From c70b4a6237e3ffdf3f0e7f558b3c904fc415c695 Mon Sep 17 00:00:00 2001 From: Benjamin Date: Sat, 3 Jul 2021 09:48:33 -0400 Subject: [PATCH 1/4] added sandbox mode --- .../Schemas/App-Schema/crypto-exchange.json | 268 ++++++++---------- .../Crypto-Exchange/crypto-exchange.json | 166 +++++------ .../Low-Frequency-Trading/APIs/ExchangeAPI.js | 153 +++++----- 3 files changed, 285 insertions(+), 302 deletions(-) diff --git a/Projects/Foundations/Schemas/App-Schema/crypto-exchange.json b/Projects/Foundations/Schemas/App-Schema/crypto-exchange.json index 103c66930..3501a8027 100644 --- a/Projects/Foundations/Schemas/App-Schema/crypto-exchange.json +++ b/Projects/Foundations/Schemas/App-Schema/crypto-exchange.json @@ -1,148 +1,124 @@ { - "type": "Crypto Exchange", - "menuItems": [ - { - "action": "Configure Thise", - "actionFunction": "uiObject.configEditor.activate", - "label": "Configure", - "iconPathOn": "configuration", - "iconPathOff": "configuration" - }, - { - "action": "Add UI Object", - "disableIfPropertyIsDefined": true, - "propertyToCheckFor": "exchangeAssets", - "label": "Add Exchange Assets", - "relatedUiObject": "Exchange Assets", - "actionFunction": "payload.executeAction" - }, - { - "action": "Add UI Object", - "disableIfPropertyIsDefined": true, - "propertyToCheckFor": "exchangeMarkets", - "label": "Add Exchange Markets", - "relatedUiObject": "Exchange Markets", - "actionFunction": "payload.executeAction" - }, - { - "action": "Add UI Object", - "disableIfPropertyIsDefined": true, - "propertyToCheckFor": "exchangeAccounts", - "label": "Add Exchange Accounts", - "relatedUiObject": "Exchange Accounts", - "actionFunction": "payload.executeAction" - }, - { - "action": "Delete UI Object", - "askConfirmation": true, - "confirmationLabel": "Confirm to Delete", - "label": "Delete", - "iconPathOn": "delete-entity", - "iconPathOff": "delete-entity", - "actionFunction": "payload.executeAction" - } - ], - "isTitleAllwaysVisible": true, - "addLeftIcons": true, - "level": 2, - "editors": { - "config": true - }, - "initialValues": { - "config": "{ \n\"codeName\": \"Type the name of the exchange\"\n}" - }, - "attachingRules": { - "compatibleTypes": "->Crypto Exchanges->" - }, - "propertyNameAtParent": "exchanges", - "childrenNodesProperties": [ - { - "name": "exchangeAssets", - "type": "node", - "childType": "Exchange Assets", - "autoAdd": true - }, - { - "name": "exchangeMarkets", - "type": "node", - "childType": "Exchange Markets", - "autoAdd": true - }, - { - "name": "exchangeAccounts", - "type": "node", - "childType": "Exchange Accounts", - "autoAdd": true - } - ], - "alternativeIcons": [ - { - "codeName": "binance", - "iconName": "binance" - }, - { - "codeName": "binanceus", - "iconName": "binanceus" - }, - { - "codeName": "bitfinex", - "iconName": "bitfinex" - }, - { - "codeName": "bitmex", - "iconName": "bitmex" - }, - { - "codeName": "bittrex", - "iconName": "bittrex" - }, - { - "codeName": "coinbasepro", - "iconName": "coinbasepro" - }, - { - "codeName": "ftx", - "iconName": "ftx" - }, - { - "codeName": "hitbtc", - "iconName": "hitbtc" - }, - { - "codeName": "kraken", - "iconName": "kraken" - }, - { - "codeName": "kucoin", - "iconName": "kucoin" - }, - { - "codeName": "liquid", - "iconName": "liquid" - }, - { - "codeName": "luno", - "iconName": "luno" - }, - { - "codeName": "lykke", - "iconName": "lykke" - }, - { - "codeName": "okex", - "iconName": "okex" - }, - { - "codeName": "okex5", - "iconName": "okex" - }, - { - "codeName": "poloniex", - "iconName": "poloniex" - }, - { - "codeName": "upbit", - "iconName": "upbit" - } - ] + "type": "Crypto Exchange", + "menuItems": [ + { + "action": "Configure Thise", + "actionFunction": "uiObject.configEditor.activate", + "label": "Configure", + "iconPathOn": "configuration", + "iconPathOff": "configuration" + }, + { + "action": "Add UI Object", + "disableIfPropertyIsDefined": true, + "propertyToCheckFor": "exchangeAssets", + "label": "Add Exchange Assets", + "relatedUiObject": "Exchange Assets", + "actionFunction": "payload.executeAction" + }, + { + "action": "Add UI Object", + "disableIfPropertyIsDefined": true, + "propertyToCheckFor": "exchangeMarkets", + "label": "Add Exchange Markets", + "relatedUiObject": "Exchange Markets", + "actionFunction": "payload.executeAction" + }, + { + "action": "Add UI Object", + "disableIfPropertyIsDefined": true, + "propertyToCheckFor": "exchangeAccounts", + "label": "Add Exchange Accounts", + "relatedUiObject": "Exchange Accounts", + "actionFunction": "payload.executeAction" + }, + { + "action": "Delete UI Object", + "askConfirmation": true, + "confirmationLabel": "Confirm to Delete", + "label": "Delete", + "iconPathOn": "delete-entity", + "iconPathOff": "delete-entity", + "actionFunction": "payload.executeAction" + } + ], + "isTitleAllwaysVisible": true, + "addLeftIcons": true, + "level": 2, + "editors": { + "config": true + }, + "initialValues": { + "config": "{ \n\"codeName\": \"Type the name of the exchange\",\n \n\"sandBox\": \"false\"\n}" + }, + "attachingRules": { + "compatibleTypes": "->Crypto Exchanges->" + }, + "propertyNameAtParent": "exchanges", + "childrenNodesProperties": [ + { + "name": "exchangeAssets", + "type": "node", + "childType": "Exchange Assets", + "autoAdd": true + }, + { + "name": "exchangeMarkets", + "type": "node", + "childType": "Exchange Markets", + "autoAdd": true + }, + { + "name": "exchangeAccounts", + "type": "node", + "childType": "Exchange Accounts", + "autoAdd": true + } + ], + "alternativeIcons": [ + { + "codeName": "bitfinex", + "iconName": "bitfinex" + }, + { + "codeName": "binance", + "iconName": "binance" + }, + { + "codeName": "kucoin", + "iconName": "kucoin" + }, + { + "codeName": "bittrex", + "iconName": "bittrex" + }, + { + "codeName": "kraken", + "iconName": "kraken" + }, + { + "codeName": "poloniex", + "iconName": "poloniex" + }, + { + "codeName": "upbit", + "iconName": "upbit" + }, + { + "codeName": "bitmex", + "iconName": "bitmex" + }, + { + "codeName": "liquid", + "iconName": "liquid" + }, + { + "codeName": "hitbtc", + "iconName": "hitbtc" + }, + { + "codeName": "luno", + "iconName": "luno" + } + ] } \ No newline at end of file diff --git a/Projects/Foundations/Schemas/Docs-Nodes/C/Crypto/Crypto-Exchange/crypto-exchange.json b/Projects/Foundations/Schemas/Docs-Nodes/C/Crypto/Crypto-Exchange/crypto-exchange.json index cfbaec461..f59d5d576 100644 --- a/Projects/Foundations/Schemas/Docs-Nodes/C/Crypto/Crypto-Exchange/crypto-exchange.json +++ b/Projects/Foundations/Schemas/Docs-Nodes/C/Crypto/Crypto-Exchange/crypto-exchange.json @@ -1,83 +1,87 @@ { - "type": "Crypto Exchange", - "definition": { - "text": "A crypto exchange node holds the definitions of assets and markets in a specific exchange." - }, - "paragraphs": [ - { - "style": "Block", - "text": "Configuring" - }, - { - "style": "Title", - "text": "Tested Exchanges", - "updated": 1615200855230 - }, - { - "style": "Text", - "text": "In theory, Superalgos supports dozens of exchanges. However, each exchange must go through a testing process, as not all of them conform to the standard proposed by the CCXT library.", - "updated": 1615201479524 - }, - { - "style": "List", - "text": "Binance Test Status", - "updated": 1615203667257 - }, - { - "style": "List", - "text": "Binance-US Test Status" - }, - { - "style": "List", - "text": "Bitfinex Test Status" - }, - { - "style": "List", - "text": "Bittrex Test Status" - }, - { - "style": "List", - "text": "CoinbasePro Test Status" - }, - { - "style": "List", - "text": "FTX Test Status", - "updated": 1615203669878 - }, - { - "style": "List", - "text": "Kraken Test Status", - "updated": 1615453046113 - }, - { - "style": "List", - "text": "Kucoin Test Status" - }, - { - "style": "List", - "text": "Luno Test Status" - }, - { - "style": "Title", - "text": "Crypto Exchange Configuration" - }, - { - "style": "Text", - "text": "Each exchange may require a very specific configuration. This is determined during the exchange testing process. Consult the page of each exchange as listed above. If you are interested in testing a new exchange, go to the How to Test New Exchanges page.", - "updated": 1615201685376 - }, - { - "style": "Subtitle", - "text": "Properties", - "updated": 1609771684679 - }, - { - "style": "List", - "text": "codeName is the name of the exchange as handled in the code of the system." - }, - { - "style": "List", - "text": "API holds a series of definitions used only in the case in which the sensor bot fetches trades (using the Historic-Trades process) instead of the OHLCV process that fetches one-minute candles and is the current default. In such a case, finding the right set of parameters to work with a specific exchange may be challenging, nd involves understanding how the exchanges API and the CCXT Library API work. In other words, there is no hard rule as of what each of the values should be. Determining each of this values requires exploring the exchange's API documentation, as well as the documentation of the CCXT Library." - } - ] + "type": "Crypto Exchange", + "definition": { + "text": "A crypto exchange node holds the definitions of assets and markets in a specific exchange." + }, + "paragraphs": [ + { + "style": "Block", + "text": "Configuring" + }, + { + "style": "Title", + "text": "Tested Exchanges", + "updated": 1615200855230 + }, + { + "style": "Text", + "text": "In theory, Superalgos supports dozens of exchanges. However, each exchange must go through a testing process, as not all of them conform to the standard proposed by the CCXT library.", + "updated": 1615201479524 + }, + { + "style": "List", + "text": "Binance Test Status", + "updated": 1615203667257 + }, + { + "style": "List", + "text": "Binance-US Test Status" + }, + { + "style": "List", + "text": "Bitfinex Test Status" + }, + { + "style": "List", + "text": "Bittrex Test Status" + }, + { + "style": "List", + "text": "CoinbasePro Test Status" + }, + { + "style": "List", + "text": "FTX Test Status", + "updated": 1615203669878 + }, + { + "style": "List", + "text": "Kraken Test Status", + "updated": 1615453046113 + }, + { + "style": "List", + "text": "Kucoin Test Status" + }, + { + "style": "List", + "text": "Luno Test Status" + }, + { + "style": "Title", + "text": "Crypto Exchange Configuration" + }, + { + "style": "Text", + "text": "Each exchange may require a very specific configuration. This is determined during the exchange testing process. Consult the page of each exchange as listed above. If you are interested in testing a new exchange, go to the How to Test New Exchanges page.", + "updated": 1615201685376 + }, + { + "style": "Subtitle", + "text": "Properties", + "updated": 1609771684679 + }, + { + "style": "List", + "text": "codeName is the name of the exchange as handled in the code of the system." + }, + { + "style": "List", + "text": "sandBox setting this parameter to true allows SuperAlgos to perform live trading on the exchanges sandbox or testnet if one is available." + }, + { + "style": "List", + "text": "API holds a series of definitions used only in the case in which the sensor bot fetches trades (using the Historic-Trades process) instead of the OHLCV process that fetches one-minute candles and is the current default. In such a case, finding the right set of parameters to work with a specific exchange may be challenging, nd involves understanding how the exchanges API and the CCXT Library API work. In other words, there is no hard rule as of what each of the values should be. Determining each of this values requires exploring the exchange's API documentation, as well as the documentation of the CCXT Library." + } + ] } \ No newline at end of file diff --git a/Projects/Foundations/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/ExchangeAPI.js b/Projects/Foundations/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/ExchangeAPI.js index 94efc1a52..d5155dbc9 100644 --- a/Projects/Foundations/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/ExchangeAPI.js +++ b/Projects/Foundations/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/ExchangeAPI.js @@ -1,7 +1,7 @@ -exports.newFoundationsBotModulesExchangeAPI = function (processIndex) { +exports.newSuperalgosBotModulesExchangeAPI = function (processIndex) { let MODULE_NAME = "Exchange API"; - + let thisObject = { getOrder: getOrder, createOrder: createOrder, @@ -9,33 +9,34 @@ initialize: initialize, finalize: finalize }; - + let tradingSystem - + let exchangeId let options = {} let exchange - + const ccxt = require('ccxt') - + return thisObject; - + function initialize() { - tradingSystem = TS.projects.foundations.globals.processVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).SIMULATION_STATE.tradingSystem - - exchangeId = TS.projects.foundations.globals.taskConstants.TASK_NODE.parentNode.parentNode.parentNode.referenceParent.parentNode.parentNode.config.codeName - + tradingSystem = TS.projects.superalgos.globals.processVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).SIMULATION_STATE.tradingSystem + + exchangeId = TS.projects.superalgos.globals.taskConstants.TASK_NODE.parentNode.parentNode.parentNode.referenceParent.parentNode.parentNode.config.codeName + let key let secret let uid let password - - if (TS.projects.foundations.globals.taskConstants.TASK_NODE.keyReference !== undefined) { - if (TS.projects.foundations.globals.taskConstants.TASK_NODE.keyReference.referenceParent !== undefined) { - key = TS.projects.foundations.globals.taskConstants.TASK_NODE.keyReference.referenceParent.config.codeName - secret = TS.projects.foundations.globals.taskConstants.TASK_NODE.keyReference.referenceParent.config.secret - uid = TS.projects.foundations.globals.taskConstants.TASK_NODE.keyReference.referenceParent.config.uid - password = TS.projects.foundations.globals.taskConstants.TASK_NODE.keyReference.referenceParent.config.password + let sandBox = TS.projects.superalgos.globals.taskConstants.TASK_NODE.parentNode.parentNode.parentNode.referenceParent.parentNode.parentNode.config.sandbox || false; + + if (TS.projects.superalgos.globals.taskConstants.TASK_NODE.keyReference !== undefined) { + if (TS.projects.superalgos.globals.taskConstants.TASK_NODE.keyReference.referenceParent !== undefined) { + key = TS.projects.superalgos.globals.taskConstants.TASK_NODE.keyReference.referenceParent.config.codeName + secret = TS.projects.superalgos.globals.taskConstants.TASK_NODE.keyReference.referenceParent.config.secret + uid = TS.projects.superalgos.globals.taskConstants.TASK_NODE.keyReference.referenceParent.config.uid + password = TS.projects.superalgos.globals.taskConstants.TASK_NODE.keyReference.referenceParent.config.password } } const exchangeClass = ccxt[exchangeId] @@ -50,40 +51,48 @@ 'adjustForTimeDifference': true, options: options } - exchange = new exchangeClass(exchangeConstructorParams) + exchange = new exchangeClass(exchangeConstructorParams); + // enable sandbox mode based on exchange sandbox param value + if (sandBox) { + exchange.setSandboxMode(sandBox); + } + console.log('Sandbox mode = ' + sandBox); + + // uncomment the following line if you want to log the exchange api being used + // console.log(exchange.urls.api); } - + function finalize() { tradingSystem = undefined exchangeId = undefined options = undefined exchange = undefined } - + async function getOrder(tradingSystemOrder, tradingEngineOrder) { - + let orderId = tradingEngineOrder.exchangeId.value - const symbol = TS.projects.foundations.globals.taskConstants.TASK_NODE.parentNode.parentNode.parentNode.referenceParent.baseAsset.referenceParent.config.codeName + '/' + TS.projects.foundations.globals.taskConstants.TASK_NODE.parentNode.parentNode.parentNode.referenceParent.quotedAsset.referenceParent.config.codeName - + const symbol = TS.projects.superalgos.globals.taskConstants.TASK_NODE.parentNode.parentNode.parentNode.referenceParent.baseAsset.referenceParent.config.codeName + '/' + TS.projects.superalgos.globals.taskConstants.TASK_NODE.parentNode.parentNode.parentNode.referenceParent.quotedAsset.referenceParent.config.codeName + /* Basic Logging */ logInfo("getOrder -> orderId = " + orderId) logInfo("getOrder -> symbol = " + symbol) - + /* Basic Validations */ if (exchange.has['fetchOrder'] === false) { logError("getOrder -> Exchange does not support fetchOrder command."); return } - + try { let order = await exchange.fetchOrder(orderId, symbol) - + logInfo("getOrder -> Response from the Exchange: " + JSON.stringify(order)); return order } catch (err) { const message = 'Get Order Unexpected Error' let docs = { - project: 'Foundations', + project: 'Superalgos', category: 'Topic', type: 'TS LF Trading Bot Error - ' + message, placeholder: {} @@ -92,30 +101,23 @@ symbol: symbol, orderId: orderId } - - TS.projects.education.utilities.docsFunctions.buildPlaceholder(docs, err, tradingSystemOrder.name, undefined, undefined, undefined, contextInfo) - + + TS.projects.superalgos.utilities.docsFunctions.buildPlaceholder(docs, err, tradingSystemOrder.name, undefined, undefined, undefined, contextInfo) + tradingSystem.addError([tradingSystemOrder.id, message, docs]) - + logError("getOrder -> Error = " + err.message); - if ( /[0-9a-z]+ NotFound/.test(err.message) ) { - logInfo("getOrder -> NotFound, so order is actually closed.") - order = { - status: 'NotFound' - } - return order - } } } - + async function createOrder(tradingSystemOrder, tradingEngineOrder) { - + let price = tradingEngineOrder.rate.value // CCXT: how much quote currency you are willing to pay for a trade lot of base currency (for limit orders only) let type // CCXT: a string literal type of order, ccxt currently unifies market and limit orders only let side // CCXT: a string literal for the direction of your order, buy or sell - let symbol = TS.projects.foundations.globals.taskConstants.TASK_NODE.parentNode.parentNode.parentNode.referenceParent.baseAsset.referenceParent.config.codeName + '/' + TS.projects.foundations.globals.taskConstants.TASK_NODE.parentNode.parentNode.parentNode.referenceParent.quotedAsset.referenceParent.config.codeName // CCXT: a string literal symbol of the market you wish to trade on, like BTC/USD, ZEC/ETH, DOGE/DASH, etc + let symbol = TS.projects.superalgos.globals.taskConstants.TASK_NODE.parentNode.parentNode.parentNode.referenceParent.baseAsset.referenceParent.config.codeName + '/' + TS.projects.superalgos.globals.taskConstants.TASK_NODE.parentNode.parentNode.parentNode.referenceParent.quotedAsset.referenceParent.config.codeName // CCXT: a string literal symbol of the market you wish to trade on, like BTC/USD, ZEC/ETH, DOGE/DASH, etc let amount = tradingEngineOrder.orderBaseAsset.size.value // CCXT: how much of currency you want to trade, in Base Asset. - + switch (tradingSystemOrder.type) { case 'Market Buy Order': { type = 'market' @@ -138,14 +140,14 @@ break } } - + /* Basic Logging */ logInfo("createOrder -> symbol = " + symbol); logInfo("createOrder -> side = " + side); logInfo("createOrder -> type = " + type); logInfo("createOrder -> amount = " + amount); logInfo("createOrder -> price = " + price); - + /* Basic Validations */ if (side !== "buy" && side !== "sell") { logError("createOrder -> side must be either 'buy' or 'sell'."); @@ -155,17 +157,17 @@ logError("createOrder -> Exchange does not support createOrder command."); return } - + try { let order = await (exchange.createOrder(symbol, type, side, amount, price)) - + logInfo("createOrder -> Response from the Exchange: " + JSON.stringify(order)); return order.id } catch (err) { - - let exchangeApiKey = TS.projects.foundations.globals.taskConstants.TASK_NODE.keyReference.referenceParent + + let exchangeApiKey = TS.projects.superalgos.globals.taskConstants.TASK_NODE.keyReference.referenceParent let message = 'Create Order Unexpected Error' - + logError("createOrder -> Error = " + err.message) logError("createOrder -> symbol = " + symbol); logError("createOrder -> side = " + side); @@ -179,7 +181,7 @@ ) { logError('The exchange says the API key provided is not good or it is not in the correct format. This is what you are using:') errorFooter() - + message = 'Invalid Exchange API Key' } if ( @@ -188,17 +190,17 @@ ) { logError('The exchange says the secret provided is not good, incorrect or not in the correct format. This is what you are using:') errorFooter() - + message = 'Invalid Exchange API Secret' } - + let docs = { - project: 'Foundations', + project: 'Superalgos', category: 'Topic', type: 'TS LF Trading Bot Error - ' + message, placeholder: {} } - + let contextInfo = { symbol: symbol, side: side, @@ -210,10 +212,10 @@ keyLength: exchangeApiKey.config.codeName.length, secretLength: exchangeApiKey.config.secret.length } - TS.projects.education.utilities.docsFunctions.buildPlaceholder(docs, err, exchangeApiKey.name, undefined, exchangeApiKey.config, undefined, contextInfo) - + TS.projects.superalgos.utilities.docsFunctions.buildPlaceholder(docs, err, exchangeApiKey.name, undefined, exchangeApiKey.config, undefined, contextInfo) + tradingSystem.addError([exchangeApiKey.id, message, docs]) - + function errorFooter() { logError('key: ->' + exchangeApiKey.config.codeName + '<-') logError('secret: ->' + exchangeApiKey.config.secret + '<-') @@ -224,31 +226,31 @@ } } } - + async function cancelOrder(tradingSystemOrder, tradingEngineOrder) { - + let orderId = tradingEngineOrder.exchangeId.value - + /* Basic Logging */ logInfo("cancelOrder -> Entering function. orderId = " + orderId); - - const symbol = TS.projects.foundations.globals.taskConstants.TASK_NODE.parentNode.parentNode.parentNode.referenceParent.baseAsset.referenceParent.config.codeName + '/' + TS.projects.foundations.globals.taskConstants.TASK_NODE.parentNode.parentNode.parentNode.referenceParent.quotedAsset.referenceParent.config.codeName - + + const symbol = TS.projects.superalgos.globals.taskConstants.TASK_NODE.parentNode.parentNode.parentNode.referenceParent.baseAsset.referenceParent.config.codeName + '/' + TS.projects.superalgos.globals.taskConstants.TASK_NODE.parentNode.parentNode.parentNode.referenceParent.quotedAsset.referenceParent.config.codeName + /* Basic Validations */ if (exchange.has['fetchOrder'] === false) { logError("cancelOrder -> Exchange does not support fetchOrder command."); return } - + try { let order = await exchange.cancelOrder(orderId, symbol) - + logInfo("cancelOrder -> Response from the Exchange: " + JSON.stringify(order)); return true } catch (err) { const message = 'Cancel Order Unexpected Error' let docs = { - project: 'Foundations', + project: 'Superalgos', category: 'Topic', type: 'TS LF Trading Bot Error - ' + message, placeholder: {} @@ -257,19 +259,20 @@ symbol: symbol, orderId: orderId } - - TS.projects.education.utilities.docsFunctions.buildPlaceholder(docs, err, tradingSystemOrder.name, undefined, undefined, undefined, contextInfo) - + + TS.projects.superalgos.utilities.docsFunctions.buildPlaceholder(docs, err, tradingSystemOrder.name, undefined, undefined, undefined, contextInfo) + tradingSystem.addError([tradingSystemOrder.id, message, docs]) logError("cancelOrder -> Error = " + err.message); } } - + function logInfo(message) { - TS.projects.foundations.globals.loggerVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).BOT_MAIN_LOOP_LOGGER_MODULE_OBJECT.write(MODULE_NAME, '[INFO] ' + message) + TS.projects.superalgos.globals.loggerVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).BOT_MAIN_LOOP_LOGGER_MODULE_OBJECT.write(MODULE_NAME, '[INFO] ' + message) } - + function logError(message) { - TS.projects.foundations.globals.loggerVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).BOT_MAIN_LOOP_LOGGER_MODULE_OBJECT.write(MODULE_NAME, '[ERROR] ' + message) + TS.projects.superalgos.globals.loggerVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).BOT_MAIN_LOOP_LOGGER_MODULE_OBJECT.write(MODULE_NAME, '[ERROR] ' + message) } -}; + }; + \ No newline at end of file From 80ab62225c9c2f770801553e119523d28a21a4c8 Mon Sep 17 00:00:00 2001 From: Benjamin Date: Sat, 3 Jul 2021 09:54:55 -0400 Subject: [PATCH 2/4] added sandbox mode --- .../Schemas/App-Schema/crypto-exchange.json | 288 +++++++++--------- .../Crypto-Exchange/crypto-exchange.json | 166 +++++----- .../Low-Frequency-Trading/APIs/ExchangeAPI.js | 10 +- 3 files changed, 238 insertions(+), 226 deletions(-) diff --git a/Projects/Foundations/Schemas/App-Schema/crypto-exchange.json b/Projects/Foundations/Schemas/App-Schema/crypto-exchange.json index 103c66930..caec647ba 100644 --- a/Projects/Foundations/Schemas/App-Schema/crypto-exchange.json +++ b/Projects/Foundations/Schemas/App-Schema/crypto-exchange.json @@ -1,148 +1,148 @@ { - "type": "Crypto Exchange", - "menuItems": [ - { - "action": "Configure Thise", - "actionFunction": "uiObject.configEditor.activate", - "label": "Configure", - "iconPathOn": "configuration", - "iconPathOff": "configuration" - }, - { - "action": "Add UI Object", - "disableIfPropertyIsDefined": true, - "propertyToCheckFor": "exchangeAssets", - "label": "Add Exchange Assets", - "relatedUiObject": "Exchange Assets", - "actionFunction": "payload.executeAction" - }, - { - "action": "Add UI Object", - "disableIfPropertyIsDefined": true, - "propertyToCheckFor": "exchangeMarkets", - "label": "Add Exchange Markets", - "relatedUiObject": "Exchange Markets", - "actionFunction": "payload.executeAction" - }, - { - "action": "Add UI Object", - "disableIfPropertyIsDefined": true, - "propertyToCheckFor": "exchangeAccounts", - "label": "Add Exchange Accounts", - "relatedUiObject": "Exchange Accounts", - "actionFunction": "payload.executeAction" - }, - { - "action": "Delete UI Object", - "askConfirmation": true, - "confirmationLabel": "Confirm to Delete", - "label": "Delete", - "iconPathOn": "delete-entity", - "iconPathOff": "delete-entity", - "actionFunction": "payload.executeAction" - } - ], - "isTitleAllwaysVisible": true, - "addLeftIcons": true, - "level": 2, - "editors": { - "config": true + "type": "Crypto Exchange", + "menuItems": [ + { + "action": "Configure Thise", + "actionFunction": "uiObject.configEditor.activate", + "label": "Configure", + "iconPathOn": "configuration", + "iconPathOff": "configuration" }, - "initialValues": { - "config": "{ \n\"codeName\": \"Type the name of the exchange\"\n}" + { + "action": "Add UI Object", + "disableIfPropertyIsDefined": true, + "propertyToCheckFor": "exchangeAssets", + "label": "Add Exchange Assets", + "relatedUiObject": "Exchange Assets", + "actionFunction": "payload.executeAction" }, - "attachingRules": { - "compatibleTypes": "->Crypto Exchanges->" + { + "action": "Add UI Object", + "disableIfPropertyIsDefined": true, + "propertyToCheckFor": "exchangeMarkets", + "label": "Add Exchange Markets", + "relatedUiObject": "Exchange Markets", + "actionFunction": "payload.executeAction" }, - "propertyNameAtParent": "exchanges", - "childrenNodesProperties": [ - { - "name": "exchangeAssets", - "type": "node", - "childType": "Exchange Assets", - "autoAdd": true - }, - { - "name": "exchangeMarkets", - "type": "node", - "childType": "Exchange Markets", - "autoAdd": true - }, - { - "name": "exchangeAccounts", - "type": "node", - "childType": "Exchange Accounts", - "autoAdd": true - } - ], - "alternativeIcons": [ - { - "codeName": "binance", - "iconName": "binance" - }, - { - "codeName": "binanceus", - "iconName": "binanceus" - }, - { - "codeName": "bitfinex", - "iconName": "bitfinex" - }, - { - "codeName": "bitmex", - "iconName": "bitmex" - }, - { - "codeName": "bittrex", - "iconName": "bittrex" - }, - { - "codeName": "coinbasepro", - "iconName": "coinbasepro" - }, - { - "codeName": "ftx", - "iconName": "ftx" - }, - { - "codeName": "hitbtc", - "iconName": "hitbtc" - }, - { - "codeName": "kraken", - "iconName": "kraken" - }, - { - "codeName": "kucoin", - "iconName": "kucoin" - }, - { - "codeName": "liquid", - "iconName": "liquid" - }, - { - "codeName": "luno", - "iconName": "luno" - }, - { - "codeName": "lykke", - "iconName": "lykke" - }, - { - "codeName": "okex", - "iconName": "okex" - }, - { - "codeName": "okex5", - "iconName": "okex" - }, - { - "codeName": "poloniex", - "iconName": "poloniex" - }, - { - "codeName": "upbit", - "iconName": "upbit" - } - ] -} \ No newline at end of file + { + "action": "Add UI Object", + "disableIfPropertyIsDefined": true, + "propertyToCheckFor": "exchangeAccounts", + "label": "Add Exchange Accounts", + "relatedUiObject": "Exchange Accounts", + "actionFunction": "payload.executeAction" + }, + { + "action": "Delete UI Object", + "askConfirmation": true, + "confirmationLabel": "Confirm to Delete", + "label": "Delete", + "iconPathOn": "delete-entity", + "iconPathOff": "delete-entity", + "actionFunction": "payload.executeAction" + } + ], + "isTitleAllwaysVisible": true, + "addLeftIcons": true, + "level": 2, + "editors": { + "config": true + }, + "initialValues": { + "config": "{ \n\"codeName\": \"Type the name of the exchange\",\n \n\"sandBox\": \"false\"\n}" + }, + "attachingRules": { + "compatibleTypes": "->Crypto Exchanges->" + }, + "propertyNameAtParent": "exchanges", + "childrenNodesProperties": [ + { + "name": "exchangeAssets", + "type": "node", + "childType": "Exchange Assets", + "autoAdd": true + }, + { + "name": "exchangeMarkets", + "type": "node", + "childType": "Exchange Markets", + "autoAdd": true + }, + { + "name": "exchangeAccounts", + "type": "node", + "childType": "Exchange Accounts", + "autoAdd": true + } + ], + "alternativeIcons": [ + { + "codeName": "binance", + "iconName": "binance" + }, + { + "codeName": "binanceus", + "iconName": "binanceus" + }, + { + "codeName": "bitfinex", + "iconName": "bitfinex" + }, + { + "codeName": "bitmex", + "iconName": "bitmex" + }, + { + "codeName": "bittrex", + "iconName": "bittrex" + }, + { + "codeName": "coinbasepro", + "iconName": "coinbasepro" + }, + { + "codeName": "ftx", + "iconName": "ftx" + }, + { + "codeName": "hitbtc", + "iconName": "hitbtc" + }, + { + "codeName": "kraken", + "iconName": "kraken" + }, + { + "codeName": "kucoin", + "iconName": "kucoin" + }, + { + "codeName": "liquid", + "iconName": "liquid" + }, + { + "codeName": "luno", + "iconName": "luno" + }, + { + "codeName": "lykke", + "iconName": "lykke" + }, + { + "codeName": "okex", + "iconName": "okex" + }, + { + "codeName": "okex5", + "iconName": "okex" + }, + { + "codeName": "poloniex", + "iconName": "poloniex" + }, + { + "codeName": "upbit", + "iconName": "upbit" + } + ] +} diff --git a/Projects/Foundations/Schemas/Docs-Nodes/C/Crypto/Crypto-Exchange/crypto-exchange.json b/Projects/Foundations/Schemas/Docs-Nodes/C/Crypto/Crypto-Exchange/crypto-exchange.json index cfbaec461..c7a296a4f 100644 --- a/Projects/Foundations/Schemas/Docs-Nodes/C/Crypto/Crypto-Exchange/crypto-exchange.json +++ b/Projects/Foundations/Schemas/Docs-Nodes/C/Crypto/Crypto-Exchange/crypto-exchange.json @@ -1,83 +1,87 @@ { - "type": "Crypto Exchange", - "definition": { - "text": "A crypto exchange node holds the definitions of assets and markets in a specific exchange." + "type": "Crypto Exchange", + "definition": { + "text": "A crypto exchange node holds the definitions of assets and markets in a specific exchange." + }, + "paragraphs": [ + { + "style": "Block", + "text": "Configuring" }, - "paragraphs": [ - { - "style": "Block", - "text": "Configuring" - }, - { - "style": "Title", - "text": "Tested Exchanges", - "updated": 1615200855230 - }, - { - "style": "Text", - "text": "In theory, Superalgos supports dozens of exchanges. However, each exchange must go through a testing process, as not all of them conform to the standard proposed by the CCXT library.", - "updated": 1615201479524 - }, - { - "style": "List", - "text": "Binance Test Status", - "updated": 1615203667257 - }, - { - "style": "List", - "text": "Binance-US Test Status" - }, - { - "style": "List", - "text": "Bitfinex Test Status" - }, - { - "style": "List", - "text": "Bittrex Test Status" - }, - { - "style": "List", - "text": "CoinbasePro Test Status" - }, - { - "style": "List", - "text": "FTX Test Status", - "updated": 1615203669878 - }, - { - "style": "List", - "text": "Kraken Test Status", - "updated": 1615453046113 - }, - { - "style": "List", - "text": "Kucoin Test Status" - }, - { - "style": "List", - "text": "Luno Test Status" - }, - { - "style": "Title", - "text": "Crypto Exchange Configuration" - }, - { - "style": "Text", - "text": "Each exchange may require a very specific configuration. This is determined during the exchange testing process. Consult the page of each exchange as listed above. If you are interested in testing a new exchange, go to the How to Test New Exchanges page.", - "updated": 1615201685376 - }, - { - "style": "Subtitle", - "text": "Properties", - "updated": 1609771684679 - }, - { - "style": "List", - "text": "codeName is the name of the exchange as handled in the code of the system." - }, - { - "style": "List", - "text": "API holds a series of definitions used only in the case in which the sensor bot fetches trades (using the Historic-Trades process) instead of the OHLCV process that fetches one-minute candles and is the current default. In such a case, finding the right set of parameters to work with a specific exchange may be challenging, nd involves understanding how the exchanges API and the CCXT Library API work. In other words, there is no hard rule as of what each of the values should be. Determining each of this values requires exploring the exchange's API documentation, as well as the documentation of the CCXT Library." - } - ] -} \ No newline at end of file + { + "style": "Title", + "text": "Tested Exchanges", + "updated": 1615200855230 + }, + { + "style": "Text", + "text": "In theory, Superalgos supports dozens of exchanges. However, each exchange must go through a testing process, as not all of them conform to the standard proposed by the CCXT library.", + "updated": 1615201479524 + }, + { + "style": "List", + "text": "Binance Test Status", + "updated": 1615203667257 + }, + { + "style": "List", + "text": "Binance-US Test Status" + }, + { + "style": "List", + "text": "Bitfinex Test Status" + }, + { + "style": "List", + "text": "Bittrex Test Status" + }, + { + "style": "List", + "text": "CoinbasePro Test Status" + }, + { + "style": "List", + "text": "FTX Test Status", + "updated": 1615203669878 + }, + { + "style": "List", + "text": "Kraken Test Status", + "updated": 1615453046113 + }, + { + "style": "List", + "text": "Kucoin Test Status" + }, + { + "style": "List", + "text": "Luno Test Status" + }, + { + "style": "Title", + "text": "Crypto Exchange Configuration" + }, + { + "style": "Text", + "text": "Each exchange may require a very specific configuration. This is determined during the exchange testing process. Consult the page of each exchange as listed above. If you are interested in testing a new exchange, go to the How to Test New Exchanges page.", + "updated": 1615201685376 + }, + { + "style": "Subtitle", + "text": "Properties", + "updated": 1609771684679 + }, + { + "style": "List", + "text": "codeName is the name of the exchange as handled in the code of the system." + }, + { + "style": "List", + "text": "sandBox setting this parameter to true allows SuperAlgos to perform live trading on the exchanges sandbox or testnet if one is available." + }, + { + "style": "List", + "text": "API holds a series of definitions used only in the case in which the sensor bot fetches trades (using the Historic-Trades process) instead of the OHLCV process that fetches one-minute candles and is the current default. In such a case, finding the right set of parameters to work with a specific exchange may be challenging, nd involves understanding how the exchanges API and the CCXT Library API work. In other words, there is no hard rule as of what each of the values should be. Determining each of this values requires exploring the exchange's API documentation, as well as the documentation of the CCXT Library." + } + ] +} diff --git a/Projects/Foundations/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/ExchangeAPI.js b/Projects/Foundations/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/ExchangeAPI.js index 94efc1a52..ad7848639 100644 --- a/Projects/Foundations/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/ExchangeAPI.js +++ b/Projects/Foundations/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/ExchangeAPI.js @@ -51,6 +51,14 @@ options: options } exchange = new exchangeClass(exchangeConstructorParams) + // enable sandbox mode based on exchange sandbox param value + if (sandBox) { + exchange.setSandboxMode(sandBox); + } + console.log('Sandbox mode = ' + sandBox); + + // uncomment the following line if you want to log the exchange api being used + // console.log(exchange.urls.api); } function finalize() { @@ -98,7 +106,7 @@ tradingSystem.addError([tradingSystemOrder.id, message, docs]) logError("getOrder -> Error = " + err.message); - if ( /[0-9a-z]+ NotFound/.test(err.message) ) { + if (/[0-9a-z]+ NotFound/.test(err.message)) { logInfo("getOrder -> NotFound, so order is actually closed.") order = { status: 'NotFound' From df9c77bd06358d667c8e9dead0fdb7840defc057 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Sun, 4 Jul 2021 09:21:24 +0200 Subject: [PATCH 3/4] Refactoring since code seems to come from master. --- .../Low-Frequency-Trading/APIs/ExchangeAPI.js | 46 +++++++++---------- 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/Projects/Foundations/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/ExchangeAPI.js b/Projects/Foundations/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/ExchangeAPI.js index ca532c749..9a0397e89 100644 --- a/Projects/Foundations/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/ExchangeAPI.js +++ b/Projects/Foundations/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/ExchangeAPI.js @@ -1,4 +1,4 @@ -exports.newSuperalgosBotModulesExchangeAPI = function (processIndex) { +exports.newFoundationsBotModulesExchangeAPI = function (processIndex) { let MODULE_NAME = "Exchange API"; @@ -21,22 +21,22 @@ return thisObject; function initialize() { - tradingSystem = TS.projects.superalgos.globals.processVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).SIMULATION_STATE.tradingSystem + tradingSystem = TS.projects.foundations.globals.processVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).SIMULATION_STATE.tradingSystem - exchangeId = TS.projects.superalgos.globals.taskConstants.TASK_NODE.parentNode.parentNode.parentNode.referenceParent.parentNode.parentNode.config.codeName + exchangeId = TS.projects.foundations.globals.taskConstants.TASK_NODE.parentNode.parentNode.parentNode.referenceParent.parentNode.parentNode.config.codeName let key let secret let uid let password - let sandBox = TS.projects.superalgos.globals.taskConstants.TASK_NODE.parentNode.parentNode.parentNode.referenceParent.parentNode.parentNode.config.sandbox || false; + let sandBox = TS.projects.foundations.globals.taskConstants.TASK_NODE.parentNode.parentNode.parentNode.referenceParent.parentNode.parentNode.config.sandbox || false; - if (TS.projects.superalgos.globals.taskConstants.TASK_NODE.keyReference !== undefined) { - if (TS.projects.superalgos.globals.taskConstants.TASK_NODE.keyReference.referenceParent !== undefined) { - key = TS.projects.superalgos.globals.taskConstants.TASK_NODE.keyReference.referenceParent.config.codeName - secret = TS.projects.superalgos.globals.taskConstants.TASK_NODE.keyReference.referenceParent.config.secret - uid = TS.projects.superalgos.globals.taskConstants.TASK_NODE.keyReference.referenceParent.config.uid - password = TS.projects.superalgos.globals.taskConstants.TASK_NODE.keyReference.referenceParent.config.password + if (TS.projects.foundations.globals.taskConstants.TASK_NODE.keyReference !== undefined) { + if (TS.projects.foundations.globals.taskConstants.TASK_NODE.keyReference.referenceParent !== undefined) { + key = TS.projects.foundations.globals.taskConstants.TASK_NODE.keyReference.referenceParent.config.codeName + secret = TS.projects.foundations.globals.taskConstants.TASK_NODE.keyReference.referenceParent.config.secret + uid = TS.projects.foundations.globals.taskConstants.TASK_NODE.keyReference.referenceParent.config.uid + password = TS.projects.foundations.globals.taskConstants.TASK_NODE.keyReference.referenceParent.config.password } } const exchangeClass = ccxt[exchangeId] @@ -71,7 +71,7 @@ async function getOrder(tradingSystemOrder, tradingEngineOrder) { let orderId = tradingEngineOrder.exchangeId.value - const symbol = TS.projects.superalgos.globals.taskConstants.TASK_NODE.parentNode.parentNode.parentNode.referenceParent.baseAsset.referenceParent.config.codeName + '/' + TS.projects.superalgos.globals.taskConstants.TASK_NODE.parentNode.parentNode.parentNode.referenceParent.quotedAsset.referenceParent.config.codeName + const symbol = TS.projects.foundations.globals.taskConstants.TASK_NODE.parentNode.parentNode.parentNode.referenceParent.baseAsset.referenceParent.config.codeName + '/' + TS.projects.foundations.globals.taskConstants.TASK_NODE.parentNode.parentNode.parentNode.referenceParent.quotedAsset.referenceParent.config.codeName /* Basic Logging */ logInfo("getOrder -> orderId = " + orderId) @@ -91,7 +91,7 @@ } catch (err) { const message = 'Get Order Unexpected Error' let docs = { - project: 'Superalgos', + project: 'Foundations', category: 'Topic', type: 'TS LF Trading Bot Error - ' + message, placeholder: {} @@ -101,7 +101,7 @@ orderId: orderId } - TS.projects.superalgos.utilities.docsFunctions.buildPlaceholder(docs, err, tradingSystemOrder.name, undefined, undefined, undefined, contextInfo) + TS.projects.foundations.utilities.docsFunctions.buildPlaceholder(docs, err, tradingSystemOrder.name, undefined, undefined, undefined, contextInfo) tradingSystem.addError([tradingSystemOrder.id, message, docs]) @@ -121,7 +121,7 @@ let price = tradingEngineOrder.rate.value // CCXT: how much quote currency you are willing to pay for a trade lot of base currency (for limit orders only) let type // CCXT: a string literal type of order, ccxt currently unifies market and limit orders only let side // CCXT: a string literal for the direction of your order, buy or sell - let symbol = TS.projects.superalgos.globals.taskConstants.TASK_NODE.parentNode.parentNode.parentNode.referenceParent.baseAsset.referenceParent.config.codeName + '/' + TS.projects.superalgos.globals.taskConstants.TASK_NODE.parentNode.parentNode.parentNode.referenceParent.quotedAsset.referenceParent.config.codeName // CCXT: a string literal symbol of the market you wish to trade on, like BTC/USD, ZEC/ETH, DOGE/DASH, etc + let symbol = TS.projects.foundations.globals.taskConstants.TASK_NODE.parentNode.parentNode.parentNode.referenceParent.baseAsset.referenceParent.config.codeName + '/' + TS.projects.foundations.globals.taskConstants.TASK_NODE.parentNode.parentNode.parentNode.referenceParent.quotedAsset.referenceParent.config.codeName // CCXT: a string literal symbol of the market you wish to trade on, like BTC/USD, ZEC/ETH, DOGE/DASH, etc let amount = tradingEngineOrder.orderBaseAsset.size.value // CCXT: how much of currency you want to trade, in Base Asset. switch (tradingSystemOrder.type) { @@ -171,7 +171,7 @@ return order.id } catch (err) { - let exchangeApiKey = TS.projects.superalgos.globals.taskConstants.TASK_NODE.keyReference.referenceParent + let exchangeApiKey = TS.projects.foundations.globals.taskConstants.TASK_NODE.keyReference.referenceParent let message = 'Create Order Unexpected Error' logError("createOrder -> Error = " + err.message) @@ -201,7 +201,7 @@ } let docs = { - project: 'Superalgos', + project: 'Foundations', category: 'Topic', type: 'TS LF Trading Bot Error - ' + message, placeholder: {} @@ -218,7 +218,7 @@ keyLength: exchangeApiKey.config.codeName.length, secretLength: exchangeApiKey.config.secret.length } - TS.projects.superalgos.utilities.docsFunctions.buildPlaceholder(docs, err, exchangeApiKey.name, undefined, exchangeApiKey.config, undefined, contextInfo) + TS.projects.foundations.utilities.docsFunctions.buildPlaceholder(docs, err, exchangeApiKey.name, undefined, exchangeApiKey.config, undefined, contextInfo) tradingSystem.addError([exchangeApiKey.id, message, docs]) @@ -240,7 +240,7 @@ /* Basic Logging */ logInfo("cancelOrder -> Entering function. orderId = " + orderId); - const symbol = TS.projects.superalgos.globals.taskConstants.TASK_NODE.parentNode.parentNode.parentNode.referenceParent.baseAsset.referenceParent.config.codeName + '/' + TS.projects.superalgos.globals.taskConstants.TASK_NODE.parentNode.parentNode.parentNode.referenceParent.quotedAsset.referenceParent.config.codeName + const symbol = TS.projects.foundations.globals.taskConstants.TASK_NODE.parentNode.parentNode.parentNode.referenceParent.baseAsset.referenceParent.config.codeName + '/' + TS.projects.foundations.globals.taskConstants.TASK_NODE.parentNode.parentNode.parentNode.referenceParent.quotedAsset.referenceParent.config.codeName /* Basic Validations */ if (exchange.has['fetchOrder'] === false) { @@ -256,7 +256,7 @@ } catch (err) { const message = 'Cancel Order Unexpected Error' let docs = { - project: 'Superalgos', + project: 'Foundations', category: 'Topic', type: 'TS LF Trading Bot Error - ' + message, placeholder: {} @@ -266,7 +266,7 @@ orderId: orderId } - TS.projects.superalgos.utilities.docsFunctions.buildPlaceholder(docs, err, tradingSystemOrder.name, undefined, undefined, undefined, contextInfo) + TS.projects.foundations.utilities.docsFunctions.buildPlaceholder(docs, err, tradingSystemOrder.name, undefined, undefined, undefined, contextInfo) tradingSystem.addError([tradingSystemOrder.id, message, docs]) logError("cancelOrder -> Error = " + err.message); @@ -274,11 +274,11 @@ } function logInfo(message) { - TS.projects.superalgos.globals.loggerVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).BOT_MAIN_LOOP_LOGGER_MODULE_OBJECT.write(MODULE_NAME, '[INFO] ' + message) + TS.projects.foundations.globals.loggerVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).BOT_MAIN_LOOP_LOGGER_MODULE_OBJECT.write(MODULE_NAME, '[INFO] ' + message) } function logError(message) { - TS.projects.superalgos.globals.loggerVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).BOT_MAIN_LOOP_LOGGER_MODULE_OBJECT.write(MODULE_NAME, '[ERROR] ' + message) + TS.projects.foundations.globals.loggerVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).BOT_MAIN_LOOP_LOGGER_MODULE_OBJECT.write(MODULE_NAME, '[ERROR] ' + message) } }; - \ No newline at end of file + From 7ba196cbb9f5a2318d962a4516b083628b926563 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Sun, 4 Jul 2021 09:24:04 +0200 Subject: [PATCH 4/4] Foundations to Education Refactoring --- .../Trading-Bot/Low-Frequency-Trading/APIs/ExchangeAPI.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Projects/Foundations/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/ExchangeAPI.js b/Projects/Foundations/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/ExchangeAPI.js index 9a0397e89..3647cbb9c 100644 --- a/Projects/Foundations/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/ExchangeAPI.js +++ b/Projects/Foundations/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/ExchangeAPI.js @@ -101,7 +101,7 @@ orderId: orderId } - TS.projects.foundations.utilities.docsFunctions.buildPlaceholder(docs, err, tradingSystemOrder.name, undefined, undefined, undefined, contextInfo) + TS.projects.education.utilities.docsFunctions.buildPlaceholder(docs, err, tradingSystemOrder.name, undefined, undefined, undefined, contextInfo) tradingSystem.addError([tradingSystemOrder.id, message, docs]) @@ -218,7 +218,7 @@ keyLength: exchangeApiKey.config.codeName.length, secretLength: exchangeApiKey.config.secret.length } - TS.projects.foundations.utilities.docsFunctions.buildPlaceholder(docs, err, exchangeApiKey.name, undefined, exchangeApiKey.config, undefined, contextInfo) + TS.projects.education.utilities.docsFunctions.buildPlaceholder(docs, err, exchangeApiKey.name, undefined, exchangeApiKey.config, undefined, contextInfo) tradingSystem.addError([exchangeApiKey.id, message, docs]) @@ -266,7 +266,7 @@ orderId: orderId } - TS.projects.foundations.utilities.docsFunctions.buildPlaceholder(docs, err, tradingSystemOrder.name, undefined, undefined, undefined, contextInfo) + TS.projects.education.utilities.docsFunctions.buildPlaceholder(docs, err, tradingSystemOrder.name, undefined, undefined, undefined, contextInfo) tradingSystem.addError([tradingSystemOrder.id, message, docs]) logError("cancelOrder -> Error = " + err.message);