Skip to content

Commit

Permalink
"Last of the typos"
Browse files Browse the repository at this point in the history
  • Loading branch information
krimsonkla committed Nov 1, 2021
1 parent c203040 commit 785e10f
Show file tree
Hide file tree
Showing 176 changed files with 449 additions and 449 deletions.
16 changes: 8 additions & 8 deletions Docker/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@

## Introduction

This walkthrough is broken up into to parts: a quick-start guide to running [Superalgos](https://github.com/Superalgos/Superalgos) with Docker and a deeper, more theoretical dive into containers with the hopes of explaining some of the design decisions.
This walk through is broken up into to parts: a quick-start guide to running [Superalgos](https://github.com/Superalgos/Superalgos) with Docker and a deeper, more theoretical dive into containers with the hopes of explaining some of the design decisions.

[Superalgos](https://github.com/Superalgos/Superalgos), at its core, is a web application which also means it can be deployed inside a container like many other web applications. One of the leading platforms for operating containers is Docker. Docker can run on many different operatng systems and compute platforms. The containers provide an easy, fast, repeatable, and secure way to deploy and distribute applications. While it doesn't take much experience to run containers or Docker, there are some basics that any user should learn in order to use the technology effectively.
[Superalgos](https://github.com/Superalgos/Superalgos), at its core, is a web application which also means it can be deployed inside a container like many other web applications. One of the leading platforms for operating containers is Docker. Docker can run on many different operating systems and compute platforms. The containers provide an easy, fast, repeatable, and secure way to deploy and distribute applications. While it doesn't take much experience to run containers or Docker, there are some basics that any user should learn in order to use the technology effectively.

Before getting started, be aware that Docker is not the originally intended method of running the [Superalgos](https://github.com/Superalgos/Superalgos) application and as such there are some drawbacks to doing so. Namely, you won't be able contribute back to the project or configure your Governance profile. We'll discuss this more later. Therefore, you should only consider using the Docker container for production deployments.

Expand Down Expand Up @@ -55,7 +55,7 @@ Docker should automatically start after installation. If you don't see the whale

### Linux and BSD

On Linux and BSD systems, Docker can be installed using the prefered package manager. [Step by step instructions for many different distributions](https://docs.docker.com/engine/install/debian/) of Linux can be found in the official Docker Docs. Since [Superalgos](https://github.com/Superalgos/Superalgos) runs well on Raspberry Pi 4 single-board computers, I'm going to illustrate the commands necessary to run [Superalgos](https://github.com/Superalgos/Superalgos) on the Raspbian Linux distribution.
On Linux and BSD systems, Docker can be installed using the preferred package manager. [Step by step instructions for many different distributions](https://docs.docker.com/engine/install/debian/) of Linux can be found in the official Docker Docs. Since [Superalgos](https://github.com/Superalgos/Superalgos) runs well on Raspberry Pi 4 single-board computers, I'm going to illustrate the commands necessary to run [Superalgos](https://github.com/Superalgos/Superalgos) on the Raspbian Linux distribution.

```shell
# install the requirements
Expand All @@ -70,7 +70,7 @@ sudo apt-get install \
# add the gpg keys to verify the packages
curl -fsSL https://download.docker.com/linux/debian/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg

# confgure the official repository
# configure the official repository
echo \
"deb [arch=arm64 signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/debian \
$(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
Expand All @@ -84,7 +84,7 @@ Docker should automatically start when it is done installing. You can check its

## Running Superalgos

Now that we have Docker installed and running, we can run the container. The option `--rm` will remove the isntance of the container when it is exited.
Now that we have Docker installed and running, we can run the container. The option `--rm` will remove the instance of the container when it is exited.

```shell
docker run --rm ghcr.io/superalgos/superalgos:latest
Expand Down Expand Up @@ -147,7 +147,7 @@ Continue reading the [Docker Command Line documentation](https://docs.docker.com

### Using Docker-Compose

Docker-compose is a wrapper for the Docker API which makes it a little easier to maintain a declaritive configuration for an application instead of using the direct command line commands. There is a sample docker-compose configuration included in the [Superalgos](https://github.com/Superalgos/Superalgos) which you can as the basis for your own configuration.
Docker-compose is a wrapper for the Docker API which makes it a little easier to maintain a declarative configuration for an application instead of using the direct command line commands. There is a sample docker-compose configuration included in the [Superalgos](https://github.com/Superalgos/Superalgos) which you can as the basis for your own configuration.

Let's download the sample and edit it. If you don't use `vim`, change that command for your preferred editor.

Expand Down Expand Up @@ -236,10 +236,10 @@ Docker has many advantages which can aid in every step from development through
Docker maintains a list of [Dockerfile best practices](https://docs.docker.com/develop/develop-images/dockerfile_best-practices/) in their main documentation. These tips dictate many of the decisions around the Superalgos Dockerfile. Some of the tips that are used by [Superalgos](https://github.com/Superalgos/Superalgos) are listed below.

- Use `.dockerignore` to prevent unwanted data from entering the container. This keeps the container small but also enhances security to prevent secrets from leaking into a container by accident.
- Don't install unneccesary packages. In lieu of multi-stage builds, build caches and build dependencies are removed before finalizing the container. Only packages that are necessary for the execution of the application are installed. This is why `git` is not present.
- Don't install unnecessary packages. In lieu of multi-stage builds, build caches and build dependencies are removed before finalizing the container. Only packages that are necessary for the execution of the application are installed. This is why `git` is not present.
- Minimize the number of layers. Many `RUN` commands are combined into one using `&&` in order to reduce the number of layers.
- Sort multiline arguments. This mostly enhances readability and maintainability.
- Leverage build cache. When testing locally, several of the tips above help levarage the build cache and speed up build times.
- Leverage build cache. When testing locally, several of the tips above help leverage the build cache and speed up build times.

### Twelve Factor App

Expand Down
6 changes: 3 additions & 3 deletions Platform/Client/taskManagerServer.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@

let path = global.env.BASE_PATH + '/TaskServerRoot.js'

/* Workarround to avoid having the same debug port at the forked process which makes it crash. */
/* Workaround to avoid having the same debug port at the forked process which makes it crash. */
for (let i = 0; i < process.execArgv.length; i++) {
let argument = process.execArgv[i]
if (argument.indexOf('--inspect') > -1) {
Expand Down Expand Up @@ -94,7 +94,7 @@
console.log(`[ERROR] Client -> Task Manager Server -> runTask -> Task Server exited with error ${err}`)
tasksMap.delete(task.id)
})
/* If the Tast Server stops, we remove it from our task map */
/* If the Task Server stops, we remove it from our task map */
task.childProcess.on('close', (code, signal) => {
//console.log('[INFO] Client -> Task Manager Server -> runTask -> Task Terminated. -> Task Name = ' + task.name)
//console.log('[INFO] Client -> Task Manager Server -> runTask -> Task Terminated. -> Task Id = ' + task.id)
Expand Down Expand Up @@ -190,7 +190,7 @@


function finalize() {
/* Before disconnecting we will forze all eventListeners to stop listening. */
/* Before disconnecting we will force all eventListeners to stop listening. */
const eventListenersArray = [...eventListeners.values()]
for (let i = 0; i < eventListenersArray.length; i++) {
let handler = eventListenersArray[i]
Expand Down
2 changes: 1 addition & 1 deletion Platform/Client/webSocketsInterface.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
try {
if (global.env.DEMO_MODE === true) {
/*
In DEMO MODE we will accept Task / Sessioins Running or Stopping if you are requesting this from localhost only.
In DEMO MODE we will accept Task / Sessions Running or Stopping if you are requesting this from localhost only.
*/
if (socket._socket.remoteAddress !== "::1") {
if (
Expand Down
2 changes: 1 addition & 1 deletion Platform/PlatformApp.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ exports.newPlatformApp = function newPlatformApp() {
})

process.on('unhandledRejection', (reason, p) => {
// Signal user that a necissary node module is missing
// Signal user that a necessary node module is missing
if (reason.code == 'MODULE_NOT_FOUND') {
console.log("[ERROR] Dependency library not found. Please try running the 'node setup' command and then restart the Superalgos Platform Client.")
console.log('[ERROR] Platform App -> reason = ' + JSON.stringify(reason))
Expand Down
2 changes: 1 addition & 1 deletion Platform/UI/ProductStorage.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ function newProductStorage(name) {
/*
This object will initialize children objects that will end up loading the data of each set defined at each product of the bot received at initialization.
Once all the underlaying objects are fully initialized it will callback.
Once all the underlying objects are fully initialized it will callback.
At the same time it will raise an event for each underlaying file being loaded, so that the UI can reflect the progress to the end user.
Expand Down
2 changes: 1 addition & 1 deletion Platform/UI/Utilities.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ function getSchemaDocument(node, project) {
even those can fail. For that reason, we will temporally see if we can find the schema document at any of the
available projects.
TODO: We need to explictly declare the project of a relatedUIObject in order to avoid potential name collision
TODO: We need to explicitly declare the project of a relatedUIObject in order to avoid potential name collision
between nodes belonging to more than one project.
*/

Expand Down
4 changes: 2 additions & 2 deletions PlatformRoot.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ load all node dependencies and get them ready to the actual App.
*/

/*
The PL object is accesible everywhere at the Superalgos Platform Client.
The PL object is accessible everywhere at the Superalgos Platform Client.
It provides access to all modules built for this Client.
*/
global.PL = {}
/*
The SA object is accesible everywhere at the Superalgos Desktop App.
The SA object is accessible everywhere at the Superalgos Desktop App.
It provides access to all modules built for Superalgos in general.
*/
global.SA = {}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
exports.newAlgorithmicTradingBotModulesOrdersCalculations = function (processIndex) {
/*
When we are live trading, we need to syncronize with the exchange.
When we are live trading, we need to synchronize with the exchange.
*/

let thisObject = {
Expand Down Expand Up @@ -48,7 +48,7 @@ exports.newAlgorithmicTradingBotModulesOrdersCalculations = function (processInd
If it happens that the size accepted (Actual Size) is different than the
size requested (Size), we need to make several adjustments so that the
accounting syncronizes with reality.
accounting synchronizes with reality.
*/

/* This calculation needs to happen only once, the first time the order is checked. */
Expand All @@ -65,8 +65,8 @@ exports.newAlgorithmicTradingBotModulesOrdersCalculations = function (processInd
function recalculateActualSize() {
/*
We will recalculate the Quoted Asset Actual Size. This will also give to it an initial value.
In the next formula, we are unsing the rate of the order because we dont know yet the Actual Rate.
This rate might be replaced afteerwards for the Actual Rate when this is calculated again once
In the next formula, we are using the rate of the order because we dont know yet the Actual Rate.
This rate might be replaced afterwards for the Actual Rate when this is calculated again once
the Actual Rate is known.
*/
tradingEngineOrder.orderQuotedAsset.actualSize.value = tradingEngineOrder.orderBaseAsset.actualSize.value * tradingEngineOrder.rate.value
Expand Down Expand Up @@ -133,7 +133,7 @@ exports.newAlgorithmicTradingBotModulesOrdersCalculations = function (processInd
tradingEngineOrder.orderStatistics.actualRate.value = TS.projects.foundations.utilities.miscellaneousFunctions.truncateToThisPrecision(tradingEngineOrder.orderStatistics.actualRate.value, 10)

/*
If the Actual Rate happens to be exctly the same than the order rate, then there is
If the Actual Rate happens to be exactly the same than the order rate, then there is
nothing else to do here. Otherwise there are adjustments to be made.
*/
if (tradingEngineOrder.orderStatistics.actualRate.value === tradingEngineOrder.rate.value) { return }
Expand All @@ -146,12 +146,12 @@ exports.newAlgorithmicTradingBotModulesOrdersCalculations = function (processInd
function recalculateActualSize() {
/*
Now we know the Actual Rate at which the order was filled. Since the actual rate
is not the same as the Rate we defined for the order, we need to syncronize
is not the same as the Rate we defined for the order, we need to synchronize
the Actual Order Size for Quoted Asset since it was calculated with the Order Size that we
now know it is not the one really used at the exchange. We will recalculate the
Actual Size in Quoted Asset and not in Base Asset, since the Actual Size in Base Asset
is the one we accepted by the exchange, so that is fixed, regardless of how we initially
got the Order Size in Base Asset, either from direct imput from the user or calculated
got the Order Size in Base Asset, either from direct input from the user or calculated
from the Order Size in Quoted Asset input it by the user. So here we go.
*/
previousQuotedAssetActualSize = tradingEngineOrder.orderQuotedAsset.actualSize.value
Expand Down Expand Up @@ -270,7 +270,7 @@ exports.newAlgorithmicTradingBotModulesOrdersCalculations = function (processInd
async function feesPaidCalculation(tradingEngineStage, tradingSystemOrder, tradingEngineOrder, order, applyFeePercentage) {
/*
Within the order information received from the exchange we can not see the fees paid so we need to
calculate them ourselves. Knwowing the Fees Paid is critical to later update the balances correctly,
calculate them ourselves. Knowing the Fees Paid is critical to later update the balances correctly,
since at every trade we will receive less than just the Actual Size. In fact we will receive the Actual
Size minus the Fees Paid.
Expand Down Expand Up @@ -324,7 +324,7 @@ exports.newAlgorithmicTradingBotModulesOrdersCalculations = function (processInd
/*
This calculation is for informational purposes, so that users do not have to calculate
it by themselves. The Amount Received out of the trade depends if we are Buying or Selling
the Base Asset. If we are Buying, then the Amount Receiced will be in Base Asset. If we
the Base Asset. If we are Buying, then the Amount Received will be in Base Asset. If we
are selling then it will be in Quoted Asset.
*/

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ exports.newAlgorithmicTradingBotModulesOrdersSimulations = function (processInde
async function actualSizeSimulation(tradingEngineStage, tradingSystemOrder, tradingEngineOrder, applyFeePercentage) {
/*
The Actual Size is the size the exchange accepts for the order,
regarless of the size sent in the request to the exchange.
regardless of the size sent in the request to the exchange.
While backtesting and paper trading, we do not really need to
simulate an Actual Size. We will just copy to that field the
Expand Down Expand Up @@ -81,7 +81,7 @@ exports.newAlgorithmicTradingBotModulesOrdersSimulations = function (processInde
switch (tradingEngineOrder.type) {
case 'Market Order': {

/* Actual Rate is simulated based on the Session Paremeters */
/* Actual Rate is simulated based on the Session Parameters */
let slippageAmount = tradingEngineOrder.rate.value * sessionParameters.slippage.config.marketOrderRate / 100
if (slippageAmount !== 0) {
switch (tradingSystemOrder.type) {
Expand Down Expand Up @@ -197,7 +197,7 @@ exports.newAlgorithmicTradingBotModulesOrdersSimulations = function (processInde
Until here we have got the Actual Rate based on the formula definition or based on session parameters slippage.
The last check is about watching what happened in the market. Let's remember that the exchange will
fill the order with the best possible matches at it's order book. That means that if the rate
we set for the order was too low (for a sale order) or too hight (for a buy order), the actual rate
we set for the order was too low (for a sale order) or too height (for a buy order), the actual rate
should be better than expected.
We don't know what it is at the order book, but whe know that the last candle includes trades that bounced between
Expand Down Expand Up @@ -303,7 +303,7 @@ exports.newAlgorithmicTradingBotModulesOrdersSimulations = function (processInde
if (tradingEngineOrder.orderStatistics.actualRate.value === tradingEngineOrder.rate.value) { return }
/*
Since the Actual Rate might have changed, we need to recalculate the Size Placed, where we accumulate all the Size Placed of
all orders of a Stage. For Base Asset there is nothing to do, since the Actual Rate does not have an inpact on it.
all orders of a Stage. For Base Asset there is nothing to do, since the Actual Rate does not have an impact on it.
For Quoted Asset, we need to first unaccount what this same orded added before to Size Placed (with the precious Actual Size) and
account with the new Actual Size.
Expand Down Expand Up @@ -462,7 +462,7 @@ exports.newAlgorithmicTradingBotModulesOrdersSimulations = function (processInde
}

/*
Another way to simulate the Fees Paid is by using the Session Paremeters configuration for Fees.
Another way to simulate the Fees Paid is by using the Session Parameters configuration for Fees.
*/
switch (tradingEngineOrder.type) {
case 'Market Order': {
Expand Down Expand Up @@ -510,7 +510,7 @@ exports.newAlgorithmicTradingBotModulesOrdersSimulations = function (processInde
/*
This simulation is for informational purposes, so that users do not have to calculate
it by themselves. The Amount Received out of the trade depends if we are Buying or Selling
the Base Asset. If we are Buying, then the Amount Receiced will be in Base Asset. If we
the Base Asset. If we are Buying, then the Amount Received will be in Base Asset. If we
are selling then it will be in Quoted Asset.
*/

Expand Down
Loading

0 comments on commit 785e10f

Please sign in to comment.