3 files changed
+285
-272
No files matched your search
@@ -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"
|
||||
}
|
||||
]
|
||||
}
|
||||
{
|
||||
"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"
|
||||
}
|
||||
]
|
||||
}
|
||||
+85
-81
@@ -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."
|
||||
}
|
||||
]
|
||||
}
|
||||
{
|
||||
"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."
|
||||
}
|
||||
]
|
||||
}
|
||||
+56
-47
@@ -1,7 +1,7 @@
|
||||
exports.newFoundationsBotModulesExchangeAPI = function (processIndex) {
|
||||
|
||||
let MODULE_NAME = "Exchange API";
|
||||
|
||||
|
||||
let thisObject = {
|
||||
getOrder: getOrder,
|
||||
createOrder: createOrder,
|
||||
@@ -9,27 +9,28 @@
|
||||
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
|
||||
|
||||
|
||||
let key
|
||||
let secret
|
||||
let uid
|
||||
let password
|
||||
|
||||
let sandBox = TS.projects.foundations.globals.taskConstants.TASK_NODE.parentNode.parentNode.parentNode.referenceParent.parentNode.parentNode.config.sandbox || false;
|
||||
|
||||
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
|
||||
@@ -51,33 +52,40 @@
|
||||
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() {
|
||||
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
|
||||
|
||||
|
||||
/* 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) {
|
||||
@@ -92,13 +100,13 @@
|
||||
symbol: symbol,
|
||||
orderId: orderId
|
||||
}
|
||||
|
||||
|
||||
TS.projects.education.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) ) {
|
||||
if (/[0-9a-z]+ NotFound/.test(err.message)) {
|
||||
logInfo("getOrder -> NotFound, so order is actually closed.")
|
||||
order = {
|
||||
status: 'NotFound'
|
||||
@@ -107,15 +115,15 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
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 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 +146,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 +163,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 message = 'Create Order Unexpected Error'
|
||||
|
||||
|
||||
logError("createOrder -> Error = " + err.message)
|
||||
logError("createOrder -> symbol = " + symbol);
|
||||
logError("createOrder -> side = " + side);
|
||||
@@ -179,7 +187,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 +196,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',
|
||||
category: 'Topic',
|
||||
type: 'TS LF Trading Bot Error - ' + message,
|
||||
placeholder: {}
|
||||
}
|
||||
|
||||
|
||||
let contextInfo = {
|
||||
symbol: symbol,
|
||||
side: side,
|
||||
@@ -211,9 +219,9 @@
|
||||
secretLength: exchangeApiKey.config.secret.length
|
||||
}
|
||||
TS.projects.education.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,25 +232,25 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
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
|
||||
|
||||
|
||||
/* 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) {
|
||||
@@ -257,19 +265,20 @@
|
||||
symbol: symbol,
|
||||
orderId: orderId
|
||||
}
|
||||
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
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)
|
||||
}
|
||||
|
||||
|
||||
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)
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
Reference in new issue
Block a user