diff --git a/Client/WebServer/index.html b/Client/WebServer/index.html index 7189ebe1f..072714379 100644 --- a/Client/WebServer/index.html +++ b/Client/WebServer/index.html @@ -56,7 +56,7 @@ onresize="onResize()">

The UI is loading...

-

Superalgos is forever free and open-source, and it's +

Superalgos is open source and free, for everyone, forever, and it's relentlessly improving thanks to the involvement of contributors:

Luis Fernando Molina, Julian Molina, Andreja Cobeljic, Matías Benitez, Ira Miller, Eduardo Remis, Jeff Braun, rico4dev, 9808us, Barry Low, Nikola Bjelogrlic, Hirajin Koizuko, Francisco J. Santillán, Norman, @@ -203,4 +203,4 @@ - \ No newline at end of file + diff --git a/Client/httpInterface.js b/Client/httpInterface.js index fc78aada2..7eb1064bf 100644 --- a/Client/httpInterface.js +++ b/Client/httpInterface.js @@ -257,6 +257,9 @@ exports.newHttpInterface = function newHttpInterface(WEB_SERVER, DATA_FILE_SERVE webhookMessages = [] } + console.log('[INFO] httpInterface -> Webhook -> Fetch-Messages -> Exchange-Market = ' + exchange + '-' + market) + console.log('[INFO] httpInterface -> Webhook -> Fetch-Messages -> Messeges Fetched by Webhooks Sensor Bot = ' + webhookMessages.length) + respondWithContent(JSON.stringify(webhookMessages), httpResponse) webhookMessages = [] @@ -299,6 +302,9 @@ exports.newHttpInterface = function newHttpInterface(WEB_SERVER, DATA_FILE_SERVE webhookMessages.push([timestamp, source, messageReceived]) webhook.set(key, webhookMessages) + console.log('[INFO] httpInterface -> Webhook -> New-Message -> Exchange-Market = ' + exchange + '-' + market) + console.log('[INFO] httpInterface -> Webhook -> New-Message -> messageReceived = ' + messageReceived) + console.log('[INFO] httpInterface -> Webhook -> New-Message -> Messeges waiting to be Fetched by Webhooks Sensor Bot = ' + webhookMessages.length) respondWithContent(JSON.stringify(global.DEFAULT_OK_RESPONSE), httpResponse) } break diff --git a/Projects/Superalgos/Plugins/Workspaces/Tested Exchanges.json b/Projects/Superalgos/Plugins/Workspaces/Tested Exchanges.json index 82aac83a8..40c4450f0 100644 --- a/Projects/Superalgos/Plugins/Workspaces/Tested Exchanges.json +++ b/Projects/Superalgos/Plugins/Workspaces/Tested Exchanges.json @@ -1 +1 @@ -{"type":"Workspace","name":"Tested Exchanges","rootNodes":[{"type":"Network","name":"My Network","project":"Superalgos","networkNodes":[{"type":"Network Node","name":"My Computer","config":"{ \n\"host\": \"localhost\", \n\"webPort\": \"34248\", \n\"webSocketsPort\": \"18041\"\n}","project":"Superalgos","dataTasks":{"type":"Data Tasks","name":"New Data Tasks","project":"Superalgos","projectDataTasks":[],"id":"40af91d9-431c-4b7d-addc-aed37bc2f3fe","savedPayload":{"position":{"x":25089.356993272086,"y":30767.11115747996},"targetPosition":{"x":25239.356993272086,"y":31026.918778615294},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"learningTasks":{"type":"Learning Tasks","name":"New Learning Tasks","project":"Superalgos","projectLearningTasks":[],"id":"0818dfbe-61ea-40b8-8544-bee25d7f45be","savedPayload":{"position":{"x":25389.356993272086,"y":30767.11115747996},"targetPosition":{"x":25239.356993272086,"y":31026.918778615294},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":true,"angleToParent":1,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"testingTradingTasks":{"type":"Testing Trading Tasks","name":"New Testing Trading Tasks","project":"Superalgos","projectTradingTasks":[],"id":"8117db0a-e418-4f56-8fe4-fda2ddac1cbb","savedPayload":{"position":{"x":25539.356993272086,"y":31026.918778615294},"targetPosition":{"x":25239.356993272086,"y":31026.918778615294},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":true,"angleToParent":1,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"productionTradingTasks":{"type":"Production Trading Tasks","name":"New Production Trading Tasks","project":"Superalgos","projectTradingTasks":[],"id":"673caa5f-511d-4688-9305-e5f0f0f780cd","savedPayload":{"position":{"x":25389.356993272086,"y":31286.726399750627},"targetPosition":{"x":25239.356993272086,"y":31026.918778615294},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":true,"angleToParent":1,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"dataStorage":{"type":"Data Storage","name":"New Data Storage","project":"Superalgos","dataMinesData":{"type":"Data Mines Data","name":"New Data Mines Data","project":"Superalgos","projectDataProducts":[],"id":"32e7c122-fa5a-4d00-9d71-d54e890e32de","savedPayload":{"position":{"x":25070.19913560607,"y":31588.15985816277},"targetPosition":{"x":25109.356993272086,"y":31290.726399750627},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":3,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"tradingMinesData":{"type":"Trading Mines Data","name":"New Trading Mines Data","project":"Superalgos","projectTradingProducts":[],"id":"e4e268f3-a677-4f90-90a1-d87244e647e5","savedPayload":{"position":{"x":24959.356993272086,"y":31550.53402088596},"targetPosition":{"x":25109.356993272086,"y":31290.726399750627},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":3,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"learningMinesData":{"type":"Learning Mines Data","name":"New Learning Mines Data","project":"Superalgos","projectLearningProducts":[],"id":"2845a687-becc-4c3b-bc79-b2293ba876ba","savedPayload":{"position":{"x":24871.350991184714,"y":31473.354828453244},"targetPosition":{"x":25109.356993272086,"y":31290.726399750627},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":3,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"id":"e2697759-6038-4943-b90c-5a68651ff9a8","savedPayload":{"position":{"x":25089.356993272086,"y":31286.726399750627},"targetPosition":{"x":25239.356993272086,"y":31026.918778615294},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":true,"angleToParent":1,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false,"shortcutKey":"d"}}},"id":"e452cf65-2b2b-44f2-9e67-bdd9d3c008e4","savedPayload":{"position":{"x":25239.356993272086,"y":31026.918778615294},"targetPosition":{"x":24939.356993272086,"y":31026.918778615294},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false,"shortcutKey":""}}}],"id":"3c165071-7558-4708-9999-8ffe71d346b1","savedPayload":{"position":{"x":24939.356993272086,"y":31026.918778615294},"targetPosition":{"x":24939.356993272086,"y":31026.918778615294},"floatingObject":{"isPinned":true,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false,"shortcutKey":"s"}}},{"type":"Crypto Ecosystem","name":"My Crypto Ecosystem","project":"Superalgos","cryptoExchanges":[{"type":"Crypto Exchanges","name":"Tested","project":"Superalgos","exchanges":[{"type":"Crypto Exchange","name":"Binance","config":"{\n \"codeName\": \"binance\",\n \"API\": [\n {\n \"method\": \"fetchTrades\",\n \"fetchType\": \"by Id\",\n \"fetchTradesMethod\": \"publicGetHistoricalTrades\",\n \"firstId\": \"f\"\n }\n ]\n}","project":"Superalgos","exchangeAssets":{"type":"Exchange Assets","name":"New Exchange Assets","config":"{ \n\"addMissingAssetsFilter\": { \"quotedAsset\": \"EUR\"} \n}","project":"Superalgos","assets":[{"type":"Asset","name":"Bitcoin","config":"{ \n\"codeName\": \"BTC\"\n}","project":"Superalgos","id":"5f5e4a94-5090-47d4-8883-cc2325d20bfa","savedPayload":{"position":{"x":18606.497829264816,"y":29451.09637134722},"targetPosition":{"x":18947.58510468027,"y":29744.625706422376},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{}}},{"type":"Asset","name":"Tether","config":"{\n \"codeName\": \"USDT\"\n}","project":"Superalgos","id":"f110bfa0-bd5b-469b-a940-4524c8688136","savedPayload":{"position":{"x":19031.245327903584,"y":29302.470793467397},"targetPosition":{"x":18947.58510468027,"y":29744.625706422376},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{}}}],"id":"95d2c30f-215b-486e-8119-f4eac0279575","savedPayload":{"position":{"x":18947.58510468027,"y":29744.625706422376},"targetPosition":{"x":19096.210682560097,"y":30169.37320506114},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false,"shortcutKey":"E"}}},"exchangeMarkets":{"type":"Exchange Markets","name":"New Exchange Markets","code":"{ \n\"codeName\": \"Write here the code name of the Market here.\"\n}","project":"Superalgos","markets":[{"type":"Market","name":"BTC/USDT","config":"{ \n\"codeName\": \"BTC/USDT\"\n}","project":"Superalgos","baseAsset":{"type":"Market Base Asset","name":"Bitcoin","project":"Superalgos","id":"1017b30d-de1b-4212-991e-9fd0a5b6c814","savedPayload":{"position":{"x":19570.366270989212,"y":28916.346310993984},"targetPosition":{"x":19486.7060477659,"y":29358.501223948962},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":3,"distanceToParent":3,"arrangementStyle":0},"uiObject":{},"referenceParent":{"type":"Asset","name":"Bitcoin","id":"5f5e4a94-5090-47d4-8883-cc2325d20bfa"}}},"quotedAsset":{"type":"Market Quoted Asset","name":"Tether","project":"Superalgos","id":"705c4a67-787a-48cd-a3dc-3a557438bf0b","savedPayload":{"position":{"x":19780.235382841056,"y":29017.413948533507},"targetPosition":{"x":19486.7060477659,"y":29358.501223948962},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":3,"distanceToParent":3,"arrangementStyle":0},"uiObject":{},"referenceParent":{"type":"Asset","name":"Tether","id":"f110bfa0-bd5b-469b-a940-4524c8688136"}}},"id":"9a867bf0-a71d-445c-b99a-75b60bbdce09","savedPayload":{"position":{"x":19486.7060477659,"y":29358.501223948962},"targetPosition":{"x":19291.458365163,"y":29763.93721450505},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":3,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false}}}],"id":"2fd80894-900e-44ac-a1a7-56c14124f7a1","savedPayload":{"position":{"x":19291.458365163,"y":29763.93721450505},"targetPosition":{"x":19096.210682560097,"y":30169.37320506114},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"exchangeAccounts":{"type":"Exchange Accounts","name":"New Exchange Accounts","project":"Superalgos","userAccounts":[{"type":"User Account","name":"New User Account","project":"Superalgos","userAssets":{"type":"User Assets","name":"New User Assets","project":"Superalgos","assets":[{"type":"Exchange Account Asset","name":"Bitcoin","project":"Superalgos","id":"ba6f3d5c-b36b-49d9-947f-392068109169","savedPayload":{"position":{"x":19810.91198701285,"y":29633.15211842039},"targetPosition":{"x":19784.76526418855,"y":29932.010527847913},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{},"referenceParent":{"type":"Asset","name":"Bitcoin","id":"5f5e4a94-5090-47d4-8883-cc2325d20bfa"}}},{"type":"Exchange Account Asset","name":"Tether","project":"Superalgos","id":"c90be267-90f9-45ae-b225-0578adb4aad9","savedPayload":{"position":{"x":20056.657600299546,"y":29805.225049325705},"targetPosition":{"x":19784.76526418855,"y":29932.010527847913},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{},"referenceParent":{"type":"Asset","name":"Tether","id":"f110bfa0-bd5b-469b-a940-4524c8688136"}}}],"id":"8ac5c2a9-a238-48ae-ab43-0a0a95a37464","savedPayload":{"position":{"x":19784.76526418855,"y":29932.010527847913},"targetPosition":{"x":19612.692333283238,"y":30177.75614113461},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"userKeys":{"type":"User Keys","name":"New User Keys","project":"Superalgos","keys":[{"type":"Exchange Account Key","name":"Key for Lighting Strike","config":"{ \n\"codeName\": \"Paste your exchange API name or label\",\n\"secret\": \"Paste your exchange API secret key\"\n}","project":"Superalgos","id":"e85bbbd6-aca8-450f-9237-788062de5761","savedPayload":{"position":{"x":20210.409152138287,"y":30230.049586783207},"targetPosition":{"x":19911.550742710762,"y":30203.90286395891},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":true,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{}}}],"id":"48925cc9-f3cd-4499-8466-1338fed28a0d","savedPayload":{"position":{"x":19911.550742710762,"y":30203.90286395891},"targetPosition":{"x":19612.692333283238,"y":30177.75614113461},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"id":"63794496-c94b-42f9-81cc-c588708617a6","savedPayload":{"position":{"x":19612.692333283238,"y":30177.75614113461},"targetPosition":{"x":19340.799997172242,"y":30304.54161965682},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false}}}],"id":"4b0c1ac5-515f-44a9-b9b9-e698a9c51eac","savedPayload":{"position":{"x":19520.95818119886,"y":30020.747627181314},"targetPosition":{"x":19096.210682560097,"y":30169.37320506114},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":true,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"id":"61ef0b8d-de6e-4e76-bdd5-996836760a4b","savedPayload":{"position":{"x":19245.509162627837,"y":30564.48909478472},"targetPosition":{"x":19073.301618063546,"y":30980.2348844148},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":true,"angleToParent":2,"distanceToParent":4,"arrangementStyle":0},"uiObject":{"isRunning":false,"shortcutKey":""},"tutorial":{"status":"Done"}}},{"type":"Crypto Exchange","name":"Binance US","config":"{\n \"codeName\": \"binanceus\",\n \"API\": [\n {\n \"method\": \"fetchTrades\",\n \"fetchType\": \"by Id\",\n \"fetchTradesMethod\": \"publicGetHistoricalTrades\",\n \"firstId\": \"f\"\n }\n ]\n}","project":"Superalgos","exchangeAssets":{"type":"Exchange Assets","name":"New Exchange Assets","config":"{ \n\"addMissingAssetsFilter\": { \"quotedAsset\": \"EUR\"} \n}","project":"Superalgos","assets":[{"type":"Asset","name":"Bitcoin","config":"{ \n\"codeName\": \"BTC\"\n}","project":"Superalgos","id":"5f600d91-40e6-43cc-82b0-586c5c422077","savedPayload":{"position":{"x":19512.947331594303,"y":30307.95713652808},"targetPosition":{"x":19435.301618063546,"y":30597.7348844148},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{}}},{"type":"Asset","name":"Tether","config":"{ \n\"codeName\": \"USDT\"\n}","project":"Superalgos","id":"d9a04ff0-c729-490c-84d1-d5d5a0397989","savedPayload":{"position":{"x":19725.079365950267,"y":30520.089170884043},"targetPosition":{"x":19435.301618063546,"y":30597.7348844148},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{}}}],"id":"8b0d5d47-de2c-4770-976d-14a006ac25e7","savedPayload":{"position":{"x":19435.301618063546,"y":30597.7348844148},"targetPosition":{"x":19223.169583707582,"y":30809.866918770764},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false,"shortcutKey":"E"}}},"exchangeMarkets":{"type":"Exchange Markets","name":"New Exchange Markets","code":"{ \n\"codeName\": \"Write here the code name of the Market here.\"\n}","project":"Superalgos","markets":[{"type":"Market","name":"BTC/USDT","config":"{ \n\"codeName\": \"BTC/USDT\"\n}","project":"Superalgos","baseAsset":{"type":"Market Base Asset","name":"Bitcoin","project":"Superalgos","id":"0f7ece91-d8ef-4c4b-be95-59fb64b5eaf9","savedPayload":{"position":{"x":20112.947331594303,"y":30732.221205240006},"targetPosition":{"x":19823.169583707582,"y":30809.866918770764},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":3,"distanceToParent":3,"arrangementStyle":0},"uiObject":{},"referenceParent":{"type":"Asset","name":"Bitcoin","id":"5f600d91-40e6-43cc-82b0-586c5c422077"}}},"quotedAsset":{"type":"Market Quoted Asset","name":"Tether","project":"Superalgos","id":"a8005fb7-1737-43af-882c-3183f2e94f41","savedPayload":{"position":{"x":20112.947331594303,"y":30887.51263230152},"targetPosition":{"x":19823.169583707582,"y":30809.866918770764},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":3,"distanceToParent":3,"arrangementStyle":0},"uiObject":{},"referenceParent":{"type":"Asset","name":"Tether","id":"d9a04ff0-c729-490c-84d1-d5d5a0397989"}}},"id":"6af7c681-a924-4e65-a8aa-a45589e12bde","savedPayload":{"position":{"x":19823.169583707582,"y":30809.866918770764},"targetPosition":{"x":19523.169583707582,"y":30809.866918770764},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":3,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false}}}],"id":"95f252bb-4047-4bfa-8c93-66618b64d419","savedPayload":{"position":{"x":19523.169583707582,"y":30809.866918770764},"targetPosition":{"x":19223.169583707582,"y":30809.866918770764},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"exchangeAccounts":{"type":"Exchange Accounts","name":"New Exchange Accounts","project":"Superalgos","userAccounts":[{"type":"User Account","name":"New User Account","project":"Superalgos","userAssets":{"type":"User Assets","name":"New User Assets","project":"Superalgos","assets":[{"type":"Exchange Account Asset","name":"Bitcoin","project":"Superalgos","id":"ef552b0e-ad3c-48a5-8a51-b57f37259043","savedPayload":{"position":{"x":20226.98914819295,"y":31234.13098748269},"targetPosition":{"x":19937.21140030623,"y":31311.77670101345},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{},"referenceParent":{"type":"Asset","name":"Bitcoin","id":"5f600d91-40e6-43cc-82b0-586c5c422077"}}},{"type":"Exchange Account Asset","name":"Tether","project":"Superalgos","id":"f5017c63-704e-4c72-a652-974ae842a2af","savedPayload":{"position":{"x":20149.343434662194,"y":31523.908735369412},"targetPosition":{"x":19937.21140030623,"y":31311.77670101345},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{},"referenceParent":{"type":"Asset","name":"Tether","id":"d9a04ff0-c729-490c-84d1-d5d5a0397989"}}}],"id":"75edbc56-de4a-4f00-9471-d8978fa1d85e","savedPayload":{"position":{"x":19937.21140030623,"y":31311.77670101345},"targetPosition":{"x":19647.43365241951,"y":31234.13098748269},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"userKeys":{"type":"User Keys","name":"New User Keys","project":"Superalgos","keys":[{"type":"Exchange Account Key","name":"Key for Lighting Strike","config":"{ \n\"codeName\": \"Paste your exchange API name or label\",\n\"secret\": \"Paste your exchange API secret key\"\n}","project":"Superalgos","id":"dfa910d1-ca6f-4d7d-9935-62f051005199","savedPayload":{"position":{"x":19802.725079481024,"y":31813.686483256133},"targetPosition":{"x":19725.079365950267,"y":31523.908735369412},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":true,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{}}}],"id":"d4f8319e-bc33-4a59-9444-ec4d44e0f1ae","savedPayload":{"position":{"x":19725.079365950267,"y":31523.908735369412},"targetPosition":{"x":19647.43365241951,"y":31234.13098748269},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"id":"3c4b38ad-2fe0-4224-80dc-d01bbd5c9ff5","savedPayload":{"position":{"x":19647.43365241951,"y":31234.13098748269},"targetPosition":{"x":19435.301618063546,"y":31021.998953126727},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false}}}],"id":"97859cdc-92f3-43a7-9170-05f02953e39a","savedPayload":{"position":{"x":19435.301618063546,"y":31021.998953126727},"targetPosition":{"x":19223.169583707582,"y":30809.866918770764},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"id":"d763fdb6-bfe0-4fd2-9b1f-0a12ead4098b","savedPayload":{"position":{"x":19391.49966959749,"y":30662.036832880854},"targetPosition":{"x":19073.301618063546,"y":30980.2348844148},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":true,"angleToParent":2,"distanceToParent":4,"arrangementStyle":0},"uiObject":{"isRunning":false,"shortcutKey":""}}},{"type":"Crypto Exchange","name":"Bitfinex","config":"{\n \"codeName\": \"bitfinex\",\n \"API\": [\n {\n \"rateLimit\": 999\n }\n ]\n}","project":"Superalgos","exchangeAssets":{"type":"Exchange Assets","name":"New Exchange Assets","config":"{ \n\"addMissingAssetsFilter\": { \"quotedAsset\": \"USDT\"} \n}","project":"Superalgos","assets":[{"type":"Asset","name":"Bitcoin","config":"{\n \"codeName\": \"BTC\"\n}","project":"Superalgos","id":"fa6fb871-10ad-4b25-ba74-b37d6a9a3025","savedPayload":{"position":{"x":19651.24733491461,"y":30138.234951669678},"targetPosition":{"x":19709.481620062677,"y":30355.56826258472},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":2,"arrangementStyle":0},"uiObject":{}}},{"type":"Asset","name":"Tether","config":"{\n \"codeName\": \"USDT\"\n}","project":"Superalgos","id":"2de2fe8f-a38b-4778-8e24-d318888c629f","savedPayload":{"position":{"x":19868.58064582965,"y":30196.469236817746},"targetPosition":{"x":19709.481620062677,"y":30355.56826258472},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":2,"arrangementStyle":0},"uiObject":{}}}],"id":"33508b53-2769-4f3d-8c98-9fa37e5cbf5b","savedPayload":{"position":{"x":19709.481620062677,"y":30355.56826258472},"targetPosition":{"x":19593.013049766545,"y":30790.2348844148},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"exchangeMarkets":{"type":"Exchange Markets","name":"New Exchange Markets","project":"Superalgos","markets":[{"type":"Market","name":"BTC/USDT","config":"{\n \"codeName\": \"BTC/USDT\"\n}","project":"Superalgos","baseAsset":{"type":"Market Base Asset","name":"Bitcoin","project":"Superalgos","id":"de06f331-5653-4539-acf4-603fa7f6b30d","savedPayload":{"position":{"x":20597.435913172543,"y":29950.5234527118},"targetPosition":{"x":20372.435913172543,"y":30340.2348844148},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{},"referenceParent":{"type":"Asset","name":"Bitcoin","id":"fa6fb871-10ad-4b25-ba74-b37d6a9a3025"}}},"quotedAsset":{"type":"Market Quoted Asset","name":"Tether","project":"Superalgos","id":"5108ee82-6b9f-4067-9a57-5b29647a26bc","savedPayload":{"position":{"x":20822.435913172543,"y":30340.2348844148},"targetPosition":{"x":20372.435913172543,"y":30340.2348844148},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{},"referenceParent":{"type":"Asset","name":"Tether","id":"2de2fe8f-a38b-4778-8e24-d318888c629f"}}},"id":"b0230cdf-6725-4d65-b633-390272cfb6c5","savedPayload":{"position":{"x":20372.435913172543,"y":30340.2348844148},"targetPosition":{"x":19982.724481469544,"y":30565.2348844148},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false}}}],"id":"4d4ad5a1-81a7-4f92-83db-99f57ce261bb","savedPayload":{"position":{"x":19982.724481469544,"y":30565.2348844148},"targetPosition":{"x":19593.013049766545,"y":30790.2348844148},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"exchangeAccounts":{"type":"Exchange Accounts","name":"New Exchange Accounts","project":"Superalgos","userAccounts":[{"type":"User Account","name":"New User Account","project":"Superalgos","userAssets":{"type":"User Assets","name":"New User Assets","project":"Superalgos","assets":[{"type":"Exchange Account Asset","name":"Bitcoin","project":"Superalgos","id":"19d9de75-5c17-4226-9dd3-947b553bd1a1","savedPayload":{"position":{"x":21056.111941023762,"y":30747.604428943956},"targetPosition":{"x":20897.01291525679,"y":30906.70345471093},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":2,"arrangementStyle":0},"uiObject":{},"referenceParent":{"type":"Asset","name":"Bitcoin","id":"fa6fb871-10ad-4b25-ba74-b37d6a9a3025"}}},{"type":"Exchange Account Asset","name":"Tether","project":"Superalgos","id":"f03bae52-5924-42a5-94ff-43e278d1cef2","savedPayload":{"position":{"x":21114.34622617183,"y":30964.937739858997},"targetPosition":{"x":20897.01291525679,"y":30906.70345471093},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":2,"arrangementStyle":0},"uiObject":{},"referenceParent":{"type":"Asset","name":"Tether","id":"2de2fe8f-a38b-4778-8e24-d318888c629f"}}}],"id":"29d52baf-645c-4d8f-9631-ebd391b4c815","savedPayload":{"position":{"x":20897.01291525679,"y":30906.70345471093},"targetPosition":{"x":20462.346293426708,"y":31023.172025007065},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"userKeys":{"type":"User Keys","name":"New User Keys","project":"Superalgos","keys":[{"type":"Exchange Account Key","name":"New Exchange Account Key","config":"{ \n\"codeName\": \"Paste your exchange API name or label\",\n\"secret\": \"Paste your exchange API secret key\"\n}","project":"Superalgos","id":"d615c33d-c6cf-4572-ac32-8e9ddeb5bb52","savedPayload":{"position":{"x":21098.7423964946,"y":31659.568128074956},"targetPosition":{"x":20780.544344960654,"y":31341.37007654101},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":3,"arrangementStyle":0},"uiObject":{}}}],"id":"0c189040-6318-483c-b6d7-982370a3298d","savedPayload":{"position":{"x":20780.544344960654,"y":31341.37007654101},"targetPosition":{"x":20462.346293426708,"y":31023.172025007065},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"id":"cd60de4a-d17c-4ba7-936a-cbf2305fe3bb","savedPayload":{"position":{"x":20462.346293426708,"y":31023.172025007065},"targetPosition":{"x":20027.679671596627,"y":30906.703454710932},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false}}}],"id":"d247f4f5-6f16-4a59-a4a5-6d1554b43562","savedPayload":{"position":{"x":20027.679671596627,"y":30906.703454710932},"targetPosition":{"x":19593.013049766545,"y":30790.2348844148},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"id":"6c076027-683d-4778-8a6a-e60984980fdf","savedPayload":{"position":{"x":19489.047407693626,"y":30808.02733985051},"targetPosition":{"x":19073.301618063546,"y":30980.2348844148},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":true,"angleToParent":2,"distanceToParent":4,"arrangementStyle":0},"uiObject":{"isRunning":false}}},{"type":"Crypto Exchange","name":"FTX","config":"{\n \"codeName\": \"ftx\"\n}","project":"Superalgos","exchangeAssets":{"type":"Exchange Assets","name":"New Exchange Assets","config":"{ \n\"addMissingAssetsFilter\": { \"quotedAsset\": \"EUR\"} \n}","project":"Superalgos","assets":[{"type":"Asset","name":"Bitcoin","config":"{ \n\"codeName\": \"BTC\"\n}","project":"Superalgos","id":"51d196fb-b457-49f7-bae2-b0ef554154a3","savedPayload":{"position":{"x":19285.301618063546,"y":30915.927263279467},"targetPosition":{"x":19435.301618063546,"y":31175.7348844148},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{}}},{"type":"Asset","name":"USD","config":"{\n \"codeName\": \"USD\"\n}","project":"Superalgos","id":"85b644de-4b78-486d-a689-5db24484bf33","savedPayload":{"position":{"x":19585.301618063546,"y":30915.927263279467},"targetPosition":{"x":19435.301618063546,"y":31175.7348844148},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{}}}],"id":"7c0b83f3-d4f6-457a-881f-9cd73f293d1c","savedPayload":{"position":{"x":19435.301618063546,"y":31175.7348844148},"targetPosition":{"x":19435.301618063546,"y":31475.7348844148},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false,"shortcutKey":"E"}}},"exchangeMarkets":{"type":"Exchange Markets","name":"New Exchange Markets","code":"{ \n\"codeName\": \"Write here the code name of the Market here.\"\n}","project":"Superalgos","markets":[{"type":"Market","name":"BTC/USD","config":"{\n \"codeName\": \"BTC/USD\"\n}","project":"Superalgos","baseAsset":{"type":"Market Base Asset","name":"Bitcoin","project":"Superalgos","id":"6b882b1c-d15c-4499-aa93-9f80e3ccb59a","savedPayload":{"position":{"x":20009.565686775473,"y":30791.66319456754},"targetPosition":{"x":19859.565686775473,"y":31051.470815702873},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":3,"distanceToParent":3,"arrangementStyle":0},"uiObject":{},"referenceParent":{"type":"Asset","name":"Bitcoin","id":"51d196fb-b457-49f7-bae2-b0ef554154a3"}}},"quotedAsset":{"type":"Market Quoted Asset","name":"USD","project":"Superalgos","id":"6eada284-7adc-4eda-9448-7165704e350e","savedPayload":{"position":{"x":20119.373307910806,"y":30901.470815702873},"targetPosition":{"x":19859.565686775473,"y":31051.470815702873},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":3,"distanceToParent":3,"arrangementStyle":0},"uiObject":{},"referenceParent":{"type":"Asset","name":"USD","id":"85b644de-4b78-486d-a689-5db24484bf33"}}},"id":"f4814fb1-d09a-45ad-8352-c0743b3a8558","savedPayload":{"position":{"x":19859.565686775473,"y":31051.470815702873},"targetPosition":{"x":19647.43365241951,"y":31263.602850058836},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":3,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false}}}],"id":"f8c75d46-aa08-4579-a4a3-ea797f70944d","savedPayload":{"position":{"x":19647.43365241951,"y":31263.602850058836},"targetPosition":{"x":19435.301618063546,"y":31475.7348844148},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"exchangeAccounts":{"type":"Exchange Accounts","name":"New Exchange Accounts","project":"Superalgos","userAccounts":[{"type":"User Account","name":"New User Account","project":"Superalgos","userAssets":{"type":"User Assets","name":"New User Assets","project":"Superalgos","assets":[{"type":"Exchange Account Asset","name":"Bitcoin","project":"Superalgos","id":"6e4dc8ba-da96-43c5-bf8c-71ee115ae628","savedPayload":{"position":{"x":20445.10923919888,"y":31065.927263279467},"targetPosition":{"x":20295.10923919888,"y":31325.7348844148},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{},"referenceParent":{"type":"Asset","name":"Bitcoin","id":"51d196fb-b457-49f7-bae2-b0ef554154a3"}}},{"type":"Exchange Account Asset","name":"USD","project":"Superalgos","id":"e4ba801d-fa96-4fed-a520-e6e80f3f67d1","savedPayload":{"position":{"x":20595.10923919888,"y":31325.7348844148},"targetPosition":{"x":20295.10923919888,"y":31325.7348844148},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{},"referenceParent":{"type":"Asset","name":"USD","id":"85b644de-4b78-486d-a689-5db24484bf33"}}}],"id":"421bb949-bde1-41d3-95b0-7b6b3c3ebf0c","savedPayload":{"position":{"x":20295.10923919888,"y":31325.7348844148},"targetPosition":{"x":20035.301618063546,"y":31475.7348844148},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"userKeys":{"type":"User Keys","name":"New User Keys","project":"Superalgos","keys":[{"type":"Exchange Account Key","name":"Key for Lighting Strike","config":"{ \n\"codeName\": \"Paste your exchange API name or label\",\n\"secret\": \"Paste your exchange API secret key\"\n}","project":"Superalgos","id":"ffd11b5a-751b-4264-bb69-f2c094ffe341","savedPayload":{"position":{"x":20554.91686033421,"y":31775.7348844148},"targetPosition":{"x":20295.10923919888,"y":31625.7348844148},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":true,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{}}}],"id":"cad1a06c-8ce7-4eb0-8046-924764a45662","savedPayload":{"position":{"x":20295.10923919888,"y":31625.7348844148},"targetPosition":{"x":20035.301618063546,"y":31475.7348844148},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"id":"52652029-df80-42d5-8300-843b764a1b47","savedPayload":{"position":{"x":20035.301618063546,"y":31475.7348844148},"targetPosition":{"x":19735.301618063546,"y":31475.7348844148},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false}}}],"id":"928314c7-c4a7-4aec-8096-074e557a71d0","savedPayload":{"position":{"x":19735.301618063546,"y":31475.7348844148},"targetPosition":{"x":19435.301618063546,"y":31475.7348844148},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"id":"b3e7f4de-1ca4-442f-8898-cb7397dc45d3","savedPayload":{"position":{"x":19523.301618063546,"y":30980.2348844148},"targetPosition":{"x":19073.301618063546,"y":30980.2348844148},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":true,"angleToParent":2,"distanceToParent":4,"arrangementStyle":0},"uiObject":{"isRunning":false,"shortcutKey":""}}},{"type":"Crypto Exchange","name":"Kraken","config":"{ \n\"codeName\": \"kraken\"\n}","project":"Superalgos","exchangeAssets":{"type":"Exchange Assets","name":"New Exchange Assets","config":"{\n \"addMissingAssetsFilter\": {\n \"quotedAsset\": \"USDT\"\n }\n}","project":"Superalgos","assets":[{"type":"Asset","name":"BTC","config":"{\n \"codeName\": \"BTC\"\n}","project":"Superalgos","id":"a18c644d-3d51-413e-8abe-dd7698c2d03a","savedPayload":{"position":{"x":19564.91960434743,"y":31467.40024970227},"targetPosition":{"x":19453.382057442876,"y":31482.084446327026},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":2,"arrangementStyle":0},"uiObject":{}}},{"type":"Asset","name":"USDT","config":"{\n \"codeName\": \"USDT\"\n}","project":"Superalgos","id":"e45ae556-e162-4d1f-ac5e-f8245d3d7f70","savedPayload":{"position":{"x":19521.86771820636,"y":31571.33669710979},"targetPosition":{"x":19453.382057442876,"y":31482.084446327026},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":2,"arrangementStyle":0},"uiObject":{}}}],"id":"2a7dfb85-9179-4c30-9b63-072adaa7b317","savedPayload":{"position":{"x":19453.382057442876,"y":31482.084446327026},"targetPosition":{"x":19245.509162627837,"y":31395.98067404488},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":2,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"exchangeMarkets":{"type":"Exchange Markets","name":"New Exchange Markets","project":"Superalgos","markets":[{"type":"Market","name":"BTC/USDT","config":"{\n \"codeName\": \"USDT/BTC\"\n}","project":"Superalgos","baseAsset":{"type":"Market Base Asset","name":"BTC","project":"Superalgos","id":"94349e75-3c40-4a66-bc82-61460105e591","savedPayload":{"position":{"x":19946.933254887477,"y":32501.414896358965},"targetPosition":{"x":19589.92425175642,"y":32227.47225330504},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{},"referenceParent":{"type":"Asset","name":"BTC","id":"a18c644d-3d51-413e-8abe-dd7698c2d03a"}}},"quotedAsset":{"type":"Market Quoted Asset","name":"USDT","project":"Superalgos","id":"4759c142-6e8c-4ce2-8b5c-c783f630bb3b","savedPayload":{"position":{"x":19531.187465257397,"y":32673.622440923256},"targetPosition":{"x":19589.92425175642,"y":32227.47225330504},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{},"referenceParent":{"type":"Asset","name":"USDT","id":"e45ae556-e162-4d1f-ac5e-f8245d3d7f70"}}},"id":"71f99544-bf86-49e7-8896-5f96f875f262","savedPayload":{"position":{"x":19589.92425175642,"y":32227.47225330504},"targetPosition":{"x":19417.71670719213,"y":31811.72646367496},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false}}}],"id":"07267ef1-f15a-43cb-94f6-c13075c3ba61","savedPayload":{"position":{"x":19417.71670719213,"y":31811.72646367496},"targetPosition":{"x":19245.509162627837,"y":31395.98067404488},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"exchangeAccounts":{"type":"Exchange Accounts","name":"New Exchange Accounts","project":"Superalgos","userAccounts":[{"type":"User Account","name":"New User Account","project":"Superalgos","userAssets":{"type":"User Assets","name":"New User Assets","project":"Superalgos","assets":[{"type":"Exchange Account Asset","name":"BTC","project":"Superalgos","id":"e73d040b-c8bb-40fb-8748-f73ae5780310","savedPayload":{"position":{"x":19282.693218981094,"y":32109.369611642072},"targetPosition":{"x":19145.721897454132,"y":31930.865110076546},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{},"referenceParent":{"type":"Asset","name":"BTC","id":"a18c644d-3d51-413e-8abe-dd7698c2d03a"}}},{"type":"Exchange Account Asset","name":"USDT","project":"Superalgos","id":"37ebe76e-55a2-413e-b6f5-ce54a6afb604","savedPayload":{"position":{"x":19059.618125171986,"y":32138.738004891584},"targetPosition":{"x":19145.721897454132,"y":31930.865110076546},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{},"referenceParent":{"type":"Asset","name":"USDT","id":"e45ae556-e162-4d1f-ac5e-f8245d3d7f70"}}}],"id":"695d852f-eab0-4114-a8a4-323efa22ceb7","savedPayload":{"position":{"x":19145.721897454132,"y":31930.865110076546},"targetPosition":{"x":19116.35350420462,"y":31707.790016267438},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"userKeys":{"type":"User Keys","name":"New User Keys","project":"Superalgos","keys":[{"type":"Exchange Account Key","name":"New Exchange Account Key","config":"{ \n\"codeName\": \"Paste your exchange API name or label\",\n\"secret\": \"Paste your exchange API secret key\"\n}","project":"Superalgos","id":"81b848a0-66d2-4825-a951-eca8f3713896","savedPayload":{"position":{"x":18580.839999508036,"y":32118.703980848324},"targetPosition":{"x":18937.849002639094,"y":31844.7613377944},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{}}}],"id":"28bab5eb-0cb5-434a-983c-8f5fb58c0e41","savedPayload":{"position":{"x":18937.849002639094,"y":31844.7613377944},"targetPosition":{"x":19116.35350420462,"y":31707.790016267438},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"id":"6a427672-e76c-4793-b2a8-8f9034bb323e","savedPayload":{"position":{"x":19116.35350420462,"y":31707.790016267438},"targetPosition":{"x":19202.457276486766,"y":31499.9171214524},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}}],"id":"9ff22337-d0b7-4d9e-8896-bd046802b961","savedPayload":{"position":{"x":19202.457276486766,"y":31499.9171214524},"targetPosition":{"x":19245.509162627837,"y":31395.98067404488},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":1,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"id":"793d2f4a-3315-4c18-abad-f4d74c83ac4f","savedPayload":{"position":{"x":19489.047407693626,"y":31152.44242897909},"targetPosition":{"x":19073.301618063546,"y":30980.2348844148},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":true,"angleToParent":2,"distanceToParent":4,"arrangementStyle":0},"uiObject":{"isRunning":false}}},{"type":"Crypto Exchange","name":"Kucoin","config":"{\n \"codeName\": \"kucoin\"\n}","project":"Superalgos","exchangeAssets":{"type":"Exchange Assets","name":"New Exchange Assets","config":"{ \n\"addMissingAssetsFilter\": { \"quotedAsset\": \"USDT\"} \n}","project":"Superalgos","assets":[{"type":"Asset","name":"BTC","config":"{\n \"codeName\": \"BTC\"\n}","project":"Superalgos","id":"5ce98b3f-3ec1-412b-acde-186f9a92a5e0","savedPayload":{"position":{"x":19829.745532847643,"y":31102.003746373946},"targetPosition":{"x":19648.71103240014,"y":31235.613288127985},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{}}},{"type":"Asset","name":"Tether","config":"{\n \"codeName\": \"USDT\"\n}","project":"Superalgos","id":"b866944c-c23e-4718-9300-1b803b54be5f","savedPayload":{"position":{"x":19854.937539970884,"y":31325.588993599926},"targetPosition":{"x":19648.71103240014,"y":31235.613288127985},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{}}}],"id":"747af60f-c8b9-4377-aa6c-172d4137ea23","savedPayload":{"position":{"x":19648.71103240014,"y":31235.613288127985},"targetPosition":{"x":19425.12578517416,"y":31260.80529525123},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":2,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"exchangeMarkets":{"type":"Exchange Markets","name":"New Exchange Markets","project":"Superalgos","markets":[{"type":"Market","name":"BTC/USDT","config":"{\n \"codeName\": \"BTC/USDT\"\n}","project":"Superalgos","baseAsset":{"type":"Market Base Asset","name":"BTC","project":"Superalgos","id":"69a1674d-6260-4c65-95d5-fbba592737f9","savedPayload":{"position":{"x":20573.7479911967,"y":31889.01513670337},"targetPosition":{"x":20128.77411939539,"y":31821.94611692409},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{},"referenceParent":{"type":"Asset","name":"BTC","id":"5ce98b3f-3ec1-412b-acde-186f9a92a5e0"}}},"quotedAsset":{"type":"Market Quoted Asset","name":"Tether","project":"Superalgos","id":"135835f5-a9be-4415-aeef-03500f24b4d1","savedPayload":{"position":{"x":20293.17758036027,"y":32240.83930381398},"targetPosition":{"x":20128.77411939539,"y":31821.94611692409},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{},"referenceParent":{"type":"Asset","name":"Tether","id":"b866944c-c23e-4718-9300-1b803b54be5f"}}},"id":"4b37ca8d-e4b2-49f4-b326-7bdf785ad482","savedPayload":{"position":{"x":20128.77411939539,"y":31821.94611692409},"targetPosition":{"x":19776.949952284776,"y":31541.37570608766},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false}}}],"id":"c75f7d97-9dc2-4d3e-89eb-f8a3d5f16368","savedPayload":{"position":{"x":19776.949952284776,"y":31541.37570608766},"targetPosition":{"x":19425.12578517416,"y":31260.80529525123},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"exchangeAccounts":{"type":"Exchange Accounts","name":"New Exchange Accounts","project":"Superalgos","userAccounts":[{"type":"User Account","name":"New User Account","project":"Superalgos","userAssets":{"type":"User Assets","name":"New User Assets","project":"Superalgos","assets":[{"type":"Exchange Account Asset","name":"BTC","project":"Superalgos","id":"0fa01ebd-8837-482f-bffc-7bee682c9600","savedPayload":{"position":{"x":19802.74984518381,"y":31867.193372009642},"targetPosition":{"x":19596.523337613067,"y":31777.2176665377},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{},"referenceParent":{"type":"Asset","name":"BTC","id":"5ce98b3f-3ec1-412b-acde-186f9a92a5e0"}}},{"type":"Exchange Account Asset","name":"Tether","project":"Superalgos","id":"27131d22-9a2f-48e0-b22e-a12e23a9cb3a","savedPayload":{"position":{"x":19621.715344736313,"y":32000.80291376368},"targetPosition":{"x":19596.523337613067,"y":31777.2176665377},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{},"referenceParent":{"type":"Asset","name":"Tether","id":"b866944c-c23e-4718-9300-1b803b54be5f"}}}],"id":"0093e946-03f4-4aec-942d-c76aed12ab1a","savedPayload":{"position":{"x":19596.523337613067,"y":31777.2176665377},"targetPosition":{"x":19462.91379585903,"y":31596.1831660902},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"userKeys":{"type":"User Keys","name":"New User Keys","project":"Superalgos","keys":[{"type":"Exchange Account Key","name":"New Exchange Account Key","config":"{ \n\"codeName\": \"Paste your exchange API name or label\",\n\"secret\": \"Paste your exchange API secret key\"\n}","project":"Superalgos","id":"2a4235ac-e5ea-4484-bccd-f06c8a7275ec","savedPayload":{"position":{"x":19282.962384915147,"y":32008.636181231686},"targetPosition":{"x":19372.938090387088,"y":31802.409673660943},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":3,"arrangementStyle":0},"uiObject":{}}}],"id":"737dec0a-23ab-4044-94ba-95c8bc50c0eb","savedPayload":{"position":{"x":19372.938090387088,"y":31802.409673660943},"targetPosition":{"x":19462.91379585903,"y":31596.1831660902},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"id":"457b045e-dae5-4f53-a8b7-cab4757e5286","savedPayload":{"position":{"x":19462.91379585903,"y":31596.1831660902},"targetPosition":{"x":19437.721788735784,"y":31372.59791886422},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}}],"id":"6eff12db-8e7c-402a-9e06-ae2618f506a0","savedPayload":{"position":{"x":19437.721788735784,"y":31372.59791886422},"targetPosition":{"x":19425.12578517416,"y":31260.80529525123},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":1,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"id":"644efe9c-597a-4ddf-9e28-b33fb3b62d3e","savedPayload":{"position":{"x":19391.49966959749,"y":31298.432935948746},"targetPosition":{"x":19073.301618063546,"y":30980.2348844148},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":true,"angleToParent":2,"distanceToParent":4,"arrangementStyle":0},"uiObject":{"isRunning":false}}},{"type":"Crypto Exchange","name":"Luno","config":"{\n \"codeName\": \"luno\",\n \"API\": [\n {\n \"method\": \"fetch_ohlcv\",\n \"useFetchTradesForFetchOHLCVs\": true,\n \"maxTradesPerFetch\": 100,\n \"limit\": 200,\n \"rateLimit\": 1100\n }\n ]\n}","project":"Superalgos","exchangeAssets":{"type":"Exchange Assets","name":"New Exchange Assets","config":"{ \n\"addMissingAssetsFilter\": { \"quotedAsset\": \"EUR\"} \n}","project":"Superalgos","assets":[{"type":"Asset","name":"Bitcoin","config":"{\n \"codeName\": \"BTC\"\n}","project":"Superalgos","id":"ac9cd2e1-566d-4bf9-83b2-a60403442302","savedPayload":{"position":{"x":19965.019021441563,"y":30875.45713652808},"targetPosition":{"x":19752.8869870856,"y":31087.589170884043},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{}}},{"type":"Asset","name":"ZAR","config":"{\n \"codeName\": \"ZAR\"\n}","project":"Superalgos","id":"0aefdb7b-972c-4c98-90cd-23317f2bd51f","savedPayload":{"position":{"x":20042.66473497232,"y":31165.2348844148},"targetPosition":{"x":19752.8869870856,"y":31087.589170884043},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{}}}],"id":"ac60a01f-74b1-41f2-93f4-5b7d5cc2b2ad","savedPayload":{"position":{"x":19752.8869870856,"y":31087.589170884043},"targetPosition":{"x":19463.10923919888,"y":31165.2348844148},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false,"shortcutKey":"E"}}},"exchangeMarkets":{"type":"Exchange Markets","name":"New Exchange Markets","code":"{ \n\"codeName\": \"Write here the code name of the Market here.\"\n}","project":"Superalgos","markets":[{"type":"Market","name":"BTC/ZAR","config":"{\n \"codeName\": \"BTC/ZAR\"\n}","project":"Superalgos","baseAsset":{"type":"Market Base Asset","name":"Bitcoin","project":"Superalgos","id":"29b5f490-2015-4039-8123-f29aa76d2546","savedPayload":{"position":{"x":20272.502229356265,"y":31542.880597945557},"targetPosition":{"x":19982.724481469544,"y":31465.2348844148},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":3,"distanceToParent":3,"arrangementStyle":0},"uiObject":{},"referenceParent":{"type":"Asset","name":"Bitcoin","id":"ac9cd2e1-566d-4bf9-83b2-a60403442302"}}},"quotedAsset":{"type":"Market Quoted Asset","name":"ZAR","project":"Superalgos","id":"6dffe17d-bbd1-424e-afba-9717386ae271","savedPayload":{"position":{"x":20194.856515825508,"y":31677.366918770764},"targetPosition":{"x":19982.724481469544,"y":31465.2348844148},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":3,"distanceToParent":3,"arrangementStyle":0},"uiObject":{},"referenceParent":{"type":"Asset","name":"ZAR","id":"0aefdb7b-972c-4c98-90cd-23317f2bd51f"}}},"id":"06796c17-169b-4815-969c-d33baca2b0ef","savedPayload":{"position":{"x":19982.724481469544,"y":31465.2348844148},"targetPosition":{"x":19722.91686033421,"y":31315.2348844148},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":3,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false}}}],"id":"e13d8073-26f6-4ae4-b612-aea2ec269fed","savedPayload":{"position":{"x":19722.91686033421,"y":31315.2348844148},"targetPosition":{"x":19463.10923919888,"y":31165.2348844148},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"exchangeAccounts":{"type":"Exchange Accounts","name":"New Exchange Accounts","project":"Superalgos","userAccounts":[{"type":"User Account","name":"New User Account","project":"Superalgos","userAssets":{"type":"User Assets","name":"New User Assets","project":"Superalgos","assets":[{"type":"Exchange Account Asset","name":"Bitcoin","project":"Superalgos","id":"8d70bbca-596c-4a0e-af81-dd089f823a11","savedPayload":{"position":{"x":20120.310448503078,"y":32034.568128074963},"targetPosition":{"x":19830.532700616357,"y":31956.922414544206},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{},"referenceParent":{"type":"Asset","name":"Bitcoin","id":"ac9cd2e1-566d-4bf9-83b2-a60403442302"}}},{"type":"Exchange Account Asset","name":"ZAR","project":"Superalgos","id":"fc0a7029-992c-4954-9695-fd98922b298a","savedPayload":{"position":{"x":19908.178414147114,"y":32246.700162430927},"targetPosition":{"x":19830.532700616357,"y":31956.922414544206},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{},"referenceParent":{"type":"Asset","name":"ZAR","id":"0aefdb7b-972c-4c98-90cd-23317f2bd51f"}}}],"id":"9aa9be52-1db3-4e4e-ba0b-428d3fbd69a6","savedPayload":{"position":{"x":19830.532700616357,"y":31956.922414544206},"targetPosition":{"x":19618.400666260393,"y":31744.790380188242},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"userKeys":{"type":"User Keys","name":"New User Keys","project":"Superalgos","keys":[{"type":"Exchange Account Key","name":"Key for Lighting Strike","config":"{ \n\"codeName\": \"Paste your exchange API name or label\",\n\"secret\": \"Paste your exchange API secret key\"\n}","project":"Superalgos","id":"13c27632-3079-49c6-a864-85208ce741eb","savedPayload":{"position":{"x":19463.10923919888,"y":32324.345875961684},"targetPosition":{"x":19540.754952729636,"y":32034.568128074963},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":true,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{}}}],"id":"d58f597c-56f6-4900-b153-830c39546a14","savedPayload":{"position":{"x":19540.754952729636,"y":32034.568128074963},"targetPosition":{"x":19618.400666260393,"y":31744.790380188242},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"id":"c70e6430-bccd-46c9-aa15-b91e07c4bec0","savedPayload":{"position":{"x":19618.400666260393,"y":31744.790380188242},"targetPosition":{"x":19540.754952729636,"y":31455.01263230152},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false}}}],"id":"a5039403-0e35-4949-b690-3f8cb7e56add","savedPayload":{"position":{"x":19540.754952729636,"y":31455.01263230152},"targetPosition":{"x":19463.10923919888,"y":31165.2348844148},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"id":"d4a66325-9be9-4855-8cf4-89a5795e30b6","savedPayload":{"position":{"x":19245.509162627837,"y":31395.98067404488},"targetPosition":{"x":19073.301618063546,"y":30980.2348844148},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":true,"angleToParent":2,"distanceToParent":4,"arrangementStyle":0},"uiObject":{"isRunning":false,"shortcutKey":""}}}],"id":"e3879d63-6f8f-41a3-8ac3-0349c4361722","savedPayload":{"position":{"x":19073.301618063546,"y":30980.2348844148},"targetPosition":{"x":18773.301618063546,"y":30980.2348844148},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false}}},{"type":"Crypto Exchanges","name":"Untested","project":"Superalgos","exchanges":[{"type":"Crypto Exchange","name":"ACX","config":"{ \n\"codeName\": \"acx\"\n}","project":"Superalgos","exchangeAssets":{"type":"Exchange Assets","name":"New Exchange Assets","config":"{ \n\"addMissingAssetsFilter\": { \"quotedAsset\": \"USDT\"} \n}","project":"Superalgos","assets":[],"id":"ebcb522b-ae58-46d2-9d82-a9b0beec3976","savedPayload":{"position":{"x":17935.64382962515,"y":31014.23747069523},"targetPosition":{"x":17912.64382962515,"y":30954.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":2,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"exchangeMarkets":{"type":"Exchange Markets","name":"New Exchange Markets","project":"Superalgos","markets":[],"id":"b2649588-27c6-442c-b179-f6d8817188b3","savedPayload":{"position":{"x":17954.64382962515,"y":31004.23747069523},"targetPosition":{"x":17912.64382962515,"y":30954.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"exchangeAccounts":{"type":"Exchange Accounts","name":"New Exchange Accounts","project":"Superalgos","userAccounts":[{"type":"User Account","name":"New User Account","project":"Superalgos","userAssets":{"type":"User Assets","name":"New User Assets","project":"Superalgos","assets":[],"id":"9b2051d5-7ee7-4e94-8c8d-306674889339","savedPayload":{"position":{"x":17838.64382962515,"y":30896.23747069523},"targetPosition":{"x":17766.64382962515,"y":30905.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"userKeys":{"type":"User Keys","name":"New User Keys","project":"Superalgos","keys":[{"type":"Exchange Account Key","name":"New Exchange Account Key","config":"{ \n\"codeName\": \"Paste your exchange API name or label\",\n\"secret\": \"Paste your exchange API secret key\"\n}","project":"Superalgos","id":"1d5461aa-d26c-4df5-b383-8c83e311b8ca","savedPayload":{"position":{"x":17643.64382962515,"y":30952.23747069523},"targetPosition":{"x":17698.64382962515,"y":30973.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{}}}],"id":"c6372400-de52-4b63-97f3-f748aac9c63f","savedPayload":{"position":{"x":17698.64382962515,"y":30973.23747069523},"targetPosition":{"x":17766.64382962515,"y":30905.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"id":"c948314e-2247-4234-b83d-cc2c1b152665","savedPayload":{"position":{"x":17766.64382962515,"y":30905.23747069523},"targetPosition":{"x":17837.64382962515,"y":30978.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}}],"id":"04ccb742-ef1b-4138-b38d-a6b0d92f2f8e","savedPayload":{"position":{"x":17837.64382962515,"y":30978.23747069523},"targetPosition":{"x":17912.64382962515,"y":30954.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":1,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"id":"e9c21b2d-de21-43b5-8b48-51367a8c981c","savedPayload":{"position":{"x":19187.85400740677,"y":30535.788467410555},"targetPosition":{"x":18473.301618063546,"y":31499.850126685462},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":true,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}},{"type":"Crypto Exchange","name":"AOFEX","config":"{ \n\"codeName\": \"aofex\"\n}","project":"Superalgos","exchangeAssets":{"type":"Exchange Assets","name":"New Exchange Assets","config":"{ \n\"addMissingAssetsFilter\": { \"quotedAsset\": \"USDT\"} \n}","project":"Superalgos","assets":[],"id":"623ef91b-04c0-4bd5-ac0d-b32c809be3ea","savedPayload":{"position":{"x":17973.64382962515,"y":30923.23747069523},"targetPosition":{"x":17950.64382962515,"y":30994.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":2,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"exchangeMarkets":{"type":"Exchange Markets","name":"New Exchange Markets","project":"Superalgos","markets":[],"id":"9d0b5855-59a6-4dda-9a4b-33d7a44d582e","savedPayload":{"position":{"x":17901.64382962515,"y":30994.23747069523},"targetPosition":{"x":17950.64382962515,"y":30994.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"exchangeAccounts":{"type":"Exchange Accounts","name":"New Exchange Accounts","project":"Superalgos","userAccounts":[{"type":"User Account","name":"New User Account","project":"Superalgos","userAssets":{"type":"User Assets","name":"New User Assets","project":"Superalgos","assets":[],"id":"e898e569-0dd3-4a22-baa5-caaace66d4ed","savedPayload":{"position":{"x":18062.64382962515,"y":30838.23747069523},"targetPosition":{"x":17982.64382962515,"y":30899.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"userKeys":{"type":"User Keys","name":"New User Keys","project":"Superalgos","keys":[{"type":"Exchange Account Key","name":"New Exchange Account Key","config":"{ \n\"codeName\": \"Paste your exchange API name or label\",\n\"secret\": \"Paste your exchange API secret key\"\n}","project":"Superalgos","id":"64a69d3d-15ff-41c3-a926-5ec93c932ab1","savedPayload":{"position":{"x":17822.64382962515,"y":31052.23747069523},"targetPosition":{"x":17893.64382962515,"y":30981.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{}}}],"id":"ae2785c5-75a1-44fc-a71b-363d88cb5dac","savedPayload":{"position":{"x":17893.64382962515,"y":30981.23747069523},"targetPosition":{"x":17982.64382962515,"y":30899.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"id":"07ea69aa-7357-43b1-b548-a4c4fab70c55","savedPayload":{"position":{"x":17982.64382962515,"y":30899.23747069523},"targetPosition":{"x":17971.64382962515,"y":30962.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}}],"id":"2146b410-fc4e-452d-ae57-5d58c9a29706","savedPayload":{"position":{"x":17971.64382962515,"y":30962.23747069523},"targetPosition":{"x":17950.64382962515,"y":30994.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":1,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"id":"c2e9bb45-97c7-47e8-b13c-56946e673c53","savedPayload":{"position":{"x":19293.091113587867,"y":30623.52531074791},"targetPosition":{"x":18473.301618063546,"y":31499.850126685462},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":true,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}},{"type":"Crypto Exchange","name":"Bequant","config":"{ \n\"codeName\": \"bequant\"\n}","project":"Superalgos","exchangeAssets":{"type":"Exchange Assets","name":"New Exchange Assets","config":"{ \n\"addMissingAssetsFilter\": { \"quotedAsset\": \"USDT\"} \n}","project":"Superalgos","assets":[],"id":"b23c8adf-c880-48fd-b4af-4b4be86cf0e5","savedPayload":{"position":{"x":18059.64382962515,"y":31101.23747069523},"targetPosition":{"x":17960.64382962515,"y":31060.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":2,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"exchangeMarkets":{"type":"Exchange Markets","name":"New Exchange Markets","project":"Superalgos","markets":[],"id":"523bd94f-68f9-457e-91fd-806c1b95e98d","savedPayload":{"position":{"x":18006.64382962515,"y":31117.23747069523},"targetPosition":{"x":17960.64382962515,"y":31060.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"exchangeAccounts":{"type":"Exchange Accounts","name":"New Exchange Accounts","project":"Superalgos","userAccounts":[{"type":"User Account","name":"New User Account","project":"Superalgos","userAssets":{"type":"User Assets","name":"New User Assets","project":"Superalgos","assets":[],"id":"9d914bb1-a68b-41ae-8666-0fcc755358c1","savedPayload":{"position":{"x":17859.64382962515,"y":30964.23747069523},"targetPosition":{"x":17936.64382962515,"y":31059.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"userKeys":{"type":"User Keys","name":"New User Keys","project":"Superalgos","keys":[{"type":"Exchange Account Key","name":"New Exchange Account Key","config":"{ \n\"codeName\": \"Paste your exchange API name or label\",\n\"secret\": \"Paste your exchange API secret key\"\n}","project":"Superalgos","id":"15d903b5-113c-465e-8120-7c46a9a85565","savedPayload":{"position":{"x":17976.64382962515,"y":31146.23747069523},"targetPosition":{"x":17943.64382962515,"y":31134.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{}}}],"id":"2d1c0bc3-abe2-4340-91bf-2eef5b98a2f0","savedPayload":{"position":{"x":17943.64382962515,"y":31134.23747069523},"targetPosition":{"x":17936.64382962515,"y":31059.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"id":"5a50d459-914c-4bfc-91e8-f15c383280eb","savedPayload":{"position":{"x":17936.64382962515,"y":31059.23747069523},"targetPosition":{"x":17931.64382962515,"y":31071.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}}],"id":"b2f2b69f-3bef-4edc-9950-5261d9f36382","savedPayload":{"position":{"x":17931.64382962515,"y":31071.23747069523},"targetPosition":{"x":17960.64382962515,"y":31060.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":1,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"id":"8e928d3e-a2c2-4341-aa2f-b753551c9479","savedPayload":{"position":{"x":19387.64100998835,"y":30722.6863882271},"targetPosition":{"x":18473.301618063546,"y":31499.850126685462},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":true,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}},{"type":"Crypto Exchange","name":"Bibox","config":"{ \n\"codeName\": \"bibox\"\n}","project":"Superalgos","exchangeAssets":{"type":"Exchange Assets","name":"New Exchange Assets","config":"{ \n\"addMissingAssetsFilter\": { \"quotedAsset\": \"USDT\"} \n}","project":"Superalgos","assets":[],"id":"13c1f22c-9a35-4d3f-b000-c96984fd6a2b","savedPayload":{"position":{"x":17995.64382962515,"y":31047.23747069523},"targetPosition":{"x":17929.64382962515,"y":31003.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":2,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"exchangeMarkets":{"type":"Exchange Markets","name":"New Exchange Markets","project":"Superalgos","markets":[],"id":"3c6df49d-70c3-468a-bdd8-6768ce6d3a9d","savedPayload":{"position":{"x":17916.64382962515,"y":31018.23747069523},"targetPosition":{"x":17929.64382962515,"y":31003.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"exchangeAccounts":{"type":"Exchange Accounts","name":"New Exchange Accounts","project":"Superalgos","userAccounts":[{"type":"User Account","name":"New User Account","project":"Superalgos","userAssets":{"type":"User Assets","name":"New User Assets","project":"Superalgos","assets":[],"id":"5a54ef39-8fba-4a5f-ac24-5f27e763e28f","savedPayload":{"position":{"x":18050.64382962515,"y":31174.23747069523},"targetPosition":{"x":17956.64382962515,"y":31128.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"userKeys":{"type":"User Keys","name":"New User Keys","project":"Superalgos","keys":[{"type":"Exchange Account Key","name":"New Exchange Account Key","config":"{ \n\"codeName\": \"Paste your exchange API name or label\",\n\"secret\": \"Paste your exchange API secret key\"\n}","project":"Superalgos","id":"08df1f45-dab0-463a-8758-359973f2620d","savedPayload":{"position":{"x":17899.64382962515,"y":31242.23747069523},"targetPosition":{"x":17959.64382962515,"y":31180.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{}}}],"id":"105b52c2-90ad-4fa1-b690-d8fab14209b4","savedPayload":{"position":{"x":17959.64382962515,"y":31180.23747069523},"targetPosition":{"x":17956.64382962515,"y":31128.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"id":"68c1ef42-1b7b-4cc6-981f-80b20dabcd89","savedPayload":{"position":{"x":17956.64382962515,"y":31128.23747069523},"targetPosition":{"x":17907.64382962515,"y":31057.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}}],"id":"fc35e5d0-ea61-42b6-979a-859f19c5ac6c","savedPayload":{"position":{"x":17907.64382962515,"y":31057.23747069523},"targetPosition":{"x":17929.64382962515,"y":31003.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":1,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"id":"e5f9ee4d-77a3-48ae-b354-b2f6a97d5e47","savedPayload":{"position":{"x":19470.27109411321,"y":30831.978983555848},"targetPosition":{"x":18473.301618063546,"y":31499.850126685462},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":true,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}},{"type":"Crypto Exchange","name":"BigONE","config":"{ \n\"codeName\": \"bigone\"\n}","project":"Superalgos","exchangeAssets":{"type":"Exchange Assets","name":"New Exchange Assets","config":"{ \n\"addMissingAssetsFilter\": { \"quotedAsset\": \"USDT\"} \n}","project":"Superalgos","assets":[],"id":"3f289513-c1c8-457c-b65a-8cf62b5f5eb5","savedPayload":{"position":{"x":17778.64382962515,"y":31071.23747069523},"targetPosition":{"x":17839.64382962515,"y":31063.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":2,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"exchangeMarkets":{"type":"Exchange Markets","name":"New Exchange Markets","project":"Superalgos","markets":[],"id":"8b365e73-1cee-496a-921f-121cb628a130","savedPayload":{"position":{"x":17798.64382962515,"y":31121.23747069523},"targetPosition":{"x":17839.64382962515,"y":31063.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"exchangeAccounts":{"type":"Exchange Accounts","name":"New Exchange Accounts","project":"Superalgos","userAccounts":[{"type":"User Account","name":"New User Account","project":"Superalgos","userAssets":{"type":"User Assets","name":"New User Assets","project":"Superalgos","assets":[],"id":"447a4f6f-cfa0-443e-9339-d7c1153ada31","savedPayload":{"position":{"x":17921.64382962515,"y":31046.23747069523},"targetPosition":{"x":17891.64382962515,"y":31102.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"userKeys":{"type":"User Keys","name":"New User Keys","project":"Superalgos","keys":[{"type":"Exchange Account Key","name":"New Exchange Account Key","config":"{ \n\"codeName\": \"Paste your exchange API name or label\",\n\"secret\": \"Paste your exchange API secret key\"\n}","project":"Superalgos","id":"0d234c53-c121-471e-bce1-a258c13cd148","savedPayload":{"position":{"x":17848.64382962515,"y":31175.23747069523},"targetPosition":{"x":17944.64382962515,"y":31086.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{}}}],"id":"816e1b6a-d790-4abd-9ae1-e203fa737af2","savedPayload":{"position":{"x":17944.64382962515,"y":31086.23747069523},"targetPosition":{"x":17891.64382962515,"y":31102.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"id":"561a57f7-8c22-4e50-840d-d983ed6bb864","savedPayload":{"position":{"x":17891.64382962515,"y":31102.23747069523},"targetPosition":{"x":17813.64382962515,"y":31064.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}}],"id":"e243bd5d-ade7-46c8-876b-6ad8c6eb5e0a","savedPayload":{"position":{"x":17813.64382962515,"y":31064.23747069523},"targetPosition":{"x":17839.64382962515,"y":31063.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":1,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"id":"fb9ee540-bf12-4dda-bf87-cb6b58fce649","savedPayload":{"position":{"x":19539.904156449455,"y":30949.97830061257},"targetPosition":{"x":18473.301618063546,"y":31499.850126685462},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":true,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}},{"type":"Crypto Exchange","name":"Binance Jersey","config":"{ \n\"codeName\": \"binanceje\"\n}","project":"Superalgos","exchangeAssets":{"type":"Exchange Assets","name":"New Exchange Assets","config":"{ \n\"addMissingAssetsFilter\": { \"quotedAsset\": \"USDT\"} \n}","project":"Superalgos","assets":[],"id":"0b979ea9-7a2d-4744-9517-2dfa632dfafc","savedPayload":{"position":{"x":17852.64382962515,"y":30989.23747069523},"targetPosition":{"x":17933.64382962515,"y":30992.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":2,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"exchangeMarkets":{"type":"Exchange Markets","name":"New Exchange Markets","project":"Superalgos","markets":[],"id":"b9a4497d-20f1-4c61-9a79-444e0fe0ddf4","savedPayload":{"position":{"x":17924.64382962515,"y":30952.23747069523},"targetPosition":{"x":17933.64382962515,"y":30992.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"exchangeAccounts":{"type":"Exchange Accounts","name":"New Exchange Accounts","project":"Superalgos","userAccounts":[{"type":"User Account","name":"New User Account","project":"Superalgos","userAssets":{"type":"User Assets","name":"New User Assets","project":"Superalgos","assets":[],"id":"1b24d8a4-ec70-4501-838c-7633f6f7288e","savedPayload":{"position":{"x":17882.64382962515,"y":31051.23747069523},"targetPosition":{"x":17942.64382962515,"y":31066.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"userKeys":{"type":"User Keys","name":"New User Keys","project":"Superalgos","keys":[{"type":"Exchange Account Key","name":"New Exchange Account Key","config":"{ \n\"codeName\": \"Paste your exchange API name or label\",\n\"secret\": \"Paste your exchange API secret key\"\n}","project":"Superalgos","id":"627472e3-638f-4d68-a917-d0844d6a227b","savedPayload":{"position":{"x":17991.64382962515,"y":31190.23747069523},"targetPosition":{"x":17986.64382962515,"y":31110.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{}}}],"id":"b8ce75fb-93c9-4ca2-9b2b-9f8ed8af34f3","savedPayload":{"position":{"x":17986.64382962515,"y":31110.23747069523},"targetPosition":{"x":17942.64382962515,"y":31066.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"id":"08b226e4-14ee-4ad3-8d96-efe77cc38489","savedPayload":{"position":{"x":17942.64382962515,"y":31066.23747069523},"targetPosition":{"x":17949.64382962515,"y":31009.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}}],"id":"2771eb11-bc72-4273-9e1b-9ac5410c6354","savedPayload":{"position":{"x":17949.64382962515,"y":31009.23747069523},"targetPosition":{"x":17933.64382962515,"y":30992.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":1,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"id":"2782350a-84a2-40ec-87c6-3c8043376a18","savedPayload":{"position":{"x":19595.632423539482,"y":31075.146037842725},"targetPosition":{"x":18473.301618063546,"y":31499.850126685462},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":true,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}},{"type":"Crypto Exchange","name":"Binance US","config":"{ \n\"codeName\": \"binanceus\"\n}","project":"Superalgos","exchangeAssets":{"type":"Exchange Assets","name":"New Exchange Assets","config":"{ \n\"addMissingAssetsFilter\": { \"quotedAsset\": \"USDT\"} \n}","project":"Superalgos","assets":[],"id":"817ee1cf-b44c-4458-a9c4-a05a17ea0510","savedPayload":{"position":{"x":17943.64382962515,"y":30999.23747069523},"targetPosition":{"x":17898.64382962515,"y":31020.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":2,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"exchangeMarkets":{"type":"Exchange Markets","name":"New Exchange Markets","project":"Superalgos","markets":[],"id":"c6694e9e-74dc-4c2e-9151-90f1d6631b45","savedPayload":{"position":{"x":17937.64382962515,"y":30989.23747069523},"targetPosition":{"x":17898.64382962515,"y":31020.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"exchangeAccounts":{"type":"Exchange Accounts","name":"New Exchange Accounts","project":"Superalgos","userAccounts":[{"type":"User Account","name":"New User Account","project":"Superalgos","userAssets":{"type":"User Assets","name":"New User Assets","project":"Superalgos","assets":[],"id":"00144904-5363-49eb-b445-8c8283d92b0d","savedPayload":{"position":{"x":17838.64382962515,"y":31193.23747069523},"targetPosition":{"x":17781.64382962515,"y":31156.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"userKeys":{"type":"User Keys","name":"New User Keys","project":"Superalgos","keys":[{"type":"Exchange Account Key","name":"New Exchange Account Key","config":"{ \n\"codeName\": \"Paste your exchange API name or label\",\n\"secret\": \"Paste your exchange API secret key\"\n}","project":"Superalgos","id":"2e71aa3c-03d4-4dbd-bc50-43b30f59e655","savedPayload":{"position":{"x":17783.64382962515,"y":31148.23747069523},"targetPosition":{"x":17703.64382962515,"y":31182.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{}}}],"id":"a4d0df32-c600-4421-b893-2a05f0442ed6","savedPayload":{"position":{"x":17703.64382962515,"y":31182.23747069523},"targetPosition":{"x":17781.64382962515,"y":31156.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"id":"7a39543a-00e1-452b-8aba-36c2b240f9fc","savedPayload":{"position":{"x":17781.64382962515,"y":31156.23747069523},"targetPosition":{"x":17799.64382962515,"y":31119.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}}],"id":"2543c4e5-8233-4348-b6dc-e47aed1ff381","savedPayload":{"position":{"x":17799.64382962515,"y":31119.23747069523},"targetPosition":{"x":17898.64382962515,"y":31020.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":1,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"id":"0b2b67d2-853b-470e-8b13-925956ad5621","savedPayload":{"position":{"x":19636.729392196376,"y":31205.850442372146},"targetPosition":{"x":18473.301618063546,"y":31499.850126685462},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":true,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}},{"type":"Crypto Exchange","name":"bitbank","config":"{ \n\"codeName\": \"bitbank\"\n}","project":"Superalgos","exchangeAssets":{"type":"Exchange Assets","name":"New Exchange Assets","config":"{ \n\"addMissingAssetsFilter\": { \"quotedAsset\": \"USDT\"} \n}","project":"Superalgos","assets":[],"id":"eb6b6842-9bf7-450e-baa3-7a87541a1cf6","savedPayload":{"position":{"x":17955.64382962515,"y":31107.23747069523},"targetPosition":{"x":17941.64382962515,"y":31102.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":2,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"exchangeMarkets":{"type":"Exchange Markets","name":"New Exchange Markets","project":"Superalgos","markets":[],"id":"6353ff56-759f-457d-81f3-fdb8ae5b3e83","savedPayload":{"position":{"x":17942.64382962515,"y":31183.23747069523},"targetPosition":{"x":17941.64382962515,"y":31102.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"exchangeAccounts":{"type":"Exchange Accounts","name":"New Exchange Accounts","project":"Superalgos","userAccounts":[{"type":"User Account","name":"New User Account","project":"Superalgos","userAssets":{"type":"User Assets","name":"New User Assets","project":"Superalgos","assets":[],"id":"a2b297c7-f33b-48b9-98fa-d339c7b0ff67","savedPayload":{"position":{"x":17999.64382962515,"y":31016.23747069523},"targetPosition":{"x":17945.64382962515,"y":31116.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"userKeys":{"type":"User Keys","name":"New User Keys","project":"Superalgos","keys":[{"type":"Exchange Account Key","name":"New Exchange Account Key","config":"{ \n\"codeName\": \"Paste your exchange API name or label\",\n\"secret\": \"Paste your exchange API secret key\"\n}","project":"Superalgos","id":"9ce6c354-b294-4062-b763-421e5edb69de","savedPayload":{"position":{"x":17883.64382962515,"y":31186.23747069523},"targetPosition":{"x":17845.64382962515,"y":31202.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{}}}],"id":"547dbf6c-a292-46c0-a628-62856858121e","savedPayload":{"position":{"x":17845.64382962515,"y":31202.23747069523},"targetPosition":{"x":17945.64382962515,"y":31116.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"id":"097055b3-37e5-4100-a24b-91e404fe49a6","savedPayload":{"position":{"x":17945.64382962515,"y":31116.23747069523},"targetPosition":{"x":17897.64382962515,"y":31142.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}}],"id":"51aed4ce-0303-431e-a15f-e6f133f7a2cf","savedPayload":{"position":{"x":17897.64382962515,"y":31142.23747069523},"targetPosition":{"x":17941.64382962515,"y":31102.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":1,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"id":"6c9a96a7-ed12-4b3e-bb51-306a8da131f5","savedPayload":{"position":{"x":19662.65930058398,"y":31340.387582401156},"targetPosition":{"x":18473.301618063546,"y":31499.850126685462},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":true,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}},{"type":"Crypto Exchange","name":"BitBay","config":"{ \n\"codeName\": \"bitbay\"\n}","project":"Superalgos","exchangeAssets":{"type":"Exchange Assets","name":"New Exchange Assets","config":"{ \n\"addMissingAssetsFilter\": { \"quotedAsset\": \"USDT\"} \n}","project":"Superalgos","assets":[],"id":"83b4e523-72a7-41ce-9363-fe0c799dcac1","savedPayload":{"position":{"x":17861.64382962515,"y":30965.23747069523},"targetPosition":{"x":17855.64382962515,"y":30961.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":2,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"exchangeMarkets":{"type":"Exchange Markets","name":"New Exchange Markets","project":"Superalgos","markets":[],"id":"966698f7-8a28-42d7-bb80-f7cd0601e44f","savedPayload":{"position":{"x":17823.64382962515,"y":31026.23747069523},"targetPosition":{"x":17855.64382962515,"y":30961.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"exchangeAccounts":{"type":"Exchange Accounts","name":"New Exchange Accounts","project":"Superalgos","userAccounts":[{"type":"User Account","name":"New User Account","project":"Superalgos","userAssets":{"type":"User Assets","name":"New User Assets","project":"Superalgos","assets":[],"id":"554829eb-3d40-4b95-a1cd-9de943763e2c","savedPayload":{"position":{"x":17914.64382962515,"y":30924.23747069523},"targetPosition":{"x":17876.64382962515,"y":30921.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"userKeys":{"type":"User Keys","name":"New User Keys","project":"Superalgos","keys":[{"type":"Exchange Account Key","name":"New Exchange Account Key","config":"{ \n\"codeName\": \"Paste your exchange API name or label\",\n\"secret\": \"Paste your exchange API secret key\"\n}","project":"Superalgos","id":"2f534989-7ca7-4c3d-b14a-3b1071543c8c","savedPayload":{"position":{"x":17845.64382962515,"y":30853.23747069523},"targetPosition":{"x":17832.64382962515,"y":30821.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{}}}],"id":"2f6b76b4-51d4-434f-8aa1-ed86b0e26bd2","savedPayload":{"position":{"x":17832.64382962515,"y":30821.23747069523},"targetPosition":{"x":17876.64382962515,"y":30921.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"id":"cbcc3ab6-9758-4273-99d2-9d05fdd392b5","savedPayload":{"position":{"x":17876.64382962515,"y":30921.23747069523},"targetPosition":{"x":17805.64382962515,"y":31015.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}}],"id":"dada6c12-7c41-4ab8-9922-908233829f58","savedPayload":{"position":{"x":17805.64382962515,"y":31015.23747069523},"targetPosition":{"x":17855.64382962515,"y":30961.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":1,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"id":"8778eee5-97a2-4f9d-bd25-cd5a64ec6663","savedPayload":{"position":{"x":19673.084112691777,"y":31477.003560561447},"targetPosition":{"x":18473.301618063546,"y":31499.850126685462},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":true,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}},{"type":"Crypto Exchange","name":"Bitfinex","config":"{ \n\"codeName\": \"bitfinex2\"\n}","project":"Superalgos","exchangeAssets":{"type":"Exchange Assets","name":"New Exchange Assets","config":"{ \n\"addMissingAssetsFilter\": { \"quotedAsset\": \"USDT\"} \n}","project":"Superalgos","assets":[],"id":"8fc7f955-5c81-446c-bbeb-205988bf1fc0","savedPayload":{"position":{"x":17830.64382962515,"y":31051.23747069523},"targetPosition":{"x":17863.64382962515,"y":31062.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":2,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"exchangeMarkets":{"type":"Exchange Markets","name":"New Exchange Markets","project":"Superalgos","markets":[],"id":"d5ba38e9-3282-4634-b922-16532c71f426","savedPayload":{"position":{"x":17819.64382962515,"y":31118.23747069523},"targetPosition":{"x":17863.64382962515,"y":31062.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"exchangeAccounts":{"type":"Exchange Accounts","name":"New Exchange Accounts","project":"Superalgos","userAccounts":[{"type":"User Account","name":"New User Account","project":"Superalgos","userAssets":{"type":"User Assets","name":"New User Assets","project":"Superalgos","assets":[],"id":"1cebbed5-28f7-4ccd-afce-9e7634d90fb6","savedPayload":{"position":{"x":17892.64382962515,"y":30997.23747069523},"targetPosition":{"x":17855.64382962515,"y":30970.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"userKeys":{"type":"User Keys","name":"New User Keys","project":"Superalgos","keys":[{"type":"Exchange Account Key","name":"New Exchange Account Key","config":"{ \n\"codeName\": \"Paste your exchange API name or label\",\n\"secret\": \"Paste your exchange API secret key\"\n}","project":"Superalgos","id":"0d109aa9-c80c-4a64-96f0-1d8fda0a70a4","savedPayload":{"position":{"x":17888.64382962515,"y":30805.23747069523},"targetPosition":{"x":17942.64382962515,"y":30905.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{}}}],"id":"5459ab1e-a1ce-4dae-ae72-61c1f7f37ce0","savedPayload":{"position":{"x":17942.64382962515,"y":30905.23747069523},"targetPosition":{"x":17855.64382962515,"y":30970.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"id":"a4615f7a-000d-4ff9-b5ac-109bc9a3a849","savedPayload":{"position":{"x":17855.64382962515,"y":30970.23747069523},"targetPosition":{"x":17919.64382962515,"y":31043.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}}],"id":"e10d303e-ea21-4625-bae1-c32ad7a44e8a","savedPayload":{"position":{"x":17919.64382962515,"y":31043.23747069523},"targetPosition":{"x":17863.64382962515,"y":31062.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":1,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"id":"f3114102-a73c-4086-9594-5888ef1ab4ec","savedPayload":{"position":{"x":19667.867925151248,"y":31613.91737865048},"targetPosition":{"x":18473.301618063546,"y":31499.850126685462},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":true,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}},{"type":"Crypto Exchange","name":"Bitforex","config":"{ \n\"codeName\": \"bitforex\"\n}","project":"Superalgos","exchangeAssets":{"type":"Exchange Assets","name":"New Exchange Assets","config":"{ \n\"addMissingAssetsFilter\": { \"quotedAsset\": \"USDT\"} \n}","project":"Superalgos","assets":[],"id":"698e5e38-ad73-4cb6-b7f6-2b69913faff9","savedPayload":{"position":{"x":17897.64382962515,"y":30956.23747069523},"targetPosition":{"x":17937.64382962515,"y":30945.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":2,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"exchangeMarkets":{"type":"Exchange Markets","name":"New Exchange Markets","project":"Superalgos","markets":[],"id":"f0142bd4-1b63-4d12-a4b7-e150d0da197f","savedPayload":{"position":{"x":18020.64382962515,"y":31021.23747069523},"targetPosition":{"x":17937.64382962515,"y":30945.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"exchangeAccounts":{"type":"Exchange Accounts","name":"New Exchange Accounts","project":"Superalgos","userAccounts":[{"type":"User Account","name":"New User Account","project":"Superalgos","userAssets":{"type":"User Assets","name":"New User Assets","project":"Superalgos","assets":[],"id":"7164fb28-405b-461a-a7d4-59d438ecf1ce","savedPayload":{"position":{"x":17821.64382962515,"y":30984.23747069523},"targetPosition":{"x":17901.64382962515,"y":30907.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"userKeys":{"type":"User Keys","name":"New User Keys","project":"Superalgos","keys":[{"type":"Exchange Account Key","name":"New Exchange Account Key","config":"{ \n\"codeName\": \"Paste your exchange API name or label\",\n\"secret\": \"Paste your exchange API secret key\"\n}","project":"Superalgos","id":"ce8a00c9-f090-4ec2-84ed-c6661f8bf7b0","savedPayload":{"position":{"x":17825.64382962515,"y":30965.23747069523},"targetPosition":{"x":17818.64382962515,"y":30913.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{}}}],"id":"579cd74b-98f6-4000-990b-25ae1456c94b","savedPayload":{"position":{"x":17818.64382962515,"y":30913.23747069523},"targetPosition":{"x":17901.64382962515,"y":30907.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"id":"dbac6eef-25d2-4cda-86a6-59ce8a9a26bc","savedPayload":{"position":{"x":17901.64382962515,"y":30907.23747069523},"targetPosition":{"x":17909.64382962515,"y":30970.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}}],"id":"a1da9dd3-22ec-4536-bb5a-4d0bb8a56b81","savedPayload":{"position":{"x":17909.64382962515,"y":30970.23747069523},"targetPosition":{"x":17937.64382962515,"y":30945.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":1,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"id":"499a5a3b-7871-4c95-9b2e-d58d4d9e2392","savedPayload":{"position":{"x":19647.078738944114,"y":31749.344155666775},"targetPosition":{"x":18473.301618063546,"y":31499.850126685462},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":true,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}},{"type":"Crypto Exchange","name":"bitkk","config":"{ \n\"codeName\": \"bitkk\"\n}","project":"Superalgos","exchangeAssets":{"type":"Exchange Assets","name":"New Exchange Assets","config":"{ \n\"addMissingAssetsFilter\": { \"quotedAsset\": \"USDT\"} \n}","project":"Superalgos","assets":[],"id":"efbb916c-780b-447f-a4c2-df68570d4ee1","savedPayload":{"position":{"x":17931.64382962515,"y":30937.23747069523},"targetPosition":{"x":17951.64382962515,"y":30936.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":2,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"exchangeMarkets":{"type":"Exchange Markets","name":"New Exchange Markets","project":"Superalgos","markets":[],"id":"0d829516-81d9-46a5-9861-7d94cc89455d","savedPayload":{"position":{"x":17951.64382962515,"y":30912.23747069523},"targetPosition":{"x":17951.64382962515,"y":30936.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"exchangeAccounts":{"type":"Exchange Accounts","name":"New Exchange Accounts","project":"Superalgos","userAccounts":[{"type":"User Account","name":"New User Account","project":"Superalgos","userAssets":{"type":"User Assets","name":"New User Assets","project":"Superalgos","assets":[],"id":"fc174aa3-c485-4b9b-ba19-444b0189ccb1","savedPayload":{"position":{"x":17788.64382962515,"y":30980.23747069523},"targetPosition":{"x":17834.64382962515,"y":30983.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"userKeys":{"type":"User Keys","name":"New User Keys","project":"Superalgos","keys":[{"type":"Exchange Account Key","name":"New Exchange Account Key","config":"{ \n\"codeName\": \"Paste your exchange API name or label\",\n\"secret\": \"Paste your exchange API secret key\"\n}","project":"Superalgos","id":"15921d8a-4b45-481c-9165-79969ed3fd27","savedPayload":{"position":{"x":17796.64382962515,"y":30936.23747069523},"targetPosition":{"x":17891.64382962515,"y":30922.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{}}}],"id":"927d5c8a-85df-48bb-b097-c36abb76ca0e","savedPayload":{"position":{"x":17891.64382962515,"y":30922.23747069523},"targetPosition":{"x":17834.64382962515,"y":30983.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"id":"43d218c2-e633-47d5-8dd8-60bc7f7c0b9e","savedPayload":{"position":{"x":17834.64382962515,"y":30983.23747069523},"targetPosition":{"x":17853.64382962515,"y":30925.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}}],"id":"2d310d61-cbc7-4306-af02-be3888939545","savedPayload":{"position":{"x":17853.64382962515,"y":30925.23747069523},"targetPosition":{"x":17951.64382962515,"y":30936.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":1,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"id":"ded39740-3c93-4fda-bb9c-6ac75d2109f4","savedPayload":{"position":{"x":19610.987572905546,"y":31881.51839646335},"targetPosition":{"x":18473.301618063546,"y":31499.850126685462},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":true,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}},{"type":"Crypto Exchange","name":"BitMart","config":"{ \n\"codeName\": \"bitmart\"\n}","project":"Superalgos","exchangeAssets":{"type":"Exchange Assets","name":"New Exchange Assets","config":"{ \n\"addMissingAssetsFilter\": { \"quotedAsset\": \"USDT\"} \n}","project":"Superalgos","assets":[],"id":"10374855-6b4a-460b-9c95-70072ac00315","savedPayload":{"position":{"x":17907.64382962515,"y":30901.23747069523},"targetPosition":{"x":17834.64382962515,"y":30915.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":2,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"exchangeMarkets":{"type":"Exchange Markets","name":"New Exchange Markets","project":"Superalgos","markets":[],"id":"3aded60c-4061-48ff-ad33-212c965b5c43","savedPayload":{"position":{"x":17829.64382962515,"y":30925.23747069523},"targetPosition":{"x":17834.64382962515,"y":30915.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"exchangeAccounts":{"type":"Exchange Accounts","name":"New Exchange Accounts","project":"Superalgos","userAccounts":[{"type":"User Account","name":"New User Account","project":"Superalgos","userAssets":{"type":"User Assets","name":"New User Assets","project":"Superalgos","assets":[],"id":"1789a3ca-d948-497d-8d1b-1eefd25d16a3","savedPayload":{"position":{"x":17886.64382962515,"y":30937.23747069523},"targetPosition":{"x":17895.64382962515,"y":30988.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"userKeys":{"type":"User Keys","name":"New User Keys","project":"Superalgos","keys":[{"type":"Exchange Account Key","name":"New Exchange Account Key","config":"{ \n\"codeName\": \"Paste your exchange API name or label\",\n\"secret\": \"Paste your exchange API secret key\"\n}","project":"Superalgos","id":"038170bc-0ca7-4a92-8219-61b7bc8431b0","savedPayload":{"position":{"x":17893.64382962515,"y":31034.23747069523},"targetPosition":{"x":17835.64382962515,"y":30962.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{}}}],"id":"55f79ede-ef02-405f-92bd-11902ab3cc7a","savedPayload":{"position":{"x":17835.64382962515,"y":30962.23747069523},"targetPosition":{"x":17895.64382962515,"y":30988.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"id":"8185c660-4af3-4a62-bfa9-8922861101b5","savedPayload":{"position":{"x":17895.64382962515,"y":30988.23747069523},"targetPosition":{"x":17819.64382962515,"y":30909.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}}],"id":"546d48c3-df31-495c-b3b4-cb35109c5542","savedPayload":{"position":{"x":17819.64382962515,"y":30909.23747069523},"targetPosition":{"x":17834.64382962515,"y":30915.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":1,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"id":"c7ed52a7-895b-46f1-a745-35954d8bcfc6","savedPayload":{"position":{"x":19560.06493057918,"y":32008.717007676983},"targetPosition":{"x":18473.301618063546,"y":31499.850126685462},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":true,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}},{"type":"Crypto Exchange","name":"BitMax","config":"{ \n\"codeName\": \"bitmax\"\n}","project":"Superalgos","exchangeAssets":{"type":"Exchange Assets","name":"New Exchange Assets","config":"{ \n\"addMissingAssetsFilter\": { \"quotedAsset\": \"USDT\"} \n}","project":"Superalgos","assets":[],"id":"8a042d0d-7a7a-4a76-889e-42d8642404f4","savedPayload":{"position":{"x":17944.64382962515,"y":31046.23747069523},"targetPosition":{"x":17944.64382962515,"y":31109.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":2,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"exchangeMarkets":{"type":"Exchange Markets","name":"New Exchange Markets","project":"Superalgos","markets":[],"id":"0c4fcc48-51e6-4ff2-925f-405cda6d1122","savedPayload":{"position":{"x":17898.64382962515,"y":31024.23747069523},"targetPosition":{"x":17944.64382962515,"y":31109.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"exchangeAccounts":{"type":"Exchange Accounts","name":"New Exchange Accounts","project":"Superalgos","userAccounts":[{"type":"User Account","name":"New User Account","project":"Superalgos","userAssets":{"type":"User Assets","name":"New User Assets","project":"Superalgos","assets":[],"id":"ef9d5381-d9e3-47f5-9069-6fc14eda0fa3","savedPayload":{"position":{"x":17879.64382962515,"y":31096.23747069523},"targetPosition":{"x":17977.64382962515,"y":31041.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"userKeys":{"type":"User Keys","name":"New User Keys","project":"Superalgos","keys":[{"type":"Exchange Account Key","name":"New Exchange Account Key","config":"{ \n\"codeName\": \"Paste your exchange API name or label\",\n\"secret\": \"Paste your exchange API secret key\"\n}","project":"Superalgos","id":"c66fe606-9705-45b0-a196-7ea3efb0221e","savedPayload":{"position":{"x":17982.64382962515,"y":31053.23747069523},"targetPosition":{"x":17943.64382962515,"y":31083.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{}}}],"id":"80a5f68e-776a-44de-8797-d2eb806c306e","savedPayload":{"position":{"x":17943.64382962515,"y":31083.23747069523},"targetPosition":{"x":17977.64382962515,"y":31041.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"id":"011fcf1c-1c94-4c36-a246-d6c400aa39dc","savedPayload":{"position":{"x":17977.64382962515,"y":31041.23747069523},"targetPosition":{"x":17942.64382962515,"y":31103.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}}],"id":"4a87b8c5-e009-427f-afb7-21afe5594b59","savedPayload":{"position":{"x":17942.64382962515,"y":31103.23747069523},"targetPosition":{"x":17944.64382962515,"y":31109.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":1,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"id":"fc6a9048-ab8c-48f9-91ae-6c95c28714b0","savedPayload":{"position":{"x":19494.974666483893,"y":32129.281760885297},"targetPosition":{"x":18473.301618063546,"y":31499.850126685462},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":true,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}},{"type":"Crypto Exchange","name":"BitMEX","config":"{ \n\"codeName\": \"bitmex\"\n}","project":"Superalgos","exchangeAssets":{"type":"Exchange Assets","name":"New Exchange Assets","config":"{ \n\"addMissingAssetsFilter\": { \"quotedAsset\": \"USDT\"} \n}","project":"Superalgos","assets":[],"id":"f7636e2b-354a-4217-894b-5e26eddc0c2a","savedPayload":{"position":{"x":17894.64382962515,"y":30934.23747069523},"targetPosition":{"x":17910.64382962515,"y":30922.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":2,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"exchangeMarkets":{"type":"Exchange Markets","name":"New Exchange Markets","project":"Superalgos","markets":[],"id":"6eb2ddd1-6d06-456c-b4e0-7df56ba182e6","savedPayload":{"position":{"x":17823.64382962515,"y":30834.23747069523},"targetPosition":{"x":17910.64382962515,"y":30922.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"exchangeAccounts":{"type":"Exchange Accounts","name":"New Exchange Accounts","project":"Superalgos","userAccounts":[{"type":"User Account","name":"New User Account","project":"Superalgos","userAssets":{"type":"User Assets","name":"New User Assets","project":"Superalgos","assets":[],"id":"b4a4b8fe-d923-4eb0-a066-171b83d1540d","savedPayload":{"position":{"x":17902.64382962515,"y":31064.23747069523},"targetPosition":{"x":17815.64382962515,"y":30988.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"userKeys":{"type":"User Keys","name":"New User Keys","project":"Superalgos","keys":[{"type":"Exchange Account Key","name":"New Exchange Account Key","config":"{ \n\"codeName\": \"Paste your exchange API name or label\",\n\"secret\": \"Paste your exchange API secret key\"\n}","project":"Superalgos","id":"918ed585-ce46-4d51-a07a-9beee51f70eb","savedPayload":{"position":{"x":17711.64382962515,"y":31036.23747069523},"targetPosition":{"x":17805.64382962515,"y":31078.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{}}}],"id":"9efef4d8-5be3-4d17-a645-6edffd9535cf","savedPayload":{"position":{"x":17805.64382962515,"y":31078.23747069523},"targetPosition":{"x":17815.64382962515,"y":30988.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"id":"6ad31a6e-f27b-45c3-9996-a41fb39aa154","savedPayload":{"position":{"x":17815.64382962515,"y":30988.23747069523},"targetPosition":{"x":17844.64382962515,"y":30896.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}}],"id":"82887393-cb1c-4b01-8581-4b3dabc86584","savedPayload":{"position":{"x":17844.64382962515,"y":30896.23747069523},"targetPosition":{"x":17910.64382962515,"y":30922.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":1,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"id":"1e2f1dd0-ebf1-4485-83d8-7723a9e3e714","savedPayload":{"position":{"x":19416.56533175489,"y":32241.64091015019},"targetPosition":{"x":18473.301618063546,"y":31499.850126685462},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":true,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}},{"type":"Crypto Exchange","name":"Bittrex","config":"{ \n\"codeName\": \"bittrex\"\n}","project":"Superalgos","exchangeAssets":{"type":"Exchange Assets","name":"New Exchange Assets","config":"{ \n\"addMissingAssetsFilter\": { \"quotedAsset\": \"USDT\"} \n}","project":"Superalgos","assets":[],"id":"88d4ef94-f030-42df-9115-69d9611317b1","savedPayload":{"position":{"x":17839.64382962515,"y":31009.23747069523},"targetPosition":{"x":17893.64382962515,"y":30968.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":2,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"exchangeMarkets":{"type":"Exchange Markets","name":"New Exchange Markets","project":"Superalgos","markets":[],"id":"7fe8234d-9a39-4b28-bf98-43b4fdb57ee5","savedPayload":{"position":{"x":17878.64382962515,"y":31045.23747069523},"targetPosition":{"x":17893.64382962515,"y":30968.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"exchangeAccounts":{"type":"Exchange Accounts","name":"New Exchange Accounts","project":"Superalgos","userAccounts":[{"type":"User Account","name":"New User Account","project":"Superalgos","userAssets":{"type":"User Assets","name":"New User Assets","project":"Superalgos","assets":[],"id":"5ba7fe13-1e0f-403a-8f4b-8e3968d2e5e2","savedPayload":{"position":{"x":17841.64382962515,"y":30890.23747069523},"targetPosition":{"x":17742.64382962515,"y":30961.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"userKeys":{"type":"User Keys","name":"New User Keys","project":"Superalgos","keys":[{"type":"Exchange Account Key","name":"New Exchange Account Key","config":"{ \n\"codeName\": \"Paste your exchange API name or label\",\n\"secret\": \"Paste your exchange API secret key\"\n}","project":"Superalgos","id":"e926fbb8-d2ac-4e3d-aa59-a0a828d202fd","savedPayload":{"position":{"x":17707.64382962515,"y":30983.23747069523},"targetPosition":{"x":17782.64382962515,"y":31052.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{}}}],"id":"4fbe41e1-cb15-4bc2-a3de-681c5b22cc97","savedPayload":{"position":{"x":17782.64382962515,"y":31052.23747069523},"targetPosition":{"x":17742.64382962515,"y":30961.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"id":"ab9fe180-1c07-44de-a0a1-863761ac52d6","savedPayload":{"position":{"x":17742.64382962515,"y":30961.23747069523},"targetPosition":{"x":17796.64382962515,"y":30903.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}}],"id":"584f29ca-9b3c-4b7f-a2b0-aab4180ecefd","savedPayload":{"position":{"x":17796.64382962515,"y":30903.23747069523},"targetPosition":{"x":17893.64382962515,"y":30968.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":1,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"id":"f598f002-8fc5-491f-888e-07d017ea83c6","savedPayload":{"position":{"x":19325.859111981987,"y":32344.329682129825},"targetPosition":{"x":18473.301618063546,"y":31499.850126685462},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":true,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}},{"type":"Crypto Exchange","name":"Bit-Z","config":"{ \n\"codeName\": \"bitz\"\n}","project":"Superalgos","exchangeAssets":{"type":"Exchange Assets","name":"New Exchange Assets","config":"{ \n\"addMissingAssetsFilter\": { \"quotedAsset\": \"USDT\"} \n}","project":"Superalgos","assets":[],"id":"0a22e02b-7d2e-4955-9cfc-ed7d95f0c9a0","savedPayload":{"position":{"x":17751.64382962515,"y":31083.23747069523},"targetPosition":{"x":17850.64382962515,"y":31073.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":2,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"exchangeMarkets":{"type":"Exchange Markets","name":"New Exchange Markets","project":"Superalgos","markets":[],"id":"298b45af-b73d-4cd5-848a-97de7b857569","savedPayload":{"position":{"x":17944.64382962515,"y":31083.23747069523},"targetPosition":{"x":17850.64382962515,"y":31073.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"exchangeAccounts":{"type":"Exchange Accounts","name":"New Exchange Accounts","project":"Superalgos","userAccounts":[{"type":"User Account","name":"New User Account","project":"Superalgos","userAssets":{"type":"User Assets","name":"New User Assets","project":"Superalgos","assets":[],"id":"6ede807b-b1ab-42b5-bfd7-3b12a942447e","savedPayload":{"position":{"x":17871.64382962515,"y":31049.23747069523},"targetPosition":{"x":17772.64382962515,"y":31098.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"userKeys":{"type":"User Keys","name":"New User Keys","project":"Superalgos","keys":[{"type":"Exchange Account Key","name":"New Exchange Account Key","config":"{ \n\"codeName\": \"Paste your exchange API name or label\",\n\"secret\": \"Paste your exchange API secret key\"\n}","project":"Superalgos","id":"dc172858-3241-4487-950a-e5cae03ac376","savedPayload":{"position":{"x":17751.64382962515,"y":31081.23747069523},"targetPosition":{"x":17753.64382962515,"y":31028.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{}}}],"id":"19c07cee-1fdf-4e02-ac9f-d110b64ee033","savedPayload":{"position":{"x":17753.64382962515,"y":31028.23747069523},"targetPosition":{"x":17772.64382962515,"y":31098.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"id":"b4ef5048-ac4c-410e-bd6d-3338e33ab108","savedPayload":{"position":{"x":17772.64382962515,"y":31098.23747069523},"targetPosition":{"x":17788.64382962515,"y":31134.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}}],"id":"e7e96c41-c839-4eec-9bcf-1c60d60fa3f5","savedPayload":{"position":{"x":17788.64382962515,"y":31134.23747069523},"targetPosition":{"x":17850.64382962515,"y":31073.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":1,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"id":"6cc10926-fe41-43be-887b-fa8aba1c7377","savedPayload":{"position":{"x":19224.038501457213,"y":32436.009371639208},"targetPosition":{"x":18473.301618063546,"y":31499.850126685462},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":true,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}},{"type":"Crypto Exchange","name":"BTC-Alpha","config":"{ \n\"codeName\": \"btcalpha\"\n}","project":"Superalgos","exchangeAssets":{"type":"Exchange Assets","name":"New Exchange Assets","config":"{ \n\"addMissingAssetsFilter\": { \"quotedAsset\": \"USDT\"} \n}","project":"Superalgos","assets":[],"id":"263e3b9c-8fdd-4376-b53b-87f32d0f5898","savedPayload":{"position":{"x":17904.64382962515,"y":30922.23747069523},"targetPosition":{"x":17883.64382962515,"y":30971.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":2,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"exchangeMarkets":{"type":"Exchange Markets","name":"New Exchange Markets","project":"Superalgos","markets":[],"id":"804603e1-3e0f-4219-a9b7-ee27810d4f07","savedPayload":{"position":{"x":17829.64382962515,"y":30977.23747069523},"targetPosition":{"x":17883.64382962515,"y":30971.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"exchangeAccounts":{"type":"Exchange Accounts","name":"New Exchange Accounts","project":"Superalgos","userAccounts":[{"type":"User Account","name":"New User Account","project":"Superalgos","userAssets":{"type":"User Assets","name":"New User Assets","project":"Superalgos","assets":[],"id":"83b25fff-e448-483f-9bee-cb85fa592c6e","savedPayload":{"position":{"x":17734.64382962515,"y":30862.23747069523},"targetPosition":{"x":17829.64382962515,"y":30960.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"userKeys":{"type":"User Keys","name":"New User Keys","project":"Superalgos","keys":[{"type":"Exchange Account Key","name":"New Exchange Account Key","config":"{ \n\"codeName\": \"Paste your exchange API name or label\",\n\"secret\": \"Paste your exchange API secret key\"\n}","project":"Superalgos","id":"efcfa3ca-0f82-4eb7-9b04-ed5eb4e1c3cf","savedPayload":{"position":{"x":17799.64382962515,"y":30864.23747069523},"targetPosition":{"x":17837.64382962515,"y":30919.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{}}}],"id":"9ca8d728-ee11-4905-9a3a-5ca4ed50f3df","savedPayload":{"position":{"x":17837.64382962515,"y":30919.23747069523},"targetPosition":{"x":17829.64382962515,"y":30960.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"id":"2cfde277-afa6-4ad3-bb5b-8a32b89e2037","savedPayload":{"position":{"x":17829.64382962515,"y":30960.23747069523},"targetPosition":{"x":17903.64382962515,"y":30969.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}}],"id":"297a0ea2-f6d7-47fd-9fb7-0d99d00a87d8","savedPayload":{"position":{"x":17903.64382962515,"y":30969.23747069523},"targetPosition":{"x":17883.64382962515,"y":30971.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":1,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"id":"30e5485f-213b-435b-a670-07b76cfe5cae","savedPayload":{"position":{"x":19112.430887553306,"y":32515.48479371957},"targetPosition":{"x":18473.301618063546,"y":31499.850126685462},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":true,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}},{"type":"Crypto Exchange","name":"BTC Markets","config":"{ \n\"codeName\": \"btcmarkets\"\n}","project":"Superalgos","exchangeAssets":{"type":"Exchange Assets","name":"New Exchange Assets","config":"{ \n\"addMissingAssetsFilter\": { \"quotedAsset\": \"USDT\"} \n}","project":"Superalgos","assets":[],"id":"fcb3b880-0852-4d93-8714-67373f9dca16","savedPayload":{"position":{"x":17911.64382962515,"y":31036.23747069523},"targetPosition":{"x":17994.64382962515,"y":31033.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":2,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"exchangeMarkets":{"type":"Exchange Markets","name":"New Exchange Markets","project":"Superalgos","markets":[],"id":"953d8eff-0b2e-4b07-8635-393fddae0c9d","savedPayload":{"position":{"x":18025.64382962515,"y":31127.23747069523},"targetPosition":{"x":17994.64382962515,"y":31033.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"exchangeAccounts":{"type":"Exchange Accounts","name":"New Exchange Accounts","project":"Superalgos","userAccounts":[{"type":"User Account","name":"New User Account","project":"Superalgos","userAssets":{"type":"User Assets","name":"New User Assets","project":"Superalgos","assets":[],"id":"c08873f6-9120-4764-8b06-c8110468b423","savedPayload":{"position":{"x":17935.64382962515,"y":30927.23747069523},"targetPosition":{"x":18027.64382962515,"y":31003.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"userKeys":{"type":"User Keys","name":"New User Keys","project":"Superalgos","keys":[{"type":"Exchange Account Key","name":"New Exchange Account Key","config":"{ \n\"codeName\": \"Paste your exchange API name or label\",\n\"secret\": \"Paste your exchange API secret key\"\n}","project":"Superalgos","id":"beaa2557-4976-4e53-8a24-7ea00fc3afd5","savedPayload":{"position":{"x":18054.64382962515,"y":30851.23747069523},"targetPosition":{"x":18125.64382962515,"y":30951.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{}}}],"id":"445158a2-91b4-4ad8-8380-036cbba6ad7e","savedPayload":{"position":{"x":18125.64382962515,"y":30951.23747069523},"targetPosition":{"x":18027.64382962515,"y":31003.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"id":"cd00e08c-a26d-4b11-93a3-b0e8f35bec4b","savedPayload":{"position":{"x":18027.64382962515,"y":31003.23747069523},"targetPosition":{"x":18016.64382962515,"y":31075.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}}],"id":"35cb55c1-ceb3-4093-98af-8a1c2411fe0f","savedPayload":{"position":{"x":18016.64382962515,"y":31075.23747069523},"targetPosition":{"x":17994.64382962515,"y":31033.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":1,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"id":"ac2fda42-95ca-404a-8dd2-72bff0ff5a0f","savedPayload":{"position":{"x":18992.491246199355,"y":32581.719864702103},"targetPosition":{"x":18473.301618063546,"y":31499.850126685462},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":true,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}},{"type":"Crypto Exchange","name":"Buda","config":"{ \n\"codeName\": \"buda\"\n}","project":"Superalgos","exchangeAssets":{"type":"Exchange Assets","name":"New Exchange Assets","config":"{ \n\"addMissingAssetsFilter\": { \"quotedAsset\": \"USDT\"} \n}","project":"Superalgos","assets":[],"id":"27f3573d-e1f0-473f-9bfd-f9198e7240a0","savedPayload":{"position":{"x":17945.64382962515,"y":30937.23747069523},"targetPosition":{"x":17853.64382962515,"y":31005.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":2,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"exchangeMarkets":{"type":"Exchange Markets","name":"New Exchange Markets","project":"Superalgos","markets":[],"id":"4ddc0981-4e45-42f3-ae11-f5b136b2bc3d","savedPayload":{"position":{"x":17783.64382962515,"y":31008.23747069523},"targetPosition":{"x":17853.64382962515,"y":31005.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"exchangeAccounts":{"type":"Exchange Accounts","name":"New Exchange Accounts","project":"Superalgos","userAccounts":[{"type":"User Account","name":"New User Account","project":"Superalgos","userAssets":{"type":"User Assets","name":"New User Assets","project":"Superalgos","assets":[],"id":"5a325d59-e6a6-4f76-a311-5e67c5f5a8a2","savedPayload":{"position":{"x":17980.64382962515,"y":30843.23747069523},"targetPosition":{"x":17956.64382962515,"y":30936.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"userKeys":{"type":"User Keys","name":"New User Keys","project":"Superalgos","keys":[{"type":"Exchange Account Key","name":"New Exchange Account Key","config":"{ \n\"codeName\": \"Paste your exchange API name or label\",\n\"secret\": \"Paste your exchange API secret key\"\n}","project":"Superalgos","id":"fb985ab9-7759-4780-a052-8ee9be0b712a","savedPayload":{"position":{"x":17907.64382962515,"y":30968.23747069523},"targetPosition":{"x":17958.64382962515,"y":30884.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{}}}],"id":"fdf7665a-2974-467b-9280-4077a888733f","savedPayload":{"position":{"x":17958.64382962515,"y":30884.23747069523},"targetPosition":{"x":17956.64382962515,"y":30936.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"id":"a3105cfc-f80e-4bcb-b399-6ea9c0f7edf0","savedPayload":{"position":{"x":17956.64382962515,"y":30936.23747069523},"targetPosition":{"x":17872.64382962515,"y":30941.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}}],"id":"5d69a76f-e7bc-4538-950e-2e2353eccea3","savedPayload":{"position":{"x":17872.64382962515,"y":30941.23747069523},"targetPosition":{"x":17853.64382962515,"y":31005.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":1,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"id":"90fe3d74-662e-4fac-aff3-f41990b61ccf","savedPayload":{"position":{"x":18865.783174044453,"y":32633.851109143063},"targetPosition":{"x":18473.301618063546,"y":31499.850126685462},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":true,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}},{"type":"Crypto Exchange","name":"BW","config":"{ \n\"codeName\": \"bw\"\n}","project":"Superalgos","exchangeAssets":{"type":"Exchange Assets","name":"New Exchange Assets","config":"{ \n\"addMissingAssetsFilter\": { \"quotedAsset\": \"USDT\"} \n}","project":"Superalgos","assets":[],"id":"457616cd-25f9-4ad3-8c18-6331859dd42e","savedPayload":{"position":{"x":17890.64382962515,"y":31014.23747069523},"targetPosition":{"x":17900.64382962515,"y":30965.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":2,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"exchangeMarkets":{"type":"Exchange Markets","name":"New Exchange Markets","project":"Superalgos","markets":[],"id":"8c1f9aa2-4253-4129-a533-e515644ddb38","savedPayload":{"position":{"x":17909.64382962515,"y":30970.23747069523},"targetPosition":{"x":17900.64382962515,"y":30965.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"exchangeAccounts":{"type":"Exchange Accounts","name":"New Exchange Accounts","project":"Superalgos","userAccounts":[{"type":"User Account","name":"New User Account","project":"Superalgos","userAssets":{"type":"User Assets","name":"New User Assets","project":"Superalgos","assets":[],"id":"24314a5b-85ca-4036-adc6-618120496f1d","savedPayload":{"position":{"x":17773.64382962515,"y":30945.23747069523},"targetPosition":{"x":17860.64382962515,"y":30865.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"userKeys":{"type":"User Keys","name":"New User Keys","project":"Superalgos","keys":[{"type":"Exchange Account Key","name":"New Exchange Account Key","config":"{ \n\"codeName\": \"Paste your exchange API name or label\",\n\"secret\": \"Paste your exchange API secret key\"\n}","project":"Superalgos","id":"f7c593f6-bd7a-41f7-a5e7-b2e1ea9a528f","savedPayload":{"position":{"x":17820.64382962515,"y":30885.23747069523},"targetPosition":{"x":17828.64382962515,"y":30802.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{}}}],"id":"60dfc799-f863-4895-8d17-568aa2303ef5","savedPayload":{"position":{"x":17828.64382962515,"y":30802.23747069523},"targetPosition":{"x":17860.64382962515,"y":30865.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"id":"223e466d-d750-4e38-91ce-8a59c15242ba","savedPayload":{"position":{"x":17860.64382962515,"y":30865.23747069523},"targetPosition":{"x":17818.64382962515,"y":30919.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}}],"id":"cfff1310-5220-4978-9553-8514be141d14","savedPayload":{"position":{"x":17818.64382962515,"y":30919.23747069523},"targetPosition":{"x":17900.64382962515,"y":30965.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":1,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"id":"d72db90c-d572-4cbb-8348-e3cc485d8e86","savedPayload":{"position":{"x":18733.958504584156,"y":32671.1989165467},"targetPosition":{"x":18473.301618063546,"y":31499.850126685462},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":true,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}},{"type":"Crypto Exchange","name":"Bybit","config":"{ \n\"codeName\": \"bybit\"\n}","project":"Superalgos","exchangeAssets":{"type":"Exchange Assets","name":"New Exchange Assets","config":"{ \n\"addMissingAssetsFilter\": { \"quotedAsset\": \"USDT\"} \n}","project":"Superalgos","assets":[],"id":"18fdf7c8-03c4-4f81-a88e-de97589765e1","savedPayload":{"position":{"x":17803.64382962515,"y":31059.23747069523},"targetPosition":{"x":17855.64382962515,"y":31007.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":2,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"exchangeMarkets":{"type":"Exchange Markets","name":"New Exchange Markets","project":"Superalgos","markets":[],"id":"a62b2603-ac6f-4b6e-9541-86daf32027b1","savedPayload":{"position":{"x":17847.64382962515,"y":31104.23747069523},"targetPosition":{"x":17855.64382962515,"y":31007.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"exchangeAccounts":{"type":"Exchange Accounts","name":"New Exchange Accounts","project":"Superalgos","userAccounts":[{"type":"User Account","name":"New User Account","project":"Superalgos","userAssets":{"type":"User Assets","name":"New User Assets","project":"Superalgos","assets":[],"id":"66ecff99-7102-4f4a-9ce8-4d55fb22dfbc","savedPayload":{"position":{"x":17851.64382962515,"y":31165.23747069523},"targetPosition":{"x":17916.64382962515,"y":31077.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"userKeys":{"type":"User Keys","name":"New User Keys","project":"Superalgos","keys":[{"type":"Exchange Account Key","name":"New Exchange Account Key","config":"{ \n\"codeName\": \"Paste your exchange API name or label\",\n\"secret\": \"Paste your exchange API secret key\"\n}","project":"Superalgos","id":"625e127c-0ebb-4f57-af9f-9dfb57b262a1","savedPayload":{"position":{"x":18004.64382962515,"y":31091.23747069523},"targetPosition":{"x":18008.64382962515,"y":31027.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{}}}],"id":"8174bb53-66b8-4575-b206-74f9b6352a80","savedPayload":{"position":{"x":18008.64382962515,"y":31027.23747069523},"targetPosition":{"x":17916.64382962515,"y":31077.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"id":"ee16357e-abde-4800-b089-f43f4b696a35","savedPayload":{"position":{"x":17916.64382962515,"y":31077.23747069523},"targetPosition":{"x":17944.64382962515,"y":31101.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}}],"id":"c9e9473b-aff9-43c8-a6be-5cd30330bee2","savedPayload":{"position":{"x":17944.64382962515,"y":31101.23747069523},"targetPosition":{"x":17855.64382962515,"y":31007.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":1,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"id":"516c3831-456b-4d17-b0a0-6a363ba2ddb2","savedPayload":{"position":{"x":18598.73577398473,"y":32693.27640112739},"targetPosition":{"x":18473.301618063546,"y":31499.850126685462},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":true,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}},{"type":"Crypto Exchange","name":"ByteTrade","config":"{ \n\"codeName\": \"bytetrade\"\n}","project":"Superalgos","exchangeAssets":{"type":"Exchange Assets","name":"New Exchange Assets","config":"{ \n\"addMissingAssetsFilter\": { \"quotedAsset\": \"USDT\"} \n}","project":"Superalgos","assets":[],"id":"e7a1e531-5a9e-466e-b98d-672de39eed3a","savedPayload":{"position":{"x":18088.64382962515,"y":31024.23747069523},"targetPosition":{"x":17991.64382962515,"y":30981.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":2,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"exchangeMarkets":{"type":"Exchange Markets","name":"New Exchange Markets","project":"Superalgos","markets":[],"id":"edafaba7-fd82-4d9f-b3f7-5d1c01c56599","savedPayload":{"position":{"x":17941.64382962515,"y":30943.23747069523},"targetPosition":{"x":17991.64382962515,"y":30981.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"exchangeAccounts":{"type":"Exchange Accounts","name":"New Exchange Accounts","project":"Superalgos","userAccounts":[{"type":"User Account","name":"New User Account","project":"Superalgos","userAssets":{"type":"User Assets","name":"New User Assets","project":"Superalgos","assets":[],"id":"50fa78b8-3aea-4e43-adcf-1e31820bf97f","savedPayload":{"position":{"x":17886.64382962515,"y":31008.23747069523},"targetPosition":{"x":17858.64382962515,"y":30967.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"userKeys":{"type":"User Keys","name":"New User Keys","project":"Superalgos","keys":[{"type":"Exchange Account Key","name":"New Exchange Account Key","config":"{ \n\"codeName\": \"Paste your exchange API name or label\",\n\"secret\": \"Paste your exchange API secret key\"\n}","project":"Superalgos","id":"b9c39b04-e86e-4ebb-9aba-39c375f2960c","savedPayload":{"position":{"x":17865.64382962515,"y":30941.23747069523},"targetPosition":{"x":17953.64382962515,"y":31023.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{}}}],"id":"5965d9cc-1d68-47a7-b838-e6dd81da6ea9","savedPayload":{"position":{"x":17953.64382962515,"y":31023.23747069523},"targetPosition":{"x":17858.64382962515,"y":30967.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"id":"f51a08be-ee3f-4d3b-a75e-d783d63092a7","savedPayload":{"position":{"x":17858.64382962515,"y":30967.23747069523},"targetPosition":{"x":17898.64382962515,"y":30965.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}}],"id":"d395efd0-691b-4a68-a7f1-9bce95b2f687","savedPayload":{"position":{"x":17898.64382962515,"y":30965.23747069523},"targetPosition":{"x":17991.64382962515,"y":30981.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":1,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"id":"45e2306f-03e8-4d17-a73a-72c11dd14e78","savedPayload":{"position":{"x":18461.877817336055,"y":32699.795749110468},"targetPosition":{"x":18473.301618063546,"y":31499.850126685462},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":true,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}},{"type":"Crypto Exchange","name":"CEX.IO","config":"{ \n\"codeName\": \"cex\"\n}","project":"Superalgos","exchangeAssets":{"type":"Exchange Assets","name":"New Exchange Assets","config":"{ \n\"addMissingAssetsFilter\": { \"quotedAsset\": \"USDT\"} \n}","project":"Superalgos","assets":[],"id":"9de19f0a-5824-4e42-af00-484b64421dc3","savedPayload":{"position":{"x":17890.64382962515,"y":31049.23747069523},"targetPosition":{"x":17896.64382962515,"y":31076.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":2,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"exchangeMarkets":{"type":"Exchange Markets","name":"New Exchange Markets","project":"Superalgos","markets":[],"id":"39db01bc-0cea-422f-b9e9-7d84e3f5446d","savedPayload":{"position":{"x":17918.64382962515,"y":31105.23747069523},"targetPosition":{"x":17896.64382962515,"y":31076.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"exchangeAccounts":{"type":"Exchange Accounts","name":"New Exchange Accounts","project":"Superalgos","userAccounts":[{"type":"User Account","name":"New User Account","project":"Superalgos","userAssets":{"type":"User Assets","name":"New User Assets","project":"Superalgos","assets":[],"id":"93833d3c-42c9-4e4d-bf0f-5b80a90d10c2","savedPayload":{"position":{"x":17978.64382962515,"y":31126.23747069523},"targetPosition":{"x":17953.64382962515,"y":31167.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"userKeys":{"type":"User Keys","name":"New User Keys","project":"Superalgos","keys":[{"type":"Exchange Account Key","name":"New Exchange Account Key","config":"{ \n\"codeName\": \"Paste your exchange API name or label\",\n\"secret\": \"Paste your exchange API secret key\"\n}","project":"Superalgos","id":"42863a52-30f4-4322-9c20-99a45d6dc3d6","savedPayload":{"position":{"x":17884.64382962515,"y":31149.23747069523},"targetPosition":{"x":17895.64382962515,"y":31148.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{}}}],"id":"fcff471d-29be-4176-8ff8-12088361f9fc","savedPayload":{"position":{"x":17895.64382962515,"y":31148.23747069523},"targetPosition":{"x":17953.64382962515,"y":31167.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"id":"f7975a18-b3ab-49bc-ae45-eb02c99aff8c","savedPayload":{"position":{"x":17953.64382962515,"y":31167.23747069523},"targetPosition":{"x":17881.64382962515,"y":31096.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}}],"id":"ec432123-43fe-4171-8c41-b797d3161edb","savedPayload":{"position":{"x":17881.64382962515,"y":31096.23747069523},"targetPosition":{"x":17896.64382962515,"y":31076.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":1,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"id":"346bfc30-e32a-453a-bdc6-0ead48221581","savedPayload":{"position":{"x":18325.16878740031,"y":32690.67197082492},"targetPosition":{"x":18473.301618063546,"y":31499.850126685462},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":true,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}},{"type":"Crypto Exchange","name":"Coinbase Prime","config":"{ \n\"codeName\": \"coinbaseprime\"\n}","project":"Superalgos","exchangeAssets":{"type":"Exchange Assets","name":"New Exchange Assets","config":"{ \n\"addMissingAssetsFilter\": { \"quotedAsset\": \"USDT\"} \n}","project":"Superalgos","assets":[],"id":"73cabd8d-9308-49ed-b544-44f785ee7d38","savedPayload":{"position":{"x":17867.64382962515,"y":30962.23747069523},"targetPosition":{"x":17922.64382962515,"y":30960.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":2,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"exchangeMarkets":{"type":"Exchange Markets","name":"New Exchange Markets","project":"Superalgos","markets":[],"id":"31bd1360-f0c5-4d70-876a-b152f7cedfd7","savedPayload":{"position":{"x":17960.64382962515,"y":30864.23747069523},"targetPosition":{"x":17922.64382962515,"y":30960.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"exchangeAccounts":{"type":"Exchange Accounts","name":"New Exchange Accounts","project":"Superalgos","userAccounts":[{"type":"User Account","name":"New User Account","project":"Superalgos","userAssets":{"type":"User Assets","name":"New User Assets","project":"Superalgos","assets":[],"id":"9b75fcfa-fe75-48a8-9d28-2ff19c58c041","savedPayload":{"position":{"x":17792.64382962515,"y":30841.23747069523},"targetPosition":{"x":17809.64382962515,"y":30934.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"userKeys":{"type":"User Keys","name":"New User Keys","project":"Superalgos","keys":[{"type":"Exchange Account Key","name":"New Exchange Account Key","config":"{ \n\"codeName\": \"Paste your exchange API name or label\",\n\"secret\": \"Paste your exchange API secret key\"\n}","project":"Superalgos","id":"c900b14a-c728-45af-90f8-29b3e5f29f46","savedPayload":{"position":{"x":17801.64382962515,"y":30986.23747069523},"targetPosition":{"x":17793.64382962515,"y":31006.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{}}}],"id":"eaf72df3-b66f-4b83-83f9-91e22ec0c300","savedPayload":{"position":{"x":17793.64382962515,"y":31006.23747069523},"targetPosition":{"x":17809.64382962515,"y":30934.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"id":"9da95675-2071-41bf-b5ac-4f2af602994f","savedPayload":{"position":{"x":17809.64382962515,"y":30934.23747069523},"targetPosition":{"x":17862.64382962515,"y":31021.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}}],"id":"4fc49ad4-57cc-43b0-b14b-15f26af994aa","savedPayload":{"position":{"x":17862.64382962515,"y":31021.23747069523},"targetPosition":{"x":17922.64382962515,"y":30960.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":1,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"id":"5a8281db-6ace-4186-8cfb-cd249c4af48b","savedPayload":{"position":{"x":18190.390895452234,"y":32666.02400867371},"targetPosition":{"x":18473.301618063546,"y":31499.850126685462},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":true,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}},{"type":"Crypto Exchange","name":"CoinEx","config":"{ \n\"codeName\": \"coinex\"\n}","project":"Superalgos","exchangeAssets":{"type":"Exchange Assets","name":"New Exchange Assets","config":"{ \n\"addMissingAssetsFilter\": { \"quotedAsset\": \"USDT\"} \n}","project":"Superalgos","assets":[],"id":"af78f796-60e5-4794-87b8-772c7bc74be1","savedPayload":{"position":{"x":18043.64382962515,"y":31069.23747069523},"targetPosition":{"x":18000.64382962515,"y":31106.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":2,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"exchangeMarkets":{"type":"Exchange Markets","name":"New Exchange Markets","project":"Superalgos","markets":[],"id":"d351e6d9-36eb-4d0e-aca5-94429bbb23a3","savedPayload":{"position":{"x":18094.64382962515,"y":31090.23747069523},"targetPosition":{"x":18000.64382962515,"y":31106.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"exchangeAccounts":{"type":"Exchange Accounts","name":"New Exchange Accounts","project":"Superalgos","userAccounts":[{"type":"User Account","name":"New User Account","project":"Superalgos","userAssets":{"type":"User Assets","name":"New User Assets","project":"Superalgos","assets":[],"id":"438f74c6-15e0-4553-af2a-febd5290c269","savedPayload":{"position":{"x":17908.64382962515,"y":31088.23747069523},"targetPosition":{"x":17986.64382962515,"y":31075.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"userKeys":{"type":"User Keys","name":"New User Keys","project":"Superalgos","keys":[{"type":"Exchange Account Key","name":"New Exchange Account Key","config":"{ \n\"codeName\": \"Paste your exchange API name or label\",\n\"secret\": \"Paste your exchange API secret key\"\n}","project":"Superalgos","id":"bfb22430-77c7-41a7-8083-771f7d7f3634","savedPayload":{"position":{"x":17927.64382962515,"y":30953.23747069523},"targetPosition":{"x":17947.64382962515,"y":30990.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{}}}],"id":"51daaa12-1c60-4cef-96d8-a445b4b32296","savedPayload":{"position":{"x":17947.64382962515,"y":30990.23747069523},"targetPosition":{"x":17986.64382962515,"y":31075.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"id":"726b8c33-9873-4be1-b9ef-d6b4483f23b1","savedPayload":{"position":{"x":17986.64382962515,"y":31075.23747069523},"targetPosition":{"x":17919.64382962515,"y":31016.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}}],"id":"30469514-b983-4f6f-9d74-6d6ceef25eb6","savedPayload":{"position":{"x":17919.64382962515,"y":31016.23747069523},"targetPosition":{"x":18000.64382962515,"y":31106.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":1,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"id":"62ad0961-6bdf-4a4a-a340-610816742d0a","savedPayload":{"position":{"x":18059.30117742958,"y":32626.17318653769},"targetPosition":{"x":18473.301618063546,"y":31499.850126685462},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":true,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}},{"type":"Crypto Exchange","name":"COSS","config":"{ \n\"codeName\": \"coss\"\n}","project":"Superalgos","exchangeAssets":{"type":"Exchange Assets","name":"New Exchange Assets","config":"{ \n\"addMissingAssetsFilter\": { \"quotedAsset\": \"USDT\"} \n}","project":"Superalgos","assets":[],"id":"e6315232-c6b1-4e25-aade-7bc7ba9ba6ac","savedPayload":{"position":{"x":17787.64382962515,"y":30984.23747069523},"targetPosition":{"x":17874.64382962515,"y":31049.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":2,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"exchangeMarkets":{"type":"Exchange Markets","name":"New Exchange Markets","project":"Superalgos","markets":[],"id":"b1e8451f-09a2-47b0-add3-cf9c35c487bb","savedPayload":{"position":{"x":17829.64382962515,"y":31095.23747069523},"targetPosition":{"x":17874.64382962515,"y":31049.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"exchangeAccounts":{"type":"Exchange Accounts","name":"New Exchange Accounts","project":"Superalgos","userAccounts":[{"type":"User Account","name":"New User Account","project":"Superalgos","userAssets":{"type":"User Assets","name":"New User Assets","project":"Superalgos","assets":[],"id":"d1c9b795-0434-4ce1-9cb7-cc61fac7396d","savedPayload":{"position":{"x":17950.64382962515,"y":31149.23747069523},"targetPosition":{"x":17882.64382962515,"y":31131.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"userKeys":{"type":"User Keys","name":"New User Keys","project":"Superalgos","keys":[{"type":"Exchange Account Key","name":"New Exchange Account Key","config":"{ \n\"codeName\": \"Paste your exchange API name or label\",\n\"secret\": \"Paste your exchange API secret key\"\n}","project":"Superalgos","id":"22be64f9-4b08-4ac3-ae89-6726743a7d5a","savedPayload":{"position":{"x":17890.64382962515,"y":31165.23747069523},"targetPosition":{"x":17956.64382962515,"y":31156.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{}}}],"id":"c7462500-ba74-4bf3-ad81-35fa232bede3","savedPayload":{"position":{"x":17956.64382962515,"y":31156.23747069523},"targetPosition":{"x":17882.64382962515,"y":31131.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"id":"5cd41ced-981a-4075-af43-3a0497eb0fcb","savedPayload":{"position":{"x":17882.64382962515,"y":31131.23747069523},"targetPosition":{"x":17856.64382962515,"y":31148.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}}],"id":"b5937899-c6ee-4d7a-b259-1ee23d721f60","savedPayload":{"position":{"x":17856.64382962515,"y":31148.23747069523},"targetPosition":{"x":17874.64382962515,"y":31049.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":1,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"id":"695029de-7f61-45bb-aa4c-c6d51e6369ed","savedPayload":{"position":{"x":17933.608588282666,"y":32571.63902082737},"targetPosition":{"x":18473.301618063546,"y":31499.850126685462},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":true,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}},{"type":"Crypto Exchange","name":"CREX24","config":"{ \n\"codeName\": \"crex24\"\n}","project":"Superalgos","exchangeAssets":{"type":"Exchange Assets","name":"New Exchange Assets","config":"{ \n\"addMissingAssetsFilter\": { \"quotedAsset\": \"USDT\"} \n}","project":"Superalgos","assets":[],"id":"c5e12f4a-fb26-40d3-9e70-751b55018e74","savedPayload":{"position":{"x":17910.64382962515,"y":31024.23747069523},"targetPosition":{"x":17860.64382962515,"y":31075.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":2,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"exchangeMarkets":{"type":"Exchange Markets","name":"New Exchange Markets","project":"Superalgos","markets":[],"id":"00cb629e-bad4-4c6e-8abb-499cad3992f4","savedPayload":{"position":{"x":17938.64382962515,"y":31054.23747069523},"targetPosition":{"x":17860.64382962515,"y":31075.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"exchangeAccounts":{"type":"Exchange Accounts","name":"New Exchange Accounts","project":"Superalgos","userAccounts":[{"type":"User Account","name":"New User Account","project":"Superalgos","userAssets":{"type":"User Assets","name":"New User Assets","project":"Superalgos","assets":[],"id":"4909d182-e0d5-49a9-8ad2-a553c8aaaf88","savedPayload":{"position":{"x":17912.64382962515,"y":31301.23747069523},"targetPosition":{"x":17920.64382962515,"y":31249.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"userKeys":{"type":"User Keys","name":"New User Keys","project":"Superalgos","keys":[{"type":"Exchange Account Key","name":"New Exchange Account Key","config":"{ \n\"codeName\": \"Paste your exchange API name or label\",\n\"secret\": \"Paste your exchange API secret key\"\n}","project":"Superalgos","id":"075eb2a2-299b-4a0f-9f6d-76c385521dc4","savedPayload":{"position":{"x":17800.64382962515,"y":31332.23747069523},"targetPosition":{"x":17883.64382962515,"y":31289.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{}}}],"id":"e062ef2e-b252-4a66-8f58-d9aa8031f526","savedPayload":{"position":{"x":17883.64382962515,"y":31289.23747069523},"targetPosition":{"x":17920.64382962515,"y":31249.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"id":"8e75be98-f874-486d-b749-536e364934dc","savedPayload":{"position":{"x":17920.64382962515,"y":31249.23747069523},"targetPosition":{"x":17845.64382962515,"y":31164.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}}],"id":"052f73cd-7ed7-4537-8b01-840b5b892fea","savedPayload":{"position":{"x":17845.64382962515,"y":31164.23747069523},"targetPosition":{"x":17860.64382962515,"y":31075.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":1,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"id":"07a7ec7c-273e-4675-8d8d-21ab8514a1f0","savedPayload":{"position":{"x":17814.95172313306,"y":32503.13244779205},"targetPosition":{"x":18473.301618063546,"y":31499.850126685462},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":true,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}},{"type":"Crypto Exchange","name":"Deribit","config":"{ \n\"codeName\": \"deribit\"\n}","project":"Superalgos","exchangeAssets":{"type":"Exchange Assets","name":"New Exchange Assets","config":"{ \n\"addMissingAssetsFilter\": { \"quotedAsset\": \"USDT\"} \n}","project":"Superalgos","assets":[],"id":"f0b2354b-89e3-4eca-b051-664a3b8283f6","savedPayload":{"position":{"x":17862.64382962515,"y":30844.23747069523},"targetPosition":{"x":17906.64382962515,"y":30929.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":2,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"exchangeMarkets":{"type":"Exchange Markets","name":"New Exchange Markets","project":"Superalgos","markets":[],"id":"4ae1f824-82a8-4796-a2d5-3d2358d8089f","savedPayload":{"position":{"x":17912.64382962515,"y":31024.23747069523},"targetPosition":{"x":17906.64382962515,"y":30929.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"exchangeAccounts":{"type":"Exchange Accounts","name":"New Exchange Accounts","project":"Superalgos","userAccounts":[{"type":"User Account","name":"New User Account","project":"Superalgos","userAssets":{"type":"User Assets","name":"New User Assets","project":"Superalgos","assets":[],"id":"2013fe7a-d52c-4c9d-ba53-d281d014a8fc","savedPayload":{"position":{"x":17873.64382962515,"y":30926.23747069523},"targetPosition":{"x":17855.64382962515,"y":30967.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"userKeys":{"type":"User Keys","name":"New User Keys","project":"Superalgos","keys":[{"type":"Exchange Account Key","name":"New Exchange Account Key","config":"{ \n\"codeName\": \"Paste your exchange API name or label\",\n\"secret\": \"Paste your exchange API secret key\"\n}","project":"Superalgos","id":"706d5778-ed21-49bd-9277-1840ec52708d","savedPayload":{"position":{"x":17729.64382962515,"y":31033.23747069523},"targetPosition":{"x":17813.64382962515,"y":31053.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{}}}],"id":"2e76bc02-6e10-4f14-9bf1-a11dc4268466","savedPayload":{"position":{"x":17813.64382962515,"y":31053.23747069523},"targetPosition":{"x":17855.64382962515,"y":30967.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"id":"89a3ccc7-20ab-4e2d-929b-52d9286179b7","savedPayload":{"position":{"x":17855.64382962515,"y":30967.23747069523},"targetPosition":{"x":17818.64382962515,"y":30920.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}}],"id":"5c8219e3-4509-4b8b-941b-b88ac2c12237","savedPayload":{"position":{"x":17818.64382962515,"y":30920.23747069523},"targetPosition":{"x":17906.64382962515,"y":30929.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":1,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"id":"21971815-4248-45df-8e04-20b9a5a83f06","savedPayload":{"position":{"x":17704.87745568028,"y":32421.54655537854},"targetPosition":{"x":18473.301618063546,"y":31499.850126685462},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":true,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}},{"type":"Crypto Exchange","name":"DigiFinex","config":"{ \n\"codeName\": \"digifinex\"\n}","project":"Superalgos","exchangeAssets":{"type":"Exchange Assets","name":"New Exchange Assets","config":"{ \n\"addMissingAssetsFilter\": { \"quotedAsset\": \"USDT\"} \n}","project":"Superalgos","assets":[],"id":"e583c93e-9a44-4e0d-acb7-56d7e00a555a","savedPayload":{"position":{"x":17954.64382962515,"y":30992.23747069523},"targetPosition":{"x":17996.64382962515,"y":31033.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":2,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"exchangeMarkets":{"type":"Exchange Markets","name":"New Exchange Markets","project":"Superalgos","markets":[],"id":"8917c7c0-b420-4d4f-a35a-c0fc6870f0de","savedPayload":{"position":{"x":18052.64382962515,"y":30972.23747069523},"targetPosition":{"x":17996.64382962515,"y":31033.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"exchangeAccounts":{"type":"Exchange Accounts","name":"New Exchange Accounts","project":"Superalgos","userAccounts":[{"type":"User Account","name":"New User Account","project":"Superalgos","userAssets":{"type":"User Assets","name":"New User Assets","project":"Superalgos","assets":[],"id":"a00b5bb0-5ab9-42e2-91fe-b450c7eb66d2","savedPayload":{"position":{"x":18220.64382962515,"y":31090.23747069523},"targetPosition":{"x":18123.64382962515,"y":30998.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"userKeys":{"type":"User Keys","name":"New User Keys","project":"Superalgos","keys":[{"type":"Exchange Account Key","name":"New Exchange Account Key","config":"{ \n\"codeName\": \"Paste your exchange API name or label\",\n\"secret\": \"Paste your exchange API secret key\"\n}","project":"Superalgos","id":"2aafc473-339b-4d23-9b74-06fa7574c293","savedPayload":{"position":{"x":18144.64382962515,"y":31123.23747069523},"targetPosition":{"x":18203.64382962515,"y":31084.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{}}}],"id":"99e9e136-1ac7-4400-a100-0a2d37f0882d","savedPayload":{"position":{"x":18203.64382962515,"y":31084.23747069523},"targetPosition":{"x":18123.64382962515,"y":30998.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"id":"b7cee21b-ddcb-4fd7-b610-43aabb2d1766","savedPayload":{"position":{"x":18123.64382962515,"y":30998.23747069523},"targetPosition":{"x":18032.64382962515,"y":30976.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}}],"id":"08e84a25-4368-4ad6-939f-5a16cece62cc","savedPayload":{"position":{"x":18032.64382962515,"y":30976.23747069523},"targetPosition":{"x":17996.64382962515,"y":31033.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":1,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"id":"b7d56781-0c51-4ec1-95fd-bf4dc8c00352","savedPayload":{"position":{"x":17604.82077233746,"y":32327.944940463996},"targetPosition":{"x":18473.301618063546,"y":31499.850126685462},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":true,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}},{"type":"Crypto Exchange","name":"DSX","config":"{ \n\"codeName\": \"dsx\"\n}","project":"Superalgos","exchangeAssets":{"type":"Exchange Assets","name":"New Exchange Assets","config":"{ \n\"addMissingAssetsFilter\": { \"quotedAsset\": \"USDT\"} \n}","project":"Superalgos","assets":[],"id":"d672ab56-cd32-4ff5-8fc5-3733262aeccb","savedPayload":{"position":{"x":17916.64382962515,"y":31106.23747069523},"targetPosition":{"x":17955.64382962515,"y":31011.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":2,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"exchangeMarkets":{"type":"Exchange Markets","name":"New Exchange Markets","project":"Superalgos","markets":[],"id":"3731a7b5-ba9d-483e-bb41-abf3ae0232c6","savedPayload":{"position":{"x":17878.64382962515,"y":30946.23747069523},"targetPosition":{"x":17955.64382962515,"y":31011.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"exchangeAccounts":{"type":"Exchange Accounts","name":"New Exchange Accounts","project":"Superalgos","userAccounts":[{"type":"User Account","name":"New User Account","project":"Superalgos","userAssets":{"type":"User Assets","name":"New User Assets","project":"Superalgos","assets":[],"id":"9ef7e0ac-dc27-4b47-a06e-0cb7e80ee3d7","savedPayload":{"position":{"x":18124.64382962515,"y":31136.23747069523},"targetPosition":{"x":18093.64382962515,"y":31072.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"userKeys":{"type":"User Keys","name":"New User Keys","project":"Superalgos","keys":[{"type":"Exchange Account Key","name":"New Exchange Account Key","config":"{ \n\"codeName\": \"Paste your exchange API name or label\",\n\"secret\": \"Paste your exchange API secret key\"\n}","project":"Superalgos","id":"77491a3c-3db7-446f-aa67-9b5a1a3be7b3","savedPayload":{"position":{"x":18109.64382962515,"y":31081.23747069523},"targetPosition":{"x":18188.64382962515,"y":31137.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{}}}],"id":"bd1bd0b7-4943-4aeb-bf90-d3192dcabbb1","savedPayload":{"position":{"x":18188.64382962515,"y":31137.23747069523},"targetPosition":{"x":18093.64382962515,"y":31072.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"id":"45747fef-f30e-4fae-b02d-5768ae7dbe68","savedPayload":{"position":{"x":18093.64382962515,"y":31072.23747069523},"targetPosition":{"x":18018.64382962515,"y":31005.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}}],"id":"aa2e1c9b-428c-4bb0-9e75-ceb8c9043d4b","savedPayload":{"position":{"x":18018.64382962515,"y":31005.23747069523},"targetPosition":{"x":17955.64382962515,"y":31011.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":1,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"id":"4c543abc-7372-4701-bc58-107578d45c25","savedPayload":{"position":{"x":17516.08606498896,"y":32223.54784324405},"targetPosition":{"x":18473.301618063546,"y":31499.850126685462},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":true,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}},{"type":"Crypto Exchange","name":"FCoin","config":"{ \n\"codeName\": \"fcoin\"\n}","project":"Superalgos","exchangeAssets":{"type":"Exchange Assets","name":"New Exchange Assets","config":"{ \n\"addMissingAssetsFilter\": { \"quotedAsset\": \"USDT\"} \n}","project":"Superalgos","assets":[],"id":"a97d578c-6d7f-403c-8294-18aacf14abd8","savedPayload":{"position":{"x":17893.64382962515,"y":30953.23747069523},"targetPosition":{"x":17919.64382962515,"y":30948.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":2,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"exchangeMarkets":{"type":"Exchange Markets","name":"New Exchange Markets","project":"Superalgos","markets":[],"id":"442c3834-482e-4928-9255-8ac859ae012e","savedPayload":{"position":{"x":17905.64382962515,"y":30896.23747069523},"targetPosition":{"x":17919.64382962515,"y":30948.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"exchangeAccounts":{"type":"Exchange Accounts","name":"New Exchange Accounts","project":"Superalgos","userAccounts":[{"type":"User Account","name":"New User Account","project":"Superalgos","userAssets":{"type":"User Assets","name":"New User Assets","project":"Superalgos","assets":[],"id":"79754959-1219-4c4d-be63-22766158beb5","savedPayload":{"position":{"x":18106.64382962515,"y":30976.23747069523},"targetPosition":{"x":18069.64382962515,"y":31056.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"userKeys":{"type":"User Keys","name":"New User Keys","project":"Superalgos","keys":[{"type":"Exchange Account Key","name":"New Exchange Account Key","config":"{ \n\"codeName\": \"Paste your exchange API name or label\",\n\"secret\": \"Paste your exchange API secret key\"\n}","project":"Superalgos","id":"1c3ae096-5024-43c3-abca-24498254e363","savedPayload":{"position":{"x":18112.64382962515,"y":30919.23747069523},"targetPosition":{"x":18126.64382962515,"y":30965.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{}}}],"id":"59db5bfd-e413-48a7-af63-237ad56adc82","savedPayload":{"position":{"x":18126.64382962515,"y":30965.23747069523},"targetPosition":{"x":18069.64382962515,"y":31056.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"id":"833c4e54-08f4-48ec-b90a-2767eb55f244","savedPayload":{"position":{"x":18069.64382962515,"y":31056.23747069523},"targetPosition":{"x":17996.64382962515,"y":30970.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}}],"id":"a8cf17b3-0ea7-4a14-8c76-f655344b58a3","savedPayload":{"position":{"x":17996.64382962515,"y":30970.23747069523},"targetPosition":{"x":17919.64382962515,"y":30948.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":1,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"id":"6ddedcbd-07cb-4928-91b3-348f47118391","savedPayload":{"position":{"x":17439.830126247303,"y":32109.716239535745},"targetPosition":{"x":18473.301618063546,"y":31499.850126685462},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":true,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}},{"type":"Crypto Exchange","name":"FCoinJP","config":"{ \n\"codeName\": \"fcoinjp\"\n}","project":"Superalgos","exchangeAssets":{"type":"Exchange Assets","name":"New Exchange Assets","config":"{ \n\"addMissingAssetsFilter\": { \"quotedAsset\": \"USDT\"} \n}","project":"Superalgos","assets":[],"id":"4a8a9810-6df6-451a-ab26-22bd7e7be85a","savedPayload":{"position":{"x":17930.64382962515,"y":31129.23747069523},"targetPosition":{"x":17942.64382962515,"y":31052.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":2,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"exchangeMarkets":{"type":"Exchange Markets","name":"New Exchange Markets","project":"Superalgos","markets":[],"id":"138ab40c-18ca-4a11-9709-0baa040873e6","savedPayload":{"position":{"x":18007.64382962515,"y":31122.23747069523},"targetPosition":{"x":17942.64382962515,"y":31052.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"exchangeAccounts":{"type":"Exchange Accounts","name":"New Exchange Accounts","project":"Superalgos","userAccounts":[{"type":"User Account","name":"New User Account","project":"Superalgos","userAssets":{"type":"User Assets","name":"New User Assets","project":"Superalgos","assets":[],"id":"258cdf92-8ed0-4133-ae2a-b9f086f56a13","savedPayload":{"position":{"x":17897.64382962515,"y":30887.23747069523},"targetPosition":{"x":17903.64382962515,"y":30977.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"userKeys":{"type":"User Keys","name":"New User Keys","project":"Superalgos","keys":[{"type":"Exchange Account Key","name":"New Exchange Account Key","config":"{ \n\"codeName\": \"Paste your exchange API name or label\",\n\"secret\": \"Paste your exchange API secret key\"\n}","project":"Superalgos","id":"537e8f0c-05ca-4403-bc96-da6c2f4678ae","savedPayload":{"position":{"x":17825.64382962515,"y":30842.23747069523},"targetPosition":{"x":17836.64382962515,"y":30926.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{}}}],"id":"62519e63-8f4e-4b72-a341-0a6eea01ac3f","savedPayload":{"position":{"x":17836.64382962515,"y":30926.23747069523},"targetPosition":{"x":17903.64382962515,"y":30977.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"id":"b4974cc1-f594-436b-8aa4-aff2733b8e3c","savedPayload":{"position":{"x":17903.64382962515,"y":30977.23747069523},"targetPosition":{"x":17873.64382962515,"y":31061.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}}],"id":"d84b404f-75e2-4eb5-b34a-b45af8a57ca7","savedPayload":{"position":{"x":17873.64382962515,"y":31061.23747069523},"targetPosition":{"x":17942.64382962515,"y":31052.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":1,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"id":"982627ea-df84-4ba9-9219-612fbe1e4276","savedPayload":{"position":{"x":17377.047068892425,"y":31987.934098376423},"targetPosition":{"x":18473.301618063546,"y":31499.850126685462},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":true,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}},{"type":"Crypto Exchange","name":"FTX","config":"{ \n\"codeName\": \"ftx\"\n}","project":"Superalgos","exchangeAssets":{"type":"Exchange Assets","name":"New Exchange Assets","config":"{ \n\"addMissingAssetsFilter\": { \"quotedAsset\": \"USDT\"} \n}","project":"Superalgos","assets":[],"id":"20c0a4f5-bdb9-46cc-af7e-2111964551e3","savedPayload":{"position":{"x":17886.64382962515,"y":30940.23747069523},"targetPosition":{"x":17960.64382962515,"y":31019.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":2,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"exchangeMarkets":{"type":"Exchange Markets","name":"New Exchange Markets","project":"Superalgos","markets":[],"id":"75c99a0b-d3c9-4073-9283-d33e539c36bb","savedPayload":{"position":{"x":17992.64382962515,"y":31061.23747069523},"targetPosition":{"x":17960.64382962515,"y":31019.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"exchangeAccounts":{"type":"Exchange Accounts","name":"New Exchange Accounts","project":"Superalgos","userAccounts":[{"type":"User Account","name":"New User Account","project":"Superalgos","userAssets":{"type":"User Assets","name":"New User Assets","project":"Superalgos","assets":[],"id":"2e037470-549e-4aa8-bbe7-95cdeaef88ea","savedPayload":{"position":{"x":17964.64382962515,"y":31027.23747069523},"targetPosition":{"x":17970.64382962515,"y":31008.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"userKeys":{"type":"User Keys","name":"New User Keys","project":"Superalgos","keys":[{"type":"Exchange Account Key","name":"New Exchange Account Key","config":"{ \n\"codeName\": \"Paste your exchange API name or label\",\n\"secret\": \"Paste your exchange API secret key\"\n}","project":"Superalgos","id":"3b6f5b7b-9c61-4b71-b29a-ca1bc027e55f","savedPayload":{"position":{"x":17817.64382962515,"y":30943.23747069523},"targetPosition":{"x":17890.64382962515,"y":30978.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{}}}],"id":"a84010f0-04b5-4eab-a3a6-a5944b80a373","savedPayload":{"position":{"x":17890.64382962515,"y":30978.23747069523},"targetPosition":{"x":17970.64382962515,"y":31008.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"id":"5cdc51a3-6136-4e03-9e2c-26a752140d17","savedPayload":{"position":{"x":17970.64382962515,"y":31008.23747069523},"targetPosition":{"x":18010.64382962515,"y":30986.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}}],"id":"55258a2b-3199-4070-beed-d34a8496870c","savedPayload":{"position":{"x":18010.64382962515,"y":30986.23747069523},"targetPosition":{"x":17960.64382962515,"y":31019.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":1,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"id":"0c0bcf5c-2774-423e-9fcf-c512b38dd06d","savedPayload":{"position":{"x":17328.555366091252,"y":31859.789036217877},"targetPosition":{"x":18473.301618063546,"y":31499.850126685462},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":true,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}},{"type":"Crypto Exchange","name":"Gate.io","config":"{ \n\"codeName\": \"gateio\"\n}","project":"Superalgos","exchangeAssets":{"type":"Exchange Assets","name":"New Exchange Assets","config":"{ \n\"addMissingAssetsFilter\": { \"quotedAsset\": \"USDT\"} \n}","project":"Superalgos","assets":[],"id":"71a15089-9d40-4726-9a41-37d406064164","savedPayload":{"position":{"x":17930.64382962515,"y":30993.23747069523},"targetPosition":{"x":17880.64382962515,"y":31031.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":2,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"exchangeMarkets":{"type":"Exchange Markets","name":"New Exchange Markets","project":"Superalgos","markets":[],"id":"c025e976-c2c6-49de-81ec-48e2f737b412","savedPayload":{"position":{"x":17925.64382962515,"y":31053.23747069523},"targetPosition":{"x":17880.64382962515,"y":31031.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"exchangeAccounts":{"type":"Exchange Accounts","name":"New Exchange Accounts","project":"Superalgos","userAccounts":[{"type":"User Account","name":"New User Account","project":"Superalgos","userAssets":{"type":"User Assets","name":"New User Assets","project":"Superalgos","assets":[],"id":"876f964a-e12d-4438-87fb-a84be22f86d1","savedPayload":{"position":{"x":17914.64382962515,"y":30833.23747069523},"targetPosition":{"x":17827.64382962515,"y":30882.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"userKeys":{"type":"User Keys","name":"New User Keys","project":"Superalgos","keys":[{"type":"Exchange Account Key","name":"New Exchange Account Key","config":"{ \n\"codeName\": \"Paste your exchange API name or label\",\n\"secret\": \"Paste your exchange API secret key\"\n}","project":"Superalgos","id":"0c5d34c4-467f-4e98-bd39-1b2d9afb834e","savedPayload":{"position":{"x":17852.64382962515,"y":30831.23747069523},"targetPosition":{"x":17870.64382962515,"y":30847.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{}}}],"id":"89316d8c-893a-46ae-b147-948b4b8a5292","savedPayload":{"position":{"x":17870.64382962515,"y":30847.23747069523},"targetPosition":{"x":17827.64382962515,"y":30882.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"id":"a2a5de53-bd45-4904-8bae-0cf5ed66d2af","savedPayload":{"position":{"x":17827.64382962515,"y":30882.23747069523},"targetPosition":{"x":17800.64382962515,"y":30936.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}}],"id":"f6f4072d-8cf6-4e47-8b4e-a21cd553348a","savedPayload":{"position":{"x":17800.64382962515,"y":30936.23747069523},"targetPosition":{"x":17880.64382962515,"y":31031.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":1,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"id":"c4028289-4cdb-4da0-90e6-5f93328b8e03","savedPayload":{"position":{"x":17294.987181348297,"y":31726.951619917952},"targetPosition":{"x":18473.301618063546,"y":31499.850126685462},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":true,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}},{"type":"Crypto Exchange","name":"Gemini","config":"{ \n\"codeName\": \"gemini\"\n}","project":"Superalgos","exchangeAssets":{"type":"Exchange Assets","name":"New Exchange Assets","config":"{ \n\"addMissingAssetsFilter\": { \"quotedAsset\": \"USDT\"} \n}","project":"Superalgos","assets":[],"id":"9eb15872-8d15-4086-9920-46909eb5f9e7","savedPayload":{"position":{"x":17951.64382962515,"y":30901.23747069523},"targetPosition":{"x":17971.64382962515,"y":30935.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":2,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"exchangeMarkets":{"type":"Exchange Markets","name":"New Exchange Markets","project":"Superalgos","markets":[],"id":"a84dcf06-57c6-47d7-97a0-9f03f3af8b34","savedPayload":{"position":{"x":18045.64382962515,"y":30891.23747069523},"targetPosition":{"x":17971.64382962515,"y":30935.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"exchangeAccounts":{"type":"Exchange Accounts","name":"New Exchange Accounts","project":"Superalgos","userAccounts":[{"type":"User Account","name":"New User Account","project":"Superalgos","userAssets":{"type":"User Assets","name":"New User Assets","project":"Superalgos","assets":[],"id":"5da1ba65-3839-4664-8105-2ccb11652767","savedPayload":{"position":{"x":18028.64382962515,"y":31112.23747069523},"targetPosition":{"x":17941.64382962515,"y":31044.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"userKeys":{"type":"User Keys","name":"New User Keys","project":"Superalgos","keys":[{"type":"Exchange Account Key","name":"New Exchange Account Key","config":"{ \n\"codeName\": \"Paste your exchange API name or label\",\n\"secret\": \"Paste your exchange API secret key\"\n}","project":"Superalgos","id":"337fe5e2-b9fd-40eb-9f42-44fc5057d981","savedPayload":{"position":{"x":17957.64382962515,"y":31129.23747069523},"targetPosition":{"x":17875.64382962515,"y":31086.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{}}}],"id":"17a3f4a3-8914-4995-afb0-7e8115791b17","savedPayload":{"position":{"x":17875.64382962515,"y":31086.23747069523},"targetPosition":{"x":17941.64382962515,"y":31044.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"id":"32e4a3f1-40d8-421f-9634-7ab339858286","savedPayload":{"position":{"x":17941.64382962515,"y":31044.23747069523},"targetPosition":{"x":17877.64382962515,"y":30977.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}}],"id":"365f6865-e707-415d-a168-b67c66ca9553","savedPayload":{"position":{"x":17877.64382962515,"y":30977.23747069523},"targetPosition":{"x":17971.64382962515,"y":30935.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":1,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"id":"58bf8247-baef-4ea6-a483-7ed8f0ba5043","savedPayload":{"position":{"x":17276.780127287613,"y":31591.153588346777},"targetPosition":{"x":18473.301618063546,"y":31499.850126685462},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":true,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}},{"type":"Crypto Exchange","name":"HitBTC","config":"{ \n\"codeName\": \"hitbtc\"\n}","project":"Superalgos","exchangeAssets":{"type":"Exchange Assets","name":"New Exchange Assets","config":"{ \n\"addMissingAssetsFilter\": { \"quotedAsset\": \"USDT\"} \n}","project":"Superalgos","assets":[],"id":"1632c520-fa79-442f-b33b-430cb1356de6","savedPayload":{"position":{"x":17809.64382962515,"y":31086.23747069523},"targetPosition":{"x":17880.64382962515,"y":31069.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":2,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"exchangeMarkets":{"type":"Exchange Markets","name":"New Exchange Markets","project":"Superalgos","markets":[],"id":"576d1666-dbd3-4914-9fe2-fa05bdf72eea","savedPayload":{"position":{"x":17840.64382962515,"y":31148.23747069523},"targetPosition":{"x":17880.64382962515,"y":31069.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"exchangeAccounts":{"type":"Exchange Accounts","name":"New Exchange Accounts","project":"Superalgos","userAccounts":[{"type":"User Account","name":"New User Account","project":"Superalgos","userAssets":{"type":"User Assets","name":"New User Assets","project":"Superalgos","assets":[],"id":"41317aae-08ce-48cf-a47b-c2d2cc3920ec","savedPayload":{"position":{"x":18096.64382962515,"y":30975.23747069523},"targetPosition":{"x":18026.64382962515,"y":31066.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"userKeys":{"type":"User Keys","name":"New User Keys","project":"Superalgos","keys":[{"type":"Exchange Account Key","name":"New Exchange Account Key","config":"{ \n\"codeName\": \"Paste your exchange API name or label\",\n\"secret\": \"Paste your exchange API secret key\"\n}","project":"Superalgos","id":"23d7e4ba-8432-4214-bd94-0db5046e39cd","savedPayload":{"position":{"x":18039.64382962515,"y":31075.23747069523},"targetPosition":{"x":17981.64382962515,"y":31126.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{}}}],"id":"ab200349-5ba5-44d2-ad5c-fa826303cfcd","savedPayload":{"position":{"x":17981.64382962515,"y":31126.23747069523},"targetPosition":{"x":18026.64382962515,"y":31066.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"id":"a5f24785-5b2c-429b-a2e4-07063e2de904","savedPayload":{"position":{"x":18026.64382962515,"y":31066.23747069523},"targetPosition":{"x":17972.64382962515,"y":31093.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}}],"id":"13f275ca-06a6-4a72-8b4d-a9c079b9cef4","savedPayload":{"position":{"x":17972.64382962515,"y":31093.23747069523},"targetPosition":{"x":17880.64382962515,"y":31069.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":1,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"id":"8384fa0b-854c-4c23-846e-a5da0179a738","savedPayload":{"position":{"x":17274.171560702976,"y":31454.16527652219},"targetPosition":{"x":18473.301618063546,"y":31499.850126685462},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":true,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}},{"type":"Crypto Exchange","name":"HitBTC","config":"{ \n\"codeName\": \"hitbtc2\"\n}","project":"Superalgos","exchangeAssets":{"type":"Exchange Assets","name":"New Exchange Assets","config":"{ \n\"addMissingAssetsFilter\": { \"quotedAsset\": \"USDT\"} \n}","project":"Superalgos","assets":[],"id":"9a29cb9e-ee8d-4315-8532-eef82224b84a","savedPayload":{"position":{"x":17838.64382962515,"y":30922.23747069523},"targetPosition":{"x":17829.64382962515,"y":30949.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":2,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"exchangeMarkets":{"type":"Exchange Markets","name":"New Exchange Markets","project":"Superalgos","markets":[],"id":"badd79e7-1e21-4dc3-bfa7-8dfb4a6c6267","savedPayload":{"position":{"x":17920.64382962515,"y":30944.23747069523},"targetPosition":{"x":17829.64382962515,"y":30949.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"exchangeAccounts":{"type":"Exchange Accounts","name":"New Exchange Accounts","project":"Superalgos","userAccounts":[{"type":"User Account","name":"New User Account","project":"Superalgos","userAssets":{"type":"User Assets","name":"New User Assets","project":"Superalgos","assets":[],"id":"ffdda0b7-af50-4010-84da-2bc0d562af2b","savedPayload":{"position":{"x":17887.64382962515,"y":30982.23747069523},"targetPosition":{"x":17836.64382962515,"y":31023.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"userKeys":{"type":"User Keys","name":"New User Keys","project":"Superalgos","keys":[{"type":"Exchange Account Key","name":"New Exchange Account Key","config":"{ \n\"codeName\": \"Paste your exchange API name or label\",\n\"secret\": \"Paste your exchange API secret key\"\n}","project":"Superalgos","id":"24816eed-adf7-453e-9b38-42ea4758dbaa","savedPayload":{"position":{"x":18021.64382962515,"y":30979.23747069523},"targetPosition":{"x":17931.64382962515,"y":30923.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{}}}],"id":"1dd16858-5641-4454-88a3-e5d7446e12a3","savedPayload":{"position":{"x":17931.64382962515,"y":30923.23747069523},"targetPosition":{"x":17836.64382962515,"y":31023.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"id":"457d75ed-ad21-4ee5-b36b-88cdc444008e","savedPayload":{"position":{"x":17836.64382962515,"y":31023.23747069523},"targetPosition":{"x":17808.64382962515,"y":31039.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}}],"id":"b29ded7e-e2d5-4c7f-89af-b0816c32c743","savedPayload":{"position":{"x":17808.64382962515,"y":31039.23747069523},"targetPosition":{"x":17829.64382962515,"y":30949.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":1,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"id":"09c634c2-5aba-49c5-80bc-4fd4175e7f0c","savedPayload":{"position":{"x":17287.19548824911,"y":31317.772536585464},"targetPosition":{"x":18473.301618063546,"y":31499.850126685462},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":true,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}},{"type":"Crypto Exchange","name":"Huobi Pro","config":"{ \n\"codeName\": \"huobipro\"\n}","project":"Superalgos","exchangeAssets":{"type":"Exchange Assets","name":"New Exchange Assets","config":"{ \n\"addMissingAssetsFilter\": { \"quotedAsset\": \"USDT\"} \n}","project":"Superalgos","assets":[],"id":"86caa38c-5bdf-40e4-b27b-8d8b64319575","savedPayload":{"position":{"x":18071.64382962515,"y":31171.23747069523},"targetPosition":{"x":17996.64382962515,"y":31077.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":2,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"exchangeMarkets":{"type":"Exchange Markets","name":"New Exchange Markets","project":"Superalgos","markets":[],"id":"001225af-c715-4566-9502-f8f0ac1c4531","savedPayload":{"position":{"x":18040.64382962515,"y":31019.23747069523},"targetPosition":{"x":17996.64382962515,"y":31077.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"exchangeAccounts":{"type":"Exchange Accounts","name":"New Exchange Accounts","project":"Superalgos","userAccounts":[{"type":"User Account","name":"New User Account","project":"Superalgos","userAssets":{"type":"User Assets","name":"New User Assets","project":"Superalgos","assets":[],"id":"b4bf5ccb-b529-4500-a192-d9c3a0613389","savedPayload":{"position":{"x":18129.64382962515,"y":31073.23747069523},"targetPosition":{"x":18033.64382962515,"y":31090.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"userKeys":{"type":"User Keys","name":"New User Keys","project":"Superalgos","keys":[{"type":"Exchange Account Key","name":"New Exchange Account Key","config":"{ \n\"codeName\": \"Paste your exchange API name or label\",\n\"secret\": \"Paste your exchange API secret key\"\n}","project":"Superalgos","id":"2e58c6d1-cfa7-4dc7-a322-e9356596ea1e","savedPayload":{"position":{"x":17976.64382962515,"y":31132.23747069523},"targetPosition":{"x":17953.64382962515,"y":31093.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{}}}],"id":"ae04ddf4-ae3e-4bdc-9393-41acc38ef818","savedPayload":{"position":{"x":17953.64382962515,"y":31093.23747069523},"targetPosition":{"x":18033.64382962515,"y":31090.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"id":"2428e8ef-6a09-48fa-8ae4-ebfb28420be8","savedPayload":{"position":{"x":18033.64382962515,"y":31090.23747069523},"targetPosition":{"x":18085.64382962515,"y":31157.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}}],"id":"55c71c8b-f21f-4d16-ae93-e29362c39bf5","savedPayload":{"position":{"x":18085.64382962515,"y":31157.23747069523},"targetPosition":{"x":17996.64382962515,"y":31077.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":1,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"id":"967c3914-a76d-4389-9c7e-9c258ae683bd","savedPayload":{"position":{"x":17315.682123112918,"y":31183.753456487473},"targetPosition":{"x":18473.301618063546,"y":31499.850126685462},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":true,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}},{"type":"Crypto Exchange","name":"Huobi Russia","config":"{ \n\"codeName\": \"huobiru\"\n}","project":"Superalgos","exchangeAssets":{"type":"Exchange Assets","name":"New Exchange Assets","config":"{ \n\"addMissingAssetsFilter\": { \"quotedAsset\": \"USDT\"} \n}","project":"Superalgos","assets":[],"id":"9b7b32d6-a42e-44bb-8065-5aa32b1e844b","savedPayload":{"position":{"x":17980.64382962515,"y":31034.23747069523},"targetPosition":{"x":17957.64382962515,"y":31088.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":2,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"exchangeMarkets":{"type":"Exchange Markets","name":"New Exchange Markets","project":"Superalgos","markets":[],"id":"8d74201c-33cd-4e12-8920-b08d0ef97572","savedPayload":{"position":{"x":17992.64382962515,"y":31105.23747069523},"targetPosition":{"x":17957.64382962515,"y":31088.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"exchangeAccounts":{"type":"Exchange Accounts","name":"New Exchange Accounts","project":"Superalgos","userAccounts":[{"type":"User Account","name":"New User Account","project":"Superalgos","userAssets":{"type":"User Assets","name":"New User Assets","project":"Superalgos","assets":[],"id":"c6e289d7-074b-4837-96e3-687988886fcc","savedPayload":{"position":{"x":18078.64382962515,"y":30954.23747069523},"targetPosition":{"x":18008.64382962515,"y":31029.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"userKeys":{"type":"User Keys","name":"New User Keys","project":"Superalgos","keys":[{"type":"Exchange Account Key","name":"New Exchange Account Key","config":"{ \n\"codeName\": \"Paste your exchange API name or label\",\n\"secret\": \"Paste your exchange API secret key\"\n}","project":"Superalgos","id":"d72f81ba-6b41-414d-9cf0-d5f9c0c25403","savedPayload":{"position":{"x":18026.64382962515,"y":31021.23747069523},"targetPosition":{"x":18083.64382962515,"y":31117.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{}}}],"id":"5354f66c-6e73-4fe5-80ca-2c25b761ef51","savedPayload":{"position":{"x":18083.64382962515,"y":31117.23747069523},"targetPosition":{"x":18008.64382962515,"y":31029.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"id":"81f5adbb-054c-47f2-b019-52585f5d7417","savedPayload":{"position":{"x":18008.64382962515,"y":31029.23747069523},"targetPosition":{"x":18018.64382962515,"y":31009.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}}],"id":"ecd8645b-4bb6-4641-a20f-cee51bf33f1a","savedPayload":{"position":{"x":18018.64382962515,"y":31009.23747069523},"targetPosition":{"x":17957.64382962515,"y":31088.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":1,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"id":"6f97bb5c-8d85-43ee-86a1-33e22cdfbb5e","savedPayload":{"position":{"x":17359.260098444258,"y":31053.85517989307},"targetPosition":{"x":18473.301618063546,"y":31499.850126685462},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":true,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}},{"type":"Crypto Exchange","name":"KKEX","config":"{ \n\"codeName\": \"kkex\"\n}","project":"Superalgos","exchangeAssets":{"type":"Exchange Assets","name":"New Exchange Assets","config":"{ \n\"addMissingAssetsFilter\": { \"quotedAsset\": \"USDT\"} \n}","project":"Superalgos","assets":[],"id":"daa4e07a-1cd8-4d92-8004-2eabfaa62f77","savedPayload":{"position":{"x":17924.64382962515,"y":31038.23747069523},"targetPosition":{"x":17987.64382962515,"y":31073.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":2,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"exchangeMarkets":{"type":"Exchange Markets","name":"New Exchange Markets","project":"Superalgos","markets":[],"id":"cb64951f-d984-4f51-a751-166a316084f3","savedPayload":{"position":{"x":17945.64382962515,"y":31156.23747069523},"targetPosition":{"x":17987.64382962515,"y":31073.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"exchangeAccounts":{"type":"Exchange Accounts","name":"New Exchange Accounts","project":"Superalgos","userAccounts":[{"type":"User Account","name":"New User Account","project":"Superalgos","userAssets":{"type":"User Assets","name":"New User Assets","project":"Superalgos","assets":[],"id":"6915bf12-9271-47e2-8b49-924ae9f5c65f","savedPayload":{"position":{"x":17958.64382962515,"y":31297.23747069523},"targetPosition":{"x":17875.64382962515,"y":31252.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"userKeys":{"type":"User Keys","name":"New User Keys","project":"Superalgos","keys":[{"type":"Exchange Account Key","name":"New Exchange Account Key","config":"{ \n\"codeName\": \"Paste your exchange API name or label\",\n\"secret\": \"Paste your exchange API secret key\"\n}","project":"Superalgos","id":"ff53381f-c6dd-4d17-a477-11396f60663f","savedPayload":{"position":{"x":17805.64382962515,"y":31141.23747069523},"targetPosition":{"x":17861.64382962515,"y":31223.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{}}}],"id":"ae05bfc4-6ac8-408c-a90b-263830b2a71e","savedPayload":{"position":{"x":17861.64382962515,"y":31223.23747069523},"targetPosition":{"x":17875.64382962515,"y":31252.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"id":"61c85f1a-a2a6-45c9-bb1e-3c76110f5d1e","savedPayload":{"position":{"x":17875.64382962515,"y":31252.23747069523},"targetPosition":{"x":17911.64382962515,"y":31154.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}}],"id":"9fafb114-37d2-4d04-9c42-83d04ff62fc7","savedPayload":{"position":{"x":17911.64382962515,"y":31154.23747069523},"targetPosition":{"x":17987.64382962515,"y":31073.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":1,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"id":"16ae95ce-796f-4f2b-942c-f98dcbf9cf4b","savedPayload":{"position":{"x":17417.36130869076,"y":30929.77112949147},"targetPosition":{"x":18473.301618063546,"y":31499.850126685462},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":true,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}},{"type":"Crypto Exchange","name":"LBank","config":"{ \n\"codeName\": \"lbank\"\n}","project":"Superalgos","exchangeAssets":{"type":"Exchange Assets","name":"New Exchange Assets","config":"{ \n\"addMissingAssetsFilter\": { \"quotedAsset\": \"USDT\"} \n}","project":"Superalgos","assets":[],"id":"def3f9d0-f09e-4e09-8b6d-a4c322a4384b","savedPayload":{"position":{"x":17877.64382962515,"y":31024.23747069523},"targetPosition":{"x":17838.64382962515,"y":31032.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":2,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"exchangeMarkets":{"type":"Exchange Markets","name":"New Exchange Markets","project":"Superalgos","markets":[],"id":"53eac3c1-96d6-4cb1-b54d-f3f174eaf733","savedPayload":{"position":{"x":17764.64382962515,"y":31036.23747069523},"targetPosition":{"x":17838.64382962515,"y":31032.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"exchangeAccounts":{"type":"Exchange Accounts","name":"New Exchange Accounts","project":"Superalgos","userAccounts":[{"type":"User Account","name":"New User Account","project":"Superalgos","userAssets":{"type":"User Assets","name":"New User Assets","project":"Superalgos","assets":[],"id":"c6c00704-1357-4426-910e-8134d6f87017","savedPayload":{"position":{"x":18030.64382962515,"y":31212.23747069523},"targetPosition":{"x":17951.64382962515,"y":31172.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"userKeys":{"type":"User Keys","name":"New User Keys","project":"Superalgos","keys":[{"type":"Exchange Account Key","name":"New Exchange Account Key","config":"{ \n\"codeName\": \"Paste your exchange API name or label\",\n\"secret\": \"Paste your exchange API secret key\"\n}","project":"Superalgos","id":"13990604-2192-4be1-b21b-53cf2bafc002","savedPayload":{"position":{"x":17893.64382962515,"y":31189.23747069523},"targetPosition":{"x":17964.64382962515,"y":31122.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{}}}],"id":"ed2c483e-d412-406d-b6f3-cfb1112a3a05","savedPayload":{"position":{"x":17964.64382962515,"y":31122.23747069523},"targetPosition":{"x":17951.64382962515,"y":31172.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"id":"6033b63c-c7fe-4a5d-8cf6-82128e2cfb41","savedPayload":{"position":{"x":17951.64382962515,"y":31172.23747069523},"targetPosition":{"x":17891.64382962515,"y":31096.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}}],"id":"20ece5c4-dbfa-4f4a-a9ee-8c8d9c38943b","savedPayload":{"position":{"x":17891.64382962515,"y":31096.23747069523},"targetPosition":{"x":17838.64382962515,"y":31032.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":1,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"id":"cb2558d6-dab0-4f35-b83f-7cfc161b3d4f","savedPayload":{"position":{"x":17489.228315722517,"y":30813.11893064175},"targetPosition":{"x":18473.301618063546,"y":31499.850126685462},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":true,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}},{"type":"Crypto Exchange","name":"Mercado Bitcoin","config":"{ \n\"codeName\": \"mercado\"\n}","project":"Superalgos","exchangeAssets":{"type":"Exchange Assets","name":"New Exchange Assets","config":"{ \n\"addMissingAssetsFilter\": { \"quotedAsset\": \"USDT\"} \n}","project":"Superalgos","assets":[],"id":"83ab2c39-e844-496f-bebb-7b8607428902","savedPayload":{"position":{"x":17849.64382962515,"y":31081.23747069523},"targetPosition":{"x":17849.64382962515,"y":30986.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":2,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"exchangeMarkets":{"type":"Exchange Markets","name":"New Exchange Markets","project":"Superalgos","markets":[],"id":"d69e722e-c71a-462a-8bbd-d3482d0eab21","savedPayload":{"position":{"x":17771.64382962515,"y":30887.23747069523},"targetPosition":{"x":17849.64382962515,"y":30986.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"exchangeAccounts":{"type":"Exchange Accounts","name":"New Exchange Accounts","project":"Superalgos","userAccounts":[{"type":"User Account","name":"New User Account","project":"Superalgos","userAssets":{"type":"User Assets","name":"New User Assets","project":"Superalgos","assets":[],"id":"18438709-83cf-49a3-96b8-888ab5adbcc5","savedPayload":{"position":{"x":17937.64382962515,"y":31080.23747069523},"targetPosition":{"x":17866.64382962515,"y":31013.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"userKeys":{"type":"User Keys","name":"New User Keys","project":"Superalgos","keys":[{"type":"Exchange Account Key","name":"New Exchange Account Key","config":"{ \n\"codeName\": \"Paste your exchange API name or label\",\n\"secret\": \"Paste your exchange API secret key\"\n}","project":"Superalgos","id":"6b9d4ed4-af81-462a-aace-fac0afd4687a","savedPayload":{"position":{"x":17787.64382962515,"y":30841.23747069523},"targetPosition":{"x":17873.64382962515,"y":30935.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{}}}],"id":"802a4c53-8617-4257-95a5-45bfaa60ad0e","savedPayload":{"position":{"x":17873.64382962515,"y":30935.23747069523},"targetPosition":{"x":17866.64382962515,"y":31013.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"id":"87936a4a-aac5-4aca-8f3e-2051611932c4","savedPayload":{"position":{"x":17866.64382962515,"y":31013.23747069523},"targetPosition":{"x":17829.64382962515,"y":30919.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}}],"id":"48f3a793-bb97-447b-8f1a-1d6965219747","savedPayload":{"position":{"x":17829.64382962515,"y":30919.23747069523},"targetPosition":{"x":17849.64382962515,"y":30986.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":1,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"id":"5002072e-145c-4aeb-a611-3e0e4c60ee5d","savedPayload":{"position":{"x":17573.92422319644,"y":30705.41932315248},"targetPosition":{"x":18473.301618063546,"y":31499.850126685462},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":true,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}},{"type":"Crypto Exchange","name":"OKCoin","config":"{ \n\"codeName\": \"okcoin\"\n}","project":"Superalgos","exchangeAssets":{"type":"Exchange Assets","name":"New Exchange Assets","config":"{ \n\"addMissingAssetsFilter\": { \"quotedAsset\": \"USDT\"} \n}","project":"Superalgos","assets":[],"id":"1e4dd5c8-0545-4698-8695-c985880243a3","savedPayload":{"position":{"x":17921.64382962515,"y":31043.23747069523},"targetPosition":{"x":17967.64382962515,"y":30969.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":2,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"exchangeMarkets":{"type":"Exchange Markets","name":"New Exchange Markets","project":"Superalgos","markets":[],"id":"0e188cae-9764-4963-a78b-e5d7ef272522","savedPayload":{"position":{"x":18005.64382962515,"y":30891.23747069523},"targetPosition":{"x":17967.64382962515,"y":30969.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"exchangeAccounts":{"type":"Exchange Accounts","name":"New Exchange Accounts","project":"Superalgos","userAccounts":[{"type":"User Account","name":"New User Account","project":"Superalgos","userAssets":{"type":"User Assets","name":"New User Assets","project":"Superalgos","assets":[],"id":"6d82bfd7-b4e1-4f93-a0f8-18f62cee944e","savedPayload":{"position":{"x":18047.64382962515,"y":30877.23747069523},"targetPosition":{"x":17963.64382962515,"y":30898.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"userKeys":{"type":"User Keys","name":"New User Keys","project":"Superalgos","keys":[{"type":"Exchange Account Key","name":"New Exchange Account Key","config":"{ \n\"codeName\": \"Paste your exchange API name or label\",\n\"secret\": \"Paste your exchange API secret key\"\n}","project":"Superalgos","id":"d815409c-1dd4-4e89-b844-5b96104509b4","savedPayload":{"position":{"x":17958.64382962515,"y":30988.23747069523},"targetPosition":{"x":17945.64382962515,"y":30961.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{}}}],"id":"238b9d2c-e2c0-4a77-945e-8e28604c0a2d","savedPayload":{"position":{"x":17945.64382962515,"y":30961.23747069523},"targetPosition":{"x":17963.64382962515,"y":30898.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"id":"8416c29a-5d73-4b2a-9463-511f400deafb","savedPayload":{"position":{"x":17963.64382962515,"y":30898.23747069523},"targetPosition":{"x":18047.64382962515,"y":30885.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}}],"id":"04abf32b-084e-4784-aa84-8c5612d3b7b9","savedPayload":{"position":{"x":18047.64382962515,"y":30885.23747069523},"targetPosition":{"x":17967.64382962515,"y":30969.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":1,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"id":"1f860b4b-2893-4a51-8649-19c47d494a37","savedPayload":{"position":{"x":17670.344890432916,"y":30608.07633611259},"targetPosition":{"x":18473.301618063546,"y":31499.850126685462},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":true,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}},{"type":"Crypto Exchange","name":"OKEX","config":"{ \n\"codeName\": \"okex\"\n}","project":"Superalgos","exchangeAssets":{"type":"Exchange Assets","name":"New Exchange Assets","config":"{ \n\"addMissingAssetsFilter\": { \"quotedAsset\": \"USDT\"} \n}","project":"Superalgos","assets":[],"id":"7f618566-3d10-4c3c-90b2-7541a5146eeb","savedPayload":{"position":{"x":17770.64382962515,"y":31094.23747069523},"targetPosition":{"x":17847.64382962515,"y":31102.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":2,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"exchangeMarkets":{"type":"Exchange Markets","name":"New Exchange Markets","project":"Superalgos","markets":[],"id":"21205576-5d12-452c-814f-eb56182162ae","savedPayload":{"position":{"x":17794.64382962515,"y":31173.23747069523},"targetPosition":{"x":17847.64382962515,"y":31102.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"exchangeAccounts":{"type":"Exchange Accounts","name":"New Exchange Accounts","project":"Superalgos","userAccounts":[{"type":"User Account","name":"New User Account","project":"Superalgos","userAssets":{"type":"User Assets","name":"New User Assets","project":"Superalgos","assets":[],"id":"46456247-ae9c-41ea-8395-a5e4a78007d4","savedPayload":{"position":{"x":17724.64382962515,"y":31147.23747069523},"targetPosition":{"x":17795.64382962515,"y":31083.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"userKeys":{"type":"User Keys","name":"New User Keys","project":"Superalgos","keys":[{"type":"Exchange Account Key","name":"New Exchange Account Key","config":"{ \n\"codeName\": \"Paste your exchange API name or label\",\n\"secret\": \"Paste your exchange API secret key\"\n}","project":"Superalgos","id":"706bf601-eaad-48bd-b0a7-8dad59066171","savedPayload":{"position":{"x":17715.64382962515,"y":31182.23747069523},"targetPosition":{"x":17706.64382962515,"y":31162.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{}}}],"id":"f9c7071c-2e5b-4c90-b482-dfc7ee001244","savedPayload":{"position":{"x":17706.64382962515,"y":31162.23747069523},"targetPosition":{"x":17795.64382962515,"y":31083.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"id":"e87e1e10-3404-48b9-8629-5df92ffa1979","savedPayload":{"position":{"x":17795.64382962515,"y":31083.23747069523},"targetPosition":{"x":17789.64382962515,"y":31181.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}}],"id":"08e8fd6a-6b23-4d65-8b8e-d966f845c07f","savedPayload":{"position":{"x":17789.64382962515,"y":31181.23747069523},"targetPosition":{"x":17847.64382962515,"y":31102.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":1,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"id":"aa0edec0-8b27-4f94-abce-1e437ce5aba6","savedPayload":{"position":{"x":17777.233326578105,"y":30522.35898422506},"targetPosition":{"x":18473.301618063546,"y":31499.850126685462},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":true,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}},{"type":"Crypto Exchange","name":"RightBTC","config":"{ \n\"codeName\": \"rightbtc\"\n}","project":"Superalgos","exchangeAssets":{"type":"Exchange Assets","name":"New Exchange Assets","config":"{ \n\"addMissingAssetsFilter\": { \"quotedAsset\": \"USDT\"} \n}","project":"Superalgos","assets":[],"id":"ade372e9-5070-4fa9-843e-57732c4106c3","savedPayload":{"position":{"x":17999.64382962515,"y":30964.23747069523},"targetPosition":{"x":17991.64382962515,"y":30935.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":2,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"exchangeMarkets":{"type":"Exchange Markets","name":"New Exchange Markets","project":"Superalgos","markets":[],"id":"b63d440e-4501-475c-b8a6-2b9a144e32a1","savedPayload":{"position":{"x":17984.64382962515,"y":30901.23747069523},"targetPosition":{"x":17991.64382962515,"y":30935.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"exchangeAccounts":{"type":"Exchange Accounts","name":"New Exchange Accounts","project":"Superalgos","userAccounts":[{"type":"User Account","name":"New User Account","project":"Superalgos","userAssets":{"type":"User Assets","name":"New User Assets","project":"Superalgos","assets":[],"id":"81d77477-4f2e-43c0-b284-dde54f91c37f","savedPayload":{"position":{"x":17864.64382962515,"y":31036.23747069523},"targetPosition":{"x":17861.64382962515,"y":31043.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"userKeys":{"type":"User Keys","name":"New User Keys","project":"Superalgos","keys":[{"type":"Exchange Account Key","name":"New Exchange Account Key","config":"{ \n\"codeName\": \"Paste your exchange API name or label\",\n\"secret\": \"Paste your exchange API secret key\"\n}","project":"Superalgos","id":"9ce3cc34-1ba4-4155-96a5-c946b1bcc5ab","savedPayload":{"position":{"x":17819.64382962515,"y":31127.23747069523},"targetPosition":{"x":17810.64382962515,"y":31080.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{}}}],"id":"c7df4af7-37c1-403d-ada1-b6a527821bdd","savedPayload":{"position":{"x":17810.64382962515,"y":31080.23747069523},"targetPosition":{"x":17861.64382962515,"y":31043.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"id":"6de19501-5ce7-4944-b9dd-25b149acbb38","savedPayload":{"position":{"x":17861.64382962515,"y":31043.23747069523},"targetPosition":{"x":17946.64382962515,"y":30988.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}}],"id":"aa87ace4-a976-401c-93f9-24a498261742","savedPayload":{"position":{"x":17946.64382962515,"y":30988.23747069523},"targetPosition":{"x":17991.64382962515,"y":30935.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":1,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"id":"c20cd9e1-52a0-4d17-b90c-e9d5b63315ce","savedPayload":{"position":{"x":17893.19607740207,"y":30449.38472425954},"targetPosition":{"x":18473.301618063546,"y":31499.850126685462},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":true,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}},{"type":"Crypto Exchange","name":"STEX","config":"{ \n\"codeName\": \"stex\"\n}","project":"Superalgos","exchangeAssets":{"type":"Exchange Assets","name":"New Exchange Assets","config":"{ \n\"addMissingAssetsFilter\": { \"quotedAsset\": \"USDT\"} \n}","project":"Superalgos","assets":[],"id":"f1d65161-4922-4a1e-ac98-df1a842347a7","savedPayload":{"position":{"x":17872.64382962515,"y":31001.23747069523},"targetPosition":{"x":17892.64382962515,"y":31092.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":2,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"exchangeMarkets":{"type":"Exchange Markets","name":"New Exchange Markets","project":"Superalgos","markets":[],"id":"c313b2c6-6154-4a9a-b826-fd99cc500cd9","savedPayload":{"position":{"x":17888.64382962515,"y":31186.23747069523},"targetPosition":{"x":17892.64382962515,"y":31092.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"exchangeAccounts":{"type":"Exchange Accounts","name":"New Exchange Accounts","project":"Superalgos","userAccounts":[{"type":"User Account","name":"New User Account","project":"Superalgos","userAssets":{"type":"User Assets","name":"New User Assets","project":"Superalgos","assets":[],"id":"d0a1259b-1c37-4d39-836e-3c434c3b3687","savedPayload":{"position":{"x":17778.64382962515,"y":31076.23747069523},"targetPosition":{"x":17858.64382962515,"y":31091.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"userKeys":{"type":"User Keys","name":"New User Keys","project":"Superalgos","keys":[{"type":"Exchange Account Key","name":"New Exchange Account Key","config":"{ \n\"codeName\": \"Paste your exchange API name or label\",\n\"secret\": \"Paste your exchange API secret key\"\n}","project":"Superalgos","id":"4a1e5627-459c-4dec-be13-c20d4a9ea58f","savedPayload":{"position":{"x":17841.64382962515,"y":31179.23747069523},"targetPosition":{"x":17795.64382962515,"y":31105.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{}}}],"id":"6981eb0d-0f0e-4f8e-9781-4a03e22e93fd","savedPayload":{"position":{"x":17795.64382962515,"y":31105.23747069523},"targetPosition":{"x":17858.64382962515,"y":31091.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"id":"7704478a-9717-43a8-bd2e-88daa6f84bd0","savedPayload":{"position":{"x":17858.64382962515,"y":31091.23747069523},"targetPosition":{"x":17941.64382962515,"y":31173.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}}],"id":"262aad86-f430-49ea-a636-e8bd816a9636","savedPayload":{"position":{"x":17941.64382962515,"y":31173.23747069523},"targetPosition":{"x":17892.64382962515,"y":31092.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":1,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"id":"0ea23137-3c65-4de1-9772-6ac1b65196e8","savedPayload":{"position":{"x":18016.72139110564,"y":30390.104887294427},"targetPosition":{"x":18473.301618063546,"y":31499.850126685462},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":true,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}},{"type":"Crypto Exchange","name":"TideBit","config":"{ \n\"codeName\": \"tidebit\"\n}","project":"Superalgos","exchangeAssets":{"type":"Exchange Assets","name":"New Exchange Assets","config":"{ \n\"addMissingAssetsFilter\": { \"quotedAsset\": \"USDT\"} \n}","project":"Superalgos","assets":[],"id":"c92318bd-8b2d-489b-b8e8-cf30fb63286e","savedPayload":{"position":{"x":17981.64382962515,"y":31021.23747069523},"targetPosition":{"x":17978.64382962515,"y":31048.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":2,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"exchangeMarkets":{"type":"Exchange Markets","name":"New Exchange Markets","project":"Superalgos","markets":[],"id":"83bca3ec-fc1c-435c-b5fe-b1cf92463fd1","savedPayload":{"position":{"x":18051.64382962515,"y":31072.23747069523},"targetPosition":{"x":17978.64382962515,"y":31048.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"exchangeAccounts":{"type":"Exchange Accounts","name":"New Exchange Accounts","project":"Superalgos","userAccounts":[{"type":"User Account","name":"New User Account","project":"Superalgos","userAssets":{"type":"User Assets","name":"New User Assets","project":"Superalgos","assets":[],"id":"2f3ee9b2-cd41-458c-84da-edac3155028a","savedPayload":{"position":{"x":18075.64382962515,"y":31059.23747069523},"targetPosition":{"x":17987.64382962515,"y":31047.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"userKeys":{"type":"User Keys","name":"New User Keys","project":"Superalgos","keys":[{"type":"Exchange Account Key","name":"New Exchange Account Key","config":"{ \n\"codeName\": \"Paste your exchange API name or label\",\n\"secret\": \"Paste your exchange API secret key\"\n}","project":"Superalgos","id":"009ae4b6-adbc-4900-9fc0-f18936eeed9b","savedPayload":{"position":{"x":18030.64382962515,"y":31058.23747069523},"targetPosition":{"x":18009.64382962515,"y":31028.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{}}}],"id":"3ee88180-fe10-41df-8251-b1ed0a526e7a","savedPayload":{"position":{"x":18009.64382962515,"y":31028.23747069523},"targetPosition":{"x":17987.64382962515,"y":31047.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"id":"bb88e6e8-a99a-4c4e-9ca5-ffed49aa8b54","savedPayload":{"position":{"x":17987.64382962515,"y":31047.23747069523},"targetPosition":{"x":17925.64382962515,"y":31135.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}}],"id":"13a4a95e-4333-4455-9f7c-90bc839d174a","savedPayload":{"position":{"x":17925.64382962515,"y":31135.23747069523},"targetPosition":{"x":17978.64382962515,"y":31048.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":1,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"id":"5563c310-701a-4c1e-8155-87c08c927ce3","savedPayload":{"position":{"x":18146.19892631707,"y":30345.29227666139},"targetPosition":{"x":18473.301618063546,"y":31499.850126685462},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":true,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}},{"type":"Crypto Exchange","name":"TimeX","config":"{ \n\"codeName\": \"timex\"\n}","project":"Superalgos","exchangeAssets":{"type":"Exchange Assets","name":"New Exchange Assets","config":"{ \n\"addMissingAssetsFilter\": { \"quotedAsset\": \"USDT\"} \n}","project":"Superalgos","assets":[],"id":"5c004b5f-eec4-414f-8d01-d9b3fddeee9e","savedPayload":{"position":{"x":17892.64382962515,"y":30973.23747069523},"targetPosition":{"x":17949.64382962515,"y":30914.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":2,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"exchangeMarkets":{"type":"Exchange Markets","name":"New Exchange Markets","project":"Superalgos","markets":[],"id":"59a33add-d0e9-4ae1-8a01-f1e0ed09cb61","savedPayload":{"position":{"x":17911.64382962515,"y":30878.23747069523},"targetPosition":{"x":17949.64382962515,"y":30914.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"exchangeAccounts":{"type":"Exchange Accounts","name":"New Exchange Accounts","project":"Superalgos","userAccounts":[{"type":"User Account","name":"New User Account","project":"Superalgos","userAssets":{"type":"User Assets","name":"New User Assets","project":"Superalgos","assets":[],"id":"a4189ba1-d1d4-4ff8-91dd-a8696ca493e3","savedPayload":{"position":{"x":17953.64382962515,"y":30880.23747069523},"targetPosition":{"x":17924.64382962515,"y":30871.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"userKeys":{"type":"User Keys","name":"New User Keys","project":"Superalgos","keys":[{"type":"Exchange Account Key","name":"New Exchange Account Key","config":"{ \n\"codeName\": \"Paste your exchange API name or label\",\n\"secret\": \"Paste your exchange API secret key\"\n}","project":"Superalgos","id":"3d34eb9d-e7cb-42fe-8785-c327b2bbc529","savedPayload":{"position":{"x":17839.64382962515,"y":30875.23747069523},"targetPosition":{"x":17930.64382962515,"y":30877.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{}}}],"id":"773de01f-0999-4a59-91f0-642148cd58d0","savedPayload":{"position":{"x":17930.64382962515,"y":30877.23747069523},"targetPosition":{"x":17924.64382962515,"y":30871.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"id":"fe33a596-4f98-4843-a5b1-26e7e0fcf1c8","savedPayload":{"position":{"x":17924.64382962515,"y":30871.23747069523},"targetPosition":{"x":18018.64382962515,"y":30832.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}}],"id":"d078b9a3-cdc6-458e-a511-dc4f5bef38ba","savedPayload":{"position":{"x":18018.64382962515,"y":30832.23747069523},"targetPosition":{"x":17949.64382962515,"y":30914.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":1,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"id":"27d69fa7-b561-4986-8c0d-1b374e7e1bf1","savedPayload":{"position":{"x":18279.94074535451,"y":30315.531093272082},"targetPosition":{"x":18473.301618063546,"y":31499.850126685462},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":true,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}},{"type":"Crypto Exchange","name":"TOP.Q","config":"{ \n\"codeName\": \"topq\"\n}","project":"Superalgos","exchangeAssets":{"type":"Exchange Assets","name":"New Exchange Assets","config":"{ \n\"addMissingAssetsFilter\": { \"quotedAsset\": \"USDT\"} \n}","project":"Superalgos","assets":[],"id":"eafef6a3-eed2-470e-a15c-aa4c10001cd2","savedPayload":{"position":{"x":17818.64382962515,"y":31115.23747069523},"targetPosition":{"x":17847.64382962515,"y":31105.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":2,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"exchangeMarkets":{"type":"Exchange Markets","name":"New Exchange Markets","project":"Superalgos","markets":[],"id":"2d5eb813-ceb6-40cd-8682-7205596bb8b5","savedPayload":{"position":{"x":17759.64382962515,"y":31188.23747069523},"targetPosition":{"x":17847.64382962515,"y":31105.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"exchangeAccounts":{"type":"Exchange Accounts","name":"New Exchange Accounts","project":"Superalgos","userAccounts":[{"type":"User Account","name":"New User Account","project":"Superalgos","userAssets":{"type":"User Assets","name":"New User Assets","project":"Superalgos","assets":[],"id":"61f7832c-c1f0-40bc-b1f2-ba947c58309d","savedPayload":{"position":{"x":17741.64382962515,"y":31288.23747069523},"targetPosition":{"x":17788.64382962515,"y":31228.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"userKeys":{"type":"User Keys","name":"New User Keys","project":"Superalgos","keys":[{"type":"Exchange Account Key","name":"New Exchange Account Key","config":"{ \n\"codeName\": \"Paste your exchange API name or label\",\n\"secret\": \"Paste your exchange API secret key\"\n}","project":"Superalgos","id":"63b973da-30a7-467a-b954-c57537aab18d","savedPayload":{"position":{"x":17677.64382962515,"y":31206.23747069523},"targetPosition":{"x":17756.64382962515,"y":31146.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{}}}],"id":"722dcf44-de3f-4d1a-8655-80561e1e4d55","savedPayload":{"position":{"x":17756.64382962515,"y":31146.23747069523},"targetPosition":{"x":17788.64382962515,"y":31228.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"id":"45d5e04a-4a53-4f32-b4c0-d882456cb263","savedPayload":{"position":{"x":17788.64382962515,"y":31228.23747069523},"targetPosition":{"x":17806.64382962515,"y":31163.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}}],"id":"c66e8dfc-4847-4180-b82c-36458f9b405d","savedPayload":{"position":{"x":17806.64382962515,"y":31163.23747069523},"targetPosition":{"x":17847.64382962515,"y":31105.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":1,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"id":"8fdf13d8-e8d2-4ef4-8b34-f492a25d753a","savedPayload":{"position":{"x":18416.203319075055,"y":30301.209319665853},"targetPosition":{"x":18473.301618063546,"y":31499.850126685462},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":true,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}},{"type":"Crypto Exchange","name":"Upbit","config":"{ \n\"codeName\": \"upbit\"\n}","project":"Superalgos","exchangeAssets":{"type":"Exchange Assets","name":"New Exchange Assets","config":"{ \n\"addMissingAssetsFilter\": { \"quotedAsset\": \"USDT\"} \n}","project":"Superalgos","assets":[],"id":"f456fec2-cee6-4f0c-b865-1188088879c9","savedPayload":{"position":{"x":17919.64382962515,"y":30973.23747069523},"targetPosition":{"x":17991.64382962515,"y":30980.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":2,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"exchangeMarkets":{"type":"Exchange Markets","name":"New Exchange Markets","project":"Superalgos","markets":[],"id":"947c1ca0-bff9-4372-b153-40054e29b705","savedPayload":{"position":{"x":17921.64382962515,"y":31014.23747069523},"targetPosition":{"x":17991.64382962515,"y":30980.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"exchangeAccounts":{"type":"Exchange Accounts","name":"New Exchange Accounts","project":"Superalgos","userAccounts":[{"type":"User Account","name":"New User Account","project":"Superalgos","userAssets":{"type":"User Assets","name":"New User Assets","project":"Superalgos","assets":[],"id":"34ffbe12-5a26-446a-8bf6-7395c0370ba2","savedPayload":{"position":{"x":17874.64382962515,"y":30900.23747069523},"targetPosition":{"x":17945.64382962515,"y":30971.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"userKeys":{"type":"User Keys","name":"New User Keys","project":"Superalgos","keys":[{"type":"Exchange Account Key","name":"New Exchange Account Key","config":"{ \n\"codeName\": \"Paste your exchange API name or label\",\n\"secret\": \"Paste your exchange API secret key\"\n}","project":"Superalgos","id":"8f00f19d-74a8-48d8-b951-79f35e87b110","savedPayload":{"position":{"x":17906.64382962515,"y":30902.23747069523},"targetPosition":{"x":17896.64382962515,"y":30896.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{}}}],"id":"64e1bede-aabf-4831-83a6-fe1cea435613","savedPayload":{"position":{"x":17896.64382962515,"y":30896.23747069523},"targetPosition":{"x":17945.64382962515,"y":30971.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"id":"7c80b956-f2ca-4a6f-a661-f17546288d3e","savedPayload":{"position":{"x":17945.64382962515,"y":30971.23747069523},"targetPosition":{"x":18027.64382962515,"y":31048.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}}],"id":"e3686b02-4ecc-4dcb-a311-b7ef542a3c37","savedPayload":{"position":{"x":18027.64382962515,"y":31048.23747069523},"targetPosition":{"x":17991.64382962515,"y":30980.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":1,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"id":"74e57ecd-3394-42b4-b2c4-6f216f7e41db","savedPayload":{"position":{"x":18553.210256443508,"y":30302.513662063982},"targetPosition":{"x":18473.301618063546,"y":31499.850126685462},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":true,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}},{"type":"Crypto Exchange","name":"WhiteBit","config":"{ \n\"codeName\": \"whitebit\"\n}","project":"Superalgos","exchangeAssets":{"type":"Exchange Assets","name":"New Exchange Assets","config":"{ \n\"addMissingAssetsFilter\": { \"quotedAsset\": \"USDT\"} \n}","project":"Superalgos","assets":[],"id":"c16eae45-a568-4b2e-b064-4431bdf34c24","savedPayload":{"position":{"x":17767.64382962515,"y":30899.23747069523},"targetPosition":{"x":17834.64382962515,"y":30950.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":2,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"exchangeMarkets":{"type":"Exchange Markets","name":"New Exchange Markets","project":"Superalgos","markets":[],"id":"dfdf793f-4ba6-4215-a325-323c0f223553","savedPayload":{"position":{"x":17920.64382962515,"y":31004.23747069523},"targetPosition":{"x":17834.64382962515,"y":30950.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"exchangeAccounts":{"type":"Exchange Accounts","name":"New Exchange Accounts","project":"Superalgos","userAccounts":[{"type":"User Account","name":"New User Account","project":"Superalgos","userAssets":{"type":"User Assets","name":"New User Assets","project":"Superalgos","assets":[],"id":"fd749d13-dbac-493f-9af6-c521eddf909f","savedPayload":{"position":{"x":17815.64382962515,"y":30973.23747069523},"targetPosition":{"x":17720.64382962515,"y":31056.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"userKeys":{"type":"User Keys","name":"New User Keys","project":"Superalgos","keys":[{"type":"Exchange Account Key","name":"New Exchange Account Key","config":"{ \n\"codeName\": \"Paste your exchange API name or label\",\n\"secret\": \"Paste your exchange API secret key\"\n}","project":"Superalgos","id":"79f7d2d0-77a5-4f38-ac68-fd11f18e5e6b","savedPayload":{"position":{"x":17761.64382962515,"y":31182.23747069523},"targetPosition":{"x":17680.64382962515,"y":31153.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{}}}],"id":"fd0506f4-58b7-431e-bc9d-69bce63c3379","savedPayload":{"position":{"x":17680.64382962515,"y":31153.23747069523},"targetPosition":{"x":17720.64382962515,"y":31056.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"id":"47e8a4b1-9a6c-4555-a881-f7524183d72e","savedPayload":{"position":{"x":17720.64382962515,"y":31056.23747069523},"targetPosition":{"x":17817.64382962515,"y":31010.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}}],"id":"7fa08b91-55ab-477d-a097-88ea7f25fb76","savedPayload":{"position":{"x":17817.64382962515,"y":31010.23747069523},"targetPosition":{"x":17834.64382962515,"y":30950.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":1,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"id":"467ece1e-d1d0-4a11-ae7a-d0e22cd4eba5","savedPayload":{"position":{"x":18689.17546250617,"y":30319.427116368584},"targetPosition":{"x":18473.301618063546,"y":31499.850126685462},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":true,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}},{"type":"Crypto Exchange","name":"ZB","config":"{ \n\"codeName\": \"zb\"\n}","project":"Superalgos","exchangeAssets":{"type":"Exchange Assets","name":"New Exchange Assets","config":"{ \n\"addMissingAssetsFilter\": { \"quotedAsset\": \"USDT\"} \n}","project":"Superalgos","assets":[],"id":"db206cbd-a587-4e8e-acbe-6581ad3b5cc4","savedPayload":{"position":{"x":17855.64382962515,"y":31027.23747069523},"targetPosition":{"x":17861.64382962515,"y":30951.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":2,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"exchangeMarkets":{"type":"Exchange Markets","name":"New Exchange Markets","project":"Superalgos","markets":[],"id":"1dd658c5-7755-44b7-85f0-9bcd787762a0","savedPayload":{"position":{"x":17789.64382962515,"y":31044.23747069523},"targetPosition":{"x":17861.64382962515,"y":30951.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"exchangeAccounts":{"type":"Exchange Accounts","name":"New Exchange Accounts","project":"Superalgos","userAccounts":[{"type":"User Account","name":"New User Account","project":"Superalgos","userAssets":{"type":"User Assets","name":"New User Assets","project":"Superalgos","assets":[],"id":"0de82bbe-7909-4b65-b304-f59b41f618ae","savedPayload":{"position":{"x":17830.64382962515,"y":30696.23747069523},"targetPosition":{"x":17846.64382962515,"y":30793.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"userKeys":{"type":"User Keys","name":"New User Keys","project":"Superalgos","keys":[{"type":"Exchange Account Key","name":"New Exchange Account Key","config":"{ \n\"codeName\": \"Paste your exchange API name or label\",\n\"secret\": \"Paste your exchange API secret key\"\n}","project":"Superalgos","id":"c89819d0-8880-4b36-a9b3-0b284d266e3b","savedPayload":{"position":{"x":17891.64382962515,"y":30748.23747069523},"targetPosition":{"x":17865.64382962515,"y":30772.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{}}}],"id":"7a55f503-17fa-45c4-880b-1a9a11a0a555","savedPayload":{"position":{"x":17865.64382962515,"y":30772.23747069523},"targetPosition":{"x":17846.64382962515,"y":30793.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"id":"e640fca2-8bab-45ff-9a47-8e7b9650c277","savedPayload":{"position":{"x":17846.64382962515,"y":30793.23747069523},"targetPosition":{"x":17909.64382962515,"y":30886.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}}],"id":"421a99cd-3d9a-46a5-8654-08d6336e75be","savedPayload":{"position":{"x":17909.64382962515,"y":30886.23747069523},"targetPosition":{"x":17861.64382962515,"y":30951.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":1,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"id":"07df07e8-39a8-4fbc-a0c8-150f20b6ac59","savedPayload":{"position":{"x":18822.32642287003,"y":30351.729189836995},"targetPosition":{"x":18473.301618063546,"y":31499.850126685462},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":true,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}},{"type":"Crypto Exchange","name":"Coinbase Pro","config":"{ \n\"codeName\": \"coinbasepro\"\n}","project":"Superalgos","exchangeAssets":{"type":"Exchange Assets","name":"New Exchange Assets","config":"{ \n\"addMissingAssetsFilter\": { \"quotedAsset\": \"USDT\"} \n}","project":"Superalgos","assets":[],"id":"5e970185-b876-4d70-af88-e4944e992801","savedPayload":{"position":{"x":18389.301618063546,"y":31417.850126685462},"targetPosition":{"x":18398.301618063546,"y":31478.850126685462},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":2,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"exchangeMarkets":{"type":"Exchange Markets","name":"New Exchange Markets","project":"Superalgos","markets":[],"id":"f84cdb3e-86c4-4b6c-bba4-678d71440ee0","savedPayload":{"position":{"x":18327.301618063546,"y":31445.850126685462},"targetPosition":{"x":18398.301618063546,"y":31478.850126685462},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"exchangeAccounts":{"type":"Exchange Accounts","name":"New Exchange Accounts","project":"Superalgos","userAccounts":[{"type":"User Account","name":"New User Account","project":"Superalgos","userAssets":{"type":"User Assets","name":"New User Assets","project":"Superalgos","assets":[],"id":"3975e43a-780e-4e9e-88b3-8dc946efab78","savedPayload":{"position":{"x":18372.301618063546,"y":31423.850126685462},"targetPosition":{"x":18428.301618063546,"y":31462.850126685462},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"userKeys":{"type":"User Keys","name":"New User Keys","project":"Superalgos","keys":[{"type":"Exchange Account Key","name":"New Exchange Account Key","config":"{ \n\"codeName\": \"Paste your exchange API name or label\",\n\"secret\": \"Paste your exchange API secret key\"\n}","project":"Superalgos","id":"17e78895-a58f-4bf3-b484-07871243adcc","savedPayload":{"position":{"x":18612.301618063546,"y":31592.850126685462},"targetPosition":{"x":18523.301618063546,"y":31550.850126685462},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{}}}],"id":"71cd3cd3-7d6f-4a77-b383-cf4d14c90ac7","savedPayload":{"position":{"x":18523.301618063546,"y":31550.850126685462},"targetPosition":{"x":18428.301618063546,"y":31462.850126685462},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"id":"7d6893e0-8262-4bfe-97c6-54cf7f1d1559","savedPayload":{"position":{"x":18428.301618063546,"y":31462.850126685462},"targetPosition":{"x":18348.301618063546,"y":31529.850126685462},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}}],"id":"68dc9fd9-7d27-4102-821c-91d69fe98858","savedPayload":{"position":{"x":18348.301618063546,"y":31529.850126685462},"targetPosition":{"x":18398.301618063546,"y":31478.850126685462},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":1,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"id":"23ec7356-eed9-4a26-ace4-f21ae0d1e43e","savedPayload":{"position":{"x":18950.92731113858,"y":30398.998775541906},"targetPosition":{"x":18473.301618063546,"y":31499.850126685462},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":true,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}}],"id":"51f64e29-e3ab-4683-a5de-f397fbf94260","savedPayload":{"position":{"x":18473.301618063546,"y":31499.850126685462},"targetPosition":{"x":18773.301618063546,"y":30980.2348844148},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":true,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}},{"type":"Crypto Exchanges","name":"Testing Queue","project":"Superalgos","exchanges":[],"id":"895ce4b1-4890-4216-89ba-a012181d2546","savedPayload":{"position":{"x":18623.301618063546,"y":30720.427263279467},"targetPosition":{"x":18773.301618063546,"y":30980.2348844148},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false}}}],"signalsProviders":[],"id":"7217b56c-e854-4c06-8b8a-d5d3c05a153d","savedPayload":{"position":{"x":18773.301618063546,"y":30980.2348844148},"targetPosition":{"x":18773.301618063546,"y":30980.2348844148},"floatingObject":{"isPinned":true,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false,"shortcutKey":""}}},{"type":"Charting Space","name":"New Charting Space","project":"Superalgos","viewport":{"type":"Viewport","name":"New Viewport","config":"{\"zoom\":\"5.00\"}","project":"Superalgos","id":"01713f1d-91b8-44f9-9c5d-a0c12fd09037","savedPayload":{"position":{"x":19200.806237131383,"y":24983.35640053908},"targetPosition":{"x":18900.806237131383,"y":24983.35640053908},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":3,"arrangementStyle":0},"uiObject":{},"frame":{"position":{"x":-2189.197939162836,"y":-6992.422473301482}}}},"projectDashboards":[],"id":"21d2ec55-9e56-4652-8e96-c7e451262c36","savedPayload":{"position":{"x":18900.806237131383,"y":24983.35640053908},"targetPosition":{"x":18900.806237131383,"y":24983.35640053908},"floatingObject":{"isPinned":true,"isFrozen":false,"isCollapsed":true,"angleToParent":1,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false,"shortcutKey":"c"}}},{"type":"Plugins","name":"New Plugins","project":"Superalgos","pluginProjects":[{"type":"Plugin Project","name":"Superalgos","config":"{ \n \"codeName\": \"Superalgos\"\n}","project":"Superalgos","pluginDataMines":{"type":"Plugin Data Mines","name":"New Plugin Data Mines","project":"Superalgos","pluginFiles":[{"type":"Plugin File","name":"Masters","project":"Superalgos","pluginFilePosition":{"type":"Plugin File Position","name":"Masters","project":"Superalgos","id":"d5234bd2-ef4e-4856-a6a0-ce7659653a48","savedPayload":{"position":{"x":18879.35218735615,"y":18688.55301821844},"targetPosition":{"x":31820.67692045767,"y":18678.794324352373},"floatingObject":{"isPinned":true,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"id":"ecc1a524-de9b-4e73-8874-b99a7ea0402b","savedPayload":{"position":{"x":31820.67692045767,"y":18678.794324352373},"targetPosition":{"x":31320.502678827743,"y":18678.79704693609},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false}}}],"id":"cbc3d9be-5e59-45d8-bb0f-4ec82763691d","savedPayload":{"position":{"x":31253.673182942548,"y":18372.4854210064},"targetPosition":{"x":31346.37828125503,"y":18657.802375894946},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":true,"angleToParent":1,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"pluginTradingMines":{"type":"Plugin Trading Mines","name":"New Plugin Trading Mines","project":"Superalgos","pluginFiles":[{"type":"Plugin File","name":"Masters","project":"Superalgos","pluginFilePosition":{"type":"Plugin File Position","name":"Masters","project":"Superalgos","id":"ad1ce785-858f-4cfc-ba68-108b5e0c54d9","savedPayload":{"position":{"x":24941.217404066585,"y":18714.893045797242},"targetPosition":{"x":31320.45102232534,"y":19544.930491916948},"floatingObject":{"isPinned":true,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"id":"8a64c00e-4f8c-49bf-b57d-4e2e388bae41","savedPayload":{"position":{"x":31320.45102232534,"y":19544.930491916948},"targetPosition":{"x":31070.415084976332,"y":19111.835158656926},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false}}}],"id":"8d881813-3ab9-4e8b-ab5a-48dedab2dd19","savedPayload":{"position":{"x":31589.083379567513,"y":18481.466800207203},"targetPosition":{"x":31346.37828125503,"y":18657.802375894946},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":true,"angleToParent":1,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"pluginTradingSystems":{"type":"Plugin Trading Systems","name":"New Plugin Trading Systems","project":"Superalgos","pluginFiles":[],"id":"3569d452-c593-4e54-a356-7ff8c6b519f3","savedPayload":{"position":{"x":31589.083379567513,"y":18834.13795158269},"targetPosition":{"x":31346.37828125503,"y":18657.802375894946},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"pluginTradingEngines":{"type":"Plugin Trading Engines","name":"New Plugin Trading Engines","project":"Superalgos","pluginFiles":[{"type":"Plugin File","name":"Low-Frequency","project":"Superalgos","pluginFilePosition":{"type":"Plugin File Position","name":"Low-Frequency","project":"Superalgos","id":"e117a2a4-09b3-4181-8455-e680de3bdeb3","savedPayload":{"position":{"x":30923.55093774257,"y":24967.049392142086},"targetPosition":{"x":29820.22642897682,"y":18678.80776835817},"floatingObject":{"isPinned":true,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"id":"e9270d67-4630-4ac9-91ca-1dec4fb5aa38","savedPayload":{"position":{"x":29820.22642897682,"y":18678.80776835817},"targetPosition":{"x":30320.32799443869,"y":18678.805890109317},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false}}}],"id":"87a28762-63d0-45f7-bd39-9dea436d8244","savedPayload":{"position":{"x":31253.673182942548,"y":18943.11933078349},"targetPosition":{"x":31346.37828125503,"y":18657.802375894946},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":true,"angleToParent":1,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"id":"c4e402d7-5228-408c-9d67-379d6ef40bae","savedPayload":{"position":{"x":31346.37828125503,"y":18657.802375894946},"targetPosition":{"x":31046.37828125503,"y":18657.802375894946},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false}}}],"id":"bfb0b514-3b9f-4e9a-85ca-d0ca714b09f6","savedPayload":{"position":{"x":31046.37828125503,"y":18657.802375894946},"targetPosition":{"x":31046.37828125503,"y":18657.802375894946},"floatingObject":{"isPinned":true,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false}}},{"type":"Design Space","name":"My Design Space","project":"Superalgos","spaceStyle":{"type":"Space Style","name":"My Space Style","config":" {\n \"backgroundColor\": \"UI_COLOR.BLACK\",\n \"node\": {\n \"fontSize\": 16,\n \"imageSize\": 60,\n \"type\": {\n \"fontColor\": \"UI_COLOR.WHITE\"\n },\n \"name\": {\n \"fontColor\": \"UI_COLOR.WHITE\"\n },\n \"menuItem\": {\n \"backgroundColor\": \"UI_COLOR.BLACK\",\n \"fontColor\": \"UI_COLOR.WHITE\",\n \"fontSize\": 14,\n \"imageSize\": 14\n }\n }\n }","project":"Superalgos","id":"fad0e429-f7a7-4b62-a2a5-2ead29b8f695","savedPayload":{"position":{"x":25236.875,"y":8701.347826086958},"targetPosition":{"x":24936.875,"y":8701.347826086958},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":3,"arrangementStyle":0},"uiObject":{}}},"spaceSettings":{"type":"Space Settings","name":"New Space Settings","config":"{\n \"node\": {\n \"distancePercentage\": 60,\n \"radiusPercentage\": 85,\n \"massPercentage\": 100,\n \"animationSteps\": 2, \n \"menuItem\": {\n \"widthPercentage\": 100,\n \"heightPercentage\": 60,\n \"radiusPercentage\": 90\n }\n },\n \"physics\": false\n}","project":"Superalgos","id":"05c9d6d5-24c4-4eec-9aca-9668d6486fdd","savedPayload":{"position":{"x":24636.875,"y":8701.347826086958},"targetPosition":{"x":24936.875,"y":8701.347826086958},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":3,"arrangementStyle":0},"uiObject":{}}},"id":"f8485ce5-67f3-4476-b9e2-80994e49c318","savedPayload":{"position":{"x":24940.875,"y":10717.347826086958},"targetPosition":{"x":24940.875,"y":10717.347826086958},"floatingObject":{"isPinned":true,"isFrozen":false,"isCollapsed":true,"angleToParent":1,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false},"frame":{"position":{"x":255,"y":588.3125}}}},{"type":"Superalgos Project","name":"New Superalgos Project","project":"Superalgos","projectDefinition":{"type":"Project Definition","name":"Superalgos","config":"{ \n \"codeName\": \"Superalgos\"\n}","project":"Superalgos","id":"a2a04e12-604e-43f8-a986-1b8ca3b043cb","savedPayload":{"position":{"x":19203,"y":10733.5},"targetPosition":{"x":18903,"y":10733.5},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":3,"arrangementStyle":0},"uiObject":{}}},"spaces":{"type":"Spaces","name":"New Spaces","project":"Superalgos","id":"4d0ee814-4e48-4688-9cc5-7ee03de5192b","savedPayload":{"position":{"x":19053,"y":10993.307621135331},"targetPosition":{"x":18903,"y":10733.5},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":3,"arrangementStyle":0},"uiObject":{}}},"mines":{"type":"Mines","name":"New Mines","project":"Superalgos","id":"b979e3a3-9316-4e5a-831b-c503b4b0e507","savedPayload":{"position":{"x":18753,"y":10993.307621135331},"targetPosition":{"x":18903,"y":10733.5},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":3,"arrangementStyle":0},"uiObject":{}}},"trading":{"type":"Trading","name":"New Trading","project":"Superalgos","id":"7c24591e-b252-4be3-8952-e4da0a52f467","savedPayload":{"position":{"x":18603,"y":10733.5},"targetPosition":{"x":18903,"y":10733.5},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":3,"arrangementStyle":0},"uiObject":{}}},"learning":{"type":"Learning","name":"New Learning","project":"Superalgos","id":"7a0b6167-5554-497a-b150-8886120539c2","savedPayload":{"position":{"x":18753,"y":10473.692378864669},"targetPosition":{"x":18903,"y":10733.5},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":3,"arrangementStyle":0},"uiObject":{}}},"otherHierarchies":{"type":"Other Hierarchies","name":"New Other Hierarchies","project":"Superalgos","id":"0a1ff755-8e0b-4f62-976e-df76c8139c6f","savedPayload":{"position":{"x":19053,"y":10473.692378864669},"targetPosition":{"x":18903,"y":10733.5},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":3,"arrangementStyle":0},"uiObject":{}}},"id":"cf9f8b3b-77c6-43c6-b01f-95cf366a91f6","savedPayload":{"position":{"x":18903,"y":10733.5},"targetPosition":{"x":18903,"y":10733.5},"floatingObject":{"isPinned":true,"isFrozen":false,"isCollapsed":true,"angleToParent":1,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false}}},{"type":"Tutorial","name":"Install a New Market","config":"{\"position\":\"\",\"slider\":\"toTop\",\"documentationURL\":\"\",\"docs\":{\"project\":\"Superalgos\",\"category\":\"Tutorial\",\"type\":\"Tutorial - Install a New Market\"},\"icon\":{\"name\":\"market\",\"project\":\"Superalgos\"}}","project":"Superalgos","tutorialSteps":[],"tutorialTopics":[{"type":"Tutorial Topic","name":"Add the Assets","config":"{\"position\":\"Left\",\"slider\":\"toTop\",\"positionAtReferenceParent\":true,\"documentationURL\":\"\",\"docs\":{\"project\":\"Superalgos\",\"category\":\"Tutorial\",\"type\":\"Tutorial Topic - Add the Assets\"},\"icon\":{\"name\":\"asset\",\"project\":\"Superalgos\"}}","project":"Superalgos","tutorialSteps":[{"type":"Tutorial Step","name":"New Tutorial Step","config":"{\n \"image\": \"exchange-assets\",\n \"position\": \"Left\",\n \"slider\": \"toTop\",\n \"documentationURL\": \"\",\n \"docs\": {\n \"project\": \"Superalgos\",\n \"category\": \"Tutorial\",\n \"type\": \"Tutorial Step - Add the Assets 1\"\n }\n}","project":"Superalgos","id":"1b3b8d0e-3aa9-4aba-8b74-351647a3b5b5","savedPayload":{"position":{"x":31555.632034355964,"y":40268.44846100007},"targetPosition":{"x":31343.5,"y":40480.58049535604},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false},"tutorial":{"status":"Reset"}}},{"type":"Tutorial Step","name":"New Tutorial Step","config":"{\n \"image\": \"asset\",\n \"externalLink\": [\n \"\",\n \"\"\n ],\n \"position\": \"Left\",\n \"slider\": \"toTop\",\n \"documentationURL\": \"\",\n \"docs\": {\n \"project\": \"Superalgos\",\n \"category\": \"Tutorial\",\n \"type\": \"Tutorial Step - Add the Assets 2\"\n }\n}","project":"Superalgos","id":"05f7092a-2326-40e7-b618-f3be5523e670","savedPayload":{"position":{"x":31643.5,"y":40480.58049535604},"targetPosition":{"x":31343.5,"y":40480.58049535604},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false},"tutorial":{"status":"Reset"}}},{"type":"Tutorial Step","name":"New Tutorial Step","config":"{\n \"image\": \"asset\",\n \"externalLink\": [\n \"\",\n \"\"\n ],\n \"position\": \"Left\",\n \"slider\": \"toTop\",\n \"documentationURL\": \"\",\n \"docs\": {\n \"project\": \"Superalgos\",\n \"category\": \"Tutorial\",\n \"type\": \"Tutorial Step - Add the Assets 3\"\n }\n}","project":"Superalgos","id":"281274f1-a4ec-47a2-b97c-0c29aa71eed9","savedPayload":{"position":{"x":31555.632034355964,"y":40692.712529712},"targetPosition":{"x":31343.5,"y":40480.58049535604},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false},"tutorial":{"status":"Reset"}}}],"tutorialTopics":[],"id":"cd6f2f74-407e-46c9-b7de-95d9ab2cc82d","savedPayload":{"position":{"x":25258.5,"y":37561.33049535604},"targetPosition":{"x":24958.5,"y":37561.33049535604},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":true,"angleToParent":1,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false},"tutorial":{"status":"Reset"},"referenceParent":{"type":"Exchange Assets","name":"New Exchange Assets","id":"95d2c30f-215b-486e-8119-f4eac0279575"}}},{"type":"Tutorial Topic","name":"Set up the Market","config":"{\n \"image\": \"market\",\n \"position\": \"Left\",\n \"slider\": \"toTop\",\n \"positionAtReferenceParent\": true,\n \"documentationURL\": \"\",\n \"docs\": {\n \"project\": \"Superalgos\",\n \"category\": \"Tutorial\",\n \"type\": \"Tutorial Topic - Set Up the Market\"\n }\n}","project":"Superalgos","tutorialSteps":[{"type":"Tutorial Step","name":"New Tutorial Step","config":"{\n \"image\": \"market\",\n \"position\": \"Left\",\n \"slider\": \"toTop\",\n \"documentationURL\": \"\",\n \"docs\": {\n \"project\": \"Superalgos\",\n \"category\": \"Tutorial\",\n \"type\": \"Tutorial Step - Set Up the Market 1\"\n },\n \"controlDocs\": {\n \"panel\": \"Close\"\n }\n}","project":"Superalgos","id":"cae5ddd4-0c48-488d-86f7-38192c7fdbca","savedPayload":{"position":{"x":31483.85656861048,"y":40749.74665547167},"targetPosition":{"x":31185.5,"y":40718.38811649137},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false},"tutorial":{"status":"Reset"}}},{"type":"Tutorial Step","name":"New Tutorial Step","config":"{\n \"image\": \"asset\",\n \"position\": \"Left\",\n \"slider\": \"toTop\",\n \"docs\": {\n \"project\": \"Superalgos\",\n \"category\": \"Tutorial\",\n \"type\": \"Tutorial Step - Set Up the Market 2\"\n },\n \"controlDocs\": {\n \"panel\": \"Open\",\n \"page\": {\n \"project\": \"Superalgos\",\n \"category\": \"Topic\",\n \"type\": \"References\",\n \"anchor\": \"How to Estabish and Remove References\"\n }\n }\n}","project":"Superalgos","id":"a7a049cb-72e0-4d76-9247-ee0d873e79c8","savedPayload":{"position":{"x":31408.443447643218,"y":40919.12729839903},"targetPosition":{"x":31185.5,"y":40718.38811649137},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false},"tutorial":{"status":"Reset"}}},{"type":"Tutorial Step","name":"New Tutorial Step","config":"{\n \"image\": \"asset\",\n \"position\": \"Left\",\n \"slider\": \"toTop\",\n \"documentationURL\": \"\",\n \"docs\": {\n \"project\": \"Superalgos\",\n \"category\": \"Tutorial\",\n \"type\": \"Tutorial Step - Set Up the Market 3\"\n },\n \"controlDocs\": {\n \"panel\": \"Close\"\n }\n}","project":"Superalgos","id":"9710d88d-c4ae-406b-9079-31bcf7395817","savedPayload":{"position":{"x":31247.873507245327,"y":41011.832396711514},"targetPosition":{"x":31185.5,"y":40718.38811649137},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false},"tutorial":{"status":"Reset"}}},{"type":"Tutorial Step","name":"New Tutorial Step","config":"{\n \"image\": \"market\",\n \"position\": \"Left\",\n \"slider\": \"toTop\",\n \"documentationURL\": \"\",\n \"docs\": {\n \"project\": \"Superalgos\",\n \"category\": \"Tutorial\",\n \"type\": \"Tutorial Step - Set Up the Market 4\"\n }\n}","project":"Superalgos","id":"2d2ce361-6261-44b4-b7ff-466035934334","savedPayload":{"position":{"x":31063.47900707726,"y":40992.45175378415},"targetPosition":{"x":31185.5,"y":40718.38811649137},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false},"tutorial":{"status":"Reset"}}}],"tutorialTopics":[],"id":"4de3cd7d-f552-4f39-b4cd-e29269b64668","savedPayload":{"position":{"x":25108.5,"y":37821.13811649137},"targetPosition":{"x":24958.5,"y":37561.33049535604},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":true,"angleToParent":1,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false},"tutorial":{"status":"Reset"},"referenceParent":{"type":"Exchange Markets","name":"New Exchange Markets","id":"2fd80894-900e-44ac-a1a7-56c14124f7a1"}}},{"type":"Tutorial Topic","name":"Install the Market","config":"{\n \"image\": \"market\",\n \"position\": \"Left\",\n \"slider\": \"toTop\",\n \"documentationURL\": \"\",\n \"docs\": {\n \"project\": \"Superalgos\",\n \"category\": \"Tutorial\",\n \"type\": \"Tutorial Topic - Install the Market\"\n }\n}","project":"Superalgos","tutorialSteps":[],"tutorialTopics":[],"id":"e003540b-91f4-41ce-8082-45122ddb55e7","savedPayload":{"position":{"x":24808.5,"y":37821.13811649137},"targetPosition":{"x":24958.5,"y":37561.33049535604},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false},"tutorial":{"status":"Reset"}}},{"type":"Tutorial Topic","name":"Network Verification","config":"{\n \"image\": \"network-node\",\n \"position\": \"Left\",\n \"slider\": \"toTop\",\n \"positionAtReferenceParent\": true,\n \"documentationURL\": \"\",\n \"docs\": {\n \"project\": \"Superalgos\",\n \"category\": \"Tutorial\",\n \"type\": \"Tutorial Topic - Network Verification\"\n }\n}","project":"Superalgos","tutorialSteps":[{"type":"Tutorial Step","name":"New Tutorial Step","config":"{\n \"image\": \"data-tasks\",\n \"externalLink\": [\n \"\",\n \"\"\n ],\n \"position\": \"Left\",\n \"slider\": \"toTop\",\n \"positionAtReferenceParent\": true,\n \"documentationURL\": \"\",\n \"docs\": {\n \"project\": \"Superalgos\",\n \"category\": \"Tutorial\",\n \"type\": \"Tutorial Step - Network Verification 1\"\n }\n}","project":"Superalgos","id":"4bca0860-329c-4fde-a11e-d404d0f23431","savedPayload":{"position":{"x":30567.164424312257,"y":40723.28559366852},"targetPosition":{"x":30743.5,"y":40480.58049535604},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false},"tutorial":{"status":"Reset"},"referenceParent":{"type":"Data Tasks","name":"New Data Tasks","id":"40af91d9-431c-4b7d-addc-aed37bc2f3fe"}}},{"type":"Tutorial Step","name":"New Tutorial Step","config":"{\n \"image\": \"testing-trading-tasks\",\n \"externalLink\": [\n \"\",\n \"\"\n ],\n \"position\": \"Left\",\n \"slider\": \"toTop\",\n \"positionAtReferenceParent\": true,\n \"documentationURL\": \"\",\n \"docs\": {\n \"project\": \"Superalgos\",\n \"category\": \"Tutorial\",\n \"type\": \"Tutorial Step - Network Verification 2\"\n }\n}","project":"Superalgos","id":"495e3d4c-87a8-4147-ad2a-06920da9d7a6","savedPayload":{"position":{"x":30458.183045111455,"y":40573.28559366852},"targetPosition":{"x":30743.5,"y":40480.58049535604},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false},"tutorial":{"status":"Reset"},"referenceParent":{"type":"Testing Trading Tasks","name":"New Testing Trading Tasks","id":"8117db0a-e418-4f56-8fe4-fda2ddac1cbb"}}},{"type":"Tutorial Step","name":"New Tutorial Step","config":"{\n \"image\": \"production-trading-tasks\",\n \"position\": \"Left\",\n \"slider\": \"toTop\",\n \"positionAtReferenceParent\": true,\n \"documentationURL\": \"\",\n \"docs\": {\n \"project\": \"Superalgos\",\n \"category\": \"Tutorial\",\n \"type\": \"Tutorial Step - Network Verification 3\"\n }\n}","project":"Superalgos","id":"43b85e55-3417-4b13-a7b6-7c5bc0fb691d","savedPayload":{"position":{"x":30458.183045111455,"y":40387.87539704355},"targetPosition":{"x":30743.5,"y":40480.58049535604},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false},"tutorial":{"status":"Reset"},"referenceParent":{"type":"Production Trading Tasks","name":"New Production Trading Tasks","id":"673caa5f-511d-4688-9305-e5f0f0f780cd"}}},{"type":"Tutorial Step","name":"New Tutorial Step","config":"{\n \"image\": \"data-storage\",\n \"position\": \"Left\",\n \"slider\": \"toTop\",\n \"positionAtReferenceParent\": true,\n \"documentationURL\": \"\",\n \"docs\": {\n \"project\": \"Superalgos\",\n \"category\": \"Tutorial\",\n \"type\": \"Tutorial Step - Network Verification 4\"\n }\n}","project":"Superalgos","id":"f37edf40-24ba-42d0-9458-bf008c123659","savedPayload":{"position":{"x":30567.164424312257,"y":40237.87539704355},"targetPosition":{"x":30743.5,"y":40480.58049535604},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false},"tutorial":{"status":"Reset"},"referenceParent":{"type":"Data Storage","name":"New Data Storage","id":"e2697759-6038-4943-b90c-5a68651ff9a8"}}}],"tutorialTopics":[],"id":"89c6f1e3-d4c8-48c0-aec1-9dda6e0b9797","savedPayload":{"position":{"x":24658.5,"y":37561.33049535604},"targetPosition":{"x":24958.5,"y":37561.33049535604},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":true,"angleToParent":1,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false},"tutorial":{"status":"Reset"},"referenceParent":{"type":"Network Node","name":"My Computer","id":"e452cf65-2b2b-44f2-9e67-bdd9d3c008e4"}}},{"type":"Tutorial Topic","name":"Charts Verification","config":"{\n \"image\": \"charting-space\",\n \"position\": \"Right\",\n \"slider\": \"toTop\",\n \"positionAtReferenceParent\": true,\n \"documentationURL\": \"\",\n \"docs\": {\n \"project\": \"Superalgos\",\n \"category\": \"Tutorial\",\n \"type\": \"Tutorial Topic - Charts Verification\"\n }\n}","project":"Superalgos","tutorialSteps":[{"type":"Tutorial Step","name":"New Tutorial Step","config":"{\n \"image\": \"charting-space\",\n \"externalLink\": [\n \"\",\n \"\"\n ],\n \"position\": \"Right\",\n \"slider\": \"toTop\",\n \"documentationURL\": \"\",\n \"docs\": {\n \"project\": \"Superalgos\",\n \"category\": \"Tutorial\",\n \"type\": \"Tutorial Step - Charts Verification 1\"\n }\n}","project":"Superalgos","id":"17eb1e8e-e9f4-4fe4-a8ea-2c0ea0804d87","savedPayload":{"position":{"x":30633.692378864667,"y":40070.772874220704},"targetPosition":{"x":30893.5,"y":40220.772874220704},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false},"tutorial":{"status":"Reset"}}},{"type":"Tutorial Step","name":"New Tutorial Step","config":"{\n \"image\": \"time-machine\",\n \"position\": \"Left\",\n \"slider\": \"toBottom\",\n \"documentationURL\": \"\",\n \"docs\": {\n \"project\": \"Superalgos\",\n \"category\": \"Tutorial\",\n \"type\": \"Tutorial Step - Charts Verification 2\"\n }\n}","project":"Superalgos","id":"a94fa42a-87c8-4874-ba45-ffa0ffd02f36","savedPayload":{"position":{"x":30893.5,"y":39920.772874220704},"targetPosition":{"x":30893.5,"y":40220.772874220704},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false},"tutorial":{"status":"Reset"}}}],"tutorialTopics":[],"id":"064a5be1-bb06-468b-8fad-d78d2c844ee1","savedPayload":{"position":{"x":24808.5,"y":37301.522874220704},"targetPosition":{"x":24958.5,"y":37561.33049535604},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":true,"angleToParent":1,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false},"tutorial":{"status":"Reset"},"referenceParent":{"type":"Charting Space","name":"New Charting Space","id":"21d2ec55-9e56-4652-8e96-c7e451262c36"}}},{"type":"Tutorial Topic","name":"The End","config":"{\n \"image\": \"tutorial\",\n \"position\": \"Left\",\n \"slider\": \"toTop\",\n \"documentationURL\": \"\",\n \"docs\": {\n \"project\": \"Superalgos\",\n \"category\": \"Tutorial\",\n \"type\": \"Tutorial Topic - You Made It!\"\n }\n}","project":"Superalgos","tutorialSteps":[],"tutorialTopics":[],"id":"9b5e9927-860c-4b89-ac5d-d7f6fd86b18d","savedPayload":{"position":{"x":25108.5,"y":37301.522874220704},"targetPosition":{"x":24958.5,"y":37561.33049535604},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":true,"angleToParent":1,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false},"tutorial":{"status":"Reset"}}}],"id":"d86ff84f-15d3-4a2d-9674-114c5b526de5","savedPayload":{"position":{"x":24958.5,"y":37561.33049535604},"targetPosition":{"x":24958.5,"y":37561.33049535604},"floatingObject":{"isPinned":true,"isFrozen":false,"isCollapsed":true,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isPlaying":true,"isRunning":false},"tutorial":{"status":"Done"}}},{"type":"APIs","name":"New APIs","project":"Superalgos","githubAPI":{"type":"Github API","name":"New Github API","config":"{\n \"username\": \"\",\n \"token\": \"\"\n}","project":"Superalgos","id":"9ea7bee2-c4db-4cee-a05f-63fcf3a86a4a","savedPayload":{"position":{"x":31349.208333333332,"y":10755.819458631257},"targetPosition":{"x":31049.208333333332,"y":10755.819458631257},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":3,"arrangementStyle":0},"uiObject":{}}},"id":"23021bb7-9997-4fe6-8199-71ebf70aef76","savedPayload":{"position":{"x":31049.208333333332,"y":10755.819458631257},"targetPosition":{"x":31049.208333333332,"y":10755.819458631257},"floatingObject":{"isPinned":true,"isFrozen":false,"isCollapsed":true,"angleToParent":1,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false}}},{"type":"Trading System","name":"New Trading System","project":"Superalgos","tradingStrategies":[{"type":"Trading Strategy","name":"New Trading Strategy","project":"Superalgos","triggerStage":{"type":"Trigger Stage","name":"New Trigger Stage","project":"Superalgos","triggerOn":{"type":"Trigger On Event","name":"New Trigger On Event","project":"Superalgos","situations":[{"type":"Situation","name":"New Situation","project":"Superalgos","conditions":[{"type":"Condition","name":"New Condition","project":"Superalgos","javascriptCode":{"type":"Javascript Code","name":"New Javascript Code","code":"// Type you code","project":"Superalgos","id":"64a86fa1-8ce7-4bca-a684-20f8d1126d70","savedPayload":{"position":{"x":30720.690987174497,"y":30424.038745267728},"targetPosition":{"x":30854.341965802752,"y":30492.13732022866},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":3,"arrangementStyle":0},"uiObject":{}}},"id":"e21a0776-acd7-4cb2-9f5f-2bcbfa6e89e0","savedPayload":{"position":{"x":30854.341965802752,"y":30492.13732022866},"targetPosition":{"x":30987.992944431007,"y":30560.23589518959},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false}}}],"id":"bb7fdf98-25b3-4282-81cc-0658dcf6d484","savedPayload":{"position":{"x":30987.992944431007,"y":30560.23589518959},"targetPosition":{"x":31121.643923059262,"y":30628.334470150523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false}}}],"announcements":[],"id":"1f62cb3d-19fa-4717-a113-c0915e8ceaa0","savedPayload":{"position":{"x":31121.643923059262,"y":30628.334470150523},"targetPosition":{"x":31255.294901687517,"y":30696.433045111455},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":2,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"triggerOff":{"type":"Trigger Off Event","name":"New Trigger Off Event","project":"Superalgos","situations":[{"type":"Situation","name":"New Situation","project":"Superalgos","conditions":[{"type":"Condition","name":"New Condition","project":"Superalgos","javascriptCode":{"type":"Javascript Code","name":"New Javascript Code","code":"// Type you code","project":"Superalgos","id":"f11bf186-ccfd-4e60-8260-f52cdf898bb4","savedPayload":{"position":{"x":31069.884705062545,"y":30125.799135334357},"targetPosition":{"x":31116.237254218788,"y":30268.45761277863},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":3,"arrangementStyle":0},"uiObject":{}}},"id":"7051b998-d100-48b2-90a4-d5e3f361e334","savedPayload":{"position":{"x":31116.237254218788,"y":30268.45761277863},"targetPosition":{"x":31162.58980337503,"y":30411.116090222906},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false}}}],"id":"d76e94fb-d895-4634-90f9-667d0367e210","savedPayload":{"position":{"x":31162.58980337503,"y":30411.116090222906},"targetPosition":{"x":31208.942352531274,"y":30553.77456766718},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false}}}],"announcements":[],"id":"0d1dc41a-7185-43a8-814e-e6a5300e6a1d","savedPayload":{"position":{"x":31208.942352531274,"y":30553.77456766718},"targetPosition":{"x":31255.294901687517,"y":30696.433045111455},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":2,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"takePosition":{"type":"Take Position Event","name":"New Take Position Event","project":"Superalgos","situations":[{"type":"Situation","name":"New Situation","project":"Superalgos","conditions":[{"type":"Condition","name":"New Condition","project":"Superalgos","javascriptCode":{"type":"Javascript Code","name":"New Javascript Code","code":"// Type you code","project":"Superalgos","id":"c8cb9f04-5192-4b0c-b87b-d614ef07ec58","savedPayload":{"position":{"x":31527.689201531244,"y":30161.829130598435},"targetPosition":{"x":31459.590626570312,"y":30295.48010922669},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":3,"arrangementStyle":0},"uiObject":{}}},"id":"3094206b-682a-481a-9b36-5d86eb621ef5","savedPayload":{"position":{"x":31459.590626570312,"y":30295.48010922669},"targetPosition":{"x":31391.49205160938,"y":30429.131087854945},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false}}}],"id":"7a3d4c6a-147e-4b75-8914-4ca3972ab3d5","savedPayload":{"position":{"x":31391.49205160938,"y":30429.131087854945},"targetPosition":{"x":31323.39347664845,"y":30562.7820664832},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false}}}],"announcements":[],"id":"0e1d431a-e1be-439e-9f86-2771f5f3fde4","savedPayload":{"position":{"x":31323.39347664845,"y":30562.7820664832},"targetPosition":{"x":31255.294901687517,"y":30696.433045111455},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":2,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"announcements":[],"id":"f8551c2e-bbb4-4cba-ab56-d7873f725f07","savedPayload":{"position":{"x":31255.294901687517,"y":30696.433045111455},"targetPosition":{"x":31348,"y":30981.75},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":true,"angleToParent":1,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"openStage":{"type":"Open Stage","name":"New Open Stage","config":"{\n\"roundingErrorCorrectionFactor\": 1.01, \n\"absoluteDustInBaseAsset\": 0,\n\"absoluteDustInQuotedAsset\": 0 \n}","project":"Superalgos","initialTargets":{"type":"Initial Targets","name":"New Initial Targets","project":"Superalgos","targetRate":{"type":"Target Rate","name":"New Target Rate","project":"Superalgos","formula":{"type":"Formula","name":"New Formula","code":"// Type your formula","project":"Superalgos","id":"c2cc6b16-4d23-4fb5-ba60-a05c6758f6ea","savedPayload":{"position":{"x":31284.964286449067,"y":30023.69772550875},"targetPosition":{"x":31461.29986213681,"y":30266.402823821234},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":3,"arrangementStyle":0},"uiObject":{}}},"id":"5febb99a-093e-4ae2-afa8-e28743b302c3","savedPayload":{"position":{"x":31461.29986213681,"y":30266.402823821234},"targetPosition":{"x":31637.635437824552,"y":30509.107922133717},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"targetSizeInBaseAsset":{"type":"Target Size In Base Asset","name":"New Target Size In Base Asset","project":"Superalgos","formula":{"type":"Formula","name":"New Formula","code":"// Type your formula","project":"Superalgos","id":"4f17a02a-185b-4c85-b26f-85667100b1a7","savedPayload":{"position":{"x":31731.49611684869,"y":29916.494917776636},"targetPosition":{"x":31684.565777336622,"y":30212.801419955176},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":3,"arrangementStyle":0},"uiObject":{}}},"id":"bba4131a-dd63-490c-97a7-819c484a9a6a","savedPayload":{"position":{"x":31684.565777336622,"y":30212.801419955176},"targetPosition":{"x":31637.635437824552,"y":30509.107922133717},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"targetSizeInQuotedAsset":{"type":"Target Size In Quoted Asset","name":"New Target Size In Quoted Asset","project":"Superalgos","formula":{"type":"Formula","name":"New Formula","code":"// Type your formula","project":"Superalgos","id":"f9ae8796-8a5b-421e-b2b1-8741ea1a8cc2","savedPayload":{"position":{"x":32123.045634449518,"y":30156.43677075823},"targetPosition":{"x":31880.340536137035,"y":30332.772346445974},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":3,"arrangementStyle":0},"uiObject":{}}},"id":"19f04a50-0d33-4c0b-a723-1dd922de9b57","savedPayload":{"position":{"x":31880.340536137035,"y":30332.772346445974},"targetPosition":{"x":31637.635437824552,"y":30509.107922133717},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"id":"d41b3907-2ae7-4d87-8b10-f80fc30107d1","savedPayload":{"position":{"x":31637.635437824552,"y":30509.107922133717},"targetPosition":{"x":31590.705098312483,"y":30805.414424312257},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"openExecution":{"type":"Open Execution","name":"New Open Execution","project":"Superalgos","executionAlgorithms":[],"id":"90f51fa8-874d-460c-9f40-b4c533c0e75f","savedPayload":{"position":{"x":31833.410196624965,"y":30629.078848624515},"targetPosition":{"x":31590.705098312483,"y":30805.414424312257},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"closeStageEvent":{"type":"Close Stage Event","name":"New Close Stage Event","project":"Superalgos","situations":[{"type":"Situation","name":"New Situation","project":"Superalgos","conditions":[{"type":"Condition","name":"New Condition","project":"Superalgos","javascriptCode":{"type":"Javascript Code","name":"New Javascript Code","code":"// Type you code","project":"Superalgos","id":"76f03cf3-14ab-444d-847d-a3d86244236c","savedPayload":{"position":{"x":32183.31810266957,"y":30899.27510333639},"targetPosition":{"x":32035.1648515803,"y":30875.809933580356},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":3,"arrangementStyle":0},"uiObject":{}}},"id":"da3fb954-8ee5-4537-98ef-7ae9a9d18ade","savedPayload":{"position":{"x":32035.1648515803,"y":30875.809933580356},"targetPosition":{"x":31887.011600491027,"y":30852.344763824323},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false}}}],"id":"230c7c45-dfe4-44cf-96fd-103ccc94c7ec","savedPayload":{"position":{"x":31887.011600491027,"y":30852.344763824323},"targetPosition":{"x":31738.858349401755,"y":30828.87959406829},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false}}}],"announcements":[],"id":"9516578c-09f5-4e5a-9512-bd6a972e653b","savedPayload":{"position":{"x":31738.858349401755,"y":30828.87959406829},"targetPosition":{"x":31590.705098312483,"y":30805.414424312257},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":2,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"announcements":[],"id":"a4bc39be-42fd-4439-9397-d4f9b72c86ae","savedPayload":{"position":{"x":31590.705098312483,"y":30805.414424312257},"targetPosition":{"x":31348,"y":30981.75},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":true,"angleToParent":1,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"manageStage":{"type":"Manage Stage","name":"New Manage Stage","project":"Superalgos","managedStopLoss":{"type":"Managed Stop Loss","name":"New Managed Stop Loss","project":"Superalgos","phases":[{"type":"Phase","name":"New Phase","project":"Superalgos","formula":{"type":"Formula","name":"New Formula","code":"// Type your formula","project":"Superalgos","id":"2355e7d2-8df6-40ea-89b5-c14871b45a46","savedPayload":{"position":{"x":32038.23995122821,"y":31205.12338415819},"targetPosition":{"x":31889.061666922968,"y":31189.44411466804},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":3,"arrangementStyle":0},"uiObject":{}}},"moveToPhaseEvents":[],"announcements":[],"id":"6c14c525-08b9-47ab-a147-10a974ae6ceb","savedPayload":{"position":{"x":31889.061666922968,"y":31189.44411466804},"targetPosition":{"x":31739.883382617725,"y":31173.76484517789},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false}}}],"id":"b6587a2b-f666-49b8-a613-f0e2364d77ca","savedPayload":{"position":{"x":31739.883382617725,"y":31173.76484517789},"targetPosition":{"x":31590.705098312483,"y":31158.085575687743},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":2,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"managedTakeProfit":{"type":"Managed Take Profit","name":"New Managed Take Profit","project":"Superalgos","phases":[{"type":"Phase","name":"New Phase","project":"Superalgos","formula":{"type":"Formula","name":"New Formula","code":"// Type your formula","project":"Superalgos","id":"ec410d91-2186-4c11-9298-a7e728004bea","savedPayload":{"position":{"x":31773.736587696596,"y":31569.18103162692},"targetPosition":{"x":31712.726091235225,"y":31432.149212980526},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":3,"arrangementStyle":0},"uiObject":{}}},"moveToPhaseEvents":[],"announcements":[],"id":"e0f595de-f085-4890-bc73-881928da8d60","savedPayload":{"position":{"x":31712.726091235225,"y":31432.149212980526},"targetPosition":{"x":31651.715594773854,"y":31295.117394334135},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false}}}],"id":"5ef91d3f-b318-4ff2-9690-d79830001df6","savedPayload":{"position":{"x":31651.715594773854,"y":31295.117394334135},"targetPosition":{"x":31590.705098312483,"y":31158.085575687743},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":2,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"announcements":[],"id":"4e67c91b-a870-48e7-86b6-97d1ffa7df85","savedPayload":{"position":{"x":31590.705098312483,"y":31158.085575687743},"targetPosition":{"x":31348,"y":30981.75},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":true,"angleToParent":1,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"closeStage":{"type":"Close Stage","name":"New Close Stage","config":"{\n\"roundingErrorCorrectionFactor\": 1.01, \n\"absoluteDustInBaseAsset\": 0,\n\"absoluteDustInQuotedAsset\": 0 \n}","project":"Superalgos","initialTargets":{"type":"Initial Targets","name":"New Initial Targets","project":"Superalgos","targetRate":{"type":"Target Rate","name":"New Target Rate","project":"Superalgos","formula":{"type":"Formula","name":"New Formula","code":"// Type your formula","project":"Superalgos","id":"ff36b87d-b2af-432d-aad7-9f425d05da30","savedPayload":{"position":{"x":31962.12596138647,"y":31719.77910877002},"targetPosition":{"x":31676.809006497926,"y":31627.074010457538},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":3,"arrangementStyle":0},"uiObject":{}}},"id":"0c4588ed-6aad-4e43-aea2-fd857cdde709","savedPayload":{"position":{"x":31676.809006497926,"y":31627.074010457538},"targetPosition":{"x":31391.49205160938,"y":31534.368912145055},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"targetSizeInBaseAsset":{"type":"Target Size In Base Asset","name":"New Target Size In Base Asset","project":"Superalgos","formula":{"type":"Formula","name":"New Formula","code":"// Type your formula","project":"Superalgos","id":"b63cde4a-ffa7-4d55-827e-fdbe25d55f92","savedPayload":{"position":{"x":31663.886351453108,"y":32068.972826658075},"targetPosition":{"x":31527.689201531244,"y":31801.670869401565},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":3,"arrangementStyle":0},"uiObject":{}}},"id":"888c1960-5e4e-40bf-86a5-0733ad54d2d4","savedPayload":{"position":{"x":31527.689201531244,"y":31801.670869401565},"targetPosition":{"x":31391.49205160938,"y":31534.368912145055},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"targetSizeInQuotedAsset":{"type":"Target Size In Quoted Asset","name":"New Target Size In Quoted Asset","project":"Superalgos","formula":{"type":"Formula","name":"New Formula","code":"// Type your formula","project":"Superalgos","id":"555c938b-6d6a-43dc-89f2-864738616991","savedPayload":{"position":{"x":31206.081854984415,"y":32105.002821922146},"targetPosition":{"x":31298.786953296898,"y":31819.6858670336},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":3,"arrangementStyle":0},"uiObject":{}}},"id":"a8c951b1-9c11-4f6d-8461-fb935cf062d8","savedPayload":{"position":{"x":31298.786953296898,"y":31819.6858670336},"targetPosition":{"x":31391.49205160938,"y":31534.368912145055},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"id":"f33dc477-014b-4b16-a6bb-0c347f5a4992","savedPayload":{"position":{"x":31391.49205160938,"y":31534.368912145055},"targetPosition":{"x":31255.294901687517,"y":31267.066954888545},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"closeExecution":{"type":"Close Execution","name":"New Close Execution","project":"Superalgos","executionAlgorithms":[],"id":"b79f9f3f-01e6-417f-b644-825e17427e7c","savedPayload":{"position":{"x":31162.589803375035,"y":31552.38390977709},"targetPosition":{"x":31255.294901687517,"y":31267.066954888545},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"closeStageEvent":{"type":"Close Stage Event","name":"New Close Stage Event","project":"Superalgos","situations":[{"type":"Situation","name":"New Situation","project":"Superalgos","conditions":[{"type":"Condition","name":"New Condition","project":"Superalgos","javascriptCode":{"type":"Javascript Code","name":"New Javascript Code","code":"// Type you code","project":"Superalgos","id":"c6103247-6024-4e7d-81a5-833dc6d8d3ff","savedPayload":{"position":{"x":30720.690987174497,"y":31539.461254732272},"targetPosition":{"x":30854.341965802752,"y":31471.36267977134},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":3,"arrangementStyle":0},"uiObject":{}}},"id":"8655ace0-0cba-4682-aa94-795a3d34ce9a","savedPayload":{"position":{"x":30854.341965802752,"y":31471.36267977134},"targetPosition":{"x":30987.992944431007,"y":31403.26410481041},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false}}}],"id":"42267582-434d-4698-81d6-7ae8093d9a3a","savedPayload":{"position":{"x":30987.992944431007,"y":31403.26410481041},"targetPosition":{"x":31121.643923059262,"y":31335.165529849477},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false}}}],"announcements":[],"id":"8ebc6ab4-56ff-4afc-9741-a5ea2d8495f3","savedPayload":{"position":{"x":31121.643923059262,"y":31335.165529849477},"targetPosition":{"x":31255.294901687517,"y":31267.066954888545},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":2,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"announcements":[],"id":"3baca3ee-6498-4db5-8ba9-d7c9640907cf","savedPayload":{"position":{"x":31255.294901687517,"y":31267.066954888545},"targetPosition":{"x":31348,"y":30981.75},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":true,"angleToParent":1,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"id":"6b8ed032-1481-4e79-bcfa-b4d572e21df3","savedPayload":{"position":{"x":31348,"y":30981.75},"targetPosition":{"x":31048,"y":30981.75},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false}}}],"dynamicIndicators":{"type":"Dynamic Indicators","name":"New Dynamic Indicators","project":"Superalgos","indicatorFunctions":[{"type":"Indicator Function","name":"New Indicator Function","config":"{ \n \"codeName\": \"\"\n}","project":"Superalgos","formula":{"type":"Formula","name":"New Formula","code":"// Type your formula","project":"Superalgos","id":"3e3301b4-6742-49c8-82d6-20cd3453365f","savedPayload":{"position":{"x":30148,"y":30981.75},"targetPosition":{"x":30448,"y":30981.75},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":3,"arrangementStyle":0},"uiObject":{}}},"id":"21cc000a-cdbd-4c02-b1e4-4c4560861792","savedPayload":{"position":{"x":30448,"y":30981.75},"targetPosition":{"x":30748,"y":30981.75},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false}}}],"id":"ec700c19-7aee-4180-bb1f-5493f518e7ee","savedPayload":{"position":{"x":30748,"y":30981.75},"targetPosition":{"x":31048,"y":30981.75},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"id":"91a1d0d1-2a1a-45d5-a52b-b2dc5502339f","savedPayload":{"position":{"x":31048,"y":30981.75},"targetPosition":{"x":31048,"y":30981.75},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":true,"angleToParent":1,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false}}}]} \ No newline at end of file +{"type":"Workspace","name":"Tested Exchanges","rootNodes":[{"type":"Network","name":"My Network","project":"Superalgos","networkNodes":[{"type":"Network Node","name":"My Computer","config":"{ \n\"host\": \"localhost\", \n\"webPort\": \"34248\", \n\"webSocketsPort\": \"18041\"\n}","project":"Superalgos","dataTasks":{"type":"Data Tasks","name":"New Data Tasks","project":"Superalgos","projectDataTasks":[],"id":"40af91d9-431c-4b7d-addc-aed37bc2f3fe","savedPayload":{"position":{"x":25089.356993272086,"y":30767.11115747996},"targetPosition":{"x":25239.356993272086,"y":31026.918778615294},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"learningTasks":{"type":"Learning Tasks","name":"New Learning Tasks","project":"Superalgos","projectLearningTasks":[],"id":"0818dfbe-61ea-40b8-8544-bee25d7f45be","savedPayload":{"position":{"x":25389.356993272086,"y":30767.11115747996},"targetPosition":{"x":25239.356993272086,"y":31026.918778615294},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":true,"angleToParent":1,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"testingTradingTasks":{"type":"Testing Trading Tasks","name":"New Testing Trading Tasks","project":"Superalgos","projectTradingTasks":[],"id":"8117db0a-e418-4f56-8fe4-fda2ddac1cbb","savedPayload":{"position":{"x":25539.356993272086,"y":31026.918778615294},"targetPosition":{"x":25239.356993272086,"y":31026.918778615294},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":true,"angleToParent":1,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"productionTradingTasks":{"type":"Production Trading Tasks","name":"New Production Trading Tasks","project":"Superalgos","projectTradingTasks":[],"id":"673caa5f-511d-4688-9305-e5f0f0f780cd","savedPayload":{"position":{"x":25389.356993272086,"y":31286.726399750627},"targetPosition":{"x":25239.356993272086,"y":31026.918778615294},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":true,"angleToParent":1,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"dataStorage":{"type":"Data Storage","name":"New Data Storage","project":"Superalgos","dataMinesData":{"type":"Data Mines Data","name":"New Data Mines Data","project":"Superalgos","projectDataProducts":[],"id":"32e7c122-fa5a-4d00-9d71-d54e890e32de","savedPayload":{"position":{"x":25070.19913560607,"y":31588.15985816277},"targetPosition":{"x":25109.356993272086,"y":31290.726399750627},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":3,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"tradingMinesData":{"type":"Trading Mines Data","name":"New Trading Mines Data","project":"Superalgos","projectTradingProducts":[],"id":"e4e268f3-a677-4f90-90a1-d87244e647e5","savedPayload":{"position":{"x":24959.356993272086,"y":31550.53402088596},"targetPosition":{"x":25109.356993272086,"y":31290.726399750627},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":3,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"learningMinesData":{"type":"Learning Mines Data","name":"New Learning Mines Data","project":"Superalgos","projectLearningProducts":[],"id":"2845a687-becc-4c3b-bc79-b2293ba876ba","savedPayload":{"position":{"x":24871.350991184714,"y":31473.354828453244},"targetPosition":{"x":25109.356993272086,"y":31290.726399750627},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":3,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"id":"e2697759-6038-4943-b90c-5a68651ff9a8","savedPayload":{"position":{"x":25089.356993272086,"y":31286.726399750627},"targetPosition":{"x":25239.356993272086,"y":31026.918778615294},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":true,"angleToParent":1,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false,"shortcutKey":"d"}}},"id":"e452cf65-2b2b-44f2-9e67-bdd9d3c008e4","savedPayload":{"position":{"x":25239.356993272086,"y":31026.918778615294},"targetPosition":{"x":24939.356993272086,"y":31026.918778615294},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false,"shortcutKey":""}}}],"id":"3c165071-7558-4708-9999-8ffe71d346b1","savedPayload":{"position":{"x":24939.356993272086,"y":31026.918778615294},"targetPosition":{"x":24939.356993272086,"y":31026.918778615294},"floatingObject":{"isPinned":true,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false,"shortcutKey":"s"}}},{"type":"Crypto Ecosystem","name":"My Crypto Ecosystem","project":"Superalgos","cryptoExchanges":[{"type":"Crypto Exchanges","name":"Tested","project":"Superalgos","exchanges":[{"type":"Crypto Exchange","name":"Binance","config":"{\n \"codeName\": \"binance\",\n \"API\": [\n {\n \"method\": \"fetchTrades\",\n \"fetchType\": \"by Id\",\n \"fetchTradesMethod\": \"publicGetHistoricalTrades\",\n \"firstId\": \"f\"\n }\n ]\n}","project":"Superalgos","exchangeAssets":{"type":"Exchange Assets","name":"New Exchange Assets","config":"{ \n\"addMissingAssetsFilter\": { \"quotedAsset\": \"EUR\"} \n}","project":"Superalgos","assets":[{"type":"Asset","name":"Bitcoin","config":"{ \n\"codeName\": \"BTC\"\n}","project":"Superalgos","id":"5f5e4a94-5090-47d4-8883-cc2325d20bfa","savedPayload":{"position":{"x":18606.497829264816,"y":29451.09637134722},"targetPosition":{"x":18947.58510468027,"y":29744.625706422376},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{}}},{"type":"Asset","name":"Tether","config":"{\n \"codeName\": \"USDT\"\n}","project":"Superalgos","id":"f110bfa0-bd5b-469b-a940-4524c8688136","savedPayload":{"position":{"x":19031.245327903584,"y":29302.470793467397},"targetPosition":{"x":18947.58510468027,"y":29744.625706422376},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{}}}],"id":"95d2c30f-215b-486e-8119-f4eac0279575","savedPayload":{"position":{"x":18947.58510468027,"y":29744.625706422376},"targetPosition":{"x":19096.210682560097,"y":30169.37320506114},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false,"shortcutKey":"E"}}},"exchangeMarkets":{"type":"Exchange Markets","name":"New Exchange Markets","code":"{ \n\"codeName\": \"Write here the code name of the Market here.\"\n}","project":"Superalgos","markets":[{"type":"Market","name":"BTC/USDT","config":"{ \n\"codeName\": \"BTC/USDT\"\n}","project":"Superalgos","baseAsset":{"type":"Market Base Asset","name":"Bitcoin","project":"Superalgos","id":"1017b30d-de1b-4212-991e-9fd0a5b6c814","savedPayload":{"position":{"x":19570.366270989212,"y":28916.346310993984},"targetPosition":{"x":19486.7060477659,"y":29358.501223948962},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":3,"distanceToParent":3,"arrangementStyle":0},"uiObject":{},"referenceParent":{"type":"Asset","name":"Bitcoin","id":"5f5e4a94-5090-47d4-8883-cc2325d20bfa"}}},"quotedAsset":{"type":"Market Quoted Asset","name":"Tether","project":"Superalgos","id":"705c4a67-787a-48cd-a3dc-3a557438bf0b","savedPayload":{"position":{"x":19780.235382841056,"y":29017.413948533507},"targetPosition":{"x":19486.7060477659,"y":29358.501223948962},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":3,"distanceToParent":3,"arrangementStyle":0},"uiObject":{},"referenceParent":{"type":"Asset","name":"Tether","id":"f110bfa0-bd5b-469b-a940-4524c8688136"}}},"id":"9a867bf0-a71d-445c-b99a-75b60bbdce09","savedPayload":{"position":{"x":19486.7060477659,"y":29358.501223948962},"targetPosition":{"x":19291.458365163,"y":29763.93721450505},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":3,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false}}}],"id":"2fd80894-900e-44ac-a1a7-56c14124f7a1","savedPayload":{"position":{"x":19291.458365163,"y":29763.93721450505},"targetPosition":{"x":19096.210682560097,"y":30169.37320506114},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"exchangeAccounts":{"type":"Exchange Accounts","name":"New Exchange Accounts","project":"Superalgos","userAccounts":[{"type":"User Account","name":"New User Account","project":"Superalgos","userAssets":{"type":"User Assets","name":"New User Assets","project":"Superalgos","assets":[{"type":"Exchange Account Asset","name":"Bitcoin","project":"Superalgos","id":"ba6f3d5c-b36b-49d9-947f-392068109169","savedPayload":{"position":{"x":19810.91198701285,"y":29633.15211842039},"targetPosition":{"x":19784.76526418855,"y":29932.010527847913},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{},"referenceParent":{"type":"Asset","name":"Bitcoin","id":"5f5e4a94-5090-47d4-8883-cc2325d20bfa"}}},{"type":"Exchange Account Asset","name":"Tether","project":"Superalgos","id":"c90be267-90f9-45ae-b225-0578adb4aad9","savedPayload":{"position":{"x":20056.657600299546,"y":29805.225049325705},"targetPosition":{"x":19784.76526418855,"y":29932.010527847913},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{},"referenceParent":{"type":"Asset","name":"Tether","id":"f110bfa0-bd5b-469b-a940-4524c8688136"}}}],"id":"8ac5c2a9-a238-48ae-ab43-0a0a95a37464","savedPayload":{"position":{"x":19784.76526418855,"y":29932.010527847913},"targetPosition":{"x":19612.692333283238,"y":30177.75614113461},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"userKeys":{"type":"User Keys","name":"New User Keys","project":"Superalgos","keys":[{"type":"Exchange Account Key","name":"Key for Lighting Strike","config":"{ \n\"codeName\": \"Paste your exchange API name or label\",\n\"secret\": \"Paste your exchange API secret key\"\n}","project":"Superalgos","id":"e85bbbd6-aca8-450f-9237-788062de5761","savedPayload":{"position":{"x":20210.409152138287,"y":30230.049586783207},"targetPosition":{"x":19911.550742710762,"y":30203.90286395891},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":true,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{}}}],"id":"48925cc9-f3cd-4499-8466-1338fed28a0d","savedPayload":{"position":{"x":19911.550742710762,"y":30203.90286395891},"targetPosition":{"x":19612.692333283238,"y":30177.75614113461},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"id":"63794496-c94b-42f9-81cc-c588708617a6","savedPayload":{"position":{"x":19612.692333283238,"y":30177.75614113461},"targetPosition":{"x":19340.799997172242,"y":30304.54161965682},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false}}}],"id":"4b0c1ac5-515f-44a9-b9b9-e698a9c51eac","savedPayload":{"position":{"x":19520.95818119886,"y":30020.747627181314},"targetPosition":{"x":19096.210682560097,"y":30169.37320506114},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":true,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"id":"61ef0b8d-de6e-4e76-bdd5-996836760a4b","savedPayload":{"position":{"x":19212.359265532272,"y":30552.25945208198},"targetPosition":{"x":19073.301618063546,"y":30980.2348844148},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":true,"angleToParent":2,"distanceToParent":4,"arrangementStyle":0},"uiObject":{"isRunning":false,"shortcutKey":""},"tutorial":{"status":"Done"}}},{"type":"Crypto Exchange","name":"Binance US","config":"{\n \"codeName\": \"binanceus\",\n \"API\": [\n {\n \"method\": \"fetchTrades\",\n \"fetchType\": \"by Id\",\n \"fetchTradesMethod\": \"publicGetHistoricalTrades\",\n \"firstId\": \"f\"\n }\n ]\n}","project":"Superalgos","exchangeAssets":{"type":"Exchange Assets","name":"New Exchange Assets","config":"{ \n\"addMissingAssetsFilter\": { \"quotedAsset\": \"EUR\"} \n}","project":"Superalgos","assets":[{"type":"Asset","name":"Bitcoin","config":"{ \n\"codeName\": \"BTC\"\n}","project":"Superalgos","id":"5f600d91-40e6-43cc-82b0-586c5c422077","savedPayload":{"position":{"x":19512.947331594303,"y":30307.95713652808},"targetPosition":{"x":19435.301618063546,"y":30597.7348844148},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{}}},{"type":"Asset","name":"Tether","config":"{ \n\"codeName\": \"USDT\"\n}","project":"Superalgos","id":"d9a04ff0-c729-490c-84d1-d5d5a0397989","savedPayload":{"position":{"x":19725.079365950267,"y":30520.089170884043},"targetPosition":{"x":19435.301618063546,"y":30597.7348844148},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{}}}],"id":"8b0d5d47-de2c-4770-976d-14a006ac25e7","savedPayload":{"position":{"x":19435.301618063546,"y":30597.7348844148},"targetPosition":{"x":19223.169583707582,"y":30809.866918770764},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false,"shortcutKey":"E"}}},"exchangeMarkets":{"type":"Exchange Markets","name":"New Exchange Markets","code":"{ \n\"codeName\": \"Write here the code name of the Market here.\"\n}","project":"Superalgos","markets":[{"type":"Market","name":"BTC/USDT","config":"{ \n\"codeName\": \"BTC/USDT\"\n}","project":"Superalgos","baseAsset":{"type":"Market Base Asset","name":"Bitcoin","project":"Superalgos","id":"0f7ece91-d8ef-4c4b-be95-59fb64b5eaf9","savedPayload":{"position":{"x":20112.947331594303,"y":30732.221205240006},"targetPosition":{"x":19823.169583707582,"y":30809.866918770764},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":3,"distanceToParent":3,"arrangementStyle":0},"uiObject":{},"referenceParent":{"type":"Asset","name":"Bitcoin","id":"5f600d91-40e6-43cc-82b0-586c5c422077"}}},"quotedAsset":{"type":"Market Quoted Asset","name":"Tether","project":"Superalgos","id":"a8005fb7-1737-43af-882c-3183f2e94f41","savedPayload":{"position":{"x":20112.947331594303,"y":30887.51263230152},"targetPosition":{"x":19823.169583707582,"y":30809.866918770764},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":3,"distanceToParent":3,"arrangementStyle":0},"uiObject":{},"referenceParent":{"type":"Asset","name":"Tether","id":"d9a04ff0-c729-490c-84d1-d5d5a0397989"}}},"id":"6af7c681-a924-4e65-a8aa-a45589e12bde","savedPayload":{"position":{"x":19823.169583707582,"y":30809.866918770764},"targetPosition":{"x":19523.169583707582,"y":30809.866918770764},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":3,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false}}}],"id":"95f252bb-4047-4bfa-8c93-66618b64d419","savedPayload":{"position":{"x":19523.169583707582,"y":30809.866918770764},"targetPosition":{"x":19223.169583707582,"y":30809.866918770764},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"exchangeAccounts":{"type":"Exchange Accounts","name":"New Exchange Accounts","project":"Superalgos","userAccounts":[{"type":"User Account","name":"New User Account","project":"Superalgos","userAssets":{"type":"User Assets","name":"New User Assets","project":"Superalgos","assets":[{"type":"Exchange Account Asset","name":"Bitcoin","project":"Superalgos","id":"ef552b0e-ad3c-48a5-8a51-b57f37259043","savedPayload":{"position":{"x":20226.98914819295,"y":31234.13098748269},"targetPosition":{"x":19937.21140030623,"y":31311.77670101345},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{},"referenceParent":{"type":"Asset","name":"Bitcoin","id":"5f600d91-40e6-43cc-82b0-586c5c422077"}}},{"type":"Exchange Account Asset","name":"Tether","project":"Superalgos","id":"f5017c63-704e-4c72-a652-974ae842a2af","savedPayload":{"position":{"x":20149.343434662194,"y":31523.908735369412},"targetPosition":{"x":19937.21140030623,"y":31311.77670101345},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{},"referenceParent":{"type":"Asset","name":"Tether","id":"d9a04ff0-c729-490c-84d1-d5d5a0397989"}}}],"id":"75edbc56-de4a-4f00-9471-d8978fa1d85e","savedPayload":{"position":{"x":19937.21140030623,"y":31311.77670101345},"targetPosition":{"x":19647.43365241951,"y":31234.13098748269},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"userKeys":{"type":"User Keys","name":"New User Keys","project":"Superalgos","keys":[{"type":"Exchange Account Key","name":"Key for Lighting Strike","config":"{ \n\"codeName\": \"Paste your exchange API name or label\",\n\"secret\": \"Paste your exchange API secret key\"\n}","project":"Superalgos","id":"dfa910d1-ca6f-4d7d-9935-62f051005199","savedPayload":{"position":{"x":19802.725079481024,"y":31813.686483256133},"targetPosition":{"x":19725.079365950267,"y":31523.908735369412},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":true,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{}}}],"id":"d4f8319e-bc33-4a59-9444-ec4d44e0f1ae","savedPayload":{"position":{"x":19725.079365950267,"y":31523.908735369412},"targetPosition":{"x":19647.43365241951,"y":31234.13098748269},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"id":"3c4b38ad-2fe0-4224-80dc-d01bbd5c9ff5","savedPayload":{"position":{"x":19647.43365241951,"y":31234.13098748269},"targetPosition":{"x":19435.301618063546,"y":31021.998953126727},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false}}}],"id":"97859cdc-92f3-43a7-9170-05f02953e39a","savedPayload":{"position":{"x":19435.301618063546,"y":31021.998953126727},"targetPosition":{"x":19223.169583707582,"y":30809.866918770764},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"id":"d763fdb6-bfe0-4fd2-9b1f-0a12ead4098b","savedPayload":{"position":{"x":19337.80498159516,"y":30616.177236946074},"targetPosition":{"x":19073.301618063546,"y":30980.2348844148},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":true,"angleToParent":2,"distanceToParent":4,"arrangementStyle":0},"uiObject":{"isRunning":false,"shortcutKey":""}}},{"type":"Crypto Exchange","name":"Bitfinex","config":"{\n \"codeName\": \"bitfinex\",\n \"API\": [\n {\n \"rateLimit\": 999\n }\n ]\n}","project":"Superalgos","exchangeAssets":{"type":"Exchange Assets","name":"New Exchange Assets","config":"{ \n\"addMissingAssetsFilter\": { \"quotedAsset\": \"USDT\"} \n}","project":"Superalgos","assets":[{"type":"Asset","name":"Bitcoin","config":"{\n \"codeName\": \"BTC\"\n}","project":"Superalgos","id":"fa6fb871-10ad-4b25-ba74-b37d6a9a3025","savedPayload":{"position":{"x":19651.24733491461,"y":30138.234951669678},"targetPosition":{"x":19709.481620062677,"y":30355.56826258472},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":2,"arrangementStyle":0},"uiObject":{}}},{"type":"Asset","name":"Tether","config":"{\n \"codeName\": \"USDT\"\n}","project":"Superalgos","id":"2de2fe8f-a38b-4778-8e24-d318888c629f","savedPayload":{"position":{"x":19868.58064582965,"y":30196.469236817746},"targetPosition":{"x":19709.481620062677,"y":30355.56826258472},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":2,"arrangementStyle":0},"uiObject":{}}}],"id":"33508b53-2769-4f3d-8c98-9fa37e5cbf5b","savedPayload":{"position":{"x":19709.481620062677,"y":30355.56826258472},"targetPosition":{"x":19593.013049766545,"y":30790.2348844148},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"exchangeMarkets":{"type":"Exchange Markets","name":"New Exchange Markets","project":"Superalgos","markets":[{"type":"Market","name":"BTC/USDT","config":"{\n \"codeName\": \"BTC/USDT\"\n}","project":"Superalgos","baseAsset":{"type":"Market Base Asset","name":"Bitcoin","project":"Superalgos","id":"de06f331-5653-4539-acf4-603fa7f6b30d","savedPayload":{"position":{"x":20597.435913172543,"y":29950.5234527118},"targetPosition":{"x":20372.435913172543,"y":30340.2348844148},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{},"referenceParent":{"type":"Asset","name":"Bitcoin","id":"fa6fb871-10ad-4b25-ba74-b37d6a9a3025"}}},"quotedAsset":{"type":"Market Quoted Asset","name":"Tether","project":"Superalgos","id":"5108ee82-6b9f-4067-9a57-5b29647a26bc","savedPayload":{"position":{"x":20822.435913172543,"y":30340.2348844148},"targetPosition":{"x":20372.435913172543,"y":30340.2348844148},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{},"referenceParent":{"type":"Asset","name":"Tether","id":"2de2fe8f-a38b-4778-8e24-d318888c629f"}}},"id":"b0230cdf-6725-4d65-b633-390272cfb6c5","savedPayload":{"position":{"x":20372.435913172543,"y":30340.2348844148},"targetPosition":{"x":19982.724481469544,"y":30565.2348844148},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false}}}],"id":"4d4ad5a1-81a7-4f92-83db-99f57ce261bb","savedPayload":{"position":{"x":19982.724481469544,"y":30565.2348844148},"targetPosition":{"x":19593.013049766545,"y":30790.2348844148},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"exchangeAccounts":{"type":"Exchange Accounts","name":"New Exchange Accounts","project":"Superalgos","userAccounts":[{"type":"User Account","name":"New User Account","project":"Superalgos","userAssets":{"type":"User Assets","name":"New User Assets","project":"Superalgos","assets":[{"type":"Exchange Account Asset","name":"Bitcoin","project":"Superalgos","id":"19d9de75-5c17-4226-9dd3-947b553bd1a1","savedPayload":{"position":{"x":21056.111941023762,"y":30747.604428943956},"targetPosition":{"x":20897.01291525679,"y":30906.70345471093},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":2,"arrangementStyle":0},"uiObject":{},"referenceParent":{"type":"Asset","name":"Bitcoin","id":"fa6fb871-10ad-4b25-ba74-b37d6a9a3025"}}},{"type":"Exchange Account Asset","name":"Tether","project":"Superalgos","id":"f03bae52-5924-42a5-94ff-43e278d1cef2","savedPayload":{"position":{"x":21114.34622617183,"y":30964.937739858997},"targetPosition":{"x":20897.01291525679,"y":30906.70345471093},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":2,"arrangementStyle":0},"uiObject":{},"referenceParent":{"type":"Asset","name":"Tether","id":"2de2fe8f-a38b-4778-8e24-d318888c629f"}}}],"id":"29d52baf-645c-4d8f-9631-ebd391b4c815","savedPayload":{"position":{"x":20897.01291525679,"y":30906.70345471093},"targetPosition":{"x":20462.346293426708,"y":31023.172025007065},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"userKeys":{"type":"User Keys","name":"New User Keys","project":"Superalgos","keys":[{"type":"Exchange Account Key","name":"New Exchange Account Key","config":"{ \n\"codeName\": \"Paste your exchange API name or label\",\n\"secret\": \"Paste your exchange API secret key\"\n}","project":"Superalgos","id":"d615c33d-c6cf-4572-ac32-8e9ddeb5bb52","savedPayload":{"position":{"x":21098.7423964946,"y":31659.568128074956},"targetPosition":{"x":20780.544344960654,"y":31341.37007654101},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":3,"arrangementStyle":0},"uiObject":{}}}],"id":"0c189040-6318-483c-b6d7-982370a3298d","savedPayload":{"position":{"x":20780.544344960654,"y":31341.37007654101},"targetPosition":{"x":20462.346293426708,"y":31023.172025007065},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"id":"cd60de4a-d17c-4ba7-936a-cbf2305fe3bb","savedPayload":{"position":{"x":20462.346293426708,"y":31023.172025007065},"targetPosition":{"x":20027.679671596627,"y":30906.703454710932},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false}}}],"id":"d247f4f5-6f16-4a59-a4a5-6d1554b43562","savedPayload":{"position":{"x":20027.679671596627,"y":30906.703454710932},"targetPosition":{"x":19593.013049766545,"y":30790.2348844148},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"id":"6c076027-683d-4778-8a6a-e60984980fdf","savedPayload":{"position":{"x":19437.359265532272,"y":30715.731520883186},"targetPosition":{"x":19073.301618063546,"y":30980.2348844148},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":true,"angleToParent":2,"distanceToParent":4,"arrangementStyle":0},"uiObject":{"isRunning":false}}},{"type":"Crypto Exchange","name":"Bittrex","config":"{\n \"codeName\": \"bittrex\",\n \"API\": [\n {\n \"method\": \"fetch_ohlcv\",\n \"limit\": 2\n }\n ]\n}","project":"Superalgos","exchangeAssets":{"type":"Exchange Assets","name":"New Exchange Assets","config":"{ \n\"addMissingAssetsFilter\": { \"quotedAsset\": \"USDT\"} \n}","project":"Superalgos","assets":[{"type":"Asset","name":"BTC","config":"{\n \"codeName\": \"BTC\"\n}","project":"Superalgos","id":"41164633-9a2a-4123-88f0-7f9acb42d68a","savedPayload":{"position":{"x":19682.021594969836,"y":29990.84101042175},"targetPosition":{"x":19705.57277527916,"y":30440.22430106131},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{}}},{"type":"Asset","name":"USDT","config":"{\n \"codeName\": \"USDT\"\n}","project":"Superalgos","id":"fab49590-9900-4352-a8dc-e464471f8def","savedPayload":{"position":{"x":20082.9745308546,"y":30195.136735304546},"targetPosition":{"x":19705.57277527916,"y":30440.22430106131},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{}}}],"id":"88d4ef94-f030-42df-9115-69d9611317b1","savedPayload":{"position":{"x":19705.57277527916,"y":30440.22430106131},"targetPosition":{"x":19501.277050396366,"y":30841.177236946074},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"exchangeMarkets":{"type":"Exchange Markets","name":"New Exchange Markets","project":"Superalgos","markets":[{"type":"Market","name":"BTC/USDT","config":"{\n \"codeName\": \"BTC/USDT\"\n}","project":"Superalgos","baseAsset":{"type":"Market Base Asset","name":"BTC","project":"Superalgos","id":"fc48c4e5-ca22-4343-862b-297182111709","savedPayload":{"position":{"x":20658.336687923493,"y":30228.646770543794},"targetPosition":{"x":20357.227915062005,"y":30563.061942008622},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{},"referenceParent":{"type":"Asset","name":"BTC","id":"41164633-9a2a-4123-88f0-7f9acb42d68a"}}},"quotedAsset":{"type":"Market Quoted Asset","name":"USDT","project":"Superalgos","id":"9b0a49d7-b6df-4489-bbdf-b2cb19f585cd","savedPayload":{"position":{"x":20797.39433539222,"y":30656.622202876613},"targetPosition":{"x":20357.227915062005,"y":30563.061942008622},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{},"referenceParent":{"type":"Asset","name":"USDT","id":"fab49590-9900-4352-a8dc-e464471f8def"}}},"id":"f1770733-f08a-4d8d-a64b-b569ee2a4d7b","savedPayload":{"position":{"x":20357.227915062005,"y":30563.061942008622},"targetPosition":{"x":19929.252482729185,"y":30702.11958947735},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false}}}],"id":"7fe8234d-9a39-4b28-bf98-43b4fdb57ee5","savedPayload":{"position":{"x":19929.252482729185,"y":30702.11958947735},"targetPosition":{"x":19501.277050396366,"y":30841.177236946074},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"exchangeAccounts":{"type":"Exchange Accounts","name":"New Exchange Accounts","project":"Superalgos","userAccounts":[{"type":"User Account","name":"New User Account","project":"Superalgos","userAssets":{"type":"User Assets","name":"New User Assets","project":"Superalgos","assets":[{"type":"Exchange Account Asset","name":"BTC","project":"Superalgos","id":"644896f8-63ea-45ca-bb42-8b9c6f661bb5","savedPayload":{"position":{"x":20422.08053697119,"y":30792.919971058607},"targetPosition":{"x":20139.02922028961,"y":30976.73564537618},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{},"referenceParent":{"type":"Asset","name":"BTC","id":"41164633-9a2a-4123-88f0-7f9acb42d68a"}}},{"type":"Exchange Account Asset","name":"USDT","project":"Superalgos","id":"f845c71a-aaef-43df-9fb7-fbb551443475","savedPayload":{"position":{"x":20439.743922203183,"y":31129.957439038277},"targetPosition":{"x":20139.02922028961,"y":30976.73564537618},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{},"referenceParent":{"type":"Asset","name":"USDT","id":"fab49590-9900-4352-a8dc-e464471f8def"}}}],"id":"5ba7fe13-1e0f-403a-8f4b-8e3968d2e5e2","savedPayload":{"position":{"x":20139.02922028961,"y":30976.73564537618},"targetPosition":{"x":19801.99175230994,"y":30994.399030608172},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":4,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"userKeys":{"type":"User Keys","name":"New User Keys","project":"Superalgos","keys":[{"type":"Exchange Account Key","name":"New Exchange Account Key","config":"{ \n\"codeName\": \"Paste your exchange API name or label\",\n\"secret\": \"Paste your exchange API secret key\"\n}","project":"Superalgos","id":"e926fbb8-d2ac-4e3d-aa59-a0a828d202fd","savedPayload":{"position":{"x":20047.0793180667,"y":31371.800786183612},"targetPosition":{"x":19924.53553518832,"y":31183.099908395892},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":3,"arrangementStyle":0},"uiObject":{}}}],"id":"4fbe41e1-cb15-4bc2-a3de-681c5b22cc97","savedPayload":{"position":{"x":19924.53553518832,"y":31183.099908395892},"targetPosition":{"x":19801.99175230994,"y":30994.399030608172},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"id":"ab9fe180-1c07-44de-a0a1-863761ac52d6","savedPayload":{"position":{"x":19801.99175230994,"y":30994.399030608172},"targetPosition":{"x":19601.515284367557,"y":30892.251168166775},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}}],"id":"584f29ca-9b3c-4b7f-a2b0-aab4180ecefd","savedPayload":{"position":{"x":19601.515284367557,"y":30892.251168166775},"targetPosition":{"x":19501.277050396366,"y":30841.177236946074},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":1,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"id":"f598f002-8fc5-491f-888e-07d017ea83c6","savedPayload":{"position":{"x":19501.277050396366,"y":30841.177236946074},"targetPosition":{"x":19073.301618063546,"y":30980.2348844148},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":true,"angleToParent":2,"distanceToParent":4,"arrangementStyle":0},"uiObject":{"isRunning":false}}},{"type":"Crypto Exchange","name":"Coinbase Pro","config":"{\n \"codeName\": \"coinbasepro\",\n \"API\": [\n {\n \"method\": \"fetch_ohlcv\",\n \"limit\": 300\n }\n ]\n}","project":"Superalgos","exchangeAssets":{"type":"Exchange Assets","name":"New Exchange Assets","config":"{ \n\"addMissingAssetsFilter\": { \"quotedAsset\": \"USDT\"} \n}","project":"Superalgos","assets":[{"type":"Asset","name":"BTC","config":"{\n \"codeName\": \"BTC\"\n}","project":"Superalgos","id":"ee182378-a852-48d9-970a-d1741fa24003","savedPayload":{"position":{"x":19711.51778640455,"y":30712.469203190307},"targetPosition":{"x":19682.40064383052,"y":30821.135858647827},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":2,"arrangementStyle":0},"uiObject":{}}},{"type":"Asset","name":"USDC","config":"{\n \"codeName\": \"USDC\"\n}","project":"Superalgos","id":"a4229bf5-90b6-4590-90f4-fdec3cd60df9","savedPayload":{"position":{"x":19791.06729928804,"y":30792.018716073795},"targetPosition":{"x":19682.40064383052,"y":30821.135858647827},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":2,"arrangementStyle":0},"uiObject":{}}}],"id":"5e970185-b876-4d70-af88-e4944e992801","savedPayload":{"position":{"x":19682.40064383052,"y":30821.135858647827},"targetPosition":{"x":19523.301618063546,"y":30980.2348844148},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":2,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"exchangeMarkets":{"type":"Exchange Markets","name":"New Exchange Markets","project":"Superalgos","markets":[{"type":"Market","name":"BTC/USDC","config":"{ \n\"codeName\": \"Type the name of the market\"\n}","project":"Superalgos","baseAsset":{"type":"Market Base Asset","name":"BTC","project":"Superalgos","id":"b6375bea-7164-4e45-89cb-80a1ec275c52","savedPayload":{"position":{"x":20813.013049766545,"y":30755.2348844148},"targetPosition":{"x":20423.301618063546,"y":30980.2348844148},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{},"referenceParent":{"type":"Asset","name":"BTC","id":"ee182378-a852-48d9-970a-d1741fa24003"}}},"quotedAsset":{"type":"Market Quoted Asset","name":"USDC","project":"Superalgos","id":"bb8913af-3d8c-4d31-af21-457d5d6ab9cc","savedPayload":{"position":{"x":20813.013049766545,"y":31205.2348844148},"targetPosition":{"x":20423.301618063546,"y":30980.2348844148},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{},"referenceParent":{"type":"Asset","name":"USDC","id":"a4229bf5-90b6-4590-90f4-fdec3cd60df9"}}},"id":"cbabed50-b6b1-4f1b-b750-0f802bd36f6e","savedPayload":{"position":{"x":20423.301618063546,"y":30980.2348844148},"targetPosition":{"x":19973.301618063546,"y":30980.2348844148},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false}}}],"id":"f84cdb3e-86c4-4b6c-bba4-678d71440ee0","savedPayload":{"position":{"x":19973.301618063546,"y":30980.2348844148},"targetPosition":{"x":19523.301618063546,"y":30980.2348844148},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"exchangeAccounts":{"type":"Exchange Accounts","name":"New Exchange Accounts","project":"Superalgos","userAccounts":[{"type":"User Account","name":"New User Account","project":"Superalgos","userAssets":{"type":"User Assets","name":"New User Assets","project":"Superalgos","assets":[{"type":"Exchange Account Asset","name":"BTC","project":"Superalgos","id":"777bd1d0-5675-42a6-b662-a3939bf6be3f","savedPayload":{"position":{"x":20196.61677854409,"y":31218.88342306526},"targetPosition":{"x":19979.283467629048,"y":31277.11770821333},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{},"referenceParent":{"type":"Asset","name":"BTC","id":"ee182378-a852-48d9-970a-d1741fa24003"}}},{"type":"Exchange Account Asset","name":"USDC","project":"Superalgos","id":"1ba83f2c-fe9f-4a79-b0ee-52eb70b342bc","savedPayload":{"position":{"x":20138.38249339602,"y":31436.2167339803},"targetPosition":{"x":19979.283467629048,"y":31277.11770821333},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{},"referenceParent":{"type":"Asset","name":"USDC","id":"a4229bf5-90b6-4590-90f4-fdec3cd60df9"}}}],"id":"3975e43a-780e-4e9e-88b3-8dc946efab78","savedPayload":{"position":{"x":19979.283467629048,"y":31277.11770821333},"targetPosition":{"x":19761.950156714007,"y":31218.88342306526},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"userKeys":{"type":"User Keys","name":"New User Keys","project":"Superalgos","keys":[{"type":"Exchange Account Key","name":"New Exchange Account Key","config":"{ \n\"codeName\": \"Paste your exchange API name or label\",\n\"secret\": \"Paste your exchange API secret key\"\n}","project":"Superalgos","id":"17e78895-a58f-4bf3-b484-07871243adcc","savedPayload":{"position":{"x":19878.418727010143,"y":31653.550044895343},"targetPosition":{"x":19820.184441862075,"y":31436.2167339803},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":3,"arrangementStyle":0},"uiObject":{}}}],"id":"71cd3cd3-7d6f-4a77-b383-cf4d14c90ac7","savedPayload":{"position":{"x":19820.184441862075,"y":31436.2167339803},"targetPosition":{"x":19761.950156714007,"y":31218.88342306526},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"id":"7d6893e0-8262-4bfe-97c6-54cf7f1d1559","savedPayload":{"position":{"x":19761.950156714007,"y":31218.88342306526},"targetPosition":{"x":19602.851130947034,"y":31059.78439729829},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}}],"id":"68dc9fd9-7d27-4102-821c-91d69fe98858","savedPayload":{"position":{"x":19602.851130947034,"y":31059.78439729829},"targetPosition":{"x":19523.301618063546,"y":30980.2348844148},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":1,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"id":"23ec7356-eed9-4a26-ace4-f21ae0d1e43e","savedPayload":{"position":{"x":19523.301618063546,"y":30980.2348844148},"targetPosition":{"x":19073.301618063546,"y":30980.2348844148},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":true,"angleToParent":2,"distanceToParent":4,"arrangementStyle":0},"uiObject":{"isRunning":false}}},{"type":"Crypto Exchange","name":"FTX","config":"{\n \"codeName\": \"ftx\"\n}","project":"Superalgos","exchangeAssets":{"type":"Exchange Assets","name":"New Exchange Assets","config":"{ \n\"addMissingAssetsFilter\": { \"quotedAsset\": \"EUR\"} \n}","project":"Superalgos","assets":[{"type":"Asset","name":"Bitcoin","config":"{ \n\"codeName\": \"BTC\"\n}","project":"Superalgos","id":"51d196fb-b457-49f7-bae2-b0ef554154a3","savedPayload":{"position":{"x":19285.301618063546,"y":30915.927263279467},"targetPosition":{"x":19435.301618063546,"y":31175.7348844148},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{}}},{"type":"Asset","name":"USD","config":"{\n \"codeName\": \"USD\"\n}","project":"Superalgos","id":"85b644de-4b78-486d-a689-5db24484bf33","savedPayload":{"position":{"x":19585.301618063546,"y":30915.927263279467},"targetPosition":{"x":19435.301618063546,"y":31175.7348844148},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{}}}],"id":"7c0b83f3-d4f6-457a-881f-9cd73f293d1c","savedPayload":{"position":{"x":19435.301618063546,"y":31175.7348844148},"targetPosition":{"x":19435.301618063546,"y":31475.7348844148},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false,"shortcutKey":"E"}}},"exchangeMarkets":{"type":"Exchange Markets","name":"New Exchange Markets","code":"{ \n\"codeName\": \"Write here the code name of the Market here.\"\n}","project":"Superalgos","markets":[{"type":"Market","name":"BTC/USD","config":"{\n \"codeName\": \"BTC/USD\"\n}","project":"Superalgos","baseAsset":{"type":"Market Base Asset","name":"Bitcoin","project":"Superalgos","id":"6b882b1c-d15c-4499-aa93-9f80e3ccb59a","savedPayload":{"position":{"x":20009.565686775473,"y":30791.66319456754},"targetPosition":{"x":19859.565686775473,"y":31051.470815702873},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":3,"distanceToParent":3,"arrangementStyle":0},"uiObject":{},"referenceParent":{"type":"Asset","name":"Bitcoin","id":"51d196fb-b457-49f7-bae2-b0ef554154a3"}}},"quotedAsset":{"type":"Market Quoted Asset","name":"USD","project":"Superalgos","id":"6eada284-7adc-4eda-9448-7165704e350e","savedPayload":{"position":{"x":20119.373307910806,"y":30901.470815702873},"targetPosition":{"x":19859.565686775473,"y":31051.470815702873},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":3,"distanceToParent":3,"arrangementStyle":0},"uiObject":{},"referenceParent":{"type":"Asset","name":"USD","id":"85b644de-4b78-486d-a689-5db24484bf33"}}},"id":"f4814fb1-d09a-45ad-8352-c0743b3a8558","savedPayload":{"position":{"x":19859.565686775473,"y":31051.470815702873},"targetPosition":{"x":19647.43365241951,"y":31263.602850058836},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":3,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false}}}],"id":"f8c75d46-aa08-4579-a4a3-ea797f70944d","savedPayload":{"position":{"x":19647.43365241951,"y":31263.602850058836},"targetPosition":{"x":19435.301618063546,"y":31475.7348844148},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"exchangeAccounts":{"type":"Exchange Accounts","name":"New Exchange Accounts","project":"Superalgos","userAccounts":[{"type":"User Account","name":"New User Account","project":"Superalgos","userAssets":{"type":"User Assets","name":"New User Assets","project":"Superalgos","assets":[{"type":"Exchange Account Asset","name":"Bitcoin","project":"Superalgos","id":"6e4dc8ba-da96-43c5-bf8c-71ee115ae628","savedPayload":{"position":{"x":20445.10923919888,"y":31065.927263279467},"targetPosition":{"x":20295.10923919888,"y":31325.7348844148},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{},"referenceParent":{"type":"Asset","name":"Bitcoin","id":"51d196fb-b457-49f7-bae2-b0ef554154a3"}}},{"type":"Exchange Account Asset","name":"USD","project":"Superalgos","id":"e4ba801d-fa96-4fed-a520-e6e80f3f67d1","savedPayload":{"position":{"x":20595.10923919888,"y":31325.7348844148},"targetPosition":{"x":20295.10923919888,"y":31325.7348844148},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{},"referenceParent":{"type":"Asset","name":"USD","id":"85b644de-4b78-486d-a689-5db24484bf33"}}}],"id":"421bb949-bde1-41d3-95b0-7b6b3c3ebf0c","savedPayload":{"position":{"x":20295.10923919888,"y":31325.7348844148},"targetPosition":{"x":20035.301618063546,"y":31475.7348844148},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"userKeys":{"type":"User Keys","name":"New User Keys","project":"Superalgos","keys":[{"type":"Exchange Account Key","name":"Key for Lighting Strike","config":"{ \n\"codeName\": \"Paste your exchange API name or label\",\n\"secret\": \"Paste your exchange API secret key\"\n}","project":"Superalgos","id":"ffd11b5a-751b-4264-bb69-f2c094ffe341","savedPayload":{"position":{"x":20554.91686033421,"y":31775.7348844148},"targetPosition":{"x":20295.10923919888,"y":31625.7348844148},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":true,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{}}}],"id":"cad1a06c-8ce7-4eb0-8046-924764a45662","savedPayload":{"position":{"x":20295.10923919888,"y":31625.7348844148},"targetPosition":{"x":20035.301618063546,"y":31475.7348844148},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"id":"52652029-df80-42d5-8300-843b764a1b47","savedPayload":{"position":{"x":20035.301618063546,"y":31475.7348844148},"targetPosition":{"x":19735.301618063546,"y":31475.7348844148},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false}}}],"id":"928314c7-c4a7-4aec-8096-074e557a71d0","savedPayload":{"position":{"x":19735.301618063546,"y":31475.7348844148},"targetPosition":{"x":19435.301618063546,"y":31475.7348844148},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"id":"b3e7f4de-1ca4-442f-8898-cb7397dc45d3","savedPayload":{"position":{"x":19501.277050396366,"y":31119.292531883526},"targetPosition":{"x":19073.301618063546,"y":30980.2348844148},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":true,"angleToParent":2,"distanceToParent":4,"arrangementStyle":0},"uiObject":{"isRunning":false,"shortcutKey":""}}},{"type":"Crypto Exchange","name":"Kraken","config":"{ \n\"codeName\": \"kraken\"\n}","project":"Superalgos","exchangeAssets":{"type":"Exchange Assets","name":"New Exchange Assets","config":"{\n \"addMissingAssetsFilter\": {\n \"quotedAsset\": \"USDT\"\n }\n}","project":"Superalgos","assets":[{"type":"Asset","name":"BTC","config":"{\n \"codeName\": \"BTC\"\n}","project":"Superalgos","id":"a18c644d-3d51-413e-8abe-dd7698c2d03a","savedPayload":{"position":{"x":19564.91960434743,"y":31467.40024970227},"targetPosition":{"x":19453.382057442876,"y":31482.084446327026},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":2,"arrangementStyle":0},"uiObject":{}}},{"type":"Asset","name":"USDT","config":"{\n \"codeName\": \"USDT\"\n}","project":"Superalgos","id":"e45ae556-e162-4d1f-ac5e-f8245d3d7f70","savedPayload":{"position":{"x":19521.86771820636,"y":31571.33669710979},"targetPosition":{"x":19453.382057442876,"y":31482.084446327026},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":2,"arrangementStyle":0},"uiObject":{}}}],"id":"2a7dfb85-9179-4c30-9b63-072adaa7b317","savedPayload":{"position":{"x":19453.382057442876,"y":31482.084446327026},"targetPosition":{"x":19245.509162627837,"y":31395.98067404488},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":2,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"exchangeMarkets":{"type":"Exchange Markets","name":"New Exchange Markets","project":"Superalgos","markets":[{"type":"Market","name":"BTC/USDT","config":"{\n \"codeName\": \"USDT/BTC\"\n}","project":"Superalgos","baseAsset":{"type":"Market Base Asset","name":"BTC","project":"Superalgos","id":"94349e75-3c40-4a66-bc82-61460105e591","savedPayload":{"position":{"x":19946.933254887477,"y":32501.414896358965},"targetPosition":{"x":19589.92425175642,"y":32227.47225330504},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{},"referenceParent":{"type":"Asset","name":"BTC","id":"a18c644d-3d51-413e-8abe-dd7698c2d03a"}}},"quotedAsset":{"type":"Market Quoted Asset","name":"USDT","project":"Superalgos","id":"4759c142-6e8c-4ce2-8b5c-c783f630bb3b","savedPayload":{"position":{"x":19531.187465257397,"y":32673.622440923256},"targetPosition":{"x":19589.92425175642,"y":32227.47225330504},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{},"referenceParent":{"type":"Asset","name":"USDT","id":"e45ae556-e162-4d1f-ac5e-f8245d3d7f70"}}},"id":"71f99544-bf86-49e7-8896-5f96f875f262","savedPayload":{"position":{"x":19589.92425175642,"y":32227.47225330504},"targetPosition":{"x":19417.71670719213,"y":31811.72646367496},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false}}}],"id":"07267ef1-f15a-43cb-94f6-c13075c3ba61","savedPayload":{"position":{"x":19417.71670719213,"y":31811.72646367496},"targetPosition":{"x":19245.509162627837,"y":31395.98067404488},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"exchangeAccounts":{"type":"Exchange Accounts","name":"New Exchange Accounts","project":"Superalgos","userAccounts":[{"type":"User Account","name":"New User Account","project":"Superalgos","userAssets":{"type":"User Assets","name":"New User Assets","project":"Superalgos","assets":[{"type":"Exchange Account Asset","name":"BTC","project":"Superalgos","id":"e73d040b-c8bb-40fb-8748-f73ae5780310","savedPayload":{"position":{"x":19282.693218981094,"y":32109.369611642072},"targetPosition":{"x":19145.721897454132,"y":31930.865110076546},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{},"referenceParent":{"type":"Asset","name":"BTC","id":"a18c644d-3d51-413e-8abe-dd7698c2d03a"}}},{"type":"Exchange Account Asset","name":"USDT","project":"Superalgos","id":"37ebe76e-55a2-413e-b6f5-ce54a6afb604","savedPayload":{"position":{"x":19059.618125171986,"y":32138.738004891584},"targetPosition":{"x":19145.721897454132,"y":31930.865110076546},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{},"referenceParent":{"type":"Asset","name":"USDT","id":"e45ae556-e162-4d1f-ac5e-f8245d3d7f70"}}}],"id":"695d852f-eab0-4114-a8a4-323efa22ceb7","savedPayload":{"position":{"x":19145.721897454132,"y":31930.865110076546},"targetPosition":{"x":19116.35350420462,"y":31707.790016267438},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"userKeys":{"type":"User Keys","name":"New User Keys","project":"Superalgos","keys":[{"type":"Exchange Account Key","name":"New Exchange Account Key","config":"{ \n\"codeName\": \"Paste your exchange API name or label\",\n\"secret\": \"Paste your exchange API secret key\"\n}","project":"Superalgos","id":"81b848a0-66d2-4825-a951-eca8f3713896","savedPayload":{"position":{"x":18580.839999508036,"y":32118.703980848324},"targetPosition":{"x":18937.849002639094,"y":31844.7613377944},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{}}}],"id":"28bab5eb-0cb5-434a-983c-8f5fb58c0e41","savedPayload":{"position":{"x":18937.849002639094,"y":31844.7613377944},"targetPosition":{"x":19116.35350420462,"y":31707.790016267438},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"id":"6a427672-e76c-4793-b2a8-8f9034bb323e","savedPayload":{"position":{"x":19116.35350420462,"y":31707.790016267438},"targetPosition":{"x":19202.457276486766,"y":31499.9171214524},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}}],"id":"9ff22337-d0b7-4d9e-8896-bd046802b961","savedPayload":{"position":{"x":19202.457276486766,"y":31499.9171214524},"targetPosition":{"x":19245.509162627837,"y":31395.98067404488},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":1,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"id":"793d2f4a-3315-4c18-abad-f4d74c83ac4f","savedPayload":{"position":{"x":19437.359265532272,"y":31244.738247946414},"targetPosition":{"x":19073.301618063546,"y":30980.2348844148},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":true,"angleToParent":2,"distanceToParent":4,"arrangementStyle":0},"uiObject":{"isRunning":false}}},{"type":"Crypto Exchange","name":"Kucoin","config":"{\n \"codeName\": \"kucoin\"\n}","project":"Superalgos","exchangeAssets":{"type":"Exchange Assets","name":"New Exchange Assets","config":"{ \n\"addMissingAssetsFilter\": { \"quotedAsset\": \"USDT\"} \n}","project":"Superalgos","assets":[{"type":"Asset","name":"BTC","config":"{\n \"codeName\": \"BTC\"\n}","project":"Superalgos","id":"5ce98b3f-3ec1-412b-acde-186f9a92a5e0","savedPayload":{"position":{"x":19829.745532847643,"y":31102.003746373946},"targetPosition":{"x":19648.71103240014,"y":31235.613288127985},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{}}},{"type":"Asset","name":"Tether","config":"{\n \"codeName\": \"USDT\"\n}","project":"Superalgos","id":"b866944c-c23e-4718-9300-1b803b54be5f","savedPayload":{"position":{"x":19854.937539970884,"y":31325.588993599926},"targetPosition":{"x":19648.71103240014,"y":31235.613288127985},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{}}}],"id":"747af60f-c8b9-4377-aa6c-172d4137ea23","savedPayload":{"position":{"x":19648.71103240014,"y":31235.613288127985},"targetPosition":{"x":19425.12578517416,"y":31260.80529525123},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":2,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"exchangeMarkets":{"type":"Exchange Markets","name":"New Exchange Markets","project":"Superalgos","markets":[{"type":"Market","name":"BTC/USDT","config":"{\n \"codeName\": \"BTC/USDT\"\n}","project":"Superalgos","baseAsset":{"type":"Market Base Asset","name":"BTC","project":"Superalgos","id":"69a1674d-6260-4c65-95d5-fbba592737f9","savedPayload":{"position":{"x":20573.7479911967,"y":31889.01513670337},"targetPosition":{"x":20128.77411939539,"y":31821.94611692409},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{},"referenceParent":{"type":"Asset","name":"BTC","id":"5ce98b3f-3ec1-412b-acde-186f9a92a5e0"}}},"quotedAsset":{"type":"Market Quoted Asset","name":"Tether","project":"Superalgos","id":"135835f5-a9be-4415-aeef-03500f24b4d1","savedPayload":{"position":{"x":20293.17758036027,"y":32240.83930381398},"targetPosition":{"x":20128.77411939539,"y":31821.94611692409},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{},"referenceParent":{"type":"Asset","name":"Tether","id":"b866944c-c23e-4718-9300-1b803b54be5f"}}},"id":"4b37ca8d-e4b2-49f4-b326-7bdf785ad482","savedPayload":{"position":{"x":20128.77411939539,"y":31821.94611692409},"targetPosition":{"x":19776.949952284776,"y":31541.37570608766},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false}}}],"id":"c75f7d97-9dc2-4d3e-89eb-f8a3d5f16368","savedPayload":{"position":{"x":19776.949952284776,"y":31541.37570608766},"targetPosition":{"x":19425.12578517416,"y":31260.80529525123},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"exchangeAccounts":{"type":"Exchange Accounts","name":"New Exchange Accounts","project":"Superalgos","userAccounts":[{"type":"User Account","name":"New User Account","project":"Superalgos","userAssets":{"type":"User Assets","name":"New User Assets","project":"Superalgos","assets":[{"type":"Exchange Account Asset","name":"BTC","project":"Superalgos","id":"0fa01ebd-8837-482f-bffc-7bee682c9600","savedPayload":{"position":{"x":19802.74984518381,"y":31867.193372009642},"targetPosition":{"x":19596.523337613067,"y":31777.2176665377},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{},"referenceParent":{"type":"Asset","name":"BTC","id":"5ce98b3f-3ec1-412b-acde-186f9a92a5e0"}}},{"type":"Exchange Account Asset","name":"Tether","project":"Superalgos","id":"27131d22-9a2f-48e0-b22e-a12e23a9cb3a","savedPayload":{"position":{"x":19621.715344736313,"y":32000.80291376368},"targetPosition":{"x":19596.523337613067,"y":31777.2176665377},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{},"referenceParent":{"type":"Asset","name":"Tether","id":"b866944c-c23e-4718-9300-1b803b54be5f"}}}],"id":"0093e946-03f4-4aec-942d-c76aed12ab1a","savedPayload":{"position":{"x":19596.523337613067,"y":31777.2176665377},"targetPosition":{"x":19462.91379585903,"y":31596.1831660902},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"userKeys":{"type":"User Keys","name":"New User Keys","project":"Superalgos","keys":[{"type":"Exchange Account Key","name":"New Exchange Account Key","config":"{ \n\"codeName\": \"Paste your exchange API name or label\",\n\"secret\": \"Paste your exchange API secret key\"\n}","project":"Superalgos","id":"2a4235ac-e5ea-4484-bccd-f06c8a7275ec","savedPayload":{"position":{"x":19282.962384915147,"y":32008.636181231686},"targetPosition":{"x":19372.938090387088,"y":31802.409673660943},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":3,"arrangementStyle":0},"uiObject":{}}}],"id":"737dec0a-23ab-4044-94ba-95c8bc50c0eb","savedPayload":{"position":{"x":19372.938090387088,"y":31802.409673660943},"targetPosition":{"x":19462.91379585903,"y":31596.1831660902},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"id":"457b045e-dae5-4f53-a8b7-cab4757e5286","savedPayload":{"position":{"x":19462.91379585903,"y":31596.1831660902},"targetPosition":{"x":19437.721788735784,"y":31372.59791886422},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}}],"id":"6eff12db-8e7c-402a-9e06-ae2618f506a0","savedPayload":{"position":{"x":19437.721788735784,"y":31372.59791886422},"targetPosition":{"x":19425.12578517416,"y":31260.80529525123},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":1,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"id":"644efe9c-597a-4ddf-9e28-b33fb3b62d3e","savedPayload":{"position":{"x":19337.80498159516,"y":31344.292531883526},"targetPosition":{"x":19073.301618063546,"y":30980.2348844148},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":true,"angleToParent":2,"distanceToParent":4,"arrangementStyle":0},"uiObject":{"isRunning":false}}},{"type":"Crypto Exchange","name":"Luno","config":"{\n \"codeName\": \"luno\",\n \"API\": [\n {\n \"method\": \"fetch_ohlcv\",\n \"useFetchTradesForFetchOHLCVs\": true,\n \"maxTradesPerFetch\": 100,\n \"limit\": 200,\n \"rateLimit\": 1100\n }\n ]\n}","project":"Superalgos","exchangeAssets":{"type":"Exchange Assets","name":"New Exchange Assets","config":"{ \n\"addMissingAssetsFilter\": { \"quotedAsset\": \"EUR\"} \n}","project":"Superalgos","assets":[{"type":"Asset","name":"Bitcoin","config":"{\n \"codeName\": \"BTC\"\n}","project":"Superalgos","id":"ac9cd2e1-566d-4bf9-83b2-a60403442302","savedPayload":{"position":{"x":19965.019021441563,"y":30875.45713652808},"targetPosition":{"x":19752.8869870856,"y":31087.589170884043},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{}}},{"type":"Asset","name":"ZAR","config":"{\n \"codeName\": \"ZAR\"\n}","project":"Superalgos","id":"0aefdb7b-972c-4c98-90cd-23317f2bd51f","savedPayload":{"position":{"x":20042.66473497232,"y":31165.2348844148},"targetPosition":{"x":19752.8869870856,"y":31087.589170884043},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{}}}],"id":"ac60a01f-74b1-41f2-93f4-5b7d5cc2b2ad","savedPayload":{"position":{"x":19752.8869870856,"y":31087.589170884043},"targetPosition":{"x":19463.10923919888,"y":31165.2348844148},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false,"shortcutKey":"E"}}},"exchangeMarkets":{"type":"Exchange Markets","name":"New Exchange Markets","code":"{ \n\"codeName\": \"Write here the code name of the Market here.\"\n}","project":"Superalgos","markets":[{"type":"Market","name":"BTC/ZAR","config":"{\n \"codeName\": \"BTC/ZAR\"\n}","project":"Superalgos","baseAsset":{"type":"Market Base Asset","name":"Bitcoin","project":"Superalgos","id":"29b5f490-2015-4039-8123-f29aa76d2546","savedPayload":{"position":{"x":20272.502229356265,"y":31542.880597945557},"targetPosition":{"x":19982.724481469544,"y":31465.2348844148},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":3,"distanceToParent":3,"arrangementStyle":0},"uiObject":{},"referenceParent":{"type":"Asset","name":"Bitcoin","id":"ac9cd2e1-566d-4bf9-83b2-a60403442302"}}},"quotedAsset":{"type":"Market Quoted Asset","name":"ZAR","project":"Superalgos","id":"6dffe17d-bbd1-424e-afba-9717386ae271","savedPayload":{"position":{"x":20194.856515825508,"y":31677.366918770764},"targetPosition":{"x":19982.724481469544,"y":31465.2348844148},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":3,"distanceToParent":3,"arrangementStyle":0},"uiObject":{},"referenceParent":{"type":"Asset","name":"ZAR","id":"0aefdb7b-972c-4c98-90cd-23317f2bd51f"}}},"id":"06796c17-169b-4815-969c-d33baca2b0ef","savedPayload":{"position":{"x":19982.724481469544,"y":31465.2348844148},"targetPosition":{"x":19722.91686033421,"y":31315.2348844148},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":3,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false}}}],"id":"e13d8073-26f6-4ae4-b612-aea2ec269fed","savedPayload":{"position":{"x":19722.91686033421,"y":31315.2348844148},"targetPosition":{"x":19463.10923919888,"y":31165.2348844148},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"exchangeAccounts":{"type":"Exchange Accounts","name":"New Exchange Accounts","project":"Superalgos","userAccounts":[{"type":"User Account","name":"New User Account","project":"Superalgos","userAssets":{"type":"User Assets","name":"New User Assets","project":"Superalgos","assets":[{"type":"Exchange Account Asset","name":"Bitcoin","project":"Superalgos","id":"8d70bbca-596c-4a0e-af81-dd089f823a11","savedPayload":{"position":{"x":20120.310448503078,"y":32034.568128074963},"targetPosition":{"x":19830.532700616357,"y":31956.922414544206},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{},"referenceParent":{"type":"Asset","name":"Bitcoin","id":"ac9cd2e1-566d-4bf9-83b2-a60403442302"}}},{"type":"Exchange Account Asset","name":"ZAR","project":"Superalgos","id":"fc0a7029-992c-4954-9695-fd98922b298a","savedPayload":{"position":{"x":19908.178414147114,"y":32246.700162430927},"targetPosition":{"x":19830.532700616357,"y":31956.922414544206},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{},"referenceParent":{"type":"Asset","name":"ZAR","id":"0aefdb7b-972c-4c98-90cd-23317f2bd51f"}}}],"id":"9aa9be52-1db3-4e4e-ba0b-428d3fbd69a6","savedPayload":{"position":{"x":19830.532700616357,"y":31956.922414544206},"targetPosition":{"x":19618.400666260393,"y":31744.790380188242},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"userKeys":{"type":"User Keys","name":"New User Keys","project":"Superalgos","keys":[{"type":"Exchange Account Key","name":"Key for Lighting Strike","config":"{ \n\"codeName\": \"Paste your exchange API name or label\",\n\"secret\": \"Paste your exchange API secret key\"\n}","project":"Superalgos","id":"13c27632-3079-49c6-a864-85208ce741eb","savedPayload":{"position":{"x":19463.10923919888,"y":32324.345875961684},"targetPosition":{"x":19540.754952729636,"y":32034.568128074963},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":true,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{}}}],"id":"d58f597c-56f6-4900-b153-830c39546a14","savedPayload":{"position":{"x":19540.754952729636,"y":32034.568128074963},"targetPosition":{"x":19618.400666260393,"y":31744.790380188242},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"id":"c70e6430-bccd-46c9-aa15-b91e07c4bec0","savedPayload":{"position":{"x":19618.400666260393,"y":31744.790380188242},"targetPosition":{"x":19540.754952729636,"y":31455.01263230152},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false}}}],"id":"a5039403-0e35-4949-b690-3f8cb7e56add","savedPayload":{"position":{"x":19540.754952729636,"y":31455.01263230152},"targetPosition":{"x":19463.10923919888,"y":31165.2348844148},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"id":"d4a66325-9be9-4855-8cf4-89a5795e30b6","savedPayload":{"position":{"x":19212.359265532272,"y":31408.21031674762},"targetPosition":{"x":19073.301618063546,"y":30980.2348844148},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":true,"angleToParent":2,"distanceToParent":4,"arrangementStyle":0},"uiObject":{"isRunning":false,"shortcutKey":""}}}],"id":"e3879d63-6f8f-41a3-8ac3-0349c4361722","savedPayload":{"position":{"x":19073.301618063546,"y":30980.2348844148},"targetPosition":{"x":18773.301618063546,"y":30980.2348844148},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false}}},{"type":"Crypto Exchanges","name":"Untested","project":"Superalgos","exchanges":[{"type":"Crypto Exchange","name":"ACX","config":"{ \n\"codeName\": \"acx\"\n}","project":"Superalgos","exchangeAssets":{"type":"Exchange Assets","name":"New Exchange Assets","config":"{ \n\"addMissingAssetsFilter\": { \"quotedAsset\": \"USDT\"} \n}","project":"Superalgos","assets":[],"id":"ebcb522b-ae58-46d2-9d82-a9b0beec3976","savedPayload":{"position":{"x":17935.64382962515,"y":31014.23747069523},"targetPosition":{"x":17912.64382962515,"y":30954.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":2,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"exchangeMarkets":{"type":"Exchange Markets","name":"New Exchange Markets","project":"Superalgos","markets":[],"id":"b2649588-27c6-442c-b179-f6d8817188b3","savedPayload":{"position":{"x":17954.64382962515,"y":31004.23747069523},"targetPosition":{"x":17912.64382962515,"y":30954.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"exchangeAccounts":{"type":"Exchange Accounts","name":"New Exchange Accounts","project":"Superalgos","userAccounts":[{"type":"User Account","name":"New User Account","project":"Superalgos","userAssets":{"type":"User Assets","name":"New User Assets","project":"Superalgos","assets":[],"id":"9b2051d5-7ee7-4e94-8c8d-306674889339","savedPayload":{"position":{"x":17838.64382962515,"y":30896.23747069523},"targetPosition":{"x":17766.64382962515,"y":30905.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"userKeys":{"type":"User Keys","name":"New User Keys","project":"Superalgos","keys":[{"type":"Exchange Account Key","name":"New Exchange Account Key","config":"{ \n\"codeName\": \"Paste your exchange API name or label\",\n\"secret\": \"Paste your exchange API secret key\"\n}","project":"Superalgos","id":"1d5461aa-d26c-4df5-b383-8c83e311b8ca","savedPayload":{"position":{"x":17643.64382962515,"y":30952.23747069523},"targetPosition":{"x":17698.64382962515,"y":30973.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{}}}],"id":"c6372400-de52-4b63-97f3-f748aac9c63f","savedPayload":{"position":{"x":17698.64382962515,"y":30973.23747069523},"targetPosition":{"x":17766.64382962515,"y":30905.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"id":"c948314e-2247-4234-b83d-cc2c1b152665","savedPayload":{"position":{"x":17766.64382962515,"y":30905.23747069523},"targetPosition":{"x":17837.64382962515,"y":30978.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}}],"id":"04ccb742-ef1b-4138-b38d-a6b0d92f2f8e","savedPayload":{"position":{"x":17837.64382962515,"y":30978.23747069523},"targetPosition":{"x":17912.64382962515,"y":30954.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":1,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"id":"e9c21b2d-de21-43b5-8b48-51367a8c981c","savedPayload":{"position":{"x":19198.820555898394,"y":30544.014225056424},"targetPosition":{"x":18473.301618063546,"y":31499.850126685462},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":true,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}},{"type":"Crypto Exchange","name":"AOFEX","config":"{ \n\"codeName\": \"aofex\"\n}","project":"Superalgos","exchangeAssets":{"type":"Exchange Assets","name":"New Exchange Assets","config":"{ \n\"addMissingAssetsFilter\": { \"quotedAsset\": \"USDT\"} \n}","project":"Superalgos","assets":[],"id":"623ef91b-04c0-4bd5-ac0d-b32c809be3ea","savedPayload":{"position":{"x":17973.64382962515,"y":30923.23747069523},"targetPosition":{"x":17950.64382962515,"y":30994.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":2,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"exchangeMarkets":{"type":"Exchange Markets","name":"New Exchange Markets","project":"Superalgos","markets":[],"id":"9d0b5855-59a6-4dda-9a4b-33d7a44d582e","savedPayload":{"position":{"x":17901.64382962515,"y":30994.23747069523},"targetPosition":{"x":17950.64382962515,"y":30994.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"exchangeAccounts":{"type":"Exchange Accounts","name":"New Exchange Accounts","project":"Superalgos","userAccounts":[{"type":"User Account","name":"New User Account","project":"Superalgos","userAssets":{"type":"User Assets","name":"New User Assets","project":"Superalgos","assets":[],"id":"e898e569-0dd3-4a22-baa5-caaace66d4ed","savedPayload":{"position":{"x":18062.64382962515,"y":30838.23747069523},"targetPosition":{"x":17982.64382962515,"y":30899.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"userKeys":{"type":"User Keys","name":"New User Keys","project":"Superalgos","keys":[{"type":"Exchange Account Key","name":"New Exchange Account Key","config":"{ \n\"codeName\": \"Paste your exchange API name or label\",\n\"secret\": \"Paste your exchange API secret key\"\n}","project":"Superalgos","id":"64a69d3d-15ff-41c3-a926-5ec93c932ab1","savedPayload":{"position":{"x":17822.64382962515,"y":31052.23747069523},"targetPosition":{"x":17893.64382962515,"y":30981.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{}}}],"id":"ae2785c5-75a1-44fc-a71b-363d88cb5dac","savedPayload":{"position":{"x":17893.64382962515,"y":30981.23747069523},"targetPosition":{"x":17982.64382962515,"y":30899.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"id":"07ea69aa-7357-43b1-b548-a4c4fab70c55","savedPayload":{"position":{"x":17982.64382962515,"y":30899.23747069523},"targetPosition":{"x":17971.64382962515,"y":30962.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}}],"id":"2146b410-fc4e-452d-ae57-5d58c9a29706","savedPayload":{"position":{"x":17971.64382962515,"y":30962.23747069523},"targetPosition":{"x":17950.64382962515,"y":30994.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":1,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"id":"c2e9bb45-97c7-47e8-b13c-56946e673c53","savedPayload":{"position":{"x":19312.897626679583,"y":30642.4829111261},"targetPosition":{"x":18473.301618063546,"y":31499.850126685462},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":true,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}},{"type":"Crypto Exchange","name":"Bequant","config":"{ \n\"codeName\": \"bequant\"\n}","project":"Superalgos","exchangeAssets":{"type":"Exchange Assets","name":"New Exchange Assets","config":"{ \n\"addMissingAssetsFilter\": { \"quotedAsset\": \"USDT\"} \n}","project":"Superalgos","assets":[],"id":"b23c8adf-c880-48fd-b4af-4b4be86cf0e5","savedPayload":{"position":{"x":18059.64382962515,"y":31101.23747069523},"targetPosition":{"x":17960.64382962515,"y":31060.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":2,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"exchangeMarkets":{"type":"Exchange Markets","name":"New Exchange Markets","project":"Superalgos","markets":[],"id":"523bd94f-68f9-457e-91fd-806c1b95e98d","savedPayload":{"position":{"x":18006.64382962515,"y":31117.23747069523},"targetPosition":{"x":17960.64382962515,"y":31060.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"exchangeAccounts":{"type":"Exchange Accounts","name":"New Exchange Accounts","project":"Superalgos","userAccounts":[{"type":"User Account","name":"New User Account","project":"Superalgos","userAssets":{"type":"User Assets","name":"New User Assets","project":"Superalgos","assets":[],"id":"9d914bb1-a68b-41ae-8666-0fcc755358c1","savedPayload":{"position":{"x":17859.64382962515,"y":30964.23747069523},"targetPosition":{"x":17936.64382962515,"y":31059.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"userKeys":{"type":"User Keys","name":"New User Keys","project":"Superalgos","keys":[{"type":"Exchange Account Key","name":"New Exchange Account Key","config":"{ \n\"codeName\": \"Paste your exchange API name or label\",\n\"secret\": \"Paste your exchange API secret key\"\n}","project":"Superalgos","id":"15d903b5-113c-465e-8120-7c46a9a85565","savedPayload":{"position":{"x":17976.64382962515,"y":31146.23747069523},"targetPosition":{"x":17943.64382962515,"y":31134.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{}}}],"id":"2d1c0bc3-abe2-4340-91bf-2eef5b98a2f0","savedPayload":{"position":{"x":17943.64382962515,"y":31134.23747069523},"targetPosition":{"x":17936.64382962515,"y":31059.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"id":"5a50d459-914c-4bfc-91e8-f15c383280eb","savedPayload":{"position":{"x":17936.64382962515,"y":31059.23747069523},"targetPosition":{"x":17931.64382962515,"y":31071.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}}],"id":"b2f2b69f-3bef-4edc-9950-5261d9f36382","savedPayload":{"position":{"x":17931.64382962515,"y":31071.23747069523},"targetPosition":{"x":17960.64382962515,"y":31060.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":1,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"id":"8e928d3e-a2c2-4341-aa2f-b753551c9479","savedPayload":{"position":{"x":19413.733766854555,"y":30754.47279035149},"targetPosition":{"x":18473.301618063546,"y":31499.850126685462},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":true,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}},{"type":"Crypto Exchange","name":"Bibox","config":"{ \n\"codeName\": \"bibox\"\n}","project":"Superalgos","exchangeAssets":{"type":"Exchange Assets","name":"New Exchange Assets","config":"{ \n\"addMissingAssetsFilter\": { \"quotedAsset\": \"USDT\"} \n}","project":"Superalgos","assets":[],"id":"13c1f22c-9a35-4d3f-b000-c96984fd6a2b","savedPayload":{"position":{"x":17995.64382962515,"y":31047.23747069523},"targetPosition":{"x":17929.64382962515,"y":31003.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":2,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"exchangeMarkets":{"type":"Exchange Markets","name":"New Exchange Markets","project":"Superalgos","markets":[],"id":"3c6df49d-70c3-468a-bdd8-6768ce6d3a9d","savedPayload":{"position":{"x":17916.64382962515,"y":31018.23747069523},"targetPosition":{"x":17929.64382962515,"y":31003.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"exchangeAccounts":{"type":"Exchange Accounts","name":"New Exchange Accounts","project":"Superalgos","userAccounts":[{"type":"User Account","name":"New User Account","project":"Superalgos","userAssets":{"type":"User Assets","name":"New User Assets","project":"Superalgos","assets":[],"id":"5a54ef39-8fba-4a5f-ac24-5f27e763e28f","savedPayload":{"position":{"x":18050.64382962515,"y":31174.23747069523},"targetPosition":{"x":17956.64382962515,"y":31128.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"userKeys":{"type":"User Keys","name":"New User Keys","project":"Superalgos","keys":[{"type":"Exchange Account Key","name":"New Exchange Account Key","config":"{ \n\"codeName\": \"Paste your exchange API name or label\",\n\"secret\": \"Paste your exchange API secret key\"\n}","project":"Superalgos","id":"08df1f45-dab0-463a-8758-359973f2620d","savedPayload":{"position":{"x":17899.64382962515,"y":31242.23747069523},"targetPosition":{"x":17959.64382962515,"y":31180.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{}}}],"id":"105b52c2-90ad-4fa1-b690-d8fab14209b4","savedPayload":{"position":{"x":17959.64382962515,"y":31180.23747069523},"targetPosition":{"x":17956.64382962515,"y":31128.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"id":"68c1ef42-1b7b-4cc6-981f-80b20dabcd89","savedPayload":{"position":{"x":17956.64382962515,"y":31128.23747069523},"targetPosition":{"x":17907.64382962515,"y":31057.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}}],"id":"fc35e5d0-ea61-42b6-979a-859f19c5ac6c","savedPayload":{"position":{"x":17907.64382962515,"y":31057.23747069523},"targetPosition":{"x":17929.64382962515,"y":31003.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":1,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"id":"e5f9ee4d-77a3-48ae-b354-b2f6a97d5e47","savedPayload":{"position":{"x":19499.738730256155,"y":30878.217715437706},"targetPosition":{"x":18473.301618063546,"y":31499.850126685462},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":true,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}},{"type":"Crypto Exchange","name":"BigONE","config":"{ \n\"codeName\": \"bigone\"\n}","project":"Superalgos","exchangeAssets":{"type":"Exchange Assets","name":"New Exchange Assets","config":"{ \n\"addMissingAssetsFilter\": { \"quotedAsset\": \"USDT\"} \n}","project":"Superalgos","assets":[],"id":"3f289513-c1c8-457c-b65a-8cf62b5f5eb5","savedPayload":{"position":{"x":17778.64382962515,"y":31071.23747069523},"targetPosition":{"x":17839.64382962515,"y":31063.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":2,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"exchangeMarkets":{"type":"Exchange Markets","name":"New Exchange Markets","project":"Superalgos","markets":[],"id":"8b365e73-1cee-496a-921f-121cb628a130","savedPayload":{"position":{"x":17798.64382962515,"y":31121.23747069523},"targetPosition":{"x":17839.64382962515,"y":31063.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"exchangeAccounts":{"type":"Exchange Accounts","name":"New Exchange Accounts","project":"Superalgos","userAccounts":[{"type":"User Account","name":"New User Account","project":"Superalgos","userAssets":{"type":"User Assets","name":"New User Assets","project":"Superalgos","assets":[],"id":"447a4f6f-cfa0-443e-9339-d7c1153ada31","savedPayload":{"position":{"x":17921.64382962515,"y":31046.23747069523},"targetPosition":{"x":17891.64382962515,"y":31102.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"userKeys":{"type":"User Keys","name":"New User Keys","project":"Superalgos","keys":[{"type":"Exchange Account Key","name":"New Exchange Account Key","config":"{ \n\"codeName\": \"Paste your exchange API name or label\",\n\"secret\": \"Paste your exchange API secret key\"\n}","project":"Superalgos","id":"0d234c53-c121-471e-bce1-a258c13cd148","savedPayload":{"position":{"x":17848.64382962515,"y":31175.23747069523},"targetPosition":{"x":17944.64382962515,"y":31086.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{}}}],"id":"816e1b6a-d790-4abd-9ae1-e203fa737af2","savedPayload":{"position":{"x":17944.64382962515,"y":31086.23747069523},"targetPosition":{"x":17891.64382962515,"y":31102.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"id":"561a57f7-8c22-4e50-840d-d983ed6bb864","savedPayload":{"position":{"x":17891.64382962515,"y":31102.23747069523},"targetPosition":{"x":17813.64382962515,"y":31064.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}}],"id":"e243bd5d-ade7-46c8-876b-6ad8c6eb5e0a","savedPayload":{"position":{"x":17813.64382962515,"y":31064.23747069523},"targetPosition":{"x":17839.64382962515,"y":31063.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":1,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"id":"fb9ee540-bf12-4dda-bf87-cb6b58fce649","savedPayload":{"position":{"x":19569.556167234667,"y":31011.7661549945},"targetPosition":{"x":18473.301618063546,"y":31499.850126685462},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":true,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}},{"type":"Crypto Exchange","name":"Binance Jersey","config":"{ \n\"codeName\": \"binanceje\"\n}","project":"Superalgos","exchangeAssets":{"type":"Exchange Assets","name":"New Exchange Assets","config":"{ \n\"addMissingAssetsFilter\": { \"quotedAsset\": \"USDT\"} \n}","project":"Superalgos","assets":[],"id":"0b979ea9-7a2d-4744-9517-2dfa632dfafc","savedPayload":{"position":{"x":17852.64382962515,"y":30989.23747069523},"targetPosition":{"x":17933.64382962515,"y":30992.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":2,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"exchangeMarkets":{"type":"Exchange Markets","name":"New Exchange Markets","project":"Superalgos","markets":[],"id":"b9a4497d-20f1-4c61-9a79-444e0fe0ddf4","savedPayload":{"position":{"x":17924.64382962515,"y":30952.23747069523},"targetPosition":{"x":17933.64382962515,"y":30992.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"exchangeAccounts":{"type":"Exchange Accounts","name":"New Exchange Accounts","project":"Superalgos","userAccounts":[{"type":"User Account","name":"New User Account","project":"Superalgos","userAssets":{"type":"User Assets","name":"New User Assets","project":"Superalgos","assets":[],"id":"1b24d8a4-ec70-4501-838c-7633f6f7288e","savedPayload":{"position":{"x":17882.64382962515,"y":31051.23747069523},"targetPosition":{"x":17942.64382962515,"y":31066.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"userKeys":{"type":"User Keys","name":"New User Keys","project":"Superalgos","keys":[{"type":"Exchange Account Key","name":"New Exchange Account Key","config":"{ \n\"codeName\": \"Paste your exchange API name or label\",\n\"secret\": \"Paste your exchange API secret key\"\n}","project":"Superalgos","id":"627472e3-638f-4d68-a917-d0844d6a227b","savedPayload":{"position":{"x":17991.64382962515,"y":31190.23747069523},"targetPosition":{"x":17986.64382962515,"y":31110.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{}}}],"id":"b8ce75fb-93c9-4ca2-9b2b-9f8ed8af34f3","savedPayload":{"position":{"x":17986.64382962515,"y":31110.23747069523},"targetPosition":{"x":17942.64382962515,"y":31066.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"id":"08b226e4-14ee-4ad3-8d96-efe77cc38489","savedPayload":{"position":{"x":17942.64382962515,"y":31066.23747069523},"targetPosition":{"x":17949.64382962515,"y":31009.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}}],"id":"2771eb11-bc72-4273-9e1b-9ac5410c6354","savedPayload":{"position":{"x":17949.64382962515,"y":31009.23747069523},"targetPosition":{"x":17933.64382962515,"y":30992.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":1,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"id":"2782350a-84a2-40ec-87c6-3c8043376a18","savedPayload":{"position":{"x":19622.085015102028,"y":31153.011970352094},"targetPosition":{"x":18473.301618063546,"y":31499.850126685462},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":true,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}},{"type":"Crypto Exchange","name":"bitbank","config":"{ \n\"codeName\": \"bitbank\"\n}","project":"Superalgos","exchangeAssets":{"type":"Exchange Assets","name":"New Exchange Assets","config":"{ \n\"addMissingAssetsFilter\": { \"quotedAsset\": \"USDT\"} \n}","project":"Superalgos","assets":[],"id":"eb6b6842-9bf7-450e-baa3-7a87541a1cf6","savedPayload":{"position":{"x":17955.64382962515,"y":31107.23747069523},"targetPosition":{"x":17941.64382962515,"y":31102.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":2,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"exchangeMarkets":{"type":"Exchange Markets","name":"New Exchange Markets","project":"Superalgos","markets":[],"id":"6353ff56-759f-457d-81f3-fdb8ae5b3e83","savedPayload":{"position":{"x":17942.64382962515,"y":31183.23747069523},"targetPosition":{"x":17941.64382962515,"y":31102.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"exchangeAccounts":{"type":"Exchange Accounts","name":"New Exchange Accounts","project":"Superalgos","userAccounts":[{"type":"User Account","name":"New User Account","project":"Superalgos","userAssets":{"type":"User Assets","name":"New User Assets","project":"Superalgos","assets":[],"id":"a2b297c7-f33b-48b9-98fa-d339c7b0ff67","savedPayload":{"position":{"x":17999.64382962515,"y":31016.23747069523},"targetPosition":{"x":17945.64382962515,"y":31116.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"userKeys":{"type":"User Keys","name":"New User Keys","project":"Superalgos","keys":[{"type":"Exchange Account Key","name":"New Exchange Account Key","config":"{ \n\"codeName\": \"Paste your exchange API name or label\",\n\"secret\": \"Paste your exchange API secret key\"\n}","project":"Superalgos","id":"9ce6c354-b294-4062-b763-421e5edb69de","savedPayload":{"position":{"x":17883.64382962515,"y":31186.23747069523},"targetPosition":{"x":17845.64382962515,"y":31202.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{}}}],"id":"547dbf6c-a292-46c0-a628-62856858121e","savedPayload":{"position":{"x":17845.64382962515,"y":31202.23747069523},"targetPosition":{"x":17945.64382962515,"y":31116.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"id":"097055b3-37e5-4100-a24b-91e404fe49a6","savedPayload":{"position":{"x":17945.64382962515,"y":31116.23747069523},"targetPosition":{"x":17897.64382962515,"y":31142.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}}],"id":"51aed4ce-0303-431e-a15f-e6f133f7a2cf","savedPayload":{"position":{"x":17897.64382962515,"y":31142.23747069523},"targetPosition":{"x":17941.64382962515,"y":31102.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":1,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"id":"6c9a96a7-ed12-4b3e-bb51-306a8da131f5","savedPayload":{"position":{"x":19656.496862548152,"y":31299.727630626137},"targetPosition":{"x":18473.301618063546,"y":31499.850126685462},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":true,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}},{"type":"Crypto Exchange","name":"BitBay","config":"{ \n\"codeName\": \"bitbay\"\n}","project":"Superalgos","exchangeAssets":{"type":"Exchange Assets","name":"New Exchange Assets","config":"{ \n\"addMissingAssetsFilter\": { \"quotedAsset\": \"USDT\"} \n}","project":"Superalgos","assets":[],"id":"83b4e523-72a7-41ce-9363-fe0c799dcac1","savedPayload":{"position":{"x":17861.64382962515,"y":30965.23747069523},"targetPosition":{"x":17855.64382962515,"y":30961.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":2,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"exchangeMarkets":{"type":"Exchange Markets","name":"New Exchange Markets","project":"Superalgos","markets":[],"id":"966698f7-8a28-42d7-bb80-f7cd0601e44f","savedPayload":{"position":{"x":17823.64382962515,"y":31026.23747069523},"targetPosition":{"x":17855.64382962515,"y":30961.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"exchangeAccounts":{"type":"Exchange Accounts","name":"New Exchange Accounts","project":"Superalgos","userAccounts":[{"type":"User Account","name":"New User Account","project":"Superalgos","userAssets":{"type":"User Assets","name":"New User Assets","project":"Superalgos","assets":[],"id":"554829eb-3d40-4b95-a1cd-9de943763e2c","savedPayload":{"position":{"x":17914.64382962515,"y":30924.23747069523},"targetPosition":{"x":17876.64382962515,"y":30921.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"userKeys":{"type":"User Keys","name":"New User Keys","project":"Superalgos","keys":[{"type":"Exchange Account Key","name":"New Exchange Account Key","config":"{ \n\"codeName\": \"Paste your exchange API name or label\",\n\"secret\": \"Paste your exchange API secret key\"\n}","project":"Superalgos","id":"2f534989-7ca7-4c3d-b14a-3b1071543c8c","savedPayload":{"position":{"x":17845.64382962515,"y":30853.23747069523},"targetPosition":{"x":17832.64382962515,"y":30821.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{}}}],"id":"2f6b76b4-51d4-434f-8aa1-ed86b0e26bd2","savedPayload":{"position":{"x":17832.64382962515,"y":30821.23747069523},"targetPosition":{"x":17876.64382962515,"y":30921.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"id":"cbcc3ab6-9758-4273-99d2-9d05fdd392b5","savedPayload":{"position":{"x":17876.64382962515,"y":30921.23747069523},"targetPosition":{"x":17805.64382962515,"y":31015.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}}],"id":"dada6c12-7c41-4ab8-9922-908233829f58","savedPayload":{"position":{"x":17805.64382962515,"y":31015.23747069523},"targetPosition":{"x":17855.64382962515,"y":30961.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":1,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"id":"8778eee5-97a2-4f9d-bd25-cd5a64ec6663","savedPayload":{"position":{"x":19672.249014182176,"y":31449.599342210422},"targetPosition":{"x":18473.301618063546,"y":31499.850126685462},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":true,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}},{"type":"Crypto Exchange","name":"Bitforex","config":"{ \n\"codeName\": \"bitforex\"\n}","project":"Superalgos","exchangeAssets":{"type":"Exchange Assets","name":"New Exchange Assets","config":"{ \n\"addMissingAssetsFilter\": { \"quotedAsset\": \"USDT\"} \n}","project":"Superalgos","assets":[],"id":"698e5e38-ad73-4cb6-b7f6-2b69913faff9","savedPayload":{"position":{"x":17897.64382962515,"y":30956.23747069523},"targetPosition":{"x":17937.64382962515,"y":30945.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":2,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"exchangeMarkets":{"type":"Exchange Markets","name":"New Exchange Markets","project":"Superalgos","markets":[],"id":"f0142bd4-1b63-4d12-a4b7-e150d0da197f","savedPayload":{"position":{"x":18020.64382962515,"y":31021.23747069523},"targetPosition":{"x":17937.64382962515,"y":30945.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"exchangeAccounts":{"type":"Exchange Accounts","name":"New Exchange Accounts","project":"Superalgos","userAccounts":[{"type":"User Account","name":"New User Account","project":"Superalgos","userAssets":{"type":"User Assets","name":"New User Assets","project":"Superalgos","assets":[],"id":"7164fb28-405b-461a-a7d4-59d438ecf1ce","savedPayload":{"position":{"x":17821.64382962515,"y":30984.23747069523},"targetPosition":{"x":17901.64382962515,"y":30907.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"userKeys":{"type":"User Keys","name":"New User Keys","project":"Superalgos","keys":[{"type":"Exchange Account Key","name":"New Exchange Account Key","config":"{ \n\"codeName\": \"Paste your exchange API name or label\",\n\"secret\": \"Paste your exchange API secret key\"\n}","project":"Superalgos","id":"ce8a00c9-f090-4ec2-84ed-c6661f8bf7b0","savedPayload":{"position":{"x":17825.64382962515,"y":30965.23747069523},"targetPosition":{"x":17818.64382962515,"y":30913.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{}}}],"id":"579cd74b-98f6-4000-990b-25ae1456c94b","savedPayload":{"position":{"x":17818.64382962515,"y":30913.23747069523},"targetPosition":{"x":17901.64382962515,"y":30907.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"id":"dbac6eef-25d2-4cda-86a6-59ce8a9a26bc","savedPayload":{"position":{"x":17901.64382962515,"y":30907.23747069523},"targetPosition":{"x":17909.64382962515,"y":30970.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}}],"id":"a1da9dd3-22ec-4536-bb5a-4d0bb8a56b81","savedPayload":{"position":{"x":17909.64382962515,"y":30970.23747069523},"targetPosition":{"x":17937.64382962515,"y":30945.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":1,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"id":"499a5a3b-7871-4c95-9b2e-d58d4d9e2392","savedPayload":{"position":{"x":19669.09304916295,"y":31600.26353868424},"targetPosition":{"x":18473.301618063546,"y":31499.850126685462},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":true,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}},{"type":"Crypto Exchange","name":"bitkk","config":"{ \n\"codeName\": \"bitkk\"\n}","project":"Superalgos","exchangeAssets":{"type":"Exchange Assets","name":"New Exchange Assets","config":"{ \n\"addMissingAssetsFilter\": { \"quotedAsset\": \"USDT\"} \n}","project":"Superalgos","assets":[],"id":"efbb916c-780b-447f-a4c2-df68570d4ee1","savedPayload":{"position":{"x":17931.64382962515,"y":30937.23747069523},"targetPosition":{"x":17951.64382962515,"y":30936.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":2,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"exchangeMarkets":{"type":"Exchange Markets","name":"New Exchange Markets","project":"Superalgos","markets":[],"id":"0d829516-81d9-46a5-9861-7d94cc89455d","savedPayload":{"position":{"x":17951.64382962515,"y":30912.23747069523},"targetPosition":{"x":17951.64382962515,"y":30936.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"exchangeAccounts":{"type":"Exchange Accounts","name":"New Exchange Accounts","project":"Superalgos","userAccounts":[{"type":"User Account","name":"New User Account","project":"Superalgos","userAssets":{"type":"User Assets","name":"New User Assets","project":"Superalgos","assets":[],"id":"fc174aa3-c485-4b9b-ba19-444b0189ccb1","savedPayload":{"position":{"x":17788.64382962515,"y":30980.23747069523},"targetPosition":{"x":17834.64382962515,"y":30983.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"userKeys":{"type":"User Keys","name":"New User Keys","project":"Superalgos","keys":[{"type":"Exchange Account Key","name":"New Exchange Account Key","config":"{ \n\"codeName\": \"Paste your exchange API name or label\",\n\"secret\": \"Paste your exchange API secret key\"\n}","project":"Superalgos","id":"15921d8a-4b45-481c-9165-79969ed3fd27","savedPayload":{"position":{"x":17796.64382962515,"y":30936.23747069523},"targetPosition":{"x":17891.64382962515,"y":30922.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{}}}],"id":"927d5c8a-85df-48bb-b097-c36abb76ca0e","savedPayload":{"position":{"x":17891.64382962515,"y":30922.23747069523},"targetPosition":{"x":17834.64382962515,"y":30983.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"id":"43d218c2-e633-47d5-8dd8-60bc7f7c0b9e","savedPayload":{"position":{"x":17834.64382962515,"y":30983.23747069523},"targetPosition":{"x":17853.64382962515,"y":30925.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}}],"id":"2d310d61-cbc7-4306-af02-be3888939545","savedPayload":{"position":{"x":17853.64382962515,"y":30925.23747069523},"targetPosition":{"x":17951.64382962515,"y":30936.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":1,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"id":"ded39740-3c93-4fda-bb9c-6ac75d2109f4","savedPayload":{"position":{"x":19647.078738944114,"y":31749.344155666775},"targetPosition":{"x":18473.301618063546,"y":31499.850126685462},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":true,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}},{"type":"Crypto Exchange","name":"BitMart","config":"{ \n\"codeName\": \"bitmart\"\n}","project":"Superalgos","exchangeAssets":{"type":"Exchange Assets","name":"New Exchange Assets","config":"{ \n\"addMissingAssetsFilter\": { \"quotedAsset\": \"USDT\"} \n}","project":"Superalgos","assets":[],"id":"10374855-6b4a-460b-9c95-70072ac00315","savedPayload":{"position":{"x":17907.64382962515,"y":30901.23747069523},"targetPosition":{"x":17834.64382962515,"y":30915.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":2,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"exchangeMarkets":{"type":"Exchange Markets","name":"New Exchange Markets","project":"Superalgos","markets":[],"id":"3aded60c-4061-48ff-ad33-212c965b5c43","savedPayload":{"position":{"x":17829.64382962515,"y":30925.23747069523},"targetPosition":{"x":17834.64382962515,"y":30915.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"exchangeAccounts":{"type":"Exchange Accounts","name":"New Exchange Accounts","project":"Superalgos","userAccounts":[{"type":"User Account","name":"New User Account","project":"Superalgos","userAssets":{"type":"User Assets","name":"New User Assets","project":"Superalgos","assets":[],"id":"1789a3ca-d948-497d-8d1b-1eefd25d16a3","savedPayload":{"position":{"x":17886.64382962515,"y":30937.23747069523},"targetPosition":{"x":17895.64382962515,"y":30988.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"userKeys":{"type":"User Keys","name":"New User Keys","project":"Superalgos","keys":[{"type":"Exchange Account Key","name":"New Exchange Account Key","config":"{ \n\"codeName\": \"Paste your exchange API name or label\",\n\"secret\": \"Paste your exchange API secret key\"\n}","project":"Superalgos","id":"038170bc-0ca7-4a92-8219-61b7bc8431b0","savedPayload":{"position":{"x":17893.64382962515,"y":31034.23747069523},"targetPosition":{"x":17835.64382962515,"y":30962.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{}}}],"id":"55f79ede-ef02-405f-92bd-11902ab3cc7a","savedPayload":{"position":{"x":17835.64382962515,"y":30962.23747069523},"targetPosition":{"x":17895.64382962515,"y":30988.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"id":"8185c660-4af3-4a62-bfa9-8922861101b5","savedPayload":{"position":{"x":17895.64382962515,"y":30988.23747069523},"targetPosition":{"x":17819.64382962515,"y":30909.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}}],"id":"546d48c3-df31-495c-b3b4-cb35109c5542","savedPayload":{"position":{"x":17819.64382962515,"y":30909.23747069523},"targetPosition":{"x":17834.64382962515,"y":30915.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":1,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"id":"c7ed52a7-895b-46f1-a745-35954d8bcfc6","savedPayload":{"position":{"x":19606.553262348523,"y":31894.49010277176},"targetPosition":{"x":18473.301618063546,"y":31499.850126685462},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":true,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}},{"type":"Crypto Exchange","name":"BitMax","config":"{ \n\"codeName\": \"bitmax\"\n}","project":"Superalgos","exchangeAssets":{"type":"Exchange Assets","name":"New Exchange Assets","config":"{ \n\"addMissingAssetsFilter\": { \"quotedAsset\": \"USDT\"} \n}","project":"Superalgos","assets":[],"id":"8a042d0d-7a7a-4a76-889e-42d8642404f4","savedPayload":{"position":{"x":17944.64382962515,"y":31046.23747069523},"targetPosition":{"x":17944.64382962515,"y":31109.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":2,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"exchangeMarkets":{"type":"Exchange Markets","name":"New Exchange Markets","project":"Superalgos","markets":[],"id":"0c4fcc48-51e6-4ff2-925f-405cda6d1122","savedPayload":{"position":{"x":17898.64382962515,"y":31024.23747069523},"targetPosition":{"x":17944.64382962515,"y":31109.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"exchangeAccounts":{"type":"Exchange Accounts","name":"New Exchange Accounts","project":"Superalgos","userAccounts":[{"type":"User Account","name":"New User Account","project":"Superalgos","userAssets":{"type":"User Assets","name":"New User Assets","project":"Superalgos","assets":[],"id":"ef9d5381-d9e3-47f5-9069-6fc14eda0fa3","savedPayload":{"position":{"x":17879.64382962515,"y":31096.23747069523},"targetPosition":{"x":17977.64382962515,"y":31041.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"userKeys":{"type":"User Keys","name":"New User Keys","project":"Superalgos","keys":[{"type":"Exchange Account Key","name":"New Exchange Account Key","config":"{ \n\"codeName\": \"Paste your exchange API name or label\",\n\"secret\": \"Paste your exchange API secret key\"\n}","project":"Superalgos","id":"c66fe606-9705-45b0-a196-7ea3efb0221e","savedPayload":{"position":{"x":17982.64382962515,"y":31053.23747069523},"targetPosition":{"x":17943.64382962515,"y":31083.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{}}}],"id":"80a5f68e-776a-44de-8797-d2eb806c306e","savedPayload":{"position":{"x":17943.64382962515,"y":31083.23747069523},"targetPosition":{"x":17977.64382962515,"y":31041.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"id":"011fcf1c-1c94-4c36-a246-d6c400aa39dc","savedPayload":{"position":{"x":17977.64382962515,"y":31041.23747069523},"targetPosition":{"x":17942.64382962515,"y":31103.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}}],"id":"4a87b8c5-e009-427f-afb7-21afe5594b59","savedPayload":{"position":{"x":17942.64382962515,"y":31103.23747069523},"targetPosition":{"x":17944.64382962515,"y":31109.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":1,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"id":"fc6a9048-ab8c-48f9-91ae-6c95c28714b0","savedPayload":{"position":{"x":19548.15573035084,"y":32033.412341707375},"targetPosition":{"x":18473.301618063546,"y":31499.850126685462},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":true,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}},{"type":"Crypto Exchange","name":"BitMEX","config":"{ \n\"codeName\": \"bitmex\"\n}","project":"Superalgos","exchangeAssets":{"type":"Exchange Assets","name":"New Exchange Assets","config":"{ \n\"addMissingAssetsFilter\": { \"quotedAsset\": \"USDT\"} \n}","project":"Superalgos","assets":[],"id":"f7636e2b-354a-4217-894b-5e26eddc0c2a","savedPayload":{"position":{"x":17894.64382962515,"y":30934.23747069523},"targetPosition":{"x":17910.64382962515,"y":30922.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":2,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"exchangeMarkets":{"type":"Exchange Markets","name":"New Exchange Markets","project":"Superalgos","markets":[],"id":"6eb2ddd1-6d06-456c-b4e0-7df56ba182e6","savedPayload":{"position":{"x":17823.64382962515,"y":30834.23747069523},"targetPosition":{"x":17910.64382962515,"y":30922.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"exchangeAccounts":{"type":"Exchange Accounts","name":"New Exchange Accounts","project":"Superalgos","userAccounts":[{"type":"User Account","name":"New User Account","project":"Superalgos","userAssets":{"type":"User Assets","name":"New User Assets","project":"Superalgos","assets":[],"id":"b4a4b8fe-d923-4eb0-a066-171b83d1540d","savedPayload":{"position":{"x":17902.64382962515,"y":31064.23747069523},"targetPosition":{"x":17815.64382962515,"y":30988.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"userKeys":{"type":"User Keys","name":"New User Keys","project":"Superalgos","keys":[{"type":"Exchange Account Key","name":"New Exchange Account Key","config":"{ \n\"codeName\": \"Paste your exchange API name or label\",\n\"secret\": \"Paste your exchange API secret key\"\n}","project":"Superalgos","id":"918ed585-ce46-4d51-a07a-9beee51f70eb","savedPayload":{"position":{"x":17711.64382962515,"y":31036.23747069523},"targetPosition":{"x":17805.64382962515,"y":31078.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{}}}],"id":"9efef4d8-5be3-4d17-a645-6edffd9535cf","savedPayload":{"position":{"x":17805.64382962515,"y":31078.23747069523},"targetPosition":{"x":17815.64382962515,"y":30988.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"id":"6ad31a6e-f27b-45c3-9996-a41fb39aa154","savedPayload":{"position":{"x":17815.64382962515,"y":30988.23747069523},"targetPosition":{"x":17844.64382962515,"y":30896.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}}],"id":"82887393-cb1c-4b01-8581-4b3dabc86584","savedPayload":{"position":{"x":17844.64382962515,"y":30896.23747069523},"targetPosition":{"x":17910.64382962515,"y":30922.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":1,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"id":"1e2f1dd0-ebf1-4485-83d8-7723a9e3e714","savedPayload":{"position":{"x":19472.807106915665,"y":32163.919985777477},"targetPosition":{"x":18473.301618063546,"y":31499.850126685462},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":true,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}},{"type":"Crypto Exchange","name":"Bit-Z","config":"{ \n\"codeName\": \"bitz\"\n}","project":"Superalgos","exchangeAssets":{"type":"Exchange Assets","name":"New Exchange Assets","config":"{ \n\"addMissingAssetsFilter\": { \"quotedAsset\": \"USDT\"} \n}","project":"Superalgos","assets":[],"id":"0a22e02b-7d2e-4955-9cfc-ed7d95f0c9a0","savedPayload":{"position":{"x":17751.64382962515,"y":31083.23747069523},"targetPosition":{"x":17850.64382962515,"y":31073.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":2,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"exchangeMarkets":{"type":"Exchange Markets","name":"New Exchange Markets","project":"Superalgos","markets":[],"id":"298b45af-b73d-4cd5-848a-97de7b857569","savedPayload":{"position":{"x":17944.64382962515,"y":31083.23747069523},"targetPosition":{"x":17850.64382962515,"y":31073.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"exchangeAccounts":{"type":"Exchange Accounts","name":"New Exchange Accounts","project":"Superalgos","userAccounts":[{"type":"User Account","name":"New User Account","project":"Superalgos","userAssets":{"type":"User Assets","name":"New User Assets","project":"Superalgos","assets":[],"id":"6ede807b-b1ab-42b5-bfd7-3b12a942447e","savedPayload":{"position":{"x":17871.64382962515,"y":31049.23747069523},"targetPosition":{"x":17772.64382962515,"y":31098.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"userKeys":{"type":"User Keys","name":"New User Keys","project":"Superalgos","keys":[{"type":"Exchange Account Key","name":"New Exchange Account Key","config":"{ \n\"codeName\": \"Paste your exchange API name or label\",\n\"secret\": \"Paste your exchange API secret key\"\n}","project":"Superalgos","id":"dc172858-3241-4487-950a-e5cae03ac376","savedPayload":{"position":{"x":17751.64382962515,"y":31081.23747069523},"targetPosition":{"x":17753.64382962515,"y":31028.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{}}}],"id":"19c07cee-1fdf-4e02-ac9f-d110b64ee033","savedPayload":{"position":{"x":17753.64382962515,"y":31028.23747069523},"targetPosition":{"x":17772.64382962515,"y":31098.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"id":"b4ef5048-ac4c-410e-bd6d-3338e33ab108","savedPayload":{"position":{"x":17772.64382962515,"y":31098.23747069523},"targetPosition":{"x":17788.64382962515,"y":31134.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}}],"id":"e7e96c41-c839-4eec-9bcf-1c60d60fa3f5","savedPayload":{"position":{"x":17788.64382962515,"y":31134.23747069523},"targetPosition":{"x":17850.64382962515,"y":31073.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":1,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"id":"6cc10926-fe41-43be-887b-fa8aba1c7377","savedPayload":{"position":{"x":19381.695684845654,"y":32283.954851473587},"targetPosition":{"x":18473.301618063546,"y":31499.850126685462},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":true,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}},{"type":"Crypto Exchange","name":"BTC-Alpha","config":"{ \n\"codeName\": \"btcalpha\"\n}","project":"Superalgos","exchangeAssets":{"type":"Exchange Assets","name":"New Exchange Assets","config":"{ \n\"addMissingAssetsFilter\": { \"quotedAsset\": \"USDT\"} \n}","project":"Superalgos","assets":[],"id":"263e3b9c-8fdd-4376-b53b-87f32d0f5898","savedPayload":{"position":{"x":17904.64382962515,"y":30922.23747069523},"targetPosition":{"x":17883.64382962515,"y":30971.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":2,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"exchangeMarkets":{"type":"Exchange Markets","name":"New Exchange Markets","project":"Superalgos","markets":[],"id":"804603e1-3e0f-4219-a9b7-ee27810d4f07","savedPayload":{"position":{"x":17829.64382962515,"y":30977.23747069523},"targetPosition":{"x":17883.64382962515,"y":30971.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"exchangeAccounts":{"type":"Exchange Accounts","name":"New Exchange Accounts","project":"Superalgos","userAccounts":[{"type":"User Account","name":"New User Account","project":"Superalgos","userAssets":{"type":"User Assets","name":"New User Assets","project":"Superalgos","assets":[],"id":"83b25fff-e448-483f-9bee-cb85fa592c6e","savedPayload":{"position":{"x":17734.64382962515,"y":30862.23747069523},"targetPosition":{"x":17829.64382962515,"y":30960.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"userKeys":{"type":"User Keys","name":"New User Keys","project":"Superalgos","keys":[{"type":"Exchange Account Key","name":"New Exchange Account Key","config":"{ \n\"codeName\": \"Paste your exchange API name or label\",\n\"secret\": \"Paste your exchange API secret key\"\n}","project":"Superalgos","id":"efcfa3ca-0f82-4eb7-9b04-ed5eb4e1c3cf","savedPayload":{"position":{"x":17799.64382962515,"y":30864.23747069523},"targetPosition":{"x":17837.64382962515,"y":30919.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{}}}],"id":"9ca8d728-ee11-4905-9a3a-5ca4ed50f3df","savedPayload":{"position":{"x":17837.64382962515,"y":30919.23747069523},"targetPosition":{"x":17829.64382962515,"y":30960.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"id":"2cfde277-afa6-4ad3-bb5b-8a32b89e2037","savedPayload":{"position":{"x":17829.64382962515,"y":30960.23747069523},"targetPosition":{"x":17903.64382962515,"y":30969.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}}],"id":"297a0ea2-f6d7-47fd-9fb7-0d99d00a87d8","savedPayload":{"position":{"x":17903.64382962515,"y":30969.23747069523},"targetPosition":{"x":17883.64382962515,"y":30971.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":1,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"id":"30e5485f-213b-435b-a670-07b76cfe5cae","savedPayload":{"position":{"x":19276.258345694176,"y":32391.623917258334},"targetPosition":{"x":18473.301618063546,"y":31499.850126685462},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":true,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}},{"type":"Crypto Exchange","name":"BTC Markets","config":"{ \n\"codeName\": \"btcmarkets\"\n}","project":"Superalgos","exchangeAssets":{"type":"Exchange Assets","name":"New Exchange Assets","config":"{ \n\"addMissingAssetsFilter\": { \"quotedAsset\": \"USDT\"} \n}","project":"Superalgos","assets":[],"id":"fcb3b880-0852-4d93-8714-67373f9dca16","savedPayload":{"position":{"x":17911.64382962515,"y":31036.23747069523},"targetPosition":{"x":17994.64382962515,"y":31033.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":2,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"exchangeMarkets":{"type":"Exchange Markets","name":"New Exchange Markets","project":"Superalgos","markets":[],"id":"953d8eff-0b2e-4b07-8635-393fddae0c9d","savedPayload":{"position":{"x":18025.64382962515,"y":31127.23747069523},"targetPosition":{"x":17994.64382962515,"y":31033.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"exchangeAccounts":{"type":"Exchange Accounts","name":"New Exchange Accounts","project":"Superalgos","userAccounts":[{"type":"User Account","name":"New User Account","project":"Superalgos","userAssets":{"type":"User Assets","name":"New User Assets","project":"Superalgos","assets":[],"id":"c08873f6-9120-4764-8b06-c8110468b423","savedPayload":{"position":{"x":17935.64382962515,"y":30927.23747069523},"targetPosition":{"x":18027.64382962515,"y":31003.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"userKeys":{"type":"User Keys","name":"New User Keys","project":"Superalgos","keys":[{"type":"Exchange Account Key","name":"New Exchange Account Key","config":"{ \n\"codeName\": \"Paste your exchange API name or label\",\n\"secret\": \"Paste your exchange API secret key\"\n}","project":"Superalgos","id":"beaa2557-4976-4e53-8a24-7ea00fc3afd5","savedPayload":{"position":{"x":18054.64382962515,"y":30851.23747069523},"targetPosition":{"x":18125.64382962515,"y":30951.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{}}}],"id":"445158a2-91b4-4ad8-8380-036cbba6ad7e","savedPayload":{"position":{"x":18125.64382962515,"y":30951.23747069523},"targetPosition":{"x":18027.64382962515,"y":31003.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"id":"cd00e08c-a26d-4b11-93a3-b0e8f35bec4b","savedPayload":{"position":{"x":18027.64382962515,"y":31003.23747069523},"targetPosition":{"x":18016.64382962515,"y":31075.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}}],"id":"35cb55c1-ceb3-4093-98af-8a1c2411fe0f","savedPayload":{"position":{"x":18016.64382962515,"y":31075.23747069523},"targetPosition":{"x":17994.64382962515,"y":31033.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":1,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"id":"ac2fda42-95ca-404a-8dd2-72bff0ff5a0f","savedPayload":{"position":{"x":19158.157899284863,"y":32485.229177645906},"targetPosition":{"x":18473.301618063546,"y":31499.850126685462},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":true,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}},{"type":"Crypto Exchange","name":"Buda","config":"{ \n\"codeName\": \"buda\"\n}","project":"Superalgos","exchangeAssets":{"type":"Exchange Assets","name":"New Exchange Assets","config":"{ \n\"addMissingAssetsFilter\": { \"quotedAsset\": \"USDT\"} \n}","project":"Superalgos","assets":[],"id":"27f3573d-e1f0-473f-9bfd-f9198e7240a0","savedPayload":{"position":{"x":17945.64382962515,"y":30937.23747069523},"targetPosition":{"x":17853.64382962515,"y":31005.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":2,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"exchangeMarkets":{"type":"Exchange Markets","name":"New Exchange Markets","project":"Superalgos","markets":[],"id":"4ddc0981-4e45-42f3-ae11-f5b136b2bc3d","savedPayload":{"position":{"x":17783.64382962515,"y":31008.23747069523},"targetPosition":{"x":17853.64382962515,"y":31005.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"exchangeAccounts":{"type":"Exchange Accounts","name":"New Exchange Accounts","project":"Superalgos","userAccounts":[{"type":"User Account","name":"New User Account","project":"Superalgos","userAssets":{"type":"User Assets","name":"New User Assets","project":"Superalgos","assets":[],"id":"5a325d59-e6a6-4f76-a311-5e67c5f5a8a2","savedPayload":{"position":{"x":17980.64382962515,"y":30843.23747069523},"targetPosition":{"x":17956.64382962515,"y":30936.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"userKeys":{"type":"User Keys","name":"New User Keys","project":"Superalgos","keys":[{"type":"Exchange Account Key","name":"New Exchange Account Key","config":"{ \n\"codeName\": \"Paste your exchange API name or label\",\n\"secret\": \"Paste your exchange API secret key\"\n}","project":"Superalgos","id":"fb985ab9-7759-4780-a052-8ee9be0b712a","savedPayload":{"position":{"x":17907.64382962515,"y":30968.23747069523},"targetPosition":{"x":17958.64382962515,"y":30884.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{}}}],"id":"fdf7665a-2974-467b-9280-4077a888733f","savedPayload":{"position":{"x":17958.64382962515,"y":30884.23747069523},"targetPosition":{"x":17956.64382962515,"y":30936.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"id":"a3105cfc-f80e-4bcb-b399-6ea9c0f7edf0","savedPayload":{"position":{"x":17956.64382962515,"y":30936.23747069523},"targetPosition":{"x":17872.64382962515,"y":30941.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}}],"id":"5d69a76f-e7bc-4538-950e-2e2353eccea3","savedPayload":{"position":{"x":17872.64382962515,"y":30941.23747069523},"targetPosition":{"x":17853.64382962515,"y":31005.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":1,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"id":"90fe3d74-662e-4fac-aff3-f41990b61ccf","savedPayload":{"position":{"x":19029.25686020738,"y":32563.29442176292},"targetPosition":{"x":18473.301618063546,"y":31499.850126685462},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":true,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}},{"type":"Crypto Exchange","name":"BW","config":"{ \n\"codeName\": \"bw\"\n}","project":"Superalgos","exchangeAssets":{"type":"Exchange Assets","name":"New Exchange Assets","config":"{ \n\"addMissingAssetsFilter\": { \"quotedAsset\": \"USDT\"} \n}","project":"Superalgos","assets":[],"id":"457616cd-25f9-4ad3-8c18-6331859dd42e","savedPayload":{"position":{"x":17890.64382962515,"y":31014.23747069523},"targetPosition":{"x":17900.64382962515,"y":30965.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":2,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"exchangeMarkets":{"type":"Exchange Markets","name":"New Exchange Markets","project":"Superalgos","markets":[],"id":"8c1f9aa2-4253-4129-a533-e515644ddb38","savedPayload":{"position":{"x":17909.64382962515,"y":30970.23747069523},"targetPosition":{"x":17900.64382962515,"y":30965.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"exchangeAccounts":{"type":"Exchange Accounts","name":"New Exchange Accounts","project":"Superalgos","userAccounts":[{"type":"User Account","name":"New User Account","project":"Superalgos","userAssets":{"type":"User Assets","name":"New User Assets","project":"Superalgos","assets":[],"id":"24314a5b-85ca-4036-adc6-618120496f1d","savedPayload":{"position":{"x":17773.64382962515,"y":30945.23747069523},"targetPosition":{"x":17860.64382962515,"y":30865.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"userKeys":{"type":"User Keys","name":"New User Keys","project":"Superalgos","keys":[{"type":"Exchange Account Key","name":"New Exchange Account Key","config":"{ \n\"codeName\": \"Paste your exchange API name or label\",\n\"secret\": \"Paste your exchange API secret key\"\n}","project":"Superalgos","id":"f7c593f6-bd7a-41f7-a5e7-b2e1ea9a528f","savedPayload":{"position":{"x":17820.64382962515,"y":30885.23747069523},"targetPosition":{"x":17828.64382962515,"y":30802.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{}}}],"id":"60dfc799-f863-4895-8d17-568aa2303ef5","savedPayload":{"position":{"x":17828.64382962515,"y":30802.23747069523},"targetPosition":{"x":17860.64382962515,"y":30865.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"id":"223e466d-d750-4e38-91ce-8a59c15242ba","savedPayload":{"position":{"x":17860.64382962515,"y":30865.23747069523},"targetPosition":{"x":17818.64382962515,"y":30919.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}}],"id":"cfff1310-5220-4978-9553-8514be141d14","savedPayload":{"position":{"x":17818.64382962515,"y":30919.23747069523},"targetPosition":{"x":17900.64382962515,"y":30965.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":1,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"id":"d72db90c-d572-4cbb-8348-e3cc485d8e86","savedPayload":{"position":{"x":18891.588074849722,"y":32624.58851407573},"targetPosition":{"x":18473.301618063546,"y":31499.850126685462},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":true,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}},{"type":"Crypto Exchange","name":"Bybit","config":"{ \n\"codeName\": \"bybit\"\n}","project":"Superalgos","exchangeAssets":{"type":"Exchange Assets","name":"New Exchange Assets","config":"{ \n\"addMissingAssetsFilter\": { \"quotedAsset\": \"USDT\"} \n}","project":"Superalgos","assets":[],"id":"18fdf7c8-03c4-4f81-a88e-de97589765e1","savedPayload":{"position":{"x":17803.64382962515,"y":31059.23747069523},"targetPosition":{"x":17855.64382962515,"y":31007.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":2,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"exchangeMarkets":{"type":"Exchange Markets","name":"New Exchange Markets","project":"Superalgos","markets":[],"id":"a62b2603-ac6f-4b6e-9541-86daf32027b1","savedPayload":{"position":{"x":17847.64382962515,"y":31104.23747069523},"targetPosition":{"x":17855.64382962515,"y":31007.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"exchangeAccounts":{"type":"Exchange Accounts","name":"New Exchange Accounts","project":"Superalgos","userAccounts":[{"type":"User Account","name":"New User Account","project":"Superalgos","userAssets":{"type":"User Assets","name":"New User Assets","project":"Superalgos","assets":[],"id":"66ecff99-7102-4f4a-9ce8-4d55fb22dfbc","savedPayload":{"position":{"x":17851.64382962515,"y":31165.23747069523},"targetPosition":{"x":17916.64382962515,"y":31077.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"userKeys":{"type":"User Keys","name":"New User Keys","project":"Superalgos","keys":[{"type":"Exchange Account Key","name":"New Exchange Account Key","config":"{ \n\"codeName\": \"Paste your exchange API name or label\",\n\"secret\": \"Paste your exchange API secret key\"\n}","project":"Superalgos","id":"625e127c-0ebb-4f57-af9f-9dfb57b262a1","savedPayload":{"position":{"x":18004.64382962515,"y":31091.23747069523},"targetPosition":{"x":18008.64382962515,"y":31027.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{}}}],"id":"8174bb53-66b8-4575-b206-74f9b6352a80","savedPayload":{"position":{"x":18008.64382962515,"y":31027.23747069523},"targetPosition":{"x":17916.64382962515,"y":31077.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"id":"ee16357e-abde-4800-b089-f43f4b696a35","savedPayload":{"position":{"x":17916.64382962515,"y":31077.23747069523},"targetPosition":{"x":17944.64382962515,"y":31101.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}}],"id":"c9e9473b-aff9-43c8-a6be-5cd30330bee2","savedPayload":{"position":{"x":17944.64382962515,"y":31101.23747069523},"targetPosition":{"x":17855.64382962515,"y":31007.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":1,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"id":"516c3831-456b-4d17-b0a0-6a363ba2ddb2","savedPayload":{"position":{"x":18747.322662196333,"y":32668.144810133253},"targetPosition":{"x":18473.301618063546,"y":31499.850126685462},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":true,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}},{"type":"Crypto Exchange","name":"ByteTrade","config":"{ \n\"codeName\": \"bytetrade\"\n}","project":"Superalgos","exchangeAssets":{"type":"Exchange Assets","name":"New Exchange Assets","config":"{ \n\"addMissingAssetsFilter\": { \"quotedAsset\": \"USDT\"} \n}","project":"Superalgos","assets":[],"id":"e7a1e531-5a9e-466e-b98d-672de39eed3a","savedPayload":{"position":{"x":18088.64382962515,"y":31024.23747069523},"targetPosition":{"x":17991.64382962515,"y":30981.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":2,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"exchangeMarkets":{"type":"Exchange Markets","name":"New Exchange Markets","project":"Superalgos","markets":[],"id":"edafaba7-fd82-4d9f-b3f7-5d1c01c56599","savedPayload":{"position":{"x":17941.64382962515,"y":30943.23747069523},"targetPosition":{"x":17991.64382962515,"y":30981.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"exchangeAccounts":{"type":"Exchange Accounts","name":"New Exchange Accounts","project":"Superalgos","userAccounts":[{"type":"User Account","name":"New User Account","project":"Superalgos","userAssets":{"type":"User Assets","name":"New User Assets","project":"Superalgos","assets":[],"id":"50fa78b8-3aea-4e43-adcf-1e31820bf97f","savedPayload":{"position":{"x":17886.64382962515,"y":31008.23747069523},"targetPosition":{"x":17858.64382962515,"y":30967.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"userKeys":{"type":"User Keys","name":"New User Keys","project":"Superalgos","keys":[{"type":"Exchange Account Key","name":"New Exchange Account Key","config":"{ \n\"codeName\": \"Paste your exchange API name or label\",\n\"secret\": \"Paste your exchange API secret key\"\n}","project":"Superalgos","id":"b9c39b04-e86e-4ebb-9aba-39c375f2960c","savedPayload":{"position":{"x":17865.64382962515,"y":30941.23747069523},"targetPosition":{"x":17953.64382962515,"y":31023.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{}}}],"id":"5965d9cc-1d68-47a7-b838-e6dd81da6ea9","savedPayload":{"position":{"x":17953.64382962515,"y":31023.23747069523},"targetPosition":{"x":17858.64382962515,"y":30967.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"id":"f51a08be-ee3f-4d3b-a75e-d783d63092a7","savedPayload":{"position":{"x":17858.64382962515,"y":30967.23747069523},"targetPosition":{"x":17898.64382962515,"y":30965.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}}],"id":"d395efd0-691b-4a68-a7f1-9bce95b2f687","savedPayload":{"position":{"x":17898.64382962515,"y":30965.23747069523},"targetPosition":{"x":17991.64382962515,"y":30981.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":1,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"id":"45e2306f-03e8-4d17-a73a-72c11dd14e78","savedPayload":{"position":{"x":18598.73577398473,"y":32693.27640112739},"targetPosition":{"x":18473.301618063546,"y":31499.850126685462},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":true,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}},{"type":"Crypto Exchange","name":"CEX.IO","config":"{ \n\"codeName\": \"cex\"\n}","project":"Superalgos","exchangeAssets":{"type":"Exchange Assets","name":"New Exchange Assets","config":"{ \n\"addMissingAssetsFilter\": { \"quotedAsset\": \"USDT\"} \n}","project":"Superalgos","assets":[],"id":"9de19f0a-5824-4e42-af00-484b64421dc3","savedPayload":{"position":{"x":17890.64382962515,"y":31049.23747069523},"targetPosition":{"x":17896.64382962515,"y":31076.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":2,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"exchangeMarkets":{"type":"Exchange Markets","name":"New Exchange Markets","project":"Superalgos","markets":[],"id":"39db01bc-0cea-422f-b9e9-7d84e3f5446d","savedPayload":{"position":{"x":17918.64382962515,"y":31105.23747069523},"targetPosition":{"x":17896.64382962515,"y":31076.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"exchangeAccounts":{"type":"Exchange Accounts","name":"New Exchange Accounts","project":"Superalgos","userAccounts":[{"type":"User Account","name":"New User Account","project":"Superalgos","userAssets":{"type":"User Assets","name":"New User Assets","project":"Superalgos","assets":[],"id":"93833d3c-42c9-4e4d-bf0f-5b80a90d10c2","savedPayload":{"position":{"x":17978.64382962515,"y":31126.23747069523},"targetPosition":{"x":17953.64382962515,"y":31167.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"userKeys":{"type":"User Keys","name":"New User Keys","project":"Superalgos","keys":[{"type":"Exchange Account Key","name":"New Exchange Account Key","config":"{ \n\"codeName\": \"Paste your exchange API name or label\",\n\"secret\": \"Paste your exchange API secret key\"\n}","project":"Superalgos","id":"42863a52-30f4-4322-9c20-99a45d6dc3d6","savedPayload":{"position":{"x":17884.64382962515,"y":31149.23747069523},"targetPosition":{"x":17895.64382962515,"y":31148.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{}}}],"id":"fcff471d-29be-4176-8ff8-12088361f9fc","savedPayload":{"position":{"x":17895.64382962515,"y":31148.23747069523},"targetPosition":{"x":17953.64382962515,"y":31167.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"id":"f7975a18-b3ab-49bc-ae45-eb02c99aff8c","savedPayload":{"position":{"x":17953.64382962515,"y":31167.23747069523},"targetPosition":{"x":17881.64382962515,"y":31096.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}}],"id":"ec432123-43fe-4171-8c41-b797d3161edb","savedPayload":{"position":{"x":17881.64382962515,"y":31096.23747069523},"targetPosition":{"x":17896.64382962515,"y":31076.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":1,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"id":"346bfc30-e32a-453a-bdc6-0ead48221581","savedPayload":{"position":{"x":18448.170714203516,"y":32699.586946855277},"targetPosition":{"x":18473.301618063546,"y":31499.850126685462},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":true,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}},{"type":"Crypto Exchange","name":"Coinbase Prime","config":"{ \n\"codeName\": \"coinbaseprime\"\n}","project":"Superalgos","exchangeAssets":{"type":"Exchange Assets","name":"New Exchange Assets","config":"{ \n\"addMissingAssetsFilter\": { \"quotedAsset\": \"USDT\"} \n}","project":"Superalgos","assets":[],"id":"73cabd8d-9308-49ed-b544-44f785ee7d38","savedPayload":{"position":{"x":17867.64382962515,"y":30962.23747069523},"targetPosition":{"x":17922.64382962515,"y":30960.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":2,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"exchangeMarkets":{"type":"Exchange Markets","name":"New Exchange Markets","project":"Superalgos","markets":[],"id":"31bd1360-f0c5-4d70-876a-b152f7cedfd7","savedPayload":{"position":{"x":17960.64382962515,"y":30864.23747069523},"targetPosition":{"x":17922.64382962515,"y":30960.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"exchangeAccounts":{"type":"Exchange Accounts","name":"New Exchange Accounts","project":"Superalgos","userAccounts":[{"type":"User Account","name":"New User Account","project":"Superalgos","userAssets":{"type":"User Assets","name":"New User Assets","project":"Superalgos","assets":[],"id":"9b75fcfa-fe75-48a8-9d28-2ff19c58c041","savedPayload":{"position":{"x":17792.64382962515,"y":30841.23747069523},"targetPosition":{"x":17809.64382962515,"y":30934.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"userKeys":{"type":"User Keys","name":"New User Keys","project":"Superalgos","keys":[{"type":"Exchange Account Key","name":"New Exchange Account Key","config":"{ \n\"codeName\": \"Paste your exchange API name or label\",\n\"secret\": \"Paste your exchange API secret key\"\n}","project":"Superalgos","id":"c900b14a-c728-45af-90f8-29b3e5f29f46","savedPayload":{"position":{"x":17801.64382962515,"y":30986.23747069523},"targetPosition":{"x":17793.64382962515,"y":31006.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{}}}],"id":"eaf72df3-b66f-4b83-83f9-91e22ec0c300","savedPayload":{"position":{"x":17793.64382962515,"y":31006.23747069523},"targetPosition":{"x":17809.64382962515,"y":30934.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"id":"9da95675-2071-41bf-b5ac-4f2af602994f","savedPayload":{"position":{"x":17809.64382962515,"y":30934.23747069523},"targetPosition":{"x":17862.64382962515,"y":31021.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}}],"id":"4fc49ad4-57cc-43b0-b14b-15f26af994aa","savedPayload":{"position":{"x":17862.64382962515,"y":31021.23747069523},"targetPosition":{"x":17922.64382962515,"y":30960.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":1,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"id":"5a8281db-6ace-4186-8cfb-cd249c4af48b","savedPayload":{"position":{"x":18298.001983788654,"y":32686.97692624105},"targetPosition":{"x":18473.301618063546,"y":31499.850126685462},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":true,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}},{"type":"Crypto Exchange","name":"CoinEx","config":"{ \n\"codeName\": \"coinex\"\n}","project":"Superalgos","exchangeAssets":{"type":"Exchange Assets","name":"New Exchange Assets","config":"{ \n\"addMissingAssetsFilter\": { \"quotedAsset\": \"USDT\"} \n}","project":"Superalgos","assets":[],"id":"af78f796-60e5-4794-87b8-772c7bc74be1","savedPayload":{"position":{"x":18043.64382962515,"y":31069.23747069523},"targetPosition":{"x":18000.64382962515,"y":31106.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":2,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"exchangeMarkets":{"type":"Exchange Markets","name":"New Exchange Markets","project":"Superalgos","markets":[],"id":"d351e6d9-36eb-4d0e-aca5-94429bbb23a3","savedPayload":{"position":{"x":18094.64382962515,"y":31090.23747069523},"targetPosition":{"x":18000.64382962515,"y":31106.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"exchangeAccounts":{"type":"Exchange Accounts","name":"New Exchange Accounts","project":"Superalgos","userAccounts":[{"type":"User Account","name":"New User Account","project":"Superalgos","userAssets":{"type":"User Assets","name":"New User Assets","project":"Superalgos","assets":[],"id":"438f74c6-15e0-4553-af2a-febd5290c269","savedPayload":{"position":{"x":17908.64382962515,"y":31088.23747069523},"targetPosition":{"x":17986.64382962515,"y":31075.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"userKeys":{"type":"User Keys","name":"New User Keys","project":"Superalgos","keys":[{"type":"Exchange Account Key","name":"New Exchange Account Key","config":"{ \n\"codeName\": \"Paste your exchange API name or label\",\n\"secret\": \"Paste your exchange API secret key\"\n}","project":"Superalgos","id":"bfb22430-77c7-41a7-8083-771f7d7f3634","savedPayload":{"position":{"x":17927.64382962515,"y":30953.23747069523},"targetPosition":{"x":17947.64382962515,"y":30990.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{}}}],"id":"51daaa12-1c60-4cef-96d8-a445b4b32296","savedPayload":{"position":{"x":17947.64382962515,"y":30990.23747069523},"targetPosition":{"x":17986.64382962515,"y":31075.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"id":"726b8c33-9873-4be1-b9ef-d6b4483f23b1","savedPayload":{"position":{"x":17986.64382962515,"y":31075.23747069523},"targetPosition":{"x":17919.64382962515,"y":31016.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}}],"id":"30469514-b983-4f6f-9d74-6d6ceef25eb6","savedPayload":{"position":{"x":17919.64382962515,"y":31016.23747069523},"targetPosition":{"x":18000.64382962515,"y":31106.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":1,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"id":"62ad0961-6bdf-4a4a-a340-610816742d0a","savedPayload":{"position":{"x":18150.597833325228,"y":32655.64520684265},"targetPosition":{"x":18473.301618063546,"y":31499.850126685462},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":true,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}},{"type":"Crypto Exchange","name":"COSS","config":"{ \n\"codeName\": \"coss\"\n}","project":"Superalgos","exchangeAssets":{"type":"Exchange Assets","name":"New Exchange Assets","config":"{ \n\"addMissingAssetsFilter\": { \"quotedAsset\": \"USDT\"} \n}","project":"Superalgos","assets":[],"id":"e6315232-c6b1-4e25-aade-7bc7ba9ba6ac","savedPayload":{"position":{"x":17787.64382962515,"y":30984.23747069523},"targetPosition":{"x":17874.64382962515,"y":31049.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":2,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"exchangeMarkets":{"type":"Exchange Markets","name":"New Exchange Markets","project":"Superalgos","markets":[],"id":"b1e8451f-09a2-47b0-add3-cf9c35c487bb","savedPayload":{"position":{"x":17829.64382962515,"y":31095.23747069523},"targetPosition":{"x":17874.64382962515,"y":31049.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"exchangeAccounts":{"type":"Exchange Accounts","name":"New Exchange Accounts","project":"Superalgos","userAccounts":[{"type":"User Account","name":"New User Account","project":"Superalgos","userAssets":{"type":"User Assets","name":"New User Assets","project":"Superalgos","assets":[],"id":"d1c9b795-0434-4ce1-9cb7-cc61fac7396d","savedPayload":{"position":{"x":17950.64382962515,"y":31149.23747069523},"targetPosition":{"x":17882.64382962515,"y":31131.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"userKeys":{"type":"User Keys","name":"New User Keys","project":"Superalgos","keys":[{"type":"Exchange Account Key","name":"New Exchange Account Key","config":"{ \n\"codeName\": \"Paste your exchange API name or label\",\n\"secret\": \"Paste your exchange API secret key\"\n}","project":"Superalgos","id":"22be64f9-4b08-4ac3-ae89-6726743a7d5a","savedPayload":{"position":{"x":17890.64382962515,"y":31165.23747069523},"targetPosition":{"x":17956.64382962515,"y":31156.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{}}}],"id":"c7462500-ba74-4bf3-ad81-35fa232bede3","savedPayload":{"position":{"x":17956.64382962515,"y":31156.23747069523},"targetPosition":{"x":17882.64382962515,"y":31131.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"id":"5cd41ced-981a-4075-af43-3a0497eb0fcb","savedPayload":{"position":{"x":17882.64382962515,"y":31131.23747069523},"targetPosition":{"x":17856.64382962515,"y":31148.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}}],"id":"b5937899-c6ee-4d7a-b259-1ee23d721f60","savedPayload":{"position":{"x":17856.64382962515,"y":31148.23747069523},"targetPosition":{"x":17874.64382962515,"y":31049.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":1,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"id":"695029de-7f61-45bb-aa4c-c6d51e6369ed","savedPayload":{"position":{"x":18008.282914321022,"y":32606.085908591664},"targetPosition":{"x":18473.301618063546,"y":31499.850126685462},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":true,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}},{"type":"Crypto Exchange","name":"CREX24","config":"{ \n\"codeName\": \"crex24\"\n}","project":"Superalgos","exchangeAssets":{"type":"Exchange Assets","name":"New Exchange Assets","config":"{ \n\"addMissingAssetsFilter\": { \"quotedAsset\": \"USDT\"} \n}","project":"Superalgos","assets":[],"id":"c5e12f4a-fb26-40d3-9e70-751b55018e74","savedPayload":{"position":{"x":17910.64382962515,"y":31024.23747069523},"targetPosition":{"x":17860.64382962515,"y":31075.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":2,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"exchangeMarkets":{"type":"Exchange Markets","name":"New Exchange Markets","project":"Superalgos","markets":[],"id":"00cb629e-bad4-4c6e-8abb-499cad3992f4","savedPayload":{"position":{"x":17938.64382962515,"y":31054.23747069523},"targetPosition":{"x":17860.64382962515,"y":31075.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"exchangeAccounts":{"type":"Exchange Accounts","name":"New Exchange Accounts","project":"Superalgos","userAccounts":[{"type":"User Account","name":"New User Account","project":"Superalgos","userAssets":{"type":"User Assets","name":"New User Assets","project":"Superalgos","assets":[],"id":"4909d182-e0d5-49a9-8ad2-a553c8aaaf88","savedPayload":{"position":{"x":17912.64382962515,"y":31301.23747069523},"targetPosition":{"x":17920.64382962515,"y":31249.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"userKeys":{"type":"User Keys","name":"New User Keys","project":"Superalgos","keys":[{"type":"Exchange Account Key","name":"New Exchange Account Key","config":"{ \n\"codeName\": \"Paste your exchange API name or label\",\n\"secret\": \"Paste your exchange API secret key\"\n}","project":"Superalgos","id":"075eb2a2-299b-4a0f-9f6d-76c385521dc4","savedPayload":{"position":{"x":17800.64382962515,"y":31332.23747069523},"targetPosition":{"x":17883.64382962515,"y":31289.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{}}}],"id":"e062ef2e-b252-4a66-8f58-d9aa8031f526","savedPayload":{"position":{"x":17883.64382962515,"y":31289.23747069523},"targetPosition":{"x":17920.64382962515,"y":31249.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"id":"8e75be98-f874-486d-b749-536e364934dc","savedPayload":{"position":{"x":17920.64382962515,"y":31249.23747069523},"targetPosition":{"x":17845.64382962515,"y":31164.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}}],"id":"052f73cd-7ed7-4537-8b01-840b5b892fea","savedPayload":{"position":{"x":17845.64382962515,"y":31164.23747069523},"targetPosition":{"x":17860.64382962515,"y":31075.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":1,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"id":"07a7ec7c-273e-4675-8d8d-21ab8514a1f0","savedPayload":{"position":{"x":17873.301618063546,"y":32539.08061122679},"targetPosition":{"x":18473.301618063546,"y":31499.850126685462},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":true,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}},{"type":"Crypto Exchange","name":"Deribit","config":"{ \n\"codeName\": \"deribit\"\n}","project":"Superalgos","exchangeAssets":{"type":"Exchange Assets","name":"New Exchange Assets","config":"{ \n\"addMissingAssetsFilter\": { \"quotedAsset\": \"USDT\"} \n}","project":"Superalgos","assets":[],"id":"f0b2354b-89e3-4eca-b051-664a3b8283f6","savedPayload":{"position":{"x":17862.64382962515,"y":30844.23747069523},"targetPosition":{"x":17906.64382962515,"y":30929.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":2,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"exchangeMarkets":{"type":"Exchange Markets","name":"New Exchange Markets","project":"Superalgos","markets":[],"id":"4ae1f824-82a8-4796-a2d5-3d2358d8089f","savedPayload":{"position":{"x":17912.64382962515,"y":31024.23747069523},"targetPosition":{"x":17906.64382962515,"y":30929.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"exchangeAccounts":{"type":"Exchange Accounts","name":"New Exchange Accounts","project":"Superalgos","userAccounts":[{"type":"User Account","name":"New User Account","project":"Superalgos","userAssets":{"type":"User Assets","name":"New User Assets","project":"Superalgos","assets":[],"id":"2013fe7a-d52c-4c9d-ba53-d281d014a8fc","savedPayload":{"position":{"x":17873.64382962515,"y":30926.23747069523},"targetPosition":{"x":17855.64382962515,"y":30967.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"userKeys":{"type":"User Keys","name":"New User Keys","project":"Superalgos","keys":[{"type":"Exchange Account Key","name":"New Exchange Account Key","config":"{ \n\"codeName\": \"Paste your exchange API name or label\",\n\"secret\": \"Paste your exchange API secret key\"\n}","project":"Superalgos","id":"706d5778-ed21-49bd-9277-1840ec52708d","savedPayload":{"position":{"x":17729.64382962515,"y":31033.23747069523},"targetPosition":{"x":17813.64382962515,"y":31053.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{}}}],"id":"2e76bc02-6e10-4f14-9bf1-a11dc4268466","savedPayload":{"position":{"x":17813.64382962515,"y":31053.23747069523},"targetPosition":{"x":17855.64382962515,"y":30967.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"id":"89a3ccc7-20ab-4e2d-929b-52d9286179b7","savedPayload":{"position":{"x":17855.64382962515,"y":30967.23747069523},"targetPosition":{"x":17818.64382962515,"y":30920.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}}],"id":"5c8219e3-4509-4b8b-941b-b88ac2c12237","savedPayload":{"position":{"x":17818.64382962515,"y":30920.23747069523},"targetPosition":{"x":17906.64382962515,"y":30929.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":1,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"id":"21971815-4248-45df-8e04-20b9a5a83f06","savedPayload":{"position":{"x":17747.782680228695,"y":32455.686028314496},"targetPosition":{"x":18473.301618063546,"y":31499.850126685462},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":true,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}},{"type":"Crypto Exchange","name":"DigiFinex","config":"{ \n\"codeName\": \"digifinex\"\n}","project":"Superalgos","exchangeAssets":{"type":"Exchange Assets","name":"New Exchange Assets","config":"{ \n\"addMissingAssetsFilter\": { \"quotedAsset\": \"USDT\"} \n}","project":"Superalgos","assets":[],"id":"e583c93e-9a44-4e0d-acb7-56d7e00a555a","savedPayload":{"position":{"x":17954.64382962515,"y":30992.23747069523},"targetPosition":{"x":17996.64382962515,"y":31033.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":2,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"exchangeMarkets":{"type":"Exchange Markets","name":"New Exchange Markets","project":"Superalgos","markets":[],"id":"8917c7c0-b420-4d4f-a35a-c0fc6870f0de","savedPayload":{"position":{"x":18052.64382962515,"y":30972.23747069523},"targetPosition":{"x":17996.64382962515,"y":31033.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"exchangeAccounts":{"type":"Exchange Accounts","name":"New Exchange Accounts","project":"Superalgos","userAccounts":[{"type":"User Account","name":"New User Account","project":"Superalgos","userAssets":{"type":"User Assets","name":"New User Assets","project":"Superalgos","assets":[],"id":"a00b5bb0-5ab9-42e2-91fe-b450c7eb66d2","savedPayload":{"position":{"x":18220.64382962515,"y":31090.23747069523},"targetPosition":{"x":18123.64382962515,"y":30998.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"userKeys":{"type":"User Keys","name":"New User Keys","project":"Superalgos","keys":[{"type":"Exchange Account Key","name":"New Exchange Account Key","config":"{ \n\"codeName\": \"Paste your exchange API name or label\",\n\"secret\": \"Paste your exchange API secret key\"\n}","project":"Superalgos","id":"2aafc473-339b-4d23-9b74-06fa7574c293","savedPayload":{"position":{"x":18144.64382962515,"y":31123.23747069523},"targetPosition":{"x":18203.64382962515,"y":31084.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{}}}],"id":"99e9e136-1ac7-4400-a100-0a2d37f0882d","savedPayload":{"position":{"x":18203.64382962515,"y":31084.23747069523},"targetPosition":{"x":18123.64382962515,"y":30998.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"id":"b7cee21b-ddcb-4fd7-b610-43aabb2d1766","savedPayload":{"position":{"x":18123.64382962515,"y":30998.23747069523},"targetPosition":{"x":18032.64382962515,"y":30976.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}}],"id":"08e84a25-4368-4ad6-939f-5a16cece62cc","savedPayload":{"position":{"x":18032.64382962515,"y":30976.23747069523},"targetPosition":{"x":17996.64382962515,"y":31033.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":1,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"id":"b7d56781-0c51-4ec1-95fd-bf4dc8c00352","savedPayload":{"position":{"x":17633.70560944751,"y":32357.217342244825},"targetPosition":{"x":18473.301618063546,"y":31499.850126685462},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":true,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}},{"type":"Crypto Exchange","name":"DSX","config":"{ \n\"codeName\": \"dsx\"\n}","project":"Superalgos","exchangeAssets":{"type":"Exchange Assets","name":"New Exchange Assets","config":"{ \n\"addMissingAssetsFilter\": { \"quotedAsset\": \"USDT\"} \n}","project":"Superalgos","assets":[],"id":"d672ab56-cd32-4ff5-8fc5-3733262aeccb","savedPayload":{"position":{"x":17916.64382962515,"y":31106.23747069523},"targetPosition":{"x":17955.64382962515,"y":31011.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":2,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"exchangeMarkets":{"type":"Exchange Markets","name":"New Exchange Markets","project":"Superalgos","markets":[],"id":"3731a7b5-ba9d-483e-bb41-abf3ae0232c6","savedPayload":{"position":{"x":17878.64382962515,"y":30946.23747069523},"targetPosition":{"x":17955.64382962515,"y":31011.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"exchangeAccounts":{"type":"Exchange Accounts","name":"New Exchange Accounts","project":"Superalgos","userAccounts":[{"type":"User Account","name":"New User Account","project":"Superalgos","userAssets":{"type":"User Assets","name":"New User Assets","project":"Superalgos","assets":[],"id":"9ef7e0ac-dc27-4b47-a06e-0cb7e80ee3d7","savedPayload":{"position":{"x":18124.64382962515,"y":31136.23747069523},"targetPosition":{"x":18093.64382962515,"y":31072.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"userKeys":{"type":"User Keys","name":"New User Keys","project":"Superalgos","keys":[{"type":"Exchange Account Key","name":"New Exchange Account Key","config":"{ \n\"codeName\": \"Paste your exchange API name or label\",\n\"secret\": \"Paste your exchange API secret key\"\n}","project":"Superalgos","id":"77491a3c-3db7-446f-aa67-9b5a1a3be7b3","savedPayload":{"position":{"x":18109.64382962515,"y":31081.23747069523},"targetPosition":{"x":18188.64382962515,"y":31137.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{}}}],"id":"bd1bd0b7-4943-4aeb-bf90-d3192dcabbb1","savedPayload":{"position":{"x":18188.64382962515,"y":31137.23747069523},"targetPosition":{"x":18093.64382962515,"y":31072.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"id":"45747fef-f30e-4fae-b02d-5768ae7dbe68","savedPayload":{"position":{"x":18093.64382962515,"y":31072.23747069523},"targetPosition":{"x":18018.64382962515,"y":31005.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}}],"id":"aa2e1c9b-428c-4bb0-9e75-ceb8c9043d4b","savedPayload":{"position":{"x":18018.64382962515,"y":31005.23747069523},"targetPosition":{"x":17955.64382962515,"y":31011.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":1,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"id":"4c543abc-7372-4701-bc58-107578d45c25","savedPayload":{"position":{"x":17532.869469272537,"y":32245.227463019433},"targetPosition":{"x":18473.301618063546,"y":31499.850126685462},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":true,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}},{"type":"Crypto Exchange","name":"FCoin","config":"{ \n\"codeName\": \"fcoin\"\n}","project":"Superalgos","exchangeAssets":{"type":"Exchange Assets","name":"New Exchange Assets","config":"{ \n\"addMissingAssetsFilter\": { \"quotedAsset\": \"USDT\"} \n}","project":"Superalgos","assets":[],"id":"a97d578c-6d7f-403c-8294-18aacf14abd8","savedPayload":{"position":{"x":17893.64382962515,"y":30953.23747069523},"targetPosition":{"x":17919.64382962515,"y":30948.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":2,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"exchangeMarkets":{"type":"Exchange Markets","name":"New Exchange Markets","project":"Superalgos","markets":[],"id":"442c3834-482e-4928-9255-8ac859ae012e","savedPayload":{"position":{"x":17905.64382962515,"y":30896.23747069523},"targetPosition":{"x":17919.64382962515,"y":30948.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"exchangeAccounts":{"type":"Exchange Accounts","name":"New Exchange Accounts","project":"Superalgos","userAccounts":[{"type":"User Account","name":"New User Account","project":"Superalgos","userAssets":{"type":"User Assets","name":"New User Assets","project":"Superalgos","assets":[],"id":"79754959-1219-4c4d-be63-22766158beb5","savedPayload":{"position":{"x":18106.64382962515,"y":30976.23747069523},"targetPosition":{"x":18069.64382962515,"y":31056.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"userKeys":{"type":"User Keys","name":"New User Keys","project":"Superalgos","keys":[{"type":"Exchange Account Key","name":"New Exchange Account Key","config":"{ \n\"codeName\": \"Paste your exchange API name or label\",\n\"secret\": \"Paste your exchange API secret key\"\n}","project":"Superalgos","id":"1c3ae096-5024-43c3-abca-24498254e363","savedPayload":{"position":{"x":18112.64382962515,"y":30919.23747069523},"targetPosition":{"x":18126.64382962515,"y":30965.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{}}}],"id":"59db5bfd-e413-48a7-af63-237ad56adc82","savedPayload":{"position":{"x":18126.64382962515,"y":30965.23747069523},"targetPosition":{"x":18069.64382962515,"y":31056.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"id":"833c4e54-08f4-48ec-b90a-2767eb55f244","savedPayload":{"position":{"x":18069.64382962515,"y":31056.23747069523},"targetPosition":{"x":17996.64382962515,"y":30970.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}}],"id":"a8cf17b3-0ea7-4a14-8c76-f655344b58a3","savedPayload":{"position":{"x":17996.64382962515,"y":30970.23747069523},"targetPosition":{"x":17919.64382962515,"y":30948.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":1,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"id":"6ddedcbd-07cb-4928-91b3-348f47118391","savedPayload":{"position":{"x":17446.864505870937,"y":32121.482537933218},"targetPosition":{"x":18473.301618063546,"y":31499.850126685462},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":true,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}},{"type":"Crypto Exchange","name":"FCoinJP","config":"{ \n\"codeName\": \"fcoinjp\"\n}","project":"Superalgos","exchangeAssets":{"type":"Exchange Assets","name":"New Exchange Assets","config":"{ \n\"addMissingAssetsFilter\": { \"quotedAsset\": \"USDT\"} \n}","project":"Superalgos","assets":[],"id":"4a8a9810-6df6-451a-ab26-22bd7e7be85a","savedPayload":{"position":{"x":17930.64382962515,"y":31129.23747069523},"targetPosition":{"x":17942.64382962515,"y":31052.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":2,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"exchangeMarkets":{"type":"Exchange Markets","name":"New Exchange Markets","project":"Superalgos","markets":[],"id":"138ab40c-18ca-4a11-9709-0baa040873e6","savedPayload":{"position":{"x":18007.64382962515,"y":31122.23747069523},"targetPosition":{"x":17942.64382962515,"y":31052.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"exchangeAccounts":{"type":"Exchange Accounts","name":"New Exchange Accounts","project":"Superalgos","userAccounts":[{"type":"User Account","name":"New User Account","project":"Superalgos","userAssets":{"type":"User Assets","name":"New User Assets","project":"Superalgos","assets":[],"id":"258cdf92-8ed0-4133-ae2a-b9f086f56a13","savedPayload":{"position":{"x":17897.64382962515,"y":30887.23747069523},"targetPosition":{"x":17903.64382962515,"y":30977.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"userKeys":{"type":"User Keys","name":"New User Keys","project":"Superalgos","keys":[{"type":"Exchange Account Key","name":"New Exchange Account Key","config":"{ \n\"codeName\": \"Paste your exchange API name or label\",\n\"secret\": \"Paste your exchange API secret key\"\n}","project":"Superalgos","id":"537e8f0c-05ca-4403-bc96-da6c2f4678ae","savedPayload":{"position":{"x":17825.64382962515,"y":30842.23747069523},"targetPosition":{"x":17836.64382962515,"y":30926.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{}}}],"id":"62519e63-8f4e-4b72-a341-0a6eea01ac3f","savedPayload":{"position":{"x":17836.64382962515,"y":30926.23747069523},"targetPosition":{"x":17903.64382962515,"y":30977.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"id":"b4974cc1-f594-436b-8aa4-aff2733b8e3c","savedPayload":{"position":{"x":17903.64382962515,"y":30977.23747069523},"targetPosition":{"x":17873.64382962515,"y":31061.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}}],"id":"d84b404f-75e2-4eb5-b34a-b45af8a57ca7","savedPayload":{"position":{"x":17873.64382962515,"y":31061.23747069523},"targetPosition":{"x":17942.64382962515,"y":31052.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":1,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"id":"982627ea-df84-4ba9-9219-612fbe1e4276","savedPayload":{"position":{"x":17377.047068892425,"y":31987.934098376423},"targetPosition":{"x":18473.301618063546,"y":31499.850126685462},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":true,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}},{"type":"Crypto Exchange","name":"Gate.io","config":"{ \n\"codeName\": \"gateio\"\n}","project":"Superalgos","exchangeAssets":{"type":"Exchange Assets","name":"New Exchange Assets","config":"{ \n\"addMissingAssetsFilter\": { \"quotedAsset\": \"USDT\"} \n}","project":"Superalgos","assets":[],"id":"71a15089-9d40-4726-9a41-37d406064164","savedPayload":{"position":{"x":17930.64382962515,"y":30993.23747069523},"targetPosition":{"x":17880.64382962515,"y":31031.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":2,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"exchangeMarkets":{"type":"Exchange Markets","name":"New Exchange Markets","project":"Superalgos","markets":[],"id":"c025e976-c2c6-49de-81ec-48e2f737b412","savedPayload":{"position":{"x":17925.64382962515,"y":31053.23747069523},"targetPosition":{"x":17880.64382962515,"y":31031.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"exchangeAccounts":{"type":"Exchange Accounts","name":"New Exchange Accounts","project":"Superalgos","userAccounts":[{"type":"User Account","name":"New User Account","project":"Superalgos","userAssets":{"type":"User Assets","name":"New User Assets","project":"Superalgos","assets":[],"id":"876f964a-e12d-4438-87fb-a84be22f86d1","savedPayload":{"position":{"x":17914.64382962515,"y":30833.23747069523},"targetPosition":{"x":17827.64382962515,"y":30882.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"userKeys":{"type":"User Keys","name":"New User Keys","project":"Superalgos","keys":[{"type":"Exchange Account Key","name":"New Exchange Account Key","config":"{ \n\"codeName\": \"Paste your exchange API name or label\",\n\"secret\": \"Paste your exchange API secret key\"\n}","project":"Superalgos","id":"0c5d34c4-467f-4e98-bd39-1b2d9afb834e","savedPayload":{"position":{"x":17852.64382962515,"y":30831.23747069523},"targetPosition":{"x":17870.64382962515,"y":30847.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{}}}],"id":"89316d8c-893a-46ae-b147-948b4b8a5292","savedPayload":{"position":{"x":17870.64382962515,"y":30847.23747069523},"targetPosition":{"x":17827.64382962515,"y":30882.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"id":"a2a5de53-bd45-4904-8bae-0cf5ed66d2af","savedPayload":{"position":{"x":17827.64382962515,"y":30882.23747069523},"targetPosition":{"x":17800.64382962515,"y":30936.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}}],"id":"f6f4072d-8cf6-4e47-8b4e-a21cd553348a","savedPayload":{"position":{"x":17800.64382962515,"y":30936.23747069523},"targetPosition":{"x":17880.64382962515,"y":31031.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":1,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"id":"c4028289-4cdb-4da0-90e6-5f93328b8e03","savedPayload":{"position":{"x":17324.518221025064,"y":31846.688283018826},"targetPosition":{"x":18473.301618063546,"y":31499.850126685462},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":true,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}},{"type":"Crypto Exchange","name":"Gemini","config":"{ \n\"codeName\": \"gemini\"\n}","project":"Superalgos","exchangeAssets":{"type":"Exchange Assets","name":"New Exchange Assets","config":"{ \n\"addMissingAssetsFilter\": { \"quotedAsset\": \"USDT\"} \n}","project":"Superalgos","assets":[],"id":"9eb15872-8d15-4086-9920-46909eb5f9e7","savedPayload":{"position":{"x":17951.64382962515,"y":30901.23747069523},"targetPosition":{"x":17971.64382962515,"y":30935.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":2,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"exchangeMarkets":{"type":"Exchange Markets","name":"New Exchange Markets","project":"Superalgos","markets":[],"id":"a84dcf06-57c6-47d7-97a0-9f03f3af8b34","savedPayload":{"position":{"x":18045.64382962515,"y":30891.23747069523},"targetPosition":{"x":17971.64382962515,"y":30935.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"exchangeAccounts":{"type":"Exchange Accounts","name":"New Exchange Accounts","project":"Superalgos","userAccounts":[{"type":"User Account","name":"New User Account","project":"Superalgos","userAssets":{"type":"User Assets","name":"New User Assets","project":"Superalgos","assets":[],"id":"5da1ba65-3839-4664-8105-2ccb11652767","savedPayload":{"position":{"x":18028.64382962515,"y":31112.23747069523},"targetPosition":{"x":17941.64382962515,"y":31044.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"userKeys":{"type":"User Keys","name":"New User Keys","project":"Superalgos","keys":[{"type":"Exchange Account Key","name":"New Exchange Account Key","config":"{ \n\"codeName\": \"Paste your exchange API name or label\",\n\"secret\": \"Paste your exchange API secret key\"\n}","project":"Superalgos","id":"337fe5e2-b9fd-40eb-9f42-44fc5057d981","savedPayload":{"position":{"x":17957.64382962515,"y":31129.23747069523},"targetPosition":{"x":17875.64382962515,"y":31086.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{}}}],"id":"17a3f4a3-8914-4995-afb0-7e8115791b17","savedPayload":{"position":{"x":17875.64382962515,"y":31086.23747069523},"targetPosition":{"x":17941.64382962515,"y":31044.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"id":"32e4a3f1-40d8-421f-9634-7ab339858286","savedPayload":{"position":{"x":17941.64382962515,"y":31044.23747069523},"targetPosition":{"x":17877.64382962515,"y":30977.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}}],"id":"365f6865-e707-415d-a168-b67c66ca9553","savedPayload":{"position":{"x":17877.64382962515,"y":30977.23747069523},"targetPosition":{"x":17971.64382962515,"y":30935.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":1,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"id":"58bf8247-baef-4ea6-a483-7ed8f0ba5043","savedPayload":{"position":{"x":17290.10637357894,"y":31699.972622744786},"targetPosition":{"x":18473.301618063546,"y":31499.850126685462},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":true,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}},{"type":"Crypto Exchange","name":"HitBTC","config":"{ \n\"codeName\": \"hitbtc\"\n}","project":"Superalgos","exchangeAssets":{"type":"Exchange Assets","name":"New Exchange Assets","config":"{ \n\"addMissingAssetsFilter\": { \"quotedAsset\": \"USDT\"} \n}","project":"Superalgos","assets":[],"id":"1632c520-fa79-442f-b33b-430cb1356de6","savedPayload":{"position":{"x":17809.64382962515,"y":31086.23747069523},"targetPosition":{"x":17880.64382962515,"y":31069.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":2,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"exchangeMarkets":{"type":"Exchange Markets","name":"New Exchange Markets","project":"Superalgos","markets":[],"id":"576d1666-dbd3-4914-9fe2-fa05bdf72eea","savedPayload":{"position":{"x":17840.64382962515,"y":31148.23747069523},"targetPosition":{"x":17880.64382962515,"y":31069.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"exchangeAccounts":{"type":"Exchange Accounts","name":"New Exchange Accounts","project":"Superalgos","userAccounts":[{"type":"User Account","name":"New User Account","project":"Superalgos","userAssets":{"type":"User Assets","name":"New User Assets","project":"Superalgos","assets":[],"id":"41317aae-08ce-48cf-a47b-c2d2cc3920ec","savedPayload":{"position":{"x":18096.64382962515,"y":30975.23747069523},"targetPosition":{"x":18026.64382962515,"y":31066.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"userKeys":{"type":"User Keys","name":"New User Keys","project":"Superalgos","keys":[{"type":"Exchange Account Key","name":"New Exchange Account Key","config":"{ \n\"codeName\": \"Paste your exchange API name or label\",\n\"secret\": \"Paste your exchange API secret key\"\n}","project":"Superalgos","id":"23d7e4ba-8432-4214-bd94-0db5046e39cd","savedPayload":{"position":{"x":18039.64382962515,"y":31075.23747069523},"targetPosition":{"x":17981.64382962515,"y":31126.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{}}}],"id":"ab200349-5ba5-44d2-ad5c-fa826303cfcd","savedPayload":{"position":{"x":17981.64382962515,"y":31126.23747069523},"targetPosition":{"x":18026.64382962515,"y":31066.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"id":"a5f24785-5b2c-429b-a2e4-07063e2de904","savedPayload":{"position":{"x":18026.64382962515,"y":31066.23747069523},"targetPosition":{"x":17972.64382962515,"y":31093.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}}],"id":"13f275ca-06a6-4a72-8b4d-a9c079b9cef4","savedPayload":{"position":{"x":17972.64382962515,"y":31093.23747069523},"targetPosition":{"x":17880.64382962515,"y":31069.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":1,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"id":"8384fa0b-854c-4c23-846e-a5da0179a738","savedPayload":{"position":{"x":17274.354221944915,"y":31550.1009111605},"targetPosition":{"x":18473.301618063546,"y":31499.850126685462},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":true,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}},{"type":"Crypto Exchange","name":"HitBTC","config":"{ \n\"codeName\": \"hitbtc2\"\n}","project":"Superalgos","exchangeAssets":{"type":"Exchange Assets","name":"New Exchange Assets","config":"{ \n\"addMissingAssetsFilter\": { \"quotedAsset\": \"USDT\"} \n}","project":"Superalgos","assets":[],"id":"9a29cb9e-ee8d-4315-8532-eef82224b84a","savedPayload":{"position":{"x":17838.64382962515,"y":30922.23747069523},"targetPosition":{"x":17829.64382962515,"y":30949.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":2,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"exchangeMarkets":{"type":"Exchange Markets","name":"New Exchange Markets","project":"Superalgos","markets":[],"id":"badd79e7-1e21-4dc3-bfa7-8dfb4a6c6267","savedPayload":{"position":{"x":17920.64382962515,"y":30944.23747069523},"targetPosition":{"x":17829.64382962515,"y":30949.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"exchangeAccounts":{"type":"Exchange Accounts","name":"New Exchange Accounts","project":"Superalgos","userAccounts":[{"type":"User Account","name":"New User Account","project":"Superalgos","userAssets":{"type":"User Assets","name":"New User Assets","project":"Superalgos","assets":[],"id":"ffdda0b7-af50-4010-84da-2bc0d562af2b","savedPayload":{"position":{"x":17887.64382962515,"y":30982.23747069523},"targetPosition":{"x":17836.64382962515,"y":31023.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"userKeys":{"type":"User Keys","name":"New User Keys","project":"Superalgos","keys":[{"type":"Exchange Account Key","name":"New Exchange Account Key","config":"{ \n\"codeName\": \"Paste your exchange API name or label\",\n\"secret\": \"Paste your exchange API secret key\"\n}","project":"Superalgos","id":"24816eed-adf7-453e-9b38-42ea4758dbaa","savedPayload":{"position":{"x":18021.64382962515,"y":30979.23747069523},"targetPosition":{"x":17931.64382962515,"y":30923.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{}}}],"id":"1dd16858-5641-4454-88a3-e5d7446e12a3","savedPayload":{"position":{"x":17931.64382962515,"y":30923.23747069523},"targetPosition":{"x":17836.64382962515,"y":31023.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"id":"457d75ed-ad21-4ee5-b36b-88cdc444008e","savedPayload":{"position":{"x":17836.64382962515,"y":31023.23747069523},"targetPosition":{"x":17808.64382962515,"y":31039.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}}],"id":"b29ded7e-e2d5-4c7f-89af-b0816c32c743","savedPayload":{"position":{"x":17808.64382962515,"y":31039.23747069523},"targetPosition":{"x":17829.64382962515,"y":30949.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":1,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"id":"09c634c2-5aba-49c5-80bc-4fd4175e7f0c","savedPayload":{"position":{"x":17277.51018696414,"y":31399.436714686686},"targetPosition":{"x":18473.301618063546,"y":31499.850126685462},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":true,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}},{"type":"Crypto Exchange","name":"Huobi Pro","config":"{ \n\"codeName\": \"huobipro\"\n}","project":"Superalgos","exchangeAssets":{"type":"Exchange Assets","name":"New Exchange Assets","config":"{ \n\"addMissingAssetsFilter\": { \"quotedAsset\": \"USDT\"} \n}","project":"Superalgos","assets":[],"id":"86caa38c-5bdf-40e4-b27b-8d8b64319575","savedPayload":{"position":{"x":18071.64382962515,"y":31171.23747069523},"targetPosition":{"x":17996.64382962515,"y":31077.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":2,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"exchangeMarkets":{"type":"Exchange Markets","name":"New Exchange Markets","project":"Superalgos","markets":[],"id":"001225af-c715-4566-9502-f8f0ac1c4531","savedPayload":{"position":{"x":18040.64382962515,"y":31019.23747069523},"targetPosition":{"x":17996.64382962515,"y":31077.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"exchangeAccounts":{"type":"Exchange Accounts","name":"New Exchange Accounts","project":"Superalgos","userAccounts":[{"type":"User Account","name":"New User Account","project":"Superalgos","userAssets":{"type":"User Assets","name":"New User Assets","project":"Superalgos","assets":[],"id":"b4bf5ccb-b529-4500-a192-d9c3a0613389","savedPayload":{"position":{"x":18129.64382962515,"y":31073.23747069523},"targetPosition":{"x":18033.64382962515,"y":31090.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"userKeys":{"type":"User Keys","name":"New User Keys","project":"Superalgos","keys":[{"type":"Exchange Account Key","name":"New Exchange Account Key","config":"{ \n\"codeName\": \"Paste your exchange API name or label\",\n\"secret\": \"Paste your exchange API secret key\"\n}","project":"Superalgos","id":"2e58c6d1-cfa7-4dc7-a322-e9356596ea1e","savedPayload":{"position":{"x":17976.64382962515,"y":31132.23747069523},"targetPosition":{"x":17953.64382962515,"y":31093.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{}}}],"id":"ae04ddf4-ae3e-4bdc-9393-41acc38ef818","savedPayload":{"position":{"x":17953.64382962515,"y":31093.23747069523},"targetPosition":{"x":18033.64382962515,"y":31090.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"id":"2428e8ef-6a09-48fa-8ae4-ebfb28420be8","savedPayload":{"position":{"x":18033.64382962515,"y":31090.23747069523},"targetPosition":{"x":18085.64382962515,"y":31157.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}}],"id":"55c71c8b-f21f-4d16-ae93-e29362c39bf5","savedPayload":{"position":{"x":18085.64382962515,"y":31157.23747069523},"targetPosition":{"x":17996.64382962515,"y":31077.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":1,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"id":"967c3914-a76d-4389-9c7e-9c258ae683bd","savedPayload":{"position":{"x":17299.524497182978,"y":31250.35609770415},"targetPosition":{"x":18473.301618063546,"y":31499.850126685462},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":true,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}},{"type":"Crypto Exchange","name":"Huobi Russia","config":"{ \n\"codeName\": \"huobiru\"\n}","project":"Superalgos","exchangeAssets":{"type":"Exchange Assets","name":"New Exchange Assets","config":"{ \n\"addMissingAssetsFilter\": { \"quotedAsset\": \"USDT\"} \n}","project":"Superalgos","assets":[],"id":"9b7b32d6-a42e-44bb-8065-5aa32b1e844b","savedPayload":{"position":{"x":17980.64382962515,"y":31034.23747069523},"targetPosition":{"x":17957.64382962515,"y":31088.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":2,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"exchangeMarkets":{"type":"Exchange Markets","name":"New Exchange Markets","project":"Superalgos","markets":[],"id":"8d74201c-33cd-4e12-8920-b08d0ef97572","savedPayload":{"position":{"x":17992.64382962515,"y":31105.23747069523},"targetPosition":{"x":17957.64382962515,"y":31088.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"exchangeAccounts":{"type":"Exchange Accounts","name":"New Exchange Accounts","project":"Superalgos","userAccounts":[{"type":"User Account","name":"New User Account","project":"Superalgos","userAssets":{"type":"User Assets","name":"New User Assets","project":"Superalgos","assets":[],"id":"c6e289d7-074b-4837-96e3-687988886fcc","savedPayload":{"position":{"x":18078.64382962515,"y":30954.23747069523},"targetPosition":{"x":18008.64382962515,"y":31029.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"userKeys":{"type":"User Keys","name":"New User Keys","project":"Superalgos","keys":[{"type":"Exchange Account Key","name":"New Exchange Account Key","config":"{ \n\"codeName\": \"Paste your exchange API name or label\",\n\"secret\": \"Paste your exchange API secret key\"\n}","project":"Superalgos","id":"d72f81ba-6b41-414d-9cf0-d5f9c0c25403","savedPayload":{"position":{"x":18026.64382962515,"y":31021.23747069523},"targetPosition":{"x":18083.64382962515,"y":31117.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{}}}],"id":"5354f66c-6e73-4fe5-80ca-2c25b761ef51","savedPayload":{"position":{"x":18083.64382962515,"y":31117.23747069523},"targetPosition":{"x":18008.64382962515,"y":31029.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"id":"81f5adbb-054c-47f2-b019-52585f5d7417","savedPayload":{"position":{"x":18008.64382962515,"y":31029.23747069523},"targetPosition":{"x":18018.64382962515,"y":31009.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}}],"id":"ecd8645b-4bb6-4641-a20f-cee51bf33f1a","savedPayload":{"position":{"x":18018.64382962515,"y":31009.23747069523},"targetPosition":{"x":17957.64382962515,"y":31088.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":1,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"id":"6f97bb5c-8d85-43ee-86a1-33e22cdfbb5e","savedPayload":{"position":{"x":17340.04997377857,"y":31105.21015059916},"targetPosition":{"x":18473.301618063546,"y":31499.850126685462},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":true,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}},{"type":"Crypto Exchange","name":"KKEX","config":"{ \n\"codeName\": \"kkex\"\n}","project":"Superalgos","exchangeAssets":{"type":"Exchange Assets","name":"New Exchange Assets","config":"{ \n\"addMissingAssetsFilter\": { \"quotedAsset\": \"USDT\"} \n}","project":"Superalgos","assets":[],"id":"daa4e07a-1cd8-4d92-8004-2eabfaa62f77","savedPayload":{"position":{"x":17924.64382962515,"y":31038.23747069523},"targetPosition":{"x":17987.64382962515,"y":31073.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":2,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"exchangeMarkets":{"type":"Exchange Markets","name":"New Exchange Markets","project":"Superalgos","markets":[],"id":"cb64951f-d984-4f51-a751-166a316084f3","savedPayload":{"position":{"x":17945.64382962515,"y":31156.23747069523},"targetPosition":{"x":17987.64382962515,"y":31073.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"exchangeAccounts":{"type":"Exchange Accounts","name":"New Exchange Accounts","project":"Superalgos","userAccounts":[{"type":"User Account","name":"New User Account","project":"Superalgos","userAssets":{"type":"User Assets","name":"New User Assets","project":"Superalgos","assets":[],"id":"6915bf12-9271-47e2-8b49-924ae9f5c65f","savedPayload":{"position":{"x":17958.64382962515,"y":31297.23747069523},"targetPosition":{"x":17875.64382962515,"y":31252.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"userKeys":{"type":"User Keys","name":"New User Keys","project":"Superalgos","keys":[{"type":"Exchange Account Key","name":"New Exchange Account Key","config":"{ \n\"codeName\": \"Paste your exchange API name or label\",\n\"secret\": \"Paste your exchange API secret key\"\n}","project":"Superalgos","id":"ff53381f-c6dd-4d17-a477-11396f60663f","savedPayload":{"position":{"x":17805.64382962515,"y":31141.23747069523},"targetPosition":{"x":17861.64382962515,"y":31223.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{}}}],"id":"ae05bfc4-6ac8-408c-a90b-263830b2a71e","savedPayload":{"position":{"x":17861.64382962515,"y":31223.23747069523},"targetPosition":{"x":17875.64382962515,"y":31252.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"id":"61c85f1a-a2a6-45c9-bb1e-3c76110f5d1e","savedPayload":{"position":{"x":17875.64382962515,"y":31252.23747069523},"targetPosition":{"x":17911.64382962515,"y":31154.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}}],"id":"9fafb114-37d2-4d04-9c42-83d04ff62fc7","savedPayload":{"position":{"x":17911.64382962515,"y":31154.23747069523},"targetPosition":{"x":17987.64382962515,"y":31073.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":1,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"id":"16ae95ce-796f-4f2b-942c-f98dcbf9cf4b","savedPayload":{"position":{"x":17398.44750577625,"y":30966.28791166355},"targetPosition":{"x":18473.301618063546,"y":31499.850126685462},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":true,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}},{"type":"Crypto Exchange","name":"LBank","config":"{ \n\"codeName\": \"lbank\"\n}","project":"Superalgos","exchangeAssets":{"type":"Exchange Assets","name":"New Exchange Assets","config":"{ \n\"addMissingAssetsFilter\": { \"quotedAsset\": \"USDT\"} \n}","project":"Superalgos","assets":[],"id":"def3f9d0-f09e-4e09-8b6d-a4c322a4384b","savedPayload":{"position":{"x":17877.64382962515,"y":31024.23747069523},"targetPosition":{"x":17838.64382962515,"y":31032.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":2,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"exchangeMarkets":{"type":"Exchange Markets","name":"New Exchange Markets","project":"Superalgos","markets":[],"id":"53eac3c1-96d6-4cb1-b54d-f3f174eaf733","savedPayload":{"position":{"x":17764.64382962515,"y":31036.23747069523},"targetPosition":{"x":17838.64382962515,"y":31032.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"exchangeAccounts":{"type":"Exchange Accounts","name":"New Exchange Accounts","project":"Superalgos","userAccounts":[{"type":"User Account","name":"New User Account","project":"Superalgos","userAssets":{"type":"User Assets","name":"New User Assets","project":"Superalgos","assets":[],"id":"c6c00704-1357-4426-910e-8134d6f87017","savedPayload":{"position":{"x":18030.64382962515,"y":31212.23747069523},"targetPosition":{"x":17951.64382962515,"y":31172.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"userKeys":{"type":"User Keys","name":"New User Keys","project":"Superalgos","keys":[{"type":"Exchange Account Key","name":"New Exchange Account Key","config":"{ \n\"codeName\": \"Paste your exchange API name or label\",\n\"secret\": \"Paste your exchange API secret key\"\n}","project":"Superalgos","id":"13990604-2192-4be1-b21b-53cf2bafc002","savedPayload":{"position":{"x":17893.64382962515,"y":31189.23747069523},"targetPosition":{"x":17964.64382962515,"y":31122.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{}}}],"id":"ed2c483e-d412-406d-b6f3-cfb1112a3a05","savedPayload":{"position":{"x":17964.64382962515,"y":31122.23747069523},"targetPosition":{"x":17951.64382962515,"y":31172.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"id":"6033b63c-c7fe-4a5d-8cf6-82128e2cfb41","savedPayload":{"position":{"x":17951.64382962515,"y":31172.23747069523},"targetPosition":{"x":17891.64382962515,"y":31096.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}}],"id":"20ece5c4-dbfa-4f4a-a9ee-8c8d9c38943b","savedPayload":{"position":{"x":17891.64382962515,"y":31096.23747069523},"targetPosition":{"x":17838.64382962515,"y":31032.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":1,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"id":"cb2558d6-dab0-4f35-b83f-7cfc161b3d4f","savedPayload":{"position":{"x":17473.796129211427,"y":30835.780267593447},"targetPosition":{"x":18473.301618063546,"y":31499.850126685462},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":true,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}},{"type":"Crypto Exchange","name":"Mercado Bitcoin","config":"{ \n\"codeName\": \"mercado\"\n}","project":"Superalgos","exchangeAssets":{"type":"Exchange Assets","name":"New Exchange Assets","config":"{ \n\"addMissingAssetsFilter\": { \"quotedAsset\": \"USDT\"} \n}","project":"Superalgos","assets":[],"id":"83ab2c39-e844-496f-bebb-7b8607428902","savedPayload":{"position":{"x":17849.64382962515,"y":31081.23747069523},"targetPosition":{"x":17849.64382962515,"y":30986.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":2,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"exchangeMarkets":{"type":"Exchange Markets","name":"New Exchange Markets","project":"Superalgos","markets":[],"id":"d69e722e-c71a-462a-8bbd-d3482d0eab21","savedPayload":{"position":{"x":17771.64382962515,"y":30887.23747069523},"targetPosition":{"x":17849.64382962515,"y":30986.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"exchangeAccounts":{"type":"Exchange Accounts","name":"New Exchange Accounts","project":"Superalgos","userAccounts":[{"type":"User Account","name":"New User Account","project":"Superalgos","userAssets":{"type":"User Assets","name":"New User Assets","project":"Superalgos","assets":[],"id":"18438709-83cf-49a3-96b8-888ab5adbcc5","savedPayload":{"position":{"x":17937.64382962515,"y":31080.23747069523},"targetPosition":{"x":17866.64382962515,"y":31013.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"userKeys":{"type":"User Keys","name":"New User Keys","project":"Superalgos","keys":[{"type":"Exchange Account Key","name":"New Exchange Account Key","config":"{ \n\"codeName\": \"Paste your exchange API name or label\",\n\"secret\": \"Paste your exchange API secret key\"\n}","project":"Superalgos","id":"6b9d4ed4-af81-462a-aace-fac0afd4687a","savedPayload":{"position":{"x":17787.64382962515,"y":30841.23747069523},"targetPosition":{"x":17873.64382962515,"y":30935.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{}}}],"id":"802a4c53-8617-4257-95a5-45bfaa60ad0e","savedPayload":{"position":{"x":17873.64382962515,"y":30935.23747069523},"targetPosition":{"x":17866.64382962515,"y":31013.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"id":"87936a4a-aac5-4aca-8f3e-2051611932c4","savedPayload":{"position":{"x":17866.64382962515,"y":31013.23747069523},"targetPosition":{"x":17829.64382962515,"y":30919.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}}],"id":"48f3a793-bb97-447b-8f1a-1d6965219747","savedPayload":{"position":{"x":17829.64382962515,"y":30919.23747069523},"targetPosition":{"x":17849.64382962515,"y":30986.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":1,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"id":"5002072e-145c-4aeb-a611-3e0e4c60ee5d","savedPayload":{"position":{"x":17564.907551281438,"y":30715.745401897337},"targetPosition":{"x":18473.301618063546,"y":31499.850126685462},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":true,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}},{"type":"Crypto Exchange","name":"OKCoin","config":"{ \n\"codeName\": \"okcoin\"\n}","project":"Superalgos","exchangeAssets":{"type":"Exchange Assets","name":"New Exchange Assets","config":"{ \n\"addMissingAssetsFilter\": { \"quotedAsset\": \"USDT\"} \n}","project":"Superalgos","assets":[],"id":"1e4dd5c8-0545-4698-8695-c985880243a3","savedPayload":{"position":{"x":17921.64382962515,"y":31043.23747069523},"targetPosition":{"x":17967.64382962515,"y":30969.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":2,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"exchangeMarkets":{"type":"Exchange Markets","name":"New Exchange Markets","project":"Superalgos","markets":[],"id":"0e188cae-9764-4963-a78b-e5d7ef272522","savedPayload":{"position":{"x":18005.64382962515,"y":30891.23747069523},"targetPosition":{"x":17967.64382962515,"y":30969.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"exchangeAccounts":{"type":"Exchange Accounts","name":"New Exchange Accounts","project":"Superalgos","userAccounts":[{"type":"User Account","name":"New User Account","project":"Superalgos","userAssets":{"type":"User Assets","name":"New User Assets","project":"Superalgos","assets":[],"id":"6d82bfd7-b4e1-4f93-a0f8-18f62cee944e","savedPayload":{"position":{"x":18047.64382962515,"y":30877.23747069523},"targetPosition":{"x":17963.64382962515,"y":30898.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"userKeys":{"type":"User Keys","name":"New User Keys","project":"Superalgos","keys":[{"type":"Exchange Account Key","name":"New Exchange Account Key","config":"{ \n\"codeName\": \"Paste your exchange API name or label\",\n\"secret\": \"Paste your exchange API secret key\"\n}","project":"Superalgos","id":"d815409c-1dd4-4e89-b844-5b96104509b4","savedPayload":{"position":{"x":17958.64382962515,"y":30988.23747069523},"targetPosition":{"x":17945.64382962515,"y":30961.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{}}}],"id":"238b9d2c-e2c0-4a77-945e-8e28604c0a2d","savedPayload":{"position":{"x":17945.64382962515,"y":30961.23747069523},"targetPosition":{"x":17963.64382962515,"y":30898.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"id":"8416c29a-5d73-4b2a-9463-511f400deafb","savedPayload":{"position":{"x":17963.64382962515,"y":30898.23747069523},"targetPosition":{"x":18047.64382962515,"y":30885.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}}],"id":"04abf32b-084e-4784-aa84-8c5612d3b7b9","savedPayload":{"position":{"x":18047.64382962515,"y":30885.23747069523},"targetPosition":{"x":17967.64382962515,"y":30969.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":1,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"id":"1f860b4b-2893-4a51-8649-19c47d494a37","savedPayload":{"position":{"x":17670.344890432916,"y":30608.07633611259},"targetPosition":{"x":18473.301618063546,"y":31499.850126685462},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":true,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}},{"type":"Crypto Exchange","name":"OKEX","config":"{ \n\"codeName\": \"okex\"\n}","project":"Superalgos","exchangeAssets":{"type":"Exchange Assets","name":"New Exchange Assets","config":"{ \n\"addMissingAssetsFilter\": { \"quotedAsset\": \"USDT\"} \n}","project":"Superalgos","assets":[],"id":"7f618566-3d10-4c3c-90b2-7541a5146eeb","savedPayload":{"position":{"x":17770.64382962515,"y":31094.23747069523},"targetPosition":{"x":17847.64382962515,"y":31102.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":2,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"exchangeMarkets":{"type":"Exchange Markets","name":"New Exchange Markets","project":"Superalgos","markets":[],"id":"21205576-5d12-452c-814f-eb56182162ae","savedPayload":{"position":{"x":17794.64382962515,"y":31173.23747069523},"targetPosition":{"x":17847.64382962515,"y":31102.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"exchangeAccounts":{"type":"Exchange Accounts","name":"New Exchange Accounts","project":"Superalgos","userAccounts":[{"type":"User Account","name":"New User Account","project":"Superalgos","userAssets":{"type":"User Assets","name":"New User Assets","project":"Superalgos","assets":[],"id":"46456247-ae9c-41ea-8395-a5e4a78007d4","savedPayload":{"position":{"x":17724.64382962515,"y":31147.23747069523},"targetPosition":{"x":17795.64382962515,"y":31083.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"userKeys":{"type":"User Keys","name":"New User Keys","project":"Superalgos","keys":[{"type":"Exchange Account Key","name":"New Exchange Account Key","config":"{ \n\"codeName\": \"Paste your exchange API name or label\",\n\"secret\": \"Paste your exchange API secret key\"\n}","project":"Superalgos","id":"706bf601-eaad-48bd-b0a7-8dad59066171","savedPayload":{"position":{"x":17715.64382962515,"y":31182.23747069523},"targetPosition":{"x":17706.64382962515,"y":31162.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{}}}],"id":"f9c7071c-2e5b-4c90-b482-dfc7ee001244","savedPayload":{"position":{"x":17706.64382962515,"y":31162.23747069523},"targetPosition":{"x":17795.64382962515,"y":31083.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"id":"e87e1e10-3404-48b9-8629-5df92ffa1979","savedPayload":{"position":{"x":17795.64382962515,"y":31083.23747069523},"targetPosition":{"x":17789.64382962515,"y":31181.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}}],"id":"08e8fd6a-6b23-4d65-8b8e-d966f845c07f","savedPayload":{"position":{"x":17789.64382962515,"y":31181.23747069523},"targetPosition":{"x":17847.64382962515,"y":31102.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":1,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"id":"aa0edec0-8b27-4f94-abce-1e437ce5aba6","savedPayload":{"position":{"x":17788.44533684223,"y":30514.471075725018},"targetPosition":{"x":18473.301618063546,"y":31499.850126685462},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":true,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}},{"type":"Crypto Exchange","name":"RightBTC","config":"{ \n\"codeName\": \"rightbtc\"\n}","project":"Superalgos","exchangeAssets":{"type":"Exchange Assets","name":"New Exchange Assets","config":"{ \n\"addMissingAssetsFilter\": { \"quotedAsset\": \"USDT\"} \n}","project":"Superalgos","assets":[],"id":"ade372e9-5070-4fa9-843e-57732c4106c3","savedPayload":{"position":{"x":17999.64382962515,"y":30964.23747069523},"targetPosition":{"x":17991.64382962515,"y":30935.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":2,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"exchangeMarkets":{"type":"Exchange Markets","name":"New Exchange Markets","project":"Superalgos","markets":[],"id":"b63d440e-4501-475c-b8a6-2b9a144e32a1","savedPayload":{"position":{"x":17984.64382962515,"y":30901.23747069523},"targetPosition":{"x":17991.64382962515,"y":30935.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"exchangeAccounts":{"type":"Exchange Accounts","name":"New Exchange Accounts","project":"Superalgos","userAccounts":[{"type":"User Account","name":"New User Account","project":"Superalgos","userAssets":{"type":"User Assets","name":"New User Assets","project":"Superalgos","assets":[],"id":"81d77477-4f2e-43c0-b284-dde54f91c37f","savedPayload":{"position":{"x":17864.64382962515,"y":31036.23747069523},"targetPosition":{"x":17861.64382962515,"y":31043.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"userKeys":{"type":"User Keys","name":"New User Keys","project":"Superalgos","keys":[{"type":"Exchange Account Key","name":"New Exchange Account Key","config":"{ \n\"codeName\": \"Paste your exchange API name or label\",\n\"secret\": \"Paste your exchange API secret key\"\n}","project":"Superalgos","id":"9ce3cc34-1ba4-4155-96a5-c946b1bcc5ab","savedPayload":{"position":{"x":17819.64382962515,"y":31127.23747069523},"targetPosition":{"x":17810.64382962515,"y":31080.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{}}}],"id":"c7df4af7-37c1-403d-ada1-b6a527821bdd","savedPayload":{"position":{"x":17810.64382962515,"y":31080.23747069523},"targetPosition":{"x":17861.64382962515,"y":31043.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"id":"6de19501-5ce7-4944-b9dd-25b149acbb38","savedPayload":{"position":{"x":17861.64382962515,"y":31043.23747069523},"targetPosition":{"x":17946.64382962515,"y":30988.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}}],"id":"aa87ace4-a976-401c-93f9-24a498261742","savedPayload":{"position":{"x":17946.64382962515,"y":30988.23747069523},"targetPosition":{"x":17991.64382962515,"y":30935.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":1,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"id":"c20cd9e1-52a0-4d17-b90c-e9d5b63315ce","savedPayload":{"position":{"x":17917.346375919715,"y":30436.405831608005},"targetPosition":{"x":18473.301618063546,"y":31499.850126685462},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":true,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}},{"type":"Crypto Exchange","name":"STEX","config":"{ \n\"codeName\": \"stex\"\n}","project":"Superalgos","exchangeAssets":{"type":"Exchange Assets","name":"New Exchange Assets","config":"{ \n\"addMissingAssetsFilter\": { \"quotedAsset\": \"USDT\"} \n}","project":"Superalgos","assets":[],"id":"f1d65161-4922-4a1e-ac98-df1a842347a7","savedPayload":{"position":{"x":17872.64382962515,"y":31001.23747069523},"targetPosition":{"x":17892.64382962515,"y":31092.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":2,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"exchangeMarkets":{"type":"Exchange Markets","name":"New Exchange Markets","project":"Superalgos","markets":[],"id":"c313b2c6-6154-4a9a-b826-fd99cc500cd9","savedPayload":{"position":{"x":17888.64382962515,"y":31186.23747069523},"targetPosition":{"x":17892.64382962515,"y":31092.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"exchangeAccounts":{"type":"Exchange Accounts","name":"New Exchange Accounts","project":"Superalgos","userAccounts":[{"type":"User Account","name":"New User Account","project":"Superalgos","userAssets":{"type":"User Assets","name":"New User Assets","project":"Superalgos","assets":[],"id":"d0a1259b-1c37-4d39-836e-3c434c3b3687","savedPayload":{"position":{"x":17778.64382962515,"y":31076.23747069523},"targetPosition":{"x":17858.64382962515,"y":31091.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"userKeys":{"type":"User Keys","name":"New User Keys","project":"Superalgos","keys":[{"type":"Exchange Account Key","name":"New Exchange Account Key","config":"{ \n\"codeName\": \"Paste your exchange API name or label\",\n\"secret\": \"Paste your exchange API secret key\"\n}","project":"Superalgos","id":"4a1e5627-459c-4dec-be13-c20d4a9ea58f","savedPayload":{"position":{"x":17841.64382962515,"y":31179.23747069523},"targetPosition":{"x":17795.64382962515,"y":31105.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{}}}],"id":"6981eb0d-0f0e-4f8e-9781-4a03e22e93fd","savedPayload":{"position":{"x":17795.64382962515,"y":31105.23747069523},"targetPosition":{"x":17858.64382962515,"y":31091.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"id":"7704478a-9717-43a8-bd2e-88daa6f84bd0","savedPayload":{"position":{"x":17858.64382962515,"y":31091.23747069523},"targetPosition":{"x":17941.64382962515,"y":31173.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}}],"id":"262aad86-f430-49ea-a636-e8bd816a9636","savedPayload":{"position":{"x":17941.64382962515,"y":31173.23747069523},"targetPosition":{"x":17892.64382962515,"y":31092.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":1,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"id":"0ea23137-3c65-4de1-9772-6ac1b65196e8","savedPayload":{"position":{"x":18055.01516127737,"y":30375.111739295193},"targetPosition":{"x":18473.301618063546,"y":31499.850126685462},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":true,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}},{"type":"Crypto Exchange","name":"TideBit","config":"{ \n\"codeName\": \"tidebit\"\n}","project":"Superalgos","exchangeAssets":{"type":"Exchange Assets","name":"New Exchange Assets","config":"{ \n\"addMissingAssetsFilter\": { \"quotedAsset\": \"USDT\"} \n}","project":"Superalgos","assets":[],"id":"c92318bd-8b2d-489b-b8e8-cf30fb63286e","savedPayload":{"position":{"x":17981.64382962515,"y":31021.23747069523},"targetPosition":{"x":17978.64382962515,"y":31048.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":2,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"exchangeMarkets":{"type":"Exchange Markets","name":"New Exchange Markets","project":"Superalgos","markets":[],"id":"83bca3ec-fc1c-435c-b5fe-b1cf92463fd1","savedPayload":{"position":{"x":18051.64382962515,"y":31072.23747069523},"targetPosition":{"x":17978.64382962515,"y":31048.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"exchangeAccounts":{"type":"Exchange Accounts","name":"New Exchange Accounts","project":"Superalgos","userAccounts":[{"type":"User Account","name":"New User Account","project":"Superalgos","userAssets":{"type":"User Assets","name":"New User Assets","project":"Superalgos","assets":[],"id":"2f3ee9b2-cd41-458c-84da-edac3155028a","savedPayload":{"position":{"x":18075.64382962515,"y":31059.23747069523},"targetPosition":{"x":17987.64382962515,"y":31047.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"userKeys":{"type":"User Keys","name":"New User Keys","project":"Superalgos","keys":[{"type":"Exchange Account Key","name":"New Exchange Account Key","config":"{ \n\"codeName\": \"Paste your exchange API name or label\",\n\"secret\": \"Paste your exchange API secret key\"\n}","project":"Superalgos","id":"009ae4b6-adbc-4900-9fc0-f18936eeed9b","savedPayload":{"position":{"x":18030.64382962515,"y":31058.23747069523},"targetPosition":{"x":18009.64382962515,"y":31028.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{}}}],"id":"3ee88180-fe10-41df-8251-b1ed0a526e7a","savedPayload":{"position":{"x":18009.64382962515,"y":31028.23747069523},"targetPosition":{"x":17987.64382962515,"y":31047.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"id":"bb88e6e8-a99a-4c4e-9ca5-ffed49aa8b54","savedPayload":{"position":{"x":17987.64382962515,"y":31047.23747069523},"targetPosition":{"x":17925.64382962515,"y":31135.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}}],"id":"13a4a95e-4333-4455-9f7c-90bc839d174a","savedPayload":{"position":{"x":17925.64382962515,"y":31135.23747069523},"targetPosition":{"x":17978.64382962515,"y":31048.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":1,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"id":"5563c310-701a-4c1e-8155-87c08c927ce3","savedPayload":{"position":{"x":18199.28057393076,"y":30331.55544323767},"targetPosition":{"x":18473.301618063546,"y":31499.850126685462},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":true,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}},{"type":"Crypto Exchange","name":"TimeX","config":"{ \n\"codeName\": \"timex\"\n}","project":"Superalgos","exchangeAssets":{"type":"Exchange Assets","name":"New Exchange Assets","config":"{ \n\"addMissingAssetsFilter\": { \"quotedAsset\": \"USDT\"} \n}","project":"Superalgos","assets":[],"id":"5c004b5f-eec4-414f-8d01-d9b3fddeee9e","savedPayload":{"position":{"x":17892.64382962515,"y":30973.23747069523},"targetPosition":{"x":17949.64382962515,"y":30914.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":2,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"exchangeMarkets":{"type":"Exchange Markets","name":"New Exchange Markets","project":"Superalgos","markets":[],"id":"59a33add-d0e9-4ae1-8a01-f1e0ed09cb61","savedPayload":{"position":{"x":17911.64382962515,"y":30878.23747069523},"targetPosition":{"x":17949.64382962515,"y":30914.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"exchangeAccounts":{"type":"Exchange Accounts","name":"New Exchange Accounts","project":"Superalgos","userAccounts":[{"type":"User Account","name":"New User Account","project":"Superalgos","userAssets":{"type":"User Assets","name":"New User Assets","project":"Superalgos","assets":[],"id":"a4189ba1-d1d4-4ff8-91dd-a8696ca493e3","savedPayload":{"position":{"x":17953.64382962515,"y":30880.23747069523},"targetPosition":{"x":17924.64382962515,"y":30871.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"userKeys":{"type":"User Keys","name":"New User Keys","project":"Superalgos","keys":[{"type":"Exchange Account Key","name":"New Exchange Account Key","config":"{ \n\"codeName\": \"Paste your exchange API name or label\",\n\"secret\": \"Paste your exchange API secret key\"\n}","project":"Superalgos","id":"3d34eb9d-e7cb-42fe-8785-c327b2bbc529","savedPayload":{"position":{"x":17839.64382962515,"y":30875.23747069523},"targetPosition":{"x":17930.64382962515,"y":30877.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{}}}],"id":"773de01f-0999-4a59-91f0-642148cd58d0","savedPayload":{"position":{"x":17930.64382962515,"y":30877.23747069523},"targetPosition":{"x":17924.64382962515,"y":30871.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"id":"fe33a596-4f98-4843-a5b1-26e7e0fcf1c8","savedPayload":{"position":{"x":17924.64382962515,"y":30871.23747069523},"targetPosition":{"x":18018.64382962515,"y":30832.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}}],"id":"d078b9a3-cdc6-458e-a511-dc4f5bef38ba","savedPayload":{"position":{"x":18018.64382962515,"y":30832.23747069523},"targetPosition":{"x":17949.64382962515,"y":30914.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":1,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"id":"27d69fa7-b561-4986-8c0d-1b374e7e1bf1","savedPayload":{"position":{"x":18347.867462142363,"y":30306.423852243533},"targetPosition":{"x":18473.301618063546,"y":31499.850126685462},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":true,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}},{"type":"Crypto Exchange","name":"TOP.Q","config":"{ \n\"codeName\": \"topq\"\n}","project":"Superalgos","exchangeAssets":{"type":"Exchange Assets","name":"New Exchange Assets","config":"{ \n\"addMissingAssetsFilter\": { \"quotedAsset\": \"USDT\"} \n}","project":"Superalgos","assets":[],"id":"eafef6a3-eed2-470e-a15c-aa4c10001cd2","savedPayload":{"position":{"x":17818.64382962515,"y":31115.23747069523},"targetPosition":{"x":17847.64382962515,"y":31105.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":2,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"exchangeMarkets":{"type":"Exchange Markets","name":"New Exchange Markets","project":"Superalgos","markets":[],"id":"2d5eb813-ceb6-40cd-8682-7205596bb8b5","savedPayload":{"position":{"x":17759.64382962515,"y":31188.23747069523},"targetPosition":{"x":17847.64382962515,"y":31105.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"exchangeAccounts":{"type":"Exchange Accounts","name":"New Exchange Accounts","project":"Superalgos","userAccounts":[{"type":"User Account","name":"New User Account","project":"Superalgos","userAssets":{"type":"User Assets","name":"New User Assets","project":"Superalgos","assets":[],"id":"61f7832c-c1f0-40bc-b1f2-ba947c58309d","savedPayload":{"position":{"x":17741.64382962515,"y":31288.23747069523},"targetPosition":{"x":17788.64382962515,"y":31228.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"userKeys":{"type":"User Keys","name":"New User Keys","project":"Superalgos","keys":[{"type":"Exchange Account Key","name":"New Exchange Account Key","config":"{ \n\"codeName\": \"Paste your exchange API name or label\",\n\"secret\": \"Paste your exchange API secret key\"\n}","project":"Superalgos","id":"63b973da-30a7-467a-b954-c57537aab18d","savedPayload":{"position":{"x":17677.64382962515,"y":31206.23747069523},"targetPosition":{"x":17756.64382962515,"y":31146.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{}}}],"id":"722dcf44-de3f-4d1a-8655-80561e1e4d55","savedPayload":{"position":{"x":17756.64382962515,"y":31146.23747069523},"targetPosition":{"x":17788.64382962515,"y":31228.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"id":"45d5e04a-4a53-4f32-b4c0-d882456cb263","savedPayload":{"position":{"x":17788.64382962515,"y":31228.23747069523},"targetPosition":{"x":17806.64382962515,"y":31163.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}}],"id":"c66e8dfc-4847-4180-b82c-36458f9b405d","savedPayload":{"position":{"x":17806.64382962515,"y":31163.23747069523},"targetPosition":{"x":17847.64382962515,"y":31105.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":1,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"id":"8fdf13d8-e8d2-4ef4-8b34-f492a25d753a","savedPayload":{"position":{"x":18498.432521923576,"y":30300.113306515646},"targetPosition":{"x":18473.301618063546,"y":31499.850126685462},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":true,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}},{"type":"Crypto Exchange","name":"Upbit","config":"{ \n\"codeName\": \"upbit\"\n}","project":"Superalgos","exchangeAssets":{"type":"Exchange Assets","name":"New Exchange Assets","config":"{ \n\"addMissingAssetsFilter\": { \"quotedAsset\": \"USDT\"} \n}","project":"Superalgos","assets":[],"id":"f456fec2-cee6-4f0c-b865-1188088879c9","savedPayload":{"position":{"x":17919.64382962515,"y":30973.23747069523},"targetPosition":{"x":17991.64382962515,"y":30980.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":2,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"exchangeMarkets":{"type":"Exchange Markets","name":"New Exchange Markets","project":"Superalgos","markets":[],"id":"947c1ca0-bff9-4372-b153-40054e29b705","savedPayload":{"position":{"x":17921.64382962515,"y":31014.23747069523},"targetPosition":{"x":17991.64382962515,"y":30980.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"exchangeAccounts":{"type":"Exchange Accounts","name":"New Exchange Accounts","project":"Superalgos","userAccounts":[{"type":"User Account","name":"New User Account","project":"Superalgos","userAssets":{"type":"User Assets","name":"New User Assets","project":"Superalgos","assets":[],"id":"34ffbe12-5a26-446a-8bf6-7395c0370ba2","savedPayload":{"position":{"x":17874.64382962515,"y":30900.23747069523},"targetPosition":{"x":17945.64382962515,"y":30971.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"userKeys":{"type":"User Keys","name":"New User Keys","project":"Superalgos","keys":[{"type":"Exchange Account Key","name":"New Exchange Account Key","config":"{ \n\"codeName\": \"Paste your exchange API name or label\",\n\"secret\": \"Paste your exchange API secret key\"\n}","project":"Superalgos","id":"8f00f19d-74a8-48d8-b951-79f35e87b110","savedPayload":{"position":{"x":17906.64382962515,"y":30902.23747069523},"targetPosition":{"x":17896.64382962515,"y":30896.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{}}}],"id":"64e1bede-aabf-4831-83a6-fe1cea435613","savedPayload":{"position":{"x":17896.64382962515,"y":30896.23747069523},"targetPosition":{"x":17945.64382962515,"y":30971.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"id":"7c80b956-f2ca-4a6f-a661-f17546288d3e","savedPayload":{"position":{"x":17945.64382962515,"y":30971.23747069523},"targetPosition":{"x":18027.64382962515,"y":31048.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}}],"id":"e3686b02-4ecc-4dcb-a311-b7ef542a3c37","savedPayload":{"position":{"x":18027.64382962515,"y":31048.23747069523},"targetPosition":{"x":17991.64382962515,"y":30980.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":1,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"id":"74e57ecd-3394-42b4-b2c4-6f216f7e41db","savedPayload":{"position":{"x":18648.60125233844,"y":30312.723327129876},"targetPosition":{"x":18473.301618063546,"y":31499.850126685462},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":true,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}},{"type":"Crypto Exchange","name":"WhiteBit","config":"{ \n\"codeName\": \"whitebit\"\n}","project":"Superalgos","exchangeAssets":{"type":"Exchange Assets","name":"New Exchange Assets","config":"{ \n\"addMissingAssetsFilter\": { \"quotedAsset\": \"USDT\"} \n}","project":"Superalgos","assets":[],"id":"c16eae45-a568-4b2e-b064-4431bdf34c24","savedPayload":{"position":{"x":17767.64382962515,"y":30899.23747069523},"targetPosition":{"x":17834.64382962515,"y":30950.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":2,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"exchangeMarkets":{"type":"Exchange Markets","name":"New Exchange Markets","project":"Superalgos","markets":[],"id":"dfdf793f-4ba6-4215-a325-323c0f223553","savedPayload":{"position":{"x":17920.64382962515,"y":31004.23747069523},"targetPosition":{"x":17834.64382962515,"y":30950.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"exchangeAccounts":{"type":"Exchange Accounts","name":"New Exchange Accounts","project":"Superalgos","userAccounts":[{"type":"User Account","name":"New User Account","project":"Superalgos","userAssets":{"type":"User Assets","name":"New User Assets","project":"Superalgos","assets":[],"id":"fd749d13-dbac-493f-9af6-c521eddf909f","savedPayload":{"position":{"x":17815.64382962515,"y":30973.23747069523},"targetPosition":{"x":17720.64382962515,"y":31056.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"userKeys":{"type":"User Keys","name":"New User Keys","project":"Superalgos","keys":[{"type":"Exchange Account Key","name":"New Exchange Account Key","config":"{ \n\"codeName\": \"Paste your exchange API name or label\",\n\"secret\": \"Paste your exchange API secret key\"\n}","project":"Superalgos","id":"79f7d2d0-77a5-4f38-ac68-fd11f18e5e6b","savedPayload":{"position":{"x":17761.64382962515,"y":31182.23747069523},"targetPosition":{"x":17680.64382962515,"y":31153.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{}}}],"id":"fd0506f4-58b7-431e-bc9d-69bce63c3379","savedPayload":{"position":{"x":17680.64382962515,"y":31153.23747069523},"targetPosition":{"x":17720.64382962515,"y":31056.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"id":"47e8a4b1-9a6c-4555-a881-f7524183d72e","savedPayload":{"position":{"x":17720.64382962515,"y":31056.23747069523},"targetPosition":{"x":17817.64382962515,"y":31010.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}}],"id":"7fa08b91-55ab-477d-a097-88ea7f25fb76","savedPayload":{"position":{"x":17817.64382962515,"y":31010.23747069523},"targetPosition":{"x":17834.64382962515,"y":30950.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":1,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"id":"467ece1e-d1d0-4a11-ae7a-d0e22cd4eba5","savedPayload":{"position":{"x":18796.005402801864,"y":30344.055046528272},"targetPosition":{"x":18473.301618063546,"y":31499.850126685462},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":true,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}},{"type":"Crypto Exchange","name":"ZB","config":"{ \n\"codeName\": \"zb\"\n}","project":"Superalgos","exchangeAssets":{"type":"Exchange Assets","name":"New Exchange Assets","config":"{ \n\"addMissingAssetsFilter\": { \"quotedAsset\": \"USDT\"} \n}","project":"Superalgos","assets":[],"id":"db206cbd-a587-4e8e-acbe-6581ad3b5cc4","savedPayload":{"position":{"x":17855.64382962515,"y":31027.23747069523},"targetPosition":{"x":17861.64382962515,"y":30951.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":2,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"exchangeMarkets":{"type":"Exchange Markets","name":"New Exchange Markets","project":"Superalgos","markets":[],"id":"1dd658c5-7755-44b7-85f0-9bcd787762a0","savedPayload":{"position":{"x":17789.64382962515,"y":31044.23747069523},"targetPosition":{"x":17861.64382962515,"y":30951.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"exchangeAccounts":{"type":"Exchange Accounts","name":"New Exchange Accounts","project":"Superalgos","userAccounts":[{"type":"User Account","name":"New User Account","project":"Superalgos","userAssets":{"type":"User Assets","name":"New User Assets","project":"Superalgos","assets":[],"id":"0de82bbe-7909-4b65-b304-f59b41f618ae","savedPayload":{"position":{"x":17830.64382962515,"y":30696.23747069523},"targetPosition":{"x":17846.64382962515,"y":30793.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"userKeys":{"type":"User Keys","name":"New User Keys","project":"Superalgos","keys":[{"type":"Exchange Account Key","name":"New Exchange Account Key","config":"{ \n\"codeName\": \"Paste your exchange API name or label\",\n\"secret\": \"Paste your exchange API secret key\"\n}","project":"Superalgos","id":"c89819d0-8880-4b36-a9b3-0b284d266e3b","savedPayload":{"position":{"x":17891.64382962515,"y":30748.23747069523},"targetPosition":{"x":17865.64382962515,"y":30772.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{}}}],"id":"7a55f503-17fa-45c4-880b-1a9a11a0a555","savedPayload":{"position":{"x":17865.64382962515,"y":30772.23747069523},"targetPosition":{"x":17846.64382962515,"y":30793.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"id":"e640fca2-8bab-45ff-9a47-8e7b9650c277","savedPayload":{"position":{"x":17846.64382962515,"y":30793.23747069523},"targetPosition":{"x":17909.64382962515,"y":30886.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}}],"id":"421a99cd-3d9a-46a5-8654-08d6336e75be","savedPayload":{"position":{"x":17909.64382962515,"y":30886.23747069523},"targetPosition":{"x":17861.64382962515,"y":30951.23747069523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":1,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"id":"07df07e8-39a8-4fbc-a0c8-150f20b6ac59","savedPayload":{"position":{"x":18938.32032180607,"y":30393.61434477926},"targetPosition":{"x":18473.301618063546,"y":31499.850126685462},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":true,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}}],"id":"51f64e29-e3ab-4683-a5de-f397fbf94260","savedPayload":{"position":{"x":18473.301618063546,"y":31499.850126685462},"targetPosition":{"x":18773.301618063546,"y":30980.2348844148},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":true,"angleToParent":1,"distanceToParent":5,"arrangementStyle":0},"uiObject":{"isRunning":false}}},{"type":"Crypto Exchanges","name":"Testing Queue","project":"Superalgos","exchanges":[],"id":"895ce4b1-4890-4216-89ba-a012181d2546","savedPayload":{"position":{"x":18623.301618063546,"y":30720.427263279467},"targetPosition":{"x":18773.301618063546,"y":30980.2348844148},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false}}}],"signalsProviders":[],"id":"7217b56c-e854-4c06-8b8a-d5d3c05a153d","savedPayload":{"position":{"x":18773.301618063546,"y":30980.2348844148},"targetPosition":{"x":18773.301618063546,"y":30980.2348844148},"floatingObject":{"isPinned":true,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false,"shortcutKey":""}}},{"type":"Charting Space","name":"New Charting Space","project":"Superalgos","viewport":{"type":"Viewport","name":"New Viewport","config":"{\"zoom\":\"5.00\"}","project":"Superalgos","id":"01713f1d-91b8-44f9-9c5d-a0c12fd09037","savedPayload":{"position":{"x":19200.806237131383,"y":24983.35640053908},"targetPosition":{"x":18900.806237131383,"y":24983.35640053908},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":3,"arrangementStyle":0},"uiObject":{},"frame":{"position":{"x":-2189.197939162836,"y":-6992.422473301482}}}},"projectDashboards":[],"id":"21d2ec55-9e56-4652-8e96-c7e451262c36","savedPayload":{"position":{"x":18900.806237131383,"y":24983.35640053908},"targetPosition":{"x":18900.806237131383,"y":24983.35640053908},"floatingObject":{"isPinned":true,"isFrozen":false,"isCollapsed":true,"angleToParent":1,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false,"shortcutKey":"c"}}},{"type":"Plugins","name":"New Plugins","project":"Superalgos","pluginProjects":[{"type":"Plugin Project","name":"Superalgos","config":"{ \n \"codeName\": \"Superalgos\"\n}","project":"Superalgos","pluginDataMines":{"type":"Plugin Data Mines","name":"New Plugin Data Mines","project":"Superalgos","pluginFiles":[{"type":"Plugin File","name":"Masters","project":"Superalgos","pluginFilePosition":{"type":"Plugin File Position","name":"Masters","project":"Superalgos","id":"d5234bd2-ef4e-4856-a6a0-ce7659653a48","savedPayload":{"position":{"x":18879.35218735615,"y":18688.55301821844},"targetPosition":{"x":31820.67692045767,"y":18678.794324352373},"floatingObject":{"isPinned":true,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"id":"ecc1a524-de9b-4e73-8874-b99a7ea0402b","savedPayload":{"position":{"x":31820.67692045767,"y":18678.794324352373},"targetPosition":{"x":31320.502678827743,"y":18678.79704693609},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false}}}],"id":"cbc3d9be-5e59-45d8-bb0f-4ec82763691d","savedPayload":{"position":{"x":31253.673182942548,"y":18372.4854210064},"targetPosition":{"x":31346.37828125503,"y":18657.802375894946},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":true,"angleToParent":1,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"pluginTradingMines":{"type":"Plugin Trading Mines","name":"New Plugin Trading Mines","project":"Superalgos","pluginFiles":[{"type":"Plugin File","name":"Masters","project":"Superalgos","pluginFilePosition":{"type":"Plugin File Position","name":"Masters","project":"Superalgos","id":"ad1ce785-858f-4cfc-ba68-108b5e0c54d9","savedPayload":{"position":{"x":24941.217404066585,"y":18714.893045797242},"targetPosition":{"x":31320.45102232534,"y":19544.930491916948},"floatingObject":{"isPinned":true,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"id":"8a64c00e-4f8c-49bf-b57d-4e2e388bae41","savedPayload":{"position":{"x":31320.45102232534,"y":19544.930491916948},"targetPosition":{"x":31070.415084976332,"y":19111.835158656926},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false}}}],"id":"8d881813-3ab9-4e8b-ab5a-48dedab2dd19","savedPayload":{"position":{"x":31589.083379567513,"y":18481.466800207203},"targetPosition":{"x":31346.37828125503,"y":18657.802375894946},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":true,"angleToParent":1,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"pluginTradingSystems":{"type":"Plugin Trading Systems","name":"New Plugin Trading Systems","project":"Superalgos","pluginFiles":[],"id":"3569d452-c593-4e54-a356-7ff8c6b519f3","savedPayload":{"position":{"x":31589.083379567513,"y":18834.13795158269},"targetPosition":{"x":31346.37828125503,"y":18657.802375894946},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"pluginTradingEngines":{"type":"Plugin Trading Engines","name":"New Plugin Trading Engines","project":"Superalgos","pluginFiles":[{"type":"Plugin File","name":"Low-Frequency","project":"Superalgos","pluginFilePosition":{"type":"Plugin File Position","name":"Low-Frequency","project":"Superalgos","id":"e117a2a4-09b3-4181-8455-e680de3bdeb3","savedPayload":{"position":{"x":30923.55093774257,"y":24967.049392142086},"targetPosition":{"x":29820.22642897682,"y":18678.80776835817},"floatingObject":{"isPinned":true,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"id":"e9270d67-4630-4ac9-91ca-1dec4fb5aa38","savedPayload":{"position":{"x":29820.22642897682,"y":18678.80776835817},"targetPosition":{"x":30320.32799443869,"y":18678.805890109317},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false}}}],"id":"87a28762-63d0-45f7-bd39-9dea436d8244","savedPayload":{"position":{"x":31253.673182942548,"y":18943.11933078349},"targetPosition":{"x":31346.37828125503,"y":18657.802375894946},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":true,"angleToParent":1,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"id":"c4e402d7-5228-408c-9d67-379d6ef40bae","savedPayload":{"position":{"x":31346.37828125503,"y":18657.802375894946},"targetPosition":{"x":31046.37828125503,"y":18657.802375894946},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false}}}],"id":"bfb0b514-3b9f-4e9a-85ca-d0ca714b09f6","savedPayload":{"position":{"x":31046.37828125503,"y":18657.802375894946},"targetPosition":{"x":31046.37828125503,"y":18657.802375894946},"floatingObject":{"isPinned":true,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false}}},{"type":"Design Space","name":"My Design Space","project":"Superalgos","spaceStyle":{"type":"Space Style","name":"My Space Style","config":" {\n \"backgroundColor\": \"UI_COLOR.BLACK\",\n \"node\": {\n \"fontSize\": 16,\n \"imageSize\": 60,\n \"type\": {\n \"fontColor\": \"UI_COLOR.WHITE\"\n },\n \"name\": {\n \"fontColor\": \"UI_COLOR.WHITE\"\n },\n \"menuItem\": {\n \"backgroundColor\": \"UI_COLOR.BLACK\",\n \"fontColor\": \"UI_COLOR.WHITE\",\n \"fontSize\": 14,\n \"imageSize\": 14\n }\n }\n }","project":"Superalgos","id":"fad0e429-f7a7-4b62-a2a5-2ead29b8f695","savedPayload":{"position":{"x":25236.875,"y":8701.347826086958},"targetPosition":{"x":24936.875,"y":8701.347826086958},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":3,"arrangementStyle":0},"uiObject":{}}},"spaceSettings":{"type":"Space Settings","name":"New Space Settings","config":"{\n \"node\": {\n \"distancePercentage\": 60,\n \"radiusPercentage\": 85,\n \"massPercentage\": 100,\n \"animationSteps\": 2, \n \"menuItem\": {\n \"widthPercentage\": 100,\n \"heightPercentage\": 60,\n \"radiusPercentage\": 90\n }\n },\n \"physics\": false\n}","project":"Superalgos","id":"05c9d6d5-24c4-4eec-9aca-9668d6486fdd","savedPayload":{"position":{"x":24636.875,"y":8701.347826086958},"targetPosition":{"x":24936.875,"y":8701.347826086958},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":3,"arrangementStyle":0},"uiObject":{}}},"id":"f8485ce5-67f3-4476-b9e2-80994e49c318","savedPayload":{"position":{"x":24940.875,"y":10717.347826086958},"targetPosition":{"x":24940.875,"y":10717.347826086958},"floatingObject":{"isPinned":true,"isFrozen":false,"isCollapsed":true,"angleToParent":1,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false},"frame":{"position":{"x":255,"y":588.3125}}}},{"type":"Superalgos Project","name":"New Superalgos Project","project":"Superalgos","projectDefinition":{"type":"Project Definition","name":"Superalgos","config":"{ \n \"codeName\": \"Superalgos\"\n}","project":"Superalgos","id":"a2a04e12-604e-43f8-a986-1b8ca3b043cb","savedPayload":{"position":{"x":19203,"y":10733.5},"targetPosition":{"x":18903,"y":10733.5},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":3,"arrangementStyle":0},"uiObject":{}}},"spaces":{"type":"Spaces","name":"New Spaces","project":"Superalgos","id":"4d0ee814-4e48-4688-9cc5-7ee03de5192b","savedPayload":{"position":{"x":19053,"y":10993.307621135331},"targetPosition":{"x":18903,"y":10733.5},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":3,"arrangementStyle":0},"uiObject":{}}},"mines":{"type":"Mines","name":"New Mines","project":"Superalgos","id":"b979e3a3-9316-4e5a-831b-c503b4b0e507","savedPayload":{"position":{"x":18753,"y":10993.307621135331},"targetPosition":{"x":18903,"y":10733.5},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":3,"arrangementStyle":0},"uiObject":{}}},"trading":{"type":"Trading","name":"New Trading","project":"Superalgos","id":"7c24591e-b252-4be3-8952-e4da0a52f467","savedPayload":{"position":{"x":18603,"y":10733.5},"targetPosition":{"x":18903,"y":10733.5},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":3,"arrangementStyle":0},"uiObject":{}}},"learning":{"type":"Learning","name":"New Learning","project":"Superalgos","id":"7a0b6167-5554-497a-b150-8886120539c2","savedPayload":{"position":{"x":18753,"y":10473.692378864669},"targetPosition":{"x":18903,"y":10733.5},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":3,"arrangementStyle":0},"uiObject":{}}},"otherHierarchies":{"type":"Other Hierarchies","name":"New Other Hierarchies","project":"Superalgos","id":"0a1ff755-8e0b-4f62-976e-df76c8139c6f","savedPayload":{"position":{"x":19053,"y":10473.692378864669},"targetPosition":{"x":18903,"y":10733.5},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":3,"arrangementStyle":0},"uiObject":{}}},"id":"cf9f8b3b-77c6-43c6-b01f-95cf366a91f6","savedPayload":{"position":{"x":18903,"y":10733.5},"targetPosition":{"x":18903,"y":10733.5},"floatingObject":{"isPinned":true,"isFrozen":false,"isCollapsed":true,"angleToParent":1,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false}}},{"type":"Tutorial","name":"Install a New Market","config":"{\"position\":\"\",\"slider\":\"toTop\",\"documentationURL\":\"\",\"docs\":{\"project\":\"Superalgos\",\"category\":\"Tutorial\",\"type\":\"Tutorial - Install a New Market\"},\"icon\":{\"name\":\"market\",\"project\":\"Superalgos\"}}","project":"Superalgos","tutorialSteps":[],"tutorialTopics":[{"type":"Tutorial Topic","name":"Add the Assets","config":"{\"position\":\"Left\",\"slider\":\"toTop\",\"positionAtReferenceParent\":true,\"documentationURL\":\"\",\"docs\":{\"project\":\"Superalgos\",\"category\":\"Tutorial\",\"type\":\"Tutorial Topic - Add the Assets\"},\"icon\":{\"name\":\"asset\",\"project\":\"Superalgos\"}}","project":"Superalgos","tutorialSteps":[{"type":"Tutorial Step","name":"New Tutorial Step","config":"{\n \"image\": \"exchange-assets\",\n \"position\": \"Left\",\n \"slider\": \"toTop\",\n \"documentationURL\": \"\",\n \"docs\": {\n \"project\": \"Superalgos\",\n \"category\": \"Tutorial\",\n \"type\": \"Tutorial Step - Add the Assets 1\"\n }\n}","project":"Superalgos","id":"1b3b8d0e-3aa9-4aba-8b74-351647a3b5b5","savedPayload":{"position":{"x":31555.632034355964,"y":40268.44846100007},"targetPosition":{"x":31343.5,"y":40480.58049535604},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false},"tutorial":{"status":"Reset"}}},{"type":"Tutorial Step","name":"New Tutorial Step","config":"{\n \"image\": \"asset\",\n \"externalLink\": [\n \"\",\n \"\"\n ],\n \"position\": \"Left\",\n \"slider\": \"toTop\",\n \"documentationURL\": \"\",\n \"docs\": {\n \"project\": \"Superalgos\",\n \"category\": \"Tutorial\",\n \"type\": \"Tutorial Step - Add the Assets 2\"\n }\n}","project":"Superalgos","id":"05f7092a-2326-40e7-b618-f3be5523e670","savedPayload":{"position":{"x":31643.5,"y":40480.58049535604},"targetPosition":{"x":31343.5,"y":40480.58049535604},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false},"tutorial":{"status":"Reset"}}},{"type":"Tutorial Step","name":"New Tutorial Step","config":"{\n \"image\": \"asset\",\n \"externalLink\": [\n \"\",\n \"\"\n ],\n \"position\": \"Left\",\n \"slider\": \"toTop\",\n \"documentationURL\": \"\",\n \"docs\": {\n \"project\": \"Superalgos\",\n \"category\": \"Tutorial\",\n \"type\": \"Tutorial Step - Add the Assets 3\"\n }\n}","project":"Superalgos","id":"281274f1-a4ec-47a2-b97c-0c29aa71eed9","savedPayload":{"position":{"x":31555.632034355964,"y":40692.712529712},"targetPosition":{"x":31343.5,"y":40480.58049535604},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false},"tutorial":{"status":"Reset"}}}],"tutorialTopics":[],"id":"cd6f2f74-407e-46c9-b7de-95d9ab2cc82d","savedPayload":{"position":{"x":25258.5,"y":37561.33049535604},"targetPosition":{"x":24958.5,"y":37561.33049535604},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":true,"angleToParent":1,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false},"tutorial":{"status":"Reset"},"referenceParent":{"type":"Exchange Assets","name":"New Exchange Assets","id":"95d2c30f-215b-486e-8119-f4eac0279575"}}},{"type":"Tutorial Topic","name":"Set up the Market","config":"{\n \"image\": \"market\",\n \"position\": \"Left\",\n \"slider\": \"toTop\",\n \"positionAtReferenceParent\": true,\n \"documentationURL\": \"\",\n \"docs\": {\n \"project\": \"Superalgos\",\n \"category\": \"Tutorial\",\n \"type\": \"Tutorial Topic - Set Up the Market\"\n }\n}","project":"Superalgos","tutorialSteps":[{"type":"Tutorial Step","name":"New Tutorial Step","config":"{\n \"image\": \"market\",\n \"position\": \"Left\",\n \"slider\": \"toTop\",\n \"documentationURL\": \"\",\n \"docs\": {\n \"project\": \"Superalgos\",\n \"category\": \"Tutorial\",\n \"type\": \"Tutorial Step - Set Up the Market 1\"\n },\n \"controlDocs\": {\n \"panel\": \"Close\"\n }\n}","project":"Superalgos","id":"cae5ddd4-0c48-488d-86f7-38192c7fdbca","savedPayload":{"position":{"x":31483.85656861048,"y":40749.74665547167},"targetPosition":{"x":31185.5,"y":40718.38811649137},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false},"tutorial":{"status":"Reset"}}},{"type":"Tutorial Step","name":"New Tutorial Step","config":"{\n \"image\": \"asset\",\n \"position\": \"Left\",\n \"slider\": \"toTop\",\n \"docs\": {\n \"project\": \"Superalgos\",\n \"category\": \"Tutorial\",\n \"type\": \"Tutorial Step - Set Up the Market 2\"\n },\n \"controlDocs\": {\n \"panel\": \"Open\",\n \"page\": {\n \"project\": \"Superalgos\",\n \"category\": \"Topic\",\n \"type\": \"References\",\n \"anchor\": \"How to Estabish and Remove References\"\n }\n }\n}","project":"Superalgos","id":"a7a049cb-72e0-4d76-9247-ee0d873e79c8","savedPayload":{"position":{"x":31408.443447643218,"y":40919.12729839903},"targetPosition":{"x":31185.5,"y":40718.38811649137},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false},"tutorial":{"status":"Reset"}}},{"type":"Tutorial Step","name":"New Tutorial Step","config":"{\n \"image\": \"asset\",\n \"position\": \"Left\",\n \"slider\": \"toTop\",\n \"documentationURL\": \"\",\n \"docs\": {\n \"project\": \"Superalgos\",\n \"category\": \"Tutorial\",\n \"type\": \"Tutorial Step - Set Up the Market 3\"\n },\n \"controlDocs\": {\n \"panel\": \"Close\"\n }\n}","project":"Superalgos","id":"9710d88d-c4ae-406b-9079-31bcf7395817","savedPayload":{"position":{"x":31247.873507245327,"y":41011.832396711514},"targetPosition":{"x":31185.5,"y":40718.38811649137},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false},"tutorial":{"status":"Reset"}}},{"type":"Tutorial Step","name":"New Tutorial Step","config":"{\n \"image\": \"market\",\n \"position\": \"Left\",\n \"slider\": \"toTop\",\n \"documentationURL\": \"\",\n \"docs\": {\n \"project\": \"Superalgos\",\n \"category\": \"Tutorial\",\n \"type\": \"Tutorial Step - Set Up the Market 4\"\n }\n}","project":"Superalgos","id":"2d2ce361-6261-44b4-b7ff-466035934334","savedPayload":{"position":{"x":31063.47900707726,"y":40992.45175378415},"targetPosition":{"x":31185.5,"y":40718.38811649137},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false},"tutorial":{"status":"Reset"}}}],"tutorialTopics":[],"id":"4de3cd7d-f552-4f39-b4cd-e29269b64668","savedPayload":{"position":{"x":25108.5,"y":37821.13811649137},"targetPosition":{"x":24958.5,"y":37561.33049535604},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":true,"angleToParent":1,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false},"tutorial":{"status":"Reset"},"referenceParent":{"type":"Exchange Markets","name":"New Exchange Markets","id":"2fd80894-900e-44ac-a1a7-56c14124f7a1"}}},{"type":"Tutorial Topic","name":"Install the Market","config":"{\n \"image\": \"market\",\n \"position\": \"Left\",\n \"slider\": \"toTop\",\n \"documentationURL\": \"\",\n \"docs\": {\n \"project\": \"Superalgos\",\n \"category\": \"Tutorial\",\n \"type\": \"Tutorial Topic - Install the Market\"\n }\n}","project":"Superalgos","tutorialSteps":[],"tutorialTopics":[],"id":"e003540b-91f4-41ce-8082-45122ddb55e7","savedPayload":{"position":{"x":24808.5,"y":37821.13811649137},"targetPosition":{"x":24958.5,"y":37561.33049535604},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false},"tutorial":{"status":"Reset"}}},{"type":"Tutorial Topic","name":"Network Verification","config":"{\n \"image\": \"network-node\",\n \"position\": \"Left\",\n \"slider\": \"toTop\",\n \"positionAtReferenceParent\": true,\n \"documentationURL\": \"\",\n \"docs\": {\n \"project\": \"Superalgos\",\n \"category\": \"Tutorial\",\n \"type\": \"Tutorial Topic - Network Verification\"\n }\n}","project":"Superalgos","tutorialSteps":[{"type":"Tutorial Step","name":"New Tutorial Step","config":"{\n \"image\": \"data-tasks\",\n \"externalLink\": [\n \"\",\n \"\"\n ],\n \"position\": \"Left\",\n \"slider\": \"toTop\",\n \"positionAtReferenceParent\": true,\n \"documentationURL\": \"\",\n \"docs\": {\n \"project\": \"Superalgos\",\n \"category\": \"Tutorial\",\n \"type\": \"Tutorial Step - Network Verification 1\"\n }\n}","project":"Superalgos","id":"4bca0860-329c-4fde-a11e-d404d0f23431","savedPayload":{"position":{"x":30567.164424312257,"y":40723.28559366852},"targetPosition":{"x":30743.5,"y":40480.58049535604},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false},"tutorial":{"status":"Reset"},"referenceParent":{"type":"Data Tasks","name":"New Data Tasks","id":"40af91d9-431c-4b7d-addc-aed37bc2f3fe"}}},{"type":"Tutorial Step","name":"New Tutorial Step","config":"{\n \"image\": \"testing-trading-tasks\",\n \"externalLink\": [\n \"\",\n \"\"\n ],\n \"position\": \"Left\",\n \"slider\": \"toTop\",\n \"positionAtReferenceParent\": true,\n \"documentationURL\": \"\",\n \"docs\": {\n \"project\": \"Superalgos\",\n \"category\": \"Tutorial\",\n \"type\": \"Tutorial Step - Network Verification 2\"\n }\n}","project":"Superalgos","id":"495e3d4c-87a8-4147-ad2a-06920da9d7a6","savedPayload":{"position":{"x":30458.183045111455,"y":40573.28559366852},"targetPosition":{"x":30743.5,"y":40480.58049535604},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false},"tutorial":{"status":"Reset"},"referenceParent":{"type":"Testing Trading Tasks","name":"New Testing Trading Tasks","id":"8117db0a-e418-4f56-8fe4-fda2ddac1cbb"}}},{"type":"Tutorial Step","name":"New Tutorial Step","config":"{\n \"image\": \"production-trading-tasks\",\n \"position\": \"Left\",\n \"slider\": \"toTop\",\n \"positionAtReferenceParent\": true,\n \"documentationURL\": \"\",\n \"docs\": {\n \"project\": \"Superalgos\",\n \"category\": \"Tutorial\",\n \"type\": \"Tutorial Step - Network Verification 3\"\n }\n}","project":"Superalgos","id":"43b85e55-3417-4b13-a7b6-7c5bc0fb691d","savedPayload":{"position":{"x":30458.183045111455,"y":40387.87539704355},"targetPosition":{"x":30743.5,"y":40480.58049535604},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false},"tutorial":{"status":"Reset"},"referenceParent":{"type":"Production Trading Tasks","name":"New Production Trading Tasks","id":"673caa5f-511d-4688-9305-e5f0f0f780cd"}}},{"type":"Tutorial Step","name":"New Tutorial Step","config":"{\n \"image\": \"data-storage\",\n \"position\": \"Left\",\n \"slider\": \"toTop\",\n \"positionAtReferenceParent\": true,\n \"documentationURL\": \"\",\n \"docs\": {\n \"project\": \"Superalgos\",\n \"category\": \"Tutorial\",\n \"type\": \"Tutorial Step - Network Verification 4\"\n }\n}","project":"Superalgos","id":"f37edf40-24ba-42d0-9458-bf008c123659","savedPayload":{"position":{"x":30567.164424312257,"y":40237.87539704355},"targetPosition":{"x":30743.5,"y":40480.58049535604},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false},"tutorial":{"status":"Reset"},"referenceParent":{"type":"Data Storage","name":"New Data Storage","id":"e2697759-6038-4943-b90c-5a68651ff9a8"}}}],"tutorialTopics":[],"id":"89c6f1e3-d4c8-48c0-aec1-9dda6e0b9797","savedPayload":{"position":{"x":24658.5,"y":37561.33049535604},"targetPosition":{"x":24958.5,"y":37561.33049535604},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":true,"angleToParent":1,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false},"tutorial":{"status":"Reset"},"referenceParent":{"type":"Network Node","name":"My Computer","id":"e452cf65-2b2b-44f2-9e67-bdd9d3c008e4"}}},{"type":"Tutorial Topic","name":"Charts Verification","config":"{\n \"image\": \"charting-space\",\n \"position\": \"Right\",\n \"slider\": \"toTop\",\n \"positionAtReferenceParent\": true,\n \"documentationURL\": \"\",\n \"docs\": {\n \"project\": \"Superalgos\",\n \"category\": \"Tutorial\",\n \"type\": \"Tutorial Topic - Charts Verification\"\n }\n}","project":"Superalgos","tutorialSteps":[{"type":"Tutorial Step","name":"New Tutorial Step","config":"{\n \"image\": \"charting-space\",\n \"externalLink\": [\n \"\",\n \"\"\n ],\n \"position\": \"Right\",\n \"slider\": \"toTop\",\n \"documentationURL\": \"\",\n \"docs\": {\n \"project\": \"Superalgos\",\n \"category\": \"Tutorial\",\n \"type\": \"Tutorial Step - Charts Verification 1\"\n }\n}","project":"Superalgos","id":"17eb1e8e-e9f4-4fe4-a8ea-2c0ea0804d87","savedPayload":{"position":{"x":30633.692378864667,"y":40070.772874220704},"targetPosition":{"x":30893.5,"y":40220.772874220704},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false},"tutorial":{"status":"Reset"}}},{"type":"Tutorial Step","name":"New Tutorial Step","config":"{\n \"image\": \"time-machine\",\n \"position\": \"Left\",\n \"slider\": \"toBottom\",\n \"documentationURL\": \"\",\n \"docs\": {\n \"project\": \"Superalgos\",\n \"category\": \"Tutorial\",\n \"type\": \"Tutorial Step - Charts Verification 2\"\n }\n}","project":"Superalgos","id":"a94fa42a-87c8-4874-ba45-ffa0ffd02f36","savedPayload":{"position":{"x":30893.5,"y":39920.772874220704},"targetPosition":{"x":30893.5,"y":40220.772874220704},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false},"tutorial":{"status":"Reset"}}}],"tutorialTopics":[],"id":"064a5be1-bb06-468b-8fad-d78d2c844ee1","savedPayload":{"position":{"x":24808.5,"y":37301.522874220704},"targetPosition":{"x":24958.5,"y":37561.33049535604},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":true,"angleToParent":1,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false},"tutorial":{"status":"Reset"},"referenceParent":{"type":"Charting Space","name":"New Charting Space","id":"21d2ec55-9e56-4652-8e96-c7e451262c36"}}},{"type":"Tutorial Topic","name":"The End","config":"{\n \"image\": \"tutorial\",\n \"position\": \"Left\",\n \"slider\": \"toTop\",\n \"documentationURL\": \"\",\n \"docs\": {\n \"project\": \"Superalgos\",\n \"category\": \"Tutorial\",\n \"type\": \"Tutorial Topic - You Made It!\"\n }\n}","project":"Superalgos","tutorialSteps":[],"tutorialTopics":[],"id":"9b5e9927-860c-4b89-ac5d-d7f6fd86b18d","savedPayload":{"position":{"x":25108.5,"y":37301.522874220704},"targetPosition":{"x":24958.5,"y":37561.33049535604},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":true,"angleToParent":1,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false},"tutorial":{"status":"Reset"}}}],"id":"d86ff84f-15d3-4a2d-9674-114c5b526de5","savedPayload":{"position":{"x":24969.5,"y":37571.33049535604},"targetPosition":{"x":24969.5,"y":37571.33049535604},"floatingObject":{"isPinned":true,"isFrozen":false,"isCollapsed":true,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isPlaying":true,"isRunning":false},"tutorial":{"status":"Done"}}},{"type":"APIs","name":"New APIs","project":"Superalgos","githubAPI":{"type":"Github API","name":"New Github API","config":"{\n \"username\": \"\",\n \"token\": \"\"\n}","project":"Superalgos","id":"9ea7bee2-c4db-4cee-a05f-63fcf3a86a4a","savedPayload":{"position":{"x":31349.208333333332,"y":10755.819458631257},"targetPosition":{"x":31049.208333333332,"y":10755.819458631257},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":3,"arrangementStyle":0},"uiObject":{}}},"id":"23021bb7-9997-4fe6-8199-71ebf70aef76","savedPayload":{"position":{"x":31049.208333333332,"y":10755.819458631257},"targetPosition":{"x":31049.208333333332,"y":10755.819458631257},"floatingObject":{"isPinned":true,"isFrozen":false,"isCollapsed":true,"angleToParent":1,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false}}},{"type":"Trading System","name":"New Trading System","project":"Superalgos","tradingStrategies":[{"type":"Trading Strategy","name":"New Trading Strategy","project":"Superalgos","triggerStage":{"type":"Trigger Stage","name":"New Trigger Stage","project":"Superalgos","triggerOn":{"type":"Trigger On Event","name":"New Trigger On Event","project":"Superalgos","situations":[{"type":"Situation","name":"New Situation","project":"Superalgos","conditions":[{"type":"Condition","name":"New Condition","project":"Superalgos","javascriptCode":{"type":"Javascript Code","name":"New Javascript Code","code":"// Type you code","project":"Superalgos","id":"64a86fa1-8ce7-4bca-a684-20f8d1126d70","savedPayload":{"position":{"x":30720.690987174497,"y":30424.038745267728},"targetPosition":{"x":30854.341965802752,"y":30492.13732022866},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":3,"arrangementStyle":0},"uiObject":{}}},"id":"e21a0776-acd7-4cb2-9f5f-2bcbfa6e89e0","savedPayload":{"position":{"x":30854.341965802752,"y":30492.13732022866},"targetPosition":{"x":30987.992944431007,"y":30560.23589518959},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false}}}],"id":"bb7fdf98-25b3-4282-81cc-0658dcf6d484","savedPayload":{"position":{"x":30987.992944431007,"y":30560.23589518959},"targetPosition":{"x":31121.643923059262,"y":30628.334470150523},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false}}}],"announcements":[],"id":"1f62cb3d-19fa-4717-a113-c0915e8ceaa0","savedPayload":{"position":{"x":31121.643923059262,"y":30628.334470150523},"targetPosition":{"x":31255.294901687517,"y":30696.433045111455},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":2,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"triggerOff":{"type":"Trigger Off Event","name":"New Trigger Off Event","project":"Superalgos","situations":[{"type":"Situation","name":"New Situation","project":"Superalgos","conditions":[{"type":"Condition","name":"New Condition","project":"Superalgos","javascriptCode":{"type":"Javascript Code","name":"New Javascript Code","code":"// Type you code","project":"Superalgos","id":"f11bf186-ccfd-4e60-8260-f52cdf898bb4","savedPayload":{"position":{"x":31069.884705062545,"y":30125.799135334357},"targetPosition":{"x":31116.237254218788,"y":30268.45761277863},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":3,"arrangementStyle":0},"uiObject":{}}},"id":"7051b998-d100-48b2-90a4-d5e3f361e334","savedPayload":{"position":{"x":31116.237254218788,"y":30268.45761277863},"targetPosition":{"x":31162.58980337503,"y":30411.116090222906},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false}}}],"id":"d76e94fb-d895-4634-90f9-667d0367e210","savedPayload":{"position":{"x":31162.58980337503,"y":30411.116090222906},"targetPosition":{"x":31208.942352531274,"y":30553.77456766718},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false}}}],"announcements":[],"id":"0d1dc41a-7185-43a8-814e-e6a5300e6a1d","savedPayload":{"position":{"x":31208.942352531274,"y":30553.77456766718},"targetPosition":{"x":31255.294901687517,"y":30696.433045111455},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":2,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"takePosition":{"type":"Take Position Event","name":"New Take Position Event","project":"Superalgos","situations":[{"type":"Situation","name":"New Situation","project":"Superalgos","conditions":[{"type":"Condition","name":"New Condition","project":"Superalgos","javascriptCode":{"type":"Javascript Code","name":"New Javascript Code","code":"// Type you code","project":"Superalgos","id":"c8cb9f04-5192-4b0c-b87b-d614ef07ec58","savedPayload":{"position":{"x":31527.689201531244,"y":30161.829130598435},"targetPosition":{"x":31459.590626570312,"y":30295.48010922669},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":3,"arrangementStyle":0},"uiObject":{}}},"id":"3094206b-682a-481a-9b36-5d86eb621ef5","savedPayload":{"position":{"x":31459.590626570312,"y":30295.48010922669},"targetPosition":{"x":31391.49205160938,"y":30429.131087854945},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false}}}],"id":"7a3d4c6a-147e-4b75-8914-4ca3972ab3d5","savedPayload":{"position":{"x":31391.49205160938,"y":30429.131087854945},"targetPosition":{"x":31323.39347664845,"y":30562.7820664832},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false}}}],"announcements":[],"id":"0e1d431a-e1be-439e-9f86-2771f5f3fde4","savedPayload":{"position":{"x":31323.39347664845,"y":30562.7820664832},"targetPosition":{"x":31255.294901687517,"y":30696.433045111455},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":2,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"announcements":[],"id":"f8551c2e-bbb4-4cba-ab56-d7873f725f07","savedPayload":{"position":{"x":31255.294901687517,"y":30696.433045111455},"targetPosition":{"x":31348,"y":30981.75},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":true,"angleToParent":1,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"openStage":{"type":"Open Stage","name":"New Open Stage","config":"{\n\"roundingErrorCorrectionFactor\": 1.01, \n\"absoluteDustInBaseAsset\": 0,\n\"absoluteDustInQuotedAsset\": 0 \n}","project":"Superalgos","initialTargets":{"type":"Initial Targets","name":"New Initial Targets","project":"Superalgos","targetRate":{"type":"Target Rate","name":"New Target Rate","project":"Superalgos","formula":{"type":"Formula","name":"New Formula","code":"// Type your formula","project":"Superalgos","id":"c2cc6b16-4d23-4fb5-ba60-a05c6758f6ea","savedPayload":{"position":{"x":31284.964286449067,"y":30023.69772550875},"targetPosition":{"x":31461.29986213681,"y":30266.402823821234},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":3,"arrangementStyle":0},"uiObject":{}}},"id":"5febb99a-093e-4ae2-afa8-e28743b302c3","savedPayload":{"position":{"x":31461.29986213681,"y":30266.402823821234},"targetPosition":{"x":31637.635437824552,"y":30509.107922133717},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"targetSizeInBaseAsset":{"type":"Target Size In Base Asset","name":"New Target Size In Base Asset","project":"Superalgos","formula":{"type":"Formula","name":"New Formula","code":"// Type your formula","project":"Superalgos","id":"4f17a02a-185b-4c85-b26f-85667100b1a7","savedPayload":{"position":{"x":31731.49611684869,"y":29916.494917776636},"targetPosition":{"x":31684.565777336622,"y":30212.801419955176},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":3,"arrangementStyle":0},"uiObject":{}}},"id":"bba4131a-dd63-490c-97a7-819c484a9a6a","savedPayload":{"position":{"x":31684.565777336622,"y":30212.801419955176},"targetPosition":{"x":31637.635437824552,"y":30509.107922133717},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"targetSizeInQuotedAsset":{"type":"Target Size In Quoted Asset","name":"New Target Size In Quoted Asset","project":"Superalgos","formula":{"type":"Formula","name":"New Formula","code":"// Type your formula","project":"Superalgos","id":"f9ae8796-8a5b-421e-b2b1-8741ea1a8cc2","savedPayload":{"position":{"x":32123.045634449518,"y":30156.43677075823},"targetPosition":{"x":31880.340536137035,"y":30332.772346445974},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":3,"arrangementStyle":0},"uiObject":{}}},"id":"19f04a50-0d33-4c0b-a723-1dd922de9b57","savedPayload":{"position":{"x":31880.340536137035,"y":30332.772346445974},"targetPosition":{"x":31637.635437824552,"y":30509.107922133717},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"id":"d41b3907-2ae7-4d87-8b10-f80fc30107d1","savedPayload":{"position":{"x":31637.635437824552,"y":30509.107922133717},"targetPosition":{"x":31590.705098312483,"y":30805.414424312257},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"openExecution":{"type":"Open Execution","name":"New Open Execution","project":"Superalgos","executionAlgorithms":[],"id":"90f51fa8-874d-460c-9f40-b4c533c0e75f","savedPayload":{"position":{"x":31833.410196624965,"y":30629.078848624515},"targetPosition":{"x":31590.705098312483,"y":30805.414424312257},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"closeStageEvent":{"type":"Close Stage Event","name":"New Close Stage Event","project":"Superalgos","situations":[{"type":"Situation","name":"New Situation","project":"Superalgos","conditions":[{"type":"Condition","name":"New Condition","project":"Superalgos","javascriptCode":{"type":"Javascript Code","name":"New Javascript Code","code":"// Type you code","project":"Superalgos","id":"76f03cf3-14ab-444d-847d-a3d86244236c","savedPayload":{"position":{"x":32183.31810266957,"y":30899.27510333639},"targetPosition":{"x":32035.1648515803,"y":30875.809933580356},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":3,"arrangementStyle":0},"uiObject":{}}},"id":"da3fb954-8ee5-4537-98ef-7ae9a9d18ade","savedPayload":{"position":{"x":32035.1648515803,"y":30875.809933580356},"targetPosition":{"x":31887.011600491027,"y":30852.344763824323},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false}}}],"id":"230c7c45-dfe4-44cf-96fd-103ccc94c7ec","savedPayload":{"position":{"x":31887.011600491027,"y":30852.344763824323},"targetPosition":{"x":31738.858349401755,"y":30828.87959406829},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false}}}],"announcements":[],"id":"9516578c-09f5-4e5a-9512-bd6a972e653b","savedPayload":{"position":{"x":31738.858349401755,"y":30828.87959406829},"targetPosition":{"x":31590.705098312483,"y":30805.414424312257},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":2,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"announcements":[],"id":"a4bc39be-42fd-4439-9397-d4f9b72c86ae","savedPayload":{"position":{"x":31590.705098312483,"y":30805.414424312257},"targetPosition":{"x":31348,"y":30981.75},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":true,"angleToParent":1,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"manageStage":{"type":"Manage Stage","name":"New Manage Stage","project":"Superalgos","managedStopLoss":{"type":"Managed Stop Loss","name":"New Managed Stop Loss","project":"Superalgos","phases":[{"type":"Phase","name":"New Phase","project":"Superalgos","formula":{"type":"Formula","name":"New Formula","code":"// Type your formula","project":"Superalgos","id":"2355e7d2-8df6-40ea-89b5-c14871b45a46","savedPayload":{"position":{"x":32038.23995122821,"y":31205.12338415819},"targetPosition":{"x":31889.061666922968,"y":31189.44411466804},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":3,"arrangementStyle":0},"uiObject":{}}},"moveToPhaseEvents":[],"announcements":[],"id":"6c14c525-08b9-47ab-a147-10a974ae6ceb","savedPayload":{"position":{"x":31889.061666922968,"y":31189.44411466804},"targetPosition":{"x":31739.883382617725,"y":31173.76484517789},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false}}}],"id":"b6587a2b-f666-49b8-a613-f0e2364d77ca","savedPayload":{"position":{"x":31739.883382617725,"y":31173.76484517789},"targetPosition":{"x":31590.705098312483,"y":31158.085575687743},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":2,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"managedTakeProfit":{"type":"Managed Take Profit","name":"New Managed Take Profit","project":"Superalgos","phases":[{"type":"Phase","name":"New Phase","project":"Superalgos","formula":{"type":"Formula","name":"New Formula","code":"// Type your formula","project":"Superalgos","id":"ec410d91-2186-4c11-9298-a7e728004bea","savedPayload":{"position":{"x":31773.736587696596,"y":31569.18103162692},"targetPosition":{"x":31712.726091235225,"y":31432.149212980526},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":3,"arrangementStyle":0},"uiObject":{}}},"moveToPhaseEvents":[],"announcements":[],"id":"e0f595de-f085-4890-bc73-881928da8d60","savedPayload":{"position":{"x":31712.726091235225,"y":31432.149212980526},"targetPosition":{"x":31651.715594773854,"y":31295.117394334135},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false}}}],"id":"5ef91d3f-b318-4ff2-9690-d79830001df6","savedPayload":{"position":{"x":31651.715594773854,"y":31295.117394334135},"targetPosition":{"x":31590.705098312483,"y":31158.085575687743},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":2,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"announcements":[],"id":"4e67c91b-a870-48e7-86b6-97d1ffa7df85","savedPayload":{"position":{"x":31590.705098312483,"y":31158.085575687743},"targetPosition":{"x":31348,"y":30981.75},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":true,"angleToParent":1,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"closeStage":{"type":"Close Stage","name":"New Close Stage","config":"{\n\"roundingErrorCorrectionFactor\": 1.01, \n\"absoluteDustInBaseAsset\": 0,\n\"absoluteDustInQuotedAsset\": 0 \n}","project":"Superalgos","initialTargets":{"type":"Initial Targets","name":"New Initial Targets","project":"Superalgos","targetRate":{"type":"Target Rate","name":"New Target Rate","project":"Superalgos","formula":{"type":"Formula","name":"New Formula","code":"// Type your formula","project":"Superalgos","id":"ff36b87d-b2af-432d-aad7-9f425d05da30","savedPayload":{"position":{"x":31962.12596138647,"y":31719.77910877002},"targetPosition":{"x":31676.809006497926,"y":31627.074010457538},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":3,"arrangementStyle":0},"uiObject":{}}},"id":"0c4588ed-6aad-4e43-aea2-fd857cdde709","savedPayload":{"position":{"x":31676.809006497926,"y":31627.074010457538},"targetPosition":{"x":31391.49205160938,"y":31534.368912145055},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"targetSizeInBaseAsset":{"type":"Target Size In Base Asset","name":"New Target Size In Base Asset","project":"Superalgos","formula":{"type":"Formula","name":"New Formula","code":"// Type your formula","project":"Superalgos","id":"b63cde4a-ffa7-4d55-827e-fdbe25d55f92","savedPayload":{"position":{"x":31663.886351453108,"y":32068.972826658075},"targetPosition":{"x":31527.689201531244,"y":31801.670869401565},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":3,"arrangementStyle":0},"uiObject":{}}},"id":"888c1960-5e4e-40bf-86a5-0733ad54d2d4","savedPayload":{"position":{"x":31527.689201531244,"y":31801.670869401565},"targetPosition":{"x":31391.49205160938,"y":31534.368912145055},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"targetSizeInQuotedAsset":{"type":"Target Size In Quoted Asset","name":"New Target Size In Quoted Asset","project":"Superalgos","formula":{"type":"Formula","name":"New Formula","code":"// Type your formula","project":"Superalgos","id":"555c938b-6d6a-43dc-89f2-864738616991","savedPayload":{"position":{"x":31206.081854984415,"y":32105.002821922146},"targetPosition":{"x":31298.786953296898,"y":31819.6858670336},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":3,"arrangementStyle":0},"uiObject":{}}},"id":"a8c951b1-9c11-4f6d-8461-fb935cf062d8","savedPayload":{"position":{"x":31298.786953296898,"y":31819.6858670336},"targetPosition":{"x":31391.49205160938,"y":31534.368912145055},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"id":"f33dc477-014b-4b16-a6bb-0c347f5a4992","savedPayload":{"position":{"x":31391.49205160938,"y":31534.368912145055},"targetPosition":{"x":31255.294901687517,"y":31267.066954888545},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"closeExecution":{"type":"Close Execution","name":"New Close Execution","project":"Superalgos","executionAlgorithms":[],"id":"b79f9f3f-01e6-417f-b644-825e17427e7c","savedPayload":{"position":{"x":31162.589803375035,"y":31552.38390977709},"targetPosition":{"x":31255.294901687517,"y":31267.066954888545},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"closeStageEvent":{"type":"Close Stage Event","name":"New Close Stage Event","project":"Superalgos","situations":[{"type":"Situation","name":"New Situation","project":"Superalgos","conditions":[{"type":"Condition","name":"New Condition","project":"Superalgos","javascriptCode":{"type":"Javascript Code","name":"New Javascript Code","code":"// Type you code","project":"Superalgos","id":"c6103247-6024-4e7d-81a5-833dc6d8d3ff","savedPayload":{"position":{"x":30720.690987174497,"y":31539.461254732272},"targetPosition":{"x":30854.341965802752,"y":31471.36267977134},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":3,"arrangementStyle":0},"uiObject":{}}},"id":"8655ace0-0cba-4682-aa94-795a3d34ce9a","savedPayload":{"position":{"x":30854.341965802752,"y":31471.36267977134},"targetPosition":{"x":30987.992944431007,"y":31403.26410481041},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false}}}],"id":"42267582-434d-4698-81d6-7ae8093d9a3a","savedPayload":{"position":{"x":30987.992944431007,"y":31403.26410481041},"targetPosition":{"x":31121.643923059262,"y":31335.165529849477},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false}}}],"announcements":[],"id":"8ebc6ab4-56ff-4afc-9741-a5ea2d8495f3","savedPayload":{"position":{"x":31121.643923059262,"y":31335.165529849477},"targetPosition":{"x":31255.294901687517,"y":31267.066954888545},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":2,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"announcements":[],"id":"3baca3ee-6498-4db5-8ba9-d7c9640907cf","savedPayload":{"position":{"x":31255.294901687517,"y":31267.066954888545},"targetPosition":{"x":31348,"y":30981.75},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":true,"angleToParent":1,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"id":"6b8ed032-1481-4e79-bcfa-b4d572e21df3","savedPayload":{"position":{"x":31348,"y":30981.75},"targetPosition":{"x":31048,"y":30981.75},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false}}}],"dynamicIndicators":{"type":"Dynamic Indicators","name":"New Dynamic Indicators","project":"Superalgos","indicatorFunctions":[{"type":"Indicator Function","name":"New Indicator Function","config":"{ \n \"codeName\": \"\"\n}","project":"Superalgos","formula":{"type":"Formula","name":"New Formula","code":"// Type your formula","project":"Superalgos","id":"3e3301b4-6742-49c8-82d6-20cd3453365f","savedPayload":{"position":{"x":30148,"y":30981.75},"targetPosition":{"x":30448,"y":30981.75},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":3,"arrangementStyle":0},"uiObject":{}}},"id":"21cc000a-cdbd-4c02-b1e4-4c4560861792","savedPayload":{"position":{"x":30448,"y":30981.75},"targetPosition":{"x":30748,"y":30981.75},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false}}}],"id":"ec700c19-7aee-4180-bb1f-5493f518e7ee","savedPayload":{"position":{"x":30748,"y":30981.75},"targetPosition":{"x":31048,"y":30981.75},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"id":"91a1d0d1-2a1a-45d5-a52b-b2dc5502339f","savedPayload":{"position":{"x":31048,"y":30981.75},"targetPosition":{"x":31048,"y":30981.75},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":true,"angleToParent":1,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false}}}]} \ No newline at end of file diff --git a/Projects/Superalgos/Schemas/AppSchema.json b/Projects/Superalgos/Schemas/AppSchema.json index c088ebefb..d329c4b5c 100644 --- a/Projects/Superalgos/Schemas/AppSchema.json +++ b/Projects/Superalgos/Schemas/AppSchema.json @@ -3242,8 +3242,7 @@ "compatibleTypes": "->Prediction->" }, "propertyNameAtParent": "predictionValue", - "childrenNodesProperties": [ - ], + "childrenNodesProperties": [], "icon": "bitcoin" }, { @@ -3415,8 +3414,7 @@ "compatibleTypes": "->Feature->" }, "propertyNameAtParent": "featureValue", - "childrenNodesProperties": [ - ], + "childrenNodesProperties": [], "icon": "bitcoin" }, { @@ -3588,8 +3586,7 @@ "compatibleTypes": "->Label->" }, "propertyNameAtParent": "labelValue", - "childrenNodesProperties": [ - ], + "childrenNodesProperties": [], "icon": "bitcoin" }, { @@ -5961,7 +5958,7 @@ "action": "Delete UI Object", "askConfirmation": true, "confirmationLabel": "Confirm to Delete", - "label": "This", + "label": "Delete", "iconPathOn": "delete-entity", "iconPathOff": "delete-entity", "actionFunction": "payload.executeAction" @@ -15083,7 +15080,8 @@ "childType": "Signals Provider", "autoAdd": true } - ] + ], + "icon": "bitcoin" }, { "type": "Signals Provider", @@ -15124,10 +15122,11 @@ "config": true }, "initialValues": { - "config": "{ \n\"webhookURL\": \"Webhook/New-Message/Trading-View/Binance/BTC-USDT\",\n\"testMessage\": \"\" \n}" + "config": "{ \n\"webhookURL\": \"Webhook/New-Message/Trading-View/binance/BTC-USDT\",\n\"testMessage\": \"\" \n}" }, "propertyNameAtParent": "signalsProviders", - "childrenNodesProperties": [] + "childrenNodesProperties": [], + "icon": "bitcoin" }, { "type": "Crypto Exchanges", @@ -15937,7 +15936,7 @@ "config": true }, "initialValues": { - "config": "{\"node\":{\"distancePercentage\":60,\"radiusPercentage\":85,\"massPercentage\":100,\"animationSteps\":2,\"menuItem\":{\"widthPercentage\":100,\"heightPercentage\":60,\"radiusPercentage\":90}},\"physics\":false}" + "config": "{\"node\":{\"distancePercentage\":60,\"radiusPercentage\":85,\"massPercentage\":100,\"animationSteps\":2,\"menuItem\":{\"widthPercentage\":100,\"heightPercentage\":60,\"radiusPercentage\":90}},\"physics\":false,\"detachUsingMouse\":false }" }, "menuItems": [ { @@ -19794,4 +19793,4 @@ } ] } -] \ No newline at end of file +] diff --git a/Projects/Superalgos/Schemas/Docs-Concepts/superalgos-sa-token.json b/Projects/Superalgos/Schemas/Docs-Concepts/superalgos-sa-token.json index d3a7aa9cd..23b498c98 100644 --- a/Projects/Superalgos/Schemas/Docs-Concepts/superalgos-sa-token.json +++ b/Projects/Superalgos/Schemas/Docs-Concepts/superalgos-sa-token.json @@ -37,8 +37,8 @@ }, { "style": "Text", - "text": "After issuing the token in March 2021, the funds were deposited at the project's Treasury Account, from where it is distributed to each year's Budget Account, each Release Account and finally to contributors accounts.", - "updated": 1614853686491 + "text": "After issuing the token in March 2021, the funds were deposited at the project's Treasury Account, from where it is distributed to contributors accounts.", + "updated": 1615564586741 }, { "style": "List", diff --git a/Projects/Superalgos/Schemas/Docs-Nodes/crypto-exchange.json b/Projects/Superalgos/Schemas/Docs-Nodes/crypto-exchange.json index ce26efe9e..cfbaec461 100644 --- a/Projects/Superalgos/Schemas/Docs-Nodes/crypto-exchange.json +++ b/Projects/Superalgos/Schemas/Docs-Nodes/crypto-exchange.json @@ -31,6 +31,14 @@ "style": "List", "text": "Bitfinex Test Status" }, + { + "style": "List", + "text": "Bittrex Test Status" + }, + { + "style": "List", + "text": "CoinbasePro Test Status" + }, { "style": "List", "text": "FTX Test Status", @@ -38,7 +46,8 @@ }, { "style": "List", - "text": "Kraken Tested Status" + "text": "Kraken Test Status", + "updated": 1615453046113 }, { "style": "List", diff --git a/Projects/Superalgos/Schemas/Docs-Nodes/space-settings.json b/Projects/Superalgos/Schemas/Docs-Nodes/space-settings.json index 163254323..704cea2c2 100644 --- a/Projects/Superalgos/Schemas/Docs-Nodes/space-settings.json +++ b/Projects/Superalgos/Schemas/Docs-Nodes/space-settings.json @@ -55,6 +55,10 @@ { "style": "List", "text": "physics determines wether the environment is static (false) or dynamic (true). When physics is set to true, nodes in the design space are affected by th gravitational pull and repulsion of other nodes." + }, + { + "style": "List", + "text": "detachUsingMouse defines if you can detach nodes from it's parent or reference parents only using the mouse (when true) or if you can not use the mouse for that and can only do it using the detach buttons on the icon's menu (when false)." } ] } \ No newline at end of file diff --git a/Projects/Superalgos/Schemas/Docs-Topics/app-commands-001-app-contribute-command.json b/Projects/Superalgos/Schemas/Docs-Topics/app-commands-001-app-contribute-command.json index c8b92efe2..0d8e372c7 100644 --- a/Projects/Superalgos/Schemas/Docs-Topics/app-commands-001-app-contribute-command.json +++ b/Projects/Superalgos/Schemas/Docs-Topics/app-commands-001-app-contribute-command.json @@ -7,15 +7,36 @@ "updated": 1610909304702 }, "paragraphs": [ + { + "style": "Text", + "text": "This command will send all the changes you have made both at Docs pages but also at any file within the Superalgos Repository to your fork at Github.com and from there to the main Superalgos Repository. It will do it specifically from the Current Branch to the Contributions Branch mentioned at the footer of this page. ", + "updated": 1615288848213 + }, + { + "style": "Important", + "text": "Contributions in most cases needs to come from the develop branch to the develop branch unless you have previously agreed with team members that you will send a contribution from master to master." + }, + { + "style": "Text", + "text": "Master is our stable branch and it is very unlikely that we are going to merge contributions there. Instead all contributions are expected to go to the develop branch, where there are many users testing that branch every day, and the contribution will reach the master branch at the next relrease.", + "updated": 1615288915134 + }, + { + "style": "Note", + "text": "It is also very unlikely that contributions coming from the master branch will be merged into the develop branch, since that can usually lead to merging conflicts. " + }, + { + "style": "Text", + "text": "So be sure that your Current Branch is develop and the Contribution Branch is develop before submitting your contribution. " + }, { "style": "Title", - "text": "Syntax", - "updated": 1609943337280 + "text": "Syntax" }, { "style": "Javascript", - "text": "docs.contribute Message", - "updated": 1609943744230 + "text": "app.contribute [Message]", + "updated": 1615461375106 }, { "style": "Title", @@ -33,8 +54,8 @@ }, { "style": "Javascript", - "text": "docs.contribute Fixed typo.", - "updated": 1610742512175 + "text": "app.contribute Fixed typo.", + "updated": 1615461382913 }, { "style": "Title", diff --git a/Projects/Superalgos/Schemas/Docs-Topics/app-commands-002-app-update-command.json b/Projects/Superalgos/Schemas/Docs-Topics/app-commands-002-app-update-command.json index 58aae238a..6d2b2ae00 100644 --- a/Projects/Superalgos/Schemas/Docs-Topics/app-commands-002-app-update-command.json +++ b/Projects/Superalgos/Schemas/Docs-Topics/app-commands-002-app-update-command.json @@ -14,8 +14,8 @@ }, { "style": "Json", - "text": "docs.update", - "updated": 1610710006400 + "text": "app.update", + "updated": 1615612258411 }, { "style": "Title", diff --git a/Projects/Superalgos/Schemas/Docs-Topics/app-commands-messages-004-app-message-update-done-new-version-found.json b/Projects/Superalgos/Schemas/Docs-Topics/app-commands-messages-004-app-message-update-done-new-version-found.json index 22209e9f7..a8f338a12 100644 --- a/Projects/Superalgos/Schemas/Docs-Topics/app-commands-messages-004-app-message-update-done-new-version-found.json +++ b/Projects/Superalgos/Schemas/Docs-Topics/app-commands-messages-004-app-message-update-done-new-version-found.json @@ -9,33 +9,37 @@ { "language": "ID", "text": "Proses pembaruan berhasil dilaksanakan. Versi terbaru Superalgos telah selesai diunduh dan mengganti versi yang sekarang. Agar perubahan diterapkan dengan baik, anda harus memulai ulang Client ini dan merefresh halaman UI ini.", - "updated": 1613891855110 + "updated": 1613891855110, + "style": "Definition" } ] }, "paragraphs": [ { "style": "Success", - "text": "You now have the latest version of Superalgos. Just remeber to restart the Client and the UI. If you have Tasks running, you should first stop the tasks, and then restart the Client, so that you can run those task again using the updated codebase.", - "updated": 1611160648343, + "text": "You now have the latest version of Superalgos. Just remember to restart the Client and the UI. If you have Tasks running, you should first stop the tasks, and then restart the Client, so that you can run those task again using the updated codebase.", + "updated": 1615458633005, "translations": [ { "language": "ID", "text": "Sekarang anda memiliki Superalgos versi terbaru. Perlu diingat untuk selalu memulai ulang Client dan UI. Jika memiliki Task yang berjalan, maka anda harus menghentikan Task tersebut terlebih dahulu, lalu memulai ulang Client, sehingga anda dapat menjalankan Task tersebut lagi menggunakan codebase yang terupdate.", - "updated": 1613892095568 + "updated": 1613892095568, + "style": "Success" } ] }, { "style": "Note", - "text": "The update you made, only afffects the Client which you are connected to via http using your browser. If you have more Clients running as part of a Network, you will need to update them too, etither manually using Git or by navigating with your browser to their URL and doing running the App Update Command there.", + "text": "The update you made, only affects the Client which you are connected to via http using your browser. If you have more Clients running as part of a Network, you will need to update them too, etither manually using Git or by navigating with your browser to their URL and doing running the App Update Command there.", "translations": [ { "language": "ID", "text": "Pembaruan yang Anda buat, hanya mempengaruhi Client yang terhubung melalui http menggunakan browser ini. Jika Anda memiliki lebih banyak Client yang berjalan sebagai bagian dari Network, anda juga perlu memperbaruinya, baik secara manual menggunakan Git atau dengan menavigasikan browser anda ke URL tujuan dan menjalankan App Update Command di sana.", - "updated": 1613892300538 + "updated": 1613892300538, + "style": "Note" } - ] + ], + "updated": 1615458652244 } ] } \ No newline at end of file diff --git a/Projects/Superalgos/Schemas/Docs-Topics/app-commands-messages-005-app-message-update-done-already-up-to-date.json b/Projects/Superalgos/Schemas/Docs-Topics/app-commands-messages-005-app-message-update-done-already-up-to-date.json index 85c72857c..b310587fe 100644 --- a/Projects/Superalgos/Schemas/Docs-Topics/app-commands-messages-005-app-message-update-done-already-up-to-date.json +++ b/Projects/Superalgos/Schemas/Docs-Topics/app-commands-messages-005-app-message-update-done-already-up-to-date.json @@ -3,13 +3,14 @@ "pageNumber": "5", "type": "App Message - Update Done - Already Up-To-Date", "definition": { - "text": "The update process run successfully but no changes where made since your installation is up-to-date with the current branch. No further action required.", - "updated": 1611128829429, + "text": "The update process run successfully but no changes were made since your installation is up-to-date with the current branch. No further action required.", + "updated": 1615458687718, "translations": [ { "language": "ID", "text": "Proses pembaruan berjalan dengan lancar namun tidak ada perubahan yang terjadi karena versi Superalgos anda sudah diversi paling baru dengan cabang saat ini. Tidak perlu tindakan lebih lanjut.", - "updated": 1613892507215 + "updated": 1613892507215, + "style": "Definition" } ] }, @@ -22,7 +23,8 @@ { "language": "ID", "text": "Anda sudah diversi paling up-to-date. Tidak perlu me-reboot Client atau merefresh halaman UI ini.", - "updated": 1613892633200 + "updated": 1613892633200, + "style": "Success" } ] } diff --git a/Projects/Superalgos/Schemas/Docs-Topics/contributing-to-superalgos-003-how-to-contribute-to-the-docs.json b/Projects/Superalgos/Schemas/Docs-Topics/contributing-to-superalgos-003-how-to-contribute-to-the-docs.json index 5b277022f..90c57c786 100644 --- a/Projects/Superalgos/Schemas/Docs-Topics/contributing-to-superalgos-003-how-to-contribute-to-the-docs.json +++ b/Projects/Superalgos/Schemas/Docs-Topics/contributing-to-superalgos-003-how-to-contribute-to-the-docs.json @@ -19,7 +19,8 @@ }, { "style": "Link", - "text": "Docs Group->https://t.me/superalgosdocs" + "text": "Docs Group->t.me/superalgosdocs", + "updated": 1615385427537 }, { "style": "Text", diff --git a/Projects/Superalgos/Schemas/Docs-Topics/docs-paragraph-styles-021-docs-anchor-style.json b/Projects/Superalgos/Schemas/Docs-Topics/docs-paragraph-styles-021-docs-anchor-style.json index a9cbe9e33..9a41f82cc 100644 --- a/Projects/Superalgos/Schemas/Docs-Topics/docs-paragraph-styles-021-docs-anchor-style.json +++ b/Projects/Superalgos/Schemas/Docs-Topics/docs-paragraph-styles-021-docs-anchor-style.json @@ -3,8 +3,8 @@ "pageNumber": 21, "type": "Docs Anchor Style", "definition": { - "text": "Amchor paragraphs are used together with the Docs Goto Command. When you want to generate a Docs Link to an specific part of a Docs Page, you first need to create an Anchor paragraph in order to be able to create the link to that part of the page.", - "updated": 1609258745310 + "text": "Anchor paragraphs are used together with the Docs Goto Command. When you want to generate a Docs Link to an specific part of a Docs Page, you first need to create an Anchor paragraph in order to be able to create the link to that part of the page.", + "updated": 1615591597546 }, "paragraphs": [ { diff --git a/Projects/Superalgos/Schemas/Docs-Topics/frequently-asked-questions-001-why-my-stage-is-not-closing.json b/Projects/Superalgos/Schemas/Docs-Topics/frequently-asked-questions-001-why-my-stage-is-not-closing.json index 9ead986d4..35469e22c 100644 --- a/Projects/Superalgos/Schemas/Docs-Topics/frequently-asked-questions-001-why-my-stage-is-not-closing.json +++ b/Projects/Superalgos/Schemas/Docs-Topics/frequently-asked-questions-001-why-my-stage-is-not-closing.json @@ -58,11 +58,6 @@ "text": "ABSOLUTE_DUST_IN_QUOTED_ASSET: is a numeric value that represents the distance that you allow to be between the Size Filled and the Target Side for a stage, measured in Base Asset. It's default value is Zero and you can define it at the config of a Stage node using the absoluteDustInQuotedAsset property.", "updated": 1615054151393 }, - { - "style": "Note", - "text": "The parameter that will actually be used from the two previous ones will depend on how you dedined your Target Size, either in Base Asset or Quoted Asset.", - "updated": 1615054261790 - }, { "style": "Subtitle", "text": "Implementation", @@ -74,8 +69,8 @@ }, { "style": "Javascript", - "text": "switch (tradingEngineStage.stageDefinedIn.value) {\n case 'Base Asset': {\n if (\n tradingEngineStage.stageBaseAsset.sizeFilled.value\n * \n ROUNDING_ERROR_CORRECTION_FACTOR\n +\n ABSOLUTE_DUST_IN_BASE_ASSET\n >=\n tradingEngineStage.stageBaseAsset.targetSize.value\n ) {\n positionFilled()\n } else {\n checkCloseStageEvent(tradingSystemStage)\n }\n break\n }\n case 'Quoted Asset': {\n if (\n tradingEngineStage.stageQuotedAsset.sizeFilled.value\n * \n ROUNDING_ERROR_CORRECTION_FACTOR\n +\n ABSOLUTE_DUST_IN_QUOTED_ASSET\n >=\n tradingEngineStage.stageQuotedAsset.targetSize.value\n ) {\n positionFilled()\n } else {\n checkCloseStageEvent(tradingSystemStage)\n }\n break\n }\n }", - "updated": 1615054391439 + "text": " if (\n tradingEngineStage.stageBaseAsset.sizeFilled.value\n *\n ROUNDING_ERROR_CORRECTION_FACTOR\n +\n ABSOLUTE_DUST_IN_BASE_ASSET\n >=\n tradingEngineStage.stageBaseAsset.targetSize.value\n ) {\n positionFilled()\n } else if (\n tradingEngineStage.stageQuotedAsset.sizeFilled.value\n *\n ROUNDING_ERROR_CORRECTION_FACTOR\n +\n ABSOLUTE_DUST_IN_QUOTED_ASSET\n >=\n tradingEngineStage.stageQuotedAsset.targetSize.value\n ) {\n positionFilled()\n } else {\n checkCloseStageEvent(tradingSystemStage)\n }", + "updated": 1615296774086 } ] } \ No newline at end of file diff --git a/Projects/Superalgos/Schemas/Docs-Topics/integrations-002-webhook-notifications.json b/Projects/Superalgos/Schemas/Docs-Topics/integrations-002-webhook-notifications.json index 9e172fe13..59cf5d19a 100644 --- a/Projects/Superalgos/Schemas/Docs-Topics/integrations-002-webhook-notifications.json +++ b/Projects/Superalgos/Schemas/Docs-Topics/integrations-002-webhook-notifications.json @@ -3,8 +3,8 @@ "pageNumber": "2", "type": "Webhook Notifications", "definition": { - "text": "Receive webhook notifications from other systems and use them as signals in your strategies.", - "updated": 1611486052936 + "text": "Receive webhook notifications from other systems like Trading View, and use them as signals in your strategies.", + "updated": 1615365927821 }, "paragraphs": [ { @@ -17,8 +17,29 @@ "text": "Superalgos allows you to receive webhook notifications from TradingView or any other system supporting webhooks. You may use this feature to turn notifications into signals upon which you may act from within your strategies." }, { - "style": "Text", - "text": "The system’s Web Server receives notifications and serves them to a sensor bot running as a data mining task. The sensor creates a data product with several properties which are made available to be used from within strategies." + "style": "Title", + "text": "How does it Work?", + "updated": 1615366465462 + }, + { + "style": "List", + "text": "Receving Data: the Client receives via it's http interface notifications from external sources (like Trading View) and keep the data received in-memory. This happens independently of the Webhooks Sensor Bot, meaning that it does not matter if the Webhook Sensor Bot is running or not.", + "updated": 1615366502234 + }, + { + "style": "List", + "text": "Retrieving Data: The Webhooks Sensor Bot, when it is running, queries the Client and ask it for the in-memory data it holds.", + "updated": 1615366526381 + }, + { + "style": "List", + "text": "Saving Data: The Webhooks Sensor Bot saves this data to disk.", + "updated": 1615366538404 + }, + { + "style": "List", + "text": "Consuming Data: A Trading Bot running a Strategy, might consume the data saved by the Webhooks Sensor Bot.", + "updated": 1615366547425 }, { "style": "Text", @@ -26,19 +47,11 @@ }, { "style": "Title", - "text": "Set-up the Webhooks Sensor Bot Tasks" + "text": "Set-up the Client for Webhooks" }, { "style": "Text", - "text": "The Masters data mine features the definition of the Webhooks sensor bot used to monitor incoming notifications. You need to run an instance of this bot in the data mining section of the exchange and market of your choice." - }, - { - "style": "Text", - "text": "The default workspace does not feature these tasks. To create a task for the Webhooks sensor bot, you need to uninstall and re-install the corresponding market." - }, - { - "style": "Text", - "text": "Once the Webhooks sensor task is set up and running, you are all set at the application level. It’s that simple." + "text": "There is nothing to configure in order for the Client to receive webhooks calls from external systems. The only thing you might need to do is to change the http interface port number at the Environment.js file if and only if your signals provider has any constraints regarding the port number it can send the notifications to." }, { "style": "Title", @@ -54,21 +67,143 @@ }, { "style": "Json", - "text": "{\n\"webhookURL\": \"Webhook/New-Message/Trading-View/Binance/BTC-USDT\",\n\"testMessage\": \"\"\n}", - "updated": 1611486196742 + "text": "{\n\"webhookURL\": \"Webhook/New-Message/Trading-View/binance/BTC-USDT\",\n\"testMessage\": \"\"\n}", + "updated": 1615370606690 }, { "style": "List", - "text": "webhookURL: This is the URL you need to use for testing purposes. Make sure you refer to the correct exchange and market." + "text": "webhookURL: This is the URL you need to use for testing purposes. Make sure you refer to the correct exchange and market. Something very similar to this, you will configure later at Trading View or other Signal Provider. ", + "updated": 1615368679683 }, { "style": "List", - "text": "testMessage: Enter any message, for testing purposes." + "text": "testMessage: Enter any message, for testing purposes. This message will be what you will use at your Trading System conditions to know which type of signal you received. ", + "updated": 1615368846219 + }, + { + "style": "Subtitle", + "text": "testMessage Examples" + }, + { + "style": "Javascript", + "text": "BUY" + }, + { + "style": "Javascript", + "text": "SELL" + }, + { + "style": "Javascript", + "text": "TRIGGER ON" + }, + { + "style": "Javascript", + "text": "TRIGGER OFF" + }, + { + "style": "Javascript", + "text": "TAKE POSITION" + }, + { + "style": "Subtitle", + "text": "Send the Test Message to the Client", + "updated": 1615368890166 }, { "style": "Text", "text": "Once the test message is configured, select Send Test Message on the menu." }, + { + "style": "Success", + "text": "By doing this, you are simulating being Trading View's server and sending the message in the exact same way they would do it, to the Superalgos Client you are running. " + }, + { + "style": "Text", + "text": "The Client does not know you are sending a Test Message, and it does not know it is you and not the real Trading View. For the Client's point of view someone sent a Webhook message to it and it will do with it what it will do with any other message of this type. Store it in-memory waiting for the Webhook Sensor Bot to fetch the pending messages, in which case the Client will delete them upon delivery to the Sensor Bot.", + "updated": 1615369237281 + }, + { + "style": "Note", + "text": "At the Signals Provider node you will see a message of failure or success depending if the message was succesfuly delivered to the Client or not." + }, + { + "style": "Note", + "text": "At the Client 's console, you will see 3 lines of logs, aknolidging that the message was received or if something was wrong, an error message with the cause." + }, + { + "style": "Text", + "text": "The success logs looks like this:" + }, + { + "style": "Javascript", + "text": "[INFO] httpInterface -> Webhook -> New-Message -> Exchange-Market = binance-BTC-USDT\n[INFO] httpInterface -> Webhook -> New-Message -> messageReceived = Sell\n[INFO] httpInterface -> Webhook -> New-Message -> Messeges waiting to be Ferched by Webhooks Sensor Bot = 1", + "updated": 1615370618823 + }, + { + "style": "Title", + "text": "Set-up the Webhooks Sensor Bot Tasks", + "updated": 1615370044893 + }, + { + "style": "Text", + "text": "The Masters Data Mine features the definition of the Webhooks sensor bot used to monitor incoming notifications. You need to run an instance of this bot in the data mining section of the exchange and market of your choice.", + "updated": 1615370092995 + }, + { + "style": "Text", + "text": "The default workspace does not feature these tasks. To create a task for the Webhooks sensor bot, you need to uninstall and re-install the corresponding market." + }, + { + "style": "Success", + "text": "Once the Webhooks sensor task is set up, you are all set at the application level. It’s that simple.", + "updated": 1615370160742 + }, + { + "style": "Title", + "text": "Running the Webhooks Sensor Bot" + }, + { + "style": "Text", + "text": "Now that you have verified that the Client is receiving the signal messages and storing them for you, the next thing to do is to run the Webhooks Sensor Bot so that it fetches the signals from the Client and saves them on disk in the format that later can be consumed from strategies.", + "updated": 1615369878800 + }, + { + "style": "Text", + "text": "By default, this bot will run every 30 seconds. Each time it runs you will see logs entries at the Client 's console similar to this:" + }, + { + "style": "Javascript", + "text": "2021-03-10T09:57:40.111Z Binance BTC/USDT Masters Webhooks Check-Webhook Main Loop # 3\n[INFO] httpInterface -> Webhook -> Fetch-Messages -> Exchange-Market = binance-BTC-USDT\n[INFO] httpInterface -> Webhook -> Fetch-Messages -> Messeges Fetched by Webhooks Sensor Bot = 0", + "updated": 1615370294905 + }, + { + "style": "Title", + "text": "Send Test Messages while Sensor Bot is Running", + "updated": 1615371461320 + }, + { + "style": "Text", + "text": "Now that you know how to send test messages, try doing that while the Sensor Bot is running. By looking at the Client 's console you will be able to see what is going on:", + "updated": 1615370466427 + }, + { + "style": "List", + "text": "The Client accumulates the signas received.", + "updated": 1615370477786 + }, + { + "style": "List", + "text": "The Sensor Bot fetches all the accumulated signals every time it runs." + }, + { + "style": "Text", + "text": "In the example below I sent 3 signal messages from the UI to the Client, and then the Sensor Bot fetch them all." + }, + { + "style": "Javascript", + "text": "[INFO] httpInterface -> Webhook -> New-Message -> Exchange-Market = binance-BTC-USDT\n[INFO] httpInterface -> Webhook -> New-Message -> messageReceived = Sell\n[INFO] httpInterface -> Webhook -> New-Message -> Messeges waiting to be Fetched by Webhooks Sensor Bot = 1\n[INFO] httpInterface -> Webhook -> New-Message -> Exchange-Market = binance-BTC-USDT\n[INFO] httpInterface -> Webhook -> New-Message -> messageReceived = Sell\n[INFO] httpInterface -> Webhook -> New-Message -> Messeges waiting to be Fetched by Webhooks Sensor Bot = 2\n[INFO] httpInterface -> Webhook -> New-Message -> Exchange-Market = binance-BTC-USDT\n[INFO] httpInterface -> Webhook -> New-Message -> messageReceived = Sell\n[INFO] httpInterface -> Webhook -> New-Message -> Messeges waiting to be Fetched by Webhooks Sensor Bot = 3\n2021-03-10T10:04:40.472Z Binance BTC/USDT Masters Webhooks Check-Webhook Main Loop # 17\n[INFO] httpInterface -> Webhook -> Fetch-Messages -> Exchange-Market = binance-BTC-USDT\n[INFO] httpInterface -> Webhook -> Fetch-Messages -> Messeges Fetched by Webhooks Sensor Bot = 3", + "updated": 1615370778562 + }, { "style": "Title", "text": "Webhooks Sensor Bot Output" @@ -80,8 +215,18 @@ }, { "style": "Json", - "text": "\\Data-Storage\\Exchange\\Market\\Masters\\Webhooks\\Output\\External-Signals\\Single-File\\", - "updated": 1611486278677 + "text": " Data-Storage\\Project\\Superalgos\\Data-Mine\\Masters\\Webhooks\\Exchange-Id\\Market\\Output\\External-Signals\\Single-File\n", + "updated": 1615371100856 + }, + { + "style": "Text", + "text": "Based on our tests, the location you would find the file would be:", + "updated": 1615371008258 + }, + { + "style": "Json", + "text": "Data-Storage\\Project\\Superalgos\\Data-Mine\\Masters\\Webhooks\\binance\\BTC-USDT\\Output\\External-Signals\\Single-File", + "updated": 1615371017985 }, { "style": "Text", @@ -94,11 +239,13 @@ }, { "style": "Text", - "text": "This is what the file may look like, assuming you sent four different test messages:" + "text": "This is what the file may look like after the 3 test messages we sent:", + "updated": 1615370943470 }, { "style": "Json", - "text": "[[1587998459260,\"Trading-View\",\"Sell\"],[1587998475409,\"Trading-View\",\"Buy\"],[1587998530190,\"Trading-View\",\"A custom signal I just configured\"],[1588000300940,\"Trading-View\",\"This is my new message\"]]" + "text": "[[1615370665064,\"Trading-View\",\"Sell\"],[1615370665655,\"Trading-View\",\"Sell\"],[1615370666472,\"Trading-View\",\"Sell\"]]\n", + "updated": 1615370924302 }, { "style": "Text", @@ -106,15 +253,18 @@ }, { "style": "List", - "text": "timestamp: the Unix datetime of the message." + "text": "timestamp: the Unix datetime of the message. This is the moment in time the Client received the signal from the external Signals provider.", + "updated": 1615371169447 }, { "style": "List", - "text": "source: the name of the signal provider." + "text": "source: the name of the Signal Provider. This comes as part of the message sent by the provider, because is part of the URL you will specify later at the Signal Provider's system. In our example we used Trading View, but in fact it could be any other provider. You will have this property available at your Trading System, meaning that you will be able to write conditions that distingish the signal by Signal Provider.", + "updated": 1615371322994 }, { "style": "List", - "text": "message: the message set up at the provider’s system." + "text": "message: the message set up at the provider’s system (BUY, SELL, etc.).", + "updated": 1615371373274 }, { "style": "Title", @@ -142,7 +292,8 @@ }, { "style": "Javascript", - "text": "chart.atAnyTimeFrame.externalSignal.source === \"Trading-View\" && chart.atAnyTimeFrame.externalSignal.message === \"Buy\"" + "text": "chart.atAnyTimeFrame.externalSignal.source === \"Trading-View\" && \nchart.atAnyTimeFrame.externalSignal.message === \"BUY\"", + "updated": 1615371544991 }, { "style": "Text", @@ -150,7 +301,8 @@ }, { "style": "Javascript", - "text": "chart.atAnyTimeFrame.externalSignal.previous.message === \"Buy\"" + "text": "chart.atAnyTimeFrame.externalSignal.previous.message === \"BUY\"", + "updated": 1615371536367 }, { "style": "Text", @@ -164,9 +316,227 @@ "style": "Text", "text": "In the above example, the first parameter chart.atAnyTimeFrame.externalSignal is the signal object you wish to check, and the second parameter chart.at01hs.candle is any other object that is delimited in time. In this case, the condition validates true if the last message falls within the last 1-hour candle." }, + { + "style": "Warning", + "text": "The reason to make this validation is to avoid situations where the Webhook sensor bot was not running and it retrieved from the Client signals that are already old. If you do not check the age of the signal you might get into the situation where you are triggering a buy or sell based on old data." + }, { "style": "Title", - "text": "Set-up Alerts/Messages at the Provider" + "text": "Test that the Signal is Taken by your Strategy", + "updated": 1615377044554 + }, + { + "style": "Text", + "text": "We will make ourselves sure that from within a strategy we can react to an external Signal. To test this, plese take the following steps. All of the following goes into the current Lighting Strike Backtesting Session / Task.", + "updated": 1615379790606 + }, + { + "style": "Subtitle", + "text": "Paper Trading Session", + "updated": 1615380274411 + }, + { + "style": "Text", + "text": "Rigth click over the Backtesting Session node and select switch to Paper Trading so that we can simulate live trading without connecting to the exchange." + }, + { + "style": "Subtitle", + "text": "Set-up Session Parameters" + }, + { + "style": "Text", + "text": "Since you have reinstalled the market in order for the task of the Webhooks bot to appear at the Master Trading Mine Tasks, the setup for the Lighting Strike strategy needs to be fixed. (Assuming you are at the Getting Started Workspace). This is what we are going to do:", + "updated": 1615379719899 + }, + { + "style": "Text", + "text": "Apply this config to your Session Base Asset", + "updated": 1615379980416 + }, + { + "style": "Json", + "text": "{\n \"initialBalance\": 0\n}", + "updated": 1615382028446 + }, + { + "style": "Text", + "text": "Apply this config to the Session Quoted Asset", + "updated": 1615379973089 + }, + { + "style": "Json", + "text": "{\n \"initialBalance\": 1\n}", + "updated": 1615380003924 + }, + { + "style": "Text", + "text": "Apply this config to the Time Range", + "updated": 1615380023496 + }, + { + "style": "Json", + "text": "{\n \"initialDatetime\": \"2020-09-01\",\n \"finalDatetime\": \"2030-09-02\"\n}", + "updated": 1615380126836 + }, + { + "style": "Text", + "text": "The initialDatetime will be ingoned because we are running a Paper Trading Session. The important thing is that the finalDatetime is in the future.", + "updated": 1615380159343 + }, + { + "style": "Text", + "text": "Apply this config to the Time Frame", + "updated": 1615380180549 + }, + { + "style": "Json", + "text": "{\n \"label\": \"01-min\"\n}", + "updated": 1615380196254 + }, + { + "style": "Subtitle", + "text": "Set-up the Strategy for Webhooks Signals", + "updated": 1615380571676 + }, + { + "style": "Text", + "text": "Inside the Lighting Strike trading system locate the Trigger On Event, and paste the following into the Javascript Node of the only condition it has.", + "updated": 1615380721252 + }, + { + "style": "Javascript", + "text": "chart.atAnyTimeFrame.externalSignal.message === \"TRIGGER ON\"", + "updated": 1615380737459 + }, + { + "style": "Text", + "text": "What we are doing here is setting the strategy to be triggered once an external signal with the message TRIGGER ON is received via the Webhook Sensor Bot." + }, + { + "style": "Subtitle", + "text": "Run the Data Mining Tasks" + }, + { + "style": "Text", + "text": "For this test, since we are Paper Trading, we will need a live stream of data from the exchange. We don't need to run all the Task of Mater Data Mining, only the ones needed by the Lighting Strike strategy:" + }, + { + "style": "List", + "text": "Exchange Raw Data" + }, + { + "style": "List", + "text": "Candles Volumens" + }, + { + "style": "List", + "text": "Resistances and Supports" + }, + { + "style": "List", + "text": "Webhooks " + }, + { + "style": "Text", + "text": "" + }, + { + "style": "Subtitle", + "text": "Run Task and Session" + }, + { + "style": "Text", + "text": "Run Task and the Session, and monitor the chart that was called Backtesting (now that is our Papertrading session), at the end of the market at the 1 minute time frame. Turn on the Episodes layer and wait for a few minutes until you see the Episode icons appear at the charts.", + "updated": 1615380482184 + }, + { + "style": "Text", + "text": "Before running the task and session, delete the data at " + }, + { + "style": "Javascript", + "text": "Data-Storage\\Project\\Superalgos\\Data-Mine\\Masters\\Webhooks", + "updated": 1615381701627 + }, + { + "style": "Important", + "text": "This is not necesary the first time you run this, but if you are repeating this test, you will avoid confusions since the file of signals will be accumulating the test messages you send, and at the strategy we are not checking for the age of the messages, so it is a good idea to delete this data every time you try this procedure.", + "updated": 1615381726583 + }, + { + "style": "Subtitle", + "text": "Set-up the Signals Provider", + "updated": 1615380812487 + }, + { + "style": "Text", + "text": "At the Crypto Ecosystem, paste the following config to the Signals Provider.", + "updated": 1615380855069 + }, + { + "style": "Javascript", + "text": "{\n \"webhookURL\": \"Webhook/New-Message/Trading-View/binance/BTC-USDT\",\n \"testMessage\": \"TRIGGER ON\"\n}", + "updated": 1615380896874 + }, + { + "style": "Text", + "text": "This means that when you send this test message, you will be delivering the TRIGGER ON signal expected by the strategy." + }, + { + "style": "Subtitle", + "text": "Ready to Send the Test Message TRIGGER ON", + "updated": 1615381087734 + }, + { + "style": "Text", + "text": "Go to the charts again an turn on the Strategies layer. You should not see anything at the charts since no strategy has been triggered.", + "updated": 1615381066133 + }, + { + "style": "Success", + "text": "Now you can send the test message." + }, + { + "style": "Text", + "text": "After you see the confirmation at the UI that the message was sent, check the Client's console to verify the message was received. Then wait until the message is picked up by the Webhooks Sensor Bot. Then wait until the Trading Bot runs again." + }, + { + "style": "Text", + "text": "Go to the charts and wait until it plots the icons of the strategy, confirming that the strategy was triggered by the test message you sent." + }, + { + "style": "Note", + "text": "If all this worked, it means that it will work if the message comes from Trading View or other Signal Provider too." + }, + { + "style": "Text", + "text": "" + }, + { + "style": "Text", + "text": "" + }, + { + "style": "Title", + "text": "Set-up your Firewall / Rounter to accept Incoming Connections" + }, + { + "style": "Text", + "text": "As you might have imagined, you will need to open a port at your rounter / firewall to accept incomming connections from the signal provider's servers (like Trading View for instance). This is what allows that server to connect to the server where the Client is running, enabling the Client to receive those signals." + }, + { + "style": "Important", + "text": "How you configure your Rounter / Firewall is up to you, and it depends on your network setup. You will need to do your research for details on how to do it, because it depends on which rounter / firewall you are using. We suggest you to include on the rules of your Firewall / Rounter the domain name or IP address of the Signal provider, so that nobody else can connect to the Client's http interface, which has, beyond Webhooks other features you don't want to expose openly to the world without restrictions.", + "updated": 1615368540044 + }, + { + "style": "Text", + "text": "What we can tell you regarding this, is that the Superalgos Client is running a very simple http server at the port configured at the Environment.js file." + }, + { + "style": "Title", + "text": "Set-up Alerts / Messages at the Signals Provider", + "updated": 1615368585310 }, { "style": "Text", @@ -182,15 +552,8 @@ }, { "style": "Json", - "text": "http://182.45.73.1:34247/Webhook/New-Message/Trading-View/Binance/BTC-USDT" - }, - { - "style": "Text", - "text": "Set-up Your Network to Accept Incoming Connections" - }, - { - "style": "Text", - "text": "Needless to say, you need to configure your network / router / firewall to allow incoming webhook messages on the corresponding port." + "text": "http://182.45.73.1:34247/Webhook/New-Message/Trading-View/binance/BTC-USDT", + "updated": 1615371762205 }, { "style": "Text", diff --git a/Projects/Superalgos/Schemas/Docs-Topics/tested-exchanges-006-luno-test-status.json b/Projects/Superalgos/Schemas/Docs-Topics/tested-exchanges-006-luno-test-status.json index 4c90f05e2..8cfc8ac2a 100644 --- a/Projects/Superalgos/Schemas/Docs-Topics/tested-exchanges-006-luno-test-status.json +++ b/Projects/Superalgos/Schemas/Docs-Topics/tested-exchanges-006-luno-test-status.json @@ -3,8 +3,8 @@ "pageNumber": "6", "type": "Luno Test Status", "definition": { - "text": "Luno is tested for data mining but not for live trading", - "updated": 1615204721150 + "text": "Luno is tested for data mining and for live trading", + "updated": 1615550142553 }, "paragraphs": [ { @@ -24,23 +24,23 @@ }, { "style": "List", - "text": "Trading Capability [**]: Unknown", - "updated": 1615204866750 + "text": "Trading Capability [**]: Yes", + "updated": 1615550165906 }, { "style": "List", - "text": "Comments: Raw Data mining is extremely slow due to exchange restrictions on their API that limit the number of data it can be requested via Rest API. One day of Raw Data takes about 5 minutes to download. Keep this in mind when setting a start date", - "updated": 1615205045729 + "text": "Comments: Raw Data mining is extremely slow due to exchange restrictions on their API that limit the number of data it can be requested via Rest API. One day of Raw Data takes about 5 minutes to download. Keep this in mind when setting a start date. The reason for this is because they do not support fetching of OHCLV data - this data has to be compiled by fetching individual trades. The fetching of trades is limited to 100 trades per request, and the rate limit is 1 second.", + "updated": 1615456853257 }, { "style": "Text", - "text": "[*] The ability to fetch historic data for backtesting purposes has been verified", - "updated": 1615211359233 + "text": "[*] The ability to fetch historic data for backtesting purposes has been verified.", + "updated": 1615456911815 }, { "style": "Text", - "text": "[**] The ability to run strategies in live-trading mode has not been verified", - "updated": 1615211364516 + "text": "[**] The ability to run strategies in live-trading mode is now possible. Ensure that the version of the CCXT library being used by Superalgos is 1.42.77 or better - earlier versions of this library did not correctly apply the precision settings of the exchange in the amounts specified for creating orders.", + "updated": 1615550355806 }, { "style": "Title", diff --git a/Projects/Superalgos/Schemas/Docs-Topics/tested-exchanges-008-bittrex-test-status.json b/Projects/Superalgos/Schemas/Docs-Topics/tested-exchanges-008-bittrex-test-status.json new file mode 100644 index 000000000..f3829220a --- /dev/null +++ b/Projects/Superalgos/Schemas/Docs-Topics/tested-exchanges-008-bittrex-test-status.json @@ -0,0 +1,59 @@ +{ + "topic": "Tested Exchanges", + "pageNumber": "8", + "type": "Bittrex Test Status", + "definition": { + "text": "Bittrex is not fully tested for data mining nor for live trading", + "updated": 1615450372178 + }, + "paragraphs": [ + { + "style": "Title", + "text": "Properties", + "updated": 1615143100216 + }, + { + "style": "List", + "text": "1-min OHLCVs Capability [*]: Yes", + "updated": 1615204617519 + }, + { + "style": "List", + "text": "Market History: Unknown", + "updated": 1615450231832 + }, + { + "style": "List", + "text": "Trading Capability [**]: Unknown", + "updated": 1615204866750 + }, + { + "style": "List", + "text": "Comments: Raw Data mining it's extremely slow due to API restriction", + "updated": 1615450349464 + }, + { + "style": "Text", + "text": "[*] The ability to fetch historic data for backtesting purposes has not been verified", + "updated": 1615211296452 + }, + { + "style": "Text", + "text": "[**] The ability to run strategies in live-trading mode has not been verified", + "updated": 1615211304255 + }, + { + "style": "Title", + "text": "Configuration" + }, + { + "style": "Json", + "text": "{\n \"codeName\": \"bittrex\",\n \"API\": [\n {\n \"method\": \"fetch_ohlcv\",\n \"limit\": 2\n }\n ]\n}", + "updated": 1615450253869 + }, + { + "style": "Text", + "text": "" + } + ] +} \ No newline at end of file diff --git a/Projects/Superalgos/Schemas/Docs-Topics/tested-exchanges-009-coinbasepro-test-status.json b/Projects/Superalgos/Schemas/Docs-Topics/tested-exchanges-009-coinbasepro-test-status.json new file mode 100644 index 000000000..7abf7f26f --- /dev/null +++ b/Projects/Superalgos/Schemas/Docs-Topics/tested-exchanges-009-coinbasepro-test-status.json @@ -0,0 +1,59 @@ +{ + "topic": "Tested Exchanges", + "pageNumber": "9", + "type": "CoinbasePro Test Status", + "definition": { + "text": "Coinbase Pro is not fully tested for data mining nor for live trading", + "updated": 1615453123690 + }, + "paragraphs": [ + { + "style": "Title", + "text": "Properties", + "updated": 1615143100216 + }, + { + "style": "List", + "text": "1-min OHLCVs Capability [*]: Yes", + "updated": 1615204617519 + }, + { + "style": "List", + "text": "Market History: Unknown", + "updated": 1615453086807 + }, + { + "style": "List", + "text": "Trading Capability [**]: Unknown", + "updated": 1615204866750 + }, + { + "style": "List", + "text": "Comments: Raw Data fetching extremely slow due to API restrictions, see config", + "updated": 1615453110186 + }, + { + "style": "Text", + "text": "[*] The ability to fetch historic data for backtesting purposes has not been fully verified", + "updated": 1615453130798 + }, + { + "style": "Text", + "text": "[**] The ability to run strategies in live-trading mode has not been verified", + "updated": 1615211304255 + }, + { + "style": "Title", + "text": "Configuration" + }, + { + "style": "Json", + "text": "{\n \"codeName\": \"coinbasepro\",\n \"API\": [\n {\n \"method\": \"fetch_ohlcv\",\n \"limit\": 300\n }\n ]\n}", + "updated": 1615453067170 + }, + { + "style": "Text", + "text": "" + } + ] +} \ No newline at end of file diff --git a/Projects/Superalgos/Schemas/Docs-Topics/user-examples-for-stop-loss-001-trailing-stop-loss-percentage-of-rate.json b/Projects/Superalgos/Schemas/Docs-Topics/user-examples-for-stop-loss-001-trailing-stop-loss-percentage-of-rate.json index e371d17ca..58f92f209 100644 --- a/Projects/Superalgos/Schemas/Docs-Topics/user-examples-for-stop-loss-001-trailing-stop-loss-percentage-of-rate.json +++ b/Projects/Superalgos/Schemas/Docs-Topics/user-examples-for-stop-loss-001-trailing-stop-loss-percentage-of-rate.json @@ -32,8 +32,8 @@ }, { "style": "Javascript", - "text": "\nlet trailingStopLoss = 3 // Set the percentage you wish your Trailing Stop Loss to trail\n\nif ( chart.at01min.candle.close * ( 1 + (trailingStopLoss / 100) ) > tradingEngine.tradingCurrent.position.stopLoss.value ) {\nchart.at01min.candle.close * ( 1 + (trailingStopLoss / 100) )\n}\nelse {\ntradingEngine.tradingCurrent.position.stopLoss.value\n}", - "updated": 1615286314820 + "text": "let trailingStopLoss = 3 // Set the percentage you wish your Trailing Stop Loss to trail\n\nif ( chart.at01min.candle.close * ( 1 + (trailingStopLoss / 100) ) < tradingEngine.tradingCurrent.position.stopLoss.value ) {\nchart.at01min.candle.close * ( 1 + (trailingStopLoss / 100) )\n}\nelse {\ntradingEngine.tradingCurrent.position.stopLoss.value\n}", + "updated": 1615297661487 }, { "style": "Important", diff --git a/Projects/Superalgos/Schemas/Docs-Topics/user-examples-for-stop-loss-002-trailing-stop-loss-risk-of-total-quoted-balance.json b/Projects/Superalgos/Schemas/Docs-Topics/user-examples-for-stop-loss-002-trailing-stop-loss-risk-of-total-quoted-balance.json index 84fe43f85..4c1c2097f 100644 --- a/Projects/Superalgos/Schemas/Docs-Topics/user-examples-for-stop-loss-002-trailing-stop-loss-risk-of-total-quoted-balance.json +++ b/Projects/Superalgos/Schemas/Docs-Topics/user-examples-for-stop-loss-002-trailing-stop-loss-risk-of-total-quoted-balance.json @@ -39,8 +39,8 @@ }, { "style": "Javascript", - "text": "\nlet riskPercentage = 2\n\nif ( tradingEngine.tradingCurrent.position.entryTargetRate.value * (1 + (( tradingEngine.tradingCurrent.tradingEpisode.episodeQuotedAsset.balance.value * (riskPercentage / 100)) / tradingEngine.tradingCurrent.strategyOpenStage.stageQuotedAsset.sizeFilled.value)) > tradingEngine.tradingCurrent.position.stopLoss.value ) \n\n{\ntradingEngine.tradingCurrent.position.entryTargetRate.value * (1 + (( tradingEngine.tradingCurrent.tradingEpisode.episodeQuotedAsset.balance.value * (riskPercentage / 100)) / tradingEngine.tradingCurrent.strategyOpenStage.stageQuotedAsset.sizeFilled.value))\n}\n\nelse {\ntradingEngine.tradingCurrent.position.stopLoss.value\n}", - "updated": 1615287799360 + "text": "let riskPercentage = 2\n\nif ( tradingEngine.tradingCurrent.position.entryTargetRate.value * (1 + (( tradingEngine.tradingCurrent.tradingEpisode.episodeQuotedAsset.balance.value * (riskPercentage / 100)) / tradingEngine.tradingCurrent.strategyOpenStage.stageQuotedAsset.sizeFilled.value)) < tradingEngine.tradingCurrent.position.stopLoss.value ) \n\n{\ntradingEngine.tradingCurrent.position.entryTargetRate.value * (1 + (( tradingEngine.tradingCurrent.tradingEpisode.episodeQuotedAsset.balance.value * (riskPercentage / 100)) / tradingEngine.tradingCurrent.strategyOpenStage.stageQuotedAsset.sizeFilled.value))\n}\n\nelse {\ntradingEngine.tradingCurrent.position.stopLoss.value\n}", + "updated": 1615297434458 } ] } \ No newline at end of file diff --git a/Projects/Superalgos/Schemas/Docs-Topics/user-examples-for-stop-loss-003-trailing-stop-loss-initial-stop-loss-risk-and-targets-combo.json b/Projects/Superalgos/Schemas/Docs-Topics/user-examples-for-stop-loss-003-trailing-stop-loss-initial-stop-loss-risk-and-targets-combo.json new file mode 100644 index 000000000..d62d36c0d --- /dev/null +++ b/Projects/Superalgos/Schemas/Docs-Topics/user-examples-for-stop-loss-003-trailing-stop-loss-initial-stop-loss-risk-and-targets-combo.json @@ -0,0 +1,43 @@ +{ + "topic": "User Examples for Stop Loss ", + "pageNumber": 3, + "type": " Trailing Stop Loss - Initial Stop Loss, Risk and Targets Combo", + "definition": { + "text": "Setting an initial Risk Percentage of your Total Quoted Balance, after reaching the first Profit Target your first Trailing Stop Loss takes place. After reaching second Profit Target, we'll set the Trailing Stop Loss to a fixed percentage.", + "updated": 1615298179984 + }, + "paragraphs": [ + { + "style": "Title", + "text": "Initial Stop Loss, Risk and Target Combo", + "updated": 1615297964577 + }, + { + "style": "Text", + "text": "The idea of this is to initially give the position some space to move." + }, + { + "style": "Text", + "text": "When ever the position reaches the first Profit Target, it will use a Trailing Stop Loss set to the Profit divided by your Profit Divider. After reaching the second Profit Target, the Trailing Stop Loss will use a fixed percentage." + }, + { + "style": "Subtitle", + "text": "Example for a Long Position" + }, + { + "style": "Javascript", + "text": "\nriskPercentage = 1 // Initial Stop Loss is set by this Risk Percentage out of your Total Quoted Balance\n\nprofitTarget1 = 0.5 // First Percent Profit\nprofitDivider = 2 // The profit will be divided with this value and set your Stop Loss to the Entry Rate + Half Profit\n\nprofitTarget2 = 5 // Second Percent Profit\ntrailingStopLoss = 2.5 // Fixed Trailing Percentage\n\nif ( chart.at01min.candle.close > (tradingEngine.tradingCurrent.position.entryTargetRate.value * (1 + (profitTarget2 / 100))) && tradingEngine.tradingCurrent.position.stopLoss.value < (chart.at01min.candle.close * (1 - (trailingStopLoss2 / 100))) ) {\n chart.at01min.candle.close * (1 - (trailingStopLoss / 100))\n}\n\nelse if ( chart.at01min.candle.close > (tradingEngine.tradingCurrent.position.entryTargetRate.value * (1 + (profitTarget1 / 100))) && tradingEngine.tradingCurrent.position.stopLoss.value < chart.at01min.candle.close - ( (chart.at01min.candle.close - tradingEngine.tradingCurrent.position.entryTargetRate.value) / profitDivider) ) {\n chart.at01min.candle.close - ( (chart.at01min.candle.close - tradingEngine.tradingCurrent.position.entryTargetRate.value) / profitDivider)\n}\n\nelse {\n tradingEngine.tradingCurrent.position.entryTargetRate.value * (1 - (( tradingEngine.tradingCurrent.tradingEpisode.episodeQuotedAsset.balance.value * (riskPercentage / 100)) / tradingEngine.tradingCurrent.strategyOpenStage.stageQuotedAsset.sizeFilled.value))\n}", + "updated": 1615298020120 + }, + { + "style": "Subtitle", + "text": "Example for a Short Position", + "updated": 1615298191803 + }, + { + "style": "Javascript", + "text": "\nriskPercentage = 1 // Initial Stop Loss is set by this Risk Percentage out of your Total Quoted Balance\n\nprofitTarget1 = 0.5 // First Percent Profit\nprofitDivider = 2 // The profit will be divided with this value and set your Stop Loss to the Entry Rate + Half Profit\n\nprofitTarget2 = 5 // Second Percent Profit\ntrailingStopLoss = 2.5 // Fixed Trailing Percentage\n\nif ( chart.at01min.candle.close < (tradingEngine.tradingCurrent.position.entryTargetRate.value * (1 - (profitTarget2 / 100))) && tradingEngine.tradingCurrent.position.stopLoss.value > (chart.at01min.candle.close * (1 + (trailingStopLoss2 / 100))) ) {\n chart.at01min.candle.close * (1 + (trailingStopLoss / 100))\n}\n\nelse if ( chart.at01min.candle.close < (tradingEngine.tradingCurrent.position.entryTargetRate.value * (1 - (profitTarget1 / 100))) && tradingEngine.tradingCurrent.position.stopLoss.value > chart.at01min.candle.close + ( (chart.at01min.candle.close - tradingEngine.tradingCurrent.position.entryTargetRate.value) / profitDivider) ) {\n chart.at01min.candle.close + ( (chart.at01min.candle.close + tradingEngine.tradingCurrent.position.entryTargetRate.value) / profitDivider)\n}\n\nelse {\n tradingEngine.tradingCurrent.position.entryTargetRate.value * (1 + (( tradingEngine.tradingCurrent.tradingEpisode.episodeQuotedAsset.balance.value * (riskPercentage / 100)) / tradingEngine.tradingCurrent.strategyOpenStage.stageQuotedAsset.sizeFilled.value))\n}", + "updated": 1615298026442 + } + ] +} \ No newline at end of file diff --git a/Projects/Superalgos/Schemas/Docs-Tutorials/contribute-to-superalgos-015-tutorial-step-set-up-the-token.json b/Projects/Superalgos/Schemas/Docs-Tutorials/contribute-to-superalgos-015-tutorial-step-set-up-the-token.json index c13be1036..4b149248c 100644 --- a/Projects/Superalgos/Schemas/Docs-Tutorials/contribute-to-superalgos-015-tutorial-step-set-up-the-token.json +++ b/Projects/Superalgos/Schemas/Docs-Tutorials/contribute-to-superalgos-015-tutorial-step-set-up-the-token.json @@ -11,10 +11,14 @@ "updated": 1610815737032 }, "paragraphs": [ + { + "style": "Note", + "text": "Github API is currently at the \"Getting Started\" workspace, under APIs.", + "updated": 1615593559409 + }, { "style": "Callout", - "text": "Copy the token, open the Github API node config, and paste it between the double quotes of the token parameter. Fill in the username parameter with your GitHub.com user, not your email!", - "updated": 1610984794891 + "text": "Copy the token, open the Github API node config, and paste it between the double quotes of the token parameter. Fill in the username parameter with your GitHub.com user, not your email!" }, { "style": "Note", diff --git a/Projects/Superalgos/Schemas/Docs-Tutorials/defining-a-trading-idea-014-tutorial-step-bollinger-bands-rules.json b/Projects/Superalgos/Schemas/Docs-Tutorials/defining-a-trading-idea-014-tutorial-step-bollinger-bands-rules.json index 0d079211f..8cc4b7c2d 100644 --- a/Projects/Superalgos/Schemas/Docs-Tutorials/defining-a-trading-idea-014-tutorial-step-bollinger-bands-rules.json +++ b/Projects/Superalgos/Schemas/Docs-Tutorials/defining-a-trading-idea-014-tutorial-step-bollinger-bands-rules.json @@ -17,8 +17,8 @@ }, { "style": "Link", - "text": "as defined by John Bollinger himself!->https://www.bollingerbands.com/bollinger-band-rules", - "updated": 1610452258290 + "text": "as defined by John Bollinger himself!->www.bollingerbands.com/bollinger-band-rules", + "updated": 1615384340218 }, { "style": "Callout", diff --git a/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/HistoricOHLCVs.js b/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/HistoricOHLCVs.js index c331e30bf..1e6f79e12 100644 --- a/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/HistoricOHLCVs.js +++ b/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/HistoricOHLCVs.js @@ -237,7 +237,7 @@ exports.newSuperalgosBotModulesHistoricOHLCVs = function (processIndex) { } } if (mustLoadRawData) { // there is raw data to load - getRawDataArray() // so fetch it from the file wehere it was saved on the last run of this process + getRawDataArray() // so fetch it from the file where it was saved on the last run of this process } function getRawDataArray() { mustLoadRawData = false @@ -260,11 +260,8 @@ exports.newSuperalgosBotModulesHistoricOHLCVs = function (processIndex) { rawDataArray = JSON.parse(text); let dataLength = rawDataArray.length if (dataLength > 1) { - let lastData = rawDataArray[dataLength - 1] - let lastTimeStamp = lastData[0] - rawDataArray.pop() // ditch the last ohlcv since it may be incomplete - dataLength = rawDataArray.length - since = lastTimeStamp // we will now start again from the last full ohlvc we had (instead of the beginning of the day) + since = rawDataArray[dataLength - 2][0] // set the beginning of the fetch back to the start of the second last ohlcv received + rawDataArray.pop() // ditch the last ohlcv received since it may be incomplete } else { rawDataArrayFile = [] // we got less than two ohlcvs so we might as well start again from the beginning of the day } @@ -506,9 +503,9 @@ exports.newSuperalgosBotModulesHistoricOHLCVs = function (processIndex) { break // end of the market } else { if (ohlcvcArray.length > limit) { - break // get enough ohlcvs for this process loop + break // got enough ohlcvs for this process loop } else { - await new Promise(resolve => setTimeout(resolve, rateLimit)) // wait for exchanges rateLimit before requesting again + await new Promise(resolve => setTimeout(resolve, rateLimit)) // wait for exchange's rateLimit before requesting again } } } diff --git a/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/.eslintignore b/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/.eslintignore new file mode 100644 index 000000000..a007feab0 --- /dev/null +++ b/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/.eslintignore @@ -0,0 +1 @@ +build/* diff --git a/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/.gitattributes b/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/.gitattributes index 147ee79bf..513b2a256 100644 --- a/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/.gitattributes +++ b/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/.gitattributes @@ -1,4 +1,5 @@ *.* text eol=lf php/test/*.php linguist-generated=true +php/*.php linguist-generated=true python/ccxt/*.py linguist-generated=true python/ccxt/__init__.py linguist-generated=false diff --git a/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/CONTRIBUTING.md b/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/CONTRIBUTING.md index 5ce4a0405..1d3ff05d1 100644 --- a/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/CONTRIBUTING.md +++ b/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/CONTRIBUTING.md @@ -246,7 +246,7 @@ These files containing derived exchange classes are transpiled from JS into Pyth - `js/[_a-z].js` → `python/ccxt/async/[_a-z].py` - `python/ccxt/async[_a-z].py` → `python/ccxt/[_a-z].py` (Python 3 asyncio → Python 2 sync transpilation stage) -- `python/test/test_async.py` → `python/test/test.py` (the sync test is generated from the async test) +- `python/ccxt/test/test_async.py` → `python/ccxt/test/test_sync.py` (the sync test is generated from the async test) These Python base classes and files are not transpiled: @@ -868,14 +868,6 @@ npm run git-unignore-generated-files ## Financial Contributions We also welcome financial contributions in full transparency on our [open collective](https://opencollective.com/ccxt). -Anyone can file an expense. If the expense makes sense for the development of the community, it will be "merged" in the ledger of our open collective by the core contributors and the person who filed the expense will be reimbursed. - -``` -ETH 0x26a3CB49578F07000575405a57888681249c35Fd (ETH only!) -BTC 33RmVRfhK2WZVQR1R83h2e9yXoqRNDvJva -BCH 1GN9p233TvNcNQFthCgfiHUnj5JRKEc2Ze -LTC LbT8mkAqQBphc4yxLXEDgYDfEax74et3bP -``` ## Credits diff --git a/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/README.md b/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/README.md index ed47b610c..3f8dfeea4 100644 --- a/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/README.md +++ b/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/README.md @@ -1,11 +1,11 @@ # CCXT – CryptoCurrency eXchange Trading Library -[![Build Status](https://travis-ci.com/ccxt/ccxt.svg?branch=master)](https://travis-ci.com/ccxt/ccxt) [![npm](https://img.shields.io/npm/v/ccxt.svg)](https://npmjs.com/package/ccxt) [![PyPI](https://img.shields.io/pypi/v/ccxt.svg)](https://pypi.python.org/pypi/ccxt) [![NPM Downloads](https://img.shields.io/npm/dm/ccxt.svg)](https://www.npmjs.com/package/ccxt) [![Discord](https://img.shields.io/discord/690203284119617602?logo=discord&logoColor=white)](https://discord.gg/dhzSKYU) [![Supported Exchanges](https://img.shields.io/badge/exchanges-123-blue.svg)](https://github.com/ccxt/ccxt/wiki/Exchange-Markets) [![Open Collective](https://opencollective.com/ccxt/backers/badge.svg)](https://opencollective.com/ccxt) +[![Build Status](https://travis-ci.com/ccxt/ccxt.svg?branch=master)](https://travis-ci.com/ccxt/ccxt) [![npm](https://img.shields.io/npm/v/ccxt.svg)](https://npmjs.com/package/ccxt) [![PyPI](https://img.shields.io/pypi/v/ccxt.svg)](https://pypi.python.org/pypi/ccxt) [![NPM Downloads](https://img.shields.io/npm/dy/ccxt.svg)](https://www.npmjs.com/package/ccxt) [![Discord](https://img.shields.io/discord/690203284119617602?logo=discord&logoColor=white)](https://discord.gg/dhzSKYU) [![Supported Exchanges](https://img.shields.io/badge/exchanges-126-blue.svg)](https://github.com/ccxt/ccxt/wiki/Exchange-Markets) [![Open Collective](https://opencollective.com/ccxt/backers/badge.svg)](https://opencollective.com/ccxt) [![Twitter Follow](https://img.shields.io/twitter/follow/ccxt_official.svg?style=social&label=CCXT)](https://twitter.com/ccxt_official) A JavaScript / Python / PHP library for cryptocurrency trading and e-commerce with support for many bitcoin/ether/altcoin exchange markets and merchant APIs. -### [Install](#install) · [Usage](#usage) · [Manual](https://github.com/ccxt/ccxt/wiki) · [FAQ](https://github.com/ccxt/ccxt/wiki/FAQ) · [Examples](https://github.com/ccxt/ccxt/tree/master/examples) · [Contributing](https://github.com/ccxt/ccxt/blob/master/CONTRIBUTING.md) · [Social](#social) +### [Install](#install) · [Usage](#usage) · [Manual](https://github.com/ccxt/ccxt/wiki) · [FAQ](https://github.com/ccxt/ccxt/wiki/FAQ) · [Examples](https://github.com/ccxt/ccxt/tree/master/examples) · [Contributing](https://github.com/ccxt/ccxt/blob/master/CONTRIBUTING.md) · [Social](#social) · [CCXT Pro](https://ccxt.pro) The **CCXT** library is used to connect and trade with cryptocurrency exchanges and payment processing services worldwide. It provides quick access to market data for storage, analysis, visualization, indicator development, algorithmic trading, strategy backtesting, bot programming, and related software engineering. @@ -21,42 +21,44 @@ Current feature list: ## Sponsored Promotion -[![CCXT Pro – A JavaScript / Python / PHP cryptocurrency exchange trading WebSocket API for professionals](https://user-images.githubusercontent.com/1294454/93346896-22dfb080-f83d-11ea-957f-6b8ae008f62a.png)](https://ccxt.pro) **[A JavaScript / Python / PHP cryptocurrency exchange trading WebSocket API for professionals](https://ccxt.pro)** +[![CCXT Pro – A JavaScript / Python / PHP cryptocurrency exchange trading WebSocket API for professionals](https://user-images.githubusercontent.com/1294454/106092533-865ce180-613f-11eb-8d67-0830771fde32.png)](https://ccxt.pro) ## See Also - [![Quadency](https://user-images.githubusercontent.com/1294454/69334382-a0618100-0c6b-11ea-9ba9-40aa97440cfa.png)](https://quadency.com?utm_source=ccxt)  **[Quadency](https://quadency.com?utm_source=ccxt)** — trading automation terminal for leading exchanges with streaming APIs + Python IDE. - [![TabTrader](https://user-images.githubusercontent.com/1294454/66755907-9c3e8880-eea1-11e9-846e-0bff349ceb87.png)](https://tab-trader.com/?utm_source=ccxt)  **[TabTrader](https://tab-trader.com/?utm_source=ccxt)** — trading on all exchanges in one app. Avaliable on [Android](https://play.google.com/store/apps/details?id=com.tabtrader.android&referrer=utm_source%3Dccxt) and [iOS](https://itunes.apple.com/app/apple-store/id1095716562?mt=8). +- [![Pionex](https://user-images.githubusercontent.com/1294454/106112806-c2ec0580-615e-11eb-870c-0b7aef021db2.png)](https://www.pionex.com/en-US/sign?r=8wSFCbNk&utm_source=ad&utm_medium=banner&utm_campaign=ccxt-2)  **[Pionex](https://www.pionex.com/en-US/sign?r=8wSFCbNk&utm_source=ad&utm_medium=banner&utm_campaign=ccxt-2)** — 6 grid bots, spot-futures arb bot, smart trade and DCA bots. Free for [Android](https://play.google.com/store/apps/details?id=com.pionex.client&referrer=utm_source%3Dccxt) and [iOS](https://apps.apple.com/us/app/pionex/id1485348891?pt=ccxt&ct=inline)! +- [![AAX](https://user-images.githubusercontent.com/1294454/106509642-ef957980-64de-11eb-92e0-8323cda7874e.png)](https://www.aaxpro.com/en-US/ad-sign-up/?utm_source=ccxt&utm_medium=one-liner&utm_campaign=futures)  **[AAX](https://www.aaxpro.com/en-US/ad-sign-up/?utm_source=ccxt&utm_medium=one-liner&utm_campaign=futures)** — trade bitcoin futures with fees as low as 0.02% and up to 100x leverage! ## Certified Cryptocurrency Exchanges -| logo | id | name | ver | doc | certified | pro | -|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---------------|-----------------------------------------------------------------------------|:---:|:----------------------------------------------------------------------------------:|-----------------------------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------| -| [![binance](https://user-images.githubusercontent.com/1294454/29604020-d5483cdc-87ee-11e7-94c7-d1a8d9169293.jpg)](https://www.binance.com/?ref=10205187) | binance | [Binance](https://www.binance.com/?ref=10205187) | * | [API](https://binance-docs.github.io/apidocs/spot/en) | [![CCXT Certified](https://img.shields.io/badge/CCXT-Certified-green.svg)](https://github.com/ccxt/ccxt/wiki/Certification) | [![CCXT Pro](https://img.shields.io/badge/CCXT-Pro-black)](https://ccxt.pro) | -| [![bitfinex](https://user-images.githubusercontent.com/1294454/27766244-e328a50c-5ed2-11e7-947b-041416579bb3.jpg)](https://www.bitfinex.com/?refcode=P61eYxFL) | bitfinex | [Bitfinex](https://www.bitfinex.com/?refcode=P61eYxFL) | 1 | [API](https://docs.bitfinex.com/v1/docs) | [![CCXT Certified](https://img.shields.io/badge/CCXT-Certified-green.svg)](https://github.com/ccxt/ccxt/wiki/Certification) | [![CCXT Pro](https://img.shields.io/badge/CCXT-Pro-black)](https://ccxt.pro) | -| [![bittrex](https://user-images.githubusercontent.com/51840849/87153921-edf53180-c2c0-11ea-96b9-f2a9a95a455b.jpg)](https://bittrex.com/Account/Register?referralCode=1ZE-G0G-M3B) | bittrex | [Bittrex](https://bittrex.com/Account/Register?referralCode=1ZE-G0G-M3B) | 3 | [API](https://bittrex.github.io/api/v3) | [![CCXT Certified](https://img.shields.io/badge/CCXT-Certified-green.svg)](https://github.com/ccxt/ccxt/wiki/Certification) | [![CCXT Pro](https://img.shields.io/badge/CCXT-Pro-black)](https://ccxt.pro) | -| [![bitvavo](https://user-images.githubusercontent.com/1294454/83165440-2f1cf200-a116-11ea-9046-a255d09fb2ed.jpg)](https://bitvavo.com/?a=24F34952F7) | bitvavo | [Bitvavo](https://bitvavo.com/?a=24F34952F7) | 2 | [API](https://docs.bitvavo.com/) | [![CCXT Certified](https://img.shields.io/badge/CCXT-Certified-green.svg)](https://github.com/ccxt/ccxt/wiki/Certification) | [![CCXT Pro](https://img.shields.io/badge/CCXT-Pro-black)](https://ccxt.pro) | -| [![bytetrade](https://user-images.githubusercontent.com/1294454/67288762-2f04a600-f4e6-11e9-9fd6-c60641919491.jpg)](https://www.byte-trade.com) | bytetrade | [ByteTrade](https://www.byte-trade.com) | * | [API](https://docs.byte-trade.com/#description) | [![CCXT Certified](https://img.shields.io/badge/CCXT-Certified-green.svg)](https://github.com/ccxt/ccxt/wiki/Certification) | | -| [![currencycom](https://user-images.githubusercontent.com/1294454/83718672-36745c00-a63e-11ea-81a9-677b1f789a4d.jpg)](https://currency.com/trading/signup?c=362jaimv&pid=referral) | currencycom | [Currency.com](https://currency.com/trading/signup?c=362jaimv&pid=referral) | 1 | [API](https://currency.com/api) | [![CCXT Certified](https://img.shields.io/badge/CCXT-Certified-green.svg)](https://github.com/ccxt/ccxt/wiki/Certification) | [![CCXT Pro](https://img.shields.io/badge/CCXT-Pro-black)](https://ccxt.pro) | -| [![eterbase](https://user-images.githubusercontent.com/1294454/82067900-faeb0f80-96d9-11ea-9f22-0071cfcb9871.jpg)](https://eterbase.exchange/invite/1wjjh4Pe) | eterbase | [Eterbase](https://eterbase.exchange/invite/1wjjh4Pe) | 1 | [API](https://developers.eterbase.exchange) | [![CCXT Certified](https://img.shields.io/badge/CCXT-Certified-green.svg)](https://github.com/ccxt/ccxt/wiki/Certification) | | -| [![ftx](https://user-images.githubusercontent.com/1294454/67149189-df896480-f2b0-11e9-8816-41593e17f9ec.jpg)](https://ftx.com/#a=1623029) | ftx | [FTX](https://ftx.com/#a=1623029) | * | [API](https://github.com/ftexchange/ftx) | [![CCXT Certified](https://img.shields.io/badge/CCXT-Certified-green.svg)](https://github.com/ccxt/ccxt/wiki/Certification) | [![CCXT Pro](https://img.shields.io/badge/CCXT-Pro-black)](https://ccxt.pro) | -| [![idex](https://user-images.githubusercontent.com/51840849/94481303-2f222100-01e0-11eb-97dd-bc14c5943a86.jpg)](https://idex.io) | idex | [IDEX](https://idex.io) | 2 | [API](https://docs.idex.io/) | [![CCXT Certified](https://img.shields.io/badge/CCXT-Certified-green.svg)](https://github.com/ccxt/ccxt/wiki/Certification) | [![CCXT Pro](https://img.shields.io/badge/CCXT-Pro-black)](https://ccxt.pro) | -| [![kraken](https://user-images.githubusercontent.com/51840849/76173629-fc67fb00-61b1-11ea-84fe-f2de582f58a3.jpg)](https://www.kraken.com) | kraken | [Kraken](https://www.kraken.com) | 0 | [API](https://www.kraken.com/features/api) | [![CCXT Certified](https://img.shields.io/badge/CCXT-Certified-green.svg)](https://github.com/ccxt/ccxt/wiki/Certification) | [![CCXT Pro](https://img.shields.io/badge/CCXT-Pro-black)](https://ccxt.pro) | -| [![upbit](https://user-images.githubusercontent.com/1294454/49245610-eeaabe00-f423-11e8-9cba-4b0aed794799.jpg)](https://upbit.com) | upbit | [Upbit](https://upbit.com) | 1 | [API](https://docs.upbit.com/docs/%EC%9A%94%EC%B2%AD-%EC%88%98-%EC%A0%9C%ED%95%9C) | [![CCXT Certified](https://img.shields.io/badge/CCXT-Certified-green.svg)](https://github.com/ccxt/ccxt/wiki/Certification) | [![CCXT Pro](https://img.shields.io/badge/CCXT-Pro-black)](https://ccxt.pro) | -| [![wavesexchange](https://user-images.githubusercontent.com/1294454/84547058-5fb27d80-ad0b-11ea-8711-78ac8b3c7f31.jpg)](https://waves.exchange) | wavesexchange | [Waves.Exchange](https://waves.exchange) | * | [API](https://docs.waves.exchange) | [![CCXT Certified](https://img.shields.io/badge/CCXT-Certified-green.svg)](https://github.com/ccxt/ccxt/wiki/Certification) | | -| [![xena](https://user-images.githubusercontent.com/51840849/87489843-bb469280-c64c-11ea-91aa-69c6326506af.jpg)](https://xena.exchange) | xena | [Xena Exchange](https://xena.exchange) | * | [API](https://support.xena.exchange/support/solutions/44000808700) | [![CCXT Certified](https://img.shields.io/badge/CCXT-Certified-green.svg)](https://github.com/ccxt/ccxt/wiki/Certification) | | +| logo | id | name | ver | doc | certified | pro | +|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---------------|-----------------------------------------------------------------------------|:---:|:------------------------------------------------------------------:|-----------------------------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------| +| [![aax](https://user-images.githubusercontent.com/1294454/104140087-a27f2580-53c0-11eb-87c1-5d9e81208fe9.jpg)](https://www.aaxpro.com/invite/sign-up?inviteCode=JXGm5Fy7R2MB) | aax | [AAX](https://www.aaxpro.com/invite/sign-up?inviteCode=JXGm5Fy7R2MB) | 2 | [API](https://www.aaxpro.com/apidoc/index.html) | [![CCXT Certified](https://img.shields.io/badge/CCXT-Certified-green.svg)](https://github.com/ccxt/ccxt/wiki/Certification) | | +| [![binance](https://user-images.githubusercontent.com/1294454/29604020-d5483cdc-87ee-11e7-94c7-d1a8d9169293.jpg)](https://www.binance.com/?ref=10205187) | binance | [Binance](https://www.binance.com/?ref=10205187) | * | [API](https://binance-docs.github.io/apidocs/spot/en) | [![CCXT Certified](https://img.shields.io/badge/CCXT-Certified-green.svg)](https://github.com/ccxt/ccxt/wiki/Certification) | [![CCXT Pro](https://img.shields.io/badge/CCXT-Pro-black)](https://ccxt.pro) | +| [![bittrex](https://user-images.githubusercontent.com/51840849/87153921-edf53180-c2c0-11ea-96b9-f2a9a95a455b.jpg)](https://bittrex.com/Account/Register?referralCode=1ZE-G0G-M3B) | bittrex | [Bittrex](https://bittrex.com/Account/Register?referralCode=1ZE-G0G-M3B) | 3 | [API](https://bittrex.github.io/api/v3) | [![CCXT Certified](https://img.shields.io/badge/CCXT-Certified-green.svg)](https://github.com/ccxt/ccxt/wiki/Certification) | [![CCXT Pro](https://img.shields.io/badge/CCXT-Pro-black)](https://ccxt.pro) | +| [![bitvavo](https://user-images.githubusercontent.com/1294454/83165440-2f1cf200-a116-11ea-9046-a255d09fb2ed.jpg)](https://bitvavo.com/?a=24F34952F7) | bitvavo | [Bitvavo](https://bitvavo.com/?a=24F34952F7) | 2 | [API](https://docs.bitvavo.com/) | [![CCXT Certified](https://img.shields.io/badge/CCXT-Certified-green.svg)](https://github.com/ccxt/ccxt/wiki/Certification) | [![CCXT Pro](https://img.shields.io/badge/CCXT-Pro-black)](https://ccxt.pro) | +| [![bytetrade](https://user-images.githubusercontent.com/1294454/67288762-2f04a600-f4e6-11e9-9fd6-c60641919491.jpg)](https://www.byte-trade.com) | bytetrade | [ByteTrade](https://www.byte-trade.com) | * | [API](https://docs.byte-trade.com/#description) | [![CCXT Certified](https://img.shields.io/badge/CCXT-Certified-green.svg)](https://github.com/ccxt/ccxt/wiki/Certification) | | +| [![currencycom](https://user-images.githubusercontent.com/1294454/83718672-36745c00-a63e-11ea-81a9-677b1f789a4d.jpg)](https://currency.com/trading/signup?c=362jaimv&pid=referral) | currencycom | [Currency.com](https://currency.com/trading/signup?c=362jaimv&pid=referral) | 1 | [API](https://currency.com/api) | [![CCXT Certified](https://img.shields.io/badge/CCXT-Certified-green.svg)](https://github.com/ccxt/ccxt/wiki/Certification) | [![CCXT Pro](https://img.shields.io/badge/CCXT-Pro-black)](https://ccxt.pro) | +| [![eterbase](https://user-images.githubusercontent.com/1294454/82067900-faeb0f80-96d9-11ea-9f22-0071cfcb9871.jpg)](https://eterbase.exchange/invite/1wjjh4Pe) | eterbase | [Eterbase](https://eterbase.exchange/invite/1wjjh4Pe) | 1 | [API](https://developers.eterbase.exchange) | [![CCXT Certified](https://img.shields.io/badge/CCXT-Certified-green.svg)](https://github.com/ccxt/ccxt/wiki/Certification) | | +| [![ftx](https://user-images.githubusercontent.com/1294454/67149189-df896480-f2b0-11e9-8816-41593e17f9ec.jpg)](https://ftx.com/#a=1623029) | ftx | [FTX](https://ftx.com/#a=1623029) | * | [API](https://github.com/ftexchange/ftx) | [![CCXT Certified](https://img.shields.io/badge/CCXT-Certified-green.svg)](https://github.com/ccxt/ccxt/wiki/Certification) | [![CCXT Pro](https://img.shields.io/badge/CCXT-Pro-black)](https://ccxt.pro) | +| [![gopax](https://user-images.githubusercontent.com/1294454/102897212-ae8a5e00-4478-11eb-9bab-91507c643900.jpg)](https://www.gopax.co.kr) | gopax | [GOPAX](https://www.gopax.co.kr) | 1 | [API](https://gopax.github.io/API/index.en.html) | [![CCXT Certified](https://img.shields.io/badge/CCXT-Certified-green.svg)](https://github.com/ccxt/ccxt/wiki/Certification) | [![CCXT Pro](https://img.shields.io/badge/CCXT-Pro-black)](https://ccxt.pro) | +| [![idex](https://user-images.githubusercontent.com/51840849/94481303-2f222100-01e0-11eb-97dd-bc14c5943a86.jpg)](https://idex.io) | idex | [IDEX](https://idex.io) | 2 | [API](https://docs.idex.io/) | [![CCXT Certified](https://img.shields.io/badge/CCXT-Certified-green.svg)](https://github.com/ccxt/ccxt/wiki/Certification) | [![CCXT Pro](https://img.shields.io/badge/CCXT-Pro-black)](https://ccxt.pro) | +| [![kraken](https://user-images.githubusercontent.com/51840849/76173629-fc67fb00-61b1-11ea-84fe-f2de582f58a3.jpg)](https://www.kraken.com) | kraken | [Kraken](https://www.kraken.com) | 0 | [API](https://www.kraken.com/features/api) | [![CCXT Certified](https://img.shields.io/badge/CCXT-Certified-green.svg)](https://github.com/ccxt/ccxt/wiki/Certification) | [![CCXT Pro](https://img.shields.io/badge/CCXT-Pro-black)](https://ccxt.pro) | +| [![wavesexchange](https://user-images.githubusercontent.com/1294454/84547058-5fb27d80-ad0b-11ea-8711-78ac8b3c7f31.jpg)](https://waves.exchange) | wavesexchange | [Waves.Exchange](https://waves.exchange) | * | [API](https://docs.waves.exchange) | [![CCXT Certified](https://img.shields.io/badge/CCXT-Certified-green.svg)](https://github.com/ccxt/ccxt/wiki/Certification) | | +| [![xena](https://user-images.githubusercontent.com/51840849/87489843-bb469280-c64c-11ea-91aa-69c6326506af.jpg)](https://xena.exchange) | xena | [Xena Exchange](https://xena.exchange) | * | [API](https://support.xena.exchange/support/solutions/44000808700) | [![CCXT Certified](https://img.shields.io/badge/CCXT-Certified-green.svg)](https://github.com/ccxt/ccxt/wiki/Certification) | | ## Supported Cryptocurrency Exchange Markets -The CCXT library currently supports the following 123 cryptocurrency exchange markets and trading APIs: +The CCXT library currently supports the following 126 cryptocurrency exchange markets and trading APIs: | logo | id | name | ver | doc | certified | pro | |--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|--------------------|-----------------------------------------------------------------------------------------|:---:|:-------------------------------------------------------------------------------------------:|-----------------------------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------| +| [![aax](https://user-images.githubusercontent.com/1294454/104140087-a27f2580-53c0-11eb-87c1-5d9e81208fe9.jpg)](https://www.aaxpro.com/invite/sign-up?inviteCode=JXGm5Fy7R2MB) | aax | [AAX](https://www.aaxpro.com/invite/sign-up?inviteCode=JXGm5Fy7R2MB) | 2 | [API](https://www.aaxpro.com/apidoc/index.html) | [![CCXT Certified](https://img.shields.io/badge/CCXT-Certified-green.svg)](https://github.com/ccxt/ccxt/wiki/Certification) | | | [![acx](https://user-images.githubusercontent.com/1294454/30247614-1fe61c74-9621-11e7-9e8c-f1a627afa279.jpg)](https://acx.io) | acx | [ACX](https://acx.io) | 2 | [API](https://acx.io/documents/api_v2) | | | | [![aofex](https://user-images.githubusercontent.com/51840849/77670271-056d1080-6f97-11ea-9ac2-4268e9ed0c1f.jpg)](https://aofex.com/#/register?key=9763840) | aofex | [AOFEX](https://aofex.com/#/register?key=9763840) | * | [API](https://aofex.zendesk.com/hc/en-us/sections/360005576574-API) | | | -| [![bcex](https://user-images.githubusercontent.com/51840849/77231516-851c6900-6bac-11ea-8fd6-ee5c23eddbd4.jpg)](https://www.bcex.top/register?invite_code=758978&lang=en) | bcex | [BCEX](https://www.bcex.top/register?invite_code=758978&lang=en) | 1 | [API](https://github.com/BCEX-TECHNOLOGY-LIMITED/API_Docs/wiki/Interface) | | | | [![bequant](https://user-images.githubusercontent.com/1294454/55248342-a75dfe00-525a-11e9-8aa2-05e9dca943c6.jpg)](https://bequant.io) | bequant | [Bequant](https://bequant.io) | 2 | [API](https://api.bequant.io/) | | [![CCXT Pro](https://img.shields.io/badge/CCXT-Pro-black)](https://ccxt.pro) | | [![bibox](https://user-images.githubusercontent.com/51840849/77257418-3262b000-6c85-11ea-8fb8-20bdf20b3592.jpg)](https://w2.bibox365.com/login/register?invite_code=05Kj3I) | bibox | [Bibox](https://w2.bibox365.com/login/register?invite_code=05Kj3I) | 1 | [API](https://biboxcom.github.io/en/) | | | | [![bigone](https://user-images.githubusercontent.com/1294454/69354403-1d532180-0c91-11ea-88ed-44c06cefdf87.jpg)](https://b1.run/users/new?code=D3LLBVFT) | bigone | [BigONE](https://b1.run/users/new?code=D3LLBVFT) | 3 | [API](https://open.big.one/docs/api.html) | | | @@ -66,14 +68,14 @@ The CCXT library currently supports the following 123 cryptocurrency exchange ma | [![bitbank](https://user-images.githubusercontent.com/1294454/37808081-b87f2d9c-2e59-11e8-894d-c1900b7584fe.jpg)](https://bitbank.cc/) | bitbank | [bitbank](https://bitbank.cc/) | 1 | [API](https://docs.bitbank.cc/) | | | | [![bitbay](https://user-images.githubusercontent.com/1294454/27766132-978a7bd8-5ece-11e7-9540-bc96d1e9bbb8.jpg)](https://auth.bitbay.net/ref/jHlbB4mIkdS1) | bitbay | [BitBay](https://auth.bitbay.net/ref/jHlbB4mIkdS1) | * | [API](https://bitbay.net/public-api) | | | | [![bitcoincom](https://user-images.githubusercontent.com/1294454/97296144-514fa300-1861-11eb-952b-3d55d492200b.jpg)](https://exchange.bitcoin.com/referral/da948b21d6c92d69) | bitcoincom | [bitcoin.com](https://exchange.bitcoin.com/referral/da948b21d6c92d69) | 2 | [API](https://api.exchange.bitcoin.com/api/2/explore) | | [![CCXT Pro](https://img.shields.io/badge/CCXT-Pro-black)](https://ccxt.pro) | -| [![bitfinex](https://user-images.githubusercontent.com/1294454/27766244-e328a50c-5ed2-11e7-947b-041416579bb3.jpg)](https://www.bitfinex.com/?refcode=P61eYxFL) | bitfinex | [Bitfinex](https://www.bitfinex.com/?refcode=P61eYxFL) | 1 | [API](https://docs.bitfinex.com/v1/docs) | [![CCXT Certified](https://img.shields.io/badge/CCXT-Certified-green.svg)](https://github.com/ccxt/ccxt/wiki/Certification) | [![CCXT Pro](https://img.shields.io/badge/CCXT-Pro-black)](https://ccxt.pro) | +| [![bitfinex](https://user-images.githubusercontent.com/1294454/27766244-e328a50c-5ed2-11e7-947b-041416579bb3.jpg)](https://www.bitfinex.com/?refcode=P61eYxFL) | bitfinex | [Bitfinex](https://www.bitfinex.com/?refcode=P61eYxFL) | 1 | [API](https://docs.bitfinex.com/v1/docs) | | [![CCXT Pro](https://img.shields.io/badge/CCXT-Pro-black)](https://ccxt.pro) | | [![bitfinex2](https://user-images.githubusercontent.com/1294454/27766244-e328a50c-5ed2-11e7-947b-041416579bb3.jpg)](https://www.bitfinex.com/?refcode=P61eYxFL) | bitfinex2 | [Bitfinex](https://www.bitfinex.com/?refcode=P61eYxFL) | 2 | [API](https://docs.bitfinex.com/v2/docs/) | | | | [![bitflyer](https://user-images.githubusercontent.com/1294454/28051642-56154182-660e-11e7-9b0d-6042d1e6edd8.jpg)](https://bitflyer.com) | bitflyer | [bitFlyer](https://bitflyer.com) | 1 | [API](https://lightning.bitflyer.com/docs?lang=en) | | | | [![bitforex](https://user-images.githubusercontent.com/51840849/87295553-1160ec00-c50e-11ea-8ea0-df79276a9646.jpg)](https://www.bitforex.com/en/invitationRegister?inviterId=1867438) | bitforex | [Bitforex](https://www.bitforex.com/en/invitationRegister?inviterId=1867438) | 1 | [API](https://github.com/githubdev2020/API_Doc_en/wiki) | | | | [![bitget](https://user-images.githubusercontent.com/51840849/88317935-a8a21c80-cd22-11ea-8e2b-4b9fac5975eb.jpg)](https://www.bitget.com/expressly?languageType=0&channelCode=ccxt&vipCode=tg9j) | bitget | [Bitget](https://www.bitget.com/expressly?languageType=0&channelCode=ccxt&vipCode=tg9j) | 3 | [API](https://bitgetlimited.github.io/apidoc/en/swap) | | | | [![bithumb](https://user-images.githubusercontent.com/1294454/30597177-ea800172-9d5e-11e7-804c-b9d4fa9b56b0.jpg)](https://www.bithumb.com) | bithumb | [Bithumb](https://www.bithumb.com) | * | [API](https://apidocs.bithumb.com) | | | | [![bitkk](https://user-images.githubusercontent.com/1294454/32859187-cd5214f0-ca5e-11e7-967d-96568e2e2bd1.jpg)](https://www.bitkk.com) | bitkk | [bitkk](https://www.bitkk.com) | 1 | [API](https://www.bitkk.com/i/developer) | | | -| [![bitmart](https://user-images.githubusercontent.com/1294454/61835713-a2662f80-ae85-11e9-9d00-6442919701fd.jpg)](http://www.bitmart.com/?r=rQCFLh) | bitmart | [BitMart](http://www.bitmart.com/?r=rQCFLh) | 1 | [API](https://github.com/bitmartexchange/bitmart-official-api-docs) | | | +| [![bitmart](https://user-images.githubusercontent.com/1294454/61835713-a2662f80-ae85-11e9-9d00-6442919701fd.jpg)](http://www.bitmart.com/?r=rQCFLh) | bitmart | [BitMart](http://www.bitmart.com/?r=rQCFLh) | 1 | [API](https://developer-pro.bitmart.com/) | | | | [![bitmax](https://user-images.githubusercontent.com/1294454/66820319-19710880-ef49-11e9-8fbe-16be62a11992.jpg)](https://bitmax.io/#/register?inviteCode=EL6BXBQM) | bitmax | [BitMax](https://bitmax.io/#/register?inviteCode=EL6BXBQM) | 1 | [API](https://bitmax-exchange.github.io/bitmax-pro-api/#bitmax-pro-api-documentation) | | | | [![bitmex](https://user-images.githubusercontent.com/1294454/27766319-f653c6e6-5ed4-11e7-933d-f0bc3699ae8f.jpg)](https://www.bitmex.com/register/upZpOX) | bitmex | [BitMEX](https://www.bitmex.com/register/upZpOX) | 1 | [API](https://www.bitmex.com/app/apiOverview) | | [![CCXT Pro](https://img.shields.io/badge/CCXT-Pro-black)](https://ccxt.pro) | | [![bitpanda](https://user-images.githubusercontent.com/51840849/87591171-9a377d80-c6f0-11ea-94ac-97a126eac3bc.jpg)](https://www.bitpanda.com/en/pro) | bitpanda | [Bitpanda Pro](https://www.bitpanda.com/en/pro) | 1 | [API](https://developers.bitpanda.com/exchange/) | | | @@ -95,6 +97,7 @@ The CCXT library currently supports the following 123 cryptocurrency exchange ma | [![bw](https://user-images.githubusercontent.com/1294454/69436317-31128c80-0d52-11ea-91d1-eb7bb5818812.jpg)](https://www.bw.com/regGetCommission/N3JuT1R3bWxKTE0) | bw | [BW](https://www.bw.com/regGetCommission/N3JuT1R3bWxKTE0) | 1 | [API](https://github.com/bw-exchange/api_docs_en/wiki) | | | | [![bybit](https://user-images.githubusercontent.com/51840849/76547799-daff5b80-649e-11ea-87fb-3be9bac08954.jpg)](https://www.bybit.com/app/register?ref=X7Prm) | bybit | [Bybit](https://www.bybit.com/app/register?ref=X7Prm) | 2 | [API](https://bybit-exchange.github.io/docs/inverse/) | | | | [![bytetrade](https://user-images.githubusercontent.com/1294454/67288762-2f04a600-f4e6-11e9-9fd6-c60641919491.jpg)](https://www.byte-trade.com) | bytetrade | [ByteTrade](https://www.byte-trade.com) | * | [API](https://docs.byte-trade.com/#description) | [![CCXT Certified](https://img.shields.io/badge/CCXT-Certified-green.svg)](https://github.com/ccxt/ccxt/wiki/Certification) | | +| [![cdax](https://user-images.githubusercontent.com/1294454/102157692-fd406280-3e90-11eb-8d46-4511b617cd17.jpg)](https://cdax.io/invite?invite_code=esc74) | cdax | [CDAX](https://cdax.io/invite?invite_code=esc74) | 1 | [API](https://github.com/cloudapidoc/API_Docs) | | | | [![cex](https://user-images.githubusercontent.com/1294454/27766442-8ddc33b0-5ed8-11e7-8b98-f786aef0f3c9.jpg)](https://cex.io/r/0/up105393824/0/) | cex | [CEX.IO](https://cex.io/r/0/up105393824/0/) | * | [API](https://cex.io/cex-api) | | | | [![chilebit](https://user-images.githubusercontent.com/1294454/27991414-1298f0d8-647f-11e7-9c40-d56409266336.jpg)](https://chilebit.net) | chilebit | [ChileBit](https://chilebit.net) | 1 | [API](https://blinktrade.com/docs) | | | | [![coinbase](https://user-images.githubusercontent.com/1294454/40811661-b6eceae2-653a-11e8-829e-10bfadb078cf.jpg)](https://www.coinbase.com/join/58cbe25a355148797479dbd2) | coinbase | [Coinbase](https://www.coinbase.com/join/58cbe25a355148797479dbd2) | 2 | [API](https://developers.coinbase.com/api/v2) | | | @@ -112,9 +115,11 @@ The CCXT library currently supports the following 123 cryptocurrency exchange ma | [![coinspot](https://user-images.githubusercontent.com/1294454/28208429-3cacdf9a-6896-11e7-854e-4c79a772a30f.jpg)](https://www.coinspot.com.au/register?code=PJURCU) | coinspot | [CoinSpot](https://www.coinspot.com.au/register?code=PJURCU) | * | [API](https://www.coinspot.com.au/api) | | | | [![crex24](https://user-images.githubusercontent.com/1294454/47813922-6f12cc00-dd5d-11e8-97c6-70f957712d47.jpg)](https://crex24.com/?refid=slxsjsjtil8xexl9hksr) | crex24 | [CREX24](https://crex24.com/?refid=slxsjsjtil8xexl9hksr) | 2 | [API](https://docs.crex24.com/trade-api/v2) | | | | [![currencycom](https://user-images.githubusercontent.com/1294454/83718672-36745c00-a63e-11ea-81a9-677b1f789a4d.jpg)](https://currency.com/trading/signup?c=362jaimv&pid=referral) | currencycom | [Currency.com](https://currency.com/trading/signup?c=362jaimv&pid=referral) | 1 | [API](https://currency.com/api) | [![CCXT Certified](https://img.shields.io/badge/CCXT-Certified-green.svg)](https://github.com/ccxt/ccxt/wiki/Certification) | [![CCXT Pro](https://img.shields.io/badge/CCXT-Pro-black)](https://ccxt.pro) | +| [![delta](https://user-images.githubusercontent.com/1294454/99450025-3be60a00-2931-11eb-9302-f4fd8d8589aa.jpg)](https://www.delta.exchange/app/signup/?code=IULYNB) | delta | [Delta Exchange](https://www.delta.exchange/app/signup/?code=IULYNB) | 2 | [API](https://docs.delta.exchange) | | | | [![deribit](https://user-images.githubusercontent.com/1294454/41933112-9e2dd65a-798b-11e8-8440-5bab2959fcb8.jpg)](https://www.deribit.com/reg-1189.4038) | deribit | [Deribit](https://www.deribit.com/reg-1189.4038) | 2 | [API](https://docs.deribit.com/v2) | | | | [![digifinex](https://user-images.githubusercontent.com/51840849/87443315-01283a00-c5fe-11ea-8628-c2a0feaf07ac.jpg)](https://www.digifinex.com/en-ww/from/DhOzBg?channelCode=ljaUPp) | digifinex | [DigiFinex](https://www.digifinex.com/en-ww/from/DhOzBg?channelCode=ljaUPp) | 3 | [API](https://docs.digifinex.com) | | | | [![dsx](https://user-images.githubusercontent.com/51840849/76909626-cb2bb100-68bc-11ea-99e0-28ba54f04792.jpg)](https://dsxglobal.com) | dsx | [DSX](https://dsxglobal.com) | 3 | [API](https://dsxglobal.com/developers/publicApi) | | | +| [![equos](https://user-images.githubusercontent.com/1294454/107758499-05edd180-6d38-11eb-9e09-0b69602a7a15.jpg)](https://equos.io?referredByCode=zpa8kij4ouvBFup3) | equos | [EQUOS](https://equos.io?referredByCode=zpa8kij4ouvBFup3) | * | [API](https://developer.equos.io) | | | | [![eterbase](https://user-images.githubusercontent.com/1294454/82067900-faeb0f80-96d9-11ea-9f22-0071cfcb9871.jpg)](https://eterbase.exchange/invite/1wjjh4Pe) | eterbase | [Eterbase](https://eterbase.exchange/invite/1wjjh4Pe) | 1 | [API](https://developers.eterbase.exchange) | [![CCXT Certified](https://img.shields.io/badge/CCXT-Certified-green.svg)](https://github.com/ccxt/ccxt/wiki/Certification) | | | [![exmo](https://user-images.githubusercontent.com/1294454/27766491-1b0ea956-5eda-11e7-9225-40d67b481b8d.jpg)](https://exmo.me/?ref=131685) | exmo | [EXMO](https://exmo.me/?ref=131685) | 1.1 | [API](https://exmo.me/en/api_doc?ref=131685) | | | | [![exx](https://user-images.githubusercontent.com/1294454/37770292-fbf613d0-2de4-11e8-9f79-f2dc451b8ccb.jpg)](https://www.exx.com/r/fde4260159e53ab8a58cc9186d35501f?recommQd=1) | exx | [EXX](https://www.exx.com/r/fde4260159e53ab8a58cc9186d35501f?recommQd=1) | * | [API](https://www.exx.com/help/restApi) | | | @@ -125,12 +130,12 @@ The CCXT library currently supports the following 123 cryptocurrency exchange ma | [![ftx](https://user-images.githubusercontent.com/1294454/67149189-df896480-f2b0-11e9-8816-41593e17f9ec.jpg)](https://ftx.com/#a=1623029) | ftx | [FTX](https://ftx.com/#a=1623029) | * | [API](https://github.com/ftexchange/ftx) | [![CCXT Certified](https://img.shields.io/badge/CCXT-Certified-green.svg)](https://github.com/ccxt/ccxt/wiki/Certification) | [![CCXT Pro](https://img.shields.io/badge/CCXT-Pro-black)](https://ccxt.pro) | | [![gateio](https://user-images.githubusercontent.com/1294454/31784029-0313c702-b509-11e7-9ccc-bc0da6a0e435.jpg)](https://www.gate.io/signup/2436035) | gateio | [Gate.io](https://www.gate.io/signup/2436035) | 2 | [API](https://gate.io/api2) | | [![CCXT Pro](https://img.shields.io/badge/CCXT-Pro-black)](https://ccxt.pro) | | [![gemini](https://user-images.githubusercontent.com/1294454/27816857-ce7be644-6096-11e7-82d6-3c257263229c.jpg)](https://gemini.com/) | gemini | [Gemini](https://gemini.com/) | 1 | [API](https://docs.gemini.com/rest-api) | | | +| [![gopax](https://user-images.githubusercontent.com/1294454/102897212-ae8a5e00-4478-11eb-9bab-91507c643900.jpg)](https://www.gopax.co.kr) | gopax | [GOPAX](https://www.gopax.co.kr) | 1 | [API](https://gopax.github.io/API/index.en.html) | [![CCXT Certified](https://img.shields.io/badge/CCXT-Certified-green.svg)](https://github.com/ccxt/ccxt/wiki/Certification) | [![CCXT Pro](https://img.shields.io/badge/CCXT-Pro-black)](https://ccxt.pro) | | [![hbtc](https://user-images.githubusercontent.com/51840849/80134449-70663300-85a7-11ea-8942-e204cdeaab5d.jpg)](https://www.hbtc.com/register/O2S8NS) | hbtc | [HBTC](https://www.hbtc.com/register/O2S8NS) | 1 | [API](https://github.com/bhexopen/BHEX-OpenApi/tree/master/doc) | | | | [![hitbtc](https://user-images.githubusercontent.com/1294454/27766555-8eaec20e-5edc-11e7-9c5b-6dc69fc42f5e.jpg)](https://hitbtc.com/?ref_id=5a5d39a65d466) | hitbtc | [HitBTC](https://hitbtc.com/?ref_id=5a5d39a65d466) | 2 | [API](https://api.hitbtc.com) | | [![CCXT Pro](https://img.shields.io/badge/CCXT-Pro-black)](https://ccxt.pro) | | [![hollaex](https://user-images.githubusercontent.com/1294454/75841031-ca375180-5ddd-11ea-8417-b975674c23cb.jpg)](https://pro.hollaex.com/signup?affiliation_code=QSWA6G) | hollaex | [HollaEx](https://pro.hollaex.com/signup?affiliation_code=QSWA6G) | 1 | [API](https://apidocs.hollaex.com) | | | | [![huobijp](https://user-images.githubusercontent.com/1294454/85734211-85755480-b705-11ea-8b35-0b7f1db33a2f.jpg)](https://www.huobi.co.jp/register/?invite_code=znnq3) | huobijp | [Huobi Japan](https://www.huobi.co.jp/register/?invite_code=znnq3) | 1 | [API](https://api-doc.huobi.co.jp) | | [![CCXT Pro](https://img.shields.io/badge/CCXT-Pro-black)](https://ccxt.pro) | | [![huobipro](https://user-images.githubusercontent.com/1294454/76137448-22748a80-604e-11ea-8069-6e389271911d.jpg)](https://www.huobi.com/en-us/topic/invited/?invite_code=rwrd3) | huobipro | [Huobi Pro](https://www.huobi.com/en-us/topic/invited/?invite_code=rwrd3) | 1 | [API](https://huobiapi.github.io/docs/spot/v1/cn/) | | [![CCXT Pro](https://img.shields.io/badge/CCXT-Pro-black)](https://ccxt.pro) | -| [![huobiru](https://user-images.githubusercontent.com/1294454/52978816-e8552e00-33e3-11e9-98ed-845acfece834.jpg)](https://www.huobi.com.ru/invite?invite_code=esc74) | huobiru | [Huobi Russia](https://www.huobi.com.ru/invite?invite_code=esc74) | 1 | [API](https://github.com/cloudapidoc/API_Docs_en) | | [![CCXT Pro](https://img.shields.io/badge/CCXT-Pro-black)](https://ccxt.pro) | | [![ice3x](https://user-images.githubusercontent.com/51840849/87460809-1dd06c00-c616-11ea-98ad-7d5e1cb7fcdd.jpg)](https://ice3x.com?ref=14341802) | ice3x | [ICE3X](https://ice3x.com?ref=14341802) | 1 | [API](https://ice3x.co.za/ice-cubed-bitcoin-exchange-api-documentation-1-june-2017) | | | | [![idex](https://user-images.githubusercontent.com/51840849/94481303-2f222100-01e0-11eb-97dd-bc14c5943a86.jpg)](https://idex.io) | idex | [IDEX](https://idex.io) | 2 | [API](https://docs.idex.io/) | [![CCXT Certified](https://img.shields.io/badge/CCXT-Certified-green.svg)](https://github.com/ccxt/ccxt/wiki/Certification) | [![CCXT Pro](https://img.shields.io/badge/CCXT-Pro-black)](https://ccxt.pro) | | [![independentreserve](https://user-images.githubusercontent.com/51840849/87182090-1e9e9080-c2ec-11ea-8e49-563db9a38f37.jpg)](https://www.independentreserve.com) | independentreserve | [Independent Reserve](https://www.independentreserve.com) | * | [API](https://www.independentreserve.com/API) | | | @@ -143,11 +148,11 @@ The CCXT library currently supports the following 123 cryptocurrency exchange ma | [![latoken](https://user-images.githubusercontent.com/1294454/61511972-24c39f00-aa01-11e9-9f7c-471f1d6e5214.jpg)](https://latoken.com) | latoken | [Latoken](https://latoken.com) | 1 | [API](https://api.latoken.com) | | | | [![lbank](https://user-images.githubusercontent.com/1294454/38063602-9605e28a-3302-11e8-81be-64b1e53c4cfb.jpg)](https://www.lbex.io/invite?icode=7QCY) | lbank | [LBank](https://www.lbex.io/invite?icode=7QCY) | 1 | [API](https://github.com/LBank-exchange/lbank-official-api-docs) | | | | [![liquid](https://user-images.githubusercontent.com/1294454/45798859-1a872600-bcb4-11e8-8746-69291ce87b04.jpg)](https://www.liquid.com/sign-up/?affiliate=SbzC62lt30976) | liquid | [Liquid](https://www.liquid.com/sign-up/?affiliate=SbzC62lt30976) | 2 | [API](https://developers.liquid.com) | | | -| [![livecoin](https://user-images.githubusercontent.com/1294454/27980768-f22fc424-638a-11e7-89c9-6010a54ff9be.jpg)](https://livecoin.net/?from=Livecoin-CQ1hfx44) | livecoin | [LiveCoin](https://livecoin.net/?from=Livecoin-CQ1hfx44) | * | [API](https://www.livecoin.net/api?lang=en) | | | | [![luno](https://user-images.githubusercontent.com/1294454/27766607-8c1a69d8-5ede-11e7-930c-540b5eb9be24.jpg)](https://www.luno.com/invite/44893A) | luno | [luno](https://www.luno.com/invite/44893A) | 1 | [API](https://www.luno.com/en/api) | | | | [![lykke](https://user-images.githubusercontent.com/1294454/34487620-3139a7b0-efe6-11e7-90f5-e520cef74451.jpg)](https://www.lykke.com) | lykke | [Lykke](https://www.lykke.com) | 1 | [API](https://hft-api.lykke.com/swagger/ui/) | | | | [![mercado](https://user-images.githubusercontent.com/1294454/27837060-e7c58714-60ea-11e7-9192-f05e86adb83f.jpg)](https://www.mercadobitcoin.com.br) | mercado | [Mercado Bitcoin](https://www.mercadobitcoin.com.br) | 3 | [API](https://www.mercadobitcoin.com.br/api-doc) | | | | [![mixcoins](https://user-images.githubusercontent.com/51840849/87460810-1dd06c00-c616-11ea-9276-956f400d6ffa.jpg)](https://mixcoins.com) | mixcoins | [MixCoins](https://mixcoins.com) | 1 | [API](https://mixcoins.com/help/api/) | | | +| [![ndax](https://user-images.githubusercontent.com/1294454/108623144-67a3ef00-744e-11eb-8140-75c6b851e945.jpg)](https://one.ndax.io/bfQiSL) | ndax | [NDAX](https://one.ndax.io/bfQiSL) | * | [API](https://apidoc.ndax.io/) | | [![CCXT Pro](https://img.shields.io/badge/CCXT-Pro-black)](https://ccxt.pro) | | [![novadax](https://user-images.githubusercontent.com/1294454/92337550-2b085500-f0b3-11ea-98e7-5794fb07dd3b.jpg)](https://www.novadax.com.br/?s=ccxt) | novadax | [NovaDAX](https://www.novadax.com.br/?s=ccxt) | 1 | [API](https://doc.novadax.com/pt-BR/) | | | | [![oceanex](https://user-images.githubusercontent.com/1294454/58385970-794e2d80-8001-11e9-889c-0567cd79b78e.jpg)](https://oceanex.pro/signup?referral=VE24QX) | oceanex | [OceanEx](https://oceanex.pro/signup?referral=VE24QX) | 1 | [API](https://api.oceanex.pro/doc/v1) | | | | [![okcoin](https://user-images.githubusercontent.com/51840849/87295551-102fbf00-c50e-11ea-90a9-462eebba5829.jpg)](https://www.okcoin.com/account/register?flag=activity&channelId=600001513) | okcoin | [OKCoin](https://www.okcoin.com/account/register?flag=activity&channelId=600001513) | 3 | [API](https://www.okcoin.com/docs/en/) | | [![CCXT Pro](https://img.shields.io/badge/CCXT-Pro-black)](https://ccxt.pro) | @@ -166,7 +171,7 @@ The CCXT library currently supports the following 123 cryptocurrency exchange ma | [![tidebit](https://user-images.githubusercontent.com/51840849/87460811-1e690280-c616-11ea-8652-69f187305add.jpg)](http://bit.ly/2IX0LrM) | tidebit | [TideBit](http://bit.ly/2IX0LrM) | 2 | [API](https://www.tidebit.com/documents/api/guide) | | | | [![tidex](https://user-images.githubusercontent.com/1294454/30781780-03149dc4-a12e-11e7-82bb-313b269d24d4.jpg)](https://tidex.com/exchange/?ref=57f5638d9cd7) | tidex | [Tidex](https://tidex.com/exchange/?ref=57f5638d9cd7) | 3 | [API](https://tidex.com/exchange/public-api) | | | | [![timex](https://user-images.githubusercontent.com/1294454/70423869-6839ab00-1a7f-11ea-8f94-13ae72c31115.jpg)](https://timex.io/?refcode=1x27vNkTbP1uwkCck) | timex | [TimeX](https://timex.io/?refcode=1x27vNkTbP1uwkCck) | 1 | [API](https://docs.timex.io) | | | -| [![upbit](https://user-images.githubusercontent.com/1294454/49245610-eeaabe00-f423-11e8-9cba-4b0aed794799.jpg)](https://upbit.com) | upbit | [Upbit](https://upbit.com) | 1 | [API](https://docs.upbit.com/docs/%EC%9A%94%EC%B2%AD-%EC%88%98-%EC%A0%9C%ED%95%9C) | [![CCXT Certified](https://img.shields.io/badge/CCXT-Certified-green.svg)](https://github.com/ccxt/ccxt/wiki/Certification) | [![CCXT Pro](https://img.shields.io/badge/CCXT-Pro-black)](https://ccxt.pro) | +| [![upbit](https://user-images.githubusercontent.com/1294454/49245610-eeaabe00-f423-11e8-9cba-4b0aed794799.jpg)](https://upbit.com) | upbit | [Upbit](https://upbit.com) | 1 | [API](https://docs.upbit.com/docs/%EC%9A%94%EC%B2%AD-%EC%88%98-%EC%A0%9C%ED%95%9C) | | [![CCXT Pro](https://img.shields.io/badge/CCXT-Pro-black)](https://ccxt.pro) | | [![vaultoro](https://user-images.githubusercontent.com/1294454/27766880-f205e870-5ee9-11e7-8fe2-0d5b15880752.jpg)](https://www.vaultoro.com) | vaultoro | [Vaultoro](https://www.vaultoro.com) | 1 | [API](https://api.vaultoro.com) | | | | [![vbtc](https://user-images.githubusercontent.com/1294454/27991481-1f53d1d8-6481-11e7-884e-21d17e7939db.jpg)](https://vbtc.exchange) | vbtc | [VBTC](https://vbtc.exchange) | 1 | [API](https://blinktrade.com/docs) | | | | [![vcc](https://user-images.githubusercontent.com/1294454/100545356-8427f500-326c-11eb-9539-7d338242d61b.jpg)](https://vcc.exchange?ref=l4xhrH) | vcc | [VCC Exchange](https://vcc.exchange?ref=l4xhrH) | 3 | [API](https://vcc.exchange/api) | | | @@ -224,13 +229,13 @@ console.log (ccxt.exchanges) // print all available exchanges All-in-one browser bundle (dependencies included), served from a CDN of your choice: -* jsDelivr: https://cdn.jsdelivr.net/npm/ccxt@1.38.76/dist/ccxt.browser.js -* unpkg: https://unpkg.com/ccxt@1.38.76/dist/ccxt.browser.js +* jsDelivr: https://cdn.jsdelivr.net/npm/ccxt@1.42.77/dist/ccxt.browser.js +* unpkg: https://unpkg.com/ccxt@1.42.77/dist/ccxt.browser.js CDNs are not updated in real-time and may have delays. Defaulting to the most recent version without specifying the version number is not recommended. Please, keep in mind that we are not responsible for the correct operation of those CDN servers. ```HTML - + ``` Creates a global `ccxt` object: @@ -275,6 +280,8 @@ include "ccxt.php"; var_dump (\ccxt\Exchange::$exchanges); // print a list of all available exchange classes ``` +The library supports concurrent asynchronous mode using tools from [RecoilPHP](https://github.com/recoilphp/recoil) and [ReactPHP](https://reactphp.org/) in PHP 7.1+. Read the [Manual](https://github.com/ccxt/ccxt/wiki) for more details. + ### Docker You can get CCXT installed in a container along with all the supported languages and dependencies. This may be useful if you want to contribute to CCXT (e.g. run the build scripts and tests — please see the [Contributing](https://github.com/ccxt/ccxt/blob/master/CONTRIBUTING.md) document for the details on that). @@ -529,15 +536,6 @@ Thank you to all our backers! [[Become a backer](https://opencollective.com/ccxt -### Crypto - -``` -ETH 0x26a3CB49578F07000575405a57888681249c35Fd (ETH only) -BTC 33RmVRfhK2WZVQR1R83h2e9yXoqRNDvJva -BCH 1GN9p233TvNcNQFthCgfiHUnj5JRKEc2Ze -LTC LgM5hkvPzytEFfQGGDFGKYkE743jwUA7qv -``` - Thank you! ## Social diff --git a/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/build/transpile.js b/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/build/transpile.js index 0f4d1dcc6..948a34c0f 100644 --- a/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/build/transpile.js +++ b/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/build/transpile.js @@ -274,6 +274,7 @@ class Transpiler { [ /(?<=[^\s#]) \]/g, ']' ], // PEP8 E202 remove whitespaces before right ] square bracket [ /(?<=[^\s#]) \}/g, '}' ], // PEP8 E202 remove whitespaces before right } bracket [ /([^a-z])(elif|if|or|else)\(/g, '$1$2 \(' ], // a correction for PEP8 E225 side-effect for compound and ternary conditionals + [ /\!\=\sTrue/g, 'is not True' ], // a correction for PEP8 E712, it likes "is not True", not "!= True" [ /\=\=\sTrue/g, 'is True' ], // a correction for PEP8 E712, it likes "is True", not "== True" [ /\sdelete\s/g, ' del ' ], [ /(?\=]+(\<=|\>=|<|>)\s*(.*)\s*\;([^\)]+)\)\s*{/g, 'for ($1 = $2; $1 $3 $4;$5) {' ], [ /([^\s]+)\.length\;/g, 'is_array($1) ? count($1) : 0;' ], [ /\.push\s*\(([\s\S]+?)\)\;/g, '[] = $1;' ], - [ /(\s)await(\s)/g, '$1' ], + [ /(\b)await(\b)/g, 'yield' ], [ /([\S])\: /g, '$1 => ' ], // add {}-array syntax conversions up to 20 levels deep @@ -441,7 +448,7 @@ class Transpiler { "import os", "import sys", "", - "root = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))", + "root = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))", "sys.path.append(root)", "", "# ----------------------------------------------------------------------------", @@ -598,11 +605,11 @@ class Transpiler { return 'class ' + className + ' extends ' + baseClass + ' {' } - createPHPClassHeader (className, baseClass, bodyAsString) { + createPHPClassHeader (className, baseClass, bodyAsString, namespace) { return [ " sync PHP + let phpBody = this.transpileAsyncPHPToSyncPHP (phpAsyncBody) + + return { python3Body, python2Body, phpBody, phpAsyncBody } } //----------------------------------------------------------------------------- transpilePythonAsyncToSync () { - const async = './python/test/test_async.py' - const sync = './python/test/test.py' + const async = './python/ccxt/test/test_async.py' + const sync = './python/ccxt/test/test_sync.py' log.magenta ('Transpiling ' + async .yellow + ' → ' + sync.yellow) const fileContents = fs.readFileSync (async, 'utf8') let lines = fileContents.split ("\n") lines = lines.filter (line => ![ 'import asyncio' ].includes (line)) - .map (line => { - return ( - line.replace ('asyncio.get_event_loop().run_until_complete(main())', 'main()') - .replace ('import ccxt.async_support as ccxt', 'import ccxt') - .replace (/.*token\_bucket.*/g, '') - .replace ('await asyncio.sleep', 'time.sleep') - .replace ('async ', '') - .replace ('await ', '')) - }) + .map (line => { + return ( + line.replace ('asyncio.get_event_loop().run_until_complete(main())', 'main()') + .replace ('import ccxt.async_support as ccxt', 'import ccxt') + .replace (/.*token\_bucket.*/g, '') + .replace ('await asyncio.sleep', 'time.sleep') + .replace ('async ', '') + .replace ('await ', '')) + }) // lines.forEach (line => log (line)) @@ -803,22 +822,47 @@ class Transpiler { fs.writeFileSync (sync, newContents) } + //----------------------------------------------------------------------------- + + transpilePhpAsyncToSync () { + + const async = './php/test/test_async.php' + const sync = './php/test/test_sync.php' + log.magenta ('Transpiling ' + async .yellow + ' → ' + sync.yellow) + const fileContents = fs.readFileSync (async, 'utf8') + const syncBody = this.transpileAsyncPHPToSyncPHP (fileContents) + + const phpSyncRegexes = [ + [ /\$kernel->execute\(\$main\)/, '\$main()' ], + [ /\$kernel->run\(\);\n/, '' ], + [ /\$kernel = async\\Exchange::get_kernel\(\);\n/, '' ], + [ /ccxt\\\\async/, 'ccxt' ], + ] + + const newContents = this.regexAll (syncBody, phpSyncRegexes) + + fs.truncateSync (sync) + fs.writeFileSync (sync, newContents) + } + + // ------------------------------------------------------------------------ + + getExchangeClassDeclarationMatches (contents) { + return contents.match (/^module\.exports\s*=\s*class\s+([\S]+)\s+extends\s+([\S]+)\s+{([\s\S]+?)^};*/m) + } + // ------------------------------------------------------------------------ transpileDerivedExchangeClass (contents, methodNames = undefined) { - let exchangeClassDeclarationMatches = contents.match (/^module\.exports\s*=\s*class\s+([\S]+)\s+extends\s+([\S]+)\s+{([\s\S]+?)^};*/m) + const [ _, className, baseClass, methodMatches ] = this.getExchangeClassDeclarationMatches (contents) - // log.green (file, exchangeClassDeclarationMatches[3]) - - let className = exchangeClassDeclarationMatches[1] - let baseClass = exchangeClassDeclarationMatches[2] - - let methods = exchangeClassDeclarationMatches[3].trim ().split (/\n\s*\n/) + const methods = methodMatches.trim ().split (/\n\s*\n/) let python2 = [] let python3 = [] let php = [] + let phpAsync = [] methodNames = [] // methodNames || [] @@ -838,14 +882,6 @@ class Transpiler { // async or not let keyword = matches[1] - // try { - // keyword = matches[1] - // } catch (e) { - // log.red (e) - // log.green (methods[i]) - // log.yellow (exchangeClassDeclarationMatches[3].trim ().split (/\n\s*\n/)) - // process.exit () - // } // method name let method = matches[2] @@ -869,17 +905,17 @@ class Transpiler { // remove excessive spacing from argument defaults in Python method signature let pythonArgs = args.map (x => x.replace (' = ', '=')) - .join (', ') - .replace (/undefined/g, 'None') - .replace (/false/g, 'False') - .replace (/true/g, 'True') + .join (', ') + .replace (/undefined/g, 'None') + .replace (/false/g, 'False') + .replace (/true/g, 'True') // method body without the signature (first line) // and without the closing bracket (last line) let js = lines.slice (1, -1).join ("\n") // transpile everything - let { python3Body, python2Body, phpBody } = this.transpileJavaScriptToPythonAndPHP ({ js, className, variables, removeEmptyLines: true }) + let { python3Body, python2Body, phpBody, phpAsyncBody } = this.transpileJavaScriptToPythonAndPHP ({ js, className, variables, removeEmptyLines: true }) // compile the final Python code for the method signature let pythonString = 'def ' + method + '(self' + (pythonArgs.length ? ', ' + pythonArgs : '') + '):' @@ -900,14 +936,19 @@ class Transpiler { php.push (phpBody); php.push (' }') + phpAsync.push (''); + phpAsync.push (' public function ' + method + '(' + phpArgs + ') {'); + phpAsync.push (phpAsyncBody); + phpAsync.push (' }') } return { - // altogether in PHP, Python 2 and 3 (async) - python2: this.createPythonClass (className, baseClass, python2, methodNames), - python3: this.createPythonClass (className, baseClass, python3, methodNames, true), - php: this.createPHPClass (className, baseClass, php, methodNames), + // altogether in PHP, async PHP, Python 2 and 3 (async) + python2: this.createPythonClass (className, baseClass, python2, methodNames), + python3: this.createPythonClass (className, baseClass, python3, methodNames, true), + php: this.createPHPClass (className, baseClass, php, methodNames), + phpAsync: this.createPHPClass (className, baseClass, phpAsync, methodNames, true), className, baseClass, @@ -916,46 +957,58 @@ class Transpiler { // ======================================================================== - transpileDerivedExchangeFile (jsFolder, filename, options) { + transpileDerivedExchangeFile (jsFolder, filename, options, force = false) { // todo normalize jsFolder and other arguments try { - const { python2Folder, python3Folder, phpFolder } = options - const path = jsFolder + filename - const contents = fs.readFileSync (path, 'utf8') + const { python2Folder, python3Folder, phpFolder, phpAsyncFolder } = options + const pythonFilename = filename.replace ('.js', '.py') + const phpFilename = filename.replace ('.js', '.php') - // function getMethodNames (object) { - // let functions = [] - // let o = object - // do { - // functions = functions.concat (Object.getOwnPropertyNames (o)) - // } while (o = Object.getPrototypeOf (o)) - // return unique (functions.filter (f => (typeof object[f] === 'function'))) - // } - // const exchangeClass = require ('.' + path) - // const exchange = new exchangeClass () - // const methodNames = getMethodNames (exchange) - // const { python2, python3, php, className, baseClass } = - // this.transpileDerivedExchangeClass (contents, methodNames) + const jsMtime = fs.statSync (jsFolder + filename).mtime.getTime () - const { python2, python3, php, className, baseClass } = - this.transpileDerivedExchangeClass (contents) + const python2Path = python2Folder ? (python2Folder + pythonFilename) : undefined + const python3Path = python3Folder ? (python3Folder + pythonFilename) : undefined + const phpPath = phpFolder ? (phpFolder + phpFilename) : undefined + const phpAsyncPath = phpAsyncFolder ? (phpAsyncFolder + phpFilename) : undefined - log.cyan ('Transpiling from', filename.yellow) + const python2Mtime = python2Folder ? (fs.existsSync (python2Path) ? fs.statSync (python2Path).mtime.getTime () : 0) : undefined + const python3Mtime = python3Path ? (fs.existsSync (python3Path) ? fs.statSync (python3Path).mtime.getTime () : 0) : undefined + const phpAsyncMtime = phpAsyncFolder ? (fs.existsSync (phpAsyncPath) ? fs.statSync (phpAsyncPath).mtime.getTime () : 0) : undefined + const phpMtime = phpPath ? (fs.existsSync (phpPath) ? fs.statSync (phpPath).mtime.getTime () : 0) : undefined - ;[ - [ python2Folder, filename.replace ('.js', '.py'), python2 ], - [ python3Folder, filename.replace ('.js', '.py'), python3 ], - [ phpFolder, filename.replace ('.js', '.php'), php ], - ].forEach (([ folder, filename, code ]) => { - if (folder) { - overwriteFile (folder + filename, code) - } - }) + const contents = fs.readFileSync (jsFolder + filename, 'utf8') - return { className, baseClass } + if (force || + (python3Folder && (jsMtime > python3Mtime)) || + (phpFolder && (jsMtime > phpMtime)) || + (phpAsyncFolder && (jsMtime > phpAsyncMtime)) || + (python2Folder && (jsMtime > python2Mtime))) { + const { python2, python3, php, phpAsync, className, baseClass } = this.transpileDerivedExchangeClass (contents) + log.cyan ('Transpiling from', filename.yellow) + + ;[ + [ python2Folder, pythonFilename, python2 ], + [ python3Folder, pythonFilename, python3 ], + [ phpFolder, phpFilename, php ], + [ phpAsyncFolder, phpFilename, phpAsync ], + ].forEach (([ folder, filename, code ]) => { + if (folder) { + overwriteFile (folder + filename, code) + fs.utimesSync (folder + filename, new Date (), new Date (jsMtime)) + } + }) + + return { className, baseClass } + + } else { + + const [ _, className, baseClass ] = this.getExchangeClassDeclarationMatches (contents) + log.green ('Already transpiled', filename.yellow) + return { className, baseClass } + } } catch (e) { @@ -967,11 +1020,11 @@ class Transpiler { //------------------------------------------------------------------------- - transpileDerivedExchangeFiles (jsFolder, options, pattern = '.js') { + transpileDerivedExchangeFiles (jsFolder, options, pattern = '.js', force = false) { // todo normalize jsFolder and other arguments - const { python2Folder, python3Folder, phpFolder } = options + const { python2Folder, python3Folder, phpFolder, phpAsyncFolder } = options // exchanges.json accounts for ids included in exchanges.cfg let ids = undefined @@ -984,7 +1037,7 @@ class Transpiler { const classNames = fs.readdirSync (jsFolder) .filter (file => file.match (regex) && (!ids || ids.includes (basename (file, '.js')))) - .map (file => this.transpileDerivedExchangeFile (jsFolder, file, options)) + .map (file => this.transpileDerivedExchangeFile (jsFolder, file, options, force)) const classes = {} @@ -1013,6 +1066,7 @@ class Transpiler { [ python2Folder, /\.pyc?$/ ], [ python3Folder, /\.pyc?$/ ], [ phpFolder, /\.php$/ ], + [ phpAsyncFolder, /\.php$/ ], ].forEach (([ folder, pattern ]) => { if (folder) { deleteOldTranspiledFiles (folder, pattern) @@ -1026,19 +1080,37 @@ class Transpiler { // ======================================================================== - exportTypeScriptDeclarations (file, classes) { + exportTypeScriptClassNames (file, classes) { - log.bright.cyan ('Exporting TypeScript declarations →', file.yellow) + log.bright.cyan ('Exporting TypeScript class names →', file.yellow) const regex = /\/[\n]{2}(?: export class [^\s]+ extends [^\s]+ \{\}[\r]?[\n])+/ const replacement = "/\n\n" + Object.keys (classes).map (className => { - const baseClass = classes[className] + const baseClass = classes[className].replace (/ccxt\.[a-z_]+/, 'Exchange') return ' export class ' + className + ' extends ' + baseClass + " {}" }).join ("\n") + "\n" replaceInFile (file, regex, replacement) } + exportTypeScriptExchangeIds (file, classes) { + + log.bright.cyan ('Exporting TypeScript exchange ids →', file.yellow) + + const regex = /\/[\n]{2} export type ExchangeId =\n(?: \| \'[a-z0-9_]+\'[\r]?[\n])+/ + const replacement = "/\n\n export type ExchangeId =\n" + Object.keys (classes).map (className => { + return " | '" + className + "'" + }).join ("\n") + "\n" + + replaceInFile (file, regex, replacement) + } + + exportTypeScriptDeclarations (file, classes) { + + this.exportTypeScriptClassNames (file, classes) + this.exportTypeScriptExchangeIds (file, classes) + } + // ======================================================================== transpileErrorHierarchy () { @@ -1092,7 +1164,7 @@ class Transpiler { const quote = (s) => "'" + s + "'" // helper to add quotes around class names - const pythonExports = [ 'error_hierarchy' ] + const pythonExports = [ 'error_hierarchy', 'BaseError' ] const pythonErrors = intellisense (root, 'BaseError', pythonDeclareErrorClass, pythonExports) const pythonAll = '__all__ = [\n ' + pythonExports.map (quote).join (',\n ') + '\n]' @@ -1157,7 +1229,7 @@ class Transpiler { transpileDateTimeTests () { const jsFile = './js/test/base/functions/test.datetime.js' - const pyFile = './python/test/test_exchange_datetime_functions.py' + const pyFile = './python/ccxt/test/test_exchange_datetime_functions.py' const phpFile = './php/test/test_exchange_datetime_functions.php' log.magenta ('Transpiling from', jsFile.yellow) @@ -1169,7 +1241,7 @@ class Transpiler { [/^\/\*.*\s+/mg, ''], ]) - let { python3Body, python2Body, phpBody } = this.transpileJavaScriptToPythonAndPHP ({ js, removeEmptyLines: false }) + let { python3Body, python2Body, phpBody, phpAsyncBody } = this.transpileJavaScriptToPythonAndPHP ({ js, removeEmptyLines: false }) // phpBody = phpBody.replace (/exchange\./g, 'Exchange::') @@ -1198,7 +1270,7 @@ class Transpiler { transpilePrecisionTests () { const jsFile = './js/test/base/functions/test.number.js' - const pyFile = './python/test/test_decimal_to_precision.py' + const pyFile = './python/ccxt/test/test_decimal_to_precision.py' const phpFile = './php/test/decimal_to_precision.php' log.magenta ('Transpiling from', jsFile.yellow) @@ -1212,7 +1284,7 @@ class Transpiler { [ /numberToString/g, 'number_to_string' ], ]) - let { python3Body, python2Body, phpBody } = this.transpileJavaScriptToPythonAndPHP ({ js, removeEmptyLines: false }) + let { python3Body, python2Body, phpBody, phpAsyncBody } = this.transpileJavaScriptToPythonAndPHP ({ js, removeEmptyLines: false }) const pythonHeader = [ "", @@ -1283,7 +1355,7 @@ class Transpiler { transpileCryptoTests () { const jsFile = './js/test/base/functions/test.crypto.js' - const pyFile = './python/test/test_crypto.py' + const pyFile = './python/ccxt/test/test_crypto.py' const phpFile = './php/test/test_crypto.php' log.magenta ('Transpiling from', jsFile.yellow) @@ -1295,7 +1367,7 @@ class Transpiler { [ /function equals \([\S\s]+?return true\n}\n/g, '' ], ]) - let { python3Body, python2Body, phpBody } = this.transpileJavaScriptToPythonAndPHP ({ js, removeEmptyLines: false }) + let { python3Body, python2Body, phpBody, phpAsyncBody } = this.transpileJavaScriptToPythonAndPHP ({ js, removeEmptyLines: false }) const pythonHeader = [ "", @@ -1352,22 +1424,22 @@ class Transpiler { const tests = [ { 'jsFile': './js/test/Exchange/test.trade.js', - 'pyFile': './python/test/test_trade.py', + 'pyFile': './python/ccxt/test/test_trade.py', 'phpFile': './php/test/test_trade.php', }, { 'jsFile': './js/test/Exchange/test.order.js', - 'pyFile': './python/test/test_order.py', + 'pyFile': './python/ccxt/test/test_order.py', 'phpFile': './php/test/test_order.php', }, { 'jsFile': './js/test/Exchange/test.transaction.js', - 'pyFile': './python/test/test_transaction.py', + 'pyFile': './python/ccxt/test/test_transaction.py', 'phpFile': './php/test/test_transaction.php', }, { 'jsFile': './js/test/Exchange/test.ohlcv.js', - 'pyFile': './python/test/test_ohlcv.py', + 'pyFile': './python/ccxt/test/test_ohlcv.py', 'phpFile': './php/test/test_ohlcv.php', }, ] @@ -1389,7 +1461,6 @@ class Transpiler { ]) const pythonHeader = [ - '', 'import numbers # noqa: E402', 'try:', ' basestring # basestring was removed in Python 3', @@ -1400,7 +1471,7 @@ class Transpiler { ].join('\n') let { python3Body, python2Body, phpBody } = this.transpileJavaScriptToPythonAndPHP ({ js, removeEmptyLines: false }) - const python = this.getPythonPreamble () + pythonHeader + python3Body; + const python = pythonHeader + python3Body; const php = this.getPHPPreamble (false) + phpBody; log.magenta ('→', test.pyFile.yellow) @@ -1423,22 +1494,53 @@ class Transpiler { // ============================================================================ - transpileEverything () { + transpilePhpBaseClassMethods () { + const baseMethods = this.getPHPBaseMethods () + const indent = 4 + const space = ' '.repeat (indent) + const result = [ + 'public static $camelcase_methods = array(', + ] + for (const method of baseMethods) { + const underscoreCase = unCamelCase (method) + if (underscoreCase !== method) { + result.push (space.repeat (2) + '\'' + method + '\' => ' + '\'' + underscoreCase + '\',') + } + } + result.push (space + ');') + const string = result.join ('\n') + + const phpBaseClass = './php/base/Exchange.php'; + const phpBody = fs.readFileSync (phpBaseClass, 'utf8') + const regex = /public static \$camelcase_methods = array\([\s\S]+?\);/g + const bodyArray = phpBody.split (regex) + + const newBody = bodyArray[0] + string + bodyArray[1] + + log.magenta ('Transpiling from ', phpBaseClass.yellow, '→', phpBaseClass.yellow) + overwriteFile (phpBaseClass, newBody) + } + + // ============================================================================ + + transpileEverything (force = false) { // default pattern is '.js' - const [ /* node */, /* script */, pattern ] = process.argv - , python2Folder = './python/ccxt/' - , python3Folder = './python/ccxt/async_support/' - , phpFolder = './php/' - , options = { python2Folder, python3Folder, phpFolder } + const [ /* node */, /* script */, pattern ] = process.argv.filter (x => !x.startsWith ('--')) + , python2Folder = './python/ccxt/' + , python3Folder = './python/ccxt/async_support/' + , phpFolder = './php/' + , phpAsyncFolder = './php/async/' + , options = { python2Folder, python3Folder, phpFolder, phpAsyncFolder } createFolderRecursively (python2Folder) createFolderRecursively (python3Folder) createFolderRecursively (phpFolder) + createFolderRecursively (phpAsyncFolder) //* - const classes = this.transpileDerivedExchangeFiles ('./js/', options, pattern) + const classes = this.transpileDerivedExchangeFiles ('./js/', options, pattern, force) if (classes === null) { log.bright.yellow ('0 files transpiled.') @@ -1457,6 +1559,10 @@ class Transpiler { this.transpilePythonAsyncToSync () + this.transpilePhpAsyncToSync () + + this.transpilePhpBaseClassMethods () + log.bright.green ('Transpiled successfully.') } } @@ -1469,12 +1575,14 @@ if (require.main === module) { // called directly like `node module` const transpiler = new Transpiler () const test = process.argv.includes ('--test') || process.argv.includes ('--tests') const errors = process.argv.includes ('--error') || process.argv.includes ('--errors') + const force = process.argv.includes ('--force') + log.bright.green ({ force }) if (test) { transpiler.transpileTests () } else if (errors) { transpiler.transpileErrorHierarchy () } else { - transpiler.transpileEverything () + transpiler.transpileEverything (force) } } else { // if required as a module diff --git a/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/build/vss.js b/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/build/vss.js index 24db17ce1..0d98e3c07 100644 --- a/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/build/vss.js +++ b/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/build/vss.js @@ -52,6 +52,8 @@ function vssEverything () { vss ('./ccxt.js', "const version = '{version}'", version) vss ('./php/base/Exchange.php', "$version = '{version}'", version) + vss ('./php/async/base/Exchange.php', "VERSION = '{version}'", version) + vss ('./php/async/base/Exchange.php', "$version = '{version}'", version) vss ('./php/base/Exchange.php', "VERSION = '{version}'", version) vss ('./python/ccxt/__init__.py', "__version__ = '{version}'", version) vss ('./python/ccxt/base/exchange.py', "__version__ = '{version}'", version) diff --git a/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/ccxt.d.ts b/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/ccxt.d.ts index eae728f4c..823f7825b 100644 --- a/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/ccxt.d.ts +++ b/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/ccxt.d.ts @@ -56,16 +56,21 @@ declare module 'ccxt' { symbol: string; base: string; quote: string; - baseId: string, - quoteId: string, + baseId: string; + quoteId: string; + type?: string; + spot?: boolean; + margin?: boolean; + swap?: boolean; + future?: boolean; active: boolean; precision: { base: number, quote: number, amount: number, price: number }; limits: { amount: MinMax, price: MinMax, cost?: MinMax }; - tierBased: boolean, - percentage: boolean, - taker: number, - maker: number, - info: any, + tierBased: boolean; + percentage: boolean; + taker: number; + maker: number; + info: any; } export interface Order { @@ -417,9 +422,9 @@ declare module 'ccxt' { /* tslint:disable */ + export class aax extends Exchange {} export class acx extends Exchange {} export class aofex extends Exchange {} - export class bcex extends Exchange {} export class bequant extends hitbtc {} export class bibox extends Exchange {} export class bigone extends Exchange {} @@ -458,6 +463,7 @@ declare module 'ccxt' { export class bw extends Exchange {} export class bybit extends Exchange {} export class bytetrade extends Exchange {} + export class cdax extends huobipro {} export class cex extends Exchange {} export class chilebit extends foxbit {} export class coinbase extends Exchange {} @@ -475,9 +481,11 @@ declare module 'ccxt' { export class coinspot extends Exchange {} export class crex24 extends Exchange {} export class currencycom extends Exchange {} + export class delta extends Exchange {} export class deribit extends Exchange {} export class digifinex extends Exchange {} export class dsx extends Exchange {} + export class equos extends Exchange {} export class eterbase extends Exchange {} export class exmo extends Exchange {} export class exx extends Exchange {} @@ -488,12 +496,12 @@ declare module 'ccxt' { export class ftx extends Exchange {} export class gateio extends Exchange {} export class gemini extends Exchange {} + export class gopax extends Exchange {} export class hbtc extends Exchange {} export class hitbtc extends Exchange {} export class hollaex extends Exchange {} export class huobijp extends huobipro {} export class huobipro extends Exchange {} - export class huobiru extends huobipro {} export class ice3x extends Exchange {} export class idex extends Exchange {} export class independentreserve extends Exchange {} @@ -506,11 +514,11 @@ declare module 'ccxt' { export class latoken extends Exchange {} export class lbank extends Exchange {} export class liquid extends Exchange {} - export class livecoin extends Exchange {} export class luno extends Exchange {} export class lykke extends Exchange {} export class mercado extends Exchange {} export class mixcoins extends Exchange {} + export class ndax extends Exchange {} export class novadax extends Exchange {} export class oceanex extends Exchange {} export class okcoin extends okex {} @@ -543,4 +551,132 @@ declare module 'ccxt' { /* tslint:enable */ + export type ExchangeId = + | 'aax' + | 'acx' + | 'aofex' + | 'bequant' + | 'bibox' + | 'bigone' + | 'binance' + | 'binanceus' + | 'bit2c' + | 'bitbank' + | 'bitbay' + | 'bitcoincom' + | 'bitfinex' + | 'bitfinex2' + | 'bitflyer' + | 'bitforex' + | 'bitget' + | 'bithumb' + | 'bitkk' + | 'bitmart' + | 'bitmax' + | 'bitmex' + | 'bitpanda' + | 'bitso' + | 'bitstamp' + | 'bitstamp1' + | 'bittrex' + | 'bitvavo' + | 'bitz' + | 'bl3p' + | 'bleutrade' + | 'braziliex' + | 'btcalpha' + | 'btcbox' + | 'btcmarkets' + | 'btctradeua' + | 'btcturk' + | 'buda' + | 'bw' + | 'bybit' + | 'bytetrade' + | 'cdax' + | 'cex' + | 'chilebit' + | 'coinbase' + | 'coinbaseprime' + | 'coinbasepro' + | 'coincheck' + | 'coinegg' + | 'coinex' + | 'coinfalcon' + | 'coinfloor' + | 'coingi' + | 'coinmarketcap' + | 'coinmate' + | 'coinone' + | 'coinspot' + | 'crex24' + | 'currencycom' + | 'delta' + | 'deribit' + | 'digifinex' + | 'dsx' + | 'equos' + | 'eterbase' + | 'exmo' + | 'exx' + | 'fcoin' + | 'fcoinjp' + | 'flowbtc' + | 'foxbit' + | 'ftx' + | 'gateio' + | 'gemini' + | 'gopax' + | 'hbtc' + | 'hitbtc' + | 'hollaex' + | 'huobijp' + | 'huobipro' + | 'ice3x' + | 'idex' + | 'independentreserve' + | 'indodax' + | 'itbit' + | 'kraken' + | 'kucoin' + | 'kuna' + | 'lakebtc' + | 'latoken' + | 'lbank' + | 'liquid' + | 'luno' + | 'lykke' + | 'mercado' + | 'mixcoins' + | 'ndax' + | 'novadax' + | 'oceanex' + | 'okcoin' + | 'okex' + | 'paymium' + | 'phemex' + | 'poloniex' + | 'probit' + | 'qtrade' + | 'rightbtc' + | 'ripio' + | 'southxchange' + | 'stex' + | 'surbitcoin' + | 'therock' + | 'tidebit' + | 'tidex' + | 'timex' + | 'upbit' + | 'vaultoro' + | 'vbtc' + | 'vcc' + | 'wavesexchange' + | 'whitebit' + | 'xbtce' + | 'xena' + | 'yobit' + | 'zaif' + | 'zb' + } diff --git a/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/ccxt.js b/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/ccxt.js index 20640ac7b..1d5c72642 100644 --- a/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/ccxt.js +++ b/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/ccxt.js @@ -35,16 +35,16 @@ const Exchange = require ('./js/base/Exchange') //----------------------------------------------------------------------------- // this is updated by vss.js when building -const version = '1.38.76' +const version = '1.42.77' Exchange.ccxtVersion = version //----------------------------------------------------------------------------- const exchanges = { + 'aax': require ('./js/aax.js'), 'acx': require ('./js/acx.js'), 'aofex': require ('./js/aofex.js'), - 'bcex': require ('./js/bcex.js'), 'bequant': require ('./js/bequant.js'), 'bibox': require ('./js/bibox.js'), 'bigone': require ('./js/bigone.js'), @@ -83,6 +83,7 @@ const exchanges = { 'bw': require ('./js/bw.js'), 'bybit': require ('./js/bybit.js'), 'bytetrade': require ('./js/bytetrade.js'), + 'cdax': require ('./js/cdax.js'), 'cex': require ('./js/cex.js'), 'chilebit': require ('./js/chilebit.js'), 'coinbase': require ('./js/coinbase.js'), @@ -100,9 +101,11 @@ const exchanges = { 'coinspot': require ('./js/coinspot.js'), 'crex24': require ('./js/crex24.js'), 'currencycom': require ('./js/currencycom.js'), + 'delta': require ('./js/delta.js'), 'deribit': require ('./js/deribit.js'), 'digifinex': require ('./js/digifinex.js'), 'dsx': require ('./js/dsx.js'), + 'equos': require ('./js/equos.js'), 'eterbase': require ('./js/eterbase.js'), 'exmo': require ('./js/exmo.js'), 'exx': require ('./js/exx.js'), @@ -113,12 +116,12 @@ const exchanges = { 'ftx': require ('./js/ftx.js'), 'gateio': require ('./js/gateio.js'), 'gemini': require ('./js/gemini.js'), + 'gopax': require ('./js/gopax.js'), 'hbtc': require ('./js/hbtc.js'), 'hitbtc': require ('./js/hitbtc.js'), 'hollaex': require ('./js/hollaex.js'), 'huobijp': require ('./js/huobijp.js'), 'huobipro': require ('./js/huobipro.js'), - 'huobiru': require ('./js/huobiru.js'), 'ice3x': require ('./js/ice3x.js'), 'idex': require ('./js/idex.js'), 'independentreserve': require ('./js/independentreserve.js'), @@ -131,11 +134,11 @@ const exchanges = { 'latoken': require ('./js/latoken.js'), 'lbank': require ('./js/lbank.js'), 'liquid': require ('./js/liquid.js'), - 'livecoin': require ('./js/livecoin.js'), 'luno': require ('./js/luno.js'), 'lykke': require ('./js/lykke.js'), 'mercado': require ('./js/mercado.js'), 'mixcoins': require ('./js/mixcoins.js'), + 'ndax': require ('./js/ndax.js'), 'novadax': require ('./js/novadax.js'), 'oceanex': require ('./js/oceanex.js'), 'okcoin': require ('./js/okcoin.js'), diff --git a/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/cleanup.sh b/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/cleanup.sh new file mode 100644 index 000000000..0dc60ed78 --- /dev/null +++ b/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/cleanup.sh @@ -0,0 +1,2 @@ +#!/bin/bash +git checkout HEAD package.json README.md ccxt.d.ts ccxt.js wiki python php dist doc diff --git a/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/dist/ccxt.browser.js b/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/dist/ccxt.browser.js index 7dff379a3..e8b439fb1 100644 --- a/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/dist/ccxt.browser.js +++ b/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/dist/ccxt.browser.js @@ -43,16 +43,16 @@ const Exchange = require ('./js/base/Exchange') //----------------------------------------------------------------------------- // this is updated by vss.js when building -const version = '1.38.76' +const version = '1.42.77' Exchange.ccxtVersion = version //----------------------------------------------------------------------------- const exchanges = { + 'aax': require ('./js/aax.js'), 'acx': require ('./js/acx.js'), 'aofex': require ('./js/aofex.js'), - 'bcex': require ('./js/bcex.js'), 'bequant': require ('./js/bequant.js'), 'bibox': require ('./js/bibox.js'), 'bigone': require ('./js/bigone.js'), @@ -91,6 +91,7 @@ const exchanges = { 'bw': require ('./js/bw.js'), 'bybit': require ('./js/bybit.js'), 'bytetrade': require ('./js/bytetrade.js'), + 'cdax': require ('./js/cdax.js'), 'cex': require ('./js/cex.js'), 'chilebit': require ('./js/chilebit.js'), 'coinbase': require ('./js/coinbase.js'), @@ -108,9 +109,11 @@ const exchanges = { 'coinspot': require ('./js/coinspot.js'), 'crex24': require ('./js/crex24.js'), 'currencycom': require ('./js/currencycom.js'), + 'delta': require ('./js/delta.js'), 'deribit': require ('./js/deribit.js'), 'digifinex': require ('./js/digifinex.js'), 'dsx': require ('./js/dsx.js'), + 'equos': require ('./js/equos.js'), 'eterbase': require ('./js/eterbase.js'), 'exmo': require ('./js/exmo.js'), 'exx': require ('./js/exx.js'), @@ -121,12 +124,12 @@ const exchanges = { 'ftx': require ('./js/ftx.js'), 'gateio': require ('./js/gateio.js'), 'gemini': require ('./js/gemini.js'), + 'gopax': require ('./js/gopax.js'), 'hbtc': require ('./js/hbtc.js'), 'hitbtc': require ('./js/hitbtc.js'), 'hollaex': require ('./js/hollaex.js'), 'huobijp': require ('./js/huobijp.js'), 'huobipro': require ('./js/huobipro.js'), - 'huobiru': require ('./js/huobiru.js'), 'ice3x': require ('./js/ice3x.js'), 'idex': require ('./js/idex.js'), 'independentreserve': require ('./js/independentreserve.js'), @@ -139,11 +142,11 @@ const exchanges = { 'latoken': require ('./js/latoken.js'), 'lbank': require ('./js/lbank.js'), 'liquid': require ('./js/liquid.js'), - 'livecoin': require ('./js/livecoin.js'), 'luno': require ('./js/luno.js'), 'lykke': require ('./js/lykke.js'), 'mercado': require ('./js/mercado.js'), 'mixcoins': require ('./js/mixcoins.js'), + 'ndax': require ('./js/ndax.js'), 'novadax': require ('./js/novadax.js'), 'oceanex': require ('./js/oceanex.js'), 'okcoin': require ('./js/okcoin.js'), @@ -181,7 +184,1793 @@ module.exports = Object.assign ({ version, Exchange, 'exchanges': Object.keys (e //----------------------------------------------------------------------------- -},{"./js/acx.js":3,"./js/aofex.js":4,"./js/base/Exchange":5,"./js/base/errors":7,"./js/base/functions":8,"./js/bcex.js":19,"./js/bequant.js":20,"./js/bibox.js":21,"./js/bigone.js":22,"./js/binance.js":23,"./js/binanceus.js":24,"./js/bit2c.js":25,"./js/bitbank.js":26,"./js/bitbay.js":27,"./js/bitcoincom.js":28,"./js/bitfinex.js":29,"./js/bitfinex2.js":30,"./js/bitflyer.js":31,"./js/bitforex.js":32,"./js/bitget.js":33,"./js/bithumb.js":34,"./js/bitkk.js":35,"./js/bitmart.js":36,"./js/bitmax.js":37,"./js/bitmex.js":38,"./js/bitpanda.js":39,"./js/bitso.js":40,"./js/bitstamp.js":41,"./js/bitstamp1.js":42,"./js/bittrex.js":43,"./js/bitvavo.js":44,"./js/bitz.js":45,"./js/bl3p.js":46,"./js/bleutrade.js":47,"./js/braziliex.js":48,"./js/btcalpha.js":49,"./js/btcbox.js":50,"./js/btcmarkets.js":51,"./js/btctradeua.js":52,"./js/btcturk.js":53,"./js/buda.js":54,"./js/bw.js":55,"./js/bybit.js":56,"./js/bytetrade.js":57,"./js/cex.js":58,"./js/chilebit.js":59,"./js/coinbase.js":60,"./js/coinbaseprime.js":61,"./js/coinbasepro.js":62,"./js/coincheck.js":63,"./js/coinegg.js":64,"./js/coinex.js":65,"./js/coinfalcon.js":66,"./js/coinfloor.js":67,"./js/coingi.js":68,"./js/coinmarketcap.js":69,"./js/coinmate.js":70,"./js/coinone.js":71,"./js/coinspot.js":72,"./js/crex24.js":73,"./js/currencycom.js":74,"./js/deribit.js":75,"./js/digifinex.js":76,"./js/dsx.js":77,"./js/eterbase.js":78,"./js/exmo.js":79,"./js/exx.js":80,"./js/fcoin.js":81,"./js/fcoinjp.js":82,"./js/flowbtc.js":83,"./js/foxbit.js":84,"./js/ftx.js":85,"./js/gateio.js":86,"./js/gemini.js":87,"./js/hbtc.js":88,"./js/hitbtc.js":89,"./js/hollaex.js":90,"./js/huobijp.js":91,"./js/huobipro.js":92,"./js/huobiru.js":93,"./js/ice3x.js":94,"./js/idex.js":95,"./js/independentreserve.js":96,"./js/indodax.js":97,"./js/itbit.js":98,"./js/kraken.js":99,"./js/kucoin.js":100,"./js/kuna.js":101,"./js/lakebtc.js":102,"./js/latoken.js":103,"./js/lbank.js":104,"./js/liquid.js":105,"./js/livecoin.js":106,"./js/luno.js":107,"./js/lykke.js":108,"./js/mercado.js":109,"./js/mixcoins.js":110,"./js/novadax.js":111,"./js/oceanex.js":112,"./js/okcoin.js":113,"./js/okex.js":114,"./js/paymium.js":115,"./js/phemex.js":116,"./js/poloniex.js":117,"./js/probit.js":118,"./js/qtrade.js":119,"./js/rightbtc.js":120,"./js/ripio.js":121,"./js/southxchange.js":122,"./js/stex.js":163,"./js/surbitcoin.js":164,"./js/therock.js":165,"./js/tidebit.js":166,"./js/tidex.js":167,"./js/timex.js":168,"./js/upbit.js":169,"./js/vaultoro.js":170,"./js/vbtc.js":171,"./js/vcc.js":172,"./js/wavesexchange.js":173,"./js/whitebit.js":174,"./js/xbtce.js":175,"./js/xena.js":176,"./js/yobit.js":177,"./js/zaif.js":178,"./js/zb.js":179}],3:[function(require,module,exports){ +},{"./js/aax.js":3,"./js/acx.js":4,"./js/aofex.js":5,"./js/base/Exchange":6,"./js/base/errors":8,"./js/base/functions":9,"./js/bequant.js":20,"./js/bibox.js":21,"./js/bigone.js":22,"./js/binance.js":23,"./js/binanceus.js":24,"./js/bit2c.js":25,"./js/bitbank.js":26,"./js/bitbay.js":27,"./js/bitcoincom.js":28,"./js/bitfinex.js":29,"./js/bitfinex2.js":30,"./js/bitflyer.js":31,"./js/bitforex.js":32,"./js/bitget.js":33,"./js/bithumb.js":34,"./js/bitkk.js":35,"./js/bitmart.js":36,"./js/bitmax.js":37,"./js/bitmex.js":38,"./js/bitpanda.js":39,"./js/bitso.js":40,"./js/bitstamp.js":41,"./js/bitstamp1.js":42,"./js/bittrex.js":43,"./js/bitvavo.js":44,"./js/bitz.js":45,"./js/bl3p.js":46,"./js/bleutrade.js":47,"./js/braziliex.js":48,"./js/btcalpha.js":49,"./js/btcbox.js":50,"./js/btcmarkets.js":51,"./js/btctradeua.js":52,"./js/btcturk.js":53,"./js/buda.js":54,"./js/bw.js":55,"./js/bybit.js":56,"./js/bytetrade.js":57,"./js/cdax.js":58,"./js/cex.js":59,"./js/chilebit.js":60,"./js/coinbase.js":61,"./js/coinbaseprime.js":62,"./js/coinbasepro.js":63,"./js/coincheck.js":64,"./js/coinegg.js":65,"./js/coinex.js":66,"./js/coinfalcon.js":67,"./js/coinfloor.js":68,"./js/coingi.js":69,"./js/coinmarketcap.js":70,"./js/coinmate.js":71,"./js/coinone.js":72,"./js/coinspot.js":73,"./js/crex24.js":74,"./js/currencycom.js":75,"./js/delta.js":76,"./js/deribit.js":77,"./js/digifinex.js":78,"./js/dsx.js":79,"./js/equos.js":80,"./js/eterbase.js":81,"./js/exmo.js":82,"./js/exx.js":83,"./js/fcoin.js":84,"./js/fcoinjp.js":85,"./js/flowbtc.js":86,"./js/foxbit.js":87,"./js/ftx.js":88,"./js/gateio.js":89,"./js/gemini.js":90,"./js/gopax.js":91,"./js/hbtc.js":92,"./js/hitbtc.js":93,"./js/hollaex.js":94,"./js/huobijp.js":95,"./js/huobipro.js":96,"./js/ice3x.js":97,"./js/idex.js":98,"./js/independentreserve.js":99,"./js/indodax.js":100,"./js/itbit.js":101,"./js/kraken.js":102,"./js/kucoin.js":103,"./js/kuna.js":104,"./js/lakebtc.js":105,"./js/latoken.js":106,"./js/lbank.js":107,"./js/liquid.js":108,"./js/luno.js":109,"./js/lykke.js":110,"./js/mercado.js":111,"./js/mixcoins.js":112,"./js/ndax.js":113,"./js/novadax.js":114,"./js/oceanex.js":115,"./js/okcoin.js":116,"./js/okex.js":117,"./js/paymium.js":118,"./js/phemex.js":119,"./js/poloniex.js":120,"./js/probit.js":121,"./js/qtrade.js":122,"./js/rightbtc.js":123,"./js/ripio.js":124,"./js/southxchange.js":125,"./js/stex.js":166,"./js/surbitcoin.js":167,"./js/therock.js":168,"./js/tidebit.js":169,"./js/tidex.js":170,"./js/timex.js":171,"./js/upbit.js":172,"./js/vaultoro.js":173,"./js/vbtc.js":174,"./js/vcc.js":175,"./js/wavesexchange.js":176,"./js/whitebit.js":177,"./js/xbtce.js":178,"./js/xena.js":179,"./js/yobit.js":180,"./js/zaif.js":181,"./js/zb.js":182}],3:[function(require,module,exports){ +'use strict'; + +// ---------------------------------------------------------------------------- + +const Exchange = require ('./base/Exchange'); +const { ArgumentsRequired, AuthenticationError, ExchangeError, ExchangeNotAvailable, OrderNotFound, InvalidOrder, CancelPending, RateLimitExceeded, InsufficientFunds, BadRequest, BadSymbol, PermissionDenied } = require ('./base/errors'); +const { TICK_SIZE } = require ('./base/functions/number'); + +// ---------------------------------------------------------------------------- + +module.exports = class aax extends Exchange { + describe () { + return this.deepExtend (super.describe (), { + 'id': 'aax', + 'name': 'AAX', + 'countries': [ 'MT' ], // Malta + 'enableRateLimit': true, + 'rateLimit': 500, + 'version': 'v2', + 'hostname': 'aaxpro.com', // aax.com + 'certified': true, + 'has': { + 'cancelAllOrders': true, + 'cancelOrder': true, + 'createOrder': true, + 'editOrder': true, + 'fetchBalance': true, + 'fetchCanceledOrders': true, + 'fetchClosedOrders': true, + 'fetchDepositAddress': true, + 'fetchMarkets': true, + 'fetchMyTrades': true, + 'fetchOHLCV': true, + 'fetchOpenOrders': true, + 'fetchOrder': true, + 'fetchOrderBook': true, + 'fetchOrders': true, + 'fetchTicker': 'emulated', + 'fetchTickers': true, + 'fetchTrades': true, + }, + 'timeframes': { + '1m': '1m', + '5m': '5m', + '15m': '15m', + '30m': '30m', + '1h': '1h', + '2h': '2h', + '4h': '4h', + '12h': '12h', + '1d': '1d', + '3d': '3d', + '1w': '1w', + }, + 'urls': { + 'logo': 'https://user-images.githubusercontent.com/1294454/104140087-a27f2580-53c0-11eb-87c1-5d9e81208fe9.jpg', + 'test': { + 'v1': 'https://api.testnet.{hostname}/marketdata/v1', + 'public': 'https://api.testnet.{hostname}', + 'private': 'https://api.testnet.{hostname}', + }, + 'api': { + 'v1': 'https://api.{hostname}/marketdata/v1', + 'public': 'https://api.{hostname}', + 'private': 'https://api.{hostname}', + }, + 'www': 'https://www.aaxpro.com', // string website URL + 'doc': 'https://www.aaxpro.com/apidoc/index.html', + 'fees': 'https://www.aaxpro.com/en-US/fees/', + 'referral': 'https://www.aaxpro.com/invite/sign-up?inviteCode=JXGm5Fy7R2MB', + }, + 'api': { + 'v1': { + 'get': [ + 'getHistMarketData', // Get OHLC k line of specific market + ], + }, + 'public': { + // these endpoints are not documented + // 'get': [ + // 'order_book', // Get the order book of specified market + // 'order_book/{market}', + // 'trades', // Get recent trades on market, each trade is included only once Trades are sorted in reverse creation order. + // 'trades/{market}', + // 'tickers', // Get ticker of all markets + // 'tickers/{market}', // Get ticker of specific market + // ], + 'get': [ + 'announcement/maintenance', // System Maintenance Notice + 'instruments', // Retrieve all trading pairs information + 'market/orderbook', // Order Book + 'futures/position/openInterest', // Open Interest + 'market/tickers', // Get the Last 24h Market Summary + 'market/candles', // Get Current Candlestick + 'market/history/candles', // Get Current Candlestick + 'market/trades', // Get the Most Recent Trades + 'market/markPrice', // Get Current Mark Price + 'futures/funding/predictedFunding/{symbol}', // Get Predicted Funding Rate + 'futures/funding/prevFundingRate/{symbol}', // Get Last Funding Rate + 'market/candles/index', // Get Current Index Candlestick + ], + }, + 'private': { + 'get': [ + 'user/info', // Retrieve user information + 'account/balances', // Get Account Balances + 'account/deposit/address', // undocumented + 'spot/trades', // Retrieve trades details for a spot order + 'spot/openOrders', // Retrieve spot open orders + 'spot/orders', // Retrieve historical spot orders + 'futures/position', // Get positions for all contracts + 'futures/position/closed', // Get closed positions + 'futures/trades', // Retrieve trade details for a futures order + 'futures/openOrders', // Retrieve futures open orders + 'futures/orders', // Retrieve historical futures orders + 'futures/funding/predictedFundingFee/{symbol}', // Get predicted funding fee + ], + 'post': [ + 'account/transfer', // Asset Transfer + 'spot/orders', // Create a new spot order + 'spot/orders/cancelAllOnTimeout', // Automatically cancel all your spot orders after a specified timeout. + 'futures/orders', // Create a new futures order + 'futures/orders/cancelAllOnTimeout', // Automatically cancel all your futures orders after a specified timeout. + 'futures/position/sltp', // Set take profit and stop loss orders for an opening position + 'futures/position/close', // Close position + 'futures/position/leverage', // Update leverage for position + 'futures/position/margin', // Modify Isolated Position Margin + ], + 'put': [ + 'spot/orders', // Amend spot order + 'futures/orders', // Amend the quantity of an open futures order + ], + 'delete': [ + 'spot/orders/cancel/{orderID}', // Cancel a spot order + 'spot/orders/cancel/all', // Batch cancel spot orders + 'futures/orders/cancel/{orderID}', // Cancel a futures order + 'futures/orders/cancel/all', // Batch cancel futures orders + ], + }, + }, + 'fees': { + 'trading': { + 'tierBased': false, + 'percentage': true, + 'maker': 0.06 / 100, + 'taker': 0.10 / 100, + }, + 'funding': { + 'tierBased': false, + 'percentage': true, + 'withdraw': {}, // There is only 1% fee on withdrawals to your bank account. + }, + }, + 'commonCurrencies': { + 'XBT': 'XBT', + }, + 'exceptions': { + 'exact': { + '2002': InsufficientFunds, + '2003': OrderNotFound, + '10003': BadRequest, // Parameter validation error + '10006': AuthenticationError, // Session expired, please relogin + '10007': AuthenticationError, // Invalid authentication key or token + '11007': AuthenticationError, // Invalid key format + '20001': InsufficientFunds, // Insufficient balance. Please deposit to trade. + '20009': InvalidOrder, // Order amount must be positive + '30000': OrderNotFound, // {"code":30000,"data":null,"message":"The order does not exist","ts":1610259732263} + '30001': InvalidOrder, // The order is being submitted, please try again later + '30004': InvalidOrder, // Minimum quantity is {0} + '30005': InvalidOrder, // Quantity maximum precision is {0} decimal places + '30006': InvalidOrder, // Price maximum precision is {0} decimal places + '30007': InvalidOrder, // Minimum price is {0} + '30008': InvalidOrder, // Stop price maximum precision is {0} decimal places + '30009': InvalidOrder, // Stop Price cannot be less than {0} + '30010': InvalidOrder, // Market price cannot be empty + '30011': CancelPending, // The order is being cancelled, please wait. + '30012': BadRequest, // Unknown currency + '30013': BadSymbol, // Unknown symbol + '30014': OrderNotFound, // Futures order cannot be found + '30015': InvalidOrder, // This is not an open order and cannot modified + '30016': ExchangeError, // No position found + '30017': InvalidOrder, // The current close position is 0. It is recommended that you cancel the current order closing order. + '30018': InvalidOrder, // Order price cannot be greater than {0} + '30019': InvalidOrder, // Order quantity cannot be greater than {0} + '30020': InvalidOrder, // Order price must be a multiple of {0} + '30021': InvalidOrder, // Margin adjustement must be greater than 0 + '30022': InvalidOrder, // New quantity must be greater than filled quantity + '30023': InvalidOrder, // Order failed, please try again + '30024': InvalidOrder, // TimeInForce error, only GTC or IOC are allowed + '30025': InvalidOrder, // TimeInForce error, only GTC is allowed + '30026': InvalidOrder, // Quantity is not a multiple of {0} + '30027': InvalidOrder, // Close position failed, it is recommended that you cancel the current order and then close the position. + '30028': BadSymbol, // Symbol cannot be traded at this time + '30029': InvalidOrder, // Modified quantity or price cannot be empty + '30030': InvalidOrder, // Price cannot be specified for market orders + '30031': InvalidOrder, // Liquidation orders cannot be modified + '30032': InvalidOrder, // Leverage cannot be greater than {0} + '30033': InvalidOrder, // Leverage cannot be smaller than {0} + '30034': RateLimitExceeded, // The max number of open orders is {0}. To place a new order, please cancel a previous one + '30035': RateLimitExceeded, // The max number of {0} open orders is {1}. To place a new order, please cancel a previous one + '30036': ExchangeNotAvailable, // Liquidation is in progress, please try again later + '30037': InvalidOrder, // Once stop limit order triggered, stop price cannot be amended + '30038': ExchangeError, // The total value of your orders has exceeded the current risk limit. Please adjust the risk limit + '30039': InsufficientFunds, // Your risk limit has now been changed to {0}, your maximum leverage less than 1, please readjust accordingly + '30040': InvalidOrder, // Order status has changed, please try again later + '30041': InvalidOrder, // Liquidation orders cannot be cancelled + '30042': InvalidOrder, // Order cannot be placed as you will be breaching you max limit value of {1} BTC for {0} + '30043': InvalidOrder, // The risk limit cannot be less than 0 + '30044': BadRequest, // Timeout cannot be greater than 60 minutes + '30045': InvalidOrder, // Side is not valid, it should be BUY or SELL + '30046': InvalidOrder, // Order type is not valid, it should be MARKET or LIMIT or STOP-LIMIT or STOP + '30047': InvalidOrder, // The order is closed. Can't cancel + '30048': InvalidOrder, // Market orders cannot be modified + '30049': InvalidOrder, // The order is being modified, please wait + '30050': InvalidOrder, // Maximum 10 orders + '40004': BadRequest, // Requested resource doesn't exist + '40009': RateLimitExceeded, // Too many requests + '40102': AuthenticationError, // {"code":40102,"message":"Unauthorized(invalid key)"} + '40103': AuthenticationError, // {"code":40103,"message":"Unauthorized(invalid sign)"} + '40303': PermissionDenied, // {"code":40303,"message":"Forbidden(invalid scopes)"} + '41001': BadRequest, // Incorrect HTTP request + '41002': BadRequest, // Unsupported HTTP request method + '42001': ExchangeNotAvailable, // Duplicated data entry, please check and try again + '50001': ExchangeError, // Server side exception, please try again later + '50002': ExchangeError, // Server is busy, please try again later + }, + 'broad': {}, + }, + 'precisionMode': TICK_SIZE, + 'options': { + 'defaultType': 'spot', // 'spot', 'future' + }, + }); + } + + async fetchMarkets (params = {}) { + const response = await this.publicGetInstruments (params); + // + // { + // "code":1, + // "message":"success", + // "ts":1610159448962, + // "data":[ + // { + // "tickSize":"0.01", + // "lotSize":"1", + // "base":"BTC", + // "quote":"USDT", + // "minQuantity":"1.0000000000", + // "maxQuantity":"30000", + // "minPrice":"0.0100000000", + // "maxPrice":"999999.0000000000", + // "status":"readOnly", + // "symbol":"BTCUSDTFP", + // "code":"FP", + // "takerFee":"0.00040", + // "makerFee":"0.00020", + // "multiplier":"0.001000000000", + // "mmRate":"0.00500", + // "imRate":"0.01000", + // "type":"futures", + // "settleType":"Vanilla", + // "settleCurrency":"USDT" + // }, + // { + // "tickSize":"0.5", + // "lotSize":"10", + // "base":"BTC", + // "quote":"USD", + // "minQuantity":"10.0000000000", + // "maxQuantity":"300000", + // "minPrice":"0.5000000000", + // "maxPrice":"999999.0000000000", + // "status":"readOnly", + // "symbol":"BTCUSDFP", + // "code":"FP", + // "takerFee":"0.00040", + // "makerFee":"0.00020", + // "multiplier":"1.000000000000", + // "mmRate":"0.00500", + // "imRate":"0.01000", + // "type":"futures", + // "settleType":"Inverse", + // "settleCurrency":"BTC" + // }, + // { + // "tickSize":"0.0001", + // "lotSize":"0.01", + // "base":"AAB", + // "quote":"USDT", + // "minQuantity":"5.0000000000", + // "maxQuantity":"50000.0000000000", + // "minPrice":"0.0001000000", + // "maxPrice":"999999.0000000000", + // "status":"readOnly", + // "symbol":"AABUSDT", + // "code":null, + // "takerFee":"0.00100", + // "makerFee":"0.00100", + // "multiplier":"1.000000000000", + // "mmRate":"0.02500", + // "imRate":"0.05000", + // "type":"spot", + // "settleType":null, + // "settleCurrency":null + // }, + // ] + // } + // + const data = this.safeValue (response, 'data'); + const result = []; + for (let i = 0; i < data.length; i++) { + const market = data[i]; + const id = this.safeString (market, 'symbol'); + const baseId = this.safeString (market, 'base'); + const quoteId = this.safeString (market, 'quote'); + const base = this.safeCurrencyCode (baseId); + const quote = this.safeCurrencyCode (quoteId); + const status = this.safeString (market, 'status'); + const active = (status === 'enable'); + const taker = this.safeFloat (market, 'takerFee'); + const maker = this.safeFloat (market, 'makerFee'); + const type = this.safeString (market, 'type'); + let inverse = undefined; + let linear = undefined; + let quanto = undefined; + const spot = (type === 'spot'); + const futures = (type === 'futures'); + const settleType = this.safeStringLower (market, 'settleType'); + if (settleType !== undefined) { + inverse = (settleType === 'inverse'); + linear = (settleType === 'vanilla'); + quanto = (settleType === 'quanto'); + } + let symbol = id; + if (type === 'spot') { + symbol = base + '/' + quote; + } + const precision = { + 'amount': this.safeFloat (market, 'lotSize'), + 'price': this.safeFloat (market, 'tickSize'), + }; + result.push ({ + 'id': id, + 'symbol': symbol, + 'base': base, + 'quote': quote, + 'baseId': baseId, + 'quoteId': quoteId, + 'type': type, + 'spot': spot, + 'futures': futures, + 'inverse': inverse, + 'linear': linear, + 'quanto': quanto, + 'precision': precision, + 'info': market, + 'active': active, + 'taker': taker, + 'maker': maker, + 'percentage': false, + 'tierBased': true, + 'limits': { + 'amount': { + 'min': this.safeString (market, 'minQuantity'), + 'max': this.safeString (market, 'maxQuantity'), + }, + 'price': { + 'min': this.safeString (market, 'minPrice'), + 'max': this.safeString (market, 'maxPrice'), + }, + 'cost': { + 'min': undefined, + 'max': undefined, + }, + }, + }); + } + return result; + } + + parseTicker (ticker, market = undefined) { + // + // { + // "t":1610162685342, // timestamp + // "a":"0.00000000", // trading volume in USD in the last 24 hours, futures only + // "c":"435.20000000", // close + // "d":"4.22953489", // change + // "h":"455.04000000", // high + // "l":"412.78000000", // low + // "o":"417.54000000", // open + // "s":"BCHUSDTFP", // market id + // "v":"2031068.00000000", // trading volume in quote currency of last 24 hours + // } + // + const timestamp = this.safeInteger (ticker, 't'); + const marketId = this.safeString (ticker, 's'); + const symbol = this.safeSymbol (marketId, market); + const last = this.safeFloat (ticker, 'c'); + const open = this.safeFloat (ticker, 'o'); + let change = undefined; + let percentage = undefined; + let average = undefined; + if (last !== undefined && open !== undefined) { + change = last - open; + if (open > 0) { + percentage = change / open * 100; + } + average = this.sum (last, open) / 2; + } + const quoteVolume = this.safeFloat (ticker, 'v'); + return { + 'symbol': symbol, + 'timestamp': timestamp, + 'datetime': this.iso8601 (timestamp), + 'high': this.safeFloat (ticker, 'h'), + 'low': this.safeFloat (ticker, 'l'), + 'bid': undefined, + 'bidVolume': undefined, + 'ask': undefined, + 'askVolume': undefined, + 'vwap': undefined, + 'open': open, + 'close': last, + 'last': last, + 'previousClose': undefined, + 'change': change, + 'percentage': percentage, + 'average': average, + 'baseVolume': undefined, + 'quoteVolume': quoteVolume, + 'info': ticker, + }; + } + + async fetchTicker (symbol, params = {}) { + const tickers = await this.fetchTickers (undefined, params); + if (symbol in tickers) { + return tickers[symbol]; + } + throw new BadSymbol (this.id + ' fetchTicker() symbol ' + symbol + ' ticker not found'); + } + + async fetchTickers (symbols = undefined, params = {}) { + await this.loadMarkets (); + const response = await this.publicGetMarketTickers (params); + // + // { + // "e":"tickers", + // "t":1610162685342, + // "tickers":[ + // { + // "a":"0.00000000", + // "c":"435.20000000", + // "d":"4.22953489", + // "h":"455.04000000", + // "l":"412.78000000", + // "o":"417.54000000", + // "s":"BCHUSDTFP", + // "v":"2031068.00000000", + // }, + // ], + // } + // + const tickers = this.safeValue (response, 'tickers', []); + const result = []; + const timestamp = this.safeInteger (response, 't'); + for (let i = 0; i < tickers.length; i++) { + const ticker = this.parseTicker (this.extend (tickers[i], { 't': timestamp })); + result.push (ticker); + } + return this.filterByArray (result, 'symbol', symbols); + } + + async fetchOrderBook (symbol, limit = undefined, params = {}) { + await this.loadMarkets (); + const market = this.market (symbol); + if (limit === undefined) { + limit = 20; + } else { + if ((limit !== 20) && (limit !== 50)) { + throw new BadRequest (this.id + ' fetchOrderBook() limit argument must be undefined, 20 or 50'); + } + } + const request = { + 'symbol': market['id'], + 'level': limit, // required + }; + // + const response = await this.publicGetMarketOrderbook (this.extend (request, params)); + // + // { + // "asks":[ + // ["10823.00000000","0.004000"], + // ["10823.10000000","0.100000"], + // ["10823.20000000","0.010000"] + // ], + // "bids":[ + // ["10821.20000000","0.002000"], + // ["10821.10000000","0.005000"], + // ["10820.40000000","0.013000"] + // ], + // "e":"BTCUSDT@book_50", + // "t":1561543614756 + // } + // + const timestamp = this.safeInteger (response, 't'); // need unix type + return this.parseOrderBook (response, timestamp); + } + + parseTrade (trade, market = undefined) { + // + // public fetchTrades + // + // { + // "p":"9395.50000000", + // "q":"50.000000", + // "t":1592563996718 + // } + // + // private fetchMyTrades + // + // { + // "avgPrice":"1199.8", + // "base":"ETH", + // "clOrdID":null, + // "commission":"0.00002", + // "createTime":"2021-01-11T02:47:51.512Z", + // "cumQty":"0.02", + // "filledOrderID":"1eUD4F5rwK", + // "filledPrice":"1199.8", + // "filledQty":"0.02", + // "leavesQty":"0", + // "oCreateTime":"2021-01-11T02:47:51.377Z", + // "orderID":"1eUD4EHfdU", + // "orderQty":"0.02", + // "orderStatus":3, + // "orderType":1, + // "price":"1198.25", + // "quote":"USDT", + // "rejectCode":null, + // "rejectReason":null, + // "side":1, + // "stopPrice":"0", + // "symbol":"ETHUSDT", + // "taker":true, + // "tradeID":"E04WTIgfmULU", + // "transactTime":"2021-01-11T02:47:51.389Z", + // "updateTime":null, + // "userID":"1362494" + // } + // + let timestamp = this.safeInteger (trade, 't'); + if (timestamp === undefined) { + timestamp = this.parse8601 (this.safeString (trade, 'createTime')); + } + const id = this.safeString2 (trade, 'tid', 'tradeID'); + let symbol = undefined; + const marketId = this.safeString (trade, 'symbol'); + market = this.safeMarket (marketId, market); + if (market !== undefined) { + symbol = market['symbol']; + } + let price = this.safeFloat2 (trade, 'p', 'filledPrice'); + const amount = this.safeFloat2 (trade, 'q', 'filledQty'); + const orderId = this.safeString (trade, 'orderID'); + const isTaker = this.safeValue (trade, 'taker'); + let takerOrMaker = undefined; + if (isTaker !== undefined) { + takerOrMaker = isTaker ? 'taker' : 'maker'; + } + let side = this.safeString (trade, 'side'); + if (side === '1') { + side = 'buy'; + } else if (side === '2') { + side = 'sell'; + } + if (side === undefined) { + side = (price > 0) ? 'buy' : 'sell'; + } + side = (price > 0) ? 'buy' : 'sell'; + price = Math.abs (price); + let cost = undefined; + if ((price !== undefined) && (amount !== undefined)) { + cost = price * amount; + } + const orderType = this.parseOrderType (this.safeString (trade, 'orderType')); + let fee = undefined; + const feeCost = this.safeFloat (trade, 'commission'); + if (feeCost !== undefined) { + let feeCurrency = undefined; + if (market !== undefined) { + if (side === 'buy') { + feeCurrency = market['base']; + } else if (side === 'sell') { + feeCurrency = market['quote']; + } + } + fee = { + 'currency': feeCurrency, + 'cost': feeCost, + }; + } + return { + 'info': trade, + 'id': id, + 'timestamp': timestamp, + 'datetime': this.iso8601 (timestamp), + 'symbol': symbol, + 'type': orderType, + 'side': side, + 'order': orderId, + 'takerOrMaker': takerOrMaker, + 'price': price, + 'amount': amount, + 'cost': cost, + 'fee': fee, + }; + } + + async fetchTrades (symbol, since = undefined, limit = undefined, params = {}) { + await this.loadMarkets (); + const market = this.market (symbol); + limit = (limit === undefined) ? 2000 : limit; + limit = Math.min (limit, 2000); + const request = { + 'symbol': market['id'], + 'limit': limit, + }; + const response = await this.publicGetMarketTrades (request); + // + // { + // "e":"BTCUSDFP@trades", + // "trades": [ + // {"p":"9395.50000000","q":"50.000000","t":1592563996718}, + // {"p":"9395.50000000","q":"50.000000","t":1592563993577}, + // ], + // } + // + const trades = this.safeValue (response, 'trades', []); + return this.parseTrades (trades, market, since, limit); + } + + parseOHLCV (ohlcv, market = undefined) { + // + // [ + // 0.042398, // 0 open + // 0.042684, // 1 high + // 0.042366, // 2 low + // 0.042386, // 3 close + // 0.93734243, // 4 volume + // 1611514800, // 5 timestamp + // ] + // + return [ + this.safeTimestamp (ohlcv, 5), + this.safeFloat (ohlcv, 0), + this.safeFloat (ohlcv, 1), + this.safeFloat (ohlcv, 2), + this.safeFloat (ohlcv, 3), + this.safeFloat (ohlcv, 4), + ]; + } + + async fetchOHLCV (symbol, timeframe = '1h', since = undefined, limit = undefined, params = {}) { + await this.loadMarkets (); + const market = this.market (symbol); + const request = { + // 'limit': limit, // if set counts from now into the past + 'symbol': market['id'], + 'timeFrame': this.timeframes[timeframe], + }; + limit = (limit === undefined) ? 500 : limit; + const duration = this.parseTimeframe (timeframe); + if (since === undefined) { + const end = this.seconds (); + request['start'] = end - duration * limit; + request['end'] = end; + } else { + const start = parseInt (since / 1000); + request['start'] = start; + request['end'] = this.sum (start, duration * limit); + } + const response = await this.publicGetMarketHistoryCandles (this.extend (request, params)); + // + // { + // "data":[ + // [0.042398,0.042684,0.042366,0.042386,0.93734243,1611514800], + // [0.042386,0.042602,0.042234,0.042373,1.01925239,1611518400], + // [0.042373,0.042558,0.042362,0.042389,0.93801705,1611522000], + // ], + // "success":true, + // "t":1611875157 + // } + // + const data = this.safeValue (response, 'data', []); + return this.parseOHLCVs (data, market, timeframe, since, limit); + } + + async fetchBalance (params = {}) { + await this.loadMarkets (); + const defaultType = this.safeString2 (this.options, 'fetchBalance', 'defaultType', 'spot'); + const type = this.safeString (params, 'type', defaultType); + const types = { + 'spot': 'SPTP', + 'future': 'FUTP', + 'otc': 'F2CP', + 'saving': 'VLTP', + }; + const purseType = this.safeString (types, type, type); + const request = { + 'purseType': purseType, + }; + params = this.omit (params, 'type'); + const response = await this.privateGetAccountBalances (this.extend (request, params)); + // + // { + // "code":1, + // "data":[ + // { + // "purseType":"FUTP", + // "currency":"BTC", + // "available":"0.41000000", + // "unavailable":"0.00000000" + // }, + // { + // "purseType":"FUTP", + // "currency":"USDT", + // "available":"0.21000000", + // "unvaliable":"0.00000000" + // } + // ] + // "message":"success", + // "ts":1573530401020 + // } + // + const data = this.safeValue (response, 'data'); + const result = { 'info': response }; + for (let i = 0; i < data.length; i++) { + const balance = data[i]; + const balanceType = this.safeString (balance, 'purseType'); + if (balanceType === purseType) { + const currencyId = this.safeString (balance, 'currency'); + const code = this.safeCurrencyCode (currencyId); + const account = this.account (); + account['free'] = this.safeFloat (balance, 'available'); + account['used'] = this.safeFloat (balance, 'unavailable'); + result[code] = account; + } + } + return this.parseBalance (result); + } + + async createOrder (symbol, type, side, amount, price = undefined, params = {}) { + let orderType = type.toUpperCase (); + const orderSide = side.toUpperCase (); + await this.loadMarkets (); + const market = this.market (symbol); + const request = { + // 'orderType': orderType, // MARKET, LIMIT, STOP, STOP-LIMIT + 'symbol': market['id'], + 'orderQty': this.amountToPrecision (symbol, amount), + 'side': orderSide, + // 'stopPrice': this.priceToPrecision (symbol, stopPrice), + // 'clOrdID': clientOrderId, // up to 20 chars, lowercase and uppercase letters only + // 'timeInForce': 'GTC', // GTC, IOC, FOK, default is GTC + // 'execInst': 'Post-Only', // the only value supported by the exchange, futures-only + }; + const timeInForce = this.safeString (params, 'timeInForce'); + if (timeInForce !== undefined) { + request['timeInForce'] = timeInForce; + params = this.omit (params, 'timeInForce'); + } + const clientOrderId = this.safeString2 (params, 'clOrdID', 'clientOrderId'); + if (clientOrderId !== undefined) { + request['clOrdID'] = clientOrderId; + params = this.omit (params, [ 'clOrdID', 'clientOrderId' ]); + } + const stopPrice = this.safeFloat (params, 'stopPrice'); + if (stopPrice === undefined) { + if ((orderType === 'STOP-LIMIT') || (orderType === 'STOP')) { + throw new ArgumentsRequired (this.id + ' createOrder() requires a stopPrice parameter for ' + orderType + ' orders'); + } + } else { + if (orderType === 'LIMIT') { + orderType = 'STOP-LIMIT'; + } else if (orderType === 'MARKET') { + orderType = 'STOP'; + } + request['stopPrice'] = this.priceToPrecision (symbol, stopPrice); + params = this.omit (params, 'stopPrice'); + } + if (orderType === 'LIMIT' || orderType === 'STOP-LIMIT') { + request['price'] = this.priceToPrecision (symbol, price); + } + request['orderType'] = orderType; + let method = undefined; + if (market['spot']) { + method = 'privatePostSpotOrders'; + } else if (market['futures']) { + method = 'privatePostFuturesOrders'; + } + const response = await this[method] (this.extend (request, params)); + // + // spot + // + // { + // "code":1, + // "data":{ + // "symbol":"ETHUSDT", + // "orderType":2, + // "avgPrice":"0", + // "execInst":null, + // "orderStatus":0, + // "userID":"1362494", + // "quote":"USDT", + // "rejectReason":null, + // "rejectCode":null, + // "price":"1500", + // "orderQty":"1", + // "commission":"0", + // "id":"268323430253735936", + // "timeInForce":1, + // "isTriggered":false, + // "side":2, + // "orderID":"1eO51MDSpQ", + // "leavesQty":"0", + // "cumQty":"0", + // "updateTime":null, + // "lastQty":"0", + // "clOrdID":null, + // "stopPrice":null, + // "createTime":null, + // "transactTime":null, + // "base":"ETH", + // "lastPrice":"0" + // }, + // "message":"success", + // "ts":1610245290980 + // } + // + // futures + // + // { + // "code":1, + // "data":{ + // "liqType":0, + // "symbol":"ETHUSDTFP", + // "orderType":2, + // "leverage":"1", + // "marketPrice":"1318.3150000000", + // "code":"FP", + // "avgPrice":"0", + // "execInst":null, + // "orderStatus":0, + // "userID":"1362494", + // "quote":"USDT", + // "rejectReason":null, + // "rejectCode":null, + // "price":"500", + // "orderQty":"1", + // "commission":"0", + // "id":"268346885133053953", + // "timeInForce":1, + // "isTriggered":false, + // "side":1, + // "orderID":"1eOuPUAAkq", + // "leavesQty":"1", + // "cumQty":"0", + // "updateTime":null, + // "lastQty":null, + // "clOrdID":null, + // "stopPrice":null, + // "createTime":null, + // "transactTime":null, + // "settleType":"VANILLA", + // "base":"ETH", + // "lastPrice":"0" + // }, + // "message":"success", + // "ts":1610250883059 + // } + // + const data = this.safeValue (response, 'data', {}); + return this.parseOrder (data, market); + } + + async editOrder (id, symbol, type, side, amount, price = undefined, params = {}) { + await this.loadMarkets (); + const market = this.market (symbol); + const request = { + 'orderID': id, + // 'orderQty': this.amountToPrecision (symbol, amount), + // 'price': this.priceToPrecision (symbol, price), + // 'stopPrice': this.priceToPrecision (symbol, stopPrice), + }; + const stopPrice = this.safeFloat (params, 'stopPrice'); + if (stopPrice !== undefined) { + request['stopPrice'] = this.priceToPrecision (symbol, stopPrice); + params = this.omit (params, 'stopPrice'); + } + if (price !== undefined) { + request['price'] = this.priceToPrecision (symbol, price); + } + if (amount !== undefined) { + request['orderQty'] = this.amountToPrecision (symbol, amount); + } + let method = undefined; + if (market['spot']) { + method = 'privatePutSpotOrders'; + } else if (market['futures']) { + method = 'privatePutFuturesOrders'; + } + const response = await this[method] (this.extend (request, params)); + // + // spot + // + // { + // "code":1, + // "data":{ + // "symbol":"ETHUSDT", + // "orderType":2, + // "avgPrice":"0", + // "execInst":null, + // "orderStatus":0, + // "userID":"1362494", + // "quote":"USDT", + // "rejectReason":null, + // "rejectCode":null, + // "price":"1500", + // "orderQty":"1", + // "commission":"0", + // "id":"268323430253735936", + // "timeInForce":1, + // "isTriggered":false, + // "side":2, + // "orderID":"1eO51MDSpQ", + // "leavesQty":"0", + // "cumQty":"0", + // "updateTime":null, + // "lastQty":"0", + // "clOrdID":null, + // "stopPrice":null, + // "createTime":null, + // "transactTime":null, + // "base":"ETH", + // "lastPrice":"0" + // }, + // "message":"success", + // "ts":1610245290980 + // } + // + // futures + // + // { + // "code":1, + // "data":{ + // "liqType":0, + // "symbol":"ETHUSDTFP", + // "orderType":2, + // "leverage":"1", + // "marketPrice":"1318.3150000000", + // "code":"FP", + // "avgPrice":"0", + // "execInst":null, + // "orderStatus":0, + // "userID":"1362494", + // "quote":"USDT", + // "rejectReason":null, + // "rejectCode":null, + // "price":"500", + // "orderQty":"1", + // "commission":"0", + // "id":"268346885133053953", + // "timeInForce":1, + // "isTriggered":false, + // "side":1, + // "orderID":"1eOuPUAAkq", + // "leavesQty":"1", + // "cumQty":"0", + // "updateTime":null, + // "lastQty":null, + // "clOrdID":null, + // "stopPrice":null, + // "createTime":null, + // "transactTime":null, + // "settleType":"VANILLA", + // "base":"ETH", + // "lastPrice":"0" + // }, + // "message":"success", + // "ts":1610250883059 + // } + // + const data = this.safeValue (response, 'data', {}); + return this.parseOrder (data, market); + } + + async cancelOrder (id, symbol = undefined, params = {}) { + await this.loadMarkets (); + const request = { + 'orderID': id, + }; + let method = undefined; + const defaultType = this.safeString2 (this.options, 'cancelOrder', 'defaultType', 'spot'); + let type = this.safeString (params, 'type', defaultType); + params = this.omit (params, 'type'); + let market = undefined; + if (symbol !== undefined) { + market = this.market (symbol); + type = market['type']; + } + if (type === 'spot') { + method = 'privateDeleteSpotOrdersCancelOrderID'; + } else if (type === 'futures') { + method = 'privateDeleteFuturesOrdersCancelOrderID'; + } + const response = await this[method] (this.extend (request, params)); + // + // spot + // + // { + // "code":1, + // "data":{ + // "avgPrice":"0", + // "base":"BTC", + // "clOrdID":"aax", + // "commission":"0", + // "createTime":"2019-11-12T03:46:41Z", + // "cumQty":"0", + // "id":"114330021504606208", + // "isTriggered":false, + // "lastPrice":"0", + // "lastQty":"0", + // "leavesQty":"0", + // "orderID":"wJ4L366KB", + // "orderQty":"0.05", + // "orderStatus":1, + // "orderType":2, + // "price":"8000", + // "quote":"USDT", + // "rejectCode":0, + // "rejectReason":null, + // "side":1, + // "stopPrice":"0", + // "symbol":"BTCUSDT", + // "transactTime":null, + // "updateTime":"2019-11-12T03:46:41Z", + // "timeInForce":1, + // "userID":"216214" + // }, + // "message":"success", + // "ts":1573530402029 + // } + // + // futures + // + // { + // "code":1, + // "data":{ + // "avgPrice":"0", + // "base":"BTC", + // "clOrdID":"aax_futures", + // "code":"FP", + // "commission":"0", + // "createTime":"2019-11-12T06:48:58Z", + // "cumQty":"0", + // "id":"114375893764395008", + // "isTriggered":false, + // "lastPrice":"0", + // "lastQty":null, + // "leavesQty":"300", + // "leverage":"1", + // "liqType":0, + // "marketPrice":"8760.75", + // "orderID":"wJTewQc81", + // "orderQty":"300", + // "orderStatus":1, + // "orderType":2, + // "price":"8000", + // "quote":"USD", + // "rejectCode":0, + // "rejectReason":null, + // "settleType":"INVERSE", + // "side":1, + // "stopPrice":"0", + // "symbol":"BTCUSDFP", + // "transactTime":"2019-11-12T06:48:58Z", + // "updateTime":"2019-11-12T06:48:58Z", + // "timeInForce":1, + // "execInst": "", + // "userID":"216214" + // }, + // "message":"success", + // "ts":1573541642970 + // } + // + const data = this.safeValue (response, 'data', {}); + return this.parseOrder (data, market); + } + + async cancelAllOrders (symbol = undefined, params = {}) { + if (symbol === undefined) { + throw new ArgumentsRequired (this.id + ' cancelAllOrders() requires a symbol argument'); + } + await this.loadMarkets (); + const market = this.market (symbol); + const request = { + 'symbol': market['id'], + }; + let method = undefined; + if (market['spot']) { + method = 'privateDeleteSpotOrdersCancelAll'; + } else if (market['futures']) { + method = 'privateDeleteFuturesOrdersCancelAll'; + } + const response = await this[method] (this.extend (request, params)); + // + // { + // "code":1, + // "data":[ + // "vBC9rXsEE", + // "vBCc46OI0" + // ], + // "message":"success", + // "ts":1572597435470 + // } + // + return response; + } + + async fetchOrder (id, symbol = undefined, params = {}) { + await this.loadMarkets (); + const defaultType = this.safeString2 (this.options, 'fetchOrder', 'defaultType', 'spot'); + params['type'] = this.safeString (params, 'type', defaultType); + const request = {}; + const clientOrderId = this.safeString2 (params, 'clOrdID', 'clientOrderId'); + if (clientOrderId === undefined) { + request['orderID'] = id; + } else { + request['clOrdID'] = clientOrderId; + params = this.omit (params, [ 'clOrdID', 'clientOrderId' ]); + } + const orders = await this.fetchOrders (symbol, undefined, undefined, this.extend (request, params)); + const order = this.safeValue (orders, 0); + if (order === undefined) { + if (clientOrderId === undefined) { + throw new OrderNotFound (this.id + ' fetchOrder() could not find order id ' + id); + } else { + throw new OrderNotFound (this.id + ' fetchOrder() could not find order clientOrderID ' + clientOrderId); + } + } + return order; + } + + async fetchOpenOrders (symbol = undefined, since = undefined, limit = undefined, params = {}) { + await this.loadMarkets (); + const request = { + // 'pageNum': '1', + // 'pageSize': '10', + // 'symbol': market['id'], + // 'orderID': id, + // 'side': 'undefined', // BUY, SELL + // 'clOrdID': clientOrderId, + }; + const defaultType = this.safeString2 (this.options, 'fetchOpenOrders', 'defaultType', 'spot'); + let type = this.safeString (params, 'type', defaultType); + params = this.omit (params, 'type'); + let market = undefined; + if (symbol !== undefined) { + market = this.market (symbol); + request['symbol'] = market['id']; + type = market['type']; + } + const clientOrderId = this.safeString2 (params, 'clOrdID', 'clientOrderId'); + if (clientOrderId !== undefined) { + request['clOrdID'] = clientOrderId; + params = this.omit (params, [ 'clOrdID', 'clientOrderId' ]); + } + let method = undefined; + if (type === 'spot') { + method = 'privateGetSpotOpenOrders'; + } else if (type === 'futures') { + method = 'privateGetFuturesOpenOrders'; + } + if (limit !== undefined) { + request['pageSize'] = limit; // default 10 + } + const response = await this[method] (this.extend (request, params)); + // + // spot + // + // { + // "code":1, + // "data":{ + // "total":19, + // "pageSize":10, + // "list":[ + // { + // "orderType":2, + // "symbol":"BTCUSDT", + // "avgPrice":"0", + // "orderStatus":0, + // "userID":"7225", + // "quote":"USDT", + // "rejectReason":null, + // "rejectCode":null, + // "price":"0", + // "orderQty":"0.002", + // "commission":"0", + // "id":"110419975166304256", + // "isTriggered":null, + // "side":1, + // "orderID":"vBGlDcLwk", + // "cumQty":"0", + // "leavesQty":"0", + // "updateTime":null, + // "clOrdID":"0001", + // "lastQty":"0", + // "stopPrice":"0", + // "createTime":"2019-11-01T08:49:33Z", + // "transactTime":null, + // "timeInForce":1, + // "base":"BTC", + // "lastPrice":"0" + // } + // ], + // "pageNum":1 + // }, + // "message":"success", + // "ts":1572598173682 + // } + // + // futures + // + // { + // "code":1, + // "data":{ + // "list":[ + // { + // "avgPrice":"8768.99999999484997", + // "base":"BTC", + // "clOrdID":null, + // "code":"FP", + // "commission":"0.00000913", + // "createTime":"2019-11-12T07:05:52.000Z, + // "cumQty":"100", + // "id":"114380149603028993", + // "isTriggered":false, + // "lastPrice":"8769", + // "lastQty":"100", + // "leavesQty":"0", + // "leverage":"1", + // "liqType":1, + // "marketPrice":"8769.75", + // "orderID":"wJXURIFBT", + // "orderQty":"100", + // "orderStatus":3, + // "orderType":1, + // "price":"8769.75", + // "quote":"USD", + // "rejectCode":0, + // "rejectReason":null, + // "settleType":"INVERSE", + // "side":2, + // "stopPrice":"0", + // "symbol":"BTCUSDFP", + // "transactTime":"2019-11-12T07:05:52.000Z, + // "updateTime":"2019-11-12T07:05:52.000Z, + // "timeInForce":1, + // "execInst": "", + // "userID":"216214" + // }, + // ], + // "pageNum":1, + // "pageSize":10, + // "total":21 + // }, + // "message":"success", + // "ts":1573546960172 + // } + // + const data = this.safeValue (response, 'data', {}); + const orders = this.safeValue (data, 'list', []); + return this.parseOrders (orders, market, since, limit); + } + + async fetchClosedOrders (symbol = undefined, since = undefined, limit = undefined, params = {}) { + const request = { + 'orderStatus': '2', // 1 new, 2 filled, 3 canceled + }; + return await this.fetchOrders (symbol, since, limit, this.extend (request, params)); + } + + async fetchCanceledOrders (symbol = undefined, since = undefined, limit = undefined, params = {}) { + const request = { + 'orderStatus': '3', // 1 new, 2 filled, 3 canceled + }; + return await this.fetchOrders (symbol, since, limit, this.extend (request, params)); + } + + async fetchOrders (symbol = undefined, since = undefined, limit = undefined, params = {}) { + await this.loadMarkets (); + const request = { + // 'pageNum': '1', + // 'pageSize': '10', + // 'symbol': market['id'], + // 'orderID': id, + // 'base': market['baseId'], + // 'quote': market['quoteId'], + // 'orderStatus': undefined, // 1 new, 2 filled, 3 canceled + // 'startDate': this.ymd (since), + // 'endDate': this.ymd (this.milliseconds()), + // 'orderType': undefined, // MARKET, LIMIT, STOP, STOP-LIMIT + // 'side': 'undefined', // BUY, SELL + // 'clOrdID': clientOrderId, + }; + let method = undefined; + const defaultType = this.safeString2 (this.options, 'fetchOrders', 'defaultType', 'spot'); + let type = this.safeString (params, 'type', defaultType); + params = this.omit (params, 'type'); + let market = undefined; + if (symbol !== undefined) { + market = this.market (symbol); + request['symbol'] = market['id']; + type = market['type']; + } + if (type === 'spot') { + method = 'privateGetSpotOrders'; + } else if (type === 'futures') { + method = 'privateGetFuturesOrders'; + } + const clientOrderId = this.safeString2 (params, 'clOrdID', 'clientOrderId'); + if (clientOrderId !== undefined) { + request['clOrdID'] = clientOrderId; + params = this.omit (params, [ 'clOrdID', 'clientOrderId' ]); + } + if (limit !== undefined) { + request['pageSize'] = limit; // default 10 + } + if (since !== undefined) { + request['startDate'] = this.ymd (since); + } + const response = await this[method] (this.extend (request, params)); + // + // spot + // + // { + // "code":1, + // "data":{ + // "total":19, + // "pageSize":10, + // "list":[ + // { + // "orderType":2, + // "symbol":"BTCUSDT", + // "avgPrice":"0", + // "orderStatus":0, + // "userID":"7225", + // "quote":"USDT", + // "rejectReason":null, + // "rejectCode":null, + // "price":"0", + // "orderQty":"0.002", + // "commission":"0", + // "id":"110419975166304256", + // "isTriggered":null, + // "side":1, + // "orderID":"vBGlDcLwk", + // "cumQty":"0", + // "leavesQty":"0", + // "updateTime":null, + // "clOrdID":"0001", + // "lastQty":"0", + // "stopPrice":"0", + // "createTime":"2019-11-01T08:49:33Z", + // "transactTime":null, + // "timeInForce":1, + // "base":"BTC", + // "lastPrice":"0" + // } + // ], + // "pageNum":1 + // }, + // "message":"success", + // "ts":1572598173682 + // } + // + // futures + // + // { + // "code":1, + // "data":{ + // "list":[ + // { + // "avgPrice":"8768.99999999484997", + // "base":"BTC", + // "clOrdID":null, + // "code":"FP", + // "commission":"0.00000913", + // "createTime":"2019-11-12T07:05:52.000Z, + // "cumQty":"100", + // "id":"114380149603028993", + // "isTriggered":false, + // "lastPrice":"8769", + // "lastQty":"100", + // "leavesQty":"0", + // "leverage":"1", + // "liqType":1, + // "marketPrice":"8769.75", + // "orderID":"wJXURIFBT", + // "orderQty":"100", + // "orderStatus":3, + // "orderType":1, + // "price":"8769.75", + // "quote":"USD", + // "rejectCode":0, + // "rejectReason":null, + // "settleType":"INVERSE", + // "side":2, + // "stopPrice":"0", + // "symbol":"BTCUSDFP", + // "transactTime":"2019-11-12T07:05:52.000Z, + // "updateTime":"2019-11-12T07:05:52.000Z, + // "timeInForce":1, + // "execInst": "", + // "userID":"216214" + // }, + // ], + // "pageNum":1, + // "pageSize":10, + // "total":21 + // }, + // "message":"success", + // "ts":1573546960172 + // } + // + const data = this.safeValue (response, 'data', {}); + const orders = this.safeValue (data, 'list', []); + return this.parseOrders (orders, market, since, limit); + } + + parseOrderStatus (status) { + const statuses = { + '0': 'open', // pending new + '1': 'open', // new + '2': 'open', // partially-filled + '3': 'closed', // filled + '4': 'canceled', // cancel-reject + '5': 'canceled', // canceled + '6': 'rejected', // rejected + '10': 'expired', // expired + '11': 'rejected', // business-reject + }; + return this.safeString (statuses, status, status); + } + + parseOrderType (status) { + const statuses = { + '1': 'market', + '2': 'limit', + '3': 'stop', + '4': 'stop-limit', + '7': 'stop-loss', + '8': 'take-profit', + }; + return this.safeString (statuses, status, status); + } + + parseTimeInForce (timeInForce) { + const timeInForces = { + '1': 'GTC', + '3': 'IOC', + '4': 'FOK', + }; + return this.safeString (timeInForces, timeInForce, timeInForce); + } + + parseOrder (order, market = undefined) { + // + // { + // "avgPrice":"8768.99999999484997", + // "base":"BTC", + // "clOrdID":null, + // "code":"FP", // futures only + // "commission":"0.00000913", + // "createTime":"2019-11-12T07:05:52.000Z, + // "cumQty":"100", + // "id":"114380149603028993", // futures only + // "isTriggered":false, + // "lastPrice":"8769", + // "lastQty":"100", + // "leavesQty":"0", + // "leverage":"1", // futures only + // "liqType":1, // futures only + // "marketPrice":"8769.75", // futures only + // "orderID":"wJXURIFBT", + // "orderQty":"100", + // "orderStatus":3, + // "orderType":1, + // "price":"8769.75", + // "quote":"USD", + // "rejectCode":0, + // "rejectReason":null, + // "settleType":"INVERSE", // futures only + // "side":2, + // "stopPrice":"0", + // "symbol":"BTCUSDFP", + // "transactTime":"2019-11-12T07:05:52.000Z, + // "updateTime":"2019-11-12T07:05:52.000Z, + // "timeInForce":1, + // "execInst": "", + // "userID":"216214" + // } + // + // sometimes the timestamp is returned in milliseconds + let timestamp = this.safeValue (order, 'createTime'); + if (typeof timestamp === 'string') { + timestamp = this.parse8601 (timestamp); + } + const status = this.parseOrderStatus (this.safeString (order, 'orderStatus')); + const type = this.parseOrderType (this.safeString (order, 'orderType')); + let side = this.safeString (order, 'side'); + if (side === '1') { + side = 'buy'; + } else if (side === '2') { + side = 'sell'; + } + const id = this.safeString (order, 'orderID'); + const clientOrderId = this.safeString (order, 'clOrdID'); + const marketId = this.safeString (order, 'symbol'); + market = this.safeMarket (marketId, market); + const symbol = market['symbol']; + const price = this.safeFloat (order, 'price'); + const stopPrice = this.safeFloat (order, 'stopPrice'); + const timeInForce = this.parseTimeInForce (this.safeString (order, 'timeInForce')); + const execInst = this.safeString (order, 'execInst'); + const postOnly = (execInst === 'Post-Only'); + const average = this.safeFloat (order, 'avgPrice'); + const amount = this.safeFloat (order, 'orderQty'); + const filled = this.safeFloat (order, 'cumQty'); + const remaining = this.safeString (order, 'leavesQty'); + let cost = undefined; + let lastTradeTimestamp = undefined; + if (filled !== undefined) { + if (price !== undefined) { + cost = filled * price; + } + if (filled > 0) { + lastTradeTimestamp = this.safeValue (order, 'transactTime'); + if (typeof lastTradeTimestamp === 'string') { + lastTradeTimestamp = this.parse8601 (lastTradeTimestamp); + } + } + } + let fee = undefined; + const feeCost = this.safeFloat (order, 'commission'); + if (feeCost !== undefined) { + let feeCurrency = undefined; + if (market !== undefined) { + if (side === 'buy') { + feeCurrency = market['base']; + } else if (side === 'sell') { + feeCurrency = market['quote']; + } + } + fee = { + 'currency': feeCurrency, + 'cost': feeCost, + }; + } + return { + 'id': id, + 'info': order, + 'clientOrderId': clientOrderId, + 'timestamp': timestamp, + 'datetime': this.iso8601 (timestamp), + 'lastTradeTimestamp': lastTradeTimestamp, + 'status': status, + 'symbol': symbol, + 'type': type, + 'timeInForce': timeInForce, + 'postOnly': postOnly, + 'side': side, + 'price': price, + 'stopPrice': stopPrice, + 'average': average, + 'amount': amount, + 'filled': filled, + 'remaining': remaining, + 'cost': cost, + 'trades': undefined, + 'fee': fee, + }; + } + + async fetchMyTrades (symbol = undefined, since = undefined, limit = undefined, params = {}) { + await this.loadMarkets (); + const request = { + // 'pageNum': '1', + // 'pageSize': '10', + // 'symbol': market['id'], + // 'orderID': id, + // 'base': market['baseId'], + // 'quote': market['quoteId'], + // 'startDate': this.ymd (since), + // 'endDate': this.ymd (this.milliseconds()), + // 'orderType': undefined, // MARKET, LIMIT, STOP, STOP-LIMIT + // 'side': 'undefined', // BUY, SELL + }; + let method = undefined; + const defaultType = this.safeString2 (this.options, 'fetchMyTrades', 'defaultType', 'spot'); + let type = this.safeString (params, 'type', defaultType); + params = this.omit (params, 'type'); + let market = undefined; + if (symbol !== undefined) { + market = this.market (symbol); + request['symbol'] = market['id']; + type = market['type']; + } + if (type === 'spot') { + method = 'privateGetSpotTrades'; + } else if (type === 'futures') { + method = 'privateGetFuturesTrades'; + } + if (limit !== undefined) { + request['pageSize'] = limit; // default 10 + } + if (since !== undefined) { + request['startDate'] = this.ymd (since); + } + const response = await this[method] (this.extend (request, params)); + // + // { + // "code":1, + // "data":{ + // "list":[ + // { + // "avgPrice":"1199.8", + // "base":"ETH", + // "clOrdID":null, + // "commission":"0.00002", + // "createTime":"2021-01-11T02:47:51.512Z", + // "cumQty":"0.02", + // "filledOrderID":"1eUD4F5rwK", + // "filledPrice":"1199.8", + // "filledQty":"0.02", + // "leavesQty":"0", + // "oCreateTime":"2021-01-11T02:47:51.377Z", + // "orderID":"1eUD4EHfdU", + // "orderQty":"0.02", + // "orderStatus":3, + // "orderType":1, + // "price":"1198.25", + // "quote":"USDT", + // "rejectCode":null, + // "rejectReason":null, + // "side":1, + // "stopPrice":"0", + // "symbol":"ETHUSDT", + // "taker":true, + // "tradeID":"E04WTIgfmULU", + // "transactTime":"2021-01-11T02:47:51.389Z", + // "updateTime":null, + // "userID":"1362494" + // } + // ], + // "pageNum":1, + // "pageSize":10, + // "total":1 + // }, + // "message":"success", + // "ts":1610333278042 + // } + // + const data = this.safeValue (response, 'data', {}); + const trades = this.safeValue (data, 'list', []); + return this.parseTrades (trades, market, since, limit); + } + + async fetchDepositAddress (code, params = {}) { + await this.loadMarkets (); + const currency = this.currency (code); + const request = { + 'currency': currency['id'], + // 'network': undefined, // 'ERC20 + }; + const response = await this.privateGetAccountDepositAddress (this.extend (request, params)); + // + // { + // "code":1, + // "data":{ + // "address":"0x080c5c667381404cca9be0be9a04b2e47691ff86", + // "tag":null, + // "currency":"USDT", + // "network":"ERC20" + // }, + // "message":"success", + // "ts":1610270465132 + // } + // + const data = this.safeValue (response, 'data', {}); + return this.parseDepositAddress (data, currency); + } + + parseDepositAddress (depositAddress, currency = undefined) { + // + // { + // "address":"0x080c5c667381404cca9be0be9a04b2e47691ff86", + // "tag":null, + // "currency":"USDT", + // "network":"ERC20" + // } + // + const address = this.safeString (depositAddress, 'address'); + const tag = this.safeString (depositAddress, 'tag'); + const currencyId = this.safeString (depositAddress, 'currency'); + const code = this.safeCurrencyCode (currencyId); + return { + 'info': depositAddress, + 'code': code, + 'address': address, + 'tag': tag, + }; + } + + nonce () { + return this.milliseconds (); + } + + sign (path, api = 'public', method = 'GET', params = {}, headers = undefined, body = undefined) { + let url = '/' + this.implodeParams (path, params); + const query = this.omit (params, this.extractParams (path)); + if (api === 'v1') { + if (Object.keys (query).length) { + url += '?' + this.urlencode (query); + } + } else { + url = '/' + this.version + url; + if (api === 'public') { + if (Object.keys (query).length) { + url += '?' + this.urlencode (query); + } + } else if (api === 'private') { + this.checkRequiredCredentials (); + const nonce = this.nonce ().toString (); + headers = { + 'X-ACCESS-KEY': this.apiKey, + 'X-ACCESS-NONCE': nonce, + }; + let auth = nonce + ':' + method; + if (method === 'GET') { + if (Object.keys (query).length) { + url += '?' + this.urlencode (query); + } + auth += url; + } else { + headers['Content-Type'] = 'application/json'; + body = this.json (query); + auth += url + body; + } + const signature = this.hmac (this.encode (auth), this.encode (this.secret)); + headers['X-ACCESS-SIGN'] = signature; + } + } + url = this.implodeParams (this.urls['api'][api], { 'hostname': this.hostname }) + url; + return { 'url': url, 'method': method, 'body': body, 'headers': headers }; + } + + handleErrors (code, reason, url, method, headers, body, response, requestHeaders, requestBody) { + if (response === undefined) { + return; // fallback to default error handler + } + // + // {"code":40102,"message":"Unauthorized(invalid key)"} + // + const errorCode = this.safeString (response, 'code'); + if ((errorCode !== undefined) && (errorCode !== '1')) { + const feedback = this.id + ' ' + this.json (response); + this.throwExactlyMatchedException (this.exceptions['exact'], errorCode, feedback); + this.throwBroadlyMatchedException (this.exceptions['broad'], body, feedback); + } + } +}; + +},{"./base/Exchange":6,"./base/errors":8,"./base/functions/number":14}],4:[function(require,module,exports){ 'use strict'; // --------------------------------------------------------------------------- @@ -530,6 +2319,7 @@ module.exports = class acx extends Exchange { 'symbol': symbol, 'type': type, 'timeInForce': undefined, + 'postOnly': undefined, 'side': side, 'price': this.safeFloat (order, 'price'), 'stopPrice': undefined, @@ -669,7 +2459,7 @@ module.exports = class acx extends Exchange { } }; -},{"./base/Exchange":5,"./base/errors":7}],4:[function(require,module,exports){ +},{"./base/Exchange":6,"./base/errors":8}],5:[function(require,module,exports){ 'use strict'; // --------------------------------------------------------------------------- @@ -804,6 +2594,9 @@ module.exports = class aofex extends Exchange { 'show_all': '0', // '1' to show zero balances }, }, + 'commonCurrencies': { + 'CPC': 'Consensus Planet Coin', + }, }); } @@ -1470,6 +3263,7 @@ module.exports = class aofex extends Exchange { 'symbol': market['symbol'], 'type': type, 'timeInForce': undefined, + 'postOnly': undefined, 'side': side, 'price': price, 'stopPrice': undefined, @@ -1767,7 +3561,7 @@ module.exports = class aofex extends Exchange { } }; -},{"./base/Exchange":5,"./base/errors":7,"./base/functions/number":13}],5:[function(require,module,exports){ +},{"./base/Exchange":6,"./base/errors":8,"./base/functions/number":14}],6:[function(require,module,exports){ "use strict"; // ---------------------------------------------------------------------------- @@ -2181,20 +3975,20 @@ module.exports = class Exchange { if (!!enabled) { // eslint-disable-line no-extra-boolean-cast if ('test' in this.urls) { if (typeof this.urls['api'] === 'string') { - this.urls['api_backup'] = this.urls['api'] + this.urls['apiBackup'] = this.urls['api'] this.urls['api'] = this.urls['test'] } else { - this.urls['api_backup'] = clone (this.urls['api']) + this.urls['apiBackup'] = clone (this.urls['api']) this.urls['api'] = clone (this.urls['test']) } } else { throw new NotSupported (this.id + ' does not have a sandbox URL') } - } else if ('api_backup' in this.urls) { + } else if ('apiBackup' in this.urls) { if (typeof this.urls['api'] === 'string') { - this.urls['api'] = this.urls['api_backup'] + this.urls['api'] = this.urls['apiBackup'] } else { - this.urls['api'] = clone (this.urls['api_backup']) + this.urls['api'] = clone (this.urls['apiBackup']) } } } @@ -2346,34 +4140,31 @@ module.exports = class Exchange { handleRestResponse (response, url, method = 'GET', requestHeaders = undefined, requestBody = undefined) { return response.text ().then ((responseBody) => { - - const json = this.parseJson (responseBody) - const responseHeaders = this.getResponseHeaders (response) - + const bodyText = this.onRestResponse (response.status, response.statusText, url, method, responseHeaders, responseBody, requestHeaders, requestBody); + const json = this.parseJson (bodyText) if (this.enableLastResponseHeaders) { this.last_response_headers = responseHeaders } - if (this.enableLastHttpResponse) { this.last_http_response = responseBody } - if (this.enableLastJsonResponse) { this.last_json_response = json } - if (this.verbose) { this.print ("handleRestResponse:\n", this.id, method, url, response.status, response.statusText, "\nResponse:\n", responseHeaders, "\n", responseBody, "\n") } - this.handleErrors (response.status, response.statusText, url, method, responseHeaders, responseBody, json, requestHeaders, requestBody) this.handleHttpStatusCode (response.status, response.statusText, url, method, responseBody) - return json || responseBody }) } + onRestResponse (statusCode, statusText, url, method, responseHeaders, responseBody, requestHeaders, requestBody) { + return responseBody.trim ().replace (/:(\d{15,}),/g, ':"$1",'); + } + setMarkets (markets, currencies = undefined) { const values = Object.values (markets).map ((market) => deepExtend ({ 'limits': this.limits, @@ -2673,6 +4464,10 @@ module.exports = class Exchange { return symbols.map ((symbol) => this.marketId (symbol)) } + currencyIds (codes) { + return codes.map ((code) => this.currencyId (code)) + } + symbol (symbol) { return this.market (symbol).symbol || symbol } @@ -2806,7 +4601,7 @@ module.exports = class Exchange { array = array.filter ((entry) => entry[key] >= since) } if (limit !== undefined && limit !== null) { - array = (tail && !sinceIsDefined) ? array.slice (-limit) : array.slice (0, limit) + array = tail ? array.slice (-limit) : array.slice (0, limit) } return array } @@ -2824,18 +4619,18 @@ module.exports = class Exchange { } if (limit !== undefined && limit !== null) { - array = (tail && !sinceIsDefined) ? array.slice (-limit) : array.slice (0, limit) + array = tail ? array.slice (-limit) : array.slice (0, limit) } return array } - filterBySymbolSinceLimit (array, symbol = undefined, since = undefined, limit = undefined) { - return this.filterByValueSinceLimit (array, 'symbol', symbol, since, limit) + filterBySymbolSinceLimit (array, symbol = undefined, since = undefined, limit = undefined, tail = false) { + return this.filterByValueSinceLimit (array, 'symbol', symbol, since, limit, 'timestamp', tail) } - filterByCurrencySinceLimit (array, code = undefined, since = undefined, limit = undefined) { - return this.filterByValueSinceLimit (array, 'currency', code, since, limit) + filterByCurrencySinceLimit (array, code = undefined, since = undefined, limit = undefined, tail = false) { + return this.filterByValueSinceLimit (array, 'currency', code, since, limit, 'timestamp', tail) } filterByArray (objects, key, values = undefined, indexed = true) { @@ -2865,7 +4660,8 @@ module.exports = class Exchange { let result = Object.values (trades || []).map ((trade) => this.extend (this.parseTrade (trade, market), params)) result = sortBy (result, 'timestamp') const symbol = (market !== undefined) ? market['symbol'] : undefined - return this.filterBySymbolSinceLimit (result, symbol, since, limit) + const tail = since === undefined + return this.filterBySymbolSinceLimit (result, symbol, since, limit, tail) } parseTransactions (transactions, currency = undefined, since = undefined, limit = undefined, params = {}) { @@ -2876,7 +4672,8 @@ module.exports = class Exchange { let result = Object.values (transactions || []).map ((transaction) => this.extend (this.parseTransaction (transaction, currency), params)) result = this.sortBy (result, 'timestamp'); const code = (currency !== undefined) ? currency['code'] : undefined; - return this.filterByCurrencySinceLimit (result, code, since, limit); + const tail = since === undefined; + return this.filterByCurrencySinceLimit (result, code, since, limit, tail); } parseLedger (data, currency = undefined, since = undefined, limit = undefined, params = {}) { @@ -2894,7 +4691,8 @@ module.exports = class Exchange { } result = this.sortBy (result, 'timestamp'); const code = (currency !== undefined) ? currency['code'] : undefined; - return this.filterByCurrencySinceLimit (result, code, since, limit); + const tail = since === undefined; + return this.filterByCurrencySinceLimit (result, code, since, limit, tail); } parseOrders (orders, market = undefined, since = undefined, limit = undefined, params = {}) { @@ -2924,7 +4722,8 @@ module.exports = class Exchange { Object.entries (orders).map (([ id, order ]) => this.extend (this.parseOrder (this.extend ({ 'id': id }, order), market), params)) result = sortBy (result, 'timestamp') const symbol = (market !== undefined) ? market['symbol'] : undefined - return this.filterBySymbolSinceLimit (result, symbol, since, limit) + const tail = since === undefined + return this.filterBySymbolSinceLimit (result, symbol, since, limit, tail) } safeCurrency (currencyId, currency = undefined) { @@ -2995,19 +4794,10 @@ module.exports = class Exchange { // if (!this.isArray (ohlcvs)) { // throw new ExchangeError (this.id + ' parseOHLCVs expected an array in the ohlcvs argument, but got ' + typeof ohlcvs); // } - ohlcvs = Object.values (ohlcvs || []) - const result = [] - for (let i = 0; i < ohlcvs.length; i++) { - if (limit && (result.length >= limit)) { - break; - } - const ohlcv = this.parseOHLCV (ohlcvs[i], market) - if (since && (ohlcv[0] < since)) { - continue - } - result.push (ohlcv) - } - return this.sortBy (result, 0) + const parsed = ohlcvs.map ((ohlcv) => this.parseOHLCV (ohlcv, market)) + const sorted = this.sortBy (parsed, 0) + const tail = since === undefined + return this.filterBySinceLimit (sorted, since, limit, 0, tail) } editLimitBuyOrder (id, symbol, ...args) { @@ -3030,20 +4820,20 @@ module.exports = class Exchange { return this.createOrder (symbol, ...args) } - createLimitOrder (symbol, ...args) { - return this.createOrder (symbol, 'limit', ...args) + createLimitOrder (symbol, side, amount, price = undefined, params = {}) { + return this.createOrder (symbol, 'limit', side, amount, price, params) } - createMarketOrder (symbol, ...args) { - return this.createOrder (symbol, 'market', ...args) + createMarketOrder (symbol, side, amount, price = undefined, params = {}) { + return this.createOrder (symbol, 'market', side, amount, price, params) } - createLimitBuyOrder (symbol, ...args) { - return this.createOrder (symbol, 'limit', 'buy', ...args) + createLimitBuyOrder (symbol, amount, price = undefined, params = {}) { + return this.createOrder (symbol, 'limit', 'buy', amount, price, params) } - createLimitSellOrder (symbol, ...args) { - return this.createOrder (symbol, 'limit', 'sell', ...args) + createLimitSellOrder (symbol, amount, price = undefined, params = {}) { + return this.createOrder (symbol, 'limit', 'sell', amount, price, params) } createMarketBuyOrder (symbol, amount, params = {}) { @@ -3055,7 +4845,7 @@ module.exports = class Exchange { } costToPrecision (symbol, cost) { - return decimalToPrecision (cost, ROUND, this.markets[symbol].precision.price, this.precisionMode, this.paddingMode) + return decimalToPrecision (cost, TRUNCATE, this.markets[symbol].precision.price, this.precisionMode, this.paddingMode) } priceToPrecision (symbol, price) { @@ -3142,7 +4932,7 @@ module.exports = class Exchange { // still takes the input as a hex string // same as above but returns a string instead of an object const signature = this.signMessage (message, privateKey) - return signature['r'] + this.remove0xPrefix (signature['s']) + this.binaryToBase16 (this.numberToBE (signature['v'])); + return signature['r'] + this.remove0xPrefix (signature['s']) + this.binaryToBase16 (this.numberToBE (signature['v'])) } oath () { @@ -3166,10 +4956,79 @@ module.exports = class Exchange { integerPow (a, b) { return new BN (a).pow (new BN (b)) } + + safeOrder (order) { + // Cost + // Remaining + // Average + // Price + // Amount + // Filled + // + // First we try to calculate filled from the trades + const parseFilled = order['filled'] === undefined; + const parseCost = order['cost'] === undefined; + if (parseFilled) { + order['filled'] = 0 + } + if (parseCost) { + order['cost'] = 0 + } + if (parseFilled || parseCost) { + if (Array.isArray (order['trades'])) { + for (let i = 0; i < order['trades'].length; i++) { + const trade = order['trades'][i] + if (parseFilled) { + order['filled'] = this.sum (order['filled'], trade['amount']) + } + if (parseCost) { + order['cost'] = this.sum (order['cost'], trade['cost']) + } + } + } + } + // We ensure amount = filled + remaining + if (order['amount'] === undefined) { + if (order['filled'] !== undefined && order['remaining'] !== undefined) { + order['amount'] = this.sum (order['filled'], order['remaining']) + } + } + if (order['filled'] === undefined) { + if (order['amount'] !== undefined && order['remaining'] !== undefined) { + order['filled'] = Math.max (this.sum (order['amount'], -order['remaining']), 0) + } + } + if (order['remaining'] === undefined) { + if (order['amount'] !== undefined && order['filled'] !== undefined) { + order['remaining'] = Math.max (this.sum (order['amount'], -order['filled']), 0) + } + } + // We ensure that the average field is calculated correctly + if (order['average'] === undefined) { + if (order['filled'] !== undefined && order['cost'] !== undefined && order['cost'] > 0) { + order['average'] = order['filled'] / order['cost'] + } + } + // We also ensure the cost field is calculated correctly + const costPriceExists = (order['average'] !== undefined) || (order['price'] !== undefined) + if ((order['filled'] !== undefined) && costPriceExists) { + let costPrice = undefined; + if (order['average'] === undefined) { + costPrice = order['price'] + } else { + costPrice = order['average'] + } + order['cost'] = costPrice * order['filled'] + } + // We add support for market orders + if (order['price'] === undefined && order['type'] === 'market') { + order['price'] = order['average'] + } + return order + } } - -},{"../static_dependencies/BN/bn":123,"./errors":7,"./functions":8}],6:[function(require,module,exports){ +},{"../static_dependencies/BN/bn":126,"./errors":8,"./functions":9}],7:[function(require,module,exports){ 'use strict'; const errorHierarchy = { @@ -3215,7 +5074,7 @@ const errorHierarchy = { module.exports = errorHierarchy; -},{}],7:[function(require,module,exports){ +},{}],8:[function(require,module,exports){ 'use strict'; const errorHierarchy = require ('./errorHierarchy.js') @@ -3248,6 +5107,10 @@ function subclass (BaseClass, classes, namespace = {}) { this.__proto__ = Class.prototype this.name = className this.message = message + + // https://github.com/Microsoft/TypeScript/wiki/FAQ#why-doesnt-extending-built-ins-like-error-array-and-map-work + + Object.setPrototypeOf (this, Class.prototype) } } @@ -3268,7 +5131,7 @@ module.exports = subclass ( errorHierarchy ) -},{"./errorHierarchy.js":6}],8:[function(require,module,exports){ +},{"./errorHierarchy.js":7}],9:[function(require,module,exports){ 'use strict'; /* ------------------------------------------------------------------------ */ @@ -3298,7 +5161,7 @@ module.exports = unCamelCasePropertyNames (Object.assign ({} /* ------------------------------------------------------------------------ */ -},{"./functions/crypto":9,"./functions/encode":10,"./functions/generic":11,"./functions/misc":12,"./functions/number":13,"./functions/platform":14,"./functions/string":15,"./functions/throttle":16,"./functions/time":17,"./functions/type":18}],9:[function(require,module,exports){ +},{"./functions/crypto":10,"./functions/encode":11,"./functions/generic":12,"./functions/misc":13,"./functions/number":14,"./functions/platform":15,"./functions/string":16,"./functions/throttle":17,"./functions/time":18,"./functions/type":19}],10:[function(require,module,exports){ 'use strict' /* ------------------------------------------------------------------------ */ @@ -3458,7 +5321,7 @@ module.exports = { /* ------------------------------------------------------------------------ */ -},{"../../static_dependencies/BN/bn.js":123,"../../static_dependencies/crypto-js/crypto-js":124,"./../../static_dependencies/elliptic/lib/elliptic":125,"./../../static_dependencies/node-rsa/NodeRSA":143,"./../errors":7,"./encode":10,"./string":15}],10:[function(require,module,exports){ +},{"../../static_dependencies/BN/bn.js":126,"../../static_dependencies/crypto-js/crypto-js":127,"./../../static_dependencies/elliptic/lib/elliptic":128,"./../../static_dependencies/node-rsa/NodeRSA":146,"./../errors":8,"./encode":11,"./string":16}],11:[function(require,module,exports){ "use strict"; /* ------------------------------------------------------------------------ */ @@ -3578,7 +5441,7 @@ module.exports['byteArrayToWordArray'] = byteArrayToWordArray /* ------------------------------------------------------------------------ */ -},{"../../static_dependencies/BN/bn":123,"../../static_dependencies/crypto-js/crypto-js":124,"../../static_dependencies/qs/index":159}],11:[function(require,module,exports){ +},{"../../static_dependencies/BN/bn":126,"../../static_dependencies/crypto-js/crypto-js":127,"../../static_dependencies/qs/index":162}],12:[function(require,module,exports){ "use strict"; // ---------------------------------------------------------------------------- @@ -3816,7 +5679,7 @@ module.exports = { } -},{"./type":18}],12:[function(require,module,exports){ +},{"./type":19}],13:[function(require,module,exports){ 'use strict'; const { ROUND_UP, ROUND_DOWN } = require ('./number') @@ -3956,7 +5819,7 @@ module.exports = { /* ------------------------------------------------------------------------ */ -},{"../errors":7,"./number":13}],13:[function(require,module,exports){ +},{"../errors":8,"./number":14}],14:[function(require,module,exports){ 'use strict' /* ------------------------------------------------------------------------ @@ -4297,7 +6160,7 @@ module.exports = { /* ------------------------------------------------------------------------ */ -},{}],14:[function(require,module,exports){ +},{}],15:[function(require,module,exports){ (function (process){ "use strict"; @@ -4338,30 +6201,27 @@ module.exports = { defaultFetch, } }).call(this,require('_process')) -},{"../../static_dependencies/fetch-ponyfill/fetch-node":141,"_process":207}],15:[function(require,module,exports){ +},{"../../static_dependencies/fetch-ponyfill/fetch-node":144,"_process":210}],16:[function(require,module,exports){ "use strict"; -/* ------------------------------------------------------------------------ */ +// ---------------------------------------------------------------------------- -const uuid = a => a ? (a ^ Math.random () * 16 >> a / 4).toString (16) - : ([1e7]+-1e3+-4e3+-8e3+-1e11).replace (/[018]/g, uuid) +const uuid = a => a ? (a ^ Math.random () * 16 >> a / 4).toString (16) : ([1e7]+-1e3+-4e3+-8e3+-1e11).replace (/[018]/g, uuid) +const uuid22 = a => a ? (a ^ Math.random () * 16 >> a / 4).toString (16) : ([1e7]+1e3+4e3+8e5).replace (/[018]/g, uuid22) -module.exports = +// ---------------------------------------------------------------------------- - { uuid +module.exports = { - // hasFetchOHLCV → has_fetch_ohlcv; parseHTTPResponse → parse_http_response + uuid + , uuid22 + // hasFetchOHLCV → has_fetch_ohlcv; parseHTTPResponse → parse_http_response , unCamelCase: s => s.match (/^[A-Z0-9_]+$/) ? s : (s.replace (/[a-z0-9][A-Z]/g, x => x[0] + '_' + x[1]).replace(/[A-Z0-9][A-Z0-9][a-z]/g, x => x[0] + '_' + x[1] + x[2]).toLowerCase ()) - - , capitalize: s => s.length - ? (s.charAt (0).toUpperCase () + s.slice (1)) - : s + , capitalize: s => s.length ? (s.charAt (0).toUpperCase () + s.slice (1)) : s , strip: s => s.replace(/^\s+|\s+$/g, '') - } +} -/* ------------------------------------------------------------------------ */ - -},{}],16:[function(require,module,exports){ +},{}],17:[function(require,module,exports){ "use strict"; /* ------------------------------------------------------------------------ */ @@ -4427,7 +6287,7 @@ module.exports = { /* ------------------------------------------------------------------------ */ -},{"./time":17}],17:[function(require,module,exports){ +},{"./time":18}],18:[function(require,module,exports){ 'use strict'; /* ------------------------------------------------------------------------ */ @@ -4631,7 +6491,7 @@ module.exports = /* ------------------------------------------------------------------------ */ -},{}],18:[function(require,module,exports){ +},{}],19:[function(require,module,exports){ "use strict"; /* ------------------------------------------------------------------------ */ @@ -4699,696 +6559,7 @@ module.exports = { /* ------------------------------------------------------------------------ */ -},{}],19:[function(require,module,exports){ -'use strict'; - -// --------------------------------------------------------------------------- - -const Exchange = require ('./base/Exchange'); -const { ExchangeError, ArgumentsRequired, AuthenticationError, InsufficientFunds, InvalidOrder, OrderNotFound } = require ('./base/errors'); - -// --------------------------------------------------------------------------- - -module.exports = class bcex extends Exchange { - describe () { - return this.deepExtend (super.describe (), { - 'id': 'bcex', - 'name': 'BCEX', - 'countries': [ 'CN', 'HK' ], - 'version': '1', - 'has': { - 'cancelOrder': true, - 'createOrder': true, - 'fetchBalance': true, - 'fetchClosedOrders': 'emulated', - 'fetchMarkets': true, - 'fetchMyTrades': true, - 'fetchOpenOrders': true, - 'fetchOrder': true, - 'fetchOrders': true, - 'fetchOrderBook': true, - 'fetchTicker': true, - 'fetchTickers': false, - 'fetchTrades': true, - 'fetchTradingLimits': true, - }, - 'urls': { - 'logo': 'https://user-images.githubusercontent.com/51840849/77231516-851c6900-6bac-11ea-8fd6-ee5c23eddbd4.jpg', - 'api': 'https://www.bcex.top', - 'www': 'https://www.bcex.top', - 'doc': 'https://github.com/BCEX-TECHNOLOGY-LIMITED/API_Docs/wiki/Interface', - 'fees': 'https://bcex.udesk.cn/hc/articles/57085', - 'referral': 'https://www.bcex.top/register?invite_code=758978&lang=en', - }, - 'status': { - 'status': 'error', - 'updated': undefined, - 'eta': undefined, - 'url': undefined, - }, - 'api': { - 'public': { - 'get': [ - 'Api_Market/getPriceList', // tickers - 'Api_Order/ticker', // last ohlcv candle (ticker) - 'Api_Order/depth', // orderbook - 'Api_Market/getCoinTrade', // ticker - 'Api_Order/marketOrder', // trades... - ], - 'post': [ - 'Api_Market/getPriceList', // tickers - 'Api_Order/ticker', // last ohlcv candle (ticker) - 'Api_Order/depth', // orderbook - 'Api_Market/getCoinTrade', // ticker - 'Api_Order/marketOrder', // trades... - ], - }, - 'private': { - 'post': [ - 'Api_Order/cancel', - 'Api_Order/coinTrust', // limit order - 'Api_Order/orderList', // open / all orders (my trades?) - 'Api_Order/orderInfo', - 'Api_Order/tradeList', // open / all orders - 'Api_Order/trustList', // ? - 'Api_User/userBalance', - ], - }, - }, - 'fees': { - 'trading': { - 'tierBased': false, - 'percentage': true, - 'maker': 0.1 / 100, - 'taker': 0.2 / 100, - }, - 'funding': { - 'tierBased': false, - 'percentage': false, - 'withdraw': { - 'ckusd': 0.0, - 'other': 0.05 / 100, - }, - 'deposit': {}, - }, - }, - 'exceptions': { - '该币不存在,非法操作': ExchangeError, // { code: 1, msg: "该币不存在,非法操作" } - returned when a required symbol parameter is missing in the request (also, maybe on other types of errors as well) - '公钥不合法': AuthenticationError, // { code: 1, msg: '公钥不合法' } - wrong public key - '您的可用余额不足': InsufficientFunds, // { code: 1, msg: '您的可用余额不足' } - your available balance is insufficient - '您的btc不足': InsufficientFunds, // { code: 1, msg: '您的btc不足' } - your btc is insufficient - '参数非法': InvalidOrder, // {'code': 1, 'msg': '参数非法'} - 'Parameter illegal' - '订单信息不存在': OrderNotFound, // {'code': 1, 'msg': '订单信息不存在'} - 'Order information does not exist' - }, - 'commonCurrencies': { - 'UNI': 'UNI COIN', - 'PNT': 'Penta', - }, - 'options': { - 'limits': { - // hardcoding is deprecated, using these predefined values is not recommended, use loadTradingLimits instead - 'AFC/CKUSD': { 'precision': { 'amount': 2, 'price': 4 }, 'limits': { 'amount': { 'min': 6, 'max': 120000 }}}, - 'AFC/ETH': { 'precision': { 'amount': 2, 'price': 8 }, 'limits': { 'amount': { 'min': 6, 'max': 120000 }}}, - 'AFT/ETH': { 'precision': { 'amount': 2, 'price': 8 }, 'limits': { 'amount': { 'min': 15, 'max': 300000 }}}, - 'AICC/CNET': { 'precision': { 'amount': 2, 'price': 2 }, 'limits': { 'amount': { 'min': 5, 'max': 50000 }}}, - 'AIDOC/CKUSD': { 'precision': { 'amount': 2, 'price': 4 }, 'limits': { 'amount': { 'min': 5, 'max': 100000 }}}, - 'AISI/ETH': { 'precision': { 'amount': 4, 'price': 2 }, 'limits': { 'amount': { 'min': 0.001, 'max': 500 }}}, - 'AIT/ETH': { 'precision': { 'amount': 2, 'price': 8 }, 'limits': { 'amount': { 'min': 20, 'max': 400000 }}}, - 'ANS/BTC': { 'precision': { 'amount': 4, 'price': 8 }, 'limits': { 'amount': { 'min': 0.1, 'max': 500 }}}, - 'ANS/CKUSD': { 'precision': { 'amount': 2, 'price': 2 }, 'limits': { 'amount': { 'min': 0.1, 'max': 1000 }}}, - 'ARC/CNET': { 'precision': { 'amount': 2, 'price': 4 }, 'limits': { 'amount': { 'min': 60, 'max': 600000 }}}, - 'AXF/CNET': { 'precision': { 'amount': 2, 'price': 4 }, 'limits': { 'amount': { 'min': 100, 'max': 1000000 }}}, - 'BASH/CKUSD': { 'precision': { 'amount': 2, 'price': 4 }, 'limits': { 'amount': { 'min': 250, 'max': 3000000 }}}, - 'BATT/ETH': { 'precision': { 'amount': 2, 'price': 8 }, 'limits': { 'amount': { 'min': 60, 'max': 1500000 }}}, - 'BCD/BTC': { 'precision': { 'amount': 2, 'price': 8 }, 'limits': { 'amount': { 'min': 0.3, 'max': 7000 }}}, - 'BHPC/BTC': { 'precision': { 'amount': 2, 'price': 8 }, 'limits': { 'amount': { 'min': 2, 'max': 70000 }}}, - 'BHPC/ETH': { 'precision': { 'amount': 2, 'price': 8 }, 'limits': { 'amount': { 'min': 2, 'max': 60000 }}}, - 'BOPO/BTC': { 'precision': { 'amount': 2, 'price': 8 }, 'limits': { 'amount': { 'min': 100, 'max': 2000000 }}}, - 'BOPO/CKUSD': { 'precision': { 'amount': 2, 'price': 4 }, 'limits': { 'amount': { 'min': 100, 'max': 10000000 }}}, - 'BTC/CKUSD': { 'precision': { 'amount': 4, 'price': 2 }, 'limits': { 'amount': { 'min': 0.001, 'max': 10 }}}, - 'BTC/CNET': { 'precision': { 'amount': 4, 'price': 2 }, 'limits': { 'amount': { 'min': 0.0005, 'max': 5 }}}, - 'BTC/USDT': { 'precision': { 'amount': 4, 'price': 2 }, 'limits': { 'amount': { 'min': 0.0002, 'max': 4 }}}, - 'BTE/CNET': { 'precision': { 'amount': 2, 'price': 4 }, 'limits': { 'amount': { 'min': 25, 'max': 250000 }}}, - 'BU/ETH': { 'precision': { 'amount': 2, 'price': 8 }, 'limits': { 'amount': { 'min': 20, 'max': 400000 }}}, - 'CIC/CNET': { 'precision': { 'amount': 2, 'price': 4 }, 'limits': { 'amount': { 'min': 3000, 'max': 30000000 }}}, - 'CIT/CKUSD': { 'precision': { 'amount': 2, 'price': 4 }, 'limits': { 'amount': { 'min': 4, 'max': 40000 }}}, - 'CIT/ETH': { 'precision': { 'amount': 2, 'price': 8 }, 'limits': { 'amount': { 'min': 4, 'max': 40000 }}}, - 'CMT/CKUSD': { 'precision': { 'amount': 2, 'price': 4 }, 'limits': { 'amount': { 'min': 5, 'max': 2500000 }}}, - 'CNET/CKUSD': { 'precision': { 'amount': 2, 'price': 4 }, 'limits': { 'amount': { 'min': 12, 'max': 120000 }}}, - 'CNMC/BTC': { 'precision': { 'amount': 2, 'price': 8 }, 'limits': { 'amount': { 'min': 4, 'max': 50000 }}}, - 'CTC/ETH': { 'precision': { 'amount': 2, 'price': 8 }, 'limits': { 'amount': { 'min': 5, 'max': 550000 }}}, - 'CZR/ETH': { 'precision': { 'amount': 2, 'price': 8 }, 'limits': { 'amount': { 'min': 12, 'max': 500000 }}}, - 'DCON/ETH': { 'precision': { 'amount': 2, 'price': 8 }, 'limits': { 'amount': { 'min': 8, 'max': 300000 }}}, - 'DCT/BTC': { 'precision': { 'amount': 4, 'price': 8 }, 'limits': { 'amount': { 'min': 2, 'max': 40000 }}}, - 'DCT/CKUSD': { 'precision': { 'amount': 2, 'price': 3 }, 'limits': { 'amount': { 'min': 2, 'max': 2000 }}}, - 'DOGE/BTC': { 'precision': { 'amount': 4, 'price': 8 }, 'limits': { 'amount': { 'min': 3000, 'max': 14000000 }}}, - 'DOGE/CKUSD': { 'precision': { 'amount': 2, 'price': 6 }, 'limits': { 'amount': { 'min': 500, 'max': 2000000 }}}, - 'DRCT/ETH': { 'precision': { 'amount': 2, 'price': 8 }, 'limits': { 'amount': { 'min': 16, 'max': 190000 }}}, - 'ELA/BTC': { 'precision': { 'amount': 2, 'price': 8 }, 'limits': { 'amount': { 'min': 0.02, 'max': 500 }}}, - 'ELF/BTC': { 'precision': { 'amount': 2, 'price': 8 }, 'limits': { 'amount': { 'min': 0.1, 'max': 100000 }}}, - 'ELF/CKUSD': { 'precision': { 'amount': 2, 'price': 3 }, 'limits': { 'amount': { 'min': 0.01, 'max': 100000 }}}, - 'EOS/CKUSD': { 'precision': { 'amount': 2, 'price': 2 }, 'limits': { 'amount': { 'min': 0.5, 'max': 5000 }}}, - 'EOS/CNET': { 'precision': { 'amount': 2, 'price': 2 }, 'limits': { 'amount': { 'min': 2.5, 'max': 30000 }}}, - 'EOS/ETH': { 'precision': { 'amount': 2, 'price': 8 }, 'limits': { 'amount': { 'min': 0.18, 'max': 1800 }}}, - 'ETC/BTC': { 'precision': { 'amount': 4, 'price': 8 }, 'limits': { 'amount': { 'min': 0.2, 'max': 2500 }}}, - 'ETC/CKUSD': { 'precision': { 'amount': 2, 'price': 2 }, 'limits': { 'amount': { 'min': 0.2, 'max': 2500 }}}, - 'ETF/ETH': { 'precision': { 'amount': 2, 'price': 8 }, 'limits': { 'amount': { 'min': 7, 'max': 150000 }}}, - 'ETH/BTC': { 'precision': { 'amount': 4, 'price': 8 }, 'limits': { 'amount': { 'min': 0.015, 'max': 100 }}}, - 'ETH/CKUSD': { 'precision': { 'amount': 4, 'price': 4 }, 'limits': { 'amount': { 'min': 0.005, 'max': 100 }}}, - 'ETH/USDT': { 'precision': { 'amount': 4, 'price': 2 }, 'limits': { 'amount': { 'min': 0.005, 'max': 100 }}}, - 'FCT/BTC': { 'precision': { 'amount': 4, 'price': 8 }, 'limits': { 'amount': { 'min': 0.24, 'max': 1000 }}}, - 'FCT/CKUSD': { 'precision': { 'amount': 2, 'price': 2 }, 'limits': { 'amount': { 'min': 0.24, 'max': 1000 }}}, - 'GAME/CNET': { 'precision': { 'amount': 2, 'price': 2 }, 'limits': { 'amount': { 'min': 1, 'max': 10000 }}}, - 'GOOC/CKUSD': { 'precision': { 'amount': 2, 'price': 4 }, 'limits': { 'amount': { 'min': 200, 'max': 2000000 }}}, - 'GP/CNET': { 'precision': { 'amount': 2, 'price': 4 }, 'limits': { 'amount': { 'min': 600, 'max': 6000000 }}}, - 'HSC/ETH': { 'precision': { 'amount': 2, 'price': 8 }, 'limits': { 'amount': { 'min': 1000, 'max': 20000000 }}}, - 'IFISH/ETH': { 'precision': { 'amount': 2, 'price': 8 }, 'limits': { 'amount': { 'min': 300, 'max': 8000000 }}}, - 'IIC/ETH': { 'precision': { 'amount': 2, 'price': 8 }, 'limits': { 'amount': { 'min': 50, 'max': 4000000 }}}, - 'IMOS/ETH': { 'precision': { 'amount': 2, 'price': 8 }, 'limits': { 'amount': { 'min': 15, 'max': 300000 }}}, - 'JC/CNET': { 'precision': { 'amount': 2, 'price': 4 }, 'limits': { 'amount': { 'min': 300, 'max': 3000000 }}}, - 'LBTC/BTC': { 'precision': { 'amount': 2, 'price': 8 }, 'limits': { 'amount': { 'min': 0.1, 'max': 3000 }}}, - 'LEC/CNET': { 'precision': { 'amount': 2, 'price': 4 }, 'limits': { 'amount': { 'min': 500, 'max': 5000000 }}}, - 'LKY/CKUSD': { 'precision': { 'amount': 2, 'price': 4 }, 'limits': { 'amount': { 'min': 10, 'max': 70000 }}}, - 'LKY/ETH': { 'precision': { 'amount': 2, 'price': 8 }, 'limits': { 'amount': { 'min': 10, 'max': 100000 }}}, - 'LMC/CNET': { 'precision': { 'amount': 2, 'price': 4 }, 'limits': { 'amount': { 'min': 25, 'max': 250000 }}}, - 'LSK/CNET': { 'precision': { 'amount': 2, 'price': 2 }, 'limits': { 'amount': { 'min': 0.3, 'max': 3000 }}}, - 'LTC/BTC': { 'precision': { 'amount': 4, 'price': 8 }, 'limits': { 'amount': { 'min': 0.01, 'max': 500 }}}, - 'LTC/CKUSD': { 'precision': { 'amount': 2, 'price': 2 }, 'limits': { 'amount': { 'min': 0.01, 'max': 500 }}}, - 'LTC/USDT': { 'precision': { 'amount': 4, 'price': 2 }, 'limits': { 'amount': { 'min': 0.02, 'max': 450 }}}, - 'MC/CNET': { 'precision': { 'amount': 2, 'price': 6 }, 'limits': { 'amount': { 'min': 10000, 'max': 100000000 }}}, - 'MCC/CKUSD': { 'precision': { 'amount': 2, 'price': 4 }, 'limits': { 'amount': { 'min': 30, 'max': 350000 }}}, - 'MOC/ETH': { 'precision': { 'amount': 2, 'price': 8 }, 'limits': { 'amount': { 'min': 25, 'max': 600000 }}}, - 'MRYC/CNET': { 'precision': { 'amount': 2, 'price': 4 }, 'limits': { 'amount': { 'min': 300, 'max': 3000000 }}}, - 'MT/ETH': { 'precision': { 'amount': 2, 'price': 8 }, 'limits': { 'amount': { 'min': 200, 'max': 6000000 }}}, - 'MXI/CNET': { 'precision': { 'amount': 2, 'price': 6 }, 'limits': { 'amount': { 'min': 5000, 'max': 60000000 }}}, - 'NAI/ETH': { 'precision': { 'amount': 2, 'price': 8 }, 'limits': { 'amount': { 'min': 10, 'max': 100000 }}}, - 'NAS/BTC': { 'precision': { 'amount': 4, 'price': 8 }, 'limits': { 'amount': { 'min': 0.2, 'max': 15000 }}}, - 'NAS/CKUSD': { 'precision': { 'amount': 2, 'price': 2 }, 'limits': { 'amount': { 'min': 0.5, 'max': 5000 }}}, - 'NEWOS/ETH': { 'precision': { 'amount': 2, 'price': 8 }, 'limits': { 'amount': { 'min': 65, 'max': 700000 }}}, - 'NKN/ETH': { 'precision': { 'amount': 2, 'price': 8 }, 'limits': { 'amount': { 'min': 3, 'max': 350000 }}}, - 'NTK/ETH': { 'precision': { 'amount': 2, 'price': 8 }, 'limits': { 'amount': { 'min': 2, 'max': 30000 }}}, - 'ONT/CKUSD': { 'precision': { 'amount': 2, 'price': 3 }, 'limits': { 'amount': { 'min': 0.2, 'max': 2000 }}}, - 'ONT/ETH': { 'precision': { 'amount': 3, 'price': 8 }, 'limits': { 'amount': { 'min': 0.01, 'max': 1000 }}}, - 'PNT/ETH': { 'precision': { 'amount': 2, 'price': 8 }, 'limits': { 'amount': { 'min': 80, 'max': 800000 }}}, - 'PST/ETH': { 'precision': { 'amount': 2, 'price': 8 }, 'limits': { 'amount': { 'min': 5, 'max': 100000 }}}, - 'PTT/ETH': { 'precision': { 'amount': 2, 'price': 8 }, 'limits': { 'amount': { 'min': 450, 'max': 10000000 }}}, - 'QTUM/BTC': { 'precision': { 'amount': 4, 'price': 8 }, 'limits': { 'amount': { 'min': 0.4, 'max': 2800 }}}, - 'QTUM/CKUSD': { 'precision': { 'amount': 2, 'price': 2 }, 'limits': { 'amount': { 'min': 0.1, 'max': 1000 }}}, - 'RATING/ETH': { 'precision': { 'amount': 2, 'price': 8 }, 'limits': { 'amount': { 'min': 500, 'max': 10000000 }}}, - 'RHC/CNET': { 'precision': { 'amount': 2, 'price': 4 }, 'limits': { 'amount': { 'min': 1000, 'max': 10000000 }}}, - 'SDA/ETH': { 'precision': { 'amount': 2, 'price': 8 }, 'limits': { 'amount': { 'min': 20, 'max': 500000 }}}, - 'SDD/CKUSD': { 'precision': { 'amount': 2, 'price': 3 }, 'limits': { 'amount': { 'min': 10, 'max': 100000 }}}, - 'SHC/CNET': { 'precision': { 'amount': 2, 'price': 4 }, 'limits': { 'amount': { 'min': 250, 'max': 2500000 }}}, - 'SHE/ETH': { 'precision': { 'amount': 2, 'price': 8 }, 'limits': { 'amount': { 'min': 100, 'max': 5000000 }}}, - 'SMC/CNET': { 'precision': { 'amount': 2, 'price': 6 }, 'limits': { 'amount': { 'min': 1000, 'max': 10000000 }}}, - 'SOP/ETH': { 'precision': { 'amount': 2, 'price': 8 }, 'limits': { 'amount': { 'min': 50, 'max': 1000000 }}}, - 'TAC/ETH': { 'precision': { 'amount': 2, 'price': 8 }, 'limits': { 'amount': { 'min': 35, 'max': 800000 }}}, - 'TIP/ETH': { 'precision': { 'amount': 2, 'price': 8 }, 'limits': { 'amount': { 'min': 7, 'max': 200000 }}}, - 'TKT/ETH': { 'precision': { 'amount': 2, 'price': 8 }, 'limits': { 'amount': { 'min': 40, 'max': 400000 }}}, - 'TLC/ETH': { 'precision': { 'amount': 2, 'price': 8 }, 'limits': { 'amount': { 'min': 500, 'max': 10000000 }}}, - 'TNC/ETH': { 'precision': { 'amount': 2, 'price': 8 }, 'limits': { 'amount': { 'min': 10, 'max': 110000 }}}, - 'TUB/ETH': { 'precision': { 'amount': 2, 'price': 8 }, 'limits': { 'amount': { 'min': 200, 'max': 8000000 }}}, - 'UC/ETH': { 'precision': { 'amount': 2, 'price': 8 }, 'limits': { 'amount': { 'min': 100, 'max': 3000000 }}}, - 'UDB/CNET': { 'precision': { 'amount': 2, 'price': 6 }, 'limits': { 'amount': { 'min': 2000, 'max': 40000000 }}}, - 'UIC/CKUSD': { 'precision': { 'amount': 2, 'price': 4 }, 'limits': { 'amount': { 'min': 5, 'max': 150000 }}}, - 'VAAC/ETH': { 'precision': { 'amount': 2, 'price': 8 }, 'limits': { 'amount': { 'min': 10, 'max': 250000 }}}, - 'VPN/CNET': { 'precision': { 'amount': 2, 'price': 4 }, 'limits': { 'amount': { 'min': 200, 'max': 2000000 }}}, - 'VSC/ETH': { 'precision': { 'amount': 2, 'price': 8 }, 'limits': { 'amount': { 'min': 30, 'max': 650000 }}}, - 'WAVES/CKUSD': { 'precision': { 'amount': 2, 'price': 3 }, 'limits': { 'amount': { 'min': 0.15, 'max': 1500 }}}, - 'WDNA/ETH': { 'precision': { 'amount': 2, 'price': 8 }, 'limits': { 'amount': { 'min': 100, 'max': 250000 }}}, - 'WIC/CKUSD': { 'precision': { 'amount': 2, 'price': 4 }, 'limits': { 'amount': { 'min': 3, 'max': 30000 }}}, - 'XAS/CNET': { 'precision': { 'amount': 2, 'price': 2 }, 'limits': { 'amount': { 'min': 2.5, 'max': 25000 }}}, - 'XLM/BTC': { 'precision': { 'amount': 4, 'price': 8 }, 'limits': { 'amount': { 'min': 10, 'max': 300000 }}}, - 'XLM/CKUSD': { 'precision': { 'amount': 2, 'price': 4 }, 'limits': { 'amount': { 'min': 1, 'max': 300000 }}}, - 'XLM/USDT': { 'precision': { 'amount': 2, 'price': 4 }, 'limits': { 'amount': { 'min': 5, 'max': 150000 }}}, - 'XRP/BTC': { 'precision': { 'amount': 4, 'price': 8 }, 'limits': { 'amount': { 'min': 24, 'max': 100000 }}}, - 'XRP/CKUSD': { 'precision': { 'amount': 2, 'price': 3 }, 'limits': { 'amount': { 'min': 5, 'max': 50000 }}}, - 'YBCT/BTC': { 'precision': { 'amount': 4, 'price': 8 }, 'limits': { 'amount': { 'min': 15, 'max': 200000 }}}, - 'YBCT/CKUSD': { 'precision': { 'amount': 2, 'price': 4 }, 'limits': { 'amount': { 'min': 10, 'max': 200000 }}}, - 'YBY/CNET': { 'precision': { 'amount': 2, 'price': 6 }, 'limits': { 'amount': { 'min': 25000, 'max': 250000000 }}}, - 'ZEC/BTC': { 'precision': { 'amount': 4, 'price': 8 }, 'limits': { 'amount': { 'min': 0.02, 'max': 100 }}}, - 'ZEC/CKUSD': { 'precision': { 'amount': 4, 'price': 2 }, 'limits': { 'amount': { 'min': 0.02, 'max': 100 }}}, - }, - }, - }); - } - - async fetchTradingLimits (symbols = undefined, params = {}) { - // this method should not be called directly, use loadTradingLimits () instead - // by default it will try load withdrawal fees of all currencies (with separate requests, sequentially) - // however if you define symbols = [ 'ETH/BTC', 'LTC/BTC' ] in args it will only load those - await this.loadMarkets (); - if (symbols === undefined) { - symbols = this.symbols; - } - const result = {}; - for (let i = 0; i < symbols.length; i++) { - const symbol = symbols[i]; - result[symbol] = await this.fetchTradingLimitsById (this.marketId (symbol), params); - } - return result; - } - - async fetchTradingLimitsById (id, params = {}) { - const request = { - 'symbol': id, - }; - const response = await this.publicPostApiOrderTicker (this.extend (request, params)); - // - // { code: 0, - // msg: "获取牌价信息成功", - // data: { high: 0.03721392, - // low: 0.03335362, - // buy: "0.03525757", - // sell: "0.03531160", - // last: 0.0352634, - // vol: "184742.4176", - // min_trade: "0.01500000", - // max_trade: "100.00000000", - // number_float: "4", - // price_float: "8" } } } - // - return this.parseTradingLimits (this.safeValue (response, 'data', {})); - } - - parseTradingLimits (limits, symbol = undefined, params = {}) { - // - // { high: 0.03721392, - // low: 0.03335362, - // buy: "0.03525757", - // sell: "0.03531160", - // last: 0.0352634, - // vol: "184742.4176", - // min_trade: "0.01500000", - // max_trade: "100.00000000", - // number_float: "4", - // price_float: "8" } - // - return { - 'info': limits, - 'precision': { - 'amount': this.safeInteger (limits, 'number_float'), - 'price': this.safeInteger (limits, 'price_float'), - }, - 'limits': { - 'amount': { - 'min': this.safeFloat (limits, 'min_trade'), - 'max': this.safeFloat (limits, 'max_trade'), - }, - }, - }; - } - - async fetchMarkets (params = {}) { - const response = await this.publicGetApiMarketGetPriceList (params); - const result = []; - const keys = Object.keys (response); - for (let i = 0; i < keys.length; i++) { - const currentMarketId = keys[i]; - const currentMarkets = response[currentMarketId]; - for (let j = 0; j < currentMarkets.length; j++) { - const market = currentMarkets[j]; - const baseId = this.safeString (market, 'coin_from'); - const quoteId = this.safeString (market, 'coin_to'); - let base = baseId.toUpperCase (); - let quote = quoteId.toUpperCase (); - base = this.safeCurrencyCode (base); - quote = this.safeCurrencyCode (quote); - const id = baseId + '2' + quoteId; - const symbol = base + '/' + quote; - const active = true; - const defaults = this.safeValue (this.options['limits'], symbol, {}); - result.push (this.extend ({ - 'id': id, - 'symbol': symbol, - 'base': base, - 'quote': quote, - 'baseId': baseId, - 'quoteId': quoteId, - 'active': active, - // overrided by defaults from this.options['limits'] - 'precision': { - 'amount': undefined, - 'price': undefined, - }, - // overrided by defaults from this.options['limits'] - 'limits': { - 'amount': { 'min': undefined, 'max': undefined }, - 'price': { 'min': undefined, 'max': undefined }, - 'cost': { 'min': undefined, 'max': undefined }, - }, - 'info': market, - }, defaults)); - } - } - return result; - } - - parseTrade (trade, market = undefined) { - let symbol = undefined; - if (market !== undefined) { - symbol = market['symbol']; - } - const timestamp = this.safeTimestamp2 (trade, 'date', 'created'); - const id = this.safeString (trade, 'tid'); - const orderId = this.safeString (trade, 'order_id'); - const amount = this.safeFloat2 (trade, 'number', 'amount'); - const price = this.safeFloat (trade, 'price'); - let cost = undefined; - if (price !== undefined) { - if (amount !== undefined) { - cost = amount * price; - } - } - let side = this.safeString (trade, 'side'); - if (side === 'sale') { - side = 'sell'; - } - return { - 'info': trade, - 'id': id, - 'timestamp': timestamp, - 'datetime': this.iso8601 (timestamp), - 'symbol': symbol, - 'type': undefined, - 'side': side, - 'price': price, - 'amount': amount, - 'cost': cost, - 'order': orderId, - 'fee': undefined, - 'takerOrMaker': undefined, - }; - } - - async fetchTrades (symbol, since = undefined, limit = undefined, params = {}) { - await this.loadMarkets (); - const request = { - 'symbol': this.marketId (symbol), - }; - if (limit !== undefined) { - request['limit'] = limit; - } - const market = this.market (symbol); - const response = await this.publicPostApiOrderMarketOrder (this.extend (request, params)); - return this.parseTrades (response['data'], market, since, limit); - } - - async fetchBalance (params = {}) { - await this.loadMarkets (); - const response = await this.privatePostApiUserUserBalance (params); - const data = this.safeValue (response, 'data'); - let keys = Object.keys (data); - const result = { }; - for (let i = 0; i < keys.length; i++) { - const key = keys[i]; - const amount = this.safeFloat (data, key); - const parts = key.split ('_'); - const currencyId = parts[0]; - const lockOrOver = parts[1]; - const code = this.safeCurrencyCode (currencyId); - if (!(code in result)) { - result[code] = this.account (); - } - if (lockOrOver === 'lock') { - result[code]['used'] = parseFloat (amount); - } else { - result[code]['free'] = parseFloat (amount); - } - } - keys = Object.keys (result); - for (let i = 0; i < keys.length; i++) { - const key = keys[i]; - const total = this.sum (result[key]['used'], result[key]['free']); - result[key]['total'] = total; - } - result['info'] = data; - return this.parseBalance (result); - } - - async fetchTicker (symbol, params = {}) { - await this.loadMarkets (); - const market = this.markets[symbol]; - const request = { - 'part': market['quoteId'], - 'coin': market['baseId'], - }; - const response = await this.publicPostApiMarketGetCoinTrade (this.extend (request, params)); - const timestamp = this.milliseconds (); - return { - 'symbol': symbol, - 'timestamp': timestamp, - 'datetime': this.iso8601 (timestamp), - 'high': this.safeFloat (response, 'max'), - 'low': this.safeFloat (response, 'min'), - 'bid': this.safeFloat (response, 'buy'), - 'bidVolume': undefined, - 'ask': this.safeFloat (response, 'sale'), - 'askVolume': undefined, - 'vwap': undefined, - 'open': undefined, - 'close': this.safeFloat (response, 'price'), - 'last': this.safeFloat (response, 'price'), - 'previousClose': undefined, - 'change': undefined, - 'percentage': this.safeFloat (response, 'change_24h'), - 'average': undefined, - 'baseVolume': this.safeFloat (response, 'volume_24h'), - 'quoteVolume': undefined, - 'info': response, - }; - } - - async fetchOrderBook (symbol, limit = undefined, params = {}) { - await this.loadMarkets (); - const marketId = this.marketId (symbol); - const request = { - 'symbol': marketId, - }; - const response = await this.publicPostApiOrderDepth (this.extend (request, params)); - const data = this.safeValue (response, 'data'); - const timestamp = this.safeTimestamp (data, 'date'); - return this.parseOrderBook (data, timestamp); - } - - async fetchMyTrades (symbol = undefined, since = undefined, limit = undefined, params = {}) { - await this.loadMarkets (); - const market = this.market (symbol); - const request = { - 'symbol': market['id'], - }; - const response = await this.privatePostApiOrderOrderList (this.extend (request, params)); - return this.parseTrades (response['data'], market, since, limit); - } - - parseOrderStatus (status) { - const statuses = { - '0': 'open', - '1': 'open', // partially filled - '2': 'closed', - '3': 'canceled', - }; - return this.safeString (statuses, status, status); - } - - async fetchOrder (id, symbol = undefined, params = {}) { - if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' fetchOrder requires a `symbol` argument'); - } - await this.loadMarkets (); - const request = { - 'symbol': this.marketId (symbol), - 'trust_id': id, - }; - const response = await this.privatePostApiOrderOrderInfo (this.extend (request, params)); - const order = this.safeValue (response, 'data'); - const timestamp = this.safeTimestamp (order, 'created'); - const status = this.parseOrderStatus (this.safeString (order, 'status')); - let side = this.safeString (order, 'flag'); - if (side === 'sale') { - side = 'sell'; - } - // Can't use parseOrder because the data format is different btw endpoint for fetchOrder and fetchOrders - return { - 'info': order, - 'id': id, - 'timestamp': timestamp, - 'datetime': this.iso8601 (timestamp), - 'lastTradeTimestamp': undefined, - 'symbol': symbol, - 'type': undefined, - 'side': side, - 'price': this.safeFloat (order, 'price'), - 'cost': undefined, - 'average': this.safeFloat (order, 'avg_price'), - 'amount': this.safeFloat (order, 'number'), - 'filled': this.safeFloat (order, 'numberdeal'), - 'remaining': this.safeFloat (order, 'numberover'), - 'status': status, - 'fee': undefined, - 'clientOrderId': undefined, - 'trades': undefined, - }; - } - - parseOrder (order, market = undefined) { - const id = this.safeString (order, 'id'); - const timestamp = this.safeTimestamp (order, 'datetime'); - let symbol = undefined; - if (market !== undefined) { - symbol = market['symbol']; - } - const type = undefined; - let side = this.safeString (order, 'type'); - if (side === 'sale') { - side = 'sell'; - } - const price = this.safeFloat (order, 'price'); - const average = this.safeFloat (order, 'avg_price'); - const amount = this.safeFloat (order, 'amount'); - const remaining = this.safeFloat (order, 'amount_outstanding'); - const filled = amount - remaining; - const status = this.parseOrderStatus (this.safeString (order, 'status')); - const cost = filled * price; - const fee = undefined; - const result = { - 'info': order, - 'id': id, - 'clientOrderId': undefined, - 'timestamp': timestamp, - 'datetime': this.iso8601 (timestamp), - 'lastTradeTimestamp': undefined, - 'symbol': symbol, - 'type': type, - 'timeInForce': undefined, - 'side': side, - 'price': price, - 'stopPrice': undefined, - 'cost': cost, - 'average': average, - 'amount': amount, - 'filled': filled, - 'remaining': remaining, - 'status': status, - 'fee': fee, - 'trades': undefined, - }; - return result; - } - - async fetchOrdersByType (type, symbol = undefined, since = undefined, limit = undefined, params = {}) { - await this.loadMarkets (); - const request = { - 'type': type, - }; - let market = undefined; - if (symbol !== undefined) { - market = this.market (symbol); - request['symbol'] = market['id']; - } - const response = await this.privatePostApiOrderTradeList (this.extend (request, params)); - if ('data' in response) { - return this.parseOrders (response['data'], market, since, limit); - } - return []; - } - - async fetchOpenOrders (symbol = undefined, since = undefined, limit = undefined, params = {}) { - return this.fetchOrdersByType ('open', symbol, since, limit, params); - } - - async fetchClosedOrders (symbol = undefined, since = undefined, limit = undefined, params = {}) { - const orders = await this.fetchOrders (symbol, since, limit, params); - return this.filterBy (orders, 'status', 'closed'); - } - - async fetchOrders (symbol = undefined, since = undefined, limit = undefined, params = {}) { - return this.fetchOrdersByType ('all', symbol, since, limit, params); - } - - async createOrder (symbol, type, side, amount, price = undefined, params = {}) { - await this.loadMarkets (); - const request = { - 'symbol': this.marketId (symbol), - 'type': side, - 'price': this.priceToPrecision (symbol, price), - 'number': this.amountToPrecision (symbol, amount), - }; - const response = await this.privatePostApiOrderCoinTrust (this.extend (request, params)); - const data = this.safeValue (response, 'data', {}); - const id = this.safeString (data, 'order_id'); - return { - 'info': response, - 'id': id, - }; - } - - async cancelOrder (id, symbol = undefined, params = {}) { - if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' cancelOrder requires a `symbol` argument'); - } - await this.loadMarkets (); - const request = {}; - if (symbol !== undefined) { - request['symbol'] = this.marketId (symbol); - } - if (id !== undefined) { - request['order_id'] = id; - } - return await this.privatePostApiOrderCancel (this.extend (request, params)); - } - - sign (path, api = 'public', method = 'GET', params = {}, headers = undefined, body = undefined) { - let url = this.urls['api'] + '/' + this.implodeParams (path, params); - const query = this.omit (params, this.extractParams (path)); - if (api === 'public') { - if (Object.keys (query).length) { - url += '?' + this.urlencode (query); - } - } else { - this.checkRequiredCredentials (); - let payload = this.urlencode ({ 'api_key': this.apiKey }); - if (Object.keys (query).length) { - payload += '&' + this.urlencode (this.keysort (query)); - } - const auth = payload + '&secret_key=' + this.secret; - const signature = this.hash (this.encode (auth)); - body = payload + '&sign=' + signature; - headers = { - 'Content-Type': 'application/x-www-form-urlencoded', - }; - } - return { 'url': url, 'method': method, 'body': body, 'headers': headers }; - } - - handleErrors (code, reason, url, method, headers, body, response, requestHeaders, requestBody) { - if (response === undefined) { - return; // fallback to default error handler - } - const errorCode = this.safeValue (response, 'code'); - if (errorCode !== undefined) { - if (errorCode !== 0) { - // - // { code: 1, msg: "该币不存在,非法操作" } - returned when a required symbol parameter is missing in the request (also, maybe on other types of errors as well) - // { code: 1, msg: '公钥不合法' } - wrong public key - // { code: 1, msg: '价格输入有误,请检查你的数值精度' } - 'The price input is incorrect, please check your numerical accuracy' - // { code: 1, msg: '单笔最小交易数量不能小于0.00100000,请您重新挂单'} - - // 'The minimum number of single transactions cannot be less than 0.00100000. Please re-post the order' - // - const message = this.safeString (response, 'msg'); - const feedback = this.id + ' ' + message; - this.throwExactlyMatchedException (this.exceptions, message, feedback); - if (message.indexOf ('请您重新挂单') >= 0) { // minimum limit - throw new InvalidOrder (feedback); - } else { - throw new ExchangeError (feedback); - } - } - } - } -}; - -},{"./base/Exchange":5,"./base/errors":7}],20:[function(require,module,exports){ +},{}],20:[function(require,module,exports){ 'use strict'; // --------------------------------------------------------------------------- @@ -5422,13 +6593,13 @@ module.exports = class bequant extends hitbtc { } }; -},{"./hitbtc":89}],21:[function(require,module,exports){ +},{"./hitbtc":93}],21:[function(require,module,exports){ 'use strict'; // --------------------------------------------------------------------------- const Exchange = require ('./base/Exchange'); -const { ExchangeError, AccountSuspended, ArgumentsRequired, AuthenticationError, DDoSProtection, ExchangeNotAvailable, InvalidOrder, OrderNotFound, PermissionDenied, InsufficientFunds, BadSymbol } = require ('./base/errors'); +const { ExchangeError, AccountSuspended, ArgumentsRequired, AuthenticationError, DDoSProtection, ExchangeNotAvailable, InvalidOrder, OrderNotFound, PermissionDenied, InsufficientFunds, BadSymbol, RateLimitExceeded, BadRequest } = require ('./base/errors'); // --------------------------------------------------------------------------- @@ -5496,6 +6667,7 @@ module.exports = class bibox extends Exchange { 'get': [ 'cquery', 'mdata', + 'cdata', ], }, 'private': { @@ -5533,9 +6705,16 @@ module.exports = class bibox extends Exchange { '2021': InsufficientFunds, // Insufficient balance available for withdrawal '2027': InsufficientFunds, // Insufficient balance available (for trade) '2033': OrderNotFound, // operation failed! Orders have been completed or revoked + '2065': InvalidOrder, // Precatory price is exorbitant, please reset + '2066': InvalidOrder, // Precatory price is low, please reset '2067': InvalidOrder, // Does not support market orders '2068': InvalidOrder, // The number of orders can not be less than + '2078': InvalidOrder, // unvalid order price '2085': InvalidOrder, // Order quantity is too small + '2091': RateLimitExceeded, // request is too frequency, please try again later + '2092': InvalidOrder, // Minimum amount not met + '3000': BadRequest, // Requested parameter incorrect + '3002': BadRequest, // Parameter cannot be null '3012': AuthenticationError, // invalid apiKey '3016': BadSymbol, // Trading pair error '3024': PermissionDenied, // wrong apikey permissions @@ -5549,6 +6728,10 @@ module.exports = class bibox extends Exchange { 'KEY': 'Bihu', 'MTC': 'MTC Mesh Network', // conflict with MTC Docademic doc.com Token https://github.com/ccxt/ccxt/issues/6081 https://github.com/ccxt/ccxt/issues/3025 'PAI': 'PCHAIN', + 'TERN': 'Ternio-ERC20', + }, + 'options': { + 'fetchCurrencies': 'fetch_currencies_public', // or 'fetch_currencies_private' with apiKey and secret }, }); } @@ -5848,6 +7031,78 @@ module.exports = class bibox extends Exchange { } async fetchCurrencies (params = {}) { + const method = this.safeString (this.options, 'fetchCurrencies', 'fetch_currencies_public'); + return await this[method] (params); + } + + async fetchCurrenciesPublic (params = {}) { + const request = { + 'cmd': 'currencies', + }; + const response = await this.publicGetCdata (this.extend (request, params)); + // + // publicGetCdata + // + // { + // "result":[ + // { + // "symbol":"BTC", + // "name":"BTC", + // "valid_decimals":8, + // "original_decimals":8, + // "is_erc20":0, + // "enable_withdraw":1, + // "enable_deposit":1, + // "withdraw_min":0.005, + // "describe_summary":"[{\"lang\":\"zh-cn\",\"text\":\"Bitcoin 比特币的概念最初由中本聪在2009年提出,是点对点的基于 SHA-256 算法的一种P2P形式的数字货币,点对点的传输意味着一个去中心化的支付系统。\"},{\"lang\":\"en-ww\",\"text\":\"Bitcoin is a digital asset and a payment system invented by Satoshi Nakamoto who published a related paper in 2008 and released it as open-source software in 2009. The system featured as peer-to-peer; users can transact directly without an intermediary.\"}]" + // } + // ], + // "cmd":"currencies" + // } + // + const currencies = this.safeValue (response, 'result'); + const result = {}; + for (let i = 0; i < currencies.length; i++) { + const currency = currencies[i]; + const id = this.safeString (currency, 'symbol'); + const name = this.safeString (currency, 'name'); // contains hieroglyphs causing python ASCII bug + const code = this.safeCurrencyCode (id); + const precision = this.safeInteger (currency, 'valid_decimals'); + const deposit = this.safeValue (currency, 'enable_deposit'); + const withdraw = this.safeValue (currency, 'enable_withdraw'); + const active = (deposit && withdraw); + result[code] = { + 'id': id, + 'code': code, + 'info': currency, + 'name': name, + 'active': active, + 'fee': undefined, + 'precision': precision, + 'limits': { + 'amount': { + 'min': Math.pow (10, -precision), + 'max': undefined, + }, + 'price': { + 'min': Math.pow (10, -precision), + 'max': undefined, + }, + 'cost': { + 'min': undefined, + 'max': undefined, + }, + 'withdraw': { + 'min': this.safeFloat (currency, 'withdraw_min'), + 'max': undefined, + }, + }, + }; + } + return result; + } + + async fetchCurrenciesPrivate (params = {}) { if (!this.apiKey || !this.secret) { throw new AuthenticationError (this.id + " fetchCurrencies is an authenticated endpoint, therefore it requires 'apiKey' and 'secret' credentials. If you don't need currency details, set exchange.has['fetchCurrencies'] = false before calling its methods."); } @@ -5860,46 +7115,42 @@ module.exports = class bibox extends Exchange { // { // "result":[ // { - // "result":[ - // { - // "totalBalance":"14.57582269", - // "balance":"14.57582269", - // "freeze":"0.00000000", - // "id":60, - // "symbol":"USDT", - // "icon_url":"/appimg/USDT_icon.png", - // "describe_url":"[{\"lang\":\"zh-cn\",\"link\":\"https://bibox.zendesk.com/hc/zh-cn/articles/115004798234\"},{\"lang\":\"en-ww\",\"link\":\"https://bibox.zendesk.com/hc/en-us/articles/115004798234\"}]", - // "name":"USDT", - // "enable_withdraw":1, - // "enable_deposit":1, - // "enable_transfer":1, - // "confirm_count":2, - // "is_erc20":1, - // "forbid_info":null, - // "describe_summary":"[{\"lang\":\"zh-cn\",\"text\":\"USDT 是 Tether 公司推出的基于稳定价值货币美元(USD)的代币 Tether USD(简称USDT),1USDT=1美元,用户可以随时使用 USDT 与 USD 进行1:1的兑换。\"},{\"lang\":\"en-ww\",\"text\":\"USDT is a cryptocurrency asset issued on the Bitcoin blockchain via the Omni Layer Protocol. Each USDT unit is backed by a U.S Dollar held in the reserves of the Tether Limited and can be redeemed through the Tether Platform.\"}]", - // "total_amount":4776930644, - // "supply_amount":4642367414, - // "price":"--", - // "contract_father":"OMNI", - // "supply_time":"--", - // "comment":null, - // "contract":"31", - // "original_decimals":8, - // "deposit_type":0, - // "hasCobo":0, - // "BTCValue":"0.00126358", - // "CNYValue":"100.93381445", - // "USDValue":"14.57524654", - // "children":[ - // {"type":"OMNI","symbol":"USDT","enable_deposit":1,"enable_withdraw":1,"confirm_count":2}, - // {"type":"TRC20","symbol":"tUSDT","enable_deposit":1,"enable_withdraw":1,"confirm_count":20}, - // {"type":"ERC20","symbol":"eUSDT","enable_deposit":1,"enable_withdraw":1,"confirm_count":25} - // ] - // }, - // ], - // "cmd":"transfer/coinList" - // } - // ] + // "totalBalance":"14.57582269", + // "balance":"14.57582269", + // "freeze":"0.00000000", + // "id":60, + // "symbol":"USDT", + // "icon_url":"/appimg/USDT_icon.png", + // "describe_url":"[{\"lang\":\"zh-cn\",\"link\":\"https://bibox.zendesk.com/hc/zh-cn/articles/115004798234\"},{\"lang\":\"en-ww\",\"link\":\"https://bibox.zendesk.com/hc/en-us/articles/115004798234\"}]", + // "name":"USDT", + // "enable_withdraw":1, + // "enable_deposit":1, + // "enable_transfer":1, + // "confirm_count":2, + // "is_erc20":1, + // "forbid_info":null, + // "describe_summary":"[{\"lang\":\"zh-cn\",\"text\":\"USDT 是 Tether 公司推出的基于稳定价值货币美元(USD)的代币 Tether USD(简称USDT),1USDT=1美元,用户可以随时使用 USDT 与 USD 进行1:1的兑换。\"},{\"lang\":\"en-ww\",\"text\":\"USDT is a cryptocurrency asset issued on the Bitcoin blockchain via the Omni Layer Protocol. Each USDT unit is backed by a U.S Dollar held in the reserves of the Tether Limited and can be redeemed through the Tether Platform.\"}]", + // "total_amount":4776930644, + // "supply_amount":4642367414, + // "price":"--", + // "contract_father":"OMNI", + // "supply_time":"--", + // "comment":null, + // "contract":"31", + // "original_decimals":8, + // "deposit_type":0, + // "hasCobo":0, + // "BTCValue":"0.00126358", + // "CNYValue":"100.93381445", + // "USDValue":"14.57524654", + // "children":[ + // {"type":"OMNI","symbol":"USDT","enable_deposit":1,"enable_withdraw":1,"confirm_count":2}, + // {"type":"TRC20","symbol":"tUSDT","enable_deposit":1,"enable_withdraw":1,"confirm_count":20}, + // {"type":"ERC20","symbol":"eUSDT","enable_deposit":1,"enable_withdraw":1,"confirm_count":25} + // ] + // }, + // ], + // "cmd":"transfer/coinList" // } // const currencies = this.safeValue (response, 'result'); @@ -6224,6 +7475,7 @@ module.exports = class bibox extends Exchange { 'symbol': symbol, 'type': type, 'timeInForce': undefined, + 'postOnly': undefined, 'side': side, 'price': price, 'stopPrice': undefined, @@ -6276,7 +7528,7 @@ module.exports = class bibox extends Exchange { async fetchClosedOrders (symbol = undefined, since = undefined, limit = 200, params = {}) { if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' fetchClosedOrders requires a `symbol` argument'); + throw new ArgumentsRequired (this.id + ' fetchClosedOrders() requires a `symbol` argument'); } await this.loadMarkets (); const market = this.market (symbol); @@ -6296,7 +7548,7 @@ module.exports = class bibox extends Exchange { async fetchMyTrades (symbol = undefined, since = undefined, limit = undefined, params = {}) { if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' fetchMyTrades requires a `symbol` argument'); + throw new ArgumentsRequired (this.id + ' fetchMyTrades() requires a `symbol` argument'); } await this.loadMarkets (); const market = this.market (symbol); @@ -6423,7 +7675,7 @@ module.exports = class bibox extends Exchange { } } else if (api === 'v2private') { this.checkRequiredCredentials (); - url = this.urls['api'] + '/v2/' + path; + url = this.implodeParams (this.urls['api'], { 'hostname': this.hostname }) + '/v2/' + path; const json_params = this.json (params); body = { 'body': json_params, @@ -6473,7 +7725,7 @@ module.exports = class bibox extends Exchange { } }; -},{"./base/Exchange":5,"./base/errors":7}],22:[function(require,module,exports){ +},{"./base/Exchange":6,"./base/errors":8}],22:[function(require,module,exports){ 'use strict'; // --------------------------------------------------------------------------- @@ -6554,6 +7806,7 @@ module.exports = class bigone extends Exchange { 'private': { 'get': [ 'accounts', + 'fund/accounts', 'assets/{asset_symbol}/address', 'orders', 'orders/{id}', @@ -6567,6 +7820,7 @@ module.exports = class bigone extends Exchange { 'orders/{id}/cancel', 'orders/cancel', 'withdrawals', + 'transfer', ], }, }, @@ -7121,7 +8375,10 @@ module.exports = class bigone extends Exchange { async fetchBalance (params = {}) { await this.loadMarkets (); - const response = await this.privateGetAccounts (params); + const type = this.safeString (params, 'type', ''); + params = this.omit (params, 'type'); + const method = 'privateGet' + this.capitalize (type) + 'Accounts'; + const response = await this[method] (params); // // { // "code":0, @@ -7197,6 +8454,7 @@ module.exports = class bigone extends Exchange { 'symbol': symbol, 'type': undefined, 'timeInForce': undefined, + 'postOnly': undefined, 'side': side, 'price': price, 'stopPrice': undefined, @@ -7234,7 +8492,7 @@ module.exports = class bigone extends Exchange { if (isStopLimit || isStopMarket) { const stopPrice = this.safeFloat2 (params, 'stop_price', 'stopPrice'); if (stopPrice === undefined) { - throw new ArgumentsRequired (this.id + ' createOrder requires a stop_price parameter'); + throw new ArgumentsRequired (this.id + ' createOrder() requires a stop_price parameter'); } request['stop_price'] = this.priceToPrecision (symbol, stopPrice); params = this.omit (params, [ 'stop_price', 'stopPrice' ]); @@ -7742,13 +9000,13 @@ module.exports = class bigone extends Exchange { } }; -},{"./base/Exchange":5,"./base/errors":7}],23:[function(require,module,exports){ +},{"./base/Exchange":6,"./base/errors":8}],23:[function(require,module,exports){ 'use strict'; // --------------------------------------------------------------------------- const Exchange = require ('./base/Exchange'); -const { ExchangeError, ArgumentsRequired, ExchangeNotAvailable, InsufficientFunds, OrderNotFound, InvalidOrder, DDoSProtection, InvalidNonce, AuthenticationError, InvalidAddress, RateLimitExceeded, PermissionDenied, NotSupported, BadRequest, BadSymbol, AccountSuspended, OrderImmediatelyFillable } = require ('./base/errors'); +const { ExchangeError, ArgumentsRequired, ExchangeNotAvailable, InsufficientFunds, OrderNotFound, InvalidOrder, DDoSProtection, InvalidNonce, AuthenticationError, RateLimitExceeded, PermissionDenied, NotSupported, BadRequest, BadSymbol, AccountSuspended, OrderImmediatelyFillable } = require ('./base/errors'); const { ROUND, TRUNCATE } = require ('./base/functions/number'); // --------------------------------------------------------------------------- @@ -7768,6 +9026,7 @@ module.exports = class binance extends Exchange { 'cancelOrder': true, 'CORS': false, 'createOrder': true, + 'fetchCurrencies': true, 'fetchBalance': true, 'fetchBidsAsks': true, 'fetchClosedOrders': 'emulated', @@ -7858,6 +9117,7 @@ module.exports = class binance extends Exchange { 'margin/priceIndex', // these endpoints require this.apiKey + this.secret 'asset/assetDividend', + 'asset/transfer', 'margin/loan', 'margin/repay', 'margin/account', @@ -7899,6 +9159,7 @@ module.exports = class binance extends Exchange { 'sub-account/spotSummary', 'sub-account/status', 'sub-account/transfer/subUserHistory', + 'sub-account/universalTransfer', // lending endpoints 'lending/daily/product/list', 'lending/daily/userLeftQuota', @@ -7924,9 +9185,23 @@ module.exports = class binance extends Exchange { 'bswap/liquidityOps', 'bswap/quote', 'bswap/swap', + // leveraged token endpoints + 'blvt/tokenInfo', + 'blvt/subscribe/record', + 'blvt/redeem/record', + 'blvt/userLimit', + // broker api + 'apiReferral/ifNewUser', + 'apiReferral/customization', + 'apiReferral/userCustomization', + 'apiReferral/rebate/recentRecord', + 'apiReferral/rebate/historicalRecord', + 'apiReferral/kickback/recentRecord', + 'apiReferral/kickback/historicalRecord', ], 'post': [ 'asset/dust', + 'asset/transfer', 'account/disableFastWithdrawSwitch', 'account/enableFastWithdrawSwitch', 'capital/withdraw/apply', @@ -7944,6 +9219,7 @@ module.exports = class binance extends Exchange { 'sub-account/futures/internalTransfer', 'sub-account/transfer/subToSub', 'sub-account/transfer/subToMaster', + 'sub-account/universalTransfer', 'userDataStream', 'userDataStream/isolated', 'futures/transfer', @@ -7958,12 +9234,21 @@ module.exports = class binance extends Exchange { 'bswap/liquidityAdd', 'bswap/liquidityRemove', 'bswap/swap', + // leveraged token endpoints + 'blvt/subscribe', + 'blvt/redeem', + // broker api + 'apiReferral/customization', + 'apiReferral/userCustomization', + 'apiReferral/rebate/historicalRecord', + 'apiReferral/kickback/historicalRecord', ], 'put': [ 'userDataStream', 'userDataStream/isolated', ], 'delete': [ + 'margin/openOrders', 'margin/order', 'userDataStream', 'userDataStream/isolated', @@ -8068,6 +9353,7 @@ module.exports = class binance extends Exchange { 'historicalTrades', 'aggTrades', 'klines', + 'continuousKlines', 'fundingRate', 'premiumIndex', 'ticker/24hr', @@ -8102,6 +9388,15 @@ module.exports = class binance extends Exchange { 'positionSide/dual', 'userTrades', 'income', + // broker endpoints + 'apiReferral/ifNewUser', + 'apiReferral/customization', + 'apiReferral/userCustomization', + 'apiReferral/traderNum', + 'apiReferral/overview', + 'apiReferral/tradeVol', + 'apiReferral/rebateVol', + 'apiReferral/traderSummary', ], 'post': [ 'batchOrders', @@ -8112,6 +9407,9 @@ module.exports = class binance extends Exchange { 'leverage', 'listenKey', 'countdownCancelAll', + // broker endpoints + 'apiReferral/customization', + 'apiReferral/userCustomization', ], 'put': [ 'listenKey', @@ -8191,6 +9489,7 @@ module.exports = class binance extends Exchange { }, // exchange-specific options 'options': { + 'fetchCurrencies': false, // this is a private call and it requires API keys // 'fetchTradesMethod': 'publicGetAggTrades', // publicGetTrades, publicGetHistoricalTrades 'defaultTimeInForce': 'GTC', // 'GTC' = Good To Cancel (default), 'IOC' = Immediate Or Cancel 'defaultType': 'spot', // 'spot', 'future', 'margin', 'delivery' @@ -8205,11 +9504,20 @@ module.exports = class binance extends Exchange { 'limit': 'RESULT', // we change it from 'ACK' by default to 'RESULT' }, 'quoteOrderQty': true, // whether market orders support amounts in quote currency + 'broker': { + 'spot': 'x-R4BD3S82', + 'margin': 'x-R4BD3S82', + 'future': 'x-xcKtGhcu', + 'delivery': 'x-xcKtGhcu', + }, }, // https://binance-docs.github.io/apidocs/spot/en/#error-codes-2 'exceptions': { + 'System abnormality': ExchangeError, // {"code":-1000,"msg":"System abnormality"} + 'You are not authorized to execute this request.': PermissionDenied, // {"msg":"You are not authorized to execute this request."} 'API key does not exist': AuthenticationError, 'Order would trigger immediately.': OrderImmediatelyFillable, + 'Stop price would trigger immediately.': OrderImmediatelyFillable, // {"code":-2010,"msg":"Stop price would trigger immediately."} 'Order would immediately match and take.': OrderImmediatelyFillable, // {"code":-2010,"msg":"Order would immediately match and take."} 'Account has insufficient balance for requested action.': InsufficientFunds, 'Rest API trading is not enabled.': ExchangeNotAvailable, @@ -8253,14 +9561,21 @@ module.exports = class binance extends Exchange { '-2013': OrderNotFound, // fetchOrder (1, 'BTC/USDT') -> 'Order does not exist' '-2014': AuthenticationError, // { "code":-2014, "msg": "API-key format invalid." } '-2015': AuthenticationError, // "Invalid API-key, IP, or permissions for action." + '-2019': InsufficientFunds, // {"code":-2019,"msg":"Margin is insufficient."} '-3005': InsufficientFunds, // {"code":-3005,"msg":"Transferring out not allowed. Transfer out amount exceeds max amount."} '-3008': InsufficientFunds, // {"code":-3008,"msg":"Borrow not allowed. Your borrow amount has exceed maximum borrow amount."} '-3010': ExchangeError, // {"code":-3010,"msg":"Repay not allowed. Repay amount exceeds borrow amount."} '-3022': AccountSuspended, // You account's trading is banned. + '-4028': BadRequest, // {"code":-4028,"msg":"Leverage 100 is not valid"} + '-5013': InsufficientFunds, // Asset transfer failed: insufficient balance" }, }); } + currencyToPrecision (currency, fee) { + return this.numberToString (fee); + } + nonce () { return this.milliseconds () - this.options['timeDifference']; } @@ -8284,6 +9599,145 @@ module.exports = class binance extends Exchange { return this.options['timeDifference']; } + async fetchCurrencies (params = {}) { + const fetchCurrenciesEnabled = this.safeValue (this.options, 'fetchCurrencies'); + if (!fetchCurrenciesEnabled) { + return undefined; + } + // this endpoint requires authentication + // while fetchCurrencies is a public API method by design + // therefore we check the keys here + // and fallback to generating the currencies from the markets + if (!this.checkRequiredCredentials (false)) { + return undefined; + } + // sandbox/testnet does not support sapi endpoints + const apiBackup = this.safeString (this.urls, 'apiBackup'); + if (apiBackup !== undefined) { + return undefined; + } + const response = await this.sapiGetCapitalConfigGetall (params); + const result = {}; + for (let i = 0; i < response.length; i++) { + // + // { + // coin: 'LINK', + // depositAllEnable: true, + // withdrawAllEnable: true, + // name: 'ChainLink', + // free: '0.06168', + // locked: '0', + // freeze: '0', + // withdrawing: '0', + // ipoing: '0', + // ipoable: '0', + // storage: '0', + // isLegalMoney: false, + // trading: true, + // networkList: [ + // { + // network: 'BNB', + // coin: 'LINK', + // withdrawIntegerMultiple: '0', + // isDefault: false, + // depositEnable: true, + // withdrawEnable: true, + // depositDesc: '', + // withdrawDesc: '', + // specialTips: 'Both a MEMO and an Address are required to successfully deposit your LINK BEP2 tokens to Binance.', + // name: 'BEP2', + // resetAddressStatus: false, + // addressRegex: '^(bnb1)[0-9a-z]{38}$', + // memoRegex: '^[0-9A-Za-z\\-_]{1,120}$', + // withdrawFee: '0.002', + // withdrawMin: '0.01', + // withdrawMax: '9999999', + // minConfirm: 1, + // unLockConfirm: 0 + // }, + // { + // network: 'BSC', + // coin: 'LINK', + // withdrawIntegerMultiple: '0.00000001', + // isDefault: false, + // depositEnable: true, + // withdrawEnable: true, + // depositDesc: '', + // withdrawDesc: '', + // specialTips: '', + // name: 'BEP20 (BSC)', + // resetAddressStatus: false, + // addressRegex: '^(0x)[0-9A-Fa-f]{40}$', + // memoRegex: '', + // withdrawFee: '0.005', + // withdrawMin: '0.01', + // withdrawMax: '9999999', + // minConfirm: 15, + // unLockConfirm: 0 + // }, + // { + // network: 'ETH', + // coin: 'LINK', + // withdrawIntegerMultiple: '0.00000001', + // isDefault: true, + // depositEnable: true, + // withdrawEnable: true, + // depositDesc: '', + // withdrawDesc: '', + // name: 'ERC20', + // resetAddressStatus: false, + // addressRegex: '^(0x)[0-9A-Fa-f]{40}$', + // memoRegex: '', + // withdrawFee: '0.34', + // withdrawMin: '0.68', + // withdrawMax: '0', + // minConfirm: 12, + // unLockConfirm: 0 + // } + // ] + // } + // + const entry = response[i]; + const id = this.safeString (entry, 'coin'); + const name = this.safeString (entry, 'name'); + const code = this.safeCurrencyCode (id); + const precision = undefined; + let isWithdrawEnabled = true; + let isDepositEnabled = true; + const networkList = this.safeValue (entry, 'networkList', []); + const fees = {}; + let fee = undefined; + for (let j = 0; j < networkList.length; j++) { + const networkItem = networkList[j]; + const name = this.safeString (networkItem, 'name'); + const withdrawFee = this.safeFloat (networkItem, 'withdrawFee'); + const depositEnable = this.safeValue (networkItem, 'depositEnable'); + const withdrawEnable = this.safeValue (networkItem, 'withdrawEnable'); + isDepositEnabled = isDepositEnabled || depositEnable; + isWithdrawEnabled = isWithdrawEnabled || withdrawEnable; + fees[name] = withdrawFee; + const isDefault = this.safeValue (networkItem, 'isDefault'); + if (isDefault || fee === undefined) { + fee = withdrawFee; + } + } + const trading = this.safeValue (entry, 'trading'); + const active = (isWithdrawEnabled && isDepositEnabled && trading); + result[code] = { + 'id': id, + 'name': name, + 'code': code, + 'precision': precision, + 'info': entry, + 'active': active, + 'fee': fee, + 'fees': fees, + 'limits': this.limits, + }; + } + return result; + } + async fetchMarkets (params = {}) { const defaultType = this.safeString2 (this.options, 'fetchMarkets', 'defaultType', 'spot'); const type = this.safeString (params, 'type', defaultType); @@ -8460,9 +9914,8 @@ module.exports = class binance extends Exchange { const quoteId = this.safeString (market, 'quoteAsset'); const base = this.safeCurrencyCode (baseId); const quote = this.safeCurrencyCode (quoteId); - const parts = id.split ('_'); - const lastPart = this.safeString (parts, 1); - const idSymbol = (delivery) && (lastPart !== 'PERP'); + const contractType = this.safeString (market, 'contractType'); + const idSymbol = (future || delivery) && (contractType !== 'PERPETUAL'); const symbol = idSymbol ? id : (base + '/' + quote); const filters = this.safeValue (market, 'filters', []); const filtersByType = this.indexBy (filters, 'filterType'); @@ -8540,7 +9993,7 @@ module.exports = class binance extends Exchange { } if ('MIN_NOTIONAL' in filtersByType) { const filter = this.safeValue (filtersByType, 'MIN_NOTIONAL', {}); - entry['limits']['cost']['min'] = this.safeFloat (filter, 'minNotional'); + entry['limits']['cost']['min'] = this.safeFloat2 (filter, 'minNotional', 'notional'); } result.push (entry); } @@ -8942,15 +10395,24 @@ module.exports = class binance extends Exchange { async fetchOHLCV (symbol, timeframe = '1m', since = undefined, limit = undefined, params = {}) { await this.loadMarkets (); const market = this.market (symbol); + // binance docs say that the default limit 500, max 1500 for futures, max 1000 for spot markets + // the reality is that the time range wider than 500 candles won't work right + const defaultLimit = 500; + const maxLimit = 1500; + limit = (limit === undefined) ? defaultLimit : Math.min (limit, maxLimit); const request = { 'symbol': market['id'], 'interval': this.timeframes[timeframe], + 'limit': limit, }; + const duration = this.parseTimeframe (timeframe); if (since !== undefined) { request['startTime'] = since; - } - if (limit !== undefined) { - request['limit'] = limit; // default == max == 500 + if (since > 0) { + const endTime = this.sum (since, limit * duration * 1000 - 1); + const now = this.milliseconds (); + request['endTime'] = Math.min (now, endTime); + } } let method = 'publicGetKlines'; if (market['future']) { @@ -9038,6 +10500,23 @@ module.exports = class binance extends Exchange { // "symbol": "BTCUSDT", // "time": 1569514978020 // } + // { + // "symbol": "BTCUSDT", + // "id": 477128891, + // "orderId": 13809777875, + // "side": "SELL", + // "price": "38479.55", + // "qty": "0.001", + // "realizedPnl": "-0.00009534", + // "marginAsset": "USDT", + // "quoteQty": "38.47955", + // "commission": "-0.00076959", + // "commissionAsset": "USDT", + // "time": 1612733566708, + // "positionSide": "BOTH", + // "maker": true, + // "buyer": false + // } // const timestamp = this.safeInteger2 (trade, 'T', 'time'); const price = this.safeFloat2 (trade, 'p', 'price'); @@ -9067,6 +10546,9 @@ module.exports = class binance extends Exchange { if ('isMaker' in trade) { takerOrMaker = trade['isMaker'] ? 'maker' : 'taker'; } + if ('maker' in trade) { + takerOrMaker = trade['maker'] ? 'maker' : 'taker'; + } const marketId = this.safeString (trade, 'symbol'); const symbol = this.safeSymbol (marketId, market); let cost = undefined; @@ -9184,7 +10666,7 @@ module.exports = class binance extends Exchange { 'CANCELED': 'canceled', 'PENDING_CANCEL': 'canceling', // currently unused 'REJECTED': 'rejected', - 'EXPIRED': 'canceled', + 'EXPIRED': 'expired', }; return this.safeString (statuses, status, status); } @@ -9310,6 +10792,8 @@ module.exports = class binance extends Exchange { } const clientOrderId = this.safeString (order, 'clientOrderId'); const timeInForce = this.safeString (order, 'timeInForce'); + const postOnly = (type === 'limit_maker') || (timeInForce === 'GTX'); + const stopPrice = this.safeFloat (order, 'stopPrice'); return { 'info': order, 'id': id, @@ -9320,8 +10804,10 @@ module.exports = class binance extends Exchange { 'symbol': symbol, 'type': type, 'timeInForce': timeInForce, + 'postOnly': postOnly, 'side': side, 'price': price, + 'stopPrice': stopPrice, 'amount': amount, 'cost': cost, 'average': average, @@ -9366,7 +10852,15 @@ module.exports = class binance extends Exchange { 'type': uppercaseType, 'side': side.toUpperCase (), }; - if (clientOrderId !== undefined) { + if (clientOrderId === undefined) { + const broker = this.safeValue (this.options, 'broker'); + if (broker) { + const brokerId = this.safeString (broker, orderType); + if (brokerId !== undefined) { + request['newClientOrderId'] = brokerId + this.uuid22 (); + } + } + } else { request['newClientOrderId'] = clientOrderId; } if (market['spot']) { @@ -9445,7 +10939,7 @@ module.exports = class binance extends Exchange { quantityIsRequired = true; const callbackRate = this.safeFloat (params, 'callbackRate'); if (callbackRate === undefined) { - throw new InvalidOrder (this.id + ' createOrder method requires a callbackRate extra param for a ' + type + ' order'); + throw new InvalidOrder (this.id + ' createOrder() requires a callbackRate extra param for a ' + type + ' order'); } } if (quantityIsRequired) { @@ -9453,7 +10947,7 @@ module.exports = class binance extends Exchange { } if (priceIsRequired) { if (price === undefined) { - throw new InvalidOrder (this.id + ' createOrder method requires a price argument for a ' + type + ' order'); + throw new InvalidOrder (this.id + ' createOrder() requires a price argument for a ' + type + ' order'); } request['price'] = this.priceToPrecision (symbol, price); } @@ -9463,7 +10957,7 @@ module.exports = class binance extends Exchange { if (stopPriceIsRequired) { const stopPrice = this.safeFloat (params, 'stopPrice'); if (stopPrice === undefined) { - throw new InvalidOrder (this.id + ' createOrder method requires a stopPrice extra param for a ' + type + ' order'); + throw new InvalidOrder (this.id + ' createOrder() requires a stopPrice extra param for a ' + type + ' order'); } else { params = this.omit (params, 'stopPrice'); request['stopPrice'] = this.priceToPrecision (symbol, stopPrice); @@ -9475,7 +10969,7 @@ module.exports = class binance extends Exchange { async fetchOrder (id, symbol = undefined, params = {}) { if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' fetchOrder requires a symbol argument'); + throw new ArgumentsRequired (this.id + ' fetchOrder() requires a symbol argument'); } await this.loadMarkets (); const market = this.market (symbol); @@ -9496,7 +10990,7 @@ module.exports = class binance extends Exchange { if (clientOrderId !== undefined) { request['origClientOrderId'] = clientOrderId; } else { - request['orderId'] = parseInt (id); + request['orderId'] = id; } const query = this.omit (params, [ 'type', 'clientOrderId', 'origClientOrderId' ]); const response = await this[method] (this.extend (request, query)); @@ -9505,7 +10999,7 @@ module.exports = class binance extends Exchange { async fetchOrders (symbol = undefined, since = undefined, limit = undefined, params = {}) { if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' fetchOrders requires a symbol argument'); + throw new ArgumentsRequired (this.id + ' fetchOrders() requires a symbol argument'); } await this.loadMarkets (); const market = this.market (symbol); @@ -9618,7 +11112,7 @@ module.exports = class binance extends Exchange { async cancelOrder (id, symbol = undefined, params = {}) { if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' cancelOrder requires a symbol argument'); + throw new ArgumentsRequired (this.id + ' cancelOrder() requires a symbol argument'); } await this.loadMarkets (); const market = this.market (symbol); @@ -9628,11 +11122,11 @@ module.exports = class binance extends Exchange { const origClientOrderId = this.safeValue2 (params, 'origClientOrderId', 'clientOrderId'); const request = { 'symbol': market['id'], - // 'orderId': parseInt (id), + // 'orderId': id, // 'origClientOrderId': id, }; if (origClientOrderId === undefined) { - request['orderId'] = parseInt (id); + request['orderId'] = id; } else { request['origClientOrderId'] = origClientOrderId; } @@ -9651,7 +11145,7 @@ module.exports = class binance extends Exchange { async cancelAllOrders (symbol = undefined, params = {}) { if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' cancelAllOrders requires a symbol argument'); + throw new ArgumentsRequired (this.id + ' cancelAllOrders() requires a symbol argument'); } await this.loadMarkets (); const market = this.market (symbol); @@ -9662,7 +11156,9 @@ module.exports = class binance extends Exchange { const type = this.safeString (params, 'type', defaultType); const query = this.omit (params, 'type'); let method = 'privateDeleteOpenOrders'; - if (type === 'future') { + if (type === 'margin') { + method = 'sapiDeleteMarginOpenOrders'; + } else if (type === 'future') { method = 'fapiPrivateDeleteAllOpenOrders'; } else if (type === 'delivery') { method = 'dapiPrivateDeleteAllOpenOrders'; @@ -9728,20 +11224,23 @@ module.exports = class binance extends Exchange { async fetchMyTrades (symbol = undefined, since = undefined, limit = undefined, params = {}) { if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' fetchMyTrades requires a symbol argument'); + throw new ArgumentsRequired (this.id + ' fetchMyTrades() requires a symbol argument'); } await this.loadMarkets (); const market = this.market (symbol); - const type = this.safeValue (params, 'type', market['type']); + const defaultType = this.safeString2 (this.options, 'fetchMyTrades', 'defaultType', market['type']); + const type = this.safeString (params, 'type', defaultType); + params = this.omit (params, 'type'); let method = undefined; if (type === 'spot') { method = 'privateGetMyTrades'; + } else if (type === 'margin') { + method = 'sapiGetMarginMyTrades'; } else if (type === 'future') { method = 'fapiPrivateGetUserTrades'; } else if (type === 'delivery') { method = 'dapiPrivateGetUserTrades'; } - params = this.omit (params, 'type'); const request = { 'symbol': market['id'], }; @@ -10025,7 +11524,10 @@ module.exports = class binance extends Exchange { tag = undefined; } } - const txid = this.safeString (transaction, 'txId'); + let txid = this.safeString (transaction, 'txId'); + if ((txid !== undefined) && (txid.indexOf ('Internal transfer ') >= 0)) { + txid = txid.slice (18); + } const currencyId = this.safeString (transaction, 'asset'); const code = this.safeCurrencyCode (currencyId, currency); let timestamp = undefined; @@ -10074,15 +11576,27 @@ module.exports = class binance extends Exchange { await this.loadMarkets (); const currency = this.currency (code); const request = { - 'asset': currency['id'], + 'coin': currency['id'], + // 'network': 'ETH', // 'BSC', 'XMR', you can get network and isDefault in networkList in the response of sapiGetCapitalConfigDetail }; - const response = await this.wapiGetDepositAddress (this.extend (request, params)); - const success = this.safeValue (response, 'success'); - if ((success === undefined) || !success) { - throw new InvalidAddress (this.id + ' fetchDepositAddress returned an empty response – create the deposit address in the user settings first.'); - } + // has support for the 'network' parameter + // https://binance-docs.github.io/apidocs/spot/en/#deposit-address-supporting-network-user_data + const response = await this.sapiGetCapitalDepositAddress (this.extend (request, params)); + // + // { + // currency: 'XRP', + // address: 'rEb8TK3gBgk5auZkwc6sHnwrGVJH8DuaLh', + // tag: '108618262', + // info: { + // coin: 'XRP', + // address: 'rEb8TK3gBgk5auZkwc6sHnwrGVJH8DuaLh', + // tag: '108618262', + // url: 'https://bithomp.com/explorer/rEb8TK3gBgk5auZkwc6sHnwrGVJH8DuaLh' + // } + // } + // const address = this.safeString (response, 'address'); - const tag = this.safeString (response, 'addressTag'); + const tag = this.safeString (response, 'tag'); this.checkAddress (address); return { 'currency': code, @@ -10260,7 +11774,7 @@ module.exports = class binance extends Exchange { 'timestamp': this.nonce (), 'recvWindow': recvWindow, }, params)); - } else if (path === 'batchOrders') { + } else if ((path === 'batchOrders') || (path.indexOf ('sub-account') >= 0)) { query = this.rawencode (this.extend ({ 'timestamp': this.nonce (), 'recvWindow': recvWindow, @@ -10371,7 +11885,7 @@ module.exports = class binance extends Exchange { } }; -},{"./base/Exchange":5,"./base/errors":7,"./base/functions/number":13}],24:[function(require,module,exports){ +},{"./base/Exchange":6,"./base/errors":8,"./base/functions/number":14}],24:[function(require,module,exports){ 'use strict'; // --------------------------------------------------------------------------- @@ -10416,6 +11930,10 @@ module.exports = class binanceus extends binance { }, }); } + + async fetchCurrencies (params = {}) { + return undefined; + } }; @@ -10728,6 +12246,7 @@ module.exports = class bit2c extends Exchange { 'symbol': symbol, 'type': undefined, 'timeInForce': undefined, + 'postOnly': undefined, 'side': side, 'price': price, 'stopPrice': undefined, @@ -10879,7 +12398,7 @@ module.exports = class bit2c extends Exchange { }; -},{"./base/Exchange":5,"./base/errors":7}],26:[function(require,module,exports){ +},{"./base/Exchange":6,"./base/errors":8}],26:[function(require,module,exports){ 'use strict'; // --------------------------------------------------------------------------- @@ -10964,6 +12483,8 @@ module.exports = class bitbank extends Exchange { 'BCH/JPY': { 'id': 'bcc_jpy', 'symbol': 'BCH/JPY', 'base': 'BCH', 'quote': 'JPY', 'baseId': 'bcc', 'quoteId': 'jpy' }, 'MONA/BTC': { 'id': 'mona_btc', 'symbol': 'MONA/BTC', 'base': 'MONA', 'quote': 'BTC', 'baseId': 'mona', 'quoteId': 'btc' }, 'MONA/JPY': { 'id': 'mona_jpy', 'symbol': 'MONA/JPY', 'base': 'MONA', 'quote': 'JPY', 'baseId': 'mona', 'quoteId': 'jpy' }, + 'QTUM/BTC': { 'id': 'qtum_btc', 'symbol': 'QTUM/BTC', 'base': 'QTUM', 'quote': 'BTC', 'baseId': 'qtum', 'quoteId': 'btc' }, + 'QTUM/JPY': { 'id': 'qtum_jpy', 'symbol': 'QTUM/JPY', 'base': 'QTUM', 'quote': 'JPY', 'baseId': 'qtum', 'quoteId': 'jpy' }, 'ETH/BTC': { 'id': 'eth_btc', 'symbol': 'ETH/BTC', 'base': 'ETH', 'quote': 'BTC', 'baseId': 'eth', 'quoteId': 'btc' }, 'LTC/BTC': { 'id': 'ltc_btc', 'symbol': 'LTC/BTC', 'base': 'LTC', 'quote': 'BTC', 'baseId': 'ltc', 'quoteId': 'btc' }, 'XRP/JPY': { 'id': 'xrp_jpy', 'symbol': 'XRP/JPY', 'base': 'XRP', 'quote': 'JPY', 'baseId': 'xrp', 'quoteId': 'jpy' }, @@ -10972,6 +12493,7 @@ module.exports = class bitbank extends Exchange { 'ETH/JPY': { 'id': 'eth_jpy', 'symbol': 'ETH/JPY', 'base': 'ETH', 'quote': 'JPY', 'baseId': 'eth', 'quoteId': 'jpy' }, 'LTC/JPY': { 'id': 'ltc_jpy', 'symbol': 'LTC/JPY', 'base': 'LTC', 'quote': 'JPY', 'baseId': 'ltc', 'quoteId': 'jpy' }, 'XRP/BTC': { 'id': 'xrp_btc', 'symbol': 'XRP/BTC', 'base': 'XRP', 'quote': 'BTC', 'baseId': 'xrp', 'quoteId': 'btc' }, + 'XLM/BTC': { 'id': 'xlm_btc', 'symbol': 'XLM/BTC', 'base': 'XLM', 'quote': 'BTC', 'baseId': 'xlm', 'quoteId': 'btc' }, }, 'fees': { 'trading': { @@ -11089,8 +12611,8 @@ module.exports = class bitbank extends Exchange { const feeCost = this.safeFloat (trade, 'fee_amount_quote'); if (feeCost !== undefined) { fee = { - 'currency': market['quote'], - 'cost': feeCurrency, + 'currency': feeCurrency, + 'cost': feeCost, }; } const orderId = this.safeString (trade, 'order_id'); @@ -11249,6 +12771,7 @@ module.exports = class bitbank extends Exchange { 'symbol': symbol, 'type': type, 'timeInForce': undefined, + 'postOnly': undefined, 'side': side, 'price': price, 'stopPrice': undefined, @@ -11267,7 +12790,7 @@ module.exports = class bitbank extends Exchange { await this.loadMarkets (); const market = this.market (symbol); if (price === undefined) { - throw new InvalidOrder (this.id + ' createOrder requires a price argument for both market and limit orders'); + throw new InvalidOrder (this.id + ' createOrder() requires a price argument for both market and limit orders'); } const request = { 'pair': market['id'], @@ -11503,7 +13026,7 @@ module.exports = class bitbank extends Exchange { } }; -},{"./base/Exchange":5,"./base/errors":7}],27:[function(require,module,exports){ +},{"./base/Exchange":6,"./base/errors":8}],27:[function(require,module,exports){ 'use strict'; // --------------------------------------------------------------------------- @@ -11857,6 +13380,7 @@ module.exports = class bitbay extends Exchange { filled = Math.max (0, amount - remaining); } } + const postOnly = this.safeValue (order, 'postOnly'); return { 'id': this.safeString (order, 'id'), 'clientOrderId': undefined, @@ -11868,6 +13392,7 @@ module.exports = class bitbay extends Exchange { 'symbol': symbol, 'type': this.safeString (order, 'mode'), 'timeInForce': undefined, + 'postOnly': postOnly, 'side': this.safeStringLower (order, 'offerType'), 'price': this.safeFloat (order, 'rate'), 'stopPrice': undefined, @@ -12777,7 +14302,7 @@ module.exports = class bitbay extends Exchange { } }; -},{"./base/Exchange":5,"./base/errors":7}],28:[function(require,module,exports){ +},{"./base/Exchange":6,"./base/errors":8}],28:[function(require,module,exports){ 'use strict'; // --------------------------------------------------------------------------- @@ -12813,7 +14338,7 @@ module.exports = class bitcoincom extends hitbtc { } }; -},{"./hitbtc.js":89}],29:[function(require,module,exports){ +},{"./hitbtc.js":93}],29:[function(require,module,exports){ 'use strict'; // --------------------------------------------------------------------------- @@ -12832,7 +14357,6 @@ module.exports = class bitfinex extends Exchange { 'countries': [ 'VG' ], 'version': 'v1', 'rateLimit': 1500, - 'certified': true, 'pro': true, // new metainfo interface 'has': { @@ -12870,6 +14394,7 @@ module.exports = class bitfinex extends Exchange { '30m': '30m', '1h': '1h', '3h': '3h', + '4h': '4h', '6h': '6h', '12h': '12h', '1d': '1D', @@ -13416,13 +14941,32 @@ module.exports = class bitfinex extends Exchange { async fetchBalance (params = {}) { await this.loadMarkets (); + const types = { + 'exchange': 'exchange', + 'deposit': 'funding', + 'trading': 'margin', + }; const balanceType = this.safeString (params, 'type', 'exchange'); const query = this.omit (params, 'type'); const response = await this.privatePostBalances (query); + // [ { type: 'deposit', + // currency: 'btc', + // amount: '0.00116721', + // available: '0.00116721' }, + // { type: 'exchange', + // currency: 'ust', + // amount: '0.0000002', + // available: '0.0000002' }, + // { type: 'trading', + // currency: 'btc', + // amount: '0.0005', + // available: '0.0005' } ], const result = { 'info': response }; for (let i = 0; i < response.length; i++) { const balance = response[i]; - if (balance['type'] === balanceType) { + const type = this.safeString (balance, 'type'); + const parsedType = this.safeString (types, type); + if ((parsedType === balanceType) || (type === balanceType)) { const currencyId = this.safeString (balance, 'currency'); const code = this.safeCurrencyCode (currencyId); // bitfinex had BCH previously, now it's BAB, but the old @@ -13585,7 +15129,7 @@ module.exports = class bitfinex extends Exchange { async fetchMyTrades (symbol = undefined, since = undefined, limit = undefined, params = {}) { if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' fetchMyTrades requires a `symbol` argument'); + throw new ArgumentsRequired (this.id + ' fetchMyTrades() requires a `symbol` argument'); } await this.loadMarkets (); const market = this.market (symbol); @@ -13703,6 +15247,7 @@ module.exports = class bitfinex extends Exchange { 'symbol': symbol, 'type': orderType, 'timeInForce': undefined, + 'postOnly': undefined, 'side': side, 'price': this.safeFloat (order, 'price'), 'stopPrice': undefined, @@ -14078,13 +15623,13 @@ module.exports = class bitfinex extends Exchange { } }; -},{"./base/Exchange":5,"./base/errors":7,"./base/functions/number":13}],30:[function(require,module,exports){ +},{"./base/Exchange":6,"./base/errors":8,"./base/functions/number":14}],30:[function(require,module,exports){ 'use strict'; // --------------------------------------------------------------------------- const bitfinex = require ('./bitfinex.js'); -const { ExchangeError, InvalidAddress, ArgumentsRequired, InsufficientFunds, AuthenticationError, OrderNotFound, InvalidOrder, BadRequest, InvalidNonce, BadSymbol, OnMaintenance } = require ('./base/errors'); +const { ExchangeError, InvalidAddress, ArgumentsRequired, InsufficientFunds, AuthenticationError, OrderNotFound, InvalidOrder, BadRequest, InvalidNonce, BadSymbol, OnMaintenance, NotSupported } = require ('./base/errors'); // --------------------------------------------------------------------------- @@ -14134,6 +15679,7 @@ module.exports = class bitfinex2 extends bitfinex { '30m': '30m', '1h': '1h', '3h': '3h', + '4h': '4h', '6h': '6h', '12h': '12h', '1d': '1D', @@ -14252,7 +15798,9 @@ module.exports = class bitfinex2 extends bitfinex { 'auth/w/position/claim', 'auth/r/positions/hist', 'auth/r/positions/audit', + 'auth/r/positions/snap', 'auth/w/deriv/collateral/set', + 'auth/w/deriv/collateral/limits', 'auth/r/funding/offers', 'auth/r/funding/offers/{symbol}', 'auth/w/funding/offer/submit', @@ -14664,6 +16212,10 @@ module.exports = class bitfinex2 extends bitfinex { return this.parseBalance (result); } + async fetchOrder (id, symbol = undefined, params = {}) { + throw new NotSupported (this.id + ' fetchOrder is not implemented yet'); + } + async fetchOrderBook (symbol, limit = undefined, params = {}) { await this.loadMarkets (); const precision = this.safeValue (this.options, 'precision', 'R0'); @@ -15004,6 +16556,7 @@ module.exports = class bitfinex2 extends bitfinex { 'symbol': symbol, 'type': type, 'timeInForce': undefined, + 'postOnly': undefined, 'side': side, 'price': price, 'stopPrice': undefined, @@ -15022,16 +16575,43 @@ module.exports = class bitfinex2 extends bitfinex { await this.loadMarkets (); const market = this.market (symbol); const orderTypes = this.safeValue (this.options, 'orderTypes', {}); - const orderType = this.safeString (orderTypes, type, type); + const orderType = this.safeStringUpper (orderTypes, type, type); amount = (side === 'sell') ? -amount : amount; const request = { 'symbol': market['id'], 'type': orderType, 'amount': this.numberToString (amount), }; - if (type !== 'market') { + if ((orderType === 'LIMIT') || (orderType === 'EXCHANGE LIMIT')) { + request['price'] = this.numberToString (price); + } else if ((orderType === 'STOP') || (orderType === 'EXCHANGE STOP')) { + const stopPrice = this.safeFloat (params, 'stopPrice', price); + request['price'] = this.numberToString (stopPrice); + } else if ((orderType === 'STOP LIMIT') || (orderType === 'EXCHANGE STOP LIMIT')) { + const priceAuxLimit = this.safeFloat (params, 'price_aux_limit'); + let stopPrice = this.safeFloat (params, 'stopPrice'); + if (priceAuxLimit === undefined) { + if (stopPrice === undefined) { + throw new ArgumentsRequired (this.id + ' createOrder() requires a stopPrice parameter or a price_aux_limit parameter for a ' + orderType + ' order'); + } else { + request['price_aux_limit'] = this.numberToString (price); + } + } else { + request['price_aux_limit'] = this.numberToString (priceAuxLimit); + if (stopPrice === undefined) { + stopPrice = price; + } + } + request['price'] = this.numberToString (stopPrice); + } else if ((orderType === 'TRAILING STOP') || (orderType === 'EXCHANGE TRAILING STOP')) { + const priceTrailing = this.safeFloat (params, 'price_trailing'); + request['price_trailing'] = this.numberToString (priceTrailing); + const stopPrice = this.safeFloat (params, 'stopPrice', price); + request['price'] = this.numberToString (stopPrice); + } else if ((orderType === 'FOK') || (orderType === 'EXCHANGE FOK') || (orderType === 'IOC') || (orderType === 'EXCHANGE IOC')) { request['price'] = this.numberToString (price); } + params = this.omit (params, [ 'stopPrice', 'price_aux_limit', 'price_trailing' ]); const clientOrderId = this.safeValue2 (params, 'cid', 'clientOrderId'); if (clientOrderId !== undefined) { request['cid'] = clientOrderId; @@ -15617,7 +17197,7 @@ module.exports = class bitfinex2 extends bitfinex { } }; -},{"./base/errors":7,"./bitfinex.js":29}],31:[function(require,module,exports){ +},{"./base/errors":8,"./bitfinex.js":29}],31:[function(require,module,exports){ 'use strict'; // --------------------------------------------------------------------------- @@ -15985,6 +17565,7 @@ module.exports = class bitflyer extends Exchange { 'symbol': symbol, 'type': type, 'timeInForce': undefined, + 'postOnly': undefined, 'side': side, 'price': price, 'stopPrice': undefined, @@ -16044,7 +17625,7 @@ module.exports = class bitflyer extends Exchange { async fetchMyTrades (symbol = undefined, since = undefined, limit = undefined, params = {}) { if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' fetchMyTrades requires a `symbol` argument'); + throw new ArgumentsRequired (this.id + ' fetchMyTrades() requires a `symbol` argument'); } await this.loadMarkets (); const market = this.market (symbol); @@ -16060,7 +17641,7 @@ module.exports = class bitflyer extends Exchange { async fetchPositions (symbols = undefined, since = undefined, limit = undefined, params = {}) { if (symbols === undefined) { - throw new ArgumentsRequired (this.id + ' fetchPositions requires a `symbols` argument, exactly one symbol in an array'); + throw new ArgumentsRequired (this.id + ' fetchPositions() requires a `symbols` argument, exactly one symbol in an array'); } await this.loadMarkets (); const request = { @@ -16142,13 +17723,13 @@ module.exports = class bitflyer extends Exchange { } }; -},{"./base/Exchange":5,"./base/errors":7}],32:[function(require,module,exports){ +},{"./base/Exchange":6,"./base/errors":8}],32:[function(require,module,exports){ 'use strict'; // --------------------------------------------------------------------------- const Exchange = require ('./base/Exchange'); -const { ExchangeError, AuthenticationError, OrderNotFound, InsufficientFunds, DDoSProtection, PermissionDenied } = require ('./base/errors'); +const { ExchangeError, AuthenticationError, OrderNotFound, InsufficientFunds, DDoSProtection, PermissionDenied, BadSymbol } = require ('./base/errors'); // --------------------------------------------------------------------------- @@ -16368,6 +17949,7 @@ module.exports = class bitforex extends Exchange { }, 'commonCurrencies': { 'CREDIT': 'TerraCredit', + 'HBC': 'Hybrid Bank Cash', 'IQ': 'IQ.Cash', 'UOS': 'UOS Network', }, @@ -16376,6 +17958,7 @@ module.exports = class bitforex extends Exchange { '1013': AuthenticationError, '1016': AuthenticationError, '1017': PermissionDenied, // {"code":"1017","success":false,"time":1602670594367,"message":"IP not allow"} + '1019': BadSymbol, // {"code":"1019","success":false,"time":1607087743778,"message":"Symbol Invalid"} '3002': InsufficientFunds, '10204': DDoSProtection, }, @@ -16644,6 +18227,7 @@ module.exports = class bitforex extends Exchange { 'symbol': symbol, 'type': type, 'timeInForce': undefined, + 'postOnly': undefined, 'side': side, 'price': price, 'stopPrice': undefined, @@ -16772,7 +18356,7 @@ module.exports = class bitforex extends Exchange { } }; -},{"./base/Exchange":5,"./base/errors":7}],33:[function(require,module,exports){ +},{"./base/Exchange":6,"./base/errors":8}],33:[function(require,module,exports){ 'use strict'; // --------------------------------------------------------------------------- @@ -18479,7 +20063,7 @@ module.exports = class bitget extends Exchange { const type = this.safeString (params, 'type', defaultType); params = this.omit (params, 'type'); if (type === undefined) { - throw new ArgumentsRequired (this.id + " requires an 'accountId' parameter"); + throw new ArgumentsRequired (this.id + " getAccountId() requires an 'accountId' parameter"); } const account = await this.findAccountByType (type); return account['id']; @@ -18491,7 +20075,7 @@ module.exports = class bitget extends Exchange { const defaultType = this.safeString2 (this.options, 'fetchBalance', 'defaultType'); const type = this.safeString (params, 'type', defaultType); if (type === undefined) { - throw new ArgumentsRequired (this.id + " fetchBalance requires a 'type' parameter, one of 'spot', 'swap'"); + throw new ArgumentsRequired (this.id + " fetchBalance() requires a 'type' parameter, one of 'spot', 'swap'"); } let method = undefined; const query = this.omit (params, 'type'); @@ -18735,6 +20319,7 @@ module.exports = class bitget extends Exchange { 'symbol': symbol, 'type': type, 'timeInForce': undefined, + 'postOnly': undefined, 'side': side, 'price': price, 'stopPrice': undefined, @@ -18817,7 +20402,7 @@ module.exports = class bitget extends Exchange { request['client_oid'] = clientOrderId; const orderType = this.safeString (params, 'type'); if (orderType === undefined) { - throw new ArgumentsRequired (this.id + " createOrder requires a type parameter, '1' = open long, '2' = open short, '3' = close long, '4' = close short for " + market['type'] + ' orders'); + throw new ArgumentsRequired (this.id + " createOrder() requires a type parameter, '1' = open long, '2' = open short, '3' = close long, '4' = close short for " + market['type'] + ' orders'); } request['size'] = this.amountToPrecision (symbol, amount); request['type'] = orderType; @@ -18859,7 +20444,7 @@ module.exports = class bitget extends Exchange { const type = this.safeString (params, 'type', defaultType); if (type === 'spot') { if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' cancelOrder requires a symbol argument for spot orders'); + throw new ArgumentsRequired (this.id + ' cancelOrder() requires a symbol argument for spot orders'); } } } else { @@ -18900,14 +20485,15 @@ module.exports = class bitget extends Exchange { async cancelOrders (ids, symbol = undefined, params = {}) { if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' cancelOrders requires a symbol argument'); + throw new ArgumentsRequired (this.id + ' cancelOrders() requires a symbol argument'); } await this.loadMarkets (); const market = this.market (symbol); const type = this.safeString (params, 'type', market['type']); if (type === undefined) { - throw new ArgumentsRequired (this.id + " cancelOrders requires a type parameter (one of 'spot', 'swap')."); + throw new ArgumentsRequired (this.id + " cancelOrders() requires a type parameter (one of 'spot', 'swap')."); } + params = this.omit (params, 'type'); const request = {}; let method = undefined; if (type === 'spot') { @@ -18964,13 +20550,13 @@ module.exports = class bitget extends Exchange { async fetchOrder (id, symbol = undefined, params = {}) { if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' fetchOrder requires a symbol argument'); + throw new ArgumentsRequired (this.id + ' fetchOrder() requires a symbol argument'); } await this.loadMarkets (); const market = this.market (symbol); const type = this.safeString (params, 'type', market['type']); if (type === undefined) { - throw new ArgumentsRequired (this.id + " fetchOrder requires a type parameter (one of 'spot', 'swap')."); + throw new ArgumentsRequired (this.id + " fetchOrder() requires a type parameter (one of 'spot', 'swap')."); } let method = undefined; const request = {}; @@ -19041,7 +20627,7 @@ module.exports = class bitget extends Exchange { async fetchOpenOrders (symbol = undefined, since = undefined, limit = undefined, params = {}) { if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' fetchOpenOrders requires a symbol argument'); + throw new ArgumentsRequired (this.id + ' fetchOpenOrders() requires a symbol argument'); } await this.loadMarkets (); const market = this.market (symbol); @@ -19126,7 +20712,7 @@ module.exports = class bitget extends Exchange { async fetchClosedOrders (symbol = undefined, since = undefined, limit = undefined, params = {}) { if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' fetchClosedOrders requires a symbol argument'); + throw new ArgumentsRequired (this.id + ' fetchClosedOrders() requires a symbol argument'); } await this.loadMarkets (); const market = this.market (symbol); @@ -19218,7 +20804,7 @@ module.exports = class bitget extends Exchange { async fetchDeposits (code = undefined, since = undefined, limit = undefined, params = {}) { if (code === undefined) { - throw new ArgumentsRequired (this.id + ' fetchDeposits requires a currency code argument'); + throw new ArgumentsRequired (this.id + ' fetchDeposits() requires a currency code argument'); } await this.loadMarkets (); const currency = this.currency (code); @@ -19255,7 +20841,7 @@ module.exports = class bitget extends Exchange { async fetchWithdrawals (code = undefined, since = undefined, limit = undefined, params = {}) { if (code === undefined) { - throw new ArgumentsRequired (this.id + ' fetchWithdrawals requires a currency code argument'); + throw new ArgumentsRequired (this.id + ' fetchWithdrawals() requires a currency code argument'); } await this.loadMarkets (); const currency = this.currency (code); @@ -19378,14 +20964,14 @@ module.exports = class bitget extends Exchange { async fetchMyTrades (symbol = undefined, since = undefined, limit = undefined, params = {}) { if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' fetchMyTrades requires a symbol argument'); + throw new ArgumentsRequired (this.id + ' fetchMyTrades() requires a symbol argument'); } await this.loadMarkets (); const market = this.market (symbol); const type = this.safeString (params, 'type', market['type']); const query = this.omit (params, 'type'); if (type === 'swap') { - throw new ArgumentsRequired (this.id + ' fetchMyTrades is not supported for ' + type + ' type'); + throw new ArgumentsRequired (this.id + ' fetchMyTrades() is not supported for ' + type + ' type'); } // // spot @@ -19442,12 +21028,12 @@ module.exports = class bitget extends Exchange { async fetchOrderTrades (id, symbol = undefined, since = undefined, limit = undefined, params = {}) { if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' fetchOrderTrades requires a symbol argument'); + throw new ArgumentsRequired (this.id + ' fetchOrderTrades() requires a symbol argument'); } await this.loadMarkets (); const market = this.market (symbol); const type = this.safeString (params, 'type', market['type']); - const query = this.omit (params, 'type'); + params = this.omit (params, 'type'); let method = undefined; const request = {}; if (type === 'spot') { @@ -19459,7 +21045,7 @@ module.exports = class bitget extends Exchange { request['symbol'] = market['id']; method = 'swapGetOrderFills'; } - const response = await this[method] (this.extend (request, query)); + const response = await this[method] (this.extend (request, params)); // // spot // @@ -19678,7 +21264,7 @@ module.exports = class bitget extends Exchange { } }; -},{"./base/Exchange":5,"./base/errors":7,"./base/functions/number":13}],34:[function(require,module,exports){ +},{"./base/Exchange":6,"./base/errors":8,"./base/functions/number":14}],34:[function(require,module,exports){ 'use strict'; // --------------------------------------------------------------------------- @@ -19703,6 +21289,7 @@ module.exports = class bithumb extends Exchange { 'createOrder': true, 'fetchBalance': true, 'fetchMarkets': true, + 'fetchOHLCV': true, 'fetchOpenOrders': true, 'fetchOrder': true, 'fetchOrderBook': true, @@ -19726,10 +21313,13 @@ module.exports = class bithumb extends Exchange { 'get': [ 'ticker/{currency}', 'ticker/all', + 'ticker/ALL_BTC', + 'ticker/ALL_KRW', 'orderbook/{currency}', 'orderbook/all', 'transaction_history/{currency}', 'transaction_history/all', + 'candlestick/{currency}/{interval}', ], }, 'private': { @@ -19773,6 +21363,27 @@ module.exports = class bithumb extends Exchange { 'Unknown Error': ExchangeError, 'After May 23th, recent_transactions is no longer, hence users will not be able to connect to recent_transactions': ExchangeError, // {"status":"5100","message":"After May 23th, recent_transactions is no longer, hence users will not be able to connect to recent_transactions"} }, + 'timeframes': { + '1m': '1m', + '3m': '3m', + '5m': '5m', + '10m': '10m', + '30m': '30m', + '1h': '1h', + '6h': '6h', + '12h': '12h', + '1d': '24h', + }, + 'options': { + 'quoteCurrencies': { + 'BTC': { + 'precision': { + 'price': 8, + }, + }, + 'KRW': {}, + }, + }, }); } @@ -19781,54 +21392,61 @@ module.exports = class bithumb extends Exchange { } async fetchMarkets (params = {}) { - const response = await this.publicGetTickerAll (params); - const data = this.safeValue (response, 'data'); - const currencyIds = Object.keys (data); const result = []; - const quote = this.safeCurrencyCode ('KRW'); - for (let i = 0; i < currencyIds.length; i++) { - const currencyId = currencyIds[i]; - if (currencyId === 'date') { - continue; - } - const market = data[currencyId]; - const base = this.safeCurrencyCode (currencyId); - const symbol = currencyId + '/' + quote; - let active = true; - if (Array.isArray (market)) { - const numElements = market.length; - if (numElements === 0) { - active = false; + const quoteCurrencies = this.safeValue (this.options, 'quoteCurrencies', {}); + const quotes = Object.keys (quoteCurrencies); + for (let i = 0; i < quotes.length; i++) { + const quote = quotes[i]; + const extension = this.safeValue (quoteCurrencies, quote, {}); + const method = 'publicGetTickerALL' + quote; + const response = await this[method] (params); + const data = this.safeValue (response, 'data'); + const currencyIds = Object.keys (data); + for (let j = 0; j < currencyIds.length; j++) { + const currencyId = currencyIds[j]; + if (currencyId === 'date') { + continue; } + const market = data[currencyId]; + const base = this.safeCurrencyCode (currencyId); + const symbol = currencyId + '/' + quote; + let active = true; + if (Array.isArray (market)) { + const numElements = market.length; + if (numElements === 0) { + active = false; + } + } + const entry = this.deepExtend ({ + 'id': currencyId, + 'symbol': symbol, + 'base': base, + 'quote': quote, + 'info': market, + 'active': active, + 'precision': { + 'amount': 4, + 'price': 4, + }, + 'limits': { + 'amount': { + 'min': undefined, + 'max': undefined, + }, + 'price': { + 'min': undefined, + 'max': undefined, + }, + 'cost': { + 'min': 500, + 'max': 5000000000, + }, + }, + 'baseId': undefined, + 'quoteId': undefined, + }, extension); + result.push (entry); } - result.push ({ - 'id': currencyId, - 'symbol': symbol, - 'base': base, - 'quote': quote, - 'info': market, - 'active': active, - 'precision': { - 'amount': 4, - 'price': 4, - }, - 'limits': { - 'amount': { - 'min': undefined, - 'max': undefined, - }, - 'price': { - 'min': undefined, - 'max': undefined, - }, - 'cost': { - 'min': 500, - 'max': 5000000000, - }, - }, - 'baseId': undefined, - 'quoteId': undefined, - }); } return result; } @@ -20030,6 +21648,62 @@ module.exports = class bithumb extends Exchange { return this.parseTicker (data, market); } + parseOHLCV (ohlcv, market = undefined) { + // + // [ + // 1576823400000, // 기준 시간 + // '8284000', // 시가 + // '8286000', // 종가 + // '8289000', // 고가 + // '8276000', // 저가 + // '15.41503692' // 거래량 + // ] + // + return [ + this.safeInteger (ohlcv, 0), + this.safeFloat (ohlcv, 1), + this.safeFloat (ohlcv, 3), + this.safeFloat (ohlcv, 4), + this.safeFloat (ohlcv, 2), + this.safeFloat (ohlcv, 5), + ]; + } + + async fetchOHLCV (symbol, timeframe = '1m', since = undefined, limit = undefined, params = {}) { + await this.loadMarkets (); + const market = this.market (symbol); + const request = { + 'currency': market['base'], + 'interval': this.timeframes[timeframe], + }; + const response = await this.publicGetCandlestickCurrencyInterval (this.extend (request, params)); + // + // { + // 'status': '0000', + // 'data': { + // [ + // 1576823400000, // 기준 시간 + // '8284000', // 시가 + // '8286000', // 종가 + // '8289000', // 고가 + // '8276000', // 저가 + // '15.41503692' // 거래량 + // ], + // [ + // 1576824000000, // 기준 시간 + // '8284000', // 시가 + // '8281000', // 종가 + // '8289000', // 고가 + // '8275000', // 저가 + // '6.19584467' // 거래량 + // ], + // } + // } + // + const data = this.safeValue (response, 'data', []); + return this.parseOHLCVs (data, market, timeframe, since, limit); + } + parseTrade (trade, market = undefined) { // // fetchTrades (public) @@ -20151,7 +21825,7 @@ module.exports = class bithumb extends Exchange { const market = this.market (symbol); const request = { 'order_currency': market['id'], - 'Payment_currency': market['quote'], + 'payment_currency': market['quote'], 'units': amount, }; let method = 'privatePostTradePlace'; @@ -20164,7 +21838,7 @@ module.exports = class bithumb extends Exchange { const response = await this[method] (this.extend (request, params)); const id = this.safeString (response, 'order_id'); if (id === undefined) { - throw new InvalidOrder (this.id + ' createOrder did not return an order id'); + throw new InvalidOrder (this.id + ' createOrder() did not return an order id'); } return { 'info': response, @@ -20177,7 +21851,7 @@ module.exports = class bithumb extends Exchange { async fetchOrder (id, symbol = undefined, params = {}) { if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' fetchOrder requires a symbol argument'); + throw new ArgumentsRequired (this.id + ' fetchOrder() requires a symbol argument'); } await this.loadMarkets (); const market = this.market (symbol); @@ -20389,6 +22063,7 @@ module.exports = class bithumb extends Exchange { 'symbol': symbol, 'type': type, 'timeInForce': undefined, + 'postOnly': undefined, 'side': side, 'price': price, 'stopPrice': undefined, @@ -20411,7 +22086,7 @@ module.exports = class bithumb extends Exchange { async fetchOpenOrders (symbol = undefined, since = undefined, limit = undefined, params = {}) { if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' fetchOpenOrders requires a symbol argument'); + throw new ArgumentsRequired (this.id + ' fetchOpenOrders() requires a symbol argument'); } await this.loadMarkets (); const market = this.market (symbol); @@ -20451,10 +22126,10 @@ module.exports = class bithumb extends Exchange { async cancelOrder (id, symbol = undefined, params = {}) { const side_in_params = ('side' in params); if (!side_in_params) { - throw new ArgumentsRequired (this.id + ' cancelOrder requires a `symbol` argument and a `side` parameter (sell or buy)'); + throw new ArgumentsRequired (this.id + ' cancelOrder() requires a `symbol` argument and a `side` parameter (sell or buy)'); } if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' cancelOrder requires a `symbol` argument and a `side` parameter (sell or buy)'); + throw new ArgumentsRequired (this.id + ' cancelOrder() requires a `symbol` argument and a `side` parameter (sell or buy)'); } const market = this.market (symbol); const side = (params['side'] === 'buy') ? 'bid' : 'ask'; @@ -20485,7 +22160,7 @@ module.exports = class bithumb extends Exchange { 'address': address, 'currency': currency['id'], }; - if (currency === 'XRP' || currency === 'XMR') { + if (currency === 'XRP' || currency === 'XMR' || currency === 'EOS' || currency === 'STEEM') { const destination = this.safeString (params, 'destination'); if ((tag === undefined) && (destination === undefined)) { throw new ArgumentsRequired (this.id + ' ' + code + ' withdraw() requires a tag argument or an extra destination param'); @@ -20566,7 +22241,7 @@ module.exports = class bithumb extends Exchange { } }; -},{"./base/Exchange":5,"./base/errors":7,"./base/functions/number":13}],35:[function(require,module,exports){ +},{"./base/Exchange":6,"./base/errors":8,"./base/functions/number":14}],35:[function(require,module,exports){ 'use strict'; // --------------------------------------------------------------------------- @@ -20590,11 +22265,14 @@ module.exports = class bitkk extends zb { 'doc': 'https://www.bitkk.com/i/developer', 'fees': 'https://www.bitkk.com/i/rate', }, + 'commonCurrencies': { + 'BCH': 'BCHOLD', + }, }); } }; -},{"./zb.js":179}],36:[function(require,module,exports){ +},{"./zb.js":182}],36:[function(require,module,exports){ 'use strict'; // --------------------------------------------------------------------------- @@ -20645,7 +22323,7 @@ module.exports = class bitmart extends Exchange { 'logo': 'https://user-images.githubusercontent.com/1294454/61835713-a2662f80-ae85-11e9-9d00-6442919701fd.jpg', 'api': 'https://api-cloud.{hostname}', // bitmart.info for Hong Kong users 'www': 'https://www.bitmart.com/', - 'doc': 'https://github.com/bitmartexchange/bitmart-official-api-docs', + 'doc': 'https://developer-pro.bitmart.com/', 'referral': 'http://www.bitmart.com/?r=rQCFLh', 'fees': 'https://www.bitmart.com/fee/en', }, @@ -20758,8 +22436,8 @@ module.exports = class bitmart extends Exchange { 'trading': { 'tierBased': true, 'percentage': true, - 'taker': 0.002, - 'maker': 0.001, + 'taker': 0.0025, + 'maker': 0.0025, 'tiers': { 'taker': [ [0, 0.20 / 100], @@ -20893,6 +22571,8 @@ module.exports = class bitmart extends Exchange { 'broad': {}, }, 'commonCurrencies': { + 'COT': 'Community Coin', + 'CPC': 'CPCoin', 'ONE': 'Menlo One', 'PLA': 'Plair', }, @@ -21838,7 +23518,7 @@ module.exports = class bitmart extends Exchange { async fetchMyTrades (symbol = undefined, since = undefined, limit = undefined, params = {}) { if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' fetchMyTrades requires a symbol argument'); + throw new ArgumentsRequired (this.id + ' fetchMyTrades() requires a symbol argument'); } await this.loadMarkets (); const market = this.market (symbol); @@ -21846,7 +23526,7 @@ module.exports = class bitmart extends Exchange { const request = {}; if (market['spot']) { request['symbol'] = market['id']; - request['offset'] = 1; + request['offset'] = 1; // max offset * limit < 500 if (limit === undefined) { limit = 100; // max 100 } @@ -21919,7 +23599,7 @@ module.exports = class bitmart extends Exchange { async fetchOrderTrades (id, symbol = undefined, since = undefined, limit = undefined, params = {}) { if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' fetchOrderTrades requires a symbol argument'); + throw new ArgumentsRequired (this.id + ' fetchOrderTrades() requires a symbol argument'); } await this.loadMarkets (); const market = this.market (symbol); @@ -22197,6 +23877,7 @@ module.exports = class bitmart extends Exchange { 'symbol': symbol, 'type': type, 'timeInForce': undefined, + 'postOnly': undefined, 'side': side, 'price': price, 'stopPrice': undefined, @@ -22302,7 +23983,7 @@ module.exports = class bitmart extends Exchange { async cancelOrder (id, symbol = undefined, params = {}) { if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' cancelOrder requires a symbol argument'); + throw new ArgumentsRequired (this.id + ' cancelOrder() requires a symbol argument'); } await this.loadMarkets (); const market = this.market (symbol); @@ -22330,6 +24011,15 @@ module.exports = class bitmart extends Exchange { // } // } // + // spot alternative + // + // { + // "code": 1000, + // "trace":"886fb6ae-456b-4654-b4e0-d681ac05cea1", + // "message": "OK", + // "data": true + // } + // // contract // // { @@ -22345,16 +24035,19 @@ module.exports = class bitmart extends Exchange { // } // const data = this.safeValue (response, 'data'); + if (data === true) { + return this.parseOrder (id, market); + } const succeeded = this.safeValue (data, 'succeed'); if (succeeded !== undefined) { id = this.safeString (succeeded, 0); if (id === undefined) { - throw new InvalidOrder (this.id + ' cancelOrder failed to cancel ' + symbol + ' order id ' + id); + throw new InvalidOrder (this.id + ' cancelOrder() failed to cancel ' + symbol + ' order id ' + id); } } else { const result = this.safeValue (data, 'result'); if (!result) { - throw new InvalidOrder (this.id + ' cancelOrder ' + symbol + ' order id ' + id + ' is filled or canceled'); + throw new InvalidOrder (this.id + ' cancelOrder() ' + symbol + ' order id ' + id + ' is filled or canceled'); } } const order = this.parseOrder (id, market); @@ -22363,16 +24056,16 @@ module.exports = class bitmart extends Exchange { async cancelAllOrders (symbol = undefined, params = {}) { if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' cancelAllOrders requires a symbol argument'); + throw new ArgumentsRequired (this.id + ' cancelAllOrders() requires a symbol argument'); } const side = this.safeString (params, 'side'); if (side === undefined) { - throw new ArgumentsRequired (this.id + " cancelAllOrders requires a `side` parameter ('buy' or 'sell')"); + throw new ArgumentsRequired (this.id + " cancelAllOrders() requires a `side` parameter ('buy' or 'sell')"); } await this.loadMarkets (); const market = this.market (symbol); if (!market['spot']) { - throw new NotSupported (this.id + ' cancelAllOrders does not support ' + market['type'] + ' orders, only spot orders are accepted'); + throw new NotSupported (this.id + ' cancelAllOrders() does not support ' + market['type'] + ' orders, only spot orders are accepted'); } const request = { 'symbol': market['id'], @@ -22392,12 +24085,12 @@ module.exports = class bitmart extends Exchange { async cancelOrders (ids, symbol = undefined, params = {}) { if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' canelOrders requires a symbol argument'); + throw new ArgumentsRequired (this.id + ' canelOrders() requires a symbol argument'); } await this.loadMarkets (); const market = this.market (symbol); if (!market['spot']) { - throw new NotSupported (this.id + ' cancelOrders does not support ' + market['type'] + ' orders, only contract orders are accepted'); + throw new NotSupported (this.id + ' cancelOrders() does not support ' + market['type'] + ' orders, only contract orders are accepted'); } const orders = []; for (let i = 0; i < ids.length; i++) { @@ -22438,7 +24131,7 @@ module.exports = class bitmart extends Exchange { async fetchOrdersByStatus (status, symbol = undefined, since = undefined, limit = undefined, params = {}) { if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' fetchOrdersByStatus requires a symbol argument'); + throw new ArgumentsRequired (this.id + ' fetchOrdersByStatus() requires a symbol argument'); } await this.loadMarkets (); const market = this.market (symbol); @@ -22560,7 +24253,7 @@ module.exports = class bitmart extends Exchange { async fetchOrders (symbol = undefined, since = undefined, limit = undefined, params = {}) { if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' fetchOrders requires a symbol argument'); + throw new ArgumentsRequired (this.id + ' fetchOrders() requires a symbol argument'); } await this.loadMarkets (); const market = this.market (symbol); @@ -22572,7 +24265,7 @@ module.exports = class bitmart extends Exchange { async fetchOrder (id, symbol = undefined, params = {}) { if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' fetchOrder requires a symbol argument'); + throw new ArgumentsRequired (this.id + ' fetchOrder() requires a symbol argument'); } await this.loadMarkets (); const request = {}; @@ -22650,7 +24343,7 @@ module.exports = class bitmart extends Exchange { const orders = this.safeValue (data, 'orders', []); const firstOrder = this.safeValue (orders, 0); if (firstOrder === undefined) { - throw new OrderNotFound (this.id + ' fetchOrder could not find ' + symbol + ' order id ' + id); + throw new OrderNotFound (this.id + ' fetchOrder() could not find ' + symbol + ' order id ' + id); } return this.parseOrder (firstOrder, market); } else { @@ -22944,7 +24637,7 @@ module.exports = class bitmart extends Exchange { } }; -},{"./base/Exchange":5,"./base/errors":7,"./base/functions/number":13}],37:[function(require,module,exports){ +},{"./base/Exchange":6,"./base/errors":8,"./base/functions/number":14}],37:[function(require,module,exports){ 'use strict'; // --------------------------------------------------------------------------- @@ -23080,8 +24773,8 @@ module.exports = class bitmax extends Exchange { 'trading': { 'tierBased': true, 'percentage': true, - 'taker': 0.001, - 'maker': 0.001, + 'taker': 0.002, + 'maker': 0.002, }, }, 'precisionMode': TICK_SIZE, @@ -23986,6 +25679,7 @@ module.exports = class bitmax extends Exchange { 'symbol': symbol, 'type': type, 'timeInForce': undefined, + 'postOnly': undefined, 'side': side, 'price': price, 'stopPrice': stopPrice, @@ -24036,7 +25730,7 @@ module.exports = class bitmax extends Exchange { if ((type === 'stop_limit') || (type === 'stop_market')) { const stopPrice = this.safeFloat (params, 'stopPrice'); if (stopPrice === undefined) { - throw new InvalidOrder (this.id + ' createOrder requires a stopPrice parameter for ' + type + ' orders'); + throw new InvalidOrder (this.id + ' createOrder() requires a stopPrice parameter for ' + type + ' orders'); } else { request['stopPrice'] = this.priceToPrecision (symbol, stopPrice); params = this.omit (params, 'stopPrice'); @@ -24291,7 +25985,7 @@ module.exports = class bitmax extends Exchange { async cancelOrder (id, symbol = undefined, params = {}) { if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' cancelOrder requires a symbol argument'); + throw new ArgumentsRequired (this.id + ' cancelOrder() requires a symbol argument'); } await this.loadMarkets (); await this.loadAccounts (); @@ -24671,14 +26365,14 @@ module.exports = class bitmax extends Exchange { } }; -},{"./base/Exchange":5,"./base/errors":7,"./base/functions/number":13}],38:[function(require,module,exports){ +},{"./base/Exchange":6,"./base/errors":8,"./base/functions/number":14}],38:[function(require,module,exports){ 'use strict'; // --------------------------------------------------------------------------- const Exchange = require ('./base/Exchange'); const { TICK_SIZE } = require ('./base/functions/number'); -const { AuthenticationError, BadRequest, DDoSProtection, ExchangeError, ExchangeNotAvailable, InsufficientFunds, InvalidOrder, OrderNotFound, PermissionDenied } = require ('./base/errors'); +const { AuthenticationError, BadRequest, DDoSProtection, ExchangeError, ExchangeNotAvailable, InsufficientFunds, InvalidOrder, OrderNotFound, PermissionDenied, ArgumentsRequired } = require ('./base/errors'); // --------------------------------------------------------------------------- @@ -24841,6 +26535,7 @@ module.exports = class bitmex extends Exchange { 'Account has insufficient Available Balance': InsufficientFunds, 'Service unavailable': ExchangeNotAvailable, // {"error":{"message":"Service unavailable","name":"HTTPError"}} 'Server Error': ExchangeError, // {"error":{"message":"Server Error","name":"HTTPError"}} + 'Unable to cancel order due to existing state': InvalidOrder, }, }, 'precisionMode': TICK_SIZE, @@ -25893,6 +27588,43 @@ module.exports = class bitmex extends Exchange { } parseOrder (order, market = undefined) { + // + // { + // "orderID":"56222c7a-9956-413a-82cf-99f4812c214b", + // "clOrdID":"", + // "clOrdLinkID":"", + // "account":1455728, + // "symbol":"XBTUSD", + // "side":"Sell", + // "simpleOrderQty":null, + // "orderQty":1, + // "price":40000, + // "displayQty":null, + // "stopPx":null, + // "pegOffsetValue":null, + // "pegPriceType":"", + // "currency":"USD", + // "settlCurrency":"XBt", + // "ordType":"Limit", + // "timeInForce":"GoodTillCancel", + // "execInst":"", + // "contingencyType":"", + // "exDestination":"XBME", + // "ordStatus":"New", + // "triggered":"", + // "workingIndicator":true, + // "ordRejReason":"", + // "simpleLeavesQty":null, + // "leavesQty":1, + // "simpleCumQty":null, + // "cumQty":0, + // "avgPx":null, + // "multiLegReportingType":"SingleSecurity", + // "text":"Submitted via API.", + // "transactTime":"2021-01-02T21:38:49.246Z", + // "timestamp":"2021-01-02T21:38:49.246Z" + // } + // const status = this.parseOrderStatus (this.safeString (order, 'ordStatus')); const marketId = this.safeString (order, 'symbol'); const symbol = this.safeSymbol (marketId, market); @@ -25922,6 +27654,8 @@ module.exports = class bitmex extends Exchange { const clientOrderId = this.safeString (order, 'clOrdID'); const timeInForce = this.parseTimeInForce (this.safeString (order, 'timeInForce')); const stopPrice = this.safeFloat (order, 'stopPx'); + const execInst = this.safeString (order, 'execInst'); + const postOnly = (execInst === 'ParticipateDoNotInitiate'); return { 'info': order, 'id': id, @@ -25932,6 +27666,7 @@ module.exports = class bitmex extends Exchange { 'symbol': symbol, 'type': type, 'timeInForce': timeInForce, + 'postOnly': postOnly, 'side': side, 'price': price, 'stopPrice': stopPrice, @@ -26000,18 +27735,21 @@ module.exports = class bitmex extends Exchange { const request = { 'symbol': market['id'], 'side': this.capitalize (side), - 'orderQty': amount, + 'orderQty': parseFloat (this.amountToPrecision (symbol, amount)), 'ordType': orderType, }; - if (price !== undefined) { - if (orderType === 'Stop') { - const stopPrice = this.safeFloat2 (params, 'stopPx', 'stopPrice'); - request['stopPx'] = stopPrice; - params = this.omit (params, [ 'stopPx', 'stopPrice' ]); + if ((orderType === 'Stop') || (orderType === 'StopLimit') || (orderType === 'MarketIfTouched') || (orderType === 'LimitIfTouched')) { + const stopPrice = this.safeFloat2 (params, 'stopPx', 'stopPrice'); + if (stopPrice === undefined) { + throw new ArgumentsRequired (this.id + ' createOrder() requires a stopPx or stopPrice parameter for the ' + orderType + ' order type'); } else { - request['price'] = price; + request['stopPx'] = parseFloat (this.priceToPrecision (symbol, stopPrice)); + params = this.omit (params, [ 'stopPx', 'stopPrice' ]); } } + if ((orderType === 'Limit') || (orderType === 'StopLimit') || (orderType === 'LimitIfTouched')) { + request['price'] = parseFloat (this.priceToPrecision (symbol, price)); + } const clientOrderId = this.safeString2 (params, 'clOrdID', 'clientOrderId'); if (clientOrderId !== undefined) { request['clOrdID'] = clientOrderId; @@ -26313,7 +28051,7 @@ module.exports = class bitmex extends Exchange { } }; -},{"./base/Exchange":5,"./base/errors":7,"./base/functions/number":13}],39:[function(require,module,exports){ +},{"./base/Exchange":6,"./base/errors":8,"./base/functions/number":14}],39:[function(require,module,exports){ 'use strict'; // --------------------------------------------------------------------------- @@ -27106,7 +28844,10 @@ module.exports = class bitpanda extends Exchange { // const feeInfo = this.safeValue (trade, 'fee', {}); trade = this.safeValue (trade, 'trade', trade); - const timestamp = this.parse8601 (this.safeString (trade, 'time')); + let timestamp = this.safeInteger (trade, 'trade_timestamp'); + if (timestamp === undefined) { + timestamp = this.parse8601 (this.safeString (trade, 'time')); + } const side = this.safeStringLower2 (trade, 'side', 'taker_side'); const price = this.safeFloat (trade, 'price'); const amount = this.safeFloat (trade, 'amount'); @@ -27281,7 +29022,7 @@ module.exports = class bitpanda extends Exchange { if (since !== undefined) { const to = this.safeString (params, 'to'); if (to === undefined) { - throw new ArgumentsRequired (this.id + ' fetchDeposits requires a "to" iso8601 string param with the since argument is specified'); + throw new ArgumentsRequired (this.id + ' fetchDeposits() requires a "to" iso8601 string param with the since argument is specified'); } request['from'] = this.iso8601 (since); } @@ -27336,7 +29077,7 @@ module.exports = class bitpanda extends Exchange { if (since !== undefined) { const to = this.safeString (params, 'to'); if (to === undefined) { - throw new ArgumentsRequired (this.id + ' fetchWithdrawals requires a "to" iso8601 string param with the since argument is specified'); + throw new ArgumentsRequired (this.id + ' fetchWithdrawals() requires a "to" iso8601 string param with the since argument is specified'); } request['from'] = this.iso8601 (since); } @@ -27641,6 +29382,7 @@ module.exports = class bitpanda extends Exchange { } const timeInForce = this.parseTimeInForce (this.safeString (order, 'time_in_force')); const stopPrice = this.safeFloat (order, 'trigger_price'); + const postOnly = this.safeValue (order, 'is_post_only'); const result = { 'id': id, 'clientOrderId': clientOrderId, @@ -27651,6 +29393,7 @@ module.exports = class bitpanda extends Exchange { 'symbol': symbol, 'type': type, 'timeInForce': timeInForce, + 'postOnly': postOnly, 'side': side, 'price': price, 'stopPrice': stopPrice, @@ -27725,7 +29468,7 @@ module.exports = class bitpanda extends Exchange { if (uppercaseType === 'STOP') { const triggerPrice = this.safeFloat (params, 'trigger_price'); if (triggerPrice === undefined) { - throw new ArgumentsRequired (this.id + ' createOrder requires a trigger_price param for ' + type + ' orders'); + throw new ArgumentsRequired (this.id + ' createOrder() requires a trigger_price param for ' + type + ' orders'); } request['trigger_price'] = this.priceToPrecision (symbol, triggerPrice); params = this.omit (params, 'trigger_price'); @@ -27876,7 +29619,7 @@ module.exports = class bitpanda extends Exchange { if (since !== undefined) { const to = this.safeString (params, 'to'); if (to === undefined) { - throw new ArgumentsRequired (this.id + ' fetchOrders requires a "to" iso8601 string param with the since argument is specified, max range is 100 days'); + throw new ArgumentsRequired (this.id + ' fetchOrders() requires a "to" iso8601 string param with the since argument is specified, max range is 100 days'); } request['from'] = this.iso8601 (since); } @@ -28040,7 +29783,7 @@ module.exports = class bitpanda extends Exchange { if (since !== undefined) { const to = this.safeString (params, 'to'); if (to === undefined) { - throw new ArgumentsRequired (this.id + ' fetchMyTrades requires a "to" iso8601 string param with the since argument is specified, max range is 100 days'); + throw new ArgumentsRequired (this.id + ' fetchMyTrades() requires a "to" iso8601 string param with the since argument is specified, max range is 100 days'); } request['from'] = this.iso8601 (since); } @@ -28126,14 +29869,14 @@ module.exports = class bitpanda extends Exchange { } }; -},{"./base/Exchange":5,"./base/errors":7}],40:[function(require,module,exports){ +},{"./base/Exchange":6,"./base/errors":8}],40:[function(require,module,exports){ 'use strict'; // --------------------------------------------------------------------------- const Exchange = require ('./base/Exchange'); const { ExchangeError, InvalidNonce, AuthenticationError, OrderNotFound } = require ('./base/errors'); -const { TICK_SIZE } = require ('./base/functions/number'); +const { TICK_SIZE, ROUND } = require ('./base/functions/number'); // --------------------------------------------------------------------------- @@ -28310,23 +30053,25 @@ module.exports = class bitso extends Exchange { const taker = this.safeFloat (flatRate, 'taker'); const feeTiers = this.safeValue (fees, 'structure', []); const fee = { - 'maker': maker, - 'taker': taker, + 'taker': parseFloat (this.decimalToPrecision (taker / 100, ROUND, 0.00000001, TICK_SIZE)), + 'maker': parseFloat (this.decimalToPrecision (maker / 100, ROUND, 0.00000001, TICK_SIZE)), 'percentage': true, 'tierBased': true, }; const takerFees = []; const makerFees = []; - for (let i = 0; i < feeTiers.length; i++) { - const tier = feeTiers[i]; + for (let j = 0; j < feeTiers.length; j++) { + const tier = feeTiers[j]; const volume = this.safeFloat (tier, 'volume'); const takerFee = this.safeFloat (tier, 'taker'); const makerFee = this.safeFloat (tier, 'maker'); - takerFees.push ([ volume, takerFee ]); - makerFees.push ([ volume, makerFee ]); - if (i === 0) { - fee['taker'] = taker; - fee['maker'] = maker; + const takerFeeToPrecision = parseFloat (this.decimalToPrecision (takerFee / 100, ROUND, 0.00000001, TICK_SIZE)); + const makerFeeToPrecision = parseFloat (this.decimalToPrecision (makerFee / 100, ROUND, 0.00000001, TICK_SIZE)); + takerFees.push ([ volume, takerFeeToPrecision ]); + makerFees.push ([ volume, makerFeeToPrecision ]); + if (j === 0) { + fee['taker'] = parseFloat (this.decimalToPrecision (taker / 100, ROUND, 0.00000001, TICK_SIZE)); + fee['maker'] = parseFloat (this.decimalToPrecision (maker / 100, ROUND, 0.00000001, TICK_SIZE)); } } const tiers = { @@ -28563,6 +30308,7 @@ module.exports = class bitso extends Exchange { 'symbol': symbol, 'type': orderType, 'timeInForce': undefined, + 'postOnly': undefined, 'side': side, 'price': price, 'stopPrice': undefined, @@ -28750,13 +30496,13 @@ module.exports = class bitso extends Exchange { } }; -},{"./base/Exchange":5,"./base/errors":7,"./base/functions/number":13}],41:[function(require,module,exports){ +},{"./base/Exchange":6,"./base/errors":8,"./base/functions/number":14}],41:[function(require,module,exports){ 'use strict'; // --------------------------------------------------------------------------- const Exchange = require ('./base/Exchange'); -const { AuthenticationError, ExchangeError, NotSupported, PermissionDenied, InvalidNonce, OrderNotFound, InsufficientFunds, InvalidAddress, InvalidOrder, ArgumentsRequired, OnMaintenance } = require ('./base/errors'); +const { AuthenticationError, ExchangeError, NotSupported, PermissionDenied, InvalidNonce, OrderNotFound, InsufficientFunds, InvalidAddress, InvalidOrder, ArgumentsRequired, OnMaintenance, ExchangeNotAvailable } = require ('./base/errors'); // --------------------------------------------------------------------------- @@ -28976,6 +30722,7 @@ module.exports = class bitstamp extends Exchange { 'Order not found': OrderNotFound, 'Price is more than 20% below market price.': InvalidOrder, 'Bitstamp.net is under scheduled maintenance.': OnMaintenance, // { "error": "Bitstamp.net is under scheduled maintenance. We'll be back soon." } + 'Order could not be placed.': ExchangeNotAvailable, // Order could not be placed (perhaps due to internal error or trade halt). Please retry placing order. }, 'broad': { 'Minimum order size is': InvalidOrder, // Minimum order size is 5.0 EUR. @@ -29458,7 +31205,7 @@ module.exports = class bitstamp extends Exchange { const duration = this.parseTimeframe (timeframe); if (limit === undefined) { if (since === undefined) { - throw new ArgumentsRequired (this.id + ' fetchOHLCV requires a since argument or a limit argument'); + throw new ArgumentsRequired (this.id + ' fetchOHLCV() requires a since argument or a limit argument'); } else { limit = 1000; const start = parseInt (since / 1000); @@ -29524,8 +31271,8 @@ module.exports = class bitstamp extends Exchange { return { 'info': balance, 'symbol': symbol, - 'maker': balance.fee, - 'taker': balance.fee, + 'maker': balance['fee'], + 'taker': balance['fee'], }; } @@ -30015,6 +31762,7 @@ module.exports = class bitstamp extends Exchange { 'symbol': symbol, 'type': undefined, 'timeInForce': undefined, + 'postOnly': undefined, 'side': side, 'price': price, 'stopPrice': undefined, @@ -30357,7 +32105,7 @@ module.exports = class bitstamp extends Exchange { } }; -},{"./base/Exchange":5,"./base/errors":7}],42:[function(require,module,exports){ +},{"./base/Exchange":6,"./base/errors":8}],42:[function(require,module,exports){ 'use strict'; // --------------------------------------------------------------------------- @@ -30658,13 +32406,13 @@ module.exports = class bitstamp1 extends Exchange { } }; -},{"./base/Exchange":5,"./base/errors":7}],43:[function(require,module,exports){ +},{"./base/Exchange":6,"./base/errors":8}],43:[function(require,module,exports){ 'use strict'; // --------------------------------------------------------------------------- const Exchange = require ('./base/Exchange'); -const { BadSymbol, ExchangeError, ExchangeNotAvailable, AuthenticationError, InvalidOrder, InsufficientFunds, OrderNotFound, DDoSProtection, PermissionDenied, AddressPending, OnMaintenance, BadRequest } = require ('./base/errors'); +const { BadSymbol, ExchangeError, ExchangeNotAvailable, AuthenticationError, InvalidOrder, InsufficientFunds, OrderNotFound, DDoSProtection, PermissionDenied, AddressPending, OnMaintenance, BadRequest, InvalidAddress } = require ('./base/errors'); const { TRUNCATE, DECIMAL_PLACES } = require ('./base/functions/number'); // --------------------------------------------------------------------------- @@ -30684,6 +32432,7 @@ module.exports = class bittrex extends Exchange { 'CORS': false, 'cancelAllOrders': true, 'cancelOrder': true, + 'createDepositAddress': true, 'createMarketOrder': true, 'createOrder': true, 'fetchBalance': true, @@ -30798,10 +32547,10 @@ module.exports = class bittrex extends Exchange { }, 'fees': { 'trading': { - 'tierBased': false, + 'tierBased': true, 'percentage': true, - 'maker': 0.0025, - 'taker': 0.0025, + 'maker': 0.0035, + 'taker': 0.0035, }, 'funding': { 'tierBased': false, @@ -31419,7 +33168,22 @@ module.exports = class bittrex extends Exchange { const isCeilingMarket = (uppercaseType === 'CEILING_MARKET'); const isCeilingOrder = isCeilingLimit || isCeilingMarket; if (isCeilingOrder) { - request['ceiling'] = this.priceToPrecision (symbol, price); + let cost = undefined; + if (isCeilingLimit) { + request['limit'] = this.priceToPrecision (symbol, price); + cost = this.safeFloat2 (params, 'ceiling', 'cost', amount); + } else if (isCeilingMarket) { + cost = this.safeFloat2 (params, 'ceiling', 'cost'); + if (cost === undefined) { + if (price === undefined) { + cost = amount; + } else { + cost = amount * price; + } + } + } + params = this.omit (params, [ 'ceiling', 'cost' ]); + request['ceiling'] = this.costToPrecision (symbol, cost); // bittrex only accepts IMMEDIATE_OR_CANCEL or FILL_OR_KILL for ceiling orders request['timeInForce'] = 'IMMEDIATE_OR_CANCEL'; } else { @@ -31636,7 +33400,7 @@ module.exports = class bittrex extends Exchange { 'GOOD_TIL_CANCELLED': 'GTC', 'IMMEDIATE_OR_CANCEL': 'IOC', 'FILL_OR_KILL': 'FOK', - 'POST_ONLY_GOOD_TIL_CANCELLED': 'POST_ONLY_GOOD_TIL_CANCELLED', + 'POST_ONLY_GOOD_TIL_CANCELLED': 'PO', }; return this.safeString (timeInForces, timeInForce, timeInForce); } @@ -31706,6 +33470,7 @@ module.exports = class bittrex extends Exchange { status = 'canceled'; } const timeInForce = this.parseTimeInForce (this.safeString (order, 'timeInForce')); + const postOnly = (timeInForce === 'PO'); return { 'id': this.safeString (order, 'id'), 'clientOrderId': undefined, @@ -31715,6 +33480,7 @@ module.exports = class bittrex extends Exchange { 'symbol': symbol, 'type': type, 'timeInForce': timeInForce, + 'postOnly': postOnly, 'side': direction, 'price': limit, 'stopPrice': undefined, @@ -31852,6 +33618,40 @@ module.exports = class bittrex extends Exchange { return this.parseOrders (response, market, since, limit); } + async createDepositAddress (code, params = {}) { + await this.loadMarkets (); + const currency = this.currency (code); + const request = { + 'currencySymbol': currency['id'], + }; + const response = await this.privatePostAddresses (this.extend (request, params)); + // + // { + // "status":"PROVISIONED", + // "currencySymbol":"XRP", + // "cryptoAddress":"rPVMhWBsfF9iMXYj3aAzJVkPDTFNSyWdKy", + // "cryptoAddressTag":"392034158" + // } + // + let address = this.safeString (response, 'cryptoAddress'); + const message = this.safeString (response, 'status'); + if (!address || message === 'REQUESTED') { + throw new AddressPending (this.id + ' the address for ' + code + ' is being generated (pending, not ready yet, retry again later)'); + } + let tag = this.safeString (response, 'cryptoAddressTag'); + if ((tag === undefined) && (currency['type'] in this.options['tag'])) { + tag = address; + address = currency['address']; + } + this.checkAddress (address); + return { + 'currency': code, + 'address': address, + 'tag': tag, + 'info': response, + }; + } + async fetchDepositAddress (code, params = {}) { await this.loadMarkets (); const currency = this.currency (code); @@ -31859,18 +33659,21 @@ module.exports = class bittrex extends Exchange { 'currencySymbol': currency['id'], }; const response = await this.privateGetAddressesCurrencySymbol (this.extend (request, params)); - // { - // "status": "PROVISIONED", - // "currencySymbol": "BTC", - // "cryptoAddress": "1PhmYjnJPZH5NUwV8AUjqkeDkCBpbE2xqX" - // } + // + // { + // "status":"PROVISIONED", + // "currencySymbol":"XRP", + // "cryptoAddress":"rPVMhWBsfF9iMXYj3aAzJVkPDTFNSyWdKy", + // "cryptoAddressTag":"392034158" + // } + // let address = this.safeString (response, 'cryptoAddress'); const message = this.safeString (response, 'status'); if (!address || message === 'REQUESTED') { throw new AddressPending (this.id + ' the address for ' + code + ' is being generated (pending, not ready yet, retry again later)'); } - let tag = undefined; - if (currency['type'] in this.options['tag']) { + let tag = this.safeString (response, 'cryptoAddressTag'); + if ((tag === undefined) && (currency['type'] in this.options['tag'])) { tag = address; address = currency['address']; } @@ -31970,6 +33773,9 @@ module.exports = class bittrex extends Exchange { this.throwExactlyMatchedException (this.exceptions['exact'], code, feedback); this.throwBroadlyMatchedException (this.exceptions['broad'], code, feedback); } + if ((code === 'NOT_FOUND') && (url.indexOf ('addresses') >= 0)) { + throw new InvalidAddress (feedback); + } // throw new ExchangeError (this.id + ' malformed response ' + this.json (response)); return; } @@ -32033,14 +33839,14 @@ module.exports = class bittrex extends Exchange { } }; -},{"./base/Exchange":5,"./base/errors":7,"./base/functions/number":13}],44:[function(require,module,exports){ +},{"./base/Exchange":6,"./base/errors":8,"./base/functions/number":14}],44:[function(require,module,exports){ 'use strict'; // ---------------------------------------------------------------------------- const Exchange = require ('./base/Exchange'); const { ExchangeError, BadSymbol, AuthenticationError, InsufficientFunds, InvalidOrder, ArgumentsRequired, OrderNotFound, InvalidAddress, BadRequest, RateLimitExceeded, PermissionDenied, ExchangeNotAvailable, AccountSuspended, OnMaintenance } = require ('./base/errors'); -const { TRUNCATE } = require ('./base/functions/number'); +const { SIGNIFICANT_DIGITS, DECIMAL_PLACES, TRUNCATE, ROUND } = require ('./base/functions/number'); // ---------------------------------------------------------------------------- @@ -32257,12 +34063,33 @@ module.exports = class bitvavo extends Exchange { 'expires': 1000, // 1 second }, }, + 'precisionMode': SIGNIFICANT_DIGITS, 'commonCurrencies': { 'MIOTA': 'IOTA', // https://github.com/ccxt/ccxt/issues/7487 }, }); } + currencyToPrecision (currency, fee) { + return this.decimalToPrecision (fee, 0, this.currencies[currency]['precision']); + } + + amountToPrecision (symbol, amount) { + // https://docs.bitfinex.com/docs/introduction#amount-precision + // The amount field allows up to 8 decimals. + // Anything exceeding this will be rounded to the 8th decimal. + return this.decimalToPrecision (amount, TRUNCATE, this.markets[symbol]['precision']['amount'], DECIMAL_PLACES); + } + + priceToPrecision (symbol, price) { + price = this.decimalToPrecision (price, ROUND, this.markets[symbol]['precision']['price'], this.precisionMode); + // https://docs.bitfinex.com/docs/introduction#price-precision + // The precision level of all trading prices is based on significant figures. + // All pairs on Bitfinex use up to 5 significant digits and up to 8 decimals (e.g. 1.2345, 123.45, 1234.5, 0.00012345). + // Prices submit with a precision larger than 5 will be cut by the API. + return this.decimalToPrecision (price, TRUNCATE, 8, DECIMAL_PLACES); + } + async fetchTime (params = {}) { const response = await this.publicGetTime (params); // @@ -32804,16 +34631,18 @@ module.exports = class bitvavo extends Exchange { const request = { 'market': market['id'], 'side': side, - 'orderType': type, + 'orderType': type, // 'market', 'limit', 'stopLoss', 'stopLossLimit', 'takeProfit', 'takeProfitLimit' // 'amount': this.amountToPrecision (symbol, amount), // 'price': this.priceToPrecision (symbol, price), // 'amountQuote': this.costToPrecision (symbol, cost), - // 'timeInForce': 'GTC', // "GTC" "IOC" "FOK" - // 'selfTradePrevention': "decrementAndCancel", // "decrementAndCancel" "cancelOldest" "cancelNewest" "cancelBoth" + // 'timeInForce': 'GTC', // 'GTC', 'IOC', 'FOK' + // 'selfTradePrevention': 'decrementAndCancel', // 'decrementAndCancel', 'cancelOldest', 'cancelNewest', 'cancelBoth' // 'postOnly': false, // 'disableMarketProtection': false, // don't cancel if the next fill price is 10% worse than the best fill price // 'responseRequired': true, // false is faster }; + const isStopLimit = (type === 'stopLossLimit') || (type === 'takeProfitLimit'); + const isStopMarket = (type === 'stopLoss') || (type === 'takeProfit'); if (type === 'market') { let cost = undefined; if (price !== undefined) { @@ -32831,6 +34660,26 @@ module.exports = class bitvavo extends Exchange { } else if (type === 'limit') { request['price'] = this.priceToPrecision (symbol, price); request['amount'] = this.amountToPrecision (symbol, amount); + } else if (isStopMarket || isStopLimit) { + let stopPrice = this.safeFloat2 (params, 'stopPrice', 'triggerAmount'); + if (stopPrice === undefined) { + if (isStopLimit) { + throw new ArgumentsRequired (this.id + ' createOrder requires a stopPrice parameter for a ' + type + ' order'); + } else if (isStopMarket) { + if (price === undefined) { + throw new ArgumentsRequired (this.id + ' createOrder requires a price argument or a stopPrice parameter for a ' + type + ' order'); + } else { + stopPrice = price; + } + } + } + if (isStopLimit) { + request['price'] = this.priceToPrecision (symbol, price); + } + params = this.omit (params, [ 'stopPrice', 'triggerAmount' ]); + request['triggerAmount'] = this.priceToPrecision (symbol, stopPrice); + request['triggerType'] = 'price'; + request['amount'] = this.amountToPrecision (symbol, amount); } const response = await this.privatePostOrder (this.extend (request, params)); // @@ -32892,13 +34741,13 @@ module.exports = class bitvavo extends Exchange { const response = await this.privatePutOrder (this.extend (request, params)); return this.parseOrder (response, market); } else { - throw new ArgumentsRequired (this.id + ' editOrder requires an amount argument, or a price argument, or non-empty params'); + throw new ArgumentsRequired (this.id + ' editOrder() requires an amount argument, or a price argument, or non-empty params'); } } async cancelOrder (id, symbol = undefined, params = {}) { if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' cancelOrder requires a symbol argument'); + throw new ArgumentsRequired (this.id + ' cancelOrder() requires a symbol argument'); } await this.loadMarkets (); const market = this.market (symbol); @@ -32936,7 +34785,7 @@ module.exports = class bitvavo extends Exchange { async fetchOrder (id, symbol = undefined, params = {}) { if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' fetchOrder requires a symbol argument'); + throw new ArgumentsRequired (this.id + ' fetchOrder() requires a symbol argument'); } await this.loadMarkets (); await this.loadMarkets (); @@ -32985,7 +34834,7 @@ module.exports = class bitvavo extends Exchange { async fetchOrders (symbol = undefined, since = undefined, limit = undefined, params = {}) { if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' fetchOrders requires a symbol argument'); + throw new ArgumentsRequired (this.id + ' fetchOrders() requires a symbol argument'); } await this.loadMarkets (); const market = this.market (symbol); @@ -33046,24 +34895,13 @@ module.exports = class bitvavo extends Exchange { async fetchOpenOrders (symbol = undefined, since = undefined, limit = undefined, params = {}) { await this.loadMarkets (); const request = { - // 'market': market['id'], - // 'limit': 500, - // 'start': since, - // 'end': this.milliseconds (), - // 'orderIdFrom': 'af76d6ce-9f7c-4006-b715-bb5d430652d0', - // 'orderIdTo': 'af76d6ce-9f7c-4006-b715-bb5d430652d0', + // 'market': market['id'], // rate limit 25 without a market, 1 with market specified }; let market = undefined; if (symbol !== undefined) { market = this.market (symbol); request['market'] = market['id']; } - if (since !== undefined) { - request['start'] = since; - } - if (limit !== undefined) { - request['limit'] = limit; // default 500, max 1000 - } const response = await this.privateGetOrdersOpen (this.extend (request, params)); // // [ @@ -33118,6 +34956,7 @@ module.exports = class bitvavo extends Exchange { 'partiallyFilled': 'open', 'expired': 'canceled', 'rejected': 'canceled', + 'awaitingTrigger': 'open', // https://github.com/ccxt/ccxt/issues/8489 }; return this.safeString (statuses, status, status); } @@ -33219,6 +35058,9 @@ module.exports = class bitvavo extends Exchange { } } const timeInForce = this.safeString (order, 'timeInForce'); + const postOnly = this.safeValue (order, 'postOnly'); + // https://github.com/ccxt/ccxt/issues/8489 + const stopPrice = this.safeFloat (order, 'triggerPrice'); return { 'info': order, 'id': id, @@ -33229,9 +35071,10 @@ module.exports = class bitvavo extends Exchange { 'symbol': symbol, 'type': type, 'timeInForce': timeInForce, + 'postOnly': postOnly, 'side': side, 'price': price, - 'stopPrice': undefined, + 'stopPrice': stopPrice, 'amount': amount, 'cost': cost, 'average': average, @@ -33245,7 +35088,7 @@ module.exports = class bitvavo extends Exchange { async fetchMyTrades (symbol = undefined, since = undefined, limit = undefined, params = {}) { if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' fetchMyTrades requires a symbol argument'); + throw new ArgumentsRequired (this.id + ' fetchMyTrades() requires a symbol argument'); } await this.loadMarkets (); const market = this.market (symbol); @@ -33530,7 +35373,7 @@ module.exports = class bitvavo extends Exchange { } }; -},{"./base/Exchange":5,"./base/errors":7,"./base/functions/number":13}],45:[function(require,module,exports){ +},{"./base/Exchange":6,"./base/errors":8,"./base/functions/number":14}],45:[function(require,module,exports){ 'use strict'; // --------------------------------------------------------------------------- @@ -34208,7 +36051,7 @@ module.exports = class bitz extends Exchange { } } else { if (since !== undefined) { - throw new ArgumentsRequired (this.id + ' fetchOHLCV requires a limit argument if the since argument is specified'); + throw new ArgumentsRequired (this.id + ' fetchOHLCV() requires a limit argument if the since argument is specified'); } } const response = await this.marketGetKline (this.extend (request, params)); @@ -34312,6 +36155,7 @@ module.exports = class bitz extends Exchange { 'symbol': symbol, 'type': 'limit', 'timeInForce': undefined, + 'postOnly': undefined, 'side': side, 'price': price, 'stopPrice': undefined, @@ -34481,7 +36325,7 @@ module.exports = class bitz extends Exchange { async fetchOrdersWithMethod (method, symbol = undefined, since = undefined, limit = undefined, params = {}) { if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' fetchOpenOrders requires a symbol argument'); + throw new ArgumentsRequired (this.id + ' fetchOpenOrders() requires a symbol argument'); } await this.loadMarkets (); const market = this.market (symbol); @@ -34817,7 +36661,7 @@ module.exports = class bitz extends Exchange { } }; -},{"./base/Exchange":5,"./base/errors":7}],46:[function(require,module,exports){ +},{"./base/Exchange":6,"./base/errors":8}],46:[function(require,module,exports){ 'use strict'; // --------------------------------------------------------------------------- @@ -35055,7 +36899,7 @@ module.exports = class bl3p extends Exchange { } }; -},{"./base/Exchange":5}],47:[function(require,module,exports){ +},{"./base/Exchange":6}],47:[function(require,module,exports){ 'use strict'; // --------------------------------------------------------------------------- @@ -35720,6 +37564,7 @@ module.exports = class bleutrade extends Exchange { 'symbol': symbol, 'type': 'limit', 'timeInForce': undefined, + 'postOnly': undefined, 'side': side, 'price': price, 'stopPrice': undefined, @@ -35870,7 +37715,7 @@ module.exports = class bleutrade extends Exchange { } }; -},{"./base/Exchange":5,"./base/errors":7}],48:[function(require,module,exports){ +},{"./base/Exchange":6,"./base/errors":8}],48:[function(require,module,exports){ 'use strict'; // --------------------------------------------------------------------------- @@ -36333,6 +38178,7 @@ module.exports = class braziliex extends Exchange { 'symbol': symbol, 'type': 'limit', 'timeInForce': undefined, + 'postOnly': undefined, 'side': side, 'price': price, 'stopPrice': undefined, @@ -36513,7 +38359,7 @@ module.exports = class braziliex extends Exchange { } }; -},{"./base/Exchange":5,"./base/errors":7}],49:[function(require,module,exports){ +},{"./base/Exchange":6,"./base/errors":8}],49:[function(require,module,exports){ 'use strict'; // --------------------------------------------------------------------------- @@ -36864,6 +38710,7 @@ module.exports = class btcalpha extends Exchange { 'symbol': symbol, 'type': 'limit', 'timeInForce': undefined, + 'postOnly': undefined, 'side': side, 'price': price, 'stopPrice': undefined, @@ -37017,7 +38864,7 @@ module.exports = class btcalpha extends Exchange { } }; -},{"./base/Exchange":5,"./base/errors":7}],50:[function(require,module,exports){ +},{"./base/Exchange":6,"./base/errors":8}],50:[function(require,module,exports){ 'use strict'; // --------------------------------------------------------------------------- @@ -37326,6 +39173,7 @@ module.exports = class btcbox extends Exchange { 'side': side, 'type': undefined, 'timeInForce': undefined, + 'postOnly': undefined, 'status': status, 'symbol': symbol, 'price': price, @@ -37444,7 +39292,7 @@ module.exports = class btcbox extends Exchange { } }; -},{"./base/Exchange":5,"./base/errors":7}],51:[function(require,module,exports){ +},{"./base/Exchange":6,"./base/errors":8}],51:[function(require,module,exports){ 'use strict'; // --------------------------------------------------------------------------- @@ -38312,6 +40160,7 @@ module.exports = class btcmarkets extends Exchange { const clientOrderId = this.safeString (order, 'clientOrderId'); const timeInForce = this.safeString (order, 'timeInForce'); const stopPrice = this.safeFloat (order, 'triggerPrice'); + const postOnly = this.safeValue (order, 'postOnly'); return { 'info': order, 'id': id, @@ -38322,6 +40171,7 @@ module.exports = class btcmarkets extends Exchange { 'symbol': symbol, 'type': type, 'timeInForce': timeInForce, + 'postOnly': postOnly, 'side': side, 'price': price, 'stopPrice': stopPrice, @@ -38501,7 +40351,7 @@ module.exports = class btcmarkets extends Exchange { } }; -},{"./base/Exchange":5,"./base/errors":7}],52:[function(require,module,exports){ +},{"./base/Exchange":6,"./base/errors":8}],52:[function(require,module,exports){ 'use strict'; // --------------------------------------------------------------------------- @@ -38839,6 +40689,7 @@ module.exports = class btctradeua extends Exchange { 'symbol': symbol, 'type': undefined, 'timeInForce': undefined, + 'postOnly': undefined, 'side': this.safeString (order, 'type'), 'price': this.safeFloat (order, 'price'), 'stopPrice': undefined, @@ -38855,7 +40706,7 @@ module.exports = class btctradeua extends Exchange { async fetchOpenOrders (symbol = undefined, since = undefined, limit = undefined, params = {}) { if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' fetchOpenOrders requires a symbol argument'); + throw new ArgumentsRequired (this.id + ' fetchOpenOrders() requires a symbol argument'); } await this.loadMarkets (); const market = this.market (symbol); @@ -38896,7 +40747,7 @@ module.exports = class btctradeua extends Exchange { } }; -},{"./base/Exchange":5,"./base/errors":7}],53:[function(require,module,exports){ +},{"./base/Exchange":6,"./base/errors":8}],53:[function(require,module,exports){ 'use strict'; // --------------------------------------------------------------------------- @@ -39174,7 +41025,7 @@ module.exports = class btcturk extends Exchange { }; if (type === 'market') { if (!('Total' in params)) { - throw new ExchangeError (this.id + ' createOrder requires the "Total" extra parameter for market orders (amount and price are both ignored)'); + throw new ExchangeError (this.id + ' createOrder() requires the "Total" extra parameter for market orders (amount and price are both ignored)'); } } else { request['Price'] = price; @@ -39225,7 +41076,7 @@ module.exports = class btcturk extends Exchange { } }; -},{"./base/Exchange":5,"./base/errors":7}],54:[function(require,module,exports){ +},{"./base/Exchange":6,"./base/errors":8}],54:[function(require,module,exports){ 'use strict'; // --------------------------------------------------------------------------- @@ -39765,29 +41616,65 @@ module.exports = class buda extends Exchange { } parseOrder (order, market = undefined) { + // + // { + // 'id': 63679183, + // 'uuid': 'f9697bee-627e-4175-983f-0d5a41963fec', + // 'market_id': 'ETH-CLP', + // 'account_id': 51590, + // 'type': 'Ask', + // 'state': 'received', + // 'created_at': '2021-01-04T08:29:52.730Z', + // 'fee_currency': 'CLP', + // 'price_type': 'limit', + // 'source': None, + // 'limit': ['741000.0', 'CLP'], + // 'amount': ['0.001', 'ETH'], + // 'original_amount': ['0.001', 'ETH'], + // 'traded_amount': ['0.0', 'ETH'], + // 'total_exchanged': ['0.0', 'CLP'], + // 'paid_fee': ['0.0', 'CLP'] + // } + // const id = this.safeString (order, 'id'); const timestamp = this.parse8601 (this.safeString (order, 'created_at')); const marketId = this.safeString (order, 'market_id'); - const symbol = this.safeSymbol (marketId, market); + const symbol = this.safeSymbol (marketId, market, '-'); const type = this.safeString (order, 'price_type'); const side = this.safeStringLower (order, 'type'); const status = this.parseOrderStatus (this.safeString (order, 'state')); - const amount = parseFloat (order['original_amount'][0]); - const remaining = parseFloat (order['amount'][0]); - const filled = parseFloat (order['traded_amount'][0]); - const cost = parseFloat (order['total_exchanged'][0]); - let price = this.safeFloat (order, 'limit'); - if (price !== undefined) { - price = parseFloat (price[0]); + const originalAmount = this.safeValue (order, 'original_amount', []); + const amount = this.safeFloat (originalAmount, 0); + const remainingAmount = this.safeValue (order, 'amount', []); + const remaining = this.safeFloat (remainingAmount, 0); + const tradedAmount = this.safeValue (order, 'traded_amount', []); + const filled = this.safeFloat (tradedAmount, 0); + const totalExchanged = this.safeValue (order, 'totalExchanged', []); + const cost = this.safeFloat (totalExchanged, 0); + const limitPrice = this.safeValue (order, 'limit', []); + let price = this.safeFloat (limitPrice, 0); + if (price === undefined) { + if (limitPrice !== undefined) { + price = limitPrice; + } } - if (cost > 0 && filled > 0) { - price = this.priceToPrecision (symbol, cost / filled); + let average = undefined; + if ((cost !== undefined) && (filled !== undefined) && (filled > 0)) { + average = this.priceToPrecision (symbol, cost / filled); + } + const paidFee = this.safeValue (order, 'paid_fee', []); + const feeCost = this.safeFloat (paidFee, 0); + let fee = undefined; + if (feeCost !== undefined) { + const feeCurrencyId = this.safeString (paidFee, 1); + const feeCurrencyCode = this.safeCurrencyCode (feeCurrencyId); + fee = { + 'cost': feeCost, + 'code': feeCurrencyCode, + }; } - const fee = { - 'cost': parseFloat (order['paid_fee'][0]), - 'currency': order['paid_fee'][1], - }; return { + 'info': order, 'id': id, 'clientOrderId': undefined, 'datetime': this.iso8601 (timestamp), @@ -39797,17 +41684,17 @@ module.exports = class buda extends Exchange { 'symbol': symbol, 'type': type, 'timeInForce': undefined, + 'postOnly': undefined, 'side': side, 'price': price, 'stopPrice': undefined, + 'average': average, 'cost': cost, 'amount': amount, 'filled': filled, 'remaining': remaining, 'trades': undefined, 'fee': fee, - 'info': order, - 'average': undefined, }; } @@ -40015,7 +41902,7 @@ module.exports = class buda extends Exchange { } }; -},{"./base/Exchange":5,"./base/errors":7}],55:[function(require,module,exports){ +},{"./base/Exchange":6,"./base/errors":8}],55:[function(require,module,exports){ 'use strict'; // --------------------------------------------------------------------------- @@ -40779,6 +42666,7 @@ module.exports = class bw extends Exchange { 'symbol': symbol, 'type': 'limit', 'timeInForce': undefined, + 'postOnly': undefined, 'side': side, 'price': price, 'stopPrice': undefined, @@ -40795,7 +42683,7 @@ module.exports = class bw extends Exchange { async fetchOrder (id, symbol = undefined, params = {}) { if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' fetchOrder requires a symbol argument'); + throw new ArgumentsRequired (this.id + ' fetchOrder() requires a symbol argument'); } await this.loadMarkets (); const market = this.market (symbol); @@ -40830,7 +42718,7 @@ module.exports = class bw extends Exchange { async cancelOrder (id, symbol = undefined, params = {}) { if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' cancelOrder requires a symbol argument'); + throw new ArgumentsRequired (this.id + ' cancelOrder() requires a symbol argument'); } await this.loadMarkets (); const market = this.market (symbol); @@ -41222,7 +43110,7 @@ module.exports = class bw extends Exchange { } }; -},{"./base/Exchange":5,"./base/errors":7}],56:[function(require,module,exports){ +},{"./base/Exchange":6,"./base/errors":8}],56:[function(require,module,exports){ 'use strict'; // --------------------------------------------------------------------------- @@ -41242,6 +43130,7 @@ module.exports = class bybit extends Exchange { 'version': 'v2', 'userAgent': undefined, 'rateLimit': 100, + 'hostname': 'bybit.com', // bybit.com, bytick.com 'has': { 'cancelOrder': true, 'CORS': true, @@ -41284,9 +43173,9 @@ module.exports = class bybit extends Exchange { '1y': 'Y', }, 'urls': { - 'test': 'https://api-testnet.bybit.com', + 'test': 'https://api-testnet.{hostname}', 'logo': 'https://user-images.githubusercontent.com/51840849/76547799-daff5b80-649e-11ea-87fb-3be9bac08954.jpg', - 'api': 'https://api.bybit.com', + 'api': 'https://api.{hostname}', 'www': 'https://www.bybit.com', 'doc': [ 'https://bybit-exchange.github.io/docs/inverse/', @@ -41297,117 +43186,112 @@ module.exports = class bybit extends Exchange { 'referral': 'https://www.bybit.com/app/register?ref=X7Prm', }, 'api': { + 'v2': { + 'public': { + 'get': [ + 'orderBook/L2', + 'kline/list', + 'tickers', + 'trading-records', + 'symbols', + 'liq-records', + 'mark-price-kline', + 'index-price-kline', + 'premium-index-kline', + 'open-interest', + 'big-deal', + 'account-ratio', + 'time', + 'announcement', + ], + }, + 'private': { + 'get': [ + 'order/list', + 'order', + 'stop-order/list', + 'stop-order', + 'position/list', + 'execution/list', + 'trade/closed-pnl/list', + 'funding/prev-funding-rate', + 'funding/prev-funding', + 'funding/predicted-funding', + 'account/api-key', + 'account/lcp', + 'wallet/balance', + 'wallet/fund/records', + 'wallet/withdraw/list', + 'exchange-order/list', + ], + 'post': [ + 'order/create', + 'order/cancel', + 'order/cancelAll', + 'order/replace', + 'stop-order/create', + 'stop-order/cancel', + 'stop-order/cancelAll', + 'stop-order/replace', + 'position/change-position-margin', + 'position/trading-stop', + 'position/leverage/save', + ], + }, + }, 'public': { - 'get': [ - 'orderBook/L2', - 'kline/list', - 'tickers', - 'trading-records', - 'symbols', - 'liq-records', - 'mark-price-kline', - 'open-interest', - 'big-deal', - 'account-ratio', - 'time', - 'announcement', - ], + 'linear': { + 'get': [ + 'kline', + 'recent-trading-records', + 'funding/prev-funding-rate', + 'mark-price-kline', + 'index-price-kline', + 'premium-index-kline', + 'risk-limit', + ], + }, }, 'private': { - 'get': [ - 'order/list', - 'order', - 'stop-order/list', - 'stop-order', - 'position/list', - 'wallet/balance', - 'execution/list', - 'trade/closed-pnl/list', - 'account/lcp', - 'exchange-order/list', - ], - 'post': [ - 'order/create', - 'order/cancel', - 'order/cancelAll', - 'order/replace', - 'stop-order/create', - 'stop-order/cancel', - 'stop-order/cancelAll', - 'stop-order/replace', - ], + 'linear': { + 'get': [ + 'order/list', + 'order/search', + 'stop-order/list', + 'stop-order/search', + 'position/list', + 'trade/execution/list', + 'trade/closed-pnl/list', + 'funding/predicted-funding', + 'funding/prev-funding', + ], + 'post': [ + 'order/create', + 'order/cancel', + 'order/cancel-all', + 'order/replace', + 'stop-order/create', + 'stop-order/cancel', + 'stop-order/cancel-all', + 'stop-order/replace', + 'position/set-auto-add-margin', + 'position/switch-isolated', + 'tpsl/switch-mode', + 'position/add-margin', + 'position/set-leverage', + 'position/trading-stop', + ], + }, }, 'openapi': { - 'get': [ - 'order/list', // deprecated - 'stop-order/list', // deprecated - 'wallet/risk-limit/list', - 'funding/prev-funding-rate', - 'funding/prev-funding', - 'funding/predicted-funding', - 'api-key', - 'wallet/fund/records', - 'wallet/withdraw/list', - ], - 'post': [ - 'order/replace', // deprecated - 'stop-order/create', // deprecated - 'stop-order/cancel', // deprecated - 'stop-order/replace', // deprecated - 'position/trading-stop', - 'wallet/risk-limit', - ], - }, - 'publicLinear': { - 'get': [ - 'kline', - 'recent-trading-records', - 'funding/prev-funding-rate', - 'mark-price-kline', - 'risk-limit', - ], - }, - 'privateLinear': { - 'get': [ - 'order/list', - 'order/search', - 'stop-order/list', - 'stop-order/search', - 'position/list', - 'trade/execution/list', - 'trade/closed-pnl/list', - 'funding/prev-funding', - 'funding/predicted-funding', - ], - 'post': [ - 'order/create', - 'order/cancel', - 'order/cancel-all', - 'order/replace', - 'stop-order/create', - 'stop-order/cancel', - 'stop-order/cancel-all', - 'stop-order/replace', - 'position/switch-isolated', - 'position/set-auto-add-margin', - 'tpsl/switch-mode', - 'position/set-leverage', - 'position/trading-stop', - 'position/add-margin', - ], - }, - 'position': { - 'post': [ - 'change-position-margin', - ], - }, - 'user': { - 'get': [ - 'leverage', // deprecated - ], - 'post': [ - 'leverage/save', - ], + 'wallet': { + 'get': [ + 'risk-limit/list', + ], + 'post': [ + 'risk-limit', + ], + }, }, }, 'httpExceptions': { @@ -41510,6 +43394,7 @@ module.exports = class bybit extends Exchange { 'options': { 'marketTypes': { 'BTC/USDT': 'linear', + 'BCH/USDT': 'linear', 'ETH/USDT': 'linear', 'LTC/USDT': 'linear', 'XTZ/USDT': 'linear', @@ -41517,10 +43402,10 @@ module.exports = class bybit extends Exchange { }, 'code': 'BTC', 'cancelAllOrders': { - 'method': 'privatePostOrderCancelAll', // privatePostStopOrderCancelAll + // 'method': 'v2PrivatePostOrderCancelAll', // v2PrivatePostStopOrderCancelAll }, 'recvWindow': 5 * 1000, // 5 sec default - 'timeDifference': 0, // the difference between system clock and Binance clock + 'timeDifference': 0, // the difference between system clock and exchange server clock 'adjustForTimeDifference': false, // controls the adjustment logic upon instantiation }, 'fees': { @@ -41552,7 +43437,7 @@ module.exports = class bybit extends Exchange { } async fetchTime (params = {}) { - const response = await this.publicGetTime (params); + const response = await this.v2PublicGetTime (params); // // { // ret_code: 0, @@ -41570,30 +43455,7 @@ module.exports = class bybit extends Exchange { if (this.options['adjustForTimeDifference']) { await this.loadTimeDifference (); } - const response = await this.publicGetSymbols (params); - // - // { - // ret_code: 0, - // ret_msg: 'OK', - // ext_code: '', - // ext_info: '', - // result: [ - // { - // name: 'BTCUSD', - // base_currency: 'BTC', - // quote_currency: 'USD', - // price_scale: 2, - // taker_fee: '0.00075', - // maker_fee: '-0.00025', - // leverage_filter: { min_leverage: 1, max_leverage: 100, leverage_step: '0.01' }, - // price_filter: { min_price: '0.5', max_price: '999999.5', tick_size: '0.5' }, - // lot_size_filter: { max_trading_qty: 1000000, min_trading_qty: 1, qty_step: 1 } - // }, - // ], - // time_now: '1583930495.454196' - // } - // - // sandbox/testnet + const response = await this.v2PublicGetSymbols (params); // // { // "ret_code":0, @@ -41602,8 +43464,8 @@ module.exports = class bybit extends Exchange { // "ext_info":"", // "result":[ // { - // "symbol":"BTCUSD", - // "symbol_alias":"BTCUSD", + // "name":"BTCUSD", + // "alias":"BTCUSD", // "status":"Trading", // "base_currency":"BTC", // "quote_currency":"USD", @@ -41613,9 +43475,22 @@ module.exports = class bybit extends Exchange { // "leverage_filter":{"min_leverage":1,"max_leverage":100,"leverage_step":"0.01"}, // "price_filter":{"min_price":"0.5","max_price":"999999.5","tick_size":"0.5"}, // "lot_size_filter":{"max_trading_qty":1000000,"min_trading_qty":1,"qty_step":1} - // } + // }, + // { + // "name":"BTCUSDT", + // "alias":"BTCUSDT", + // "status":"Trading", + // "base_currency":"BTC", + // "quote_currency":"USDT", + // "price_scale":2, + // "taker_fee":"0.00075", + // "maker_fee":"-0.00025", + // "leverage_filter":{"min_leverage":1,"max_leverage":100,"leverage_step":"0.01"}, + // "price_filter":{"min_price":"0.5","max_price":"999999.5","tick_size":"0.5"}, + // "lot_size_filter":{"max_trading_qty":100,"min_trading_qty":0.001,"qty_step":0.001} + // }, // ], - // "time_now":"1605916574.118500" + // "time_now":"1610539664.818033" // } // const markets = this.safeValue (response, 'result', []); @@ -41682,65 +43557,6 @@ module.exports = class bybit extends Exchange { return result; } - async fetchBalance (params = {}) { - await this.loadMarkets (); - const request = {}; - const coin = this.safeString (params, 'coin'); - const code = this.safeString (params, 'code'); - if (coin !== undefined) { - request['coin'] = coin; - } else if (code !== undefined) { - const currency = this.currency (code); - request['coin'] = currency['id']; - } - const response = await this.privateGetWalletBalance (this.extend (request, params)); - // - // { - // ret_code: 0, - // ret_msg: 'OK', - // ext_code: '', - // ext_info: '', - // result: { - // BTC: { - // equity: 0, - // available_balance: 0, - // used_margin: 0, - // order_margin: 0, - // position_margin: 0, - // occ_closing_fee: 0, - // occ_funding_fee: 0, - // wallet_balance: 0, - // realised_pnl: 0, - // unrealised_pnl: 0, - // cum_realised_pnl: 0, - // given_cash: 0, - // service_cash: 0 - // } - // }, - // time_now: '1583937810.370020', - // rate_limit_status: 119, - // rate_limit_reset_ms: 1583937810367, - // rate_limit: 120 - // } - // - const result = { - 'info': response, - }; - const balances = this.safeValue (response, 'result', {}); - const currencyIds = Object.keys (balances); - for (let i = 0; i < currencyIds.length; i++) { - const currencyId = currencyIds[i]; - const balance = balances[currencyId]; - const code = this.safeCurrencyCode (currencyId); - const account = this.account (); - account['free'] = this.safeFloat (balance, 'available_balance'); - account['used'] = this.safeFloat (balance, 'used_margin'); - account['total'] = this.safeFloat (balance, 'equity'); - result[code] = account; - } - return this.parseBalance (result); - } - parseTicker (ticker, market = undefined) { // // fetchTicker @@ -41819,7 +43635,7 @@ module.exports = class bybit extends Exchange { const request = { 'symbol': market['id'], }; - const response = await this.publicGetTickers (this.extend (request, params)); + const response = await this.v2PublicGetTickers (this.extend (request, params)); // // { // ret_code: 0, @@ -41867,7 +43683,7 @@ module.exports = class bybit extends Exchange { async fetchTickers (symbols = undefined, params = {}) { await this.loadMarkets (); - const response = await this.publicGetTickers (params); + const response = await this.v2PublicGetTickers (params); // // { // ret_code: 0, @@ -41965,7 +43781,7 @@ module.exports = class bybit extends Exchange { const now = this.seconds (); if (since === undefined) { if (limit === undefined) { - throw new ArgumentsRequired (this.id + ' fetchOHLCV requires a since argument or a limit argument'); + throw new ArgumentsRequired (this.id + ' fetchOHLCV() requires a since argument or a limit argument'); } else { request['from'] = now - limit * duration; } @@ -41977,7 +43793,7 @@ module.exports = class bybit extends Exchange { } const marketTypes = this.safeValue (this.options, 'marketTypes', {}); const marketType = this.safeString (marketTypes, symbol); - const method = (marketType === 'linear') ? 'publicLinearGetKline' : 'publicGetKlineList'; + const method = (marketType === 'linear') ? 'publicLinearGetKline' : 'v2PublicGetKlineList'; const response = await this[method] (this.extend (request, params)); // // inverse perpetual BTC/USD @@ -42132,7 +43948,7 @@ module.exports = class bybit extends Exchange { } const marketTypes = this.safeValue (this.options, 'marketTypes', {}); const marketType = this.safeString (marketTypes, symbol); - const method = (marketType === 'linear') ? 'publicLinearGetRecentTradingRecords' : 'publicGetTradingRecords'; + const method = (marketType === 'linear') ? 'publicLinearGetRecentTradingRecords' : 'v2PublicGetTradingRecords'; const response = await this[method] (this.extend (request, params)); // // { @@ -42186,7 +44002,7 @@ module.exports = class bybit extends Exchange { const request = { 'symbol': market['id'], }; - const response = await this.publicGetOrderBookL2 (this.extend (request, params)); + const response = await this.v2PublicGetOrderBookL2 (this.extend (request, params)); // // { // ret_code: 0, @@ -42209,6 +44025,65 @@ module.exports = class bybit extends Exchange { return this.parseOrderBook (result, timestamp, 'Buy', 'Sell', 'price', 'size'); } + async fetchBalance (params = {}) { + await this.loadMarkets (); + const request = {}; + const coin = this.safeString (params, 'coin'); + const code = this.safeString (params, 'code'); + if (coin !== undefined) { + request['coin'] = coin; + } else if (code !== undefined) { + const currency = this.currency (code); + request['coin'] = currency['id']; + } + const response = await this.v2PrivateGetWalletBalance (this.extend (request, params)); + // + // { + // ret_code: 0, + // ret_msg: 'OK', + // ext_code: '', + // ext_info: '', + // result: { + // BTC: { + // equity: 0, + // available_balance: 0, + // used_margin: 0, + // order_margin: 0, + // position_margin: 0, + // occ_closing_fee: 0, + // occ_funding_fee: 0, + // wallet_balance: 0, + // realised_pnl: 0, + // unrealised_pnl: 0, + // cum_realised_pnl: 0, + // given_cash: 0, + // service_cash: 0 + // } + // }, + // time_now: '1583937810.370020', + // rate_limit_status: 119, + // rate_limit_reset_ms: 1583937810367, + // rate_limit: 120 + // } + // + const result = { + 'info': response, + }; + const balances = this.safeValue (response, 'result', {}); + const currencyIds = Object.keys (balances); + for (let i = 0; i < currencyIds.length; i++) { + const currencyId = currencyIds[i]; + const balance = balances[currencyId]; + const code = this.safeCurrencyCode (currencyId); + const account = this.account (); + account['free'] = this.safeFloat (balance, 'available_balance'); + account['used'] = this.safeFloat (balance, 'used_margin'); + account['total'] = this.safeFloat (balance, 'equity'); + result[code] = account; + } + return this.parseBalance (result); + } + parseOrderStatus (status) { const statuses = { // basic orders @@ -42391,6 +44266,7 @@ module.exports = class bybit extends Exchange { } const timeInForce = this.parseTimeInForce (this.safeString (order, 'time_in_force')); const stopPrice = this.safeFloat (order, 'stop_px'); + const postOnly = (timeInForce === 'PO'); return { 'info': order, 'id': id, @@ -42401,6 +44277,7 @@ module.exports = class bybit extends Exchange { 'symbol': symbol, 'type': type, 'timeInForce': timeInForce, + 'postOnly': postOnly, 'side': side, 'price': price, 'stopPrice': stopPrice, @@ -42417,7 +44294,7 @@ module.exports = class bybit extends Exchange { async fetchOrder (id, symbol = undefined, params = {}) { if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' fetchOrder requires a symbol argument'); + throw new ArgumentsRequired (this.id + ' fetchOrder() requires a symbol argument'); } await this.loadMarkets (); const market = this.market (symbol); @@ -42431,7 +44308,7 @@ module.exports = class bybit extends Exchange { }; const marketTypes = this.safeValue (this.options, 'marketTypes', {}); const marketType = this.safeString (marketTypes, symbol); - let method = (marketType === 'linear') ? 'privateLinearGetOrderSearch' : 'privateGetOrder'; + let method = (marketType === 'linear') ? 'privateLinearGetOrderSearch' : 'v2PrivateGetOrder'; const stopOrderId = this.safeString (params, 'stop_order_id'); if (stopOrderId === undefined) { const orderLinkId = this.safeString (params, 'order_link_id'); @@ -42439,7 +44316,7 @@ module.exports = class bybit extends Exchange { request['order_id'] = id; } } else { - method = (marketType === 'linear') ? 'privateLinearGetStopOrderSearch' : 'privateGetStopOrder'; + method = (marketType === 'linear') ? 'privateLinearGetStopOrderSearch' : 'v2PrivateGetStopOrder'; } const response = await this[method] (this.extend (request, params)); // @@ -42552,7 +44429,7 @@ module.exports = class bybit extends Exchange { if (price !== undefined) { request['price'] = parseFloat (this.priceToPrecision (symbol, price)); } else { - throw new ArgumentsRequired (this.id + ' createOrder requires a price argument for a ' + type + ' order'); + throw new ArgumentsRequired (this.id + ' createOrder() requires a price argument for a ' + type + ' order'); } } const clientOrderId = this.safeString2 (params, 'order_link_id', 'clientOrderId'); @@ -42564,7 +44441,7 @@ module.exports = class bybit extends Exchange { const basePrice = this.safeValue (params, 'base_price'); const marketTypes = this.safeValue (this.options, 'marketTypes', {}); const marketType = this.safeString (marketTypes, symbol); - let method = (marketType === 'linear') ? 'privateLinearPostOrderCreate' : 'privatePostOrderCreate'; + let method = (marketType === 'linear') ? 'privateLinearPostOrderCreate' : 'v2PrivatePostOrderCreate'; if (marketType === 'linear') { method = 'privateLinearPostOrderCreate'; request['reduce_only'] = false; @@ -42572,15 +44449,15 @@ module.exports = class bybit extends Exchange { } if (stopPx !== undefined) { if (basePrice === undefined) { - throw new ArgumentsRequired (this.id + ' createOrder requires both the stop_px and base_price params for a conditional ' + type + ' order'); + throw new ArgumentsRequired (this.id + ' createOrder() requires both the stop_px and base_price params for a conditional ' + type + ' order'); } else { - method = (marketType === 'linear') ? 'privateLinearPostStopOrderCreate' : 'openapiPostStopOrderCreate'; + method = (marketType === 'linear') ? 'privateLinearPostStopOrderCreate' : 'v2PrivatePostStopOrderCreate'; request['stop_px'] = parseFloat (this.priceToPrecision (symbol, stopPx)); request['base_price'] = parseFloat (this.priceToPrecision (symbol, basePrice)); params = this.omit (params, [ 'stop_px', 'stopPrice', 'base_price' ]); } } else if (basePrice !== undefined) { - throw new ArgumentsRequired (this.id + ' createOrder requires both the stop_px and base_price params for a conditional ' + type + ' order'); + throw new ArgumentsRequired (this.id + ' createOrder() requires both the stop_px and base_price params for a conditional ' + type + ' order'); } const response = await this[method] (this.extend (request, params)); // @@ -42666,7 +44543,7 @@ module.exports = class bybit extends Exchange { async editOrder (id, symbol, type, side, amount = undefined, price = undefined, params = {}) { if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' editOrder requires an symbol argument'); + throw new ArgumentsRequired (this.id + ' editOrder() requires an symbol argument'); } const marketTypes = this.safeValue (this.options, 'marketTypes', {}); const marketType = this.safeString (marketTypes, symbol); @@ -42682,17 +44559,23 @@ module.exports = class bybit extends Exchange { // 'stop_order_id': id, // only for conditional orders // 'p_r_trigger_price': 123.45, // new trigger price also known as stop_px }; - let method = (marketType === 'linear') ? 'privateLinearPostOrderReplace' : 'openapiPostOrderReplace'; + let method = (marketType === 'linear') ? 'privateLinearPostOrderReplace' : 'v2PrivatePostOrderReplace'; const stopOrderId = this.safeString (params, 'stop_order_id'); if (stopOrderId !== undefined) { - method = (marketType === 'linear') ? 'privateLinearPostStopOrderReplace' : 'openapiPostStopOrderReplace'; + method = (marketType === 'linear') ? 'privateLinearPostStopOrderReplace' : 'v2PrivatePostStopOrderReplace'; request['stop_order_id'] = stopOrderId; params = this.omit (params, [ 'stop_order_id' ]); } else { request['order_id'] = id; } if (amount !== undefined) { - request['p_r_qty'] = parseInt (this.amountToPrecision (symbol, amount)); + let qty = this.amountToPrecision (symbol, amount); + if (market['inverse']) { + qty = parseInt (qty); + } else { + qty = parseFloat (qty); + } + request['p_r_qty'] = qty; } if (price !== undefined) { request['p_r_price'] = parseFloat (this.priceToPrecision (symbol, price)); @@ -42735,7 +44618,7 @@ module.exports = class bybit extends Exchange { async cancelOrder (id, symbol = undefined, params = {}) { if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' cancelOrder requires a symbol argument'); + throw new ArgumentsRequired (this.id + ' cancelOrder() requires a symbol argument'); } await this.loadMarkets (); const market = this.market (symbol); @@ -42749,7 +44632,7 @@ module.exports = class bybit extends Exchange { }; const marketTypes = this.safeValue (this.options, 'marketTypes', {}); const marketType = this.safeValue (marketTypes, symbol); - let method = (marketType === 'linear') ? 'privateLinearPostOrderCancel' : 'privatePostOrderCancel'; + let method = (marketType === 'linear') ? 'privateLinearPostOrderCancel' : 'v2PrivatePostOrderCancel'; const stopOrderId = this.safeString (params, 'stop_order_id'); if (stopOrderId === undefined) { const orderLinkId = this.safeString (params, 'order_link_id'); @@ -42757,7 +44640,7 @@ module.exports = class bybit extends Exchange { request['order_id'] = id; } } else { - method = (marketType === 'linear') ? 'privateLinearPostStopOrderCancel' : 'openapiPostStopOrderCancel'; + method = (marketType === 'linear') ? 'privateLinearPostStopOrderCancel' : 'v2PrivatePostStopOrderCancel'; } const response = await this[method] (this.extend (request, params)); const result = this.safeValue (response, 'result', {}); @@ -42766,17 +44649,17 @@ module.exports = class bybit extends Exchange { async cancelAllOrders (symbol = undefined, params = {}) { if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' cancelAllOrders requires a symbol argument'); + throw new ArgumentsRequired (this.id + ' cancelAllOrders() requires a symbol argument'); } await this.loadMarkets (); const market = this.market (symbol); const request = { 'symbol': market['id'], }; - const options = this.safeValue (this.options, 'cancelAllOrders'); + const options = this.safeValue (this.options, 'cancelAllOrders', {}); const marketTypes = this.safeValue (this.options, 'marketTypes', {}); const marketType = this.safeString (marketTypes, symbol); - const defaultMethod = (marketType === 'linear') ? 'privateLinearPostOrderCancelAll' : 'privatePostOrderCancelAll'; + const defaultMethod = (marketType === 'linear') ? 'privateLinearPostOrderCancelAll' : 'v2PrivatePostOrderCancelAll'; const method = this.safeString (options, 'method', defaultMethod); const response = await this[method] (this.extend (request, params)); const result = this.safeValue (response, 'result', []); @@ -42808,7 +44691,7 @@ module.exports = class bybit extends Exchange { const options = this.safeValue (this.options, 'fetchOrders', {}); const marketTypes = this.safeValue (this.options, 'marketTypes', {}); const marketType = this.safeString (marketTypes, symbol); - let defaultMethod = (marketType === 'linear') ? 'privateLinearGetOrderList' : 'openapiGetOrderList'; + let defaultMethod = (marketType === 'linear') ? 'privateLinearGetOrderList' : 'v2PrivateGetOrderList'; let query = params; if (('stop_order_id' in params) || ('stop_order_status' in params)) { let stopOrderStatus = this.safeValue (params, 'stopOrderStatus'); @@ -42819,7 +44702,7 @@ module.exports = class bybit extends Exchange { request['stop_order_status'] = stopOrderStatus; query = this.omit (params, 'stop_order_status'); } - defaultMethod = (marketType === 'linear') ? 'privateLinearGetStopOrderList' : 'openapiGetStopOrderList'; + defaultMethod = (marketType === 'linear') ? 'privateLinearGetStopOrderList' : 'v2PrivateGetStopOrderList'; } const method = this.safeString (options, 'method', defaultMethod); const response = await this[method] (this.extend (request, query)); @@ -42985,7 +44868,7 @@ module.exports = class bybit extends Exchange { if (symbol === undefined) { const orderId = this.safeString (params, 'order_id'); if (orderId === undefined) { - throw new ArgumentsRequired (this.id + ' fetchMyTrades requires a symbol argument or an order_id param'); + throw new ArgumentsRequired (this.id + ' fetchMyTrades() requires a symbol argument or an order_id param'); } else { request['order_id'] = orderId; params = this.omit (params, 'order_id'); @@ -43002,7 +44885,7 @@ module.exports = class bybit extends Exchange { } const marketTypes = this.safeValue (this.options, 'marketTypes', {}); const marketType = this.safeString (marketTypes, symbol); - const method = (marketType === 'linear') ? 'privateLinearGetTradeExecutionList' : 'privateGetExecutionList'; + const method = (marketType === 'linear') ? 'privateLinearGetTradeExecutionList' : 'v2PrivateGetExecutionList'; const response = await this[method] (this.extend (request, params)); // // inverse @@ -43092,41 +44975,60 @@ module.exports = class bybit extends Exchange { } async fetchDeposits (code = undefined, since = undefined, limit = undefined, params = {}) { - if (code === undefined) { - throw new ArgumentsRequired (this.id + ' fetchWithdrawals() requires a currency code argument'); - } await this.loadMarkets (); - const currency = this.currency (code); const request = { - 'currency': currency['id'], + // 'coin': currency['id'], + // 'currency': currency['id'], // alias + // 'start_date': this.iso8601 (since), + // 'end_date': this.iso8601 (till), + 'wallet_fund_type': 'Deposit', // Deposit, Withdraw, RealisedPNL, Commission, Refund, Prize, ExchangeOrderWithdraw, ExchangeOrderDeposit + // 'page': 1, + // 'limit': 20, // max 50 }; - if (limit !== undefined) { - request['count'] = limit; + let currency = undefined; + if (code !== undefined) { + currency = this.currency (code); + request['coin'] = currency['id']; } - const response = await this.privateGetGetDeposits (this.extend (request, params)); + if (since !== undefined) { + request['start_date'] = this.ymd (since); + } + if (limit !== undefined) { + request['limit'] = limit; + } + const response = await this.v2PrivateGetWalletFundRecords (this.extend (request, params)); // // { - // "jsonrpc": "2.0", - // "id": 5611, + // "ret_code": 0, + // "ret_msg": "ok", + // "ext_code": "", // "result": { - // "count": 1, // "data": [ // { - // "address": "2N35qDKDY22zmJq9eSyiAerMD4enJ1xx6ax", - // "amount": 5, - // "currency": "BTC", - // "received_timestamp": 1549295017670, - // "state": "completed", - // "transaction_id": "230669110fdaf0a0dbcdc079b6b8b43d5af29cc73683835b9bc6b3406c065fda", - // "updated_timestamp": 1549295130159 + // "id": 234467, + // "user_id": 1, + // "coin": "BTC", + // "wallet_id": 27913, + // "type": "Realized P&L", + // "amount": "-0.00000006", + // "tx_id": "", + // "address": "BTCUSD", + // "wallet_balance": "0.03000330", + // "exec_time": "2019-12-09T00:00:25.000Z", + // "cross_seq": 0 // } // ] - // } + // }, + // "ext_info": null, + // "time_now": "1577481867.115552", + // "rate_limit_status": 119, + // "rate_limit_reset_ms": 1577481867122, + // "rate_limit": 120 // } // const result = this.safeValue (response, 'result', {}); const data = this.safeValue (result, 'data', []); - return this.parseTransactions (data, currency, since, limit, params); + return this.parseTransactions (data, currency, since, limit); } async fetchWithdrawals (code = undefined, since = undefined, limit = undefined, params = {}) { @@ -43145,12 +45047,12 @@ module.exports = class bybit extends Exchange { request['coin'] = currency['id']; } if (since !== undefined) { - request['start_date'] = this.iso8601 (since); + request['start_date'] = this.ymd (since); } if (limit !== undefined) { request['limit'] = limit; } - const response = await this.openapiGetWalletWithdrawList (this.extend (request, params)); + const response = await this.v2PrivateGetWalletWithdrawList (this.extend (request, params)); // // { // "ret_code": 0, @@ -43216,9 +45118,25 @@ module.exports = class bybit extends Exchange { // "updated_at": "2019-06-11T02:20:24.000Z" // } // + // fetchDeposits ledger entries + // + // { + // "id": 234467, + // "user_id": 1, + // "coin": "BTC", + // "wallet_id": 27913, + // "type": "Realized P&L", + // "amount": "-0.00000006", + // "tx_id": "", + // "address": "BTCUSD", + // "wallet_balance": "0.03000330", + // "exec_time": "2019-12-09T00:00:25.000Z", + // "cross_seq": 0 + // } + // const currencyId = this.safeString (transaction, 'coin'); const code = this.safeCurrencyCode (currencyId, currency); - const timestamp = this.parse8601 (this.safeString (transaction, 'submited_at')); + const timestamp = this.parse8601 (this.safeString2 (transaction, 'submited_at', 'exec_time')); const updated = this.parse8601 (this.safeString (transaction, 'updated_at')); const status = this.parseTransactionStatus (this.safeString (transaction, 'status')); const address = this.safeString (transaction, 'address'); @@ -43268,12 +45186,12 @@ module.exports = class bybit extends Exchange { request['coin'] = currency['id']; } if (since !== undefined) { - request['start_date'] = this.iso8601 (since); + request['start_date'] = this.ymd (since); } if (limit !== undefined) { request['limit'] = limit; } - const response = await this.openapiGetWalletFundRecords (this.extend (request, params)); + const response = await this.v2PrivateGetWalletFundRecords (this.extend (request, params)); // // { // "ret_code": 0, @@ -43372,45 +45290,28 @@ module.exports = class bybit extends Exchange { } sign (path, api = 'public', method = 'GET', params = {}, headers = undefined, body = undefined) { - let url = this.urls['api']; - let request = path; + let url = this.implodeParams (this.urls['api'], { 'hostname': this.hostname }); + const type = this.safeString (api, 0); + const section = this.safeString (api, 1); + let request = '/' + type + '/' + section + '/' + path; // public v2 - if (api === 'public') { - request = '/' + this.version + '/' + api + '/' + request; + if (section === 'public') { if (Object.keys (params).length) { request += '?' + this.rawencode (params); } - } else if (api === 'publicLinear') { - request = '/public/linear/' + request; + } else if (type === 'public') { if (Object.keys (params).length) { request += '?' + this.rawencode (params); } } else { this.checkRequiredCredentials (); - if (api === 'openapi') { - request = '/open-api/' + request; - } else if (api === 'private') { - // private v2 - request = '/' + this.version + '/' + api + '/' + request; - } else if (api === 'privateLinear') { - request = '/private/linear/' + request; - } else { - // position, user - request = '/' + api + '/' + request; - } const timestamp = this.nonce (); const query = this.extend (params, { 'api_key': this.apiKey, 'recv_window': this.options['recvWindow'], 'timestamp': timestamp, }); - let auth = this.rawencode (this.keysort (query)); - // https://github.com/ccxt/ccxt/issues/7377 - // https://github.com/ccxt/ccxt/issues/7515 - // bybit encodes whole floats as integers without .0 for conditional stop-orders only - if (path.indexOf ('stop-order') >= 0) { - auth = auth.replace ('.0&', '&'); - } + const auth = this.rawencode (this.keysort (query)); const signature = this.hmac (this.encode (auth), this.encode (this.secret)); if (method === 'POST') { body = this.json (this.extend (query, { @@ -43453,7 +45354,7 @@ module.exports = class bybit extends Exchange { } }; -},{"./base/Exchange":5,"./base/errors":7,"./base/functions/number":13}],57:[function(require,module,exports){ +},{"./base/Exchange":6,"./base/errors":8,"./base/functions/number":14}],57:[function(require,module,exports){ 'use strict'; // --------------------------------------------------------------------------- @@ -43741,7 +45642,7 @@ module.exports = class bytetrade extends Exchange { async fetchBalance (params = {}) { if (!('userid' in params) && (this.apiKey === undefined)) { - throw new ArgumentsRequired (this.id + ' fetchDeposits requires this.apiKey or userid argument'); + throw new ArgumentsRequired (this.id + ' fetchDeposits() requires this.apiKey or userid argument'); } await this.loadMarkets (); const request = { @@ -44036,6 +45937,7 @@ module.exports = class bytetrade extends Exchange { 'symbol': symbol, 'type': type, 'timeInForce': undefined, + 'postOnly': undefined, 'side': side, 'price': price, 'stopPrice': undefined, @@ -44053,7 +45955,7 @@ module.exports = class bytetrade extends Exchange { async createOrder (symbol, type, side, amount, price = undefined, params = {}) { this.checkRequiredDependencies (); if (this.apiKey === undefined) { - throw new ArgumentsRequired ('createOrder requires this.apiKey or userid in params'); + throw new ArgumentsRequired ('createOrder() requires this.apiKey or userid in params'); } await this.loadMarkets (); const market = this.market (symbol); @@ -44237,7 +46139,7 @@ module.exports = class bytetrade extends Exchange { async fetchOrder (id, symbol = undefined, params = {}) { if (!('userid' in params) && (this.apiKey === undefined)) { - throw new ArgumentsRequired ('fetchOrder requires this.apiKey or userid argument'); + throw new ArgumentsRequired ('fetchOrder() requires this.apiKey or userid argument'); } await this.loadMarkets (); const request = { @@ -44255,7 +46157,7 @@ module.exports = class bytetrade extends Exchange { async fetchOpenOrders (symbol = undefined, since = undefined, limit = undefined, params = {}) { if (!('userid' in params) && (this.apiKey === undefined)) { - throw new ArgumentsRequired ('fetchOpenOrders requires this.apiKey or userid argument'); + throw new ArgumentsRequired ('fetchOpenOrders() requires this.apiKey or userid argument'); } await this.loadMarkets (); const request = { @@ -44275,7 +46177,7 @@ module.exports = class bytetrade extends Exchange { async fetchClosedOrders (symbol = undefined, since = undefined, limit = undefined, params = {}) { if (!('userid' in params) && (this.apiKey === undefined)) { - throw new ArgumentsRequired ('fetchClosedOrders requires this.apiKey or userid argument'); + throw new ArgumentsRequired ('fetchClosedOrders() requires this.apiKey or userid argument'); } await this.loadMarkets (); let market = undefined; @@ -44295,7 +46197,7 @@ module.exports = class bytetrade extends Exchange { async fetchOrders (symbol = undefined, since = undefined, limit = undefined, params = {}) { if (!('userid' in params) && (this.apiKey === undefined)) { - throw new ArgumentsRequired ('fetchOrders requires this.apiKey or userid argument'); + throw new ArgumentsRequired ('fetchOrders() requires this.apiKey or userid argument'); } await this.loadMarkets (); let market = undefined; @@ -44315,10 +46217,10 @@ module.exports = class bytetrade extends Exchange { async cancelOrder (id, symbol = undefined, params = {}) { if (this.apiKey === undefined) { - throw new ArgumentsRequired ('cancelOrder requires hasAlreadyAuthenticatedSuccessfully'); + throw new ArgumentsRequired ('cancelOrder() requires hasAlreadyAuthenticatedSuccessfully'); } if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' cancelOrder requires a symbol argument'); + throw new ArgumentsRequired (this.id + ' cancelOrder() requires a symbol argument'); } await this.loadMarkets (); const market = this.market (symbol); @@ -44416,7 +46318,7 @@ module.exports = class bytetrade extends Exchange { async transfer (code, amount, address, message = '', params = {}) { this.checkRequiredDependencies (); if (this.apiKey === undefined) { - throw new ArgumentsRequired ('transfer requires this.apiKey'); + throw new ArgumentsRequired ('transfer() requires this.apiKey'); } await this.loadMarkets (); const currency = this.currency (code); @@ -44522,7 +46424,7 @@ module.exports = class bytetrade extends Exchange { async fetchMyTrades (symbol = undefined, since = undefined, limit = undefined, params = {}) { if (!('userid' in params) && (this.apiKey === undefined)) { - throw new ArgumentsRequired ('fetchMyTrades requires this.apiKey or userid argument'); + throw new ArgumentsRequired ('fetchMyTrades() requires this.apiKey or userid argument'); } await this.loadMarkets (); const market = this.market (symbol); @@ -44542,7 +46444,7 @@ module.exports = class bytetrade extends Exchange { async fetchDeposits (code = undefined, since = undefined, limit = undefined, params = {}) { await this.loadMarkets (); if (!('userid' in params) && (this.apiKey === undefined)) { - throw new ArgumentsRequired ('fetchDeposits requires this.apiKey or userid argument'); + throw new ArgumentsRequired ('fetchDeposits() requires this.apiKey or userid argument'); } let currency = undefined; const request = { @@ -44565,7 +46467,7 @@ module.exports = class bytetrade extends Exchange { async fetchWithdrawals (code = undefined, since = undefined, limit = undefined, params = {}) { await this.loadMarkets (); if (!('userid' in params) && (this.apiKey === undefined)) { - throw new ArgumentsRequired ('fetchWithdrawals requires this.apiKey or userid argument'); + throw new ArgumentsRequired ('fetchWithdrawals() requires this.apiKey or userid argument'); } let currency = undefined; const request = { @@ -44649,7 +46551,7 @@ module.exports = class bytetrade extends Exchange { async fetchDepositAddress (code, params = {}) { await this.loadMarkets (); if (!('userid' in params) && (this.apiKey === undefined)) { - throw new ArgumentsRequired ('fetchDepositAddress requires this.apiKey or userid argument'); + throw new ArgumentsRequired ('fetchDepositAddress() requires this.apiKey or userid argument'); } const currency = this.currency (code); const request = { @@ -44675,7 +46577,7 @@ module.exports = class bytetrade extends Exchange { this.checkAddress (address); await this.loadMarkets (); if (this.apiKey === undefined) { - throw new ArgumentsRequired ('withdraw requires this.apiKey'); + throw new ArgumentsRequired (this.id + ' withdraw() requires this.apiKey'); } const addressResponse = await this.fetchDepositAddress (code); const chainTypeString = this.safeString (addressResponse, 'chainType'); @@ -44885,7 +46787,42 @@ module.exports = class bytetrade extends Exchange { } }; -},{"./base/Exchange":5,"./base/errors":7,"./base/functions/number":13}],58:[function(require,module,exports){ +},{"./base/Exchange":6,"./base/errors":8,"./base/functions/number":14}],58:[function(require,module,exports){ +'use strict'; + +// --------------------------------------------------------------------------- + +const huobipro = require ('./huobipro.js'); + +// --------------------------------------------------------------------------- + +module.exports = class cdax extends huobipro { + describe () { + return this.deepExtend (super.describe (), { + 'id': 'cdax', + 'name': 'CDAX', + 'countries': [ 'RU' ], + 'hostname': 'cdax.io', + 'pro': false, + 'urls': { + 'logo': 'https://user-images.githubusercontent.com/1294454/102157692-fd406280-3e90-11eb-8d46-4511b617cd17.jpg', + 'api': { + 'market': 'https://{hostname}/api', + 'public': 'https://{hostname}/api', + 'private': 'https://{hostname}/api', + 'v2Public': 'https://{hostname}/api', + 'v2Private': 'https://{hostname}/api', + }, + 'www': 'https://cdax.io', + 'referral': 'https://cdax.io/invite?invite_code=esc74', + 'doc': 'https://github.com/cloudapidoc/API_Docs', + 'fees': 'https://cdax.io/about/fee', + }, + }); + } +}; + +},{"./huobipro.js":96}],59:[function(require,module,exports){ 'use strict'; // --------------------------------------------------------------------------- @@ -45564,10 +47501,9 @@ module.exports = class cex extends Exchange { let cost = undefined; if (market !== undefined) { symbol = market['symbol']; - cost = this.safeFloat (order, 'ta:' + market['quote']); - if (cost === undefined) { - cost = this.safeFloat (order, 'tta:' + market['quote']); - } + const taCost = this.safeFloat (order, 'ta:' + market['quote']); + const ttaCost = this.safeFloat (order, 'tta:' + market['quote']); + cost = this.sum (taCost, ttaCost); const baseFee = 'fa:' + market['base']; const baseTakerFee = 'tfa:' + market['base']; const quoteFee = 'fa:' + market['quote']; @@ -45771,6 +47707,7 @@ module.exports = class cex extends Exchange { 'symbol': symbol, 'type': (price === undefined) ? 'market' : 'limit', 'timeInForce': undefined, + 'postOnly': undefined, 'side': side, 'price': price, 'stopPrice': undefined, @@ -45806,7 +47743,7 @@ module.exports = class cex extends Exchange { await this.loadMarkets (); const method = 'privatePostArchivedOrdersPair'; if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' fetchClosedOrders requires a symbol argument'); + throw new ArgumentsRequired (this.id + ' fetchClosedOrders() requires a symbol argument'); } const market = this.market (symbol); const request = { 'pair': market['id'] }; @@ -46140,10 +48077,10 @@ module.exports = class cex extends Exchange { async editOrder (id, symbol, type, side, amount = undefined, price = undefined, params = {}) { if (amount === undefined) { - throw new ArgumentsRequired (this.id + ' editOrder requires a amount argument'); + throw new ArgumentsRequired (this.id + ' editOrder() requires a amount argument'); } if (price === undefined) { - throw new ArgumentsRequired (this.id + ' editOrder requires a price argument'); + throw new ArgumentsRequired (this.id + ' editOrder() requires a price argument'); } await this.loadMarkets (); const market = this.market (symbol); @@ -46235,7 +48172,7 @@ module.exports = class cex extends Exchange { } }; -},{"./base/Exchange":5,"./base/errors":7}],59:[function(require,module,exports){ +},{"./base/Exchange":6,"./base/errors":8}],60:[function(require,module,exports){ 'use strict'; // --------------------------------------------------------------------------- @@ -46269,13 +48206,13 @@ module.exports = class chilebit extends foxbit { } }; -},{"./foxbit.js":84}],60:[function(require,module,exports){ +},{"./foxbit.js":87}],61:[function(require,module,exports){ 'use strict'; // ---------------------------------------------------------------------------- const Exchange = require ('./base/Exchange'); -const { ExchangeError, ArgumentsRequired, AuthenticationError, RateLimitExceeded } = require ('./base/errors'); +const { ExchangeError, ArgumentsRequired, AuthenticationError, RateLimitExceeded, InvalidNonce } = require ('./base/errors'); // ---------------------------------------------------------------------------- @@ -46395,23 +48332,28 @@ module.exports = class coinbase extends Exchange { }, }, 'exceptions': { - 'two_factor_required': AuthenticationError, // 402 When sending money over 2fa limit - 'param_required': ExchangeError, // 400 Missing parameter - 'validation_error': ExchangeError, // 400 Unable to validate POST/PUT - 'invalid_request': ExchangeError, // 400 Invalid request - 'personal_details_required': AuthenticationError, // 400 User’s personal detail required to complete this request - 'identity_verification_required': AuthenticationError, // 400 Identity verification is required to complete this request - 'jumio_verification_required': AuthenticationError, // 400 Document verification is required to complete this request - 'jumio_face_match_verification_required': AuthenticationError, // 400 Document verification including face match is required to complete this request - 'unverified_email': AuthenticationError, // 400 User has not verified their email - 'authentication_error': AuthenticationError, // 401 Invalid auth (generic) - 'invalid_token': AuthenticationError, // 401 Invalid Oauth token - 'revoked_token': AuthenticationError, // 401 Revoked Oauth token - 'expired_token': AuthenticationError, // 401 Expired Oauth token - 'invalid_scope': AuthenticationError, // 403 User hasn’t authenticated necessary scope - 'not_found': ExchangeError, // 404 Resource not found - 'rate_limit_exceeded': RateLimitExceeded, // 429 Rate limit exceeded - 'internal_server_error': ExchangeError, // 500 Internal server error + 'exact': { + 'two_factor_required': AuthenticationError, // 402 When sending money over 2fa limit + 'param_required': ExchangeError, // 400 Missing parameter + 'validation_error': ExchangeError, // 400 Unable to validate POST/PUT + 'invalid_request': ExchangeError, // 400 Invalid request + 'personal_details_required': AuthenticationError, // 400 User’s personal detail required to complete this request + 'identity_verification_required': AuthenticationError, // 400 Identity verification is required to complete this request + 'jumio_verification_required': AuthenticationError, // 400 Document verification is required to complete this request + 'jumio_face_match_verification_required': AuthenticationError, // 400 Document verification including face match is required to complete this request + 'unverified_email': AuthenticationError, // 400 User has not verified their email + 'authentication_error': AuthenticationError, // 401 Invalid auth (generic) + 'invalid_token': AuthenticationError, // 401 Invalid Oauth token + 'revoked_token': AuthenticationError, // 401 Revoked Oauth token + 'expired_token': AuthenticationError, // 401 Expired Oauth token + 'invalid_scope': AuthenticationError, // 403 User hasn’t authenticated necessary scope + 'not_found': ExchangeError, // 404 Resource not found + 'rate_limit_exceeded': RateLimitExceeded, // 429 Rate limit exceeded + 'internal_server_error': ExchangeError, // 500 Internal server error + }, + 'broad': { + 'request timestamp expired': InvalidNonce, // {"errors":[{"id":"authentication_error","message":"request timestamp expired"}]} + }, }, 'commonCurrencies': { 'CGLD': 'CELO', @@ -46444,7 +48386,11 @@ module.exports = class coinbase extends Exchange { } async fetchAccounts (params = {}) { - const response = await this.privateGetAccounts (params); + await this.loadMarkets (); + const request = { + 'limit': 100, + }; + const response = await this.privateGetAccounts (this.extend (request, params)); // // { // "id": "XLM", @@ -46975,7 +48921,10 @@ module.exports = class coinbase extends Exchange { async fetchBalance (params = {}) { await this.loadMarkets (); - const response = await this.privateGetAccounts (params); + const request = { + 'limit': 100, + }; + const response = await this.privateGetAccounts (this.extend (request, params)); const balances = this.safeValue (response, 'data'); const accounts = this.safeValue (params, 'type', this.options['accounts']); const result = { 'info': response }; @@ -47447,7 +49396,9 @@ module.exports = class coinbase extends Exchange { // let errorCode = this.safeString (response, 'error'); if (errorCode !== undefined) { - this.throwExactlyMatchedException (this.exceptions, errorCode, feedback); + const errorMessage = this.safeString (response, 'error_description'); + this.throwExactlyMatchedException (this.exceptions['exact'], errorCode, feedback); + this.throwBroadlyMatchedException (this.exceptions['broad'], errorMessage, feedback); throw new ExchangeError (feedback); } const errors = this.safeValue (response, 'errors'); @@ -47456,8 +49407,10 @@ module.exports = class coinbase extends Exchange { const numErrors = errors.length; if (numErrors > 0) { errorCode = this.safeString (errors[0], 'id'); + const errorMessage = this.safeString (errors[0], 'message'); if (errorCode !== undefined) { - this.throwExactlyMatchedException (this.exceptions, errorCode, feedback); + this.throwExactlyMatchedException (this.exceptions['exact'], errorCode, feedback); + this.throwBroadlyMatchedException (this.exceptions['broad'], errorMessage, feedback); throw new ExchangeError (feedback); } } @@ -47471,7 +49424,7 @@ module.exports = class coinbase extends Exchange { }; -},{"./base/Exchange":5,"./base/errors":7}],61:[function(require,module,exports){ +},{"./base/Exchange":6,"./base/errors":8}],62:[function(require,module,exports){ 'use strict'; // --------------------------------------------------------------------------- @@ -47504,7 +49457,7 @@ module.exports = class coinbaseprime extends coinbasepro { } }; -},{"./coinbasepro.js":62}],62:[function(require,module,exports){ +},{"./coinbasepro.js":63}],63:[function(require,module,exports){ 'use strict'; // ---------------------------------------------------------------------------- @@ -47852,6 +49805,7 @@ module.exports = class coinbasepro extends Exchange { } async fetchAccounts (params = {}) { + await this.loadMarkets (); const response = await this.privateGetAccounts (params); // // [ @@ -48030,12 +49984,20 @@ module.exports = class coinbasepro extends Exchange { // trade_id: 82047307, // maker_order_id: '0f358725-2134-435e-be11-753912a326e0', // taker_order_id: '252b7002-87a3-425c-ac73-f5b9e23f3caf', + // order_id: 'd50ec984-77a8-460a-b958-66f114b0de9b', // side: 'sell', // size: '0.00513192', // price: '9314.78', // product_id: 'BTC-USD', + // profile_id: '6244401d-c078-40d9-b305-7ad3551bc3b0', // sequence: 12038915443, // time: '2020-01-31T20:03:41.158814Z' + // created_at: '2014-11-07T22:19:28.578544Z', + // liquidity: 'T', + // fee: '0.00025', + // settled: true, + // usd_volume: '0.0924556000000000', + // user_id: '595eb864313c2b02ddf2937d' // } // const timestamp = this.parse8601 (this.safeString2 (trade, 'time', 'created_at')); @@ -48044,10 +50006,15 @@ module.exports = class coinbasepro extends Exchange { let feeRate = undefined; let feeCurrency = undefined; let takerOrMaker = undefined; + let cost = undefined; if (market !== undefined) { + const feeCurrencyId = this.safeStringLower (market, 'quoteId'); + const costField = feeCurrencyId + '_value'; + cost = this.safeFloat (trade, costField); feeCurrency = market['quote']; - if ('liquidity' in trade) { - takerOrMaker = (trade['liquidity'] === 'T') ? 'taker' : 'maker'; + const liquidity = this.safeString (trade, 'liquidity'); + if (liquidity !== undefined) { + takerOrMaker = (liquidity === 'T') ? 'taker' : 'maker'; feeRate = market[takerOrMaker]; } } @@ -48067,6 +50034,9 @@ module.exports = class coinbasepro extends Exchange { } const price = this.safeFloat (trade, 'price'); const amount = this.safeFloat (trade, 'size'); + if (cost === undefined) { + cost = amount * price; + } return { 'id': id, 'order': orderId, @@ -48080,14 +50050,14 @@ module.exports = class coinbasepro extends Exchange { 'price': price, 'amount': amount, 'fee': fee, - 'cost': price * amount, + 'cost': cost, }; } async fetchMyTrades (symbol = undefined, since = undefined, limit = undefined, params = {}) { // as of 2018-08-23 if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' fetchMyTrades requires a symbol argument'); + throw new ArgumentsRequired (this.id + ' fetchMyTrades() requires a symbol argument'); } await this.loadMarkets (); const market = this.market (symbol); @@ -48107,6 +50077,9 @@ module.exports = class coinbasepro extends Exchange { const request = { 'id': market['id'], // fixes issue #2 }; + if (limit !== undefined) { + request['limit'] = limit; // default 100 + } const response = await this.publicGetProductsIdTrades (this.extend (request, params)); return this.parseTrades (response, market, since, limit); } @@ -48183,6 +50156,27 @@ module.exports = class coinbasepro extends Exchange { } parseOrder (order, market = undefined) { + // + // createOrder + // + // { + // "id": "d0c5340b-6d6c-49d9-b567-48c4bfca13d2", + // "price": "0.10000000", + // "size": "0.01000000", + // "product_id": "BTC-USD", + // "side": "buy", + // "stp": "dc", + // "type": "limit", + // "time_in_force": "GTC", + // "post_only": false, + // "created_at": "2016-12-08T20:02:28.53864Z", + // "fill_fees": "0.0000000000000000", + // "filled_size": "0.00000000", + // "executed_value": "0.0000000000000000", + // "status": "pending", + // "settled": false + // } + // const timestamp = this.parse8601 (this.safeString (order, 'created_at')); const marketId = this.safeString (order, 'product_id'); market = this.safeMarket (marketId, market, '-'); @@ -48213,9 +50207,13 @@ module.exports = class coinbasepro extends Exchange { const id = this.safeString (order, 'id'); const type = this.safeString (order, 'type'); const side = this.safeString (order, 'side'); + const timeInForce = this.safeString (order, 'time_in_force'); + const postOnly = this.safeValue (order, 'post_only'); + const stopPrice = this.safeFloat (order, 'stop_price'); + const clientOrderId = this.safeString (order, 'client_oid'); return { 'id': id, - 'clientOrderId': undefined, + 'clientOrderId': clientOrderId, 'info': order, 'timestamp': timestamp, 'datetime': this.iso8601 (timestamp), @@ -48223,10 +50221,11 @@ module.exports = class coinbasepro extends Exchange { 'status': status, 'symbol': market['symbol'], 'type': type, - 'timeInForce': undefined, + 'timeInForce': timeInForce, + 'postOnly': postOnly, 'side': side, 'price': price, - 'stopPrice': undefined, + 'stopPrice': stopPrice, 'cost': cost, 'amount': amount, 'filled': filled, @@ -48239,10 +50238,18 @@ module.exports = class coinbasepro extends Exchange { async fetchOrder (id, symbol = undefined, params = {}) { await this.loadMarkets (); - const request = { - 'id': id, - }; - const response = await this.privateGetOrdersId (this.extend (request, params)); + const request = {}; + const clientOrderId = this.safeString2 (params, 'clientOrderId', 'client_oid'); + let method = undefined; + if (clientOrderId === undefined) { + method = 'privateGetOrdersId'; + request['id'] = id; + } else { + method = 'privateGetOrdersClientClientOid'; + request['client_oid'] = clientOrderId; + params = this.omit (params, [ 'clientOrderId', 'client_oid' ]); + } + const response = await this[method] (this.extend (request, params)); return this.parseOrder (response); } @@ -48260,17 +50267,10 @@ module.exports = class coinbasepro extends Exchange { } async fetchOrders (symbol = undefined, since = undefined, limit = undefined, params = {}) { - await this.loadMarkets (); const request = { 'status': 'all', }; - let market = undefined; - if (symbol !== undefined) { - market = this.market (symbol); - request['product_id'] = market['id']; - } - const response = await this.privateGetOrders (this.extend (request, params)); - return this.parseOrders (response, market, since, limit); + return await this.fetchOpenOrders (symbol, since, limit, this.extend (request, params)); } async fetchOpenOrders (symbol = undefined, since = undefined, limit = undefined, params = {}) { @@ -48281,47 +50281,131 @@ module.exports = class coinbasepro extends Exchange { market = this.market (symbol); request['product_id'] = market['id']; } + if (limit !== undefined) { + request['limit'] = limit; // default 100 + } const response = await this.privateGetOrders (this.extend (request, params)); return this.parseOrders (response, market, since, limit); } async fetchClosedOrders (symbol = undefined, since = undefined, limit = undefined, params = {}) { - await this.loadMarkets (); const request = { 'status': 'done', }; - let market = undefined; - if (symbol !== undefined) { - market = this.market (symbol); - request['product_id'] = market['id']; - } - const response = await this.privateGetOrders (this.extend (request, params)); - return this.parseOrders (response, market, since, limit); + return await this.fetchOpenOrders (symbol, since, limit, this.extend (request, params)); } async createOrder (symbol, type, side, amount, price = undefined, params = {}) { await this.loadMarkets (); - // let oid = this.nonce ().toString (); + const market = this.market (symbol); const request = { - 'product_id': this.marketId (symbol), - 'side': side, - 'size': this.amountToPrecision (symbol, amount), + // common params -------------------------------------------------- + // 'client_oid': clientOrderId, 'type': type, + 'side': side, + 'product_id': market['id'], + // 'size': this.amountToPrecision (symbol, amount), + // 'stp': 'dc', // self-trade prevention, dc = decrease and cancel, co = cancel oldest, cn = cancel newest, cb = cancel both + // 'stop': 'loss', // "loss" = stop loss below price, "entry" = take profit above price + // 'stop_price': this.priceToPrecision (symbol, price), + // limit order params --------------------------------------------- + // 'price': this.priceToPrecision (symbol, price), + // 'size': this.amountToPrecision (symbol, amount), + // 'time_in_force': 'GTC', // GTC, GTT, IOC, or FOK + // 'cancel_after' [optional]* min, hour, day, requires time_in_force to be GTT + // 'post_only': false, // invalid when time_in_force is IOC or FOK + // market order params -------------------------------------------- + // 'size': this.amountToPrecision (symbol, amount), + // 'funds': this.costToPrecision (symbol, amount), }; + const clientOrderId = this.safeString2 (params, 'clientOrderId', 'client_oid'); + if (clientOrderId !== undefined) { + request['client_oid'] = clientOrderId; + params = this.omit (params, [ 'clientOrderId', 'client_oid' ]); + } + const stopPrice = this.safeFloat2 (params, 'stopPrice', 'stop_price'); + if (stopPrice !== undefined) { + request['stop_price'] = this.priceToPrecision (symbol, stopPrice); + params = this.omit (params, [ 'stopPrice', 'stop_price' ]); + } + const timeInForce = this.safeString2 (params, 'timeInForce', 'time_in_force'); + if (timeInForce !== undefined) { + request['time_in_force'] = timeInForce; + params = this.omit (params, [ 'timeInForce', 'time_in_force' ]); + } if (type === 'limit') { request['price'] = this.priceToPrecision (symbol, price); + request['size'] = this.amountToPrecision (symbol, amount); + } else if (type === 'market') { + let cost = this.safeFloat2 (params, 'cost', 'funds'); + if (cost === undefined) { + if (price !== undefined) { + cost = amount * price; + } + } else { + params = this.omit (params, [ 'cost', 'funds' ]); + } + if (cost !== undefined) { + request['funds'] = this.costToPrecision (symbol, cost); + } else { + request['size'] = this.amountToPrecision (symbol, amount); + } } const response = await this.privatePostOrders (this.extend (request, params)); - return this.parseOrder (response); + // + // { + // "id": "d0c5340b-6d6c-49d9-b567-48c4bfca13d2", + // "price": "0.10000000", + // "size": "0.01000000", + // "product_id": "BTC-USD", + // "side": "buy", + // "stp": "dc", + // "type": "limit", + // "time_in_force": "GTC", + // "post_only": false, + // "created_at": "2016-12-08T20:02:28.53864Z", + // "fill_fees": "0.0000000000000000", + // "filled_size": "0.00000000", + // "executed_value": "0.0000000000000000", + // "status": "pending", + // "settled": false + // } + // + return this.parseOrder (response, market); } async cancelOrder (id, symbol = undefined, params = {}) { await this.loadMarkets (); - return await this.privateDeleteOrdersId ({ 'id': id }); + const request = { + // 'product_id': market['id'], // the request will be more performant if you include it + }; + const clientOrderId = this.safeString2 (params, 'clientOrderId', 'client_oid'); + let method = undefined; + if (clientOrderId === undefined) { + method = 'privateDeleteOrdersId'; + request['id'] = id; + } else { + method = 'privateDeleteOrdersClientClientOid'; + request['client_oid'] = clientOrderId; + params = this.omit (params, [ 'clientOrderId', 'client_oid' ]); + } + let market = undefined; + if (symbol !== undefined) { + market = this.market (symbol); + request['product_id'] = market['symbol']; // the request will be more performant if you include it + } + return await this[method] (this.extend (request, params)); } async cancelAllOrders (symbol = undefined, params = {}) { - return await this.privateDeleteOrders (params); + await this.loadMarkets (); + const request = {}; + let market = undefined; + if (symbol !== undefined) { + market = this.market (symbol); + request['product_id'] = market['symbol']; // the request will be more performant if you include it + } + return await this.privateDeleteOrders (this.extend (request, params)); } calculateFee (symbol, type, side, amount, price, takerOrMaker = 'taker', params = {}) { @@ -48387,6 +50471,9 @@ module.exports = class coinbasepro extends Exchange { } else { method += 'Crypto'; request['crypto_address'] = address; + if (tag !== undefined) { + request['destination_tag'] = tag; + } } const response = await this[method] (this.extend (request, params)); if (!response) { @@ -48472,7 +50559,7 @@ module.exports = class coinbasepro extends Exchange { const currencyId = this.safeString (transaction, 'currency'); const code = this.safeCurrencyCode (currencyId, currency); const status = this.parseTransactionStatus (transaction); - const amount = this.safeFloat (transaction, 'amount'); + let amount = this.safeFloat (transaction, 'amount'); let type = this.safeString (transaction, 'type'); let address = this.safeString (details, 'crypto_address'); const tag = this.safeString (details, 'destination_tag'); @@ -48483,9 +50570,12 @@ module.exports = class coinbasepro extends Exchange { address = this.safeString (details, 'sent_to_address', address); const feeCost = this.safeFloat (details, 'fee'); if (feeCost !== undefined) { + if (amount !== undefined) { + amount -= feeCost; + } fee = { 'cost': feeCost, - 'code': code, + 'currency': code, }; } } @@ -48592,7 +50682,7 @@ module.exports = class coinbasepro extends Exchange { } }; -},{"./base/Exchange":5,"./base/errors":7,"./base/functions/number":13}],63:[function(require,module,exports){ +},{"./base/Exchange":6,"./base/errors":8,"./base/functions/number":14}],64:[function(require,module,exports){ 'use strict'; // --------------------------------------------------------------------------- @@ -48676,10 +50766,11 @@ module.exports = class coincheck extends Exchange { 'markets': { 'BTC/JPY': { 'id': 'btc_jpy', 'symbol': 'BTC/JPY', 'base': 'BTC', 'quote': 'JPY', 'baseId': 'btc', 'quoteId': 'jpy' }, // the only real pair // 'ETH/JPY': { 'id': 'eth_jpy', 'symbol': 'ETH/JPY', 'base': 'ETH', 'quote': 'JPY', 'baseId': 'eth', 'quoteId': 'jpy' }, - // 'ETC/JPY': { 'id': 'etc_jpy', 'symbol': 'ETC/JPY', 'base': 'ETC', 'quote': 'JPY', 'baseId': 'etc', 'quoteId': 'jpy' }, + 'ETC/JPY': { 'id': 'etc_jpy', 'symbol': 'ETC/JPY', 'base': 'ETC', 'quote': 'JPY', 'baseId': 'etc', 'quoteId': 'jpy' }, // 'DAO/JPY': { 'id': 'dao_jpy', 'symbol': 'DAO/JPY', 'base': 'DAO', 'quote': 'JPY', 'baseId': 'dao', 'quoteId': 'jpy' }, // 'LSK/JPY': { 'id': 'lsk_jpy', 'symbol': 'LSK/JPY', 'base': 'LSK', 'quote': 'JPY', 'baseId': 'lsk', 'quoteId': 'jpy' }, - // 'FCT/JPY': { 'id': 'fct_jpy', 'symbol': 'FCT/JPY', 'base': 'FCT', 'quote': 'JPY', 'baseId': 'fct', 'quoteId': 'jpy' }, + 'FCT/JPY': { 'id': 'fct_jpy', 'symbol': 'FCT/JPY', 'base': 'FCT', 'quote': 'JPY', 'baseId': 'fct', 'quoteId': 'jpy' }, + 'MONA/JPY': { 'id': 'mona_jpy', 'symbol': 'MONA/JPY', 'base': 'MONA', 'quote': 'JPY', 'baseId': 'mona', 'quoteId': 'jpy' }, // 'XMR/JPY': { 'id': 'xmr_jpy', 'symbol': 'XMR/JPY', 'base': 'XMR', 'quote': 'JPY', 'baseId': 'xmr', 'quoteId': 'jpy' }, // 'REP/JPY': { 'id': 'rep_jpy', 'symbol': 'REP/JPY', 'base': 'REP', 'quote': 'JPY', 'baseId': 'rep', 'quoteId': 'jpy' }, // 'XRP/JPY': { 'id': 'xrp_jpy', 'symbol': 'XRP/JPY', 'base': 'XRP', 'quote': 'JPY', 'baseId': 'xrp', 'quoteId': 'jpy' }, @@ -48688,7 +50779,7 @@ module.exports = class coincheck extends Exchange { // 'LTC/JPY': { 'id': 'ltc_jpy', 'symbol': 'LTC/JPY', 'base': 'LTC', 'quote': 'JPY', 'baseId': 'ltc', 'quoteId': 'jpy' }, // 'DASH/JPY': { 'id': 'dash_jpy', 'symbol': 'DASH/JPY', 'base': 'DASH', 'quote': 'JPY', 'baseId': 'dash', 'quoteId': 'jpy' }, // 'ETH/BTC': { 'id': 'eth_btc', 'symbol': 'ETH/BTC', 'base': 'ETH', 'quote': 'BTC', 'baseId': 'eth', 'quoteId': 'btc' }, - // 'ETC/BTC': { 'id': 'etc_btc', 'symbol': 'ETC/BTC', 'base': 'ETC', 'quote': 'BTC', 'baseId': 'etc', 'quoteId': 'btc' }, + 'ETC/BTC': { 'id': 'etc_btc', 'symbol': 'ETC/BTC', 'base': 'ETC', 'quote': 'BTC', 'baseId': 'etc', 'quoteId': 'btc' }, // 'LSK/BTC': { 'id': 'lsk_btc', 'symbol': 'LSK/BTC', 'base': 'LSK', 'quote': 'BTC', 'baseId': 'lsk', 'quoteId': 'btc' }, // 'FCT/BTC': { 'id': 'fct_btc', 'symbol': 'FCT/BTC', 'base': 'FCT', 'quote': 'BTC', 'baseId': 'fct', 'quoteId': 'btc' }, // 'XMR/BTC': { 'id': 'xmr_btc', 'symbol': 'XMR/BTC', 'base': 'XMR', 'quote': 'BTC', 'baseId': 'xmr', 'quoteId': 'btc' }, @@ -48792,6 +50883,7 @@ module.exports = class coincheck extends Exchange { 'side': side, 'type': undefined, 'timeInForce': undefined, + 'postOnly': undefined, 'status': status, 'symbol': symbol, 'price': price, @@ -48805,11 +50897,12 @@ module.exports = class coincheck extends Exchange { } async fetchOrderBook (symbol, limit = undefined, params = {}) { - if (symbol !== 'BTC/JPY') { - throw new BadSymbol (this.id + ' fetchOrderBook () supports BTC/JPY only'); - } await this.loadMarkets (); - const response = await this.publicGetOrderBooks (params); + const market = this.market (symbol); + const request = { + 'pair': market['id'], + }; + const response = await this.publicGetOrderBooks (this.extend (request, params)); return this.parseOrderBook (response); } @@ -48818,7 +50911,11 @@ module.exports = class coincheck extends Exchange { throw new BadSymbol (this.id + ' fetchTicker () supports BTC/JPY only'); } await this.loadMarkets (); - const ticker = await this.publicGetTicker (params); + const market = this.market (symbol); + const request = { + 'pair': market['id'], + }; + const ticker = await this.publicGetTicker (this.extend (request, params)); const timestamp = this.safeTimestamp (ticker, 'timestamp'); const last = this.safeFloat (ticker, 'last'); return { @@ -48932,9 +51029,6 @@ module.exports = class coincheck extends Exchange { } async fetchTrades (symbol, since = undefined, limit = undefined, params = {}) { - if (symbol !== 'BTC/JPY') { - throw new BadSymbol (this.id + ' fetchTrades () supports BTC/JPY only'); - } await this.loadMarkets (); const market = this.market (symbol); const request = { @@ -49024,7 +51118,7 @@ module.exports = class coincheck extends Exchange { } }; -},{"./base/Exchange":5,"./base/errors":7}],64:[function(require,module,exports){ +},{"./base/Exchange":6,"./base/errors":8}],65:[function(require,module,exports){ 'use strict'; // --------------------------------------------------------------------------- @@ -49181,6 +51275,7 @@ module.exports = class coinegg extends Exchange { }, 'commonCurrencies': { 'JBC': 'JubaoCoin', + 'SBTC': 'Super Bitcoin', }, }); } @@ -49394,6 +51489,7 @@ module.exports = class coinegg extends Exchange { 'symbol': symbol, 'type': type, 'timeInForce': undefined, + 'postOnly': undefined, 'side': side, 'price': price, 'stopPrice': undefined, @@ -49541,7 +51637,7 @@ module.exports = class coinegg extends Exchange { } }; -},{"./base/Exchange":5,"./base/errors":7}],65:[function(require,module,exports){ +},{"./base/Exchange":6,"./base/errors":8}],66:[function(require,module,exports){ 'use strict'; // --------------------------------------------------------------------------- @@ -49636,6 +51732,8 @@ module.exports = class coinex extends Exchange { 'order/status', 'order/status/batch', 'order/user/deals', + 'sub_account/balance', + 'sub_account/transfer/history', ], 'post': [ 'balance/coin/withdraw', @@ -50043,6 +52141,7 @@ module.exports = class coinex extends Exchange { 'symbol': symbol, 'type': type, 'timeInForce': undefined, + 'postOnly': undefined, 'side': side, 'price': price, 'stopPrice': undefined, @@ -50106,7 +52205,7 @@ module.exports = class coinex extends Exchange { async fetchOrder (id, symbol = undefined, params = {}) { if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' fetchOrder requires a symbol argument'); + throw new ArgumentsRequired (this.id + ' fetchOrder() requires a symbol argument'); } await this.loadMarkets (); const market = this.market (symbol); @@ -50303,7 +52402,7 @@ module.exports = class coinex extends Exchange { const timestamp = this.safeTimestamp (transaction, 'create_time'); const type = ('coin_withdraw_id' in transaction) ? 'withdraw' : 'deposit'; const status = this.parseTransactionStatus (this.safeString (transaction, 'status')); - const amount = this.safeFloat (transaction, 'amount'); + let amount = this.safeFloat (transaction, 'amount'); let feeCost = this.safeFloat (transaction, 'tx_fee'); if (type === 'deposit') { feeCost = 0; @@ -50312,6 +52411,10 @@ module.exports = class coinex extends Exchange { 'cost': feeCost, 'currency': code, }; + // https://github.com/ccxt/ccxt/issues/8321 + if (amount !== undefined) { + amount = amount - feeCost; + } return { 'info': transaction, 'id': id, @@ -50331,7 +52434,7 @@ module.exports = class coinex extends Exchange { async fetchWithdrawals (code = undefined, since = undefined, limit = undefined, params = {}) { if (code === undefined) { - throw new ArgumentsRequired (this.id + ' fetchWithdrawals requires a currency code argument'); + throw new ArgumentsRequired (this.id + ' fetchWithdrawals() requires a currency code argument'); } await this.loadMarkets (); const currency = this.currency (code); @@ -50389,7 +52492,7 @@ module.exports = class coinex extends Exchange { async fetchDeposits (code = undefined, since = undefined, limit = undefined, params = {}) { if (code === undefined) { - throw new ArgumentsRequired (this.id + ' fetchDeposits requires a currency code argument'); + throw new ArgumentsRequired (this.id + ' fetchDeposits() requires a currency code argument'); } await this.loadMarkets (); const currency = this.currency (code); @@ -50454,7 +52557,7 @@ module.exports = class coinex extends Exchange { 'tonce': nonce.toString (), }, query); query = this.keysort (query); - const urlencoded = this.urlencode (query); + const urlencoded = this.rawencode (query); const signature = this.hash (this.encode (urlencoded + '&secret_key=' + this.secret)); headers = { 'Authorization': signature.toUpperCase (), @@ -50491,7 +52594,7 @@ module.exports = class coinex extends Exchange { } }; -},{"./base/Exchange":5,"./base/errors":7}],66:[function(require,module,exports){ +},{"./base/Exchange":6,"./base/errors":8}],67:[function(require,module,exports){ 'use strict'; // --------------------------------------------------------------------------- @@ -50711,7 +52814,7 @@ module.exports = class coinfalcon extends Exchange { async fetchMyTrades (symbol = undefined, since = undefined, limit = undefined, params = {}) { if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' fetchMyTrades requires a symbol argument'); + throw new ArgumentsRequired (this.id + ' fetchMyTrades() requires a symbol argument'); } await this.loadMarkets (); const market = this.market (symbol); @@ -50814,6 +52917,7 @@ module.exports = class coinfalcon extends Exchange { type = type[0]; } const side = this.safeString (order, 'order_type'); + const postOnly = this.safeValue (order, 'post_only'); return { 'id': this.safeString (order, 'id'), 'clientOrderId': undefined, @@ -50823,6 +52927,7 @@ module.exports = class coinfalcon extends Exchange { 'symbol': symbol, 'type': type, 'timeInForce': undefined, + 'postOnly': postOnly, 'side': side, 'price': price, 'stopPrice': undefined, @@ -50945,7 +53050,7 @@ module.exports = class coinfalcon extends Exchange { } }; -},{"./base/Exchange":5,"./base/errors":7}],67:[function(require,module,exports){ +},{"./base/Exchange":6,"./base/errors":8}],68:[function(require,module,exports){ 'use strict'; // --------------------------------------------------------------------------- @@ -50975,7 +53080,7 @@ module.exports = class coinfloor extends Exchange { }, 'urls': { 'logo': 'https://user-images.githubusercontent.com/51840849/87153925-ef265e80-c2c0-11ea-91b5-020c804b90e0.jpg', - 'api': 'https://webapi.coinfloor.co.uk/bist', + 'api': 'https://webapi.coinfloor.co.uk/v2/bist', 'www': 'https://www.coinfloor.co.uk', 'doc': [ 'https://github.com/coinfloor/api', @@ -51038,7 +53143,7 @@ module.exports = class coinfloor extends Exchange { market = this.markets_by_id[marketId]; } if (market === undefined) { - throw new ArgumentsRequired (this.id + ' fetchBalance requires a symbol param'); + throw new ArgumentsRequired (this.id + ' fetchBalance() requires a symbol param'); } const request = { 'id': market['id'], @@ -51171,7 +53276,7 @@ module.exports = class coinfloor extends Exchange { if (code !== undefined) { market = this.market (code); if (market === undefined) { - throw new ArgumentsRequired (this.id + ' fetchTransactions requires a code argument (a market symbol)'); + throw new ArgumentsRequired (this.id + ' fetchTransactions() requires a code argument (a market symbol)'); } } const request = { @@ -51379,7 +53484,7 @@ module.exports = class coinfloor extends Exchange { async cancelOrder (id, symbol = undefined, params = {}) { if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' cancelOrder requires a symbol argument'); + throw new ArgumentsRequired (this.id + ' cancelOrder() requires a symbol argument'); } await this.loadMarkets (); const market = this.market (symbol); @@ -51428,6 +53533,7 @@ module.exports = class coinfloor extends Exchange { 'symbol': symbol, 'type': 'limit', 'timeInForce': undefined, + 'postOnly': undefined, 'side': side, 'price': price, 'stopPrice': undefined, @@ -51443,7 +53549,7 @@ module.exports = class coinfloor extends Exchange { async fetchOpenOrders (symbol = undefined, since = undefined, limit = undefined, params = {}) { if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' fetchOpenOrders requires a symbol param'); + throw new ArgumentsRequired (this.id + ' fetchOpenOrders() requires a symbol param'); } await this.loadMarkets (); const market = this.market (symbol); @@ -51497,7 +53603,7 @@ module.exports = class coinfloor extends Exchange { } }; -},{"./base/Exchange":5,"./base/errors":7}],68:[function(require,module,exports){ +},{"./base/Exchange":6,"./base/errors":8}],69:[function(require,module,exports){ 'use strict'; // --------------------------------------------------------------------------- @@ -51847,7 +53953,7 @@ module.exports = class coingi extends Exchange { } }; -},{"./base/Exchange":5,"./base/errors":7}],69:[function(require,module,exports){ +},{"./base/Exchange":6,"./base/errors":8}],70:[function(require,module,exports){ 'use strict'; // --------------------------------------------------------------------------- @@ -52000,6 +54106,8 @@ module.exports = class coinmarketcap extends Exchange { // https://github.com/ccxt/ccxt/issues/6081 // https://github.com/ccxt/ccxt/issues/3365 // https://github.com/ccxt/ccxt/issues/2873 + 'SBTCT': 'SiamBitcoin', // conflict with sBTC + 'Super Bitcoin': 'Super Bitcoin', // conflict with sBTC 'TerraCredit': 'TerraCredit', // conflict with CREDIT (PROXI) 'Themis': 'Themis', // conflict with GET (Guaranteed Entrance Token, GET Protocol) 'UNI COIN': 'UNI COIN', // conflict with UNI (Uniswap) @@ -52194,7 +54302,7 @@ module.exports = class coinmarketcap extends Exchange { } }; -},{"./base/Exchange":5,"./base/errors":7}],70:[function(require,module,exports){ +},{"./base/Exchange":6,"./base/errors":8}],71:[function(require,module,exports){ 'use strict'; // --------------------------------------------------------------------------- @@ -52726,7 +54834,7 @@ module.exports = class coinmate extends Exchange { async fetchOrders (symbol = undefined, since = undefined, limit = undefined, params = {}) { if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' fetchOrders requires a symbol argument'); + throw new ArgumentsRequired (this.id + ' fetchOrders() requires a symbol argument'); } await this.loadMarkets (); const market = this.market (symbol); @@ -52838,6 +54946,7 @@ module.exports = class coinmate extends Exchange { 'symbol': symbol, 'type': type, 'timeInForce': undefined, + 'postOnly': undefined, 'side': side, 'price': price, 'stopPrice': stopPrice, @@ -52955,7 +55064,7 @@ module.exports = class coinmate extends Exchange { } }; -},{"./base/Exchange":5,"./base/errors":7}],71:[function(require,module,exports){ +},{"./base/Exchange":6,"./base/errors":8}],72:[function(require,module,exports){ 'use strict'; // --------------------------------------------------------------------------- @@ -53331,7 +55440,7 @@ module.exports = class coinone extends Exchange { async fetchOrder (id, symbol = undefined, params = {}) { if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' fetchOrder requires a symbol argument'); + throw new ArgumentsRequired (this.id + ' fetchOrder() requires a symbol argument'); } await this.loadMarkets (); const market = this.market (symbol); @@ -53476,6 +55585,7 @@ module.exports = class coinone extends Exchange { 'symbol': symbol, 'type': 'limit', 'timeInForce': undefined, + 'postOnly': undefined, 'side': side, 'price': price, 'stopPrice': undefined, @@ -53525,7 +55635,7 @@ module.exports = class coinone extends Exchange { async fetchMyTrades (symbol = undefined, since = undefined, limit = undefined, params = {}) { if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' fetchMyTrades requires a symbol argument'); + throw new ArgumentsRequired (this.id + ' fetchMyTrades() requires a symbol argument'); } await this.loadMarkets (); const market = this.market (symbol); @@ -53560,14 +55670,14 @@ module.exports = class coinone extends Exchange { async cancelOrder (id, symbol = undefined, params = {}) { if (symbol === undefined) { // eslint-disable-next-line quotes - throw new ArgumentsRequired (this.id + " cancelOrder requires a symbol argument. To cancel the order, pass a symbol argument and {'price': 12345, 'qty': 1.2345, 'is_ask': 0} in the params argument of cancelOrder."); + throw new ArgumentsRequired (this.id + " cancelOrder() requires a symbol argument. To cancel the order, pass a symbol argument and {'price': 12345, 'qty': 1.2345, 'is_ask': 0} in the params argument of cancelOrder."); } const price = this.safeFloat (params, 'price'); const qty = this.safeFloat (params, 'qty'); const isAsk = this.safeInteger (params, 'is_ask'); if ((price === undefined) || (qty === undefined) || (isAsk === undefined)) { // eslint-disable-next-line quotes - throw new ArgumentsRequired (this.id + " cancelOrder requires {'price': 12345, 'qty': 1.2345, 'is_ask': 0} in the params argument."); + throw new ArgumentsRequired (this.id + " cancelOrder() requires {'price': 12345, 'qty': 1.2345, 'is_ask': 0} in the params argument."); } await this.loadMarkets (); const request = { @@ -53638,13 +55748,13 @@ module.exports = class coinone extends Exchange { } }; -},{"./base/Exchange":5,"./base/errors":7}],72:[function(require,module,exports){ +},{"./base/Exchange":6,"./base/errors":8}],73:[function(require,module,exports){ 'use strict'; // --------------------------------------------------------------------------- const Exchange = require ('./base/Exchange'); -const { ExchangeError, AuthenticationError, NotSupported } = require ('./base/errors'); +const { ExchangeError, ArgumentsRequired, AuthenticationError } = require ('./base/errors'); // --------------------------------------------------------------------------- @@ -53711,27 +55821,72 @@ module.exports = class coinspot extends Exchange { }, 'markets': { 'BTC/AUD': { 'id': 'btc', 'symbol': 'BTC/AUD', 'base': 'BTC', 'quote': 'AUD', 'baseId': 'btc', 'quoteId': 'aud' }, + 'ETH/AUD': { 'id': 'eth', 'symbol': 'ETH/AUD', 'base': 'ETH', 'quote': 'AUD', 'baseId': 'eth', 'quoteId': 'aud' }, + 'XRP/AUD': { 'id': 'xrp', 'symbol': 'XRP/AUD', 'base': 'XRP', 'quote': 'AUD', 'baseId': 'xrp', 'quoteId': 'aud' }, 'LTC/AUD': { 'id': 'ltc', 'symbol': 'LTC/AUD', 'base': 'LTC', 'quote': 'AUD', 'baseId': 'ltc', 'quoteId': 'aud' }, 'DOGE/AUD': { 'id': 'doge', 'symbol': 'DOGE/AUD', 'base': 'DOGE', 'quote': 'AUD', 'baseId': 'doge', 'quoteId': 'aud' }, + 'RFOX/AUD': { 'id': 'rfox', 'symbol': 'RFOX/AUD', 'base': 'RFOX', 'quote': 'AUD', 'baseId': 'rfox', 'quoteId': 'aud' }, + 'POWR/AUD': { 'id': 'powr', 'symbol': 'POWR/AUD', 'base': 'POWR', 'quote': 'AUD', 'baseId': 'powr', 'quoteId': 'aud' }, + 'NEO/AUD': { 'id': 'neo', 'symbol': 'NEO/AUD', 'base': 'NEO', 'quote': 'AUD', 'baseId': 'neo', 'quoteId': 'aud' }, + 'TRX/AUD': { 'id': 'trx', 'symbol': 'TRX/AUD', 'base': 'TRX', 'quote': 'AUD', 'baseId': 'trx', 'quoteId': 'aud' }, + 'EOS/AUD': { 'id': 'eos', 'symbol': 'EOS/AUD', 'base': 'EOS', 'quote': 'AUD', 'baseId': 'eos', 'quoteId': 'aud' }, + 'XLM/AUD': { 'id': 'xlm', 'symbol': 'XLM/AUD', 'base': 'XLM', 'quote': 'AUD', 'baseId': 'xlm', 'quoteId': 'aud' }, + 'RHOC/AUD': { 'id': 'rhoc', 'symbol': 'RHOC/AUD', 'base': 'RHOC', 'quote': 'AUD', 'baseId': 'rhoc', 'quoteId': 'aud' }, + 'GAS/AUD': { 'id': 'gas', 'symbol': 'GAS/AUD', 'base': 'GAS', 'quote': 'AUD', 'baseId': 'gas', 'quoteId': 'aud' }, }, 'commonCurrencies': { 'DRK': 'DASH', }, + 'options': { + 'fetchBalance': 'private_post_my_balances', + }, }); } async fetchBalance (params = {}) { await this.loadMarkets (); - const response = await this.privatePostMyBalances (params); + const method = this.safeString (this.options, 'fetchBalance', 'private_post_my_balances'); + const response = await this[method] (params); + // + // read-write api keys + // + // ... + // + // read-only api keys + // + // { + // "status":"ok", + // "balances":[ + // { + // "LTC":{"balance":0.1,"audbalance":16.59,"rate":165.95} + // } + // ] + // } + // const result = { 'info': response }; - const balances = this.safeValue (response, 'balance', {}); - const currencyIds = Object.keys (balances); - for (let i = 0; i < currencyIds.length; i++) { - const currencyId = currencyIds[i]; - const code = this.safeCurrencyCode (currencyId); - const account = this.account (); - account['total'] = this.safeFloat (balances, currencyId); - result[code] = account; + const balances = this.safeValue2 (response, 'balance', 'balances'); + if (Array.isArray (balances)) { + for (let i = 0; i < balances.length; i++) { + const currencies = balances[i]; + const currencyIds = Object.keys (currencies); + for (let j = 0; j < currencyIds.length; j++) { + const currencyId = currencyIds[j]; + const balance = currencies[currencyId]; + const code = this.safeCurrencyCode (currencyId); + const account = this.account (); + account['total'] = this.safeFloat (balance, 'balance'); + result[code] = account; + } + } + } else { + const currencyIds = Object.keys (balances); + for (let i = 0; i < currencyIds.length; i++) { + const currencyId = currencyIds[i]; + const code = this.safeCurrencyCode (currencyId); + const account = this.account (); + account['total'] = this.safeFloat (balances, currencyId); + result[code] = account; + } } return this.parseBalance (result); } @@ -53851,9 +56006,16 @@ module.exports = class coinspot extends Exchange { } async cancelOrder (id, symbol = undefined, params = {}) { - throw new NotSupported (this.id + ' cancelOrder () is not fully implemented yet'); - // let method = 'privatePostMyBuy'; - // return await this[method] ({ 'id': id }); + const side = this.safeString (params, 'side'); + if (side !== 'buy' && side !== 'sell') { + throw new ArgumentsRequired (this.id + ' cancelOrder() requires a side parameter, "buy" or "sell"'); + } + params = this.omit (params, 'side'); + const method = 'privatePostMy' + this.capitalize (side) + 'Cancel'; + const request = { + 'id': id, + }; + return await this[method] (this.extend (request, params)); } sign (path, api = 'public', method = 'GET', params = {}, headers = undefined, body = undefined) { @@ -53875,7 +56037,7 @@ module.exports = class coinspot extends Exchange { } }; -},{"./base/Exchange":5,"./base/errors":7}],73:[function(require,module,exports){ +},{"./base/Exchange":6,"./base/errors":8}],74:[function(require,module,exports){ 'use strict'; // --------------------------------------------------------------------------- @@ -54011,6 +56173,7 @@ module.exports = class crex24 extends Exchange { 'GHOST': 'GHOSTPRISM', 'IQ': 'IQ.Cash', 'PUT': 'PutinCoin', + 'SBTC': 'SBTCT', // SiamBitcoin 'UNI': 'Universe', 'YOYO': 'YOYOW', }, @@ -54036,6 +56199,7 @@ module.exports = class crex24 extends Exchange { "Parameter 'instrument' contains invalid value.": BadSymbol, }, 'broad': { + 'try again later': ExchangeNotAvailable, // {"errorDescription":"Failed to process the request. Please, try again later."} 'API Key': AuthenticationError, // "API Key '9edc48de-d5b0-4248-8e7e-f59ffcd1c7f1' doesn't exist." 'Insufficient funds': InsufficientFunds, // "Insufficient funds: new order requires 10 ETH which is more than the available balance." 'has been delisted.': BadSymbol, // {"errorDescription":"Instrument '$PAC-BTC' has been delisted."} @@ -54635,14 +56799,14 @@ module.exports = class crex24 extends Exchange { } if (priceIsRequired) { if (price === undefined) { - throw new InvalidOrder (this.id + ' createOrder method requires a price argument for a ' + type + ' order'); + throw new InvalidOrder (this.id + ' createOrder() requires a price argument for a ' + type + ' order'); } request['price'] = this.priceToPrecision (symbol, price); } if (stopPriceIsRequired) { const stopPrice = this.safeFloat (params, 'stopPrice'); if (stopPrice === undefined) { - throw new InvalidOrder (this.id + ' createOrder method requires a stopPrice extra param for a ' + type + ' order'); + throw new InvalidOrder (this.id + ' createOrder() requires a stopPrice extra param for a ' + type + ' order'); } else { request['stopPrice'] = this.priceToPrecision (symbol, stopPrice); } @@ -55185,7 +57349,7 @@ module.exports = class crex24 extends Exchange { } }; -},{"./base/Exchange":5,"./base/errors":7}],74:[function(require,module,exports){ +},{"./base/Exchange":6,"./base/errors":8}],75:[function(require,module,exports){ 'use strict'; // --------------------------------------------------------------------------- @@ -56104,7 +58268,7 @@ module.exports = class currencycom extends Exchange { if (market['margin']) { accountId = this.safeInteger (params, 'accountId'); if (accountId === undefined) { - throw new ArgumentsRequired (this.id + ' createOrder requires an accountId parameter for ' + market['type'] + ' market ' + symbol); + throw new ArgumentsRequired (this.id + ' createOrder() requires an accountId parameter for ' + market['type'] + ' market ' + symbol); } } const uppercaseType = type.toUpperCase (); @@ -56165,7 +58329,7 @@ module.exports = class currencycom extends Exchange { const symbols = this.symbols; const numSymbols = symbols.length; const fetchOpenOrdersRateLimit = parseInt (numSymbols / 2); - throw new ExchangeError (this.id + ' fetchOpenOrders WARNING: fetching open orders without specifying a symbol is rate-limited to one call per ' + fetchOpenOrdersRateLimit.toString () + ' seconds. Do not call this method frequently to avoid ban. Set ' + this.id + '.options["warnOnFetchOpenOrdersWithoutSymbol"] = false to suppress this warning message.'); + throw new ExchangeError (this.id + ' fetchOpenOrders() WARNING: fetching open orders without specifying a symbol is rate-limited to one call per ' + fetchOpenOrdersRateLimit.toString () + ' seconds. Do not call this method frequently to avoid ban. Set ' + this.id + '.options["warnOnFetchOpenOrdersWithoutSymbol"] = false to suppress this warning message.'); } const response = await this.privateGetOpenOrders (this.extend (request, params)); return this.parseOrders (response, market, since, limit); @@ -56173,7 +58337,7 @@ module.exports = class currencycom extends Exchange { async cancelOrder (id, symbol = undefined, params = {}) { if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' cancelOrder requires a symbol argument'); + throw new ArgumentsRequired (this.id + ' cancelOrder() requires a symbol argument'); } await this.loadMarkets (); const market = this.market (symbol); @@ -56208,7 +58372,7 @@ module.exports = class currencycom extends Exchange { async fetchMyTrades (symbol = undefined, since = undefined, limit = undefined, params = {}) { if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' fetchMyTrades requires a symbol argument'); + throw new ArgumentsRequired (this.id + ' fetchMyTrades() requires a symbol argument'); } await this.loadMarkets (); const market = this.market (symbol); @@ -56306,7 +58470,1492 @@ module.exports = class currencycom extends Exchange { } }; -},{"./base/Exchange":5,"./base/errors":7,"./base/functions/number":13}],75:[function(require,module,exports){ +},{"./base/Exchange":6,"./base/errors":8,"./base/functions/number":14}],76:[function(require,module,exports){ +'use strict'; + +// --------------------------------------------------------------------------- + +const Exchange = require ('./base/Exchange'); +const { ExchangeError, InsufficientFunds, BadRequest, BadSymbol, InvalidOrder, AuthenticationError, ArgumentsRequired, OrderNotFound, ExchangeNotAvailable } = require ('./base/errors'); +const { TICK_SIZE } = require ('./base/functions/number'); + +// --------------------------------------------------------------------------- + +module.exports = class delta extends Exchange { + describe () { + return this.deepExtend (super.describe (), { + 'id': 'delta', + 'name': 'Delta Exchange', + 'countries': [ 'VC' ], // Saint Vincent and the Grenadines + 'rateLimit': 300, + 'version': 'v2', + // new metainfo interface + 'has': { + 'cancelAllOrders': true, + 'cancelOrder': true, + 'createOrder': true, + 'editOrder': true, + 'fetchBalance': true, + 'fetchClosedOrders': true, + 'fetchDepositAddress': true, + 'fetchCurrencies': true, + 'fetchLedger': true, + 'fetchMarkets': true, + 'fetchMyTrades': true, + 'fetchOHLCV': true, + 'fetchOpenOrders': true, + 'fetchOrderBook': true, + 'fetchStatus': true, + 'fetchTicker': true, + 'fetchTickers': true, + 'fetchTime': true, + 'fetchTrades': true, + }, + 'timeframes': { + '1m': '1m', + '3m': '3m', + '5m': '5m', + '15m': '15m', + '30m': '30m', + '1h': '1h', + '2h': '2h', + '4h': '4h', + '6h': '6h', + '1d': '1d', + '7d': '7d', + '1w': '1w', + '2w': '2w', + '1M': '30d', + }, + 'urls': { + 'logo': 'https://user-images.githubusercontent.com/1294454/99450025-3be60a00-2931-11eb-9302-f4fd8d8589aa.jpg', + 'test': { + 'public': 'https://testnet-api.delta.exchange', + 'private': 'https://testnet-api.delta.exchange', + }, + 'api': { + 'public': 'https://api.delta.exchange', + 'private': 'https://api.delta.exchange', + }, + 'www': 'https://www.delta.exchange', + 'doc': [ + 'https://docs.delta.exchange', + ], + 'fees': 'https://www.delta.exchange/fees', + 'referral': 'https://www.delta.exchange/app/signup/?code=IULYNB', + }, + 'api': { + 'public': { + 'get': [ + 'assets', + 'settings', + 'indices', + 'products', + 'tickers', + 'tickers/{symbol}', + 'l2orderbook/{symbol}', + 'trades/{symbol}', + 'history/candles', + 'history/sparklines', + ], + }, + 'private': { + 'get': [ + 'orders', + 'orders/leverage', + 'positions', + 'positions/margined', + 'orders/history', + 'fills', + 'fills/history/download/csv', + 'wallet/balances', + 'wallet/transactions', + 'wallet/transactions/download', + 'deposits/address', + ], + 'post': [ + 'orders', + 'orders/batch', + 'orders/leverage', + 'positions/change_margin', + ], + 'put': [ + 'orders', + 'orders/batch', + ], + 'delete': [ + 'orders', + 'orders/all', + 'orders/batch', + ], + }, + }, + 'fees': { + 'trading': { + 'tierBased': true, + 'percentage': true, + 'taker': 0.15 / 100, + 'maker': 0.10 / 100, + 'tiers': { + 'taker': [ + [0, 0.15 / 100], + [100, 0.13 / 100], + [250, 0.13 / 100], + [1000, 0.1 / 100], + [5000, 0.09 / 100], + [10000, 0.075 / 100], + [20000, 0.065 / 100], + ], + 'maker': [ + [0, 0.1 / 100], + [100, 0.1 / 100], + [250, 0.09 / 100], + [1000, 0.075 / 100], + [5000, 0.06 / 100], + [10000, 0.05 / 100], + [20000, 0.05 / 100], + ], + }, + }, + }, + 'precisionMode': TICK_SIZE, + 'requiredCredentials': { + 'apiKey': true, + 'secret': false, + }, + 'exceptions': { + 'exact': { + // Margin required to place order with selected leverage and quantity is insufficient. + 'insufficient_margin': InsufficientFunds, // {"error":{"code":"insufficient_margin","context":{"available_balance":"0.000000000000000000","required_additional_balance":"1.618626000000000000000000000"}},"success":false} + 'order_size_exceed_available': InvalidOrder, // The order book doesn't have sufficient liquidity, hence the order couldnt be filled, for example, ioc orders + 'risk_limits_breached': BadRequest, // orders couldn't be placed as it will breach allowed risk limits. + 'invalid_contract': BadSymbol, // The contract/product is either doesn't exist or has already expired. + 'immediate_liquidation': InvalidOrder, // Order will cause immediate liquidation. + 'out_of_bankruptcy': InvalidOrder, // Order prices are out of position bankruptcy limits. + 'self_matching_disrupted_post_only': InvalidOrder, // Self matching is not allowed during auction. + 'immediate_execution_post_only': InvalidOrder, // orders couldn't be placed as it includes post only orders which will be immediately executed + 'bad_schema': BadRequest, // {"error":{"code":"bad_schema","context":{"schema_errors":[{"code":"validation_error","message":"id is required","param":""}]}},"success":false} + 'invalid_api_key': AuthenticationError, // {"success":false,"error":{"code":"invalid_api_key"}} + 'invalid_signature': AuthenticationError, // {"success":false,"error":{"code":"invalid_signature"}} + 'open_order_not_found': OrderNotFound, // {"error":{"code":"open_order_not_found"},"success":false} + 'unavailable': ExchangeNotAvailable, // {"error":{"code":"unavailable"},"success":false} + }, + 'broad': { + }, + }, + }); + } + + async fetchTime (params = {}) { + const response = await this.publicGetSettings (params); + // + // { + // "result":{ + // "server_time":1605472733766141, + // "deto_referral_mining_daily_reward":"25000", + // "deto_total_reward_pool":"100000000", + // "deto_trade_mining_daily_reward":"75000", + // "kyc_deposit_limit":"20", + // "kyc_withdrawal_limit":"2", + // "under_maintenance":"false" + // }, + // "success":true + // } + // + const result = this.safeValue (response, 'result', {}); + return this.safeIntegerProduct (result, 'server_time', 0.001); + } + + async fetchStatus (params = {}) { + const response = await this.publicGetSettings (params); + const result = this.safeValue (response, 'result', {}); + const underMaintenance = this.safeValue (result, 'under_maintenance'); + const status = (underMaintenance === 'true') ? 'maintenance' : 'ok'; + const updated = this.safeIntegerProduct (result, 'server_time', 0.001); + this.status = this.extend (this.status, { + 'status': status, + 'updated': updated, + }); + return this.status; + } + + async fetchCurrencies (params = {}) { + const response = await this.publicGetAssets (params); + // + // { + // "result":[ + // { + // "base_withdrawal_fee":"0.0005", + // "deposit_status":"enabled", + // "id":2, + // "interest_credit":true, + // "interest_slabs":[ + // {"limit":"0.1","rate":"0"}, + // {"limit":"1","rate":"0.05"}, + // {"limit":"5","rate":"0.075"}, + // {"limit":"10","rate":"0.1"}, + // {"limit":"9999999999999999","rate":"0"} + // ], + // "kyc_deposit_limit":"10", + // "kyc_withdrawal_limit":"2", + // "min_withdrawal_amount":"0.001", + // "minimum_precision":4, + // "name":"Bitcoin", + // "precision":8, + // "sort_priority":1, + // "symbol":"BTC", + // "variable_withdrawal_fee":"0", + // "withdrawal_status":"enabled" + // }, + // ], + // "success":true + // } + // + const currencies = this.safeValue (response, 'result', []); + const result = {}; + for (let i = 0; i < currencies.length; i++) { + const currency = currencies[i]; + const id = this.safeString (currency, 'symbol'); + const numericId = this.safeInteger (currency, 'id'); + const code = this.safeCurrencyCode (id); + const depositStatus = this.safeString (currency, 'deposit_status'); + const withdrawalStatus = this.safeString (currency, 'withdrawal_status'); + const depositsEnabled = (depositStatus === 'enabled'); + const withdrawalsEnabled = (withdrawalStatus === 'enabled'); + const active = depositsEnabled && withdrawalsEnabled; + const precision = this.safeInteger (currency, 'precision'); + result[code] = { + 'id': id, + 'numericId': numericId, + 'code': code, + 'name': this.safeString (currency, 'name'), + 'info': currency, // the original payload + 'active': active, + 'fee': this.safeFloat (currency, 'base_withdrawal_fee'), + 'precision': 1 / Math.pow (10, precision), + 'limits': { + 'amount': { 'min': undefined, 'max': undefined }, + 'price': { 'min': undefined, 'max': undefined }, + 'cost': { 'min': undefined, 'max': undefined }, + 'withdraw': { + 'min': this.safeFloat (currency, 'min_withdrawal_amount'), + 'max': undefined, + }, + }, + }; + } + return result; + } + + async loadMarkets (reload = false, params = {}) { + const markets = await super.loadMarkets (reload, params); + const currenciesByNumericId = this.safeValue (this.options, 'currenciesByNumericId'); + if ((currenciesByNumericId === undefined) || reload) { + this.options['currenciesByNumericId'] = this.indexBy (this.currencies, 'numericId'); + } + const marketsByNumericId = this.safeValue (this.options, 'marketsByNumericId'); + if ((marketsByNumericId === undefined) || reload) { + this.options['marketsByNumericId'] = this.indexBy (this.markets, 'numericId'); + } + return markets; + } + + async fetchMarkets (params = {}) { + const response = await this.publicGetProducts (params); + // + // { + // "meta":{ + // "after":null, + // "before":null, + // "limit":100, + // "total_count":81 + // }, + // "result":[ + // { + // "annualized_funding":"5.475000000000000000", + // "is_quanto":false, + // "ui_config":{ + // "default_trading_view_candle":"15", + // "leverage_slider_values":[1,3,5,10,25,50], + // "price_clubbing_values":[0.001,0.005,0.05,0.1,0.5,1,5], + // "show_bracket_orders":false, + // "sort_priority":29, + // "tags":[] + // }, + // "basis_factor_max_limit":"0.15", + // "symbol":"P-LINK-D-151120", + // "id":1584, + // "default_leverage":"5.000000000000000000", + // "maker_commission_rate":"0.0005", + // "contract_unit_currency":"LINK", + // "strike_price":"12.507948", + // "settling_asset":{ + // // asset structure + // }, + // "auction_start_time":null, + // "auction_finish_time":null, + // "settlement_time":"2020-11-15T12:00:00Z", + // "launch_time":"2020-11-14T11:55:05Z", + // "spot_index":{ + // // index structure + // }, + // "trading_status":"operational", + // "tick_size":"0.001", + // "position_size_limit":100000, + // "notional_type":"vanilla", // vanilla, inverse + // "price_band":"0.4", + // "barrier_price":null, + // "description":"Daily LINK PUT options quoted in USDT and settled in USDT", + // "insurance_fund_margin_contribution":"1", + // "quoting_asset":{ + // // asset structure + // }, + // "liquidation_penalty_factor":"0.2", + // "product_specs":{"max_volatility":3,"min_volatility":0.3,"spot_price_band":"0.40"}, + // "initial_margin_scaling_factor":"0.0001", + // "underlying_asset":{ + // // asset structure + // }, + // "state":"live", + // "contract_value":"1", + // "initial_margin":"2", + // "impact_size":5000, + // "settlement_price":null, + // "contract_type":"put_options", // put_options, call_options, move_options, perpetual_futures, interest_rate_swaps, futures, spreads + // "taker_commission_rate":"0.0005", + // "maintenance_margin":"1", + // "short_description":"LINK Daily PUT Options", + // "maintenance_margin_scaling_factor":"0.00005", + // "funding_method":"mark_price", + // "max_leverage_notional":"20000" + // }, + // ], + // "success":true + // } + // + const markets = this.safeValue (response, 'result', []); + const result = []; + for (let i = 0; i < markets.length; i++) { + const market = markets[i]; + let type = this.safeString (market, 'contract_type'); + // const settlingAsset = this.safeValue (market, 'settling_asset', {}); + const quotingAsset = this.safeValue (market, 'quoting_asset', {}); + const underlyingAsset = this.safeValue (market, 'underlying_asset', {}); + const baseId = this.safeString (underlyingAsset, 'symbol'); + const quoteId = this.safeString (quotingAsset, 'symbol'); + const id = this.safeString (market, 'symbol'); + const numericId = this.safeInteger (market, 'id'); + const base = this.safeCurrencyCode (baseId); + const quote = this.safeCurrencyCode (quoteId); + let symbol = id; + let swap = false; + let future = false; + let option = false; + if (type === 'perpetual_futures') { + type = 'swap'; + swap = true; + future = false; + option = false; + if (id.indexOf ('_') < 0) { + symbol = base + '/' + quote; + } + } else if ((type === 'call_options') || (type === 'put_options') || (type === 'move_options')) { + type = 'option'; + swap = false; + option = true; + future = false; + } else if (type === 'futures') { + type = 'future'; + swap = false; + option = false; + future = true; + } + const precision = { + 'amount': 1.0, // number of contracts + 'price': this.safeFloat (market, 'tick_size'), + }; + const limits = { + 'amount': { + 'min': 1.0, + 'max': this.safeFloat (market, 'position_size_limit'), + }, + 'price': { + 'min': precision['price'], + 'max': undefined, + }, + 'cost': { + 'min': this.safeFloat (market, 'min_size'), + 'max': undefined, + }, + }; + const state = this.safeString (market, 'state'); + const active = (state === 'live'); + const maker = this.safeFloat (market, 'maker_commission_rate'); + const taker = this.safeFloat (market, 'taker_commission_rate'); + result.push ({ + 'id': id, + 'numericId': numericId, + 'symbol': symbol, + 'base': base, + 'quote': quote, + 'baseId': baseId, + 'quoteId': quoteId, + 'type': type, + 'option': option, + 'swap': swap, + 'future': future, + 'maker': maker, + 'taker': taker, + 'precision': precision, + 'limits': limits, + 'info': market, + 'active': active, + }); + } + return result; + } + + parseTicker (ticker, market = undefined) { + // + // fetchTicker, fetchTickers + // + // { + // "close":15837.5, + // "high":16354, + // "low":15751.5, + // "mark_price":"15820.100867", + // "open":16140.5, + // "product_id":139, + // "size":640552, + // "spot_price":"15827.050000000001", + // "symbol":"BTCUSDT", + // "timestamp":1605373550208262, + // "turnover":10298630.3735, + // "turnover_symbol":"USDT", + // "turnover_usd":10298630.3735, + // "volume":640.5520000000001 + // } + // + const timestamp = this.safeIntegerProduct (ticker, 'timestamp', 0.001); + const marketId = this.safeString (ticker, 'symbol'); + const symbol = this.safeSymbol (marketId, market); + const last = this.safeFloat (ticker, 'close'); + const open = this.safeFloat (ticker, 'open'); + let change = undefined; + let average = undefined; + let percentage = undefined; + if ((open !== undefined) && (last !== undefined)) { + change = last - open; + average = this.sum (last, open) / 2; + if (open !== 0.0) { + percentage = (change / open) * 100; + } + } + const baseVolume = this.safeFloat (ticker, 'volume'); + const quoteVolume = this.safeFloat (ticker, 'turnover'); + const vwap = this.vwap (baseVolume, quoteVolume); + return { + 'symbol': symbol, + 'timestamp': timestamp, + 'datetime': this.iso8601 (timestamp), + 'high': this.safeFloat (ticker, 'high'), + 'low': this.safeFloat (ticker, 'low'), + 'bid': undefined, + 'bidVolume': undefined, + 'ask': undefined, + 'askVolume': undefined, + 'vwap': vwap, + 'open': open, + 'close': last, + 'last': last, + 'previousClose': undefined, + 'change': change, + 'percentage': percentage, + 'average': average, + 'baseVolume': baseVolume, + 'quoteVolume': quoteVolume, + 'info': ticker, + }; + } + + async fetchTicker (symbol, params = {}) { + await this.loadMarkets (); + const market = this.market (symbol); + const request = { + 'symbol': market['id'], + }; + const response = await this.publicGetTickersSymbol (this.extend (request, params)); + // + // { + // "result":{ + // "close":15837.5, + // "high":16354, + // "low":15751.5, + // "mark_price":"15820.100867", + // "open":16140.5, + // "product_id":139, + // "size":640552, + // "spot_price":"15827.050000000001", + // "symbol":"BTCUSDT", + // "timestamp":1605373550208262, + // "turnover":10298630.3735, + // "turnover_symbol":"USDT", + // "turnover_usd":10298630.3735, + // "volume":640.5520000000001 + // }, + // "success":true + // } + // + const result = this.safeValue (response, 'result', {}); + return this.parseTicker (result, market); + } + + async fetchTickers (symbols = undefined, params = {}) { + await this.loadMarkets (); + const response = await this.publicGetTickers (params); + // + // { + // "result":[ + // { + // "close":0.003966, + // "high":0.004032, + // "low":0.003606, + // "mark_price":"0.00396328", + // "open":0.003996, + // "product_id":1327, + // "size":6242, + // "spot_price":"0.0039555", + // "symbol":"AAVEBTC", + // "timestamp":1605374143864107, + // "turnover":23.997904999999996, + // "turnover_symbol":"BTC", + // "turnover_usd":387957.4544782897, + // "volume":6242 + // }, + // ], + // "success":true + // } + // + const tickers = this.safeValue (response, 'result', []); + const result = {}; + for (let i = 0; i < tickers.length; i++) { + const ticker = this.parseTicker (tickers[i]); + const symbol = ticker['symbol']; + result[symbol] = ticker; + } + return this.filterByArray (result, 'symbol', symbols); + } + + async fetchOrderBook (symbol, limit = undefined, params = {}) { + await this.loadMarkets (); + const request = { + 'symbol': this.marketId (symbol), + }; + if (limit !== undefined) { + request['depth'] = limit; + } + const response = await this.publicGetL2orderbookSymbol (this.extend (request, params)); + // + // { + // "result":{ + // "buy":[ + // {"price":"15814.0","size":912}, + // {"price":"15813.5","size":1279}, + // {"price":"15813.0","size":1634}, + // ], + // "sell":[ + // {"price":"15814.5","size":625}, + // {"price":"15815.0","size":982}, + // {"price":"15815.5","size":1328}, + // ], + // "symbol":"BTCUSDT" + // }, + // "success":true + // } + // + const result = this.safeValue (response, 'result', {}); + return this.parseOrderBook (result, undefined, 'buy', 'sell', 'price', 'size'); + } + + parseTrade (trade, market = undefined) { + // + // public fetchTrades + // + // { + // "buyer_role":"maker", + // "price":"15896.5", + // "seller_role":"taker", + // "size":241, + // "symbol":"BTCUSDT", + // "timestamp":1605376684714595 + // } + // + // private fetchMyTrades + // + // { + // "commission":"0.008335000000000000", + // "created_at":"2020-11-16T19:07:19Z", + // "fill_type":"normal", + // "id":"e7ff05c233a74245b72381f8dd91d1ce", + // "meta_data":{ + // "effective_commission_rate":"0.0005", + // "order_price":"16249", + // "order_size":1, + // "order_type":"market_order", + // "order_unfilled_size":0, + // "trading_fee_credits_used":"0" + // }, + // "order_id":"152999629", + // "price":"16669", + // "product":{ + // "contract_type":"perpetual_futures", + // "contract_unit_currency":"BTC", + // "contract_value":"0.001", + // "id":139, + // "notional_type":"vanilla", + // "quoting_asset":{"minimum_precision":2,"precision":6,"symbol":"USDT"}, + // "settling_asset":{"minimum_precision":2,"precision":6,"symbol":"USDT"}, + // "symbol":"BTCUSDT", + // "tick_size":"0.5", + // "underlying_asset":{"minimum_precision":4,"precision":8,"symbol":"BTC"} + // }, + // "product_id":139, + // "role":"taker", + // "side":"sell", + // "size":1 + // } + // + const id = this.safeString (trade, 'id'); + const orderId = this.safeString (trade, 'order_id'); + let timestamp = this.parse8601 (this.safeString (trade, 'created_at')); + timestamp = this.safeIntegerProduct (trade, 'timestamp', 0.001, timestamp); + const price = this.safeFloat (trade, 'price'); + const amount = this.safeFloat (trade, 'size'); + let cost = undefined; + if ((amount !== undefined) && (price !== undefined)) { + cost = amount * price; + } + const product = this.safeValue (trade, 'product', {}); + const marketId = this.safeString (product, 'symbol'); + const symbol = this.safeSymbol (marketId, market); + const sellerRole = this.safeString (trade, 'seller_role'); + let side = this.safeString (trade, 'side'); + if (side === undefined) { + if (sellerRole === 'taker') { + side = 'sell'; + } else if (sellerRole === 'maker') { + side = 'buy'; + } + } + const takerOrMaker = this.safeString (trade, 'role'); + const metaData = this.safeValue (trade, 'meta_data', {}); + let type = this.safeString (metaData, 'order_type'); + if (type !== undefined) { + type = type.replace ('_order', ''); + } + const feeCost = this.safeFloat (trade, 'commission'); + let fee = undefined; + if (feeCost !== undefined) { + const settlingAsset = this.safeValue (product, 'settling_asset', {}); + const feeCurrencyId = this.safeString (settlingAsset, 'symbol'); + const feeCurrencyCode = this.safeCurrencyCode (feeCurrencyId); + fee = { + 'cost': feeCost, + 'currency': feeCurrencyCode, + }; + } + return { + 'id': id, + 'order': orderId, + 'timestamp': timestamp, + 'datetime': this.iso8601 (timestamp), + 'symbol': symbol, + 'type': type, + 'side': side, + 'price': price, + 'amount': amount, + 'cost': cost, + 'takerOrMaker': takerOrMaker, + 'fee': fee, + 'info': trade, + }; + } + + async fetchTrades (symbol, since = undefined, limit = undefined, params = {}) { + await this.loadMarkets (); + const market = this.market (symbol); + const request = { + 'symbol': market['id'], + }; + const response = await this.publicGetTradesSymbol (this.extend (request, params)); + // + // { + // "result":[ + // { + // "buyer_role":"maker", + // "price":"15896.5", + // "seller_role":"taker", + // "size":241, + // "symbol":"BTCUSDT", + // "timestamp":1605376684714595 + // } + // ], + // "success":true + // } + // + const result = this.safeValue (response, 'result', []); + return this.parseTrades (result, market, since, limit); + } + + parseOHLCV (ohlcv, market = undefined) { + // + // { + // "time":1605393120, + // "open":15989, + // "high":15989, + // "low":15987.5, + // "close":15987.5, + // "volume":565 + // } + // + return [ + this.safeTimestamp (ohlcv, 'time'), + this.safeFloat (ohlcv, 'open'), + this.safeFloat (ohlcv, 'high'), + this.safeFloat (ohlcv, 'low'), + this.safeFloat (ohlcv, 'close'), + this.safeFloat (ohlcv, 'volume'), + ]; + } + + async fetchOHLCV (symbol, timeframe = '1m', since = undefined, limit = undefined, params = {}) { + await this.loadMarkets (); + const market = this.market (symbol); + const request = { + 'symbol': market['id'], + 'resolution': this.timeframes[timeframe], + }; + const duration = this.parseTimeframe (timeframe); + limit = limit ? limit : 2000; // max 2000 + if (since === undefined) { + const end = this.seconds (); + request['end'] = end; + request['start'] = end - limit * duration; + } else { + const start = parseInt (since / 1000); + request['start'] = start; + request['end'] = this.sum (start, limit * duration); + } + const response = await this.publicGetHistoryCandles (this.extend (request, params)); + // + // { + // "success":true, + // "result":[ + // {"time":1605393120,"open":15989,"high":15989,"low":15987.5,"close":15987.5,"volume":565}, + // {"time":1605393180,"open":15966,"high":15966,"low":15959,"close":15959,"volume":24}, + // {"time":1605393300,"open":15973,"high":15973,"low":15973,"close":15973,"volume":1288}, + // ] + // } + // + const result = this.safeValue (response, 'result', []); + return this.parseOHLCVs (result, market, timeframe, since, limit); + } + + async fetchBalance (params = {}) { + await this.loadMarkets (); + const response = await this.privateGetWalletBalances (params); + // + // { + // "result":[ + // { + // "asset_id":1, + // "available_balance":"0", + // "balance":"0", + // "commission":"0", + // "id":154883, + // "interest_credit":"0", + // "order_margin":"0", + // "pending_referral_bonus":"0", + // "pending_trading_fee_credit":"0", + // "position_margin":"0", + // "trading_fee_credit":"0", + // "user_id":22142 + // }, + // ], + // "success":true + // } + // + const balances = this.safeValue (response, 'result', []); + const result = { 'info': response }; + const currenciesByNumericId = this.safeValue (this.options, 'currenciesByNumericId', {}); + for (let i = 0; i < balances.length; i++) { + const balance = balances[i]; + const currencyId = this.safeString (balance, 'asset_id'); + const currency = this.safeValue (currenciesByNumericId, currencyId); + const code = (currency === undefined) ? currencyId : currency['code']; + const account = this.account (); + account['total'] = this.safeFloat (balance, 'balance'); + account['free'] = this.safeFloat (balance, 'available_balance'); + result[code] = account; + } + return this.parseBalance (result); + } + + async fetchPosition (symbol, params = undefined) { + await this.loadMarkets (); + const market = this.market (symbol); + const request = { + 'product_id': market['numericId'], + }; + const response = await this.privateGetPositions (this.extend (request, params)); + // + // { + // "result":{ + // "entry_price":null, + // "size":0, + // "timestamp":1605454074268079 + // }, + // "success":true + // } + // + const result = this.safeValue (response, 'result', {}); + return result; + } + + async fetchPositions (symbols = undefined, since = undefined, limit = undefined, params = {}) { + await this.loadMarkets (); + const response = await this.privateGetPositionsMargined (params); + // + // { + // "success": true, + // "result": [ + // { + // "user_id": 0, + // "size": 0, + // "entry_price": "string", + // "margin": "string", + // "liquidation_price": "string", + // "bankruptcy_price": "string", + // "adl_level": 0, + // "product_id": 0 + // } + // ] + // } + // + const result = this.safeValue (response, 'result', []); + return result; + } + + parseOrderStatus (status) { + const statuses = { + 'open': 'open', + 'pending': 'open', + 'closed': 'closed', + 'cancelled': 'canceled', + }; + return this.safeString (statuses, status, status); + } + + parseOrder (order, market = undefined) { + // + // createOrder, cancelOrder, editOrder, fetchOpenOrders, fetchClosedOrders + // + // { + // "average_fill_price":null, + // "bracket_order":null, + // "bracket_stop_loss_limit_price":null, + // "bracket_stop_loss_price":null, + // "bracket_take_profit_limit_price":null, + // "bracket_take_profit_price":null, + // "bracket_trail_amount":null, + // "cancellation_reason":null, + // "client_order_id":null, + // "close_on_trigger":"false", + // "commission":"0", + // "created_at":"2020-11-16T02:38:26Z", + // "id":152870626, + // "limit_price":"10000", + // "meta_data":{"source":"api"}, + // "order_type":"limit_order", + // "paid_commission":"0", + // "product_id":139, + // "reduce_only":false, + // "side":"buy", + // "size":0, + // "state":"open", + // "stop_order_type":null, + // "stop_price":null, + // "stop_trigger_method":"mark_price", + // "time_in_force":"gtc", + // "trail_amount":null, + // "unfilled_size":0, + // "user_id":22142 + // } + // + const id = this.safeString (order, 'id'); + const clientOrderId = this.safeString (order, 'client_order_id'); + const timestamp = this.parse8601 (this.safeString (order, 'created_at')); + const marketId = this.safeString (order, 'product_id'); + const marketsByNumericId = this.safeValue (this.options, 'marketsByNumericId', {}); + market = this.safeValue (marketsByNumericId, marketId, market); + const symbol = (market === undefined) ? marketId : market['symbol']; + const status = this.parseOrderStatus (this.safeString (order, 'state')); + const side = this.safeString (order, 'side'); + let type = this.safeString (order, 'order_type'); + type = type.replace ('_order', ''); + const price = this.safeFloat (order, 'limit_price'); + const amount = this.safeFloat (order, 'size'); + const remaining = this.safeFloat (order, 'unfilled_size'); + let filled = undefined; + if ((amount !== undefined) && (remaining !== undefined)) { + filled = Math.max (0, amount - remaining); + } + let cost = undefined; + const average = this.safeFloat (order, 'average_fill_price'); + if ((average !== undefined) && filled) { + cost = average * filled; + } + let fee = undefined; + const feeCost = this.safeFloat (order, 'paid_commission'); + if (feeCost !== undefined) { + let feeCurrencyCode = undefined; + if (market !== undefined) { + const settlingAsset = this.safeValue (market['info'], 'settling_asset', {}); + const feeCurrencyId = this.safeString (settlingAsset, 'symbol'); + feeCurrencyCode = this.safeCurrencyCode (feeCurrencyId); + } + fee = { + 'cost': feeCost, + 'currency': feeCurrencyCode, + }; + } + return { + 'info': order, + 'id': id, + 'clientOrderId': clientOrderId, + 'timestamp': timestamp, + 'datetime': this.iso8601 (timestamp), + 'lastTradeTimestamp': undefined, + 'symbol': symbol, + 'type': type, + 'side': side, + 'price': price, + 'amount': amount, + 'cost': cost, + 'average': average, + 'filled': filled, + 'remaining': remaining, + 'status': status, + 'fee': fee, + 'trades': undefined, + }; + } + + async createOrder (symbol, type, side, amount, price = undefined, params = {}) { + await this.loadMarkets (); + const orderType = type + '_order'; + const market = this.market (symbol); + const request = { + 'product_id': market['numericId'], + // 'limit_price': this.priceToPrecision (symbol, price), + 'size': this.amountToPrecision (symbol, amount), + 'side': side, + 'order_type': orderType, + // 'client_order_id': 'string', + // 'time_in_force': 'gtc', // gtc, ioc, fok + // 'post_only': 'false', // 'true', + // 'reduce_only': 'false', // 'true', + }; + if (type === 'limit') { + request['limit_price'] = this.priceToPrecision (symbol, price); + } + const clientOrderId = this.safeString2 (params, 'clientOrderId', 'client_order_id'); + params = this.omit (params, [ 'clientOrderId', 'client_order_id' ]); + if (clientOrderId !== undefined) { + request['client_order_id'] = clientOrderId; + } + const response = await this.privatePostOrders (this.extend (request, params)); + // + // { + // "result":{ + // "average_fill_price":null, + // "bracket_order":null, + // "bracket_stop_loss_limit_price":null, + // "bracket_stop_loss_price":null, + // "bracket_take_profit_limit_price":null, + // "bracket_take_profit_price":null, + // "bracket_trail_amount":null, + // "cancellation_reason":null, + // "client_order_id":null, + // "close_on_trigger":"false", + // "commission":"0", + // "created_at":"2020-11-16T02:38:26Z", + // "id":152870626, + // "limit_price":"10000", + // "meta_data":{"source":"api"}, + // "order_type":"limit_order", + // "paid_commission":"0", + // "product_id":139, + // "reduce_only":false, + // "side":"buy", + // "size":0, + // "state":"open", + // "stop_order_type":null, + // "stop_price":null, + // "stop_trigger_method":"mark_price", + // "time_in_force":"gtc", + // "trail_amount":null, + // "unfilled_size":0, + // "user_id":22142 + // }, + // "success":true + // } + // + const result = this.safeValue (response, 'result', {}); + return this.parseOrder (result, market); + } + + async editOrder (id, symbol, type, side, amount, price = undefined, params = {}) { + await this.loadMarkets (); + const market = this.market (symbol); + const request = { + 'id': parseInt (id), + 'product_id': market['numericId'], + // 'limit_price': this.priceToPrecision (symbol, price), + // 'size': this.amountToPrecision (symbol, amount), + }; + if (amount !== undefined) { + request['size'] = parseInt (this.amountToPrecision (symbol, amount)); + } + if (price !== undefined) { + request['limit_price'] = this.priceToPrecision (symbol, price); + } + const response = await this.privatePutOrders (this.extend (request, params)); + // + // { + // "success": true, + // "result": { + // "id": "ashb1212", + // "product_id": 27, + // "limit_price": "9200", + // "side": "buy", + // "size": 100, + // "unfilled_size": 50, + // "user_id": 1, + // "order_type": "limit_order", + // "state": "open", + // "created_at": "..." + // } + // } + // + const result = this.safeValue (response, 'result'); + return this.parseOrder (result, market); + } + + async cancelOrder (id, symbol = undefined, params = {}) { + if (symbol === undefined) { + throw new ArgumentsRequired (this.id + ' cancelOrder() requires a symbol argument'); + } + await this.loadMarkets (); + const market = this.market (symbol); + const request = { + 'id': parseInt (id), + 'product_id': market['numericId'], + }; + const response = await this.privateDeleteOrders (this.extend (request, params)); + // + // { + // "result":{ + // "average_fill_price":null, + // "bracket_order":null, + // "bracket_stop_loss_limit_price":null, + // "bracket_stop_loss_price":null, + // "bracket_take_profit_limit_price":null, + // "bracket_take_profit_price":null, + // "bracket_trail_amount":null, + // "cancellation_reason":"cancelled_by_user", + // "client_order_id":null, + // "close_on_trigger":"false", + // "commission":"0", + // "created_at":"2020-11-16T02:38:26Z", + // "id":152870626, + // "limit_price":"10000", + // "meta_data":{"source":"api"}, + // "order_type":"limit_order", + // "paid_commission":"0", + // "product_id":139, + // "reduce_only":false, + // "side":"buy", + // "size":0, + // "state":"cancelled", + // "stop_order_type":null, + // "stop_price":null, + // "stop_trigger_method":"mark_price", + // "time_in_force":"gtc", + // "trail_amount":null, + // "unfilled_size":0, + // "user_id":22142 + // }, + // "success":true + // } + // + const result = this.safeValue (response, 'result'); + return this.parseOrder (result, market); + } + + async cancelAllOrders (symbol = undefined, params = {}) { + if (symbol === undefined) { + throw new ArgumentsRequired (this.id + ' cancelAllOrders() requires a symbol argument'); + } + await this.loadMarkets (); + const market = this.market (symbol); + const request = { + 'product_id': market['numericId'], + // 'cancel_limit_orders': 'true', + // 'cancel_stop_orders': 'true', + }; + const response = this.privateDeleteOrdersAll (this.extend (request, params)); + // + // { + // "result":{}, + // "success":true + // } + // + return response; + } + + async fetchOpenOrders (symbol = undefined, since = undefined, limit = undefined, params = {}) { + return await this.fetchOrdersWithMethod ('privateGetOrders', symbol, since, limit, params); + } + + async fetchClosedOrders (symbol = undefined, since = undefined, limit = undefined, params = {}) { + return await this.fetchOrdersWithMethod ('privateGetOrdersHistory', symbol, since, limit, params); + } + + async fetchOrdersWithMethod (method, symbol = undefined, since = undefined, limit = undefined, params = {}) { + await this.loadMarkets (); + const request = { + // 'product_ids': market['id'], // comma-separated + // 'contract_types': types, // comma-separated, futures, perpetual_futures, call_options, put_options, interest_rate_swaps, move_options, spreads + // 'order_types': types, // comma-separated, market, limit, stop_market, stop_limit, all_stop + // 'start_time': since * 1000, + // 'end_time': this.microseconds (), + // 'after': string, // after cursor for pagination + // 'before': string, // before cursor for pagination + // 'page_size': limit, // number of records per page + }; + let market = undefined; + if (symbol !== undefined) { + market = this.market (symbol); + request['product_ids'] = market['numericId']; // accepts a comma-separated list of ids + } + if (since !== undefined) { + request['start_time'] = since.toString () + '000'; + } + if (limit !== undefined) { + request['page_size'] = limit; + } + const response = await this[method] (this.extend (request, params)); + // + // { + // "success": true, + // "result": [ + // { + // "id": "ashb1212", + // "product_id": 27, + // "limit_price": "9200", + // "side": "buy", + // "size": 100, + // "unfilled_size": 50, + // "user_id": 1, + // "order_type": "limit_order", + // "state": "open", + // "created_at": "..." + // } + // ], + // "meta": { + // "after": "string", + // "before": "string" + // } + // } + // + const result = this.safeValue (response, 'result', []); + return this.parseOrders (result, market, since, limit); + } + + async fetchMyTrades (symbol = undefined, since = undefined, limit = undefined, params = {}) { + await this.loadMarkets (); + const request = { + // 'product_ids': market['id'], // comma-separated + // 'contract_types': types, // comma-separated, futures, perpetual_futures, call_options, put_options, interest_rate_swaps, move_options, spreads + // 'start_time': since * 1000, + // 'end_time': this.microseconds (), + // 'after': string, // after cursor for pagination + // 'before': string, // before cursor for pagination + // 'page_size': limit, // number of records per page + }; + let market = undefined; + if (symbol !== undefined) { + market = this.market (symbol); + request['product_ids'] = market['numericId']; // accepts a comma-separated list of ids + } + if (since !== undefined) { + request['start_time'] = since.toString () + '000'; + } + if (limit !== undefined) { + request['page_size'] = limit; + } + const response = await this.privateGetFills (this.extend (request, params)); + // + // { + // "meta":{ + // "after":null, + // "before":null, + // "limit":10, + // "total_count":2 + // }, + // "result":[ + // { + // "commission":"0.008335000000000000", + // "created_at":"2020-11-16T19:07:19Z", + // "fill_type":"normal", + // "id":"e7ff05c233a74245b72381f8dd91d1ce", + // "meta_data":{ + // "effective_commission_rate":"0.0005", + // "order_price":"16249", + // "order_size":1, + // "order_type":"market_order", + // "order_unfilled_size":0, + // "trading_fee_credits_used":"0" + // }, + // "order_id":"152999629", + // "price":"16669", + // "product":{ + // "contract_type":"perpetual_futures", + // "contract_unit_currency":"BTC", + // "contract_value":"0.001", + // "id":139, + // "notional_type":"vanilla", + // "quoting_asset":{"minimum_precision":2,"precision":6,"symbol":"USDT"}, + // "settling_asset":{"minimum_precision":2,"precision":6,"symbol":"USDT"}, + // "symbol":"BTCUSDT", + // "tick_size":"0.5", + // "underlying_asset":{"minimum_precision":4,"precision":8,"symbol":"BTC"} + // }, + // "product_id":139, + // "role":"taker", + // "side":"sell", + // "size":1 + // } + // ], + // "success":true + // } + // + const result = this.safeValue (response, 'result', []); + return this.parseTrades (result, market, since, limit); + } + + async fetchLedger (code = undefined, since = undefined, limit = undefined, params = {}) { + await this.loadMarkets (); + const request = { + // 'asset_id': currency['numericId'], + // 'end_time': this.seconds (), + // 'after': 'string', // after cursor for pagination + // 'before': 'string', // before cursor for pagination + // 'page_size': limit, + }; + let currency = undefined; + if (code !== undefined) { + currency = this.currency (code); + request['asset_id'] = currency['numericId']; + } + if (limit !== undefined) { + request['page_size'] = limit; + } + const response = await this.privateGetWalletTransactions (this.extend (request, params)); + // + // { + // "meta":{"after":null,"before":null,"limit":10,"total_count":1}, + // "result":[ + // { + // "amount":"29.889184", + // "asset_id":5, + // "balance":"29.889184", + // "created_at":"2020-11-15T21:25:01Z", + // "meta_data":{ + // "deposit_id":3884, + // "transaction_id":"0x41a60174849828530abb5008e98fc63c9b598288743ec4ba9620bcce900a3b8d" + // }, + // "transaction_type":"deposit", + // "user_id":22142, + // "uuid":"70bb5679da3c4637884e2dc63efaa846" + // } + // ], + // "success":true + // } + // + const result = this.safeValue (response, 'result', []); + return this.parseLedger (result, currency, since, limit); + } + + parseLedgerEntryType (type) { + const types = { + 'pnl': 'pnl', + 'deposit': 'transaction', + 'withdrawal': 'transaction', + 'commission': 'fee', + 'conversion': 'trade', + // 'perpetual_futures_funding': 'perpetual_futures_funding', + // 'withdrawal_cancellation': 'withdrawal_cancellation', + 'referral_bonus': 'referral', + 'commission_rebate': 'rebate', + // 'promo_credit': 'promo_credit', + }; + return this.safeString (types, type, type); + } + + parseLedgerEntry (item, currency = undefined) { + // + // { + // "amount":"29.889184", + // "asset_id":5, + // "balance":"29.889184", + // "created_at":"2020-11-15T21:25:01Z", + // "meta_data":{ + // "deposit_id":3884, + // "transaction_id":"0x41a60174849828530abb5008e98fc63c9b598288743ec4ba9620bcce900a3b8d" + // }, + // "transaction_type":"deposit", + // "user_id":22142, + // "uuid":"70bb5679da3c4637884e2dc63efaa846" + // } + // + const id = this.safeString (item, 'uuid'); + let direction = undefined; + const account = undefined; + const metaData = this.safeValue (item, 'meta_data', {}); + const referenceId = this.safeString (metaData, 'transaction_id'); + const referenceAccount = undefined; + let type = this.safeString (item, 'transaction_type'); + if ((type === 'deposit') || (type === 'commission_rebate') || (type === 'referral_bonus') || (type === 'pnl') || (type === 'withdrawal_cancellation') || (type === 'promo_credit')) { + direction = 'in'; + } else if ((type === 'withdrawal') || (type === 'commission') || (type === 'conversion') || (type === 'perpetual_futures_funding')) { + direction = 'out'; + } + type = this.parseLedgerEntryType (type); + const currencyId = this.safeInteger (item, 'asset_id'); + const currenciesByNumericId = this.safeValue (this.options, 'currenciesByNumericId'); + currency = this.safeValue (currenciesByNumericId, currencyId, currency); + const code = (currency === undefined) ? undefined : currency['code']; + const amount = this.safeFloat (item, 'amount'); + const timestamp = this.parse8601 (this.safeString (item, 'created_at')); + const after = this.safeFloat (item, 'balance'); + const before = Math.max (0, after - amount); + const status = 'ok'; + return { + 'info': item, + 'id': id, + 'direction': direction, + 'account': account, + 'referenceId': referenceId, + 'referenceAccount': referenceAccount, + 'type': type, + 'currency': code, + 'amount': amount, + 'before': before, + 'after': after, + 'status': status, + 'timestamp': timestamp, + 'datetime': this.iso8601 (timestamp), + 'fee': undefined, + }; + } + + async fetchDepositAddress (code, params = {}) { + await this.loadMarkets (); + const currency = this.currency (code); + const request = { + 'asset_symbol': currency['id'], + }; + const response = await this.privateGetDepositsAddress (this.extend (request, params)); + // + // { + // "success":true, + // "result":{ + // "id":19628, + // "user_id":22142, + // "address":"0x0eda26523397534f814d553a065d8e46b4188e9a", + // "status":"active", + // "updated_at":"2020-11-15T20:25:53.000Z", + // "created_at":"2020-11-15T20:25:53.000Z", + // "asset_symbol":"USDT", + // "custodian":"onc" + // } + // } + // + const result = this.safeValue (response, 'result', {}); + const address = this.safeString (result, 'address'); + this.checkAddress (address); + return { + 'currency': code, + 'address': address, + 'tag': undefined, + 'info': response, + }; + } + + sign (path, api = 'public', method = 'GET', params = {}, headers = undefined, body = undefined) { + const requestPath = '/' + this.version + '/' + this.implodeParams (path, params); + let url = this.urls['api'][api] + requestPath; + const query = this.omit (params, this.extractParams (path)); + if (api === 'public') { + if (Object.keys (query).length) { + url += '?' + this.urlencode (query); + } + } else if (api === 'private') { + this.checkRequiredCredentials (); + const timestamp = this.seconds ().toString (); + headers = { + 'api-key': this.apiKey, + 'timestamp': timestamp, + }; + let auth = method + timestamp + requestPath; + if ((method === 'GET') || (method === 'DELETE')) { + if (Object.keys (query).length) { + const queryString = '?' + this.urlencode (query); + auth += queryString; + url += queryString; + } + } else { + body = this.json (query); + auth += body; + headers['Content-Type'] = 'application/json'; + } + const signature = this.hmac (this.encode (auth), this.encode (this.secret)); + headers['signature'] = signature; + } + return { 'url': url, 'method': method, 'body': body, 'headers': headers }; + } + + handleErrors (code, reason, url, method, headers, body, response, requestHeaders, requestBody) { + if (response === undefined) { + return; + } + // + // {"error":{"code":"insufficient_margin","context":{"available_balance":"0.000000000000000000","required_additional_balance":"1.618626000000000000000000000"}},"success":false} + // + const error = this.safeValue (response, 'error', {}); + const errorCode = this.safeString (error, 'code'); + if (errorCode !== undefined) { + const feedback = this.id + ' ' + body; + this.throwExactlyMatchedException (this.exceptions['exact'], errorCode, feedback); + this.throwBroadlyMatchedException (this.exceptions['broad'], errorCode, feedback); + throw new ExchangeError (feedback); // unknown message + } + } +}; + +},{"./base/Exchange":6,"./base/errors":8,"./base/functions/number":14}],77:[function(require,module,exports){ 'use strict'; // --------------------------------------------------------------------------- @@ -57087,7 +60736,7 @@ module.exports = class deribit extends Exchange { const now = this.milliseconds (); if (since === undefined) { if (limit === undefined) { - throw new ArgumentsRequired (this.id + ' fetchOHLCV requires a since argument or a limit argument'); + throw new ArgumentsRequired (this.id + ' fetchOHLCV() requires a since argument or a limit argument'); } else { request['start_timestamp'] = now - (limit - 1) * duration * 1000; request['end_timestamp'] = now; @@ -57320,7 +60969,7 @@ module.exports = class deribit extends Exchange { 'cancelled': 'canceled', 'filled': 'closed', 'rejected': 'rejected', - // 'untriggered': 'open', + 'untriggered': 'open', }; return this.safeString (statuses, status, status); } @@ -57405,7 +61054,8 @@ module.exports = class deribit extends Exchange { trades = this.parseTrades (trades, market); } const timeInForce = this.parseTimeInForce (this.safeString (order, 'time_in_force')); - const stopPrice = undefined; + const stopPrice = this.safeValue (order, 'stop_price'); + const postOnly = this.safeValue (order, 'post_only'); return { 'info': order, 'id': id, @@ -57416,6 +61066,7 @@ module.exports = class deribit extends Exchange { 'symbol': market['symbol'], 'type': type, 'timeInForce': timeInForce, + 'postOnly': postOnly, 'side': side, 'price': price, 'stopPrice': stopPrice, @@ -57500,13 +61151,13 @@ module.exports = class deribit extends Exchange { if (price !== undefined) { request['price'] = this.priceToPrecision (symbol, price); } else { - throw new ArgumentsRequired (this.id + ' createOrder requires a price argument for a ' + type + ' order'); + throw new ArgumentsRequired (this.id + ' createOrder() requires a price argument for a ' + type + ' order'); } } if (stopPriceIsRequired) { const stopPrice = this.safeFloat2 (params, 'stop_price', 'stopPrice'); if (stopPrice === undefined) { - throw new ArgumentsRequired (this.id + ' createOrder requires a stop_price or stopPrice param for a ' + type + ' order'); + throw new ArgumentsRequired (this.id + ' createOrder() requires a stop_price or stopPrice param for a ' + type + ' order'); } else { request['stop_price'] = this.priceToPrecision (symbol, stopPrice); } @@ -57575,10 +61226,10 @@ module.exports = class deribit extends Exchange { async editOrder (id, symbol, type, side, amount = undefined, price = undefined, params = {}) { if (amount === undefined) { - throw new ArgumentsRequired (this.id + ' editOrder requires an amount argument'); + throw new ArgumentsRequired (this.id + ' editOrder() requires an amount argument'); } if (price === undefined) { - throw new ArgumentsRequired (this.id + ' editOrder requires a price argument'); + throw new ArgumentsRequired (this.id + ' editOrder() requires a price argument'); } await this.loadMarkets (); const request = { @@ -57940,7 +61591,7 @@ module.exports = class deribit extends Exchange { const request = { 'instrument_name': market['id'], }; - const response = await this.privateGetPosition (this.extend (request, params)); + const response = await this.privateGetGetPosition (this.extend (request, params)); // // { // "jsonrpc": "2.0", @@ -57979,7 +61630,7 @@ module.exports = class deribit extends Exchange { const request = { 'currency': currency['id'], }; - const response = await this.privateGetPositions (this.extend (request, params)); + const response = await this.privateGetGetPositions (this.extend (request, params)); // // { // "jsonrpc": "2.0", @@ -58093,7 +61744,7 @@ module.exports = class deribit extends Exchange { } }; -},{"./base/Exchange":5,"./base/errors":7,"./base/functions/number":13}],76:[function(require,module,exports){ +},{"./base/Exchange":6,"./base/errors":8,"./base/functions/number":14}],78:[function(require,module,exports){ 'use strict'; // --------------------------------------------------------------------------- @@ -58598,7 +62249,7 @@ module.exports = class digifinex extends Exchange { async fetchTickers (symbols = undefined, params = {}) { const apiKey = this.safeValue (params, 'apiKey', this.apiKey); if (!apiKey) { - throw new ArgumentsRequired (this.id + ' fetchTicker is a private v2 endpoint that requires an `exchange.apiKey` credential or an `apiKey` extra parameter'); + throw new ArgumentsRequired (this.id + ' fetchTickers() is a private v2 endpoint that requires an `exchange.apiKey` credential or an `apiKey` extra parameter'); } await this.loadMarkets (); const request = { @@ -58644,7 +62295,7 @@ module.exports = class digifinex extends Exchange { async fetchTicker (symbol, params = {}) { const apiKey = this.safeValue (params, 'apiKey', this.apiKey); if (!apiKey) { - throw new ArgumentsRequired (this.id + ' fetchTicker is a private v2 endpoint that requires an `exchange.apiKey` credential or an `apiKey` extra parameter'); + throw new ArgumentsRequired (this.id + ' fetchTicker() is a private v2 endpoint that requires an `exchange.apiKey` credential or an `apiKey` extra parameter'); } await this.loadMarkets (); const market = this.market (symbol); @@ -59090,6 +62741,7 @@ module.exports = class digifinex extends Exchange { 'symbol': symbol, 'type': type, 'timeInForce': undefined, + 'postOnly': undefined, 'side': side, 'price': price, 'stopPrice': undefined, @@ -59380,7 +63032,7 @@ module.exports = class digifinex extends Exchange { const address = this.safeString (depositAddress, 'address'); const tag = this.safeString (depositAddress, 'addressTag'); const currencyId = this.safeStringUpper (depositAddress, 'currency'); - const code = this.safeCurrencCode (currencyId); + const code = this.safeCurrencyCode (currencyId); return { 'info': depositAddress, 'code': code, @@ -59623,7 +63275,7 @@ module.exports = class digifinex extends Exchange { } }; -},{"./base/Exchange":5,"./base/errors":7}],77:[function(require,module,exports){ +},{"./base/Exchange":6,"./base/errors":8}],79:[function(require,module,exports){ 'use strict'; // --------------------------------------------------------------------------- @@ -60279,7 +63931,7 @@ module.exports = class dsx extends Exchange { await this.loadMarkets (); const market = this.market (symbol); if (type === 'market' && price === undefined) { - throw new ArgumentsRequired (this.id + ' createOrder requires a price argument even for market orders, that is the worst price that you agree to fill your order for'); + throw new ArgumentsRequired (this.id + ' createOrder() requires a price argument even for market orders, that is the worst price that you agree to fill your order for'); } const request = { 'pair': market['id'], @@ -60466,6 +64118,7 @@ module.exports = class dsx extends Exchange { 'lastTradeTimestamp': lastTradeTimestamp, 'type': orderType, 'timeInForce': undefined, + 'postOnly': undefined, 'side': side, 'price': price, 'stopPrice': undefined, @@ -60898,7 +64551,1557 @@ module.exports = class dsx extends Exchange { } }; -},{"./base/Exchange":5,"./base/errors":7}],78:[function(require,module,exports){ +},{"./base/Exchange":6,"./base/errors":8}],80:[function(require,module,exports){ +'use strict'; + +// ---------------------------------------------------------------------------- + +const Exchange = require ('./base/Exchange'); +const { ExchangeError, ArgumentsRequired, BadSymbol } = require ('./base/errors'); + +// ---------------------------------------------------------------------------- + +module.exports = class equos extends Exchange { + describe () { + return this.deepExtend (super.describe (), { + 'id': 'equos', + 'name': 'EQUOS', + 'countries': [ 'US', 'SG' ], // United States, Singapore + 'rateLimit': 10, + 'has': { + 'CORS': false, + 'cancelOrder': true, + 'createOrder': true, + 'editOrder': true, + 'fetchBalance': true, + 'fetchCanceledOrders': true, + 'fetchClosedOrders': true, + 'fetchCurrencies': true, + 'fetchDepositAddress': true, + 'fetchDeposits': true, + 'fetchMarkets': true, + 'fetchMyTrades': true, + 'fetchOHLCV': true, + 'fetchOrder': true, + 'fetchOrderBook': true, + 'fetchOrders': true, + 'fetchTicker': false, + 'fetchTrades': true, + 'fetchTradingFees': true, + 'fetchWithdrawals': true, + 'withdraw': true, + }, + 'timeframes': { + '1m': 1, + '5m': 2, + '15m': 3, + '1h': 4, + '6h': 5, + '1d': 6, + '7d': 7, + }, + 'urls': { + 'logo': 'https://user-images.githubusercontent.com/1294454/107758499-05edd180-6d38-11eb-9e09-0b69602a7a15.jpg', + 'test': { + 'public': 'https://testnet.equos.io/api', + 'private': 'https://testnet.equos.io/api', + }, + 'api': { + 'public': 'https://equos.io/api', + 'private': 'https://equos.io/api', + }, + 'www': 'https://equos.io', + 'doc': [ + 'https://developer.equos.io', + ], + 'referral': 'https://equos.io?referredByCode=zpa8kij4ouvBFup3', + }, + 'api': { + 'public': { + 'get': [ + 'health', + 'getInstruments', + 'getInstrumentPairs', + 'getOrderBook', + 'getRisk', + 'getTradeHistory', + 'getFundingRateHistory', + 'getChart', + 'getExchangeInfo', // not documented + ], + }, + 'private': { + 'post': [ + 'logon', + 'order', + 'cancelOrder', + 'cancelReplaceOrder', + 'getOrder', + 'getOrders', + 'getOrderStatus', + 'getOrderHistory', + 'userTrades', + 'getPositions', + 'cancelAll', + 'getUserHistory', + 'getRisk', + 'getDepositAddresses', + 'getDepositHistory', // not documented + 'getWithdrawRequests', + 'sendWithdrawRequest', + 'getTransferHistory', + ], + }, + }, + 'requiredCredentials': { + 'apiKey': true, + 'secret': true, + 'uid': true, + }, + 'exceptions': { + 'broad': { + 'symbol not found': BadSymbol, + }, + }, + }); + } + + async fetchMarkets (params = {}) { + const request = { + 'verbose': true, + }; + const response = await this.publicGetGetInstrumentPairs (this.extend (request, params)); + // + // { + // "instrumentPairs":[ + // { + // "instrumentId":52, + // "symbol":"BTC/USDC", + // "quoteId":1, + // "baseId":3, + // "price_scale":2, + // "quantity_scale":6, + // "securityStatus":1, + // "securityDesc":"BTC/USDC", // "BTC/USDC[F]" + // "assetType":"PAIR", // "PERPETUAL_SWAP" + // "currency":"BTC", + // "contAmtCurr":"USDC", + // "settlCurrency":"USDC", + // "commCurrency":"USDC", + // "cfiCode":"XXXXXX", + // "securityExchange":"XXXX", + // "instrumentPricePrecision":2, + // "minPriceIncrement":1.0, + // "minPriceIncrementAmount":1.0, + // "roundLot":1, + // "minTradeVol":0.001000, + // "maxTradeVol":0.000000 + // // contracts onlye + // "qtyType":0, + // "contractMultiplier":1.0, + // "issueDate":1598608087000 + // }, + // ] + // } + // + const instrumentPairs = this.safeValue (response, 'instrumentPairs', []); + const markets = []; + for (let i = 0; i < instrumentPairs.length; i++) { + const market = this.parseMarket (instrumentPairs[i]); + markets.push (market); + } + return markets; + } + + parseMarket (market) { + // + // { + // "instrumentId":52, + // "symbol":"BTC/USDC", // "BTC/USDC[F]" + // "quoteId":1, + // "baseId":3, + // "price_scale":2, + // "quantity_scale":6, + // "securityStatus":1, + // "securityDesc":"BTC/USDC", // "BTC/USDC[F]" + // "assetType":"PAIR", // "PERPETUAL_SWAP" + // "currency":"BTC", + // "contAmtCurr":"USDC", + // "settlCurrency":"USDC", + // "commCurrency":"USDC", + // "cfiCode":"XXXXXX", + // "securityExchange":"XXXX", + // "instrumentPricePrecision":2, + // "minPriceIncrement":1.0, + // "minPriceIncrementAmount":1.0, + // "roundLot":1, + // "minTradeVol":0.001000, + // "maxTradeVol":0.000000 + // // contracts onlye + // "qtyType":0, + // "contractMultiplier":1.0, + // "issueDate":1598608087000 + // } + // + const id = this.safeString (market, 'instrumentId'); + const uppercaseId = this.safeString (market, 'symbol'); + const assetType = this.safeString (market, 'assetType'); + const spot = (assetType === 'PAIR'); + const swap = (assetType === 'PERPETUAL_SWAP'); + const type = swap ? 'swap' : 'spot'; + const baseId = this.safeString (market, 'currency'); + const quoteId = this.safeString (market, 'contAmtCurr'); + const base = this.safeCurrencyCode (baseId); + const quote = this.safeCurrencyCode (quoteId); + const symbol = swap ? uppercaseId : (base + '/' + quote); + const status = this.safeInteger (market, 'securityStatus'); + const active = (status === 1); + const precision = { + 'amount': this.safeInteger (market, 'quantity_scale'), + 'price': this.safeInteger (market, 'price_scale'), + }; + return { + 'id': id, + 'uppercaseId': uppercaseId, + 'symbol': symbol, + 'base': base, + 'quote': quote, + 'baseId': baseId, + 'quoteId': quoteId, + 'type': type, + 'spot': spot, + 'swap': swap, + 'active': active, + 'precision': precision, + 'limits': { + 'amount': { + 'min': this.safeFloat (market, 'minTradeVol'), + 'max': undefined, + }, + 'price': { + 'min': undefined, + 'max': undefined, + }, + 'cost': { + 'min': undefined, + 'max': undefined, + }, + }, + 'info': market, + }; + } + + async fetchCurrencies (params = {}) { + const response = await this.publicGetGetInstruments (params); + // + // { + // "instruments": [ + // [ + // 3, // id + // "BTC", // symbol + // 2, // price_scale + // 6, // amount_scale + // 1, // status + // 0, // withdraw_fee + // "BTC", // name + // true, // withdrawal_pct + // ], + // ] + // } + // + const currencies = {}; + const instruments = this.safeValue (response, 'instruments', []); + for (let i = 0; i < instruments.length; i++) { + const currency = this.parseCurrency (instruments[i]); + const code = currency['code']; + currencies[code] = currency; + } + return currencies; + } + + parseCurrency (currency) { + // + // [ + // 3, // 0 id + // "BTC", // 1 symbol + // 2, // 2 price_scale + // 6, // 3 amount_scale + // 1, // 4 status + // 0, // 5 withdraw_fee + // "BTC", // 6 name + // true, // 7 withdrawal_pct + // ], + // + const id = this.safeString (currency, 0); + const uppercaseId = this.safeString (currency, 1); + const code = this.safeCurrencyCode (uppercaseId); + const priceScale = this.safeInteger (currency, 2); + const amountScale = this.safeInteger (currency, 3); + const precision = Math.max (priceScale, amountScale); + const name = this.safeString (currency, 6); + const status = this.safeInteger (currency, 4); + const active = (status === 1); + const fee = this.safeFloat (currency, 5); // withdraw_fee + return { + 'id': id, + 'info': currency, + 'uppercaseId': uppercaseId, + 'code': code, + 'name': name, + 'precision': precision, + 'fee': fee, + 'active': active, + 'limits': { + 'amount': { + 'min': undefined, + 'max': undefined, + }, + 'price': { + 'min': undefined, + 'max': undefined, + }, + 'cost': { + 'min': undefined, + 'max': undefined, + }, + 'withdraw': { + 'min': undefined, + 'max': undefined, + }, + }, + }; + } + + async fetchOHLCV (symbol, timeframe = '1m', since = undefined, limit = undefined, params = {}) { + await this.loadMarkets (); + const market = this.market (symbol); + const request = { + 'pairId': parseInt (market['id']), + 'timespan': this.timeframes[timeframe], + }; + if (limit !== undefined) { + request['limit'] = limit; + } + const response = await this.publicGetGetChart (this.extend (request, params)); + // + // { + // "pairId":57, + // "t":1, + // "s":"ETH/BTC", + // "lastPx":44099, + // "lastQty":100000, + // "o":0.043831000000000016, + // "h":0.04427100000000002, + // "l":0.032000000000000015, + // "c":0.04409900000000002, + // "v":0.21267333000000016, + // "q":4.850000000000001, + // "chart":[ + // [1612519260000,44099,44099,44099,44099,0,441], + // [1612519200000,44099,44099,44099,44099,0,440], + // [1612519140000,44269,44271,44269,44271,0,439], + // ] + // } + // + const chart = this.safeValue (response, 'chart', []); + return this.parseOHLCVs (chart, market, timeframe, since, limit); + } + + parseOHLCV (ohlcv, market = undefined) { + // + // [ + // 1612519260000, // timestamp + // 44099, // open + // 44099, // high + // 44099, // low + // 44099, // close + // 0, // base volume + // 441, // seqNumber + // ] + // + const timestamp = this.safeInteger (ohlcv, 0); + const open = this.convertFromScale (ohlcv[1], market['precision']['price']); + const high = this.convertFromScale (ohlcv[2], market['precision']['price']); + const low = this.convertFromScale (ohlcv[3], market['precision']['price']); + const close = this.convertFromScale (ohlcv[4], market['precision']['price']); + const volume = this.convertFromScale (ohlcv[5], market['precision']['amount']); + // volume = ohlcv[5]; + return [timestamp, open, high, low, close, volume]; + } + + parseBidAsk (bidask, priceKey = 0, amountKey = 1, market = undefined) { + if (market === undefined) { + throw new ArgumentsRequired (this.id + ' parseBidAsk() requires a market argument'); + } + const price = this.safeFloat (bidask, priceKey); + const amount = this.safeFloat (bidask, amountKey); + return [ + this.convertFromScale (price, market['precision']['price']), + this.convertFromScale (amount, market['precision']['amount']), + ]; + } + + parseOrderBook (orderbook, timestamp = undefined, bidsKey = 'bids', asksKey = 'asks', priceKey = 0, amountKey = 1, market = undefined) { + const result = { + 'timestamp': timestamp, + 'datetime': this.iso8601 (timestamp), + 'nonce': undefined, + }; + const sides = [ bidsKey, asksKey ]; + for (let i = 0; i < sides.length; i++) { + const side = sides[i]; + const orders = []; + const bidasks = this.safeValue (orderbook, side); + for (let k = 0; k < bidasks.length; k++) { + orders.push (this.parseBidAsk (bidasks[k], priceKey, amountKey, market)); + } + result[side] = orders; + } + result[bidsKey] = this.sortBy (result[bidsKey], 0, true); + result[asksKey] = this.sortBy (result[asksKey], 0); + return result; + } + + async fetchOrderBook (symbol, limit = undefined, params = {}) { + await this.loadMarkets (); + const market = this.market (symbol); + const request = { + 'pairId': parseInt (market['id']), + }; + const response = await this.publicGetGetOrderBook (this.extend (request, params)); + // + // { + // "bids":[ + // [4000480,30000,1612644984667], + // [3999304,200000,1612644984667], + // [3998862,50000,1612644984667], + // ], + // "asks":[ + // [4001962,1790000,1612644984667], + // [4002616,1000,1612644984667], + // [4003889,1000,1612644984667], + // ], + // "usdMark":40011.02, + // "marketStatus":0, + // "estFundingRate":0.0, + // "fundingRateTime":0, + // "auctionPrice":0.0, + // "auctionVolume":0.0 + // } + // + return this.parseOrderBook (response, undefined, 'bids', 'asks', 0, 1, market); + } + + async fetchTrades (symbol, since = undefined, limit = undefined, params = {}) { + await this.loadMarkets (); + const market = this.market (symbol); + const request = { + 'pairId': parseInt (market['id']), + }; + const response = await this.publicGetGetTradeHistory (this.extend (request, params)); + // + // { + // "trades":[ + // [4022800,47000,"20210206-21:39:12.886",256323,1], + // [4023066,1000,"20210206-21:38:55.030",256322,1], + // [4022406,50000,"20210206-21:36:56.334",256321,1], + // ] + // } + // + const trades = this.safeValue (response, 'trades', []); + return this.parseTrades (trades, market, since, limit, params); + } + + parseTrade (trade, market = undefined) { + // + // public fetchTrades + // + // [ + // 4022800, // 0 price + // 47000, // 1 quantity + // "20210206-21:39:12.886", // 2 timestamp + // 256323, // 3 sequence number + // 1 // 4 taker side 1 = buy, 2 = sell + // ] + // + // private fetchMyTrades + // + // { + // "account":3583, + // "commission":"-0.015805", + // "commCurrency":"USDC", + // "execId":265757, + // "ordType":"2", + // "ordStatus":"2", + // "execType":"F", + // "aggressorIndicator":true, + // "orderId":388953019, + // "price":"1842.04", + // "qty":"0.010000", + // "lastPx":"1756.22", + // "avgPx":"1756.22", + // "cumQty":"0.010000", + // "quoteQty":"0.010000", + // "side":"BUY", + // "symbol":"ETH/USDC", + // "clOrdId":"1613106766970339107", + // "submitterId":3583, + // "targetStrategy":"0", + // "time":1613106766971, + // "date":"20210212-05:12:46.971" + // } + // + let id = undefined; + let timestamp = undefined; + let orderId = undefined; + let type = undefined; + let side = undefined; + let price = undefined; + let amount = undefined; + let cost = undefined; + let fee = undefined; + let symbol = undefined; + if (Array.isArray (trade)) { + id = this.safeString (trade, 3); + price = this.convertFromScale (this.safeInteger (trade, 0), market['precision']['price']); + amount = this.convertFromScale (this.safeInteger (trade, 1), market['precision']['amount']); + timestamp = this.toMilliseconds (this.safeString (trade, 2)); + const takerSide = this.safeInteger (trade, 4); + if (takerSide === 1) { + side = 'buy'; + } else if (takerSide === 2) { + side = 'sell'; + } + } else { + id = this.safeString (trade, 'execId'); + timestamp = this.safeInteger (trade, 'time'); + const marketId = this.safeString (trade, 'symbol'); + symbol = this.safeSymbol (marketId, market); + orderId = this.safeString (trade, 'orderId'); + side = this.safeStringLower (trade, 'side'); + type = this.parseOrderType (this.safeString (trade, 'ordType')); + price = this.safeFloat (trade, 'lastPx'); + amount = this.safeFloat (trade, 'quoteQty'); + let feeCost = this.safeFloat (trade, 'commission'); + if (feeCost !== undefined) { + feeCost = -feeCost; + const feeCurrencyId = this.safeString (trade, 'commCurrency'); + const feeCurrencyCode = this.safeCurrencyCode (feeCurrencyId); + fee = { + 'cost': feeCost, + 'currency': feeCurrencyCode, + }; + } + } + if ((symbol === undefined) && (market !== undefined)) { + symbol = market['symbol']; + } + if (cost === undefined) { + if ((amount !== undefined) && (price !== undefined)) { + cost = amount * price; + } + } + return { + 'info': trade, + 'id': id, + 'timestamp': timestamp, + 'datetime': this.iso8601 (timestamp), + 'symbol': symbol, + 'order': orderId, + 'type': type, + 'side': side, + 'takerOrMaker': undefined, + 'price': price, + 'amount': amount, + 'cost': cost, + 'fee': fee, + }; + } + + async fetchBalance (params = {}) { + await this.loadMarkets (); + const response = await this.privatePostGetPositions (params); + // { + // "positions":[ + // { + // "instrumentId":1, + // "userId":3583, + // "quantity":0, + // "availableQuantity":0, + // "quantity_scale":6, + // "symbol":"USDC", + // "assetType":"ASSET", + // "usdCostBasis":0.0, + // "usdAvgCostBasis":0.0, + // "usdValue":0.0, + // "usdUnrealized":0.0, + // "usdRealized":0.0, + // "baseUsdMark":1.0, + // "settleCoinUsdMark":0.0, + // "settleCoinUnrealized":0.0, + // "settleCoinRealized":0.0 + // }, + // ] + // } + const positions = this.safeValue (response, 'positions', []); + const result = { + 'info': response, + }; + for (let i = 0; i < positions.length; i++) { + const position = positions[i]; + const assetType = this.safeString (position, 'assetType'); + if (assetType === 'ASSET') { + const currencyId = this.safeString (position, 'symbol'); + const code = this.safeCurrencyCode (currencyId); + const quantity = this.safeFloat (position, 'quantity'); + const availableQuantity = this.safeFloat (position, 'availableQuantity'); + const scale = this.safeInteger (position, 'quantity_scale'); + const account = this.account (); + account['free'] = this.convertFromScale (availableQuantity, scale); + account['total'] = this.convertFromScale (quantity, scale); + result[code] = account; + } + } + return this.parseBalance (result); + } + + async createOrder (symbol, type, side, amount, price = undefined, params = {}) { + await this.loadMarkets (); + const market = this.market (symbol); + const orderSide = (side === 'buy') ? 1 : 2; + const quantityScale = this.getScale (amount); + const request = { + // 'id': 0, + // 'account': 0, // required for institutional users + 'instrumentId': parseInt (market['id']), + 'symbol': market['uppercaseId'], + // 'clOrdId': '', + 'side': orderSide, // 1 = buy, 2 = sell + // 'ordType': 1, // 1 = market, 2 = limit, 3 = stop market, 4 = stop limit + // 'price': this.priceToPrecision (symbol, price), // required for limit and stop limit orders + // 'price_scale': this.getScale (price), + 'quantity': this.convertToScale (amount, quantityScale), + 'quantity_scale': quantityScale, + // 'stopPx': this.priceToPrecision (symbol, stopPx), + // 'stopPx_scale': this.getScale (stopPx), + // 'targetStrategy': 0, + // 'isHidden': false, + // 'timeInForce': 1, // 1 = Good Till Cancel (GTC), 3 = Immediate or Cancel (IOC), 4 = Fill or Kill (FOK), 5 = Good Till Crossing (GTX), 6 = Good Till Date (GTD) + // 'interval': 0, + // 'intervalCount': 0, + // 'intervalDelay': 0, + // 'price2': 0, + // 'price2_scale': this.getScale (price2), + // 'blockWaitAck': 0, // 1 = wait for order acknowledgement, when set, response will include the matching engine "orderId" field + }; + if (type === 'market') { + request['ordType'] = 1; + } else if (type === 'limit') { + request['ordType'] = 2; + request['price'] = this.convertToScale (price, this.getScale (price)); + } else { + const stopPrice = this.safeFloat2 (params, 'stopPrice', 'stopPx'); + params = this.omit (params, [ 'stopPrice', 'stopPx' ]); + if (stopPrice === undefined) { + if (type === 'stop') { + if (price === undefined) { + throw new ArgumentsRequired (this.id + ' createOrder() requires a price argument or a stopPrice parameter or a stopPx parameter for ' + type + ' orders'); + } + request['ordType'] = 3; + request['stopPx'] = this.convertToScale (price, this.getScale (price)); + } else if (type === 'stop limit') { + throw new ArgumentsRequired (this.id + ' createOrder() requires a stopPrice parameter or a stopPx parameter for ' + type + ' orders'); + } + } else { + if (type === 'stop') { + request['ordType'] = 3; + request['stopPx'] = this.convertToScale (stopPrice, this.getScale (stopPrice)); + } else if (type === 'stop limit') { + request['ordType'] = 4; + const priceScale = this.getScale (price); + const stopPriceScale = this.getScale (stopPrice); + request['price_scale'] = priceScale; + request['stopPx_scale'] = stopPriceScale; + request['stopPx'] = this.convertToScale (stopPrice, stopPriceScale); + request['price'] = this.convertToScale (price, priceScale); + } + } + } + const response = await this.privatePostOrder (this.extend (request, params)); + // + // { + // "status":"sent", + // "id":385617863, + // "instrumentId":53, + // "clOrdId":"1613037510849637345", + // "userId":3583, + // "price":2000, + // "quantity":200, + // "ordType":2 + // } + // + return this.parseOrder (response, market); + } + + async cancelOrder (id, symbol = undefined, params = {}) { + if (symbol === undefined) { + throw new ArgumentsRequired (this.id + ' cancelOrder() requires a symbol argument'); + } + await this.loadMarkets (); + const market = this.market (symbol); + const request = { + 'origOrderId': parseInt (id), + 'instrumentId': parseInt (market['id']), + }; + const response = await this.privatePostCancelOrder (this.extend (request, params)); + // + // { + // "status":"sent", + // "id":0, + // "origOrderId":385613629, + // "instrumentId":53, + // "userId":3583, + // "price":0, + // "quantity":0, + // "ordType":0 + // } + // + return this.parseOrder (response, market); + } + + async editOrder (id, symbol, type, side, amount, price = undefined, params = {}) { + await this.loadMarkets (); + const market = this.market (symbol); + const orderSide = (side === 'buy') ? 1 : 2; + const quantityScale = this.getScale (amount); + const request = { + // 'id': 0, + 'origOrderId': id, + // 'account': 0, // required for institutional users + 'instrumentId': parseInt (market['id']), + 'symbol': market['uppercaseId'], + // 'clOrdId': '', + 'side': orderSide, // 1 = buy, 2 = sell + // 'ordType': 1, // 1 = market, 2 = limit, 3 = stop market, 4 = stop limit + // 'price': this.priceToPrecision (symbol, price), // required for limit and stop limit orders + // 'price_scale': this.getScale (price), + 'quantity': this.convertToScale (amount, quantityScale), + 'quantity_scale': quantityScale, + // 'stopPx': this.priceToPrecision (symbol, stopPx), + // 'stopPx_scale': this.getScale (stopPx), + // 'timeInForce': 1, // 1 = Good Till Cancel (GTC), 3 = Immediate or Cancel (IOC), 4 = Fill or Kill (FOK), 5 = Good Till Crossing (GTX), 6 = Good Till Date (GTD) + }; + if (type === 'market') { + request['ordType'] = 1; + } else if (type === 'limit') { + request['ordType'] = 2; + request['price'] = this.convertToScale (price, this.getScale (price)); + } else { + const stopPrice = this.safeFloat2 (params, 'stopPrice', 'stopPx'); + params = this.omit (params, [ 'stopPrice', 'stopPx' ]); + if (stopPrice === undefined) { + if (type === 'stop') { + if (price === undefined) { + throw new ArgumentsRequired (this.id + ' editOrder() requires a price argument or a stopPrice parameter or a stopPx parameter for ' + type + ' orders'); + } + request['ordType'] = 3; + request['stopPx'] = this.convertToScale (price, this.getScale (price)); + } else if (type === 'stop limit') { + throw new ArgumentsRequired (this.id + ' editOrder() requires a stopPrice parameter or a stopPx parameter for ' + type + ' orders'); + } + } else { + if (type === 'stop') { + request['ordType'] = 3; + request['stopPx'] = this.convertToScale (stopPrice, this.getScale (stopPrice)); + } else if (type === 'stop limit') { + request['ordType'] = 4; + const priceScale = this.getScale (price); + const stopPriceScale = this.getScale (stopPrice); + request['price_scale'] = priceScale; + request['stopPx_scale'] = stopPriceScale; + request['stopPx'] = this.convertToScale (stopPrice, stopPriceScale); + request['price'] = this.convertToScale (price, priceScale); + } + } + } + const response = await this.privatePostOrder (this.extend (request, params)); + // + // { + // "status":"sent", + // "id":385617863, + // "instrumentId":53, + // "clOrdId":"1613037510849637345", + // "userId":3583, + // "price":2000, + // "quantity":200, + // "ordType":2 + // } + // + return this.parseOrder (response, market); + } + + async fetchOrder (id, symbol = undefined, params = {}) { + await this.loadMarkets (); + const request = { + 'orderId': parseInt (id), + }; + const response = await this.privatePostGetOrderStatus (this.extend (request, params)); + // + // { + // "orderId":388953019, + // "clOrdId":"1613106766970339107", + // "symbol":"ETH/USDC", + // "instrumentId":53, + // "side":"1", + // "userId":3583, + // "account":3583, + // "execType":"F", + // "ordType":"2", + // "ordStatus":"2", + // "timeInForce":"3", + // "timeStamp":"20210212-05:12:46.971", + // "execId":265757, + // "targetStrategy":0, + // "isHidden":false, + // "isReduceOnly":false, + // "isLiquidation":false, + // "fee":0, + // "fee_scale":6, + // "feeInstrumentId":1, + // "price":184204, + // "price_scale":2, + // "quantity":10000, + // "quantity_scale":6, + // "leavesQty":0, + // "leavesQty_scale":6, + // "cumQty":10000, + // "cumQty_scale":6, + // "lastPx":175622, + // "lastPx_scale":2, + // "avgPx":175622, + // "avgPx_scale":2, + // "lastQty":10000, + // "lastQty_scale":6 + // } + // + return this.parseOrder (response); + } + + async fetchClosedOrders (symbol = undefined, since = undefined, limit = undefined, params = {}) { + const request = { + 'ordStatus': '2', // '0' = New, '1' = Partially filled, '2' = Filled, '4' = Cancelled, '8' = Rejected, 'C' = Expired + }; + return await this.fetchOrders (symbol, since, limit, this.extend (request, params)); + } + + async fetchCanceledOrders (symbol = undefined, since = undefined, limit = undefined, params = {}) { + const request = { + 'ordStatus': '4', // '0' = New, '1' = Partially filled, '2' = Filled, '4' = Cancelled, '8' = Rejected, 'C' = Expired + }; + return await this.fetchOrders (symbol, since, limit, this.extend (request, params)); + } + + async fetchOrders (symbol = undefined, since = undefined, limit = undefined, params = {}) { + await this.loadMarkets (); + let market = undefined; + const request = { + // 'account': id, // for institutional users + // 'symbol': marketSymbol, // cannot be used with instrumentId + // 'instrumentId': market['numericId'], + // 'limit': limit, + // 'execType': execType, // '0' = New, '4' = Canceled, '5' = Replace, '8' = Rejected, 'C' = Expired, 'F' = Fill Status, 'I' = Order Status + // 'ordStatus': ordStatus, // '0' = New, '1' = Partially filled, '2' = Filled, '4' = Cancelled, '8' = Rejected, 'C' = Expired + }; + if (symbol !== undefined) { + market = this.market (symbol); + request['instrumentId'] = parseInt (market['id']); + } + if (limit !== undefined) { + request['limit'] = limit; + } + const response = await this.privatePostGetOrders (this.extend (request, params)); + // + // { + // "isInitialSnap":false, + // "orders":[ + // { + // "orderId":385613629, + // "orderUpdateSeq":1, + // "clOrdId":"1613037448945798198", + // "symbol":"ETH/USDC", + // "instrumentId":53, + // "side":"1", + // "userId":3583, + // "account":3583, + // "execType":"4", + // "ordType":"2", + // "ordStatus":"C", + // "timeInForce":"3", + // "timeStamp":"20210211-09:57:28.944", + // "execId":0, + // "targetStrategy":0, + // "isHidden":false, + // "isReduceOnly":false, + // "isLiquidation":false, + // "fee":0, + // "feeTotal":0, + // "fee_scale":0, + // "feeInstrumentId":0, + // "price":999, + // "price_scale":2, + // "quantity":10000000, + // "quantity_scale":6, + // "leavesQty":10000000, + // "leavesQty_scale":6, + // "cumQty":0, + // "cumQty_scale":0, + // "lastPx":0, + // "lastPx_scale":2, + // "avgPx":0, + // "avgPx_scale":0, + // "lastQty":0, + // "lastQty_scale":6 + // } + // ] + // } + // + const orders = this.safeValue (response, 'orders', []); + return this.parseOrders (orders, market, since, limit, params); + } + + async fetchMyTrades (symbol = undefined, since = undefined, limit = undefined, params = {}) { + await this.loadMarkets (); + const request = { + // 'account': 123, // for institutional users + // 'instrumentId': market['id'], + // 'startTime': since, + // 'endTime': this.milliseconds (), + }; + let market = undefined; + if (symbol !== undefined) { + market = this.market (symbol); + request['instrumentId'] = market['id']; + } + if (since !== undefined) { + request['startTime'] = since; + } + const response = await this.privatePostUserTrades (this.extend (request, params)); + // + // { + // "trades":[ + // { + // "account":3583, + // "commission":"-0.015805", + // "commCurrency":"USDC", + // "execId":265757, + // "ordType":"2", + // "ordStatus":"2", + // "execType":"F", + // "aggressorIndicator":true, + // "orderId":388953019, + // "price":"1842.04", + // "qty":"0.010000", + // "lastPx":"1756.22", + // "avgPx":"1756.22", + // "cumQty":"0.010000", + // "quoteQty":"0.010000", + // "side":"BUY", + // "symbol":"ETH/USDC", + // "clOrdId":"1613106766970339107", + // "submitterId":3583, + // "targetStrategy":"0", + // "time":1613106766971, + // "date":"20210212-05:12:46.971" + // } + // ] + // } + // + const trades = this.safeValue (response, 'trades', []); + return this.parseTrades (trades, market, since, limit, params); + } + + async fetchDepositAddress (code, params = {}) { + await this.loadMarkets (); + const currency = this.currency (code); + const request = { + 'instrumentId': parseInt (currency['id']), + }; + const response = await this.privatePostGetDepositAddresses (this.extend (request, params)); + // + // { + // "addresses":[ + // {"instrumentId":1,"userId":3583,"symbol":"USDC","address":"0xdff47af071ea3c537e57278290516cda32a78b97","status":1} + // ] + // } + // + const addresses = this.safeValue (response, 'addresses', []); + const address = this.safeValue (addresses, 0); + return this.parseDepositAddress (address, currency); + } + + parseDepositAddress (depositAddress, currency = undefined) { + // + // { + // "instrumentId":1, + // "userId":3583, + // "symbol":"USDC", + // "address":"0xdff47af071ea3c537e57278290516cda32a78b97", + // "status":1 + // } + // + const currencyId = this.safeString (depositAddress, 'symbol'); + const code = this.safeCurrencyCode (currencyId, currency); + const address = this.safeString (depositAddress, 'address'); + this.checkAddress (address); + return { + 'currency': code, + 'address': address, + 'tag': undefined, + 'info': depositAddress, + }; + } + + async fetchDeposits (code = undefined, since = undefined, limit = undefined, params = {}) { + await this.loadMarkets (); + const request = {}; + let currency = undefined; + if (code !== undefined) { + currency = this.currency (code); + request['instrumentId'] = parseInt (currency['id']); + } + const response = await this.privatePostGetDepositHistory (this.extend (request, params)); + // + // { + // "deposits":[ + // { + // "id":4309, + // "instrumentId":1, + // "userId":3583, + // "symbol":"USDC", + // "address":"null", + // "timestamp":"1613021112189", + // "status":1, + // "balance":0.0, + // "balance_change":100.0, + // "confirms":1, + // "transactionId":"caba4500-489f-424e-abd7-b4dabc09a800" + // } + // ] + // } + // + const deposits = this.safeValue (response, 'deposits', []); + return this.parseTransactions (deposits, currency, since, limit, { 'type': 'deposit' }); + } + + async fetchWithdrawals (code = undefined, since = undefined, limit = undefined, params = {}) { + await this.loadMarkets (); + const request = {}; + let currency = undefined; + if (code !== undefined) { + currency = this.currency (code); + request['instrumentId'] = parseInt (currency['id']); + } + const response = await this.privatePostGetWithdrawRequests (this.extend (request, params)); + // + // { + // "addresses":[ + // { + // "id":3841, + // "instrumentId":3, + // "userId":4245, + // "symbol":"BTC", + // "address":"XXXXXYYYYYZZZZZ", + // "timestamp":"20200806-11:04:35.053", + // "status":0, + // "balance":1, + // "balance_scale":3, + // "confirms":0, + // "transactionId":"null" + // } + // ] + // } + // + const withdrawals = this.safeValue (response, 'addresses', []); + return this.parseTransactions (withdrawals, currency, since, limit, { 'type': 'withdrawal' }); + } + + parseTransaction (transaction, currency = undefined) { + // + // fetchDeposits, fetchWithdrawals + // + // { + // "id":4309, + // "instrumentId":1, + // "userId":3583, + // "symbol":"USDC", + // "address":"null", + // "timestamp":"1613021112189", + // "status":1, + // "balance":0.0, + // "balance_change":100.0, + // "confirms":1, + // "transactionId":"caba4500-489f-424e-abd7-b4dabc09a800" + // } + // + // withdraw + // + // { + // "instrumentId": 1, + // "userId": 23750, + // "symbol": "USDC", + // "timestamp": "20200201-05:37:16.584", + // "status": 1, + // "userUuid": "b9e33713-c28f-468f-99bd-f6deab0dd854", + // "currencyCode": "USDC", + // "address": "2MvW97yT6E2Kq8bWc1aj1DqfbgMzjRNk2LE", + // "quantity": 20, + // "requestUuid": "56782b34-8a78-4f5f-b164-4b8f7d583b7f", + // "transactionUuid": "1004eb0f-41e1-41e9-9d48-8eefcc6c09f2", + // "transactionId": "WS23436", + // "destinationWalletAlias": "Test", + // "quantity_scale": 0 + // } + // + const id = this.safeString (transaction, 'id', 'transactionId'); + const txid = this.safeString (transaction, 'transactionUuid'); + const timestamp = this.safeInteger (transaction, 'timestamp'); + let address = this.safeString (transaction, 'address'); + if (address === 'null') { + address = undefined; + } + const type = this.safeString (transaction, 'type'); + let amount = this.safeFloat (transaction, 'balance_change'); + if (amount === undefined) { + amount = this.safeInteger (transaction, 'quantity'); + const amountScale = this.safeInteger (transaction, 'quantity_scale'); + amount = this.convertFromScale (amount, amountScale); + } + const currencyId = this.safeString (transaction, 'symbol'); + const code = this.safeCurrencyCode (currencyId, currency); + const status = this.parseTransactionStatus (this.safeString (transaction, 'status')); + return { + 'info': transaction, + 'id': id, + 'txid': txid, + 'timestamp': timestamp, + 'datetime': this.iso8601 (timestamp), + 'addressFrom': undefined, + 'address': address, + 'addressTo': undefined, + 'tagFrom': undefined, + 'tag': undefined, + 'tagTo': undefined, + 'type': type, + 'amount': amount, + 'currency': code, + 'status': status, + 'updated': undefined, + 'comment': undefined, + 'fee': undefined, + }; + } + + parseTransactionStatus (status) { + const statuses = { + '0': 'pending', + '1': 'ok', + }; + return this.safeString (statuses, status, status); + } + + async withdraw (code, amount, address, tag = undefined, params = {}) { + this.checkAddress (address); + await this.loadMarkets (); + const currency = this.currency (code); + const scale = this.getScale (amount); + const quantity = this.convertToScale (amount, scale); + const request = { + 'instrumentId': parseInt (currency['id']), + 'symbol': currency['uppercaseId'], + 'quantity': quantity, + 'quantity_scale': scale, + 'address': address, + }; + const response = await this.privatePostSendWithdrawRequest (this.extend (request, params)); + // + // { + // "instrumentId": 1, + // "userId": 23750, + // "symbol": "USDC", + // "timestamp": "20200201-05:37:16.584", + // "status": 1, + // "userUuid": "b9e33713-c28f-468f-99bd-f6deab0dd854", + // "currencyCode": "USDC", + // "address": "2MvW97yT6E2Kq8bWc1aj1DqfbgMzjRNk2LE", + // "quantity": 20, + // "requestUuid": "56782b34-8a78-4f5f-b164-4b8f7d583b7f", + // "transactionUuid": "1004eb0f-41e1-41e9-9d48-8eefcc6c09f2", + // "transactionId": "WS23436", + // "destinationWalletAlias": "Test", + // "quantity_scale": 0 + // } + // + return this.parseTransaction (response, currency); + } + + async fetchTradingFees (params = {}) { + // getExchangeInfo + const response = await this.publicGetGetExchangeInfo (params); + const tradingFees = this.safeValue (response, 'spotFees', []); + const taker = {}; + const maker = {}; + for (let i = 0; i < tradingFees.length; i++) { + const tradingFee = tradingFees[i]; + if (this.safeString (tradingFee, 'tier') !== undefined) { + taker[tradingFee['tier']] = this.safeFloat (tradingFee, 'taker'); + maker[tradingFee['tier']] = this.safeFloat (tradingFee, 'maker'); + } + } + return { + 'info': tradingFees, + 'tierBased': true, + 'maker': maker, + 'taker': taker, + }; + } + + async fetchTradingLimits (symbols = undefined, params = {}) { + await this.loadMarkets (); + // getExchangeInfo + const response = await this.publicGetGetExchangeInfo (params); + const tradingLimits = this.safeValue (response, 'tradingLimits', []); + // To-do parsing response when available + return { + 'info': tradingLimits, + 'limits': { + 'amount': { + 'min': undefined, + 'max': undefined, + }, + 'price': { + 'min': undefined, + 'max': undefined, + }, + 'cost': { + 'min': undefined, + 'max': undefined, + }, + }, + }; + } + + async fetchFundingLimits (params = {}) { + // getExchangeInfo + const response = await this.publicGetGetExchangeInfo (params); + const withdrawLimits = this.safeValue (response, 'withdrawLimits', []); + // TO-DO parse response when available + return { + 'info': withdrawLimits, + 'withdraw': undefined, + }; + } + + parseOrder (order, market = undefined) { + // + // createOrder, editOrder, cancelOrder + // + // { + // "status":"sent", + // "id":385617863, + // "instrumentId":53, + // "clOrdId":"1613037510849637345", + // "userId":3583, + // "price":2000, + // "quantity":200, + // "ordType":2 + // } + // + // fetchOrders, fetchOrder + // + // { + // "orderId":385613629, + // "orderUpdateSeq":1, + // "clOrdId":"1613037448945798198", + // "symbol":"ETH/USDC", + // "instrumentId":53, + // "side":"1", + // "userId":3583, + // "account":3583, + // "execType":"4", + // "ordType":"2", + // "ordStatus":"C", + // "timeInForce":"3", + // "timeStamp":"20210211-09:57:28.944", + // "execId":0, + // "targetStrategy":0, + // "isHidden":false, + // "isReduceOnly":false, + // "isLiquidation":false, + // "fee":0, + // "feeTotal":0, + // "fee_scale":0, + // "feeInstrumentId":0, + // "price":999, + // "price_scale":2, + // "quantity":10000000, + // "quantity_scale":6, + // "leavesQty":10000000, + // "leavesQty_scale":6, + // "cumQty":0, + // "cumQty_scale":0, + // "lastPx":0, + // "lastPx_scale":2, + // "avgPx":0, + // "avgPx_scale":0, + // "lastQty":0, + // "lastQty_scale":6 + // } + // + let id = this.safeString2 (order, 'orderId', 'id'); + id = this.safeString (order, 'origOrderId', id); + const clientOrderId = this.safeString (order, 'clOrdId'); + const type = this.parseOrderType (this.safeString (order, 'ordType')); + const side = this.parseOrderSide (this.safeString (order, 'side')); + const status = this.parseOrderStatus (this.safeString (order, 'ordStatus')); + const marketId = this.safeString (order, 'instrumentId'); + const symbol = this.safeSymbol (marketId, market); + const timestamp = this.toMilliseconds (this.safeString (order, 'timeStamp')); + const lastTradeTimestamp = undefined; + let price = this.safeInteger (order, 'price'); + if (price === 0) { + price = undefined; + } + const priceScale = this.safeInteger (order, 'price_scale'); + price = this.convertFromScale (price, priceScale); + let amount = this.safeInteger (order, 'quantity'); + if (amount === 0) { + amount = undefined; + } + const amountScale = this.safeInteger (order, 'quantity_scale'); + amount = this.convertFromScale (amount, amountScale); + let filled = this.safeInteger (order, 'cumQty'); + const filledScale = this.safeInteger (order, 'cumQty_scale'); + filled = this.convertFromScale (filled, filledScale); + let remaining = this.safeInteger (order, 'leavesQty'); + const remainingScale = this.safeInteger (order, 'leavesQty_scale'); + remaining = this.convertFromScale (remaining, remainingScale); + if (remaining <= 0) { + if ((filled !== undefined) && (amount !== undefined) && (filled < amount)) { + remaining = undefined; + } + } + if ((remaining === undefined) && (amount !== undefined) && (filled !== undefined)) { + remaining = Math.max (amount - filled, 0); + } + let average = this.safeInteger (order, 'price', 0); + if (average === 0) { + average = undefined; + } + const averageScale = this.safeInteger (order, 'price_scale'); + average = this.convertFromScale (average, averageScale); + let cost = undefined; + if (filled !== 0) { + if (average > 0) { + cost = average * filled; + } else if (price > 0) { + cost = price * filled; + } + } + let fee = undefined; + const currencyId = this.safeInteger (order, 'feeInstrumentId'); + const feeCurrencyCode = this.safeCurrencyCode (currencyId); + let feeCost = this.safeInteger (order, 'feeTotal'); + const feeScale = this.safeInteger (order, 'fee_scale'); + if (feeCost !== undefined) { + feeCost = -feeCost; + feeCost = this.convertFromScale (feeCost, feeScale); + } + if (feeCost !== undefined) { + fee = { + 'currency': feeCurrencyCode, + 'cost': feeCost, + 'rate': undefined, + }; + } + let timeInForce = this.parseTimeInForce (this.safeString (order, 'timeInForce')); + if (timeInForce === '0') { + timeInForce = undefined; + } + const stopPriceScale = this.safeInteger (order, 'stopPx_scale', 0); + const stopPrice = this.convertFromScale (this.safeInteger (order, 'stopPx'), stopPriceScale); + return { + 'info': order, + 'id': id, + 'clientOrderId': clientOrderId, + 'timestamp': timestamp, + 'datetime': this.iso8601 (timestamp), + 'lastTradeTimestamp': lastTradeTimestamp, + 'symbol': symbol, + 'type': type, + 'timeInForce': timeInForce, + 'postOnly': undefined, + 'side': side, + 'price': price, + 'stopPrice': stopPrice, + 'amount': amount, + 'cost': cost, + 'average': average, + 'filled': filled, + 'remaining': remaining, + 'status': status, + 'fee': fee, + 'trades': undefined, + }; + } + + parseOrderStatus (status) { + const statuses = { + '0': 'open', + '1': 'open', // 'partially filled', + '2': 'closed', // 'filled', + '3': 'open', // 'done for day', + '4': 'canceled', + '5': 'canceled', // 'replaced', + '6': 'canceling', // 'pending cancel', + '7': 'canceled', // 'stopped', + '8': 'rejected', // 'rejected', + '9': 'canceled', // 'suspended', + 'A': 'open', // 'pending new', + 'B': 'open', // 'calculated', + 'C': 'expired', + 'D': 'open', // 'accepted for bidding', + 'E': 'canceling', // 'pending replace', + 'F': 'open', // 'partial fill or fill', + }; + return this.safeString (statuses, status, status); + } + + parseOrderSide (side) { + const sides = { + '1': 'buy', + '2': 'sell', + }; + return this.safeString (sides, side, side); + } + + parseOrderType (type) { + const types = { + '1': 'market', + '2': 'limit', + '3': 'stop', + '4': 'stop limit', + }; + return this.safeString (types, type, type); + } + + parseTimeInForce (timeInForce) { + const timeInForces = { + '1': 'GTC', // Good Till Canceled + '3': 'IOC', // Immediate or Cancel + '4': 'FOK', // Fill or Kill + '5': 'GTX', // Good Till Crossing (GTX) + '6': 'GTD', // Good Till Date + }; + return this.safeString (timeInForces, timeInForce, timeInForce); + } + + toMilliseconds (dateString) { + if (dateString === undefined) { + return dateString; + } + // '20200328-10:31:01.575' -> '2020-03-28 12:42:48.000' + const splits = dateString.split ('-'); + const partOne = this.safeString (splits, 0); + const partTwo = this.safeString (splits, 1); + if (partOne === undefined || partTwo === undefined) { + return undefined; + } + if (partOne.length !== 8) { + return undefined; + } + const date = partOne.slice (0, 4) + '-' + partOne.slice (4, 6) + '-' + partOne.slice (6, 8); + return this.parse8601 (date + ' ' + partTwo); + } + + convertFromScale (number, scale) { + if ((number === undefined) || (scale === undefined)) { + return undefined; + } + return this.fromWei (number, scale); + } + + getScale (num) { + const s = this.numberToString (num); + return this.precisionFromString (s); + } + + convertToScale (number, scale) { + if ((number === undefined) || (scale === undefined)) { + return undefined; + } + return parseInt (this.toWei (number, scale)); + } + + nonce () { + return this.milliseconds (); + } + + handleErrors (code, reason, url, method, headers, body, response, requestHeaders, requestBody) { + if (response === undefined) { + return; // fallback to default error handler + } + const error = this.safeString (response, 'error'); + if (error !== undefined) { + const feedback = this.id + ' ' + body; + this.throwExactlyMatchedException (this.exceptions, error, feedback); + this.throwBroadlyMatchedException (this.exceptions, body, feedback); + throw new ExchangeError (this.id + ' ' + body); + } + } + + sign (path, api = 'public', method = 'GET', params = {}, headers = undefined, body = undefined) { + let url = this.implodeParams (path, params); + let query = this.omit (params, this.extractParams (path)); + if (api === 'public') { + if (Object.keys (query).length) { + url += '?' + this.urlencode (query); + } + } else if (api === 'private') { + // special case for getUserHistory + const format = this.safeValue (params, 'format'); + const type = this.safeValue (params, 'type'); + const extension = {}; + if (format !== undefined) { + extension['format'] = format; + } + if (type !== undefined) { + extension['type'] = type; + } + if (Object.keys (extension).length) { + url += '?' + this.urlencode (extension); + } + params = this.omit (params, [ 'format', 'type' ]); + this.checkRequiredCredentials (); + const nonce = this.nonce (); + query = this.extend (query, { + 'userId': this.uid, + 'nonce': nonce, + }); + params['nonce'] = this.nonce (); + body = this.json (query); + const signature = this.hmac (this.encode (body), this.encode (this.secret), 'sha384'); + headers = { + 'Content-Type': 'application/json', + 'requestToken': this.apiKey, + 'signature': signature, + }; + } + url = this.urls['api'][api] + '/' + url; + return { 'url': url, 'method': method, 'body': body, 'headers': headers }; + } +}; + +},{"./base/Exchange":6,"./base/errors":8}],81:[function(require,module,exports){ 'use strict'; // ---------------------------------------------------------------------------- @@ -61506,7 +66709,7 @@ module.exports = class eterbase extends Exchange { request['start'] = now - duration * limit * 1000; request['end'] = now; } else { - throw new ArgumentsRequired (this.id + ' fetchOHLCV requires a since argument, or a limit argument, or both'); + throw new ArgumentsRequired (this.id + ' fetchOHLCV() requires a since argument, or a limit argument, or both'); } await this.loadMarkets (); const market = this.market (symbol); @@ -61708,6 +66911,7 @@ module.exports = class eterbase extends Exchange { } const timeInForce = this.safeString (order, 'timeInForce'); const stopPrice = this.safeFloat (order, 'stopPrice'); + const postOnly = this.safeValue (order, 'postOnly'); return { 'info': order, 'id': id, @@ -61717,8 +66921,9 @@ module.exports = class eterbase extends Exchange { 'lastTradeTimestamp': undefined, 'symbol': symbol, 'type': type, - 'side': side, 'timeInForce': timeInForce, + 'postOnly': postOnly, + 'side': side, 'price': price, 'stopPrice': stopPrice, 'amount': amount, @@ -62041,7 +67246,7 @@ module.exports = class eterbase extends Exchange { } }; -},{"./base/Exchange":5,"./base/errors":7,"./base/functions/number":13}],79:[function(require,module,exports){ +},{"./base/Exchange":6,"./base/errors":8,"./base/functions/number":14}],82:[function(require,module,exports){ 'use strict'; // --------------------------------------------------------------------------- @@ -62746,7 +67951,7 @@ module.exports = class exmo extends Exchange { const now = this.milliseconds (); if (since === undefined) { if (limit === undefined) { - throw new ArgumentsRequired (this.id + ' fetchOHLCV requires a since argument or a limit argument'); + throw new ArgumentsRequired (this.id + ' fetchOHLCV() requires a since argument or a limit argument'); } else { if (limit > maxLimit) { throw new BadRequest (this.id + ' fetchOHLCV will serve ' + maxLimit.toString () + ' candles at most'); @@ -63362,6 +68567,7 @@ module.exports = class exmo extends Exchange { 'symbol': symbol, 'type': 'limit', 'timeInForce': undefined, + 'postOnly': undefined, 'side': side, 'price': price, 'stopPrice': undefined, @@ -63480,12 +68686,21 @@ module.exports = class exmo extends Exchange { const type = this.safeString (transaction, 'type'); const currencyId = this.safeString (transaction, 'curr'); const code = this.safeCurrencyCode (currencyId, currency); - let address = this.safeString (transaction, 'account'); - if (address !== undefined) { - const parts = address.split (':'); - const numParts = parts.length; - if (numParts === 2) { - address = parts[1].replace (' ', ''); + let address = undefined; + const tag = undefined; + let comment = undefined; + const account = this.safeString (transaction, 'account'); + if (type === 'deposit') { + comment = account; + } else if (type === 'withdrawal') { + address = account; + if (address !== undefined) { + const parts = address.split (':'); + const numParts = parts.length; + if (numParts === 2) { + address = this.safeString (parts, 1); + address = address.replace (' ', ''); + } } } let fee = undefined; @@ -63513,16 +68728,21 @@ module.exports = class exmo extends Exchange { return { 'info': transaction, 'id': undefined, + 'timestamp': timestamp, + 'datetime': this.iso8601 (timestamp), 'currency': code, 'amount': amount, 'address': address, - 'tag': undefined, // refix it properly + 'addressTo': address, + 'addressFrom': undefined, + 'tag': tag, + 'tagTo': tag, + 'tagFrom': undefined, 'status': status, 'type': type, 'updated': undefined, + 'comment': comment, 'txid': txid, - 'timestamp': timestamp, - 'datetime': this.iso8601 (timestamp), 'fee': fee, }; } @@ -63634,7 +68854,7 @@ module.exports = class exmo extends Exchange { } }; -},{"./base/Exchange":5,"./base/errors":7}],80:[function(require,module,exports){ +},{"./base/Exchange":6,"./base/errors":8}],83:[function(require,module,exports){ 'use strict'; // --------------------------------------------------------------------------- @@ -63963,6 +69183,7 @@ module.exports = class exx extends Exchange { 'symbol': symbol, 'type': 'limit', 'timeInForce': undefined, + 'postOnly': undefined, 'side': order['type'], 'price': price, 'stopPrice': undefined, @@ -64024,7 +69245,7 @@ module.exports = class exx extends Exchange { async fetchOpenOrders (symbol = undefined, since = undefined, limit = undefined, params = {}) { await this.loadMarkets (); if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' fetchOpenOrders requires a symbol argument'); + throw new ArgumentsRequired (this.id + ' fetchOpenOrders() requires a symbol argument'); } const market = this.market (symbol); const request = { @@ -64099,7 +69320,7 @@ module.exports = class exx extends Exchange { } }; -},{"./base/Exchange":5,"./base/errors":7}],81:[function(require,module,exports){ +},{"./base/Exchange":6,"./base/errors":8}],84:[function(require,module,exports){ 'use strict'; // --------------------------------------------------------------------------- @@ -64694,6 +69915,7 @@ module.exports = class fcoin extends Exchange { 'symbol': symbol, 'type': orderType, 'timeInForce': undefined, + 'postOnly': undefined, 'side': side, 'price': price, 'stopPrice': undefined, @@ -64843,7 +70065,7 @@ module.exports = class fcoin extends Exchange { } }; -},{"./base/Exchange":5,"./base/errors":7}],82:[function(require,module,exports){ +},{"./base/Exchange":6,"./base/errors":8}],85:[function(require,module,exports){ 'use strict'; // --------------------------------------------------------------------------- @@ -64869,7 +70091,7 @@ module.exports = class fcoinjp extends fcoin { } }; -},{"./fcoin.js":81}],83:[function(require,module,exports){ +},{"./fcoin.js":84}],86:[function(require,module,exports){ 'use strict'; // --------------------------------------------------------------------------- @@ -65118,7 +70340,7 @@ module.exports = class flowbtc extends Exchange { }; return await this.privatePostCancelOrder (this.extend (request, params)); } - throw new ExchangeError (this.id + ' requires `ins` symbol parameter for cancelling an order'); + throw new ExchangeError (this.id + ' cancelOrder() requires an `ins` symbol parameter for cancelling an order'); } sign (path, api = 'public', method = 'GET', params = {}, headers = undefined, body = undefined) { @@ -65155,7 +70377,7 @@ module.exports = class flowbtc extends Exchange { } }; -},{"./base/Exchange":5,"./base/errors":7}],84:[function(require,module,exports){ +},{"./base/Exchange":6,"./base/errors":8}],87:[function(require,module,exports){ 'use strict'; // --------------------------------------------------------------------------- @@ -65420,14 +70642,14 @@ module.exports = class foxbit extends Exchange { } }; -},{"./base/Exchange":5,"./base/errors":7}],85:[function(require,module,exports){ +},{"./base/Exchange":6,"./base/errors":8}],88:[function(require,module,exports){ 'use strict'; // --------------------------------------------------------------------------- const Exchange = require ('./base/Exchange'); const { TICK_SIZE } = require ('./base/functions/number'); -const { ExchangeError, InvalidOrder, BadRequest, InsufficientFunds, OrderNotFound, AuthenticationError } = require ('./base/errors'); +const { ExchangeError, InvalidOrder, BadRequest, InsufficientFunds, OrderNotFound, AuthenticationError, RateLimitExceeded, ExchangeNotAvailable, CancelPending } = require ('./base/errors'); // --------------------------------------------------------------------------- @@ -65437,7 +70659,7 @@ module.exports = class ftx extends Exchange { 'id': 'ftx', 'name': 'FTX', 'countries': [ 'HK' ], - 'rateLimit': 100, + 'rateLimit': 50, 'certified': true, 'pro': true, 'hostname': 'ftx.com', // or ftx.us @@ -65522,9 +70744,12 @@ module.exports = class ftx extends Exchange { 'wallet/coins', 'wallet/balances', 'wallet/all_balances', - 'wallet/deposit_address/{coin}', + 'wallet/deposit_address/{coin}', // ?method={method} 'wallet/deposits', 'wallet/withdrawals', + 'wallet/withdrawal_fee', + 'wallet/airdrops', + 'wallet/saved_addresses', 'orders', // ?market={market} 'orders/history', // ?market={market} 'orders/{order_id}', @@ -65532,6 +70757,14 @@ module.exports = class ftx extends Exchange { 'conditional_orders', // ?market={market} 'conditional_orders/{conditional_order_id}/triggers', 'conditional_orders/history', // ?market={market} + 'spot_margin/borrow_rates', + 'spot_margin/lending_rates', + 'spot_margin/borrow_summary', + 'spot_margin/market_info', // ?market={market} + 'spot_margin/borrow_history', + 'spot_margin/lending_history', + 'spot_margin/offers', + 'spot_margin/lending_info', 'fills', // ?market={market} 'funding_payments', // leverage tokens @@ -65550,15 +70783,23 @@ module.exports = class ftx extends Exchange { 'options/account_info', 'options/positions', 'options/fills', + // staking + 'staking/stakes', + 'staking/unstake_requests', + 'staking/balances', + 'staking/staking_rewards', ], 'post': [ 'account/leverage', 'wallet/withdrawals', + 'wallet/saved_addresses', 'orders', 'conditional_orders', 'orders/{order_id}/modify', 'orders/by_client_id/{client_order_id}/modify', 'conditional_orders/{order_id}/modify', + // spot margin + 'spot_margin/offers', // leverage tokens 'lt/{token_name}/create', 'lt/{token_name}/redeem', @@ -65573,8 +70814,12 @@ module.exports = class ftx extends Exchange { 'options/requests', 'options/requests/{request_id}/quotes', 'options/quotes/{quote_id}/accept', + // staking + 'staking/unstake_requests', + 'srm_stakes/stakes', ], 'delete': [ + 'wallet/saved_addresses/{saved_address_id}', 'orders/{order_id}', 'orders/by_client_id/{client_order_id}', 'orders', @@ -65584,6 +70829,8 @@ module.exports = class ftx extends Exchange { // options 'options/requests/{request_id}', 'options/quotes/{quote_id}', + // staking + 'staking/unstake_requests/{request_id}', ], }, }, @@ -65618,6 +70865,8 @@ module.exports = class ftx extends Exchange { }, 'exceptions': { 'exact': { + 'Please slow down': RateLimitExceeded, // {"error":"Please slow down","success":false} + 'Size too small for provide': InvalidOrder, // {"error":"Size too small for provide","success":false} 'Not logged in': AuthenticationError, // {"error":"Not logged in","success":false} 'Not enough balances': InsufficientFunds, // {"error":"Not enough balances","success":false} 'InvalidPrice': InvalidOrder, // {"error":"Invalid price","success":false} @@ -65625,13 +70874,20 @@ module.exports = class ftx extends Exchange { 'Missing parameter price': InvalidOrder, // {"error":"Missing parameter price","success":false} 'Order not found': OrderNotFound, // {"error":"Order not found","success":false} 'Order already closed': InvalidOrder, // {"error":"Order already closed","success":false} + 'Trigger price too high': InvalidOrder, // {"error":"Trigger price too high","success":false} + 'Trigger price too low': InvalidOrder, // {"error":"Trigger price too low","success":false} + 'Order already queued for cancellation': CancelPending, // {"error":"Order already queued for cancellation","success":false} }, 'broad': { + 'Account does not have enough margin for order': InsufficientFunds, 'Invalid parameter': BadRequest, // {"error":"Invalid parameter start_time","success":false} 'The requested URL was not found on the server': BadRequest, 'No such coin': BadRequest, 'No such market': BadRequest, - 'An unexpected error occurred': ExchangeError, // {"error":"An unexpected error occurred, please try again later (58BC21C795).","success":false} + 'Do not send more than': RateLimitExceeded, + 'An unexpected error occurred': ExchangeNotAvailable, // {"error":"An unexpected error occurred, please try again later (58BC21C795).","success":false} + 'Please retry request': ExchangeNotAvailable, // {"error":"Please retry request","success":false} + 'Please try again': ExchangeNotAvailable, // {"error":"Please try again","success":false} }, }, 'precisionMode': TICK_SIZE, @@ -65761,7 +71017,7 @@ module.exports = class ftx extends Exchange { 'amount': sizeIncrement, 'price': priceIncrement, }; - const entry = { + result.push ({ 'id': id, 'symbol': symbol, 'base': base, @@ -65788,8 +71044,7 @@ module.exports = class ftx extends Exchange { }, }, 'info': market, - }; - result.push (entry); + }); } return result; } @@ -66088,22 +71343,39 @@ module.exports = class ftx extends Exchange { // "type": "order" // } // + // { + // "baseCurrency": "BTC", + // "fee": 0, + // "feeCurrency": "USD", + // "feeRate": 0, + // "future": null, + // "id": 664079556, + // "liquidity": "taker", + // "market": null, + // "orderId": null, + // "price": 34830.61359, + // "quoteCurrency": "USD", + // "side": "sell", + // "size": 0.0005996, + // "time": "2021-01-15T16:05:29.246135+00:00", + // "tradeId": null, + // "type": "otc" + // } + // const id = this.safeString (trade, 'id'); const takerOrMaker = this.safeString (trade, 'liquidity'); const marketId = this.safeString (trade, 'market'); let symbol = undefined; - if (marketId !== undefined) { - if (marketId in this.markets_by_id) { - market = this.markets_by_id[marketId]; - symbol = market['symbol']; + if (marketId in this.markets_by_id) { + market = this.markets_by_id[marketId]; + symbol = market['symbol']; + } else { + const base = this.safeCurrencyCode (this.safeString (trade, 'baseCurrency')); + const quote = this.safeCurrencyCode (this.safeString (trade, 'quoteCurrency')); + if ((base !== undefined) && (quote !== undefined)) { + symbol = base + '/' + quote; } else { - const base = this.safeCurrencyCode (this.safeString (trade, 'baseCurrency')); - const quote = this.safeCurrencyCode (this.safeString (trade, 'quoteCurrency')); - if ((base !== undefined) && (quote !== undefined)) { - symbol = base + '/' + quote; - } else { - symbol = marketId; - } + symbol = marketId; } } const timestamp = this.parse8601 (this.safeString (trade, 'time')); @@ -66421,6 +71693,7 @@ module.exports = class ftx extends Exchange { const lastTradeTimestamp = this.parse8601 (this.safeString (order, 'triggeredAt')); const clientOrderId = this.safeString (order, 'clientId'); const stopPrice = this.safeFloat (order, 'triggerPrice'); + const postOnly = this.safeValue (order, 'postOnly'); return { 'info': order, 'id': id, @@ -66431,6 +71704,7 @@ module.exports = class ftx extends Exchange { 'symbol': symbol, 'type': type, 'timeInForce': undefined, + 'postOnly': postOnly, 'side': side, 'price': price, 'stopPrice': stopPrice, @@ -66568,12 +71842,12 @@ module.exports = class ftx extends Exchange { } } else { if (clientOrderId === undefined) { + method = 'privatePostOrdersOrderIdModify'; + request['order_id'] = id; + } else { method = 'privatePostOrdersByClientIdClientOrderIdModify'; request['client_order_id'] = clientOrderId; // request['clientId'] = clientOrderId; - } else { - method = 'privatePostOrdersOrderIdModify'; - request['order_id'] = id; } if (price !== undefined) { request['price'] = parseFloat (this.priceToPrecision (symbol, price)); @@ -66639,9 +71913,7 @@ module.exports = class ftx extends Exchange { async cancelOrder (id, symbol = undefined, params = {}) { await this.loadMarkets (); - const request = { - 'order_id': parseInt (id), - }; + const request = {}; // support for canceling conditional orders // https://github.com/ccxt/ccxt/issues/6669 const options = this.safeValue (this.options, 'cancelOrder', {}); @@ -66674,8 +71946,8 @@ module.exports = class ftx extends Exchange { await this.loadMarkets (); const request = { // 'market': market['id'], // optional - 'conditionalOrdersOnly': false, // cancel conditional orders only - 'limitOrdersOnly': false, // cancel existing limit orders (non-conditional orders) only + // 'conditionalOrdersOnly': false, // cancel conditional orders only + // 'limitOrdersOnly': false, // cancel existing limit orders (non-conditional orders) only }; const marketId = this.getMarketId (symbol, 'market', params); if (marketId !== undefined) { @@ -66844,6 +72116,7 @@ module.exports = class ftx extends Exchange { } if (since !== undefined) { request['start_time'] = parseInt (since / 1000); + request['end_time'] = this.seconds (); } const response = await this.privateGetFills (this.extend (request, params)); // @@ -67033,6 +72306,15 @@ module.exports = class ftx extends Exchange { // "txid": "0x8078356ae4b06a036d64747546c274af19581f1c78c510b60505798a7ffcaf1" // } // + // { + // "coin": 'BTC', + // "id": 1969806, + // "notes": 'Transfer to Dd6gi7m2Eg4zzBbPAxuwfEaHs6tYvyUX5hbPpsTcNPXo', + // "size": 0.003, + // "status": 'complete', + // "time": '2021-02-03T20:28:54.918146+00:00' + // } + // const code = this.safeCurrencyCode (this.safeString (transaction, 'coin')); const id = this.safeString (transaction, 'id'); const amount = this.safeFloat (transaction, 'size'); @@ -67045,8 +72327,14 @@ module.exports = class ftx extends Exchange { tag = this.safeString (address, 'tag'); address = this.safeString (address, 'address'); } + if (address === undefined) { + // parse address from internal transfer + const notes = this.safeString (transaction, 'notes'); + if (notes !== undefined) { + address = notes.slice (12); + } + } const fee = this.safeFloat (transaction, 'fee'); - const type = ('destinationName' in transaction) ? 'withdrawal' : 'deposit'; return { 'info': transaction, 'id': id, @@ -67059,7 +72347,7 @@ module.exports = class ftx extends Exchange { 'tagFrom': undefined, 'tag': tag, 'tagTo': tag, - 'type': type, + 'type': undefined, 'amount': amount, 'currency': code, 'status': status, @@ -67097,7 +72385,7 @@ module.exports = class ftx extends Exchange { if (code !== undefined) { currency = this.currency (code); } - return this.parseTransactions (result, currency, since, limit); + return this.parseTransactions (result, currency, since, limit, { 'type': 'deposit' }); } async fetchWithdrawals (code = undefined, since = undefined, limit = undefined, params = {}) { @@ -67124,7 +72412,7 @@ module.exports = class ftx extends Exchange { if (code !== undefined) { currency = this.currency (code); } - return this.parseTransactions (result, currency, since, limit); + return this.parseTransactions (result, currency, since, limit, { 'type': 'withdrawal' }); } sign (path, api = 'public', method = 'GET', params = {}, headers = undefined, body = undefined) { @@ -67181,7 +72469,7 @@ module.exports = class ftx extends Exchange { } }; -},{"./base/Exchange":5,"./base/errors":7,"./base/functions/number":13}],86:[function(require,module,exports){ +},{"./base/Exchange":6,"./base/errors":8,"./base/functions/number":14}],89:[function(require,module,exports){ 'use strict'; // --------------------------------------------------------------------------- @@ -67351,6 +72639,7 @@ module.exports = class gateio extends Exchange { 'BOX': 'DefiBox', 'BTCBEAR': 'BEAR', 'BTCBULL': 'BULL', + 'SBTC': 'Super Bitcoin', 'TNC': 'Trinity Network Credit', }, }); @@ -67874,6 +73163,7 @@ module.exports = class gateio extends Exchange { 'symbol': symbol, 'type': 'limit', 'timeInForce': undefined, + 'postOnly': undefined, 'side': side, 'price': price, 'stopPrice': undefined, @@ -67914,7 +73204,7 @@ module.exports = class gateio extends Exchange { async cancelOrder (id, symbol = undefined, params = {}) { if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' cancelOrder requires symbol argument'); + throw new ArgumentsRequired (this.id + ' cancelOrder() requires symbol argument'); } await this.loadMarkets (); const request = { @@ -67937,13 +73227,13 @@ module.exports = class gateio extends Exchange { if ((address !== undefined) && (address.indexOf ('address') >= 0)) { throw new InvalidAddress (this.id + ' queryDepositAddress ' + address); } - if (code === 'XRP') { + if ((code === 'XRP') || (code === 'HBAR') || (code === 'STEEM') || (code === 'XLM') || (code === 'EOS')) { const parts = address.split (' '); address = parts[0]; tag = parts[1]; } return { - 'currency': currency, + 'currency': code, 'address': address, 'tag': tag, 'info': response, @@ -67970,7 +73260,7 @@ module.exports = class gateio extends Exchange { async fetchOrderTrades (id, symbol = undefined, since = undefined, limit = undefined, params = {}) { if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' fetchMyTrades requires a symbol argument'); + throw new ArgumentsRequired (this.id + ' fetchOrderTrades() requires a symbol argument'); } await this.loadMarkets (); const market = this.market (symbol); @@ -67984,7 +73274,7 @@ module.exports = class gateio extends Exchange { async fetchMyTrades (symbol = undefined, since = undefined, limit = undefined, params = {}) { if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' fetchMyTrades requires symbol argument'); + throw new ArgumentsRequired (this.id + ' fetchMyTrades() requires symbol argument'); } await this.loadMarkets (); const market = this.market (symbol); @@ -68066,21 +73356,21 @@ module.exports = class gateio extends Exchange { // withdrawal // // { - // 'id': 'w5864259', - // 'currency': 'ETH', - // 'address': '0x72632f462....', - // 'amount': '0.4947', - // 'txid': '0x111167d120f736....', - // 'timestamp': '1553123688', - // 'status': 'DONE', - // 'type': 'withdrawal' - // } + // "id": "w6754336", + // "fee": "0.1", + // "txid": "zzyy", + // "amount": "1", + // "status": "DONE", + // "address": "tz11234", + // "currency": "XTZ", + // "timestamp": "1561030206" + // } // const currencyId = this.safeString (transaction, 'currency'); const code = this.safeCurrencyCode (currencyId, currency); const id = this.safeString (transaction, 'id'); const txid = this.safeString (transaction, 'txid'); - const amount = this.safeFloat (transaction, 'amount'); + let amount = this.safeFloat (transaction, 'amount'); let address = this.safeString (transaction, 'address'); if (address === 'false') { address = undefined; @@ -68088,6 +73378,17 @@ module.exports = class gateio extends Exchange { const timestamp = this.safeTimestamp (transaction, 'timestamp'); const status = this.parseTransactionStatus (this.safeString (transaction, 'status')); const type = this.parseTransactionType (id[0]); + const feeCost = this.safeFloat (transaction, 'fee'); + let fee = undefined; + if (feeCost !== undefined) { + fee = { + 'currency': code, + 'cost': feeCost, + }; + if (amount !== undefined) { + amount = amount - feeCost; + } + } return { 'info': transaction, 'id': id, @@ -68100,7 +73401,7 @@ module.exports = class gateio extends Exchange { 'type': type, 'timestamp': timestamp, 'datetime': this.iso8601 (timestamp), - 'fee': undefined, + 'fee': fee, }; } @@ -68166,7 +73467,7 @@ module.exports = class gateio extends Exchange { } }; -},{"./base/Exchange":5,"./base/errors":7}],87:[function(require,module,exports){ +},{"./base/Exchange":6,"./base/errors":8}],90:[function(require,module,exports){ 'use strict'; // --------------------------------------------------------------------------- @@ -68838,6 +74139,7 @@ module.exports = class gemini extends Exchange { 'symbol': symbol, 'type': type, 'timeInForce': undefined, + 'postOnly': undefined, 'side': side, 'price': price, 'stopPrice': undefined, @@ -68901,7 +74203,7 @@ module.exports = class gemini extends Exchange { async fetchMyTrades (symbol = undefined, since = undefined, limit = undefined, params = {}) { if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' fetchMyTrades requires a symbol argument'); + throw new ArgumentsRequired (this.id + ' fetchMyTrades() requires a symbol argument'); } await this.loadMarkets (); const market = this.market (symbol); @@ -69078,7 +74380,1356 @@ module.exports = class gemini extends Exchange { } }; -},{"./base/Exchange":5,"./base/errors":7,"./base/functions/number":13}],88:[function(require,module,exports){ +},{"./base/Exchange":6,"./base/errors":8,"./base/functions/number":14}],91:[function(require,module,exports){ +'use strict'; + +// --------------------------------------------------------------------------- + +const Exchange = require ('./base/Exchange'); +const { ExchangeError, InvalidOrder, AuthenticationError, InsufficientFunds, BadSymbol, OrderNotFound, InvalidAddress, BadRequest } = require ('./base/errors'); +const { TRUNCATE, ROUND, TICK_SIZE } = require ('./base/functions/number'); + +// --------------------------------------------------------------------------- + +module.exports = class gopax extends Exchange { + describe () { + return this.deepExtend (super.describe (), { + 'id': 'gopax', + 'name': 'GOPAX', + 'countries': [ 'KR' ], // South Korea + 'version': 'v1', + 'rateLimit': 50, + 'hostname': 'gopax.co.kr', // or 'gopax.com' + 'certified': true, + 'pro': true, + 'has': { + 'cancelOrder': true, + 'createMarketOrder': true, + 'createOrder': true, + 'fetchBalance': true, + 'fetchCurrencies': true, + 'fetchDepositAddress': 'emulated', + 'fetchDepositAddresses': true, + 'fetchMarkets': true, + 'fetchMyTrades': true, + 'fetchOHLCV': true, + 'fetchOpenOrders': true, + 'fetchOrder': true, + 'fetchOrderBook': true, + 'fetchOrders': true, + 'fetchTicker': true, + 'fetchTickers': true, + 'fetchTime': true, + 'fetchTrades': true, + 'fetchTransactions': true, + }, + 'timeframes': { + '1m': '1', + '5m': '5', + '30m': '30', + '1d': '1440', + }, + 'urls': { + 'logo': 'https://user-images.githubusercontent.com/1294454/102897212-ae8a5e00-4478-11eb-9bab-91507c643900.jpg', + 'api': { + 'public': 'https://api.{hostname}', // or 'https://api.gopax.co.kr' + 'private': 'https://api.{hostname}', + }, + 'www': 'https://www.gopax.co.kr', + 'doc': 'https://gopax.github.io/API/index.en.html', + 'fees': 'https://www.gopax.com/feeinfo', + }, + 'api': { + 'public': { + 'get': [ + 'notices', + 'assets', + 'price-tick-size', + 'trading-pairs', + 'trading-pairs/{tradingPair}/ticker', + 'trading-pairs/{tradingPair}/book', + 'trading-pairs/{tradingPair}/trades', + 'trading-pairs/{tradingPair}/stats', + 'trading-pairs/{tradingPair}/price-tick-size', + 'trading-pairs/stats', + 'trading-pairs/{tradingPair}/candles', + 'time', + ], + }, + 'private': { + 'get': [ + 'balances', + 'balances/{assetName}', + 'orders', + 'orders/{orderId}', + 'orders/clientOrderId/{clientOrderId}', + 'trades', + 'deposit-withdrawal-status', + 'crypto-deposit-addresses', + 'crypto-withdrawal-addresses', + ], + 'post': [ + 'orders', + ], + 'delete': [ + 'orders/{orderId}', + 'orders/clientOrderId/{clientOrderId}', + ], + }, + }, + 'fees': { + 'trading': { + 'percentage': true, + 'tierBased': false, + 'maker': 0.04 / 100, + 'taker': 0.04 / 100, + }, + }, + 'exceptions': { + 'broad': { + 'ERROR_INVALID_ORDER_TYPE': InvalidOrder, + 'ERROR_INVALID_AMOUNT': InvalidOrder, + 'ERROR_INVALID_TRADING_PAIR': BadSymbol, // Unlikely to be triggered, due to ccxt.gopax.js implementation + 'No such order ID': OrderNotFound, // {"errorMessage":"No such order ID","errorCode":202,"errorData":"Order server error: 202"} + // 'Not enough amount': InsufficientFunds, // {"errorMessage":"Not enough amount, try increasing your order amount","errorCode":10212,"errorData":{}} + 'Forbidden order type': InvalidOrder, + 'the client order ID will be reusable which order has already been completed or canceled': InvalidOrder, + 'ERROR_NO_SUCH_TRADING_PAIR': BadSymbol, // Unlikely to be triggered, due to ccxt.gopax.js implementation + 'ERROR_INVALID_ORDER_SIDE': InvalidOrder, + 'ERROR_NOT_HEDGE_TOKEN_USER': InvalidOrder, + 'ORDER_EVENT_ERROR_NOT_ALLOWED_BID_ORDER': InvalidOrder, // Triggered only when the exchange is locked + 'ORDER_EVENT_ERROR_INSUFFICIENT_BALANCE': InsufficientFunds, + 'Invalid option combination': InvalidOrder, + 'No such client order ID': OrderNotFound, + }, + 'exact': { + '100': BadSymbol, // Invalid asset name + '101': BadSymbol, // Invalid trading pair + '103': InvalidOrder, // Invalid order type + '104': BadSymbol, // Invalid trading pair + '105': BadSymbol, // Trading pair temporarily disabled + '106': BadSymbol, // Invalid asset name + '107': InvalidOrder, // Invalid order amount + '108': InvalidOrder, // Invalid order price + '111': InvalidOrder, // Invalid event type + '201': InsufficientFunds, // Not enough balance + '202': InvalidOrder, // Invalid order ID + '203': InvalidOrder, // Order amount X order price too large + '204': InvalidOrder, // Bid order temporarily unavailable + '205': InvalidOrder, // Invalid side + '206': InvalidOrder, // Invalid order option combination + '10004': AuthenticationError, // Not authorized + // '10004': ExchangeError, // API key not exist + // '10004': ExchangeError, // User KYC not approved + // '10004': ExchangeError, // User account is frozen + // '10004': ExchangeError, // User is under deactivation process + // '10004': ExchangeError, // 2FA is not enabled + // '10004': ExchangeError, // Invalid signature + '10041': BadRequest, // Invalid exchange + '10056': BadRequest, // No registered asset + '10057': BadSymbol, // No registered trading pair + '10059': BadSymbol, // Invalid trading pair + '10062': BadRequest, // Invalid chart interval + '10069': OrderNotFound, // {"errorMessage":"No such order ID: 73152094","errorCode":10069,"errorData":"73152094"} + '10155': AuthenticationError, // {"errorMessage":"Invalid API key","errorCode":10155} + '10166': BadRequest, // Invalid chart range + '10212': InvalidOrder, // {"errorMessage":"Not enough amount, try increasing your order amount","errorCode":10212,"errorData":{}} + '10221': OrderNotFound, // No such client order ID + '10222': InvalidOrder, // Client order ID being used + '10223': InvalidOrder, // Soon the client order ID will be reusable which order has already been completed or canceled + '10227': InvalidOrder, // Invalid client order ID format + '10319': BadRequest, // Pagination is required as you have too many orders + '10358': InvalidOrder, // Invalid order type + '10359': InvalidOrder, // Invalid order side + '10360': InvalidOrder, // Invalid order status + '10361': InvalidOrder, // Invalid order time in force + '10362': InvalidOrder, // Invalid order protection + '10363': InvalidOrder, // Invalid forced completion reason + }, + }, + 'options': { + 'createMarketBuyOrderRequiresPrice': true, + }, + }); + } + + async fetchTime (params = {}) { + const response = await this.publicGetTime (params); + // + // {"serverTime":1608327726656} + // + return this.safeInteger (response, 'serverTime'); + } + + async fetchMarkets (params = {}) { + const response = await this.publicGetTradingPairs (params); + // + // [ + // { + // "id":1, + // "name":"ETH-KRW", + // "baseAsset":"ETH", + // "quoteAsset":"KRW", + // "baseAssetScale":8, + // "quoteAssetScale":0, + // "priceMin":1, + // "restApiOrderAmountMin":{ + // "limitAsk":{"amount":10000,"unit":"KRW"}, + // "limitBid":{"amount":10000,"unit":"KRW"}, + // "marketAsk":{"amount":0.001,"unit":"ETH"}, + // "marketBid":{"amount":10000,"unit":"KRW"}, + // }, + // "makerFeePercent":0.2, + // "takerFeePercent":0.2, + // }, + // ] + // + const result = []; + for (let i = 0; i < response.length; i++) { + const market = response[i]; + const id = this.safeString (market, 'name'); + const numericId = this.safeInteger (market, 'id'); + const baseId = this.safeString (market, 'baseAsset'); + const quoteId = this.safeString (market, 'quoteAsset'); + const base = this.safeCurrencyCode (baseId); + const quote = this.safeCurrencyCode (quoteId); + const symbol = base + '/' + quote; + const precision = { + 'price': this.safeInteger (market, 'quoteAssetScale'), + 'amount': this.safeInteger (market, 'baseAssetScale'), + }; + const minimums = this.safeValue (market, 'restApiOrderAmountMin', {}); + const marketAsk = this.safeValue (minimums, 'marketAsk', {}); + const marketBid = this.safeValue (minimums, 'marketBid', {}); + const takerFeePercent = this.safeFloat (market, 'takerFeePercent'); + const makerFeePercent = this.safeFloat (market, 'makerFeePercent'); + const taker = parseFloat (this.decimalToPrecision (takerFeePercent / 100, ROUND, 0.00000001, TICK_SIZE)); + const maker = parseFloat (this.decimalToPrecision (makerFeePercent / 100, ROUND, 0.00000001, TICK_SIZE)); + result.push ({ + 'id': id, + 'info': market, + 'numericId': numericId, + 'symbol': symbol, + 'base': base, + 'quote': quote, + 'baseId': this.safeString (market, 'baseAsset'), + 'quoteId': this.safeString (market, 'quoteAsset'), + 'active': true, + 'taker': taker, + 'maker': maker, + 'precision': precision, + 'limits': { + 'amount': { + 'min': this.safeFloat (marketAsk, 'amount'), + 'max': undefined, + }, + 'price': { + 'min': this.safeFloat (market, 'priceMin'), + 'max': undefined, + }, + 'cost': { + 'min': this.safeFloat (marketBid, 'amount'), + 'max': undefined, + }, + }, + }); + } + return result; + } + + async fetchCurrencies (params = {}) { + const response = await this.publicGetAssets (params); + // + // [ + // { + // "id":"KRW", + // "name":"대한민국 원", + // "scale":0, + // "withdrawalFee":1000, + // "withdrawalAmountMin":5000 + // }, + // { + // "id":"ETH", + // "name":"이더리움", + // "scale":8, + // "withdrawalFee":0.03, + // "withdrawalAmountMin":0.015 + // }, + // ] + // + const result = {}; + for (let i = 0; i < response.length; i++) { + const currency = response[i]; + const id = this.safeString (currency, 'id'); + const code = this.safeCurrencyCode (id); + const name = this.safeString (currency, 'name'); + const fee = this.safeFloat (currency, 'withdrawalFee'); + const precision = this.safeFloat (currency, 'scale'); + result[code] = { + 'id': id, + 'info': currency, + 'code': code, + 'name': name, + 'active': true, + 'fee': fee, + 'precision': precision, + 'limits': { + 'amount': { + 'min': undefined, + 'max': undefined, + }, + 'price': { + 'min': undefined, + 'max': undefined, + }, + 'cost': { + 'min': undefined, + 'max': undefined, + }, + 'withdraw': { + 'min': this.safeFloat (currency, 'withdrawalAmountMin'), + 'max': undefined, + }, + }, + }; + } + return result; + } + + async fetchOrderBook (symbol, limit = undefined, params = {}) { + await this.loadMarkets (); + const market = this.market (symbol); + const request = { + 'tradingPair': market['id'], + // 'level': 3, // 1 best bidask, 2 top 50 bidasks, 3 all bidasks + }; + const response = await this.publicGetTradingPairsTradingPairBook (this.extend (request, params)); + // + // { + // "sequence":17691957, + // "bid":[ + // ["17690499",25019000,0.00008904,"1608326468921"], + // ["17691894",25010000,0.4295,"1608326499940"], + // ["17691895",25009000,0.2359,"1608326499953"], + // ], + // "ask":[ + // ["17689176",25024000,0.000098,"1608326442006"], + // ["17691351",25031000,0.206,"1608326490418"], + // ["17691571",25035000,0.3996,"1608326493742"], + // ] + // } + // + const nonce = this.safeInteger (response, 'sequence'); + const result = this.parseOrderBook (response, undefined, 'bid', 'ask', 1, 2); + result['nonce'] = nonce; + return result; + } + + parseTicker (ticker, market = undefined) { + // + // fetchTicker + // + // { + // "price":25087000, + // "ask":25107000, + // "askVolume":0.05837704, + // "bid":25087000, + // "bidVolume":0.00398628, + // "volume":350.09171591, + // "quoteVolume":8721016926.06529, + // "time":"2020-12-18T21:42:13.774Z", + // } + // + // fetchTickers + // + // { + // "name":"ETH-KRW", + // "open":690500, + // "high":719500, + // "low":681500, + // "close":709500, + // "volume":2784.6081544, + // "time":"2020-12-18T21:54:50.795Z" + // } + // + const marketId = this.safeString (ticker, 'name'); + const symbol = this.safeSymbol (marketId, market, '-'); + const timestamp = this.parse8601 (this.safeString (ticker, 'time')); + const open = this.safeFloat (ticker, 'open'); + const last = this.safeFloat2 (ticker, 'price', 'close'); + let change = undefined; + let percentage = undefined; + let average = undefined; + if ((last !== undefined) && (open !== undefined)) { + average = this.sum (last, open) / 2; + change = last - open; + if (open > 0) { + percentage = change / open * 100; + } + } + const baseVolume = this.safeFloat (ticker, 'volume'); + const quoteVolume = this.safeFloat (ticker, 'quoteVolume'); + const vwap = this.vwap (baseVolume, quoteVolume); + return { + 'symbol': symbol, + 'info': ticker, + 'timestamp': timestamp, + 'datetime': this.iso8601 (timestamp), + 'high': this.safeFloat (ticker, 'high'), + 'low': this.safeFloat (ticker, 'low'), + 'bid': this.safeFloat (ticker, 'bid'), + 'bidVolume': this.safeFloat (ticker, 'bidVolume'), + 'ask': this.safeFloat (ticker, 'ask'), + 'askVolume': this.safeFloat (ticker, 'askVolume'), + 'vwap': vwap, + 'open': open, + 'close': last, + 'last': last, + 'previousClose': undefined, + 'change': change, + 'percentage': percentage, + 'average': average, + 'baseVolume': baseVolume, + 'quoteVolume': quoteVolume, + }; + } + + async fetchTicker (symbol, params = {}) { + await this.loadMarkets (); + const market = this.market (symbol); + const request = { + 'tradingPair': market['id'], + }; + const response = await this.publicGetTradingPairsTradingPairTicker (this.extend (request, params)); + // + // { + // "price":25087000, + // "ask":25107000, + // "askVolume":0.05837704, + // "bid":25087000, + // "bidVolume":0.00398628, + // "volume":350.09171591, + // "quoteVolume":8721016926.06529, + // "time":"2020-12-18T21:42:13.774Z", + // } + // + return this.parseTicker (response, market); + } + + parseTickers (rawTickers, symbols = undefined) { + const tickers = []; + for (let i = 0; i < rawTickers.length; i++) { + tickers.push (this.parseTicker (rawTickers[i])); + } + return this.filterByArray (tickers, 'symbol', symbols); + } + + async fetchTickers (symbols = undefined, params = {}) { + await this.loadMarkets (); + const response = await this.publicGetTradingPairsStats (params); + // + // [ + // { + // "name":"ETH-KRW", + // "open":690500, + // "high":719500, + // "low":681500, + // "close":709500, + // "volume":2784.6081544, + // "time":"2020-12-18T21:54:50.795Z" + // } + // ] + // + return this.parseTickers (response, symbols); + } + + parsePublicTrade (trade, market = undefined) { + const timestamp = this.parse8601 (this.safeString (trade, 'time')); + const price = this.safeFloat (trade, 'price'); + const amount = this.safeFloat (trade, 'amount'); + let symbol = undefined; + if ('symbol' in market) { + symbol = this.safeString (market, 'symbol'); + } + return { + 'info': trade, + 'id': this.safeString (trade, 'id'), + 'timestamp': timestamp, + 'datetime': this.iso8601 (timestamp), + 'symbol': symbol, + 'order': undefined, // Not mandatory to specify + 'type': undefined, // Not mandatory to specify + 'side': this.safeString (trade, 'side'), + 'takerOrMaker': undefined, + 'price': price, + 'amount': amount, + 'cost': price * amount, + 'fee': undefined, + }; + } + + parsePrivateTrade (trade, market = undefined) { + const timestamp = this.parse8601 (this.safeString (trade, 'timestamp')); + const symbol = this.safeString (trade, 'tradingPairName').replace ('-', '/'); + const side = this.safeString (trade, 'side'); + const price = this.safeFloat (trade, 'price'); + const amount = this.safeFloat (trade, 'baseAmount'); + let feeCurrency = symbol.slice (0, 3); + if (side === 'sell') { + feeCurrency = symbol.slice (4); + } + const fee = { + 'cost': this.safeFloat (trade, 'fee'), + 'currency': feeCurrency, + 'rate': undefined, + }; + return { + 'info': trade, + 'id': this.safeString (trade, 'id'), + 'timestamp': timestamp, + 'datetime': this.iso8601 (timestamp), + 'symbol': symbol, + 'order': this.safeInteger (trade, 'orderId'), + 'type': undefined, + 'side': side, + 'takerOrMaker': this.safeString (trade, 'position'), + 'price': price, + 'amount': amount, + 'cost': price * amount, + 'fee': fee, + }; + } + + parseTrade (trade, market = undefined) { + // + // public fetchTrades + // + // { + // "time":"2020-12-19T12:17:43.000Z", + // "date":1608380263, + // "id":23903608, + // "price":25155000, + // "amount":0.0505, + // "side":"sell", + // } + // + // private fetchMyTrades + // + // { + // "id": 73953, // trading event ID + // "orderId": 453324, // order ID + // "baseAmount": 3, // traded base asset amount + // "quoteAmount": 3000000, // traded quote asset amount + // "fee": 0.0012, // fee + // "price": 1000000, // price + // "timestamp": "2020-09-25T04:06:30.000Z", // trading time + // "side": "buy", // buy, sell + // "tradingPairName": "ZEC-KRW", // order book + // "position": "maker" // maker, taker + // } + // + // { + // "tradeId": 74072, // trade ID + // "orderId": 453529, // order ID + // "side": 2, // 1(bid), 2(ask) + // "type": 1, // 1(limit), 2(market) + // "baseAmount": 0.01, // filled base asset amount (in ZEC for this case) + // "quoteAmount": 1, // filled quote asset amount (in KRW for this case) + // "fee": 0.0004, // fee + // "price": 100, // price + // "isSelfTrade": false, // whether both of matching orders are yours + // "occurredAt": 1603932107, // trade occurrence time + // "tradingPairName": "ZEC-KRW" // order book + // } + // + const id = this.safeString2 (trade, 'id', 'tradeId'); + const orderId = this.safeInteger (trade, 'orderId'); + let timestamp = this.parse8601 (this.safeString2 (trade, 'time', 'timestamp')); + timestamp = this.safeTimestamp (trade, 'occuredAt', timestamp); + const marketId = this.safeString (trade, 'tradingPairName'); + market = this.safeMarket (marketId, market, '-'); + const symbol = market['symbol']; + let side = this.safeString (trade, 'side'); + if (side === '1') { + side = 'buy'; + } else if (side === '2') { + side = 'sell'; + } + let type = this.safeString (trade, 'type'); + if (type === '1') { + type = 'limit'; + } else if (type === '2') { + type = 'market'; + } + const price = this.safeFloat (trade, 'price'); + const amount = this.safeFloat2 (trade, 'amount', 'baseAmount'); + let cost = this.safeFloat (trade, 'quoteAmount'); + if (cost === undefined) { + if ((price !== undefined) && (amount !== undefined)) { + cost = price * amount; + } + } + const feeCost = this.safeFloat (trade, 'fee'); + let fee = undefined; + if (feeCost !== undefined) { + fee = { + 'cost': feeCost, + 'currency': market['base'], + }; + } + const takerOrMaker = this.safeString (trade, 'position'); + return { + 'info': trade, + 'id': id, + 'timestamp': timestamp, + 'datetime': this.iso8601 (timestamp), + 'symbol': symbol, + 'order': orderId, + 'type': undefined, + 'side': side, + 'takerOrMaker': takerOrMaker, + 'price': price, + 'amount': amount, + 'cost': cost, + 'fee': fee, + }; + } + + async fetchTrades (symbol, since = undefined, limit = undefined, params = {}) { + await this.loadMarkets (); + const market = this.market (symbol); + const request = { + 'tradingPair': market['id'], + // 'limit': limit, + // 'pastmax': id, // read data older than this ID + // 'latestmin': id, // read data newer than this ID + // 'after': parseInt (since / 1000), + // 'before': this.seconds (), + }; + if (since !== undefined) { + request['after'] = parseInt (since / 1000); + } + if (limit !== undefined) { + request['limit'] = limit; + } + const response = await this.publicGetTradingPairsTradingPairTrades (this.extend (request, params)); + // + // [ + // {"time":"2020-12-19T12:17:43.000Z","date":1608380263,"id":23903608,"price":25155000,"amount":0.0505,"side":"sell"}, + // {"time":"2020-12-19T12:17:13.000Z","date":1608380233,"id":23903604,"price":25140000,"amount":0.019,"side":"sell"}, + // {"time":"2020-12-19T12:16:49.000Z","date":1608380209,"id":23903599,"price":25140000,"amount":0.0072,"side":"sell"}, + // ] + // + return this.parseTrades (response, market, since, limit); + } + + parseOHLCV (ohlcv, market = undefined) { + // + // [ + // 1606780800000, // timestamp + // 21293000, // low + // 21300000, // high + // 21294000, // open + // 21300000, // close + // 1.019126, // volume + // ] + // + return [ + this.safeInteger (ohlcv, 0), + this.safeFloat (ohlcv, 3), + this.safeFloat (ohlcv, 2), + this.safeFloat (ohlcv, 1), + this.safeFloat (ohlcv, 4), + this.safeFloat (ohlcv, 5), + ]; + } + + async fetchOHLCV (symbol, timeframe = '1m', since = undefined, limit = undefined, params = {}) { + await this.loadMarkets (); + const market = this.market (symbol); + limit = (limit === undefined) ? 1024 : limit; // default 1024 + const request = { + 'tradingPair': market['id'], + // 'start': since, + // 'end': this.milliseconds (), + 'interval': this.timeframes[timeframe], + }; + const duration = this.parseTimeframe (timeframe); + if (since === undefined) { + const end = this.milliseconds (); + request['end'] = end; + request['start'] = end - limit * duration * 1000; + } else { + request['start'] = since; + request['end'] = this.sum (since, limit * duration * 1000); + } + const response = await this.publicGetTradingPairsTradingPairCandles (this.extend (request, params)); + // + // [ + // [1606780800000,21293000,21300000,21294000,21300000,1.019126], + // [1606780860000,21237000,21293000,21293000,21263000,0.96800057], + // [1606780920000,21240000,21240000,21240000,21240000,0.11068715], + // ] + // + return this.parseOHLCVs (response, market, timeframe, since, limit); + } + + parseBalanceResponse (response) { + const result = { 'info': response }; + for (let i = 0; i < response.length; i++) { + const balance = response[i]; + const currencyId = this.safeString2 (balance, 'asset', 'isoAlpha3'); + const code = this.safeCurrencyCode (currencyId); + const hold = this.safeFloat (balance, 'hold'); + const pendingWithdrawal = this.safeFloat (balance, 'pendingWithdrawal'); + const account = this.account (); + account['free'] = this.safeFloat (balance, 'avail'); + account['used'] = this.sum (hold, pendingWithdrawal); + result[code] = account; + } + return this.parseBalance (result); + } + + async fetchBalance (params = {}) { + await this.loadMarkets (); + const response = await this.privateGetBalances (params); + // + // [ + // { + // "asset": "KRW", // asset name + // "avail": 1759466.76, // available amount to place order + // "hold": 16500, // outstanding amount on order books + // "pendingWithdrawal": 0, // amount being withdrawn + // "lastUpdatedAt": "1600684352032", // balance last update time + // }, + // ] + // + return this.parseBalanceResponse (response); + } + + parseOrderStatus (status) { + const statuses = { + 'placed': 'open', + 'cancelled': 'canceled', + 'completed': 'closed', + 'updated': 'open', + 'reserved': 'open', + }; + return this.safeString (statuses, status, status); + } + + parseOrder (order, market = undefined) { + // + // cancelOrder + // + // {} // empty object + // + // fetchOrder, fetchOrders, fetchOpenOrders, createOrder + // + // { + // "id": "453324", // order ID + // "clientOrderId": "zeckrw23456", // client order ID (showed only when it exists) + // "status": "updated", // placed, cancelled, completed, updated, reserved + // "forcedCompletionReason": undefined, // the reason in case it was canceled in the middle (protection or timeInForce) + // "tradingPairName": "ZEC-KRW", // order book + // "side": "buy", // buy, sell + // "type": "limit", // limit, market + // "price": 1000000, // price + // "stopPrice": undefined, // stop price (showed only for stop orders) + // "amount": 4, // initial amount + // "remaining": 1, // outstanding amount + // "protection": "yes", // whether protection is activated (yes or no) + // "timeInForce": "gtc", // limit order's time in force (gtc/po/ioc/fok) + // "createdAt": "2020-09-25T04:06:20.000Z", // order placement time + // "updatedAt": "2020-09-25T04:06:29.000Z", // order last update time + // "balanceChange": { + // "baseGross": 3, // base asset balance's gross change (in ZEC for this case) + // "baseFee": { + // "taking": 0, // base asset fee imposed as taker + // "making": -0.0012 // base asset fee imposed as maker + // }, + // "baseNet": 2.9988, // base asset balance's net change (in ZEC for this case) + // "quoteGross": -3000000, // quote asset balance's gross change (in KRW for + // "quoteFee": { + // "taking": 0, // quote asset fee imposed as taker + // "making": 0 // quote asset fee imposed as maker + // }, + // "quoteNet": -3000000 // quote asset balance's net change (in KRW for this case) + // } + // } + // + const id = this.safeString (order, 'id'); + const clientOrderId = this.safeString (order, 'clientOrderId'); + const timestamp = this.parse8601 (this.safeString (order, 'createdAt')); + const type = this.safeString (order, 'type'); + const side = this.safeString (order, 'side'); + const timeInForce = this.safeStringUpper (order, 'timeInForce'); + const price = this.safeFloat (order, 'price'); + const amount = this.safeFloat (order, 'amount'); + const stopPrice = this.safeFloat (order, 'stopPrice'); + const remaining = this.safeFloat (order, 'remaining'); + const marketId = this.safeString (order, 'tradingPairName'); + market = this.safeMarket (marketId, market, '-'); + const status = this.parseOrderStatus (this.safeString (order, 'status')); + const balanceChange = this.safeValue (order, 'balanceChange', {}); + let filled = this.safeFloat (balanceChange, 'baseNet'); + let cost = this.safeFloat (balanceChange, 'quoteNet'); + if (cost !== undefined) { + cost = Math.abs (cost); + } + let updated = undefined; + if ((filled === undefined) && (amount !== undefined) && (remaining !== undefined)) { + filled = Math.max (0, amount - remaining); + } + if ((filled !== undefined) && (filled > 0)) { + updated = this.parse8601 (this.safeString (order, 'updatedAt')); + } + if ((cost === undefined) && (price !== undefined) && (filled !== undefined)) { + cost = filled * price; + } + let fee = undefined; + if (side === 'buy') { + const baseFee = this.safeValue (balanceChange, 'baseFee', {}); + const taking = this.safeFloat (baseFee, 'taking'); + const making = this.safeFloat (baseFee, 'making'); + fee = { + 'currency': market['base'], + 'cost': this.sum (taking, making), + }; + } else { + const quoteFee = this.safeValue (balanceChange, 'quoteFee', {}); + const taking = this.safeFloat (quoteFee, 'taking'); + const making = this.safeFloat (quoteFee, 'making'); + fee = { + 'currency': market['quote'], + 'cost': this.sum (taking, making), + }; + } + let postOnly = undefined; + if (timeInForce !== undefined) { + postOnly = (timeInForce === 'PO'); + } + return { + 'id': id, + 'clientOrderId': clientOrderId, + 'datetime': this.iso8601 (timestamp), + 'timestamp': timestamp, + 'lastTradeTimestamp': updated, + 'status': status, + 'symbol': market['symbol'], + 'type': type, + 'timeInForce': timeInForce, + 'postOnly': postOnly, + 'side': side, + 'price': price, + 'stopPrice': stopPrice, + 'average': undefined, + 'amount': amount, + 'filled': filled, + 'remaining': remaining, + 'cost': cost, + 'trades': undefined, + 'fee': fee, + 'info': order, + }; + } + + async fetchOrder (id, symbol = undefined, params = {}) { + await this.loadMarkets (); + let method = undefined; + const clientOrderId = this.safeString (params, 'clientOrderId'); + params = this.omit (params, 'clientOrderId'); + const request = {}; + if (clientOrderId === undefined) { + method = 'privateGetOrdersOrderId'; + request['orderId'] = id; + } else { + method = 'privateGetOrdersClientOrderIdClientOrderId'; + request['clientOrderId'] = clientOrderId; + } + const response = await this[method] (this.extend (request, params)); + // + // { + // "id": "453324", // order ID + // "clientOrderId": "zeckrw23456", // client order ID (showed only when it exists) + // "status": "updated", // placed, cancelled, completed, updated, reserved + // "forcedCompletionReason": undefined, // the reason in case it was canceled in the middle (protection or timeInForce) + // "tradingPairName": "ZEC-KRW", // order book + // "side": "buy", // buy, sell + // "type": "limit", // limit, market + // "price": 1000000, // price + // "stopPrice": undefined, // stop price (showed only for stop orders) + // "amount": 4, // initial amount + // "remaining": 1, // outstanding amount + // "protection": "yes", // whether protection is activated (yes or no) + // "timeInForce": "gtc", // limit order's time in force (gtc/po/ioc/fok) + // "createdAt": "2020-09-25T04:06:20.000Z", // order placement time + // "updatedAt": "2020-09-25T04:06:29.000Z", // order last update time + // "balanceChange": { + // "baseGross": 3, // base asset balance's gross change (in ZEC for this case) + // "baseFee": { + // "taking": 0, // base asset fee imposed as taker + // "making": -0.0012 // base asset fee imposed as maker + // }, + // "baseNet": 2.9988, // base asset balance's net change (in ZEC for this case) + // "quoteGross": -3000000, // quote asset balance's gross change (in KRW for + // "quoteFee": { + // "taking": 0, // quote asset fee imposed as taker + // "making": 0 // quote asset fee imposed as maker + // }, + // "quoteNet": -3000000 // quote asset balance's net change (in KRW for this case) + // } + // } + // + return this.parseOrder (response); + } + + async fetchOrders (symbol = undefined, since = undefined, limit = undefined, params = {}) { + await this.loadMarkets (); + const request = { + 'includePast': 'true', // if true, completed and canceled orders are included as the result, they are accessible for one hour only from its completion or cancellation time + // 'pagination': 'false', // if the result is more than 3,000 orders, set this value as true to access 1000 orders at max per each page + }; + let market = undefined; + if (symbol !== undefined) { + market = this.market (symbol); + } + const response = await this.privateGetOrders (this.extend (request, params)); + // + // [ + // { + // "id": "453324", // order ID + // "clientOrderId": "zeckrw23456", // client order ID (showed only when it exists) + // "status": "updated", // placed, cancelled, completed, updated, reserved + // "forcedCompletionReason": undefined, // the reason in case it was canceled in the middle (protection or timeInForce) + // "tradingPairName": "ZEC-KRW", // order book + // "side": "buy", // buy, sell + // "type": "limit", // limit, market + // "price": 1000000, // price + // "stopPrice": undefined, // stop price (showed only for stop orders) + // "amount": 4, // initial amount + // "remaining": 1, // outstanding amount + // "protection": "yes", // whether protection is activated (yes or no) + // "timeInForce": "gtc", // limit order's time in force (gtc/po/ioc/fok) + // "createdAt": "2020-09-25T04:06:20.000Z", // order placement time + // "updatedAt": "2020-09-25T04:06:29.000Z", // order last update time + // "balanceChange": { + // "baseGross": 3, // base asset balance's gross change (in ZEC for this case) + // "baseFee": { + // "taking": 0, // base asset fee imposed as taker + // "making": -0.0012 // base asset fee imposed as maker + // }, + // "baseNet": 2.9988, // base asset balance's net change (in ZEC for this case) + // "quoteGross": -3000000, // quote asset balance's gross change (in KRW for + // "quoteFee": { + // "taking": 0, // quote asset fee imposed as taker + // "making": 0 // quote asset fee imposed as maker + // }, + // "quoteNet": -3000000 // quote asset balance's net change (in KRW for this case) + // } + // }, + // ] + // + return this.parseOrders (response, market, since, limit); + } + + async fetchOpenOrders (symbol = undefined, since = undefined, limit = undefined, params = {}) { + const request = { + 'includePast': 'false', + }; + return await this.fetchOrders (symbol, since, limit, this.extend (request, params)); + } + + async createOrder (symbol, type, side, amount, price = undefined, params = {}) { + await this.loadMarkets (); + const market = this.market (symbol); + const request = { + // 'clientOrderId': 'test4321', // max 20 characters of [a-zA-Z0-9_-] + 'tradingPairName': market['id'], + 'side': side, // buy, sell + 'type': type, // limit, market + // 'price': this.priceToPrecision (symbol, price), + // 'stopPrice': this.priceToPrecision (symbol, stopPrice), // optional, becomes a stop order if set + // 'amount': this.amountToPrecision (symbol, amount), + // 'protection': 'no', // whether protection is activated + // 'timeInForce': 'gtc', // gtc, po, ioc, fok + }; + if (type === 'limit') { + request['price'] = this.priceToPrecision (symbol, price); + request['amount'] = this.amountToPrecision (symbol, amount); + } else if (type === 'market') { + // for market buy it requires the amount of quote currency to spend + if (side === 'buy') { + let total = amount; + const createMarketBuyOrderRequiresPrice = this.safeValue (this.options, 'createMarketBuyOrderRequiresPrice', true); + if (createMarketBuyOrderRequiresPrice) { + if (price === undefined) { + throw new InvalidOrder (this.id + " createOrder() requires the price argument with market buy orders to calculate total order cost (amount to spend), where cost = amount * price. Supply a price argument to createOrder() call if you want the cost to be calculated for you from price and amount, or, alternatively, add .options['createMarketBuyOrderRequiresPrice'] = false and supply the total cost value in the 'amount' argument"); + } + total = price * amount; + } + const precision = market['precision']['price']; + request['amount'] = this.decimalToPrecision (total, TRUNCATE, precision, this.precisionMode); + } else { + request['amount'] = this.amountToPrecision (symbol, amount); + } + } + const clientOrderId = this.safeString (params, 'clientOrderId'); + if (clientOrderId !== undefined) { + request['clientOrderId'] = clientOrderId; + params = this.omit (params, 'clientOrderId'); + } + const stopPrice = this.safeFloat (params, 'stopPrice'); + if (stopPrice !== undefined) { + request['stopPrice'] = this.priceToPrecision (symbol, stopPrice); + params = this.omit (params, 'stopPrice'); + } + const timeInForce = this.safeStringLower (params, 'timeInForce'); + if (timeInForce !== undefined) { + request['timeInForce'] = timeInForce; + params = this.omit (params, 'timeInForce'); + } + const response = await this.privatePostOrders (this.extend (request, params)); + // + // { + // "id": "453327", // order ID + // "clientOrderId": "test4321", // client order ID (showed only when it exists) + // "status": "reserved", // placed, cancelled, completed, updated, reserved + // "forcedCompletionReason": undefined, // the reason in case it was canceled in the middle (protection or timeInForce) + // "tradingPairName": "BCH-KRW", // order book + // "side": "sell", // buy, sell + // "type": "limit", // limit, market + // "price": 11000000, // price + // "stopPrice": 12000000, // stop price (showed only for stop orders) + // "amount": 0.5, // initial amount + // "remaining": 0.5, // outstanding amount + // "protection": "no", // whether protection is activated (yes or no) + // "timeInForce": "gtc", // limit order's time in force (gtc/po/ioc/fok) + // "createdAt": "2020-09-25T04:51:31.000Z", // order placement time + // "balanceChange": { + // "baseGross": 0, // base asset balance's gross change (in BCH for this case) + // "baseFee": { + // "taking": 0, // base asset fee imposed as taker + // "making": 0 // base asset fee imposed as maker + // }, + // "baseNet": 0, // base asset balance's net change (in BCH for this case) + // "quoteGross": 0, // quote asset balance's gross change (in KRW for + // "quoteFee": { + // "taking": 0, // quote asset fee imposed as taker + // "making": 0 // quote asset fee imposed as maker + // }, + // "quoteNet": 0 // quote asset balance's net change (in KRW for this case) + // } + // } + // + return this.parseOrder (response, market); + } + + async cancelOrder (id, symbol = undefined, params = {}) { + await this.loadMarkets (); + const request = {}; + const clientOrderId = this.safeString (params, 'clientOrderId'); + let method = undefined; + if (clientOrderId === undefined) { + method = 'privateDeleteOrdersOrderId'; + request['orderId'] = id; + } else { + method = 'privateDeleteOrdersClientOrderIdClientOrderId'; + request['clientOrderId'] = clientOrderId; + params = this.omit (params, 'clientOrderId'); + } + const response = await this[method] (this.extend (request, params)); + // + // {} + // + const order = this.parseOrder (response); + return this.extend (order, { 'id': id }); + } + + async fetchMyTrades (symbol = undefined, since = undefined, limit = undefined, params = {}) { + await this.loadMarkets (); + const request = { + // 'limit': limit, // max 100 + // 'pastmax': id, // read data older than this id + // 'latestmin': id, // read data newer than this id + // 'after': parseInt (since / 1000), // Read data after this timestamp in seconds + // 'before': this.seconds (), // Read data before this timestamp in seconds + 'deepSearch': 'true', // read data older than one month ago are inclusively looked up only when it is "true" + }; + if (since !== undefined) { + request['after'] = parseInt (since / 1000); + } + if (limit !== undefined) { + request['limit'] = limit; + } + const response = await this.privateGetTrades (this.extend (request, params)); + // + // [ + // { + // "id": 73953, // trading event ID + // "orderId": 453324, // order ID + // "baseAmount": 3, // traded base asset amount + // "quoteAmount": 3000000, // traded quote asset amount + // "fee": 0.0012, // fee + // "price": 1000000, // price + // "timestamp": "2020-09-25T04:06:30.000Z", // trading time + // "side": "buy", // buy, sell + // "tradingPairName": "ZEC-KRW", // order book + // "position": "maker" // maker, taker + // }, + // ] + // + let market = undefined; + if (symbol !== undefined) { + market = this.market (symbol); + } + return this.parseTrades (response, market, since, limit); + } + + parseDepositAddress (depositAddress, currency = undefined) { + // + // { + // "asset": "BTC", // asset name + // "address": "1CwC2cMFu1jRQUBtw925cENbT1kctJBMdm", // deposit address + // "memoId": null, // memo ID (showed only for assets using memo ID) + // "createdAt": 1594802312 // deposit address creation time + // } + // + const address = this.safeString (depositAddress, 'address'); + const tag = this.safeString (depositAddress, 'memoId'); + const currencyId = this.safeString (depositAddress, 'asset'); + const code = this.safeCurrencyCode (currencyId); + this.checkAddress (address); + return { + 'currency': code, + 'address': address, + 'tag': tag, + 'info': depositAddress, + }; + } + + parseDepositAddresses (addresses, codes = undefined) { + let result = []; + for (let i = 0; i < addresses.length; i++) { + const address = this.parseDepositAddress (addresses[i]); + result.push (address); + } + if (codes) { + result = this.filterByArray (result, 'currency', codes); + } + return this.indexBy (result, 'currency'); + } + + async fetchDepositAddresses (codes = undefined, params = {}) { + await this.loadMarkets (); + const response = await this.privateGetCryptoDepositAddresses (params); + // + // [ + // { + // "asset": "BTC", // asset name + // "address": "1CwC2cMFu1jRQUBtw925cENbT1kctJBMdm", // deposit address + // "memoId": null, // memo ID (showed only for assets using memo ID) + // "createdAt": 1594802312 // deposit address creation time + // }, + // ] + // + return this.parseDepositAddresses (response, codes); + } + + async fetchDepositAddress (code, params = {}) { + await this.loadMarkets (); + const response = await this.fetchDepositAddresses (undefined, params); + const address = this.safeValue (response, code); + if (address === undefined) { + throw new InvalidAddress (this.id + ' fetchDepositAddress() ' + code + ' address not found'); + } + return address; + } + + parseTransactionStatus (status) { + const statuses = { + 'reviewing': 'pending', + 'rejected': 'rejected', + 'processing': 'pending', + 'failed': 'failed', + 'completed': 'ok', + }; + return this.safeString (statuses, status, status); + } + + parseTransaction (transaction, currency = undefined) { + // + // { + // "id": 640, // deposit/withdrawal event ID + // "asset": "BTC", // asset name + // "type": "crypto_withdrawal", // fiat_withdrawal, fiat_deposit, crypto_withdrawal, crypto_deposit + // "netAmount": 0.0001, // amount + // "feeAmount": 0.0005, // fee (null if there is no imposed fee) + // "status": "completed", // reviewing, rejected, processing, failed, completed + // "reviewStartedAt": 1595556218, // request time + // "completedAt": 1595556902, // completion time (showed only in case of completed) + // "txId": "eaca5ad3...", // tx ID + // "sourceAddress": null, // sender address (showed only in case of crypto_deposit) + // "destinationAddress: "3H8...", // recipient address (showed only in case of crypto_withdrawal) + // "destinationMemoId": null // recipient address's memo ID + // } + // + const id = this.safeString (transaction, 'id'); + const txid = this.safeString (transaction, 'txId'); + const currencyId = this.safeString (transaction, 'asset'); + const code = this.safeCurrencyCode (currencyId, currency); + let type = this.safeString (transaction, 'type'); + if ((type === 'crypto_withdrawal') || (type === 'fiat_withdrawal')) { + type = 'withdrawal'; + } else if ((type === 'crypto_deposit' || type === 'fiat_deposit')) { + type = 'deposit'; + } + const amount = this.safeFloat (transaction, 'netAmount'); + const feeCost = this.safeFloat (transaction, 'feeAmount'); + let fee = undefined; + if (feeCost !== undefined) { + fee = { + 'cost': feeCost, + 'currency': code, + }; + } + const timestamp = this.safeTimestamp (transaction, 'reviewStartedAt'); + const updated = this.safeTimestamp (transaction, 'completedAt'); + const addressFrom = this.safeString (transaction, 'sourceAddress'); + const addressTo = this.safeString (transaction, 'destinationAddress'); + const tagFrom = this.safeString (transaction, 'sourceMemoId'); + const tagTo = this.safeString (transaction, 'destinationMemoId'); + const status = this.parseTransactionStatus (this.safeString (transaction, 'status')); + return { + 'info': transaction, + 'id': id, + 'txid': txid, + 'timestamp': timestamp, + 'datetime': this.iso8601 (timestamp), + 'addressFrom': addressFrom, + 'address': addressTo, + 'addressTo': addressTo, + 'tagFrom': tagFrom, + 'tag': tagTo, + 'tagTo': tagTo, + 'type': type, + 'amount': amount, + 'currency': code, + 'status': status, + 'updated': updated, + 'comment': undefined, + 'fee': fee, + }; + } + + async fetchTransactions (code = undefined, since = undefined, limit = undefined, params = {}) { + await this.loadMarkets (); + const request = { + // 'limit': limit, // max 20 + // 'latestmin': limit, // read data older than this id + // 'after': this.milliseconds (), + // 'before': since, + // 'completedOnly': 'no', + }; + if (since !== undefined) { + request['before'] = since; + } + if (limit !== undefined) { + request['limit'] = limit; + } + const response = await this.privateGetDepositWithdrawalStatus (this.extend (request, params)); + // + // [ + // { + // "id": 640, // deposit/withdrawal event ID + // "asset": "BTC", // asset name + // "type": "crypto_withdrawal", // fiat_withdrawal, fiat_deposit, crypto_withdrawal, crypto_deposit + // "netAmount": 0.0001, // amount + // "feeAmount": 0.0005, // fee (null if there is no imposed fee) + // "status": "completed", // reviewing, rejected, processing, failed, completed + // "reviewStartedAt": 1595556218, // request time + // "completedAt": 1595556902, // completion time (showed only in case of completed) + // "txId": "eaca5ad3...", // tx ID + // "sourceAddress": null, // sender address (showed only in case of crypto_deposit) + // "destinationAddress: "3H8...", // recipient address (showed only in case of crypto_withdrawal) + // "destinationMemoId": null // recipient address's memo ID + // }, + // ] + // + let currency = undefined; + if (code !== undefined) { + currency = this.currency (code); + } + return this.parseTransactions (response, currency, since, limit, params); + } + + nonce () { + return this.milliseconds (); + } + + sign (path, api = 'public', method = 'GET', params = {}, headers = undefined, body = undefined) { // for authentication in private API calls + const endpoint = '/' + this.implodeParams (path, params); + let url = this.implodeParams (this.urls['api'][api], { 'hostname': this.hostname }) + endpoint; + const query = this.omit (params, this.extractParams (path)); + if (api === 'public') { + if (Object.keys (query).length) { + url += '?' + this.urlencode (query); + } + } else if (api === 'private') { + this.checkRequiredCredentials (); + const timestamp = this.nonce ().toString (); + let auth = 't' + timestamp + method + endpoint; + headers = { + 'api-key': this.apiKey, + 'timestamp': timestamp, + }; + if (method === 'POST') { + headers['Content-Type'] = 'application/json'; + body = this.json (params); + auth += body; + } else if (endpoint === '/orders') { + if (Object.keys (query).length) { + const urlQuery = '?' + this.urlencode (query); + auth += urlQuery; + url += urlQuery; + } + } else if (method === 'GET') { + if (Object.keys (query).length) { + url += '?' + this.urlencode (query); + } + } + const rawSecret = this.base64ToBinary (this.secret); + const signature = this.hmac (this.encode (auth), rawSecret, 'sha512', 'base64'); + headers['signature'] = signature; + } + return { 'url': url, 'method': method, 'body': body, 'headers': headers }; + } + + handleErrors (code, reason, url, method, headers, body, response, requestHeaders, requestBody) { + if (response === undefined) { + return; + } + // + // {"errorMessage":"Invalid API key","errorCode":10155} + // + if (!Array.isArray (response)) { + const errorCode = this.safeString (response, 'errorCode'); + const errorMessage = this.safeString (response, 'errorMessage'); + const feedback = this.id + ' ' + body; + if (errorMessage !== undefined) { + this.throwBroadlyMatchedException (this.exceptions['broad'], body, feedback); + } + if (errorCode !== undefined) { + this.throwExactlyMatchedException (this.exceptions['exact'], errorCode, feedback); + } + if ((errorCode !== undefined) || (errorMessage !== undefined)) { + throw new ExchangeError (feedback); + } + } + } +}; + +},{"./base/Exchange":6,"./base/errors":8,"./base/functions/number":14}],92:[function(require,module,exports){ 'use strict'; // --------------------------------------------------------------------------- @@ -69922,7 +76573,7 @@ module.exports = class hbtc extends Exchange { method = 'optionGetMyTrades'; } else { if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' fetchMyTrades requires a `symbol` argument for ' + type + ' markets'); + throw new ArgumentsRequired (this.id + ' fetchMyTrades() requires a `symbol` argument for ' + type + ' markets'); } const market = this.market (symbol); request['symbol'] = market['id']; @@ -71035,6 +77686,7 @@ module.exports = class hbtc extends Exchange { 'NEW': 'open', 'CANCELED': 'canceled', 'FILLED': 'closed', + 'PARTIALLY_FILLED': 'open', 'PENDING_CANCEL': 'canceled', }; return this.safeString (statuses, status, status); @@ -71088,7 +77740,7 @@ module.exports = class hbtc extends Exchange { } }; -},{"./base/Exchange":5,"./base/errors":7,"./base/functions/number":13}],89:[function(require,module,exports){ +},{"./base/Exchange":6,"./base/errors":8,"./base/functions/number":14}],93:[function(require,module,exports){ 'use strict'; // --------------------------------------------------------------------------- @@ -71150,6 +77802,10 @@ module.exports = class hitbtc extends Exchange { }, 'urls': { 'logo': 'https://user-images.githubusercontent.com/1294454/27766555-8eaec20e-5edc-11e7-9c5b-6dc69fc42f5e.jpg', + 'test': { + 'public': 'https://api.demo.hitbtc.com', + 'private': 'https://api.demo.hitbtc.com', + }, 'api': { 'public': 'https://api.hitbtc.com', 'private': 'https://api.hitbtc.com', @@ -71251,6 +77907,7 @@ module.exports = class hitbtc extends Exchange { 'LNC': 'LinkerCoin', 'PLA': 'PlayChip', 'PNT': 'Penta', + 'SBTC': 'Super Bitcoin', 'TV': 'Tokenville', 'USD': 'USDT', 'XPNT': 'PNT', @@ -71888,22 +78545,44 @@ module.exports = class hitbtc extends Exchange { // // createMarketOrder // - // { clientOrderId: "fe36aa5e190149bf9985fb673bbb2ea0", - // createdAt: "2018-10-25T16:41:44.780Z", - // cumQuantity: "1", - // id: "66799540063", - // quantity: "1", - // side: "sell", - // status: "filled", - // symbol: "XRPUSDT", - // timeInForce: "FOK", - // tradesReport: [ { fee: "0.0004644", - // id: 386394956, - // price: "0.4644", - // quantity: "1", - // timestamp: "2018-10-25T16:41:44.780Z" } ], - // type: "market", - // updatedAt: "2018-10-25T16:41:44.780Z" } + // { + // clientOrderId: "fe36aa5e190149bf9985fb673bbb2ea0", + // createdAt: "2018-10-25T16:41:44.780Z", + // cumQuantity: "1", + // id: "66799540063", + // quantity: "1", + // side: "sell", + // status: "filled", + // symbol: "XRPUSDT", + // timeInForce: "FOK", + // tradesReport: [ + // { + // fee: "0.0004644", + // id: 386394956, + // price: "0.4644", + // quantity: "1", + // timestamp: "2018-10-25T16:41:44.780Z" + // } + // ], + // type: "market", + // updatedAt: "2018-10-25T16:41:44.780Z" + // } + // + // { + // "id": 119499457455, + // "clientOrderId": "87baab109d58401b9202fa0749cb8288", + // "symbol": "ETHUSD", + // "side": "buy", + // "status": "filled", + // "type": "market", + // "timeInForce": "FOK", + // "quantity": "0.0007", + // "price": "181.487", + // "avgPrice": "164.989", + // "cumQuantity": "0.0007", + // "createdAt": "2019-04-17T13:27:38.062Z", + // "updatedAt": "2019-04-17T13:27:38.062Z" + // } // const created = this.parse8601 (this.safeString (order, 'createdAt')); const updated = this.parse8601 (this.safeString (order, 'updatedAt')); @@ -71933,7 +78612,7 @@ module.exports = class hitbtc extends Exchange { const side = this.safeString (order, 'side'); let trades = this.safeValue (order, 'tradesReport'); let fee = undefined; - let average = undefined; + let average = this.safeValue (order, 'avgPrice'); if (trades !== undefined) { trades = this.parseTrades (trades, market); let feeCost = undefined; @@ -71952,7 +78631,9 @@ module.exports = class hitbtc extends Exchange { } cost = tradesCost; if ((filled !== undefined) && (filled > 0)) { - average = cost / filled; + if (average === undefined) { + average = cost / filled; + } if (type === 'market') { if (price === undefined) { price = average; @@ -72249,7 +78930,7 @@ module.exports = class hitbtc extends Exchange { } }; -},{"./base/Exchange":5,"./base/errors":7,"./base/functions/number":13}],90:[function(require,module,exports){ +},{"./base/Exchange":6,"./base/errors":8,"./base/functions/number":14}],94:[function(require,module,exports){ 'use strict'; // --------------------------------------------------------------------------- @@ -72772,7 +79453,7 @@ module.exports = class hollaex extends Exchange { const duration = this.parseTimeframe (timeframe); if (since === undefined) { if (limit === undefined) { - throw new ArgumentsRequired (this.id + " fetchOHLCV requires a 'since' or a 'limit' argument"); + throw new ArgumentsRequired (this.id + " fetchOHLCV() requires a 'since' or a 'limit' argument"); } else { const end = this.seconds (); const start = end - duration * limit; @@ -72954,6 +79635,7 @@ module.exports = class hollaex extends Exchange { 'symbol': symbol, 'type': type, 'timeInForce': undefined, + 'postOnly': undefined, 'side': side, 'price': price, 'stopPrice': undefined, @@ -73423,7 +80105,7 @@ module.exports = class hollaex extends Exchange { } }; -},{"./base/Exchange":5,"./base/errors":7,"./base/functions/number":13}],91:[function(require,module,exports){ +},{"./base/Exchange":6,"./base/errors":8,"./base/functions/number":14}],95:[function(require,module,exports){ 'use strict'; // --------------------------------------------------------------------------- @@ -73464,7 +80146,7 @@ module.exports = class huobijp extends huobipro { } }; -},{"./base/errors":7,"./huobipro.js":92}],92:[function(require,module,exports){ +},{"./base/errors":8,"./huobipro.js":96}],96:[function(require,module,exports){ 'use strict'; // --------------------------------------------------------------------------- @@ -73565,6 +80247,7 @@ module.exports = class huobipro extends Exchange { 'user/api-key', // 母子用户API key信息查询 ], 'post': [ + 'account/transfer', 'point/transfer', // 点卡划转 'sub-user/management', // 冻结/解冻子用户 'sub-user/creation', // 子用户创建 @@ -73662,9 +80345,14 @@ module.exports = class huobipro extends Exchange { }, }, 'exceptions': { + 'broad': { + 'contract is restricted of closing positions on API. Please contact customer service': OnMaintenance, + 'maintain': OnMaintenance, + }, 'exact': { // err-code 'bad-request': BadRequest, + 'base-date-limit-error': BadRequest, // {"status":"error","err-code":"base-date-limit-error","err-msg":"date less than system limit","data":null} 'api-not-support-temp-addr': PermissionDenied, // {"status":"error","err-code":"api-not-support-temp-addr","err-msg":"API withdrawal does not support temporary addresses","data":null} 'timeout': RequestTimeout, // {"ts":1571653730865,"status":"error","err-code":"timeout","err-msg":"Request Timeout"} 'gateway-internal-error': ExchangeNotAvailable, // {"status":"error","err-code":"gateway-internal-error","err-msg":"Failed to load data. Try again later.","data":null} @@ -73675,6 +80363,8 @@ module.exports = class huobipro extends Exchange { 'order-marketorder-amount-min-error': InvalidOrder, // market order amount error, min: `0.01` 'order-limitorder-price-min-error': InvalidOrder, // limit order price error 'order-limitorder-price-max-error': InvalidOrder, // limit order price error + 'order-holding-limit-failed': InvalidOrder, // {"status":"error","err-code":"order-holding-limit-failed","err-msg":"Order failed, exceeded the holding limit of this currency","data":null} + 'order-orderprice-precision-error': InvalidOrder, // {"status":"error","err-code":"order-orderprice-precision-error","err-msg":"order price precision error, scale: `4`","data":null} 'order-orderstate-error': OrderNotFound, // canceling an already canceled order 'order-queryorder-invalid': OrderNotFound, // querying a non-existent order 'order-update-error': ExchangeNotAvailable, // undocumented error @@ -73710,6 +80400,7 @@ module.exports = class huobipro extends Exchange { // https://coinmarketcap.com/currencies/penta/markets/ // https://en.cryptonomist.ch/blog/eidoo/the-edo-to-pnt-upgrade-what-you-need-to-know-updated/ 'PNT': 'Penta', + 'SBTC': 'Super Bitcoin', }, }); } @@ -74142,7 +80833,8 @@ module.exports = class huobipro extends Exchange { request['size'] = limit; // 1-100 orders, default is 100 } if (since !== undefined) { - request['start-date'] = this.ymd (since); // maximum query window size is 2 days, query window shift should be within past 120 days + request['start-date'] = this.ymd (since); // a date within 61 days from today + request['end-date'] = this.ymd (this.sum (since, 86400000)); } const response = await this.privateGetOrderMatchresults (this.extend (request, params)); const trades = this.parseTrades (response['data'], market, since, limit); @@ -74410,7 +81102,7 @@ module.exports = class huobipro extends Exchange { async fetchOpenOrdersV1 (symbol = undefined, since = undefined, limit = undefined, params = {}) { if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' fetchOpenOrdersV1 requires a symbol argument'); + throw new ArgumentsRequired (this.id + ' fetchOpenOrdersV1() requires a symbol argument'); } return await this.fetchOrdersByStates ('pre-submitted,submitted,partial-filled', symbol, since, limit, params); } @@ -74422,7 +81114,7 @@ module.exports = class huobipro extends Exchange { async fetchOpenOrdersV2 (symbol = undefined, since = undefined, limit = undefined, params = {}) { await this.loadMarkets (); if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' fetchOpenOrders requires a symbol argument'); + throw new ArgumentsRequired (this.id + ' fetchOpenOrders() requires a symbol argument'); } const market = this.market (symbol); let accountId = this.safeString (params, 'account-id'); @@ -74572,6 +81264,7 @@ module.exports = class huobipro extends Exchange { 'symbol': symbol, 'type': type, 'timeInForce': undefined, + 'postOnly': undefined, 'side': side, 'price': price, 'stopPrice': undefined, @@ -74951,6 +81644,7 @@ module.exports = class huobipro extends Exchange { if (status === 'error') { const code = this.safeString (response, 'err-code'); const feedback = this.id + ' ' + body; + this.throwBroadlyMatchedException (this.exceptions['broad'], body, feedback); this.throwExactlyMatchedException (this.exceptions['exact'], code, feedback); const message = this.safeString (response, 'err-msg'); this.throwExactlyMatchedException (this.exceptions['exact'], message, feedback); @@ -74960,40 +81654,7 @@ module.exports = class huobipro extends Exchange { } }; -},{"./base/Exchange":5,"./base/errors":7,"./base/functions/number":13}],93:[function(require,module,exports){ -'use strict'; - -// --------------------------------------------------------------------------- - -const huobipro = require ('./huobipro.js'); - -// --------------------------------------------------------------------------- - -module.exports = class huobiru extends huobipro { - describe () { - return this.deepExtend (super.describe (), { - 'id': 'huobiru', - 'name': 'Huobi Russia', - 'countries': [ 'RU' ], - 'hostname': 'www.huobi.com.ru', - 'pro': true, - 'urls': { - 'logo': 'https://user-images.githubusercontent.com/1294454/52978816-e8552e00-33e3-11e9-98ed-845acfece834.jpg', - 'api': { - 'market': 'https://{hostname}/api', - 'public': 'https://{hostname}/api', - 'private': 'https://{hostname}/api', - }, - 'www': 'https://www.huobi.com.ru/ru-ru', - 'referral': 'https://www.huobi.com.ru/invite?invite_code=esc74', - 'doc': 'https://github.com/cloudapidoc/API_Docs_en', - 'fees': 'https://www.huobi.com.ru/ru-ru/about/fee/', - }, - }); - } -}; - -},{"./huobipro.js":92}],94:[function(require,module,exports){ +},{"./base/Exchange":6,"./base/errors":8,"./base/functions/number":14}],97:[function(require,module,exports){ 'use strict'; // --------------------------------------------------------------------------- @@ -75221,7 +81882,7 @@ module.exports = class ice3x extends Exchange { const type = this.safeString (params, 'type'); if ((type !== 'ask') && (type !== 'bid')) { // eslint-disable-next-line quotes - throw new ArgumentsRequired (this.id + " fetchOrderBook requires an exchange-specific extra 'type' param ('bid' or 'ask') when used with a limit"); + throw new ArgumentsRequired (this.id + " fetchOrderBook() requires an exchange-specific extra 'type' param ('bid' or 'ask') when used with a limit"); } else { request['items_per_page'] = limit; } @@ -75341,6 +82002,7 @@ module.exports = class ice3x extends Exchange { 'symbol': symbol, 'type': 'limit', 'timeInForce': undefined, + 'postOnly': undefined, 'side': this.safeString (order, 'type'), 'price': price, 'stopPrice': undefined, @@ -75489,7 +82151,7 @@ module.exports = class ice3x extends Exchange { } }; -},{"./base/Exchange":5,"./base/errors":7}],95:[function(require,module,exports){ +},{"./base/Exchange":6,"./base/errors":8}],98:[function(require,module,exports){ 'use strict'; // --------------------------------------------------------------------------- @@ -75548,8 +82210,8 @@ module.exports = class idex extends Exchange { }, 'logo': 'https://user-images.githubusercontent.com/51840849/94481303-2f222100-01e0-11eb-97dd-bc14c5943a86.jpg', 'api': { - 'public': 'https://api.idex.io', - 'private': 'https://api.idex.io', + 'ETH': 'https://api-eth.idex.io', + 'BSC': 'https://api-bsc.idex.io', }, 'www': 'https://idex.io', 'doc': [ @@ -75595,6 +82257,7 @@ module.exports = class idex extends Exchange { 'options': { 'defaultTimeInForce': 'gtc', 'defaultSelfTradePrevention': 'cn', + 'network': 'ETH', // also supports BSC }, 'exceptions': { 'INVALID_ORDER_QUANTITY': InvalidOrder, @@ -76314,16 +82977,8 @@ module.exports = class idex extends Exchange { const type = this.safeString (order, 'type'); const amount = this.safeFloat (order, 'originalQuantity'); const filled = this.safeFloat (order, 'executedQuantity'); - let remaining = undefined; - if ((amount !== undefined) && (filled !== undefined)) { - remaining = amount - filled; - } const average = this.safeFloat (order, 'avgExecutionPrice'); - const price = this.safeFloat (order, 'price', average); // for market orders - let cost = undefined; - if ((amount !== undefined) && (price !== undefined)) { - cost = amount * price; - } + const price = this.safeFloat (order, 'price'); const rawStatus = this.safeString (order, 'status'); const status = this.parseOrderStatus (rawStatus); const fee = { @@ -76337,7 +82992,7 @@ module.exports = class idex extends Exchange { fee['cost'] = this.sum (fee['cost'], lastTrade['fee']['cost']); } const lastTradeTimestamp = this.safeInteger (lastTrade, 'timestamp'); - return { + return this.safeOrder ({ 'info': order, 'id': id, 'clientOrderId': clientOrderId, @@ -76347,18 +83002,19 @@ module.exports = class idex extends Exchange { 'symbol': symbol, 'type': type, 'timeInForce': undefined, + 'postOnly': undefined, 'side': side, 'price': price, 'stopPrice': undefined, 'amount': amount, - 'cost': cost, + 'cost': undefined, 'average': average, 'filled': filled, - 'remaining': remaining, + 'remaining': undefined, 'status': status, 'fee': fee, 'trades': trades, - }; + }); } async associateWallet (walletAddress, params = {}) { @@ -76435,7 +83091,8 @@ module.exports = class idex extends Exchange { } const sideEnum = (side === 'buy') ? 0 : 1; const walletBytes = this.remove0xPrefix (this.walletAddress); - const orderVersion = 1; + const network = this.safeString (this.options, 'network', 'ETH'); + const orderVersion = (network === 'ETH') ? 1 : 2; const amountString = this.amountToPrecision (symbol, amount); // https://docs.idex.io/#time-in-force const timeInForceEnums = { @@ -76764,8 +83421,9 @@ module.exports = class idex extends Exchange { } sign (path, api = 'public', method = 'GET', params = {}, headers = undefined, body = undefined) { + const network = this.safeString (this.options, 'network', 'ETH'); const version = this.safeString (this.options, 'version', 'v1'); - let url = this.urls['api'][api] + '/' + version + '/' + path; + let url = this.urls['api'][network] + '/' + version + '/' + path; const keys = Object.keys (params); const length = keys.length; let query = undefined; @@ -76796,7 +83454,7 @@ module.exports = class idex extends Exchange { } }; -},{"./base/Exchange":5,"./base/errors":7,"./base/functions/number":13}],96:[function(require,module,exports){ +},{"./base/Exchange":6,"./base/errors":8,"./base/functions/number":14}],99:[function(require,module,exports){ 'use strict'; // --------------------------------------------------------------------------- @@ -77086,6 +83744,7 @@ module.exports = class independentreserve extends Exchange { 'symbol': symbol, 'type': orderType, 'timeInForce': undefined, + 'postOnly': undefined, 'side': side, 'price': price, 'stopPrice': undefined, @@ -77193,10 +83852,13 @@ module.exports = class independentreserve extends Exchange { cost = price * amount; } } - let symbol = undefined; - if (market !== undefined) { - symbol = market['symbol']; + const baseId = this.safeString (trade, 'PrimaryCurrencyCode'); + const quoteId = this.safeString (trade, 'SecondaryCurrencyCode'); + let marketId = undefined; + if ((baseId !== undefined) && (quoteId !== undefined)) { + marketId = baseId + '/' + quoteId; } + const symbol = this.safeSymbol (marketId, market, '/'); let side = this.safeString (trade, 'OrderType'); if (side !== undefined) { if (side.indexOf ('Bid') >= 0) { @@ -77302,7 +83964,7 @@ module.exports = class independentreserve extends Exchange { } }; -},{"./base/Exchange":5}],97:[function(require,module,exports){ +},{"./base/Exchange":6}],100:[function(require,module,exports){ 'use strict'; // --------------------------------------------------------------------------- @@ -77704,6 +84366,7 @@ module.exports = class indodax extends Exchange { 'symbol': symbol, 'type': 'limit', 'timeInForce': undefined, + 'postOnly': undefined, 'side': side, 'price': price, 'stopPrice': undefined, @@ -77720,7 +84383,7 @@ module.exports = class indodax extends Exchange { async fetchOrder (id, symbol = undefined, params = {}) { if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' fetchOrder requires a symbol'); + throw new ArgumentsRequired (this.id + ' fetchOrder() requires a symbol'); } await this.loadMarkets (); const market = this.market (symbol); @@ -77767,7 +84430,7 @@ module.exports = class indodax extends Exchange { async fetchClosedOrders (symbol = undefined, since = undefined, limit = undefined, params = {}) { if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' fetchOrders requires a symbol argument'); + throw new ArgumentsRequired (this.id + ' fetchOrders() requires a symbol argument'); } await this.loadMarkets (); const request = {}; @@ -77811,11 +84474,11 @@ module.exports = class indodax extends Exchange { async cancelOrder (id, symbol = undefined, params = {}) { if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' cancelOrder requires a symbol argument'); + throw new ArgumentsRequired (this.id + ' cancelOrder() requires a symbol argument'); } const side = this.safeValue (params, 'side'); if (side === undefined) { - throw new ArgumentsRequired (this.id + ' cancelOrder requires an extra "side" param'); + throw new ArgumentsRequired (this.id + ' cancelOrder() requires an extra "side" param'); } await this.loadMarkets (); const market = this.market (symbol); @@ -77922,7 +84585,7 @@ module.exports = class indodax extends Exchange { } }; -},{"./base/Exchange":5,"./base/errors":7}],98:[function(require,module,exports){ +},{"./base/Exchange":6,"./base/errors":8}],101:[function(require,module,exports){ 'use strict'; // --------------------------------------------------------------------------- @@ -78193,7 +84856,7 @@ module.exports = class itbit extends Exchange { await this.loadMarkets (); const walletId = this.safeString (params, 'walletId'); if (walletId === undefined) { - throw new ArgumentsRequired (this.id + ' fetchMyTrades requires a walletId parameter'); + throw new ArgumentsRequired (this.id + ' fetchMyTrades() requires a walletId parameter'); } const request = { 'walletId': walletId, @@ -78262,7 +84925,7 @@ module.exports = class itbit extends Exchange { await this.loadMarkets (); const walletId = this.safeString (params, 'walletId'); if (walletId === undefined) { - throw new ExchangeError (this.id + ' fetchMyTrades requires a walletId parameter'); + throw new ExchangeError (this.id + ' fetchMyTrades() requires a walletId parameter'); } const request = { 'walletId': walletId, @@ -78352,7 +85015,7 @@ module.exports = class itbit extends Exchange { async fetchWallets (params = {}) { await this.loadMarkets (); if (!this.uid) { - throw new AuthenticationError (this.id + ' fetchWallets requires uid API credential'); + throw new AuthenticationError (this.id + ' fetchWallets() requires uid API credential'); } const request = { 'userId': this.uid, @@ -78390,7 +85053,7 @@ module.exports = class itbit extends Exchange { } const walletIdInParams = ('walletId' in params); if (!walletIdInParams) { - throw new ExchangeError (this.id + ' fetchOrders requires a walletId parameter'); + throw new ExchangeError (this.id + ' fetchOrders() requires a walletId parameter'); } const walletId = params['walletId']; const request = { @@ -78454,6 +85117,8 @@ module.exports = class itbit extends Exchange { } const clientOrderId = this.safeString (order, 'clientOrderIdentifier'); const id = this.safeString (order, 'id'); + const postOnlyString = this.safeString (order, 'postOnly'); + const postOnly = (postOnlyString === 'True'); return { 'id': id, 'clientOrderId': clientOrderId, @@ -78465,6 +85130,7 @@ module.exports = class itbit extends Exchange { 'symbol': symbol, 'type': type, 'timeInForce': undefined, + 'postOnly': postOnly, 'side': side, 'price': price, 'stopPrice': undefined, @@ -78490,7 +85156,7 @@ module.exports = class itbit extends Exchange { } const walletIdInParams = ('walletId' in params); if (!walletIdInParams) { - throw new ExchangeError (this.id + ' createOrder requires a walletId parameter'); + throw new ExchangeError (this.id + ' createOrder() requires a walletId parameter'); } amount = amount.toString (); price = price.toString (); @@ -78515,7 +85181,7 @@ module.exports = class itbit extends Exchange { await this.loadMarkets (); const walletIdInParams = ('walletId' in params); if (!walletIdInParams) { - throw new ExchangeError (this.id + ' fetchOrder requires a walletId parameter'); + throw new ExchangeError (this.id + ' fetchOrder() requires a walletId parameter'); } const request = { 'id': id, @@ -78527,7 +85193,7 @@ module.exports = class itbit extends Exchange { async cancelOrder (id, symbol = undefined, params = {}) { const walletIdInParams = ('walletId' in params); if (!walletIdInParams) { - throw new ExchangeError (this.id + ' cancelOrder requires a walletId parameter'); + throw new ExchangeError (this.id + ' cancelOrder() requires a walletId parameter'); } const request = { 'id': id, @@ -78574,13 +85240,13 @@ module.exports = class itbit extends Exchange { } }; -},{"./base/Exchange":5,"./base/errors":7}],99:[function(require,module,exports){ +},{"./base/Exchange":6,"./base/errors":8}],102:[function(require,module,exports){ 'use strict'; // --------------------------------------------------------------------------- const Exchange = require ('./base/Exchange'); -const { BadSymbol, ExchangeNotAvailable, ArgumentsRequired, PermissionDenied, AuthenticationError, ExchangeError, OrderNotFound, DDoSProtection, InvalidNonce, InsufficientFunds, CancelPending, InvalidOrder, InvalidAddress } = require ('./base/errors'); +const { BadSymbol, ExchangeNotAvailable, ArgumentsRequired, PermissionDenied, AuthenticationError, ExchangeError, OrderNotFound, DDoSProtection, InvalidNonce, InsufficientFunds, CancelPending, InvalidOrder, InvalidAddress, RateLimitExceeded } = require ('./base/errors'); const { TRUNCATE, DECIMAL_PLACES } = require ('./base/functions/number'); // --------------------------------------------------------------------------- @@ -78596,6 +85262,7 @@ module.exports = class kraken extends Exchange { 'certified': true, 'pro': true, 'has': { + 'cancelAllOrders': true, 'cancelOrder': true, 'CORS': false, 'createDepositAddress': true, @@ -78756,6 +85423,7 @@ module.exports = class kraken extends Exchange { 'AddOrder', 'AddExport', 'Balance', + 'CancelAll', 'CancelOrder', 'ClosedOrders', 'DepositAddresses', @@ -78783,6 +85451,7 @@ module.exports = class kraken extends Exchange { }, 'commonCurrencies': { 'XBT': 'BTC', + 'XBT.M': 'BTC.M', // https://support.kraken.com/hc/en-us/articles/360039879471-What-is-Asset-S-and-Asset-M- 'XDG': 'DOGE', 'REPV2': 'REP', 'REP': 'REPV1', @@ -78926,13 +85595,17 @@ module.exports = class kraken extends Exchange { return result; } - safeCurrencyCode (currencyId, currency = undefined) { + safeCurrency (currencyId, currency = undefined) { if (currencyId.length > 3) { if ((currencyId.indexOf ('X') === 0) || (currencyId.indexOf ('Z') === 0)) { - currencyId = currencyId.slice (1); + if (currencyId.indexOf ('.') > 0) { + return super.safeCurrency (currencyId, currency); + } else { + currencyId = currencyId.slice (1); + } } } - return super.safeCurrencyCode (currencyId, currency); + return super.safeCurrency (currencyId, currency); } appendInactiveMarkets (result) { @@ -79397,7 +86070,7 @@ module.exports = class kraken extends Exchange { let amount = undefined; let cost = undefined; let id = undefined; - let order = undefined; + let orderId = undefined; let fee = undefined; let symbol = undefined; if (Array.isArray (trade)) { @@ -79421,7 +86094,7 @@ module.exports = class kraken extends Exchange { // delisted market ids go here market = this.getDelistedMarketById (marketId); } - order = trade['ordertxid']; + orderId = this.safeString (trade, 'ordertxid'); id = this.safeString2 (trade, 'id', 'postxid'); timestamp = this.safeTimestamp (trade, 'time'); side = this.safeString (trade, 'type'); @@ -79449,7 +86122,7 @@ module.exports = class kraken extends Exchange { } return { 'id': id, - 'order': order, + 'order': orderId, 'info': trade, 'timestamp': timestamp, 'datetime': this.iso8601 (timestamp), @@ -79512,6 +86185,7 @@ module.exports = class kraken extends Exchange { } async fetchBalance (params = {}) { + await this.loadMarkets (); const response = await this.privatePostBalance (params); const balances = this.safeValue (response, 'result', {}); const result = { 'info': balances }; @@ -79536,18 +86210,50 @@ module.exports = class kraken extends Exchange { 'volume': this.amountToPrecision (symbol, amount), }; const clientOrderId = this.safeString2 (params, 'userref', 'clientOrderId'); - const query = this.omit (params, [ 'userref', 'clientOrderId' ]); + params = this.omit (params, [ 'userref', 'clientOrderId' ]); if (clientOrderId !== undefined) { request['userref'] = clientOrderId; } - const priceIsDefined = (price !== undefined); - const marketOrder = (type === 'market'); - const limitOrder = (type === 'limit'); - const shouldIncludePrice = limitOrder || (!marketOrder && priceIsDefined); - if (shouldIncludePrice) { + // + // market + // limit (price = limit price) + // stop-loss (price = stop loss price) + // take-profit (price = take profit price) + // stop-loss-limit (price = stop loss trigger price, price2 = triggered limit price) + // take-profit-limit (price = take profit trigger price, price2 = triggered limit price) + // settle-position + // + if (type === 'limit') { request['price'] = this.priceToPrecision (symbol, price); + } else if ((type === 'stop-loss') || (type === 'take-profit')) { + const stopPrice = this.safeFloat2 (params, 'price', 'stopPrice', price); + if (stopPrice === undefined) { + throw new ArgumentsRequired (this.id + ' createOrder() requires a price argument or a price/stopPrice parameter for a ' + type + ' order'); + } else { + request['price'] = this.priceToPrecision (symbol, stopPrice); + } + } else if ((type === 'stop-loss-limit') || (type === 'take-profit-limit')) { + const stopPrice = this.safeFloat2 (params, 'price', 'stopPrice'); + const limitPrice = this.safeFloat (params, 'price2'); + const stopPriceDefined = (stopPrice !== undefined); + const limitPriceDefined = (limitPrice !== undefined); + if (stopPriceDefined && limitPriceDefined) { + request['price'] = this.priceToPrecision (symbol, stopPrice); + request['price2'] = this.priceToPrecision (symbol, limitPrice); + } else if ((price === undefined) || (!(stopPriceDefined || limitPriceDefined))) { + throw new ArgumentsRequired (this.id + ' createOrder() requires a price argument and/or price/stopPrice/price2 parameters for a ' + type + ' order'); + } else { + if (stopPriceDefined) { + request['price'] = this.priceToPrecision (symbol, stopPrice); + request['price2'] = this.priceToPrecision (symbol, price); + } else if (limitPriceDefined) { + request['price'] = this.priceToPrecision (symbol, price); + request['price2'] = this.priceToPrecision (symbol, limitPrice); + } + } } - const response = await this.privatePostAddOrder (this.extend (request, query)); + params = this.omit (params, [ 'price', 'stopPrice', 'price2' ]); + const response = await this.privatePostAddOrder (this.extend (request, params)); // // { // error: [], @@ -79710,6 +86416,7 @@ module.exports = class kraken extends Exchange { 'symbol': symbol, 'type': type, 'timeInForce': undefined, + 'postOnly': undefined, 'side': side, 'price': price, 'stopPrice': stopPrice, @@ -79776,8 +86483,11 @@ module.exports = class kraken extends Exchange { // } // } // - const orders = this.safeValue (response, 'result', []); - const order = this.parseOrder (this.extend ({ 'id': id }, orders[id])); + const result = this.safeValue (response, 'result', []); + if (!(id in result)) { + throw new OrderNotFound (this.id + ' fetchOrder() could not find order id ' + id); + } + const order = this.parseOrder (this.extend ({ 'id': id }, result[id])); return this.extend ({ 'info': response }, order); } @@ -79785,7 +86495,7 @@ module.exports = class kraken extends Exchange { const orderTrades = this.safeValue (params, 'trades'); const tradeIds = []; if (orderTrades === undefined) { - throw new ArgumentsRequired (this.id + " fetchOrderTrades requires a unified order structure in the params argument or a 'trades' param (an array of trade id strings)"); + throw new ArgumentsRequired (this.id + " fetchOrderTrades() requires a unified order structure in the params argument or a 'trades' param (an array of trade id strings)"); } else { for (let i = 0; i < orderTrades.length; i++) { const orderTrade = orderTrades[i]; @@ -79934,6 +86644,11 @@ module.exports = class kraken extends Exchange { return response; } + async cancelAllOrders (symbol = undefined, params = {}) { + await this.loadMarkets (); + return await this.privatePostCancelAll (params); + } + async fetchOpenOrders (symbol = undefined, since = undefined, limit = undefined, params = {}) { await this.loadMarkets (); const request = {}; @@ -80105,7 +86820,7 @@ module.exports = class kraken extends Exchange { async fetchDeposits (code = undefined, since = undefined, limit = undefined, params = {}) { // https://www.kraken.com/en-us/help/api#deposit-status if (code === undefined) { - throw new ArgumentsRequired (this.id + ' fetchDeposits requires a currency code argument'); + throw new ArgumentsRequired (this.id + ' fetchDeposits() requires a currency code argument'); } await this.loadMarkets (); const currency = this.currency (code); @@ -80148,7 +86863,7 @@ module.exports = class kraken extends Exchange { async fetchWithdrawals (code = undefined, since = undefined, limit = undefined, params = {}) { // https://www.kraken.com/en-us/help/api#withdraw-status if (code === undefined) { - throw new ArgumentsRequired (this.id + ' fetchWithdrawals requires a currency code argument'); + throw new ArgumentsRequired (this.id + ' fetchWithdrawals() requires a currency code argument'); } await this.loadMarkets (); const currency = this.currency (code); @@ -80239,7 +86954,65 @@ module.exports = class kraken extends Exchange { 'id': response['result'], }; } - throw new ExchangeError (this.id + " withdraw requires a 'key' parameter (withdrawal key name, as set up on your account)"); + throw new ExchangeError (this.id + " withdraw() requires a 'key' parameter (withdrawal key name, as set up on your account)"); + } + + async fetchPositions (symbols = undefined, since = undefined, limit = undefined, params = {}) { + await this.loadMarkets (); + const request = { + // 'txid': 'comma delimited list of transaction ids to restrict output to', + // 'docalcs': false, // whether or not to include profit/loss calculations + // 'consolidation': 'market', // what to consolidate the positions data around, market will consolidate positions based on market pair + }; + const response = await this.privatePostOpenPositions (this.extend (request, params)); + // + // no consolidation + // + // { + // error: [], + // result: { + // 'TGUFMY-FLESJ-VYIX3J': { + // ordertxid: "O3LRNU-ZKDG5-XNCDFR", + // posstatus: "open", + // pair: "ETHUSDT", + // time: 1611557231.4584, + // type: "buy", + // ordertype: "market", + // cost: "28.49800", + // fee: "0.07979", + // vol: "0.02000000", + // vol_closed: "0.00000000", + // margin: "14.24900", + // terms: "0.0200% per 4 hours", + // rollovertm: "1611571631", + // misc: "", + // oflags: "" + // } + // } + // } + // + // consolidation by market + // + // { + // error: [], + // result: [ + // { + // pair: "ETHUSDT", + // positions: "1", + // type: "buy", + // leverage: "2.00000", + // cost: "28.49800", + // fee: "0.07979", + // vol: "0.02000000", + // vol_closed: "0.00000000", + // margin: "14.24900" + // } + // ] + // } + // + const result = this.safeValue (response, 'result'); + // todo unify parsePosition/parsePositions + return result; } sign (path, api = 'public', method = 'GET', params = {}, headers = undefined, body = undefined) { @@ -80294,6 +87067,12 @@ module.exports = class kraken extends Exchange { if (body.indexOf ('Invalid arguments:volume') >= 0) { throw new InvalidOrder (this.id + ' ' + body); } + if (body.indexOf ('Rate limit exceeded') >= 0) { + throw new RateLimitExceeded (this.id + ' ' + body); + } + if (response === undefined) { + return; + } if (body[0] === '{') { if (typeof response !== 'string') { if ('error' in response) { @@ -80312,7 +87091,7 @@ module.exports = class kraken extends Exchange { } }; -},{"./base/Exchange":5,"./base/errors":7,"./base/functions/number":13}],100:[function(require,module,exports){ +},{"./base/Exchange":6,"./base/errors":8,"./base/functions/number":14}],103:[function(require,module,exports){ 'use strict'; // --------------------------------------------------------------------------- @@ -80335,30 +87114,31 @@ module.exports = class kucoin extends Exchange { 'comment': 'Platform 2.0', 'has': { 'CORS': false, - 'fetchStatus': true, - 'fetchTime': true, - 'fetchMarkets': true, + 'cancelAllOrders': true, + 'cancelOrder': true, + 'createDepositAddress': true, + 'createOrder': true, + 'fetchAccounts': true, + 'fetchBalance': true, + 'fetchClosedOrders': true, 'fetchCurrencies': true, + 'fetchDepositAddress': true, + 'fetchDeposits': true, + 'fetchFundingFee': true, + 'fetchLedger': true, + 'fetchMarkets': true, + 'fetchMyTrades': true, + 'fetchOHLCV': true, + 'fetchOpenOrders': true, + 'fetchOrder': true, + 'fetchOrderBook': true, + 'fetchStatus': true, 'fetchTicker': true, 'fetchTickers': true, - 'fetchOrderBook': true, - 'fetchOrder': true, - 'fetchClosedOrders': true, - 'fetchOpenOrders': true, - 'fetchDepositAddress': true, - 'createDepositAddress': true, - 'withdraw': true, - 'fetchDeposits': true, - 'fetchWithdrawals': true, - 'fetchBalance': true, + 'fetchTime': true, 'fetchTrades': true, - 'fetchMyTrades': true, - 'createOrder': true, - 'cancelOrder': true, - 'fetchAccounts': true, - 'fetchFundingFee': true, - 'fetchOHLCV': true, - 'fetchLedger': true, + 'fetchWithdrawals': true, + 'withdraw': true, }, 'urls': { 'logo': 'https://user-images.githubusercontent.com/51840849/87295558-132aaf80-c50e-11ea-9801-a2fb0c57c799.jpg', @@ -80389,6 +87169,7 @@ module.exports = class kucoin extends Exchange { 'symbols', 'markets', 'market/allTickers', + 'market/orderbook/level{level}_{limit}', 'market/orderbook/level{level}', 'market/orderbook/level2', 'market/orderbook/level2_20', @@ -80425,6 +87206,7 @@ module.exports = class kucoin extends Exchange { 'withdrawals', 'withdrawals/quotas', 'orders', + 'order/client-order/{clientOid}', 'orders/{orderId}', 'limit/orders', 'fills', @@ -80440,6 +87222,9 @@ module.exports = class kucoin extends Exchange { 'margin/lend/assets', 'margin/market', 'margin/trade/last', + 'stop-order/{orderId}', + 'stop-order', + 'stop-order/queryOrderByClientOid', ], 'post': [ 'accounts', @@ -80450,17 +87235,23 @@ module.exports = class kucoin extends Exchange { 'orders', 'orders/multi', 'margin/borrow', + 'margin/order', 'margin/repay/all', 'margin/repay/single', 'margin/lend', 'margin/toggle-auto-lend', 'bullet-private', + 'stop-order', ], 'delete': [ 'withdrawals/{withdrawalId}', 'orders', + 'orders/client-order/{clientOid}', 'orders/{orderId}', 'margin/lend/{orderId}', + 'stop-order/cancelOrderByClientOid', + 'stop-order/{orderId}', + 'stop-order/cancel', ], }, }, @@ -80551,10 +87342,12 @@ module.exports = class kucoin extends Exchange { 'public': { 'GET': { 'status': 'v1', - 'market/orderbook/level{level}': 'v1', 'market/orderbook/level2': 'v2', + 'market/orderbook/level3': 'v2', 'market/orderbook/level2_20': 'v1', 'market/orderbook/level2_100': 'v1', + 'market/orderbook/level{level}': 'v2', + 'market/orderbook/level{level}_{limit}': 'v1', }, }, 'private': { @@ -80997,7 +87790,10 @@ module.exports = class kucoin extends Exchange { address = address.replace ('bitcoincash:', ''); } const tag = this.safeString (data, 'memo'); - this.checkAddress (address); + if (code !== 'NIM') { + // contains spaces + this.checkAddress (address); + } return { 'info': response, 'currency': code, @@ -81014,13 +87810,12 @@ module.exports = class kucoin extends Exchange { // BCH {"code":"200000","data":{"address":"bitcoincash:qza3m4nj9rx7l9r0cdadfqxts6f92shvhvr5ls4q7z","memo":""}} // BTC {"code":"200000","data":{"address":"36SjucKqQpQSvsak9A7h6qzFjrVXpRNZhE","memo":""}} const data = this.safeValue (response, 'data', {}); - let address = this.safeString (data, 'address'); - // BCH/BSV is returned with a "bitcoincash:" prefix, which we cut off here and only keep the address - if (address !== undefined) { - address = address.replace ('bitcoincash:', ''); - } + const address = this.safeString (data, 'address'); const tag = this.safeString (data, 'memo'); - this.checkAddress (address); + if (code !== 'NIM') { + // contains spaces + this.checkAddress (address); + } return { 'info': response, 'currency': code, @@ -81034,20 +87829,22 @@ module.exports = class kucoin extends Exchange { } async fetchOrderBook (symbol, limit = undefined, params = {}) { - const level = this.safeInteger (params, 'level', 2); - let levelLimit = level.toString (); - if (levelLimit === '2') { - if (limit !== undefined) { - if ((limit !== 20) && (limit !== 100)) { - throw new ExchangeError (this.id + ' fetchOrderBook limit argument must be undefined, 20 or 100'); - } - levelLimit += '_' + limit.toString (); - } - } await this.loadMarkets (); const marketId = this.marketId (symbol); - const request = { 'symbol': marketId, 'level': levelLimit }; - const response = await this.publicGetMarketOrderbookLevelLevel (this.extend (request, params)); + const level = this.safeInteger (params, 'level', 2); + const request = { 'symbol': marketId, 'level': level }; + let method = 'publicGetMarketOrderbookLevelLevel'; + if (level === 2) { + if (limit !== undefined) { + if ((limit === 20) || (limit === 100)) { + request['limit'] = limit; + method = 'publicGetMarketOrderbookLevelLevelLimit'; + } else { + throw new ExchangeError (this.id + ' fetchOrderBook limit argument must be undefined, 20 or 100'); + } + } + } + const response = await this[method] (this.extend (request, params)); // // 'market/orderbook/level2' // 'market/orderbook/level2_20' @@ -81109,7 +87906,29 @@ module.exports = class kucoin extends Exchange { 'clientOid': clientOrderId, 'side': side, 'symbol': marketId, - 'type': type, + 'type': type, // limit or market + // 'remark': '', // optional remark for the order, length cannot exceed 100 utf8 characters + // 'stp': '', // self trade prevention, CN, CO, CB or DC + // To improve the system performance and to accelerate order placing and processing, KuCoin has added a new interface for margin orders + // The current one will no longer accept margin orders by May 1st, 2021 (UTC) + // At the time, KuCoin will notify users via the announcement, please pay attention to it + // 'tradeType': 'TRADE', // TRADE, MARGIN_TRADE // not used with margin orders + // limit orders --------------------------------------------------- + // 'timeInForce': 'GTC', // GTC, GTT, IOC, or FOK (default is GTC), limit orders only + // 'cancelAfter': long, // cancel after n seconds, requires timeInForce to be GTT + // 'postOnly': false, // Post only flag, invalid when timeInForce is IOC or FOK + // 'hidden': false, // Order will not be displayed in the order book + // 'iceberg': false, // Only a portion of the order is displayed in the order book + // 'visibleSize': this.amountToPrecision (symbol, visibleSize), // The maximum visible size of an iceberg order + // market orders -------------------------------------------------- + // 'size': this.amountToPrecision (symbol, amount), // Amount in base currency + // 'funds': this.costToPrecision (symbol, cost), // Amount of quote currency to use + // stop orders ---------------------------------------------------- + // 'stop': 'loss', // loss or entry, the default is loss, requires stopPrice + // 'stopPrice': this.priceToPrecision (symbol, amount), // need to be defined if stop is specified + // margin orders -------------------------------------------------- + // 'marginMode': 'cross', // cross (cross mode) and isolated (isolated mode), set to cross by default, the isolated mode will be released soon, stay tuned + // 'autoBorrow': false, // The system will first borrow you funds at the optimal interest rate and then place an order for you }; if (type !== 'market') { request['price'] = this.priceToPrecision (symbol, price); @@ -81161,9 +87980,32 @@ module.exports = class kucoin extends Exchange { } async cancelOrder (id, symbol = undefined, params = {}) { - const request = { 'orderId': id }; - const response = await this.privateDeleteOrdersOrderId (this.extend (request, params)); - return response; + await this.loadMarkets (); + const request = {}; + const clientOrderId = this.safeString2 (params, 'clientOid', 'clientOrderId'); + let method = 'privateDeleteOrdersOrderId'; + if (clientOrderId !== undefined) { + request['clientOid'] = clientOrderId; + method = 'privateDeleteOrdersClientOrderClientOid'; + } else { + request['orderId'] = id; + } + params = this.omit (params, [ 'clientOid', 'clientOrderId' ]); + return await this[method] (this.extend (request, params)); + } + + async cancelAllOrders (symbol = undefined, params = {}) { + await this.loadMarkets (); + const request = { + // 'symbol': market['id'], + // 'tradeType': 'TRADE', // default is to cancel the spot trading order + }; + let market = undefined; + if (symbol !== undefined) { + market = this.market (symbol); + request['symbol'] = market['id']; + } + return await this.privateDeleteOrders (this.extend (request, params)); } async fetchOrdersByStatus (status, symbol = undefined, since = undefined, limit = undefined, params = {}) { @@ -81241,20 +88083,27 @@ module.exports = class kucoin extends Exchange { async fetchOrder (id, symbol = undefined, params = {}) { await this.loadMarkets (); - // a special case for undefined ids - // otherwise a wrong endpoint for all orders will be triggered - // https://github.com/ccxt/ccxt/issues/7234 - if (id === undefined) { - throw new InvalidOrder (this.id + ' fetchOrder requires an order id'); + const request = {}; + const clientOrderId = this.safeString2 (params, 'clientOid', 'clientOrderId'); + let method = 'privateGetOrdersOrderId'; + if (clientOrderId !== undefined) { + request['clientOid'] = clientOrderId; + method = 'privateGetOrdersClientOrderClientOid'; + } else { + // a special case for undefined ids + // otherwise a wrong endpoint for all orders will be triggered + // https://github.com/ccxt/ccxt/issues/7234 + if (id === undefined) { + throw new InvalidOrder (this.id + ' fetchOrder() requires an order id'); + } + request['orderId'] = id; } - const request = { - 'orderId': id, - }; + params = this.omit (params, [ 'clientOid', 'clientOrderId' ]); + const response = await this[method] (this.extend (request, params)); let market = undefined; if (symbol !== undefined) { market = this.market (symbol); } - const response = await this.privateGetOrdersOrderId (this.extend (request, params)); const responseData = this.safeValue (response, 'data'); return this.parseOrder (responseData, market); } @@ -81331,12 +88180,14 @@ module.exports = class kucoin extends Exchange { const clientOrderId = this.safeString (order, 'clientOid'); const timeInForce = this.safeString (order, 'timeInForce'); const stopPrice = this.safeFloat (order, 'stopPrice'); + const postOnly = this.safeValue (order, 'postOnly'); return { 'id': orderId, 'clientOrderId': clientOrderId, 'symbol': symbol, 'type': type, 'timeInForce': timeInForce, + 'postOnly': postOnly, 'side': side, 'amount': amount, 'price': price, @@ -81665,6 +88516,7 @@ module.exports = class kucoin extends Exchange { // "status": "SUCCESS", // "createdAt": 1544178843000, // "updatedAt": 1544178891000 + // "remark":"foobar" // } // // fetchWithdrawals @@ -81681,6 +88533,7 @@ module.exports = class kucoin extends Exchange { // "status": "FAILURE", // "createdAt": 1546503758000, // "updatedAt": 1546504603000 + // "remark":"foobar" // } // const currencyId = this.safeString (transaction, 'currency'); @@ -81731,20 +88584,26 @@ module.exports = class kucoin extends Exchange { updated = updated * 1000; } } + const comment = this.safeString (transaction, 'remark'); return { 'id': id, + 'info': transaction, + 'timestamp': timestamp, + 'datetime': this.iso8601 (timestamp), 'address': address, + 'addressTo': address, + 'addressFrom': undefined, 'tag': tag, + 'tagTo': tag, + 'tagFrom': undefined, 'currency': code, 'amount': amount, 'txid': txid, 'type': type, 'status': status, + 'comment': comment, 'fee': fee, - 'timestamp': timestamp, - 'datetime': this.iso8601 (timestamp), 'updated': updated, - 'info': transaction, }; } @@ -81792,6 +88651,7 @@ module.exports = class kucoin extends Exchange { // "status": "SUCCESS", // "createdAt": 1544178843000, // "updatedAt": 1544178891000 + // "remark":"foobar" // }, // //-------------------------------------------------- // // version 1 (historical) deposit response structure @@ -81921,7 +88781,7 @@ module.exports = class kucoin extends Exchange { async fetchLedger (code = undefined, since = undefined, limit = undefined, params = {}) { if (code === undefined) { - throw new ArgumentsRequired (this.id + ' fetchLedger requires a code param'); + throw new ArgumentsRequired (this.id + ' fetchLedger() requires a code param'); } await this.loadMarkets (); await this.loadAccounts (); @@ -82064,7 +88924,7 @@ module.exports = class kucoin extends Exchange { // † ↑ // const versions = this.safeValue (this.options, 'versions', {}); - const apiVersions = this.safeValue (versions, api); + const apiVersions = this.safeValue (versions, api, {}); const methodVersions = this.safeValue (apiVersions, method, {}); const defaultVersion = this.safeString (methodVersions, path, this.options['version']); const version = this.safeString (params, 'version', defaultVersion); @@ -82087,10 +88947,17 @@ module.exports = class kucoin extends Exchange { this.checkRequiredCredentials (); const timestamp = this.nonce ().toString (); headers = this.extend ({ + 'KC-API-KEY-VERSION': '2', 'KC-API-KEY': this.apiKey, 'KC-API-TIMESTAMP': timestamp, - 'KC-API-PASSPHRASE': this.password, }, headers); + const apiKeyVersion = this.safeString (headers, 'KC-API-KEY-VERSION'); + if (apiKeyVersion === '2') { + const passphrase = this.hmac (this.encode (this.password), this.encode (this.secret), 'sha256', 'base64'); + headers['KC-API-PASSPHRASE'] = passphrase; + } else { + headers['KC-API-PASSPHRASE'] = this.password; + } const payload = timestamp + method + endpoint + endpart; const signature = this.hmac (this.encode (payload), this.encode (this.secret), 'sha256', 'base64'); headers['KC-API-SIGN'] = signature; @@ -82125,7 +88992,7 @@ module.exports = class kucoin extends Exchange { } }; -},{"./base/Exchange":5,"./base/errors":7}],101:[function(require,module,exports){ +},{"./base/Exchange":6,"./base/errors":8}],104:[function(require,module,exports){ 'use strict'; // --------------------------------------------------------------------------- @@ -82248,7 +89115,7 @@ module.exports = class kuna extends acx { async fetchOpenOrders (symbol = undefined, since = undefined, limit = undefined, params = {}) { if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' fetchOpenOrders requires a symbol argument'); + throw new ArgumentsRequired (this.id + ' fetchOpenOrders() requires a symbol argument'); } await this.loadMarkets (); const market = this.market (symbol); @@ -82310,7 +89177,7 @@ module.exports = class kuna extends acx { async fetchMyTrades (symbol = undefined, since = undefined, limit = undefined, params = {}) { if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' fetchOpenOrders requires a symbol argument'); + throw new ArgumentsRequired (this.id + ' fetchMyTrades() requires a symbol argument'); } await this.loadMarkets (); const market = this.market (symbol); @@ -82341,7 +89208,7 @@ module.exports = class kuna extends acx { } }; -},{"./acx.js":3,"./base/errors":7}],102:[function(require,module,exports){ +},{"./acx.js":4,"./base/errors":8}],105:[function(require,module,exports){ 'use strict'; // --------------------------------------------------------------------------- @@ -82671,7 +89538,7 @@ module.exports = class lakebtc extends Exchange { } }; -},{"./base/Exchange":5,"./base/errors":7}],103:[function(require,module,exports){ +},{"./base/Exchange":6,"./base/errors":8}],106:[function(require,module,exports){ 'use strict'; // --------------------------------------------------------------------------- @@ -83208,7 +90075,7 @@ module.exports = class latoken extends Exchange { async fetchMyTrades (symbol = undefined, since = undefined, limit = undefined, params = {}) { if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' fetchMyTrades requires a symbol argument'); + throw new ArgumentsRequired (this.id + ' fetchMyTrades() requires a symbol argument'); } await this.loadMarkets (); const market = this.market (symbol); @@ -83320,6 +90187,7 @@ module.exports = class latoken extends Exchange { 'symbol': symbol, 'type': type, 'timeInForce': undefined, + 'postOnly': undefined, 'side': side, 'price': price, 'stopPrice': undefined, @@ -83354,7 +90222,7 @@ module.exports = class latoken extends Exchange { async fetchOrdersWithMethod (method, symbol = undefined, since = undefined, limit = undefined, params = {}) { if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' fetchOrdersWithMethod requires a symbol argument'); + throw new ArgumentsRequired (this.id + ' fetchOrdersWithMethod() requires a symbol argument'); } await this.loadMarkets (); const market = this.market (symbol); @@ -83470,7 +90338,7 @@ module.exports = class latoken extends Exchange { async cancelAllOrders (symbol = undefined, params = {}) { if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' cancelAllOrders requires a symbol argument'); + throw new ArgumentsRequired (this.id + ' cancelAllOrders() requires a symbol argument'); } await this.loadMarkets (); const marketId = this.marketId (symbol); @@ -83560,7 +90428,7 @@ module.exports = class latoken extends Exchange { } }; -},{"./base/Exchange":5,"./base/errors":7,"./base/functions/number":13}],104:[function(require,module,exports){ +},{"./base/Exchange":6,"./base/errors":8,"./base/functions/number":14}],107:[function(require,module,exports){ 'use strict'; // --------------------------------------------------------------------------- @@ -83921,10 +90789,10 @@ module.exports = class lbank extends Exchange { await this.loadMarkets (); const market = this.market (symbol); if (since === undefined) { - throw new ArgumentsRequired (this.id + ' fetchOHLCV requires a `since` argument'); + throw new ArgumentsRequired (this.id + ' fetchOHLCV() requires a `since` argument'); } if (limit === undefined) { - throw new ArgumentsRequired (this.id + ' fetchOHLCV requires a `limit` argument'); + throw new ArgumentsRequired (this.id + ' fetchOHLCV() requires a `limit` argument'); } const request = { 'symbol': market['id'], @@ -84049,6 +90917,7 @@ module.exports = class lbank extends Exchange { 'symbol': symbol, 'type': type, 'timeInForce': undefined, + 'postOnly': undefined, 'side': side, 'price': price, 'stopPrice': undefined, @@ -84260,7 +91129,7 @@ module.exports = class lbank extends Exchange { } }; -},{"./base/Exchange":5,"./base/errors":7}],105:[function(require,module,exports){ +},{"./base/Exchange":6,"./base/errors":8}],108:[function(require,module,exports){ 'use strict'; // --------------------------------------------------------------------------- @@ -84449,6 +91318,7 @@ module.exports = class liquid extends Exchange { 'must_be_positive': InvalidOrder, 'less_than_order_size': InvalidOrder, 'price_too_high': InvalidOrder, + 'price_too_small': InvalidOrder, // {"errors":{"order":["price_too_small"]}} }, 'commonCurrencies': { 'WIN': 'WCOIN', @@ -84986,7 +91856,7 @@ module.exports = class liquid extends Exchange { async editOrder (id, symbol, type, side, amount, price = undefined, params = {}) { await this.loadMarkets (); if (price === undefined) { - throw new ArgumentsRequired (this.id + ' editOrder requires the price argument'); + throw new ArgumentsRequired (this.id + ' editOrder() requires the price argument'); } const request = { 'order': { @@ -85127,6 +91997,7 @@ module.exports = class liquid extends Exchange { 'lastTradeTimestamp': lastTradeTimestamp, 'type': type, 'timeInForce': undefined, + 'postOnly': undefined, 'status': status, 'symbol': symbol, 'side': side, @@ -85396,940 +92267,7 @@ module.exports = class liquid extends Exchange { } }; -},{"./base/Exchange":5,"./base/errors":7,"./base/functions/number":13}],106:[function(require,module,exports){ -'use strict'; - -// --------------------------------------------------------------------------- - -const Exchange = require ('./base/Exchange'); -const { ExchangeError, OnMaintenance, BadResponse, ArgumentsRequired, AuthenticationError, NotSupported, InvalidOrder, OrderNotFound, ExchangeNotAvailable, RateLimitExceeded, InsufficientFunds } = require ('./base/errors'); -const { TRUNCATE, DECIMAL_PLACES } = require ('./base/functions/number'); - -// --------------------------------------------------------------------------- - -module.exports = class livecoin extends Exchange { - describe () { - return this.deepExtend (super.describe (), { - 'id': 'livecoin', - 'name': 'LiveCoin', - 'countries': [ 'US', 'UK', 'RU' ], - 'rateLimit': 1000, - 'userAgent': this.userAgents['chrome'], - 'has': { - 'cancelOrder': true, - 'CORS': false, - 'createOrder': true, - 'fetchBalance': true, - 'fetchClosedOrders': true, - 'fetchCurrencies': true, - 'fetchDepositAddress': true, - 'fetchDeposits': true, - 'fetchMarkets': true, - 'fetchMyTrades': true, - 'fetchOpenOrders': true, - 'fetchOrder': true, - 'fetchOrderBook': true, - 'fetchOrders': true, - 'fetchTicker': true, - 'fetchTickers': true, - 'fetchTrades': true, - 'fetchTradingFee': true, - 'fetchTradingFees': true, - 'fetchWithdrawals': true, - 'withdraw': true, - }, - 'urls': { - 'logo': 'https://user-images.githubusercontent.com/1294454/27980768-f22fc424-638a-11e7-89c9-6010a54ff9be.jpg', - 'api': 'https://api.livecoin.net', - 'www': 'https://www.livecoin.net', - 'doc': 'https://www.livecoin.net/api?lang=en', - 'referral': 'https://livecoin.net/?from=Livecoin-CQ1hfx44', - }, - 'api': { - 'public': { - 'get': [ - 'exchange/all/order_book', - 'exchange/last_trades', - 'exchange/maxbid_minask', - 'exchange/order_book', - 'exchange/restrictions', - 'exchange/ticker', // omit params to get all tickers at once - 'info/coinInfo', - ], - }, - 'private': { - 'get': [ - 'exchange/client_orders', - 'exchange/order', - 'exchange/trades', - 'exchange/commission', - 'exchange/commissionCommonInfo', - 'payment/balances', - 'payment/balance', - 'payment/get/address', - 'payment/history/size', - 'payment/history/transactions', - ], - 'post': [ - 'exchange/buylimit', - 'exchange/buymarket', - 'exchange/cancellimit', - 'exchange/selllimit', - 'exchange/sellmarket', - 'payment/out/capitalist', - 'payment/out/card', - 'payment/out/coin', - 'payment/out/okpay', - 'payment/out/payeer', - 'payment/out/perfectmoney', - 'payment/voucher/amount', - 'payment/voucher/make', - 'payment/voucher/redeem', - ], - }, - }, - 'fees': { - 'trading': { - 'tierBased': false, - 'percentage': true, - 'maker': 0.18 / 100, - 'taker': 0.18 / 100, - }, - }, - 'commonCurrencies': { - 'BIT': 'First Bitcoin', - 'BTCH': 'Bithash', - 'CPC': 'Capricoin', - 'CBC': 'CryptoBossCoin', // conflict with CBC (CashBet Coin) - 'CPT': 'Cryptos', // conflict with CPT = Contents Protocol https://github.com/ccxt/ccxt/issues/4920 and https://github.com/ccxt/ccxt/issues/6081 - 'EDR': 'E-Dinar Coin', // conflicts with EDR for Endor Protocol and EDRCoin - 'eETT': 'EETT', - 'FirstBlood': '1ST', - 'FORTYTWO': '42', - 'LEO': 'LeoCoin', - 'MIOTA': 'IOTA', // https://github.com/ccxt/ccxt/issues/7487 - 'ORE': 'Orectic', - 'PLN': 'Plutaneum', // conflict with Polish Zloty - 'RUR': 'RUB', - 'SCT': 'SpaceCoin', - 'TPI': 'ThaneCoin', - 'UNUS': 'LEO', // https://github.com/ccxt/ccxt/issues/7496 - 'WAX': 'WAXP', - 'wETT': 'WETT', - 'XBT': 'Bricktox', - }, - 'exceptions': { - 'exact': { - '1': ExchangeError, - '10': AuthenticationError, - '100': ExchangeError, // invalid parameters - '101': AuthenticationError, - '102': AuthenticationError, - '103': InvalidOrder, // invalid currency - '104': InvalidOrder, // invalid amount - '105': InvalidOrder, // unable to block funds - '11': AuthenticationError, - '12': AuthenticationError, - '2': AuthenticationError, // "User not found" - '20': AuthenticationError, - '30': AuthenticationError, - '31': NotSupported, - '32': ExchangeError, - '429': RateLimitExceeded, - '503': ExchangeNotAvailable, - }, - 'broad': { - 'insufficient funds': InsufficientFunds, // https://github.com/ccxt/ccxt/issues/5749 - 'NOT FOUND': OrderNotFound, - 'Cannot find order': OrderNotFound, - 'Minimal amount is': InvalidOrder, - }, - }, - }); - } - - async fetchMarkets (params = {}) { - const response = await this.publicGetExchangeTicker (params); - const restrictions = await this.publicGetExchangeRestrictions (); - const restrictionsById = this.indexBy (restrictions['restrictions'], 'currencyPair'); - const result = []; - for (let i = 0; i < response.length; i++) { - const market = response[i]; - const id = this.safeString (market, 'symbol'); - const [ baseId, quoteId ] = id.split ('/'); - const base = this.safeCurrencyCode (baseId); - const quote = this.safeCurrencyCode (quoteId); - const symbol = base + '/' + quote; - const coinRestrictions = this.safeValue (restrictionsById, symbol); - const precision = { - 'price': 5, - 'amount': 8, - 'cost': 8, - }; - const limits = { - 'amount': { - 'min': Math.pow (10, -precision['amount']), - 'max': Math.pow (10, precision['amount']), - }, - }; - if (coinRestrictions) { - precision['price'] = this.safeInteger (coinRestrictions, 'priceScale', 5); - limits['amount']['min'] = this.safeFloat (coinRestrictions, 'minLimitQuantity', limits['amount']['min']); - } - limits['price'] = { - 'min': Math.pow (10, -precision['price']), - 'max': Math.pow (10, precision['price']), - }; - result.push ({ - 'id': id, - 'symbol': symbol, - 'base': base, - 'quote': quote, - 'baseId': baseId, - 'quoteId': quoteId, - 'active': true, - 'precision': precision, - 'limits': limits, - 'info': market, - }); - } - return result; - } - - async fetchCurrencies (params = {}) { - const response = await this.publicGetInfoCoinInfo (params); - if (typeof response === 'string') { - if (response.indexOf ('site is under maintenance') >= 0) { - throw new OnMaintenance (this.id + ' fetchCurrencies() failed to fetch the currencies, the exchange is on maintenance'); - } else { - throw new BadResponse (this.id + ' fetchCurrencies() failed to fetch the currencies'); - } - } - const currencies = this.safeValue (response, 'info'); - let result = {}; - for (let i = 0; i < currencies.length; i++) { - const currency = currencies[i]; - const id = this.safeString (currency, 'symbol'); - // todo: will need to rethink the fees - // to add support for multiple withdrawal/deposit methods and - // differentiated fees for each particular method - const code = this.safeCurrencyCode (id); - const precision = 8; // default precision, todo: fix "magic constants" - const walletStatus = this.safeString (currency, 'walletStatus'); - const active = (walletStatus === 'normal'); - const name = this.safeString (currency, 'name'); - const fee = this.safeFloat (currency, 'withdrawFee'); - result[code] = { - 'id': id, - 'code': code, - 'info': currency, - 'name': name, - 'active': active, - 'fee': fee, - 'precision': precision, - 'limits': { - 'amount': { - 'min': this.safeFloat (currency, 'minOrderAmount'), - 'max': Math.pow (10, precision), - }, - 'price': { - 'min': Math.pow (10, -precision), - 'max': Math.pow (10, precision), - }, - 'cost': { - 'min': this.safeFloat (currency, 'minOrderAmount'), - 'max': undefined, - }, - 'withdraw': { - 'min': this.safeFloat (currency, 'minWithdrawAmount'), - 'max': Math.pow (10, precision), - }, - 'deposit': { - 'min': this.safeFloat (currency, 'minDepositAmount'), - 'max': undefined, - }, - }, - }; - } - result = this.appendFiatCurrencies (result); - return result; - } - - appendFiatCurrencies (result) { - const precision = 8; - const defaults = { - 'info': undefined, - 'active': true, - 'fee': undefined, - 'precision': precision, - 'limits': { - 'withdraw': { 'min': undefined, 'max': undefined }, - 'deposit': { 'min': undefined, 'max': undefined }, - 'amount': { 'min': undefined, 'max': undefined }, - 'cost': { 'min': undefined, 'max': undefined }, - 'price': { - 'min': Math.pow (10, -precision), - 'max': Math.pow (10, precision), - }, - }, - 'id': undefined, - 'code': undefined, - 'name': undefined, - }; - const currencies = [ - { 'id': 'USD', 'code': 'USD', 'name': 'US Dollar' }, - { 'id': 'EUR', 'code': 'EUR', 'name': 'Euro' }, - // { 'id': 'RUR', 'code': 'RUB', 'name': 'Russian ruble' }, - ]; - currencies.push ({ - 'id': 'RUR', - 'code': this.safeCurrencyCode ('RUR'), - 'name': 'Russian ruble', - }); - for (let i = 0; i < currencies.length; i++) { - const currency = currencies[i]; - const code = currency['code']; - result[code] = this.extend (defaults, currency); - } - return result; - } - - async fetchBalance (params = {}) { - await this.loadMarkets (); - const response = await this.privateGetPaymentBalances (params); - const result = { 'info': response }; - for (let i = 0; i < response.length; i++) { - const balance = response[i]; - const currencyId = this.safeString (balance, 'currency'); - const code = this.safeCurrencyCode (currencyId); - let account = undefined; - if (code in result) { - account = result[code]; - } else { - account = this.account (); - } - if (balance['type'] === 'total') { - account['total'] = this.safeFloat (balance, 'value'); - } - if (balance['type'] === 'available') { - account['free'] = this.safeFloat (balance, 'value'); - } - if (balance['type'] === 'trade') { - account['used'] = this.safeFloat (balance, 'value'); - } - result[code] = account; - } - return this.parseBalance (result); - } - - async fetchTradingFees (params = {}) { - await this.loadMarkets (); - const response = await this.privateGetExchangeCommissionCommonInfo (params); - const commission = this.safeFloat (response, 'commission'); - return { - 'info': response, - 'maker': commission, - 'taker': commission, - }; - } - - async fetchOrderBook (symbol, limit = undefined, params = {}) { - await this.loadMarkets (); - const request = { - 'currencyPair': this.marketId (symbol), - 'groupByPrice': 'false', - }; - if (limit !== undefined) { - request['depth'] = limit; // 100 - } - const response = await this.publicGetExchangeOrderBook (this.extend (request, params)); - const timestamp = this.safeInteger (response, 'timestamp'); - return this.parseOrderBook (response, timestamp); - } - - parseTicker (ticker, market = undefined) { - const timestamp = this.milliseconds (); - let symbol = undefined; - if (market) { - symbol = market['symbol']; - } - const vwap = this.safeFloat (ticker, 'vwap'); - const baseVolume = this.safeFloat (ticker, 'volume'); - let quoteVolume = undefined; - if (baseVolume !== undefined && vwap !== undefined) { - quoteVolume = baseVolume * vwap; - } - const last = this.safeFloat (ticker, 'last'); - return { - 'symbol': symbol, - 'timestamp': timestamp, - 'datetime': this.iso8601 (timestamp), - 'high': this.safeFloat (ticker, 'high'), - 'low': this.safeFloat (ticker, 'low'), - 'bid': this.safeFloat (ticker, 'best_bid'), - 'bidVolume': undefined, - 'ask': this.safeFloat (ticker, 'best_ask'), - 'askVolume': undefined, - 'vwap': this.safeFloat (ticker, 'vwap'), - 'open': undefined, - 'close': last, - 'last': last, - 'previousClose': undefined, - 'change': undefined, - 'percentage': undefined, - 'average': undefined, - 'baseVolume': baseVolume, - 'quoteVolume': quoteVolume, - 'info': ticker, - }; - } - - async fetchTickers (symbols = undefined, params = {}) { - await this.loadMarkets (); - const response = await this.publicGetExchangeTicker (params); - const tickers = this.indexBy (response, 'symbol'); - const ids = Object.keys (tickers); - const result = {}; - for (let i = 0; i < ids.length; i++) { - const id = ids[i]; - const market = this.safeMarket (id); - const symbol = market['symbol']; - const ticker = tickers[id]; - result[symbol] = this.parseTicker (ticker, market); - } - return this.filterByArray (result, 'symbol', symbols); - } - - async fetchTicker (symbol, params = {}) { - await this.loadMarkets (); - const market = this.market (symbol); - const request = { - 'currencyPair': market['id'], - }; - const ticker = await this.publicGetExchangeTicker (this.extend (request, params)); - return this.parseTicker (ticker, market); - } - - parseTrade (trade, market = undefined) { - // - // fetchTrades (public) - // - // { - // "time": 1409935047, - // "id": 99451, - // "price": 350, - // "quantity": 2.85714285, - // "type": "BUY" - // } - // - // fetchMyTrades (private) - // - // { - // "datetime": 1435844369, - // "id": 30651619, - // "type": "sell", - // "symbol": "BTC/EUR", - // "price": 230, - // "quantity": 0.1, - // "commission": 0, - // "clientorderid": 1472837650 - // } - const timestamp = this.safeTimestamp2 (trade, 'time', 'datetime'); - let fee = undefined; - const feeCost = this.safeFloat (trade, 'commission'); - if (feeCost !== undefined) { - const feeCurrency = market ? market['quote'] : undefined; - fee = { - 'cost': feeCost, - 'currency': feeCurrency, - }; - } - const orderId = this.safeString (trade, 'clientorderid'); - const id = this.safeString (trade, 'id'); - const side = this.safeStringLower (trade, 'type'); - const amount = this.safeFloat (trade, 'quantity'); - const price = this.safeFloat (trade, 'price'); - let cost = undefined; - if (amount !== undefined) { - if (price !== undefined) { - cost = amount * price; - } - } - const marketId = this.safeString (trade, 'symbol'); - const symbol = this.safeSymbol (marketId, market, '/'); - return { - 'id': id, - 'info': trade, - 'timestamp': timestamp, - 'datetime': this.iso8601 (timestamp), - 'symbol': symbol, - 'order': orderId, - 'type': undefined, - 'side': side, - 'takerOrMaker': undefined, - 'price': price, - 'amount': amount, - 'cost': cost, - 'fee': fee, - }; - } - - async fetchMyTrades (symbol = undefined, since = undefined, limit = undefined, params = {}) { - await this.loadMarkets (); - const request = { - // 'currencyPair': market['id'], - // 'orderDesc': 'true', // or 'false', if true then new orders will be first, otherwise old orders will be first. - // 'offset': 0, // page offset, position of the first item on the page - }; - let market = undefined; - if (symbol !== undefined) { - market = this.market (symbol); - request['currencyPair'] = market['id']; - } - if (limit !== undefined) { - request['limit'] = limit; - } - const response = await this.privateGetExchangeTrades (this.extend (request, params)); - // - // [ - // { - // "datetime": 1435844369, - // "id": 30651619, - // "type": "sell", - // "symbol": "BTC/EUR", - // "price": 230, - // "quantity": 0.1, - // "commission": 0, - // "clientorderid": 1472837650 - // }, - // { - // "datetime": 1435844356, - // "id": 30651618, - // "type": "sell", - // "symbol": "BTC/EUR", - // "price": 230, - // "quantity": 0.2, - // "commission": 0.092, - // "clientorderid": 1472837651 - // } - // ] - // - return this.parseTrades (response, market, since, limit); - } - - async fetchTrades (symbol, since = undefined, limit = undefined, params = {}) { - await this.loadMarkets (); - const market = this.market (symbol); - const request = { - 'currencyPair': market['id'], - }; - const response = await this.publicGetExchangeLastTrades (this.extend (request, params)); - // - // [ - // { - // "time": 1409935047, - // "id": 99451, - // "price": 350, - // "quantity": 2.85714285, - // "type": "BUY" - // }, - // { - // "time": 1409934792, - // "id": 99450, - // "price": 350, - // "quantity": 0.57142857, - // "type": "SELL" - // } - // ] - // - return this.parseTrades (response, market, since, limit); - } - - async fetchOrder (id, symbol = undefined, params = {}) { - await this.loadMarkets (); - const request = { - 'orderId': id, - }; - const response = await this.privateGetExchangeOrder (this.extend (request, params)); - return this.parseOrder (response); - } - - parseOrderStatus (status) { - const statuses = { - 'OPEN': 'open', - 'PARTIALLY_FILLED': 'open', - 'EXECUTED': 'closed', - 'CANCELLED': 'canceled', - 'PARTIALLY_FILLED_AND_CANCELLED': 'canceled', - }; - return this.safeString (statuses, status, status); - } - - parseOrder (order, market = undefined) { - let timestamp = undefined; - if ('lastModificationTime' in order) { - timestamp = this.safeString (order, 'lastModificationTime'); - if (timestamp !== undefined) { - if (timestamp.indexOf ('T') >= 0) { - timestamp = this.parse8601 (timestamp); - } else { - timestamp = this.safeInteger (order, 'lastModificationTime'); - } - } - } - // TODO currently not supported by livecoin - // let trades = this.parseTrades (order['trades'], market, since, limit); - const trades = undefined; - const status = this.parseOrderStatus (this.safeString2 (order, 'status', 'orderStatus')); - const marketId = this.safeString2 (order, 'symbol', 'currencyPair'); - const symbol = this.safeSymbol (marketId, market, '/'); - let type = this.safeStringLower (order, 'type'); - let side = undefined; - if (type !== undefined) { - const orderType = type.split ('_'); - type = orderType[0]; - side = orderType[1]; - } - const price = this.safeFloat (order, 'price'); - // of the next two lines the latter overrides the former, if present in the order structure - let remaining = this.safeFloat (order, 'remainingQuantity'); - remaining = this.safeFloat (order, 'remaining_quantity', remaining); - const amount = this.safeFloat (order, 'quantity', remaining); - let filled = undefined; - if (remaining !== undefined) { - filled = amount - remaining; - } - let cost = undefined; - if (filled !== undefined && price !== undefined) { - cost = filled * price; - } - const feeRate = this.safeFloat (order, 'commission_rate'); - let feeCost = undefined; - if (cost !== undefined && feeRate !== undefined) { - feeCost = cost * feeRate; - } - if ((market === undefined) && (symbol in this.markets)) { - market = this.markets[symbol]; - } - let feeCurrency = undefined; - if (market !== undefined) { - feeCurrency = market['quote']; - } - return { - 'info': order, - 'id': order['id'], - 'clientOrderId': undefined, - 'timestamp': timestamp, - 'datetime': this.iso8601 (timestamp), - 'lastTradeTimestamp': undefined, - 'status': status, - 'symbol': symbol, - 'type': type, - 'timeInForce': undefined, - 'side': side, - 'price': price, - 'stopPrice': undefined, - 'amount': amount, - 'cost': cost, - 'filled': filled, - 'remaining': remaining, - 'trades': trades, - 'fee': { - 'cost': feeCost, - 'currency': feeCurrency, - 'rate': feeRate, - }, - 'average': undefined, - }; - } - - async fetchOrders (symbol = undefined, since = undefined, limit = undefined, params = {}) { - await this.loadMarkets (); - let market = undefined; - const request = {}; - if (symbol !== undefined) { - market = this.market (symbol); - request['currencyPair'] = market['id']; - } - if (since !== undefined) { - request['issuedFrom'] = parseInt (since); - } - if (limit !== undefined) { - request['endRow'] = limit - 1; - } - const response = await this.privateGetExchangeClientOrders (this.extend (request, params)); - const result = []; - let rawOrders = []; - if (response['data']) { - rawOrders = response['data']; - } - for (let i = 0; i < rawOrders.length; i++) { - const order = rawOrders[i]; - result.push (this.parseOrder (order, market)); - } - return this.sortBy (result, 'timestamp'); - } - - async fetchOpenOrders (symbol = undefined, since = undefined, limit = undefined, params = {}) { - const request = { - 'openClosed': 'OPEN', - }; - return await this.fetchOrders (symbol, since, limit, this.extend (request, params)); - } - - async fetchClosedOrders (symbol = undefined, since = undefined, limit = undefined, params = {}) { - const request = { - 'openClosed': 'CLOSED', - }; - return await this.fetchOrders (symbol, since, limit, this.extend (request, params)); - } - - async createOrder (symbol, type, side, amount, price = undefined, params = {}) { - await this.loadMarkets (); - const method = 'privatePostExchange' + this.capitalize (side) + type; - const market = this.market (symbol); - const request = { - 'quantity': this.amountToPrecision (symbol, amount), - 'currencyPair': market['id'], - }; - if (type === 'limit') { - request['price'] = this.priceToPrecision (symbol, price); - } - const response = await this[method] (this.extend (request, params)); - const result = { - 'info': response, - 'id': response['orderId'].toString (), - }; - const success = this.safeValue (response, 'success'); - if (success) { - result['status'] = 'open'; - } - return result; - } - - async cancelOrder (id, symbol = undefined, params = {}) { - if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' cancelOrder requires a symbol argument'); - } - await this.loadMarkets (); - const market = this.market (symbol); - const request = { - 'orderId': id, - 'currencyPair': market['id'], - }; - const response = await this.privatePostExchangeCancellimit (this.extend (request, params)); - const message = this.safeString (response, 'message', this.json (response)); - if ('success' in response) { - if (!response['success']) { - throw new InvalidOrder (message); - } else if ('cancelled' in response) { - if (response['cancelled']) { - return { - 'status': 'canceled', - 'info': response, - }; - } else { - throw new OrderNotFound (message); - } - } - } - throw new ExchangeError (this.id + ' cancelOrder() failed: ' + this.json (response)); - } - - async withdraw (code, amount, address, tag = undefined, params = {}) { - // Sometimes the response with be { key: null } for all keys. - // An example is if you attempt to withdraw more than is allowed when withdrawal fees are considered. - this.checkAddress (address); - await this.loadMarkets (); - const currency = this.currency (code); - let wallet = address; - if (tag !== undefined) { - wallet += '::' + tag; - } - const request = { - 'amount': this.decimalToPrecision (amount, TRUNCATE, currency['precision'], DECIMAL_PLACES), - 'currency': currency['id'], - 'wallet': wallet, - }; - const response = await this.privatePostPaymentOutCoin (this.extend (request, params)); - const id = this.safeInteger (response, 'id'); - if (id === undefined) { - throw new InsufficientFunds (this.id + ' insufficient funds to cover requested withdrawal amount post fees ' + this.json (response)); - } - return { - 'info': response, - 'id': id, - }; - } - - parseTransaction (transaction, currency = undefined) { - // { - // "id": "c853093d5aa06df1c92d79c2...", (tx on deposits, address on withdrawals) - // "type": "DEPOSIT", - // "date": 1553186482676, - // "amount": 712.61266, - // "fee": 0, - // "fixedCurrency": "XVG", - // "taxCurrency": "XVG", - // "variableAmount": null, - // "variableCurrency": null, - // "external": "Coin", - // "login": "USERNAME", - // "externalKey": "....87diPBy......3hTtuwUT78Yi", (address on deposits, tx on withdrawals) - // "documentId": 1110662453 - // }, - let txid = undefined; - let address = undefined; - const id = this.safeString (transaction, 'documentId'); - const amount = this.safeFloat (transaction, 'amount'); - const timestamp = this.safeInteger (transaction, 'date'); - const type = this.safeStringLower (transaction, 'type'); - const currencyId = this.safeString (transaction, 'fixedCurrency'); - const feeCost = this.safeFloat (transaction, 'fee'); - const code = this.safeCurrencyCode (currencyId, currency); - if (type === 'withdrawal') { - txid = this.safeString (transaction, 'externalKey'); - address = this.safeString (transaction, 'id'); - } else if (type === 'deposit') { - address = this.safeString (transaction, 'externalKey'); - txid = this.safeString (transaction, 'id'); - } - let status = undefined; - if (type === 'deposit') { - status = 'ok'; // Deposits is not registered until they are in account. Withdrawals are left as undefined, not entirely sure about theyre status. - } - return { - 'info': transaction, - 'id': id, - 'currency': code, - 'amount': amount, - 'address': address, - 'tag': undefined, - 'status': status, - 'type': type, - 'updated': undefined, - 'txid': txid, - 'timestamp': timestamp, - 'datetime': this.iso8601 (timestamp), - 'fee': { - 'currency': code, - 'cost': feeCost, - }, - }; - } - - async fetchDeposits (code = undefined, since = undefined, limit = undefined, params = {}) { - await this.loadMarkets (); - const endtime = 2505600000; // 29 days - exchange has maximum 30 days. - const now = this.milliseconds (); - const request = { - 'types': 'DEPOSIT', - 'end': now, - 'start': (since !== undefined) ? parseInt (since) : now - endtime, - }; - let currency = undefined; - if (code !== undefined) { - currency = this.currency (code); - } - if (limit !== undefined) { - request['limit'] = limit; // default is 100 - } - const response = await this.privateGetPaymentHistoryTransactions (this.extend (request, params)); - return this.parseTransactions (response, currency, since, limit); - } - - async fetchWithdrawals (code = undefined, since = undefined, limit = undefined, params = {}) { - await this.loadMarkets (); - const endtime = 2505600000; // 29 days - exchange has maximum 30 days. - const now = this.milliseconds (); - const request = { - 'types': 'WITHDRAWAL', - 'end': now, - 'start': (since !== undefined) ? parseInt (since) : now - endtime, - }; - let currency = undefined; - if (code !== undefined) { - currency = this.currency (code); - } - if (limit !== undefined) { - request['limit'] = limit; // default is 100 - } - if (since !== undefined) { - request['start'] = since; - } - const response = await this.privateGetPaymentHistoryTransactions (this.extend (request, params)); - return this.parseTransactions (response, currency, since, limit); - } - - async fetchDepositAddress (currency, params = {}) { - const request = { - 'currency': currency, - }; - const response = await this.privateGetPaymentGetAddress (this.extend (request, params)); - let address = this.safeString (response, 'wallet'); - let tag = undefined; - if (address.indexOf (':') >= 0) { - const parts = address.split (':'); - address = parts[0]; - tag = parts[2]; - } - this.checkAddress (address); - return { - 'currency': currency, - 'address': address, - 'tag': tag, - 'info': response, - }; - } - - sign (path, api = 'public', method = 'GET', params = {}, headers = undefined, body = undefined) { - let url = this.urls['api'] + '/' + path; - const query = this.urlencode (this.keysort (params)); - if (method === 'GET') { - if (Object.keys (params).length) { - url += '?' + query; - } - } - if (api === 'private') { - this.checkRequiredCredentials (); - if (method === 'POST') { - body = query; - } - const signature = this.hmac (this.encode (query), this.encode (this.secret), 'sha256'); - headers = { - 'Api-Key': this.apiKey, - 'Sign': signature.toUpperCase (), - 'Content-Type': 'application/x-www-form-urlencoded', - }; - } - return { 'url': url, 'method': method, 'body': body, 'headers': headers }; - } - - handleErrors (code, reason, url, method, headers, body, response, requestHeaders, requestBody) { - if (response === undefined) { - return; // fallback to default error handler - } - if (code >= 300) { - const feedback = this.id + ' ' + body; - const errorCode = this.safeString (response, 'errorCode'); - this.throwExactlyMatchedException (this.exceptions['exact'], errorCode, feedback); - throw new ExchangeError (feedback); - } - // returns status code 200 even if success === false - const success = this.safeValue (response, 'success', true); - if (!success) { - const feedback = this.id + ' ' + body; - const message = this.safeString2 (response, 'message', 'exception'); - if (message !== undefined) { - this.throwBroadlyMatchedException (this.exceptions['broad'], message, feedback); - } - throw new ExchangeError (feedback); - } - } -}; - - -},{"./base/Exchange":5,"./base/errors":7,"./base/functions/number":13}],107:[function(require,module,exports){ +},{"./base/Exchange":6,"./base/errors":8,"./base/functions/number":14}],109:[function(require,module,exports){ 'use strict'; // --------------------------------------------------------------------------- @@ -86370,7 +92308,11 @@ module.exports = class luno extends Exchange { 'urls': { 'referral': 'https://www.luno.com/invite/44893A', 'logo': 'https://user-images.githubusercontent.com/1294454/27766607-8c1a69d8-5ede-11e7-930c-540b5eb9be24.jpg', - 'api': 'https://api.luno.com/api', + 'api': { + 'public': 'https://api.luno.com/api', + 'private': 'https://api.luno.com/api', + 'exchange': 'https://api.luno.com/api/exchange', + }, 'www': 'https://www.luno.com', 'doc': [ 'https://www.luno.com/en/api', @@ -86379,6 +92321,11 @@ module.exports = class luno extends Exchange { ], }, 'api': { + 'exchange': { + 'get': [ + 'markets', + ], + }, 'public': { 'get': [ 'orderbook', @@ -86429,16 +92376,42 @@ module.exports = class luno extends Exchange { } async fetchMarkets (params = {}) { - const response = await this.publicGetTickers (params); + const response = await this.exchangeGetMarkets (params); + // + // { + // "markets":[ + // { + // "market_id":"BCHXBT", + // "trading_status":"ACTIVE", + // "base_currency":"BCH", + // "counter_currency":"XBT", + // "min_volume":"0.01", + // "max_volume":"100.00", + // "volume_scale":2, + // "min_price":"0.0001", + // "max_price":"1.00", + // "price_scale":6, + // "fee_scale":8, + // }, + // ] + // } + // const result = []; - for (let i = 0; i < response['tickers'].length; i++) { - const market = response['tickers'][i]; - const id = market['pair']; - const baseId = id.slice (0, 3); - const quoteId = id.slice (3, 6); + const markets = this.safeValue (response, 'markets', []); + for (let i = 0; i < markets.length; i++) { + const market = markets[i]; + const id = this.safeString (market, 'market_id'); + const baseId = this.safeString (market, 'base_currency'); + const quoteId = this.safeString (market, 'counter_currency'); const base = this.safeCurrencyCode (baseId); const quote = this.safeCurrencyCode (quoteId); const symbol = base + '/' + quote; + const status = this.safeString (market, 'trading_status'); + const active = (status === 'ACTIVE'); + const precision = { + 'amount': this.safeInteger (market, 'volume_scale'), + 'price': this.safeInteger (market, 'price_scale'), + }; result.push ({ 'id': id, 'symbol': symbol, @@ -86446,10 +92419,23 @@ module.exports = class luno extends Exchange { 'quote': quote, 'baseId': baseId, 'quoteId': quoteId, + 'active': active, + 'precision': precision, + 'limits': { + 'amount': { + 'min': this.safeFloat (market, 'min_volume'), + 'max': this.safeFloat (market, 'max_volume'), + }, + 'price': { + 'min': this.safeFloat (market, 'min_price'), + 'max': this.safeFloat (market, 'max_price'), + }, + 'cost': { + 'min': undefined, + 'max': undefined, + }, + }, 'info': market, - 'active': undefined, - 'precision': this.precision, - 'limits': this.limits, }); } return result; @@ -86477,6 +92463,16 @@ module.exports = class luno extends Exchange { async fetchBalance (params = {}) { await this.loadMarkets (); const response = await this.privateGetBalance (params); + // + // { + // 'balance': [ + // {'account_id': '119...1336','asset': 'XBT','balance': '0.00','reserved': '0.00','unconfirmed': '0.00'}, + // {'account_id': '66...289','asset': 'XBT','balance': '0.00','reserved': '0.00','unconfirmed': '0.00'}, + // {'account_id': '718...5300','asset': 'ETH','balance': '0.00','reserved': '0.00','unconfirmed': '0.00'}, + // {'account_id': '818...7072','asset': 'ZAR','balance': '0.001417','reserved': '0.00','unconfirmed': '0.00'}]} + // ] + // } + // const wallets = this.safeValue (response, 'balance', []); const result = { 'info': response }; for (let i = 0; i < wallets.length; i++) { @@ -86486,10 +92482,15 @@ module.exports = class luno extends Exchange { const reserved = this.safeFloat (wallet, 'reserved'); const unconfirmed = this.safeFloat (wallet, 'unconfirmed'); const balance = this.safeFloat (wallet, 'balance'); - const account = this.account (); - account['used'] = this.sum (reserved, unconfirmed); - account['total'] = this.sum (balance, unconfirmed); - result[code] = account; + if (code in result) { + result[code]['used'] = this.sum (result[code]['used'], reserved, unconfirmed); + result[code]['total'] = this.sum (result[code]['total'], balance, unconfirmed); + } else { + const account = this.account (); + account['used'] = this.sum (reserved, unconfirmed); + account['total'] = this.sum (balance, unconfirmed); + result[code] = account; + } } return this.parseBalance (result); } @@ -86577,6 +92578,7 @@ module.exports = class luno extends Exchange { 'symbol': symbol, 'type': undefined, 'timeInForce': undefined, + 'postOnly': undefined, 'side': side, 'price': price, 'stopPrice': undefined, @@ -86757,7 +92759,7 @@ module.exports = class luno extends Exchange { async fetchMyTrades (symbol = undefined, since = undefined, limit = undefined, params = {}) { if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' fetchMyTrades requires a symbol argument'); + throw new ArgumentsRequired (this.id + ' fetchMyTrades() requires a symbol argument'); } await this.loadMarkets (); const market = this.market (symbol); @@ -86794,15 +92796,16 @@ module.exports = class luno extends Exchange { if (type === 'market') { method += 'Marketorder'; request['type'] = side.toUpperCase (); + // todo add createMarketBuyOrderRequires price logic as it is implemented in the other exchanges if (side === 'buy') { - request['counter_volume'] = amount; + request['counter_volume'] = parseFloat (this.amountToPrecision (symbol, amount)); } else { - request['base_volume'] = amount; + request['base_volume'] = parseFloat (this.amountToPrecision (symbol, amount)); } } else { method += 'Postorder'; - request['volume'] = amount; - request['price'] = price; + request['volume'] = parseFloat (this.amountToPrecision (symbol, amount)); + request['price'] = parseFloat (this.priceToPrecision (symbol, price)); request['type'] = (side === 'buy') ? 'BID' : 'ASK'; } const response = await this[method] (this.extend (request, params)); @@ -86961,7 +92964,7 @@ module.exports = class luno extends Exchange { } sign (path, api = 'public', method = 'GET', params = {}, headers = undefined, body = undefined) { - let url = this.urls['api'] + '/' + this.version + '/' + this.implodeParams (path, params); + let url = this.urls['api'][api] + '/' + this.version + '/' + this.implodeParams (path, params); const query = this.omit (params, this.extractParams (path)); if (Object.keys (query).length) { url += '?' + this.urlencode (query); @@ -86985,7 +92988,7 @@ module.exports = class luno extends Exchange { } }; -},{"./base/Exchange":5,"./base/errors":7}],108:[function(require,module,exports){ +},{"./base/Exchange":6,"./base/errors":8}],110:[function(require,module,exports){ 'use strict'; // --------------------------------------------------------------------------- @@ -87487,6 +93490,7 @@ module.exports = class lykke extends Exchange { 'symbol': symbol, 'type': undefined, 'timeInForce': undefined, + 'postOnly': undefined, 'side': side, 'price': price, 'stopPrice': undefined, @@ -87600,7 +93604,7 @@ module.exports = class lykke extends Exchange { } }; -},{"./base/Exchange":5}],109:[function(require,module,exports){ +},{"./base/Exchange":6}],111:[function(require,module,exports){ 'use strict'; // --------------------------------------------------------------------------- @@ -87624,6 +93628,8 @@ module.exports = class mercado extends Exchange { 'createMarketOrder': true, 'createOrder': true, 'fetchBalance': true, + 'fetchMarkets': true, + 'fetchMyTrades': 'emulated', 'fetchOHLCV': true, 'fetchOpenOrders': true, 'fetchOrder': true, @@ -87663,6 +93669,7 @@ module.exports = class mercado extends Exchange { 'api': { 'public': { 'get': [ + 'coins', '{coin}/orderbook/', // last slash critical '{coin}/ticker/', '{coin}/trades/', @@ -87693,23 +93700,90 @@ module.exports = class mercado extends Exchange { ], }, }, - 'markets': { - 'BTC/BRL': { 'id': 'BRLBTC', 'symbol': 'BTC/BRL', 'base': 'BTC', 'quote': 'BRL', 'precision': { 'amount': 8, 'price': 5 }, 'suffix': 'Bitcoin' }, - 'LTC/BRL': { 'id': 'BRLLTC', 'symbol': 'LTC/BRL', 'base': 'LTC', 'quote': 'BRL', 'precision': { 'amount': 8, 'price': 5 }, 'suffix': 'Litecoin' }, - 'BCH/BRL': { 'id': 'BRLBCH', 'symbol': 'BCH/BRL', 'base': 'BCH', 'quote': 'BRL', 'precision': { 'amount': 8, 'price': 5 }, 'suffix': 'BCash' }, - 'XRP/BRL': { 'id': 'BRLXRP', 'symbol': 'XRP/BRL', 'base': 'XRP', 'quote': 'BRL', 'precision': { 'amount': 8, 'price': 5 }, 'suffix': 'Ripple' }, - 'ETH/BRL': { 'id': 'BRLETH', 'symbol': 'ETH/BRL', 'base': 'ETH', 'quote': 'BRL', 'precision': { 'amount': 8, 'price': 5 }, 'suffix': 'Ethereum' }, - 'USDC/BRL': { 'id': 'BRLUSDC', 'symbol': 'USDC/BRL', 'base': 'USDC', 'quote': 'BRL', 'precision': { 'amount': 8, 'price': 5 }, 'suffix': 'USDC' }, - }, 'fees': { 'trading': { - 'maker': 0.3 / 100, - 'taker': 0.7 / 100, + 'maker': 0.003, + 'taker': 0.007, + }, + }, + 'options': { + 'limits': { + 'BTC': 0.001, + 'BCH': 0.001, + 'ETH': 0.01, + 'LTC': 0.01, + 'XRP': 0.1, }, }, }); } + async fetchMarkets (params = {}) { + const response = await this.publicGetCoins (params); + // + // [ + // "BCH", + // "BTC", + // "ETH", + // "LTC", + // "XRP", + // "MBPRK01", + // "MBPRK02", + // "MBPRK03", + // "MBPRK04", + // "MBCONS01", + // "USDC", + // "WBX", + // "CHZ", + // "MBCONS02", + // "PAXG", + // "MBVASCO01", + // "LINK" + // ] + // + const result = []; + const amountLimits = this.safeValue (this.options, 'limits', {}); + for (let i = 0; i < response.length; i++) { + const coin = response[i]; + const baseId = coin; + const quoteId = 'BRL'; + const base = this.safeCurrencyCode (baseId); + const quote = this.safeCurrencyCode (quoteId); + const symbol = base + '/' + quote; + const id = quote + base; + const precision = { + 'amount': 8, + 'price': 5, + }; + result.push ({ + 'id': id, + 'symbol': symbol, + 'base': base, + 'quote': quote, + 'baseId': baseId, + 'quoteId': quoteId, + 'active': undefined, + 'info': coin, + 'precision': precision, + 'limits': { + 'amount': { + 'min': this.safeFloat (amountLimits, baseId), + 'max': undefined, + }, + 'price': { + 'min': 1 / Math.pow (10, precision['price']), + 'max': undefined, + }, + 'cost': { + 'min': undefined, + 'max': undefined, + }, + }, + }); + } + return result; + } + async fetchOrderBook (symbol, limit = undefined, params = {}) { await this.loadMarkets (); const market = this.market (symbol); @@ -87755,22 +93829,30 @@ module.exports = class mercado extends Exchange { } parseTrade (trade, market = undefined) { - const timestamp = this.safeTimestamp (trade, 'date'); + const timestamp = this.safeTimestamp2 (trade, 'date', 'executed_timestamp'); let symbol = undefined; if (market !== undefined) { symbol = market['symbol']; } - const id = this.safeString (trade, 'tid'); + const id = this.safeString2 (trade, 'tid', 'operation_id'); const type = undefined; const side = this.safeString (trade, 'type'); const price = this.safeFloat (trade, 'price'); - const amount = this.safeFloat (trade, 'amount'); + const amount = this.safeFloat2 (trade, 'amount', 'quantity'); let cost = undefined; if (price !== undefined) { if (amount !== undefined) { cost = price * amount; } } + const feeCost = this.safeFloat (trade, 'fee_rate'); + let fee = undefined; + if (feeCost !== undefined) { + fee = { + 'cost': feeCost, + 'currency': undefined, + }; + } return { 'id': id, 'info': trade, @@ -87784,7 +93866,7 @@ module.exports = class mercado extends Exchange { 'price': price, 'amount': amount, 'cost': cost, - 'fee': undefined, + 'fee': fee, }; } @@ -87952,6 +94034,11 @@ module.exports = class mercado extends Exchange { const remaining = amount - filled; const cost = filled * average; const lastTradeTimestamp = this.safeTimestamp (order, 'updated_timestamp'); + const rawTrades = this.safeValue (order, 'operations', []); + const trades = this.parseTrades (rawTrades, market, undefined, undefined, { + 'side': side, + 'order': id, + }); return { 'info': order, 'id': id, @@ -87962,6 +94049,7 @@ module.exports = class mercado extends Exchange { 'symbol': market['symbol'], 'type': 'limit', 'timeInForce': undefined, + 'postOnly': undefined, 'side': side, 'price': price, 'stopPrice': undefined, @@ -87972,7 +94060,7 @@ module.exports = class mercado extends Exchange { 'remaining': remaining, 'status': status, 'fee': fee, - 'trades': undefined, // todo parse trades (operations) + 'trades': trades, }; } @@ -88004,17 +94092,17 @@ module.exports = class mercado extends Exchange { if (code === 'BRL') { const account_ref = ('account_ref' in params); if (!account_ref) { - throw new ArgumentsRequired (this.id + ' requires account_ref parameter to withdraw ' + code); + throw new ArgumentsRequired (this.id + ' withdraw() requires account_ref parameter to withdraw ' + code); } } else if (code !== 'LTC') { const tx_fee = ('tx_fee' in params); if (!tx_fee) { - throw new ArgumentsRequired (this.id + ' requires tx_fee parameter to withdraw ' + code); + throw new ArgumentsRequired (this.id + ' withdraw() requires tx_fee parameter to withdraw ' + code); } if (code === 'XRP') { if (tag === undefined) { if (!('destination_tag' in params)) { - throw new ArgumentsRequired (this.id + ' requires a tag argument or destination_tag parameter to withdraw ' + code); + throw new ArgumentsRequired (this.id + ' withdraw() requires a tag argument or destination_tag parameter to withdraw ' + code); } } else { request['destination_tag'] = tag; @@ -88076,6 +94164,51 @@ module.exports = class mercado extends Exchange { return this.parseOrders (orders, market, since, limit); } + async fetchOpenOrders (symbol = undefined, since = undefined, limit = undefined, params = {}) { + if (symbol === undefined) { + throw new ArgumentsRequired (this.id + ' fetchOpenOrders () requires a symbol argument'); + } + await this.loadMarkets (); + const market = this.market (symbol); + const request = { + 'coin_pair': market['id'], + 'status_list': '[2]', // open only + }; + const response = await this.privatePostListOrders (this.extend (request, params)); + const responseData = this.safeValue (response, 'response_data', {}); + const orders = this.safeValue (responseData, 'orders', []); + return this.parseOrders (orders, market, since, limit); + } + + async fetchMyTrades (symbol = undefined, since = undefined, limit = undefined, params = {}) { + if (symbol === undefined) { + throw new ArgumentsRequired (this.id + ' fetchMyTrades () requires a symbol argument'); + } + await this.loadMarkets (); + const market = this.market (symbol); + const request = { + 'coin_pair': market['id'], + 'has_fills': true, + }; + const response = await this.privatePostListOrders (this.extend (request, params)); + const responseData = this.safeValue (response, 'response_data', {}); + const ordersRaw = this.safeValue (responseData, 'orders', []); + const orders = this.parseOrders (ordersRaw, market, since, limit); + const trades = this.ordersToTrades (orders); + return this.filterBySymbolSinceLimit (trades, symbol, since, limit); + } + + ordersToTrades (orders) { + const result = []; + for (let i = 0; i < orders.length; i++) { + const trades = this.safeValue (orders[i], 'trades', []); + for (let y = 0; y < trades.length; y++) { + result.push (trades[y]); + } + } + return result; + } + sign (path, api = 'public', method = 'GET', params = {}, headers = undefined, body = undefined) { let url = this.urls['api'][api] + '/'; const query = this.omit (params, this.extractParams (path)); @@ -88111,7 +94244,7 @@ module.exports = class mercado extends Exchange { } }; -},{"./base/Exchange":5,"./base/errors":7}],110:[function(require,module,exports){ +},{"./base/Exchange":6,"./base/errors":8}],112:[function(require,module,exports){ 'use strict'; // --------------------------------------------------------------------------- @@ -88342,7 +94475,2024 @@ module.exports = class mixcoins extends Exchange { } }; -},{"./base/Exchange":5,"./base/errors":7}],111:[function(require,module,exports){ +},{"./base/Exchange":6,"./base/errors":8}],113:[function(require,module,exports){ +'use strict'; + +// --------------------------------------------------------------------------- + +const Exchange = require ('./base/Exchange'); +const { ExchangeError, AuthenticationError, InsufficientFunds, BadSymbol, OrderNotFound } = require ('./base/errors'); +const { TICK_SIZE } = require ('./base/functions/number'); + +// --------------------------------------------------------------------------- + +module.exports = class ndax extends Exchange { + describe () { + return this.deepExtend (super.describe (), { + 'id': 'ndax', + 'name': 'NDAX', + 'countries': [ 'US' ], // United States + 'rateLimit': 1000, + 'pro': true, + 'has': { + 'cancelAllOrders': true, + 'cancelOrder': true, + 'createDepositAddress': true, + 'createOrder': true, + 'editOrder': true, + 'fetchAccounts': true, + 'fetchBalance': true, + 'fetchCurrencies': true, + 'fetchDepositAddress': true, + 'fetchDeposits': true, + 'fetchLedger': true, + 'fetchMarkets': true, + 'fetchMyTrades': true, + 'fetchOHLCV': true, + 'fetchOpenOrders': true, + 'fetchOrders': true, + 'fetchOrder': true, + 'fetchOrderBook': true, + 'fetchOrderTrades': true, + 'fetchTicker': true, + 'fetchTrades': true, + }, + 'timeframes': { + '1m': '60', + '5m': '300', + '15m': '900', + '30m': '1800', + '1h': '3600', + '2h': '7200', + '4h': '14400', + '6h': '21600', + '12h': '43200', + '1d': '86400', + '1w': '604800', + '1M': '2419200', + '4M': '9676800', + }, + 'urls': { + 'logo': 'https://user-images.githubusercontent.com/1294454/108623144-67a3ef00-744e-11eb-8140-75c6b851e945.jpg', + 'test': { + 'public': 'https://ndaxmarginstaging.cdnhop.net:8443/AP', + 'private': 'https://ndaxmarginstaging.cdnhop.net:8443/AP', + }, + 'api': { + 'public': 'https://api.ndax.io:8443/AP', + 'private': 'https://api.ndax.io:8443/AP', + }, + 'www': 'https://ndax.io', + 'doc': [ + 'https://apidoc.ndax.io/', + ], + 'fees': 'https://ndax.io/fees', + 'referral': 'https://one.ndax.io/bfQiSL', + }, + 'api': { + 'public': { + 'get': [ + 'Activate2FA', + 'Authenticate2FA', + 'AuthenticateUser', + 'GetL2Snapshot', + 'GetLevel1', + 'GetValidate2FARequiredEndpoints', + 'LogOut', + 'GetTickerHistory', + 'GetProduct', + 'GetProducts', + 'GetInstrument', + 'GetInstruments', + 'Ping', + 'trades', // undocumented + 'GetLastTrades', // undocumented + 'SubscribeLevel1', + 'SubscribeLevel2', + 'SubscribeTicker', + 'SubscribeTrades', + 'SubscribeBlockTrades', + 'UnsubscribeBlockTrades', + 'UnsubscribeLevel1', + 'UnsubscribeLevel2', + 'UnsubscribeTicker', + 'UnsubscribeTrades', + 'Authenticate', // undocumented + ], + }, + 'private': { + 'get': [ + 'GetUserAccountInfos', + 'GetUserAccounts', + 'GetUserAffiliateCount', + 'GetUserAffiliateTag', + 'GetUserConfig', + 'GetAllUnredactedUserConfigsForUser', + 'GetUnredactedUserConfigByKey', + 'GetUserDevices', + 'GetUserReportTickets', + 'GetUserReportWriterResultRecords', + 'GetAccountInfo', + 'GetAccountPositions', + 'GetAllAccountConfigs', + 'GetTreasuryProductsForAccount', + 'GetAccountTrades', + 'GetAccountTransactions', + 'GetOpenTradeReports', + 'GetAllOpenTradeReports', + 'GetTradesHistory', + 'GetOpenOrders', + 'GetOpenQuotes', + 'GetOrderFee', + 'GetOrderHistory', + 'GetOrdersHistory', + 'GetOrderStatus', + 'GetOmsFeeTiers', + 'GetAccountDepositTransactions', + 'GetAccountWithdrawTransactions', + 'GetAllDepositRequestInfoTemplates', + 'GetDepositInfo', + 'GetDepositRequestInfoTemplate', + 'GetDeposits', + 'GetDepositTicket', + 'GetDepositTickets', + 'GetOMSWithdrawFees', + 'GetWithdrawFee', + 'GetWithdraws', + 'GetWithdrawTemplate', + 'GetWithdrawTemplateTypes', + 'GetWithdrawTicket', + 'GetWithdrawTickets', + ], + 'post': [ + 'AddUserAffiliateTag', + 'CancelUserReport', + 'RegisterNewDevice', + 'SubscribeAccountEvents', + 'UpdateUserAffiliateTag', + 'GenerateTradeActivityReport', + 'GenerateTransactionActivityReport', + 'GenerateTreasuryActivityReport', + 'ScheduleTradeActivityReport', + 'ScheduleTransactionActivityReport', + 'ScheduleTreasuryActivityReport', + 'CancelAllOrders', + 'CancelOrder', + 'CancelQuote', + 'CancelReplaceOrder', + 'CreateQuote', + 'ModifyOrder', + 'SendOrder', + 'SubmitBlockTrade', + 'UpdateQuote', + 'CancelWithdraw', + 'CreateDepositTicket', + 'CreateWithdrawTicket', + 'SubmitDepositTicketComment', + 'SubmitWithdrawTicketComment', + 'GetOrderHistoryByOrderId', + ], + }, + }, + 'fees': { + 'trading': { + 'tierBased': false, + 'percentage': true, + 'maker': 0.2 / 100, + 'taker': 0.25 / 100, + }, + }, + 'requiredCredentials': { + 'apiKey': true, + 'secret': true, + 'uid': true, + }, + 'precisionMode': TICK_SIZE, + 'exceptions': { + 'exact': { + 'Not_Enough_Funds': InsufficientFunds, // {"status":"Rejected","errormsg":"Not_Enough_Funds","errorcode":101} + 'Server Error': ExchangeError, // {"result":false,"errormsg":"Server Error","errorcode":102,"detail":null} + 'Resource Not Found': OrderNotFound, // {"result":false,"errormsg":"Resource Not Found","errorcode":104,"detail":null} + }, + 'broad': { + 'Invalid InstrumentId': BadSymbol, // {"result":false,"errormsg":"Invalid InstrumentId: 10000","errorcode":100,"detail":null} + }, + }, + 'options': { + 'omsId': 1, + 'orderTypes': { + 'Market': 1, + 'Limit': 2, + 'StopMarket': 3, + 'StopLimit': 4, + 'TrailingStopMarket': 5, + 'TrailingStopLimit': 6, + 'BlockTrade': 7, + }, + }, + }); + } + + async fetchCurrencies (params = {}) { + const omsId = this.safeInteger (this.options, 'omsId', 1); + const request = { + 'omsId': omsId, + }; + const response = await this.publicGetGetProducts (this.extend (request, params)); + // + // [ + // { + // "OMSId":1, + // "ProductId":1, + // "Product":"BTC", + // "ProductFullName":"Bitcoin", + // "ProductType":"CryptoCurrency", + // "DecimalPlaces":8, + // "TickSize":0.0000000100000000000000000000, + // "NoFees":false, + // "IsDisabled":false, + // "MarginEnabled":false + // }, + // ] + // + const result = {}; + for (let i = 0; i < response.length; i++) { + const currency = response[i]; + const id = this.safeString (currency, 'ProductId'); + const name = this.safeString (currency, 'ProductFullName'); + const type = this.safeString (currency, 'ProductType'); + const code = this.safeCurrencyCode (this.safeString (currency, 'Product')); + const precision = this.safeFloat (currency, 'TickSize'); + const isDisabled = this.safeValue (currency, 'IsDisabled'); + const active = !isDisabled; + result[code] = { + 'id': id, + 'name': name, + 'code': code, + 'type': type, + 'precision': precision, + 'info': currency, + 'active': active, + 'fee': undefined, + 'limits': this.limits, + }; + } + return result; + } + + async fetchMarkets (params = {}) { + const omsId = this.safeInteger (this.options, 'omsId', 1); + const request = { + 'omsId': omsId, + }; + const response = await this.publicGetGetInstruments (this.extend (request, params)); + // + // [ + // { + // "OMSId":1, + // "InstrumentId":3, + // "Symbol":"LTCBTC", + // "Product1":3, + // "Product1Symbol":"LTC", + // "Product2":1, + // "Product2Symbol":"BTC", + // "InstrumentType":"Standard", + // "VenueInstrumentId":3, + // "VenueId":1, + // "SortIndex":0, + // "SessionStatus":"Running", + // "PreviousSessionStatus":"Stopped", + // "SessionStatusDateTime":"2020-11-25T19:42:15.245Z", + // "SelfTradePrevention":true, + // "QuantityIncrement":0.0000000100000000000000000000, + // "PriceIncrement":0.0000000100000000000000000000, + // "MinimumQuantity":0.0100000000000000000000000000, + // "MinimumPrice":0.0000010000000000000000000000, + // "VenueSymbol":"LTCBTC", + // "IsDisable":false, + // "MasterDataId":0, + // "PriceCollarThreshold":0.0000000000000000000000000000, + // "PriceCollarPercent":0.0000000000000000000000000000, + // "PriceCollarEnabled":false, + // "PriceFloorLimit":0.0000000000000000000000000000, + // "PriceFloorLimitEnabled":false, + // "PriceCeilingLimit":0.0000000000000000000000000000, + // "PriceCeilingLimitEnabled":false, + // "CreateWithMarketRunning":true, + // "AllowOnlyMarketMakerCounterParty":false, + // "PriceCollarIndexDifference":0.0000000000000000000000000000, + // "PriceCollarConvertToOtcEnabled":false, + // "PriceCollarConvertToOtcClientUserId":0, + // "PriceCollarConvertToOtcAccountId":0, + // "PriceCollarConvertToOtcThreshold":0.0000000000000000000000000000, + // "OtcConvertSizeThreshold":0.0000000000000000000000000000, + // "OtcConvertSizeEnabled":false, + // "OtcTradesPublic":true, + // "PriceTier":0 + // }, + // ] + // + const result = []; + for (let i = 0; i < response.length; i++) { + const market = response[i]; + const id = this.safeString (market, 'InstrumentId'); + // const lowercaseId = this.safeStringLower (market, 'symbol'); + const baseId = this.safeString (market, 'Product1'); + const quoteId = this.safeString (market, 'Product2'); + const base = this.safeCurrencyCode (this.safeString (market, 'Product1Symbol')); + const quote = this.safeCurrencyCode (this.safeString (market, 'Product2Symbol')); + const symbol = base + '/' + quote; + const precision = { + 'amount': this.safeFloat (market, 'QuantityIncrement'), + 'price': this.safeFloat (market, 'PriceIncrement'), + }; + const sessionStatus = this.safeString (market, 'SessionStatus'); + const isDisable = this.safeValue (market, 'IsDisable'); + const sessionRunning = (sessionStatus === 'Running'); + const active = (sessionRunning && !isDisable) ? true : false; + result.push ({ + 'id': id, + 'symbol': symbol, + 'base': base, + 'quote': quote, + 'baseId': baseId, + 'quoteId': quoteId, + 'info': market, + 'active': active, + 'precision': precision, + 'limits': { + 'amount': { + 'min': this.safeFloat (market, 'MinimumQuantity'), + 'max': undefined, + }, + 'price': { + 'min': this.safeFloat (market, 'MinimumPrice'), + 'max': undefined, + }, + 'cost': { + 'min': undefined, + 'max': undefined, + }, + }, + }); + } + return result; + } + + parseOrderBook (orderbook, timestamp = undefined, bidsKey = 'bids', asksKey = 'asks', priceKey = 6, amountKey = 8) { + let nonce = undefined; + const result = { + 'bids': [], + 'asks': [], + 'timestamp': undefined, + 'datetime': undefined, + 'nonce': undefined, + }; + for (let i = 0; i < orderbook.length; i++) { + const level = orderbook[i]; + if (timestamp === undefined) { + timestamp = this.safeInteger (level, 2); + } else { + const newTimestamp = this.safeInteger (level, 2); + timestamp = Math.max (timestamp, newTimestamp); + } + if (nonce === undefined) { + nonce = this.safeInteger (level, 0); + } else { + const newNonce = this.safeInteger (level, 0); + nonce = Math.max (nonce, newNonce); + } + const bidask = this.parseBidAsk (level, priceKey, amountKey); + const levelSide = this.safeValue (level, 9); + const side = levelSide ? asksKey : bidsKey; + result[side].push (bidask); + } + result['bids'] = this.sortBy (result['bids'], 0, true); + result['asks'] = this.sortBy (result['asks'], 0); + result['timestamp'] = timestamp; + result['datetime'] = this.iso8601 (timestamp); + result['nonce'] = nonce; + return result; + } + + async fetchOrderBook (symbol, limit = undefined, params = {}) { + const omsId = this.safeInteger (this.options, 'omsId', 1); + await this.loadMarkets (); + const market = this.market (symbol); + limit = (limit === undefined) ? 100 : limit; // default 100 + const request = { + 'omsId': omsId, + 'InstrumentId': market['id'], + 'Depth': limit, // default 100 + }; + const response = await this.publicGetGetL2Snapshot (this.extend (request, params)); + // + // [ + // [ + // 0, // 0 MDUpdateId + // 1, // 1 Number of Unique Accounts + // 123, // 2 ActionDateTime in Posix format X 1000 + // 0, // 3 ActionType 0 (New), 1 (Update), 2(Delete) + // 0.0, // 4 LastTradePrice + // 0, // 5 Number of Orders + // 0.0, // 6 Price + // 0, // 7 ProductPairCode + // 0.0, // 8 Quantity + // 0, // 9 Side + // ], + // [97244115,1,1607456142963,0,19069.32,1,19069.31,8,0.140095,0], + // [97244115,0,1607456142963,0,19069.32,1,19068.64,8,0.0055,0], + // [97244115,0,1607456142963,0,19069.32,1,19068.26,8,0.021291,0], + // [97244115,1,1607456142964,0,19069.32,1,19069.32,8,0.099636,1], + // [97244115,0,1607456142964,0,19069.32,1,19069.98,8,0.1,1], + // [97244115,0,1607456142964,0,19069.32,1,19069.99,8,0.141604,1], + // ] + // + return this.parseOrderBook (response); + } + + parseTicker (ticker, market = undefined) { + // + // fetchTicker + // + // { + // "OMSId":1, + // "InstrumentId":8, + // "BestBid":19069.31, + // "BestOffer":19069.32, + // "LastTradedPx":19069.32, + // "LastTradedQty":0.0001, + // "LastTradeTime":1607040406424, + // "SessionOpen":19069.32, + // "SessionHigh":19069.32, + // "SessionLow":19069.32, + // "SessionClose":19069.32, + // "Volume":0.0001, + // "CurrentDayVolume":0.0001, + // "CurrentDayNotional":1.906932, + // "CurrentDayNumTrades":1, + // "CurrentDayPxChange":0.00, + // "Rolling24HrVolume":0.000000000000000000000000000, + // "Rolling24HrNotional":0.00000000000000000000000, + // "Rolling24NumTrades":0, + // "Rolling24HrPxChange":0, + // "TimeStamp":"1607040406425", + // "BidQty":0, + // "AskQty":0, + // "BidOrderCt":0, + // "AskOrderCt":0, + // "Rolling24HrPxChangePercent":0, + // } + // + const timestamp = this.safeInteger (ticker, 'TimeStamp'); + const marketId = this.safeString (ticker, 'InstrumentId'); + const symbol = this.safeSymbol (marketId, market); + const last = this.safeFloat (ticker, 'LastTradedPx'); + const percentage = this.safeFloat (ticker, 'Rolling24HrPxChangePercent'); + const change = this.safeFloat (ticker, 'Rolling24HrPxChange'); + const open = this.safeFloat (ticker, 'SessionOpen'); + let average = undefined; + if ((last !== undefined) && (change !== undefined)) { + average = this.sum (last, open) / 2; + } + const baseVolume = this.safeFloat (ticker, 'Rolling24HrVolume'); + const quoteVolume = this.safeFloat (ticker, 'Rolling24HrNotional'); + const vwap = this.vwap (baseVolume, quoteVolume); + return { + 'symbol': symbol, + 'timestamp': timestamp, + 'datetime': this.iso8601 (timestamp), + 'high': this.safeFloat (ticker, 'SessionHigh'), + 'low': this.safeFloat (ticker, 'SessionLow'), + 'bid': this.safeFloat (ticker, 'BestBid'), + 'bidVolume': undefined, // this.safeFloat (ticker, 'BidQty'), always shows 0 + 'ask': this.safeFloat (ticker, 'BestOffer'), + 'askVolume': undefined, // this.safeFloat (ticker, 'AskQty'), always shows 0 + 'vwap': vwap, + 'open': open, + 'close': last, + 'last': last, + 'previousClose': undefined, + 'change': change, + 'percentage': percentage, + 'average': average, + 'baseVolume': baseVolume, + 'quoteVolume': quoteVolume, + 'info': ticker, + }; + } + + async fetchTicker (symbol, params = {}) { + const omsId = this.safeInteger (this.options, 'omsId', 1); + await this.loadMarkets (); + const market = this.market (symbol); + const request = { + 'omsId': omsId, + 'InstrumentId': market['id'], + }; + const response = await this.publicGetGetLevel1 (this.extend (request, params)); + // + // { + // "OMSId":1, + // "InstrumentId":8, + // "BestBid":19069.31, + // "BestOffer":19069.32, + // "LastTradedPx":19069.32, + // "LastTradedQty":0.0001, + // "LastTradeTime":1607040406424, + // "SessionOpen":19069.32, + // "SessionHigh":19069.32, + // "SessionLow":19069.32, + // "SessionClose":19069.32, + // "Volume":0.0001, + // "CurrentDayVolume":0.0001, + // "CurrentDayNotional":1.906932, + // "CurrentDayNumTrades":1, + // "CurrentDayPxChange":0.00, + // "Rolling24HrVolume":0.000000000000000000000000000, + // "Rolling24HrNotional":0.00000000000000000000000, + // "Rolling24NumTrades":0, + // "Rolling24HrPxChange":0, + // "TimeStamp":"1607040406425", + // "BidQty":0, + // "AskQty":0, + // "BidOrderCt":0, + // "AskOrderCt":0, + // "Rolling24HrPxChangePercent":0, + // } + // + return this.parseTicker (response, market); + } + + parseOHLCV (ohlcv, market = undefined) { + // + // [ + // 1501603632000, // 0 DateTime + // 2700.33, // 1 High + // 2687.01, // 2 Low + // 2687.01, // 3 Open + // 2687.01, // 4 Close + // 24.86100992, // 5 Volume + // 0, // 6 Inside Bid Price + // 2870.95, // 7 Inside Ask Price + // 1 // 8 InstrumentId + // ] + // + return [ + this.safeInteger (ohlcv, 0), + this.safeFloat (ohlcv, 3), + this.safeFloat (ohlcv, 1), + this.safeFloat (ohlcv, 2), + this.safeFloat (ohlcv, 4), + this.safeFloat (ohlcv, 5), + ]; + } + + async fetchOHLCV (symbol, timeframe = '1m', since = undefined, limit = undefined, params = {}) { + const omsId = this.safeInteger (this.options, 'omsId', 1); + await this.loadMarkets (); + const market = this.market (symbol); + const request = { + 'omsId': omsId, + 'InstrumentId': market['id'], + 'Interval': this.timeframes[timeframe], + }; + const duration = this.parseTimeframe (timeframe); + const now = this.milliseconds (); + if (since === undefined) { + if (limit !== undefined) { + request['FromDate'] = this.ymd (now - duration * limit * 1000); + request['ToDate'] = this.ymd (now); + } + } else { + request['FromDate'] = this.ymd (since); + if (limit === undefined) { + request['ToDate'] = this.ymd (now); + } else { + request['ToDate'] = this.ymd (this.sum (since, duration * limit * 1000)); + } + } + const response = await this.publicGetGetTickerHistory (this.extend (request, params)); + // + // [ + // [1607299260000,19069.32,19069.32,19069.32,19069.32,0,19069.31,19069.32,8,1607299200000], + // [1607299320000,19069.32,19069.32,19069.32,19069.32,0,19069.31,19069.32,8,1607299260000], + // [1607299380000,19069.32,19069.32,19069.32,19069.32,0,19069.31,19069.32,8,1607299320000], + // ] + // + return this.parseOHLCVs (response, market, timeframe, since, limit); + } + + parseTrade (trade, market = undefined) { + // + // fetchTrades (public) + // + // [ + // 6913253, // 0 TradeId + // 8, // 1 ProductPairCode + // 0.03340802, // 2 Quantity + // 19116.08, // 3 Price + // 2543425077, // 4 Order1 + // 2543425482, // 5 Order2 + // 1606935922416, // 6 Tradetime + // 0, // 7 Direction + // 1, // 8 TakerSide + // 0, // 9 BlockTrade + // 0, // 10 Either Order1ClientId or Order2ClientId + // ] + // + // fetchMyTrades (private) + // + // { + // "OMSId":1, + // "ExecutionId":16916567, + // "TradeId":14476351, + // "OrderId":2543565231, + // "AccountId":449, + // "AccountName":"igor@ccxt.trade", + // "SubAccountId":0, + // "ClientOrderId":0, + // "InstrumentId":8, + // "Side":"Sell", + // "OrderType":"Market", + // "Quantity":0.1230000000000000000000000000, + // "RemainingQuantity":0.0000000000000000000000000000, + // "Price":19069.310000000000000000000000, + // "Value":2345.5251300000000000000000000, + // "CounterParty":"7", + // "OrderTradeRevision":1, + // "Direction":"NoChange", + // "IsBlockTrade":false, + // "Fee":1.1727625650000000000000000000, + // "FeeProductId":8, + // "OrderOriginator":446, + // "UserName":"igor@ccxt.trade", + // "TradeTimeMS":1607565031569, + // "MakerTaker":"Taker", + // "AdapterTradeId":0, + // "InsideBid":19069.310000000000000000000000, + // "InsideBidSize":0.2400950000000000000000000000, + // "InsideAsk":19069.320000000000000000000000, + // "InsideAskSize":0.0997360000000000000000000000, + // "IsQuote":false, + // "CounterPartyClientUserId":1, + // "NotionalProductId":2, + // "NotionalRate":1.0000000000000000000000000000, + // "NotionalValue":2345.5251300000000000000000000, + // "NotionalHoldAmount":0, + // "TradeTime":637431618315686826 + // } + // + // fetchOrderTrades + // + // { + // "Side":"Sell", + // "OrderId":2543565235, + // "Price":18600.000000000000000000000000, + // "Quantity":0.0000000000000000000000000000, + // "DisplayQuantity":0.0000000000000000000000000000, + // "Instrument":8, + // "Account":449, + // "AccountName":"igor@ccxt.trade", + // "OrderType":"Limit", + // "ClientOrderId":0, + // "OrderState":"FullyExecuted", + // "ReceiveTime":1607585844956, + // "ReceiveTimeTicks":637431826449564182, + // "LastUpdatedTime":1607585844959, + // "LastUpdatedTimeTicks":637431826449593893, + // "OrigQuantity":0.1230000000000000000000000000, + // "QuantityExecuted":0.1230000000000000000000000000, + // "GrossValueExecuted":2345.3947500000000000000000000, + // "ExecutableValue":0.0000000000000000000000000000, + // "AvgPrice":19068.250000000000000000000000, + // "CounterPartyId":0, + // "ChangeReason":"Trade", + // "OrigOrderId":2543565235, + // "OrigClOrdId":0, + // "EnteredBy":446, + // "UserName":"igor@ccxt.trade", + // "IsQuote":false, + // "InsideAsk":19069.320000000000000000000000, + // "InsideAskSize":0.0997360000000000000000000000, + // "InsideBid":19068.250000000000000000000000, + // "InsideBidSize":1.3300010000000000000000000000, + // "LastTradePrice":19068.250000000000000000000000, + // "RejectReason":"", + // "IsLockedIn":false, + // "CancelReason":"", + // "OrderFlag":"0", + // "UseMargin":false, + // "StopPrice":0.0000000000000000000000000000, + // "PegPriceType":"Unknown", + // "PegOffset":0.0000000000000000000000000000, + // "PegLimitOffset":0.0000000000000000000000000000, + // "IpAddress":"5.228.233.138", + // "ClientOrderIdUuid":null, + // "OMSId":1 + // } + // + let price = undefined; + let amount = undefined; + let cost = undefined; + let timestamp = undefined; + let id = undefined; + let marketId = undefined; + let side = undefined; + let orderId = undefined; + let takerOrMaker = undefined; + let fee = undefined; + let type = undefined; + if (Array.isArray (trade)) { + price = this.safeFloat (trade, 3); + amount = this.safeFloat (trade, 2); + if ((price !== undefined) && (amount !== undefined)) { + cost = price * amount; + } + timestamp = this.safeInteger (trade, 6); + id = this.safeString (trade, 0); + marketId = this.safeInteger (trade, 1); + const takerSide = this.safeValue (trade, 8); + side = takerSide ? 'sell' : 'buy'; + orderId = this.safeString (trade, 4); + } else { + timestamp = this.safeInteger2 (trade, 'TradeTimeMS', 'ReceiveTime'); + id = this.safeString (trade, 'TradeId'); + orderId = this.safeString2 (trade, 'OrderId', 'OrigOrderId'); + marketId = this.safeString2 (trade, 'InstrumentId', 'Instrument'); + price = this.safeFloat (trade, 'Price'); + amount = this.safeFloat (trade, 'Quantity'); + cost = this.safeFloat2 (trade, 'Value', 'GrossValueExecuted'); + takerOrMaker = this.safeStringLower (trade, 'MakerTaker'); + side = this.safeStringLower (trade, 'Side'); + type = this.safeStringLower (trade, 'OrderType'); + const feeCost = this.safeFloat (trade, 'Fee'); + if (feeCost !== undefined) { + const feeCurrencyId = this.safeString (trade, 'FeeProductId'); + const feeCurrencyCode = this.safeCurrencyCode (feeCurrencyId); + fee = { + 'cost': feeCost, + 'currency': feeCurrencyCode, + }; + } + } + const symbol = this.safeSymbol (marketId, market); + return { + 'info': trade, + 'id': id, + 'symbol': symbol, + 'timestamp': timestamp, + 'datetime': this.iso8601 (timestamp), + 'order': orderId, + 'type': type, + 'side': side, + 'takerOrMaker': takerOrMaker, + 'price': price, + 'amount': amount, + 'cost': cost, + 'fee': fee, + }; + } + + async fetchTrades (symbol, since = undefined, limit = undefined, params = {}) { + const omsId = this.safeInteger (this.options, 'omsId', 1); + await this.loadMarkets (); + const market = this.market (symbol); + const request = { + 'omsId': omsId, + 'InstrumentId': market['id'], + }; + if (limit !== undefined) { + request['Count'] = limit; + } + const response = await this.publicGetGetLastTrades (this.extend (request, params)); + // + // [ + // [6913253,8,0.03340802,19116.08,2543425077,2543425482,1606935922416,0,1,0,0], + // [6913254,8,0.01391671,19117.42,2543427510,2543427811,1606935927998,1,1,0,0], + // [6913255,8,0.000006,19107.81,2543430495,2543430793,1606935933881,2,0,0,0], + // ] + // + return this.parseTrades (response, market, since, limit); + } + + async fetchAccounts (params = {}) { + const omsId = this.safeInteger (this.options, 'omsId', 1); + this.checkRequiredCredentials (); + const request = { + 'omsId': omsId, + 'UserId': this.uid, + 'UserName': 'igor@ccxt.trade', + }; + const response = await this.privateGetGetUserAccounts (this.extend (request, params)); + // + // [ 449 ] // comma-separated list of account ids + // + const result = []; + for (let i = 0; i < response.length; i++) { + const accountId = this.safeString (response, i); + result.push ({ + 'id': accountId, + 'type': undefined, + 'currency': undefined, + 'info': accountId, + }); + } + return result; + } + + async fetchBalance (params = {}) { + const omsId = this.safeInteger (this.options, 'omsId', 1); + await this.loadMarkets (); + await this.loadAccounts (); + const defaultAccountId = this.safeInteger2 (this.options, 'accountId', 'AccountId', parseInt (this.accounts[0]['id'])); + const accountId = this.safeInteger2 (params, 'accountId', 'AccountId', defaultAccountId); + params = this.omit (params, [ 'accountId', 'AccountId' ]); + const request = { + 'omsId': omsId, + 'AccountId': accountId, + }; + const response = await this.privateGetGetAccountPositions (this.extend (request, params)); + // + // [ + // { + // "OMSId":1, + // "AccountId":449, + // "ProductSymbol":"BTC", + // "ProductId":1, + // "Amount":10.000000000000000000000000000, + // "Hold":0, + // "PendingDeposits":0.0000000000000000000000000000, + // "PendingWithdraws":0.0000000000000000000000000000, + // "TotalDayDeposits":10.000000000000000000000000000, + // "TotalMonthDeposits":10.000000000000000000000000000, + // "TotalYearDeposits":10.000000000000000000000000000, + // "TotalDayDepositNotional":10.000000000000000000000000000, + // "TotalMonthDepositNotional":10.000000000000000000000000000, + // "TotalYearDepositNotional":10.000000000000000000000000000, + // "TotalDayWithdraws":0, + // "TotalMonthWithdraws":0, + // "TotalYearWithdraws":0, + // "TotalDayWithdrawNotional":0, + // "TotalMonthWithdrawNotional":0, + // "TotalYearWithdrawNotional":0, + // "NotionalProductId":8, + // "NotionalProductSymbol":"USDT", + // "NotionalValue":10.000000000000000000000000000, + // "NotionalHoldAmount":0, + // "NotionalRate":1 + // }, + // ] + // + const result = { 'info': response }; + for (let i = 0; i < response.length; i++) { + const balance = response[i]; + const currencyId = this.safeString (balance, 'ProductId'); + const code = this.safeCurrencyCode (currencyId); + const account = this.account (); + account['total'] = this.safeFloat (balance, 'Amount'); + account['used'] = this.safeFloat (balance, 'Hold'); + result[code] = account; + } + return this.parseBalance (result); + } + + parseLedgerEntryType (type) { + const types = { + 'Trade': 'trade', + 'Deposit': 'transaction', + 'Withdraw': 'transaction', + 'Transfer': 'transfer', + 'OrderHold': 'trade', + 'WithdrawHold': 'transaction', + 'DepositHold': 'transaction', + 'MarginHold': 'trade', + 'ManualHold': 'trade', + 'ManualEntry': 'trade', + 'MarginAcquisition': 'trade', + 'MarginRelinquish': 'trade', + 'MarginQuoteHold': 'trade', + }; + return this.safeString (types, type, type); + } + + parseLedgerEntry (item, currency = undefined) { + // + // { + // "TransactionId":2663709493, + // "ReferenceId":68, + // "OMSId":1, + // "AccountId":449, + // "CR":10.000000000000000000000000000, + // "DR":0.0000000000000000000000000000, + // "Counterparty":3, + // "TransactionType":"Other", + // "ReferenceType":"Deposit", + // "ProductId":1, + // "Balance":10.000000000000000000000000000, + // "TimeStamp":1607532331591 + // } + // + const id = this.safeString (item, 'TransactionId'); + const account = this.safeString (item, 'AccountId'); + const referenceId = this.safeString (item, 'ReferenceId'); + const referenceAccount = this.safeString (item, 'Counterparty'); + const type = this.parseLedgerEntryType (this.safeString (item, 'ReferenceType')); + const currencyId = this.safeString (item, 'ProductId'); + const code = this.safeCurrencyCode (currencyId, currency); + const credit = this.safeFloat (item, 'CR'); + const debit = this.safeFloat (item, 'DR'); + let amount = undefined; + let direction = undefined; + if (credit > 0) { + amount = credit; + direction = 'in'; + } else if (debit > 0) { + amount = debit; + direction = 'out'; + } + const timestamp = this.safeInteger (item, 'TimeStamp'); + let before = undefined; + const after = this.safeFloat (item, 'Balance'); + if (direction === 'out') { + before = this.sum (after, amount); + } else if (direction === 'in') { + before = Math.max (0, after - amount); + } + const status = 'ok'; + return { + 'info': item, + 'id': id, + 'direction': direction, + 'account': account, + 'referenceId': referenceId, + 'referenceAccount': referenceAccount, + 'type': type, + 'currency': code, + 'amount': amount, + 'before': before, + 'after': after, + 'status': status, + 'timestamp': timestamp, + 'datetime': this.iso8601 (timestamp), + 'fee': undefined, + }; + } + + async fetchLedger (code = undefined, since = undefined, limit = undefined, params = {}) { + const omsId = this.safeInteger (this.options, 'omsId', 1); + await this.loadMarkets (); + await this.loadAccounts (); + const defaultAccountId = this.safeInteger2 (this.options, 'accountId', 'AccountId', parseInt (this.accounts[0]['id'])); + const accountId = this.safeInteger2 (params, 'accountId', 'AccountId', defaultAccountId); + params = this.omit (params, [ 'accountId', 'AccountId' ]); + const request = { + 'omsId': omsId, + 'AccountId': accountId, + }; + if (limit !== undefined) { + request['Depth'] = limit; + } + const response = await this.privateGetGetAccountTransactions (this.extend (request, params)); + // + // [ + // { + // "TransactionId":2663709493, + // "ReferenceId":68, + // "OMSId":1, + // "AccountId":449, + // "CR":10.000000000000000000000000000, + // "DR":0.0000000000000000000000000000, + // "Counterparty":3, + // "TransactionType":"Other", + // "ReferenceType":"Deposit", + // "ProductId":1, + // "Balance":10.000000000000000000000000000, + // "TimeStamp":1607532331591 + // }, + // ] + // + let currency = undefined; + if (code !== undefined) { + currency = this.currency (code); + } + return this.parseLedger (response, currency, since, limit); + } + + parseOrderStatus (status) { + const statuses = { + 'Accepted': 'open', + 'Rejected': 'rejected', + 'Working': 'open', + 'Canceled': 'canceled', + 'Expired': 'expired', + 'FullyExecuted': 'closed', + }; + return this.safeString (statuses, status, status); + } + + parseOrder (order, market = undefined) { + // + // createOrder + // + // { + // "status":"Accepted", + // "errormsg":"", + // "OrderId": 2543565231 + // } + // + // editOrder + // + // { + // "ReplacementOrderId": 1234, + // "ReplacementClOrdId": 1561, + // "OrigOrderId": 5678, + // "OrigClOrdId": 91011, + // } + // + // fetchOpenOrders, fetchClosedOrders + // + // { + // "Side":"Buy", + // "OrderId":2543565233, + // "Price":19010, + // "Quantity":0.345, + // "DisplayQuantity":0.345, + // "Instrument":8, + // "Account":449, + // "AccountName":"igor@ccxt.trade", + // "OrderType":"Limit", + // "ClientOrderId":0, + // "OrderState":"Working", + // "ReceiveTime":1607579326003, + // "ReceiveTimeTicks":637431761260028981, + // "LastUpdatedTime":1607579326005, + // "LastUpdatedTimeTicks":637431761260054714, + // "OrigQuantity":0.345, + // "QuantityExecuted":0, + // "GrossValueExecuted":0, + // "ExecutableValue":0, + // "AvgPrice":0, + // "CounterPartyId":0, + // "ChangeReason":"NewInputAccepted", + // "OrigOrderId":2543565233, + // "OrigClOrdId":0, + // "EnteredBy":446, + // "UserName":"igor@ccxt.trade", + // "IsQuote":false, + // "InsideAsk":19069.32, + // "InsideAskSize":0.099736, + // "InsideBid":19068.25, + // "InsideBidSize":1.330001, + // "LastTradePrice":19068.25, + // "RejectReason":"", + // "IsLockedIn":false, + // "CancelReason":"", + // "OrderFlag":"AddedToBook", + // "UseMargin":false, + // "StopPrice":0, + // "PegPriceType":"Unknown", + // "PegOffset":0, + // "PegLimitOffset":0, + // "IpAddress":null, + // "ClientOrderIdUuid":null, + // "OMSId":1 + // } + // + const id = this.safeString2 (order, 'ReplacementOrderId', 'OrderId'); + const timestamp = this.safeInteger (order, 'ReceiveTime'); + let lastTradeTimestamp = undefined; + const marketId = this.safeString (order, 'Instrument'); + const symbol = this.safeSymbol (marketId, market); + const side = this.safeStringLower (order, 'Side'); + const type = this.safeStringLower (order, 'OrderType'); + const clientOrderId = this.safeString2 (order, 'ReplacementClOrdId', 'ClientOrderId'); + let price = this.safeFloat (order, 'Price', 0.0); + price = (price > 0.0) ? price : undefined; + const amount = this.safeFloat (order, 'OrigQuantity'); + const filled = this.safeFloat (order, 'QuantityExecuted'); + const cost = this.safeFloat (order, 'GrossValueExecuted'); + let remaining = undefined; + let average = undefined; + if (filled !== undefined) { + if (amount !== undefined) { + remaining = Math.max (0, amount - filled); + } + if (filled > 0) { + lastTradeTimestamp = this.safeInteger (order, 'LastUpdatedTime'); + average = this.safeFloat (order, 'AvgPrice', 0.0); + average = (average > 0) ? average : undefined; + } + } + let stopPrice = this.safeFloat (order, 'StopPrice', 0.0); + stopPrice = (stopPrice > 0.0) ? stopPrice : undefined; + const timeInForce = undefined; + const status = this.parseOrderStatus (this.safeString (order, 'OrderState')); + const fee = undefined; + const trades = undefined; + return { + 'id': id, + 'clientOrderId': clientOrderId, + 'info': order, + 'timestamp': timestamp, + 'datetime': this.iso8601 (timestamp), + 'lastTradeTimestamp': lastTradeTimestamp, + 'status': status, + 'symbol': symbol, + 'type': type, + 'timeInForce': timeInForce, + 'postOnly': undefined, + 'side': side, + 'price': price, + 'stopPrice': stopPrice, + 'cost': cost, + 'amount': amount, + 'filled': filled, + 'average': average, + 'remaining': remaining, + 'fee': fee, + 'trades': trades, + }; + } + + async createOrder (symbol, type, side, amount, price = undefined, params = {}) { + const omsId = this.safeInteger (this.options, 'omsId', 1); + await this.loadMarkets (); + await this.loadAccounts (); + const defaultAccountId = this.safeInteger2 (this.options, 'accountId', 'AccountId', parseInt (this.accounts[0]['id'])); + const accountId = this.safeInteger2 (params, 'accountId', 'AccountId', defaultAccountId); + const clientOrderId = this.safeInteger2 (params, 'ClientOrderId', 'clientOrderId'); + params = this.omit (params, [ 'accountId', 'AccountId', 'clientOrderId', 'ClientOrderId' ]); + const market = this.market (symbol); + const orderSide = (side === 'buy') ? 0 : 1; + const request = { + 'InstrumentId': parseInt (market['id']), + 'omsId': omsId, + 'AccountId': accountId, + 'TimeInForce': 1, // 0 Unknown, 1 GTC by default, 2 OPG execute as close to opening price as possible, 3 IOC immediate or canceled, 4 FOK fill-or-kill, 5 GTX good 'til executed, 6 GTD good 'til date + // 'ClientOrderId': clientOrderId, // defaults to 0 + // If this order is order A, OrderIdOCO refers to the order ID of an order B (which is not the order being created by this call). + // If order B executes, then order A created by this call is canceled. + // You can also set up order B to watch order A in the same way, but that may require an update to order B to make it watch this one, which could have implications for priority in the order book. + // See CancelReplaceOrder and ModifyOrder. + // 'OrderIdOCO': 0, // The order ID if One Cancels the Other. + // 'UseDisplayQuantity': false, // If you enter a Limit order with a reserve, you must set UseDisplayQuantity to true + 'Side': orderSide, // 0 Buy, 1 Sell, 2 Short, 3 unknown an error condition + 'Quantity': parseFloat (this.amountToPrecision (symbol, amount)), + 'OrderType': this.safeInteger (this.options['orderTypes'], this.capitalize (type)), // 0 Unknown, 1 Market, 2 Limit, 3 StopMarket, 4 StopLimit, 5 TrailingStopMarket, 6 TrailingStopLimit, 7 BlockTrade + // 'PegPriceType': 3, // 1 Last, 2 Bid, 3 Ask, 4 Midpoint + // 'LimitPrice': parseFloat (this.priceToPrecision (symbol, price)), + }; + // If OrderType=1 (Market), Side=0 (Buy), and LimitPrice is supplied, the Market order will execute up to the value specified + if (price !== undefined) { + request['LimitPrice'] = parseFloat (this.priceToPrecision (symbol, price)); + } + if (clientOrderId !== undefined) { + request['ClientOrderId'] = clientOrderId; + } + const response = await this.privatePostSendOrder (this.extend (request, params)); + // + // { + // "status":"Accepted", + // "errormsg":"", + // "OrderId": 2543565231 + // } + // + return this.parseOrder (response, market); + } + + async editOrder (id, symbol, type, side, amount, price = undefined, params = {}) { + const omsId = this.safeInteger (this.options, 'omsId', 1); + await this.loadMarkets (); + await this.loadAccounts (); + const defaultAccountId = this.safeInteger2 (this.options, 'accountId', 'AccountId', parseInt (this.accounts[0]['id'])); + const accountId = this.safeInteger2 (params, 'accountId', 'AccountId', defaultAccountId); + const clientOrderId = this.safeInteger2 (params, 'ClientOrderId', 'clientOrderId'); + params = this.omit (params, [ 'accountId', 'AccountId', 'clientOrderId', 'ClientOrderId' ]); + const market = this.market (symbol); + const orderSide = (side === 'buy') ? 0 : 1; + const request = { + 'OrderIdToReplace': parseInt (id), + 'InstrumentId': parseInt (market['id']), + 'omsId': omsId, + 'AccountId': accountId, + 'TimeInForce': 1, // 0 Unknown, 1 GTC by default, 2 OPG execute as close to opening price as possible, 3 IOC immediate or canceled, 4 FOK fill-or-kill, 5 GTX good 'til executed, 6 GTD good 'til date + // 'ClientOrderId': clientOrderId, // defaults to 0 + // If this order is order A, OrderIdOCO refers to the order ID of an order B (which is not the order being created by this call). + // If order B executes, then order A created by this call is canceled. + // You can also set up order B to watch order A in the same way, but that may require an update to order B to make it watch this one, which could have implications for priority in the order book. + // See CancelReplaceOrder and ModifyOrder. + // 'OrderIdOCO': 0, // The order ID if One Cancels the Other. + // 'UseDisplayQuantity': false, // If you enter a Limit order with a reserve, you must set UseDisplayQuantity to true + 'Side': orderSide, // 0 Buy, 1 Sell, 2 Short, 3 unknown an error condition + 'Quantity': parseFloat (this.amountToPrecision (symbol, amount)), + 'OrderType': this.safeInteger (this.options['orderTypes'], this.capitalize (type)), // 0 Unknown, 1 Market, 2 Limit, 3 StopMarket, 4 StopLimit, 5 TrailingStopMarket, 6 TrailingStopLimit, 7 BlockTrade + // 'PegPriceType': 3, // 1 Last, 2 Bid, 3 Ask, 4 Midpoint + // 'LimitPrice': parseFloat (this.priceToPrecision (symbol, price)), + }; + // If OrderType=1 (Market), Side=0 (Buy), and LimitPrice is supplied, the Market order will execute up to the value specified + if (price !== undefined) { + request['LimitPrice'] = parseFloat (this.priceToPrecision (symbol, price)); + } + if (clientOrderId !== undefined) { + request['ClientOrderId'] = clientOrderId; + } + const response = await this.privatePostCancelReplaceOrder (this.extend (request, params)); + // + // { + // "replacementOrderId": 1234, + // "replacementClOrdId": 1561, + // "origOrderId": 5678, + // "origClOrdId": 91011, + // } + // + return this.parseOrder (response, market); + } + + async fetchMyTrades (symbol = undefined, since = undefined, limit = undefined, params = {}) { + const omsId = this.safeInteger (this.options, 'omsId', 1); + await this.loadMarkets (); + await this.loadAccounts (); + const defaultAccountId = this.safeInteger2 (this.options, 'accountId', 'AccountId', parseInt (this.accounts[0]['id'])); + const accountId = this.safeInteger2 (params, 'accountId', 'AccountId', defaultAccountId); + params = this.omit (params, [ 'accountId', 'AccountId' ]); + const request = { + 'omsId': omsId, + 'AccountId': accountId, + // 'InstrumentId': market['id'], + // 'TradeId': 123, // If you specify TradeId, GetTradesHistory can return all states for a single trade + // 'OrderId': 456, // If specified, the call returns all trades associated with the order + // 'UserId': integer. The ID of the logged-in user. If not specified, the call returns trades associated with the users belonging to the default account for the logged-in user of this OMS. + // 'StartTimeStamp': long integer. The historical date and time at which to begin the trade report, in POSIX format. If not specified, reverts to the start date of this account on the trading venue. + // 'EndTimeStamp': long integer. Date at which to end the trade report, in POSIX format. + // 'Depth': integer. In this case, the count of trades to return, counting from the StartIndex. If Depth is not specified, returns all trades between BeginTimeStamp and EndTimeStamp, beginning at StartIndex. + // 'StartIndex': 0 // from the most recent trade 0 and moving backwards in time + // 'ExecutionId': 123, // The ID of the individual buy or sell execution. If not specified, returns all. + }; + let market = undefined; + if (symbol !== undefined) { + market = this.market (symbol); + request['InstrumentId'] = market['id']; + } + if (since !== undefined) { + request['StartTimeStamp'] = since; + } + if (limit !== undefined) { + request['Depth'] = limit; + } + const response = await this.privateGetGetTradesHistory (this.extend (request, params)); + // + // [ + // { + // "OMSId":1, + // "ExecutionId":16916567, + // "TradeId":14476351, + // "OrderId":2543565231, + // "AccountId":449, + // "AccountName":"igor@ccxt.trade", + // "SubAccountId":0, + // "ClientOrderId":0, + // "InstrumentId":8, + // "Side":"Sell", + // "OrderType":"Market", + // "Quantity":0.1230000000000000000000000000, + // "RemainingQuantity":0.0000000000000000000000000000, + // "Price":19069.310000000000000000000000, + // "Value":2345.5251300000000000000000000, + // "CounterParty":"7", + // "OrderTradeRevision":1, + // "Direction":"NoChange", + // "IsBlockTrade":false, + // "Fee":1.1727625650000000000000000000, + // "FeeProductId":8, + // "OrderOriginator":446, + // "UserName":"igor@ccxt.trade", + // "TradeTimeMS":1607565031569, + // "MakerTaker":"Taker", + // "AdapterTradeId":0, + // "InsideBid":19069.310000000000000000000000, + // "InsideBidSize":0.2400950000000000000000000000, + // "InsideAsk":19069.320000000000000000000000, + // "InsideAskSize":0.0997360000000000000000000000, + // "IsQuote":false, + // "CounterPartyClientUserId":1, + // "NotionalProductId":2, + // "NotionalRate":1.0000000000000000000000000000, + // "NotionalValue":2345.5251300000000000000000000, + // "NotionalHoldAmount":0, + // "TradeTime":637431618315686826 + // } + // ] + // + return this.parseTrades (response, market, since, limit); + } + + async cancelAllOrders (symbol = undefined, params = {}) { + const omsId = this.safeInteger (this.options, 'omsId', 1); + await this.loadMarkets (); + await this.loadAccounts (); + const defaultAccountId = this.safeInteger2 (this.options, 'accountId', 'AccountId', parseInt (this.accounts[0]['id'])); + const accountId = this.safeInteger2 (params, 'accountId', 'AccountId', defaultAccountId); + params = this.omit (params, [ 'accountId', 'AccountId' ]); + const request = { + 'omsId': omsId, + 'AccountId': accountId, + }; + if (symbol !== undefined) { + const market = this.market (symbol); + request['IntrumentId'] = market['id']; + } + const response = await this.privatePostCancelAllOrders (this.extend (request, params)); + // + // { + // "result":true, + // "errormsg":null, + // "errorcode":0, + // "detail":null + // } + // + return response; + } + + async cancelOrder (id, symbol = undefined, params = {}) { + const omsId = this.safeInteger (this.options, 'omsId', 1); + await this.loadMarkets (); + await this.loadAccounts (); + // const defaultAccountId = this.safeInteger2 (this.options, 'accountId', 'AccountId', parseInt (this.accounts[0]['id'])); + // const accountId = this.safeInteger2 (params, 'accountId', 'AccountId', defaultAccountId); + // params = this.omit (params, [ 'accountId', 'AccountId' ]); + let market = undefined; + if (symbol !== undefined) { + market = this.market (symbol); + } + const request = { + 'omsId': omsId, + // 'AccountId': accountId, + }; + const clientOrderId = this.safeInteger2 (params, 'clientOrderId', 'ClOrderId'); + if (clientOrderId !== undefined) { + request['ClOrderId'] = clientOrderId; + } else { + request['OrderId'] = parseInt (id); + } + params = this.omit (params, [ 'clientOrderId', 'ClOrderId' ]); + const response = await this.privatePostCancelOrder (this.extend (request, params)); + const order = this.parseOrder (response, market); + return this.extend (order, { + 'id': id, + 'clientOrderId': clientOrderId, + }); + } + + async fetchOpenOrders (symbol = undefined, since = undefined, limit = undefined, params = {}) { + const omsId = this.safeInteger (this.options, 'omsId', 1); + await this.loadMarkets (); + await this.loadAccounts (); + const defaultAccountId = this.safeInteger2 (this.options, 'accountId', 'AccountId', parseInt (this.accounts[0]['id'])); + const accountId = this.safeInteger2 (params, 'accountId', 'AccountId', defaultAccountId); + params = this.omit (params, [ 'accountId', 'AccountId' ]); + let market = undefined; + if (symbol !== undefined) { + market = this.market (symbol); + } + const request = { + 'omsId': omsId, + 'AccountId': accountId, + }; + const response = await this.privateGetGetOpenOrders (this.extend (request, params)); + // + // [ + // { + // "Side":"Buy", + // "OrderId":2543565233, + // "Price":19010, + // "Quantity":0.345, + // "DisplayQuantity":0.345, + // "Instrument":8, + // "Account":449, + // "AccountName":"igor@ccxt.trade", + // "OrderType":"Limit", + // "ClientOrderId":0, + // "OrderState":"Working", + // "ReceiveTime":1607579326003, + // "ReceiveTimeTicks":637431761260028981, + // "LastUpdatedTime":1607579326005, + // "LastUpdatedTimeTicks":637431761260054714, + // "OrigQuantity":0.345, + // "QuantityExecuted":0, + // "GrossValueExecuted":0, + // "ExecutableValue":0, + // "AvgPrice":0, + // "CounterPartyId":0, + // "ChangeReason":"NewInputAccepted", + // "OrigOrderId":2543565233, + // "OrigClOrdId":0, + // "EnteredBy":446, + // "UserName":"igor@ccxt.trade", + // "IsQuote":false, + // "InsideAsk":19069.32, + // "InsideAskSize":0.099736, + // "InsideBid":19068.25, + // "InsideBidSize":1.330001, + // "LastTradePrice":19068.25, + // "RejectReason":"", + // "IsLockedIn":false, + // "CancelReason":"", + // "OrderFlag":"AddedToBook", + // "UseMargin":false, + // "StopPrice":0, + // "PegPriceType":"Unknown", + // "PegOffset":0, + // "PegLimitOffset":0, + // "IpAddress":null, + // "ClientOrderIdUuid":null, + // "OMSId":1 + // } + // ] + // + return this.parseOrders (response, market, since, limit); + } + + async fetchOrders (symbol = undefined, since = undefined, limit = undefined, params = {}) { + const omsId = this.safeInteger (this.options, 'omsId', 1); + await this.loadMarkets (); + await this.loadAccounts (); + const defaultAccountId = this.safeInteger2 (this.options, 'accountId', 'AccountId', parseInt (this.accounts[0]['id'])); + const accountId = this.safeInteger2 (params, 'accountId', 'AccountId', defaultAccountId); + params = this.omit (params, [ 'accountId', 'AccountId' ]); + const request = { + 'omsId': omsId, + 'AccountId': accountId, + // 'ClientOrderId': clientOrderId, + // 'OriginalOrderId': id, + // 'OriginalClientOrderId': long integer, + // 'UserId': integer, + // 'InstrumentId': market['id'], + // 'StartTimestamp': since, + // 'EndTimestamp': this.milliseconds (), + // 'Depth': limit, + // 'StartIndex': 0, + }; + let market = undefined; + if (symbol !== undefined) { + market = this.market (symbol); + request['InstrumentId'] = market['id']; + } + if (since !== undefined) { + request['StartTimeStamp'] = since; + } + if (limit !== undefined) { + request['Depth'] = limit; + } + const response = await this.privateGetGetOrdersHistory (this.extend (request, params)); + // + // [ + // { + // "Side":"Buy", + // "OrderId":2543565233, + // "Price":19010.000000000000000000000000, + // "Quantity":0.0000000000000000000000000000, + // "DisplayQuantity":0.3450000000000000000000000000, + // "Instrument":8, + // "Account":449, + // "AccountName":"igor@ccxt.trade", + // "OrderType":"Limit", + // "ClientOrderId":0, + // "OrderState":"Canceled", + // "ReceiveTime":1607579326003, + // "ReceiveTimeTicks":637431761260028981, + // "LastUpdatedTime":1607580965346, + // "LastUpdatedTimeTicks":637431777653463754, + // "OrigQuantity":0.3450000000000000000000000000, + // "QuantityExecuted":0.0000000000000000000000000000, + // "GrossValueExecuted":0.0000000000000000000000000000, + // "ExecutableValue":0.0000000000000000000000000000, + // "AvgPrice":0.0000000000000000000000000000, + // "CounterPartyId":0, + // "ChangeReason":"UserModified", + // "OrigOrderId":2543565233, + // "OrigClOrdId":0, + // "EnteredBy":446, + // "UserName":"igor@ccxt.trade", + // "IsQuote":false, + // "InsideAsk":19069.320000000000000000000000, + // "InsideAskSize":0.0997360000000000000000000000, + // "InsideBid":19068.250000000000000000000000, + // "InsideBidSize":1.3300010000000000000000000000, + // "LastTradePrice":19068.250000000000000000000000, + // "RejectReason":"", + // "IsLockedIn":false, + // "CancelReason":"UserModified", + // "OrderFlag":"AddedToBook, RemovedFromBook", + // "UseMargin":false, + // "StopPrice":0.0000000000000000000000000000, + // "PegPriceType":"Unknown", + // "PegOffset":0.0000000000000000000000000000, + // "PegLimitOffset":0.0000000000000000000000000000, + // "IpAddress":"5.228.233.138", + // "ClientOrderIdUuid":null, + // "OMSId":1 + // }, + // ] + // + return this.parseOrders (response, market, since, limit); + } + + async fetchOrder (id, symbol = undefined, params = {}) { + const omsId = this.safeInteger (this.options, 'omsId', 1); + await this.loadMarkets (); + await this.loadAccounts (); + const defaultAccountId = this.safeInteger2 (this.options, 'accountId', 'AccountId', parseInt (this.accounts[0]['id'])); + const accountId = this.safeInteger2 (params, 'accountId', 'AccountId', defaultAccountId); + params = this.omit (params, [ 'accountId', 'AccountId' ]); + let market = undefined; + if (symbol !== undefined) { + market = this.market (symbol); + } + const request = { + 'omsId': omsId, + 'AccountId': accountId, + 'OrderId': parseInt (id), + }; + const response = await this.privateGetGetOrderStatus (this.extend (request, params)); + // + // { + // "Side":"Sell", + // "OrderId":2543565232, + // "Price":0.0000000000000000000000000000, + // "Quantity":0.0000000000000000000000000000, + // "DisplayQuantity":0.0000000000000000000000000000, + // "Instrument":8, + // "Account":449, + // "AccountName":"igor@ccxt.trade", + // "OrderType":"Market", + // "ClientOrderId":0, + // "OrderState":"FullyExecuted", + // "ReceiveTime":1607569475591, + // "ReceiveTimeTicks":637431662755912377, + // "LastUpdatedTime":1607569475596, + // "LastUpdatedTimeTicks":637431662755960902, + // "OrigQuantity":1.0000000000000000000000000000, + // "QuantityExecuted":1.0000000000000000000000000000, + // "GrossValueExecuted":19068.270478610000000000000000, + // "ExecutableValue":0.0000000000000000000000000000, + // "AvgPrice":19068.270478610000000000000000, + // "CounterPartyId":0, + // "ChangeReason":"Trade", + // "OrigOrderId":2543565232, + // "OrigClOrdId":0, + // "EnteredBy":446, + // "UserName":"igor@ccxt.trade", + // "IsQuote":false, + // "InsideAsk":19069.320000000000000000000000, + // "InsideAskSize":0.0997360000000000000000000000, + // "InsideBid":19069.310000000000000000000000, + // "InsideBidSize":0.2400950000000000000000000000, + // "LastTradePrice":19069.310000000000000000000000, + // "RejectReason":"", + // "IsLockedIn":false, + // "CancelReason":"", + // "OrderFlag":"0", + // "UseMargin":false, + // "StopPrice":0.0000000000000000000000000000, + // "PegPriceType":"Unknown", + // "PegOffset":0.0000000000000000000000000000, + // "PegLimitOffset":0.0000000000000000000000000000, + // "IpAddress":"5.228.233.138", + // "ClientOrderIdUuid":null, + // "OMSId":1 + // } + // + return this.parseOrder (response, market); + } + + async fetchOrderTrades (id, symbol = undefined, since = undefined, limit = undefined, params = {}) { + const omsId = this.safeInteger (this.options, 'omsId', 1); + await this.loadMarkets (); + await this.loadAccounts (); + // const defaultAccountId = this.safeInteger2 (this.options, 'accountId', 'AccountId', parseInt (this.accounts[0]['id'])); + // const accountId = this.safeInteger2 (params, 'accountId', 'AccountId', defaultAccountId); + // params = this.omit (params, [ 'accountId', 'AccountId' ]); + let market = undefined; + if (symbol !== undefined) { + market = this.market (symbol); + } + const request = { + 'OMSId': parseInt (omsId), + // 'AccountId': accountId, + 'OrderId': id, + }; + const response = await this.privatePostGetOrderHistoryByOrderId (this.extend (request, params)); + // + // [ + // { + // "Side":"Sell", + // "OrderId":2543565235, + // "Price":18600.000000000000000000000000, + // "Quantity":0.0000000000000000000000000000, + // "DisplayQuantity":0.0000000000000000000000000000, + // "Instrument":8, + // "Account":449, + // "AccountName":"igor@ccxt.trade", + // "OrderType":"Limit", + // "ClientOrderId":0, + // "OrderState":"FullyExecuted", + // "ReceiveTime":1607585844956, + // "ReceiveTimeTicks":637431826449564182, + // "LastUpdatedTime":1607585844959, + // "LastUpdatedTimeTicks":637431826449593893, + // "OrigQuantity":0.1230000000000000000000000000, + // "QuantityExecuted":0.1230000000000000000000000000, + // "GrossValueExecuted":2345.3947500000000000000000000, + // "ExecutableValue":0.0000000000000000000000000000, + // "AvgPrice":19068.250000000000000000000000, + // "CounterPartyId":0, + // "ChangeReason":"Trade", + // "OrigOrderId":2543565235, + // "OrigClOrdId":0, + // "EnteredBy":446, + // "UserName":"igor@ccxt.trade", + // "IsQuote":false, + // "InsideAsk":19069.320000000000000000000000, + // "InsideAskSize":0.0997360000000000000000000000, + // "InsideBid":19068.250000000000000000000000, + // "InsideBidSize":1.3300010000000000000000000000, + // "LastTradePrice":19068.250000000000000000000000, + // "RejectReason":"", + // "IsLockedIn":false, + // "CancelReason":"", + // "OrderFlag":"0", + // "UseMargin":false, + // "StopPrice":0.0000000000000000000000000000, + // "PegPriceType":"Unknown", + // "PegOffset":0.0000000000000000000000000000, + // "PegLimitOffset":0.0000000000000000000000000000, + // "IpAddress":"5.228.233.138", + // "ClientOrderIdUuid":null, + // "OMSId":1 + // }, + // ] + // + const grouped = this.groupBy (response, 'ChangeReason'); + const trades = this.safeValue (grouped, 'Trade', []); + return this.parseTrades (trades, market, since, limit); + } + + async fetchDepositAddress (code, params = {}) { + const omsId = this.safeInteger (this.options, 'omsId', 1); + await this.loadMarkets (); + await this.loadAccounts (); + const defaultAccountId = this.safeInteger2 (this.options, 'accountId', 'AccountId', parseInt (this.accounts[0]['id'])); + const accountId = this.safeInteger2 (params, 'accountId', 'AccountId', defaultAccountId); + params = this.omit (params, [ 'accountId', 'AccountId' ]); + const currency = this.currency (code); + const request = { + 'omsId': omsId, + 'AccountId': accountId, + 'ProductId': currency['id'], + 'GenerateNewKey': false, + }; + const response = await this.privateGetGetDepositInfo (this.extend (request, params)); + // + // { + // "result":true, + // "errormsg":null, + // "statuscode":0, + // "AssetManagerId":1, + // "AccountId":57922, + // "AssetId":16, + // "ProviderId":23, + // "DepositInfo":"[\"0x8A27564b5c30b91C93B1591821642420F323a210\"]" + // } + // + return this.parseDepositAddress (response, currency); + } + + parseDepositAddress (depositAddress, currency = undefined) { + // + // fetchDepositAddress, createDepositAddress + // + // { + // "result":true, + // "errormsg":null, + // "statuscode":0, + // "AssetManagerId":1, + // "AccountId":449, + // "AssetId":1, + // "ProviderId":1, + // "DepositInfo":"[\"r3e95RwVsLH7yCbnMfyh7SA8FdwUJCB4S2?memo=241452010\"]" + // } + // + const depositInfoString = this.safeString (depositAddress, 'DepositInfo'); + const depositInfo = JSON.parse (depositInfoString); + const depositInfoLength = depositInfo.length; + const lastString = this.safeString (depositInfo, depositInfoLength - 1); + const parts = lastString.split ('?memo='); + const address = this.safeString (parts, 0); + const tag = this.safeString (parts, 1); + let code = undefined; + if (currency !== undefined) { + code = currency['code']; + } + this.checkAddress (address); + return { + 'currency': code, + 'address': address, + 'tag': tag, + 'info': depositAddress, + }; + } + + async createDepositAddress (code, params = {}) { + const request = { + 'GenerateNewKey': true, + }; + return await this.fetchDepositAddress (code, this.extend (request, params)); + } + + async fetchDeposits (code = undefined, since = undefined, limit = undefined, params = {}) { + const omsId = this.safeInteger (this.options, 'omsId', 1); + await this.loadMarkets (); + await this.loadAccounts (); + const defaultAccountId = this.safeInteger2 (this.options, 'accountId', 'AccountId', parseInt (this.accounts[0]['id'])); + const accountId = this.safeInteger2 (params, 'accountId', 'AccountId', defaultAccountId); + params = this.omit (params, [ 'accountId', 'AccountId' ]); + let currency = undefined; + if (code !== undefined) { + currency = this.currency (code); + } + const request = { + 'omsId': omsId, + 'AccountId': accountId, + }; + const response = await this.privateGetGetDeposits (this.extend (request, params)); + // + // [ + // { + // "OMSId":1, + // "DepositId":44, + // "AccountId":449, + // "SubAccountId":0, + // "ProductId":4, + // "Amount":200.00000000000000000000000000, + // "LastUpdateTimeStamp":637431291261187806, + // "ProductType":"CryptoCurrency", + // "TicketStatus":"FullyProcessed", + // "DepositInfo":"{}", + // "DepositCode":"ab0e23d5-a9ce-4d94-865f-9ab464fb1de3", + // "TicketNumber":71, + // "NotionalProductId":13, + // "NotionalValue":200.00000000000000000000000000, + // "FeeAmount":0.0000000000000000000000000000, + // }, + // ] + // + return this.parseTransactions (response, currency, since, limit); + } + + async fetchWithdrawals (code = undefined, since = undefined, limit = undefined, params = {}) { + const omsId = this.safeInteger (this.options, 'omsId', 1); + await this.loadMarkets (); + await this.loadAccounts (); + const defaultAccountId = this.safeInteger2 (this.options, 'accountId', 'AccountId', parseInt (this.accounts[0]['id'])); + const accountId = this.safeInteger2 (params, 'accountId', 'AccountId', defaultAccountId); + params = this.omit (params, [ 'accountId', 'AccountId' ]); + let currency = undefined; + if (code !== undefined) { + currency = this.currency (code); + } + const request = { + 'omsId': omsId, + 'AccountId': accountId, + }; + const response = await this.privateGetGetWithdraws (this.extend (request, params)); + // + // [ + // { + // "Amount": 0.0, + // "FeeAmount": 0.0, + // "NotionalValue": 0.0, + // "WithdrawId": 0, + // "AssetManagerId": 0, + // "AccountId": 0, + // "AssetId": 0, + // "TemplateForm": "{\"TemplateType\": \"TetherRPCWithdraw\",\"Comment\": \"TestWithdraw\",\"ExternalAddress\": \"ms6C3pKAAr8gRCcnVebs8VRkVrjcvqNYv3\"}", + // "TemplateFormType": "TetherRPCWithdraw", + // "omsId": 0, + // "TicketStatus": 0, + // "TicketNumber": 0, + // "WithdrawTransactionDetails": "", + // "WithdrawType": "", + // "WithdrawCode": "490b4fa3-53fc-44f4-bd29-7e16be86fba3", + // "AssetType": 0, + // "Reaccepted": true, + // "NotionalProductId": 0 + // }, + // ] + // + return this.parseTransactions (response, currency, since, limit); + } + + parseTransactionStatusByType (status, type = undefined) { + const statusesByType = { + 'deposit': { + 'New': 'pending', // new ticket awaiting operator review + 'AdminProcessing': 'pending', // an admin is looking at the ticket + 'Accepted': 'pending', // an admin accepts the ticket + 'Rejected': 'rejected', // admin rejects the ticket + 'SystemProcessing': 'pending', // automatic processing; an unlikely status for a deposit + 'FullyProcessed': 'ok', // the deposit has concluded + 'Failed': 'failed', // the deposit has failed for some reason + 'Pending': 'pending', // Account Provider has set status to pending + 'Confirmed': 'pending', // Account Provider confirms the deposit + 'AmlProcessing': 'pending', // anti-money-laundering process underway + 'AmlAccepted': 'pending', // anti-money-laundering process successful + 'AmlRejected': 'rejected', // deposit did not stand up to anti-money-laundering process + 'AmlFailed': 'failed', // anti-money-laundering process failed/did not complete + 'LimitsAccepted': 'pending', // deposit meets limits for fiat or crypto asset + 'LimitsRejected': 'rejected', // deposit does not meet limits for fiat or crypto asset + }, + 'withdrawal': { + 'New': 'pending', // awaiting operator review + 'AdminProcessing': 'pending', // An admin is looking at the ticket + 'Accepted': 'pending', // withdrawal will proceed + 'Rejected': 'rejected', // admin or automatic rejection + 'SystemProcessing': 'pending', // automatic processing underway + 'FullyProcessed': 'ok', // the withdrawal has concluded + 'Failed': 'failed', // the withdrawal failed for some reason + 'Pending': 'pending', // the admin has placed the withdrawal in pending status + 'Pending2Fa': 'pending', // user must click 2-factor authentication confirmation link + 'AutoAccepted': 'pending', // withdrawal will be automatically processed + 'Delayed': 'pending', // waiting for funds to be allocated for the withdrawal + 'UserCanceled': 'canceled', // withdraw canceled by user or Superuser + 'AdminCanceled': 'canceled', // withdraw canceled by Superuser + 'AmlProcessing': 'pending', // anti-money-laundering process underway + 'AmlAccepted': 'pending', // anti-money-laundering process complete + 'AmlRejected': 'rejected', // withdrawal did not stand up to anti-money-laundering process + 'AmlFailed': 'failed', // withdrawal did not complete anti-money-laundering process + 'LimitsAccepted': 'pending', // withdrawal meets limits for fiat or crypto asset + 'LimitsRejected': 'rejected', // withdrawal does not meet limits for fiat or crypto asset + 'Submitted': 'pending', // withdrawal sent to Account Provider; awaiting blockchain confirmation + 'Confirmed': 'pending', // Account Provider confirms that withdrawal is on the blockchain + 'ManuallyConfirmed': 'pending', // admin has sent withdrawal via wallet or admin function directly; marks ticket as FullyProcessed; debits account + 'Confirmed2Fa': 'pending', // user has confirmed withdraw via 2-factor authentication. + }, + }; + const statuses = this.safeValue (statusesByType, type, {}); + return this.safeString (statuses, status, status); + } + + parseTransaction (transaction, currency = undefined) { + // + // fetchDeposits + // + // { + // "OMSId":1, + // "DepositId":44, + // "AccountId":449, + // "SubAccountId":0, + // "ProductId":4, + // "Amount":200.00000000000000000000000000, + // "LastUpdateTimeStamp":637431291261187806, + // "ProductType":"CryptoCurrency", + // "TicketStatus":"FullyProcessed", + // "DepositInfo":"{}", + // "DepositCode":"ab0e23d5-a9ce-4d94-865f-9ab464fb1de3", + // "TicketNumber":71, + // "NotionalProductId":13, + // "NotionalValue":200.00000000000000000000000000, + // "FeeAmount":0.0000000000000000000000000000, + // } + // + // fetchWithdrawals + // + // { + // "Amount": 0.0, + // "FeeAmount": 0.0, + // "NotionalValue": 0.0, + // "WithdrawId": 0, + // "AssetManagerId": 0, + // "AccountId": 0, + // "AssetId": 0, + // "TemplateForm": "{\"TemplateType\": \"TetherRPCWithdraw\",\"Comment\": \"TestWithdraw\",\"ExternalAddress\": \"ms6C3pKAAr8gRCcnVebs8VRkVrjcvqNYv3\"}", + // "TemplateFormType": "TetherRPCWithdraw", + // "omsId": 0, + // "TicketStatus": 0, + // "TicketNumber": 0, + // "WithdrawTransactionDetails": "", + // "WithdrawType": "", + // "WithdrawCode": "490b4fa3-53fc-44f4-bd29-7e16be86fba3", + // "AssetType": 0, + // "Reaccepted": true, + // "NotionalProductId": 0 + // } + // + const id = this.safeString (transaction, 'DepositId'); + let txid = undefined; + const currencyId = this.safeString (transaction, 'ProductId'); + const code = this.safeCurrencyCode (currencyId, currency); + let timestamp = undefined; + let type = undefined; + if ('DepositId' in transaction) { + type = 'deposit'; + } else if ('WithdrawId' in transaction) { + type = 'withdrawal'; + } + const templateFormString = this.safeString (transaction, 'TemplateForm'); + let address = undefined; + let updated = this.safeInteger (transaction, 'LastUpdateTimeStamp'); + if (templateFormString !== undefined) { + const templateForm = JSON.parse (templateFormString); + address = this.safeString (templateForm, 'ExternalAddress'); + txid = this.safeString (templateForm, 'TxId'); + timestamp = this.safeInteger (templateForm, 'TimeSubmitted'); + updated = this.safeInteger (templateForm, 'LastUpdated', updated); + } + const addressTo = address; + const status = this.parseTransactionStatusByType (this.safeString (transaction, 'TicketStatus'), type); + const amount = this.safeFloat (transaction, 'Amount'); + const feeCost = this.safeFloat (transaction, 'FeeAmount'); + let fee = undefined; + if (feeCost !== undefined) { + fee = { 'currency': code, 'cost': feeCost }; + } + return { + 'info': transaction, + 'id': id, + 'txid': txid, + 'timestamp': timestamp, + 'datetime': this.iso8601 (timestamp), + 'address': address, + 'addressTo': addressTo, + 'addressFrom': undefined, + 'tag': undefined, + 'tagTo': undefined, + 'tagFrom': undefined, + 'type': type, + 'amount': amount, + 'currency': code, + 'status': status, + 'updated': updated, + 'fee': fee, + }; + } + + nonce () { + return this.milliseconds (); + } + + sign (path, api = 'public', method = 'GET', params = {}, headers = undefined, body = undefined) { + let url = this.urls['api'][api] + '/' + this.implodeParams (path, params); + const query = this.omit (params, this.extractParams (path)); + if (api === 'public') { + if (Object.keys (query).length) { + url += '?' + this.urlencode (query); + } + } else if (api === 'private') { + this.checkRequiredCredentials (); + const nonce = this.nonce ().toString (); + const auth = nonce + this.uid + this.apiKey; + const signature = this.hmac (this.encode (auth), this.encode (this.secret)); + headers = { + 'Nonce': nonce, + 'APIKey': this.apiKey, + 'Signature': signature, + 'UserId': this.uid, + }; + if (method === 'POST') { + headers['Content-Type'] = 'application/json'; + body = this.json (query); + } else { + if (Object.keys (query).length) { + url += '?' + this.urlencode (query); + } + } + } + return { 'url': url, 'method': method, 'body': body, 'headers': headers }; + } + + handleErrors (code, reason, url, method, headers, body, response, requestHeaders, requestBody) { + if (code === 404) { + throw new AuthenticationError (this.id + ' ' + body); + } + if (response === undefined) { + return; + } + // + // {"status":"Rejected","errormsg":"Not_Enough_Funds","errorcode":101} + // {"result":false,"errormsg":"Server Error","errorcode":102,"detail":null} + // + const message = this.safeString (response, 'errormsg'); + if ((message !== undefined) && (message !== '')) { + const feedback = this.id + ' ' + body; + this.throwExactlyMatchedException (this.exceptions['exact'], message, feedback); + this.throwBroadlyMatchedException (this.exceptions['broad'], body, feedback); + throw new ExchangeError (feedback); + } + } +}; + +},{"./base/Exchange":6,"./base/errors":8,"./base/functions/number":14}],114:[function(require,module,exports){ 'use strict'; // --------------------------------------------------------------------------- @@ -89216,6 +97366,7 @@ module.exports = class novadax extends Exchange { 'symbol': symbol, 'type': type, 'timeInForce': undefined, + 'postOnly': undefined, 'side': side, 'price': price, 'stopPrice': undefined, @@ -89532,7 +97683,7 @@ module.exports = class novadax extends Exchange { } }; -},{"./base/Exchange":5,"./base/errors":7,"./base/functions/number":13}],112:[function(require,module,exports){ +},{"./base/Exchange":6,"./base/errors":8,"./base/functions/number":14}],115:[function(require,module,exports){ 'use strict'; // --------------------------------------------------------------------------- @@ -90047,7 +98198,7 @@ module.exports = class oceanex extends Exchange { async fetchOrders (symbol = undefined, since = undefined, limit = undefined, params = {}) { if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' fetchOrders requires a `symbol` argument'); + throw new ArgumentsRequired (this.id + ' fetchOrders() requires a `symbol` argument'); } await this.loadMarkets (); const market = this.market (symbol); @@ -90108,6 +98259,7 @@ module.exports = class oceanex extends Exchange { 'symbol': symbol, 'type': this.safeValue (order, 'ord_type'), 'timeInForce': undefined, + 'postOnly': undefined, 'side': this.safeValue (order, 'side'), 'price': this.safeFloat (order, 'price'), 'stopPrice': undefined, @@ -90217,7 +98369,7 @@ module.exports = class oceanex extends Exchange { } }; -},{"./base/Exchange":5,"./base/errors":7}],113:[function(require,module,exports){ +},{"./base/Exchange":6,"./base/errors":8}],116:[function(require,module,exports){ 'use strict'; // --------------------------------------------------------------------------- @@ -90254,13 +98406,13 @@ module.exports = class okcoin extends okex { } }; -},{"./okex.js":114}],114:[function(require,module,exports){ +},{"./okex.js":117}],117:[function(require,module,exports){ 'use strict'; // --------------------------------------------------------------------------- const Exchange = require ('./base/Exchange'); -const { ExchangeError, ExchangeNotAvailable, OnMaintenance, ArgumentsRequired, BadRequest, AccountSuspended, InvalidAddress, PermissionDenied, DDoSProtection, InsufficientFunds, InvalidNonce, CancelPending, InvalidOrder, OrderNotFound, AuthenticationError, RequestTimeout, NotSupported, BadSymbol } = require ('./base/errors'); +const { ExchangeError, ExchangeNotAvailable, OnMaintenance, ArgumentsRequired, BadRequest, AccountSuspended, InvalidAddress, PermissionDenied, DDoSProtection, InsufficientFunds, InvalidNonce, CancelPending, InvalidOrder, OrderNotFound, AuthenticationError, RequestTimeout, NotSupported, BadSymbol, RateLimitExceeded } = require ('./base/errors'); const { TICK_SIZE, TRUNCATE } = require ('./base/functions/number'); // --------------------------------------------------------------------------- @@ -90365,6 +98517,7 @@ module.exports = class okex extends Exchange { 'accounts/{currency}', 'accounts/{currency}/ledger', 'orders', + 'amend_order/{instrument_id}', 'orders_pending', 'orders/{order_id}', 'orders/{client_oid}', @@ -90455,6 +98608,7 @@ module.exports = class okex extends Exchange { 'post': [ 'accounts/{underlying}/leverage', 'order', + 'amend_order/{instrument_id}', 'orders', 'cancel_order/{instrument_id}/{order_id}', 'cancel_order/{instrument_id}/{client_oid}', @@ -90501,12 +98655,17 @@ module.exports = class okex extends Exchange { 'post': [ 'accounts/{instrument_id}/leverage', 'order', + 'amend_order/{instrument_id}', 'orders', 'cancel_order/{instrument_id}/{order_id}', 'cancel_order/{instrument_id}/{client_oid}', 'cancel_batch_orders/{instrument_id}', 'order_algo', 'cancel_algos', + 'close_position', + 'cancel_all', + 'order_algo', + 'cancel_algos', ], }, 'option': { @@ -90783,7 +98942,7 @@ module.exports = class okex extends Exchange { '34021': InvalidAddress, // { "code": 34021, "message": "Not verified address" } '34022': ExchangeError, // { "code": 34022, "message": "Withdrawals are not available for sub accounts" } '34023': PermissionDenied, // { "code": 34023, "message": "Please enable futures trading before transferring your funds" } - '34026': ExchangeError, // transfer too frequently(transfer too frequently) + '34026': RateLimitExceeded, // transfer too frequently(transfer too frequently) '34036': ExchangeError, // Parameter is incorrect, please refer to API documentation '34037': ExchangeError, // Get the sub-account balance interface, account type is not supported '34038': ExchangeError, // Since your C2C transaction is unusual, you are restricted from fund transfer. Please contact our customer support to cancel the restriction @@ -90812,7 +98971,7 @@ module.exports = class okex extends Exchange { '35031': InvalidOrder, // { "code": 35031, "message": "Cancel order size too large" } '35032': ExchangeError, // { "code": 35032, "message": "Invalid user status" } '35037': ExchangeError, // No last traded price in cache - '35039': ExchangeError, // { "code": 35039, "message": "Open order quantity exceeds limit" } + '35039': InsufficientFunds, // { "code": 35039, "message": "Open order quantity exceeds limit" } '35040': InvalidOrder, // {"error_message":"Invalid order type","result":"true","error_code":"35040","order_id":"-1"} '35044': ExchangeError, // { "code": 35044, "message": "Invalid order status" } '35046': InsufficientFunds, // { "code": 35046, "message": "Negative account balance" } @@ -90865,6 +99024,7 @@ module.exports = class okex extends Exchange { '35097': ExchangeError, // Order status and order ID cannot exist at the same time '35098': ExchangeError, // An order status or order ID must exist '35099': ExchangeError, // Algo order ID error + '35102': RateLimitExceeded, // {"error_message":"The operation that close all at market price is too frequent","result":"true","error_code":"35102","order_id":"-1"} // option '36001': BadRequest, // Invalid underlying index. '36002': BadRequest, // Instrument does not exist. @@ -90934,6 +99094,7 @@ module.exports = class okex extends Exchange { 'HOT': 'Hydro Protocol', 'HSR': 'HC', 'MAG': 'Maggie', + 'SBTC': 'Super Bitcoin', 'YOYO': 'YOYOW', 'WIN': 'WinToken', // https://github.com/ccxt/ccxt/issues/5701 }, @@ -91233,7 +99394,7 @@ module.exports = class okex extends Exchange { const currency = response[i]; const id = this.safeString (currency, 'currency'); const code = this.safeCurrencyCode (id); - const precision = 8; // default precision, todo: fix "magic constants" + const precision = 0.00000001; // default precision, todo: fix "magic constants" const name = this.safeString (currency, 'name'); const canDeposit = this.safeInteger (currency, 'can_deposit'); const canWithdraw = this.safeInteger (currency, 'can_withdraw'); @@ -91969,7 +100130,7 @@ module.exports = class okex extends Exchange { const defaultType = this.safeString2 (this.options, 'fetchBalance', 'defaultType'); const type = this.safeString (params, 'type', defaultType); if (type === undefined) { - throw new ArgumentsRequired (this.id + " fetchBalance requires a type parameter (one of 'account', 'spot', 'margin', 'futures', 'swap')"); + throw new ArgumentsRequired (this.id + " fetchBalance() requires a type parameter (one of 'account', 'spot', 'margin', 'futures', 'swap')"); } await this.loadMarkets (); const suffix = (type === 'account') ? 'Wallet' : 'Accounts'; @@ -92215,7 +100376,7 @@ module.exports = class okex extends Exchange { type = this.safeString (params, 'type', defaultType); } if (type === undefined) { - throw new ArgumentsRequired (this.id + " cancelOrder requires a type parameter (one of 'spot', 'margin', 'futures', 'swap')."); + throw new ArgumentsRequired (this.id + " cancelOrder() requires a type parameter (one of 'spot', 'margin', 'futures', 'swap')."); } let method = type + 'PostCancelOrder'; const request = { @@ -92422,6 +100583,7 @@ module.exports = class okex extends Exchange { 'symbol': symbol, 'type': type, 'timeInForce': undefined, + 'postOnly': undefined, 'side': side, 'price': price, 'stopPrice': stopPrice, @@ -92438,14 +100600,14 @@ module.exports = class okex extends Exchange { async fetchOrder (id, symbol = undefined, params = {}) { if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' fetchOrder requires a symbol argument'); + throw new ArgumentsRequired (this.id + ' fetchOrder() requires a symbol argument'); } await this.loadMarkets (); const market = this.market (symbol); const defaultType = this.safeString2 (this.options, 'fetchOrder', 'defaultType', market['type']); const type = this.safeString (params, 'type', defaultType); if (type === undefined) { - throw new ArgumentsRequired (this.id + " fetchOrder requires a type parameter (one of 'spot', 'margin', 'futures', 'swap')."); + throw new ArgumentsRequired (this.id + " fetchOrder() requires a type parameter (one of 'spot', 'margin', 'futures', 'swap')."); } const instrumentId = (market['futures'] || market['swap']) ? 'InstrumentId' : ''; let method = type + 'GetOrders' + instrumentId; @@ -92513,7 +100675,7 @@ module.exports = class okex extends Exchange { async fetchOrdersByState (state, symbol = undefined, since = undefined, limit = undefined, params = {}) { if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' fetchOrdersByState requires a symbol argument'); + throw new ArgumentsRequired (this.id + ' fetchOrdersByState() requires a symbol argument'); } await this.loadMarkets (); const market = this.market (symbol); @@ -92525,7 +100687,7 @@ module.exports = class okex extends Exchange { type = this.safeString (params, 'type', defaultType); } if (type === undefined) { - throw new ArgumentsRequired (this.id + " fetchOrder requires a type parameter (one of 'spot', 'margin', 'futures', 'swap')."); + throw new ArgumentsRequired (this.id + " fetchOrdersByState() requires a type parameter (one of 'spot', 'margin', 'futures', 'swap')."); } const request = { 'instrument_id': market['id'], @@ -92855,6 +101017,7 @@ module.exports = class okex extends Exchange { // "currency": "XMR", // "from": "", // "to": "48PjH3ksv1fiXniKvKvyH5UtFs5WhfS2Vf7U3TwzdRJtCc7HJWvCQe56dRahyhQyTAViXZ8Nzk4gQg6o4BJBMUoxNy8y8g7", + // "tag": "1234567", // "deposit_id": 11571659, <-- we can use this // "timestamp": "2019-10-01T14:54:19.000Z", // "status": "2" @@ -92866,6 +101029,7 @@ module.exports = class okex extends Exchange { const withdrawalId = this.safeString (transaction, 'withdrawal_id'); const addressFrom = this.safeString (transaction, 'from'); const addressTo = this.safeString (transaction, 'to'); + const tagTo = this.safeString (transaction, 'tag'); if (withdrawalId !== undefined) { type = 'withdrawal'; id = withdrawalId; @@ -92906,8 +101070,8 @@ module.exports = class okex extends Exchange { 'addressTo': addressTo, 'address': address, 'tagFrom': undefined, - 'tagTo': undefined, - 'tag': undefined, + 'tagTo': tagTo, + 'tag': tagTo, 'status': status, 'type': type, 'updated': undefined, @@ -93080,7 +101244,7 @@ module.exports = class okex extends Exchange { // this aspect renders the 'fills' endpoint unusable for fetchOrderTrades // until either OKEX fixes the API or we workaround this on our side somehow if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' fetchMyTrades requires a symbol argument'); + throw new ArgumentsRequired (this.id + ' fetchMyTrades() requires a symbol argument'); } await this.loadMarkets (); const market = this.market (symbol); @@ -93469,16 +101633,28 @@ module.exports = class okex extends Exchange { request['limit'] = limit; } let currency = undefined; - if ((type === 'spot') || (type === 'futures')) { + if (type === 'spot') { if (code === undefined) { - throw new ArgumentsRequired (this.id + " fetchLedger requires a currency code argument for '" + type + "' markets"); + throw new ArgumentsRequired (this.id + " fetchLedger() requires a currency code argument for '" + type + "' markets"); } argument = 'Currency'; currency = this.currency (code); request['currency'] = currency['id']; + } else if (type === 'futures') { + if (code === undefined) { + throw new ArgumentsRequired (this.id + " fetchLedger() requires an underlying symbol for '" + type + "' markets"); + } + argument = 'Underlying'; + const market = this.market (code); // we intentionally put a market inside here for the margin and swap ledgers + const marketInfo = this.safeValue (market, 'info', {}); + const settlementCurrencyId = this.safeString (marketInfo, 'settlement_currency'); + const settlementCurrencyСode = this.safeCurrencyCode (settlementCurrencyId); + currency = this.currency (settlementCurrencyСode); + const underlyingId = this.safeString (marketInfo, 'underlying'); + request['underlying'] = underlyingId; } else if ((type === 'margin') || (type === 'swap')) { if (code === undefined) { - throw new ArgumentsRequired (this.id + " fetchLedger requires a code argument (a market symbol) for '" + type + "' markets"); + throw new ArgumentsRequired (this.id + " fetchLedger() requires a code argument (a market symbol) for '" + type + "' markets"); } argument = 'InstrumentId'; const market = this.market (code); // we intentionally put a market inside here for the margin and swap ledgers @@ -93872,7 +102048,7 @@ module.exports = class okex extends Exchange { } }; -},{"./base/Exchange":5,"./base/errors":7,"./base/functions/number":13}],115:[function(require,module,exports){ +},{"./base/Exchange":6,"./base/errors":8,"./base/functions/number":14}],118:[function(require,module,exports){ 'use strict'; // --------------------------------------------------------------------------- @@ -94137,7 +102313,7 @@ module.exports = class paymium extends Exchange { } }; -},{"./base/Exchange":5,"./base/errors":7}],116:[function(require,module,exports){ +},{"./base/Exchange":6,"./base/errors":8}],119:[function(require,module,exports){ 'use strict'; // ---------------------------------------------------------------------------- @@ -94242,6 +102418,7 @@ module.exports = class phemex extends Exchange { 'exchange/spot/order/trades', // ?symbol=&start=&end=&limit=&offset= // swap 'accounts/accountPositions', // ?currency= + 'accounts/positions', // ?currency= 'orders/activeList', // ?symbol= 'exchange/order/list', // ?symbol=&start=&end=&offset=&limit=&ordStatus=&withCount= 'exchange/order', // ?symbol=&orderID= @@ -94868,7 +103045,7 @@ module.exports = class phemex extends Exchange { parseBidAsk (bidask, priceKey = 0, amountKey = 1, market = undefined) { if (market === undefined) { - throw new ArgumentsRequired (this.id + ' parseBidAsk requires a market argument'); + throw new ArgumentsRequired (this.id + ' parseBidAsk() requires a market argument'); } let amount = this.safeFloat (bidask, amountKey); if (market['spot']) { @@ -94961,6 +103138,9 @@ module.exports = class phemex extends Exchange { } fromEn (en, scale, precision, precisionMode = undefined) { + if (en === undefined) { + return en; + } precisionMode = (precisionMode === undefined) ? this.precisionMode : precisionMode; return parseFloat (this.decimalToPrecision (en * Math.pow (10, -scale), ROUND, precision, precisionMode)); } @@ -95004,13 +103184,19 @@ module.exports = class phemex extends Exchange { // 48759063370, // quote volume // ] // + let baseVolume = undefined; + if ((market !== undefined) && market['spot']) { + baseVolume = this.fromEv (this.safeFloat (ohlcv, 7), market); + } else { + baseVolume = this.safeInteger (ohlcv, 7); + } return [ this.safeTimestamp (ohlcv, 0), this.fromEp (this.safeFloat (ohlcv, 3), market), this.fromEp (this.safeFloat (ohlcv, 4), market), this.fromEp (this.safeFloat (ohlcv, 5), market), this.fromEp (this.safeFloat (ohlcv, 6), market), - this.fromEv (this.safeFloat (ohlcv, 7), market), + baseVolume, ]; } @@ -95037,7 +103223,7 @@ module.exports = class phemex extends Exchange { request['from'] = now - duration * this.sum (limit, 1); request['to'] = now; } else { - throw new ArgumentsRequired (this.id + ' fetchOHLCV requires a since argument, or a limit argument, or both'); + throw new ArgumentsRequired (this.id + ' fetchOHLCV() requires a since argument, or a limit argument, or both'); } await this.loadMarkets (); const market = this.market (symbol); @@ -95542,7 +103728,7 @@ module.exports = class phemex extends Exchange { } else { const currency = this.safeString (params, 'currency'); if (currency === undefined) { - throw new ArgumentsRequired (this.id + ' fetchBalance requires a code parameter or a currency parameter for ' + type + ' type'); + throw new ArgumentsRequired (this.id + ' fetchBalance() requires a code parameter or a currency parameter for ' + type + ' type'); } } method = 'privateGetAccountsAccountPositions'; @@ -95777,8 +103963,9 @@ module.exports = class phemex extends Exchange { filled = Math.min (0, amount - remaining); } } - const timeInForce = this.parseTimeInForce (this.safeStirng (order, 'timeInForce')); + const timeInForce = this.parseTimeInForce (this.safeString (order, 'timeInForce')); const stopPrice = this.fromEp (this.safeFloat (order, 'stopPxEp', market)); + const postOnly = (timeInForce === 'PO'); return { 'info': order, 'id': id, @@ -95789,6 +103976,7 @@ module.exports = class phemex extends Exchange { 'symbol': symbol, 'type': type, 'timeInForce': timeInForce, + 'postOnly': postOnly, 'side': side, 'price': price, 'stopPrice': stopPrice, @@ -95861,6 +104049,7 @@ module.exports = class phemex extends Exchange { } const timeInForce = this.parseTimeInForce (this.safeString (order, 'timeInForce')); const stopPrice = this.safeFloat (order, 'stopPx'); + const postOnly = (timeInForce === 'PO'); return { 'info': order, 'id': id, @@ -95871,6 +104060,7 @@ module.exports = class phemex extends Exchange { 'symbol': symbol, 'type': type, 'timeInForce': timeInForce, + 'postOnly': postOnly, 'side': side, 'price': price, 'stopPrice': stopPrice, @@ -95926,8 +104116,10 @@ module.exports = class phemex extends Exchange { }; if (market['spot']) { let qtyType = this.safeValue (params, 'qtyType', 'ByBase'); - if (price !== undefined) { - qtyType = 'ByQuote'; + if ((type === 'Market') || (type === 'Stop') || (type === 'MarketIfTouched')) { + if (price !== undefined) { + qtyType = 'ByQuote'; + } } request['qtyType'] = qtyType; if (qtyType === 'ByQuote') { @@ -95937,7 +104129,7 @@ module.exports = class phemex extends Exchange { if (price !== undefined) { cost = amount * price; } else if (cost === undefined) { - throw new ArgumentsRequired (this.id + ' createOrder ' + qtyType + ' requires a price argument or a cost parameter'); + throw new ArgumentsRequired (this.id + ' createOrder() ' + qtyType + ' requires a price argument or a cost parameter'); } } cost = (cost === undefined) ? amount : cost; @@ -96040,7 +104232,7 @@ module.exports = class phemex extends Exchange { async cancelOrder (id, symbol = undefined, params = {}) { if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' cancelOrder requires a symbol argument'); + throw new ArgumentsRequired (this.id + ' cancelOrder() requires a symbol argument'); } await this.loadMarkets (); const market = this.market (symbol); @@ -96080,7 +104272,7 @@ module.exports = class phemex extends Exchange { async fetchOrder (id, symbol = undefined, params = {}) { if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' fetchOrder requires a symbol argument'); + throw new ArgumentsRequired (this.id + ' fetchOrder() requires a symbol argument'); } await this.loadMarkets (); const market = this.market (symbol); @@ -96114,7 +104306,7 @@ module.exports = class phemex extends Exchange { async fetchOrders (symbol = undefined, since = undefined, limit = undefined, params = {}) { if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' fetchOrders requires a symbol argument'); + throw new ArgumentsRequired (this.id + ' fetchOrders() requires a symbol argument'); } await this.loadMarkets (); const market = this.market (symbol); @@ -96136,7 +104328,7 @@ module.exports = class phemex extends Exchange { async fetchOpenOrders (symbol = undefined, since = undefined, limit = undefined, params = {}) { if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' fetchOpenOrders requires a symbol argument'); + throw new ArgumentsRequired (this.id + ' fetchOpenOrders() requires a symbol argument'); } await this.loadMarkets (); const market = this.market (symbol); @@ -96160,7 +104352,7 @@ module.exports = class phemex extends Exchange { async fetchClosedOrders (symbol = undefined, since = undefined, limit = undefined, params = {}) { if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' fetchClosedOrders requires a symbol argument'); + throw new ArgumentsRequired (this.id + ' fetchClosedOrders() requires a symbol argument'); } await this.loadMarkets (); const market = this.market (symbol); @@ -96222,7 +104414,7 @@ module.exports = class phemex extends Exchange { async fetchMyTrades (symbol = undefined, since = undefined, limit = undefined, params = {}) { if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' fetchClosedOrders requires a symbol argument'); + throw new ArgumentsRequired (this.id + ' fetchClosedOrders() requires a symbol argument'); } await this.loadMarkets (); const market = this.market (symbol); @@ -96457,7 +104649,7 @@ module.exports = class phemex extends Exchange { const currencyId = this.safeString (transaction, 'currency'); currency = this.safeCurrency (currencyId, currency); const code = currency['code']; - const timestamp = this.safeInteger (transaction, 'createdAt'); + const timestamp = this.safeInteger2 (transaction, 'createdAt', 'submitedAt'); let type = this.safeStringLower (transaction, 'type'); const feeCost = this.fromEn (this.safeFloat (transaction, 'feeEv'), currency['valueScale'], currency['precision']); let fee = undefined; @@ -96644,7 +104836,7 @@ module.exports = class phemex extends Exchange { } }; -},{"./base/Exchange":5,"./base/errors":7,"./base/functions/number":13}],117:[function(require,module,exports){ +},{"./base/Exchange":6,"./base/errors":8,"./base/functions/number":14}],120:[function(require,module,exports){ 'use strict'; // --------------------------------------------------------------------------- @@ -96851,7 +105043,6 @@ module.exports = class poloniex extends Exchange { 'Error pulling ': ExchangeError, // {"error":"Error pulling order book"} }, }, - 'orders': {}, // orders cache / emulation }); } @@ -97570,6 +105761,7 @@ module.exports = class poloniex extends Exchange { 'symbol': symbol, 'type': type, 'timeInForce': undefined, + 'postOnly': undefined, 'side': side, 'price': price, 'stopPrice': undefined, @@ -98131,7 +106323,7 @@ module.exports = class poloniex extends Exchange { } }; -},{"./base/Exchange":5,"./base/errors":7}],118:[function(require,module,exports){ +},{"./base/Exchange":6,"./base/errors":8}],121:[function(require,module,exports){ 'use strict'; // --------------------------------------------------------------------------- @@ -98255,6 +106447,7 @@ module.exports = class probit extends Exchange { 'RATE_LIMIT_EXCEEDED': RateLimitExceeded, // You are sending requests too frequently. Please try it later. 'MARKET_UNAVAILABLE': ExchangeNotAvailable, // Market is closed today 'INVALID_MARKET': BadSymbol, // Requested market is not exist + 'MARKET_CLOSED': BadSymbol, // {"errorCode":"MARKET_CLOSED"} 'INVALID_CURRENCY': BadRequest, // Requested currency is not exist on ProBit system 'TOO_MANY_OPEN_ORDERS': DDoSProtection, // Too many open orders 'DUPLICATE_ADDRESS': InvalidAddress, // Address already exists in withdrawal address list @@ -98276,6 +106469,7 @@ module.exports = class probit extends Exchange { 'BTCBEAR': 'BEAR', 'BTCBULL': 'BULL', 'CBC': 'CryptoBharatCoin', + 'HBC': 'Hybrid Bank Cash', 'UNI': 'UNICORN Token', }, }); @@ -98433,7 +106627,18 @@ module.exports = class probit extends Exchange { const withdrawalSuspended = this.safeValue (platform, 'withdrawal_suspended'); const active = !(depositSuspended && withdrawalSuspended); const withdrawalFees = this.safeValue (platform, 'withdrawal_fee', {}); - const withdrawalFeesByPriority = this.sortBy (withdrawalFees, 'priority'); + const fees = []; + // sometimes the withdrawal fee is an empty object + // [ { 'amount': '0.015', 'priority': 1, 'currency_id': 'ETH' }, {} ] + for (let j = 0; j < withdrawalFees.length; j++) { + const withdrawalFee = withdrawalFees[j]; + const amount = this.safeFloat (withdrawalFee, 'amount'); + const priority = this.safeInteger (withdrawalFee, 'priority'); + if ((amount !== undefined) && (priority !== undefined)) { + fees.push (withdrawalFee); + } + } + const withdrawalFeesByPriority = this.sortBy (fees, 'priority'); const withdrawalFee = this.safeValue (withdrawalFeesByPriority, 0, {}); const fee = this.safeFloat (withdrawalFee, 'amount'); result[code] = { @@ -98863,7 +107068,7 @@ module.exports = class probit extends Exchange { let endTime = now; if (since === undefined) { if (limit === undefined) { - throw new ArgumentsRequired (this.id + ' fetchOHLCV requires either a since argument or a limit argument'); + throw new ArgumentsRequired (this.id + ' fetchOHLCV() requires either a since argument or a limit argument'); } else { startTime = now - limit * duration * 1000; } @@ -98963,7 +107168,7 @@ module.exports = class probit extends Exchange { async fetchOrder (id, symbol = undefined, params = {}) { if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' fetchOrder requires a symbol argument'); + throw new ArgumentsRequired (this.id + ' fetchOrder() requires a symbol argument'); } await this.loadMarkets (); const market = this.market (symbol); @@ -99156,7 +107361,7 @@ module.exports = class probit extends Exchange { async cancelOrder (id, symbol = undefined, params = {}) { if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' cancelOrder requires a symbol argument'); + throw new ArgumentsRequired (this.id + ' cancelOrder() requires a symbol argument'); } await this.loadMarkets (); const market = this.market (symbol); @@ -99404,7 +107609,7 @@ module.exports = class probit extends Exchange { } }; -},{"./base/Exchange":5,"./base/errors":7,"./base/functions/number":13}],119:[function(require,module,exports){ +},{"./base/Exchange":6,"./base/errors":8,"./base/functions/number":14}],122:[function(require,module,exports){ 'use strict'; // --------------------------------------------------------------------------- @@ -100322,6 +108527,7 @@ module.exports = class qtrade extends Exchange { 'symbol': symbol, 'type': orderType, 'timeInForce': undefined, + 'postOnly': undefined, 'side': side, 'price': price, 'stopPrice': undefined, @@ -100946,7 +109152,7 @@ module.exports = class qtrade extends Exchange { } }; -},{"./base/Exchange":5,"./base/errors":7}],120:[function(require,module,exports){ +},{"./base/Exchange":6,"./base/errors":8}],123:[function(require,module,exports){ 'use strict'; const Exchange = require ('./base/Exchange'); @@ -101380,7 +109586,7 @@ module.exports = class rightbtc extends Exchange { async cancelOrder (id, symbol = undefined, params = {}) { if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' cancelOrder requires a symbol argument'); + throw new ArgumentsRequired (this.id + ' cancelOrder() requires a symbol argument'); } await this.loadMarkets (); const market = this.market (symbol); @@ -101490,6 +109696,7 @@ module.exports = class rightbtc extends Exchange { 'symbol': symbol, 'type': type, 'timeInForce': undefined, + 'postOnly': undefined, 'side': side, 'price': price, 'stopPrice': undefined, @@ -101506,7 +109713,7 @@ module.exports = class rightbtc extends Exchange { async fetchOrder (id, symbol = undefined, params = {}) { if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' fetchOrder requires a symbol argument'); + throw new ArgumentsRequired (this.id + ' fetchOrder() requires a symbol argument'); } await this.loadMarkets (); const market = this.market (symbol); @@ -101544,7 +109751,7 @@ module.exports = class rightbtc extends Exchange { async fetchOpenOrders (symbol = undefined, since = undefined, limit = undefined, params = {}) { if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' fetchOpenOrders requires a symbol argument'); + throw new ArgumentsRequired (this.id + ' fetchOpenOrders() requires a symbol argument'); } await this.loadMarkets (); const market = this.market (symbol); @@ -101581,7 +109788,7 @@ module.exports = class rightbtc extends Exchange { async fetchOrders (symbol = undefined, since = undefined, limit = undefined, params = {}) { let ids = this.safeString (params, 'ids'); if ((symbol === undefined) || (ids === undefined)) { - throw new ArgumentsRequired (this.id + " fetchOrders requires a 'symbol' argument and an extra 'ids' parameter. The 'ids' should be an array or a string of one or more order ids separated with slashes."); // eslint-disable-line quotes + throw new ArgumentsRequired (this.id + " fetchOrders() requires a 'symbol' argument and an extra 'ids' parameter. The 'ids' should be an array or a string of one or more order ids separated with slashes."); // eslint-disable-line quotes } if (Array.isArray (ids)) { ids = ids.join ('/'); @@ -101620,7 +109827,7 @@ module.exports = class rightbtc extends Exchange { async fetchMyTrades (symbol = undefined, since = undefined, limit = undefined, params = {}) { if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' fetchMyTrades requires a symbol argument'); + throw new ArgumentsRequired (this.id + ' fetchMyTrades() requires a symbol argument'); } await this.loadMarkets (); const market = this.market (symbol); @@ -101705,7 +109912,7 @@ module.exports = class rightbtc extends Exchange { } }; -},{"./base/Exchange":5,"./base/errors":7,"./base/functions/number":13}],121:[function(require,module,exports){ +},{"./base/Exchange":6,"./base/errors":8,"./base/functions/number":14}],124:[function(require,module,exports){ 'use strict'; // --------------------------------------------------------------------------- @@ -102538,6 +110745,7 @@ module.exports = class ripio extends Exchange { 'symbol': symbol, 'type': type, 'timeInForce': undefined, + 'postOnly': undefined, 'side': side, 'price': price, 'stopPrice': stopPrice, @@ -102652,7 +110860,7 @@ module.exports = class ripio extends Exchange { } }; -},{"./base/Exchange":5,"./base/errors":7,"./base/functions/number":13}],122:[function(require,module,exports){ +},{"./base/Exchange":6,"./base/errors":8,"./base/functions/number":14}],125:[function(require,module,exports){ 'use strict'; // --------------------------------------------------------------------------- @@ -102919,6 +111127,7 @@ module.exports = class southxchange extends Exchange { 'symbol': symbol, 'type': type, 'timeInForce': undefined, + 'postOnly': undefined, 'side': side, 'price': price, 'stopPrice': undefined, @@ -103351,7 +111560,7 @@ module.exports = class southxchange extends Exchange { } }; -},{"./base/Exchange":5,"./base/errors":7}],123:[function(require,module,exports){ +},{"./base/Exchange":6,"./base/errors":8}],126:[function(require,module,exports){ (function (module, exports) { 'use strict'; @@ -106879,7 +115088,7 @@ module.exports = class southxchange extends Exchange { }; })(typeof module === 'undefined' || module, this); -},{"buffer":185}],124:[function(require,module,exports){ +},{"buffer":188}],127:[function(require,module,exports){ ;(function (root, factory) { if (typeof exports === "object") { // CommonJS @@ -112868,7 +121077,7 @@ module.exports = class southxchange extends Exchange { return CryptoJS; })); -},{}],125:[function(require,module,exports){ +},{}],128:[function(require,module,exports){ 'use strict'; var elliptic = exports; @@ -112892,7 +121101,7 @@ elliptic.curves = require('./elliptic/curves'); elliptic.ec = require('./elliptic/ec'); elliptic.eddsa = require('./elliptic/eddsa'); -},{"./elliptic/curve":128,"./elliptic/curves":131,"./elliptic/ec":132,"./elliptic/eddsa":135,"./elliptic/utils":139}],126:[function(require,module,exports){ +},{"./elliptic/curve":131,"./elliptic/curves":134,"./elliptic/ec":135,"./elliptic/eddsa":138,"./elliptic/utils":142}],129:[function(require,module,exports){ 'use strict'; var BN = require('../../../../BN/bn'); @@ -113269,7 +121478,7 @@ BasePoint.prototype.dblp = function dblp(k) { return r; }; -},{"../../../../BN/bn":123,"../../elliptic":125}],127:[function(require,module,exports){ +},{"../../../../BN/bn":126,"../../elliptic":128}],130:[function(require,module,exports){ 'use strict'; var curve = require('../curve'); @@ -113704,7 +121913,7 @@ Point.prototype.eqXToP = function eqXToP(x) { Point.prototype.toP = Point.prototype.normalize; Point.prototype.mixedAdd = Point.prototype.add; -},{"../../../../BN/bn":123,"../../elliptic":125,"../curve":128}],128:[function(require,module,exports){ +},{"../../../../BN/bn":126,"../../elliptic":128,"../curve":131}],131:[function(require,module,exports){ 'use strict'; var curve = exports; @@ -113714,7 +121923,7 @@ curve.short = require('./short'); curve.mont = require('./mont'); curve.edwards = require('./edwards'); -},{"./base":126,"./edwards":127,"./mont":129,"./short":130}],129:[function(require,module,exports){ +},{"./base":129,"./edwards":130,"./mont":132,"./short":133}],132:[function(require,module,exports){ 'use strict'; var curve = require('../curve'); @@ -113896,7 +122105,7 @@ Point.prototype.getX = function getX() { return this.x.fromRed(); }; -},{"../../../../BN/bn":123,"../../elliptic":125,"../curve":128}],130:[function(require,module,exports){ +},{"../../../../BN/bn":126,"../../elliptic":128,"../curve":131}],133:[function(require,module,exports){ 'use strict'; var curve = require('../curve'); @@ -114836,7 +123045,7 @@ JPoint.prototype.isInfinity = function isInfinity() { return this.z.cmpn(0) === 0; }; -},{"../../../../BN/bn":123,"../../elliptic":125,"../curve":128}],131:[function(require,module,exports){ +},{"../../../../BN/bn":126,"../../elliptic":128,"../curve":131}],134:[function(require,module,exports){ 'use strict'; var curves = exports; @@ -115042,7 +123251,7 @@ defineCurve('secp256k1', { ] }); -},{"../elliptic":125,"./precomputed/secp256k1":138}],132:[function(require,module,exports){ +},{"../elliptic":128,"./precomputed/secp256k1":141}],135:[function(require,module,exports){ 'use strict'; var BN = require('../../../../BN/bn'); @@ -115284,7 +123493,7 @@ EC.prototype.getKeyRecoveryParam = function(e, signature, Q, enc) { throw new Error('Unable to find valid recovery factor'); }; -},{"../../../../BN/bn":123,"../../elliptic":125,"../../hmac-drbg/hmac-drbg":140,"./key":133,"./signature":134}],133:[function(require,module,exports){ +},{"../../../../BN/bn":126,"../../elliptic":128,"../../hmac-drbg/hmac-drbg":143,"./key":136,"./signature":137}],136:[function(require,module,exports){ 'use strict'; var BN = require('../../../../BN/bn'); @@ -115405,7 +123614,7 @@ KeyPair.prototype.inspect = function inspect() { ' pub: ' + (this.pub && this.pub.inspect()) + ' >'; }; -},{"../../../../BN/bn":123,"../../elliptic":125}],134:[function(require,module,exports){ +},{"../../../../BN/bn":126,"../../elliptic":128}],137:[function(require,module,exports){ 'use strict'; var BN = require('../../../../BN/bn'); @@ -115431,7 +123640,7 @@ function Signature(options, enc) { } module.exports = Signature; -},{"../../../../BN/bn":123,"../../elliptic":125}],135:[function(require,module,exports){ +},{"../../../../BN/bn":126,"../../elliptic":128}],138:[function(require,module,exports){ 'use strict'; var curves = require('../curves'); @@ -115578,7 +123787,7 @@ EDDSA.prototype.isPoint = function isPoint(val) { return val instanceof this.pointClass; }; -},{"../../../../../base/functions/encode":10,"../../../../BN/bn.js":123,"../../../../crypto-js/crypto-js":124,"../curves":131,"../utils":139,"./key":136,"./signature":137}],136:[function(require,module,exports){ +},{"../../../../../base/functions/encode":11,"../../../../BN/bn.js":126,"../../../../crypto-js/crypto-js":127,"../curves":134,"../utils":142,"./key":139,"./signature":140}],139:[function(require,module,exports){ 'use strict'; var utils = require('../utils'); @@ -115680,7 +123889,7 @@ KeyPair.prototype.getPublic = function getPublic(enc) { module.exports = KeyPair; -},{"../utils":139}],137:[function(require,module,exports){ +},{"../utils":142}],140:[function(require,module,exports){ 'use strict'; var BN = require('../../../../BN/bn'); @@ -115747,7 +123956,7 @@ Signature.prototype.toHex = function toHex() { module.exports = Signature; -},{"../../../../BN/bn":123,"../utils":139}],138:[function(require,module,exports){ +},{"../../../../BN/bn":126,"../utils":142}],141:[function(require,module,exports){ module.exports = { doubles: { step: 4, @@ -116529,7 +124738,7 @@ module.exports = { } }; -},{}],139:[function(require,module,exports){ +},{}],142:[function(require,module,exports){ 'use strict'; var utils = exports; @@ -116745,7 +124954,7 @@ utils.encode = function encode(arr, enc) { return arr; }; -},{"../../../BN/bn":123}],140:[function(require,module,exports){ +},{"../../../BN/bn":126}],143:[function(require,module,exports){ 'use strict'; var CryptoJS = require('../../../crypto-js/crypto-js'); @@ -116861,7 +125070,7 @@ HmacDRBG.prototype.generate = function generate(len, enc, add, addEnc) { return utils.wordArrayToBuffer(res); }; -},{"../../../../base/functions/encode":10,"../../../crypto-js/crypto-js":124,"../elliptic/utils":139}],141:[function(require,module,exports){ +},{"../../../../base/functions/encode":11,"../../../crypto-js/crypto-js":127,"../elliptic/utils":142}],144:[function(require,module,exports){ 'use strict'; var fetch = require('../node-fetch/index'); @@ -116902,7 +125111,7 @@ module.exports = function (context) { }; }; -},{"../node-fetch/index":142}],142:[function(require,module,exports){ +},{"../node-fetch/index":145}],145:[function(require,module,exports){ (function (global,Buffer){ 'use strict'; @@ -118470,7 +126679,7 @@ exports.Response = Response; exports.FetchError = FetchError; }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {},require("buffer").Buffer) -},{"buffer":185,"http":227,"https":190,"stream":226,"url":233,"zlib":184}],143:[function(require,module,exports){ +},{"buffer":188,"http":230,"https":193,"stream":229,"url":236,"zlib":187}],146:[function(require,module,exports){ (function (Buffer){ /*! * RSA library for Node.js @@ -118697,7 +126906,7 @@ module.exports = (function () { })(); }).call(this,require("buffer").Buffer) -},{"./formats/formats.js":150,"./libs/rsa.js":154,"./schemes/schemes.js":156,"./utils":157,"buffer":185}],144:[function(require,module,exports){ +},{"./formats/formats.js":153,"./libs/rsa.js":157,"./schemes/schemes.js":159,"./utils":160,"buffer":188}],147:[function(require,module,exports){ // Copyright 2011 Mark Cavage All rights reserved. @@ -118712,7 +126921,7 @@ module.exports = { }; -},{}],145:[function(require,module,exports){ +},{}],148:[function(require,module,exports){ // Copyright 2011 Mark Cavage All rights reserved. var errors = require('./errors'); @@ -118735,7 +126944,7 @@ for (var e in errors) { module.exports[e] = errors[e]; } -},{"./errors":144,"./reader":146,"./types":147}],146:[function(require,module,exports){ +},{"./errors":147,"./reader":149,"./types":150}],149:[function(require,module,exports){ (function (Buffer){ // Copyright 2011 Mark Cavage All rights reserved. @@ -119001,7 +127210,7 @@ Reader.prototype._readTag = function (tag) { module.exports = Reader; }).call(this,require("buffer").Buffer) -},{"./errors":144,"./types":147,"assert":180,"buffer":185}],147:[function(require,module,exports){ +},{"./errors":147,"./types":150,"assert":183,"buffer":188}],150:[function(require,module,exports){ // Copyright 2011 Mark Cavage All rights reserved. @@ -119039,7 +127248,7 @@ module.exports = { Context: 128 }; -},{}],148:[function(require,module,exports){ +},{}],151:[function(require,module,exports){ // Copyright 2011 Mark Cavage All rights reserved. // If you have no idea what ASN.1 or BER is, see this: @@ -119058,7 +127267,7 @@ module.exports = { BerReader: Ber.Reader, }; -},{"./ber/index":145}],149:[function(require,module,exports){ +},{"./ber/index":148}],152:[function(require,module,exports){ var _ = require('../utils')._; var utils = require('../utils'); @@ -119131,7 +127340,7 @@ module.exports = { } }; -},{"../utils":157}],150:[function(require,module,exports){ +},{"../utils":160}],153:[function(require,module,exports){ var _ = require('../utils')._; module.exports = { @@ -119164,7 +127373,7 @@ module.exports = { }, }; -},{"../utils":157,"./components":149,"./pkcs1":151,"./pkcs8":152}],151:[function(require,module,exports){ +},{"../utils":160,"./components":152,"./pkcs1":154,"./pkcs8":155}],154:[function(require,module,exports){ (function (Buffer){ var ber = require('../asn1/index').Ber; var _ = require('../utils')._; @@ -119316,7 +127525,7 @@ module.exports = { }; }).call(this,require("buffer").Buffer) -},{"../asn1/index":148,"../utils":157,"buffer":185}],152:[function(require,module,exports){ +},{"../asn1/index":151,"../utils":160,"buffer":188}],155:[function(require,module,exports){ (function (Buffer){ var ber = require('../asn1/index').Ber; var _ = require('../utils')._; @@ -119507,7 +127716,7 @@ module.exports = { }; }).call(this,require("buffer").Buffer) -},{"../asn1/index":148,"../utils":157,"buffer":185}],153:[function(require,module,exports){ +},{"../asn1/index":151,"../utils":160,"buffer":188}],156:[function(require,module,exports){ (function (Buffer){ /* * Basic JavaScript BN library - subset useful for RSA encryption. @@ -120763,7 +128972,7 @@ BigInteger.prototype.square = bnSquare; module.exports = BigInteger; }).call(this,require("buffer").Buffer) -},{"../utils":157,"buffer":185}],154:[function(require,module,exports){ +},{"../utils":160,"buffer":188}],157:[function(require,module,exports){ /* * RSA Encryption / Decryption with PKCS1 v2 Padding. * @@ -120912,7 +129121,7 @@ module.exports.Key = (function () { })(); -},{"../schemes/schemes.js":156,"../utils":157,"../utils.js":157,"./jsbn.js":153}],155:[function(require,module,exports){ +},{"../schemes/schemes.js":159,"../utils":160,"../utils.js":160,"./jsbn.js":156}],158:[function(require,module,exports){ (function (Buffer){ /** * PKCS1 padding and signature scheme @@ -121092,7 +129301,7 @@ function wordArrayToBuffer(wordArray) { } }).call(this,require("buffer").Buffer) -},{"../../crypto-js/crypto-js":124,"../libs/jsbn":153,"buffer":185,"constants":187}],156:[function(require,module,exports){ +},{"../../crypto-js/crypto-js":127,"../libs/jsbn":156,"buffer":188,"constants":190}],159:[function(require,module,exports){ module.exports = { pkcs1: require('./pkcs1'), @@ -121115,7 +129324,7 @@ module.exports = { } }; -},{"./pkcs1":155}],157:[function(require,module,exports){ +},{"./pkcs1":158}],160:[function(require,module,exports){ /* * Utils functions * @@ -121215,7 +129424,7 @@ module.exports.trimSurroundingText = function (data, opening, closing) { return data.substring(trimStartIndex, trimEndIndex); } -},{}],158:[function(require,module,exports){ +},{}],161:[function(require,module,exports){ 'use strict'; var replace = String.prototype.replace; @@ -121235,7 +129444,7 @@ module.exports = { RFC3986: 'RFC3986' }; -},{}],159:[function(require,module,exports){ +},{}],162:[function(require,module,exports){ 'use strict'; var stringify = require('./stringify'); @@ -121248,7 +129457,7 @@ module.exports = { stringify: stringify }; -},{"./formats":158,"./parse":160,"./stringify":161}],160:[function(require,module,exports){ +},{"./formats":161,"./parse":163,"./stringify":164}],163:[function(require,module,exports){ 'use strict'; var utils = require('./utils'); @@ -121492,7 +129701,7 @@ module.exports = function (str, opts) { return utils.compact(obj); }; -},{"./utils":162}],161:[function(require,module,exports){ +},{"./utils":165}],164:[function(require,module,exports){ 'use strict'; var utils = require('./utils'); @@ -121763,7 +129972,7 @@ module.exports = function (object, opts) { return joined.length > 0 ? prefix + joined : ''; }; -},{"./formats":158,"./utils":162}],162:[function(require,module,exports){ +},{"./formats":161,"./utils":165}],165:[function(require,module,exports){ 'use strict'; var has = Object.prototype.hasOwnProperty; @@ -121995,7 +130204,7 @@ module.exports = { merge: merge }; -},{}],163:[function(require,module,exports){ +},{}],166:[function(require,module,exports){ 'use strict'; // --------------------------------------------------------------------------- @@ -122183,6 +130392,8 @@ module.exports = class stex extends Exchange { 'BITS': 'Bitcoinus', 'BITSW': 'BITS', 'BHD': 'Bithold', + 'BTH': 'Bithereum', + 'SBTC': 'SBTCT', // SiamBitcoin }, 'options': { 'parseOrderToPrecision': false, @@ -122924,6 +131135,7 @@ module.exports = class stex extends Exchange { 'symbol': symbol, 'type': type, 'timeInForce': undefined, + 'postOnly': undefined, 'side': side, 'price': price, 'stopPrice': stopPrice, @@ -123220,7 +131432,7 @@ module.exports = class stex extends Exchange { async fetchMyTrades (symbol = undefined, since = undefined, limit = undefined, params = {}) { if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' fetchMyTrades requires a symbol argument'); + throw new ArgumentsRequired (this.id + ' fetchMyTrades() requires a symbol argument'); } await this.loadMarkets (); const market = this.market (symbol); @@ -123799,7 +132011,7 @@ module.exports = class stex extends Exchange { } }; -},{"./base/Exchange":5,"./base/errors":7}],164:[function(require,module,exports){ +},{"./base/Exchange":6,"./base/errors":8}],167:[function(require,module,exports){ 'use strict'; // --------------------------------------------------------------------------- @@ -123833,7 +132045,7 @@ module.exports = class surbitcoin extends foxbit { } }; -},{"./foxbit.js":84}],165:[function(require,module,exports){ +},{"./foxbit.js":87}],168:[function(require,module,exports){ 'use strict'; // --------------------------------------------------------------------------- @@ -124801,6 +133013,7 @@ module.exports = class therock extends Exchange { 'symbol': symbol, 'type': type, 'timeInForce': undefined, + 'postOnly': undefined, 'side': side, 'price': price, 'stopPrice': stopPrice, @@ -124830,7 +133043,7 @@ module.exports = class therock extends Exchange { async fetchOrders (symbol = undefined, since = undefined, limit = undefined, params = {}) { if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' fetchOrders requires a symbol argument'); + throw new ArgumentsRequired (this.id + ' fetchOrders() requires a symbol argument'); } await this.loadMarkets (); const market = this.market (symbol); @@ -124875,7 +133088,7 @@ module.exports = class therock extends Exchange { async fetchOrder (id, symbol = undefined, params = {}) { if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' fetchOrder requires a symbol argument'); + throw new ArgumentsRequired (this.id + ' fetchOrder() requires a symbol argument'); } await this.loadMarkets (); const market = this.market (symbol); @@ -124914,7 +133127,7 @@ module.exports = class therock extends Exchange { async fetchMyTrades (symbol = undefined, since = undefined, limit = undefined, params = {}) { if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' fetchMyTrades requires a symbol argument'); + throw new ArgumentsRequired (this.id + ' fetchMyTrades() requires a symbol argument'); } await this.loadMarkets (); const market = this.market (symbol); @@ -125066,7 +133279,7 @@ module.exports = class therock extends Exchange { } }; -},{"./base/Exchange":5,"./base/errors":7}],166:[function(require,module,exports){ +},{"./base/Exchange":6,"./base/errors":8}],169:[function(require,module,exports){ 'use strict'; // --------------------------------------------------------------------------- @@ -125491,6 +133704,7 @@ module.exports = class tidebit extends Exchange { 'symbol': symbol, 'type': type, 'timeInForce': undefined, + 'postOnly': undefined, 'side': side, 'price': price, 'stopPrice': undefined, @@ -125610,7 +133824,7 @@ module.exports = class tidebit extends Exchange { } }; -},{"./base/Exchange":5,"./base/errors":7}],167:[function(require,module,exports){ +},{"./base/Exchange":6,"./base/errors":8}],170:[function(require,module,exports){ 'use strict'; const Exchange = require ('./base/Exchange'); @@ -126193,6 +134407,7 @@ module.exports = class tidex extends Exchange { 'lastTradeTimestamp': undefined, 'type': 'limit', 'timeInForce': undefined, + 'postOnly': undefined, 'side': this.safeString (order, 'type'), 'price': price, 'stopPrice': undefined, @@ -126394,7 +134609,7 @@ module.exports = class tidex extends Exchange { } }; -},{"./base/Exchange":5,"./base/errors":7}],168:[function(require,module,exports){ +},{"./base/Exchange":6,"./base/errors":8}],171:[function(require,module,exports){ 'use strict'; const Exchange = require ('./base/Exchange'); @@ -126857,16 +135072,19 @@ module.exports = class timex extends Exchange { async createOrder (symbol, type, side, amount, price = undefined, params = {}) { await this.loadMarkets (); const market = this.market (symbol); + const uppercaseSide = side.toUpperCase (); + const uppercaseType = type.toUpperCase (); const request = { 'symbol': market['id'], 'quantity': this.amountToPrecision (symbol, amount), - 'side': side.toUpperCase (), + 'side': uppercaseSide, + 'orderTypes': uppercaseType, // 'clientOrderId': '123', // 'expireIn': 1575523308, // in seconds // 'expireTime': 1575523308, // unix timestamp }; let query = params; - if (type === 'limit') { + if (uppercaseType === 'LIMIT') { request['price'] = this.priceToPrecision (symbol, price); const defaultExpireIn = this.safeInteger (this.options, 'expireIn'); const expireTime = this.safeValue (params, 'expireTime'); @@ -126876,7 +135094,7 @@ module.exports = class timex extends Exchange { } else if (expireIn !== undefined) { request['expireIn'] = expireIn; } else { - throw new InvalidOrder (this.id + ' createOrder method requires a expireTime or expireIn param for a ' + type + ' order, you can also set the expireIn exchange-wide option'); + throw new InvalidOrder (this.id + ' createOrder() method requires a expireTime or expireIn param for a ' + type + ' order, you can also set the expireIn exchange-wide option'); } query = this.omit (params, [ 'expireTime', 'expireIn' ]); } else { @@ -127579,6 +135797,7 @@ module.exports = class timex extends Exchange { 'symbol': symbol, 'type': type, 'timeInForce': undefined, + 'postOnly': undefined, 'side': side, 'price': price, 'stopPrice': undefined, @@ -127631,7 +135850,7 @@ module.exports = class timex extends Exchange { } }; -},{"./base/Exchange":5,"./base/errors":7}],169:[function(require,module,exports){ +},{"./base/Exchange":6,"./base/errors":8}],172:[function(require,module,exports){ 'use strict'; // --------------------------------------------------------------------------- @@ -127649,7 +135868,6 @@ module.exports = class upbit extends Exchange { 'countries': [ 'KR' ], 'version': 'v1', 'rateLimit': 1000, - 'certified': true, 'pro': true, // new metainfo interface 'has': { @@ -127855,7 +136073,7 @@ module.exports = class upbit extends Exchange { const walletLocked = this.safeValue (memberInfo, 'wallet_locked'); const locked = this.safeValue (memberInfo, 'locked'); let active = true; - if ((canWithdraw !== undefined) && canWithdraw) { + if ((canWithdraw !== undefined) && !canWithdraw) { active = false; } else if (walletState !== 'working') { active = false; @@ -128838,6 +137056,7 @@ module.exports = class upbit extends Exchange { 'symbol': market['symbol'], 'type': type, 'timeInForce': undefined, + 'postOnly': undefined, 'side': side, 'price': price, 'stopPrice': undefined, @@ -129162,7 +137381,7 @@ module.exports = class upbit extends Exchange { } }; -},{"./base/Exchange":5,"./base/errors":7}],170:[function(require,module,exports){ +},{"./base/Exchange":6,"./base/errors":8}],173:[function(require,module,exports){ 'use strict'; // --------------------------------------------------------------------------- @@ -129367,7 +137586,7 @@ module.exports = class vaultoro extends Exchange { } }; -},{"./base/Exchange":5}],171:[function(require,module,exports){ +},{"./base/Exchange":6}],174:[function(require,module,exports){ 'use strict'; // --------------------------------------------------------------------------- @@ -129401,7 +137620,7 @@ module.exports = class vbtc extends foxbit { } }; -},{"./foxbit.js":84}],172:[function(require,module,exports){ +},{"./foxbit.js":87}],175:[function(require,module,exports){ 'use strict'; // --------------------------------------------------------------------------- @@ -130460,6 +138679,7 @@ module.exports = class vcc extends Exchange { 'symbol': symbol, 'type': type, 'timeInForce': undefined, + 'postOnly': undefined, 'side': side, 'price': price, 'stopPrice': stopPrice, @@ -130741,7 +138961,7 @@ module.exports = class vcc extends Exchange { } }; -},{"./base/Exchange":5,"./base/errors":7,"./base/functions/number":13}],173:[function(require,module,exports){ +},{"./base/Exchange":6,"./base/errors":8,"./base/functions/number":14}],176:[function(require,module,exports){ 'use strict'; // --------------------------------------------------------------------------- @@ -131800,7 +140020,7 @@ module.exports = class wavesexchange extends Exchange { this.checkRequiredDependencies (); this.checkRequiredKeys (); if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' fetchOrders requires symbol argument'); + throw new ArgumentsRequired (this.id + ' fetchOrders() requires symbol argument'); } await this.loadMarkets (); const market = this.market (symbol); @@ -132013,6 +140233,7 @@ module.exports = class wavesexchange extends Exchange { 'symbol': symbol, 'type': type, 'timeInForce': undefined, + 'postOnly': undefined, 'side': side, 'price': price, 'stopPrice': undefined, @@ -132409,7 +140630,7 @@ module.exports = class wavesexchange extends Exchange { } }; -},{"./base/Exchange":5,"./base/errors":7}],174:[function(require,module,exports){ +},{"./base/Exchange":6,"./base/errors":8}],177:[function(require,module,exports){ 'use strict'; // --------------------------------------------------------------------------- @@ -133064,7 +141285,7 @@ module.exports = class whitebit extends Exchange { } }; -},{"./base/Exchange":5,"./base/errors":7}],175:[function(require,module,exports){ +},{"./base/Exchange":6,"./base/errors":8}],178:[function(require,module,exports){ 'use strict'; // --------------------------------------------------------------------------- @@ -133436,7 +141657,7 @@ module.exports = class xbtce extends Exchange { } }; -},{"./base/Exchange":5,"./base/errors":7}],176:[function(require,module,exports){ +},{"./base/Exchange":6,"./base/errors":8}],179:[function(require,module,exports){ 'use strict'; const Exchange = require ('./base/Exchange'); @@ -133477,6 +141698,10 @@ module.exports = class xena extends Exchange { }, 'urls': { 'logo': 'https://user-images.githubusercontent.com/51840849/87489843-bb469280-c64c-11ea-91aa-69c6326506af.jpg', + 'test': { + 'public': 'https://trading.demo.xena.io/api', + 'private': 'https://api.demo.xena.io', + }, 'api': { 'public': 'https://trading.xena.exchange/api', 'private': 'https://api.xena.exchange', @@ -134397,6 +142622,7 @@ module.exports = class xena extends Exchange { 'symbol': symbol, 'type': type, 'timeInForce': undefined, + 'postOnly': undefined, 'side': side, 'price': price, 'stopPrice': undefined, @@ -134456,14 +142682,14 @@ module.exports = class xena extends Exchange { }; if ((type === 'limit') || (type === 'stop-limit')) { if (price === undefined) { - throw new InvalidOrder (this.id + ' createOrder requires a price argument for order type ' + type); + throw new InvalidOrder (this.id + ' createOrder() requires a price argument for order type ' + type); } request['price'] = this.priceToPrecision (symbol, price); } if ((type === 'stop') || (type === 'stop-limit')) { const stopPx = this.safeFloat (params, 'stopPx'); if (stopPx === undefined) { - throw new InvalidOrder (this.id + ' createOrder requires a stopPx param for order type ' + type); + throw new InvalidOrder (this.id + ' createOrder() requires a stopPx param for order type ' + type); } request['stopPx'] = this.priceToPrecision (symbol, stopPx); params = this.omit (params, 'stopPx'); @@ -134501,7 +142727,7 @@ module.exports = class xena extends Exchange { async editOrder (id, symbol, type, side, amount = undefined, price = undefined, params = {}) { if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' cancelOrder requires a symbol argument'); + throw new ArgumentsRequired (this.id + ' cancelOrder() requires a symbol argument'); } await this.loadMarkets (); await this.loadAccounts (); @@ -134556,7 +142782,7 @@ module.exports = class xena extends Exchange { async cancelOrder (id, symbol = undefined, params = {}) { if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' cancelOrder requires a symbol argument'); + throw new ArgumentsRequired (this.id + ' cancelOrder() requires a symbol argument'); } await this.loadMarkets (); await this.loadAccounts (); @@ -135153,7 +143379,7 @@ module.exports = class xena extends Exchange { } }; -},{"./base/Exchange":5,"./base/errors":7}],177:[function(require,module,exports){ +},{"./base/Exchange":6,"./base/errors":8}],180:[function(require,module,exports){ 'use strict'; // --------------------------------------------------------------------------- @@ -135289,6 +143515,7 @@ module.exports = class yobit extends Exchange { 'LOCX': 'LOC', 'LUNYR': 'LUN', 'LUN': 'LunarCoin', // they just change the ticker if it is already taken + 'MASK': 'Yobit MASK', 'MDT': 'Midnight', 'NAV': 'NavajoCoin', 'NBT': 'NiceBytes', @@ -135305,6 +143532,7 @@ module.exports = class yobit extends Exchange { 'RCN': 'RCoin', 'REP': 'Republicoin', 'RUR': 'RUB', + 'SBTC': 'Super Bitcoin', 'TTC': 'TittieCoin', 'UNI': 'Universe', 'UST': 'Uservice', @@ -135751,6 +143979,7 @@ module.exports = class yobit extends Exchange { 'lastTradeTimestamp': undefined, 'type': type, 'timeInForce': undefined, + 'postOnly': undefined, 'side': side, 'price': price, 'stopPrice': undefined, @@ -135795,7 +144024,7 @@ module.exports = class yobit extends Exchange { async fetchMyTrades (symbol = undefined, since = undefined, limit = undefined, params = {}) { if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' fetchMyTrades requires a `symbol` argument'); + throw new ArgumentsRequired (this.id + ' fetchMyTrades() requires a `symbol` argument'); } await this.loadMarkets (); const market = this.market (symbol); @@ -135883,24 +144112,6 @@ module.exports = class yobit extends Exchange { }; } - calculateFee (symbol, type, side, amount, price, takerOrMaker = 'taker', params = {}) { - const market = this.markets[symbol]; - let key = 'quote'; - const rate = market[takerOrMaker]; - let cost = parseFloat (this.costToPrecision (symbol, amount * rate)); - if (side === 'sell') { - cost *= price; - } else { - key = 'base'; - } - return { - 'type': takerOrMaker, - 'currency': market[key], - 'rate': rate, - 'cost': cost, - }; - } - sign (path, api = 'public', method = 'GET', params = {}, headers = undefined, body = undefined) { let url = this.urls['api'][api]; const query = this.omit (params, this.extractParams (path)); @@ -135992,7 +144203,7 @@ module.exports = class yobit extends Exchange { } }; -},{"./base/Exchange":5,"./base/errors":7}],178:[function(require,module,exports){ +},{"./base/Exchange":6,"./base/errors":8}],181:[function(require,module,exports){ 'use strict'; // --------------------------------------------------------------------------- @@ -136352,6 +144563,7 @@ module.exports = class zaif extends Exchange { 'symbol': symbol, 'type': 'limit', 'timeInForce': undefined, + 'postOnly': undefined, 'side': side, 'price': price, 'stopPrice': undefined, @@ -136482,13 +144694,13 @@ module.exports = class zaif extends Exchange { } }; -},{"./base/Exchange":5,"./base/errors":7}],179:[function(require,module,exports){ +},{"./base/Exchange":6,"./base/errors":8}],182:[function(require,module,exports){ 'use strict'; // --------------------------------------------------------------------------- const Exchange = require ('./base/Exchange'); -const { BadRequest, ExchangeError, ArgumentsRequired, AuthenticationError, InsufficientFunds, OrderNotFound, ExchangeNotAvailable, DDoSProtection, InvalidOrder } = require ('./base/errors'); +const { BadRequest, ExchangeError, ArgumentsRequired, AuthenticationError, InsufficientFunds, OrderNotFound, ExchangeNotAvailable, DDoSProtection, InvalidOrder, InvalidAddress } = require ('./base/errors'); // --------------------------------------------------------------------------- @@ -136507,15 +144719,19 @@ module.exports = class zb extends Exchange { 'createOrder': true, 'fetchBalance': true, 'fetchDepositAddress': true, + 'fetchDepositAddresses': true, + 'fetchDeposits': true, 'fetchMarkets': true, 'fetchOHLCV': true, 'fetchOpenOrders': true, 'fetchOrder': true, 'fetchOrderBook': true, 'fetchOrders': true, + 'fetchClosedOrders': true, 'fetchTicker': true, 'fetchTickers': true, 'fetchTrades': true, + 'fetchWithdrawals': true, 'withdraw': true, }, 'timeframes': { @@ -136534,33 +144750,38 @@ module.exports = class zb extends Exchange { '1w': '1week', }, 'exceptions': { - // '1000': 'Successful operation', - '1001': ExchangeError, // 'General error message', - '1002': ExchangeError, // 'Internal error', - '1003': AuthenticationError, // 'Verification does not pass', - '1004': AuthenticationError, // 'Funding security password lock', - '1005': AuthenticationError, // 'Funds security password is incorrect, please confirm and re-enter.', - '1006': AuthenticationError, // 'Real-name certification pending approval or audit does not pass', - '1009': ExchangeNotAvailable, // 'This interface is under maintenance', - '2001': InsufficientFunds, // 'Insufficient CNY Balance', - '2002': InsufficientFunds, // 'Insufficient BTC Balance', - '2003': InsufficientFunds, // 'Insufficient LTC Balance', - '2005': InsufficientFunds, // 'Insufficient ETH Balance', - '2006': InsufficientFunds, // 'Insufficient ETC Balance', - '2007': InsufficientFunds, // 'Insufficient BTS Balance', - '2009': InsufficientFunds, // 'Account balance is not enough', - '3001': OrderNotFound, // 'Pending orders not found', - '3002': InvalidOrder, // 'Invalid price', - '3003': InvalidOrder, // 'Invalid amount', - '3004': AuthenticationError, // 'User does not exist', - '3005': BadRequest, // 'Invalid parameter', - '3006': AuthenticationError, // 'Invalid IP or inconsistent with the bound IP', - '3007': AuthenticationError, // 'The request time has expired', - '3008': OrderNotFound, // 'Transaction records not found', - '3009': InvalidOrder, // 'The price exceeds the limit', - '3011': InvalidOrder, // 'The entrusted price is abnormal, please modify it and place order again', - '4001': ExchangeNotAvailable, // 'API interface is locked or not enabled', - '4002': DDoSProtection, // 'Request too often', + 'exact': { + // '1000': 'Successful operation', + '1001': ExchangeError, // 'General error message', + '1002': ExchangeError, // 'Internal error', + '1003': AuthenticationError, // 'Verification does not pass', + '1004': AuthenticationError, // 'Funding security password lock', + '1005': AuthenticationError, // 'Funds security password is incorrect, please confirm and re-enter.', + '1006': AuthenticationError, // 'Real-name certification pending approval or audit does not pass', + '1009': ExchangeNotAvailable, // 'This interface is under maintenance', + '2001': InsufficientFunds, // 'Insufficient CNY Balance', + '2002': InsufficientFunds, // 'Insufficient BTC Balance', + '2003': InsufficientFunds, // 'Insufficient LTC Balance', + '2005': InsufficientFunds, // 'Insufficient ETH Balance', + '2006': InsufficientFunds, // 'Insufficient ETC Balance', + '2007': InsufficientFunds, // 'Insufficient BTS Balance', + '2009': InsufficientFunds, // 'Account balance is not enough', + '3001': OrderNotFound, // 'Pending orders not found', + '3002': InvalidOrder, // 'Invalid price', + '3003': InvalidOrder, // 'Invalid amount', + '3004': AuthenticationError, // 'User does not exist', + '3005': BadRequest, // 'Invalid parameter', + '3006': AuthenticationError, // 'Invalid IP or inconsistent with the bound IP', + '3007': AuthenticationError, // 'The request time has expired', + '3008': OrderNotFound, // 'Transaction records not found', + '3009': InvalidOrder, // 'The price exceeds the limit', + '3011': InvalidOrder, // 'The entrusted price is abnormal, please modify it and place order again', + '4001': ExchangeNotAvailable, // 'API interface is locked or not enabled', + '4002': DDoSProtection, // 'Request too often', + }, + 'broad': { + '提币地址有误,请先添加提币地址。': InvalidAddress, // {"code":1001,"message":"提币地址有误,请先添加提币地址。"} + }, }, 'urls': { 'logo': 'https://user-images.githubusercontent.com/1294454/32859187-cd5214f0-ca5e-11e7-967d-96568e2e2bd1.jpg', @@ -136587,20 +144808,28 @@ module.exports = class zb extends Exchange { 'get': [ // spot API 'order', + 'orderMoreV2', 'cancelOrder', 'getOrder', 'getOrders', 'getOrdersNew', 'getOrdersIgnoreTradeType', 'getUnfinishedOrdersIgnoreTradeType', + 'getFinishedAndPartialOrders', 'getAccountInfo', 'getUserAddress', + 'getPayinAddress', 'getWithdrawAddress', 'getWithdrawRecord', 'getChargeRecord', 'getCnyWithdrawRecord', 'getCnyChargeRecord', 'withdraw', + // sub accounts + 'addSubUser', + 'getSubUserList', + 'doTransferFunds', + 'createSubUserKey', // leverage API 'getLeverAssetsInfo', 'getLeverBills', @@ -136611,8 +144840,21 @@ module.exports = class zb extends Exchange { 'getLoans', 'getLoanRecords', 'borrow', + 'autoBorrow', 'repay', + 'doAllRepay', 'getRepayments', + 'getFinanceRecords', + 'changeInvestMark', + 'changeLoop', + // cross API + 'getCrossAssets', + 'getCrossBills', + 'transferInCross', + 'transferOutCross', + 'doCrossLoan', + 'doCrossRepay', + 'getCrossRepayRecords', ], }, }, @@ -136730,8 +144972,96 @@ module.exports = class zb extends Exchange { return this.parseBalance (result); } - getMarketFieldName () { - return 'market'; + parseDepositAddress (depositAddress, currency = undefined) { + // + // fetchDepositAddress + // + // { + // "key": "0x0af7f36b8f09410f3df62c81e5846da673d4d9a9" + // } + // + // fetchDepositAddresses + // + // { + // "blockChain": "btc", + // "isUseMemo": false, + // "address": "1LL5ati6pXHZnTGzHSA3rWdqi4mGGXudwM", + // "canWithdraw": true, + // "canDeposit": true + // } + // { + // "blockChain": "bts", + // "isUseMemo": true, + // "account": "btstest", + // "memo": "123", + // "canWithdraw": true, + // "canDeposit": true + // } + // + let address = this.safeString (depositAddress, 'key'); + let tag = undefined; + const memo = this.safeString (depositAddress, 'memo'); + if (memo !== undefined) { + tag = memo; + } else if (address.indexOf ('_') >= 0) { + const parts = address.split ('_'); + address = parts[0]; // WARNING: MAY BE tag_address INSTEAD OF address_tag FOR SOME CURRENCIES!! + tag = parts[1]; + } + const currencyId = this.safeString (depositAddress, 'blockChain'); + const code = this.safeCurrencyCode (currencyId, currency); + return { + 'currency': code, + 'address': address, + 'tag': tag, + 'info': depositAddress, + }; + } + + parseDepositAddresses (addresses, codes = undefined) { + let result = []; + for (let i = 0; i < addresses.length; i++) { + const address = this.parseDepositAddress (addresses[i]); + result.push (address); + } + if (codes) { + result = this.filterByArray (result, 'currency', codes); + } + return this.indexBy (result, 'currency'); + } + + async fetchDepositAddresses (codes = undefined, params = {}) { + await this.loadMarkets (); + const response = await this.privateGetGetPayinAddress (params); + // + // { + // "code": 1000, + // "message": { + // "des": "success", + // "isSuc": true, + // "datas": [ + // { + // "blockChain": "btc", + // "isUseMemo": false, + // "address": "1LL5ati6pXHZnTGzHSA3rWdqi4mGGXudwM", + // "canWithdraw": true, + // "canDeposit": true + // }, + // { + // "blockChain": "bts", + // "isUseMemo": true, + // "account": "btstest", + // "memo": "123", + // "canWithdraw": true, + // "canDeposit": true + // }, + // ] + // } + // } + // + const message = this.safeValue (response, 'message', {}); + const datas = this.safeValue (message, 'datas', []); + return this.parseDepositAddresses (datas, codes); } async fetchDepositAddress (code, params = {}) { @@ -136741,27 +145071,29 @@ module.exports = class zb extends Exchange { 'currency': currency['id'], }; const response = await this.privateGetGetUserAddress (this.extend (request, params)); - let address = response['message']['datas']['key']; - let tag = undefined; - if (address.indexOf ('_') >= 0) { - const parts = address.split ('_'); - address = parts[0]; // WARNING: MAY BE tag_address INSTEAD OF address_tag FOR SOME CURRENCIES!! - tag = parts[1]; - } - return { - 'currency': code, - 'address': address, - 'tag': tag, - 'info': response, - }; + // + // { + // "code": 1000, + // "message": { + // "des": "success", + // "isSuc": true, + // "datas": { + // "key": "0x0af7f36b8f09410f3df62c81e5846da673d4d9a9" + // } + // } + // } + // + const message = this.safeValue (response, 'message', {}); + const datas = this.safeValue (message, 'datas', {}); + return this.parseDepositAddress (datas, currency); } async fetchOrderBook (symbol, limit = undefined, params = {}) { await this.loadMarkets (); const market = this.market (symbol); - const marketFieldName = this.getMarketFieldName (); - const request = {}; - request[marketFieldName] = market['id']; + const request = { + 'market': market['id'], + }; if (limit !== undefined) { request['size'] = limit; } @@ -136790,9 +145122,9 @@ module.exports = class zb extends Exchange { async fetchTicker (symbol, params = {}) { await this.loadMarkets (); const market = this.market (symbol); - const marketFieldName = this.getMarketFieldName (); - const request = {}; - request[marketFieldName] = market['id']; + const request = { + 'market': market['id'], + }; const response = await this.publicGetTicker (this.extend (request, params)); const ticker = response['ticker']; return this.parseTicker (ticker, market); @@ -136885,9 +145217,9 @@ module.exports = class zb extends Exchange { async fetchTrades (symbol, since = undefined, limit = undefined, params = {}) { await this.loadMarkets (); const market = this.market (symbol); - const marketFieldName = this.getMarketFieldName (); - const request = {}; - request[marketFieldName] = market['id']; + const request = { + 'market': market['id'], + }; const response = await this.publicGetTrades (this.extend (request, params)); return this.parseTrades (response, market, since, limit); } @@ -136947,7 +145279,7 @@ module.exports = class zb extends Exchange { async fetchOrders (symbol = undefined, since = undefined, limit = 50, params = {}) { if (symbol === undefined) { - throw new ArgumentsRequired (this.id + 'fetchOrders requires a symbol argument'); + throw new ArgumentsRequired (this.id + 'fetchOrders() requires a symbol argument'); } await this.loadMarkets (); const market = this.market (symbol); @@ -136973,9 +145305,24 @@ module.exports = class zb extends Exchange { return this.parseOrders (response, market, since, limit); } + async fetchClosedOrders (symbol = undefined, since = undefined, limit = undefined, params = {}) { + if (symbol === undefined) { + throw new ArgumentsRequired (this.id + 'fetchClosedOrders() requires a symbol argument'); + } + await this.loadMarkets (); + const market = this.market (symbol); + const request = { + 'currency': market['id'], + 'pageIndex': 1, // default pageIndex is 1 + 'pageSize': 10, // default pageSize is 10, doesn't work with other values now + }; + const response = await this.privateGetGetFinishedAndPartialOrders (this.extend (request, params)); + return this.parseOrders (response, market, since, limit); + } + async fetchOpenOrders (symbol = undefined, since = undefined, limit = 10, params = {}) { if (symbol === undefined) { - throw new ArgumentsRequired (this.id + 'fetchOpenOrders requires a symbol argument'); + throw new ArgumentsRequired (this.id + 'fetchOpenOrders() requires a symbol argument'); } await this.loadMarkets (); const market = this.market (symbol); @@ -137002,29 +145349,26 @@ module.exports = class zb extends Exchange { } parseOrder (order, market = undefined) { - // - // fetchOrder // // { - // 'total_amount': 0.01, - // 'id': '20180910244276459', - // 'price': 180.0, - // 'trade_date': 1536576744960, - // 'status': 2, - // 'trade_money': '1.96742', - // 'trade_amount': 0.01, - // 'type': 0, - // 'currency': 'eth_usdt' - // } + // acctType: 0, + // currency: 'btc_usdt', + // fees: 3.6e-7, + // id: '202102282829772463', + // price: 45177.5, + // status: 2, + // total_amount: 0.0002, + // trade_amount: 0.0002, + // trade_date: 1614515104998, + // trade_money: 8.983712, + // type: 1, + // useZbFee: false + // }, // let side = this.safeInteger (order, 'type'); side = (side === 1) ? 'buy' : 'sell'; const type = 'limit'; // market order is not availalbe in ZB - let timestamp = undefined; - const createDateField = this.getCreateDateField (); - if (createDateField in order) { - timestamp = order[createDateField]; - } + const timestamp = this.safeInteger (order, 'trade_date'); const marketId = this.safeString (order, 'currency'); const symbol = this.safeSymbol (marketId, market, '_'); const price = this.safeFloat (order, 'price'); @@ -137043,6 +145387,21 @@ module.exports = class zb extends Exchange { average = cost / filled; } const id = this.safeString (order, 'id'); + const feeCost = this.safeFloat (order, 'fees'); + let fee = undefined; + if (feeCost !== undefined) { + let feeCurrency = undefined; + const zbFees = this.safeValue (order, 'useZbFee'); + if (zbFees === true) { + feeCurrency = 'ZB'; + } else if (market !== undefined) { + feeCurrency = (side === 'sell') ? market['quote'] : market['base']; + } + fee = { + 'cost': feeCost, + 'currency': feeCurrency, + }; + } return { 'info': order, 'id': id, @@ -137053,6 +145412,7 @@ module.exports = class zb extends Exchange { 'symbol': symbol, 'type': type, 'timeInForce': undefined, + 'postOnly': undefined, 'side': side, 'price': price, 'stopPrice': undefined, @@ -137062,7 +145422,7 @@ module.exports = class zb extends Exchange { 'filled': filled, 'remaining': remaining, 'status': status, - 'fee': undefined, + 'fee': fee, 'trades': undefined, }; } @@ -137077,8 +145437,241 @@ module.exports = class zb extends Exchange { return this.safeString (statuses, status, status); } - getCreateDateField () { - return 'trade_date'; + parseTransactionStatus (status) { + const statuses = { + '0': 'pending', // submitted, pending confirmation + '1': 'failed', + '2': 'ok', + '3': 'canceled', + '5': 'ok', // confirmed + }; + return this.safeString (statuses, status, status); + } + + parseTransaction (transaction, currency = undefined) { + // + // withdraw + // + // { + // "code": 1000, + // "message": "success", + // "id": "withdrawalId" + // } + // + // fetchWithdrawals + // + // { + // "amount": 0.01, + // "fees": 0.001, + // "id": 2016042556231, + // "manageTime": 1461579340000, + // "status": 3, + // "submitTime": 1461579288000, + // "toAddress": "14fxEPirL9fyfw1i9EF439Pq6gQ5xijUmp", + // } + // + // fetchDeposits + // + // { + // "address": "1FKN1DZqCm8HaTujDioRL2Aezdh7Qj7xxx", + // "amount": "1.00000000", + // "confirmTimes": 1, + // "currency": "BTC", + // "description": "Successfully Confirm", + // "hash": "7ce842de187c379abafadd64a5fe66c5c61c8a21fb04edff9532234a1dae6xxx", + // "id": 558, + // "itransfer": 1, + // "status": 2, + // "submit_time": "2016-12-07 18:51:57", + // } + // + const id = this.safeString (transaction, 'id'); + const txid = this.safeString (transaction, 'hash'); + const amount = this.safeFloat (transaction, 'amount'); + let timestamp = this.parse8601 (this.safeString (transaction, 'submit_time')); + timestamp = this.safeInteger (transaction, 'submitTime', timestamp); + let address = this.safeString2 (transaction, 'toAddress', 'address'); + let tag = undefined; + if (address !== undefined) { + const parts = address.split ('_'); + address = this.safeString (parts, 0); + tag = this.safeString (parts, 1); + } + const confirmTimes = this.safeInteger (transaction, 'confirmTimes'); + const updated = this.safeInteger (transaction, 'manageTime'); + let type = undefined; + const currencyId = this.safeString (transaction, 'currency'); + const code = this.safeCurrencyCode (currencyId, currency); + if (address !== undefined) { + type = (confirmTimes === undefined) ? 'withdrawal' : 'deposit'; + } + const status = this.parseTransactionStatus (this.safeString (transaction, 'status')); + let fee = undefined; + const feeCost = this.safeFloat (transaction, 'fees'); + if (feeCost !== undefined) { + fee = { + 'cost': feeCost, + 'currency': code, + }; + } + return { + 'info': transaction, + 'id': id, + 'txid': txid, + 'timestamp': timestamp, + 'datetime': this.iso8601 (timestamp), + 'addressFrom': undefined, + 'address': address, + 'addressTo': address, + 'tagFrom': undefined, + 'tag': tag, + 'tagTo': tag, + 'type': type, + 'amount': amount, + 'currency': code, + 'status': status, + 'updated': updated, + 'fee': fee, + }; + } + + async withdraw (code, amount, address, tag = undefined, params = {}) { + const password = this.safeString (params, 'safePwd', this.password); + if (password === undefined) { + throw new ArgumentsRequired (this.id + ' withdraw() requires exchange.password or a safePwd parameter'); + } + const fees = this.safeFloat (params, 'fees'); + if (fees === undefined) { + throw new ArgumentsRequired (this.id + ' withdraw() requires a fees parameter'); + } + this.checkAddress (address); + await this.loadMarkets (); + const currency = this.currency (code); + if (tag !== undefined) { + address += '_' + tag; + } + const request = { + 'amount': this.currencyToPrecision (code, amount), + 'currency': currency['id'], + 'fees': this.currencyToPrecision (code, fees), + // 'itransfer': 0, // agree for an internal transfer, 0 disagree, 1 agree, the default is to disagree + 'method': 'withdraw', + 'receiveAddr': address, + 'safePwd': password, + }; + const response = await this.privateGetWithdraw (this.extend (request, params)); + // + // { + // "code": 1000, + // "message": "success", + // "id": "withdrawalId" + // } + // + const transaction = this.parseTransaction (response, currency); + return this.extend (transaction, { + 'type': 'withdrawal', + 'address': address, + 'addressTo': address, + 'amount': amount, + }); + } + + async fetchWithdrawals (code = undefined, since = undefined, limit = undefined, params = {}) { + await this.loadMarkets (); + const request = { + // 'currency': currency['id'], + // 'pageIndex': 1, + // 'pageSize': limit, + }; + let currency = undefined; + if (code !== undefined) { + currency = this.currency (code); + request['currency'] = currency['id']; + } + if (limit !== undefined) { + request['pageSize'] = limit; + } + const response = await this.privateGetGetWithdrawRecord (this.extend (request, params)); + // + // { + // "code": 1000, + // "message": { + // "des": "success", + // "isSuc": true, + // "datas": { + // "list": [ + // { + // "amount": 0.01, + // "fees": 0.001, + // "id": 2016042556231, + // "manageTime": 1461579340000, + // "status": 3, + // "submitTime": 1461579288000, + // "toAddress": "14fxEPirL9fyfw1i9EF439Pq6gQ5xijUmp", + // }, + // ], + // "pageIndex": 1, + // "pageSize": 10, + // "totalCount": 4, + // "totalPage": 1 + // } + // } + // } + // + const message = this.safeValue (response, 'message', {}); + const datas = this.safeValue (message, 'datas', {}); + const withdrawals = this.safeValue (datas, 'list', []); + return this.parseTransactions (withdrawals, currency, since, limit); + } + + async fetchDeposits (code = undefined, since = undefined, limit = undefined, params = {}) { + await this.loadMarkets (); + const request = { + // 'currency': currency['id'], + // 'pageIndex': 1, + // 'pageSize': limit, + }; + let currency = undefined; + if (code !== undefined) { + currency = this.currency (code); + request['currency'] = currency['id']; + } + if (limit !== undefined) { + request['pageSize'] = limit; + } + const response = await this.privateGetGetChargeRecord (this.extend (request, params)); + // + // { + // "code": 1000, + // "message": { + // "des": "success", + // "isSuc": true, + // "datas": { + // "list": [ + // { + // "address": "1FKN1DZqCm8HaTujDioRL2Aezdh7Qj7xxx", + // "amount": "1.00000000", + // "confirmTimes": 1, + // "currency": "BTC", + // "description": "Successfully Confirm", + // "hash": "7ce842de187c379abafadd64a5fe66c5c61c8a21fb04edff9532234a1dae6xxx", + // "id": 558, + // "itransfer": 1, + // "status": 2, + // "submit_time": "2016-12-07 18:51:57", + // }, + // ], + // "pageIndex": 1, + // "pageSize": 10, + // "total": 8 + // } + // } + // } + // + const message = this.safeValue (response, 'message', {}); + const datas = this.safeValue (message, 'datas', {}); + const deposits = this.safeValue (datas, 'list', []); + return this.parseTransactions (deposits, currency, since, limit); } nonce () { @@ -137114,9 +145707,10 @@ module.exports = class zb extends Exchange { } if (body[0] === '{') { const feedback = this.id + ' ' + body; + this.throwBroadlyMatchedException (this.exceptions['broad'], body, feedback); if ('code' in response) { const code = this.safeString (response, 'code'); - this.throwExactlyMatchedException (this.exceptions, code, feedback); + this.throwExactlyMatchedException (this.exceptions['exact'], code, feedback); if (code !== '1000') { throw new ExchangeError (feedback); } @@ -137137,7 +145731,7 @@ module.exports = class zb extends Exchange { } }; -},{"./base/Exchange":5,"./base/errors":7}],180:[function(require,module,exports){ +},{"./base/Exchange":6,"./base/errors":8}],183:[function(require,module,exports){ (function (global){ 'use strict'; @@ -137631,7 +146225,7 @@ var objectKeys = Object.keys || function (obj) { }; }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) -},{"util/":238}],181:[function(require,module,exports){ +},{"util/":241}],184:[function(require,module,exports){ 'use strict' exports.byteLength = byteLength @@ -137747,9 +146341,9 @@ function fromByteArray (uint8) { return parts.join('') } -},{}],182:[function(require,module,exports){ +},{}],185:[function(require,module,exports){ -},{}],183:[function(require,module,exports){ +},{}],186:[function(require,module,exports){ (function (process,Buffer){ 'use strict'; /* eslint camelcase: "off" */ @@ -138161,7 +146755,7 @@ Zlib.prototype._reset = function () { exports.Zlib = Zlib; }).call(this,require('_process'),require("buffer").Buffer) -},{"_process":207,"assert":180,"buffer":185,"pako/lib/zlib/constants":197,"pako/lib/zlib/deflate.js":199,"pako/lib/zlib/inflate.js":201,"pako/lib/zlib/zstream":205}],184:[function(require,module,exports){ +},{"_process":210,"assert":183,"buffer":188,"pako/lib/zlib/constants":200,"pako/lib/zlib/deflate.js":202,"pako/lib/zlib/inflate.js":204,"pako/lib/zlib/zstream":208}],187:[function(require,module,exports){ (function (process){ 'use strict'; @@ -138773,7 +147367,7 @@ util.inherits(DeflateRaw, Zlib); util.inherits(InflateRaw, Zlib); util.inherits(Unzip, Zlib); }).call(this,require('_process')) -},{"./binding":183,"_process":207,"assert":180,"buffer":185,"stream":226,"util":238}],185:[function(require,module,exports){ +},{"./binding":186,"_process":210,"assert":183,"buffer":188,"stream":229,"util":241}],188:[function(require,module,exports){ /*! * The buffer module from node.js, for the browser. * @@ -140489,7 +149083,7 @@ function numberIsNaN (obj) { return obj !== obj // eslint-disable-line no-self-compare } -},{"base64-js":181,"ieee754":191}],186:[function(require,module,exports){ +},{"base64-js":184,"ieee754":194}],189:[function(require,module,exports){ module.exports = { "100": "Continue", "101": "Switching Protocols", @@ -140555,7 +149149,7 @@ module.exports = { "511": "Network Authentication Required" } -},{}],187:[function(require,module,exports){ +},{}],190:[function(require,module,exports){ module.exports={ "O_RDONLY": 0, "O_WRONLY": 1, @@ -140766,7 +149360,7 @@ module.exports={ "UV_UDP_REUSEADDR": 4 } -},{}],188:[function(require,module,exports){ +},{}],191:[function(require,module,exports){ (function (Buffer){ // Copyright Joyent, Inc. and other Node contributors. // @@ -140877,7 +149471,7 @@ function objectToString(o) { } }).call(this,{"isBuffer":require("../../is-buffer/index.js")}) -},{"../../is-buffer/index.js":193}],189:[function(require,module,exports){ +},{"../../is-buffer/index.js":196}],192:[function(require,module,exports){ // Copyright Joyent, Inc. and other Node contributors. // // Permission is hereby granted, free of charge, to any person obtaining a @@ -141181,7 +149775,7 @@ function isUndefined(arg) { return arg === void 0; } -},{}],190:[function(require,module,exports){ +},{}],193:[function(require,module,exports){ var http = require('http') var url = require('url') @@ -141214,7 +149808,7 @@ function validateParams (params) { return params } -},{"http":227,"url":233}],191:[function(require,module,exports){ +},{"http":230,"url":236}],194:[function(require,module,exports){ exports.read = function (buffer, offset, isLE, mLen, nBytes) { var e, m var eLen = nBytes * 8 - mLen - 1 @@ -141300,7 +149894,7 @@ exports.write = function (buffer, value, offset, isLE, mLen, nBytes) { buffer[offset + i - d] |= s * 128 } -},{}],192:[function(require,module,exports){ +},{}],195:[function(require,module,exports){ if (typeof Object.create === 'function') { // implementation from standard node.js 'util' module module.exports = function inherits(ctor, superCtor) { @@ -141325,7 +149919,7 @@ if (typeof Object.create === 'function') { } } -},{}],193:[function(require,module,exports){ +},{}],196:[function(require,module,exports){ /*! * Determine if an object is a Buffer * @@ -141348,14 +149942,14 @@ function isSlowBuffer (obj) { return typeof obj.readFloatLE === 'function' && typeof obj.slice === 'function' && isBuffer(obj.slice(0, 0)) } -},{}],194:[function(require,module,exports){ +},{}],197:[function(require,module,exports){ var toString = {}.toString; module.exports = Array.isArray || function (arr) { return toString.call(arr) == '[object Array]'; }; -},{}],195:[function(require,module,exports){ +},{}],198:[function(require,module,exports){ 'use strict'; @@ -141462,7 +150056,7 @@ exports.setTyped = function (on) { exports.setTyped(TYPED_OK); -},{}],196:[function(require,module,exports){ +},{}],199:[function(require,module,exports){ 'use strict'; // Note: adler32 takes 12% for level 0 and 2% for level 6. @@ -141515,7 +150109,7 @@ function adler32(adler, buf, len, pos) { module.exports = adler32; -},{}],197:[function(require,module,exports){ +},{}],200:[function(require,module,exports){ 'use strict'; // (C) 1995-2013 Jean-loup Gailly and Mark Adler @@ -141585,7 +150179,7 @@ module.exports = { //Z_NULL: null // Use -1 or null inline, depending on var type }; -},{}],198:[function(require,module,exports){ +},{}],201:[function(require,module,exports){ 'use strict'; // Note: we can't get significant speed boost here. @@ -141646,7 +150240,7 @@ function crc32(crc, buf, len, pos) { module.exports = crc32; -},{}],199:[function(require,module,exports){ +},{}],202:[function(require,module,exports){ 'use strict'; // (C) 1995-2013 Jean-loup Gailly and Mark Adler @@ -143522,7 +152116,7 @@ exports.deflatePrime = deflatePrime; exports.deflateTune = deflateTune; */ -},{"../utils/common":195,"./adler32":196,"./crc32":198,"./messages":203,"./trees":204}],200:[function(require,module,exports){ +},{"../utils/common":198,"./adler32":199,"./crc32":201,"./messages":206,"./trees":207}],203:[function(require,module,exports){ 'use strict'; // (C) 1995-2013 Jean-loup Gailly and Mark Adler @@ -143869,7 +152463,7 @@ module.exports = function inflate_fast(strm, start) { return; }; -},{}],201:[function(require,module,exports){ +},{}],204:[function(require,module,exports){ 'use strict'; // (C) 1995-2013 Jean-loup Gailly and Mark Adler @@ -145427,7 +154021,7 @@ exports.inflateSyncPoint = inflateSyncPoint; exports.inflateUndermine = inflateUndermine; */ -},{"../utils/common":195,"./adler32":196,"./crc32":198,"./inffast":200,"./inftrees":202}],202:[function(require,module,exports){ +},{"../utils/common":198,"./adler32":199,"./crc32":201,"./inffast":203,"./inftrees":205}],205:[function(require,module,exports){ 'use strict'; // (C) 1995-2013 Jean-loup Gailly and Mark Adler @@ -145772,7 +154366,7 @@ module.exports = function inflate_table(type, lens, lens_index, codes, table, ta return 0; }; -},{"../utils/common":195}],203:[function(require,module,exports){ +},{"../utils/common":198}],206:[function(require,module,exports){ 'use strict'; // (C) 1995-2013 Jean-loup Gailly and Mark Adler @@ -145806,7 +154400,7 @@ module.exports = { '-6': 'incompatible version' /* Z_VERSION_ERROR (-6) */ }; -},{}],204:[function(require,module,exports){ +},{}],207:[function(require,module,exports){ 'use strict'; // (C) 1995-2013 Jean-loup Gailly and Mark Adler @@ -147028,7 +155622,7 @@ exports._tr_flush_block = _tr_flush_block; exports._tr_tally = _tr_tally; exports._tr_align = _tr_align; -},{"../utils/common":195}],205:[function(require,module,exports){ +},{"../utils/common":198}],208:[function(require,module,exports){ 'use strict'; // (C) 1995-2013 Jean-loup Gailly and Mark Adler @@ -147077,7 +155671,7 @@ function ZStream() { module.exports = ZStream; -},{}],206:[function(require,module,exports){ +},{}],209:[function(require,module,exports){ (function (process){ 'use strict'; @@ -147124,7 +155718,7 @@ function nextTick(fn, arg1, arg2, arg3) { } }).call(this,require('_process')) -},{"_process":207}],207:[function(require,module,exports){ +},{"_process":210}],210:[function(require,module,exports){ // shim for using process in browser var process = module.exports = {}; @@ -147310,7 +155904,7 @@ process.chdir = function (dir) { }; process.umask = function() { return 0; }; -},{}],208:[function(require,module,exports){ +},{}],211:[function(require,module,exports){ (function (global){ /*! https://mths.be/punycode v1.4.1 by @mathias */ ;(function(root) { @@ -147847,7 +156441,7 @@ process.umask = function() { return 0; }; }(this)); }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) -},{}],209:[function(require,module,exports){ +},{}],212:[function(require,module,exports){ // Copyright Joyent, Inc. and other Node contributors. // // Permission is hereby granted, free of charge, to any person obtaining a @@ -147933,7 +156527,7 @@ var isArray = Array.isArray || function (xs) { return Object.prototype.toString.call(xs) === '[object Array]'; }; -},{}],210:[function(require,module,exports){ +},{}],213:[function(require,module,exports){ // Copyright Joyent, Inc. and other Node contributors. // // Permission is hereby granted, free of charge, to any person obtaining a @@ -148020,16 +156614,16 @@ var objectKeys = Object.keys || function (obj) { return res; }; -},{}],211:[function(require,module,exports){ +},{}],214:[function(require,module,exports){ 'use strict'; exports.decode = exports.parse = require('./decode'); exports.encode = exports.stringify = require('./encode'); -},{"./decode":209,"./encode":210}],212:[function(require,module,exports){ +},{"./decode":212,"./encode":213}],215:[function(require,module,exports){ module.exports = require('./lib/_stream_duplex.js'); -},{"./lib/_stream_duplex.js":213}],213:[function(require,module,exports){ +},{"./lib/_stream_duplex.js":216}],216:[function(require,module,exports){ // Copyright Joyent, Inc. and other Node contributors. // // Permission is hereby granted, free of charge, to any person obtaining a @@ -148154,7 +156748,7 @@ function forEach(xs, f) { f(xs[i], i); } } -},{"./_stream_readable":215,"./_stream_writable":217,"core-util-is":188,"inherits":192,"process-nextick-args":206}],214:[function(require,module,exports){ +},{"./_stream_readable":218,"./_stream_writable":220,"core-util-is":191,"inherits":195,"process-nextick-args":209}],217:[function(require,module,exports){ // Copyright Joyent, Inc. and other Node contributors. // // Permission is hereby granted, free of charge, to any person obtaining a @@ -148202,7 +156796,7 @@ function PassThrough(options) { PassThrough.prototype._transform = function (chunk, encoding, cb) { cb(null, chunk); }; -},{"./_stream_transform":216,"core-util-is":188,"inherits":192}],215:[function(require,module,exports){ +},{"./_stream_transform":219,"core-util-is":191,"inherits":195}],218:[function(require,module,exports){ (function (process,global){ // Copyright Joyent, Inc. and other Node contributors. // @@ -149212,7 +157806,7 @@ function indexOf(xs, x) { return -1; } }).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) -},{"./_stream_duplex":213,"./internal/streams/BufferList":218,"./internal/streams/destroy":219,"./internal/streams/stream":220,"_process":207,"core-util-is":188,"events":189,"inherits":192,"isarray":194,"process-nextick-args":206,"safe-buffer":225,"string_decoder/":231,"util":182}],216:[function(require,module,exports){ +},{"./_stream_duplex":216,"./internal/streams/BufferList":221,"./internal/streams/destroy":222,"./internal/streams/stream":223,"_process":210,"core-util-is":191,"events":192,"inherits":195,"isarray":197,"process-nextick-args":209,"safe-buffer":228,"string_decoder/":234,"util":185}],219:[function(require,module,exports){ // Copyright Joyent, Inc. and other Node contributors. // // Permission is hereby granted, free of charge, to any person obtaining a @@ -149427,7 +158021,7 @@ function done(stream, er, data) { return stream.push(null); } -},{"./_stream_duplex":213,"core-util-is":188,"inherits":192}],217:[function(require,module,exports){ +},{"./_stream_duplex":216,"core-util-is":191,"inherits":195}],220:[function(require,module,exports){ (function (process,global){ // Copyright Joyent, Inc. and other Node contributors. // @@ -150094,7 +158688,7 @@ Writable.prototype._destroy = function (err, cb) { cb(err); }; }).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) -},{"./_stream_duplex":213,"./internal/streams/destroy":219,"./internal/streams/stream":220,"_process":207,"core-util-is":188,"inherits":192,"process-nextick-args":206,"safe-buffer":225,"util-deprecate":235}],218:[function(require,module,exports){ +},{"./_stream_duplex":216,"./internal/streams/destroy":222,"./internal/streams/stream":223,"_process":210,"core-util-is":191,"inherits":195,"process-nextick-args":209,"safe-buffer":228,"util-deprecate":238}],221:[function(require,module,exports){ 'use strict'; /**/ @@ -150169,7 +158763,7 @@ module.exports = function () { return BufferList; }(); -},{"safe-buffer":225}],219:[function(require,module,exports){ +},{"safe-buffer":228}],222:[function(require,module,exports){ 'use strict'; /**/ @@ -150242,13 +158836,13 @@ module.exports = { destroy: destroy, undestroy: undestroy }; -},{"process-nextick-args":206}],220:[function(require,module,exports){ +},{"process-nextick-args":209}],223:[function(require,module,exports){ module.exports = require('events').EventEmitter; -},{"events":189}],221:[function(require,module,exports){ +},{"events":192}],224:[function(require,module,exports){ module.exports = require('./readable').PassThrough -},{"./readable":222}],222:[function(require,module,exports){ +},{"./readable":225}],225:[function(require,module,exports){ exports = module.exports = require('./lib/_stream_readable.js'); exports.Stream = exports; exports.Readable = exports; @@ -150257,13 +158851,13 @@ exports.Duplex = require('./lib/_stream_duplex.js'); exports.Transform = require('./lib/_stream_transform.js'); exports.PassThrough = require('./lib/_stream_passthrough.js'); -},{"./lib/_stream_duplex.js":213,"./lib/_stream_passthrough.js":214,"./lib/_stream_readable.js":215,"./lib/_stream_transform.js":216,"./lib/_stream_writable.js":217}],223:[function(require,module,exports){ +},{"./lib/_stream_duplex.js":216,"./lib/_stream_passthrough.js":217,"./lib/_stream_readable.js":218,"./lib/_stream_transform.js":219,"./lib/_stream_writable.js":220}],226:[function(require,module,exports){ module.exports = require('./readable').Transform -},{"./readable":222}],224:[function(require,module,exports){ +},{"./readable":225}],227:[function(require,module,exports){ module.exports = require('./lib/_stream_writable.js'); -},{"./lib/_stream_writable.js":217}],225:[function(require,module,exports){ +},{"./lib/_stream_writable.js":220}],228:[function(require,module,exports){ /* eslint-disable node/no-deprecated-api */ var buffer = require('buffer') var Buffer = buffer.Buffer @@ -150327,7 +158921,7 @@ SafeBuffer.allocUnsafeSlow = function (size) { return buffer.SlowBuffer(size) } -},{"buffer":185}],226:[function(require,module,exports){ +},{"buffer":188}],229:[function(require,module,exports){ // Copyright Joyent, Inc. and other Node contributors. // // Permission is hereby granted, free of charge, to any person obtaining a @@ -150456,7 +159050,7 @@ Stream.prototype.pipe = function(dest, options) { return dest; }; -},{"events":189,"inherits":192,"readable-stream/duplex.js":212,"readable-stream/passthrough.js":221,"readable-stream/readable.js":222,"readable-stream/transform.js":223,"readable-stream/writable.js":224}],227:[function(require,module,exports){ +},{"events":192,"inherits":195,"readable-stream/duplex.js":215,"readable-stream/passthrough.js":224,"readable-stream/readable.js":225,"readable-stream/transform.js":226,"readable-stream/writable.js":227}],230:[function(require,module,exports){ (function (global){ var ClientRequest = require('./lib/request') var extend = require('xtend') @@ -150538,7 +159132,7 @@ http.METHODS = [ 'UNSUBSCRIBE' ] }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) -},{"./lib/request":229,"builtin-status-codes":186,"url":233,"xtend":239}],228:[function(require,module,exports){ +},{"./lib/request":232,"builtin-status-codes":189,"url":236,"xtend":242}],231:[function(require,module,exports){ (function (global){ exports.fetch = isFunction(global.fetch) && isFunction(global.ReadableStream) @@ -150611,7 +159205,7 @@ function isFunction (value) { xhr = null // Help gc }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) -},{}],229:[function(require,module,exports){ +},{}],232:[function(require,module,exports){ (function (process,global,Buffer){ var capability = require('./capability') var inherits = require('inherits') @@ -150921,7 +159515,7 @@ var unsafeHeaders = [ ] }).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {},require("buffer").Buffer) -},{"./capability":228,"./response":230,"_process":207,"buffer":185,"inherits":192,"readable-stream":222,"to-arraybuffer":232}],230:[function(require,module,exports){ +},{"./capability":231,"./response":233,"_process":210,"buffer":188,"inherits":195,"readable-stream":225,"to-arraybuffer":235}],233:[function(require,module,exports){ (function (process,global,Buffer){ var capability = require('./capability') var inherits = require('inherits') @@ -151107,7 +159701,7 @@ IncomingMessage.prototype._onXHRProgress = function () { } }).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {},require("buffer").Buffer) -},{"./capability":228,"_process":207,"buffer":185,"inherits":192,"readable-stream":222}],231:[function(require,module,exports){ +},{"./capability":231,"_process":210,"buffer":188,"inherits":195,"readable-stream":225}],234:[function(require,module,exports){ 'use strict'; var Buffer = require('safe-buffer').Buffer; @@ -151380,7 +159974,7 @@ function simpleWrite(buf) { function simpleEnd(buf) { return buf && buf.length ? this.write(buf) : ''; } -},{"safe-buffer":225}],232:[function(require,module,exports){ +},{"safe-buffer":228}],235:[function(require,module,exports){ var Buffer = require('buffer').Buffer module.exports = function (buf) { @@ -151409,7 +160003,7 @@ module.exports = function (buf) { } } -},{"buffer":185}],233:[function(require,module,exports){ +},{"buffer":188}],236:[function(require,module,exports){ // Copyright Joyent, Inc. and other Node contributors. // // Permission is hereby granted, free of charge, to any person obtaining a @@ -152143,7 +160737,7 @@ Url.prototype.parseHost = function() { if (host) this.hostname = host; }; -},{"./util":234,"punycode":208,"querystring":211}],234:[function(require,module,exports){ +},{"./util":237,"punycode":211,"querystring":214}],237:[function(require,module,exports){ 'use strict'; module.exports = { @@ -152161,7 +160755,7 @@ module.exports = { } }; -},{}],235:[function(require,module,exports){ +},{}],238:[function(require,module,exports){ (function (global){ /** @@ -152232,16 +160826,16 @@ function config (name) { } }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) -},{}],236:[function(require,module,exports){ -arguments[4][192][0].apply(exports,arguments) -},{"dup":192}],237:[function(require,module,exports){ +},{}],239:[function(require,module,exports){ +arguments[4][195][0].apply(exports,arguments) +},{"dup":195}],240:[function(require,module,exports){ module.exports = function isBuffer(arg) { return arg && typeof arg === 'object' && typeof arg.copy === 'function' && typeof arg.fill === 'function' && typeof arg.readUInt8 === 'function'; } -},{}],238:[function(require,module,exports){ +},{}],241:[function(require,module,exports){ (function (process,global){ // Copyright Joyent, Inc. and other Node contributors. // @@ -152831,7 +161425,7 @@ function hasOwnProperty(obj, prop) { } }).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) -},{"./support/isBuffer":237,"_process":207,"inherits":236}],239:[function(require,module,exports){ +},{"./support/isBuffer":240,"_process":210,"inherits":239}],242:[function(require,module,exports){ module.exports = extend var hasOwnProperty = Object.prototype.hasOwnProperty; diff --git a/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/aax.js b/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/aax.js new file mode 100644 index 000000000..9c71e445f --- /dev/null +++ b/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/aax.js @@ -0,0 +1,1784 @@ +'use strict'; + +// ---------------------------------------------------------------------------- + +const Exchange = require ('./base/Exchange'); +const { ArgumentsRequired, AuthenticationError, ExchangeError, ExchangeNotAvailable, OrderNotFound, InvalidOrder, CancelPending, RateLimitExceeded, InsufficientFunds, BadRequest, BadSymbol, PermissionDenied } = require ('./base/errors'); +const { TICK_SIZE } = require ('./base/functions/number'); + +// ---------------------------------------------------------------------------- + +module.exports = class aax extends Exchange { + describe () { + return this.deepExtend (super.describe (), { + 'id': 'aax', + 'name': 'AAX', + 'countries': [ 'MT' ], // Malta + 'enableRateLimit': true, + 'rateLimit': 500, + 'version': 'v2', + 'hostname': 'aaxpro.com', // aax.com + 'certified': true, + 'has': { + 'cancelAllOrders': true, + 'cancelOrder': true, + 'createOrder': true, + 'editOrder': true, + 'fetchBalance': true, + 'fetchCanceledOrders': true, + 'fetchClosedOrders': true, + 'fetchDepositAddress': true, + 'fetchMarkets': true, + 'fetchMyTrades': true, + 'fetchOHLCV': true, + 'fetchOpenOrders': true, + 'fetchOrder': true, + 'fetchOrderBook': true, + 'fetchOrders': true, + 'fetchTicker': 'emulated', + 'fetchTickers': true, + 'fetchTrades': true, + }, + 'timeframes': { + '1m': '1m', + '5m': '5m', + '15m': '15m', + '30m': '30m', + '1h': '1h', + '2h': '2h', + '4h': '4h', + '12h': '12h', + '1d': '1d', + '3d': '3d', + '1w': '1w', + }, + 'urls': { + 'logo': 'https://user-images.githubusercontent.com/1294454/104140087-a27f2580-53c0-11eb-87c1-5d9e81208fe9.jpg', + 'test': { + 'v1': 'https://api.testnet.{hostname}/marketdata/v1', + 'public': 'https://api.testnet.{hostname}', + 'private': 'https://api.testnet.{hostname}', + }, + 'api': { + 'v1': 'https://api.{hostname}/marketdata/v1', + 'public': 'https://api.{hostname}', + 'private': 'https://api.{hostname}', + }, + 'www': 'https://www.aaxpro.com', // string website URL + 'doc': 'https://www.aaxpro.com/apidoc/index.html', + 'fees': 'https://www.aaxpro.com/en-US/fees/', + 'referral': 'https://www.aaxpro.com/invite/sign-up?inviteCode=JXGm5Fy7R2MB', + }, + 'api': { + 'v1': { + 'get': [ + 'getHistMarketData', // Get OHLC k line of specific market + ], + }, + 'public': { + // these endpoints are not documented + // 'get': [ + // 'order_book', // Get the order book of specified market + // 'order_book/{market}', + // 'trades', // Get recent trades on market, each trade is included only once Trades are sorted in reverse creation order. + // 'trades/{market}', + // 'tickers', // Get ticker of all markets + // 'tickers/{market}', // Get ticker of specific market + // ], + 'get': [ + 'announcement/maintenance', // System Maintenance Notice + 'instruments', // Retrieve all trading pairs information + 'market/orderbook', // Order Book + 'futures/position/openInterest', // Open Interest + 'market/tickers', // Get the Last 24h Market Summary + 'market/candles', // Get Current Candlestick + 'market/history/candles', // Get Current Candlestick + 'market/trades', // Get the Most Recent Trades + 'market/markPrice', // Get Current Mark Price + 'futures/funding/predictedFunding/{symbol}', // Get Predicted Funding Rate + 'futures/funding/prevFundingRate/{symbol}', // Get Last Funding Rate + 'market/candles/index', // Get Current Index Candlestick + ], + }, + 'private': { + 'get': [ + 'user/info', // Retrieve user information + 'account/balances', // Get Account Balances + 'account/deposit/address', // undocumented + 'spot/trades', // Retrieve trades details for a spot order + 'spot/openOrders', // Retrieve spot open orders + 'spot/orders', // Retrieve historical spot orders + 'futures/position', // Get positions for all contracts + 'futures/position/closed', // Get closed positions + 'futures/trades', // Retrieve trade details for a futures order + 'futures/openOrders', // Retrieve futures open orders + 'futures/orders', // Retrieve historical futures orders + 'futures/funding/predictedFundingFee/{symbol}', // Get predicted funding fee + ], + 'post': [ + 'account/transfer', // Asset Transfer + 'spot/orders', // Create a new spot order + 'spot/orders/cancelAllOnTimeout', // Automatically cancel all your spot orders after a specified timeout. + 'futures/orders', // Create a new futures order + 'futures/orders/cancelAllOnTimeout', // Automatically cancel all your futures orders after a specified timeout. + 'futures/position/sltp', // Set take profit and stop loss orders for an opening position + 'futures/position/close', // Close position + 'futures/position/leverage', // Update leverage for position + 'futures/position/margin', // Modify Isolated Position Margin + ], + 'put': [ + 'spot/orders', // Amend spot order + 'futures/orders', // Amend the quantity of an open futures order + ], + 'delete': [ + 'spot/orders/cancel/{orderID}', // Cancel a spot order + 'spot/orders/cancel/all', // Batch cancel spot orders + 'futures/orders/cancel/{orderID}', // Cancel a futures order + 'futures/orders/cancel/all', // Batch cancel futures orders + ], + }, + }, + 'fees': { + 'trading': { + 'tierBased': false, + 'percentage': true, + 'maker': 0.06 / 100, + 'taker': 0.10 / 100, + }, + 'funding': { + 'tierBased': false, + 'percentage': true, + 'withdraw': {}, // There is only 1% fee on withdrawals to your bank account. + }, + }, + 'commonCurrencies': { + 'XBT': 'XBT', + }, + 'exceptions': { + 'exact': { + '2002': InsufficientFunds, + '2003': OrderNotFound, + '10003': BadRequest, // Parameter validation error + '10006': AuthenticationError, // Session expired, please relogin + '10007': AuthenticationError, // Invalid authentication key or token + '11007': AuthenticationError, // Invalid key format + '20001': InsufficientFunds, // Insufficient balance. Please deposit to trade. + '20009': InvalidOrder, // Order amount must be positive + '30000': OrderNotFound, // {"code":30000,"data":null,"message":"The order does not exist","ts":1610259732263} + '30001': InvalidOrder, // The order is being submitted, please try again later + '30004': InvalidOrder, // Minimum quantity is {0} + '30005': InvalidOrder, // Quantity maximum precision is {0} decimal places + '30006': InvalidOrder, // Price maximum precision is {0} decimal places + '30007': InvalidOrder, // Minimum price is {0} + '30008': InvalidOrder, // Stop price maximum precision is {0} decimal places + '30009': InvalidOrder, // Stop Price cannot be less than {0} + '30010': InvalidOrder, // Market price cannot be empty + '30011': CancelPending, // The order is being cancelled, please wait. + '30012': BadRequest, // Unknown currency + '30013': BadSymbol, // Unknown symbol + '30014': OrderNotFound, // Futures order cannot be found + '30015': InvalidOrder, // This is not an open order and cannot modified + '30016': ExchangeError, // No position found + '30017': InvalidOrder, // The current close position is 0. It is recommended that you cancel the current order closing order. + '30018': InvalidOrder, // Order price cannot be greater than {0} + '30019': InvalidOrder, // Order quantity cannot be greater than {0} + '30020': InvalidOrder, // Order price must be a multiple of {0} + '30021': InvalidOrder, // Margin adjustement must be greater than 0 + '30022': InvalidOrder, // New quantity must be greater than filled quantity + '30023': InvalidOrder, // Order failed, please try again + '30024': InvalidOrder, // TimeInForce error, only GTC or IOC are allowed + '30025': InvalidOrder, // TimeInForce error, only GTC is allowed + '30026': InvalidOrder, // Quantity is not a multiple of {0} + '30027': InvalidOrder, // Close position failed, it is recommended that you cancel the current order and then close the position. + '30028': BadSymbol, // Symbol cannot be traded at this time + '30029': InvalidOrder, // Modified quantity or price cannot be empty + '30030': InvalidOrder, // Price cannot be specified for market orders + '30031': InvalidOrder, // Liquidation orders cannot be modified + '30032': InvalidOrder, // Leverage cannot be greater than {0} + '30033': InvalidOrder, // Leverage cannot be smaller than {0} + '30034': RateLimitExceeded, // The max number of open orders is {0}. To place a new order, please cancel a previous one + '30035': RateLimitExceeded, // The max number of {0} open orders is {1}. To place a new order, please cancel a previous one + '30036': ExchangeNotAvailable, // Liquidation is in progress, please try again later + '30037': InvalidOrder, // Once stop limit order triggered, stop price cannot be amended + '30038': ExchangeError, // The total value of your orders has exceeded the current risk limit. Please adjust the risk limit + '30039': InsufficientFunds, // Your risk limit has now been changed to {0}, your maximum leverage less than 1, please readjust accordingly + '30040': InvalidOrder, // Order status has changed, please try again later + '30041': InvalidOrder, // Liquidation orders cannot be cancelled + '30042': InvalidOrder, // Order cannot be placed as you will be breaching you max limit value of {1} BTC for {0} + '30043': InvalidOrder, // The risk limit cannot be less than 0 + '30044': BadRequest, // Timeout cannot be greater than 60 minutes + '30045': InvalidOrder, // Side is not valid, it should be BUY or SELL + '30046': InvalidOrder, // Order type is not valid, it should be MARKET or LIMIT or STOP-LIMIT or STOP + '30047': InvalidOrder, // The order is closed. Can't cancel + '30048': InvalidOrder, // Market orders cannot be modified + '30049': InvalidOrder, // The order is being modified, please wait + '30050': InvalidOrder, // Maximum 10 orders + '40004': BadRequest, // Requested resource doesn't exist + '40009': RateLimitExceeded, // Too many requests + '40102': AuthenticationError, // {"code":40102,"message":"Unauthorized(invalid key)"} + '40103': AuthenticationError, // {"code":40103,"message":"Unauthorized(invalid sign)"} + '40303': PermissionDenied, // {"code":40303,"message":"Forbidden(invalid scopes)"} + '41001': BadRequest, // Incorrect HTTP request + '41002': BadRequest, // Unsupported HTTP request method + '42001': ExchangeNotAvailable, // Duplicated data entry, please check and try again + '50001': ExchangeError, // Server side exception, please try again later + '50002': ExchangeError, // Server is busy, please try again later + }, + 'broad': {}, + }, + 'precisionMode': TICK_SIZE, + 'options': { + 'defaultType': 'spot', // 'spot', 'future' + }, + }); + } + + async fetchMarkets (params = {}) { + const response = await this.publicGetInstruments (params); + // + // { + // "code":1, + // "message":"success", + // "ts":1610159448962, + // "data":[ + // { + // "tickSize":"0.01", + // "lotSize":"1", + // "base":"BTC", + // "quote":"USDT", + // "minQuantity":"1.0000000000", + // "maxQuantity":"30000", + // "minPrice":"0.0100000000", + // "maxPrice":"999999.0000000000", + // "status":"readOnly", + // "symbol":"BTCUSDTFP", + // "code":"FP", + // "takerFee":"0.00040", + // "makerFee":"0.00020", + // "multiplier":"0.001000000000", + // "mmRate":"0.00500", + // "imRate":"0.01000", + // "type":"futures", + // "settleType":"Vanilla", + // "settleCurrency":"USDT" + // }, + // { + // "tickSize":"0.5", + // "lotSize":"10", + // "base":"BTC", + // "quote":"USD", + // "minQuantity":"10.0000000000", + // "maxQuantity":"300000", + // "minPrice":"0.5000000000", + // "maxPrice":"999999.0000000000", + // "status":"readOnly", + // "symbol":"BTCUSDFP", + // "code":"FP", + // "takerFee":"0.00040", + // "makerFee":"0.00020", + // "multiplier":"1.000000000000", + // "mmRate":"0.00500", + // "imRate":"0.01000", + // "type":"futures", + // "settleType":"Inverse", + // "settleCurrency":"BTC" + // }, + // { + // "tickSize":"0.0001", + // "lotSize":"0.01", + // "base":"AAB", + // "quote":"USDT", + // "minQuantity":"5.0000000000", + // "maxQuantity":"50000.0000000000", + // "minPrice":"0.0001000000", + // "maxPrice":"999999.0000000000", + // "status":"readOnly", + // "symbol":"AABUSDT", + // "code":null, + // "takerFee":"0.00100", + // "makerFee":"0.00100", + // "multiplier":"1.000000000000", + // "mmRate":"0.02500", + // "imRate":"0.05000", + // "type":"spot", + // "settleType":null, + // "settleCurrency":null + // }, + // ] + // } + // + const data = this.safeValue (response, 'data'); + const result = []; + for (let i = 0; i < data.length; i++) { + const market = data[i]; + const id = this.safeString (market, 'symbol'); + const baseId = this.safeString (market, 'base'); + const quoteId = this.safeString (market, 'quote'); + const base = this.safeCurrencyCode (baseId); + const quote = this.safeCurrencyCode (quoteId); + const status = this.safeString (market, 'status'); + const active = (status === 'enable'); + const taker = this.safeFloat (market, 'takerFee'); + const maker = this.safeFloat (market, 'makerFee'); + const type = this.safeString (market, 'type'); + let inverse = undefined; + let linear = undefined; + let quanto = undefined; + const spot = (type === 'spot'); + const futures = (type === 'futures'); + const settleType = this.safeStringLower (market, 'settleType'); + if (settleType !== undefined) { + inverse = (settleType === 'inverse'); + linear = (settleType === 'vanilla'); + quanto = (settleType === 'quanto'); + } + let symbol = id; + if (type === 'spot') { + symbol = base + '/' + quote; + } + const precision = { + 'amount': this.safeFloat (market, 'lotSize'), + 'price': this.safeFloat (market, 'tickSize'), + }; + result.push ({ + 'id': id, + 'symbol': symbol, + 'base': base, + 'quote': quote, + 'baseId': baseId, + 'quoteId': quoteId, + 'type': type, + 'spot': spot, + 'futures': futures, + 'inverse': inverse, + 'linear': linear, + 'quanto': quanto, + 'precision': precision, + 'info': market, + 'active': active, + 'taker': taker, + 'maker': maker, + 'percentage': false, + 'tierBased': true, + 'limits': { + 'amount': { + 'min': this.safeString (market, 'minQuantity'), + 'max': this.safeString (market, 'maxQuantity'), + }, + 'price': { + 'min': this.safeString (market, 'minPrice'), + 'max': this.safeString (market, 'maxPrice'), + }, + 'cost': { + 'min': undefined, + 'max': undefined, + }, + }, + }); + } + return result; + } + + parseTicker (ticker, market = undefined) { + // + // { + // "t":1610162685342, // timestamp + // "a":"0.00000000", // trading volume in USD in the last 24 hours, futures only + // "c":"435.20000000", // close + // "d":"4.22953489", // change + // "h":"455.04000000", // high + // "l":"412.78000000", // low + // "o":"417.54000000", // open + // "s":"BCHUSDTFP", // market id + // "v":"2031068.00000000", // trading volume in quote currency of last 24 hours + // } + // + const timestamp = this.safeInteger (ticker, 't'); + const marketId = this.safeString (ticker, 's'); + const symbol = this.safeSymbol (marketId, market); + const last = this.safeFloat (ticker, 'c'); + const open = this.safeFloat (ticker, 'o'); + let change = undefined; + let percentage = undefined; + let average = undefined; + if (last !== undefined && open !== undefined) { + change = last - open; + if (open > 0) { + percentage = change / open * 100; + } + average = this.sum (last, open) / 2; + } + const quoteVolume = this.safeFloat (ticker, 'v'); + return { + 'symbol': symbol, + 'timestamp': timestamp, + 'datetime': this.iso8601 (timestamp), + 'high': this.safeFloat (ticker, 'h'), + 'low': this.safeFloat (ticker, 'l'), + 'bid': undefined, + 'bidVolume': undefined, + 'ask': undefined, + 'askVolume': undefined, + 'vwap': undefined, + 'open': open, + 'close': last, + 'last': last, + 'previousClose': undefined, + 'change': change, + 'percentage': percentage, + 'average': average, + 'baseVolume': undefined, + 'quoteVolume': quoteVolume, + 'info': ticker, + }; + } + + async fetchTicker (symbol, params = {}) { + const tickers = await this.fetchTickers (undefined, params); + if (symbol in tickers) { + return tickers[symbol]; + } + throw new BadSymbol (this.id + ' fetchTicker() symbol ' + symbol + ' ticker not found'); + } + + async fetchTickers (symbols = undefined, params = {}) { + await this.loadMarkets (); + const response = await this.publicGetMarketTickers (params); + // + // { + // "e":"tickers", + // "t":1610162685342, + // "tickers":[ + // { + // "a":"0.00000000", + // "c":"435.20000000", + // "d":"4.22953489", + // "h":"455.04000000", + // "l":"412.78000000", + // "o":"417.54000000", + // "s":"BCHUSDTFP", + // "v":"2031068.00000000", + // }, + // ], + // } + // + const tickers = this.safeValue (response, 'tickers', []); + const result = []; + const timestamp = this.safeInteger (response, 't'); + for (let i = 0; i < tickers.length; i++) { + const ticker = this.parseTicker (this.extend (tickers[i], { 't': timestamp })); + result.push (ticker); + } + return this.filterByArray (result, 'symbol', symbols); + } + + async fetchOrderBook (symbol, limit = undefined, params = {}) { + await this.loadMarkets (); + const market = this.market (symbol); + if (limit === undefined) { + limit = 20; + } else { + if ((limit !== 20) && (limit !== 50)) { + throw new BadRequest (this.id + ' fetchOrderBook() limit argument must be undefined, 20 or 50'); + } + } + const request = { + 'symbol': market['id'], + 'level': limit, // required + }; + // + const response = await this.publicGetMarketOrderbook (this.extend (request, params)); + // + // { + // "asks":[ + // ["10823.00000000","0.004000"], + // ["10823.10000000","0.100000"], + // ["10823.20000000","0.010000"] + // ], + // "bids":[ + // ["10821.20000000","0.002000"], + // ["10821.10000000","0.005000"], + // ["10820.40000000","0.013000"] + // ], + // "e":"BTCUSDT@book_50", + // "t":1561543614756 + // } + // + const timestamp = this.safeInteger (response, 't'); // need unix type + return this.parseOrderBook (response, timestamp); + } + + parseTrade (trade, market = undefined) { + // + // public fetchTrades + // + // { + // "p":"9395.50000000", + // "q":"50.000000", + // "t":1592563996718 + // } + // + // private fetchMyTrades + // + // { + // "avgPrice":"1199.8", + // "base":"ETH", + // "clOrdID":null, + // "commission":"0.00002", + // "createTime":"2021-01-11T02:47:51.512Z", + // "cumQty":"0.02", + // "filledOrderID":"1eUD4F5rwK", + // "filledPrice":"1199.8", + // "filledQty":"0.02", + // "leavesQty":"0", + // "oCreateTime":"2021-01-11T02:47:51.377Z", + // "orderID":"1eUD4EHfdU", + // "orderQty":"0.02", + // "orderStatus":3, + // "orderType":1, + // "price":"1198.25", + // "quote":"USDT", + // "rejectCode":null, + // "rejectReason":null, + // "side":1, + // "stopPrice":"0", + // "symbol":"ETHUSDT", + // "taker":true, + // "tradeID":"E04WTIgfmULU", + // "transactTime":"2021-01-11T02:47:51.389Z", + // "updateTime":null, + // "userID":"1362494" + // } + // + let timestamp = this.safeInteger (trade, 't'); + if (timestamp === undefined) { + timestamp = this.parse8601 (this.safeString (trade, 'createTime')); + } + const id = this.safeString2 (trade, 'tid', 'tradeID'); + let symbol = undefined; + const marketId = this.safeString (trade, 'symbol'); + market = this.safeMarket (marketId, market); + if (market !== undefined) { + symbol = market['symbol']; + } + let price = this.safeFloat2 (trade, 'p', 'filledPrice'); + const amount = this.safeFloat2 (trade, 'q', 'filledQty'); + const orderId = this.safeString (trade, 'orderID'); + const isTaker = this.safeValue (trade, 'taker'); + let takerOrMaker = undefined; + if (isTaker !== undefined) { + takerOrMaker = isTaker ? 'taker' : 'maker'; + } + let side = this.safeString (trade, 'side'); + if (side === '1') { + side = 'buy'; + } else if (side === '2') { + side = 'sell'; + } + if (side === undefined) { + side = (price > 0) ? 'buy' : 'sell'; + } + side = (price > 0) ? 'buy' : 'sell'; + price = Math.abs (price); + let cost = undefined; + if ((price !== undefined) && (amount !== undefined)) { + cost = price * amount; + } + const orderType = this.parseOrderType (this.safeString (trade, 'orderType')); + let fee = undefined; + const feeCost = this.safeFloat (trade, 'commission'); + if (feeCost !== undefined) { + let feeCurrency = undefined; + if (market !== undefined) { + if (side === 'buy') { + feeCurrency = market['base']; + } else if (side === 'sell') { + feeCurrency = market['quote']; + } + } + fee = { + 'currency': feeCurrency, + 'cost': feeCost, + }; + } + return { + 'info': trade, + 'id': id, + 'timestamp': timestamp, + 'datetime': this.iso8601 (timestamp), + 'symbol': symbol, + 'type': orderType, + 'side': side, + 'order': orderId, + 'takerOrMaker': takerOrMaker, + 'price': price, + 'amount': amount, + 'cost': cost, + 'fee': fee, + }; + } + + async fetchTrades (symbol, since = undefined, limit = undefined, params = {}) { + await this.loadMarkets (); + const market = this.market (symbol); + limit = (limit === undefined) ? 2000 : limit; + limit = Math.min (limit, 2000); + const request = { + 'symbol': market['id'], + 'limit': limit, + }; + const response = await this.publicGetMarketTrades (request); + // + // { + // "e":"BTCUSDFP@trades", + // "trades": [ + // {"p":"9395.50000000","q":"50.000000","t":1592563996718}, + // {"p":"9395.50000000","q":"50.000000","t":1592563993577}, + // ], + // } + // + const trades = this.safeValue (response, 'trades', []); + return this.parseTrades (trades, market, since, limit); + } + + parseOHLCV (ohlcv, market = undefined) { + // + // [ + // 0.042398, // 0 open + // 0.042684, // 1 high + // 0.042366, // 2 low + // 0.042386, // 3 close + // 0.93734243, // 4 volume + // 1611514800, // 5 timestamp + // ] + // + return [ + this.safeTimestamp (ohlcv, 5), + this.safeFloat (ohlcv, 0), + this.safeFloat (ohlcv, 1), + this.safeFloat (ohlcv, 2), + this.safeFloat (ohlcv, 3), + this.safeFloat (ohlcv, 4), + ]; + } + + async fetchOHLCV (symbol, timeframe = '1h', since = undefined, limit = undefined, params = {}) { + await this.loadMarkets (); + const market = this.market (symbol); + const request = { + // 'limit': limit, // if set counts from now into the past + 'symbol': market['id'], + 'timeFrame': this.timeframes[timeframe], + }; + limit = (limit === undefined) ? 500 : limit; + const duration = this.parseTimeframe (timeframe); + if (since === undefined) { + const end = this.seconds (); + request['start'] = end - duration * limit; + request['end'] = end; + } else { + const start = parseInt (since / 1000); + request['start'] = start; + request['end'] = this.sum (start, duration * limit); + } + const response = await this.publicGetMarketHistoryCandles (this.extend (request, params)); + // + // { + // "data":[ + // [0.042398,0.042684,0.042366,0.042386,0.93734243,1611514800], + // [0.042386,0.042602,0.042234,0.042373,1.01925239,1611518400], + // [0.042373,0.042558,0.042362,0.042389,0.93801705,1611522000], + // ], + // "success":true, + // "t":1611875157 + // } + // + const data = this.safeValue (response, 'data', []); + return this.parseOHLCVs (data, market, timeframe, since, limit); + } + + async fetchBalance (params = {}) { + await this.loadMarkets (); + const defaultType = this.safeString2 (this.options, 'fetchBalance', 'defaultType', 'spot'); + const type = this.safeString (params, 'type', defaultType); + const types = { + 'spot': 'SPTP', + 'future': 'FUTP', + 'otc': 'F2CP', + 'saving': 'VLTP', + }; + const purseType = this.safeString (types, type, type); + const request = { + 'purseType': purseType, + }; + params = this.omit (params, 'type'); + const response = await this.privateGetAccountBalances (this.extend (request, params)); + // + // { + // "code":1, + // "data":[ + // { + // "purseType":"FUTP", + // "currency":"BTC", + // "available":"0.41000000", + // "unavailable":"0.00000000" + // }, + // { + // "purseType":"FUTP", + // "currency":"USDT", + // "available":"0.21000000", + // "unvaliable":"0.00000000" + // } + // ] + // "message":"success", + // "ts":1573530401020 + // } + // + const data = this.safeValue (response, 'data'); + const result = { 'info': response }; + for (let i = 0; i < data.length; i++) { + const balance = data[i]; + const balanceType = this.safeString (balance, 'purseType'); + if (balanceType === purseType) { + const currencyId = this.safeString (balance, 'currency'); + const code = this.safeCurrencyCode (currencyId); + const account = this.account (); + account['free'] = this.safeFloat (balance, 'available'); + account['used'] = this.safeFloat (balance, 'unavailable'); + result[code] = account; + } + } + return this.parseBalance (result); + } + + async createOrder (symbol, type, side, amount, price = undefined, params = {}) { + let orderType = type.toUpperCase (); + const orderSide = side.toUpperCase (); + await this.loadMarkets (); + const market = this.market (symbol); + const request = { + // 'orderType': orderType, // MARKET, LIMIT, STOP, STOP-LIMIT + 'symbol': market['id'], + 'orderQty': this.amountToPrecision (symbol, amount), + 'side': orderSide, + // 'stopPrice': this.priceToPrecision (symbol, stopPrice), + // 'clOrdID': clientOrderId, // up to 20 chars, lowercase and uppercase letters only + // 'timeInForce': 'GTC', // GTC, IOC, FOK, default is GTC + // 'execInst': 'Post-Only', // the only value supported by the exchange, futures-only + }; + const timeInForce = this.safeString (params, 'timeInForce'); + if (timeInForce !== undefined) { + request['timeInForce'] = timeInForce; + params = this.omit (params, 'timeInForce'); + } + const clientOrderId = this.safeString2 (params, 'clOrdID', 'clientOrderId'); + if (clientOrderId !== undefined) { + request['clOrdID'] = clientOrderId; + params = this.omit (params, [ 'clOrdID', 'clientOrderId' ]); + } + const stopPrice = this.safeFloat (params, 'stopPrice'); + if (stopPrice === undefined) { + if ((orderType === 'STOP-LIMIT') || (orderType === 'STOP')) { + throw new ArgumentsRequired (this.id + ' createOrder() requires a stopPrice parameter for ' + orderType + ' orders'); + } + } else { + if (orderType === 'LIMIT') { + orderType = 'STOP-LIMIT'; + } else if (orderType === 'MARKET') { + orderType = 'STOP'; + } + request['stopPrice'] = this.priceToPrecision (symbol, stopPrice); + params = this.omit (params, 'stopPrice'); + } + if (orderType === 'LIMIT' || orderType === 'STOP-LIMIT') { + request['price'] = this.priceToPrecision (symbol, price); + } + request['orderType'] = orderType; + let method = undefined; + if (market['spot']) { + method = 'privatePostSpotOrders'; + } else if (market['futures']) { + method = 'privatePostFuturesOrders'; + } + const response = await this[method] (this.extend (request, params)); + // + // spot + // + // { + // "code":1, + // "data":{ + // "symbol":"ETHUSDT", + // "orderType":2, + // "avgPrice":"0", + // "execInst":null, + // "orderStatus":0, + // "userID":"1362494", + // "quote":"USDT", + // "rejectReason":null, + // "rejectCode":null, + // "price":"1500", + // "orderQty":"1", + // "commission":"0", + // "id":"268323430253735936", + // "timeInForce":1, + // "isTriggered":false, + // "side":2, + // "orderID":"1eO51MDSpQ", + // "leavesQty":"0", + // "cumQty":"0", + // "updateTime":null, + // "lastQty":"0", + // "clOrdID":null, + // "stopPrice":null, + // "createTime":null, + // "transactTime":null, + // "base":"ETH", + // "lastPrice":"0" + // }, + // "message":"success", + // "ts":1610245290980 + // } + // + // futures + // + // { + // "code":1, + // "data":{ + // "liqType":0, + // "symbol":"ETHUSDTFP", + // "orderType":2, + // "leverage":"1", + // "marketPrice":"1318.3150000000", + // "code":"FP", + // "avgPrice":"0", + // "execInst":null, + // "orderStatus":0, + // "userID":"1362494", + // "quote":"USDT", + // "rejectReason":null, + // "rejectCode":null, + // "price":"500", + // "orderQty":"1", + // "commission":"0", + // "id":"268346885133053953", + // "timeInForce":1, + // "isTriggered":false, + // "side":1, + // "orderID":"1eOuPUAAkq", + // "leavesQty":"1", + // "cumQty":"0", + // "updateTime":null, + // "lastQty":null, + // "clOrdID":null, + // "stopPrice":null, + // "createTime":null, + // "transactTime":null, + // "settleType":"VANILLA", + // "base":"ETH", + // "lastPrice":"0" + // }, + // "message":"success", + // "ts":1610250883059 + // } + // + const data = this.safeValue (response, 'data', {}); + return this.parseOrder (data, market); + } + + async editOrder (id, symbol, type, side, amount, price = undefined, params = {}) { + await this.loadMarkets (); + const market = this.market (symbol); + const request = { + 'orderID': id, + // 'orderQty': this.amountToPrecision (symbol, amount), + // 'price': this.priceToPrecision (symbol, price), + // 'stopPrice': this.priceToPrecision (symbol, stopPrice), + }; + const stopPrice = this.safeFloat (params, 'stopPrice'); + if (stopPrice !== undefined) { + request['stopPrice'] = this.priceToPrecision (symbol, stopPrice); + params = this.omit (params, 'stopPrice'); + } + if (price !== undefined) { + request['price'] = this.priceToPrecision (symbol, price); + } + if (amount !== undefined) { + request['orderQty'] = this.amountToPrecision (symbol, amount); + } + let method = undefined; + if (market['spot']) { + method = 'privatePutSpotOrders'; + } else if (market['futures']) { + method = 'privatePutFuturesOrders'; + } + const response = await this[method] (this.extend (request, params)); + // + // spot + // + // { + // "code":1, + // "data":{ + // "symbol":"ETHUSDT", + // "orderType":2, + // "avgPrice":"0", + // "execInst":null, + // "orderStatus":0, + // "userID":"1362494", + // "quote":"USDT", + // "rejectReason":null, + // "rejectCode":null, + // "price":"1500", + // "orderQty":"1", + // "commission":"0", + // "id":"268323430253735936", + // "timeInForce":1, + // "isTriggered":false, + // "side":2, + // "orderID":"1eO51MDSpQ", + // "leavesQty":"0", + // "cumQty":"0", + // "updateTime":null, + // "lastQty":"0", + // "clOrdID":null, + // "stopPrice":null, + // "createTime":null, + // "transactTime":null, + // "base":"ETH", + // "lastPrice":"0" + // }, + // "message":"success", + // "ts":1610245290980 + // } + // + // futures + // + // { + // "code":1, + // "data":{ + // "liqType":0, + // "symbol":"ETHUSDTFP", + // "orderType":2, + // "leverage":"1", + // "marketPrice":"1318.3150000000", + // "code":"FP", + // "avgPrice":"0", + // "execInst":null, + // "orderStatus":0, + // "userID":"1362494", + // "quote":"USDT", + // "rejectReason":null, + // "rejectCode":null, + // "price":"500", + // "orderQty":"1", + // "commission":"0", + // "id":"268346885133053953", + // "timeInForce":1, + // "isTriggered":false, + // "side":1, + // "orderID":"1eOuPUAAkq", + // "leavesQty":"1", + // "cumQty":"0", + // "updateTime":null, + // "lastQty":null, + // "clOrdID":null, + // "stopPrice":null, + // "createTime":null, + // "transactTime":null, + // "settleType":"VANILLA", + // "base":"ETH", + // "lastPrice":"0" + // }, + // "message":"success", + // "ts":1610250883059 + // } + // + const data = this.safeValue (response, 'data', {}); + return this.parseOrder (data, market); + } + + async cancelOrder (id, symbol = undefined, params = {}) { + await this.loadMarkets (); + const request = { + 'orderID': id, + }; + let method = undefined; + const defaultType = this.safeString2 (this.options, 'cancelOrder', 'defaultType', 'spot'); + let type = this.safeString (params, 'type', defaultType); + params = this.omit (params, 'type'); + let market = undefined; + if (symbol !== undefined) { + market = this.market (symbol); + type = market['type']; + } + if (type === 'spot') { + method = 'privateDeleteSpotOrdersCancelOrderID'; + } else if (type === 'futures') { + method = 'privateDeleteFuturesOrdersCancelOrderID'; + } + const response = await this[method] (this.extend (request, params)); + // + // spot + // + // { + // "code":1, + // "data":{ + // "avgPrice":"0", + // "base":"BTC", + // "clOrdID":"aax", + // "commission":"0", + // "createTime":"2019-11-12T03:46:41Z", + // "cumQty":"0", + // "id":"114330021504606208", + // "isTriggered":false, + // "lastPrice":"0", + // "lastQty":"0", + // "leavesQty":"0", + // "orderID":"wJ4L366KB", + // "orderQty":"0.05", + // "orderStatus":1, + // "orderType":2, + // "price":"8000", + // "quote":"USDT", + // "rejectCode":0, + // "rejectReason":null, + // "side":1, + // "stopPrice":"0", + // "symbol":"BTCUSDT", + // "transactTime":null, + // "updateTime":"2019-11-12T03:46:41Z", + // "timeInForce":1, + // "userID":"216214" + // }, + // "message":"success", + // "ts":1573530402029 + // } + // + // futures + // + // { + // "code":1, + // "data":{ + // "avgPrice":"0", + // "base":"BTC", + // "clOrdID":"aax_futures", + // "code":"FP", + // "commission":"0", + // "createTime":"2019-11-12T06:48:58Z", + // "cumQty":"0", + // "id":"114375893764395008", + // "isTriggered":false, + // "lastPrice":"0", + // "lastQty":null, + // "leavesQty":"300", + // "leverage":"1", + // "liqType":0, + // "marketPrice":"8760.75", + // "orderID":"wJTewQc81", + // "orderQty":"300", + // "orderStatus":1, + // "orderType":2, + // "price":"8000", + // "quote":"USD", + // "rejectCode":0, + // "rejectReason":null, + // "settleType":"INVERSE", + // "side":1, + // "stopPrice":"0", + // "symbol":"BTCUSDFP", + // "transactTime":"2019-11-12T06:48:58Z", + // "updateTime":"2019-11-12T06:48:58Z", + // "timeInForce":1, + // "execInst": "", + // "userID":"216214" + // }, + // "message":"success", + // "ts":1573541642970 + // } + // + const data = this.safeValue (response, 'data', {}); + return this.parseOrder (data, market); + } + + async cancelAllOrders (symbol = undefined, params = {}) { + if (symbol === undefined) { + throw new ArgumentsRequired (this.id + ' cancelAllOrders() requires a symbol argument'); + } + await this.loadMarkets (); + const market = this.market (symbol); + const request = { + 'symbol': market['id'], + }; + let method = undefined; + if (market['spot']) { + method = 'privateDeleteSpotOrdersCancelAll'; + } else if (market['futures']) { + method = 'privateDeleteFuturesOrdersCancelAll'; + } + const response = await this[method] (this.extend (request, params)); + // + // { + // "code":1, + // "data":[ + // "vBC9rXsEE", + // "vBCc46OI0" + // ], + // "message":"success", + // "ts":1572597435470 + // } + // + return response; + } + + async fetchOrder (id, symbol = undefined, params = {}) { + await this.loadMarkets (); + const defaultType = this.safeString2 (this.options, 'fetchOrder', 'defaultType', 'spot'); + params['type'] = this.safeString (params, 'type', defaultType); + const request = {}; + const clientOrderId = this.safeString2 (params, 'clOrdID', 'clientOrderId'); + if (clientOrderId === undefined) { + request['orderID'] = id; + } else { + request['clOrdID'] = clientOrderId; + params = this.omit (params, [ 'clOrdID', 'clientOrderId' ]); + } + const orders = await this.fetchOrders (symbol, undefined, undefined, this.extend (request, params)); + const order = this.safeValue (orders, 0); + if (order === undefined) { + if (clientOrderId === undefined) { + throw new OrderNotFound (this.id + ' fetchOrder() could not find order id ' + id); + } else { + throw new OrderNotFound (this.id + ' fetchOrder() could not find order clientOrderID ' + clientOrderId); + } + } + return order; + } + + async fetchOpenOrders (symbol = undefined, since = undefined, limit = undefined, params = {}) { + await this.loadMarkets (); + const request = { + // 'pageNum': '1', + // 'pageSize': '10', + // 'symbol': market['id'], + // 'orderID': id, + // 'side': 'undefined', // BUY, SELL + // 'clOrdID': clientOrderId, + }; + const defaultType = this.safeString2 (this.options, 'fetchOpenOrders', 'defaultType', 'spot'); + let type = this.safeString (params, 'type', defaultType); + params = this.omit (params, 'type'); + let market = undefined; + if (symbol !== undefined) { + market = this.market (symbol); + request['symbol'] = market['id']; + type = market['type']; + } + const clientOrderId = this.safeString2 (params, 'clOrdID', 'clientOrderId'); + if (clientOrderId !== undefined) { + request['clOrdID'] = clientOrderId; + params = this.omit (params, [ 'clOrdID', 'clientOrderId' ]); + } + let method = undefined; + if (type === 'spot') { + method = 'privateGetSpotOpenOrders'; + } else if (type === 'futures') { + method = 'privateGetFuturesOpenOrders'; + } + if (limit !== undefined) { + request['pageSize'] = limit; // default 10 + } + const response = await this[method] (this.extend (request, params)); + // + // spot + // + // { + // "code":1, + // "data":{ + // "total":19, + // "pageSize":10, + // "list":[ + // { + // "orderType":2, + // "symbol":"BTCUSDT", + // "avgPrice":"0", + // "orderStatus":0, + // "userID":"7225", + // "quote":"USDT", + // "rejectReason":null, + // "rejectCode":null, + // "price":"0", + // "orderQty":"0.002", + // "commission":"0", + // "id":"110419975166304256", + // "isTriggered":null, + // "side":1, + // "orderID":"vBGlDcLwk", + // "cumQty":"0", + // "leavesQty":"0", + // "updateTime":null, + // "clOrdID":"0001", + // "lastQty":"0", + // "stopPrice":"0", + // "createTime":"2019-11-01T08:49:33Z", + // "transactTime":null, + // "timeInForce":1, + // "base":"BTC", + // "lastPrice":"0" + // } + // ], + // "pageNum":1 + // }, + // "message":"success", + // "ts":1572598173682 + // } + // + // futures + // + // { + // "code":1, + // "data":{ + // "list":[ + // { + // "avgPrice":"8768.99999999484997", + // "base":"BTC", + // "clOrdID":null, + // "code":"FP", + // "commission":"0.00000913", + // "createTime":"2019-11-12T07:05:52.000Z, + // "cumQty":"100", + // "id":"114380149603028993", + // "isTriggered":false, + // "lastPrice":"8769", + // "lastQty":"100", + // "leavesQty":"0", + // "leverage":"1", + // "liqType":1, + // "marketPrice":"8769.75", + // "orderID":"wJXURIFBT", + // "orderQty":"100", + // "orderStatus":3, + // "orderType":1, + // "price":"8769.75", + // "quote":"USD", + // "rejectCode":0, + // "rejectReason":null, + // "settleType":"INVERSE", + // "side":2, + // "stopPrice":"0", + // "symbol":"BTCUSDFP", + // "transactTime":"2019-11-12T07:05:52.000Z, + // "updateTime":"2019-11-12T07:05:52.000Z, + // "timeInForce":1, + // "execInst": "", + // "userID":"216214" + // }, + // ], + // "pageNum":1, + // "pageSize":10, + // "total":21 + // }, + // "message":"success", + // "ts":1573546960172 + // } + // + const data = this.safeValue (response, 'data', {}); + const orders = this.safeValue (data, 'list', []); + return this.parseOrders (orders, market, since, limit); + } + + async fetchClosedOrders (symbol = undefined, since = undefined, limit = undefined, params = {}) { + const request = { + 'orderStatus': '2', // 1 new, 2 filled, 3 canceled + }; + return await this.fetchOrders (symbol, since, limit, this.extend (request, params)); + } + + async fetchCanceledOrders (symbol = undefined, since = undefined, limit = undefined, params = {}) { + const request = { + 'orderStatus': '3', // 1 new, 2 filled, 3 canceled + }; + return await this.fetchOrders (symbol, since, limit, this.extend (request, params)); + } + + async fetchOrders (symbol = undefined, since = undefined, limit = undefined, params = {}) { + await this.loadMarkets (); + const request = { + // 'pageNum': '1', + // 'pageSize': '10', + // 'symbol': market['id'], + // 'orderID': id, + // 'base': market['baseId'], + // 'quote': market['quoteId'], + // 'orderStatus': undefined, // 1 new, 2 filled, 3 canceled + // 'startDate': this.ymd (since), + // 'endDate': this.ymd (this.milliseconds()), + // 'orderType': undefined, // MARKET, LIMIT, STOP, STOP-LIMIT + // 'side': 'undefined', // BUY, SELL + // 'clOrdID': clientOrderId, + }; + let method = undefined; + const defaultType = this.safeString2 (this.options, 'fetchOrders', 'defaultType', 'spot'); + let type = this.safeString (params, 'type', defaultType); + params = this.omit (params, 'type'); + let market = undefined; + if (symbol !== undefined) { + market = this.market (symbol); + request['symbol'] = market['id']; + type = market['type']; + } + if (type === 'spot') { + method = 'privateGetSpotOrders'; + } else if (type === 'futures') { + method = 'privateGetFuturesOrders'; + } + const clientOrderId = this.safeString2 (params, 'clOrdID', 'clientOrderId'); + if (clientOrderId !== undefined) { + request['clOrdID'] = clientOrderId; + params = this.omit (params, [ 'clOrdID', 'clientOrderId' ]); + } + if (limit !== undefined) { + request['pageSize'] = limit; // default 10 + } + if (since !== undefined) { + request['startDate'] = this.ymd (since); + } + const response = await this[method] (this.extend (request, params)); + // + // spot + // + // { + // "code":1, + // "data":{ + // "total":19, + // "pageSize":10, + // "list":[ + // { + // "orderType":2, + // "symbol":"BTCUSDT", + // "avgPrice":"0", + // "orderStatus":0, + // "userID":"7225", + // "quote":"USDT", + // "rejectReason":null, + // "rejectCode":null, + // "price":"0", + // "orderQty":"0.002", + // "commission":"0", + // "id":"110419975166304256", + // "isTriggered":null, + // "side":1, + // "orderID":"vBGlDcLwk", + // "cumQty":"0", + // "leavesQty":"0", + // "updateTime":null, + // "clOrdID":"0001", + // "lastQty":"0", + // "stopPrice":"0", + // "createTime":"2019-11-01T08:49:33Z", + // "transactTime":null, + // "timeInForce":1, + // "base":"BTC", + // "lastPrice":"0" + // } + // ], + // "pageNum":1 + // }, + // "message":"success", + // "ts":1572598173682 + // } + // + // futures + // + // { + // "code":1, + // "data":{ + // "list":[ + // { + // "avgPrice":"8768.99999999484997", + // "base":"BTC", + // "clOrdID":null, + // "code":"FP", + // "commission":"0.00000913", + // "createTime":"2019-11-12T07:05:52.000Z, + // "cumQty":"100", + // "id":"114380149603028993", + // "isTriggered":false, + // "lastPrice":"8769", + // "lastQty":"100", + // "leavesQty":"0", + // "leverage":"1", + // "liqType":1, + // "marketPrice":"8769.75", + // "orderID":"wJXURIFBT", + // "orderQty":"100", + // "orderStatus":3, + // "orderType":1, + // "price":"8769.75", + // "quote":"USD", + // "rejectCode":0, + // "rejectReason":null, + // "settleType":"INVERSE", + // "side":2, + // "stopPrice":"0", + // "symbol":"BTCUSDFP", + // "transactTime":"2019-11-12T07:05:52.000Z, + // "updateTime":"2019-11-12T07:05:52.000Z, + // "timeInForce":1, + // "execInst": "", + // "userID":"216214" + // }, + // ], + // "pageNum":1, + // "pageSize":10, + // "total":21 + // }, + // "message":"success", + // "ts":1573546960172 + // } + // + const data = this.safeValue (response, 'data', {}); + const orders = this.safeValue (data, 'list', []); + return this.parseOrders (orders, market, since, limit); + } + + parseOrderStatus (status) { + const statuses = { + '0': 'open', // pending new + '1': 'open', // new + '2': 'open', // partially-filled + '3': 'closed', // filled + '4': 'canceled', // cancel-reject + '5': 'canceled', // canceled + '6': 'rejected', // rejected + '10': 'expired', // expired + '11': 'rejected', // business-reject + }; + return this.safeString (statuses, status, status); + } + + parseOrderType (status) { + const statuses = { + '1': 'market', + '2': 'limit', + '3': 'stop', + '4': 'stop-limit', + '7': 'stop-loss', + '8': 'take-profit', + }; + return this.safeString (statuses, status, status); + } + + parseTimeInForce (timeInForce) { + const timeInForces = { + '1': 'GTC', + '3': 'IOC', + '4': 'FOK', + }; + return this.safeString (timeInForces, timeInForce, timeInForce); + } + + parseOrder (order, market = undefined) { + // + // { + // "avgPrice":"8768.99999999484997", + // "base":"BTC", + // "clOrdID":null, + // "code":"FP", // futures only + // "commission":"0.00000913", + // "createTime":"2019-11-12T07:05:52.000Z, + // "cumQty":"100", + // "id":"114380149603028993", // futures only + // "isTriggered":false, + // "lastPrice":"8769", + // "lastQty":"100", + // "leavesQty":"0", + // "leverage":"1", // futures only + // "liqType":1, // futures only + // "marketPrice":"8769.75", // futures only + // "orderID":"wJXURIFBT", + // "orderQty":"100", + // "orderStatus":3, + // "orderType":1, + // "price":"8769.75", + // "quote":"USD", + // "rejectCode":0, + // "rejectReason":null, + // "settleType":"INVERSE", // futures only + // "side":2, + // "stopPrice":"0", + // "symbol":"BTCUSDFP", + // "transactTime":"2019-11-12T07:05:52.000Z, + // "updateTime":"2019-11-12T07:05:52.000Z, + // "timeInForce":1, + // "execInst": "", + // "userID":"216214" + // } + // + // sometimes the timestamp is returned in milliseconds + let timestamp = this.safeValue (order, 'createTime'); + if (typeof timestamp === 'string') { + timestamp = this.parse8601 (timestamp); + } + const status = this.parseOrderStatus (this.safeString (order, 'orderStatus')); + const type = this.parseOrderType (this.safeString (order, 'orderType')); + let side = this.safeString (order, 'side'); + if (side === '1') { + side = 'buy'; + } else if (side === '2') { + side = 'sell'; + } + const id = this.safeString (order, 'orderID'); + const clientOrderId = this.safeString (order, 'clOrdID'); + const marketId = this.safeString (order, 'symbol'); + market = this.safeMarket (marketId, market); + const symbol = market['symbol']; + const price = this.safeFloat (order, 'price'); + const stopPrice = this.safeFloat (order, 'stopPrice'); + const timeInForce = this.parseTimeInForce (this.safeString (order, 'timeInForce')); + const execInst = this.safeString (order, 'execInst'); + const postOnly = (execInst === 'Post-Only'); + const average = this.safeFloat (order, 'avgPrice'); + const amount = this.safeFloat (order, 'orderQty'); + const filled = this.safeFloat (order, 'cumQty'); + const remaining = this.safeString (order, 'leavesQty'); + let cost = undefined; + let lastTradeTimestamp = undefined; + if (filled !== undefined) { + if (price !== undefined) { + cost = filled * price; + } + if (filled > 0) { + lastTradeTimestamp = this.safeValue (order, 'transactTime'); + if (typeof lastTradeTimestamp === 'string') { + lastTradeTimestamp = this.parse8601 (lastTradeTimestamp); + } + } + } + let fee = undefined; + const feeCost = this.safeFloat (order, 'commission'); + if (feeCost !== undefined) { + let feeCurrency = undefined; + if (market !== undefined) { + if (side === 'buy') { + feeCurrency = market['base']; + } else if (side === 'sell') { + feeCurrency = market['quote']; + } + } + fee = { + 'currency': feeCurrency, + 'cost': feeCost, + }; + } + return { + 'id': id, + 'info': order, + 'clientOrderId': clientOrderId, + 'timestamp': timestamp, + 'datetime': this.iso8601 (timestamp), + 'lastTradeTimestamp': lastTradeTimestamp, + 'status': status, + 'symbol': symbol, + 'type': type, + 'timeInForce': timeInForce, + 'postOnly': postOnly, + 'side': side, + 'price': price, + 'stopPrice': stopPrice, + 'average': average, + 'amount': amount, + 'filled': filled, + 'remaining': remaining, + 'cost': cost, + 'trades': undefined, + 'fee': fee, + }; + } + + async fetchMyTrades (symbol = undefined, since = undefined, limit = undefined, params = {}) { + await this.loadMarkets (); + const request = { + // 'pageNum': '1', + // 'pageSize': '10', + // 'symbol': market['id'], + // 'orderID': id, + // 'base': market['baseId'], + // 'quote': market['quoteId'], + // 'startDate': this.ymd (since), + // 'endDate': this.ymd (this.milliseconds()), + // 'orderType': undefined, // MARKET, LIMIT, STOP, STOP-LIMIT + // 'side': 'undefined', // BUY, SELL + }; + let method = undefined; + const defaultType = this.safeString2 (this.options, 'fetchMyTrades', 'defaultType', 'spot'); + let type = this.safeString (params, 'type', defaultType); + params = this.omit (params, 'type'); + let market = undefined; + if (symbol !== undefined) { + market = this.market (symbol); + request['symbol'] = market['id']; + type = market['type']; + } + if (type === 'spot') { + method = 'privateGetSpotTrades'; + } else if (type === 'futures') { + method = 'privateGetFuturesTrades'; + } + if (limit !== undefined) { + request['pageSize'] = limit; // default 10 + } + if (since !== undefined) { + request['startDate'] = this.ymd (since); + } + const response = await this[method] (this.extend (request, params)); + // + // { + // "code":1, + // "data":{ + // "list":[ + // { + // "avgPrice":"1199.8", + // "base":"ETH", + // "clOrdID":null, + // "commission":"0.00002", + // "createTime":"2021-01-11T02:47:51.512Z", + // "cumQty":"0.02", + // "filledOrderID":"1eUD4F5rwK", + // "filledPrice":"1199.8", + // "filledQty":"0.02", + // "leavesQty":"0", + // "oCreateTime":"2021-01-11T02:47:51.377Z", + // "orderID":"1eUD4EHfdU", + // "orderQty":"0.02", + // "orderStatus":3, + // "orderType":1, + // "price":"1198.25", + // "quote":"USDT", + // "rejectCode":null, + // "rejectReason":null, + // "side":1, + // "stopPrice":"0", + // "symbol":"ETHUSDT", + // "taker":true, + // "tradeID":"E04WTIgfmULU", + // "transactTime":"2021-01-11T02:47:51.389Z", + // "updateTime":null, + // "userID":"1362494" + // } + // ], + // "pageNum":1, + // "pageSize":10, + // "total":1 + // }, + // "message":"success", + // "ts":1610333278042 + // } + // + const data = this.safeValue (response, 'data', {}); + const trades = this.safeValue (data, 'list', []); + return this.parseTrades (trades, market, since, limit); + } + + async fetchDepositAddress (code, params = {}) { + await this.loadMarkets (); + const currency = this.currency (code); + const request = { + 'currency': currency['id'], + // 'network': undefined, // 'ERC20 + }; + const response = await this.privateGetAccountDepositAddress (this.extend (request, params)); + // + // { + // "code":1, + // "data":{ + // "address":"0x080c5c667381404cca9be0be9a04b2e47691ff86", + // "tag":null, + // "currency":"USDT", + // "network":"ERC20" + // }, + // "message":"success", + // "ts":1610270465132 + // } + // + const data = this.safeValue (response, 'data', {}); + return this.parseDepositAddress (data, currency); + } + + parseDepositAddress (depositAddress, currency = undefined) { + // + // { + // "address":"0x080c5c667381404cca9be0be9a04b2e47691ff86", + // "tag":null, + // "currency":"USDT", + // "network":"ERC20" + // } + // + const address = this.safeString (depositAddress, 'address'); + const tag = this.safeString (depositAddress, 'tag'); + const currencyId = this.safeString (depositAddress, 'currency'); + const code = this.safeCurrencyCode (currencyId); + return { + 'info': depositAddress, + 'code': code, + 'address': address, + 'tag': tag, + }; + } + + nonce () { + return this.milliseconds (); + } + + sign (path, api = 'public', method = 'GET', params = {}, headers = undefined, body = undefined) { + let url = '/' + this.implodeParams (path, params); + const query = this.omit (params, this.extractParams (path)); + if (api === 'v1') { + if (Object.keys (query).length) { + url += '?' + this.urlencode (query); + } + } else { + url = '/' + this.version + url; + if (api === 'public') { + if (Object.keys (query).length) { + url += '?' + this.urlencode (query); + } + } else if (api === 'private') { + this.checkRequiredCredentials (); + const nonce = this.nonce ().toString (); + headers = { + 'X-ACCESS-KEY': this.apiKey, + 'X-ACCESS-NONCE': nonce, + }; + let auth = nonce + ':' + method; + if (method === 'GET') { + if (Object.keys (query).length) { + url += '?' + this.urlencode (query); + } + auth += url; + } else { + headers['Content-Type'] = 'application/json'; + body = this.json (query); + auth += url + body; + } + const signature = this.hmac (this.encode (auth), this.encode (this.secret)); + headers['X-ACCESS-SIGN'] = signature; + } + } + url = this.implodeParams (this.urls['api'][api], { 'hostname': this.hostname }) + url; + return { 'url': url, 'method': method, 'body': body, 'headers': headers }; + } + + handleErrors (code, reason, url, method, headers, body, response, requestHeaders, requestBody) { + if (response === undefined) { + return; // fallback to default error handler + } + // + // {"code":40102,"message":"Unauthorized(invalid key)"} + // + const errorCode = this.safeString (response, 'code'); + if ((errorCode !== undefined) && (errorCode !== '1')) { + const feedback = this.id + ' ' + this.json (response); + this.throwExactlyMatchedException (this.exceptions['exact'], errorCode, feedback); + this.throwBroadlyMatchedException (this.exceptions['broad'], body, feedback); + } + } +}; diff --git a/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/acx.js b/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/acx.js index 011921fa4..e10ec85ca 100644 --- a/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/acx.js +++ b/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/acx.js @@ -346,6 +346,7 @@ module.exports = class acx extends Exchange { 'symbol': symbol, 'type': type, 'timeInForce': undefined, + 'postOnly': undefined, 'side': side, 'price': this.safeFloat (order, 'price'), 'stopPrice': undefined, diff --git a/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/aofex.js b/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/aofex.js index fb5e7f4a3..7899f09d5 100644 --- a/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/aofex.js +++ b/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/aofex.js @@ -132,6 +132,9 @@ module.exports = class aofex extends Exchange { 'show_all': '0', // '1' to show zero balances }, }, + 'commonCurrencies': { + 'CPC': 'Consensus Planet Coin', + }, }); } @@ -798,6 +801,7 @@ module.exports = class aofex extends Exchange { 'symbol': market['symbol'], 'type': type, 'timeInForce': undefined, + 'postOnly': undefined, 'side': side, 'price': price, 'stopPrice': undefined, diff --git a/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/base/Exchange.js b/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/base/Exchange.js index f231581ed..eb017b5bf 100644 --- a/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/base/Exchange.js +++ b/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/base/Exchange.js @@ -411,20 +411,20 @@ module.exports = class Exchange { if (!!enabled) { // eslint-disable-line no-extra-boolean-cast if ('test' in this.urls) { if (typeof this.urls['api'] === 'string') { - this.urls['api_backup'] = this.urls['api'] + this.urls['apiBackup'] = this.urls['api'] this.urls['api'] = this.urls['test'] } else { - this.urls['api_backup'] = clone (this.urls['api']) + this.urls['apiBackup'] = clone (this.urls['api']) this.urls['api'] = clone (this.urls['test']) } } else { throw new NotSupported (this.id + ' does not have a sandbox URL') } - } else if ('api_backup' in this.urls) { + } else if ('apiBackup' in this.urls) { if (typeof this.urls['api'] === 'string') { - this.urls['api'] = this.urls['api_backup'] + this.urls['api'] = this.urls['apiBackup'] } else { - this.urls['api'] = clone (this.urls['api_backup']) + this.urls['api'] = clone (this.urls['apiBackup']) } } } @@ -576,34 +576,31 @@ module.exports = class Exchange { handleRestResponse (response, url, method = 'GET', requestHeaders = undefined, requestBody = undefined) { return response.text ().then ((responseBody) => { - - const json = this.parseJson (responseBody) - const responseHeaders = this.getResponseHeaders (response) - + const bodyText = this.onRestResponse (response.status, response.statusText, url, method, responseHeaders, responseBody, requestHeaders, requestBody); + const json = this.parseJson (bodyText) if (this.enableLastResponseHeaders) { this.last_response_headers = responseHeaders } - if (this.enableLastHttpResponse) { this.last_http_response = responseBody } - if (this.enableLastJsonResponse) { this.last_json_response = json } - if (this.verbose) { this.print ("handleRestResponse:\n", this.id, method, url, response.status, response.statusText, "\nResponse:\n", responseHeaders, "\n", responseBody, "\n") } - this.handleErrors (response.status, response.statusText, url, method, responseHeaders, responseBody, json, requestHeaders, requestBody) this.handleHttpStatusCode (response.status, response.statusText, url, method, responseBody) - return json || responseBody }) } + onRestResponse (statusCode, statusText, url, method, responseHeaders, responseBody, requestHeaders, requestBody) { + return responseBody.trim ().replace (/:(\d{15,}),/g, ':"$1",'); + } + setMarkets (markets, currencies = undefined) { const values = Object.values (markets).map ((market) => deepExtend ({ 'limits': this.limits, @@ -903,6 +900,10 @@ module.exports = class Exchange { return symbols.map ((symbol) => this.marketId (symbol)) } + currencyIds (codes) { + return codes.map ((code) => this.currencyId (code)) + } + symbol (symbol) { return this.market (symbol).symbol || symbol } @@ -1036,7 +1037,7 @@ module.exports = class Exchange { array = array.filter ((entry) => entry[key] >= since) } if (limit !== undefined && limit !== null) { - array = (tail && !sinceIsDefined) ? array.slice (-limit) : array.slice (0, limit) + array = tail ? array.slice (-limit) : array.slice (0, limit) } return array } @@ -1054,18 +1055,18 @@ module.exports = class Exchange { } if (limit !== undefined && limit !== null) { - array = (tail && !sinceIsDefined) ? array.slice (-limit) : array.slice (0, limit) + array = tail ? array.slice (-limit) : array.slice (0, limit) } return array } - filterBySymbolSinceLimit (array, symbol = undefined, since = undefined, limit = undefined) { - return this.filterByValueSinceLimit (array, 'symbol', symbol, since, limit) + filterBySymbolSinceLimit (array, symbol = undefined, since = undefined, limit = undefined, tail = false) { + return this.filterByValueSinceLimit (array, 'symbol', symbol, since, limit, 'timestamp', tail) } - filterByCurrencySinceLimit (array, code = undefined, since = undefined, limit = undefined) { - return this.filterByValueSinceLimit (array, 'currency', code, since, limit) + filterByCurrencySinceLimit (array, code = undefined, since = undefined, limit = undefined, tail = false) { + return this.filterByValueSinceLimit (array, 'currency', code, since, limit, 'timestamp', tail) } filterByArray (objects, key, values = undefined, indexed = true) { @@ -1095,7 +1096,8 @@ module.exports = class Exchange { let result = Object.values (trades || []).map ((trade) => this.extend (this.parseTrade (trade, market), params)) result = sortBy (result, 'timestamp') const symbol = (market !== undefined) ? market['symbol'] : undefined - return this.filterBySymbolSinceLimit (result, symbol, since, limit) + const tail = since === undefined + return this.filterBySymbolSinceLimit (result, symbol, since, limit, tail) } parseTransactions (transactions, currency = undefined, since = undefined, limit = undefined, params = {}) { @@ -1106,7 +1108,8 @@ module.exports = class Exchange { let result = Object.values (transactions || []).map ((transaction) => this.extend (this.parseTransaction (transaction, currency), params)) result = this.sortBy (result, 'timestamp'); const code = (currency !== undefined) ? currency['code'] : undefined; - return this.filterByCurrencySinceLimit (result, code, since, limit); + const tail = since === undefined; + return this.filterByCurrencySinceLimit (result, code, since, limit, tail); } parseLedger (data, currency = undefined, since = undefined, limit = undefined, params = {}) { @@ -1124,7 +1127,8 @@ module.exports = class Exchange { } result = this.sortBy (result, 'timestamp'); const code = (currency !== undefined) ? currency['code'] : undefined; - return this.filterByCurrencySinceLimit (result, code, since, limit); + const tail = since === undefined; + return this.filterByCurrencySinceLimit (result, code, since, limit, tail); } parseOrders (orders, market = undefined, since = undefined, limit = undefined, params = {}) { @@ -1154,7 +1158,8 @@ module.exports = class Exchange { Object.entries (orders).map (([ id, order ]) => this.extend (this.parseOrder (this.extend ({ 'id': id }, order), market), params)) result = sortBy (result, 'timestamp') const symbol = (market !== undefined) ? market['symbol'] : undefined - return this.filterBySymbolSinceLimit (result, symbol, since, limit) + const tail = since === undefined + return this.filterBySymbolSinceLimit (result, symbol, since, limit, tail) } safeCurrency (currencyId, currency = undefined) { @@ -1225,19 +1230,10 @@ module.exports = class Exchange { // if (!this.isArray (ohlcvs)) { // throw new ExchangeError (this.id + ' parseOHLCVs expected an array in the ohlcvs argument, but got ' + typeof ohlcvs); // } - ohlcvs = Object.values (ohlcvs || []) - const result = [] - for (let i = 0; i < ohlcvs.length; i++) { - if (limit && (result.length >= limit)) { - break; - } - const ohlcv = this.parseOHLCV (ohlcvs[i], market) - if (since && (ohlcv[0] < since)) { - continue - } - result.push (ohlcv) - } - return this.sortBy (result, 0) + const parsed = ohlcvs.map ((ohlcv) => this.parseOHLCV (ohlcv, market)) + const sorted = this.sortBy (parsed, 0) + const tail = since === undefined + return this.filterBySinceLimit (sorted, since, limit, 0, tail) } editLimitBuyOrder (id, symbol, ...args) { @@ -1260,20 +1256,20 @@ module.exports = class Exchange { return this.createOrder (symbol, ...args) } - createLimitOrder (symbol, ...args) { - return this.createOrder (symbol, 'limit', ...args) + createLimitOrder (symbol, side, amount, price = undefined, params = {}) { + return this.createOrder (symbol, 'limit', side, amount, price, params) } - createMarketOrder (symbol, ...args) { - return this.createOrder (symbol, 'market', ...args) + createMarketOrder (symbol, side, amount, price = undefined, params = {}) { + return this.createOrder (symbol, 'market', side, amount, price, params) } - createLimitBuyOrder (symbol, ...args) { - return this.createOrder (symbol, 'limit', 'buy', ...args) + createLimitBuyOrder (symbol, amount, price = undefined, params = {}) { + return this.createOrder (symbol, 'limit', 'buy', amount, price, params) } - createLimitSellOrder (symbol, ...args) { - return this.createOrder (symbol, 'limit', 'sell', ...args) + createLimitSellOrder (symbol, amount, price = undefined, params = {}) { + return this.createOrder (symbol, 'limit', 'sell', amount, price, params) } createMarketBuyOrder (symbol, amount, params = {}) { @@ -1285,7 +1281,7 @@ module.exports = class Exchange { } costToPrecision (symbol, cost) { - return decimalToPrecision (cost, ROUND, this.markets[symbol].precision.price, this.precisionMode, this.paddingMode) + return decimalToPrecision (cost, TRUNCATE, this.markets[symbol].precision.price, this.precisionMode, this.paddingMode) } priceToPrecision (symbol, price) { @@ -1372,7 +1368,7 @@ module.exports = class Exchange { // still takes the input as a hex string // same as above but returns a string instead of an object const signature = this.signMessage (message, privateKey) - return signature['r'] + this.remove0xPrefix (signature['s']) + this.binaryToBase16 (this.numberToBE (signature['v'])); + return signature['r'] + this.remove0xPrefix (signature['s']) + this.binaryToBase16 (this.numberToBE (signature['v'])) } oath () { @@ -1396,5 +1392,74 @@ module.exports = class Exchange { integerPow (a, b) { return new BN (a).pow (new BN (b)) } -} + safeOrder (order) { + // Cost + // Remaining + // Average + // Price + // Amount + // Filled + // + // First we try to calculate filled from the trades + const parseFilled = order['filled'] === undefined; + const parseCost = order['cost'] === undefined; + if (parseFilled) { + order['filled'] = 0 + } + if (parseCost) { + order['cost'] = 0 + } + if (parseFilled || parseCost) { + if (Array.isArray (order['trades'])) { + for (let i = 0; i < order['trades'].length; i++) { + const trade = order['trades'][i] + if (parseFilled) { + order['filled'] = this.sum (order['filled'], trade['amount']) + } + if (parseCost) { + order['cost'] = this.sum (order['cost'], trade['cost']) + } + } + } + } + // We ensure amount = filled + remaining + if (order['amount'] === undefined) { + if (order['filled'] !== undefined && order['remaining'] !== undefined) { + order['amount'] = this.sum (order['filled'], order['remaining']) + } + } + if (order['filled'] === undefined) { + if (order['amount'] !== undefined && order['remaining'] !== undefined) { + order['filled'] = Math.max (this.sum (order['amount'], -order['remaining']), 0) + } + } + if (order['remaining'] === undefined) { + if (order['amount'] !== undefined && order['filled'] !== undefined) { + order['remaining'] = Math.max (this.sum (order['amount'], -order['filled']), 0) + } + } + // We ensure that the average field is calculated correctly + if (order['average'] === undefined) { + if (order['filled'] !== undefined && order['cost'] !== undefined && order['cost'] > 0) { + order['average'] = order['filled'] / order['cost'] + } + } + // We also ensure the cost field is calculated correctly + const costPriceExists = (order['average'] !== undefined) || (order['price'] !== undefined) + if ((order['filled'] !== undefined) && costPriceExists) { + let costPrice = undefined; + if (order['average'] === undefined) { + costPrice = order['price'] + } else { + costPrice = order['average'] + } + order['cost'] = costPrice * order['filled'] + } + // We add support for market orders + if (order['price'] === undefined && order['type'] === 'market') { + order['price'] = order['average'] + } + return order + } +} diff --git a/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/base/errors.js b/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/base/errors.js index 25a28580a..5248e49d0 100644 --- a/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/base/errors.js +++ b/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/base/errors.js @@ -30,6 +30,10 @@ function subclass (BaseClass, classes, namespace = {}) { this.__proto__ = Class.prototype this.name = className this.message = message + + // https://github.com/Microsoft/TypeScript/wiki/FAQ#why-doesnt-extending-built-ins-like-error-array-and-map-work + + Object.setPrototypeOf (this, Class.prototype) } } diff --git a/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/base/functions/string.js b/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/base/functions/string.js index cabc63b48..ba9601a12 100644 --- a/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/base/functions/string.js +++ b/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/base/functions/string.js @@ -1,21 +1,18 @@ "use strict"; -/* ------------------------------------------------------------------------ */ +// ---------------------------------------------------------------------------- -const uuid = a => a ? (a ^ Math.random () * 16 >> a / 4).toString (16) - : ([1e7]+-1e3+-4e3+-8e3+-1e11).replace (/[018]/g, uuid) +const uuid = a => a ? (a ^ Math.random () * 16 >> a / 4).toString (16) : ([1e7]+-1e3+-4e3+-8e3+-1e11).replace (/[018]/g, uuid) +const uuid22 = a => a ? (a ^ Math.random () * 16 >> a / 4).toString (16) : ([1e7]+1e3+4e3+8e5).replace (/[018]/g, uuid22) -module.exports = +// ---------------------------------------------------------------------------- - { uuid +module.exports = { - // hasFetchOHLCV → has_fetch_ohlcv; parseHTTPResponse → parse_http_response + uuid + , uuid22 + // hasFetchOHLCV → has_fetch_ohlcv; parseHTTPResponse → parse_http_response , unCamelCase: s => s.match (/^[A-Z0-9_]+$/) ? s : (s.replace (/[a-z0-9][A-Z]/g, x => x[0] + '_' + x[1]).replace(/[A-Z0-9][A-Z0-9][a-z]/g, x => x[0] + '_' + x[1] + x[2]).toLowerCase ()) - - , capitalize: s => s.length - ? (s.charAt (0).toUpperCase () + s.slice (1)) - : s + , capitalize: s => s.length ? (s.charAt (0).toUpperCase () + s.slice (1)) : s , strip: s => s.replace(/^\s+|\s+$/g, '') - } - -/* ------------------------------------------------------------------------ */ +} diff --git a/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/bcex.js b/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/bcex.js deleted file mode 100644 index 22eb628a3..000000000 --- a/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/bcex.js +++ /dev/null @@ -1,687 +0,0 @@ -'use strict'; - -// --------------------------------------------------------------------------- - -const Exchange = require ('./base/Exchange'); -const { ExchangeError, ArgumentsRequired, AuthenticationError, InsufficientFunds, InvalidOrder, OrderNotFound } = require ('./base/errors'); - -// --------------------------------------------------------------------------- - -module.exports = class bcex extends Exchange { - describe () { - return this.deepExtend (super.describe (), { - 'id': 'bcex', - 'name': 'BCEX', - 'countries': [ 'CN', 'HK' ], - 'version': '1', - 'has': { - 'cancelOrder': true, - 'createOrder': true, - 'fetchBalance': true, - 'fetchClosedOrders': 'emulated', - 'fetchMarkets': true, - 'fetchMyTrades': true, - 'fetchOpenOrders': true, - 'fetchOrder': true, - 'fetchOrders': true, - 'fetchOrderBook': true, - 'fetchTicker': true, - 'fetchTickers': false, - 'fetchTrades': true, - 'fetchTradingLimits': true, - }, - 'urls': { - 'logo': 'https://user-images.githubusercontent.com/51840849/77231516-851c6900-6bac-11ea-8fd6-ee5c23eddbd4.jpg', - 'api': 'https://www.bcex.top', - 'www': 'https://www.bcex.top', - 'doc': 'https://github.com/BCEX-TECHNOLOGY-LIMITED/API_Docs/wiki/Interface', - 'fees': 'https://bcex.udesk.cn/hc/articles/57085', - 'referral': 'https://www.bcex.top/register?invite_code=758978&lang=en', - }, - 'status': { - 'status': 'error', - 'updated': undefined, - 'eta': undefined, - 'url': undefined, - }, - 'api': { - 'public': { - 'get': [ - 'Api_Market/getPriceList', // tickers - 'Api_Order/ticker', // last ohlcv candle (ticker) - 'Api_Order/depth', // orderbook - 'Api_Market/getCoinTrade', // ticker - 'Api_Order/marketOrder', // trades... - ], - 'post': [ - 'Api_Market/getPriceList', // tickers - 'Api_Order/ticker', // last ohlcv candle (ticker) - 'Api_Order/depth', // orderbook - 'Api_Market/getCoinTrade', // ticker - 'Api_Order/marketOrder', // trades... - ], - }, - 'private': { - 'post': [ - 'Api_Order/cancel', - 'Api_Order/coinTrust', // limit order - 'Api_Order/orderList', // open / all orders (my trades?) - 'Api_Order/orderInfo', - 'Api_Order/tradeList', // open / all orders - 'Api_Order/trustList', // ? - 'Api_User/userBalance', - ], - }, - }, - 'fees': { - 'trading': { - 'tierBased': false, - 'percentage': true, - 'maker': 0.1 / 100, - 'taker': 0.2 / 100, - }, - 'funding': { - 'tierBased': false, - 'percentage': false, - 'withdraw': { - 'ckusd': 0.0, - 'other': 0.05 / 100, - }, - 'deposit': {}, - }, - }, - 'exceptions': { - '该币不存在,非法操作': ExchangeError, // { code: 1, msg: "该币不存在,非法操作" } - returned when a required symbol parameter is missing in the request (also, maybe on other types of errors as well) - '公钥不合法': AuthenticationError, // { code: 1, msg: '公钥不合法' } - wrong public key - '您的可用余额不足': InsufficientFunds, // { code: 1, msg: '您的可用余额不足' } - your available balance is insufficient - '您的btc不足': InsufficientFunds, // { code: 1, msg: '您的btc不足' } - your btc is insufficient - '参数非法': InvalidOrder, // {'code': 1, 'msg': '参数非法'} - 'Parameter illegal' - '订单信息不存在': OrderNotFound, // {'code': 1, 'msg': '订单信息不存在'} - 'Order information does not exist' - }, - 'commonCurrencies': { - 'UNI': 'UNI COIN', - 'PNT': 'Penta', - }, - 'options': { - 'limits': { - // hardcoding is deprecated, using these predefined values is not recommended, use loadTradingLimits instead - 'AFC/CKUSD': { 'precision': { 'amount': 2, 'price': 4 }, 'limits': { 'amount': { 'min': 6, 'max': 120000 }}}, - 'AFC/ETH': { 'precision': { 'amount': 2, 'price': 8 }, 'limits': { 'amount': { 'min': 6, 'max': 120000 }}}, - 'AFT/ETH': { 'precision': { 'amount': 2, 'price': 8 }, 'limits': { 'amount': { 'min': 15, 'max': 300000 }}}, - 'AICC/CNET': { 'precision': { 'amount': 2, 'price': 2 }, 'limits': { 'amount': { 'min': 5, 'max': 50000 }}}, - 'AIDOC/CKUSD': { 'precision': { 'amount': 2, 'price': 4 }, 'limits': { 'amount': { 'min': 5, 'max': 100000 }}}, - 'AISI/ETH': { 'precision': { 'amount': 4, 'price': 2 }, 'limits': { 'amount': { 'min': 0.001, 'max': 500 }}}, - 'AIT/ETH': { 'precision': { 'amount': 2, 'price': 8 }, 'limits': { 'amount': { 'min': 20, 'max': 400000 }}}, - 'ANS/BTC': { 'precision': { 'amount': 4, 'price': 8 }, 'limits': { 'amount': { 'min': 0.1, 'max': 500 }}}, - 'ANS/CKUSD': { 'precision': { 'amount': 2, 'price': 2 }, 'limits': { 'amount': { 'min': 0.1, 'max': 1000 }}}, - 'ARC/CNET': { 'precision': { 'amount': 2, 'price': 4 }, 'limits': { 'amount': { 'min': 60, 'max': 600000 }}}, - 'AXF/CNET': { 'precision': { 'amount': 2, 'price': 4 }, 'limits': { 'amount': { 'min': 100, 'max': 1000000 }}}, - 'BASH/CKUSD': { 'precision': { 'amount': 2, 'price': 4 }, 'limits': { 'amount': { 'min': 250, 'max': 3000000 }}}, - 'BATT/ETH': { 'precision': { 'amount': 2, 'price': 8 }, 'limits': { 'amount': { 'min': 60, 'max': 1500000 }}}, - 'BCD/BTC': { 'precision': { 'amount': 2, 'price': 8 }, 'limits': { 'amount': { 'min': 0.3, 'max': 7000 }}}, - 'BHPC/BTC': { 'precision': { 'amount': 2, 'price': 8 }, 'limits': { 'amount': { 'min': 2, 'max': 70000 }}}, - 'BHPC/ETH': { 'precision': { 'amount': 2, 'price': 8 }, 'limits': { 'amount': { 'min': 2, 'max': 60000 }}}, - 'BOPO/BTC': { 'precision': { 'amount': 2, 'price': 8 }, 'limits': { 'amount': { 'min': 100, 'max': 2000000 }}}, - 'BOPO/CKUSD': { 'precision': { 'amount': 2, 'price': 4 }, 'limits': { 'amount': { 'min': 100, 'max': 10000000 }}}, - 'BTC/CKUSD': { 'precision': { 'amount': 4, 'price': 2 }, 'limits': { 'amount': { 'min': 0.001, 'max': 10 }}}, - 'BTC/CNET': { 'precision': { 'amount': 4, 'price': 2 }, 'limits': { 'amount': { 'min': 0.0005, 'max': 5 }}}, - 'BTC/USDT': { 'precision': { 'amount': 4, 'price': 2 }, 'limits': { 'amount': { 'min': 0.0002, 'max': 4 }}}, - 'BTE/CNET': { 'precision': { 'amount': 2, 'price': 4 }, 'limits': { 'amount': { 'min': 25, 'max': 250000 }}}, - 'BU/ETH': { 'precision': { 'amount': 2, 'price': 8 }, 'limits': { 'amount': { 'min': 20, 'max': 400000 }}}, - 'CIC/CNET': { 'precision': { 'amount': 2, 'price': 4 }, 'limits': { 'amount': { 'min': 3000, 'max': 30000000 }}}, - 'CIT/CKUSD': { 'precision': { 'amount': 2, 'price': 4 }, 'limits': { 'amount': { 'min': 4, 'max': 40000 }}}, - 'CIT/ETH': { 'precision': { 'amount': 2, 'price': 8 }, 'limits': { 'amount': { 'min': 4, 'max': 40000 }}}, - 'CMT/CKUSD': { 'precision': { 'amount': 2, 'price': 4 }, 'limits': { 'amount': { 'min': 5, 'max': 2500000 }}}, - 'CNET/CKUSD': { 'precision': { 'amount': 2, 'price': 4 }, 'limits': { 'amount': { 'min': 12, 'max': 120000 }}}, - 'CNMC/BTC': { 'precision': { 'amount': 2, 'price': 8 }, 'limits': { 'amount': { 'min': 4, 'max': 50000 }}}, - 'CTC/ETH': { 'precision': { 'amount': 2, 'price': 8 }, 'limits': { 'amount': { 'min': 5, 'max': 550000 }}}, - 'CZR/ETH': { 'precision': { 'amount': 2, 'price': 8 }, 'limits': { 'amount': { 'min': 12, 'max': 500000 }}}, - 'DCON/ETH': { 'precision': { 'amount': 2, 'price': 8 }, 'limits': { 'amount': { 'min': 8, 'max': 300000 }}}, - 'DCT/BTC': { 'precision': { 'amount': 4, 'price': 8 }, 'limits': { 'amount': { 'min': 2, 'max': 40000 }}}, - 'DCT/CKUSD': { 'precision': { 'amount': 2, 'price': 3 }, 'limits': { 'amount': { 'min': 2, 'max': 2000 }}}, - 'DOGE/BTC': { 'precision': { 'amount': 4, 'price': 8 }, 'limits': { 'amount': { 'min': 3000, 'max': 14000000 }}}, - 'DOGE/CKUSD': { 'precision': { 'amount': 2, 'price': 6 }, 'limits': { 'amount': { 'min': 500, 'max': 2000000 }}}, - 'DRCT/ETH': { 'precision': { 'amount': 2, 'price': 8 }, 'limits': { 'amount': { 'min': 16, 'max': 190000 }}}, - 'ELA/BTC': { 'precision': { 'amount': 2, 'price': 8 }, 'limits': { 'amount': { 'min': 0.02, 'max': 500 }}}, - 'ELF/BTC': { 'precision': { 'amount': 2, 'price': 8 }, 'limits': { 'amount': { 'min': 0.1, 'max': 100000 }}}, - 'ELF/CKUSD': { 'precision': { 'amount': 2, 'price': 3 }, 'limits': { 'amount': { 'min': 0.01, 'max': 100000 }}}, - 'EOS/CKUSD': { 'precision': { 'amount': 2, 'price': 2 }, 'limits': { 'amount': { 'min': 0.5, 'max': 5000 }}}, - 'EOS/CNET': { 'precision': { 'amount': 2, 'price': 2 }, 'limits': { 'amount': { 'min': 2.5, 'max': 30000 }}}, - 'EOS/ETH': { 'precision': { 'amount': 2, 'price': 8 }, 'limits': { 'amount': { 'min': 0.18, 'max': 1800 }}}, - 'ETC/BTC': { 'precision': { 'amount': 4, 'price': 8 }, 'limits': { 'amount': { 'min': 0.2, 'max': 2500 }}}, - 'ETC/CKUSD': { 'precision': { 'amount': 2, 'price': 2 }, 'limits': { 'amount': { 'min': 0.2, 'max': 2500 }}}, - 'ETF/ETH': { 'precision': { 'amount': 2, 'price': 8 }, 'limits': { 'amount': { 'min': 7, 'max': 150000 }}}, - 'ETH/BTC': { 'precision': { 'amount': 4, 'price': 8 }, 'limits': { 'amount': { 'min': 0.015, 'max': 100 }}}, - 'ETH/CKUSD': { 'precision': { 'amount': 4, 'price': 4 }, 'limits': { 'amount': { 'min': 0.005, 'max': 100 }}}, - 'ETH/USDT': { 'precision': { 'amount': 4, 'price': 2 }, 'limits': { 'amount': { 'min': 0.005, 'max': 100 }}}, - 'FCT/BTC': { 'precision': { 'amount': 4, 'price': 8 }, 'limits': { 'amount': { 'min': 0.24, 'max': 1000 }}}, - 'FCT/CKUSD': { 'precision': { 'amount': 2, 'price': 2 }, 'limits': { 'amount': { 'min': 0.24, 'max': 1000 }}}, - 'GAME/CNET': { 'precision': { 'amount': 2, 'price': 2 }, 'limits': { 'amount': { 'min': 1, 'max': 10000 }}}, - 'GOOC/CKUSD': { 'precision': { 'amount': 2, 'price': 4 }, 'limits': { 'amount': { 'min': 200, 'max': 2000000 }}}, - 'GP/CNET': { 'precision': { 'amount': 2, 'price': 4 }, 'limits': { 'amount': { 'min': 600, 'max': 6000000 }}}, - 'HSC/ETH': { 'precision': { 'amount': 2, 'price': 8 }, 'limits': { 'amount': { 'min': 1000, 'max': 20000000 }}}, - 'IFISH/ETH': { 'precision': { 'amount': 2, 'price': 8 }, 'limits': { 'amount': { 'min': 300, 'max': 8000000 }}}, - 'IIC/ETH': { 'precision': { 'amount': 2, 'price': 8 }, 'limits': { 'amount': { 'min': 50, 'max': 4000000 }}}, - 'IMOS/ETH': { 'precision': { 'amount': 2, 'price': 8 }, 'limits': { 'amount': { 'min': 15, 'max': 300000 }}}, - 'JC/CNET': { 'precision': { 'amount': 2, 'price': 4 }, 'limits': { 'amount': { 'min': 300, 'max': 3000000 }}}, - 'LBTC/BTC': { 'precision': { 'amount': 2, 'price': 8 }, 'limits': { 'amount': { 'min': 0.1, 'max': 3000 }}}, - 'LEC/CNET': { 'precision': { 'amount': 2, 'price': 4 }, 'limits': { 'amount': { 'min': 500, 'max': 5000000 }}}, - 'LKY/CKUSD': { 'precision': { 'amount': 2, 'price': 4 }, 'limits': { 'amount': { 'min': 10, 'max': 70000 }}}, - 'LKY/ETH': { 'precision': { 'amount': 2, 'price': 8 }, 'limits': { 'amount': { 'min': 10, 'max': 100000 }}}, - 'LMC/CNET': { 'precision': { 'amount': 2, 'price': 4 }, 'limits': { 'amount': { 'min': 25, 'max': 250000 }}}, - 'LSK/CNET': { 'precision': { 'amount': 2, 'price': 2 }, 'limits': { 'amount': { 'min': 0.3, 'max': 3000 }}}, - 'LTC/BTC': { 'precision': { 'amount': 4, 'price': 8 }, 'limits': { 'amount': { 'min': 0.01, 'max': 500 }}}, - 'LTC/CKUSD': { 'precision': { 'amount': 2, 'price': 2 }, 'limits': { 'amount': { 'min': 0.01, 'max': 500 }}}, - 'LTC/USDT': { 'precision': { 'amount': 4, 'price': 2 }, 'limits': { 'amount': { 'min': 0.02, 'max': 450 }}}, - 'MC/CNET': { 'precision': { 'amount': 2, 'price': 6 }, 'limits': { 'amount': { 'min': 10000, 'max': 100000000 }}}, - 'MCC/CKUSD': { 'precision': { 'amount': 2, 'price': 4 }, 'limits': { 'amount': { 'min': 30, 'max': 350000 }}}, - 'MOC/ETH': { 'precision': { 'amount': 2, 'price': 8 }, 'limits': { 'amount': { 'min': 25, 'max': 600000 }}}, - 'MRYC/CNET': { 'precision': { 'amount': 2, 'price': 4 }, 'limits': { 'amount': { 'min': 300, 'max': 3000000 }}}, - 'MT/ETH': { 'precision': { 'amount': 2, 'price': 8 }, 'limits': { 'amount': { 'min': 200, 'max': 6000000 }}}, - 'MXI/CNET': { 'precision': { 'amount': 2, 'price': 6 }, 'limits': { 'amount': { 'min': 5000, 'max': 60000000 }}}, - 'NAI/ETH': { 'precision': { 'amount': 2, 'price': 8 }, 'limits': { 'amount': { 'min': 10, 'max': 100000 }}}, - 'NAS/BTC': { 'precision': { 'amount': 4, 'price': 8 }, 'limits': { 'amount': { 'min': 0.2, 'max': 15000 }}}, - 'NAS/CKUSD': { 'precision': { 'amount': 2, 'price': 2 }, 'limits': { 'amount': { 'min': 0.5, 'max': 5000 }}}, - 'NEWOS/ETH': { 'precision': { 'amount': 2, 'price': 8 }, 'limits': { 'amount': { 'min': 65, 'max': 700000 }}}, - 'NKN/ETH': { 'precision': { 'amount': 2, 'price': 8 }, 'limits': { 'amount': { 'min': 3, 'max': 350000 }}}, - 'NTK/ETH': { 'precision': { 'amount': 2, 'price': 8 }, 'limits': { 'amount': { 'min': 2, 'max': 30000 }}}, - 'ONT/CKUSD': { 'precision': { 'amount': 2, 'price': 3 }, 'limits': { 'amount': { 'min': 0.2, 'max': 2000 }}}, - 'ONT/ETH': { 'precision': { 'amount': 3, 'price': 8 }, 'limits': { 'amount': { 'min': 0.01, 'max': 1000 }}}, - 'PNT/ETH': { 'precision': { 'amount': 2, 'price': 8 }, 'limits': { 'amount': { 'min': 80, 'max': 800000 }}}, - 'PST/ETH': { 'precision': { 'amount': 2, 'price': 8 }, 'limits': { 'amount': { 'min': 5, 'max': 100000 }}}, - 'PTT/ETH': { 'precision': { 'amount': 2, 'price': 8 }, 'limits': { 'amount': { 'min': 450, 'max': 10000000 }}}, - 'QTUM/BTC': { 'precision': { 'amount': 4, 'price': 8 }, 'limits': { 'amount': { 'min': 0.4, 'max': 2800 }}}, - 'QTUM/CKUSD': { 'precision': { 'amount': 2, 'price': 2 }, 'limits': { 'amount': { 'min': 0.1, 'max': 1000 }}}, - 'RATING/ETH': { 'precision': { 'amount': 2, 'price': 8 }, 'limits': { 'amount': { 'min': 500, 'max': 10000000 }}}, - 'RHC/CNET': { 'precision': { 'amount': 2, 'price': 4 }, 'limits': { 'amount': { 'min': 1000, 'max': 10000000 }}}, - 'SDA/ETH': { 'precision': { 'amount': 2, 'price': 8 }, 'limits': { 'amount': { 'min': 20, 'max': 500000 }}}, - 'SDD/CKUSD': { 'precision': { 'amount': 2, 'price': 3 }, 'limits': { 'amount': { 'min': 10, 'max': 100000 }}}, - 'SHC/CNET': { 'precision': { 'amount': 2, 'price': 4 }, 'limits': { 'amount': { 'min': 250, 'max': 2500000 }}}, - 'SHE/ETH': { 'precision': { 'amount': 2, 'price': 8 }, 'limits': { 'amount': { 'min': 100, 'max': 5000000 }}}, - 'SMC/CNET': { 'precision': { 'amount': 2, 'price': 6 }, 'limits': { 'amount': { 'min': 1000, 'max': 10000000 }}}, - 'SOP/ETH': { 'precision': { 'amount': 2, 'price': 8 }, 'limits': { 'amount': { 'min': 50, 'max': 1000000 }}}, - 'TAC/ETH': { 'precision': { 'amount': 2, 'price': 8 }, 'limits': { 'amount': { 'min': 35, 'max': 800000 }}}, - 'TIP/ETH': { 'precision': { 'amount': 2, 'price': 8 }, 'limits': { 'amount': { 'min': 7, 'max': 200000 }}}, - 'TKT/ETH': { 'precision': { 'amount': 2, 'price': 8 }, 'limits': { 'amount': { 'min': 40, 'max': 400000 }}}, - 'TLC/ETH': { 'precision': { 'amount': 2, 'price': 8 }, 'limits': { 'amount': { 'min': 500, 'max': 10000000 }}}, - 'TNC/ETH': { 'precision': { 'amount': 2, 'price': 8 }, 'limits': { 'amount': { 'min': 10, 'max': 110000 }}}, - 'TUB/ETH': { 'precision': { 'amount': 2, 'price': 8 }, 'limits': { 'amount': { 'min': 200, 'max': 8000000 }}}, - 'UC/ETH': { 'precision': { 'amount': 2, 'price': 8 }, 'limits': { 'amount': { 'min': 100, 'max': 3000000 }}}, - 'UDB/CNET': { 'precision': { 'amount': 2, 'price': 6 }, 'limits': { 'amount': { 'min': 2000, 'max': 40000000 }}}, - 'UIC/CKUSD': { 'precision': { 'amount': 2, 'price': 4 }, 'limits': { 'amount': { 'min': 5, 'max': 150000 }}}, - 'VAAC/ETH': { 'precision': { 'amount': 2, 'price': 8 }, 'limits': { 'amount': { 'min': 10, 'max': 250000 }}}, - 'VPN/CNET': { 'precision': { 'amount': 2, 'price': 4 }, 'limits': { 'amount': { 'min': 200, 'max': 2000000 }}}, - 'VSC/ETH': { 'precision': { 'amount': 2, 'price': 8 }, 'limits': { 'amount': { 'min': 30, 'max': 650000 }}}, - 'WAVES/CKUSD': { 'precision': { 'amount': 2, 'price': 3 }, 'limits': { 'amount': { 'min': 0.15, 'max': 1500 }}}, - 'WDNA/ETH': { 'precision': { 'amount': 2, 'price': 8 }, 'limits': { 'amount': { 'min': 100, 'max': 250000 }}}, - 'WIC/CKUSD': { 'precision': { 'amount': 2, 'price': 4 }, 'limits': { 'amount': { 'min': 3, 'max': 30000 }}}, - 'XAS/CNET': { 'precision': { 'amount': 2, 'price': 2 }, 'limits': { 'amount': { 'min': 2.5, 'max': 25000 }}}, - 'XLM/BTC': { 'precision': { 'amount': 4, 'price': 8 }, 'limits': { 'amount': { 'min': 10, 'max': 300000 }}}, - 'XLM/CKUSD': { 'precision': { 'amount': 2, 'price': 4 }, 'limits': { 'amount': { 'min': 1, 'max': 300000 }}}, - 'XLM/USDT': { 'precision': { 'amount': 2, 'price': 4 }, 'limits': { 'amount': { 'min': 5, 'max': 150000 }}}, - 'XRP/BTC': { 'precision': { 'amount': 4, 'price': 8 }, 'limits': { 'amount': { 'min': 24, 'max': 100000 }}}, - 'XRP/CKUSD': { 'precision': { 'amount': 2, 'price': 3 }, 'limits': { 'amount': { 'min': 5, 'max': 50000 }}}, - 'YBCT/BTC': { 'precision': { 'amount': 4, 'price': 8 }, 'limits': { 'amount': { 'min': 15, 'max': 200000 }}}, - 'YBCT/CKUSD': { 'precision': { 'amount': 2, 'price': 4 }, 'limits': { 'amount': { 'min': 10, 'max': 200000 }}}, - 'YBY/CNET': { 'precision': { 'amount': 2, 'price': 6 }, 'limits': { 'amount': { 'min': 25000, 'max': 250000000 }}}, - 'ZEC/BTC': { 'precision': { 'amount': 4, 'price': 8 }, 'limits': { 'amount': { 'min': 0.02, 'max': 100 }}}, - 'ZEC/CKUSD': { 'precision': { 'amount': 4, 'price': 2 }, 'limits': { 'amount': { 'min': 0.02, 'max': 100 }}}, - }, - }, - }); - } - - async fetchTradingLimits (symbols = undefined, params = {}) { - // this method should not be called directly, use loadTradingLimits () instead - // by default it will try load withdrawal fees of all currencies (with separate requests, sequentially) - // however if you define symbols = [ 'ETH/BTC', 'LTC/BTC' ] in args it will only load those - await this.loadMarkets (); - if (symbols === undefined) { - symbols = this.symbols; - } - const result = {}; - for (let i = 0; i < symbols.length; i++) { - const symbol = symbols[i]; - result[symbol] = await this.fetchTradingLimitsById (this.marketId (symbol), params); - } - return result; - } - - async fetchTradingLimitsById (id, params = {}) { - const request = { - 'symbol': id, - }; - const response = await this.publicPostApiOrderTicker (this.extend (request, params)); - // - // { code: 0, - // msg: "获取牌价信息成功", - // data: { high: 0.03721392, - // low: 0.03335362, - // buy: "0.03525757", - // sell: "0.03531160", - // last: 0.0352634, - // vol: "184742.4176", - // min_trade: "0.01500000", - // max_trade: "100.00000000", - // number_float: "4", - // price_float: "8" } } } - // - return this.parseTradingLimits (this.safeValue (response, 'data', {})); - } - - parseTradingLimits (limits, symbol = undefined, params = {}) { - // - // { high: 0.03721392, - // low: 0.03335362, - // buy: "0.03525757", - // sell: "0.03531160", - // last: 0.0352634, - // vol: "184742.4176", - // min_trade: "0.01500000", - // max_trade: "100.00000000", - // number_float: "4", - // price_float: "8" } - // - return { - 'info': limits, - 'precision': { - 'amount': this.safeInteger (limits, 'number_float'), - 'price': this.safeInteger (limits, 'price_float'), - }, - 'limits': { - 'amount': { - 'min': this.safeFloat (limits, 'min_trade'), - 'max': this.safeFloat (limits, 'max_trade'), - }, - }, - }; - } - - async fetchMarkets (params = {}) { - const response = await this.publicGetApiMarketGetPriceList (params); - const result = []; - const keys = Object.keys (response); - for (let i = 0; i < keys.length; i++) { - const currentMarketId = keys[i]; - const currentMarkets = response[currentMarketId]; - for (let j = 0; j < currentMarkets.length; j++) { - const market = currentMarkets[j]; - const baseId = this.safeString (market, 'coin_from'); - const quoteId = this.safeString (market, 'coin_to'); - let base = baseId.toUpperCase (); - let quote = quoteId.toUpperCase (); - base = this.safeCurrencyCode (base); - quote = this.safeCurrencyCode (quote); - const id = baseId + '2' + quoteId; - const symbol = base + '/' + quote; - const active = true; - const defaults = this.safeValue (this.options['limits'], symbol, {}); - result.push (this.extend ({ - 'id': id, - 'symbol': symbol, - 'base': base, - 'quote': quote, - 'baseId': baseId, - 'quoteId': quoteId, - 'active': active, - // overrided by defaults from this.options['limits'] - 'precision': { - 'amount': undefined, - 'price': undefined, - }, - // overrided by defaults from this.options['limits'] - 'limits': { - 'amount': { 'min': undefined, 'max': undefined }, - 'price': { 'min': undefined, 'max': undefined }, - 'cost': { 'min': undefined, 'max': undefined }, - }, - 'info': market, - }, defaults)); - } - } - return result; - } - - parseTrade (trade, market = undefined) { - let symbol = undefined; - if (market !== undefined) { - symbol = market['symbol']; - } - const timestamp = this.safeTimestamp2 (trade, 'date', 'created'); - const id = this.safeString (trade, 'tid'); - const orderId = this.safeString (trade, 'order_id'); - const amount = this.safeFloat2 (trade, 'number', 'amount'); - const price = this.safeFloat (trade, 'price'); - let cost = undefined; - if (price !== undefined) { - if (amount !== undefined) { - cost = amount * price; - } - } - let side = this.safeString (trade, 'side'); - if (side === 'sale') { - side = 'sell'; - } - return { - 'info': trade, - 'id': id, - 'timestamp': timestamp, - 'datetime': this.iso8601 (timestamp), - 'symbol': symbol, - 'type': undefined, - 'side': side, - 'price': price, - 'amount': amount, - 'cost': cost, - 'order': orderId, - 'fee': undefined, - 'takerOrMaker': undefined, - }; - } - - async fetchTrades (symbol, since = undefined, limit = undefined, params = {}) { - await this.loadMarkets (); - const request = { - 'symbol': this.marketId (symbol), - }; - if (limit !== undefined) { - request['limit'] = limit; - } - const market = this.market (symbol); - const response = await this.publicPostApiOrderMarketOrder (this.extend (request, params)); - return this.parseTrades (response['data'], market, since, limit); - } - - async fetchBalance (params = {}) { - await this.loadMarkets (); - const response = await this.privatePostApiUserUserBalance (params); - const data = this.safeValue (response, 'data'); - let keys = Object.keys (data); - const result = { }; - for (let i = 0; i < keys.length; i++) { - const key = keys[i]; - const amount = this.safeFloat (data, key); - const parts = key.split ('_'); - const currencyId = parts[0]; - const lockOrOver = parts[1]; - const code = this.safeCurrencyCode (currencyId); - if (!(code in result)) { - result[code] = this.account (); - } - if (lockOrOver === 'lock') { - result[code]['used'] = parseFloat (amount); - } else { - result[code]['free'] = parseFloat (amount); - } - } - keys = Object.keys (result); - for (let i = 0; i < keys.length; i++) { - const key = keys[i]; - const total = this.sum (result[key]['used'], result[key]['free']); - result[key]['total'] = total; - } - result['info'] = data; - return this.parseBalance (result); - } - - async fetchTicker (symbol, params = {}) { - await this.loadMarkets (); - const market = this.markets[symbol]; - const request = { - 'part': market['quoteId'], - 'coin': market['baseId'], - }; - const response = await this.publicPostApiMarketGetCoinTrade (this.extend (request, params)); - const timestamp = this.milliseconds (); - return { - 'symbol': symbol, - 'timestamp': timestamp, - 'datetime': this.iso8601 (timestamp), - 'high': this.safeFloat (response, 'max'), - 'low': this.safeFloat (response, 'min'), - 'bid': this.safeFloat (response, 'buy'), - 'bidVolume': undefined, - 'ask': this.safeFloat (response, 'sale'), - 'askVolume': undefined, - 'vwap': undefined, - 'open': undefined, - 'close': this.safeFloat (response, 'price'), - 'last': this.safeFloat (response, 'price'), - 'previousClose': undefined, - 'change': undefined, - 'percentage': this.safeFloat (response, 'change_24h'), - 'average': undefined, - 'baseVolume': this.safeFloat (response, 'volume_24h'), - 'quoteVolume': undefined, - 'info': response, - }; - } - - async fetchOrderBook (symbol, limit = undefined, params = {}) { - await this.loadMarkets (); - const marketId = this.marketId (symbol); - const request = { - 'symbol': marketId, - }; - const response = await this.publicPostApiOrderDepth (this.extend (request, params)); - const data = this.safeValue (response, 'data'); - const timestamp = this.safeTimestamp (data, 'date'); - return this.parseOrderBook (data, timestamp); - } - - async fetchMyTrades (symbol = undefined, since = undefined, limit = undefined, params = {}) { - await this.loadMarkets (); - const market = this.market (symbol); - const request = { - 'symbol': market['id'], - }; - const response = await this.privatePostApiOrderOrderList (this.extend (request, params)); - return this.parseTrades (response['data'], market, since, limit); - } - - parseOrderStatus (status) { - const statuses = { - '0': 'open', - '1': 'open', // partially filled - '2': 'closed', - '3': 'canceled', - }; - return this.safeString (statuses, status, status); - } - - async fetchOrder (id, symbol = undefined, params = {}) { - if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' fetchOrder requires a `symbol` argument'); - } - await this.loadMarkets (); - const request = { - 'symbol': this.marketId (symbol), - 'trust_id': id, - }; - const response = await this.privatePostApiOrderOrderInfo (this.extend (request, params)); - const order = this.safeValue (response, 'data'); - const timestamp = this.safeTimestamp (order, 'created'); - const status = this.parseOrderStatus (this.safeString (order, 'status')); - let side = this.safeString (order, 'flag'); - if (side === 'sale') { - side = 'sell'; - } - // Can't use parseOrder because the data format is different btw endpoint for fetchOrder and fetchOrders - return { - 'info': order, - 'id': id, - 'timestamp': timestamp, - 'datetime': this.iso8601 (timestamp), - 'lastTradeTimestamp': undefined, - 'symbol': symbol, - 'type': undefined, - 'side': side, - 'price': this.safeFloat (order, 'price'), - 'cost': undefined, - 'average': this.safeFloat (order, 'avg_price'), - 'amount': this.safeFloat (order, 'number'), - 'filled': this.safeFloat (order, 'numberdeal'), - 'remaining': this.safeFloat (order, 'numberover'), - 'status': status, - 'fee': undefined, - 'clientOrderId': undefined, - 'trades': undefined, - }; - } - - parseOrder (order, market = undefined) { - const id = this.safeString (order, 'id'); - const timestamp = this.safeTimestamp (order, 'datetime'); - let symbol = undefined; - if (market !== undefined) { - symbol = market['symbol']; - } - const type = undefined; - let side = this.safeString (order, 'type'); - if (side === 'sale') { - side = 'sell'; - } - const price = this.safeFloat (order, 'price'); - const average = this.safeFloat (order, 'avg_price'); - const amount = this.safeFloat (order, 'amount'); - const remaining = this.safeFloat (order, 'amount_outstanding'); - const filled = amount - remaining; - const status = this.parseOrderStatus (this.safeString (order, 'status')); - const cost = filled * price; - const fee = undefined; - const result = { - 'info': order, - 'id': id, - 'clientOrderId': undefined, - 'timestamp': timestamp, - 'datetime': this.iso8601 (timestamp), - 'lastTradeTimestamp': undefined, - 'symbol': symbol, - 'type': type, - 'timeInForce': undefined, - 'side': side, - 'price': price, - 'stopPrice': undefined, - 'cost': cost, - 'average': average, - 'amount': amount, - 'filled': filled, - 'remaining': remaining, - 'status': status, - 'fee': fee, - 'trades': undefined, - }; - return result; - } - - async fetchOrdersByType (type, symbol = undefined, since = undefined, limit = undefined, params = {}) { - await this.loadMarkets (); - const request = { - 'type': type, - }; - let market = undefined; - if (symbol !== undefined) { - market = this.market (symbol); - request['symbol'] = market['id']; - } - const response = await this.privatePostApiOrderTradeList (this.extend (request, params)); - if ('data' in response) { - return this.parseOrders (response['data'], market, since, limit); - } - return []; - } - - async fetchOpenOrders (symbol = undefined, since = undefined, limit = undefined, params = {}) { - return this.fetchOrdersByType ('open', symbol, since, limit, params); - } - - async fetchClosedOrders (symbol = undefined, since = undefined, limit = undefined, params = {}) { - const orders = await this.fetchOrders (symbol, since, limit, params); - return this.filterBy (orders, 'status', 'closed'); - } - - async fetchOrders (symbol = undefined, since = undefined, limit = undefined, params = {}) { - return this.fetchOrdersByType ('all', symbol, since, limit, params); - } - - async createOrder (symbol, type, side, amount, price = undefined, params = {}) { - await this.loadMarkets (); - const request = { - 'symbol': this.marketId (symbol), - 'type': side, - 'price': this.priceToPrecision (symbol, price), - 'number': this.amountToPrecision (symbol, amount), - }; - const response = await this.privatePostApiOrderCoinTrust (this.extend (request, params)); - const data = this.safeValue (response, 'data', {}); - const id = this.safeString (data, 'order_id'); - return { - 'info': response, - 'id': id, - }; - } - - async cancelOrder (id, symbol = undefined, params = {}) { - if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' cancelOrder requires a `symbol` argument'); - } - await this.loadMarkets (); - const request = {}; - if (symbol !== undefined) { - request['symbol'] = this.marketId (symbol); - } - if (id !== undefined) { - request['order_id'] = id; - } - return await this.privatePostApiOrderCancel (this.extend (request, params)); - } - - sign (path, api = 'public', method = 'GET', params = {}, headers = undefined, body = undefined) { - let url = this.urls['api'] + '/' + this.implodeParams (path, params); - const query = this.omit (params, this.extractParams (path)); - if (api === 'public') { - if (Object.keys (query).length) { - url += '?' + this.urlencode (query); - } - } else { - this.checkRequiredCredentials (); - let payload = this.urlencode ({ 'api_key': this.apiKey }); - if (Object.keys (query).length) { - payload += '&' + this.urlencode (this.keysort (query)); - } - const auth = payload + '&secret_key=' + this.secret; - const signature = this.hash (this.encode (auth)); - body = payload + '&sign=' + signature; - headers = { - 'Content-Type': 'application/x-www-form-urlencoded', - }; - } - return { 'url': url, 'method': method, 'body': body, 'headers': headers }; - } - - handleErrors (code, reason, url, method, headers, body, response, requestHeaders, requestBody) { - if (response === undefined) { - return; // fallback to default error handler - } - const errorCode = this.safeValue (response, 'code'); - if (errorCode !== undefined) { - if (errorCode !== 0) { - // - // { code: 1, msg: "该币不存在,非法操作" } - returned when a required symbol parameter is missing in the request (also, maybe on other types of errors as well) - // { code: 1, msg: '公钥不合法' } - wrong public key - // { code: 1, msg: '价格输入有误,请检查你的数值精度' } - 'The price input is incorrect, please check your numerical accuracy' - // { code: 1, msg: '单笔最小交易数量不能小于0.00100000,请您重新挂单'} - - // 'The minimum number of single transactions cannot be less than 0.00100000. Please re-post the order' - // - const message = this.safeString (response, 'msg'); - const feedback = this.id + ' ' + message; - this.throwExactlyMatchedException (this.exceptions, message, feedback); - if (message.indexOf ('请您重新挂单') >= 0) { // minimum limit - throw new InvalidOrder (feedback); - } else { - throw new ExchangeError (feedback); - } - } - } - } -}; diff --git a/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/bibox.js b/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/bibox.js index 5f1e30c04..4d46d8f35 100644 --- a/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/bibox.js +++ b/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/bibox.js @@ -3,7 +3,7 @@ // --------------------------------------------------------------------------- const Exchange = require ('./base/Exchange'); -const { ExchangeError, AccountSuspended, ArgumentsRequired, AuthenticationError, DDoSProtection, ExchangeNotAvailable, InvalidOrder, OrderNotFound, PermissionDenied, InsufficientFunds, BadSymbol } = require ('./base/errors'); +const { ExchangeError, AccountSuspended, ArgumentsRequired, AuthenticationError, DDoSProtection, ExchangeNotAvailable, InvalidOrder, OrderNotFound, PermissionDenied, InsufficientFunds, BadSymbol, RateLimitExceeded, BadRequest } = require ('./base/errors'); // --------------------------------------------------------------------------- @@ -71,6 +71,7 @@ module.exports = class bibox extends Exchange { 'get': [ 'cquery', 'mdata', + 'cdata', ], }, 'private': { @@ -108,9 +109,16 @@ module.exports = class bibox extends Exchange { '2021': InsufficientFunds, // Insufficient balance available for withdrawal '2027': InsufficientFunds, // Insufficient balance available (for trade) '2033': OrderNotFound, // operation failed! Orders have been completed or revoked + '2065': InvalidOrder, // Precatory price is exorbitant, please reset + '2066': InvalidOrder, // Precatory price is low, please reset '2067': InvalidOrder, // Does not support market orders '2068': InvalidOrder, // The number of orders can not be less than + '2078': InvalidOrder, // unvalid order price '2085': InvalidOrder, // Order quantity is too small + '2091': RateLimitExceeded, // request is too frequency, please try again later + '2092': InvalidOrder, // Minimum amount not met + '3000': BadRequest, // Requested parameter incorrect + '3002': BadRequest, // Parameter cannot be null '3012': AuthenticationError, // invalid apiKey '3016': BadSymbol, // Trading pair error '3024': PermissionDenied, // wrong apikey permissions @@ -124,6 +132,10 @@ module.exports = class bibox extends Exchange { 'KEY': 'Bihu', 'MTC': 'MTC Mesh Network', // conflict with MTC Docademic doc.com Token https://github.com/ccxt/ccxt/issues/6081 https://github.com/ccxt/ccxt/issues/3025 'PAI': 'PCHAIN', + 'TERN': 'Ternio-ERC20', + }, + 'options': { + 'fetchCurrencies': 'fetch_currencies_public', // or 'fetch_currencies_private' with apiKey and secret }, }); } @@ -423,6 +435,78 @@ module.exports = class bibox extends Exchange { } async fetchCurrencies (params = {}) { + const method = this.safeString (this.options, 'fetchCurrencies', 'fetch_currencies_public'); + return await this[method] (params); + } + + async fetchCurrenciesPublic (params = {}) { + const request = { + 'cmd': 'currencies', + }; + const response = await this.publicGetCdata (this.extend (request, params)); + // + // publicGetCdata + // + // { + // "result":[ + // { + // "symbol":"BTC", + // "name":"BTC", + // "valid_decimals":8, + // "original_decimals":8, + // "is_erc20":0, + // "enable_withdraw":1, + // "enable_deposit":1, + // "withdraw_min":0.005, + // "describe_summary":"[{\"lang\":\"zh-cn\",\"text\":\"Bitcoin 比特币的概念最初由中本聪在2009年提出,是点对点的基于 SHA-256 算法的一种P2P形式的数字货币,点对点的传输意味着一个去中心化的支付系统。\"},{\"lang\":\"en-ww\",\"text\":\"Bitcoin is a digital asset and a payment system invented by Satoshi Nakamoto who published a related paper in 2008 and released it as open-source software in 2009. The system featured as peer-to-peer; users can transact directly without an intermediary.\"}]" + // } + // ], + // "cmd":"currencies" + // } + // + const currencies = this.safeValue (response, 'result'); + const result = {}; + for (let i = 0; i < currencies.length; i++) { + const currency = currencies[i]; + const id = this.safeString (currency, 'symbol'); + const name = this.safeString (currency, 'name'); // contains hieroglyphs causing python ASCII bug + const code = this.safeCurrencyCode (id); + const precision = this.safeInteger (currency, 'valid_decimals'); + const deposit = this.safeValue (currency, 'enable_deposit'); + const withdraw = this.safeValue (currency, 'enable_withdraw'); + const active = (deposit && withdraw); + result[code] = { + 'id': id, + 'code': code, + 'info': currency, + 'name': name, + 'active': active, + 'fee': undefined, + 'precision': precision, + 'limits': { + 'amount': { + 'min': Math.pow (10, -precision), + 'max': undefined, + }, + 'price': { + 'min': Math.pow (10, -precision), + 'max': undefined, + }, + 'cost': { + 'min': undefined, + 'max': undefined, + }, + 'withdraw': { + 'min': this.safeFloat (currency, 'withdraw_min'), + 'max': undefined, + }, + }, + }; + } + return result; + } + + async fetchCurrenciesPrivate (params = {}) { if (!this.apiKey || !this.secret) { throw new AuthenticationError (this.id + " fetchCurrencies is an authenticated endpoint, therefore it requires 'apiKey' and 'secret' credentials. If you don't need currency details, set exchange.has['fetchCurrencies'] = false before calling its methods."); } @@ -435,46 +519,42 @@ module.exports = class bibox extends Exchange { // { // "result":[ // { - // "result":[ - // { - // "totalBalance":"14.57582269", - // "balance":"14.57582269", - // "freeze":"0.00000000", - // "id":60, - // "symbol":"USDT", - // "icon_url":"/appimg/USDT_icon.png", - // "describe_url":"[{\"lang\":\"zh-cn\",\"link\":\"https://bibox.zendesk.com/hc/zh-cn/articles/115004798234\"},{\"lang\":\"en-ww\",\"link\":\"https://bibox.zendesk.com/hc/en-us/articles/115004798234\"}]", - // "name":"USDT", - // "enable_withdraw":1, - // "enable_deposit":1, - // "enable_transfer":1, - // "confirm_count":2, - // "is_erc20":1, - // "forbid_info":null, - // "describe_summary":"[{\"lang\":\"zh-cn\",\"text\":\"USDT 是 Tether 公司推出的基于稳定价值货币美元(USD)的代币 Tether USD(简称USDT),1USDT=1美元,用户可以随时使用 USDT 与 USD 进行1:1的兑换。\"},{\"lang\":\"en-ww\",\"text\":\"USDT is a cryptocurrency asset issued on the Bitcoin blockchain via the Omni Layer Protocol. Each USDT unit is backed by a U.S Dollar held in the reserves of the Tether Limited and can be redeemed through the Tether Platform.\"}]", - // "total_amount":4776930644, - // "supply_amount":4642367414, - // "price":"--", - // "contract_father":"OMNI", - // "supply_time":"--", - // "comment":null, - // "contract":"31", - // "original_decimals":8, - // "deposit_type":0, - // "hasCobo":0, - // "BTCValue":"0.00126358", - // "CNYValue":"100.93381445", - // "USDValue":"14.57524654", - // "children":[ - // {"type":"OMNI","symbol":"USDT","enable_deposit":1,"enable_withdraw":1,"confirm_count":2}, - // {"type":"TRC20","symbol":"tUSDT","enable_deposit":1,"enable_withdraw":1,"confirm_count":20}, - // {"type":"ERC20","symbol":"eUSDT","enable_deposit":1,"enable_withdraw":1,"confirm_count":25} - // ] - // }, - // ], - // "cmd":"transfer/coinList" - // } - // ] + // "totalBalance":"14.57582269", + // "balance":"14.57582269", + // "freeze":"0.00000000", + // "id":60, + // "symbol":"USDT", + // "icon_url":"/appimg/USDT_icon.png", + // "describe_url":"[{\"lang\":\"zh-cn\",\"link\":\"https://bibox.zendesk.com/hc/zh-cn/articles/115004798234\"},{\"lang\":\"en-ww\",\"link\":\"https://bibox.zendesk.com/hc/en-us/articles/115004798234\"}]", + // "name":"USDT", + // "enable_withdraw":1, + // "enable_deposit":1, + // "enable_transfer":1, + // "confirm_count":2, + // "is_erc20":1, + // "forbid_info":null, + // "describe_summary":"[{\"lang\":\"zh-cn\",\"text\":\"USDT 是 Tether 公司推出的基于稳定价值货币美元(USD)的代币 Tether USD(简称USDT),1USDT=1美元,用户可以随时使用 USDT 与 USD 进行1:1的兑换。\"},{\"lang\":\"en-ww\",\"text\":\"USDT is a cryptocurrency asset issued on the Bitcoin blockchain via the Omni Layer Protocol. Each USDT unit is backed by a U.S Dollar held in the reserves of the Tether Limited and can be redeemed through the Tether Platform.\"}]", + // "total_amount":4776930644, + // "supply_amount":4642367414, + // "price":"--", + // "contract_father":"OMNI", + // "supply_time":"--", + // "comment":null, + // "contract":"31", + // "original_decimals":8, + // "deposit_type":0, + // "hasCobo":0, + // "BTCValue":"0.00126358", + // "CNYValue":"100.93381445", + // "USDValue":"14.57524654", + // "children":[ + // {"type":"OMNI","symbol":"USDT","enable_deposit":1,"enable_withdraw":1,"confirm_count":2}, + // {"type":"TRC20","symbol":"tUSDT","enable_deposit":1,"enable_withdraw":1,"confirm_count":20}, + // {"type":"ERC20","symbol":"eUSDT","enable_deposit":1,"enable_withdraw":1,"confirm_count":25} + // ] + // }, + // ], + // "cmd":"transfer/coinList" // } // const currencies = this.safeValue (response, 'result'); @@ -799,6 +879,7 @@ module.exports = class bibox extends Exchange { 'symbol': symbol, 'type': type, 'timeInForce': undefined, + 'postOnly': undefined, 'side': side, 'price': price, 'stopPrice': undefined, @@ -851,7 +932,7 @@ module.exports = class bibox extends Exchange { async fetchClosedOrders (symbol = undefined, since = undefined, limit = 200, params = {}) { if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' fetchClosedOrders requires a `symbol` argument'); + throw new ArgumentsRequired (this.id + ' fetchClosedOrders() requires a `symbol` argument'); } await this.loadMarkets (); const market = this.market (symbol); @@ -871,7 +952,7 @@ module.exports = class bibox extends Exchange { async fetchMyTrades (symbol = undefined, since = undefined, limit = undefined, params = {}) { if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' fetchMyTrades requires a `symbol` argument'); + throw new ArgumentsRequired (this.id + ' fetchMyTrades() requires a `symbol` argument'); } await this.loadMarkets (); const market = this.market (symbol); @@ -998,7 +1079,7 @@ module.exports = class bibox extends Exchange { } } else if (api === 'v2private') { this.checkRequiredCredentials (); - url = this.urls['api'] + '/v2/' + path; + url = this.implodeParams (this.urls['api'], { 'hostname': this.hostname }) + '/v2/' + path; const json_params = this.json (params); body = { 'body': json_params, diff --git a/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/bigone.js b/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/bigone.js index b589aceeb..d6e940c4d 100644 --- a/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/bigone.js +++ b/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/bigone.js @@ -78,6 +78,7 @@ module.exports = class bigone extends Exchange { 'private': { 'get': [ 'accounts', + 'fund/accounts', 'assets/{asset_symbol}/address', 'orders', 'orders/{id}', @@ -91,6 +92,7 @@ module.exports = class bigone extends Exchange { 'orders/{id}/cancel', 'orders/cancel', 'withdrawals', + 'transfer', ], }, }, @@ -645,7 +647,10 @@ module.exports = class bigone extends Exchange { async fetchBalance (params = {}) { await this.loadMarkets (); - const response = await this.privateGetAccounts (params); + const type = this.safeString (params, 'type', ''); + params = this.omit (params, 'type'); + const method = 'privateGet' + this.capitalize (type) + 'Accounts'; + const response = await this[method] (params); // // { // "code":0, @@ -721,6 +726,7 @@ module.exports = class bigone extends Exchange { 'symbol': symbol, 'type': undefined, 'timeInForce': undefined, + 'postOnly': undefined, 'side': side, 'price': price, 'stopPrice': undefined, @@ -758,7 +764,7 @@ module.exports = class bigone extends Exchange { if (isStopLimit || isStopMarket) { const stopPrice = this.safeFloat2 (params, 'stop_price', 'stopPrice'); if (stopPrice === undefined) { - throw new ArgumentsRequired (this.id + ' createOrder requires a stop_price parameter'); + throw new ArgumentsRequired (this.id + ' createOrder() requires a stop_price parameter'); } request['stop_price'] = this.priceToPrecision (symbol, stopPrice); params = this.omit (params, [ 'stop_price', 'stopPrice' ]); diff --git a/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/binance.js b/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/binance.js index c9e459dfb..a115b3f7b 100644 --- a/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/binance.js +++ b/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/binance.js @@ -3,7 +3,7 @@ // --------------------------------------------------------------------------- const Exchange = require ('./base/Exchange'); -const { ExchangeError, ArgumentsRequired, ExchangeNotAvailable, InsufficientFunds, OrderNotFound, InvalidOrder, DDoSProtection, InvalidNonce, AuthenticationError, InvalidAddress, RateLimitExceeded, PermissionDenied, NotSupported, BadRequest, BadSymbol, AccountSuspended, OrderImmediatelyFillable } = require ('./base/errors'); +const { ExchangeError, ArgumentsRequired, ExchangeNotAvailable, InsufficientFunds, OrderNotFound, InvalidOrder, DDoSProtection, InvalidNonce, AuthenticationError, RateLimitExceeded, PermissionDenied, NotSupported, BadRequest, BadSymbol, AccountSuspended, OrderImmediatelyFillable } = require ('./base/errors'); const { ROUND, TRUNCATE } = require ('./base/functions/number'); // --------------------------------------------------------------------------- @@ -23,6 +23,7 @@ module.exports = class binance extends Exchange { 'cancelOrder': true, 'CORS': false, 'createOrder': true, + 'fetchCurrencies': true, 'fetchBalance': true, 'fetchBidsAsks': true, 'fetchClosedOrders': 'emulated', @@ -113,6 +114,7 @@ module.exports = class binance extends Exchange { 'margin/priceIndex', // these endpoints require this.apiKey + this.secret 'asset/assetDividend', + 'asset/transfer', 'margin/loan', 'margin/repay', 'margin/account', @@ -154,6 +156,7 @@ module.exports = class binance extends Exchange { 'sub-account/spotSummary', 'sub-account/status', 'sub-account/transfer/subUserHistory', + 'sub-account/universalTransfer', // lending endpoints 'lending/daily/product/list', 'lending/daily/userLeftQuota', @@ -179,9 +182,23 @@ module.exports = class binance extends Exchange { 'bswap/liquidityOps', 'bswap/quote', 'bswap/swap', + // leveraged token endpoints + 'blvt/tokenInfo', + 'blvt/subscribe/record', + 'blvt/redeem/record', + 'blvt/userLimit', + // broker api + 'apiReferral/ifNewUser', + 'apiReferral/customization', + 'apiReferral/userCustomization', + 'apiReferral/rebate/recentRecord', + 'apiReferral/rebate/historicalRecord', + 'apiReferral/kickback/recentRecord', + 'apiReferral/kickback/historicalRecord', ], 'post': [ 'asset/dust', + 'asset/transfer', 'account/disableFastWithdrawSwitch', 'account/enableFastWithdrawSwitch', 'capital/withdraw/apply', @@ -199,6 +216,7 @@ module.exports = class binance extends Exchange { 'sub-account/futures/internalTransfer', 'sub-account/transfer/subToSub', 'sub-account/transfer/subToMaster', + 'sub-account/universalTransfer', 'userDataStream', 'userDataStream/isolated', 'futures/transfer', @@ -213,12 +231,21 @@ module.exports = class binance extends Exchange { 'bswap/liquidityAdd', 'bswap/liquidityRemove', 'bswap/swap', + // leveraged token endpoints + 'blvt/subscribe', + 'blvt/redeem', + // broker api + 'apiReferral/customization', + 'apiReferral/userCustomization', + 'apiReferral/rebate/historicalRecord', + 'apiReferral/kickback/historicalRecord', ], 'put': [ 'userDataStream', 'userDataStream/isolated', ], 'delete': [ + 'margin/openOrders', 'margin/order', 'userDataStream', 'userDataStream/isolated', @@ -323,6 +350,7 @@ module.exports = class binance extends Exchange { 'historicalTrades', 'aggTrades', 'klines', + 'continuousKlines', 'fundingRate', 'premiumIndex', 'ticker/24hr', @@ -357,6 +385,15 @@ module.exports = class binance extends Exchange { 'positionSide/dual', 'userTrades', 'income', + // broker endpoints + 'apiReferral/ifNewUser', + 'apiReferral/customization', + 'apiReferral/userCustomization', + 'apiReferral/traderNum', + 'apiReferral/overview', + 'apiReferral/tradeVol', + 'apiReferral/rebateVol', + 'apiReferral/traderSummary', ], 'post': [ 'batchOrders', @@ -367,6 +404,9 @@ module.exports = class binance extends Exchange { 'leverage', 'listenKey', 'countdownCancelAll', + // broker endpoints + 'apiReferral/customization', + 'apiReferral/userCustomization', ], 'put': [ 'listenKey', @@ -446,6 +486,7 @@ module.exports = class binance extends Exchange { }, // exchange-specific options 'options': { + 'fetchCurrencies': false, // this is a private call and it requires API keys // 'fetchTradesMethod': 'publicGetAggTrades', // publicGetTrades, publicGetHistoricalTrades 'defaultTimeInForce': 'GTC', // 'GTC' = Good To Cancel (default), 'IOC' = Immediate Or Cancel 'defaultType': 'spot', // 'spot', 'future', 'margin', 'delivery' @@ -460,11 +501,20 @@ module.exports = class binance extends Exchange { 'limit': 'RESULT', // we change it from 'ACK' by default to 'RESULT' }, 'quoteOrderQty': true, // whether market orders support amounts in quote currency + 'broker': { + 'spot': 'x-R4BD3S82', + 'margin': 'x-R4BD3S82', + 'future': 'x-xcKtGhcu', + 'delivery': 'x-xcKtGhcu', + }, }, // https://binance-docs.github.io/apidocs/spot/en/#error-codes-2 'exceptions': { + 'System abnormality': ExchangeError, // {"code":-1000,"msg":"System abnormality"} + 'You are not authorized to execute this request.': PermissionDenied, // {"msg":"You are not authorized to execute this request."} 'API key does not exist': AuthenticationError, 'Order would trigger immediately.': OrderImmediatelyFillable, + 'Stop price would trigger immediately.': OrderImmediatelyFillable, // {"code":-2010,"msg":"Stop price would trigger immediately."} 'Order would immediately match and take.': OrderImmediatelyFillable, // {"code":-2010,"msg":"Order would immediately match and take."} 'Account has insufficient balance for requested action.': InsufficientFunds, 'Rest API trading is not enabled.': ExchangeNotAvailable, @@ -508,14 +558,21 @@ module.exports = class binance extends Exchange { '-2013': OrderNotFound, // fetchOrder (1, 'BTC/USDT') -> 'Order does not exist' '-2014': AuthenticationError, // { "code":-2014, "msg": "API-key format invalid." } '-2015': AuthenticationError, // "Invalid API-key, IP, or permissions for action." + '-2019': InsufficientFunds, // {"code":-2019,"msg":"Margin is insufficient."} '-3005': InsufficientFunds, // {"code":-3005,"msg":"Transferring out not allowed. Transfer out amount exceeds max amount."} '-3008': InsufficientFunds, // {"code":-3008,"msg":"Borrow not allowed. Your borrow amount has exceed maximum borrow amount."} '-3010': ExchangeError, // {"code":-3010,"msg":"Repay not allowed. Repay amount exceeds borrow amount."} '-3022': AccountSuspended, // You account's trading is banned. + '-4028': BadRequest, // {"code":-4028,"msg":"Leverage 100 is not valid"} + '-5013': InsufficientFunds, // Asset transfer failed: insufficient balance" }, }); } + currencyToPrecision (currency, fee) { + return this.numberToString (fee); + } + nonce () { return this.milliseconds () - this.options['timeDifference']; } @@ -539,6 +596,145 @@ module.exports = class binance extends Exchange { return this.options['timeDifference']; } + async fetchCurrencies (params = {}) { + const fetchCurrenciesEnabled = this.safeValue (this.options, 'fetchCurrencies'); + if (!fetchCurrenciesEnabled) { + return undefined; + } + // this endpoint requires authentication + // while fetchCurrencies is a public API method by design + // therefore we check the keys here + // and fallback to generating the currencies from the markets + if (!this.checkRequiredCredentials (false)) { + return undefined; + } + // sandbox/testnet does not support sapi endpoints + const apiBackup = this.safeString (this.urls, 'apiBackup'); + if (apiBackup !== undefined) { + return undefined; + } + const response = await this.sapiGetCapitalConfigGetall (params); + const result = {}; + for (let i = 0; i < response.length; i++) { + // + // { + // coin: 'LINK', + // depositAllEnable: true, + // withdrawAllEnable: true, + // name: 'ChainLink', + // free: '0.06168', + // locked: '0', + // freeze: '0', + // withdrawing: '0', + // ipoing: '0', + // ipoable: '0', + // storage: '0', + // isLegalMoney: false, + // trading: true, + // networkList: [ + // { + // network: 'BNB', + // coin: 'LINK', + // withdrawIntegerMultiple: '0', + // isDefault: false, + // depositEnable: true, + // withdrawEnable: true, + // depositDesc: '', + // withdrawDesc: '', + // specialTips: 'Both a MEMO and an Address are required to successfully deposit your LINK BEP2 tokens to Binance.', + // name: 'BEP2', + // resetAddressStatus: false, + // addressRegex: '^(bnb1)[0-9a-z]{38}$', + // memoRegex: '^[0-9A-Za-z\\-_]{1,120}$', + // withdrawFee: '0.002', + // withdrawMin: '0.01', + // withdrawMax: '9999999', + // minConfirm: 1, + // unLockConfirm: 0 + // }, + // { + // network: 'BSC', + // coin: 'LINK', + // withdrawIntegerMultiple: '0.00000001', + // isDefault: false, + // depositEnable: true, + // withdrawEnable: true, + // depositDesc: '', + // withdrawDesc: '', + // specialTips: '', + // name: 'BEP20 (BSC)', + // resetAddressStatus: false, + // addressRegex: '^(0x)[0-9A-Fa-f]{40}$', + // memoRegex: '', + // withdrawFee: '0.005', + // withdrawMin: '0.01', + // withdrawMax: '9999999', + // minConfirm: 15, + // unLockConfirm: 0 + // }, + // { + // network: 'ETH', + // coin: 'LINK', + // withdrawIntegerMultiple: '0.00000001', + // isDefault: true, + // depositEnable: true, + // withdrawEnable: true, + // depositDesc: '', + // withdrawDesc: '', + // name: 'ERC20', + // resetAddressStatus: false, + // addressRegex: '^(0x)[0-9A-Fa-f]{40}$', + // memoRegex: '', + // withdrawFee: '0.34', + // withdrawMin: '0.68', + // withdrawMax: '0', + // minConfirm: 12, + // unLockConfirm: 0 + // } + // ] + // } + // + const entry = response[i]; + const id = this.safeString (entry, 'coin'); + const name = this.safeString (entry, 'name'); + const code = this.safeCurrencyCode (id); + const precision = undefined; + let isWithdrawEnabled = true; + let isDepositEnabled = true; + const networkList = this.safeValue (entry, 'networkList', []); + const fees = {}; + let fee = undefined; + for (let j = 0; j < networkList.length; j++) { + const networkItem = networkList[j]; + const name = this.safeString (networkItem, 'name'); + const withdrawFee = this.safeFloat (networkItem, 'withdrawFee'); + const depositEnable = this.safeValue (networkItem, 'depositEnable'); + const withdrawEnable = this.safeValue (networkItem, 'withdrawEnable'); + isDepositEnabled = isDepositEnabled || depositEnable; + isWithdrawEnabled = isWithdrawEnabled || withdrawEnable; + fees[name] = withdrawFee; + const isDefault = this.safeValue (networkItem, 'isDefault'); + if (isDefault || fee === undefined) { + fee = withdrawFee; + } + } + const trading = this.safeValue (entry, 'trading'); + const active = (isWithdrawEnabled && isDepositEnabled && trading); + result[code] = { + 'id': id, + 'name': name, + 'code': code, + 'precision': precision, + 'info': entry, + 'active': active, + 'fee': fee, + 'fees': fees, + 'limits': this.limits, + }; + } + return result; + } + async fetchMarkets (params = {}) { const defaultType = this.safeString2 (this.options, 'fetchMarkets', 'defaultType', 'spot'); const type = this.safeString (params, 'type', defaultType); @@ -715,9 +911,8 @@ module.exports = class binance extends Exchange { const quoteId = this.safeString (market, 'quoteAsset'); const base = this.safeCurrencyCode (baseId); const quote = this.safeCurrencyCode (quoteId); - const parts = id.split ('_'); - const lastPart = this.safeString (parts, 1); - const idSymbol = (delivery) && (lastPart !== 'PERP'); + const contractType = this.safeString (market, 'contractType'); + const idSymbol = (future || delivery) && (contractType !== 'PERPETUAL'); const symbol = idSymbol ? id : (base + '/' + quote); const filters = this.safeValue (market, 'filters', []); const filtersByType = this.indexBy (filters, 'filterType'); @@ -795,7 +990,7 @@ module.exports = class binance extends Exchange { } if ('MIN_NOTIONAL' in filtersByType) { const filter = this.safeValue (filtersByType, 'MIN_NOTIONAL', {}); - entry['limits']['cost']['min'] = this.safeFloat (filter, 'minNotional'); + entry['limits']['cost']['min'] = this.safeFloat2 (filter, 'minNotional', 'notional'); } result.push (entry); } @@ -1197,15 +1392,24 @@ module.exports = class binance extends Exchange { async fetchOHLCV (symbol, timeframe = '1m', since = undefined, limit = undefined, params = {}) { await this.loadMarkets (); const market = this.market (symbol); + // binance docs say that the default limit 500, max 1500 for futures, max 1000 for spot markets + // the reality is that the time range wider than 500 candles won't work right + const defaultLimit = 500; + const maxLimit = 1500; + limit = (limit === undefined) ? defaultLimit : Math.min (limit, maxLimit); const request = { 'symbol': market['id'], 'interval': this.timeframes[timeframe], + 'limit': limit, }; + const duration = this.parseTimeframe (timeframe); if (since !== undefined) { request['startTime'] = since; - } - if (limit !== undefined) { - request['limit'] = limit; // default == max == 500 + if (since > 0) { + const endTime = this.sum (since, limit * duration * 1000 - 1); + const now = this.milliseconds (); + request['endTime'] = Math.min (now, endTime); + } } let method = 'publicGetKlines'; if (market['future']) { @@ -1293,6 +1497,23 @@ module.exports = class binance extends Exchange { // "symbol": "BTCUSDT", // "time": 1569514978020 // } + // { + // "symbol": "BTCUSDT", + // "id": 477128891, + // "orderId": 13809777875, + // "side": "SELL", + // "price": "38479.55", + // "qty": "0.001", + // "realizedPnl": "-0.00009534", + // "marginAsset": "USDT", + // "quoteQty": "38.47955", + // "commission": "-0.00076959", + // "commissionAsset": "USDT", + // "time": 1612733566708, + // "positionSide": "BOTH", + // "maker": true, + // "buyer": false + // } // const timestamp = this.safeInteger2 (trade, 'T', 'time'); const price = this.safeFloat2 (trade, 'p', 'price'); @@ -1322,6 +1543,9 @@ module.exports = class binance extends Exchange { if ('isMaker' in trade) { takerOrMaker = trade['isMaker'] ? 'maker' : 'taker'; } + if ('maker' in trade) { + takerOrMaker = trade['maker'] ? 'maker' : 'taker'; + } const marketId = this.safeString (trade, 'symbol'); const symbol = this.safeSymbol (marketId, market); let cost = undefined; @@ -1439,7 +1663,7 @@ module.exports = class binance extends Exchange { 'CANCELED': 'canceled', 'PENDING_CANCEL': 'canceling', // currently unused 'REJECTED': 'rejected', - 'EXPIRED': 'canceled', + 'EXPIRED': 'expired', }; return this.safeString (statuses, status, status); } @@ -1565,6 +1789,8 @@ module.exports = class binance extends Exchange { } const clientOrderId = this.safeString (order, 'clientOrderId'); const timeInForce = this.safeString (order, 'timeInForce'); + const postOnly = (type === 'limit_maker') || (timeInForce === 'GTX'); + const stopPrice = this.safeFloat (order, 'stopPrice'); return { 'info': order, 'id': id, @@ -1575,8 +1801,10 @@ module.exports = class binance extends Exchange { 'symbol': symbol, 'type': type, 'timeInForce': timeInForce, + 'postOnly': postOnly, 'side': side, 'price': price, + 'stopPrice': stopPrice, 'amount': amount, 'cost': cost, 'average': average, @@ -1621,7 +1849,15 @@ module.exports = class binance extends Exchange { 'type': uppercaseType, 'side': side.toUpperCase (), }; - if (clientOrderId !== undefined) { + if (clientOrderId === undefined) { + const broker = this.safeValue (this.options, 'broker'); + if (broker) { + const brokerId = this.safeString (broker, orderType); + if (brokerId !== undefined) { + request['newClientOrderId'] = brokerId + this.uuid22 (); + } + } + } else { request['newClientOrderId'] = clientOrderId; } if (market['spot']) { @@ -1700,7 +1936,7 @@ module.exports = class binance extends Exchange { quantityIsRequired = true; const callbackRate = this.safeFloat (params, 'callbackRate'); if (callbackRate === undefined) { - throw new InvalidOrder (this.id + ' createOrder method requires a callbackRate extra param for a ' + type + ' order'); + throw new InvalidOrder (this.id + ' createOrder() requires a callbackRate extra param for a ' + type + ' order'); } } if (quantityIsRequired) { @@ -1708,7 +1944,7 @@ module.exports = class binance extends Exchange { } if (priceIsRequired) { if (price === undefined) { - throw new InvalidOrder (this.id + ' createOrder method requires a price argument for a ' + type + ' order'); + throw new InvalidOrder (this.id + ' createOrder() requires a price argument for a ' + type + ' order'); } request['price'] = this.priceToPrecision (symbol, price); } @@ -1718,7 +1954,7 @@ module.exports = class binance extends Exchange { if (stopPriceIsRequired) { const stopPrice = this.safeFloat (params, 'stopPrice'); if (stopPrice === undefined) { - throw new InvalidOrder (this.id + ' createOrder method requires a stopPrice extra param for a ' + type + ' order'); + throw new InvalidOrder (this.id + ' createOrder() requires a stopPrice extra param for a ' + type + ' order'); } else { params = this.omit (params, 'stopPrice'); request['stopPrice'] = this.priceToPrecision (symbol, stopPrice); @@ -1730,7 +1966,7 @@ module.exports = class binance extends Exchange { async fetchOrder (id, symbol = undefined, params = {}) { if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' fetchOrder requires a symbol argument'); + throw new ArgumentsRequired (this.id + ' fetchOrder() requires a symbol argument'); } await this.loadMarkets (); const market = this.market (symbol); @@ -1751,7 +1987,7 @@ module.exports = class binance extends Exchange { if (clientOrderId !== undefined) { request['origClientOrderId'] = clientOrderId; } else { - request['orderId'] = parseInt (id); + request['orderId'] = id; } const query = this.omit (params, [ 'type', 'clientOrderId', 'origClientOrderId' ]); const response = await this[method] (this.extend (request, query)); @@ -1760,7 +1996,7 @@ module.exports = class binance extends Exchange { async fetchOrders (symbol = undefined, since = undefined, limit = undefined, params = {}) { if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' fetchOrders requires a symbol argument'); + throw new ArgumentsRequired (this.id + ' fetchOrders() requires a symbol argument'); } await this.loadMarkets (); const market = this.market (symbol); @@ -1873,7 +2109,7 @@ module.exports = class binance extends Exchange { async cancelOrder (id, symbol = undefined, params = {}) { if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' cancelOrder requires a symbol argument'); + throw new ArgumentsRequired (this.id + ' cancelOrder() requires a symbol argument'); } await this.loadMarkets (); const market = this.market (symbol); @@ -1883,11 +2119,11 @@ module.exports = class binance extends Exchange { const origClientOrderId = this.safeValue2 (params, 'origClientOrderId', 'clientOrderId'); const request = { 'symbol': market['id'], - // 'orderId': parseInt (id), + // 'orderId': id, // 'origClientOrderId': id, }; if (origClientOrderId === undefined) { - request['orderId'] = parseInt (id); + request['orderId'] = id; } else { request['origClientOrderId'] = origClientOrderId; } @@ -1906,7 +2142,7 @@ module.exports = class binance extends Exchange { async cancelAllOrders (symbol = undefined, params = {}) { if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' cancelAllOrders requires a symbol argument'); + throw new ArgumentsRequired (this.id + ' cancelAllOrders() requires a symbol argument'); } await this.loadMarkets (); const market = this.market (symbol); @@ -1917,7 +2153,9 @@ module.exports = class binance extends Exchange { const type = this.safeString (params, 'type', defaultType); const query = this.omit (params, 'type'); let method = 'privateDeleteOpenOrders'; - if (type === 'future') { + if (type === 'margin') { + method = 'sapiDeleteMarginOpenOrders'; + } else if (type === 'future') { method = 'fapiPrivateDeleteAllOpenOrders'; } else if (type === 'delivery') { method = 'dapiPrivateDeleteAllOpenOrders'; @@ -1983,20 +2221,23 @@ module.exports = class binance extends Exchange { async fetchMyTrades (symbol = undefined, since = undefined, limit = undefined, params = {}) { if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' fetchMyTrades requires a symbol argument'); + throw new ArgumentsRequired (this.id + ' fetchMyTrades() requires a symbol argument'); } await this.loadMarkets (); const market = this.market (symbol); - const type = this.safeValue (params, 'type', market['type']); + const defaultType = this.safeString2 (this.options, 'fetchMyTrades', 'defaultType', market['type']); + const type = this.safeString (params, 'type', defaultType); + params = this.omit (params, 'type'); let method = undefined; if (type === 'spot') { method = 'privateGetMyTrades'; + } else if (type === 'margin') { + method = 'sapiGetMarginMyTrades'; } else if (type === 'future') { method = 'fapiPrivateGetUserTrades'; } else if (type === 'delivery') { method = 'dapiPrivateGetUserTrades'; } - params = this.omit (params, 'type'); const request = { 'symbol': market['id'], }; @@ -2280,7 +2521,10 @@ module.exports = class binance extends Exchange { tag = undefined; } } - const txid = this.safeString (transaction, 'txId'); + let txid = this.safeString (transaction, 'txId'); + if ((txid !== undefined) && (txid.indexOf ('Internal transfer ') >= 0)) { + txid = txid.slice (18); + } const currencyId = this.safeString (transaction, 'asset'); const code = this.safeCurrencyCode (currencyId, currency); let timestamp = undefined; @@ -2329,15 +2573,27 @@ module.exports = class binance extends Exchange { await this.loadMarkets (); const currency = this.currency (code); const request = { - 'asset': currency['id'], + 'coin': currency['id'], + // 'network': 'ETH', // 'BSC', 'XMR', you can get network and isDefault in networkList in the response of sapiGetCapitalConfigDetail }; - const response = await this.wapiGetDepositAddress (this.extend (request, params)); - const success = this.safeValue (response, 'success'); - if ((success === undefined) || !success) { - throw new InvalidAddress (this.id + ' fetchDepositAddress returned an empty response – create the deposit address in the user settings first.'); - } + // has support for the 'network' parameter + // https://binance-docs.github.io/apidocs/spot/en/#deposit-address-supporting-network-user_data + const response = await this.sapiGetCapitalDepositAddress (this.extend (request, params)); + // + // { + // currency: 'XRP', + // address: 'rEb8TK3gBgk5auZkwc6sHnwrGVJH8DuaLh', + // tag: '108618262', + // info: { + // coin: 'XRP', + // address: 'rEb8TK3gBgk5auZkwc6sHnwrGVJH8DuaLh', + // tag: '108618262', + // url: 'https://bithomp.com/explorer/rEb8TK3gBgk5auZkwc6sHnwrGVJH8DuaLh' + // } + // } + // const address = this.safeString (response, 'address'); - const tag = this.safeString (response, 'addressTag'); + const tag = this.safeString (response, 'tag'); this.checkAddress (address); return { 'currency': code, @@ -2515,7 +2771,7 @@ module.exports = class binance extends Exchange { 'timestamp': this.nonce (), 'recvWindow': recvWindow, }, params)); - } else if (path === 'batchOrders') { + } else if ((path === 'batchOrders') || (path.indexOf ('sub-account') >= 0)) { query = this.rawencode (this.extend ({ 'timestamp': this.nonce (), 'recvWindow': recvWindow, diff --git a/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/binanceus.js b/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/binanceus.js index c35f3f3e4..f7bd5c19c 100644 --- a/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/binanceus.js +++ b/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/binanceus.js @@ -42,5 +42,9 @@ module.exports = class binanceus extends binance { }, }); } + + async fetchCurrencies (params = {}) { + return undefined; + } }; diff --git a/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/bit2c.js b/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/bit2c.js index f09a98746..a4d60733a 100644 --- a/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/bit2c.js +++ b/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/bit2c.js @@ -306,6 +306,7 @@ module.exports = class bit2c extends Exchange { 'symbol': symbol, 'type': undefined, 'timeInForce': undefined, + 'postOnly': undefined, 'side': side, 'price': price, 'stopPrice': undefined, diff --git a/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/bitbank.js b/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/bitbank.js index 722f16be6..d357531d7 100644 --- a/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/bitbank.js +++ b/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/bitbank.js @@ -82,6 +82,8 @@ module.exports = class bitbank extends Exchange { 'BCH/JPY': { 'id': 'bcc_jpy', 'symbol': 'BCH/JPY', 'base': 'BCH', 'quote': 'JPY', 'baseId': 'bcc', 'quoteId': 'jpy' }, 'MONA/BTC': { 'id': 'mona_btc', 'symbol': 'MONA/BTC', 'base': 'MONA', 'quote': 'BTC', 'baseId': 'mona', 'quoteId': 'btc' }, 'MONA/JPY': { 'id': 'mona_jpy', 'symbol': 'MONA/JPY', 'base': 'MONA', 'quote': 'JPY', 'baseId': 'mona', 'quoteId': 'jpy' }, + 'QTUM/BTC': { 'id': 'qtum_btc', 'symbol': 'QTUM/BTC', 'base': 'QTUM', 'quote': 'BTC', 'baseId': 'qtum', 'quoteId': 'btc' }, + 'QTUM/JPY': { 'id': 'qtum_jpy', 'symbol': 'QTUM/JPY', 'base': 'QTUM', 'quote': 'JPY', 'baseId': 'qtum', 'quoteId': 'jpy' }, 'ETH/BTC': { 'id': 'eth_btc', 'symbol': 'ETH/BTC', 'base': 'ETH', 'quote': 'BTC', 'baseId': 'eth', 'quoteId': 'btc' }, 'LTC/BTC': { 'id': 'ltc_btc', 'symbol': 'LTC/BTC', 'base': 'LTC', 'quote': 'BTC', 'baseId': 'ltc', 'quoteId': 'btc' }, 'XRP/JPY': { 'id': 'xrp_jpy', 'symbol': 'XRP/JPY', 'base': 'XRP', 'quote': 'JPY', 'baseId': 'xrp', 'quoteId': 'jpy' }, @@ -90,6 +92,7 @@ module.exports = class bitbank extends Exchange { 'ETH/JPY': { 'id': 'eth_jpy', 'symbol': 'ETH/JPY', 'base': 'ETH', 'quote': 'JPY', 'baseId': 'eth', 'quoteId': 'jpy' }, 'LTC/JPY': { 'id': 'ltc_jpy', 'symbol': 'LTC/JPY', 'base': 'LTC', 'quote': 'JPY', 'baseId': 'ltc', 'quoteId': 'jpy' }, 'XRP/BTC': { 'id': 'xrp_btc', 'symbol': 'XRP/BTC', 'base': 'XRP', 'quote': 'BTC', 'baseId': 'xrp', 'quoteId': 'btc' }, + 'XLM/BTC': { 'id': 'xlm_btc', 'symbol': 'XLM/BTC', 'base': 'XLM', 'quote': 'BTC', 'baseId': 'xlm', 'quoteId': 'btc' }, }, 'fees': { 'trading': { @@ -207,8 +210,8 @@ module.exports = class bitbank extends Exchange { const feeCost = this.safeFloat (trade, 'fee_amount_quote'); if (feeCost !== undefined) { fee = { - 'currency': market['quote'], - 'cost': feeCurrency, + 'currency': feeCurrency, + 'cost': feeCost, }; } const orderId = this.safeString (trade, 'order_id'); @@ -367,6 +370,7 @@ module.exports = class bitbank extends Exchange { 'symbol': symbol, 'type': type, 'timeInForce': undefined, + 'postOnly': undefined, 'side': side, 'price': price, 'stopPrice': undefined, @@ -385,7 +389,7 @@ module.exports = class bitbank extends Exchange { await this.loadMarkets (); const market = this.market (symbol); if (price === undefined) { - throw new InvalidOrder (this.id + ' createOrder requires a price argument for both market and limit orders'); + throw new InvalidOrder (this.id + ' createOrder() requires a price argument for both market and limit orders'); } const request = { 'pair': market['id'], diff --git a/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/bitbay.js b/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/bitbay.js index f1cb3a288..4f502e934 100644 --- a/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/bitbay.js +++ b/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/bitbay.js @@ -351,6 +351,7 @@ module.exports = class bitbay extends Exchange { filled = Math.max (0, amount - remaining); } } + const postOnly = this.safeValue (order, 'postOnly'); return { 'id': this.safeString (order, 'id'), 'clientOrderId': undefined, @@ -362,6 +363,7 @@ module.exports = class bitbay extends Exchange { 'symbol': symbol, 'type': this.safeString (order, 'mode'), 'timeInForce': undefined, + 'postOnly': postOnly, 'side': this.safeStringLower (order, 'offerType'), 'price': this.safeFloat (order, 'rate'), 'stopPrice': undefined, diff --git a/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/bitfinex.js b/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/bitfinex.js index ed9038a81..6d34687ff 100644 --- a/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/bitfinex.js +++ b/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/bitfinex.js @@ -16,7 +16,6 @@ module.exports = class bitfinex extends Exchange { 'countries': [ 'VG' ], 'version': 'v1', 'rateLimit': 1500, - 'certified': true, 'pro': true, // new metainfo interface 'has': { @@ -54,6 +53,7 @@ module.exports = class bitfinex extends Exchange { '30m': '30m', '1h': '1h', '3h': '3h', + '4h': '4h', '6h': '6h', '12h': '12h', '1d': '1D', @@ -600,13 +600,32 @@ module.exports = class bitfinex extends Exchange { async fetchBalance (params = {}) { await this.loadMarkets (); + const types = { + 'exchange': 'exchange', + 'deposit': 'funding', + 'trading': 'margin', + }; const balanceType = this.safeString (params, 'type', 'exchange'); const query = this.omit (params, 'type'); const response = await this.privatePostBalances (query); + // [ { type: 'deposit', + // currency: 'btc', + // amount: '0.00116721', + // available: '0.00116721' }, + // { type: 'exchange', + // currency: 'ust', + // amount: '0.0000002', + // available: '0.0000002' }, + // { type: 'trading', + // currency: 'btc', + // amount: '0.0005', + // available: '0.0005' } ], const result = { 'info': response }; for (let i = 0; i < response.length; i++) { const balance = response[i]; - if (balance['type'] === balanceType) { + const type = this.safeString (balance, 'type'); + const parsedType = this.safeString (types, type); + if ((parsedType === balanceType) || (type === balanceType)) { const currencyId = this.safeString (balance, 'currency'); const code = this.safeCurrencyCode (currencyId); // bitfinex had BCH previously, now it's BAB, but the old @@ -769,7 +788,7 @@ module.exports = class bitfinex extends Exchange { async fetchMyTrades (symbol = undefined, since = undefined, limit = undefined, params = {}) { if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' fetchMyTrades requires a `symbol` argument'); + throw new ArgumentsRequired (this.id + ' fetchMyTrades() requires a `symbol` argument'); } await this.loadMarkets (); const market = this.market (symbol); @@ -887,6 +906,7 @@ module.exports = class bitfinex extends Exchange { 'symbol': symbol, 'type': orderType, 'timeInForce': undefined, + 'postOnly': undefined, 'side': side, 'price': this.safeFloat (order, 'price'), 'stopPrice': undefined, diff --git a/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/bitfinex2.js b/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/bitfinex2.js index 5c44875e0..b47da9faf 100644 --- a/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/bitfinex2.js +++ b/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/bitfinex2.js @@ -3,7 +3,7 @@ // --------------------------------------------------------------------------- const bitfinex = require ('./bitfinex.js'); -const { ExchangeError, InvalidAddress, ArgumentsRequired, InsufficientFunds, AuthenticationError, OrderNotFound, InvalidOrder, BadRequest, InvalidNonce, BadSymbol, OnMaintenance } = require ('./base/errors'); +const { ExchangeError, InvalidAddress, ArgumentsRequired, InsufficientFunds, AuthenticationError, OrderNotFound, InvalidOrder, BadRequest, InvalidNonce, BadSymbol, OnMaintenance, NotSupported } = require ('./base/errors'); // --------------------------------------------------------------------------- @@ -53,6 +53,7 @@ module.exports = class bitfinex2 extends bitfinex { '30m': '30m', '1h': '1h', '3h': '3h', + '4h': '4h', '6h': '6h', '12h': '12h', '1d': '1D', @@ -171,7 +172,9 @@ module.exports = class bitfinex2 extends bitfinex { 'auth/w/position/claim', 'auth/r/positions/hist', 'auth/r/positions/audit', + 'auth/r/positions/snap', 'auth/w/deriv/collateral/set', + 'auth/w/deriv/collateral/limits', 'auth/r/funding/offers', 'auth/r/funding/offers/{symbol}', 'auth/w/funding/offer/submit', @@ -583,6 +586,10 @@ module.exports = class bitfinex2 extends bitfinex { return this.parseBalance (result); } + async fetchOrder (id, symbol = undefined, params = {}) { + throw new NotSupported (this.id + ' fetchOrder is not implemented yet'); + } + async fetchOrderBook (symbol, limit = undefined, params = {}) { await this.loadMarkets (); const precision = this.safeValue (this.options, 'precision', 'R0'); @@ -923,6 +930,7 @@ module.exports = class bitfinex2 extends bitfinex { 'symbol': symbol, 'type': type, 'timeInForce': undefined, + 'postOnly': undefined, 'side': side, 'price': price, 'stopPrice': undefined, @@ -941,16 +949,43 @@ module.exports = class bitfinex2 extends bitfinex { await this.loadMarkets (); const market = this.market (symbol); const orderTypes = this.safeValue (this.options, 'orderTypes', {}); - const orderType = this.safeString (orderTypes, type, type); + const orderType = this.safeStringUpper (orderTypes, type, type); amount = (side === 'sell') ? -amount : amount; const request = { 'symbol': market['id'], 'type': orderType, 'amount': this.numberToString (amount), }; - if (type !== 'market') { + if ((orderType === 'LIMIT') || (orderType === 'EXCHANGE LIMIT')) { + request['price'] = this.numberToString (price); + } else if ((orderType === 'STOP') || (orderType === 'EXCHANGE STOP')) { + const stopPrice = this.safeFloat (params, 'stopPrice', price); + request['price'] = this.numberToString (stopPrice); + } else if ((orderType === 'STOP LIMIT') || (orderType === 'EXCHANGE STOP LIMIT')) { + const priceAuxLimit = this.safeFloat (params, 'price_aux_limit'); + let stopPrice = this.safeFloat (params, 'stopPrice'); + if (priceAuxLimit === undefined) { + if (stopPrice === undefined) { + throw new ArgumentsRequired (this.id + ' createOrder() requires a stopPrice parameter or a price_aux_limit parameter for a ' + orderType + ' order'); + } else { + request['price_aux_limit'] = this.numberToString (price); + } + } else { + request['price_aux_limit'] = this.numberToString (priceAuxLimit); + if (stopPrice === undefined) { + stopPrice = price; + } + } + request['price'] = this.numberToString (stopPrice); + } else if ((orderType === 'TRAILING STOP') || (orderType === 'EXCHANGE TRAILING STOP')) { + const priceTrailing = this.safeFloat (params, 'price_trailing'); + request['price_trailing'] = this.numberToString (priceTrailing); + const stopPrice = this.safeFloat (params, 'stopPrice', price); + request['price'] = this.numberToString (stopPrice); + } else if ((orderType === 'FOK') || (orderType === 'EXCHANGE FOK') || (orderType === 'IOC') || (orderType === 'EXCHANGE IOC')) { request['price'] = this.numberToString (price); } + params = this.omit (params, [ 'stopPrice', 'price_aux_limit', 'price_trailing' ]); const clientOrderId = this.safeValue2 (params, 'cid', 'clientOrderId'); if (clientOrderId !== undefined) { request['cid'] = clientOrderId; diff --git a/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/bitflyer.js b/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/bitflyer.js index 99c60448b..f9c19b59a 100644 --- a/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/bitflyer.js +++ b/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/bitflyer.js @@ -365,6 +365,7 @@ module.exports = class bitflyer extends Exchange { 'symbol': symbol, 'type': type, 'timeInForce': undefined, + 'postOnly': undefined, 'side': side, 'price': price, 'stopPrice': undefined, @@ -424,7 +425,7 @@ module.exports = class bitflyer extends Exchange { async fetchMyTrades (symbol = undefined, since = undefined, limit = undefined, params = {}) { if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' fetchMyTrades requires a `symbol` argument'); + throw new ArgumentsRequired (this.id + ' fetchMyTrades() requires a `symbol` argument'); } await this.loadMarkets (); const market = this.market (symbol); @@ -440,7 +441,7 @@ module.exports = class bitflyer extends Exchange { async fetchPositions (symbols = undefined, since = undefined, limit = undefined, params = {}) { if (symbols === undefined) { - throw new ArgumentsRequired (this.id + ' fetchPositions requires a `symbols` argument, exactly one symbol in an array'); + throw new ArgumentsRequired (this.id + ' fetchPositions() requires a `symbols` argument, exactly one symbol in an array'); } await this.loadMarkets (); const request = { diff --git a/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/bitforex.js b/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/bitforex.js index 9932a4d34..8fa337979 100644 --- a/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/bitforex.js +++ b/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/bitforex.js @@ -3,7 +3,7 @@ // --------------------------------------------------------------------------- const Exchange = require ('./base/Exchange'); -const { ExchangeError, AuthenticationError, OrderNotFound, InsufficientFunds, DDoSProtection, PermissionDenied } = require ('./base/errors'); +const { ExchangeError, AuthenticationError, OrderNotFound, InsufficientFunds, DDoSProtection, PermissionDenied, BadSymbol } = require ('./base/errors'); // --------------------------------------------------------------------------- @@ -223,6 +223,7 @@ module.exports = class bitforex extends Exchange { }, 'commonCurrencies': { 'CREDIT': 'TerraCredit', + 'HBC': 'Hybrid Bank Cash', 'IQ': 'IQ.Cash', 'UOS': 'UOS Network', }, @@ -231,6 +232,7 @@ module.exports = class bitforex extends Exchange { '1013': AuthenticationError, '1016': AuthenticationError, '1017': PermissionDenied, // {"code":"1017","success":false,"time":1602670594367,"message":"IP not allow"} + '1019': BadSymbol, // {"code":"1019","success":false,"time":1607087743778,"message":"Symbol Invalid"} '3002': InsufficientFunds, '10204': DDoSProtection, }, @@ -499,6 +501,7 @@ module.exports = class bitforex extends Exchange { 'symbol': symbol, 'type': type, 'timeInForce': undefined, + 'postOnly': undefined, 'side': side, 'price': price, 'stopPrice': undefined, diff --git a/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/bitget.js b/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/bitget.js index 78e7fe8aa..3c9581955 100644 --- a/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/bitget.js +++ b/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/bitget.js @@ -1704,7 +1704,7 @@ module.exports = class bitget extends Exchange { const type = this.safeString (params, 'type', defaultType); params = this.omit (params, 'type'); if (type === undefined) { - throw new ArgumentsRequired (this.id + " requires an 'accountId' parameter"); + throw new ArgumentsRequired (this.id + " getAccountId() requires an 'accountId' parameter"); } const account = await this.findAccountByType (type); return account['id']; @@ -1716,7 +1716,7 @@ module.exports = class bitget extends Exchange { const defaultType = this.safeString2 (this.options, 'fetchBalance', 'defaultType'); const type = this.safeString (params, 'type', defaultType); if (type === undefined) { - throw new ArgumentsRequired (this.id + " fetchBalance requires a 'type' parameter, one of 'spot', 'swap'"); + throw new ArgumentsRequired (this.id + " fetchBalance() requires a 'type' parameter, one of 'spot', 'swap'"); } let method = undefined; const query = this.omit (params, 'type'); @@ -1960,6 +1960,7 @@ module.exports = class bitget extends Exchange { 'symbol': symbol, 'type': type, 'timeInForce': undefined, + 'postOnly': undefined, 'side': side, 'price': price, 'stopPrice': undefined, @@ -2042,7 +2043,7 @@ module.exports = class bitget extends Exchange { request['client_oid'] = clientOrderId; const orderType = this.safeString (params, 'type'); if (orderType === undefined) { - throw new ArgumentsRequired (this.id + " createOrder requires a type parameter, '1' = open long, '2' = open short, '3' = close long, '4' = close short for " + market['type'] + ' orders'); + throw new ArgumentsRequired (this.id + " createOrder() requires a type parameter, '1' = open long, '2' = open short, '3' = close long, '4' = close short for " + market['type'] + ' orders'); } request['size'] = this.amountToPrecision (symbol, amount); request['type'] = orderType; @@ -2084,7 +2085,7 @@ module.exports = class bitget extends Exchange { const type = this.safeString (params, 'type', defaultType); if (type === 'spot') { if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' cancelOrder requires a symbol argument for spot orders'); + throw new ArgumentsRequired (this.id + ' cancelOrder() requires a symbol argument for spot orders'); } } } else { @@ -2125,14 +2126,15 @@ module.exports = class bitget extends Exchange { async cancelOrders (ids, symbol = undefined, params = {}) { if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' cancelOrders requires a symbol argument'); + throw new ArgumentsRequired (this.id + ' cancelOrders() requires a symbol argument'); } await this.loadMarkets (); const market = this.market (symbol); const type = this.safeString (params, 'type', market['type']); if (type === undefined) { - throw new ArgumentsRequired (this.id + " cancelOrders requires a type parameter (one of 'spot', 'swap')."); + throw new ArgumentsRequired (this.id + " cancelOrders() requires a type parameter (one of 'spot', 'swap')."); } + params = this.omit (params, 'type'); const request = {}; let method = undefined; if (type === 'spot') { @@ -2189,13 +2191,13 @@ module.exports = class bitget extends Exchange { async fetchOrder (id, symbol = undefined, params = {}) { if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' fetchOrder requires a symbol argument'); + throw new ArgumentsRequired (this.id + ' fetchOrder() requires a symbol argument'); } await this.loadMarkets (); const market = this.market (symbol); const type = this.safeString (params, 'type', market['type']); if (type === undefined) { - throw new ArgumentsRequired (this.id + " fetchOrder requires a type parameter (one of 'spot', 'swap')."); + throw new ArgumentsRequired (this.id + " fetchOrder() requires a type parameter (one of 'spot', 'swap')."); } let method = undefined; const request = {}; @@ -2266,7 +2268,7 @@ module.exports = class bitget extends Exchange { async fetchOpenOrders (symbol = undefined, since = undefined, limit = undefined, params = {}) { if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' fetchOpenOrders requires a symbol argument'); + throw new ArgumentsRequired (this.id + ' fetchOpenOrders() requires a symbol argument'); } await this.loadMarkets (); const market = this.market (symbol); @@ -2351,7 +2353,7 @@ module.exports = class bitget extends Exchange { async fetchClosedOrders (symbol = undefined, since = undefined, limit = undefined, params = {}) { if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' fetchClosedOrders requires a symbol argument'); + throw new ArgumentsRequired (this.id + ' fetchClosedOrders() requires a symbol argument'); } await this.loadMarkets (); const market = this.market (symbol); @@ -2443,7 +2445,7 @@ module.exports = class bitget extends Exchange { async fetchDeposits (code = undefined, since = undefined, limit = undefined, params = {}) { if (code === undefined) { - throw new ArgumentsRequired (this.id + ' fetchDeposits requires a currency code argument'); + throw new ArgumentsRequired (this.id + ' fetchDeposits() requires a currency code argument'); } await this.loadMarkets (); const currency = this.currency (code); @@ -2480,7 +2482,7 @@ module.exports = class bitget extends Exchange { async fetchWithdrawals (code = undefined, since = undefined, limit = undefined, params = {}) { if (code === undefined) { - throw new ArgumentsRequired (this.id + ' fetchWithdrawals requires a currency code argument'); + throw new ArgumentsRequired (this.id + ' fetchWithdrawals() requires a currency code argument'); } await this.loadMarkets (); const currency = this.currency (code); @@ -2603,14 +2605,14 @@ module.exports = class bitget extends Exchange { async fetchMyTrades (symbol = undefined, since = undefined, limit = undefined, params = {}) { if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' fetchMyTrades requires a symbol argument'); + throw new ArgumentsRequired (this.id + ' fetchMyTrades() requires a symbol argument'); } await this.loadMarkets (); const market = this.market (symbol); const type = this.safeString (params, 'type', market['type']); const query = this.omit (params, 'type'); if (type === 'swap') { - throw new ArgumentsRequired (this.id + ' fetchMyTrades is not supported for ' + type + ' type'); + throw new ArgumentsRequired (this.id + ' fetchMyTrades() is not supported for ' + type + ' type'); } // // spot @@ -2667,12 +2669,12 @@ module.exports = class bitget extends Exchange { async fetchOrderTrades (id, symbol = undefined, since = undefined, limit = undefined, params = {}) { if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' fetchOrderTrades requires a symbol argument'); + throw new ArgumentsRequired (this.id + ' fetchOrderTrades() requires a symbol argument'); } await this.loadMarkets (); const market = this.market (symbol); const type = this.safeString (params, 'type', market['type']); - const query = this.omit (params, 'type'); + params = this.omit (params, 'type'); let method = undefined; const request = {}; if (type === 'spot') { @@ -2684,7 +2686,7 @@ module.exports = class bitget extends Exchange { request['symbol'] = market['id']; method = 'swapGetOrderFills'; } - const response = await this[method] (this.extend (request, query)); + const response = await this[method] (this.extend (request, params)); // // spot // diff --git a/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/bithumb.js b/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/bithumb.js index 904b8715d..ef4e7d479 100644 --- a/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/bithumb.js +++ b/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/bithumb.js @@ -22,6 +22,7 @@ module.exports = class bithumb extends Exchange { 'createOrder': true, 'fetchBalance': true, 'fetchMarkets': true, + 'fetchOHLCV': true, 'fetchOpenOrders': true, 'fetchOrder': true, 'fetchOrderBook': true, @@ -45,10 +46,13 @@ module.exports = class bithumb extends Exchange { 'get': [ 'ticker/{currency}', 'ticker/all', + 'ticker/ALL_BTC', + 'ticker/ALL_KRW', 'orderbook/{currency}', 'orderbook/all', 'transaction_history/{currency}', 'transaction_history/all', + 'candlestick/{currency}/{interval}', ], }, 'private': { @@ -92,6 +96,27 @@ module.exports = class bithumb extends Exchange { 'Unknown Error': ExchangeError, 'After May 23th, recent_transactions is no longer, hence users will not be able to connect to recent_transactions': ExchangeError, // {"status":"5100","message":"After May 23th, recent_transactions is no longer, hence users will not be able to connect to recent_transactions"} }, + 'timeframes': { + '1m': '1m', + '3m': '3m', + '5m': '5m', + '10m': '10m', + '30m': '30m', + '1h': '1h', + '6h': '6h', + '12h': '12h', + '1d': '24h', + }, + 'options': { + 'quoteCurrencies': { + 'BTC': { + 'precision': { + 'price': 8, + }, + }, + 'KRW': {}, + }, + }, }); } @@ -100,54 +125,61 @@ module.exports = class bithumb extends Exchange { } async fetchMarkets (params = {}) { - const response = await this.publicGetTickerAll (params); - const data = this.safeValue (response, 'data'); - const currencyIds = Object.keys (data); const result = []; - const quote = this.safeCurrencyCode ('KRW'); - for (let i = 0; i < currencyIds.length; i++) { - const currencyId = currencyIds[i]; - if (currencyId === 'date') { - continue; - } - const market = data[currencyId]; - const base = this.safeCurrencyCode (currencyId); - const symbol = currencyId + '/' + quote; - let active = true; - if (Array.isArray (market)) { - const numElements = market.length; - if (numElements === 0) { - active = false; + const quoteCurrencies = this.safeValue (this.options, 'quoteCurrencies', {}); + const quotes = Object.keys (quoteCurrencies); + for (let i = 0; i < quotes.length; i++) { + const quote = quotes[i]; + const extension = this.safeValue (quoteCurrencies, quote, {}); + const method = 'publicGetTickerALL' + quote; + const response = await this[method] (params); + const data = this.safeValue (response, 'data'); + const currencyIds = Object.keys (data); + for (let j = 0; j < currencyIds.length; j++) { + const currencyId = currencyIds[j]; + if (currencyId === 'date') { + continue; } + const market = data[currencyId]; + const base = this.safeCurrencyCode (currencyId); + const symbol = currencyId + '/' + quote; + let active = true; + if (Array.isArray (market)) { + const numElements = market.length; + if (numElements === 0) { + active = false; + } + } + const entry = this.deepExtend ({ + 'id': currencyId, + 'symbol': symbol, + 'base': base, + 'quote': quote, + 'info': market, + 'active': active, + 'precision': { + 'amount': 4, + 'price': 4, + }, + 'limits': { + 'amount': { + 'min': undefined, + 'max': undefined, + }, + 'price': { + 'min': undefined, + 'max': undefined, + }, + 'cost': { + 'min': 500, + 'max': 5000000000, + }, + }, + 'baseId': undefined, + 'quoteId': undefined, + }, extension); + result.push (entry); } - result.push ({ - 'id': currencyId, - 'symbol': symbol, - 'base': base, - 'quote': quote, - 'info': market, - 'active': active, - 'precision': { - 'amount': 4, - 'price': 4, - }, - 'limits': { - 'amount': { - 'min': undefined, - 'max': undefined, - }, - 'price': { - 'min': undefined, - 'max': undefined, - }, - 'cost': { - 'min': 500, - 'max': 5000000000, - }, - }, - 'baseId': undefined, - 'quoteId': undefined, - }); } return result; } @@ -349,6 +381,62 @@ module.exports = class bithumb extends Exchange { return this.parseTicker (data, market); } + parseOHLCV (ohlcv, market = undefined) { + // + // [ + // 1576823400000, // 기준 시간 + // '8284000', // 시가 + // '8286000', // 종가 + // '8289000', // 고가 + // '8276000', // 저가 + // '15.41503692' // 거래량 + // ] + // + return [ + this.safeInteger (ohlcv, 0), + this.safeFloat (ohlcv, 1), + this.safeFloat (ohlcv, 3), + this.safeFloat (ohlcv, 4), + this.safeFloat (ohlcv, 2), + this.safeFloat (ohlcv, 5), + ]; + } + + async fetchOHLCV (symbol, timeframe = '1m', since = undefined, limit = undefined, params = {}) { + await this.loadMarkets (); + const market = this.market (symbol); + const request = { + 'currency': market['base'], + 'interval': this.timeframes[timeframe], + }; + const response = await this.publicGetCandlestickCurrencyInterval (this.extend (request, params)); + // + // { + // 'status': '0000', + // 'data': { + // [ + // 1576823400000, // 기준 시간 + // '8284000', // 시가 + // '8286000', // 종가 + // '8289000', // 고가 + // '8276000', // 저가 + // '15.41503692' // 거래량 + // ], + // [ + // 1576824000000, // 기준 시간 + // '8284000', // 시가 + // '8281000', // 종가 + // '8289000', // 고가 + // '8275000', // 저가 + // '6.19584467' // 거래량 + // ], + // } + // } + // + const data = this.safeValue (response, 'data', []); + return this.parseOHLCVs (data, market, timeframe, since, limit); + } + parseTrade (trade, market = undefined) { // // fetchTrades (public) @@ -470,7 +558,7 @@ module.exports = class bithumb extends Exchange { const market = this.market (symbol); const request = { 'order_currency': market['id'], - 'Payment_currency': market['quote'], + 'payment_currency': market['quote'], 'units': amount, }; let method = 'privatePostTradePlace'; @@ -483,7 +571,7 @@ module.exports = class bithumb extends Exchange { const response = await this[method] (this.extend (request, params)); const id = this.safeString (response, 'order_id'); if (id === undefined) { - throw new InvalidOrder (this.id + ' createOrder did not return an order id'); + throw new InvalidOrder (this.id + ' createOrder() did not return an order id'); } return { 'info': response, @@ -496,7 +584,7 @@ module.exports = class bithumb extends Exchange { async fetchOrder (id, symbol = undefined, params = {}) { if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' fetchOrder requires a symbol argument'); + throw new ArgumentsRequired (this.id + ' fetchOrder() requires a symbol argument'); } await this.loadMarkets (); const market = this.market (symbol); @@ -708,6 +796,7 @@ module.exports = class bithumb extends Exchange { 'symbol': symbol, 'type': type, 'timeInForce': undefined, + 'postOnly': undefined, 'side': side, 'price': price, 'stopPrice': undefined, @@ -730,7 +819,7 @@ module.exports = class bithumb extends Exchange { async fetchOpenOrders (symbol = undefined, since = undefined, limit = undefined, params = {}) { if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' fetchOpenOrders requires a symbol argument'); + throw new ArgumentsRequired (this.id + ' fetchOpenOrders() requires a symbol argument'); } await this.loadMarkets (); const market = this.market (symbol); @@ -770,10 +859,10 @@ module.exports = class bithumb extends Exchange { async cancelOrder (id, symbol = undefined, params = {}) { const side_in_params = ('side' in params); if (!side_in_params) { - throw new ArgumentsRequired (this.id + ' cancelOrder requires a `symbol` argument and a `side` parameter (sell or buy)'); + throw new ArgumentsRequired (this.id + ' cancelOrder() requires a `symbol` argument and a `side` parameter (sell or buy)'); } if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' cancelOrder requires a `symbol` argument and a `side` parameter (sell or buy)'); + throw new ArgumentsRequired (this.id + ' cancelOrder() requires a `symbol` argument and a `side` parameter (sell or buy)'); } const market = this.market (symbol); const side = (params['side'] === 'buy') ? 'bid' : 'ask'; @@ -804,7 +893,7 @@ module.exports = class bithumb extends Exchange { 'address': address, 'currency': currency['id'], }; - if (currency === 'XRP' || currency === 'XMR') { + if (currency === 'XRP' || currency === 'XMR' || currency === 'EOS' || currency === 'STEEM') { const destination = this.safeString (params, 'destination'); if ((tag === undefined) && (destination === undefined)) { throw new ArgumentsRequired (this.id + ' ' + code + ' withdraw() requires a tag argument or an extra destination param'); diff --git a/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/bitkk.js b/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/bitkk.js index 055657b41..f416bef33 100644 --- a/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/bitkk.js +++ b/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/bitkk.js @@ -21,6 +21,9 @@ module.exports = class bitkk extends zb { 'doc': 'https://www.bitkk.com/i/developer', 'fees': 'https://www.bitkk.com/i/rate', }, + 'commonCurrencies': { + 'BCH': 'BCHOLD', + }, }); } }; diff --git a/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/bitmart.js b/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/bitmart.js index d99c5d095..4ad47118a 100644 --- a/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/bitmart.js +++ b/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/bitmart.js @@ -48,7 +48,7 @@ module.exports = class bitmart extends Exchange { 'logo': 'https://user-images.githubusercontent.com/1294454/61835713-a2662f80-ae85-11e9-9d00-6442919701fd.jpg', 'api': 'https://api-cloud.{hostname}', // bitmart.info for Hong Kong users 'www': 'https://www.bitmart.com/', - 'doc': 'https://github.com/bitmartexchange/bitmart-official-api-docs', + 'doc': 'https://developer-pro.bitmart.com/', 'referral': 'http://www.bitmart.com/?r=rQCFLh', 'fees': 'https://www.bitmart.com/fee/en', }, @@ -161,8 +161,8 @@ module.exports = class bitmart extends Exchange { 'trading': { 'tierBased': true, 'percentage': true, - 'taker': 0.002, - 'maker': 0.001, + 'taker': 0.0025, + 'maker': 0.0025, 'tiers': { 'taker': [ [0, 0.20 / 100], @@ -296,6 +296,8 @@ module.exports = class bitmart extends Exchange { 'broad': {}, }, 'commonCurrencies': { + 'COT': 'Community Coin', + 'CPC': 'CPCoin', 'ONE': 'Menlo One', 'PLA': 'Plair', }, @@ -1241,7 +1243,7 @@ module.exports = class bitmart extends Exchange { async fetchMyTrades (symbol = undefined, since = undefined, limit = undefined, params = {}) { if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' fetchMyTrades requires a symbol argument'); + throw new ArgumentsRequired (this.id + ' fetchMyTrades() requires a symbol argument'); } await this.loadMarkets (); const market = this.market (symbol); @@ -1249,7 +1251,7 @@ module.exports = class bitmart extends Exchange { const request = {}; if (market['spot']) { request['symbol'] = market['id']; - request['offset'] = 1; + request['offset'] = 1; // max offset * limit < 500 if (limit === undefined) { limit = 100; // max 100 } @@ -1322,7 +1324,7 @@ module.exports = class bitmart extends Exchange { async fetchOrderTrades (id, symbol = undefined, since = undefined, limit = undefined, params = {}) { if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' fetchOrderTrades requires a symbol argument'); + throw new ArgumentsRequired (this.id + ' fetchOrderTrades() requires a symbol argument'); } await this.loadMarkets (); const market = this.market (symbol); @@ -1600,6 +1602,7 @@ module.exports = class bitmart extends Exchange { 'symbol': symbol, 'type': type, 'timeInForce': undefined, + 'postOnly': undefined, 'side': side, 'price': price, 'stopPrice': undefined, @@ -1705,7 +1708,7 @@ module.exports = class bitmart extends Exchange { async cancelOrder (id, symbol = undefined, params = {}) { if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' cancelOrder requires a symbol argument'); + throw new ArgumentsRequired (this.id + ' cancelOrder() requires a symbol argument'); } await this.loadMarkets (); const market = this.market (symbol); @@ -1733,6 +1736,15 @@ module.exports = class bitmart extends Exchange { // } // } // + // spot alternative + // + // { + // "code": 1000, + // "trace":"886fb6ae-456b-4654-b4e0-d681ac05cea1", + // "message": "OK", + // "data": true + // } + // // contract // // { @@ -1748,16 +1760,19 @@ module.exports = class bitmart extends Exchange { // } // const data = this.safeValue (response, 'data'); + if (data === true) { + return this.parseOrder (id, market); + } const succeeded = this.safeValue (data, 'succeed'); if (succeeded !== undefined) { id = this.safeString (succeeded, 0); if (id === undefined) { - throw new InvalidOrder (this.id + ' cancelOrder failed to cancel ' + symbol + ' order id ' + id); + throw new InvalidOrder (this.id + ' cancelOrder() failed to cancel ' + symbol + ' order id ' + id); } } else { const result = this.safeValue (data, 'result'); if (!result) { - throw new InvalidOrder (this.id + ' cancelOrder ' + symbol + ' order id ' + id + ' is filled or canceled'); + throw new InvalidOrder (this.id + ' cancelOrder() ' + symbol + ' order id ' + id + ' is filled or canceled'); } } const order = this.parseOrder (id, market); @@ -1766,16 +1781,16 @@ module.exports = class bitmart extends Exchange { async cancelAllOrders (symbol = undefined, params = {}) { if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' cancelAllOrders requires a symbol argument'); + throw new ArgumentsRequired (this.id + ' cancelAllOrders() requires a symbol argument'); } const side = this.safeString (params, 'side'); if (side === undefined) { - throw new ArgumentsRequired (this.id + " cancelAllOrders requires a `side` parameter ('buy' or 'sell')"); + throw new ArgumentsRequired (this.id + " cancelAllOrders() requires a `side` parameter ('buy' or 'sell')"); } await this.loadMarkets (); const market = this.market (symbol); if (!market['spot']) { - throw new NotSupported (this.id + ' cancelAllOrders does not support ' + market['type'] + ' orders, only spot orders are accepted'); + throw new NotSupported (this.id + ' cancelAllOrders() does not support ' + market['type'] + ' orders, only spot orders are accepted'); } const request = { 'symbol': market['id'], @@ -1795,12 +1810,12 @@ module.exports = class bitmart extends Exchange { async cancelOrders (ids, symbol = undefined, params = {}) { if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' canelOrders requires a symbol argument'); + throw new ArgumentsRequired (this.id + ' canelOrders() requires a symbol argument'); } await this.loadMarkets (); const market = this.market (symbol); if (!market['spot']) { - throw new NotSupported (this.id + ' cancelOrders does not support ' + market['type'] + ' orders, only contract orders are accepted'); + throw new NotSupported (this.id + ' cancelOrders() does not support ' + market['type'] + ' orders, only contract orders are accepted'); } const orders = []; for (let i = 0; i < ids.length; i++) { @@ -1841,7 +1856,7 @@ module.exports = class bitmart extends Exchange { async fetchOrdersByStatus (status, symbol = undefined, since = undefined, limit = undefined, params = {}) { if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' fetchOrdersByStatus requires a symbol argument'); + throw new ArgumentsRequired (this.id + ' fetchOrdersByStatus() requires a symbol argument'); } await this.loadMarkets (); const market = this.market (symbol); @@ -1963,7 +1978,7 @@ module.exports = class bitmart extends Exchange { async fetchOrders (symbol = undefined, since = undefined, limit = undefined, params = {}) { if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' fetchOrders requires a symbol argument'); + throw new ArgumentsRequired (this.id + ' fetchOrders() requires a symbol argument'); } await this.loadMarkets (); const market = this.market (symbol); @@ -1975,7 +1990,7 @@ module.exports = class bitmart extends Exchange { async fetchOrder (id, symbol = undefined, params = {}) { if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' fetchOrder requires a symbol argument'); + throw new ArgumentsRequired (this.id + ' fetchOrder() requires a symbol argument'); } await this.loadMarkets (); const request = {}; @@ -2053,7 +2068,7 @@ module.exports = class bitmart extends Exchange { const orders = this.safeValue (data, 'orders', []); const firstOrder = this.safeValue (orders, 0); if (firstOrder === undefined) { - throw new OrderNotFound (this.id + ' fetchOrder could not find ' + symbol + ' order id ' + id); + throw new OrderNotFound (this.id + ' fetchOrder() could not find ' + symbol + ' order id ' + id); } return this.parseOrder (firstOrder, market); } else { diff --git a/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/bitmax.js b/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/bitmax.js index 0fa940d42..62cbf55d5 100644 --- a/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/bitmax.js +++ b/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/bitmax.js @@ -133,8 +133,8 @@ module.exports = class bitmax extends Exchange { 'trading': { 'tierBased': true, 'percentage': true, - 'taker': 0.001, - 'maker': 0.001, + 'taker': 0.002, + 'maker': 0.002, }, }, 'precisionMode': TICK_SIZE, @@ -1039,6 +1039,7 @@ module.exports = class bitmax extends Exchange { 'symbol': symbol, 'type': type, 'timeInForce': undefined, + 'postOnly': undefined, 'side': side, 'price': price, 'stopPrice': stopPrice, @@ -1089,7 +1090,7 @@ module.exports = class bitmax extends Exchange { if ((type === 'stop_limit') || (type === 'stop_market')) { const stopPrice = this.safeFloat (params, 'stopPrice'); if (stopPrice === undefined) { - throw new InvalidOrder (this.id + ' createOrder requires a stopPrice parameter for ' + type + ' orders'); + throw new InvalidOrder (this.id + ' createOrder() requires a stopPrice parameter for ' + type + ' orders'); } else { request['stopPrice'] = this.priceToPrecision (symbol, stopPrice); params = this.omit (params, 'stopPrice'); @@ -1344,7 +1345,7 @@ module.exports = class bitmax extends Exchange { async cancelOrder (id, symbol = undefined, params = {}) { if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' cancelOrder requires a symbol argument'); + throw new ArgumentsRequired (this.id + ' cancelOrder() requires a symbol argument'); } await this.loadMarkets (); await this.loadAccounts (); diff --git a/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/bitmex.js b/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/bitmex.js index 536120bf6..4f5a0552a 100644 --- a/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/bitmex.js +++ b/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/bitmex.js @@ -4,7 +4,7 @@ const Exchange = require ('./base/Exchange'); const { TICK_SIZE } = require ('./base/functions/number'); -const { AuthenticationError, BadRequest, DDoSProtection, ExchangeError, ExchangeNotAvailable, InsufficientFunds, InvalidOrder, OrderNotFound, PermissionDenied } = require ('./base/errors'); +const { AuthenticationError, BadRequest, DDoSProtection, ExchangeError, ExchangeNotAvailable, InsufficientFunds, InvalidOrder, OrderNotFound, PermissionDenied, ArgumentsRequired } = require ('./base/errors'); // --------------------------------------------------------------------------- @@ -167,6 +167,7 @@ module.exports = class bitmex extends Exchange { 'Account has insufficient Available Balance': InsufficientFunds, 'Service unavailable': ExchangeNotAvailable, // {"error":{"message":"Service unavailable","name":"HTTPError"}} 'Server Error': ExchangeError, // {"error":{"message":"Server Error","name":"HTTPError"}} + 'Unable to cancel order due to existing state': InvalidOrder, }, }, 'precisionMode': TICK_SIZE, @@ -1219,6 +1220,43 @@ module.exports = class bitmex extends Exchange { } parseOrder (order, market = undefined) { + // + // { + // "orderID":"56222c7a-9956-413a-82cf-99f4812c214b", + // "clOrdID":"", + // "clOrdLinkID":"", + // "account":1455728, + // "symbol":"XBTUSD", + // "side":"Sell", + // "simpleOrderQty":null, + // "orderQty":1, + // "price":40000, + // "displayQty":null, + // "stopPx":null, + // "pegOffsetValue":null, + // "pegPriceType":"", + // "currency":"USD", + // "settlCurrency":"XBt", + // "ordType":"Limit", + // "timeInForce":"GoodTillCancel", + // "execInst":"", + // "contingencyType":"", + // "exDestination":"XBME", + // "ordStatus":"New", + // "triggered":"", + // "workingIndicator":true, + // "ordRejReason":"", + // "simpleLeavesQty":null, + // "leavesQty":1, + // "simpleCumQty":null, + // "cumQty":0, + // "avgPx":null, + // "multiLegReportingType":"SingleSecurity", + // "text":"Submitted via API.", + // "transactTime":"2021-01-02T21:38:49.246Z", + // "timestamp":"2021-01-02T21:38:49.246Z" + // } + // const status = this.parseOrderStatus (this.safeString (order, 'ordStatus')); const marketId = this.safeString (order, 'symbol'); const symbol = this.safeSymbol (marketId, market); @@ -1248,6 +1286,8 @@ module.exports = class bitmex extends Exchange { const clientOrderId = this.safeString (order, 'clOrdID'); const timeInForce = this.parseTimeInForce (this.safeString (order, 'timeInForce')); const stopPrice = this.safeFloat (order, 'stopPx'); + const execInst = this.safeString (order, 'execInst'); + const postOnly = (execInst === 'ParticipateDoNotInitiate'); return { 'info': order, 'id': id, @@ -1258,6 +1298,7 @@ module.exports = class bitmex extends Exchange { 'symbol': symbol, 'type': type, 'timeInForce': timeInForce, + 'postOnly': postOnly, 'side': side, 'price': price, 'stopPrice': stopPrice, @@ -1326,18 +1367,21 @@ module.exports = class bitmex extends Exchange { const request = { 'symbol': market['id'], 'side': this.capitalize (side), - 'orderQty': amount, + 'orderQty': parseFloat (this.amountToPrecision (symbol, amount)), 'ordType': orderType, }; - if (price !== undefined) { - if (orderType === 'Stop') { - const stopPrice = this.safeFloat2 (params, 'stopPx', 'stopPrice'); - request['stopPx'] = stopPrice; - params = this.omit (params, [ 'stopPx', 'stopPrice' ]); + if ((orderType === 'Stop') || (orderType === 'StopLimit') || (orderType === 'MarketIfTouched') || (orderType === 'LimitIfTouched')) { + const stopPrice = this.safeFloat2 (params, 'stopPx', 'stopPrice'); + if (stopPrice === undefined) { + throw new ArgumentsRequired (this.id + ' createOrder() requires a stopPx or stopPrice parameter for the ' + orderType + ' order type'); } else { - request['price'] = price; + request['stopPx'] = parseFloat (this.priceToPrecision (symbol, stopPrice)); + params = this.omit (params, [ 'stopPx', 'stopPrice' ]); } } + if ((orderType === 'Limit') || (orderType === 'StopLimit') || (orderType === 'LimitIfTouched')) { + request['price'] = parseFloat (this.priceToPrecision (symbol, price)); + } const clientOrderId = this.safeString2 (params, 'clOrdID', 'clientOrderId'); if (clientOrderId !== undefined) { request['clOrdID'] = clientOrderId; diff --git a/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/bitpanda.js b/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/bitpanda.js index 41f855168..b440aba7d 100644 --- a/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/bitpanda.js +++ b/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/bitpanda.js @@ -790,7 +790,10 @@ module.exports = class bitpanda extends Exchange { // const feeInfo = this.safeValue (trade, 'fee', {}); trade = this.safeValue (trade, 'trade', trade); - const timestamp = this.parse8601 (this.safeString (trade, 'time')); + let timestamp = this.safeInteger (trade, 'trade_timestamp'); + if (timestamp === undefined) { + timestamp = this.parse8601 (this.safeString (trade, 'time')); + } const side = this.safeStringLower2 (trade, 'side', 'taker_side'); const price = this.safeFloat (trade, 'price'); const amount = this.safeFloat (trade, 'amount'); @@ -965,7 +968,7 @@ module.exports = class bitpanda extends Exchange { if (since !== undefined) { const to = this.safeString (params, 'to'); if (to === undefined) { - throw new ArgumentsRequired (this.id + ' fetchDeposits requires a "to" iso8601 string param with the since argument is specified'); + throw new ArgumentsRequired (this.id + ' fetchDeposits() requires a "to" iso8601 string param with the since argument is specified'); } request['from'] = this.iso8601 (since); } @@ -1020,7 +1023,7 @@ module.exports = class bitpanda extends Exchange { if (since !== undefined) { const to = this.safeString (params, 'to'); if (to === undefined) { - throw new ArgumentsRequired (this.id + ' fetchWithdrawals requires a "to" iso8601 string param with the since argument is specified'); + throw new ArgumentsRequired (this.id + ' fetchWithdrawals() requires a "to" iso8601 string param with the since argument is specified'); } request['from'] = this.iso8601 (since); } @@ -1325,6 +1328,7 @@ module.exports = class bitpanda extends Exchange { } const timeInForce = this.parseTimeInForce (this.safeString (order, 'time_in_force')); const stopPrice = this.safeFloat (order, 'trigger_price'); + const postOnly = this.safeValue (order, 'is_post_only'); const result = { 'id': id, 'clientOrderId': clientOrderId, @@ -1335,6 +1339,7 @@ module.exports = class bitpanda extends Exchange { 'symbol': symbol, 'type': type, 'timeInForce': timeInForce, + 'postOnly': postOnly, 'side': side, 'price': price, 'stopPrice': stopPrice, @@ -1409,7 +1414,7 @@ module.exports = class bitpanda extends Exchange { if (uppercaseType === 'STOP') { const triggerPrice = this.safeFloat (params, 'trigger_price'); if (triggerPrice === undefined) { - throw new ArgumentsRequired (this.id + ' createOrder requires a trigger_price param for ' + type + ' orders'); + throw new ArgumentsRequired (this.id + ' createOrder() requires a trigger_price param for ' + type + ' orders'); } request['trigger_price'] = this.priceToPrecision (symbol, triggerPrice); params = this.omit (params, 'trigger_price'); @@ -1560,7 +1565,7 @@ module.exports = class bitpanda extends Exchange { if (since !== undefined) { const to = this.safeString (params, 'to'); if (to === undefined) { - throw new ArgumentsRequired (this.id + ' fetchOrders requires a "to" iso8601 string param with the since argument is specified, max range is 100 days'); + throw new ArgumentsRequired (this.id + ' fetchOrders() requires a "to" iso8601 string param with the since argument is specified, max range is 100 days'); } request['from'] = this.iso8601 (since); } @@ -1724,7 +1729,7 @@ module.exports = class bitpanda extends Exchange { if (since !== undefined) { const to = this.safeString (params, 'to'); if (to === undefined) { - throw new ArgumentsRequired (this.id + ' fetchMyTrades requires a "to" iso8601 string param with the since argument is specified, max range is 100 days'); + throw new ArgumentsRequired (this.id + ' fetchMyTrades() requires a "to" iso8601 string param with the since argument is specified, max range is 100 days'); } request['from'] = this.iso8601 (since); } diff --git a/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/bitso.js b/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/bitso.js index 8ef7dc93c..d8bc07145 100644 --- a/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/bitso.js +++ b/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/bitso.js @@ -4,7 +4,7 @@ const Exchange = require ('./base/Exchange'); const { ExchangeError, InvalidNonce, AuthenticationError, OrderNotFound } = require ('./base/errors'); -const { TICK_SIZE } = require ('./base/functions/number'); +const { TICK_SIZE, ROUND } = require ('./base/functions/number'); // --------------------------------------------------------------------------- @@ -181,23 +181,25 @@ module.exports = class bitso extends Exchange { const taker = this.safeFloat (flatRate, 'taker'); const feeTiers = this.safeValue (fees, 'structure', []); const fee = { - 'maker': maker, - 'taker': taker, + 'taker': parseFloat (this.decimalToPrecision (taker / 100, ROUND, 0.00000001, TICK_SIZE)), + 'maker': parseFloat (this.decimalToPrecision (maker / 100, ROUND, 0.00000001, TICK_SIZE)), 'percentage': true, 'tierBased': true, }; const takerFees = []; const makerFees = []; - for (let i = 0; i < feeTiers.length; i++) { - const tier = feeTiers[i]; + for (let j = 0; j < feeTiers.length; j++) { + const tier = feeTiers[j]; const volume = this.safeFloat (tier, 'volume'); const takerFee = this.safeFloat (tier, 'taker'); const makerFee = this.safeFloat (tier, 'maker'); - takerFees.push ([ volume, takerFee ]); - makerFees.push ([ volume, makerFee ]); - if (i === 0) { - fee['taker'] = taker; - fee['maker'] = maker; + const takerFeeToPrecision = parseFloat (this.decimalToPrecision (takerFee / 100, ROUND, 0.00000001, TICK_SIZE)); + const makerFeeToPrecision = parseFloat (this.decimalToPrecision (makerFee / 100, ROUND, 0.00000001, TICK_SIZE)); + takerFees.push ([ volume, takerFeeToPrecision ]); + makerFees.push ([ volume, makerFeeToPrecision ]); + if (j === 0) { + fee['taker'] = parseFloat (this.decimalToPrecision (taker / 100, ROUND, 0.00000001, TICK_SIZE)); + fee['maker'] = parseFloat (this.decimalToPrecision (maker / 100, ROUND, 0.00000001, TICK_SIZE)); } } const tiers = { @@ -434,6 +436,7 @@ module.exports = class bitso extends Exchange { 'symbol': symbol, 'type': orderType, 'timeInForce': undefined, + 'postOnly': undefined, 'side': side, 'price': price, 'stopPrice': undefined, diff --git a/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/bitstamp.js b/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/bitstamp.js index 1b4a33a46..4671385bf 100644 --- a/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/bitstamp.js +++ b/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/bitstamp.js @@ -3,7 +3,7 @@ // --------------------------------------------------------------------------- const Exchange = require ('./base/Exchange'); -const { AuthenticationError, ExchangeError, NotSupported, PermissionDenied, InvalidNonce, OrderNotFound, InsufficientFunds, InvalidAddress, InvalidOrder, ArgumentsRequired, OnMaintenance } = require ('./base/errors'); +const { AuthenticationError, ExchangeError, NotSupported, PermissionDenied, InvalidNonce, OrderNotFound, InsufficientFunds, InvalidAddress, InvalidOrder, ArgumentsRequired, OnMaintenance, ExchangeNotAvailable } = require ('./base/errors'); // --------------------------------------------------------------------------- @@ -223,6 +223,7 @@ module.exports = class bitstamp extends Exchange { 'Order not found': OrderNotFound, 'Price is more than 20% below market price.': InvalidOrder, 'Bitstamp.net is under scheduled maintenance.': OnMaintenance, // { "error": "Bitstamp.net is under scheduled maintenance. We'll be back soon." } + 'Order could not be placed.': ExchangeNotAvailable, // Order could not be placed (perhaps due to internal error or trade halt). Please retry placing order. }, 'broad': { 'Minimum order size is': InvalidOrder, // Minimum order size is 5.0 EUR. @@ -705,7 +706,7 @@ module.exports = class bitstamp extends Exchange { const duration = this.parseTimeframe (timeframe); if (limit === undefined) { if (since === undefined) { - throw new ArgumentsRequired (this.id + ' fetchOHLCV requires a since argument or a limit argument'); + throw new ArgumentsRequired (this.id + ' fetchOHLCV() requires a since argument or a limit argument'); } else { limit = 1000; const start = parseInt (since / 1000); @@ -771,8 +772,8 @@ module.exports = class bitstamp extends Exchange { return { 'info': balance, 'symbol': symbol, - 'maker': balance.fee, - 'taker': balance.fee, + 'maker': balance['fee'], + 'taker': balance['fee'], }; } @@ -1262,6 +1263,7 @@ module.exports = class bitstamp extends Exchange { 'symbol': symbol, 'type': undefined, 'timeInForce': undefined, + 'postOnly': undefined, 'side': side, 'price': price, 'stopPrice': undefined, diff --git a/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/bittrex.js b/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/bittrex.js index 36d09cbb8..1e11d600a 100644 --- a/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/bittrex.js +++ b/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/bittrex.js @@ -3,7 +3,7 @@ // --------------------------------------------------------------------------- const Exchange = require ('./base/Exchange'); -const { BadSymbol, ExchangeError, ExchangeNotAvailable, AuthenticationError, InvalidOrder, InsufficientFunds, OrderNotFound, DDoSProtection, PermissionDenied, AddressPending, OnMaintenance, BadRequest } = require ('./base/errors'); +const { BadSymbol, ExchangeError, ExchangeNotAvailable, AuthenticationError, InvalidOrder, InsufficientFunds, OrderNotFound, DDoSProtection, PermissionDenied, AddressPending, OnMaintenance, BadRequest, InvalidAddress } = require ('./base/errors'); const { TRUNCATE, DECIMAL_PLACES } = require ('./base/functions/number'); // --------------------------------------------------------------------------- @@ -23,6 +23,7 @@ module.exports = class bittrex extends Exchange { 'CORS': false, 'cancelAllOrders': true, 'cancelOrder': true, + 'createDepositAddress': true, 'createMarketOrder': true, 'createOrder': true, 'fetchBalance': true, @@ -137,10 +138,10 @@ module.exports = class bittrex extends Exchange { }, 'fees': { 'trading': { - 'tierBased': false, + 'tierBased': true, 'percentage': true, - 'maker': 0.0025, - 'taker': 0.0025, + 'maker': 0.0035, + 'taker': 0.0035, }, 'funding': { 'tierBased': false, @@ -758,7 +759,22 @@ module.exports = class bittrex extends Exchange { const isCeilingMarket = (uppercaseType === 'CEILING_MARKET'); const isCeilingOrder = isCeilingLimit || isCeilingMarket; if (isCeilingOrder) { - request['ceiling'] = this.priceToPrecision (symbol, price); + let cost = undefined; + if (isCeilingLimit) { + request['limit'] = this.priceToPrecision (symbol, price); + cost = this.safeFloat2 (params, 'ceiling', 'cost', amount); + } else if (isCeilingMarket) { + cost = this.safeFloat2 (params, 'ceiling', 'cost'); + if (cost === undefined) { + if (price === undefined) { + cost = amount; + } else { + cost = amount * price; + } + } + } + params = this.omit (params, [ 'ceiling', 'cost' ]); + request['ceiling'] = this.costToPrecision (symbol, cost); // bittrex only accepts IMMEDIATE_OR_CANCEL or FILL_OR_KILL for ceiling orders request['timeInForce'] = 'IMMEDIATE_OR_CANCEL'; } else { @@ -975,7 +991,7 @@ module.exports = class bittrex extends Exchange { 'GOOD_TIL_CANCELLED': 'GTC', 'IMMEDIATE_OR_CANCEL': 'IOC', 'FILL_OR_KILL': 'FOK', - 'POST_ONLY_GOOD_TIL_CANCELLED': 'POST_ONLY_GOOD_TIL_CANCELLED', + 'POST_ONLY_GOOD_TIL_CANCELLED': 'PO', }; return this.safeString (timeInForces, timeInForce, timeInForce); } @@ -1045,6 +1061,7 @@ module.exports = class bittrex extends Exchange { status = 'canceled'; } const timeInForce = this.parseTimeInForce (this.safeString (order, 'timeInForce')); + const postOnly = (timeInForce === 'PO'); return { 'id': this.safeString (order, 'id'), 'clientOrderId': undefined, @@ -1054,6 +1071,7 @@ module.exports = class bittrex extends Exchange { 'symbol': symbol, 'type': type, 'timeInForce': timeInForce, + 'postOnly': postOnly, 'side': direction, 'price': limit, 'stopPrice': undefined, @@ -1191,6 +1209,40 @@ module.exports = class bittrex extends Exchange { return this.parseOrders (response, market, since, limit); } + async createDepositAddress (code, params = {}) { + await this.loadMarkets (); + const currency = this.currency (code); + const request = { + 'currencySymbol': currency['id'], + }; + const response = await this.privatePostAddresses (this.extend (request, params)); + // + // { + // "status":"PROVISIONED", + // "currencySymbol":"XRP", + // "cryptoAddress":"rPVMhWBsfF9iMXYj3aAzJVkPDTFNSyWdKy", + // "cryptoAddressTag":"392034158" + // } + // + let address = this.safeString (response, 'cryptoAddress'); + const message = this.safeString (response, 'status'); + if (!address || message === 'REQUESTED') { + throw new AddressPending (this.id + ' the address for ' + code + ' is being generated (pending, not ready yet, retry again later)'); + } + let tag = this.safeString (response, 'cryptoAddressTag'); + if ((tag === undefined) && (currency['type'] in this.options['tag'])) { + tag = address; + address = currency['address']; + } + this.checkAddress (address); + return { + 'currency': code, + 'address': address, + 'tag': tag, + 'info': response, + }; + } + async fetchDepositAddress (code, params = {}) { await this.loadMarkets (); const currency = this.currency (code); @@ -1198,18 +1250,21 @@ module.exports = class bittrex extends Exchange { 'currencySymbol': currency['id'], }; const response = await this.privateGetAddressesCurrencySymbol (this.extend (request, params)); - // { - // "status": "PROVISIONED", - // "currencySymbol": "BTC", - // "cryptoAddress": "1PhmYjnJPZH5NUwV8AUjqkeDkCBpbE2xqX" - // } + // + // { + // "status":"PROVISIONED", + // "currencySymbol":"XRP", + // "cryptoAddress":"rPVMhWBsfF9iMXYj3aAzJVkPDTFNSyWdKy", + // "cryptoAddressTag":"392034158" + // } + // let address = this.safeString (response, 'cryptoAddress'); const message = this.safeString (response, 'status'); if (!address || message === 'REQUESTED') { throw new AddressPending (this.id + ' the address for ' + code + ' is being generated (pending, not ready yet, retry again later)'); } - let tag = undefined; - if (currency['type'] in this.options['tag']) { + let tag = this.safeString (response, 'cryptoAddressTag'); + if ((tag === undefined) && (currency['type'] in this.options['tag'])) { tag = address; address = currency['address']; } @@ -1309,6 +1364,9 @@ module.exports = class bittrex extends Exchange { this.throwExactlyMatchedException (this.exceptions['exact'], code, feedback); this.throwBroadlyMatchedException (this.exceptions['broad'], code, feedback); } + if ((code === 'NOT_FOUND') && (url.indexOf ('addresses') >= 0)) { + throw new InvalidAddress (feedback); + } // throw new ExchangeError (this.id + ' malformed response ' + this.json (response)); return; } diff --git a/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/bitvavo.js b/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/bitvavo.js index 10d62cfeb..e6633b568 100644 --- a/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/bitvavo.js +++ b/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/bitvavo.js @@ -4,7 +4,7 @@ const Exchange = require ('./base/Exchange'); const { ExchangeError, BadSymbol, AuthenticationError, InsufficientFunds, InvalidOrder, ArgumentsRequired, OrderNotFound, InvalidAddress, BadRequest, RateLimitExceeded, PermissionDenied, ExchangeNotAvailable, AccountSuspended, OnMaintenance } = require ('./base/errors'); -const { TRUNCATE } = require ('./base/functions/number'); +const { SIGNIFICANT_DIGITS, DECIMAL_PLACES, TRUNCATE, ROUND } = require ('./base/functions/number'); // ---------------------------------------------------------------------------- @@ -221,12 +221,33 @@ module.exports = class bitvavo extends Exchange { 'expires': 1000, // 1 second }, }, + 'precisionMode': SIGNIFICANT_DIGITS, 'commonCurrencies': { 'MIOTA': 'IOTA', // https://github.com/ccxt/ccxt/issues/7487 }, }); } + currencyToPrecision (currency, fee) { + return this.decimalToPrecision (fee, 0, this.currencies[currency]['precision']); + } + + amountToPrecision (symbol, amount) { + // https://docs.bitfinex.com/docs/introduction#amount-precision + // The amount field allows up to 8 decimals. + // Anything exceeding this will be rounded to the 8th decimal. + return this.decimalToPrecision (amount, TRUNCATE, this.markets[symbol]['precision']['amount'], DECIMAL_PLACES); + } + + priceToPrecision (symbol, price) { + price = this.decimalToPrecision (price, ROUND, this.markets[symbol]['precision']['price'], this.precisionMode); + // https://docs.bitfinex.com/docs/introduction#price-precision + // The precision level of all trading prices is based on significant figures. + // All pairs on Bitfinex use up to 5 significant digits and up to 8 decimals (e.g. 1.2345, 123.45, 1234.5, 0.00012345). + // Prices submit with a precision larger than 5 will be cut by the API. + return this.decimalToPrecision (price, TRUNCATE, 8, DECIMAL_PLACES); + } + async fetchTime (params = {}) { const response = await this.publicGetTime (params); // @@ -768,16 +789,18 @@ module.exports = class bitvavo extends Exchange { const request = { 'market': market['id'], 'side': side, - 'orderType': type, + 'orderType': type, // 'market', 'limit', 'stopLoss', 'stopLossLimit', 'takeProfit', 'takeProfitLimit' // 'amount': this.amountToPrecision (symbol, amount), // 'price': this.priceToPrecision (symbol, price), // 'amountQuote': this.costToPrecision (symbol, cost), - // 'timeInForce': 'GTC', // "GTC" "IOC" "FOK" - // 'selfTradePrevention': "decrementAndCancel", // "decrementAndCancel" "cancelOldest" "cancelNewest" "cancelBoth" + // 'timeInForce': 'GTC', // 'GTC', 'IOC', 'FOK' + // 'selfTradePrevention': 'decrementAndCancel', // 'decrementAndCancel', 'cancelOldest', 'cancelNewest', 'cancelBoth' // 'postOnly': false, // 'disableMarketProtection': false, // don't cancel if the next fill price is 10% worse than the best fill price // 'responseRequired': true, // false is faster }; + const isStopLimit = (type === 'stopLossLimit') || (type === 'takeProfitLimit'); + const isStopMarket = (type === 'stopLoss') || (type === 'takeProfit'); if (type === 'market') { let cost = undefined; if (price !== undefined) { @@ -795,6 +818,26 @@ module.exports = class bitvavo extends Exchange { } else if (type === 'limit') { request['price'] = this.priceToPrecision (symbol, price); request['amount'] = this.amountToPrecision (symbol, amount); + } else if (isStopMarket || isStopLimit) { + let stopPrice = this.safeFloat2 (params, 'stopPrice', 'triggerAmount'); + if (stopPrice === undefined) { + if (isStopLimit) { + throw new ArgumentsRequired (this.id + ' createOrder requires a stopPrice parameter for a ' + type + ' order'); + } else if (isStopMarket) { + if (price === undefined) { + throw new ArgumentsRequired (this.id + ' createOrder requires a price argument or a stopPrice parameter for a ' + type + ' order'); + } else { + stopPrice = price; + } + } + } + if (isStopLimit) { + request['price'] = this.priceToPrecision (symbol, price); + } + params = this.omit (params, [ 'stopPrice', 'triggerAmount' ]); + request['triggerAmount'] = this.priceToPrecision (symbol, stopPrice); + request['triggerType'] = 'price'; + request['amount'] = this.amountToPrecision (symbol, amount); } const response = await this.privatePostOrder (this.extend (request, params)); // @@ -856,13 +899,13 @@ module.exports = class bitvavo extends Exchange { const response = await this.privatePutOrder (this.extend (request, params)); return this.parseOrder (response, market); } else { - throw new ArgumentsRequired (this.id + ' editOrder requires an amount argument, or a price argument, or non-empty params'); + throw new ArgumentsRequired (this.id + ' editOrder() requires an amount argument, or a price argument, or non-empty params'); } } async cancelOrder (id, symbol = undefined, params = {}) { if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' cancelOrder requires a symbol argument'); + throw new ArgumentsRequired (this.id + ' cancelOrder() requires a symbol argument'); } await this.loadMarkets (); const market = this.market (symbol); @@ -900,7 +943,7 @@ module.exports = class bitvavo extends Exchange { async fetchOrder (id, symbol = undefined, params = {}) { if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' fetchOrder requires a symbol argument'); + throw new ArgumentsRequired (this.id + ' fetchOrder() requires a symbol argument'); } await this.loadMarkets (); await this.loadMarkets (); @@ -949,7 +992,7 @@ module.exports = class bitvavo extends Exchange { async fetchOrders (symbol = undefined, since = undefined, limit = undefined, params = {}) { if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' fetchOrders requires a symbol argument'); + throw new ArgumentsRequired (this.id + ' fetchOrders() requires a symbol argument'); } await this.loadMarkets (); const market = this.market (symbol); @@ -1010,24 +1053,13 @@ module.exports = class bitvavo extends Exchange { async fetchOpenOrders (symbol = undefined, since = undefined, limit = undefined, params = {}) { await this.loadMarkets (); const request = { - // 'market': market['id'], - // 'limit': 500, - // 'start': since, - // 'end': this.milliseconds (), - // 'orderIdFrom': 'af76d6ce-9f7c-4006-b715-bb5d430652d0', - // 'orderIdTo': 'af76d6ce-9f7c-4006-b715-bb5d430652d0', + // 'market': market['id'], // rate limit 25 without a market, 1 with market specified }; let market = undefined; if (symbol !== undefined) { market = this.market (symbol); request['market'] = market['id']; } - if (since !== undefined) { - request['start'] = since; - } - if (limit !== undefined) { - request['limit'] = limit; // default 500, max 1000 - } const response = await this.privateGetOrdersOpen (this.extend (request, params)); // // [ @@ -1082,6 +1114,7 @@ module.exports = class bitvavo extends Exchange { 'partiallyFilled': 'open', 'expired': 'canceled', 'rejected': 'canceled', + 'awaitingTrigger': 'open', // https://github.com/ccxt/ccxt/issues/8489 }; return this.safeString (statuses, status, status); } @@ -1183,6 +1216,9 @@ module.exports = class bitvavo extends Exchange { } } const timeInForce = this.safeString (order, 'timeInForce'); + const postOnly = this.safeValue (order, 'postOnly'); + // https://github.com/ccxt/ccxt/issues/8489 + const stopPrice = this.safeFloat (order, 'triggerPrice'); return { 'info': order, 'id': id, @@ -1193,9 +1229,10 @@ module.exports = class bitvavo extends Exchange { 'symbol': symbol, 'type': type, 'timeInForce': timeInForce, + 'postOnly': postOnly, 'side': side, 'price': price, - 'stopPrice': undefined, + 'stopPrice': stopPrice, 'amount': amount, 'cost': cost, 'average': average, @@ -1209,7 +1246,7 @@ module.exports = class bitvavo extends Exchange { async fetchMyTrades (symbol = undefined, since = undefined, limit = undefined, params = {}) { if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' fetchMyTrades requires a symbol argument'); + throw new ArgumentsRequired (this.id + ' fetchMyTrades() requires a symbol argument'); } await this.loadMarkets (); const market = this.market (symbol); diff --git a/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/bitz.js b/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/bitz.js index 9b28cd463..816bb15a4 100644 --- a/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/bitz.js +++ b/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/bitz.js @@ -675,7 +675,7 @@ module.exports = class bitz extends Exchange { } } else { if (since !== undefined) { - throw new ArgumentsRequired (this.id + ' fetchOHLCV requires a limit argument if the since argument is specified'); + throw new ArgumentsRequired (this.id + ' fetchOHLCV() requires a limit argument if the since argument is specified'); } } const response = await this.marketGetKline (this.extend (request, params)); @@ -779,6 +779,7 @@ module.exports = class bitz extends Exchange { 'symbol': symbol, 'type': 'limit', 'timeInForce': undefined, + 'postOnly': undefined, 'side': side, 'price': price, 'stopPrice': undefined, @@ -948,7 +949,7 @@ module.exports = class bitz extends Exchange { async fetchOrdersWithMethod (method, symbol = undefined, since = undefined, limit = undefined, params = {}) { if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' fetchOpenOrders requires a symbol argument'); + throw new ArgumentsRequired (this.id + ' fetchOpenOrders() requires a symbol argument'); } await this.loadMarkets (); const market = this.market (symbol); diff --git a/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/bleutrade.js b/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/bleutrade.js index 385e7e455..67262da33 100644 --- a/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/bleutrade.js +++ b/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/bleutrade.js @@ -662,6 +662,7 @@ module.exports = class bleutrade extends Exchange { 'symbol': symbol, 'type': 'limit', 'timeInForce': undefined, + 'postOnly': undefined, 'side': side, 'price': price, 'stopPrice': undefined, diff --git a/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/braziliex.js b/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/braziliex.js index ac9d460c0..0c54e4840 100644 --- a/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/braziliex.js +++ b/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/braziliex.js @@ -460,6 +460,7 @@ module.exports = class braziliex extends Exchange { 'symbol': symbol, 'type': 'limit', 'timeInForce': undefined, + 'postOnly': undefined, 'side': side, 'price': price, 'stopPrice': undefined, diff --git a/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/btcalpha.js b/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/btcalpha.js index 441947aa1..820234604 100644 --- a/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/btcalpha.js +++ b/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/btcalpha.js @@ -348,6 +348,7 @@ module.exports = class btcalpha extends Exchange { 'symbol': symbol, 'type': 'limit', 'timeInForce': undefined, + 'postOnly': undefined, 'side': side, 'price': price, 'stopPrice': undefined, diff --git a/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/btcbox.js b/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/btcbox.js index af988de09..1a5f82456 100644 --- a/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/btcbox.js +++ b/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/btcbox.js @@ -306,6 +306,7 @@ module.exports = class btcbox extends Exchange { 'side': side, 'type': undefined, 'timeInForce': undefined, + 'postOnly': undefined, 'status': status, 'symbol': symbol, 'price': price, diff --git a/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/btcmarkets.js b/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/btcmarkets.js index 15bbd9610..2340d1960 100644 --- a/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/btcmarkets.js +++ b/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/btcmarkets.js @@ -865,6 +865,7 @@ module.exports = class btcmarkets extends Exchange { const clientOrderId = this.safeString (order, 'clientOrderId'); const timeInForce = this.safeString (order, 'timeInForce'); const stopPrice = this.safeFloat (order, 'triggerPrice'); + const postOnly = this.safeValue (order, 'postOnly'); return { 'info': order, 'id': id, @@ -875,6 +876,7 @@ module.exports = class btcmarkets extends Exchange { 'symbol': symbol, 'type': type, 'timeInForce': timeInForce, + 'postOnly': postOnly, 'side': side, 'price': price, 'stopPrice': stopPrice, diff --git a/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/btctradeua.js b/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/btctradeua.js index 4d6743bf5..011bc33b6 100644 --- a/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/btctradeua.js +++ b/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/btctradeua.js @@ -335,6 +335,7 @@ module.exports = class btctradeua extends Exchange { 'symbol': symbol, 'type': undefined, 'timeInForce': undefined, + 'postOnly': undefined, 'side': this.safeString (order, 'type'), 'price': this.safeFloat (order, 'price'), 'stopPrice': undefined, @@ -351,7 +352,7 @@ module.exports = class btctradeua extends Exchange { async fetchOpenOrders (symbol = undefined, since = undefined, limit = undefined, params = {}) { if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' fetchOpenOrders requires a symbol argument'); + throw new ArgumentsRequired (this.id + ' fetchOpenOrders() requires a symbol argument'); } await this.loadMarkets (); const market = this.market (symbol); diff --git a/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/btcturk.js b/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/btcturk.js index 24f79880b..32ea74550 100644 --- a/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/btcturk.js +++ b/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/btcturk.js @@ -275,7 +275,7 @@ module.exports = class btcturk extends Exchange { }; if (type === 'market') { if (!('Total' in params)) { - throw new ExchangeError (this.id + ' createOrder requires the "Total" extra parameter for market orders (amount and price are both ignored)'); + throw new ExchangeError (this.id + ' createOrder() requires the "Total" extra parameter for market orders (amount and price are both ignored)'); } } else { request['Price'] = price; diff --git a/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/buda.js b/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/buda.js index 96da5d093..e78c228ea 100644 --- a/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/buda.js +++ b/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/buda.js @@ -537,29 +537,65 @@ module.exports = class buda extends Exchange { } parseOrder (order, market = undefined) { + // + // { + // 'id': 63679183, + // 'uuid': 'f9697bee-627e-4175-983f-0d5a41963fec', + // 'market_id': 'ETH-CLP', + // 'account_id': 51590, + // 'type': 'Ask', + // 'state': 'received', + // 'created_at': '2021-01-04T08:29:52.730Z', + // 'fee_currency': 'CLP', + // 'price_type': 'limit', + // 'source': None, + // 'limit': ['741000.0', 'CLP'], + // 'amount': ['0.001', 'ETH'], + // 'original_amount': ['0.001', 'ETH'], + // 'traded_amount': ['0.0', 'ETH'], + // 'total_exchanged': ['0.0', 'CLP'], + // 'paid_fee': ['0.0', 'CLP'] + // } + // const id = this.safeString (order, 'id'); const timestamp = this.parse8601 (this.safeString (order, 'created_at')); const marketId = this.safeString (order, 'market_id'); - const symbol = this.safeSymbol (marketId, market); + const symbol = this.safeSymbol (marketId, market, '-'); const type = this.safeString (order, 'price_type'); const side = this.safeStringLower (order, 'type'); const status = this.parseOrderStatus (this.safeString (order, 'state')); - const amount = parseFloat (order['original_amount'][0]); - const remaining = parseFloat (order['amount'][0]); - const filled = parseFloat (order['traded_amount'][0]); - const cost = parseFloat (order['total_exchanged'][0]); - let price = this.safeFloat (order, 'limit'); - if (price !== undefined) { - price = parseFloat (price[0]); + const originalAmount = this.safeValue (order, 'original_amount', []); + const amount = this.safeFloat (originalAmount, 0); + const remainingAmount = this.safeValue (order, 'amount', []); + const remaining = this.safeFloat (remainingAmount, 0); + const tradedAmount = this.safeValue (order, 'traded_amount', []); + const filled = this.safeFloat (tradedAmount, 0); + const totalExchanged = this.safeValue (order, 'totalExchanged', []); + const cost = this.safeFloat (totalExchanged, 0); + const limitPrice = this.safeValue (order, 'limit', []); + let price = this.safeFloat (limitPrice, 0); + if (price === undefined) { + if (limitPrice !== undefined) { + price = limitPrice; + } } - if (cost > 0 && filled > 0) { - price = this.priceToPrecision (symbol, cost / filled); + let average = undefined; + if ((cost !== undefined) && (filled !== undefined) && (filled > 0)) { + average = this.priceToPrecision (symbol, cost / filled); + } + const paidFee = this.safeValue (order, 'paid_fee', []); + const feeCost = this.safeFloat (paidFee, 0); + let fee = undefined; + if (feeCost !== undefined) { + const feeCurrencyId = this.safeString (paidFee, 1); + const feeCurrencyCode = this.safeCurrencyCode (feeCurrencyId); + fee = { + 'cost': feeCost, + 'code': feeCurrencyCode, + }; } - const fee = { - 'cost': parseFloat (order['paid_fee'][0]), - 'currency': order['paid_fee'][1], - }; return { + 'info': order, 'id': id, 'clientOrderId': undefined, 'datetime': this.iso8601 (timestamp), @@ -569,17 +605,17 @@ module.exports = class buda extends Exchange { 'symbol': symbol, 'type': type, 'timeInForce': undefined, + 'postOnly': undefined, 'side': side, 'price': price, 'stopPrice': undefined, + 'average': average, 'cost': cost, 'amount': amount, 'filled': filled, 'remaining': remaining, 'trades': undefined, 'fee': fee, - 'info': order, - 'average': undefined, }; } diff --git a/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/bw.js b/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/bw.js index 57a8a64c7..388946b39 100644 --- a/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/bw.js +++ b/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/bw.js @@ -761,6 +761,7 @@ module.exports = class bw extends Exchange { 'symbol': symbol, 'type': 'limit', 'timeInForce': undefined, + 'postOnly': undefined, 'side': side, 'price': price, 'stopPrice': undefined, @@ -777,7 +778,7 @@ module.exports = class bw extends Exchange { async fetchOrder (id, symbol = undefined, params = {}) { if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' fetchOrder requires a symbol argument'); + throw new ArgumentsRequired (this.id + ' fetchOrder() requires a symbol argument'); } await this.loadMarkets (); const market = this.market (symbol); @@ -812,7 +813,7 @@ module.exports = class bw extends Exchange { async cancelOrder (id, symbol = undefined, params = {}) { if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' cancelOrder requires a symbol argument'); + throw new ArgumentsRequired (this.id + ' cancelOrder() requires a symbol argument'); } await this.loadMarkets (); const market = this.market (symbol); diff --git a/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/bybit.js b/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/bybit.js index 7a9159515..f74d0db18 100644 --- a/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/bybit.js +++ b/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/bybit.js @@ -17,6 +17,7 @@ module.exports = class bybit extends Exchange { 'version': 'v2', 'userAgent': undefined, 'rateLimit': 100, + 'hostname': 'bybit.com', // bybit.com, bytick.com 'has': { 'cancelOrder': true, 'CORS': true, @@ -59,9 +60,9 @@ module.exports = class bybit extends Exchange { '1y': 'Y', }, 'urls': { - 'test': 'https://api-testnet.bybit.com', + 'test': 'https://api-testnet.{hostname}', 'logo': 'https://user-images.githubusercontent.com/51840849/76547799-daff5b80-649e-11ea-87fb-3be9bac08954.jpg', - 'api': 'https://api.bybit.com', + 'api': 'https://api.{hostname}', 'www': 'https://www.bybit.com', 'doc': [ 'https://bybit-exchange.github.io/docs/inverse/', @@ -72,117 +73,112 @@ module.exports = class bybit extends Exchange { 'referral': 'https://www.bybit.com/app/register?ref=X7Prm', }, 'api': { + 'v2': { + 'public': { + 'get': [ + 'orderBook/L2', + 'kline/list', + 'tickers', + 'trading-records', + 'symbols', + 'liq-records', + 'mark-price-kline', + 'index-price-kline', + 'premium-index-kline', + 'open-interest', + 'big-deal', + 'account-ratio', + 'time', + 'announcement', + ], + }, + 'private': { + 'get': [ + 'order/list', + 'order', + 'stop-order/list', + 'stop-order', + 'position/list', + 'execution/list', + 'trade/closed-pnl/list', + 'funding/prev-funding-rate', + 'funding/prev-funding', + 'funding/predicted-funding', + 'account/api-key', + 'account/lcp', + 'wallet/balance', + 'wallet/fund/records', + 'wallet/withdraw/list', + 'exchange-order/list', + ], + 'post': [ + 'order/create', + 'order/cancel', + 'order/cancelAll', + 'order/replace', + 'stop-order/create', + 'stop-order/cancel', + 'stop-order/cancelAll', + 'stop-order/replace', + 'position/change-position-margin', + 'position/trading-stop', + 'position/leverage/save', + ], + }, + }, 'public': { - 'get': [ - 'orderBook/L2', - 'kline/list', - 'tickers', - 'trading-records', - 'symbols', - 'liq-records', - 'mark-price-kline', - 'open-interest', - 'big-deal', - 'account-ratio', - 'time', - 'announcement', - ], + 'linear': { + 'get': [ + 'kline', + 'recent-trading-records', + 'funding/prev-funding-rate', + 'mark-price-kline', + 'index-price-kline', + 'premium-index-kline', + 'risk-limit', + ], + }, }, 'private': { - 'get': [ - 'order/list', - 'order', - 'stop-order/list', - 'stop-order', - 'position/list', - 'wallet/balance', - 'execution/list', - 'trade/closed-pnl/list', - 'account/lcp', - 'exchange-order/list', - ], - 'post': [ - 'order/create', - 'order/cancel', - 'order/cancelAll', - 'order/replace', - 'stop-order/create', - 'stop-order/cancel', - 'stop-order/cancelAll', - 'stop-order/replace', - ], + 'linear': { + 'get': [ + 'order/list', + 'order/search', + 'stop-order/list', + 'stop-order/search', + 'position/list', + 'trade/execution/list', + 'trade/closed-pnl/list', + 'funding/predicted-funding', + 'funding/prev-funding', + ], + 'post': [ + 'order/create', + 'order/cancel', + 'order/cancel-all', + 'order/replace', + 'stop-order/create', + 'stop-order/cancel', + 'stop-order/cancel-all', + 'stop-order/replace', + 'position/set-auto-add-margin', + 'position/switch-isolated', + 'tpsl/switch-mode', + 'position/add-margin', + 'position/set-leverage', + 'position/trading-stop', + ], + }, }, 'openapi': { - 'get': [ - 'order/list', // deprecated - 'stop-order/list', // deprecated - 'wallet/risk-limit/list', - 'funding/prev-funding-rate', - 'funding/prev-funding', - 'funding/predicted-funding', - 'api-key', - 'wallet/fund/records', - 'wallet/withdraw/list', - ], - 'post': [ - 'order/replace', // deprecated - 'stop-order/create', // deprecated - 'stop-order/cancel', // deprecated - 'stop-order/replace', // deprecated - 'position/trading-stop', - 'wallet/risk-limit', - ], - }, - 'publicLinear': { - 'get': [ - 'kline', - 'recent-trading-records', - 'funding/prev-funding-rate', - 'mark-price-kline', - 'risk-limit', - ], - }, - 'privateLinear': { - 'get': [ - 'order/list', - 'order/search', - 'stop-order/list', - 'stop-order/search', - 'position/list', - 'trade/execution/list', - 'trade/closed-pnl/list', - 'funding/prev-funding', - 'funding/predicted-funding', - ], - 'post': [ - 'order/create', - 'order/cancel', - 'order/cancel-all', - 'order/replace', - 'stop-order/create', - 'stop-order/cancel', - 'stop-order/cancel-all', - 'stop-order/replace', - 'position/switch-isolated', - 'position/set-auto-add-margin', - 'tpsl/switch-mode', - 'position/set-leverage', - 'position/trading-stop', - 'position/add-margin', - ], - }, - 'position': { - 'post': [ - 'change-position-margin', - ], - }, - 'user': { - 'get': [ - 'leverage', // deprecated - ], - 'post': [ - 'leverage/save', - ], + 'wallet': { + 'get': [ + 'risk-limit/list', + ], + 'post': [ + 'risk-limit', + ], + }, }, }, 'httpExceptions': { @@ -285,6 +281,7 @@ module.exports = class bybit extends Exchange { 'options': { 'marketTypes': { 'BTC/USDT': 'linear', + 'BCH/USDT': 'linear', 'ETH/USDT': 'linear', 'LTC/USDT': 'linear', 'XTZ/USDT': 'linear', @@ -292,10 +289,10 @@ module.exports = class bybit extends Exchange { }, 'code': 'BTC', 'cancelAllOrders': { - 'method': 'privatePostOrderCancelAll', // privatePostStopOrderCancelAll + // 'method': 'v2PrivatePostOrderCancelAll', // v2PrivatePostStopOrderCancelAll }, 'recvWindow': 5 * 1000, // 5 sec default - 'timeDifference': 0, // the difference between system clock and Binance clock + 'timeDifference': 0, // the difference between system clock and exchange server clock 'adjustForTimeDifference': false, // controls the adjustment logic upon instantiation }, 'fees': { @@ -327,7 +324,7 @@ module.exports = class bybit extends Exchange { } async fetchTime (params = {}) { - const response = await this.publicGetTime (params); + const response = await this.v2PublicGetTime (params); // // { // ret_code: 0, @@ -345,30 +342,7 @@ module.exports = class bybit extends Exchange { if (this.options['adjustForTimeDifference']) { await this.loadTimeDifference (); } - const response = await this.publicGetSymbols (params); - // - // { - // ret_code: 0, - // ret_msg: 'OK', - // ext_code: '', - // ext_info: '', - // result: [ - // { - // name: 'BTCUSD', - // base_currency: 'BTC', - // quote_currency: 'USD', - // price_scale: 2, - // taker_fee: '0.00075', - // maker_fee: '-0.00025', - // leverage_filter: { min_leverage: 1, max_leverage: 100, leverage_step: '0.01' }, - // price_filter: { min_price: '0.5', max_price: '999999.5', tick_size: '0.5' }, - // lot_size_filter: { max_trading_qty: 1000000, min_trading_qty: 1, qty_step: 1 } - // }, - // ], - // time_now: '1583930495.454196' - // } - // - // sandbox/testnet + const response = await this.v2PublicGetSymbols (params); // // { // "ret_code":0, @@ -377,8 +351,8 @@ module.exports = class bybit extends Exchange { // "ext_info":"", // "result":[ // { - // "symbol":"BTCUSD", - // "symbol_alias":"BTCUSD", + // "name":"BTCUSD", + // "alias":"BTCUSD", // "status":"Trading", // "base_currency":"BTC", // "quote_currency":"USD", @@ -388,9 +362,22 @@ module.exports = class bybit extends Exchange { // "leverage_filter":{"min_leverage":1,"max_leverage":100,"leverage_step":"0.01"}, // "price_filter":{"min_price":"0.5","max_price":"999999.5","tick_size":"0.5"}, // "lot_size_filter":{"max_trading_qty":1000000,"min_trading_qty":1,"qty_step":1} - // } + // }, + // { + // "name":"BTCUSDT", + // "alias":"BTCUSDT", + // "status":"Trading", + // "base_currency":"BTC", + // "quote_currency":"USDT", + // "price_scale":2, + // "taker_fee":"0.00075", + // "maker_fee":"-0.00025", + // "leverage_filter":{"min_leverage":1,"max_leverage":100,"leverage_step":"0.01"}, + // "price_filter":{"min_price":"0.5","max_price":"999999.5","tick_size":"0.5"}, + // "lot_size_filter":{"max_trading_qty":100,"min_trading_qty":0.001,"qty_step":0.001} + // }, // ], - // "time_now":"1605916574.118500" + // "time_now":"1610539664.818033" // } // const markets = this.safeValue (response, 'result', []); @@ -457,65 +444,6 @@ module.exports = class bybit extends Exchange { return result; } - async fetchBalance (params = {}) { - await this.loadMarkets (); - const request = {}; - const coin = this.safeString (params, 'coin'); - const code = this.safeString (params, 'code'); - if (coin !== undefined) { - request['coin'] = coin; - } else if (code !== undefined) { - const currency = this.currency (code); - request['coin'] = currency['id']; - } - const response = await this.privateGetWalletBalance (this.extend (request, params)); - // - // { - // ret_code: 0, - // ret_msg: 'OK', - // ext_code: '', - // ext_info: '', - // result: { - // BTC: { - // equity: 0, - // available_balance: 0, - // used_margin: 0, - // order_margin: 0, - // position_margin: 0, - // occ_closing_fee: 0, - // occ_funding_fee: 0, - // wallet_balance: 0, - // realised_pnl: 0, - // unrealised_pnl: 0, - // cum_realised_pnl: 0, - // given_cash: 0, - // service_cash: 0 - // } - // }, - // time_now: '1583937810.370020', - // rate_limit_status: 119, - // rate_limit_reset_ms: 1583937810367, - // rate_limit: 120 - // } - // - const result = { - 'info': response, - }; - const balances = this.safeValue (response, 'result', {}); - const currencyIds = Object.keys (balances); - for (let i = 0; i < currencyIds.length; i++) { - const currencyId = currencyIds[i]; - const balance = balances[currencyId]; - const code = this.safeCurrencyCode (currencyId); - const account = this.account (); - account['free'] = this.safeFloat (balance, 'available_balance'); - account['used'] = this.safeFloat (balance, 'used_margin'); - account['total'] = this.safeFloat (balance, 'equity'); - result[code] = account; - } - return this.parseBalance (result); - } - parseTicker (ticker, market = undefined) { // // fetchTicker @@ -594,7 +522,7 @@ module.exports = class bybit extends Exchange { const request = { 'symbol': market['id'], }; - const response = await this.publicGetTickers (this.extend (request, params)); + const response = await this.v2PublicGetTickers (this.extend (request, params)); // // { // ret_code: 0, @@ -642,7 +570,7 @@ module.exports = class bybit extends Exchange { async fetchTickers (symbols = undefined, params = {}) { await this.loadMarkets (); - const response = await this.publicGetTickers (params); + const response = await this.v2PublicGetTickers (params); // // { // ret_code: 0, @@ -740,7 +668,7 @@ module.exports = class bybit extends Exchange { const now = this.seconds (); if (since === undefined) { if (limit === undefined) { - throw new ArgumentsRequired (this.id + ' fetchOHLCV requires a since argument or a limit argument'); + throw new ArgumentsRequired (this.id + ' fetchOHLCV() requires a since argument or a limit argument'); } else { request['from'] = now - limit * duration; } @@ -752,7 +680,7 @@ module.exports = class bybit extends Exchange { } const marketTypes = this.safeValue (this.options, 'marketTypes', {}); const marketType = this.safeString (marketTypes, symbol); - const method = (marketType === 'linear') ? 'publicLinearGetKline' : 'publicGetKlineList'; + const method = (marketType === 'linear') ? 'publicLinearGetKline' : 'v2PublicGetKlineList'; const response = await this[method] (this.extend (request, params)); // // inverse perpetual BTC/USD @@ -907,7 +835,7 @@ module.exports = class bybit extends Exchange { } const marketTypes = this.safeValue (this.options, 'marketTypes', {}); const marketType = this.safeString (marketTypes, symbol); - const method = (marketType === 'linear') ? 'publicLinearGetRecentTradingRecords' : 'publicGetTradingRecords'; + const method = (marketType === 'linear') ? 'publicLinearGetRecentTradingRecords' : 'v2PublicGetTradingRecords'; const response = await this[method] (this.extend (request, params)); // // { @@ -961,7 +889,7 @@ module.exports = class bybit extends Exchange { const request = { 'symbol': market['id'], }; - const response = await this.publicGetOrderBookL2 (this.extend (request, params)); + const response = await this.v2PublicGetOrderBookL2 (this.extend (request, params)); // // { // ret_code: 0, @@ -984,6 +912,65 @@ module.exports = class bybit extends Exchange { return this.parseOrderBook (result, timestamp, 'Buy', 'Sell', 'price', 'size'); } + async fetchBalance (params = {}) { + await this.loadMarkets (); + const request = {}; + const coin = this.safeString (params, 'coin'); + const code = this.safeString (params, 'code'); + if (coin !== undefined) { + request['coin'] = coin; + } else if (code !== undefined) { + const currency = this.currency (code); + request['coin'] = currency['id']; + } + const response = await this.v2PrivateGetWalletBalance (this.extend (request, params)); + // + // { + // ret_code: 0, + // ret_msg: 'OK', + // ext_code: '', + // ext_info: '', + // result: { + // BTC: { + // equity: 0, + // available_balance: 0, + // used_margin: 0, + // order_margin: 0, + // position_margin: 0, + // occ_closing_fee: 0, + // occ_funding_fee: 0, + // wallet_balance: 0, + // realised_pnl: 0, + // unrealised_pnl: 0, + // cum_realised_pnl: 0, + // given_cash: 0, + // service_cash: 0 + // } + // }, + // time_now: '1583937810.370020', + // rate_limit_status: 119, + // rate_limit_reset_ms: 1583937810367, + // rate_limit: 120 + // } + // + const result = { + 'info': response, + }; + const balances = this.safeValue (response, 'result', {}); + const currencyIds = Object.keys (balances); + for (let i = 0; i < currencyIds.length; i++) { + const currencyId = currencyIds[i]; + const balance = balances[currencyId]; + const code = this.safeCurrencyCode (currencyId); + const account = this.account (); + account['free'] = this.safeFloat (balance, 'available_balance'); + account['used'] = this.safeFloat (balance, 'used_margin'); + account['total'] = this.safeFloat (balance, 'equity'); + result[code] = account; + } + return this.parseBalance (result); + } + parseOrderStatus (status) { const statuses = { // basic orders @@ -1166,6 +1153,7 @@ module.exports = class bybit extends Exchange { } const timeInForce = this.parseTimeInForce (this.safeString (order, 'time_in_force')); const stopPrice = this.safeFloat (order, 'stop_px'); + const postOnly = (timeInForce === 'PO'); return { 'info': order, 'id': id, @@ -1176,6 +1164,7 @@ module.exports = class bybit extends Exchange { 'symbol': symbol, 'type': type, 'timeInForce': timeInForce, + 'postOnly': postOnly, 'side': side, 'price': price, 'stopPrice': stopPrice, @@ -1192,7 +1181,7 @@ module.exports = class bybit extends Exchange { async fetchOrder (id, symbol = undefined, params = {}) { if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' fetchOrder requires a symbol argument'); + throw new ArgumentsRequired (this.id + ' fetchOrder() requires a symbol argument'); } await this.loadMarkets (); const market = this.market (symbol); @@ -1206,7 +1195,7 @@ module.exports = class bybit extends Exchange { }; const marketTypes = this.safeValue (this.options, 'marketTypes', {}); const marketType = this.safeString (marketTypes, symbol); - let method = (marketType === 'linear') ? 'privateLinearGetOrderSearch' : 'privateGetOrder'; + let method = (marketType === 'linear') ? 'privateLinearGetOrderSearch' : 'v2PrivateGetOrder'; const stopOrderId = this.safeString (params, 'stop_order_id'); if (stopOrderId === undefined) { const orderLinkId = this.safeString (params, 'order_link_id'); @@ -1214,7 +1203,7 @@ module.exports = class bybit extends Exchange { request['order_id'] = id; } } else { - method = (marketType === 'linear') ? 'privateLinearGetStopOrderSearch' : 'privateGetStopOrder'; + method = (marketType === 'linear') ? 'privateLinearGetStopOrderSearch' : 'v2PrivateGetStopOrder'; } const response = await this[method] (this.extend (request, params)); // @@ -1327,7 +1316,7 @@ module.exports = class bybit extends Exchange { if (price !== undefined) { request['price'] = parseFloat (this.priceToPrecision (symbol, price)); } else { - throw new ArgumentsRequired (this.id + ' createOrder requires a price argument for a ' + type + ' order'); + throw new ArgumentsRequired (this.id + ' createOrder() requires a price argument for a ' + type + ' order'); } } const clientOrderId = this.safeString2 (params, 'order_link_id', 'clientOrderId'); @@ -1339,7 +1328,7 @@ module.exports = class bybit extends Exchange { const basePrice = this.safeValue (params, 'base_price'); const marketTypes = this.safeValue (this.options, 'marketTypes', {}); const marketType = this.safeString (marketTypes, symbol); - let method = (marketType === 'linear') ? 'privateLinearPostOrderCreate' : 'privatePostOrderCreate'; + let method = (marketType === 'linear') ? 'privateLinearPostOrderCreate' : 'v2PrivatePostOrderCreate'; if (marketType === 'linear') { method = 'privateLinearPostOrderCreate'; request['reduce_only'] = false; @@ -1347,15 +1336,15 @@ module.exports = class bybit extends Exchange { } if (stopPx !== undefined) { if (basePrice === undefined) { - throw new ArgumentsRequired (this.id + ' createOrder requires both the stop_px and base_price params for a conditional ' + type + ' order'); + throw new ArgumentsRequired (this.id + ' createOrder() requires both the stop_px and base_price params for a conditional ' + type + ' order'); } else { - method = (marketType === 'linear') ? 'privateLinearPostStopOrderCreate' : 'openapiPostStopOrderCreate'; + method = (marketType === 'linear') ? 'privateLinearPostStopOrderCreate' : 'v2PrivatePostStopOrderCreate'; request['stop_px'] = parseFloat (this.priceToPrecision (symbol, stopPx)); request['base_price'] = parseFloat (this.priceToPrecision (symbol, basePrice)); params = this.omit (params, [ 'stop_px', 'stopPrice', 'base_price' ]); } } else if (basePrice !== undefined) { - throw new ArgumentsRequired (this.id + ' createOrder requires both the stop_px and base_price params for a conditional ' + type + ' order'); + throw new ArgumentsRequired (this.id + ' createOrder() requires both the stop_px and base_price params for a conditional ' + type + ' order'); } const response = await this[method] (this.extend (request, params)); // @@ -1441,7 +1430,7 @@ module.exports = class bybit extends Exchange { async editOrder (id, symbol, type, side, amount = undefined, price = undefined, params = {}) { if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' editOrder requires an symbol argument'); + throw new ArgumentsRequired (this.id + ' editOrder() requires an symbol argument'); } const marketTypes = this.safeValue (this.options, 'marketTypes', {}); const marketType = this.safeString (marketTypes, symbol); @@ -1457,17 +1446,23 @@ module.exports = class bybit extends Exchange { // 'stop_order_id': id, // only for conditional orders // 'p_r_trigger_price': 123.45, // new trigger price also known as stop_px }; - let method = (marketType === 'linear') ? 'privateLinearPostOrderReplace' : 'openapiPostOrderReplace'; + let method = (marketType === 'linear') ? 'privateLinearPostOrderReplace' : 'v2PrivatePostOrderReplace'; const stopOrderId = this.safeString (params, 'stop_order_id'); if (stopOrderId !== undefined) { - method = (marketType === 'linear') ? 'privateLinearPostStopOrderReplace' : 'openapiPostStopOrderReplace'; + method = (marketType === 'linear') ? 'privateLinearPostStopOrderReplace' : 'v2PrivatePostStopOrderReplace'; request['stop_order_id'] = stopOrderId; params = this.omit (params, [ 'stop_order_id' ]); } else { request['order_id'] = id; } if (amount !== undefined) { - request['p_r_qty'] = parseInt (this.amountToPrecision (symbol, amount)); + let qty = this.amountToPrecision (symbol, amount); + if (market['inverse']) { + qty = parseInt (qty); + } else { + qty = parseFloat (qty); + } + request['p_r_qty'] = qty; } if (price !== undefined) { request['p_r_price'] = parseFloat (this.priceToPrecision (symbol, price)); @@ -1510,7 +1505,7 @@ module.exports = class bybit extends Exchange { async cancelOrder (id, symbol = undefined, params = {}) { if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' cancelOrder requires a symbol argument'); + throw new ArgumentsRequired (this.id + ' cancelOrder() requires a symbol argument'); } await this.loadMarkets (); const market = this.market (symbol); @@ -1524,7 +1519,7 @@ module.exports = class bybit extends Exchange { }; const marketTypes = this.safeValue (this.options, 'marketTypes', {}); const marketType = this.safeValue (marketTypes, symbol); - let method = (marketType === 'linear') ? 'privateLinearPostOrderCancel' : 'privatePostOrderCancel'; + let method = (marketType === 'linear') ? 'privateLinearPostOrderCancel' : 'v2PrivatePostOrderCancel'; const stopOrderId = this.safeString (params, 'stop_order_id'); if (stopOrderId === undefined) { const orderLinkId = this.safeString (params, 'order_link_id'); @@ -1532,7 +1527,7 @@ module.exports = class bybit extends Exchange { request['order_id'] = id; } } else { - method = (marketType === 'linear') ? 'privateLinearPostStopOrderCancel' : 'openapiPostStopOrderCancel'; + method = (marketType === 'linear') ? 'privateLinearPostStopOrderCancel' : 'v2PrivatePostStopOrderCancel'; } const response = await this[method] (this.extend (request, params)); const result = this.safeValue (response, 'result', {}); @@ -1541,17 +1536,17 @@ module.exports = class bybit extends Exchange { async cancelAllOrders (symbol = undefined, params = {}) { if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' cancelAllOrders requires a symbol argument'); + throw new ArgumentsRequired (this.id + ' cancelAllOrders() requires a symbol argument'); } await this.loadMarkets (); const market = this.market (symbol); const request = { 'symbol': market['id'], }; - const options = this.safeValue (this.options, 'cancelAllOrders'); + const options = this.safeValue (this.options, 'cancelAllOrders', {}); const marketTypes = this.safeValue (this.options, 'marketTypes', {}); const marketType = this.safeString (marketTypes, symbol); - const defaultMethod = (marketType === 'linear') ? 'privateLinearPostOrderCancelAll' : 'privatePostOrderCancelAll'; + const defaultMethod = (marketType === 'linear') ? 'privateLinearPostOrderCancelAll' : 'v2PrivatePostOrderCancelAll'; const method = this.safeString (options, 'method', defaultMethod); const response = await this[method] (this.extend (request, params)); const result = this.safeValue (response, 'result', []); @@ -1583,7 +1578,7 @@ module.exports = class bybit extends Exchange { const options = this.safeValue (this.options, 'fetchOrders', {}); const marketTypes = this.safeValue (this.options, 'marketTypes', {}); const marketType = this.safeString (marketTypes, symbol); - let defaultMethod = (marketType === 'linear') ? 'privateLinearGetOrderList' : 'openapiGetOrderList'; + let defaultMethod = (marketType === 'linear') ? 'privateLinearGetOrderList' : 'v2PrivateGetOrderList'; let query = params; if (('stop_order_id' in params) || ('stop_order_status' in params)) { let stopOrderStatus = this.safeValue (params, 'stopOrderStatus'); @@ -1594,7 +1589,7 @@ module.exports = class bybit extends Exchange { request['stop_order_status'] = stopOrderStatus; query = this.omit (params, 'stop_order_status'); } - defaultMethod = (marketType === 'linear') ? 'privateLinearGetStopOrderList' : 'openapiGetStopOrderList'; + defaultMethod = (marketType === 'linear') ? 'privateLinearGetStopOrderList' : 'v2PrivateGetStopOrderList'; } const method = this.safeString (options, 'method', defaultMethod); const response = await this[method] (this.extend (request, query)); @@ -1760,7 +1755,7 @@ module.exports = class bybit extends Exchange { if (symbol === undefined) { const orderId = this.safeString (params, 'order_id'); if (orderId === undefined) { - throw new ArgumentsRequired (this.id + ' fetchMyTrades requires a symbol argument or an order_id param'); + throw new ArgumentsRequired (this.id + ' fetchMyTrades() requires a symbol argument or an order_id param'); } else { request['order_id'] = orderId; params = this.omit (params, 'order_id'); @@ -1777,7 +1772,7 @@ module.exports = class bybit extends Exchange { } const marketTypes = this.safeValue (this.options, 'marketTypes', {}); const marketType = this.safeString (marketTypes, symbol); - const method = (marketType === 'linear') ? 'privateLinearGetTradeExecutionList' : 'privateGetExecutionList'; + const method = (marketType === 'linear') ? 'privateLinearGetTradeExecutionList' : 'v2PrivateGetExecutionList'; const response = await this[method] (this.extend (request, params)); // // inverse @@ -1867,41 +1862,60 @@ module.exports = class bybit extends Exchange { } async fetchDeposits (code = undefined, since = undefined, limit = undefined, params = {}) { - if (code === undefined) { - throw new ArgumentsRequired (this.id + ' fetchWithdrawals() requires a currency code argument'); - } await this.loadMarkets (); - const currency = this.currency (code); const request = { - 'currency': currency['id'], + // 'coin': currency['id'], + // 'currency': currency['id'], // alias + // 'start_date': this.iso8601 (since), + // 'end_date': this.iso8601 (till), + 'wallet_fund_type': 'Deposit', // Deposit, Withdraw, RealisedPNL, Commission, Refund, Prize, ExchangeOrderWithdraw, ExchangeOrderDeposit + // 'page': 1, + // 'limit': 20, // max 50 }; - if (limit !== undefined) { - request['count'] = limit; + let currency = undefined; + if (code !== undefined) { + currency = this.currency (code); + request['coin'] = currency['id']; } - const response = await this.privateGetGetDeposits (this.extend (request, params)); + if (since !== undefined) { + request['start_date'] = this.ymd (since); + } + if (limit !== undefined) { + request['limit'] = limit; + } + const response = await this.v2PrivateGetWalletFundRecords (this.extend (request, params)); // // { - // "jsonrpc": "2.0", - // "id": 5611, + // "ret_code": 0, + // "ret_msg": "ok", + // "ext_code": "", // "result": { - // "count": 1, // "data": [ // { - // "address": "2N35qDKDY22zmJq9eSyiAerMD4enJ1xx6ax", - // "amount": 5, - // "currency": "BTC", - // "received_timestamp": 1549295017670, - // "state": "completed", - // "transaction_id": "230669110fdaf0a0dbcdc079b6b8b43d5af29cc73683835b9bc6b3406c065fda", - // "updated_timestamp": 1549295130159 + // "id": 234467, + // "user_id": 1, + // "coin": "BTC", + // "wallet_id": 27913, + // "type": "Realized P&L", + // "amount": "-0.00000006", + // "tx_id": "", + // "address": "BTCUSD", + // "wallet_balance": "0.03000330", + // "exec_time": "2019-12-09T00:00:25.000Z", + // "cross_seq": 0 // } // ] - // } + // }, + // "ext_info": null, + // "time_now": "1577481867.115552", + // "rate_limit_status": 119, + // "rate_limit_reset_ms": 1577481867122, + // "rate_limit": 120 // } // const result = this.safeValue (response, 'result', {}); const data = this.safeValue (result, 'data', []); - return this.parseTransactions (data, currency, since, limit, params); + return this.parseTransactions (data, currency, since, limit); } async fetchWithdrawals (code = undefined, since = undefined, limit = undefined, params = {}) { @@ -1920,12 +1934,12 @@ module.exports = class bybit extends Exchange { request['coin'] = currency['id']; } if (since !== undefined) { - request['start_date'] = this.iso8601 (since); + request['start_date'] = this.ymd (since); } if (limit !== undefined) { request['limit'] = limit; } - const response = await this.openapiGetWalletWithdrawList (this.extend (request, params)); + const response = await this.v2PrivateGetWalletWithdrawList (this.extend (request, params)); // // { // "ret_code": 0, @@ -1991,9 +2005,25 @@ module.exports = class bybit extends Exchange { // "updated_at": "2019-06-11T02:20:24.000Z" // } // + // fetchDeposits ledger entries + // + // { + // "id": 234467, + // "user_id": 1, + // "coin": "BTC", + // "wallet_id": 27913, + // "type": "Realized P&L", + // "amount": "-0.00000006", + // "tx_id": "", + // "address": "BTCUSD", + // "wallet_balance": "0.03000330", + // "exec_time": "2019-12-09T00:00:25.000Z", + // "cross_seq": 0 + // } + // const currencyId = this.safeString (transaction, 'coin'); const code = this.safeCurrencyCode (currencyId, currency); - const timestamp = this.parse8601 (this.safeString (transaction, 'submited_at')); + const timestamp = this.parse8601 (this.safeString2 (transaction, 'submited_at', 'exec_time')); const updated = this.parse8601 (this.safeString (transaction, 'updated_at')); const status = this.parseTransactionStatus (this.safeString (transaction, 'status')); const address = this.safeString (transaction, 'address'); @@ -2043,12 +2073,12 @@ module.exports = class bybit extends Exchange { request['coin'] = currency['id']; } if (since !== undefined) { - request['start_date'] = this.iso8601 (since); + request['start_date'] = this.ymd (since); } if (limit !== undefined) { request['limit'] = limit; } - const response = await this.openapiGetWalletFundRecords (this.extend (request, params)); + const response = await this.v2PrivateGetWalletFundRecords (this.extend (request, params)); // // { // "ret_code": 0, @@ -2147,45 +2177,28 @@ module.exports = class bybit extends Exchange { } sign (path, api = 'public', method = 'GET', params = {}, headers = undefined, body = undefined) { - let url = this.urls['api']; - let request = path; + let url = this.implodeParams (this.urls['api'], { 'hostname': this.hostname }); + const type = this.safeString (api, 0); + const section = this.safeString (api, 1); + let request = '/' + type + '/' + section + '/' + path; // public v2 - if (api === 'public') { - request = '/' + this.version + '/' + api + '/' + request; + if (section === 'public') { if (Object.keys (params).length) { request += '?' + this.rawencode (params); } - } else if (api === 'publicLinear') { - request = '/public/linear/' + request; + } else if (type === 'public') { if (Object.keys (params).length) { request += '?' + this.rawencode (params); } } else { this.checkRequiredCredentials (); - if (api === 'openapi') { - request = '/open-api/' + request; - } else if (api === 'private') { - // private v2 - request = '/' + this.version + '/' + api + '/' + request; - } else if (api === 'privateLinear') { - request = '/private/linear/' + request; - } else { - // position, user - request = '/' + api + '/' + request; - } const timestamp = this.nonce (); const query = this.extend (params, { 'api_key': this.apiKey, 'recv_window': this.options['recvWindow'], 'timestamp': timestamp, }); - let auth = this.rawencode (this.keysort (query)); - // https://github.com/ccxt/ccxt/issues/7377 - // https://github.com/ccxt/ccxt/issues/7515 - // bybit encodes whole floats as integers without .0 for conditional stop-orders only - if (path.indexOf ('stop-order') >= 0) { - auth = auth.replace ('.0&', '&'); - } + const auth = this.rawencode (this.keysort (query)); const signature = this.hmac (this.encode (auth), this.encode (this.secret)); if (method === 'POST') { body = this.json (this.extend (query, { diff --git a/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/bytetrade.js b/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/bytetrade.js index bbd1af6f6..25953b6f7 100644 --- a/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/bytetrade.js +++ b/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/bytetrade.js @@ -285,7 +285,7 @@ module.exports = class bytetrade extends Exchange { async fetchBalance (params = {}) { if (!('userid' in params) && (this.apiKey === undefined)) { - throw new ArgumentsRequired (this.id + ' fetchDeposits requires this.apiKey or userid argument'); + throw new ArgumentsRequired (this.id + ' fetchDeposits() requires this.apiKey or userid argument'); } await this.loadMarkets (); const request = { @@ -580,6 +580,7 @@ module.exports = class bytetrade extends Exchange { 'symbol': symbol, 'type': type, 'timeInForce': undefined, + 'postOnly': undefined, 'side': side, 'price': price, 'stopPrice': undefined, @@ -597,7 +598,7 @@ module.exports = class bytetrade extends Exchange { async createOrder (symbol, type, side, amount, price = undefined, params = {}) { this.checkRequiredDependencies (); if (this.apiKey === undefined) { - throw new ArgumentsRequired ('createOrder requires this.apiKey or userid in params'); + throw new ArgumentsRequired ('createOrder() requires this.apiKey or userid in params'); } await this.loadMarkets (); const market = this.market (symbol); @@ -781,7 +782,7 @@ module.exports = class bytetrade extends Exchange { async fetchOrder (id, symbol = undefined, params = {}) { if (!('userid' in params) && (this.apiKey === undefined)) { - throw new ArgumentsRequired ('fetchOrder requires this.apiKey or userid argument'); + throw new ArgumentsRequired ('fetchOrder() requires this.apiKey or userid argument'); } await this.loadMarkets (); const request = { @@ -799,7 +800,7 @@ module.exports = class bytetrade extends Exchange { async fetchOpenOrders (symbol = undefined, since = undefined, limit = undefined, params = {}) { if (!('userid' in params) && (this.apiKey === undefined)) { - throw new ArgumentsRequired ('fetchOpenOrders requires this.apiKey or userid argument'); + throw new ArgumentsRequired ('fetchOpenOrders() requires this.apiKey or userid argument'); } await this.loadMarkets (); const request = { @@ -819,7 +820,7 @@ module.exports = class bytetrade extends Exchange { async fetchClosedOrders (symbol = undefined, since = undefined, limit = undefined, params = {}) { if (!('userid' in params) && (this.apiKey === undefined)) { - throw new ArgumentsRequired ('fetchClosedOrders requires this.apiKey or userid argument'); + throw new ArgumentsRequired ('fetchClosedOrders() requires this.apiKey or userid argument'); } await this.loadMarkets (); let market = undefined; @@ -839,7 +840,7 @@ module.exports = class bytetrade extends Exchange { async fetchOrders (symbol = undefined, since = undefined, limit = undefined, params = {}) { if (!('userid' in params) && (this.apiKey === undefined)) { - throw new ArgumentsRequired ('fetchOrders requires this.apiKey or userid argument'); + throw new ArgumentsRequired ('fetchOrders() requires this.apiKey or userid argument'); } await this.loadMarkets (); let market = undefined; @@ -859,10 +860,10 @@ module.exports = class bytetrade extends Exchange { async cancelOrder (id, symbol = undefined, params = {}) { if (this.apiKey === undefined) { - throw new ArgumentsRequired ('cancelOrder requires hasAlreadyAuthenticatedSuccessfully'); + throw new ArgumentsRequired ('cancelOrder() requires hasAlreadyAuthenticatedSuccessfully'); } if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' cancelOrder requires a symbol argument'); + throw new ArgumentsRequired (this.id + ' cancelOrder() requires a symbol argument'); } await this.loadMarkets (); const market = this.market (symbol); @@ -960,7 +961,7 @@ module.exports = class bytetrade extends Exchange { async transfer (code, amount, address, message = '', params = {}) { this.checkRequiredDependencies (); if (this.apiKey === undefined) { - throw new ArgumentsRequired ('transfer requires this.apiKey'); + throw new ArgumentsRequired ('transfer() requires this.apiKey'); } await this.loadMarkets (); const currency = this.currency (code); @@ -1066,7 +1067,7 @@ module.exports = class bytetrade extends Exchange { async fetchMyTrades (symbol = undefined, since = undefined, limit = undefined, params = {}) { if (!('userid' in params) && (this.apiKey === undefined)) { - throw new ArgumentsRequired ('fetchMyTrades requires this.apiKey or userid argument'); + throw new ArgumentsRequired ('fetchMyTrades() requires this.apiKey or userid argument'); } await this.loadMarkets (); const market = this.market (symbol); @@ -1086,7 +1087,7 @@ module.exports = class bytetrade extends Exchange { async fetchDeposits (code = undefined, since = undefined, limit = undefined, params = {}) { await this.loadMarkets (); if (!('userid' in params) && (this.apiKey === undefined)) { - throw new ArgumentsRequired ('fetchDeposits requires this.apiKey or userid argument'); + throw new ArgumentsRequired ('fetchDeposits() requires this.apiKey or userid argument'); } let currency = undefined; const request = { @@ -1109,7 +1110,7 @@ module.exports = class bytetrade extends Exchange { async fetchWithdrawals (code = undefined, since = undefined, limit = undefined, params = {}) { await this.loadMarkets (); if (!('userid' in params) && (this.apiKey === undefined)) { - throw new ArgumentsRequired ('fetchWithdrawals requires this.apiKey or userid argument'); + throw new ArgumentsRequired ('fetchWithdrawals() requires this.apiKey or userid argument'); } let currency = undefined; const request = { @@ -1193,7 +1194,7 @@ module.exports = class bytetrade extends Exchange { async fetchDepositAddress (code, params = {}) { await this.loadMarkets (); if (!('userid' in params) && (this.apiKey === undefined)) { - throw new ArgumentsRequired ('fetchDepositAddress requires this.apiKey or userid argument'); + throw new ArgumentsRequired ('fetchDepositAddress() requires this.apiKey or userid argument'); } const currency = this.currency (code); const request = { @@ -1219,7 +1220,7 @@ module.exports = class bytetrade extends Exchange { this.checkAddress (address); await this.loadMarkets (); if (this.apiKey === undefined) { - throw new ArgumentsRequired ('withdraw requires this.apiKey'); + throw new ArgumentsRequired (this.id + ' withdraw() requires this.apiKey'); } const addressResponse = await this.fetchDepositAddress (code); const chainTypeString = this.safeString (addressResponse, 'chainType'); diff --git a/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/huobiru.js b/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/cdax.js similarity index 53% rename from Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/huobiru.js rename to Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/cdax.js index 21e0de149..8bd27989d 100644 --- a/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/huobiru.js +++ b/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/cdax.js @@ -6,25 +6,27 @@ const huobipro = require ('./huobipro.js'); // --------------------------------------------------------------------------- -module.exports = class huobiru extends huobipro { +module.exports = class cdax extends huobipro { describe () { return this.deepExtend (super.describe (), { - 'id': 'huobiru', - 'name': 'Huobi Russia', + 'id': 'cdax', + 'name': 'CDAX', 'countries': [ 'RU' ], - 'hostname': 'www.huobi.com.ru', - 'pro': true, + 'hostname': 'cdax.io', + 'pro': false, 'urls': { - 'logo': 'https://user-images.githubusercontent.com/1294454/52978816-e8552e00-33e3-11e9-98ed-845acfece834.jpg', + 'logo': 'https://user-images.githubusercontent.com/1294454/102157692-fd406280-3e90-11eb-8d46-4511b617cd17.jpg', 'api': { 'market': 'https://{hostname}/api', 'public': 'https://{hostname}/api', 'private': 'https://{hostname}/api', + 'v2Public': 'https://{hostname}/api', + 'v2Private': 'https://{hostname}/api', }, - 'www': 'https://www.huobi.com.ru/ru-ru', - 'referral': 'https://www.huobi.com.ru/invite?invite_code=esc74', - 'doc': 'https://github.com/cloudapidoc/API_Docs_en', - 'fees': 'https://www.huobi.com.ru/ru-ru/about/fee/', + 'www': 'https://cdax.io', + 'referral': 'https://cdax.io/invite?invite_code=esc74', + 'doc': 'https://github.com/cloudapidoc/API_Docs', + 'fees': 'https://cdax.io/about/fee', }, }); } diff --git a/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/cex.js b/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/cex.js index 082db07c7..77473d391 100644 --- a/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/cex.js +++ b/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/cex.js @@ -676,10 +676,9 @@ module.exports = class cex extends Exchange { let cost = undefined; if (market !== undefined) { symbol = market['symbol']; - cost = this.safeFloat (order, 'ta:' + market['quote']); - if (cost === undefined) { - cost = this.safeFloat (order, 'tta:' + market['quote']); - } + const taCost = this.safeFloat (order, 'ta:' + market['quote']); + const ttaCost = this.safeFloat (order, 'tta:' + market['quote']); + cost = this.sum (taCost, ttaCost); const baseFee = 'fa:' + market['base']; const baseTakerFee = 'tfa:' + market['base']; const quoteFee = 'fa:' + market['quote']; @@ -883,6 +882,7 @@ module.exports = class cex extends Exchange { 'symbol': symbol, 'type': (price === undefined) ? 'market' : 'limit', 'timeInForce': undefined, + 'postOnly': undefined, 'side': side, 'price': price, 'stopPrice': undefined, @@ -918,7 +918,7 @@ module.exports = class cex extends Exchange { await this.loadMarkets (); const method = 'privatePostArchivedOrdersPair'; if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' fetchClosedOrders requires a symbol argument'); + throw new ArgumentsRequired (this.id + ' fetchClosedOrders() requires a symbol argument'); } const market = this.market (symbol); const request = { 'pair': market['id'] }; @@ -1252,10 +1252,10 @@ module.exports = class cex extends Exchange { async editOrder (id, symbol, type, side, amount = undefined, price = undefined, params = {}) { if (amount === undefined) { - throw new ArgumentsRequired (this.id + ' editOrder requires a amount argument'); + throw new ArgumentsRequired (this.id + ' editOrder() requires a amount argument'); } if (price === undefined) { - throw new ArgumentsRequired (this.id + ' editOrder requires a price argument'); + throw new ArgumentsRequired (this.id + ' editOrder() requires a price argument'); } await this.loadMarkets (); const market = this.market (symbol); diff --git a/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/coinbase.js b/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/coinbase.js index 61fc650dc..cfceba2a4 100644 --- a/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/coinbase.js +++ b/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/coinbase.js @@ -3,7 +3,7 @@ // ---------------------------------------------------------------------------- const Exchange = require ('./base/Exchange'); -const { ExchangeError, ArgumentsRequired, AuthenticationError, RateLimitExceeded } = require ('./base/errors'); +const { ExchangeError, ArgumentsRequired, AuthenticationError, RateLimitExceeded, InvalidNonce } = require ('./base/errors'); // ---------------------------------------------------------------------------- @@ -123,23 +123,28 @@ module.exports = class coinbase extends Exchange { }, }, 'exceptions': { - 'two_factor_required': AuthenticationError, // 402 When sending money over 2fa limit - 'param_required': ExchangeError, // 400 Missing parameter - 'validation_error': ExchangeError, // 400 Unable to validate POST/PUT - 'invalid_request': ExchangeError, // 400 Invalid request - 'personal_details_required': AuthenticationError, // 400 User’s personal detail required to complete this request - 'identity_verification_required': AuthenticationError, // 400 Identity verification is required to complete this request - 'jumio_verification_required': AuthenticationError, // 400 Document verification is required to complete this request - 'jumio_face_match_verification_required': AuthenticationError, // 400 Document verification including face match is required to complete this request - 'unverified_email': AuthenticationError, // 400 User has not verified their email - 'authentication_error': AuthenticationError, // 401 Invalid auth (generic) - 'invalid_token': AuthenticationError, // 401 Invalid Oauth token - 'revoked_token': AuthenticationError, // 401 Revoked Oauth token - 'expired_token': AuthenticationError, // 401 Expired Oauth token - 'invalid_scope': AuthenticationError, // 403 User hasn’t authenticated necessary scope - 'not_found': ExchangeError, // 404 Resource not found - 'rate_limit_exceeded': RateLimitExceeded, // 429 Rate limit exceeded - 'internal_server_error': ExchangeError, // 500 Internal server error + 'exact': { + 'two_factor_required': AuthenticationError, // 402 When sending money over 2fa limit + 'param_required': ExchangeError, // 400 Missing parameter + 'validation_error': ExchangeError, // 400 Unable to validate POST/PUT + 'invalid_request': ExchangeError, // 400 Invalid request + 'personal_details_required': AuthenticationError, // 400 User’s personal detail required to complete this request + 'identity_verification_required': AuthenticationError, // 400 Identity verification is required to complete this request + 'jumio_verification_required': AuthenticationError, // 400 Document verification is required to complete this request + 'jumio_face_match_verification_required': AuthenticationError, // 400 Document verification including face match is required to complete this request + 'unverified_email': AuthenticationError, // 400 User has not verified their email + 'authentication_error': AuthenticationError, // 401 Invalid auth (generic) + 'invalid_token': AuthenticationError, // 401 Invalid Oauth token + 'revoked_token': AuthenticationError, // 401 Revoked Oauth token + 'expired_token': AuthenticationError, // 401 Expired Oauth token + 'invalid_scope': AuthenticationError, // 403 User hasn’t authenticated necessary scope + 'not_found': ExchangeError, // 404 Resource not found + 'rate_limit_exceeded': RateLimitExceeded, // 429 Rate limit exceeded + 'internal_server_error': ExchangeError, // 500 Internal server error + }, + 'broad': { + 'request timestamp expired': InvalidNonce, // {"errors":[{"id":"authentication_error","message":"request timestamp expired"}]} + }, }, 'commonCurrencies': { 'CGLD': 'CELO', @@ -172,7 +177,11 @@ module.exports = class coinbase extends Exchange { } async fetchAccounts (params = {}) { - const response = await this.privateGetAccounts (params); + await this.loadMarkets (); + const request = { + 'limit': 100, + }; + const response = await this.privateGetAccounts (this.extend (request, params)); // // { // "id": "XLM", @@ -703,7 +712,10 @@ module.exports = class coinbase extends Exchange { async fetchBalance (params = {}) { await this.loadMarkets (); - const response = await this.privateGetAccounts (params); + const request = { + 'limit': 100, + }; + const response = await this.privateGetAccounts (this.extend (request, params)); const balances = this.safeValue (response, 'data'); const accounts = this.safeValue (params, 'type', this.options['accounts']); const result = { 'info': response }; @@ -1175,7 +1187,9 @@ module.exports = class coinbase extends Exchange { // let errorCode = this.safeString (response, 'error'); if (errorCode !== undefined) { - this.throwExactlyMatchedException (this.exceptions, errorCode, feedback); + const errorMessage = this.safeString (response, 'error_description'); + this.throwExactlyMatchedException (this.exceptions['exact'], errorCode, feedback); + this.throwBroadlyMatchedException (this.exceptions['broad'], errorMessage, feedback); throw new ExchangeError (feedback); } const errors = this.safeValue (response, 'errors'); @@ -1184,8 +1198,10 @@ module.exports = class coinbase extends Exchange { const numErrors = errors.length; if (numErrors > 0) { errorCode = this.safeString (errors[0], 'id'); + const errorMessage = this.safeString (errors[0], 'message'); if (errorCode !== undefined) { - this.throwExactlyMatchedException (this.exceptions, errorCode, feedback); + this.throwExactlyMatchedException (this.exceptions['exact'], errorCode, feedback); + this.throwBroadlyMatchedException (this.exceptions['broad'], errorMessage, feedback); throw new ExchangeError (feedback); } } diff --git a/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/coinbasepro.js b/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/coinbasepro.js index f28b951c4..582c03a61 100644 --- a/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/coinbasepro.js +++ b/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/coinbasepro.js @@ -345,6 +345,7 @@ module.exports = class coinbasepro extends Exchange { } async fetchAccounts (params = {}) { + await this.loadMarkets (); const response = await this.privateGetAccounts (params); // // [ @@ -523,12 +524,20 @@ module.exports = class coinbasepro extends Exchange { // trade_id: 82047307, // maker_order_id: '0f358725-2134-435e-be11-753912a326e0', // taker_order_id: '252b7002-87a3-425c-ac73-f5b9e23f3caf', + // order_id: 'd50ec984-77a8-460a-b958-66f114b0de9b', // side: 'sell', // size: '0.00513192', // price: '9314.78', // product_id: 'BTC-USD', + // profile_id: '6244401d-c078-40d9-b305-7ad3551bc3b0', // sequence: 12038915443, // time: '2020-01-31T20:03:41.158814Z' + // created_at: '2014-11-07T22:19:28.578544Z', + // liquidity: 'T', + // fee: '0.00025', + // settled: true, + // usd_volume: '0.0924556000000000', + // user_id: '595eb864313c2b02ddf2937d' // } // const timestamp = this.parse8601 (this.safeString2 (trade, 'time', 'created_at')); @@ -537,10 +546,15 @@ module.exports = class coinbasepro extends Exchange { let feeRate = undefined; let feeCurrency = undefined; let takerOrMaker = undefined; + let cost = undefined; if (market !== undefined) { + const feeCurrencyId = this.safeStringLower (market, 'quoteId'); + const costField = feeCurrencyId + '_value'; + cost = this.safeFloat (trade, costField); feeCurrency = market['quote']; - if ('liquidity' in trade) { - takerOrMaker = (trade['liquidity'] === 'T') ? 'taker' : 'maker'; + const liquidity = this.safeString (trade, 'liquidity'); + if (liquidity !== undefined) { + takerOrMaker = (liquidity === 'T') ? 'taker' : 'maker'; feeRate = market[takerOrMaker]; } } @@ -560,6 +574,9 @@ module.exports = class coinbasepro extends Exchange { } const price = this.safeFloat (trade, 'price'); const amount = this.safeFloat (trade, 'size'); + if (cost === undefined) { + cost = amount * price; + } return { 'id': id, 'order': orderId, @@ -573,14 +590,14 @@ module.exports = class coinbasepro extends Exchange { 'price': price, 'amount': amount, 'fee': fee, - 'cost': price * amount, + 'cost': cost, }; } async fetchMyTrades (symbol = undefined, since = undefined, limit = undefined, params = {}) { // as of 2018-08-23 if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' fetchMyTrades requires a symbol argument'); + throw new ArgumentsRequired (this.id + ' fetchMyTrades() requires a symbol argument'); } await this.loadMarkets (); const market = this.market (symbol); @@ -600,6 +617,9 @@ module.exports = class coinbasepro extends Exchange { const request = { 'id': market['id'], // fixes issue #2 }; + if (limit !== undefined) { + request['limit'] = limit; // default 100 + } const response = await this.publicGetProductsIdTrades (this.extend (request, params)); return this.parseTrades (response, market, since, limit); } @@ -676,6 +696,27 @@ module.exports = class coinbasepro extends Exchange { } parseOrder (order, market = undefined) { + // + // createOrder + // + // { + // "id": "d0c5340b-6d6c-49d9-b567-48c4bfca13d2", + // "price": "0.10000000", + // "size": "0.01000000", + // "product_id": "BTC-USD", + // "side": "buy", + // "stp": "dc", + // "type": "limit", + // "time_in_force": "GTC", + // "post_only": false, + // "created_at": "2016-12-08T20:02:28.53864Z", + // "fill_fees": "0.0000000000000000", + // "filled_size": "0.00000000", + // "executed_value": "0.0000000000000000", + // "status": "pending", + // "settled": false + // } + // const timestamp = this.parse8601 (this.safeString (order, 'created_at')); const marketId = this.safeString (order, 'product_id'); market = this.safeMarket (marketId, market, '-'); @@ -706,9 +747,13 @@ module.exports = class coinbasepro extends Exchange { const id = this.safeString (order, 'id'); const type = this.safeString (order, 'type'); const side = this.safeString (order, 'side'); + const timeInForce = this.safeString (order, 'time_in_force'); + const postOnly = this.safeValue (order, 'post_only'); + const stopPrice = this.safeFloat (order, 'stop_price'); + const clientOrderId = this.safeString (order, 'client_oid'); return { 'id': id, - 'clientOrderId': undefined, + 'clientOrderId': clientOrderId, 'info': order, 'timestamp': timestamp, 'datetime': this.iso8601 (timestamp), @@ -716,10 +761,11 @@ module.exports = class coinbasepro extends Exchange { 'status': status, 'symbol': market['symbol'], 'type': type, - 'timeInForce': undefined, + 'timeInForce': timeInForce, + 'postOnly': postOnly, 'side': side, 'price': price, - 'stopPrice': undefined, + 'stopPrice': stopPrice, 'cost': cost, 'amount': amount, 'filled': filled, @@ -732,10 +778,18 @@ module.exports = class coinbasepro extends Exchange { async fetchOrder (id, symbol = undefined, params = {}) { await this.loadMarkets (); - const request = { - 'id': id, - }; - const response = await this.privateGetOrdersId (this.extend (request, params)); + const request = {}; + const clientOrderId = this.safeString2 (params, 'clientOrderId', 'client_oid'); + let method = undefined; + if (clientOrderId === undefined) { + method = 'privateGetOrdersId'; + request['id'] = id; + } else { + method = 'privateGetOrdersClientClientOid'; + request['client_oid'] = clientOrderId; + params = this.omit (params, [ 'clientOrderId', 'client_oid' ]); + } + const response = await this[method] (this.extend (request, params)); return this.parseOrder (response); } @@ -753,17 +807,10 @@ module.exports = class coinbasepro extends Exchange { } async fetchOrders (symbol = undefined, since = undefined, limit = undefined, params = {}) { - await this.loadMarkets (); const request = { 'status': 'all', }; - let market = undefined; - if (symbol !== undefined) { - market = this.market (symbol); - request['product_id'] = market['id']; - } - const response = await this.privateGetOrders (this.extend (request, params)); - return this.parseOrders (response, market, since, limit); + return await this.fetchOpenOrders (symbol, since, limit, this.extend (request, params)); } async fetchOpenOrders (symbol = undefined, since = undefined, limit = undefined, params = {}) { @@ -774,47 +821,131 @@ module.exports = class coinbasepro extends Exchange { market = this.market (symbol); request['product_id'] = market['id']; } + if (limit !== undefined) { + request['limit'] = limit; // default 100 + } const response = await this.privateGetOrders (this.extend (request, params)); return this.parseOrders (response, market, since, limit); } async fetchClosedOrders (symbol = undefined, since = undefined, limit = undefined, params = {}) { - await this.loadMarkets (); const request = { 'status': 'done', }; - let market = undefined; - if (symbol !== undefined) { - market = this.market (symbol); - request['product_id'] = market['id']; - } - const response = await this.privateGetOrders (this.extend (request, params)); - return this.parseOrders (response, market, since, limit); + return await this.fetchOpenOrders (symbol, since, limit, this.extend (request, params)); } async createOrder (symbol, type, side, amount, price = undefined, params = {}) { await this.loadMarkets (); - // let oid = this.nonce ().toString (); + const market = this.market (symbol); const request = { - 'product_id': this.marketId (symbol), - 'side': side, - 'size': this.amountToPrecision (symbol, amount), + // common params -------------------------------------------------- + // 'client_oid': clientOrderId, 'type': type, + 'side': side, + 'product_id': market['id'], + // 'size': this.amountToPrecision (symbol, amount), + // 'stp': 'dc', // self-trade prevention, dc = decrease and cancel, co = cancel oldest, cn = cancel newest, cb = cancel both + // 'stop': 'loss', // "loss" = stop loss below price, "entry" = take profit above price + // 'stop_price': this.priceToPrecision (symbol, price), + // limit order params --------------------------------------------- + // 'price': this.priceToPrecision (symbol, price), + // 'size': this.amountToPrecision (symbol, amount), + // 'time_in_force': 'GTC', // GTC, GTT, IOC, or FOK + // 'cancel_after' [optional]* min, hour, day, requires time_in_force to be GTT + // 'post_only': false, // invalid when time_in_force is IOC or FOK + // market order params -------------------------------------------- + // 'size': this.amountToPrecision (symbol, amount), + // 'funds': this.costToPrecision (symbol, amount), }; + const clientOrderId = this.safeString2 (params, 'clientOrderId', 'client_oid'); + if (clientOrderId !== undefined) { + request['client_oid'] = clientOrderId; + params = this.omit (params, [ 'clientOrderId', 'client_oid' ]); + } + const stopPrice = this.safeFloat2 (params, 'stopPrice', 'stop_price'); + if (stopPrice !== undefined) { + request['stop_price'] = this.priceToPrecision (symbol, stopPrice); + params = this.omit (params, [ 'stopPrice', 'stop_price' ]); + } + const timeInForce = this.safeString2 (params, 'timeInForce', 'time_in_force'); + if (timeInForce !== undefined) { + request['time_in_force'] = timeInForce; + params = this.omit (params, [ 'timeInForce', 'time_in_force' ]); + } if (type === 'limit') { request['price'] = this.priceToPrecision (symbol, price); + request['size'] = this.amountToPrecision (symbol, amount); + } else if (type === 'market') { + let cost = this.safeFloat2 (params, 'cost', 'funds'); + if (cost === undefined) { + if (price !== undefined) { + cost = amount * price; + } + } else { + params = this.omit (params, [ 'cost', 'funds' ]); + } + if (cost !== undefined) { + request['funds'] = this.costToPrecision (symbol, cost); + } else { + request['size'] = this.amountToPrecision (symbol, amount); + } } const response = await this.privatePostOrders (this.extend (request, params)); - return this.parseOrder (response); + // + // { + // "id": "d0c5340b-6d6c-49d9-b567-48c4bfca13d2", + // "price": "0.10000000", + // "size": "0.01000000", + // "product_id": "BTC-USD", + // "side": "buy", + // "stp": "dc", + // "type": "limit", + // "time_in_force": "GTC", + // "post_only": false, + // "created_at": "2016-12-08T20:02:28.53864Z", + // "fill_fees": "0.0000000000000000", + // "filled_size": "0.00000000", + // "executed_value": "0.0000000000000000", + // "status": "pending", + // "settled": false + // } + // + return this.parseOrder (response, market); } async cancelOrder (id, symbol = undefined, params = {}) { await this.loadMarkets (); - return await this.privateDeleteOrdersId ({ 'id': id }); + const request = { + // 'product_id': market['id'], // the request will be more performant if you include it + }; + const clientOrderId = this.safeString2 (params, 'clientOrderId', 'client_oid'); + let method = undefined; + if (clientOrderId === undefined) { + method = 'privateDeleteOrdersId'; + request['id'] = id; + } else { + method = 'privateDeleteOrdersClientClientOid'; + request['client_oid'] = clientOrderId; + params = this.omit (params, [ 'clientOrderId', 'client_oid' ]); + } + let market = undefined; + if (symbol !== undefined) { + market = this.market (symbol); + request['product_id'] = market['symbol']; // the request will be more performant if you include it + } + return await this[method] (this.extend (request, params)); } async cancelAllOrders (symbol = undefined, params = {}) { - return await this.privateDeleteOrders (params); + await this.loadMarkets (); + const request = {}; + let market = undefined; + if (symbol !== undefined) { + market = this.market (symbol); + request['product_id'] = market['symbol']; // the request will be more performant if you include it + } + return await this.privateDeleteOrders (this.extend (request, params)); } calculateFee (symbol, type, side, amount, price, takerOrMaker = 'taker', params = {}) { @@ -880,6 +1011,9 @@ module.exports = class coinbasepro extends Exchange { } else { method += 'Crypto'; request['crypto_address'] = address; + if (tag !== undefined) { + request['destination_tag'] = tag; + } } const response = await this[method] (this.extend (request, params)); if (!response) { @@ -965,7 +1099,7 @@ module.exports = class coinbasepro extends Exchange { const currencyId = this.safeString (transaction, 'currency'); const code = this.safeCurrencyCode (currencyId, currency); const status = this.parseTransactionStatus (transaction); - const amount = this.safeFloat (transaction, 'amount'); + let amount = this.safeFloat (transaction, 'amount'); let type = this.safeString (transaction, 'type'); let address = this.safeString (details, 'crypto_address'); const tag = this.safeString (details, 'destination_tag'); @@ -976,9 +1110,12 @@ module.exports = class coinbasepro extends Exchange { address = this.safeString (details, 'sent_to_address', address); const feeCost = this.safeFloat (details, 'fee'); if (feeCost !== undefined) { + if (amount !== undefined) { + amount -= feeCost; + } fee = { 'cost': feeCost, - 'code': code, + 'currency': code, }; } } diff --git a/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/coincheck.js b/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/coincheck.js index 6b2618ad3..807882d02 100644 --- a/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/coincheck.js +++ b/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/coincheck.js @@ -81,10 +81,11 @@ module.exports = class coincheck extends Exchange { 'markets': { 'BTC/JPY': { 'id': 'btc_jpy', 'symbol': 'BTC/JPY', 'base': 'BTC', 'quote': 'JPY', 'baseId': 'btc', 'quoteId': 'jpy' }, // the only real pair // 'ETH/JPY': { 'id': 'eth_jpy', 'symbol': 'ETH/JPY', 'base': 'ETH', 'quote': 'JPY', 'baseId': 'eth', 'quoteId': 'jpy' }, - // 'ETC/JPY': { 'id': 'etc_jpy', 'symbol': 'ETC/JPY', 'base': 'ETC', 'quote': 'JPY', 'baseId': 'etc', 'quoteId': 'jpy' }, + 'ETC/JPY': { 'id': 'etc_jpy', 'symbol': 'ETC/JPY', 'base': 'ETC', 'quote': 'JPY', 'baseId': 'etc', 'quoteId': 'jpy' }, // 'DAO/JPY': { 'id': 'dao_jpy', 'symbol': 'DAO/JPY', 'base': 'DAO', 'quote': 'JPY', 'baseId': 'dao', 'quoteId': 'jpy' }, // 'LSK/JPY': { 'id': 'lsk_jpy', 'symbol': 'LSK/JPY', 'base': 'LSK', 'quote': 'JPY', 'baseId': 'lsk', 'quoteId': 'jpy' }, - // 'FCT/JPY': { 'id': 'fct_jpy', 'symbol': 'FCT/JPY', 'base': 'FCT', 'quote': 'JPY', 'baseId': 'fct', 'quoteId': 'jpy' }, + 'FCT/JPY': { 'id': 'fct_jpy', 'symbol': 'FCT/JPY', 'base': 'FCT', 'quote': 'JPY', 'baseId': 'fct', 'quoteId': 'jpy' }, + 'MONA/JPY': { 'id': 'mona_jpy', 'symbol': 'MONA/JPY', 'base': 'MONA', 'quote': 'JPY', 'baseId': 'mona', 'quoteId': 'jpy' }, // 'XMR/JPY': { 'id': 'xmr_jpy', 'symbol': 'XMR/JPY', 'base': 'XMR', 'quote': 'JPY', 'baseId': 'xmr', 'quoteId': 'jpy' }, // 'REP/JPY': { 'id': 'rep_jpy', 'symbol': 'REP/JPY', 'base': 'REP', 'quote': 'JPY', 'baseId': 'rep', 'quoteId': 'jpy' }, // 'XRP/JPY': { 'id': 'xrp_jpy', 'symbol': 'XRP/JPY', 'base': 'XRP', 'quote': 'JPY', 'baseId': 'xrp', 'quoteId': 'jpy' }, @@ -93,7 +94,7 @@ module.exports = class coincheck extends Exchange { // 'LTC/JPY': { 'id': 'ltc_jpy', 'symbol': 'LTC/JPY', 'base': 'LTC', 'quote': 'JPY', 'baseId': 'ltc', 'quoteId': 'jpy' }, // 'DASH/JPY': { 'id': 'dash_jpy', 'symbol': 'DASH/JPY', 'base': 'DASH', 'quote': 'JPY', 'baseId': 'dash', 'quoteId': 'jpy' }, // 'ETH/BTC': { 'id': 'eth_btc', 'symbol': 'ETH/BTC', 'base': 'ETH', 'quote': 'BTC', 'baseId': 'eth', 'quoteId': 'btc' }, - // 'ETC/BTC': { 'id': 'etc_btc', 'symbol': 'ETC/BTC', 'base': 'ETC', 'quote': 'BTC', 'baseId': 'etc', 'quoteId': 'btc' }, + 'ETC/BTC': { 'id': 'etc_btc', 'symbol': 'ETC/BTC', 'base': 'ETC', 'quote': 'BTC', 'baseId': 'etc', 'quoteId': 'btc' }, // 'LSK/BTC': { 'id': 'lsk_btc', 'symbol': 'LSK/BTC', 'base': 'LSK', 'quote': 'BTC', 'baseId': 'lsk', 'quoteId': 'btc' }, // 'FCT/BTC': { 'id': 'fct_btc', 'symbol': 'FCT/BTC', 'base': 'FCT', 'quote': 'BTC', 'baseId': 'fct', 'quoteId': 'btc' }, // 'XMR/BTC': { 'id': 'xmr_btc', 'symbol': 'XMR/BTC', 'base': 'XMR', 'quote': 'BTC', 'baseId': 'xmr', 'quoteId': 'btc' }, @@ -197,6 +198,7 @@ module.exports = class coincheck extends Exchange { 'side': side, 'type': undefined, 'timeInForce': undefined, + 'postOnly': undefined, 'status': status, 'symbol': symbol, 'price': price, @@ -210,11 +212,12 @@ module.exports = class coincheck extends Exchange { } async fetchOrderBook (symbol, limit = undefined, params = {}) { - if (symbol !== 'BTC/JPY') { - throw new BadSymbol (this.id + ' fetchOrderBook () supports BTC/JPY only'); - } await this.loadMarkets (); - const response = await this.publicGetOrderBooks (params); + const market = this.market (symbol); + const request = { + 'pair': market['id'], + }; + const response = await this.publicGetOrderBooks (this.extend (request, params)); return this.parseOrderBook (response); } @@ -223,7 +226,11 @@ module.exports = class coincheck extends Exchange { throw new BadSymbol (this.id + ' fetchTicker () supports BTC/JPY only'); } await this.loadMarkets (); - const ticker = await this.publicGetTicker (params); + const market = this.market (symbol); + const request = { + 'pair': market['id'], + }; + const ticker = await this.publicGetTicker (this.extend (request, params)); const timestamp = this.safeTimestamp (ticker, 'timestamp'); const last = this.safeFloat (ticker, 'last'); return { @@ -337,9 +344,6 @@ module.exports = class coincheck extends Exchange { } async fetchTrades (symbol, since = undefined, limit = undefined, params = {}) { - if (symbol !== 'BTC/JPY') { - throw new BadSymbol (this.id + ' fetchTrades () supports BTC/JPY only'); - } await this.loadMarkets (); const market = this.market (symbol); const request = { diff --git a/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/coinegg.js b/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/coinegg.js index 0918ef9a0..e270e3bf7 100644 --- a/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/coinegg.js +++ b/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/coinegg.js @@ -154,6 +154,7 @@ module.exports = class coinegg extends Exchange { }, 'commonCurrencies': { 'JBC': 'JubaoCoin', + 'SBTC': 'Super Bitcoin', }, }); } @@ -367,6 +368,7 @@ module.exports = class coinegg extends Exchange { 'symbol': symbol, 'type': type, 'timeInForce': undefined, + 'postOnly': undefined, 'side': side, 'price': price, 'stopPrice': undefined, diff --git a/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/coinex.js b/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/coinex.js index 91f4c2052..cc344ee72 100644 --- a/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/coinex.js +++ b/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/coinex.js @@ -92,6 +92,8 @@ module.exports = class coinex extends Exchange { 'order/status', 'order/status/batch', 'order/user/deals', + 'sub_account/balance', + 'sub_account/transfer/history', ], 'post': [ 'balance/coin/withdraw', @@ -499,6 +501,7 @@ module.exports = class coinex extends Exchange { 'symbol': symbol, 'type': type, 'timeInForce': undefined, + 'postOnly': undefined, 'side': side, 'price': price, 'stopPrice': undefined, @@ -562,7 +565,7 @@ module.exports = class coinex extends Exchange { async fetchOrder (id, symbol = undefined, params = {}) { if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' fetchOrder requires a symbol argument'); + throw new ArgumentsRequired (this.id + ' fetchOrder() requires a symbol argument'); } await this.loadMarkets (); const market = this.market (symbol); @@ -759,7 +762,7 @@ module.exports = class coinex extends Exchange { const timestamp = this.safeTimestamp (transaction, 'create_time'); const type = ('coin_withdraw_id' in transaction) ? 'withdraw' : 'deposit'; const status = this.parseTransactionStatus (this.safeString (transaction, 'status')); - const amount = this.safeFloat (transaction, 'amount'); + let amount = this.safeFloat (transaction, 'amount'); let feeCost = this.safeFloat (transaction, 'tx_fee'); if (type === 'deposit') { feeCost = 0; @@ -768,6 +771,10 @@ module.exports = class coinex extends Exchange { 'cost': feeCost, 'currency': code, }; + // https://github.com/ccxt/ccxt/issues/8321 + if (amount !== undefined) { + amount = amount - feeCost; + } return { 'info': transaction, 'id': id, @@ -787,7 +794,7 @@ module.exports = class coinex extends Exchange { async fetchWithdrawals (code = undefined, since = undefined, limit = undefined, params = {}) { if (code === undefined) { - throw new ArgumentsRequired (this.id + ' fetchWithdrawals requires a currency code argument'); + throw new ArgumentsRequired (this.id + ' fetchWithdrawals() requires a currency code argument'); } await this.loadMarkets (); const currency = this.currency (code); @@ -845,7 +852,7 @@ module.exports = class coinex extends Exchange { async fetchDeposits (code = undefined, since = undefined, limit = undefined, params = {}) { if (code === undefined) { - throw new ArgumentsRequired (this.id + ' fetchDeposits requires a currency code argument'); + throw new ArgumentsRequired (this.id + ' fetchDeposits() requires a currency code argument'); } await this.loadMarkets (); const currency = this.currency (code); @@ -910,7 +917,7 @@ module.exports = class coinex extends Exchange { 'tonce': nonce.toString (), }, query); query = this.keysort (query); - const urlencoded = this.urlencode (query); + const urlencoded = this.rawencode (query); const signature = this.hash (this.encode (urlencoded + '&secret_key=' + this.secret)); headers = { 'Authorization': signature.toUpperCase (), diff --git a/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/coinfalcon.js b/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/coinfalcon.js index 563a4c987..6c264b4ec 100644 --- a/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/coinfalcon.js +++ b/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/coinfalcon.js @@ -217,7 +217,7 @@ module.exports = class coinfalcon extends Exchange { async fetchMyTrades (symbol = undefined, since = undefined, limit = undefined, params = {}) { if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' fetchMyTrades requires a symbol argument'); + throw new ArgumentsRequired (this.id + ' fetchMyTrades() requires a symbol argument'); } await this.loadMarkets (); const market = this.market (symbol); @@ -320,6 +320,7 @@ module.exports = class coinfalcon extends Exchange { type = type[0]; } const side = this.safeString (order, 'order_type'); + const postOnly = this.safeValue (order, 'post_only'); return { 'id': this.safeString (order, 'id'), 'clientOrderId': undefined, @@ -329,6 +330,7 @@ module.exports = class coinfalcon extends Exchange { 'symbol': symbol, 'type': type, 'timeInForce': undefined, + 'postOnly': postOnly, 'side': side, 'price': price, 'stopPrice': undefined, diff --git a/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/coinfloor.js b/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/coinfloor.js index 5d59bdf98..7fff650de 100644 --- a/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/coinfloor.js +++ b/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/coinfloor.js @@ -27,7 +27,7 @@ module.exports = class coinfloor extends Exchange { }, 'urls': { 'logo': 'https://user-images.githubusercontent.com/51840849/87153925-ef265e80-c2c0-11ea-91b5-020c804b90e0.jpg', - 'api': 'https://webapi.coinfloor.co.uk/bist', + 'api': 'https://webapi.coinfloor.co.uk/v2/bist', 'www': 'https://www.coinfloor.co.uk', 'doc': [ 'https://github.com/coinfloor/api', @@ -90,7 +90,7 @@ module.exports = class coinfloor extends Exchange { market = this.markets_by_id[marketId]; } if (market === undefined) { - throw new ArgumentsRequired (this.id + ' fetchBalance requires a symbol param'); + throw new ArgumentsRequired (this.id + ' fetchBalance() requires a symbol param'); } const request = { 'id': market['id'], @@ -223,7 +223,7 @@ module.exports = class coinfloor extends Exchange { if (code !== undefined) { market = this.market (code); if (market === undefined) { - throw new ArgumentsRequired (this.id + ' fetchTransactions requires a code argument (a market symbol)'); + throw new ArgumentsRequired (this.id + ' fetchTransactions() requires a code argument (a market symbol)'); } } const request = { @@ -431,7 +431,7 @@ module.exports = class coinfloor extends Exchange { async cancelOrder (id, symbol = undefined, params = {}) { if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' cancelOrder requires a symbol argument'); + throw new ArgumentsRequired (this.id + ' cancelOrder() requires a symbol argument'); } await this.loadMarkets (); const market = this.market (symbol); @@ -480,6 +480,7 @@ module.exports = class coinfloor extends Exchange { 'symbol': symbol, 'type': 'limit', 'timeInForce': undefined, + 'postOnly': undefined, 'side': side, 'price': price, 'stopPrice': undefined, @@ -495,7 +496,7 @@ module.exports = class coinfloor extends Exchange { async fetchOpenOrders (symbol = undefined, since = undefined, limit = undefined, params = {}) { if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' fetchOpenOrders requires a symbol param'); + throw new ArgumentsRequired (this.id + ' fetchOpenOrders() requires a symbol param'); } await this.loadMarkets (); const market = this.market (symbol); diff --git a/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/coinmarketcap.js b/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/coinmarketcap.js index 3d983cc88..171a65889 100644 --- a/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/coinmarketcap.js +++ b/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/coinmarketcap.js @@ -150,6 +150,8 @@ module.exports = class coinmarketcap extends Exchange { // https://github.com/ccxt/ccxt/issues/6081 // https://github.com/ccxt/ccxt/issues/3365 // https://github.com/ccxt/ccxt/issues/2873 + 'SBTCT': 'SiamBitcoin', // conflict with sBTC + 'Super Bitcoin': 'Super Bitcoin', // conflict with sBTC 'TerraCredit': 'TerraCredit', // conflict with CREDIT (PROXI) 'Themis': 'Themis', // conflict with GET (Guaranteed Entrance Token, GET Protocol) 'UNI COIN': 'UNI COIN', // conflict with UNI (Uniswap) diff --git a/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/coinmate.js b/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/coinmate.js index 844bc0011..b03ce8783 100644 --- a/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/coinmate.js +++ b/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/coinmate.js @@ -529,7 +529,7 @@ module.exports = class coinmate extends Exchange { async fetchOrders (symbol = undefined, since = undefined, limit = undefined, params = {}) { if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' fetchOrders requires a symbol argument'); + throw new ArgumentsRequired (this.id + ' fetchOrders() requires a symbol argument'); } await this.loadMarkets (); const market = this.market (symbol); @@ -641,6 +641,7 @@ module.exports = class coinmate extends Exchange { 'symbol': symbol, 'type': type, 'timeInForce': undefined, + 'postOnly': undefined, 'side': side, 'price': price, 'stopPrice': stopPrice, diff --git a/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/coinone.js b/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/coinone.js index eb14695fa..0c86365b6 100644 --- a/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/coinone.js +++ b/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/coinone.js @@ -373,7 +373,7 @@ module.exports = class coinone extends Exchange { async fetchOrder (id, symbol = undefined, params = {}) { if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' fetchOrder requires a symbol argument'); + throw new ArgumentsRequired (this.id + ' fetchOrder() requires a symbol argument'); } await this.loadMarkets (); const market = this.market (symbol); @@ -518,6 +518,7 @@ module.exports = class coinone extends Exchange { 'symbol': symbol, 'type': 'limit', 'timeInForce': undefined, + 'postOnly': undefined, 'side': side, 'price': price, 'stopPrice': undefined, @@ -567,7 +568,7 @@ module.exports = class coinone extends Exchange { async fetchMyTrades (symbol = undefined, since = undefined, limit = undefined, params = {}) { if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' fetchMyTrades requires a symbol argument'); + throw new ArgumentsRequired (this.id + ' fetchMyTrades() requires a symbol argument'); } await this.loadMarkets (); const market = this.market (symbol); @@ -602,14 +603,14 @@ module.exports = class coinone extends Exchange { async cancelOrder (id, symbol = undefined, params = {}) { if (symbol === undefined) { // eslint-disable-next-line quotes - throw new ArgumentsRequired (this.id + " cancelOrder requires a symbol argument. To cancel the order, pass a symbol argument and {'price': 12345, 'qty': 1.2345, 'is_ask': 0} in the params argument of cancelOrder."); + throw new ArgumentsRequired (this.id + " cancelOrder() requires a symbol argument. To cancel the order, pass a symbol argument and {'price': 12345, 'qty': 1.2345, 'is_ask': 0} in the params argument of cancelOrder."); } const price = this.safeFloat (params, 'price'); const qty = this.safeFloat (params, 'qty'); const isAsk = this.safeInteger (params, 'is_ask'); if ((price === undefined) || (qty === undefined) || (isAsk === undefined)) { // eslint-disable-next-line quotes - throw new ArgumentsRequired (this.id + " cancelOrder requires {'price': 12345, 'qty': 1.2345, 'is_ask': 0} in the params argument."); + throw new ArgumentsRequired (this.id + " cancelOrder() requires {'price': 12345, 'qty': 1.2345, 'is_ask': 0} in the params argument."); } await this.loadMarkets (); const request = { diff --git a/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/coinspot.js b/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/coinspot.js index 2da1a5ee7..e04c42b5d 100644 --- a/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/coinspot.js +++ b/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/coinspot.js @@ -3,7 +3,7 @@ // --------------------------------------------------------------------------- const Exchange = require ('./base/Exchange'); -const { ExchangeError, AuthenticationError, NotSupported } = require ('./base/errors'); +const { ExchangeError, ArgumentsRequired, AuthenticationError } = require ('./base/errors'); // --------------------------------------------------------------------------- @@ -70,27 +70,72 @@ module.exports = class coinspot extends Exchange { }, 'markets': { 'BTC/AUD': { 'id': 'btc', 'symbol': 'BTC/AUD', 'base': 'BTC', 'quote': 'AUD', 'baseId': 'btc', 'quoteId': 'aud' }, + 'ETH/AUD': { 'id': 'eth', 'symbol': 'ETH/AUD', 'base': 'ETH', 'quote': 'AUD', 'baseId': 'eth', 'quoteId': 'aud' }, + 'XRP/AUD': { 'id': 'xrp', 'symbol': 'XRP/AUD', 'base': 'XRP', 'quote': 'AUD', 'baseId': 'xrp', 'quoteId': 'aud' }, 'LTC/AUD': { 'id': 'ltc', 'symbol': 'LTC/AUD', 'base': 'LTC', 'quote': 'AUD', 'baseId': 'ltc', 'quoteId': 'aud' }, 'DOGE/AUD': { 'id': 'doge', 'symbol': 'DOGE/AUD', 'base': 'DOGE', 'quote': 'AUD', 'baseId': 'doge', 'quoteId': 'aud' }, + 'RFOX/AUD': { 'id': 'rfox', 'symbol': 'RFOX/AUD', 'base': 'RFOX', 'quote': 'AUD', 'baseId': 'rfox', 'quoteId': 'aud' }, + 'POWR/AUD': { 'id': 'powr', 'symbol': 'POWR/AUD', 'base': 'POWR', 'quote': 'AUD', 'baseId': 'powr', 'quoteId': 'aud' }, + 'NEO/AUD': { 'id': 'neo', 'symbol': 'NEO/AUD', 'base': 'NEO', 'quote': 'AUD', 'baseId': 'neo', 'quoteId': 'aud' }, + 'TRX/AUD': { 'id': 'trx', 'symbol': 'TRX/AUD', 'base': 'TRX', 'quote': 'AUD', 'baseId': 'trx', 'quoteId': 'aud' }, + 'EOS/AUD': { 'id': 'eos', 'symbol': 'EOS/AUD', 'base': 'EOS', 'quote': 'AUD', 'baseId': 'eos', 'quoteId': 'aud' }, + 'XLM/AUD': { 'id': 'xlm', 'symbol': 'XLM/AUD', 'base': 'XLM', 'quote': 'AUD', 'baseId': 'xlm', 'quoteId': 'aud' }, + 'RHOC/AUD': { 'id': 'rhoc', 'symbol': 'RHOC/AUD', 'base': 'RHOC', 'quote': 'AUD', 'baseId': 'rhoc', 'quoteId': 'aud' }, + 'GAS/AUD': { 'id': 'gas', 'symbol': 'GAS/AUD', 'base': 'GAS', 'quote': 'AUD', 'baseId': 'gas', 'quoteId': 'aud' }, }, 'commonCurrencies': { 'DRK': 'DASH', }, + 'options': { + 'fetchBalance': 'private_post_my_balances', + }, }); } async fetchBalance (params = {}) { await this.loadMarkets (); - const response = await this.privatePostMyBalances (params); + const method = this.safeString (this.options, 'fetchBalance', 'private_post_my_balances'); + const response = await this[method] (params); + // + // read-write api keys + // + // ... + // + // read-only api keys + // + // { + // "status":"ok", + // "balances":[ + // { + // "LTC":{"balance":0.1,"audbalance":16.59,"rate":165.95} + // } + // ] + // } + // const result = { 'info': response }; - const balances = this.safeValue (response, 'balance', {}); - const currencyIds = Object.keys (balances); - for (let i = 0; i < currencyIds.length; i++) { - const currencyId = currencyIds[i]; - const code = this.safeCurrencyCode (currencyId); - const account = this.account (); - account['total'] = this.safeFloat (balances, currencyId); - result[code] = account; + const balances = this.safeValue2 (response, 'balance', 'balances'); + if (Array.isArray (balances)) { + for (let i = 0; i < balances.length; i++) { + const currencies = balances[i]; + const currencyIds = Object.keys (currencies); + for (let j = 0; j < currencyIds.length; j++) { + const currencyId = currencyIds[j]; + const balance = currencies[currencyId]; + const code = this.safeCurrencyCode (currencyId); + const account = this.account (); + account['total'] = this.safeFloat (balance, 'balance'); + result[code] = account; + } + } + } else { + const currencyIds = Object.keys (balances); + for (let i = 0; i < currencyIds.length; i++) { + const currencyId = currencyIds[i]; + const code = this.safeCurrencyCode (currencyId); + const account = this.account (); + account['total'] = this.safeFloat (balances, currencyId); + result[code] = account; + } } return this.parseBalance (result); } @@ -210,9 +255,16 @@ module.exports = class coinspot extends Exchange { } async cancelOrder (id, symbol = undefined, params = {}) { - throw new NotSupported (this.id + ' cancelOrder () is not fully implemented yet'); - // let method = 'privatePostMyBuy'; - // return await this[method] ({ 'id': id }); + const side = this.safeString (params, 'side'); + if (side !== 'buy' && side !== 'sell') { + throw new ArgumentsRequired (this.id + ' cancelOrder() requires a side parameter, "buy" or "sell"'); + } + params = this.omit (params, 'side'); + const method = 'privatePostMy' + this.capitalize (side) + 'Cancel'; + const request = { + 'id': id, + }; + return await this[method] (this.extend (request, params)); } sign (path, api = 'public', method = 'GET', params = {}, headers = undefined, body = undefined) { diff --git a/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/crex24.js b/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/crex24.js index 5ea3e826c..7c1298090 100644 --- a/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/crex24.js +++ b/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/crex24.js @@ -133,6 +133,7 @@ module.exports = class crex24 extends Exchange { 'GHOST': 'GHOSTPRISM', 'IQ': 'IQ.Cash', 'PUT': 'PutinCoin', + 'SBTC': 'SBTCT', // SiamBitcoin 'UNI': 'Universe', 'YOYO': 'YOYOW', }, @@ -158,6 +159,7 @@ module.exports = class crex24 extends Exchange { "Parameter 'instrument' contains invalid value.": BadSymbol, }, 'broad': { + 'try again later': ExchangeNotAvailable, // {"errorDescription":"Failed to process the request. Please, try again later."} 'API Key': AuthenticationError, // "API Key '9edc48de-d5b0-4248-8e7e-f59ffcd1c7f1' doesn't exist." 'Insufficient funds': InsufficientFunds, // "Insufficient funds: new order requires 10 ETH which is more than the available balance." 'has been delisted.': BadSymbol, // {"errorDescription":"Instrument '$PAC-BTC' has been delisted."} @@ -757,14 +759,14 @@ module.exports = class crex24 extends Exchange { } if (priceIsRequired) { if (price === undefined) { - throw new InvalidOrder (this.id + ' createOrder method requires a price argument for a ' + type + ' order'); + throw new InvalidOrder (this.id + ' createOrder() requires a price argument for a ' + type + ' order'); } request['price'] = this.priceToPrecision (symbol, price); } if (stopPriceIsRequired) { const stopPrice = this.safeFloat (params, 'stopPrice'); if (stopPrice === undefined) { - throw new InvalidOrder (this.id + ' createOrder method requires a stopPrice extra param for a ' + type + ' order'); + throw new InvalidOrder (this.id + ' createOrder() requires a stopPrice extra param for a ' + type + ' order'); } else { request['stopPrice'] = this.priceToPrecision (symbol, stopPrice); } diff --git a/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/currencycom.js b/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/currencycom.js index 3914c1bfc..c8570f1d4 100644 --- a/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/currencycom.js +++ b/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/currencycom.js @@ -916,7 +916,7 @@ module.exports = class currencycom extends Exchange { if (market['margin']) { accountId = this.safeInteger (params, 'accountId'); if (accountId === undefined) { - throw new ArgumentsRequired (this.id + ' createOrder requires an accountId parameter for ' + market['type'] + ' market ' + symbol); + throw new ArgumentsRequired (this.id + ' createOrder() requires an accountId parameter for ' + market['type'] + ' market ' + symbol); } } const uppercaseType = type.toUpperCase (); @@ -977,7 +977,7 @@ module.exports = class currencycom extends Exchange { const symbols = this.symbols; const numSymbols = symbols.length; const fetchOpenOrdersRateLimit = parseInt (numSymbols / 2); - throw new ExchangeError (this.id + ' fetchOpenOrders WARNING: fetching open orders without specifying a symbol is rate-limited to one call per ' + fetchOpenOrdersRateLimit.toString () + ' seconds. Do not call this method frequently to avoid ban. Set ' + this.id + '.options["warnOnFetchOpenOrdersWithoutSymbol"] = false to suppress this warning message.'); + throw new ExchangeError (this.id + ' fetchOpenOrders() WARNING: fetching open orders without specifying a symbol is rate-limited to one call per ' + fetchOpenOrdersRateLimit.toString () + ' seconds. Do not call this method frequently to avoid ban. Set ' + this.id + '.options["warnOnFetchOpenOrdersWithoutSymbol"] = false to suppress this warning message.'); } const response = await this.privateGetOpenOrders (this.extend (request, params)); return this.parseOrders (response, market, since, limit); @@ -985,7 +985,7 @@ module.exports = class currencycom extends Exchange { async cancelOrder (id, symbol = undefined, params = {}) { if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' cancelOrder requires a symbol argument'); + throw new ArgumentsRequired (this.id + ' cancelOrder() requires a symbol argument'); } await this.loadMarkets (); const market = this.market (symbol); @@ -1020,7 +1020,7 @@ module.exports = class currencycom extends Exchange { async fetchMyTrades (symbol = undefined, since = undefined, limit = undefined, params = {}) { if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' fetchMyTrades requires a symbol argument'); + throw new ArgumentsRequired (this.id + ' fetchMyTrades() requires a symbol argument'); } await this.loadMarkets (); const market = this.market (symbol); diff --git a/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/delta.js b/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/delta.js new file mode 100644 index 000000000..9b3c559bf --- /dev/null +++ b/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/delta.js @@ -0,0 +1,1483 @@ +'use strict'; + +// --------------------------------------------------------------------------- + +const Exchange = require ('./base/Exchange'); +const { ExchangeError, InsufficientFunds, BadRequest, BadSymbol, InvalidOrder, AuthenticationError, ArgumentsRequired, OrderNotFound, ExchangeNotAvailable } = require ('./base/errors'); +const { TICK_SIZE } = require ('./base/functions/number'); + +// --------------------------------------------------------------------------- + +module.exports = class delta extends Exchange { + describe () { + return this.deepExtend (super.describe (), { + 'id': 'delta', + 'name': 'Delta Exchange', + 'countries': [ 'VC' ], // Saint Vincent and the Grenadines + 'rateLimit': 300, + 'version': 'v2', + // new metainfo interface + 'has': { + 'cancelAllOrders': true, + 'cancelOrder': true, + 'createOrder': true, + 'editOrder': true, + 'fetchBalance': true, + 'fetchClosedOrders': true, + 'fetchDepositAddress': true, + 'fetchCurrencies': true, + 'fetchLedger': true, + 'fetchMarkets': true, + 'fetchMyTrades': true, + 'fetchOHLCV': true, + 'fetchOpenOrders': true, + 'fetchOrderBook': true, + 'fetchStatus': true, + 'fetchTicker': true, + 'fetchTickers': true, + 'fetchTime': true, + 'fetchTrades': true, + }, + 'timeframes': { + '1m': '1m', + '3m': '3m', + '5m': '5m', + '15m': '15m', + '30m': '30m', + '1h': '1h', + '2h': '2h', + '4h': '4h', + '6h': '6h', + '1d': '1d', + '7d': '7d', + '1w': '1w', + '2w': '2w', + '1M': '30d', + }, + 'urls': { + 'logo': 'https://user-images.githubusercontent.com/1294454/99450025-3be60a00-2931-11eb-9302-f4fd8d8589aa.jpg', + 'test': { + 'public': 'https://testnet-api.delta.exchange', + 'private': 'https://testnet-api.delta.exchange', + }, + 'api': { + 'public': 'https://api.delta.exchange', + 'private': 'https://api.delta.exchange', + }, + 'www': 'https://www.delta.exchange', + 'doc': [ + 'https://docs.delta.exchange', + ], + 'fees': 'https://www.delta.exchange/fees', + 'referral': 'https://www.delta.exchange/app/signup/?code=IULYNB', + }, + 'api': { + 'public': { + 'get': [ + 'assets', + 'settings', + 'indices', + 'products', + 'tickers', + 'tickers/{symbol}', + 'l2orderbook/{symbol}', + 'trades/{symbol}', + 'history/candles', + 'history/sparklines', + ], + }, + 'private': { + 'get': [ + 'orders', + 'orders/leverage', + 'positions', + 'positions/margined', + 'orders/history', + 'fills', + 'fills/history/download/csv', + 'wallet/balances', + 'wallet/transactions', + 'wallet/transactions/download', + 'deposits/address', + ], + 'post': [ + 'orders', + 'orders/batch', + 'orders/leverage', + 'positions/change_margin', + ], + 'put': [ + 'orders', + 'orders/batch', + ], + 'delete': [ + 'orders', + 'orders/all', + 'orders/batch', + ], + }, + }, + 'fees': { + 'trading': { + 'tierBased': true, + 'percentage': true, + 'taker': 0.15 / 100, + 'maker': 0.10 / 100, + 'tiers': { + 'taker': [ + [0, 0.15 / 100], + [100, 0.13 / 100], + [250, 0.13 / 100], + [1000, 0.1 / 100], + [5000, 0.09 / 100], + [10000, 0.075 / 100], + [20000, 0.065 / 100], + ], + 'maker': [ + [0, 0.1 / 100], + [100, 0.1 / 100], + [250, 0.09 / 100], + [1000, 0.075 / 100], + [5000, 0.06 / 100], + [10000, 0.05 / 100], + [20000, 0.05 / 100], + ], + }, + }, + }, + 'precisionMode': TICK_SIZE, + 'requiredCredentials': { + 'apiKey': true, + 'secret': false, + }, + 'exceptions': { + 'exact': { + // Margin required to place order with selected leverage and quantity is insufficient. + 'insufficient_margin': InsufficientFunds, // {"error":{"code":"insufficient_margin","context":{"available_balance":"0.000000000000000000","required_additional_balance":"1.618626000000000000000000000"}},"success":false} + 'order_size_exceed_available': InvalidOrder, // The order book doesn't have sufficient liquidity, hence the order couldnt be filled, for example, ioc orders + 'risk_limits_breached': BadRequest, // orders couldn't be placed as it will breach allowed risk limits. + 'invalid_contract': BadSymbol, // The contract/product is either doesn't exist or has already expired. + 'immediate_liquidation': InvalidOrder, // Order will cause immediate liquidation. + 'out_of_bankruptcy': InvalidOrder, // Order prices are out of position bankruptcy limits. + 'self_matching_disrupted_post_only': InvalidOrder, // Self matching is not allowed during auction. + 'immediate_execution_post_only': InvalidOrder, // orders couldn't be placed as it includes post only orders which will be immediately executed + 'bad_schema': BadRequest, // {"error":{"code":"bad_schema","context":{"schema_errors":[{"code":"validation_error","message":"id is required","param":""}]}},"success":false} + 'invalid_api_key': AuthenticationError, // {"success":false,"error":{"code":"invalid_api_key"}} + 'invalid_signature': AuthenticationError, // {"success":false,"error":{"code":"invalid_signature"}} + 'open_order_not_found': OrderNotFound, // {"error":{"code":"open_order_not_found"},"success":false} + 'unavailable': ExchangeNotAvailable, // {"error":{"code":"unavailable"},"success":false} + }, + 'broad': { + }, + }, + }); + } + + async fetchTime (params = {}) { + const response = await this.publicGetSettings (params); + // + // { + // "result":{ + // "server_time":1605472733766141, + // "deto_referral_mining_daily_reward":"25000", + // "deto_total_reward_pool":"100000000", + // "deto_trade_mining_daily_reward":"75000", + // "kyc_deposit_limit":"20", + // "kyc_withdrawal_limit":"2", + // "under_maintenance":"false" + // }, + // "success":true + // } + // + const result = this.safeValue (response, 'result', {}); + return this.safeIntegerProduct (result, 'server_time', 0.001); + } + + async fetchStatus (params = {}) { + const response = await this.publicGetSettings (params); + const result = this.safeValue (response, 'result', {}); + const underMaintenance = this.safeValue (result, 'under_maintenance'); + const status = (underMaintenance === 'true') ? 'maintenance' : 'ok'; + const updated = this.safeIntegerProduct (result, 'server_time', 0.001); + this.status = this.extend (this.status, { + 'status': status, + 'updated': updated, + }); + return this.status; + } + + async fetchCurrencies (params = {}) { + const response = await this.publicGetAssets (params); + // + // { + // "result":[ + // { + // "base_withdrawal_fee":"0.0005", + // "deposit_status":"enabled", + // "id":2, + // "interest_credit":true, + // "interest_slabs":[ + // {"limit":"0.1","rate":"0"}, + // {"limit":"1","rate":"0.05"}, + // {"limit":"5","rate":"0.075"}, + // {"limit":"10","rate":"0.1"}, + // {"limit":"9999999999999999","rate":"0"} + // ], + // "kyc_deposit_limit":"10", + // "kyc_withdrawal_limit":"2", + // "min_withdrawal_amount":"0.001", + // "minimum_precision":4, + // "name":"Bitcoin", + // "precision":8, + // "sort_priority":1, + // "symbol":"BTC", + // "variable_withdrawal_fee":"0", + // "withdrawal_status":"enabled" + // }, + // ], + // "success":true + // } + // + const currencies = this.safeValue (response, 'result', []); + const result = {}; + for (let i = 0; i < currencies.length; i++) { + const currency = currencies[i]; + const id = this.safeString (currency, 'symbol'); + const numericId = this.safeInteger (currency, 'id'); + const code = this.safeCurrencyCode (id); + const depositStatus = this.safeString (currency, 'deposit_status'); + const withdrawalStatus = this.safeString (currency, 'withdrawal_status'); + const depositsEnabled = (depositStatus === 'enabled'); + const withdrawalsEnabled = (withdrawalStatus === 'enabled'); + const active = depositsEnabled && withdrawalsEnabled; + const precision = this.safeInteger (currency, 'precision'); + result[code] = { + 'id': id, + 'numericId': numericId, + 'code': code, + 'name': this.safeString (currency, 'name'), + 'info': currency, // the original payload + 'active': active, + 'fee': this.safeFloat (currency, 'base_withdrawal_fee'), + 'precision': 1 / Math.pow (10, precision), + 'limits': { + 'amount': { 'min': undefined, 'max': undefined }, + 'price': { 'min': undefined, 'max': undefined }, + 'cost': { 'min': undefined, 'max': undefined }, + 'withdraw': { + 'min': this.safeFloat (currency, 'min_withdrawal_amount'), + 'max': undefined, + }, + }, + }; + } + return result; + } + + async loadMarkets (reload = false, params = {}) { + const markets = await super.loadMarkets (reload, params); + const currenciesByNumericId = this.safeValue (this.options, 'currenciesByNumericId'); + if ((currenciesByNumericId === undefined) || reload) { + this.options['currenciesByNumericId'] = this.indexBy (this.currencies, 'numericId'); + } + const marketsByNumericId = this.safeValue (this.options, 'marketsByNumericId'); + if ((marketsByNumericId === undefined) || reload) { + this.options['marketsByNumericId'] = this.indexBy (this.markets, 'numericId'); + } + return markets; + } + + async fetchMarkets (params = {}) { + const response = await this.publicGetProducts (params); + // + // { + // "meta":{ + // "after":null, + // "before":null, + // "limit":100, + // "total_count":81 + // }, + // "result":[ + // { + // "annualized_funding":"5.475000000000000000", + // "is_quanto":false, + // "ui_config":{ + // "default_trading_view_candle":"15", + // "leverage_slider_values":[1,3,5,10,25,50], + // "price_clubbing_values":[0.001,0.005,0.05,0.1,0.5,1,5], + // "show_bracket_orders":false, + // "sort_priority":29, + // "tags":[] + // }, + // "basis_factor_max_limit":"0.15", + // "symbol":"P-LINK-D-151120", + // "id":1584, + // "default_leverage":"5.000000000000000000", + // "maker_commission_rate":"0.0005", + // "contract_unit_currency":"LINK", + // "strike_price":"12.507948", + // "settling_asset":{ + // // asset structure + // }, + // "auction_start_time":null, + // "auction_finish_time":null, + // "settlement_time":"2020-11-15T12:00:00Z", + // "launch_time":"2020-11-14T11:55:05Z", + // "spot_index":{ + // // index structure + // }, + // "trading_status":"operational", + // "tick_size":"0.001", + // "position_size_limit":100000, + // "notional_type":"vanilla", // vanilla, inverse + // "price_band":"0.4", + // "barrier_price":null, + // "description":"Daily LINK PUT options quoted in USDT and settled in USDT", + // "insurance_fund_margin_contribution":"1", + // "quoting_asset":{ + // // asset structure + // }, + // "liquidation_penalty_factor":"0.2", + // "product_specs":{"max_volatility":3,"min_volatility":0.3,"spot_price_band":"0.40"}, + // "initial_margin_scaling_factor":"0.0001", + // "underlying_asset":{ + // // asset structure + // }, + // "state":"live", + // "contract_value":"1", + // "initial_margin":"2", + // "impact_size":5000, + // "settlement_price":null, + // "contract_type":"put_options", // put_options, call_options, move_options, perpetual_futures, interest_rate_swaps, futures, spreads + // "taker_commission_rate":"0.0005", + // "maintenance_margin":"1", + // "short_description":"LINK Daily PUT Options", + // "maintenance_margin_scaling_factor":"0.00005", + // "funding_method":"mark_price", + // "max_leverage_notional":"20000" + // }, + // ], + // "success":true + // } + // + const markets = this.safeValue (response, 'result', []); + const result = []; + for (let i = 0; i < markets.length; i++) { + const market = markets[i]; + let type = this.safeString (market, 'contract_type'); + // const settlingAsset = this.safeValue (market, 'settling_asset', {}); + const quotingAsset = this.safeValue (market, 'quoting_asset', {}); + const underlyingAsset = this.safeValue (market, 'underlying_asset', {}); + const baseId = this.safeString (underlyingAsset, 'symbol'); + const quoteId = this.safeString (quotingAsset, 'symbol'); + const id = this.safeString (market, 'symbol'); + const numericId = this.safeInteger (market, 'id'); + const base = this.safeCurrencyCode (baseId); + const quote = this.safeCurrencyCode (quoteId); + let symbol = id; + let swap = false; + let future = false; + let option = false; + if (type === 'perpetual_futures') { + type = 'swap'; + swap = true; + future = false; + option = false; + if (id.indexOf ('_') < 0) { + symbol = base + '/' + quote; + } + } else if ((type === 'call_options') || (type === 'put_options') || (type === 'move_options')) { + type = 'option'; + swap = false; + option = true; + future = false; + } else if (type === 'futures') { + type = 'future'; + swap = false; + option = false; + future = true; + } + const precision = { + 'amount': 1.0, // number of contracts + 'price': this.safeFloat (market, 'tick_size'), + }; + const limits = { + 'amount': { + 'min': 1.0, + 'max': this.safeFloat (market, 'position_size_limit'), + }, + 'price': { + 'min': precision['price'], + 'max': undefined, + }, + 'cost': { + 'min': this.safeFloat (market, 'min_size'), + 'max': undefined, + }, + }; + const state = this.safeString (market, 'state'); + const active = (state === 'live'); + const maker = this.safeFloat (market, 'maker_commission_rate'); + const taker = this.safeFloat (market, 'taker_commission_rate'); + result.push ({ + 'id': id, + 'numericId': numericId, + 'symbol': symbol, + 'base': base, + 'quote': quote, + 'baseId': baseId, + 'quoteId': quoteId, + 'type': type, + 'option': option, + 'swap': swap, + 'future': future, + 'maker': maker, + 'taker': taker, + 'precision': precision, + 'limits': limits, + 'info': market, + 'active': active, + }); + } + return result; + } + + parseTicker (ticker, market = undefined) { + // + // fetchTicker, fetchTickers + // + // { + // "close":15837.5, + // "high":16354, + // "low":15751.5, + // "mark_price":"15820.100867", + // "open":16140.5, + // "product_id":139, + // "size":640552, + // "spot_price":"15827.050000000001", + // "symbol":"BTCUSDT", + // "timestamp":1605373550208262, + // "turnover":10298630.3735, + // "turnover_symbol":"USDT", + // "turnover_usd":10298630.3735, + // "volume":640.5520000000001 + // } + // + const timestamp = this.safeIntegerProduct (ticker, 'timestamp', 0.001); + const marketId = this.safeString (ticker, 'symbol'); + const symbol = this.safeSymbol (marketId, market); + const last = this.safeFloat (ticker, 'close'); + const open = this.safeFloat (ticker, 'open'); + let change = undefined; + let average = undefined; + let percentage = undefined; + if ((open !== undefined) && (last !== undefined)) { + change = last - open; + average = this.sum (last, open) / 2; + if (open !== 0.0) { + percentage = (change / open) * 100; + } + } + const baseVolume = this.safeFloat (ticker, 'volume'); + const quoteVolume = this.safeFloat (ticker, 'turnover'); + const vwap = this.vwap (baseVolume, quoteVolume); + return { + 'symbol': symbol, + 'timestamp': timestamp, + 'datetime': this.iso8601 (timestamp), + 'high': this.safeFloat (ticker, 'high'), + 'low': this.safeFloat (ticker, 'low'), + 'bid': undefined, + 'bidVolume': undefined, + 'ask': undefined, + 'askVolume': undefined, + 'vwap': vwap, + 'open': open, + 'close': last, + 'last': last, + 'previousClose': undefined, + 'change': change, + 'percentage': percentage, + 'average': average, + 'baseVolume': baseVolume, + 'quoteVolume': quoteVolume, + 'info': ticker, + }; + } + + async fetchTicker (symbol, params = {}) { + await this.loadMarkets (); + const market = this.market (symbol); + const request = { + 'symbol': market['id'], + }; + const response = await this.publicGetTickersSymbol (this.extend (request, params)); + // + // { + // "result":{ + // "close":15837.5, + // "high":16354, + // "low":15751.5, + // "mark_price":"15820.100867", + // "open":16140.5, + // "product_id":139, + // "size":640552, + // "spot_price":"15827.050000000001", + // "symbol":"BTCUSDT", + // "timestamp":1605373550208262, + // "turnover":10298630.3735, + // "turnover_symbol":"USDT", + // "turnover_usd":10298630.3735, + // "volume":640.5520000000001 + // }, + // "success":true + // } + // + const result = this.safeValue (response, 'result', {}); + return this.parseTicker (result, market); + } + + async fetchTickers (symbols = undefined, params = {}) { + await this.loadMarkets (); + const response = await this.publicGetTickers (params); + // + // { + // "result":[ + // { + // "close":0.003966, + // "high":0.004032, + // "low":0.003606, + // "mark_price":"0.00396328", + // "open":0.003996, + // "product_id":1327, + // "size":6242, + // "spot_price":"0.0039555", + // "symbol":"AAVEBTC", + // "timestamp":1605374143864107, + // "turnover":23.997904999999996, + // "turnover_symbol":"BTC", + // "turnover_usd":387957.4544782897, + // "volume":6242 + // }, + // ], + // "success":true + // } + // + const tickers = this.safeValue (response, 'result', []); + const result = {}; + for (let i = 0; i < tickers.length; i++) { + const ticker = this.parseTicker (tickers[i]); + const symbol = ticker['symbol']; + result[symbol] = ticker; + } + return this.filterByArray (result, 'symbol', symbols); + } + + async fetchOrderBook (symbol, limit = undefined, params = {}) { + await this.loadMarkets (); + const request = { + 'symbol': this.marketId (symbol), + }; + if (limit !== undefined) { + request['depth'] = limit; + } + const response = await this.publicGetL2orderbookSymbol (this.extend (request, params)); + // + // { + // "result":{ + // "buy":[ + // {"price":"15814.0","size":912}, + // {"price":"15813.5","size":1279}, + // {"price":"15813.0","size":1634}, + // ], + // "sell":[ + // {"price":"15814.5","size":625}, + // {"price":"15815.0","size":982}, + // {"price":"15815.5","size":1328}, + // ], + // "symbol":"BTCUSDT" + // }, + // "success":true + // } + // + const result = this.safeValue (response, 'result', {}); + return this.parseOrderBook (result, undefined, 'buy', 'sell', 'price', 'size'); + } + + parseTrade (trade, market = undefined) { + // + // public fetchTrades + // + // { + // "buyer_role":"maker", + // "price":"15896.5", + // "seller_role":"taker", + // "size":241, + // "symbol":"BTCUSDT", + // "timestamp":1605376684714595 + // } + // + // private fetchMyTrades + // + // { + // "commission":"0.008335000000000000", + // "created_at":"2020-11-16T19:07:19Z", + // "fill_type":"normal", + // "id":"e7ff05c233a74245b72381f8dd91d1ce", + // "meta_data":{ + // "effective_commission_rate":"0.0005", + // "order_price":"16249", + // "order_size":1, + // "order_type":"market_order", + // "order_unfilled_size":0, + // "trading_fee_credits_used":"0" + // }, + // "order_id":"152999629", + // "price":"16669", + // "product":{ + // "contract_type":"perpetual_futures", + // "contract_unit_currency":"BTC", + // "contract_value":"0.001", + // "id":139, + // "notional_type":"vanilla", + // "quoting_asset":{"minimum_precision":2,"precision":6,"symbol":"USDT"}, + // "settling_asset":{"minimum_precision":2,"precision":6,"symbol":"USDT"}, + // "symbol":"BTCUSDT", + // "tick_size":"0.5", + // "underlying_asset":{"minimum_precision":4,"precision":8,"symbol":"BTC"} + // }, + // "product_id":139, + // "role":"taker", + // "side":"sell", + // "size":1 + // } + // + const id = this.safeString (trade, 'id'); + const orderId = this.safeString (trade, 'order_id'); + let timestamp = this.parse8601 (this.safeString (trade, 'created_at')); + timestamp = this.safeIntegerProduct (trade, 'timestamp', 0.001, timestamp); + const price = this.safeFloat (trade, 'price'); + const amount = this.safeFloat (trade, 'size'); + let cost = undefined; + if ((amount !== undefined) && (price !== undefined)) { + cost = amount * price; + } + const product = this.safeValue (trade, 'product', {}); + const marketId = this.safeString (product, 'symbol'); + const symbol = this.safeSymbol (marketId, market); + const sellerRole = this.safeString (trade, 'seller_role'); + let side = this.safeString (trade, 'side'); + if (side === undefined) { + if (sellerRole === 'taker') { + side = 'sell'; + } else if (sellerRole === 'maker') { + side = 'buy'; + } + } + const takerOrMaker = this.safeString (trade, 'role'); + const metaData = this.safeValue (trade, 'meta_data', {}); + let type = this.safeString (metaData, 'order_type'); + if (type !== undefined) { + type = type.replace ('_order', ''); + } + const feeCost = this.safeFloat (trade, 'commission'); + let fee = undefined; + if (feeCost !== undefined) { + const settlingAsset = this.safeValue (product, 'settling_asset', {}); + const feeCurrencyId = this.safeString (settlingAsset, 'symbol'); + const feeCurrencyCode = this.safeCurrencyCode (feeCurrencyId); + fee = { + 'cost': feeCost, + 'currency': feeCurrencyCode, + }; + } + return { + 'id': id, + 'order': orderId, + 'timestamp': timestamp, + 'datetime': this.iso8601 (timestamp), + 'symbol': symbol, + 'type': type, + 'side': side, + 'price': price, + 'amount': amount, + 'cost': cost, + 'takerOrMaker': takerOrMaker, + 'fee': fee, + 'info': trade, + }; + } + + async fetchTrades (symbol, since = undefined, limit = undefined, params = {}) { + await this.loadMarkets (); + const market = this.market (symbol); + const request = { + 'symbol': market['id'], + }; + const response = await this.publicGetTradesSymbol (this.extend (request, params)); + // + // { + // "result":[ + // { + // "buyer_role":"maker", + // "price":"15896.5", + // "seller_role":"taker", + // "size":241, + // "symbol":"BTCUSDT", + // "timestamp":1605376684714595 + // } + // ], + // "success":true + // } + // + const result = this.safeValue (response, 'result', []); + return this.parseTrades (result, market, since, limit); + } + + parseOHLCV (ohlcv, market = undefined) { + // + // { + // "time":1605393120, + // "open":15989, + // "high":15989, + // "low":15987.5, + // "close":15987.5, + // "volume":565 + // } + // + return [ + this.safeTimestamp (ohlcv, 'time'), + this.safeFloat (ohlcv, 'open'), + this.safeFloat (ohlcv, 'high'), + this.safeFloat (ohlcv, 'low'), + this.safeFloat (ohlcv, 'close'), + this.safeFloat (ohlcv, 'volume'), + ]; + } + + async fetchOHLCV (symbol, timeframe = '1m', since = undefined, limit = undefined, params = {}) { + await this.loadMarkets (); + const market = this.market (symbol); + const request = { + 'symbol': market['id'], + 'resolution': this.timeframes[timeframe], + }; + const duration = this.parseTimeframe (timeframe); + limit = limit ? limit : 2000; // max 2000 + if (since === undefined) { + const end = this.seconds (); + request['end'] = end; + request['start'] = end - limit * duration; + } else { + const start = parseInt (since / 1000); + request['start'] = start; + request['end'] = this.sum (start, limit * duration); + } + const response = await this.publicGetHistoryCandles (this.extend (request, params)); + // + // { + // "success":true, + // "result":[ + // {"time":1605393120,"open":15989,"high":15989,"low":15987.5,"close":15987.5,"volume":565}, + // {"time":1605393180,"open":15966,"high":15966,"low":15959,"close":15959,"volume":24}, + // {"time":1605393300,"open":15973,"high":15973,"low":15973,"close":15973,"volume":1288}, + // ] + // } + // + const result = this.safeValue (response, 'result', []); + return this.parseOHLCVs (result, market, timeframe, since, limit); + } + + async fetchBalance (params = {}) { + await this.loadMarkets (); + const response = await this.privateGetWalletBalances (params); + // + // { + // "result":[ + // { + // "asset_id":1, + // "available_balance":"0", + // "balance":"0", + // "commission":"0", + // "id":154883, + // "interest_credit":"0", + // "order_margin":"0", + // "pending_referral_bonus":"0", + // "pending_trading_fee_credit":"0", + // "position_margin":"0", + // "trading_fee_credit":"0", + // "user_id":22142 + // }, + // ], + // "success":true + // } + // + const balances = this.safeValue (response, 'result', []); + const result = { 'info': response }; + const currenciesByNumericId = this.safeValue (this.options, 'currenciesByNumericId', {}); + for (let i = 0; i < balances.length; i++) { + const balance = balances[i]; + const currencyId = this.safeString (balance, 'asset_id'); + const currency = this.safeValue (currenciesByNumericId, currencyId); + const code = (currency === undefined) ? currencyId : currency['code']; + const account = this.account (); + account['total'] = this.safeFloat (balance, 'balance'); + account['free'] = this.safeFloat (balance, 'available_balance'); + result[code] = account; + } + return this.parseBalance (result); + } + + async fetchPosition (symbol, params = undefined) { + await this.loadMarkets (); + const market = this.market (symbol); + const request = { + 'product_id': market['numericId'], + }; + const response = await this.privateGetPositions (this.extend (request, params)); + // + // { + // "result":{ + // "entry_price":null, + // "size":0, + // "timestamp":1605454074268079 + // }, + // "success":true + // } + // + const result = this.safeValue (response, 'result', {}); + return result; + } + + async fetchPositions (symbols = undefined, since = undefined, limit = undefined, params = {}) { + await this.loadMarkets (); + const response = await this.privateGetPositionsMargined (params); + // + // { + // "success": true, + // "result": [ + // { + // "user_id": 0, + // "size": 0, + // "entry_price": "string", + // "margin": "string", + // "liquidation_price": "string", + // "bankruptcy_price": "string", + // "adl_level": 0, + // "product_id": 0 + // } + // ] + // } + // + const result = this.safeValue (response, 'result', []); + return result; + } + + parseOrderStatus (status) { + const statuses = { + 'open': 'open', + 'pending': 'open', + 'closed': 'closed', + 'cancelled': 'canceled', + }; + return this.safeString (statuses, status, status); + } + + parseOrder (order, market = undefined) { + // + // createOrder, cancelOrder, editOrder, fetchOpenOrders, fetchClosedOrders + // + // { + // "average_fill_price":null, + // "bracket_order":null, + // "bracket_stop_loss_limit_price":null, + // "bracket_stop_loss_price":null, + // "bracket_take_profit_limit_price":null, + // "bracket_take_profit_price":null, + // "bracket_trail_amount":null, + // "cancellation_reason":null, + // "client_order_id":null, + // "close_on_trigger":"false", + // "commission":"0", + // "created_at":"2020-11-16T02:38:26Z", + // "id":152870626, + // "limit_price":"10000", + // "meta_data":{"source":"api"}, + // "order_type":"limit_order", + // "paid_commission":"0", + // "product_id":139, + // "reduce_only":false, + // "side":"buy", + // "size":0, + // "state":"open", + // "stop_order_type":null, + // "stop_price":null, + // "stop_trigger_method":"mark_price", + // "time_in_force":"gtc", + // "trail_amount":null, + // "unfilled_size":0, + // "user_id":22142 + // } + // + const id = this.safeString (order, 'id'); + const clientOrderId = this.safeString (order, 'client_order_id'); + const timestamp = this.parse8601 (this.safeString (order, 'created_at')); + const marketId = this.safeString (order, 'product_id'); + const marketsByNumericId = this.safeValue (this.options, 'marketsByNumericId', {}); + market = this.safeValue (marketsByNumericId, marketId, market); + const symbol = (market === undefined) ? marketId : market['symbol']; + const status = this.parseOrderStatus (this.safeString (order, 'state')); + const side = this.safeString (order, 'side'); + let type = this.safeString (order, 'order_type'); + type = type.replace ('_order', ''); + const price = this.safeFloat (order, 'limit_price'); + const amount = this.safeFloat (order, 'size'); + const remaining = this.safeFloat (order, 'unfilled_size'); + let filled = undefined; + if ((amount !== undefined) && (remaining !== undefined)) { + filled = Math.max (0, amount - remaining); + } + let cost = undefined; + const average = this.safeFloat (order, 'average_fill_price'); + if ((average !== undefined) && filled) { + cost = average * filled; + } + let fee = undefined; + const feeCost = this.safeFloat (order, 'paid_commission'); + if (feeCost !== undefined) { + let feeCurrencyCode = undefined; + if (market !== undefined) { + const settlingAsset = this.safeValue (market['info'], 'settling_asset', {}); + const feeCurrencyId = this.safeString (settlingAsset, 'symbol'); + feeCurrencyCode = this.safeCurrencyCode (feeCurrencyId); + } + fee = { + 'cost': feeCost, + 'currency': feeCurrencyCode, + }; + } + return { + 'info': order, + 'id': id, + 'clientOrderId': clientOrderId, + 'timestamp': timestamp, + 'datetime': this.iso8601 (timestamp), + 'lastTradeTimestamp': undefined, + 'symbol': symbol, + 'type': type, + 'side': side, + 'price': price, + 'amount': amount, + 'cost': cost, + 'average': average, + 'filled': filled, + 'remaining': remaining, + 'status': status, + 'fee': fee, + 'trades': undefined, + }; + } + + async createOrder (symbol, type, side, amount, price = undefined, params = {}) { + await this.loadMarkets (); + const orderType = type + '_order'; + const market = this.market (symbol); + const request = { + 'product_id': market['numericId'], + // 'limit_price': this.priceToPrecision (symbol, price), + 'size': this.amountToPrecision (symbol, amount), + 'side': side, + 'order_type': orderType, + // 'client_order_id': 'string', + // 'time_in_force': 'gtc', // gtc, ioc, fok + // 'post_only': 'false', // 'true', + // 'reduce_only': 'false', // 'true', + }; + if (type === 'limit') { + request['limit_price'] = this.priceToPrecision (symbol, price); + } + const clientOrderId = this.safeString2 (params, 'clientOrderId', 'client_order_id'); + params = this.omit (params, [ 'clientOrderId', 'client_order_id' ]); + if (clientOrderId !== undefined) { + request['client_order_id'] = clientOrderId; + } + const response = await this.privatePostOrders (this.extend (request, params)); + // + // { + // "result":{ + // "average_fill_price":null, + // "bracket_order":null, + // "bracket_stop_loss_limit_price":null, + // "bracket_stop_loss_price":null, + // "bracket_take_profit_limit_price":null, + // "bracket_take_profit_price":null, + // "bracket_trail_amount":null, + // "cancellation_reason":null, + // "client_order_id":null, + // "close_on_trigger":"false", + // "commission":"0", + // "created_at":"2020-11-16T02:38:26Z", + // "id":152870626, + // "limit_price":"10000", + // "meta_data":{"source":"api"}, + // "order_type":"limit_order", + // "paid_commission":"0", + // "product_id":139, + // "reduce_only":false, + // "side":"buy", + // "size":0, + // "state":"open", + // "stop_order_type":null, + // "stop_price":null, + // "stop_trigger_method":"mark_price", + // "time_in_force":"gtc", + // "trail_amount":null, + // "unfilled_size":0, + // "user_id":22142 + // }, + // "success":true + // } + // + const result = this.safeValue (response, 'result', {}); + return this.parseOrder (result, market); + } + + async editOrder (id, symbol, type, side, amount, price = undefined, params = {}) { + await this.loadMarkets (); + const market = this.market (symbol); + const request = { + 'id': parseInt (id), + 'product_id': market['numericId'], + // 'limit_price': this.priceToPrecision (symbol, price), + // 'size': this.amountToPrecision (symbol, amount), + }; + if (amount !== undefined) { + request['size'] = parseInt (this.amountToPrecision (symbol, amount)); + } + if (price !== undefined) { + request['limit_price'] = this.priceToPrecision (symbol, price); + } + const response = await this.privatePutOrders (this.extend (request, params)); + // + // { + // "success": true, + // "result": { + // "id": "ashb1212", + // "product_id": 27, + // "limit_price": "9200", + // "side": "buy", + // "size": 100, + // "unfilled_size": 50, + // "user_id": 1, + // "order_type": "limit_order", + // "state": "open", + // "created_at": "..." + // } + // } + // + const result = this.safeValue (response, 'result'); + return this.parseOrder (result, market); + } + + async cancelOrder (id, symbol = undefined, params = {}) { + if (symbol === undefined) { + throw new ArgumentsRequired (this.id + ' cancelOrder() requires a symbol argument'); + } + await this.loadMarkets (); + const market = this.market (symbol); + const request = { + 'id': parseInt (id), + 'product_id': market['numericId'], + }; + const response = await this.privateDeleteOrders (this.extend (request, params)); + // + // { + // "result":{ + // "average_fill_price":null, + // "bracket_order":null, + // "bracket_stop_loss_limit_price":null, + // "bracket_stop_loss_price":null, + // "bracket_take_profit_limit_price":null, + // "bracket_take_profit_price":null, + // "bracket_trail_amount":null, + // "cancellation_reason":"cancelled_by_user", + // "client_order_id":null, + // "close_on_trigger":"false", + // "commission":"0", + // "created_at":"2020-11-16T02:38:26Z", + // "id":152870626, + // "limit_price":"10000", + // "meta_data":{"source":"api"}, + // "order_type":"limit_order", + // "paid_commission":"0", + // "product_id":139, + // "reduce_only":false, + // "side":"buy", + // "size":0, + // "state":"cancelled", + // "stop_order_type":null, + // "stop_price":null, + // "stop_trigger_method":"mark_price", + // "time_in_force":"gtc", + // "trail_amount":null, + // "unfilled_size":0, + // "user_id":22142 + // }, + // "success":true + // } + // + const result = this.safeValue (response, 'result'); + return this.parseOrder (result, market); + } + + async cancelAllOrders (symbol = undefined, params = {}) { + if (symbol === undefined) { + throw new ArgumentsRequired (this.id + ' cancelAllOrders() requires a symbol argument'); + } + await this.loadMarkets (); + const market = this.market (symbol); + const request = { + 'product_id': market['numericId'], + // 'cancel_limit_orders': 'true', + // 'cancel_stop_orders': 'true', + }; + const response = this.privateDeleteOrdersAll (this.extend (request, params)); + // + // { + // "result":{}, + // "success":true + // } + // + return response; + } + + async fetchOpenOrders (symbol = undefined, since = undefined, limit = undefined, params = {}) { + return await this.fetchOrdersWithMethod ('privateGetOrders', symbol, since, limit, params); + } + + async fetchClosedOrders (symbol = undefined, since = undefined, limit = undefined, params = {}) { + return await this.fetchOrdersWithMethod ('privateGetOrdersHistory', symbol, since, limit, params); + } + + async fetchOrdersWithMethod (method, symbol = undefined, since = undefined, limit = undefined, params = {}) { + await this.loadMarkets (); + const request = { + // 'product_ids': market['id'], // comma-separated + // 'contract_types': types, // comma-separated, futures, perpetual_futures, call_options, put_options, interest_rate_swaps, move_options, spreads + // 'order_types': types, // comma-separated, market, limit, stop_market, stop_limit, all_stop + // 'start_time': since * 1000, + // 'end_time': this.microseconds (), + // 'after': string, // after cursor for pagination + // 'before': string, // before cursor for pagination + // 'page_size': limit, // number of records per page + }; + let market = undefined; + if (symbol !== undefined) { + market = this.market (symbol); + request['product_ids'] = market['numericId']; // accepts a comma-separated list of ids + } + if (since !== undefined) { + request['start_time'] = since.toString () + '000'; + } + if (limit !== undefined) { + request['page_size'] = limit; + } + const response = await this[method] (this.extend (request, params)); + // + // { + // "success": true, + // "result": [ + // { + // "id": "ashb1212", + // "product_id": 27, + // "limit_price": "9200", + // "side": "buy", + // "size": 100, + // "unfilled_size": 50, + // "user_id": 1, + // "order_type": "limit_order", + // "state": "open", + // "created_at": "..." + // } + // ], + // "meta": { + // "after": "string", + // "before": "string" + // } + // } + // + const result = this.safeValue (response, 'result', []); + return this.parseOrders (result, market, since, limit); + } + + async fetchMyTrades (symbol = undefined, since = undefined, limit = undefined, params = {}) { + await this.loadMarkets (); + const request = { + // 'product_ids': market['id'], // comma-separated + // 'contract_types': types, // comma-separated, futures, perpetual_futures, call_options, put_options, interest_rate_swaps, move_options, spreads + // 'start_time': since * 1000, + // 'end_time': this.microseconds (), + // 'after': string, // after cursor for pagination + // 'before': string, // before cursor for pagination + // 'page_size': limit, // number of records per page + }; + let market = undefined; + if (symbol !== undefined) { + market = this.market (symbol); + request['product_ids'] = market['numericId']; // accepts a comma-separated list of ids + } + if (since !== undefined) { + request['start_time'] = since.toString () + '000'; + } + if (limit !== undefined) { + request['page_size'] = limit; + } + const response = await this.privateGetFills (this.extend (request, params)); + // + // { + // "meta":{ + // "after":null, + // "before":null, + // "limit":10, + // "total_count":2 + // }, + // "result":[ + // { + // "commission":"0.008335000000000000", + // "created_at":"2020-11-16T19:07:19Z", + // "fill_type":"normal", + // "id":"e7ff05c233a74245b72381f8dd91d1ce", + // "meta_data":{ + // "effective_commission_rate":"0.0005", + // "order_price":"16249", + // "order_size":1, + // "order_type":"market_order", + // "order_unfilled_size":0, + // "trading_fee_credits_used":"0" + // }, + // "order_id":"152999629", + // "price":"16669", + // "product":{ + // "contract_type":"perpetual_futures", + // "contract_unit_currency":"BTC", + // "contract_value":"0.001", + // "id":139, + // "notional_type":"vanilla", + // "quoting_asset":{"minimum_precision":2,"precision":6,"symbol":"USDT"}, + // "settling_asset":{"minimum_precision":2,"precision":6,"symbol":"USDT"}, + // "symbol":"BTCUSDT", + // "tick_size":"0.5", + // "underlying_asset":{"minimum_precision":4,"precision":8,"symbol":"BTC"} + // }, + // "product_id":139, + // "role":"taker", + // "side":"sell", + // "size":1 + // } + // ], + // "success":true + // } + // + const result = this.safeValue (response, 'result', []); + return this.parseTrades (result, market, since, limit); + } + + async fetchLedger (code = undefined, since = undefined, limit = undefined, params = {}) { + await this.loadMarkets (); + const request = { + // 'asset_id': currency['numericId'], + // 'end_time': this.seconds (), + // 'after': 'string', // after cursor for pagination + // 'before': 'string', // before cursor for pagination + // 'page_size': limit, + }; + let currency = undefined; + if (code !== undefined) { + currency = this.currency (code); + request['asset_id'] = currency['numericId']; + } + if (limit !== undefined) { + request['page_size'] = limit; + } + const response = await this.privateGetWalletTransactions (this.extend (request, params)); + // + // { + // "meta":{"after":null,"before":null,"limit":10,"total_count":1}, + // "result":[ + // { + // "amount":"29.889184", + // "asset_id":5, + // "balance":"29.889184", + // "created_at":"2020-11-15T21:25:01Z", + // "meta_data":{ + // "deposit_id":3884, + // "transaction_id":"0x41a60174849828530abb5008e98fc63c9b598288743ec4ba9620bcce900a3b8d" + // }, + // "transaction_type":"deposit", + // "user_id":22142, + // "uuid":"70bb5679da3c4637884e2dc63efaa846" + // } + // ], + // "success":true + // } + // + const result = this.safeValue (response, 'result', []); + return this.parseLedger (result, currency, since, limit); + } + + parseLedgerEntryType (type) { + const types = { + 'pnl': 'pnl', + 'deposit': 'transaction', + 'withdrawal': 'transaction', + 'commission': 'fee', + 'conversion': 'trade', + // 'perpetual_futures_funding': 'perpetual_futures_funding', + // 'withdrawal_cancellation': 'withdrawal_cancellation', + 'referral_bonus': 'referral', + 'commission_rebate': 'rebate', + // 'promo_credit': 'promo_credit', + }; + return this.safeString (types, type, type); + } + + parseLedgerEntry (item, currency = undefined) { + // + // { + // "amount":"29.889184", + // "asset_id":5, + // "balance":"29.889184", + // "created_at":"2020-11-15T21:25:01Z", + // "meta_data":{ + // "deposit_id":3884, + // "transaction_id":"0x41a60174849828530abb5008e98fc63c9b598288743ec4ba9620bcce900a3b8d" + // }, + // "transaction_type":"deposit", + // "user_id":22142, + // "uuid":"70bb5679da3c4637884e2dc63efaa846" + // } + // + const id = this.safeString (item, 'uuid'); + let direction = undefined; + const account = undefined; + const metaData = this.safeValue (item, 'meta_data', {}); + const referenceId = this.safeString (metaData, 'transaction_id'); + const referenceAccount = undefined; + let type = this.safeString (item, 'transaction_type'); + if ((type === 'deposit') || (type === 'commission_rebate') || (type === 'referral_bonus') || (type === 'pnl') || (type === 'withdrawal_cancellation') || (type === 'promo_credit')) { + direction = 'in'; + } else if ((type === 'withdrawal') || (type === 'commission') || (type === 'conversion') || (type === 'perpetual_futures_funding')) { + direction = 'out'; + } + type = this.parseLedgerEntryType (type); + const currencyId = this.safeInteger (item, 'asset_id'); + const currenciesByNumericId = this.safeValue (this.options, 'currenciesByNumericId'); + currency = this.safeValue (currenciesByNumericId, currencyId, currency); + const code = (currency === undefined) ? undefined : currency['code']; + const amount = this.safeFloat (item, 'amount'); + const timestamp = this.parse8601 (this.safeString (item, 'created_at')); + const after = this.safeFloat (item, 'balance'); + const before = Math.max (0, after - amount); + const status = 'ok'; + return { + 'info': item, + 'id': id, + 'direction': direction, + 'account': account, + 'referenceId': referenceId, + 'referenceAccount': referenceAccount, + 'type': type, + 'currency': code, + 'amount': amount, + 'before': before, + 'after': after, + 'status': status, + 'timestamp': timestamp, + 'datetime': this.iso8601 (timestamp), + 'fee': undefined, + }; + } + + async fetchDepositAddress (code, params = {}) { + await this.loadMarkets (); + const currency = this.currency (code); + const request = { + 'asset_symbol': currency['id'], + }; + const response = await this.privateGetDepositsAddress (this.extend (request, params)); + // + // { + // "success":true, + // "result":{ + // "id":19628, + // "user_id":22142, + // "address":"0x0eda26523397534f814d553a065d8e46b4188e9a", + // "status":"active", + // "updated_at":"2020-11-15T20:25:53.000Z", + // "created_at":"2020-11-15T20:25:53.000Z", + // "asset_symbol":"USDT", + // "custodian":"onc" + // } + // } + // + const result = this.safeValue (response, 'result', {}); + const address = this.safeString (result, 'address'); + this.checkAddress (address); + return { + 'currency': code, + 'address': address, + 'tag': undefined, + 'info': response, + }; + } + + sign (path, api = 'public', method = 'GET', params = {}, headers = undefined, body = undefined) { + const requestPath = '/' + this.version + '/' + this.implodeParams (path, params); + let url = this.urls['api'][api] + requestPath; + const query = this.omit (params, this.extractParams (path)); + if (api === 'public') { + if (Object.keys (query).length) { + url += '?' + this.urlencode (query); + } + } else if (api === 'private') { + this.checkRequiredCredentials (); + const timestamp = this.seconds ().toString (); + headers = { + 'api-key': this.apiKey, + 'timestamp': timestamp, + }; + let auth = method + timestamp + requestPath; + if ((method === 'GET') || (method === 'DELETE')) { + if (Object.keys (query).length) { + const queryString = '?' + this.urlencode (query); + auth += queryString; + url += queryString; + } + } else { + body = this.json (query); + auth += body; + headers['Content-Type'] = 'application/json'; + } + const signature = this.hmac (this.encode (auth), this.encode (this.secret)); + headers['signature'] = signature; + } + return { 'url': url, 'method': method, 'body': body, 'headers': headers }; + } + + handleErrors (code, reason, url, method, headers, body, response, requestHeaders, requestBody) { + if (response === undefined) { + return; + } + // + // {"error":{"code":"insufficient_margin","context":{"available_balance":"0.000000000000000000","required_additional_balance":"1.618626000000000000000000000"}},"success":false} + // + const error = this.safeValue (response, 'error', {}); + const errorCode = this.safeString (error, 'code'); + if (errorCode !== undefined) { + const feedback = this.id + ' ' + body; + this.throwExactlyMatchedException (this.exceptions['exact'], errorCode, feedback); + this.throwBroadlyMatchedException (this.exceptions['broad'], errorCode, feedback); + throw new ExchangeError (feedback); // unknown message + } + } +}; diff --git a/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/deribit.js b/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/deribit.js index 9f88f869b..f277c3975 100644 --- a/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/deribit.js +++ b/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/deribit.js @@ -778,7 +778,7 @@ module.exports = class deribit extends Exchange { const now = this.milliseconds (); if (since === undefined) { if (limit === undefined) { - throw new ArgumentsRequired (this.id + ' fetchOHLCV requires a since argument or a limit argument'); + throw new ArgumentsRequired (this.id + ' fetchOHLCV() requires a since argument or a limit argument'); } else { request['start_timestamp'] = now - (limit - 1) * duration * 1000; request['end_timestamp'] = now; @@ -1011,7 +1011,7 @@ module.exports = class deribit extends Exchange { 'cancelled': 'canceled', 'filled': 'closed', 'rejected': 'rejected', - // 'untriggered': 'open', + 'untriggered': 'open', }; return this.safeString (statuses, status, status); } @@ -1096,7 +1096,8 @@ module.exports = class deribit extends Exchange { trades = this.parseTrades (trades, market); } const timeInForce = this.parseTimeInForce (this.safeString (order, 'time_in_force')); - const stopPrice = undefined; + const stopPrice = this.safeValue (order, 'stop_price'); + const postOnly = this.safeValue (order, 'post_only'); return { 'info': order, 'id': id, @@ -1107,6 +1108,7 @@ module.exports = class deribit extends Exchange { 'symbol': market['symbol'], 'type': type, 'timeInForce': timeInForce, + 'postOnly': postOnly, 'side': side, 'price': price, 'stopPrice': stopPrice, @@ -1191,13 +1193,13 @@ module.exports = class deribit extends Exchange { if (price !== undefined) { request['price'] = this.priceToPrecision (symbol, price); } else { - throw new ArgumentsRequired (this.id + ' createOrder requires a price argument for a ' + type + ' order'); + throw new ArgumentsRequired (this.id + ' createOrder() requires a price argument for a ' + type + ' order'); } } if (stopPriceIsRequired) { const stopPrice = this.safeFloat2 (params, 'stop_price', 'stopPrice'); if (stopPrice === undefined) { - throw new ArgumentsRequired (this.id + ' createOrder requires a stop_price or stopPrice param for a ' + type + ' order'); + throw new ArgumentsRequired (this.id + ' createOrder() requires a stop_price or stopPrice param for a ' + type + ' order'); } else { request['stop_price'] = this.priceToPrecision (symbol, stopPrice); } @@ -1266,10 +1268,10 @@ module.exports = class deribit extends Exchange { async editOrder (id, symbol, type, side, amount = undefined, price = undefined, params = {}) { if (amount === undefined) { - throw new ArgumentsRequired (this.id + ' editOrder requires an amount argument'); + throw new ArgumentsRequired (this.id + ' editOrder() requires an amount argument'); } if (price === undefined) { - throw new ArgumentsRequired (this.id + ' editOrder requires a price argument'); + throw new ArgumentsRequired (this.id + ' editOrder() requires a price argument'); } await this.loadMarkets (); const request = { @@ -1631,7 +1633,7 @@ module.exports = class deribit extends Exchange { const request = { 'instrument_name': market['id'], }; - const response = await this.privateGetPosition (this.extend (request, params)); + const response = await this.privateGetGetPosition (this.extend (request, params)); // // { // "jsonrpc": "2.0", @@ -1670,7 +1672,7 @@ module.exports = class deribit extends Exchange { const request = { 'currency': currency['id'], }; - const response = await this.privateGetPositions (this.extend (request, params)); + const response = await this.privateGetGetPositions (this.extend (request, params)); // // { // "jsonrpc": "2.0", diff --git a/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/digifinex.js b/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/digifinex.js index 25a9fcabb..6584b919c 100644 --- a/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/digifinex.js +++ b/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/digifinex.js @@ -502,7 +502,7 @@ module.exports = class digifinex extends Exchange { async fetchTickers (symbols = undefined, params = {}) { const apiKey = this.safeValue (params, 'apiKey', this.apiKey); if (!apiKey) { - throw new ArgumentsRequired (this.id + ' fetchTicker is a private v2 endpoint that requires an `exchange.apiKey` credential or an `apiKey` extra parameter'); + throw new ArgumentsRequired (this.id + ' fetchTickers() is a private v2 endpoint that requires an `exchange.apiKey` credential or an `apiKey` extra parameter'); } await this.loadMarkets (); const request = { @@ -548,7 +548,7 @@ module.exports = class digifinex extends Exchange { async fetchTicker (symbol, params = {}) { const apiKey = this.safeValue (params, 'apiKey', this.apiKey); if (!apiKey) { - throw new ArgumentsRequired (this.id + ' fetchTicker is a private v2 endpoint that requires an `exchange.apiKey` credential or an `apiKey` extra parameter'); + throw new ArgumentsRequired (this.id + ' fetchTicker() is a private v2 endpoint that requires an `exchange.apiKey` credential or an `apiKey` extra parameter'); } await this.loadMarkets (); const market = this.market (symbol); @@ -994,6 +994,7 @@ module.exports = class digifinex extends Exchange { 'symbol': symbol, 'type': type, 'timeInForce': undefined, + 'postOnly': undefined, 'side': side, 'price': price, 'stopPrice': undefined, @@ -1284,7 +1285,7 @@ module.exports = class digifinex extends Exchange { const address = this.safeString (depositAddress, 'address'); const tag = this.safeString (depositAddress, 'addressTag'); const currencyId = this.safeStringUpper (depositAddress, 'currency'); - const code = this.safeCurrencCode (currencyId); + const code = this.safeCurrencyCode (currencyId); return { 'info': depositAddress, 'code': code, diff --git a/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/dsx.js b/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/dsx.js index cff6ab255..349fc2489 100644 --- a/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/dsx.js +++ b/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/dsx.js @@ -653,7 +653,7 @@ module.exports = class dsx extends Exchange { await this.loadMarkets (); const market = this.market (symbol); if (type === 'market' && price === undefined) { - throw new ArgumentsRequired (this.id + ' createOrder requires a price argument even for market orders, that is the worst price that you agree to fill your order for'); + throw new ArgumentsRequired (this.id + ' createOrder() requires a price argument even for market orders, that is the worst price that you agree to fill your order for'); } const request = { 'pair': market['id'], @@ -840,6 +840,7 @@ module.exports = class dsx extends Exchange { 'lastTradeTimestamp': lastTradeTimestamp, 'type': orderType, 'timeInForce': undefined, + 'postOnly': undefined, 'side': side, 'price': price, 'stopPrice': undefined, diff --git a/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/equos.js b/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/equos.js new file mode 100644 index 000000000..5dc44a2ac --- /dev/null +++ b/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/equos.js @@ -0,0 +1,1548 @@ +'use strict'; + +// ---------------------------------------------------------------------------- + +const Exchange = require ('./base/Exchange'); +const { ExchangeError, ArgumentsRequired, BadSymbol } = require ('./base/errors'); + +// ---------------------------------------------------------------------------- + +module.exports = class equos extends Exchange { + describe () { + return this.deepExtend (super.describe (), { + 'id': 'equos', + 'name': 'EQUOS', + 'countries': [ 'US', 'SG' ], // United States, Singapore + 'rateLimit': 10, + 'has': { + 'CORS': false, + 'cancelOrder': true, + 'createOrder': true, + 'editOrder': true, + 'fetchBalance': true, + 'fetchCanceledOrders': true, + 'fetchClosedOrders': true, + 'fetchCurrencies': true, + 'fetchDepositAddress': true, + 'fetchDeposits': true, + 'fetchMarkets': true, + 'fetchMyTrades': true, + 'fetchOHLCV': true, + 'fetchOrder': true, + 'fetchOrderBook': true, + 'fetchOrders': true, + 'fetchTicker': false, + 'fetchTrades': true, + 'fetchTradingFees': true, + 'fetchWithdrawals': true, + 'withdraw': true, + }, + 'timeframes': { + '1m': 1, + '5m': 2, + '15m': 3, + '1h': 4, + '6h': 5, + '1d': 6, + '7d': 7, + }, + 'urls': { + 'logo': 'https://user-images.githubusercontent.com/1294454/107758499-05edd180-6d38-11eb-9e09-0b69602a7a15.jpg', + 'test': { + 'public': 'https://testnet.equos.io/api', + 'private': 'https://testnet.equos.io/api', + }, + 'api': { + 'public': 'https://equos.io/api', + 'private': 'https://equos.io/api', + }, + 'www': 'https://equos.io', + 'doc': [ + 'https://developer.equos.io', + ], + 'referral': 'https://equos.io?referredByCode=zpa8kij4ouvBFup3', + }, + 'api': { + 'public': { + 'get': [ + 'health', + 'getInstruments', + 'getInstrumentPairs', + 'getOrderBook', + 'getRisk', + 'getTradeHistory', + 'getFundingRateHistory', + 'getChart', + 'getExchangeInfo', // not documented + ], + }, + 'private': { + 'post': [ + 'logon', + 'order', + 'cancelOrder', + 'cancelReplaceOrder', + 'getOrder', + 'getOrders', + 'getOrderStatus', + 'getOrderHistory', + 'userTrades', + 'getPositions', + 'cancelAll', + 'getUserHistory', + 'getRisk', + 'getDepositAddresses', + 'getDepositHistory', // not documented + 'getWithdrawRequests', + 'sendWithdrawRequest', + 'getTransferHistory', + ], + }, + }, + 'requiredCredentials': { + 'apiKey': true, + 'secret': true, + 'uid': true, + }, + 'exceptions': { + 'broad': { + 'symbol not found': BadSymbol, + }, + }, + }); + } + + async fetchMarkets (params = {}) { + const request = { + 'verbose': true, + }; + const response = await this.publicGetGetInstrumentPairs (this.extend (request, params)); + // + // { + // "instrumentPairs":[ + // { + // "instrumentId":52, + // "symbol":"BTC/USDC", + // "quoteId":1, + // "baseId":3, + // "price_scale":2, + // "quantity_scale":6, + // "securityStatus":1, + // "securityDesc":"BTC/USDC", // "BTC/USDC[F]" + // "assetType":"PAIR", // "PERPETUAL_SWAP" + // "currency":"BTC", + // "contAmtCurr":"USDC", + // "settlCurrency":"USDC", + // "commCurrency":"USDC", + // "cfiCode":"XXXXXX", + // "securityExchange":"XXXX", + // "instrumentPricePrecision":2, + // "minPriceIncrement":1.0, + // "minPriceIncrementAmount":1.0, + // "roundLot":1, + // "minTradeVol":0.001000, + // "maxTradeVol":0.000000 + // // contracts onlye + // "qtyType":0, + // "contractMultiplier":1.0, + // "issueDate":1598608087000 + // }, + // ] + // } + // + const instrumentPairs = this.safeValue (response, 'instrumentPairs', []); + const markets = []; + for (let i = 0; i < instrumentPairs.length; i++) { + const market = this.parseMarket (instrumentPairs[i]); + markets.push (market); + } + return markets; + } + + parseMarket (market) { + // + // { + // "instrumentId":52, + // "symbol":"BTC/USDC", // "BTC/USDC[F]" + // "quoteId":1, + // "baseId":3, + // "price_scale":2, + // "quantity_scale":6, + // "securityStatus":1, + // "securityDesc":"BTC/USDC", // "BTC/USDC[F]" + // "assetType":"PAIR", // "PERPETUAL_SWAP" + // "currency":"BTC", + // "contAmtCurr":"USDC", + // "settlCurrency":"USDC", + // "commCurrency":"USDC", + // "cfiCode":"XXXXXX", + // "securityExchange":"XXXX", + // "instrumentPricePrecision":2, + // "minPriceIncrement":1.0, + // "minPriceIncrementAmount":1.0, + // "roundLot":1, + // "minTradeVol":0.001000, + // "maxTradeVol":0.000000 + // // contracts onlye + // "qtyType":0, + // "contractMultiplier":1.0, + // "issueDate":1598608087000 + // } + // + const id = this.safeString (market, 'instrumentId'); + const uppercaseId = this.safeString (market, 'symbol'); + const assetType = this.safeString (market, 'assetType'); + const spot = (assetType === 'PAIR'); + const swap = (assetType === 'PERPETUAL_SWAP'); + const type = swap ? 'swap' : 'spot'; + const baseId = this.safeString (market, 'currency'); + const quoteId = this.safeString (market, 'contAmtCurr'); + const base = this.safeCurrencyCode (baseId); + const quote = this.safeCurrencyCode (quoteId); + const symbol = swap ? uppercaseId : (base + '/' + quote); + const status = this.safeInteger (market, 'securityStatus'); + const active = (status === 1); + const precision = { + 'amount': this.safeInteger (market, 'quantity_scale'), + 'price': this.safeInteger (market, 'price_scale'), + }; + return { + 'id': id, + 'uppercaseId': uppercaseId, + 'symbol': symbol, + 'base': base, + 'quote': quote, + 'baseId': baseId, + 'quoteId': quoteId, + 'type': type, + 'spot': spot, + 'swap': swap, + 'active': active, + 'precision': precision, + 'limits': { + 'amount': { + 'min': this.safeFloat (market, 'minTradeVol'), + 'max': undefined, + }, + 'price': { + 'min': undefined, + 'max': undefined, + }, + 'cost': { + 'min': undefined, + 'max': undefined, + }, + }, + 'info': market, + }; + } + + async fetchCurrencies (params = {}) { + const response = await this.publicGetGetInstruments (params); + // + // { + // "instruments": [ + // [ + // 3, // id + // "BTC", // symbol + // 2, // price_scale + // 6, // amount_scale + // 1, // status + // 0, // withdraw_fee + // "BTC", // name + // true, // withdrawal_pct + // ], + // ] + // } + // + const currencies = {}; + const instruments = this.safeValue (response, 'instruments', []); + for (let i = 0; i < instruments.length; i++) { + const currency = this.parseCurrency (instruments[i]); + const code = currency['code']; + currencies[code] = currency; + } + return currencies; + } + + parseCurrency (currency) { + // + // [ + // 3, // 0 id + // "BTC", // 1 symbol + // 2, // 2 price_scale + // 6, // 3 amount_scale + // 1, // 4 status + // 0, // 5 withdraw_fee + // "BTC", // 6 name + // true, // 7 withdrawal_pct + // ], + // + const id = this.safeString (currency, 0); + const uppercaseId = this.safeString (currency, 1); + const code = this.safeCurrencyCode (uppercaseId); + const priceScale = this.safeInteger (currency, 2); + const amountScale = this.safeInteger (currency, 3); + const precision = Math.max (priceScale, amountScale); + const name = this.safeString (currency, 6); + const status = this.safeInteger (currency, 4); + const active = (status === 1); + const fee = this.safeFloat (currency, 5); // withdraw_fee + return { + 'id': id, + 'info': currency, + 'uppercaseId': uppercaseId, + 'code': code, + 'name': name, + 'precision': precision, + 'fee': fee, + 'active': active, + 'limits': { + 'amount': { + 'min': undefined, + 'max': undefined, + }, + 'price': { + 'min': undefined, + 'max': undefined, + }, + 'cost': { + 'min': undefined, + 'max': undefined, + }, + 'withdraw': { + 'min': undefined, + 'max': undefined, + }, + }, + }; + } + + async fetchOHLCV (symbol, timeframe = '1m', since = undefined, limit = undefined, params = {}) { + await this.loadMarkets (); + const market = this.market (symbol); + const request = { + 'pairId': parseInt (market['id']), + 'timespan': this.timeframes[timeframe], + }; + if (limit !== undefined) { + request['limit'] = limit; + } + const response = await this.publicGetGetChart (this.extend (request, params)); + // + // { + // "pairId":57, + // "t":1, + // "s":"ETH/BTC", + // "lastPx":44099, + // "lastQty":100000, + // "o":0.043831000000000016, + // "h":0.04427100000000002, + // "l":0.032000000000000015, + // "c":0.04409900000000002, + // "v":0.21267333000000016, + // "q":4.850000000000001, + // "chart":[ + // [1612519260000,44099,44099,44099,44099,0,441], + // [1612519200000,44099,44099,44099,44099,0,440], + // [1612519140000,44269,44271,44269,44271,0,439], + // ] + // } + // + const chart = this.safeValue (response, 'chart', []); + return this.parseOHLCVs (chart, market, timeframe, since, limit); + } + + parseOHLCV (ohlcv, market = undefined) { + // + // [ + // 1612519260000, // timestamp + // 44099, // open + // 44099, // high + // 44099, // low + // 44099, // close + // 0, // base volume + // 441, // seqNumber + // ] + // + const timestamp = this.safeInteger (ohlcv, 0); + const open = this.convertFromScale (ohlcv[1], market['precision']['price']); + const high = this.convertFromScale (ohlcv[2], market['precision']['price']); + const low = this.convertFromScale (ohlcv[3], market['precision']['price']); + const close = this.convertFromScale (ohlcv[4], market['precision']['price']); + const volume = this.convertFromScale (ohlcv[5], market['precision']['amount']); + // volume = ohlcv[5]; + return [timestamp, open, high, low, close, volume]; + } + + parseBidAsk (bidask, priceKey = 0, amountKey = 1, market = undefined) { + if (market === undefined) { + throw new ArgumentsRequired (this.id + ' parseBidAsk() requires a market argument'); + } + const price = this.safeFloat (bidask, priceKey); + const amount = this.safeFloat (bidask, amountKey); + return [ + this.convertFromScale (price, market['precision']['price']), + this.convertFromScale (amount, market['precision']['amount']), + ]; + } + + parseOrderBook (orderbook, timestamp = undefined, bidsKey = 'bids', asksKey = 'asks', priceKey = 0, amountKey = 1, market = undefined) { + const result = { + 'timestamp': timestamp, + 'datetime': this.iso8601 (timestamp), + 'nonce': undefined, + }; + const sides = [ bidsKey, asksKey ]; + for (let i = 0; i < sides.length; i++) { + const side = sides[i]; + const orders = []; + const bidasks = this.safeValue (orderbook, side); + for (let k = 0; k < bidasks.length; k++) { + orders.push (this.parseBidAsk (bidasks[k], priceKey, amountKey, market)); + } + result[side] = orders; + } + result[bidsKey] = this.sortBy (result[bidsKey], 0, true); + result[asksKey] = this.sortBy (result[asksKey], 0); + return result; + } + + async fetchOrderBook (symbol, limit = undefined, params = {}) { + await this.loadMarkets (); + const market = this.market (symbol); + const request = { + 'pairId': parseInt (market['id']), + }; + const response = await this.publicGetGetOrderBook (this.extend (request, params)); + // + // { + // "bids":[ + // [4000480,30000,1612644984667], + // [3999304,200000,1612644984667], + // [3998862,50000,1612644984667], + // ], + // "asks":[ + // [4001962,1790000,1612644984667], + // [4002616,1000,1612644984667], + // [4003889,1000,1612644984667], + // ], + // "usdMark":40011.02, + // "marketStatus":0, + // "estFundingRate":0.0, + // "fundingRateTime":0, + // "auctionPrice":0.0, + // "auctionVolume":0.0 + // } + // + return this.parseOrderBook (response, undefined, 'bids', 'asks', 0, 1, market); + } + + async fetchTrades (symbol, since = undefined, limit = undefined, params = {}) { + await this.loadMarkets (); + const market = this.market (symbol); + const request = { + 'pairId': parseInt (market['id']), + }; + const response = await this.publicGetGetTradeHistory (this.extend (request, params)); + // + // { + // "trades":[ + // [4022800,47000,"20210206-21:39:12.886",256323,1], + // [4023066,1000,"20210206-21:38:55.030",256322,1], + // [4022406,50000,"20210206-21:36:56.334",256321,1], + // ] + // } + // + const trades = this.safeValue (response, 'trades', []); + return this.parseTrades (trades, market, since, limit, params); + } + + parseTrade (trade, market = undefined) { + // + // public fetchTrades + // + // [ + // 4022800, // 0 price + // 47000, // 1 quantity + // "20210206-21:39:12.886", // 2 timestamp + // 256323, // 3 sequence number + // 1 // 4 taker side 1 = buy, 2 = sell + // ] + // + // private fetchMyTrades + // + // { + // "account":3583, + // "commission":"-0.015805", + // "commCurrency":"USDC", + // "execId":265757, + // "ordType":"2", + // "ordStatus":"2", + // "execType":"F", + // "aggressorIndicator":true, + // "orderId":388953019, + // "price":"1842.04", + // "qty":"0.010000", + // "lastPx":"1756.22", + // "avgPx":"1756.22", + // "cumQty":"0.010000", + // "quoteQty":"0.010000", + // "side":"BUY", + // "symbol":"ETH/USDC", + // "clOrdId":"1613106766970339107", + // "submitterId":3583, + // "targetStrategy":"0", + // "time":1613106766971, + // "date":"20210212-05:12:46.971" + // } + // + let id = undefined; + let timestamp = undefined; + let orderId = undefined; + let type = undefined; + let side = undefined; + let price = undefined; + let amount = undefined; + let cost = undefined; + let fee = undefined; + let symbol = undefined; + if (Array.isArray (trade)) { + id = this.safeString (trade, 3); + price = this.convertFromScale (this.safeInteger (trade, 0), market['precision']['price']); + amount = this.convertFromScale (this.safeInteger (trade, 1), market['precision']['amount']); + timestamp = this.toMilliseconds (this.safeString (trade, 2)); + const takerSide = this.safeInteger (trade, 4); + if (takerSide === 1) { + side = 'buy'; + } else if (takerSide === 2) { + side = 'sell'; + } + } else { + id = this.safeString (trade, 'execId'); + timestamp = this.safeInteger (trade, 'time'); + const marketId = this.safeString (trade, 'symbol'); + symbol = this.safeSymbol (marketId, market); + orderId = this.safeString (trade, 'orderId'); + side = this.safeStringLower (trade, 'side'); + type = this.parseOrderType (this.safeString (trade, 'ordType')); + price = this.safeFloat (trade, 'lastPx'); + amount = this.safeFloat (trade, 'quoteQty'); + let feeCost = this.safeFloat (trade, 'commission'); + if (feeCost !== undefined) { + feeCost = -feeCost; + const feeCurrencyId = this.safeString (trade, 'commCurrency'); + const feeCurrencyCode = this.safeCurrencyCode (feeCurrencyId); + fee = { + 'cost': feeCost, + 'currency': feeCurrencyCode, + }; + } + } + if ((symbol === undefined) && (market !== undefined)) { + symbol = market['symbol']; + } + if (cost === undefined) { + if ((amount !== undefined) && (price !== undefined)) { + cost = amount * price; + } + } + return { + 'info': trade, + 'id': id, + 'timestamp': timestamp, + 'datetime': this.iso8601 (timestamp), + 'symbol': symbol, + 'order': orderId, + 'type': type, + 'side': side, + 'takerOrMaker': undefined, + 'price': price, + 'amount': amount, + 'cost': cost, + 'fee': fee, + }; + } + + async fetchBalance (params = {}) { + await this.loadMarkets (); + const response = await this.privatePostGetPositions (params); + // { + // "positions":[ + // { + // "instrumentId":1, + // "userId":3583, + // "quantity":0, + // "availableQuantity":0, + // "quantity_scale":6, + // "symbol":"USDC", + // "assetType":"ASSET", + // "usdCostBasis":0.0, + // "usdAvgCostBasis":0.0, + // "usdValue":0.0, + // "usdUnrealized":0.0, + // "usdRealized":0.0, + // "baseUsdMark":1.0, + // "settleCoinUsdMark":0.0, + // "settleCoinUnrealized":0.0, + // "settleCoinRealized":0.0 + // }, + // ] + // } + const positions = this.safeValue (response, 'positions', []); + const result = { + 'info': response, + }; + for (let i = 0; i < positions.length; i++) { + const position = positions[i]; + const assetType = this.safeString (position, 'assetType'); + if (assetType === 'ASSET') { + const currencyId = this.safeString (position, 'symbol'); + const code = this.safeCurrencyCode (currencyId); + const quantity = this.safeFloat (position, 'quantity'); + const availableQuantity = this.safeFloat (position, 'availableQuantity'); + const scale = this.safeInteger (position, 'quantity_scale'); + const account = this.account (); + account['free'] = this.convertFromScale (availableQuantity, scale); + account['total'] = this.convertFromScale (quantity, scale); + result[code] = account; + } + } + return this.parseBalance (result); + } + + async createOrder (symbol, type, side, amount, price = undefined, params = {}) { + await this.loadMarkets (); + const market = this.market (symbol); + const orderSide = (side === 'buy') ? 1 : 2; + const quantityScale = this.getScale (amount); + const request = { + // 'id': 0, + // 'account': 0, // required for institutional users + 'instrumentId': parseInt (market['id']), + 'symbol': market['uppercaseId'], + // 'clOrdId': '', + 'side': orderSide, // 1 = buy, 2 = sell + // 'ordType': 1, // 1 = market, 2 = limit, 3 = stop market, 4 = stop limit + // 'price': this.priceToPrecision (symbol, price), // required for limit and stop limit orders + // 'price_scale': this.getScale (price), + 'quantity': this.convertToScale (amount, quantityScale), + 'quantity_scale': quantityScale, + // 'stopPx': this.priceToPrecision (symbol, stopPx), + // 'stopPx_scale': this.getScale (stopPx), + // 'targetStrategy': 0, + // 'isHidden': false, + // 'timeInForce': 1, // 1 = Good Till Cancel (GTC), 3 = Immediate or Cancel (IOC), 4 = Fill or Kill (FOK), 5 = Good Till Crossing (GTX), 6 = Good Till Date (GTD) + // 'interval': 0, + // 'intervalCount': 0, + // 'intervalDelay': 0, + // 'price2': 0, + // 'price2_scale': this.getScale (price2), + // 'blockWaitAck': 0, // 1 = wait for order acknowledgement, when set, response will include the matching engine "orderId" field + }; + if (type === 'market') { + request['ordType'] = 1; + } else if (type === 'limit') { + request['ordType'] = 2; + request['price'] = this.convertToScale (price, this.getScale (price)); + } else { + const stopPrice = this.safeFloat2 (params, 'stopPrice', 'stopPx'); + params = this.omit (params, [ 'stopPrice', 'stopPx' ]); + if (stopPrice === undefined) { + if (type === 'stop') { + if (price === undefined) { + throw new ArgumentsRequired (this.id + ' createOrder() requires a price argument or a stopPrice parameter or a stopPx parameter for ' + type + ' orders'); + } + request['ordType'] = 3; + request['stopPx'] = this.convertToScale (price, this.getScale (price)); + } else if (type === 'stop limit') { + throw new ArgumentsRequired (this.id + ' createOrder() requires a stopPrice parameter or a stopPx parameter for ' + type + ' orders'); + } + } else { + if (type === 'stop') { + request['ordType'] = 3; + request['stopPx'] = this.convertToScale (stopPrice, this.getScale (stopPrice)); + } else if (type === 'stop limit') { + request['ordType'] = 4; + const priceScale = this.getScale (price); + const stopPriceScale = this.getScale (stopPrice); + request['price_scale'] = priceScale; + request['stopPx_scale'] = stopPriceScale; + request['stopPx'] = this.convertToScale (stopPrice, stopPriceScale); + request['price'] = this.convertToScale (price, priceScale); + } + } + } + const response = await this.privatePostOrder (this.extend (request, params)); + // + // { + // "status":"sent", + // "id":385617863, + // "instrumentId":53, + // "clOrdId":"1613037510849637345", + // "userId":3583, + // "price":2000, + // "quantity":200, + // "ordType":2 + // } + // + return this.parseOrder (response, market); + } + + async cancelOrder (id, symbol = undefined, params = {}) { + if (symbol === undefined) { + throw new ArgumentsRequired (this.id + ' cancelOrder() requires a symbol argument'); + } + await this.loadMarkets (); + const market = this.market (symbol); + const request = { + 'origOrderId': parseInt (id), + 'instrumentId': parseInt (market['id']), + }; + const response = await this.privatePostCancelOrder (this.extend (request, params)); + // + // { + // "status":"sent", + // "id":0, + // "origOrderId":385613629, + // "instrumentId":53, + // "userId":3583, + // "price":0, + // "quantity":0, + // "ordType":0 + // } + // + return this.parseOrder (response, market); + } + + async editOrder (id, symbol, type, side, amount, price = undefined, params = {}) { + await this.loadMarkets (); + const market = this.market (symbol); + const orderSide = (side === 'buy') ? 1 : 2; + const quantityScale = this.getScale (amount); + const request = { + // 'id': 0, + 'origOrderId': id, + // 'account': 0, // required for institutional users + 'instrumentId': parseInt (market['id']), + 'symbol': market['uppercaseId'], + // 'clOrdId': '', + 'side': orderSide, // 1 = buy, 2 = sell + // 'ordType': 1, // 1 = market, 2 = limit, 3 = stop market, 4 = stop limit + // 'price': this.priceToPrecision (symbol, price), // required for limit and stop limit orders + // 'price_scale': this.getScale (price), + 'quantity': this.convertToScale (amount, quantityScale), + 'quantity_scale': quantityScale, + // 'stopPx': this.priceToPrecision (symbol, stopPx), + // 'stopPx_scale': this.getScale (stopPx), + // 'timeInForce': 1, // 1 = Good Till Cancel (GTC), 3 = Immediate or Cancel (IOC), 4 = Fill or Kill (FOK), 5 = Good Till Crossing (GTX), 6 = Good Till Date (GTD) + }; + if (type === 'market') { + request['ordType'] = 1; + } else if (type === 'limit') { + request['ordType'] = 2; + request['price'] = this.convertToScale (price, this.getScale (price)); + } else { + const stopPrice = this.safeFloat2 (params, 'stopPrice', 'stopPx'); + params = this.omit (params, [ 'stopPrice', 'stopPx' ]); + if (stopPrice === undefined) { + if (type === 'stop') { + if (price === undefined) { + throw new ArgumentsRequired (this.id + ' editOrder() requires a price argument or a stopPrice parameter or a stopPx parameter for ' + type + ' orders'); + } + request['ordType'] = 3; + request['stopPx'] = this.convertToScale (price, this.getScale (price)); + } else if (type === 'stop limit') { + throw new ArgumentsRequired (this.id + ' editOrder() requires a stopPrice parameter or a stopPx parameter for ' + type + ' orders'); + } + } else { + if (type === 'stop') { + request['ordType'] = 3; + request['stopPx'] = this.convertToScale (stopPrice, this.getScale (stopPrice)); + } else if (type === 'stop limit') { + request['ordType'] = 4; + const priceScale = this.getScale (price); + const stopPriceScale = this.getScale (stopPrice); + request['price_scale'] = priceScale; + request['stopPx_scale'] = stopPriceScale; + request['stopPx'] = this.convertToScale (stopPrice, stopPriceScale); + request['price'] = this.convertToScale (price, priceScale); + } + } + } + const response = await this.privatePostOrder (this.extend (request, params)); + // + // { + // "status":"sent", + // "id":385617863, + // "instrumentId":53, + // "clOrdId":"1613037510849637345", + // "userId":3583, + // "price":2000, + // "quantity":200, + // "ordType":2 + // } + // + return this.parseOrder (response, market); + } + + async fetchOrder (id, symbol = undefined, params = {}) { + await this.loadMarkets (); + const request = { + 'orderId': parseInt (id), + }; + const response = await this.privatePostGetOrderStatus (this.extend (request, params)); + // + // { + // "orderId":388953019, + // "clOrdId":"1613106766970339107", + // "symbol":"ETH/USDC", + // "instrumentId":53, + // "side":"1", + // "userId":3583, + // "account":3583, + // "execType":"F", + // "ordType":"2", + // "ordStatus":"2", + // "timeInForce":"3", + // "timeStamp":"20210212-05:12:46.971", + // "execId":265757, + // "targetStrategy":0, + // "isHidden":false, + // "isReduceOnly":false, + // "isLiquidation":false, + // "fee":0, + // "fee_scale":6, + // "feeInstrumentId":1, + // "price":184204, + // "price_scale":2, + // "quantity":10000, + // "quantity_scale":6, + // "leavesQty":0, + // "leavesQty_scale":6, + // "cumQty":10000, + // "cumQty_scale":6, + // "lastPx":175622, + // "lastPx_scale":2, + // "avgPx":175622, + // "avgPx_scale":2, + // "lastQty":10000, + // "lastQty_scale":6 + // } + // + return this.parseOrder (response); + } + + async fetchClosedOrders (symbol = undefined, since = undefined, limit = undefined, params = {}) { + const request = { + 'ordStatus': '2', // '0' = New, '1' = Partially filled, '2' = Filled, '4' = Cancelled, '8' = Rejected, 'C' = Expired + }; + return await this.fetchOrders (symbol, since, limit, this.extend (request, params)); + } + + async fetchCanceledOrders (symbol = undefined, since = undefined, limit = undefined, params = {}) { + const request = { + 'ordStatus': '4', // '0' = New, '1' = Partially filled, '2' = Filled, '4' = Cancelled, '8' = Rejected, 'C' = Expired + }; + return await this.fetchOrders (symbol, since, limit, this.extend (request, params)); + } + + async fetchOrders (symbol = undefined, since = undefined, limit = undefined, params = {}) { + await this.loadMarkets (); + let market = undefined; + const request = { + // 'account': id, // for institutional users + // 'symbol': marketSymbol, // cannot be used with instrumentId + // 'instrumentId': market['numericId'], + // 'limit': limit, + // 'execType': execType, // '0' = New, '4' = Canceled, '5' = Replace, '8' = Rejected, 'C' = Expired, 'F' = Fill Status, 'I' = Order Status + // 'ordStatus': ordStatus, // '0' = New, '1' = Partially filled, '2' = Filled, '4' = Cancelled, '8' = Rejected, 'C' = Expired + }; + if (symbol !== undefined) { + market = this.market (symbol); + request['instrumentId'] = parseInt (market['id']); + } + if (limit !== undefined) { + request['limit'] = limit; + } + const response = await this.privatePostGetOrders (this.extend (request, params)); + // + // { + // "isInitialSnap":false, + // "orders":[ + // { + // "orderId":385613629, + // "orderUpdateSeq":1, + // "clOrdId":"1613037448945798198", + // "symbol":"ETH/USDC", + // "instrumentId":53, + // "side":"1", + // "userId":3583, + // "account":3583, + // "execType":"4", + // "ordType":"2", + // "ordStatus":"C", + // "timeInForce":"3", + // "timeStamp":"20210211-09:57:28.944", + // "execId":0, + // "targetStrategy":0, + // "isHidden":false, + // "isReduceOnly":false, + // "isLiquidation":false, + // "fee":0, + // "feeTotal":0, + // "fee_scale":0, + // "feeInstrumentId":0, + // "price":999, + // "price_scale":2, + // "quantity":10000000, + // "quantity_scale":6, + // "leavesQty":10000000, + // "leavesQty_scale":6, + // "cumQty":0, + // "cumQty_scale":0, + // "lastPx":0, + // "lastPx_scale":2, + // "avgPx":0, + // "avgPx_scale":0, + // "lastQty":0, + // "lastQty_scale":6 + // } + // ] + // } + // + const orders = this.safeValue (response, 'orders', []); + return this.parseOrders (orders, market, since, limit, params); + } + + async fetchMyTrades (symbol = undefined, since = undefined, limit = undefined, params = {}) { + await this.loadMarkets (); + const request = { + // 'account': 123, // for institutional users + // 'instrumentId': market['id'], + // 'startTime': since, + // 'endTime': this.milliseconds (), + }; + let market = undefined; + if (symbol !== undefined) { + market = this.market (symbol); + request['instrumentId'] = market['id']; + } + if (since !== undefined) { + request['startTime'] = since; + } + const response = await this.privatePostUserTrades (this.extend (request, params)); + // + // { + // "trades":[ + // { + // "account":3583, + // "commission":"-0.015805", + // "commCurrency":"USDC", + // "execId":265757, + // "ordType":"2", + // "ordStatus":"2", + // "execType":"F", + // "aggressorIndicator":true, + // "orderId":388953019, + // "price":"1842.04", + // "qty":"0.010000", + // "lastPx":"1756.22", + // "avgPx":"1756.22", + // "cumQty":"0.010000", + // "quoteQty":"0.010000", + // "side":"BUY", + // "symbol":"ETH/USDC", + // "clOrdId":"1613106766970339107", + // "submitterId":3583, + // "targetStrategy":"0", + // "time":1613106766971, + // "date":"20210212-05:12:46.971" + // } + // ] + // } + // + const trades = this.safeValue (response, 'trades', []); + return this.parseTrades (trades, market, since, limit, params); + } + + async fetchDepositAddress (code, params = {}) { + await this.loadMarkets (); + const currency = this.currency (code); + const request = { + 'instrumentId': parseInt (currency['id']), + }; + const response = await this.privatePostGetDepositAddresses (this.extend (request, params)); + // + // { + // "addresses":[ + // {"instrumentId":1,"userId":3583,"symbol":"USDC","address":"0xdff47af071ea3c537e57278290516cda32a78b97","status":1} + // ] + // } + // + const addresses = this.safeValue (response, 'addresses', []); + const address = this.safeValue (addresses, 0); + return this.parseDepositAddress (address, currency); + } + + parseDepositAddress (depositAddress, currency = undefined) { + // + // { + // "instrumentId":1, + // "userId":3583, + // "symbol":"USDC", + // "address":"0xdff47af071ea3c537e57278290516cda32a78b97", + // "status":1 + // } + // + const currencyId = this.safeString (depositAddress, 'symbol'); + const code = this.safeCurrencyCode (currencyId, currency); + const address = this.safeString (depositAddress, 'address'); + this.checkAddress (address); + return { + 'currency': code, + 'address': address, + 'tag': undefined, + 'info': depositAddress, + }; + } + + async fetchDeposits (code = undefined, since = undefined, limit = undefined, params = {}) { + await this.loadMarkets (); + const request = {}; + let currency = undefined; + if (code !== undefined) { + currency = this.currency (code); + request['instrumentId'] = parseInt (currency['id']); + } + const response = await this.privatePostGetDepositHistory (this.extend (request, params)); + // + // { + // "deposits":[ + // { + // "id":4309, + // "instrumentId":1, + // "userId":3583, + // "symbol":"USDC", + // "address":"null", + // "timestamp":"1613021112189", + // "status":1, + // "balance":0.0, + // "balance_change":100.0, + // "confirms":1, + // "transactionId":"caba4500-489f-424e-abd7-b4dabc09a800" + // } + // ] + // } + // + const deposits = this.safeValue (response, 'deposits', []); + return this.parseTransactions (deposits, currency, since, limit, { 'type': 'deposit' }); + } + + async fetchWithdrawals (code = undefined, since = undefined, limit = undefined, params = {}) { + await this.loadMarkets (); + const request = {}; + let currency = undefined; + if (code !== undefined) { + currency = this.currency (code); + request['instrumentId'] = parseInt (currency['id']); + } + const response = await this.privatePostGetWithdrawRequests (this.extend (request, params)); + // + // { + // "addresses":[ + // { + // "id":3841, + // "instrumentId":3, + // "userId":4245, + // "symbol":"BTC", + // "address":"XXXXXYYYYYZZZZZ", + // "timestamp":"20200806-11:04:35.053", + // "status":0, + // "balance":1, + // "balance_scale":3, + // "confirms":0, + // "transactionId":"null" + // } + // ] + // } + // + const withdrawals = this.safeValue (response, 'addresses', []); + return this.parseTransactions (withdrawals, currency, since, limit, { 'type': 'withdrawal' }); + } + + parseTransaction (transaction, currency = undefined) { + // + // fetchDeposits, fetchWithdrawals + // + // { + // "id":4309, + // "instrumentId":1, + // "userId":3583, + // "symbol":"USDC", + // "address":"null", + // "timestamp":"1613021112189", + // "status":1, + // "balance":0.0, + // "balance_change":100.0, + // "confirms":1, + // "transactionId":"caba4500-489f-424e-abd7-b4dabc09a800" + // } + // + // withdraw + // + // { + // "instrumentId": 1, + // "userId": 23750, + // "symbol": "USDC", + // "timestamp": "20200201-05:37:16.584", + // "status": 1, + // "userUuid": "b9e33713-c28f-468f-99bd-f6deab0dd854", + // "currencyCode": "USDC", + // "address": "2MvW97yT6E2Kq8bWc1aj1DqfbgMzjRNk2LE", + // "quantity": 20, + // "requestUuid": "56782b34-8a78-4f5f-b164-4b8f7d583b7f", + // "transactionUuid": "1004eb0f-41e1-41e9-9d48-8eefcc6c09f2", + // "transactionId": "WS23436", + // "destinationWalletAlias": "Test", + // "quantity_scale": 0 + // } + // + const id = this.safeString (transaction, 'id', 'transactionId'); + const txid = this.safeString (transaction, 'transactionUuid'); + const timestamp = this.safeInteger (transaction, 'timestamp'); + let address = this.safeString (transaction, 'address'); + if (address === 'null') { + address = undefined; + } + const type = this.safeString (transaction, 'type'); + let amount = this.safeFloat (transaction, 'balance_change'); + if (amount === undefined) { + amount = this.safeInteger (transaction, 'quantity'); + const amountScale = this.safeInteger (transaction, 'quantity_scale'); + amount = this.convertFromScale (amount, amountScale); + } + const currencyId = this.safeString (transaction, 'symbol'); + const code = this.safeCurrencyCode (currencyId, currency); + const status = this.parseTransactionStatus (this.safeString (transaction, 'status')); + return { + 'info': transaction, + 'id': id, + 'txid': txid, + 'timestamp': timestamp, + 'datetime': this.iso8601 (timestamp), + 'addressFrom': undefined, + 'address': address, + 'addressTo': undefined, + 'tagFrom': undefined, + 'tag': undefined, + 'tagTo': undefined, + 'type': type, + 'amount': amount, + 'currency': code, + 'status': status, + 'updated': undefined, + 'comment': undefined, + 'fee': undefined, + }; + } + + parseTransactionStatus (status) { + const statuses = { + '0': 'pending', + '1': 'ok', + }; + return this.safeString (statuses, status, status); + } + + async withdraw (code, amount, address, tag = undefined, params = {}) { + this.checkAddress (address); + await this.loadMarkets (); + const currency = this.currency (code); + const scale = this.getScale (amount); + const quantity = this.convertToScale (amount, scale); + const request = { + 'instrumentId': parseInt (currency['id']), + 'symbol': currency['uppercaseId'], + 'quantity': quantity, + 'quantity_scale': scale, + 'address': address, + }; + const response = await this.privatePostSendWithdrawRequest (this.extend (request, params)); + // + // { + // "instrumentId": 1, + // "userId": 23750, + // "symbol": "USDC", + // "timestamp": "20200201-05:37:16.584", + // "status": 1, + // "userUuid": "b9e33713-c28f-468f-99bd-f6deab0dd854", + // "currencyCode": "USDC", + // "address": "2MvW97yT6E2Kq8bWc1aj1DqfbgMzjRNk2LE", + // "quantity": 20, + // "requestUuid": "56782b34-8a78-4f5f-b164-4b8f7d583b7f", + // "transactionUuid": "1004eb0f-41e1-41e9-9d48-8eefcc6c09f2", + // "transactionId": "WS23436", + // "destinationWalletAlias": "Test", + // "quantity_scale": 0 + // } + // + return this.parseTransaction (response, currency); + } + + async fetchTradingFees (params = {}) { + // getExchangeInfo + const response = await this.publicGetGetExchangeInfo (params); + const tradingFees = this.safeValue (response, 'spotFees', []); + const taker = {}; + const maker = {}; + for (let i = 0; i < tradingFees.length; i++) { + const tradingFee = tradingFees[i]; + if (this.safeString (tradingFee, 'tier') !== undefined) { + taker[tradingFee['tier']] = this.safeFloat (tradingFee, 'taker'); + maker[tradingFee['tier']] = this.safeFloat (tradingFee, 'maker'); + } + } + return { + 'info': tradingFees, + 'tierBased': true, + 'maker': maker, + 'taker': taker, + }; + } + + async fetchTradingLimits (symbols = undefined, params = {}) { + await this.loadMarkets (); + // getExchangeInfo + const response = await this.publicGetGetExchangeInfo (params); + const tradingLimits = this.safeValue (response, 'tradingLimits', []); + // To-do parsing response when available + return { + 'info': tradingLimits, + 'limits': { + 'amount': { + 'min': undefined, + 'max': undefined, + }, + 'price': { + 'min': undefined, + 'max': undefined, + }, + 'cost': { + 'min': undefined, + 'max': undefined, + }, + }, + }; + } + + async fetchFundingLimits (params = {}) { + // getExchangeInfo + const response = await this.publicGetGetExchangeInfo (params); + const withdrawLimits = this.safeValue (response, 'withdrawLimits', []); + // TO-DO parse response when available + return { + 'info': withdrawLimits, + 'withdraw': undefined, + }; + } + + parseOrder (order, market = undefined) { + // + // createOrder, editOrder, cancelOrder + // + // { + // "status":"sent", + // "id":385617863, + // "instrumentId":53, + // "clOrdId":"1613037510849637345", + // "userId":3583, + // "price":2000, + // "quantity":200, + // "ordType":2 + // } + // + // fetchOrders, fetchOrder + // + // { + // "orderId":385613629, + // "orderUpdateSeq":1, + // "clOrdId":"1613037448945798198", + // "symbol":"ETH/USDC", + // "instrumentId":53, + // "side":"1", + // "userId":3583, + // "account":3583, + // "execType":"4", + // "ordType":"2", + // "ordStatus":"C", + // "timeInForce":"3", + // "timeStamp":"20210211-09:57:28.944", + // "execId":0, + // "targetStrategy":0, + // "isHidden":false, + // "isReduceOnly":false, + // "isLiquidation":false, + // "fee":0, + // "feeTotal":0, + // "fee_scale":0, + // "feeInstrumentId":0, + // "price":999, + // "price_scale":2, + // "quantity":10000000, + // "quantity_scale":6, + // "leavesQty":10000000, + // "leavesQty_scale":6, + // "cumQty":0, + // "cumQty_scale":0, + // "lastPx":0, + // "lastPx_scale":2, + // "avgPx":0, + // "avgPx_scale":0, + // "lastQty":0, + // "lastQty_scale":6 + // } + // + let id = this.safeString2 (order, 'orderId', 'id'); + id = this.safeString (order, 'origOrderId', id); + const clientOrderId = this.safeString (order, 'clOrdId'); + const type = this.parseOrderType (this.safeString (order, 'ordType')); + const side = this.parseOrderSide (this.safeString (order, 'side')); + const status = this.parseOrderStatus (this.safeString (order, 'ordStatus')); + const marketId = this.safeString (order, 'instrumentId'); + const symbol = this.safeSymbol (marketId, market); + const timestamp = this.toMilliseconds (this.safeString (order, 'timeStamp')); + const lastTradeTimestamp = undefined; + let price = this.safeInteger (order, 'price'); + if (price === 0) { + price = undefined; + } + const priceScale = this.safeInteger (order, 'price_scale'); + price = this.convertFromScale (price, priceScale); + let amount = this.safeInteger (order, 'quantity'); + if (amount === 0) { + amount = undefined; + } + const amountScale = this.safeInteger (order, 'quantity_scale'); + amount = this.convertFromScale (amount, amountScale); + let filled = this.safeInteger (order, 'cumQty'); + const filledScale = this.safeInteger (order, 'cumQty_scale'); + filled = this.convertFromScale (filled, filledScale); + let remaining = this.safeInteger (order, 'leavesQty'); + const remainingScale = this.safeInteger (order, 'leavesQty_scale'); + remaining = this.convertFromScale (remaining, remainingScale); + if (remaining <= 0) { + if ((filled !== undefined) && (amount !== undefined) && (filled < amount)) { + remaining = undefined; + } + } + if ((remaining === undefined) && (amount !== undefined) && (filled !== undefined)) { + remaining = Math.max (amount - filled, 0); + } + let average = this.safeInteger (order, 'price', 0); + if (average === 0) { + average = undefined; + } + const averageScale = this.safeInteger (order, 'price_scale'); + average = this.convertFromScale (average, averageScale); + let cost = undefined; + if (filled !== 0) { + if (average > 0) { + cost = average * filled; + } else if (price > 0) { + cost = price * filled; + } + } + let fee = undefined; + const currencyId = this.safeInteger (order, 'feeInstrumentId'); + const feeCurrencyCode = this.safeCurrencyCode (currencyId); + let feeCost = this.safeInteger (order, 'feeTotal'); + const feeScale = this.safeInteger (order, 'fee_scale'); + if (feeCost !== undefined) { + feeCost = -feeCost; + feeCost = this.convertFromScale (feeCost, feeScale); + } + if (feeCost !== undefined) { + fee = { + 'currency': feeCurrencyCode, + 'cost': feeCost, + 'rate': undefined, + }; + } + let timeInForce = this.parseTimeInForce (this.safeString (order, 'timeInForce')); + if (timeInForce === '0') { + timeInForce = undefined; + } + const stopPriceScale = this.safeInteger (order, 'stopPx_scale', 0); + const stopPrice = this.convertFromScale (this.safeInteger (order, 'stopPx'), stopPriceScale); + return { + 'info': order, + 'id': id, + 'clientOrderId': clientOrderId, + 'timestamp': timestamp, + 'datetime': this.iso8601 (timestamp), + 'lastTradeTimestamp': lastTradeTimestamp, + 'symbol': symbol, + 'type': type, + 'timeInForce': timeInForce, + 'postOnly': undefined, + 'side': side, + 'price': price, + 'stopPrice': stopPrice, + 'amount': amount, + 'cost': cost, + 'average': average, + 'filled': filled, + 'remaining': remaining, + 'status': status, + 'fee': fee, + 'trades': undefined, + }; + } + + parseOrderStatus (status) { + const statuses = { + '0': 'open', + '1': 'open', // 'partially filled', + '2': 'closed', // 'filled', + '3': 'open', // 'done for day', + '4': 'canceled', + '5': 'canceled', // 'replaced', + '6': 'canceling', // 'pending cancel', + '7': 'canceled', // 'stopped', + '8': 'rejected', // 'rejected', + '9': 'canceled', // 'suspended', + 'A': 'open', // 'pending new', + 'B': 'open', // 'calculated', + 'C': 'expired', + 'D': 'open', // 'accepted for bidding', + 'E': 'canceling', // 'pending replace', + 'F': 'open', // 'partial fill or fill', + }; + return this.safeString (statuses, status, status); + } + + parseOrderSide (side) { + const sides = { + '1': 'buy', + '2': 'sell', + }; + return this.safeString (sides, side, side); + } + + parseOrderType (type) { + const types = { + '1': 'market', + '2': 'limit', + '3': 'stop', + '4': 'stop limit', + }; + return this.safeString (types, type, type); + } + + parseTimeInForce (timeInForce) { + const timeInForces = { + '1': 'GTC', // Good Till Canceled + '3': 'IOC', // Immediate or Cancel + '4': 'FOK', // Fill or Kill + '5': 'GTX', // Good Till Crossing (GTX) + '6': 'GTD', // Good Till Date + }; + return this.safeString (timeInForces, timeInForce, timeInForce); + } + + toMilliseconds (dateString) { + if (dateString === undefined) { + return dateString; + } + // '20200328-10:31:01.575' -> '2020-03-28 12:42:48.000' + const splits = dateString.split ('-'); + const partOne = this.safeString (splits, 0); + const partTwo = this.safeString (splits, 1); + if (partOne === undefined || partTwo === undefined) { + return undefined; + } + if (partOne.length !== 8) { + return undefined; + } + const date = partOne.slice (0, 4) + '-' + partOne.slice (4, 6) + '-' + partOne.slice (6, 8); + return this.parse8601 (date + ' ' + partTwo); + } + + convertFromScale (number, scale) { + if ((number === undefined) || (scale === undefined)) { + return undefined; + } + return this.fromWei (number, scale); + } + + getScale (num) { + const s = this.numberToString (num); + return this.precisionFromString (s); + } + + convertToScale (number, scale) { + if ((number === undefined) || (scale === undefined)) { + return undefined; + } + return parseInt (this.toWei (number, scale)); + } + + nonce () { + return this.milliseconds (); + } + + handleErrors (code, reason, url, method, headers, body, response, requestHeaders, requestBody) { + if (response === undefined) { + return; // fallback to default error handler + } + const error = this.safeString (response, 'error'); + if (error !== undefined) { + const feedback = this.id + ' ' + body; + this.throwExactlyMatchedException (this.exceptions, error, feedback); + this.throwBroadlyMatchedException (this.exceptions, body, feedback); + throw new ExchangeError (this.id + ' ' + body); + } + } + + sign (path, api = 'public', method = 'GET', params = {}, headers = undefined, body = undefined) { + let url = this.implodeParams (path, params); + let query = this.omit (params, this.extractParams (path)); + if (api === 'public') { + if (Object.keys (query).length) { + url += '?' + this.urlencode (query); + } + } else if (api === 'private') { + // special case for getUserHistory + const format = this.safeValue (params, 'format'); + const type = this.safeValue (params, 'type'); + const extension = {}; + if (format !== undefined) { + extension['format'] = format; + } + if (type !== undefined) { + extension['type'] = type; + } + if (Object.keys (extension).length) { + url += '?' + this.urlencode (extension); + } + params = this.omit (params, [ 'format', 'type' ]); + this.checkRequiredCredentials (); + const nonce = this.nonce (); + query = this.extend (query, { + 'userId': this.uid, + 'nonce': nonce, + }); + params['nonce'] = this.nonce (); + body = this.json (query); + const signature = this.hmac (this.encode (body), this.encode (this.secret), 'sha384'); + headers = { + 'Content-Type': 'application/json', + 'requestToken': this.apiKey, + 'signature': signature, + }; + } + url = this.urls['api'][api] + '/' + url; + return { 'url': url, 'method': method, 'body': body, 'headers': headers }; + } +}; diff --git a/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/eterbase.js b/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/eterbase.js index 56d975d44..40d2893d3 100644 --- a/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/eterbase.js +++ b/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/eterbase.js @@ -605,7 +605,7 @@ module.exports = class eterbase extends Exchange { request['start'] = now - duration * limit * 1000; request['end'] = now; } else { - throw new ArgumentsRequired (this.id + ' fetchOHLCV requires a since argument, or a limit argument, or both'); + throw new ArgumentsRequired (this.id + ' fetchOHLCV() requires a since argument, or a limit argument, or both'); } await this.loadMarkets (); const market = this.market (symbol); @@ -807,6 +807,7 @@ module.exports = class eterbase extends Exchange { } const timeInForce = this.safeString (order, 'timeInForce'); const stopPrice = this.safeFloat (order, 'stopPrice'); + const postOnly = this.safeValue (order, 'postOnly'); return { 'info': order, 'id': id, @@ -816,8 +817,9 @@ module.exports = class eterbase extends Exchange { 'lastTradeTimestamp': undefined, 'symbol': symbol, 'type': type, - 'side': side, 'timeInForce': timeInForce, + 'postOnly': postOnly, + 'side': side, 'price': price, 'stopPrice': stopPrice, 'amount': amount, diff --git a/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/exmo.js b/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/exmo.js index 52c2ba65e..c9e19479d 100644 --- a/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/exmo.js +++ b/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/exmo.js @@ -702,7 +702,7 @@ module.exports = class exmo extends Exchange { const now = this.milliseconds (); if (since === undefined) { if (limit === undefined) { - throw new ArgumentsRequired (this.id + ' fetchOHLCV requires a since argument or a limit argument'); + throw new ArgumentsRequired (this.id + ' fetchOHLCV() requires a since argument or a limit argument'); } else { if (limit > maxLimit) { throw new BadRequest (this.id + ' fetchOHLCV will serve ' + maxLimit.toString () + ' candles at most'); @@ -1318,6 +1318,7 @@ module.exports = class exmo extends Exchange { 'symbol': symbol, 'type': 'limit', 'timeInForce': undefined, + 'postOnly': undefined, 'side': side, 'price': price, 'stopPrice': undefined, @@ -1436,12 +1437,21 @@ module.exports = class exmo extends Exchange { const type = this.safeString (transaction, 'type'); const currencyId = this.safeString (transaction, 'curr'); const code = this.safeCurrencyCode (currencyId, currency); - let address = this.safeString (transaction, 'account'); - if (address !== undefined) { - const parts = address.split (':'); - const numParts = parts.length; - if (numParts === 2) { - address = parts[1].replace (' ', ''); + let address = undefined; + const tag = undefined; + let comment = undefined; + const account = this.safeString (transaction, 'account'); + if (type === 'deposit') { + comment = account; + } else if (type === 'withdrawal') { + address = account; + if (address !== undefined) { + const parts = address.split (':'); + const numParts = parts.length; + if (numParts === 2) { + address = this.safeString (parts, 1); + address = address.replace (' ', ''); + } } } let fee = undefined; @@ -1469,16 +1479,21 @@ module.exports = class exmo extends Exchange { return { 'info': transaction, 'id': undefined, + 'timestamp': timestamp, + 'datetime': this.iso8601 (timestamp), 'currency': code, 'amount': amount, 'address': address, - 'tag': undefined, // refix it properly + 'addressTo': address, + 'addressFrom': undefined, + 'tag': tag, + 'tagTo': tag, + 'tagFrom': undefined, 'status': status, 'type': type, 'updated': undefined, + 'comment': comment, 'txid': txid, - 'timestamp': timestamp, - 'datetime': this.iso8601 (timestamp), 'fee': fee, }; } diff --git a/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/exx.js b/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/exx.js index 925d4a2f2..c4c12d03f 100644 --- a/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/exx.js +++ b/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/exx.js @@ -326,6 +326,7 @@ module.exports = class exx extends Exchange { 'symbol': symbol, 'type': 'limit', 'timeInForce': undefined, + 'postOnly': undefined, 'side': order['type'], 'price': price, 'stopPrice': undefined, @@ -387,7 +388,7 @@ module.exports = class exx extends Exchange { async fetchOpenOrders (symbol = undefined, since = undefined, limit = undefined, params = {}) { await this.loadMarkets (); if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' fetchOpenOrders requires a symbol argument'); + throw new ArgumentsRequired (this.id + ' fetchOpenOrders() requires a symbol argument'); } const market = this.market (symbol); const request = { diff --git a/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/fcoin.js b/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/fcoin.js index 1bdb5920d..2d1c845ab 100644 --- a/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/fcoin.js +++ b/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/fcoin.js @@ -592,6 +592,7 @@ module.exports = class fcoin extends Exchange { 'symbol': symbol, 'type': orderType, 'timeInForce': undefined, + 'postOnly': undefined, 'side': side, 'price': price, 'stopPrice': undefined, diff --git a/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/flowbtc.js b/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/flowbtc.js index d38ebfea9..12646489b 100644 --- a/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/flowbtc.js +++ b/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/flowbtc.js @@ -246,7 +246,7 @@ module.exports = class flowbtc extends Exchange { }; return await this.privatePostCancelOrder (this.extend (request, params)); } - throw new ExchangeError (this.id + ' requires `ins` symbol parameter for cancelling an order'); + throw new ExchangeError (this.id + ' cancelOrder() requires an `ins` symbol parameter for cancelling an order'); } sign (path, api = 'public', method = 'GET', params = {}, headers = undefined, body = undefined) { diff --git a/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/ftx.js b/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/ftx.js index 8e3992ac5..18b572cc6 100644 --- a/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/ftx.js +++ b/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/ftx.js @@ -4,7 +4,7 @@ const Exchange = require ('./base/Exchange'); const { TICK_SIZE } = require ('./base/functions/number'); -const { ExchangeError, InvalidOrder, BadRequest, InsufficientFunds, OrderNotFound, AuthenticationError } = require ('./base/errors'); +const { ExchangeError, InvalidOrder, BadRequest, InsufficientFunds, OrderNotFound, AuthenticationError, RateLimitExceeded, ExchangeNotAvailable, CancelPending } = require ('./base/errors'); // --------------------------------------------------------------------------- @@ -14,7 +14,7 @@ module.exports = class ftx extends Exchange { 'id': 'ftx', 'name': 'FTX', 'countries': [ 'HK' ], - 'rateLimit': 100, + 'rateLimit': 50, 'certified': true, 'pro': true, 'hostname': 'ftx.com', // or ftx.us @@ -99,9 +99,12 @@ module.exports = class ftx extends Exchange { 'wallet/coins', 'wallet/balances', 'wallet/all_balances', - 'wallet/deposit_address/{coin}', + 'wallet/deposit_address/{coin}', // ?method={method} 'wallet/deposits', 'wallet/withdrawals', + 'wallet/withdrawal_fee', + 'wallet/airdrops', + 'wallet/saved_addresses', 'orders', // ?market={market} 'orders/history', // ?market={market} 'orders/{order_id}', @@ -109,6 +112,14 @@ module.exports = class ftx extends Exchange { 'conditional_orders', // ?market={market} 'conditional_orders/{conditional_order_id}/triggers', 'conditional_orders/history', // ?market={market} + 'spot_margin/borrow_rates', + 'spot_margin/lending_rates', + 'spot_margin/borrow_summary', + 'spot_margin/market_info', // ?market={market} + 'spot_margin/borrow_history', + 'spot_margin/lending_history', + 'spot_margin/offers', + 'spot_margin/lending_info', 'fills', // ?market={market} 'funding_payments', // leverage tokens @@ -127,15 +138,23 @@ module.exports = class ftx extends Exchange { 'options/account_info', 'options/positions', 'options/fills', + // staking + 'staking/stakes', + 'staking/unstake_requests', + 'staking/balances', + 'staking/staking_rewards', ], 'post': [ 'account/leverage', 'wallet/withdrawals', + 'wallet/saved_addresses', 'orders', 'conditional_orders', 'orders/{order_id}/modify', 'orders/by_client_id/{client_order_id}/modify', 'conditional_orders/{order_id}/modify', + // spot margin + 'spot_margin/offers', // leverage tokens 'lt/{token_name}/create', 'lt/{token_name}/redeem', @@ -150,8 +169,12 @@ module.exports = class ftx extends Exchange { 'options/requests', 'options/requests/{request_id}/quotes', 'options/quotes/{quote_id}/accept', + // staking + 'staking/unstake_requests', + 'srm_stakes/stakes', ], 'delete': [ + 'wallet/saved_addresses/{saved_address_id}', 'orders/{order_id}', 'orders/by_client_id/{client_order_id}', 'orders', @@ -161,6 +184,8 @@ module.exports = class ftx extends Exchange { // options 'options/requests/{request_id}', 'options/quotes/{quote_id}', + // staking + 'staking/unstake_requests/{request_id}', ], }, }, @@ -195,6 +220,8 @@ module.exports = class ftx extends Exchange { }, 'exceptions': { 'exact': { + 'Please slow down': RateLimitExceeded, // {"error":"Please slow down","success":false} + 'Size too small for provide': InvalidOrder, // {"error":"Size too small for provide","success":false} 'Not logged in': AuthenticationError, // {"error":"Not logged in","success":false} 'Not enough balances': InsufficientFunds, // {"error":"Not enough balances","success":false} 'InvalidPrice': InvalidOrder, // {"error":"Invalid price","success":false} @@ -202,13 +229,20 @@ module.exports = class ftx extends Exchange { 'Missing parameter price': InvalidOrder, // {"error":"Missing parameter price","success":false} 'Order not found': OrderNotFound, // {"error":"Order not found","success":false} 'Order already closed': InvalidOrder, // {"error":"Order already closed","success":false} + 'Trigger price too high': InvalidOrder, // {"error":"Trigger price too high","success":false} + 'Trigger price too low': InvalidOrder, // {"error":"Trigger price too low","success":false} + 'Order already queued for cancellation': CancelPending, // {"error":"Order already queued for cancellation","success":false} }, 'broad': { + 'Account does not have enough margin for order': InsufficientFunds, 'Invalid parameter': BadRequest, // {"error":"Invalid parameter start_time","success":false} 'The requested URL was not found on the server': BadRequest, 'No such coin': BadRequest, 'No such market': BadRequest, - 'An unexpected error occurred': ExchangeError, // {"error":"An unexpected error occurred, please try again later (58BC21C795).","success":false} + 'Do not send more than': RateLimitExceeded, + 'An unexpected error occurred': ExchangeNotAvailable, // {"error":"An unexpected error occurred, please try again later (58BC21C795).","success":false} + 'Please retry request': ExchangeNotAvailable, // {"error":"Please retry request","success":false} + 'Please try again': ExchangeNotAvailable, // {"error":"Please try again","success":false} }, }, 'precisionMode': TICK_SIZE, @@ -338,7 +372,7 @@ module.exports = class ftx extends Exchange { 'amount': sizeIncrement, 'price': priceIncrement, }; - const entry = { + result.push ({ 'id': id, 'symbol': symbol, 'base': base, @@ -365,8 +399,7 @@ module.exports = class ftx extends Exchange { }, }, 'info': market, - }; - result.push (entry); + }); } return result; } @@ -665,22 +698,39 @@ module.exports = class ftx extends Exchange { // "type": "order" // } // + // { + // "baseCurrency": "BTC", + // "fee": 0, + // "feeCurrency": "USD", + // "feeRate": 0, + // "future": null, + // "id": 664079556, + // "liquidity": "taker", + // "market": null, + // "orderId": null, + // "price": 34830.61359, + // "quoteCurrency": "USD", + // "side": "sell", + // "size": 0.0005996, + // "time": "2021-01-15T16:05:29.246135+00:00", + // "tradeId": null, + // "type": "otc" + // } + // const id = this.safeString (trade, 'id'); const takerOrMaker = this.safeString (trade, 'liquidity'); const marketId = this.safeString (trade, 'market'); let symbol = undefined; - if (marketId !== undefined) { - if (marketId in this.markets_by_id) { - market = this.markets_by_id[marketId]; - symbol = market['symbol']; + if (marketId in this.markets_by_id) { + market = this.markets_by_id[marketId]; + symbol = market['symbol']; + } else { + const base = this.safeCurrencyCode (this.safeString (trade, 'baseCurrency')); + const quote = this.safeCurrencyCode (this.safeString (trade, 'quoteCurrency')); + if ((base !== undefined) && (quote !== undefined)) { + symbol = base + '/' + quote; } else { - const base = this.safeCurrencyCode (this.safeString (trade, 'baseCurrency')); - const quote = this.safeCurrencyCode (this.safeString (trade, 'quoteCurrency')); - if ((base !== undefined) && (quote !== undefined)) { - symbol = base + '/' + quote; - } else { - symbol = marketId; - } + symbol = marketId; } } const timestamp = this.parse8601 (this.safeString (trade, 'time')); @@ -998,6 +1048,7 @@ module.exports = class ftx extends Exchange { const lastTradeTimestamp = this.parse8601 (this.safeString (order, 'triggeredAt')); const clientOrderId = this.safeString (order, 'clientId'); const stopPrice = this.safeFloat (order, 'triggerPrice'); + const postOnly = this.safeValue (order, 'postOnly'); return { 'info': order, 'id': id, @@ -1008,6 +1059,7 @@ module.exports = class ftx extends Exchange { 'symbol': symbol, 'type': type, 'timeInForce': undefined, + 'postOnly': postOnly, 'side': side, 'price': price, 'stopPrice': stopPrice, @@ -1145,12 +1197,12 @@ module.exports = class ftx extends Exchange { } } else { if (clientOrderId === undefined) { + method = 'privatePostOrdersOrderIdModify'; + request['order_id'] = id; + } else { method = 'privatePostOrdersByClientIdClientOrderIdModify'; request['client_order_id'] = clientOrderId; // request['clientId'] = clientOrderId; - } else { - method = 'privatePostOrdersOrderIdModify'; - request['order_id'] = id; } if (price !== undefined) { request['price'] = parseFloat (this.priceToPrecision (symbol, price)); @@ -1216,9 +1268,7 @@ module.exports = class ftx extends Exchange { async cancelOrder (id, symbol = undefined, params = {}) { await this.loadMarkets (); - const request = { - 'order_id': parseInt (id), - }; + const request = {}; // support for canceling conditional orders // https://github.com/ccxt/ccxt/issues/6669 const options = this.safeValue (this.options, 'cancelOrder', {}); @@ -1251,8 +1301,8 @@ module.exports = class ftx extends Exchange { await this.loadMarkets (); const request = { // 'market': market['id'], // optional - 'conditionalOrdersOnly': false, // cancel conditional orders only - 'limitOrdersOnly': false, // cancel existing limit orders (non-conditional orders) only + // 'conditionalOrdersOnly': false, // cancel conditional orders only + // 'limitOrdersOnly': false, // cancel existing limit orders (non-conditional orders) only }; const marketId = this.getMarketId (symbol, 'market', params); if (marketId !== undefined) { @@ -1421,6 +1471,7 @@ module.exports = class ftx extends Exchange { } if (since !== undefined) { request['start_time'] = parseInt (since / 1000); + request['end_time'] = this.seconds (); } const response = await this.privateGetFills (this.extend (request, params)); // @@ -1610,6 +1661,15 @@ module.exports = class ftx extends Exchange { // "txid": "0x8078356ae4b06a036d64747546c274af19581f1c78c510b60505798a7ffcaf1" // } // + // { + // "coin": 'BTC', + // "id": 1969806, + // "notes": 'Transfer to Dd6gi7m2Eg4zzBbPAxuwfEaHs6tYvyUX5hbPpsTcNPXo', + // "size": 0.003, + // "status": 'complete', + // "time": '2021-02-03T20:28:54.918146+00:00' + // } + // const code = this.safeCurrencyCode (this.safeString (transaction, 'coin')); const id = this.safeString (transaction, 'id'); const amount = this.safeFloat (transaction, 'size'); @@ -1622,8 +1682,14 @@ module.exports = class ftx extends Exchange { tag = this.safeString (address, 'tag'); address = this.safeString (address, 'address'); } + if (address === undefined) { + // parse address from internal transfer + const notes = this.safeString (transaction, 'notes'); + if (notes !== undefined) { + address = notes.slice (12); + } + } const fee = this.safeFloat (transaction, 'fee'); - const type = ('destinationName' in transaction) ? 'withdrawal' : 'deposit'; return { 'info': transaction, 'id': id, @@ -1636,7 +1702,7 @@ module.exports = class ftx extends Exchange { 'tagFrom': undefined, 'tag': tag, 'tagTo': tag, - 'type': type, + 'type': undefined, 'amount': amount, 'currency': code, 'status': status, @@ -1674,7 +1740,7 @@ module.exports = class ftx extends Exchange { if (code !== undefined) { currency = this.currency (code); } - return this.parseTransactions (result, currency, since, limit); + return this.parseTransactions (result, currency, since, limit, { 'type': 'deposit' }); } async fetchWithdrawals (code = undefined, since = undefined, limit = undefined, params = {}) { @@ -1701,7 +1767,7 @@ module.exports = class ftx extends Exchange { if (code !== undefined) { currency = this.currency (code); } - return this.parseTransactions (result, currency, since, limit); + return this.parseTransactions (result, currency, since, limit, { 'type': 'withdrawal' }); } sign (path, api = 'public', method = 'GET', params = {}, headers = undefined, body = undefined) { diff --git a/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/gateio.js b/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/gateio.js index d03f929d8..f0835c774 100644 --- a/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/gateio.js +++ b/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/gateio.js @@ -167,6 +167,7 @@ module.exports = class gateio extends Exchange { 'BOX': 'DefiBox', 'BTCBEAR': 'BEAR', 'BTCBULL': 'BULL', + 'SBTC': 'Super Bitcoin', 'TNC': 'Trinity Network Credit', }, }); @@ -690,6 +691,7 @@ module.exports = class gateio extends Exchange { 'symbol': symbol, 'type': 'limit', 'timeInForce': undefined, + 'postOnly': undefined, 'side': side, 'price': price, 'stopPrice': undefined, @@ -730,7 +732,7 @@ module.exports = class gateio extends Exchange { async cancelOrder (id, symbol = undefined, params = {}) { if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' cancelOrder requires symbol argument'); + throw new ArgumentsRequired (this.id + ' cancelOrder() requires symbol argument'); } await this.loadMarkets (); const request = { @@ -753,13 +755,13 @@ module.exports = class gateio extends Exchange { if ((address !== undefined) && (address.indexOf ('address') >= 0)) { throw new InvalidAddress (this.id + ' queryDepositAddress ' + address); } - if (code === 'XRP') { + if ((code === 'XRP') || (code === 'HBAR') || (code === 'STEEM') || (code === 'XLM') || (code === 'EOS')) { const parts = address.split (' '); address = parts[0]; tag = parts[1]; } return { - 'currency': currency, + 'currency': code, 'address': address, 'tag': tag, 'info': response, @@ -786,7 +788,7 @@ module.exports = class gateio extends Exchange { async fetchOrderTrades (id, symbol = undefined, since = undefined, limit = undefined, params = {}) { if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' fetchMyTrades requires a symbol argument'); + throw new ArgumentsRequired (this.id + ' fetchOrderTrades() requires a symbol argument'); } await this.loadMarkets (); const market = this.market (symbol); @@ -800,7 +802,7 @@ module.exports = class gateio extends Exchange { async fetchMyTrades (symbol = undefined, since = undefined, limit = undefined, params = {}) { if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' fetchMyTrades requires symbol argument'); + throw new ArgumentsRequired (this.id + ' fetchMyTrades() requires symbol argument'); } await this.loadMarkets (); const market = this.market (symbol); @@ -882,21 +884,21 @@ module.exports = class gateio extends Exchange { // withdrawal // // { - // 'id': 'w5864259', - // 'currency': 'ETH', - // 'address': '0x72632f462....', - // 'amount': '0.4947', - // 'txid': '0x111167d120f736....', - // 'timestamp': '1553123688', - // 'status': 'DONE', - // 'type': 'withdrawal' - // } + // "id": "w6754336", + // "fee": "0.1", + // "txid": "zzyy", + // "amount": "1", + // "status": "DONE", + // "address": "tz11234", + // "currency": "XTZ", + // "timestamp": "1561030206" + // } // const currencyId = this.safeString (transaction, 'currency'); const code = this.safeCurrencyCode (currencyId, currency); const id = this.safeString (transaction, 'id'); const txid = this.safeString (transaction, 'txid'); - const amount = this.safeFloat (transaction, 'amount'); + let amount = this.safeFloat (transaction, 'amount'); let address = this.safeString (transaction, 'address'); if (address === 'false') { address = undefined; @@ -904,6 +906,17 @@ module.exports = class gateio extends Exchange { const timestamp = this.safeTimestamp (transaction, 'timestamp'); const status = this.parseTransactionStatus (this.safeString (transaction, 'status')); const type = this.parseTransactionType (id[0]); + const feeCost = this.safeFloat (transaction, 'fee'); + let fee = undefined; + if (feeCost !== undefined) { + fee = { + 'currency': code, + 'cost': feeCost, + }; + if (amount !== undefined) { + amount = amount - feeCost; + } + } return { 'info': transaction, 'id': id, @@ -916,7 +929,7 @@ module.exports = class gateio extends Exchange { 'type': type, 'timestamp': timestamp, 'datetime': this.iso8601 (timestamp), - 'fee': undefined, + 'fee': fee, }; } diff --git a/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/gemini.js b/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/gemini.js index a0894c364..6f28ef220 100644 --- a/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/gemini.js +++ b/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/gemini.js @@ -669,6 +669,7 @@ module.exports = class gemini extends Exchange { 'symbol': symbol, 'type': type, 'timeInForce': undefined, + 'postOnly': undefined, 'side': side, 'price': price, 'stopPrice': undefined, @@ -732,7 +733,7 @@ module.exports = class gemini extends Exchange { async fetchMyTrades (symbol = undefined, since = undefined, limit = undefined, params = {}) { if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' fetchMyTrades requires a symbol argument'); + throw new ArgumentsRequired (this.id + ' fetchMyTrades() requires a symbol argument'); } await this.loadMarkets (); const market = this.market (symbol); diff --git a/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/gopax.js b/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/gopax.js new file mode 100644 index 000000000..e3150163a --- /dev/null +++ b/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/gopax.js @@ -0,0 +1,1347 @@ +'use strict'; + +// --------------------------------------------------------------------------- + +const Exchange = require ('./base/Exchange'); +const { ExchangeError, InvalidOrder, AuthenticationError, InsufficientFunds, BadSymbol, OrderNotFound, InvalidAddress, BadRequest } = require ('./base/errors'); +const { TRUNCATE, ROUND, TICK_SIZE } = require ('./base/functions/number'); + +// --------------------------------------------------------------------------- + +module.exports = class gopax extends Exchange { + describe () { + return this.deepExtend (super.describe (), { + 'id': 'gopax', + 'name': 'GOPAX', + 'countries': [ 'KR' ], // South Korea + 'version': 'v1', + 'rateLimit': 50, + 'hostname': 'gopax.co.kr', // or 'gopax.com' + 'certified': true, + 'pro': true, + 'has': { + 'cancelOrder': true, + 'createMarketOrder': true, + 'createOrder': true, + 'fetchBalance': true, + 'fetchCurrencies': true, + 'fetchDepositAddress': 'emulated', + 'fetchDepositAddresses': true, + 'fetchMarkets': true, + 'fetchMyTrades': true, + 'fetchOHLCV': true, + 'fetchOpenOrders': true, + 'fetchOrder': true, + 'fetchOrderBook': true, + 'fetchOrders': true, + 'fetchTicker': true, + 'fetchTickers': true, + 'fetchTime': true, + 'fetchTrades': true, + 'fetchTransactions': true, + }, + 'timeframes': { + '1m': '1', + '5m': '5', + '30m': '30', + '1d': '1440', + }, + 'urls': { + 'logo': 'https://user-images.githubusercontent.com/1294454/102897212-ae8a5e00-4478-11eb-9bab-91507c643900.jpg', + 'api': { + 'public': 'https://api.{hostname}', // or 'https://api.gopax.co.kr' + 'private': 'https://api.{hostname}', + }, + 'www': 'https://www.gopax.co.kr', + 'doc': 'https://gopax.github.io/API/index.en.html', + 'fees': 'https://www.gopax.com/feeinfo', + }, + 'api': { + 'public': { + 'get': [ + 'notices', + 'assets', + 'price-tick-size', + 'trading-pairs', + 'trading-pairs/{tradingPair}/ticker', + 'trading-pairs/{tradingPair}/book', + 'trading-pairs/{tradingPair}/trades', + 'trading-pairs/{tradingPair}/stats', + 'trading-pairs/{tradingPair}/price-tick-size', + 'trading-pairs/stats', + 'trading-pairs/{tradingPair}/candles', + 'time', + ], + }, + 'private': { + 'get': [ + 'balances', + 'balances/{assetName}', + 'orders', + 'orders/{orderId}', + 'orders/clientOrderId/{clientOrderId}', + 'trades', + 'deposit-withdrawal-status', + 'crypto-deposit-addresses', + 'crypto-withdrawal-addresses', + ], + 'post': [ + 'orders', + ], + 'delete': [ + 'orders/{orderId}', + 'orders/clientOrderId/{clientOrderId}', + ], + }, + }, + 'fees': { + 'trading': { + 'percentage': true, + 'tierBased': false, + 'maker': 0.04 / 100, + 'taker': 0.04 / 100, + }, + }, + 'exceptions': { + 'broad': { + 'ERROR_INVALID_ORDER_TYPE': InvalidOrder, + 'ERROR_INVALID_AMOUNT': InvalidOrder, + 'ERROR_INVALID_TRADING_PAIR': BadSymbol, // Unlikely to be triggered, due to ccxt.gopax.js implementation + 'No such order ID': OrderNotFound, // {"errorMessage":"No such order ID","errorCode":202,"errorData":"Order server error: 202"} + // 'Not enough amount': InsufficientFunds, // {"errorMessage":"Not enough amount, try increasing your order amount","errorCode":10212,"errorData":{}} + 'Forbidden order type': InvalidOrder, + 'the client order ID will be reusable which order has already been completed or canceled': InvalidOrder, + 'ERROR_NO_SUCH_TRADING_PAIR': BadSymbol, // Unlikely to be triggered, due to ccxt.gopax.js implementation + 'ERROR_INVALID_ORDER_SIDE': InvalidOrder, + 'ERROR_NOT_HEDGE_TOKEN_USER': InvalidOrder, + 'ORDER_EVENT_ERROR_NOT_ALLOWED_BID_ORDER': InvalidOrder, // Triggered only when the exchange is locked + 'ORDER_EVENT_ERROR_INSUFFICIENT_BALANCE': InsufficientFunds, + 'Invalid option combination': InvalidOrder, + 'No such client order ID': OrderNotFound, + }, + 'exact': { + '100': BadSymbol, // Invalid asset name + '101': BadSymbol, // Invalid trading pair + '103': InvalidOrder, // Invalid order type + '104': BadSymbol, // Invalid trading pair + '105': BadSymbol, // Trading pair temporarily disabled + '106': BadSymbol, // Invalid asset name + '107': InvalidOrder, // Invalid order amount + '108': InvalidOrder, // Invalid order price + '111': InvalidOrder, // Invalid event type + '201': InsufficientFunds, // Not enough balance + '202': InvalidOrder, // Invalid order ID + '203': InvalidOrder, // Order amount X order price too large + '204': InvalidOrder, // Bid order temporarily unavailable + '205': InvalidOrder, // Invalid side + '206': InvalidOrder, // Invalid order option combination + '10004': AuthenticationError, // Not authorized + // '10004': ExchangeError, // API key not exist + // '10004': ExchangeError, // User KYC not approved + // '10004': ExchangeError, // User account is frozen + // '10004': ExchangeError, // User is under deactivation process + // '10004': ExchangeError, // 2FA is not enabled + // '10004': ExchangeError, // Invalid signature + '10041': BadRequest, // Invalid exchange + '10056': BadRequest, // No registered asset + '10057': BadSymbol, // No registered trading pair + '10059': BadSymbol, // Invalid trading pair + '10062': BadRequest, // Invalid chart interval + '10069': OrderNotFound, // {"errorMessage":"No such order ID: 73152094","errorCode":10069,"errorData":"73152094"} + '10155': AuthenticationError, // {"errorMessage":"Invalid API key","errorCode":10155} + '10166': BadRequest, // Invalid chart range + '10212': InvalidOrder, // {"errorMessage":"Not enough amount, try increasing your order amount","errorCode":10212,"errorData":{}} + '10221': OrderNotFound, // No such client order ID + '10222': InvalidOrder, // Client order ID being used + '10223': InvalidOrder, // Soon the client order ID will be reusable which order has already been completed or canceled + '10227': InvalidOrder, // Invalid client order ID format + '10319': BadRequest, // Pagination is required as you have too many orders + '10358': InvalidOrder, // Invalid order type + '10359': InvalidOrder, // Invalid order side + '10360': InvalidOrder, // Invalid order status + '10361': InvalidOrder, // Invalid order time in force + '10362': InvalidOrder, // Invalid order protection + '10363': InvalidOrder, // Invalid forced completion reason + }, + }, + 'options': { + 'createMarketBuyOrderRequiresPrice': true, + }, + }); + } + + async fetchTime (params = {}) { + const response = await this.publicGetTime (params); + // + // {"serverTime":1608327726656} + // + return this.safeInteger (response, 'serverTime'); + } + + async fetchMarkets (params = {}) { + const response = await this.publicGetTradingPairs (params); + // + // [ + // { + // "id":1, + // "name":"ETH-KRW", + // "baseAsset":"ETH", + // "quoteAsset":"KRW", + // "baseAssetScale":8, + // "quoteAssetScale":0, + // "priceMin":1, + // "restApiOrderAmountMin":{ + // "limitAsk":{"amount":10000,"unit":"KRW"}, + // "limitBid":{"amount":10000,"unit":"KRW"}, + // "marketAsk":{"amount":0.001,"unit":"ETH"}, + // "marketBid":{"amount":10000,"unit":"KRW"}, + // }, + // "makerFeePercent":0.2, + // "takerFeePercent":0.2, + // }, + // ] + // + const result = []; + for (let i = 0; i < response.length; i++) { + const market = response[i]; + const id = this.safeString (market, 'name'); + const numericId = this.safeInteger (market, 'id'); + const baseId = this.safeString (market, 'baseAsset'); + const quoteId = this.safeString (market, 'quoteAsset'); + const base = this.safeCurrencyCode (baseId); + const quote = this.safeCurrencyCode (quoteId); + const symbol = base + '/' + quote; + const precision = { + 'price': this.safeInteger (market, 'quoteAssetScale'), + 'amount': this.safeInteger (market, 'baseAssetScale'), + }; + const minimums = this.safeValue (market, 'restApiOrderAmountMin', {}); + const marketAsk = this.safeValue (minimums, 'marketAsk', {}); + const marketBid = this.safeValue (minimums, 'marketBid', {}); + const takerFeePercent = this.safeFloat (market, 'takerFeePercent'); + const makerFeePercent = this.safeFloat (market, 'makerFeePercent'); + const taker = parseFloat (this.decimalToPrecision (takerFeePercent / 100, ROUND, 0.00000001, TICK_SIZE)); + const maker = parseFloat (this.decimalToPrecision (makerFeePercent / 100, ROUND, 0.00000001, TICK_SIZE)); + result.push ({ + 'id': id, + 'info': market, + 'numericId': numericId, + 'symbol': symbol, + 'base': base, + 'quote': quote, + 'baseId': this.safeString (market, 'baseAsset'), + 'quoteId': this.safeString (market, 'quoteAsset'), + 'active': true, + 'taker': taker, + 'maker': maker, + 'precision': precision, + 'limits': { + 'amount': { + 'min': this.safeFloat (marketAsk, 'amount'), + 'max': undefined, + }, + 'price': { + 'min': this.safeFloat (market, 'priceMin'), + 'max': undefined, + }, + 'cost': { + 'min': this.safeFloat (marketBid, 'amount'), + 'max': undefined, + }, + }, + }); + } + return result; + } + + async fetchCurrencies (params = {}) { + const response = await this.publicGetAssets (params); + // + // [ + // { + // "id":"KRW", + // "name":"대한민국 원", + // "scale":0, + // "withdrawalFee":1000, + // "withdrawalAmountMin":5000 + // }, + // { + // "id":"ETH", + // "name":"이더리움", + // "scale":8, + // "withdrawalFee":0.03, + // "withdrawalAmountMin":0.015 + // }, + // ] + // + const result = {}; + for (let i = 0; i < response.length; i++) { + const currency = response[i]; + const id = this.safeString (currency, 'id'); + const code = this.safeCurrencyCode (id); + const name = this.safeString (currency, 'name'); + const fee = this.safeFloat (currency, 'withdrawalFee'); + const precision = this.safeFloat (currency, 'scale'); + result[code] = { + 'id': id, + 'info': currency, + 'code': code, + 'name': name, + 'active': true, + 'fee': fee, + 'precision': precision, + 'limits': { + 'amount': { + 'min': undefined, + 'max': undefined, + }, + 'price': { + 'min': undefined, + 'max': undefined, + }, + 'cost': { + 'min': undefined, + 'max': undefined, + }, + 'withdraw': { + 'min': this.safeFloat (currency, 'withdrawalAmountMin'), + 'max': undefined, + }, + }, + }; + } + return result; + } + + async fetchOrderBook (symbol, limit = undefined, params = {}) { + await this.loadMarkets (); + const market = this.market (symbol); + const request = { + 'tradingPair': market['id'], + // 'level': 3, // 1 best bidask, 2 top 50 bidasks, 3 all bidasks + }; + const response = await this.publicGetTradingPairsTradingPairBook (this.extend (request, params)); + // + // { + // "sequence":17691957, + // "bid":[ + // ["17690499",25019000,0.00008904,"1608326468921"], + // ["17691894",25010000,0.4295,"1608326499940"], + // ["17691895",25009000,0.2359,"1608326499953"], + // ], + // "ask":[ + // ["17689176",25024000,0.000098,"1608326442006"], + // ["17691351",25031000,0.206,"1608326490418"], + // ["17691571",25035000,0.3996,"1608326493742"], + // ] + // } + // + const nonce = this.safeInteger (response, 'sequence'); + const result = this.parseOrderBook (response, undefined, 'bid', 'ask', 1, 2); + result['nonce'] = nonce; + return result; + } + + parseTicker (ticker, market = undefined) { + // + // fetchTicker + // + // { + // "price":25087000, + // "ask":25107000, + // "askVolume":0.05837704, + // "bid":25087000, + // "bidVolume":0.00398628, + // "volume":350.09171591, + // "quoteVolume":8721016926.06529, + // "time":"2020-12-18T21:42:13.774Z", + // } + // + // fetchTickers + // + // { + // "name":"ETH-KRW", + // "open":690500, + // "high":719500, + // "low":681500, + // "close":709500, + // "volume":2784.6081544, + // "time":"2020-12-18T21:54:50.795Z" + // } + // + const marketId = this.safeString (ticker, 'name'); + const symbol = this.safeSymbol (marketId, market, '-'); + const timestamp = this.parse8601 (this.safeString (ticker, 'time')); + const open = this.safeFloat (ticker, 'open'); + const last = this.safeFloat2 (ticker, 'price', 'close'); + let change = undefined; + let percentage = undefined; + let average = undefined; + if ((last !== undefined) && (open !== undefined)) { + average = this.sum (last, open) / 2; + change = last - open; + if (open > 0) { + percentage = change / open * 100; + } + } + const baseVolume = this.safeFloat (ticker, 'volume'); + const quoteVolume = this.safeFloat (ticker, 'quoteVolume'); + const vwap = this.vwap (baseVolume, quoteVolume); + return { + 'symbol': symbol, + 'info': ticker, + 'timestamp': timestamp, + 'datetime': this.iso8601 (timestamp), + 'high': this.safeFloat (ticker, 'high'), + 'low': this.safeFloat (ticker, 'low'), + 'bid': this.safeFloat (ticker, 'bid'), + 'bidVolume': this.safeFloat (ticker, 'bidVolume'), + 'ask': this.safeFloat (ticker, 'ask'), + 'askVolume': this.safeFloat (ticker, 'askVolume'), + 'vwap': vwap, + 'open': open, + 'close': last, + 'last': last, + 'previousClose': undefined, + 'change': change, + 'percentage': percentage, + 'average': average, + 'baseVolume': baseVolume, + 'quoteVolume': quoteVolume, + }; + } + + async fetchTicker (symbol, params = {}) { + await this.loadMarkets (); + const market = this.market (symbol); + const request = { + 'tradingPair': market['id'], + }; + const response = await this.publicGetTradingPairsTradingPairTicker (this.extend (request, params)); + // + // { + // "price":25087000, + // "ask":25107000, + // "askVolume":0.05837704, + // "bid":25087000, + // "bidVolume":0.00398628, + // "volume":350.09171591, + // "quoteVolume":8721016926.06529, + // "time":"2020-12-18T21:42:13.774Z", + // } + // + return this.parseTicker (response, market); + } + + parseTickers (rawTickers, symbols = undefined) { + const tickers = []; + for (let i = 0; i < rawTickers.length; i++) { + tickers.push (this.parseTicker (rawTickers[i])); + } + return this.filterByArray (tickers, 'symbol', symbols); + } + + async fetchTickers (symbols = undefined, params = {}) { + await this.loadMarkets (); + const response = await this.publicGetTradingPairsStats (params); + // + // [ + // { + // "name":"ETH-KRW", + // "open":690500, + // "high":719500, + // "low":681500, + // "close":709500, + // "volume":2784.6081544, + // "time":"2020-12-18T21:54:50.795Z" + // } + // ] + // + return this.parseTickers (response, symbols); + } + + parsePublicTrade (trade, market = undefined) { + const timestamp = this.parse8601 (this.safeString (trade, 'time')); + const price = this.safeFloat (trade, 'price'); + const amount = this.safeFloat (trade, 'amount'); + let symbol = undefined; + if ('symbol' in market) { + symbol = this.safeString (market, 'symbol'); + } + return { + 'info': trade, + 'id': this.safeString (trade, 'id'), + 'timestamp': timestamp, + 'datetime': this.iso8601 (timestamp), + 'symbol': symbol, + 'order': undefined, // Not mandatory to specify + 'type': undefined, // Not mandatory to specify + 'side': this.safeString (trade, 'side'), + 'takerOrMaker': undefined, + 'price': price, + 'amount': amount, + 'cost': price * amount, + 'fee': undefined, + }; + } + + parsePrivateTrade (trade, market = undefined) { + const timestamp = this.parse8601 (this.safeString (trade, 'timestamp')); + const symbol = this.safeString (trade, 'tradingPairName').replace ('-', '/'); + const side = this.safeString (trade, 'side'); + const price = this.safeFloat (trade, 'price'); + const amount = this.safeFloat (trade, 'baseAmount'); + let feeCurrency = symbol.slice (0, 3); + if (side === 'sell') { + feeCurrency = symbol.slice (4); + } + const fee = { + 'cost': this.safeFloat (trade, 'fee'), + 'currency': feeCurrency, + 'rate': undefined, + }; + return { + 'info': trade, + 'id': this.safeString (trade, 'id'), + 'timestamp': timestamp, + 'datetime': this.iso8601 (timestamp), + 'symbol': symbol, + 'order': this.safeInteger (trade, 'orderId'), + 'type': undefined, + 'side': side, + 'takerOrMaker': this.safeString (trade, 'position'), + 'price': price, + 'amount': amount, + 'cost': price * amount, + 'fee': fee, + }; + } + + parseTrade (trade, market = undefined) { + // + // public fetchTrades + // + // { + // "time":"2020-12-19T12:17:43.000Z", + // "date":1608380263, + // "id":23903608, + // "price":25155000, + // "amount":0.0505, + // "side":"sell", + // } + // + // private fetchMyTrades + // + // { + // "id": 73953, // trading event ID + // "orderId": 453324, // order ID + // "baseAmount": 3, // traded base asset amount + // "quoteAmount": 3000000, // traded quote asset amount + // "fee": 0.0012, // fee + // "price": 1000000, // price + // "timestamp": "2020-09-25T04:06:30.000Z", // trading time + // "side": "buy", // buy, sell + // "tradingPairName": "ZEC-KRW", // order book + // "position": "maker" // maker, taker + // } + // + // { + // "tradeId": 74072, // trade ID + // "orderId": 453529, // order ID + // "side": 2, // 1(bid), 2(ask) + // "type": 1, // 1(limit), 2(market) + // "baseAmount": 0.01, // filled base asset amount (in ZEC for this case) + // "quoteAmount": 1, // filled quote asset amount (in KRW for this case) + // "fee": 0.0004, // fee + // "price": 100, // price + // "isSelfTrade": false, // whether both of matching orders are yours + // "occurredAt": 1603932107, // trade occurrence time + // "tradingPairName": "ZEC-KRW" // order book + // } + // + const id = this.safeString2 (trade, 'id', 'tradeId'); + const orderId = this.safeInteger (trade, 'orderId'); + let timestamp = this.parse8601 (this.safeString2 (trade, 'time', 'timestamp')); + timestamp = this.safeTimestamp (trade, 'occuredAt', timestamp); + const marketId = this.safeString (trade, 'tradingPairName'); + market = this.safeMarket (marketId, market, '-'); + const symbol = market['symbol']; + let side = this.safeString (trade, 'side'); + if (side === '1') { + side = 'buy'; + } else if (side === '2') { + side = 'sell'; + } + let type = this.safeString (trade, 'type'); + if (type === '1') { + type = 'limit'; + } else if (type === '2') { + type = 'market'; + } + const price = this.safeFloat (trade, 'price'); + const amount = this.safeFloat2 (trade, 'amount', 'baseAmount'); + let cost = this.safeFloat (trade, 'quoteAmount'); + if (cost === undefined) { + if ((price !== undefined) && (amount !== undefined)) { + cost = price * amount; + } + } + const feeCost = this.safeFloat (trade, 'fee'); + let fee = undefined; + if (feeCost !== undefined) { + fee = { + 'cost': feeCost, + 'currency': market['base'], + }; + } + const takerOrMaker = this.safeString (trade, 'position'); + return { + 'info': trade, + 'id': id, + 'timestamp': timestamp, + 'datetime': this.iso8601 (timestamp), + 'symbol': symbol, + 'order': orderId, + 'type': undefined, + 'side': side, + 'takerOrMaker': takerOrMaker, + 'price': price, + 'amount': amount, + 'cost': cost, + 'fee': fee, + }; + } + + async fetchTrades (symbol, since = undefined, limit = undefined, params = {}) { + await this.loadMarkets (); + const market = this.market (symbol); + const request = { + 'tradingPair': market['id'], + // 'limit': limit, + // 'pastmax': id, // read data older than this ID + // 'latestmin': id, // read data newer than this ID + // 'after': parseInt (since / 1000), + // 'before': this.seconds (), + }; + if (since !== undefined) { + request['after'] = parseInt (since / 1000); + } + if (limit !== undefined) { + request['limit'] = limit; + } + const response = await this.publicGetTradingPairsTradingPairTrades (this.extend (request, params)); + // + // [ + // {"time":"2020-12-19T12:17:43.000Z","date":1608380263,"id":23903608,"price":25155000,"amount":0.0505,"side":"sell"}, + // {"time":"2020-12-19T12:17:13.000Z","date":1608380233,"id":23903604,"price":25140000,"amount":0.019,"side":"sell"}, + // {"time":"2020-12-19T12:16:49.000Z","date":1608380209,"id":23903599,"price":25140000,"amount":0.0072,"side":"sell"}, + // ] + // + return this.parseTrades (response, market, since, limit); + } + + parseOHLCV (ohlcv, market = undefined) { + // + // [ + // 1606780800000, // timestamp + // 21293000, // low + // 21300000, // high + // 21294000, // open + // 21300000, // close + // 1.019126, // volume + // ] + // + return [ + this.safeInteger (ohlcv, 0), + this.safeFloat (ohlcv, 3), + this.safeFloat (ohlcv, 2), + this.safeFloat (ohlcv, 1), + this.safeFloat (ohlcv, 4), + this.safeFloat (ohlcv, 5), + ]; + } + + async fetchOHLCV (symbol, timeframe = '1m', since = undefined, limit = undefined, params = {}) { + await this.loadMarkets (); + const market = this.market (symbol); + limit = (limit === undefined) ? 1024 : limit; // default 1024 + const request = { + 'tradingPair': market['id'], + // 'start': since, + // 'end': this.milliseconds (), + 'interval': this.timeframes[timeframe], + }; + const duration = this.parseTimeframe (timeframe); + if (since === undefined) { + const end = this.milliseconds (); + request['end'] = end; + request['start'] = end - limit * duration * 1000; + } else { + request['start'] = since; + request['end'] = this.sum (since, limit * duration * 1000); + } + const response = await this.publicGetTradingPairsTradingPairCandles (this.extend (request, params)); + // + // [ + // [1606780800000,21293000,21300000,21294000,21300000,1.019126], + // [1606780860000,21237000,21293000,21293000,21263000,0.96800057], + // [1606780920000,21240000,21240000,21240000,21240000,0.11068715], + // ] + // + return this.parseOHLCVs (response, market, timeframe, since, limit); + } + + parseBalanceResponse (response) { + const result = { 'info': response }; + for (let i = 0; i < response.length; i++) { + const balance = response[i]; + const currencyId = this.safeString2 (balance, 'asset', 'isoAlpha3'); + const code = this.safeCurrencyCode (currencyId); + const hold = this.safeFloat (balance, 'hold'); + const pendingWithdrawal = this.safeFloat (balance, 'pendingWithdrawal'); + const account = this.account (); + account['free'] = this.safeFloat (balance, 'avail'); + account['used'] = this.sum (hold, pendingWithdrawal); + result[code] = account; + } + return this.parseBalance (result); + } + + async fetchBalance (params = {}) { + await this.loadMarkets (); + const response = await this.privateGetBalances (params); + // + // [ + // { + // "asset": "KRW", // asset name + // "avail": 1759466.76, // available amount to place order + // "hold": 16500, // outstanding amount on order books + // "pendingWithdrawal": 0, // amount being withdrawn + // "lastUpdatedAt": "1600684352032", // balance last update time + // }, + // ] + // + return this.parseBalanceResponse (response); + } + + parseOrderStatus (status) { + const statuses = { + 'placed': 'open', + 'cancelled': 'canceled', + 'completed': 'closed', + 'updated': 'open', + 'reserved': 'open', + }; + return this.safeString (statuses, status, status); + } + + parseOrder (order, market = undefined) { + // + // cancelOrder + // + // {} // empty object + // + // fetchOrder, fetchOrders, fetchOpenOrders, createOrder + // + // { + // "id": "453324", // order ID + // "clientOrderId": "zeckrw23456", // client order ID (showed only when it exists) + // "status": "updated", // placed, cancelled, completed, updated, reserved + // "forcedCompletionReason": undefined, // the reason in case it was canceled in the middle (protection or timeInForce) + // "tradingPairName": "ZEC-KRW", // order book + // "side": "buy", // buy, sell + // "type": "limit", // limit, market + // "price": 1000000, // price + // "stopPrice": undefined, // stop price (showed only for stop orders) + // "amount": 4, // initial amount + // "remaining": 1, // outstanding amount + // "protection": "yes", // whether protection is activated (yes or no) + // "timeInForce": "gtc", // limit order's time in force (gtc/po/ioc/fok) + // "createdAt": "2020-09-25T04:06:20.000Z", // order placement time + // "updatedAt": "2020-09-25T04:06:29.000Z", // order last update time + // "balanceChange": { + // "baseGross": 3, // base asset balance's gross change (in ZEC for this case) + // "baseFee": { + // "taking": 0, // base asset fee imposed as taker + // "making": -0.0012 // base asset fee imposed as maker + // }, + // "baseNet": 2.9988, // base asset balance's net change (in ZEC for this case) + // "quoteGross": -3000000, // quote asset balance's gross change (in KRW for + // "quoteFee": { + // "taking": 0, // quote asset fee imposed as taker + // "making": 0 // quote asset fee imposed as maker + // }, + // "quoteNet": -3000000 // quote asset balance's net change (in KRW for this case) + // } + // } + // + const id = this.safeString (order, 'id'); + const clientOrderId = this.safeString (order, 'clientOrderId'); + const timestamp = this.parse8601 (this.safeString (order, 'createdAt')); + const type = this.safeString (order, 'type'); + const side = this.safeString (order, 'side'); + const timeInForce = this.safeStringUpper (order, 'timeInForce'); + const price = this.safeFloat (order, 'price'); + const amount = this.safeFloat (order, 'amount'); + const stopPrice = this.safeFloat (order, 'stopPrice'); + const remaining = this.safeFloat (order, 'remaining'); + const marketId = this.safeString (order, 'tradingPairName'); + market = this.safeMarket (marketId, market, '-'); + const status = this.parseOrderStatus (this.safeString (order, 'status')); + const balanceChange = this.safeValue (order, 'balanceChange', {}); + let filled = this.safeFloat (balanceChange, 'baseNet'); + let cost = this.safeFloat (balanceChange, 'quoteNet'); + if (cost !== undefined) { + cost = Math.abs (cost); + } + let updated = undefined; + if ((filled === undefined) && (amount !== undefined) && (remaining !== undefined)) { + filled = Math.max (0, amount - remaining); + } + if ((filled !== undefined) && (filled > 0)) { + updated = this.parse8601 (this.safeString (order, 'updatedAt')); + } + if ((cost === undefined) && (price !== undefined) && (filled !== undefined)) { + cost = filled * price; + } + let fee = undefined; + if (side === 'buy') { + const baseFee = this.safeValue (balanceChange, 'baseFee', {}); + const taking = this.safeFloat (baseFee, 'taking'); + const making = this.safeFloat (baseFee, 'making'); + fee = { + 'currency': market['base'], + 'cost': this.sum (taking, making), + }; + } else { + const quoteFee = this.safeValue (balanceChange, 'quoteFee', {}); + const taking = this.safeFloat (quoteFee, 'taking'); + const making = this.safeFloat (quoteFee, 'making'); + fee = { + 'currency': market['quote'], + 'cost': this.sum (taking, making), + }; + } + let postOnly = undefined; + if (timeInForce !== undefined) { + postOnly = (timeInForce === 'PO'); + } + return { + 'id': id, + 'clientOrderId': clientOrderId, + 'datetime': this.iso8601 (timestamp), + 'timestamp': timestamp, + 'lastTradeTimestamp': updated, + 'status': status, + 'symbol': market['symbol'], + 'type': type, + 'timeInForce': timeInForce, + 'postOnly': postOnly, + 'side': side, + 'price': price, + 'stopPrice': stopPrice, + 'average': undefined, + 'amount': amount, + 'filled': filled, + 'remaining': remaining, + 'cost': cost, + 'trades': undefined, + 'fee': fee, + 'info': order, + }; + } + + async fetchOrder (id, symbol = undefined, params = {}) { + await this.loadMarkets (); + let method = undefined; + const clientOrderId = this.safeString (params, 'clientOrderId'); + params = this.omit (params, 'clientOrderId'); + const request = {}; + if (clientOrderId === undefined) { + method = 'privateGetOrdersOrderId'; + request['orderId'] = id; + } else { + method = 'privateGetOrdersClientOrderIdClientOrderId'; + request['clientOrderId'] = clientOrderId; + } + const response = await this[method] (this.extend (request, params)); + // + // { + // "id": "453324", // order ID + // "clientOrderId": "zeckrw23456", // client order ID (showed only when it exists) + // "status": "updated", // placed, cancelled, completed, updated, reserved + // "forcedCompletionReason": undefined, // the reason in case it was canceled in the middle (protection or timeInForce) + // "tradingPairName": "ZEC-KRW", // order book + // "side": "buy", // buy, sell + // "type": "limit", // limit, market + // "price": 1000000, // price + // "stopPrice": undefined, // stop price (showed only for stop orders) + // "amount": 4, // initial amount + // "remaining": 1, // outstanding amount + // "protection": "yes", // whether protection is activated (yes or no) + // "timeInForce": "gtc", // limit order's time in force (gtc/po/ioc/fok) + // "createdAt": "2020-09-25T04:06:20.000Z", // order placement time + // "updatedAt": "2020-09-25T04:06:29.000Z", // order last update time + // "balanceChange": { + // "baseGross": 3, // base asset balance's gross change (in ZEC for this case) + // "baseFee": { + // "taking": 0, // base asset fee imposed as taker + // "making": -0.0012 // base asset fee imposed as maker + // }, + // "baseNet": 2.9988, // base asset balance's net change (in ZEC for this case) + // "quoteGross": -3000000, // quote asset balance's gross change (in KRW for + // "quoteFee": { + // "taking": 0, // quote asset fee imposed as taker + // "making": 0 // quote asset fee imposed as maker + // }, + // "quoteNet": -3000000 // quote asset balance's net change (in KRW for this case) + // } + // } + // + return this.parseOrder (response); + } + + async fetchOrders (symbol = undefined, since = undefined, limit = undefined, params = {}) { + await this.loadMarkets (); + const request = { + 'includePast': 'true', // if true, completed and canceled orders are included as the result, they are accessible for one hour only from its completion or cancellation time + // 'pagination': 'false', // if the result is more than 3,000 orders, set this value as true to access 1000 orders at max per each page + }; + let market = undefined; + if (symbol !== undefined) { + market = this.market (symbol); + } + const response = await this.privateGetOrders (this.extend (request, params)); + // + // [ + // { + // "id": "453324", // order ID + // "clientOrderId": "zeckrw23456", // client order ID (showed only when it exists) + // "status": "updated", // placed, cancelled, completed, updated, reserved + // "forcedCompletionReason": undefined, // the reason in case it was canceled in the middle (protection or timeInForce) + // "tradingPairName": "ZEC-KRW", // order book + // "side": "buy", // buy, sell + // "type": "limit", // limit, market + // "price": 1000000, // price + // "stopPrice": undefined, // stop price (showed only for stop orders) + // "amount": 4, // initial amount + // "remaining": 1, // outstanding amount + // "protection": "yes", // whether protection is activated (yes or no) + // "timeInForce": "gtc", // limit order's time in force (gtc/po/ioc/fok) + // "createdAt": "2020-09-25T04:06:20.000Z", // order placement time + // "updatedAt": "2020-09-25T04:06:29.000Z", // order last update time + // "balanceChange": { + // "baseGross": 3, // base asset balance's gross change (in ZEC for this case) + // "baseFee": { + // "taking": 0, // base asset fee imposed as taker + // "making": -0.0012 // base asset fee imposed as maker + // }, + // "baseNet": 2.9988, // base asset balance's net change (in ZEC for this case) + // "quoteGross": -3000000, // quote asset balance's gross change (in KRW for + // "quoteFee": { + // "taking": 0, // quote asset fee imposed as taker + // "making": 0 // quote asset fee imposed as maker + // }, + // "quoteNet": -3000000 // quote asset balance's net change (in KRW for this case) + // } + // }, + // ] + // + return this.parseOrders (response, market, since, limit); + } + + async fetchOpenOrders (symbol = undefined, since = undefined, limit = undefined, params = {}) { + const request = { + 'includePast': 'false', + }; + return await this.fetchOrders (symbol, since, limit, this.extend (request, params)); + } + + async createOrder (symbol, type, side, amount, price = undefined, params = {}) { + await this.loadMarkets (); + const market = this.market (symbol); + const request = { + // 'clientOrderId': 'test4321', // max 20 characters of [a-zA-Z0-9_-] + 'tradingPairName': market['id'], + 'side': side, // buy, sell + 'type': type, // limit, market + // 'price': this.priceToPrecision (symbol, price), + // 'stopPrice': this.priceToPrecision (symbol, stopPrice), // optional, becomes a stop order if set + // 'amount': this.amountToPrecision (symbol, amount), + // 'protection': 'no', // whether protection is activated + // 'timeInForce': 'gtc', // gtc, po, ioc, fok + }; + if (type === 'limit') { + request['price'] = this.priceToPrecision (symbol, price); + request['amount'] = this.amountToPrecision (symbol, amount); + } else if (type === 'market') { + // for market buy it requires the amount of quote currency to spend + if (side === 'buy') { + let total = amount; + const createMarketBuyOrderRequiresPrice = this.safeValue (this.options, 'createMarketBuyOrderRequiresPrice', true); + if (createMarketBuyOrderRequiresPrice) { + if (price === undefined) { + throw new InvalidOrder (this.id + " createOrder() requires the price argument with market buy orders to calculate total order cost (amount to spend), where cost = amount * price. Supply a price argument to createOrder() call if you want the cost to be calculated for you from price and amount, or, alternatively, add .options['createMarketBuyOrderRequiresPrice'] = false and supply the total cost value in the 'amount' argument"); + } + total = price * amount; + } + const precision = market['precision']['price']; + request['amount'] = this.decimalToPrecision (total, TRUNCATE, precision, this.precisionMode); + } else { + request['amount'] = this.amountToPrecision (symbol, amount); + } + } + const clientOrderId = this.safeString (params, 'clientOrderId'); + if (clientOrderId !== undefined) { + request['clientOrderId'] = clientOrderId; + params = this.omit (params, 'clientOrderId'); + } + const stopPrice = this.safeFloat (params, 'stopPrice'); + if (stopPrice !== undefined) { + request['stopPrice'] = this.priceToPrecision (symbol, stopPrice); + params = this.omit (params, 'stopPrice'); + } + const timeInForce = this.safeStringLower (params, 'timeInForce'); + if (timeInForce !== undefined) { + request['timeInForce'] = timeInForce; + params = this.omit (params, 'timeInForce'); + } + const response = await this.privatePostOrders (this.extend (request, params)); + // + // { + // "id": "453327", // order ID + // "clientOrderId": "test4321", // client order ID (showed only when it exists) + // "status": "reserved", // placed, cancelled, completed, updated, reserved + // "forcedCompletionReason": undefined, // the reason in case it was canceled in the middle (protection or timeInForce) + // "tradingPairName": "BCH-KRW", // order book + // "side": "sell", // buy, sell + // "type": "limit", // limit, market + // "price": 11000000, // price + // "stopPrice": 12000000, // stop price (showed only for stop orders) + // "amount": 0.5, // initial amount + // "remaining": 0.5, // outstanding amount + // "protection": "no", // whether protection is activated (yes or no) + // "timeInForce": "gtc", // limit order's time in force (gtc/po/ioc/fok) + // "createdAt": "2020-09-25T04:51:31.000Z", // order placement time + // "balanceChange": { + // "baseGross": 0, // base asset balance's gross change (in BCH for this case) + // "baseFee": { + // "taking": 0, // base asset fee imposed as taker + // "making": 0 // base asset fee imposed as maker + // }, + // "baseNet": 0, // base asset balance's net change (in BCH for this case) + // "quoteGross": 0, // quote asset balance's gross change (in KRW for + // "quoteFee": { + // "taking": 0, // quote asset fee imposed as taker + // "making": 0 // quote asset fee imposed as maker + // }, + // "quoteNet": 0 // quote asset balance's net change (in KRW for this case) + // } + // } + // + return this.parseOrder (response, market); + } + + async cancelOrder (id, symbol = undefined, params = {}) { + await this.loadMarkets (); + const request = {}; + const clientOrderId = this.safeString (params, 'clientOrderId'); + let method = undefined; + if (clientOrderId === undefined) { + method = 'privateDeleteOrdersOrderId'; + request['orderId'] = id; + } else { + method = 'privateDeleteOrdersClientOrderIdClientOrderId'; + request['clientOrderId'] = clientOrderId; + params = this.omit (params, 'clientOrderId'); + } + const response = await this[method] (this.extend (request, params)); + // + // {} + // + const order = this.parseOrder (response); + return this.extend (order, { 'id': id }); + } + + async fetchMyTrades (symbol = undefined, since = undefined, limit = undefined, params = {}) { + await this.loadMarkets (); + const request = { + // 'limit': limit, // max 100 + // 'pastmax': id, // read data older than this id + // 'latestmin': id, // read data newer than this id + // 'after': parseInt (since / 1000), // Read data after this timestamp in seconds + // 'before': this.seconds (), // Read data before this timestamp in seconds + 'deepSearch': 'true', // read data older than one month ago are inclusively looked up only when it is "true" + }; + if (since !== undefined) { + request['after'] = parseInt (since / 1000); + } + if (limit !== undefined) { + request['limit'] = limit; + } + const response = await this.privateGetTrades (this.extend (request, params)); + // + // [ + // { + // "id": 73953, // trading event ID + // "orderId": 453324, // order ID + // "baseAmount": 3, // traded base asset amount + // "quoteAmount": 3000000, // traded quote asset amount + // "fee": 0.0012, // fee + // "price": 1000000, // price + // "timestamp": "2020-09-25T04:06:30.000Z", // trading time + // "side": "buy", // buy, sell + // "tradingPairName": "ZEC-KRW", // order book + // "position": "maker" // maker, taker + // }, + // ] + // + let market = undefined; + if (symbol !== undefined) { + market = this.market (symbol); + } + return this.parseTrades (response, market, since, limit); + } + + parseDepositAddress (depositAddress, currency = undefined) { + // + // { + // "asset": "BTC", // asset name + // "address": "1CwC2cMFu1jRQUBtw925cENbT1kctJBMdm", // deposit address + // "memoId": null, // memo ID (showed only for assets using memo ID) + // "createdAt": 1594802312 // deposit address creation time + // } + // + const address = this.safeString (depositAddress, 'address'); + const tag = this.safeString (depositAddress, 'memoId'); + const currencyId = this.safeString (depositAddress, 'asset'); + const code = this.safeCurrencyCode (currencyId); + this.checkAddress (address); + return { + 'currency': code, + 'address': address, + 'tag': tag, + 'info': depositAddress, + }; + } + + parseDepositAddresses (addresses, codes = undefined) { + let result = []; + for (let i = 0; i < addresses.length; i++) { + const address = this.parseDepositAddress (addresses[i]); + result.push (address); + } + if (codes) { + result = this.filterByArray (result, 'currency', codes); + } + return this.indexBy (result, 'currency'); + } + + async fetchDepositAddresses (codes = undefined, params = {}) { + await this.loadMarkets (); + const response = await this.privateGetCryptoDepositAddresses (params); + // + // [ + // { + // "asset": "BTC", // asset name + // "address": "1CwC2cMFu1jRQUBtw925cENbT1kctJBMdm", // deposit address + // "memoId": null, // memo ID (showed only for assets using memo ID) + // "createdAt": 1594802312 // deposit address creation time + // }, + // ] + // + return this.parseDepositAddresses (response, codes); + } + + async fetchDepositAddress (code, params = {}) { + await this.loadMarkets (); + const response = await this.fetchDepositAddresses (undefined, params); + const address = this.safeValue (response, code); + if (address === undefined) { + throw new InvalidAddress (this.id + ' fetchDepositAddress() ' + code + ' address not found'); + } + return address; + } + + parseTransactionStatus (status) { + const statuses = { + 'reviewing': 'pending', + 'rejected': 'rejected', + 'processing': 'pending', + 'failed': 'failed', + 'completed': 'ok', + }; + return this.safeString (statuses, status, status); + } + + parseTransaction (transaction, currency = undefined) { + // + // { + // "id": 640, // deposit/withdrawal event ID + // "asset": "BTC", // asset name + // "type": "crypto_withdrawal", // fiat_withdrawal, fiat_deposit, crypto_withdrawal, crypto_deposit + // "netAmount": 0.0001, // amount + // "feeAmount": 0.0005, // fee (null if there is no imposed fee) + // "status": "completed", // reviewing, rejected, processing, failed, completed + // "reviewStartedAt": 1595556218, // request time + // "completedAt": 1595556902, // completion time (showed only in case of completed) + // "txId": "eaca5ad3...", // tx ID + // "sourceAddress": null, // sender address (showed only in case of crypto_deposit) + // "destinationAddress: "3H8...", // recipient address (showed only in case of crypto_withdrawal) + // "destinationMemoId": null // recipient address's memo ID + // } + // + const id = this.safeString (transaction, 'id'); + const txid = this.safeString (transaction, 'txId'); + const currencyId = this.safeString (transaction, 'asset'); + const code = this.safeCurrencyCode (currencyId, currency); + let type = this.safeString (transaction, 'type'); + if ((type === 'crypto_withdrawal') || (type === 'fiat_withdrawal')) { + type = 'withdrawal'; + } else if ((type === 'crypto_deposit' || type === 'fiat_deposit')) { + type = 'deposit'; + } + const amount = this.safeFloat (transaction, 'netAmount'); + const feeCost = this.safeFloat (transaction, 'feeAmount'); + let fee = undefined; + if (feeCost !== undefined) { + fee = { + 'cost': feeCost, + 'currency': code, + }; + } + const timestamp = this.safeTimestamp (transaction, 'reviewStartedAt'); + const updated = this.safeTimestamp (transaction, 'completedAt'); + const addressFrom = this.safeString (transaction, 'sourceAddress'); + const addressTo = this.safeString (transaction, 'destinationAddress'); + const tagFrom = this.safeString (transaction, 'sourceMemoId'); + const tagTo = this.safeString (transaction, 'destinationMemoId'); + const status = this.parseTransactionStatus (this.safeString (transaction, 'status')); + return { + 'info': transaction, + 'id': id, + 'txid': txid, + 'timestamp': timestamp, + 'datetime': this.iso8601 (timestamp), + 'addressFrom': addressFrom, + 'address': addressTo, + 'addressTo': addressTo, + 'tagFrom': tagFrom, + 'tag': tagTo, + 'tagTo': tagTo, + 'type': type, + 'amount': amount, + 'currency': code, + 'status': status, + 'updated': updated, + 'comment': undefined, + 'fee': fee, + }; + } + + async fetchTransactions (code = undefined, since = undefined, limit = undefined, params = {}) { + await this.loadMarkets (); + const request = { + // 'limit': limit, // max 20 + // 'latestmin': limit, // read data older than this id + // 'after': this.milliseconds (), + // 'before': since, + // 'completedOnly': 'no', + }; + if (since !== undefined) { + request['before'] = since; + } + if (limit !== undefined) { + request['limit'] = limit; + } + const response = await this.privateGetDepositWithdrawalStatus (this.extend (request, params)); + // + // [ + // { + // "id": 640, // deposit/withdrawal event ID + // "asset": "BTC", // asset name + // "type": "crypto_withdrawal", // fiat_withdrawal, fiat_deposit, crypto_withdrawal, crypto_deposit + // "netAmount": 0.0001, // amount + // "feeAmount": 0.0005, // fee (null if there is no imposed fee) + // "status": "completed", // reviewing, rejected, processing, failed, completed + // "reviewStartedAt": 1595556218, // request time + // "completedAt": 1595556902, // completion time (showed only in case of completed) + // "txId": "eaca5ad3...", // tx ID + // "sourceAddress": null, // sender address (showed only in case of crypto_deposit) + // "destinationAddress: "3H8...", // recipient address (showed only in case of crypto_withdrawal) + // "destinationMemoId": null // recipient address's memo ID + // }, + // ] + // + let currency = undefined; + if (code !== undefined) { + currency = this.currency (code); + } + return this.parseTransactions (response, currency, since, limit, params); + } + + nonce () { + return this.milliseconds (); + } + + sign (path, api = 'public', method = 'GET', params = {}, headers = undefined, body = undefined) { // for authentication in private API calls + const endpoint = '/' + this.implodeParams (path, params); + let url = this.implodeParams (this.urls['api'][api], { 'hostname': this.hostname }) + endpoint; + const query = this.omit (params, this.extractParams (path)); + if (api === 'public') { + if (Object.keys (query).length) { + url += '?' + this.urlencode (query); + } + } else if (api === 'private') { + this.checkRequiredCredentials (); + const timestamp = this.nonce ().toString (); + let auth = 't' + timestamp + method + endpoint; + headers = { + 'api-key': this.apiKey, + 'timestamp': timestamp, + }; + if (method === 'POST') { + headers['Content-Type'] = 'application/json'; + body = this.json (params); + auth += body; + } else if (endpoint === '/orders') { + if (Object.keys (query).length) { + const urlQuery = '?' + this.urlencode (query); + auth += urlQuery; + url += urlQuery; + } + } else if (method === 'GET') { + if (Object.keys (query).length) { + url += '?' + this.urlencode (query); + } + } + const rawSecret = this.base64ToBinary (this.secret); + const signature = this.hmac (this.encode (auth), rawSecret, 'sha512', 'base64'); + headers['signature'] = signature; + } + return { 'url': url, 'method': method, 'body': body, 'headers': headers }; + } + + handleErrors (code, reason, url, method, headers, body, response, requestHeaders, requestBody) { + if (response === undefined) { + return; + } + // + // {"errorMessage":"Invalid API key","errorCode":10155} + // + if (!Array.isArray (response)) { + const errorCode = this.safeString (response, 'errorCode'); + const errorMessage = this.safeString (response, 'errorMessage'); + const feedback = this.id + ' ' + body; + if (errorMessage !== undefined) { + this.throwBroadlyMatchedException (this.exceptions['broad'], body, feedback); + } + if (errorCode !== undefined) { + this.throwExactlyMatchedException (this.exceptions['exact'], errorCode, feedback); + } + if ((errorCode !== undefined) || (errorMessage !== undefined)) { + throw new ExchangeError (feedback); + } + } + } +}; diff --git a/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/hbtc.js b/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/hbtc.js index d7bde5c6c..d819c3d77 100644 --- a/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/hbtc.js +++ b/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/hbtc.js @@ -841,7 +841,7 @@ module.exports = class hbtc extends Exchange { method = 'optionGetMyTrades'; } else { if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' fetchMyTrades requires a `symbol` argument for ' + type + ' markets'); + throw new ArgumentsRequired (this.id + ' fetchMyTrades() requires a `symbol` argument for ' + type + ' markets'); } const market = this.market (symbol); request['symbol'] = market['id']; @@ -1954,6 +1954,7 @@ module.exports = class hbtc extends Exchange { 'NEW': 'open', 'CANCELED': 'canceled', 'FILLED': 'closed', + 'PARTIALLY_FILLED': 'open', 'PENDING_CANCEL': 'canceled', }; return this.safeString (statuses, status, status); diff --git a/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/hitbtc.js b/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/hitbtc.js index 0ec19ca80..b66392816 100644 --- a/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/hitbtc.js +++ b/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/hitbtc.js @@ -59,6 +59,10 @@ module.exports = class hitbtc extends Exchange { }, 'urls': { 'logo': 'https://user-images.githubusercontent.com/1294454/27766555-8eaec20e-5edc-11e7-9c5b-6dc69fc42f5e.jpg', + 'test': { + 'public': 'https://api.demo.hitbtc.com', + 'private': 'https://api.demo.hitbtc.com', + }, 'api': { 'public': 'https://api.hitbtc.com', 'private': 'https://api.hitbtc.com', @@ -160,6 +164,7 @@ module.exports = class hitbtc extends Exchange { 'LNC': 'LinkerCoin', 'PLA': 'PlayChip', 'PNT': 'Penta', + 'SBTC': 'Super Bitcoin', 'TV': 'Tokenville', 'USD': 'USDT', 'XPNT': 'PNT', @@ -797,22 +802,44 @@ module.exports = class hitbtc extends Exchange { // // createMarketOrder // - // { clientOrderId: "fe36aa5e190149bf9985fb673bbb2ea0", - // createdAt: "2018-10-25T16:41:44.780Z", - // cumQuantity: "1", - // id: "66799540063", - // quantity: "1", - // side: "sell", - // status: "filled", - // symbol: "XRPUSDT", - // timeInForce: "FOK", - // tradesReport: [ { fee: "0.0004644", - // id: 386394956, - // price: "0.4644", - // quantity: "1", - // timestamp: "2018-10-25T16:41:44.780Z" } ], - // type: "market", - // updatedAt: "2018-10-25T16:41:44.780Z" } + // { + // clientOrderId: "fe36aa5e190149bf9985fb673bbb2ea0", + // createdAt: "2018-10-25T16:41:44.780Z", + // cumQuantity: "1", + // id: "66799540063", + // quantity: "1", + // side: "sell", + // status: "filled", + // symbol: "XRPUSDT", + // timeInForce: "FOK", + // tradesReport: [ + // { + // fee: "0.0004644", + // id: 386394956, + // price: "0.4644", + // quantity: "1", + // timestamp: "2018-10-25T16:41:44.780Z" + // } + // ], + // type: "market", + // updatedAt: "2018-10-25T16:41:44.780Z" + // } + // + // { + // "id": 119499457455, + // "clientOrderId": "87baab109d58401b9202fa0749cb8288", + // "symbol": "ETHUSD", + // "side": "buy", + // "status": "filled", + // "type": "market", + // "timeInForce": "FOK", + // "quantity": "0.0007", + // "price": "181.487", + // "avgPrice": "164.989", + // "cumQuantity": "0.0007", + // "createdAt": "2019-04-17T13:27:38.062Z", + // "updatedAt": "2019-04-17T13:27:38.062Z" + // } // const created = this.parse8601 (this.safeString (order, 'createdAt')); const updated = this.parse8601 (this.safeString (order, 'updatedAt')); @@ -842,7 +869,7 @@ module.exports = class hitbtc extends Exchange { const side = this.safeString (order, 'side'); let trades = this.safeValue (order, 'tradesReport'); let fee = undefined; - let average = undefined; + let average = this.safeValue (order, 'avgPrice'); if (trades !== undefined) { trades = this.parseTrades (trades, market); let feeCost = undefined; @@ -861,7 +888,9 @@ module.exports = class hitbtc extends Exchange { } cost = tradesCost; if ((filled !== undefined) && (filled > 0)) { - average = cost / filled; + if (average === undefined) { + average = cost / filled; + } if (type === 'market') { if (price === undefined) { price = average; diff --git a/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/hollaex.js b/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/hollaex.js index 47b127d50..52e81fec3 100644 --- a/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/hollaex.js +++ b/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/hollaex.js @@ -520,7 +520,7 @@ module.exports = class hollaex extends Exchange { const duration = this.parseTimeframe (timeframe); if (since === undefined) { if (limit === undefined) { - throw new ArgumentsRequired (this.id + " fetchOHLCV requires a 'since' or a 'limit' argument"); + throw new ArgumentsRequired (this.id + " fetchOHLCV() requires a 'since' or a 'limit' argument"); } else { const end = this.seconds (); const start = end - duration * limit; @@ -702,6 +702,7 @@ module.exports = class hollaex extends Exchange { 'symbol': symbol, 'type': type, 'timeInForce': undefined, + 'postOnly': undefined, 'side': side, 'price': price, 'stopPrice': undefined, diff --git a/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/huobipro.js b/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/huobipro.js index 62edb18d3..52dc315e8 100644 --- a/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/huobipro.js +++ b/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/huobipro.js @@ -98,6 +98,7 @@ module.exports = class huobipro extends Exchange { 'user/api-key', // 母子用户API key信息查询 ], 'post': [ + 'account/transfer', 'point/transfer', // 点卡划转 'sub-user/management', // 冻结/解冻子用户 'sub-user/creation', // 子用户创建 @@ -195,9 +196,14 @@ module.exports = class huobipro extends Exchange { }, }, 'exceptions': { + 'broad': { + 'contract is restricted of closing positions on API. Please contact customer service': OnMaintenance, + 'maintain': OnMaintenance, + }, 'exact': { // err-code 'bad-request': BadRequest, + 'base-date-limit-error': BadRequest, // {"status":"error","err-code":"base-date-limit-error","err-msg":"date less than system limit","data":null} 'api-not-support-temp-addr': PermissionDenied, // {"status":"error","err-code":"api-not-support-temp-addr","err-msg":"API withdrawal does not support temporary addresses","data":null} 'timeout': RequestTimeout, // {"ts":1571653730865,"status":"error","err-code":"timeout","err-msg":"Request Timeout"} 'gateway-internal-error': ExchangeNotAvailable, // {"status":"error","err-code":"gateway-internal-error","err-msg":"Failed to load data. Try again later.","data":null} @@ -208,6 +214,8 @@ module.exports = class huobipro extends Exchange { 'order-marketorder-amount-min-error': InvalidOrder, // market order amount error, min: `0.01` 'order-limitorder-price-min-error': InvalidOrder, // limit order price error 'order-limitorder-price-max-error': InvalidOrder, // limit order price error + 'order-holding-limit-failed': InvalidOrder, // {"status":"error","err-code":"order-holding-limit-failed","err-msg":"Order failed, exceeded the holding limit of this currency","data":null} + 'order-orderprice-precision-error': InvalidOrder, // {"status":"error","err-code":"order-orderprice-precision-error","err-msg":"order price precision error, scale: `4`","data":null} 'order-orderstate-error': OrderNotFound, // canceling an already canceled order 'order-queryorder-invalid': OrderNotFound, // querying a non-existent order 'order-update-error': ExchangeNotAvailable, // undocumented error @@ -243,6 +251,7 @@ module.exports = class huobipro extends Exchange { // https://coinmarketcap.com/currencies/penta/markets/ // https://en.cryptonomist.ch/blog/eidoo/the-edo-to-pnt-upgrade-what-you-need-to-know-updated/ 'PNT': 'Penta', + 'SBTC': 'Super Bitcoin', }, }); } @@ -675,7 +684,8 @@ module.exports = class huobipro extends Exchange { request['size'] = limit; // 1-100 orders, default is 100 } if (since !== undefined) { - request['start-date'] = this.ymd (since); // maximum query window size is 2 days, query window shift should be within past 120 days + request['start-date'] = this.ymd (since); // a date within 61 days from today + request['end-date'] = this.ymd (this.sum (since, 86400000)); } const response = await this.privateGetOrderMatchresults (this.extend (request, params)); const trades = this.parseTrades (response['data'], market, since, limit); @@ -943,7 +953,7 @@ module.exports = class huobipro extends Exchange { async fetchOpenOrdersV1 (symbol = undefined, since = undefined, limit = undefined, params = {}) { if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' fetchOpenOrdersV1 requires a symbol argument'); + throw new ArgumentsRequired (this.id + ' fetchOpenOrdersV1() requires a symbol argument'); } return await this.fetchOrdersByStates ('pre-submitted,submitted,partial-filled', symbol, since, limit, params); } @@ -955,7 +965,7 @@ module.exports = class huobipro extends Exchange { async fetchOpenOrdersV2 (symbol = undefined, since = undefined, limit = undefined, params = {}) { await this.loadMarkets (); if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' fetchOpenOrders requires a symbol argument'); + throw new ArgumentsRequired (this.id + ' fetchOpenOrders() requires a symbol argument'); } const market = this.market (symbol); let accountId = this.safeString (params, 'account-id'); @@ -1105,6 +1115,7 @@ module.exports = class huobipro extends Exchange { 'symbol': symbol, 'type': type, 'timeInForce': undefined, + 'postOnly': undefined, 'side': side, 'price': price, 'stopPrice': undefined, @@ -1484,6 +1495,7 @@ module.exports = class huobipro extends Exchange { if (status === 'error') { const code = this.safeString (response, 'err-code'); const feedback = this.id + ' ' + body; + this.throwBroadlyMatchedException (this.exceptions['broad'], body, feedback); this.throwExactlyMatchedException (this.exceptions['exact'], code, feedback); const message = this.safeString (response, 'err-msg'); this.throwExactlyMatchedException (this.exceptions['exact'], message, feedback); diff --git a/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/ice3x.js b/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/ice3x.js index 42e54b79f..f228076d1 100644 --- a/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/ice3x.js +++ b/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/ice3x.js @@ -225,7 +225,7 @@ module.exports = class ice3x extends Exchange { const type = this.safeString (params, 'type'); if ((type !== 'ask') && (type !== 'bid')) { // eslint-disable-next-line quotes - throw new ArgumentsRequired (this.id + " fetchOrderBook requires an exchange-specific extra 'type' param ('bid' or 'ask') when used with a limit"); + throw new ArgumentsRequired (this.id + " fetchOrderBook() requires an exchange-specific extra 'type' param ('bid' or 'ask') when used with a limit"); } else { request['items_per_page'] = limit; } @@ -345,6 +345,7 @@ module.exports = class ice3x extends Exchange { 'symbol': symbol, 'type': 'limit', 'timeInForce': undefined, + 'postOnly': undefined, 'side': this.safeString (order, 'type'), 'price': price, 'stopPrice': undefined, diff --git a/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/idex.js b/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/idex.js index d70fa94f4..7d52a5286 100644 --- a/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/idex.js +++ b/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/idex.js @@ -56,8 +56,8 @@ module.exports = class idex extends Exchange { }, 'logo': 'https://user-images.githubusercontent.com/51840849/94481303-2f222100-01e0-11eb-97dd-bc14c5943a86.jpg', 'api': { - 'public': 'https://api.idex.io', - 'private': 'https://api.idex.io', + 'ETH': 'https://api-eth.idex.io', + 'BSC': 'https://api-bsc.idex.io', }, 'www': 'https://idex.io', 'doc': [ @@ -103,6 +103,7 @@ module.exports = class idex extends Exchange { 'options': { 'defaultTimeInForce': 'gtc', 'defaultSelfTradePrevention': 'cn', + 'network': 'ETH', // also supports BSC }, 'exceptions': { 'INVALID_ORDER_QUANTITY': InvalidOrder, @@ -822,16 +823,8 @@ module.exports = class idex extends Exchange { const type = this.safeString (order, 'type'); const amount = this.safeFloat (order, 'originalQuantity'); const filled = this.safeFloat (order, 'executedQuantity'); - let remaining = undefined; - if ((amount !== undefined) && (filled !== undefined)) { - remaining = amount - filled; - } const average = this.safeFloat (order, 'avgExecutionPrice'); - const price = this.safeFloat (order, 'price', average); // for market orders - let cost = undefined; - if ((amount !== undefined) && (price !== undefined)) { - cost = amount * price; - } + const price = this.safeFloat (order, 'price'); const rawStatus = this.safeString (order, 'status'); const status = this.parseOrderStatus (rawStatus); const fee = { @@ -845,7 +838,7 @@ module.exports = class idex extends Exchange { fee['cost'] = this.sum (fee['cost'], lastTrade['fee']['cost']); } const lastTradeTimestamp = this.safeInteger (lastTrade, 'timestamp'); - return { + return this.safeOrder ({ 'info': order, 'id': id, 'clientOrderId': clientOrderId, @@ -855,18 +848,19 @@ module.exports = class idex extends Exchange { 'symbol': symbol, 'type': type, 'timeInForce': undefined, + 'postOnly': undefined, 'side': side, 'price': price, 'stopPrice': undefined, 'amount': amount, - 'cost': cost, + 'cost': undefined, 'average': average, 'filled': filled, - 'remaining': remaining, + 'remaining': undefined, 'status': status, 'fee': fee, 'trades': trades, - }; + }); } async associateWallet (walletAddress, params = {}) { @@ -943,7 +937,8 @@ module.exports = class idex extends Exchange { } const sideEnum = (side === 'buy') ? 0 : 1; const walletBytes = this.remove0xPrefix (this.walletAddress); - const orderVersion = 1; + const network = this.safeString (this.options, 'network', 'ETH'); + const orderVersion = (network === 'ETH') ? 1 : 2; const amountString = this.amountToPrecision (symbol, amount); // https://docs.idex.io/#time-in-force const timeInForceEnums = { @@ -1272,8 +1267,9 @@ module.exports = class idex extends Exchange { } sign (path, api = 'public', method = 'GET', params = {}, headers = undefined, body = undefined) { + const network = this.safeString (this.options, 'network', 'ETH'); const version = this.safeString (this.options, 'version', 'v1'); - let url = this.urls['api'][api] + '/' + version + '/' + path; + let url = this.urls['api'][network] + '/' + version + '/' + path; const keys = Object.keys (params); const length = keys.length; let query = undefined; diff --git a/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/independentreserve.js b/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/independentreserve.js index 30f75d9a6..119a216d5 100644 --- a/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/independentreserve.js +++ b/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/independentreserve.js @@ -287,6 +287,7 @@ module.exports = class independentreserve extends Exchange { 'symbol': symbol, 'type': orderType, 'timeInForce': undefined, + 'postOnly': undefined, 'side': side, 'price': price, 'stopPrice': undefined, @@ -394,10 +395,13 @@ module.exports = class independentreserve extends Exchange { cost = price * amount; } } - let symbol = undefined; - if (market !== undefined) { - symbol = market['symbol']; + const baseId = this.safeString (trade, 'PrimaryCurrencyCode'); + const quoteId = this.safeString (trade, 'SecondaryCurrencyCode'); + let marketId = undefined; + if ((baseId !== undefined) && (quoteId !== undefined)) { + marketId = baseId + '/' + quoteId; } + const symbol = this.safeSymbol (marketId, market, '/'); let side = this.safeString (trade, 'OrderType'); if (side !== undefined) { if (side.indexOf ('Bid') >= 0) { diff --git a/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/indodax.js b/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/indodax.js index 30457eca2..f1cc33732 100644 --- a/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/indodax.js +++ b/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/indodax.js @@ -399,6 +399,7 @@ module.exports = class indodax extends Exchange { 'symbol': symbol, 'type': 'limit', 'timeInForce': undefined, + 'postOnly': undefined, 'side': side, 'price': price, 'stopPrice': undefined, @@ -415,7 +416,7 @@ module.exports = class indodax extends Exchange { async fetchOrder (id, symbol = undefined, params = {}) { if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' fetchOrder requires a symbol'); + throw new ArgumentsRequired (this.id + ' fetchOrder() requires a symbol'); } await this.loadMarkets (); const market = this.market (symbol); @@ -462,7 +463,7 @@ module.exports = class indodax extends Exchange { async fetchClosedOrders (symbol = undefined, since = undefined, limit = undefined, params = {}) { if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' fetchOrders requires a symbol argument'); + throw new ArgumentsRequired (this.id + ' fetchOrders() requires a symbol argument'); } await this.loadMarkets (); const request = {}; @@ -506,11 +507,11 @@ module.exports = class indodax extends Exchange { async cancelOrder (id, symbol = undefined, params = {}) { if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' cancelOrder requires a symbol argument'); + throw new ArgumentsRequired (this.id + ' cancelOrder() requires a symbol argument'); } const side = this.safeValue (params, 'side'); if (side === undefined) { - throw new ArgumentsRequired (this.id + ' cancelOrder requires an extra "side" param'); + throw new ArgumentsRequired (this.id + ' cancelOrder() requires an extra "side" param'); } await this.loadMarkets (); const market = this.market (symbol); diff --git a/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/itbit.js b/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/itbit.js index f26cf47eb..552bb0de5 100644 --- a/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/itbit.js +++ b/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/itbit.js @@ -268,7 +268,7 @@ module.exports = class itbit extends Exchange { await this.loadMarkets (); const walletId = this.safeString (params, 'walletId'); if (walletId === undefined) { - throw new ArgumentsRequired (this.id + ' fetchMyTrades requires a walletId parameter'); + throw new ArgumentsRequired (this.id + ' fetchMyTrades() requires a walletId parameter'); } const request = { 'walletId': walletId, @@ -337,7 +337,7 @@ module.exports = class itbit extends Exchange { await this.loadMarkets (); const walletId = this.safeString (params, 'walletId'); if (walletId === undefined) { - throw new ExchangeError (this.id + ' fetchMyTrades requires a walletId parameter'); + throw new ExchangeError (this.id + ' fetchMyTrades() requires a walletId parameter'); } const request = { 'walletId': walletId, @@ -427,7 +427,7 @@ module.exports = class itbit extends Exchange { async fetchWallets (params = {}) { await this.loadMarkets (); if (!this.uid) { - throw new AuthenticationError (this.id + ' fetchWallets requires uid API credential'); + throw new AuthenticationError (this.id + ' fetchWallets() requires uid API credential'); } const request = { 'userId': this.uid, @@ -465,7 +465,7 @@ module.exports = class itbit extends Exchange { } const walletIdInParams = ('walletId' in params); if (!walletIdInParams) { - throw new ExchangeError (this.id + ' fetchOrders requires a walletId parameter'); + throw new ExchangeError (this.id + ' fetchOrders() requires a walletId parameter'); } const walletId = params['walletId']; const request = { @@ -529,6 +529,8 @@ module.exports = class itbit extends Exchange { } const clientOrderId = this.safeString (order, 'clientOrderIdentifier'); const id = this.safeString (order, 'id'); + const postOnlyString = this.safeString (order, 'postOnly'); + const postOnly = (postOnlyString === 'True'); return { 'id': id, 'clientOrderId': clientOrderId, @@ -540,6 +542,7 @@ module.exports = class itbit extends Exchange { 'symbol': symbol, 'type': type, 'timeInForce': undefined, + 'postOnly': postOnly, 'side': side, 'price': price, 'stopPrice': undefined, @@ -565,7 +568,7 @@ module.exports = class itbit extends Exchange { } const walletIdInParams = ('walletId' in params); if (!walletIdInParams) { - throw new ExchangeError (this.id + ' createOrder requires a walletId parameter'); + throw new ExchangeError (this.id + ' createOrder() requires a walletId parameter'); } amount = amount.toString (); price = price.toString (); @@ -590,7 +593,7 @@ module.exports = class itbit extends Exchange { await this.loadMarkets (); const walletIdInParams = ('walletId' in params); if (!walletIdInParams) { - throw new ExchangeError (this.id + ' fetchOrder requires a walletId parameter'); + throw new ExchangeError (this.id + ' fetchOrder() requires a walletId parameter'); } const request = { 'id': id, @@ -602,7 +605,7 @@ module.exports = class itbit extends Exchange { async cancelOrder (id, symbol = undefined, params = {}) { const walletIdInParams = ('walletId' in params); if (!walletIdInParams) { - throw new ExchangeError (this.id + ' cancelOrder requires a walletId parameter'); + throw new ExchangeError (this.id + ' cancelOrder() requires a walletId parameter'); } const request = { 'id': id, diff --git a/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/kraken.js b/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/kraken.js index 78e997c6d..198ee4cf8 100644 --- a/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/kraken.js +++ b/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/kraken.js @@ -3,7 +3,7 @@ // --------------------------------------------------------------------------- const Exchange = require ('./base/Exchange'); -const { BadSymbol, ExchangeNotAvailable, ArgumentsRequired, PermissionDenied, AuthenticationError, ExchangeError, OrderNotFound, DDoSProtection, InvalidNonce, InsufficientFunds, CancelPending, InvalidOrder, InvalidAddress } = require ('./base/errors'); +const { BadSymbol, ExchangeNotAvailable, ArgumentsRequired, PermissionDenied, AuthenticationError, ExchangeError, OrderNotFound, DDoSProtection, InvalidNonce, InsufficientFunds, CancelPending, InvalidOrder, InvalidAddress, RateLimitExceeded } = require ('./base/errors'); const { TRUNCATE, DECIMAL_PLACES } = require ('./base/functions/number'); // --------------------------------------------------------------------------- @@ -19,6 +19,7 @@ module.exports = class kraken extends Exchange { 'certified': true, 'pro': true, 'has': { + 'cancelAllOrders': true, 'cancelOrder': true, 'CORS': false, 'createDepositAddress': true, @@ -179,6 +180,7 @@ module.exports = class kraken extends Exchange { 'AddOrder', 'AddExport', 'Balance', + 'CancelAll', 'CancelOrder', 'ClosedOrders', 'DepositAddresses', @@ -206,6 +208,7 @@ module.exports = class kraken extends Exchange { }, 'commonCurrencies': { 'XBT': 'BTC', + 'XBT.M': 'BTC.M', // https://support.kraken.com/hc/en-us/articles/360039879471-What-is-Asset-S-and-Asset-M- 'XDG': 'DOGE', 'REPV2': 'REP', 'REP': 'REPV1', @@ -349,13 +352,17 @@ module.exports = class kraken extends Exchange { return result; } - safeCurrencyCode (currencyId, currency = undefined) { + safeCurrency (currencyId, currency = undefined) { if (currencyId.length > 3) { if ((currencyId.indexOf ('X') === 0) || (currencyId.indexOf ('Z') === 0)) { - currencyId = currencyId.slice (1); + if (currencyId.indexOf ('.') > 0) { + return super.safeCurrency (currencyId, currency); + } else { + currencyId = currencyId.slice (1); + } } } - return super.safeCurrencyCode (currencyId, currency); + return super.safeCurrency (currencyId, currency); } appendInactiveMarkets (result) { @@ -820,7 +827,7 @@ module.exports = class kraken extends Exchange { let amount = undefined; let cost = undefined; let id = undefined; - let order = undefined; + let orderId = undefined; let fee = undefined; let symbol = undefined; if (Array.isArray (trade)) { @@ -844,7 +851,7 @@ module.exports = class kraken extends Exchange { // delisted market ids go here market = this.getDelistedMarketById (marketId); } - order = trade['ordertxid']; + orderId = this.safeString (trade, 'ordertxid'); id = this.safeString2 (trade, 'id', 'postxid'); timestamp = this.safeTimestamp (trade, 'time'); side = this.safeString (trade, 'type'); @@ -872,7 +879,7 @@ module.exports = class kraken extends Exchange { } return { 'id': id, - 'order': order, + 'order': orderId, 'info': trade, 'timestamp': timestamp, 'datetime': this.iso8601 (timestamp), @@ -935,6 +942,7 @@ module.exports = class kraken extends Exchange { } async fetchBalance (params = {}) { + await this.loadMarkets (); const response = await this.privatePostBalance (params); const balances = this.safeValue (response, 'result', {}); const result = { 'info': balances }; @@ -959,18 +967,50 @@ module.exports = class kraken extends Exchange { 'volume': this.amountToPrecision (symbol, amount), }; const clientOrderId = this.safeString2 (params, 'userref', 'clientOrderId'); - const query = this.omit (params, [ 'userref', 'clientOrderId' ]); + params = this.omit (params, [ 'userref', 'clientOrderId' ]); if (clientOrderId !== undefined) { request['userref'] = clientOrderId; } - const priceIsDefined = (price !== undefined); - const marketOrder = (type === 'market'); - const limitOrder = (type === 'limit'); - const shouldIncludePrice = limitOrder || (!marketOrder && priceIsDefined); - if (shouldIncludePrice) { + // + // market + // limit (price = limit price) + // stop-loss (price = stop loss price) + // take-profit (price = take profit price) + // stop-loss-limit (price = stop loss trigger price, price2 = triggered limit price) + // take-profit-limit (price = take profit trigger price, price2 = triggered limit price) + // settle-position + // + if (type === 'limit') { request['price'] = this.priceToPrecision (symbol, price); + } else if ((type === 'stop-loss') || (type === 'take-profit')) { + const stopPrice = this.safeFloat2 (params, 'price', 'stopPrice', price); + if (stopPrice === undefined) { + throw new ArgumentsRequired (this.id + ' createOrder() requires a price argument or a price/stopPrice parameter for a ' + type + ' order'); + } else { + request['price'] = this.priceToPrecision (symbol, stopPrice); + } + } else if ((type === 'stop-loss-limit') || (type === 'take-profit-limit')) { + const stopPrice = this.safeFloat2 (params, 'price', 'stopPrice'); + const limitPrice = this.safeFloat (params, 'price2'); + const stopPriceDefined = (stopPrice !== undefined); + const limitPriceDefined = (limitPrice !== undefined); + if (stopPriceDefined && limitPriceDefined) { + request['price'] = this.priceToPrecision (symbol, stopPrice); + request['price2'] = this.priceToPrecision (symbol, limitPrice); + } else if ((price === undefined) || (!(stopPriceDefined || limitPriceDefined))) { + throw new ArgumentsRequired (this.id + ' createOrder() requires a price argument and/or price/stopPrice/price2 parameters for a ' + type + ' order'); + } else { + if (stopPriceDefined) { + request['price'] = this.priceToPrecision (symbol, stopPrice); + request['price2'] = this.priceToPrecision (symbol, price); + } else if (limitPriceDefined) { + request['price'] = this.priceToPrecision (symbol, price); + request['price2'] = this.priceToPrecision (symbol, limitPrice); + } + } } - const response = await this.privatePostAddOrder (this.extend (request, query)); + params = this.omit (params, [ 'price', 'stopPrice', 'price2' ]); + const response = await this.privatePostAddOrder (this.extend (request, params)); // // { // error: [], @@ -1133,6 +1173,7 @@ module.exports = class kraken extends Exchange { 'symbol': symbol, 'type': type, 'timeInForce': undefined, + 'postOnly': undefined, 'side': side, 'price': price, 'stopPrice': stopPrice, @@ -1199,8 +1240,11 @@ module.exports = class kraken extends Exchange { // } // } // - const orders = this.safeValue (response, 'result', []); - const order = this.parseOrder (this.extend ({ 'id': id }, orders[id])); + const result = this.safeValue (response, 'result', []); + if (!(id in result)) { + throw new OrderNotFound (this.id + ' fetchOrder() could not find order id ' + id); + } + const order = this.parseOrder (this.extend ({ 'id': id }, result[id])); return this.extend ({ 'info': response }, order); } @@ -1208,7 +1252,7 @@ module.exports = class kraken extends Exchange { const orderTrades = this.safeValue (params, 'trades'); const tradeIds = []; if (orderTrades === undefined) { - throw new ArgumentsRequired (this.id + " fetchOrderTrades requires a unified order structure in the params argument or a 'trades' param (an array of trade id strings)"); + throw new ArgumentsRequired (this.id + " fetchOrderTrades() requires a unified order structure in the params argument or a 'trades' param (an array of trade id strings)"); } else { for (let i = 0; i < orderTrades.length; i++) { const orderTrade = orderTrades[i]; @@ -1357,6 +1401,11 @@ module.exports = class kraken extends Exchange { return response; } + async cancelAllOrders (symbol = undefined, params = {}) { + await this.loadMarkets (); + return await this.privatePostCancelAll (params); + } + async fetchOpenOrders (symbol = undefined, since = undefined, limit = undefined, params = {}) { await this.loadMarkets (); const request = {}; @@ -1528,7 +1577,7 @@ module.exports = class kraken extends Exchange { async fetchDeposits (code = undefined, since = undefined, limit = undefined, params = {}) { // https://www.kraken.com/en-us/help/api#deposit-status if (code === undefined) { - throw new ArgumentsRequired (this.id + ' fetchDeposits requires a currency code argument'); + throw new ArgumentsRequired (this.id + ' fetchDeposits() requires a currency code argument'); } await this.loadMarkets (); const currency = this.currency (code); @@ -1571,7 +1620,7 @@ module.exports = class kraken extends Exchange { async fetchWithdrawals (code = undefined, since = undefined, limit = undefined, params = {}) { // https://www.kraken.com/en-us/help/api#withdraw-status if (code === undefined) { - throw new ArgumentsRequired (this.id + ' fetchWithdrawals requires a currency code argument'); + throw new ArgumentsRequired (this.id + ' fetchWithdrawals() requires a currency code argument'); } await this.loadMarkets (); const currency = this.currency (code); @@ -1662,7 +1711,65 @@ module.exports = class kraken extends Exchange { 'id': response['result'], }; } - throw new ExchangeError (this.id + " withdraw requires a 'key' parameter (withdrawal key name, as set up on your account)"); + throw new ExchangeError (this.id + " withdraw() requires a 'key' parameter (withdrawal key name, as set up on your account)"); + } + + async fetchPositions (symbols = undefined, since = undefined, limit = undefined, params = {}) { + await this.loadMarkets (); + const request = { + // 'txid': 'comma delimited list of transaction ids to restrict output to', + // 'docalcs': false, // whether or not to include profit/loss calculations + // 'consolidation': 'market', // what to consolidate the positions data around, market will consolidate positions based on market pair + }; + const response = await this.privatePostOpenPositions (this.extend (request, params)); + // + // no consolidation + // + // { + // error: [], + // result: { + // 'TGUFMY-FLESJ-VYIX3J': { + // ordertxid: "O3LRNU-ZKDG5-XNCDFR", + // posstatus: "open", + // pair: "ETHUSDT", + // time: 1611557231.4584, + // type: "buy", + // ordertype: "market", + // cost: "28.49800", + // fee: "0.07979", + // vol: "0.02000000", + // vol_closed: "0.00000000", + // margin: "14.24900", + // terms: "0.0200% per 4 hours", + // rollovertm: "1611571631", + // misc: "", + // oflags: "" + // } + // } + // } + // + // consolidation by market + // + // { + // error: [], + // result: [ + // { + // pair: "ETHUSDT", + // positions: "1", + // type: "buy", + // leverage: "2.00000", + // cost: "28.49800", + // fee: "0.07979", + // vol: "0.02000000", + // vol_closed: "0.00000000", + // margin: "14.24900" + // } + // ] + // } + // + const result = this.safeValue (response, 'result'); + // todo unify parsePosition/parsePositions + return result; } sign (path, api = 'public', method = 'GET', params = {}, headers = undefined, body = undefined) { @@ -1717,6 +1824,12 @@ module.exports = class kraken extends Exchange { if (body.indexOf ('Invalid arguments:volume') >= 0) { throw new InvalidOrder (this.id + ' ' + body); } + if (body.indexOf ('Rate limit exceeded') >= 0) { + throw new RateLimitExceeded (this.id + ' ' + body); + } + if (response === undefined) { + return; + } if (body[0] === '{') { if (typeof response !== 'string') { if ('error' in response) { diff --git a/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/kucoin.js b/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/kucoin.js index 1d8270ec0..bcb058989 100644 --- a/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/kucoin.js +++ b/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/kucoin.js @@ -20,30 +20,31 @@ module.exports = class kucoin extends Exchange { 'comment': 'Platform 2.0', 'has': { 'CORS': false, - 'fetchStatus': true, - 'fetchTime': true, - 'fetchMarkets': true, + 'cancelAllOrders': true, + 'cancelOrder': true, + 'createDepositAddress': true, + 'createOrder': true, + 'fetchAccounts': true, + 'fetchBalance': true, + 'fetchClosedOrders': true, 'fetchCurrencies': true, + 'fetchDepositAddress': true, + 'fetchDeposits': true, + 'fetchFundingFee': true, + 'fetchLedger': true, + 'fetchMarkets': true, + 'fetchMyTrades': true, + 'fetchOHLCV': true, + 'fetchOpenOrders': true, + 'fetchOrder': true, + 'fetchOrderBook': true, + 'fetchStatus': true, 'fetchTicker': true, 'fetchTickers': true, - 'fetchOrderBook': true, - 'fetchOrder': true, - 'fetchClosedOrders': true, - 'fetchOpenOrders': true, - 'fetchDepositAddress': true, - 'createDepositAddress': true, - 'withdraw': true, - 'fetchDeposits': true, - 'fetchWithdrawals': true, - 'fetchBalance': true, + 'fetchTime': true, 'fetchTrades': true, - 'fetchMyTrades': true, - 'createOrder': true, - 'cancelOrder': true, - 'fetchAccounts': true, - 'fetchFundingFee': true, - 'fetchOHLCV': true, - 'fetchLedger': true, + 'fetchWithdrawals': true, + 'withdraw': true, }, 'urls': { 'logo': 'https://user-images.githubusercontent.com/51840849/87295558-132aaf80-c50e-11ea-9801-a2fb0c57c799.jpg', @@ -74,6 +75,7 @@ module.exports = class kucoin extends Exchange { 'symbols', 'markets', 'market/allTickers', + 'market/orderbook/level{level}_{limit}', 'market/orderbook/level{level}', 'market/orderbook/level2', 'market/orderbook/level2_20', @@ -110,6 +112,7 @@ module.exports = class kucoin extends Exchange { 'withdrawals', 'withdrawals/quotas', 'orders', + 'order/client-order/{clientOid}', 'orders/{orderId}', 'limit/orders', 'fills', @@ -125,6 +128,9 @@ module.exports = class kucoin extends Exchange { 'margin/lend/assets', 'margin/market', 'margin/trade/last', + 'stop-order/{orderId}', + 'stop-order', + 'stop-order/queryOrderByClientOid', ], 'post': [ 'accounts', @@ -135,17 +141,23 @@ module.exports = class kucoin extends Exchange { 'orders', 'orders/multi', 'margin/borrow', + 'margin/order', 'margin/repay/all', 'margin/repay/single', 'margin/lend', 'margin/toggle-auto-lend', 'bullet-private', + 'stop-order', ], 'delete': [ 'withdrawals/{withdrawalId}', 'orders', + 'orders/client-order/{clientOid}', 'orders/{orderId}', 'margin/lend/{orderId}', + 'stop-order/cancelOrderByClientOid', + 'stop-order/{orderId}', + 'stop-order/cancel', ], }, }, @@ -236,10 +248,12 @@ module.exports = class kucoin extends Exchange { 'public': { 'GET': { 'status': 'v1', - 'market/orderbook/level{level}': 'v1', 'market/orderbook/level2': 'v2', + 'market/orderbook/level3': 'v2', 'market/orderbook/level2_20': 'v1', 'market/orderbook/level2_100': 'v1', + 'market/orderbook/level{level}': 'v2', + 'market/orderbook/level{level}_{limit}': 'v1', }, }, 'private': { @@ -682,7 +696,10 @@ module.exports = class kucoin extends Exchange { address = address.replace ('bitcoincash:', ''); } const tag = this.safeString (data, 'memo'); - this.checkAddress (address); + if (code !== 'NIM') { + // contains spaces + this.checkAddress (address); + } return { 'info': response, 'currency': code, @@ -699,13 +716,12 @@ module.exports = class kucoin extends Exchange { // BCH {"code":"200000","data":{"address":"bitcoincash:qza3m4nj9rx7l9r0cdadfqxts6f92shvhvr5ls4q7z","memo":""}} // BTC {"code":"200000","data":{"address":"36SjucKqQpQSvsak9A7h6qzFjrVXpRNZhE","memo":""}} const data = this.safeValue (response, 'data', {}); - let address = this.safeString (data, 'address'); - // BCH/BSV is returned with a "bitcoincash:" prefix, which we cut off here and only keep the address - if (address !== undefined) { - address = address.replace ('bitcoincash:', ''); - } + const address = this.safeString (data, 'address'); const tag = this.safeString (data, 'memo'); - this.checkAddress (address); + if (code !== 'NIM') { + // contains spaces + this.checkAddress (address); + } return { 'info': response, 'currency': code, @@ -719,20 +735,22 @@ module.exports = class kucoin extends Exchange { } async fetchOrderBook (symbol, limit = undefined, params = {}) { - const level = this.safeInteger (params, 'level', 2); - let levelLimit = level.toString (); - if (levelLimit === '2') { - if (limit !== undefined) { - if ((limit !== 20) && (limit !== 100)) { - throw new ExchangeError (this.id + ' fetchOrderBook limit argument must be undefined, 20 or 100'); - } - levelLimit += '_' + limit.toString (); - } - } await this.loadMarkets (); const marketId = this.marketId (symbol); - const request = { 'symbol': marketId, 'level': levelLimit }; - const response = await this.publicGetMarketOrderbookLevelLevel (this.extend (request, params)); + const level = this.safeInteger (params, 'level', 2); + const request = { 'symbol': marketId, 'level': level }; + let method = 'publicGetMarketOrderbookLevelLevel'; + if (level === 2) { + if (limit !== undefined) { + if ((limit === 20) || (limit === 100)) { + request['limit'] = limit; + method = 'publicGetMarketOrderbookLevelLevelLimit'; + } else { + throw new ExchangeError (this.id + ' fetchOrderBook limit argument must be undefined, 20 or 100'); + } + } + } + const response = await this[method] (this.extend (request, params)); // // 'market/orderbook/level2' // 'market/orderbook/level2_20' @@ -794,7 +812,29 @@ module.exports = class kucoin extends Exchange { 'clientOid': clientOrderId, 'side': side, 'symbol': marketId, - 'type': type, + 'type': type, // limit or market + // 'remark': '', // optional remark for the order, length cannot exceed 100 utf8 characters + // 'stp': '', // self trade prevention, CN, CO, CB or DC + // To improve the system performance and to accelerate order placing and processing, KuCoin has added a new interface for margin orders + // The current one will no longer accept margin orders by May 1st, 2021 (UTC) + // At the time, KuCoin will notify users via the announcement, please pay attention to it + // 'tradeType': 'TRADE', // TRADE, MARGIN_TRADE // not used with margin orders + // limit orders --------------------------------------------------- + // 'timeInForce': 'GTC', // GTC, GTT, IOC, or FOK (default is GTC), limit orders only + // 'cancelAfter': long, // cancel after n seconds, requires timeInForce to be GTT + // 'postOnly': false, // Post only flag, invalid when timeInForce is IOC or FOK + // 'hidden': false, // Order will not be displayed in the order book + // 'iceberg': false, // Only a portion of the order is displayed in the order book + // 'visibleSize': this.amountToPrecision (symbol, visibleSize), // The maximum visible size of an iceberg order + // market orders -------------------------------------------------- + // 'size': this.amountToPrecision (symbol, amount), // Amount in base currency + // 'funds': this.costToPrecision (symbol, cost), // Amount of quote currency to use + // stop orders ---------------------------------------------------- + // 'stop': 'loss', // loss or entry, the default is loss, requires stopPrice + // 'stopPrice': this.priceToPrecision (symbol, amount), // need to be defined if stop is specified + // margin orders -------------------------------------------------- + // 'marginMode': 'cross', // cross (cross mode) and isolated (isolated mode), set to cross by default, the isolated mode will be released soon, stay tuned + // 'autoBorrow': false, // The system will first borrow you funds at the optimal interest rate and then place an order for you }; if (type !== 'market') { request['price'] = this.priceToPrecision (symbol, price); @@ -846,9 +886,32 @@ module.exports = class kucoin extends Exchange { } async cancelOrder (id, symbol = undefined, params = {}) { - const request = { 'orderId': id }; - const response = await this.privateDeleteOrdersOrderId (this.extend (request, params)); - return response; + await this.loadMarkets (); + const request = {}; + const clientOrderId = this.safeString2 (params, 'clientOid', 'clientOrderId'); + let method = 'privateDeleteOrdersOrderId'; + if (clientOrderId !== undefined) { + request['clientOid'] = clientOrderId; + method = 'privateDeleteOrdersClientOrderClientOid'; + } else { + request['orderId'] = id; + } + params = this.omit (params, [ 'clientOid', 'clientOrderId' ]); + return await this[method] (this.extend (request, params)); + } + + async cancelAllOrders (symbol = undefined, params = {}) { + await this.loadMarkets (); + const request = { + // 'symbol': market['id'], + // 'tradeType': 'TRADE', // default is to cancel the spot trading order + }; + let market = undefined; + if (symbol !== undefined) { + market = this.market (symbol); + request['symbol'] = market['id']; + } + return await this.privateDeleteOrders (this.extend (request, params)); } async fetchOrdersByStatus (status, symbol = undefined, since = undefined, limit = undefined, params = {}) { @@ -926,20 +989,27 @@ module.exports = class kucoin extends Exchange { async fetchOrder (id, symbol = undefined, params = {}) { await this.loadMarkets (); - // a special case for undefined ids - // otherwise a wrong endpoint for all orders will be triggered - // https://github.com/ccxt/ccxt/issues/7234 - if (id === undefined) { - throw new InvalidOrder (this.id + ' fetchOrder requires an order id'); + const request = {}; + const clientOrderId = this.safeString2 (params, 'clientOid', 'clientOrderId'); + let method = 'privateGetOrdersOrderId'; + if (clientOrderId !== undefined) { + request['clientOid'] = clientOrderId; + method = 'privateGetOrdersClientOrderClientOid'; + } else { + // a special case for undefined ids + // otherwise a wrong endpoint for all orders will be triggered + // https://github.com/ccxt/ccxt/issues/7234 + if (id === undefined) { + throw new InvalidOrder (this.id + ' fetchOrder() requires an order id'); + } + request['orderId'] = id; } - const request = { - 'orderId': id, - }; + params = this.omit (params, [ 'clientOid', 'clientOrderId' ]); + const response = await this[method] (this.extend (request, params)); let market = undefined; if (symbol !== undefined) { market = this.market (symbol); } - const response = await this.privateGetOrdersOrderId (this.extend (request, params)); const responseData = this.safeValue (response, 'data'); return this.parseOrder (responseData, market); } @@ -1016,12 +1086,14 @@ module.exports = class kucoin extends Exchange { const clientOrderId = this.safeString (order, 'clientOid'); const timeInForce = this.safeString (order, 'timeInForce'); const stopPrice = this.safeFloat (order, 'stopPrice'); + const postOnly = this.safeValue (order, 'postOnly'); return { 'id': orderId, 'clientOrderId': clientOrderId, 'symbol': symbol, 'type': type, 'timeInForce': timeInForce, + 'postOnly': postOnly, 'side': side, 'amount': amount, 'price': price, @@ -1350,6 +1422,7 @@ module.exports = class kucoin extends Exchange { // "status": "SUCCESS", // "createdAt": 1544178843000, // "updatedAt": 1544178891000 + // "remark":"foobar" // } // // fetchWithdrawals @@ -1366,6 +1439,7 @@ module.exports = class kucoin extends Exchange { // "status": "FAILURE", // "createdAt": 1546503758000, // "updatedAt": 1546504603000 + // "remark":"foobar" // } // const currencyId = this.safeString (transaction, 'currency'); @@ -1416,20 +1490,26 @@ module.exports = class kucoin extends Exchange { updated = updated * 1000; } } + const comment = this.safeString (transaction, 'remark'); return { 'id': id, + 'info': transaction, + 'timestamp': timestamp, + 'datetime': this.iso8601 (timestamp), 'address': address, + 'addressTo': address, + 'addressFrom': undefined, 'tag': tag, + 'tagTo': tag, + 'tagFrom': undefined, 'currency': code, 'amount': amount, 'txid': txid, 'type': type, 'status': status, + 'comment': comment, 'fee': fee, - 'timestamp': timestamp, - 'datetime': this.iso8601 (timestamp), 'updated': updated, - 'info': transaction, }; } @@ -1477,6 +1557,7 @@ module.exports = class kucoin extends Exchange { // "status": "SUCCESS", // "createdAt": 1544178843000, // "updatedAt": 1544178891000 + // "remark":"foobar" // }, // //-------------------------------------------------- // // version 1 (historical) deposit response structure @@ -1606,7 +1687,7 @@ module.exports = class kucoin extends Exchange { async fetchLedger (code = undefined, since = undefined, limit = undefined, params = {}) { if (code === undefined) { - throw new ArgumentsRequired (this.id + ' fetchLedger requires a code param'); + throw new ArgumentsRequired (this.id + ' fetchLedger() requires a code param'); } await this.loadMarkets (); await this.loadAccounts (); @@ -1749,7 +1830,7 @@ module.exports = class kucoin extends Exchange { // † ↑ // const versions = this.safeValue (this.options, 'versions', {}); - const apiVersions = this.safeValue (versions, api); + const apiVersions = this.safeValue (versions, api, {}); const methodVersions = this.safeValue (apiVersions, method, {}); const defaultVersion = this.safeString (methodVersions, path, this.options['version']); const version = this.safeString (params, 'version', defaultVersion); @@ -1772,10 +1853,17 @@ module.exports = class kucoin extends Exchange { this.checkRequiredCredentials (); const timestamp = this.nonce ().toString (); headers = this.extend ({ + 'KC-API-KEY-VERSION': '2', 'KC-API-KEY': this.apiKey, 'KC-API-TIMESTAMP': timestamp, - 'KC-API-PASSPHRASE': this.password, }, headers); + const apiKeyVersion = this.safeString (headers, 'KC-API-KEY-VERSION'); + if (apiKeyVersion === '2') { + const passphrase = this.hmac (this.encode (this.password), this.encode (this.secret), 'sha256', 'base64'); + headers['KC-API-PASSPHRASE'] = passphrase; + } else { + headers['KC-API-PASSPHRASE'] = this.password; + } const payload = timestamp + method + endpoint + endpart; const signature = this.hmac (this.encode (payload), this.encode (this.secret), 'sha256', 'base64'); headers['KC-API-SIGN'] = signature; diff --git a/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/kuna.js b/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/kuna.js index 8b80f40a4..e652171d1 100644 --- a/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/kuna.js +++ b/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/kuna.js @@ -120,7 +120,7 @@ module.exports = class kuna extends acx { async fetchOpenOrders (symbol = undefined, since = undefined, limit = undefined, params = {}) { if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' fetchOpenOrders requires a symbol argument'); + throw new ArgumentsRequired (this.id + ' fetchOpenOrders() requires a symbol argument'); } await this.loadMarkets (); const market = this.market (symbol); @@ -182,7 +182,7 @@ module.exports = class kuna extends acx { async fetchMyTrades (symbol = undefined, since = undefined, limit = undefined, params = {}) { if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' fetchOpenOrders requires a symbol argument'); + throw new ArgumentsRequired (this.id + ' fetchMyTrades() requires a symbol argument'); } await this.loadMarkets (); const market = this.market (symbol); diff --git a/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/latoken.js b/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/latoken.js index f7e8b4a69..45cb5951d 100644 --- a/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/latoken.js +++ b/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/latoken.js @@ -534,7 +534,7 @@ module.exports = class latoken extends Exchange { async fetchMyTrades (symbol = undefined, since = undefined, limit = undefined, params = {}) { if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' fetchMyTrades requires a symbol argument'); + throw new ArgumentsRequired (this.id + ' fetchMyTrades() requires a symbol argument'); } await this.loadMarkets (); const market = this.market (symbol); @@ -646,6 +646,7 @@ module.exports = class latoken extends Exchange { 'symbol': symbol, 'type': type, 'timeInForce': undefined, + 'postOnly': undefined, 'side': side, 'price': price, 'stopPrice': undefined, @@ -680,7 +681,7 @@ module.exports = class latoken extends Exchange { async fetchOrdersWithMethod (method, symbol = undefined, since = undefined, limit = undefined, params = {}) { if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' fetchOrdersWithMethod requires a symbol argument'); + throw new ArgumentsRequired (this.id + ' fetchOrdersWithMethod() requires a symbol argument'); } await this.loadMarkets (); const market = this.market (symbol); @@ -796,7 +797,7 @@ module.exports = class latoken extends Exchange { async cancelAllOrders (symbol = undefined, params = {}) { if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' cancelAllOrders requires a symbol argument'); + throw new ArgumentsRequired (this.id + ' cancelAllOrders() requires a symbol argument'); } await this.loadMarkets (); const marketId = this.marketId (symbol); diff --git a/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/lbank.js b/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/lbank.js index c90433927..9b39a0236 100644 --- a/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/lbank.js +++ b/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/lbank.js @@ -358,10 +358,10 @@ module.exports = class lbank extends Exchange { await this.loadMarkets (); const market = this.market (symbol); if (since === undefined) { - throw new ArgumentsRequired (this.id + ' fetchOHLCV requires a `since` argument'); + throw new ArgumentsRequired (this.id + ' fetchOHLCV() requires a `since` argument'); } if (limit === undefined) { - throw new ArgumentsRequired (this.id + ' fetchOHLCV requires a `limit` argument'); + throw new ArgumentsRequired (this.id + ' fetchOHLCV() requires a `limit` argument'); } const request = { 'symbol': market['id'], @@ -486,6 +486,7 @@ module.exports = class lbank extends Exchange { 'symbol': symbol, 'type': type, 'timeInForce': undefined, + 'postOnly': undefined, 'side': side, 'price': price, 'stopPrice': undefined, diff --git a/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/liquid.js b/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/liquid.js index ddb1e0acc..732eda853 100644 --- a/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/liquid.js +++ b/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/liquid.js @@ -186,6 +186,7 @@ module.exports = class liquid extends Exchange { 'must_be_positive': InvalidOrder, 'less_than_order_size': InvalidOrder, 'price_too_high': InvalidOrder, + 'price_too_small': InvalidOrder, // {"errors":{"order":["price_too_small"]}} }, 'commonCurrencies': { 'WIN': 'WCOIN', @@ -723,7 +724,7 @@ module.exports = class liquid extends Exchange { async editOrder (id, symbol, type, side, amount, price = undefined, params = {}) { await this.loadMarkets (); if (price === undefined) { - throw new ArgumentsRequired (this.id + ' editOrder requires the price argument'); + throw new ArgumentsRequired (this.id + ' editOrder() requires the price argument'); } const request = { 'order': { @@ -864,6 +865,7 @@ module.exports = class liquid extends Exchange { 'lastTradeTimestamp': lastTradeTimestamp, 'type': type, 'timeInForce': undefined, + 'postOnly': undefined, 'status': status, 'symbol': symbol, 'side': side, diff --git a/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/livecoin.js b/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/livecoin.js deleted file mode 100644 index 0a8aa1aa0..000000000 --- a/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/livecoin.js +++ /dev/null @@ -1,931 +0,0 @@ -'use strict'; - -// --------------------------------------------------------------------------- - -const Exchange = require ('./base/Exchange'); -const { ExchangeError, OnMaintenance, BadResponse, ArgumentsRequired, AuthenticationError, NotSupported, InvalidOrder, OrderNotFound, ExchangeNotAvailable, RateLimitExceeded, InsufficientFunds } = require ('./base/errors'); -const { TRUNCATE, DECIMAL_PLACES } = require ('./base/functions/number'); - -// --------------------------------------------------------------------------- - -module.exports = class livecoin extends Exchange { - describe () { - return this.deepExtend (super.describe (), { - 'id': 'livecoin', - 'name': 'LiveCoin', - 'countries': [ 'US', 'UK', 'RU' ], - 'rateLimit': 1000, - 'userAgent': this.userAgents['chrome'], - 'has': { - 'cancelOrder': true, - 'CORS': false, - 'createOrder': true, - 'fetchBalance': true, - 'fetchClosedOrders': true, - 'fetchCurrencies': true, - 'fetchDepositAddress': true, - 'fetchDeposits': true, - 'fetchMarkets': true, - 'fetchMyTrades': true, - 'fetchOpenOrders': true, - 'fetchOrder': true, - 'fetchOrderBook': true, - 'fetchOrders': true, - 'fetchTicker': true, - 'fetchTickers': true, - 'fetchTrades': true, - 'fetchTradingFee': true, - 'fetchTradingFees': true, - 'fetchWithdrawals': true, - 'withdraw': true, - }, - 'urls': { - 'logo': 'https://user-images.githubusercontent.com/1294454/27980768-f22fc424-638a-11e7-89c9-6010a54ff9be.jpg', - 'api': 'https://api.livecoin.net', - 'www': 'https://www.livecoin.net', - 'doc': 'https://www.livecoin.net/api?lang=en', - 'referral': 'https://livecoin.net/?from=Livecoin-CQ1hfx44', - }, - 'api': { - 'public': { - 'get': [ - 'exchange/all/order_book', - 'exchange/last_trades', - 'exchange/maxbid_minask', - 'exchange/order_book', - 'exchange/restrictions', - 'exchange/ticker', // omit params to get all tickers at once - 'info/coinInfo', - ], - }, - 'private': { - 'get': [ - 'exchange/client_orders', - 'exchange/order', - 'exchange/trades', - 'exchange/commission', - 'exchange/commissionCommonInfo', - 'payment/balances', - 'payment/balance', - 'payment/get/address', - 'payment/history/size', - 'payment/history/transactions', - ], - 'post': [ - 'exchange/buylimit', - 'exchange/buymarket', - 'exchange/cancellimit', - 'exchange/selllimit', - 'exchange/sellmarket', - 'payment/out/capitalist', - 'payment/out/card', - 'payment/out/coin', - 'payment/out/okpay', - 'payment/out/payeer', - 'payment/out/perfectmoney', - 'payment/voucher/amount', - 'payment/voucher/make', - 'payment/voucher/redeem', - ], - }, - }, - 'fees': { - 'trading': { - 'tierBased': false, - 'percentage': true, - 'maker': 0.18 / 100, - 'taker': 0.18 / 100, - }, - }, - 'commonCurrencies': { - 'BIT': 'First Bitcoin', - 'BTCH': 'Bithash', - 'CPC': 'Capricoin', - 'CBC': 'CryptoBossCoin', // conflict with CBC (CashBet Coin) - 'CPT': 'Cryptos', // conflict with CPT = Contents Protocol https://github.com/ccxt/ccxt/issues/4920 and https://github.com/ccxt/ccxt/issues/6081 - 'EDR': 'E-Dinar Coin', // conflicts with EDR for Endor Protocol and EDRCoin - 'eETT': 'EETT', - 'FirstBlood': '1ST', - 'FORTYTWO': '42', - 'LEO': 'LeoCoin', - 'MIOTA': 'IOTA', // https://github.com/ccxt/ccxt/issues/7487 - 'ORE': 'Orectic', - 'PLN': 'Plutaneum', // conflict with Polish Zloty - 'RUR': 'RUB', - 'SCT': 'SpaceCoin', - 'TPI': 'ThaneCoin', - 'UNUS': 'LEO', // https://github.com/ccxt/ccxt/issues/7496 - 'WAX': 'WAXP', - 'wETT': 'WETT', - 'XBT': 'Bricktox', - }, - 'exceptions': { - 'exact': { - '1': ExchangeError, - '10': AuthenticationError, - '100': ExchangeError, // invalid parameters - '101': AuthenticationError, - '102': AuthenticationError, - '103': InvalidOrder, // invalid currency - '104': InvalidOrder, // invalid amount - '105': InvalidOrder, // unable to block funds - '11': AuthenticationError, - '12': AuthenticationError, - '2': AuthenticationError, // "User not found" - '20': AuthenticationError, - '30': AuthenticationError, - '31': NotSupported, - '32': ExchangeError, - '429': RateLimitExceeded, - '503': ExchangeNotAvailable, - }, - 'broad': { - 'insufficient funds': InsufficientFunds, // https://github.com/ccxt/ccxt/issues/5749 - 'NOT FOUND': OrderNotFound, - 'Cannot find order': OrderNotFound, - 'Minimal amount is': InvalidOrder, - }, - }, - }); - } - - async fetchMarkets (params = {}) { - const response = await this.publicGetExchangeTicker (params); - const restrictions = await this.publicGetExchangeRestrictions (); - const restrictionsById = this.indexBy (restrictions['restrictions'], 'currencyPair'); - const result = []; - for (let i = 0; i < response.length; i++) { - const market = response[i]; - const id = this.safeString (market, 'symbol'); - const [ baseId, quoteId ] = id.split ('/'); - const base = this.safeCurrencyCode (baseId); - const quote = this.safeCurrencyCode (quoteId); - const symbol = base + '/' + quote; - const coinRestrictions = this.safeValue (restrictionsById, symbol); - const precision = { - 'price': 5, - 'amount': 8, - 'cost': 8, - }; - const limits = { - 'amount': { - 'min': Math.pow (10, -precision['amount']), - 'max': Math.pow (10, precision['amount']), - }, - }; - if (coinRestrictions) { - precision['price'] = this.safeInteger (coinRestrictions, 'priceScale', 5); - limits['amount']['min'] = this.safeFloat (coinRestrictions, 'minLimitQuantity', limits['amount']['min']); - } - limits['price'] = { - 'min': Math.pow (10, -precision['price']), - 'max': Math.pow (10, precision['price']), - }; - result.push ({ - 'id': id, - 'symbol': symbol, - 'base': base, - 'quote': quote, - 'baseId': baseId, - 'quoteId': quoteId, - 'active': true, - 'precision': precision, - 'limits': limits, - 'info': market, - }); - } - return result; - } - - async fetchCurrencies (params = {}) { - const response = await this.publicGetInfoCoinInfo (params); - if (typeof response === 'string') { - if (response.indexOf ('site is under maintenance') >= 0) { - throw new OnMaintenance (this.id + ' fetchCurrencies() failed to fetch the currencies, the exchange is on maintenance'); - } else { - throw new BadResponse (this.id + ' fetchCurrencies() failed to fetch the currencies'); - } - } - const currencies = this.safeValue (response, 'info'); - let result = {}; - for (let i = 0; i < currencies.length; i++) { - const currency = currencies[i]; - const id = this.safeString (currency, 'symbol'); - // todo: will need to rethink the fees - // to add support for multiple withdrawal/deposit methods and - // differentiated fees for each particular method - const code = this.safeCurrencyCode (id); - const precision = 8; // default precision, todo: fix "magic constants" - const walletStatus = this.safeString (currency, 'walletStatus'); - const active = (walletStatus === 'normal'); - const name = this.safeString (currency, 'name'); - const fee = this.safeFloat (currency, 'withdrawFee'); - result[code] = { - 'id': id, - 'code': code, - 'info': currency, - 'name': name, - 'active': active, - 'fee': fee, - 'precision': precision, - 'limits': { - 'amount': { - 'min': this.safeFloat (currency, 'minOrderAmount'), - 'max': Math.pow (10, precision), - }, - 'price': { - 'min': Math.pow (10, -precision), - 'max': Math.pow (10, precision), - }, - 'cost': { - 'min': this.safeFloat (currency, 'minOrderAmount'), - 'max': undefined, - }, - 'withdraw': { - 'min': this.safeFloat (currency, 'minWithdrawAmount'), - 'max': Math.pow (10, precision), - }, - 'deposit': { - 'min': this.safeFloat (currency, 'minDepositAmount'), - 'max': undefined, - }, - }, - }; - } - result = this.appendFiatCurrencies (result); - return result; - } - - appendFiatCurrencies (result) { - const precision = 8; - const defaults = { - 'info': undefined, - 'active': true, - 'fee': undefined, - 'precision': precision, - 'limits': { - 'withdraw': { 'min': undefined, 'max': undefined }, - 'deposit': { 'min': undefined, 'max': undefined }, - 'amount': { 'min': undefined, 'max': undefined }, - 'cost': { 'min': undefined, 'max': undefined }, - 'price': { - 'min': Math.pow (10, -precision), - 'max': Math.pow (10, precision), - }, - }, - 'id': undefined, - 'code': undefined, - 'name': undefined, - }; - const currencies = [ - { 'id': 'USD', 'code': 'USD', 'name': 'US Dollar' }, - { 'id': 'EUR', 'code': 'EUR', 'name': 'Euro' }, - // { 'id': 'RUR', 'code': 'RUB', 'name': 'Russian ruble' }, - ]; - currencies.push ({ - 'id': 'RUR', - 'code': this.safeCurrencyCode ('RUR'), - 'name': 'Russian ruble', - }); - for (let i = 0; i < currencies.length; i++) { - const currency = currencies[i]; - const code = currency['code']; - result[code] = this.extend (defaults, currency); - } - return result; - } - - async fetchBalance (params = {}) { - await this.loadMarkets (); - const response = await this.privateGetPaymentBalances (params); - const result = { 'info': response }; - for (let i = 0; i < response.length; i++) { - const balance = response[i]; - const currencyId = this.safeString (balance, 'currency'); - const code = this.safeCurrencyCode (currencyId); - let account = undefined; - if (code in result) { - account = result[code]; - } else { - account = this.account (); - } - if (balance['type'] === 'total') { - account['total'] = this.safeFloat (balance, 'value'); - } - if (balance['type'] === 'available') { - account['free'] = this.safeFloat (balance, 'value'); - } - if (balance['type'] === 'trade') { - account['used'] = this.safeFloat (balance, 'value'); - } - result[code] = account; - } - return this.parseBalance (result); - } - - async fetchTradingFees (params = {}) { - await this.loadMarkets (); - const response = await this.privateGetExchangeCommissionCommonInfo (params); - const commission = this.safeFloat (response, 'commission'); - return { - 'info': response, - 'maker': commission, - 'taker': commission, - }; - } - - async fetchOrderBook (symbol, limit = undefined, params = {}) { - await this.loadMarkets (); - const request = { - 'currencyPair': this.marketId (symbol), - 'groupByPrice': 'false', - }; - if (limit !== undefined) { - request['depth'] = limit; // 100 - } - const response = await this.publicGetExchangeOrderBook (this.extend (request, params)); - const timestamp = this.safeInteger (response, 'timestamp'); - return this.parseOrderBook (response, timestamp); - } - - parseTicker (ticker, market = undefined) { - const timestamp = this.milliseconds (); - let symbol = undefined; - if (market) { - symbol = market['symbol']; - } - const vwap = this.safeFloat (ticker, 'vwap'); - const baseVolume = this.safeFloat (ticker, 'volume'); - let quoteVolume = undefined; - if (baseVolume !== undefined && vwap !== undefined) { - quoteVolume = baseVolume * vwap; - } - const last = this.safeFloat (ticker, 'last'); - return { - 'symbol': symbol, - 'timestamp': timestamp, - 'datetime': this.iso8601 (timestamp), - 'high': this.safeFloat (ticker, 'high'), - 'low': this.safeFloat (ticker, 'low'), - 'bid': this.safeFloat (ticker, 'best_bid'), - 'bidVolume': undefined, - 'ask': this.safeFloat (ticker, 'best_ask'), - 'askVolume': undefined, - 'vwap': this.safeFloat (ticker, 'vwap'), - 'open': undefined, - 'close': last, - 'last': last, - 'previousClose': undefined, - 'change': undefined, - 'percentage': undefined, - 'average': undefined, - 'baseVolume': baseVolume, - 'quoteVolume': quoteVolume, - 'info': ticker, - }; - } - - async fetchTickers (symbols = undefined, params = {}) { - await this.loadMarkets (); - const response = await this.publicGetExchangeTicker (params); - const tickers = this.indexBy (response, 'symbol'); - const ids = Object.keys (tickers); - const result = {}; - for (let i = 0; i < ids.length; i++) { - const id = ids[i]; - const market = this.safeMarket (id); - const symbol = market['symbol']; - const ticker = tickers[id]; - result[symbol] = this.parseTicker (ticker, market); - } - return this.filterByArray (result, 'symbol', symbols); - } - - async fetchTicker (symbol, params = {}) { - await this.loadMarkets (); - const market = this.market (symbol); - const request = { - 'currencyPair': market['id'], - }; - const ticker = await this.publicGetExchangeTicker (this.extend (request, params)); - return this.parseTicker (ticker, market); - } - - parseTrade (trade, market = undefined) { - // - // fetchTrades (public) - // - // { - // "time": 1409935047, - // "id": 99451, - // "price": 350, - // "quantity": 2.85714285, - // "type": "BUY" - // } - // - // fetchMyTrades (private) - // - // { - // "datetime": 1435844369, - // "id": 30651619, - // "type": "sell", - // "symbol": "BTC/EUR", - // "price": 230, - // "quantity": 0.1, - // "commission": 0, - // "clientorderid": 1472837650 - // } - const timestamp = this.safeTimestamp2 (trade, 'time', 'datetime'); - let fee = undefined; - const feeCost = this.safeFloat (trade, 'commission'); - if (feeCost !== undefined) { - const feeCurrency = market ? market['quote'] : undefined; - fee = { - 'cost': feeCost, - 'currency': feeCurrency, - }; - } - const orderId = this.safeString (trade, 'clientorderid'); - const id = this.safeString (trade, 'id'); - const side = this.safeStringLower (trade, 'type'); - const amount = this.safeFloat (trade, 'quantity'); - const price = this.safeFloat (trade, 'price'); - let cost = undefined; - if (amount !== undefined) { - if (price !== undefined) { - cost = amount * price; - } - } - const marketId = this.safeString (trade, 'symbol'); - const symbol = this.safeSymbol (marketId, market, '/'); - return { - 'id': id, - 'info': trade, - 'timestamp': timestamp, - 'datetime': this.iso8601 (timestamp), - 'symbol': symbol, - 'order': orderId, - 'type': undefined, - 'side': side, - 'takerOrMaker': undefined, - 'price': price, - 'amount': amount, - 'cost': cost, - 'fee': fee, - }; - } - - async fetchMyTrades (symbol = undefined, since = undefined, limit = undefined, params = {}) { - await this.loadMarkets (); - const request = { - // 'currencyPair': market['id'], - // 'orderDesc': 'true', // or 'false', if true then new orders will be first, otherwise old orders will be first. - // 'offset': 0, // page offset, position of the first item on the page - }; - let market = undefined; - if (symbol !== undefined) { - market = this.market (symbol); - request['currencyPair'] = market['id']; - } - if (limit !== undefined) { - request['limit'] = limit; - } - const response = await this.privateGetExchangeTrades (this.extend (request, params)); - // - // [ - // { - // "datetime": 1435844369, - // "id": 30651619, - // "type": "sell", - // "symbol": "BTC/EUR", - // "price": 230, - // "quantity": 0.1, - // "commission": 0, - // "clientorderid": 1472837650 - // }, - // { - // "datetime": 1435844356, - // "id": 30651618, - // "type": "sell", - // "symbol": "BTC/EUR", - // "price": 230, - // "quantity": 0.2, - // "commission": 0.092, - // "clientorderid": 1472837651 - // } - // ] - // - return this.parseTrades (response, market, since, limit); - } - - async fetchTrades (symbol, since = undefined, limit = undefined, params = {}) { - await this.loadMarkets (); - const market = this.market (symbol); - const request = { - 'currencyPair': market['id'], - }; - const response = await this.publicGetExchangeLastTrades (this.extend (request, params)); - // - // [ - // { - // "time": 1409935047, - // "id": 99451, - // "price": 350, - // "quantity": 2.85714285, - // "type": "BUY" - // }, - // { - // "time": 1409934792, - // "id": 99450, - // "price": 350, - // "quantity": 0.57142857, - // "type": "SELL" - // } - // ] - // - return this.parseTrades (response, market, since, limit); - } - - async fetchOrder (id, symbol = undefined, params = {}) { - await this.loadMarkets (); - const request = { - 'orderId': id, - }; - const response = await this.privateGetExchangeOrder (this.extend (request, params)); - return this.parseOrder (response); - } - - parseOrderStatus (status) { - const statuses = { - 'OPEN': 'open', - 'PARTIALLY_FILLED': 'open', - 'EXECUTED': 'closed', - 'CANCELLED': 'canceled', - 'PARTIALLY_FILLED_AND_CANCELLED': 'canceled', - }; - return this.safeString (statuses, status, status); - } - - parseOrder (order, market = undefined) { - let timestamp = undefined; - if ('lastModificationTime' in order) { - timestamp = this.safeString (order, 'lastModificationTime'); - if (timestamp !== undefined) { - if (timestamp.indexOf ('T') >= 0) { - timestamp = this.parse8601 (timestamp); - } else { - timestamp = this.safeInteger (order, 'lastModificationTime'); - } - } - } - // TODO currently not supported by livecoin - // let trades = this.parseTrades (order['trades'], market, since, limit); - const trades = undefined; - const status = this.parseOrderStatus (this.safeString2 (order, 'status', 'orderStatus')); - const marketId = this.safeString2 (order, 'symbol', 'currencyPair'); - const symbol = this.safeSymbol (marketId, market, '/'); - let type = this.safeStringLower (order, 'type'); - let side = undefined; - if (type !== undefined) { - const orderType = type.split ('_'); - type = orderType[0]; - side = orderType[1]; - } - const price = this.safeFloat (order, 'price'); - // of the next two lines the latter overrides the former, if present in the order structure - let remaining = this.safeFloat (order, 'remainingQuantity'); - remaining = this.safeFloat (order, 'remaining_quantity', remaining); - const amount = this.safeFloat (order, 'quantity', remaining); - let filled = undefined; - if (remaining !== undefined) { - filled = amount - remaining; - } - let cost = undefined; - if (filled !== undefined && price !== undefined) { - cost = filled * price; - } - const feeRate = this.safeFloat (order, 'commission_rate'); - let feeCost = undefined; - if (cost !== undefined && feeRate !== undefined) { - feeCost = cost * feeRate; - } - if ((market === undefined) && (symbol in this.markets)) { - market = this.markets[symbol]; - } - let feeCurrency = undefined; - if (market !== undefined) { - feeCurrency = market['quote']; - } - return { - 'info': order, - 'id': order['id'], - 'clientOrderId': undefined, - 'timestamp': timestamp, - 'datetime': this.iso8601 (timestamp), - 'lastTradeTimestamp': undefined, - 'status': status, - 'symbol': symbol, - 'type': type, - 'timeInForce': undefined, - 'side': side, - 'price': price, - 'stopPrice': undefined, - 'amount': amount, - 'cost': cost, - 'filled': filled, - 'remaining': remaining, - 'trades': trades, - 'fee': { - 'cost': feeCost, - 'currency': feeCurrency, - 'rate': feeRate, - }, - 'average': undefined, - }; - } - - async fetchOrders (symbol = undefined, since = undefined, limit = undefined, params = {}) { - await this.loadMarkets (); - let market = undefined; - const request = {}; - if (symbol !== undefined) { - market = this.market (symbol); - request['currencyPair'] = market['id']; - } - if (since !== undefined) { - request['issuedFrom'] = parseInt (since); - } - if (limit !== undefined) { - request['endRow'] = limit - 1; - } - const response = await this.privateGetExchangeClientOrders (this.extend (request, params)); - const result = []; - let rawOrders = []; - if (response['data']) { - rawOrders = response['data']; - } - for (let i = 0; i < rawOrders.length; i++) { - const order = rawOrders[i]; - result.push (this.parseOrder (order, market)); - } - return this.sortBy (result, 'timestamp'); - } - - async fetchOpenOrders (symbol = undefined, since = undefined, limit = undefined, params = {}) { - const request = { - 'openClosed': 'OPEN', - }; - return await this.fetchOrders (symbol, since, limit, this.extend (request, params)); - } - - async fetchClosedOrders (symbol = undefined, since = undefined, limit = undefined, params = {}) { - const request = { - 'openClosed': 'CLOSED', - }; - return await this.fetchOrders (symbol, since, limit, this.extend (request, params)); - } - - async createOrder (symbol, type, side, amount, price = undefined, params = {}) { - await this.loadMarkets (); - const method = 'privatePostExchange' + this.capitalize (side) + type; - const market = this.market (symbol); - const request = { - 'quantity': this.amountToPrecision (symbol, amount), - 'currencyPair': market['id'], - }; - if (type === 'limit') { - request['price'] = this.priceToPrecision (symbol, price); - } - const response = await this[method] (this.extend (request, params)); - const result = { - 'info': response, - 'id': response['orderId'].toString (), - }; - const success = this.safeValue (response, 'success'); - if (success) { - result['status'] = 'open'; - } - return result; - } - - async cancelOrder (id, symbol = undefined, params = {}) { - if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' cancelOrder requires a symbol argument'); - } - await this.loadMarkets (); - const market = this.market (symbol); - const request = { - 'orderId': id, - 'currencyPair': market['id'], - }; - const response = await this.privatePostExchangeCancellimit (this.extend (request, params)); - const message = this.safeString (response, 'message', this.json (response)); - if ('success' in response) { - if (!response['success']) { - throw new InvalidOrder (message); - } else if ('cancelled' in response) { - if (response['cancelled']) { - return { - 'status': 'canceled', - 'info': response, - }; - } else { - throw new OrderNotFound (message); - } - } - } - throw new ExchangeError (this.id + ' cancelOrder() failed: ' + this.json (response)); - } - - async withdraw (code, amount, address, tag = undefined, params = {}) { - // Sometimes the response with be { key: null } for all keys. - // An example is if you attempt to withdraw more than is allowed when withdrawal fees are considered. - this.checkAddress (address); - await this.loadMarkets (); - const currency = this.currency (code); - let wallet = address; - if (tag !== undefined) { - wallet += '::' + tag; - } - const request = { - 'amount': this.decimalToPrecision (amount, TRUNCATE, currency['precision'], DECIMAL_PLACES), - 'currency': currency['id'], - 'wallet': wallet, - }; - const response = await this.privatePostPaymentOutCoin (this.extend (request, params)); - const id = this.safeInteger (response, 'id'); - if (id === undefined) { - throw new InsufficientFunds (this.id + ' insufficient funds to cover requested withdrawal amount post fees ' + this.json (response)); - } - return { - 'info': response, - 'id': id, - }; - } - - parseTransaction (transaction, currency = undefined) { - // { - // "id": "c853093d5aa06df1c92d79c2...", (tx on deposits, address on withdrawals) - // "type": "DEPOSIT", - // "date": 1553186482676, - // "amount": 712.61266, - // "fee": 0, - // "fixedCurrency": "XVG", - // "taxCurrency": "XVG", - // "variableAmount": null, - // "variableCurrency": null, - // "external": "Coin", - // "login": "USERNAME", - // "externalKey": "....87diPBy......3hTtuwUT78Yi", (address on deposits, tx on withdrawals) - // "documentId": 1110662453 - // }, - let txid = undefined; - let address = undefined; - const id = this.safeString (transaction, 'documentId'); - const amount = this.safeFloat (transaction, 'amount'); - const timestamp = this.safeInteger (transaction, 'date'); - const type = this.safeStringLower (transaction, 'type'); - const currencyId = this.safeString (transaction, 'fixedCurrency'); - const feeCost = this.safeFloat (transaction, 'fee'); - const code = this.safeCurrencyCode (currencyId, currency); - if (type === 'withdrawal') { - txid = this.safeString (transaction, 'externalKey'); - address = this.safeString (transaction, 'id'); - } else if (type === 'deposit') { - address = this.safeString (transaction, 'externalKey'); - txid = this.safeString (transaction, 'id'); - } - let status = undefined; - if (type === 'deposit') { - status = 'ok'; // Deposits is not registered until they are in account. Withdrawals are left as undefined, not entirely sure about theyre status. - } - return { - 'info': transaction, - 'id': id, - 'currency': code, - 'amount': amount, - 'address': address, - 'tag': undefined, - 'status': status, - 'type': type, - 'updated': undefined, - 'txid': txid, - 'timestamp': timestamp, - 'datetime': this.iso8601 (timestamp), - 'fee': { - 'currency': code, - 'cost': feeCost, - }, - }; - } - - async fetchDeposits (code = undefined, since = undefined, limit = undefined, params = {}) { - await this.loadMarkets (); - const endtime = 2505600000; // 29 days - exchange has maximum 30 days. - const now = this.milliseconds (); - const request = { - 'types': 'DEPOSIT', - 'end': now, - 'start': (since !== undefined) ? parseInt (since) : now - endtime, - }; - let currency = undefined; - if (code !== undefined) { - currency = this.currency (code); - } - if (limit !== undefined) { - request['limit'] = limit; // default is 100 - } - const response = await this.privateGetPaymentHistoryTransactions (this.extend (request, params)); - return this.parseTransactions (response, currency, since, limit); - } - - async fetchWithdrawals (code = undefined, since = undefined, limit = undefined, params = {}) { - await this.loadMarkets (); - const endtime = 2505600000; // 29 days - exchange has maximum 30 days. - const now = this.milliseconds (); - const request = { - 'types': 'WITHDRAWAL', - 'end': now, - 'start': (since !== undefined) ? parseInt (since) : now - endtime, - }; - let currency = undefined; - if (code !== undefined) { - currency = this.currency (code); - } - if (limit !== undefined) { - request['limit'] = limit; // default is 100 - } - if (since !== undefined) { - request['start'] = since; - } - const response = await this.privateGetPaymentHistoryTransactions (this.extend (request, params)); - return this.parseTransactions (response, currency, since, limit); - } - - async fetchDepositAddress (currency, params = {}) { - const request = { - 'currency': currency, - }; - const response = await this.privateGetPaymentGetAddress (this.extend (request, params)); - let address = this.safeString (response, 'wallet'); - let tag = undefined; - if (address.indexOf (':') >= 0) { - const parts = address.split (':'); - address = parts[0]; - tag = parts[2]; - } - this.checkAddress (address); - return { - 'currency': currency, - 'address': address, - 'tag': tag, - 'info': response, - }; - } - - sign (path, api = 'public', method = 'GET', params = {}, headers = undefined, body = undefined) { - let url = this.urls['api'] + '/' + path; - const query = this.urlencode (this.keysort (params)); - if (method === 'GET') { - if (Object.keys (params).length) { - url += '?' + query; - } - } - if (api === 'private') { - this.checkRequiredCredentials (); - if (method === 'POST') { - body = query; - } - const signature = this.hmac (this.encode (query), this.encode (this.secret), 'sha256'); - headers = { - 'Api-Key': this.apiKey, - 'Sign': signature.toUpperCase (), - 'Content-Type': 'application/x-www-form-urlencoded', - }; - } - return { 'url': url, 'method': method, 'body': body, 'headers': headers }; - } - - handleErrors (code, reason, url, method, headers, body, response, requestHeaders, requestBody) { - if (response === undefined) { - return; // fallback to default error handler - } - if (code >= 300) { - const feedback = this.id + ' ' + body; - const errorCode = this.safeString (response, 'errorCode'); - this.throwExactlyMatchedException (this.exceptions['exact'], errorCode, feedback); - throw new ExchangeError (feedback); - } - // returns status code 200 even if success === false - const success = this.safeValue (response, 'success', true); - if (!success) { - const feedback = this.id + ' ' + body; - const message = this.safeString2 (response, 'message', 'exception'); - if (message !== undefined) { - this.throwBroadlyMatchedException (this.exceptions['broad'], message, feedback); - } - throw new ExchangeError (feedback); - } - } -}; - diff --git a/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/luno.js b/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/luno.js index 068e1c184..2bbec0ec1 100644 --- a/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/luno.js +++ b/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/luno.js @@ -38,7 +38,11 @@ module.exports = class luno extends Exchange { 'urls': { 'referral': 'https://www.luno.com/invite/44893A', 'logo': 'https://user-images.githubusercontent.com/1294454/27766607-8c1a69d8-5ede-11e7-930c-540b5eb9be24.jpg', - 'api': 'https://api.luno.com/api', + 'api': { + 'public': 'https://api.luno.com/api', + 'private': 'https://api.luno.com/api', + 'exchange': 'https://api.luno.com/api/exchange', + }, 'www': 'https://www.luno.com', 'doc': [ 'https://www.luno.com/en/api', @@ -47,6 +51,11 @@ module.exports = class luno extends Exchange { ], }, 'api': { + 'exchange': { + 'get': [ + 'markets', + ], + }, 'public': { 'get': [ 'orderbook', @@ -97,16 +106,42 @@ module.exports = class luno extends Exchange { } async fetchMarkets (params = {}) { - const response = await this.publicGetTickers (params); + const response = await this.exchangeGetMarkets (params); + // + // { + // "markets":[ + // { + // "market_id":"BCHXBT", + // "trading_status":"ACTIVE", + // "base_currency":"BCH", + // "counter_currency":"XBT", + // "min_volume":"0.01", + // "max_volume":"100.00", + // "volume_scale":2, + // "min_price":"0.0001", + // "max_price":"1.00", + // "price_scale":6, + // "fee_scale":8, + // }, + // ] + // } + // const result = []; - for (let i = 0; i < response['tickers'].length; i++) { - const market = response['tickers'][i]; - const id = market['pair']; - const baseId = id.slice (0, 3); - const quoteId = id.slice (3, 6); + const markets = this.safeValue (response, 'markets', []); + for (let i = 0; i < markets.length; i++) { + const market = markets[i]; + const id = this.safeString (market, 'market_id'); + const baseId = this.safeString (market, 'base_currency'); + const quoteId = this.safeString (market, 'counter_currency'); const base = this.safeCurrencyCode (baseId); const quote = this.safeCurrencyCode (quoteId); const symbol = base + '/' + quote; + const status = this.safeString (market, 'trading_status'); + const active = (status === 'ACTIVE'); + const precision = { + 'amount': this.safeInteger (market, 'volume_scale'), + 'price': this.safeInteger (market, 'price_scale'), + }; result.push ({ 'id': id, 'symbol': symbol, @@ -114,10 +149,23 @@ module.exports = class luno extends Exchange { 'quote': quote, 'baseId': baseId, 'quoteId': quoteId, + 'active': active, + 'precision': precision, + 'limits': { + 'amount': { + 'min': this.safeFloat (market, 'min_volume'), + 'max': this.safeFloat (market, 'max_volume'), + }, + 'price': { + 'min': this.safeFloat (market, 'min_price'), + 'max': this.safeFloat (market, 'max_price'), + }, + 'cost': { + 'min': undefined, + 'max': undefined, + }, + }, 'info': market, - 'active': undefined, - 'precision': this.precision, - 'limits': this.limits, }); } return result; @@ -145,6 +193,16 @@ module.exports = class luno extends Exchange { async fetchBalance (params = {}) { await this.loadMarkets (); const response = await this.privateGetBalance (params); + // + // { + // 'balance': [ + // {'account_id': '119...1336','asset': 'XBT','balance': '0.00','reserved': '0.00','unconfirmed': '0.00'}, + // {'account_id': '66...289','asset': 'XBT','balance': '0.00','reserved': '0.00','unconfirmed': '0.00'}, + // {'account_id': '718...5300','asset': 'ETH','balance': '0.00','reserved': '0.00','unconfirmed': '0.00'}, + // {'account_id': '818...7072','asset': 'ZAR','balance': '0.001417','reserved': '0.00','unconfirmed': '0.00'}]} + // ] + // } + // const wallets = this.safeValue (response, 'balance', []); const result = { 'info': response }; for (let i = 0; i < wallets.length; i++) { @@ -154,10 +212,15 @@ module.exports = class luno extends Exchange { const reserved = this.safeFloat (wallet, 'reserved'); const unconfirmed = this.safeFloat (wallet, 'unconfirmed'); const balance = this.safeFloat (wallet, 'balance'); - const account = this.account (); - account['used'] = this.sum (reserved, unconfirmed); - account['total'] = this.sum (balance, unconfirmed); - result[code] = account; + if (code in result) { + result[code]['used'] = this.sum (result[code]['used'], reserved, unconfirmed); + result[code]['total'] = this.sum (result[code]['total'], balance, unconfirmed); + } else { + const account = this.account (); + account['used'] = this.sum (reserved, unconfirmed); + account['total'] = this.sum (balance, unconfirmed); + result[code] = account; + } } return this.parseBalance (result); } @@ -245,6 +308,7 @@ module.exports = class luno extends Exchange { 'symbol': symbol, 'type': undefined, 'timeInForce': undefined, + 'postOnly': undefined, 'side': side, 'price': price, 'stopPrice': undefined, @@ -425,7 +489,7 @@ module.exports = class luno extends Exchange { async fetchMyTrades (symbol = undefined, since = undefined, limit = undefined, params = {}) { if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' fetchMyTrades requires a symbol argument'); + throw new ArgumentsRequired (this.id + ' fetchMyTrades() requires a symbol argument'); } await this.loadMarkets (); const market = this.market (symbol); @@ -462,15 +526,16 @@ module.exports = class luno extends Exchange { if (type === 'market') { method += 'Marketorder'; request['type'] = side.toUpperCase (); + // todo add createMarketBuyOrderRequires price logic as it is implemented in the other exchanges if (side === 'buy') { - request['counter_volume'] = amount; + request['counter_volume'] = parseFloat (this.amountToPrecision (symbol, amount)); } else { - request['base_volume'] = amount; + request['base_volume'] = parseFloat (this.amountToPrecision (symbol, amount)); } } else { method += 'Postorder'; - request['volume'] = amount; - request['price'] = price; + request['volume'] = parseFloat (this.amountToPrecision (symbol, amount)); + request['price'] = parseFloat (this.priceToPrecision (symbol, price)); request['type'] = (side === 'buy') ? 'BID' : 'ASK'; } const response = await this[method] (this.extend (request, params)); @@ -629,7 +694,7 @@ module.exports = class luno extends Exchange { } sign (path, api = 'public', method = 'GET', params = {}, headers = undefined, body = undefined) { - let url = this.urls['api'] + '/' + this.version + '/' + this.implodeParams (path, params); + let url = this.urls['api'][api] + '/' + this.version + '/' + this.implodeParams (path, params); const query = this.omit (params, this.extractParams (path)); if (Object.keys (query).length) { url += '?' + this.urlencode (query); diff --git a/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/lykke.js b/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/lykke.js index c513b8d80..edc0fe73a 100644 --- a/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/lykke.js +++ b/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/lykke.js @@ -499,6 +499,7 @@ module.exports = class lykke extends Exchange { 'symbol': symbol, 'type': undefined, 'timeInForce': undefined, + 'postOnly': undefined, 'side': side, 'price': price, 'stopPrice': undefined, diff --git a/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/mercado.js b/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/mercado.js index 228e82f69..a2fd9593e 100644 --- a/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/mercado.js +++ b/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/mercado.js @@ -21,6 +21,8 @@ module.exports = class mercado extends Exchange { 'createMarketOrder': true, 'createOrder': true, 'fetchBalance': true, + 'fetchMarkets': true, + 'fetchMyTrades': 'emulated', 'fetchOHLCV': true, 'fetchOpenOrders': true, 'fetchOrder': true, @@ -60,6 +62,7 @@ module.exports = class mercado extends Exchange { 'api': { 'public': { 'get': [ + 'coins', '{coin}/orderbook/', // last slash critical '{coin}/ticker/', '{coin}/trades/', @@ -90,23 +93,90 @@ module.exports = class mercado extends Exchange { ], }, }, - 'markets': { - 'BTC/BRL': { 'id': 'BRLBTC', 'symbol': 'BTC/BRL', 'base': 'BTC', 'quote': 'BRL', 'precision': { 'amount': 8, 'price': 5 }, 'suffix': 'Bitcoin' }, - 'LTC/BRL': { 'id': 'BRLLTC', 'symbol': 'LTC/BRL', 'base': 'LTC', 'quote': 'BRL', 'precision': { 'amount': 8, 'price': 5 }, 'suffix': 'Litecoin' }, - 'BCH/BRL': { 'id': 'BRLBCH', 'symbol': 'BCH/BRL', 'base': 'BCH', 'quote': 'BRL', 'precision': { 'amount': 8, 'price': 5 }, 'suffix': 'BCash' }, - 'XRP/BRL': { 'id': 'BRLXRP', 'symbol': 'XRP/BRL', 'base': 'XRP', 'quote': 'BRL', 'precision': { 'amount': 8, 'price': 5 }, 'suffix': 'Ripple' }, - 'ETH/BRL': { 'id': 'BRLETH', 'symbol': 'ETH/BRL', 'base': 'ETH', 'quote': 'BRL', 'precision': { 'amount': 8, 'price': 5 }, 'suffix': 'Ethereum' }, - 'USDC/BRL': { 'id': 'BRLUSDC', 'symbol': 'USDC/BRL', 'base': 'USDC', 'quote': 'BRL', 'precision': { 'amount': 8, 'price': 5 }, 'suffix': 'USDC' }, - }, 'fees': { 'trading': { - 'maker': 0.3 / 100, - 'taker': 0.7 / 100, + 'maker': 0.003, + 'taker': 0.007, + }, + }, + 'options': { + 'limits': { + 'BTC': 0.001, + 'BCH': 0.001, + 'ETH': 0.01, + 'LTC': 0.01, + 'XRP': 0.1, }, }, }); } + async fetchMarkets (params = {}) { + const response = await this.publicGetCoins (params); + // + // [ + // "BCH", + // "BTC", + // "ETH", + // "LTC", + // "XRP", + // "MBPRK01", + // "MBPRK02", + // "MBPRK03", + // "MBPRK04", + // "MBCONS01", + // "USDC", + // "WBX", + // "CHZ", + // "MBCONS02", + // "PAXG", + // "MBVASCO01", + // "LINK" + // ] + // + const result = []; + const amountLimits = this.safeValue (this.options, 'limits', {}); + for (let i = 0; i < response.length; i++) { + const coin = response[i]; + const baseId = coin; + const quoteId = 'BRL'; + const base = this.safeCurrencyCode (baseId); + const quote = this.safeCurrencyCode (quoteId); + const symbol = base + '/' + quote; + const id = quote + base; + const precision = { + 'amount': 8, + 'price': 5, + }; + result.push ({ + 'id': id, + 'symbol': symbol, + 'base': base, + 'quote': quote, + 'baseId': baseId, + 'quoteId': quoteId, + 'active': undefined, + 'info': coin, + 'precision': precision, + 'limits': { + 'amount': { + 'min': this.safeFloat (amountLimits, baseId), + 'max': undefined, + }, + 'price': { + 'min': 1 / Math.pow (10, precision['price']), + 'max': undefined, + }, + 'cost': { + 'min': undefined, + 'max': undefined, + }, + }, + }); + } + return result; + } + async fetchOrderBook (symbol, limit = undefined, params = {}) { await this.loadMarkets (); const market = this.market (symbol); @@ -152,22 +222,30 @@ module.exports = class mercado extends Exchange { } parseTrade (trade, market = undefined) { - const timestamp = this.safeTimestamp (trade, 'date'); + const timestamp = this.safeTimestamp2 (trade, 'date', 'executed_timestamp'); let symbol = undefined; if (market !== undefined) { symbol = market['symbol']; } - const id = this.safeString (trade, 'tid'); + const id = this.safeString2 (trade, 'tid', 'operation_id'); const type = undefined; const side = this.safeString (trade, 'type'); const price = this.safeFloat (trade, 'price'); - const amount = this.safeFloat (trade, 'amount'); + const amount = this.safeFloat2 (trade, 'amount', 'quantity'); let cost = undefined; if (price !== undefined) { if (amount !== undefined) { cost = price * amount; } } + const feeCost = this.safeFloat (trade, 'fee_rate'); + let fee = undefined; + if (feeCost !== undefined) { + fee = { + 'cost': feeCost, + 'currency': undefined, + }; + } return { 'id': id, 'info': trade, @@ -181,7 +259,7 @@ module.exports = class mercado extends Exchange { 'price': price, 'amount': amount, 'cost': cost, - 'fee': undefined, + 'fee': fee, }; } @@ -349,6 +427,11 @@ module.exports = class mercado extends Exchange { const remaining = amount - filled; const cost = filled * average; const lastTradeTimestamp = this.safeTimestamp (order, 'updated_timestamp'); + const rawTrades = this.safeValue (order, 'operations', []); + const trades = this.parseTrades (rawTrades, market, undefined, undefined, { + 'side': side, + 'order': id, + }); return { 'info': order, 'id': id, @@ -359,6 +442,7 @@ module.exports = class mercado extends Exchange { 'symbol': market['symbol'], 'type': 'limit', 'timeInForce': undefined, + 'postOnly': undefined, 'side': side, 'price': price, 'stopPrice': undefined, @@ -369,7 +453,7 @@ module.exports = class mercado extends Exchange { 'remaining': remaining, 'status': status, 'fee': fee, - 'trades': undefined, // todo parse trades (operations) + 'trades': trades, }; } @@ -401,17 +485,17 @@ module.exports = class mercado extends Exchange { if (code === 'BRL') { const account_ref = ('account_ref' in params); if (!account_ref) { - throw new ArgumentsRequired (this.id + ' requires account_ref parameter to withdraw ' + code); + throw new ArgumentsRequired (this.id + ' withdraw() requires account_ref parameter to withdraw ' + code); } } else if (code !== 'LTC') { const tx_fee = ('tx_fee' in params); if (!tx_fee) { - throw new ArgumentsRequired (this.id + ' requires tx_fee parameter to withdraw ' + code); + throw new ArgumentsRequired (this.id + ' withdraw() requires tx_fee parameter to withdraw ' + code); } if (code === 'XRP') { if (tag === undefined) { if (!('destination_tag' in params)) { - throw new ArgumentsRequired (this.id + ' requires a tag argument or destination_tag parameter to withdraw ' + code); + throw new ArgumentsRequired (this.id + ' withdraw() requires a tag argument or destination_tag parameter to withdraw ' + code); } } else { request['destination_tag'] = tag; @@ -473,6 +557,51 @@ module.exports = class mercado extends Exchange { return this.parseOrders (orders, market, since, limit); } + async fetchOpenOrders (symbol = undefined, since = undefined, limit = undefined, params = {}) { + if (symbol === undefined) { + throw new ArgumentsRequired (this.id + ' fetchOpenOrders () requires a symbol argument'); + } + await this.loadMarkets (); + const market = this.market (symbol); + const request = { + 'coin_pair': market['id'], + 'status_list': '[2]', // open only + }; + const response = await this.privatePostListOrders (this.extend (request, params)); + const responseData = this.safeValue (response, 'response_data', {}); + const orders = this.safeValue (responseData, 'orders', []); + return this.parseOrders (orders, market, since, limit); + } + + async fetchMyTrades (symbol = undefined, since = undefined, limit = undefined, params = {}) { + if (symbol === undefined) { + throw new ArgumentsRequired (this.id + ' fetchMyTrades () requires a symbol argument'); + } + await this.loadMarkets (); + const market = this.market (symbol); + const request = { + 'coin_pair': market['id'], + 'has_fills': true, + }; + const response = await this.privatePostListOrders (this.extend (request, params)); + const responseData = this.safeValue (response, 'response_data', {}); + const ordersRaw = this.safeValue (responseData, 'orders', []); + const orders = this.parseOrders (ordersRaw, market, since, limit); + const trades = this.ordersToTrades (orders); + return this.filterBySymbolSinceLimit (trades, symbol, since, limit); + } + + ordersToTrades (orders) { + const result = []; + for (let i = 0; i < orders.length; i++) { + const trades = this.safeValue (orders[i], 'trades', []); + for (let y = 0; y < trades.length; y++) { + result.push (trades[y]); + } + } + return result; + } + sign (path, api = 'public', method = 'GET', params = {}, headers = undefined, body = undefined) { let url = this.urls['api'][api] + '/'; const query = this.omit (params, this.extractParams (path)); diff --git a/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/ndax.js b/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/ndax.js new file mode 100644 index 000000000..0367c2695 --- /dev/null +++ b/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/ndax.js @@ -0,0 +1,2015 @@ +'use strict'; + +// --------------------------------------------------------------------------- + +const Exchange = require ('./base/Exchange'); +const { ExchangeError, AuthenticationError, InsufficientFunds, BadSymbol, OrderNotFound } = require ('./base/errors'); +const { TICK_SIZE } = require ('./base/functions/number'); + +// --------------------------------------------------------------------------- + +module.exports = class ndax extends Exchange { + describe () { + return this.deepExtend (super.describe (), { + 'id': 'ndax', + 'name': 'NDAX', + 'countries': [ 'US' ], // United States + 'rateLimit': 1000, + 'pro': true, + 'has': { + 'cancelAllOrders': true, + 'cancelOrder': true, + 'createDepositAddress': true, + 'createOrder': true, + 'editOrder': true, + 'fetchAccounts': true, + 'fetchBalance': true, + 'fetchCurrencies': true, + 'fetchDepositAddress': true, + 'fetchDeposits': true, + 'fetchLedger': true, + 'fetchMarkets': true, + 'fetchMyTrades': true, + 'fetchOHLCV': true, + 'fetchOpenOrders': true, + 'fetchOrders': true, + 'fetchOrder': true, + 'fetchOrderBook': true, + 'fetchOrderTrades': true, + 'fetchTicker': true, + 'fetchTrades': true, + }, + 'timeframes': { + '1m': '60', + '5m': '300', + '15m': '900', + '30m': '1800', + '1h': '3600', + '2h': '7200', + '4h': '14400', + '6h': '21600', + '12h': '43200', + '1d': '86400', + '1w': '604800', + '1M': '2419200', + '4M': '9676800', + }, + 'urls': { + 'logo': 'https://user-images.githubusercontent.com/1294454/108623144-67a3ef00-744e-11eb-8140-75c6b851e945.jpg', + 'test': { + 'public': 'https://ndaxmarginstaging.cdnhop.net:8443/AP', + 'private': 'https://ndaxmarginstaging.cdnhop.net:8443/AP', + }, + 'api': { + 'public': 'https://api.ndax.io:8443/AP', + 'private': 'https://api.ndax.io:8443/AP', + }, + 'www': 'https://ndax.io', + 'doc': [ + 'https://apidoc.ndax.io/', + ], + 'fees': 'https://ndax.io/fees', + 'referral': 'https://one.ndax.io/bfQiSL', + }, + 'api': { + 'public': { + 'get': [ + 'Activate2FA', + 'Authenticate2FA', + 'AuthenticateUser', + 'GetL2Snapshot', + 'GetLevel1', + 'GetValidate2FARequiredEndpoints', + 'LogOut', + 'GetTickerHistory', + 'GetProduct', + 'GetProducts', + 'GetInstrument', + 'GetInstruments', + 'Ping', + 'trades', // undocumented + 'GetLastTrades', // undocumented + 'SubscribeLevel1', + 'SubscribeLevel2', + 'SubscribeTicker', + 'SubscribeTrades', + 'SubscribeBlockTrades', + 'UnsubscribeBlockTrades', + 'UnsubscribeLevel1', + 'UnsubscribeLevel2', + 'UnsubscribeTicker', + 'UnsubscribeTrades', + 'Authenticate', // undocumented + ], + }, + 'private': { + 'get': [ + 'GetUserAccountInfos', + 'GetUserAccounts', + 'GetUserAffiliateCount', + 'GetUserAffiliateTag', + 'GetUserConfig', + 'GetAllUnredactedUserConfigsForUser', + 'GetUnredactedUserConfigByKey', + 'GetUserDevices', + 'GetUserReportTickets', + 'GetUserReportWriterResultRecords', + 'GetAccountInfo', + 'GetAccountPositions', + 'GetAllAccountConfigs', + 'GetTreasuryProductsForAccount', + 'GetAccountTrades', + 'GetAccountTransactions', + 'GetOpenTradeReports', + 'GetAllOpenTradeReports', + 'GetTradesHistory', + 'GetOpenOrders', + 'GetOpenQuotes', + 'GetOrderFee', + 'GetOrderHistory', + 'GetOrdersHistory', + 'GetOrderStatus', + 'GetOmsFeeTiers', + 'GetAccountDepositTransactions', + 'GetAccountWithdrawTransactions', + 'GetAllDepositRequestInfoTemplates', + 'GetDepositInfo', + 'GetDepositRequestInfoTemplate', + 'GetDeposits', + 'GetDepositTicket', + 'GetDepositTickets', + 'GetOMSWithdrawFees', + 'GetWithdrawFee', + 'GetWithdraws', + 'GetWithdrawTemplate', + 'GetWithdrawTemplateTypes', + 'GetWithdrawTicket', + 'GetWithdrawTickets', + ], + 'post': [ + 'AddUserAffiliateTag', + 'CancelUserReport', + 'RegisterNewDevice', + 'SubscribeAccountEvents', + 'UpdateUserAffiliateTag', + 'GenerateTradeActivityReport', + 'GenerateTransactionActivityReport', + 'GenerateTreasuryActivityReport', + 'ScheduleTradeActivityReport', + 'ScheduleTransactionActivityReport', + 'ScheduleTreasuryActivityReport', + 'CancelAllOrders', + 'CancelOrder', + 'CancelQuote', + 'CancelReplaceOrder', + 'CreateQuote', + 'ModifyOrder', + 'SendOrder', + 'SubmitBlockTrade', + 'UpdateQuote', + 'CancelWithdraw', + 'CreateDepositTicket', + 'CreateWithdrawTicket', + 'SubmitDepositTicketComment', + 'SubmitWithdrawTicketComment', + 'GetOrderHistoryByOrderId', + ], + }, + }, + 'fees': { + 'trading': { + 'tierBased': false, + 'percentage': true, + 'maker': 0.2 / 100, + 'taker': 0.25 / 100, + }, + }, + 'requiredCredentials': { + 'apiKey': true, + 'secret': true, + 'uid': true, + }, + 'precisionMode': TICK_SIZE, + 'exceptions': { + 'exact': { + 'Not_Enough_Funds': InsufficientFunds, // {"status":"Rejected","errormsg":"Not_Enough_Funds","errorcode":101} + 'Server Error': ExchangeError, // {"result":false,"errormsg":"Server Error","errorcode":102,"detail":null} + 'Resource Not Found': OrderNotFound, // {"result":false,"errormsg":"Resource Not Found","errorcode":104,"detail":null} + }, + 'broad': { + 'Invalid InstrumentId': BadSymbol, // {"result":false,"errormsg":"Invalid InstrumentId: 10000","errorcode":100,"detail":null} + }, + }, + 'options': { + 'omsId': 1, + 'orderTypes': { + 'Market': 1, + 'Limit': 2, + 'StopMarket': 3, + 'StopLimit': 4, + 'TrailingStopMarket': 5, + 'TrailingStopLimit': 6, + 'BlockTrade': 7, + }, + }, + }); + } + + async fetchCurrencies (params = {}) { + const omsId = this.safeInteger (this.options, 'omsId', 1); + const request = { + 'omsId': omsId, + }; + const response = await this.publicGetGetProducts (this.extend (request, params)); + // + // [ + // { + // "OMSId":1, + // "ProductId":1, + // "Product":"BTC", + // "ProductFullName":"Bitcoin", + // "ProductType":"CryptoCurrency", + // "DecimalPlaces":8, + // "TickSize":0.0000000100000000000000000000, + // "NoFees":false, + // "IsDisabled":false, + // "MarginEnabled":false + // }, + // ] + // + const result = {}; + for (let i = 0; i < response.length; i++) { + const currency = response[i]; + const id = this.safeString (currency, 'ProductId'); + const name = this.safeString (currency, 'ProductFullName'); + const type = this.safeString (currency, 'ProductType'); + const code = this.safeCurrencyCode (this.safeString (currency, 'Product')); + const precision = this.safeFloat (currency, 'TickSize'); + const isDisabled = this.safeValue (currency, 'IsDisabled'); + const active = !isDisabled; + result[code] = { + 'id': id, + 'name': name, + 'code': code, + 'type': type, + 'precision': precision, + 'info': currency, + 'active': active, + 'fee': undefined, + 'limits': this.limits, + }; + } + return result; + } + + async fetchMarkets (params = {}) { + const omsId = this.safeInteger (this.options, 'omsId', 1); + const request = { + 'omsId': omsId, + }; + const response = await this.publicGetGetInstruments (this.extend (request, params)); + // + // [ + // { + // "OMSId":1, + // "InstrumentId":3, + // "Symbol":"LTCBTC", + // "Product1":3, + // "Product1Symbol":"LTC", + // "Product2":1, + // "Product2Symbol":"BTC", + // "InstrumentType":"Standard", + // "VenueInstrumentId":3, + // "VenueId":1, + // "SortIndex":0, + // "SessionStatus":"Running", + // "PreviousSessionStatus":"Stopped", + // "SessionStatusDateTime":"2020-11-25T19:42:15.245Z", + // "SelfTradePrevention":true, + // "QuantityIncrement":0.0000000100000000000000000000, + // "PriceIncrement":0.0000000100000000000000000000, + // "MinimumQuantity":0.0100000000000000000000000000, + // "MinimumPrice":0.0000010000000000000000000000, + // "VenueSymbol":"LTCBTC", + // "IsDisable":false, + // "MasterDataId":0, + // "PriceCollarThreshold":0.0000000000000000000000000000, + // "PriceCollarPercent":0.0000000000000000000000000000, + // "PriceCollarEnabled":false, + // "PriceFloorLimit":0.0000000000000000000000000000, + // "PriceFloorLimitEnabled":false, + // "PriceCeilingLimit":0.0000000000000000000000000000, + // "PriceCeilingLimitEnabled":false, + // "CreateWithMarketRunning":true, + // "AllowOnlyMarketMakerCounterParty":false, + // "PriceCollarIndexDifference":0.0000000000000000000000000000, + // "PriceCollarConvertToOtcEnabled":false, + // "PriceCollarConvertToOtcClientUserId":0, + // "PriceCollarConvertToOtcAccountId":0, + // "PriceCollarConvertToOtcThreshold":0.0000000000000000000000000000, + // "OtcConvertSizeThreshold":0.0000000000000000000000000000, + // "OtcConvertSizeEnabled":false, + // "OtcTradesPublic":true, + // "PriceTier":0 + // }, + // ] + // + const result = []; + for (let i = 0; i < response.length; i++) { + const market = response[i]; + const id = this.safeString (market, 'InstrumentId'); + // const lowercaseId = this.safeStringLower (market, 'symbol'); + const baseId = this.safeString (market, 'Product1'); + const quoteId = this.safeString (market, 'Product2'); + const base = this.safeCurrencyCode (this.safeString (market, 'Product1Symbol')); + const quote = this.safeCurrencyCode (this.safeString (market, 'Product2Symbol')); + const symbol = base + '/' + quote; + const precision = { + 'amount': this.safeFloat (market, 'QuantityIncrement'), + 'price': this.safeFloat (market, 'PriceIncrement'), + }; + const sessionStatus = this.safeString (market, 'SessionStatus'); + const isDisable = this.safeValue (market, 'IsDisable'); + const sessionRunning = (sessionStatus === 'Running'); + const active = (sessionRunning && !isDisable) ? true : false; + result.push ({ + 'id': id, + 'symbol': symbol, + 'base': base, + 'quote': quote, + 'baseId': baseId, + 'quoteId': quoteId, + 'info': market, + 'active': active, + 'precision': precision, + 'limits': { + 'amount': { + 'min': this.safeFloat (market, 'MinimumQuantity'), + 'max': undefined, + }, + 'price': { + 'min': this.safeFloat (market, 'MinimumPrice'), + 'max': undefined, + }, + 'cost': { + 'min': undefined, + 'max': undefined, + }, + }, + }); + } + return result; + } + + parseOrderBook (orderbook, timestamp = undefined, bidsKey = 'bids', asksKey = 'asks', priceKey = 6, amountKey = 8) { + let nonce = undefined; + const result = { + 'bids': [], + 'asks': [], + 'timestamp': undefined, + 'datetime': undefined, + 'nonce': undefined, + }; + for (let i = 0; i < orderbook.length; i++) { + const level = orderbook[i]; + if (timestamp === undefined) { + timestamp = this.safeInteger (level, 2); + } else { + const newTimestamp = this.safeInteger (level, 2); + timestamp = Math.max (timestamp, newTimestamp); + } + if (nonce === undefined) { + nonce = this.safeInteger (level, 0); + } else { + const newNonce = this.safeInteger (level, 0); + nonce = Math.max (nonce, newNonce); + } + const bidask = this.parseBidAsk (level, priceKey, amountKey); + const levelSide = this.safeValue (level, 9); + const side = levelSide ? asksKey : bidsKey; + result[side].push (bidask); + } + result['bids'] = this.sortBy (result['bids'], 0, true); + result['asks'] = this.sortBy (result['asks'], 0); + result['timestamp'] = timestamp; + result['datetime'] = this.iso8601 (timestamp); + result['nonce'] = nonce; + return result; + } + + async fetchOrderBook (symbol, limit = undefined, params = {}) { + const omsId = this.safeInteger (this.options, 'omsId', 1); + await this.loadMarkets (); + const market = this.market (symbol); + limit = (limit === undefined) ? 100 : limit; // default 100 + const request = { + 'omsId': omsId, + 'InstrumentId': market['id'], + 'Depth': limit, // default 100 + }; + const response = await this.publicGetGetL2Snapshot (this.extend (request, params)); + // + // [ + // [ + // 0, // 0 MDUpdateId + // 1, // 1 Number of Unique Accounts + // 123, // 2 ActionDateTime in Posix format X 1000 + // 0, // 3 ActionType 0 (New), 1 (Update), 2(Delete) + // 0.0, // 4 LastTradePrice + // 0, // 5 Number of Orders + // 0.0, // 6 Price + // 0, // 7 ProductPairCode + // 0.0, // 8 Quantity + // 0, // 9 Side + // ], + // [97244115,1,1607456142963,0,19069.32,1,19069.31,8,0.140095,0], + // [97244115,0,1607456142963,0,19069.32,1,19068.64,8,0.0055,0], + // [97244115,0,1607456142963,0,19069.32,1,19068.26,8,0.021291,0], + // [97244115,1,1607456142964,0,19069.32,1,19069.32,8,0.099636,1], + // [97244115,0,1607456142964,0,19069.32,1,19069.98,8,0.1,1], + // [97244115,0,1607456142964,0,19069.32,1,19069.99,8,0.141604,1], + // ] + // + return this.parseOrderBook (response); + } + + parseTicker (ticker, market = undefined) { + // + // fetchTicker + // + // { + // "OMSId":1, + // "InstrumentId":8, + // "BestBid":19069.31, + // "BestOffer":19069.32, + // "LastTradedPx":19069.32, + // "LastTradedQty":0.0001, + // "LastTradeTime":1607040406424, + // "SessionOpen":19069.32, + // "SessionHigh":19069.32, + // "SessionLow":19069.32, + // "SessionClose":19069.32, + // "Volume":0.0001, + // "CurrentDayVolume":0.0001, + // "CurrentDayNotional":1.906932, + // "CurrentDayNumTrades":1, + // "CurrentDayPxChange":0.00, + // "Rolling24HrVolume":0.000000000000000000000000000, + // "Rolling24HrNotional":0.00000000000000000000000, + // "Rolling24NumTrades":0, + // "Rolling24HrPxChange":0, + // "TimeStamp":"1607040406425", + // "BidQty":0, + // "AskQty":0, + // "BidOrderCt":0, + // "AskOrderCt":0, + // "Rolling24HrPxChangePercent":0, + // } + // + const timestamp = this.safeInteger (ticker, 'TimeStamp'); + const marketId = this.safeString (ticker, 'InstrumentId'); + const symbol = this.safeSymbol (marketId, market); + const last = this.safeFloat (ticker, 'LastTradedPx'); + const percentage = this.safeFloat (ticker, 'Rolling24HrPxChangePercent'); + const change = this.safeFloat (ticker, 'Rolling24HrPxChange'); + const open = this.safeFloat (ticker, 'SessionOpen'); + let average = undefined; + if ((last !== undefined) && (change !== undefined)) { + average = this.sum (last, open) / 2; + } + const baseVolume = this.safeFloat (ticker, 'Rolling24HrVolume'); + const quoteVolume = this.safeFloat (ticker, 'Rolling24HrNotional'); + const vwap = this.vwap (baseVolume, quoteVolume); + return { + 'symbol': symbol, + 'timestamp': timestamp, + 'datetime': this.iso8601 (timestamp), + 'high': this.safeFloat (ticker, 'SessionHigh'), + 'low': this.safeFloat (ticker, 'SessionLow'), + 'bid': this.safeFloat (ticker, 'BestBid'), + 'bidVolume': undefined, // this.safeFloat (ticker, 'BidQty'), always shows 0 + 'ask': this.safeFloat (ticker, 'BestOffer'), + 'askVolume': undefined, // this.safeFloat (ticker, 'AskQty'), always shows 0 + 'vwap': vwap, + 'open': open, + 'close': last, + 'last': last, + 'previousClose': undefined, + 'change': change, + 'percentage': percentage, + 'average': average, + 'baseVolume': baseVolume, + 'quoteVolume': quoteVolume, + 'info': ticker, + }; + } + + async fetchTicker (symbol, params = {}) { + const omsId = this.safeInteger (this.options, 'omsId', 1); + await this.loadMarkets (); + const market = this.market (symbol); + const request = { + 'omsId': omsId, + 'InstrumentId': market['id'], + }; + const response = await this.publicGetGetLevel1 (this.extend (request, params)); + // + // { + // "OMSId":1, + // "InstrumentId":8, + // "BestBid":19069.31, + // "BestOffer":19069.32, + // "LastTradedPx":19069.32, + // "LastTradedQty":0.0001, + // "LastTradeTime":1607040406424, + // "SessionOpen":19069.32, + // "SessionHigh":19069.32, + // "SessionLow":19069.32, + // "SessionClose":19069.32, + // "Volume":0.0001, + // "CurrentDayVolume":0.0001, + // "CurrentDayNotional":1.906932, + // "CurrentDayNumTrades":1, + // "CurrentDayPxChange":0.00, + // "Rolling24HrVolume":0.000000000000000000000000000, + // "Rolling24HrNotional":0.00000000000000000000000, + // "Rolling24NumTrades":0, + // "Rolling24HrPxChange":0, + // "TimeStamp":"1607040406425", + // "BidQty":0, + // "AskQty":0, + // "BidOrderCt":0, + // "AskOrderCt":0, + // "Rolling24HrPxChangePercent":0, + // } + // + return this.parseTicker (response, market); + } + + parseOHLCV (ohlcv, market = undefined) { + // + // [ + // 1501603632000, // 0 DateTime + // 2700.33, // 1 High + // 2687.01, // 2 Low + // 2687.01, // 3 Open + // 2687.01, // 4 Close + // 24.86100992, // 5 Volume + // 0, // 6 Inside Bid Price + // 2870.95, // 7 Inside Ask Price + // 1 // 8 InstrumentId + // ] + // + return [ + this.safeInteger (ohlcv, 0), + this.safeFloat (ohlcv, 3), + this.safeFloat (ohlcv, 1), + this.safeFloat (ohlcv, 2), + this.safeFloat (ohlcv, 4), + this.safeFloat (ohlcv, 5), + ]; + } + + async fetchOHLCV (symbol, timeframe = '1m', since = undefined, limit = undefined, params = {}) { + const omsId = this.safeInteger (this.options, 'omsId', 1); + await this.loadMarkets (); + const market = this.market (symbol); + const request = { + 'omsId': omsId, + 'InstrumentId': market['id'], + 'Interval': this.timeframes[timeframe], + }; + const duration = this.parseTimeframe (timeframe); + const now = this.milliseconds (); + if (since === undefined) { + if (limit !== undefined) { + request['FromDate'] = this.ymd (now - duration * limit * 1000); + request['ToDate'] = this.ymd (now); + } + } else { + request['FromDate'] = this.ymd (since); + if (limit === undefined) { + request['ToDate'] = this.ymd (now); + } else { + request['ToDate'] = this.ymd (this.sum (since, duration * limit * 1000)); + } + } + const response = await this.publicGetGetTickerHistory (this.extend (request, params)); + // + // [ + // [1607299260000,19069.32,19069.32,19069.32,19069.32,0,19069.31,19069.32,8,1607299200000], + // [1607299320000,19069.32,19069.32,19069.32,19069.32,0,19069.31,19069.32,8,1607299260000], + // [1607299380000,19069.32,19069.32,19069.32,19069.32,0,19069.31,19069.32,8,1607299320000], + // ] + // + return this.parseOHLCVs (response, market, timeframe, since, limit); + } + + parseTrade (trade, market = undefined) { + // + // fetchTrades (public) + // + // [ + // 6913253, // 0 TradeId + // 8, // 1 ProductPairCode + // 0.03340802, // 2 Quantity + // 19116.08, // 3 Price + // 2543425077, // 4 Order1 + // 2543425482, // 5 Order2 + // 1606935922416, // 6 Tradetime + // 0, // 7 Direction + // 1, // 8 TakerSide + // 0, // 9 BlockTrade + // 0, // 10 Either Order1ClientId or Order2ClientId + // ] + // + // fetchMyTrades (private) + // + // { + // "OMSId":1, + // "ExecutionId":16916567, + // "TradeId":14476351, + // "OrderId":2543565231, + // "AccountId":449, + // "AccountName":"igor@ccxt.trade", + // "SubAccountId":0, + // "ClientOrderId":0, + // "InstrumentId":8, + // "Side":"Sell", + // "OrderType":"Market", + // "Quantity":0.1230000000000000000000000000, + // "RemainingQuantity":0.0000000000000000000000000000, + // "Price":19069.310000000000000000000000, + // "Value":2345.5251300000000000000000000, + // "CounterParty":"7", + // "OrderTradeRevision":1, + // "Direction":"NoChange", + // "IsBlockTrade":false, + // "Fee":1.1727625650000000000000000000, + // "FeeProductId":8, + // "OrderOriginator":446, + // "UserName":"igor@ccxt.trade", + // "TradeTimeMS":1607565031569, + // "MakerTaker":"Taker", + // "AdapterTradeId":0, + // "InsideBid":19069.310000000000000000000000, + // "InsideBidSize":0.2400950000000000000000000000, + // "InsideAsk":19069.320000000000000000000000, + // "InsideAskSize":0.0997360000000000000000000000, + // "IsQuote":false, + // "CounterPartyClientUserId":1, + // "NotionalProductId":2, + // "NotionalRate":1.0000000000000000000000000000, + // "NotionalValue":2345.5251300000000000000000000, + // "NotionalHoldAmount":0, + // "TradeTime":637431618315686826 + // } + // + // fetchOrderTrades + // + // { + // "Side":"Sell", + // "OrderId":2543565235, + // "Price":18600.000000000000000000000000, + // "Quantity":0.0000000000000000000000000000, + // "DisplayQuantity":0.0000000000000000000000000000, + // "Instrument":8, + // "Account":449, + // "AccountName":"igor@ccxt.trade", + // "OrderType":"Limit", + // "ClientOrderId":0, + // "OrderState":"FullyExecuted", + // "ReceiveTime":1607585844956, + // "ReceiveTimeTicks":637431826449564182, + // "LastUpdatedTime":1607585844959, + // "LastUpdatedTimeTicks":637431826449593893, + // "OrigQuantity":0.1230000000000000000000000000, + // "QuantityExecuted":0.1230000000000000000000000000, + // "GrossValueExecuted":2345.3947500000000000000000000, + // "ExecutableValue":0.0000000000000000000000000000, + // "AvgPrice":19068.250000000000000000000000, + // "CounterPartyId":0, + // "ChangeReason":"Trade", + // "OrigOrderId":2543565235, + // "OrigClOrdId":0, + // "EnteredBy":446, + // "UserName":"igor@ccxt.trade", + // "IsQuote":false, + // "InsideAsk":19069.320000000000000000000000, + // "InsideAskSize":0.0997360000000000000000000000, + // "InsideBid":19068.250000000000000000000000, + // "InsideBidSize":1.3300010000000000000000000000, + // "LastTradePrice":19068.250000000000000000000000, + // "RejectReason":"", + // "IsLockedIn":false, + // "CancelReason":"", + // "OrderFlag":"0", + // "UseMargin":false, + // "StopPrice":0.0000000000000000000000000000, + // "PegPriceType":"Unknown", + // "PegOffset":0.0000000000000000000000000000, + // "PegLimitOffset":0.0000000000000000000000000000, + // "IpAddress":"5.228.233.138", + // "ClientOrderIdUuid":null, + // "OMSId":1 + // } + // + let price = undefined; + let amount = undefined; + let cost = undefined; + let timestamp = undefined; + let id = undefined; + let marketId = undefined; + let side = undefined; + let orderId = undefined; + let takerOrMaker = undefined; + let fee = undefined; + let type = undefined; + if (Array.isArray (trade)) { + price = this.safeFloat (trade, 3); + amount = this.safeFloat (trade, 2); + if ((price !== undefined) && (amount !== undefined)) { + cost = price * amount; + } + timestamp = this.safeInteger (trade, 6); + id = this.safeString (trade, 0); + marketId = this.safeInteger (trade, 1); + const takerSide = this.safeValue (trade, 8); + side = takerSide ? 'sell' : 'buy'; + orderId = this.safeString (trade, 4); + } else { + timestamp = this.safeInteger2 (trade, 'TradeTimeMS', 'ReceiveTime'); + id = this.safeString (trade, 'TradeId'); + orderId = this.safeString2 (trade, 'OrderId', 'OrigOrderId'); + marketId = this.safeString2 (trade, 'InstrumentId', 'Instrument'); + price = this.safeFloat (trade, 'Price'); + amount = this.safeFloat (trade, 'Quantity'); + cost = this.safeFloat2 (trade, 'Value', 'GrossValueExecuted'); + takerOrMaker = this.safeStringLower (trade, 'MakerTaker'); + side = this.safeStringLower (trade, 'Side'); + type = this.safeStringLower (trade, 'OrderType'); + const feeCost = this.safeFloat (trade, 'Fee'); + if (feeCost !== undefined) { + const feeCurrencyId = this.safeString (trade, 'FeeProductId'); + const feeCurrencyCode = this.safeCurrencyCode (feeCurrencyId); + fee = { + 'cost': feeCost, + 'currency': feeCurrencyCode, + }; + } + } + const symbol = this.safeSymbol (marketId, market); + return { + 'info': trade, + 'id': id, + 'symbol': symbol, + 'timestamp': timestamp, + 'datetime': this.iso8601 (timestamp), + 'order': orderId, + 'type': type, + 'side': side, + 'takerOrMaker': takerOrMaker, + 'price': price, + 'amount': amount, + 'cost': cost, + 'fee': fee, + }; + } + + async fetchTrades (symbol, since = undefined, limit = undefined, params = {}) { + const omsId = this.safeInteger (this.options, 'omsId', 1); + await this.loadMarkets (); + const market = this.market (symbol); + const request = { + 'omsId': omsId, + 'InstrumentId': market['id'], + }; + if (limit !== undefined) { + request['Count'] = limit; + } + const response = await this.publicGetGetLastTrades (this.extend (request, params)); + // + // [ + // [6913253,8,0.03340802,19116.08,2543425077,2543425482,1606935922416,0,1,0,0], + // [6913254,8,0.01391671,19117.42,2543427510,2543427811,1606935927998,1,1,0,0], + // [6913255,8,0.000006,19107.81,2543430495,2543430793,1606935933881,2,0,0,0], + // ] + // + return this.parseTrades (response, market, since, limit); + } + + async fetchAccounts (params = {}) { + const omsId = this.safeInteger (this.options, 'omsId', 1); + this.checkRequiredCredentials (); + const request = { + 'omsId': omsId, + 'UserId': this.uid, + 'UserName': 'igor@ccxt.trade', + }; + const response = await this.privateGetGetUserAccounts (this.extend (request, params)); + // + // [ 449 ] // comma-separated list of account ids + // + const result = []; + for (let i = 0; i < response.length; i++) { + const accountId = this.safeString (response, i); + result.push ({ + 'id': accountId, + 'type': undefined, + 'currency': undefined, + 'info': accountId, + }); + } + return result; + } + + async fetchBalance (params = {}) { + const omsId = this.safeInteger (this.options, 'omsId', 1); + await this.loadMarkets (); + await this.loadAccounts (); + const defaultAccountId = this.safeInteger2 (this.options, 'accountId', 'AccountId', parseInt (this.accounts[0]['id'])); + const accountId = this.safeInteger2 (params, 'accountId', 'AccountId', defaultAccountId); + params = this.omit (params, [ 'accountId', 'AccountId' ]); + const request = { + 'omsId': omsId, + 'AccountId': accountId, + }; + const response = await this.privateGetGetAccountPositions (this.extend (request, params)); + // + // [ + // { + // "OMSId":1, + // "AccountId":449, + // "ProductSymbol":"BTC", + // "ProductId":1, + // "Amount":10.000000000000000000000000000, + // "Hold":0, + // "PendingDeposits":0.0000000000000000000000000000, + // "PendingWithdraws":0.0000000000000000000000000000, + // "TotalDayDeposits":10.000000000000000000000000000, + // "TotalMonthDeposits":10.000000000000000000000000000, + // "TotalYearDeposits":10.000000000000000000000000000, + // "TotalDayDepositNotional":10.000000000000000000000000000, + // "TotalMonthDepositNotional":10.000000000000000000000000000, + // "TotalYearDepositNotional":10.000000000000000000000000000, + // "TotalDayWithdraws":0, + // "TotalMonthWithdraws":0, + // "TotalYearWithdraws":0, + // "TotalDayWithdrawNotional":0, + // "TotalMonthWithdrawNotional":0, + // "TotalYearWithdrawNotional":0, + // "NotionalProductId":8, + // "NotionalProductSymbol":"USDT", + // "NotionalValue":10.000000000000000000000000000, + // "NotionalHoldAmount":0, + // "NotionalRate":1 + // }, + // ] + // + const result = { 'info': response }; + for (let i = 0; i < response.length; i++) { + const balance = response[i]; + const currencyId = this.safeString (balance, 'ProductId'); + const code = this.safeCurrencyCode (currencyId); + const account = this.account (); + account['total'] = this.safeFloat (balance, 'Amount'); + account['used'] = this.safeFloat (balance, 'Hold'); + result[code] = account; + } + return this.parseBalance (result); + } + + parseLedgerEntryType (type) { + const types = { + 'Trade': 'trade', + 'Deposit': 'transaction', + 'Withdraw': 'transaction', + 'Transfer': 'transfer', + 'OrderHold': 'trade', + 'WithdrawHold': 'transaction', + 'DepositHold': 'transaction', + 'MarginHold': 'trade', + 'ManualHold': 'trade', + 'ManualEntry': 'trade', + 'MarginAcquisition': 'trade', + 'MarginRelinquish': 'trade', + 'MarginQuoteHold': 'trade', + }; + return this.safeString (types, type, type); + } + + parseLedgerEntry (item, currency = undefined) { + // + // { + // "TransactionId":2663709493, + // "ReferenceId":68, + // "OMSId":1, + // "AccountId":449, + // "CR":10.000000000000000000000000000, + // "DR":0.0000000000000000000000000000, + // "Counterparty":3, + // "TransactionType":"Other", + // "ReferenceType":"Deposit", + // "ProductId":1, + // "Balance":10.000000000000000000000000000, + // "TimeStamp":1607532331591 + // } + // + const id = this.safeString (item, 'TransactionId'); + const account = this.safeString (item, 'AccountId'); + const referenceId = this.safeString (item, 'ReferenceId'); + const referenceAccount = this.safeString (item, 'Counterparty'); + const type = this.parseLedgerEntryType (this.safeString (item, 'ReferenceType')); + const currencyId = this.safeString (item, 'ProductId'); + const code = this.safeCurrencyCode (currencyId, currency); + const credit = this.safeFloat (item, 'CR'); + const debit = this.safeFloat (item, 'DR'); + let amount = undefined; + let direction = undefined; + if (credit > 0) { + amount = credit; + direction = 'in'; + } else if (debit > 0) { + amount = debit; + direction = 'out'; + } + const timestamp = this.safeInteger (item, 'TimeStamp'); + let before = undefined; + const after = this.safeFloat (item, 'Balance'); + if (direction === 'out') { + before = this.sum (after, amount); + } else if (direction === 'in') { + before = Math.max (0, after - amount); + } + const status = 'ok'; + return { + 'info': item, + 'id': id, + 'direction': direction, + 'account': account, + 'referenceId': referenceId, + 'referenceAccount': referenceAccount, + 'type': type, + 'currency': code, + 'amount': amount, + 'before': before, + 'after': after, + 'status': status, + 'timestamp': timestamp, + 'datetime': this.iso8601 (timestamp), + 'fee': undefined, + }; + } + + async fetchLedger (code = undefined, since = undefined, limit = undefined, params = {}) { + const omsId = this.safeInteger (this.options, 'omsId', 1); + await this.loadMarkets (); + await this.loadAccounts (); + const defaultAccountId = this.safeInteger2 (this.options, 'accountId', 'AccountId', parseInt (this.accounts[0]['id'])); + const accountId = this.safeInteger2 (params, 'accountId', 'AccountId', defaultAccountId); + params = this.omit (params, [ 'accountId', 'AccountId' ]); + const request = { + 'omsId': omsId, + 'AccountId': accountId, + }; + if (limit !== undefined) { + request['Depth'] = limit; + } + const response = await this.privateGetGetAccountTransactions (this.extend (request, params)); + // + // [ + // { + // "TransactionId":2663709493, + // "ReferenceId":68, + // "OMSId":1, + // "AccountId":449, + // "CR":10.000000000000000000000000000, + // "DR":0.0000000000000000000000000000, + // "Counterparty":3, + // "TransactionType":"Other", + // "ReferenceType":"Deposit", + // "ProductId":1, + // "Balance":10.000000000000000000000000000, + // "TimeStamp":1607532331591 + // }, + // ] + // + let currency = undefined; + if (code !== undefined) { + currency = this.currency (code); + } + return this.parseLedger (response, currency, since, limit); + } + + parseOrderStatus (status) { + const statuses = { + 'Accepted': 'open', + 'Rejected': 'rejected', + 'Working': 'open', + 'Canceled': 'canceled', + 'Expired': 'expired', + 'FullyExecuted': 'closed', + }; + return this.safeString (statuses, status, status); + } + + parseOrder (order, market = undefined) { + // + // createOrder + // + // { + // "status":"Accepted", + // "errormsg":"", + // "OrderId": 2543565231 + // } + // + // editOrder + // + // { + // "ReplacementOrderId": 1234, + // "ReplacementClOrdId": 1561, + // "OrigOrderId": 5678, + // "OrigClOrdId": 91011, + // } + // + // fetchOpenOrders, fetchClosedOrders + // + // { + // "Side":"Buy", + // "OrderId":2543565233, + // "Price":19010, + // "Quantity":0.345, + // "DisplayQuantity":0.345, + // "Instrument":8, + // "Account":449, + // "AccountName":"igor@ccxt.trade", + // "OrderType":"Limit", + // "ClientOrderId":0, + // "OrderState":"Working", + // "ReceiveTime":1607579326003, + // "ReceiveTimeTicks":637431761260028981, + // "LastUpdatedTime":1607579326005, + // "LastUpdatedTimeTicks":637431761260054714, + // "OrigQuantity":0.345, + // "QuantityExecuted":0, + // "GrossValueExecuted":0, + // "ExecutableValue":0, + // "AvgPrice":0, + // "CounterPartyId":0, + // "ChangeReason":"NewInputAccepted", + // "OrigOrderId":2543565233, + // "OrigClOrdId":0, + // "EnteredBy":446, + // "UserName":"igor@ccxt.trade", + // "IsQuote":false, + // "InsideAsk":19069.32, + // "InsideAskSize":0.099736, + // "InsideBid":19068.25, + // "InsideBidSize":1.330001, + // "LastTradePrice":19068.25, + // "RejectReason":"", + // "IsLockedIn":false, + // "CancelReason":"", + // "OrderFlag":"AddedToBook", + // "UseMargin":false, + // "StopPrice":0, + // "PegPriceType":"Unknown", + // "PegOffset":0, + // "PegLimitOffset":0, + // "IpAddress":null, + // "ClientOrderIdUuid":null, + // "OMSId":1 + // } + // + const id = this.safeString2 (order, 'ReplacementOrderId', 'OrderId'); + const timestamp = this.safeInteger (order, 'ReceiveTime'); + let lastTradeTimestamp = undefined; + const marketId = this.safeString (order, 'Instrument'); + const symbol = this.safeSymbol (marketId, market); + const side = this.safeStringLower (order, 'Side'); + const type = this.safeStringLower (order, 'OrderType'); + const clientOrderId = this.safeString2 (order, 'ReplacementClOrdId', 'ClientOrderId'); + let price = this.safeFloat (order, 'Price', 0.0); + price = (price > 0.0) ? price : undefined; + const amount = this.safeFloat (order, 'OrigQuantity'); + const filled = this.safeFloat (order, 'QuantityExecuted'); + const cost = this.safeFloat (order, 'GrossValueExecuted'); + let remaining = undefined; + let average = undefined; + if (filled !== undefined) { + if (amount !== undefined) { + remaining = Math.max (0, amount - filled); + } + if (filled > 0) { + lastTradeTimestamp = this.safeInteger (order, 'LastUpdatedTime'); + average = this.safeFloat (order, 'AvgPrice', 0.0); + average = (average > 0) ? average : undefined; + } + } + let stopPrice = this.safeFloat (order, 'StopPrice', 0.0); + stopPrice = (stopPrice > 0.0) ? stopPrice : undefined; + const timeInForce = undefined; + const status = this.parseOrderStatus (this.safeString (order, 'OrderState')); + const fee = undefined; + const trades = undefined; + return { + 'id': id, + 'clientOrderId': clientOrderId, + 'info': order, + 'timestamp': timestamp, + 'datetime': this.iso8601 (timestamp), + 'lastTradeTimestamp': lastTradeTimestamp, + 'status': status, + 'symbol': symbol, + 'type': type, + 'timeInForce': timeInForce, + 'postOnly': undefined, + 'side': side, + 'price': price, + 'stopPrice': stopPrice, + 'cost': cost, + 'amount': amount, + 'filled': filled, + 'average': average, + 'remaining': remaining, + 'fee': fee, + 'trades': trades, + }; + } + + async createOrder (symbol, type, side, amount, price = undefined, params = {}) { + const omsId = this.safeInteger (this.options, 'omsId', 1); + await this.loadMarkets (); + await this.loadAccounts (); + const defaultAccountId = this.safeInteger2 (this.options, 'accountId', 'AccountId', parseInt (this.accounts[0]['id'])); + const accountId = this.safeInteger2 (params, 'accountId', 'AccountId', defaultAccountId); + const clientOrderId = this.safeInteger2 (params, 'ClientOrderId', 'clientOrderId'); + params = this.omit (params, [ 'accountId', 'AccountId', 'clientOrderId', 'ClientOrderId' ]); + const market = this.market (symbol); + const orderSide = (side === 'buy') ? 0 : 1; + const request = { + 'InstrumentId': parseInt (market['id']), + 'omsId': omsId, + 'AccountId': accountId, + 'TimeInForce': 1, // 0 Unknown, 1 GTC by default, 2 OPG execute as close to opening price as possible, 3 IOC immediate or canceled, 4 FOK fill-or-kill, 5 GTX good 'til executed, 6 GTD good 'til date + // 'ClientOrderId': clientOrderId, // defaults to 0 + // If this order is order A, OrderIdOCO refers to the order ID of an order B (which is not the order being created by this call). + // If order B executes, then order A created by this call is canceled. + // You can also set up order B to watch order A in the same way, but that may require an update to order B to make it watch this one, which could have implications for priority in the order book. + // See CancelReplaceOrder and ModifyOrder. + // 'OrderIdOCO': 0, // The order ID if One Cancels the Other. + // 'UseDisplayQuantity': false, // If you enter a Limit order with a reserve, you must set UseDisplayQuantity to true + 'Side': orderSide, // 0 Buy, 1 Sell, 2 Short, 3 unknown an error condition + 'Quantity': parseFloat (this.amountToPrecision (symbol, amount)), + 'OrderType': this.safeInteger (this.options['orderTypes'], this.capitalize (type)), // 0 Unknown, 1 Market, 2 Limit, 3 StopMarket, 4 StopLimit, 5 TrailingStopMarket, 6 TrailingStopLimit, 7 BlockTrade + // 'PegPriceType': 3, // 1 Last, 2 Bid, 3 Ask, 4 Midpoint + // 'LimitPrice': parseFloat (this.priceToPrecision (symbol, price)), + }; + // If OrderType=1 (Market), Side=0 (Buy), and LimitPrice is supplied, the Market order will execute up to the value specified + if (price !== undefined) { + request['LimitPrice'] = parseFloat (this.priceToPrecision (symbol, price)); + } + if (clientOrderId !== undefined) { + request['ClientOrderId'] = clientOrderId; + } + const response = await this.privatePostSendOrder (this.extend (request, params)); + // + // { + // "status":"Accepted", + // "errormsg":"", + // "OrderId": 2543565231 + // } + // + return this.parseOrder (response, market); + } + + async editOrder (id, symbol, type, side, amount, price = undefined, params = {}) { + const omsId = this.safeInteger (this.options, 'omsId', 1); + await this.loadMarkets (); + await this.loadAccounts (); + const defaultAccountId = this.safeInteger2 (this.options, 'accountId', 'AccountId', parseInt (this.accounts[0]['id'])); + const accountId = this.safeInteger2 (params, 'accountId', 'AccountId', defaultAccountId); + const clientOrderId = this.safeInteger2 (params, 'ClientOrderId', 'clientOrderId'); + params = this.omit (params, [ 'accountId', 'AccountId', 'clientOrderId', 'ClientOrderId' ]); + const market = this.market (symbol); + const orderSide = (side === 'buy') ? 0 : 1; + const request = { + 'OrderIdToReplace': parseInt (id), + 'InstrumentId': parseInt (market['id']), + 'omsId': omsId, + 'AccountId': accountId, + 'TimeInForce': 1, // 0 Unknown, 1 GTC by default, 2 OPG execute as close to opening price as possible, 3 IOC immediate or canceled, 4 FOK fill-or-kill, 5 GTX good 'til executed, 6 GTD good 'til date + // 'ClientOrderId': clientOrderId, // defaults to 0 + // If this order is order A, OrderIdOCO refers to the order ID of an order B (which is not the order being created by this call). + // If order B executes, then order A created by this call is canceled. + // You can also set up order B to watch order A in the same way, but that may require an update to order B to make it watch this one, which could have implications for priority in the order book. + // See CancelReplaceOrder and ModifyOrder. + // 'OrderIdOCO': 0, // The order ID if One Cancels the Other. + // 'UseDisplayQuantity': false, // If you enter a Limit order with a reserve, you must set UseDisplayQuantity to true + 'Side': orderSide, // 0 Buy, 1 Sell, 2 Short, 3 unknown an error condition + 'Quantity': parseFloat (this.amountToPrecision (symbol, amount)), + 'OrderType': this.safeInteger (this.options['orderTypes'], this.capitalize (type)), // 0 Unknown, 1 Market, 2 Limit, 3 StopMarket, 4 StopLimit, 5 TrailingStopMarket, 6 TrailingStopLimit, 7 BlockTrade + // 'PegPriceType': 3, // 1 Last, 2 Bid, 3 Ask, 4 Midpoint + // 'LimitPrice': parseFloat (this.priceToPrecision (symbol, price)), + }; + // If OrderType=1 (Market), Side=0 (Buy), and LimitPrice is supplied, the Market order will execute up to the value specified + if (price !== undefined) { + request['LimitPrice'] = parseFloat (this.priceToPrecision (symbol, price)); + } + if (clientOrderId !== undefined) { + request['ClientOrderId'] = clientOrderId; + } + const response = await this.privatePostCancelReplaceOrder (this.extend (request, params)); + // + // { + // "replacementOrderId": 1234, + // "replacementClOrdId": 1561, + // "origOrderId": 5678, + // "origClOrdId": 91011, + // } + // + return this.parseOrder (response, market); + } + + async fetchMyTrades (symbol = undefined, since = undefined, limit = undefined, params = {}) { + const omsId = this.safeInteger (this.options, 'omsId', 1); + await this.loadMarkets (); + await this.loadAccounts (); + const defaultAccountId = this.safeInteger2 (this.options, 'accountId', 'AccountId', parseInt (this.accounts[0]['id'])); + const accountId = this.safeInteger2 (params, 'accountId', 'AccountId', defaultAccountId); + params = this.omit (params, [ 'accountId', 'AccountId' ]); + const request = { + 'omsId': omsId, + 'AccountId': accountId, + // 'InstrumentId': market['id'], + // 'TradeId': 123, // If you specify TradeId, GetTradesHistory can return all states for a single trade + // 'OrderId': 456, // If specified, the call returns all trades associated with the order + // 'UserId': integer. The ID of the logged-in user. If not specified, the call returns trades associated with the users belonging to the default account for the logged-in user of this OMS. + // 'StartTimeStamp': long integer. The historical date and time at which to begin the trade report, in POSIX format. If not specified, reverts to the start date of this account on the trading venue. + // 'EndTimeStamp': long integer. Date at which to end the trade report, in POSIX format. + // 'Depth': integer. In this case, the count of trades to return, counting from the StartIndex. If Depth is not specified, returns all trades between BeginTimeStamp and EndTimeStamp, beginning at StartIndex. + // 'StartIndex': 0 // from the most recent trade 0 and moving backwards in time + // 'ExecutionId': 123, // The ID of the individual buy or sell execution. If not specified, returns all. + }; + let market = undefined; + if (symbol !== undefined) { + market = this.market (symbol); + request['InstrumentId'] = market['id']; + } + if (since !== undefined) { + request['StartTimeStamp'] = since; + } + if (limit !== undefined) { + request['Depth'] = limit; + } + const response = await this.privateGetGetTradesHistory (this.extend (request, params)); + // + // [ + // { + // "OMSId":1, + // "ExecutionId":16916567, + // "TradeId":14476351, + // "OrderId":2543565231, + // "AccountId":449, + // "AccountName":"igor@ccxt.trade", + // "SubAccountId":0, + // "ClientOrderId":0, + // "InstrumentId":8, + // "Side":"Sell", + // "OrderType":"Market", + // "Quantity":0.1230000000000000000000000000, + // "RemainingQuantity":0.0000000000000000000000000000, + // "Price":19069.310000000000000000000000, + // "Value":2345.5251300000000000000000000, + // "CounterParty":"7", + // "OrderTradeRevision":1, + // "Direction":"NoChange", + // "IsBlockTrade":false, + // "Fee":1.1727625650000000000000000000, + // "FeeProductId":8, + // "OrderOriginator":446, + // "UserName":"igor@ccxt.trade", + // "TradeTimeMS":1607565031569, + // "MakerTaker":"Taker", + // "AdapterTradeId":0, + // "InsideBid":19069.310000000000000000000000, + // "InsideBidSize":0.2400950000000000000000000000, + // "InsideAsk":19069.320000000000000000000000, + // "InsideAskSize":0.0997360000000000000000000000, + // "IsQuote":false, + // "CounterPartyClientUserId":1, + // "NotionalProductId":2, + // "NotionalRate":1.0000000000000000000000000000, + // "NotionalValue":2345.5251300000000000000000000, + // "NotionalHoldAmount":0, + // "TradeTime":637431618315686826 + // } + // ] + // + return this.parseTrades (response, market, since, limit); + } + + async cancelAllOrders (symbol = undefined, params = {}) { + const omsId = this.safeInteger (this.options, 'omsId', 1); + await this.loadMarkets (); + await this.loadAccounts (); + const defaultAccountId = this.safeInteger2 (this.options, 'accountId', 'AccountId', parseInt (this.accounts[0]['id'])); + const accountId = this.safeInteger2 (params, 'accountId', 'AccountId', defaultAccountId); + params = this.omit (params, [ 'accountId', 'AccountId' ]); + const request = { + 'omsId': omsId, + 'AccountId': accountId, + }; + if (symbol !== undefined) { + const market = this.market (symbol); + request['IntrumentId'] = market['id']; + } + const response = await this.privatePostCancelAllOrders (this.extend (request, params)); + // + // { + // "result":true, + // "errormsg":null, + // "errorcode":0, + // "detail":null + // } + // + return response; + } + + async cancelOrder (id, symbol = undefined, params = {}) { + const omsId = this.safeInteger (this.options, 'omsId', 1); + await this.loadMarkets (); + await this.loadAccounts (); + // const defaultAccountId = this.safeInteger2 (this.options, 'accountId', 'AccountId', parseInt (this.accounts[0]['id'])); + // const accountId = this.safeInteger2 (params, 'accountId', 'AccountId', defaultAccountId); + // params = this.omit (params, [ 'accountId', 'AccountId' ]); + let market = undefined; + if (symbol !== undefined) { + market = this.market (symbol); + } + const request = { + 'omsId': omsId, + // 'AccountId': accountId, + }; + const clientOrderId = this.safeInteger2 (params, 'clientOrderId', 'ClOrderId'); + if (clientOrderId !== undefined) { + request['ClOrderId'] = clientOrderId; + } else { + request['OrderId'] = parseInt (id); + } + params = this.omit (params, [ 'clientOrderId', 'ClOrderId' ]); + const response = await this.privatePostCancelOrder (this.extend (request, params)); + const order = this.parseOrder (response, market); + return this.extend (order, { + 'id': id, + 'clientOrderId': clientOrderId, + }); + } + + async fetchOpenOrders (symbol = undefined, since = undefined, limit = undefined, params = {}) { + const omsId = this.safeInteger (this.options, 'omsId', 1); + await this.loadMarkets (); + await this.loadAccounts (); + const defaultAccountId = this.safeInteger2 (this.options, 'accountId', 'AccountId', parseInt (this.accounts[0]['id'])); + const accountId = this.safeInteger2 (params, 'accountId', 'AccountId', defaultAccountId); + params = this.omit (params, [ 'accountId', 'AccountId' ]); + let market = undefined; + if (symbol !== undefined) { + market = this.market (symbol); + } + const request = { + 'omsId': omsId, + 'AccountId': accountId, + }; + const response = await this.privateGetGetOpenOrders (this.extend (request, params)); + // + // [ + // { + // "Side":"Buy", + // "OrderId":2543565233, + // "Price":19010, + // "Quantity":0.345, + // "DisplayQuantity":0.345, + // "Instrument":8, + // "Account":449, + // "AccountName":"igor@ccxt.trade", + // "OrderType":"Limit", + // "ClientOrderId":0, + // "OrderState":"Working", + // "ReceiveTime":1607579326003, + // "ReceiveTimeTicks":637431761260028981, + // "LastUpdatedTime":1607579326005, + // "LastUpdatedTimeTicks":637431761260054714, + // "OrigQuantity":0.345, + // "QuantityExecuted":0, + // "GrossValueExecuted":0, + // "ExecutableValue":0, + // "AvgPrice":0, + // "CounterPartyId":0, + // "ChangeReason":"NewInputAccepted", + // "OrigOrderId":2543565233, + // "OrigClOrdId":0, + // "EnteredBy":446, + // "UserName":"igor@ccxt.trade", + // "IsQuote":false, + // "InsideAsk":19069.32, + // "InsideAskSize":0.099736, + // "InsideBid":19068.25, + // "InsideBidSize":1.330001, + // "LastTradePrice":19068.25, + // "RejectReason":"", + // "IsLockedIn":false, + // "CancelReason":"", + // "OrderFlag":"AddedToBook", + // "UseMargin":false, + // "StopPrice":0, + // "PegPriceType":"Unknown", + // "PegOffset":0, + // "PegLimitOffset":0, + // "IpAddress":null, + // "ClientOrderIdUuid":null, + // "OMSId":1 + // } + // ] + // + return this.parseOrders (response, market, since, limit); + } + + async fetchOrders (symbol = undefined, since = undefined, limit = undefined, params = {}) { + const omsId = this.safeInteger (this.options, 'omsId', 1); + await this.loadMarkets (); + await this.loadAccounts (); + const defaultAccountId = this.safeInteger2 (this.options, 'accountId', 'AccountId', parseInt (this.accounts[0]['id'])); + const accountId = this.safeInteger2 (params, 'accountId', 'AccountId', defaultAccountId); + params = this.omit (params, [ 'accountId', 'AccountId' ]); + const request = { + 'omsId': omsId, + 'AccountId': accountId, + // 'ClientOrderId': clientOrderId, + // 'OriginalOrderId': id, + // 'OriginalClientOrderId': long integer, + // 'UserId': integer, + // 'InstrumentId': market['id'], + // 'StartTimestamp': since, + // 'EndTimestamp': this.milliseconds (), + // 'Depth': limit, + // 'StartIndex': 0, + }; + let market = undefined; + if (symbol !== undefined) { + market = this.market (symbol); + request['InstrumentId'] = market['id']; + } + if (since !== undefined) { + request['StartTimeStamp'] = since; + } + if (limit !== undefined) { + request['Depth'] = limit; + } + const response = await this.privateGetGetOrdersHistory (this.extend (request, params)); + // + // [ + // { + // "Side":"Buy", + // "OrderId":2543565233, + // "Price":19010.000000000000000000000000, + // "Quantity":0.0000000000000000000000000000, + // "DisplayQuantity":0.3450000000000000000000000000, + // "Instrument":8, + // "Account":449, + // "AccountName":"igor@ccxt.trade", + // "OrderType":"Limit", + // "ClientOrderId":0, + // "OrderState":"Canceled", + // "ReceiveTime":1607579326003, + // "ReceiveTimeTicks":637431761260028981, + // "LastUpdatedTime":1607580965346, + // "LastUpdatedTimeTicks":637431777653463754, + // "OrigQuantity":0.3450000000000000000000000000, + // "QuantityExecuted":0.0000000000000000000000000000, + // "GrossValueExecuted":0.0000000000000000000000000000, + // "ExecutableValue":0.0000000000000000000000000000, + // "AvgPrice":0.0000000000000000000000000000, + // "CounterPartyId":0, + // "ChangeReason":"UserModified", + // "OrigOrderId":2543565233, + // "OrigClOrdId":0, + // "EnteredBy":446, + // "UserName":"igor@ccxt.trade", + // "IsQuote":false, + // "InsideAsk":19069.320000000000000000000000, + // "InsideAskSize":0.0997360000000000000000000000, + // "InsideBid":19068.250000000000000000000000, + // "InsideBidSize":1.3300010000000000000000000000, + // "LastTradePrice":19068.250000000000000000000000, + // "RejectReason":"", + // "IsLockedIn":false, + // "CancelReason":"UserModified", + // "OrderFlag":"AddedToBook, RemovedFromBook", + // "UseMargin":false, + // "StopPrice":0.0000000000000000000000000000, + // "PegPriceType":"Unknown", + // "PegOffset":0.0000000000000000000000000000, + // "PegLimitOffset":0.0000000000000000000000000000, + // "IpAddress":"5.228.233.138", + // "ClientOrderIdUuid":null, + // "OMSId":1 + // }, + // ] + // + return this.parseOrders (response, market, since, limit); + } + + async fetchOrder (id, symbol = undefined, params = {}) { + const omsId = this.safeInteger (this.options, 'omsId', 1); + await this.loadMarkets (); + await this.loadAccounts (); + const defaultAccountId = this.safeInteger2 (this.options, 'accountId', 'AccountId', parseInt (this.accounts[0]['id'])); + const accountId = this.safeInteger2 (params, 'accountId', 'AccountId', defaultAccountId); + params = this.omit (params, [ 'accountId', 'AccountId' ]); + let market = undefined; + if (symbol !== undefined) { + market = this.market (symbol); + } + const request = { + 'omsId': omsId, + 'AccountId': accountId, + 'OrderId': parseInt (id), + }; + const response = await this.privateGetGetOrderStatus (this.extend (request, params)); + // + // { + // "Side":"Sell", + // "OrderId":2543565232, + // "Price":0.0000000000000000000000000000, + // "Quantity":0.0000000000000000000000000000, + // "DisplayQuantity":0.0000000000000000000000000000, + // "Instrument":8, + // "Account":449, + // "AccountName":"igor@ccxt.trade", + // "OrderType":"Market", + // "ClientOrderId":0, + // "OrderState":"FullyExecuted", + // "ReceiveTime":1607569475591, + // "ReceiveTimeTicks":637431662755912377, + // "LastUpdatedTime":1607569475596, + // "LastUpdatedTimeTicks":637431662755960902, + // "OrigQuantity":1.0000000000000000000000000000, + // "QuantityExecuted":1.0000000000000000000000000000, + // "GrossValueExecuted":19068.270478610000000000000000, + // "ExecutableValue":0.0000000000000000000000000000, + // "AvgPrice":19068.270478610000000000000000, + // "CounterPartyId":0, + // "ChangeReason":"Trade", + // "OrigOrderId":2543565232, + // "OrigClOrdId":0, + // "EnteredBy":446, + // "UserName":"igor@ccxt.trade", + // "IsQuote":false, + // "InsideAsk":19069.320000000000000000000000, + // "InsideAskSize":0.0997360000000000000000000000, + // "InsideBid":19069.310000000000000000000000, + // "InsideBidSize":0.2400950000000000000000000000, + // "LastTradePrice":19069.310000000000000000000000, + // "RejectReason":"", + // "IsLockedIn":false, + // "CancelReason":"", + // "OrderFlag":"0", + // "UseMargin":false, + // "StopPrice":0.0000000000000000000000000000, + // "PegPriceType":"Unknown", + // "PegOffset":0.0000000000000000000000000000, + // "PegLimitOffset":0.0000000000000000000000000000, + // "IpAddress":"5.228.233.138", + // "ClientOrderIdUuid":null, + // "OMSId":1 + // } + // + return this.parseOrder (response, market); + } + + async fetchOrderTrades (id, symbol = undefined, since = undefined, limit = undefined, params = {}) { + const omsId = this.safeInteger (this.options, 'omsId', 1); + await this.loadMarkets (); + await this.loadAccounts (); + // const defaultAccountId = this.safeInteger2 (this.options, 'accountId', 'AccountId', parseInt (this.accounts[0]['id'])); + // const accountId = this.safeInteger2 (params, 'accountId', 'AccountId', defaultAccountId); + // params = this.omit (params, [ 'accountId', 'AccountId' ]); + let market = undefined; + if (symbol !== undefined) { + market = this.market (symbol); + } + const request = { + 'OMSId': parseInt (omsId), + // 'AccountId': accountId, + 'OrderId': id, + }; + const response = await this.privatePostGetOrderHistoryByOrderId (this.extend (request, params)); + // + // [ + // { + // "Side":"Sell", + // "OrderId":2543565235, + // "Price":18600.000000000000000000000000, + // "Quantity":0.0000000000000000000000000000, + // "DisplayQuantity":0.0000000000000000000000000000, + // "Instrument":8, + // "Account":449, + // "AccountName":"igor@ccxt.trade", + // "OrderType":"Limit", + // "ClientOrderId":0, + // "OrderState":"FullyExecuted", + // "ReceiveTime":1607585844956, + // "ReceiveTimeTicks":637431826449564182, + // "LastUpdatedTime":1607585844959, + // "LastUpdatedTimeTicks":637431826449593893, + // "OrigQuantity":0.1230000000000000000000000000, + // "QuantityExecuted":0.1230000000000000000000000000, + // "GrossValueExecuted":2345.3947500000000000000000000, + // "ExecutableValue":0.0000000000000000000000000000, + // "AvgPrice":19068.250000000000000000000000, + // "CounterPartyId":0, + // "ChangeReason":"Trade", + // "OrigOrderId":2543565235, + // "OrigClOrdId":0, + // "EnteredBy":446, + // "UserName":"igor@ccxt.trade", + // "IsQuote":false, + // "InsideAsk":19069.320000000000000000000000, + // "InsideAskSize":0.0997360000000000000000000000, + // "InsideBid":19068.250000000000000000000000, + // "InsideBidSize":1.3300010000000000000000000000, + // "LastTradePrice":19068.250000000000000000000000, + // "RejectReason":"", + // "IsLockedIn":false, + // "CancelReason":"", + // "OrderFlag":"0", + // "UseMargin":false, + // "StopPrice":0.0000000000000000000000000000, + // "PegPriceType":"Unknown", + // "PegOffset":0.0000000000000000000000000000, + // "PegLimitOffset":0.0000000000000000000000000000, + // "IpAddress":"5.228.233.138", + // "ClientOrderIdUuid":null, + // "OMSId":1 + // }, + // ] + // + const grouped = this.groupBy (response, 'ChangeReason'); + const trades = this.safeValue (grouped, 'Trade', []); + return this.parseTrades (trades, market, since, limit); + } + + async fetchDepositAddress (code, params = {}) { + const omsId = this.safeInteger (this.options, 'omsId', 1); + await this.loadMarkets (); + await this.loadAccounts (); + const defaultAccountId = this.safeInteger2 (this.options, 'accountId', 'AccountId', parseInt (this.accounts[0]['id'])); + const accountId = this.safeInteger2 (params, 'accountId', 'AccountId', defaultAccountId); + params = this.omit (params, [ 'accountId', 'AccountId' ]); + const currency = this.currency (code); + const request = { + 'omsId': omsId, + 'AccountId': accountId, + 'ProductId': currency['id'], + 'GenerateNewKey': false, + }; + const response = await this.privateGetGetDepositInfo (this.extend (request, params)); + // + // { + // "result":true, + // "errormsg":null, + // "statuscode":0, + // "AssetManagerId":1, + // "AccountId":57922, + // "AssetId":16, + // "ProviderId":23, + // "DepositInfo":"[\"0x8A27564b5c30b91C93B1591821642420F323a210\"]" + // } + // + return this.parseDepositAddress (response, currency); + } + + parseDepositAddress (depositAddress, currency = undefined) { + // + // fetchDepositAddress, createDepositAddress + // + // { + // "result":true, + // "errormsg":null, + // "statuscode":0, + // "AssetManagerId":1, + // "AccountId":449, + // "AssetId":1, + // "ProviderId":1, + // "DepositInfo":"[\"r3e95RwVsLH7yCbnMfyh7SA8FdwUJCB4S2?memo=241452010\"]" + // } + // + const depositInfoString = this.safeString (depositAddress, 'DepositInfo'); + const depositInfo = JSON.parse (depositInfoString); + const depositInfoLength = depositInfo.length; + const lastString = this.safeString (depositInfo, depositInfoLength - 1); + const parts = lastString.split ('?memo='); + const address = this.safeString (parts, 0); + const tag = this.safeString (parts, 1); + let code = undefined; + if (currency !== undefined) { + code = currency['code']; + } + this.checkAddress (address); + return { + 'currency': code, + 'address': address, + 'tag': tag, + 'info': depositAddress, + }; + } + + async createDepositAddress (code, params = {}) { + const request = { + 'GenerateNewKey': true, + }; + return await this.fetchDepositAddress (code, this.extend (request, params)); + } + + async fetchDeposits (code = undefined, since = undefined, limit = undefined, params = {}) { + const omsId = this.safeInteger (this.options, 'omsId', 1); + await this.loadMarkets (); + await this.loadAccounts (); + const defaultAccountId = this.safeInteger2 (this.options, 'accountId', 'AccountId', parseInt (this.accounts[0]['id'])); + const accountId = this.safeInteger2 (params, 'accountId', 'AccountId', defaultAccountId); + params = this.omit (params, [ 'accountId', 'AccountId' ]); + let currency = undefined; + if (code !== undefined) { + currency = this.currency (code); + } + const request = { + 'omsId': omsId, + 'AccountId': accountId, + }; + const response = await this.privateGetGetDeposits (this.extend (request, params)); + // + // [ + // { + // "OMSId":1, + // "DepositId":44, + // "AccountId":449, + // "SubAccountId":0, + // "ProductId":4, + // "Amount":200.00000000000000000000000000, + // "LastUpdateTimeStamp":637431291261187806, + // "ProductType":"CryptoCurrency", + // "TicketStatus":"FullyProcessed", + // "DepositInfo":"{}", + // "DepositCode":"ab0e23d5-a9ce-4d94-865f-9ab464fb1de3", + // "TicketNumber":71, + // "NotionalProductId":13, + // "NotionalValue":200.00000000000000000000000000, + // "FeeAmount":0.0000000000000000000000000000, + // }, + // ] + // + return this.parseTransactions (response, currency, since, limit); + } + + async fetchWithdrawals (code = undefined, since = undefined, limit = undefined, params = {}) { + const omsId = this.safeInteger (this.options, 'omsId', 1); + await this.loadMarkets (); + await this.loadAccounts (); + const defaultAccountId = this.safeInteger2 (this.options, 'accountId', 'AccountId', parseInt (this.accounts[0]['id'])); + const accountId = this.safeInteger2 (params, 'accountId', 'AccountId', defaultAccountId); + params = this.omit (params, [ 'accountId', 'AccountId' ]); + let currency = undefined; + if (code !== undefined) { + currency = this.currency (code); + } + const request = { + 'omsId': omsId, + 'AccountId': accountId, + }; + const response = await this.privateGetGetWithdraws (this.extend (request, params)); + // + // [ + // { + // "Amount": 0.0, + // "FeeAmount": 0.0, + // "NotionalValue": 0.0, + // "WithdrawId": 0, + // "AssetManagerId": 0, + // "AccountId": 0, + // "AssetId": 0, + // "TemplateForm": "{\"TemplateType\": \"TetherRPCWithdraw\",\"Comment\": \"TestWithdraw\",\"ExternalAddress\": \"ms6C3pKAAr8gRCcnVebs8VRkVrjcvqNYv3\"}", + // "TemplateFormType": "TetherRPCWithdraw", + // "omsId": 0, + // "TicketStatus": 0, + // "TicketNumber": 0, + // "WithdrawTransactionDetails": "", + // "WithdrawType": "", + // "WithdrawCode": "490b4fa3-53fc-44f4-bd29-7e16be86fba3", + // "AssetType": 0, + // "Reaccepted": true, + // "NotionalProductId": 0 + // }, + // ] + // + return this.parseTransactions (response, currency, since, limit); + } + + parseTransactionStatusByType (status, type = undefined) { + const statusesByType = { + 'deposit': { + 'New': 'pending', // new ticket awaiting operator review + 'AdminProcessing': 'pending', // an admin is looking at the ticket + 'Accepted': 'pending', // an admin accepts the ticket + 'Rejected': 'rejected', // admin rejects the ticket + 'SystemProcessing': 'pending', // automatic processing; an unlikely status for a deposit + 'FullyProcessed': 'ok', // the deposit has concluded + 'Failed': 'failed', // the deposit has failed for some reason + 'Pending': 'pending', // Account Provider has set status to pending + 'Confirmed': 'pending', // Account Provider confirms the deposit + 'AmlProcessing': 'pending', // anti-money-laundering process underway + 'AmlAccepted': 'pending', // anti-money-laundering process successful + 'AmlRejected': 'rejected', // deposit did not stand up to anti-money-laundering process + 'AmlFailed': 'failed', // anti-money-laundering process failed/did not complete + 'LimitsAccepted': 'pending', // deposit meets limits for fiat or crypto asset + 'LimitsRejected': 'rejected', // deposit does not meet limits for fiat or crypto asset + }, + 'withdrawal': { + 'New': 'pending', // awaiting operator review + 'AdminProcessing': 'pending', // An admin is looking at the ticket + 'Accepted': 'pending', // withdrawal will proceed + 'Rejected': 'rejected', // admin or automatic rejection + 'SystemProcessing': 'pending', // automatic processing underway + 'FullyProcessed': 'ok', // the withdrawal has concluded + 'Failed': 'failed', // the withdrawal failed for some reason + 'Pending': 'pending', // the admin has placed the withdrawal in pending status + 'Pending2Fa': 'pending', // user must click 2-factor authentication confirmation link + 'AutoAccepted': 'pending', // withdrawal will be automatically processed + 'Delayed': 'pending', // waiting for funds to be allocated for the withdrawal + 'UserCanceled': 'canceled', // withdraw canceled by user or Superuser + 'AdminCanceled': 'canceled', // withdraw canceled by Superuser + 'AmlProcessing': 'pending', // anti-money-laundering process underway + 'AmlAccepted': 'pending', // anti-money-laundering process complete + 'AmlRejected': 'rejected', // withdrawal did not stand up to anti-money-laundering process + 'AmlFailed': 'failed', // withdrawal did not complete anti-money-laundering process + 'LimitsAccepted': 'pending', // withdrawal meets limits for fiat or crypto asset + 'LimitsRejected': 'rejected', // withdrawal does not meet limits for fiat or crypto asset + 'Submitted': 'pending', // withdrawal sent to Account Provider; awaiting blockchain confirmation + 'Confirmed': 'pending', // Account Provider confirms that withdrawal is on the blockchain + 'ManuallyConfirmed': 'pending', // admin has sent withdrawal via wallet or admin function directly; marks ticket as FullyProcessed; debits account + 'Confirmed2Fa': 'pending', // user has confirmed withdraw via 2-factor authentication. + }, + }; + const statuses = this.safeValue (statusesByType, type, {}); + return this.safeString (statuses, status, status); + } + + parseTransaction (transaction, currency = undefined) { + // + // fetchDeposits + // + // { + // "OMSId":1, + // "DepositId":44, + // "AccountId":449, + // "SubAccountId":0, + // "ProductId":4, + // "Amount":200.00000000000000000000000000, + // "LastUpdateTimeStamp":637431291261187806, + // "ProductType":"CryptoCurrency", + // "TicketStatus":"FullyProcessed", + // "DepositInfo":"{}", + // "DepositCode":"ab0e23d5-a9ce-4d94-865f-9ab464fb1de3", + // "TicketNumber":71, + // "NotionalProductId":13, + // "NotionalValue":200.00000000000000000000000000, + // "FeeAmount":0.0000000000000000000000000000, + // } + // + // fetchWithdrawals + // + // { + // "Amount": 0.0, + // "FeeAmount": 0.0, + // "NotionalValue": 0.0, + // "WithdrawId": 0, + // "AssetManagerId": 0, + // "AccountId": 0, + // "AssetId": 0, + // "TemplateForm": "{\"TemplateType\": \"TetherRPCWithdraw\",\"Comment\": \"TestWithdraw\",\"ExternalAddress\": \"ms6C3pKAAr8gRCcnVebs8VRkVrjcvqNYv3\"}", + // "TemplateFormType": "TetherRPCWithdraw", + // "omsId": 0, + // "TicketStatus": 0, + // "TicketNumber": 0, + // "WithdrawTransactionDetails": "", + // "WithdrawType": "", + // "WithdrawCode": "490b4fa3-53fc-44f4-bd29-7e16be86fba3", + // "AssetType": 0, + // "Reaccepted": true, + // "NotionalProductId": 0 + // } + // + const id = this.safeString (transaction, 'DepositId'); + let txid = undefined; + const currencyId = this.safeString (transaction, 'ProductId'); + const code = this.safeCurrencyCode (currencyId, currency); + let timestamp = undefined; + let type = undefined; + if ('DepositId' in transaction) { + type = 'deposit'; + } else if ('WithdrawId' in transaction) { + type = 'withdrawal'; + } + const templateFormString = this.safeString (transaction, 'TemplateForm'); + let address = undefined; + let updated = this.safeInteger (transaction, 'LastUpdateTimeStamp'); + if (templateFormString !== undefined) { + const templateForm = JSON.parse (templateFormString); + address = this.safeString (templateForm, 'ExternalAddress'); + txid = this.safeString (templateForm, 'TxId'); + timestamp = this.safeInteger (templateForm, 'TimeSubmitted'); + updated = this.safeInteger (templateForm, 'LastUpdated', updated); + } + const addressTo = address; + const status = this.parseTransactionStatusByType (this.safeString (transaction, 'TicketStatus'), type); + const amount = this.safeFloat (transaction, 'Amount'); + const feeCost = this.safeFloat (transaction, 'FeeAmount'); + let fee = undefined; + if (feeCost !== undefined) { + fee = { 'currency': code, 'cost': feeCost }; + } + return { + 'info': transaction, + 'id': id, + 'txid': txid, + 'timestamp': timestamp, + 'datetime': this.iso8601 (timestamp), + 'address': address, + 'addressTo': addressTo, + 'addressFrom': undefined, + 'tag': undefined, + 'tagTo': undefined, + 'tagFrom': undefined, + 'type': type, + 'amount': amount, + 'currency': code, + 'status': status, + 'updated': updated, + 'fee': fee, + }; + } + + nonce () { + return this.milliseconds (); + } + + sign (path, api = 'public', method = 'GET', params = {}, headers = undefined, body = undefined) { + let url = this.urls['api'][api] + '/' + this.implodeParams (path, params); + const query = this.omit (params, this.extractParams (path)); + if (api === 'public') { + if (Object.keys (query).length) { + url += '?' + this.urlencode (query); + } + } else if (api === 'private') { + this.checkRequiredCredentials (); + const nonce = this.nonce ().toString (); + const auth = nonce + this.uid + this.apiKey; + const signature = this.hmac (this.encode (auth), this.encode (this.secret)); + headers = { + 'Nonce': nonce, + 'APIKey': this.apiKey, + 'Signature': signature, + 'UserId': this.uid, + }; + if (method === 'POST') { + headers['Content-Type'] = 'application/json'; + body = this.json (query); + } else { + if (Object.keys (query).length) { + url += '?' + this.urlencode (query); + } + } + } + return { 'url': url, 'method': method, 'body': body, 'headers': headers }; + } + + handleErrors (code, reason, url, method, headers, body, response, requestHeaders, requestBody) { + if (code === 404) { + throw new AuthenticationError (this.id + ' ' + body); + } + if (response === undefined) { + return; + } + // + // {"status":"Rejected","errormsg":"Not_Enough_Funds","errorcode":101} + // {"result":false,"errormsg":"Server Error","errorcode":102,"detail":null} + // + const message = this.safeString (response, 'errormsg'); + if ((message !== undefined) && (message !== '')) { + const feedback = this.id + ' ' + body; + this.throwExactlyMatchedException (this.exceptions['exact'], message, feedback); + this.throwBroadlyMatchedException (this.exceptions['broad'], body, feedback); + throw new ExchangeError (feedback); + } + } +}; diff --git a/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/novadax.js b/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/novadax.js index c02d4f1a9..dfc6569d2 100644 --- a/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/novadax.js +++ b/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/novadax.js @@ -871,6 +871,7 @@ module.exports = class novadax extends Exchange { 'symbol': symbol, 'type': type, 'timeInForce': undefined, + 'postOnly': undefined, 'side': side, 'price': price, 'stopPrice': undefined, diff --git a/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/oceanex.js b/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/oceanex.js index b77c3dde7..28cb8e857 100644 --- a/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/oceanex.js +++ b/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/oceanex.js @@ -512,7 +512,7 @@ module.exports = class oceanex extends Exchange { async fetchOrders (symbol = undefined, since = undefined, limit = undefined, params = {}) { if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' fetchOrders requires a `symbol` argument'); + throw new ArgumentsRequired (this.id + ' fetchOrders() requires a `symbol` argument'); } await this.loadMarkets (); const market = this.market (symbol); @@ -573,6 +573,7 @@ module.exports = class oceanex extends Exchange { 'symbol': symbol, 'type': this.safeValue (order, 'ord_type'), 'timeInForce': undefined, + 'postOnly': undefined, 'side': this.safeValue (order, 'side'), 'price': this.safeFloat (order, 'price'), 'stopPrice': undefined, diff --git a/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/okex.js b/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/okex.js index a1d6e3c48..b9b09c4e0 100644 --- a/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/okex.js +++ b/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/okex.js @@ -3,7 +3,7 @@ // --------------------------------------------------------------------------- const Exchange = require ('./base/Exchange'); -const { ExchangeError, ExchangeNotAvailable, OnMaintenance, ArgumentsRequired, BadRequest, AccountSuspended, InvalidAddress, PermissionDenied, DDoSProtection, InsufficientFunds, InvalidNonce, CancelPending, InvalidOrder, OrderNotFound, AuthenticationError, RequestTimeout, NotSupported, BadSymbol } = require ('./base/errors'); +const { ExchangeError, ExchangeNotAvailable, OnMaintenance, ArgumentsRequired, BadRequest, AccountSuspended, InvalidAddress, PermissionDenied, DDoSProtection, InsufficientFunds, InvalidNonce, CancelPending, InvalidOrder, OrderNotFound, AuthenticationError, RequestTimeout, NotSupported, BadSymbol, RateLimitExceeded } = require ('./base/errors'); const { TICK_SIZE, TRUNCATE } = require ('./base/functions/number'); // --------------------------------------------------------------------------- @@ -108,6 +108,7 @@ module.exports = class okex extends Exchange { 'accounts/{currency}', 'accounts/{currency}/ledger', 'orders', + 'amend_order/{instrument_id}', 'orders_pending', 'orders/{order_id}', 'orders/{client_oid}', @@ -198,6 +199,7 @@ module.exports = class okex extends Exchange { 'post': [ 'accounts/{underlying}/leverage', 'order', + 'amend_order/{instrument_id}', 'orders', 'cancel_order/{instrument_id}/{order_id}', 'cancel_order/{instrument_id}/{client_oid}', @@ -244,12 +246,17 @@ module.exports = class okex extends Exchange { 'post': [ 'accounts/{instrument_id}/leverage', 'order', + 'amend_order/{instrument_id}', 'orders', 'cancel_order/{instrument_id}/{order_id}', 'cancel_order/{instrument_id}/{client_oid}', 'cancel_batch_orders/{instrument_id}', 'order_algo', 'cancel_algos', + 'close_position', + 'cancel_all', + 'order_algo', + 'cancel_algos', ], }, 'option': { @@ -526,7 +533,7 @@ module.exports = class okex extends Exchange { '34021': InvalidAddress, // { "code": 34021, "message": "Not verified address" } '34022': ExchangeError, // { "code": 34022, "message": "Withdrawals are not available for sub accounts" } '34023': PermissionDenied, // { "code": 34023, "message": "Please enable futures trading before transferring your funds" } - '34026': ExchangeError, // transfer too frequently(transfer too frequently) + '34026': RateLimitExceeded, // transfer too frequently(transfer too frequently) '34036': ExchangeError, // Parameter is incorrect, please refer to API documentation '34037': ExchangeError, // Get the sub-account balance interface, account type is not supported '34038': ExchangeError, // Since your C2C transaction is unusual, you are restricted from fund transfer. Please contact our customer support to cancel the restriction @@ -555,7 +562,7 @@ module.exports = class okex extends Exchange { '35031': InvalidOrder, // { "code": 35031, "message": "Cancel order size too large" } '35032': ExchangeError, // { "code": 35032, "message": "Invalid user status" } '35037': ExchangeError, // No last traded price in cache - '35039': ExchangeError, // { "code": 35039, "message": "Open order quantity exceeds limit" } + '35039': InsufficientFunds, // { "code": 35039, "message": "Open order quantity exceeds limit" } '35040': InvalidOrder, // {"error_message":"Invalid order type","result":"true","error_code":"35040","order_id":"-1"} '35044': ExchangeError, // { "code": 35044, "message": "Invalid order status" } '35046': InsufficientFunds, // { "code": 35046, "message": "Negative account balance" } @@ -608,6 +615,7 @@ module.exports = class okex extends Exchange { '35097': ExchangeError, // Order status and order ID cannot exist at the same time '35098': ExchangeError, // An order status or order ID must exist '35099': ExchangeError, // Algo order ID error + '35102': RateLimitExceeded, // {"error_message":"The operation that close all at market price is too frequent","result":"true","error_code":"35102","order_id":"-1"} // option '36001': BadRequest, // Invalid underlying index. '36002': BadRequest, // Instrument does not exist. @@ -677,6 +685,7 @@ module.exports = class okex extends Exchange { 'HOT': 'Hydro Protocol', 'HSR': 'HC', 'MAG': 'Maggie', + 'SBTC': 'Super Bitcoin', 'YOYO': 'YOYOW', 'WIN': 'WinToken', // https://github.com/ccxt/ccxt/issues/5701 }, @@ -976,7 +985,7 @@ module.exports = class okex extends Exchange { const currency = response[i]; const id = this.safeString (currency, 'currency'); const code = this.safeCurrencyCode (id); - const precision = 8; // default precision, todo: fix "magic constants" + const precision = 0.00000001; // default precision, todo: fix "magic constants" const name = this.safeString (currency, 'name'); const canDeposit = this.safeInteger (currency, 'can_deposit'); const canWithdraw = this.safeInteger (currency, 'can_withdraw'); @@ -1712,7 +1721,7 @@ module.exports = class okex extends Exchange { const defaultType = this.safeString2 (this.options, 'fetchBalance', 'defaultType'); const type = this.safeString (params, 'type', defaultType); if (type === undefined) { - throw new ArgumentsRequired (this.id + " fetchBalance requires a type parameter (one of 'account', 'spot', 'margin', 'futures', 'swap')"); + throw new ArgumentsRequired (this.id + " fetchBalance() requires a type parameter (one of 'account', 'spot', 'margin', 'futures', 'swap')"); } await this.loadMarkets (); const suffix = (type === 'account') ? 'Wallet' : 'Accounts'; @@ -1958,7 +1967,7 @@ module.exports = class okex extends Exchange { type = this.safeString (params, 'type', defaultType); } if (type === undefined) { - throw new ArgumentsRequired (this.id + " cancelOrder requires a type parameter (one of 'spot', 'margin', 'futures', 'swap')."); + throw new ArgumentsRequired (this.id + " cancelOrder() requires a type parameter (one of 'spot', 'margin', 'futures', 'swap')."); } let method = type + 'PostCancelOrder'; const request = { @@ -2165,6 +2174,7 @@ module.exports = class okex extends Exchange { 'symbol': symbol, 'type': type, 'timeInForce': undefined, + 'postOnly': undefined, 'side': side, 'price': price, 'stopPrice': stopPrice, @@ -2181,14 +2191,14 @@ module.exports = class okex extends Exchange { async fetchOrder (id, symbol = undefined, params = {}) { if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' fetchOrder requires a symbol argument'); + throw new ArgumentsRequired (this.id + ' fetchOrder() requires a symbol argument'); } await this.loadMarkets (); const market = this.market (symbol); const defaultType = this.safeString2 (this.options, 'fetchOrder', 'defaultType', market['type']); const type = this.safeString (params, 'type', defaultType); if (type === undefined) { - throw new ArgumentsRequired (this.id + " fetchOrder requires a type parameter (one of 'spot', 'margin', 'futures', 'swap')."); + throw new ArgumentsRequired (this.id + " fetchOrder() requires a type parameter (one of 'spot', 'margin', 'futures', 'swap')."); } const instrumentId = (market['futures'] || market['swap']) ? 'InstrumentId' : ''; let method = type + 'GetOrders' + instrumentId; @@ -2256,7 +2266,7 @@ module.exports = class okex extends Exchange { async fetchOrdersByState (state, symbol = undefined, since = undefined, limit = undefined, params = {}) { if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' fetchOrdersByState requires a symbol argument'); + throw new ArgumentsRequired (this.id + ' fetchOrdersByState() requires a symbol argument'); } await this.loadMarkets (); const market = this.market (symbol); @@ -2268,7 +2278,7 @@ module.exports = class okex extends Exchange { type = this.safeString (params, 'type', defaultType); } if (type === undefined) { - throw new ArgumentsRequired (this.id + " fetchOrder requires a type parameter (one of 'spot', 'margin', 'futures', 'swap')."); + throw new ArgumentsRequired (this.id + " fetchOrdersByState() requires a type parameter (one of 'spot', 'margin', 'futures', 'swap')."); } const request = { 'instrument_id': market['id'], @@ -2598,6 +2608,7 @@ module.exports = class okex extends Exchange { // "currency": "XMR", // "from": "", // "to": "48PjH3ksv1fiXniKvKvyH5UtFs5WhfS2Vf7U3TwzdRJtCc7HJWvCQe56dRahyhQyTAViXZ8Nzk4gQg6o4BJBMUoxNy8y8g7", + // "tag": "1234567", // "deposit_id": 11571659, <-- we can use this // "timestamp": "2019-10-01T14:54:19.000Z", // "status": "2" @@ -2609,6 +2620,7 @@ module.exports = class okex extends Exchange { const withdrawalId = this.safeString (transaction, 'withdrawal_id'); const addressFrom = this.safeString (transaction, 'from'); const addressTo = this.safeString (transaction, 'to'); + const tagTo = this.safeString (transaction, 'tag'); if (withdrawalId !== undefined) { type = 'withdrawal'; id = withdrawalId; @@ -2649,8 +2661,8 @@ module.exports = class okex extends Exchange { 'addressTo': addressTo, 'address': address, 'tagFrom': undefined, - 'tagTo': undefined, - 'tag': undefined, + 'tagTo': tagTo, + 'tag': tagTo, 'status': status, 'type': type, 'updated': undefined, @@ -2823,7 +2835,7 @@ module.exports = class okex extends Exchange { // this aspect renders the 'fills' endpoint unusable for fetchOrderTrades // until either OKEX fixes the API or we workaround this on our side somehow if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' fetchMyTrades requires a symbol argument'); + throw new ArgumentsRequired (this.id + ' fetchMyTrades() requires a symbol argument'); } await this.loadMarkets (); const market = this.market (symbol); @@ -3212,16 +3224,28 @@ module.exports = class okex extends Exchange { request['limit'] = limit; } let currency = undefined; - if ((type === 'spot') || (type === 'futures')) { + if (type === 'spot') { if (code === undefined) { - throw new ArgumentsRequired (this.id + " fetchLedger requires a currency code argument for '" + type + "' markets"); + throw new ArgumentsRequired (this.id + " fetchLedger() requires a currency code argument for '" + type + "' markets"); } argument = 'Currency'; currency = this.currency (code); request['currency'] = currency['id']; + } else if (type === 'futures') { + if (code === undefined) { + throw new ArgumentsRequired (this.id + " fetchLedger() requires an underlying symbol for '" + type + "' markets"); + } + argument = 'Underlying'; + const market = this.market (code); // we intentionally put a market inside here for the margin and swap ledgers + const marketInfo = this.safeValue (market, 'info', {}); + const settlementCurrencyId = this.safeString (marketInfo, 'settlement_currency'); + const settlementCurrencyСode = this.safeCurrencyCode (settlementCurrencyId); + currency = this.currency (settlementCurrencyСode); + const underlyingId = this.safeString (marketInfo, 'underlying'); + request['underlying'] = underlyingId; } else if ((type === 'margin') || (type === 'swap')) { if (code === undefined) { - throw new ArgumentsRequired (this.id + " fetchLedger requires a code argument (a market symbol) for '" + type + "' markets"); + throw new ArgumentsRequired (this.id + " fetchLedger() requires a code argument (a market symbol) for '" + type + "' markets"); } argument = 'InstrumentId'; const market = this.market (code); // we intentionally put a market inside here for the margin and swap ledgers diff --git a/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/phemex.js b/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/phemex.js index 5fa317455..b1c294ab2 100644 --- a/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/phemex.js +++ b/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/phemex.js @@ -102,6 +102,7 @@ module.exports = class phemex extends Exchange { 'exchange/spot/order/trades', // ?symbol=&start=&end=&limit=&offset= // swap 'accounts/accountPositions', // ?currency= + 'accounts/positions', // ?currency= 'orders/activeList', // ?symbol= 'exchange/order/list', // ?symbol=&start=&end=&offset=&limit=&ordStatus=&withCount= 'exchange/order', // ?symbol=&orderID= @@ -728,7 +729,7 @@ module.exports = class phemex extends Exchange { parseBidAsk (bidask, priceKey = 0, amountKey = 1, market = undefined) { if (market === undefined) { - throw new ArgumentsRequired (this.id + ' parseBidAsk requires a market argument'); + throw new ArgumentsRequired (this.id + ' parseBidAsk() requires a market argument'); } let amount = this.safeFloat (bidask, amountKey); if (market['spot']) { @@ -821,6 +822,9 @@ module.exports = class phemex extends Exchange { } fromEn (en, scale, precision, precisionMode = undefined) { + if (en === undefined) { + return en; + } precisionMode = (precisionMode === undefined) ? this.precisionMode : precisionMode; return parseFloat (this.decimalToPrecision (en * Math.pow (10, -scale), ROUND, precision, precisionMode)); } @@ -864,13 +868,19 @@ module.exports = class phemex extends Exchange { // 48759063370, // quote volume // ] // + let baseVolume = undefined; + if ((market !== undefined) && market['spot']) { + baseVolume = this.fromEv (this.safeFloat (ohlcv, 7), market); + } else { + baseVolume = this.safeInteger (ohlcv, 7); + } return [ this.safeTimestamp (ohlcv, 0), this.fromEp (this.safeFloat (ohlcv, 3), market), this.fromEp (this.safeFloat (ohlcv, 4), market), this.fromEp (this.safeFloat (ohlcv, 5), market), this.fromEp (this.safeFloat (ohlcv, 6), market), - this.fromEv (this.safeFloat (ohlcv, 7), market), + baseVolume, ]; } @@ -897,7 +907,7 @@ module.exports = class phemex extends Exchange { request['from'] = now - duration * this.sum (limit, 1); request['to'] = now; } else { - throw new ArgumentsRequired (this.id + ' fetchOHLCV requires a since argument, or a limit argument, or both'); + throw new ArgumentsRequired (this.id + ' fetchOHLCV() requires a since argument, or a limit argument, or both'); } await this.loadMarkets (); const market = this.market (symbol); @@ -1402,7 +1412,7 @@ module.exports = class phemex extends Exchange { } else { const currency = this.safeString (params, 'currency'); if (currency === undefined) { - throw new ArgumentsRequired (this.id + ' fetchBalance requires a code parameter or a currency parameter for ' + type + ' type'); + throw new ArgumentsRequired (this.id + ' fetchBalance() requires a code parameter or a currency parameter for ' + type + ' type'); } } method = 'privateGetAccountsAccountPositions'; @@ -1637,8 +1647,9 @@ module.exports = class phemex extends Exchange { filled = Math.min (0, amount - remaining); } } - const timeInForce = this.parseTimeInForce (this.safeStirng (order, 'timeInForce')); + const timeInForce = this.parseTimeInForce (this.safeString (order, 'timeInForce')); const stopPrice = this.fromEp (this.safeFloat (order, 'stopPxEp', market)); + const postOnly = (timeInForce === 'PO'); return { 'info': order, 'id': id, @@ -1649,6 +1660,7 @@ module.exports = class phemex extends Exchange { 'symbol': symbol, 'type': type, 'timeInForce': timeInForce, + 'postOnly': postOnly, 'side': side, 'price': price, 'stopPrice': stopPrice, @@ -1721,6 +1733,7 @@ module.exports = class phemex extends Exchange { } const timeInForce = this.parseTimeInForce (this.safeString (order, 'timeInForce')); const stopPrice = this.safeFloat (order, 'stopPx'); + const postOnly = (timeInForce === 'PO'); return { 'info': order, 'id': id, @@ -1731,6 +1744,7 @@ module.exports = class phemex extends Exchange { 'symbol': symbol, 'type': type, 'timeInForce': timeInForce, + 'postOnly': postOnly, 'side': side, 'price': price, 'stopPrice': stopPrice, @@ -1786,8 +1800,10 @@ module.exports = class phemex extends Exchange { }; if (market['spot']) { let qtyType = this.safeValue (params, 'qtyType', 'ByBase'); - if (price !== undefined) { - qtyType = 'ByQuote'; + if ((type === 'Market') || (type === 'Stop') || (type === 'MarketIfTouched')) { + if (price !== undefined) { + qtyType = 'ByQuote'; + } } request['qtyType'] = qtyType; if (qtyType === 'ByQuote') { @@ -1797,7 +1813,7 @@ module.exports = class phemex extends Exchange { if (price !== undefined) { cost = amount * price; } else if (cost === undefined) { - throw new ArgumentsRequired (this.id + ' createOrder ' + qtyType + ' requires a price argument or a cost parameter'); + throw new ArgumentsRequired (this.id + ' createOrder() ' + qtyType + ' requires a price argument or a cost parameter'); } } cost = (cost === undefined) ? amount : cost; @@ -1900,7 +1916,7 @@ module.exports = class phemex extends Exchange { async cancelOrder (id, symbol = undefined, params = {}) { if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' cancelOrder requires a symbol argument'); + throw new ArgumentsRequired (this.id + ' cancelOrder() requires a symbol argument'); } await this.loadMarkets (); const market = this.market (symbol); @@ -1940,7 +1956,7 @@ module.exports = class phemex extends Exchange { async fetchOrder (id, symbol = undefined, params = {}) { if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' fetchOrder requires a symbol argument'); + throw new ArgumentsRequired (this.id + ' fetchOrder() requires a symbol argument'); } await this.loadMarkets (); const market = this.market (symbol); @@ -1974,7 +1990,7 @@ module.exports = class phemex extends Exchange { async fetchOrders (symbol = undefined, since = undefined, limit = undefined, params = {}) { if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' fetchOrders requires a symbol argument'); + throw new ArgumentsRequired (this.id + ' fetchOrders() requires a symbol argument'); } await this.loadMarkets (); const market = this.market (symbol); @@ -1996,7 +2012,7 @@ module.exports = class phemex extends Exchange { async fetchOpenOrders (symbol = undefined, since = undefined, limit = undefined, params = {}) { if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' fetchOpenOrders requires a symbol argument'); + throw new ArgumentsRequired (this.id + ' fetchOpenOrders() requires a symbol argument'); } await this.loadMarkets (); const market = this.market (symbol); @@ -2020,7 +2036,7 @@ module.exports = class phemex extends Exchange { async fetchClosedOrders (symbol = undefined, since = undefined, limit = undefined, params = {}) { if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' fetchClosedOrders requires a symbol argument'); + throw new ArgumentsRequired (this.id + ' fetchClosedOrders() requires a symbol argument'); } await this.loadMarkets (); const market = this.market (symbol); @@ -2082,7 +2098,7 @@ module.exports = class phemex extends Exchange { async fetchMyTrades (symbol = undefined, since = undefined, limit = undefined, params = {}) { if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' fetchClosedOrders requires a symbol argument'); + throw new ArgumentsRequired (this.id + ' fetchClosedOrders() requires a symbol argument'); } await this.loadMarkets (); const market = this.market (symbol); @@ -2317,7 +2333,7 @@ module.exports = class phemex extends Exchange { const currencyId = this.safeString (transaction, 'currency'); currency = this.safeCurrency (currencyId, currency); const code = currency['code']; - const timestamp = this.safeInteger (transaction, 'createdAt'); + const timestamp = this.safeInteger2 (transaction, 'createdAt', 'submitedAt'); let type = this.safeStringLower (transaction, 'type'); const feeCost = this.fromEn (this.safeFloat (transaction, 'feeEv'), currency['valueScale'], currency['precision']); let fee = undefined; diff --git a/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/poloniex.js b/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/poloniex.js index f0b874031..30eee15c9 100644 --- a/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/poloniex.js +++ b/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/poloniex.js @@ -204,7 +204,6 @@ module.exports = class poloniex extends Exchange { 'Error pulling ': ExchangeError, // {"error":"Error pulling order book"} }, }, - 'orders': {}, // orders cache / emulation }); } @@ -923,6 +922,7 @@ module.exports = class poloniex extends Exchange { 'symbol': symbol, 'type': type, 'timeInForce': undefined, + 'postOnly': undefined, 'side': side, 'price': price, 'stopPrice': undefined, diff --git a/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/probit.js b/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/probit.js index 9fb49b9d1..522045f2c 100644 --- a/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/probit.js +++ b/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/probit.js @@ -121,6 +121,7 @@ module.exports = class probit extends Exchange { 'RATE_LIMIT_EXCEEDED': RateLimitExceeded, // You are sending requests too frequently. Please try it later. 'MARKET_UNAVAILABLE': ExchangeNotAvailable, // Market is closed today 'INVALID_MARKET': BadSymbol, // Requested market is not exist + 'MARKET_CLOSED': BadSymbol, // {"errorCode":"MARKET_CLOSED"} 'INVALID_CURRENCY': BadRequest, // Requested currency is not exist on ProBit system 'TOO_MANY_OPEN_ORDERS': DDoSProtection, // Too many open orders 'DUPLICATE_ADDRESS': InvalidAddress, // Address already exists in withdrawal address list @@ -142,6 +143,7 @@ module.exports = class probit extends Exchange { 'BTCBEAR': 'BEAR', 'BTCBULL': 'BULL', 'CBC': 'CryptoBharatCoin', + 'HBC': 'Hybrid Bank Cash', 'UNI': 'UNICORN Token', }, }); @@ -299,7 +301,18 @@ module.exports = class probit extends Exchange { const withdrawalSuspended = this.safeValue (platform, 'withdrawal_suspended'); const active = !(depositSuspended && withdrawalSuspended); const withdrawalFees = this.safeValue (platform, 'withdrawal_fee', {}); - const withdrawalFeesByPriority = this.sortBy (withdrawalFees, 'priority'); + const fees = []; + // sometimes the withdrawal fee is an empty object + // [ { 'amount': '0.015', 'priority': 1, 'currency_id': 'ETH' }, {} ] + for (let j = 0; j < withdrawalFees.length; j++) { + const withdrawalFee = withdrawalFees[j]; + const amount = this.safeFloat (withdrawalFee, 'amount'); + const priority = this.safeInteger (withdrawalFee, 'priority'); + if ((amount !== undefined) && (priority !== undefined)) { + fees.push (withdrawalFee); + } + } + const withdrawalFeesByPriority = this.sortBy (fees, 'priority'); const withdrawalFee = this.safeValue (withdrawalFeesByPriority, 0, {}); const fee = this.safeFloat (withdrawalFee, 'amount'); result[code] = { @@ -729,7 +742,7 @@ module.exports = class probit extends Exchange { let endTime = now; if (since === undefined) { if (limit === undefined) { - throw new ArgumentsRequired (this.id + ' fetchOHLCV requires either a since argument or a limit argument'); + throw new ArgumentsRequired (this.id + ' fetchOHLCV() requires either a since argument or a limit argument'); } else { startTime = now - limit * duration * 1000; } @@ -829,7 +842,7 @@ module.exports = class probit extends Exchange { async fetchOrder (id, symbol = undefined, params = {}) { if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' fetchOrder requires a symbol argument'); + throw new ArgumentsRequired (this.id + ' fetchOrder() requires a symbol argument'); } await this.loadMarkets (); const market = this.market (symbol); @@ -1022,7 +1035,7 @@ module.exports = class probit extends Exchange { async cancelOrder (id, symbol = undefined, params = {}) { if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' cancelOrder requires a symbol argument'); + throw new ArgumentsRequired (this.id + ' cancelOrder() requires a symbol argument'); } await this.loadMarkets (); const market = this.market (symbol); diff --git a/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/qtrade.js b/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/qtrade.js index b1a3ab46e..aa66545bf 100644 --- a/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/qtrade.js +++ b/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/qtrade.js @@ -915,6 +915,7 @@ module.exports = class qtrade extends Exchange { 'symbol': symbol, 'type': orderType, 'timeInForce': undefined, + 'postOnly': undefined, 'side': side, 'price': price, 'stopPrice': undefined, diff --git a/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/rightbtc.js b/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/rightbtc.js index ca2de52dd..d22048303 100644 --- a/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/rightbtc.js +++ b/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/rightbtc.js @@ -431,7 +431,7 @@ module.exports = class rightbtc extends Exchange { async cancelOrder (id, symbol = undefined, params = {}) { if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' cancelOrder requires a symbol argument'); + throw new ArgumentsRequired (this.id + ' cancelOrder() requires a symbol argument'); } await this.loadMarkets (); const market = this.market (symbol); @@ -541,6 +541,7 @@ module.exports = class rightbtc extends Exchange { 'symbol': symbol, 'type': type, 'timeInForce': undefined, + 'postOnly': undefined, 'side': side, 'price': price, 'stopPrice': undefined, @@ -557,7 +558,7 @@ module.exports = class rightbtc extends Exchange { async fetchOrder (id, symbol = undefined, params = {}) { if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' fetchOrder requires a symbol argument'); + throw new ArgumentsRequired (this.id + ' fetchOrder() requires a symbol argument'); } await this.loadMarkets (); const market = this.market (symbol); @@ -595,7 +596,7 @@ module.exports = class rightbtc extends Exchange { async fetchOpenOrders (symbol = undefined, since = undefined, limit = undefined, params = {}) { if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' fetchOpenOrders requires a symbol argument'); + throw new ArgumentsRequired (this.id + ' fetchOpenOrders() requires a symbol argument'); } await this.loadMarkets (); const market = this.market (symbol); @@ -632,7 +633,7 @@ module.exports = class rightbtc extends Exchange { async fetchOrders (symbol = undefined, since = undefined, limit = undefined, params = {}) { let ids = this.safeString (params, 'ids'); if ((symbol === undefined) || (ids === undefined)) { - throw new ArgumentsRequired (this.id + " fetchOrders requires a 'symbol' argument and an extra 'ids' parameter. The 'ids' should be an array or a string of one or more order ids separated with slashes."); // eslint-disable-line quotes + throw new ArgumentsRequired (this.id + " fetchOrders() requires a 'symbol' argument and an extra 'ids' parameter. The 'ids' should be an array or a string of one or more order ids separated with slashes."); // eslint-disable-line quotes } if (Array.isArray (ids)) { ids = ids.join ('/'); @@ -671,7 +672,7 @@ module.exports = class rightbtc extends Exchange { async fetchMyTrades (symbol = undefined, since = undefined, limit = undefined, params = {}) { if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' fetchMyTrades requires a symbol argument'); + throw new ArgumentsRequired (this.id + ' fetchMyTrades() requires a symbol argument'); } await this.loadMarkets (); const market = this.market (symbol); diff --git a/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/ripio.js b/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/ripio.js index 4c6595d11..b3a30607e 100644 --- a/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/ripio.js +++ b/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/ripio.js @@ -830,6 +830,7 @@ module.exports = class ripio extends Exchange { 'symbol': symbol, 'type': type, 'timeInForce': undefined, + 'postOnly': undefined, 'side': side, 'price': price, 'stopPrice': stopPrice, diff --git a/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/southxchange.js b/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/southxchange.js index 126cfdfb3..d2bdd8cec 100644 --- a/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/southxchange.js +++ b/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/southxchange.js @@ -264,6 +264,7 @@ module.exports = class southxchange extends Exchange { 'symbol': symbol, 'type': type, 'timeInForce': undefined, + 'postOnly': undefined, 'side': side, 'price': price, 'stopPrice': undefined, diff --git a/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/static_dependencies/elliptic/package.json b/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/static_dependencies/elliptic/package.json new file mode 100644 index 000000000..ec6f8c8e5 --- /dev/null +++ b/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/static_dependencies/elliptic/package.json @@ -0,0 +1,84 @@ +{ + "_args": [ + [ + "elliptic@6.4.0", + "/Users/carlorevelli/Documents/important/code/ccxt" + ] + ], + "_development": true, + "_from": "elliptic@6.4.0", + "_id": "elliptic@6.4.0", + "_inBundle": false, + "_integrity": "sha1-ysmvh2LIWDYYcAPI3+GT5eLq5d8=", + "_location": "/elliptic", + "_phantomChildren": {}, + "_requested": { + "type": "version", + "registry": true, + "raw": "elliptic@6.4.0", + "name": "elliptic", + "escapedName": "elliptic", + "rawSpec": "6.4.0", + "saveSpec": null, + "fetchSpec": "6.4.0" + }, + "_requiredBy": [ + "/browserify-sign", + "/create-ecdh" + ], + "_resolved": "https://registry.npmjs.org/elliptic/-/elliptic-6.4.0.tgz", + "_spec": "6.4.0", + "_where": "/Users/carlorevelli/Documents/important/code/ccxt", + "author": { + "name": "Fedor Indutny", + "email": "fedor@indutny.com" + }, + "bugs": { + "url": "https://github.com/indutny/elliptic/issues" + }, + "dependencies": { + }, + "description": "EC cryptography", + "devDependencies": { + "brfs": "^1.4.3", + "coveralls": "^2.11.3", + "grunt": "^0.4.5", + "grunt-browserify": "^5.0.0", + "grunt-cli": "^1.2.0", + "grunt-contrib-connect": "^1.0.0", + "grunt-contrib-copy": "^1.0.0", + "grunt-contrib-uglify": "^1.0.1", + "grunt-mocha-istanbul": "^3.0.1", + "grunt-saucelabs": "^8.6.2", + "istanbul": "^0.4.2", + "jscs": "^2.9.0", + "jshint": "^2.6.0", + "mocha": "^2.1.0" + }, + "files": [ + "lib" + ], + "homepage": "https://github.com/indutny/elliptic", + "keywords": [ + "EC", + "Elliptic", + "curve", + "Cryptography" + ], + "license": "MIT", + "main": "lib/elliptic.js", + "name": "elliptic", + "repository": { + "type": "git", + "url": "git+ssh://git@github.com/indutny/elliptic.git" + }, + "scripts": { + "jscs": "jscs benchmarks/*.js lib/*.js lib/**/*.js lib/**/**/*.js test/index.js", + "jshint": "jscs benchmarks/*.js lib/*.js lib/**/*.js lib/**/**/*.js test/index.js", + "lint": "npm run jscs && npm run jshint", + "test": "npm run lint && npm run unit", + "unit": "istanbul test _mocha --reporter=spec test/index.js", + "version": "grunt dist && git add dist/" + }, + "version": "6.4.0" +} diff --git a/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/stex.js b/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/stex.js index aaf34ea4a..af2e256f3 100644 --- a/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/stex.js +++ b/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/stex.js @@ -185,6 +185,8 @@ module.exports = class stex extends Exchange { 'BITS': 'Bitcoinus', 'BITSW': 'BITS', 'BHD': 'Bithold', + 'BTH': 'Bithereum', + 'SBTC': 'SBTCT', // SiamBitcoin }, 'options': { 'parseOrderToPrecision': false, @@ -926,6 +928,7 @@ module.exports = class stex extends Exchange { 'symbol': symbol, 'type': type, 'timeInForce': undefined, + 'postOnly': undefined, 'side': side, 'price': price, 'stopPrice': stopPrice, @@ -1222,7 +1225,7 @@ module.exports = class stex extends Exchange { async fetchMyTrades (symbol = undefined, since = undefined, limit = undefined, params = {}) { if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' fetchMyTrades requires a symbol argument'); + throw new ArgumentsRequired (this.id + ' fetchMyTrades() requires a symbol argument'); } await this.loadMarkets (); const market = this.market (symbol); diff --git a/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/test/Exchange/test.fetchCurrencies.js b/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/test/Exchange/test.fetchCurrencies.js index 79c018d74..563ed1eea 100644 --- a/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/test/Exchange/test.fetchCurrencies.js +++ b/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/test/Exchange/test.fetchCurrencies.js @@ -27,7 +27,9 @@ module.exports = async (exchange) => { const method = 'fetchCurrencies' const currencies = await exchange[method] () - Object.values (currencies).forEach ((currency) => testCurrency (exchange, currency, method)) + if (currencies !== undefined) { + Object.values (currencies).forEach ((currency) => testCurrency (exchange, currency, method)) + } return currencies } else { diff --git a/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/test/Exchange/test.ticker.js b/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/test/Exchange/test.ticker.js index 33a86ceaf..7d91ea0ba 100644 --- a/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/test/Exchange/test.ticker.js +++ b/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/test/Exchange/test.ticker.js @@ -82,8 +82,12 @@ module.exports = (exchange, ticker, method, symbol) => { 'okex', 'southxchange', // https://user-images.githubusercontent.com/1294454/59953532-314bea80-9489-11e9-85b3-2a711ca49aa7.png 'bitmart', + 'ftx', 'gateio', // some ticker bids are greaters than asks 'timex', + 'poloniex', + 'qtrade', + 'bigone', ].includes (exchange.id)) { diff --git a/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/therock.js b/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/therock.js index c26b1b8fe..12217e2b2 100644 --- a/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/therock.js +++ b/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/therock.js @@ -965,6 +965,7 @@ module.exports = class therock extends Exchange { 'symbol': symbol, 'type': type, 'timeInForce': undefined, + 'postOnly': undefined, 'side': side, 'price': price, 'stopPrice': stopPrice, @@ -994,7 +995,7 @@ module.exports = class therock extends Exchange { async fetchOrders (symbol = undefined, since = undefined, limit = undefined, params = {}) { if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' fetchOrders requires a symbol argument'); + throw new ArgumentsRequired (this.id + ' fetchOrders() requires a symbol argument'); } await this.loadMarkets (); const market = this.market (symbol); @@ -1039,7 +1040,7 @@ module.exports = class therock extends Exchange { async fetchOrder (id, symbol = undefined, params = {}) { if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' fetchOrder requires a symbol argument'); + throw new ArgumentsRequired (this.id + ' fetchOrder() requires a symbol argument'); } await this.loadMarkets (); const market = this.market (symbol); @@ -1078,7 +1079,7 @@ module.exports = class therock extends Exchange { async fetchMyTrades (symbol = undefined, since = undefined, limit = undefined, params = {}) { if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' fetchMyTrades requires a symbol argument'); + throw new ArgumentsRequired (this.id + ' fetchMyTrades() requires a symbol argument'); } await this.loadMarkets (); const market = this.market (symbol); diff --git a/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/tidebit.js b/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/tidebit.js index 1f2ef5cd9..acf65de25 100644 --- a/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/tidebit.js +++ b/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/tidebit.js @@ -422,6 +422,7 @@ module.exports = class tidebit extends Exchange { 'symbol': symbol, 'type': type, 'timeInForce': undefined, + 'postOnly': undefined, 'side': side, 'price': price, 'stopPrice': undefined, diff --git a/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/tidex.js b/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/tidex.js index 5b2504114..0988a4ad1 100644 --- a/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/tidex.js +++ b/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/tidex.js @@ -580,6 +580,7 @@ module.exports = class tidex extends Exchange { 'lastTradeTimestamp': undefined, 'type': 'limit', 'timeInForce': undefined, + 'postOnly': undefined, 'side': this.safeString (order, 'type'), 'price': price, 'stopPrice': undefined, diff --git a/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/timex.js b/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/timex.js index 3937e4660..4c71ac4ff 100644 --- a/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/timex.js +++ b/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/timex.js @@ -460,16 +460,19 @@ module.exports = class timex extends Exchange { async createOrder (symbol, type, side, amount, price = undefined, params = {}) { await this.loadMarkets (); const market = this.market (symbol); + const uppercaseSide = side.toUpperCase (); + const uppercaseType = type.toUpperCase (); const request = { 'symbol': market['id'], 'quantity': this.amountToPrecision (symbol, amount), - 'side': side.toUpperCase (), + 'side': uppercaseSide, + 'orderTypes': uppercaseType, // 'clientOrderId': '123', // 'expireIn': 1575523308, // in seconds // 'expireTime': 1575523308, // unix timestamp }; let query = params; - if (type === 'limit') { + if (uppercaseType === 'LIMIT') { request['price'] = this.priceToPrecision (symbol, price); const defaultExpireIn = this.safeInteger (this.options, 'expireIn'); const expireTime = this.safeValue (params, 'expireTime'); @@ -479,7 +482,7 @@ module.exports = class timex extends Exchange { } else if (expireIn !== undefined) { request['expireIn'] = expireIn; } else { - throw new InvalidOrder (this.id + ' createOrder method requires a expireTime or expireIn param for a ' + type + ' order, you can also set the expireIn exchange-wide option'); + throw new InvalidOrder (this.id + ' createOrder() method requires a expireTime or expireIn param for a ' + type + ' order, you can also set the expireIn exchange-wide option'); } query = this.omit (params, [ 'expireTime', 'expireIn' ]); } else { @@ -1182,6 +1185,7 @@ module.exports = class timex extends Exchange { 'symbol': symbol, 'type': type, 'timeInForce': undefined, + 'postOnly': undefined, 'side': side, 'price': price, 'stopPrice': undefined, diff --git a/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/upbit.js b/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/upbit.js index b7665f041..829aa6586 100644 --- a/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/upbit.js +++ b/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/upbit.js @@ -15,7 +15,6 @@ module.exports = class upbit extends Exchange { 'countries': [ 'KR' ], 'version': 'v1', 'rateLimit': 1000, - 'certified': true, 'pro': true, // new metainfo interface 'has': { @@ -221,7 +220,7 @@ module.exports = class upbit extends Exchange { const walletLocked = this.safeValue (memberInfo, 'wallet_locked'); const locked = this.safeValue (memberInfo, 'locked'); let active = true; - if ((canWithdraw !== undefined) && canWithdraw) { + if ((canWithdraw !== undefined) && !canWithdraw) { active = false; } else if (walletState !== 'working') { active = false; @@ -1204,6 +1203,7 @@ module.exports = class upbit extends Exchange { 'symbol': market['symbol'], 'type': type, 'timeInForce': undefined, + 'postOnly': undefined, 'side': side, 'price': price, 'stopPrice': undefined, diff --git a/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/vcc.js b/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/vcc.js index 006c36ec6..bd3a9602d 100644 --- a/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/vcc.js +++ b/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/vcc.js @@ -1056,6 +1056,7 @@ module.exports = class vcc extends Exchange { 'symbol': symbol, 'type': type, 'timeInForce': undefined, + 'postOnly': undefined, 'side': side, 'price': price, 'stopPrice': stopPrice, diff --git a/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/wavesexchange.js b/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/wavesexchange.js index 976435981..139780062 100644 --- a/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/wavesexchange.js +++ b/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/wavesexchange.js @@ -1056,7 +1056,7 @@ module.exports = class wavesexchange extends Exchange { this.checkRequiredDependencies (); this.checkRequiredKeys (); if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' fetchOrders requires symbol argument'); + throw new ArgumentsRequired (this.id + ' fetchOrders() requires symbol argument'); } await this.loadMarkets (); const market = this.market (symbol); @@ -1269,6 +1269,7 @@ module.exports = class wavesexchange extends Exchange { 'symbol': symbol, 'type': type, 'timeInForce': undefined, + 'postOnly': undefined, 'side': side, 'price': price, 'stopPrice': undefined, diff --git a/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/xena.js b/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/xena.js index 8be88d342..2facd429b 100644 --- a/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/xena.js +++ b/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/xena.js @@ -38,6 +38,10 @@ module.exports = class xena extends Exchange { }, 'urls': { 'logo': 'https://user-images.githubusercontent.com/51840849/87489843-bb469280-c64c-11ea-91aa-69c6326506af.jpg', + 'test': { + 'public': 'https://trading.demo.xena.io/api', + 'private': 'https://api.demo.xena.io', + }, 'api': { 'public': 'https://trading.xena.exchange/api', 'private': 'https://api.xena.exchange', @@ -958,6 +962,7 @@ module.exports = class xena extends Exchange { 'symbol': symbol, 'type': type, 'timeInForce': undefined, + 'postOnly': undefined, 'side': side, 'price': price, 'stopPrice': undefined, @@ -1017,14 +1022,14 @@ module.exports = class xena extends Exchange { }; if ((type === 'limit') || (type === 'stop-limit')) { if (price === undefined) { - throw new InvalidOrder (this.id + ' createOrder requires a price argument for order type ' + type); + throw new InvalidOrder (this.id + ' createOrder() requires a price argument for order type ' + type); } request['price'] = this.priceToPrecision (symbol, price); } if ((type === 'stop') || (type === 'stop-limit')) { const stopPx = this.safeFloat (params, 'stopPx'); if (stopPx === undefined) { - throw new InvalidOrder (this.id + ' createOrder requires a stopPx param for order type ' + type); + throw new InvalidOrder (this.id + ' createOrder() requires a stopPx param for order type ' + type); } request['stopPx'] = this.priceToPrecision (symbol, stopPx); params = this.omit (params, 'stopPx'); @@ -1062,7 +1067,7 @@ module.exports = class xena extends Exchange { async editOrder (id, symbol, type, side, amount = undefined, price = undefined, params = {}) { if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' cancelOrder requires a symbol argument'); + throw new ArgumentsRequired (this.id + ' cancelOrder() requires a symbol argument'); } await this.loadMarkets (); await this.loadAccounts (); @@ -1117,7 +1122,7 @@ module.exports = class xena extends Exchange { async cancelOrder (id, symbol = undefined, params = {}) { if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' cancelOrder requires a symbol argument'); + throw new ArgumentsRequired (this.id + ' cancelOrder() requires a symbol argument'); } await this.loadMarkets (); await this.loadAccounts (); diff --git a/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/yobit.js b/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/yobit.js index 46fc1d99d..0ab100f68 100644 --- a/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/yobit.js +++ b/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/yobit.js @@ -133,6 +133,7 @@ module.exports = class yobit extends Exchange { 'LOCX': 'LOC', 'LUNYR': 'LUN', 'LUN': 'LunarCoin', // they just change the ticker if it is already taken + 'MASK': 'Yobit MASK', 'MDT': 'Midnight', 'NAV': 'NavajoCoin', 'NBT': 'NiceBytes', @@ -149,6 +150,7 @@ module.exports = class yobit extends Exchange { 'RCN': 'RCoin', 'REP': 'Republicoin', 'RUR': 'RUB', + 'SBTC': 'Super Bitcoin', 'TTC': 'TittieCoin', 'UNI': 'Universe', 'UST': 'Uservice', @@ -595,6 +597,7 @@ module.exports = class yobit extends Exchange { 'lastTradeTimestamp': undefined, 'type': type, 'timeInForce': undefined, + 'postOnly': undefined, 'side': side, 'price': price, 'stopPrice': undefined, @@ -639,7 +642,7 @@ module.exports = class yobit extends Exchange { async fetchMyTrades (symbol = undefined, since = undefined, limit = undefined, params = {}) { if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' fetchMyTrades requires a `symbol` argument'); + throw new ArgumentsRequired (this.id + ' fetchMyTrades() requires a `symbol` argument'); } await this.loadMarkets (); const market = this.market (symbol); @@ -727,24 +730,6 @@ module.exports = class yobit extends Exchange { }; } - calculateFee (symbol, type, side, amount, price, takerOrMaker = 'taker', params = {}) { - const market = this.markets[symbol]; - let key = 'quote'; - const rate = market[takerOrMaker]; - let cost = parseFloat (this.costToPrecision (symbol, amount * rate)); - if (side === 'sell') { - cost *= price; - } else { - key = 'base'; - } - return { - 'type': takerOrMaker, - 'currency': market[key], - 'rate': rate, - 'cost': cost, - }; - } - sign (path, api = 'public', method = 'GET', params = {}, headers = undefined, body = undefined) { let url = this.urls['api'][api]; const query = this.omit (params, this.extractParams (path)); diff --git a/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/zaif.js b/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/zaif.js index b9618184e..2c6454a05 100644 --- a/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/zaif.js +++ b/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/zaif.js @@ -357,6 +357,7 @@ module.exports = class zaif extends Exchange { 'symbol': symbol, 'type': 'limit', 'timeInForce': undefined, + 'postOnly': undefined, 'side': side, 'price': price, 'stopPrice': undefined, diff --git a/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/zb.js b/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/zb.js index 9b4d81872..1f8f61cdf 100644 --- a/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/zb.js +++ b/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/zb.js @@ -3,7 +3,7 @@ // --------------------------------------------------------------------------- const Exchange = require ('./base/Exchange'); -const { BadRequest, ExchangeError, ArgumentsRequired, AuthenticationError, InsufficientFunds, OrderNotFound, ExchangeNotAvailable, DDoSProtection, InvalidOrder } = require ('./base/errors'); +const { BadRequest, ExchangeError, ArgumentsRequired, AuthenticationError, InsufficientFunds, OrderNotFound, ExchangeNotAvailable, DDoSProtection, InvalidOrder, InvalidAddress } = require ('./base/errors'); // --------------------------------------------------------------------------- @@ -22,15 +22,19 @@ module.exports = class zb extends Exchange { 'createOrder': true, 'fetchBalance': true, 'fetchDepositAddress': true, + 'fetchDepositAddresses': true, + 'fetchDeposits': true, 'fetchMarkets': true, 'fetchOHLCV': true, 'fetchOpenOrders': true, 'fetchOrder': true, 'fetchOrderBook': true, 'fetchOrders': true, + 'fetchClosedOrders': true, 'fetchTicker': true, 'fetchTickers': true, 'fetchTrades': true, + 'fetchWithdrawals': true, 'withdraw': true, }, 'timeframes': { @@ -49,33 +53,38 @@ module.exports = class zb extends Exchange { '1w': '1week', }, 'exceptions': { - // '1000': 'Successful operation', - '1001': ExchangeError, // 'General error message', - '1002': ExchangeError, // 'Internal error', - '1003': AuthenticationError, // 'Verification does not pass', - '1004': AuthenticationError, // 'Funding security password lock', - '1005': AuthenticationError, // 'Funds security password is incorrect, please confirm and re-enter.', - '1006': AuthenticationError, // 'Real-name certification pending approval or audit does not pass', - '1009': ExchangeNotAvailable, // 'This interface is under maintenance', - '2001': InsufficientFunds, // 'Insufficient CNY Balance', - '2002': InsufficientFunds, // 'Insufficient BTC Balance', - '2003': InsufficientFunds, // 'Insufficient LTC Balance', - '2005': InsufficientFunds, // 'Insufficient ETH Balance', - '2006': InsufficientFunds, // 'Insufficient ETC Balance', - '2007': InsufficientFunds, // 'Insufficient BTS Balance', - '2009': InsufficientFunds, // 'Account balance is not enough', - '3001': OrderNotFound, // 'Pending orders not found', - '3002': InvalidOrder, // 'Invalid price', - '3003': InvalidOrder, // 'Invalid amount', - '3004': AuthenticationError, // 'User does not exist', - '3005': BadRequest, // 'Invalid parameter', - '3006': AuthenticationError, // 'Invalid IP or inconsistent with the bound IP', - '3007': AuthenticationError, // 'The request time has expired', - '3008': OrderNotFound, // 'Transaction records not found', - '3009': InvalidOrder, // 'The price exceeds the limit', - '3011': InvalidOrder, // 'The entrusted price is abnormal, please modify it and place order again', - '4001': ExchangeNotAvailable, // 'API interface is locked or not enabled', - '4002': DDoSProtection, // 'Request too often', + 'exact': { + // '1000': 'Successful operation', + '1001': ExchangeError, // 'General error message', + '1002': ExchangeError, // 'Internal error', + '1003': AuthenticationError, // 'Verification does not pass', + '1004': AuthenticationError, // 'Funding security password lock', + '1005': AuthenticationError, // 'Funds security password is incorrect, please confirm and re-enter.', + '1006': AuthenticationError, // 'Real-name certification pending approval or audit does not pass', + '1009': ExchangeNotAvailable, // 'This interface is under maintenance', + '2001': InsufficientFunds, // 'Insufficient CNY Balance', + '2002': InsufficientFunds, // 'Insufficient BTC Balance', + '2003': InsufficientFunds, // 'Insufficient LTC Balance', + '2005': InsufficientFunds, // 'Insufficient ETH Balance', + '2006': InsufficientFunds, // 'Insufficient ETC Balance', + '2007': InsufficientFunds, // 'Insufficient BTS Balance', + '2009': InsufficientFunds, // 'Account balance is not enough', + '3001': OrderNotFound, // 'Pending orders not found', + '3002': InvalidOrder, // 'Invalid price', + '3003': InvalidOrder, // 'Invalid amount', + '3004': AuthenticationError, // 'User does not exist', + '3005': BadRequest, // 'Invalid parameter', + '3006': AuthenticationError, // 'Invalid IP or inconsistent with the bound IP', + '3007': AuthenticationError, // 'The request time has expired', + '3008': OrderNotFound, // 'Transaction records not found', + '3009': InvalidOrder, // 'The price exceeds the limit', + '3011': InvalidOrder, // 'The entrusted price is abnormal, please modify it and place order again', + '4001': ExchangeNotAvailable, // 'API interface is locked or not enabled', + '4002': DDoSProtection, // 'Request too often', + }, + 'broad': { + '提币地址有误,请先添加提币地址。': InvalidAddress, // {"code":1001,"message":"提币地址有误,请先添加提币地址。"} + }, }, 'urls': { 'logo': 'https://user-images.githubusercontent.com/1294454/32859187-cd5214f0-ca5e-11e7-967d-96568e2e2bd1.jpg', @@ -102,20 +111,28 @@ module.exports = class zb extends Exchange { 'get': [ // spot API 'order', + 'orderMoreV2', 'cancelOrder', 'getOrder', 'getOrders', 'getOrdersNew', 'getOrdersIgnoreTradeType', 'getUnfinishedOrdersIgnoreTradeType', + 'getFinishedAndPartialOrders', 'getAccountInfo', 'getUserAddress', + 'getPayinAddress', 'getWithdrawAddress', 'getWithdrawRecord', 'getChargeRecord', 'getCnyWithdrawRecord', 'getCnyChargeRecord', 'withdraw', + // sub accounts + 'addSubUser', + 'getSubUserList', + 'doTransferFunds', + 'createSubUserKey', // leverage API 'getLeverAssetsInfo', 'getLeverBills', @@ -126,8 +143,21 @@ module.exports = class zb extends Exchange { 'getLoans', 'getLoanRecords', 'borrow', + 'autoBorrow', 'repay', + 'doAllRepay', 'getRepayments', + 'getFinanceRecords', + 'changeInvestMark', + 'changeLoop', + // cross API + 'getCrossAssets', + 'getCrossBills', + 'transferInCross', + 'transferOutCross', + 'doCrossLoan', + 'doCrossRepay', + 'getCrossRepayRecords', ], }, }, @@ -245,8 +275,96 @@ module.exports = class zb extends Exchange { return this.parseBalance (result); } - getMarketFieldName () { - return 'market'; + parseDepositAddress (depositAddress, currency = undefined) { + // + // fetchDepositAddress + // + // { + // "key": "0x0af7f36b8f09410f3df62c81e5846da673d4d9a9" + // } + // + // fetchDepositAddresses + // + // { + // "blockChain": "btc", + // "isUseMemo": false, + // "address": "1LL5ati6pXHZnTGzHSA3rWdqi4mGGXudwM", + // "canWithdraw": true, + // "canDeposit": true + // } + // { + // "blockChain": "bts", + // "isUseMemo": true, + // "account": "btstest", + // "memo": "123", + // "canWithdraw": true, + // "canDeposit": true + // } + // + let address = this.safeString (depositAddress, 'key'); + let tag = undefined; + const memo = this.safeString (depositAddress, 'memo'); + if (memo !== undefined) { + tag = memo; + } else if (address.indexOf ('_') >= 0) { + const parts = address.split ('_'); + address = parts[0]; // WARNING: MAY BE tag_address INSTEAD OF address_tag FOR SOME CURRENCIES!! + tag = parts[1]; + } + const currencyId = this.safeString (depositAddress, 'blockChain'); + const code = this.safeCurrencyCode (currencyId, currency); + return { + 'currency': code, + 'address': address, + 'tag': tag, + 'info': depositAddress, + }; + } + + parseDepositAddresses (addresses, codes = undefined) { + let result = []; + for (let i = 0; i < addresses.length; i++) { + const address = this.parseDepositAddress (addresses[i]); + result.push (address); + } + if (codes) { + result = this.filterByArray (result, 'currency', codes); + } + return this.indexBy (result, 'currency'); + } + + async fetchDepositAddresses (codes = undefined, params = {}) { + await this.loadMarkets (); + const response = await this.privateGetGetPayinAddress (params); + // + // { + // "code": 1000, + // "message": { + // "des": "success", + // "isSuc": true, + // "datas": [ + // { + // "blockChain": "btc", + // "isUseMemo": false, + // "address": "1LL5ati6pXHZnTGzHSA3rWdqi4mGGXudwM", + // "canWithdraw": true, + // "canDeposit": true + // }, + // { + // "blockChain": "bts", + // "isUseMemo": true, + // "account": "btstest", + // "memo": "123", + // "canWithdraw": true, + // "canDeposit": true + // }, + // ] + // } + // } + // + const message = this.safeValue (response, 'message', {}); + const datas = this.safeValue (message, 'datas', []); + return this.parseDepositAddresses (datas, codes); } async fetchDepositAddress (code, params = {}) { @@ -256,27 +374,29 @@ module.exports = class zb extends Exchange { 'currency': currency['id'], }; const response = await this.privateGetGetUserAddress (this.extend (request, params)); - let address = response['message']['datas']['key']; - let tag = undefined; - if (address.indexOf ('_') >= 0) { - const parts = address.split ('_'); - address = parts[0]; // WARNING: MAY BE tag_address INSTEAD OF address_tag FOR SOME CURRENCIES!! - tag = parts[1]; - } - return { - 'currency': code, - 'address': address, - 'tag': tag, - 'info': response, - }; + // + // { + // "code": 1000, + // "message": { + // "des": "success", + // "isSuc": true, + // "datas": { + // "key": "0x0af7f36b8f09410f3df62c81e5846da673d4d9a9" + // } + // } + // } + // + const message = this.safeValue (response, 'message', {}); + const datas = this.safeValue (message, 'datas', {}); + return this.parseDepositAddress (datas, currency); } async fetchOrderBook (symbol, limit = undefined, params = {}) { await this.loadMarkets (); const market = this.market (symbol); - const marketFieldName = this.getMarketFieldName (); - const request = {}; - request[marketFieldName] = market['id']; + const request = { + 'market': market['id'], + }; if (limit !== undefined) { request['size'] = limit; } @@ -305,9 +425,9 @@ module.exports = class zb extends Exchange { async fetchTicker (symbol, params = {}) { await this.loadMarkets (); const market = this.market (symbol); - const marketFieldName = this.getMarketFieldName (); - const request = {}; - request[marketFieldName] = market['id']; + const request = { + 'market': market['id'], + }; const response = await this.publicGetTicker (this.extend (request, params)); const ticker = response['ticker']; return this.parseTicker (ticker, market); @@ -400,9 +520,9 @@ module.exports = class zb extends Exchange { async fetchTrades (symbol, since = undefined, limit = undefined, params = {}) { await this.loadMarkets (); const market = this.market (symbol); - const marketFieldName = this.getMarketFieldName (); - const request = {}; - request[marketFieldName] = market['id']; + const request = { + 'market': market['id'], + }; const response = await this.publicGetTrades (this.extend (request, params)); return this.parseTrades (response, market, since, limit); } @@ -462,7 +582,7 @@ module.exports = class zb extends Exchange { async fetchOrders (symbol = undefined, since = undefined, limit = 50, params = {}) { if (symbol === undefined) { - throw new ArgumentsRequired (this.id + 'fetchOrders requires a symbol argument'); + throw new ArgumentsRequired (this.id + 'fetchOrders() requires a symbol argument'); } await this.loadMarkets (); const market = this.market (symbol); @@ -488,9 +608,24 @@ module.exports = class zb extends Exchange { return this.parseOrders (response, market, since, limit); } + async fetchClosedOrders (symbol = undefined, since = undefined, limit = undefined, params = {}) { + if (symbol === undefined) { + throw new ArgumentsRequired (this.id + 'fetchClosedOrders() requires a symbol argument'); + } + await this.loadMarkets (); + const market = this.market (symbol); + const request = { + 'currency': market['id'], + 'pageIndex': 1, // default pageIndex is 1 + 'pageSize': 10, // default pageSize is 10, doesn't work with other values now + }; + const response = await this.privateGetGetFinishedAndPartialOrders (this.extend (request, params)); + return this.parseOrders (response, market, since, limit); + } + async fetchOpenOrders (symbol = undefined, since = undefined, limit = 10, params = {}) { if (symbol === undefined) { - throw new ArgumentsRequired (this.id + 'fetchOpenOrders requires a symbol argument'); + throw new ArgumentsRequired (this.id + 'fetchOpenOrders() requires a symbol argument'); } await this.loadMarkets (); const market = this.market (symbol); @@ -517,29 +652,26 @@ module.exports = class zb extends Exchange { } parseOrder (order, market = undefined) { - // - // fetchOrder // // { - // 'total_amount': 0.01, - // 'id': '20180910244276459', - // 'price': 180.0, - // 'trade_date': 1536576744960, - // 'status': 2, - // 'trade_money': '1.96742', - // 'trade_amount': 0.01, - // 'type': 0, - // 'currency': 'eth_usdt' - // } + // acctType: 0, + // currency: 'btc_usdt', + // fees: 3.6e-7, + // id: '202102282829772463', + // price: 45177.5, + // status: 2, + // total_amount: 0.0002, + // trade_amount: 0.0002, + // trade_date: 1614515104998, + // trade_money: 8.983712, + // type: 1, + // useZbFee: false + // }, // let side = this.safeInteger (order, 'type'); side = (side === 1) ? 'buy' : 'sell'; const type = 'limit'; // market order is not availalbe in ZB - let timestamp = undefined; - const createDateField = this.getCreateDateField (); - if (createDateField in order) { - timestamp = order[createDateField]; - } + const timestamp = this.safeInteger (order, 'trade_date'); const marketId = this.safeString (order, 'currency'); const symbol = this.safeSymbol (marketId, market, '_'); const price = this.safeFloat (order, 'price'); @@ -558,6 +690,21 @@ module.exports = class zb extends Exchange { average = cost / filled; } const id = this.safeString (order, 'id'); + const feeCost = this.safeFloat (order, 'fees'); + let fee = undefined; + if (feeCost !== undefined) { + let feeCurrency = undefined; + const zbFees = this.safeValue (order, 'useZbFee'); + if (zbFees === true) { + feeCurrency = 'ZB'; + } else if (market !== undefined) { + feeCurrency = (side === 'sell') ? market['quote'] : market['base']; + } + fee = { + 'cost': feeCost, + 'currency': feeCurrency, + }; + } return { 'info': order, 'id': id, @@ -568,6 +715,7 @@ module.exports = class zb extends Exchange { 'symbol': symbol, 'type': type, 'timeInForce': undefined, + 'postOnly': undefined, 'side': side, 'price': price, 'stopPrice': undefined, @@ -577,7 +725,7 @@ module.exports = class zb extends Exchange { 'filled': filled, 'remaining': remaining, 'status': status, - 'fee': undefined, + 'fee': fee, 'trades': undefined, }; } @@ -592,8 +740,241 @@ module.exports = class zb extends Exchange { return this.safeString (statuses, status, status); } - getCreateDateField () { - return 'trade_date'; + parseTransactionStatus (status) { + const statuses = { + '0': 'pending', // submitted, pending confirmation + '1': 'failed', + '2': 'ok', + '3': 'canceled', + '5': 'ok', // confirmed + }; + return this.safeString (statuses, status, status); + } + + parseTransaction (transaction, currency = undefined) { + // + // withdraw + // + // { + // "code": 1000, + // "message": "success", + // "id": "withdrawalId" + // } + // + // fetchWithdrawals + // + // { + // "amount": 0.01, + // "fees": 0.001, + // "id": 2016042556231, + // "manageTime": 1461579340000, + // "status": 3, + // "submitTime": 1461579288000, + // "toAddress": "14fxEPirL9fyfw1i9EF439Pq6gQ5xijUmp", + // } + // + // fetchDeposits + // + // { + // "address": "1FKN1DZqCm8HaTujDioRL2Aezdh7Qj7xxx", + // "amount": "1.00000000", + // "confirmTimes": 1, + // "currency": "BTC", + // "description": "Successfully Confirm", + // "hash": "7ce842de187c379abafadd64a5fe66c5c61c8a21fb04edff9532234a1dae6xxx", + // "id": 558, + // "itransfer": 1, + // "status": 2, + // "submit_time": "2016-12-07 18:51:57", + // } + // + const id = this.safeString (transaction, 'id'); + const txid = this.safeString (transaction, 'hash'); + const amount = this.safeFloat (transaction, 'amount'); + let timestamp = this.parse8601 (this.safeString (transaction, 'submit_time')); + timestamp = this.safeInteger (transaction, 'submitTime', timestamp); + let address = this.safeString2 (transaction, 'toAddress', 'address'); + let tag = undefined; + if (address !== undefined) { + const parts = address.split ('_'); + address = this.safeString (parts, 0); + tag = this.safeString (parts, 1); + } + const confirmTimes = this.safeInteger (transaction, 'confirmTimes'); + const updated = this.safeInteger (transaction, 'manageTime'); + let type = undefined; + const currencyId = this.safeString (transaction, 'currency'); + const code = this.safeCurrencyCode (currencyId, currency); + if (address !== undefined) { + type = (confirmTimes === undefined) ? 'withdrawal' : 'deposit'; + } + const status = this.parseTransactionStatus (this.safeString (transaction, 'status')); + let fee = undefined; + const feeCost = this.safeFloat (transaction, 'fees'); + if (feeCost !== undefined) { + fee = { + 'cost': feeCost, + 'currency': code, + }; + } + return { + 'info': transaction, + 'id': id, + 'txid': txid, + 'timestamp': timestamp, + 'datetime': this.iso8601 (timestamp), + 'addressFrom': undefined, + 'address': address, + 'addressTo': address, + 'tagFrom': undefined, + 'tag': tag, + 'tagTo': tag, + 'type': type, + 'amount': amount, + 'currency': code, + 'status': status, + 'updated': updated, + 'fee': fee, + }; + } + + async withdraw (code, amount, address, tag = undefined, params = {}) { + const password = this.safeString (params, 'safePwd', this.password); + if (password === undefined) { + throw new ArgumentsRequired (this.id + ' withdraw() requires exchange.password or a safePwd parameter'); + } + const fees = this.safeFloat (params, 'fees'); + if (fees === undefined) { + throw new ArgumentsRequired (this.id + ' withdraw() requires a fees parameter'); + } + this.checkAddress (address); + await this.loadMarkets (); + const currency = this.currency (code); + if (tag !== undefined) { + address += '_' + tag; + } + const request = { + 'amount': this.currencyToPrecision (code, amount), + 'currency': currency['id'], + 'fees': this.currencyToPrecision (code, fees), + // 'itransfer': 0, // agree for an internal transfer, 0 disagree, 1 agree, the default is to disagree + 'method': 'withdraw', + 'receiveAddr': address, + 'safePwd': password, + }; + const response = await this.privateGetWithdraw (this.extend (request, params)); + // + // { + // "code": 1000, + // "message": "success", + // "id": "withdrawalId" + // } + // + const transaction = this.parseTransaction (response, currency); + return this.extend (transaction, { + 'type': 'withdrawal', + 'address': address, + 'addressTo': address, + 'amount': amount, + }); + } + + async fetchWithdrawals (code = undefined, since = undefined, limit = undefined, params = {}) { + await this.loadMarkets (); + const request = { + // 'currency': currency['id'], + // 'pageIndex': 1, + // 'pageSize': limit, + }; + let currency = undefined; + if (code !== undefined) { + currency = this.currency (code); + request['currency'] = currency['id']; + } + if (limit !== undefined) { + request['pageSize'] = limit; + } + const response = await this.privateGetGetWithdrawRecord (this.extend (request, params)); + // + // { + // "code": 1000, + // "message": { + // "des": "success", + // "isSuc": true, + // "datas": { + // "list": [ + // { + // "amount": 0.01, + // "fees": 0.001, + // "id": 2016042556231, + // "manageTime": 1461579340000, + // "status": 3, + // "submitTime": 1461579288000, + // "toAddress": "14fxEPirL9fyfw1i9EF439Pq6gQ5xijUmp", + // }, + // ], + // "pageIndex": 1, + // "pageSize": 10, + // "totalCount": 4, + // "totalPage": 1 + // } + // } + // } + // + const message = this.safeValue (response, 'message', {}); + const datas = this.safeValue (message, 'datas', {}); + const withdrawals = this.safeValue (datas, 'list', []); + return this.parseTransactions (withdrawals, currency, since, limit); + } + + async fetchDeposits (code = undefined, since = undefined, limit = undefined, params = {}) { + await this.loadMarkets (); + const request = { + // 'currency': currency['id'], + // 'pageIndex': 1, + // 'pageSize': limit, + }; + let currency = undefined; + if (code !== undefined) { + currency = this.currency (code); + request['currency'] = currency['id']; + } + if (limit !== undefined) { + request['pageSize'] = limit; + } + const response = await this.privateGetGetChargeRecord (this.extend (request, params)); + // + // { + // "code": 1000, + // "message": { + // "des": "success", + // "isSuc": true, + // "datas": { + // "list": [ + // { + // "address": "1FKN1DZqCm8HaTujDioRL2Aezdh7Qj7xxx", + // "amount": "1.00000000", + // "confirmTimes": 1, + // "currency": "BTC", + // "description": "Successfully Confirm", + // "hash": "7ce842de187c379abafadd64a5fe66c5c61c8a21fb04edff9532234a1dae6xxx", + // "id": 558, + // "itransfer": 1, + // "status": 2, + // "submit_time": "2016-12-07 18:51:57", + // }, + // ], + // "pageIndex": 1, + // "pageSize": 10, + // "total": 8 + // } + // } + // } + // + const message = this.safeValue (response, 'message', {}); + const datas = this.safeValue (message, 'datas', {}); + const deposits = this.safeValue (datas, 'list', []); + return this.parseTransactions (deposits, currency, since, limit); } nonce () { @@ -629,9 +1010,10 @@ module.exports = class zb extends Exchange { } if (body[0] === '{') { const feedback = this.id + ' ' + body; + this.throwBroadlyMatchedException (this.exceptions['broad'], body, feedback); if ('code' in response) { const code = this.safeString (response, 'code'); - this.throwExactlyMatchedException (this.exceptions, code, feedback); + this.throwExactlyMatchedException (this.exceptions['exact'], code, feedback); if (code !== '1000') { throw new ExchangeError (feedback); } diff --git a/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/package.json b/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/package.json index e9ee481cb..a5305f19f 100644 --- a/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/package.json +++ b/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/package.json @@ -1,28 +1,28 @@ { - "_from": "ccxt", - "_id": "ccxt@1.38.76", + "_from": "ccxt@1.42.77", + "_id": "ccxt@1.42.77", "_inBundle": false, - "_integrity": "sha512-t2XalR99Uv4YdRMyBk/sCKwynA7voPl3TRF/IfzICQf8vr7EyGh3CTuV9o3TYAHSNliotitk3SNC8cp1e/ULjw==", + "_integrity": "sha512-vPaw8G3hr9iq1iJ59EHuA6iqjufgK6dNC7MjT3qV8YQbpEJoD2ynoFwfl1hbuvlyKlFjiOa3gHwhRV64UacBDQ==", "_location": "/ccxt", "_phantomChildren": {}, "_requested": { - "type": "tag", + "type": "version", "registry": true, - "raw": "ccxt", + "raw": "ccxt@1.42.77", "name": "ccxt", "escapedName": "ccxt", - "rawSpec": "", + "rawSpec": "1.42.77", "saveSpec": null, - "fetchSpec": "latest" + "fetchSpec": "1.42.77" }, "_requiredBy": [ "#USER", "/" ], - "_resolved": "https://registry.npmjs.org/ccxt/-/ccxt-1.38.76.tgz", - "_shasum": "5b231f550ba1a328480528401944f630ed2685e3", - "_spec": "ccxt", - "_where": "c:\\Superalgos\\Projects\\Superalgos\\TS\\Bot-Modules\\Sensor-Bot\\Exchange-Raw-Data", + "_resolved": "https://registry.npmjs.org/ccxt/-/ccxt-1.42.77.tgz", + "_shasum": "8ab5f8e7190854e163da6d4fcf44530794d0a21c", + "_spec": "ccxt@1.42.77", + "_where": "C:\\Superalgos\\Projects\\Superalgos\\TS\\Bot-Modules\\Sensor-Bot\\Exchange-Raw-Data", "author": { "name": "Igor Kroitor", "email": "igor.kroitor@gmail.com", @@ -529,7 +529,21 @@ "bitcoin.com", "bibox365.com", "vcc.exchange", - "VCC Exchange" + "VCC Exchange", + "cdax.io", + "CDAX", + "delta.exchange", + "Delta Exchange", + "gopax.co.kr", + "Gopax", + "GOPAX", + "aax.com", + "AAX", + "aaxpro.com", + "equos.io", + "EQUOS", + "ndax.io", + "NDAX" ], "license": "MIT", "main": "./ccxt.js", @@ -540,9 +554,8 @@ }, "scripts": { "browserify": "browserify ./ccxt.browser.js > ./dist/ccxt.browser.js", - "build": "npm run build-without-docs && npm run update-badges", - "build-without-docs": "npm run export-exchanges && npm run vss && npm run copy-python-files && npm run check-js-syntax && npm run browserify && npm run transpile && npm run check-python-syntax && npm run check-php-syntax", - "check-js-syntax": "pwd && eslint --version && eslint \"js/*.js\"", + "build": "npm run pre-transpile && npm run transpile && npm run post-transpile && npm run update-badges", + "check-js-syntax": "node -e \"console.log(process.cwd())\" && eslint --version && eslint \"js/*.js\"", "check-php-syntax": "php -f php/test/syntax.php", "check-python-syntax": "cd python && tox -e qa && cd ..", "check-syntax": "npm run transpile && npm run check-js-syntax && npm run check-python-syntax && npm run check-php-syntax", @@ -554,20 +567,25 @@ "docker": "docker-compose run --rm ccxt", "export-exchanges": "node build/export-exchanges", "fast-test": "node run-tests --js", + "force-build": "npm run pre-transpile && npm run force-transpile && npm run post-transpile && npm run update-badges", + "force-transpile": "node build/transpile --force", "git-ignore-generated-files": "node build/git-ignore-generated-files", "git-unignore-generated-files": "node build/git-ignore-generated-files --unignore", "lint": "eslint", + "post-transpile": "npm run check-python-syntax && npm run check-php-syntax", "postinstall": "node postinstall", + "pre-transpile": "npm run export-exchanges && npm run vss && npm run copy-python-files && npm run check-js-syntax && npm run browserify", "test": "npm run build && node run-tests", "test-base": "npm run test-js-base && npm run test-python-base && npm run test-php-base", "test-js-base": "mocha js/test/base/test.base.js --reporter ololog/reporter", "test-php-base": "php -f php/test/decimal_to_precision.php && php -f php/test/test_crypto.php", - "test-python-base": "python python/test/test_decimal_to_precision.py", + "test-python-base": "python python/ccxt/test/test_decimal_to_precision.py", "transpile": "node build/transpile", "update-badges": "node build/update-badges", + "update-links": "node build/update-links", "vss": "node build/vss" }, "types": "./ccxt.d.ts", "unpkg": "dist/ccxt.browser.js", - "version": "1.38.76" + "version": "1.42.77" } diff --git a/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/package-lock.json b/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/package-lock.json index 4eb0d27c5..976144cc2 100644 --- a/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/package-lock.json +++ b/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/package-lock.json @@ -3,9 +3,9 @@ "lockfileVersion": 1, "dependencies": { "ccxt": { - "version": "1.38.76", - "resolved": "https://registry.npmjs.org/ccxt/-/ccxt-1.38.76.tgz", - "integrity": "sha512-t2XalR99Uv4YdRMyBk/sCKwynA7voPl3TRF/IfzICQf8vr7EyGh3CTuV9o3TYAHSNliotitk3SNC8cp1e/ULjw==" + "version": "1.42.77", + "resolved": "https://registry.npmjs.org/ccxt/-/ccxt-1.42.77.tgz", + "integrity": "sha512-vPaw8G3hr9iq1iJ59EHuA6iqjufgK6dNC7MjT3qV8YQbpEJoD2ynoFwfl1hbuvlyKlFjiOa3gHwhRV64UacBDQ==" } } } diff --git a/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/.eslintignore b/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/.eslintignore new file mode 100644 index 000000000..a007feab0 --- /dev/null +++ b/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/.eslintignore @@ -0,0 +1 @@ +build/* diff --git a/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/.gitattributes b/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/.gitattributes index 147ee79bf..513b2a256 100644 --- a/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/.gitattributes +++ b/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/.gitattributes @@ -1,4 +1,5 @@ *.* text eol=lf php/test/*.php linguist-generated=true +php/*.php linguist-generated=true python/ccxt/*.py linguist-generated=true python/ccxt/__init__.py linguist-generated=false diff --git a/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/CONTRIBUTING.md b/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/CONTRIBUTING.md index 5ce4a0405..1d3ff05d1 100644 --- a/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/CONTRIBUTING.md +++ b/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/CONTRIBUTING.md @@ -246,7 +246,7 @@ These files containing derived exchange classes are transpiled from JS into Pyth - `js/[_a-z].js` → `python/ccxt/async/[_a-z].py` - `python/ccxt/async[_a-z].py` → `python/ccxt/[_a-z].py` (Python 3 asyncio → Python 2 sync transpilation stage) -- `python/test/test_async.py` → `python/test/test.py` (the sync test is generated from the async test) +- `python/ccxt/test/test_async.py` → `python/ccxt/test/test_sync.py` (the sync test is generated from the async test) These Python base classes and files are not transpiled: @@ -868,14 +868,6 @@ npm run git-unignore-generated-files ## Financial Contributions We also welcome financial contributions in full transparency on our [open collective](https://opencollective.com/ccxt). -Anyone can file an expense. If the expense makes sense for the development of the community, it will be "merged" in the ledger of our open collective by the core contributors and the person who filed the expense will be reimbursed. - -``` -ETH 0x26a3CB49578F07000575405a57888681249c35Fd (ETH only!) -BTC 33RmVRfhK2WZVQR1R83h2e9yXoqRNDvJva -BCH 1GN9p233TvNcNQFthCgfiHUnj5JRKEc2Ze -LTC LbT8mkAqQBphc4yxLXEDgYDfEax74et3bP -``` ## Credits diff --git a/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/README.md b/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/README.md index 8782b3b2c..3f8dfeea4 100644 --- a/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/README.md +++ b/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/README.md @@ -1,11 +1,11 @@ # CCXT – CryptoCurrency eXchange Trading Library -[![Build Status](https://travis-ci.com/ccxt/ccxt.svg?branch=master)](https://travis-ci.com/ccxt/ccxt) [![npm](https://img.shields.io/npm/v/ccxt.svg)](https://npmjs.com/package/ccxt) [![PyPI](https://img.shields.io/pypi/v/ccxt.svg)](https://pypi.python.org/pypi/ccxt) [![NPM Downloads](https://img.shields.io/npm/dm/ccxt.svg)](https://www.npmjs.com/package/ccxt) [![Discord](https://img.shields.io/discord/690203284119617602?logo=discord&logoColor=white)](https://discord.gg/dhzSKYU) [![Supported Exchanges](https://img.shields.io/badge/exchanges-123-blue.svg)](https://github.com/ccxt/ccxt/wiki/Exchange-Markets) [![Open Collective](https://opencollective.com/ccxt/backers/badge.svg)](https://opencollective.com/ccxt) +[![Build Status](https://travis-ci.com/ccxt/ccxt.svg?branch=master)](https://travis-ci.com/ccxt/ccxt) [![npm](https://img.shields.io/npm/v/ccxt.svg)](https://npmjs.com/package/ccxt) [![PyPI](https://img.shields.io/pypi/v/ccxt.svg)](https://pypi.python.org/pypi/ccxt) [![NPM Downloads](https://img.shields.io/npm/dy/ccxt.svg)](https://www.npmjs.com/package/ccxt) [![Discord](https://img.shields.io/discord/690203284119617602?logo=discord&logoColor=white)](https://discord.gg/dhzSKYU) [![Supported Exchanges](https://img.shields.io/badge/exchanges-126-blue.svg)](https://github.com/ccxt/ccxt/wiki/Exchange-Markets) [![Open Collective](https://opencollective.com/ccxt/backers/badge.svg)](https://opencollective.com/ccxt) [![Twitter Follow](https://img.shields.io/twitter/follow/ccxt_official.svg?style=social&label=CCXT)](https://twitter.com/ccxt_official) A JavaScript / Python / PHP library for cryptocurrency trading and e-commerce with support for many bitcoin/ether/altcoin exchange markets and merchant APIs. -### [Install](#install) · [Usage](#usage) · [Manual](https://github.com/ccxt/ccxt/wiki) · [FAQ](https://github.com/ccxt/ccxt/wiki/FAQ) · [Examples](https://github.com/ccxt/ccxt/tree/master/examples) · [Contributing](https://github.com/ccxt/ccxt/blob/master/CONTRIBUTING.md) · [Social](#social) +### [Install](#install) · [Usage](#usage) · [Manual](https://github.com/ccxt/ccxt/wiki) · [FAQ](https://github.com/ccxt/ccxt/wiki/FAQ) · [Examples](https://github.com/ccxt/ccxt/tree/master/examples) · [Contributing](https://github.com/ccxt/ccxt/blob/master/CONTRIBUTING.md) · [Social](#social) · [CCXT Pro](https://ccxt.pro) The **CCXT** library is used to connect and trade with cryptocurrency exchanges and payment processing services worldwide. It provides quick access to market data for storage, analysis, visualization, indicator development, algorithmic trading, strategy backtesting, bot programming, and related software engineering. @@ -21,42 +21,44 @@ Current feature list: ## Sponsored Promotion -[![CCXT Pro – A JavaScript / Python / PHP cryptocurrency exchange trading WebSocket API for professionals](https://user-images.githubusercontent.com/1294454/93346896-22dfb080-f83d-11ea-957f-6b8ae008f62a.png)](https://ccxt.pro) **[A JavaScript / Python / PHP cryptocurrency exchange trading WebSocket API for professionals](https://ccxt.pro)** +[![CCXT Pro – A JavaScript / Python / PHP cryptocurrency exchange trading WebSocket API for professionals](https://user-images.githubusercontent.com/1294454/106092533-865ce180-613f-11eb-8d67-0830771fde32.png)](https://ccxt.pro) ## See Also - [![Quadency](https://user-images.githubusercontent.com/1294454/69334382-a0618100-0c6b-11ea-9ba9-40aa97440cfa.png)](https://quadency.com?utm_source=ccxt)  **[Quadency](https://quadency.com?utm_source=ccxt)** — trading automation terminal for leading exchanges with streaming APIs + Python IDE. - [![TabTrader](https://user-images.githubusercontent.com/1294454/66755907-9c3e8880-eea1-11e9-846e-0bff349ceb87.png)](https://tab-trader.com/?utm_source=ccxt)  **[TabTrader](https://tab-trader.com/?utm_source=ccxt)** — trading on all exchanges in one app. Avaliable on [Android](https://play.google.com/store/apps/details?id=com.tabtrader.android&referrer=utm_source%3Dccxt) and [iOS](https://itunes.apple.com/app/apple-store/id1095716562?mt=8). +- [![Pionex](https://user-images.githubusercontent.com/1294454/106112806-c2ec0580-615e-11eb-870c-0b7aef021db2.png)](https://www.pionex.com/en-US/sign?r=8wSFCbNk&utm_source=ad&utm_medium=banner&utm_campaign=ccxt-2)  **[Pionex](https://www.pionex.com/en-US/sign?r=8wSFCbNk&utm_source=ad&utm_medium=banner&utm_campaign=ccxt-2)** — 6 grid bots, spot-futures arb bot, smart trade and DCA bots. Free for [Android](https://play.google.com/store/apps/details?id=com.pionex.client&referrer=utm_source%3Dccxt) and [iOS](https://apps.apple.com/us/app/pionex/id1485348891?pt=ccxt&ct=inline)! +- [![AAX](https://user-images.githubusercontent.com/1294454/106509642-ef957980-64de-11eb-92e0-8323cda7874e.png)](https://www.aaxpro.com/en-US/ad-sign-up/?utm_source=ccxt&utm_medium=one-liner&utm_campaign=futures)  **[AAX](https://www.aaxpro.com/en-US/ad-sign-up/?utm_source=ccxt&utm_medium=one-liner&utm_campaign=futures)** — trade bitcoin futures with fees as low as 0.02% and up to 100x leverage! ## Certified Cryptocurrency Exchanges -| logo | id | name | ver | doc | certified | pro | -|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---------------|-----------------------------------------------------------------------------|:---:|:----------------------------------------------------------------------------------:|-----------------------------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------| -| [![binance](https://user-images.githubusercontent.com/1294454/29604020-d5483cdc-87ee-11e7-94c7-d1a8d9169293.jpg)](https://www.binance.com/?ref=10205187) | binance | [Binance](https://www.binance.com/?ref=10205187) | * | [API](https://binance-docs.github.io/apidocs/spot/en) | [![CCXT Certified](https://img.shields.io/badge/CCXT-Certified-green.svg)](https://github.com/ccxt/ccxt/wiki/Certification) | [![CCXT Pro](https://img.shields.io/badge/CCXT-Pro-black)](https://ccxt.pro) | -| [![bitfinex](https://user-images.githubusercontent.com/1294454/27766244-e328a50c-5ed2-11e7-947b-041416579bb3.jpg)](https://www.bitfinex.com/?refcode=P61eYxFL) | bitfinex | [Bitfinex](https://www.bitfinex.com/?refcode=P61eYxFL) | 1 | [API](https://docs.bitfinex.com/v1/docs) | [![CCXT Certified](https://img.shields.io/badge/CCXT-Certified-green.svg)](https://github.com/ccxt/ccxt/wiki/Certification) | [![CCXT Pro](https://img.shields.io/badge/CCXT-Pro-black)](https://ccxt.pro) | -| [![bittrex](https://user-images.githubusercontent.com/51840849/87153921-edf53180-c2c0-11ea-96b9-f2a9a95a455b.jpg)](https://bittrex.com/Account/Register?referralCode=1ZE-G0G-M3B) | bittrex | [Bittrex](https://bittrex.com/Account/Register?referralCode=1ZE-G0G-M3B) | 3 | [API](https://bittrex.github.io/api/v3) | [![CCXT Certified](https://img.shields.io/badge/CCXT-Certified-green.svg)](https://github.com/ccxt/ccxt/wiki/Certification) | [![CCXT Pro](https://img.shields.io/badge/CCXT-Pro-black)](https://ccxt.pro) | -| [![bitvavo](https://user-images.githubusercontent.com/1294454/83165440-2f1cf200-a116-11ea-9046-a255d09fb2ed.jpg)](https://bitvavo.com/?a=24F34952F7) | bitvavo | [Bitvavo](https://bitvavo.com/?a=24F34952F7) | 2 | [API](https://docs.bitvavo.com/) | [![CCXT Certified](https://img.shields.io/badge/CCXT-Certified-green.svg)](https://github.com/ccxt/ccxt/wiki/Certification) | [![CCXT Pro](https://img.shields.io/badge/CCXT-Pro-black)](https://ccxt.pro) | -| [![bytetrade](https://user-images.githubusercontent.com/1294454/67288762-2f04a600-f4e6-11e9-9fd6-c60641919491.jpg)](https://www.byte-trade.com) | bytetrade | [ByteTrade](https://www.byte-trade.com) | * | [API](https://docs.byte-trade.com/#description) | [![CCXT Certified](https://img.shields.io/badge/CCXT-Certified-green.svg)](https://github.com/ccxt/ccxt/wiki/Certification) | | -| [![currencycom](https://user-images.githubusercontent.com/1294454/83718672-36745c00-a63e-11ea-81a9-677b1f789a4d.jpg)](https://currency.com/trading/signup?c=362jaimv&pid=referral) | currencycom | [Currency.com](https://currency.com/trading/signup?c=362jaimv&pid=referral) | 1 | [API](https://currency.com/api) | [![CCXT Certified](https://img.shields.io/badge/CCXT-Certified-green.svg)](https://github.com/ccxt/ccxt/wiki/Certification) | [![CCXT Pro](https://img.shields.io/badge/CCXT-Pro-black)](https://ccxt.pro) | -| [![eterbase](https://user-images.githubusercontent.com/1294454/82067900-faeb0f80-96d9-11ea-9f22-0071cfcb9871.jpg)](https://eterbase.exchange/invite/1wjjh4Pe) | eterbase | [Eterbase](https://eterbase.exchange/invite/1wjjh4Pe) | 1 | [API](https://developers.eterbase.exchange) | [![CCXT Certified](https://img.shields.io/badge/CCXT-Certified-green.svg)](https://github.com/ccxt/ccxt/wiki/Certification) | | -| [![ftx](https://user-images.githubusercontent.com/1294454/67149189-df896480-f2b0-11e9-8816-41593e17f9ec.jpg)](https://ftx.com/#a=1623029) | ftx | [FTX](https://ftx.com/#a=1623029) | * | [API](https://github.com/ftexchange/ftx) | [![CCXT Certified](https://img.shields.io/badge/CCXT-Certified-green.svg)](https://github.com/ccxt/ccxt/wiki/Certification) | [![CCXT Pro](https://img.shields.io/badge/CCXT-Pro-black)](https://ccxt.pro) | -| [![idex](https://user-images.githubusercontent.com/51840849/94481303-2f222100-01e0-11eb-97dd-bc14c5943a86.jpg)](https://idex.io) | idex | [IDEX](https://idex.io) | 2 | [API](https://docs.idex.io/) | [![CCXT Certified](https://img.shields.io/badge/CCXT-Certified-green.svg)](https://github.com/ccxt/ccxt/wiki/Certification) | [![CCXT Pro](https://img.shields.io/badge/CCXT-Pro-black)](https://ccxt.pro) | -| [![kraken](https://user-images.githubusercontent.com/51840849/76173629-fc67fb00-61b1-11ea-84fe-f2de582f58a3.jpg)](https://www.kraken.com) | kraken | [Kraken](https://www.kraken.com) | 0 | [API](https://www.kraken.com/features/api) | [![CCXT Certified](https://img.shields.io/badge/CCXT-Certified-green.svg)](https://github.com/ccxt/ccxt/wiki/Certification) | [![CCXT Pro](https://img.shields.io/badge/CCXT-Pro-black)](https://ccxt.pro) | -| [![upbit](https://user-images.githubusercontent.com/1294454/49245610-eeaabe00-f423-11e8-9cba-4b0aed794799.jpg)](https://upbit.com) | upbit | [Upbit](https://upbit.com) | 1 | [API](https://docs.upbit.com/docs/%EC%9A%94%EC%B2%AD-%EC%88%98-%EC%A0%9C%ED%95%9C) | [![CCXT Certified](https://img.shields.io/badge/CCXT-Certified-green.svg)](https://github.com/ccxt/ccxt/wiki/Certification) | [![CCXT Pro](https://img.shields.io/badge/CCXT-Pro-black)](https://ccxt.pro) | -| [![wavesexchange](https://user-images.githubusercontent.com/1294454/84547058-5fb27d80-ad0b-11ea-8711-78ac8b3c7f31.jpg)](https://waves.exchange) | wavesexchange | [Waves.Exchange](https://waves.exchange) | * | [API](https://docs.waves.exchange) | [![CCXT Certified](https://img.shields.io/badge/CCXT-Certified-green.svg)](https://github.com/ccxt/ccxt/wiki/Certification) | | -| [![xena](https://user-images.githubusercontent.com/51840849/87489843-bb469280-c64c-11ea-91aa-69c6326506af.jpg)](https://xena.exchange) | xena | [Xena Exchange](https://xena.exchange) | * | [API](https://support.xena.exchange/support/solutions/44000808700) | [![CCXT Certified](https://img.shields.io/badge/CCXT-Certified-green.svg)](https://github.com/ccxt/ccxt/wiki/Certification) | | +| logo | id | name | ver | doc | certified | pro | +|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---------------|-----------------------------------------------------------------------------|:---:|:------------------------------------------------------------------:|-----------------------------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------| +| [![aax](https://user-images.githubusercontent.com/1294454/104140087-a27f2580-53c0-11eb-87c1-5d9e81208fe9.jpg)](https://www.aaxpro.com/invite/sign-up?inviteCode=JXGm5Fy7R2MB) | aax | [AAX](https://www.aaxpro.com/invite/sign-up?inviteCode=JXGm5Fy7R2MB) | 2 | [API](https://www.aaxpro.com/apidoc/index.html) | [![CCXT Certified](https://img.shields.io/badge/CCXT-Certified-green.svg)](https://github.com/ccxt/ccxt/wiki/Certification) | | +| [![binance](https://user-images.githubusercontent.com/1294454/29604020-d5483cdc-87ee-11e7-94c7-d1a8d9169293.jpg)](https://www.binance.com/?ref=10205187) | binance | [Binance](https://www.binance.com/?ref=10205187) | * | [API](https://binance-docs.github.io/apidocs/spot/en) | [![CCXT Certified](https://img.shields.io/badge/CCXT-Certified-green.svg)](https://github.com/ccxt/ccxt/wiki/Certification) | [![CCXT Pro](https://img.shields.io/badge/CCXT-Pro-black)](https://ccxt.pro) | +| [![bittrex](https://user-images.githubusercontent.com/51840849/87153921-edf53180-c2c0-11ea-96b9-f2a9a95a455b.jpg)](https://bittrex.com/Account/Register?referralCode=1ZE-G0G-M3B) | bittrex | [Bittrex](https://bittrex.com/Account/Register?referralCode=1ZE-G0G-M3B) | 3 | [API](https://bittrex.github.io/api/v3) | [![CCXT Certified](https://img.shields.io/badge/CCXT-Certified-green.svg)](https://github.com/ccxt/ccxt/wiki/Certification) | [![CCXT Pro](https://img.shields.io/badge/CCXT-Pro-black)](https://ccxt.pro) | +| [![bitvavo](https://user-images.githubusercontent.com/1294454/83165440-2f1cf200-a116-11ea-9046-a255d09fb2ed.jpg)](https://bitvavo.com/?a=24F34952F7) | bitvavo | [Bitvavo](https://bitvavo.com/?a=24F34952F7) | 2 | [API](https://docs.bitvavo.com/) | [![CCXT Certified](https://img.shields.io/badge/CCXT-Certified-green.svg)](https://github.com/ccxt/ccxt/wiki/Certification) | [![CCXT Pro](https://img.shields.io/badge/CCXT-Pro-black)](https://ccxt.pro) | +| [![bytetrade](https://user-images.githubusercontent.com/1294454/67288762-2f04a600-f4e6-11e9-9fd6-c60641919491.jpg)](https://www.byte-trade.com) | bytetrade | [ByteTrade](https://www.byte-trade.com) | * | [API](https://docs.byte-trade.com/#description) | [![CCXT Certified](https://img.shields.io/badge/CCXT-Certified-green.svg)](https://github.com/ccxt/ccxt/wiki/Certification) | | +| [![currencycom](https://user-images.githubusercontent.com/1294454/83718672-36745c00-a63e-11ea-81a9-677b1f789a4d.jpg)](https://currency.com/trading/signup?c=362jaimv&pid=referral) | currencycom | [Currency.com](https://currency.com/trading/signup?c=362jaimv&pid=referral) | 1 | [API](https://currency.com/api) | [![CCXT Certified](https://img.shields.io/badge/CCXT-Certified-green.svg)](https://github.com/ccxt/ccxt/wiki/Certification) | [![CCXT Pro](https://img.shields.io/badge/CCXT-Pro-black)](https://ccxt.pro) | +| [![eterbase](https://user-images.githubusercontent.com/1294454/82067900-faeb0f80-96d9-11ea-9f22-0071cfcb9871.jpg)](https://eterbase.exchange/invite/1wjjh4Pe) | eterbase | [Eterbase](https://eterbase.exchange/invite/1wjjh4Pe) | 1 | [API](https://developers.eterbase.exchange) | [![CCXT Certified](https://img.shields.io/badge/CCXT-Certified-green.svg)](https://github.com/ccxt/ccxt/wiki/Certification) | | +| [![ftx](https://user-images.githubusercontent.com/1294454/67149189-df896480-f2b0-11e9-8816-41593e17f9ec.jpg)](https://ftx.com/#a=1623029) | ftx | [FTX](https://ftx.com/#a=1623029) | * | [API](https://github.com/ftexchange/ftx) | [![CCXT Certified](https://img.shields.io/badge/CCXT-Certified-green.svg)](https://github.com/ccxt/ccxt/wiki/Certification) | [![CCXT Pro](https://img.shields.io/badge/CCXT-Pro-black)](https://ccxt.pro) | +| [![gopax](https://user-images.githubusercontent.com/1294454/102897212-ae8a5e00-4478-11eb-9bab-91507c643900.jpg)](https://www.gopax.co.kr) | gopax | [GOPAX](https://www.gopax.co.kr) | 1 | [API](https://gopax.github.io/API/index.en.html) | [![CCXT Certified](https://img.shields.io/badge/CCXT-Certified-green.svg)](https://github.com/ccxt/ccxt/wiki/Certification) | [![CCXT Pro](https://img.shields.io/badge/CCXT-Pro-black)](https://ccxt.pro) | +| [![idex](https://user-images.githubusercontent.com/51840849/94481303-2f222100-01e0-11eb-97dd-bc14c5943a86.jpg)](https://idex.io) | idex | [IDEX](https://idex.io) | 2 | [API](https://docs.idex.io/) | [![CCXT Certified](https://img.shields.io/badge/CCXT-Certified-green.svg)](https://github.com/ccxt/ccxt/wiki/Certification) | [![CCXT Pro](https://img.shields.io/badge/CCXT-Pro-black)](https://ccxt.pro) | +| [![kraken](https://user-images.githubusercontent.com/51840849/76173629-fc67fb00-61b1-11ea-84fe-f2de582f58a3.jpg)](https://www.kraken.com) | kraken | [Kraken](https://www.kraken.com) | 0 | [API](https://www.kraken.com/features/api) | [![CCXT Certified](https://img.shields.io/badge/CCXT-Certified-green.svg)](https://github.com/ccxt/ccxt/wiki/Certification) | [![CCXT Pro](https://img.shields.io/badge/CCXT-Pro-black)](https://ccxt.pro) | +| [![wavesexchange](https://user-images.githubusercontent.com/1294454/84547058-5fb27d80-ad0b-11ea-8711-78ac8b3c7f31.jpg)](https://waves.exchange) | wavesexchange | [Waves.Exchange](https://waves.exchange) | * | [API](https://docs.waves.exchange) | [![CCXT Certified](https://img.shields.io/badge/CCXT-Certified-green.svg)](https://github.com/ccxt/ccxt/wiki/Certification) | | +| [![xena](https://user-images.githubusercontent.com/51840849/87489843-bb469280-c64c-11ea-91aa-69c6326506af.jpg)](https://xena.exchange) | xena | [Xena Exchange](https://xena.exchange) | * | [API](https://support.xena.exchange/support/solutions/44000808700) | [![CCXT Certified](https://img.shields.io/badge/CCXT-Certified-green.svg)](https://github.com/ccxt/ccxt/wiki/Certification) | | ## Supported Cryptocurrency Exchange Markets -The CCXT library currently supports the following 123 cryptocurrency exchange markets and trading APIs: +The CCXT library currently supports the following 126 cryptocurrency exchange markets and trading APIs: | logo | id | name | ver | doc | certified | pro | |--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|--------------------|-----------------------------------------------------------------------------------------|:---:|:-------------------------------------------------------------------------------------------:|-----------------------------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------| +| [![aax](https://user-images.githubusercontent.com/1294454/104140087-a27f2580-53c0-11eb-87c1-5d9e81208fe9.jpg)](https://www.aaxpro.com/invite/sign-up?inviteCode=JXGm5Fy7R2MB) | aax | [AAX](https://www.aaxpro.com/invite/sign-up?inviteCode=JXGm5Fy7R2MB) | 2 | [API](https://www.aaxpro.com/apidoc/index.html) | [![CCXT Certified](https://img.shields.io/badge/CCXT-Certified-green.svg)](https://github.com/ccxt/ccxt/wiki/Certification) | | | [![acx](https://user-images.githubusercontent.com/1294454/30247614-1fe61c74-9621-11e7-9e8c-f1a627afa279.jpg)](https://acx.io) | acx | [ACX](https://acx.io) | 2 | [API](https://acx.io/documents/api_v2) | | | | [![aofex](https://user-images.githubusercontent.com/51840849/77670271-056d1080-6f97-11ea-9ac2-4268e9ed0c1f.jpg)](https://aofex.com/#/register?key=9763840) | aofex | [AOFEX](https://aofex.com/#/register?key=9763840) | * | [API](https://aofex.zendesk.com/hc/en-us/sections/360005576574-API) | | | -| [![bcex](https://user-images.githubusercontent.com/51840849/77231516-851c6900-6bac-11ea-8fd6-ee5c23eddbd4.jpg)](https://www.bcex.top/register?invite_code=758978&lang=en) | bcex | [BCEX](https://www.bcex.top/register?invite_code=758978&lang=en) | 1 | [API](https://github.com/BCEX-TECHNOLOGY-LIMITED/API_Docs/wiki/Interface) | | | | [![bequant](https://user-images.githubusercontent.com/1294454/55248342-a75dfe00-525a-11e9-8aa2-05e9dca943c6.jpg)](https://bequant.io) | bequant | [Bequant](https://bequant.io) | 2 | [API](https://api.bequant.io/) | | [![CCXT Pro](https://img.shields.io/badge/CCXT-Pro-black)](https://ccxt.pro) | | [![bibox](https://user-images.githubusercontent.com/51840849/77257418-3262b000-6c85-11ea-8fb8-20bdf20b3592.jpg)](https://w2.bibox365.com/login/register?invite_code=05Kj3I) | bibox | [Bibox](https://w2.bibox365.com/login/register?invite_code=05Kj3I) | 1 | [API](https://biboxcom.github.io/en/) | | | | [![bigone](https://user-images.githubusercontent.com/1294454/69354403-1d532180-0c91-11ea-88ed-44c06cefdf87.jpg)](https://b1.run/users/new?code=D3LLBVFT) | bigone | [BigONE](https://b1.run/users/new?code=D3LLBVFT) | 3 | [API](https://open.big.one/docs/api.html) | | | @@ -66,14 +68,14 @@ The CCXT library currently supports the following 123 cryptocurrency exchange ma | [![bitbank](https://user-images.githubusercontent.com/1294454/37808081-b87f2d9c-2e59-11e8-894d-c1900b7584fe.jpg)](https://bitbank.cc/) | bitbank | [bitbank](https://bitbank.cc/) | 1 | [API](https://docs.bitbank.cc/) | | | | [![bitbay](https://user-images.githubusercontent.com/1294454/27766132-978a7bd8-5ece-11e7-9540-bc96d1e9bbb8.jpg)](https://auth.bitbay.net/ref/jHlbB4mIkdS1) | bitbay | [BitBay](https://auth.bitbay.net/ref/jHlbB4mIkdS1) | * | [API](https://bitbay.net/public-api) | | | | [![bitcoincom](https://user-images.githubusercontent.com/1294454/97296144-514fa300-1861-11eb-952b-3d55d492200b.jpg)](https://exchange.bitcoin.com/referral/da948b21d6c92d69) | bitcoincom | [bitcoin.com](https://exchange.bitcoin.com/referral/da948b21d6c92d69) | 2 | [API](https://api.exchange.bitcoin.com/api/2/explore) | | [![CCXT Pro](https://img.shields.io/badge/CCXT-Pro-black)](https://ccxt.pro) | -| [![bitfinex](https://user-images.githubusercontent.com/1294454/27766244-e328a50c-5ed2-11e7-947b-041416579bb3.jpg)](https://www.bitfinex.com/?refcode=P61eYxFL) | bitfinex | [Bitfinex](https://www.bitfinex.com/?refcode=P61eYxFL) | 1 | [API](https://docs.bitfinex.com/v1/docs) | [![CCXT Certified](https://img.shields.io/badge/CCXT-Certified-green.svg)](https://github.com/ccxt/ccxt/wiki/Certification) | [![CCXT Pro](https://img.shields.io/badge/CCXT-Pro-black)](https://ccxt.pro) | +| [![bitfinex](https://user-images.githubusercontent.com/1294454/27766244-e328a50c-5ed2-11e7-947b-041416579bb3.jpg)](https://www.bitfinex.com/?refcode=P61eYxFL) | bitfinex | [Bitfinex](https://www.bitfinex.com/?refcode=P61eYxFL) | 1 | [API](https://docs.bitfinex.com/v1/docs) | | [![CCXT Pro](https://img.shields.io/badge/CCXT-Pro-black)](https://ccxt.pro) | | [![bitfinex2](https://user-images.githubusercontent.com/1294454/27766244-e328a50c-5ed2-11e7-947b-041416579bb3.jpg)](https://www.bitfinex.com/?refcode=P61eYxFL) | bitfinex2 | [Bitfinex](https://www.bitfinex.com/?refcode=P61eYxFL) | 2 | [API](https://docs.bitfinex.com/v2/docs/) | | | | [![bitflyer](https://user-images.githubusercontent.com/1294454/28051642-56154182-660e-11e7-9b0d-6042d1e6edd8.jpg)](https://bitflyer.com) | bitflyer | [bitFlyer](https://bitflyer.com) | 1 | [API](https://lightning.bitflyer.com/docs?lang=en) | | | | [![bitforex](https://user-images.githubusercontent.com/51840849/87295553-1160ec00-c50e-11ea-8ea0-df79276a9646.jpg)](https://www.bitforex.com/en/invitationRegister?inviterId=1867438) | bitforex | [Bitforex](https://www.bitforex.com/en/invitationRegister?inviterId=1867438) | 1 | [API](https://github.com/githubdev2020/API_Doc_en/wiki) | | | | [![bitget](https://user-images.githubusercontent.com/51840849/88317935-a8a21c80-cd22-11ea-8e2b-4b9fac5975eb.jpg)](https://www.bitget.com/expressly?languageType=0&channelCode=ccxt&vipCode=tg9j) | bitget | [Bitget](https://www.bitget.com/expressly?languageType=0&channelCode=ccxt&vipCode=tg9j) | 3 | [API](https://bitgetlimited.github.io/apidoc/en/swap) | | | | [![bithumb](https://user-images.githubusercontent.com/1294454/30597177-ea800172-9d5e-11e7-804c-b9d4fa9b56b0.jpg)](https://www.bithumb.com) | bithumb | [Bithumb](https://www.bithumb.com) | * | [API](https://apidocs.bithumb.com) | | | | [![bitkk](https://user-images.githubusercontent.com/1294454/32859187-cd5214f0-ca5e-11e7-967d-96568e2e2bd1.jpg)](https://www.bitkk.com) | bitkk | [bitkk](https://www.bitkk.com) | 1 | [API](https://www.bitkk.com/i/developer) | | | -| [![bitmart](https://user-images.githubusercontent.com/1294454/61835713-a2662f80-ae85-11e9-9d00-6442919701fd.jpg)](http://www.bitmart.com/?r=rQCFLh) | bitmart | [BitMart](http://www.bitmart.com/?r=rQCFLh) | 1 | [API](https://github.com/bitmartexchange/bitmart-official-api-docs) | | | +| [![bitmart](https://user-images.githubusercontent.com/1294454/61835713-a2662f80-ae85-11e9-9d00-6442919701fd.jpg)](http://www.bitmart.com/?r=rQCFLh) | bitmart | [BitMart](http://www.bitmart.com/?r=rQCFLh) | 1 | [API](https://developer-pro.bitmart.com/) | | | | [![bitmax](https://user-images.githubusercontent.com/1294454/66820319-19710880-ef49-11e9-8fbe-16be62a11992.jpg)](https://bitmax.io/#/register?inviteCode=EL6BXBQM) | bitmax | [BitMax](https://bitmax.io/#/register?inviteCode=EL6BXBQM) | 1 | [API](https://bitmax-exchange.github.io/bitmax-pro-api/#bitmax-pro-api-documentation) | | | | [![bitmex](https://user-images.githubusercontent.com/1294454/27766319-f653c6e6-5ed4-11e7-933d-f0bc3699ae8f.jpg)](https://www.bitmex.com/register/upZpOX) | bitmex | [BitMEX](https://www.bitmex.com/register/upZpOX) | 1 | [API](https://www.bitmex.com/app/apiOverview) | | [![CCXT Pro](https://img.shields.io/badge/CCXT-Pro-black)](https://ccxt.pro) | | [![bitpanda](https://user-images.githubusercontent.com/51840849/87591171-9a377d80-c6f0-11ea-94ac-97a126eac3bc.jpg)](https://www.bitpanda.com/en/pro) | bitpanda | [Bitpanda Pro](https://www.bitpanda.com/en/pro) | 1 | [API](https://developers.bitpanda.com/exchange/) | | | @@ -95,6 +97,7 @@ The CCXT library currently supports the following 123 cryptocurrency exchange ma | [![bw](https://user-images.githubusercontent.com/1294454/69436317-31128c80-0d52-11ea-91d1-eb7bb5818812.jpg)](https://www.bw.com/regGetCommission/N3JuT1R3bWxKTE0) | bw | [BW](https://www.bw.com/regGetCommission/N3JuT1R3bWxKTE0) | 1 | [API](https://github.com/bw-exchange/api_docs_en/wiki) | | | | [![bybit](https://user-images.githubusercontent.com/51840849/76547799-daff5b80-649e-11ea-87fb-3be9bac08954.jpg)](https://www.bybit.com/app/register?ref=X7Prm) | bybit | [Bybit](https://www.bybit.com/app/register?ref=X7Prm) | 2 | [API](https://bybit-exchange.github.io/docs/inverse/) | | | | [![bytetrade](https://user-images.githubusercontent.com/1294454/67288762-2f04a600-f4e6-11e9-9fd6-c60641919491.jpg)](https://www.byte-trade.com) | bytetrade | [ByteTrade](https://www.byte-trade.com) | * | [API](https://docs.byte-trade.com/#description) | [![CCXT Certified](https://img.shields.io/badge/CCXT-Certified-green.svg)](https://github.com/ccxt/ccxt/wiki/Certification) | | +| [![cdax](https://user-images.githubusercontent.com/1294454/102157692-fd406280-3e90-11eb-8d46-4511b617cd17.jpg)](https://cdax.io/invite?invite_code=esc74) | cdax | [CDAX](https://cdax.io/invite?invite_code=esc74) | 1 | [API](https://github.com/cloudapidoc/API_Docs) | | | | [![cex](https://user-images.githubusercontent.com/1294454/27766442-8ddc33b0-5ed8-11e7-8b98-f786aef0f3c9.jpg)](https://cex.io/r/0/up105393824/0/) | cex | [CEX.IO](https://cex.io/r/0/up105393824/0/) | * | [API](https://cex.io/cex-api) | | | | [![chilebit](https://user-images.githubusercontent.com/1294454/27991414-1298f0d8-647f-11e7-9c40-d56409266336.jpg)](https://chilebit.net) | chilebit | [ChileBit](https://chilebit.net) | 1 | [API](https://blinktrade.com/docs) | | | | [![coinbase](https://user-images.githubusercontent.com/1294454/40811661-b6eceae2-653a-11e8-829e-10bfadb078cf.jpg)](https://www.coinbase.com/join/58cbe25a355148797479dbd2) | coinbase | [Coinbase](https://www.coinbase.com/join/58cbe25a355148797479dbd2) | 2 | [API](https://developers.coinbase.com/api/v2) | | | @@ -112,9 +115,11 @@ The CCXT library currently supports the following 123 cryptocurrency exchange ma | [![coinspot](https://user-images.githubusercontent.com/1294454/28208429-3cacdf9a-6896-11e7-854e-4c79a772a30f.jpg)](https://www.coinspot.com.au/register?code=PJURCU) | coinspot | [CoinSpot](https://www.coinspot.com.au/register?code=PJURCU) | * | [API](https://www.coinspot.com.au/api) | | | | [![crex24](https://user-images.githubusercontent.com/1294454/47813922-6f12cc00-dd5d-11e8-97c6-70f957712d47.jpg)](https://crex24.com/?refid=slxsjsjtil8xexl9hksr) | crex24 | [CREX24](https://crex24.com/?refid=slxsjsjtil8xexl9hksr) | 2 | [API](https://docs.crex24.com/trade-api/v2) | | | | [![currencycom](https://user-images.githubusercontent.com/1294454/83718672-36745c00-a63e-11ea-81a9-677b1f789a4d.jpg)](https://currency.com/trading/signup?c=362jaimv&pid=referral) | currencycom | [Currency.com](https://currency.com/trading/signup?c=362jaimv&pid=referral) | 1 | [API](https://currency.com/api) | [![CCXT Certified](https://img.shields.io/badge/CCXT-Certified-green.svg)](https://github.com/ccxt/ccxt/wiki/Certification) | [![CCXT Pro](https://img.shields.io/badge/CCXT-Pro-black)](https://ccxt.pro) | +| [![delta](https://user-images.githubusercontent.com/1294454/99450025-3be60a00-2931-11eb-9302-f4fd8d8589aa.jpg)](https://www.delta.exchange/app/signup/?code=IULYNB) | delta | [Delta Exchange](https://www.delta.exchange/app/signup/?code=IULYNB) | 2 | [API](https://docs.delta.exchange) | | | | [![deribit](https://user-images.githubusercontent.com/1294454/41933112-9e2dd65a-798b-11e8-8440-5bab2959fcb8.jpg)](https://www.deribit.com/reg-1189.4038) | deribit | [Deribit](https://www.deribit.com/reg-1189.4038) | 2 | [API](https://docs.deribit.com/v2) | | | | [![digifinex](https://user-images.githubusercontent.com/51840849/87443315-01283a00-c5fe-11ea-8628-c2a0feaf07ac.jpg)](https://www.digifinex.com/en-ww/from/DhOzBg?channelCode=ljaUPp) | digifinex | [DigiFinex](https://www.digifinex.com/en-ww/from/DhOzBg?channelCode=ljaUPp) | 3 | [API](https://docs.digifinex.com) | | | | [![dsx](https://user-images.githubusercontent.com/51840849/76909626-cb2bb100-68bc-11ea-99e0-28ba54f04792.jpg)](https://dsxglobal.com) | dsx | [DSX](https://dsxglobal.com) | 3 | [API](https://dsxglobal.com/developers/publicApi) | | | +| [![equos](https://user-images.githubusercontent.com/1294454/107758499-05edd180-6d38-11eb-9e09-0b69602a7a15.jpg)](https://equos.io?referredByCode=zpa8kij4ouvBFup3) | equos | [EQUOS](https://equos.io?referredByCode=zpa8kij4ouvBFup3) | * | [API](https://developer.equos.io) | | | | [![eterbase](https://user-images.githubusercontent.com/1294454/82067900-faeb0f80-96d9-11ea-9f22-0071cfcb9871.jpg)](https://eterbase.exchange/invite/1wjjh4Pe) | eterbase | [Eterbase](https://eterbase.exchange/invite/1wjjh4Pe) | 1 | [API](https://developers.eterbase.exchange) | [![CCXT Certified](https://img.shields.io/badge/CCXT-Certified-green.svg)](https://github.com/ccxt/ccxt/wiki/Certification) | | | [![exmo](https://user-images.githubusercontent.com/1294454/27766491-1b0ea956-5eda-11e7-9225-40d67b481b8d.jpg)](https://exmo.me/?ref=131685) | exmo | [EXMO](https://exmo.me/?ref=131685) | 1.1 | [API](https://exmo.me/en/api_doc?ref=131685) | | | | [![exx](https://user-images.githubusercontent.com/1294454/37770292-fbf613d0-2de4-11e8-9f79-f2dc451b8ccb.jpg)](https://www.exx.com/r/fde4260159e53ab8a58cc9186d35501f?recommQd=1) | exx | [EXX](https://www.exx.com/r/fde4260159e53ab8a58cc9186d35501f?recommQd=1) | * | [API](https://www.exx.com/help/restApi) | | | @@ -125,12 +130,12 @@ The CCXT library currently supports the following 123 cryptocurrency exchange ma | [![ftx](https://user-images.githubusercontent.com/1294454/67149189-df896480-f2b0-11e9-8816-41593e17f9ec.jpg)](https://ftx.com/#a=1623029) | ftx | [FTX](https://ftx.com/#a=1623029) | * | [API](https://github.com/ftexchange/ftx) | [![CCXT Certified](https://img.shields.io/badge/CCXT-Certified-green.svg)](https://github.com/ccxt/ccxt/wiki/Certification) | [![CCXT Pro](https://img.shields.io/badge/CCXT-Pro-black)](https://ccxt.pro) | | [![gateio](https://user-images.githubusercontent.com/1294454/31784029-0313c702-b509-11e7-9ccc-bc0da6a0e435.jpg)](https://www.gate.io/signup/2436035) | gateio | [Gate.io](https://www.gate.io/signup/2436035) | 2 | [API](https://gate.io/api2) | | [![CCXT Pro](https://img.shields.io/badge/CCXT-Pro-black)](https://ccxt.pro) | | [![gemini](https://user-images.githubusercontent.com/1294454/27816857-ce7be644-6096-11e7-82d6-3c257263229c.jpg)](https://gemini.com/) | gemini | [Gemini](https://gemini.com/) | 1 | [API](https://docs.gemini.com/rest-api) | | | +| [![gopax](https://user-images.githubusercontent.com/1294454/102897212-ae8a5e00-4478-11eb-9bab-91507c643900.jpg)](https://www.gopax.co.kr) | gopax | [GOPAX](https://www.gopax.co.kr) | 1 | [API](https://gopax.github.io/API/index.en.html) | [![CCXT Certified](https://img.shields.io/badge/CCXT-Certified-green.svg)](https://github.com/ccxt/ccxt/wiki/Certification) | [![CCXT Pro](https://img.shields.io/badge/CCXT-Pro-black)](https://ccxt.pro) | | [![hbtc](https://user-images.githubusercontent.com/51840849/80134449-70663300-85a7-11ea-8942-e204cdeaab5d.jpg)](https://www.hbtc.com/register/O2S8NS) | hbtc | [HBTC](https://www.hbtc.com/register/O2S8NS) | 1 | [API](https://github.com/bhexopen/BHEX-OpenApi/tree/master/doc) | | | | [![hitbtc](https://user-images.githubusercontent.com/1294454/27766555-8eaec20e-5edc-11e7-9c5b-6dc69fc42f5e.jpg)](https://hitbtc.com/?ref_id=5a5d39a65d466) | hitbtc | [HitBTC](https://hitbtc.com/?ref_id=5a5d39a65d466) | 2 | [API](https://api.hitbtc.com) | | [![CCXT Pro](https://img.shields.io/badge/CCXT-Pro-black)](https://ccxt.pro) | | [![hollaex](https://user-images.githubusercontent.com/1294454/75841031-ca375180-5ddd-11ea-8417-b975674c23cb.jpg)](https://pro.hollaex.com/signup?affiliation_code=QSWA6G) | hollaex | [HollaEx](https://pro.hollaex.com/signup?affiliation_code=QSWA6G) | 1 | [API](https://apidocs.hollaex.com) | | | | [![huobijp](https://user-images.githubusercontent.com/1294454/85734211-85755480-b705-11ea-8b35-0b7f1db33a2f.jpg)](https://www.huobi.co.jp/register/?invite_code=znnq3) | huobijp | [Huobi Japan](https://www.huobi.co.jp/register/?invite_code=znnq3) | 1 | [API](https://api-doc.huobi.co.jp) | | [![CCXT Pro](https://img.shields.io/badge/CCXT-Pro-black)](https://ccxt.pro) | | [![huobipro](https://user-images.githubusercontent.com/1294454/76137448-22748a80-604e-11ea-8069-6e389271911d.jpg)](https://www.huobi.com/en-us/topic/invited/?invite_code=rwrd3) | huobipro | [Huobi Pro](https://www.huobi.com/en-us/topic/invited/?invite_code=rwrd3) | 1 | [API](https://huobiapi.github.io/docs/spot/v1/cn/) | | [![CCXT Pro](https://img.shields.io/badge/CCXT-Pro-black)](https://ccxt.pro) | -| [![huobiru](https://user-images.githubusercontent.com/1294454/52978816-e8552e00-33e3-11e9-98ed-845acfece834.jpg)](https://www.huobi.com.ru/invite?invite_code=esc74) | huobiru | [Huobi Russia](https://www.huobi.com.ru/invite?invite_code=esc74) | 1 | [API](https://github.com/cloudapidoc/API_Docs_en) | | [![CCXT Pro](https://img.shields.io/badge/CCXT-Pro-black)](https://ccxt.pro) | | [![ice3x](https://user-images.githubusercontent.com/51840849/87460809-1dd06c00-c616-11ea-98ad-7d5e1cb7fcdd.jpg)](https://ice3x.com?ref=14341802) | ice3x | [ICE3X](https://ice3x.com?ref=14341802) | 1 | [API](https://ice3x.co.za/ice-cubed-bitcoin-exchange-api-documentation-1-june-2017) | | | | [![idex](https://user-images.githubusercontent.com/51840849/94481303-2f222100-01e0-11eb-97dd-bc14c5943a86.jpg)](https://idex.io) | idex | [IDEX](https://idex.io) | 2 | [API](https://docs.idex.io/) | [![CCXT Certified](https://img.shields.io/badge/CCXT-Certified-green.svg)](https://github.com/ccxt/ccxt/wiki/Certification) | [![CCXT Pro](https://img.shields.io/badge/CCXT-Pro-black)](https://ccxt.pro) | | [![independentreserve](https://user-images.githubusercontent.com/51840849/87182090-1e9e9080-c2ec-11ea-8e49-563db9a38f37.jpg)](https://www.independentreserve.com) | independentreserve | [Independent Reserve](https://www.independentreserve.com) | * | [API](https://www.independentreserve.com/API) | | | @@ -143,11 +148,11 @@ The CCXT library currently supports the following 123 cryptocurrency exchange ma | [![latoken](https://user-images.githubusercontent.com/1294454/61511972-24c39f00-aa01-11e9-9f7c-471f1d6e5214.jpg)](https://latoken.com) | latoken | [Latoken](https://latoken.com) | 1 | [API](https://api.latoken.com) | | | | [![lbank](https://user-images.githubusercontent.com/1294454/38063602-9605e28a-3302-11e8-81be-64b1e53c4cfb.jpg)](https://www.lbex.io/invite?icode=7QCY) | lbank | [LBank](https://www.lbex.io/invite?icode=7QCY) | 1 | [API](https://github.com/LBank-exchange/lbank-official-api-docs) | | | | [![liquid](https://user-images.githubusercontent.com/1294454/45798859-1a872600-bcb4-11e8-8746-69291ce87b04.jpg)](https://www.liquid.com/sign-up/?affiliate=SbzC62lt30976) | liquid | [Liquid](https://www.liquid.com/sign-up/?affiliate=SbzC62lt30976) | 2 | [API](https://developers.liquid.com) | | | -| [![livecoin](https://user-images.githubusercontent.com/1294454/27980768-f22fc424-638a-11e7-89c9-6010a54ff9be.jpg)](https://livecoin.net/?from=Livecoin-CQ1hfx44) | livecoin | [LiveCoin](https://livecoin.net/?from=Livecoin-CQ1hfx44) | * | [API](https://www.livecoin.net/api?lang=en) | | | | [![luno](https://user-images.githubusercontent.com/1294454/27766607-8c1a69d8-5ede-11e7-930c-540b5eb9be24.jpg)](https://www.luno.com/invite/44893A) | luno | [luno](https://www.luno.com/invite/44893A) | 1 | [API](https://www.luno.com/en/api) | | | | [![lykke](https://user-images.githubusercontent.com/1294454/34487620-3139a7b0-efe6-11e7-90f5-e520cef74451.jpg)](https://www.lykke.com) | lykke | [Lykke](https://www.lykke.com) | 1 | [API](https://hft-api.lykke.com/swagger/ui/) | | | | [![mercado](https://user-images.githubusercontent.com/1294454/27837060-e7c58714-60ea-11e7-9192-f05e86adb83f.jpg)](https://www.mercadobitcoin.com.br) | mercado | [Mercado Bitcoin](https://www.mercadobitcoin.com.br) | 3 | [API](https://www.mercadobitcoin.com.br/api-doc) | | | | [![mixcoins](https://user-images.githubusercontent.com/51840849/87460810-1dd06c00-c616-11ea-9276-956f400d6ffa.jpg)](https://mixcoins.com) | mixcoins | [MixCoins](https://mixcoins.com) | 1 | [API](https://mixcoins.com/help/api/) | | | +| [![ndax](https://user-images.githubusercontent.com/1294454/108623144-67a3ef00-744e-11eb-8140-75c6b851e945.jpg)](https://one.ndax.io/bfQiSL) | ndax | [NDAX](https://one.ndax.io/bfQiSL) | * | [API](https://apidoc.ndax.io/) | | [![CCXT Pro](https://img.shields.io/badge/CCXT-Pro-black)](https://ccxt.pro) | | [![novadax](https://user-images.githubusercontent.com/1294454/92337550-2b085500-f0b3-11ea-98e7-5794fb07dd3b.jpg)](https://www.novadax.com.br/?s=ccxt) | novadax | [NovaDAX](https://www.novadax.com.br/?s=ccxt) | 1 | [API](https://doc.novadax.com/pt-BR/) | | | | [![oceanex](https://user-images.githubusercontent.com/1294454/58385970-794e2d80-8001-11e9-889c-0567cd79b78e.jpg)](https://oceanex.pro/signup?referral=VE24QX) | oceanex | [OceanEx](https://oceanex.pro/signup?referral=VE24QX) | 1 | [API](https://api.oceanex.pro/doc/v1) | | | | [![okcoin](https://user-images.githubusercontent.com/51840849/87295551-102fbf00-c50e-11ea-90a9-462eebba5829.jpg)](https://www.okcoin.com/account/register?flag=activity&channelId=600001513) | okcoin | [OKCoin](https://www.okcoin.com/account/register?flag=activity&channelId=600001513) | 3 | [API](https://www.okcoin.com/docs/en/) | | [![CCXT Pro](https://img.shields.io/badge/CCXT-Pro-black)](https://ccxt.pro) | @@ -166,7 +171,7 @@ The CCXT library currently supports the following 123 cryptocurrency exchange ma | [![tidebit](https://user-images.githubusercontent.com/51840849/87460811-1e690280-c616-11ea-8652-69f187305add.jpg)](http://bit.ly/2IX0LrM) | tidebit | [TideBit](http://bit.ly/2IX0LrM) | 2 | [API](https://www.tidebit.com/documents/api/guide) | | | | [![tidex](https://user-images.githubusercontent.com/1294454/30781780-03149dc4-a12e-11e7-82bb-313b269d24d4.jpg)](https://tidex.com/exchange/?ref=57f5638d9cd7) | tidex | [Tidex](https://tidex.com/exchange/?ref=57f5638d9cd7) | 3 | [API](https://tidex.com/exchange/public-api) | | | | [![timex](https://user-images.githubusercontent.com/1294454/70423869-6839ab00-1a7f-11ea-8f94-13ae72c31115.jpg)](https://timex.io/?refcode=1x27vNkTbP1uwkCck) | timex | [TimeX](https://timex.io/?refcode=1x27vNkTbP1uwkCck) | 1 | [API](https://docs.timex.io) | | | -| [![upbit](https://user-images.githubusercontent.com/1294454/49245610-eeaabe00-f423-11e8-9cba-4b0aed794799.jpg)](https://upbit.com) | upbit | [Upbit](https://upbit.com) | 1 | [API](https://docs.upbit.com/docs/%EC%9A%94%EC%B2%AD-%EC%88%98-%EC%A0%9C%ED%95%9C) | [![CCXT Certified](https://img.shields.io/badge/CCXT-Certified-green.svg)](https://github.com/ccxt/ccxt/wiki/Certification) | [![CCXT Pro](https://img.shields.io/badge/CCXT-Pro-black)](https://ccxt.pro) | +| [![upbit](https://user-images.githubusercontent.com/1294454/49245610-eeaabe00-f423-11e8-9cba-4b0aed794799.jpg)](https://upbit.com) | upbit | [Upbit](https://upbit.com) | 1 | [API](https://docs.upbit.com/docs/%EC%9A%94%EC%B2%AD-%EC%88%98-%EC%A0%9C%ED%95%9C) | | [![CCXT Pro](https://img.shields.io/badge/CCXT-Pro-black)](https://ccxt.pro) | | [![vaultoro](https://user-images.githubusercontent.com/1294454/27766880-f205e870-5ee9-11e7-8fe2-0d5b15880752.jpg)](https://www.vaultoro.com) | vaultoro | [Vaultoro](https://www.vaultoro.com) | 1 | [API](https://api.vaultoro.com) | | | | [![vbtc](https://user-images.githubusercontent.com/1294454/27991481-1f53d1d8-6481-11e7-884e-21d17e7939db.jpg)](https://vbtc.exchange) | vbtc | [VBTC](https://vbtc.exchange) | 1 | [API](https://blinktrade.com/docs) | | | | [![vcc](https://user-images.githubusercontent.com/1294454/100545356-8427f500-326c-11eb-9539-7d338242d61b.jpg)](https://vcc.exchange?ref=l4xhrH) | vcc | [VCC Exchange](https://vcc.exchange?ref=l4xhrH) | 3 | [API](https://vcc.exchange/api) | | | @@ -224,13 +229,13 @@ console.log (ccxt.exchanges) // print all available exchanges All-in-one browser bundle (dependencies included), served from a CDN of your choice: -* jsDelivr: https://cdn.jsdelivr.net/npm/ccxt@1.38.75/dist/ccxt.browser.js -* unpkg: https://unpkg.com/ccxt@1.38.75/dist/ccxt.browser.js +* jsDelivr: https://cdn.jsdelivr.net/npm/ccxt@1.42.77/dist/ccxt.browser.js +* unpkg: https://unpkg.com/ccxt@1.42.77/dist/ccxt.browser.js CDNs are not updated in real-time and may have delays. Defaulting to the most recent version without specifying the version number is not recommended. Please, keep in mind that we are not responsible for the correct operation of those CDN servers. ```HTML - + ``` Creates a global `ccxt` object: @@ -275,6 +280,8 @@ include "ccxt.php"; var_dump (\ccxt\Exchange::$exchanges); // print a list of all available exchange classes ``` +The library supports concurrent asynchronous mode using tools from [RecoilPHP](https://github.com/recoilphp/recoil) and [ReactPHP](https://reactphp.org/) in PHP 7.1+. Read the [Manual](https://github.com/ccxt/ccxt/wiki) for more details. + ### Docker You can get CCXT installed in a container along with all the supported languages and dependencies. This may be useful if you want to contribute to CCXT (e.g. run the build scripts and tests — please see the [Contributing](https://github.com/ccxt/ccxt/blob/master/CONTRIBUTING.md) document for the details on that). @@ -529,15 +536,6 @@ Thank you to all our backers! [[Become a backer](https://opencollective.com/ccxt -### Crypto - -``` -ETH 0x26a3CB49578F07000575405a57888681249c35Fd (ETH only) -BTC 33RmVRfhK2WZVQR1R83h2e9yXoqRNDvJva -BCH 1GN9p233TvNcNQFthCgfiHUnj5JRKEc2Ze -LTC LgM5hkvPzytEFfQGGDFGKYkE743jwUA7qv -``` - Thank you! ## Social diff --git a/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/build/transpile.js b/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/build/transpile.js index 0f4d1dcc6..948a34c0f 100644 --- a/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/build/transpile.js +++ b/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/build/transpile.js @@ -274,6 +274,7 @@ class Transpiler { [ /(?<=[^\s#]) \]/g, ']' ], // PEP8 E202 remove whitespaces before right ] square bracket [ /(?<=[^\s#]) \}/g, '}' ], // PEP8 E202 remove whitespaces before right } bracket [ /([^a-z])(elif|if|or|else)\(/g, '$1$2 \(' ], // a correction for PEP8 E225 side-effect for compound and ternary conditionals + [ /\!\=\sTrue/g, 'is not True' ], // a correction for PEP8 E712, it likes "is not True", not "!= True" [ /\=\=\sTrue/g, 'is True' ], // a correction for PEP8 E712, it likes "is True", not "== True" [ /\sdelete\s/g, ' del ' ], [ /(?\=]+(\<=|\>=|<|>)\s*(.*)\s*\;([^\)]+)\)\s*{/g, 'for ($1 = $2; $1 $3 $4;$5) {' ], [ /([^\s]+)\.length\;/g, 'is_array($1) ? count($1) : 0;' ], [ /\.push\s*\(([\s\S]+?)\)\;/g, '[] = $1;' ], - [ /(\s)await(\s)/g, '$1' ], + [ /(\b)await(\b)/g, 'yield' ], [ /([\S])\: /g, '$1 => ' ], // add {}-array syntax conversions up to 20 levels deep @@ -441,7 +448,7 @@ class Transpiler { "import os", "import sys", "", - "root = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))", + "root = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))", "sys.path.append(root)", "", "# ----------------------------------------------------------------------------", @@ -598,11 +605,11 @@ class Transpiler { return 'class ' + className + ' extends ' + baseClass + ' {' } - createPHPClassHeader (className, baseClass, bodyAsString) { + createPHPClassHeader (className, baseClass, bodyAsString, namespace) { return [ " sync PHP + let phpBody = this.transpileAsyncPHPToSyncPHP (phpAsyncBody) + + return { python3Body, python2Body, phpBody, phpAsyncBody } } //----------------------------------------------------------------------------- transpilePythonAsyncToSync () { - const async = './python/test/test_async.py' - const sync = './python/test/test.py' + const async = './python/ccxt/test/test_async.py' + const sync = './python/ccxt/test/test_sync.py' log.magenta ('Transpiling ' + async .yellow + ' → ' + sync.yellow) const fileContents = fs.readFileSync (async, 'utf8') let lines = fileContents.split ("\n") lines = lines.filter (line => ![ 'import asyncio' ].includes (line)) - .map (line => { - return ( - line.replace ('asyncio.get_event_loop().run_until_complete(main())', 'main()') - .replace ('import ccxt.async_support as ccxt', 'import ccxt') - .replace (/.*token\_bucket.*/g, '') - .replace ('await asyncio.sleep', 'time.sleep') - .replace ('async ', '') - .replace ('await ', '')) - }) + .map (line => { + return ( + line.replace ('asyncio.get_event_loop().run_until_complete(main())', 'main()') + .replace ('import ccxt.async_support as ccxt', 'import ccxt') + .replace (/.*token\_bucket.*/g, '') + .replace ('await asyncio.sleep', 'time.sleep') + .replace ('async ', '') + .replace ('await ', '')) + }) // lines.forEach (line => log (line)) @@ -803,22 +822,47 @@ class Transpiler { fs.writeFileSync (sync, newContents) } + //----------------------------------------------------------------------------- + + transpilePhpAsyncToSync () { + + const async = './php/test/test_async.php' + const sync = './php/test/test_sync.php' + log.magenta ('Transpiling ' + async .yellow + ' → ' + sync.yellow) + const fileContents = fs.readFileSync (async, 'utf8') + const syncBody = this.transpileAsyncPHPToSyncPHP (fileContents) + + const phpSyncRegexes = [ + [ /\$kernel->execute\(\$main\)/, '\$main()' ], + [ /\$kernel->run\(\);\n/, '' ], + [ /\$kernel = async\\Exchange::get_kernel\(\);\n/, '' ], + [ /ccxt\\\\async/, 'ccxt' ], + ] + + const newContents = this.regexAll (syncBody, phpSyncRegexes) + + fs.truncateSync (sync) + fs.writeFileSync (sync, newContents) + } + + // ------------------------------------------------------------------------ + + getExchangeClassDeclarationMatches (contents) { + return contents.match (/^module\.exports\s*=\s*class\s+([\S]+)\s+extends\s+([\S]+)\s+{([\s\S]+?)^};*/m) + } + // ------------------------------------------------------------------------ transpileDerivedExchangeClass (contents, methodNames = undefined) { - let exchangeClassDeclarationMatches = contents.match (/^module\.exports\s*=\s*class\s+([\S]+)\s+extends\s+([\S]+)\s+{([\s\S]+?)^};*/m) + const [ _, className, baseClass, methodMatches ] = this.getExchangeClassDeclarationMatches (contents) - // log.green (file, exchangeClassDeclarationMatches[3]) - - let className = exchangeClassDeclarationMatches[1] - let baseClass = exchangeClassDeclarationMatches[2] - - let methods = exchangeClassDeclarationMatches[3].trim ().split (/\n\s*\n/) + const methods = methodMatches.trim ().split (/\n\s*\n/) let python2 = [] let python3 = [] let php = [] + let phpAsync = [] methodNames = [] // methodNames || [] @@ -838,14 +882,6 @@ class Transpiler { // async or not let keyword = matches[1] - // try { - // keyword = matches[1] - // } catch (e) { - // log.red (e) - // log.green (methods[i]) - // log.yellow (exchangeClassDeclarationMatches[3].trim ().split (/\n\s*\n/)) - // process.exit () - // } // method name let method = matches[2] @@ -869,17 +905,17 @@ class Transpiler { // remove excessive spacing from argument defaults in Python method signature let pythonArgs = args.map (x => x.replace (' = ', '=')) - .join (', ') - .replace (/undefined/g, 'None') - .replace (/false/g, 'False') - .replace (/true/g, 'True') + .join (', ') + .replace (/undefined/g, 'None') + .replace (/false/g, 'False') + .replace (/true/g, 'True') // method body without the signature (first line) // and without the closing bracket (last line) let js = lines.slice (1, -1).join ("\n") // transpile everything - let { python3Body, python2Body, phpBody } = this.transpileJavaScriptToPythonAndPHP ({ js, className, variables, removeEmptyLines: true }) + let { python3Body, python2Body, phpBody, phpAsyncBody } = this.transpileJavaScriptToPythonAndPHP ({ js, className, variables, removeEmptyLines: true }) // compile the final Python code for the method signature let pythonString = 'def ' + method + '(self' + (pythonArgs.length ? ', ' + pythonArgs : '') + '):' @@ -900,14 +936,19 @@ class Transpiler { php.push (phpBody); php.push (' }') + phpAsync.push (''); + phpAsync.push (' public function ' + method + '(' + phpArgs + ') {'); + phpAsync.push (phpAsyncBody); + phpAsync.push (' }') } return { - // altogether in PHP, Python 2 and 3 (async) - python2: this.createPythonClass (className, baseClass, python2, methodNames), - python3: this.createPythonClass (className, baseClass, python3, methodNames, true), - php: this.createPHPClass (className, baseClass, php, methodNames), + // altogether in PHP, async PHP, Python 2 and 3 (async) + python2: this.createPythonClass (className, baseClass, python2, methodNames), + python3: this.createPythonClass (className, baseClass, python3, methodNames, true), + php: this.createPHPClass (className, baseClass, php, methodNames), + phpAsync: this.createPHPClass (className, baseClass, phpAsync, methodNames, true), className, baseClass, @@ -916,46 +957,58 @@ class Transpiler { // ======================================================================== - transpileDerivedExchangeFile (jsFolder, filename, options) { + transpileDerivedExchangeFile (jsFolder, filename, options, force = false) { // todo normalize jsFolder and other arguments try { - const { python2Folder, python3Folder, phpFolder } = options - const path = jsFolder + filename - const contents = fs.readFileSync (path, 'utf8') + const { python2Folder, python3Folder, phpFolder, phpAsyncFolder } = options + const pythonFilename = filename.replace ('.js', '.py') + const phpFilename = filename.replace ('.js', '.php') - // function getMethodNames (object) { - // let functions = [] - // let o = object - // do { - // functions = functions.concat (Object.getOwnPropertyNames (o)) - // } while (o = Object.getPrototypeOf (o)) - // return unique (functions.filter (f => (typeof object[f] === 'function'))) - // } - // const exchangeClass = require ('.' + path) - // const exchange = new exchangeClass () - // const methodNames = getMethodNames (exchange) - // const { python2, python3, php, className, baseClass } = - // this.transpileDerivedExchangeClass (contents, methodNames) + const jsMtime = fs.statSync (jsFolder + filename).mtime.getTime () - const { python2, python3, php, className, baseClass } = - this.transpileDerivedExchangeClass (contents) + const python2Path = python2Folder ? (python2Folder + pythonFilename) : undefined + const python3Path = python3Folder ? (python3Folder + pythonFilename) : undefined + const phpPath = phpFolder ? (phpFolder + phpFilename) : undefined + const phpAsyncPath = phpAsyncFolder ? (phpAsyncFolder + phpFilename) : undefined - log.cyan ('Transpiling from', filename.yellow) + const python2Mtime = python2Folder ? (fs.existsSync (python2Path) ? fs.statSync (python2Path).mtime.getTime () : 0) : undefined + const python3Mtime = python3Path ? (fs.existsSync (python3Path) ? fs.statSync (python3Path).mtime.getTime () : 0) : undefined + const phpAsyncMtime = phpAsyncFolder ? (fs.existsSync (phpAsyncPath) ? fs.statSync (phpAsyncPath).mtime.getTime () : 0) : undefined + const phpMtime = phpPath ? (fs.existsSync (phpPath) ? fs.statSync (phpPath).mtime.getTime () : 0) : undefined - ;[ - [ python2Folder, filename.replace ('.js', '.py'), python2 ], - [ python3Folder, filename.replace ('.js', '.py'), python3 ], - [ phpFolder, filename.replace ('.js', '.php'), php ], - ].forEach (([ folder, filename, code ]) => { - if (folder) { - overwriteFile (folder + filename, code) - } - }) + const contents = fs.readFileSync (jsFolder + filename, 'utf8') - return { className, baseClass } + if (force || + (python3Folder && (jsMtime > python3Mtime)) || + (phpFolder && (jsMtime > phpMtime)) || + (phpAsyncFolder && (jsMtime > phpAsyncMtime)) || + (python2Folder && (jsMtime > python2Mtime))) { + const { python2, python3, php, phpAsync, className, baseClass } = this.transpileDerivedExchangeClass (contents) + log.cyan ('Transpiling from', filename.yellow) + + ;[ + [ python2Folder, pythonFilename, python2 ], + [ python3Folder, pythonFilename, python3 ], + [ phpFolder, phpFilename, php ], + [ phpAsyncFolder, phpFilename, phpAsync ], + ].forEach (([ folder, filename, code ]) => { + if (folder) { + overwriteFile (folder + filename, code) + fs.utimesSync (folder + filename, new Date (), new Date (jsMtime)) + } + }) + + return { className, baseClass } + + } else { + + const [ _, className, baseClass ] = this.getExchangeClassDeclarationMatches (contents) + log.green ('Already transpiled', filename.yellow) + return { className, baseClass } + } } catch (e) { @@ -967,11 +1020,11 @@ class Transpiler { //------------------------------------------------------------------------- - transpileDerivedExchangeFiles (jsFolder, options, pattern = '.js') { + transpileDerivedExchangeFiles (jsFolder, options, pattern = '.js', force = false) { // todo normalize jsFolder and other arguments - const { python2Folder, python3Folder, phpFolder } = options + const { python2Folder, python3Folder, phpFolder, phpAsyncFolder } = options // exchanges.json accounts for ids included in exchanges.cfg let ids = undefined @@ -984,7 +1037,7 @@ class Transpiler { const classNames = fs.readdirSync (jsFolder) .filter (file => file.match (regex) && (!ids || ids.includes (basename (file, '.js')))) - .map (file => this.transpileDerivedExchangeFile (jsFolder, file, options)) + .map (file => this.transpileDerivedExchangeFile (jsFolder, file, options, force)) const classes = {} @@ -1013,6 +1066,7 @@ class Transpiler { [ python2Folder, /\.pyc?$/ ], [ python3Folder, /\.pyc?$/ ], [ phpFolder, /\.php$/ ], + [ phpAsyncFolder, /\.php$/ ], ].forEach (([ folder, pattern ]) => { if (folder) { deleteOldTranspiledFiles (folder, pattern) @@ -1026,19 +1080,37 @@ class Transpiler { // ======================================================================== - exportTypeScriptDeclarations (file, classes) { + exportTypeScriptClassNames (file, classes) { - log.bright.cyan ('Exporting TypeScript declarations →', file.yellow) + log.bright.cyan ('Exporting TypeScript class names →', file.yellow) const regex = /\/[\n]{2}(?: export class [^\s]+ extends [^\s]+ \{\}[\r]?[\n])+/ const replacement = "/\n\n" + Object.keys (classes).map (className => { - const baseClass = classes[className] + const baseClass = classes[className].replace (/ccxt\.[a-z_]+/, 'Exchange') return ' export class ' + className + ' extends ' + baseClass + " {}" }).join ("\n") + "\n" replaceInFile (file, regex, replacement) } + exportTypeScriptExchangeIds (file, classes) { + + log.bright.cyan ('Exporting TypeScript exchange ids →', file.yellow) + + const regex = /\/[\n]{2} export type ExchangeId =\n(?: \| \'[a-z0-9_]+\'[\r]?[\n])+/ + const replacement = "/\n\n export type ExchangeId =\n" + Object.keys (classes).map (className => { + return " | '" + className + "'" + }).join ("\n") + "\n" + + replaceInFile (file, regex, replacement) + } + + exportTypeScriptDeclarations (file, classes) { + + this.exportTypeScriptClassNames (file, classes) + this.exportTypeScriptExchangeIds (file, classes) + } + // ======================================================================== transpileErrorHierarchy () { @@ -1092,7 +1164,7 @@ class Transpiler { const quote = (s) => "'" + s + "'" // helper to add quotes around class names - const pythonExports = [ 'error_hierarchy' ] + const pythonExports = [ 'error_hierarchy', 'BaseError' ] const pythonErrors = intellisense (root, 'BaseError', pythonDeclareErrorClass, pythonExports) const pythonAll = '__all__ = [\n ' + pythonExports.map (quote).join (',\n ') + '\n]' @@ -1157,7 +1229,7 @@ class Transpiler { transpileDateTimeTests () { const jsFile = './js/test/base/functions/test.datetime.js' - const pyFile = './python/test/test_exchange_datetime_functions.py' + const pyFile = './python/ccxt/test/test_exchange_datetime_functions.py' const phpFile = './php/test/test_exchange_datetime_functions.php' log.magenta ('Transpiling from', jsFile.yellow) @@ -1169,7 +1241,7 @@ class Transpiler { [/^\/\*.*\s+/mg, ''], ]) - let { python3Body, python2Body, phpBody } = this.transpileJavaScriptToPythonAndPHP ({ js, removeEmptyLines: false }) + let { python3Body, python2Body, phpBody, phpAsyncBody } = this.transpileJavaScriptToPythonAndPHP ({ js, removeEmptyLines: false }) // phpBody = phpBody.replace (/exchange\./g, 'Exchange::') @@ -1198,7 +1270,7 @@ class Transpiler { transpilePrecisionTests () { const jsFile = './js/test/base/functions/test.number.js' - const pyFile = './python/test/test_decimal_to_precision.py' + const pyFile = './python/ccxt/test/test_decimal_to_precision.py' const phpFile = './php/test/decimal_to_precision.php' log.magenta ('Transpiling from', jsFile.yellow) @@ -1212,7 +1284,7 @@ class Transpiler { [ /numberToString/g, 'number_to_string' ], ]) - let { python3Body, python2Body, phpBody } = this.transpileJavaScriptToPythonAndPHP ({ js, removeEmptyLines: false }) + let { python3Body, python2Body, phpBody, phpAsyncBody } = this.transpileJavaScriptToPythonAndPHP ({ js, removeEmptyLines: false }) const pythonHeader = [ "", @@ -1283,7 +1355,7 @@ class Transpiler { transpileCryptoTests () { const jsFile = './js/test/base/functions/test.crypto.js' - const pyFile = './python/test/test_crypto.py' + const pyFile = './python/ccxt/test/test_crypto.py' const phpFile = './php/test/test_crypto.php' log.magenta ('Transpiling from', jsFile.yellow) @@ -1295,7 +1367,7 @@ class Transpiler { [ /function equals \([\S\s]+?return true\n}\n/g, '' ], ]) - let { python3Body, python2Body, phpBody } = this.transpileJavaScriptToPythonAndPHP ({ js, removeEmptyLines: false }) + let { python3Body, python2Body, phpBody, phpAsyncBody } = this.transpileJavaScriptToPythonAndPHP ({ js, removeEmptyLines: false }) const pythonHeader = [ "", @@ -1352,22 +1424,22 @@ class Transpiler { const tests = [ { 'jsFile': './js/test/Exchange/test.trade.js', - 'pyFile': './python/test/test_trade.py', + 'pyFile': './python/ccxt/test/test_trade.py', 'phpFile': './php/test/test_trade.php', }, { 'jsFile': './js/test/Exchange/test.order.js', - 'pyFile': './python/test/test_order.py', + 'pyFile': './python/ccxt/test/test_order.py', 'phpFile': './php/test/test_order.php', }, { 'jsFile': './js/test/Exchange/test.transaction.js', - 'pyFile': './python/test/test_transaction.py', + 'pyFile': './python/ccxt/test/test_transaction.py', 'phpFile': './php/test/test_transaction.php', }, { 'jsFile': './js/test/Exchange/test.ohlcv.js', - 'pyFile': './python/test/test_ohlcv.py', + 'pyFile': './python/ccxt/test/test_ohlcv.py', 'phpFile': './php/test/test_ohlcv.php', }, ] @@ -1389,7 +1461,6 @@ class Transpiler { ]) const pythonHeader = [ - '', 'import numbers # noqa: E402', 'try:', ' basestring # basestring was removed in Python 3', @@ -1400,7 +1471,7 @@ class Transpiler { ].join('\n') let { python3Body, python2Body, phpBody } = this.transpileJavaScriptToPythonAndPHP ({ js, removeEmptyLines: false }) - const python = this.getPythonPreamble () + pythonHeader + python3Body; + const python = pythonHeader + python3Body; const php = this.getPHPPreamble (false) + phpBody; log.magenta ('→', test.pyFile.yellow) @@ -1423,22 +1494,53 @@ class Transpiler { // ============================================================================ - transpileEverything () { + transpilePhpBaseClassMethods () { + const baseMethods = this.getPHPBaseMethods () + const indent = 4 + const space = ' '.repeat (indent) + const result = [ + 'public static $camelcase_methods = array(', + ] + for (const method of baseMethods) { + const underscoreCase = unCamelCase (method) + if (underscoreCase !== method) { + result.push (space.repeat (2) + '\'' + method + '\' => ' + '\'' + underscoreCase + '\',') + } + } + result.push (space + ');') + const string = result.join ('\n') + + const phpBaseClass = './php/base/Exchange.php'; + const phpBody = fs.readFileSync (phpBaseClass, 'utf8') + const regex = /public static \$camelcase_methods = array\([\s\S]+?\);/g + const bodyArray = phpBody.split (regex) + + const newBody = bodyArray[0] + string + bodyArray[1] + + log.magenta ('Transpiling from ', phpBaseClass.yellow, '→', phpBaseClass.yellow) + overwriteFile (phpBaseClass, newBody) + } + + // ============================================================================ + + transpileEverything (force = false) { // default pattern is '.js' - const [ /* node */, /* script */, pattern ] = process.argv - , python2Folder = './python/ccxt/' - , python3Folder = './python/ccxt/async_support/' - , phpFolder = './php/' - , options = { python2Folder, python3Folder, phpFolder } + const [ /* node */, /* script */, pattern ] = process.argv.filter (x => !x.startsWith ('--')) + , python2Folder = './python/ccxt/' + , python3Folder = './python/ccxt/async_support/' + , phpFolder = './php/' + , phpAsyncFolder = './php/async/' + , options = { python2Folder, python3Folder, phpFolder, phpAsyncFolder } createFolderRecursively (python2Folder) createFolderRecursively (python3Folder) createFolderRecursively (phpFolder) + createFolderRecursively (phpAsyncFolder) //* - const classes = this.transpileDerivedExchangeFiles ('./js/', options, pattern) + const classes = this.transpileDerivedExchangeFiles ('./js/', options, pattern, force) if (classes === null) { log.bright.yellow ('0 files transpiled.') @@ -1457,6 +1559,10 @@ class Transpiler { this.transpilePythonAsyncToSync () + this.transpilePhpAsyncToSync () + + this.transpilePhpBaseClassMethods () + log.bright.green ('Transpiled successfully.') } } @@ -1469,12 +1575,14 @@ if (require.main === module) { // called directly like `node module` const transpiler = new Transpiler () const test = process.argv.includes ('--test') || process.argv.includes ('--tests') const errors = process.argv.includes ('--error') || process.argv.includes ('--errors') + const force = process.argv.includes ('--force') + log.bright.green ({ force }) if (test) { transpiler.transpileTests () } else if (errors) { transpiler.transpileErrorHierarchy () } else { - transpiler.transpileEverything () + transpiler.transpileEverything (force) } } else { // if required as a module diff --git a/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/build/vss.js b/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/build/vss.js index 24db17ce1..0d98e3c07 100644 --- a/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/build/vss.js +++ b/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/build/vss.js @@ -52,6 +52,8 @@ function vssEverything () { vss ('./ccxt.js', "const version = '{version}'", version) vss ('./php/base/Exchange.php', "$version = '{version}'", version) + vss ('./php/async/base/Exchange.php', "VERSION = '{version}'", version) + vss ('./php/async/base/Exchange.php', "$version = '{version}'", version) vss ('./php/base/Exchange.php', "VERSION = '{version}'", version) vss ('./python/ccxt/__init__.py', "__version__ = '{version}'", version) vss ('./python/ccxt/base/exchange.py', "__version__ = '{version}'", version) diff --git a/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/ccxt.d.ts b/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/ccxt.d.ts index eae728f4c..823f7825b 100644 --- a/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/ccxt.d.ts +++ b/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/ccxt.d.ts @@ -56,16 +56,21 @@ declare module 'ccxt' { symbol: string; base: string; quote: string; - baseId: string, - quoteId: string, + baseId: string; + quoteId: string; + type?: string; + spot?: boolean; + margin?: boolean; + swap?: boolean; + future?: boolean; active: boolean; precision: { base: number, quote: number, amount: number, price: number }; limits: { amount: MinMax, price: MinMax, cost?: MinMax }; - tierBased: boolean, - percentage: boolean, - taker: number, - maker: number, - info: any, + tierBased: boolean; + percentage: boolean; + taker: number; + maker: number; + info: any; } export interface Order { @@ -417,9 +422,9 @@ declare module 'ccxt' { /* tslint:disable */ + export class aax extends Exchange {} export class acx extends Exchange {} export class aofex extends Exchange {} - export class bcex extends Exchange {} export class bequant extends hitbtc {} export class bibox extends Exchange {} export class bigone extends Exchange {} @@ -458,6 +463,7 @@ declare module 'ccxt' { export class bw extends Exchange {} export class bybit extends Exchange {} export class bytetrade extends Exchange {} + export class cdax extends huobipro {} export class cex extends Exchange {} export class chilebit extends foxbit {} export class coinbase extends Exchange {} @@ -475,9 +481,11 @@ declare module 'ccxt' { export class coinspot extends Exchange {} export class crex24 extends Exchange {} export class currencycom extends Exchange {} + export class delta extends Exchange {} export class deribit extends Exchange {} export class digifinex extends Exchange {} export class dsx extends Exchange {} + export class equos extends Exchange {} export class eterbase extends Exchange {} export class exmo extends Exchange {} export class exx extends Exchange {} @@ -488,12 +496,12 @@ declare module 'ccxt' { export class ftx extends Exchange {} export class gateio extends Exchange {} export class gemini extends Exchange {} + export class gopax extends Exchange {} export class hbtc extends Exchange {} export class hitbtc extends Exchange {} export class hollaex extends Exchange {} export class huobijp extends huobipro {} export class huobipro extends Exchange {} - export class huobiru extends huobipro {} export class ice3x extends Exchange {} export class idex extends Exchange {} export class independentreserve extends Exchange {} @@ -506,11 +514,11 @@ declare module 'ccxt' { export class latoken extends Exchange {} export class lbank extends Exchange {} export class liquid extends Exchange {} - export class livecoin extends Exchange {} export class luno extends Exchange {} export class lykke extends Exchange {} export class mercado extends Exchange {} export class mixcoins extends Exchange {} + export class ndax extends Exchange {} export class novadax extends Exchange {} export class oceanex extends Exchange {} export class okcoin extends okex {} @@ -543,4 +551,132 @@ declare module 'ccxt' { /* tslint:enable */ + export type ExchangeId = + | 'aax' + | 'acx' + | 'aofex' + | 'bequant' + | 'bibox' + | 'bigone' + | 'binance' + | 'binanceus' + | 'bit2c' + | 'bitbank' + | 'bitbay' + | 'bitcoincom' + | 'bitfinex' + | 'bitfinex2' + | 'bitflyer' + | 'bitforex' + | 'bitget' + | 'bithumb' + | 'bitkk' + | 'bitmart' + | 'bitmax' + | 'bitmex' + | 'bitpanda' + | 'bitso' + | 'bitstamp' + | 'bitstamp1' + | 'bittrex' + | 'bitvavo' + | 'bitz' + | 'bl3p' + | 'bleutrade' + | 'braziliex' + | 'btcalpha' + | 'btcbox' + | 'btcmarkets' + | 'btctradeua' + | 'btcturk' + | 'buda' + | 'bw' + | 'bybit' + | 'bytetrade' + | 'cdax' + | 'cex' + | 'chilebit' + | 'coinbase' + | 'coinbaseprime' + | 'coinbasepro' + | 'coincheck' + | 'coinegg' + | 'coinex' + | 'coinfalcon' + | 'coinfloor' + | 'coingi' + | 'coinmarketcap' + | 'coinmate' + | 'coinone' + | 'coinspot' + | 'crex24' + | 'currencycom' + | 'delta' + | 'deribit' + | 'digifinex' + | 'dsx' + | 'equos' + | 'eterbase' + | 'exmo' + | 'exx' + | 'fcoin' + | 'fcoinjp' + | 'flowbtc' + | 'foxbit' + | 'ftx' + | 'gateio' + | 'gemini' + | 'gopax' + | 'hbtc' + | 'hitbtc' + | 'hollaex' + | 'huobijp' + | 'huobipro' + | 'ice3x' + | 'idex' + | 'independentreserve' + | 'indodax' + | 'itbit' + | 'kraken' + | 'kucoin' + | 'kuna' + | 'lakebtc' + | 'latoken' + | 'lbank' + | 'liquid' + | 'luno' + | 'lykke' + | 'mercado' + | 'mixcoins' + | 'ndax' + | 'novadax' + | 'oceanex' + | 'okcoin' + | 'okex' + | 'paymium' + | 'phemex' + | 'poloniex' + | 'probit' + | 'qtrade' + | 'rightbtc' + | 'ripio' + | 'southxchange' + | 'stex' + | 'surbitcoin' + | 'therock' + | 'tidebit' + | 'tidex' + | 'timex' + | 'upbit' + | 'vaultoro' + | 'vbtc' + | 'vcc' + | 'wavesexchange' + | 'whitebit' + | 'xbtce' + | 'xena' + | 'yobit' + | 'zaif' + | 'zb' + } diff --git a/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/ccxt.js b/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/ccxt.js index ca416bfae..1d5c72642 100644 --- a/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/ccxt.js +++ b/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/ccxt.js @@ -35,16 +35,16 @@ const Exchange = require ('./js/base/Exchange') //----------------------------------------------------------------------------- // this is updated by vss.js when building -const version = '1.38.75' +const version = '1.42.77' Exchange.ccxtVersion = version //----------------------------------------------------------------------------- const exchanges = { + 'aax': require ('./js/aax.js'), 'acx': require ('./js/acx.js'), 'aofex': require ('./js/aofex.js'), - 'bcex': require ('./js/bcex.js'), 'bequant': require ('./js/bequant.js'), 'bibox': require ('./js/bibox.js'), 'bigone': require ('./js/bigone.js'), @@ -83,6 +83,7 @@ const exchanges = { 'bw': require ('./js/bw.js'), 'bybit': require ('./js/bybit.js'), 'bytetrade': require ('./js/bytetrade.js'), + 'cdax': require ('./js/cdax.js'), 'cex': require ('./js/cex.js'), 'chilebit': require ('./js/chilebit.js'), 'coinbase': require ('./js/coinbase.js'), @@ -100,9 +101,11 @@ const exchanges = { 'coinspot': require ('./js/coinspot.js'), 'crex24': require ('./js/crex24.js'), 'currencycom': require ('./js/currencycom.js'), + 'delta': require ('./js/delta.js'), 'deribit': require ('./js/deribit.js'), 'digifinex': require ('./js/digifinex.js'), 'dsx': require ('./js/dsx.js'), + 'equos': require ('./js/equos.js'), 'eterbase': require ('./js/eterbase.js'), 'exmo': require ('./js/exmo.js'), 'exx': require ('./js/exx.js'), @@ -113,12 +116,12 @@ const exchanges = { 'ftx': require ('./js/ftx.js'), 'gateio': require ('./js/gateio.js'), 'gemini': require ('./js/gemini.js'), + 'gopax': require ('./js/gopax.js'), 'hbtc': require ('./js/hbtc.js'), 'hitbtc': require ('./js/hitbtc.js'), 'hollaex': require ('./js/hollaex.js'), 'huobijp': require ('./js/huobijp.js'), 'huobipro': require ('./js/huobipro.js'), - 'huobiru': require ('./js/huobiru.js'), 'ice3x': require ('./js/ice3x.js'), 'idex': require ('./js/idex.js'), 'independentreserve': require ('./js/independentreserve.js'), @@ -131,11 +134,11 @@ const exchanges = { 'latoken': require ('./js/latoken.js'), 'lbank': require ('./js/lbank.js'), 'liquid': require ('./js/liquid.js'), - 'livecoin': require ('./js/livecoin.js'), 'luno': require ('./js/luno.js'), 'lykke': require ('./js/lykke.js'), 'mercado': require ('./js/mercado.js'), 'mixcoins': require ('./js/mixcoins.js'), + 'ndax': require ('./js/ndax.js'), 'novadax': require ('./js/novadax.js'), 'oceanex': require ('./js/oceanex.js'), 'okcoin': require ('./js/okcoin.js'), diff --git a/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/cleanup.sh b/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/cleanup.sh new file mode 100644 index 000000000..0dc60ed78 --- /dev/null +++ b/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/cleanup.sh @@ -0,0 +1,2 @@ +#!/bin/bash +git checkout HEAD package.json README.md ccxt.d.ts ccxt.js wiki python php dist doc diff --git a/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/dist/ccxt.browser.js b/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/dist/ccxt.browser.js index 6e6c398a4..e8b439fb1 100644 --- a/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/dist/ccxt.browser.js +++ b/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/dist/ccxt.browser.js @@ -43,16 +43,16 @@ const Exchange = require ('./js/base/Exchange') //----------------------------------------------------------------------------- // this is updated by vss.js when building -const version = '1.38.75' +const version = '1.42.77' Exchange.ccxtVersion = version //----------------------------------------------------------------------------- const exchanges = { + 'aax': require ('./js/aax.js'), 'acx': require ('./js/acx.js'), 'aofex': require ('./js/aofex.js'), - 'bcex': require ('./js/bcex.js'), 'bequant': require ('./js/bequant.js'), 'bibox': require ('./js/bibox.js'), 'bigone': require ('./js/bigone.js'), @@ -91,6 +91,7 @@ const exchanges = { 'bw': require ('./js/bw.js'), 'bybit': require ('./js/bybit.js'), 'bytetrade': require ('./js/bytetrade.js'), + 'cdax': require ('./js/cdax.js'), 'cex': require ('./js/cex.js'), 'chilebit': require ('./js/chilebit.js'), 'coinbase': require ('./js/coinbase.js'), @@ -108,9 +109,11 @@ const exchanges = { 'coinspot': require ('./js/coinspot.js'), 'crex24': require ('./js/crex24.js'), 'currencycom': require ('./js/currencycom.js'), + 'delta': require ('./js/delta.js'), 'deribit': require ('./js/deribit.js'), 'digifinex': require ('./js/digifinex.js'), 'dsx': require ('./js/dsx.js'), + 'equos': require ('./js/equos.js'), 'eterbase': require ('./js/eterbase.js'), 'exmo': require ('./js/exmo.js'), 'exx': require ('./js/exx.js'), @@ -121,12 +124,12 @@ const exchanges = { 'ftx': require ('./js/ftx.js'), 'gateio': require ('./js/gateio.js'), 'gemini': require ('./js/gemini.js'), + 'gopax': require ('./js/gopax.js'), 'hbtc': require ('./js/hbtc.js'), 'hitbtc': require ('./js/hitbtc.js'), 'hollaex': require ('./js/hollaex.js'), 'huobijp': require ('./js/huobijp.js'), 'huobipro': require ('./js/huobipro.js'), - 'huobiru': require ('./js/huobiru.js'), 'ice3x': require ('./js/ice3x.js'), 'idex': require ('./js/idex.js'), 'independentreserve': require ('./js/independentreserve.js'), @@ -139,11 +142,11 @@ const exchanges = { 'latoken': require ('./js/latoken.js'), 'lbank': require ('./js/lbank.js'), 'liquid': require ('./js/liquid.js'), - 'livecoin': require ('./js/livecoin.js'), 'luno': require ('./js/luno.js'), 'lykke': require ('./js/lykke.js'), 'mercado': require ('./js/mercado.js'), 'mixcoins': require ('./js/mixcoins.js'), + 'ndax': require ('./js/ndax.js'), 'novadax': require ('./js/novadax.js'), 'oceanex': require ('./js/oceanex.js'), 'okcoin': require ('./js/okcoin.js'), @@ -181,7 +184,1793 @@ module.exports = Object.assign ({ version, Exchange, 'exchanges': Object.keys (e //----------------------------------------------------------------------------- -},{"./js/acx.js":3,"./js/aofex.js":4,"./js/base/Exchange":5,"./js/base/errors":7,"./js/base/functions":8,"./js/bcex.js":19,"./js/bequant.js":20,"./js/bibox.js":21,"./js/bigone.js":22,"./js/binance.js":23,"./js/binanceus.js":24,"./js/bit2c.js":25,"./js/bitbank.js":26,"./js/bitbay.js":27,"./js/bitcoincom.js":28,"./js/bitfinex.js":29,"./js/bitfinex2.js":30,"./js/bitflyer.js":31,"./js/bitforex.js":32,"./js/bitget.js":33,"./js/bithumb.js":34,"./js/bitkk.js":35,"./js/bitmart.js":36,"./js/bitmax.js":37,"./js/bitmex.js":38,"./js/bitpanda.js":39,"./js/bitso.js":40,"./js/bitstamp.js":41,"./js/bitstamp1.js":42,"./js/bittrex.js":43,"./js/bitvavo.js":44,"./js/bitz.js":45,"./js/bl3p.js":46,"./js/bleutrade.js":47,"./js/braziliex.js":48,"./js/btcalpha.js":49,"./js/btcbox.js":50,"./js/btcmarkets.js":51,"./js/btctradeua.js":52,"./js/btcturk.js":53,"./js/buda.js":54,"./js/bw.js":55,"./js/bybit.js":56,"./js/bytetrade.js":57,"./js/cex.js":58,"./js/chilebit.js":59,"./js/coinbase.js":60,"./js/coinbaseprime.js":61,"./js/coinbasepro.js":62,"./js/coincheck.js":63,"./js/coinegg.js":64,"./js/coinex.js":65,"./js/coinfalcon.js":66,"./js/coinfloor.js":67,"./js/coingi.js":68,"./js/coinmarketcap.js":69,"./js/coinmate.js":70,"./js/coinone.js":71,"./js/coinspot.js":72,"./js/crex24.js":73,"./js/currencycom.js":74,"./js/deribit.js":75,"./js/digifinex.js":76,"./js/dsx.js":77,"./js/eterbase.js":78,"./js/exmo.js":79,"./js/exx.js":80,"./js/fcoin.js":81,"./js/fcoinjp.js":82,"./js/flowbtc.js":83,"./js/foxbit.js":84,"./js/ftx.js":85,"./js/gateio.js":86,"./js/gemini.js":87,"./js/hbtc.js":88,"./js/hitbtc.js":89,"./js/hollaex.js":90,"./js/huobijp.js":91,"./js/huobipro.js":92,"./js/huobiru.js":93,"./js/ice3x.js":94,"./js/idex.js":95,"./js/independentreserve.js":96,"./js/indodax.js":97,"./js/itbit.js":98,"./js/kraken.js":99,"./js/kucoin.js":100,"./js/kuna.js":101,"./js/lakebtc.js":102,"./js/latoken.js":103,"./js/lbank.js":104,"./js/liquid.js":105,"./js/livecoin.js":106,"./js/luno.js":107,"./js/lykke.js":108,"./js/mercado.js":109,"./js/mixcoins.js":110,"./js/novadax.js":111,"./js/oceanex.js":112,"./js/okcoin.js":113,"./js/okex.js":114,"./js/paymium.js":115,"./js/phemex.js":116,"./js/poloniex.js":117,"./js/probit.js":118,"./js/qtrade.js":119,"./js/rightbtc.js":120,"./js/ripio.js":121,"./js/southxchange.js":122,"./js/stex.js":163,"./js/surbitcoin.js":164,"./js/therock.js":165,"./js/tidebit.js":166,"./js/tidex.js":167,"./js/timex.js":168,"./js/upbit.js":169,"./js/vaultoro.js":170,"./js/vbtc.js":171,"./js/vcc.js":172,"./js/wavesexchange.js":173,"./js/whitebit.js":174,"./js/xbtce.js":175,"./js/xena.js":176,"./js/yobit.js":177,"./js/zaif.js":178,"./js/zb.js":179}],3:[function(require,module,exports){ +},{"./js/aax.js":3,"./js/acx.js":4,"./js/aofex.js":5,"./js/base/Exchange":6,"./js/base/errors":8,"./js/base/functions":9,"./js/bequant.js":20,"./js/bibox.js":21,"./js/bigone.js":22,"./js/binance.js":23,"./js/binanceus.js":24,"./js/bit2c.js":25,"./js/bitbank.js":26,"./js/bitbay.js":27,"./js/bitcoincom.js":28,"./js/bitfinex.js":29,"./js/bitfinex2.js":30,"./js/bitflyer.js":31,"./js/bitforex.js":32,"./js/bitget.js":33,"./js/bithumb.js":34,"./js/bitkk.js":35,"./js/bitmart.js":36,"./js/bitmax.js":37,"./js/bitmex.js":38,"./js/bitpanda.js":39,"./js/bitso.js":40,"./js/bitstamp.js":41,"./js/bitstamp1.js":42,"./js/bittrex.js":43,"./js/bitvavo.js":44,"./js/bitz.js":45,"./js/bl3p.js":46,"./js/bleutrade.js":47,"./js/braziliex.js":48,"./js/btcalpha.js":49,"./js/btcbox.js":50,"./js/btcmarkets.js":51,"./js/btctradeua.js":52,"./js/btcturk.js":53,"./js/buda.js":54,"./js/bw.js":55,"./js/bybit.js":56,"./js/bytetrade.js":57,"./js/cdax.js":58,"./js/cex.js":59,"./js/chilebit.js":60,"./js/coinbase.js":61,"./js/coinbaseprime.js":62,"./js/coinbasepro.js":63,"./js/coincheck.js":64,"./js/coinegg.js":65,"./js/coinex.js":66,"./js/coinfalcon.js":67,"./js/coinfloor.js":68,"./js/coingi.js":69,"./js/coinmarketcap.js":70,"./js/coinmate.js":71,"./js/coinone.js":72,"./js/coinspot.js":73,"./js/crex24.js":74,"./js/currencycom.js":75,"./js/delta.js":76,"./js/deribit.js":77,"./js/digifinex.js":78,"./js/dsx.js":79,"./js/equos.js":80,"./js/eterbase.js":81,"./js/exmo.js":82,"./js/exx.js":83,"./js/fcoin.js":84,"./js/fcoinjp.js":85,"./js/flowbtc.js":86,"./js/foxbit.js":87,"./js/ftx.js":88,"./js/gateio.js":89,"./js/gemini.js":90,"./js/gopax.js":91,"./js/hbtc.js":92,"./js/hitbtc.js":93,"./js/hollaex.js":94,"./js/huobijp.js":95,"./js/huobipro.js":96,"./js/ice3x.js":97,"./js/idex.js":98,"./js/independentreserve.js":99,"./js/indodax.js":100,"./js/itbit.js":101,"./js/kraken.js":102,"./js/kucoin.js":103,"./js/kuna.js":104,"./js/lakebtc.js":105,"./js/latoken.js":106,"./js/lbank.js":107,"./js/liquid.js":108,"./js/luno.js":109,"./js/lykke.js":110,"./js/mercado.js":111,"./js/mixcoins.js":112,"./js/ndax.js":113,"./js/novadax.js":114,"./js/oceanex.js":115,"./js/okcoin.js":116,"./js/okex.js":117,"./js/paymium.js":118,"./js/phemex.js":119,"./js/poloniex.js":120,"./js/probit.js":121,"./js/qtrade.js":122,"./js/rightbtc.js":123,"./js/ripio.js":124,"./js/southxchange.js":125,"./js/stex.js":166,"./js/surbitcoin.js":167,"./js/therock.js":168,"./js/tidebit.js":169,"./js/tidex.js":170,"./js/timex.js":171,"./js/upbit.js":172,"./js/vaultoro.js":173,"./js/vbtc.js":174,"./js/vcc.js":175,"./js/wavesexchange.js":176,"./js/whitebit.js":177,"./js/xbtce.js":178,"./js/xena.js":179,"./js/yobit.js":180,"./js/zaif.js":181,"./js/zb.js":182}],3:[function(require,module,exports){ +'use strict'; + +// ---------------------------------------------------------------------------- + +const Exchange = require ('./base/Exchange'); +const { ArgumentsRequired, AuthenticationError, ExchangeError, ExchangeNotAvailable, OrderNotFound, InvalidOrder, CancelPending, RateLimitExceeded, InsufficientFunds, BadRequest, BadSymbol, PermissionDenied } = require ('./base/errors'); +const { TICK_SIZE } = require ('./base/functions/number'); + +// ---------------------------------------------------------------------------- + +module.exports = class aax extends Exchange { + describe () { + return this.deepExtend (super.describe (), { + 'id': 'aax', + 'name': 'AAX', + 'countries': [ 'MT' ], // Malta + 'enableRateLimit': true, + 'rateLimit': 500, + 'version': 'v2', + 'hostname': 'aaxpro.com', // aax.com + 'certified': true, + 'has': { + 'cancelAllOrders': true, + 'cancelOrder': true, + 'createOrder': true, + 'editOrder': true, + 'fetchBalance': true, + 'fetchCanceledOrders': true, + 'fetchClosedOrders': true, + 'fetchDepositAddress': true, + 'fetchMarkets': true, + 'fetchMyTrades': true, + 'fetchOHLCV': true, + 'fetchOpenOrders': true, + 'fetchOrder': true, + 'fetchOrderBook': true, + 'fetchOrders': true, + 'fetchTicker': 'emulated', + 'fetchTickers': true, + 'fetchTrades': true, + }, + 'timeframes': { + '1m': '1m', + '5m': '5m', + '15m': '15m', + '30m': '30m', + '1h': '1h', + '2h': '2h', + '4h': '4h', + '12h': '12h', + '1d': '1d', + '3d': '3d', + '1w': '1w', + }, + 'urls': { + 'logo': 'https://user-images.githubusercontent.com/1294454/104140087-a27f2580-53c0-11eb-87c1-5d9e81208fe9.jpg', + 'test': { + 'v1': 'https://api.testnet.{hostname}/marketdata/v1', + 'public': 'https://api.testnet.{hostname}', + 'private': 'https://api.testnet.{hostname}', + }, + 'api': { + 'v1': 'https://api.{hostname}/marketdata/v1', + 'public': 'https://api.{hostname}', + 'private': 'https://api.{hostname}', + }, + 'www': 'https://www.aaxpro.com', // string website URL + 'doc': 'https://www.aaxpro.com/apidoc/index.html', + 'fees': 'https://www.aaxpro.com/en-US/fees/', + 'referral': 'https://www.aaxpro.com/invite/sign-up?inviteCode=JXGm5Fy7R2MB', + }, + 'api': { + 'v1': { + 'get': [ + 'getHistMarketData', // Get OHLC k line of specific market + ], + }, + 'public': { + // these endpoints are not documented + // 'get': [ + // 'order_book', // Get the order book of specified market + // 'order_book/{market}', + // 'trades', // Get recent trades on market, each trade is included only once Trades are sorted in reverse creation order. + // 'trades/{market}', + // 'tickers', // Get ticker of all markets + // 'tickers/{market}', // Get ticker of specific market + // ], + 'get': [ + 'announcement/maintenance', // System Maintenance Notice + 'instruments', // Retrieve all trading pairs information + 'market/orderbook', // Order Book + 'futures/position/openInterest', // Open Interest + 'market/tickers', // Get the Last 24h Market Summary + 'market/candles', // Get Current Candlestick + 'market/history/candles', // Get Current Candlestick + 'market/trades', // Get the Most Recent Trades + 'market/markPrice', // Get Current Mark Price + 'futures/funding/predictedFunding/{symbol}', // Get Predicted Funding Rate + 'futures/funding/prevFundingRate/{symbol}', // Get Last Funding Rate + 'market/candles/index', // Get Current Index Candlestick + ], + }, + 'private': { + 'get': [ + 'user/info', // Retrieve user information + 'account/balances', // Get Account Balances + 'account/deposit/address', // undocumented + 'spot/trades', // Retrieve trades details for a spot order + 'spot/openOrders', // Retrieve spot open orders + 'spot/orders', // Retrieve historical spot orders + 'futures/position', // Get positions for all contracts + 'futures/position/closed', // Get closed positions + 'futures/trades', // Retrieve trade details for a futures order + 'futures/openOrders', // Retrieve futures open orders + 'futures/orders', // Retrieve historical futures orders + 'futures/funding/predictedFundingFee/{symbol}', // Get predicted funding fee + ], + 'post': [ + 'account/transfer', // Asset Transfer + 'spot/orders', // Create a new spot order + 'spot/orders/cancelAllOnTimeout', // Automatically cancel all your spot orders after a specified timeout. + 'futures/orders', // Create a new futures order + 'futures/orders/cancelAllOnTimeout', // Automatically cancel all your futures orders after a specified timeout. + 'futures/position/sltp', // Set take profit and stop loss orders for an opening position + 'futures/position/close', // Close position + 'futures/position/leverage', // Update leverage for position + 'futures/position/margin', // Modify Isolated Position Margin + ], + 'put': [ + 'spot/orders', // Amend spot order + 'futures/orders', // Amend the quantity of an open futures order + ], + 'delete': [ + 'spot/orders/cancel/{orderID}', // Cancel a spot order + 'spot/orders/cancel/all', // Batch cancel spot orders + 'futures/orders/cancel/{orderID}', // Cancel a futures order + 'futures/orders/cancel/all', // Batch cancel futures orders + ], + }, + }, + 'fees': { + 'trading': { + 'tierBased': false, + 'percentage': true, + 'maker': 0.06 / 100, + 'taker': 0.10 / 100, + }, + 'funding': { + 'tierBased': false, + 'percentage': true, + 'withdraw': {}, // There is only 1% fee on withdrawals to your bank account. + }, + }, + 'commonCurrencies': { + 'XBT': 'XBT', + }, + 'exceptions': { + 'exact': { + '2002': InsufficientFunds, + '2003': OrderNotFound, + '10003': BadRequest, // Parameter validation error + '10006': AuthenticationError, // Session expired, please relogin + '10007': AuthenticationError, // Invalid authentication key or token + '11007': AuthenticationError, // Invalid key format + '20001': InsufficientFunds, // Insufficient balance. Please deposit to trade. + '20009': InvalidOrder, // Order amount must be positive + '30000': OrderNotFound, // {"code":30000,"data":null,"message":"The order does not exist","ts":1610259732263} + '30001': InvalidOrder, // The order is being submitted, please try again later + '30004': InvalidOrder, // Minimum quantity is {0} + '30005': InvalidOrder, // Quantity maximum precision is {0} decimal places + '30006': InvalidOrder, // Price maximum precision is {0} decimal places + '30007': InvalidOrder, // Minimum price is {0} + '30008': InvalidOrder, // Stop price maximum precision is {0} decimal places + '30009': InvalidOrder, // Stop Price cannot be less than {0} + '30010': InvalidOrder, // Market price cannot be empty + '30011': CancelPending, // The order is being cancelled, please wait. + '30012': BadRequest, // Unknown currency + '30013': BadSymbol, // Unknown symbol + '30014': OrderNotFound, // Futures order cannot be found + '30015': InvalidOrder, // This is not an open order and cannot modified + '30016': ExchangeError, // No position found + '30017': InvalidOrder, // The current close position is 0. It is recommended that you cancel the current order closing order. + '30018': InvalidOrder, // Order price cannot be greater than {0} + '30019': InvalidOrder, // Order quantity cannot be greater than {0} + '30020': InvalidOrder, // Order price must be a multiple of {0} + '30021': InvalidOrder, // Margin adjustement must be greater than 0 + '30022': InvalidOrder, // New quantity must be greater than filled quantity + '30023': InvalidOrder, // Order failed, please try again + '30024': InvalidOrder, // TimeInForce error, only GTC or IOC are allowed + '30025': InvalidOrder, // TimeInForce error, only GTC is allowed + '30026': InvalidOrder, // Quantity is not a multiple of {0} + '30027': InvalidOrder, // Close position failed, it is recommended that you cancel the current order and then close the position. + '30028': BadSymbol, // Symbol cannot be traded at this time + '30029': InvalidOrder, // Modified quantity or price cannot be empty + '30030': InvalidOrder, // Price cannot be specified for market orders + '30031': InvalidOrder, // Liquidation orders cannot be modified + '30032': InvalidOrder, // Leverage cannot be greater than {0} + '30033': InvalidOrder, // Leverage cannot be smaller than {0} + '30034': RateLimitExceeded, // The max number of open orders is {0}. To place a new order, please cancel a previous one + '30035': RateLimitExceeded, // The max number of {0} open orders is {1}. To place a new order, please cancel a previous one + '30036': ExchangeNotAvailable, // Liquidation is in progress, please try again later + '30037': InvalidOrder, // Once stop limit order triggered, stop price cannot be amended + '30038': ExchangeError, // The total value of your orders has exceeded the current risk limit. Please adjust the risk limit + '30039': InsufficientFunds, // Your risk limit has now been changed to {0}, your maximum leverage less than 1, please readjust accordingly + '30040': InvalidOrder, // Order status has changed, please try again later + '30041': InvalidOrder, // Liquidation orders cannot be cancelled + '30042': InvalidOrder, // Order cannot be placed as you will be breaching you max limit value of {1} BTC for {0} + '30043': InvalidOrder, // The risk limit cannot be less than 0 + '30044': BadRequest, // Timeout cannot be greater than 60 minutes + '30045': InvalidOrder, // Side is not valid, it should be BUY or SELL + '30046': InvalidOrder, // Order type is not valid, it should be MARKET or LIMIT or STOP-LIMIT or STOP + '30047': InvalidOrder, // The order is closed. Can't cancel + '30048': InvalidOrder, // Market orders cannot be modified + '30049': InvalidOrder, // The order is being modified, please wait + '30050': InvalidOrder, // Maximum 10 orders + '40004': BadRequest, // Requested resource doesn't exist + '40009': RateLimitExceeded, // Too many requests + '40102': AuthenticationError, // {"code":40102,"message":"Unauthorized(invalid key)"} + '40103': AuthenticationError, // {"code":40103,"message":"Unauthorized(invalid sign)"} + '40303': PermissionDenied, // {"code":40303,"message":"Forbidden(invalid scopes)"} + '41001': BadRequest, // Incorrect HTTP request + '41002': BadRequest, // Unsupported HTTP request method + '42001': ExchangeNotAvailable, // Duplicated data entry, please check and try again + '50001': ExchangeError, // Server side exception, please try again later + '50002': ExchangeError, // Server is busy, please try again later + }, + 'broad': {}, + }, + 'precisionMode': TICK_SIZE, + 'options': { + 'defaultType': 'spot', // 'spot', 'future' + }, + }); + } + + async fetchMarkets (params = {}) { + const response = await this.publicGetInstruments (params); + // + // { + // "code":1, + // "message":"success", + // "ts":1610159448962, + // "data":[ + // { + // "tickSize":"0.01", + // "lotSize":"1", + // "base":"BTC", + // "quote":"USDT", + // "minQuantity":"1.0000000000", + // "maxQuantity":"30000", + // "minPrice":"0.0100000000", + // "maxPrice":"999999.0000000000", + // "status":"readOnly", + // "symbol":"BTCUSDTFP", + // "code":"FP", + // "takerFee":"0.00040", + // "makerFee":"0.00020", + // "multiplier":"0.001000000000", + // "mmRate":"0.00500", + // "imRate":"0.01000", + // "type":"futures", + // "settleType":"Vanilla", + // "settleCurrency":"USDT" + // }, + // { + // "tickSize":"0.5", + // "lotSize":"10", + // "base":"BTC", + // "quote":"USD", + // "minQuantity":"10.0000000000", + // "maxQuantity":"300000", + // "minPrice":"0.5000000000", + // "maxPrice":"999999.0000000000", + // "status":"readOnly", + // "symbol":"BTCUSDFP", + // "code":"FP", + // "takerFee":"0.00040", + // "makerFee":"0.00020", + // "multiplier":"1.000000000000", + // "mmRate":"0.00500", + // "imRate":"0.01000", + // "type":"futures", + // "settleType":"Inverse", + // "settleCurrency":"BTC" + // }, + // { + // "tickSize":"0.0001", + // "lotSize":"0.01", + // "base":"AAB", + // "quote":"USDT", + // "minQuantity":"5.0000000000", + // "maxQuantity":"50000.0000000000", + // "minPrice":"0.0001000000", + // "maxPrice":"999999.0000000000", + // "status":"readOnly", + // "symbol":"AABUSDT", + // "code":null, + // "takerFee":"0.00100", + // "makerFee":"0.00100", + // "multiplier":"1.000000000000", + // "mmRate":"0.02500", + // "imRate":"0.05000", + // "type":"spot", + // "settleType":null, + // "settleCurrency":null + // }, + // ] + // } + // + const data = this.safeValue (response, 'data'); + const result = []; + for (let i = 0; i < data.length; i++) { + const market = data[i]; + const id = this.safeString (market, 'symbol'); + const baseId = this.safeString (market, 'base'); + const quoteId = this.safeString (market, 'quote'); + const base = this.safeCurrencyCode (baseId); + const quote = this.safeCurrencyCode (quoteId); + const status = this.safeString (market, 'status'); + const active = (status === 'enable'); + const taker = this.safeFloat (market, 'takerFee'); + const maker = this.safeFloat (market, 'makerFee'); + const type = this.safeString (market, 'type'); + let inverse = undefined; + let linear = undefined; + let quanto = undefined; + const spot = (type === 'spot'); + const futures = (type === 'futures'); + const settleType = this.safeStringLower (market, 'settleType'); + if (settleType !== undefined) { + inverse = (settleType === 'inverse'); + linear = (settleType === 'vanilla'); + quanto = (settleType === 'quanto'); + } + let symbol = id; + if (type === 'spot') { + symbol = base + '/' + quote; + } + const precision = { + 'amount': this.safeFloat (market, 'lotSize'), + 'price': this.safeFloat (market, 'tickSize'), + }; + result.push ({ + 'id': id, + 'symbol': symbol, + 'base': base, + 'quote': quote, + 'baseId': baseId, + 'quoteId': quoteId, + 'type': type, + 'spot': spot, + 'futures': futures, + 'inverse': inverse, + 'linear': linear, + 'quanto': quanto, + 'precision': precision, + 'info': market, + 'active': active, + 'taker': taker, + 'maker': maker, + 'percentage': false, + 'tierBased': true, + 'limits': { + 'amount': { + 'min': this.safeString (market, 'minQuantity'), + 'max': this.safeString (market, 'maxQuantity'), + }, + 'price': { + 'min': this.safeString (market, 'minPrice'), + 'max': this.safeString (market, 'maxPrice'), + }, + 'cost': { + 'min': undefined, + 'max': undefined, + }, + }, + }); + } + return result; + } + + parseTicker (ticker, market = undefined) { + // + // { + // "t":1610162685342, // timestamp + // "a":"0.00000000", // trading volume in USD in the last 24 hours, futures only + // "c":"435.20000000", // close + // "d":"4.22953489", // change + // "h":"455.04000000", // high + // "l":"412.78000000", // low + // "o":"417.54000000", // open + // "s":"BCHUSDTFP", // market id + // "v":"2031068.00000000", // trading volume in quote currency of last 24 hours + // } + // + const timestamp = this.safeInteger (ticker, 't'); + const marketId = this.safeString (ticker, 's'); + const symbol = this.safeSymbol (marketId, market); + const last = this.safeFloat (ticker, 'c'); + const open = this.safeFloat (ticker, 'o'); + let change = undefined; + let percentage = undefined; + let average = undefined; + if (last !== undefined && open !== undefined) { + change = last - open; + if (open > 0) { + percentage = change / open * 100; + } + average = this.sum (last, open) / 2; + } + const quoteVolume = this.safeFloat (ticker, 'v'); + return { + 'symbol': symbol, + 'timestamp': timestamp, + 'datetime': this.iso8601 (timestamp), + 'high': this.safeFloat (ticker, 'h'), + 'low': this.safeFloat (ticker, 'l'), + 'bid': undefined, + 'bidVolume': undefined, + 'ask': undefined, + 'askVolume': undefined, + 'vwap': undefined, + 'open': open, + 'close': last, + 'last': last, + 'previousClose': undefined, + 'change': change, + 'percentage': percentage, + 'average': average, + 'baseVolume': undefined, + 'quoteVolume': quoteVolume, + 'info': ticker, + }; + } + + async fetchTicker (symbol, params = {}) { + const tickers = await this.fetchTickers (undefined, params); + if (symbol in tickers) { + return tickers[symbol]; + } + throw new BadSymbol (this.id + ' fetchTicker() symbol ' + symbol + ' ticker not found'); + } + + async fetchTickers (symbols = undefined, params = {}) { + await this.loadMarkets (); + const response = await this.publicGetMarketTickers (params); + // + // { + // "e":"tickers", + // "t":1610162685342, + // "tickers":[ + // { + // "a":"0.00000000", + // "c":"435.20000000", + // "d":"4.22953489", + // "h":"455.04000000", + // "l":"412.78000000", + // "o":"417.54000000", + // "s":"BCHUSDTFP", + // "v":"2031068.00000000", + // }, + // ], + // } + // + const tickers = this.safeValue (response, 'tickers', []); + const result = []; + const timestamp = this.safeInteger (response, 't'); + for (let i = 0; i < tickers.length; i++) { + const ticker = this.parseTicker (this.extend (tickers[i], { 't': timestamp })); + result.push (ticker); + } + return this.filterByArray (result, 'symbol', symbols); + } + + async fetchOrderBook (symbol, limit = undefined, params = {}) { + await this.loadMarkets (); + const market = this.market (symbol); + if (limit === undefined) { + limit = 20; + } else { + if ((limit !== 20) && (limit !== 50)) { + throw new BadRequest (this.id + ' fetchOrderBook() limit argument must be undefined, 20 or 50'); + } + } + const request = { + 'symbol': market['id'], + 'level': limit, // required + }; + // + const response = await this.publicGetMarketOrderbook (this.extend (request, params)); + // + // { + // "asks":[ + // ["10823.00000000","0.004000"], + // ["10823.10000000","0.100000"], + // ["10823.20000000","0.010000"] + // ], + // "bids":[ + // ["10821.20000000","0.002000"], + // ["10821.10000000","0.005000"], + // ["10820.40000000","0.013000"] + // ], + // "e":"BTCUSDT@book_50", + // "t":1561543614756 + // } + // + const timestamp = this.safeInteger (response, 't'); // need unix type + return this.parseOrderBook (response, timestamp); + } + + parseTrade (trade, market = undefined) { + // + // public fetchTrades + // + // { + // "p":"9395.50000000", + // "q":"50.000000", + // "t":1592563996718 + // } + // + // private fetchMyTrades + // + // { + // "avgPrice":"1199.8", + // "base":"ETH", + // "clOrdID":null, + // "commission":"0.00002", + // "createTime":"2021-01-11T02:47:51.512Z", + // "cumQty":"0.02", + // "filledOrderID":"1eUD4F5rwK", + // "filledPrice":"1199.8", + // "filledQty":"0.02", + // "leavesQty":"0", + // "oCreateTime":"2021-01-11T02:47:51.377Z", + // "orderID":"1eUD4EHfdU", + // "orderQty":"0.02", + // "orderStatus":3, + // "orderType":1, + // "price":"1198.25", + // "quote":"USDT", + // "rejectCode":null, + // "rejectReason":null, + // "side":1, + // "stopPrice":"0", + // "symbol":"ETHUSDT", + // "taker":true, + // "tradeID":"E04WTIgfmULU", + // "transactTime":"2021-01-11T02:47:51.389Z", + // "updateTime":null, + // "userID":"1362494" + // } + // + let timestamp = this.safeInteger (trade, 't'); + if (timestamp === undefined) { + timestamp = this.parse8601 (this.safeString (trade, 'createTime')); + } + const id = this.safeString2 (trade, 'tid', 'tradeID'); + let symbol = undefined; + const marketId = this.safeString (trade, 'symbol'); + market = this.safeMarket (marketId, market); + if (market !== undefined) { + symbol = market['symbol']; + } + let price = this.safeFloat2 (trade, 'p', 'filledPrice'); + const amount = this.safeFloat2 (trade, 'q', 'filledQty'); + const orderId = this.safeString (trade, 'orderID'); + const isTaker = this.safeValue (trade, 'taker'); + let takerOrMaker = undefined; + if (isTaker !== undefined) { + takerOrMaker = isTaker ? 'taker' : 'maker'; + } + let side = this.safeString (trade, 'side'); + if (side === '1') { + side = 'buy'; + } else if (side === '2') { + side = 'sell'; + } + if (side === undefined) { + side = (price > 0) ? 'buy' : 'sell'; + } + side = (price > 0) ? 'buy' : 'sell'; + price = Math.abs (price); + let cost = undefined; + if ((price !== undefined) && (amount !== undefined)) { + cost = price * amount; + } + const orderType = this.parseOrderType (this.safeString (trade, 'orderType')); + let fee = undefined; + const feeCost = this.safeFloat (trade, 'commission'); + if (feeCost !== undefined) { + let feeCurrency = undefined; + if (market !== undefined) { + if (side === 'buy') { + feeCurrency = market['base']; + } else if (side === 'sell') { + feeCurrency = market['quote']; + } + } + fee = { + 'currency': feeCurrency, + 'cost': feeCost, + }; + } + return { + 'info': trade, + 'id': id, + 'timestamp': timestamp, + 'datetime': this.iso8601 (timestamp), + 'symbol': symbol, + 'type': orderType, + 'side': side, + 'order': orderId, + 'takerOrMaker': takerOrMaker, + 'price': price, + 'amount': amount, + 'cost': cost, + 'fee': fee, + }; + } + + async fetchTrades (symbol, since = undefined, limit = undefined, params = {}) { + await this.loadMarkets (); + const market = this.market (symbol); + limit = (limit === undefined) ? 2000 : limit; + limit = Math.min (limit, 2000); + const request = { + 'symbol': market['id'], + 'limit': limit, + }; + const response = await this.publicGetMarketTrades (request); + // + // { + // "e":"BTCUSDFP@trades", + // "trades": [ + // {"p":"9395.50000000","q":"50.000000","t":1592563996718}, + // {"p":"9395.50000000","q":"50.000000","t":1592563993577}, + // ], + // } + // + const trades = this.safeValue (response, 'trades', []); + return this.parseTrades (trades, market, since, limit); + } + + parseOHLCV (ohlcv, market = undefined) { + // + // [ + // 0.042398, // 0 open + // 0.042684, // 1 high + // 0.042366, // 2 low + // 0.042386, // 3 close + // 0.93734243, // 4 volume + // 1611514800, // 5 timestamp + // ] + // + return [ + this.safeTimestamp (ohlcv, 5), + this.safeFloat (ohlcv, 0), + this.safeFloat (ohlcv, 1), + this.safeFloat (ohlcv, 2), + this.safeFloat (ohlcv, 3), + this.safeFloat (ohlcv, 4), + ]; + } + + async fetchOHLCV (symbol, timeframe = '1h', since = undefined, limit = undefined, params = {}) { + await this.loadMarkets (); + const market = this.market (symbol); + const request = { + // 'limit': limit, // if set counts from now into the past + 'symbol': market['id'], + 'timeFrame': this.timeframes[timeframe], + }; + limit = (limit === undefined) ? 500 : limit; + const duration = this.parseTimeframe (timeframe); + if (since === undefined) { + const end = this.seconds (); + request['start'] = end - duration * limit; + request['end'] = end; + } else { + const start = parseInt (since / 1000); + request['start'] = start; + request['end'] = this.sum (start, duration * limit); + } + const response = await this.publicGetMarketHistoryCandles (this.extend (request, params)); + // + // { + // "data":[ + // [0.042398,0.042684,0.042366,0.042386,0.93734243,1611514800], + // [0.042386,0.042602,0.042234,0.042373,1.01925239,1611518400], + // [0.042373,0.042558,0.042362,0.042389,0.93801705,1611522000], + // ], + // "success":true, + // "t":1611875157 + // } + // + const data = this.safeValue (response, 'data', []); + return this.parseOHLCVs (data, market, timeframe, since, limit); + } + + async fetchBalance (params = {}) { + await this.loadMarkets (); + const defaultType = this.safeString2 (this.options, 'fetchBalance', 'defaultType', 'spot'); + const type = this.safeString (params, 'type', defaultType); + const types = { + 'spot': 'SPTP', + 'future': 'FUTP', + 'otc': 'F2CP', + 'saving': 'VLTP', + }; + const purseType = this.safeString (types, type, type); + const request = { + 'purseType': purseType, + }; + params = this.omit (params, 'type'); + const response = await this.privateGetAccountBalances (this.extend (request, params)); + // + // { + // "code":1, + // "data":[ + // { + // "purseType":"FUTP", + // "currency":"BTC", + // "available":"0.41000000", + // "unavailable":"0.00000000" + // }, + // { + // "purseType":"FUTP", + // "currency":"USDT", + // "available":"0.21000000", + // "unvaliable":"0.00000000" + // } + // ] + // "message":"success", + // "ts":1573530401020 + // } + // + const data = this.safeValue (response, 'data'); + const result = { 'info': response }; + for (let i = 0; i < data.length; i++) { + const balance = data[i]; + const balanceType = this.safeString (balance, 'purseType'); + if (balanceType === purseType) { + const currencyId = this.safeString (balance, 'currency'); + const code = this.safeCurrencyCode (currencyId); + const account = this.account (); + account['free'] = this.safeFloat (balance, 'available'); + account['used'] = this.safeFloat (balance, 'unavailable'); + result[code] = account; + } + } + return this.parseBalance (result); + } + + async createOrder (symbol, type, side, amount, price = undefined, params = {}) { + let orderType = type.toUpperCase (); + const orderSide = side.toUpperCase (); + await this.loadMarkets (); + const market = this.market (symbol); + const request = { + // 'orderType': orderType, // MARKET, LIMIT, STOP, STOP-LIMIT + 'symbol': market['id'], + 'orderQty': this.amountToPrecision (symbol, amount), + 'side': orderSide, + // 'stopPrice': this.priceToPrecision (symbol, stopPrice), + // 'clOrdID': clientOrderId, // up to 20 chars, lowercase and uppercase letters only + // 'timeInForce': 'GTC', // GTC, IOC, FOK, default is GTC + // 'execInst': 'Post-Only', // the only value supported by the exchange, futures-only + }; + const timeInForce = this.safeString (params, 'timeInForce'); + if (timeInForce !== undefined) { + request['timeInForce'] = timeInForce; + params = this.omit (params, 'timeInForce'); + } + const clientOrderId = this.safeString2 (params, 'clOrdID', 'clientOrderId'); + if (clientOrderId !== undefined) { + request['clOrdID'] = clientOrderId; + params = this.omit (params, [ 'clOrdID', 'clientOrderId' ]); + } + const stopPrice = this.safeFloat (params, 'stopPrice'); + if (stopPrice === undefined) { + if ((orderType === 'STOP-LIMIT') || (orderType === 'STOP')) { + throw new ArgumentsRequired (this.id + ' createOrder() requires a stopPrice parameter for ' + orderType + ' orders'); + } + } else { + if (orderType === 'LIMIT') { + orderType = 'STOP-LIMIT'; + } else if (orderType === 'MARKET') { + orderType = 'STOP'; + } + request['stopPrice'] = this.priceToPrecision (symbol, stopPrice); + params = this.omit (params, 'stopPrice'); + } + if (orderType === 'LIMIT' || orderType === 'STOP-LIMIT') { + request['price'] = this.priceToPrecision (symbol, price); + } + request['orderType'] = orderType; + let method = undefined; + if (market['spot']) { + method = 'privatePostSpotOrders'; + } else if (market['futures']) { + method = 'privatePostFuturesOrders'; + } + const response = await this[method] (this.extend (request, params)); + // + // spot + // + // { + // "code":1, + // "data":{ + // "symbol":"ETHUSDT", + // "orderType":2, + // "avgPrice":"0", + // "execInst":null, + // "orderStatus":0, + // "userID":"1362494", + // "quote":"USDT", + // "rejectReason":null, + // "rejectCode":null, + // "price":"1500", + // "orderQty":"1", + // "commission":"0", + // "id":"268323430253735936", + // "timeInForce":1, + // "isTriggered":false, + // "side":2, + // "orderID":"1eO51MDSpQ", + // "leavesQty":"0", + // "cumQty":"0", + // "updateTime":null, + // "lastQty":"0", + // "clOrdID":null, + // "stopPrice":null, + // "createTime":null, + // "transactTime":null, + // "base":"ETH", + // "lastPrice":"0" + // }, + // "message":"success", + // "ts":1610245290980 + // } + // + // futures + // + // { + // "code":1, + // "data":{ + // "liqType":0, + // "symbol":"ETHUSDTFP", + // "orderType":2, + // "leverage":"1", + // "marketPrice":"1318.3150000000", + // "code":"FP", + // "avgPrice":"0", + // "execInst":null, + // "orderStatus":0, + // "userID":"1362494", + // "quote":"USDT", + // "rejectReason":null, + // "rejectCode":null, + // "price":"500", + // "orderQty":"1", + // "commission":"0", + // "id":"268346885133053953", + // "timeInForce":1, + // "isTriggered":false, + // "side":1, + // "orderID":"1eOuPUAAkq", + // "leavesQty":"1", + // "cumQty":"0", + // "updateTime":null, + // "lastQty":null, + // "clOrdID":null, + // "stopPrice":null, + // "createTime":null, + // "transactTime":null, + // "settleType":"VANILLA", + // "base":"ETH", + // "lastPrice":"0" + // }, + // "message":"success", + // "ts":1610250883059 + // } + // + const data = this.safeValue (response, 'data', {}); + return this.parseOrder (data, market); + } + + async editOrder (id, symbol, type, side, amount, price = undefined, params = {}) { + await this.loadMarkets (); + const market = this.market (symbol); + const request = { + 'orderID': id, + // 'orderQty': this.amountToPrecision (symbol, amount), + // 'price': this.priceToPrecision (symbol, price), + // 'stopPrice': this.priceToPrecision (symbol, stopPrice), + }; + const stopPrice = this.safeFloat (params, 'stopPrice'); + if (stopPrice !== undefined) { + request['stopPrice'] = this.priceToPrecision (symbol, stopPrice); + params = this.omit (params, 'stopPrice'); + } + if (price !== undefined) { + request['price'] = this.priceToPrecision (symbol, price); + } + if (amount !== undefined) { + request['orderQty'] = this.amountToPrecision (symbol, amount); + } + let method = undefined; + if (market['spot']) { + method = 'privatePutSpotOrders'; + } else if (market['futures']) { + method = 'privatePutFuturesOrders'; + } + const response = await this[method] (this.extend (request, params)); + // + // spot + // + // { + // "code":1, + // "data":{ + // "symbol":"ETHUSDT", + // "orderType":2, + // "avgPrice":"0", + // "execInst":null, + // "orderStatus":0, + // "userID":"1362494", + // "quote":"USDT", + // "rejectReason":null, + // "rejectCode":null, + // "price":"1500", + // "orderQty":"1", + // "commission":"0", + // "id":"268323430253735936", + // "timeInForce":1, + // "isTriggered":false, + // "side":2, + // "orderID":"1eO51MDSpQ", + // "leavesQty":"0", + // "cumQty":"0", + // "updateTime":null, + // "lastQty":"0", + // "clOrdID":null, + // "stopPrice":null, + // "createTime":null, + // "transactTime":null, + // "base":"ETH", + // "lastPrice":"0" + // }, + // "message":"success", + // "ts":1610245290980 + // } + // + // futures + // + // { + // "code":1, + // "data":{ + // "liqType":0, + // "symbol":"ETHUSDTFP", + // "orderType":2, + // "leverage":"1", + // "marketPrice":"1318.3150000000", + // "code":"FP", + // "avgPrice":"0", + // "execInst":null, + // "orderStatus":0, + // "userID":"1362494", + // "quote":"USDT", + // "rejectReason":null, + // "rejectCode":null, + // "price":"500", + // "orderQty":"1", + // "commission":"0", + // "id":"268346885133053953", + // "timeInForce":1, + // "isTriggered":false, + // "side":1, + // "orderID":"1eOuPUAAkq", + // "leavesQty":"1", + // "cumQty":"0", + // "updateTime":null, + // "lastQty":null, + // "clOrdID":null, + // "stopPrice":null, + // "createTime":null, + // "transactTime":null, + // "settleType":"VANILLA", + // "base":"ETH", + // "lastPrice":"0" + // }, + // "message":"success", + // "ts":1610250883059 + // } + // + const data = this.safeValue (response, 'data', {}); + return this.parseOrder (data, market); + } + + async cancelOrder (id, symbol = undefined, params = {}) { + await this.loadMarkets (); + const request = { + 'orderID': id, + }; + let method = undefined; + const defaultType = this.safeString2 (this.options, 'cancelOrder', 'defaultType', 'spot'); + let type = this.safeString (params, 'type', defaultType); + params = this.omit (params, 'type'); + let market = undefined; + if (symbol !== undefined) { + market = this.market (symbol); + type = market['type']; + } + if (type === 'spot') { + method = 'privateDeleteSpotOrdersCancelOrderID'; + } else if (type === 'futures') { + method = 'privateDeleteFuturesOrdersCancelOrderID'; + } + const response = await this[method] (this.extend (request, params)); + // + // spot + // + // { + // "code":1, + // "data":{ + // "avgPrice":"0", + // "base":"BTC", + // "clOrdID":"aax", + // "commission":"0", + // "createTime":"2019-11-12T03:46:41Z", + // "cumQty":"0", + // "id":"114330021504606208", + // "isTriggered":false, + // "lastPrice":"0", + // "lastQty":"0", + // "leavesQty":"0", + // "orderID":"wJ4L366KB", + // "orderQty":"0.05", + // "orderStatus":1, + // "orderType":2, + // "price":"8000", + // "quote":"USDT", + // "rejectCode":0, + // "rejectReason":null, + // "side":1, + // "stopPrice":"0", + // "symbol":"BTCUSDT", + // "transactTime":null, + // "updateTime":"2019-11-12T03:46:41Z", + // "timeInForce":1, + // "userID":"216214" + // }, + // "message":"success", + // "ts":1573530402029 + // } + // + // futures + // + // { + // "code":1, + // "data":{ + // "avgPrice":"0", + // "base":"BTC", + // "clOrdID":"aax_futures", + // "code":"FP", + // "commission":"0", + // "createTime":"2019-11-12T06:48:58Z", + // "cumQty":"0", + // "id":"114375893764395008", + // "isTriggered":false, + // "lastPrice":"0", + // "lastQty":null, + // "leavesQty":"300", + // "leverage":"1", + // "liqType":0, + // "marketPrice":"8760.75", + // "orderID":"wJTewQc81", + // "orderQty":"300", + // "orderStatus":1, + // "orderType":2, + // "price":"8000", + // "quote":"USD", + // "rejectCode":0, + // "rejectReason":null, + // "settleType":"INVERSE", + // "side":1, + // "stopPrice":"0", + // "symbol":"BTCUSDFP", + // "transactTime":"2019-11-12T06:48:58Z", + // "updateTime":"2019-11-12T06:48:58Z", + // "timeInForce":1, + // "execInst": "", + // "userID":"216214" + // }, + // "message":"success", + // "ts":1573541642970 + // } + // + const data = this.safeValue (response, 'data', {}); + return this.parseOrder (data, market); + } + + async cancelAllOrders (symbol = undefined, params = {}) { + if (symbol === undefined) { + throw new ArgumentsRequired (this.id + ' cancelAllOrders() requires a symbol argument'); + } + await this.loadMarkets (); + const market = this.market (symbol); + const request = { + 'symbol': market['id'], + }; + let method = undefined; + if (market['spot']) { + method = 'privateDeleteSpotOrdersCancelAll'; + } else if (market['futures']) { + method = 'privateDeleteFuturesOrdersCancelAll'; + } + const response = await this[method] (this.extend (request, params)); + // + // { + // "code":1, + // "data":[ + // "vBC9rXsEE", + // "vBCc46OI0" + // ], + // "message":"success", + // "ts":1572597435470 + // } + // + return response; + } + + async fetchOrder (id, symbol = undefined, params = {}) { + await this.loadMarkets (); + const defaultType = this.safeString2 (this.options, 'fetchOrder', 'defaultType', 'spot'); + params['type'] = this.safeString (params, 'type', defaultType); + const request = {}; + const clientOrderId = this.safeString2 (params, 'clOrdID', 'clientOrderId'); + if (clientOrderId === undefined) { + request['orderID'] = id; + } else { + request['clOrdID'] = clientOrderId; + params = this.omit (params, [ 'clOrdID', 'clientOrderId' ]); + } + const orders = await this.fetchOrders (symbol, undefined, undefined, this.extend (request, params)); + const order = this.safeValue (orders, 0); + if (order === undefined) { + if (clientOrderId === undefined) { + throw new OrderNotFound (this.id + ' fetchOrder() could not find order id ' + id); + } else { + throw new OrderNotFound (this.id + ' fetchOrder() could not find order clientOrderID ' + clientOrderId); + } + } + return order; + } + + async fetchOpenOrders (symbol = undefined, since = undefined, limit = undefined, params = {}) { + await this.loadMarkets (); + const request = { + // 'pageNum': '1', + // 'pageSize': '10', + // 'symbol': market['id'], + // 'orderID': id, + // 'side': 'undefined', // BUY, SELL + // 'clOrdID': clientOrderId, + }; + const defaultType = this.safeString2 (this.options, 'fetchOpenOrders', 'defaultType', 'spot'); + let type = this.safeString (params, 'type', defaultType); + params = this.omit (params, 'type'); + let market = undefined; + if (symbol !== undefined) { + market = this.market (symbol); + request['symbol'] = market['id']; + type = market['type']; + } + const clientOrderId = this.safeString2 (params, 'clOrdID', 'clientOrderId'); + if (clientOrderId !== undefined) { + request['clOrdID'] = clientOrderId; + params = this.omit (params, [ 'clOrdID', 'clientOrderId' ]); + } + let method = undefined; + if (type === 'spot') { + method = 'privateGetSpotOpenOrders'; + } else if (type === 'futures') { + method = 'privateGetFuturesOpenOrders'; + } + if (limit !== undefined) { + request['pageSize'] = limit; // default 10 + } + const response = await this[method] (this.extend (request, params)); + // + // spot + // + // { + // "code":1, + // "data":{ + // "total":19, + // "pageSize":10, + // "list":[ + // { + // "orderType":2, + // "symbol":"BTCUSDT", + // "avgPrice":"0", + // "orderStatus":0, + // "userID":"7225", + // "quote":"USDT", + // "rejectReason":null, + // "rejectCode":null, + // "price":"0", + // "orderQty":"0.002", + // "commission":"0", + // "id":"110419975166304256", + // "isTriggered":null, + // "side":1, + // "orderID":"vBGlDcLwk", + // "cumQty":"0", + // "leavesQty":"0", + // "updateTime":null, + // "clOrdID":"0001", + // "lastQty":"0", + // "stopPrice":"0", + // "createTime":"2019-11-01T08:49:33Z", + // "transactTime":null, + // "timeInForce":1, + // "base":"BTC", + // "lastPrice":"0" + // } + // ], + // "pageNum":1 + // }, + // "message":"success", + // "ts":1572598173682 + // } + // + // futures + // + // { + // "code":1, + // "data":{ + // "list":[ + // { + // "avgPrice":"8768.99999999484997", + // "base":"BTC", + // "clOrdID":null, + // "code":"FP", + // "commission":"0.00000913", + // "createTime":"2019-11-12T07:05:52.000Z, + // "cumQty":"100", + // "id":"114380149603028993", + // "isTriggered":false, + // "lastPrice":"8769", + // "lastQty":"100", + // "leavesQty":"0", + // "leverage":"1", + // "liqType":1, + // "marketPrice":"8769.75", + // "orderID":"wJXURIFBT", + // "orderQty":"100", + // "orderStatus":3, + // "orderType":1, + // "price":"8769.75", + // "quote":"USD", + // "rejectCode":0, + // "rejectReason":null, + // "settleType":"INVERSE", + // "side":2, + // "stopPrice":"0", + // "symbol":"BTCUSDFP", + // "transactTime":"2019-11-12T07:05:52.000Z, + // "updateTime":"2019-11-12T07:05:52.000Z, + // "timeInForce":1, + // "execInst": "", + // "userID":"216214" + // }, + // ], + // "pageNum":1, + // "pageSize":10, + // "total":21 + // }, + // "message":"success", + // "ts":1573546960172 + // } + // + const data = this.safeValue (response, 'data', {}); + const orders = this.safeValue (data, 'list', []); + return this.parseOrders (orders, market, since, limit); + } + + async fetchClosedOrders (symbol = undefined, since = undefined, limit = undefined, params = {}) { + const request = { + 'orderStatus': '2', // 1 new, 2 filled, 3 canceled + }; + return await this.fetchOrders (symbol, since, limit, this.extend (request, params)); + } + + async fetchCanceledOrders (symbol = undefined, since = undefined, limit = undefined, params = {}) { + const request = { + 'orderStatus': '3', // 1 new, 2 filled, 3 canceled + }; + return await this.fetchOrders (symbol, since, limit, this.extend (request, params)); + } + + async fetchOrders (symbol = undefined, since = undefined, limit = undefined, params = {}) { + await this.loadMarkets (); + const request = { + // 'pageNum': '1', + // 'pageSize': '10', + // 'symbol': market['id'], + // 'orderID': id, + // 'base': market['baseId'], + // 'quote': market['quoteId'], + // 'orderStatus': undefined, // 1 new, 2 filled, 3 canceled + // 'startDate': this.ymd (since), + // 'endDate': this.ymd (this.milliseconds()), + // 'orderType': undefined, // MARKET, LIMIT, STOP, STOP-LIMIT + // 'side': 'undefined', // BUY, SELL + // 'clOrdID': clientOrderId, + }; + let method = undefined; + const defaultType = this.safeString2 (this.options, 'fetchOrders', 'defaultType', 'spot'); + let type = this.safeString (params, 'type', defaultType); + params = this.omit (params, 'type'); + let market = undefined; + if (symbol !== undefined) { + market = this.market (symbol); + request['symbol'] = market['id']; + type = market['type']; + } + if (type === 'spot') { + method = 'privateGetSpotOrders'; + } else if (type === 'futures') { + method = 'privateGetFuturesOrders'; + } + const clientOrderId = this.safeString2 (params, 'clOrdID', 'clientOrderId'); + if (clientOrderId !== undefined) { + request['clOrdID'] = clientOrderId; + params = this.omit (params, [ 'clOrdID', 'clientOrderId' ]); + } + if (limit !== undefined) { + request['pageSize'] = limit; // default 10 + } + if (since !== undefined) { + request['startDate'] = this.ymd (since); + } + const response = await this[method] (this.extend (request, params)); + // + // spot + // + // { + // "code":1, + // "data":{ + // "total":19, + // "pageSize":10, + // "list":[ + // { + // "orderType":2, + // "symbol":"BTCUSDT", + // "avgPrice":"0", + // "orderStatus":0, + // "userID":"7225", + // "quote":"USDT", + // "rejectReason":null, + // "rejectCode":null, + // "price":"0", + // "orderQty":"0.002", + // "commission":"0", + // "id":"110419975166304256", + // "isTriggered":null, + // "side":1, + // "orderID":"vBGlDcLwk", + // "cumQty":"0", + // "leavesQty":"0", + // "updateTime":null, + // "clOrdID":"0001", + // "lastQty":"0", + // "stopPrice":"0", + // "createTime":"2019-11-01T08:49:33Z", + // "transactTime":null, + // "timeInForce":1, + // "base":"BTC", + // "lastPrice":"0" + // } + // ], + // "pageNum":1 + // }, + // "message":"success", + // "ts":1572598173682 + // } + // + // futures + // + // { + // "code":1, + // "data":{ + // "list":[ + // { + // "avgPrice":"8768.99999999484997", + // "base":"BTC", + // "clOrdID":null, + // "code":"FP", + // "commission":"0.00000913", + // "createTime":"2019-11-12T07:05:52.000Z, + // "cumQty":"100", + // "id":"114380149603028993", + // "isTriggered":false, + // "lastPrice":"8769", + // "lastQty":"100", + // "leavesQty":"0", + // "leverage":"1", + // "liqType":1, + // "marketPrice":"8769.75", + // "orderID":"wJXURIFBT", + // "orderQty":"100", + // "orderStatus":3, + // "orderType":1, + // "price":"8769.75", + // "quote":"USD", + // "rejectCode":0, + // "rejectReason":null, + // "settleType":"INVERSE", + // "side":2, + // "stopPrice":"0", + // "symbol":"BTCUSDFP", + // "transactTime":"2019-11-12T07:05:52.000Z, + // "updateTime":"2019-11-12T07:05:52.000Z, + // "timeInForce":1, + // "execInst": "", + // "userID":"216214" + // }, + // ], + // "pageNum":1, + // "pageSize":10, + // "total":21 + // }, + // "message":"success", + // "ts":1573546960172 + // } + // + const data = this.safeValue (response, 'data', {}); + const orders = this.safeValue (data, 'list', []); + return this.parseOrders (orders, market, since, limit); + } + + parseOrderStatus (status) { + const statuses = { + '0': 'open', // pending new + '1': 'open', // new + '2': 'open', // partially-filled + '3': 'closed', // filled + '4': 'canceled', // cancel-reject + '5': 'canceled', // canceled + '6': 'rejected', // rejected + '10': 'expired', // expired + '11': 'rejected', // business-reject + }; + return this.safeString (statuses, status, status); + } + + parseOrderType (status) { + const statuses = { + '1': 'market', + '2': 'limit', + '3': 'stop', + '4': 'stop-limit', + '7': 'stop-loss', + '8': 'take-profit', + }; + return this.safeString (statuses, status, status); + } + + parseTimeInForce (timeInForce) { + const timeInForces = { + '1': 'GTC', + '3': 'IOC', + '4': 'FOK', + }; + return this.safeString (timeInForces, timeInForce, timeInForce); + } + + parseOrder (order, market = undefined) { + // + // { + // "avgPrice":"8768.99999999484997", + // "base":"BTC", + // "clOrdID":null, + // "code":"FP", // futures only + // "commission":"0.00000913", + // "createTime":"2019-11-12T07:05:52.000Z, + // "cumQty":"100", + // "id":"114380149603028993", // futures only + // "isTriggered":false, + // "lastPrice":"8769", + // "lastQty":"100", + // "leavesQty":"0", + // "leverage":"1", // futures only + // "liqType":1, // futures only + // "marketPrice":"8769.75", // futures only + // "orderID":"wJXURIFBT", + // "orderQty":"100", + // "orderStatus":3, + // "orderType":1, + // "price":"8769.75", + // "quote":"USD", + // "rejectCode":0, + // "rejectReason":null, + // "settleType":"INVERSE", // futures only + // "side":2, + // "stopPrice":"0", + // "symbol":"BTCUSDFP", + // "transactTime":"2019-11-12T07:05:52.000Z, + // "updateTime":"2019-11-12T07:05:52.000Z, + // "timeInForce":1, + // "execInst": "", + // "userID":"216214" + // } + // + // sometimes the timestamp is returned in milliseconds + let timestamp = this.safeValue (order, 'createTime'); + if (typeof timestamp === 'string') { + timestamp = this.parse8601 (timestamp); + } + const status = this.parseOrderStatus (this.safeString (order, 'orderStatus')); + const type = this.parseOrderType (this.safeString (order, 'orderType')); + let side = this.safeString (order, 'side'); + if (side === '1') { + side = 'buy'; + } else if (side === '2') { + side = 'sell'; + } + const id = this.safeString (order, 'orderID'); + const clientOrderId = this.safeString (order, 'clOrdID'); + const marketId = this.safeString (order, 'symbol'); + market = this.safeMarket (marketId, market); + const symbol = market['symbol']; + const price = this.safeFloat (order, 'price'); + const stopPrice = this.safeFloat (order, 'stopPrice'); + const timeInForce = this.parseTimeInForce (this.safeString (order, 'timeInForce')); + const execInst = this.safeString (order, 'execInst'); + const postOnly = (execInst === 'Post-Only'); + const average = this.safeFloat (order, 'avgPrice'); + const amount = this.safeFloat (order, 'orderQty'); + const filled = this.safeFloat (order, 'cumQty'); + const remaining = this.safeString (order, 'leavesQty'); + let cost = undefined; + let lastTradeTimestamp = undefined; + if (filled !== undefined) { + if (price !== undefined) { + cost = filled * price; + } + if (filled > 0) { + lastTradeTimestamp = this.safeValue (order, 'transactTime'); + if (typeof lastTradeTimestamp === 'string') { + lastTradeTimestamp = this.parse8601 (lastTradeTimestamp); + } + } + } + let fee = undefined; + const feeCost = this.safeFloat (order, 'commission'); + if (feeCost !== undefined) { + let feeCurrency = undefined; + if (market !== undefined) { + if (side === 'buy') { + feeCurrency = market['base']; + } else if (side === 'sell') { + feeCurrency = market['quote']; + } + } + fee = { + 'currency': feeCurrency, + 'cost': feeCost, + }; + } + return { + 'id': id, + 'info': order, + 'clientOrderId': clientOrderId, + 'timestamp': timestamp, + 'datetime': this.iso8601 (timestamp), + 'lastTradeTimestamp': lastTradeTimestamp, + 'status': status, + 'symbol': symbol, + 'type': type, + 'timeInForce': timeInForce, + 'postOnly': postOnly, + 'side': side, + 'price': price, + 'stopPrice': stopPrice, + 'average': average, + 'amount': amount, + 'filled': filled, + 'remaining': remaining, + 'cost': cost, + 'trades': undefined, + 'fee': fee, + }; + } + + async fetchMyTrades (symbol = undefined, since = undefined, limit = undefined, params = {}) { + await this.loadMarkets (); + const request = { + // 'pageNum': '1', + // 'pageSize': '10', + // 'symbol': market['id'], + // 'orderID': id, + // 'base': market['baseId'], + // 'quote': market['quoteId'], + // 'startDate': this.ymd (since), + // 'endDate': this.ymd (this.milliseconds()), + // 'orderType': undefined, // MARKET, LIMIT, STOP, STOP-LIMIT + // 'side': 'undefined', // BUY, SELL + }; + let method = undefined; + const defaultType = this.safeString2 (this.options, 'fetchMyTrades', 'defaultType', 'spot'); + let type = this.safeString (params, 'type', defaultType); + params = this.omit (params, 'type'); + let market = undefined; + if (symbol !== undefined) { + market = this.market (symbol); + request['symbol'] = market['id']; + type = market['type']; + } + if (type === 'spot') { + method = 'privateGetSpotTrades'; + } else if (type === 'futures') { + method = 'privateGetFuturesTrades'; + } + if (limit !== undefined) { + request['pageSize'] = limit; // default 10 + } + if (since !== undefined) { + request['startDate'] = this.ymd (since); + } + const response = await this[method] (this.extend (request, params)); + // + // { + // "code":1, + // "data":{ + // "list":[ + // { + // "avgPrice":"1199.8", + // "base":"ETH", + // "clOrdID":null, + // "commission":"0.00002", + // "createTime":"2021-01-11T02:47:51.512Z", + // "cumQty":"0.02", + // "filledOrderID":"1eUD4F5rwK", + // "filledPrice":"1199.8", + // "filledQty":"0.02", + // "leavesQty":"0", + // "oCreateTime":"2021-01-11T02:47:51.377Z", + // "orderID":"1eUD4EHfdU", + // "orderQty":"0.02", + // "orderStatus":3, + // "orderType":1, + // "price":"1198.25", + // "quote":"USDT", + // "rejectCode":null, + // "rejectReason":null, + // "side":1, + // "stopPrice":"0", + // "symbol":"ETHUSDT", + // "taker":true, + // "tradeID":"E04WTIgfmULU", + // "transactTime":"2021-01-11T02:47:51.389Z", + // "updateTime":null, + // "userID":"1362494" + // } + // ], + // "pageNum":1, + // "pageSize":10, + // "total":1 + // }, + // "message":"success", + // "ts":1610333278042 + // } + // + const data = this.safeValue (response, 'data', {}); + const trades = this.safeValue (data, 'list', []); + return this.parseTrades (trades, market, since, limit); + } + + async fetchDepositAddress (code, params = {}) { + await this.loadMarkets (); + const currency = this.currency (code); + const request = { + 'currency': currency['id'], + // 'network': undefined, // 'ERC20 + }; + const response = await this.privateGetAccountDepositAddress (this.extend (request, params)); + // + // { + // "code":1, + // "data":{ + // "address":"0x080c5c667381404cca9be0be9a04b2e47691ff86", + // "tag":null, + // "currency":"USDT", + // "network":"ERC20" + // }, + // "message":"success", + // "ts":1610270465132 + // } + // + const data = this.safeValue (response, 'data', {}); + return this.parseDepositAddress (data, currency); + } + + parseDepositAddress (depositAddress, currency = undefined) { + // + // { + // "address":"0x080c5c667381404cca9be0be9a04b2e47691ff86", + // "tag":null, + // "currency":"USDT", + // "network":"ERC20" + // } + // + const address = this.safeString (depositAddress, 'address'); + const tag = this.safeString (depositAddress, 'tag'); + const currencyId = this.safeString (depositAddress, 'currency'); + const code = this.safeCurrencyCode (currencyId); + return { + 'info': depositAddress, + 'code': code, + 'address': address, + 'tag': tag, + }; + } + + nonce () { + return this.milliseconds (); + } + + sign (path, api = 'public', method = 'GET', params = {}, headers = undefined, body = undefined) { + let url = '/' + this.implodeParams (path, params); + const query = this.omit (params, this.extractParams (path)); + if (api === 'v1') { + if (Object.keys (query).length) { + url += '?' + this.urlencode (query); + } + } else { + url = '/' + this.version + url; + if (api === 'public') { + if (Object.keys (query).length) { + url += '?' + this.urlencode (query); + } + } else if (api === 'private') { + this.checkRequiredCredentials (); + const nonce = this.nonce ().toString (); + headers = { + 'X-ACCESS-KEY': this.apiKey, + 'X-ACCESS-NONCE': nonce, + }; + let auth = nonce + ':' + method; + if (method === 'GET') { + if (Object.keys (query).length) { + url += '?' + this.urlencode (query); + } + auth += url; + } else { + headers['Content-Type'] = 'application/json'; + body = this.json (query); + auth += url + body; + } + const signature = this.hmac (this.encode (auth), this.encode (this.secret)); + headers['X-ACCESS-SIGN'] = signature; + } + } + url = this.implodeParams (this.urls['api'][api], { 'hostname': this.hostname }) + url; + return { 'url': url, 'method': method, 'body': body, 'headers': headers }; + } + + handleErrors (code, reason, url, method, headers, body, response, requestHeaders, requestBody) { + if (response === undefined) { + return; // fallback to default error handler + } + // + // {"code":40102,"message":"Unauthorized(invalid key)"} + // + const errorCode = this.safeString (response, 'code'); + if ((errorCode !== undefined) && (errorCode !== '1')) { + const feedback = this.id + ' ' + this.json (response); + this.throwExactlyMatchedException (this.exceptions['exact'], errorCode, feedback); + this.throwBroadlyMatchedException (this.exceptions['broad'], body, feedback); + } + } +}; + +},{"./base/Exchange":6,"./base/errors":8,"./base/functions/number":14}],4:[function(require,module,exports){ 'use strict'; // --------------------------------------------------------------------------- @@ -530,6 +2319,7 @@ module.exports = class acx extends Exchange { 'symbol': symbol, 'type': type, 'timeInForce': undefined, + 'postOnly': undefined, 'side': side, 'price': this.safeFloat (order, 'price'), 'stopPrice': undefined, @@ -669,7 +2459,7 @@ module.exports = class acx extends Exchange { } }; -},{"./base/Exchange":5,"./base/errors":7}],4:[function(require,module,exports){ +},{"./base/Exchange":6,"./base/errors":8}],5:[function(require,module,exports){ 'use strict'; // --------------------------------------------------------------------------- @@ -804,6 +2594,9 @@ module.exports = class aofex extends Exchange { 'show_all': '0', // '1' to show zero balances }, }, + 'commonCurrencies': { + 'CPC': 'Consensus Planet Coin', + }, }); } @@ -1470,6 +3263,7 @@ module.exports = class aofex extends Exchange { 'symbol': market['symbol'], 'type': type, 'timeInForce': undefined, + 'postOnly': undefined, 'side': side, 'price': price, 'stopPrice': undefined, @@ -1767,7 +3561,7 @@ module.exports = class aofex extends Exchange { } }; -},{"./base/Exchange":5,"./base/errors":7,"./base/functions/number":13}],5:[function(require,module,exports){ +},{"./base/Exchange":6,"./base/errors":8,"./base/functions/number":14}],6:[function(require,module,exports){ "use strict"; // ---------------------------------------------------------------------------- @@ -2181,20 +3975,20 @@ module.exports = class Exchange { if (!!enabled) { // eslint-disable-line no-extra-boolean-cast if ('test' in this.urls) { if (typeof this.urls['api'] === 'string') { - this.urls['api_backup'] = this.urls['api'] + this.urls['apiBackup'] = this.urls['api'] this.urls['api'] = this.urls['test'] } else { - this.urls['api_backup'] = clone (this.urls['api']) + this.urls['apiBackup'] = clone (this.urls['api']) this.urls['api'] = clone (this.urls['test']) } } else { throw new NotSupported (this.id + ' does not have a sandbox URL') } - } else if ('api_backup' in this.urls) { + } else if ('apiBackup' in this.urls) { if (typeof this.urls['api'] === 'string') { - this.urls['api'] = this.urls['api_backup'] + this.urls['api'] = this.urls['apiBackup'] } else { - this.urls['api'] = clone (this.urls['api_backup']) + this.urls['api'] = clone (this.urls['apiBackup']) } } } @@ -2346,34 +4140,31 @@ module.exports = class Exchange { handleRestResponse (response, url, method = 'GET', requestHeaders = undefined, requestBody = undefined) { return response.text ().then ((responseBody) => { - - const json = this.parseJson (responseBody) - const responseHeaders = this.getResponseHeaders (response) - + const bodyText = this.onRestResponse (response.status, response.statusText, url, method, responseHeaders, responseBody, requestHeaders, requestBody); + const json = this.parseJson (bodyText) if (this.enableLastResponseHeaders) { this.last_response_headers = responseHeaders } - if (this.enableLastHttpResponse) { this.last_http_response = responseBody } - if (this.enableLastJsonResponse) { this.last_json_response = json } - if (this.verbose) { this.print ("handleRestResponse:\n", this.id, method, url, response.status, response.statusText, "\nResponse:\n", responseHeaders, "\n", responseBody, "\n") } - this.handleErrors (response.status, response.statusText, url, method, responseHeaders, responseBody, json, requestHeaders, requestBody) this.handleHttpStatusCode (response.status, response.statusText, url, method, responseBody) - return json || responseBody }) } + onRestResponse (statusCode, statusText, url, method, responseHeaders, responseBody, requestHeaders, requestBody) { + return responseBody.trim ().replace (/:(\d{15,}),/g, ':"$1",'); + } + setMarkets (markets, currencies = undefined) { const values = Object.values (markets).map ((market) => deepExtend ({ 'limits': this.limits, @@ -2673,6 +4464,10 @@ module.exports = class Exchange { return symbols.map ((symbol) => this.marketId (symbol)) } + currencyIds (codes) { + return codes.map ((code) => this.currencyId (code)) + } + symbol (symbol) { return this.market (symbol).symbol || symbol } @@ -2806,7 +4601,7 @@ module.exports = class Exchange { array = array.filter ((entry) => entry[key] >= since) } if (limit !== undefined && limit !== null) { - array = (tail && !sinceIsDefined) ? array.slice (-limit) : array.slice (0, limit) + array = tail ? array.slice (-limit) : array.slice (0, limit) } return array } @@ -2824,18 +4619,18 @@ module.exports = class Exchange { } if (limit !== undefined && limit !== null) { - array = (tail && !sinceIsDefined) ? array.slice (-limit) : array.slice (0, limit) + array = tail ? array.slice (-limit) : array.slice (0, limit) } return array } - filterBySymbolSinceLimit (array, symbol = undefined, since = undefined, limit = undefined) { - return this.filterByValueSinceLimit (array, 'symbol', symbol, since, limit) + filterBySymbolSinceLimit (array, symbol = undefined, since = undefined, limit = undefined, tail = false) { + return this.filterByValueSinceLimit (array, 'symbol', symbol, since, limit, 'timestamp', tail) } - filterByCurrencySinceLimit (array, code = undefined, since = undefined, limit = undefined) { - return this.filterByValueSinceLimit (array, 'currency', code, since, limit) + filterByCurrencySinceLimit (array, code = undefined, since = undefined, limit = undefined, tail = false) { + return this.filterByValueSinceLimit (array, 'currency', code, since, limit, 'timestamp', tail) } filterByArray (objects, key, values = undefined, indexed = true) { @@ -2865,7 +4660,8 @@ module.exports = class Exchange { let result = Object.values (trades || []).map ((trade) => this.extend (this.parseTrade (trade, market), params)) result = sortBy (result, 'timestamp') const symbol = (market !== undefined) ? market['symbol'] : undefined - return this.filterBySymbolSinceLimit (result, symbol, since, limit) + const tail = since === undefined + return this.filterBySymbolSinceLimit (result, symbol, since, limit, tail) } parseTransactions (transactions, currency = undefined, since = undefined, limit = undefined, params = {}) { @@ -2876,7 +4672,8 @@ module.exports = class Exchange { let result = Object.values (transactions || []).map ((transaction) => this.extend (this.parseTransaction (transaction, currency), params)) result = this.sortBy (result, 'timestamp'); const code = (currency !== undefined) ? currency['code'] : undefined; - return this.filterByCurrencySinceLimit (result, code, since, limit); + const tail = since === undefined; + return this.filterByCurrencySinceLimit (result, code, since, limit, tail); } parseLedger (data, currency = undefined, since = undefined, limit = undefined, params = {}) { @@ -2894,7 +4691,8 @@ module.exports = class Exchange { } result = this.sortBy (result, 'timestamp'); const code = (currency !== undefined) ? currency['code'] : undefined; - return this.filterByCurrencySinceLimit (result, code, since, limit); + const tail = since === undefined; + return this.filterByCurrencySinceLimit (result, code, since, limit, tail); } parseOrders (orders, market = undefined, since = undefined, limit = undefined, params = {}) { @@ -2924,7 +4722,8 @@ module.exports = class Exchange { Object.entries (orders).map (([ id, order ]) => this.extend (this.parseOrder (this.extend ({ 'id': id }, order), market), params)) result = sortBy (result, 'timestamp') const symbol = (market !== undefined) ? market['symbol'] : undefined - return this.filterBySymbolSinceLimit (result, symbol, since, limit) + const tail = since === undefined + return this.filterBySymbolSinceLimit (result, symbol, since, limit, tail) } safeCurrency (currencyId, currency = undefined) { @@ -2995,19 +4794,10 @@ module.exports = class Exchange { // if (!this.isArray (ohlcvs)) { // throw new ExchangeError (this.id + ' parseOHLCVs expected an array in the ohlcvs argument, but got ' + typeof ohlcvs); // } - ohlcvs = Object.values (ohlcvs || []) - const result = [] - for (let i = 0; i < ohlcvs.length; i++) { - if (limit && (result.length >= limit)) { - break; - } - const ohlcv = this.parseOHLCV (ohlcvs[i], market) - if (since && (ohlcv[0] < since)) { - continue - } - result.push (ohlcv) - } - return this.sortBy (result, 0) + const parsed = ohlcvs.map ((ohlcv) => this.parseOHLCV (ohlcv, market)) + const sorted = this.sortBy (parsed, 0) + const tail = since === undefined + return this.filterBySinceLimit (sorted, since, limit, 0, tail) } editLimitBuyOrder (id, symbol, ...args) { @@ -3030,20 +4820,20 @@ module.exports = class Exchange { return this.createOrder (symbol, ...args) } - createLimitOrder (symbol, ...args) { - return this.createOrder (symbol, 'limit', ...args) + createLimitOrder (symbol, side, amount, price = undefined, params = {}) { + return this.createOrder (symbol, 'limit', side, amount, price, params) } - createMarketOrder (symbol, ...args) { - return this.createOrder (symbol, 'market', ...args) + createMarketOrder (symbol, side, amount, price = undefined, params = {}) { + return this.createOrder (symbol, 'market', side, amount, price, params) } - createLimitBuyOrder (symbol, ...args) { - return this.createOrder (symbol, 'limit', 'buy', ...args) + createLimitBuyOrder (symbol, amount, price = undefined, params = {}) { + return this.createOrder (symbol, 'limit', 'buy', amount, price, params) } - createLimitSellOrder (symbol, ...args) { - return this.createOrder (symbol, 'limit', 'sell', ...args) + createLimitSellOrder (symbol, amount, price = undefined, params = {}) { + return this.createOrder (symbol, 'limit', 'sell', amount, price, params) } createMarketBuyOrder (symbol, amount, params = {}) { @@ -3055,7 +4845,7 @@ module.exports = class Exchange { } costToPrecision (symbol, cost) { - return decimalToPrecision (cost, ROUND, this.markets[symbol].precision.price, this.precisionMode, this.paddingMode) + return decimalToPrecision (cost, TRUNCATE, this.markets[symbol].precision.price, this.precisionMode, this.paddingMode) } priceToPrecision (symbol, price) { @@ -3142,7 +4932,7 @@ module.exports = class Exchange { // still takes the input as a hex string // same as above but returns a string instead of an object const signature = this.signMessage (message, privateKey) - return signature['r'] + this.remove0xPrefix (signature['s']) + this.binaryToBase16 (this.numberToBE (signature['v'])); + return signature['r'] + this.remove0xPrefix (signature['s']) + this.binaryToBase16 (this.numberToBE (signature['v'])) } oath () { @@ -3166,10 +4956,79 @@ module.exports = class Exchange { integerPow (a, b) { return new BN (a).pow (new BN (b)) } + + safeOrder (order) { + // Cost + // Remaining + // Average + // Price + // Amount + // Filled + // + // First we try to calculate filled from the trades + const parseFilled = order['filled'] === undefined; + const parseCost = order['cost'] === undefined; + if (parseFilled) { + order['filled'] = 0 + } + if (parseCost) { + order['cost'] = 0 + } + if (parseFilled || parseCost) { + if (Array.isArray (order['trades'])) { + for (let i = 0; i < order['trades'].length; i++) { + const trade = order['trades'][i] + if (parseFilled) { + order['filled'] = this.sum (order['filled'], trade['amount']) + } + if (parseCost) { + order['cost'] = this.sum (order['cost'], trade['cost']) + } + } + } + } + // We ensure amount = filled + remaining + if (order['amount'] === undefined) { + if (order['filled'] !== undefined && order['remaining'] !== undefined) { + order['amount'] = this.sum (order['filled'], order['remaining']) + } + } + if (order['filled'] === undefined) { + if (order['amount'] !== undefined && order['remaining'] !== undefined) { + order['filled'] = Math.max (this.sum (order['amount'], -order['remaining']), 0) + } + } + if (order['remaining'] === undefined) { + if (order['amount'] !== undefined && order['filled'] !== undefined) { + order['remaining'] = Math.max (this.sum (order['amount'], -order['filled']), 0) + } + } + // We ensure that the average field is calculated correctly + if (order['average'] === undefined) { + if (order['filled'] !== undefined && order['cost'] !== undefined && order['cost'] > 0) { + order['average'] = order['filled'] / order['cost'] + } + } + // We also ensure the cost field is calculated correctly + const costPriceExists = (order['average'] !== undefined) || (order['price'] !== undefined) + if ((order['filled'] !== undefined) && costPriceExists) { + let costPrice = undefined; + if (order['average'] === undefined) { + costPrice = order['price'] + } else { + costPrice = order['average'] + } + order['cost'] = costPrice * order['filled'] + } + // We add support for market orders + if (order['price'] === undefined && order['type'] === 'market') { + order['price'] = order['average'] + } + return order + } } - -},{"../static_dependencies/BN/bn":123,"./errors":7,"./functions":8}],6:[function(require,module,exports){ +},{"../static_dependencies/BN/bn":126,"./errors":8,"./functions":9}],7:[function(require,module,exports){ 'use strict'; const errorHierarchy = { @@ -3215,7 +5074,7 @@ const errorHierarchy = { module.exports = errorHierarchy; -},{}],7:[function(require,module,exports){ +},{}],8:[function(require,module,exports){ 'use strict'; const errorHierarchy = require ('./errorHierarchy.js') @@ -3248,6 +5107,10 @@ function subclass (BaseClass, classes, namespace = {}) { this.__proto__ = Class.prototype this.name = className this.message = message + + // https://github.com/Microsoft/TypeScript/wiki/FAQ#why-doesnt-extending-built-ins-like-error-array-and-map-work + + Object.setPrototypeOf (this, Class.prototype) } } @@ -3268,7 +5131,7 @@ module.exports = subclass ( errorHierarchy ) -},{"./errorHierarchy.js":6}],8:[function(require,module,exports){ +},{"./errorHierarchy.js":7}],9:[function(require,module,exports){ 'use strict'; /* ------------------------------------------------------------------------ */ @@ -3298,7 +5161,7 @@ module.exports = unCamelCasePropertyNames (Object.assign ({} /* ------------------------------------------------------------------------ */ -},{"./functions/crypto":9,"./functions/encode":10,"./functions/generic":11,"./functions/misc":12,"./functions/number":13,"./functions/platform":14,"./functions/string":15,"./functions/throttle":16,"./functions/time":17,"./functions/type":18}],9:[function(require,module,exports){ +},{"./functions/crypto":10,"./functions/encode":11,"./functions/generic":12,"./functions/misc":13,"./functions/number":14,"./functions/platform":15,"./functions/string":16,"./functions/throttle":17,"./functions/time":18,"./functions/type":19}],10:[function(require,module,exports){ 'use strict' /* ------------------------------------------------------------------------ */ @@ -3458,7 +5321,7 @@ module.exports = { /* ------------------------------------------------------------------------ */ -},{"../../static_dependencies/BN/bn.js":123,"../../static_dependencies/crypto-js/crypto-js":124,"./../../static_dependencies/elliptic/lib/elliptic":125,"./../../static_dependencies/node-rsa/NodeRSA":143,"./../errors":7,"./encode":10,"./string":15}],10:[function(require,module,exports){ +},{"../../static_dependencies/BN/bn.js":126,"../../static_dependencies/crypto-js/crypto-js":127,"./../../static_dependencies/elliptic/lib/elliptic":128,"./../../static_dependencies/node-rsa/NodeRSA":146,"./../errors":8,"./encode":11,"./string":16}],11:[function(require,module,exports){ "use strict"; /* ------------------------------------------------------------------------ */ @@ -3578,7 +5441,7 @@ module.exports['byteArrayToWordArray'] = byteArrayToWordArray /* ------------------------------------------------------------------------ */ -},{"../../static_dependencies/BN/bn":123,"../../static_dependencies/crypto-js/crypto-js":124,"../../static_dependencies/qs/index":159}],11:[function(require,module,exports){ +},{"../../static_dependencies/BN/bn":126,"../../static_dependencies/crypto-js/crypto-js":127,"../../static_dependencies/qs/index":162}],12:[function(require,module,exports){ "use strict"; // ---------------------------------------------------------------------------- @@ -3816,7 +5679,7 @@ module.exports = { } -},{"./type":18}],12:[function(require,module,exports){ +},{"./type":19}],13:[function(require,module,exports){ 'use strict'; const { ROUND_UP, ROUND_DOWN } = require ('./number') @@ -3956,7 +5819,7 @@ module.exports = { /* ------------------------------------------------------------------------ */ -},{"../errors":7,"./number":13}],13:[function(require,module,exports){ +},{"../errors":8,"./number":14}],14:[function(require,module,exports){ 'use strict' /* ------------------------------------------------------------------------ @@ -4297,7 +6160,7 @@ module.exports = { /* ------------------------------------------------------------------------ */ -},{}],14:[function(require,module,exports){ +},{}],15:[function(require,module,exports){ (function (process){ "use strict"; @@ -4338,30 +6201,27 @@ module.exports = { defaultFetch, } }).call(this,require('_process')) -},{"../../static_dependencies/fetch-ponyfill/fetch-node":141,"_process":207}],15:[function(require,module,exports){ +},{"../../static_dependencies/fetch-ponyfill/fetch-node":144,"_process":210}],16:[function(require,module,exports){ "use strict"; -/* ------------------------------------------------------------------------ */ +// ---------------------------------------------------------------------------- -const uuid = a => a ? (a ^ Math.random () * 16 >> a / 4).toString (16) - : ([1e7]+-1e3+-4e3+-8e3+-1e11).replace (/[018]/g, uuid) +const uuid = a => a ? (a ^ Math.random () * 16 >> a / 4).toString (16) : ([1e7]+-1e3+-4e3+-8e3+-1e11).replace (/[018]/g, uuid) +const uuid22 = a => a ? (a ^ Math.random () * 16 >> a / 4).toString (16) : ([1e7]+1e3+4e3+8e5).replace (/[018]/g, uuid22) -module.exports = +// ---------------------------------------------------------------------------- - { uuid +module.exports = { - // hasFetchOHLCV → has_fetch_ohlcv; parseHTTPResponse → parse_http_response + uuid + , uuid22 + // hasFetchOHLCV → has_fetch_ohlcv; parseHTTPResponse → parse_http_response , unCamelCase: s => s.match (/^[A-Z0-9_]+$/) ? s : (s.replace (/[a-z0-9][A-Z]/g, x => x[0] + '_' + x[1]).replace(/[A-Z0-9][A-Z0-9][a-z]/g, x => x[0] + '_' + x[1] + x[2]).toLowerCase ()) - - , capitalize: s => s.length - ? (s.charAt (0).toUpperCase () + s.slice (1)) - : s + , capitalize: s => s.length ? (s.charAt (0).toUpperCase () + s.slice (1)) : s , strip: s => s.replace(/^\s+|\s+$/g, '') - } +} -/* ------------------------------------------------------------------------ */ - -},{}],16:[function(require,module,exports){ +},{}],17:[function(require,module,exports){ "use strict"; /* ------------------------------------------------------------------------ */ @@ -4427,7 +6287,7 @@ module.exports = { /* ------------------------------------------------------------------------ */ -},{"./time":17}],17:[function(require,module,exports){ +},{"./time":18}],18:[function(require,module,exports){ 'use strict'; /* ------------------------------------------------------------------------ */ @@ -4631,7 +6491,7 @@ module.exports = /* ------------------------------------------------------------------------ */ -},{}],18:[function(require,module,exports){ +},{}],19:[function(require,module,exports){ "use strict"; /* ------------------------------------------------------------------------ */ @@ -4699,696 +6559,7 @@ module.exports = { /* ------------------------------------------------------------------------ */ -},{}],19:[function(require,module,exports){ -'use strict'; - -// --------------------------------------------------------------------------- - -const Exchange = require ('./base/Exchange'); -const { ExchangeError, ArgumentsRequired, AuthenticationError, InsufficientFunds, InvalidOrder, OrderNotFound } = require ('./base/errors'); - -// --------------------------------------------------------------------------- - -module.exports = class bcex extends Exchange { - describe () { - return this.deepExtend (super.describe (), { - 'id': 'bcex', - 'name': 'BCEX', - 'countries': [ 'CN', 'HK' ], - 'version': '1', - 'has': { - 'cancelOrder': true, - 'createOrder': true, - 'fetchBalance': true, - 'fetchClosedOrders': 'emulated', - 'fetchMarkets': true, - 'fetchMyTrades': true, - 'fetchOpenOrders': true, - 'fetchOrder': true, - 'fetchOrders': true, - 'fetchOrderBook': true, - 'fetchTicker': true, - 'fetchTickers': false, - 'fetchTrades': true, - 'fetchTradingLimits': true, - }, - 'urls': { - 'logo': 'https://user-images.githubusercontent.com/51840849/77231516-851c6900-6bac-11ea-8fd6-ee5c23eddbd4.jpg', - 'api': 'https://www.bcex.top', - 'www': 'https://www.bcex.top', - 'doc': 'https://github.com/BCEX-TECHNOLOGY-LIMITED/API_Docs/wiki/Interface', - 'fees': 'https://bcex.udesk.cn/hc/articles/57085', - 'referral': 'https://www.bcex.top/register?invite_code=758978&lang=en', - }, - 'status': { - 'status': 'error', - 'updated': undefined, - 'eta': undefined, - 'url': undefined, - }, - 'api': { - 'public': { - 'get': [ - 'Api_Market/getPriceList', // tickers - 'Api_Order/ticker', // last ohlcv candle (ticker) - 'Api_Order/depth', // orderbook - 'Api_Market/getCoinTrade', // ticker - 'Api_Order/marketOrder', // trades... - ], - 'post': [ - 'Api_Market/getPriceList', // tickers - 'Api_Order/ticker', // last ohlcv candle (ticker) - 'Api_Order/depth', // orderbook - 'Api_Market/getCoinTrade', // ticker - 'Api_Order/marketOrder', // trades... - ], - }, - 'private': { - 'post': [ - 'Api_Order/cancel', - 'Api_Order/coinTrust', // limit order - 'Api_Order/orderList', // open / all orders (my trades?) - 'Api_Order/orderInfo', - 'Api_Order/tradeList', // open / all orders - 'Api_Order/trustList', // ? - 'Api_User/userBalance', - ], - }, - }, - 'fees': { - 'trading': { - 'tierBased': false, - 'percentage': true, - 'maker': 0.1 / 100, - 'taker': 0.2 / 100, - }, - 'funding': { - 'tierBased': false, - 'percentage': false, - 'withdraw': { - 'ckusd': 0.0, - 'other': 0.05 / 100, - }, - 'deposit': {}, - }, - }, - 'exceptions': { - '该币不存在,非法操作': ExchangeError, // { code: 1, msg: "该币不存在,非法操作" } - returned when a required symbol parameter is missing in the request (also, maybe on other types of errors as well) - '公钥不合法': AuthenticationError, // { code: 1, msg: '公钥不合法' } - wrong public key - '您的可用余额不足': InsufficientFunds, // { code: 1, msg: '您的可用余额不足' } - your available balance is insufficient - '您的btc不足': InsufficientFunds, // { code: 1, msg: '您的btc不足' } - your btc is insufficient - '参数非法': InvalidOrder, // {'code': 1, 'msg': '参数非法'} - 'Parameter illegal' - '订单信息不存在': OrderNotFound, // {'code': 1, 'msg': '订单信息不存在'} - 'Order information does not exist' - }, - 'commonCurrencies': { - 'UNI': 'UNI COIN', - 'PNT': 'Penta', - }, - 'options': { - 'limits': { - // hardcoding is deprecated, using these predefined values is not recommended, use loadTradingLimits instead - 'AFC/CKUSD': { 'precision': { 'amount': 2, 'price': 4 }, 'limits': { 'amount': { 'min': 6, 'max': 120000 }}}, - 'AFC/ETH': { 'precision': { 'amount': 2, 'price': 8 }, 'limits': { 'amount': { 'min': 6, 'max': 120000 }}}, - 'AFT/ETH': { 'precision': { 'amount': 2, 'price': 8 }, 'limits': { 'amount': { 'min': 15, 'max': 300000 }}}, - 'AICC/CNET': { 'precision': { 'amount': 2, 'price': 2 }, 'limits': { 'amount': { 'min': 5, 'max': 50000 }}}, - 'AIDOC/CKUSD': { 'precision': { 'amount': 2, 'price': 4 }, 'limits': { 'amount': { 'min': 5, 'max': 100000 }}}, - 'AISI/ETH': { 'precision': { 'amount': 4, 'price': 2 }, 'limits': { 'amount': { 'min': 0.001, 'max': 500 }}}, - 'AIT/ETH': { 'precision': { 'amount': 2, 'price': 8 }, 'limits': { 'amount': { 'min': 20, 'max': 400000 }}}, - 'ANS/BTC': { 'precision': { 'amount': 4, 'price': 8 }, 'limits': { 'amount': { 'min': 0.1, 'max': 500 }}}, - 'ANS/CKUSD': { 'precision': { 'amount': 2, 'price': 2 }, 'limits': { 'amount': { 'min': 0.1, 'max': 1000 }}}, - 'ARC/CNET': { 'precision': { 'amount': 2, 'price': 4 }, 'limits': { 'amount': { 'min': 60, 'max': 600000 }}}, - 'AXF/CNET': { 'precision': { 'amount': 2, 'price': 4 }, 'limits': { 'amount': { 'min': 100, 'max': 1000000 }}}, - 'BASH/CKUSD': { 'precision': { 'amount': 2, 'price': 4 }, 'limits': { 'amount': { 'min': 250, 'max': 3000000 }}}, - 'BATT/ETH': { 'precision': { 'amount': 2, 'price': 8 }, 'limits': { 'amount': { 'min': 60, 'max': 1500000 }}}, - 'BCD/BTC': { 'precision': { 'amount': 2, 'price': 8 }, 'limits': { 'amount': { 'min': 0.3, 'max': 7000 }}}, - 'BHPC/BTC': { 'precision': { 'amount': 2, 'price': 8 }, 'limits': { 'amount': { 'min': 2, 'max': 70000 }}}, - 'BHPC/ETH': { 'precision': { 'amount': 2, 'price': 8 }, 'limits': { 'amount': { 'min': 2, 'max': 60000 }}}, - 'BOPO/BTC': { 'precision': { 'amount': 2, 'price': 8 }, 'limits': { 'amount': { 'min': 100, 'max': 2000000 }}}, - 'BOPO/CKUSD': { 'precision': { 'amount': 2, 'price': 4 }, 'limits': { 'amount': { 'min': 100, 'max': 10000000 }}}, - 'BTC/CKUSD': { 'precision': { 'amount': 4, 'price': 2 }, 'limits': { 'amount': { 'min': 0.001, 'max': 10 }}}, - 'BTC/CNET': { 'precision': { 'amount': 4, 'price': 2 }, 'limits': { 'amount': { 'min': 0.0005, 'max': 5 }}}, - 'BTC/USDT': { 'precision': { 'amount': 4, 'price': 2 }, 'limits': { 'amount': { 'min': 0.0002, 'max': 4 }}}, - 'BTE/CNET': { 'precision': { 'amount': 2, 'price': 4 }, 'limits': { 'amount': { 'min': 25, 'max': 250000 }}}, - 'BU/ETH': { 'precision': { 'amount': 2, 'price': 8 }, 'limits': { 'amount': { 'min': 20, 'max': 400000 }}}, - 'CIC/CNET': { 'precision': { 'amount': 2, 'price': 4 }, 'limits': { 'amount': { 'min': 3000, 'max': 30000000 }}}, - 'CIT/CKUSD': { 'precision': { 'amount': 2, 'price': 4 }, 'limits': { 'amount': { 'min': 4, 'max': 40000 }}}, - 'CIT/ETH': { 'precision': { 'amount': 2, 'price': 8 }, 'limits': { 'amount': { 'min': 4, 'max': 40000 }}}, - 'CMT/CKUSD': { 'precision': { 'amount': 2, 'price': 4 }, 'limits': { 'amount': { 'min': 5, 'max': 2500000 }}}, - 'CNET/CKUSD': { 'precision': { 'amount': 2, 'price': 4 }, 'limits': { 'amount': { 'min': 12, 'max': 120000 }}}, - 'CNMC/BTC': { 'precision': { 'amount': 2, 'price': 8 }, 'limits': { 'amount': { 'min': 4, 'max': 50000 }}}, - 'CTC/ETH': { 'precision': { 'amount': 2, 'price': 8 }, 'limits': { 'amount': { 'min': 5, 'max': 550000 }}}, - 'CZR/ETH': { 'precision': { 'amount': 2, 'price': 8 }, 'limits': { 'amount': { 'min': 12, 'max': 500000 }}}, - 'DCON/ETH': { 'precision': { 'amount': 2, 'price': 8 }, 'limits': { 'amount': { 'min': 8, 'max': 300000 }}}, - 'DCT/BTC': { 'precision': { 'amount': 4, 'price': 8 }, 'limits': { 'amount': { 'min': 2, 'max': 40000 }}}, - 'DCT/CKUSD': { 'precision': { 'amount': 2, 'price': 3 }, 'limits': { 'amount': { 'min': 2, 'max': 2000 }}}, - 'DOGE/BTC': { 'precision': { 'amount': 4, 'price': 8 }, 'limits': { 'amount': { 'min': 3000, 'max': 14000000 }}}, - 'DOGE/CKUSD': { 'precision': { 'amount': 2, 'price': 6 }, 'limits': { 'amount': { 'min': 500, 'max': 2000000 }}}, - 'DRCT/ETH': { 'precision': { 'amount': 2, 'price': 8 }, 'limits': { 'amount': { 'min': 16, 'max': 190000 }}}, - 'ELA/BTC': { 'precision': { 'amount': 2, 'price': 8 }, 'limits': { 'amount': { 'min': 0.02, 'max': 500 }}}, - 'ELF/BTC': { 'precision': { 'amount': 2, 'price': 8 }, 'limits': { 'amount': { 'min': 0.1, 'max': 100000 }}}, - 'ELF/CKUSD': { 'precision': { 'amount': 2, 'price': 3 }, 'limits': { 'amount': { 'min': 0.01, 'max': 100000 }}}, - 'EOS/CKUSD': { 'precision': { 'amount': 2, 'price': 2 }, 'limits': { 'amount': { 'min': 0.5, 'max': 5000 }}}, - 'EOS/CNET': { 'precision': { 'amount': 2, 'price': 2 }, 'limits': { 'amount': { 'min': 2.5, 'max': 30000 }}}, - 'EOS/ETH': { 'precision': { 'amount': 2, 'price': 8 }, 'limits': { 'amount': { 'min': 0.18, 'max': 1800 }}}, - 'ETC/BTC': { 'precision': { 'amount': 4, 'price': 8 }, 'limits': { 'amount': { 'min': 0.2, 'max': 2500 }}}, - 'ETC/CKUSD': { 'precision': { 'amount': 2, 'price': 2 }, 'limits': { 'amount': { 'min': 0.2, 'max': 2500 }}}, - 'ETF/ETH': { 'precision': { 'amount': 2, 'price': 8 }, 'limits': { 'amount': { 'min': 7, 'max': 150000 }}}, - 'ETH/BTC': { 'precision': { 'amount': 4, 'price': 8 }, 'limits': { 'amount': { 'min': 0.015, 'max': 100 }}}, - 'ETH/CKUSD': { 'precision': { 'amount': 4, 'price': 4 }, 'limits': { 'amount': { 'min': 0.005, 'max': 100 }}}, - 'ETH/USDT': { 'precision': { 'amount': 4, 'price': 2 }, 'limits': { 'amount': { 'min': 0.005, 'max': 100 }}}, - 'FCT/BTC': { 'precision': { 'amount': 4, 'price': 8 }, 'limits': { 'amount': { 'min': 0.24, 'max': 1000 }}}, - 'FCT/CKUSD': { 'precision': { 'amount': 2, 'price': 2 }, 'limits': { 'amount': { 'min': 0.24, 'max': 1000 }}}, - 'GAME/CNET': { 'precision': { 'amount': 2, 'price': 2 }, 'limits': { 'amount': { 'min': 1, 'max': 10000 }}}, - 'GOOC/CKUSD': { 'precision': { 'amount': 2, 'price': 4 }, 'limits': { 'amount': { 'min': 200, 'max': 2000000 }}}, - 'GP/CNET': { 'precision': { 'amount': 2, 'price': 4 }, 'limits': { 'amount': { 'min': 600, 'max': 6000000 }}}, - 'HSC/ETH': { 'precision': { 'amount': 2, 'price': 8 }, 'limits': { 'amount': { 'min': 1000, 'max': 20000000 }}}, - 'IFISH/ETH': { 'precision': { 'amount': 2, 'price': 8 }, 'limits': { 'amount': { 'min': 300, 'max': 8000000 }}}, - 'IIC/ETH': { 'precision': { 'amount': 2, 'price': 8 }, 'limits': { 'amount': { 'min': 50, 'max': 4000000 }}}, - 'IMOS/ETH': { 'precision': { 'amount': 2, 'price': 8 }, 'limits': { 'amount': { 'min': 15, 'max': 300000 }}}, - 'JC/CNET': { 'precision': { 'amount': 2, 'price': 4 }, 'limits': { 'amount': { 'min': 300, 'max': 3000000 }}}, - 'LBTC/BTC': { 'precision': { 'amount': 2, 'price': 8 }, 'limits': { 'amount': { 'min': 0.1, 'max': 3000 }}}, - 'LEC/CNET': { 'precision': { 'amount': 2, 'price': 4 }, 'limits': { 'amount': { 'min': 500, 'max': 5000000 }}}, - 'LKY/CKUSD': { 'precision': { 'amount': 2, 'price': 4 }, 'limits': { 'amount': { 'min': 10, 'max': 70000 }}}, - 'LKY/ETH': { 'precision': { 'amount': 2, 'price': 8 }, 'limits': { 'amount': { 'min': 10, 'max': 100000 }}}, - 'LMC/CNET': { 'precision': { 'amount': 2, 'price': 4 }, 'limits': { 'amount': { 'min': 25, 'max': 250000 }}}, - 'LSK/CNET': { 'precision': { 'amount': 2, 'price': 2 }, 'limits': { 'amount': { 'min': 0.3, 'max': 3000 }}}, - 'LTC/BTC': { 'precision': { 'amount': 4, 'price': 8 }, 'limits': { 'amount': { 'min': 0.01, 'max': 500 }}}, - 'LTC/CKUSD': { 'precision': { 'amount': 2, 'price': 2 }, 'limits': { 'amount': { 'min': 0.01, 'max': 500 }}}, - 'LTC/USDT': { 'precision': { 'amount': 4, 'price': 2 }, 'limits': { 'amount': { 'min': 0.02, 'max': 450 }}}, - 'MC/CNET': { 'precision': { 'amount': 2, 'price': 6 }, 'limits': { 'amount': { 'min': 10000, 'max': 100000000 }}}, - 'MCC/CKUSD': { 'precision': { 'amount': 2, 'price': 4 }, 'limits': { 'amount': { 'min': 30, 'max': 350000 }}}, - 'MOC/ETH': { 'precision': { 'amount': 2, 'price': 8 }, 'limits': { 'amount': { 'min': 25, 'max': 600000 }}}, - 'MRYC/CNET': { 'precision': { 'amount': 2, 'price': 4 }, 'limits': { 'amount': { 'min': 300, 'max': 3000000 }}}, - 'MT/ETH': { 'precision': { 'amount': 2, 'price': 8 }, 'limits': { 'amount': { 'min': 200, 'max': 6000000 }}}, - 'MXI/CNET': { 'precision': { 'amount': 2, 'price': 6 }, 'limits': { 'amount': { 'min': 5000, 'max': 60000000 }}}, - 'NAI/ETH': { 'precision': { 'amount': 2, 'price': 8 }, 'limits': { 'amount': { 'min': 10, 'max': 100000 }}}, - 'NAS/BTC': { 'precision': { 'amount': 4, 'price': 8 }, 'limits': { 'amount': { 'min': 0.2, 'max': 15000 }}}, - 'NAS/CKUSD': { 'precision': { 'amount': 2, 'price': 2 }, 'limits': { 'amount': { 'min': 0.5, 'max': 5000 }}}, - 'NEWOS/ETH': { 'precision': { 'amount': 2, 'price': 8 }, 'limits': { 'amount': { 'min': 65, 'max': 700000 }}}, - 'NKN/ETH': { 'precision': { 'amount': 2, 'price': 8 }, 'limits': { 'amount': { 'min': 3, 'max': 350000 }}}, - 'NTK/ETH': { 'precision': { 'amount': 2, 'price': 8 }, 'limits': { 'amount': { 'min': 2, 'max': 30000 }}}, - 'ONT/CKUSD': { 'precision': { 'amount': 2, 'price': 3 }, 'limits': { 'amount': { 'min': 0.2, 'max': 2000 }}}, - 'ONT/ETH': { 'precision': { 'amount': 3, 'price': 8 }, 'limits': { 'amount': { 'min': 0.01, 'max': 1000 }}}, - 'PNT/ETH': { 'precision': { 'amount': 2, 'price': 8 }, 'limits': { 'amount': { 'min': 80, 'max': 800000 }}}, - 'PST/ETH': { 'precision': { 'amount': 2, 'price': 8 }, 'limits': { 'amount': { 'min': 5, 'max': 100000 }}}, - 'PTT/ETH': { 'precision': { 'amount': 2, 'price': 8 }, 'limits': { 'amount': { 'min': 450, 'max': 10000000 }}}, - 'QTUM/BTC': { 'precision': { 'amount': 4, 'price': 8 }, 'limits': { 'amount': { 'min': 0.4, 'max': 2800 }}}, - 'QTUM/CKUSD': { 'precision': { 'amount': 2, 'price': 2 }, 'limits': { 'amount': { 'min': 0.1, 'max': 1000 }}}, - 'RATING/ETH': { 'precision': { 'amount': 2, 'price': 8 }, 'limits': { 'amount': { 'min': 500, 'max': 10000000 }}}, - 'RHC/CNET': { 'precision': { 'amount': 2, 'price': 4 }, 'limits': { 'amount': { 'min': 1000, 'max': 10000000 }}}, - 'SDA/ETH': { 'precision': { 'amount': 2, 'price': 8 }, 'limits': { 'amount': { 'min': 20, 'max': 500000 }}}, - 'SDD/CKUSD': { 'precision': { 'amount': 2, 'price': 3 }, 'limits': { 'amount': { 'min': 10, 'max': 100000 }}}, - 'SHC/CNET': { 'precision': { 'amount': 2, 'price': 4 }, 'limits': { 'amount': { 'min': 250, 'max': 2500000 }}}, - 'SHE/ETH': { 'precision': { 'amount': 2, 'price': 8 }, 'limits': { 'amount': { 'min': 100, 'max': 5000000 }}}, - 'SMC/CNET': { 'precision': { 'amount': 2, 'price': 6 }, 'limits': { 'amount': { 'min': 1000, 'max': 10000000 }}}, - 'SOP/ETH': { 'precision': { 'amount': 2, 'price': 8 }, 'limits': { 'amount': { 'min': 50, 'max': 1000000 }}}, - 'TAC/ETH': { 'precision': { 'amount': 2, 'price': 8 }, 'limits': { 'amount': { 'min': 35, 'max': 800000 }}}, - 'TIP/ETH': { 'precision': { 'amount': 2, 'price': 8 }, 'limits': { 'amount': { 'min': 7, 'max': 200000 }}}, - 'TKT/ETH': { 'precision': { 'amount': 2, 'price': 8 }, 'limits': { 'amount': { 'min': 40, 'max': 400000 }}}, - 'TLC/ETH': { 'precision': { 'amount': 2, 'price': 8 }, 'limits': { 'amount': { 'min': 500, 'max': 10000000 }}}, - 'TNC/ETH': { 'precision': { 'amount': 2, 'price': 8 }, 'limits': { 'amount': { 'min': 10, 'max': 110000 }}}, - 'TUB/ETH': { 'precision': { 'amount': 2, 'price': 8 }, 'limits': { 'amount': { 'min': 200, 'max': 8000000 }}}, - 'UC/ETH': { 'precision': { 'amount': 2, 'price': 8 }, 'limits': { 'amount': { 'min': 100, 'max': 3000000 }}}, - 'UDB/CNET': { 'precision': { 'amount': 2, 'price': 6 }, 'limits': { 'amount': { 'min': 2000, 'max': 40000000 }}}, - 'UIC/CKUSD': { 'precision': { 'amount': 2, 'price': 4 }, 'limits': { 'amount': { 'min': 5, 'max': 150000 }}}, - 'VAAC/ETH': { 'precision': { 'amount': 2, 'price': 8 }, 'limits': { 'amount': { 'min': 10, 'max': 250000 }}}, - 'VPN/CNET': { 'precision': { 'amount': 2, 'price': 4 }, 'limits': { 'amount': { 'min': 200, 'max': 2000000 }}}, - 'VSC/ETH': { 'precision': { 'amount': 2, 'price': 8 }, 'limits': { 'amount': { 'min': 30, 'max': 650000 }}}, - 'WAVES/CKUSD': { 'precision': { 'amount': 2, 'price': 3 }, 'limits': { 'amount': { 'min': 0.15, 'max': 1500 }}}, - 'WDNA/ETH': { 'precision': { 'amount': 2, 'price': 8 }, 'limits': { 'amount': { 'min': 100, 'max': 250000 }}}, - 'WIC/CKUSD': { 'precision': { 'amount': 2, 'price': 4 }, 'limits': { 'amount': { 'min': 3, 'max': 30000 }}}, - 'XAS/CNET': { 'precision': { 'amount': 2, 'price': 2 }, 'limits': { 'amount': { 'min': 2.5, 'max': 25000 }}}, - 'XLM/BTC': { 'precision': { 'amount': 4, 'price': 8 }, 'limits': { 'amount': { 'min': 10, 'max': 300000 }}}, - 'XLM/CKUSD': { 'precision': { 'amount': 2, 'price': 4 }, 'limits': { 'amount': { 'min': 1, 'max': 300000 }}}, - 'XLM/USDT': { 'precision': { 'amount': 2, 'price': 4 }, 'limits': { 'amount': { 'min': 5, 'max': 150000 }}}, - 'XRP/BTC': { 'precision': { 'amount': 4, 'price': 8 }, 'limits': { 'amount': { 'min': 24, 'max': 100000 }}}, - 'XRP/CKUSD': { 'precision': { 'amount': 2, 'price': 3 }, 'limits': { 'amount': { 'min': 5, 'max': 50000 }}}, - 'YBCT/BTC': { 'precision': { 'amount': 4, 'price': 8 }, 'limits': { 'amount': { 'min': 15, 'max': 200000 }}}, - 'YBCT/CKUSD': { 'precision': { 'amount': 2, 'price': 4 }, 'limits': { 'amount': { 'min': 10, 'max': 200000 }}}, - 'YBY/CNET': { 'precision': { 'amount': 2, 'price': 6 }, 'limits': { 'amount': { 'min': 25000, 'max': 250000000 }}}, - 'ZEC/BTC': { 'precision': { 'amount': 4, 'price': 8 }, 'limits': { 'amount': { 'min': 0.02, 'max': 100 }}}, - 'ZEC/CKUSD': { 'precision': { 'amount': 4, 'price': 2 }, 'limits': { 'amount': { 'min': 0.02, 'max': 100 }}}, - }, - }, - }); - } - - async fetchTradingLimits (symbols = undefined, params = {}) { - // this method should not be called directly, use loadTradingLimits () instead - // by default it will try load withdrawal fees of all currencies (with separate requests, sequentially) - // however if you define symbols = [ 'ETH/BTC', 'LTC/BTC' ] in args it will only load those - await this.loadMarkets (); - if (symbols === undefined) { - symbols = this.symbols; - } - const result = {}; - for (let i = 0; i < symbols.length; i++) { - const symbol = symbols[i]; - result[symbol] = await this.fetchTradingLimitsById (this.marketId (symbol), params); - } - return result; - } - - async fetchTradingLimitsById (id, params = {}) { - const request = { - 'symbol': id, - }; - const response = await this.publicPostApiOrderTicker (this.extend (request, params)); - // - // { code: 0, - // msg: "获取牌价信息成功", - // data: { high: 0.03721392, - // low: 0.03335362, - // buy: "0.03525757", - // sell: "0.03531160", - // last: 0.0352634, - // vol: "184742.4176", - // min_trade: "0.01500000", - // max_trade: "100.00000000", - // number_float: "4", - // price_float: "8" } } } - // - return this.parseTradingLimits (this.safeValue (response, 'data', {})); - } - - parseTradingLimits (limits, symbol = undefined, params = {}) { - // - // { high: 0.03721392, - // low: 0.03335362, - // buy: "0.03525757", - // sell: "0.03531160", - // last: 0.0352634, - // vol: "184742.4176", - // min_trade: "0.01500000", - // max_trade: "100.00000000", - // number_float: "4", - // price_float: "8" } - // - return { - 'info': limits, - 'precision': { - 'amount': this.safeInteger (limits, 'number_float'), - 'price': this.safeInteger (limits, 'price_float'), - }, - 'limits': { - 'amount': { - 'min': this.safeFloat (limits, 'min_trade'), - 'max': this.safeFloat (limits, 'max_trade'), - }, - }, - }; - } - - async fetchMarkets (params = {}) { - const response = await this.publicGetApiMarketGetPriceList (params); - const result = []; - const keys = Object.keys (response); - for (let i = 0; i < keys.length; i++) { - const currentMarketId = keys[i]; - const currentMarkets = response[currentMarketId]; - for (let j = 0; j < currentMarkets.length; j++) { - const market = currentMarkets[j]; - const baseId = this.safeString (market, 'coin_from'); - const quoteId = this.safeString (market, 'coin_to'); - let base = baseId.toUpperCase (); - let quote = quoteId.toUpperCase (); - base = this.safeCurrencyCode (base); - quote = this.safeCurrencyCode (quote); - const id = baseId + '2' + quoteId; - const symbol = base + '/' + quote; - const active = true; - const defaults = this.safeValue (this.options['limits'], symbol, {}); - result.push (this.extend ({ - 'id': id, - 'symbol': symbol, - 'base': base, - 'quote': quote, - 'baseId': baseId, - 'quoteId': quoteId, - 'active': active, - // overrided by defaults from this.options['limits'] - 'precision': { - 'amount': undefined, - 'price': undefined, - }, - // overrided by defaults from this.options['limits'] - 'limits': { - 'amount': { 'min': undefined, 'max': undefined }, - 'price': { 'min': undefined, 'max': undefined }, - 'cost': { 'min': undefined, 'max': undefined }, - }, - 'info': market, - }, defaults)); - } - } - return result; - } - - parseTrade (trade, market = undefined) { - let symbol = undefined; - if (market !== undefined) { - symbol = market['symbol']; - } - const timestamp = this.safeTimestamp2 (trade, 'date', 'created'); - const id = this.safeString (trade, 'tid'); - const orderId = this.safeString (trade, 'order_id'); - const amount = this.safeFloat2 (trade, 'number', 'amount'); - const price = this.safeFloat (trade, 'price'); - let cost = undefined; - if (price !== undefined) { - if (amount !== undefined) { - cost = amount * price; - } - } - let side = this.safeString (trade, 'side'); - if (side === 'sale') { - side = 'sell'; - } - return { - 'info': trade, - 'id': id, - 'timestamp': timestamp, - 'datetime': this.iso8601 (timestamp), - 'symbol': symbol, - 'type': undefined, - 'side': side, - 'price': price, - 'amount': amount, - 'cost': cost, - 'order': orderId, - 'fee': undefined, - 'takerOrMaker': undefined, - }; - } - - async fetchTrades (symbol, since = undefined, limit = undefined, params = {}) { - await this.loadMarkets (); - const request = { - 'symbol': this.marketId (symbol), - }; - if (limit !== undefined) { - request['limit'] = limit; - } - const market = this.market (symbol); - const response = await this.publicPostApiOrderMarketOrder (this.extend (request, params)); - return this.parseTrades (response['data'], market, since, limit); - } - - async fetchBalance (params = {}) { - await this.loadMarkets (); - const response = await this.privatePostApiUserUserBalance (params); - const data = this.safeValue (response, 'data'); - let keys = Object.keys (data); - const result = { }; - for (let i = 0; i < keys.length; i++) { - const key = keys[i]; - const amount = this.safeFloat (data, key); - const parts = key.split ('_'); - const currencyId = parts[0]; - const lockOrOver = parts[1]; - const code = this.safeCurrencyCode (currencyId); - if (!(code in result)) { - result[code] = this.account (); - } - if (lockOrOver === 'lock') { - result[code]['used'] = parseFloat (amount); - } else { - result[code]['free'] = parseFloat (amount); - } - } - keys = Object.keys (result); - for (let i = 0; i < keys.length; i++) { - const key = keys[i]; - const total = this.sum (result[key]['used'], result[key]['free']); - result[key]['total'] = total; - } - result['info'] = data; - return this.parseBalance (result); - } - - async fetchTicker (symbol, params = {}) { - await this.loadMarkets (); - const market = this.markets[symbol]; - const request = { - 'part': market['quoteId'], - 'coin': market['baseId'], - }; - const response = await this.publicPostApiMarketGetCoinTrade (this.extend (request, params)); - const timestamp = this.milliseconds (); - return { - 'symbol': symbol, - 'timestamp': timestamp, - 'datetime': this.iso8601 (timestamp), - 'high': this.safeFloat (response, 'max'), - 'low': this.safeFloat (response, 'min'), - 'bid': this.safeFloat (response, 'buy'), - 'bidVolume': undefined, - 'ask': this.safeFloat (response, 'sale'), - 'askVolume': undefined, - 'vwap': undefined, - 'open': undefined, - 'close': this.safeFloat (response, 'price'), - 'last': this.safeFloat (response, 'price'), - 'previousClose': undefined, - 'change': undefined, - 'percentage': this.safeFloat (response, 'change_24h'), - 'average': undefined, - 'baseVolume': this.safeFloat (response, 'volume_24h'), - 'quoteVolume': undefined, - 'info': response, - }; - } - - async fetchOrderBook (symbol, limit = undefined, params = {}) { - await this.loadMarkets (); - const marketId = this.marketId (symbol); - const request = { - 'symbol': marketId, - }; - const response = await this.publicPostApiOrderDepth (this.extend (request, params)); - const data = this.safeValue (response, 'data'); - const timestamp = this.safeTimestamp (data, 'date'); - return this.parseOrderBook (data, timestamp); - } - - async fetchMyTrades (symbol = undefined, since = undefined, limit = undefined, params = {}) { - await this.loadMarkets (); - const market = this.market (symbol); - const request = { - 'symbol': market['id'], - }; - const response = await this.privatePostApiOrderOrderList (this.extend (request, params)); - return this.parseTrades (response['data'], market, since, limit); - } - - parseOrderStatus (status) { - const statuses = { - '0': 'open', - '1': 'open', // partially filled - '2': 'closed', - '3': 'canceled', - }; - return this.safeString (statuses, status, status); - } - - async fetchOrder (id, symbol = undefined, params = {}) { - if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' fetchOrder requires a `symbol` argument'); - } - await this.loadMarkets (); - const request = { - 'symbol': this.marketId (symbol), - 'trust_id': id, - }; - const response = await this.privatePostApiOrderOrderInfo (this.extend (request, params)); - const order = this.safeValue (response, 'data'); - const timestamp = this.safeTimestamp (order, 'created'); - const status = this.parseOrderStatus (this.safeString (order, 'status')); - let side = this.safeString (order, 'flag'); - if (side === 'sale') { - side = 'sell'; - } - // Can't use parseOrder because the data format is different btw endpoint for fetchOrder and fetchOrders - return { - 'info': order, - 'id': id, - 'timestamp': timestamp, - 'datetime': this.iso8601 (timestamp), - 'lastTradeTimestamp': undefined, - 'symbol': symbol, - 'type': undefined, - 'side': side, - 'price': this.safeFloat (order, 'price'), - 'cost': undefined, - 'average': this.safeFloat (order, 'avg_price'), - 'amount': this.safeFloat (order, 'number'), - 'filled': this.safeFloat (order, 'numberdeal'), - 'remaining': this.safeFloat (order, 'numberover'), - 'status': status, - 'fee': undefined, - 'clientOrderId': undefined, - 'trades': undefined, - }; - } - - parseOrder (order, market = undefined) { - const id = this.safeString (order, 'id'); - const timestamp = this.safeTimestamp (order, 'datetime'); - let symbol = undefined; - if (market !== undefined) { - symbol = market['symbol']; - } - const type = undefined; - let side = this.safeString (order, 'type'); - if (side === 'sale') { - side = 'sell'; - } - const price = this.safeFloat (order, 'price'); - const average = this.safeFloat (order, 'avg_price'); - const amount = this.safeFloat (order, 'amount'); - const remaining = this.safeFloat (order, 'amount_outstanding'); - const filled = amount - remaining; - const status = this.parseOrderStatus (this.safeString (order, 'status')); - const cost = filled * price; - const fee = undefined; - const result = { - 'info': order, - 'id': id, - 'clientOrderId': undefined, - 'timestamp': timestamp, - 'datetime': this.iso8601 (timestamp), - 'lastTradeTimestamp': undefined, - 'symbol': symbol, - 'type': type, - 'timeInForce': undefined, - 'side': side, - 'price': price, - 'stopPrice': undefined, - 'cost': cost, - 'average': average, - 'amount': amount, - 'filled': filled, - 'remaining': remaining, - 'status': status, - 'fee': fee, - 'trades': undefined, - }; - return result; - } - - async fetchOrdersByType (type, symbol = undefined, since = undefined, limit = undefined, params = {}) { - await this.loadMarkets (); - const request = { - 'type': type, - }; - let market = undefined; - if (symbol !== undefined) { - market = this.market (symbol); - request['symbol'] = market['id']; - } - const response = await this.privatePostApiOrderTradeList (this.extend (request, params)); - if ('data' in response) { - return this.parseOrders (response['data'], market, since, limit); - } - return []; - } - - async fetchOpenOrders (symbol = undefined, since = undefined, limit = undefined, params = {}) { - return this.fetchOrdersByType ('open', symbol, since, limit, params); - } - - async fetchClosedOrders (symbol = undefined, since = undefined, limit = undefined, params = {}) { - const orders = await this.fetchOrders (symbol, since, limit, params); - return this.filterBy (orders, 'status', 'closed'); - } - - async fetchOrders (symbol = undefined, since = undefined, limit = undefined, params = {}) { - return this.fetchOrdersByType ('all', symbol, since, limit, params); - } - - async createOrder (symbol, type, side, amount, price = undefined, params = {}) { - await this.loadMarkets (); - const request = { - 'symbol': this.marketId (symbol), - 'type': side, - 'price': this.priceToPrecision (symbol, price), - 'number': this.amountToPrecision (symbol, amount), - }; - const response = await this.privatePostApiOrderCoinTrust (this.extend (request, params)); - const data = this.safeValue (response, 'data', {}); - const id = this.safeString (data, 'order_id'); - return { - 'info': response, - 'id': id, - }; - } - - async cancelOrder (id, symbol = undefined, params = {}) { - if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' cancelOrder requires a `symbol` argument'); - } - await this.loadMarkets (); - const request = {}; - if (symbol !== undefined) { - request['symbol'] = this.marketId (symbol); - } - if (id !== undefined) { - request['order_id'] = id; - } - return await this.privatePostApiOrderCancel (this.extend (request, params)); - } - - sign (path, api = 'public', method = 'GET', params = {}, headers = undefined, body = undefined) { - let url = this.urls['api'] + '/' + this.implodeParams (path, params); - const query = this.omit (params, this.extractParams (path)); - if (api === 'public') { - if (Object.keys (query).length) { - url += '?' + this.urlencode (query); - } - } else { - this.checkRequiredCredentials (); - let payload = this.urlencode ({ 'api_key': this.apiKey }); - if (Object.keys (query).length) { - payload += '&' + this.urlencode (this.keysort (query)); - } - const auth = payload + '&secret_key=' + this.secret; - const signature = this.hash (this.encode (auth)); - body = payload + '&sign=' + signature; - headers = { - 'Content-Type': 'application/x-www-form-urlencoded', - }; - } - return { 'url': url, 'method': method, 'body': body, 'headers': headers }; - } - - handleErrors (code, reason, url, method, headers, body, response, requestHeaders, requestBody) { - if (response === undefined) { - return; // fallback to default error handler - } - const errorCode = this.safeValue (response, 'code'); - if (errorCode !== undefined) { - if (errorCode !== 0) { - // - // { code: 1, msg: "该币不存在,非法操作" } - returned when a required symbol parameter is missing in the request (also, maybe on other types of errors as well) - // { code: 1, msg: '公钥不合法' } - wrong public key - // { code: 1, msg: '价格输入有误,请检查你的数值精度' } - 'The price input is incorrect, please check your numerical accuracy' - // { code: 1, msg: '单笔最小交易数量不能小于0.00100000,请您重新挂单'} - - // 'The minimum number of single transactions cannot be less than 0.00100000. Please re-post the order' - // - const message = this.safeString (response, 'msg'); - const feedback = this.id + ' ' + message; - this.throwExactlyMatchedException (this.exceptions, message, feedback); - if (message.indexOf ('请您重新挂单') >= 0) { // minimum limit - throw new InvalidOrder (feedback); - } else { - throw new ExchangeError (feedback); - } - } - } - } -}; - -},{"./base/Exchange":5,"./base/errors":7}],20:[function(require,module,exports){ +},{}],20:[function(require,module,exports){ 'use strict'; // --------------------------------------------------------------------------- @@ -5422,13 +6593,13 @@ module.exports = class bequant extends hitbtc { } }; -},{"./hitbtc":89}],21:[function(require,module,exports){ +},{"./hitbtc":93}],21:[function(require,module,exports){ 'use strict'; // --------------------------------------------------------------------------- const Exchange = require ('./base/Exchange'); -const { ExchangeError, AccountSuspended, ArgumentsRequired, AuthenticationError, DDoSProtection, ExchangeNotAvailable, InvalidOrder, OrderNotFound, PermissionDenied, InsufficientFunds, BadSymbol } = require ('./base/errors'); +const { ExchangeError, AccountSuspended, ArgumentsRequired, AuthenticationError, DDoSProtection, ExchangeNotAvailable, InvalidOrder, OrderNotFound, PermissionDenied, InsufficientFunds, BadSymbol, RateLimitExceeded, BadRequest } = require ('./base/errors'); // --------------------------------------------------------------------------- @@ -5496,6 +6667,7 @@ module.exports = class bibox extends Exchange { 'get': [ 'cquery', 'mdata', + 'cdata', ], }, 'private': { @@ -5533,9 +6705,16 @@ module.exports = class bibox extends Exchange { '2021': InsufficientFunds, // Insufficient balance available for withdrawal '2027': InsufficientFunds, // Insufficient balance available (for trade) '2033': OrderNotFound, // operation failed! Orders have been completed or revoked + '2065': InvalidOrder, // Precatory price is exorbitant, please reset + '2066': InvalidOrder, // Precatory price is low, please reset '2067': InvalidOrder, // Does not support market orders '2068': InvalidOrder, // The number of orders can not be less than + '2078': InvalidOrder, // unvalid order price '2085': InvalidOrder, // Order quantity is too small + '2091': RateLimitExceeded, // request is too frequency, please try again later + '2092': InvalidOrder, // Minimum amount not met + '3000': BadRequest, // Requested parameter incorrect + '3002': BadRequest, // Parameter cannot be null '3012': AuthenticationError, // invalid apiKey '3016': BadSymbol, // Trading pair error '3024': PermissionDenied, // wrong apikey permissions @@ -5549,6 +6728,10 @@ module.exports = class bibox extends Exchange { 'KEY': 'Bihu', 'MTC': 'MTC Mesh Network', // conflict with MTC Docademic doc.com Token https://github.com/ccxt/ccxt/issues/6081 https://github.com/ccxt/ccxt/issues/3025 'PAI': 'PCHAIN', + 'TERN': 'Ternio-ERC20', + }, + 'options': { + 'fetchCurrencies': 'fetch_currencies_public', // or 'fetch_currencies_private' with apiKey and secret }, }); } @@ -5848,6 +7031,78 @@ module.exports = class bibox extends Exchange { } async fetchCurrencies (params = {}) { + const method = this.safeString (this.options, 'fetchCurrencies', 'fetch_currencies_public'); + return await this[method] (params); + } + + async fetchCurrenciesPublic (params = {}) { + const request = { + 'cmd': 'currencies', + }; + const response = await this.publicGetCdata (this.extend (request, params)); + // + // publicGetCdata + // + // { + // "result":[ + // { + // "symbol":"BTC", + // "name":"BTC", + // "valid_decimals":8, + // "original_decimals":8, + // "is_erc20":0, + // "enable_withdraw":1, + // "enable_deposit":1, + // "withdraw_min":0.005, + // "describe_summary":"[{\"lang\":\"zh-cn\",\"text\":\"Bitcoin 比特币的概念最初由中本聪在2009年提出,是点对点的基于 SHA-256 算法的一种P2P形式的数字货币,点对点的传输意味着一个去中心化的支付系统。\"},{\"lang\":\"en-ww\",\"text\":\"Bitcoin is a digital asset and a payment system invented by Satoshi Nakamoto who published a related paper in 2008 and released it as open-source software in 2009. The system featured as peer-to-peer; users can transact directly without an intermediary.\"}]" + // } + // ], + // "cmd":"currencies" + // } + // + const currencies = this.safeValue (response, 'result'); + const result = {}; + for (let i = 0; i < currencies.length; i++) { + const currency = currencies[i]; + const id = this.safeString (currency, 'symbol'); + const name = this.safeString (currency, 'name'); // contains hieroglyphs causing python ASCII bug + const code = this.safeCurrencyCode (id); + const precision = this.safeInteger (currency, 'valid_decimals'); + const deposit = this.safeValue (currency, 'enable_deposit'); + const withdraw = this.safeValue (currency, 'enable_withdraw'); + const active = (deposit && withdraw); + result[code] = { + 'id': id, + 'code': code, + 'info': currency, + 'name': name, + 'active': active, + 'fee': undefined, + 'precision': precision, + 'limits': { + 'amount': { + 'min': Math.pow (10, -precision), + 'max': undefined, + }, + 'price': { + 'min': Math.pow (10, -precision), + 'max': undefined, + }, + 'cost': { + 'min': undefined, + 'max': undefined, + }, + 'withdraw': { + 'min': this.safeFloat (currency, 'withdraw_min'), + 'max': undefined, + }, + }, + }; + } + return result; + } + + async fetchCurrenciesPrivate (params = {}) { if (!this.apiKey || !this.secret) { throw new AuthenticationError (this.id + " fetchCurrencies is an authenticated endpoint, therefore it requires 'apiKey' and 'secret' credentials. If you don't need currency details, set exchange.has['fetchCurrencies'] = false before calling its methods."); } @@ -5860,46 +7115,42 @@ module.exports = class bibox extends Exchange { // { // "result":[ // { - // "result":[ - // { - // "totalBalance":"14.57582269", - // "balance":"14.57582269", - // "freeze":"0.00000000", - // "id":60, - // "symbol":"USDT", - // "icon_url":"/appimg/USDT_icon.png", - // "describe_url":"[{\"lang\":\"zh-cn\",\"link\":\"https://bibox.zendesk.com/hc/zh-cn/articles/115004798234\"},{\"lang\":\"en-ww\",\"link\":\"https://bibox.zendesk.com/hc/en-us/articles/115004798234\"}]", - // "name":"USDT", - // "enable_withdraw":1, - // "enable_deposit":1, - // "enable_transfer":1, - // "confirm_count":2, - // "is_erc20":1, - // "forbid_info":null, - // "describe_summary":"[{\"lang\":\"zh-cn\",\"text\":\"USDT 是 Tether 公司推出的基于稳定价值货币美元(USD)的代币 Tether USD(简称USDT),1USDT=1美元,用户可以随时使用 USDT 与 USD 进行1:1的兑换。\"},{\"lang\":\"en-ww\",\"text\":\"USDT is a cryptocurrency asset issued on the Bitcoin blockchain via the Omni Layer Protocol. Each USDT unit is backed by a U.S Dollar held in the reserves of the Tether Limited and can be redeemed through the Tether Platform.\"}]", - // "total_amount":4776930644, - // "supply_amount":4642367414, - // "price":"--", - // "contract_father":"OMNI", - // "supply_time":"--", - // "comment":null, - // "contract":"31", - // "original_decimals":8, - // "deposit_type":0, - // "hasCobo":0, - // "BTCValue":"0.00126358", - // "CNYValue":"100.93381445", - // "USDValue":"14.57524654", - // "children":[ - // {"type":"OMNI","symbol":"USDT","enable_deposit":1,"enable_withdraw":1,"confirm_count":2}, - // {"type":"TRC20","symbol":"tUSDT","enable_deposit":1,"enable_withdraw":1,"confirm_count":20}, - // {"type":"ERC20","symbol":"eUSDT","enable_deposit":1,"enable_withdraw":1,"confirm_count":25} - // ] - // }, - // ], - // "cmd":"transfer/coinList" - // } - // ] + // "totalBalance":"14.57582269", + // "balance":"14.57582269", + // "freeze":"0.00000000", + // "id":60, + // "symbol":"USDT", + // "icon_url":"/appimg/USDT_icon.png", + // "describe_url":"[{\"lang\":\"zh-cn\",\"link\":\"https://bibox.zendesk.com/hc/zh-cn/articles/115004798234\"},{\"lang\":\"en-ww\",\"link\":\"https://bibox.zendesk.com/hc/en-us/articles/115004798234\"}]", + // "name":"USDT", + // "enable_withdraw":1, + // "enable_deposit":1, + // "enable_transfer":1, + // "confirm_count":2, + // "is_erc20":1, + // "forbid_info":null, + // "describe_summary":"[{\"lang\":\"zh-cn\",\"text\":\"USDT 是 Tether 公司推出的基于稳定价值货币美元(USD)的代币 Tether USD(简称USDT),1USDT=1美元,用户可以随时使用 USDT 与 USD 进行1:1的兑换。\"},{\"lang\":\"en-ww\",\"text\":\"USDT is a cryptocurrency asset issued on the Bitcoin blockchain via the Omni Layer Protocol. Each USDT unit is backed by a U.S Dollar held in the reserves of the Tether Limited and can be redeemed through the Tether Platform.\"}]", + // "total_amount":4776930644, + // "supply_amount":4642367414, + // "price":"--", + // "contract_father":"OMNI", + // "supply_time":"--", + // "comment":null, + // "contract":"31", + // "original_decimals":8, + // "deposit_type":0, + // "hasCobo":0, + // "BTCValue":"0.00126358", + // "CNYValue":"100.93381445", + // "USDValue":"14.57524654", + // "children":[ + // {"type":"OMNI","symbol":"USDT","enable_deposit":1,"enable_withdraw":1,"confirm_count":2}, + // {"type":"TRC20","symbol":"tUSDT","enable_deposit":1,"enable_withdraw":1,"confirm_count":20}, + // {"type":"ERC20","symbol":"eUSDT","enable_deposit":1,"enable_withdraw":1,"confirm_count":25} + // ] + // }, + // ], + // "cmd":"transfer/coinList" // } // const currencies = this.safeValue (response, 'result'); @@ -6224,6 +7475,7 @@ module.exports = class bibox extends Exchange { 'symbol': symbol, 'type': type, 'timeInForce': undefined, + 'postOnly': undefined, 'side': side, 'price': price, 'stopPrice': undefined, @@ -6276,7 +7528,7 @@ module.exports = class bibox extends Exchange { async fetchClosedOrders (symbol = undefined, since = undefined, limit = 200, params = {}) { if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' fetchClosedOrders requires a `symbol` argument'); + throw new ArgumentsRequired (this.id + ' fetchClosedOrders() requires a `symbol` argument'); } await this.loadMarkets (); const market = this.market (symbol); @@ -6296,7 +7548,7 @@ module.exports = class bibox extends Exchange { async fetchMyTrades (symbol = undefined, since = undefined, limit = undefined, params = {}) { if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' fetchMyTrades requires a `symbol` argument'); + throw new ArgumentsRequired (this.id + ' fetchMyTrades() requires a `symbol` argument'); } await this.loadMarkets (); const market = this.market (symbol); @@ -6423,7 +7675,7 @@ module.exports = class bibox extends Exchange { } } else if (api === 'v2private') { this.checkRequiredCredentials (); - url = this.urls['api'] + '/v2/' + path; + url = this.implodeParams (this.urls['api'], { 'hostname': this.hostname }) + '/v2/' + path; const json_params = this.json (params); body = { 'body': json_params, @@ -6473,7 +7725,7 @@ module.exports = class bibox extends Exchange { } }; -},{"./base/Exchange":5,"./base/errors":7}],22:[function(require,module,exports){ +},{"./base/Exchange":6,"./base/errors":8}],22:[function(require,module,exports){ 'use strict'; // --------------------------------------------------------------------------- @@ -6554,6 +7806,7 @@ module.exports = class bigone extends Exchange { 'private': { 'get': [ 'accounts', + 'fund/accounts', 'assets/{asset_symbol}/address', 'orders', 'orders/{id}', @@ -6567,6 +7820,7 @@ module.exports = class bigone extends Exchange { 'orders/{id}/cancel', 'orders/cancel', 'withdrawals', + 'transfer', ], }, }, @@ -7121,7 +8375,10 @@ module.exports = class bigone extends Exchange { async fetchBalance (params = {}) { await this.loadMarkets (); - const response = await this.privateGetAccounts (params); + const type = this.safeString (params, 'type', ''); + params = this.omit (params, 'type'); + const method = 'privateGet' + this.capitalize (type) + 'Accounts'; + const response = await this[method] (params); // // { // "code":0, @@ -7197,6 +8454,7 @@ module.exports = class bigone extends Exchange { 'symbol': symbol, 'type': undefined, 'timeInForce': undefined, + 'postOnly': undefined, 'side': side, 'price': price, 'stopPrice': undefined, @@ -7234,7 +8492,7 @@ module.exports = class bigone extends Exchange { if (isStopLimit || isStopMarket) { const stopPrice = this.safeFloat2 (params, 'stop_price', 'stopPrice'); if (stopPrice === undefined) { - throw new ArgumentsRequired (this.id + ' createOrder requires a stop_price parameter'); + throw new ArgumentsRequired (this.id + ' createOrder() requires a stop_price parameter'); } request['stop_price'] = this.priceToPrecision (symbol, stopPrice); params = this.omit (params, [ 'stop_price', 'stopPrice' ]); @@ -7742,13 +9000,13 @@ module.exports = class bigone extends Exchange { } }; -},{"./base/Exchange":5,"./base/errors":7}],23:[function(require,module,exports){ +},{"./base/Exchange":6,"./base/errors":8}],23:[function(require,module,exports){ 'use strict'; // --------------------------------------------------------------------------- const Exchange = require ('./base/Exchange'); -const { ExchangeError, ArgumentsRequired, ExchangeNotAvailable, InsufficientFunds, OrderNotFound, InvalidOrder, DDoSProtection, InvalidNonce, AuthenticationError, InvalidAddress, RateLimitExceeded, PermissionDenied, NotSupported, BadRequest, BadSymbol, AccountSuspended, OrderImmediatelyFillable } = require ('./base/errors'); +const { ExchangeError, ArgumentsRequired, ExchangeNotAvailable, InsufficientFunds, OrderNotFound, InvalidOrder, DDoSProtection, InvalidNonce, AuthenticationError, RateLimitExceeded, PermissionDenied, NotSupported, BadRequest, BadSymbol, AccountSuspended, OrderImmediatelyFillable } = require ('./base/errors'); const { ROUND, TRUNCATE } = require ('./base/functions/number'); // --------------------------------------------------------------------------- @@ -7768,6 +9026,7 @@ module.exports = class binance extends Exchange { 'cancelOrder': true, 'CORS': false, 'createOrder': true, + 'fetchCurrencies': true, 'fetchBalance': true, 'fetchBidsAsks': true, 'fetchClosedOrders': 'emulated', @@ -7858,6 +9117,7 @@ module.exports = class binance extends Exchange { 'margin/priceIndex', // these endpoints require this.apiKey + this.secret 'asset/assetDividend', + 'asset/transfer', 'margin/loan', 'margin/repay', 'margin/account', @@ -7899,6 +9159,7 @@ module.exports = class binance extends Exchange { 'sub-account/spotSummary', 'sub-account/status', 'sub-account/transfer/subUserHistory', + 'sub-account/universalTransfer', // lending endpoints 'lending/daily/product/list', 'lending/daily/userLeftQuota', @@ -7924,9 +9185,23 @@ module.exports = class binance extends Exchange { 'bswap/liquidityOps', 'bswap/quote', 'bswap/swap', + // leveraged token endpoints + 'blvt/tokenInfo', + 'blvt/subscribe/record', + 'blvt/redeem/record', + 'blvt/userLimit', + // broker api + 'apiReferral/ifNewUser', + 'apiReferral/customization', + 'apiReferral/userCustomization', + 'apiReferral/rebate/recentRecord', + 'apiReferral/rebate/historicalRecord', + 'apiReferral/kickback/recentRecord', + 'apiReferral/kickback/historicalRecord', ], 'post': [ 'asset/dust', + 'asset/transfer', 'account/disableFastWithdrawSwitch', 'account/enableFastWithdrawSwitch', 'capital/withdraw/apply', @@ -7944,6 +9219,7 @@ module.exports = class binance extends Exchange { 'sub-account/futures/internalTransfer', 'sub-account/transfer/subToSub', 'sub-account/transfer/subToMaster', + 'sub-account/universalTransfer', 'userDataStream', 'userDataStream/isolated', 'futures/transfer', @@ -7958,12 +9234,21 @@ module.exports = class binance extends Exchange { 'bswap/liquidityAdd', 'bswap/liquidityRemove', 'bswap/swap', + // leveraged token endpoints + 'blvt/subscribe', + 'blvt/redeem', + // broker api + 'apiReferral/customization', + 'apiReferral/userCustomization', + 'apiReferral/rebate/historicalRecord', + 'apiReferral/kickback/historicalRecord', ], 'put': [ 'userDataStream', 'userDataStream/isolated', ], 'delete': [ + 'margin/openOrders', 'margin/order', 'userDataStream', 'userDataStream/isolated', @@ -8068,6 +9353,7 @@ module.exports = class binance extends Exchange { 'historicalTrades', 'aggTrades', 'klines', + 'continuousKlines', 'fundingRate', 'premiumIndex', 'ticker/24hr', @@ -8102,6 +9388,15 @@ module.exports = class binance extends Exchange { 'positionSide/dual', 'userTrades', 'income', + // broker endpoints + 'apiReferral/ifNewUser', + 'apiReferral/customization', + 'apiReferral/userCustomization', + 'apiReferral/traderNum', + 'apiReferral/overview', + 'apiReferral/tradeVol', + 'apiReferral/rebateVol', + 'apiReferral/traderSummary', ], 'post': [ 'batchOrders', @@ -8112,6 +9407,9 @@ module.exports = class binance extends Exchange { 'leverage', 'listenKey', 'countdownCancelAll', + // broker endpoints + 'apiReferral/customization', + 'apiReferral/userCustomization', ], 'put': [ 'listenKey', @@ -8191,6 +9489,7 @@ module.exports = class binance extends Exchange { }, // exchange-specific options 'options': { + 'fetchCurrencies': false, // this is a private call and it requires API keys // 'fetchTradesMethod': 'publicGetAggTrades', // publicGetTrades, publicGetHistoricalTrades 'defaultTimeInForce': 'GTC', // 'GTC' = Good To Cancel (default), 'IOC' = Immediate Or Cancel 'defaultType': 'spot', // 'spot', 'future', 'margin', 'delivery' @@ -8205,11 +9504,20 @@ module.exports = class binance extends Exchange { 'limit': 'RESULT', // we change it from 'ACK' by default to 'RESULT' }, 'quoteOrderQty': true, // whether market orders support amounts in quote currency + 'broker': { + 'spot': 'x-R4BD3S82', + 'margin': 'x-R4BD3S82', + 'future': 'x-xcKtGhcu', + 'delivery': 'x-xcKtGhcu', + }, }, // https://binance-docs.github.io/apidocs/spot/en/#error-codes-2 'exceptions': { + 'System abnormality': ExchangeError, // {"code":-1000,"msg":"System abnormality"} + 'You are not authorized to execute this request.': PermissionDenied, // {"msg":"You are not authorized to execute this request."} 'API key does not exist': AuthenticationError, 'Order would trigger immediately.': OrderImmediatelyFillable, + 'Stop price would trigger immediately.': OrderImmediatelyFillable, // {"code":-2010,"msg":"Stop price would trigger immediately."} 'Order would immediately match and take.': OrderImmediatelyFillable, // {"code":-2010,"msg":"Order would immediately match and take."} 'Account has insufficient balance for requested action.': InsufficientFunds, 'Rest API trading is not enabled.': ExchangeNotAvailable, @@ -8253,14 +9561,21 @@ module.exports = class binance extends Exchange { '-2013': OrderNotFound, // fetchOrder (1, 'BTC/USDT') -> 'Order does not exist' '-2014': AuthenticationError, // { "code":-2014, "msg": "API-key format invalid." } '-2015': AuthenticationError, // "Invalid API-key, IP, or permissions for action." + '-2019': InsufficientFunds, // {"code":-2019,"msg":"Margin is insufficient."} '-3005': InsufficientFunds, // {"code":-3005,"msg":"Transferring out not allowed. Transfer out amount exceeds max amount."} '-3008': InsufficientFunds, // {"code":-3008,"msg":"Borrow not allowed. Your borrow amount has exceed maximum borrow amount."} '-3010': ExchangeError, // {"code":-3010,"msg":"Repay not allowed. Repay amount exceeds borrow amount."} '-3022': AccountSuspended, // You account's trading is banned. + '-4028': BadRequest, // {"code":-4028,"msg":"Leverage 100 is not valid"} + '-5013': InsufficientFunds, // Asset transfer failed: insufficient balance" }, }); } + currencyToPrecision (currency, fee) { + return this.numberToString (fee); + } + nonce () { return this.milliseconds () - this.options['timeDifference']; } @@ -8284,6 +9599,145 @@ module.exports = class binance extends Exchange { return this.options['timeDifference']; } + async fetchCurrencies (params = {}) { + const fetchCurrenciesEnabled = this.safeValue (this.options, 'fetchCurrencies'); + if (!fetchCurrenciesEnabled) { + return undefined; + } + // this endpoint requires authentication + // while fetchCurrencies is a public API method by design + // therefore we check the keys here + // and fallback to generating the currencies from the markets + if (!this.checkRequiredCredentials (false)) { + return undefined; + } + // sandbox/testnet does not support sapi endpoints + const apiBackup = this.safeString (this.urls, 'apiBackup'); + if (apiBackup !== undefined) { + return undefined; + } + const response = await this.sapiGetCapitalConfigGetall (params); + const result = {}; + for (let i = 0; i < response.length; i++) { + // + // { + // coin: 'LINK', + // depositAllEnable: true, + // withdrawAllEnable: true, + // name: 'ChainLink', + // free: '0.06168', + // locked: '0', + // freeze: '0', + // withdrawing: '0', + // ipoing: '0', + // ipoable: '0', + // storage: '0', + // isLegalMoney: false, + // trading: true, + // networkList: [ + // { + // network: 'BNB', + // coin: 'LINK', + // withdrawIntegerMultiple: '0', + // isDefault: false, + // depositEnable: true, + // withdrawEnable: true, + // depositDesc: '', + // withdrawDesc: '', + // specialTips: 'Both a MEMO and an Address are required to successfully deposit your LINK BEP2 tokens to Binance.', + // name: 'BEP2', + // resetAddressStatus: false, + // addressRegex: '^(bnb1)[0-9a-z]{38}$', + // memoRegex: '^[0-9A-Za-z\\-_]{1,120}$', + // withdrawFee: '0.002', + // withdrawMin: '0.01', + // withdrawMax: '9999999', + // minConfirm: 1, + // unLockConfirm: 0 + // }, + // { + // network: 'BSC', + // coin: 'LINK', + // withdrawIntegerMultiple: '0.00000001', + // isDefault: false, + // depositEnable: true, + // withdrawEnable: true, + // depositDesc: '', + // withdrawDesc: '', + // specialTips: '', + // name: 'BEP20 (BSC)', + // resetAddressStatus: false, + // addressRegex: '^(0x)[0-9A-Fa-f]{40}$', + // memoRegex: '', + // withdrawFee: '0.005', + // withdrawMin: '0.01', + // withdrawMax: '9999999', + // minConfirm: 15, + // unLockConfirm: 0 + // }, + // { + // network: 'ETH', + // coin: 'LINK', + // withdrawIntegerMultiple: '0.00000001', + // isDefault: true, + // depositEnable: true, + // withdrawEnable: true, + // depositDesc: '', + // withdrawDesc: '', + // name: 'ERC20', + // resetAddressStatus: false, + // addressRegex: '^(0x)[0-9A-Fa-f]{40}$', + // memoRegex: '', + // withdrawFee: '0.34', + // withdrawMin: '0.68', + // withdrawMax: '0', + // minConfirm: 12, + // unLockConfirm: 0 + // } + // ] + // } + // + const entry = response[i]; + const id = this.safeString (entry, 'coin'); + const name = this.safeString (entry, 'name'); + const code = this.safeCurrencyCode (id); + const precision = undefined; + let isWithdrawEnabled = true; + let isDepositEnabled = true; + const networkList = this.safeValue (entry, 'networkList', []); + const fees = {}; + let fee = undefined; + for (let j = 0; j < networkList.length; j++) { + const networkItem = networkList[j]; + const name = this.safeString (networkItem, 'name'); + const withdrawFee = this.safeFloat (networkItem, 'withdrawFee'); + const depositEnable = this.safeValue (networkItem, 'depositEnable'); + const withdrawEnable = this.safeValue (networkItem, 'withdrawEnable'); + isDepositEnabled = isDepositEnabled || depositEnable; + isWithdrawEnabled = isWithdrawEnabled || withdrawEnable; + fees[name] = withdrawFee; + const isDefault = this.safeValue (networkItem, 'isDefault'); + if (isDefault || fee === undefined) { + fee = withdrawFee; + } + } + const trading = this.safeValue (entry, 'trading'); + const active = (isWithdrawEnabled && isDepositEnabled && trading); + result[code] = { + 'id': id, + 'name': name, + 'code': code, + 'precision': precision, + 'info': entry, + 'active': active, + 'fee': fee, + 'fees': fees, + 'limits': this.limits, + }; + } + return result; + } + async fetchMarkets (params = {}) { const defaultType = this.safeString2 (this.options, 'fetchMarkets', 'defaultType', 'spot'); const type = this.safeString (params, 'type', defaultType); @@ -8460,9 +9914,8 @@ module.exports = class binance extends Exchange { const quoteId = this.safeString (market, 'quoteAsset'); const base = this.safeCurrencyCode (baseId); const quote = this.safeCurrencyCode (quoteId); - const parts = id.split ('_'); - const lastPart = this.safeString (parts, 1); - const idSymbol = (delivery) && (lastPart !== 'PERP'); + const contractType = this.safeString (market, 'contractType'); + const idSymbol = (future || delivery) && (contractType !== 'PERPETUAL'); const symbol = idSymbol ? id : (base + '/' + quote); const filters = this.safeValue (market, 'filters', []); const filtersByType = this.indexBy (filters, 'filterType'); @@ -8540,7 +9993,7 @@ module.exports = class binance extends Exchange { } if ('MIN_NOTIONAL' in filtersByType) { const filter = this.safeValue (filtersByType, 'MIN_NOTIONAL', {}); - entry['limits']['cost']['min'] = this.safeFloat (filter, 'minNotional'); + entry['limits']['cost']['min'] = this.safeFloat2 (filter, 'minNotional', 'notional'); } result.push (entry); } @@ -8942,15 +10395,24 @@ module.exports = class binance extends Exchange { async fetchOHLCV (symbol, timeframe = '1m', since = undefined, limit = undefined, params = {}) { await this.loadMarkets (); const market = this.market (symbol); + // binance docs say that the default limit 500, max 1500 for futures, max 1000 for spot markets + // the reality is that the time range wider than 500 candles won't work right + const defaultLimit = 500; + const maxLimit = 1500; + limit = (limit === undefined) ? defaultLimit : Math.min (limit, maxLimit); const request = { 'symbol': market['id'], 'interval': this.timeframes[timeframe], + 'limit': limit, }; + const duration = this.parseTimeframe (timeframe); if (since !== undefined) { request['startTime'] = since; - } - if (limit !== undefined) { - request['limit'] = limit; // default == max == 500 + if (since > 0) { + const endTime = this.sum (since, limit * duration * 1000 - 1); + const now = this.milliseconds (); + request['endTime'] = Math.min (now, endTime); + } } let method = 'publicGetKlines'; if (market['future']) { @@ -9038,6 +10500,23 @@ module.exports = class binance extends Exchange { // "symbol": "BTCUSDT", // "time": 1569514978020 // } + // { + // "symbol": "BTCUSDT", + // "id": 477128891, + // "orderId": 13809777875, + // "side": "SELL", + // "price": "38479.55", + // "qty": "0.001", + // "realizedPnl": "-0.00009534", + // "marginAsset": "USDT", + // "quoteQty": "38.47955", + // "commission": "-0.00076959", + // "commissionAsset": "USDT", + // "time": 1612733566708, + // "positionSide": "BOTH", + // "maker": true, + // "buyer": false + // } // const timestamp = this.safeInteger2 (trade, 'T', 'time'); const price = this.safeFloat2 (trade, 'p', 'price'); @@ -9067,6 +10546,9 @@ module.exports = class binance extends Exchange { if ('isMaker' in trade) { takerOrMaker = trade['isMaker'] ? 'maker' : 'taker'; } + if ('maker' in trade) { + takerOrMaker = trade['maker'] ? 'maker' : 'taker'; + } const marketId = this.safeString (trade, 'symbol'); const symbol = this.safeSymbol (marketId, market); let cost = undefined; @@ -9184,7 +10666,7 @@ module.exports = class binance extends Exchange { 'CANCELED': 'canceled', 'PENDING_CANCEL': 'canceling', // currently unused 'REJECTED': 'rejected', - 'EXPIRED': 'canceled', + 'EXPIRED': 'expired', }; return this.safeString (statuses, status, status); } @@ -9310,6 +10792,8 @@ module.exports = class binance extends Exchange { } const clientOrderId = this.safeString (order, 'clientOrderId'); const timeInForce = this.safeString (order, 'timeInForce'); + const postOnly = (type === 'limit_maker') || (timeInForce === 'GTX'); + const stopPrice = this.safeFloat (order, 'stopPrice'); return { 'info': order, 'id': id, @@ -9320,8 +10804,10 @@ module.exports = class binance extends Exchange { 'symbol': symbol, 'type': type, 'timeInForce': timeInForce, + 'postOnly': postOnly, 'side': side, 'price': price, + 'stopPrice': stopPrice, 'amount': amount, 'cost': cost, 'average': average, @@ -9366,7 +10852,15 @@ module.exports = class binance extends Exchange { 'type': uppercaseType, 'side': side.toUpperCase (), }; - if (clientOrderId !== undefined) { + if (clientOrderId === undefined) { + const broker = this.safeValue (this.options, 'broker'); + if (broker) { + const brokerId = this.safeString (broker, orderType); + if (brokerId !== undefined) { + request['newClientOrderId'] = brokerId + this.uuid22 (); + } + } + } else { request['newClientOrderId'] = clientOrderId; } if (market['spot']) { @@ -9445,7 +10939,7 @@ module.exports = class binance extends Exchange { quantityIsRequired = true; const callbackRate = this.safeFloat (params, 'callbackRate'); if (callbackRate === undefined) { - throw new InvalidOrder (this.id + ' createOrder method requires a callbackRate extra param for a ' + type + ' order'); + throw new InvalidOrder (this.id + ' createOrder() requires a callbackRate extra param for a ' + type + ' order'); } } if (quantityIsRequired) { @@ -9453,7 +10947,7 @@ module.exports = class binance extends Exchange { } if (priceIsRequired) { if (price === undefined) { - throw new InvalidOrder (this.id + ' createOrder method requires a price argument for a ' + type + ' order'); + throw new InvalidOrder (this.id + ' createOrder() requires a price argument for a ' + type + ' order'); } request['price'] = this.priceToPrecision (symbol, price); } @@ -9463,7 +10957,7 @@ module.exports = class binance extends Exchange { if (stopPriceIsRequired) { const stopPrice = this.safeFloat (params, 'stopPrice'); if (stopPrice === undefined) { - throw new InvalidOrder (this.id + ' createOrder method requires a stopPrice extra param for a ' + type + ' order'); + throw new InvalidOrder (this.id + ' createOrder() requires a stopPrice extra param for a ' + type + ' order'); } else { params = this.omit (params, 'stopPrice'); request['stopPrice'] = this.priceToPrecision (symbol, stopPrice); @@ -9475,7 +10969,7 @@ module.exports = class binance extends Exchange { async fetchOrder (id, symbol = undefined, params = {}) { if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' fetchOrder requires a symbol argument'); + throw new ArgumentsRequired (this.id + ' fetchOrder() requires a symbol argument'); } await this.loadMarkets (); const market = this.market (symbol); @@ -9496,7 +10990,7 @@ module.exports = class binance extends Exchange { if (clientOrderId !== undefined) { request['origClientOrderId'] = clientOrderId; } else { - request['orderId'] = parseInt (id); + request['orderId'] = id; } const query = this.omit (params, [ 'type', 'clientOrderId', 'origClientOrderId' ]); const response = await this[method] (this.extend (request, query)); @@ -9505,7 +10999,7 @@ module.exports = class binance extends Exchange { async fetchOrders (symbol = undefined, since = undefined, limit = undefined, params = {}) { if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' fetchOrders requires a symbol argument'); + throw new ArgumentsRequired (this.id + ' fetchOrders() requires a symbol argument'); } await this.loadMarkets (); const market = this.market (symbol); @@ -9618,7 +11112,7 @@ module.exports = class binance extends Exchange { async cancelOrder (id, symbol = undefined, params = {}) { if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' cancelOrder requires a symbol argument'); + throw new ArgumentsRequired (this.id + ' cancelOrder() requires a symbol argument'); } await this.loadMarkets (); const market = this.market (symbol); @@ -9628,11 +11122,11 @@ module.exports = class binance extends Exchange { const origClientOrderId = this.safeValue2 (params, 'origClientOrderId', 'clientOrderId'); const request = { 'symbol': market['id'], - // 'orderId': parseInt (id), + // 'orderId': id, // 'origClientOrderId': id, }; if (origClientOrderId === undefined) { - request['orderId'] = parseInt (id); + request['orderId'] = id; } else { request['origClientOrderId'] = origClientOrderId; } @@ -9651,7 +11145,7 @@ module.exports = class binance extends Exchange { async cancelAllOrders (symbol = undefined, params = {}) { if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' cancelAllOrders requires a symbol argument'); + throw new ArgumentsRequired (this.id + ' cancelAllOrders() requires a symbol argument'); } await this.loadMarkets (); const market = this.market (symbol); @@ -9662,7 +11156,9 @@ module.exports = class binance extends Exchange { const type = this.safeString (params, 'type', defaultType); const query = this.omit (params, 'type'); let method = 'privateDeleteOpenOrders'; - if (type === 'future') { + if (type === 'margin') { + method = 'sapiDeleteMarginOpenOrders'; + } else if (type === 'future') { method = 'fapiPrivateDeleteAllOpenOrders'; } else if (type === 'delivery') { method = 'dapiPrivateDeleteAllOpenOrders'; @@ -9728,20 +11224,23 @@ module.exports = class binance extends Exchange { async fetchMyTrades (symbol = undefined, since = undefined, limit = undefined, params = {}) { if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' fetchMyTrades requires a symbol argument'); + throw new ArgumentsRequired (this.id + ' fetchMyTrades() requires a symbol argument'); } await this.loadMarkets (); const market = this.market (symbol); - const type = this.safeValue (params, 'type', market['type']); + const defaultType = this.safeString2 (this.options, 'fetchMyTrades', 'defaultType', market['type']); + const type = this.safeString (params, 'type', defaultType); + params = this.omit (params, 'type'); let method = undefined; if (type === 'spot') { method = 'privateGetMyTrades'; + } else if (type === 'margin') { + method = 'sapiGetMarginMyTrades'; } else if (type === 'future') { method = 'fapiPrivateGetUserTrades'; } else if (type === 'delivery') { method = 'dapiPrivateGetUserTrades'; } - params = this.omit (params, 'type'); const request = { 'symbol': market['id'], }; @@ -10025,7 +11524,10 @@ module.exports = class binance extends Exchange { tag = undefined; } } - const txid = this.safeString (transaction, 'txId'); + let txid = this.safeString (transaction, 'txId'); + if ((txid !== undefined) && (txid.indexOf ('Internal transfer ') >= 0)) { + txid = txid.slice (18); + } const currencyId = this.safeString (transaction, 'asset'); const code = this.safeCurrencyCode (currencyId, currency); let timestamp = undefined; @@ -10074,15 +11576,27 @@ module.exports = class binance extends Exchange { await this.loadMarkets (); const currency = this.currency (code); const request = { - 'asset': currency['id'], + 'coin': currency['id'], + // 'network': 'ETH', // 'BSC', 'XMR', you can get network and isDefault in networkList in the response of sapiGetCapitalConfigDetail }; - const response = await this.wapiGetDepositAddress (this.extend (request, params)); - const success = this.safeValue (response, 'success'); - if ((success === undefined) || !success) { - throw new InvalidAddress (this.id + ' fetchDepositAddress returned an empty response – create the deposit address in the user settings first.'); - } + // has support for the 'network' parameter + // https://binance-docs.github.io/apidocs/spot/en/#deposit-address-supporting-network-user_data + const response = await this.sapiGetCapitalDepositAddress (this.extend (request, params)); + // + // { + // currency: 'XRP', + // address: 'rEb8TK3gBgk5auZkwc6sHnwrGVJH8DuaLh', + // tag: '108618262', + // info: { + // coin: 'XRP', + // address: 'rEb8TK3gBgk5auZkwc6sHnwrGVJH8DuaLh', + // tag: '108618262', + // url: 'https://bithomp.com/explorer/rEb8TK3gBgk5auZkwc6sHnwrGVJH8DuaLh' + // } + // } + // const address = this.safeString (response, 'address'); - const tag = this.safeString (response, 'addressTag'); + const tag = this.safeString (response, 'tag'); this.checkAddress (address); return { 'currency': code, @@ -10260,7 +11774,7 @@ module.exports = class binance extends Exchange { 'timestamp': this.nonce (), 'recvWindow': recvWindow, }, params)); - } else if (path === 'batchOrders') { + } else if ((path === 'batchOrders') || (path.indexOf ('sub-account') >= 0)) { query = this.rawencode (this.extend ({ 'timestamp': this.nonce (), 'recvWindow': recvWindow, @@ -10371,7 +11885,7 @@ module.exports = class binance extends Exchange { } }; -},{"./base/Exchange":5,"./base/errors":7,"./base/functions/number":13}],24:[function(require,module,exports){ +},{"./base/Exchange":6,"./base/errors":8,"./base/functions/number":14}],24:[function(require,module,exports){ 'use strict'; // --------------------------------------------------------------------------- @@ -10416,6 +11930,10 @@ module.exports = class binanceus extends binance { }, }); } + + async fetchCurrencies (params = {}) { + return undefined; + } }; @@ -10728,6 +12246,7 @@ module.exports = class bit2c extends Exchange { 'symbol': symbol, 'type': undefined, 'timeInForce': undefined, + 'postOnly': undefined, 'side': side, 'price': price, 'stopPrice': undefined, @@ -10879,7 +12398,7 @@ module.exports = class bit2c extends Exchange { }; -},{"./base/Exchange":5,"./base/errors":7}],26:[function(require,module,exports){ +},{"./base/Exchange":6,"./base/errors":8}],26:[function(require,module,exports){ 'use strict'; // --------------------------------------------------------------------------- @@ -10964,6 +12483,8 @@ module.exports = class bitbank extends Exchange { 'BCH/JPY': { 'id': 'bcc_jpy', 'symbol': 'BCH/JPY', 'base': 'BCH', 'quote': 'JPY', 'baseId': 'bcc', 'quoteId': 'jpy' }, 'MONA/BTC': { 'id': 'mona_btc', 'symbol': 'MONA/BTC', 'base': 'MONA', 'quote': 'BTC', 'baseId': 'mona', 'quoteId': 'btc' }, 'MONA/JPY': { 'id': 'mona_jpy', 'symbol': 'MONA/JPY', 'base': 'MONA', 'quote': 'JPY', 'baseId': 'mona', 'quoteId': 'jpy' }, + 'QTUM/BTC': { 'id': 'qtum_btc', 'symbol': 'QTUM/BTC', 'base': 'QTUM', 'quote': 'BTC', 'baseId': 'qtum', 'quoteId': 'btc' }, + 'QTUM/JPY': { 'id': 'qtum_jpy', 'symbol': 'QTUM/JPY', 'base': 'QTUM', 'quote': 'JPY', 'baseId': 'qtum', 'quoteId': 'jpy' }, 'ETH/BTC': { 'id': 'eth_btc', 'symbol': 'ETH/BTC', 'base': 'ETH', 'quote': 'BTC', 'baseId': 'eth', 'quoteId': 'btc' }, 'LTC/BTC': { 'id': 'ltc_btc', 'symbol': 'LTC/BTC', 'base': 'LTC', 'quote': 'BTC', 'baseId': 'ltc', 'quoteId': 'btc' }, 'XRP/JPY': { 'id': 'xrp_jpy', 'symbol': 'XRP/JPY', 'base': 'XRP', 'quote': 'JPY', 'baseId': 'xrp', 'quoteId': 'jpy' }, @@ -10972,6 +12493,7 @@ module.exports = class bitbank extends Exchange { 'ETH/JPY': { 'id': 'eth_jpy', 'symbol': 'ETH/JPY', 'base': 'ETH', 'quote': 'JPY', 'baseId': 'eth', 'quoteId': 'jpy' }, 'LTC/JPY': { 'id': 'ltc_jpy', 'symbol': 'LTC/JPY', 'base': 'LTC', 'quote': 'JPY', 'baseId': 'ltc', 'quoteId': 'jpy' }, 'XRP/BTC': { 'id': 'xrp_btc', 'symbol': 'XRP/BTC', 'base': 'XRP', 'quote': 'BTC', 'baseId': 'xrp', 'quoteId': 'btc' }, + 'XLM/BTC': { 'id': 'xlm_btc', 'symbol': 'XLM/BTC', 'base': 'XLM', 'quote': 'BTC', 'baseId': 'xlm', 'quoteId': 'btc' }, }, 'fees': { 'trading': { @@ -11089,8 +12611,8 @@ module.exports = class bitbank extends Exchange { const feeCost = this.safeFloat (trade, 'fee_amount_quote'); if (feeCost !== undefined) { fee = { - 'currency': market['quote'], - 'cost': feeCurrency, + 'currency': feeCurrency, + 'cost': feeCost, }; } const orderId = this.safeString (trade, 'order_id'); @@ -11249,6 +12771,7 @@ module.exports = class bitbank extends Exchange { 'symbol': symbol, 'type': type, 'timeInForce': undefined, + 'postOnly': undefined, 'side': side, 'price': price, 'stopPrice': undefined, @@ -11267,7 +12790,7 @@ module.exports = class bitbank extends Exchange { await this.loadMarkets (); const market = this.market (symbol); if (price === undefined) { - throw new InvalidOrder (this.id + ' createOrder requires a price argument for both market and limit orders'); + throw new InvalidOrder (this.id + ' createOrder() requires a price argument for both market and limit orders'); } const request = { 'pair': market['id'], @@ -11503,7 +13026,7 @@ module.exports = class bitbank extends Exchange { } }; -},{"./base/Exchange":5,"./base/errors":7}],27:[function(require,module,exports){ +},{"./base/Exchange":6,"./base/errors":8}],27:[function(require,module,exports){ 'use strict'; // --------------------------------------------------------------------------- @@ -11857,6 +13380,7 @@ module.exports = class bitbay extends Exchange { filled = Math.max (0, amount - remaining); } } + const postOnly = this.safeValue (order, 'postOnly'); return { 'id': this.safeString (order, 'id'), 'clientOrderId': undefined, @@ -11868,6 +13392,7 @@ module.exports = class bitbay extends Exchange { 'symbol': symbol, 'type': this.safeString (order, 'mode'), 'timeInForce': undefined, + 'postOnly': postOnly, 'side': this.safeStringLower (order, 'offerType'), 'price': this.safeFloat (order, 'rate'), 'stopPrice': undefined, @@ -12777,7 +14302,7 @@ module.exports = class bitbay extends Exchange { } }; -},{"./base/Exchange":5,"./base/errors":7}],28:[function(require,module,exports){ +},{"./base/Exchange":6,"./base/errors":8}],28:[function(require,module,exports){ 'use strict'; // --------------------------------------------------------------------------- @@ -12813,7 +14338,7 @@ module.exports = class bitcoincom extends hitbtc { } }; -},{"./hitbtc.js":89}],29:[function(require,module,exports){ +},{"./hitbtc.js":93}],29:[function(require,module,exports){ 'use strict'; // --------------------------------------------------------------------------- @@ -12832,7 +14357,6 @@ module.exports = class bitfinex extends Exchange { 'countries': [ 'VG' ], 'version': 'v1', 'rateLimit': 1500, - 'certified': true, 'pro': true, // new metainfo interface 'has': { @@ -12870,6 +14394,7 @@ module.exports = class bitfinex extends Exchange { '30m': '30m', '1h': '1h', '3h': '3h', + '4h': '4h', '6h': '6h', '12h': '12h', '1d': '1D', @@ -13416,13 +14941,32 @@ module.exports = class bitfinex extends Exchange { async fetchBalance (params = {}) { await this.loadMarkets (); + const types = { + 'exchange': 'exchange', + 'deposit': 'funding', + 'trading': 'margin', + }; const balanceType = this.safeString (params, 'type', 'exchange'); const query = this.omit (params, 'type'); const response = await this.privatePostBalances (query); + // [ { type: 'deposit', + // currency: 'btc', + // amount: '0.00116721', + // available: '0.00116721' }, + // { type: 'exchange', + // currency: 'ust', + // amount: '0.0000002', + // available: '0.0000002' }, + // { type: 'trading', + // currency: 'btc', + // amount: '0.0005', + // available: '0.0005' } ], const result = { 'info': response }; for (let i = 0; i < response.length; i++) { const balance = response[i]; - if (balance['type'] === balanceType) { + const type = this.safeString (balance, 'type'); + const parsedType = this.safeString (types, type); + if ((parsedType === balanceType) || (type === balanceType)) { const currencyId = this.safeString (balance, 'currency'); const code = this.safeCurrencyCode (currencyId); // bitfinex had BCH previously, now it's BAB, but the old @@ -13585,7 +15129,7 @@ module.exports = class bitfinex extends Exchange { async fetchMyTrades (symbol = undefined, since = undefined, limit = undefined, params = {}) { if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' fetchMyTrades requires a `symbol` argument'); + throw new ArgumentsRequired (this.id + ' fetchMyTrades() requires a `symbol` argument'); } await this.loadMarkets (); const market = this.market (symbol); @@ -13703,6 +15247,7 @@ module.exports = class bitfinex extends Exchange { 'symbol': symbol, 'type': orderType, 'timeInForce': undefined, + 'postOnly': undefined, 'side': side, 'price': this.safeFloat (order, 'price'), 'stopPrice': undefined, @@ -14078,13 +15623,13 @@ module.exports = class bitfinex extends Exchange { } }; -},{"./base/Exchange":5,"./base/errors":7,"./base/functions/number":13}],30:[function(require,module,exports){ +},{"./base/Exchange":6,"./base/errors":8,"./base/functions/number":14}],30:[function(require,module,exports){ 'use strict'; // --------------------------------------------------------------------------- const bitfinex = require ('./bitfinex.js'); -const { ExchangeError, InvalidAddress, ArgumentsRequired, InsufficientFunds, AuthenticationError, OrderNotFound, InvalidOrder, BadRequest, InvalidNonce, BadSymbol, OnMaintenance } = require ('./base/errors'); +const { ExchangeError, InvalidAddress, ArgumentsRequired, InsufficientFunds, AuthenticationError, OrderNotFound, InvalidOrder, BadRequest, InvalidNonce, BadSymbol, OnMaintenance, NotSupported } = require ('./base/errors'); // --------------------------------------------------------------------------- @@ -14134,6 +15679,7 @@ module.exports = class bitfinex2 extends bitfinex { '30m': '30m', '1h': '1h', '3h': '3h', + '4h': '4h', '6h': '6h', '12h': '12h', '1d': '1D', @@ -14252,7 +15798,9 @@ module.exports = class bitfinex2 extends bitfinex { 'auth/w/position/claim', 'auth/r/positions/hist', 'auth/r/positions/audit', + 'auth/r/positions/snap', 'auth/w/deriv/collateral/set', + 'auth/w/deriv/collateral/limits', 'auth/r/funding/offers', 'auth/r/funding/offers/{symbol}', 'auth/w/funding/offer/submit', @@ -14664,6 +16212,10 @@ module.exports = class bitfinex2 extends bitfinex { return this.parseBalance (result); } + async fetchOrder (id, symbol = undefined, params = {}) { + throw new NotSupported (this.id + ' fetchOrder is not implemented yet'); + } + async fetchOrderBook (symbol, limit = undefined, params = {}) { await this.loadMarkets (); const precision = this.safeValue (this.options, 'precision', 'R0'); @@ -15004,6 +16556,7 @@ module.exports = class bitfinex2 extends bitfinex { 'symbol': symbol, 'type': type, 'timeInForce': undefined, + 'postOnly': undefined, 'side': side, 'price': price, 'stopPrice': undefined, @@ -15022,16 +16575,43 @@ module.exports = class bitfinex2 extends bitfinex { await this.loadMarkets (); const market = this.market (symbol); const orderTypes = this.safeValue (this.options, 'orderTypes', {}); - const orderType = this.safeString (orderTypes, type, type); + const orderType = this.safeStringUpper (orderTypes, type, type); amount = (side === 'sell') ? -amount : amount; const request = { 'symbol': market['id'], 'type': orderType, 'amount': this.numberToString (amount), }; - if (type !== 'market') { + if ((orderType === 'LIMIT') || (orderType === 'EXCHANGE LIMIT')) { + request['price'] = this.numberToString (price); + } else if ((orderType === 'STOP') || (orderType === 'EXCHANGE STOP')) { + const stopPrice = this.safeFloat (params, 'stopPrice', price); + request['price'] = this.numberToString (stopPrice); + } else if ((orderType === 'STOP LIMIT') || (orderType === 'EXCHANGE STOP LIMIT')) { + const priceAuxLimit = this.safeFloat (params, 'price_aux_limit'); + let stopPrice = this.safeFloat (params, 'stopPrice'); + if (priceAuxLimit === undefined) { + if (stopPrice === undefined) { + throw new ArgumentsRequired (this.id + ' createOrder() requires a stopPrice parameter or a price_aux_limit parameter for a ' + orderType + ' order'); + } else { + request['price_aux_limit'] = this.numberToString (price); + } + } else { + request['price_aux_limit'] = this.numberToString (priceAuxLimit); + if (stopPrice === undefined) { + stopPrice = price; + } + } + request['price'] = this.numberToString (stopPrice); + } else if ((orderType === 'TRAILING STOP') || (orderType === 'EXCHANGE TRAILING STOP')) { + const priceTrailing = this.safeFloat (params, 'price_trailing'); + request['price_trailing'] = this.numberToString (priceTrailing); + const stopPrice = this.safeFloat (params, 'stopPrice', price); + request['price'] = this.numberToString (stopPrice); + } else if ((orderType === 'FOK') || (orderType === 'EXCHANGE FOK') || (orderType === 'IOC') || (orderType === 'EXCHANGE IOC')) { request['price'] = this.numberToString (price); } + params = this.omit (params, [ 'stopPrice', 'price_aux_limit', 'price_trailing' ]); const clientOrderId = this.safeValue2 (params, 'cid', 'clientOrderId'); if (clientOrderId !== undefined) { request['cid'] = clientOrderId; @@ -15617,7 +17197,7 @@ module.exports = class bitfinex2 extends bitfinex { } }; -},{"./base/errors":7,"./bitfinex.js":29}],31:[function(require,module,exports){ +},{"./base/errors":8,"./bitfinex.js":29}],31:[function(require,module,exports){ 'use strict'; // --------------------------------------------------------------------------- @@ -15985,6 +17565,7 @@ module.exports = class bitflyer extends Exchange { 'symbol': symbol, 'type': type, 'timeInForce': undefined, + 'postOnly': undefined, 'side': side, 'price': price, 'stopPrice': undefined, @@ -16044,7 +17625,7 @@ module.exports = class bitflyer extends Exchange { async fetchMyTrades (symbol = undefined, since = undefined, limit = undefined, params = {}) { if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' fetchMyTrades requires a `symbol` argument'); + throw new ArgumentsRequired (this.id + ' fetchMyTrades() requires a `symbol` argument'); } await this.loadMarkets (); const market = this.market (symbol); @@ -16060,7 +17641,7 @@ module.exports = class bitflyer extends Exchange { async fetchPositions (symbols = undefined, since = undefined, limit = undefined, params = {}) { if (symbols === undefined) { - throw new ArgumentsRequired (this.id + ' fetchPositions requires a `symbols` argument, exactly one symbol in an array'); + throw new ArgumentsRequired (this.id + ' fetchPositions() requires a `symbols` argument, exactly one symbol in an array'); } await this.loadMarkets (); const request = { @@ -16142,13 +17723,13 @@ module.exports = class bitflyer extends Exchange { } }; -},{"./base/Exchange":5,"./base/errors":7}],32:[function(require,module,exports){ +},{"./base/Exchange":6,"./base/errors":8}],32:[function(require,module,exports){ 'use strict'; // --------------------------------------------------------------------------- const Exchange = require ('./base/Exchange'); -const { ExchangeError, AuthenticationError, OrderNotFound, InsufficientFunds, DDoSProtection, PermissionDenied } = require ('./base/errors'); +const { ExchangeError, AuthenticationError, OrderNotFound, InsufficientFunds, DDoSProtection, PermissionDenied, BadSymbol } = require ('./base/errors'); // --------------------------------------------------------------------------- @@ -16368,6 +17949,7 @@ module.exports = class bitforex extends Exchange { }, 'commonCurrencies': { 'CREDIT': 'TerraCredit', + 'HBC': 'Hybrid Bank Cash', 'IQ': 'IQ.Cash', 'UOS': 'UOS Network', }, @@ -16376,6 +17958,7 @@ module.exports = class bitforex extends Exchange { '1013': AuthenticationError, '1016': AuthenticationError, '1017': PermissionDenied, // {"code":"1017","success":false,"time":1602670594367,"message":"IP not allow"} + '1019': BadSymbol, // {"code":"1019","success":false,"time":1607087743778,"message":"Symbol Invalid"} '3002': InsufficientFunds, '10204': DDoSProtection, }, @@ -16644,6 +18227,7 @@ module.exports = class bitforex extends Exchange { 'symbol': symbol, 'type': type, 'timeInForce': undefined, + 'postOnly': undefined, 'side': side, 'price': price, 'stopPrice': undefined, @@ -16772,7 +18356,7 @@ module.exports = class bitforex extends Exchange { } }; -},{"./base/Exchange":5,"./base/errors":7}],33:[function(require,module,exports){ +},{"./base/Exchange":6,"./base/errors":8}],33:[function(require,module,exports){ 'use strict'; // --------------------------------------------------------------------------- @@ -18479,7 +20063,7 @@ module.exports = class bitget extends Exchange { const type = this.safeString (params, 'type', defaultType); params = this.omit (params, 'type'); if (type === undefined) { - throw new ArgumentsRequired (this.id + " requires an 'accountId' parameter"); + throw new ArgumentsRequired (this.id + " getAccountId() requires an 'accountId' parameter"); } const account = await this.findAccountByType (type); return account['id']; @@ -18491,7 +20075,7 @@ module.exports = class bitget extends Exchange { const defaultType = this.safeString2 (this.options, 'fetchBalance', 'defaultType'); const type = this.safeString (params, 'type', defaultType); if (type === undefined) { - throw new ArgumentsRequired (this.id + " fetchBalance requires a 'type' parameter, one of 'spot', 'swap'"); + throw new ArgumentsRequired (this.id + " fetchBalance() requires a 'type' parameter, one of 'spot', 'swap'"); } let method = undefined; const query = this.omit (params, 'type'); @@ -18735,6 +20319,7 @@ module.exports = class bitget extends Exchange { 'symbol': symbol, 'type': type, 'timeInForce': undefined, + 'postOnly': undefined, 'side': side, 'price': price, 'stopPrice': undefined, @@ -18817,7 +20402,7 @@ module.exports = class bitget extends Exchange { request['client_oid'] = clientOrderId; const orderType = this.safeString (params, 'type'); if (orderType === undefined) { - throw new ArgumentsRequired (this.id + " createOrder requires a type parameter, '1' = open long, '2' = open short, '3' = close long, '4' = close short for " + market['type'] + ' orders'); + throw new ArgumentsRequired (this.id + " createOrder() requires a type parameter, '1' = open long, '2' = open short, '3' = close long, '4' = close short for " + market['type'] + ' orders'); } request['size'] = this.amountToPrecision (symbol, amount); request['type'] = orderType; @@ -18859,7 +20444,7 @@ module.exports = class bitget extends Exchange { const type = this.safeString (params, 'type', defaultType); if (type === 'spot') { if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' cancelOrder requires a symbol argument for spot orders'); + throw new ArgumentsRequired (this.id + ' cancelOrder() requires a symbol argument for spot orders'); } } } else { @@ -18900,14 +20485,15 @@ module.exports = class bitget extends Exchange { async cancelOrders (ids, symbol = undefined, params = {}) { if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' cancelOrders requires a symbol argument'); + throw new ArgumentsRequired (this.id + ' cancelOrders() requires a symbol argument'); } await this.loadMarkets (); const market = this.market (symbol); const type = this.safeString (params, 'type', market['type']); if (type === undefined) { - throw new ArgumentsRequired (this.id + " cancelOrders requires a type parameter (one of 'spot', 'swap')."); + throw new ArgumentsRequired (this.id + " cancelOrders() requires a type parameter (one of 'spot', 'swap')."); } + params = this.omit (params, 'type'); const request = {}; let method = undefined; if (type === 'spot') { @@ -18964,13 +20550,13 @@ module.exports = class bitget extends Exchange { async fetchOrder (id, symbol = undefined, params = {}) { if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' fetchOrder requires a symbol argument'); + throw new ArgumentsRequired (this.id + ' fetchOrder() requires a symbol argument'); } await this.loadMarkets (); const market = this.market (symbol); const type = this.safeString (params, 'type', market['type']); if (type === undefined) { - throw new ArgumentsRequired (this.id + " fetchOrder requires a type parameter (one of 'spot', 'swap')."); + throw new ArgumentsRequired (this.id + " fetchOrder() requires a type parameter (one of 'spot', 'swap')."); } let method = undefined; const request = {}; @@ -19041,7 +20627,7 @@ module.exports = class bitget extends Exchange { async fetchOpenOrders (symbol = undefined, since = undefined, limit = undefined, params = {}) { if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' fetchOpenOrders requires a symbol argument'); + throw new ArgumentsRequired (this.id + ' fetchOpenOrders() requires a symbol argument'); } await this.loadMarkets (); const market = this.market (symbol); @@ -19126,7 +20712,7 @@ module.exports = class bitget extends Exchange { async fetchClosedOrders (symbol = undefined, since = undefined, limit = undefined, params = {}) { if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' fetchClosedOrders requires a symbol argument'); + throw new ArgumentsRequired (this.id + ' fetchClosedOrders() requires a symbol argument'); } await this.loadMarkets (); const market = this.market (symbol); @@ -19218,7 +20804,7 @@ module.exports = class bitget extends Exchange { async fetchDeposits (code = undefined, since = undefined, limit = undefined, params = {}) { if (code === undefined) { - throw new ArgumentsRequired (this.id + ' fetchDeposits requires a currency code argument'); + throw new ArgumentsRequired (this.id + ' fetchDeposits() requires a currency code argument'); } await this.loadMarkets (); const currency = this.currency (code); @@ -19255,7 +20841,7 @@ module.exports = class bitget extends Exchange { async fetchWithdrawals (code = undefined, since = undefined, limit = undefined, params = {}) { if (code === undefined) { - throw new ArgumentsRequired (this.id + ' fetchWithdrawals requires a currency code argument'); + throw new ArgumentsRequired (this.id + ' fetchWithdrawals() requires a currency code argument'); } await this.loadMarkets (); const currency = this.currency (code); @@ -19378,14 +20964,14 @@ module.exports = class bitget extends Exchange { async fetchMyTrades (symbol = undefined, since = undefined, limit = undefined, params = {}) { if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' fetchMyTrades requires a symbol argument'); + throw new ArgumentsRequired (this.id + ' fetchMyTrades() requires a symbol argument'); } await this.loadMarkets (); const market = this.market (symbol); const type = this.safeString (params, 'type', market['type']); const query = this.omit (params, 'type'); if (type === 'swap') { - throw new ArgumentsRequired (this.id + ' fetchMyTrades is not supported for ' + type + ' type'); + throw new ArgumentsRequired (this.id + ' fetchMyTrades() is not supported for ' + type + ' type'); } // // spot @@ -19442,12 +21028,12 @@ module.exports = class bitget extends Exchange { async fetchOrderTrades (id, symbol = undefined, since = undefined, limit = undefined, params = {}) { if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' fetchOrderTrades requires a symbol argument'); + throw new ArgumentsRequired (this.id + ' fetchOrderTrades() requires a symbol argument'); } await this.loadMarkets (); const market = this.market (symbol); const type = this.safeString (params, 'type', market['type']); - const query = this.omit (params, 'type'); + params = this.omit (params, 'type'); let method = undefined; const request = {}; if (type === 'spot') { @@ -19459,7 +21045,7 @@ module.exports = class bitget extends Exchange { request['symbol'] = market['id']; method = 'swapGetOrderFills'; } - const response = await this[method] (this.extend (request, query)); + const response = await this[method] (this.extend (request, params)); // // spot // @@ -19678,7 +21264,7 @@ module.exports = class bitget extends Exchange { } }; -},{"./base/Exchange":5,"./base/errors":7,"./base/functions/number":13}],34:[function(require,module,exports){ +},{"./base/Exchange":6,"./base/errors":8,"./base/functions/number":14}],34:[function(require,module,exports){ 'use strict'; // --------------------------------------------------------------------------- @@ -19703,6 +21289,7 @@ module.exports = class bithumb extends Exchange { 'createOrder': true, 'fetchBalance': true, 'fetchMarkets': true, + 'fetchOHLCV': true, 'fetchOpenOrders': true, 'fetchOrder': true, 'fetchOrderBook': true, @@ -19726,10 +21313,13 @@ module.exports = class bithumb extends Exchange { 'get': [ 'ticker/{currency}', 'ticker/all', + 'ticker/ALL_BTC', + 'ticker/ALL_KRW', 'orderbook/{currency}', 'orderbook/all', 'transaction_history/{currency}', 'transaction_history/all', + 'candlestick/{currency}/{interval}', ], }, 'private': { @@ -19773,6 +21363,27 @@ module.exports = class bithumb extends Exchange { 'Unknown Error': ExchangeError, 'After May 23th, recent_transactions is no longer, hence users will not be able to connect to recent_transactions': ExchangeError, // {"status":"5100","message":"After May 23th, recent_transactions is no longer, hence users will not be able to connect to recent_transactions"} }, + 'timeframes': { + '1m': '1m', + '3m': '3m', + '5m': '5m', + '10m': '10m', + '30m': '30m', + '1h': '1h', + '6h': '6h', + '12h': '12h', + '1d': '24h', + }, + 'options': { + 'quoteCurrencies': { + 'BTC': { + 'precision': { + 'price': 8, + }, + }, + 'KRW': {}, + }, + }, }); } @@ -19781,54 +21392,61 @@ module.exports = class bithumb extends Exchange { } async fetchMarkets (params = {}) { - const response = await this.publicGetTickerAll (params); - const data = this.safeValue (response, 'data'); - const currencyIds = Object.keys (data); const result = []; - const quote = this.safeCurrencyCode ('KRW'); - for (let i = 0; i < currencyIds.length; i++) { - const currencyId = currencyIds[i]; - if (currencyId === 'date') { - continue; - } - const market = data[currencyId]; - const base = this.safeCurrencyCode (currencyId); - const symbol = currencyId + '/' + quote; - let active = true; - if (Array.isArray (market)) { - const numElements = market.length; - if (numElements === 0) { - active = false; + const quoteCurrencies = this.safeValue (this.options, 'quoteCurrencies', {}); + const quotes = Object.keys (quoteCurrencies); + for (let i = 0; i < quotes.length; i++) { + const quote = quotes[i]; + const extension = this.safeValue (quoteCurrencies, quote, {}); + const method = 'publicGetTickerALL' + quote; + const response = await this[method] (params); + const data = this.safeValue (response, 'data'); + const currencyIds = Object.keys (data); + for (let j = 0; j < currencyIds.length; j++) { + const currencyId = currencyIds[j]; + if (currencyId === 'date') { + continue; } + const market = data[currencyId]; + const base = this.safeCurrencyCode (currencyId); + const symbol = currencyId + '/' + quote; + let active = true; + if (Array.isArray (market)) { + const numElements = market.length; + if (numElements === 0) { + active = false; + } + } + const entry = this.deepExtend ({ + 'id': currencyId, + 'symbol': symbol, + 'base': base, + 'quote': quote, + 'info': market, + 'active': active, + 'precision': { + 'amount': 4, + 'price': 4, + }, + 'limits': { + 'amount': { + 'min': undefined, + 'max': undefined, + }, + 'price': { + 'min': undefined, + 'max': undefined, + }, + 'cost': { + 'min': 500, + 'max': 5000000000, + }, + }, + 'baseId': undefined, + 'quoteId': undefined, + }, extension); + result.push (entry); } - result.push ({ - 'id': currencyId, - 'symbol': symbol, - 'base': base, - 'quote': quote, - 'info': market, - 'active': active, - 'precision': { - 'amount': 4, - 'price': 4, - }, - 'limits': { - 'amount': { - 'min': undefined, - 'max': undefined, - }, - 'price': { - 'min': undefined, - 'max': undefined, - }, - 'cost': { - 'min': 500, - 'max': 5000000000, - }, - }, - 'baseId': undefined, - 'quoteId': undefined, - }); } return result; } @@ -20030,6 +21648,62 @@ module.exports = class bithumb extends Exchange { return this.parseTicker (data, market); } + parseOHLCV (ohlcv, market = undefined) { + // + // [ + // 1576823400000, // 기준 시간 + // '8284000', // 시가 + // '8286000', // 종가 + // '8289000', // 고가 + // '8276000', // 저가 + // '15.41503692' // 거래량 + // ] + // + return [ + this.safeInteger (ohlcv, 0), + this.safeFloat (ohlcv, 1), + this.safeFloat (ohlcv, 3), + this.safeFloat (ohlcv, 4), + this.safeFloat (ohlcv, 2), + this.safeFloat (ohlcv, 5), + ]; + } + + async fetchOHLCV (symbol, timeframe = '1m', since = undefined, limit = undefined, params = {}) { + await this.loadMarkets (); + const market = this.market (symbol); + const request = { + 'currency': market['base'], + 'interval': this.timeframes[timeframe], + }; + const response = await this.publicGetCandlestickCurrencyInterval (this.extend (request, params)); + // + // { + // 'status': '0000', + // 'data': { + // [ + // 1576823400000, // 기준 시간 + // '8284000', // 시가 + // '8286000', // 종가 + // '8289000', // 고가 + // '8276000', // 저가 + // '15.41503692' // 거래량 + // ], + // [ + // 1576824000000, // 기준 시간 + // '8284000', // 시가 + // '8281000', // 종가 + // '8289000', // 고가 + // '8275000', // 저가 + // '6.19584467' // 거래량 + // ], + // } + // } + // + const data = this.safeValue (response, 'data', []); + return this.parseOHLCVs (data, market, timeframe, since, limit); + } + parseTrade (trade, market = undefined) { // // fetchTrades (public) @@ -20151,7 +21825,7 @@ module.exports = class bithumb extends Exchange { const market = this.market (symbol); const request = { 'order_currency': market['id'], - 'Payment_currency': market['quote'], + 'payment_currency': market['quote'], 'units': amount, }; let method = 'privatePostTradePlace'; @@ -20164,7 +21838,7 @@ module.exports = class bithumb extends Exchange { const response = await this[method] (this.extend (request, params)); const id = this.safeString (response, 'order_id'); if (id === undefined) { - throw new InvalidOrder (this.id + ' createOrder did not return an order id'); + throw new InvalidOrder (this.id + ' createOrder() did not return an order id'); } return { 'info': response, @@ -20177,7 +21851,7 @@ module.exports = class bithumb extends Exchange { async fetchOrder (id, symbol = undefined, params = {}) { if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' fetchOrder requires a symbol argument'); + throw new ArgumentsRequired (this.id + ' fetchOrder() requires a symbol argument'); } await this.loadMarkets (); const market = this.market (symbol); @@ -20389,6 +22063,7 @@ module.exports = class bithumb extends Exchange { 'symbol': symbol, 'type': type, 'timeInForce': undefined, + 'postOnly': undefined, 'side': side, 'price': price, 'stopPrice': undefined, @@ -20411,7 +22086,7 @@ module.exports = class bithumb extends Exchange { async fetchOpenOrders (symbol = undefined, since = undefined, limit = undefined, params = {}) { if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' fetchOpenOrders requires a symbol argument'); + throw new ArgumentsRequired (this.id + ' fetchOpenOrders() requires a symbol argument'); } await this.loadMarkets (); const market = this.market (symbol); @@ -20451,10 +22126,10 @@ module.exports = class bithumb extends Exchange { async cancelOrder (id, symbol = undefined, params = {}) { const side_in_params = ('side' in params); if (!side_in_params) { - throw new ArgumentsRequired (this.id + ' cancelOrder requires a `symbol` argument and a `side` parameter (sell or buy)'); + throw new ArgumentsRequired (this.id + ' cancelOrder() requires a `symbol` argument and a `side` parameter (sell or buy)'); } if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' cancelOrder requires a `symbol` argument and a `side` parameter (sell or buy)'); + throw new ArgumentsRequired (this.id + ' cancelOrder() requires a `symbol` argument and a `side` parameter (sell or buy)'); } const market = this.market (symbol); const side = (params['side'] === 'buy') ? 'bid' : 'ask'; @@ -20485,7 +22160,7 @@ module.exports = class bithumb extends Exchange { 'address': address, 'currency': currency['id'], }; - if (currency === 'XRP' || currency === 'XMR') { + if (currency === 'XRP' || currency === 'XMR' || currency === 'EOS' || currency === 'STEEM') { const destination = this.safeString (params, 'destination'); if ((tag === undefined) && (destination === undefined)) { throw new ArgumentsRequired (this.id + ' ' + code + ' withdraw() requires a tag argument or an extra destination param'); @@ -20566,7 +22241,7 @@ module.exports = class bithumb extends Exchange { } }; -},{"./base/Exchange":5,"./base/errors":7,"./base/functions/number":13}],35:[function(require,module,exports){ +},{"./base/Exchange":6,"./base/errors":8,"./base/functions/number":14}],35:[function(require,module,exports){ 'use strict'; // --------------------------------------------------------------------------- @@ -20590,11 +22265,14 @@ module.exports = class bitkk extends zb { 'doc': 'https://www.bitkk.com/i/developer', 'fees': 'https://www.bitkk.com/i/rate', }, + 'commonCurrencies': { + 'BCH': 'BCHOLD', + }, }); } }; -},{"./zb.js":179}],36:[function(require,module,exports){ +},{"./zb.js":182}],36:[function(require,module,exports){ 'use strict'; // --------------------------------------------------------------------------- @@ -20645,7 +22323,7 @@ module.exports = class bitmart extends Exchange { 'logo': 'https://user-images.githubusercontent.com/1294454/61835713-a2662f80-ae85-11e9-9d00-6442919701fd.jpg', 'api': 'https://api-cloud.{hostname}', // bitmart.info for Hong Kong users 'www': 'https://www.bitmart.com/', - 'doc': 'https://github.com/bitmartexchange/bitmart-official-api-docs', + 'doc': 'https://developer-pro.bitmart.com/', 'referral': 'http://www.bitmart.com/?r=rQCFLh', 'fees': 'https://www.bitmart.com/fee/en', }, @@ -20758,8 +22436,8 @@ module.exports = class bitmart extends Exchange { 'trading': { 'tierBased': true, 'percentage': true, - 'taker': 0.002, - 'maker': 0.001, + 'taker': 0.0025, + 'maker': 0.0025, 'tiers': { 'taker': [ [0, 0.20 / 100], @@ -20893,6 +22571,8 @@ module.exports = class bitmart extends Exchange { 'broad': {}, }, 'commonCurrencies': { + 'COT': 'Community Coin', + 'CPC': 'CPCoin', 'ONE': 'Menlo One', 'PLA': 'Plair', }, @@ -21838,7 +23518,7 @@ module.exports = class bitmart extends Exchange { async fetchMyTrades (symbol = undefined, since = undefined, limit = undefined, params = {}) { if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' fetchMyTrades requires a symbol argument'); + throw new ArgumentsRequired (this.id + ' fetchMyTrades() requires a symbol argument'); } await this.loadMarkets (); const market = this.market (symbol); @@ -21846,7 +23526,7 @@ module.exports = class bitmart extends Exchange { const request = {}; if (market['spot']) { request['symbol'] = market['id']; - request['offset'] = 1; + request['offset'] = 1; // max offset * limit < 500 if (limit === undefined) { limit = 100; // max 100 } @@ -21919,7 +23599,7 @@ module.exports = class bitmart extends Exchange { async fetchOrderTrades (id, symbol = undefined, since = undefined, limit = undefined, params = {}) { if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' fetchOrderTrades requires a symbol argument'); + throw new ArgumentsRequired (this.id + ' fetchOrderTrades() requires a symbol argument'); } await this.loadMarkets (); const market = this.market (symbol); @@ -22197,6 +23877,7 @@ module.exports = class bitmart extends Exchange { 'symbol': symbol, 'type': type, 'timeInForce': undefined, + 'postOnly': undefined, 'side': side, 'price': price, 'stopPrice': undefined, @@ -22302,7 +23983,7 @@ module.exports = class bitmart extends Exchange { async cancelOrder (id, symbol = undefined, params = {}) { if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' cancelOrder requires a symbol argument'); + throw new ArgumentsRequired (this.id + ' cancelOrder() requires a symbol argument'); } await this.loadMarkets (); const market = this.market (symbol); @@ -22330,6 +24011,15 @@ module.exports = class bitmart extends Exchange { // } // } // + // spot alternative + // + // { + // "code": 1000, + // "trace":"886fb6ae-456b-4654-b4e0-d681ac05cea1", + // "message": "OK", + // "data": true + // } + // // contract // // { @@ -22345,16 +24035,19 @@ module.exports = class bitmart extends Exchange { // } // const data = this.safeValue (response, 'data'); + if (data === true) { + return this.parseOrder (id, market); + } const succeeded = this.safeValue (data, 'succeed'); if (succeeded !== undefined) { id = this.safeString (succeeded, 0); if (id === undefined) { - throw new InvalidOrder (this.id + ' cancelOrder failed to cancel ' + symbol + ' order id ' + id); + throw new InvalidOrder (this.id + ' cancelOrder() failed to cancel ' + symbol + ' order id ' + id); } } else { const result = this.safeValue (data, 'result'); if (!result) { - throw new InvalidOrder (this.id + ' cancelOrder ' + symbol + ' order id ' + id + ' is filled or canceled'); + throw new InvalidOrder (this.id + ' cancelOrder() ' + symbol + ' order id ' + id + ' is filled or canceled'); } } const order = this.parseOrder (id, market); @@ -22363,16 +24056,16 @@ module.exports = class bitmart extends Exchange { async cancelAllOrders (symbol = undefined, params = {}) { if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' cancelAllOrders requires a symbol argument'); + throw new ArgumentsRequired (this.id + ' cancelAllOrders() requires a symbol argument'); } const side = this.safeString (params, 'side'); if (side === undefined) { - throw new ArgumentsRequired (this.id + " cancelAllOrders requires a `side` parameter ('buy' or 'sell')"); + throw new ArgumentsRequired (this.id + " cancelAllOrders() requires a `side` parameter ('buy' or 'sell')"); } await this.loadMarkets (); const market = this.market (symbol); if (!market['spot']) { - throw new NotSupported (this.id + ' cancelAllOrders does not support ' + market['type'] + ' orders, only spot orders are accepted'); + throw new NotSupported (this.id + ' cancelAllOrders() does not support ' + market['type'] + ' orders, only spot orders are accepted'); } const request = { 'symbol': market['id'], @@ -22392,12 +24085,12 @@ module.exports = class bitmart extends Exchange { async cancelOrders (ids, symbol = undefined, params = {}) { if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' canelOrders requires a symbol argument'); + throw new ArgumentsRequired (this.id + ' canelOrders() requires a symbol argument'); } await this.loadMarkets (); const market = this.market (symbol); if (!market['spot']) { - throw new NotSupported (this.id + ' cancelOrders does not support ' + market['type'] + ' orders, only contract orders are accepted'); + throw new NotSupported (this.id + ' cancelOrders() does not support ' + market['type'] + ' orders, only contract orders are accepted'); } const orders = []; for (let i = 0; i < ids.length; i++) { @@ -22438,7 +24131,7 @@ module.exports = class bitmart extends Exchange { async fetchOrdersByStatus (status, symbol = undefined, since = undefined, limit = undefined, params = {}) { if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' fetchOrdersByStatus requires a symbol argument'); + throw new ArgumentsRequired (this.id + ' fetchOrdersByStatus() requires a symbol argument'); } await this.loadMarkets (); const market = this.market (symbol); @@ -22560,7 +24253,7 @@ module.exports = class bitmart extends Exchange { async fetchOrders (symbol = undefined, since = undefined, limit = undefined, params = {}) { if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' fetchOrders requires a symbol argument'); + throw new ArgumentsRequired (this.id + ' fetchOrders() requires a symbol argument'); } await this.loadMarkets (); const market = this.market (symbol); @@ -22572,7 +24265,7 @@ module.exports = class bitmart extends Exchange { async fetchOrder (id, symbol = undefined, params = {}) { if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' fetchOrder requires a symbol argument'); + throw new ArgumentsRequired (this.id + ' fetchOrder() requires a symbol argument'); } await this.loadMarkets (); const request = {}; @@ -22650,7 +24343,7 @@ module.exports = class bitmart extends Exchange { const orders = this.safeValue (data, 'orders', []); const firstOrder = this.safeValue (orders, 0); if (firstOrder === undefined) { - throw new OrderNotFound (this.id + ' fetchOrder could not find ' + symbol + ' order id ' + id); + throw new OrderNotFound (this.id + ' fetchOrder() could not find ' + symbol + ' order id ' + id); } return this.parseOrder (firstOrder, market); } else { @@ -22944,7 +24637,7 @@ module.exports = class bitmart extends Exchange { } }; -},{"./base/Exchange":5,"./base/errors":7,"./base/functions/number":13}],37:[function(require,module,exports){ +},{"./base/Exchange":6,"./base/errors":8,"./base/functions/number":14}],37:[function(require,module,exports){ 'use strict'; // --------------------------------------------------------------------------- @@ -23080,8 +24773,8 @@ module.exports = class bitmax extends Exchange { 'trading': { 'tierBased': true, 'percentage': true, - 'taker': 0.001, - 'maker': 0.001, + 'taker': 0.002, + 'maker': 0.002, }, }, 'precisionMode': TICK_SIZE, @@ -23986,6 +25679,7 @@ module.exports = class bitmax extends Exchange { 'symbol': symbol, 'type': type, 'timeInForce': undefined, + 'postOnly': undefined, 'side': side, 'price': price, 'stopPrice': stopPrice, @@ -24036,7 +25730,7 @@ module.exports = class bitmax extends Exchange { if ((type === 'stop_limit') || (type === 'stop_market')) { const stopPrice = this.safeFloat (params, 'stopPrice'); if (stopPrice === undefined) { - throw new InvalidOrder (this.id + ' createOrder requires a stopPrice parameter for ' + type + ' orders'); + throw new InvalidOrder (this.id + ' createOrder() requires a stopPrice parameter for ' + type + ' orders'); } else { request['stopPrice'] = this.priceToPrecision (symbol, stopPrice); params = this.omit (params, 'stopPrice'); @@ -24291,7 +25985,7 @@ module.exports = class bitmax extends Exchange { async cancelOrder (id, symbol = undefined, params = {}) { if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' cancelOrder requires a symbol argument'); + throw new ArgumentsRequired (this.id + ' cancelOrder() requires a symbol argument'); } await this.loadMarkets (); await this.loadAccounts (); @@ -24671,14 +26365,14 @@ module.exports = class bitmax extends Exchange { } }; -},{"./base/Exchange":5,"./base/errors":7,"./base/functions/number":13}],38:[function(require,module,exports){ +},{"./base/Exchange":6,"./base/errors":8,"./base/functions/number":14}],38:[function(require,module,exports){ 'use strict'; // --------------------------------------------------------------------------- const Exchange = require ('./base/Exchange'); const { TICK_SIZE } = require ('./base/functions/number'); -const { AuthenticationError, BadRequest, DDoSProtection, ExchangeError, ExchangeNotAvailable, InsufficientFunds, InvalidOrder, OrderNotFound, PermissionDenied } = require ('./base/errors'); +const { AuthenticationError, BadRequest, DDoSProtection, ExchangeError, ExchangeNotAvailable, InsufficientFunds, InvalidOrder, OrderNotFound, PermissionDenied, ArgumentsRequired } = require ('./base/errors'); // --------------------------------------------------------------------------- @@ -24841,6 +26535,7 @@ module.exports = class bitmex extends Exchange { 'Account has insufficient Available Balance': InsufficientFunds, 'Service unavailable': ExchangeNotAvailable, // {"error":{"message":"Service unavailable","name":"HTTPError"}} 'Server Error': ExchangeError, // {"error":{"message":"Server Error","name":"HTTPError"}} + 'Unable to cancel order due to existing state': InvalidOrder, }, }, 'precisionMode': TICK_SIZE, @@ -25893,6 +27588,43 @@ module.exports = class bitmex extends Exchange { } parseOrder (order, market = undefined) { + // + // { + // "orderID":"56222c7a-9956-413a-82cf-99f4812c214b", + // "clOrdID":"", + // "clOrdLinkID":"", + // "account":1455728, + // "symbol":"XBTUSD", + // "side":"Sell", + // "simpleOrderQty":null, + // "orderQty":1, + // "price":40000, + // "displayQty":null, + // "stopPx":null, + // "pegOffsetValue":null, + // "pegPriceType":"", + // "currency":"USD", + // "settlCurrency":"XBt", + // "ordType":"Limit", + // "timeInForce":"GoodTillCancel", + // "execInst":"", + // "contingencyType":"", + // "exDestination":"XBME", + // "ordStatus":"New", + // "triggered":"", + // "workingIndicator":true, + // "ordRejReason":"", + // "simpleLeavesQty":null, + // "leavesQty":1, + // "simpleCumQty":null, + // "cumQty":0, + // "avgPx":null, + // "multiLegReportingType":"SingleSecurity", + // "text":"Submitted via API.", + // "transactTime":"2021-01-02T21:38:49.246Z", + // "timestamp":"2021-01-02T21:38:49.246Z" + // } + // const status = this.parseOrderStatus (this.safeString (order, 'ordStatus')); const marketId = this.safeString (order, 'symbol'); const symbol = this.safeSymbol (marketId, market); @@ -25922,6 +27654,8 @@ module.exports = class bitmex extends Exchange { const clientOrderId = this.safeString (order, 'clOrdID'); const timeInForce = this.parseTimeInForce (this.safeString (order, 'timeInForce')); const stopPrice = this.safeFloat (order, 'stopPx'); + const execInst = this.safeString (order, 'execInst'); + const postOnly = (execInst === 'ParticipateDoNotInitiate'); return { 'info': order, 'id': id, @@ -25932,6 +27666,7 @@ module.exports = class bitmex extends Exchange { 'symbol': symbol, 'type': type, 'timeInForce': timeInForce, + 'postOnly': postOnly, 'side': side, 'price': price, 'stopPrice': stopPrice, @@ -26000,18 +27735,21 @@ module.exports = class bitmex extends Exchange { const request = { 'symbol': market['id'], 'side': this.capitalize (side), - 'orderQty': amount, + 'orderQty': parseFloat (this.amountToPrecision (symbol, amount)), 'ordType': orderType, }; - if (price !== undefined) { - if (orderType === 'Stop') { - const stopPrice = this.safeFloat2 (params, 'stopPx', 'stopPrice'); - request['stopPx'] = stopPrice; - params = this.omit (params, [ 'stopPx', 'stopPrice' ]); + if ((orderType === 'Stop') || (orderType === 'StopLimit') || (orderType === 'MarketIfTouched') || (orderType === 'LimitIfTouched')) { + const stopPrice = this.safeFloat2 (params, 'stopPx', 'stopPrice'); + if (stopPrice === undefined) { + throw new ArgumentsRequired (this.id + ' createOrder() requires a stopPx or stopPrice parameter for the ' + orderType + ' order type'); } else { - request['price'] = price; + request['stopPx'] = parseFloat (this.priceToPrecision (symbol, stopPrice)); + params = this.omit (params, [ 'stopPx', 'stopPrice' ]); } } + if ((orderType === 'Limit') || (orderType === 'StopLimit') || (orderType === 'LimitIfTouched')) { + request['price'] = parseFloat (this.priceToPrecision (symbol, price)); + } const clientOrderId = this.safeString2 (params, 'clOrdID', 'clientOrderId'); if (clientOrderId !== undefined) { request['clOrdID'] = clientOrderId; @@ -26313,7 +28051,7 @@ module.exports = class bitmex extends Exchange { } }; -},{"./base/Exchange":5,"./base/errors":7,"./base/functions/number":13}],39:[function(require,module,exports){ +},{"./base/Exchange":6,"./base/errors":8,"./base/functions/number":14}],39:[function(require,module,exports){ 'use strict'; // --------------------------------------------------------------------------- @@ -27106,7 +28844,10 @@ module.exports = class bitpanda extends Exchange { // const feeInfo = this.safeValue (trade, 'fee', {}); trade = this.safeValue (trade, 'trade', trade); - const timestamp = this.parse8601 (this.safeString (trade, 'time')); + let timestamp = this.safeInteger (trade, 'trade_timestamp'); + if (timestamp === undefined) { + timestamp = this.parse8601 (this.safeString (trade, 'time')); + } const side = this.safeStringLower2 (trade, 'side', 'taker_side'); const price = this.safeFloat (trade, 'price'); const amount = this.safeFloat (trade, 'amount'); @@ -27281,7 +29022,7 @@ module.exports = class bitpanda extends Exchange { if (since !== undefined) { const to = this.safeString (params, 'to'); if (to === undefined) { - throw new ArgumentsRequired (this.id + ' fetchDeposits requires a "to" iso8601 string param with the since argument is specified'); + throw new ArgumentsRequired (this.id + ' fetchDeposits() requires a "to" iso8601 string param with the since argument is specified'); } request['from'] = this.iso8601 (since); } @@ -27336,7 +29077,7 @@ module.exports = class bitpanda extends Exchange { if (since !== undefined) { const to = this.safeString (params, 'to'); if (to === undefined) { - throw new ArgumentsRequired (this.id + ' fetchWithdrawals requires a "to" iso8601 string param with the since argument is specified'); + throw new ArgumentsRequired (this.id + ' fetchWithdrawals() requires a "to" iso8601 string param with the since argument is specified'); } request['from'] = this.iso8601 (since); } @@ -27641,6 +29382,7 @@ module.exports = class bitpanda extends Exchange { } const timeInForce = this.parseTimeInForce (this.safeString (order, 'time_in_force')); const stopPrice = this.safeFloat (order, 'trigger_price'); + const postOnly = this.safeValue (order, 'is_post_only'); const result = { 'id': id, 'clientOrderId': clientOrderId, @@ -27651,6 +29393,7 @@ module.exports = class bitpanda extends Exchange { 'symbol': symbol, 'type': type, 'timeInForce': timeInForce, + 'postOnly': postOnly, 'side': side, 'price': price, 'stopPrice': stopPrice, @@ -27725,7 +29468,7 @@ module.exports = class bitpanda extends Exchange { if (uppercaseType === 'STOP') { const triggerPrice = this.safeFloat (params, 'trigger_price'); if (triggerPrice === undefined) { - throw new ArgumentsRequired (this.id + ' createOrder requires a trigger_price param for ' + type + ' orders'); + throw new ArgumentsRequired (this.id + ' createOrder() requires a trigger_price param for ' + type + ' orders'); } request['trigger_price'] = this.priceToPrecision (symbol, triggerPrice); params = this.omit (params, 'trigger_price'); @@ -27876,7 +29619,7 @@ module.exports = class bitpanda extends Exchange { if (since !== undefined) { const to = this.safeString (params, 'to'); if (to === undefined) { - throw new ArgumentsRequired (this.id + ' fetchOrders requires a "to" iso8601 string param with the since argument is specified, max range is 100 days'); + throw new ArgumentsRequired (this.id + ' fetchOrders() requires a "to" iso8601 string param with the since argument is specified, max range is 100 days'); } request['from'] = this.iso8601 (since); } @@ -28040,7 +29783,7 @@ module.exports = class bitpanda extends Exchange { if (since !== undefined) { const to = this.safeString (params, 'to'); if (to === undefined) { - throw new ArgumentsRequired (this.id + ' fetchMyTrades requires a "to" iso8601 string param with the since argument is specified, max range is 100 days'); + throw new ArgumentsRequired (this.id + ' fetchMyTrades() requires a "to" iso8601 string param with the since argument is specified, max range is 100 days'); } request['from'] = this.iso8601 (since); } @@ -28126,14 +29869,14 @@ module.exports = class bitpanda extends Exchange { } }; -},{"./base/Exchange":5,"./base/errors":7}],40:[function(require,module,exports){ +},{"./base/Exchange":6,"./base/errors":8}],40:[function(require,module,exports){ 'use strict'; // --------------------------------------------------------------------------- const Exchange = require ('./base/Exchange'); const { ExchangeError, InvalidNonce, AuthenticationError, OrderNotFound } = require ('./base/errors'); -const { TICK_SIZE } = require ('./base/functions/number'); +const { TICK_SIZE, ROUND } = require ('./base/functions/number'); // --------------------------------------------------------------------------- @@ -28310,23 +30053,25 @@ module.exports = class bitso extends Exchange { const taker = this.safeFloat (flatRate, 'taker'); const feeTiers = this.safeValue (fees, 'structure', []); const fee = { - 'maker': maker, - 'taker': taker, + 'taker': parseFloat (this.decimalToPrecision (taker / 100, ROUND, 0.00000001, TICK_SIZE)), + 'maker': parseFloat (this.decimalToPrecision (maker / 100, ROUND, 0.00000001, TICK_SIZE)), 'percentage': true, 'tierBased': true, }; const takerFees = []; const makerFees = []; - for (let i = 0; i < feeTiers.length; i++) { - const tier = feeTiers[i]; + for (let j = 0; j < feeTiers.length; j++) { + const tier = feeTiers[j]; const volume = this.safeFloat (tier, 'volume'); const takerFee = this.safeFloat (tier, 'taker'); const makerFee = this.safeFloat (tier, 'maker'); - takerFees.push ([ volume, takerFee ]); - makerFees.push ([ volume, makerFee ]); - if (i === 0) { - fee['taker'] = taker; - fee['maker'] = maker; + const takerFeeToPrecision = parseFloat (this.decimalToPrecision (takerFee / 100, ROUND, 0.00000001, TICK_SIZE)); + const makerFeeToPrecision = parseFloat (this.decimalToPrecision (makerFee / 100, ROUND, 0.00000001, TICK_SIZE)); + takerFees.push ([ volume, takerFeeToPrecision ]); + makerFees.push ([ volume, makerFeeToPrecision ]); + if (j === 0) { + fee['taker'] = parseFloat (this.decimalToPrecision (taker / 100, ROUND, 0.00000001, TICK_SIZE)); + fee['maker'] = parseFloat (this.decimalToPrecision (maker / 100, ROUND, 0.00000001, TICK_SIZE)); } } const tiers = { @@ -28563,6 +30308,7 @@ module.exports = class bitso extends Exchange { 'symbol': symbol, 'type': orderType, 'timeInForce': undefined, + 'postOnly': undefined, 'side': side, 'price': price, 'stopPrice': undefined, @@ -28750,13 +30496,13 @@ module.exports = class bitso extends Exchange { } }; -},{"./base/Exchange":5,"./base/errors":7,"./base/functions/number":13}],41:[function(require,module,exports){ +},{"./base/Exchange":6,"./base/errors":8,"./base/functions/number":14}],41:[function(require,module,exports){ 'use strict'; // --------------------------------------------------------------------------- const Exchange = require ('./base/Exchange'); -const { AuthenticationError, ExchangeError, NotSupported, PermissionDenied, InvalidNonce, OrderNotFound, InsufficientFunds, InvalidAddress, InvalidOrder, ArgumentsRequired, OnMaintenance } = require ('./base/errors'); +const { AuthenticationError, ExchangeError, NotSupported, PermissionDenied, InvalidNonce, OrderNotFound, InsufficientFunds, InvalidAddress, InvalidOrder, ArgumentsRequired, OnMaintenance, ExchangeNotAvailable } = require ('./base/errors'); // --------------------------------------------------------------------------- @@ -28976,6 +30722,7 @@ module.exports = class bitstamp extends Exchange { 'Order not found': OrderNotFound, 'Price is more than 20% below market price.': InvalidOrder, 'Bitstamp.net is under scheduled maintenance.': OnMaintenance, // { "error": "Bitstamp.net is under scheduled maintenance. We'll be back soon." } + 'Order could not be placed.': ExchangeNotAvailable, // Order could not be placed (perhaps due to internal error or trade halt). Please retry placing order. }, 'broad': { 'Minimum order size is': InvalidOrder, // Minimum order size is 5.0 EUR. @@ -29458,7 +31205,7 @@ module.exports = class bitstamp extends Exchange { const duration = this.parseTimeframe (timeframe); if (limit === undefined) { if (since === undefined) { - throw new ArgumentsRequired (this.id + ' fetchOHLCV requires a since argument or a limit argument'); + throw new ArgumentsRequired (this.id + ' fetchOHLCV() requires a since argument or a limit argument'); } else { limit = 1000; const start = parseInt (since / 1000); @@ -29524,8 +31271,8 @@ module.exports = class bitstamp extends Exchange { return { 'info': balance, 'symbol': symbol, - 'maker': balance.fee, - 'taker': balance.fee, + 'maker': balance['fee'], + 'taker': balance['fee'], }; } @@ -30015,6 +31762,7 @@ module.exports = class bitstamp extends Exchange { 'symbol': symbol, 'type': undefined, 'timeInForce': undefined, + 'postOnly': undefined, 'side': side, 'price': price, 'stopPrice': undefined, @@ -30357,7 +32105,7 @@ module.exports = class bitstamp extends Exchange { } }; -},{"./base/Exchange":5,"./base/errors":7}],42:[function(require,module,exports){ +},{"./base/Exchange":6,"./base/errors":8}],42:[function(require,module,exports){ 'use strict'; // --------------------------------------------------------------------------- @@ -30658,13 +32406,13 @@ module.exports = class bitstamp1 extends Exchange { } }; -},{"./base/Exchange":5,"./base/errors":7}],43:[function(require,module,exports){ +},{"./base/Exchange":6,"./base/errors":8}],43:[function(require,module,exports){ 'use strict'; // --------------------------------------------------------------------------- const Exchange = require ('./base/Exchange'); -const { BadSymbol, ExchangeError, ExchangeNotAvailable, AuthenticationError, InvalidOrder, InsufficientFunds, OrderNotFound, DDoSProtection, PermissionDenied, AddressPending, OnMaintenance, BadRequest } = require ('./base/errors'); +const { BadSymbol, ExchangeError, ExchangeNotAvailable, AuthenticationError, InvalidOrder, InsufficientFunds, OrderNotFound, DDoSProtection, PermissionDenied, AddressPending, OnMaintenance, BadRequest, InvalidAddress } = require ('./base/errors'); const { TRUNCATE, DECIMAL_PLACES } = require ('./base/functions/number'); // --------------------------------------------------------------------------- @@ -30684,6 +32432,7 @@ module.exports = class bittrex extends Exchange { 'CORS': false, 'cancelAllOrders': true, 'cancelOrder': true, + 'createDepositAddress': true, 'createMarketOrder': true, 'createOrder': true, 'fetchBalance': true, @@ -30798,10 +32547,10 @@ module.exports = class bittrex extends Exchange { }, 'fees': { 'trading': { - 'tierBased': false, + 'tierBased': true, 'percentage': true, - 'maker': 0.0025, - 'taker': 0.0025, + 'maker': 0.0035, + 'taker': 0.0035, }, 'funding': { 'tierBased': false, @@ -31419,7 +33168,22 @@ module.exports = class bittrex extends Exchange { const isCeilingMarket = (uppercaseType === 'CEILING_MARKET'); const isCeilingOrder = isCeilingLimit || isCeilingMarket; if (isCeilingOrder) { - request['ceiling'] = this.priceToPrecision (symbol, price); + let cost = undefined; + if (isCeilingLimit) { + request['limit'] = this.priceToPrecision (symbol, price); + cost = this.safeFloat2 (params, 'ceiling', 'cost', amount); + } else if (isCeilingMarket) { + cost = this.safeFloat2 (params, 'ceiling', 'cost'); + if (cost === undefined) { + if (price === undefined) { + cost = amount; + } else { + cost = amount * price; + } + } + } + params = this.omit (params, [ 'ceiling', 'cost' ]); + request['ceiling'] = this.costToPrecision (symbol, cost); // bittrex only accepts IMMEDIATE_OR_CANCEL or FILL_OR_KILL for ceiling orders request['timeInForce'] = 'IMMEDIATE_OR_CANCEL'; } else { @@ -31636,7 +33400,7 @@ module.exports = class bittrex extends Exchange { 'GOOD_TIL_CANCELLED': 'GTC', 'IMMEDIATE_OR_CANCEL': 'IOC', 'FILL_OR_KILL': 'FOK', - 'POST_ONLY_GOOD_TIL_CANCELLED': 'POST_ONLY_GOOD_TIL_CANCELLED', + 'POST_ONLY_GOOD_TIL_CANCELLED': 'PO', }; return this.safeString (timeInForces, timeInForce, timeInForce); } @@ -31706,6 +33470,7 @@ module.exports = class bittrex extends Exchange { status = 'canceled'; } const timeInForce = this.parseTimeInForce (this.safeString (order, 'timeInForce')); + const postOnly = (timeInForce === 'PO'); return { 'id': this.safeString (order, 'id'), 'clientOrderId': undefined, @@ -31715,6 +33480,7 @@ module.exports = class bittrex extends Exchange { 'symbol': symbol, 'type': type, 'timeInForce': timeInForce, + 'postOnly': postOnly, 'side': direction, 'price': limit, 'stopPrice': undefined, @@ -31852,6 +33618,40 @@ module.exports = class bittrex extends Exchange { return this.parseOrders (response, market, since, limit); } + async createDepositAddress (code, params = {}) { + await this.loadMarkets (); + const currency = this.currency (code); + const request = { + 'currencySymbol': currency['id'], + }; + const response = await this.privatePostAddresses (this.extend (request, params)); + // + // { + // "status":"PROVISIONED", + // "currencySymbol":"XRP", + // "cryptoAddress":"rPVMhWBsfF9iMXYj3aAzJVkPDTFNSyWdKy", + // "cryptoAddressTag":"392034158" + // } + // + let address = this.safeString (response, 'cryptoAddress'); + const message = this.safeString (response, 'status'); + if (!address || message === 'REQUESTED') { + throw new AddressPending (this.id + ' the address for ' + code + ' is being generated (pending, not ready yet, retry again later)'); + } + let tag = this.safeString (response, 'cryptoAddressTag'); + if ((tag === undefined) && (currency['type'] in this.options['tag'])) { + tag = address; + address = currency['address']; + } + this.checkAddress (address); + return { + 'currency': code, + 'address': address, + 'tag': tag, + 'info': response, + }; + } + async fetchDepositAddress (code, params = {}) { await this.loadMarkets (); const currency = this.currency (code); @@ -31859,18 +33659,21 @@ module.exports = class bittrex extends Exchange { 'currencySymbol': currency['id'], }; const response = await this.privateGetAddressesCurrencySymbol (this.extend (request, params)); - // { - // "status": "PROVISIONED", - // "currencySymbol": "BTC", - // "cryptoAddress": "1PhmYjnJPZH5NUwV8AUjqkeDkCBpbE2xqX" - // } + // + // { + // "status":"PROVISIONED", + // "currencySymbol":"XRP", + // "cryptoAddress":"rPVMhWBsfF9iMXYj3aAzJVkPDTFNSyWdKy", + // "cryptoAddressTag":"392034158" + // } + // let address = this.safeString (response, 'cryptoAddress'); const message = this.safeString (response, 'status'); if (!address || message === 'REQUESTED') { throw new AddressPending (this.id + ' the address for ' + code + ' is being generated (pending, not ready yet, retry again later)'); } - let tag = undefined; - if (currency['type'] in this.options['tag']) { + let tag = this.safeString (response, 'cryptoAddressTag'); + if ((tag === undefined) && (currency['type'] in this.options['tag'])) { tag = address; address = currency['address']; } @@ -31970,6 +33773,9 @@ module.exports = class bittrex extends Exchange { this.throwExactlyMatchedException (this.exceptions['exact'], code, feedback); this.throwBroadlyMatchedException (this.exceptions['broad'], code, feedback); } + if ((code === 'NOT_FOUND') && (url.indexOf ('addresses') >= 0)) { + throw new InvalidAddress (feedback); + } // throw new ExchangeError (this.id + ' malformed response ' + this.json (response)); return; } @@ -32033,14 +33839,14 @@ module.exports = class bittrex extends Exchange { } }; -},{"./base/Exchange":5,"./base/errors":7,"./base/functions/number":13}],44:[function(require,module,exports){ +},{"./base/Exchange":6,"./base/errors":8,"./base/functions/number":14}],44:[function(require,module,exports){ 'use strict'; // ---------------------------------------------------------------------------- const Exchange = require ('./base/Exchange'); const { ExchangeError, BadSymbol, AuthenticationError, InsufficientFunds, InvalidOrder, ArgumentsRequired, OrderNotFound, InvalidAddress, BadRequest, RateLimitExceeded, PermissionDenied, ExchangeNotAvailable, AccountSuspended, OnMaintenance } = require ('./base/errors'); -const { TRUNCATE } = require ('./base/functions/number'); +const { SIGNIFICANT_DIGITS, DECIMAL_PLACES, TRUNCATE, ROUND } = require ('./base/functions/number'); // ---------------------------------------------------------------------------- @@ -32257,12 +34063,33 @@ module.exports = class bitvavo extends Exchange { 'expires': 1000, // 1 second }, }, + 'precisionMode': SIGNIFICANT_DIGITS, 'commonCurrencies': { 'MIOTA': 'IOTA', // https://github.com/ccxt/ccxt/issues/7487 }, }); } + currencyToPrecision (currency, fee) { + return this.decimalToPrecision (fee, 0, this.currencies[currency]['precision']); + } + + amountToPrecision (symbol, amount) { + // https://docs.bitfinex.com/docs/introduction#amount-precision + // The amount field allows up to 8 decimals. + // Anything exceeding this will be rounded to the 8th decimal. + return this.decimalToPrecision (amount, TRUNCATE, this.markets[symbol]['precision']['amount'], DECIMAL_PLACES); + } + + priceToPrecision (symbol, price) { + price = this.decimalToPrecision (price, ROUND, this.markets[symbol]['precision']['price'], this.precisionMode); + // https://docs.bitfinex.com/docs/introduction#price-precision + // The precision level of all trading prices is based on significant figures. + // All pairs on Bitfinex use up to 5 significant digits and up to 8 decimals (e.g. 1.2345, 123.45, 1234.5, 0.00012345). + // Prices submit with a precision larger than 5 will be cut by the API. + return this.decimalToPrecision (price, TRUNCATE, 8, DECIMAL_PLACES); + } + async fetchTime (params = {}) { const response = await this.publicGetTime (params); // @@ -32804,16 +34631,18 @@ module.exports = class bitvavo extends Exchange { const request = { 'market': market['id'], 'side': side, - 'orderType': type, + 'orderType': type, // 'market', 'limit', 'stopLoss', 'stopLossLimit', 'takeProfit', 'takeProfitLimit' // 'amount': this.amountToPrecision (symbol, amount), // 'price': this.priceToPrecision (symbol, price), // 'amountQuote': this.costToPrecision (symbol, cost), - // 'timeInForce': 'GTC', // "GTC" "IOC" "FOK" - // 'selfTradePrevention': "decrementAndCancel", // "decrementAndCancel" "cancelOldest" "cancelNewest" "cancelBoth" + // 'timeInForce': 'GTC', // 'GTC', 'IOC', 'FOK' + // 'selfTradePrevention': 'decrementAndCancel', // 'decrementAndCancel', 'cancelOldest', 'cancelNewest', 'cancelBoth' // 'postOnly': false, // 'disableMarketProtection': false, // don't cancel if the next fill price is 10% worse than the best fill price // 'responseRequired': true, // false is faster }; + const isStopLimit = (type === 'stopLossLimit') || (type === 'takeProfitLimit'); + const isStopMarket = (type === 'stopLoss') || (type === 'takeProfit'); if (type === 'market') { let cost = undefined; if (price !== undefined) { @@ -32831,6 +34660,26 @@ module.exports = class bitvavo extends Exchange { } else if (type === 'limit') { request['price'] = this.priceToPrecision (symbol, price); request['amount'] = this.amountToPrecision (symbol, amount); + } else if (isStopMarket || isStopLimit) { + let stopPrice = this.safeFloat2 (params, 'stopPrice', 'triggerAmount'); + if (stopPrice === undefined) { + if (isStopLimit) { + throw new ArgumentsRequired (this.id + ' createOrder requires a stopPrice parameter for a ' + type + ' order'); + } else if (isStopMarket) { + if (price === undefined) { + throw new ArgumentsRequired (this.id + ' createOrder requires a price argument or a stopPrice parameter for a ' + type + ' order'); + } else { + stopPrice = price; + } + } + } + if (isStopLimit) { + request['price'] = this.priceToPrecision (symbol, price); + } + params = this.omit (params, [ 'stopPrice', 'triggerAmount' ]); + request['triggerAmount'] = this.priceToPrecision (symbol, stopPrice); + request['triggerType'] = 'price'; + request['amount'] = this.amountToPrecision (symbol, amount); } const response = await this.privatePostOrder (this.extend (request, params)); // @@ -32892,13 +34741,13 @@ module.exports = class bitvavo extends Exchange { const response = await this.privatePutOrder (this.extend (request, params)); return this.parseOrder (response, market); } else { - throw new ArgumentsRequired (this.id + ' editOrder requires an amount argument, or a price argument, or non-empty params'); + throw new ArgumentsRequired (this.id + ' editOrder() requires an amount argument, or a price argument, or non-empty params'); } } async cancelOrder (id, symbol = undefined, params = {}) { if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' cancelOrder requires a symbol argument'); + throw new ArgumentsRequired (this.id + ' cancelOrder() requires a symbol argument'); } await this.loadMarkets (); const market = this.market (symbol); @@ -32936,7 +34785,7 @@ module.exports = class bitvavo extends Exchange { async fetchOrder (id, symbol = undefined, params = {}) { if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' fetchOrder requires a symbol argument'); + throw new ArgumentsRequired (this.id + ' fetchOrder() requires a symbol argument'); } await this.loadMarkets (); await this.loadMarkets (); @@ -32985,7 +34834,7 @@ module.exports = class bitvavo extends Exchange { async fetchOrders (symbol = undefined, since = undefined, limit = undefined, params = {}) { if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' fetchOrders requires a symbol argument'); + throw new ArgumentsRequired (this.id + ' fetchOrders() requires a symbol argument'); } await this.loadMarkets (); const market = this.market (symbol); @@ -33046,24 +34895,13 @@ module.exports = class bitvavo extends Exchange { async fetchOpenOrders (symbol = undefined, since = undefined, limit = undefined, params = {}) { await this.loadMarkets (); const request = { - // 'market': market['id'], - // 'limit': 500, - // 'start': since, - // 'end': this.milliseconds (), - // 'orderIdFrom': 'af76d6ce-9f7c-4006-b715-bb5d430652d0', - // 'orderIdTo': 'af76d6ce-9f7c-4006-b715-bb5d430652d0', + // 'market': market['id'], // rate limit 25 without a market, 1 with market specified }; let market = undefined; if (symbol !== undefined) { market = this.market (symbol); request['market'] = market['id']; } - if (since !== undefined) { - request['start'] = since; - } - if (limit !== undefined) { - request['limit'] = limit; // default 500, max 1000 - } const response = await this.privateGetOrdersOpen (this.extend (request, params)); // // [ @@ -33118,6 +34956,7 @@ module.exports = class bitvavo extends Exchange { 'partiallyFilled': 'open', 'expired': 'canceled', 'rejected': 'canceled', + 'awaitingTrigger': 'open', // https://github.com/ccxt/ccxt/issues/8489 }; return this.safeString (statuses, status, status); } @@ -33219,6 +35058,9 @@ module.exports = class bitvavo extends Exchange { } } const timeInForce = this.safeString (order, 'timeInForce'); + const postOnly = this.safeValue (order, 'postOnly'); + // https://github.com/ccxt/ccxt/issues/8489 + const stopPrice = this.safeFloat (order, 'triggerPrice'); return { 'info': order, 'id': id, @@ -33229,9 +35071,10 @@ module.exports = class bitvavo extends Exchange { 'symbol': symbol, 'type': type, 'timeInForce': timeInForce, + 'postOnly': postOnly, 'side': side, 'price': price, - 'stopPrice': undefined, + 'stopPrice': stopPrice, 'amount': amount, 'cost': cost, 'average': average, @@ -33245,7 +35088,7 @@ module.exports = class bitvavo extends Exchange { async fetchMyTrades (symbol = undefined, since = undefined, limit = undefined, params = {}) { if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' fetchMyTrades requires a symbol argument'); + throw new ArgumentsRequired (this.id + ' fetchMyTrades() requires a symbol argument'); } await this.loadMarkets (); const market = this.market (symbol); @@ -33530,7 +35373,7 @@ module.exports = class bitvavo extends Exchange { } }; -},{"./base/Exchange":5,"./base/errors":7,"./base/functions/number":13}],45:[function(require,module,exports){ +},{"./base/Exchange":6,"./base/errors":8,"./base/functions/number":14}],45:[function(require,module,exports){ 'use strict'; // --------------------------------------------------------------------------- @@ -34208,7 +36051,7 @@ module.exports = class bitz extends Exchange { } } else { if (since !== undefined) { - throw new ArgumentsRequired (this.id + ' fetchOHLCV requires a limit argument if the since argument is specified'); + throw new ArgumentsRequired (this.id + ' fetchOHLCV() requires a limit argument if the since argument is specified'); } } const response = await this.marketGetKline (this.extend (request, params)); @@ -34312,6 +36155,7 @@ module.exports = class bitz extends Exchange { 'symbol': symbol, 'type': 'limit', 'timeInForce': undefined, + 'postOnly': undefined, 'side': side, 'price': price, 'stopPrice': undefined, @@ -34481,7 +36325,7 @@ module.exports = class bitz extends Exchange { async fetchOrdersWithMethod (method, symbol = undefined, since = undefined, limit = undefined, params = {}) { if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' fetchOpenOrders requires a symbol argument'); + throw new ArgumentsRequired (this.id + ' fetchOpenOrders() requires a symbol argument'); } await this.loadMarkets (); const market = this.market (symbol); @@ -34817,7 +36661,7 @@ module.exports = class bitz extends Exchange { } }; -},{"./base/Exchange":5,"./base/errors":7}],46:[function(require,module,exports){ +},{"./base/Exchange":6,"./base/errors":8}],46:[function(require,module,exports){ 'use strict'; // --------------------------------------------------------------------------- @@ -35055,7 +36899,7 @@ module.exports = class bl3p extends Exchange { } }; -},{"./base/Exchange":5}],47:[function(require,module,exports){ +},{"./base/Exchange":6}],47:[function(require,module,exports){ 'use strict'; // --------------------------------------------------------------------------- @@ -35720,6 +37564,7 @@ module.exports = class bleutrade extends Exchange { 'symbol': symbol, 'type': 'limit', 'timeInForce': undefined, + 'postOnly': undefined, 'side': side, 'price': price, 'stopPrice': undefined, @@ -35870,7 +37715,7 @@ module.exports = class bleutrade extends Exchange { } }; -},{"./base/Exchange":5,"./base/errors":7}],48:[function(require,module,exports){ +},{"./base/Exchange":6,"./base/errors":8}],48:[function(require,module,exports){ 'use strict'; // --------------------------------------------------------------------------- @@ -36333,6 +38178,7 @@ module.exports = class braziliex extends Exchange { 'symbol': symbol, 'type': 'limit', 'timeInForce': undefined, + 'postOnly': undefined, 'side': side, 'price': price, 'stopPrice': undefined, @@ -36513,7 +38359,7 @@ module.exports = class braziliex extends Exchange { } }; -},{"./base/Exchange":5,"./base/errors":7}],49:[function(require,module,exports){ +},{"./base/Exchange":6,"./base/errors":8}],49:[function(require,module,exports){ 'use strict'; // --------------------------------------------------------------------------- @@ -36864,6 +38710,7 @@ module.exports = class btcalpha extends Exchange { 'symbol': symbol, 'type': 'limit', 'timeInForce': undefined, + 'postOnly': undefined, 'side': side, 'price': price, 'stopPrice': undefined, @@ -37017,7 +38864,7 @@ module.exports = class btcalpha extends Exchange { } }; -},{"./base/Exchange":5,"./base/errors":7}],50:[function(require,module,exports){ +},{"./base/Exchange":6,"./base/errors":8}],50:[function(require,module,exports){ 'use strict'; // --------------------------------------------------------------------------- @@ -37326,6 +39173,7 @@ module.exports = class btcbox extends Exchange { 'side': side, 'type': undefined, 'timeInForce': undefined, + 'postOnly': undefined, 'status': status, 'symbol': symbol, 'price': price, @@ -37444,7 +39292,7 @@ module.exports = class btcbox extends Exchange { } }; -},{"./base/Exchange":5,"./base/errors":7}],51:[function(require,module,exports){ +},{"./base/Exchange":6,"./base/errors":8}],51:[function(require,module,exports){ 'use strict'; // --------------------------------------------------------------------------- @@ -38312,6 +40160,7 @@ module.exports = class btcmarkets extends Exchange { const clientOrderId = this.safeString (order, 'clientOrderId'); const timeInForce = this.safeString (order, 'timeInForce'); const stopPrice = this.safeFloat (order, 'triggerPrice'); + const postOnly = this.safeValue (order, 'postOnly'); return { 'info': order, 'id': id, @@ -38322,6 +40171,7 @@ module.exports = class btcmarkets extends Exchange { 'symbol': symbol, 'type': type, 'timeInForce': timeInForce, + 'postOnly': postOnly, 'side': side, 'price': price, 'stopPrice': stopPrice, @@ -38501,7 +40351,7 @@ module.exports = class btcmarkets extends Exchange { } }; -},{"./base/Exchange":5,"./base/errors":7}],52:[function(require,module,exports){ +},{"./base/Exchange":6,"./base/errors":8}],52:[function(require,module,exports){ 'use strict'; // --------------------------------------------------------------------------- @@ -38839,6 +40689,7 @@ module.exports = class btctradeua extends Exchange { 'symbol': symbol, 'type': undefined, 'timeInForce': undefined, + 'postOnly': undefined, 'side': this.safeString (order, 'type'), 'price': this.safeFloat (order, 'price'), 'stopPrice': undefined, @@ -38855,7 +40706,7 @@ module.exports = class btctradeua extends Exchange { async fetchOpenOrders (symbol = undefined, since = undefined, limit = undefined, params = {}) { if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' fetchOpenOrders requires a symbol argument'); + throw new ArgumentsRequired (this.id + ' fetchOpenOrders() requires a symbol argument'); } await this.loadMarkets (); const market = this.market (symbol); @@ -38896,7 +40747,7 @@ module.exports = class btctradeua extends Exchange { } }; -},{"./base/Exchange":5,"./base/errors":7}],53:[function(require,module,exports){ +},{"./base/Exchange":6,"./base/errors":8}],53:[function(require,module,exports){ 'use strict'; // --------------------------------------------------------------------------- @@ -39174,7 +41025,7 @@ module.exports = class btcturk extends Exchange { }; if (type === 'market') { if (!('Total' in params)) { - throw new ExchangeError (this.id + ' createOrder requires the "Total" extra parameter for market orders (amount and price are both ignored)'); + throw new ExchangeError (this.id + ' createOrder() requires the "Total" extra parameter for market orders (amount and price are both ignored)'); } } else { request['Price'] = price; @@ -39225,7 +41076,7 @@ module.exports = class btcturk extends Exchange { } }; -},{"./base/Exchange":5,"./base/errors":7}],54:[function(require,module,exports){ +},{"./base/Exchange":6,"./base/errors":8}],54:[function(require,module,exports){ 'use strict'; // --------------------------------------------------------------------------- @@ -39765,29 +41616,65 @@ module.exports = class buda extends Exchange { } parseOrder (order, market = undefined) { + // + // { + // 'id': 63679183, + // 'uuid': 'f9697bee-627e-4175-983f-0d5a41963fec', + // 'market_id': 'ETH-CLP', + // 'account_id': 51590, + // 'type': 'Ask', + // 'state': 'received', + // 'created_at': '2021-01-04T08:29:52.730Z', + // 'fee_currency': 'CLP', + // 'price_type': 'limit', + // 'source': None, + // 'limit': ['741000.0', 'CLP'], + // 'amount': ['0.001', 'ETH'], + // 'original_amount': ['0.001', 'ETH'], + // 'traded_amount': ['0.0', 'ETH'], + // 'total_exchanged': ['0.0', 'CLP'], + // 'paid_fee': ['0.0', 'CLP'] + // } + // const id = this.safeString (order, 'id'); const timestamp = this.parse8601 (this.safeString (order, 'created_at')); const marketId = this.safeString (order, 'market_id'); - const symbol = this.safeSymbol (marketId, market); + const symbol = this.safeSymbol (marketId, market, '-'); const type = this.safeString (order, 'price_type'); const side = this.safeStringLower (order, 'type'); const status = this.parseOrderStatus (this.safeString (order, 'state')); - const amount = parseFloat (order['original_amount'][0]); - const remaining = parseFloat (order['amount'][0]); - const filled = parseFloat (order['traded_amount'][0]); - const cost = parseFloat (order['total_exchanged'][0]); - let price = this.safeFloat (order, 'limit'); - if (price !== undefined) { - price = parseFloat (price[0]); + const originalAmount = this.safeValue (order, 'original_amount', []); + const amount = this.safeFloat (originalAmount, 0); + const remainingAmount = this.safeValue (order, 'amount', []); + const remaining = this.safeFloat (remainingAmount, 0); + const tradedAmount = this.safeValue (order, 'traded_amount', []); + const filled = this.safeFloat (tradedAmount, 0); + const totalExchanged = this.safeValue (order, 'totalExchanged', []); + const cost = this.safeFloat (totalExchanged, 0); + const limitPrice = this.safeValue (order, 'limit', []); + let price = this.safeFloat (limitPrice, 0); + if (price === undefined) { + if (limitPrice !== undefined) { + price = limitPrice; + } } - if (cost > 0 && filled > 0) { - price = this.priceToPrecision (symbol, cost / filled); + let average = undefined; + if ((cost !== undefined) && (filled !== undefined) && (filled > 0)) { + average = this.priceToPrecision (symbol, cost / filled); + } + const paidFee = this.safeValue (order, 'paid_fee', []); + const feeCost = this.safeFloat (paidFee, 0); + let fee = undefined; + if (feeCost !== undefined) { + const feeCurrencyId = this.safeString (paidFee, 1); + const feeCurrencyCode = this.safeCurrencyCode (feeCurrencyId); + fee = { + 'cost': feeCost, + 'code': feeCurrencyCode, + }; } - const fee = { - 'cost': parseFloat (order['paid_fee'][0]), - 'currency': order['paid_fee'][1], - }; return { + 'info': order, 'id': id, 'clientOrderId': undefined, 'datetime': this.iso8601 (timestamp), @@ -39797,17 +41684,17 @@ module.exports = class buda extends Exchange { 'symbol': symbol, 'type': type, 'timeInForce': undefined, + 'postOnly': undefined, 'side': side, 'price': price, 'stopPrice': undefined, + 'average': average, 'cost': cost, 'amount': amount, 'filled': filled, 'remaining': remaining, 'trades': undefined, 'fee': fee, - 'info': order, - 'average': undefined, }; } @@ -40015,7 +41902,7 @@ module.exports = class buda extends Exchange { } }; -},{"./base/Exchange":5,"./base/errors":7}],55:[function(require,module,exports){ +},{"./base/Exchange":6,"./base/errors":8}],55:[function(require,module,exports){ 'use strict'; // --------------------------------------------------------------------------- @@ -40779,6 +42666,7 @@ module.exports = class bw extends Exchange { 'symbol': symbol, 'type': 'limit', 'timeInForce': undefined, + 'postOnly': undefined, 'side': side, 'price': price, 'stopPrice': undefined, @@ -40795,7 +42683,7 @@ module.exports = class bw extends Exchange { async fetchOrder (id, symbol = undefined, params = {}) { if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' fetchOrder requires a symbol argument'); + throw new ArgumentsRequired (this.id + ' fetchOrder() requires a symbol argument'); } await this.loadMarkets (); const market = this.market (symbol); @@ -40830,7 +42718,7 @@ module.exports = class bw extends Exchange { async cancelOrder (id, symbol = undefined, params = {}) { if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' cancelOrder requires a symbol argument'); + throw new ArgumentsRequired (this.id + ' cancelOrder() requires a symbol argument'); } await this.loadMarkets (); const market = this.market (symbol); @@ -41222,7 +43110,7 @@ module.exports = class bw extends Exchange { } }; -},{"./base/Exchange":5,"./base/errors":7}],56:[function(require,module,exports){ +},{"./base/Exchange":6,"./base/errors":8}],56:[function(require,module,exports){ 'use strict'; // --------------------------------------------------------------------------- @@ -41242,6 +43130,7 @@ module.exports = class bybit extends Exchange { 'version': 'v2', 'userAgent': undefined, 'rateLimit': 100, + 'hostname': 'bybit.com', // bybit.com, bytick.com 'has': { 'cancelOrder': true, 'CORS': true, @@ -41284,9 +43173,9 @@ module.exports = class bybit extends Exchange { '1y': 'Y', }, 'urls': { - 'test': 'https://api-testnet.bybit.com', + 'test': 'https://api-testnet.{hostname}', 'logo': 'https://user-images.githubusercontent.com/51840849/76547799-daff5b80-649e-11ea-87fb-3be9bac08954.jpg', - 'api': 'https://api.bybit.com', + 'api': 'https://api.{hostname}', 'www': 'https://www.bybit.com', 'doc': [ 'https://bybit-exchange.github.io/docs/inverse/', @@ -41297,117 +43186,112 @@ module.exports = class bybit extends Exchange { 'referral': 'https://www.bybit.com/app/register?ref=X7Prm', }, 'api': { + 'v2': { + 'public': { + 'get': [ + 'orderBook/L2', + 'kline/list', + 'tickers', + 'trading-records', + 'symbols', + 'liq-records', + 'mark-price-kline', + 'index-price-kline', + 'premium-index-kline', + 'open-interest', + 'big-deal', + 'account-ratio', + 'time', + 'announcement', + ], + }, + 'private': { + 'get': [ + 'order/list', + 'order', + 'stop-order/list', + 'stop-order', + 'position/list', + 'execution/list', + 'trade/closed-pnl/list', + 'funding/prev-funding-rate', + 'funding/prev-funding', + 'funding/predicted-funding', + 'account/api-key', + 'account/lcp', + 'wallet/balance', + 'wallet/fund/records', + 'wallet/withdraw/list', + 'exchange-order/list', + ], + 'post': [ + 'order/create', + 'order/cancel', + 'order/cancelAll', + 'order/replace', + 'stop-order/create', + 'stop-order/cancel', + 'stop-order/cancelAll', + 'stop-order/replace', + 'position/change-position-margin', + 'position/trading-stop', + 'position/leverage/save', + ], + }, + }, 'public': { - 'get': [ - 'orderBook/L2', - 'kline/list', - 'tickers', - 'trading-records', - 'symbols', - 'liq-records', - 'mark-price-kline', - 'open-interest', - 'big-deal', - 'account-ratio', - 'time', - 'announcement', - ], + 'linear': { + 'get': [ + 'kline', + 'recent-trading-records', + 'funding/prev-funding-rate', + 'mark-price-kline', + 'index-price-kline', + 'premium-index-kline', + 'risk-limit', + ], + }, }, 'private': { - 'get': [ - 'order/list', - 'order', - 'stop-order/list', - 'stop-order', - 'position/list', - 'wallet/balance', - 'execution/list', - 'trade/closed-pnl/list', - 'account/lcp', - 'exchange-order/list', - ], - 'post': [ - 'order/create', - 'order/cancel', - 'order/cancelAll', - 'order/replace', - 'stop-order/create', - 'stop-order/cancel', - 'stop-order/cancelAll', - 'stop-order/replace', - ], + 'linear': { + 'get': [ + 'order/list', + 'order/search', + 'stop-order/list', + 'stop-order/search', + 'position/list', + 'trade/execution/list', + 'trade/closed-pnl/list', + 'funding/predicted-funding', + 'funding/prev-funding', + ], + 'post': [ + 'order/create', + 'order/cancel', + 'order/cancel-all', + 'order/replace', + 'stop-order/create', + 'stop-order/cancel', + 'stop-order/cancel-all', + 'stop-order/replace', + 'position/set-auto-add-margin', + 'position/switch-isolated', + 'tpsl/switch-mode', + 'position/add-margin', + 'position/set-leverage', + 'position/trading-stop', + ], + }, }, 'openapi': { - 'get': [ - 'order/list', // deprecated - 'stop-order/list', // deprecated - 'wallet/risk-limit/list', - 'funding/prev-funding-rate', - 'funding/prev-funding', - 'funding/predicted-funding', - 'api-key', - 'wallet/fund/records', - 'wallet/withdraw/list', - ], - 'post': [ - 'order/replace', // deprecated - 'stop-order/create', // deprecated - 'stop-order/cancel', // deprecated - 'stop-order/replace', // deprecated - 'position/trading-stop', - 'wallet/risk-limit', - ], - }, - 'publicLinear': { - 'get': [ - 'kline', - 'recent-trading-records', - 'funding/prev-funding-rate', - 'mark-price-kline', - 'risk-limit', - ], - }, - 'privateLinear': { - 'get': [ - 'order/list', - 'order/search', - 'stop-order/list', - 'stop-order/search', - 'position/list', - 'trade/execution/list', - 'trade/closed-pnl/list', - 'funding/prev-funding', - 'funding/predicted-funding', - ], - 'post': [ - 'order/create', - 'order/cancel', - 'order/cancel-all', - 'order/replace', - 'stop-order/create', - 'stop-order/cancel', - 'stop-order/cancel-all', - 'stop-order/replace', - 'position/switch-isolated', - 'position/set-auto-add-margin', - 'tpsl/switch-mode', - 'position/set-leverage', - 'position/trading-stop', - 'position/add-margin', - ], - }, - 'position': { - 'post': [ - 'change-position-margin', - ], - }, - 'user': { - 'get': [ - 'leverage', // deprecated - ], - 'post': [ - 'leverage/save', - ], + 'wallet': { + 'get': [ + 'risk-limit/list', + ], + 'post': [ + 'risk-limit', + ], + }, }, }, 'httpExceptions': { @@ -41510,6 +43394,7 @@ module.exports = class bybit extends Exchange { 'options': { 'marketTypes': { 'BTC/USDT': 'linear', + 'BCH/USDT': 'linear', 'ETH/USDT': 'linear', 'LTC/USDT': 'linear', 'XTZ/USDT': 'linear', @@ -41517,10 +43402,10 @@ module.exports = class bybit extends Exchange { }, 'code': 'BTC', 'cancelAllOrders': { - 'method': 'privatePostOrderCancelAll', // privatePostStopOrderCancelAll + // 'method': 'v2PrivatePostOrderCancelAll', // v2PrivatePostStopOrderCancelAll }, 'recvWindow': 5 * 1000, // 5 sec default - 'timeDifference': 0, // the difference between system clock and Binance clock + 'timeDifference': 0, // the difference between system clock and exchange server clock 'adjustForTimeDifference': false, // controls the adjustment logic upon instantiation }, 'fees': { @@ -41552,7 +43437,7 @@ module.exports = class bybit extends Exchange { } async fetchTime (params = {}) { - const response = await this.publicGetTime (params); + const response = await this.v2PublicGetTime (params); // // { // ret_code: 0, @@ -41570,30 +43455,7 @@ module.exports = class bybit extends Exchange { if (this.options['adjustForTimeDifference']) { await this.loadTimeDifference (); } - const response = await this.publicGetSymbols (params); - // - // { - // ret_code: 0, - // ret_msg: 'OK', - // ext_code: '', - // ext_info: '', - // result: [ - // { - // name: 'BTCUSD', - // base_currency: 'BTC', - // quote_currency: 'USD', - // price_scale: 2, - // taker_fee: '0.00075', - // maker_fee: '-0.00025', - // leverage_filter: { min_leverage: 1, max_leverage: 100, leverage_step: '0.01' }, - // price_filter: { min_price: '0.5', max_price: '999999.5', tick_size: '0.5' }, - // lot_size_filter: { max_trading_qty: 1000000, min_trading_qty: 1, qty_step: 1 } - // }, - // ], - // time_now: '1583930495.454196' - // } - // - // sandbox/testnet + const response = await this.v2PublicGetSymbols (params); // // { // "ret_code":0, @@ -41602,8 +43464,8 @@ module.exports = class bybit extends Exchange { // "ext_info":"", // "result":[ // { - // "symbol":"BTCUSD", - // "symbol_alias":"BTCUSD", + // "name":"BTCUSD", + // "alias":"BTCUSD", // "status":"Trading", // "base_currency":"BTC", // "quote_currency":"USD", @@ -41613,9 +43475,22 @@ module.exports = class bybit extends Exchange { // "leverage_filter":{"min_leverage":1,"max_leverage":100,"leverage_step":"0.01"}, // "price_filter":{"min_price":"0.5","max_price":"999999.5","tick_size":"0.5"}, // "lot_size_filter":{"max_trading_qty":1000000,"min_trading_qty":1,"qty_step":1} - // } + // }, + // { + // "name":"BTCUSDT", + // "alias":"BTCUSDT", + // "status":"Trading", + // "base_currency":"BTC", + // "quote_currency":"USDT", + // "price_scale":2, + // "taker_fee":"0.00075", + // "maker_fee":"-0.00025", + // "leverage_filter":{"min_leverage":1,"max_leverage":100,"leverage_step":"0.01"}, + // "price_filter":{"min_price":"0.5","max_price":"999999.5","tick_size":"0.5"}, + // "lot_size_filter":{"max_trading_qty":100,"min_trading_qty":0.001,"qty_step":0.001} + // }, // ], - // "time_now":"1605916574.118500" + // "time_now":"1610539664.818033" // } // const markets = this.safeValue (response, 'result', []); @@ -41682,65 +43557,6 @@ module.exports = class bybit extends Exchange { return result; } - async fetchBalance (params = {}) { - await this.loadMarkets (); - const request = {}; - const coin = this.safeString (params, 'coin'); - const code = this.safeString (params, 'code'); - if (coin !== undefined) { - request['coin'] = coin; - } else if (code !== undefined) { - const currency = this.currency (code); - request['coin'] = currency['id']; - } - const response = await this.privateGetWalletBalance (this.extend (request, params)); - // - // { - // ret_code: 0, - // ret_msg: 'OK', - // ext_code: '', - // ext_info: '', - // result: { - // BTC: { - // equity: 0, - // available_balance: 0, - // used_margin: 0, - // order_margin: 0, - // position_margin: 0, - // occ_closing_fee: 0, - // occ_funding_fee: 0, - // wallet_balance: 0, - // realised_pnl: 0, - // unrealised_pnl: 0, - // cum_realised_pnl: 0, - // given_cash: 0, - // service_cash: 0 - // } - // }, - // time_now: '1583937810.370020', - // rate_limit_status: 119, - // rate_limit_reset_ms: 1583937810367, - // rate_limit: 120 - // } - // - const result = { - 'info': response, - }; - const balances = this.safeValue (response, 'result', {}); - const currencyIds = Object.keys (balances); - for (let i = 0; i < currencyIds.length; i++) { - const currencyId = currencyIds[i]; - const balance = balances[currencyId]; - const code = this.safeCurrencyCode (currencyId); - const account = this.account (); - account['free'] = this.safeFloat (balance, 'available_balance'); - account['used'] = this.safeFloat (balance, 'used_margin'); - account['total'] = this.safeFloat (balance, 'equity'); - result[code] = account; - } - return this.parseBalance (result); - } - parseTicker (ticker, market = undefined) { // // fetchTicker @@ -41819,7 +43635,7 @@ module.exports = class bybit extends Exchange { const request = { 'symbol': market['id'], }; - const response = await this.publicGetTickers (this.extend (request, params)); + const response = await this.v2PublicGetTickers (this.extend (request, params)); // // { // ret_code: 0, @@ -41867,7 +43683,7 @@ module.exports = class bybit extends Exchange { async fetchTickers (symbols = undefined, params = {}) { await this.loadMarkets (); - const response = await this.publicGetTickers (params); + const response = await this.v2PublicGetTickers (params); // // { // ret_code: 0, @@ -41965,7 +43781,7 @@ module.exports = class bybit extends Exchange { const now = this.seconds (); if (since === undefined) { if (limit === undefined) { - throw new ArgumentsRequired (this.id + ' fetchOHLCV requires a since argument or a limit argument'); + throw new ArgumentsRequired (this.id + ' fetchOHLCV() requires a since argument or a limit argument'); } else { request['from'] = now - limit * duration; } @@ -41977,7 +43793,7 @@ module.exports = class bybit extends Exchange { } const marketTypes = this.safeValue (this.options, 'marketTypes', {}); const marketType = this.safeString (marketTypes, symbol); - const method = (marketType === 'linear') ? 'publicLinearGetKline' : 'publicGetKlineList'; + const method = (marketType === 'linear') ? 'publicLinearGetKline' : 'v2PublicGetKlineList'; const response = await this[method] (this.extend (request, params)); // // inverse perpetual BTC/USD @@ -42132,7 +43948,7 @@ module.exports = class bybit extends Exchange { } const marketTypes = this.safeValue (this.options, 'marketTypes', {}); const marketType = this.safeString (marketTypes, symbol); - const method = (marketType === 'linear') ? 'publicLinearGetRecentTradingRecords' : 'publicGetTradingRecords'; + const method = (marketType === 'linear') ? 'publicLinearGetRecentTradingRecords' : 'v2PublicGetTradingRecords'; const response = await this[method] (this.extend (request, params)); // // { @@ -42186,7 +44002,7 @@ module.exports = class bybit extends Exchange { const request = { 'symbol': market['id'], }; - const response = await this.publicGetOrderBookL2 (this.extend (request, params)); + const response = await this.v2PublicGetOrderBookL2 (this.extend (request, params)); // // { // ret_code: 0, @@ -42209,6 +44025,65 @@ module.exports = class bybit extends Exchange { return this.parseOrderBook (result, timestamp, 'Buy', 'Sell', 'price', 'size'); } + async fetchBalance (params = {}) { + await this.loadMarkets (); + const request = {}; + const coin = this.safeString (params, 'coin'); + const code = this.safeString (params, 'code'); + if (coin !== undefined) { + request['coin'] = coin; + } else if (code !== undefined) { + const currency = this.currency (code); + request['coin'] = currency['id']; + } + const response = await this.v2PrivateGetWalletBalance (this.extend (request, params)); + // + // { + // ret_code: 0, + // ret_msg: 'OK', + // ext_code: '', + // ext_info: '', + // result: { + // BTC: { + // equity: 0, + // available_balance: 0, + // used_margin: 0, + // order_margin: 0, + // position_margin: 0, + // occ_closing_fee: 0, + // occ_funding_fee: 0, + // wallet_balance: 0, + // realised_pnl: 0, + // unrealised_pnl: 0, + // cum_realised_pnl: 0, + // given_cash: 0, + // service_cash: 0 + // } + // }, + // time_now: '1583937810.370020', + // rate_limit_status: 119, + // rate_limit_reset_ms: 1583937810367, + // rate_limit: 120 + // } + // + const result = { + 'info': response, + }; + const balances = this.safeValue (response, 'result', {}); + const currencyIds = Object.keys (balances); + for (let i = 0; i < currencyIds.length; i++) { + const currencyId = currencyIds[i]; + const balance = balances[currencyId]; + const code = this.safeCurrencyCode (currencyId); + const account = this.account (); + account['free'] = this.safeFloat (balance, 'available_balance'); + account['used'] = this.safeFloat (balance, 'used_margin'); + account['total'] = this.safeFloat (balance, 'equity'); + result[code] = account; + } + return this.parseBalance (result); + } + parseOrderStatus (status) { const statuses = { // basic orders @@ -42391,6 +44266,7 @@ module.exports = class bybit extends Exchange { } const timeInForce = this.parseTimeInForce (this.safeString (order, 'time_in_force')); const stopPrice = this.safeFloat (order, 'stop_px'); + const postOnly = (timeInForce === 'PO'); return { 'info': order, 'id': id, @@ -42401,6 +44277,7 @@ module.exports = class bybit extends Exchange { 'symbol': symbol, 'type': type, 'timeInForce': timeInForce, + 'postOnly': postOnly, 'side': side, 'price': price, 'stopPrice': stopPrice, @@ -42417,7 +44294,7 @@ module.exports = class bybit extends Exchange { async fetchOrder (id, symbol = undefined, params = {}) { if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' fetchOrder requires a symbol argument'); + throw new ArgumentsRequired (this.id + ' fetchOrder() requires a symbol argument'); } await this.loadMarkets (); const market = this.market (symbol); @@ -42431,7 +44308,7 @@ module.exports = class bybit extends Exchange { }; const marketTypes = this.safeValue (this.options, 'marketTypes', {}); const marketType = this.safeString (marketTypes, symbol); - let method = (marketType === 'linear') ? 'privateLinearGetOrderSearch' : 'privateGetOrder'; + let method = (marketType === 'linear') ? 'privateLinearGetOrderSearch' : 'v2PrivateGetOrder'; const stopOrderId = this.safeString (params, 'stop_order_id'); if (stopOrderId === undefined) { const orderLinkId = this.safeString (params, 'order_link_id'); @@ -42439,7 +44316,7 @@ module.exports = class bybit extends Exchange { request['order_id'] = id; } } else { - method = (marketType === 'linear') ? 'privateLinearGetStopOrderSearch' : 'privateGetStopOrder'; + method = (marketType === 'linear') ? 'privateLinearGetStopOrderSearch' : 'v2PrivateGetStopOrder'; } const response = await this[method] (this.extend (request, params)); // @@ -42552,7 +44429,7 @@ module.exports = class bybit extends Exchange { if (price !== undefined) { request['price'] = parseFloat (this.priceToPrecision (symbol, price)); } else { - throw new ArgumentsRequired (this.id + ' createOrder requires a price argument for a ' + type + ' order'); + throw new ArgumentsRequired (this.id + ' createOrder() requires a price argument for a ' + type + ' order'); } } const clientOrderId = this.safeString2 (params, 'order_link_id', 'clientOrderId'); @@ -42564,7 +44441,7 @@ module.exports = class bybit extends Exchange { const basePrice = this.safeValue (params, 'base_price'); const marketTypes = this.safeValue (this.options, 'marketTypes', {}); const marketType = this.safeString (marketTypes, symbol); - let method = (marketType === 'linear') ? 'privateLinearPostOrderCreate' : 'privatePostOrderCreate'; + let method = (marketType === 'linear') ? 'privateLinearPostOrderCreate' : 'v2PrivatePostOrderCreate'; if (marketType === 'linear') { method = 'privateLinearPostOrderCreate'; request['reduce_only'] = false; @@ -42572,15 +44449,15 @@ module.exports = class bybit extends Exchange { } if (stopPx !== undefined) { if (basePrice === undefined) { - throw new ArgumentsRequired (this.id + ' createOrder requires both the stop_px and base_price params for a conditional ' + type + ' order'); + throw new ArgumentsRequired (this.id + ' createOrder() requires both the stop_px and base_price params for a conditional ' + type + ' order'); } else { - method = (marketType === 'linear') ? 'privateLinearPostStopOrderCreate' : 'openapiPostStopOrderCreate'; + method = (marketType === 'linear') ? 'privateLinearPostStopOrderCreate' : 'v2PrivatePostStopOrderCreate'; request['stop_px'] = parseFloat (this.priceToPrecision (symbol, stopPx)); request['base_price'] = parseFloat (this.priceToPrecision (symbol, basePrice)); params = this.omit (params, [ 'stop_px', 'stopPrice', 'base_price' ]); } } else if (basePrice !== undefined) { - throw new ArgumentsRequired (this.id + ' createOrder requires both the stop_px and base_price params for a conditional ' + type + ' order'); + throw new ArgumentsRequired (this.id + ' createOrder() requires both the stop_px and base_price params for a conditional ' + type + ' order'); } const response = await this[method] (this.extend (request, params)); // @@ -42666,7 +44543,7 @@ module.exports = class bybit extends Exchange { async editOrder (id, symbol, type, side, amount = undefined, price = undefined, params = {}) { if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' editOrder requires an symbol argument'); + throw new ArgumentsRequired (this.id + ' editOrder() requires an symbol argument'); } const marketTypes = this.safeValue (this.options, 'marketTypes', {}); const marketType = this.safeString (marketTypes, symbol); @@ -42682,17 +44559,23 @@ module.exports = class bybit extends Exchange { // 'stop_order_id': id, // only for conditional orders // 'p_r_trigger_price': 123.45, // new trigger price also known as stop_px }; - let method = (marketType === 'linear') ? 'privateLinearPostOrderReplace' : 'openapiPostOrderReplace'; + let method = (marketType === 'linear') ? 'privateLinearPostOrderReplace' : 'v2PrivatePostOrderReplace'; const stopOrderId = this.safeString (params, 'stop_order_id'); if (stopOrderId !== undefined) { - method = (marketType === 'linear') ? 'privateLinearPostStopOrderReplace' : 'openapiPostStopOrderReplace'; + method = (marketType === 'linear') ? 'privateLinearPostStopOrderReplace' : 'v2PrivatePostStopOrderReplace'; request['stop_order_id'] = stopOrderId; params = this.omit (params, [ 'stop_order_id' ]); } else { request['order_id'] = id; } if (amount !== undefined) { - request['p_r_qty'] = parseInt (this.amountToPrecision (symbol, amount)); + let qty = this.amountToPrecision (symbol, amount); + if (market['inverse']) { + qty = parseInt (qty); + } else { + qty = parseFloat (qty); + } + request['p_r_qty'] = qty; } if (price !== undefined) { request['p_r_price'] = parseFloat (this.priceToPrecision (symbol, price)); @@ -42735,7 +44618,7 @@ module.exports = class bybit extends Exchange { async cancelOrder (id, symbol = undefined, params = {}) { if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' cancelOrder requires a symbol argument'); + throw new ArgumentsRequired (this.id + ' cancelOrder() requires a symbol argument'); } await this.loadMarkets (); const market = this.market (symbol); @@ -42749,7 +44632,7 @@ module.exports = class bybit extends Exchange { }; const marketTypes = this.safeValue (this.options, 'marketTypes', {}); const marketType = this.safeValue (marketTypes, symbol); - let method = (marketType === 'linear') ? 'privateLinearPostOrderCancel' : 'privatePostOrderCancel'; + let method = (marketType === 'linear') ? 'privateLinearPostOrderCancel' : 'v2PrivatePostOrderCancel'; const stopOrderId = this.safeString (params, 'stop_order_id'); if (stopOrderId === undefined) { const orderLinkId = this.safeString (params, 'order_link_id'); @@ -42757,7 +44640,7 @@ module.exports = class bybit extends Exchange { request['order_id'] = id; } } else { - method = (marketType === 'linear') ? 'privateLinearPostStopOrderCancel' : 'openapiPostStopOrderCancel'; + method = (marketType === 'linear') ? 'privateLinearPostStopOrderCancel' : 'v2PrivatePostStopOrderCancel'; } const response = await this[method] (this.extend (request, params)); const result = this.safeValue (response, 'result', {}); @@ -42766,17 +44649,17 @@ module.exports = class bybit extends Exchange { async cancelAllOrders (symbol = undefined, params = {}) { if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' cancelAllOrders requires a symbol argument'); + throw new ArgumentsRequired (this.id + ' cancelAllOrders() requires a symbol argument'); } await this.loadMarkets (); const market = this.market (symbol); const request = { 'symbol': market['id'], }; - const options = this.safeValue (this.options, 'cancelAllOrders'); + const options = this.safeValue (this.options, 'cancelAllOrders', {}); const marketTypes = this.safeValue (this.options, 'marketTypes', {}); const marketType = this.safeString (marketTypes, symbol); - const defaultMethod = (marketType === 'linear') ? 'privateLinearPostOrderCancelAll' : 'privatePostOrderCancelAll'; + const defaultMethod = (marketType === 'linear') ? 'privateLinearPostOrderCancelAll' : 'v2PrivatePostOrderCancelAll'; const method = this.safeString (options, 'method', defaultMethod); const response = await this[method] (this.extend (request, params)); const result = this.safeValue (response, 'result', []); @@ -42808,7 +44691,7 @@ module.exports = class bybit extends Exchange { const options = this.safeValue (this.options, 'fetchOrders', {}); const marketTypes = this.safeValue (this.options, 'marketTypes', {}); const marketType = this.safeString (marketTypes, symbol); - let defaultMethod = (marketType === 'linear') ? 'privateLinearGetOrderList' : 'openapiGetOrderList'; + let defaultMethod = (marketType === 'linear') ? 'privateLinearGetOrderList' : 'v2PrivateGetOrderList'; let query = params; if (('stop_order_id' in params) || ('stop_order_status' in params)) { let stopOrderStatus = this.safeValue (params, 'stopOrderStatus'); @@ -42819,7 +44702,7 @@ module.exports = class bybit extends Exchange { request['stop_order_status'] = stopOrderStatus; query = this.omit (params, 'stop_order_status'); } - defaultMethod = (marketType === 'linear') ? 'privateLinearGetStopOrderList' : 'openapiGetStopOrderList'; + defaultMethod = (marketType === 'linear') ? 'privateLinearGetStopOrderList' : 'v2PrivateGetStopOrderList'; } const method = this.safeString (options, 'method', defaultMethod); const response = await this[method] (this.extend (request, query)); @@ -42985,7 +44868,7 @@ module.exports = class bybit extends Exchange { if (symbol === undefined) { const orderId = this.safeString (params, 'order_id'); if (orderId === undefined) { - throw new ArgumentsRequired (this.id + ' fetchMyTrades requires a symbol argument or an order_id param'); + throw new ArgumentsRequired (this.id + ' fetchMyTrades() requires a symbol argument or an order_id param'); } else { request['order_id'] = orderId; params = this.omit (params, 'order_id'); @@ -43002,7 +44885,7 @@ module.exports = class bybit extends Exchange { } const marketTypes = this.safeValue (this.options, 'marketTypes', {}); const marketType = this.safeString (marketTypes, symbol); - const method = (marketType === 'linear') ? 'privateLinearGetTradeExecutionList' : 'privateGetExecutionList'; + const method = (marketType === 'linear') ? 'privateLinearGetTradeExecutionList' : 'v2PrivateGetExecutionList'; const response = await this[method] (this.extend (request, params)); // // inverse @@ -43092,41 +44975,60 @@ module.exports = class bybit extends Exchange { } async fetchDeposits (code = undefined, since = undefined, limit = undefined, params = {}) { - if (code === undefined) { - throw new ArgumentsRequired (this.id + ' fetchWithdrawals() requires a currency code argument'); - } await this.loadMarkets (); - const currency = this.currency (code); const request = { - 'currency': currency['id'], + // 'coin': currency['id'], + // 'currency': currency['id'], // alias + // 'start_date': this.iso8601 (since), + // 'end_date': this.iso8601 (till), + 'wallet_fund_type': 'Deposit', // Deposit, Withdraw, RealisedPNL, Commission, Refund, Prize, ExchangeOrderWithdraw, ExchangeOrderDeposit + // 'page': 1, + // 'limit': 20, // max 50 }; - if (limit !== undefined) { - request['count'] = limit; + let currency = undefined; + if (code !== undefined) { + currency = this.currency (code); + request['coin'] = currency['id']; } - const response = await this.privateGetGetDeposits (this.extend (request, params)); + if (since !== undefined) { + request['start_date'] = this.ymd (since); + } + if (limit !== undefined) { + request['limit'] = limit; + } + const response = await this.v2PrivateGetWalletFundRecords (this.extend (request, params)); // // { - // "jsonrpc": "2.0", - // "id": 5611, + // "ret_code": 0, + // "ret_msg": "ok", + // "ext_code": "", // "result": { - // "count": 1, // "data": [ // { - // "address": "2N35qDKDY22zmJq9eSyiAerMD4enJ1xx6ax", - // "amount": 5, - // "currency": "BTC", - // "received_timestamp": 1549295017670, - // "state": "completed", - // "transaction_id": "230669110fdaf0a0dbcdc079b6b8b43d5af29cc73683835b9bc6b3406c065fda", - // "updated_timestamp": 1549295130159 + // "id": 234467, + // "user_id": 1, + // "coin": "BTC", + // "wallet_id": 27913, + // "type": "Realized P&L", + // "amount": "-0.00000006", + // "tx_id": "", + // "address": "BTCUSD", + // "wallet_balance": "0.03000330", + // "exec_time": "2019-12-09T00:00:25.000Z", + // "cross_seq": 0 // } // ] - // } + // }, + // "ext_info": null, + // "time_now": "1577481867.115552", + // "rate_limit_status": 119, + // "rate_limit_reset_ms": 1577481867122, + // "rate_limit": 120 // } // const result = this.safeValue (response, 'result', {}); const data = this.safeValue (result, 'data', []); - return this.parseTransactions (data, currency, since, limit, params); + return this.parseTransactions (data, currency, since, limit); } async fetchWithdrawals (code = undefined, since = undefined, limit = undefined, params = {}) { @@ -43145,12 +45047,12 @@ module.exports = class bybit extends Exchange { request['coin'] = currency['id']; } if (since !== undefined) { - request['start_date'] = this.iso8601 (since); + request['start_date'] = this.ymd (since); } if (limit !== undefined) { request['limit'] = limit; } - const response = await this.openapiGetWalletWithdrawList (this.extend (request, params)); + const response = await this.v2PrivateGetWalletWithdrawList (this.extend (request, params)); // // { // "ret_code": 0, @@ -43216,9 +45118,25 @@ module.exports = class bybit extends Exchange { // "updated_at": "2019-06-11T02:20:24.000Z" // } // + // fetchDeposits ledger entries + // + // { + // "id": 234467, + // "user_id": 1, + // "coin": "BTC", + // "wallet_id": 27913, + // "type": "Realized P&L", + // "amount": "-0.00000006", + // "tx_id": "", + // "address": "BTCUSD", + // "wallet_balance": "0.03000330", + // "exec_time": "2019-12-09T00:00:25.000Z", + // "cross_seq": 0 + // } + // const currencyId = this.safeString (transaction, 'coin'); const code = this.safeCurrencyCode (currencyId, currency); - const timestamp = this.parse8601 (this.safeString (transaction, 'submited_at')); + const timestamp = this.parse8601 (this.safeString2 (transaction, 'submited_at', 'exec_time')); const updated = this.parse8601 (this.safeString (transaction, 'updated_at')); const status = this.parseTransactionStatus (this.safeString (transaction, 'status')); const address = this.safeString (transaction, 'address'); @@ -43268,12 +45186,12 @@ module.exports = class bybit extends Exchange { request['coin'] = currency['id']; } if (since !== undefined) { - request['start_date'] = this.iso8601 (since); + request['start_date'] = this.ymd (since); } if (limit !== undefined) { request['limit'] = limit; } - const response = await this.openapiGetWalletFundRecords (this.extend (request, params)); + const response = await this.v2PrivateGetWalletFundRecords (this.extend (request, params)); // // { // "ret_code": 0, @@ -43372,45 +45290,28 @@ module.exports = class bybit extends Exchange { } sign (path, api = 'public', method = 'GET', params = {}, headers = undefined, body = undefined) { - let url = this.urls['api']; - let request = path; + let url = this.implodeParams (this.urls['api'], { 'hostname': this.hostname }); + const type = this.safeString (api, 0); + const section = this.safeString (api, 1); + let request = '/' + type + '/' + section + '/' + path; // public v2 - if (api === 'public') { - request = '/' + this.version + '/' + api + '/' + request; + if (section === 'public') { if (Object.keys (params).length) { request += '?' + this.rawencode (params); } - } else if (api === 'publicLinear') { - request = '/public/linear/' + request; + } else if (type === 'public') { if (Object.keys (params).length) { request += '?' + this.rawencode (params); } } else { this.checkRequiredCredentials (); - if (api === 'openapi') { - request = '/open-api/' + request; - } else if (api === 'private') { - // private v2 - request = '/' + this.version + '/' + api + '/' + request; - } else if (api === 'privateLinear') { - request = '/private/linear/' + request; - } else { - // position, user - request = '/' + api + '/' + request; - } const timestamp = this.nonce (); const query = this.extend (params, { 'api_key': this.apiKey, 'recv_window': this.options['recvWindow'], 'timestamp': timestamp, }); - let auth = this.rawencode (this.keysort (query)); - // https://github.com/ccxt/ccxt/issues/7377 - // https://github.com/ccxt/ccxt/issues/7515 - // bybit encodes whole floats as integers without .0 for conditional stop-orders only - if (path.indexOf ('stop-order') >= 0) { - auth = auth.replace ('.0&', '&'); - } + const auth = this.rawencode (this.keysort (query)); const signature = this.hmac (this.encode (auth), this.encode (this.secret)); if (method === 'POST') { body = this.json (this.extend (query, { @@ -43453,7 +45354,7 @@ module.exports = class bybit extends Exchange { } }; -},{"./base/Exchange":5,"./base/errors":7,"./base/functions/number":13}],57:[function(require,module,exports){ +},{"./base/Exchange":6,"./base/errors":8,"./base/functions/number":14}],57:[function(require,module,exports){ 'use strict'; // --------------------------------------------------------------------------- @@ -43741,7 +45642,7 @@ module.exports = class bytetrade extends Exchange { async fetchBalance (params = {}) { if (!('userid' in params) && (this.apiKey === undefined)) { - throw new ArgumentsRequired (this.id + ' fetchDeposits requires this.apiKey or userid argument'); + throw new ArgumentsRequired (this.id + ' fetchDeposits() requires this.apiKey or userid argument'); } await this.loadMarkets (); const request = { @@ -44036,6 +45937,7 @@ module.exports = class bytetrade extends Exchange { 'symbol': symbol, 'type': type, 'timeInForce': undefined, + 'postOnly': undefined, 'side': side, 'price': price, 'stopPrice': undefined, @@ -44053,7 +45955,7 @@ module.exports = class bytetrade extends Exchange { async createOrder (symbol, type, side, amount, price = undefined, params = {}) { this.checkRequiredDependencies (); if (this.apiKey === undefined) { - throw new ArgumentsRequired ('createOrder requires this.apiKey or userid in params'); + throw new ArgumentsRequired ('createOrder() requires this.apiKey or userid in params'); } await this.loadMarkets (); const market = this.market (symbol); @@ -44237,7 +46139,7 @@ module.exports = class bytetrade extends Exchange { async fetchOrder (id, symbol = undefined, params = {}) { if (!('userid' in params) && (this.apiKey === undefined)) { - throw new ArgumentsRequired ('fetchOrder requires this.apiKey or userid argument'); + throw new ArgumentsRequired ('fetchOrder() requires this.apiKey or userid argument'); } await this.loadMarkets (); const request = { @@ -44255,7 +46157,7 @@ module.exports = class bytetrade extends Exchange { async fetchOpenOrders (symbol = undefined, since = undefined, limit = undefined, params = {}) { if (!('userid' in params) && (this.apiKey === undefined)) { - throw new ArgumentsRequired ('fetchOpenOrders requires this.apiKey or userid argument'); + throw new ArgumentsRequired ('fetchOpenOrders() requires this.apiKey or userid argument'); } await this.loadMarkets (); const request = { @@ -44275,7 +46177,7 @@ module.exports = class bytetrade extends Exchange { async fetchClosedOrders (symbol = undefined, since = undefined, limit = undefined, params = {}) { if (!('userid' in params) && (this.apiKey === undefined)) { - throw new ArgumentsRequired ('fetchClosedOrders requires this.apiKey or userid argument'); + throw new ArgumentsRequired ('fetchClosedOrders() requires this.apiKey or userid argument'); } await this.loadMarkets (); let market = undefined; @@ -44295,7 +46197,7 @@ module.exports = class bytetrade extends Exchange { async fetchOrders (symbol = undefined, since = undefined, limit = undefined, params = {}) { if (!('userid' in params) && (this.apiKey === undefined)) { - throw new ArgumentsRequired ('fetchOrders requires this.apiKey or userid argument'); + throw new ArgumentsRequired ('fetchOrders() requires this.apiKey or userid argument'); } await this.loadMarkets (); let market = undefined; @@ -44315,10 +46217,10 @@ module.exports = class bytetrade extends Exchange { async cancelOrder (id, symbol = undefined, params = {}) { if (this.apiKey === undefined) { - throw new ArgumentsRequired ('cancelOrder requires hasAlreadyAuthenticatedSuccessfully'); + throw new ArgumentsRequired ('cancelOrder() requires hasAlreadyAuthenticatedSuccessfully'); } if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' cancelOrder requires a symbol argument'); + throw new ArgumentsRequired (this.id + ' cancelOrder() requires a symbol argument'); } await this.loadMarkets (); const market = this.market (symbol); @@ -44416,7 +46318,7 @@ module.exports = class bytetrade extends Exchange { async transfer (code, amount, address, message = '', params = {}) { this.checkRequiredDependencies (); if (this.apiKey === undefined) { - throw new ArgumentsRequired ('transfer requires this.apiKey'); + throw new ArgumentsRequired ('transfer() requires this.apiKey'); } await this.loadMarkets (); const currency = this.currency (code); @@ -44522,7 +46424,7 @@ module.exports = class bytetrade extends Exchange { async fetchMyTrades (symbol = undefined, since = undefined, limit = undefined, params = {}) { if (!('userid' in params) && (this.apiKey === undefined)) { - throw new ArgumentsRequired ('fetchMyTrades requires this.apiKey or userid argument'); + throw new ArgumentsRequired ('fetchMyTrades() requires this.apiKey or userid argument'); } await this.loadMarkets (); const market = this.market (symbol); @@ -44542,7 +46444,7 @@ module.exports = class bytetrade extends Exchange { async fetchDeposits (code = undefined, since = undefined, limit = undefined, params = {}) { await this.loadMarkets (); if (!('userid' in params) && (this.apiKey === undefined)) { - throw new ArgumentsRequired ('fetchDeposits requires this.apiKey or userid argument'); + throw new ArgumentsRequired ('fetchDeposits() requires this.apiKey or userid argument'); } let currency = undefined; const request = { @@ -44565,7 +46467,7 @@ module.exports = class bytetrade extends Exchange { async fetchWithdrawals (code = undefined, since = undefined, limit = undefined, params = {}) { await this.loadMarkets (); if (!('userid' in params) && (this.apiKey === undefined)) { - throw new ArgumentsRequired ('fetchWithdrawals requires this.apiKey or userid argument'); + throw new ArgumentsRequired ('fetchWithdrawals() requires this.apiKey or userid argument'); } let currency = undefined; const request = { @@ -44649,7 +46551,7 @@ module.exports = class bytetrade extends Exchange { async fetchDepositAddress (code, params = {}) { await this.loadMarkets (); if (!('userid' in params) && (this.apiKey === undefined)) { - throw new ArgumentsRequired ('fetchDepositAddress requires this.apiKey or userid argument'); + throw new ArgumentsRequired ('fetchDepositAddress() requires this.apiKey or userid argument'); } const currency = this.currency (code); const request = { @@ -44675,7 +46577,7 @@ module.exports = class bytetrade extends Exchange { this.checkAddress (address); await this.loadMarkets (); if (this.apiKey === undefined) { - throw new ArgumentsRequired ('withdraw requires this.apiKey'); + throw new ArgumentsRequired (this.id + ' withdraw() requires this.apiKey'); } const addressResponse = await this.fetchDepositAddress (code); const chainTypeString = this.safeString (addressResponse, 'chainType'); @@ -44885,7 +46787,42 @@ module.exports = class bytetrade extends Exchange { } }; -},{"./base/Exchange":5,"./base/errors":7,"./base/functions/number":13}],58:[function(require,module,exports){ +},{"./base/Exchange":6,"./base/errors":8,"./base/functions/number":14}],58:[function(require,module,exports){ +'use strict'; + +// --------------------------------------------------------------------------- + +const huobipro = require ('./huobipro.js'); + +// --------------------------------------------------------------------------- + +module.exports = class cdax extends huobipro { + describe () { + return this.deepExtend (super.describe (), { + 'id': 'cdax', + 'name': 'CDAX', + 'countries': [ 'RU' ], + 'hostname': 'cdax.io', + 'pro': false, + 'urls': { + 'logo': 'https://user-images.githubusercontent.com/1294454/102157692-fd406280-3e90-11eb-8d46-4511b617cd17.jpg', + 'api': { + 'market': 'https://{hostname}/api', + 'public': 'https://{hostname}/api', + 'private': 'https://{hostname}/api', + 'v2Public': 'https://{hostname}/api', + 'v2Private': 'https://{hostname}/api', + }, + 'www': 'https://cdax.io', + 'referral': 'https://cdax.io/invite?invite_code=esc74', + 'doc': 'https://github.com/cloudapidoc/API_Docs', + 'fees': 'https://cdax.io/about/fee', + }, + }); + } +}; + +},{"./huobipro.js":96}],59:[function(require,module,exports){ 'use strict'; // --------------------------------------------------------------------------- @@ -45564,10 +47501,9 @@ module.exports = class cex extends Exchange { let cost = undefined; if (market !== undefined) { symbol = market['symbol']; - cost = this.safeFloat (order, 'ta:' + market['quote']); - if (cost === undefined) { - cost = this.safeFloat (order, 'tta:' + market['quote']); - } + const taCost = this.safeFloat (order, 'ta:' + market['quote']); + const ttaCost = this.safeFloat (order, 'tta:' + market['quote']); + cost = this.sum (taCost, ttaCost); const baseFee = 'fa:' + market['base']; const baseTakerFee = 'tfa:' + market['base']; const quoteFee = 'fa:' + market['quote']; @@ -45771,6 +47707,7 @@ module.exports = class cex extends Exchange { 'symbol': symbol, 'type': (price === undefined) ? 'market' : 'limit', 'timeInForce': undefined, + 'postOnly': undefined, 'side': side, 'price': price, 'stopPrice': undefined, @@ -45806,7 +47743,7 @@ module.exports = class cex extends Exchange { await this.loadMarkets (); const method = 'privatePostArchivedOrdersPair'; if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' fetchClosedOrders requires a symbol argument'); + throw new ArgumentsRequired (this.id + ' fetchClosedOrders() requires a symbol argument'); } const market = this.market (symbol); const request = { 'pair': market['id'] }; @@ -46140,10 +48077,10 @@ module.exports = class cex extends Exchange { async editOrder (id, symbol, type, side, amount = undefined, price = undefined, params = {}) { if (amount === undefined) { - throw new ArgumentsRequired (this.id + ' editOrder requires a amount argument'); + throw new ArgumentsRequired (this.id + ' editOrder() requires a amount argument'); } if (price === undefined) { - throw new ArgumentsRequired (this.id + ' editOrder requires a price argument'); + throw new ArgumentsRequired (this.id + ' editOrder() requires a price argument'); } await this.loadMarkets (); const market = this.market (symbol); @@ -46235,7 +48172,7 @@ module.exports = class cex extends Exchange { } }; -},{"./base/Exchange":5,"./base/errors":7}],59:[function(require,module,exports){ +},{"./base/Exchange":6,"./base/errors":8}],60:[function(require,module,exports){ 'use strict'; // --------------------------------------------------------------------------- @@ -46269,13 +48206,13 @@ module.exports = class chilebit extends foxbit { } }; -},{"./foxbit.js":84}],60:[function(require,module,exports){ +},{"./foxbit.js":87}],61:[function(require,module,exports){ 'use strict'; // ---------------------------------------------------------------------------- const Exchange = require ('./base/Exchange'); -const { ExchangeError, ArgumentsRequired, AuthenticationError, RateLimitExceeded } = require ('./base/errors'); +const { ExchangeError, ArgumentsRequired, AuthenticationError, RateLimitExceeded, InvalidNonce } = require ('./base/errors'); // ---------------------------------------------------------------------------- @@ -46395,23 +48332,28 @@ module.exports = class coinbase extends Exchange { }, }, 'exceptions': { - 'two_factor_required': AuthenticationError, // 402 When sending money over 2fa limit - 'param_required': ExchangeError, // 400 Missing parameter - 'validation_error': ExchangeError, // 400 Unable to validate POST/PUT - 'invalid_request': ExchangeError, // 400 Invalid request - 'personal_details_required': AuthenticationError, // 400 User’s personal detail required to complete this request - 'identity_verification_required': AuthenticationError, // 400 Identity verification is required to complete this request - 'jumio_verification_required': AuthenticationError, // 400 Document verification is required to complete this request - 'jumio_face_match_verification_required': AuthenticationError, // 400 Document verification including face match is required to complete this request - 'unverified_email': AuthenticationError, // 400 User has not verified their email - 'authentication_error': AuthenticationError, // 401 Invalid auth (generic) - 'invalid_token': AuthenticationError, // 401 Invalid Oauth token - 'revoked_token': AuthenticationError, // 401 Revoked Oauth token - 'expired_token': AuthenticationError, // 401 Expired Oauth token - 'invalid_scope': AuthenticationError, // 403 User hasn’t authenticated necessary scope - 'not_found': ExchangeError, // 404 Resource not found - 'rate_limit_exceeded': RateLimitExceeded, // 429 Rate limit exceeded - 'internal_server_error': ExchangeError, // 500 Internal server error + 'exact': { + 'two_factor_required': AuthenticationError, // 402 When sending money over 2fa limit + 'param_required': ExchangeError, // 400 Missing parameter + 'validation_error': ExchangeError, // 400 Unable to validate POST/PUT + 'invalid_request': ExchangeError, // 400 Invalid request + 'personal_details_required': AuthenticationError, // 400 User’s personal detail required to complete this request + 'identity_verification_required': AuthenticationError, // 400 Identity verification is required to complete this request + 'jumio_verification_required': AuthenticationError, // 400 Document verification is required to complete this request + 'jumio_face_match_verification_required': AuthenticationError, // 400 Document verification including face match is required to complete this request + 'unverified_email': AuthenticationError, // 400 User has not verified their email + 'authentication_error': AuthenticationError, // 401 Invalid auth (generic) + 'invalid_token': AuthenticationError, // 401 Invalid Oauth token + 'revoked_token': AuthenticationError, // 401 Revoked Oauth token + 'expired_token': AuthenticationError, // 401 Expired Oauth token + 'invalid_scope': AuthenticationError, // 403 User hasn’t authenticated necessary scope + 'not_found': ExchangeError, // 404 Resource not found + 'rate_limit_exceeded': RateLimitExceeded, // 429 Rate limit exceeded + 'internal_server_error': ExchangeError, // 500 Internal server error + }, + 'broad': { + 'request timestamp expired': InvalidNonce, // {"errors":[{"id":"authentication_error","message":"request timestamp expired"}]} + }, }, 'commonCurrencies': { 'CGLD': 'CELO', @@ -46444,7 +48386,11 @@ module.exports = class coinbase extends Exchange { } async fetchAccounts (params = {}) { - const response = await this.privateGetAccounts (params); + await this.loadMarkets (); + const request = { + 'limit': 100, + }; + const response = await this.privateGetAccounts (this.extend (request, params)); // // { // "id": "XLM", @@ -46975,7 +48921,10 @@ module.exports = class coinbase extends Exchange { async fetchBalance (params = {}) { await this.loadMarkets (); - const response = await this.privateGetAccounts (params); + const request = { + 'limit': 100, + }; + const response = await this.privateGetAccounts (this.extend (request, params)); const balances = this.safeValue (response, 'data'); const accounts = this.safeValue (params, 'type', this.options['accounts']); const result = { 'info': response }; @@ -47447,7 +49396,9 @@ module.exports = class coinbase extends Exchange { // let errorCode = this.safeString (response, 'error'); if (errorCode !== undefined) { - this.throwExactlyMatchedException (this.exceptions, errorCode, feedback); + const errorMessage = this.safeString (response, 'error_description'); + this.throwExactlyMatchedException (this.exceptions['exact'], errorCode, feedback); + this.throwBroadlyMatchedException (this.exceptions['broad'], errorMessage, feedback); throw new ExchangeError (feedback); } const errors = this.safeValue (response, 'errors'); @@ -47456,8 +49407,10 @@ module.exports = class coinbase extends Exchange { const numErrors = errors.length; if (numErrors > 0) { errorCode = this.safeString (errors[0], 'id'); + const errorMessage = this.safeString (errors[0], 'message'); if (errorCode !== undefined) { - this.throwExactlyMatchedException (this.exceptions, errorCode, feedback); + this.throwExactlyMatchedException (this.exceptions['exact'], errorCode, feedback); + this.throwBroadlyMatchedException (this.exceptions['broad'], errorMessage, feedback); throw new ExchangeError (feedback); } } @@ -47471,7 +49424,7 @@ module.exports = class coinbase extends Exchange { }; -},{"./base/Exchange":5,"./base/errors":7}],61:[function(require,module,exports){ +},{"./base/Exchange":6,"./base/errors":8}],62:[function(require,module,exports){ 'use strict'; // --------------------------------------------------------------------------- @@ -47504,7 +49457,7 @@ module.exports = class coinbaseprime extends coinbasepro { } }; -},{"./coinbasepro.js":62}],62:[function(require,module,exports){ +},{"./coinbasepro.js":63}],63:[function(require,module,exports){ 'use strict'; // ---------------------------------------------------------------------------- @@ -47852,6 +49805,7 @@ module.exports = class coinbasepro extends Exchange { } async fetchAccounts (params = {}) { + await this.loadMarkets (); const response = await this.privateGetAccounts (params); // // [ @@ -48030,12 +49984,20 @@ module.exports = class coinbasepro extends Exchange { // trade_id: 82047307, // maker_order_id: '0f358725-2134-435e-be11-753912a326e0', // taker_order_id: '252b7002-87a3-425c-ac73-f5b9e23f3caf', + // order_id: 'd50ec984-77a8-460a-b958-66f114b0de9b', // side: 'sell', // size: '0.00513192', // price: '9314.78', // product_id: 'BTC-USD', + // profile_id: '6244401d-c078-40d9-b305-7ad3551bc3b0', // sequence: 12038915443, // time: '2020-01-31T20:03:41.158814Z' + // created_at: '2014-11-07T22:19:28.578544Z', + // liquidity: 'T', + // fee: '0.00025', + // settled: true, + // usd_volume: '0.0924556000000000', + // user_id: '595eb864313c2b02ddf2937d' // } // const timestamp = this.parse8601 (this.safeString2 (trade, 'time', 'created_at')); @@ -48044,10 +50006,15 @@ module.exports = class coinbasepro extends Exchange { let feeRate = undefined; let feeCurrency = undefined; let takerOrMaker = undefined; + let cost = undefined; if (market !== undefined) { + const feeCurrencyId = this.safeStringLower (market, 'quoteId'); + const costField = feeCurrencyId + '_value'; + cost = this.safeFloat (trade, costField); feeCurrency = market['quote']; - if ('liquidity' in trade) { - takerOrMaker = (trade['liquidity'] === 'T') ? 'taker' : 'maker'; + const liquidity = this.safeString (trade, 'liquidity'); + if (liquidity !== undefined) { + takerOrMaker = (liquidity === 'T') ? 'taker' : 'maker'; feeRate = market[takerOrMaker]; } } @@ -48067,6 +50034,9 @@ module.exports = class coinbasepro extends Exchange { } const price = this.safeFloat (trade, 'price'); const amount = this.safeFloat (trade, 'size'); + if (cost === undefined) { + cost = amount * price; + } return { 'id': id, 'order': orderId, @@ -48080,14 +50050,14 @@ module.exports = class coinbasepro extends Exchange { 'price': price, 'amount': amount, 'fee': fee, - 'cost': price * amount, + 'cost': cost, }; } async fetchMyTrades (symbol = undefined, since = undefined, limit = undefined, params = {}) { // as of 2018-08-23 if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' fetchMyTrades requires a symbol argument'); + throw new ArgumentsRequired (this.id + ' fetchMyTrades() requires a symbol argument'); } await this.loadMarkets (); const market = this.market (symbol); @@ -48107,6 +50077,9 @@ module.exports = class coinbasepro extends Exchange { const request = { 'id': market['id'], // fixes issue #2 }; + if (limit !== undefined) { + request['limit'] = limit; // default 100 + } const response = await this.publicGetProductsIdTrades (this.extend (request, params)); return this.parseTrades (response, market, since, limit); } @@ -48183,6 +50156,27 @@ module.exports = class coinbasepro extends Exchange { } parseOrder (order, market = undefined) { + // + // createOrder + // + // { + // "id": "d0c5340b-6d6c-49d9-b567-48c4bfca13d2", + // "price": "0.10000000", + // "size": "0.01000000", + // "product_id": "BTC-USD", + // "side": "buy", + // "stp": "dc", + // "type": "limit", + // "time_in_force": "GTC", + // "post_only": false, + // "created_at": "2016-12-08T20:02:28.53864Z", + // "fill_fees": "0.0000000000000000", + // "filled_size": "0.00000000", + // "executed_value": "0.0000000000000000", + // "status": "pending", + // "settled": false + // } + // const timestamp = this.parse8601 (this.safeString (order, 'created_at')); const marketId = this.safeString (order, 'product_id'); market = this.safeMarket (marketId, market, '-'); @@ -48213,9 +50207,13 @@ module.exports = class coinbasepro extends Exchange { const id = this.safeString (order, 'id'); const type = this.safeString (order, 'type'); const side = this.safeString (order, 'side'); + const timeInForce = this.safeString (order, 'time_in_force'); + const postOnly = this.safeValue (order, 'post_only'); + const stopPrice = this.safeFloat (order, 'stop_price'); + const clientOrderId = this.safeString (order, 'client_oid'); return { 'id': id, - 'clientOrderId': undefined, + 'clientOrderId': clientOrderId, 'info': order, 'timestamp': timestamp, 'datetime': this.iso8601 (timestamp), @@ -48223,10 +50221,11 @@ module.exports = class coinbasepro extends Exchange { 'status': status, 'symbol': market['symbol'], 'type': type, - 'timeInForce': undefined, + 'timeInForce': timeInForce, + 'postOnly': postOnly, 'side': side, 'price': price, - 'stopPrice': undefined, + 'stopPrice': stopPrice, 'cost': cost, 'amount': amount, 'filled': filled, @@ -48239,10 +50238,18 @@ module.exports = class coinbasepro extends Exchange { async fetchOrder (id, symbol = undefined, params = {}) { await this.loadMarkets (); - const request = { - 'id': id, - }; - const response = await this.privateGetOrdersId (this.extend (request, params)); + const request = {}; + const clientOrderId = this.safeString2 (params, 'clientOrderId', 'client_oid'); + let method = undefined; + if (clientOrderId === undefined) { + method = 'privateGetOrdersId'; + request['id'] = id; + } else { + method = 'privateGetOrdersClientClientOid'; + request['client_oid'] = clientOrderId; + params = this.omit (params, [ 'clientOrderId', 'client_oid' ]); + } + const response = await this[method] (this.extend (request, params)); return this.parseOrder (response); } @@ -48260,17 +50267,10 @@ module.exports = class coinbasepro extends Exchange { } async fetchOrders (symbol = undefined, since = undefined, limit = undefined, params = {}) { - await this.loadMarkets (); const request = { 'status': 'all', }; - let market = undefined; - if (symbol !== undefined) { - market = this.market (symbol); - request['product_id'] = market['id']; - } - const response = await this.privateGetOrders (this.extend (request, params)); - return this.parseOrders (response, market, since, limit); + return await this.fetchOpenOrders (symbol, since, limit, this.extend (request, params)); } async fetchOpenOrders (symbol = undefined, since = undefined, limit = undefined, params = {}) { @@ -48281,47 +50281,131 @@ module.exports = class coinbasepro extends Exchange { market = this.market (symbol); request['product_id'] = market['id']; } + if (limit !== undefined) { + request['limit'] = limit; // default 100 + } const response = await this.privateGetOrders (this.extend (request, params)); return this.parseOrders (response, market, since, limit); } async fetchClosedOrders (symbol = undefined, since = undefined, limit = undefined, params = {}) { - await this.loadMarkets (); const request = { 'status': 'done', }; - let market = undefined; - if (symbol !== undefined) { - market = this.market (symbol); - request['product_id'] = market['id']; - } - const response = await this.privateGetOrders (this.extend (request, params)); - return this.parseOrders (response, market, since, limit); + return await this.fetchOpenOrders (symbol, since, limit, this.extend (request, params)); } async createOrder (symbol, type, side, amount, price = undefined, params = {}) { await this.loadMarkets (); - // let oid = this.nonce ().toString (); + const market = this.market (symbol); const request = { - 'product_id': this.marketId (symbol), - 'side': side, - 'size': this.amountToPrecision (symbol, amount), + // common params -------------------------------------------------- + // 'client_oid': clientOrderId, 'type': type, + 'side': side, + 'product_id': market['id'], + // 'size': this.amountToPrecision (symbol, amount), + // 'stp': 'dc', // self-trade prevention, dc = decrease and cancel, co = cancel oldest, cn = cancel newest, cb = cancel both + // 'stop': 'loss', // "loss" = stop loss below price, "entry" = take profit above price + // 'stop_price': this.priceToPrecision (symbol, price), + // limit order params --------------------------------------------- + // 'price': this.priceToPrecision (symbol, price), + // 'size': this.amountToPrecision (symbol, amount), + // 'time_in_force': 'GTC', // GTC, GTT, IOC, or FOK + // 'cancel_after' [optional]* min, hour, day, requires time_in_force to be GTT + // 'post_only': false, // invalid when time_in_force is IOC or FOK + // market order params -------------------------------------------- + // 'size': this.amountToPrecision (symbol, amount), + // 'funds': this.costToPrecision (symbol, amount), }; + const clientOrderId = this.safeString2 (params, 'clientOrderId', 'client_oid'); + if (clientOrderId !== undefined) { + request['client_oid'] = clientOrderId; + params = this.omit (params, [ 'clientOrderId', 'client_oid' ]); + } + const stopPrice = this.safeFloat2 (params, 'stopPrice', 'stop_price'); + if (stopPrice !== undefined) { + request['stop_price'] = this.priceToPrecision (symbol, stopPrice); + params = this.omit (params, [ 'stopPrice', 'stop_price' ]); + } + const timeInForce = this.safeString2 (params, 'timeInForce', 'time_in_force'); + if (timeInForce !== undefined) { + request['time_in_force'] = timeInForce; + params = this.omit (params, [ 'timeInForce', 'time_in_force' ]); + } if (type === 'limit') { request['price'] = this.priceToPrecision (symbol, price); + request['size'] = this.amountToPrecision (symbol, amount); + } else if (type === 'market') { + let cost = this.safeFloat2 (params, 'cost', 'funds'); + if (cost === undefined) { + if (price !== undefined) { + cost = amount * price; + } + } else { + params = this.omit (params, [ 'cost', 'funds' ]); + } + if (cost !== undefined) { + request['funds'] = this.costToPrecision (symbol, cost); + } else { + request['size'] = this.amountToPrecision (symbol, amount); + } } const response = await this.privatePostOrders (this.extend (request, params)); - return this.parseOrder (response); + // + // { + // "id": "d0c5340b-6d6c-49d9-b567-48c4bfca13d2", + // "price": "0.10000000", + // "size": "0.01000000", + // "product_id": "BTC-USD", + // "side": "buy", + // "stp": "dc", + // "type": "limit", + // "time_in_force": "GTC", + // "post_only": false, + // "created_at": "2016-12-08T20:02:28.53864Z", + // "fill_fees": "0.0000000000000000", + // "filled_size": "0.00000000", + // "executed_value": "0.0000000000000000", + // "status": "pending", + // "settled": false + // } + // + return this.parseOrder (response, market); } async cancelOrder (id, symbol = undefined, params = {}) { await this.loadMarkets (); - return await this.privateDeleteOrdersId ({ 'id': id }); + const request = { + // 'product_id': market['id'], // the request will be more performant if you include it + }; + const clientOrderId = this.safeString2 (params, 'clientOrderId', 'client_oid'); + let method = undefined; + if (clientOrderId === undefined) { + method = 'privateDeleteOrdersId'; + request['id'] = id; + } else { + method = 'privateDeleteOrdersClientClientOid'; + request['client_oid'] = clientOrderId; + params = this.omit (params, [ 'clientOrderId', 'client_oid' ]); + } + let market = undefined; + if (symbol !== undefined) { + market = this.market (symbol); + request['product_id'] = market['symbol']; // the request will be more performant if you include it + } + return await this[method] (this.extend (request, params)); } async cancelAllOrders (symbol = undefined, params = {}) { - return await this.privateDeleteOrders (params); + await this.loadMarkets (); + const request = {}; + let market = undefined; + if (symbol !== undefined) { + market = this.market (symbol); + request['product_id'] = market['symbol']; // the request will be more performant if you include it + } + return await this.privateDeleteOrders (this.extend (request, params)); } calculateFee (symbol, type, side, amount, price, takerOrMaker = 'taker', params = {}) { @@ -48387,6 +50471,9 @@ module.exports = class coinbasepro extends Exchange { } else { method += 'Crypto'; request['crypto_address'] = address; + if (tag !== undefined) { + request['destination_tag'] = tag; + } } const response = await this[method] (this.extend (request, params)); if (!response) { @@ -48472,7 +50559,7 @@ module.exports = class coinbasepro extends Exchange { const currencyId = this.safeString (transaction, 'currency'); const code = this.safeCurrencyCode (currencyId, currency); const status = this.parseTransactionStatus (transaction); - const amount = this.safeFloat (transaction, 'amount'); + let amount = this.safeFloat (transaction, 'amount'); let type = this.safeString (transaction, 'type'); let address = this.safeString (details, 'crypto_address'); const tag = this.safeString (details, 'destination_tag'); @@ -48483,9 +50570,12 @@ module.exports = class coinbasepro extends Exchange { address = this.safeString (details, 'sent_to_address', address); const feeCost = this.safeFloat (details, 'fee'); if (feeCost !== undefined) { + if (amount !== undefined) { + amount -= feeCost; + } fee = { 'cost': feeCost, - 'code': code, + 'currency': code, }; } } @@ -48592,7 +50682,7 @@ module.exports = class coinbasepro extends Exchange { } }; -},{"./base/Exchange":5,"./base/errors":7,"./base/functions/number":13}],63:[function(require,module,exports){ +},{"./base/Exchange":6,"./base/errors":8,"./base/functions/number":14}],64:[function(require,module,exports){ 'use strict'; // --------------------------------------------------------------------------- @@ -48676,10 +50766,11 @@ module.exports = class coincheck extends Exchange { 'markets': { 'BTC/JPY': { 'id': 'btc_jpy', 'symbol': 'BTC/JPY', 'base': 'BTC', 'quote': 'JPY', 'baseId': 'btc', 'quoteId': 'jpy' }, // the only real pair // 'ETH/JPY': { 'id': 'eth_jpy', 'symbol': 'ETH/JPY', 'base': 'ETH', 'quote': 'JPY', 'baseId': 'eth', 'quoteId': 'jpy' }, - // 'ETC/JPY': { 'id': 'etc_jpy', 'symbol': 'ETC/JPY', 'base': 'ETC', 'quote': 'JPY', 'baseId': 'etc', 'quoteId': 'jpy' }, + 'ETC/JPY': { 'id': 'etc_jpy', 'symbol': 'ETC/JPY', 'base': 'ETC', 'quote': 'JPY', 'baseId': 'etc', 'quoteId': 'jpy' }, // 'DAO/JPY': { 'id': 'dao_jpy', 'symbol': 'DAO/JPY', 'base': 'DAO', 'quote': 'JPY', 'baseId': 'dao', 'quoteId': 'jpy' }, // 'LSK/JPY': { 'id': 'lsk_jpy', 'symbol': 'LSK/JPY', 'base': 'LSK', 'quote': 'JPY', 'baseId': 'lsk', 'quoteId': 'jpy' }, - // 'FCT/JPY': { 'id': 'fct_jpy', 'symbol': 'FCT/JPY', 'base': 'FCT', 'quote': 'JPY', 'baseId': 'fct', 'quoteId': 'jpy' }, + 'FCT/JPY': { 'id': 'fct_jpy', 'symbol': 'FCT/JPY', 'base': 'FCT', 'quote': 'JPY', 'baseId': 'fct', 'quoteId': 'jpy' }, + 'MONA/JPY': { 'id': 'mona_jpy', 'symbol': 'MONA/JPY', 'base': 'MONA', 'quote': 'JPY', 'baseId': 'mona', 'quoteId': 'jpy' }, // 'XMR/JPY': { 'id': 'xmr_jpy', 'symbol': 'XMR/JPY', 'base': 'XMR', 'quote': 'JPY', 'baseId': 'xmr', 'quoteId': 'jpy' }, // 'REP/JPY': { 'id': 'rep_jpy', 'symbol': 'REP/JPY', 'base': 'REP', 'quote': 'JPY', 'baseId': 'rep', 'quoteId': 'jpy' }, // 'XRP/JPY': { 'id': 'xrp_jpy', 'symbol': 'XRP/JPY', 'base': 'XRP', 'quote': 'JPY', 'baseId': 'xrp', 'quoteId': 'jpy' }, @@ -48688,7 +50779,7 @@ module.exports = class coincheck extends Exchange { // 'LTC/JPY': { 'id': 'ltc_jpy', 'symbol': 'LTC/JPY', 'base': 'LTC', 'quote': 'JPY', 'baseId': 'ltc', 'quoteId': 'jpy' }, // 'DASH/JPY': { 'id': 'dash_jpy', 'symbol': 'DASH/JPY', 'base': 'DASH', 'quote': 'JPY', 'baseId': 'dash', 'quoteId': 'jpy' }, // 'ETH/BTC': { 'id': 'eth_btc', 'symbol': 'ETH/BTC', 'base': 'ETH', 'quote': 'BTC', 'baseId': 'eth', 'quoteId': 'btc' }, - // 'ETC/BTC': { 'id': 'etc_btc', 'symbol': 'ETC/BTC', 'base': 'ETC', 'quote': 'BTC', 'baseId': 'etc', 'quoteId': 'btc' }, + 'ETC/BTC': { 'id': 'etc_btc', 'symbol': 'ETC/BTC', 'base': 'ETC', 'quote': 'BTC', 'baseId': 'etc', 'quoteId': 'btc' }, // 'LSK/BTC': { 'id': 'lsk_btc', 'symbol': 'LSK/BTC', 'base': 'LSK', 'quote': 'BTC', 'baseId': 'lsk', 'quoteId': 'btc' }, // 'FCT/BTC': { 'id': 'fct_btc', 'symbol': 'FCT/BTC', 'base': 'FCT', 'quote': 'BTC', 'baseId': 'fct', 'quoteId': 'btc' }, // 'XMR/BTC': { 'id': 'xmr_btc', 'symbol': 'XMR/BTC', 'base': 'XMR', 'quote': 'BTC', 'baseId': 'xmr', 'quoteId': 'btc' }, @@ -48792,6 +50883,7 @@ module.exports = class coincheck extends Exchange { 'side': side, 'type': undefined, 'timeInForce': undefined, + 'postOnly': undefined, 'status': status, 'symbol': symbol, 'price': price, @@ -48805,11 +50897,12 @@ module.exports = class coincheck extends Exchange { } async fetchOrderBook (symbol, limit = undefined, params = {}) { - if (symbol !== 'BTC/JPY') { - throw new BadSymbol (this.id + ' fetchOrderBook () supports BTC/JPY only'); - } await this.loadMarkets (); - const response = await this.publicGetOrderBooks (params); + const market = this.market (symbol); + const request = { + 'pair': market['id'], + }; + const response = await this.publicGetOrderBooks (this.extend (request, params)); return this.parseOrderBook (response); } @@ -48818,7 +50911,11 @@ module.exports = class coincheck extends Exchange { throw new BadSymbol (this.id + ' fetchTicker () supports BTC/JPY only'); } await this.loadMarkets (); - const ticker = await this.publicGetTicker (params); + const market = this.market (symbol); + const request = { + 'pair': market['id'], + }; + const ticker = await this.publicGetTicker (this.extend (request, params)); const timestamp = this.safeTimestamp (ticker, 'timestamp'); const last = this.safeFloat (ticker, 'last'); return { @@ -48932,9 +51029,6 @@ module.exports = class coincheck extends Exchange { } async fetchTrades (symbol, since = undefined, limit = undefined, params = {}) { - if (symbol !== 'BTC/JPY') { - throw new BadSymbol (this.id + ' fetchTrades () supports BTC/JPY only'); - } await this.loadMarkets (); const market = this.market (symbol); const request = { @@ -49024,7 +51118,7 @@ module.exports = class coincheck extends Exchange { } }; -},{"./base/Exchange":5,"./base/errors":7}],64:[function(require,module,exports){ +},{"./base/Exchange":6,"./base/errors":8}],65:[function(require,module,exports){ 'use strict'; // --------------------------------------------------------------------------- @@ -49181,6 +51275,7 @@ module.exports = class coinegg extends Exchange { }, 'commonCurrencies': { 'JBC': 'JubaoCoin', + 'SBTC': 'Super Bitcoin', }, }); } @@ -49394,6 +51489,7 @@ module.exports = class coinegg extends Exchange { 'symbol': symbol, 'type': type, 'timeInForce': undefined, + 'postOnly': undefined, 'side': side, 'price': price, 'stopPrice': undefined, @@ -49541,7 +51637,7 @@ module.exports = class coinegg extends Exchange { } }; -},{"./base/Exchange":5,"./base/errors":7}],65:[function(require,module,exports){ +},{"./base/Exchange":6,"./base/errors":8}],66:[function(require,module,exports){ 'use strict'; // --------------------------------------------------------------------------- @@ -49636,6 +51732,8 @@ module.exports = class coinex extends Exchange { 'order/status', 'order/status/batch', 'order/user/deals', + 'sub_account/balance', + 'sub_account/transfer/history', ], 'post': [ 'balance/coin/withdraw', @@ -50043,6 +52141,7 @@ module.exports = class coinex extends Exchange { 'symbol': symbol, 'type': type, 'timeInForce': undefined, + 'postOnly': undefined, 'side': side, 'price': price, 'stopPrice': undefined, @@ -50106,7 +52205,7 @@ module.exports = class coinex extends Exchange { async fetchOrder (id, symbol = undefined, params = {}) { if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' fetchOrder requires a symbol argument'); + throw new ArgumentsRequired (this.id + ' fetchOrder() requires a symbol argument'); } await this.loadMarkets (); const market = this.market (symbol); @@ -50303,7 +52402,7 @@ module.exports = class coinex extends Exchange { const timestamp = this.safeTimestamp (transaction, 'create_time'); const type = ('coin_withdraw_id' in transaction) ? 'withdraw' : 'deposit'; const status = this.parseTransactionStatus (this.safeString (transaction, 'status')); - const amount = this.safeFloat (transaction, 'amount'); + let amount = this.safeFloat (transaction, 'amount'); let feeCost = this.safeFloat (transaction, 'tx_fee'); if (type === 'deposit') { feeCost = 0; @@ -50312,6 +52411,10 @@ module.exports = class coinex extends Exchange { 'cost': feeCost, 'currency': code, }; + // https://github.com/ccxt/ccxt/issues/8321 + if (amount !== undefined) { + amount = amount - feeCost; + } return { 'info': transaction, 'id': id, @@ -50331,7 +52434,7 @@ module.exports = class coinex extends Exchange { async fetchWithdrawals (code = undefined, since = undefined, limit = undefined, params = {}) { if (code === undefined) { - throw new ArgumentsRequired (this.id + ' fetchWithdrawals requires a currency code argument'); + throw new ArgumentsRequired (this.id + ' fetchWithdrawals() requires a currency code argument'); } await this.loadMarkets (); const currency = this.currency (code); @@ -50389,7 +52492,7 @@ module.exports = class coinex extends Exchange { async fetchDeposits (code = undefined, since = undefined, limit = undefined, params = {}) { if (code === undefined) { - throw new ArgumentsRequired (this.id + ' fetchDeposits requires a currency code argument'); + throw new ArgumentsRequired (this.id + ' fetchDeposits() requires a currency code argument'); } await this.loadMarkets (); const currency = this.currency (code); @@ -50454,7 +52557,7 @@ module.exports = class coinex extends Exchange { 'tonce': nonce.toString (), }, query); query = this.keysort (query); - const urlencoded = this.urlencode (query); + const urlencoded = this.rawencode (query); const signature = this.hash (this.encode (urlencoded + '&secret_key=' + this.secret)); headers = { 'Authorization': signature.toUpperCase (), @@ -50491,7 +52594,7 @@ module.exports = class coinex extends Exchange { } }; -},{"./base/Exchange":5,"./base/errors":7}],66:[function(require,module,exports){ +},{"./base/Exchange":6,"./base/errors":8}],67:[function(require,module,exports){ 'use strict'; // --------------------------------------------------------------------------- @@ -50711,7 +52814,7 @@ module.exports = class coinfalcon extends Exchange { async fetchMyTrades (symbol = undefined, since = undefined, limit = undefined, params = {}) { if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' fetchMyTrades requires a symbol argument'); + throw new ArgumentsRequired (this.id + ' fetchMyTrades() requires a symbol argument'); } await this.loadMarkets (); const market = this.market (symbol); @@ -50814,6 +52917,7 @@ module.exports = class coinfalcon extends Exchange { type = type[0]; } const side = this.safeString (order, 'order_type'); + const postOnly = this.safeValue (order, 'post_only'); return { 'id': this.safeString (order, 'id'), 'clientOrderId': undefined, @@ -50823,6 +52927,7 @@ module.exports = class coinfalcon extends Exchange { 'symbol': symbol, 'type': type, 'timeInForce': undefined, + 'postOnly': postOnly, 'side': side, 'price': price, 'stopPrice': undefined, @@ -50945,7 +53050,7 @@ module.exports = class coinfalcon extends Exchange { } }; -},{"./base/Exchange":5,"./base/errors":7}],67:[function(require,module,exports){ +},{"./base/Exchange":6,"./base/errors":8}],68:[function(require,module,exports){ 'use strict'; // --------------------------------------------------------------------------- @@ -50975,7 +53080,7 @@ module.exports = class coinfloor extends Exchange { }, 'urls': { 'logo': 'https://user-images.githubusercontent.com/51840849/87153925-ef265e80-c2c0-11ea-91b5-020c804b90e0.jpg', - 'api': 'https://webapi.coinfloor.co.uk/bist', + 'api': 'https://webapi.coinfloor.co.uk/v2/bist', 'www': 'https://www.coinfloor.co.uk', 'doc': [ 'https://github.com/coinfloor/api', @@ -51038,7 +53143,7 @@ module.exports = class coinfloor extends Exchange { market = this.markets_by_id[marketId]; } if (market === undefined) { - throw new ArgumentsRequired (this.id + ' fetchBalance requires a symbol param'); + throw new ArgumentsRequired (this.id + ' fetchBalance() requires a symbol param'); } const request = { 'id': market['id'], @@ -51171,7 +53276,7 @@ module.exports = class coinfloor extends Exchange { if (code !== undefined) { market = this.market (code); if (market === undefined) { - throw new ArgumentsRequired (this.id + ' fetchTransactions requires a code argument (a market symbol)'); + throw new ArgumentsRequired (this.id + ' fetchTransactions() requires a code argument (a market symbol)'); } } const request = { @@ -51379,7 +53484,7 @@ module.exports = class coinfloor extends Exchange { async cancelOrder (id, symbol = undefined, params = {}) { if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' cancelOrder requires a symbol argument'); + throw new ArgumentsRequired (this.id + ' cancelOrder() requires a symbol argument'); } await this.loadMarkets (); const market = this.market (symbol); @@ -51428,6 +53533,7 @@ module.exports = class coinfloor extends Exchange { 'symbol': symbol, 'type': 'limit', 'timeInForce': undefined, + 'postOnly': undefined, 'side': side, 'price': price, 'stopPrice': undefined, @@ -51443,7 +53549,7 @@ module.exports = class coinfloor extends Exchange { async fetchOpenOrders (symbol = undefined, since = undefined, limit = undefined, params = {}) { if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' fetchOpenOrders requires a symbol param'); + throw new ArgumentsRequired (this.id + ' fetchOpenOrders() requires a symbol param'); } await this.loadMarkets (); const market = this.market (symbol); @@ -51497,7 +53603,7 @@ module.exports = class coinfloor extends Exchange { } }; -},{"./base/Exchange":5,"./base/errors":7}],68:[function(require,module,exports){ +},{"./base/Exchange":6,"./base/errors":8}],69:[function(require,module,exports){ 'use strict'; // --------------------------------------------------------------------------- @@ -51847,7 +53953,7 @@ module.exports = class coingi extends Exchange { } }; -},{"./base/Exchange":5,"./base/errors":7}],69:[function(require,module,exports){ +},{"./base/Exchange":6,"./base/errors":8}],70:[function(require,module,exports){ 'use strict'; // --------------------------------------------------------------------------- @@ -52000,6 +54106,8 @@ module.exports = class coinmarketcap extends Exchange { // https://github.com/ccxt/ccxt/issues/6081 // https://github.com/ccxt/ccxt/issues/3365 // https://github.com/ccxt/ccxt/issues/2873 + 'SBTCT': 'SiamBitcoin', // conflict with sBTC + 'Super Bitcoin': 'Super Bitcoin', // conflict with sBTC 'TerraCredit': 'TerraCredit', // conflict with CREDIT (PROXI) 'Themis': 'Themis', // conflict with GET (Guaranteed Entrance Token, GET Protocol) 'UNI COIN': 'UNI COIN', // conflict with UNI (Uniswap) @@ -52194,7 +54302,7 @@ module.exports = class coinmarketcap extends Exchange { } }; -},{"./base/Exchange":5,"./base/errors":7}],70:[function(require,module,exports){ +},{"./base/Exchange":6,"./base/errors":8}],71:[function(require,module,exports){ 'use strict'; // --------------------------------------------------------------------------- @@ -52726,7 +54834,7 @@ module.exports = class coinmate extends Exchange { async fetchOrders (symbol = undefined, since = undefined, limit = undefined, params = {}) { if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' fetchOrders requires a symbol argument'); + throw new ArgumentsRequired (this.id + ' fetchOrders() requires a symbol argument'); } await this.loadMarkets (); const market = this.market (symbol); @@ -52838,6 +54946,7 @@ module.exports = class coinmate extends Exchange { 'symbol': symbol, 'type': type, 'timeInForce': undefined, + 'postOnly': undefined, 'side': side, 'price': price, 'stopPrice': stopPrice, @@ -52955,7 +55064,7 @@ module.exports = class coinmate extends Exchange { } }; -},{"./base/Exchange":5,"./base/errors":7}],71:[function(require,module,exports){ +},{"./base/Exchange":6,"./base/errors":8}],72:[function(require,module,exports){ 'use strict'; // --------------------------------------------------------------------------- @@ -53331,7 +55440,7 @@ module.exports = class coinone extends Exchange { async fetchOrder (id, symbol = undefined, params = {}) { if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' fetchOrder requires a symbol argument'); + throw new ArgumentsRequired (this.id + ' fetchOrder() requires a symbol argument'); } await this.loadMarkets (); const market = this.market (symbol); @@ -53476,6 +55585,7 @@ module.exports = class coinone extends Exchange { 'symbol': symbol, 'type': 'limit', 'timeInForce': undefined, + 'postOnly': undefined, 'side': side, 'price': price, 'stopPrice': undefined, @@ -53525,7 +55635,7 @@ module.exports = class coinone extends Exchange { async fetchMyTrades (symbol = undefined, since = undefined, limit = undefined, params = {}) { if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' fetchMyTrades requires a symbol argument'); + throw new ArgumentsRequired (this.id + ' fetchMyTrades() requires a symbol argument'); } await this.loadMarkets (); const market = this.market (symbol); @@ -53560,14 +55670,14 @@ module.exports = class coinone extends Exchange { async cancelOrder (id, symbol = undefined, params = {}) { if (symbol === undefined) { // eslint-disable-next-line quotes - throw new ArgumentsRequired (this.id + " cancelOrder requires a symbol argument. To cancel the order, pass a symbol argument and {'price': 12345, 'qty': 1.2345, 'is_ask': 0} in the params argument of cancelOrder."); + throw new ArgumentsRequired (this.id + " cancelOrder() requires a symbol argument. To cancel the order, pass a symbol argument and {'price': 12345, 'qty': 1.2345, 'is_ask': 0} in the params argument of cancelOrder."); } const price = this.safeFloat (params, 'price'); const qty = this.safeFloat (params, 'qty'); const isAsk = this.safeInteger (params, 'is_ask'); if ((price === undefined) || (qty === undefined) || (isAsk === undefined)) { // eslint-disable-next-line quotes - throw new ArgumentsRequired (this.id + " cancelOrder requires {'price': 12345, 'qty': 1.2345, 'is_ask': 0} in the params argument."); + throw new ArgumentsRequired (this.id + " cancelOrder() requires {'price': 12345, 'qty': 1.2345, 'is_ask': 0} in the params argument."); } await this.loadMarkets (); const request = { @@ -53638,13 +55748,13 @@ module.exports = class coinone extends Exchange { } }; -},{"./base/Exchange":5,"./base/errors":7}],72:[function(require,module,exports){ +},{"./base/Exchange":6,"./base/errors":8}],73:[function(require,module,exports){ 'use strict'; // --------------------------------------------------------------------------- const Exchange = require ('./base/Exchange'); -const { ExchangeError, AuthenticationError, NotSupported } = require ('./base/errors'); +const { ExchangeError, ArgumentsRequired, AuthenticationError } = require ('./base/errors'); // --------------------------------------------------------------------------- @@ -53711,27 +55821,72 @@ module.exports = class coinspot extends Exchange { }, 'markets': { 'BTC/AUD': { 'id': 'btc', 'symbol': 'BTC/AUD', 'base': 'BTC', 'quote': 'AUD', 'baseId': 'btc', 'quoteId': 'aud' }, + 'ETH/AUD': { 'id': 'eth', 'symbol': 'ETH/AUD', 'base': 'ETH', 'quote': 'AUD', 'baseId': 'eth', 'quoteId': 'aud' }, + 'XRP/AUD': { 'id': 'xrp', 'symbol': 'XRP/AUD', 'base': 'XRP', 'quote': 'AUD', 'baseId': 'xrp', 'quoteId': 'aud' }, 'LTC/AUD': { 'id': 'ltc', 'symbol': 'LTC/AUD', 'base': 'LTC', 'quote': 'AUD', 'baseId': 'ltc', 'quoteId': 'aud' }, 'DOGE/AUD': { 'id': 'doge', 'symbol': 'DOGE/AUD', 'base': 'DOGE', 'quote': 'AUD', 'baseId': 'doge', 'quoteId': 'aud' }, + 'RFOX/AUD': { 'id': 'rfox', 'symbol': 'RFOX/AUD', 'base': 'RFOX', 'quote': 'AUD', 'baseId': 'rfox', 'quoteId': 'aud' }, + 'POWR/AUD': { 'id': 'powr', 'symbol': 'POWR/AUD', 'base': 'POWR', 'quote': 'AUD', 'baseId': 'powr', 'quoteId': 'aud' }, + 'NEO/AUD': { 'id': 'neo', 'symbol': 'NEO/AUD', 'base': 'NEO', 'quote': 'AUD', 'baseId': 'neo', 'quoteId': 'aud' }, + 'TRX/AUD': { 'id': 'trx', 'symbol': 'TRX/AUD', 'base': 'TRX', 'quote': 'AUD', 'baseId': 'trx', 'quoteId': 'aud' }, + 'EOS/AUD': { 'id': 'eos', 'symbol': 'EOS/AUD', 'base': 'EOS', 'quote': 'AUD', 'baseId': 'eos', 'quoteId': 'aud' }, + 'XLM/AUD': { 'id': 'xlm', 'symbol': 'XLM/AUD', 'base': 'XLM', 'quote': 'AUD', 'baseId': 'xlm', 'quoteId': 'aud' }, + 'RHOC/AUD': { 'id': 'rhoc', 'symbol': 'RHOC/AUD', 'base': 'RHOC', 'quote': 'AUD', 'baseId': 'rhoc', 'quoteId': 'aud' }, + 'GAS/AUD': { 'id': 'gas', 'symbol': 'GAS/AUD', 'base': 'GAS', 'quote': 'AUD', 'baseId': 'gas', 'quoteId': 'aud' }, }, 'commonCurrencies': { 'DRK': 'DASH', }, + 'options': { + 'fetchBalance': 'private_post_my_balances', + }, }); } async fetchBalance (params = {}) { await this.loadMarkets (); - const response = await this.privatePostMyBalances (params); + const method = this.safeString (this.options, 'fetchBalance', 'private_post_my_balances'); + const response = await this[method] (params); + // + // read-write api keys + // + // ... + // + // read-only api keys + // + // { + // "status":"ok", + // "balances":[ + // { + // "LTC":{"balance":0.1,"audbalance":16.59,"rate":165.95} + // } + // ] + // } + // const result = { 'info': response }; - const balances = this.safeValue (response, 'balance', {}); - const currencyIds = Object.keys (balances); - for (let i = 0; i < currencyIds.length; i++) { - const currencyId = currencyIds[i]; - const code = this.safeCurrencyCode (currencyId); - const account = this.account (); - account['total'] = this.safeFloat (balances, currencyId); - result[code] = account; + const balances = this.safeValue2 (response, 'balance', 'balances'); + if (Array.isArray (balances)) { + for (let i = 0; i < balances.length; i++) { + const currencies = balances[i]; + const currencyIds = Object.keys (currencies); + for (let j = 0; j < currencyIds.length; j++) { + const currencyId = currencyIds[j]; + const balance = currencies[currencyId]; + const code = this.safeCurrencyCode (currencyId); + const account = this.account (); + account['total'] = this.safeFloat (balance, 'balance'); + result[code] = account; + } + } + } else { + const currencyIds = Object.keys (balances); + for (let i = 0; i < currencyIds.length; i++) { + const currencyId = currencyIds[i]; + const code = this.safeCurrencyCode (currencyId); + const account = this.account (); + account['total'] = this.safeFloat (balances, currencyId); + result[code] = account; + } } return this.parseBalance (result); } @@ -53851,9 +56006,16 @@ module.exports = class coinspot extends Exchange { } async cancelOrder (id, symbol = undefined, params = {}) { - throw new NotSupported (this.id + ' cancelOrder () is not fully implemented yet'); - // let method = 'privatePostMyBuy'; - // return await this[method] ({ 'id': id }); + const side = this.safeString (params, 'side'); + if (side !== 'buy' && side !== 'sell') { + throw new ArgumentsRequired (this.id + ' cancelOrder() requires a side parameter, "buy" or "sell"'); + } + params = this.omit (params, 'side'); + const method = 'privatePostMy' + this.capitalize (side) + 'Cancel'; + const request = { + 'id': id, + }; + return await this[method] (this.extend (request, params)); } sign (path, api = 'public', method = 'GET', params = {}, headers = undefined, body = undefined) { @@ -53875,7 +56037,7 @@ module.exports = class coinspot extends Exchange { } }; -},{"./base/Exchange":5,"./base/errors":7}],73:[function(require,module,exports){ +},{"./base/Exchange":6,"./base/errors":8}],74:[function(require,module,exports){ 'use strict'; // --------------------------------------------------------------------------- @@ -54011,6 +56173,7 @@ module.exports = class crex24 extends Exchange { 'GHOST': 'GHOSTPRISM', 'IQ': 'IQ.Cash', 'PUT': 'PutinCoin', + 'SBTC': 'SBTCT', // SiamBitcoin 'UNI': 'Universe', 'YOYO': 'YOYOW', }, @@ -54036,6 +56199,7 @@ module.exports = class crex24 extends Exchange { "Parameter 'instrument' contains invalid value.": BadSymbol, }, 'broad': { + 'try again later': ExchangeNotAvailable, // {"errorDescription":"Failed to process the request. Please, try again later."} 'API Key': AuthenticationError, // "API Key '9edc48de-d5b0-4248-8e7e-f59ffcd1c7f1' doesn't exist." 'Insufficient funds': InsufficientFunds, // "Insufficient funds: new order requires 10 ETH which is more than the available balance." 'has been delisted.': BadSymbol, // {"errorDescription":"Instrument '$PAC-BTC' has been delisted."} @@ -54635,14 +56799,14 @@ module.exports = class crex24 extends Exchange { } if (priceIsRequired) { if (price === undefined) { - throw new InvalidOrder (this.id + ' createOrder method requires a price argument for a ' + type + ' order'); + throw new InvalidOrder (this.id + ' createOrder() requires a price argument for a ' + type + ' order'); } request['price'] = this.priceToPrecision (symbol, price); } if (stopPriceIsRequired) { const stopPrice = this.safeFloat (params, 'stopPrice'); if (stopPrice === undefined) { - throw new InvalidOrder (this.id + ' createOrder method requires a stopPrice extra param for a ' + type + ' order'); + throw new InvalidOrder (this.id + ' createOrder() requires a stopPrice extra param for a ' + type + ' order'); } else { request['stopPrice'] = this.priceToPrecision (symbol, stopPrice); } @@ -55185,7 +57349,7 @@ module.exports = class crex24 extends Exchange { } }; -},{"./base/Exchange":5,"./base/errors":7}],74:[function(require,module,exports){ +},{"./base/Exchange":6,"./base/errors":8}],75:[function(require,module,exports){ 'use strict'; // --------------------------------------------------------------------------- @@ -56104,7 +58268,7 @@ module.exports = class currencycom extends Exchange { if (market['margin']) { accountId = this.safeInteger (params, 'accountId'); if (accountId === undefined) { - throw new ArgumentsRequired (this.id + ' createOrder requires an accountId parameter for ' + market['type'] + ' market ' + symbol); + throw new ArgumentsRequired (this.id + ' createOrder() requires an accountId parameter for ' + market['type'] + ' market ' + symbol); } } const uppercaseType = type.toUpperCase (); @@ -56165,7 +58329,7 @@ module.exports = class currencycom extends Exchange { const symbols = this.symbols; const numSymbols = symbols.length; const fetchOpenOrdersRateLimit = parseInt (numSymbols / 2); - throw new ExchangeError (this.id + ' fetchOpenOrders WARNING: fetching open orders without specifying a symbol is rate-limited to one call per ' + fetchOpenOrdersRateLimit.toString () + ' seconds. Do not call this method frequently to avoid ban. Set ' + this.id + '.options["warnOnFetchOpenOrdersWithoutSymbol"] = false to suppress this warning message.'); + throw new ExchangeError (this.id + ' fetchOpenOrders() WARNING: fetching open orders without specifying a symbol is rate-limited to one call per ' + fetchOpenOrdersRateLimit.toString () + ' seconds. Do not call this method frequently to avoid ban. Set ' + this.id + '.options["warnOnFetchOpenOrdersWithoutSymbol"] = false to suppress this warning message.'); } const response = await this.privateGetOpenOrders (this.extend (request, params)); return this.parseOrders (response, market, since, limit); @@ -56173,7 +58337,7 @@ module.exports = class currencycom extends Exchange { async cancelOrder (id, symbol = undefined, params = {}) { if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' cancelOrder requires a symbol argument'); + throw new ArgumentsRequired (this.id + ' cancelOrder() requires a symbol argument'); } await this.loadMarkets (); const market = this.market (symbol); @@ -56208,7 +58372,7 @@ module.exports = class currencycom extends Exchange { async fetchMyTrades (symbol = undefined, since = undefined, limit = undefined, params = {}) { if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' fetchMyTrades requires a symbol argument'); + throw new ArgumentsRequired (this.id + ' fetchMyTrades() requires a symbol argument'); } await this.loadMarkets (); const market = this.market (symbol); @@ -56306,7 +58470,1492 @@ module.exports = class currencycom extends Exchange { } }; -},{"./base/Exchange":5,"./base/errors":7,"./base/functions/number":13}],75:[function(require,module,exports){ +},{"./base/Exchange":6,"./base/errors":8,"./base/functions/number":14}],76:[function(require,module,exports){ +'use strict'; + +// --------------------------------------------------------------------------- + +const Exchange = require ('./base/Exchange'); +const { ExchangeError, InsufficientFunds, BadRequest, BadSymbol, InvalidOrder, AuthenticationError, ArgumentsRequired, OrderNotFound, ExchangeNotAvailable } = require ('./base/errors'); +const { TICK_SIZE } = require ('./base/functions/number'); + +// --------------------------------------------------------------------------- + +module.exports = class delta extends Exchange { + describe () { + return this.deepExtend (super.describe (), { + 'id': 'delta', + 'name': 'Delta Exchange', + 'countries': [ 'VC' ], // Saint Vincent and the Grenadines + 'rateLimit': 300, + 'version': 'v2', + // new metainfo interface + 'has': { + 'cancelAllOrders': true, + 'cancelOrder': true, + 'createOrder': true, + 'editOrder': true, + 'fetchBalance': true, + 'fetchClosedOrders': true, + 'fetchDepositAddress': true, + 'fetchCurrencies': true, + 'fetchLedger': true, + 'fetchMarkets': true, + 'fetchMyTrades': true, + 'fetchOHLCV': true, + 'fetchOpenOrders': true, + 'fetchOrderBook': true, + 'fetchStatus': true, + 'fetchTicker': true, + 'fetchTickers': true, + 'fetchTime': true, + 'fetchTrades': true, + }, + 'timeframes': { + '1m': '1m', + '3m': '3m', + '5m': '5m', + '15m': '15m', + '30m': '30m', + '1h': '1h', + '2h': '2h', + '4h': '4h', + '6h': '6h', + '1d': '1d', + '7d': '7d', + '1w': '1w', + '2w': '2w', + '1M': '30d', + }, + 'urls': { + 'logo': 'https://user-images.githubusercontent.com/1294454/99450025-3be60a00-2931-11eb-9302-f4fd8d8589aa.jpg', + 'test': { + 'public': 'https://testnet-api.delta.exchange', + 'private': 'https://testnet-api.delta.exchange', + }, + 'api': { + 'public': 'https://api.delta.exchange', + 'private': 'https://api.delta.exchange', + }, + 'www': 'https://www.delta.exchange', + 'doc': [ + 'https://docs.delta.exchange', + ], + 'fees': 'https://www.delta.exchange/fees', + 'referral': 'https://www.delta.exchange/app/signup/?code=IULYNB', + }, + 'api': { + 'public': { + 'get': [ + 'assets', + 'settings', + 'indices', + 'products', + 'tickers', + 'tickers/{symbol}', + 'l2orderbook/{symbol}', + 'trades/{symbol}', + 'history/candles', + 'history/sparklines', + ], + }, + 'private': { + 'get': [ + 'orders', + 'orders/leverage', + 'positions', + 'positions/margined', + 'orders/history', + 'fills', + 'fills/history/download/csv', + 'wallet/balances', + 'wallet/transactions', + 'wallet/transactions/download', + 'deposits/address', + ], + 'post': [ + 'orders', + 'orders/batch', + 'orders/leverage', + 'positions/change_margin', + ], + 'put': [ + 'orders', + 'orders/batch', + ], + 'delete': [ + 'orders', + 'orders/all', + 'orders/batch', + ], + }, + }, + 'fees': { + 'trading': { + 'tierBased': true, + 'percentage': true, + 'taker': 0.15 / 100, + 'maker': 0.10 / 100, + 'tiers': { + 'taker': [ + [0, 0.15 / 100], + [100, 0.13 / 100], + [250, 0.13 / 100], + [1000, 0.1 / 100], + [5000, 0.09 / 100], + [10000, 0.075 / 100], + [20000, 0.065 / 100], + ], + 'maker': [ + [0, 0.1 / 100], + [100, 0.1 / 100], + [250, 0.09 / 100], + [1000, 0.075 / 100], + [5000, 0.06 / 100], + [10000, 0.05 / 100], + [20000, 0.05 / 100], + ], + }, + }, + }, + 'precisionMode': TICK_SIZE, + 'requiredCredentials': { + 'apiKey': true, + 'secret': false, + }, + 'exceptions': { + 'exact': { + // Margin required to place order with selected leverage and quantity is insufficient. + 'insufficient_margin': InsufficientFunds, // {"error":{"code":"insufficient_margin","context":{"available_balance":"0.000000000000000000","required_additional_balance":"1.618626000000000000000000000"}},"success":false} + 'order_size_exceed_available': InvalidOrder, // The order book doesn't have sufficient liquidity, hence the order couldnt be filled, for example, ioc orders + 'risk_limits_breached': BadRequest, // orders couldn't be placed as it will breach allowed risk limits. + 'invalid_contract': BadSymbol, // The contract/product is either doesn't exist or has already expired. + 'immediate_liquidation': InvalidOrder, // Order will cause immediate liquidation. + 'out_of_bankruptcy': InvalidOrder, // Order prices are out of position bankruptcy limits. + 'self_matching_disrupted_post_only': InvalidOrder, // Self matching is not allowed during auction. + 'immediate_execution_post_only': InvalidOrder, // orders couldn't be placed as it includes post only orders which will be immediately executed + 'bad_schema': BadRequest, // {"error":{"code":"bad_schema","context":{"schema_errors":[{"code":"validation_error","message":"id is required","param":""}]}},"success":false} + 'invalid_api_key': AuthenticationError, // {"success":false,"error":{"code":"invalid_api_key"}} + 'invalid_signature': AuthenticationError, // {"success":false,"error":{"code":"invalid_signature"}} + 'open_order_not_found': OrderNotFound, // {"error":{"code":"open_order_not_found"},"success":false} + 'unavailable': ExchangeNotAvailable, // {"error":{"code":"unavailable"},"success":false} + }, + 'broad': { + }, + }, + }); + } + + async fetchTime (params = {}) { + const response = await this.publicGetSettings (params); + // + // { + // "result":{ + // "server_time":1605472733766141, + // "deto_referral_mining_daily_reward":"25000", + // "deto_total_reward_pool":"100000000", + // "deto_trade_mining_daily_reward":"75000", + // "kyc_deposit_limit":"20", + // "kyc_withdrawal_limit":"2", + // "under_maintenance":"false" + // }, + // "success":true + // } + // + const result = this.safeValue (response, 'result', {}); + return this.safeIntegerProduct (result, 'server_time', 0.001); + } + + async fetchStatus (params = {}) { + const response = await this.publicGetSettings (params); + const result = this.safeValue (response, 'result', {}); + const underMaintenance = this.safeValue (result, 'under_maintenance'); + const status = (underMaintenance === 'true') ? 'maintenance' : 'ok'; + const updated = this.safeIntegerProduct (result, 'server_time', 0.001); + this.status = this.extend (this.status, { + 'status': status, + 'updated': updated, + }); + return this.status; + } + + async fetchCurrencies (params = {}) { + const response = await this.publicGetAssets (params); + // + // { + // "result":[ + // { + // "base_withdrawal_fee":"0.0005", + // "deposit_status":"enabled", + // "id":2, + // "interest_credit":true, + // "interest_slabs":[ + // {"limit":"0.1","rate":"0"}, + // {"limit":"1","rate":"0.05"}, + // {"limit":"5","rate":"0.075"}, + // {"limit":"10","rate":"0.1"}, + // {"limit":"9999999999999999","rate":"0"} + // ], + // "kyc_deposit_limit":"10", + // "kyc_withdrawal_limit":"2", + // "min_withdrawal_amount":"0.001", + // "minimum_precision":4, + // "name":"Bitcoin", + // "precision":8, + // "sort_priority":1, + // "symbol":"BTC", + // "variable_withdrawal_fee":"0", + // "withdrawal_status":"enabled" + // }, + // ], + // "success":true + // } + // + const currencies = this.safeValue (response, 'result', []); + const result = {}; + for (let i = 0; i < currencies.length; i++) { + const currency = currencies[i]; + const id = this.safeString (currency, 'symbol'); + const numericId = this.safeInteger (currency, 'id'); + const code = this.safeCurrencyCode (id); + const depositStatus = this.safeString (currency, 'deposit_status'); + const withdrawalStatus = this.safeString (currency, 'withdrawal_status'); + const depositsEnabled = (depositStatus === 'enabled'); + const withdrawalsEnabled = (withdrawalStatus === 'enabled'); + const active = depositsEnabled && withdrawalsEnabled; + const precision = this.safeInteger (currency, 'precision'); + result[code] = { + 'id': id, + 'numericId': numericId, + 'code': code, + 'name': this.safeString (currency, 'name'), + 'info': currency, // the original payload + 'active': active, + 'fee': this.safeFloat (currency, 'base_withdrawal_fee'), + 'precision': 1 / Math.pow (10, precision), + 'limits': { + 'amount': { 'min': undefined, 'max': undefined }, + 'price': { 'min': undefined, 'max': undefined }, + 'cost': { 'min': undefined, 'max': undefined }, + 'withdraw': { + 'min': this.safeFloat (currency, 'min_withdrawal_amount'), + 'max': undefined, + }, + }, + }; + } + return result; + } + + async loadMarkets (reload = false, params = {}) { + const markets = await super.loadMarkets (reload, params); + const currenciesByNumericId = this.safeValue (this.options, 'currenciesByNumericId'); + if ((currenciesByNumericId === undefined) || reload) { + this.options['currenciesByNumericId'] = this.indexBy (this.currencies, 'numericId'); + } + const marketsByNumericId = this.safeValue (this.options, 'marketsByNumericId'); + if ((marketsByNumericId === undefined) || reload) { + this.options['marketsByNumericId'] = this.indexBy (this.markets, 'numericId'); + } + return markets; + } + + async fetchMarkets (params = {}) { + const response = await this.publicGetProducts (params); + // + // { + // "meta":{ + // "after":null, + // "before":null, + // "limit":100, + // "total_count":81 + // }, + // "result":[ + // { + // "annualized_funding":"5.475000000000000000", + // "is_quanto":false, + // "ui_config":{ + // "default_trading_view_candle":"15", + // "leverage_slider_values":[1,3,5,10,25,50], + // "price_clubbing_values":[0.001,0.005,0.05,0.1,0.5,1,5], + // "show_bracket_orders":false, + // "sort_priority":29, + // "tags":[] + // }, + // "basis_factor_max_limit":"0.15", + // "symbol":"P-LINK-D-151120", + // "id":1584, + // "default_leverage":"5.000000000000000000", + // "maker_commission_rate":"0.0005", + // "contract_unit_currency":"LINK", + // "strike_price":"12.507948", + // "settling_asset":{ + // // asset structure + // }, + // "auction_start_time":null, + // "auction_finish_time":null, + // "settlement_time":"2020-11-15T12:00:00Z", + // "launch_time":"2020-11-14T11:55:05Z", + // "spot_index":{ + // // index structure + // }, + // "trading_status":"operational", + // "tick_size":"0.001", + // "position_size_limit":100000, + // "notional_type":"vanilla", // vanilla, inverse + // "price_band":"0.4", + // "barrier_price":null, + // "description":"Daily LINK PUT options quoted in USDT and settled in USDT", + // "insurance_fund_margin_contribution":"1", + // "quoting_asset":{ + // // asset structure + // }, + // "liquidation_penalty_factor":"0.2", + // "product_specs":{"max_volatility":3,"min_volatility":0.3,"spot_price_band":"0.40"}, + // "initial_margin_scaling_factor":"0.0001", + // "underlying_asset":{ + // // asset structure + // }, + // "state":"live", + // "contract_value":"1", + // "initial_margin":"2", + // "impact_size":5000, + // "settlement_price":null, + // "contract_type":"put_options", // put_options, call_options, move_options, perpetual_futures, interest_rate_swaps, futures, spreads + // "taker_commission_rate":"0.0005", + // "maintenance_margin":"1", + // "short_description":"LINK Daily PUT Options", + // "maintenance_margin_scaling_factor":"0.00005", + // "funding_method":"mark_price", + // "max_leverage_notional":"20000" + // }, + // ], + // "success":true + // } + // + const markets = this.safeValue (response, 'result', []); + const result = []; + for (let i = 0; i < markets.length; i++) { + const market = markets[i]; + let type = this.safeString (market, 'contract_type'); + // const settlingAsset = this.safeValue (market, 'settling_asset', {}); + const quotingAsset = this.safeValue (market, 'quoting_asset', {}); + const underlyingAsset = this.safeValue (market, 'underlying_asset', {}); + const baseId = this.safeString (underlyingAsset, 'symbol'); + const quoteId = this.safeString (quotingAsset, 'symbol'); + const id = this.safeString (market, 'symbol'); + const numericId = this.safeInteger (market, 'id'); + const base = this.safeCurrencyCode (baseId); + const quote = this.safeCurrencyCode (quoteId); + let symbol = id; + let swap = false; + let future = false; + let option = false; + if (type === 'perpetual_futures') { + type = 'swap'; + swap = true; + future = false; + option = false; + if (id.indexOf ('_') < 0) { + symbol = base + '/' + quote; + } + } else if ((type === 'call_options') || (type === 'put_options') || (type === 'move_options')) { + type = 'option'; + swap = false; + option = true; + future = false; + } else if (type === 'futures') { + type = 'future'; + swap = false; + option = false; + future = true; + } + const precision = { + 'amount': 1.0, // number of contracts + 'price': this.safeFloat (market, 'tick_size'), + }; + const limits = { + 'amount': { + 'min': 1.0, + 'max': this.safeFloat (market, 'position_size_limit'), + }, + 'price': { + 'min': precision['price'], + 'max': undefined, + }, + 'cost': { + 'min': this.safeFloat (market, 'min_size'), + 'max': undefined, + }, + }; + const state = this.safeString (market, 'state'); + const active = (state === 'live'); + const maker = this.safeFloat (market, 'maker_commission_rate'); + const taker = this.safeFloat (market, 'taker_commission_rate'); + result.push ({ + 'id': id, + 'numericId': numericId, + 'symbol': symbol, + 'base': base, + 'quote': quote, + 'baseId': baseId, + 'quoteId': quoteId, + 'type': type, + 'option': option, + 'swap': swap, + 'future': future, + 'maker': maker, + 'taker': taker, + 'precision': precision, + 'limits': limits, + 'info': market, + 'active': active, + }); + } + return result; + } + + parseTicker (ticker, market = undefined) { + // + // fetchTicker, fetchTickers + // + // { + // "close":15837.5, + // "high":16354, + // "low":15751.5, + // "mark_price":"15820.100867", + // "open":16140.5, + // "product_id":139, + // "size":640552, + // "spot_price":"15827.050000000001", + // "symbol":"BTCUSDT", + // "timestamp":1605373550208262, + // "turnover":10298630.3735, + // "turnover_symbol":"USDT", + // "turnover_usd":10298630.3735, + // "volume":640.5520000000001 + // } + // + const timestamp = this.safeIntegerProduct (ticker, 'timestamp', 0.001); + const marketId = this.safeString (ticker, 'symbol'); + const symbol = this.safeSymbol (marketId, market); + const last = this.safeFloat (ticker, 'close'); + const open = this.safeFloat (ticker, 'open'); + let change = undefined; + let average = undefined; + let percentage = undefined; + if ((open !== undefined) && (last !== undefined)) { + change = last - open; + average = this.sum (last, open) / 2; + if (open !== 0.0) { + percentage = (change / open) * 100; + } + } + const baseVolume = this.safeFloat (ticker, 'volume'); + const quoteVolume = this.safeFloat (ticker, 'turnover'); + const vwap = this.vwap (baseVolume, quoteVolume); + return { + 'symbol': symbol, + 'timestamp': timestamp, + 'datetime': this.iso8601 (timestamp), + 'high': this.safeFloat (ticker, 'high'), + 'low': this.safeFloat (ticker, 'low'), + 'bid': undefined, + 'bidVolume': undefined, + 'ask': undefined, + 'askVolume': undefined, + 'vwap': vwap, + 'open': open, + 'close': last, + 'last': last, + 'previousClose': undefined, + 'change': change, + 'percentage': percentage, + 'average': average, + 'baseVolume': baseVolume, + 'quoteVolume': quoteVolume, + 'info': ticker, + }; + } + + async fetchTicker (symbol, params = {}) { + await this.loadMarkets (); + const market = this.market (symbol); + const request = { + 'symbol': market['id'], + }; + const response = await this.publicGetTickersSymbol (this.extend (request, params)); + // + // { + // "result":{ + // "close":15837.5, + // "high":16354, + // "low":15751.5, + // "mark_price":"15820.100867", + // "open":16140.5, + // "product_id":139, + // "size":640552, + // "spot_price":"15827.050000000001", + // "symbol":"BTCUSDT", + // "timestamp":1605373550208262, + // "turnover":10298630.3735, + // "turnover_symbol":"USDT", + // "turnover_usd":10298630.3735, + // "volume":640.5520000000001 + // }, + // "success":true + // } + // + const result = this.safeValue (response, 'result', {}); + return this.parseTicker (result, market); + } + + async fetchTickers (symbols = undefined, params = {}) { + await this.loadMarkets (); + const response = await this.publicGetTickers (params); + // + // { + // "result":[ + // { + // "close":0.003966, + // "high":0.004032, + // "low":0.003606, + // "mark_price":"0.00396328", + // "open":0.003996, + // "product_id":1327, + // "size":6242, + // "spot_price":"0.0039555", + // "symbol":"AAVEBTC", + // "timestamp":1605374143864107, + // "turnover":23.997904999999996, + // "turnover_symbol":"BTC", + // "turnover_usd":387957.4544782897, + // "volume":6242 + // }, + // ], + // "success":true + // } + // + const tickers = this.safeValue (response, 'result', []); + const result = {}; + for (let i = 0; i < tickers.length; i++) { + const ticker = this.parseTicker (tickers[i]); + const symbol = ticker['symbol']; + result[symbol] = ticker; + } + return this.filterByArray (result, 'symbol', symbols); + } + + async fetchOrderBook (symbol, limit = undefined, params = {}) { + await this.loadMarkets (); + const request = { + 'symbol': this.marketId (symbol), + }; + if (limit !== undefined) { + request['depth'] = limit; + } + const response = await this.publicGetL2orderbookSymbol (this.extend (request, params)); + // + // { + // "result":{ + // "buy":[ + // {"price":"15814.0","size":912}, + // {"price":"15813.5","size":1279}, + // {"price":"15813.0","size":1634}, + // ], + // "sell":[ + // {"price":"15814.5","size":625}, + // {"price":"15815.0","size":982}, + // {"price":"15815.5","size":1328}, + // ], + // "symbol":"BTCUSDT" + // }, + // "success":true + // } + // + const result = this.safeValue (response, 'result', {}); + return this.parseOrderBook (result, undefined, 'buy', 'sell', 'price', 'size'); + } + + parseTrade (trade, market = undefined) { + // + // public fetchTrades + // + // { + // "buyer_role":"maker", + // "price":"15896.5", + // "seller_role":"taker", + // "size":241, + // "symbol":"BTCUSDT", + // "timestamp":1605376684714595 + // } + // + // private fetchMyTrades + // + // { + // "commission":"0.008335000000000000", + // "created_at":"2020-11-16T19:07:19Z", + // "fill_type":"normal", + // "id":"e7ff05c233a74245b72381f8dd91d1ce", + // "meta_data":{ + // "effective_commission_rate":"0.0005", + // "order_price":"16249", + // "order_size":1, + // "order_type":"market_order", + // "order_unfilled_size":0, + // "trading_fee_credits_used":"0" + // }, + // "order_id":"152999629", + // "price":"16669", + // "product":{ + // "contract_type":"perpetual_futures", + // "contract_unit_currency":"BTC", + // "contract_value":"0.001", + // "id":139, + // "notional_type":"vanilla", + // "quoting_asset":{"minimum_precision":2,"precision":6,"symbol":"USDT"}, + // "settling_asset":{"minimum_precision":2,"precision":6,"symbol":"USDT"}, + // "symbol":"BTCUSDT", + // "tick_size":"0.5", + // "underlying_asset":{"minimum_precision":4,"precision":8,"symbol":"BTC"} + // }, + // "product_id":139, + // "role":"taker", + // "side":"sell", + // "size":1 + // } + // + const id = this.safeString (trade, 'id'); + const orderId = this.safeString (trade, 'order_id'); + let timestamp = this.parse8601 (this.safeString (trade, 'created_at')); + timestamp = this.safeIntegerProduct (trade, 'timestamp', 0.001, timestamp); + const price = this.safeFloat (trade, 'price'); + const amount = this.safeFloat (trade, 'size'); + let cost = undefined; + if ((amount !== undefined) && (price !== undefined)) { + cost = amount * price; + } + const product = this.safeValue (trade, 'product', {}); + const marketId = this.safeString (product, 'symbol'); + const symbol = this.safeSymbol (marketId, market); + const sellerRole = this.safeString (trade, 'seller_role'); + let side = this.safeString (trade, 'side'); + if (side === undefined) { + if (sellerRole === 'taker') { + side = 'sell'; + } else if (sellerRole === 'maker') { + side = 'buy'; + } + } + const takerOrMaker = this.safeString (trade, 'role'); + const metaData = this.safeValue (trade, 'meta_data', {}); + let type = this.safeString (metaData, 'order_type'); + if (type !== undefined) { + type = type.replace ('_order', ''); + } + const feeCost = this.safeFloat (trade, 'commission'); + let fee = undefined; + if (feeCost !== undefined) { + const settlingAsset = this.safeValue (product, 'settling_asset', {}); + const feeCurrencyId = this.safeString (settlingAsset, 'symbol'); + const feeCurrencyCode = this.safeCurrencyCode (feeCurrencyId); + fee = { + 'cost': feeCost, + 'currency': feeCurrencyCode, + }; + } + return { + 'id': id, + 'order': orderId, + 'timestamp': timestamp, + 'datetime': this.iso8601 (timestamp), + 'symbol': symbol, + 'type': type, + 'side': side, + 'price': price, + 'amount': amount, + 'cost': cost, + 'takerOrMaker': takerOrMaker, + 'fee': fee, + 'info': trade, + }; + } + + async fetchTrades (symbol, since = undefined, limit = undefined, params = {}) { + await this.loadMarkets (); + const market = this.market (symbol); + const request = { + 'symbol': market['id'], + }; + const response = await this.publicGetTradesSymbol (this.extend (request, params)); + // + // { + // "result":[ + // { + // "buyer_role":"maker", + // "price":"15896.5", + // "seller_role":"taker", + // "size":241, + // "symbol":"BTCUSDT", + // "timestamp":1605376684714595 + // } + // ], + // "success":true + // } + // + const result = this.safeValue (response, 'result', []); + return this.parseTrades (result, market, since, limit); + } + + parseOHLCV (ohlcv, market = undefined) { + // + // { + // "time":1605393120, + // "open":15989, + // "high":15989, + // "low":15987.5, + // "close":15987.5, + // "volume":565 + // } + // + return [ + this.safeTimestamp (ohlcv, 'time'), + this.safeFloat (ohlcv, 'open'), + this.safeFloat (ohlcv, 'high'), + this.safeFloat (ohlcv, 'low'), + this.safeFloat (ohlcv, 'close'), + this.safeFloat (ohlcv, 'volume'), + ]; + } + + async fetchOHLCV (symbol, timeframe = '1m', since = undefined, limit = undefined, params = {}) { + await this.loadMarkets (); + const market = this.market (symbol); + const request = { + 'symbol': market['id'], + 'resolution': this.timeframes[timeframe], + }; + const duration = this.parseTimeframe (timeframe); + limit = limit ? limit : 2000; // max 2000 + if (since === undefined) { + const end = this.seconds (); + request['end'] = end; + request['start'] = end - limit * duration; + } else { + const start = parseInt (since / 1000); + request['start'] = start; + request['end'] = this.sum (start, limit * duration); + } + const response = await this.publicGetHistoryCandles (this.extend (request, params)); + // + // { + // "success":true, + // "result":[ + // {"time":1605393120,"open":15989,"high":15989,"low":15987.5,"close":15987.5,"volume":565}, + // {"time":1605393180,"open":15966,"high":15966,"low":15959,"close":15959,"volume":24}, + // {"time":1605393300,"open":15973,"high":15973,"low":15973,"close":15973,"volume":1288}, + // ] + // } + // + const result = this.safeValue (response, 'result', []); + return this.parseOHLCVs (result, market, timeframe, since, limit); + } + + async fetchBalance (params = {}) { + await this.loadMarkets (); + const response = await this.privateGetWalletBalances (params); + // + // { + // "result":[ + // { + // "asset_id":1, + // "available_balance":"0", + // "balance":"0", + // "commission":"0", + // "id":154883, + // "interest_credit":"0", + // "order_margin":"0", + // "pending_referral_bonus":"0", + // "pending_trading_fee_credit":"0", + // "position_margin":"0", + // "trading_fee_credit":"0", + // "user_id":22142 + // }, + // ], + // "success":true + // } + // + const balances = this.safeValue (response, 'result', []); + const result = { 'info': response }; + const currenciesByNumericId = this.safeValue (this.options, 'currenciesByNumericId', {}); + for (let i = 0; i < balances.length; i++) { + const balance = balances[i]; + const currencyId = this.safeString (balance, 'asset_id'); + const currency = this.safeValue (currenciesByNumericId, currencyId); + const code = (currency === undefined) ? currencyId : currency['code']; + const account = this.account (); + account['total'] = this.safeFloat (balance, 'balance'); + account['free'] = this.safeFloat (balance, 'available_balance'); + result[code] = account; + } + return this.parseBalance (result); + } + + async fetchPosition (symbol, params = undefined) { + await this.loadMarkets (); + const market = this.market (symbol); + const request = { + 'product_id': market['numericId'], + }; + const response = await this.privateGetPositions (this.extend (request, params)); + // + // { + // "result":{ + // "entry_price":null, + // "size":0, + // "timestamp":1605454074268079 + // }, + // "success":true + // } + // + const result = this.safeValue (response, 'result', {}); + return result; + } + + async fetchPositions (symbols = undefined, since = undefined, limit = undefined, params = {}) { + await this.loadMarkets (); + const response = await this.privateGetPositionsMargined (params); + // + // { + // "success": true, + // "result": [ + // { + // "user_id": 0, + // "size": 0, + // "entry_price": "string", + // "margin": "string", + // "liquidation_price": "string", + // "bankruptcy_price": "string", + // "adl_level": 0, + // "product_id": 0 + // } + // ] + // } + // + const result = this.safeValue (response, 'result', []); + return result; + } + + parseOrderStatus (status) { + const statuses = { + 'open': 'open', + 'pending': 'open', + 'closed': 'closed', + 'cancelled': 'canceled', + }; + return this.safeString (statuses, status, status); + } + + parseOrder (order, market = undefined) { + // + // createOrder, cancelOrder, editOrder, fetchOpenOrders, fetchClosedOrders + // + // { + // "average_fill_price":null, + // "bracket_order":null, + // "bracket_stop_loss_limit_price":null, + // "bracket_stop_loss_price":null, + // "bracket_take_profit_limit_price":null, + // "bracket_take_profit_price":null, + // "bracket_trail_amount":null, + // "cancellation_reason":null, + // "client_order_id":null, + // "close_on_trigger":"false", + // "commission":"0", + // "created_at":"2020-11-16T02:38:26Z", + // "id":152870626, + // "limit_price":"10000", + // "meta_data":{"source":"api"}, + // "order_type":"limit_order", + // "paid_commission":"0", + // "product_id":139, + // "reduce_only":false, + // "side":"buy", + // "size":0, + // "state":"open", + // "stop_order_type":null, + // "stop_price":null, + // "stop_trigger_method":"mark_price", + // "time_in_force":"gtc", + // "trail_amount":null, + // "unfilled_size":0, + // "user_id":22142 + // } + // + const id = this.safeString (order, 'id'); + const clientOrderId = this.safeString (order, 'client_order_id'); + const timestamp = this.parse8601 (this.safeString (order, 'created_at')); + const marketId = this.safeString (order, 'product_id'); + const marketsByNumericId = this.safeValue (this.options, 'marketsByNumericId', {}); + market = this.safeValue (marketsByNumericId, marketId, market); + const symbol = (market === undefined) ? marketId : market['symbol']; + const status = this.parseOrderStatus (this.safeString (order, 'state')); + const side = this.safeString (order, 'side'); + let type = this.safeString (order, 'order_type'); + type = type.replace ('_order', ''); + const price = this.safeFloat (order, 'limit_price'); + const amount = this.safeFloat (order, 'size'); + const remaining = this.safeFloat (order, 'unfilled_size'); + let filled = undefined; + if ((amount !== undefined) && (remaining !== undefined)) { + filled = Math.max (0, amount - remaining); + } + let cost = undefined; + const average = this.safeFloat (order, 'average_fill_price'); + if ((average !== undefined) && filled) { + cost = average * filled; + } + let fee = undefined; + const feeCost = this.safeFloat (order, 'paid_commission'); + if (feeCost !== undefined) { + let feeCurrencyCode = undefined; + if (market !== undefined) { + const settlingAsset = this.safeValue (market['info'], 'settling_asset', {}); + const feeCurrencyId = this.safeString (settlingAsset, 'symbol'); + feeCurrencyCode = this.safeCurrencyCode (feeCurrencyId); + } + fee = { + 'cost': feeCost, + 'currency': feeCurrencyCode, + }; + } + return { + 'info': order, + 'id': id, + 'clientOrderId': clientOrderId, + 'timestamp': timestamp, + 'datetime': this.iso8601 (timestamp), + 'lastTradeTimestamp': undefined, + 'symbol': symbol, + 'type': type, + 'side': side, + 'price': price, + 'amount': amount, + 'cost': cost, + 'average': average, + 'filled': filled, + 'remaining': remaining, + 'status': status, + 'fee': fee, + 'trades': undefined, + }; + } + + async createOrder (symbol, type, side, amount, price = undefined, params = {}) { + await this.loadMarkets (); + const orderType = type + '_order'; + const market = this.market (symbol); + const request = { + 'product_id': market['numericId'], + // 'limit_price': this.priceToPrecision (symbol, price), + 'size': this.amountToPrecision (symbol, amount), + 'side': side, + 'order_type': orderType, + // 'client_order_id': 'string', + // 'time_in_force': 'gtc', // gtc, ioc, fok + // 'post_only': 'false', // 'true', + // 'reduce_only': 'false', // 'true', + }; + if (type === 'limit') { + request['limit_price'] = this.priceToPrecision (symbol, price); + } + const clientOrderId = this.safeString2 (params, 'clientOrderId', 'client_order_id'); + params = this.omit (params, [ 'clientOrderId', 'client_order_id' ]); + if (clientOrderId !== undefined) { + request['client_order_id'] = clientOrderId; + } + const response = await this.privatePostOrders (this.extend (request, params)); + // + // { + // "result":{ + // "average_fill_price":null, + // "bracket_order":null, + // "bracket_stop_loss_limit_price":null, + // "bracket_stop_loss_price":null, + // "bracket_take_profit_limit_price":null, + // "bracket_take_profit_price":null, + // "bracket_trail_amount":null, + // "cancellation_reason":null, + // "client_order_id":null, + // "close_on_trigger":"false", + // "commission":"0", + // "created_at":"2020-11-16T02:38:26Z", + // "id":152870626, + // "limit_price":"10000", + // "meta_data":{"source":"api"}, + // "order_type":"limit_order", + // "paid_commission":"0", + // "product_id":139, + // "reduce_only":false, + // "side":"buy", + // "size":0, + // "state":"open", + // "stop_order_type":null, + // "stop_price":null, + // "stop_trigger_method":"mark_price", + // "time_in_force":"gtc", + // "trail_amount":null, + // "unfilled_size":0, + // "user_id":22142 + // }, + // "success":true + // } + // + const result = this.safeValue (response, 'result', {}); + return this.parseOrder (result, market); + } + + async editOrder (id, symbol, type, side, amount, price = undefined, params = {}) { + await this.loadMarkets (); + const market = this.market (symbol); + const request = { + 'id': parseInt (id), + 'product_id': market['numericId'], + // 'limit_price': this.priceToPrecision (symbol, price), + // 'size': this.amountToPrecision (symbol, amount), + }; + if (amount !== undefined) { + request['size'] = parseInt (this.amountToPrecision (symbol, amount)); + } + if (price !== undefined) { + request['limit_price'] = this.priceToPrecision (symbol, price); + } + const response = await this.privatePutOrders (this.extend (request, params)); + // + // { + // "success": true, + // "result": { + // "id": "ashb1212", + // "product_id": 27, + // "limit_price": "9200", + // "side": "buy", + // "size": 100, + // "unfilled_size": 50, + // "user_id": 1, + // "order_type": "limit_order", + // "state": "open", + // "created_at": "..." + // } + // } + // + const result = this.safeValue (response, 'result'); + return this.parseOrder (result, market); + } + + async cancelOrder (id, symbol = undefined, params = {}) { + if (symbol === undefined) { + throw new ArgumentsRequired (this.id + ' cancelOrder() requires a symbol argument'); + } + await this.loadMarkets (); + const market = this.market (symbol); + const request = { + 'id': parseInt (id), + 'product_id': market['numericId'], + }; + const response = await this.privateDeleteOrders (this.extend (request, params)); + // + // { + // "result":{ + // "average_fill_price":null, + // "bracket_order":null, + // "bracket_stop_loss_limit_price":null, + // "bracket_stop_loss_price":null, + // "bracket_take_profit_limit_price":null, + // "bracket_take_profit_price":null, + // "bracket_trail_amount":null, + // "cancellation_reason":"cancelled_by_user", + // "client_order_id":null, + // "close_on_trigger":"false", + // "commission":"0", + // "created_at":"2020-11-16T02:38:26Z", + // "id":152870626, + // "limit_price":"10000", + // "meta_data":{"source":"api"}, + // "order_type":"limit_order", + // "paid_commission":"0", + // "product_id":139, + // "reduce_only":false, + // "side":"buy", + // "size":0, + // "state":"cancelled", + // "stop_order_type":null, + // "stop_price":null, + // "stop_trigger_method":"mark_price", + // "time_in_force":"gtc", + // "trail_amount":null, + // "unfilled_size":0, + // "user_id":22142 + // }, + // "success":true + // } + // + const result = this.safeValue (response, 'result'); + return this.parseOrder (result, market); + } + + async cancelAllOrders (symbol = undefined, params = {}) { + if (symbol === undefined) { + throw new ArgumentsRequired (this.id + ' cancelAllOrders() requires a symbol argument'); + } + await this.loadMarkets (); + const market = this.market (symbol); + const request = { + 'product_id': market['numericId'], + // 'cancel_limit_orders': 'true', + // 'cancel_stop_orders': 'true', + }; + const response = this.privateDeleteOrdersAll (this.extend (request, params)); + // + // { + // "result":{}, + // "success":true + // } + // + return response; + } + + async fetchOpenOrders (symbol = undefined, since = undefined, limit = undefined, params = {}) { + return await this.fetchOrdersWithMethod ('privateGetOrders', symbol, since, limit, params); + } + + async fetchClosedOrders (symbol = undefined, since = undefined, limit = undefined, params = {}) { + return await this.fetchOrdersWithMethod ('privateGetOrdersHistory', symbol, since, limit, params); + } + + async fetchOrdersWithMethod (method, symbol = undefined, since = undefined, limit = undefined, params = {}) { + await this.loadMarkets (); + const request = { + // 'product_ids': market['id'], // comma-separated + // 'contract_types': types, // comma-separated, futures, perpetual_futures, call_options, put_options, interest_rate_swaps, move_options, spreads + // 'order_types': types, // comma-separated, market, limit, stop_market, stop_limit, all_stop + // 'start_time': since * 1000, + // 'end_time': this.microseconds (), + // 'after': string, // after cursor for pagination + // 'before': string, // before cursor for pagination + // 'page_size': limit, // number of records per page + }; + let market = undefined; + if (symbol !== undefined) { + market = this.market (symbol); + request['product_ids'] = market['numericId']; // accepts a comma-separated list of ids + } + if (since !== undefined) { + request['start_time'] = since.toString () + '000'; + } + if (limit !== undefined) { + request['page_size'] = limit; + } + const response = await this[method] (this.extend (request, params)); + // + // { + // "success": true, + // "result": [ + // { + // "id": "ashb1212", + // "product_id": 27, + // "limit_price": "9200", + // "side": "buy", + // "size": 100, + // "unfilled_size": 50, + // "user_id": 1, + // "order_type": "limit_order", + // "state": "open", + // "created_at": "..." + // } + // ], + // "meta": { + // "after": "string", + // "before": "string" + // } + // } + // + const result = this.safeValue (response, 'result', []); + return this.parseOrders (result, market, since, limit); + } + + async fetchMyTrades (symbol = undefined, since = undefined, limit = undefined, params = {}) { + await this.loadMarkets (); + const request = { + // 'product_ids': market['id'], // comma-separated + // 'contract_types': types, // comma-separated, futures, perpetual_futures, call_options, put_options, interest_rate_swaps, move_options, spreads + // 'start_time': since * 1000, + // 'end_time': this.microseconds (), + // 'after': string, // after cursor for pagination + // 'before': string, // before cursor for pagination + // 'page_size': limit, // number of records per page + }; + let market = undefined; + if (symbol !== undefined) { + market = this.market (symbol); + request['product_ids'] = market['numericId']; // accepts a comma-separated list of ids + } + if (since !== undefined) { + request['start_time'] = since.toString () + '000'; + } + if (limit !== undefined) { + request['page_size'] = limit; + } + const response = await this.privateGetFills (this.extend (request, params)); + // + // { + // "meta":{ + // "after":null, + // "before":null, + // "limit":10, + // "total_count":2 + // }, + // "result":[ + // { + // "commission":"0.008335000000000000", + // "created_at":"2020-11-16T19:07:19Z", + // "fill_type":"normal", + // "id":"e7ff05c233a74245b72381f8dd91d1ce", + // "meta_data":{ + // "effective_commission_rate":"0.0005", + // "order_price":"16249", + // "order_size":1, + // "order_type":"market_order", + // "order_unfilled_size":0, + // "trading_fee_credits_used":"0" + // }, + // "order_id":"152999629", + // "price":"16669", + // "product":{ + // "contract_type":"perpetual_futures", + // "contract_unit_currency":"BTC", + // "contract_value":"0.001", + // "id":139, + // "notional_type":"vanilla", + // "quoting_asset":{"minimum_precision":2,"precision":6,"symbol":"USDT"}, + // "settling_asset":{"minimum_precision":2,"precision":6,"symbol":"USDT"}, + // "symbol":"BTCUSDT", + // "tick_size":"0.5", + // "underlying_asset":{"minimum_precision":4,"precision":8,"symbol":"BTC"} + // }, + // "product_id":139, + // "role":"taker", + // "side":"sell", + // "size":1 + // } + // ], + // "success":true + // } + // + const result = this.safeValue (response, 'result', []); + return this.parseTrades (result, market, since, limit); + } + + async fetchLedger (code = undefined, since = undefined, limit = undefined, params = {}) { + await this.loadMarkets (); + const request = { + // 'asset_id': currency['numericId'], + // 'end_time': this.seconds (), + // 'after': 'string', // after cursor for pagination + // 'before': 'string', // before cursor for pagination + // 'page_size': limit, + }; + let currency = undefined; + if (code !== undefined) { + currency = this.currency (code); + request['asset_id'] = currency['numericId']; + } + if (limit !== undefined) { + request['page_size'] = limit; + } + const response = await this.privateGetWalletTransactions (this.extend (request, params)); + // + // { + // "meta":{"after":null,"before":null,"limit":10,"total_count":1}, + // "result":[ + // { + // "amount":"29.889184", + // "asset_id":5, + // "balance":"29.889184", + // "created_at":"2020-11-15T21:25:01Z", + // "meta_data":{ + // "deposit_id":3884, + // "transaction_id":"0x41a60174849828530abb5008e98fc63c9b598288743ec4ba9620bcce900a3b8d" + // }, + // "transaction_type":"deposit", + // "user_id":22142, + // "uuid":"70bb5679da3c4637884e2dc63efaa846" + // } + // ], + // "success":true + // } + // + const result = this.safeValue (response, 'result', []); + return this.parseLedger (result, currency, since, limit); + } + + parseLedgerEntryType (type) { + const types = { + 'pnl': 'pnl', + 'deposit': 'transaction', + 'withdrawal': 'transaction', + 'commission': 'fee', + 'conversion': 'trade', + // 'perpetual_futures_funding': 'perpetual_futures_funding', + // 'withdrawal_cancellation': 'withdrawal_cancellation', + 'referral_bonus': 'referral', + 'commission_rebate': 'rebate', + // 'promo_credit': 'promo_credit', + }; + return this.safeString (types, type, type); + } + + parseLedgerEntry (item, currency = undefined) { + // + // { + // "amount":"29.889184", + // "asset_id":5, + // "balance":"29.889184", + // "created_at":"2020-11-15T21:25:01Z", + // "meta_data":{ + // "deposit_id":3884, + // "transaction_id":"0x41a60174849828530abb5008e98fc63c9b598288743ec4ba9620bcce900a3b8d" + // }, + // "transaction_type":"deposit", + // "user_id":22142, + // "uuid":"70bb5679da3c4637884e2dc63efaa846" + // } + // + const id = this.safeString (item, 'uuid'); + let direction = undefined; + const account = undefined; + const metaData = this.safeValue (item, 'meta_data', {}); + const referenceId = this.safeString (metaData, 'transaction_id'); + const referenceAccount = undefined; + let type = this.safeString (item, 'transaction_type'); + if ((type === 'deposit') || (type === 'commission_rebate') || (type === 'referral_bonus') || (type === 'pnl') || (type === 'withdrawal_cancellation') || (type === 'promo_credit')) { + direction = 'in'; + } else if ((type === 'withdrawal') || (type === 'commission') || (type === 'conversion') || (type === 'perpetual_futures_funding')) { + direction = 'out'; + } + type = this.parseLedgerEntryType (type); + const currencyId = this.safeInteger (item, 'asset_id'); + const currenciesByNumericId = this.safeValue (this.options, 'currenciesByNumericId'); + currency = this.safeValue (currenciesByNumericId, currencyId, currency); + const code = (currency === undefined) ? undefined : currency['code']; + const amount = this.safeFloat (item, 'amount'); + const timestamp = this.parse8601 (this.safeString (item, 'created_at')); + const after = this.safeFloat (item, 'balance'); + const before = Math.max (0, after - amount); + const status = 'ok'; + return { + 'info': item, + 'id': id, + 'direction': direction, + 'account': account, + 'referenceId': referenceId, + 'referenceAccount': referenceAccount, + 'type': type, + 'currency': code, + 'amount': amount, + 'before': before, + 'after': after, + 'status': status, + 'timestamp': timestamp, + 'datetime': this.iso8601 (timestamp), + 'fee': undefined, + }; + } + + async fetchDepositAddress (code, params = {}) { + await this.loadMarkets (); + const currency = this.currency (code); + const request = { + 'asset_symbol': currency['id'], + }; + const response = await this.privateGetDepositsAddress (this.extend (request, params)); + // + // { + // "success":true, + // "result":{ + // "id":19628, + // "user_id":22142, + // "address":"0x0eda26523397534f814d553a065d8e46b4188e9a", + // "status":"active", + // "updated_at":"2020-11-15T20:25:53.000Z", + // "created_at":"2020-11-15T20:25:53.000Z", + // "asset_symbol":"USDT", + // "custodian":"onc" + // } + // } + // + const result = this.safeValue (response, 'result', {}); + const address = this.safeString (result, 'address'); + this.checkAddress (address); + return { + 'currency': code, + 'address': address, + 'tag': undefined, + 'info': response, + }; + } + + sign (path, api = 'public', method = 'GET', params = {}, headers = undefined, body = undefined) { + const requestPath = '/' + this.version + '/' + this.implodeParams (path, params); + let url = this.urls['api'][api] + requestPath; + const query = this.omit (params, this.extractParams (path)); + if (api === 'public') { + if (Object.keys (query).length) { + url += '?' + this.urlencode (query); + } + } else if (api === 'private') { + this.checkRequiredCredentials (); + const timestamp = this.seconds ().toString (); + headers = { + 'api-key': this.apiKey, + 'timestamp': timestamp, + }; + let auth = method + timestamp + requestPath; + if ((method === 'GET') || (method === 'DELETE')) { + if (Object.keys (query).length) { + const queryString = '?' + this.urlencode (query); + auth += queryString; + url += queryString; + } + } else { + body = this.json (query); + auth += body; + headers['Content-Type'] = 'application/json'; + } + const signature = this.hmac (this.encode (auth), this.encode (this.secret)); + headers['signature'] = signature; + } + return { 'url': url, 'method': method, 'body': body, 'headers': headers }; + } + + handleErrors (code, reason, url, method, headers, body, response, requestHeaders, requestBody) { + if (response === undefined) { + return; + } + // + // {"error":{"code":"insufficient_margin","context":{"available_balance":"0.000000000000000000","required_additional_balance":"1.618626000000000000000000000"}},"success":false} + // + const error = this.safeValue (response, 'error', {}); + const errorCode = this.safeString (error, 'code'); + if (errorCode !== undefined) { + const feedback = this.id + ' ' + body; + this.throwExactlyMatchedException (this.exceptions['exact'], errorCode, feedback); + this.throwBroadlyMatchedException (this.exceptions['broad'], errorCode, feedback); + throw new ExchangeError (feedback); // unknown message + } + } +}; + +},{"./base/Exchange":6,"./base/errors":8,"./base/functions/number":14}],77:[function(require,module,exports){ 'use strict'; // --------------------------------------------------------------------------- @@ -57087,7 +60736,7 @@ module.exports = class deribit extends Exchange { const now = this.milliseconds (); if (since === undefined) { if (limit === undefined) { - throw new ArgumentsRequired (this.id + ' fetchOHLCV requires a since argument or a limit argument'); + throw new ArgumentsRequired (this.id + ' fetchOHLCV() requires a since argument or a limit argument'); } else { request['start_timestamp'] = now - (limit - 1) * duration * 1000; request['end_timestamp'] = now; @@ -57320,7 +60969,7 @@ module.exports = class deribit extends Exchange { 'cancelled': 'canceled', 'filled': 'closed', 'rejected': 'rejected', - // 'untriggered': 'open', + 'untriggered': 'open', }; return this.safeString (statuses, status, status); } @@ -57405,7 +61054,8 @@ module.exports = class deribit extends Exchange { trades = this.parseTrades (trades, market); } const timeInForce = this.parseTimeInForce (this.safeString (order, 'time_in_force')); - const stopPrice = undefined; + const stopPrice = this.safeValue (order, 'stop_price'); + const postOnly = this.safeValue (order, 'post_only'); return { 'info': order, 'id': id, @@ -57416,6 +61066,7 @@ module.exports = class deribit extends Exchange { 'symbol': market['symbol'], 'type': type, 'timeInForce': timeInForce, + 'postOnly': postOnly, 'side': side, 'price': price, 'stopPrice': stopPrice, @@ -57500,13 +61151,13 @@ module.exports = class deribit extends Exchange { if (price !== undefined) { request['price'] = this.priceToPrecision (symbol, price); } else { - throw new ArgumentsRequired (this.id + ' createOrder requires a price argument for a ' + type + ' order'); + throw new ArgumentsRequired (this.id + ' createOrder() requires a price argument for a ' + type + ' order'); } } if (stopPriceIsRequired) { const stopPrice = this.safeFloat2 (params, 'stop_price', 'stopPrice'); if (stopPrice === undefined) { - throw new ArgumentsRequired (this.id + ' createOrder requires a stop_price or stopPrice param for a ' + type + ' order'); + throw new ArgumentsRequired (this.id + ' createOrder() requires a stop_price or stopPrice param for a ' + type + ' order'); } else { request['stop_price'] = this.priceToPrecision (symbol, stopPrice); } @@ -57575,10 +61226,10 @@ module.exports = class deribit extends Exchange { async editOrder (id, symbol, type, side, amount = undefined, price = undefined, params = {}) { if (amount === undefined) { - throw new ArgumentsRequired (this.id + ' editOrder requires an amount argument'); + throw new ArgumentsRequired (this.id + ' editOrder() requires an amount argument'); } if (price === undefined) { - throw new ArgumentsRequired (this.id + ' editOrder requires a price argument'); + throw new ArgumentsRequired (this.id + ' editOrder() requires a price argument'); } await this.loadMarkets (); const request = { @@ -57940,7 +61591,7 @@ module.exports = class deribit extends Exchange { const request = { 'instrument_name': market['id'], }; - const response = await this.privateGetPosition (this.extend (request, params)); + const response = await this.privateGetGetPosition (this.extend (request, params)); // // { // "jsonrpc": "2.0", @@ -57979,7 +61630,7 @@ module.exports = class deribit extends Exchange { const request = { 'currency': currency['id'], }; - const response = await this.privateGetPositions (this.extend (request, params)); + const response = await this.privateGetGetPositions (this.extend (request, params)); // // { // "jsonrpc": "2.0", @@ -58093,7 +61744,7 @@ module.exports = class deribit extends Exchange { } }; -},{"./base/Exchange":5,"./base/errors":7,"./base/functions/number":13}],76:[function(require,module,exports){ +},{"./base/Exchange":6,"./base/errors":8,"./base/functions/number":14}],78:[function(require,module,exports){ 'use strict'; // --------------------------------------------------------------------------- @@ -58598,7 +62249,7 @@ module.exports = class digifinex extends Exchange { async fetchTickers (symbols = undefined, params = {}) { const apiKey = this.safeValue (params, 'apiKey', this.apiKey); if (!apiKey) { - throw new ArgumentsRequired (this.id + ' fetchTicker is a private v2 endpoint that requires an `exchange.apiKey` credential or an `apiKey` extra parameter'); + throw new ArgumentsRequired (this.id + ' fetchTickers() is a private v2 endpoint that requires an `exchange.apiKey` credential or an `apiKey` extra parameter'); } await this.loadMarkets (); const request = { @@ -58644,7 +62295,7 @@ module.exports = class digifinex extends Exchange { async fetchTicker (symbol, params = {}) { const apiKey = this.safeValue (params, 'apiKey', this.apiKey); if (!apiKey) { - throw new ArgumentsRequired (this.id + ' fetchTicker is a private v2 endpoint that requires an `exchange.apiKey` credential or an `apiKey` extra parameter'); + throw new ArgumentsRequired (this.id + ' fetchTicker() is a private v2 endpoint that requires an `exchange.apiKey` credential or an `apiKey` extra parameter'); } await this.loadMarkets (); const market = this.market (symbol); @@ -59090,6 +62741,7 @@ module.exports = class digifinex extends Exchange { 'symbol': symbol, 'type': type, 'timeInForce': undefined, + 'postOnly': undefined, 'side': side, 'price': price, 'stopPrice': undefined, @@ -59380,7 +63032,7 @@ module.exports = class digifinex extends Exchange { const address = this.safeString (depositAddress, 'address'); const tag = this.safeString (depositAddress, 'addressTag'); const currencyId = this.safeStringUpper (depositAddress, 'currency'); - const code = this.safeCurrencCode (currencyId); + const code = this.safeCurrencyCode (currencyId); return { 'info': depositAddress, 'code': code, @@ -59623,7 +63275,7 @@ module.exports = class digifinex extends Exchange { } }; -},{"./base/Exchange":5,"./base/errors":7}],77:[function(require,module,exports){ +},{"./base/Exchange":6,"./base/errors":8}],79:[function(require,module,exports){ 'use strict'; // --------------------------------------------------------------------------- @@ -60279,7 +63931,7 @@ module.exports = class dsx extends Exchange { await this.loadMarkets (); const market = this.market (symbol); if (type === 'market' && price === undefined) { - throw new ArgumentsRequired (this.id + ' createOrder requires a price argument even for market orders, that is the worst price that you agree to fill your order for'); + throw new ArgumentsRequired (this.id + ' createOrder() requires a price argument even for market orders, that is the worst price that you agree to fill your order for'); } const request = { 'pair': market['id'], @@ -60466,6 +64118,7 @@ module.exports = class dsx extends Exchange { 'lastTradeTimestamp': lastTradeTimestamp, 'type': orderType, 'timeInForce': undefined, + 'postOnly': undefined, 'side': side, 'price': price, 'stopPrice': undefined, @@ -60898,7 +64551,1557 @@ module.exports = class dsx extends Exchange { } }; -},{"./base/Exchange":5,"./base/errors":7}],78:[function(require,module,exports){ +},{"./base/Exchange":6,"./base/errors":8}],80:[function(require,module,exports){ +'use strict'; + +// ---------------------------------------------------------------------------- + +const Exchange = require ('./base/Exchange'); +const { ExchangeError, ArgumentsRequired, BadSymbol } = require ('./base/errors'); + +// ---------------------------------------------------------------------------- + +module.exports = class equos extends Exchange { + describe () { + return this.deepExtend (super.describe (), { + 'id': 'equos', + 'name': 'EQUOS', + 'countries': [ 'US', 'SG' ], // United States, Singapore + 'rateLimit': 10, + 'has': { + 'CORS': false, + 'cancelOrder': true, + 'createOrder': true, + 'editOrder': true, + 'fetchBalance': true, + 'fetchCanceledOrders': true, + 'fetchClosedOrders': true, + 'fetchCurrencies': true, + 'fetchDepositAddress': true, + 'fetchDeposits': true, + 'fetchMarkets': true, + 'fetchMyTrades': true, + 'fetchOHLCV': true, + 'fetchOrder': true, + 'fetchOrderBook': true, + 'fetchOrders': true, + 'fetchTicker': false, + 'fetchTrades': true, + 'fetchTradingFees': true, + 'fetchWithdrawals': true, + 'withdraw': true, + }, + 'timeframes': { + '1m': 1, + '5m': 2, + '15m': 3, + '1h': 4, + '6h': 5, + '1d': 6, + '7d': 7, + }, + 'urls': { + 'logo': 'https://user-images.githubusercontent.com/1294454/107758499-05edd180-6d38-11eb-9e09-0b69602a7a15.jpg', + 'test': { + 'public': 'https://testnet.equos.io/api', + 'private': 'https://testnet.equos.io/api', + }, + 'api': { + 'public': 'https://equos.io/api', + 'private': 'https://equos.io/api', + }, + 'www': 'https://equos.io', + 'doc': [ + 'https://developer.equos.io', + ], + 'referral': 'https://equos.io?referredByCode=zpa8kij4ouvBFup3', + }, + 'api': { + 'public': { + 'get': [ + 'health', + 'getInstruments', + 'getInstrumentPairs', + 'getOrderBook', + 'getRisk', + 'getTradeHistory', + 'getFundingRateHistory', + 'getChart', + 'getExchangeInfo', // not documented + ], + }, + 'private': { + 'post': [ + 'logon', + 'order', + 'cancelOrder', + 'cancelReplaceOrder', + 'getOrder', + 'getOrders', + 'getOrderStatus', + 'getOrderHistory', + 'userTrades', + 'getPositions', + 'cancelAll', + 'getUserHistory', + 'getRisk', + 'getDepositAddresses', + 'getDepositHistory', // not documented + 'getWithdrawRequests', + 'sendWithdrawRequest', + 'getTransferHistory', + ], + }, + }, + 'requiredCredentials': { + 'apiKey': true, + 'secret': true, + 'uid': true, + }, + 'exceptions': { + 'broad': { + 'symbol not found': BadSymbol, + }, + }, + }); + } + + async fetchMarkets (params = {}) { + const request = { + 'verbose': true, + }; + const response = await this.publicGetGetInstrumentPairs (this.extend (request, params)); + // + // { + // "instrumentPairs":[ + // { + // "instrumentId":52, + // "symbol":"BTC/USDC", + // "quoteId":1, + // "baseId":3, + // "price_scale":2, + // "quantity_scale":6, + // "securityStatus":1, + // "securityDesc":"BTC/USDC", // "BTC/USDC[F]" + // "assetType":"PAIR", // "PERPETUAL_SWAP" + // "currency":"BTC", + // "contAmtCurr":"USDC", + // "settlCurrency":"USDC", + // "commCurrency":"USDC", + // "cfiCode":"XXXXXX", + // "securityExchange":"XXXX", + // "instrumentPricePrecision":2, + // "minPriceIncrement":1.0, + // "minPriceIncrementAmount":1.0, + // "roundLot":1, + // "minTradeVol":0.001000, + // "maxTradeVol":0.000000 + // // contracts onlye + // "qtyType":0, + // "contractMultiplier":1.0, + // "issueDate":1598608087000 + // }, + // ] + // } + // + const instrumentPairs = this.safeValue (response, 'instrumentPairs', []); + const markets = []; + for (let i = 0; i < instrumentPairs.length; i++) { + const market = this.parseMarket (instrumentPairs[i]); + markets.push (market); + } + return markets; + } + + parseMarket (market) { + // + // { + // "instrumentId":52, + // "symbol":"BTC/USDC", // "BTC/USDC[F]" + // "quoteId":1, + // "baseId":3, + // "price_scale":2, + // "quantity_scale":6, + // "securityStatus":1, + // "securityDesc":"BTC/USDC", // "BTC/USDC[F]" + // "assetType":"PAIR", // "PERPETUAL_SWAP" + // "currency":"BTC", + // "contAmtCurr":"USDC", + // "settlCurrency":"USDC", + // "commCurrency":"USDC", + // "cfiCode":"XXXXXX", + // "securityExchange":"XXXX", + // "instrumentPricePrecision":2, + // "minPriceIncrement":1.0, + // "minPriceIncrementAmount":1.0, + // "roundLot":1, + // "minTradeVol":0.001000, + // "maxTradeVol":0.000000 + // // contracts onlye + // "qtyType":0, + // "contractMultiplier":1.0, + // "issueDate":1598608087000 + // } + // + const id = this.safeString (market, 'instrumentId'); + const uppercaseId = this.safeString (market, 'symbol'); + const assetType = this.safeString (market, 'assetType'); + const spot = (assetType === 'PAIR'); + const swap = (assetType === 'PERPETUAL_SWAP'); + const type = swap ? 'swap' : 'spot'; + const baseId = this.safeString (market, 'currency'); + const quoteId = this.safeString (market, 'contAmtCurr'); + const base = this.safeCurrencyCode (baseId); + const quote = this.safeCurrencyCode (quoteId); + const symbol = swap ? uppercaseId : (base + '/' + quote); + const status = this.safeInteger (market, 'securityStatus'); + const active = (status === 1); + const precision = { + 'amount': this.safeInteger (market, 'quantity_scale'), + 'price': this.safeInteger (market, 'price_scale'), + }; + return { + 'id': id, + 'uppercaseId': uppercaseId, + 'symbol': symbol, + 'base': base, + 'quote': quote, + 'baseId': baseId, + 'quoteId': quoteId, + 'type': type, + 'spot': spot, + 'swap': swap, + 'active': active, + 'precision': precision, + 'limits': { + 'amount': { + 'min': this.safeFloat (market, 'minTradeVol'), + 'max': undefined, + }, + 'price': { + 'min': undefined, + 'max': undefined, + }, + 'cost': { + 'min': undefined, + 'max': undefined, + }, + }, + 'info': market, + }; + } + + async fetchCurrencies (params = {}) { + const response = await this.publicGetGetInstruments (params); + // + // { + // "instruments": [ + // [ + // 3, // id + // "BTC", // symbol + // 2, // price_scale + // 6, // amount_scale + // 1, // status + // 0, // withdraw_fee + // "BTC", // name + // true, // withdrawal_pct + // ], + // ] + // } + // + const currencies = {}; + const instruments = this.safeValue (response, 'instruments', []); + for (let i = 0; i < instruments.length; i++) { + const currency = this.parseCurrency (instruments[i]); + const code = currency['code']; + currencies[code] = currency; + } + return currencies; + } + + parseCurrency (currency) { + // + // [ + // 3, // 0 id + // "BTC", // 1 symbol + // 2, // 2 price_scale + // 6, // 3 amount_scale + // 1, // 4 status + // 0, // 5 withdraw_fee + // "BTC", // 6 name + // true, // 7 withdrawal_pct + // ], + // + const id = this.safeString (currency, 0); + const uppercaseId = this.safeString (currency, 1); + const code = this.safeCurrencyCode (uppercaseId); + const priceScale = this.safeInteger (currency, 2); + const amountScale = this.safeInteger (currency, 3); + const precision = Math.max (priceScale, amountScale); + const name = this.safeString (currency, 6); + const status = this.safeInteger (currency, 4); + const active = (status === 1); + const fee = this.safeFloat (currency, 5); // withdraw_fee + return { + 'id': id, + 'info': currency, + 'uppercaseId': uppercaseId, + 'code': code, + 'name': name, + 'precision': precision, + 'fee': fee, + 'active': active, + 'limits': { + 'amount': { + 'min': undefined, + 'max': undefined, + }, + 'price': { + 'min': undefined, + 'max': undefined, + }, + 'cost': { + 'min': undefined, + 'max': undefined, + }, + 'withdraw': { + 'min': undefined, + 'max': undefined, + }, + }, + }; + } + + async fetchOHLCV (symbol, timeframe = '1m', since = undefined, limit = undefined, params = {}) { + await this.loadMarkets (); + const market = this.market (symbol); + const request = { + 'pairId': parseInt (market['id']), + 'timespan': this.timeframes[timeframe], + }; + if (limit !== undefined) { + request['limit'] = limit; + } + const response = await this.publicGetGetChart (this.extend (request, params)); + // + // { + // "pairId":57, + // "t":1, + // "s":"ETH/BTC", + // "lastPx":44099, + // "lastQty":100000, + // "o":0.043831000000000016, + // "h":0.04427100000000002, + // "l":0.032000000000000015, + // "c":0.04409900000000002, + // "v":0.21267333000000016, + // "q":4.850000000000001, + // "chart":[ + // [1612519260000,44099,44099,44099,44099,0,441], + // [1612519200000,44099,44099,44099,44099,0,440], + // [1612519140000,44269,44271,44269,44271,0,439], + // ] + // } + // + const chart = this.safeValue (response, 'chart', []); + return this.parseOHLCVs (chart, market, timeframe, since, limit); + } + + parseOHLCV (ohlcv, market = undefined) { + // + // [ + // 1612519260000, // timestamp + // 44099, // open + // 44099, // high + // 44099, // low + // 44099, // close + // 0, // base volume + // 441, // seqNumber + // ] + // + const timestamp = this.safeInteger (ohlcv, 0); + const open = this.convertFromScale (ohlcv[1], market['precision']['price']); + const high = this.convertFromScale (ohlcv[2], market['precision']['price']); + const low = this.convertFromScale (ohlcv[3], market['precision']['price']); + const close = this.convertFromScale (ohlcv[4], market['precision']['price']); + const volume = this.convertFromScale (ohlcv[5], market['precision']['amount']); + // volume = ohlcv[5]; + return [timestamp, open, high, low, close, volume]; + } + + parseBidAsk (bidask, priceKey = 0, amountKey = 1, market = undefined) { + if (market === undefined) { + throw new ArgumentsRequired (this.id + ' parseBidAsk() requires a market argument'); + } + const price = this.safeFloat (bidask, priceKey); + const amount = this.safeFloat (bidask, amountKey); + return [ + this.convertFromScale (price, market['precision']['price']), + this.convertFromScale (amount, market['precision']['amount']), + ]; + } + + parseOrderBook (orderbook, timestamp = undefined, bidsKey = 'bids', asksKey = 'asks', priceKey = 0, amountKey = 1, market = undefined) { + const result = { + 'timestamp': timestamp, + 'datetime': this.iso8601 (timestamp), + 'nonce': undefined, + }; + const sides = [ bidsKey, asksKey ]; + for (let i = 0; i < sides.length; i++) { + const side = sides[i]; + const orders = []; + const bidasks = this.safeValue (orderbook, side); + for (let k = 0; k < bidasks.length; k++) { + orders.push (this.parseBidAsk (bidasks[k], priceKey, amountKey, market)); + } + result[side] = orders; + } + result[bidsKey] = this.sortBy (result[bidsKey], 0, true); + result[asksKey] = this.sortBy (result[asksKey], 0); + return result; + } + + async fetchOrderBook (symbol, limit = undefined, params = {}) { + await this.loadMarkets (); + const market = this.market (symbol); + const request = { + 'pairId': parseInt (market['id']), + }; + const response = await this.publicGetGetOrderBook (this.extend (request, params)); + // + // { + // "bids":[ + // [4000480,30000,1612644984667], + // [3999304,200000,1612644984667], + // [3998862,50000,1612644984667], + // ], + // "asks":[ + // [4001962,1790000,1612644984667], + // [4002616,1000,1612644984667], + // [4003889,1000,1612644984667], + // ], + // "usdMark":40011.02, + // "marketStatus":0, + // "estFundingRate":0.0, + // "fundingRateTime":0, + // "auctionPrice":0.0, + // "auctionVolume":0.0 + // } + // + return this.parseOrderBook (response, undefined, 'bids', 'asks', 0, 1, market); + } + + async fetchTrades (symbol, since = undefined, limit = undefined, params = {}) { + await this.loadMarkets (); + const market = this.market (symbol); + const request = { + 'pairId': parseInt (market['id']), + }; + const response = await this.publicGetGetTradeHistory (this.extend (request, params)); + // + // { + // "trades":[ + // [4022800,47000,"20210206-21:39:12.886",256323,1], + // [4023066,1000,"20210206-21:38:55.030",256322,1], + // [4022406,50000,"20210206-21:36:56.334",256321,1], + // ] + // } + // + const trades = this.safeValue (response, 'trades', []); + return this.parseTrades (trades, market, since, limit, params); + } + + parseTrade (trade, market = undefined) { + // + // public fetchTrades + // + // [ + // 4022800, // 0 price + // 47000, // 1 quantity + // "20210206-21:39:12.886", // 2 timestamp + // 256323, // 3 sequence number + // 1 // 4 taker side 1 = buy, 2 = sell + // ] + // + // private fetchMyTrades + // + // { + // "account":3583, + // "commission":"-0.015805", + // "commCurrency":"USDC", + // "execId":265757, + // "ordType":"2", + // "ordStatus":"2", + // "execType":"F", + // "aggressorIndicator":true, + // "orderId":388953019, + // "price":"1842.04", + // "qty":"0.010000", + // "lastPx":"1756.22", + // "avgPx":"1756.22", + // "cumQty":"0.010000", + // "quoteQty":"0.010000", + // "side":"BUY", + // "symbol":"ETH/USDC", + // "clOrdId":"1613106766970339107", + // "submitterId":3583, + // "targetStrategy":"0", + // "time":1613106766971, + // "date":"20210212-05:12:46.971" + // } + // + let id = undefined; + let timestamp = undefined; + let orderId = undefined; + let type = undefined; + let side = undefined; + let price = undefined; + let amount = undefined; + let cost = undefined; + let fee = undefined; + let symbol = undefined; + if (Array.isArray (trade)) { + id = this.safeString (trade, 3); + price = this.convertFromScale (this.safeInteger (trade, 0), market['precision']['price']); + amount = this.convertFromScale (this.safeInteger (trade, 1), market['precision']['amount']); + timestamp = this.toMilliseconds (this.safeString (trade, 2)); + const takerSide = this.safeInteger (trade, 4); + if (takerSide === 1) { + side = 'buy'; + } else if (takerSide === 2) { + side = 'sell'; + } + } else { + id = this.safeString (trade, 'execId'); + timestamp = this.safeInteger (trade, 'time'); + const marketId = this.safeString (trade, 'symbol'); + symbol = this.safeSymbol (marketId, market); + orderId = this.safeString (trade, 'orderId'); + side = this.safeStringLower (trade, 'side'); + type = this.parseOrderType (this.safeString (trade, 'ordType')); + price = this.safeFloat (trade, 'lastPx'); + amount = this.safeFloat (trade, 'quoteQty'); + let feeCost = this.safeFloat (trade, 'commission'); + if (feeCost !== undefined) { + feeCost = -feeCost; + const feeCurrencyId = this.safeString (trade, 'commCurrency'); + const feeCurrencyCode = this.safeCurrencyCode (feeCurrencyId); + fee = { + 'cost': feeCost, + 'currency': feeCurrencyCode, + }; + } + } + if ((symbol === undefined) && (market !== undefined)) { + symbol = market['symbol']; + } + if (cost === undefined) { + if ((amount !== undefined) && (price !== undefined)) { + cost = amount * price; + } + } + return { + 'info': trade, + 'id': id, + 'timestamp': timestamp, + 'datetime': this.iso8601 (timestamp), + 'symbol': symbol, + 'order': orderId, + 'type': type, + 'side': side, + 'takerOrMaker': undefined, + 'price': price, + 'amount': amount, + 'cost': cost, + 'fee': fee, + }; + } + + async fetchBalance (params = {}) { + await this.loadMarkets (); + const response = await this.privatePostGetPositions (params); + // { + // "positions":[ + // { + // "instrumentId":1, + // "userId":3583, + // "quantity":0, + // "availableQuantity":0, + // "quantity_scale":6, + // "symbol":"USDC", + // "assetType":"ASSET", + // "usdCostBasis":0.0, + // "usdAvgCostBasis":0.0, + // "usdValue":0.0, + // "usdUnrealized":0.0, + // "usdRealized":0.0, + // "baseUsdMark":1.0, + // "settleCoinUsdMark":0.0, + // "settleCoinUnrealized":0.0, + // "settleCoinRealized":0.0 + // }, + // ] + // } + const positions = this.safeValue (response, 'positions', []); + const result = { + 'info': response, + }; + for (let i = 0; i < positions.length; i++) { + const position = positions[i]; + const assetType = this.safeString (position, 'assetType'); + if (assetType === 'ASSET') { + const currencyId = this.safeString (position, 'symbol'); + const code = this.safeCurrencyCode (currencyId); + const quantity = this.safeFloat (position, 'quantity'); + const availableQuantity = this.safeFloat (position, 'availableQuantity'); + const scale = this.safeInteger (position, 'quantity_scale'); + const account = this.account (); + account['free'] = this.convertFromScale (availableQuantity, scale); + account['total'] = this.convertFromScale (quantity, scale); + result[code] = account; + } + } + return this.parseBalance (result); + } + + async createOrder (symbol, type, side, amount, price = undefined, params = {}) { + await this.loadMarkets (); + const market = this.market (symbol); + const orderSide = (side === 'buy') ? 1 : 2; + const quantityScale = this.getScale (amount); + const request = { + // 'id': 0, + // 'account': 0, // required for institutional users + 'instrumentId': parseInt (market['id']), + 'symbol': market['uppercaseId'], + // 'clOrdId': '', + 'side': orderSide, // 1 = buy, 2 = sell + // 'ordType': 1, // 1 = market, 2 = limit, 3 = stop market, 4 = stop limit + // 'price': this.priceToPrecision (symbol, price), // required for limit and stop limit orders + // 'price_scale': this.getScale (price), + 'quantity': this.convertToScale (amount, quantityScale), + 'quantity_scale': quantityScale, + // 'stopPx': this.priceToPrecision (symbol, stopPx), + // 'stopPx_scale': this.getScale (stopPx), + // 'targetStrategy': 0, + // 'isHidden': false, + // 'timeInForce': 1, // 1 = Good Till Cancel (GTC), 3 = Immediate or Cancel (IOC), 4 = Fill or Kill (FOK), 5 = Good Till Crossing (GTX), 6 = Good Till Date (GTD) + // 'interval': 0, + // 'intervalCount': 0, + // 'intervalDelay': 0, + // 'price2': 0, + // 'price2_scale': this.getScale (price2), + // 'blockWaitAck': 0, // 1 = wait for order acknowledgement, when set, response will include the matching engine "orderId" field + }; + if (type === 'market') { + request['ordType'] = 1; + } else if (type === 'limit') { + request['ordType'] = 2; + request['price'] = this.convertToScale (price, this.getScale (price)); + } else { + const stopPrice = this.safeFloat2 (params, 'stopPrice', 'stopPx'); + params = this.omit (params, [ 'stopPrice', 'stopPx' ]); + if (stopPrice === undefined) { + if (type === 'stop') { + if (price === undefined) { + throw new ArgumentsRequired (this.id + ' createOrder() requires a price argument or a stopPrice parameter or a stopPx parameter for ' + type + ' orders'); + } + request['ordType'] = 3; + request['stopPx'] = this.convertToScale (price, this.getScale (price)); + } else if (type === 'stop limit') { + throw new ArgumentsRequired (this.id + ' createOrder() requires a stopPrice parameter or a stopPx parameter for ' + type + ' orders'); + } + } else { + if (type === 'stop') { + request['ordType'] = 3; + request['stopPx'] = this.convertToScale (stopPrice, this.getScale (stopPrice)); + } else if (type === 'stop limit') { + request['ordType'] = 4; + const priceScale = this.getScale (price); + const stopPriceScale = this.getScale (stopPrice); + request['price_scale'] = priceScale; + request['stopPx_scale'] = stopPriceScale; + request['stopPx'] = this.convertToScale (stopPrice, stopPriceScale); + request['price'] = this.convertToScale (price, priceScale); + } + } + } + const response = await this.privatePostOrder (this.extend (request, params)); + // + // { + // "status":"sent", + // "id":385617863, + // "instrumentId":53, + // "clOrdId":"1613037510849637345", + // "userId":3583, + // "price":2000, + // "quantity":200, + // "ordType":2 + // } + // + return this.parseOrder (response, market); + } + + async cancelOrder (id, symbol = undefined, params = {}) { + if (symbol === undefined) { + throw new ArgumentsRequired (this.id + ' cancelOrder() requires a symbol argument'); + } + await this.loadMarkets (); + const market = this.market (symbol); + const request = { + 'origOrderId': parseInt (id), + 'instrumentId': parseInt (market['id']), + }; + const response = await this.privatePostCancelOrder (this.extend (request, params)); + // + // { + // "status":"sent", + // "id":0, + // "origOrderId":385613629, + // "instrumentId":53, + // "userId":3583, + // "price":0, + // "quantity":0, + // "ordType":0 + // } + // + return this.parseOrder (response, market); + } + + async editOrder (id, symbol, type, side, amount, price = undefined, params = {}) { + await this.loadMarkets (); + const market = this.market (symbol); + const orderSide = (side === 'buy') ? 1 : 2; + const quantityScale = this.getScale (amount); + const request = { + // 'id': 0, + 'origOrderId': id, + // 'account': 0, // required for institutional users + 'instrumentId': parseInt (market['id']), + 'symbol': market['uppercaseId'], + // 'clOrdId': '', + 'side': orderSide, // 1 = buy, 2 = sell + // 'ordType': 1, // 1 = market, 2 = limit, 3 = stop market, 4 = stop limit + // 'price': this.priceToPrecision (symbol, price), // required for limit and stop limit orders + // 'price_scale': this.getScale (price), + 'quantity': this.convertToScale (amount, quantityScale), + 'quantity_scale': quantityScale, + // 'stopPx': this.priceToPrecision (symbol, stopPx), + // 'stopPx_scale': this.getScale (stopPx), + // 'timeInForce': 1, // 1 = Good Till Cancel (GTC), 3 = Immediate or Cancel (IOC), 4 = Fill or Kill (FOK), 5 = Good Till Crossing (GTX), 6 = Good Till Date (GTD) + }; + if (type === 'market') { + request['ordType'] = 1; + } else if (type === 'limit') { + request['ordType'] = 2; + request['price'] = this.convertToScale (price, this.getScale (price)); + } else { + const stopPrice = this.safeFloat2 (params, 'stopPrice', 'stopPx'); + params = this.omit (params, [ 'stopPrice', 'stopPx' ]); + if (stopPrice === undefined) { + if (type === 'stop') { + if (price === undefined) { + throw new ArgumentsRequired (this.id + ' editOrder() requires a price argument or a stopPrice parameter or a stopPx parameter for ' + type + ' orders'); + } + request['ordType'] = 3; + request['stopPx'] = this.convertToScale (price, this.getScale (price)); + } else if (type === 'stop limit') { + throw new ArgumentsRequired (this.id + ' editOrder() requires a stopPrice parameter or a stopPx parameter for ' + type + ' orders'); + } + } else { + if (type === 'stop') { + request['ordType'] = 3; + request['stopPx'] = this.convertToScale (stopPrice, this.getScale (stopPrice)); + } else if (type === 'stop limit') { + request['ordType'] = 4; + const priceScale = this.getScale (price); + const stopPriceScale = this.getScale (stopPrice); + request['price_scale'] = priceScale; + request['stopPx_scale'] = stopPriceScale; + request['stopPx'] = this.convertToScale (stopPrice, stopPriceScale); + request['price'] = this.convertToScale (price, priceScale); + } + } + } + const response = await this.privatePostOrder (this.extend (request, params)); + // + // { + // "status":"sent", + // "id":385617863, + // "instrumentId":53, + // "clOrdId":"1613037510849637345", + // "userId":3583, + // "price":2000, + // "quantity":200, + // "ordType":2 + // } + // + return this.parseOrder (response, market); + } + + async fetchOrder (id, symbol = undefined, params = {}) { + await this.loadMarkets (); + const request = { + 'orderId': parseInt (id), + }; + const response = await this.privatePostGetOrderStatus (this.extend (request, params)); + // + // { + // "orderId":388953019, + // "clOrdId":"1613106766970339107", + // "symbol":"ETH/USDC", + // "instrumentId":53, + // "side":"1", + // "userId":3583, + // "account":3583, + // "execType":"F", + // "ordType":"2", + // "ordStatus":"2", + // "timeInForce":"3", + // "timeStamp":"20210212-05:12:46.971", + // "execId":265757, + // "targetStrategy":0, + // "isHidden":false, + // "isReduceOnly":false, + // "isLiquidation":false, + // "fee":0, + // "fee_scale":6, + // "feeInstrumentId":1, + // "price":184204, + // "price_scale":2, + // "quantity":10000, + // "quantity_scale":6, + // "leavesQty":0, + // "leavesQty_scale":6, + // "cumQty":10000, + // "cumQty_scale":6, + // "lastPx":175622, + // "lastPx_scale":2, + // "avgPx":175622, + // "avgPx_scale":2, + // "lastQty":10000, + // "lastQty_scale":6 + // } + // + return this.parseOrder (response); + } + + async fetchClosedOrders (symbol = undefined, since = undefined, limit = undefined, params = {}) { + const request = { + 'ordStatus': '2', // '0' = New, '1' = Partially filled, '2' = Filled, '4' = Cancelled, '8' = Rejected, 'C' = Expired + }; + return await this.fetchOrders (symbol, since, limit, this.extend (request, params)); + } + + async fetchCanceledOrders (symbol = undefined, since = undefined, limit = undefined, params = {}) { + const request = { + 'ordStatus': '4', // '0' = New, '1' = Partially filled, '2' = Filled, '4' = Cancelled, '8' = Rejected, 'C' = Expired + }; + return await this.fetchOrders (symbol, since, limit, this.extend (request, params)); + } + + async fetchOrders (symbol = undefined, since = undefined, limit = undefined, params = {}) { + await this.loadMarkets (); + let market = undefined; + const request = { + // 'account': id, // for institutional users + // 'symbol': marketSymbol, // cannot be used with instrumentId + // 'instrumentId': market['numericId'], + // 'limit': limit, + // 'execType': execType, // '0' = New, '4' = Canceled, '5' = Replace, '8' = Rejected, 'C' = Expired, 'F' = Fill Status, 'I' = Order Status + // 'ordStatus': ordStatus, // '0' = New, '1' = Partially filled, '2' = Filled, '4' = Cancelled, '8' = Rejected, 'C' = Expired + }; + if (symbol !== undefined) { + market = this.market (symbol); + request['instrumentId'] = parseInt (market['id']); + } + if (limit !== undefined) { + request['limit'] = limit; + } + const response = await this.privatePostGetOrders (this.extend (request, params)); + // + // { + // "isInitialSnap":false, + // "orders":[ + // { + // "orderId":385613629, + // "orderUpdateSeq":1, + // "clOrdId":"1613037448945798198", + // "symbol":"ETH/USDC", + // "instrumentId":53, + // "side":"1", + // "userId":3583, + // "account":3583, + // "execType":"4", + // "ordType":"2", + // "ordStatus":"C", + // "timeInForce":"3", + // "timeStamp":"20210211-09:57:28.944", + // "execId":0, + // "targetStrategy":0, + // "isHidden":false, + // "isReduceOnly":false, + // "isLiquidation":false, + // "fee":0, + // "feeTotal":0, + // "fee_scale":0, + // "feeInstrumentId":0, + // "price":999, + // "price_scale":2, + // "quantity":10000000, + // "quantity_scale":6, + // "leavesQty":10000000, + // "leavesQty_scale":6, + // "cumQty":0, + // "cumQty_scale":0, + // "lastPx":0, + // "lastPx_scale":2, + // "avgPx":0, + // "avgPx_scale":0, + // "lastQty":0, + // "lastQty_scale":6 + // } + // ] + // } + // + const orders = this.safeValue (response, 'orders', []); + return this.parseOrders (orders, market, since, limit, params); + } + + async fetchMyTrades (symbol = undefined, since = undefined, limit = undefined, params = {}) { + await this.loadMarkets (); + const request = { + // 'account': 123, // for institutional users + // 'instrumentId': market['id'], + // 'startTime': since, + // 'endTime': this.milliseconds (), + }; + let market = undefined; + if (symbol !== undefined) { + market = this.market (symbol); + request['instrumentId'] = market['id']; + } + if (since !== undefined) { + request['startTime'] = since; + } + const response = await this.privatePostUserTrades (this.extend (request, params)); + // + // { + // "trades":[ + // { + // "account":3583, + // "commission":"-0.015805", + // "commCurrency":"USDC", + // "execId":265757, + // "ordType":"2", + // "ordStatus":"2", + // "execType":"F", + // "aggressorIndicator":true, + // "orderId":388953019, + // "price":"1842.04", + // "qty":"0.010000", + // "lastPx":"1756.22", + // "avgPx":"1756.22", + // "cumQty":"0.010000", + // "quoteQty":"0.010000", + // "side":"BUY", + // "symbol":"ETH/USDC", + // "clOrdId":"1613106766970339107", + // "submitterId":3583, + // "targetStrategy":"0", + // "time":1613106766971, + // "date":"20210212-05:12:46.971" + // } + // ] + // } + // + const trades = this.safeValue (response, 'trades', []); + return this.parseTrades (trades, market, since, limit, params); + } + + async fetchDepositAddress (code, params = {}) { + await this.loadMarkets (); + const currency = this.currency (code); + const request = { + 'instrumentId': parseInt (currency['id']), + }; + const response = await this.privatePostGetDepositAddresses (this.extend (request, params)); + // + // { + // "addresses":[ + // {"instrumentId":1,"userId":3583,"symbol":"USDC","address":"0xdff47af071ea3c537e57278290516cda32a78b97","status":1} + // ] + // } + // + const addresses = this.safeValue (response, 'addresses', []); + const address = this.safeValue (addresses, 0); + return this.parseDepositAddress (address, currency); + } + + parseDepositAddress (depositAddress, currency = undefined) { + // + // { + // "instrumentId":1, + // "userId":3583, + // "symbol":"USDC", + // "address":"0xdff47af071ea3c537e57278290516cda32a78b97", + // "status":1 + // } + // + const currencyId = this.safeString (depositAddress, 'symbol'); + const code = this.safeCurrencyCode (currencyId, currency); + const address = this.safeString (depositAddress, 'address'); + this.checkAddress (address); + return { + 'currency': code, + 'address': address, + 'tag': undefined, + 'info': depositAddress, + }; + } + + async fetchDeposits (code = undefined, since = undefined, limit = undefined, params = {}) { + await this.loadMarkets (); + const request = {}; + let currency = undefined; + if (code !== undefined) { + currency = this.currency (code); + request['instrumentId'] = parseInt (currency['id']); + } + const response = await this.privatePostGetDepositHistory (this.extend (request, params)); + // + // { + // "deposits":[ + // { + // "id":4309, + // "instrumentId":1, + // "userId":3583, + // "symbol":"USDC", + // "address":"null", + // "timestamp":"1613021112189", + // "status":1, + // "balance":0.0, + // "balance_change":100.0, + // "confirms":1, + // "transactionId":"caba4500-489f-424e-abd7-b4dabc09a800" + // } + // ] + // } + // + const deposits = this.safeValue (response, 'deposits', []); + return this.parseTransactions (deposits, currency, since, limit, { 'type': 'deposit' }); + } + + async fetchWithdrawals (code = undefined, since = undefined, limit = undefined, params = {}) { + await this.loadMarkets (); + const request = {}; + let currency = undefined; + if (code !== undefined) { + currency = this.currency (code); + request['instrumentId'] = parseInt (currency['id']); + } + const response = await this.privatePostGetWithdrawRequests (this.extend (request, params)); + // + // { + // "addresses":[ + // { + // "id":3841, + // "instrumentId":3, + // "userId":4245, + // "symbol":"BTC", + // "address":"XXXXXYYYYYZZZZZ", + // "timestamp":"20200806-11:04:35.053", + // "status":0, + // "balance":1, + // "balance_scale":3, + // "confirms":0, + // "transactionId":"null" + // } + // ] + // } + // + const withdrawals = this.safeValue (response, 'addresses', []); + return this.parseTransactions (withdrawals, currency, since, limit, { 'type': 'withdrawal' }); + } + + parseTransaction (transaction, currency = undefined) { + // + // fetchDeposits, fetchWithdrawals + // + // { + // "id":4309, + // "instrumentId":1, + // "userId":3583, + // "symbol":"USDC", + // "address":"null", + // "timestamp":"1613021112189", + // "status":1, + // "balance":0.0, + // "balance_change":100.0, + // "confirms":1, + // "transactionId":"caba4500-489f-424e-abd7-b4dabc09a800" + // } + // + // withdraw + // + // { + // "instrumentId": 1, + // "userId": 23750, + // "symbol": "USDC", + // "timestamp": "20200201-05:37:16.584", + // "status": 1, + // "userUuid": "b9e33713-c28f-468f-99bd-f6deab0dd854", + // "currencyCode": "USDC", + // "address": "2MvW97yT6E2Kq8bWc1aj1DqfbgMzjRNk2LE", + // "quantity": 20, + // "requestUuid": "56782b34-8a78-4f5f-b164-4b8f7d583b7f", + // "transactionUuid": "1004eb0f-41e1-41e9-9d48-8eefcc6c09f2", + // "transactionId": "WS23436", + // "destinationWalletAlias": "Test", + // "quantity_scale": 0 + // } + // + const id = this.safeString (transaction, 'id', 'transactionId'); + const txid = this.safeString (transaction, 'transactionUuid'); + const timestamp = this.safeInteger (transaction, 'timestamp'); + let address = this.safeString (transaction, 'address'); + if (address === 'null') { + address = undefined; + } + const type = this.safeString (transaction, 'type'); + let amount = this.safeFloat (transaction, 'balance_change'); + if (amount === undefined) { + amount = this.safeInteger (transaction, 'quantity'); + const amountScale = this.safeInteger (transaction, 'quantity_scale'); + amount = this.convertFromScale (amount, amountScale); + } + const currencyId = this.safeString (transaction, 'symbol'); + const code = this.safeCurrencyCode (currencyId, currency); + const status = this.parseTransactionStatus (this.safeString (transaction, 'status')); + return { + 'info': transaction, + 'id': id, + 'txid': txid, + 'timestamp': timestamp, + 'datetime': this.iso8601 (timestamp), + 'addressFrom': undefined, + 'address': address, + 'addressTo': undefined, + 'tagFrom': undefined, + 'tag': undefined, + 'tagTo': undefined, + 'type': type, + 'amount': amount, + 'currency': code, + 'status': status, + 'updated': undefined, + 'comment': undefined, + 'fee': undefined, + }; + } + + parseTransactionStatus (status) { + const statuses = { + '0': 'pending', + '1': 'ok', + }; + return this.safeString (statuses, status, status); + } + + async withdraw (code, amount, address, tag = undefined, params = {}) { + this.checkAddress (address); + await this.loadMarkets (); + const currency = this.currency (code); + const scale = this.getScale (amount); + const quantity = this.convertToScale (amount, scale); + const request = { + 'instrumentId': parseInt (currency['id']), + 'symbol': currency['uppercaseId'], + 'quantity': quantity, + 'quantity_scale': scale, + 'address': address, + }; + const response = await this.privatePostSendWithdrawRequest (this.extend (request, params)); + // + // { + // "instrumentId": 1, + // "userId": 23750, + // "symbol": "USDC", + // "timestamp": "20200201-05:37:16.584", + // "status": 1, + // "userUuid": "b9e33713-c28f-468f-99bd-f6deab0dd854", + // "currencyCode": "USDC", + // "address": "2MvW97yT6E2Kq8bWc1aj1DqfbgMzjRNk2LE", + // "quantity": 20, + // "requestUuid": "56782b34-8a78-4f5f-b164-4b8f7d583b7f", + // "transactionUuid": "1004eb0f-41e1-41e9-9d48-8eefcc6c09f2", + // "transactionId": "WS23436", + // "destinationWalletAlias": "Test", + // "quantity_scale": 0 + // } + // + return this.parseTransaction (response, currency); + } + + async fetchTradingFees (params = {}) { + // getExchangeInfo + const response = await this.publicGetGetExchangeInfo (params); + const tradingFees = this.safeValue (response, 'spotFees', []); + const taker = {}; + const maker = {}; + for (let i = 0; i < tradingFees.length; i++) { + const tradingFee = tradingFees[i]; + if (this.safeString (tradingFee, 'tier') !== undefined) { + taker[tradingFee['tier']] = this.safeFloat (tradingFee, 'taker'); + maker[tradingFee['tier']] = this.safeFloat (tradingFee, 'maker'); + } + } + return { + 'info': tradingFees, + 'tierBased': true, + 'maker': maker, + 'taker': taker, + }; + } + + async fetchTradingLimits (symbols = undefined, params = {}) { + await this.loadMarkets (); + // getExchangeInfo + const response = await this.publicGetGetExchangeInfo (params); + const tradingLimits = this.safeValue (response, 'tradingLimits', []); + // To-do parsing response when available + return { + 'info': tradingLimits, + 'limits': { + 'amount': { + 'min': undefined, + 'max': undefined, + }, + 'price': { + 'min': undefined, + 'max': undefined, + }, + 'cost': { + 'min': undefined, + 'max': undefined, + }, + }, + }; + } + + async fetchFundingLimits (params = {}) { + // getExchangeInfo + const response = await this.publicGetGetExchangeInfo (params); + const withdrawLimits = this.safeValue (response, 'withdrawLimits', []); + // TO-DO parse response when available + return { + 'info': withdrawLimits, + 'withdraw': undefined, + }; + } + + parseOrder (order, market = undefined) { + // + // createOrder, editOrder, cancelOrder + // + // { + // "status":"sent", + // "id":385617863, + // "instrumentId":53, + // "clOrdId":"1613037510849637345", + // "userId":3583, + // "price":2000, + // "quantity":200, + // "ordType":2 + // } + // + // fetchOrders, fetchOrder + // + // { + // "orderId":385613629, + // "orderUpdateSeq":1, + // "clOrdId":"1613037448945798198", + // "symbol":"ETH/USDC", + // "instrumentId":53, + // "side":"1", + // "userId":3583, + // "account":3583, + // "execType":"4", + // "ordType":"2", + // "ordStatus":"C", + // "timeInForce":"3", + // "timeStamp":"20210211-09:57:28.944", + // "execId":0, + // "targetStrategy":0, + // "isHidden":false, + // "isReduceOnly":false, + // "isLiquidation":false, + // "fee":0, + // "feeTotal":0, + // "fee_scale":0, + // "feeInstrumentId":0, + // "price":999, + // "price_scale":2, + // "quantity":10000000, + // "quantity_scale":6, + // "leavesQty":10000000, + // "leavesQty_scale":6, + // "cumQty":0, + // "cumQty_scale":0, + // "lastPx":0, + // "lastPx_scale":2, + // "avgPx":0, + // "avgPx_scale":0, + // "lastQty":0, + // "lastQty_scale":6 + // } + // + let id = this.safeString2 (order, 'orderId', 'id'); + id = this.safeString (order, 'origOrderId', id); + const clientOrderId = this.safeString (order, 'clOrdId'); + const type = this.parseOrderType (this.safeString (order, 'ordType')); + const side = this.parseOrderSide (this.safeString (order, 'side')); + const status = this.parseOrderStatus (this.safeString (order, 'ordStatus')); + const marketId = this.safeString (order, 'instrumentId'); + const symbol = this.safeSymbol (marketId, market); + const timestamp = this.toMilliseconds (this.safeString (order, 'timeStamp')); + const lastTradeTimestamp = undefined; + let price = this.safeInteger (order, 'price'); + if (price === 0) { + price = undefined; + } + const priceScale = this.safeInteger (order, 'price_scale'); + price = this.convertFromScale (price, priceScale); + let amount = this.safeInteger (order, 'quantity'); + if (amount === 0) { + amount = undefined; + } + const amountScale = this.safeInteger (order, 'quantity_scale'); + amount = this.convertFromScale (amount, amountScale); + let filled = this.safeInteger (order, 'cumQty'); + const filledScale = this.safeInteger (order, 'cumQty_scale'); + filled = this.convertFromScale (filled, filledScale); + let remaining = this.safeInteger (order, 'leavesQty'); + const remainingScale = this.safeInteger (order, 'leavesQty_scale'); + remaining = this.convertFromScale (remaining, remainingScale); + if (remaining <= 0) { + if ((filled !== undefined) && (amount !== undefined) && (filled < amount)) { + remaining = undefined; + } + } + if ((remaining === undefined) && (amount !== undefined) && (filled !== undefined)) { + remaining = Math.max (amount - filled, 0); + } + let average = this.safeInteger (order, 'price', 0); + if (average === 0) { + average = undefined; + } + const averageScale = this.safeInteger (order, 'price_scale'); + average = this.convertFromScale (average, averageScale); + let cost = undefined; + if (filled !== 0) { + if (average > 0) { + cost = average * filled; + } else if (price > 0) { + cost = price * filled; + } + } + let fee = undefined; + const currencyId = this.safeInteger (order, 'feeInstrumentId'); + const feeCurrencyCode = this.safeCurrencyCode (currencyId); + let feeCost = this.safeInteger (order, 'feeTotal'); + const feeScale = this.safeInteger (order, 'fee_scale'); + if (feeCost !== undefined) { + feeCost = -feeCost; + feeCost = this.convertFromScale (feeCost, feeScale); + } + if (feeCost !== undefined) { + fee = { + 'currency': feeCurrencyCode, + 'cost': feeCost, + 'rate': undefined, + }; + } + let timeInForce = this.parseTimeInForce (this.safeString (order, 'timeInForce')); + if (timeInForce === '0') { + timeInForce = undefined; + } + const stopPriceScale = this.safeInteger (order, 'stopPx_scale', 0); + const stopPrice = this.convertFromScale (this.safeInteger (order, 'stopPx'), stopPriceScale); + return { + 'info': order, + 'id': id, + 'clientOrderId': clientOrderId, + 'timestamp': timestamp, + 'datetime': this.iso8601 (timestamp), + 'lastTradeTimestamp': lastTradeTimestamp, + 'symbol': symbol, + 'type': type, + 'timeInForce': timeInForce, + 'postOnly': undefined, + 'side': side, + 'price': price, + 'stopPrice': stopPrice, + 'amount': amount, + 'cost': cost, + 'average': average, + 'filled': filled, + 'remaining': remaining, + 'status': status, + 'fee': fee, + 'trades': undefined, + }; + } + + parseOrderStatus (status) { + const statuses = { + '0': 'open', + '1': 'open', // 'partially filled', + '2': 'closed', // 'filled', + '3': 'open', // 'done for day', + '4': 'canceled', + '5': 'canceled', // 'replaced', + '6': 'canceling', // 'pending cancel', + '7': 'canceled', // 'stopped', + '8': 'rejected', // 'rejected', + '9': 'canceled', // 'suspended', + 'A': 'open', // 'pending new', + 'B': 'open', // 'calculated', + 'C': 'expired', + 'D': 'open', // 'accepted for bidding', + 'E': 'canceling', // 'pending replace', + 'F': 'open', // 'partial fill or fill', + }; + return this.safeString (statuses, status, status); + } + + parseOrderSide (side) { + const sides = { + '1': 'buy', + '2': 'sell', + }; + return this.safeString (sides, side, side); + } + + parseOrderType (type) { + const types = { + '1': 'market', + '2': 'limit', + '3': 'stop', + '4': 'stop limit', + }; + return this.safeString (types, type, type); + } + + parseTimeInForce (timeInForce) { + const timeInForces = { + '1': 'GTC', // Good Till Canceled + '3': 'IOC', // Immediate or Cancel + '4': 'FOK', // Fill or Kill + '5': 'GTX', // Good Till Crossing (GTX) + '6': 'GTD', // Good Till Date + }; + return this.safeString (timeInForces, timeInForce, timeInForce); + } + + toMilliseconds (dateString) { + if (dateString === undefined) { + return dateString; + } + // '20200328-10:31:01.575' -> '2020-03-28 12:42:48.000' + const splits = dateString.split ('-'); + const partOne = this.safeString (splits, 0); + const partTwo = this.safeString (splits, 1); + if (partOne === undefined || partTwo === undefined) { + return undefined; + } + if (partOne.length !== 8) { + return undefined; + } + const date = partOne.slice (0, 4) + '-' + partOne.slice (4, 6) + '-' + partOne.slice (6, 8); + return this.parse8601 (date + ' ' + partTwo); + } + + convertFromScale (number, scale) { + if ((number === undefined) || (scale === undefined)) { + return undefined; + } + return this.fromWei (number, scale); + } + + getScale (num) { + const s = this.numberToString (num); + return this.precisionFromString (s); + } + + convertToScale (number, scale) { + if ((number === undefined) || (scale === undefined)) { + return undefined; + } + return parseInt (this.toWei (number, scale)); + } + + nonce () { + return this.milliseconds (); + } + + handleErrors (code, reason, url, method, headers, body, response, requestHeaders, requestBody) { + if (response === undefined) { + return; // fallback to default error handler + } + const error = this.safeString (response, 'error'); + if (error !== undefined) { + const feedback = this.id + ' ' + body; + this.throwExactlyMatchedException (this.exceptions, error, feedback); + this.throwBroadlyMatchedException (this.exceptions, body, feedback); + throw new ExchangeError (this.id + ' ' + body); + } + } + + sign (path, api = 'public', method = 'GET', params = {}, headers = undefined, body = undefined) { + let url = this.implodeParams (path, params); + let query = this.omit (params, this.extractParams (path)); + if (api === 'public') { + if (Object.keys (query).length) { + url += '?' + this.urlencode (query); + } + } else if (api === 'private') { + // special case for getUserHistory + const format = this.safeValue (params, 'format'); + const type = this.safeValue (params, 'type'); + const extension = {}; + if (format !== undefined) { + extension['format'] = format; + } + if (type !== undefined) { + extension['type'] = type; + } + if (Object.keys (extension).length) { + url += '?' + this.urlencode (extension); + } + params = this.omit (params, [ 'format', 'type' ]); + this.checkRequiredCredentials (); + const nonce = this.nonce (); + query = this.extend (query, { + 'userId': this.uid, + 'nonce': nonce, + }); + params['nonce'] = this.nonce (); + body = this.json (query); + const signature = this.hmac (this.encode (body), this.encode (this.secret), 'sha384'); + headers = { + 'Content-Type': 'application/json', + 'requestToken': this.apiKey, + 'signature': signature, + }; + } + url = this.urls['api'][api] + '/' + url; + return { 'url': url, 'method': method, 'body': body, 'headers': headers }; + } +}; + +},{"./base/Exchange":6,"./base/errors":8}],81:[function(require,module,exports){ 'use strict'; // ---------------------------------------------------------------------------- @@ -61506,7 +66709,7 @@ module.exports = class eterbase extends Exchange { request['start'] = now - duration * limit * 1000; request['end'] = now; } else { - throw new ArgumentsRequired (this.id + ' fetchOHLCV requires a since argument, or a limit argument, or both'); + throw new ArgumentsRequired (this.id + ' fetchOHLCV() requires a since argument, or a limit argument, or both'); } await this.loadMarkets (); const market = this.market (symbol); @@ -61708,6 +66911,7 @@ module.exports = class eterbase extends Exchange { } const timeInForce = this.safeString (order, 'timeInForce'); const stopPrice = this.safeFloat (order, 'stopPrice'); + const postOnly = this.safeValue (order, 'postOnly'); return { 'info': order, 'id': id, @@ -61717,8 +66921,9 @@ module.exports = class eterbase extends Exchange { 'lastTradeTimestamp': undefined, 'symbol': symbol, 'type': type, - 'side': side, 'timeInForce': timeInForce, + 'postOnly': postOnly, + 'side': side, 'price': price, 'stopPrice': stopPrice, 'amount': amount, @@ -62041,7 +67246,7 @@ module.exports = class eterbase extends Exchange { } }; -},{"./base/Exchange":5,"./base/errors":7,"./base/functions/number":13}],79:[function(require,module,exports){ +},{"./base/Exchange":6,"./base/errors":8,"./base/functions/number":14}],82:[function(require,module,exports){ 'use strict'; // --------------------------------------------------------------------------- @@ -62746,7 +67951,7 @@ module.exports = class exmo extends Exchange { const now = this.milliseconds (); if (since === undefined) { if (limit === undefined) { - throw new ArgumentsRequired (this.id + ' fetchOHLCV requires a since argument or a limit argument'); + throw new ArgumentsRequired (this.id + ' fetchOHLCV() requires a since argument or a limit argument'); } else { if (limit > maxLimit) { throw new BadRequest (this.id + ' fetchOHLCV will serve ' + maxLimit.toString () + ' candles at most'); @@ -63362,6 +68567,7 @@ module.exports = class exmo extends Exchange { 'symbol': symbol, 'type': 'limit', 'timeInForce': undefined, + 'postOnly': undefined, 'side': side, 'price': price, 'stopPrice': undefined, @@ -63480,12 +68686,21 @@ module.exports = class exmo extends Exchange { const type = this.safeString (transaction, 'type'); const currencyId = this.safeString (transaction, 'curr'); const code = this.safeCurrencyCode (currencyId, currency); - let address = this.safeString (transaction, 'account'); - if (address !== undefined) { - const parts = address.split (':'); - const numParts = parts.length; - if (numParts === 2) { - address = parts[1].replace (' ', ''); + let address = undefined; + const tag = undefined; + let comment = undefined; + const account = this.safeString (transaction, 'account'); + if (type === 'deposit') { + comment = account; + } else if (type === 'withdrawal') { + address = account; + if (address !== undefined) { + const parts = address.split (':'); + const numParts = parts.length; + if (numParts === 2) { + address = this.safeString (parts, 1); + address = address.replace (' ', ''); + } } } let fee = undefined; @@ -63513,16 +68728,21 @@ module.exports = class exmo extends Exchange { return { 'info': transaction, 'id': undefined, + 'timestamp': timestamp, + 'datetime': this.iso8601 (timestamp), 'currency': code, 'amount': amount, 'address': address, - 'tag': undefined, // refix it properly + 'addressTo': address, + 'addressFrom': undefined, + 'tag': tag, + 'tagTo': tag, + 'tagFrom': undefined, 'status': status, 'type': type, 'updated': undefined, + 'comment': comment, 'txid': txid, - 'timestamp': timestamp, - 'datetime': this.iso8601 (timestamp), 'fee': fee, }; } @@ -63634,7 +68854,7 @@ module.exports = class exmo extends Exchange { } }; -},{"./base/Exchange":5,"./base/errors":7}],80:[function(require,module,exports){ +},{"./base/Exchange":6,"./base/errors":8}],83:[function(require,module,exports){ 'use strict'; // --------------------------------------------------------------------------- @@ -63963,6 +69183,7 @@ module.exports = class exx extends Exchange { 'symbol': symbol, 'type': 'limit', 'timeInForce': undefined, + 'postOnly': undefined, 'side': order['type'], 'price': price, 'stopPrice': undefined, @@ -64024,7 +69245,7 @@ module.exports = class exx extends Exchange { async fetchOpenOrders (symbol = undefined, since = undefined, limit = undefined, params = {}) { await this.loadMarkets (); if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' fetchOpenOrders requires a symbol argument'); + throw new ArgumentsRequired (this.id + ' fetchOpenOrders() requires a symbol argument'); } const market = this.market (symbol); const request = { @@ -64099,7 +69320,7 @@ module.exports = class exx extends Exchange { } }; -},{"./base/Exchange":5,"./base/errors":7}],81:[function(require,module,exports){ +},{"./base/Exchange":6,"./base/errors":8}],84:[function(require,module,exports){ 'use strict'; // --------------------------------------------------------------------------- @@ -64694,6 +69915,7 @@ module.exports = class fcoin extends Exchange { 'symbol': symbol, 'type': orderType, 'timeInForce': undefined, + 'postOnly': undefined, 'side': side, 'price': price, 'stopPrice': undefined, @@ -64843,7 +70065,7 @@ module.exports = class fcoin extends Exchange { } }; -},{"./base/Exchange":5,"./base/errors":7}],82:[function(require,module,exports){ +},{"./base/Exchange":6,"./base/errors":8}],85:[function(require,module,exports){ 'use strict'; // --------------------------------------------------------------------------- @@ -64869,7 +70091,7 @@ module.exports = class fcoinjp extends fcoin { } }; -},{"./fcoin.js":81}],83:[function(require,module,exports){ +},{"./fcoin.js":84}],86:[function(require,module,exports){ 'use strict'; // --------------------------------------------------------------------------- @@ -65118,7 +70340,7 @@ module.exports = class flowbtc extends Exchange { }; return await this.privatePostCancelOrder (this.extend (request, params)); } - throw new ExchangeError (this.id + ' requires `ins` symbol parameter for cancelling an order'); + throw new ExchangeError (this.id + ' cancelOrder() requires an `ins` symbol parameter for cancelling an order'); } sign (path, api = 'public', method = 'GET', params = {}, headers = undefined, body = undefined) { @@ -65155,7 +70377,7 @@ module.exports = class flowbtc extends Exchange { } }; -},{"./base/Exchange":5,"./base/errors":7}],84:[function(require,module,exports){ +},{"./base/Exchange":6,"./base/errors":8}],87:[function(require,module,exports){ 'use strict'; // --------------------------------------------------------------------------- @@ -65420,14 +70642,14 @@ module.exports = class foxbit extends Exchange { } }; -},{"./base/Exchange":5,"./base/errors":7}],85:[function(require,module,exports){ +},{"./base/Exchange":6,"./base/errors":8}],88:[function(require,module,exports){ 'use strict'; // --------------------------------------------------------------------------- const Exchange = require ('./base/Exchange'); const { TICK_SIZE } = require ('./base/functions/number'); -const { ExchangeError, InvalidOrder, BadRequest, InsufficientFunds, OrderNotFound, AuthenticationError } = require ('./base/errors'); +const { ExchangeError, InvalidOrder, BadRequest, InsufficientFunds, OrderNotFound, AuthenticationError, RateLimitExceeded, ExchangeNotAvailable, CancelPending } = require ('./base/errors'); // --------------------------------------------------------------------------- @@ -65437,7 +70659,7 @@ module.exports = class ftx extends Exchange { 'id': 'ftx', 'name': 'FTX', 'countries': [ 'HK' ], - 'rateLimit': 100, + 'rateLimit': 50, 'certified': true, 'pro': true, 'hostname': 'ftx.com', // or ftx.us @@ -65522,9 +70744,12 @@ module.exports = class ftx extends Exchange { 'wallet/coins', 'wallet/balances', 'wallet/all_balances', - 'wallet/deposit_address/{coin}', + 'wallet/deposit_address/{coin}', // ?method={method} 'wallet/deposits', 'wallet/withdrawals', + 'wallet/withdrawal_fee', + 'wallet/airdrops', + 'wallet/saved_addresses', 'orders', // ?market={market} 'orders/history', // ?market={market} 'orders/{order_id}', @@ -65532,6 +70757,14 @@ module.exports = class ftx extends Exchange { 'conditional_orders', // ?market={market} 'conditional_orders/{conditional_order_id}/triggers', 'conditional_orders/history', // ?market={market} + 'spot_margin/borrow_rates', + 'spot_margin/lending_rates', + 'spot_margin/borrow_summary', + 'spot_margin/market_info', // ?market={market} + 'spot_margin/borrow_history', + 'spot_margin/lending_history', + 'spot_margin/offers', + 'spot_margin/lending_info', 'fills', // ?market={market} 'funding_payments', // leverage tokens @@ -65550,15 +70783,23 @@ module.exports = class ftx extends Exchange { 'options/account_info', 'options/positions', 'options/fills', + // staking + 'staking/stakes', + 'staking/unstake_requests', + 'staking/balances', + 'staking/staking_rewards', ], 'post': [ 'account/leverage', 'wallet/withdrawals', + 'wallet/saved_addresses', 'orders', 'conditional_orders', 'orders/{order_id}/modify', 'orders/by_client_id/{client_order_id}/modify', 'conditional_orders/{order_id}/modify', + // spot margin + 'spot_margin/offers', // leverage tokens 'lt/{token_name}/create', 'lt/{token_name}/redeem', @@ -65573,8 +70814,12 @@ module.exports = class ftx extends Exchange { 'options/requests', 'options/requests/{request_id}/quotes', 'options/quotes/{quote_id}/accept', + // staking + 'staking/unstake_requests', + 'srm_stakes/stakes', ], 'delete': [ + 'wallet/saved_addresses/{saved_address_id}', 'orders/{order_id}', 'orders/by_client_id/{client_order_id}', 'orders', @@ -65584,6 +70829,8 @@ module.exports = class ftx extends Exchange { // options 'options/requests/{request_id}', 'options/quotes/{quote_id}', + // staking + 'staking/unstake_requests/{request_id}', ], }, }, @@ -65618,6 +70865,8 @@ module.exports = class ftx extends Exchange { }, 'exceptions': { 'exact': { + 'Please slow down': RateLimitExceeded, // {"error":"Please slow down","success":false} + 'Size too small for provide': InvalidOrder, // {"error":"Size too small for provide","success":false} 'Not logged in': AuthenticationError, // {"error":"Not logged in","success":false} 'Not enough balances': InsufficientFunds, // {"error":"Not enough balances","success":false} 'InvalidPrice': InvalidOrder, // {"error":"Invalid price","success":false} @@ -65625,13 +70874,20 @@ module.exports = class ftx extends Exchange { 'Missing parameter price': InvalidOrder, // {"error":"Missing parameter price","success":false} 'Order not found': OrderNotFound, // {"error":"Order not found","success":false} 'Order already closed': InvalidOrder, // {"error":"Order already closed","success":false} + 'Trigger price too high': InvalidOrder, // {"error":"Trigger price too high","success":false} + 'Trigger price too low': InvalidOrder, // {"error":"Trigger price too low","success":false} + 'Order already queued for cancellation': CancelPending, // {"error":"Order already queued for cancellation","success":false} }, 'broad': { + 'Account does not have enough margin for order': InsufficientFunds, 'Invalid parameter': BadRequest, // {"error":"Invalid parameter start_time","success":false} 'The requested URL was not found on the server': BadRequest, 'No such coin': BadRequest, 'No such market': BadRequest, - 'An unexpected error occurred': ExchangeError, // {"error":"An unexpected error occurred, please try again later (58BC21C795).","success":false} + 'Do not send more than': RateLimitExceeded, + 'An unexpected error occurred': ExchangeNotAvailable, // {"error":"An unexpected error occurred, please try again later (58BC21C795).","success":false} + 'Please retry request': ExchangeNotAvailable, // {"error":"Please retry request","success":false} + 'Please try again': ExchangeNotAvailable, // {"error":"Please try again","success":false} }, }, 'precisionMode': TICK_SIZE, @@ -65761,7 +71017,7 @@ module.exports = class ftx extends Exchange { 'amount': sizeIncrement, 'price': priceIncrement, }; - const entry = { + result.push ({ 'id': id, 'symbol': symbol, 'base': base, @@ -65788,8 +71044,7 @@ module.exports = class ftx extends Exchange { }, }, 'info': market, - }; - result.push (entry); + }); } return result; } @@ -66088,22 +71343,39 @@ module.exports = class ftx extends Exchange { // "type": "order" // } // + // { + // "baseCurrency": "BTC", + // "fee": 0, + // "feeCurrency": "USD", + // "feeRate": 0, + // "future": null, + // "id": 664079556, + // "liquidity": "taker", + // "market": null, + // "orderId": null, + // "price": 34830.61359, + // "quoteCurrency": "USD", + // "side": "sell", + // "size": 0.0005996, + // "time": "2021-01-15T16:05:29.246135+00:00", + // "tradeId": null, + // "type": "otc" + // } + // const id = this.safeString (trade, 'id'); const takerOrMaker = this.safeString (trade, 'liquidity'); const marketId = this.safeString (trade, 'market'); let symbol = undefined; - if (marketId !== undefined) { - if (marketId in this.markets_by_id) { - market = this.markets_by_id[marketId]; - symbol = market['symbol']; + if (marketId in this.markets_by_id) { + market = this.markets_by_id[marketId]; + symbol = market['symbol']; + } else { + const base = this.safeCurrencyCode (this.safeString (trade, 'baseCurrency')); + const quote = this.safeCurrencyCode (this.safeString (trade, 'quoteCurrency')); + if ((base !== undefined) && (quote !== undefined)) { + symbol = base + '/' + quote; } else { - const base = this.safeCurrencyCode (this.safeString (trade, 'baseCurrency')); - const quote = this.safeCurrencyCode (this.safeString (trade, 'quoteCurrency')); - if ((base !== undefined) && (quote !== undefined)) { - symbol = base + '/' + quote; - } else { - symbol = marketId; - } + symbol = marketId; } } const timestamp = this.parse8601 (this.safeString (trade, 'time')); @@ -66421,6 +71693,7 @@ module.exports = class ftx extends Exchange { const lastTradeTimestamp = this.parse8601 (this.safeString (order, 'triggeredAt')); const clientOrderId = this.safeString (order, 'clientId'); const stopPrice = this.safeFloat (order, 'triggerPrice'); + const postOnly = this.safeValue (order, 'postOnly'); return { 'info': order, 'id': id, @@ -66431,6 +71704,7 @@ module.exports = class ftx extends Exchange { 'symbol': symbol, 'type': type, 'timeInForce': undefined, + 'postOnly': postOnly, 'side': side, 'price': price, 'stopPrice': stopPrice, @@ -66568,12 +71842,12 @@ module.exports = class ftx extends Exchange { } } else { if (clientOrderId === undefined) { + method = 'privatePostOrdersOrderIdModify'; + request['order_id'] = id; + } else { method = 'privatePostOrdersByClientIdClientOrderIdModify'; request['client_order_id'] = clientOrderId; // request['clientId'] = clientOrderId; - } else { - method = 'privatePostOrdersOrderIdModify'; - request['order_id'] = id; } if (price !== undefined) { request['price'] = parseFloat (this.priceToPrecision (symbol, price)); @@ -66639,9 +71913,7 @@ module.exports = class ftx extends Exchange { async cancelOrder (id, symbol = undefined, params = {}) { await this.loadMarkets (); - const request = { - 'order_id': parseInt (id), - }; + const request = {}; // support for canceling conditional orders // https://github.com/ccxt/ccxt/issues/6669 const options = this.safeValue (this.options, 'cancelOrder', {}); @@ -66674,8 +71946,8 @@ module.exports = class ftx extends Exchange { await this.loadMarkets (); const request = { // 'market': market['id'], // optional - 'conditionalOrdersOnly': false, // cancel conditional orders only - 'limitOrdersOnly': false, // cancel existing limit orders (non-conditional orders) only + // 'conditionalOrdersOnly': false, // cancel conditional orders only + // 'limitOrdersOnly': false, // cancel existing limit orders (non-conditional orders) only }; const marketId = this.getMarketId (symbol, 'market', params); if (marketId !== undefined) { @@ -66844,6 +72116,7 @@ module.exports = class ftx extends Exchange { } if (since !== undefined) { request['start_time'] = parseInt (since / 1000); + request['end_time'] = this.seconds (); } const response = await this.privateGetFills (this.extend (request, params)); // @@ -67033,6 +72306,15 @@ module.exports = class ftx extends Exchange { // "txid": "0x8078356ae4b06a036d64747546c274af19581f1c78c510b60505798a7ffcaf1" // } // + // { + // "coin": 'BTC', + // "id": 1969806, + // "notes": 'Transfer to Dd6gi7m2Eg4zzBbPAxuwfEaHs6tYvyUX5hbPpsTcNPXo', + // "size": 0.003, + // "status": 'complete', + // "time": '2021-02-03T20:28:54.918146+00:00' + // } + // const code = this.safeCurrencyCode (this.safeString (transaction, 'coin')); const id = this.safeString (transaction, 'id'); const amount = this.safeFloat (transaction, 'size'); @@ -67045,8 +72327,14 @@ module.exports = class ftx extends Exchange { tag = this.safeString (address, 'tag'); address = this.safeString (address, 'address'); } + if (address === undefined) { + // parse address from internal transfer + const notes = this.safeString (transaction, 'notes'); + if (notes !== undefined) { + address = notes.slice (12); + } + } const fee = this.safeFloat (transaction, 'fee'); - const type = ('destinationName' in transaction) ? 'withdrawal' : 'deposit'; return { 'info': transaction, 'id': id, @@ -67059,7 +72347,7 @@ module.exports = class ftx extends Exchange { 'tagFrom': undefined, 'tag': tag, 'tagTo': tag, - 'type': type, + 'type': undefined, 'amount': amount, 'currency': code, 'status': status, @@ -67097,7 +72385,7 @@ module.exports = class ftx extends Exchange { if (code !== undefined) { currency = this.currency (code); } - return this.parseTransactions (result, currency, since, limit); + return this.parseTransactions (result, currency, since, limit, { 'type': 'deposit' }); } async fetchWithdrawals (code = undefined, since = undefined, limit = undefined, params = {}) { @@ -67124,7 +72412,7 @@ module.exports = class ftx extends Exchange { if (code !== undefined) { currency = this.currency (code); } - return this.parseTransactions (result, currency, since, limit); + return this.parseTransactions (result, currency, since, limit, { 'type': 'withdrawal' }); } sign (path, api = 'public', method = 'GET', params = {}, headers = undefined, body = undefined) { @@ -67181,7 +72469,7 @@ module.exports = class ftx extends Exchange { } }; -},{"./base/Exchange":5,"./base/errors":7,"./base/functions/number":13}],86:[function(require,module,exports){ +},{"./base/Exchange":6,"./base/errors":8,"./base/functions/number":14}],89:[function(require,module,exports){ 'use strict'; // --------------------------------------------------------------------------- @@ -67351,6 +72639,7 @@ module.exports = class gateio extends Exchange { 'BOX': 'DefiBox', 'BTCBEAR': 'BEAR', 'BTCBULL': 'BULL', + 'SBTC': 'Super Bitcoin', 'TNC': 'Trinity Network Credit', }, }); @@ -67874,6 +73163,7 @@ module.exports = class gateio extends Exchange { 'symbol': symbol, 'type': 'limit', 'timeInForce': undefined, + 'postOnly': undefined, 'side': side, 'price': price, 'stopPrice': undefined, @@ -67914,7 +73204,7 @@ module.exports = class gateio extends Exchange { async cancelOrder (id, symbol = undefined, params = {}) { if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' cancelOrder requires symbol argument'); + throw new ArgumentsRequired (this.id + ' cancelOrder() requires symbol argument'); } await this.loadMarkets (); const request = { @@ -67937,13 +73227,13 @@ module.exports = class gateio extends Exchange { if ((address !== undefined) && (address.indexOf ('address') >= 0)) { throw new InvalidAddress (this.id + ' queryDepositAddress ' + address); } - if (code === 'XRP') { + if ((code === 'XRP') || (code === 'HBAR') || (code === 'STEEM') || (code === 'XLM') || (code === 'EOS')) { const parts = address.split (' '); address = parts[0]; tag = parts[1]; } return { - 'currency': currency, + 'currency': code, 'address': address, 'tag': tag, 'info': response, @@ -67970,7 +73260,7 @@ module.exports = class gateio extends Exchange { async fetchOrderTrades (id, symbol = undefined, since = undefined, limit = undefined, params = {}) { if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' fetchMyTrades requires a symbol argument'); + throw new ArgumentsRequired (this.id + ' fetchOrderTrades() requires a symbol argument'); } await this.loadMarkets (); const market = this.market (symbol); @@ -67984,7 +73274,7 @@ module.exports = class gateio extends Exchange { async fetchMyTrades (symbol = undefined, since = undefined, limit = undefined, params = {}) { if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' fetchMyTrades requires symbol argument'); + throw new ArgumentsRequired (this.id + ' fetchMyTrades() requires symbol argument'); } await this.loadMarkets (); const market = this.market (symbol); @@ -68066,21 +73356,21 @@ module.exports = class gateio extends Exchange { // withdrawal // // { - // 'id': 'w5864259', - // 'currency': 'ETH', - // 'address': '0x72632f462....', - // 'amount': '0.4947', - // 'txid': '0x111167d120f736....', - // 'timestamp': '1553123688', - // 'status': 'DONE', - // 'type': 'withdrawal' - // } + // "id": "w6754336", + // "fee": "0.1", + // "txid": "zzyy", + // "amount": "1", + // "status": "DONE", + // "address": "tz11234", + // "currency": "XTZ", + // "timestamp": "1561030206" + // } // const currencyId = this.safeString (transaction, 'currency'); const code = this.safeCurrencyCode (currencyId, currency); const id = this.safeString (transaction, 'id'); const txid = this.safeString (transaction, 'txid'); - const amount = this.safeFloat (transaction, 'amount'); + let amount = this.safeFloat (transaction, 'amount'); let address = this.safeString (transaction, 'address'); if (address === 'false') { address = undefined; @@ -68088,6 +73378,17 @@ module.exports = class gateio extends Exchange { const timestamp = this.safeTimestamp (transaction, 'timestamp'); const status = this.parseTransactionStatus (this.safeString (transaction, 'status')); const type = this.parseTransactionType (id[0]); + const feeCost = this.safeFloat (transaction, 'fee'); + let fee = undefined; + if (feeCost !== undefined) { + fee = { + 'currency': code, + 'cost': feeCost, + }; + if (amount !== undefined) { + amount = amount - feeCost; + } + } return { 'info': transaction, 'id': id, @@ -68100,7 +73401,7 @@ module.exports = class gateio extends Exchange { 'type': type, 'timestamp': timestamp, 'datetime': this.iso8601 (timestamp), - 'fee': undefined, + 'fee': fee, }; } @@ -68166,7 +73467,7 @@ module.exports = class gateio extends Exchange { } }; -},{"./base/Exchange":5,"./base/errors":7}],87:[function(require,module,exports){ +},{"./base/Exchange":6,"./base/errors":8}],90:[function(require,module,exports){ 'use strict'; // --------------------------------------------------------------------------- @@ -68838,6 +74139,7 @@ module.exports = class gemini extends Exchange { 'symbol': symbol, 'type': type, 'timeInForce': undefined, + 'postOnly': undefined, 'side': side, 'price': price, 'stopPrice': undefined, @@ -68901,7 +74203,7 @@ module.exports = class gemini extends Exchange { async fetchMyTrades (symbol = undefined, since = undefined, limit = undefined, params = {}) { if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' fetchMyTrades requires a symbol argument'); + throw new ArgumentsRequired (this.id + ' fetchMyTrades() requires a symbol argument'); } await this.loadMarkets (); const market = this.market (symbol); @@ -69078,7 +74380,1356 @@ module.exports = class gemini extends Exchange { } }; -},{"./base/Exchange":5,"./base/errors":7,"./base/functions/number":13}],88:[function(require,module,exports){ +},{"./base/Exchange":6,"./base/errors":8,"./base/functions/number":14}],91:[function(require,module,exports){ +'use strict'; + +// --------------------------------------------------------------------------- + +const Exchange = require ('./base/Exchange'); +const { ExchangeError, InvalidOrder, AuthenticationError, InsufficientFunds, BadSymbol, OrderNotFound, InvalidAddress, BadRequest } = require ('./base/errors'); +const { TRUNCATE, ROUND, TICK_SIZE } = require ('./base/functions/number'); + +// --------------------------------------------------------------------------- + +module.exports = class gopax extends Exchange { + describe () { + return this.deepExtend (super.describe (), { + 'id': 'gopax', + 'name': 'GOPAX', + 'countries': [ 'KR' ], // South Korea + 'version': 'v1', + 'rateLimit': 50, + 'hostname': 'gopax.co.kr', // or 'gopax.com' + 'certified': true, + 'pro': true, + 'has': { + 'cancelOrder': true, + 'createMarketOrder': true, + 'createOrder': true, + 'fetchBalance': true, + 'fetchCurrencies': true, + 'fetchDepositAddress': 'emulated', + 'fetchDepositAddresses': true, + 'fetchMarkets': true, + 'fetchMyTrades': true, + 'fetchOHLCV': true, + 'fetchOpenOrders': true, + 'fetchOrder': true, + 'fetchOrderBook': true, + 'fetchOrders': true, + 'fetchTicker': true, + 'fetchTickers': true, + 'fetchTime': true, + 'fetchTrades': true, + 'fetchTransactions': true, + }, + 'timeframes': { + '1m': '1', + '5m': '5', + '30m': '30', + '1d': '1440', + }, + 'urls': { + 'logo': 'https://user-images.githubusercontent.com/1294454/102897212-ae8a5e00-4478-11eb-9bab-91507c643900.jpg', + 'api': { + 'public': 'https://api.{hostname}', // or 'https://api.gopax.co.kr' + 'private': 'https://api.{hostname}', + }, + 'www': 'https://www.gopax.co.kr', + 'doc': 'https://gopax.github.io/API/index.en.html', + 'fees': 'https://www.gopax.com/feeinfo', + }, + 'api': { + 'public': { + 'get': [ + 'notices', + 'assets', + 'price-tick-size', + 'trading-pairs', + 'trading-pairs/{tradingPair}/ticker', + 'trading-pairs/{tradingPair}/book', + 'trading-pairs/{tradingPair}/trades', + 'trading-pairs/{tradingPair}/stats', + 'trading-pairs/{tradingPair}/price-tick-size', + 'trading-pairs/stats', + 'trading-pairs/{tradingPair}/candles', + 'time', + ], + }, + 'private': { + 'get': [ + 'balances', + 'balances/{assetName}', + 'orders', + 'orders/{orderId}', + 'orders/clientOrderId/{clientOrderId}', + 'trades', + 'deposit-withdrawal-status', + 'crypto-deposit-addresses', + 'crypto-withdrawal-addresses', + ], + 'post': [ + 'orders', + ], + 'delete': [ + 'orders/{orderId}', + 'orders/clientOrderId/{clientOrderId}', + ], + }, + }, + 'fees': { + 'trading': { + 'percentage': true, + 'tierBased': false, + 'maker': 0.04 / 100, + 'taker': 0.04 / 100, + }, + }, + 'exceptions': { + 'broad': { + 'ERROR_INVALID_ORDER_TYPE': InvalidOrder, + 'ERROR_INVALID_AMOUNT': InvalidOrder, + 'ERROR_INVALID_TRADING_PAIR': BadSymbol, // Unlikely to be triggered, due to ccxt.gopax.js implementation + 'No such order ID': OrderNotFound, // {"errorMessage":"No such order ID","errorCode":202,"errorData":"Order server error: 202"} + // 'Not enough amount': InsufficientFunds, // {"errorMessage":"Not enough amount, try increasing your order amount","errorCode":10212,"errorData":{}} + 'Forbidden order type': InvalidOrder, + 'the client order ID will be reusable which order has already been completed or canceled': InvalidOrder, + 'ERROR_NO_SUCH_TRADING_PAIR': BadSymbol, // Unlikely to be triggered, due to ccxt.gopax.js implementation + 'ERROR_INVALID_ORDER_SIDE': InvalidOrder, + 'ERROR_NOT_HEDGE_TOKEN_USER': InvalidOrder, + 'ORDER_EVENT_ERROR_NOT_ALLOWED_BID_ORDER': InvalidOrder, // Triggered only when the exchange is locked + 'ORDER_EVENT_ERROR_INSUFFICIENT_BALANCE': InsufficientFunds, + 'Invalid option combination': InvalidOrder, + 'No such client order ID': OrderNotFound, + }, + 'exact': { + '100': BadSymbol, // Invalid asset name + '101': BadSymbol, // Invalid trading pair + '103': InvalidOrder, // Invalid order type + '104': BadSymbol, // Invalid trading pair + '105': BadSymbol, // Trading pair temporarily disabled + '106': BadSymbol, // Invalid asset name + '107': InvalidOrder, // Invalid order amount + '108': InvalidOrder, // Invalid order price + '111': InvalidOrder, // Invalid event type + '201': InsufficientFunds, // Not enough balance + '202': InvalidOrder, // Invalid order ID + '203': InvalidOrder, // Order amount X order price too large + '204': InvalidOrder, // Bid order temporarily unavailable + '205': InvalidOrder, // Invalid side + '206': InvalidOrder, // Invalid order option combination + '10004': AuthenticationError, // Not authorized + // '10004': ExchangeError, // API key not exist + // '10004': ExchangeError, // User KYC not approved + // '10004': ExchangeError, // User account is frozen + // '10004': ExchangeError, // User is under deactivation process + // '10004': ExchangeError, // 2FA is not enabled + // '10004': ExchangeError, // Invalid signature + '10041': BadRequest, // Invalid exchange + '10056': BadRequest, // No registered asset + '10057': BadSymbol, // No registered trading pair + '10059': BadSymbol, // Invalid trading pair + '10062': BadRequest, // Invalid chart interval + '10069': OrderNotFound, // {"errorMessage":"No such order ID: 73152094","errorCode":10069,"errorData":"73152094"} + '10155': AuthenticationError, // {"errorMessage":"Invalid API key","errorCode":10155} + '10166': BadRequest, // Invalid chart range + '10212': InvalidOrder, // {"errorMessage":"Not enough amount, try increasing your order amount","errorCode":10212,"errorData":{}} + '10221': OrderNotFound, // No such client order ID + '10222': InvalidOrder, // Client order ID being used + '10223': InvalidOrder, // Soon the client order ID will be reusable which order has already been completed or canceled + '10227': InvalidOrder, // Invalid client order ID format + '10319': BadRequest, // Pagination is required as you have too many orders + '10358': InvalidOrder, // Invalid order type + '10359': InvalidOrder, // Invalid order side + '10360': InvalidOrder, // Invalid order status + '10361': InvalidOrder, // Invalid order time in force + '10362': InvalidOrder, // Invalid order protection + '10363': InvalidOrder, // Invalid forced completion reason + }, + }, + 'options': { + 'createMarketBuyOrderRequiresPrice': true, + }, + }); + } + + async fetchTime (params = {}) { + const response = await this.publicGetTime (params); + // + // {"serverTime":1608327726656} + // + return this.safeInteger (response, 'serverTime'); + } + + async fetchMarkets (params = {}) { + const response = await this.publicGetTradingPairs (params); + // + // [ + // { + // "id":1, + // "name":"ETH-KRW", + // "baseAsset":"ETH", + // "quoteAsset":"KRW", + // "baseAssetScale":8, + // "quoteAssetScale":0, + // "priceMin":1, + // "restApiOrderAmountMin":{ + // "limitAsk":{"amount":10000,"unit":"KRW"}, + // "limitBid":{"amount":10000,"unit":"KRW"}, + // "marketAsk":{"amount":0.001,"unit":"ETH"}, + // "marketBid":{"amount":10000,"unit":"KRW"}, + // }, + // "makerFeePercent":0.2, + // "takerFeePercent":0.2, + // }, + // ] + // + const result = []; + for (let i = 0; i < response.length; i++) { + const market = response[i]; + const id = this.safeString (market, 'name'); + const numericId = this.safeInteger (market, 'id'); + const baseId = this.safeString (market, 'baseAsset'); + const quoteId = this.safeString (market, 'quoteAsset'); + const base = this.safeCurrencyCode (baseId); + const quote = this.safeCurrencyCode (quoteId); + const symbol = base + '/' + quote; + const precision = { + 'price': this.safeInteger (market, 'quoteAssetScale'), + 'amount': this.safeInteger (market, 'baseAssetScale'), + }; + const minimums = this.safeValue (market, 'restApiOrderAmountMin', {}); + const marketAsk = this.safeValue (minimums, 'marketAsk', {}); + const marketBid = this.safeValue (minimums, 'marketBid', {}); + const takerFeePercent = this.safeFloat (market, 'takerFeePercent'); + const makerFeePercent = this.safeFloat (market, 'makerFeePercent'); + const taker = parseFloat (this.decimalToPrecision (takerFeePercent / 100, ROUND, 0.00000001, TICK_SIZE)); + const maker = parseFloat (this.decimalToPrecision (makerFeePercent / 100, ROUND, 0.00000001, TICK_SIZE)); + result.push ({ + 'id': id, + 'info': market, + 'numericId': numericId, + 'symbol': symbol, + 'base': base, + 'quote': quote, + 'baseId': this.safeString (market, 'baseAsset'), + 'quoteId': this.safeString (market, 'quoteAsset'), + 'active': true, + 'taker': taker, + 'maker': maker, + 'precision': precision, + 'limits': { + 'amount': { + 'min': this.safeFloat (marketAsk, 'amount'), + 'max': undefined, + }, + 'price': { + 'min': this.safeFloat (market, 'priceMin'), + 'max': undefined, + }, + 'cost': { + 'min': this.safeFloat (marketBid, 'amount'), + 'max': undefined, + }, + }, + }); + } + return result; + } + + async fetchCurrencies (params = {}) { + const response = await this.publicGetAssets (params); + // + // [ + // { + // "id":"KRW", + // "name":"대한민국 원", + // "scale":0, + // "withdrawalFee":1000, + // "withdrawalAmountMin":5000 + // }, + // { + // "id":"ETH", + // "name":"이더리움", + // "scale":8, + // "withdrawalFee":0.03, + // "withdrawalAmountMin":0.015 + // }, + // ] + // + const result = {}; + for (let i = 0; i < response.length; i++) { + const currency = response[i]; + const id = this.safeString (currency, 'id'); + const code = this.safeCurrencyCode (id); + const name = this.safeString (currency, 'name'); + const fee = this.safeFloat (currency, 'withdrawalFee'); + const precision = this.safeFloat (currency, 'scale'); + result[code] = { + 'id': id, + 'info': currency, + 'code': code, + 'name': name, + 'active': true, + 'fee': fee, + 'precision': precision, + 'limits': { + 'amount': { + 'min': undefined, + 'max': undefined, + }, + 'price': { + 'min': undefined, + 'max': undefined, + }, + 'cost': { + 'min': undefined, + 'max': undefined, + }, + 'withdraw': { + 'min': this.safeFloat (currency, 'withdrawalAmountMin'), + 'max': undefined, + }, + }, + }; + } + return result; + } + + async fetchOrderBook (symbol, limit = undefined, params = {}) { + await this.loadMarkets (); + const market = this.market (symbol); + const request = { + 'tradingPair': market['id'], + // 'level': 3, // 1 best bidask, 2 top 50 bidasks, 3 all bidasks + }; + const response = await this.publicGetTradingPairsTradingPairBook (this.extend (request, params)); + // + // { + // "sequence":17691957, + // "bid":[ + // ["17690499",25019000,0.00008904,"1608326468921"], + // ["17691894",25010000,0.4295,"1608326499940"], + // ["17691895",25009000,0.2359,"1608326499953"], + // ], + // "ask":[ + // ["17689176",25024000,0.000098,"1608326442006"], + // ["17691351",25031000,0.206,"1608326490418"], + // ["17691571",25035000,0.3996,"1608326493742"], + // ] + // } + // + const nonce = this.safeInteger (response, 'sequence'); + const result = this.parseOrderBook (response, undefined, 'bid', 'ask', 1, 2); + result['nonce'] = nonce; + return result; + } + + parseTicker (ticker, market = undefined) { + // + // fetchTicker + // + // { + // "price":25087000, + // "ask":25107000, + // "askVolume":0.05837704, + // "bid":25087000, + // "bidVolume":0.00398628, + // "volume":350.09171591, + // "quoteVolume":8721016926.06529, + // "time":"2020-12-18T21:42:13.774Z", + // } + // + // fetchTickers + // + // { + // "name":"ETH-KRW", + // "open":690500, + // "high":719500, + // "low":681500, + // "close":709500, + // "volume":2784.6081544, + // "time":"2020-12-18T21:54:50.795Z" + // } + // + const marketId = this.safeString (ticker, 'name'); + const symbol = this.safeSymbol (marketId, market, '-'); + const timestamp = this.parse8601 (this.safeString (ticker, 'time')); + const open = this.safeFloat (ticker, 'open'); + const last = this.safeFloat2 (ticker, 'price', 'close'); + let change = undefined; + let percentage = undefined; + let average = undefined; + if ((last !== undefined) && (open !== undefined)) { + average = this.sum (last, open) / 2; + change = last - open; + if (open > 0) { + percentage = change / open * 100; + } + } + const baseVolume = this.safeFloat (ticker, 'volume'); + const quoteVolume = this.safeFloat (ticker, 'quoteVolume'); + const vwap = this.vwap (baseVolume, quoteVolume); + return { + 'symbol': symbol, + 'info': ticker, + 'timestamp': timestamp, + 'datetime': this.iso8601 (timestamp), + 'high': this.safeFloat (ticker, 'high'), + 'low': this.safeFloat (ticker, 'low'), + 'bid': this.safeFloat (ticker, 'bid'), + 'bidVolume': this.safeFloat (ticker, 'bidVolume'), + 'ask': this.safeFloat (ticker, 'ask'), + 'askVolume': this.safeFloat (ticker, 'askVolume'), + 'vwap': vwap, + 'open': open, + 'close': last, + 'last': last, + 'previousClose': undefined, + 'change': change, + 'percentage': percentage, + 'average': average, + 'baseVolume': baseVolume, + 'quoteVolume': quoteVolume, + }; + } + + async fetchTicker (symbol, params = {}) { + await this.loadMarkets (); + const market = this.market (symbol); + const request = { + 'tradingPair': market['id'], + }; + const response = await this.publicGetTradingPairsTradingPairTicker (this.extend (request, params)); + // + // { + // "price":25087000, + // "ask":25107000, + // "askVolume":0.05837704, + // "bid":25087000, + // "bidVolume":0.00398628, + // "volume":350.09171591, + // "quoteVolume":8721016926.06529, + // "time":"2020-12-18T21:42:13.774Z", + // } + // + return this.parseTicker (response, market); + } + + parseTickers (rawTickers, symbols = undefined) { + const tickers = []; + for (let i = 0; i < rawTickers.length; i++) { + tickers.push (this.parseTicker (rawTickers[i])); + } + return this.filterByArray (tickers, 'symbol', symbols); + } + + async fetchTickers (symbols = undefined, params = {}) { + await this.loadMarkets (); + const response = await this.publicGetTradingPairsStats (params); + // + // [ + // { + // "name":"ETH-KRW", + // "open":690500, + // "high":719500, + // "low":681500, + // "close":709500, + // "volume":2784.6081544, + // "time":"2020-12-18T21:54:50.795Z" + // } + // ] + // + return this.parseTickers (response, symbols); + } + + parsePublicTrade (trade, market = undefined) { + const timestamp = this.parse8601 (this.safeString (trade, 'time')); + const price = this.safeFloat (trade, 'price'); + const amount = this.safeFloat (trade, 'amount'); + let symbol = undefined; + if ('symbol' in market) { + symbol = this.safeString (market, 'symbol'); + } + return { + 'info': trade, + 'id': this.safeString (trade, 'id'), + 'timestamp': timestamp, + 'datetime': this.iso8601 (timestamp), + 'symbol': symbol, + 'order': undefined, // Not mandatory to specify + 'type': undefined, // Not mandatory to specify + 'side': this.safeString (trade, 'side'), + 'takerOrMaker': undefined, + 'price': price, + 'amount': amount, + 'cost': price * amount, + 'fee': undefined, + }; + } + + parsePrivateTrade (trade, market = undefined) { + const timestamp = this.parse8601 (this.safeString (trade, 'timestamp')); + const symbol = this.safeString (trade, 'tradingPairName').replace ('-', '/'); + const side = this.safeString (trade, 'side'); + const price = this.safeFloat (trade, 'price'); + const amount = this.safeFloat (trade, 'baseAmount'); + let feeCurrency = symbol.slice (0, 3); + if (side === 'sell') { + feeCurrency = symbol.slice (4); + } + const fee = { + 'cost': this.safeFloat (trade, 'fee'), + 'currency': feeCurrency, + 'rate': undefined, + }; + return { + 'info': trade, + 'id': this.safeString (trade, 'id'), + 'timestamp': timestamp, + 'datetime': this.iso8601 (timestamp), + 'symbol': symbol, + 'order': this.safeInteger (trade, 'orderId'), + 'type': undefined, + 'side': side, + 'takerOrMaker': this.safeString (trade, 'position'), + 'price': price, + 'amount': amount, + 'cost': price * amount, + 'fee': fee, + }; + } + + parseTrade (trade, market = undefined) { + // + // public fetchTrades + // + // { + // "time":"2020-12-19T12:17:43.000Z", + // "date":1608380263, + // "id":23903608, + // "price":25155000, + // "amount":0.0505, + // "side":"sell", + // } + // + // private fetchMyTrades + // + // { + // "id": 73953, // trading event ID + // "orderId": 453324, // order ID + // "baseAmount": 3, // traded base asset amount + // "quoteAmount": 3000000, // traded quote asset amount + // "fee": 0.0012, // fee + // "price": 1000000, // price + // "timestamp": "2020-09-25T04:06:30.000Z", // trading time + // "side": "buy", // buy, sell + // "tradingPairName": "ZEC-KRW", // order book + // "position": "maker" // maker, taker + // } + // + // { + // "tradeId": 74072, // trade ID + // "orderId": 453529, // order ID + // "side": 2, // 1(bid), 2(ask) + // "type": 1, // 1(limit), 2(market) + // "baseAmount": 0.01, // filled base asset amount (in ZEC for this case) + // "quoteAmount": 1, // filled quote asset amount (in KRW for this case) + // "fee": 0.0004, // fee + // "price": 100, // price + // "isSelfTrade": false, // whether both of matching orders are yours + // "occurredAt": 1603932107, // trade occurrence time + // "tradingPairName": "ZEC-KRW" // order book + // } + // + const id = this.safeString2 (trade, 'id', 'tradeId'); + const orderId = this.safeInteger (trade, 'orderId'); + let timestamp = this.parse8601 (this.safeString2 (trade, 'time', 'timestamp')); + timestamp = this.safeTimestamp (trade, 'occuredAt', timestamp); + const marketId = this.safeString (trade, 'tradingPairName'); + market = this.safeMarket (marketId, market, '-'); + const symbol = market['symbol']; + let side = this.safeString (trade, 'side'); + if (side === '1') { + side = 'buy'; + } else if (side === '2') { + side = 'sell'; + } + let type = this.safeString (trade, 'type'); + if (type === '1') { + type = 'limit'; + } else if (type === '2') { + type = 'market'; + } + const price = this.safeFloat (trade, 'price'); + const amount = this.safeFloat2 (trade, 'amount', 'baseAmount'); + let cost = this.safeFloat (trade, 'quoteAmount'); + if (cost === undefined) { + if ((price !== undefined) && (amount !== undefined)) { + cost = price * amount; + } + } + const feeCost = this.safeFloat (trade, 'fee'); + let fee = undefined; + if (feeCost !== undefined) { + fee = { + 'cost': feeCost, + 'currency': market['base'], + }; + } + const takerOrMaker = this.safeString (trade, 'position'); + return { + 'info': trade, + 'id': id, + 'timestamp': timestamp, + 'datetime': this.iso8601 (timestamp), + 'symbol': symbol, + 'order': orderId, + 'type': undefined, + 'side': side, + 'takerOrMaker': takerOrMaker, + 'price': price, + 'amount': amount, + 'cost': cost, + 'fee': fee, + }; + } + + async fetchTrades (symbol, since = undefined, limit = undefined, params = {}) { + await this.loadMarkets (); + const market = this.market (symbol); + const request = { + 'tradingPair': market['id'], + // 'limit': limit, + // 'pastmax': id, // read data older than this ID + // 'latestmin': id, // read data newer than this ID + // 'after': parseInt (since / 1000), + // 'before': this.seconds (), + }; + if (since !== undefined) { + request['after'] = parseInt (since / 1000); + } + if (limit !== undefined) { + request['limit'] = limit; + } + const response = await this.publicGetTradingPairsTradingPairTrades (this.extend (request, params)); + // + // [ + // {"time":"2020-12-19T12:17:43.000Z","date":1608380263,"id":23903608,"price":25155000,"amount":0.0505,"side":"sell"}, + // {"time":"2020-12-19T12:17:13.000Z","date":1608380233,"id":23903604,"price":25140000,"amount":0.019,"side":"sell"}, + // {"time":"2020-12-19T12:16:49.000Z","date":1608380209,"id":23903599,"price":25140000,"amount":0.0072,"side":"sell"}, + // ] + // + return this.parseTrades (response, market, since, limit); + } + + parseOHLCV (ohlcv, market = undefined) { + // + // [ + // 1606780800000, // timestamp + // 21293000, // low + // 21300000, // high + // 21294000, // open + // 21300000, // close + // 1.019126, // volume + // ] + // + return [ + this.safeInteger (ohlcv, 0), + this.safeFloat (ohlcv, 3), + this.safeFloat (ohlcv, 2), + this.safeFloat (ohlcv, 1), + this.safeFloat (ohlcv, 4), + this.safeFloat (ohlcv, 5), + ]; + } + + async fetchOHLCV (symbol, timeframe = '1m', since = undefined, limit = undefined, params = {}) { + await this.loadMarkets (); + const market = this.market (symbol); + limit = (limit === undefined) ? 1024 : limit; // default 1024 + const request = { + 'tradingPair': market['id'], + // 'start': since, + // 'end': this.milliseconds (), + 'interval': this.timeframes[timeframe], + }; + const duration = this.parseTimeframe (timeframe); + if (since === undefined) { + const end = this.milliseconds (); + request['end'] = end; + request['start'] = end - limit * duration * 1000; + } else { + request['start'] = since; + request['end'] = this.sum (since, limit * duration * 1000); + } + const response = await this.publicGetTradingPairsTradingPairCandles (this.extend (request, params)); + // + // [ + // [1606780800000,21293000,21300000,21294000,21300000,1.019126], + // [1606780860000,21237000,21293000,21293000,21263000,0.96800057], + // [1606780920000,21240000,21240000,21240000,21240000,0.11068715], + // ] + // + return this.parseOHLCVs (response, market, timeframe, since, limit); + } + + parseBalanceResponse (response) { + const result = { 'info': response }; + for (let i = 0; i < response.length; i++) { + const balance = response[i]; + const currencyId = this.safeString2 (balance, 'asset', 'isoAlpha3'); + const code = this.safeCurrencyCode (currencyId); + const hold = this.safeFloat (balance, 'hold'); + const pendingWithdrawal = this.safeFloat (balance, 'pendingWithdrawal'); + const account = this.account (); + account['free'] = this.safeFloat (balance, 'avail'); + account['used'] = this.sum (hold, pendingWithdrawal); + result[code] = account; + } + return this.parseBalance (result); + } + + async fetchBalance (params = {}) { + await this.loadMarkets (); + const response = await this.privateGetBalances (params); + // + // [ + // { + // "asset": "KRW", // asset name + // "avail": 1759466.76, // available amount to place order + // "hold": 16500, // outstanding amount on order books + // "pendingWithdrawal": 0, // amount being withdrawn + // "lastUpdatedAt": "1600684352032", // balance last update time + // }, + // ] + // + return this.parseBalanceResponse (response); + } + + parseOrderStatus (status) { + const statuses = { + 'placed': 'open', + 'cancelled': 'canceled', + 'completed': 'closed', + 'updated': 'open', + 'reserved': 'open', + }; + return this.safeString (statuses, status, status); + } + + parseOrder (order, market = undefined) { + // + // cancelOrder + // + // {} // empty object + // + // fetchOrder, fetchOrders, fetchOpenOrders, createOrder + // + // { + // "id": "453324", // order ID + // "clientOrderId": "zeckrw23456", // client order ID (showed only when it exists) + // "status": "updated", // placed, cancelled, completed, updated, reserved + // "forcedCompletionReason": undefined, // the reason in case it was canceled in the middle (protection or timeInForce) + // "tradingPairName": "ZEC-KRW", // order book + // "side": "buy", // buy, sell + // "type": "limit", // limit, market + // "price": 1000000, // price + // "stopPrice": undefined, // stop price (showed only for stop orders) + // "amount": 4, // initial amount + // "remaining": 1, // outstanding amount + // "protection": "yes", // whether protection is activated (yes or no) + // "timeInForce": "gtc", // limit order's time in force (gtc/po/ioc/fok) + // "createdAt": "2020-09-25T04:06:20.000Z", // order placement time + // "updatedAt": "2020-09-25T04:06:29.000Z", // order last update time + // "balanceChange": { + // "baseGross": 3, // base asset balance's gross change (in ZEC for this case) + // "baseFee": { + // "taking": 0, // base asset fee imposed as taker + // "making": -0.0012 // base asset fee imposed as maker + // }, + // "baseNet": 2.9988, // base asset balance's net change (in ZEC for this case) + // "quoteGross": -3000000, // quote asset balance's gross change (in KRW for + // "quoteFee": { + // "taking": 0, // quote asset fee imposed as taker + // "making": 0 // quote asset fee imposed as maker + // }, + // "quoteNet": -3000000 // quote asset balance's net change (in KRW for this case) + // } + // } + // + const id = this.safeString (order, 'id'); + const clientOrderId = this.safeString (order, 'clientOrderId'); + const timestamp = this.parse8601 (this.safeString (order, 'createdAt')); + const type = this.safeString (order, 'type'); + const side = this.safeString (order, 'side'); + const timeInForce = this.safeStringUpper (order, 'timeInForce'); + const price = this.safeFloat (order, 'price'); + const amount = this.safeFloat (order, 'amount'); + const stopPrice = this.safeFloat (order, 'stopPrice'); + const remaining = this.safeFloat (order, 'remaining'); + const marketId = this.safeString (order, 'tradingPairName'); + market = this.safeMarket (marketId, market, '-'); + const status = this.parseOrderStatus (this.safeString (order, 'status')); + const balanceChange = this.safeValue (order, 'balanceChange', {}); + let filled = this.safeFloat (balanceChange, 'baseNet'); + let cost = this.safeFloat (balanceChange, 'quoteNet'); + if (cost !== undefined) { + cost = Math.abs (cost); + } + let updated = undefined; + if ((filled === undefined) && (amount !== undefined) && (remaining !== undefined)) { + filled = Math.max (0, amount - remaining); + } + if ((filled !== undefined) && (filled > 0)) { + updated = this.parse8601 (this.safeString (order, 'updatedAt')); + } + if ((cost === undefined) && (price !== undefined) && (filled !== undefined)) { + cost = filled * price; + } + let fee = undefined; + if (side === 'buy') { + const baseFee = this.safeValue (balanceChange, 'baseFee', {}); + const taking = this.safeFloat (baseFee, 'taking'); + const making = this.safeFloat (baseFee, 'making'); + fee = { + 'currency': market['base'], + 'cost': this.sum (taking, making), + }; + } else { + const quoteFee = this.safeValue (balanceChange, 'quoteFee', {}); + const taking = this.safeFloat (quoteFee, 'taking'); + const making = this.safeFloat (quoteFee, 'making'); + fee = { + 'currency': market['quote'], + 'cost': this.sum (taking, making), + }; + } + let postOnly = undefined; + if (timeInForce !== undefined) { + postOnly = (timeInForce === 'PO'); + } + return { + 'id': id, + 'clientOrderId': clientOrderId, + 'datetime': this.iso8601 (timestamp), + 'timestamp': timestamp, + 'lastTradeTimestamp': updated, + 'status': status, + 'symbol': market['symbol'], + 'type': type, + 'timeInForce': timeInForce, + 'postOnly': postOnly, + 'side': side, + 'price': price, + 'stopPrice': stopPrice, + 'average': undefined, + 'amount': amount, + 'filled': filled, + 'remaining': remaining, + 'cost': cost, + 'trades': undefined, + 'fee': fee, + 'info': order, + }; + } + + async fetchOrder (id, symbol = undefined, params = {}) { + await this.loadMarkets (); + let method = undefined; + const clientOrderId = this.safeString (params, 'clientOrderId'); + params = this.omit (params, 'clientOrderId'); + const request = {}; + if (clientOrderId === undefined) { + method = 'privateGetOrdersOrderId'; + request['orderId'] = id; + } else { + method = 'privateGetOrdersClientOrderIdClientOrderId'; + request['clientOrderId'] = clientOrderId; + } + const response = await this[method] (this.extend (request, params)); + // + // { + // "id": "453324", // order ID + // "clientOrderId": "zeckrw23456", // client order ID (showed only when it exists) + // "status": "updated", // placed, cancelled, completed, updated, reserved + // "forcedCompletionReason": undefined, // the reason in case it was canceled in the middle (protection or timeInForce) + // "tradingPairName": "ZEC-KRW", // order book + // "side": "buy", // buy, sell + // "type": "limit", // limit, market + // "price": 1000000, // price + // "stopPrice": undefined, // stop price (showed only for stop orders) + // "amount": 4, // initial amount + // "remaining": 1, // outstanding amount + // "protection": "yes", // whether protection is activated (yes or no) + // "timeInForce": "gtc", // limit order's time in force (gtc/po/ioc/fok) + // "createdAt": "2020-09-25T04:06:20.000Z", // order placement time + // "updatedAt": "2020-09-25T04:06:29.000Z", // order last update time + // "balanceChange": { + // "baseGross": 3, // base asset balance's gross change (in ZEC for this case) + // "baseFee": { + // "taking": 0, // base asset fee imposed as taker + // "making": -0.0012 // base asset fee imposed as maker + // }, + // "baseNet": 2.9988, // base asset balance's net change (in ZEC for this case) + // "quoteGross": -3000000, // quote asset balance's gross change (in KRW for + // "quoteFee": { + // "taking": 0, // quote asset fee imposed as taker + // "making": 0 // quote asset fee imposed as maker + // }, + // "quoteNet": -3000000 // quote asset balance's net change (in KRW for this case) + // } + // } + // + return this.parseOrder (response); + } + + async fetchOrders (symbol = undefined, since = undefined, limit = undefined, params = {}) { + await this.loadMarkets (); + const request = { + 'includePast': 'true', // if true, completed and canceled orders are included as the result, they are accessible for one hour only from its completion or cancellation time + // 'pagination': 'false', // if the result is more than 3,000 orders, set this value as true to access 1000 orders at max per each page + }; + let market = undefined; + if (symbol !== undefined) { + market = this.market (symbol); + } + const response = await this.privateGetOrders (this.extend (request, params)); + // + // [ + // { + // "id": "453324", // order ID + // "clientOrderId": "zeckrw23456", // client order ID (showed only when it exists) + // "status": "updated", // placed, cancelled, completed, updated, reserved + // "forcedCompletionReason": undefined, // the reason in case it was canceled in the middle (protection or timeInForce) + // "tradingPairName": "ZEC-KRW", // order book + // "side": "buy", // buy, sell + // "type": "limit", // limit, market + // "price": 1000000, // price + // "stopPrice": undefined, // stop price (showed only for stop orders) + // "amount": 4, // initial amount + // "remaining": 1, // outstanding amount + // "protection": "yes", // whether protection is activated (yes or no) + // "timeInForce": "gtc", // limit order's time in force (gtc/po/ioc/fok) + // "createdAt": "2020-09-25T04:06:20.000Z", // order placement time + // "updatedAt": "2020-09-25T04:06:29.000Z", // order last update time + // "balanceChange": { + // "baseGross": 3, // base asset balance's gross change (in ZEC for this case) + // "baseFee": { + // "taking": 0, // base asset fee imposed as taker + // "making": -0.0012 // base asset fee imposed as maker + // }, + // "baseNet": 2.9988, // base asset balance's net change (in ZEC for this case) + // "quoteGross": -3000000, // quote asset balance's gross change (in KRW for + // "quoteFee": { + // "taking": 0, // quote asset fee imposed as taker + // "making": 0 // quote asset fee imposed as maker + // }, + // "quoteNet": -3000000 // quote asset balance's net change (in KRW for this case) + // } + // }, + // ] + // + return this.parseOrders (response, market, since, limit); + } + + async fetchOpenOrders (symbol = undefined, since = undefined, limit = undefined, params = {}) { + const request = { + 'includePast': 'false', + }; + return await this.fetchOrders (symbol, since, limit, this.extend (request, params)); + } + + async createOrder (symbol, type, side, amount, price = undefined, params = {}) { + await this.loadMarkets (); + const market = this.market (symbol); + const request = { + // 'clientOrderId': 'test4321', // max 20 characters of [a-zA-Z0-9_-] + 'tradingPairName': market['id'], + 'side': side, // buy, sell + 'type': type, // limit, market + // 'price': this.priceToPrecision (symbol, price), + // 'stopPrice': this.priceToPrecision (symbol, stopPrice), // optional, becomes a stop order if set + // 'amount': this.amountToPrecision (symbol, amount), + // 'protection': 'no', // whether protection is activated + // 'timeInForce': 'gtc', // gtc, po, ioc, fok + }; + if (type === 'limit') { + request['price'] = this.priceToPrecision (symbol, price); + request['amount'] = this.amountToPrecision (symbol, amount); + } else if (type === 'market') { + // for market buy it requires the amount of quote currency to spend + if (side === 'buy') { + let total = amount; + const createMarketBuyOrderRequiresPrice = this.safeValue (this.options, 'createMarketBuyOrderRequiresPrice', true); + if (createMarketBuyOrderRequiresPrice) { + if (price === undefined) { + throw new InvalidOrder (this.id + " createOrder() requires the price argument with market buy orders to calculate total order cost (amount to spend), where cost = amount * price. Supply a price argument to createOrder() call if you want the cost to be calculated for you from price and amount, or, alternatively, add .options['createMarketBuyOrderRequiresPrice'] = false and supply the total cost value in the 'amount' argument"); + } + total = price * amount; + } + const precision = market['precision']['price']; + request['amount'] = this.decimalToPrecision (total, TRUNCATE, precision, this.precisionMode); + } else { + request['amount'] = this.amountToPrecision (symbol, amount); + } + } + const clientOrderId = this.safeString (params, 'clientOrderId'); + if (clientOrderId !== undefined) { + request['clientOrderId'] = clientOrderId; + params = this.omit (params, 'clientOrderId'); + } + const stopPrice = this.safeFloat (params, 'stopPrice'); + if (stopPrice !== undefined) { + request['stopPrice'] = this.priceToPrecision (symbol, stopPrice); + params = this.omit (params, 'stopPrice'); + } + const timeInForce = this.safeStringLower (params, 'timeInForce'); + if (timeInForce !== undefined) { + request['timeInForce'] = timeInForce; + params = this.omit (params, 'timeInForce'); + } + const response = await this.privatePostOrders (this.extend (request, params)); + // + // { + // "id": "453327", // order ID + // "clientOrderId": "test4321", // client order ID (showed only when it exists) + // "status": "reserved", // placed, cancelled, completed, updated, reserved + // "forcedCompletionReason": undefined, // the reason in case it was canceled in the middle (protection or timeInForce) + // "tradingPairName": "BCH-KRW", // order book + // "side": "sell", // buy, sell + // "type": "limit", // limit, market + // "price": 11000000, // price + // "stopPrice": 12000000, // stop price (showed only for stop orders) + // "amount": 0.5, // initial amount + // "remaining": 0.5, // outstanding amount + // "protection": "no", // whether protection is activated (yes or no) + // "timeInForce": "gtc", // limit order's time in force (gtc/po/ioc/fok) + // "createdAt": "2020-09-25T04:51:31.000Z", // order placement time + // "balanceChange": { + // "baseGross": 0, // base asset balance's gross change (in BCH for this case) + // "baseFee": { + // "taking": 0, // base asset fee imposed as taker + // "making": 0 // base asset fee imposed as maker + // }, + // "baseNet": 0, // base asset balance's net change (in BCH for this case) + // "quoteGross": 0, // quote asset balance's gross change (in KRW for + // "quoteFee": { + // "taking": 0, // quote asset fee imposed as taker + // "making": 0 // quote asset fee imposed as maker + // }, + // "quoteNet": 0 // quote asset balance's net change (in KRW for this case) + // } + // } + // + return this.parseOrder (response, market); + } + + async cancelOrder (id, symbol = undefined, params = {}) { + await this.loadMarkets (); + const request = {}; + const clientOrderId = this.safeString (params, 'clientOrderId'); + let method = undefined; + if (clientOrderId === undefined) { + method = 'privateDeleteOrdersOrderId'; + request['orderId'] = id; + } else { + method = 'privateDeleteOrdersClientOrderIdClientOrderId'; + request['clientOrderId'] = clientOrderId; + params = this.omit (params, 'clientOrderId'); + } + const response = await this[method] (this.extend (request, params)); + // + // {} + // + const order = this.parseOrder (response); + return this.extend (order, { 'id': id }); + } + + async fetchMyTrades (symbol = undefined, since = undefined, limit = undefined, params = {}) { + await this.loadMarkets (); + const request = { + // 'limit': limit, // max 100 + // 'pastmax': id, // read data older than this id + // 'latestmin': id, // read data newer than this id + // 'after': parseInt (since / 1000), // Read data after this timestamp in seconds + // 'before': this.seconds (), // Read data before this timestamp in seconds + 'deepSearch': 'true', // read data older than one month ago are inclusively looked up only when it is "true" + }; + if (since !== undefined) { + request['after'] = parseInt (since / 1000); + } + if (limit !== undefined) { + request['limit'] = limit; + } + const response = await this.privateGetTrades (this.extend (request, params)); + // + // [ + // { + // "id": 73953, // trading event ID + // "orderId": 453324, // order ID + // "baseAmount": 3, // traded base asset amount + // "quoteAmount": 3000000, // traded quote asset amount + // "fee": 0.0012, // fee + // "price": 1000000, // price + // "timestamp": "2020-09-25T04:06:30.000Z", // trading time + // "side": "buy", // buy, sell + // "tradingPairName": "ZEC-KRW", // order book + // "position": "maker" // maker, taker + // }, + // ] + // + let market = undefined; + if (symbol !== undefined) { + market = this.market (symbol); + } + return this.parseTrades (response, market, since, limit); + } + + parseDepositAddress (depositAddress, currency = undefined) { + // + // { + // "asset": "BTC", // asset name + // "address": "1CwC2cMFu1jRQUBtw925cENbT1kctJBMdm", // deposit address + // "memoId": null, // memo ID (showed only for assets using memo ID) + // "createdAt": 1594802312 // deposit address creation time + // } + // + const address = this.safeString (depositAddress, 'address'); + const tag = this.safeString (depositAddress, 'memoId'); + const currencyId = this.safeString (depositAddress, 'asset'); + const code = this.safeCurrencyCode (currencyId); + this.checkAddress (address); + return { + 'currency': code, + 'address': address, + 'tag': tag, + 'info': depositAddress, + }; + } + + parseDepositAddresses (addresses, codes = undefined) { + let result = []; + for (let i = 0; i < addresses.length; i++) { + const address = this.parseDepositAddress (addresses[i]); + result.push (address); + } + if (codes) { + result = this.filterByArray (result, 'currency', codes); + } + return this.indexBy (result, 'currency'); + } + + async fetchDepositAddresses (codes = undefined, params = {}) { + await this.loadMarkets (); + const response = await this.privateGetCryptoDepositAddresses (params); + // + // [ + // { + // "asset": "BTC", // asset name + // "address": "1CwC2cMFu1jRQUBtw925cENbT1kctJBMdm", // deposit address + // "memoId": null, // memo ID (showed only for assets using memo ID) + // "createdAt": 1594802312 // deposit address creation time + // }, + // ] + // + return this.parseDepositAddresses (response, codes); + } + + async fetchDepositAddress (code, params = {}) { + await this.loadMarkets (); + const response = await this.fetchDepositAddresses (undefined, params); + const address = this.safeValue (response, code); + if (address === undefined) { + throw new InvalidAddress (this.id + ' fetchDepositAddress() ' + code + ' address not found'); + } + return address; + } + + parseTransactionStatus (status) { + const statuses = { + 'reviewing': 'pending', + 'rejected': 'rejected', + 'processing': 'pending', + 'failed': 'failed', + 'completed': 'ok', + }; + return this.safeString (statuses, status, status); + } + + parseTransaction (transaction, currency = undefined) { + // + // { + // "id": 640, // deposit/withdrawal event ID + // "asset": "BTC", // asset name + // "type": "crypto_withdrawal", // fiat_withdrawal, fiat_deposit, crypto_withdrawal, crypto_deposit + // "netAmount": 0.0001, // amount + // "feeAmount": 0.0005, // fee (null if there is no imposed fee) + // "status": "completed", // reviewing, rejected, processing, failed, completed + // "reviewStartedAt": 1595556218, // request time + // "completedAt": 1595556902, // completion time (showed only in case of completed) + // "txId": "eaca5ad3...", // tx ID + // "sourceAddress": null, // sender address (showed only in case of crypto_deposit) + // "destinationAddress: "3H8...", // recipient address (showed only in case of crypto_withdrawal) + // "destinationMemoId": null // recipient address's memo ID + // } + // + const id = this.safeString (transaction, 'id'); + const txid = this.safeString (transaction, 'txId'); + const currencyId = this.safeString (transaction, 'asset'); + const code = this.safeCurrencyCode (currencyId, currency); + let type = this.safeString (transaction, 'type'); + if ((type === 'crypto_withdrawal') || (type === 'fiat_withdrawal')) { + type = 'withdrawal'; + } else if ((type === 'crypto_deposit' || type === 'fiat_deposit')) { + type = 'deposit'; + } + const amount = this.safeFloat (transaction, 'netAmount'); + const feeCost = this.safeFloat (transaction, 'feeAmount'); + let fee = undefined; + if (feeCost !== undefined) { + fee = { + 'cost': feeCost, + 'currency': code, + }; + } + const timestamp = this.safeTimestamp (transaction, 'reviewStartedAt'); + const updated = this.safeTimestamp (transaction, 'completedAt'); + const addressFrom = this.safeString (transaction, 'sourceAddress'); + const addressTo = this.safeString (transaction, 'destinationAddress'); + const tagFrom = this.safeString (transaction, 'sourceMemoId'); + const tagTo = this.safeString (transaction, 'destinationMemoId'); + const status = this.parseTransactionStatus (this.safeString (transaction, 'status')); + return { + 'info': transaction, + 'id': id, + 'txid': txid, + 'timestamp': timestamp, + 'datetime': this.iso8601 (timestamp), + 'addressFrom': addressFrom, + 'address': addressTo, + 'addressTo': addressTo, + 'tagFrom': tagFrom, + 'tag': tagTo, + 'tagTo': tagTo, + 'type': type, + 'amount': amount, + 'currency': code, + 'status': status, + 'updated': updated, + 'comment': undefined, + 'fee': fee, + }; + } + + async fetchTransactions (code = undefined, since = undefined, limit = undefined, params = {}) { + await this.loadMarkets (); + const request = { + // 'limit': limit, // max 20 + // 'latestmin': limit, // read data older than this id + // 'after': this.milliseconds (), + // 'before': since, + // 'completedOnly': 'no', + }; + if (since !== undefined) { + request['before'] = since; + } + if (limit !== undefined) { + request['limit'] = limit; + } + const response = await this.privateGetDepositWithdrawalStatus (this.extend (request, params)); + // + // [ + // { + // "id": 640, // deposit/withdrawal event ID + // "asset": "BTC", // asset name + // "type": "crypto_withdrawal", // fiat_withdrawal, fiat_deposit, crypto_withdrawal, crypto_deposit + // "netAmount": 0.0001, // amount + // "feeAmount": 0.0005, // fee (null if there is no imposed fee) + // "status": "completed", // reviewing, rejected, processing, failed, completed + // "reviewStartedAt": 1595556218, // request time + // "completedAt": 1595556902, // completion time (showed only in case of completed) + // "txId": "eaca5ad3...", // tx ID + // "sourceAddress": null, // sender address (showed only in case of crypto_deposit) + // "destinationAddress: "3H8...", // recipient address (showed only in case of crypto_withdrawal) + // "destinationMemoId": null // recipient address's memo ID + // }, + // ] + // + let currency = undefined; + if (code !== undefined) { + currency = this.currency (code); + } + return this.parseTransactions (response, currency, since, limit, params); + } + + nonce () { + return this.milliseconds (); + } + + sign (path, api = 'public', method = 'GET', params = {}, headers = undefined, body = undefined) { // for authentication in private API calls + const endpoint = '/' + this.implodeParams (path, params); + let url = this.implodeParams (this.urls['api'][api], { 'hostname': this.hostname }) + endpoint; + const query = this.omit (params, this.extractParams (path)); + if (api === 'public') { + if (Object.keys (query).length) { + url += '?' + this.urlencode (query); + } + } else if (api === 'private') { + this.checkRequiredCredentials (); + const timestamp = this.nonce ().toString (); + let auth = 't' + timestamp + method + endpoint; + headers = { + 'api-key': this.apiKey, + 'timestamp': timestamp, + }; + if (method === 'POST') { + headers['Content-Type'] = 'application/json'; + body = this.json (params); + auth += body; + } else if (endpoint === '/orders') { + if (Object.keys (query).length) { + const urlQuery = '?' + this.urlencode (query); + auth += urlQuery; + url += urlQuery; + } + } else if (method === 'GET') { + if (Object.keys (query).length) { + url += '?' + this.urlencode (query); + } + } + const rawSecret = this.base64ToBinary (this.secret); + const signature = this.hmac (this.encode (auth), rawSecret, 'sha512', 'base64'); + headers['signature'] = signature; + } + return { 'url': url, 'method': method, 'body': body, 'headers': headers }; + } + + handleErrors (code, reason, url, method, headers, body, response, requestHeaders, requestBody) { + if (response === undefined) { + return; + } + // + // {"errorMessage":"Invalid API key","errorCode":10155} + // + if (!Array.isArray (response)) { + const errorCode = this.safeString (response, 'errorCode'); + const errorMessage = this.safeString (response, 'errorMessage'); + const feedback = this.id + ' ' + body; + if (errorMessage !== undefined) { + this.throwBroadlyMatchedException (this.exceptions['broad'], body, feedback); + } + if (errorCode !== undefined) { + this.throwExactlyMatchedException (this.exceptions['exact'], errorCode, feedback); + } + if ((errorCode !== undefined) || (errorMessage !== undefined)) { + throw new ExchangeError (feedback); + } + } + } +}; + +},{"./base/Exchange":6,"./base/errors":8,"./base/functions/number":14}],92:[function(require,module,exports){ 'use strict'; // --------------------------------------------------------------------------- @@ -69922,7 +76573,7 @@ module.exports = class hbtc extends Exchange { method = 'optionGetMyTrades'; } else { if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' fetchMyTrades requires a `symbol` argument for ' + type + ' markets'); + throw new ArgumentsRequired (this.id + ' fetchMyTrades() requires a `symbol` argument for ' + type + ' markets'); } const market = this.market (symbol); request['symbol'] = market['id']; @@ -71035,6 +77686,7 @@ module.exports = class hbtc extends Exchange { 'NEW': 'open', 'CANCELED': 'canceled', 'FILLED': 'closed', + 'PARTIALLY_FILLED': 'open', 'PENDING_CANCEL': 'canceled', }; return this.safeString (statuses, status, status); @@ -71088,7 +77740,7 @@ module.exports = class hbtc extends Exchange { } }; -},{"./base/Exchange":5,"./base/errors":7,"./base/functions/number":13}],89:[function(require,module,exports){ +},{"./base/Exchange":6,"./base/errors":8,"./base/functions/number":14}],93:[function(require,module,exports){ 'use strict'; // --------------------------------------------------------------------------- @@ -71150,6 +77802,10 @@ module.exports = class hitbtc extends Exchange { }, 'urls': { 'logo': 'https://user-images.githubusercontent.com/1294454/27766555-8eaec20e-5edc-11e7-9c5b-6dc69fc42f5e.jpg', + 'test': { + 'public': 'https://api.demo.hitbtc.com', + 'private': 'https://api.demo.hitbtc.com', + }, 'api': { 'public': 'https://api.hitbtc.com', 'private': 'https://api.hitbtc.com', @@ -71251,6 +77907,7 @@ module.exports = class hitbtc extends Exchange { 'LNC': 'LinkerCoin', 'PLA': 'PlayChip', 'PNT': 'Penta', + 'SBTC': 'Super Bitcoin', 'TV': 'Tokenville', 'USD': 'USDT', 'XPNT': 'PNT', @@ -71888,22 +78545,44 @@ module.exports = class hitbtc extends Exchange { // // createMarketOrder // - // { clientOrderId: "fe36aa5e190149bf9985fb673bbb2ea0", - // createdAt: "2018-10-25T16:41:44.780Z", - // cumQuantity: "1", - // id: "66799540063", - // quantity: "1", - // side: "sell", - // status: "filled", - // symbol: "XRPUSDT", - // timeInForce: "FOK", - // tradesReport: [ { fee: "0.0004644", - // id: 386394956, - // price: "0.4644", - // quantity: "1", - // timestamp: "2018-10-25T16:41:44.780Z" } ], - // type: "market", - // updatedAt: "2018-10-25T16:41:44.780Z" } + // { + // clientOrderId: "fe36aa5e190149bf9985fb673bbb2ea0", + // createdAt: "2018-10-25T16:41:44.780Z", + // cumQuantity: "1", + // id: "66799540063", + // quantity: "1", + // side: "sell", + // status: "filled", + // symbol: "XRPUSDT", + // timeInForce: "FOK", + // tradesReport: [ + // { + // fee: "0.0004644", + // id: 386394956, + // price: "0.4644", + // quantity: "1", + // timestamp: "2018-10-25T16:41:44.780Z" + // } + // ], + // type: "market", + // updatedAt: "2018-10-25T16:41:44.780Z" + // } + // + // { + // "id": 119499457455, + // "clientOrderId": "87baab109d58401b9202fa0749cb8288", + // "symbol": "ETHUSD", + // "side": "buy", + // "status": "filled", + // "type": "market", + // "timeInForce": "FOK", + // "quantity": "0.0007", + // "price": "181.487", + // "avgPrice": "164.989", + // "cumQuantity": "0.0007", + // "createdAt": "2019-04-17T13:27:38.062Z", + // "updatedAt": "2019-04-17T13:27:38.062Z" + // } // const created = this.parse8601 (this.safeString (order, 'createdAt')); const updated = this.parse8601 (this.safeString (order, 'updatedAt')); @@ -71933,7 +78612,7 @@ module.exports = class hitbtc extends Exchange { const side = this.safeString (order, 'side'); let trades = this.safeValue (order, 'tradesReport'); let fee = undefined; - let average = undefined; + let average = this.safeValue (order, 'avgPrice'); if (trades !== undefined) { trades = this.parseTrades (trades, market); let feeCost = undefined; @@ -71952,7 +78631,9 @@ module.exports = class hitbtc extends Exchange { } cost = tradesCost; if ((filled !== undefined) && (filled > 0)) { - average = cost / filled; + if (average === undefined) { + average = cost / filled; + } if (type === 'market') { if (price === undefined) { price = average; @@ -72249,7 +78930,7 @@ module.exports = class hitbtc extends Exchange { } }; -},{"./base/Exchange":5,"./base/errors":7,"./base/functions/number":13}],90:[function(require,module,exports){ +},{"./base/Exchange":6,"./base/errors":8,"./base/functions/number":14}],94:[function(require,module,exports){ 'use strict'; // --------------------------------------------------------------------------- @@ -72772,7 +79453,7 @@ module.exports = class hollaex extends Exchange { const duration = this.parseTimeframe (timeframe); if (since === undefined) { if (limit === undefined) { - throw new ArgumentsRequired (this.id + " fetchOHLCV requires a 'since' or a 'limit' argument"); + throw new ArgumentsRequired (this.id + " fetchOHLCV() requires a 'since' or a 'limit' argument"); } else { const end = this.seconds (); const start = end - duration * limit; @@ -72954,6 +79635,7 @@ module.exports = class hollaex extends Exchange { 'symbol': symbol, 'type': type, 'timeInForce': undefined, + 'postOnly': undefined, 'side': side, 'price': price, 'stopPrice': undefined, @@ -73423,7 +80105,7 @@ module.exports = class hollaex extends Exchange { } }; -},{"./base/Exchange":5,"./base/errors":7,"./base/functions/number":13}],91:[function(require,module,exports){ +},{"./base/Exchange":6,"./base/errors":8,"./base/functions/number":14}],95:[function(require,module,exports){ 'use strict'; // --------------------------------------------------------------------------- @@ -73464,7 +80146,7 @@ module.exports = class huobijp extends huobipro { } }; -},{"./base/errors":7,"./huobipro.js":92}],92:[function(require,module,exports){ +},{"./base/errors":8,"./huobipro.js":96}],96:[function(require,module,exports){ 'use strict'; // --------------------------------------------------------------------------- @@ -73565,6 +80247,7 @@ module.exports = class huobipro extends Exchange { 'user/api-key', // 母子用户API key信息查询 ], 'post': [ + 'account/transfer', 'point/transfer', // 点卡划转 'sub-user/management', // 冻结/解冻子用户 'sub-user/creation', // 子用户创建 @@ -73662,9 +80345,14 @@ module.exports = class huobipro extends Exchange { }, }, 'exceptions': { + 'broad': { + 'contract is restricted of closing positions on API. Please contact customer service': OnMaintenance, + 'maintain': OnMaintenance, + }, 'exact': { // err-code 'bad-request': BadRequest, + 'base-date-limit-error': BadRequest, // {"status":"error","err-code":"base-date-limit-error","err-msg":"date less than system limit","data":null} 'api-not-support-temp-addr': PermissionDenied, // {"status":"error","err-code":"api-not-support-temp-addr","err-msg":"API withdrawal does not support temporary addresses","data":null} 'timeout': RequestTimeout, // {"ts":1571653730865,"status":"error","err-code":"timeout","err-msg":"Request Timeout"} 'gateway-internal-error': ExchangeNotAvailable, // {"status":"error","err-code":"gateway-internal-error","err-msg":"Failed to load data. Try again later.","data":null} @@ -73675,6 +80363,8 @@ module.exports = class huobipro extends Exchange { 'order-marketorder-amount-min-error': InvalidOrder, // market order amount error, min: `0.01` 'order-limitorder-price-min-error': InvalidOrder, // limit order price error 'order-limitorder-price-max-error': InvalidOrder, // limit order price error + 'order-holding-limit-failed': InvalidOrder, // {"status":"error","err-code":"order-holding-limit-failed","err-msg":"Order failed, exceeded the holding limit of this currency","data":null} + 'order-orderprice-precision-error': InvalidOrder, // {"status":"error","err-code":"order-orderprice-precision-error","err-msg":"order price precision error, scale: `4`","data":null} 'order-orderstate-error': OrderNotFound, // canceling an already canceled order 'order-queryorder-invalid': OrderNotFound, // querying a non-existent order 'order-update-error': ExchangeNotAvailable, // undocumented error @@ -73710,6 +80400,7 @@ module.exports = class huobipro extends Exchange { // https://coinmarketcap.com/currencies/penta/markets/ // https://en.cryptonomist.ch/blog/eidoo/the-edo-to-pnt-upgrade-what-you-need-to-know-updated/ 'PNT': 'Penta', + 'SBTC': 'Super Bitcoin', }, }); } @@ -74142,7 +80833,8 @@ module.exports = class huobipro extends Exchange { request['size'] = limit; // 1-100 orders, default is 100 } if (since !== undefined) { - request['start-date'] = this.ymd (since); // maximum query window size is 2 days, query window shift should be within past 120 days + request['start-date'] = this.ymd (since); // a date within 61 days from today + request['end-date'] = this.ymd (this.sum (since, 86400000)); } const response = await this.privateGetOrderMatchresults (this.extend (request, params)); const trades = this.parseTrades (response['data'], market, since, limit); @@ -74410,7 +81102,7 @@ module.exports = class huobipro extends Exchange { async fetchOpenOrdersV1 (symbol = undefined, since = undefined, limit = undefined, params = {}) { if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' fetchOpenOrdersV1 requires a symbol argument'); + throw new ArgumentsRequired (this.id + ' fetchOpenOrdersV1() requires a symbol argument'); } return await this.fetchOrdersByStates ('pre-submitted,submitted,partial-filled', symbol, since, limit, params); } @@ -74422,7 +81114,7 @@ module.exports = class huobipro extends Exchange { async fetchOpenOrdersV2 (symbol = undefined, since = undefined, limit = undefined, params = {}) { await this.loadMarkets (); if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' fetchOpenOrders requires a symbol argument'); + throw new ArgumentsRequired (this.id + ' fetchOpenOrders() requires a symbol argument'); } const market = this.market (symbol); let accountId = this.safeString (params, 'account-id'); @@ -74572,6 +81264,7 @@ module.exports = class huobipro extends Exchange { 'symbol': symbol, 'type': type, 'timeInForce': undefined, + 'postOnly': undefined, 'side': side, 'price': price, 'stopPrice': undefined, @@ -74951,6 +81644,7 @@ module.exports = class huobipro extends Exchange { if (status === 'error') { const code = this.safeString (response, 'err-code'); const feedback = this.id + ' ' + body; + this.throwBroadlyMatchedException (this.exceptions['broad'], body, feedback); this.throwExactlyMatchedException (this.exceptions['exact'], code, feedback); const message = this.safeString (response, 'err-msg'); this.throwExactlyMatchedException (this.exceptions['exact'], message, feedback); @@ -74960,40 +81654,7 @@ module.exports = class huobipro extends Exchange { } }; -},{"./base/Exchange":5,"./base/errors":7,"./base/functions/number":13}],93:[function(require,module,exports){ -'use strict'; - -// --------------------------------------------------------------------------- - -const huobipro = require ('./huobipro.js'); - -// --------------------------------------------------------------------------- - -module.exports = class huobiru extends huobipro { - describe () { - return this.deepExtend (super.describe (), { - 'id': 'huobiru', - 'name': 'Huobi Russia', - 'countries': [ 'RU' ], - 'hostname': 'www.huobi.com.ru', - 'pro': true, - 'urls': { - 'logo': 'https://user-images.githubusercontent.com/1294454/52978816-e8552e00-33e3-11e9-98ed-845acfece834.jpg', - 'api': { - 'market': 'https://{hostname}/api', - 'public': 'https://{hostname}/api', - 'private': 'https://{hostname}/api', - }, - 'www': 'https://www.huobi.com.ru/ru-ru', - 'referral': 'https://www.huobi.com.ru/invite?invite_code=esc74', - 'doc': 'https://github.com/cloudapidoc/API_Docs_en', - 'fees': 'https://www.huobi.com.ru/ru-ru/about/fee/', - }, - }); - } -}; - -},{"./huobipro.js":92}],94:[function(require,module,exports){ +},{"./base/Exchange":6,"./base/errors":8,"./base/functions/number":14}],97:[function(require,module,exports){ 'use strict'; // --------------------------------------------------------------------------- @@ -75221,7 +81882,7 @@ module.exports = class ice3x extends Exchange { const type = this.safeString (params, 'type'); if ((type !== 'ask') && (type !== 'bid')) { // eslint-disable-next-line quotes - throw new ArgumentsRequired (this.id + " fetchOrderBook requires an exchange-specific extra 'type' param ('bid' or 'ask') when used with a limit"); + throw new ArgumentsRequired (this.id + " fetchOrderBook() requires an exchange-specific extra 'type' param ('bid' or 'ask') when used with a limit"); } else { request['items_per_page'] = limit; } @@ -75341,6 +82002,7 @@ module.exports = class ice3x extends Exchange { 'symbol': symbol, 'type': 'limit', 'timeInForce': undefined, + 'postOnly': undefined, 'side': this.safeString (order, 'type'), 'price': price, 'stopPrice': undefined, @@ -75489,7 +82151,7 @@ module.exports = class ice3x extends Exchange { } }; -},{"./base/Exchange":5,"./base/errors":7}],95:[function(require,module,exports){ +},{"./base/Exchange":6,"./base/errors":8}],98:[function(require,module,exports){ 'use strict'; // --------------------------------------------------------------------------- @@ -75548,8 +82210,8 @@ module.exports = class idex extends Exchange { }, 'logo': 'https://user-images.githubusercontent.com/51840849/94481303-2f222100-01e0-11eb-97dd-bc14c5943a86.jpg', 'api': { - 'public': 'https://api.idex.io', - 'private': 'https://api.idex.io', + 'ETH': 'https://api-eth.idex.io', + 'BSC': 'https://api-bsc.idex.io', }, 'www': 'https://idex.io', 'doc': [ @@ -75595,6 +82257,7 @@ module.exports = class idex extends Exchange { 'options': { 'defaultTimeInForce': 'gtc', 'defaultSelfTradePrevention': 'cn', + 'network': 'ETH', // also supports BSC }, 'exceptions': { 'INVALID_ORDER_QUANTITY': InvalidOrder, @@ -76314,16 +82977,8 @@ module.exports = class idex extends Exchange { const type = this.safeString (order, 'type'); const amount = this.safeFloat (order, 'originalQuantity'); const filled = this.safeFloat (order, 'executedQuantity'); - let remaining = undefined; - if ((amount !== undefined) && (filled !== undefined)) { - remaining = amount - filled; - } const average = this.safeFloat (order, 'avgExecutionPrice'); - const price = this.safeFloat (order, 'price', average); // for market orders - let cost = undefined; - if ((amount !== undefined) && (price !== undefined)) { - cost = amount * price; - } + const price = this.safeFloat (order, 'price'); const rawStatus = this.safeString (order, 'status'); const status = this.parseOrderStatus (rawStatus); const fee = { @@ -76337,7 +82992,7 @@ module.exports = class idex extends Exchange { fee['cost'] = this.sum (fee['cost'], lastTrade['fee']['cost']); } const lastTradeTimestamp = this.safeInteger (lastTrade, 'timestamp'); - return { + return this.safeOrder ({ 'info': order, 'id': id, 'clientOrderId': clientOrderId, @@ -76347,18 +83002,19 @@ module.exports = class idex extends Exchange { 'symbol': symbol, 'type': type, 'timeInForce': undefined, + 'postOnly': undefined, 'side': side, 'price': price, 'stopPrice': undefined, 'amount': amount, - 'cost': cost, + 'cost': undefined, 'average': average, 'filled': filled, - 'remaining': remaining, + 'remaining': undefined, 'status': status, 'fee': fee, 'trades': trades, - }; + }); } async associateWallet (walletAddress, params = {}) { @@ -76435,7 +83091,8 @@ module.exports = class idex extends Exchange { } const sideEnum = (side === 'buy') ? 0 : 1; const walletBytes = this.remove0xPrefix (this.walletAddress); - const orderVersion = 1; + const network = this.safeString (this.options, 'network', 'ETH'); + const orderVersion = (network === 'ETH') ? 1 : 2; const amountString = this.amountToPrecision (symbol, amount); // https://docs.idex.io/#time-in-force const timeInForceEnums = { @@ -76764,8 +83421,9 @@ module.exports = class idex extends Exchange { } sign (path, api = 'public', method = 'GET', params = {}, headers = undefined, body = undefined) { + const network = this.safeString (this.options, 'network', 'ETH'); const version = this.safeString (this.options, 'version', 'v1'); - let url = this.urls['api'][api] + '/' + version + '/' + path; + let url = this.urls['api'][network] + '/' + version + '/' + path; const keys = Object.keys (params); const length = keys.length; let query = undefined; @@ -76796,7 +83454,7 @@ module.exports = class idex extends Exchange { } }; -},{"./base/Exchange":5,"./base/errors":7,"./base/functions/number":13}],96:[function(require,module,exports){ +},{"./base/Exchange":6,"./base/errors":8,"./base/functions/number":14}],99:[function(require,module,exports){ 'use strict'; // --------------------------------------------------------------------------- @@ -77086,6 +83744,7 @@ module.exports = class independentreserve extends Exchange { 'symbol': symbol, 'type': orderType, 'timeInForce': undefined, + 'postOnly': undefined, 'side': side, 'price': price, 'stopPrice': undefined, @@ -77193,10 +83852,13 @@ module.exports = class independentreserve extends Exchange { cost = price * amount; } } - let symbol = undefined; - if (market !== undefined) { - symbol = market['symbol']; + const baseId = this.safeString (trade, 'PrimaryCurrencyCode'); + const quoteId = this.safeString (trade, 'SecondaryCurrencyCode'); + let marketId = undefined; + if ((baseId !== undefined) && (quoteId !== undefined)) { + marketId = baseId + '/' + quoteId; } + const symbol = this.safeSymbol (marketId, market, '/'); let side = this.safeString (trade, 'OrderType'); if (side !== undefined) { if (side.indexOf ('Bid') >= 0) { @@ -77302,7 +83964,7 @@ module.exports = class independentreserve extends Exchange { } }; -},{"./base/Exchange":5}],97:[function(require,module,exports){ +},{"./base/Exchange":6}],100:[function(require,module,exports){ 'use strict'; // --------------------------------------------------------------------------- @@ -77704,6 +84366,7 @@ module.exports = class indodax extends Exchange { 'symbol': symbol, 'type': 'limit', 'timeInForce': undefined, + 'postOnly': undefined, 'side': side, 'price': price, 'stopPrice': undefined, @@ -77720,7 +84383,7 @@ module.exports = class indodax extends Exchange { async fetchOrder (id, symbol = undefined, params = {}) { if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' fetchOrder requires a symbol'); + throw new ArgumentsRequired (this.id + ' fetchOrder() requires a symbol'); } await this.loadMarkets (); const market = this.market (symbol); @@ -77767,7 +84430,7 @@ module.exports = class indodax extends Exchange { async fetchClosedOrders (symbol = undefined, since = undefined, limit = undefined, params = {}) { if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' fetchOrders requires a symbol argument'); + throw new ArgumentsRequired (this.id + ' fetchOrders() requires a symbol argument'); } await this.loadMarkets (); const request = {}; @@ -77811,11 +84474,11 @@ module.exports = class indodax extends Exchange { async cancelOrder (id, symbol = undefined, params = {}) { if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' cancelOrder requires a symbol argument'); + throw new ArgumentsRequired (this.id + ' cancelOrder() requires a symbol argument'); } const side = this.safeValue (params, 'side'); if (side === undefined) { - throw new ArgumentsRequired (this.id + ' cancelOrder requires an extra "side" param'); + throw new ArgumentsRequired (this.id + ' cancelOrder() requires an extra "side" param'); } await this.loadMarkets (); const market = this.market (symbol); @@ -77922,7 +84585,7 @@ module.exports = class indodax extends Exchange { } }; -},{"./base/Exchange":5,"./base/errors":7}],98:[function(require,module,exports){ +},{"./base/Exchange":6,"./base/errors":8}],101:[function(require,module,exports){ 'use strict'; // --------------------------------------------------------------------------- @@ -78193,7 +84856,7 @@ module.exports = class itbit extends Exchange { await this.loadMarkets (); const walletId = this.safeString (params, 'walletId'); if (walletId === undefined) { - throw new ArgumentsRequired (this.id + ' fetchMyTrades requires a walletId parameter'); + throw new ArgumentsRequired (this.id + ' fetchMyTrades() requires a walletId parameter'); } const request = { 'walletId': walletId, @@ -78262,7 +84925,7 @@ module.exports = class itbit extends Exchange { await this.loadMarkets (); const walletId = this.safeString (params, 'walletId'); if (walletId === undefined) { - throw new ExchangeError (this.id + ' fetchMyTrades requires a walletId parameter'); + throw new ExchangeError (this.id + ' fetchMyTrades() requires a walletId parameter'); } const request = { 'walletId': walletId, @@ -78352,7 +85015,7 @@ module.exports = class itbit extends Exchange { async fetchWallets (params = {}) { await this.loadMarkets (); if (!this.uid) { - throw new AuthenticationError (this.id + ' fetchWallets requires uid API credential'); + throw new AuthenticationError (this.id + ' fetchWallets() requires uid API credential'); } const request = { 'userId': this.uid, @@ -78390,7 +85053,7 @@ module.exports = class itbit extends Exchange { } const walletIdInParams = ('walletId' in params); if (!walletIdInParams) { - throw new ExchangeError (this.id + ' fetchOrders requires a walletId parameter'); + throw new ExchangeError (this.id + ' fetchOrders() requires a walletId parameter'); } const walletId = params['walletId']; const request = { @@ -78454,6 +85117,8 @@ module.exports = class itbit extends Exchange { } const clientOrderId = this.safeString (order, 'clientOrderIdentifier'); const id = this.safeString (order, 'id'); + const postOnlyString = this.safeString (order, 'postOnly'); + const postOnly = (postOnlyString === 'True'); return { 'id': id, 'clientOrderId': clientOrderId, @@ -78465,6 +85130,7 @@ module.exports = class itbit extends Exchange { 'symbol': symbol, 'type': type, 'timeInForce': undefined, + 'postOnly': postOnly, 'side': side, 'price': price, 'stopPrice': undefined, @@ -78490,7 +85156,7 @@ module.exports = class itbit extends Exchange { } const walletIdInParams = ('walletId' in params); if (!walletIdInParams) { - throw new ExchangeError (this.id + ' createOrder requires a walletId parameter'); + throw new ExchangeError (this.id + ' createOrder() requires a walletId parameter'); } amount = amount.toString (); price = price.toString (); @@ -78515,7 +85181,7 @@ module.exports = class itbit extends Exchange { await this.loadMarkets (); const walletIdInParams = ('walletId' in params); if (!walletIdInParams) { - throw new ExchangeError (this.id + ' fetchOrder requires a walletId parameter'); + throw new ExchangeError (this.id + ' fetchOrder() requires a walletId parameter'); } const request = { 'id': id, @@ -78527,7 +85193,7 @@ module.exports = class itbit extends Exchange { async cancelOrder (id, symbol = undefined, params = {}) { const walletIdInParams = ('walletId' in params); if (!walletIdInParams) { - throw new ExchangeError (this.id + ' cancelOrder requires a walletId parameter'); + throw new ExchangeError (this.id + ' cancelOrder() requires a walletId parameter'); } const request = { 'id': id, @@ -78574,13 +85240,13 @@ module.exports = class itbit extends Exchange { } }; -},{"./base/Exchange":5,"./base/errors":7}],99:[function(require,module,exports){ +},{"./base/Exchange":6,"./base/errors":8}],102:[function(require,module,exports){ 'use strict'; // --------------------------------------------------------------------------- const Exchange = require ('./base/Exchange'); -const { BadSymbol, ExchangeNotAvailable, ArgumentsRequired, PermissionDenied, AuthenticationError, ExchangeError, OrderNotFound, DDoSProtection, InvalidNonce, InsufficientFunds, CancelPending, InvalidOrder, InvalidAddress } = require ('./base/errors'); +const { BadSymbol, ExchangeNotAvailable, ArgumentsRequired, PermissionDenied, AuthenticationError, ExchangeError, OrderNotFound, DDoSProtection, InvalidNonce, InsufficientFunds, CancelPending, InvalidOrder, InvalidAddress, RateLimitExceeded } = require ('./base/errors'); const { TRUNCATE, DECIMAL_PLACES } = require ('./base/functions/number'); // --------------------------------------------------------------------------- @@ -78596,6 +85262,7 @@ module.exports = class kraken extends Exchange { 'certified': true, 'pro': true, 'has': { + 'cancelAllOrders': true, 'cancelOrder': true, 'CORS': false, 'createDepositAddress': true, @@ -78756,6 +85423,7 @@ module.exports = class kraken extends Exchange { 'AddOrder', 'AddExport', 'Balance', + 'CancelAll', 'CancelOrder', 'ClosedOrders', 'DepositAddresses', @@ -78783,6 +85451,7 @@ module.exports = class kraken extends Exchange { }, 'commonCurrencies': { 'XBT': 'BTC', + 'XBT.M': 'BTC.M', // https://support.kraken.com/hc/en-us/articles/360039879471-What-is-Asset-S-and-Asset-M- 'XDG': 'DOGE', 'REPV2': 'REP', 'REP': 'REPV1', @@ -78926,13 +85595,17 @@ module.exports = class kraken extends Exchange { return result; } - safeCurrencyCode (currencyId, currency = undefined) { + safeCurrency (currencyId, currency = undefined) { if (currencyId.length > 3) { if ((currencyId.indexOf ('X') === 0) || (currencyId.indexOf ('Z') === 0)) { - currencyId = currencyId.slice (1); + if (currencyId.indexOf ('.') > 0) { + return super.safeCurrency (currencyId, currency); + } else { + currencyId = currencyId.slice (1); + } } } - return super.safeCurrencyCode (currencyId, currency); + return super.safeCurrency (currencyId, currency); } appendInactiveMarkets (result) { @@ -79397,7 +86070,7 @@ module.exports = class kraken extends Exchange { let amount = undefined; let cost = undefined; let id = undefined; - let order = undefined; + let orderId = undefined; let fee = undefined; let symbol = undefined; if (Array.isArray (trade)) { @@ -79421,7 +86094,7 @@ module.exports = class kraken extends Exchange { // delisted market ids go here market = this.getDelistedMarketById (marketId); } - order = trade['ordertxid']; + orderId = this.safeString (trade, 'ordertxid'); id = this.safeString2 (trade, 'id', 'postxid'); timestamp = this.safeTimestamp (trade, 'time'); side = this.safeString (trade, 'type'); @@ -79449,7 +86122,7 @@ module.exports = class kraken extends Exchange { } return { 'id': id, - 'order': order, + 'order': orderId, 'info': trade, 'timestamp': timestamp, 'datetime': this.iso8601 (timestamp), @@ -79512,6 +86185,7 @@ module.exports = class kraken extends Exchange { } async fetchBalance (params = {}) { + await this.loadMarkets (); const response = await this.privatePostBalance (params); const balances = this.safeValue (response, 'result', {}); const result = { 'info': balances }; @@ -79536,18 +86210,50 @@ module.exports = class kraken extends Exchange { 'volume': this.amountToPrecision (symbol, amount), }; const clientOrderId = this.safeString2 (params, 'userref', 'clientOrderId'); - const query = this.omit (params, [ 'userref', 'clientOrderId' ]); + params = this.omit (params, [ 'userref', 'clientOrderId' ]); if (clientOrderId !== undefined) { request['userref'] = clientOrderId; } - const priceIsDefined = (price !== undefined); - const marketOrder = (type === 'market'); - const limitOrder = (type === 'limit'); - const shouldIncludePrice = limitOrder || (!marketOrder && priceIsDefined); - if (shouldIncludePrice) { + // + // market + // limit (price = limit price) + // stop-loss (price = stop loss price) + // take-profit (price = take profit price) + // stop-loss-limit (price = stop loss trigger price, price2 = triggered limit price) + // take-profit-limit (price = take profit trigger price, price2 = triggered limit price) + // settle-position + // + if (type === 'limit') { request['price'] = this.priceToPrecision (symbol, price); + } else if ((type === 'stop-loss') || (type === 'take-profit')) { + const stopPrice = this.safeFloat2 (params, 'price', 'stopPrice', price); + if (stopPrice === undefined) { + throw new ArgumentsRequired (this.id + ' createOrder() requires a price argument or a price/stopPrice parameter for a ' + type + ' order'); + } else { + request['price'] = this.priceToPrecision (symbol, stopPrice); + } + } else if ((type === 'stop-loss-limit') || (type === 'take-profit-limit')) { + const stopPrice = this.safeFloat2 (params, 'price', 'stopPrice'); + const limitPrice = this.safeFloat (params, 'price2'); + const stopPriceDefined = (stopPrice !== undefined); + const limitPriceDefined = (limitPrice !== undefined); + if (stopPriceDefined && limitPriceDefined) { + request['price'] = this.priceToPrecision (symbol, stopPrice); + request['price2'] = this.priceToPrecision (symbol, limitPrice); + } else if ((price === undefined) || (!(stopPriceDefined || limitPriceDefined))) { + throw new ArgumentsRequired (this.id + ' createOrder() requires a price argument and/or price/stopPrice/price2 parameters for a ' + type + ' order'); + } else { + if (stopPriceDefined) { + request['price'] = this.priceToPrecision (symbol, stopPrice); + request['price2'] = this.priceToPrecision (symbol, price); + } else if (limitPriceDefined) { + request['price'] = this.priceToPrecision (symbol, price); + request['price2'] = this.priceToPrecision (symbol, limitPrice); + } + } } - const response = await this.privatePostAddOrder (this.extend (request, query)); + params = this.omit (params, [ 'price', 'stopPrice', 'price2' ]); + const response = await this.privatePostAddOrder (this.extend (request, params)); // // { // error: [], @@ -79710,6 +86416,7 @@ module.exports = class kraken extends Exchange { 'symbol': symbol, 'type': type, 'timeInForce': undefined, + 'postOnly': undefined, 'side': side, 'price': price, 'stopPrice': stopPrice, @@ -79776,8 +86483,11 @@ module.exports = class kraken extends Exchange { // } // } // - const orders = this.safeValue (response, 'result', []); - const order = this.parseOrder (this.extend ({ 'id': id }, orders[id])); + const result = this.safeValue (response, 'result', []); + if (!(id in result)) { + throw new OrderNotFound (this.id + ' fetchOrder() could not find order id ' + id); + } + const order = this.parseOrder (this.extend ({ 'id': id }, result[id])); return this.extend ({ 'info': response }, order); } @@ -79785,7 +86495,7 @@ module.exports = class kraken extends Exchange { const orderTrades = this.safeValue (params, 'trades'); const tradeIds = []; if (orderTrades === undefined) { - throw new ArgumentsRequired (this.id + " fetchOrderTrades requires a unified order structure in the params argument or a 'trades' param (an array of trade id strings)"); + throw new ArgumentsRequired (this.id + " fetchOrderTrades() requires a unified order structure in the params argument or a 'trades' param (an array of trade id strings)"); } else { for (let i = 0; i < orderTrades.length; i++) { const orderTrade = orderTrades[i]; @@ -79934,6 +86644,11 @@ module.exports = class kraken extends Exchange { return response; } + async cancelAllOrders (symbol = undefined, params = {}) { + await this.loadMarkets (); + return await this.privatePostCancelAll (params); + } + async fetchOpenOrders (symbol = undefined, since = undefined, limit = undefined, params = {}) { await this.loadMarkets (); const request = {}; @@ -80105,7 +86820,7 @@ module.exports = class kraken extends Exchange { async fetchDeposits (code = undefined, since = undefined, limit = undefined, params = {}) { // https://www.kraken.com/en-us/help/api#deposit-status if (code === undefined) { - throw new ArgumentsRequired (this.id + ' fetchDeposits requires a currency code argument'); + throw new ArgumentsRequired (this.id + ' fetchDeposits() requires a currency code argument'); } await this.loadMarkets (); const currency = this.currency (code); @@ -80148,7 +86863,7 @@ module.exports = class kraken extends Exchange { async fetchWithdrawals (code = undefined, since = undefined, limit = undefined, params = {}) { // https://www.kraken.com/en-us/help/api#withdraw-status if (code === undefined) { - throw new ArgumentsRequired (this.id + ' fetchWithdrawals requires a currency code argument'); + throw new ArgumentsRequired (this.id + ' fetchWithdrawals() requires a currency code argument'); } await this.loadMarkets (); const currency = this.currency (code); @@ -80239,7 +86954,65 @@ module.exports = class kraken extends Exchange { 'id': response['result'], }; } - throw new ExchangeError (this.id + " withdraw requires a 'key' parameter (withdrawal key name, as set up on your account)"); + throw new ExchangeError (this.id + " withdraw() requires a 'key' parameter (withdrawal key name, as set up on your account)"); + } + + async fetchPositions (symbols = undefined, since = undefined, limit = undefined, params = {}) { + await this.loadMarkets (); + const request = { + // 'txid': 'comma delimited list of transaction ids to restrict output to', + // 'docalcs': false, // whether or not to include profit/loss calculations + // 'consolidation': 'market', // what to consolidate the positions data around, market will consolidate positions based on market pair + }; + const response = await this.privatePostOpenPositions (this.extend (request, params)); + // + // no consolidation + // + // { + // error: [], + // result: { + // 'TGUFMY-FLESJ-VYIX3J': { + // ordertxid: "O3LRNU-ZKDG5-XNCDFR", + // posstatus: "open", + // pair: "ETHUSDT", + // time: 1611557231.4584, + // type: "buy", + // ordertype: "market", + // cost: "28.49800", + // fee: "0.07979", + // vol: "0.02000000", + // vol_closed: "0.00000000", + // margin: "14.24900", + // terms: "0.0200% per 4 hours", + // rollovertm: "1611571631", + // misc: "", + // oflags: "" + // } + // } + // } + // + // consolidation by market + // + // { + // error: [], + // result: [ + // { + // pair: "ETHUSDT", + // positions: "1", + // type: "buy", + // leverage: "2.00000", + // cost: "28.49800", + // fee: "0.07979", + // vol: "0.02000000", + // vol_closed: "0.00000000", + // margin: "14.24900" + // } + // ] + // } + // + const result = this.safeValue (response, 'result'); + // todo unify parsePosition/parsePositions + return result; } sign (path, api = 'public', method = 'GET', params = {}, headers = undefined, body = undefined) { @@ -80294,6 +87067,12 @@ module.exports = class kraken extends Exchange { if (body.indexOf ('Invalid arguments:volume') >= 0) { throw new InvalidOrder (this.id + ' ' + body); } + if (body.indexOf ('Rate limit exceeded') >= 0) { + throw new RateLimitExceeded (this.id + ' ' + body); + } + if (response === undefined) { + return; + } if (body[0] === '{') { if (typeof response !== 'string') { if ('error' in response) { @@ -80312,7 +87091,7 @@ module.exports = class kraken extends Exchange { } }; -},{"./base/Exchange":5,"./base/errors":7,"./base/functions/number":13}],100:[function(require,module,exports){ +},{"./base/Exchange":6,"./base/errors":8,"./base/functions/number":14}],103:[function(require,module,exports){ 'use strict'; // --------------------------------------------------------------------------- @@ -80335,30 +87114,31 @@ module.exports = class kucoin extends Exchange { 'comment': 'Platform 2.0', 'has': { 'CORS': false, - 'fetchStatus': true, - 'fetchTime': true, - 'fetchMarkets': true, + 'cancelAllOrders': true, + 'cancelOrder': true, + 'createDepositAddress': true, + 'createOrder': true, + 'fetchAccounts': true, + 'fetchBalance': true, + 'fetchClosedOrders': true, 'fetchCurrencies': true, + 'fetchDepositAddress': true, + 'fetchDeposits': true, + 'fetchFundingFee': true, + 'fetchLedger': true, + 'fetchMarkets': true, + 'fetchMyTrades': true, + 'fetchOHLCV': true, + 'fetchOpenOrders': true, + 'fetchOrder': true, + 'fetchOrderBook': true, + 'fetchStatus': true, 'fetchTicker': true, 'fetchTickers': true, - 'fetchOrderBook': true, - 'fetchOrder': true, - 'fetchClosedOrders': true, - 'fetchOpenOrders': true, - 'fetchDepositAddress': true, - 'createDepositAddress': true, - 'withdraw': true, - 'fetchDeposits': true, - 'fetchWithdrawals': true, - 'fetchBalance': true, + 'fetchTime': true, 'fetchTrades': true, - 'fetchMyTrades': true, - 'createOrder': true, - 'cancelOrder': true, - 'fetchAccounts': true, - 'fetchFundingFee': true, - 'fetchOHLCV': true, - 'fetchLedger': true, + 'fetchWithdrawals': true, + 'withdraw': true, }, 'urls': { 'logo': 'https://user-images.githubusercontent.com/51840849/87295558-132aaf80-c50e-11ea-9801-a2fb0c57c799.jpg', @@ -80389,6 +87169,7 @@ module.exports = class kucoin extends Exchange { 'symbols', 'markets', 'market/allTickers', + 'market/orderbook/level{level}_{limit}', 'market/orderbook/level{level}', 'market/orderbook/level2', 'market/orderbook/level2_20', @@ -80425,6 +87206,7 @@ module.exports = class kucoin extends Exchange { 'withdrawals', 'withdrawals/quotas', 'orders', + 'order/client-order/{clientOid}', 'orders/{orderId}', 'limit/orders', 'fills', @@ -80440,6 +87222,9 @@ module.exports = class kucoin extends Exchange { 'margin/lend/assets', 'margin/market', 'margin/trade/last', + 'stop-order/{orderId}', + 'stop-order', + 'stop-order/queryOrderByClientOid', ], 'post': [ 'accounts', @@ -80450,17 +87235,23 @@ module.exports = class kucoin extends Exchange { 'orders', 'orders/multi', 'margin/borrow', + 'margin/order', 'margin/repay/all', 'margin/repay/single', 'margin/lend', 'margin/toggle-auto-lend', 'bullet-private', + 'stop-order', ], 'delete': [ 'withdrawals/{withdrawalId}', 'orders', + 'orders/client-order/{clientOid}', 'orders/{orderId}', 'margin/lend/{orderId}', + 'stop-order/cancelOrderByClientOid', + 'stop-order/{orderId}', + 'stop-order/cancel', ], }, }, @@ -80551,10 +87342,12 @@ module.exports = class kucoin extends Exchange { 'public': { 'GET': { 'status': 'v1', - 'market/orderbook/level{level}': 'v1', 'market/orderbook/level2': 'v2', + 'market/orderbook/level3': 'v2', 'market/orderbook/level2_20': 'v1', 'market/orderbook/level2_100': 'v1', + 'market/orderbook/level{level}': 'v2', + 'market/orderbook/level{level}_{limit}': 'v1', }, }, 'private': { @@ -80686,23 +87479,23 @@ module.exports = class kucoin extends Exchange { const response = await this.publicGetCurrencies (params); // // { - // "currency": "OMG", - // "name": "OMG", - // "fullName": "OmiseGO", - // "precision": 8, - // "confirms": 12, - // "withdrawalMinSize": "4", - // "withdrawalMinFee": "1.25", - // "isWithdrawEnabled": false, - // "isDepositEnabled": false, - // "isMarginEnabled": false, - // "isDebitEnabled": false + // "currency": "OMG", + // "name": "OMG", + // "fullName": "OmiseGO", + // "precision": 8, + // "confirms": 12, + // "withdrawalMinSize": "4", + // "withdrawalMinFee": "1.25", + // "isWithdrawEnabled": false, + // "isDepositEnabled": false, + // "isMarginEnabled": false, + // "isDebitEnabled": false // } // - const responseData = response['data']; + const data = this.safeValue (response, 'data', []); const result = {}; - for (let i = 0; i < responseData.length; i++) { - const entry = responseData[i]; + for (let i = 0; i < data.length; i++) { + const entry = data[i]; const id = this.safeString (entry, 'currency'); const name = this.safeString (entry, 'fullName'); const code = this.safeCurrencyCode (id); @@ -80997,7 +87790,10 @@ module.exports = class kucoin extends Exchange { address = address.replace ('bitcoincash:', ''); } const tag = this.safeString (data, 'memo'); - this.checkAddress (address); + if (code !== 'NIM') { + // contains spaces + this.checkAddress (address); + } return { 'info': response, 'currency': code, @@ -81014,13 +87810,12 @@ module.exports = class kucoin extends Exchange { // BCH {"code":"200000","data":{"address":"bitcoincash:qza3m4nj9rx7l9r0cdadfqxts6f92shvhvr5ls4q7z","memo":""}} // BTC {"code":"200000","data":{"address":"36SjucKqQpQSvsak9A7h6qzFjrVXpRNZhE","memo":""}} const data = this.safeValue (response, 'data', {}); - let address = this.safeString (data, 'address'); - // BCH/BSV is returned with a "bitcoincash:" prefix, which we cut off here and only keep the address - if (address !== undefined) { - address = address.replace ('bitcoincash:', ''); - } + const address = this.safeString (data, 'address'); const tag = this.safeString (data, 'memo'); - this.checkAddress (address); + if (code !== 'NIM') { + // contains spaces + this.checkAddress (address); + } return { 'info': response, 'currency': code, @@ -81034,20 +87829,22 @@ module.exports = class kucoin extends Exchange { } async fetchOrderBook (symbol, limit = undefined, params = {}) { - const level = this.safeInteger (params, 'level', 2); - let levelLimit = level.toString (); - if (levelLimit === '2') { - if (limit !== undefined) { - if ((limit !== 20) && (limit !== 100)) { - throw new ExchangeError (this.id + ' fetchOrderBook limit argument must be undefined, 20 or 100'); - } - levelLimit += '_' + limit.toString (); - } - } await this.loadMarkets (); const marketId = this.marketId (symbol); - const request = { 'symbol': marketId, 'level': levelLimit }; - const response = await this.publicGetMarketOrderbookLevelLevel (this.extend (request, params)); + const level = this.safeInteger (params, 'level', 2); + const request = { 'symbol': marketId, 'level': level }; + let method = 'publicGetMarketOrderbookLevelLevel'; + if (level === 2) { + if (limit !== undefined) { + if ((limit === 20) || (limit === 100)) { + request['limit'] = limit; + method = 'publicGetMarketOrderbookLevelLevelLimit'; + } else { + throw new ExchangeError (this.id + ' fetchOrderBook limit argument must be undefined, 20 or 100'); + } + } + } + const response = await this[method] (this.extend (request, params)); // // 'market/orderbook/level2' // 'market/orderbook/level2_20' @@ -81109,7 +87906,29 @@ module.exports = class kucoin extends Exchange { 'clientOid': clientOrderId, 'side': side, 'symbol': marketId, - 'type': type, + 'type': type, // limit or market + // 'remark': '', // optional remark for the order, length cannot exceed 100 utf8 characters + // 'stp': '', // self trade prevention, CN, CO, CB or DC + // To improve the system performance and to accelerate order placing and processing, KuCoin has added a new interface for margin orders + // The current one will no longer accept margin orders by May 1st, 2021 (UTC) + // At the time, KuCoin will notify users via the announcement, please pay attention to it + // 'tradeType': 'TRADE', // TRADE, MARGIN_TRADE // not used with margin orders + // limit orders --------------------------------------------------- + // 'timeInForce': 'GTC', // GTC, GTT, IOC, or FOK (default is GTC), limit orders only + // 'cancelAfter': long, // cancel after n seconds, requires timeInForce to be GTT + // 'postOnly': false, // Post only flag, invalid when timeInForce is IOC or FOK + // 'hidden': false, // Order will not be displayed in the order book + // 'iceberg': false, // Only a portion of the order is displayed in the order book + // 'visibleSize': this.amountToPrecision (symbol, visibleSize), // The maximum visible size of an iceberg order + // market orders -------------------------------------------------- + // 'size': this.amountToPrecision (symbol, amount), // Amount in base currency + // 'funds': this.costToPrecision (symbol, cost), // Amount of quote currency to use + // stop orders ---------------------------------------------------- + // 'stop': 'loss', // loss or entry, the default is loss, requires stopPrice + // 'stopPrice': this.priceToPrecision (symbol, amount), // need to be defined if stop is specified + // margin orders -------------------------------------------------- + // 'marginMode': 'cross', // cross (cross mode) and isolated (isolated mode), set to cross by default, the isolated mode will be released soon, stay tuned + // 'autoBorrow': false, // The system will first borrow you funds at the optimal interest rate and then place an order for you }; if (type !== 'market') { request['price'] = this.priceToPrecision (symbol, price); @@ -81161,9 +87980,32 @@ module.exports = class kucoin extends Exchange { } async cancelOrder (id, symbol = undefined, params = {}) { - const request = { 'orderId': id }; - const response = await this.privateDeleteOrdersOrderId (this.extend (request, params)); - return response; + await this.loadMarkets (); + const request = {}; + const clientOrderId = this.safeString2 (params, 'clientOid', 'clientOrderId'); + let method = 'privateDeleteOrdersOrderId'; + if (clientOrderId !== undefined) { + request['clientOid'] = clientOrderId; + method = 'privateDeleteOrdersClientOrderClientOid'; + } else { + request['orderId'] = id; + } + params = this.omit (params, [ 'clientOid', 'clientOrderId' ]); + return await this[method] (this.extend (request, params)); + } + + async cancelAllOrders (symbol = undefined, params = {}) { + await this.loadMarkets (); + const request = { + // 'symbol': market['id'], + // 'tradeType': 'TRADE', // default is to cancel the spot trading order + }; + let market = undefined; + if (symbol !== undefined) { + market = this.market (symbol); + request['symbol'] = market['id']; + } + return await this.privateDeleteOrders (this.extend (request, params)); } async fetchOrdersByStatus (status, symbol = undefined, since = undefined, limit = undefined, params = {}) { @@ -81241,20 +88083,27 @@ module.exports = class kucoin extends Exchange { async fetchOrder (id, symbol = undefined, params = {}) { await this.loadMarkets (); - // a special case for undefined ids - // otherwise a wrong endpoint for all orders will be triggered - // https://github.com/ccxt/ccxt/issues/7234 - if (id === undefined) { - throw new InvalidOrder (this.id + ' fetchOrder requires an order id'); + const request = {}; + const clientOrderId = this.safeString2 (params, 'clientOid', 'clientOrderId'); + let method = 'privateGetOrdersOrderId'; + if (clientOrderId !== undefined) { + request['clientOid'] = clientOrderId; + method = 'privateGetOrdersClientOrderClientOid'; + } else { + // a special case for undefined ids + // otherwise a wrong endpoint for all orders will be triggered + // https://github.com/ccxt/ccxt/issues/7234 + if (id === undefined) { + throw new InvalidOrder (this.id + ' fetchOrder() requires an order id'); + } + request['orderId'] = id; } - const request = { - 'orderId': id, - }; + params = this.omit (params, [ 'clientOid', 'clientOrderId' ]); + const response = await this[method] (this.extend (request, params)); let market = undefined; if (symbol !== undefined) { market = this.market (symbol); } - const response = await this.privateGetOrdersOrderId (this.extend (request, params)); const responseData = this.safeValue (response, 'data'); return this.parseOrder (responseData, market); } @@ -81331,12 +88180,14 @@ module.exports = class kucoin extends Exchange { const clientOrderId = this.safeString (order, 'clientOid'); const timeInForce = this.safeString (order, 'timeInForce'); const stopPrice = this.safeFloat (order, 'stopPrice'); + const postOnly = this.safeValue (order, 'postOnly'); return { 'id': orderId, 'clientOrderId': clientOrderId, 'symbol': symbol, 'type': type, 'timeInForce': timeInForce, + 'postOnly': postOnly, 'side': side, 'amount': amount, 'price': price, @@ -81665,6 +88516,7 @@ module.exports = class kucoin extends Exchange { // "status": "SUCCESS", // "createdAt": 1544178843000, // "updatedAt": 1544178891000 + // "remark":"foobar" // } // // fetchWithdrawals @@ -81681,6 +88533,7 @@ module.exports = class kucoin extends Exchange { // "status": "FAILURE", // "createdAt": 1546503758000, // "updatedAt": 1546504603000 + // "remark":"foobar" // } // const currencyId = this.safeString (transaction, 'currency'); @@ -81731,20 +88584,26 @@ module.exports = class kucoin extends Exchange { updated = updated * 1000; } } + const comment = this.safeString (transaction, 'remark'); return { 'id': id, + 'info': transaction, + 'timestamp': timestamp, + 'datetime': this.iso8601 (timestamp), 'address': address, + 'addressTo': address, + 'addressFrom': undefined, 'tag': tag, + 'tagTo': tag, + 'tagFrom': undefined, 'currency': code, 'amount': amount, 'txid': txid, 'type': type, 'status': status, + 'comment': comment, 'fee': fee, - 'timestamp': timestamp, - 'datetime': this.iso8601 (timestamp), 'updated': updated, - 'info': transaction, }; } @@ -81792,6 +88651,7 @@ module.exports = class kucoin extends Exchange { // "status": "SUCCESS", // "createdAt": 1544178843000, // "updatedAt": 1544178891000 + // "remark":"foobar" // }, // //-------------------------------------------------- // // version 1 (historical) deposit response structure @@ -81921,7 +88781,7 @@ module.exports = class kucoin extends Exchange { async fetchLedger (code = undefined, since = undefined, limit = undefined, params = {}) { if (code === undefined) { - throw new ArgumentsRequired (this.id + ' fetchLedger requires a code param'); + throw new ArgumentsRequired (this.id + ' fetchLedger() requires a code param'); } await this.loadMarkets (); await this.loadAccounts (); @@ -82064,7 +88924,7 @@ module.exports = class kucoin extends Exchange { // † ↑ // const versions = this.safeValue (this.options, 'versions', {}); - const apiVersions = this.safeValue (versions, api); + const apiVersions = this.safeValue (versions, api, {}); const methodVersions = this.safeValue (apiVersions, method, {}); const defaultVersion = this.safeString (methodVersions, path, this.options['version']); const version = this.safeString (params, 'version', defaultVersion); @@ -82087,10 +88947,17 @@ module.exports = class kucoin extends Exchange { this.checkRequiredCredentials (); const timestamp = this.nonce ().toString (); headers = this.extend ({ + 'KC-API-KEY-VERSION': '2', 'KC-API-KEY': this.apiKey, 'KC-API-TIMESTAMP': timestamp, - 'KC-API-PASSPHRASE': this.password, }, headers); + const apiKeyVersion = this.safeString (headers, 'KC-API-KEY-VERSION'); + if (apiKeyVersion === '2') { + const passphrase = this.hmac (this.encode (this.password), this.encode (this.secret), 'sha256', 'base64'); + headers['KC-API-PASSPHRASE'] = passphrase; + } else { + headers['KC-API-PASSPHRASE'] = this.password; + } const payload = timestamp + method + endpoint + endpart; const signature = this.hmac (this.encode (payload), this.encode (this.secret), 'sha256', 'base64'); headers['KC-API-SIGN'] = signature; @@ -82125,7 +88992,7 @@ module.exports = class kucoin extends Exchange { } }; -},{"./base/Exchange":5,"./base/errors":7}],101:[function(require,module,exports){ +},{"./base/Exchange":6,"./base/errors":8}],104:[function(require,module,exports){ 'use strict'; // --------------------------------------------------------------------------- @@ -82248,7 +89115,7 @@ module.exports = class kuna extends acx { async fetchOpenOrders (symbol = undefined, since = undefined, limit = undefined, params = {}) { if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' fetchOpenOrders requires a symbol argument'); + throw new ArgumentsRequired (this.id + ' fetchOpenOrders() requires a symbol argument'); } await this.loadMarkets (); const market = this.market (symbol); @@ -82310,7 +89177,7 @@ module.exports = class kuna extends acx { async fetchMyTrades (symbol = undefined, since = undefined, limit = undefined, params = {}) { if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' fetchOpenOrders requires a symbol argument'); + throw new ArgumentsRequired (this.id + ' fetchMyTrades() requires a symbol argument'); } await this.loadMarkets (); const market = this.market (symbol); @@ -82341,7 +89208,7 @@ module.exports = class kuna extends acx { } }; -},{"./acx.js":3,"./base/errors":7}],102:[function(require,module,exports){ +},{"./acx.js":4,"./base/errors":8}],105:[function(require,module,exports){ 'use strict'; // --------------------------------------------------------------------------- @@ -82671,7 +89538,7 @@ module.exports = class lakebtc extends Exchange { } }; -},{"./base/Exchange":5,"./base/errors":7}],103:[function(require,module,exports){ +},{"./base/Exchange":6,"./base/errors":8}],106:[function(require,module,exports){ 'use strict'; // --------------------------------------------------------------------------- @@ -83208,7 +90075,7 @@ module.exports = class latoken extends Exchange { async fetchMyTrades (symbol = undefined, since = undefined, limit = undefined, params = {}) { if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' fetchMyTrades requires a symbol argument'); + throw new ArgumentsRequired (this.id + ' fetchMyTrades() requires a symbol argument'); } await this.loadMarkets (); const market = this.market (symbol); @@ -83320,6 +90187,7 @@ module.exports = class latoken extends Exchange { 'symbol': symbol, 'type': type, 'timeInForce': undefined, + 'postOnly': undefined, 'side': side, 'price': price, 'stopPrice': undefined, @@ -83354,7 +90222,7 @@ module.exports = class latoken extends Exchange { async fetchOrdersWithMethod (method, symbol = undefined, since = undefined, limit = undefined, params = {}) { if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' fetchOrdersWithMethod requires a symbol argument'); + throw new ArgumentsRequired (this.id + ' fetchOrdersWithMethod() requires a symbol argument'); } await this.loadMarkets (); const market = this.market (symbol); @@ -83470,7 +90338,7 @@ module.exports = class latoken extends Exchange { async cancelAllOrders (symbol = undefined, params = {}) { if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' cancelAllOrders requires a symbol argument'); + throw new ArgumentsRequired (this.id + ' cancelAllOrders() requires a symbol argument'); } await this.loadMarkets (); const marketId = this.marketId (symbol); @@ -83560,7 +90428,7 @@ module.exports = class latoken extends Exchange { } }; -},{"./base/Exchange":5,"./base/errors":7,"./base/functions/number":13}],104:[function(require,module,exports){ +},{"./base/Exchange":6,"./base/errors":8,"./base/functions/number":14}],107:[function(require,module,exports){ 'use strict'; // --------------------------------------------------------------------------- @@ -83921,10 +90789,10 @@ module.exports = class lbank extends Exchange { await this.loadMarkets (); const market = this.market (symbol); if (since === undefined) { - throw new ArgumentsRequired (this.id + ' fetchOHLCV requires a `since` argument'); + throw new ArgumentsRequired (this.id + ' fetchOHLCV() requires a `since` argument'); } if (limit === undefined) { - throw new ArgumentsRequired (this.id + ' fetchOHLCV requires a `limit` argument'); + throw new ArgumentsRequired (this.id + ' fetchOHLCV() requires a `limit` argument'); } const request = { 'symbol': market['id'], @@ -84049,6 +90917,7 @@ module.exports = class lbank extends Exchange { 'symbol': symbol, 'type': type, 'timeInForce': undefined, + 'postOnly': undefined, 'side': side, 'price': price, 'stopPrice': undefined, @@ -84260,7 +91129,7 @@ module.exports = class lbank extends Exchange { } }; -},{"./base/Exchange":5,"./base/errors":7}],105:[function(require,module,exports){ +},{"./base/Exchange":6,"./base/errors":8}],108:[function(require,module,exports){ 'use strict'; // --------------------------------------------------------------------------- @@ -84449,6 +91318,7 @@ module.exports = class liquid extends Exchange { 'must_be_positive': InvalidOrder, 'less_than_order_size': InvalidOrder, 'price_too_high': InvalidOrder, + 'price_too_small': InvalidOrder, // {"errors":{"order":["price_too_small"]}} }, 'commonCurrencies': { 'WIN': 'WCOIN', @@ -84986,7 +91856,7 @@ module.exports = class liquid extends Exchange { async editOrder (id, symbol, type, side, amount, price = undefined, params = {}) { await this.loadMarkets (); if (price === undefined) { - throw new ArgumentsRequired (this.id + ' editOrder requires the price argument'); + throw new ArgumentsRequired (this.id + ' editOrder() requires the price argument'); } const request = { 'order': { @@ -85127,6 +91997,7 @@ module.exports = class liquid extends Exchange { 'lastTradeTimestamp': lastTradeTimestamp, 'type': type, 'timeInForce': undefined, + 'postOnly': undefined, 'status': status, 'symbol': symbol, 'side': side, @@ -85396,940 +92267,7 @@ module.exports = class liquid extends Exchange { } }; -},{"./base/Exchange":5,"./base/errors":7,"./base/functions/number":13}],106:[function(require,module,exports){ -'use strict'; - -// --------------------------------------------------------------------------- - -const Exchange = require ('./base/Exchange'); -const { ExchangeError, OnMaintenance, BadResponse, ArgumentsRequired, AuthenticationError, NotSupported, InvalidOrder, OrderNotFound, ExchangeNotAvailable, RateLimitExceeded, InsufficientFunds } = require ('./base/errors'); -const { TRUNCATE, DECIMAL_PLACES } = require ('./base/functions/number'); - -// --------------------------------------------------------------------------- - -module.exports = class livecoin extends Exchange { - describe () { - return this.deepExtend (super.describe (), { - 'id': 'livecoin', - 'name': 'LiveCoin', - 'countries': [ 'US', 'UK', 'RU' ], - 'rateLimit': 1000, - 'userAgent': this.userAgents['chrome'], - 'has': { - 'cancelOrder': true, - 'CORS': false, - 'createOrder': true, - 'fetchBalance': true, - 'fetchClosedOrders': true, - 'fetchCurrencies': true, - 'fetchDepositAddress': true, - 'fetchDeposits': true, - 'fetchMarkets': true, - 'fetchMyTrades': true, - 'fetchOpenOrders': true, - 'fetchOrder': true, - 'fetchOrderBook': true, - 'fetchOrders': true, - 'fetchTicker': true, - 'fetchTickers': true, - 'fetchTrades': true, - 'fetchTradingFee': true, - 'fetchTradingFees': true, - 'fetchWithdrawals': true, - 'withdraw': true, - }, - 'urls': { - 'logo': 'https://user-images.githubusercontent.com/1294454/27980768-f22fc424-638a-11e7-89c9-6010a54ff9be.jpg', - 'api': 'https://api.livecoin.net', - 'www': 'https://www.livecoin.net', - 'doc': 'https://www.livecoin.net/api?lang=en', - 'referral': 'https://livecoin.net/?from=Livecoin-CQ1hfx44', - }, - 'api': { - 'public': { - 'get': [ - 'exchange/all/order_book', - 'exchange/last_trades', - 'exchange/maxbid_minask', - 'exchange/order_book', - 'exchange/restrictions', - 'exchange/ticker', // omit params to get all tickers at once - 'info/coinInfo', - ], - }, - 'private': { - 'get': [ - 'exchange/client_orders', - 'exchange/order', - 'exchange/trades', - 'exchange/commission', - 'exchange/commissionCommonInfo', - 'payment/balances', - 'payment/balance', - 'payment/get/address', - 'payment/history/size', - 'payment/history/transactions', - ], - 'post': [ - 'exchange/buylimit', - 'exchange/buymarket', - 'exchange/cancellimit', - 'exchange/selllimit', - 'exchange/sellmarket', - 'payment/out/capitalist', - 'payment/out/card', - 'payment/out/coin', - 'payment/out/okpay', - 'payment/out/payeer', - 'payment/out/perfectmoney', - 'payment/voucher/amount', - 'payment/voucher/make', - 'payment/voucher/redeem', - ], - }, - }, - 'fees': { - 'trading': { - 'tierBased': false, - 'percentage': true, - 'maker': 0.18 / 100, - 'taker': 0.18 / 100, - }, - }, - 'commonCurrencies': { - 'BIT': 'First Bitcoin', - 'BTCH': 'Bithash', - 'CPC': 'Capricoin', - 'CBC': 'CryptoBossCoin', // conflict with CBC (CashBet Coin) - 'CPT': 'Cryptos', // conflict with CPT = Contents Protocol https://github.com/ccxt/ccxt/issues/4920 and https://github.com/ccxt/ccxt/issues/6081 - 'EDR': 'E-Dinar Coin', // conflicts with EDR for Endor Protocol and EDRCoin - 'eETT': 'EETT', - 'FirstBlood': '1ST', - 'FORTYTWO': '42', - 'LEO': 'LeoCoin', - 'MIOTA': 'IOTA', // https://github.com/ccxt/ccxt/issues/7487 - 'ORE': 'Orectic', - 'PLN': 'Plutaneum', // conflict with Polish Zloty - 'RUR': 'RUB', - 'SCT': 'SpaceCoin', - 'TPI': 'ThaneCoin', - 'UNUS': 'LEO', // https://github.com/ccxt/ccxt/issues/7496 - 'WAX': 'WAXP', - 'wETT': 'WETT', - 'XBT': 'Bricktox', - }, - 'exceptions': { - 'exact': { - '1': ExchangeError, - '10': AuthenticationError, - '100': ExchangeError, // invalid parameters - '101': AuthenticationError, - '102': AuthenticationError, - '103': InvalidOrder, // invalid currency - '104': InvalidOrder, // invalid amount - '105': InvalidOrder, // unable to block funds - '11': AuthenticationError, - '12': AuthenticationError, - '2': AuthenticationError, // "User not found" - '20': AuthenticationError, - '30': AuthenticationError, - '31': NotSupported, - '32': ExchangeError, - '429': RateLimitExceeded, - '503': ExchangeNotAvailable, - }, - 'broad': { - 'insufficient funds': InsufficientFunds, // https://github.com/ccxt/ccxt/issues/5749 - 'NOT FOUND': OrderNotFound, - 'Cannot find order': OrderNotFound, - 'Minimal amount is': InvalidOrder, - }, - }, - }); - } - - async fetchMarkets (params = {}) { - const response = await this.publicGetExchangeTicker (params); - const restrictions = await this.publicGetExchangeRestrictions (); - const restrictionsById = this.indexBy (restrictions['restrictions'], 'currencyPair'); - const result = []; - for (let i = 0; i < response.length; i++) { - const market = response[i]; - const id = this.safeString (market, 'symbol'); - const [ baseId, quoteId ] = id.split ('/'); - const base = this.safeCurrencyCode (baseId); - const quote = this.safeCurrencyCode (quoteId); - const symbol = base + '/' + quote; - const coinRestrictions = this.safeValue (restrictionsById, symbol); - const precision = { - 'price': 5, - 'amount': 8, - 'cost': 8, - }; - const limits = { - 'amount': { - 'min': Math.pow (10, -precision['amount']), - 'max': Math.pow (10, precision['amount']), - }, - }; - if (coinRestrictions) { - precision['price'] = this.safeInteger (coinRestrictions, 'priceScale', 5); - limits['amount']['min'] = this.safeFloat (coinRestrictions, 'minLimitQuantity', limits['amount']['min']); - } - limits['price'] = { - 'min': Math.pow (10, -precision['price']), - 'max': Math.pow (10, precision['price']), - }; - result.push ({ - 'id': id, - 'symbol': symbol, - 'base': base, - 'quote': quote, - 'baseId': baseId, - 'quoteId': quoteId, - 'active': true, - 'precision': precision, - 'limits': limits, - 'info': market, - }); - } - return result; - } - - async fetchCurrencies (params = {}) { - const response = await this.publicGetInfoCoinInfo (params); - if (typeof response === 'string') { - if (response.indexOf ('site is under maintenance') >= 0) { - throw new OnMaintenance (this.id + ' fetchCurrencies() failed to fetch the currencies, the exchange is on maintenance'); - } else { - throw new BadResponse (this.id + ' fetchCurrencies() failed to fetch the currencies'); - } - } - const currencies = this.safeValue (response, 'info'); - let result = {}; - for (let i = 0; i < currencies.length; i++) { - const currency = currencies[i]; - const id = this.safeString (currency, 'symbol'); - // todo: will need to rethink the fees - // to add support for multiple withdrawal/deposit methods and - // differentiated fees for each particular method - const code = this.safeCurrencyCode (id); - const precision = 8; // default precision, todo: fix "magic constants" - const walletStatus = this.safeString (currency, 'walletStatus'); - const active = (walletStatus === 'normal'); - const name = this.safeString (currency, 'name'); - const fee = this.safeFloat (currency, 'withdrawFee'); - result[code] = { - 'id': id, - 'code': code, - 'info': currency, - 'name': name, - 'active': active, - 'fee': fee, - 'precision': precision, - 'limits': { - 'amount': { - 'min': this.safeFloat (currency, 'minOrderAmount'), - 'max': Math.pow (10, precision), - }, - 'price': { - 'min': Math.pow (10, -precision), - 'max': Math.pow (10, precision), - }, - 'cost': { - 'min': this.safeFloat (currency, 'minOrderAmount'), - 'max': undefined, - }, - 'withdraw': { - 'min': this.safeFloat (currency, 'minWithdrawAmount'), - 'max': Math.pow (10, precision), - }, - 'deposit': { - 'min': this.safeFloat (currency, 'minDepositAmount'), - 'max': undefined, - }, - }, - }; - } - result = this.appendFiatCurrencies (result); - return result; - } - - appendFiatCurrencies (result) { - const precision = 8; - const defaults = { - 'info': undefined, - 'active': true, - 'fee': undefined, - 'precision': precision, - 'limits': { - 'withdraw': { 'min': undefined, 'max': undefined }, - 'deposit': { 'min': undefined, 'max': undefined }, - 'amount': { 'min': undefined, 'max': undefined }, - 'cost': { 'min': undefined, 'max': undefined }, - 'price': { - 'min': Math.pow (10, -precision), - 'max': Math.pow (10, precision), - }, - }, - 'id': undefined, - 'code': undefined, - 'name': undefined, - }; - const currencies = [ - { 'id': 'USD', 'code': 'USD', 'name': 'US Dollar' }, - { 'id': 'EUR', 'code': 'EUR', 'name': 'Euro' }, - // { 'id': 'RUR', 'code': 'RUB', 'name': 'Russian ruble' }, - ]; - currencies.push ({ - 'id': 'RUR', - 'code': this.safeCurrencyCode ('RUR'), - 'name': 'Russian ruble', - }); - for (let i = 0; i < currencies.length; i++) { - const currency = currencies[i]; - const code = currency['code']; - result[code] = this.extend (defaults, currency); - } - return result; - } - - async fetchBalance (params = {}) { - await this.loadMarkets (); - const response = await this.privateGetPaymentBalances (params); - const result = { 'info': response }; - for (let i = 0; i < response.length; i++) { - const balance = response[i]; - const currencyId = this.safeString (balance, 'currency'); - const code = this.safeCurrencyCode (currencyId); - let account = undefined; - if (code in result) { - account = result[code]; - } else { - account = this.account (); - } - if (balance['type'] === 'total') { - account['total'] = this.safeFloat (balance, 'value'); - } - if (balance['type'] === 'available') { - account['free'] = this.safeFloat (balance, 'value'); - } - if (balance['type'] === 'trade') { - account['used'] = this.safeFloat (balance, 'value'); - } - result[code] = account; - } - return this.parseBalance (result); - } - - async fetchTradingFees (params = {}) { - await this.loadMarkets (); - const response = await this.privateGetExchangeCommissionCommonInfo (params); - const commission = this.safeFloat (response, 'commission'); - return { - 'info': response, - 'maker': commission, - 'taker': commission, - }; - } - - async fetchOrderBook (symbol, limit = undefined, params = {}) { - await this.loadMarkets (); - const request = { - 'currencyPair': this.marketId (symbol), - 'groupByPrice': 'false', - }; - if (limit !== undefined) { - request['depth'] = limit; // 100 - } - const response = await this.publicGetExchangeOrderBook (this.extend (request, params)); - const timestamp = this.safeInteger (response, 'timestamp'); - return this.parseOrderBook (response, timestamp); - } - - parseTicker (ticker, market = undefined) { - const timestamp = this.milliseconds (); - let symbol = undefined; - if (market) { - symbol = market['symbol']; - } - const vwap = this.safeFloat (ticker, 'vwap'); - const baseVolume = this.safeFloat (ticker, 'volume'); - let quoteVolume = undefined; - if (baseVolume !== undefined && vwap !== undefined) { - quoteVolume = baseVolume * vwap; - } - const last = this.safeFloat (ticker, 'last'); - return { - 'symbol': symbol, - 'timestamp': timestamp, - 'datetime': this.iso8601 (timestamp), - 'high': this.safeFloat (ticker, 'high'), - 'low': this.safeFloat (ticker, 'low'), - 'bid': this.safeFloat (ticker, 'best_bid'), - 'bidVolume': undefined, - 'ask': this.safeFloat (ticker, 'best_ask'), - 'askVolume': undefined, - 'vwap': this.safeFloat (ticker, 'vwap'), - 'open': undefined, - 'close': last, - 'last': last, - 'previousClose': undefined, - 'change': undefined, - 'percentage': undefined, - 'average': undefined, - 'baseVolume': baseVolume, - 'quoteVolume': quoteVolume, - 'info': ticker, - }; - } - - async fetchTickers (symbols = undefined, params = {}) { - await this.loadMarkets (); - const response = await this.publicGetExchangeTicker (params); - const tickers = this.indexBy (response, 'symbol'); - const ids = Object.keys (tickers); - const result = {}; - for (let i = 0; i < ids.length; i++) { - const id = ids[i]; - const market = this.safeMarket (id); - const symbol = market['symbol']; - const ticker = tickers[id]; - result[symbol] = this.parseTicker (ticker, market); - } - return this.filterByArray (result, 'symbol', symbols); - } - - async fetchTicker (symbol, params = {}) { - await this.loadMarkets (); - const market = this.market (symbol); - const request = { - 'currencyPair': market['id'], - }; - const ticker = await this.publicGetExchangeTicker (this.extend (request, params)); - return this.parseTicker (ticker, market); - } - - parseTrade (trade, market = undefined) { - // - // fetchTrades (public) - // - // { - // "time": 1409935047, - // "id": 99451, - // "price": 350, - // "quantity": 2.85714285, - // "type": "BUY" - // } - // - // fetchMyTrades (private) - // - // { - // "datetime": 1435844369, - // "id": 30651619, - // "type": "sell", - // "symbol": "BTC/EUR", - // "price": 230, - // "quantity": 0.1, - // "commission": 0, - // "clientorderid": 1472837650 - // } - const timestamp = this.safeTimestamp2 (trade, 'time', 'datetime'); - let fee = undefined; - const feeCost = this.safeFloat (trade, 'commission'); - if (feeCost !== undefined) { - const feeCurrency = market ? market['quote'] : undefined; - fee = { - 'cost': feeCost, - 'currency': feeCurrency, - }; - } - const orderId = this.safeString (trade, 'clientorderid'); - const id = this.safeString (trade, 'id'); - const side = this.safeStringLower (trade, 'type'); - const amount = this.safeFloat (trade, 'quantity'); - const price = this.safeFloat (trade, 'price'); - let cost = undefined; - if (amount !== undefined) { - if (price !== undefined) { - cost = amount * price; - } - } - const marketId = this.safeString (trade, 'symbol'); - const symbol = this.safeSymbol (marketId, market, '/'); - return { - 'id': id, - 'info': trade, - 'timestamp': timestamp, - 'datetime': this.iso8601 (timestamp), - 'symbol': symbol, - 'order': orderId, - 'type': undefined, - 'side': side, - 'takerOrMaker': undefined, - 'price': price, - 'amount': amount, - 'cost': cost, - 'fee': fee, - }; - } - - async fetchMyTrades (symbol = undefined, since = undefined, limit = undefined, params = {}) { - await this.loadMarkets (); - const request = { - // 'currencyPair': market['id'], - // 'orderDesc': 'true', // or 'false', if true then new orders will be first, otherwise old orders will be first. - // 'offset': 0, // page offset, position of the first item on the page - }; - let market = undefined; - if (symbol !== undefined) { - market = this.market (symbol); - request['currencyPair'] = market['id']; - } - if (limit !== undefined) { - request['limit'] = limit; - } - const response = await this.privateGetExchangeTrades (this.extend (request, params)); - // - // [ - // { - // "datetime": 1435844369, - // "id": 30651619, - // "type": "sell", - // "symbol": "BTC/EUR", - // "price": 230, - // "quantity": 0.1, - // "commission": 0, - // "clientorderid": 1472837650 - // }, - // { - // "datetime": 1435844356, - // "id": 30651618, - // "type": "sell", - // "symbol": "BTC/EUR", - // "price": 230, - // "quantity": 0.2, - // "commission": 0.092, - // "clientorderid": 1472837651 - // } - // ] - // - return this.parseTrades (response, market, since, limit); - } - - async fetchTrades (symbol, since = undefined, limit = undefined, params = {}) { - await this.loadMarkets (); - const market = this.market (symbol); - const request = { - 'currencyPair': market['id'], - }; - const response = await this.publicGetExchangeLastTrades (this.extend (request, params)); - // - // [ - // { - // "time": 1409935047, - // "id": 99451, - // "price": 350, - // "quantity": 2.85714285, - // "type": "BUY" - // }, - // { - // "time": 1409934792, - // "id": 99450, - // "price": 350, - // "quantity": 0.57142857, - // "type": "SELL" - // } - // ] - // - return this.parseTrades (response, market, since, limit); - } - - async fetchOrder (id, symbol = undefined, params = {}) { - await this.loadMarkets (); - const request = { - 'orderId': id, - }; - const response = await this.privateGetExchangeOrder (this.extend (request, params)); - return this.parseOrder (response); - } - - parseOrderStatus (status) { - const statuses = { - 'OPEN': 'open', - 'PARTIALLY_FILLED': 'open', - 'EXECUTED': 'closed', - 'CANCELLED': 'canceled', - 'PARTIALLY_FILLED_AND_CANCELLED': 'canceled', - }; - return this.safeString (statuses, status, status); - } - - parseOrder (order, market = undefined) { - let timestamp = undefined; - if ('lastModificationTime' in order) { - timestamp = this.safeString (order, 'lastModificationTime'); - if (timestamp !== undefined) { - if (timestamp.indexOf ('T') >= 0) { - timestamp = this.parse8601 (timestamp); - } else { - timestamp = this.safeInteger (order, 'lastModificationTime'); - } - } - } - // TODO currently not supported by livecoin - // let trades = this.parseTrades (order['trades'], market, since, limit); - const trades = undefined; - const status = this.parseOrderStatus (this.safeString2 (order, 'status', 'orderStatus')); - const marketId = this.safeString2 (order, 'symbol', 'currencyPair'); - const symbol = this.safeSymbol (marketId, market, '/'); - let type = this.safeStringLower (order, 'type'); - let side = undefined; - if (type !== undefined) { - const orderType = type.split ('_'); - type = orderType[0]; - side = orderType[1]; - } - const price = this.safeFloat (order, 'price'); - // of the next two lines the latter overrides the former, if present in the order structure - let remaining = this.safeFloat (order, 'remainingQuantity'); - remaining = this.safeFloat (order, 'remaining_quantity', remaining); - const amount = this.safeFloat (order, 'quantity', remaining); - let filled = undefined; - if (remaining !== undefined) { - filled = amount - remaining; - } - let cost = undefined; - if (filled !== undefined && price !== undefined) { - cost = filled * price; - } - const feeRate = this.safeFloat (order, 'commission_rate'); - let feeCost = undefined; - if (cost !== undefined && feeRate !== undefined) { - feeCost = cost * feeRate; - } - if ((market === undefined) && (symbol in this.markets)) { - market = this.markets[symbol]; - } - let feeCurrency = undefined; - if (market !== undefined) { - feeCurrency = market['quote']; - } - return { - 'info': order, - 'id': order['id'], - 'clientOrderId': undefined, - 'timestamp': timestamp, - 'datetime': this.iso8601 (timestamp), - 'lastTradeTimestamp': undefined, - 'status': status, - 'symbol': symbol, - 'type': type, - 'timeInForce': undefined, - 'side': side, - 'price': price, - 'stopPrice': undefined, - 'amount': amount, - 'cost': cost, - 'filled': filled, - 'remaining': remaining, - 'trades': trades, - 'fee': { - 'cost': feeCost, - 'currency': feeCurrency, - 'rate': feeRate, - }, - 'average': undefined, - }; - } - - async fetchOrders (symbol = undefined, since = undefined, limit = undefined, params = {}) { - await this.loadMarkets (); - let market = undefined; - const request = {}; - if (symbol !== undefined) { - market = this.market (symbol); - request['currencyPair'] = market['id']; - } - if (since !== undefined) { - request['issuedFrom'] = parseInt (since); - } - if (limit !== undefined) { - request['endRow'] = limit - 1; - } - const response = await this.privateGetExchangeClientOrders (this.extend (request, params)); - const result = []; - let rawOrders = []; - if (response['data']) { - rawOrders = response['data']; - } - for (let i = 0; i < rawOrders.length; i++) { - const order = rawOrders[i]; - result.push (this.parseOrder (order, market)); - } - return this.sortBy (result, 'timestamp'); - } - - async fetchOpenOrders (symbol = undefined, since = undefined, limit = undefined, params = {}) { - const request = { - 'openClosed': 'OPEN', - }; - return await this.fetchOrders (symbol, since, limit, this.extend (request, params)); - } - - async fetchClosedOrders (symbol = undefined, since = undefined, limit = undefined, params = {}) { - const request = { - 'openClosed': 'CLOSED', - }; - return await this.fetchOrders (symbol, since, limit, this.extend (request, params)); - } - - async createOrder (symbol, type, side, amount, price = undefined, params = {}) { - await this.loadMarkets (); - const method = 'privatePostExchange' + this.capitalize (side) + type; - const market = this.market (symbol); - const request = { - 'quantity': this.amountToPrecision (symbol, amount), - 'currencyPair': market['id'], - }; - if (type === 'limit') { - request['price'] = this.priceToPrecision (symbol, price); - } - const response = await this[method] (this.extend (request, params)); - const result = { - 'info': response, - 'id': response['orderId'].toString (), - }; - const success = this.safeValue (response, 'success'); - if (success) { - result['status'] = 'open'; - } - return result; - } - - async cancelOrder (id, symbol = undefined, params = {}) { - if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' cancelOrder requires a symbol argument'); - } - await this.loadMarkets (); - const market = this.market (symbol); - const request = { - 'orderId': id, - 'currencyPair': market['id'], - }; - const response = await this.privatePostExchangeCancellimit (this.extend (request, params)); - const message = this.safeString (response, 'message', this.json (response)); - if ('success' in response) { - if (!response['success']) { - throw new InvalidOrder (message); - } else if ('cancelled' in response) { - if (response['cancelled']) { - return { - 'status': 'canceled', - 'info': response, - }; - } else { - throw new OrderNotFound (message); - } - } - } - throw new ExchangeError (this.id + ' cancelOrder() failed: ' + this.json (response)); - } - - async withdraw (code, amount, address, tag = undefined, params = {}) { - // Sometimes the response with be { key: null } for all keys. - // An example is if you attempt to withdraw more than is allowed when withdrawal fees are considered. - this.checkAddress (address); - await this.loadMarkets (); - const currency = this.currency (code); - let wallet = address; - if (tag !== undefined) { - wallet += '::' + tag; - } - const request = { - 'amount': this.decimalToPrecision (amount, TRUNCATE, currency['precision'], DECIMAL_PLACES), - 'currency': currency['id'], - 'wallet': wallet, - }; - const response = await this.privatePostPaymentOutCoin (this.extend (request, params)); - const id = this.safeInteger (response, 'id'); - if (id === undefined) { - throw new InsufficientFunds (this.id + ' insufficient funds to cover requested withdrawal amount post fees ' + this.json (response)); - } - return { - 'info': response, - 'id': id, - }; - } - - parseTransaction (transaction, currency = undefined) { - // { - // "id": "c853093d5aa06df1c92d79c2...", (tx on deposits, address on withdrawals) - // "type": "DEPOSIT", - // "date": 1553186482676, - // "amount": 712.61266, - // "fee": 0, - // "fixedCurrency": "XVG", - // "taxCurrency": "XVG", - // "variableAmount": null, - // "variableCurrency": null, - // "external": "Coin", - // "login": "USERNAME", - // "externalKey": "....87diPBy......3hTtuwUT78Yi", (address on deposits, tx on withdrawals) - // "documentId": 1110662453 - // }, - let txid = undefined; - let address = undefined; - const id = this.safeString (transaction, 'documentId'); - const amount = this.safeFloat (transaction, 'amount'); - const timestamp = this.safeInteger (transaction, 'date'); - const type = this.safeStringLower (transaction, 'type'); - const currencyId = this.safeString (transaction, 'fixedCurrency'); - const feeCost = this.safeFloat (transaction, 'fee'); - const code = this.safeCurrencyCode (currencyId, currency); - if (type === 'withdrawal') { - txid = this.safeString (transaction, 'externalKey'); - address = this.safeString (transaction, 'id'); - } else if (type === 'deposit') { - address = this.safeString (transaction, 'externalKey'); - txid = this.safeString (transaction, 'id'); - } - let status = undefined; - if (type === 'deposit') { - status = 'ok'; // Deposits is not registered until they are in account. Withdrawals are left as undefined, not entirely sure about theyre status. - } - return { - 'info': transaction, - 'id': id, - 'currency': code, - 'amount': amount, - 'address': address, - 'tag': undefined, - 'status': status, - 'type': type, - 'updated': undefined, - 'txid': txid, - 'timestamp': timestamp, - 'datetime': this.iso8601 (timestamp), - 'fee': { - 'currency': code, - 'cost': feeCost, - }, - }; - } - - async fetchDeposits (code = undefined, since = undefined, limit = undefined, params = {}) { - await this.loadMarkets (); - const endtime = 2505600000; // 29 days - exchange has maximum 30 days. - const now = this.milliseconds (); - const request = { - 'types': 'DEPOSIT', - 'end': now, - 'start': (since !== undefined) ? parseInt (since) : now - endtime, - }; - let currency = undefined; - if (code !== undefined) { - currency = this.currency (code); - } - if (limit !== undefined) { - request['limit'] = limit; // default is 100 - } - const response = await this.privateGetPaymentHistoryTransactions (this.extend (request, params)); - return this.parseTransactions (response, currency, since, limit); - } - - async fetchWithdrawals (code = undefined, since = undefined, limit = undefined, params = {}) { - await this.loadMarkets (); - const endtime = 2505600000; // 29 days - exchange has maximum 30 days. - const now = this.milliseconds (); - const request = { - 'types': 'WITHDRAWAL', - 'end': now, - 'start': (since !== undefined) ? parseInt (since) : now - endtime, - }; - let currency = undefined; - if (code !== undefined) { - currency = this.currency (code); - } - if (limit !== undefined) { - request['limit'] = limit; // default is 100 - } - if (since !== undefined) { - request['start'] = since; - } - const response = await this.privateGetPaymentHistoryTransactions (this.extend (request, params)); - return this.parseTransactions (response, currency, since, limit); - } - - async fetchDepositAddress (currency, params = {}) { - const request = { - 'currency': currency, - }; - const response = await this.privateGetPaymentGetAddress (this.extend (request, params)); - let address = this.safeString (response, 'wallet'); - let tag = undefined; - if (address.indexOf (':') >= 0) { - const parts = address.split (':'); - address = parts[0]; - tag = parts[2]; - } - this.checkAddress (address); - return { - 'currency': currency, - 'address': address, - 'tag': tag, - 'info': response, - }; - } - - sign (path, api = 'public', method = 'GET', params = {}, headers = undefined, body = undefined) { - let url = this.urls['api'] + '/' + path; - const query = this.urlencode (this.keysort (params)); - if (method === 'GET') { - if (Object.keys (params).length) { - url += '?' + query; - } - } - if (api === 'private') { - this.checkRequiredCredentials (); - if (method === 'POST') { - body = query; - } - const signature = this.hmac (this.encode (query), this.encode (this.secret), 'sha256'); - headers = { - 'Api-Key': this.apiKey, - 'Sign': signature.toUpperCase (), - 'Content-Type': 'application/x-www-form-urlencoded', - }; - } - return { 'url': url, 'method': method, 'body': body, 'headers': headers }; - } - - handleErrors (code, reason, url, method, headers, body, response, requestHeaders, requestBody) { - if (response === undefined) { - return; // fallback to default error handler - } - if (code >= 300) { - const feedback = this.id + ' ' + body; - const errorCode = this.safeString (response, 'errorCode'); - this.throwExactlyMatchedException (this.exceptions['exact'], errorCode, feedback); - throw new ExchangeError (feedback); - } - // returns status code 200 even if success === false - const success = this.safeValue (response, 'success', true); - if (!success) { - const feedback = this.id + ' ' + body; - const message = this.safeString2 (response, 'message', 'exception'); - if (message !== undefined) { - this.throwBroadlyMatchedException (this.exceptions['broad'], message, feedback); - } - throw new ExchangeError (feedback); - } - } -}; - - -},{"./base/Exchange":5,"./base/errors":7,"./base/functions/number":13}],107:[function(require,module,exports){ +},{"./base/Exchange":6,"./base/errors":8,"./base/functions/number":14}],109:[function(require,module,exports){ 'use strict'; // --------------------------------------------------------------------------- @@ -86370,7 +92308,11 @@ module.exports = class luno extends Exchange { 'urls': { 'referral': 'https://www.luno.com/invite/44893A', 'logo': 'https://user-images.githubusercontent.com/1294454/27766607-8c1a69d8-5ede-11e7-930c-540b5eb9be24.jpg', - 'api': 'https://api.luno.com/api', + 'api': { + 'public': 'https://api.luno.com/api', + 'private': 'https://api.luno.com/api', + 'exchange': 'https://api.luno.com/api/exchange', + }, 'www': 'https://www.luno.com', 'doc': [ 'https://www.luno.com/en/api', @@ -86379,6 +92321,11 @@ module.exports = class luno extends Exchange { ], }, 'api': { + 'exchange': { + 'get': [ + 'markets', + ], + }, 'public': { 'get': [ 'orderbook', @@ -86429,16 +92376,42 @@ module.exports = class luno extends Exchange { } async fetchMarkets (params = {}) { - const response = await this.publicGetTickers (params); + const response = await this.exchangeGetMarkets (params); + // + // { + // "markets":[ + // { + // "market_id":"BCHXBT", + // "trading_status":"ACTIVE", + // "base_currency":"BCH", + // "counter_currency":"XBT", + // "min_volume":"0.01", + // "max_volume":"100.00", + // "volume_scale":2, + // "min_price":"0.0001", + // "max_price":"1.00", + // "price_scale":6, + // "fee_scale":8, + // }, + // ] + // } + // const result = []; - for (let i = 0; i < response['tickers'].length; i++) { - const market = response['tickers'][i]; - const id = market['pair']; - const baseId = id.slice (0, 3); - const quoteId = id.slice (3, 6); + const markets = this.safeValue (response, 'markets', []); + for (let i = 0; i < markets.length; i++) { + const market = markets[i]; + const id = this.safeString (market, 'market_id'); + const baseId = this.safeString (market, 'base_currency'); + const quoteId = this.safeString (market, 'counter_currency'); const base = this.safeCurrencyCode (baseId); const quote = this.safeCurrencyCode (quoteId); const symbol = base + '/' + quote; + const status = this.safeString (market, 'trading_status'); + const active = (status === 'ACTIVE'); + const precision = { + 'amount': this.safeInteger (market, 'volume_scale'), + 'price': this.safeInteger (market, 'price_scale'), + }; result.push ({ 'id': id, 'symbol': symbol, @@ -86446,10 +92419,23 @@ module.exports = class luno extends Exchange { 'quote': quote, 'baseId': baseId, 'quoteId': quoteId, + 'active': active, + 'precision': precision, + 'limits': { + 'amount': { + 'min': this.safeFloat (market, 'min_volume'), + 'max': this.safeFloat (market, 'max_volume'), + }, + 'price': { + 'min': this.safeFloat (market, 'min_price'), + 'max': this.safeFloat (market, 'max_price'), + }, + 'cost': { + 'min': undefined, + 'max': undefined, + }, + }, 'info': market, - 'active': undefined, - 'precision': this.precision, - 'limits': this.limits, }); } return result; @@ -86477,6 +92463,16 @@ module.exports = class luno extends Exchange { async fetchBalance (params = {}) { await this.loadMarkets (); const response = await this.privateGetBalance (params); + // + // { + // 'balance': [ + // {'account_id': '119...1336','asset': 'XBT','balance': '0.00','reserved': '0.00','unconfirmed': '0.00'}, + // {'account_id': '66...289','asset': 'XBT','balance': '0.00','reserved': '0.00','unconfirmed': '0.00'}, + // {'account_id': '718...5300','asset': 'ETH','balance': '0.00','reserved': '0.00','unconfirmed': '0.00'}, + // {'account_id': '818...7072','asset': 'ZAR','balance': '0.001417','reserved': '0.00','unconfirmed': '0.00'}]} + // ] + // } + // const wallets = this.safeValue (response, 'balance', []); const result = { 'info': response }; for (let i = 0; i < wallets.length; i++) { @@ -86486,10 +92482,15 @@ module.exports = class luno extends Exchange { const reserved = this.safeFloat (wallet, 'reserved'); const unconfirmed = this.safeFloat (wallet, 'unconfirmed'); const balance = this.safeFloat (wallet, 'balance'); - const account = this.account (); - account['used'] = this.sum (reserved, unconfirmed); - account['total'] = this.sum (balance, unconfirmed); - result[code] = account; + if (code in result) { + result[code]['used'] = this.sum (result[code]['used'], reserved, unconfirmed); + result[code]['total'] = this.sum (result[code]['total'], balance, unconfirmed); + } else { + const account = this.account (); + account['used'] = this.sum (reserved, unconfirmed); + account['total'] = this.sum (balance, unconfirmed); + result[code] = account; + } } return this.parseBalance (result); } @@ -86577,6 +92578,7 @@ module.exports = class luno extends Exchange { 'symbol': symbol, 'type': undefined, 'timeInForce': undefined, + 'postOnly': undefined, 'side': side, 'price': price, 'stopPrice': undefined, @@ -86757,7 +92759,7 @@ module.exports = class luno extends Exchange { async fetchMyTrades (symbol = undefined, since = undefined, limit = undefined, params = {}) { if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' fetchMyTrades requires a symbol argument'); + throw new ArgumentsRequired (this.id + ' fetchMyTrades() requires a symbol argument'); } await this.loadMarkets (); const market = this.market (symbol); @@ -86794,15 +92796,16 @@ module.exports = class luno extends Exchange { if (type === 'market') { method += 'Marketorder'; request['type'] = side.toUpperCase (); + // todo add createMarketBuyOrderRequires price logic as it is implemented in the other exchanges if (side === 'buy') { - request['counter_volume'] = amount; + request['counter_volume'] = parseFloat (this.amountToPrecision (symbol, amount)); } else { - request['base_volume'] = amount; + request['base_volume'] = parseFloat (this.amountToPrecision (symbol, amount)); } } else { method += 'Postorder'; - request['volume'] = amount; - request['price'] = price; + request['volume'] = parseFloat (this.amountToPrecision (symbol, amount)); + request['price'] = parseFloat (this.priceToPrecision (symbol, price)); request['type'] = (side === 'buy') ? 'BID' : 'ASK'; } const response = await this[method] (this.extend (request, params)); @@ -86961,7 +92964,7 @@ module.exports = class luno extends Exchange { } sign (path, api = 'public', method = 'GET', params = {}, headers = undefined, body = undefined) { - let url = this.urls['api'] + '/' + this.version + '/' + this.implodeParams (path, params); + let url = this.urls['api'][api] + '/' + this.version + '/' + this.implodeParams (path, params); const query = this.omit (params, this.extractParams (path)); if (Object.keys (query).length) { url += '?' + this.urlencode (query); @@ -86985,7 +92988,7 @@ module.exports = class luno extends Exchange { } }; -},{"./base/Exchange":5,"./base/errors":7}],108:[function(require,module,exports){ +},{"./base/Exchange":6,"./base/errors":8}],110:[function(require,module,exports){ 'use strict'; // --------------------------------------------------------------------------- @@ -87487,6 +93490,7 @@ module.exports = class lykke extends Exchange { 'symbol': symbol, 'type': undefined, 'timeInForce': undefined, + 'postOnly': undefined, 'side': side, 'price': price, 'stopPrice': undefined, @@ -87600,7 +93604,7 @@ module.exports = class lykke extends Exchange { } }; -},{"./base/Exchange":5}],109:[function(require,module,exports){ +},{"./base/Exchange":6}],111:[function(require,module,exports){ 'use strict'; // --------------------------------------------------------------------------- @@ -87624,6 +93628,8 @@ module.exports = class mercado extends Exchange { 'createMarketOrder': true, 'createOrder': true, 'fetchBalance': true, + 'fetchMarkets': true, + 'fetchMyTrades': 'emulated', 'fetchOHLCV': true, 'fetchOpenOrders': true, 'fetchOrder': true, @@ -87663,6 +93669,7 @@ module.exports = class mercado extends Exchange { 'api': { 'public': { 'get': [ + 'coins', '{coin}/orderbook/', // last slash critical '{coin}/ticker/', '{coin}/trades/', @@ -87693,23 +93700,90 @@ module.exports = class mercado extends Exchange { ], }, }, - 'markets': { - 'BTC/BRL': { 'id': 'BRLBTC', 'symbol': 'BTC/BRL', 'base': 'BTC', 'quote': 'BRL', 'precision': { 'amount': 8, 'price': 5 }, 'suffix': 'Bitcoin' }, - 'LTC/BRL': { 'id': 'BRLLTC', 'symbol': 'LTC/BRL', 'base': 'LTC', 'quote': 'BRL', 'precision': { 'amount': 8, 'price': 5 }, 'suffix': 'Litecoin' }, - 'BCH/BRL': { 'id': 'BRLBCH', 'symbol': 'BCH/BRL', 'base': 'BCH', 'quote': 'BRL', 'precision': { 'amount': 8, 'price': 5 }, 'suffix': 'BCash' }, - 'XRP/BRL': { 'id': 'BRLXRP', 'symbol': 'XRP/BRL', 'base': 'XRP', 'quote': 'BRL', 'precision': { 'amount': 8, 'price': 5 }, 'suffix': 'Ripple' }, - 'ETH/BRL': { 'id': 'BRLETH', 'symbol': 'ETH/BRL', 'base': 'ETH', 'quote': 'BRL', 'precision': { 'amount': 8, 'price': 5 }, 'suffix': 'Ethereum' }, - 'USDC/BRL': { 'id': 'BRLUSDC', 'symbol': 'USDC/BRL', 'base': 'USDC', 'quote': 'BRL', 'precision': { 'amount': 8, 'price': 5 }, 'suffix': 'USDC' }, - }, 'fees': { 'trading': { - 'maker': 0.3 / 100, - 'taker': 0.7 / 100, + 'maker': 0.003, + 'taker': 0.007, + }, + }, + 'options': { + 'limits': { + 'BTC': 0.001, + 'BCH': 0.001, + 'ETH': 0.01, + 'LTC': 0.01, + 'XRP': 0.1, }, }, }); } + async fetchMarkets (params = {}) { + const response = await this.publicGetCoins (params); + // + // [ + // "BCH", + // "BTC", + // "ETH", + // "LTC", + // "XRP", + // "MBPRK01", + // "MBPRK02", + // "MBPRK03", + // "MBPRK04", + // "MBCONS01", + // "USDC", + // "WBX", + // "CHZ", + // "MBCONS02", + // "PAXG", + // "MBVASCO01", + // "LINK" + // ] + // + const result = []; + const amountLimits = this.safeValue (this.options, 'limits', {}); + for (let i = 0; i < response.length; i++) { + const coin = response[i]; + const baseId = coin; + const quoteId = 'BRL'; + const base = this.safeCurrencyCode (baseId); + const quote = this.safeCurrencyCode (quoteId); + const symbol = base + '/' + quote; + const id = quote + base; + const precision = { + 'amount': 8, + 'price': 5, + }; + result.push ({ + 'id': id, + 'symbol': symbol, + 'base': base, + 'quote': quote, + 'baseId': baseId, + 'quoteId': quoteId, + 'active': undefined, + 'info': coin, + 'precision': precision, + 'limits': { + 'amount': { + 'min': this.safeFloat (amountLimits, baseId), + 'max': undefined, + }, + 'price': { + 'min': 1 / Math.pow (10, precision['price']), + 'max': undefined, + }, + 'cost': { + 'min': undefined, + 'max': undefined, + }, + }, + }); + } + return result; + } + async fetchOrderBook (symbol, limit = undefined, params = {}) { await this.loadMarkets (); const market = this.market (symbol); @@ -87755,22 +93829,30 @@ module.exports = class mercado extends Exchange { } parseTrade (trade, market = undefined) { - const timestamp = this.safeTimestamp (trade, 'date'); + const timestamp = this.safeTimestamp2 (trade, 'date', 'executed_timestamp'); let symbol = undefined; if (market !== undefined) { symbol = market['symbol']; } - const id = this.safeString (trade, 'tid'); + const id = this.safeString2 (trade, 'tid', 'operation_id'); const type = undefined; const side = this.safeString (trade, 'type'); const price = this.safeFloat (trade, 'price'); - const amount = this.safeFloat (trade, 'amount'); + const amount = this.safeFloat2 (trade, 'amount', 'quantity'); let cost = undefined; if (price !== undefined) { if (amount !== undefined) { cost = price * amount; } } + const feeCost = this.safeFloat (trade, 'fee_rate'); + let fee = undefined; + if (feeCost !== undefined) { + fee = { + 'cost': feeCost, + 'currency': undefined, + }; + } return { 'id': id, 'info': trade, @@ -87784,7 +93866,7 @@ module.exports = class mercado extends Exchange { 'price': price, 'amount': amount, 'cost': cost, - 'fee': undefined, + 'fee': fee, }; } @@ -87952,6 +94034,11 @@ module.exports = class mercado extends Exchange { const remaining = amount - filled; const cost = filled * average; const lastTradeTimestamp = this.safeTimestamp (order, 'updated_timestamp'); + const rawTrades = this.safeValue (order, 'operations', []); + const trades = this.parseTrades (rawTrades, market, undefined, undefined, { + 'side': side, + 'order': id, + }); return { 'info': order, 'id': id, @@ -87962,6 +94049,7 @@ module.exports = class mercado extends Exchange { 'symbol': market['symbol'], 'type': 'limit', 'timeInForce': undefined, + 'postOnly': undefined, 'side': side, 'price': price, 'stopPrice': undefined, @@ -87972,7 +94060,7 @@ module.exports = class mercado extends Exchange { 'remaining': remaining, 'status': status, 'fee': fee, - 'trades': undefined, // todo parse trades (operations) + 'trades': trades, }; } @@ -88004,17 +94092,17 @@ module.exports = class mercado extends Exchange { if (code === 'BRL') { const account_ref = ('account_ref' in params); if (!account_ref) { - throw new ArgumentsRequired (this.id + ' requires account_ref parameter to withdraw ' + code); + throw new ArgumentsRequired (this.id + ' withdraw() requires account_ref parameter to withdraw ' + code); } } else if (code !== 'LTC') { const tx_fee = ('tx_fee' in params); if (!tx_fee) { - throw new ArgumentsRequired (this.id + ' requires tx_fee parameter to withdraw ' + code); + throw new ArgumentsRequired (this.id + ' withdraw() requires tx_fee parameter to withdraw ' + code); } if (code === 'XRP') { if (tag === undefined) { if (!('destination_tag' in params)) { - throw new ArgumentsRequired (this.id + ' requires a tag argument or destination_tag parameter to withdraw ' + code); + throw new ArgumentsRequired (this.id + ' withdraw() requires a tag argument or destination_tag parameter to withdraw ' + code); } } else { request['destination_tag'] = tag; @@ -88076,6 +94164,51 @@ module.exports = class mercado extends Exchange { return this.parseOrders (orders, market, since, limit); } + async fetchOpenOrders (symbol = undefined, since = undefined, limit = undefined, params = {}) { + if (symbol === undefined) { + throw new ArgumentsRequired (this.id + ' fetchOpenOrders () requires a symbol argument'); + } + await this.loadMarkets (); + const market = this.market (symbol); + const request = { + 'coin_pair': market['id'], + 'status_list': '[2]', // open only + }; + const response = await this.privatePostListOrders (this.extend (request, params)); + const responseData = this.safeValue (response, 'response_data', {}); + const orders = this.safeValue (responseData, 'orders', []); + return this.parseOrders (orders, market, since, limit); + } + + async fetchMyTrades (symbol = undefined, since = undefined, limit = undefined, params = {}) { + if (symbol === undefined) { + throw new ArgumentsRequired (this.id + ' fetchMyTrades () requires a symbol argument'); + } + await this.loadMarkets (); + const market = this.market (symbol); + const request = { + 'coin_pair': market['id'], + 'has_fills': true, + }; + const response = await this.privatePostListOrders (this.extend (request, params)); + const responseData = this.safeValue (response, 'response_data', {}); + const ordersRaw = this.safeValue (responseData, 'orders', []); + const orders = this.parseOrders (ordersRaw, market, since, limit); + const trades = this.ordersToTrades (orders); + return this.filterBySymbolSinceLimit (trades, symbol, since, limit); + } + + ordersToTrades (orders) { + const result = []; + for (let i = 0; i < orders.length; i++) { + const trades = this.safeValue (orders[i], 'trades', []); + for (let y = 0; y < trades.length; y++) { + result.push (trades[y]); + } + } + return result; + } + sign (path, api = 'public', method = 'GET', params = {}, headers = undefined, body = undefined) { let url = this.urls['api'][api] + '/'; const query = this.omit (params, this.extractParams (path)); @@ -88111,7 +94244,7 @@ module.exports = class mercado extends Exchange { } }; -},{"./base/Exchange":5,"./base/errors":7}],110:[function(require,module,exports){ +},{"./base/Exchange":6,"./base/errors":8}],112:[function(require,module,exports){ 'use strict'; // --------------------------------------------------------------------------- @@ -88342,7 +94475,2024 @@ module.exports = class mixcoins extends Exchange { } }; -},{"./base/Exchange":5,"./base/errors":7}],111:[function(require,module,exports){ +},{"./base/Exchange":6,"./base/errors":8}],113:[function(require,module,exports){ +'use strict'; + +// --------------------------------------------------------------------------- + +const Exchange = require ('./base/Exchange'); +const { ExchangeError, AuthenticationError, InsufficientFunds, BadSymbol, OrderNotFound } = require ('./base/errors'); +const { TICK_SIZE } = require ('./base/functions/number'); + +// --------------------------------------------------------------------------- + +module.exports = class ndax extends Exchange { + describe () { + return this.deepExtend (super.describe (), { + 'id': 'ndax', + 'name': 'NDAX', + 'countries': [ 'US' ], // United States + 'rateLimit': 1000, + 'pro': true, + 'has': { + 'cancelAllOrders': true, + 'cancelOrder': true, + 'createDepositAddress': true, + 'createOrder': true, + 'editOrder': true, + 'fetchAccounts': true, + 'fetchBalance': true, + 'fetchCurrencies': true, + 'fetchDepositAddress': true, + 'fetchDeposits': true, + 'fetchLedger': true, + 'fetchMarkets': true, + 'fetchMyTrades': true, + 'fetchOHLCV': true, + 'fetchOpenOrders': true, + 'fetchOrders': true, + 'fetchOrder': true, + 'fetchOrderBook': true, + 'fetchOrderTrades': true, + 'fetchTicker': true, + 'fetchTrades': true, + }, + 'timeframes': { + '1m': '60', + '5m': '300', + '15m': '900', + '30m': '1800', + '1h': '3600', + '2h': '7200', + '4h': '14400', + '6h': '21600', + '12h': '43200', + '1d': '86400', + '1w': '604800', + '1M': '2419200', + '4M': '9676800', + }, + 'urls': { + 'logo': 'https://user-images.githubusercontent.com/1294454/108623144-67a3ef00-744e-11eb-8140-75c6b851e945.jpg', + 'test': { + 'public': 'https://ndaxmarginstaging.cdnhop.net:8443/AP', + 'private': 'https://ndaxmarginstaging.cdnhop.net:8443/AP', + }, + 'api': { + 'public': 'https://api.ndax.io:8443/AP', + 'private': 'https://api.ndax.io:8443/AP', + }, + 'www': 'https://ndax.io', + 'doc': [ + 'https://apidoc.ndax.io/', + ], + 'fees': 'https://ndax.io/fees', + 'referral': 'https://one.ndax.io/bfQiSL', + }, + 'api': { + 'public': { + 'get': [ + 'Activate2FA', + 'Authenticate2FA', + 'AuthenticateUser', + 'GetL2Snapshot', + 'GetLevel1', + 'GetValidate2FARequiredEndpoints', + 'LogOut', + 'GetTickerHistory', + 'GetProduct', + 'GetProducts', + 'GetInstrument', + 'GetInstruments', + 'Ping', + 'trades', // undocumented + 'GetLastTrades', // undocumented + 'SubscribeLevel1', + 'SubscribeLevel2', + 'SubscribeTicker', + 'SubscribeTrades', + 'SubscribeBlockTrades', + 'UnsubscribeBlockTrades', + 'UnsubscribeLevel1', + 'UnsubscribeLevel2', + 'UnsubscribeTicker', + 'UnsubscribeTrades', + 'Authenticate', // undocumented + ], + }, + 'private': { + 'get': [ + 'GetUserAccountInfos', + 'GetUserAccounts', + 'GetUserAffiliateCount', + 'GetUserAffiliateTag', + 'GetUserConfig', + 'GetAllUnredactedUserConfigsForUser', + 'GetUnredactedUserConfigByKey', + 'GetUserDevices', + 'GetUserReportTickets', + 'GetUserReportWriterResultRecords', + 'GetAccountInfo', + 'GetAccountPositions', + 'GetAllAccountConfigs', + 'GetTreasuryProductsForAccount', + 'GetAccountTrades', + 'GetAccountTransactions', + 'GetOpenTradeReports', + 'GetAllOpenTradeReports', + 'GetTradesHistory', + 'GetOpenOrders', + 'GetOpenQuotes', + 'GetOrderFee', + 'GetOrderHistory', + 'GetOrdersHistory', + 'GetOrderStatus', + 'GetOmsFeeTiers', + 'GetAccountDepositTransactions', + 'GetAccountWithdrawTransactions', + 'GetAllDepositRequestInfoTemplates', + 'GetDepositInfo', + 'GetDepositRequestInfoTemplate', + 'GetDeposits', + 'GetDepositTicket', + 'GetDepositTickets', + 'GetOMSWithdrawFees', + 'GetWithdrawFee', + 'GetWithdraws', + 'GetWithdrawTemplate', + 'GetWithdrawTemplateTypes', + 'GetWithdrawTicket', + 'GetWithdrawTickets', + ], + 'post': [ + 'AddUserAffiliateTag', + 'CancelUserReport', + 'RegisterNewDevice', + 'SubscribeAccountEvents', + 'UpdateUserAffiliateTag', + 'GenerateTradeActivityReport', + 'GenerateTransactionActivityReport', + 'GenerateTreasuryActivityReport', + 'ScheduleTradeActivityReport', + 'ScheduleTransactionActivityReport', + 'ScheduleTreasuryActivityReport', + 'CancelAllOrders', + 'CancelOrder', + 'CancelQuote', + 'CancelReplaceOrder', + 'CreateQuote', + 'ModifyOrder', + 'SendOrder', + 'SubmitBlockTrade', + 'UpdateQuote', + 'CancelWithdraw', + 'CreateDepositTicket', + 'CreateWithdrawTicket', + 'SubmitDepositTicketComment', + 'SubmitWithdrawTicketComment', + 'GetOrderHistoryByOrderId', + ], + }, + }, + 'fees': { + 'trading': { + 'tierBased': false, + 'percentage': true, + 'maker': 0.2 / 100, + 'taker': 0.25 / 100, + }, + }, + 'requiredCredentials': { + 'apiKey': true, + 'secret': true, + 'uid': true, + }, + 'precisionMode': TICK_SIZE, + 'exceptions': { + 'exact': { + 'Not_Enough_Funds': InsufficientFunds, // {"status":"Rejected","errormsg":"Not_Enough_Funds","errorcode":101} + 'Server Error': ExchangeError, // {"result":false,"errormsg":"Server Error","errorcode":102,"detail":null} + 'Resource Not Found': OrderNotFound, // {"result":false,"errormsg":"Resource Not Found","errorcode":104,"detail":null} + }, + 'broad': { + 'Invalid InstrumentId': BadSymbol, // {"result":false,"errormsg":"Invalid InstrumentId: 10000","errorcode":100,"detail":null} + }, + }, + 'options': { + 'omsId': 1, + 'orderTypes': { + 'Market': 1, + 'Limit': 2, + 'StopMarket': 3, + 'StopLimit': 4, + 'TrailingStopMarket': 5, + 'TrailingStopLimit': 6, + 'BlockTrade': 7, + }, + }, + }); + } + + async fetchCurrencies (params = {}) { + const omsId = this.safeInteger (this.options, 'omsId', 1); + const request = { + 'omsId': omsId, + }; + const response = await this.publicGetGetProducts (this.extend (request, params)); + // + // [ + // { + // "OMSId":1, + // "ProductId":1, + // "Product":"BTC", + // "ProductFullName":"Bitcoin", + // "ProductType":"CryptoCurrency", + // "DecimalPlaces":8, + // "TickSize":0.0000000100000000000000000000, + // "NoFees":false, + // "IsDisabled":false, + // "MarginEnabled":false + // }, + // ] + // + const result = {}; + for (let i = 0; i < response.length; i++) { + const currency = response[i]; + const id = this.safeString (currency, 'ProductId'); + const name = this.safeString (currency, 'ProductFullName'); + const type = this.safeString (currency, 'ProductType'); + const code = this.safeCurrencyCode (this.safeString (currency, 'Product')); + const precision = this.safeFloat (currency, 'TickSize'); + const isDisabled = this.safeValue (currency, 'IsDisabled'); + const active = !isDisabled; + result[code] = { + 'id': id, + 'name': name, + 'code': code, + 'type': type, + 'precision': precision, + 'info': currency, + 'active': active, + 'fee': undefined, + 'limits': this.limits, + }; + } + return result; + } + + async fetchMarkets (params = {}) { + const omsId = this.safeInteger (this.options, 'omsId', 1); + const request = { + 'omsId': omsId, + }; + const response = await this.publicGetGetInstruments (this.extend (request, params)); + // + // [ + // { + // "OMSId":1, + // "InstrumentId":3, + // "Symbol":"LTCBTC", + // "Product1":3, + // "Product1Symbol":"LTC", + // "Product2":1, + // "Product2Symbol":"BTC", + // "InstrumentType":"Standard", + // "VenueInstrumentId":3, + // "VenueId":1, + // "SortIndex":0, + // "SessionStatus":"Running", + // "PreviousSessionStatus":"Stopped", + // "SessionStatusDateTime":"2020-11-25T19:42:15.245Z", + // "SelfTradePrevention":true, + // "QuantityIncrement":0.0000000100000000000000000000, + // "PriceIncrement":0.0000000100000000000000000000, + // "MinimumQuantity":0.0100000000000000000000000000, + // "MinimumPrice":0.0000010000000000000000000000, + // "VenueSymbol":"LTCBTC", + // "IsDisable":false, + // "MasterDataId":0, + // "PriceCollarThreshold":0.0000000000000000000000000000, + // "PriceCollarPercent":0.0000000000000000000000000000, + // "PriceCollarEnabled":false, + // "PriceFloorLimit":0.0000000000000000000000000000, + // "PriceFloorLimitEnabled":false, + // "PriceCeilingLimit":0.0000000000000000000000000000, + // "PriceCeilingLimitEnabled":false, + // "CreateWithMarketRunning":true, + // "AllowOnlyMarketMakerCounterParty":false, + // "PriceCollarIndexDifference":0.0000000000000000000000000000, + // "PriceCollarConvertToOtcEnabled":false, + // "PriceCollarConvertToOtcClientUserId":0, + // "PriceCollarConvertToOtcAccountId":0, + // "PriceCollarConvertToOtcThreshold":0.0000000000000000000000000000, + // "OtcConvertSizeThreshold":0.0000000000000000000000000000, + // "OtcConvertSizeEnabled":false, + // "OtcTradesPublic":true, + // "PriceTier":0 + // }, + // ] + // + const result = []; + for (let i = 0; i < response.length; i++) { + const market = response[i]; + const id = this.safeString (market, 'InstrumentId'); + // const lowercaseId = this.safeStringLower (market, 'symbol'); + const baseId = this.safeString (market, 'Product1'); + const quoteId = this.safeString (market, 'Product2'); + const base = this.safeCurrencyCode (this.safeString (market, 'Product1Symbol')); + const quote = this.safeCurrencyCode (this.safeString (market, 'Product2Symbol')); + const symbol = base + '/' + quote; + const precision = { + 'amount': this.safeFloat (market, 'QuantityIncrement'), + 'price': this.safeFloat (market, 'PriceIncrement'), + }; + const sessionStatus = this.safeString (market, 'SessionStatus'); + const isDisable = this.safeValue (market, 'IsDisable'); + const sessionRunning = (sessionStatus === 'Running'); + const active = (sessionRunning && !isDisable) ? true : false; + result.push ({ + 'id': id, + 'symbol': symbol, + 'base': base, + 'quote': quote, + 'baseId': baseId, + 'quoteId': quoteId, + 'info': market, + 'active': active, + 'precision': precision, + 'limits': { + 'amount': { + 'min': this.safeFloat (market, 'MinimumQuantity'), + 'max': undefined, + }, + 'price': { + 'min': this.safeFloat (market, 'MinimumPrice'), + 'max': undefined, + }, + 'cost': { + 'min': undefined, + 'max': undefined, + }, + }, + }); + } + return result; + } + + parseOrderBook (orderbook, timestamp = undefined, bidsKey = 'bids', asksKey = 'asks', priceKey = 6, amountKey = 8) { + let nonce = undefined; + const result = { + 'bids': [], + 'asks': [], + 'timestamp': undefined, + 'datetime': undefined, + 'nonce': undefined, + }; + for (let i = 0; i < orderbook.length; i++) { + const level = orderbook[i]; + if (timestamp === undefined) { + timestamp = this.safeInteger (level, 2); + } else { + const newTimestamp = this.safeInteger (level, 2); + timestamp = Math.max (timestamp, newTimestamp); + } + if (nonce === undefined) { + nonce = this.safeInteger (level, 0); + } else { + const newNonce = this.safeInteger (level, 0); + nonce = Math.max (nonce, newNonce); + } + const bidask = this.parseBidAsk (level, priceKey, amountKey); + const levelSide = this.safeValue (level, 9); + const side = levelSide ? asksKey : bidsKey; + result[side].push (bidask); + } + result['bids'] = this.sortBy (result['bids'], 0, true); + result['asks'] = this.sortBy (result['asks'], 0); + result['timestamp'] = timestamp; + result['datetime'] = this.iso8601 (timestamp); + result['nonce'] = nonce; + return result; + } + + async fetchOrderBook (symbol, limit = undefined, params = {}) { + const omsId = this.safeInteger (this.options, 'omsId', 1); + await this.loadMarkets (); + const market = this.market (symbol); + limit = (limit === undefined) ? 100 : limit; // default 100 + const request = { + 'omsId': omsId, + 'InstrumentId': market['id'], + 'Depth': limit, // default 100 + }; + const response = await this.publicGetGetL2Snapshot (this.extend (request, params)); + // + // [ + // [ + // 0, // 0 MDUpdateId + // 1, // 1 Number of Unique Accounts + // 123, // 2 ActionDateTime in Posix format X 1000 + // 0, // 3 ActionType 0 (New), 1 (Update), 2(Delete) + // 0.0, // 4 LastTradePrice + // 0, // 5 Number of Orders + // 0.0, // 6 Price + // 0, // 7 ProductPairCode + // 0.0, // 8 Quantity + // 0, // 9 Side + // ], + // [97244115,1,1607456142963,0,19069.32,1,19069.31,8,0.140095,0], + // [97244115,0,1607456142963,0,19069.32,1,19068.64,8,0.0055,0], + // [97244115,0,1607456142963,0,19069.32,1,19068.26,8,0.021291,0], + // [97244115,1,1607456142964,0,19069.32,1,19069.32,8,0.099636,1], + // [97244115,0,1607456142964,0,19069.32,1,19069.98,8,0.1,1], + // [97244115,0,1607456142964,0,19069.32,1,19069.99,8,0.141604,1], + // ] + // + return this.parseOrderBook (response); + } + + parseTicker (ticker, market = undefined) { + // + // fetchTicker + // + // { + // "OMSId":1, + // "InstrumentId":8, + // "BestBid":19069.31, + // "BestOffer":19069.32, + // "LastTradedPx":19069.32, + // "LastTradedQty":0.0001, + // "LastTradeTime":1607040406424, + // "SessionOpen":19069.32, + // "SessionHigh":19069.32, + // "SessionLow":19069.32, + // "SessionClose":19069.32, + // "Volume":0.0001, + // "CurrentDayVolume":0.0001, + // "CurrentDayNotional":1.906932, + // "CurrentDayNumTrades":1, + // "CurrentDayPxChange":0.00, + // "Rolling24HrVolume":0.000000000000000000000000000, + // "Rolling24HrNotional":0.00000000000000000000000, + // "Rolling24NumTrades":0, + // "Rolling24HrPxChange":0, + // "TimeStamp":"1607040406425", + // "BidQty":0, + // "AskQty":0, + // "BidOrderCt":0, + // "AskOrderCt":0, + // "Rolling24HrPxChangePercent":0, + // } + // + const timestamp = this.safeInteger (ticker, 'TimeStamp'); + const marketId = this.safeString (ticker, 'InstrumentId'); + const symbol = this.safeSymbol (marketId, market); + const last = this.safeFloat (ticker, 'LastTradedPx'); + const percentage = this.safeFloat (ticker, 'Rolling24HrPxChangePercent'); + const change = this.safeFloat (ticker, 'Rolling24HrPxChange'); + const open = this.safeFloat (ticker, 'SessionOpen'); + let average = undefined; + if ((last !== undefined) && (change !== undefined)) { + average = this.sum (last, open) / 2; + } + const baseVolume = this.safeFloat (ticker, 'Rolling24HrVolume'); + const quoteVolume = this.safeFloat (ticker, 'Rolling24HrNotional'); + const vwap = this.vwap (baseVolume, quoteVolume); + return { + 'symbol': symbol, + 'timestamp': timestamp, + 'datetime': this.iso8601 (timestamp), + 'high': this.safeFloat (ticker, 'SessionHigh'), + 'low': this.safeFloat (ticker, 'SessionLow'), + 'bid': this.safeFloat (ticker, 'BestBid'), + 'bidVolume': undefined, // this.safeFloat (ticker, 'BidQty'), always shows 0 + 'ask': this.safeFloat (ticker, 'BestOffer'), + 'askVolume': undefined, // this.safeFloat (ticker, 'AskQty'), always shows 0 + 'vwap': vwap, + 'open': open, + 'close': last, + 'last': last, + 'previousClose': undefined, + 'change': change, + 'percentage': percentage, + 'average': average, + 'baseVolume': baseVolume, + 'quoteVolume': quoteVolume, + 'info': ticker, + }; + } + + async fetchTicker (symbol, params = {}) { + const omsId = this.safeInteger (this.options, 'omsId', 1); + await this.loadMarkets (); + const market = this.market (symbol); + const request = { + 'omsId': omsId, + 'InstrumentId': market['id'], + }; + const response = await this.publicGetGetLevel1 (this.extend (request, params)); + // + // { + // "OMSId":1, + // "InstrumentId":8, + // "BestBid":19069.31, + // "BestOffer":19069.32, + // "LastTradedPx":19069.32, + // "LastTradedQty":0.0001, + // "LastTradeTime":1607040406424, + // "SessionOpen":19069.32, + // "SessionHigh":19069.32, + // "SessionLow":19069.32, + // "SessionClose":19069.32, + // "Volume":0.0001, + // "CurrentDayVolume":0.0001, + // "CurrentDayNotional":1.906932, + // "CurrentDayNumTrades":1, + // "CurrentDayPxChange":0.00, + // "Rolling24HrVolume":0.000000000000000000000000000, + // "Rolling24HrNotional":0.00000000000000000000000, + // "Rolling24NumTrades":0, + // "Rolling24HrPxChange":0, + // "TimeStamp":"1607040406425", + // "BidQty":0, + // "AskQty":0, + // "BidOrderCt":0, + // "AskOrderCt":0, + // "Rolling24HrPxChangePercent":0, + // } + // + return this.parseTicker (response, market); + } + + parseOHLCV (ohlcv, market = undefined) { + // + // [ + // 1501603632000, // 0 DateTime + // 2700.33, // 1 High + // 2687.01, // 2 Low + // 2687.01, // 3 Open + // 2687.01, // 4 Close + // 24.86100992, // 5 Volume + // 0, // 6 Inside Bid Price + // 2870.95, // 7 Inside Ask Price + // 1 // 8 InstrumentId + // ] + // + return [ + this.safeInteger (ohlcv, 0), + this.safeFloat (ohlcv, 3), + this.safeFloat (ohlcv, 1), + this.safeFloat (ohlcv, 2), + this.safeFloat (ohlcv, 4), + this.safeFloat (ohlcv, 5), + ]; + } + + async fetchOHLCV (symbol, timeframe = '1m', since = undefined, limit = undefined, params = {}) { + const omsId = this.safeInteger (this.options, 'omsId', 1); + await this.loadMarkets (); + const market = this.market (symbol); + const request = { + 'omsId': omsId, + 'InstrumentId': market['id'], + 'Interval': this.timeframes[timeframe], + }; + const duration = this.parseTimeframe (timeframe); + const now = this.milliseconds (); + if (since === undefined) { + if (limit !== undefined) { + request['FromDate'] = this.ymd (now - duration * limit * 1000); + request['ToDate'] = this.ymd (now); + } + } else { + request['FromDate'] = this.ymd (since); + if (limit === undefined) { + request['ToDate'] = this.ymd (now); + } else { + request['ToDate'] = this.ymd (this.sum (since, duration * limit * 1000)); + } + } + const response = await this.publicGetGetTickerHistory (this.extend (request, params)); + // + // [ + // [1607299260000,19069.32,19069.32,19069.32,19069.32,0,19069.31,19069.32,8,1607299200000], + // [1607299320000,19069.32,19069.32,19069.32,19069.32,0,19069.31,19069.32,8,1607299260000], + // [1607299380000,19069.32,19069.32,19069.32,19069.32,0,19069.31,19069.32,8,1607299320000], + // ] + // + return this.parseOHLCVs (response, market, timeframe, since, limit); + } + + parseTrade (trade, market = undefined) { + // + // fetchTrades (public) + // + // [ + // 6913253, // 0 TradeId + // 8, // 1 ProductPairCode + // 0.03340802, // 2 Quantity + // 19116.08, // 3 Price + // 2543425077, // 4 Order1 + // 2543425482, // 5 Order2 + // 1606935922416, // 6 Tradetime + // 0, // 7 Direction + // 1, // 8 TakerSide + // 0, // 9 BlockTrade + // 0, // 10 Either Order1ClientId or Order2ClientId + // ] + // + // fetchMyTrades (private) + // + // { + // "OMSId":1, + // "ExecutionId":16916567, + // "TradeId":14476351, + // "OrderId":2543565231, + // "AccountId":449, + // "AccountName":"igor@ccxt.trade", + // "SubAccountId":0, + // "ClientOrderId":0, + // "InstrumentId":8, + // "Side":"Sell", + // "OrderType":"Market", + // "Quantity":0.1230000000000000000000000000, + // "RemainingQuantity":0.0000000000000000000000000000, + // "Price":19069.310000000000000000000000, + // "Value":2345.5251300000000000000000000, + // "CounterParty":"7", + // "OrderTradeRevision":1, + // "Direction":"NoChange", + // "IsBlockTrade":false, + // "Fee":1.1727625650000000000000000000, + // "FeeProductId":8, + // "OrderOriginator":446, + // "UserName":"igor@ccxt.trade", + // "TradeTimeMS":1607565031569, + // "MakerTaker":"Taker", + // "AdapterTradeId":0, + // "InsideBid":19069.310000000000000000000000, + // "InsideBidSize":0.2400950000000000000000000000, + // "InsideAsk":19069.320000000000000000000000, + // "InsideAskSize":0.0997360000000000000000000000, + // "IsQuote":false, + // "CounterPartyClientUserId":1, + // "NotionalProductId":2, + // "NotionalRate":1.0000000000000000000000000000, + // "NotionalValue":2345.5251300000000000000000000, + // "NotionalHoldAmount":0, + // "TradeTime":637431618315686826 + // } + // + // fetchOrderTrades + // + // { + // "Side":"Sell", + // "OrderId":2543565235, + // "Price":18600.000000000000000000000000, + // "Quantity":0.0000000000000000000000000000, + // "DisplayQuantity":0.0000000000000000000000000000, + // "Instrument":8, + // "Account":449, + // "AccountName":"igor@ccxt.trade", + // "OrderType":"Limit", + // "ClientOrderId":0, + // "OrderState":"FullyExecuted", + // "ReceiveTime":1607585844956, + // "ReceiveTimeTicks":637431826449564182, + // "LastUpdatedTime":1607585844959, + // "LastUpdatedTimeTicks":637431826449593893, + // "OrigQuantity":0.1230000000000000000000000000, + // "QuantityExecuted":0.1230000000000000000000000000, + // "GrossValueExecuted":2345.3947500000000000000000000, + // "ExecutableValue":0.0000000000000000000000000000, + // "AvgPrice":19068.250000000000000000000000, + // "CounterPartyId":0, + // "ChangeReason":"Trade", + // "OrigOrderId":2543565235, + // "OrigClOrdId":0, + // "EnteredBy":446, + // "UserName":"igor@ccxt.trade", + // "IsQuote":false, + // "InsideAsk":19069.320000000000000000000000, + // "InsideAskSize":0.0997360000000000000000000000, + // "InsideBid":19068.250000000000000000000000, + // "InsideBidSize":1.3300010000000000000000000000, + // "LastTradePrice":19068.250000000000000000000000, + // "RejectReason":"", + // "IsLockedIn":false, + // "CancelReason":"", + // "OrderFlag":"0", + // "UseMargin":false, + // "StopPrice":0.0000000000000000000000000000, + // "PegPriceType":"Unknown", + // "PegOffset":0.0000000000000000000000000000, + // "PegLimitOffset":0.0000000000000000000000000000, + // "IpAddress":"5.228.233.138", + // "ClientOrderIdUuid":null, + // "OMSId":1 + // } + // + let price = undefined; + let amount = undefined; + let cost = undefined; + let timestamp = undefined; + let id = undefined; + let marketId = undefined; + let side = undefined; + let orderId = undefined; + let takerOrMaker = undefined; + let fee = undefined; + let type = undefined; + if (Array.isArray (trade)) { + price = this.safeFloat (trade, 3); + amount = this.safeFloat (trade, 2); + if ((price !== undefined) && (amount !== undefined)) { + cost = price * amount; + } + timestamp = this.safeInteger (trade, 6); + id = this.safeString (trade, 0); + marketId = this.safeInteger (trade, 1); + const takerSide = this.safeValue (trade, 8); + side = takerSide ? 'sell' : 'buy'; + orderId = this.safeString (trade, 4); + } else { + timestamp = this.safeInteger2 (trade, 'TradeTimeMS', 'ReceiveTime'); + id = this.safeString (trade, 'TradeId'); + orderId = this.safeString2 (trade, 'OrderId', 'OrigOrderId'); + marketId = this.safeString2 (trade, 'InstrumentId', 'Instrument'); + price = this.safeFloat (trade, 'Price'); + amount = this.safeFloat (trade, 'Quantity'); + cost = this.safeFloat2 (trade, 'Value', 'GrossValueExecuted'); + takerOrMaker = this.safeStringLower (trade, 'MakerTaker'); + side = this.safeStringLower (trade, 'Side'); + type = this.safeStringLower (trade, 'OrderType'); + const feeCost = this.safeFloat (trade, 'Fee'); + if (feeCost !== undefined) { + const feeCurrencyId = this.safeString (trade, 'FeeProductId'); + const feeCurrencyCode = this.safeCurrencyCode (feeCurrencyId); + fee = { + 'cost': feeCost, + 'currency': feeCurrencyCode, + }; + } + } + const symbol = this.safeSymbol (marketId, market); + return { + 'info': trade, + 'id': id, + 'symbol': symbol, + 'timestamp': timestamp, + 'datetime': this.iso8601 (timestamp), + 'order': orderId, + 'type': type, + 'side': side, + 'takerOrMaker': takerOrMaker, + 'price': price, + 'amount': amount, + 'cost': cost, + 'fee': fee, + }; + } + + async fetchTrades (symbol, since = undefined, limit = undefined, params = {}) { + const omsId = this.safeInteger (this.options, 'omsId', 1); + await this.loadMarkets (); + const market = this.market (symbol); + const request = { + 'omsId': omsId, + 'InstrumentId': market['id'], + }; + if (limit !== undefined) { + request['Count'] = limit; + } + const response = await this.publicGetGetLastTrades (this.extend (request, params)); + // + // [ + // [6913253,8,0.03340802,19116.08,2543425077,2543425482,1606935922416,0,1,0,0], + // [6913254,8,0.01391671,19117.42,2543427510,2543427811,1606935927998,1,1,0,0], + // [6913255,8,0.000006,19107.81,2543430495,2543430793,1606935933881,2,0,0,0], + // ] + // + return this.parseTrades (response, market, since, limit); + } + + async fetchAccounts (params = {}) { + const omsId = this.safeInteger (this.options, 'omsId', 1); + this.checkRequiredCredentials (); + const request = { + 'omsId': omsId, + 'UserId': this.uid, + 'UserName': 'igor@ccxt.trade', + }; + const response = await this.privateGetGetUserAccounts (this.extend (request, params)); + // + // [ 449 ] // comma-separated list of account ids + // + const result = []; + for (let i = 0; i < response.length; i++) { + const accountId = this.safeString (response, i); + result.push ({ + 'id': accountId, + 'type': undefined, + 'currency': undefined, + 'info': accountId, + }); + } + return result; + } + + async fetchBalance (params = {}) { + const omsId = this.safeInteger (this.options, 'omsId', 1); + await this.loadMarkets (); + await this.loadAccounts (); + const defaultAccountId = this.safeInteger2 (this.options, 'accountId', 'AccountId', parseInt (this.accounts[0]['id'])); + const accountId = this.safeInteger2 (params, 'accountId', 'AccountId', defaultAccountId); + params = this.omit (params, [ 'accountId', 'AccountId' ]); + const request = { + 'omsId': omsId, + 'AccountId': accountId, + }; + const response = await this.privateGetGetAccountPositions (this.extend (request, params)); + // + // [ + // { + // "OMSId":1, + // "AccountId":449, + // "ProductSymbol":"BTC", + // "ProductId":1, + // "Amount":10.000000000000000000000000000, + // "Hold":0, + // "PendingDeposits":0.0000000000000000000000000000, + // "PendingWithdraws":0.0000000000000000000000000000, + // "TotalDayDeposits":10.000000000000000000000000000, + // "TotalMonthDeposits":10.000000000000000000000000000, + // "TotalYearDeposits":10.000000000000000000000000000, + // "TotalDayDepositNotional":10.000000000000000000000000000, + // "TotalMonthDepositNotional":10.000000000000000000000000000, + // "TotalYearDepositNotional":10.000000000000000000000000000, + // "TotalDayWithdraws":0, + // "TotalMonthWithdraws":0, + // "TotalYearWithdraws":0, + // "TotalDayWithdrawNotional":0, + // "TotalMonthWithdrawNotional":0, + // "TotalYearWithdrawNotional":0, + // "NotionalProductId":8, + // "NotionalProductSymbol":"USDT", + // "NotionalValue":10.000000000000000000000000000, + // "NotionalHoldAmount":0, + // "NotionalRate":1 + // }, + // ] + // + const result = { 'info': response }; + for (let i = 0; i < response.length; i++) { + const balance = response[i]; + const currencyId = this.safeString (balance, 'ProductId'); + const code = this.safeCurrencyCode (currencyId); + const account = this.account (); + account['total'] = this.safeFloat (balance, 'Amount'); + account['used'] = this.safeFloat (balance, 'Hold'); + result[code] = account; + } + return this.parseBalance (result); + } + + parseLedgerEntryType (type) { + const types = { + 'Trade': 'trade', + 'Deposit': 'transaction', + 'Withdraw': 'transaction', + 'Transfer': 'transfer', + 'OrderHold': 'trade', + 'WithdrawHold': 'transaction', + 'DepositHold': 'transaction', + 'MarginHold': 'trade', + 'ManualHold': 'trade', + 'ManualEntry': 'trade', + 'MarginAcquisition': 'trade', + 'MarginRelinquish': 'trade', + 'MarginQuoteHold': 'trade', + }; + return this.safeString (types, type, type); + } + + parseLedgerEntry (item, currency = undefined) { + // + // { + // "TransactionId":2663709493, + // "ReferenceId":68, + // "OMSId":1, + // "AccountId":449, + // "CR":10.000000000000000000000000000, + // "DR":0.0000000000000000000000000000, + // "Counterparty":3, + // "TransactionType":"Other", + // "ReferenceType":"Deposit", + // "ProductId":1, + // "Balance":10.000000000000000000000000000, + // "TimeStamp":1607532331591 + // } + // + const id = this.safeString (item, 'TransactionId'); + const account = this.safeString (item, 'AccountId'); + const referenceId = this.safeString (item, 'ReferenceId'); + const referenceAccount = this.safeString (item, 'Counterparty'); + const type = this.parseLedgerEntryType (this.safeString (item, 'ReferenceType')); + const currencyId = this.safeString (item, 'ProductId'); + const code = this.safeCurrencyCode (currencyId, currency); + const credit = this.safeFloat (item, 'CR'); + const debit = this.safeFloat (item, 'DR'); + let amount = undefined; + let direction = undefined; + if (credit > 0) { + amount = credit; + direction = 'in'; + } else if (debit > 0) { + amount = debit; + direction = 'out'; + } + const timestamp = this.safeInteger (item, 'TimeStamp'); + let before = undefined; + const after = this.safeFloat (item, 'Balance'); + if (direction === 'out') { + before = this.sum (after, amount); + } else if (direction === 'in') { + before = Math.max (0, after - amount); + } + const status = 'ok'; + return { + 'info': item, + 'id': id, + 'direction': direction, + 'account': account, + 'referenceId': referenceId, + 'referenceAccount': referenceAccount, + 'type': type, + 'currency': code, + 'amount': amount, + 'before': before, + 'after': after, + 'status': status, + 'timestamp': timestamp, + 'datetime': this.iso8601 (timestamp), + 'fee': undefined, + }; + } + + async fetchLedger (code = undefined, since = undefined, limit = undefined, params = {}) { + const omsId = this.safeInteger (this.options, 'omsId', 1); + await this.loadMarkets (); + await this.loadAccounts (); + const defaultAccountId = this.safeInteger2 (this.options, 'accountId', 'AccountId', parseInt (this.accounts[0]['id'])); + const accountId = this.safeInteger2 (params, 'accountId', 'AccountId', defaultAccountId); + params = this.omit (params, [ 'accountId', 'AccountId' ]); + const request = { + 'omsId': omsId, + 'AccountId': accountId, + }; + if (limit !== undefined) { + request['Depth'] = limit; + } + const response = await this.privateGetGetAccountTransactions (this.extend (request, params)); + // + // [ + // { + // "TransactionId":2663709493, + // "ReferenceId":68, + // "OMSId":1, + // "AccountId":449, + // "CR":10.000000000000000000000000000, + // "DR":0.0000000000000000000000000000, + // "Counterparty":3, + // "TransactionType":"Other", + // "ReferenceType":"Deposit", + // "ProductId":1, + // "Balance":10.000000000000000000000000000, + // "TimeStamp":1607532331591 + // }, + // ] + // + let currency = undefined; + if (code !== undefined) { + currency = this.currency (code); + } + return this.parseLedger (response, currency, since, limit); + } + + parseOrderStatus (status) { + const statuses = { + 'Accepted': 'open', + 'Rejected': 'rejected', + 'Working': 'open', + 'Canceled': 'canceled', + 'Expired': 'expired', + 'FullyExecuted': 'closed', + }; + return this.safeString (statuses, status, status); + } + + parseOrder (order, market = undefined) { + // + // createOrder + // + // { + // "status":"Accepted", + // "errormsg":"", + // "OrderId": 2543565231 + // } + // + // editOrder + // + // { + // "ReplacementOrderId": 1234, + // "ReplacementClOrdId": 1561, + // "OrigOrderId": 5678, + // "OrigClOrdId": 91011, + // } + // + // fetchOpenOrders, fetchClosedOrders + // + // { + // "Side":"Buy", + // "OrderId":2543565233, + // "Price":19010, + // "Quantity":0.345, + // "DisplayQuantity":0.345, + // "Instrument":8, + // "Account":449, + // "AccountName":"igor@ccxt.trade", + // "OrderType":"Limit", + // "ClientOrderId":0, + // "OrderState":"Working", + // "ReceiveTime":1607579326003, + // "ReceiveTimeTicks":637431761260028981, + // "LastUpdatedTime":1607579326005, + // "LastUpdatedTimeTicks":637431761260054714, + // "OrigQuantity":0.345, + // "QuantityExecuted":0, + // "GrossValueExecuted":0, + // "ExecutableValue":0, + // "AvgPrice":0, + // "CounterPartyId":0, + // "ChangeReason":"NewInputAccepted", + // "OrigOrderId":2543565233, + // "OrigClOrdId":0, + // "EnteredBy":446, + // "UserName":"igor@ccxt.trade", + // "IsQuote":false, + // "InsideAsk":19069.32, + // "InsideAskSize":0.099736, + // "InsideBid":19068.25, + // "InsideBidSize":1.330001, + // "LastTradePrice":19068.25, + // "RejectReason":"", + // "IsLockedIn":false, + // "CancelReason":"", + // "OrderFlag":"AddedToBook", + // "UseMargin":false, + // "StopPrice":0, + // "PegPriceType":"Unknown", + // "PegOffset":0, + // "PegLimitOffset":0, + // "IpAddress":null, + // "ClientOrderIdUuid":null, + // "OMSId":1 + // } + // + const id = this.safeString2 (order, 'ReplacementOrderId', 'OrderId'); + const timestamp = this.safeInteger (order, 'ReceiveTime'); + let lastTradeTimestamp = undefined; + const marketId = this.safeString (order, 'Instrument'); + const symbol = this.safeSymbol (marketId, market); + const side = this.safeStringLower (order, 'Side'); + const type = this.safeStringLower (order, 'OrderType'); + const clientOrderId = this.safeString2 (order, 'ReplacementClOrdId', 'ClientOrderId'); + let price = this.safeFloat (order, 'Price', 0.0); + price = (price > 0.0) ? price : undefined; + const amount = this.safeFloat (order, 'OrigQuantity'); + const filled = this.safeFloat (order, 'QuantityExecuted'); + const cost = this.safeFloat (order, 'GrossValueExecuted'); + let remaining = undefined; + let average = undefined; + if (filled !== undefined) { + if (amount !== undefined) { + remaining = Math.max (0, amount - filled); + } + if (filled > 0) { + lastTradeTimestamp = this.safeInteger (order, 'LastUpdatedTime'); + average = this.safeFloat (order, 'AvgPrice', 0.0); + average = (average > 0) ? average : undefined; + } + } + let stopPrice = this.safeFloat (order, 'StopPrice', 0.0); + stopPrice = (stopPrice > 0.0) ? stopPrice : undefined; + const timeInForce = undefined; + const status = this.parseOrderStatus (this.safeString (order, 'OrderState')); + const fee = undefined; + const trades = undefined; + return { + 'id': id, + 'clientOrderId': clientOrderId, + 'info': order, + 'timestamp': timestamp, + 'datetime': this.iso8601 (timestamp), + 'lastTradeTimestamp': lastTradeTimestamp, + 'status': status, + 'symbol': symbol, + 'type': type, + 'timeInForce': timeInForce, + 'postOnly': undefined, + 'side': side, + 'price': price, + 'stopPrice': stopPrice, + 'cost': cost, + 'amount': amount, + 'filled': filled, + 'average': average, + 'remaining': remaining, + 'fee': fee, + 'trades': trades, + }; + } + + async createOrder (symbol, type, side, amount, price = undefined, params = {}) { + const omsId = this.safeInteger (this.options, 'omsId', 1); + await this.loadMarkets (); + await this.loadAccounts (); + const defaultAccountId = this.safeInteger2 (this.options, 'accountId', 'AccountId', parseInt (this.accounts[0]['id'])); + const accountId = this.safeInteger2 (params, 'accountId', 'AccountId', defaultAccountId); + const clientOrderId = this.safeInteger2 (params, 'ClientOrderId', 'clientOrderId'); + params = this.omit (params, [ 'accountId', 'AccountId', 'clientOrderId', 'ClientOrderId' ]); + const market = this.market (symbol); + const orderSide = (side === 'buy') ? 0 : 1; + const request = { + 'InstrumentId': parseInt (market['id']), + 'omsId': omsId, + 'AccountId': accountId, + 'TimeInForce': 1, // 0 Unknown, 1 GTC by default, 2 OPG execute as close to opening price as possible, 3 IOC immediate or canceled, 4 FOK fill-or-kill, 5 GTX good 'til executed, 6 GTD good 'til date + // 'ClientOrderId': clientOrderId, // defaults to 0 + // If this order is order A, OrderIdOCO refers to the order ID of an order B (which is not the order being created by this call). + // If order B executes, then order A created by this call is canceled. + // You can also set up order B to watch order A in the same way, but that may require an update to order B to make it watch this one, which could have implications for priority in the order book. + // See CancelReplaceOrder and ModifyOrder. + // 'OrderIdOCO': 0, // The order ID if One Cancels the Other. + // 'UseDisplayQuantity': false, // If you enter a Limit order with a reserve, you must set UseDisplayQuantity to true + 'Side': orderSide, // 0 Buy, 1 Sell, 2 Short, 3 unknown an error condition + 'Quantity': parseFloat (this.amountToPrecision (symbol, amount)), + 'OrderType': this.safeInteger (this.options['orderTypes'], this.capitalize (type)), // 0 Unknown, 1 Market, 2 Limit, 3 StopMarket, 4 StopLimit, 5 TrailingStopMarket, 6 TrailingStopLimit, 7 BlockTrade + // 'PegPriceType': 3, // 1 Last, 2 Bid, 3 Ask, 4 Midpoint + // 'LimitPrice': parseFloat (this.priceToPrecision (symbol, price)), + }; + // If OrderType=1 (Market), Side=0 (Buy), and LimitPrice is supplied, the Market order will execute up to the value specified + if (price !== undefined) { + request['LimitPrice'] = parseFloat (this.priceToPrecision (symbol, price)); + } + if (clientOrderId !== undefined) { + request['ClientOrderId'] = clientOrderId; + } + const response = await this.privatePostSendOrder (this.extend (request, params)); + // + // { + // "status":"Accepted", + // "errormsg":"", + // "OrderId": 2543565231 + // } + // + return this.parseOrder (response, market); + } + + async editOrder (id, symbol, type, side, amount, price = undefined, params = {}) { + const omsId = this.safeInteger (this.options, 'omsId', 1); + await this.loadMarkets (); + await this.loadAccounts (); + const defaultAccountId = this.safeInteger2 (this.options, 'accountId', 'AccountId', parseInt (this.accounts[0]['id'])); + const accountId = this.safeInteger2 (params, 'accountId', 'AccountId', defaultAccountId); + const clientOrderId = this.safeInteger2 (params, 'ClientOrderId', 'clientOrderId'); + params = this.omit (params, [ 'accountId', 'AccountId', 'clientOrderId', 'ClientOrderId' ]); + const market = this.market (symbol); + const orderSide = (side === 'buy') ? 0 : 1; + const request = { + 'OrderIdToReplace': parseInt (id), + 'InstrumentId': parseInt (market['id']), + 'omsId': omsId, + 'AccountId': accountId, + 'TimeInForce': 1, // 0 Unknown, 1 GTC by default, 2 OPG execute as close to opening price as possible, 3 IOC immediate or canceled, 4 FOK fill-or-kill, 5 GTX good 'til executed, 6 GTD good 'til date + // 'ClientOrderId': clientOrderId, // defaults to 0 + // If this order is order A, OrderIdOCO refers to the order ID of an order B (which is not the order being created by this call). + // If order B executes, then order A created by this call is canceled. + // You can also set up order B to watch order A in the same way, but that may require an update to order B to make it watch this one, which could have implications for priority in the order book. + // See CancelReplaceOrder and ModifyOrder. + // 'OrderIdOCO': 0, // The order ID if One Cancels the Other. + // 'UseDisplayQuantity': false, // If you enter a Limit order with a reserve, you must set UseDisplayQuantity to true + 'Side': orderSide, // 0 Buy, 1 Sell, 2 Short, 3 unknown an error condition + 'Quantity': parseFloat (this.amountToPrecision (symbol, amount)), + 'OrderType': this.safeInteger (this.options['orderTypes'], this.capitalize (type)), // 0 Unknown, 1 Market, 2 Limit, 3 StopMarket, 4 StopLimit, 5 TrailingStopMarket, 6 TrailingStopLimit, 7 BlockTrade + // 'PegPriceType': 3, // 1 Last, 2 Bid, 3 Ask, 4 Midpoint + // 'LimitPrice': parseFloat (this.priceToPrecision (symbol, price)), + }; + // If OrderType=1 (Market), Side=0 (Buy), and LimitPrice is supplied, the Market order will execute up to the value specified + if (price !== undefined) { + request['LimitPrice'] = parseFloat (this.priceToPrecision (symbol, price)); + } + if (clientOrderId !== undefined) { + request['ClientOrderId'] = clientOrderId; + } + const response = await this.privatePostCancelReplaceOrder (this.extend (request, params)); + // + // { + // "replacementOrderId": 1234, + // "replacementClOrdId": 1561, + // "origOrderId": 5678, + // "origClOrdId": 91011, + // } + // + return this.parseOrder (response, market); + } + + async fetchMyTrades (symbol = undefined, since = undefined, limit = undefined, params = {}) { + const omsId = this.safeInteger (this.options, 'omsId', 1); + await this.loadMarkets (); + await this.loadAccounts (); + const defaultAccountId = this.safeInteger2 (this.options, 'accountId', 'AccountId', parseInt (this.accounts[0]['id'])); + const accountId = this.safeInteger2 (params, 'accountId', 'AccountId', defaultAccountId); + params = this.omit (params, [ 'accountId', 'AccountId' ]); + const request = { + 'omsId': omsId, + 'AccountId': accountId, + // 'InstrumentId': market['id'], + // 'TradeId': 123, // If you specify TradeId, GetTradesHistory can return all states for a single trade + // 'OrderId': 456, // If specified, the call returns all trades associated with the order + // 'UserId': integer. The ID of the logged-in user. If not specified, the call returns trades associated with the users belonging to the default account for the logged-in user of this OMS. + // 'StartTimeStamp': long integer. The historical date and time at which to begin the trade report, in POSIX format. If not specified, reverts to the start date of this account on the trading venue. + // 'EndTimeStamp': long integer. Date at which to end the trade report, in POSIX format. + // 'Depth': integer. In this case, the count of trades to return, counting from the StartIndex. If Depth is not specified, returns all trades between BeginTimeStamp and EndTimeStamp, beginning at StartIndex. + // 'StartIndex': 0 // from the most recent trade 0 and moving backwards in time + // 'ExecutionId': 123, // The ID of the individual buy or sell execution. If not specified, returns all. + }; + let market = undefined; + if (symbol !== undefined) { + market = this.market (symbol); + request['InstrumentId'] = market['id']; + } + if (since !== undefined) { + request['StartTimeStamp'] = since; + } + if (limit !== undefined) { + request['Depth'] = limit; + } + const response = await this.privateGetGetTradesHistory (this.extend (request, params)); + // + // [ + // { + // "OMSId":1, + // "ExecutionId":16916567, + // "TradeId":14476351, + // "OrderId":2543565231, + // "AccountId":449, + // "AccountName":"igor@ccxt.trade", + // "SubAccountId":0, + // "ClientOrderId":0, + // "InstrumentId":8, + // "Side":"Sell", + // "OrderType":"Market", + // "Quantity":0.1230000000000000000000000000, + // "RemainingQuantity":0.0000000000000000000000000000, + // "Price":19069.310000000000000000000000, + // "Value":2345.5251300000000000000000000, + // "CounterParty":"7", + // "OrderTradeRevision":1, + // "Direction":"NoChange", + // "IsBlockTrade":false, + // "Fee":1.1727625650000000000000000000, + // "FeeProductId":8, + // "OrderOriginator":446, + // "UserName":"igor@ccxt.trade", + // "TradeTimeMS":1607565031569, + // "MakerTaker":"Taker", + // "AdapterTradeId":0, + // "InsideBid":19069.310000000000000000000000, + // "InsideBidSize":0.2400950000000000000000000000, + // "InsideAsk":19069.320000000000000000000000, + // "InsideAskSize":0.0997360000000000000000000000, + // "IsQuote":false, + // "CounterPartyClientUserId":1, + // "NotionalProductId":2, + // "NotionalRate":1.0000000000000000000000000000, + // "NotionalValue":2345.5251300000000000000000000, + // "NotionalHoldAmount":0, + // "TradeTime":637431618315686826 + // } + // ] + // + return this.parseTrades (response, market, since, limit); + } + + async cancelAllOrders (symbol = undefined, params = {}) { + const omsId = this.safeInteger (this.options, 'omsId', 1); + await this.loadMarkets (); + await this.loadAccounts (); + const defaultAccountId = this.safeInteger2 (this.options, 'accountId', 'AccountId', parseInt (this.accounts[0]['id'])); + const accountId = this.safeInteger2 (params, 'accountId', 'AccountId', defaultAccountId); + params = this.omit (params, [ 'accountId', 'AccountId' ]); + const request = { + 'omsId': omsId, + 'AccountId': accountId, + }; + if (symbol !== undefined) { + const market = this.market (symbol); + request['IntrumentId'] = market['id']; + } + const response = await this.privatePostCancelAllOrders (this.extend (request, params)); + // + // { + // "result":true, + // "errormsg":null, + // "errorcode":0, + // "detail":null + // } + // + return response; + } + + async cancelOrder (id, symbol = undefined, params = {}) { + const omsId = this.safeInteger (this.options, 'omsId', 1); + await this.loadMarkets (); + await this.loadAccounts (); + // const defaultAccountId = this.safeInteger2 (this.options, 'accountId', 'AccountId', parseInt (this.accounts[0]['id'])); + // const accountId = this.safeInteger2 (params, 'accountId', 'AccountId', defaultAccountId); + // params = this.omit (params, [ 'accountId', 'AccountId' ]); + let market = undefined; + if (symbol !== undefined) { + market = this.market (symbol); + } + const request = { + 'omsId': omsId, + // 'AccountId': accountId, + }; + const clientOrderId = this.safeInteger2 (params, 'clientOrderId', 'ClOrderId'); + if (clientOrderId !== undefined) { + request['ClOrderId'] = clientOrderId; + } else { + request['OrderId'] = parseInt (id); + } + params = this.omit (params, [ 'clientOrderId', 'ClOrderId' ]); + const response = await this.privatePostCancelOrder (this.extend (request, params)); + const order = this.parseOrder (response, market); + return this.extend (order, { + 'id': id, + 'clientOrderId': clientOrderId, + }); + } + + async fetchOpenOrders (symbol = undefined, since = undefined, limit = undefined, params = {}) { + const omsId = this.safeInteger (this.options, 'omsId', 1); + await this.loadMarkets (); + await this.loadAccounts (); + const defaultAccountId = this.safeInteger2 (this.options, 'accountId', 'AccountId', parseInt (this.accounts[0]['id'])); + const accountId = this.safeInteger2 (params, 'accountId', 'AccountId', defaultAccountId); + params = this.omit (params, [ 'accountId', 'AccountId' ]); + let market = undefined; + if (symbol !== undefined) { + market = this.market (symbol); + } + const request = { + 'omsId': omsId, + 'AccountId': accountId, + }; + const response = await this.privateGetGetOpenOrders (this.extend (request, params)); + // + // [ + // { + // "Side":"Buy", + // "OrderId":2543565233, + // "Price":19010, + // "Quantity":0.345, + // "DisplayQuantity":0.345, + // "Instrument":8, + // "Account":449, + // "AccountName":"igor@ccxt.trade", + // "OrderType":"Limit", + // "ClientOrderId":0, + // "OrderState":"Working", + // "ReceiveTime":1607579326003, + // "ReceiveTimeTicks":637431761260028981, + // "LastUpdatedTime":1607579326005, + // "LastUpdatedTimeTicks":637431761260054714, + // "OrigQuantity":0.345, + // "QuantityExecuted":0, + // "GrossValueExecuted":0, + // "ExecutableValue":0, + // "AvgPrice":0, + // "CounterPartyId":0, + // "ChangeReason":"NewInputAccepted", + // "OrigOrderId":2543565233, + // "OrigClOrdId":0, + // "EnteredBy":446, + // "UserName":"igor@ccxt.trade", + // "IsQuote":false, + // "InsideAsk":19069.32, + // "InsideAskSize":0.099736, + // "InsideBid":19068.25, + // "InsideBidSize":1.330001, + // "LastTradePrice":19068.25, + // "RejectReason":"", + // "IsLockedIn":false, + // "CancelReason":"", + // "OrderFlag":"AddedToBook", + // "UseMargin":false, + // "StopPrice":0, + // "PegPriceType":"Unknown", + // "PegOffset":0, + // "PegLimitOffset":0, + // "IpAddress":null, + // "ClientOrderIdUuid":null, + // "OMSId":1 + // } + // ] + // + return this.parseOrders (response, market, since, limit); + } + + async fetchOrders (symbol = undefined, since = undefined, limit = undefined, params = {}) { + const omsId = this.safeInteger (this.options, 'omsId', 1); + await this.loadMarkets (); + await this.loadAccounts (); + const defaultAccountId = this.safeInteger2 (this.options, 'accountId', 'AccountId', parseInt (this.accounts[0]['id'])); + const accountId = this.safeInteger2 (params, 'accountId', 'AccountId', defaultAccountId); + params = this.omit (params, [ 'accountId', 'AccountId' ]); + const request = { + 'omsId': omsId, + 'AccountId': accountId, + // 'ClientOrderId': clientOrderId, + // 'OriginalOrderId': id, + // 'OriginalClientOrderId': long integer, + // 'UserId': integer, + // 'InstrumentId': market['id'], + // 'StartTimestamp': since, + // 'EndTimestamp': this.milliseconds (), + // 'Depth': limit, + // 'StartIndex': 0, + }; + let market = undefined; + if (symbol !== undefined) { + market = this.market (symbol); + request['InstrumentId'] = market['id']; + } + if (since !== undefined) { + request['StartTimeStamp'] = since; + } + if (limit !== undefined) { + request['Depth'] = limit; + } + const response = await this.privateGetGetOrdersHistory (this.extend (request, params)); + // + // [ + // { + // "Side":"Buy", + // "OrderId":2543565233, + // "Price":19010.000000000000000000000000, + // "Quantity":0.0000000000000000000000000000, + // "DisplayQuantity":0.3450000000000000000000000000, + // "Instrument":8, + // "Account":449, + // "AccountName":"igor@ccxt.trade", + // "OrderType":"Limit", + // "ClientOrderId":0, + // "OrderState":"Canceled", + // "ReceiveTime":1607579326003, + // "ReceiveTimeTicks":637431761260028981, + // "LastUpdatedTime":1607580965346, + // "LastUpdatedTimeTicks":637431777653463754, + // "OrigQuantity":0.3450000000000000000000000000, + // "QuantityExecuted":0.0000000000000000000000000000, + // "GrossValueExecuted":0.0000000000000000000000000000, + // "ExecutableValue":0.0000000000000000000000000000, + // "AvgPrice":0.0000000000000000000000000000, + // "CounterPartyId":0, + // "ChangeReason":"UserModified", + // "OrigOrderId":2543565233, + // "OrigClOrdId":0, + // "EnteredBy":446, + // "UserName":"igor@ccxt.trade", + // "IsQuote":false, + // "InsideAsk":19069.320000000000000000000000, + // "InsideAskSize":0.0997360000000000000000000000, + // "InsideBid":19068.250000000000000000000000, + // "InsideBidSize":1.3300010000000000000000000000, + // "LastTradePrice":19068.250000000000000000000000, + // "RejectReason":"", + // "IsLockedIn":false, + // "CancelReason":"UserModified", + // "OrderFlag":"AddedToBook, RemovedFromBook", + // "UseMargin":false, + // "StopPrice":0.0000000000000000000000000000, + // "PegPriceType":"Unknown", + // "PegOffset":0.0000000000000000000000000000, + // "PegLimitOffset":0.0000000000000000000000000000, + // "IpAddress":"5.228.233.138", + // "ClientOrderIdUuid":null, + // "OMSId":1 + // }, + // ] + // + return this.parseOrders (response, market, since, limit); + } + + async fetchOrder (id, symbol = undefined, params = {}) { + const omsId = this.safeInteger (this.options, 'omsId', 1); + await this.loadMarkets (); + await this.loadAccounts (); + const defaultAccountId = this.safeInteger2 (this.options, 'accountId', 'AccountId', parseInt (this.accounts[0]['id'])); + const accountId = this.safeInteger2 (params, 'accountId', 'AccountId', defaultAccountId); + params = this.omit (params, [ 'accountId', 'AccountId' ]); + let market = undefined; + if (symbol !== undefined) { + market = this.market (symbol); + } + const request = { + 'omsId': omsId, + 'AccountId': accountId, + 'OrderId': parseInt (id), + }; + const response = await this.privateGetGetOrderStatus (this.extend (request, params)); + // + // { + // "Side":"Sell", + // "OrderId":2543565232, + // "Price":0.0000000000000000000000000000, + // "Quantity":0.0000000000000000000000000000, + // "DisplayQuantity":0.0000000000000000000000000000, + // "Instrument":8, + // "Account":449, + // "AccountName":"igor@ccxt.trade", + // "OrderType":"Market", + // "ClientOrderId":0, + // "OrderState":"FullyExecuted", + // "ReceiveTime":1607569475591, + // "ReceiveTimeTicks":637431662755912377, + // "LastUpdatedTime":1607569475596, + // "LastUpdatedTimeTicks":637431662755960902, + // "OrigQuantity":1.0000000000000000000000000000, + // "QuantityExecuted":1.0000000000000000000000000000, + // "GrossValueExecuted":19068.270478610000000000000000, + // "ExecutableValue":0.0000000000000000000000000000, + // "AvgPrice":19068.270478610000000000000000, + // "CounterPartyId":0, + // "ChangeReason":"Trade", + // "OrigOrderId":2543565232, + // "OrigClOrdId":0, + // "EnteredBy":446, + // "UserName":"igor@ccxt.trade", + // "IsQuote":false, + // "InsideAsk":19069.320000000000000000000000, + // "InsideAskSize":0.0997360000000000000000000000, + // "InsideBid":19069.310000000000000000000000, + // "InsideBidSize":0.2400950000000000000000000000, + // "LastTradePrice":19069.310000000000000000000000, + // "RejectReason":"", + // "IsLockedIn":false, + // "CancelReason":"", + // "OrderFlag":"0", + // "UseMargin":false, + // "StopPrice":0.0000000000000000000000000000, + // "PegPriceType":"Unknown", + // "PegOffset":0.0000000000000000000000000000, + // "PegLimitOffset":0.0000000000000000000000000000, + // "IpAddress":"5.228.233.138", + // "ClientOrderIdUuid":null, + // "OMSId":1 + // } + // + return this.parseOrder (response, market); + } + + async fetchOrderTrades (id, symbol = undefined, since = undefined, limit = undefined, params = {}) { + const omsId = this.safeInteger (this.options, 'omsId', 1); + await this.loadMarkets (); + await this.loadAccounts (); + // const defaultAccountId = this.safeInteger2 (this.options, 'accountId', 'AccountId', parseInt (this.accounts[0]['id'])); + // const accountId = this.safeInteger2 (params, 'accountId', 'AccountId', defaultAccountId); + // params = this.omit (params, [ 'accountId', 'AccountId' ]); + let market = undefined; + if (symbol !== undefined) { + market = this.market (symbol); + } + const request = { + 'OMSId': parseInt (omsId), + // 'AccountId': accountId, + 'OrderId': id, + }; + const response = await this.privatePostGetOrderHistoryByOrderId (this.extend (request, params)); + // + // [ + // { + // "Side":"Sell", + // "OrderId":2543565235, + // "Price":18600.000000000000000000000000, + // "Quantity":0.0000000000000000000000000000, + // "DisplayQuantity":0.0000000000000000000000000000, + // "Instrument":8, + // "Account":449, + // "AccountName":"igor@ccxt.trade", + // "OrderType":"Limit", + // "ClientOrderId":0, + // "OrderState":"FullyExecuted", + // "ReceiveTime":1607585844956, + // "ReceiveTimeTicks":637431826449564182, + // "LastUpdatedTime":1607585844959, + // "LastUpdatedTimeTicks":637431826449593893, + // "OrigQuantity":0.1230000000000000000000000000, + // "QuantityExecuted":0.1230000000000000000000000000, + // "GrossValueExecuted":2345.3947500000000000000000000, + // "ExecutableValue":0.0000000000000000000000000000, + // "AvgPrice":19068.250000000000000000000000, + // "CounterPartyId":0, + // "ChangeReason":"Trade", + // "OrigOrderId":2543565235, + // "OrigClOrdId":0, + // "EnteredBy":446, + // "UserName":"igor@ccxt.trade", + // "IsQuote":false, + // "InsideAsk":19069.320000000000000000000000, + // "InsideAskSize":0.0997360000000000000000000000, + // "InsideBid":19068.250000000000000000000000, + // "InsideBidSize":1.3300010000000000000000000000, + // "LastTradePrice":19068.250000000000000000000000, + // "RejectReason":"", + // "IsLockedIn":false, + // "CancelReason":"", + // "OrderFlag":"0", + // "UseMargin":false, + // "StopPrice":0.0000000000000000000000000000, + // "PegPriceType":"Unknown", + // "PegOffset":0.0000000000000000000000000000, + // "PegLimitOffset":0.0000000000000000000000000000, + // "IpAddress":"5.228.233.138", + // "ClientOrderIdUuid":null, + // "OMSId":1 + // }, + // ] + // + const grouped = this.groupBy (response, 'ChangeReason'); + const trades = this.safeValue (grouped, 'Trade', []); + return this.parseTrades (trades, market, since, limit); + } + + async fetchDepositAddress (code, params = {}) { + const omsId = this.safeInteger (this.options, 'omsId', 1); + await this.loadMarkets (); + await this.loadAccounts (); + const defaultAccountId = this.safeInteger2 (this.options, 'accountId', 'AccountId', parseInt (this.accounts[0]['id'])); + const accountId = this.safeInteger2 (params, 'accountId', 'AccountId', defaultAccountId); + params = this.omit (params, [ 'accountId', 'AccountId' ]); + const currency = this.currency (code); + const request = { + 'omsId': omsId, + 'AccountId': accountId, + 'ProductId': currency['id'], + 'GenerateNewKey': false, + }; + const response = await this.privateGetGetDepositInfo (this.extend (request, params)); + // + // { + // "result":true, + // "errormsg":null, + // "statuscode":0, + // "AssetManagerId":1, + // "AccountId":57922, + // "AssetId":16, + // "ProviderId":23, + // "DepositInfo":"[\"0x8A27564b5c30b91C93B1591821642420F323a210\"]" + // } + // + return this.parseDepositAddress (response, currency); + } + + parseDepositAddress (depositAddress, currency = undefined) { + // + // fetchDepositAddress, createDepositAddress + // + // { + // "result":true, + // "errormsg":null, + // "statuscode":0, + // "AssetManagerId":1, + // "AccountId":449, + // "AssetId":1, + // "ProviderId":1, + // "DepositInfo":"[\"r3e95RwVsLH7yCbnMfyh7SA8FdwUJCB4S2?memo=241452010\"]" + // } + // + const depositInfoString = this.safeString (depositAddress, 'DepositInfo'); + const depositInfo = JSON.parse (depositInfoString); + const depositInfoLength = depositInfo.length; + const lastString = this.safeString (depositInfo, depositInfoLength - 1); + const parts = lastString.split ('?memo='); + const address = this.safeString (parts, 0); + const tag = this.safeString (parts, 1); + let code = undefined; + if (currency !== undefined) { + code = currency['code']; + } + this.checkAddress (address); + return { + 'currency': code, + 'address': address, + 'tag': tag, + 'info': depositAddress, + }; + } + + async createDepositAddress (code, params = {}) { + const request = { + 'GenerateNewKey': true, + }; + return await this.fetchDepositAddress (code, this.extend (request, params)); + } + + async fetchDeposits (code = undefined, since = undefined, limit = undefined, params = {}) { + const omsId = this.safeInteger (this.options, 'omsId', 1); + await this.loadMarkets (); + await this.loadAccounts (); + const defaultAccountId = this.safeInteger2 (this.options, 'accountId', 'AccountId', parseInt (this.accounts[0]['id'])); + const accountId = this.safeInteger2 (params, 'accountId', 'AccountId', defaultAccountId); + params = this.omit (params, [ 'accountId', 'AccountId' ]); + let currency = undefined; + if (code !== undefined) { + currency = this.currency (code); + } + const request = { + 'omsId': omsId, + 'AccountId': accountId, + }; + const response = await this.privateGetGetDeposits (this.extend (request, params)); + // + // [ + // { + // "OMSId":1, + // "DepositId":44, + // "AccountId":449, + // "SubAccountId":0, + // "ProductId":4, + // "Amount":200.00000000000000000000000000, + // "LastUpdateTimeStamp":637431291261187806, + // "ProductType":"CryptoCurrency", + // "TicketStatus":"FullyProcessed", + // "DepositInfo":"{}", + // "DepositCode":"ab0e23d5-a9ce-4d94-865f-9ab464fb1de3", + // "TicketNumber":71, + // "NotionalProductId":13, + // "NotionalValue":200.00000000000000000000000000, + // "FeeAmount":0.0000000000000000000000000000, + // }, + // ] + // + return this.parseTransactions (response, currency, since, limit); + } + + async fetchWithdrawals (code = undefined, since = undefined, limit = undefined, params = {}) { + const omsId = this.safeInteger (this.options, 'omsId', 1); + await this.loadMarkets (); + await this.loadAccounts (); + const defaultAccountId = this.safeInteger2 (this.options, 'accountId', 'AccountId', parseInt (this.accounts[0]['id'])); + const accountId = this.safeInteger2 (params, 'accountId', 'AccountId', defaultAccountId); + params = this.omit (params, [ 'accountId', 'AccountId' ]); + let currency = undefined; + if (code !== undefined) { + currency = this.currency (code); + } + const request = { + 'omsId': omsId, + 'AccountId': accountId, + }; + const response = await this.privateGetGetWithdraws (this.extend (request, params)); + // + // [ + // { + // "Amount": 0.0, + // "FeeAmount": 0.0, + // "NotionalValue": 0.0, + // "WithdrawId": 0, + // "AssetManagerId": 0, + // "AccountId": 0, + // "AssetId": 0, + // "TemplateForm": "{\"TemplateType\": \"TetherRPCWithdraw\",\"Comment\": \"TestWithdraw\",\"ExternalAddress\": \"ms6C3pKAAr8gRCcnVebs8VRkVrjcvqNYv3\"}", + // "TemplateFormType": "TetherRPCWithdraw", + // "omsId": 0, + // "TicketStatus": 0, + // "TicketNumber": 0, + // "WithdrawTransactionDetails": "", + // "WithdrawType": "", + // "WithdrawCode": "490b4fa3-53fc-44f4-bd29-7e16be86fba3", + // "AssetType": 0, + // "Reaccepted": true, + // "NotionalProductId": 0 + // }, + // ] + // + return this.parseTransactions (response, currency, since, limit); + } + + parseTransactionStatusByType (status, type = undefined) { + const statusesByType = { + 'deposit': { + 'New': 'pending', // new ticket awaiting operator review + 'AdminProcessing': 'pending', // an admin is looking at the ticket + 'Accepted': 'pending', // an admin accepts the ticket + 'Rejected': 'rejected', // admin rejects the ticket + 'SystemProcessing': 'pending', // automatic processing; an unlikely status for a deposit + 'FullyProcessed': 'ok', // the deposit has concluded + 'Failed': 'failed', // the deposit has failed for some reason + 'Pending': 'pending', // Account Provider has set status to pending + 'Confirmed': 'pending', // Account Provider confirms the deposit + 'AmlProcessing': 'pending', // anti-money-laundering process underway + 'AmlAccepted': 'pending', // anti-money-laundering process successful + 'AmlRejected': 'rejected', // deposit did not stand up to anti-money-laundering process + 'AmlFailed': 'failed', // anti-money-laundering process failed/did not complete + 'LimitsAccepted': 'pending', // deposit meets limits for fiat or crypto asset + 'LimitsRejected': 'rejected', // deposit does not meet limits for fiat or crypto asset + }, + 'withdrawal': { + 'New': 'pending', // awaiting operator review + 'AdminProcessing': 'pending', // An admin is looking at the ticket + 'Accepted': 'pending', // withdrawal will proceed + 'Rejected': 'rejected', // admin or automatic rejection + 'SystemProcessing': 'pending', // automatic processing underway + 'FullyProcessed': 'ok', // the withdrawal has concluded + 'Failed': 'failed', // the withdrawal failed for some reason + 'Pending': 'pending', // the admin has placed the withdrawal in pending status + 'Pending2Fa': 'pending', // user must click 2-factor authentication confirmation link + 'AutoAccepted': 'pending', // withdrawal will be automatically processed + 'Delayed': 'pending', // waiting for funds to be allocated for the withdrawal + 'UserCanceled': 'canceled', // withdraw canceled by user or Superuser + 'AdminCanceled': 'canceled', // withdraw canceled by Superuser + 'AmlProcessing': 'pending', // anti-money-laundering process underway + 'AmlAccepted': 'pending', // anti-money-laundering process complete + 'AmlRejected': 'rejected', // withdrawal did not stand up to anti-money-laundering process + 'AmlFailed': 'failed', // withdrawal did not complete anti-money-laundering process + 'LimitsAccepted': 'pending', // withdrawal meets limits for fiat or crypto asset + 'LimitsRejected': 'rejected', // withdrawal does not meet limits for fiat or crypto asset + 'Submitted': 'pending', // withdrawal sent to Account Provider; awaiting blockchain confirmation + 'Confirmed': 'pending', // Account Provider confirms that withdrawal is on the blockchain + 'ManuallyConfirmed': 'pending', // admin has sent withdrawal via wallet or admin function directly; marks ticket as FullyProcessed; debits account + 'Confirmed2Fa': 'pending', // user has confirmed withdraw via 2-factor authentication. + }, + }; + const statuses = this.safeValue (statusesByType, type, {}); + return this.safeString (statuses, status, status); + } + + parseTransaction (transaction, currency = undefined) { + // + // fetchDeposits + // + // { + // "OMSId":1, + // "DepositId":44, + // "AccountId":449, + // "SubAccountId":0, + // "ProductId":4, + // "Amount":200.00000000000000000000000000, + // "LastUpdateTimeStamp":637431291261187806, + // "ProductType":"CryptoCurrency", + // "TicketStatus":"FullyProcessed", + // "DepositInfo":"{}", + // "DepositCode":"ab0e23d5-a9ce-4d94-865f-9ab464fb1de3", + // "TicketNumber":71, + // "NotionalProductId":13, + // "NotionalValue":200.00000000000000000000000000, + // "FeeAmount":0.0000000000000000000000000000, + // } + // + // fetchWithdrawals + // + // { + // "Amount": 0.0, + // "FeeAmount": 0.0, + // "NotionalValue": 0.0, + // "WithdrawId": 0, + // "AssetManagerId": 0, + // "AccountId": 0, + // "AssetId": 0, + // "TemplateForm": "{\"TemplateType\": \"TetherRPCWithdraw\",\"Comment\": \"TestWithdraw\",\"ExternalAddress\": \"ms6C3pKAAr8gRCcnVebs8VRkVrjcvqNYv3\"}", + // "TemplateFormType": "TetherRPCWithdraw", + // "omsId": 0, + // "TicketStatus": 0, + // "TicketNumber": 0, + // "WithdrawTransactionDetails": "", + // "WithdrawType": "", + // "WithdrawCode": "490b4fa3-53fc-44f4-bd29-7e16be86fba3", + // "AssetType": 0, + // "Reaccepted": true, + // "NotionalProductId": 0 + // } + // + const id = this.safeString (transaction, 'DepositId'); + let txid = undefined; + const currencyId = this.safeString (transaction, 'ProductId'); + const code = this.safeCurrencyCode (currencyId, currency); + let timestamp = undefined; + let type = undefined; + if ('DepositId' in transaction) { + type = 'deposit'; + } else if ('WithdrawId' in transaction) { + type = 'withdrawal'; + } + const templateFormString = this.safeString (transaction, 'TemplateForm'); + let address = undefined; + let updated = this.safeInteger (transaction, 'LastUpdateTimeStamp'); + if (templateFormString !== undefined) { + const templateForm = JSON.parse (templateFormString); + address = this.safeString (templateForm, 'ExternalAddress'); + txid = this.safeString (templateForm, 'TxId'); + timestamp = this.safeInteger (templateForm, 'TimeSubmitted'); + updated = this.safeInteger (templateForm, 'LastUpdated', updated); + } + const addressTo = address; + const status = this.parseTransactionStatusByType (this.safeString (transaction, 'TicketStatus'), type); + const amount = this.safeFloat (transaction, 'Amount'); + const feeCost = this.safeFloat (transaction, 'FeeAmount'); + let fee = undefined; + if (feeCost !== undefined) { + fee = { 'currency': code, 'cost': feeCost }; + } + return { + 'info': transaction, + 'id': id, + 'txid': txid, + 'timestamp': timestamp, + 'datetime': this.iso8601 (timestamp), + 'address': address, + 'addressTo': addressTo, + 'addressFrom': undefined, + 'tag': undefined, + 'tagTo': undefined, + 'tagFrom': undefined, + 'type': type, + 'amount': amount, + 'currency': code, + 'status': status, + 'updated': updated, + 'fee': fee, + }; + } + + nonce () { + return this.milliseconds (); + } + + sign (path, api = 'public', method = 'GET', params = {}, headers = undefined, body = undefined) { + let url = this.urls['api'][api] + '/' + this.implodeParams (path, params); + const query = this.omit (params, this.extractParams (path)); + if (api === 'public') { + if (Object.keys (query).length) { + url += '?' + this.urlencode (query); + } + } else if (api === 'private') { + this.checkRequiredCredentials (); + const nonce = this.nonce ().toString (); + const auth = nonce + this.uid + this.apiKey; + const signature = this.hmac (this.encode (auth), this.encode (this.secret)); + headers = { + 'Nonce': nonce, + 'APIKey': this.apiKey, + 'Signature': signature, + 'UserId': this.uid, + }; + if (method === 'POST') { + headers['Content-Type'] = 'application/json'; + body = this.json (query); + } else { + if (Object.keys (query).length) { + url += '?' + this.urlencode (query); + } + } + } + return { 'url': url, 'method': method, 'body': body, 'headers': headers }; + } + + handleErrors (code, reason, url, method, headers, body, response, requestHeaders, requestBody) { + if (code === 404) { + throw new AuthenticationError (this.id + ' ' + body); + } + if (response === undefined) { + return; + } + // + // {"status":"Rejected","errormsg":"Not_Enough_Funds","errorcode":101} + // {"result":false,"errormsg":"Server Error","errorcode":102,"detail":null} + // + const message = this.safeString (response, 'errormsg'); + if ((message !== undefined) && (message !== '')) { + const feedback = this.id + ' ' + body; + this.throwExactlyMatchedException (this.exceptions['exact'], message, feedback); + this.throwBroadlyMatchedException (this.exceptions['broad'], body, feedback); + throw new ExchangeError (feedback); + } + } +}; + +},{"./base/Exchange":6,"./base/errors":8,"./base/functions/number":14}],114:[function(require,module,exports){ 'use strict'; // --------------------------------------------------------------------------- @@ -89216,6 +97366,7 @@ module.exports = class novadax extends Exchange { 'symbol': symbol, 'type': type, 'timeInForce': undefined, + 'postOnly': undefined, 'side': side, 'price': price, 'stopPrice': undefined, @@ -89532,7 +97683,7 @@ module.exports = class novadax extends Exchange { } }; -},{"./base/Exchange":5,"./base/errors":7,"./base/functions/number":13}],112:[function(require,module,exports){ +},{"./base/Exchange":6,"./base/errors":8,"./base/functions/number":14}],115:[function(require,module,exports){ 'use strict'; // --------------------------------------------------------------------------- @@ -90047,7 +98198,7 @@ module.exports = class oceanex extends Exchange { async fetchOrders (symbol = undefined, since = undefined, limit = undefined, params = {}) { if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' fetchOrders requires a `symbol` argument'); + throw new ArgumentsRequired (this.id + ' fetchOrders() requires a `symbol` argument'); } await this.loadMarkets (); const market = this.market (symbol); @@ -90108,6 +98259,7 @@ module.exports = class oceanex extends Exchange { 'symbol': symbol, 'type': this.safeValue (order, 'ord_type'), 'timeInForce': undefined, + 'postOnly': undefined, 'side': this.safeValue (order, 'side'), 'price': this.safeFloat (order, 'price'), 'stopPrice': undefined, @@ -90217,7 +98369,7 @@ module.exports = class oceanex extends Exchange { } }; -},{"./base/Exchange":5,"./base/errors":7}],113:[function(require,module,exports){ +},{"./base/Exchange":6,"./base/errors":8}],116:[function(require,module,exports){ 'use strict'; // --------------------------------------------------------------------------- @@ -90254,13 +98406,13 @@ module.exports = class okcoin extends okex { } }; -},{"./okex.js":114}],114:[function(require,module,exports){ +},{"./okex.js":117}],117:[function(require,module,exports){ 'use strict'; // --------------------------------------------------------------------------- const Exchange = require ('./base/Exchange'); -const { ExchangeError, ExchangeNotAvailable, OnMaintenance, ArgumentsRequired, BadRequest, AccountSuspended, InvalidAddress, PermissionDenied, DDoSProtection, InsufficientFunds, InvalidNonce, CancelPending, InvalidOrder, OrderNotFound, AuthenticationError, RequestTimeout, NotSupported, BadSymbol } = require ('./base/errors'); +const { ExchangeError, ExchangeNotAvailable, OnMaintenance, ArgumentsRequired, BadRequest, AccountSuspended, InvalidAddress, PermissionDenied, DDoSProtection, InsufficientFunds, InvalidNonce, CancelPending, InvalidOrder, OrderNotFound, AuthenticationError, RequestTimeout, NotSupported, BadSymbol, RateLimitExceeded } = require ('./base/errors'); const { TICK_SIZE, TRUNCATE } = require ('./base/functions/number'); // --------------------------------------------------------------------------- @@ -90365,6 +98517,7 @@ module.exports = class okex extends Exchange { 'accounts/{currency}', 'accounts/{currency}/ledger', 'orders', + 'amend_order/{instrument_id}', 'orders_pending', 'orders/{order_id}', 'orders/{client_oid}', @@ -90455,6 +98608,7 @@ module.exports = class okex extends Exchange { 'post': [ 'accounts/{underlying}/leverage', 'order', + 'amend_order/{instrument_id}', 'orders', 'cancel_order/{instrument_id}/{order_id}', 'cancel_order/{instrument_id}/{client_oid}', @@ -90501,12 +98655,17 @@ module.exports = class okex extends Exchange { 'post': [ 'accounts/{instrument_id}/leverage', 'order', + 'amend_order/{instrument_id}', 'orders', 'cancel_order/{instrument_id}/{order_id}', 'cancel_order/{instrument_id}/{client_oid}', 'cancel_batch_orders/{instrument_id}', 'order_algo', 'cancel_algos', + 'close_position', + 'cancel_all', + 'order_algo', + 'cancel_algos', ], }, 'option': { @@ -90783,7 +98942,7 @@ module.exports = class okex extends Exchange { '34021': InvalidAddress, // { "code": 34021, "message": "Not verified address" } '34022': ExchangeError, // { "code": 34022, "message": "Withdrawals are not available for sub accounts" } '34023': PermissionDenied, // { "code": 34023, "message": "Please enable futures trading before transferring your funds" } - '34026': ExchangeError, // transfer too frequently(transfer too frequently) + '34026': RateLimitExceeded, // transfer too frequently(transfer too frequently) '34036': ExchangeError, // Parameter is incorrect, please refer to API documentation '34037': ExchangeError, // Get the sub-account balance interface, account type is not supported '34038': ExchangeError, // Since your C2C transaction is unusual, you are restricted from fund transfer. Please contact our customer support to cancel the restriction @@ -90812,7 +98971,7 @@ module.exports = class okex extends Exchange { '35031': InvalidOrder, // { "code": 35031, "message": "Cancel order size too large" } '35032': ExchangeError, // { "code": 35032, "message": "Invalid user status" } '35037': ExchangeError, // No last traded price in cache - '35039': ExchangeError, // { "code": 35039, "message": "Open order quantity exceeds limit" } + '35039': InsufficientFunds, // { "code": 35039, "message": "Open order quantity exceeds limit" } '35040': InvalidOrder, // {"error_message":"Invalid order type","result":"true","error_code":"35040","order_id":"-1"} '35044': ExchangeError, // { "code": 35044, "message": "Invalid order status" } '35046': InsufficientFunds, // { "code": 35046, "message": "Negative account balance" } @@ -90865,6 +99024,7 @@ module.exports = class okex extends Exchange { '35097': ExchangeError, // Order status and order ID cannot exist at the same time '35098': ExchangeError, // An order status or order ID must exist '35099': ExchangeError, // Algo order ID error + '35102': RateLimitExceeded, // {"error_message":"The operation that close all at market price is too frequent","result":"true","error_code":"35102","order_id":"-1"} // option '36001': BadRequest, // Invalid underlying index. '36002': BadRequest, // Instrument does not exist. @@ -90934,6 +99094,7 @@ module.exports = class okex extends Exchange { 'HOT': 'Hydro Protocol', 'HSR': 'HC', 'MAG': 'Maggie', + 'SBTC': 'Super Bitcoin', 'YOYO': 'YOYOW', 'WIN': 'WinToken', // https://github.com/ccxt/ccxt/issues/5701 }, @@ -91233,7 +99394,7 @@ module.exports = class okex extends Exchange { const currency = response[i]; const id = this.safeString (currency, 'currency'); const code = this.safeCurrencyCode (id); - const precision = 8; // default precision, todo: fix "magic constants" + const precision = 0.00000001; // default precision, todo: fix "magic constants" const name = this.safeString (currency, 'name'); const canDeposit = this.safeInteger (currency, 'can_deposit'); const canWithdraw = this.safeInteger (currency, 'can_withdraw'); @@ -91969,7 +100130,7 @@ module.exports = class okex extends Exchange { const defaultType = this.safeString2 (this.options, 'fetchBalance', 'defaultType'); const type = this.safeString (params, 'type', defaultType); if (type === undefined) { - throw new ArgumentsRequired (this.id + " fetchBalance requires a type parameter (one of 'account', 'spot', 'margin', 'futures', 'swap')"); + throw new ArgumentsRequired (this.id + " fetchBalance() requires a type parameter (one of 'account', 'spot', 'margin', 'futures', 'swap')"); } await this.loadMarkets (); const suffix = (type === 'account') ? 'Wallet' : 'Accounts'; @@ -92215,7 +100376,7 @@ module.exports = class okex extends Exchange { type = this.safeString (params, 'type', defaultType); } if (type === undefined) { - throw new ArgumentsRequired (this.id + " cancelOrder requires a type parameter (one of 'spot', 'margin', 'futures', 'swap')."); + throw new ArgumentsRequired (this.id + " cancelOrder() requires a type parameter (one of 'spot', 'margin', 'futures', 'swap')."); } let method = type + 'PostCancelOrder'; const request = { @@ -92422,6 +100583,7 @@ module.exports = class okex extends Exchange { 'symbol': symbol, 'type': type, 'timeInForce': undefined, + 'postOnly': undefined, 'side': side, 'price': price, 'stopPrice': stopPrice, @@ -92438,14 +100600,14 @@ module.exports = class okex extends Exchange { async fetchOrder (id, symbol = undefined, params = {}) { if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' fetchOrder requires a symbol argument'); + throw new ArgumentsRequired (this.id + ' fetchOrder() requires a symbol argument'); } await this.loadMarkets (); const market = this.market (symbol); const defaultType = this.safeString2 (this.options, 'fetchOrder', 'defaultType', market['type']); const type = this.safeString (params, 'type', defaultType); if (type === undefined) { - throw new ArgumentsRequired (this.id + " fetchOrder requires a type parameter (one of 'spot', 'margin', 'futures', 'swap')."); + throw new ArgumentsRequired (this.id + " fetchOrder() requires a type parameter (one of 'spot', 'margin', 'futures', 'swap')."); } const instrumentId = (market['futures'] || market['swap']) ? 'InstrumentId' : ''; let method = type + 'GetOrders' + instrumentId; @@ -92513,7 +100675,7 @@ module.exports = class okex extends Exchange { async fetchOrdersByState (state, symbol = undefined, since = undefined, limit = undefined, params = {}) { if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' fetchOrdersByState requires a symbol argument'); + throw new ArgumentsRequired (this.id + ' fetchOrdersByState() requires a symbol argument'); } await this.loadMarkets (); const market = this.market (symbol); @@ -92525,7 +100687,7 @@ module.exports = class okex extends Exchange { type = this.safeString (params, 'type', defaultType); } if (type === undefined) { - throw new ArgumentsRequired (this.id + " fetchOrder requires a type parameter (one of 'spot', 'margin', 'futures', 'swap')."); + throw new ArgumentsRequired (this.id + " fetchOrdersByState() requires a type parameter (one of 'spot', 'margin', 'futures', 'swap')."); } const request = { 'instrument_id': market['id'], @@ -92855,6 +101017,7 @@ module.exports = class okex extends Exchange { // "currency": "XMR", // "from": "", // "to": "48PjH3ksv1fiXniKvKvyH5UtFs5WhfS2Vf7U3TwzdRJtCc7HJWvCQe56dRahyhQyTAViXZ8Nzk4gQg6o4BJBMUoxNy8y8g7", + // "tag": "1234567", // "deposit_id": 11571659, <-- we can use this // "timestamp": "2019-10-01T14:54:19.000Z", // "status": "2" @@ -92866,6 +101029,7 @@ module.exports = class okex extends Exchange { const withdrawalId = this.safeString (transaction, 'withdrawal_id'); const addressFrom = this.safeString (transaction, 'from'); const addressTo = this.safeString (transaction, 'to'); + const tagTo = this.safeString (transaction, 'tag'); if (withdrawalId !== undefined) { type = 'withdrawal'; id = withdrawalId; @@ -92906,8 +101070,8 @@ module.exports = class okex extends Exchange { 'addressTo': addressTo, 'address': address, 'tagFrom': undefined, - 'tagTo': undefined, - 'tag': undefined, + 'tagTo': tagTo, + 'tag': tagTo, 'status': status, 'type': type, 'updated': undefined, @@ -93080,7 +101244,7 @@ module.exports = class okex extends Exchange { // this aspect renders the 'fills' endpoint unusable for fetchOrderTrades // until either OKEX fixes the API or we workaround this on our side somehow if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' fetchMyTrades requires a symbol argument'); + throw new ArgumentsRequired (this.id + ' fetchMyTrades() requires a symbol argument'); } await this.loadMarkets (); const market = this.market (symbol); @@ -93469,16 +101633,28 @@ module.exports = class okex extends Exchange { request['limit'] = limit; } let currency = undefined; - if ((type === 'spot') || (type === 'futures')) { + if (type === 'spot') { if (code === undefined) { - throw new ArgumentsRequired (this.id + " fetchLedger requires a currency code argument for '" + type + "' markets"); + throw new ArgumentsRequired (this.id + " fetchLedger() requires a currency code argument for '" + type + "' markets"); } argument = 'Currency'; currency = this.currency (code); request['currency'] = currency['id']; + } else if (type === 'futures') { + if (code === undefined) { + throw new ArgumentsRequired (this.id + " fetchLedger() requires an underlying symbol for '" + type + "' markets"); + } + argument = 'Underlying'; + const market = this.market (code); // we intentionally put a market inside here for the margin and swap ledgers + const marketInfo = this.safeValue (market, 'info', {}); + const settlementCurrencyId = this.safeString (marketInfo, 'settlement_currency'); + const settlementCurrencyСode = this.safeCurrencyCode (settlementCurrencyId); + currency = this.currency (settlementCurrencyСode); + const underlyingId = this.safeString (marketInfo, 'underlying'); + request['underlying'] = underlyingId; } else if ((type === 'margin') || (type === 'swap')) { if (code === undefined) { - throw new ArgumentsRequired (this.id + " fetchLedger requires a code argument (a market symbol) for '" + type + "' markets"); + throw new ArgumentsRequired (this.id + " fetchLedger() requires a code argument (a market symbol) for '" + type + "' markets"); } argument = 'InstrumentId'; const market = this.market (code); // we intentionally put a market inside here for the margin and swap ledgers @@ -93872,7 +102048,7 @@ module.exports = class okex extends Exchange { } }; -},{"./base/Exchange":5,"./base/errors":7,"./base/functions/number":13}],115:[function(require,module,exports){ +},{"./base/Exchange":6,"./base/errors":8,"./base/functions/number":14}],118:[function(require,module,exports){ 'use strict'; // --------------------------------------------------------------------------- @@ -94137,7 +102313,7 @@ module.exports = class paymium extends Exchange { } }; -},{"./base/Exchange":5,"./base/errors":7}],116:[function(require,module,exports){ +},{"./base/Exchange":6,"./base/errors":8}],119:[function(require,module,exports){ 'use strict'; // ---------------------------------------------------------------------------- @@ -94242,6 +102418,7 @@ module.exports = class phemex extends Exchange { 'exchange/spot/order/trades', // ?symbol=&start=&end=&limit=&offset= // swap 'accounts/accountPositions', // ?currency= + 'accounts/positions', // ?currency= 'orders/activeList', // ?symbol= 'exchange/order/list', // ?symbol=&start=&end=&offset=&limit=&ordStatus=&withCount= 'exchange/order', // ?symbol=&orderID= @@ -94868,7 +103045,7 @@ module.exports = class phemex extends Exchange { parseBidAsk (bidask, priceKey = 0, amountKey = 1, market = undefined) { if (market === undefined) { - throw new ArgumentsRequired (this.id + ' parseBidAsk requires a market argument'); + throw new ArgumentsRequired (this.id + ' parseBidAsk() requires a market argument'); } let amount = this.safeFloat (bidask, amountKey); if (market['spot']) { @@ -94961,6 +103138,9 @@ module.exports = class phemex extends Exchange { } fromEn (en, scale, precision, precisionMode = undefined) { + if (en === undefined) { + return en; + } precisionMode = (precisionMode === undefined) ? this.precisionMode : precisionMode; return parseFloat (this.decimalToPrecision (en * Math.pow (10, -scale), ROUND, precision, precisionMode)); } @@ -95004,13 +103184,19 @@ module.exports = class phemex extends Exchange { // 48759063370, // quote volume // ] // + let baseVolume = undefined; + if ((market !== undefined) && market['spot']) { + baseVolume = this.fromEv (this.safeFloat (ohlcv, 7), market); + } else { + baseVolume = this.safeInteger (ohlcv, 7); + } return [ this.safeTimestamp (ohlcv, 0), this.fromEp (this.safeFloat (ohlcv, 3), market), this.fromEp (this.safeFloat (ohlcv, 4), market), this.fromEp (this.safeFloat (ohlcv, 5), market), this.fromEp (this.safeFloat (ohlcv, 6), market), - this.fromEv (this.safeFloat (ohlcv, 7), market), + baseVolume, ]; } @@ -95037,7 +103223,7 @@ module.exports = class phemex extends Exchange { request['from'] = now - duration * this.sum (limit, 1); request['to'] = now; } else { - throw new ArgumentsRequired (this.id + ' fetchOHLCV requires a since argument, or a limit argument, or both'); + throw new ArgumentsRequired (this.id + ' fetchOHLCV() requires a since argument, or a limit argument, or both'); } await this.loadMarkets (); const market = this.market (symbol); @@ -95542,7 +103728,7 @@ module.exports = class phemex extends Exchange { } else { const currency = this.safeString (params, 'currency'); if (currency === undefined) { - throw new ArgumentsRequired (this.id + ' fetchBalance requires a code parameter or a currency parameter for ' + type + ' type'); + throw new ArgumentsRequired (this.id + ' fetchBalance() requires a code parameter or a currency parameter for ' + type + ' type'); } } method = 'privateGetAccountsAccountPositions'; @@ -95777,8 +103963,9 @@ module.exports = class phemex extends Exchange { filled = Math.min (0, amount - remaining); } } - const timeInForce = this.parseTimeInForce (this.safeStirng (order, 'timeInForce')); + const timeInForce = this.parseTimeInForce (this.safeString (order, 'timeInForce')); const stopPrice = this.fromEp (this.safeFloat (order, 'stopPxEp', market)); + const postOnly = (timeInForce === 'PO'); return { 'info': order, 'id': id, @@ -95789,6 +103976,7 @@ module.exports = class phemex extends Exchange { 'symbol': symbol, 'type': type, 'timeInForce': timeInForce, + 'postOnly': postOnly, 'side': side, 'price': price, 'stopPrice': stopPrice, @@ -95861,6 +104049,7 @@ module.exports = class phemex extends Exchange { } const timeInForce = this.parseTimeInForce (this.safeString (order, 'timeInForce')); const stopPrice = this.safeFloat (order, 'stopPx'); + const postOnly = (timeInForce === 'PO'); return { 'info': order, 'id': id, @@ -95871,6 +104060,7 @@ module.exports = class phemex extends Exchange { 'symbol': symbol, 'type': type, 'timeInForce': timeInForce, + 'postOnly': postOnly, 'side': side, 'price': price, 'stopPrice': stopPrice, @@ -95926,8 +104116,10 @@ module.exports = class phemex extends Exchange { }; if (market['spot']) { let qtyType = this.safeValue (params, 'qtyType', 'ByBase'); - if (price !== undefined) { - qtyType = 'ByQuote'; + if ((type === 'Market') || (type === 'Stop') || (type === 'MarketIfTouched')) { + if (price !== undefined) { + qtyType = 'ByQuote'; + } } request['qtyType'] = qtyType; if (qtyType === 'ByQuote') { @@ -95937,7 +104129,7 @@ module.exports = class phemex extends Exchange { if (price !== undefined) { cost = amount * price; } else if (cost === undefined) { - throw new ArgumentsRequired (this.id + ' createOrder ' + qtyType + ' requires a price argument or a cost parameter'); + throw new ArgumentsRequired (this.id + ' createOrder() ' + qtyType + ' requires a price argument or a cost parameter'); } } cost = (cost === undefined) ? amount : cost; @@ -96040,7 +104232,7 @@ module.exports = class phemex extends Exchange { async cancelOrder (id, symbol = undefined, params = {}) { if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' cancelOrder requires a symbol argument'); + throw new ArgumentsRequired (this.id + ' cancelOrder() requires a symbol argument'); } await this.loadMarkets (); const market = this.market (symbol); @@ -96080,7 +104272,7 @@ module.exports = class phemex extends Exchange { async fetchOrder (id, symbol = undefined, params = {}) { if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' fetchOrder requires a symbol argument'); + throw new ArgumentsRequired (this.id + ' fetchOrder() requires a symbol argument'); } await this.loadMarkets (); const market = this.market (symbol); @@ -96114,7 +104306,7 @@ module.exports = class phemex extends Exchange { async fetchOrders (symbol = undefined, since = undefined, limit = undefined, params = {}) { if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' fetchOrders requires a symbol argument'); + throw new ArgumentsRequired (this.id + ' fetchOrders() requires a symbol argument'); } await this.loadMarkets (); const market = this.market (symbol); @@ -96136,7 +104328,7 @@ module.exports = class phemex extends Exchange { async fetchOpenOrders (symbol = undefined, since = undefined, limit = undefined, params = {}) { if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' fetchOpenOrders requires a symbol argument'); + throw new ArgumentsRequired (this.id + ' fetchOpenOrders() requires a symbol argument'); } await this.loadMarkets (); const market = this.market (symbol); @@ -96160,7 +104352,7 @@ module.exports = class phemex extends Exchange { async fetchClosedOrders (symbol = undefined, since = undefined, limit = undefined, params = {}) { if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' fetchClosedOrders requires a symbol argument'); + throw new ArgumentsRequired (this.id + ' fetchClosedOrders() requires a symbol argument'); } await this.loadMarkets (); const market = this.market (symbol); @@ -96222,7 +104414,7 @@ module.exports = class phemex extends Exchange { async fetchMyTrades (symbol = undefined, since = undefined, limit = undefined, params = {}) { if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' fetchClosedOrders requires a symbol argument'); + throw new ArgumentsRequired (this.id + ' fetchClosedOrders() requires a symbol argument'); } await this.loadMarkets (); const market = this.market (symbol); @@ -96457,7 +104649,7 @@ module.exports = class phemex extends Exchange { const currencyId = this.safeString (transaction, 'currency'); currency = this.safeCurrency (currencyId, currency); const code = currency['code']; - const timestamp = this.safeInteger (transaction, 'createdAt'); + const timestamp = this.safeInteger2 (transaction, 'createdAt', 'submitedAt'); let type = this.safeStringLower (transaction, 'type'); const feeCost = this.fromEn (this.safeFloat (transaction, 'feeEv'), currency['valueScale'], currency['precision']); let fee = undefined; @@ -96644,7 +104836,7 @@ module.exports = class phemex extends Exchange { } }; -},{"./base/Exchange":5,"./base/errors":7,"./base/functions/number":13}],117:[function(require,module,exports){ +},{"./base/Exchange":6,"./base/errors":8,"./base/functions/number":14}],120:[function(require,module,exports){ 'use strict'; // --------------------------------------------------------------------------- @@ -96851,7 +105043,6 @@ module.exports = class poloniex extends Exchange { 'Error pulling ': ExchangeError, // {"error":"Error pulling order book"} }, }, - 'orders': {}, // orders cache / emulation }); } @@ -97570,6 +105761,7 @@ module.exports = class poloniex extends Exchange { 'symbol': symbol, 'type': type, 'timeInForce': undefined, + 'postOnly': undefined, 'side': side, 'price': price, 'stopPrice': undefined, @@ -98131,7 +106323,7 @@ module.exports = class poloniex extends Exchange { } }; -},{"./base/Exchange":5,"./base/errors":7}],118:[function(require,module,exports){ +},{"./base/Exchange":6,"./base/errors":8}],121:[function(require,module,exports){ 'use strict'; // --------------------------------------------------------------------------- @@ -98255,6 +106447,7 @@ module.exports = class probit extends Exchange { 'RATE_LIMIT_EXCEEDED': RateLimitExceeded, // You are sending requests too frequently. Please try it later. 'MARKET_UNAVAILABLE': ExchangeNotAvailable, // Market is closed today 'INVALID_MARKET': BadSymbol, // Requested market is not exist + 'MARKET_CLOSED': BadSymbol, // {"errorCode":"MARKET_CLOSED"} 'INVALID_CURRENCY': BadRequest, // Requested currency is not exist on ProBit system 'TOO_MANY_OPEN_ORDERS': DDoSProtection, // Too many open orders 'DUPLICATE_ADDRESS': InvalidAddress, // Address already exists in withdrawal address list @@ -98276,6 +106469,7 @@ module.exports = class probit extends Exchange { 'BTCBEAR': 'BEAR', 'BTCBULL': 'BULL', 'CBC': 'CryptoBharatCoin', + 'HBC': 'Hybrid Bank Cash', 'UNI': 'UNICORN Token', }, }); @@ -98433,7 +106627,18 @@ module.exports = class probit extends Exchange { const withdrawalSuspended = this.safeValue (platform, 'withdrawal_suspended'); const active = !(depositSuspended && withdrawalSuspended); const withdrawalFees = this.safeValue (platform, 'withdrawal_fee', {}); - const withdrawalFeesByPriority = this.sortBy (withdrawalFees, 'priority'); + const fees = []; + // sometimes the withdrawal fee is an empty object + // [ { 'amount': '0.015', 'priority': 1, 'currency_id': 'ETH' }, {} ] + for (let j = 0; j < withdrawalFees.length; j++) { + const withdrawalFee = withdrawalFees[j]; + const amount = this.safeFloat (withdrawalFee, 'amount'); + const priority = this.safeInteger (withdrawalFee, 'priority'); + if ((amount !== undefined) && (priority !== undefined)) { + fees.push (withdrawalFee); + } + } + const withdrawalFeesByPriority = this.sortBy (fees, 'priority'); const withdrawalFee = this.safeValue (withdrawalFeesByPriority, 0, {}); const fee = this.safeFloat (withdrawalFee, 'amount'); result[code] = { @@ -98863,7 +107068,7 @@ module.exports = class probit extends Exchange { let endTime = now; if (since === undefined) { if (limit === undefined) { - throw new ArgumentsRequired (this.id + ' fetchOHLCV requires either a since argument or a limit argument'); + throw new ArgumentsRequired (this.id + ' fetchOHLCV() requires either a since argument or a limit argument'); } else { startTime = now - limit * duration * 1000; } @@ -98963,7 +107168,7 @@ module.exports = class probit extends Exchange { async fetchOrder (id, symbol = undefined, params = {}) { if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' fetchOrder requires a symbol argument'); + throw new ArgumentsRequired (this.id + ' fetchOrder() requires a symbol argument'); } await this.loadMarkets (); const market = this.market (symbol); @@ -99156,7 +107361,7 @@ module.exports = class probit extends Exchange { async cancelOrder (id, symbol = undefined, params = {}) { if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' cancelOrder requires a symbol argument'); + throw new ArgumentsRequired (this.id + ' cancelOrder() requires a symbol argument'); } await this.loadMarkets (); const market = this.market (symbol); @@ -99404,7 +107609,7 @@ module.exports = class probit extends Exchange { } }; -},{"./base/Exchange":5,"./base/errors":7,"./base/functions/number":13}],119:[function(require,module,exports){ +},{"./base/Exchange":6,"./base/errors":8,"./base/functions/number":14}],122:[function(require,module,exports){ 'use strict'; // --------------------------------------------------------------------------- @@ -100322,6 +108527,7 @@ module.exports = class qtrade extends Exchange { 'symbol': symbol, 'type': orderType, 'timeInForce': undefined, + 'postOnly': undefined, 'side': side, 'price': price, 'stopPrice': undefined, @@ -100946,7 +109152,7 @@ module.exports = class qtrade extends Exchange { } }; -},{"./base/Exchange":5,"./base/errors":7}],120:[function(require,module,exports){ +},{"./base/Exchange":6,"./base/errors":8}],123:[function(require,module,exports){ 'use strict'; const Exchange = require ('./base/Exchange'); @@ -101380,7 +109586,7 @@ module.exports = class rightbtc extends Exchange { async cancelOrder (id, symbol = undefined, params = {}) { if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' cancelOrder requires a symbol argument'); + throw new ArgumentsRequired (this.id + ' cancelOrder() requires a symbol argument'); } await this.loadMarkets (); const market = this.market (symbol); @@ -101490,6 +109696,7 @@ module.exports = class rightbtc extends Exchange { 'symbol': symbol, 'type': type, 'timeInForce': undefined, + 'postOnly': undefined, 'side': side, 'price': price, 'stopPrice': undefined, @@ -101506,7 +109713,7 @@ module.exports = class rightbtc extends Exchange { async fetchOrder (id, symbol = undefined, params = {}) { if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' fetchOrder requires a symbol argument'); + throw new ArgumentsRequired (this.id + ' fetchOrder() requires a symbol argument'); } await this.loadMarkets (); const market = this.market (symbol); @@ -101544,7 +109751,7 @@ module.exports = class rightbtc extends Exchange { async fetchOpenOrders (symbol = undefined, since = undefined, limit = undefined, params = {}) { if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' fetchOpenOrders requires a symbol argument'); + throw new ArgumentsRequired (this.id + ' fetchOpenOrders() requires a symbol argument'); } await this.loadMarkets (); const market = this.market (symbol); @@ -101581,7 +109788,7 @@ module.exports = class rightbtc extends Exchange { async fetchOrders (symbol = undefined, since = undefined, limit = undefined, params = {}) { let ids = this.safeString (params, 'ids'); if ((symbol === undefined) || (ids === undefined)) { - throw new ArgumentsRequired (this.id + " fetchOrders requires a 'symbol' argument and an extra 'ids' parameter. The 'ids' should be an array or a string of one or more order ids separated with slashes."); // eslint-disable-line quotes + throw new ArgumentsRequired (this.id + " fetchOrders() requires a 'symbol' argument and an extra 'ids' parameter. The 'ids' should be an array or a string of one or more order ids separated with slashes."); // eslint-disable-line quotes } if (Array.isArray (ids)) { ids = ids.join ('/'); @@ -101620,7 +109827,7 @@ module.exports = class rightbtc extends Exchange { async fetchMyTrades (symbol = undefined, since = undefined, limit = undefined, params = {}) { if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' fetchMyTrades requires a symbol argument'); + throw new ArgumentsRequired (this.id + ' fetchMyTrades() requires a symbol argument'); } await this.loadMarkets (); const market = this.market (symbol); @@ -101705,7 +109912,7 @@ module.exports = class rightbtc extends Exchange { } }; -},{"./base/Exchange":5,"./base/errors":7,"./base/functions/number":13}],121:[function(require,module,exports){ +},{"./base/Exchange":6,"./base/errors":8,"./base/functions/number":14}],124:[function(require,module,exports){ 'use strict'; // --------------------------------------------------------------------------- @@ -102538,6 +110745,7 @@ module.exports = class ripio extends Exchange { 'symbol': symbol, 'type': type, 'timeInForce': undefined, + 'postOnly': undefined, 'side': side, 'price': price, 'stopPrice': stopPrice, @@ -102652,7 +110860,7 @@ module.exports = class ripio extends Exchange { } }; -},{"./base/Exchange":5,"./base/errors":7,"./base/functions/number":13}],122:[function(require,module,exports){ +},{"./base/Exchange":6,"./base/errors":8,"./base/functions/number":14}],125:[function(require,module,exports){ 'use strict'; // --------------------------------------------------------------------------- @@ -102919,6 +111127,7 @@ module.exports = class southxchange extends Exchange { 'symbol': symbol, 'type': type, 'timeInForce': undefined, + 'postOnly': undefined, 'side': side, 'price': price, 'stopPrice': undefined, @@ -103351,7 +111560,7 @@ module.exports = class southxchange extends Exchange { } }; -},{"./base/Exchange":5,"./base/errors":7}],123:[function(require,module,exports){ +},{"./base/Exchange":6,"./base/errors":8}],126:[function(require,module,exports){ (function (module, exports) { 'use strict'; @@ -106879,7 +115088,7 @@ module.exports = class southxchange extends Exchange { }; })(typeof module === 'undefined' || module, this); -},{"buffer":185}],124:[function(require,module,exports){ +},{"buffer":188}],127:[function(require,module,exports){ ;(function (root, factory) { if (typeof exports === "object") { // CommonJS @@ -112868,7 +121077,7 @@ module.exports = class southxchange extends Exchange { return CryptoJS; })); -},{}],125:[function(require,module,exports){ +},{}],128:[function(require,module,exports){ 'use strict'; var elliptic = exports; @@ -112892,7 +121101,7 @@ elliptic.curves = require('./elliptic/curves'); elliptic.ec = require('./elliptic/ec'); elliptic.eddsa = require('./elliptic/eddsa'); -},{"./elliptic/curve":128,"./elliptic/curves":131,"./elliptic/ec":132,"./elliptic/eddsa":135,"./elliptic/utils":139}],126:[function(require,module,exports){ +},{"./elliptic/curve":131,"./elliptic/curves":134,"./elliptic/ec":135,"./elliptic/eddsa":138,"./elliptic/utils":142}],129:[function(require,module,exports){ 'use strict'; var BN = require('../../../../BN/bn'); @@ -113269,7 +121478,7 @@ BasePoint.prototype.dblp = function dblp(k) { return r; }; -},{"../../../../BN/bn":123,"../../elliptic":125}],127:[function(require,module,exports){ +},{"../../../../BN/bn":126,"../../elliptic":128}],130:[function(require,module,exports){ 'use strict'; var curve = require('../curve'); @@ -113704,7 +121913,7 @@ Point.prototype.eqXToP = function eqXToP(x) { Point.prototype.toP = Point.prototype.normalize; Point.prototype.mixedAdd = Point.prototype.add; -},{"../../../../BN/bn":123,"../../elliptic":125,"../curve":128}],128:[function(require,module,exports){ +},{"../../../../BN/bn":126,"../../elliptic":128,"../curve":131}],131:[function(require,module,exports){ 'use strict'; var curve = exports; @@ -113714,7 +121923,7 @@ curve.short = require('./short'); curve.mont = require('./mont'); curve.edwards = require('./edwards'); -},{"./base":126,"./edwards":127,"./mont":129,"./short":130}],129:[function(require,module,exports){ +},{"./base":129,"./edwards":130,"./mont":132,"./short":133}],132:[function(require,module,exports){ 'use strict'; var curve = require('../curve'); @@ -113896,7 +122105,7 @@ Point.prototype.getX = function getX() { return this.x.fromRed(); }; -},{"../../../../BN/bn":123,"../../elliptic":125,"../curve":128}],130:[function(require,module,exports){ +},{"../../../../BN/bn":126,"../../elliptic":128,"../curve":131}],133:[function(require,module,exports){ 'use strict'; var curve = require('../curve'); @@ -114836,7 +123045,7 @@ JPoint.prototype.isInfinity = function isInfinity() { return this.z.cmpn(0) === 0; }; -},{"../../../../BN/bn":123,"../../elliptic":125,"../curve":128}],131:[function(require,module,exports){ +},{"../../../../BN/bn":126,"../../elliptic":128,"../curve":131}],134:[function(require,module,exports){ 'use strict'; var curves = exports; @@ -115042,7 +123251,7 @@ defineCurve('secp256k1', { ] }); -},{"../elliptic":125,"./precomputed/secp256k1":138}],132:[function(require,module,exports){ +},{"../elliptic":128,"./precomputed/secp256k1":141}],135:[function(require,module,exports){ 'use strict'; var BN = require('../../../../BN/bn'); @@ -115284,7 +123493,7 @@ EC.prototype.getKeyRecoveryParam = function(e, signature, Q, enc) { throw new Error('Unable to find valid recovery factor'); }; -},{"../../../../BN/bn":123,"../../elliptic":125,"../../hmac-drbg/hmac-drbg":140,"./key":133,"./signature":134}],133:[function(require,module,exports){ +},{"../../../../BN/bn":126,"../../elliptic":128,"../../hmac-drbg/hmac-drbg":143,"./key":136,"./signature":137}],136:[function(require,module,exports){ 'use strict'; var BN = require('../../../../BN/bn'); @@ -115405,7 +123614,7 @@ KeyPair.prototype.inspect = function inspect() { ' pub: ' + (this.pub && this.pub.inspect()) + ' >'; }; -},{"../../../../BN/bn":123,"../../elliptic":125}],134:[function(require,module,exports){ +},{"../../../../BN/bn":126,"../../elliptic":128}],137:[function(require,module,exports){ 'use strict'; var BN = require('../../../../BN/bn'); @@ -115431,7 +123640,7 @@ function Signature(options, enc) { } module.exports = Signature; -},{"../../../../BN/bn":123,"../../elliptic":125}],135:[function(require,module,exports){ +},{"../../../../BN/bn":126,"../../elliptic":128}],138:[function(require,module,exports){ 'use strict'; var curves = require('../curves'); @@ -115578,7 +123787,7 @@ EDDSA.prototype.isPoint = function isPoint(val) { return val instanceof this.pointClass; }; -},{"../../../../../base/functions/encode":10,"../../../../BN/bn.js":123,"../../../../crypto-js/crypto-js":124,"../curves":131,"../utils":139,"./key":136,"./signature":137}],136:[function(require,module,exports){ +},{"../../../../../base/functions/encode":11,"../../../../BN/bn.js":126,"../../../../crypto-js/crypto-js":127,"../curves":134,"../utils":142,"./key":139,"./signature":140}],139:[function(require,module,exports){ 'use strict'; var utils = require('../utils'); @@ -115680,7 +123889,7 @@ KeyPair.prototype.getPublic = function getPublic(enc) { module.exports = KeyPair; -},{"../utils":139}],137:[function(require,module,exports){ +},{"../utils":142}],140:[function(require,module,exports){ 'use strict'; var BN = require('../../../../BN/bn'); @@ -115747,7 +123956,7 @@ Signature.prototype.toHex = function toHex() { module.exports = Signature; -},{"../../../../BN/bn":123,"../utils":139}],138:[function(require,module,exports){ +},{"../../../../BN/bn":126,"../utils":142}],141:[function(require,module,exports){ module.exports = { doubles: { step: 4, @@ -116529,7 +124738,7 @@ module.exports = { } }; -},{}],139:[function(require,module,exports){ +},{}],142:[function(require,module,exports){ 'use strict'; var utils = exports; @@ -116745,7 +124954,7 @@ utils.encode = function encode(arr, enc) { return arr; }; -},{"../../../BN/bn":123}],140:[function(require,module,exports){ +},{"../../../BN/bn":126}],143:[function(require,module,exports){ 'use strict'; var CryptoJS = require('../../../crypto-js/crypto-js'); @@ -116861,7 +125070,7 @@ HmacDRBG.prototype.generate = function generate(len, enc, add, addEnc) { return utils.wordArrayToBuffer(res); }; -},{"../../../../base/functions/encode":10,"../../../crypto-js/crypto-js":124,"../elliptic/utils":139}],141:[function(require,module,exports){ +},{"../../../../base/functions/encode":11,"../../../crypto-js/crypto-js":127,"../elliptic/utils":142}],144:[function(require,module,exports){ 'use strict'; var fetch = require('../node-fetch/index'); @@ -116902,7 +125111,7 @@ module.exports = function (context) { }; }; -},{"../node-fetch/index":142}],142:[function(require,module,exports){ +},{"../node-fetch/index":145}],145:[function(require,module,exports){ (function (global,Buffer){ 'use strict'; @@ -118470,7 +126679,7 @@ exports.Response = Response; exports.FetchError = FetchError; }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {},require("buffer").Buffer) -},{"buffer":185,"http":227,"https":190,"stream":226,"url":233,"zlib":184}],143:[function(require,module,exports){ +},{"buffer":188,"http":230,"https":193,"stream":229,"url":236,"zlib":187}],146:[function(require,module,exports){ (function (Buffer){ /*! * RSA library for Node.js @@ -118697,7 +126906,7 @@ module.exports = (function () { })(); }).call(this,require("buffer").Buffer) -},{"./formats/formats.js":150,"./libs/rsa.js":154,"./schemes/schemes.js":156,"./utils":157,"buffer":185}],144:[function(require,module,exports){ +},{"./formats/formats.js":153,"./libs/rsa.js":157,"./schemes/schemes.js":159,"./utils":160,"buffer":188}],147:[function(require,module,exports){ // Copyright 2011 Mark Cavage All rights reserved. @@ -118712,7 +126921,7 @@ module.exports = { }; -},{}],145:[function(require,module,exports){ +},{}],148:[function(require,module,exports){ // Copyright 2011 Mark Cavage All rights reserved. var errors = require('./errors'); @@ -118735,7 +126944,7 @@ for (var e in errors) { module.exports[e] = errors[e]; } -},{"./errors":144,"./reader":146,"./types":147}],146:[function(require,module,exports){ +},{"./errors":147,"./reader":149,"./types":150}],149:[function(require,module,exports){ (function (Buffer){ // Copyright 2011 Mark Cavage All rights reserved. @@ -119001,7 +127210,7 @@ Reader.prototype._readTag = function (tag) { module.exports = Reader; }).call(this,require("buffer").Buffer) -},{"./errors":144,"./types":147,"assert":180,"buffer":185}],147:[function(require,module,exports){ +},{"./errors":147,"./types":150,"assert":183,"buffer":188}],150:[function(require,module,exports){ // Copyright 2011 Mark Cavage All rights reserved. @@ -119039,7 +127248,7 @@ module.exports = { Context: 128 }; -},{}],148:[function(require,module,exports){ +},{}],151:[function(require,module,exports){ // Copyright 2011 Mark Cavage All rights reserved. // If you have no idea what ASN.1 or BER is, see this: @@ -119058,7 +127267,7 @@ module.exports = { BerReader: Ber.Reader, }; -},{"./ber/index":145}],149:[function(require,module,exports){ +},{"./ber/index":148}],152:[function(require,module,exports){ var _ = require('../utils')._; var utils = require('../utils'); @@ -119131,7 +127340,7 @@ module.exports = { } }; -},{"../utils":157}],150:[function(require,module,exports){ +},{"../utils":160}],153:[function(require,module,exports){ var _ = require('../utils')._; module.exports = { @@ -119164,7 +127373,7 @@ module.exports = { }, }; -},{"../utils":157,"./components":149,"./pkcs1":151,"./pkcs8":152}],151:[function(require,module,exports){ +},{"../utils":160,"./components":152,"./pkcs1":154,"./pkcs8":155}],154:[function(require,module,exports){ (function (Buffer){ var ber = require('../asn1/index').Ber; var _ = require('../utils')._; @@ -119316,7 +127525,7 @@ module.exports = { }; }).call(this,require("buffer").Buffer) -},{"../asn1/index":148,"../utils":157,"buffer":185}],152:[function(require,module,exports){ +},{"../asn1/index":151,"../utils":160,"buffer":188}],155:[function(require,module,exports){ (function (Buffer){ var ber = require('../asn1/index').Ber; var _ = require('../utils')._; @@ -119507,7 +127716,7 @@ module.exports = { }; }).call(this,require("buffer").Buffer) -},{"../asn1/index":148,"../utils":157,"buffer":185}],153:[function(require,module,exports){ +},{"../asn1/index":151,"../utils":160,"buffer":188}],156:[function(require,module,exports){ (function (Buffer){ /* * Basic JavaScript BN library - subset useful for RSA encryption. @@ -120763,7 +128972,7 @@ BigInteger.prototype.square = bnSquare; module.exports = BigInteger; }).call(this,require("buffer").Buffer) -},{"../utils":157,"buffer":185}],154:[function(require,module,exports){ +},{"../utils":160,"buffer":188}],157:[function(require,module,exports){ /* * RSA Encryption / Decryption with PKCS1 v2 Padding. * @@ -120912,7 +129121,7 @@ module.exports.Key = (function () { })(); -},{"../schemes/schemes.js":156,"../utils":157,"../utils.js":157,"./jsbn.js":153}],155:[function(require,module,exports){ +},{"../schemes/schemes.js":159,"../utils":160,"../utils.js":160,"./jsbn.js":156}],158:[function(require,module,exports){ (function (Buffer){ /** * PKCS1 padding and signature scheme @@ -121092,7 +129301,7 @@ function wordArrayToBuffer(wordArray) { } }).call(this,require("buffer").Buffer) -},{"../../crypto-js/crypto-js":124,"../libs/jsbn":153,"buffer":185,"constants":187}],156:[function(require,module,exports){ +},{"../../crypto-js/crypto-js":127,"../libs/jsbn":156,"buffer":188,"constants":190}],159:[function(require,module,exports){ module.exports = { pkcs1: require('./pkcs1'), @@ -121115,7 +129324,7 @@ module.exports = { } }; -},{"./pkcs1":155}],157:[function(require,module,exports){ +},{"./pkcs1":158}],160:[function(require,module,exports){ /* * Utils functions * @@ -121215,7 +129424,7 @@ module.exports.trimSurroundingText = function (data, opening, closing) { return data.substring(trimStartIndex, trimEndIndex); } -},{}],158:[function(require,module,exports){ +},{}],161:[function(require,module,exports){ 'use strict'; var replace = String.prototype.replace; @@ -121235,7 +129444,7 @@ module.exports = { RFC3986: 'RFC3986' }; -},{}],159:[function(require,module,exports){ +},{}],162:[function(require,module,exports){ 'use strict'; var stringify = require('./stringify'); @@ -121248,7 +129457,7 @@ module.exports = { stringify: stringify }; -},{"./formats":158,"./parse":160,"./stringify":161}],160:[function(require,module,exports){ +},{"./formats":161,"./parse":163,"./stringify":164}],163:[function(require,module,exports){ 'use strict'; var utils = require('./utils'); @@ -121492,7 +129701,7 @@ module.exports = function (str, opts) { return utils.compact(obj); }; -},{"./utils":162}],161:[function(require,module,exports){ +},{"./utils":165}],164:[function(require,module,exports){ 'use strict'; var utils = require('./utils'); @@ -121763,7 +129972,7 @@ module.exports = function (object, opts) { return joined.length > 0 ? prefix + joined : ''; }; -},{"./formats":158,"./utils":162}],162:[function(require,module,exports){ +},{"./formats":161,"./utils":165}],165:[function(require,module,exports){ 'use strict'; var has = Object.prototype.hasOwnProperty; @@ -121995,7 +130204,7 @@ module.exports = { merge: merge }; -},{}],163:[function(require,module,exports){ +},{}],166:[function(require,module,exports){ 'use strict'; // --------------------------------------------------------------------------- @@ -122183,6 +130392,8 @@ module.exports = class stex extends Exchange { 'BITS': 'Bitcoinus', 'BITSW': 'BITS', 'BHD': 'Bithold', + 'BTH': 'Bithereum', + 'SBTC': 'SBTCT', // SiamBitcoin }, 'options': { 'parseOrderToPrecision': false, @@ -122924,6 +131135,7 @@ module.exports = class stex extends Exchange { 'symbol': symbol, 'type': type, 'timeInForce': undefined, + 'postOnly': undefined, 'side': side, 'price': price, 'stopPrice': stopPrice, @@ -123220,7 +131432,7 @@ module.exports = class stex extends Exchange { async fetchMyTrades (symbol = undefined, since = undefined, limit = undefined, params = {}) { if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' fetchMyTrades requires a symbol argument'); + throw new ArgumentsRequired (this.id + ' fetchMyTrades() requires a symbol argument'); } await this.loadMarkets (); const market = this.market (symbol); @@ -123799,7 +132011,7 @@ module.exports = class stex extends Exchange { } }; -},{"./base/Exchange":5,"./base/errors":7}],164:[function(require,module,exports){ +},{"./base/Exchange":6,"./base/errors":8}],167:[function(require,module,exports){ 'use strict'; // --------------------------------------------------------------------------- @@ -123833,7 +132045,7 @@ module.exports = class surbitcoin extends foxbit { } }; -},{"./foxbit.js":84}],165:[function(require,module,exports){ +},{"./foxbit.js":87}],168:[function(require,module,exports){ 'use strict'; // --------------------------------------------------------------------------- @@ -124801,6 +133013,7 @@ module.exports = class therock extends Exchange { 'symbol': symbol, 'type': type, 'timeInForce': undefined, + 'postOnly': undefined, 'side': side, 'price': price, 'stopPrice': stopPrice, @@ -124830,7 +133043,7 @@ module.exports = class therock extends Exchange { async fetchOrders (symbol = undefined, since = undefined, limit = undefined, params = {}) { if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' fetchOrders requires a symbol argument'); + throw new ArgumentsRequired (this.id + ' fetchOrders() requires a symbol argument'); } await this.loadMarkets (); const market = this.market (symbol); @@ -124875,7 +133088,7 @@ module.exports = class therock extends Exchange { async fetchOrder (id, symbol = undefined, params = {}) { if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' fetchOrder requires a symbol argument'); + throw new ArgumentsRequired (this.id + ' fetchOrder() requires a symbol argument'); } await this.loadMarkets (); const market = this.market (symbol); @@ -124914,7 +133127,7 @@ module.exports = class therock extends Exchange { async fetchMyTrades (symbol = undefined, since = undefined, limit = undefined, params = {}) { if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' fetchMyTrades requires a symbol argument'); + throw new ArgumentsRequired (this.id + ' fetchMyTrades() requires a symbol argument'); } await this.loadMarkets (); const market = this.market (symbol); @@ -125066,7 +133279,7 @@ module.exports = class therock extends Exchange { } }; -},{"./base/Exchange":5,"./base/errors":7}],166:[function(require,module,exports){ +},{"./base/Exchange":6,"./base/errors":8}],169:[function(require,module,exports){ 'use strict'; // --------------------------------------------------------------------------- @@ -125491,6 +133704,7 @@ module.exports = class tidebit extends Exchange { 'symbol': symbol, 'type': type, 'timeInForce': undefined, + 'postOnly': undefined, 'side': side, 'price': price, 'stopPrice': undefined, @@ -125610,7 +133824,7 @@ module.exports = class tidebit extends Exchange { } }; -},{"./base/Exchange":5,"./base/errors":7}],167:[function(require,module,exports){ +},{"./base/Exchange":6,"./base/errors":8}],170:[function(require,module,exports){ 'use strict'; const Exchange = require ('./base/Exchange'); @@ -126193,6 +134407,7 @@ module.exports = class tidex extends Exchange { 'lastTradeTimestamp': undefined, 'type': 'limit', 'timeInForce': undefined, + 'postOnly': undefined, 'side': this.safeString (order, 'type'), 'price': price, 'stopPrice': undefined, @@ -126394,7 +134609,7 @@ module.exports = class tidex extends Exchange { } }; -},{"./base/Exchange":5,"./base/errors":7}],168:[function(require,module,exports){ +},{"./base/Exchange":6,"./base/errors":8}],171:[function(require,module,exports){ 'use strict'; const Exchange = require ('./base/Exchange'); @@ -126857,16 +135072,19 @@ module.exports = class timex extends Exchange { async createOrder (symbol, type, side, amount, price = undefined, params = {}) { await this.loadMarkets (); const market = this.market (symbol); + const uppercaseSide = side.toUpperCase (); + const uppercaseType = type.toUpperCase (); const request = { 'symbol': market['id'], 'quantity': this.amountToPrecision (symbol, amount), - 'side': side.toUpperCase (), + 'side': uppercaseSide, + 'orderTypes': uppercaseType, // 'clientOrderId': '123', // 'expireIn': 1575523308, // in seconds // 'expireTime': 1575523308, // unix timestamp }; let query = params; - if (type === 'limit') { + if (uppercaseType === 'LIMIT') { request['price'] = this.priceToPrecision (symbol, price); const defaultExpireIn = this.safeInteger (this.options, 'expireIn'); const expireTime = this.safeValue (params, 'expireTime'); @@ -126876,7 +135094,7 @@ module.exports = class timex extends Exchange { } else if (expireIn !== undefined) { request['expireIn'] = expireIn; } else { - throw new InvalidOrder (this.id + ' createOrder method requires a expireTime or expireIn param for a ' + type + ' order, you can also set the expireIn exchange-wide option'); + throw new InvalidOrder (this.id + ' createOrder() method requires a expireTime or expireIn param for a ' + type + ' order, you can also set the expireIn exchange-wide option'); } query = this.omit (params, [ 'expireTime', 'expireIn' ]); } else { @@ -127579,6 +135797,7 @@ module.exports = class timex extends Exchange { 'symbol': symbol, 'type': type, 'timeInForce': undefined, + 'postOnly': undefined, 'side': side, 'price': price, 'stopPrice': undefined, @@ -127631,7 +135850,7 @@ module.exports = class timex extends Exchange { } }; -},{"./base/Exchange":5,"./base/errors":7}],169:[function(require,module,exports){ +},{"./base/Exchange":6,"./base/errors":8}],172:[function(require,module,exports){ 'use strict'; // --------------------------------------------------------------------------- @@ -127649,7 +135868,6 @@ module.exports = class upbit extends Exchange { 'countries': [ 'KR' ], 'version': 'v1', 'rateLimit': 1000, - 'certified': true, 'pro': true, // new metainfo interface 'has': { @@ -127855,7 +136073,7 @@ module.exports = class upbit extends Exchange { const walletLocked = this.safeValue (memberInfo, 'wallet_locked'); const locked = this.safeValue (memberInfo, 'locked'); let active = true; - if ((canWithdraw !== undefined) && canWithdraw) { + if ((canWithdraw !== undefined) && !canWithdraw) { active = false; } else if (walletState !== 'working') { active = false; @@ -128838,6 +137056,7 @@ module.exports = class upbit extends Exchange { 'symbol': market['symbol'], 'type': type, 'timeInForce': undefined, + 'postOnly': undefined, 'side': side, 'price': price, 'stopPrice': undefined, @@ -129162,7 +137381,7 @@ module.exports = class upbit extends Exchange { } }; -},{"./base/Exchange":5,"./base/errors":7}],170:[function(require,module,exports){ +},{"./base/Exchange":6,"./base/errors":8}],173:[function(require,module,exports){ 'use strict'; // --------------------------------------------------------------------------- @@ -129367,7 +137586,7 @@ module.exports = class vaultoro extends Exchange { } }; -},{"./base/Exchange":5}],171:[function(require,module,exports){ +},{"./base/Exchange":6}],174:[function(require,module,exports){ 'use strict'; // --------------------------------------------------------------------------- @@ -129401,7 +137620,7 @@ module.exports = class vbtc extends foxbit { } }; -},{"./foxbit.js":84}],172:[function(require,module,exports){ +},{"./foxbit.js":87}],175:[function(require,module,exports){ 'use strict'; // --------------------------------------------------------------------------- @@ -130460,6 +138679,7 @@ module.exports = class vcc extends Exchange { 'symbol': symbol, 'type': type, 'timeInForce': undefined, + 'postOnly': undefined, 'side': side, 'price': price, 'stopPrice': stopPrice, @@ -130741,7 +138961,7 @@ module.exports = class vcc extends Exchange { } }; -},{"./base/Exchange":5,"./base/errors":7,"./base/functions/number":13}],173:[function(require,module,exports){ +},{"./base/Exchange":6,"./base/errors":8,"./base/functions/number":14}],176:[function(require,module,exports){ 'use strict'; // --------------------------------------------------------------------------- @@ -131800,7 +140020,7 @@ module.exports = class wavesexchange extends Exchange { this.checkRequiredDependencies (); this.checkRequiredKeys (); if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' fetchOrders requires symbol argument'); + throw new ArgumentsRequired (this.id + ' fetchOrders() requires symbol argument'); } await this.loadMarkets (); const market = this.market (symbol); @@ -132013,6 +140233,7 @@ module.exports = class wavesexchange extends Exchange { 'symbol': symbol, 'type': type, 'timeInForce': undefined, + 'postOnly': undefined, 'side': side, 'price': price, 'stopPrice': undefined, @@ -132409,7 +140630,7 @@ module.exports = class wavesexchange extends Exchange { } }; -},{"./base/Exchange":5,"./base/errors":7}],174:[function(require,module,exports){ +},{"./base/Exchange":6,"./base/errors":8}],177:[function(require,module,exports){ 'use strict'; // --------------------------------------------------------------------------- @@ -133064,7 +141285,7 @@ module.exports = class whitebit extends Exchange { } }; -},{"./base/Exchange":5,"./base/errors":7}],175:[function(require,module,exports){ +},{"./base/Exchange":6,"./base/errors":8}],178:[function(require,module,exports){ 'use strict'; // --------------------------------------------------------------------------- @@ -133436,7 +141657,7 @@ module.exports = class xbtce extends Exchange { } }; -},{"./base/Exchange":5,"./base/errors":7}],176:[function(require,module,exports){ +},{"./base/Exchange":6,"./base/errors":8}],179:[function(require,module,exports){ 'use strict'; const Exchange = require ('./base/Exchange'); @@ -133477,6 +141698,10 @@ module.exports = class xena extends Exchange { }, 'urls': { 'logo': 'https://user-images.githubusercontent.com/51840849/87489843-bb469280-c64c-11ea-91aa-69c6326506af.jpg', + 'test': { + 'public': 'https://trading.demo.xena.io/api', + 'private': 'https://api.demo.xena.io', + }, 'api': { 'public': 'https://trading.xena.exchange/api', 'private': 'https://api.xena.exchange', @@ -134397,6 +142622,7 @@ module.exports = class xena extends Exchange { 'symbol': symbol, 'type': type, 'timeInForce': undefined, + 'postOnly': undefined, 'side': side, 'price': price, 'stopPrice': undefined, @@ -134456,14 +142682,14 @@ module.exports = class xena extends Exchange { }; if ((type === 'limit') || (type === 'stop-limit')) { if (price === undefined) { - throw new InvalidOrder (this.id + ' createOrder requires a price argument for order type ' + type); + throw new InvalidOrder (this.id + ' createOrder() requires a price argument for order type ' + type); } request['price'] = this.priceToPrecision (symbol, price); } if ((type === 'stop') || (type === 'stop-limit')) { const stopPx = this.safeFloat (params, 'stopPx'); if (stopPx === undefined) { - throw new InvalidOrder (this.id + ' createOrder requires a stopPx param for order type ' + type); + throw new InvalidOrder (this.id + ' createOrder() requires a stopPx param for order type ' + type); } request['stopPx'] = this.priceToPrecision (symbol, stopPx); params = this.omit (params, 'stopPx'); @@ -134501,7 +142727,7 @@ module.exports = class xena extends Exchange { async editOrder (id, symbol, type, side, amount = undefined, price = undefined, params = {}) { if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' cancelOrder requires a symbol argument'); + throw new ArgumentsRequired (this.id + ' cancelOrder() requires a symbol argument'); } await this.loadMarkets (); await this.loadAccounts (); @@ -134556,7 +142782,7 @@ module.exports = class xena extends Exchange { async cancelOrder (id, symbol = undefined, params = {}) { if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' cancelOrder requires a symbol argument'); + throw new ArgumentsRequired (this.id + ' cancelOrder() requires a symbol argument'); } await this.loadMarkets (); await this.loadAccounts (); @@ -135153,7 +143379,7 @@ module.exports = class xena extends Exchange { } }; -},{"./base/Exchange":5,"./base/errors":7}],177:[function(require,module,exports){ +},{"./base/Exchange":6,"./base/errors":8}],180:[function(require,module,exports){ 'use strict'; // --------------------------------------------------------------------------- @@ -135289,6 +143515,7 @@ module.exports = class yobit extends Exchange { 'LOCX': 'LOC', 'LUNYR': 'LUN', 'LUN': 'LunarCoin', // they just change the ticker if it is already taken + 'MASK': 'Yobit MASK', 'MDT': 'Midnight', 'NAV': 'NavajoCoin', 'NBT': 'NiceBytes', @@ -135305,6 +143532,7 @@ module.exports = class yobit extends Exchange { 'RCN': 'RCoin', 'REP': 'Republicoin', 'RUR': 'RUB', + 'SBTC': 'Super Bitcoin', 'TTC': 'TittieCoin', 'UNI': 'Universe', 'UST': 'Uservice', @@ -135751,6 +143979,7 @@ module.exports = class yobit extends Exchange { 'lastTradeTimestamp': undefined, 'type': type, 'timeInForce': undefined, + 'postOnly': undefined, 'side': side, 'price': price, 'stopPrice': undefined, @@ -135795,7 +144024,7 @@ module.exports = class yobit extends Exchange { async fetchMyTrades (symbol = undefined, since = undefined, limit = undefined, params = {}) { if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' fetchMyTrades requires a `symbol` argument'); + throw new ArgumentsRequired (this.id + ' fetchMyTrades() requires a `symbol` argument'); } await this.loadMarkets (); const market = this.market (symbol); @@ -135883,24 +144112,6 @@ module.exports = class yobit extends Exchange { }; } - calculateFee (symbol, type, side, amount, price, takerOrMaker = 'taker', params = {}) { - const market = this.markets[symbol]; - let key = 'quote'; - const rate = market[takerOrMaker]; - let cost = parseFloat (this.costToPrecision (symbol, amount * rate)); - if (side === 'sell') { - cost *= price; - } else { - key = 'base'; - } - return { - 'type': takerOrMaker, - 'currency': market[key], - 'rate': rate, - 'cost': cost, - }; - } - sign (path, api = 'public', method = 'GET', params = {}, headers = undefined, body = undefined) { let url = this.urls['api'][api]; const query = this.omit (params, this.extractParams (path)); @@ -135992,7 +144203,7 @@ module.exports = class yobit extends Exchange { } }; -},{"./base/Exchange":5,"./base/errors":7}],178:[function(require,module,exports){ +},{"./base/Exchange":6,"./base/errors":8}],181:[function(require,module,exports){ 'use strict'; // --------------------------------------------------------------------------- @@ -136352,6 +144563,7 @@ module.exports = class zaif extends Exchange { 'symbol': symbol, 'type': 'limit', 'timeInForce': undefined, + 'postOnly': undefined, 'side': side, 'price': price, 'stopPrice': undefined, @@ -136482,13 +144694,13 @@ module.exports = class zaif extends Exchange { } }; -},{"./base/Exchange":5,"./base/errors":7}],179:[function(require,module,exports){ +},{"./base/Exchange":6,"./base/errors":8}],182:[function(require,module,exports){ 'use strict'; // --------------------------------------------------------------------------- const Exchange = require ('./base/Exchange'); -const { BadRequest, ExchangeError, ArgumentsRequired, AuthenticationError, InsufficientFunds, OrderNotFound, ExchangeNotAvailable, DDoSProtection, InvalidOrder } = require ('./base/errors'); +const { BadRequest, ExchangeError, ArgumentsRequired, AuthenticationError, InsufficientFunds, OrderNotFound, ExchangeNotAvailable, DDoSProtection, InvalidOrder, InvalidAddress } = require ('./base/errors'); // --------------------------------------------------------------------------- @@ -136507,15 +144719,19 @@ module.exports = class zb extends Exchange { 'createOrder': true, 'fetchBalance': true, 'fetchDepositAddress': true, + 'fetchDepositAddresses': true, + 'fetchDeposits': true, 'fetchMarkets': true, 'fetchOHLCV': true, 'fetchOpenOrders': true, 'fetchOrder': true, 'fetchOrderBook': true, 'fetchOrders': true, + 'fetchClosedOrders': true, 'fetchTicker': true, 'fetchTickers': true, 'fetchTrades': true, + 'fetchWithdrawals': true, 'withdraw': true, }, 'timeframes': { @@ -136534,33 +144750,38 @@ module.exports = class zb extends Exchange { '1w': '1week', }, 'exceptions': { - // '1000': 'Successful operation', - '1001': ExchangeError, // 'General error message', - '1002': ExchangeError, // 'Internal error', - '1003': AuthenticationError, // 'Verification does not pass', - '1004': AuthenticationError, // 'Funding security password lock', - '1005': AuthenticationError, // 'Funds security password is incorrect, please confirm and re-enter.', - '1006': AuthenticationError, // 'Real-name certification pending approval or audit does not pass', - '1009': ExchangeNotAvailable, // 'This interface is under maintenance', - '2001': InsufficientFunds, // 'Insufficient CNY Balance', - '2002': InsufficientFunds, // 'Insufficient BTC Balance', - '2003': InsufficientFunds, // 'Insufficient LTC Balance', - '2005': InsufficientFunds, // 'Insufficient ETH Balance', - '2006': InsufficientFunds, // 'Insufficient ETC Balance', - '2007': InsufficientFunds, // 'Insufficient BTS Balance', - '2009': InsufficientFunds, // 'Account balance is not enough', - '3001': OrderNotFound, // 'Pending orders not found', - '3002': InvalidOrder, // 'Invalid price', - '3003': InvalidOrder, // 'Invalid amount', - '3004': AuthenticationError, // 'User does not exist', - '3005': BadRequest, // 'Invalid parameter', - '3006': AuthenticationError, // 'Invalid IP or inconsistent with the bound IP', - '3007': AuthenticationError, // 'The request time has expired', - '3008': OrderNotFound, // 'Transaction records not found', - '3009': InvalidOrder, // 'The price exceeds the limit', - '3011': InvalidOrder, // 'The entrusted price is abnormal, please modify it and place order again', - '4001': ExchangeNotAvailable, // 'API interface is locked or not enabled', - '4002': DDoSProtection, // 'Request too often', + 'exact': { + // '1000': 'Successful operation', + '1001': ExchangeError, // 'General error message', + '1002': ExchangeError, // 'Internal error', + '1003': AuthenticationError, // 'Verification does not pass', + '1004': AuthenticationError, // 'Funding security password lock', + '1005': AuthenticationError, // 'Funds security password is incorrect, please confirm and re-enter.', + '1006': AuthenticationError, // 'Real-name certification pending approval or audit does not pass', + '1009': ExchangeNotAvailable, // 'This interface is under maintenance', + '2001': InsufficientFunds, // 'Insufficient CNY Balance', + '2002': InsufficientFunds, // 'Insufficient BTC Balance', + '2003': InsufficientFunds, // 'Insufficient LTC Balance', + '2005': InsufficientFunds, // 'Insufficient ETH Balance', + '2006': InsufficientFunds, // 'Insufficient ETC Balance', + '2007': InsufficientFunds, // 'Insufficient BTS Balance', + '2009': InsufficientFunds, // 'Account balance is not enough', + '3001': OrderNotFound, // 'Pending orders not found', + '3002': InvalidOrder, // 'Invalid price', + '3003': InvalidOrder, // 'Invalid amount', + '3004': AuthenticationError, // 'User does not exist', + '3005': BadRequest, // 'Invalid parameter', + '3006': AuthenticationError, // 'Invalid IP or inconsistent with the bound IP', + '3007': AuthenticationError, // 'The request time has expired', + '3008': OrderNotFound, // 'Transaction records not found', + '3009': InvalidOrder, // 'The price exceeds the limit', + '3011': InvalidOrder, // 'The entrusted price is abnormal, please modify it and place order again', + '4001': ExchangeNotAvailable, // 'API interface is locked or not enabled', + '4002': DDoSProtection, // 'Request too often', + }, + 'broad': { + '提币地址有误,请先添加提币地址。': InvalidAddress, // {"code":1001,"message":"提币地址有误,请先添加提币地址。"} + }, }, 'urls': { 'logo': 'https://user-images.githubusercontent.com/1294454/32859187-cd5214f0-ca5e-11e7-967d-96568e2e2bd1.jpg', @@ -136587,20 +144808,28 @@ module.exports = class zb extends Exchange { 'get': [ // spot API 'order', + 'orderMoreV2', 'cancelOrder', 'getOrder', 'getOrders', 'getOrdersNew', 'getOrdersIgnoreTradeType', 'getUnfinishedOrdersIgnoreTradeType', + 'getFinishedAndPartialOrders', 'getAccountInfo', 'getUserAddress', + 'getPayinAddress', 'getWithdrawAddress', 'getWithdrawRecord', 'getChargeRecord', 'getCnyWithdrawRecord', 'getCnyChargeRecord', 'withdraw', + // sub accounts + 'addSubUser', + 'getSubUserList', + 'doTransferFunds', + 'createSubUserKey', // leverage API 'getLeverAssetsInfo', 'getLeverBills', @@ -136611,8 +144840,21 @@ module.exports = class zb extends Exchange { 'getLoans', 'getLoanRecords', 'borrow', + 'autoBorrow', 'repay', + 'doAllRepay', 'getRepayments', + 'getFinanceRecords', + 'changeInvestMark', + 'changeLoop', + // cross API + 'getCrossAssets', + 'getCrossBills', + 'transferInCross', + 'transferOutCross', + 'doCrossLoan', + 'doCrossRepay', + 'getCrossRepayRecords', ], }, }, @@ -136730,8 +144972,96 @@ module.exports = class zb extends Exchange { return this.parseBalance (result); } - getMarketFieldName () { - return 'market'; + parseDepositAddress (depositAddress, currency = undefined) { + // + // fetchDepositAddress + // + // { + // "key": "0x0af7f36b8f09410f3df62c81e5846da673d4d9a9" + // } + // + // fetchDepositAddresses + // + // { + // "blockChain": "btc", + // "isUseMemo": false, + // "address": "1LL5ati6pXHZnTGzHSA3rWdqi4mGGXudwM", + // "canWithdraw": true, + // "canDeposit": true + // } + // { + // "blockChain": "bts", + // "isUseMemo": true, + // "account": "btstest", + // "memo": "123", + // "canWithdraw": true, + // "canDeposit": true + // } + // + let address = this.safeString (depositAddress, 'key'); + let tag = undefined; + const memo = this.safeString (depositAddress, 'memo'); + if (memo !== undefined) { + tag = memo; + } else if (address.indexOf ('_') >= 0) { + const parts = address.split ('_'); + address = parts[0]; // WARNING: MAY BE tag_address INSTEAD OF address_tag FOR SOME CURRENCIES!! + tag = parts[1]; + } + const currencyId = this.safeString (depositAddress, 'blockChain'); + const code = this.safeCurrencyCode (currencyId, currency); + return { + 'currency': code, + 'address': address, + 'tag': tag, + 'info': depositAddress, + }; + } + + parseDepositAddresses (addresses, codes = undefined) { + let result = []; + for (let i = 0; i < addresses.length; i++) { + const address = this.parseDepositAddress (addresses[i]); + result.push (address); + } + if (codes) { + result = this.filterByArray (result, 'currency', codes); + } + return this.indexBy (result, 'currency'); + } + + async fetchDepositAddresses (codes = undefined, params = {}) { + await this.loadMarkets (); + const response = await this.privateGetGetPayinAddress (params); + // + // { + // "code": 1000, + // "message": { + // "des": "success", + // "isSuc": true, + // "datas": [ + // { + // "blockChain": "btc", + // "isUseMemo": false, + // "address": "1LL5ati6pXHZnTGzHSA3rWdqi4mGGXudwM", + // "canWithdraw": true, + // "canDeposit": true + // }, + // { + // "blockChain": "bts", + // "isUseMemo": true, + // "account": "btstest", + // "memo": "123", + // "canWithdraw": true, + // "canDeposit": true + // }, + // ] + // } + // } + // + const message = this.safeValue (response, 'message', {}); + const datas = this.safeValue (message, 'datas', []); + return this.parseDepositAddresses (datas, codes); } async fetchDepositAddress (code, params = {}) { @@ -136741,27 +145071,29 @@ module.exports = class zb extends Exchange { 'currency': currency['id'], }; const response = await this.privateGetGetUserAddress (this.extend (request, params)); - let address = response['message']['datas']['key']; - let tag = undefined; - if (address.indexOf ('_') >= 0) { - const parts = address.split ('_'); - address = parts[0]; // WARNING: MAY BE tag_address INSTEAD OF address_tag FOR SOME CURRENCIES!! - tag = parts[1]; - } - return { - 'currency': code, - 'address': address, - 'tag': tag, - 'info': response, - }; + // + // { + // "code": 1000, + // "message": { + // "des": "success", + // "isSuc": true, + // "datas": { + // "key": "0x0af7f36b8f09410f3df62c81e5846da673d4d9a9" + // } + // } + // } + // + const message = this.safeValue (response, 'message', {}); + const datas = this.safeValue (message, 'datas', {}); + return this.parseDepositAddress (datas, currency); } async fetchOrderBook (symbol, limit = undefined, params = {}) { await this.loadMarkets (); const market = this.market (symbol); - const marketFieldName = this.getMarketFieldName (); - const request = {}; - request[marketFieldName] = market['id']; + const request = { + 'market': market['id'], + }; if (limit !== undefined) { request['size'] = limit; } @@ -136790,9 +145122,9 @@ module.exports = class zb extends Exchange { async fetchTicker (symbol, params = {}) { await this.loadMarkets (); const market = this.market (symbol); - const marketFieldName = this.getMarketFieldName (); - const request = {}; - request[marketFieldName] = market['id']; + const request = { + 'market': market['id'], + }; const response = await this.publicGetTicker (this.extend (request, params)); const ticker = response['ticker']; return this.parseTicker (ticker, market); @@ -136885,9 +145217,9 @@ module.exports = class zb extends Exchange { async fetchTrades (symbol, since = undefined, limit = undefined, params = {}) { await this.loadMarkets (); const market = this.market (symbol); - const marketFieldName = this.getMarketFieldName (); - const request = {}; - request[marketFieldName] = market['id']; + const request = { + 'market': market['id'], + }; const response = await this.publicGetTrades (this.extend (request, params)); return this.parseTrades (response, market, since, limit); } @@ -136947,7 +145279,7 @@ module.exports = class zb extends Exchange { async fetchOrders (symbol = undefined, since = undefined, limit = 50, params = {}) { if (symbol === undefined) { - throw new ArgumentsRequired (this.id + 'fetchOrders requires a symbol argument'); + throw new ArgumentsRequired (this.id + 'fetchOrders() requires a symbol argument'); } await this.loadMarkets (); const market = this.market (symbol); @@ -136973,9 +145305,24 @@ module.exports = class zb extends Exchange { return this.parseOrders (response, market, since, limit); } + async fetchClosedOrders (symbol = undefined, since = undefined, limit = undefined, params = {}) { + if (symbol === undefined) { + throw new ArgumentsRequired (this.id + 'fetchClosedOrders() requires a symbol argument'); + } + await this.loadMarkets (); + const market = this.market (symbol); + const request = { + 'currency': market['id'], + 'pageIndex': 1, // default pageIndex is 1 + 'pageSize': 10, // default pageSize is 10, doesn't work with other values now + }; + const response = await this.privateGetGetFinishedAndPartialOrders (this.extend (request, params)); + return this.parseOrders (response, market, since, limit); + } + async fetchOpenOrders (symbol = undefined, since = undefined, limit = 10, params = {}) { if (symbol === undefined) { - throw new ArgumentsRequired (this.id + 'fetchOpenOrders requires a symbol argument'); + throw new ArgumentsRequired (this.id + 'fetchOpenOrders() requires a symbol argument'); } await this.loadMarkets (); const market = this.market (symbol); @@ -137002,29 +145349,26 @@ module.exports = class zb extends Exchange { } parseOrder (order, market = undefined) { - // - // fetchOrder // // { - // 'total_amount': 0.01, - // 'id': '20180910244276459', - // 'price': 180.0, - // 'trade_date': 1536576744960, - // 'status': 2, - // 'trade_money': '1.96742', - // 'trade_amount': 0.01, - // 'type': 0, - // 'currency': 'eth_usdt' - // } + // acctType: 0, + // currency: 'btc_usdt', + // fees: 3.6e-7, + // id: '202102282829772463', + // price: 45177.5, + // status: 2, + // total_amount: 0.0002, + // trade_amount: 0.0002, + // trade_date: 1614515104998, + // trade_money: 8.983712, + // type: 1, + // useZbFee: false + // }, // let side = this.safeInteger (order, 'type'); side = (side === 1) ? 'buy' : 'sell'; const type = 'limit'; // market order is not availalbe in ZB - let timestamp = undefined; - const createDateField = this.getCreateDateField (); - if (createDateField in order) { - timestamp = order[createDateField]; - } + const timestamp = this.safeInteger (order, 'trade_date'); const marketId = this.safeString (order, 'currency'); const symbol = this.safeSymbol (marketId, market, '_'); const price = this.safeFloat (order, 'price'); @@ -137043,6 +145387,21 @@ module.exports = class zb extends Exchange { average = cost / filled; } const id = this.safeString (order, 'id'); + const feeCost = this.safeFloat (order, 'fees'); + let fee = undefined; + if (feeCost !== undefined) { + let feeCurrency = undefined; + const zbFees = this.safeValue (order, 'useZbFee'); + if (zbFees === true) { + feeCurrency = 'ZB'; + } else if (market !== undefined) { + feeCurrency = (side === 'sell') ? market['quote'] : market['base']; + } + fee = { + 'cost': feeCost, + 'currency': feeCurrency, + }; + } return { 'info': order, 'id': id, @@ -137053,6 +145412,7 @@ module.exports = class zb extends Exchange { 'symbol': symbol, 'type': type, 'timeInForce': undefined, + 'postOnly': undefined, 'side': side, 'price': price, 'stopPrice': undefined, @@ -137062,7 +145422,7 @@ module.exports = class zb extends Exchange { 'filled': filled, 'remaining': remaining, 'status': status, - 'fee': undefined, + 'fee': fee, 'trades': undefined, }; } @@ -137077,8 +145437,241 @@ module.exports = class zb extends Exchange { return this.safeString (statuses, status, status); } - getCreateDateField () { - return 'trade_date'; + parseTransactionStatus (status) { + const statuses = { + '0': 'pending', // submitted, pending confirmation + '1': 'failed', + '2': 'ok', + '3': 'canceled', + '5': 'ok', // confirmed + }; + return this.safeString (statuses, status, status); + } + + parseTransaction (transaction, currency = undefined) { + // + // withdraw + // + // { + // "code": 1000, + // "message": "success", + // "id": "withdrawalId" + // } + // + // fetchWithdrawals + // + // { + // "amount": 0.01, + // "fees": 0.001, + // "id": 2016042556231, + // "manageTime": 1461579340000, + // "status": 3, + // "submitTime": 1461579288000, + // "toAddress": "14fxEPirL9fyfw1i9EF439Pq6gQ5xijUmp", + // } + // + // fetchDeposits + // + // { + // "address": "1FKN1DZqCm8HaTujDioRL2Aezdh7Qj7xxx", + // "amount": "1.00000000", + // "confirmTimes": 1, + // "currency": "BTC", + // "description": "Successfully Confirm", + // "hash": "7ce842de187c379abafadd64a5fe66c5c61c8a21fb04edff9532234a1dae6xxx", + // "id": 558, + // "itransfer": 1, + // "status": 2, + // "submit_time": "2016-12-07 18:51:57", + // } + // + const id = this.safeString (transaction, 'id'); + const txid = this.safeString (transaction, 'hash'); + const amount = this.safeFloat (transaction, 'amount'); + let timestamp = this.parse8601 (this.safeString (transaction, 'submit_time')); + timestamp = this.safeInteger (transaction, 'submitTime', timestamp); + let address = this.safeString2 (transaction, 'toAddress', 'address'); + let tag = undefined; + if (address !== undefined) { + const parts = address.split ('_'); + address = this.safeString (parts, 0); + tag = this.safeString (parts, 1); + } + const confirmTimes = this.safeInteger (transaction, 'confirmTimes'); + const updated = this.safeInteger (transaction, 'manageTime'); + let type = undefined; + const currencyId = this.safeString (transaction, 'currency'); + const code = this.safeCurrencyCode (currencyId, currency); + if (address !== undefined) { + type = (confirmTimes === undefined) ? 'withdrawal' : 'deposit'; + } + const status = this.parseTransactionStatus (this.safeString (transaction, 'status')); + let fee = undefined; + const feeCost = this.safeFloat (transaction, 'fees'); + if (feeCost !== undefined) { + fee = { + 'cost': feeCost, + 'currency': code, + }; + } + return { + 'info': transaction, + 'id': id, + 'txid': txid, + 'timestamp': timestamp, + 'datetime': this.iso8601 (timestamp), + 'addressFrom': undefined, + 'address': address, + 'addressTo': address, + 'tagFrom': undefined, + 'tag': tag, + 'tagTo': tag, + 'type': type, + 'amount': amount, + 'currency': code, + 'status': status, + 'updated': updated, + 'fee': fee, + }; + } + + async withdraw (code, amount, address, tag = undefined, params = {}) { + const password = this.safeString (params, 'safePwd', this.password); + if (password === undefined) { + throw new ArgumentsRequired (this.id + ' withdraw() requires exchange.password or a safePwd parameter'); + } + const fees = this.safeFloat (params, 'fees'); + if (fees === undefined) { + throw new ArgumentsRequired (this.id + ' withdraw() requires a fees parameter'); + } + this.checkAddress (address); + await this.loadMarkets (); + const currency = this.currency (code); + if (tag !== undefined) { + address += '_' + tag; + } + const request = { + 'amount': this.currencyToPrecision (code, amount), + 'currency': currency['id'], + 'fees': this.currencyToPrecision (code, fees), + // 'itransfer': 0, // agree for an internal transfer, 0 disagree, 1 agree, the default is to disagree + 'method': 'withdraw', + 'receiveAddr': address, + 'safePwd': password, + }; + const response = await this.privateGetWithdraw (this.extend (request, params)); + // + // { + // "code": 1000, + // "message": "success", + // "id": "withdrawalId" + // } + // + const transaction = this.parseTransaction (response, currency); + return this.extend (transaction, { + 'type': 'withdrawal', + 'address': address, + 'addressTo': address, + 'amount': amount, + }); + } + + async fetchWithdrawals (code = undefined, since = undefined, limit = undefined, params = {}) { + await this.loadMarkets (); + const request = { + // 'currency': currency['id'], + // 'pageIndex': 1, + // 'pageSize': limit, + }; + let currency = undefined; + if (code !== undefined) { + currency = this.currency (code); + request['currency'] = currency['id']; + } + if (limit !== undefined) { + request['pageSize'] = limit; + } + const response = await this.privateGetGetWithdrawRecord (this.extend (request, params)); + // + // { + // "code": 1000, + // "message": { + // "des": "success", + // "isSuc": true, + // "datas": { + // "list": [ + // { + // "amount": 0.01, + // "fees": 0.001, + // "id": 2016042556231, + // "manageTime": 1461579340000, + // "status": 3, + // "submitTime": 1461579288000, + // "toAddress": "14fxEPirL9fyfw1i9EF439Pq6gQ5xijUmp", + // }, + // ], + // "pageIndex": 1, + // "pageSize": 10, + // "totalCount": 4, + // "totalPage": 1 + // } + // } + // } + // + const message = this.safeValue (response, 'message', {}); + const datas = this.safeValue (message, 'datas', {}); + const withdrawals = this.safeValue (datas, 'list', []); + return this.parseTransactions (withdrawals, currency, since, limit); + } + + async fetchDeposits (code = undefined, since = undefined, limit = undefined, params = {}) { + await this.loadMarkets (); + const request = { + // 'currency': currency['id'], + // 'pageIndex': 1, + // 'pageSize': limit, + }; + let currency = undefined; + if (code !== undefined) { + currency = this.currency (code); + request['currency'] = currency['id']; + } + if (limit !== undefined) { + request['pageSize'] = limit; + } + const response = await this.privateGetGetChargeRecord (this.extend (request, params)); + // + // { + // "code": 1000, + // "message": { + // "des": "success", + // "isSuc": true, + // "datas": { + // "list": [ + // { + // "address": "1FKN1DZqCm8HaTujDioRL2Aezdh7Qj7xxx", + // "amount": "1.00000000", + // "confirmTimes": 1, + // "currency": "BTC", + // "description": "Successfully Confirm", + // "hash": "7ce842de187c379abafadd64a5fe66c5c61c8a21fb04edff9532234a1dae6xxx", + // "id": 558, + // "itransfer": 1, + // "status": 2, + // "submit_time": "2016-12-07 18:51:57", + // }, + // ], + // "pageIndex": 1, + // "pageSize": 10, + // "total": 8 + // } + // } + // } + // + const message = this.safeValue (response, 'message', {}); + const datas = this.safeValue (message, 'datas', {}); + const deposits = this.safeValue (datas, 'list', []); + return this.parseTransactions (deposits, currency, since, limit); } nonce () { @@ -137114,9 +145707,10 @@ module.exports = class zb extends Exchange { } if (body[0] === '{') { const feedback = this.id + ' ' + body; + this.throwBroadlyMatchedException (this.exceptions['broad'], body, feedback); if ('code' in response) { const code = this.safeString (response, 'code'); - this.throwExactlyMatchedException (this.exceptions, code, feedback); + this.throwExactlyMatchedException (this.exceptions['exact'], code, feedback); if (code !== '1000') { throw new ExchangeError (feedback); } @@ -137137,7 +145731,7 @@ module.exports = class zb extends Exchange { } }; -},{"./base/Exchange":5,"./base/errors":7}],180:[function(require,module,exports){ +},{"./base/Exchange":6,"./base/errors":8}],183:[function(require,module,exports){ (function (global){ 'use strict'; @@ -137631,7 +146225,7 @@ var objectKeys = Object.keys || function (obj) { }; }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) -},{"util/":238}],181:[function(require,module,exports){ +},{"util/":241}],184:[function(require,module,exports){ 'use strict' exports.byteLength = byteLength @@ -137747,9 +146341,9 @@ function fromByteArray (uint8) { return parts.join('') } -},{}],182:[function(require,module,exports){ +},{}],185:[function(require,module,exports){ -},{}],183:[function(require,module,exports){ +},{}],186:[function(require,module,exports){ (function (process,Buffer){ 'use strict'; /* eslint camelcase: "off" */ @@ -138161,7 +146755,7 @@ Zlib.prototype._reset = function () { exports.Zlib = Zlib; }).call(this,require('_process'),require("buffer").Buffer) -},{"_process":207,"assert":180,"buffer":185,"pako/lib/zlib/constants":197,"pako/lib/zlib/deflate.js":199,"pako/lib/zlib/inflate.js":201,"pako/lib/zlib/zstream":205}],184:[function(require,module,exports){ +},{"_process":210,"assert":183,"buffer":188,"pako/lib/zlib/constants":200,"pako/lib/zlib/deflate.js":202,"pako/lib/zlib/inflate.js":204,"pako/lib/zlib/zstream":208}],187:[function(require,module,exports){ (function (process){ 'use strict'; @@ -138773,7 +147367,7 @@ util.inherits(DeflateRaw, Zlib); util.inherits(InflateRaw, Zlib); util.inherits(Unzip, Zlib); }).call(this,require('_process')) -},{"./binding":183,"_process":207,"assert":180,"buffer":185,"stream":226,"util":238}],185:[function(require,module,exports){ +},{"./binding":186,"_process":210,"assert":183,"buffer":188,"stream":229,"util":241}],188:[function(require,module,exports){ /*! * The buffer module from node.js, for the browser. * @@ -140489,7 +149083,7 @@ function numberIsNaN (obj) { return obj !== obj // eslint-disable-line no-self-compare } -},{"base64-js":181,"ieee754":191}],186:[function(require,module,exports){ +},{"base64-js":184,"ieee754":194}],189:[function(require,module,exports){ module.exports = { "100": "Continue", "101": "Switching Protocols", @@ -140555,7 +149149,7 @@ module.exports = { "511": "Network Authentication Required" } -},{}],187:[function(require,module,exports){ +},{}],190:[function(require,module,exports){ module.exports={ "O_RDONLY": 0, "O_WRONLY": 1, @@ -140766,7 +149360,7 @@ module.exports={ "UV_UDP_REUSEADDR": 4 } -},{}],188:[function(require,module,exports){ +},{}],191:[function(require,module,exports){ (function (Buffer){ // Copyright Joyent, Inc. and other Node contributors. // @@ -140877,7 +149471,7 @@ function objectToString(o) { } }).call(this,{"isBuffer":require("../../is-buffer/index.js")}) -},{"../../is-buffer/index.js":193}],189:[function(require,module,exports){ +},{"../../is-buffer/index.js":196}],192:[function(require,module,exports){ // Copyright Joyent, Inc. and other Node contributors. // // Permission is hereby granted, free of charge, to any person obtaining a @@ -141181,7 +149775,7 @@ function isUndefined(arg) { return arg === void 0; } -},{}],190:[function(require,module,exports){ +},{}],193:[function(require,module,exports){ var http = require('http') var url = require('url') @@ -141214,7 +149808,7 @@ function validateParams (params) { return params } -},{"http":227,"url":233}],191:[function(require,module,exports){ +},{"http":230,"url":236}],194:[function(require,module,exports){ exports.read = function (buffer, offset, isLE, mLen, nBytes) { var e, m var eLen = nBytes * 8 - mLen - 1 @@ -141300,7 +149894,7 @@ exports.write = function (buffer, value, offset, isLE, mLen, nBytes) { buffer[offset + i - d] |= s * 128 } -},{}],192:[function(require,module,exports){ +},{}],195:[function(require,module,exports){ if (typeof Object.create === 'function') { // implementation from standard node.js 'util' module module.exports = function inherits(ctor, superCtor) { @@ -141325,7 +149919,7 @@ if (typeof Object.create === 'function') { } } -},{}],193:[function(require,module,exports){ +},{}],196:[function(require,module,exports){ /*! * Determine if an object is a Buffer * @@ -141348,14 +149942,14 @@ function isSlowBuffer (obj) { return typeof obj.readFloatLE === 'function' && typeof obj.slice === 'function' && isBuffer(obj.slice(0, 0)) } -},{}],194:[function(require,module,exports){ +},{}],197:[function(require,module,exports){ var toString = {}.toString; module.exports = Array.isArray || function (arr) { return toString.call(arr) == '[object Array]'; }; -},{}],195:[function(require,module,exports){ +},{}],198:[function(require,module,exports){ 'use strict'; @@ -141462,7 +150056,7 @@ exports.setTyped = function (on) { exports.setTyped(TYPED_OK); -},{}],196:[function(require,module,exports){ +},{}],199:[function(require,module,exports){ 'use strict'; // Note: adler32 takes 12% for level 0 and 2% for level 6. @@ -141515,7 +150109,7 @@ function adler32(adler, buf, len, pos) { module.exports = adler32; -},{}],197:[function(require,module,exports){ +},{}],200:[function(require,module,exports){ 'use strict'; // (C) 1995-2013 Jean-loup Gailly and Mark Adler @@ -141585,7 +150179,7 @@ module.exports = { //Z_NULL: null // Use -1 or null inline, depending on var type }; -},{}],198:[function(require,module,exports){ +},{}],201:[function(require,module,exports){ 'use strict'; // Note: we can't get significant speed boost here. @@ -141646,7 +150240,7 @@ function crc32(crc, buf, len, pos) { module.exports = crc32; -},{}],199:[function(require,module,exports){ +},{}],202:[function(require,module,exports){ 'use strict'; // (C) 1995-2013 Jean-loup Gailly and Mark Adler @@ -143522,7 +152116,7 @@ exports.deflatePrime = deflatePrime; exports.deflateTune = deflateTune; */ -},{"../utils/common":195,"./adler32":196,"./crc32":198,"./messages":203,"./trees":204}],200:[function(require,module,exports){ +},{"../utils/common":198,"./adler32":199,"./crc32":201,"./messages":206,"./trees":207}],203:[function(require,module,exports){ 'use strict'; // (C) 1995-2013 Jean-loup Gailly and Mark Adler @@ -143869,7 +152463,7 @@ module.exports = function inflate_fast(strm, start) { return; }; -},{}],201:[function(require,module,exports){ +},{}],204:[function(require,module,exports){ 'use strict'; // (C) 1995-2013 Jean-loup Gailly and Mark Adler @@ -145427,7 +154021,7 @@ exports.inflateSyncPoint = inflateSyncPoint; exports.inflateUndermine = inflateUndermine; */ -},{"../utils/common":195,"./adler32":196,"./crc32":198,"./inffast":200,"./inftrees":202}],202:[function(require,module,exports){ +},{"../utils/common":198,"./adler32":199,"./crc32":201,"./inffast":203,"./inftrees":205}],205:[function(require,module,exports){ 'use strict'; // (C) 1995-2013 Jean-loup Gailly and Mark Adler @@ -145772,7 +154366,7 @@ module.exports = function inflate_table(type, lens, lens_index, codes, table, ta return 0; }; -},{"../utils/common":195}],203:[function(require,module,exports){ +},{"../utils/common":198}],206:[function(require,module,exports){ 'use strict'; // (C) 1995-2013 Jean-loup Gailly and Mark Adler @@ -145806,7 +154400,7 @@ module.exports = { '-6': 'incompatible version' /* Z_VERSION_ERROR (-6) */ }; -},{}],204:[function(require,module,exports){ +},{}],207:[function(require,module,exports){ 'use strict'; // (C) 1995-2013 Jean-loup Gailly and Mark Adler @@ -147028,7 +155622,7 @@ exports._tr_flush_block = _tr_flush_block; exports._tr_tally = _tr_tally; exports._tr_align = _tr_align; -},{"../utils/common":195}],205:[function(require,module,exports){ +},{"../utils/common":198}],208:[function(require,module,exports){ 'use strict'; // (C) 1995-2013 Jean-loup Gailly and Mark Adler @@ -147077,7 +155671,7 @@ function ZStream() { module.exports = ZStream; -},{}],206:[function(require,module,exports){ +},{}],209:[function(require,module,exports){ (function (process){ 'use strict'; @@ -147124,7 +155718,7 @@ function nextTick(fn, arg1, arg2, arg3) { } }).call(this,require('_process')) -},{"_process":207}],207:[function(require,module,exports){ +},{"_process":210}],210:[function(require,module,exports){ // shim for using process in browser var process = module.exports = {}; @@ -147310,7 +155904,7 @@ process.chdir = function (dir) { }; process.umask = function() { return 0; }; -},{}],208:[function(require,module,exports){ +},{}],211:[function(require,module,exports){ (function (global){ /*! https://mths.be/punycode v1.4.1 by @mathias */ ;(function(root) { @@ -147847,7 +156441,7 @@ process.umask = function() { return 0; }; }(this)); }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) -},{}],209:[function(require,module,exports){ +},{}],212:[function(require,module,exports){ // Copyright Joyent, Inc. and other Node contributors. // // Permission is hereby granted, free of charge, to any person obtaining a @@ -147933,7 +156527,7 @@ var isArray = Array.isArray || function (xs) { return Object.prototype.toString.call(xs) === '[object Array]'; }; -},{}],210:[function(require,module,exports){ +},{}],213:[function(require,module,exports){ // Copyright Joyent, Inc. and other Node contributors. // // Permission is hereby granted, free of charge, to any person obtaining a @@ -148020,16 +156614,16 @@ var objectKeys = Object.keys || function (obj) { return res; }; -},{}],211:[function(require,module,exports){ +},{}],214:[function(require,module,exports){ 'use strict'; exports.decode = exports.parse = require('./decode'); exports.encode = exports.stringify = require('./encode'); -},{"./decode":209,"./encode":210}],212:[function(require,module,exports){ +},{"./decode":212,"./encode":213}],215:[function(require,module,exports){ module.exports = require('./lib/_stream_duplex.js'); -},{"./lib/_stream_duplex.js":213}],213:[function(require,module,exports){ +},{"./lib/_stream_duplex.js":216}],216:[function(require,module,exports){ // Copyright Joyent, Inc. and other Node contributors. // // Permission is hereby granted, free of charge, to any person obtaining a @@ -148154,7 +156748,7 @@ function forEach(xs, f) { f(xs[i], i); } } -},{"./_stream_readable":215,"./_stream_writable":217,"core-util-is":188,"inherits":192,"process-nextick-args":206}],214:[function(require,module,exports){ +},{"./_stream_readable":218,"./_stream_writable":220,"core-util-is":191,"inherits":195,"process-nextick-args":209}],217:[function(require,module,exports){ // Copyright Joyent, Inc. and other Node contributors. // // Permission is hereby granted, free of charge, to any person obtaining a @@ -148202,7 +156796,7 @@ function PassThrough(options) { PassThrough.prototype._transform = function (chunk, encoding, cb) { cb(null, chunk); }; -},{"./_stream_transform":216,"core-util-is":188,"inherits":192}],215:[function(require,module,exports){ +},{"./_stream_transform":219,"core-util-is":191,"inherits":195}],218:[function(require,module,exports){ (function (process,global){ // Copyright Joyent, Inc. and other Node contributors. // @@ -149212,7 +157806,7 @@ function indexOf(xs, x) { return -1; } }).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) -},{"./_stream_duplex":213,"./internal/streams/BufferList":218,"./internal/streams/destroy":219,"./internal/streams/stream":220,"_process":207,"core-util-is":188,"events":189,"inherits":192,"isarray":194,"process-nextick-args":206,"safe-buffer":225,"string_decoder/":231,"util":182}],216:[function(require,module,exports){ +},{"./_stream_duplex":216,"./internal/streams/BufferList":221,"./internal/streams/destroy":222,"./internal/streams/stream":223,"_process":210,"core-util-is":191,"events":192,"inherits":195,"isarray":197,"process-nextick-args":209,"safe-buffer":228,"string_decoder/":234,"util":185}],219:[function(require,module,exports){ // Copyright Joyent, Inc. and other Node contributors. // // Permission is hereby granted, free of charge, to any person obtaining a @@ -149427,7 +158021,7 @@ function done(stream, er, data) { return stream.push(null); } -},{"./_stream_duplex":213,"core-util-is":188,"inherits":192}],217:[function(require,module,exports){ +},{"./_stream_duplex":216,"core-util-is":191,"inherits":195}],220:[function(require,module,exports){ (function (process,global){ // Copyright Joyent, Inc. and other Node contributors. // @@ -150094,7 +158688,7 @@ Writable.prototype._destroy = function (err, cb) { cb(err); }; }).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) -},{"./_stream_duplex":213,"./internal/streams/destroy":219,"./internal/streams/stream":220,"_process":207,"core-util-is":188,"inherits":192,"process-nextick-args":206,"safe-buffer":225,"util-deprecate":235}],218:[function(require,module,exports){ +},{"./_stream_duplex":216,"./internal/streams/destroy":222,"./internal/streams/stream":223,"_process":210,"core-util-is":191,"inherits":195,"process-nextick-args":209,"safe-buffer":228,"util-deprecate":238}],221:[function(require,module,exports){ 'use strict'; /**/ @@ -150169,7 +158763,7 @@ module.exports = function () { return BufferList; }(); -},{"safe-buffer":225}],219:[function(require,module,exports){ +},{"safe-buffer":228}],222:[function(require,module,exports){ 'use strict'; /**/ @@ -150242,13 +158836,13 @@ module.exports = { destroy: destroy, undestroy: undestroy }; -},{"process-nextick-args":206}],220:[function(require,module,exports){ +},{"process-nextick-args":209}],223:[function(require,module,exports){ module.exports = require('events').EventEmitter; -},{"events":189}],221:[function(require,module,exports){ +},{"events":192}],224:[function(require,module,exports){ module.exports = require('./readable').PassThrough -},{"./readable":222}],222:[function(require,module,exports){ +},{"./readable":225}],225:[function(require,module,exports){ exports = module.exports = require('./lib/_stream_readable.js'); exports.Stream = exports; exports.Readable = exports; @@ -150257,13 +158851,13 @@ exports.Duplex = require('./lib/_stream_duplex.js'); exports.Transform = require('./lib/_stream_transform.js'); exports.PassThrough = require('./lib/_stream_passthrough.js'); -},{"./lib/_stream_duplex.js":213,"./lib/_stream_passthrough.js":214,"./lib/_stream_readable.js":215,"./lib/_stream_transform.js":216,"./lib/_stream_writable.js":217}],223:[function(require,module,exports){ +},{"./lib/_stream_duplex.js":216,"./lib/_stream_passthrough.js":217,"./lib/_stream_readable.js":218,"./lib/_stream_transform.js":219,"./lib/_stream_writable.js":220}],226:[function(require,module,exports){ module.exports = require('./readable').Transform -},{"./readable":222}],224:[function(require,module,exports){ +},{"./readable":225}],227:[function(require,module,exports){ module.exports = require('./lib/_stream_writable.js'); -},{"./lib/_stream_writable.js":217}],225:[function(require,module,exports){ +},{"./lib/_stream_writable.js":220}],228:[function(require,module,exports){ /* eslint-disable node/no-deprecated-api */ var buffer = require('buffer') var Buffer = buffer.Buffer @@ -150327,7 +158921,7 @@ SafeBuffer.allocUnsafeSlow = function (size) { return buffer.SlowBuffer(size) } -},{"buffer":185}],226:[function(require,module,exports){ +},{"buffer":188}],229:[function(require,module,exports){ // Copyright Joyent, Inc. and other Node contributors. // // Permission is hereby granted, free of charge, to any person obtaining a @@ -150456,7 +159050,7 @@ Stream.prototype.pipe = function(dest, options) { return dest; }; -},{"events":189,"inherits":192,"readable-stream/duplex.js":212,"readable-stream/passthrough.js":221,"readable-stream/readable.js":222,"readable-stream/transform.js":223,"readable-stream/writable.js":224}],227:[function(require,module,exports){ +},{"events":192,"inherits":195,"readable-stream/duplex.js":215,"readable-stream/passthrough.js":224,"readable-stream/readable.js":225,"readable-stream/transform.js":226,"readable-stream/writable.js":227}],230:[function(require,module,exports){ (function (global){ var ClientRequest = require('./lib/request') var extend = require('xtend') @@ -150538,7 +159132,7 @@ http.METHODS = [ 'UNSUBSCRIBE' ] }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) -},{"./lib/request":229,"builtin-status-codes":186,"url":233,"xtend":239}],228:[function(require,module,exports){ +},{"./lib/request":232,"builtin-status-codes":189,"url":236,"xtend":242}],231:[function(require,module,exports){ (function (global){ exports.fetch = isFunction(global.fetch) && isFunction(global.ReadableStream) @@ -150611,7 +159205,7 @@ function isFunction (value) { xhr = null // Help gc }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) -},{}],229:[function(require,module,exports){ +},{}],232:[function(require,module,exports){ (function (process,global,Buffer){ var capability = require('./capability') var inherits = require('inherits') @@ -150921,7 +159515,7 @@ var unsafeHeaders = [ ] }).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {},require("buffer").Buffer) -},{"./capability":228,"./response":230,"_process":207,"buffer":185,"inherits":192,"readable-stream":222,"to-arraybuffer":232}],230:[function(require,module,exports){ +},{"./capability":231,"./response":233,"_process":210,"buffer":188,"inherits":195,"readable-stream":225,"to-arraybuffer":235}],233:[function(require,module,exports){ (function (process,global,Buffer){ var capability = require('./capability') var inherits = require('inherits') @@ -151107,7 +159701,7 @@ IncomingMessage.prototype._onXHRProgress = function () { } }).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {},require("buffer").Buffer) -},{"./capability":228,"_process":207,"buffer":185,"inherits":192,"readable-stream":222}],231:[function(require,module,exports){ +},{"./capability":231,"_process":210,"buffer":188,"inherits":195,"readable-stream":225}],234:[function(require,module,exports){ 'use strict'; var Buffer = require('safe-buffer').Buffer; @@ -151380,7 +159974,7 @@ function simpleWrite(buf) { function simpleEnd(buf) { return buf && buf.length ? this.write(buf) : ''; } -},{"safe-buffer":225}],232:[function(require,module,exports){ +},{"safe-buffer":228}],235:[function(require,module,exports){ var Buffer = require('buffer').Buffer module.exports = function (buf) { @@ -151409,7 +160003,7 @@ module.exports = function (buf) { } } -},{"buffer":185}],233:[function(require,module,exports){ +},{"buffer":188}],236:[function(require,module,exports){ // Copyright Joyent, Inc. and other Node contributors. // // Permission is hereby granted, free of charge, to any person obtaining a @@ -152143,7 +160737,7 @@ Url.prototype.parseHost = function() { if (host) this.hostname = host; }; -},{"./util":234,"punycode":208,"querystring":211}],234:[function(require,module,exports){ +},{"./util":237,"punycode":211,"querystring":214}],237:[function(require,module,exports){ 'use strict'; module.exports = { @@ -152161,7 +160755,7 @@ module.exports = { } }; -},{}],235:[function(require,module,exports){ +},{}],238:[function(require,module,exports){ (function (global){ /** @@ -152232,16 +160826,16 @@ function config (name) { } }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) -},{}],236:[function(require,module,exports){ -arguments[4][192][0].apply(exports,arguments) -},{"dup":192}],237:[function(require,module,exports){ +},{}],239:[function(require,module,exports){ +arguments[4][195][0].apply(exports,arguments) +},{"dup":195}],240:[function(require,module,exports){ module.exports = function isBuffer(arg) { return arg && typeof arg === 'object' && typeof arg.copy === 'function' && typeof arg.fill === 'function' && typeof arg.readUInt8 === 'function'; } -},{}],238:[function(require,module,exports){ +},{}],241:[function(require,module,exports){ (function (process,global){ // Copyright Joyent, Inc. and other Node contributors. // @@ -152831,7 +161425,7 @@ function hasOwnProperty(obj, prop) { } }).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) -},{"./support/isBuffer":237,"_process":207,"inherits":236}],239:[function(require,module,exports){ +},{"./support/isBuffer":240,"_process":210,"inherits":239}],242:[function(require,module,exports){ module.exports = extend var hasOwnProperty = Object.prototype.hasOwnProperty; diff --git a/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/aax.js b/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/aax.js new file mode 100644 index 000000000..9c71e445f --- /dev/null +++ b/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/aax.js @@ -0,0 +1,1784 @@ +'use strict'; + +// ---------------------------------------------------------------------------- + +const Exchange = require ('./base/Exchange'); +const { ArgumentsRequired, AuthenticationError, ExchangeError, ExchangeNotAvailable, OrderNotFound, InvalidOrder, CancelPending, RateLimitExceeded, InsufficientFunds, BadRequest, BadSymbol, PermissionDenied } = require ('./base/errors'); +const { TICK_SIZE } = require ('./base/functions/number'); + +// ---------------------------------------------------------------------------- + +module.exports = class aax extends Exchange { + describe () { + return this.deepExtend (super.describe (), { + 'id': 'aax', + 'name': 'AAX', + 'countries': [ 'MT' ], // Malta + 'enableRateLimit': true, + 'rateLimit': 500, + 'version': 'v2', + 'hostname': 'aaxpro.com', // aax.com + 'certified': true, + 'has': { + 'cancelAllOrders': true, + 'cancelOrder': true, + 'createOrder': true, + 'editOrder': true, + 'fetchBalance': true, + 'fetchCanceledOrders': true, + 'fetchClosedOrders': true, + 'fetchDepositAddress': true, + 'fetchMarkets': true, + 'fetchMyTrades': true, + 'fetchOHLCV': true, + 'fetchOpenOrders': true, + 'fetchOrder': true, + 'fetchOrderBook': true, + 'fetchOrders': true, + 'fetchTicker': 'emulated', + 'fetchTickers': true, + 'fetchTrades': true, + }, + 'timeframes': { + '1m': '1m', + '5m': '5m', + '15m': '15m', + '30m': '30m', + '1h': '1h', + '2h': '2h', + '4h': '4h', + '12h': '12h', + '1d': '1d', + '3d': '3d', + '1w': '1w', + }, + 'urls': { + 'logo': 'https://user-images.githubusercontent.com/1294454/104140087-a27f2580-53c0-11eb-87c1-5d9e81208fe9.jpg', + 'test': { + 'v1': 'https://api.testnet.{hostname}/marketdata/v1', + 'public': 'https://api.testnet.{hostname}', + 'private': 'https://api.testnet.{hostname}', + }, + 'api': { + 'v1': 'https://api.{hostname}/marketdata/v1', + 'public': 'https://api.{hostname}', + 'private': 'https://api.{hostname}', + }, + 'www': 'https://www.aaxpro.com', // string website URL + 'doc': 'https://www.aaxpro.com/apidoc/index.html', + 'fees': 'https://www.aaxpro.com/en-US/fees/', + 'referral': 'https://www.aaxpro.com/invite/sign-up?inviteCode=JXGm5Fy7R2MB', + }, + 'api': { + 'v1': { + 'get': [ + 'getHistMarketData', // Get OHLC k line of specific market + ], + }, + 'public': { + // these endpoints are not documented + // 'get': [ + // 'order_book', // Get the order book of specified market + // 'order_book/{market}', + // 'trades', // Get recent trades on market, each trade is included only once Trades are sorted in reverse creation order. + // 'trades/{market}', + // 'tickers', // Get ticker of all markets + // 'tickers/{market}', // Get ticker of specific market + // ], + 'get': [ + 'announcement/maintenance', // System Maintenance Notice + 'instruments', // Retrieve all trading pairs information + 'market/orderbook', // Order Book + 'futures/position/openInterest', // Open Interest + 'market/tickers', // Get the Last 24h Market Summary + 'market/candles', // Get Current Candlestick + 'market/history/candles', // Get Current Candlestick + 'market/trades', // Get the Most Recent Trades + 'market/markPrice', // Get Current Mark Price + 'futures/funding/predictedFunding/{symbol}', // Get Predicted Funding Rate + 'futures/funding/prevFundingRate/{symbol}', // Get Last Funding Rate + 'market/candles/index', // Get Current Index Candlestick + ], + }, + 'private': { + 'get': [ + 'user/info', // Retrieve user information + 'account/balances', // Get Account Balances + 'account/deposit/address', // undocumented + 'spot/trades', // Retrieve trades details for a spot order + 'spot/openOrders', // Retrieve spot open orders + 'spot/orders', // Retrieve historical spot orders + 'futures/position', // Get positions for all contracts + 'futures/position/closed', // Get closed positions + 'futures/trades', // Retrieve trade details for a futures order + 'futures/openOrders', // Retrieve futures open orders + 'futures/orders', // Retrieve historical futures orders + 'futures/funding/predictedFundingFee/{symbol}', // Get predicted funding fee + ], + 'post': [ + 'account/transfer', // Asset Transfer + 'spot/orders', // Create a new spot order + 'spot/orders/cancelAllOnTimeout', // Automatically cancel all your spot orders after a specified timeout. + 'futures/orders', // Create a new futures order + 'futures/orders/cancelAllOnTimeout', // Automatically cancel all your futures orders after a specified timeout. + 'futures/position/sltp', // Set take profit and stop loss orders for an opening position + 'futures/position/close', // Close position + 'futures/position/leverage', // Update leverage for position + 'futures/position/margin', // Modify Isolated Position Margin + ], + 'put': [ + 'spot/orders', // Amend spot order + 'futures/orders', // Amend the quantity of an open futures order + ], + 'delete': [ + 'spot/orders/cancel/{orderID}', // Cancel a spot order + 'spot/orders/cancel/all', // Batch cancel spot orders + 'futures/orders/cancel/{orderID}', // Cancel a futures order + 'futures/orders/cancel/all', // Batch cancel futures orders + ], + }, + }, + 'fees': { + 'trading': { + 'tierBased': false, + 'percentage': true, + 'maker': 0.06 / 100, + 'taker': 0.10 / 100, + }, + 'funding': { + 'tierBased': false, + 'percentage': true, + 'withdraw': {}, // There is only 1% fee on withdrawals to your bank account. + }, + }, + 'commonCurrencies': { + 'XBT': 'XBT', + }, + 'exceptions': { + 'exact': { + '2002': InsufficientFunds, + '2003': OrderNotFound, + '10003': BadRequest, // Parameter validation error + '10006': AuthenticationError, // Session expired, please relogin + '10007': AuthenticationError, // Invalid authentication key or token + '11007': AuthenticationError, // Invalid key format + '20001': InsufficientFunds, // Insufficient balance. Please deposit to trade. + '20009': InvalidOrder, // Order amount must be positive + '30000': OrderNotFound, // {"code":30000,"data":null,"message":"The order does not exist","ts":1610259732263} + '30001': InvalidOrder, // The order is being submitted, please try again later + '30004': InvalidOrder, // Minimum quantity is {0} + '30005': InvalidOrder, // Quantity maximum precision is {0} decimal places + '30006': InvalidOrder, // Price maximum precision is {0} decimal places + '30007': InvalidOrder, // Minimum price is {0} + '30008': InvalidOrder, // Stop price maximum precision is {0} decimal places + '30009': InvalidOrder, // Stop Price cannot be less than {0} + '30010': InvalidOrder, // Market price cannot be empty + '30011': CancelPending, // The order is being cancelled, please wait. + '30012': BadRequest, // Unknown currency + '30013': BadSymbol, // Unknown symbol + '30014': OrderNotFound, // Futures order cannot be found + '30015': InvalidOrder, // This is not an open order and cannot modified + '30016': ExchangeError, // No position found + '30017': InvalidOrder, // The current close position is 0. It is recommended that you cancel the current order closing order. + '30018': InvalidOrder, // Order price cannot be greater than {0} + '30019': InvalidOrder, // Order quantity cannot be greater than {0} + '30020': InvalidOrder, // Order price must be a multiple of {0} + '30021': InvalidOrder, // Margin adjustement must be greater than 0 + '30022': InvalidOrder, // New quantity must be greater than filled quantity + '30023': InvalidOrder, // Order failed, please try again + '30024': InvalidOrder, // TimeInForce error, only GTC or IOC are allowed + '30025': InvalidOrder, // TimeInForce error, only GTC is allowed + '30026': InvalidOrder, // Quantity is not a multiple of {0} + '30027': InvalidOrder, // Close position failed, it is recommended that you cancel the current order and then close the position. + '30028': BadSymbol, // Symbol cannot be traded at this time + '30029': InvalidOrder, // Modified quantity or price cannot be empty + '30030': InvalidOrder, // Price cannot be specified for market orders + '30031': InvalidOrder, // Liquidation orders cannot be modified + '30032': InvalidOrder, // Leverage cannot be greater than {0} + '30033': InvalidOrder, // Leverage cannot be smaller than {0} + '30034': RateLimitExceeded, // The max number of open orders is {0}. To place a new order, please cancel a previous one + '30035': RateLimitExceeded, // The max number of {0} open orders is {1}. To place a new order, please cancel a previous one + '30036': ExchangeNotAvailable, // Liquidation is in progress, please try again later + '30037': InvalidOrder, // Once stop limit order triggered, stop price cannot be amended + '30038': ExchangeError, // The total value of your orders has exceeded the current risk limit. Please adjust the risk limit + '30039': InsufficientFunds, // Your risk limit has now been changed to {0}, your maximum leverage less than 1, please readjust accordingly + '30040': InvalidOrder, // Order status has changed, please try again later + '30041': InvalidOrder, // Liquidation orders cannot be cancelled + '30042': InvalidOrder, // Order cannot be placed as you will be breaching you max limit value of {1} BTC for {0} + '30043': InvalidOrder, // The risk limit cannot be less than 0 + '30044': BadRequest, // Timeout cannot be greater than 60 minutes + '30045': InvalidOrder, // Side is not valid, it should be BUY or SELL + '30046': InvalidOrder, // Order type is not valid, it should be MARKET or LIMIT or STOP-LIMIT or STOP + '30047': InvalidOrder, // The order is closed. Can't cancel + '30048': InvalidOrder, // Market orders cannot be modified + '30049': InvalidOrder, // The order is being modified, please wait + '30050': InvalidOrder, // Maximum 10 orders + '40004': BadRequest, // Requested resource doesn't exist + '40009': RateLimitExceeded, // Too many requests + '40102': AuthenticationError, // {"code":40102,"message":"Unauthorized(invalid key)"} + '40103': AuthenticationError, // {"code":40103,"message":"Unauthorized(invalid sign)"} + '40303': PermissionDenied, // {"code":40303,"message":"Forbidden(invalid scopes)"} + '41001': BadRequest, // Incorrect HTTP request + '41002': BadRequest, // Unsupported HTTP request method + '42001': ExchangeNotAvailable, // Duplicated data entry, please check and try again + '50001': ExchangeError, // Server side exception, please try again later + '50002': ExchangeError, // Server is busy, please try again later + }, + 'broad': {}, + }, + 'precisionMode': TICK_SIZE, + 'options': { + 'defaultType': 'spot', // 'spot', 'future' + }, + }); + } + + async fetchMarkets (params = {}) { + const response = await this.publicGetInstruments (params); + // + // { + // "code":1, + // "message":"success", + // "ts":1610159448962, + // "data":[ + // { + // "tickSize":"0.01", + // "lotSize":"1", + // "base":"BTC", + // "quote":"USDT", + // "minQuantity":"1.0000000000", + // "maxQuantity":"30000", + // "minPrice":"0.0100000000", + // "maxPrice":"999999.0000000000", + // "status":"readOnly", + // "symbol":"BTCUSDTFP", + // "code":"FP", + // "takerFee":"0.00040", + // "makerFee":"0.00020", + // "multiplier":"0.001000000000", + // "mmRate":"0.00500", + // "imRate":"0.01000", + // "type":"futures", + // "settleType":"Vanilla", + // "settleCurrency":"USDT" + // }, + // { + // "tickSize":"0.5", + // "lotSize":"10", + // "base":"BTC", + // "quote":"USD", + // "minQuantity":"10.0000000000", + // "maxQuantity":"300000", + // "minPrice":"0.5000000000", + // "maxPrice":"999999.0000000000", + // "status":"readOnly", + // "symbol":"BTCUSDFP", + // "code":"FP", + // "takerFee":"0.00040", + // "makerFee":"0.00020", + // "multiplier":"1.000000000000", + // "mmRate":"0.00500", + // "imRate":"0.01000", + // "type":"futures", + // "settleType":"Inverse", + // "settleCurrency":"BTC" + // }, + // { + // "tickSize":"0.0001", + // "lotSize":"0.01", + // "base":"AAB", + // "quote":"USDT", + // "minQuantity":"5.0000000000", + // "maxQuantity":"50000.0000000000", + // "minPrice":"0.0001000000", + // "maxPrice":"999999.0000000000", + // "status":"readOnly", + // "symbol":"AABUSDT", + // "code":null, + // "takerFee":"0.00100", + // "makerFee":"0.00100", + // "multiplier":"1.000000000000", + // "mmRate":"0.02500", + // "imRate":"0.05000", + // "type":"spot", + // "settleType":null, + // "settleCurrency":null + // }, + // ] + // } + // + const data = this.safeValue (response, 'data'); + const result = []; + for (let i = 0; i < data.length; i++) { + const market = data[i]; + const id = this.safeString (market, 'symbol'); + const baseId = this.safeString (market, 'base'); + const quoteId = this.safeString (market, 'quote'); + const base = this.safeCurrencyCode (baseId); + const quote = this.safeCurrencyCode (quoteId); + const status = this.safeString (market, 'status'); + const active = (status === 'enable'); + const taker = this.safeFloat (market, 'takerFee'); + const maker = this.safeFloat (market, 'makerFee'); + const type = this.safeString (market, 'type'); + let inverse = undefined; + let linear = undefined; + let quanto = undefined; + const spot = (type === 'spot'); + const futures = (type === 'futures'); + const settleType = this.safeStringLower (market, 'settleType'); + if (settleType !== undefined) { + inverse = (settleType === 'inverse'); + linear = (settleType === 'vanilla'); + quanto = (settleType === 'quanto'); + } + let symbol = id; + if (type === 'spot') { + symbol = base + '/' + quote; + } + const precision = { + 'amount': this.safeFloat (market, 'lotSize'), + 'price': this.safeFloat (market, 'tickSize'), + }; + result.push ({ + 'id': id, + 'symbol': symbol, + 'base': base, + 'quote': quote, + 'baseId': baseId, + 'quoteId': quoteId, + 'type': type, + 'spot': spot, + 'futures': futures, + 'inverse': inverse, + 'linear': linear, + 'quanto': quanto, + 'precision': precision, + 'info': market, + 'active': active, + 'taker': taker, + 'maker': maker, + 'percentage': false, + 'tierBased': true, + 'limits': { + 'amount': { + 'min': this.safeString (market, 'minQuantity'), + 'max': this.safeString (market, 'maxQuantity'), + }, + 'price': { + 'min': this.safeString (market, 'minPrice'), + 'max': this.safeString (market, 'maxPrice'), + }, + 'cost': { + 'min': undefined, + 'max': undefined, + }, + }, + }); + } + return result; + } + + parseTicker (ticker, market = undefined) { + // + // { + // "t":1610162685342, // timestamp + // "a":"0.00000000", // trading volume in USD in the last 24 hours, futures only + // "c":"435.20000000", // close + // "d":"4.22953489", // change + // "h":"455.04000000", // high + // "l":"412.78000000", // low + // "o":"417.54000000", // open + // "s":"BCHUSDTFP", // market id + // "v":"2031068.00000000", // trading volume in quote currency of last 24 hours + // } + // + const timestamp = this.safeInteger (ticker, 't'); + const marketId = this.safeString (ticker, 's'); + const symbol = this.safeSymbol (marketId, market); + const last = this.safeFloat (ticker, 'c'); + const open = this.safeFloat (ticker, 'o'); + let change = undefined; + let percentage = undefined; + let average = undefined; + if (last !== undefined && open !== undefined) { + change = last - open; + if (open > 0) { + percentage = change / open * 100; + } + average = this.sum (last, open) / 2; + } + const quoteVolume = this.safeFloat (ticker, 'v'); + return { + 'symbol': symbol, + 'timestamp': timestamp, + 'datetime': this.iso8601 (timestamp), + 'high': this.safeFloat (ticker, 'h'), + 'low': this.safeFloat (ticker, 'l'), + 'bid': undefined, + 'bidVolume': undefined, + 'ask': undefined, + 'askVolume': undefined, + 'vwap': undefined, + 'open': open, + 'close': last, + 'last': last, + 'previousClose': undefined, + 'change': change, + 'percentage': percentage, + 'average': average, + 'baseVolume': undefined, + 'quoteVolume': quoteVolume, + 'info': ticker, + }; + } + + async fetchTicker (symbol, params = {}) { + const tickers = await this.fetchTickers (undefined, params); + if (symbol in tickers) { + return tickers[symbol]; + } + throw new BadSymbol (this.id + ' fetchTicker() symbol ' + symbol + ' ticker not found'); + } + + async fetchTickers (symbols = undefined, params = {}) { + await this.loadMarkets (); + const response = await this.publicGetMarketTickers (params); + // + // { + // "e":"tickers", + // "t":1610162685342, + // "tickers":[ + // { + // "a":"0.00000000", + // "c":"435.20000000", + // "d":"4.22953489", + // "h":"455.04000000", + // "l":"412.78000000", + // "o":"417.54000000", + // "s":"BCHUSDTFP", + // "v":"2031068.00000000", + // }, + // ], + // } + // + const tickers = this.safeValue (response, 'tickers', []); + const result = []; + const timestamp = this.safeInteger (response, 't'); + for (let i = 0; i < tickers.length; i++) { + const ticker = this.parseTicker (this.extend (tickers[i], { 't': timestamp })); + result.push (ticker); + } + return this.filterByArray (result, 'symbol', symbols); + } + + async fetchOrderBook (symbol, limit = undefined, params = {}) { + await this.loadMarkets (); + const market = this.market (symbol); + if (limit === undefined) { + limit = 20; + } else { + if ((limit !== 20) && (limit !== 50)) { + throw new BadRequest (this.id + ' fetchOrderBook() limit argument must be undefined, 20 or 50'); + } + } + const request = { + 'symbol': market['id'], + 'level': limit, // required + }; + // + const response = await this.publicGetMarketOrderbook (this.extend (request, params)); + // + // { + // "asks":[ + // ["10823.00000000","0.004000"], + // ["10823.10000000","0.100000"], + // ["10823.20000000","0.010000"] + // ], + // "bids":[ + // ["10821.20000000","0.002000"], + // ["10821.10000000","0.005000"], + // ["10820.40000000","0.013000"] + // ], + // "e":"BTCUSDT@book_50", + // "t":1561543614756 + // } + // + const timestamp = this.safeInteger (response, 't'); // need unix type + return this.parseOrderBook (response, timestamp); + } + + parseTrade (trade, market = undefined) { + // + // public fetchTrades + // + // { + // "p":"9395.50000000", + // "q":"50.000000", + // "t":1592563996718 + // } + // + // private fetchMyTrades + // + // { + // "avgPrice":"1199.8", + // "base":"ETH", + // "clOrdID":null, + // "commission":"0.00002", + // "createTime":"2021-01-11T02:47:51.512Z", + // "cumQty":"0.02", + // "filledOrderID":"1eUD4F5rwK", + // "filledPrice":"1199.8", + // "filledQty":"0.02", + // "leavesQty":"0", + // "oCreateTime":"2021-01-11T02:47:51.377Z", + // "orderID":"1eUD4EHfdU", + // "orderQty":"0.02", + // "orderStatus":3, + // "orderType":1, + // "price":"1198.25", + // "quote":"USDT", + // "rejectCode":null, + // "rejectReason":null, + // "side":1, + // "stopPrice":"0", + // "symbol":"ETHUSDT", + // "taker":true, + // "tradeID":"E04WTIgfmULU", + // "transactTime":"2021-01-11T02:47:51.389Z", + // "updateTime":null, + // "userID":"1362494" + // } + // + let timestamp = this.safeInteger (trade, 't'); + if (timestamp === undefined) { + timestamp = this.parse8601 (this.safeString (trade, 'createTime')); + } + const id = this.safeString2 (trade, 'tid', 'tradeID'); + let symbol = undefined; + const marketId = this.safeString (trade, 'symbol'); + market = this.safeMarket (marketId, market); + if (market !== undefined) { + symbol = market['symbol']; + } + let price = this.safeFloat2 (trade, 'p', 'filledPrice'); + const amount = this.safeFloat2 (trade, 'q', 'filledQty'); + const orderId = this.safeString (trade, 'orderID'); + const isTaker = this.safeValue (trade, 'taker'); + let takerOrMaker = undefined; + if (isTaker !== undefined) { + takerOrMaker = isTaker ? 'taker' : 'maker'; + } + let side = this.safeString (trade, 'side'); + if (side === '1') { + side = 'buy'; + } else if (side === '2') { + side = 'sell'; + } + if (side === undefined) { + side = (price > 0) ? 'buy' : 'sell'; + } + side = (price > 0) ? 'buy' : 'sell'; + price = Math.abs (price); + let cost = undefined; + if ((price !== undefined) && (amount !== undefined)) { + cost = price * amount; + } + const orderType = this.parseOrderType (this.safeString (trade, 'orderType')); + let fee = undefined; + const feeCost = this.safeFloat (trade, 'commission'); + if (feeCost !== undefined) { + let feeCurrency = undefined; + if (market !== undefined) { + if (side === 'buy') { + feeCurrency = market['base']; + } else if (side === 'sell') { + feeCurrency = market['quote']; + } + } + fee = { + 'currency': feeCurrency, + 'cost': feeCost, + }; + } + return { + 'info': trade, + 'id': id, + 'timestamp': timestamp, + 'datetime': this.iso8601 (timestamp), + 'symbol': symbol, + 'type': orderType, + 'side': side, + 'order': orderId, + 'takerOrMaker': takerOrMaker, + 'price': price, + 'amount': amount, + 'cost': cost, + 'fee': fee, + }; + } + + async fetchTrades (symbol, since = undefined, limit = undefined, params = {}) { + await this.loadMarkets (); + const market = this.market (symbol); + limit = (limit === undefined) ? 2000 : limit; + limit = Math.min (limit, 2000); + const request = { + 'symbol': market['id'], + 'limit': limit, + }; + const response = await this.publicGetMarketTrades (request); + // + // { + // "e":"BTCUSDFP@trades", + // "trades": [ + // {"p":"9395.50000000","q":"50.000000","t":1592563996718}, + // {"p":"9395.50000000","q":"50.000000","t":1592563993577}, + // ], + // } + // + const trades = this.safeValue (response, 'trades', []); + return this.parseTrades (trades, market, since, limit); + } + + parseOHLCV (ohlcv, market = undefined) { + // + // [ + // 0.042398, // 0 open + // 0.042684, // 1 high + // 0.042366, // 2 low + // 0.042386, // 3 close + // 0.93734243, // 4 volume + // 1611514800, // 5 timestamp + // ] + // + return [ + this.safeTimestamp (ohlcv, 5), + this.safeFloat (ohlcv, 0), + this.safeFloat (ohlcv, 1), + this.safeFloat (ohlcv, 2), + this.safeFloat (ohlcv, 3), + this.safeFloat (ohlcv, 4), + ]; + } + + async fetchOHLCV (symbol, timeframe = '1h', since = undefined, limit = undefined, params = {}) { + await this.loadMarkets (); + const market = this.market (symbol); + const request = { + // 'limit': limit, // if set counts from now into the past + 'symbol': market['id'], + 'timeFrame': this.timeframes[timeframe], + }; + limit = (limit === undefined) ? 500 : limit; + const duration = this.parseTimeframe (timeframe); + if (since === undefined) { + const end = this.seconds (); + request['start'] = end - duration * limit; + request['end'] = end; + } else { + const start = parseInt (since / 1000); + request['start'] = start; + request['end'] = this.sum (start, duration * limit); + } + const response = await this.publicGetMarketHistoryCandles (this.extend (request, params)); + // + // { + // "data":[ + // [0.042398,0.042684,0.042366,0.042386,0.93734243,1611514800], + // [0.042386,0.042602,0.042234,0.042373,1.01925239,1611518400], + // [0.042373,0.042558,0.042362,0.042389,0.93801705,1611522000], + // ], + // "success":true, + // "t":1611875157 + // } + // + const data = this.safeValue (response, 'data', []); + return this.parseOHLCVs (data, market, timeframe, since, limit); + } + + async fetchBalance (params = {}) { + await this.loadMarkets (); + const defaultType = this.safeString2 (this.options, 'fetchBalance', 'defaultType', 'spot'); + const type = this.safeString (params, 'type', defaultType); + const types = { + 'spot': 'SPTP', + 'future': 'FUTP', + 'otc': 'F2CP', + 'saving': 'VLTP', + }; + const purseType = this.safeString (types, type, type); + const request = { + 'purseType': purseType, + }; + params = this.omit (params, 'type'); + const response = await this.privateGetAccountBalances (this.extend (request, params)); + // + // { + // "code":1, + // "data":[ + // { + // "purseType":"FUTP", + // "currency":"BTC", + // "available":"0.41000000", + // "unavailable":"0.00000000" + // }, + // { + // "purseType":"FUTP", + // "currency":"USDT", + // "available":"0.21000000", + // "unvaliable":"0.00000000" + // } + // ] + // "message":"success", + // "ts":1573530401020 + // } + // + const data = this.safeValue (response, 'data'); + const result = { 'info': response }; + for (let i = 0; i < data.length; i++) { + const balance = data[i]; + const balanceType = this.safeString (balance, 'purseType'); + if (balanceType === purseType) { + const currencyId = this.safeString (balance, 'currency'); + const code = this.safeCurrencyCode (currencyId); + const account = this.account (); + account['free'] = this.safeFloat (balance, 'available'); + account['used'] = this.safeFloat (balance, 'unavailable'); + result[code] = account; + } + } + return this.parseBalance (result); + } + + async createOrder (symbol, type, side, amount, price = undefined, params = {}) { + let orderType = type.toUpperCase (); + const orderSide = side.toUpperCase (); + await this.loadMarkets (); + const market = this.market (symbol); + const request = { + // 'orderType': orderType, // MARKET, LIMIT, STOP, STOP-LIMIT + 'symbol': market['id'], + 'orderQty': this.amountToPrecision (symbol, amount), + 'side': orderSide, + // 'stopPrice': this.priceToPrecision (symbol, stopPrice), + // 'clOrdID': clientOrderId, // up to 20 chars, lowercase and uppercase letters only + // 'timeInForce': 'GTC', // GTC, IOC, FOK, default is GTC + // 'execInst': 'Post-Only', // the only value supported by the exchange, futures-only + }; + const timeInForce = this.safeString (params, 'timeInForce'); + if (timeInForce !== undefined) { + request['timeInForce'] = timeInForce; + params = this.omit (params, 'timeInForce'); + } + const clientOrderId = this.safeString2 (params, 'clOrdID', 'clientOrderId'); + if (clientOrderId !== undefined) { + request['clOrdID'] = clientOrderId; + params = this.omit (params, [ 'clOrdID', 'clientOrderId' ]); + } + const stopPrice = this.safeFloat (params, 'stopPrice'); + if (stopPrice === undefined) { + if ((orderType === 'STOP-LIMIT') || (orderType === 'STOP')) { + throw new ArgumentsRequired (this.id + ' createOrder() requires a stopPrice parameter for ' + orderType + ' orders'); + } + } else { + if (orderType === 'LIMIT') { + orderType = 'STOP-LIMIT'; + } else if (orderType === 'MARKET') { + orderType = 'STOP'; + } + request['stopPrice'] = this.priceToPrecision (symbol, stopPrice); + params = this.omit (params, 'stopPrice'); + } + if (orderType === 'LIMIT' || orderType === 'STOP-LIMIT') { + request['price'] = this.priceToPrecision (symbol, price); + } + request['orderType'] = orderType; + let method = undefined; + if (market['spot']) { + method = 'privatePostSpotOrders'; + } else if (market['futures']) { + method = 'privatePostFuturesOrders'; + } + const response = await this[method] (this.extend (request, params)); + // + // spot + // + // { + // "code":1, + // "data":{ + // "symbol":"ETHUSDT", + // "orderType":2, + // "avgPrice":"0", + // "execInst":null, + // "orderStatus":0, + // "userID":"1362494", + // "quote":"USDT", + // "rejectReason":null, + // "rejectCode":null, + // "price":"1500", + // "orderQty":"1", + // "commission":"0", + // "id":"268323430253735936", + // "timeInForce":1, + // "isTriggered":false, + // "side":2, + // "orderID":"1eO51MDSpQ", + // "leavesQty":"0", + // "cumQty":"0", + // "updateTime":null, + // "lastQty":"0", + // "clOrdID":null, + // "stopPrice":null, + // "createTime":null, + // "transactTime":null, + // "base":"ETH", + // "lastPrice":"0" + // }, + // "message":"success", + // "ts":1610245290980 + // } + // + // futures + // + // { + // "code":1, + // "data":{ + // "liqType":0, + // "symbol":"ETHUSDTFP", + // "orderType":2, + // "leverage":"1", + // "marketPrice":"1318.3150000000", + // "code":"FP", + // "avgPrice":"0", + // "execInst":null, + // "orderStatus":0, + // "userID":"1362494", + // "quote":"USDT", + // "rejectReason":null, + // "rejectCode":null, + // "price":"500", + // "orderQty":"1", + // "commission":"0", + // "id":"268346885133053953", + // "timeInForce":1, + // "isTriggered":false, + // "side":1, + // "orderID":"1eOuPUAAkq", + // "leavesQty":"1", + // "cumQty":"0", + // "updateTime":null, + // "lastQty":null, + // "clOrdID":null, + // "stopPrice":null, + // "createTime":null, + // "transactTime":null, + // "settleType":"VANILLA", + // "base":"ETH", + // "lastPrice":"0" + // }, + // "message":"success", + // "ts":1610250883059 + // } + // + const data = this.safeValue (response, 'data', {}); + return this.parseOrder (data, market); + } + + async editOrder (id, symbol, type, side, amount, price = undefined, params = {}) { + await this.loadMarkets (); + const market = this.market (symbol); + const request = { + 'orderID': id, + // 'orderQty': this.amountToPrecision (symbol, amount), + // 'price': this.priceToPrecision (symbol, price), + // 'stopPrice': this.priceToPrecision (symbol, stopPrice), + }; + const stopPrice = this.safeFloat (params, 'stopPrice'); + if (stopPrice !== undefined) { + request['stopPrice'] = this.priceToPrecision (symbol, stopPrice); + params = this.omit (params, 'stopPrice'); + } + if (price !== undefined) { + request['price'] = this.priceToPrecision (symbol, price); + } + if (amount !== undefined) { + request['orderQty'] = this.amountToPrecision (symbol, amount); + } + let method = undefined; + if (market['spot']) { + method = 'privatePutSpotOrders'; + } else if (market['futures']) { + method = 'privatePutFuturesOrders'; + } + const response = await this[method] (this.extend (request, params)); + // + // spot + // + // { + // "code":1, + // "data":{ + // "symbol":"ETHUSDT", + // "orderType":2, + // "avgPrice":"0", + // "execInst":null, + // "orderStatus":0, + // "userID":"1362494", + // "quote":"USDT", + // "rejectReason":null, + // "rejectCode":null, + // "price":"1500", + // "orderQty":"1", + // "commission":"0", + // "id":"268323430253735936", + // "timeInForce":1, + // "isTriggered":false, + // "side":2, + // "orderID":"1eO51MDSpQ", + // "leavesQty":"0", + // "cumQty":"0", + // "updateTime":null, + // "lastQty":"0", + // "clOrdID":null, + // "stopPrice":null, + // "createTime":null, + // "transactTime":null, + // "base":"ETH", + // "lastPrice":"0" + // }, + // "message":"success", + // "ts":1610245290980 + // } + // + // futures + // + // { + // "code":1, + // "data":{ + // "liqType":0, + // "symbol":"ETHUSDTFP", + // "orderType":2, + // "leverage":"1", + // "marketPrice":"1318.3150000000", + // "code":"FP", + // "avgPrice":"0", + // "execInst":null, + // "orderStatus":0, + // "userID":"1362494", + // "quote":"USDT", + // "rejectReason":null, + // "rejectCode":null, + // "price":"500", + // "orderQty":"1", + // "commission":"0", + // "id":"268346885133053953", + // "timeInForce":1, + // "isTriggered":false, + // "side":1, + // "orderID":"1eOuPUAAkq", + // "leavesQty":"1", + // "cumQty":"0", + // "updateTime":null, + // "lastQty":null, + // "clOrdID":null, + // "stopPrice":null, + // "createTime":null, + // "transactTime":null, + // "settleType":"VANILLA", + // "base":"ETH", + // "lastPrice":"0" + // }, + // "message":"success", + // "ts":1610250883059 + // } + // + const data = this.safeValue (response, 'data', {}); + return this.parseOrder (data, market); + } + + async cancelOrder (id, symbol = undefined, params = {}) { + await this.loadMarkets (); + const request = { + 'orderID': id, + }; + let method = undefined; + const defaultType = this.safeString2 (this.options, 'cancelOrder', 'defaultType', 'spot'); + let type = this.safeString (params, 'type', defaultType); + params = this.omit (params, 'type'); + let market = undefined; + if (symbol !== undefined) { + market = this.market (symbol); + type = market['type']; + } + if (type === 'spot') { + method = 'privateDeleteSpotOrdersCancelOrderID'; + } else if (type === 'futures') { + method = 'privateDeleteFuturesOrdersCancelOrderID'; + } + const response = await this[method] (this.extend (request, params)); + // + // spot + // + // { + // "code":1, + // "data":{ + // "avgPrice":"0", + // "base":"BTC", + // "clOrdID":"aax", + // "commission":"0", + // "createTime":"2019-11-12T03:46:41Z", + // "cumQty":"0", + // "id":"114330021504606208", + // "isTriggered":false, + // "lastPrice":"0", + // "lastQty":"0", + // "leavesQty":"0", + // "orderID":"wJ4L366KB", + // "orderQty":"0.05", + // "orderStatus":1, + // "orderType":2, + // "price":"8000", + // "quote":"USDT", + // "rejectCode":0, + // "rejectReason":null, + // "side":1, + // "stopPrice":"0", + // "symbol":"BTCUSDT", + // "transactTime":null, + // "updateTime":"2019-11-12T03:46:41Z", + // "timeInForce":1, + // "userID":"216214" + // }, + // "message":"success", + // "ts":1573530402029 + // } + // + // futures + // + // { + // "code":1, + // "data":{ + // "avgPrice":"0", + // "base":"BTC", + // "clOrdID":"aax_futures", + // "code":"FP", + // "commission":"0", + // "createTime":"2019-11-12T06:48:58Z", + // "cumQty":"0", + // "id":"114375893764395008", + // "isTriggered":false, + // "lastPrice":"0", + // "lastQty":null, + // "leavesQty":"300", + // "leverage":"1", + // "liqType":0, + // "marketPrice":"8760.75", + // "orderID":"wJTewQc81", + // "orderQty":"300", + // "orderStatus":1, + // "orderType":2, + // "price":"8000", + // "quote":"USD", + // "rejectCode":0, + // "rejectReason":null, + // "settleType":"INVERSE", + // "side":1, + // "stopPrice":"0", + // "symbol":"BTCUSDFP", + // "transactTime":"2019-11-12T06:48:58Z", + // "updateTime":"2019-11-12T06:48:58Z", + // "timeInForce":1, + // "execInst": "", + // "userID":"216214" + // }, + // "message":"success", + // "ts":1573541642970 + // } + // + const data = this.safeValue (response, 'data', {}); + return this.parseOrder (data, market); + } + + async cancelAllOrders (symbol = undefined, params = {}) { + if (symbol === undefined) { + throw new ArgumentsRequired (this.id + ' cancelAllOrders() requires a symbol argument'); + } + await this.loadMarkets (); + const market = this.market (symbol); + const request = { + 'symbol': market['id'], + }; + let method = undefined; + if (market['spot']) { + method = 'privateDeleteSpotOrdersCancelAll'; + } else if (market['futures']) { + method = 'privateDeleteFuturesOrdersCancelAll'; + } + const response = await this[method] (this.extend (request, params)); + // + // { + // "code":1, + // "data":[ + // "vBC9rXsEE", + // "vBCc46OI0" + // ], + // "message":"success", + // "ts":1572597435470 + // } + // + return response; + } + + async fetchOrder (id, symbol = undefined, params = {}) { + await this.loadMarkets (); + const defaultType = this.safeString2 (this.options, 'fetchOrder', 'defaultType', 'spot'); + params['type'] = this.safeString (params, 'type', defaultType); + const request = {}; + const clientOrderId = this.safeString2 (params, 'clOrdID', 'clientOrderId'); + if (clientOrderId === undefined) { + request['orderID'] = id; + } else { + request['clOrdID'] = clientOrderId; + params = this.omit (params, [ 'clOrdID', 'clientOrderId' ]); + } + const orders = await this.fetchOrders (symbol, undefined, undefined, this.extend (request, params)); + const order = this.safeValue (orders, 0); + if (order === undefined) { + if (clientOrderId === undefined) { + throw new OrderNotFound (this.id + ' fetchOrder() could not find order id ' + id); + } else { + throw new OrderNotFound (this.id + ' fetchOrder() could not find order clientOrderID ' + clientOrderId); + } + } + return order; + } + + async fetchOpenOrders (symbol = undefined, since = undefined, limit = undefined, params = {}) { + await this.loadMarkets (); + const request = { + // 'pageNum': '1', + // 'pageSize': '10', + // 'symbol': market['id'], + // 'orderID': id, + // 'side': 'undefined', // BUY, SELL + // 'clOrdID': clientOrderId, + }; + const defaultType = this.safeString2 (this.options, 'fetchOpenOrders', 'defaultType', 'spot'); + let type = this.safeString (params, 'type', defaultType); + params = this.omit (params, 'type'); + let market = undefined; + if (symbol !== undefined) { + market = this.market (symbol); + request['symbol'] = market['id']; + type = market['type']; + } + const clientOrderId = this.safeString2 (params, 'clOrdID', 'clientOrderId'); + if (clientOrderId !== undefined) { + request['clOrdID'] = clientOrderId; + params = this.omit (params, [ 'clOrdID', 'clientOrderId' ]); + } + let method = undefined; + if (type === 'spot') { + method = 'privateGetSpotOpenOrders'; + } else if (type === 'futures') { + method = 'privateGetFuturesOpenOrders'; + } + if (limit !== undefined) { + request['pageSize'] = limit; // default 10 + } + const response = await this[method] (this.extend (request, params)); + // + // spot + // + // { + // "code":1, + // "data":{ + // "total":19, + // "pageSize":10, + // "list":[ + // { + // "orderType":2, + // "symbol":"BTCUSDT", + // "avgPrice":"0", + // "orderStatus":0, + // "userID":"7225", + // "quote":"USDT", + // "rejectReason":null, + // "rejectCode":null, + // "price":"0", + // "orderQty":"0.002", + // "commission":"0", + // "id":"110419975166304256", + // "isTriggered":null, + // "side":1, + // "orderID":"vBGlDcLwk", + // "cumQty":"0", + // "leavesQty":"0", + // "updateTime":null, + // "clOrdID":"0001", + // "lastQty":"0", + // "stopPrice":"0", + // "createTime":"2019-11-01T08:49:33Z", + // "transactTime":null, + // "timeInForce":1, + // "base":"BTC", + // "lastPrice":"0" + // } + // ], + // "pageNum":1 + // }, + // "message":"success", + // "ts":1572598173682 + // } + // + // futures + // + // { + // "code":1, + // "data":{ + // "list":[ + // { + // "avgPrice":"8768.99999999484997", + // "base":"BTC", + // "clOrdID":null, + // "code":"FP", + // "commission":"0.00000913", + // "createTime":"2019-11-12T07:05:52.000Z, + // "cumQty":"100", + // "id":"114380149603028993", + // "isTriggered":false, + // "lastPrice":"8769", + // "lastQty":"100", + // "leavesQty":"0", + // "leverage":"1", + // "liqType":1, + // "marketPrice":"8769.75", + // "orderID":"wJXURIFBT", + // "orderQty":"100", + // "orderStatus":3, + // "orderType":1, + // "price":"8769.75", + // "quote":"USD", + // "rejectCode":0, + // "rejectReason":null, + // "settleType":"INVERSE", + // "side":2, + // "stopPrice":"0", + // "symbol":"BTCUSDFP", + // "transactTime":"2019-11-12T07:05:52.000Z, + // "updateTime":"2019-11-12T07:05:52.000Z, + // "timeInForce":1, + // "execInst": "", + // "userID":"216214" + // }, + // ], + // "pageNum":1, + // "pageSize":10, + // "total":21 + // }, + // "message":"success", + // "ts":1573546960172 + // } + // + const data = this.safeValue (response, 'data', {}); + const orders = this.safeValue (data, 'list', []); + return this.parseOrders (orders, market, since, limit); + } + + async fetchClosedOrders (symbol = undefined, since = undefined, limit = undefined, params = {}) { + const request = { + 'orderStatus': '2', // 1 new, 2 filled, 3 canceled + }; + return await this.fetchOrders (symbol, since, limit, this.extend (request, params)); + } + + async fetchCanceledOrders (symbol = undefined, since = undefined, limit = undefined, params = {}) { + const request = { + 'orderStatus': '3', // 1 new, 2 filled, 3 canceled + }; + return await this.fetchOrders (symbol, since, limit, this.extend (request, params)); + } + + async fetchOrders (symbol = undefined, since = undefined, limit = undefined, params = {}) { + await this.loadMarkets (); + const request = { + // 'pageNum': '1', + // 'pageSize': '10', + // 'symbol': market['id'], + // 'orderID': id, + // 'base': market['baseId'], + // 'quote': market['quoteId'], + // 'orderStatus': undefined, // 1 new, 2 filled, 3 canceled + // 'startDate': this.ymd (since), + // 'endDate': this.ymd (this.milliseconds()), + // 'orderType': undefined, // MARKET, LIMIT, STOP, STOP-LIMIT + // 'side': 'undefined', // BUY, SELL + // 'clOrdID': clientOrderId, + }; + let method = undefined; + const defaultType = this.safeString2 (this.options, 'fetchOrders', 'defaultType', 'spot'); + let type = this.safeString (params, 'type', defaultType); + params = this.omit (params, 'type'); + let market = undefined; + if (symbol !== undefined) { + market = this.market (symbol); + request['symbol'] = market['id']; + type = market['type']; + } + if (type === 'spot') { + method = 'privateGetSpotOrders'; + } else if (type === 'futures') { + method = 'privateGetFuturesOrders'; + } + const clientOrderId = this.safeString2 (params, 'clOrdID', 'clientOrderId'); + if (clientOrderId !== undefined) { + request['clOrdID'] = clientOrderId; + params = this.omit (params, [ 'clOrdID', 'clientOrderId' ]); + } + if (limit !== undefined) { + request['pageSize'] = limit; // default 10 + } + if (since !== undefined) { + request['startDate'] = this.ymd (since); + } + const response = await this[method] (this.extend (request, params)); + // + // spot + // + // { + // "code":1, + // "data":{ + // "total":19, + // "pageSize":10, + // "list":[ + // { + // "orderType":2, + // "symbol":"BTCUSDT", + // "avgPrice":"0", + // "orderStatus":0, + // "userID":"7225", + // "quote":"USDT", + // "rejectReason":null, + // "rejectCode":null, + // "price":"0", + // "orderQty":"0.002", + // "commission":"0", + // "id":"110419975166304256", + // "isTriggered":null, + // "side":1, + // "orderID":"vBGlDcLwk", + // "cumQty":"0", + // "leavesQty":"0", + // "updateTime":null, + // "clOrdID":"0001", + // "lastQty":"0", + // "stopPrice":"0", + // "createTime":"2019-11-01T08:49:33Z", + // "transactTime":null, + // "timeInForce":1, + // "base":"BTC", + // "lastPrice":"0" + // } + // ], + // "pageNum":1 + // }, + // "message":"success", + // "ts":1572598173682 + // } + // + // futures + // + // { + // "code":1, + // "data":{ + // "list":[ + // { + // "avgPrice":"8768.99999999484997", + // "base":"BTC", + // "clOrdID":null, + // "code":"FP", + // "commission":"0.00000913", + // "createTime":"2019-11-12T07:05:52.000Z, + // "cumQty":"100", + // "id":"114380149603028993", + // "isTriggered":false, + // "lastPrice":"8769", + // "lastQty":"100", + // "leavesQty":"0", + // "leverage":"1", + // "liqType":1, + // "marketPrice":"8769.75", + // "orderID":"wJXURIFBT", + // "orderQty":"100", + // "orderStatus":3, + // "orderType":1, + // "price":"8769.75", + // "quote":"USD", + // "rejectCode":0, + // "rejectReason":null, + // "settleType":"INVERSE", + // "side":2, + // "stopPrice":"0", + // "symbol":"BTCUSDFP", + // "transactTime":"2019-11-12T07:05:52.000Z, + // "updateTime":"2019-11-12T07:05:52.000Z, + // "timeInForce":1, + // "execInst": "", + // "userID":"216214" + // }, + // ], + // "pageNum":1, + // "pageSize":10, + // "total":21 + // }, + // "message":"success", + // "ts":1573546960172 + // } + // + const data = this.safeValue (response, 'data', {}); + const orders = this.safeValue (data, 'list', []); + return this.parseOrders (orders, market, since, limit); + } + + parseOrderStatus (status) { + const statuses = { + '0': 'open', // pending new + '1': 'open', // new + '2': 'open', // partially-filled + '3': 'closed', // filled + '4': 'canceled', // cancel-reject + '5': 'canceled', // canceled + '6': 'rejected', // rejected + '10': 'expired', // expired + '11': 'rejected', // business-reject + }; + return this.safeString (statuses, status, status); + } + + parseOrderType (status) { + const statuses = { + '1': 'market', + '2': 'limit', + '3': 'stop', + '4': 'stop-limit', + '7': 'stop-loss', + '8': 'take-profit', + }; + return this.safeString (statuses, status, status); + } + + parseTimeInForce (timeInForce) { + const timeInForces = { + '1': 'GTC', + '3': 'IOC', + '4': 'FOK', + }; + return this.safeString (timeInForces, timeInForce, timeInForce); + } + + parseOrder (order, market = undefined) { + // + // { + // "avgPrice":"8768.99999999484997", + // "base":"BTC", + // "clOrdID":null, + // "code":"FP", // futures only + // "commission":"0.00000913", + // "createTime":"2019-11-12T07:05:52.000Z, + // "cumQty":"100", + // "id":"114380149603028993", // futures only + // "isTriggered":false, + // "lastPrice":"8769", + // "lastQty":"100", + // "leavesQty":"0", + // "leverage":"1", // futures only + // "liqType":1, // futures only + // "marketPrice":"8769.75", // futures only + // "orderID":"wJXURIFBT", + // "orderQty":"100", + // "orderStatus":3, + // "orderType":1, + // "price":"8769.75", + // "quote":"USD", + // "rejectCode":0, + // "rejectReason":null, + // "settleType":"INVERSE", // futures only + // "side":2, + // "stopPrice":"0", + // "symbol":"BTCUSDFP", + // "transactTime":"2019-11-12T07:05:52.000Z, + // "updateTime":"2019-11-12T07:05:52.000Z, + // "timeInForce":1, + // "execInst": "", + // "userID":"216214" + // } + // + // sometimes the timestamp is returned in milliseconds + let timestamp = this.safeValue (order, 'createTime'); + if (typeof timestamp === 'string') { + timestamp = this.parse8601 (timestamp); + } + const status = this.parseOrderStatus (this.safeString (order, 'orderStatus')); + const type = this.parseOrderType (this.safeString (order, 'orderType')); + let side = this.safeString (order, 'side'); + if (side === '1') { + side = 'buy'; + } else if (side === '2') { + side = 'sell'; + } + const id = this.safeString (order, 'orderID'); + const clientOrderId = this.safeString (order, 'clOrdID'); + const marketId = this.safeString (order, 'symbol'); + market = this.safeMarket (marketId, market); + const symbol = market['symbol']; + const price = this.safeFloat (order, 'price'); + const stopPrice = this.safeFloat (order, 'stopPrice'); + const timeInForce = this.parseTimeInForce (this.safeString (order, 'timeInForce')); + const execInst = this.safeString (order, 'execInst'); + const postOnly = (execInst === 'Post-Only'); + const average = this.safeFloat (order, 'avgPrice'); + const amount = this.safeFloat (order, 'orderQty'); + const filled = this.safeFloat (order, 'cumQty'); + const remaining = this.safeString (order, 'leavesQty'); + let cost = undefined; + let lastTradeTimestamp = undefined; + if (filled !== undefined) { + if (price !== undefined) { + cost = filled * price; + } + if (filled > 0) { + lastTradeTimestamp = this.safeValue (order, 'transactTime'); + if (typeof lastTradeTimestamp === 'string') { + lastTradeTimestamp = this.parse8601 (lastTradeTimestamp); + } + } + } + let fee = undefined; + const feeCost = this.safeFloat (order, 'commission'); + if (feeCost !== undefined) { + let feeCurrency = undefined; + if (market !== undefined) { + if (side === 'buy') { + feeCurrency = market['base']; + } else if (side === 'sell') { + feeCurrency = market['quote']; + } + } + fee = { + 'currency': feeCurrency, + 'cost': feeCost, + }; + } + return { + 'id': id, + 'info': order, + 'clientOrderId': clientOrderId, + 'timestamp': timestamp, + 'datetime': this.iso8601 (timestamp), + 'lastTradeTimestamp': lastTradeTimestamp, + 'status': status, + 'symbol': symbol, + 'type': type, + 'timeInForce': timeInForce, + 'postOnly': postOnly, + 'side': side, + 'price': price, + 'stopPrice': stopPrice, + 'average': average, + 'amount': amount, + 'filled': filled, + 'remaining': remaining, + 'cost': cost, + 'trades': undefined, + 'fee': fee, + }; + } + + async fetchMyTrades (symbol = undefined, since = undefined, limit = undefined, params = {}) { + await this.loadMarkets (); + const request = { + // 'pageNum': '1', + // 'pageSize': '10', + // 'symbol': market['id'], + // 'orderID': id, + // 'base': market['baseId'], + // 'quote': market['quoteId'], + // 'startDate': this.ymd (since), + // 'endDate': this.ymd (this.milliseconds()), + // 'orderType': undefined, // MARKET, LIMIT, STOP, STOP-LIMIT + // 'side': 'undefined', // BUY, SELL + }; + let method = undefined; + const defaultType = this.safeString2 (this.options, 'fetchMyTrades', 'defaultType', 'spot'); + let type = this.safeString (params, 'type', defaultType); + params = this.omit (params, 'type'); + let market = undefined; + if (symbol !== undefined) { + market = this.market (symbol); + request['symbol'] = market['id']; + type = market['type']; + } + if (type === 'spot') { + method = 'privateGetSpotTrades'; + } else if (type === 'futures') { + method = 'privateGetFuturesTrades'; + } + if (limit !== undefined) { + request['pageSize'] = limit; // default 10 + } + if (since !== undefined) { + request['startDate'] = this.ymd (since); + } + const response = await this[method] (this.extend (request, params)); + // + // { + // "code":1, + // "data":{ + // "list":[ + // { + // "avgPrice":"1199.8", + // "base":"ETH", + // "clOrdID":null, + // "commission":"0.00002", + // "createTime":"2021-01-11T02:47:51.512Z", + // "cumQty":"0.02", + // "filledOrderID":"1eUD4F5rwK", + // "filledPrice":"1199.8", + // "filledQty":"0.02", + // "leavesQty":"0", + // "oCreateTime":"2021-01-11T02:47:51.377Z", + // "orderID":"1eUD4EHfdU", + // "orderQty":"0.02", + // "orderStatus":3, + // "orderType":1, + // "price":"1198.25", + // "quote":"USDT", + // "rejectCode":null, + // "rejectReason":null, + // "side":1, + // "stopPrice":"0", + // "symbol":"ETHUSDT", + // "taker":true, + // "tradeID":"E04WTIgfmULU", + // "transactTime":"2021-01-11T02:47:51.389Z", + // "updateTime":null, + // "userID":"1362494" + // } + // ], + // "pageNum":1, + // "pageSize":10, + // "total":1 + // }, + // "message":"success", + // "ts":1610333278042 + // } + // + const data = this.safeValue (response, 'data', {}); + const trades = this.safeValue (data, 'list', []); + return this.parseTrades (trades, market, since, limit); + } + + async fetchDepositAddress (code, params = {}) { + await this.loadMarkets (); + const currency = this.currency (code); + const request = { + 'currency': currency['id'], + // 'network': undefined, // 'ERC20 + }; + const response = await this.privateGetAccountDepositAddress (this.extend (request, params)); + // + // { + // "code":1, + // "data":{ + // "address":"0x080c5c667381404cca9be0be9a04b2e47691ff86", + // "tag":null, + // "currency":"USDT", + // "network":"ERC20" + // }, + // "message":"success", + // "ts":1610270465132 + // } + // + const data = this.safeValue (response, 'data', {}); + return this.parseDepositAddress (data, currency); + } + + parseDepositAddress (depositAddress, currency = undefined) { + // + // { + // "address":"0x080c5c667381404cca9be0be9a04b2e47691ff86", + // "tag":null, + // "currency":"USDT", + // "network":"ERC20" + // } + // + const address = this.safeString (depositAddress, 'address'); + const tag = this.safeString (depositAddress, 'tag'); + const currencyId = this.safeString (depositAddress, 'currency'); + const code = this.safeCurrencyCode (currencyId); + return { + 'info': depositAddress, + 'code': code, + 'address': address, + 'tag': tag, + }; + } + + nonce () { + return this.milliseconds (); + } + + sign (path, api = 'public', method = 'GET', params = {}, headers = undefined, body = undefined) { + let url = '/' + this.implodeParams (path, params); + const query = this.omit (params, this.extractParams (path)); + if (api === 'v1') { + if (Object.keys (query).length) { + url += '?' + this.urlencode (query); + } + } else { + url = '/' + this.version + url; + if (api === 'public') { + if (Object.keys (query).length) { + url += '?' + this.urlencode (query); + } + } else if (api === 'private') { + this.checkRequiredCredentials (); + const nonce = this.nonce ().toString (); + headers = { + 'X-ACCESS-KEY': this.apiKey, + 'X-ACCESS-NONCE': nonce, + }; + let auth = nonce + ':' + method; + if (method === 'GET') { + if (Object.keys (query).length) { + url += '?' + this.urlencode (query); + } + auth += url; + } else { + headers['Content-Type'] = 'application/json'; + body = this.json (query); + auth += url + body; + } + const signature = this.hmac (this.encode (auth), this.encode (this.secret)); + headers['X-ACCESS-SIGN'] = signature; + } + } + url = this.implodeParams (this.urls['api'][api], { 'hostname': this.hostname }) + url; + return { 'url': url, 'method': method, 'body': body, 'headers': headers }; + } + + handleErrors (code, reason, url, method, headers, body, response, requestHeaders, requestBody) { + if (response === undefined) { + return; // fallback to default error handler + } + // + // {"code":40102,"message":"Unauthorized(invalid key)"} + // + const errorCode = this.safeString (response, 'code'); + if ((errorCode !== undefined) && (errorCode !== '1')) { + const feedback = this.id + ' ' + this.json (response); + this.throwExactlyMatchedException (this.exceptions['exact'], errorCode, feedback); + this.throwBroadlyMatchedException (this.exceptions['broad'], body, feedback); + } + } +}; diff --git a/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/acx.js b/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/acx.js index 011921fa4..e10ec85ca 100644 --- a/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/acx.js +++ b/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/acx.js @@ -346,6 +346,7 @@ module.exports = class acx extends Exchange { 'symbol': symbol, 'type': type, 'timeInForce': undefined, + 'postOnly': undefined, 'side': side, 'price': this.safeFloat (order, 'price'), 'stopPrice': undefined, diff --git a/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/aofex.js b/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/aofex.js index fb5e7f4a3..7899f09d5 100644 --- a/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/aofex.js +++ b/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/aofex.js @@ -132,6 +132,9 @@ module.exports = class aofex extends Exchange { 'show_all': '0', // '1' to show zero balances }, }, + 'commonCurrencies': { + 'CPC': 'Consensus Planet Coin', + }, }); } @@ -798,6 +801,7 @@ module.exports = class aofex extends Exchange { 'symbol': market['symbol'], 'type': type, 'timeInForce': undefined, + 'postOnly': undefined, 'side': side, 'price': price, 'stopPrice': undefined, diff --git a/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/base/Exchange.js b/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/base/Exchange.js index f231581ed..eb017b5bf 100644 --- a/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/base/Exchange.js +++ b/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/base/Exchange.js @@ -411,20 +411,20 @@ module.exports = class Exchange { if (!!enabled) { // eslint-disable-line no-extra-boolean-cast if ('test' in this.urls) { if (typeof this.urls['api'] === 'string') { - this.urls['api_backup'] = this.urls['api'] + this.urls['apiBackup'] = this.urls['api'] this.urls['api'] = this.urls['test'] } else { - this.urls['api_backup'] = clone (this.urls['api']) + this.urls['apiBackup'] = clone (this.urls['api']) this.urls['api'] = clone (this.urls['test']) } } else { throw new NotSupported (this.id + ' does not have a sandbox URL') } - } else if ('api_backup' in this.urls) { + } else if ('apiBackup' in this.urls) { if (typeof this.urls['api'] === 'string') { - this.urls['api'] = this.urls['api_backup'] + this.urls['api'] = this.urls['apiBackup'] } else { - this.urls['api'] = clone (this.urls['api_backup']) + this.urls['api'] = clone (this.urls['apiBackup']) } } } @@ -576,34 +576,31 @@ module.exports = class Exchange { handleRestResponse (response, url, method = 'GET', requestHeaders = undefined, requestBody = undefined) { return response.text ().then ((responseBody) => { - - const json = this.parseJson (responseBody) - const responseHeaders = this.getResponseHeaders (response) - + const bodyText = this.onRestResponse (response.status, response.statusText, url, method, responseHeaders, responseBody, requestHeaders, requestBody); + const json = this.parseJson (bodyText) if (this.enableLastResponseHeaders) { this.last_response_headers = responseHeaders } - if (this.enableLastHttpResponse) { this.last_http_response = responseBody } - if (this.enableLastJsonResponse) { this.last_json_response = json } - if (this.verbose) { this.print ("handleRestResponse:\n", this.id, method, url, response.status, response.statusText, "\nResponse:\n", responseHeaders, "\n", responseBody, "\n") } - this.handleErrors (response.status, response.statusText, url, method, responseHeaders, responseBody, json, requestHeaders, requestBody) this.handleHttpStatusCode (response.status, response.statusText, url, method, responseBody) - return json || responseBody }) } + onRestResponse (statusCode, statusText, url, method, responseHeaders, responseBody, requestHeaders, requestBody) { + return responseBody.trim ().replace (/:(\d{15,}),/g, ':"$1",'); + } + setMarkets (markets, currencies = undefined) { const values = Object.values (markets).map ((market) => deepExtend ({ 'limits': this.limits, @@ -903,6 +900,10 @@ module.exports = class Exchange { return symbols.map ((symbol) => this.marketId (symbol)) } + currencyIds (codes) { + return codes.map ((code) => this.currencyId (code)) + } + symbol (symbol) { return this.market (symbol).symbol || symbol } @@ -1036,7 +1037,7 @@ module.exports = class Exchange { array = array.filter ((entry) => entry[key] >= since) } if (limit !== undefined && limit !== null) { - array = (tail && !sinceIsDefined) ? array.slice (-limit) : array.slice (0, limit) + array = tail ? array.slice (-limit) : array.slice (0, limit) } return array } @@ -1054,18 +1055,18 @@ module.exports = class Exchange { } if (limit !== undefined && limit !== null) { - array = (tail && !sinceIsDefined) ? array.slice (-limit) : array.slice (0, limit) + array = tail ? array.slice (-limit) : array.slice (0, limit) } return array } - filterBySymbolSinceLimit (array, symbol = undefined, since = undefined, limit = undefined) { - return this.filterByValueSinceLimit (array, 'symbol', symbol, since, limit) + filterBySymbolSinceLimit (array, symbol = undefined, since = undefined, limit = undefined, tail = false) { + return this.filterByValueSinceLimit (array, 'symbol', symbol, since, limit, 'timestamp', tail) } - filterByCurrencySinceLimit (array, code = undefined, since = undefined, limit = undefined) { - return this.filterByValueSinceLimit (array, 'currency', code, since, limit) + filterByCurrencySinceLimit (array, code = undefined, since = undefined, limit = undefined, tail = false) { + return this.filterByValueSinceLimit (array, 'currency', code, since, limit, 'timestamp', tail) } filterByArray (objects, key, values = undefined, indexed = true) { @@ -1095,7 +1096,8 @@ module.exports = class Exchange { let result = Object.values (trades || []).map ((trade) => this.extend (this.parseTrade (trade, market), params)) result = sortBy (result, 'timestamp') const symbol = (market !== undefined) ? market['symbol'] : undefined - return this.filterBySymbolSinceLimit (result, symbol, since, limit) + const tail = since === undefined + return this.filterBySymbolSinceLimit (result, symbol, since, limit, tail) } parseTransactions (transactions, currency = undefined, since = undefined, limit = undefined, params = {}) { @@ -1106,7 +1108,8 @@ module.exports = class Exchange { let result = Object.values (transactions || []).map ((transaction) => this.extend (this.parseTransaction (transaction, currency), params)) result = this.sortBy (result, 'timestamp'); const code = (currency !== undefined) ? currency['code'] : undefined; - return this.filterByCurrencySinceLimit (result, code, since, limit); + const tail = since === undefined; + return this.filterByCurrencySinceLimit (result, code, since, limit, tail); } parseLedger (data, currency = undefined, since = undefined, limit = undefined, params = {}) { @@ -1124,7 +1127,8 @@ module.exports = class Exchange { } result = this.sortBy (result, 'timestamp'); const code = (currency !== undefined) ? currency['code'] : undefined; - return this.filterByCurrencySinceLimit (result, code, since, limit); + const tail = since === undefined; + return this.filterByCurrencySinceLimit (result, code, since, limit, tail); } parseOrders (orders, market = undefined, since = undefined, limit = undefined, params = {}) { @@ -1154,7 +1158,8 @@ module.exports = class Exchange { Object.entries (orders).map (([ id, order ]) => this.extend (this.parseOrder (this.extend ({ 'id': id }, order), market), params)) result = sortBy (result, 'timestamp') const symbol = (market !== undefined) ? market['symbol'] : undefined - return this.filterBySymbolSinceLimit (result, symbol, since, limit) + const tail = since === undefined + return this.filterBySymbolSinceLimit (result, symbol, since, limit, tail) } safeCurrency (currencyId, currency = undefined) { @@ -1225,19 +1230,10 @@ module.exports = class Exchange { // if (!this.isArray (ohlcvs)) { // throw new ExchangeError (this.id + ' parseOHLCVs expected an array in the ohlcvs argument, but got ' + typeof ohlcvs); // } - ohlcvs = Object.values (ohlcvs || []) - const result = [] - for (let i = 0; i < ohlcvs.length; i++) { - if (limit && (result.length >= limit)) { - break; - } - const ohlcv = this.parseOHLCV (ohlcvs[i], market) - if (since && (ohlcv[0] < since)) { - continue - } - result.push (ohlcv) - } - return this.sortBy (result, 0) + const parsed = ohlcvs.map ((ohlcv) => this.parseOHLCV (ohlcv, market)) + const sorted = this.sortBy (parsed, 0) + const tail = since === undefined + return this.filterBySinceLimit (sorted, since, limit, 0, tail) } editLimitBuyOrder (id, symbol, ...args) { @@ -1260,20 +1256,20 @@ module.exports = class Exchange { return this.createOrder (symbol, ...args) } - createLimitOrder (symbol, ...args) { - return this.createOrder (symbol, 'limit', ...args) + createLimitOrder (symbol, side, amount, price = undefined, params = {}) { + return this.createOrder (symbol, 'limit', side, amount, price, params) } - createMarketOrder (symbol, ...args) { - return this.createOrder (symbol, 'market', ...args) + createMarketOrder (symbol, side, amount, price = undefined, params = {}) { + return this.createOrder (symbol, 'market', side, amount, price, params) } - createLimitBuyOrder (symbol, ...args) { - return this.createOrder (symbol, 'limit', 'buy', ...args) + createLimitBuyOrder (symbol, amount, price = undefined, params = {}) { + return this.createOrder (symbol, 'limit', 'buy', amount, price, params) } - createLimitSellOrder (symbol, ...args) { - return this.createOrder (symbol, 'limit', 'sell', ...args) + createLimitSellOrder (symbol, amount, price = undefined, params = {}) { + return this.createOrder (symbol, 'limit', 'sell', amount, price, params) } createMarketBuyOrder (symbol, amount, params = {}) { @@ -1285,7 +1281,7 @@ module.exports = class Exchange { } costToPrecision (symbol, cost) { - return decimalToPrecision (cost, ROUND, this.markets[symbol].precision.price, this.precisionMode, this.paddingMode) + return decimalToPrecision (cost, TRUNCATE, this.markets[symbol].precision.price, this.precisionMode, this.paddingMode) } priceToPrecision (symbol, price) { @@ -1372,7 +1368,7 @@ module.exports = class Exchange { // still takes the input as a hex string // same as above but returns a string instead of an object const signature = this.signMessage (message, privateKey) - return signature['r'] + this.remove0xPrefix (signature['s']) + this.binaryToBase16 (this.numberToBE (signature['v'])); + return signature['r'] + this.remove0xPrefix (signature['s']) + this.binaryToBase16 (this.numberToBE (signature['v'])) } oath () { @@ -1396,5 +1392,74 @@ module.exports = class Exchange { integerPow (a, b) { return new BN (a).pow (new BN (b)) } -} + safeOrder (order) { + // Cost + // Remaining + // Average + // Price + // Amount + // Filled + // + // First we try to calculate filled from the trades + const parseFilled = order['filled'] === undefined; + const parseCost = order['cost'] === undefined; + if (parseFilled) { + order['filled'] = 0 + } + if (parseCost) { + order['cost'] = 0 + } + if (parseFilled || parseCost) { + if (Array.isArray (order['trades'])) { + for (let i = 0; i < order['trades'].length; i++) { + const trade = order['trades'][i] + if (parseFilled) { + order['filled'] = this.sum (order['filled'], trade['amount']) + } + if (parseCost) { + order['cost'] = this.sum (order['cost'], trade['cost']) + } + } + } + } + // We ensure amount = filled + remaining + if (order['amount'] === undefined) { + if (order['filled'] !== undefined && order['remaining'] !== undefined) { + order['amount'] = this.sum (order['filled'], order['remaining']) + } + } + if (order['filled'] === undefined) { + if (order['amount'] !== undefined && order['remaining'] !== undefined) { + order['filled'] = Math.max (this.sum (order['amount'], -order['remaining']), 0) + } + } + if (order['remaining'] === undefined) { + if (order['amount'] !== undefined && order['filled'] !== undefined) { + order['remaining'] = Math.max (this.sum (order['amount'], -order['filled']), 0) + } + } + // We ensure that the average field is calculated correctly + if (order['average'] === undefined) { + if (order['filled'] !== undefined && order['cost'] !== undefined && order['cost'] > 0) { + order['average'] = order['filled'] / order['cost'] + } + } + // We also ensure the cost field is calculated correctly + const costPriceExists = (order['average'] !== undefined) || (order['price'] !== undefined) + if ((order['filled'] !== undefined) && costPriceExists) { + let costPrice = undefined; + if (order['average'] === undefined) { + costPrice = order['price'] + } else { + costPrice = order['average'] + } + order['cost'] = costPrice * order['filled'] + } + // We add support for market orders + if (order['price'] === undefined && order['type'] === 'market') { + order['price'] = order['average'] + } + return order + } +} diff --git a/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/base/errors.js b/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/base/errors.js index 25a28580a..5248e49d0 100644 --- a/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/base/errors.js +++ b/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/base/errors.js @@ -30,6 +30,10 @@ function subclass (BaseClass, classes, namespace = {}) { this.__proto__ = Class.prototype this.name = className this.message = message + + // https://github.com/Microsoft/TypeScript/wiki/FAQ#why-doesnt-extending-built-ins-like-error-array-and-map-work + + Object.setPrototypeOf (this, Class.prototype) } } diff --git a/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/base/functions/string.js b/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/base/functions/string.js index cabc63b48..ba9601a12 100644 --- a/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/base/functions/string.js +++ b/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/base/functions/string.js @@ -1,21 +1,18 @@ "use strict"; -/* ------------------------------------------------------------------------ */ +// ---------------------------------------------------------------------------- -const uuid = a => a ? (a ^ Math.random () * 16 >> a / 4).toString (16) - : ([1e7]+-1e3+-4e3+-8e3+-1e11).replace (/[018]/g, uuid) +const uuid = a => a ? (a ^ Math.random () * 16 >> a / 4).toString (16) : ([1e7]+-1e3+-4e3+-8e3+-1e11).replace (/[018]/g, uuid) +const uuid22 = a => a ? (a ^ Math.random () * 16 >> a / 4).toString (16) : ([1e7]+1e3+4e3+8e5).replace (/[018]/g, uuid22) -module.exports = +// ---------------------------------------------------------------------------- - { uuid +module.exports = { - // hasFetchOHLCV → has_fetch_ohlcv; parseHTTPResponse → parse_http_response + uuid + , uuid22 + // hasFetchOHLCV → has_fetch_ohlcv; parseHTTPResponse → parse_http_response , unCamelCase: s => s.match (/^[A-Z0-9_]+$/) ? s : (s.replace (/[a-z0-9][A-Z]/g, x => x[0] + '_' + x[1]).replace(/[A-Z0-9][A-Z0-9][a-z]/g, x => x[0] + '_' + x[1] + x[2]).toLowerCase ()) - - , capitalize: s => s.length - ? (s.charAt (0).toUpperCase () + s.slice (1)) - : s + , capitalize: s => s.length ? (s.charAt (0).toUpperCase () + s.slice (1)) : s , strip: s => s.replace(/^\s+|\s+$/g, '') - } - -/* ------------------------------------------------------------------------ */ +} diff --git a/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/bcex.js b/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/bcex.js deleted file mode 100644 index 22eb628a3..000000000 --- a/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/bcex.js +++ /dev/null @@ -1,687 +0,0 @@ -'use strict'; - -// --------------------------------------------------------------------------- - -const Exchange = require ('./base/Exchange'); -const { ExchangeError, ArgumentsRequired, AuthenticationError, InsufficientFunds, InvalidOrder, OrderNotFound } = require ('./base/errors'); - -// --------------------------------------------------------------------------- - -module.exports = class bcex extends Exchange { - describe () { - return this.deepExtend (super.describe (), { - 'id': 'bcex', - 'name': 'BCEX', - 'countries': [ 'CN', 'HK' ], - 'version': '1', - 'has': { - 'cancelOrder': true, - 'createOrder': true, - 'fetchBalance': true, - 'fetchClosedOrders': 'emulated', - 'fetchMarkets': true, - 'fetchMyTrades': true, - 'fetchOpenOrders': true, - 'fetchOrder': true, - 'fetchOrders': true, - 'fetchOrderBook': true, - 'fetchTicker': true, - 'fetchTickers': false, - 'fetchTrades': true, - 'fetchTradingLimits': true, - }, - 'urls': { - 'logo': 'https://user-images.githubusercontent.com/51840849/77231516-851c6900-6bac-11ea-8fd6-ee5c23eddbd4.jpg', - 'api': 'https://www.bcex.top', - 'www': 'https://www.bcex.top', - 'doc': 'https://github.com/BCEX-TECHNOLOGY-LIMITED/API_Docs/wiki/Interface', - 'fees': 'https://bcex.udesk.cn/hc/articles/57085', - 'referral': 'https://www.bcex.top/register?invite_code=758978&lang=en', - }, - 'status': { - 'status': 'error', - 'updated': undefined, - 'eta': undefined, - 'url': undefined, - }, - 'api': { - 'public': { - 'get': [ - 'Api_Market/getPriceList', // tickers - 'Api_Order/ticker', // last ohlcv candle (ticker) - 'Api_Order/depth', // orderbook - 'Api_Market/getCoinTrade', // ticker - 'Api_Order/marketOrder', // trades... - ], - 'post': [ - 'Api_Market/getPriceList', // tickers - 'Api_Order/ticker', // last ohlcv candle (ticker) - 'Api_Order/depth', // orderbook - 'Api_Market/getCoinTrade', // ticker - 'Api_Order/marketOrder', // trades... - ], - }, - 'private': { - 'post': [ - 'Api_Order/cancel', - 'Api_Order/coinTrust', // limit order - 'Api_Order/orderList', // open / all orders (my trades?) - 'Api_Order/orderInfo', - 'Api_Order/tradeList', // open / all orders - 'Api_Order/trustList', // ? - 'Api_User/userBalance', - ], - }, - }, - 'fees': { - 'trading': { - 'tierBased': false, - 'percentage': true, - 'maker': 0.1 / 100, - 'taker': 0.2 / 100, - }, - 'funding': { - 'tierBased': false, - 'percentage': false, - 'withdraw': { - 'ckusd': 0.0, - 'other': 0.05 / 100, - }, - 'deposit': {}, - }, - }, - 'exceptions': { - '该币不存在,非法操作': ExchangeError, // { code: 1, msg: "该币不存在,非法操作" } - returned when a required symbol parameter is missing in the request (also, maybe on other types of errors as well) - '公钥不合法': AuthenticationError, // { code: 1, msg: '公钥不合法' } - wrong public key - '您的可用余额不足': InsufficientFunds, // { code: 1, msg: '您的可用余额不足' } - your available balance is insufficient - '您的btc不足': InsufficientFunds, // { code: 1, msg: '您的btc不足' } - your btc is insufficient - '参数非法': InvalidOrder, // {'code': 1, 'msg': '参数非法'} - 'Parameter illegal' - '订单信息不存在': OrderNotFound, // {'code': 1, 'msg': '订单信息不存在'} - 'Order information does not exist' - }, - 'commonCurrencies': { - 'UNI': 'UNI COIN', - 'PNT': 'Penta', - }, - 'options': { - 'limits': { - // hardcoding is deprecated, using these predefined values is not recommended, use loadTradingLimits instead - 'AFC/CKUSD': { 'precision': { 'amount': 2, 'price': 4 }, 'limits': { 'amount': { 'min': 6, 'max': 120000 }}}, - 'AFC/ETH': { 'precision': { 'amount': 2, 'price': 8 }, 'limits': { 'amount': { 'min': 6, 'max': 120000 }}}, - 'AFT/ETH': { 'precision': { 'amount': 2, 'price': 8 }, 'limits': { 'amount': { 'min': 15, 'max': 300000 }}}, - 'AICC/CNET': { 'precision': { 'amount': 2, 'price': 2 }, 'limits': { 'amount': { 'min': 5, 'max': 50000 }}}, - 'AIDOC/CKUSD': { 'precision': { 'amount': 2, 'price': 4 }, 'limits': { 'amount': { 'min': 5, 'max': 100000 }}}, - 'AISI/ETH': { 'precision': { 'amount': 4, 'price': 2 }, 'limits': { 'amount': { 'min': 0.001, 'max': 500 }}}, - 'AIT/ETH': { 'precision': { 'amount': 2, 'price': 8 }, 'limits': { 'amount': { 'min': 20, 'max': 400000 }}}, - 'ANS/BTC': { 'precision': { 'amount': 4, 'price': 8 }, 'limits': { 'amount': { 'min': 0.1, 'max': 500 }}}, - 'ANS/CKUSD': { 'precision': { 'amount': 2, 'price': 2 }, 'limits': { 'amount': { 'min': 0.1, 'max': 1000 }}}, - 'ARC/CNET': { 'precision': { 'amount': 2, 'price': 4 }, 'limits': { 'amount': { 'min': 60, 'max': 600000 }}}, - 'AXF/CNET': { 'precision': { 'amount': 2, 'price': 4 }, 'limits': { 'amount': { 'min': 100, 'max': 1000000 }}}, - 'BASH/CKUSD': { 'precision': { 'amount': 2, 'price': 4 }, 'limits': { 'amount': { 'min': 250, 'max': 3000000 }}}, - 'BATT/ETH': { 'precision': { 'amount': 2, 'price': 8 }, 'limits': { 'amount': { 'min': 60, 'max': 1500000 }}}, - 'BCD/BTC': { 'precision': { 'amount': 2, 'price': 8 }, 'limits': { 'amount': { 'min': 0.3, 'max': 7000 }}}, - 'BHPC/BTC': { 'precision': { 'amount': 2, 'price': 8 }, 'limits': { 'amount': { 'min': 2, 'max': 70000 }}}, - 'BHPC/ETH': { 'precision': { 'amount': 2, 'price': 8 }, 'limits': { 'amount': { 'min': 2, 'max': 60000 }}}, - 'BOPO/BTC': { 'precision': { 'amount': 2, 'price': 8 }, 'limits': { 'amount': { 'min': 100, 'max': 2000000 }}}, - 'BOPO/CKUSD': { 'precision': { 'amount': 2, 'price': 4 }, 'limits': { 'amount': { 'min': 100, 'max': 10000000 }}}, - 'BTC/CKUSD': { 'precision': { 'amount': 4, 'price': 2 }, 'limits': { 'amount': { 'min': 0.001, 'max': 10 }}}, - 'BTC/CNET': { 'precision': { 'amount': 4, 'price': 2 }, 'limits': { 'amount': { 'min': 0.0005, 'max': 5 }}}, - 'BTC/USDT': { 'precision': { 'amount': 4, 'price': 2 }, 'limits': { 'amount': { 'min': 0.0002, 'max': 4 }}}, - 'BTE/CNET': { 'precision': { 'amount': 2, 'price': 4 }, 'limits': { 'amount': { 'min': 25, 'max': 250000 }}}, - 'BU/ETH': { 'precision': { 'amount': 2, 'price': 8 }, 'limits': { 'amount': { 'min': 20, 'max': 400000 }}}, - 'CIC/CNET': { 'precision': { 'amount': 2, 'price': 4 }, 'limits': { 'amount': { 'min': 3000, 'max': 30000000 }}}, - 'CIT/CKUSD': { 'precision': { 'amount': 2, 'price': 4 }, 'limits': { 'amount': { 'min': 4, 'max': 40000 }}}, - 'CIT/ETH': { 'precision': { 'amount': 2, 'price': 8 }, 'limits': { 'amount': { 'min': 4, 'max': 40000 }}}, - 'CMT/CKUSD': { 'precision': { 'amount': 2, 'price': 4 }, 'limits': { 'amount': { 'min': 5, 'max': 2500000 }}}, - 'CNET/CKUSD': { 'precision': { 'amount': 2, 'price': 4 }, 'limits': { 'amount': { 'min': 12, 'max': 120000 }}}, - 'CNMC/BTC': { 'precision': { 'amount': 2, 'price': 8 }, 'limits': { 'amount': { 'min': 4, 'max': 50000 }}}, - 'CTC/ETH': { 'precision': { 'amount': 2, 'price': 8 }, 'limits': { 'amount': { 'min': 5, 'max': 550000 }}}, - 'CZR/ETH': { 'precision': { 'amount': 2, 'price': 8 }, 'limits': { 'amount': { 'min': 12, 'max': 500000 }}}, - 'DCON/ETH': { 'precision': { 'amount': 2, 'price': 8 }, 'limits': { 'amount': { 'min': 8, 'max': 300000 }}}, - 'DCT/BTC': { 'precision': { 'amount': 4, 'price': 8 }, 'limits': { 'amount': { 'min': 2, 'max': 40000 }}}, - 'DCT/CKUSD': { 'precision': { 'amount': 2, 'price': 3 }, 'limits': { 'amount': { 'min': 2, 'max': 2000 }}}, - 'DOGE/BTC': { 'precision': { 'amount': 4, 'price': 8 }, 'limits': { 'amount': { 'min': 3000, 'max': 14000000 }}}, - 'DOGE/CKUSD': { 'precision': { 'amount': 2, 'price': 6 }, 'limits': { 'amount': { 'min': 500, 'max': 2000000 }}}, - 'DRCT/ETH': { 'precision': { 'amount': 2, 'price': 8 }, 'limits': { 'amount': { 'min': 16, 'max': 190000 }}}, - 'ELA/BTC': { 'precision': { 'amount': 2, 'price': 8 }, 'limits': { 'amount': { 'min': 0.02, 'max': 500 }}}, - 'ELF/BTC': { 'precision': { 'amount': 2, 'price': 8 }, 'limits': { 'amount': { 'min': 0.1, 'max': 100000 }}}, - 'ELF/CKUSD': { 'precision': { 'amount': 2, 'price': 3 }, 'limits': { 'amount': { 'min': 0.01, 'max': 100000 }}}, - 'EOS/CKUSD': { 'precision': { 'amount': 2, 'price': 2 }, 'limits': { 'amount': { 'min': 0.5, 'max': 5000 }}}, - 'EOS/CNET': { 'precision': { 'amount': 2, 'price': 2 }, 'limits': { 'amount': { 'min': 2.5, 'max': 30000 }}}, - 'EOS/ETH': { 'precision': { 'amount': 2, 'price': 8 }, 'limits': { 'amount': { 'min': 0.18, 'max': 1800 }}}, - 'ETC/BTC': { 'precision': { 'amount': 4, 'price': 8 }, 'limits': { 'amount': { 'min': 0.2, 'max': 2500 }}}, - 'ETC/CKUSD': { 'precision': { 'amount': 2, 'price': 2 }, 'limits': { 'amount': { 'min': 0.2, 'max': 2500 }}}, - 'ETF/ETH': { 'precision': { 'amount': 2, 'price': 8 }, 'limits': { 'amount': { 'min': 7, 'max': 150000 }}}, - 'ETH/BTC': { 'precision': { 'amount': 4, 'price': 8 }, 'limits': { 'amount': { 'min': 0.015, 'max': 100 }}}, - 'ETH/CKUSD': { 'precision': { 'amount': 4, 'price': 4 }, 'limits': { 'amount': { 'min': 0.005, 'max': 100 }}}, - 'ETH/USDT': { 'precision': { 'amount': 4, 'price': 2 }, 'limits': { 'amount': { 'min': 0.005, 'max': 100 }}}, - 'FCT/BTC': { 'precision': { 'amount': 4, 'price': 8 }, 'limits': { 'amount': { 'min': 0.24, 'max': 1000 }}}, - 'FCT/CKUSD': { 'precision': { 'amount': 2, 'price': 2 }, 'limits': { 'amount': { 'min': 0.24, 'max': 1000 }}}, - 'GAME/CNET': { 'precision': { 'amount': 2, 'price': 2 }, 'limits': { 'amount': { 'min': 1, 'max': 10000 }}}, - 'GOOC/CKUSD': { 'precision': { 'amount': 2, 'price': 4 }, 'limits': { 'amount': { 'min': 200, 'max': 2000000 }}}, - 'GP/CNET': { 'precision': { 'amount': 2, 'price': 4 }, 'limits': { 'amount': { 'min': 600, 'max': 6000000 }}}, - 'HSC/ETH': { 'precision': { 'amount': 2, 'price': 8 }, 'limits': { 'amount': { 'min': 1000, 'max': 20000000 }}}, - 'IFISH/ETH': { 'precision': { 'amount': 2, 'price': 8 }, 'limits': { 'amount': { 'min': 300, 'max': 8000000 }}}, - 'IIC/ETH': { 'precision': { 'amount': 2, 'price': 8 }, 'limits': { 'amount': { 'min': 50, 'max': 4000000 }}}, - 'IMOS/ETH': { 'precision': { 'amount': 2, 'price': 8 }, 'limits': { 'amount': { 'min': 15, 'max': 300000 }}}, - 'JC/CNET': { 'precision': { 'amount': 2, 'price': 4 }, 'limits': { 'amount': { 'min': 300, 'max': 3000000 }}}, - 'LBTC/BTC': { 'precision': { 'amount': 2, 'price': 8 }, 'limits': { 'amount': { 'min': 0.1, 'max': 3000 }}}, - 'LEC/CNET': { 'precision': { 'amount': 2, 'price': 4 }, 'limits': { 'amount': { 'min': 500, 'max': 5000000 }}}, - 'LKY/CKUSD': { 'precision': { 'amount': 2, 'price': 4 }, 'limits': { 'amount': { 'min': 10, 'max': 70000 }}}, - 'LKY/ETH': { 'precision': { 'amount': 2, 'price': 8 }, 'limits': { 'amount': { 'min': 10, 'max': 100000 }}}, - 'LMC/CNET': { 'precision': { 'amount': 2, 'price': 4 }, 'limits': { 'amount': { 'min': 25, 'max': 250000 }}}, - 'LSK/CNET': { 'precision': { 'amount': 2, 'price': 2 }, 'limits': { 'amount': { 'min': 0.3, 'max': 3000 }}}, - 'LTC/BTC': { 'precision': { 'amount': 4, 'price': 8 }, 'limits': { 'amount': { 'min': 0.01, 'max': 500 }}}, - 'LTC/CKUSD': { 'precision': { 'amount': 2, 'price': 2 }, 'limits': { 'amount': { 'min': 0.01, 'max': 500 }}}, - 'LTC/USDT': { 'precision': { 'amount': 4, 'price': 2 }, 'limits': { 'amount': { 'min': 0.02, 'max': 450 }}}, - 'MC/CNET': { 'precision': { 'amount': 2, 'price': 6 }, 'limits': { 'amount': { 'min': 10000, 'max': 100000000 }}}, - 'MCC/CKUSD': { 'precision': { 'amount': 2, 'price': 4 }, 'limits': { 'amount': { 'min': 30, 'max': 350000 }}}, - 'MOC/ETH': { 'precision': { 'amount': 2, 'price': 8 }, 'limits': { 'amount': { 'min': 25, 'max': 600000 }}}, - 'MRYC/CNET': { 'precision': { 'amount': 2, 'price': 4 }, 'limits': { 'amount': { 'min': 300, 'max': 3000000 }}}, - 'MT/ETH': { 'precision': { 'amount': 2, 'price': 8 }, 'limits': { 'amount': { 'min': 200, 'max': 6000000 }}}, - 'MXI/CNET': { 'precision': { 'amount': 2, 'price': 6 }, 'limits': { 'amount': { 'min': 5000, 'max': 60000000 }}}, - 'NAI/ETH': { 'precision': { 'amount': 2, 'price': 8 }, 'limits': { 'amount': { 'min': 10, 'max': 100000 }}}, - 'NAS/BTC': { 'precision': { 'amount': 4, 'price': 8 }, 'limits': { 'amount': { 'min': 0.2, 'max': 15000 }}}, - 'NAS/CKUSD': { 'precision': { 'amount': 2, 'price': 2 }, 'limits': { 'amount': { 'min': 0.5, 'max': 5000 }}}, - 'NEWOS/ETH': { 'precision': { 'amount': 2, 'price': 8 }, 'limits': { 'amount': { 'min': 65, 'max': 700000 }}}, - 'NKN/ETH': { 'precision': { 'amount': 2, 'price': 8 }, 'limits': { 'amount': { 'min': 3, 'max': 350000 }}}, - 'NTK/ETH': { 'precision': { 'amount': 2, 'price': 8 }, 'limits': { 'amount': { 'min': 2, 'max': 30000 }}}, - 'ONT/CKUSD': { 'precision': { 'amount': 2, 'price': 3 }, 'limits': { 'amount': { 'min': 0.2, 'max': 2000 }}}, - 'ONT/ETH': { 'precision': { 'amount': 3, 'price': 8 }, 'limits': { 'amount': { 'min': 0.01, 'max': 1000 }}}, - 'PNT/ETH': { 'precision': { 'amount': 2, 'price': 8 }, 'limits': { 'amount': { 'min': 80, 'max': 800000 }}}, - 'PST/ETH': { 'precision': { 'amount': 2, 'price': 8 }, 'limits': { 'amount': { 'min': 5, 'max': 100000 }}}, - 'PTT/ETH': { 'precision': { 'amount': 2, 'price': 8 }, 'limits': { 'amount': { 'min': 450, 'max': 10000000 }}}, - 'QTUM/BTC': { 'precision': { 'amount': 4, 'price': 8 }, 'limits': { 'amount': { 'min': 0.4, 'max': 2800 }}}, - 'QTUM/CKUSD': { 'precision': { 'amount': 2, 'price': 2 }, 'limits': { 'amount': { 'min': 0.1, 'max': 1000 }}}, - 'RATING/ETH': { 'precision': { 'amount': 2, 'price': 8 }, 'limits': { 'amount': { 'min': 500, 'max': 10000000 }}}, - 'RHC/CNET': { 'precision': { 'amount': 2, 'price': 4 }, 'limits': { 'amount': { 'min': 1000, 'max': 10000000 }}}, - 'SDA/ETH': { 'precision': { 'amount': 2, 'price': 8 }, 'limits': { 'amount': { 'min': 20, 'max': 500000 }}}, - 'SDD/CKUSD': { 'precision': { 'amount': 2, 'price': 3 }, 'limits': { 'amount': { 'min': 10, 'max': 100000 }}}, - 'SHC/CNET': { 'precision': { 'amount': 2, 'price': 4 }, 'limits': { 'amount': { 'min': 250, 'max': 2500000 }}}, - 'SHE/ETH': { 'precision': { 'amount': 2, 'price': 8 }, 'limits': { 'amount': { 'min': 100, 'max': 5000000 }}}, - 'SMC/CNET': { 'precision': { 'amount': 2, 'price': 6 }, 'limits': { 'amount': { 'min': 1000, 'max': 10000000 }}}, - 'SOP/ETH': { 'precision': { 'amount': 2, 'price': 8 }, 'limits': { 'amount': { 'min': 50, 'max': 1000000 }}}, - 'TAC/ETH': { 'precision': { 'amount': 2, 'price': 8 }, 'limits': { 'amount': { 'min': 35, 'max': 800000 }}}, - 'TIP/ETH': { 'precision': { 'amount': 2, 'price': 8 }, 'limits': { 'amount': { 'min': 7, 'max': 200000 }}}, - 'TKT/ETH': { 'precision': { 'amount': 2, 'price': 8 }, 'limits': { 'amount': { 'min': 40, 'max': 400000 }}}, - 'TLC/ETH': { 'precision': { 'amount': 2, 'price': 8 }, 'limits': { 'amount': { 'min': 500, 'max': 10000000 }}}, - 'TNC/ETH': { 'precision': { 'amount': 2, 'price': 8 }, 'limits': { 'amount': { 'min': 10, 'max': 110000 }}}, - 'TUB/ETH': { 'precision': { 'amount': 2, 'price': 8 }, 'limits': { 'amount': { 'min': 200, 'max': 8000000 }}}, - 'UC/ETH': { 'precision': { 'amount': 2, 'price': 8 }, 'limits': { 'amount': { 'min': 100, 'max': 3000000 }}}, - 'UDB/CNET': { 'precision': { 'amount': 2, 'price': 6 }, 'limits': { 'amount': { 'min': 2000, 'max': 40000000 }}}, - 'UIC/CKUSD': { 'precision': { 'amount': 2, 'price': 4 }, 'limits': { 'amount': { 'min': 5, 'max': 150000 }}}, - 'VAAC/ETH': { 'precision': { 'amount': 2, 'price': 8 }, 'limits': { 'amount': { 'min': 10, 'max': 250000 }}}, - 'VPN/CNET': { 'precision': { 'amount': 2, 'price': 4 }, 'limits': { 'amount': { 'min': 200, 'max': 2000000 }}}, - 'VSC/ETH': { 'precision': { 'amount': 2, 'price': 8 }, 'limits': { 'amount': { 'min': 30, 'max': 650000 }}}, - 'WAVES/CKUSD': { 'precision': { 'amount': 2, 'price': 3 }, 'limits': { 'amount': { 'min': 0.15, 'max': 1500 }}}, - 'WDNA/ETH': { 'precision': { 'amount': 2, 'price': 8 }, 'limits': { 'amount': { 'min': 100, 'max': 250000 }}}, - 'WIC/CKUSD': { 'precision': { 'amount': 2, 'price': 4 }, 'limits': { 'amount': { 'min': 3, 'max': 30000 }}}, - 'XAS/CNET': { 'precision': { 'amount': 2, 'price': 2 }, 'limits': { 'amount': { 'min': 2.5, 'max': 25000 }}}, - 'XLM/BTC': { 'precision': { 'amount': 4, 'price': 8 }, 'limits': { 'amount': { 'min': 10, 'max': 300000 }}}, - 'XLM/CKUSD': { 'precision': { 'amount': 2, 'price': 4 }, 'limits': { 'amount': { 'min': 1, 'max': 300000 }}}, - 'XLM/USDT': { 'precision': { 'amount': 2, 'price': 4 }, 'limits': { 'amount': { 'min': 5, 'max': 150000 }}}, - 'XRP/BTC': { 'precision': { 'amount': 4, 'price': 8 }, 'limits': { 'amount': { 'min': 24, 'max': 100000 }}}, - 'XRP/CKUSD': { 'precision': { 'amount': 2, 'price': 3 }, 'limits': { 'amount': { 'min': 5, 'max': 50000 }}}, - 'YBCT/BTC': { 'precision': { 'amount': 4, 'price': 8 }, 'limits': { 'amount': { 'min': 15, 'max': 200000 }}}, - 'YBCT/CKUSD': { 'precision': { 'amount': 2, 'price': 4 }, 'limits': { 'amount': { 'min': 10, 'max': 200000 }}}, - 'YBY/CNET': { 'precision': { 'amount': 2, 'price': 6 }, 'limits': { 'amount': { 'min': 25000, 'max': 250000000 }}}, - 'ZEC/BTC': { 'precision': { 'amount': 4, 'price': 8 }, 'limits': { 'amount': { 'min': 0.02, 'max': 100 }}}, - 'ZEC/CKUSD': { 'precision': { 'amount': 4, 'price': 2 }, 'limits': { 'amount': { 'min': 0.02, 'max': 100 }}}, - }, - }, - }); - } - - async fetchTradingLimits (symbols = undefined, params = {}) { - // this method should not be called directly, use loadTradingLimits () instead - // by default it will try load withdrawal fees of all currencies (with separate requests, sequentially) - // however if you define symbols = [ 'ETH/BTC', 'LTC/BTC' ] in args it will only load those - await this.loadMarkets (); - if (symbols === undefined) { - symbols = this.symbols; - } - const result = {}; - for (let i = 0; i < symbols.length; i++) { - const symbol = symbols[i]; - result[symbol] = await this.fetchTradingLimitsById (this.marketId (symbol), params); - } - return result; - } - - async fetchTradingLimitsById (id, params = {}) { - const request = { - 'symbol': id, - }; - const response = await this.publicPostApiOrderTicker (this.extend (request, params)); - // - // { code: 0, - // msg: "获取牌价信息成功", - // data: { high: 0.03721392, - // low: 0.03335362, - // buy: "0.03525757", - // sell: "0.03531160", - // last: 0.0352634, - // vol: "184742.4176", - // min_trade: "0.01500000", - // max_trade: "100.00000000", - // number_float: "4", - // price_float: "8" } } } - // - return this.parseTradingLimits (this.safeValue (response, 'data', {})); - } - - parseTradingLimits (limits, symbol = undefined, params = {}) { - // - // { high: 0.03721392, - // low: 0.03335362, - // buy: "0.03525757", - // sell: "0.03531160", - // last: 0.0352634, - // vol: "184742.4176", - // min_trade: "0.01500000", - // max_trade: "100.00000000", - // number_float: "4", - // price_float: "8" } - // - return { - 'info': limits, - 'precision': { - 'amount': this.safeInteger (limits, 'number_float'), - 'price': this.safeInteger (limits, 'price_float'), - }, - 'limits': { - 'amount': { - 'min': this.safeFloat (limits, 'min_trade'), - 'max': this.safeFloat (limits, 'max_trade'), - }, - }, - }; - } - - async fetchMarkets (params = {}) { - const response = await this.publicGetApiMarketGetPriceList (params); - const result = []; - const keys = Object.keys (response); - for (let i = 0; i < keys.length; i++) { - const currentMarketId = keys[i]; - const currentMarkets = response[currentMarketId]; - for (let j = 0; j < currentMarkets.length; j++) { - const market = currentMarkets[j]; - const baseId = this.safeString (market, 'coin_from'); - const quoteId = this.safeString (market, 'coin_to'); - let base = baseId.toUpperCase (); - let quote = quoteId.toUpperCase (); - base = this.safeCurrencyCode (base); - quote = this.safeCurrencyCode (quote); - const id = baseId + '2' + quoteId; - const symbol = base + '/' + quote; - const active = true; - const defaults = this.safeValue (this.options['limits'], symbol, {}); - result.push (this.extend ({ - 'id': id, - 'symbol': symbol, - 'base': base, - 'quote': quote, - 'baseId': baseId, - 'quoteId': quoteId, - 'active': active, - // overrided by defaults from this.options['limits'] - 'precision': { - 'amount': undefined, - 'price': undefined, - }, - // overrided by defaults from this.options['limits'] - 'limits': { - 'amount': { 'min': undefined, 'max': undefined }, - 'price': { 'min': undefined, 'max': undefined }, - 'cost': { 'min': undefined, 'max': undefined }, - }, - 'info': market, - }, defaults)); - } - } - return result; - } - - parseTrade (trade, market = undefined) { - let symbol = undefined; - if (market !== undefined) { - symbol = market['symbol']; - } - const timestamp = this.safeTimestamp2 (trade, 'date', 'created'); - const id = this.safeString (trade, 'tid'); - const orderId = this.safeString (trade, 'order_id'); - const amount = this.safeFloat2 (trade, 'number', 'amount'); - const price = this.safeFloat (trade, 'price'); - let cost = undefined; - if (price !== undefined) { - if (amount !== undefined) { - cost = amount * price; - } - } - let side = this.safeString (trade, 'side'); - if (side === 'sale') { - side = 'sell'; - } - return { - 'info': trade, - 'id': id, - 'timestamp': timestamp, - 'datetime': this.iso8601 (timestamp), - 'symbol': symbol, - 'type': undefined, - 'side': side, - 'price': price, - 'amount': amount, - 'cost': cost, - 'order': orderId, - 'fee': undefined, - 'takerOrMaker': undefined, - }; - } - - async fetchTrades (symbol, since = undefined, limit = undefined, params = {}) { - await this.loadMarkets (); - const request = { - 'symbol': this.marketId (symbol), - }; - if (limit !== undefined) { - request['limit'] = limit; - } - const market = this.market (symbol); - const response = await this.publicPostApiOrderMarketOrder (this.extend (request, params)); - return this.parseTrades (response['data'], market, since, limit); - } - - async fetchBalance (params = {}) { - await this.loadMarkets (); - const response = await this.privatePostApiUserUserBalance (params); - const data = this.safeValue (response, 'data'); - let keys = Object.keys (data); - const result = { }; - for (let i = 0; i < keys.length; i++) { - const key = keys[i]; - const amount = this.safeFloat (data, key); - const parts = key.split ('_'); - const currencyId = parts[0]; - const lockOrOver = parts[1]; - const code = this.safeCurrencyCode (currencyId); - if (!(code in result)) { - result[code] = this.account (); - } - if (lockOrOver === 'lock') { - result[code]['used'] = parseFloat (amount); - } else { - result[code]['free'] = parseFloat (amount); - } - } - keys = Object.keys (result); - for (let i = 0; i < keys.length; i++) { - const key = keys[i]; - const total = this.sum (result[key]['used'], result[key]['free']); - result[key]['total'] = total; - } - result['info'] = data; - return this.parseBalance (result); - } - - async fetchTicker (symbol, params = {}) { - await this.loadMarkets (); - const market = this.markets[symbol]; - const request = { - 'part': market['quoteId'], - 'coin': market['baseId'], - }; - const response = await this.publicPostApiMarketGetCoinTrade (this.extend (request, params)); - const timestamp = this.milliseconds (); - return { - 'symbol': symbol, - 'timestamp': timestamp, - 'datetime': this.iso8601 (timestamp), - 'high': this.safeFloat (response, 'max'), - 'low': this.safeFloat (response, 'min'), - 'bid': this.safeFloat (response, 'buy'), - 'bidVolume': undefined, - 'ask': this.safeFloat (response, 'sale'), - 'askVolume': undefined, - 'vwap': undefined, - 'open': undefined, - 'close': this.safeFloat (response, 'price'), - 'last': this.safeFloat (response, 'price'), - 'previousClose': undefined, - 'change': undefined, - 'percentage': this.safeFloat (response, 'change_24h'), - 'average': undefined, - 'baseVolume': this.safeFloat (response, 'volume_24h'), - 'quoteVolume': undefined, - 'info': response, - }; - } - - async fetchOrderBook (symbol, limit = undefined, params = {}) { - await this.loadMarkets (); - const marketId = this.marketId (symbol); - const request = { - 'symbol': marketId, - }; - const response = await this.publicPostApiOrderDepth (this.extend (request, params)); - const data = this.safeValue (response, 'data'); - const timestamp = this.safeTimestamp (data, 'date'); - return this.parseOrderBook (data, timestamp); - } - - async fetchMyTrades (symbol = undefined, since = undefined, limit = undefined, params = {}) { - await this.loadMarkets (); - const market = this.market (symbol); - const request = { - 'symbol': market['id'], - }; - const response = await this.privatePostApiOrderOrderList (this.extend (request, params)); - return this.parseTrades (response['data'], market, since, limit); - } - - parseOrderStatus (status) { - const statuses = { - '0': 'open', - '1': 'open', // partially filled - '2': 'closed', - '3': 'canceled', - }; - return this.safeString (statuses, status, status); - } - - async fetchOrder (id, symbol = undefined, params = {}) { - if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' fetchOrder requires a `symbol` argument'); - } - await this.loadMarkets (); - const request = { - 'symbol': this.marketId (symbol), - 'trust_id': id, - }; - const response = await this.privatePostApiOrderOrderInfo (this.extend (request, params)); - const order = this.safeValue (response, 'data'); - const timestamp = this.safeTimestamp (order, 'created'); - const status = this.parseOrderStatus (this.safeString (order, 'status')); - let side = this.safeString (order, 'flag'); - if (side === 'sale') { - side = 'sell'; - } - // Can't use parseOrder because the data format is different btw endpoint for fetchOrder and fetchOrders - return { - 'info': order, - 'id': id, - 'timestamp': timestamp, - 'datetime': this.iso8601 (timestamp), - 'lastTradeTimestamp': undefined, - 'symbol': symbol, - 'type': undefined, - 'side': side, - 'price': this.safeFloat (order, 'price'), - 'cost': undefined, - 'average': this.safeFloat (order, 'avg_price'), - 'amount': this.safeFloat (order, 'number'), - 'filled': this.safeFloat (order, 'numberdeal'), - 'remaining': this.safeFloat (order, 'numberover'), - 'status': status, - 'fee': undefined, - 'clientOrderId': undefined, - 'trades': undefined, - }; - } - - parseOrder (order, market = undefined) { - const id = this.safeString (order, 'id'); - const timestamp = this.safeTimestamp (order, 'datetime'); - let symbol = undefined; - if (market !== undefined) { - symbol = market['symbol']; - } - const type = undefined; - let side = this.safeString (order, 'type'); - if (side === 'sale') { - side = 'sell'; - } - const price = this.safeFloat (order, 'price'); - const average = this.safeFloat (order, 'avg_price'); - const amount = this.safeFloat (order, 'amount'); - const remaining = this.safeFloat (order, 'amount_outstanding'); - const filled = amount - remaining; - const status = this.parseOrderStatus (this.safeString (order, 'status')); - const cost = filled * price; - const fee = undefined; - const result = { - 'info': order, - 'id': id, - 'clientOrderId': undefined, - 'timestamp': timestamp, - 'datetime': this.iso8601 (timestamp), - 'lastTradeTimestamp': undefined, - 'symbol': symbol, - 'type': type, - 'timeInForce': undefined, - 'side': side, - 'price': price, - 'stopPrice': undefined, - 'cost': cost, - 'average': average, - 'amount': amount, - 'filled': filled, - 'remaining': remaining, - 'status': status, - 'fee': fee, - 'trades': undefined, - }; - return result; - } - - async fetchOrdersByType (type, symbol = undefined, since = undefined, limit = undefined, params = {}) { - await this.loadMarkets (); - const request = { - 'type': type, - }; - let market = undefined; - if (symbol !== undefined) { - market = this.market (symbol); - request['symbol'] = market['id']; - } - const response = await this.privatePostApiOrderTradeList (this.extend (request, params)); - if ('data' in response) { - return this.parseOrders (response['data'], market, since, limit); - } - return []; - } - - async fetchOpenOrders (symbol = undefined, since = undefined, limit = undefined, params = {}) { - return this.fetchOrdersByType ('open', symbol, since, limit, params); - } - - async fetchClosedOrders (symbol = undefined, since = undefined, limit = undefined, params = {}) { - const orders = await this.fetchOrders (symbol, since, limit, params); - return this.filterBy (orders, 'status', 'closed'); - } - - async fetchOrders (symbol = undefined, since = undefined, limit = undefined, params = {}) { - return this.fetchOrdersByType ('all', symbol, since, limit, params); - } - - async createOrder (symbol, type, side, amount, price = undefined, params = {}) { - await this.loadMarkets (); - const request = { - 'symbol': this.marketId (symbol), - 'type': side, - 'price': this.priceToPrecision (symbol, price), - 'number': this.amountToPrecision (symbol, amount), - }; - const response = await this.privatePostApiOrderCoinTrust (this.extend (request, params)); - const data = this.safeValue (response, 'data', {}); - const id = this.safeString (data, 'order_id'); - return { - 'info': response, - 'id': id, - }; - } - - async cancelOrder (id, symbol = undefined, params = {}) { - if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' cancelOrder requires a `symbol` argument'); - } - await this.loadMarkets (); - const request = {}; - if (symbol !== undefined) { - request['symbol'] = this.marketId (symbol); - } - if (id !== undefined) { - request['order_id'] = id; - } - return await this.privatePostApiOrderCancel (this.extend (request, params)); - } - - sign (path, api = 'public', method = 'GET', params = {}, headers = undefined, body = undefined) { - let url = this.urls['api'] + '/' + this.implodeParams (path, params); - const query = this.omit (params, this.extractParams (path)); - if (api === 'public') { - if (Object.keys (query).length) { - url += '?' + this.urlencode (query); - } - } else { - this.checkRequiredCredentials (); - let payload = this.urlencode ({ 'api_key': this.apiKey }); - if (Object.keys (query).length) { - payload += '&' + this.urlencode (this.keysort (query)); - } - const auth = payload + '&secret_key=' + this.secret; - const signature = this.hash (this.encode (auth)); - body = payload + '&sign=' + signature; - headers = { - 'Content-Type': 'application/x-www-form-urlencoded', - }; - } - return { 'url': url, 'method': method, 'body': body, 'headers': headers }; - } - - handleErrors (code, reason, url, method, headers, body, response, requestHeaders, requestBody) { - if (response === undefined) { - return; // fallback to default error handler - } - const errorCode = this.safeValue (response, 'code'); - if (errorCode !== undefined) { - if (errorCode !== 0) { - // - // { code: 1, msg: "该币不存在,非法操作" } - returned when a required symbol parameter is missing in the request (also, maybe on other types of errors as well) - // { code: 1, msg: '公钥不合法' } - wrong public key - // { code: 1, msg: '价格输入有误,请检查你的数值精度' } - 'The price input is incorrect, please check your numerical accuracy' - // { code: 1, msg: '单笔最小交易数量不能小于0.00100000,请您重新挂单'} - - // 'The minimum number of single transactions cannot be less than 0.00100000. Please re-post the order' - // - const message = this.safeString (response, 'msg'); - const feedback = this.id + ' ' + message; - this.throwExactlyMatchedException (this.exceptions, message, feedback); - if (message.indexOf ('请您重新挂单') >= 0) { // minimum limit - throw new InvalidOrder (feedback); - } else { - throw new ExchangeError (feedback); - } - } - } - } -}; diff --git a/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/bibox.js b/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/bibox.js index 5f1e30c04..4d46d8f35 100644 --- a/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/bibox.js +++ b/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/bibox.js @@ -3,7 +3,7 @@ // --------------------------------------------------------------------------- const Exchange = require ('./base/Exchange'); -const { ExchangeError, AccountSuspended, ArgumentsRequired, AuthenticationError, DDoSProtection, ExchangeNotAvailable, InvalidOrder, OrderNotFound, PermissionDenied, InsufficientFunds, BadSymbol } = require ('./base/errors'); +const { ExchangeError, AccountSuspended, ArgumentsRequired, AuthenticationError, DDoSProtection, ExchangeNotAvailable, InvalidOrder, OrderNotFound, PermissionDenied, InsufficientFunds, BadSymbol, RateLimitExceeded, BadRequest } = require ('./base/errors'); // --------------------------------------------------------------------------- @@ -71,6 +71,7 @@ module.exports = class bibox extends Exchange { 'get': [ 'cquery', 'mdata', + 'cdata', ], }, 'private': { @@ -108,9 +109,16 @@ module.exports = class bibox extends Exchange { '2021': InsufficientFunds, // Insufficient balance available for withdrawal '2027': InsufficientFunds, // Insufficient balance available (for trade) '2033': OrderNotFound, // operation failed! Orders have been completed or revoked + '2065': InvalidOrder, // Precatory price is exorbitant, please reset + '2066': InvalidOrder, // Precatory price is low, please reset '2067': InvalidOrder, // Does not support market orders '2068': InvalidOrder, // The number of orders can not be less than + '2078': InvalidOrder, // unvalid order price '2085': InvalidOrder, // Order quantity is too small + '2091': RateLimitExceeded, // request is too frequency, please try again later + '2092': InvalidOrder, // Minimum amount not met + '3000': BadRequest, // Requested parameter incorrect + '3002': BadRequest, // Parameter cannot be null '3012': AuthenticationError, // invalid apiKey '3016': BadSymbol, // Trading pair error '3024': PermissionDenied, // wrong apikey permissions @@ -124,6 +132,10 @@ module.exports = class bibox extends Exchange { 'KEY': 'Bihu', 'MTC': 'MTC Mesh Network', // conflict with MTC Docademic doc.com Token https://github.com/ccxt/ccxt/issues/6081 https://github.com/ccxt/ccxt/issues/3025 'PAI': 'PCHAIN', + 'TERN': 'Ternio-ERC20', + }, + 'options': { + 'fetchCurrencies': 'fetch_currencies_public', // or 'fetch_currencies_private' with apiKey and secret }, }); } @@ -423,6 +435,78 @@ module.exports = class bibox extends Exchange { } async fetchCurrencies (params = {}) { + const method = this.safeString (this.options, 'fetchCurrencies', 'fetch_currencies_public'); + return await this[method] (params); + } + + async fetchCurrenciesPublic (params = {}) { + const request = { + 'cmd': 'currencies', + }; + const response = await this.publicGetCdata (this.extend (request, params)); + // + // publicGetCdata + // + // { + // "result":[ + // { + // "symbol":"BTC", + // "name":"BTC", + // "valid_decimals":8, + // "original_decimals":8, + // "is_erc20":0, + // "enable_withdraw":1, + // "enable_deposit":1, + // "withdraw_min":0.005, + // "describe_summary":"[{\"lang\":\"zh-cn\",\"text\":\"Bitcoin 比特币的概念最初由中本聪在2009年提出,是点对点的基于 SHA-256 算法的一种P2P形式的数字货币,点对点的传输意味着一个去中心化的支付系统。\"},{\"lang\":\"en-ww\",\"text\":\"Bitcoin is a digital asset and a payment system invented by Satoshi Nakamoto who published a related paper in 2008 and released it as open-source software in 2009. The system featured as peer-to-peer; users can transact directly without an intermediary.\"}]" + // } + // ], + // "cmd":"currencies" + // } + // + const currencies = this.safeValue (response, 'result'); + const result = {}; + for (let i = 0; i < currencies.length; i++) { + const currency = currencies[i]; + const id = this.safeString (currency, 'symbol'); + const name = this.safeString (currency, 'name'); // contains hieroglyphs causing python ASCII bug + const code = this.safeCurrencyCode (id); + const precision = this.safeInteger (currency, 'valid_decimals'); + const deposit = this.safeValue (currency, 'enable_deposit'); + const withdraw = this.safeValue (currency, 'enable_withdraw'); + const active = (deposit && withdraw); + result[code] = { + 'id': id, + 'code': code, + 'info': currency, + 'name': name, + 'active': active, + 'fee': undefined, + 'precision': precision, + 'limits': { + 'amount': { + 'min': Math.pow (10, -precision), + 'max': undefined, + }, + 'price': { + 'min': Math.pow (10, -precision), + 'max': undefined, + }, + 'cost': { + 'min': undefined, + 'max': undefined, + }, + 'withdraw': { + 'min': this.safeFloat (currency, 'withdraw_min'), + 'max': undefined, + }, + }, + }; + } + return result; + } + + async fetchCurrenciesPrivate (params = {}) { if (!this.apiKey || !this.secret) { throw new AuthenticationError (this.id + " fetchCurrencies is an authenticated endpoint, therefore it requires 'apiKey' and 'secret' credentials. If you don't need currency details, set exchange.has['fetchCurrencies'] = false before calling its methods."); } @@ -435,46 +519,42 @@ module.exports = class bibox extends Exchange { // { // "result":[ // { - // "result":[ - // { - // "totalBalance":"14.57582269", - // "balance":"14.57582269", - // "freeze":"0.00000000", - // "id":60, - // "symbol":"USDT", - // "icon_url":"/appimg/USDT_icon.png", - // "describe_url":"[{\"lang\":\"zh-cn\",\"link\":\"https://bibox.zendesk.com/hc/zh-cn/articles/115004798234\"},{\"lang\":\"en-ww\",\"link\":\"https://bibox.zendesk.com/hc/en-us/articles/115004798234\"}]", - // "name":"USDT", - // "enable_withdraw":1, - // "enable_deposit":1, - // "enable_transfer":1, - // "confirm_count":2, - // "is_erc20":1, - // "forbid_info":null, - // "describe_summary":"[{\"lang\":\"zh-cn\",\"text\":\"USDT 是 Tether 公司推出的基于稳定价值货币美元(USD)的代币 Tether USD(简称USDT),1USDT=1美元,用户可以随时使用 USDT 与 USD 进行1:1的兑换。\"},{\"lang\":\"en-ww\",\"text\":\"USDT is a cryptocurrency asset issued on the Bitcoin blockchain via the Omni Layer Protocol. Each USDT unit is backed by a U.S Dollar held in the reserves of the Tether Limited and can be redeemed through the Tether Platform.\"}]", - // "total_amount":4776930644, - // "supply_amount":4642367414, - // "price":"--", - // "contract_father":"OMNI", - // "supply_time":"--", - // "comment":null, - // "contract":"31", - // "original_decimals":8, - // "deposit_type":0, - // "hasCobo":0, - // "BTCValue":"0.00126358", - // "CNYValue":"100.93381445", - // "USDValue":"14.57524654", - // "children":[ - // {"type":"OMNI","symbol":"USDT","enable_deposit":1,"enable_withdraw":1,"confirm_count":2}, - // {"type":"TRC20","symbol":"tUSDT","enable_deposit":1,"enable_withdraw":1,"confirm_count":20}, - // {"type":"ERC20","symbol":"eUSDT","enable_deposit":1,"enable_withdraw":1,"confirm_count":25} - // ] - // }, - // ], - // "cmd":"transfer/coinList" - // } - // ] + // "totalBalance":"14.57582269", + // "balance":"14.57582269", + // "freeze":"0.00000000", + // "id":60, + // "symbol":"USDT", + // "icon_url":"/appimg/USDT_icon.png", + // "describe_url":"[{\"lang\":\"zh-cn\",\"link\":\"https://bibox.zendesk.com/hc/zh-cn/articles/115004798234\"},{\"lang\":\"en-ww\",\"link\":\"https://bibox.zendesk.com/hc/en-us/articles/115004798234\"}]", + // "name":"USDT", + // "enable_withdraw":1, + // "enable_deposit":1, + // "enable_transfer":1, + // "confirm_count":2, + // "is_erc20":1, + // "forbid_info":null, + // "describe_summary":"[{\"lang\":\"zh-cn\",\"text\":\"USDT 是 Tether 公司推出的基于稳定价值货币美元(USD)的代币 Tether USD(简称USDT),1USDT=1美元,用户可以随时使用 USDT 与 USD 进行1:1的兑换。\"},{\"lang\":\"en-ww\",\"text\":\"USDT is a cryptocurrency asset issued on the Bitcoin blockchain via the Omni Layer Protocol. Each USDT unit is backed by a U.S Dollar held in the reserves of the Tether Limited and can be redeemed through the Tether Platform.\"}]", + // "total_amount":4776930644, + // "supply_amount":4642367414, + // "price":"--", + // "contract_father":"OMNI", + // "supply_time":"--", + // "comment":null, + // "contract":"31", + // "original_decimals":8, + // "deposit_type":0, + // "hasCobo":0, + // "BTCValue":"0.00126358", + // "CNYValue":"100.93381445", + // "USDValue":"14.57524654", + // "children":[ + // {"type":"OMNI","symbol":"USDT","enable_deposit":1,"enable_withdraw":1,"confirm_count":2}, + // {"type":"TRC20","symbol":"tUSDT","enable_deposit":1,"enable_withdraw":1,"confirm_count":20}, + // {"type":"ERC20","symbol":"eUSDT","enable_deposit":1,"enable_withdraw":1,"confirm_count":25} + // ] + // }, + // ], + // "cmd":"transfer/coinList" // } // const currencies = this.safeValue (response, 'result'); @@ -799,6 +879,7 @@ module.exports = class bibox extends Exchange { 'symbol': symbol, 'type': type, 'timeInForce': undefined, + 'postOnly': undefined, 'side': side, 'price': price, 'stopPrice': undefined, @@ -851,7 +932,7 @@ module.exports = class bibox extends Exchange { async fetchClosedOrders (symbol = undefined, since = undefined, limit = 200, params = {}) { if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' fetchClosedOrders requires a `symbol` argument'); + throw new ArgumentsRequired (this.id + ' fetchClosedOrders() requires a `symbol` argument'); } await this.loadMarkets (); const market = this.market (symbol); @@ -871,7 +952,7 @@ module.exports = class bibox extends Exchange { async fetchMyTrades (symbol = undefined, since = undefined, limit = undefined, params = {}) { if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' fetchMyTrades requires a `symbol` argument'); + throw new ArgumentsRequired (this.id + ' fetchMyTrades() requires a `symbol` argument'); } await this.loadMarkets (); const market = this.market (symbol); @@ -998,7 +1079,7 @@ module.exports = class bibox extends Exchange { } } else if (api === 'v2private') { this.checkRequiredCredentials (); - url = this.urls['api'] + '/v2/' + path; + url = this.implodeParams (this.urls['api'], { 'hostname': this.hostname }) + '/v2/' + path; const json_params = this.json (params); body = { 'body': json_params, diff --git a/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/bigone.js b/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/bigone.js index b589aceeb..d6e940c4d 100644 --- a/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/bigone.js +++ b/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/bigone.js @@ -78,6 +78,7 @@ module.exports = class bigone extends Exchange { 'private': { 'get': [ 'accounts', + 'fund/accounts', 'assets/{asset_symbol}/address', 'orders', 'orders/{id}', @@ -91,6 +92,7 @@ module.exports = class bigone extends Exchange { 'orders/{id}/cancel', 'orders/cancel', 'withdrawals', + 'transfer', ], }, }, @@ -645,7 +647,10 @@ module.exports = class bigone extends Exchange { async fetchBalance (params = {}) { await this.loadMarkets (); - const response = await this.privateGetAccounts (params); + const type = this.safeString (params, 'type', ''); + params = this.omit (params, 'type'); + const method = 'privateGet' + this.capitalize (type) + 'Accounts'; + const response = await this[method] (params); // // { // "code":0, @@ -721,6 +726,7 @@ module.exports = class bigone extends Exchange { 'symbol': symbol, 'type': undefined, 'timeInForce': undefined, + 'postOnly': undefined, 'side': side, 'price': price, 'stopPrice': undefined, @@ -758,7 +764,7 @@ module.exports = class bigone extends Exchange { if (isStopLimit || isStopMarket) { const stopPrice = this.safeFloat2 (params, 'stop_price', 'stopPrice'); if (stopPrice === undefined) { - throw new ArgumentsRequired (this.id + ' createOrder requires a stop_price parameter'); + throw new ArgumentsRequired (this.id + ' createOrder() requires a stop_price parameter'); } request['stop_price'] = this.priceToPrecision (symbol, stopPrice); params = this.omit (params, [ 'stop_price', 'stopPrice' ]); diff --git a/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/binance.js b/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/binance.js index c9e459dfb..a115b3f7b 100644 --- a/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/binance.js +++ b/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/binance.js @@ -3,7 +3,7 @@ // --------------------------------------------------------------------------- const Exchange = require ('./base/Exchange'); -const { ExchangeError, ArgumentsRequired, ExchangeNotAvailable, InsufficientFunds, OrderNotFound, InvalidOrder, DDoSProtection, InvalidNonce, AuthenticationError, InvalidAddress, RateLimitExceeded, PermissionDenied, NotSupported, BadRequest, BadSymbol, AccountSuspended, OrderImmediatelyFillable } = require ('./base/errors'); +const { ExchangeError, ArgumentsRequired, ExchangeNotAvailable, InsufficientFunds, OrderNotFound, InvalidOrder, DDoSProtection, InvalidNonce, AuthenticationError, RateLimitExceeded, PermissionDenied, NotSupported, BadRequest, BadSymbol, AccountSuspended, OrderImmediatelyFillable } = require ('./base/errors'); const { ROUND, TRUNCATE } = require ('./base/functions/number'); // --------------------------------------------------------------------------- @@ -23,6 +23,7 @@ module.exports = class binance extends Exchange { 'cancelOrder': true, 'CORS': false, 'createOrder': true, + 'fetchCurrencies': true, 'fetchBalance': true, 'fetchBidsAsks': true, 'fetchClosedOrders': 'emulated', @@ -113,6 +114,7 @@ module.exports = class binance extends Exchange { 'margin/priceIndex', // these endpoints require this.apiKey + this.secret 'asset/assetDividend', + 'asset/transfer', 'margin/loan', 'margin/repay', 'margin/account', @@ -154,6 +156,7 @@ module.exports = class binance extends Exchange { 'sub-account/spotSummary', 'sub-account/status', 'sub-account/transfer/subUserHistory', + 'sub-account/universalTransfer', // lending endpoints 'lending/daily/product/list', 'lending/daily/userLeftQuota', @@ -179,9 +182,23 @@ module.exports = class binance extends Exchange { 'bswap/liquidityOps', 'bswap/quote', 'bswap/swap', + // leveraged token endpoints + 'blvt/tokenInfo', + 'blvt/subscribe/record', + 'blvt/redeem/record', + 'blvt/userLimit', + // broker api + 'apiReferral/ifNewUser', + 'apiReferral/customization', + 'apiReferral/userCustomization', + 'apiReferral/rebate/recentRecord', + 'apiReferral/rebate/historicalRecord', + 'apiReferral/kickback/recentRecord', + 'apiReferral/kickback/historicalRecord', ], 'post': [ 'asset/dust', + 'asset/transfer', 'account/disableFastWithdrawSwitch', 'account/enableFastWithdrawSwitch', 'capital/withdraw/apply', @@ -199,6 +216,7 @@ module.exports = class binance extends Exchange { 'sub-account/futures/internalTransfer', 'sub-account/transfer/subToSub', 'sub-account/transfer/subToMaster', + 'sub-account/universalTransfer', 'userDataStream', 'userDataStream/isolated', 'futures/transfer', @@ -213,12 +231,21 @@ module.exports = class binance extends Exchange { 'bswap/liquidityAdd', 'bswap/liquidityRemove', 'bswap/swap', + // leveraged token endpoints + 'blvt/subscribe', + 'blvt/redeem', + // broker api + 'apiReferral/customization', + 'apiReferral/userCustomization', + 'apiReferral/rebate/historicalRecord', + 'apiReferral/kickback/historicalRecord', ], 'put': [ 'userDataStream', 'userDataStream/isolated', ], 'delete': [ + 'margin/openOrders', 'margin/order', 'userDataStream', 'userDataStream/isolated', @@ -323,6 +350,7 @@ module.exports = class binance extends Exchange { 'historicalTrades', 'aggTrades', 'klines', + 'continuousKlines', 'fundingRate', 'premiumIndex', 'ticker/24hr', @@ -357,6 +385,15 @@ module.exports = class binance extends Exchange { 'positionSide/dual', 'userTrades', 'income', + // broker endpoints + 'apiReferral/ifNewUser', + 'apiReferral/customization', + 'apiReferral/userCustomization', + 'apiReferral/traderNum', + 'apiReferral/overview', + 'apiReferral/tradeVol', + 'apiReferral/rebateVol', + 'apiReferral/traderSummary', ], 'post': [ 'batchOrders', @@ -367,6 +404,9 @@ module.exports = class binance extends Exchange { 'leverage', 'listenKey', 'countdownCancelAll', + // broker endpoints + 'apiReferral/customization', + 'apiReferral/userCustomization', ], 'put': [ 'listenKey', @@ -446,6 +486,7 @@ module.exports = class binance extends Exchange { }, // exchange-specific options 'options': { + 'fetchCurrencies': false, // this is a private call and it requires API keys // 'fetchTradesMethod': 'publicGetAggTrades', // publicGetTrades, publicGetHistoricalTrades 'defaultTimeInForce': 'GTC', // 'GTC' = Good To Cancel (default), 'IOC' = Immediate Or Cancel 'defaultType': 'spot', // 'spot', 'future', 'margin', 'delivery' @@ -460,11 +501,20 @@ module.exports = class binance extends Exchange { 'limit': 'RESULT', // we change it from 'ACK' by default to 'RESULT' }, 'quoteOrderQty': true, // whether market orders support amounts in quote currency + 'broker': { + 'spot': 'x-R4BD3S82', + 'margin': 'x-R4BD3S82', + 'future': 'x-xcKtGhcu', + 'delivery': 'x-xcKtGhcu', + }, }, // https://binance-docs.github.io/apidocs/spot/en/#error-codes-2 'exceptions': { + 'System abnormality': ExchangeError, // {"code":-1000,"msg":"System abnormality"} + 'You are not authorized to execute this request.': PermissionDenied, // {"msg":"You are not authorized to execute this request."} 'API key does not exist': AuthenticationError, 'Order would trigger immediately.': OrderImmediatelyFillable, + 'Stop price would trigger immediately.': OrderImmediatelyFillable, // {"code":-2010,"msg":"Stop price would trigger immediately."} 'Order would immediately match and take.': OrderImmediatelyFillable, // {"code":-2010,"msg":"Order would immediately match and take."} 'Account has insufficient balance for requested action.': InsufficientFunds, 'Rest API trading is not enabled.': ExchangeNotAvailable, @@ -508,14 +558,21 @@ module.exports = class binance extends Exchange { '-2013': OrderNotFound, // fetchOrder (1, 'BTC/USDT') -> 'Order does not exist' '-2014': AuthenticationError, // { "code":-2014, "msg": "API-key format invalid." } '-2015': AuthenticationError, // "Invalid API-key, IP, or permissions for action." + '-2019': InsufficientFunds, // {"code":-2019,"msg":"Margin is insufficient."} '-3005': InsufficientFunds, // {"code":-3005,"msg":"Transferring out not allowed. Transfer out amount exceeds max amount."} '-3008': InsufficientFunds, // {"code":-3008,"msg":"Borrow not allowed. Your borrow amount has exceed maximum borrow amount."} '-3010': ExchangeError, // {"code":-3010,"msg":"Repay not allowed. Repay amount exceeds borrow amount."} '-3022': AccountSuspended, // You account's trading is banned. + '-4028': BadRequest, // {"code":-4028,"msg":"Leverage 100 is not valid"} + '-5013': InsufficientFunds, // Asset transfer failed: insufficient balance" }, }); } + currencyToPrecision (currency, fee) { + return this.numberToString (fee); + } + nonce () { return this.milliseconds () - this.options['timeDifference']; } @@ -539,6 +596,145 @@ module.exports = class binance extends Exchange { return this.options['timeDifference']; } + async fetchCurrencies (params = {}) { + const fetchCurrenciesEnabled = this.safeValue (this.options, 'fetchCurrencies'); + if (!fetchCurrenciesEnabled) { + return undefined; + } + // this endpoint requires authentication + // while fetchCurrencies is a public API method by design + // therefore we check the keys here + // and fallback to generating the currencies from the markets + if (!this.checkRequiredCredentials (false)) { + return undefined; + } + // sandbox/testnet does not support sapi endpoints + const apiBackup = this.safeString (this.urls, 'apiBackup'); + if (apiBackup !== undefined) { + return undefined; + } + const response = await this.sapiGetCapitalConfigGetall (params); + const result = {}; + for (let i = 0; i < response.length; i++) { + // + // { + // coin: 'LINK', + // depositAllEnable: true, + // withdrawAllEnable: true, + // name: 'ChainLink', + // free: '0.06168', + // locked: '0', + // freeze: '0', + // withdrawing: '0', + // ipoing: '0', + // ipoable: '0', + // storage: '0', + // isLegalMoney: false, + // trading: true, + // networkList: [ + // { + // network: 'BNB', + // coin: 'LINK', + // withdrawIntegerMultiple: '0', + // isDefault: false, + // depositEnable: true, + // withdrawEnable: true, + // depositDesc: '', + // withdrawDesc: '', + // specialTips: 'Both a MEMO and an Address are required to successfully deposit your LINK BEP2 tokens to Binance.', + // name: 'BEP2', + // resetAddressStatus: false, + // addressRegex: '^(bnb1)[0-9a-z]{38}$', + // memoRegex: '^[0-9A-Za-z\\-_]{1,120}$', + // withdrawFee: '0.002', + // withdrawMin: '0.01', + // withdrawMax: '9999999', + // minConfirm: 1, + // unLockConfirm: 0 + // }, + // { + // network: 'BSC', + // coin: 'LINK', + // withdrawIntegerMultiple: '0.00000001', + // isDefault: false, + // depositEnable: true, + // withdrawEnable: true, + // depositDesc: '', + // withdrawDesc: '', + // specialTips: '', + // name: 'BEP20 (BSC)', + // resetAddressStatus: false, + // addressRegex: '^(0x)[0-9A-Fa-f]{40}$', + // memoRegex: '', + // withdrawFee: '0.005', + // withdrawMin: '0.01', + // withdrawMax: '9999999', + // minConfirm: 15, + // unLockConfirm: 0 + // }, + // { + // network: 'ETH', + // coin: 'LINK', + // withdrawIntegerMultiple: '0.00000001', + // isDefault: true, + // depositEnable: true, + // withdrawEnable: true, + // depositDesc: '', + // withdrawDesc: '', + // name: 'ERC20', + // resetAddressStatus: false, + // addressRegex: '^(0x)[0-9A-Fa-f]{40}$', + // memoRegex: '', + // withdrawFee: '0.34', + // withdrawMin: '0.68', + // withdrawMax: '0', + // minConfirm: 12, + // unLockConfirm: 0 + // } + // ] + // } + // + const entry = response[i]; + const id = this.safeString (entry, 'coin'); + const name = this.safeString (entry, 'name'); + const code = this.safeCurrencyCode (id); + const precision = undefined; + let isWithdrawEnabled = true; + let isDepositEnabled = true; + const networkList = this.safeValue (entry, 'networkList', []); + const fees = {}; + let fee = undefined; + for (let j = 0; j < networkList.length; j++) { + const networkItem = networkList[j]; + const name = this.safeString (networkItem, 'name'); + const withdrawFee = this.safeFloat (networkItem, 'withdrawFee'); + const depositEnable = this.safeValue (networkItem, 'depositEnable'); + const withdrawEnable = this.safeValue (networkItem, 'withdrawEnable'); + isDepositEnabled = isDepositEnabled || depositEnable; + isWithdrawEnabled = isWithdrawEnabled || withdrawEnable; + fees[name] = withdrawFee; + const isDefault = this.safeValue (networkItem, 'isDefault'); + if (isDefault || fee === undefined) { + fee = withdrawFee; + } + } + const trading = this.safeValue (entry, 'trading'); + const active = (isWithdrawEnabled && isDepositEnabled && trading); + result[code] = { + 'id': id, + 'name': name, + 'code': code, + 'precision': precision, + 'info': entry, + 'active': active, + 'fee': fee, + 'fees': fees, + 'limits': this.limits, + }; + } + return result; + } + async fetchMarkets (params = {}) { const defaultType = this.safeString2 (this.options, 'fetchMarkets', 'defaultType', 'spot'); const type = this.safeString (params, 'type', defaultType); @@ -715,9 +911,8 @@ module.exports = class binance extends Exchange { const quoteId = this.safeString (market, 'quoteAsset'); const base = this.safeCurrencyCode (baseId); const quote = this.safeCurrencyCode (quoteId); - const parts = id.split ('_'); - const lastPart = this.safeString (parts, 1); - const idSymbol = (delivery) && (lastPart !== 'PERP'); + const contractType = this.safeString (market, 'contractType'); + const idSymbol = (future || delivery) && (contractType !== 'PERPETUAL'); const symbol = idSymbol ? id : (base + '/' + quote); const filters = this.safeValue (market, 'filters', []); const filtersByType = this.indexBy (filters, 'filterType'); @@ -795,7 +990,7 @@ module.exports = class binance extends Exchange { } if ('MIN_NOTIONAL' in filtersByType) { const filter = this.safeValue (filtersByType, 'MIN_NOTIONAL', {}); - entry['limits']['cost']['min'] = this.safeFloat (filter, 'minNotional'); + entry['limits']['cost']['min'] = this.safeFloat2 (filter, 'minNotional', 'notional'); } result.push (entry); } @@ -1197,15 +1392,24 @@ module.exports = class binance extends Exchange { async fetchOHLCV (symbol, timeframe = '1m', since = undefined, limit = undefined, params = {}) { await this.loadMarkets (); const market = this.market (symbol); + // binance docs say that the default limit 500, max 1500 for futures, max 1000 for spot markets + // the reality is that the time range wider than 500 candles won't work right + const defaultLimit = 500; + const maxLimit = 1500; + limit = (limit === undefined) ? defaultLimit : Math.min (limit, maxLimit); const request = { 'symbol': market['id'], 'interval': this.timeframes[timeframe], + 'limit': limit, }; + const duration = this.parseTimeframe (timeframe); if (since !== undefined) { request['startTime'] = since; - } - if (limit !== undefined) { - request['limit'] = limit; // default == max == 500 + if (since > 0) { + const endTime = this.sum (since, limit * duration * 1000 - 1); + const now = this.milliseconds (); + request['endTime'] = Math.min (now, endTime); + } } let method = 'publicGetKlines'; if (market['future']) { @@ -1293,6 +1497,23 @@ module.exports = class binance extends Exchange { // "symbol": "BTCUSDT", // "time": 1569514978020 // } + // { + // "symbol": "BTCUSDT", + // "id": 477128891, + // "orderId": 13809777875, + // "side": "SELL", + // "price": "38479.55", + // "qty": "0.001", + // "realizedPnl": "-0.00009534", + // "marginAsset": "USDT", + // "quoteQty": "38.47955", + // "commission": "-0.00076959", + // "commissionAsset": "USDT", + // "time": 1612733566708, + // "positionSide": "BOTH", + // "maker": true, + // "buyer": false + // } // const timestamp = this.safeInteger2 (trade, 'T', 'time'); const price = this.safeFloat2 (trade, 'p', 'price'); @@ -1322,6 +1543,9 @@ module.exports = class binance extends Exchange { if ('isMaker' in trade) { takerOrMaker = trade['isMaker'] ? 'maker' : 'taker'; } + if ('maker' in trade) { + takerOrMaker = trade['maker'] ? 'maker' : 'taker'; + } const marketId = this.safeString (trade, 'symbol'); const symbol = this.safeSymbol (marketId, market); let cost = undefined; @@ -1439,7 +1663,7 @@ module.exports = class binance extends Exchange { 'CANCELED': 'canceled', 'PENDING_CANCEL': 'canceling', // currently unused 'REJECTED': 'rejected', - 'EXPIRED': 'canceled', + 'EXPIRED': 'expired', }; return this.safeString (statuses, status, status); } @@ -1565,6 +1789,8 @@ module.exports = class binance extends Exchange { } const clientOrderId = this.safeString (order, 'clientOrderId'); const timeInForce = this.safeString (order, 'timeInForce'); + const postOnly = (type === 'limit_maker') || (timeInForce === 'GTX'); + const stopPrice = this.safeFloat (order, 'stopPrice'); return { 'info': order, 'id': id, @@ -1575,8 +1801,10 @@ module.exports = class binance extends Exchange { 'symbol': symbol, 'type': type, 'timeInForce': timeInForce, + 'postOnly': postOnly, 'side': side, 'price': price, + 'stopPrice': stopPrice, 'amount': amount, 'cost': cost, 'average': average, @@ -1621,7 +1849,15 @@ module.exports = class binance extends Exchange { 'type': uppercaseType, 'side': side.toUpperCase (), }; - if (clientOrderId !== undefined) { + if (clientOrderId === undefined) { + const broker = this.safeValue (this.options, 'broker'); + if (broker) { + const brokerId = this.safeString (broker, orderType); + if (brokerId !== undefined) { + request['newClientOrderId'] = brokerId + this.uuid22 (); + } + } + } else { request['newClientOrderId'] = clientOrderId; } if (market['spot']) { @@ -1700,7 +1936,7 @@ module.exports = class binance extends Exchange { quantityIsRequired = true; const callbackRate = this.safeFloat (params, 'callbackRate'); if (callbackRate === undefined) { - throw new InvalidOrder (this.id + ' createOrder method requires a callbackRate extra param for a ' + type + ' order'); + throw new InvalidOrder (this.id + ' createOrder() requires a callbackRate extra param for a ' + type + ' order'); } } if (quantityIsRequired) { @@ -1708,7 +1944,7 @@ module.exports = class binance extends Exchange { } if (priceIsRequired) { if (price === undefined) { - throw new InvalidOrder (this.id + ' createOrder method requires a price argument for a ' + type + ' order'); + throw new InvalidOrder (this.id + ' createOrder() requires a price argument for a ' + type + ' order'); } request['price'] = this.priceToPrecision (symbol, price); } @@ -1718,7 +1954,7 @@ module.exports = class binance extends Exchange { if (stopPriceIsRequired) { const stopPrice = this.safeFloat (params, 'stopPrice'); if (stopPrice === undefined) { - throw new InvalidOrder (this.id + ' createOrder method requires a stopPrice extra param for a ' + type + ' order'); + throw new InvalidOrder (this.id + ' createOrder() requires a stopPrice extra param for a ' + type + ' order'); } else { params = this.omit (params, 'stopPrice'); request['stopPrice'] = this.priceToPrecision (symbol, stopPrice); @@ -1730,7 +1966,7 @@ module.exports = class binance extends Exchange { async fetchOrder (id, symbol = undefined, params = {}) { if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' fetchOrder requires a symbol argument'); + throw new ArgumentsRequired (this.id + ' fetchOrder() requires a symbol argument'); } await this.loadMarkets (); const market = this.market (symbol); @@ -1751,7 +1987,7 @@ module.exports = class binance extends Exchange { if (clientOrderId !== undefined) { request['origClientOrderId'] = clientOrderId; } else { - request['orderId'] = parseInt (id); + request['orderId'] = id; } const query = this.omit (params, [ 'type', 'clientOrderId', 'origClientOrderId' ]); const response = await this[method] (this.extend (request, query)); @@ -1760,7 +1996,7 @@ module.exports = class binance extends Exchange { async fetchOrders (symbol = undefined, since = undefined, limit = undefined, params = {}) { if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' fetchOrders requires a symbol argument'); + throw new ArgumentsRequired (this.id + ' fetchOrders() requires a symbol argument'); } await this.loadMarkets (); const market = this.market (symbol); @@ -1873,7 +2109,7 @@ module.exports = class binance extends Exchange { async cancelOrder (id, symbol = undefined, params = {}) { if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' cancelOrder requires a symbol argument'); + throw new ArgumentsRequired (this.id + ' cancelOrder() requires a symbol argument'); } await this.loadMarkets (); const market = this.market (symbol); @@ -1883,11 +2119,11 @@ module.exports = class binance extends Exchange { const origClientOrderId = this.safeValue2 (params, 'origClientOrderId', 'clientOrderId'); const request = { 'symbol': market['id'], - // 'orderId': parseInt (id), + // 'orderId': id, // 'origClientOrderId': id, }; if (origClientOrderId === undefined) { - request['orderId'] = parseInt (id); + request['orderId'] = id; } else { request['origClientOrderId'] = origClientOrderId; } @@ -1906,7 +2142,7 @@ module.exports = class binance extends Exchange { async cancelAllOrders (symbol = undefined, params = {}) { if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' cancelAllOrders requires a symbol argument'); + throw new ArgumentsRequired (this.id + ' cancelAllOrders() requires a symbol argument'); } await this.loadMarkets (); const market = this.market (symbol); @@ -1917,7 +2153,9 @@ module.exports = class binance extends Exchange { const type = this.safeString (params, 'type', defaultType); const query = this.omit (params, 'type'); let method = 'privateDeleteOpenOrders'; - if (type === 'future') { + if (type === 'margin') { + method = 'sapiDeleteMarginOpenOrders'; + } else if (type === 'future') { method = 'fapiPrivateDeleteAllOpenOrders'; } else if (type === 'delivery') { method = 'dapiPrivateDeleteAllOpenOrders'; @@ -1983,20 +2221,23 @@ module.exports = class binance extends Exchange { async fetchMyTrades (symbol = undefined, since = undefined, limit = undefined, params = {}) { if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' fetchMyTrades requires a symbol argument'); + throw new ArgumentsRequired (this.id + ' fetchMyTrades() requires a symbol argument'); } await this.loadMarkets (); const market = this.market (symbol); - const type = this.safeValue (params, 'type', market['type']); + const defaultType = this.safeString2 (this.options, 'fetchMyTrades', 'defaultType', market['type']); + const type = this.safeString (params, 'type', defaultType); + params = this.omit (params, 'type'); let method = undefined; if (type === 'spot') { method = 'privateGetMyTrades'; + } else if (type === 'margin') { + method = 'sapiGetMarginMyTrades'; } else if (type === 'future') { method = 'fapiPrivateGetUserTrades'; } else if (type === 'delivery') { method = 'dapiPrivateGetUserTrades'; } - params = this.omit (params, 'type'); const request = { 'symbol': market['id'], }; @@ -2280,7 +2521,10 @@ module.exports = class binance extends Exchange { tag = undefined; } } - const txid = this.safeString (transaction, 'txId'); + let txid = this.safeString (transaction, 'txId'); + if ((txid !== undefined) && (txid.indexOf ('Internal transfer ') >= 0)) { + txid = txid.slice (18); + } const currencyId = this.safeString (transaction, 'asset'); const code = this.safeCurrencyCode (currencyId, currency); let timestamp = undefined; @@ -2329,15 +2573,27 @@ module.exports = class binance extends Exchange { await this.loadMarkets (); const currency = this.currency (code); const request = { - 'asset': currency['id'], + 'coin': currency['id'], + // 'network': 'ETH', // 'BSC', 'XMR', you can get network and isDefault in networkList in the response of sapiGetCapitalConfigDetail }; - const response = await this.wapiGetDepositAddress (this.extend (request, params)); - const success = this.safeValue (response, 'success'); - if ((success === undefined) || !success) { - throw new InvalidAddress (this.id + ' fetchDepositAddress returned an empty response – create the deposit address in the user settings first.'); - } + // has support for the 'network' parameter + // https://binance-docs.github.io/apidocs/spot/en/#deposit-address-supporting-network-user_data + const response = await this.sapiGetCapitalDepositAddress (this.extend (request, params)); + // + // { + // currency: 'XRP', + // address: 'rEb8TK3gBgk5auZkwc6sHnwrGVJH8DuaLh', + // tag: '108618262', + // info: { + // coin: 'XRP', + // address: 'rEb8TK3gBgk5auZkwc6sHnwrGVJH8DuaLh', + // tag: '108618262', + // url: 'https://bithomp.com/explorer/rEb8TK3gBgk5auZkwc6sHnwrGVJH8DuaLh' + // } + // } + // const address = this.safeString (response, 'address'); - const tag = this.safeString (response, 'addressTag'); + const tag = this.safeString (response, 'tag'); this.checkAddress (address); return { 'currency': code, @@ -2515,7 +2771,7 @@ module.exports = class binance extends Exchange { 'timestamp': this.nonce (), 'recvWindow': recvWindow, }, params)); - } else if (path === 'batchOrders') { + } else if ((path === 'batchOrders') || (path.indexOf ('sub-account') >= 0)) { query = this.rawencode (this.extend ({ 'timestamp': this.nonce (), 'recvWindow': recvWindow, diff --git a/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/binanceus.js b/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/binanceus.js index c35f3f3e4..f7bd5c19c 100644 --- a/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/binanceus.js +++ b/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/binanceus.js @@ -42,5 +42,9 @@ module.exports = class binanceus extends binance { }, }); } + + async fetchCurrencies (params = {}) { + return undefined; + } }; diff --git a/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/bit2c.js b/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/bit2c.js index f09a98746..a4d60733a 100644 --- a/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/bit2c.js +++ b/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/bit2c.js @@ -306,6 +306,7 @@ module.exports = class bit2c extends Exchange { 'symbol': symbol, 'type': undefined, 'timeInForce': undefined, + 'postOnly': undefined, 'side': side, 'price': price, 'stopPrice': undefined, diff --git a/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/bitbank.js b/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/bitbank.js index 722f16be6..d357531d7 100644 --- a/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/bitbank.js +++ b/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/bitbank.js @@ -82,6 +82,8 @@ module.exports = class bitbank extends Exchange { 'BCH/JPY': { 'id': 'bcc_jpy', 'symbol': 'BCH/JPY', 'base': 'BCH', 'quote': 'JPY', 'baseId': 'bcc', 'quoteId': 'jpy' }, 'MONA/BTC': { 'id': 'mona_btc', 'symbol': 'MONA/BTC', 'base': 'MONA', 'quote': 'BTC', 'baseId': 'mona', 'quoteId': 'btc' }, 'MONA/JPY': { 'id': 'mona_jpy', 'symbol': 'MONA/JPY', 'base': 'MONA', 'quote': 'JPY', 'baseId': 'mona', 'quoteId': 'jpy' }, + 'QTUM/BTC': { 'id': 'qtum_btc', 'symbol': 'QTUM/BTC', 'base': 'QTUM', 'quote': 'BTC', 'baseId': 'qtum', 'quoteId': 'btc' }, + 'QTUM/JPY': { 'id': 'qtum_jpy', 'symbol': 'QTUM/JPY', 'base': 'QTUM', 'quote': 'JPY', 'baseId': 'qtum', 'quoteId': 'jpy' }, 'ETH/BTC': { 'id': 'eth_btc', 'symbol': 'ETH/BTC', 'base': 'ETH', 'quote': 'BTC', 'baseId': 'eth', 'quoteId': 'btc' }, 'LTC/BTC': { 'id': 'ltc_btc', 'symbol': 'LTC/BTC', 'base': 'LTC', 'quote': 'BTC', 'baseId': 'ltc', 'quoteId': 'btc' }, 'XRP/JPY': { 'id': 'xrp_jpy', 'symbol': 'XRP/JPY', 'base': 'XRP', 'quote': 'JPY', 'baseId': 'xrp', 'quoteId': 'jpy' }, @@ -90,6 +92,7 @@ module.exports = class bitbank extends Exchange { 'ETH/JPY': { 'id': 'eth_jpy', 'symbol': 'ETH/JPY', 'base': 'ETH', 'quote': 'JPY', 'baseId': 'eth', 'quoteId': 'jpy' }, 'LTC/JPY': { 'id': 'ltc_jpy', 'symbol': 'LTC/JPY', 'base': 'LTC', 'quote': 'JPY', 'baseId': 'ltc', 'quoteId': 'jpy' }, 'XRP/BTC': { 'id': 'xrp_btc', 'symbol': 'XRP/BTC', 'base': 'XRP', 'quote': 'BTC', 'baseId': 'xrp', 'quoteId': 'btc' }, + 'XLM/BTC': { 'id': 'xlm_btc', 'symbol': 'XLM/BTC', 'base': 'XLM', 'quote': 'BTC', 'baseId': 'xlm', 'quoteId': 'btc' }, }, 'fees': { 'trading': { @@ -207,8 +210,8 @@ module.exports = class bitbank extends Exchange { const feeCost = this.safeFloat (trade, 'fee_amount_quote'); if (feeCost !== undefined) { fee = { - 'currency': market['quote'], - 'cost': feeCurrency, + 'currency': feeCurrency, + 'cost': feeCost, }; } const orderId = this.safeString (trade, 'order_id'); @@ -367,6 +370,7 @@ module.exports = class bitbank extends Exchange { 'symbol': symbol, 'type': type, 'timeInForce': undefined, + 'postOnly': undefined, 'side': side, 'price': price, 'stopPrice': undefined, @@ -385,7 +389,7 @@ module.exports = class bitbank extends Exchange { await this.loadMarkets (); const market = this.market (symbol); if (price === undefined) { - throw new InvalidOrder (this.id + ' createOrder requires a price argument for both market and limit orders'); + throw new InvalidOrder (this.id + ' createOrder() requires a price argument for both market and limit orders'); } const request = { 'pair': market['id'], diff --git a/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/bitbay.js b/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/bitbay.js index f1cb3a288..4f502e934 100644 --- a/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/bitbay.js +++ b/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/bitbay.js @@ -351,6 +351,7 @@ module.exports = class bitbay extends Exchange { filled = Math.max (0, amount - remaining); } } + const postOnly = this.safeValue (order, 'postOnly'); return { 'id': this.safeString (order, 'id'), 'clientOrderId': undefined, @@ -362,6 +363,7 @@ module.exports = class bitbay extends Exchange { 'symbol': symbol, 'type': this.safeString (order, 'mode'), 'timeInForce': undefined, + 'postOnly': postOnly, 'side': this.safeStringLower (order, 'offerType'), 'price': this.safeFloat (order, 'rate'), 'stopPrice': undefined, diff --git a/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/bitfinex.js b/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/bitfinex.js index ed9038a81..6d34687ff 100644 --- a/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/bitfinex.js +++ b/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/bitfinex.js @@ -16,7 +16,6 @@ module.exports = class bitfinex extends Exchange { 'countries': [ 'VG' ], 'version': 'v1', 'rateLimit': 1500, - 'certified': true, 'pro': true, // new metainfo interface 'has': { @@ -54,6 +53,7 @@ module.exports = class bitfinex extends Exchange { '30m': '30m', '1h': '1h', '3h': '3h', + '4h': '4h', '6h': '6h', '12h': '12h', '1d': '1D', @@ -600,13 +600,32 @@ module.exports = class bitfinex extends Exchange { async fetchBalance (params = {}) { await this.loadMarkets (); + const types = { + 'exchange': 'exchange', + 'deposit': 'funding', + 'trading': 'margin', + }; const balanceType = this.safeString (params, 'type', 'exchange'); const query = this.omit (params, 'type'); const response = await this.privatePostBalances (query); + // [ { type: 'deposit', + // currency: 'btc', + // amount: '0.00116721', + // available: '0.00116721' }, + // { type: 'exchange', + // currency: 'ust', + // amount: '0.0000002', + // available: '0.0000002' }, + // { type: 'trading', + // currency: 'btc', + // amount: '0.0005', + // available: '0.0005' } ], const result = { 'info': response }; for (let i = 0; i < response.length; i++) { const balance = response[i]; - if (balance['type'] === balanceType) { + const type = this.safeString (balance, 'type'); + const parsedType = this.safeString (types, type); + if ((parsedType === balanceType) || (type === balanceType)) { const currencyId = this.safeString (balance, 'currency'); const code = this.safeCurrencyCode (currencyId); // bitfinex had BCH previously, now it's BAB, but the old @@ -769,7 +788,7 @@ module.exports = class bitfinex extends Exchange { async fetchMyTrades (symbol = undefined, since = undefined, limit = undefined, params = {}) { if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' fetchMyTrades requires a `symbol` argument'); + throw new ArgumentsRequired (this.id + ' fetchMyTrades() requires a `symbol` argument'); } await this.loadMarkets (); const market = this.market (symbol); @@ -887,6 +906,7 @@ module.exports = class bitfinex extends Exchange { 'symbol': symbol, 'type': orderType, 'timeInForce': undefined, + 'postOnly': undefined, 'side': side, 'price': this.safeFloat (order, 'price'), 'stopPrice': undefined, diff --git a/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/bitfinex2.js b/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/bitfinex2.js index 5c44875e0..b47da9faf 100644 --- a/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/bitfinex2.js +++ b/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/bitfinex2.js @@ -3,7 +3,7 @@ // --------------------------------------------------------------------------- const bitfinex = require ('./bitfinex.js'); -const { ExchangeError, InvalidAddress, ArgumentsRequired, InsufficientFunds, AuthenticationError, OrderNotFound, InvalidOrder, BadRequest, InvalidNonce, BadSymbol, OnMaintenance } = require ('./base/errors'); +const { ExchangeError, InvalidAddress, ArgumentsRequired, InsufficientFunds, AuthenticationError, OrderNotFound, InvalidOrder, BadRequest, InvalidNonce, BadSymbol, OnMaintenance, NotSupported } = require ('./base/errors'); // --------------------------------------------------------------------------- @@ -53,6 +53,7 @@ module.exports = class bitfinex2 extends bitfinex { '30m': '30m', '1h': '1h', '3h': '3h', + '4h': '4h', '6h': '6h', '12h': '12h', '1d': '1D', @@ -171,7 +172,9 @@ module.exports = class bitfinex2 extends bitfinex { 'auth/w/position/claim', 'auth/r/positions/hist', 'auth/r/positions/audit', + 'auth/r/positions/snap', 'auth/w/deriv/collateral/set', + 'auth/w/deriv/collateral/limits', 'auth/r/funding/offers', 'auth/r/funding/offers/{symbol}', 'auth/w/funding/offer/submit', @@ -583,6 +586,10 @@ module.exports = class bitfinex2 extends bitfinex { return this.parseBalance (result); } + async fetchOrder (id, symbol = undefined, params = {}) { + throw new NotSupported (this.id + ' fetchOrder is not implemented yet'); + } + async fetchOrderBook (symbol, limit = undefined, params = {}) { await this.loadMarkets (); const precision = this.safeValue (this.options, 'precision', 'R0'); @@ -923,6 +930,7 @@ module.exports = class bitfinex2 extends bitfinex { 'symbol': symbol, 'type': type, 'timeInForce': undefined, + 'postOnly': undefined, 'side': side, 'price': price, 'stopPrice': undefined, @@ -941,16 +949,43 @@ module.exports = class bitfinex2 extends bitfinex { await this.loadMarkets (); const market = this.market (symbol); const orderTypes = this.safeValue (this.options, 'orderTypes', {}); - const orderType = this.safeString (orderTypes, type, type); + const orderType = this.safeStringUpper (orderTypes, type, type); amount = (side === 'sell') ? -amount : amount; const request = { 'symbol': market['id'], 'type': orderType, 'amount': this.numberToString (amount), }; - if (type !== 'market') { + if ((orderType === 'LIMIT') || (orderType === 'EXCHANGE LIMIT')) { + request['price'] = this.numberToString (price); + } else if ((orderType === 'STOP') || (orderType === 'EXCHANGE STOP')) { + const stopPrice = this.safeFloat (params, 'stopPrice', price); + request['price'] = this.numberToString (stopPrice); + } else if ((orderType === 'STOP LIMIT') || (orderType === 'EXCHANGE STOP LIMIT')) { + const priceAuxLimit = this.safeFloat (params, 'price_aux_limit'); + let stopPrice = this.safeFloat (params, 'stopPrice'); + if (priceAuxLimit === undefined) { + if (stopPrice === undefined) { + throw new ArgumentsRequired (this.id + ' createOrder() requires a stopPrice parameter or a price_aux_limit parameter for a ' + orderType + ' order'); + } else { + request['price_aux_limit'] = this.numberToString (price); + } + } else { + request['price_aux_limit'] = this.numberToString (priceAuxLimit); + if (stopPrice === undefined) { + stopPrice = price; + } + } + request['price'] = this.numberToString (stopPrice); + } else if ((orderType === 'TRAILING STOP') || (orderType === 'EXCHANGE TRAILING STOP')) { + const priceTrailing = this.safeFloat (params, 'price_trailing'); + request['price_trailing'] = this.numberToString (priceTrailing); + const stopPrice = this.safeFloat (params, 'stopPrice', price); + request['price'] = this.numberToString (stopPrice); + } else if ((orderType === 'FOK') || (orderType === 'EXCHANGE FOK') || (orderType === 'IOC') || (orderType === 'EXCHANGE IOC')) { request['price'] = this.numberToString (price); } + params = this.omit (params, [ 'stopPrice', 'price_aux_limit', 'price_trailing' ]); const clientOrderId = this.safeValue2 (params, 'cid', 'clientOrderId'); if (clientOrderId !== undefined) { request['cid'] = clientOrderId; diff --git a/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/bitflyer.js b/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/bitflyer.js index 99c60448b..f9c19b59a 100644 --- a/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/bitflyer.js +++ b/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/bitflyer.js @@ -365,6 +365,7 @@ module.exports = class bitflyer extends Exchange { 'symbol': symbol, 'type': type, 'timeInForce': undefined, + 'postOnly': undefined, 'side': side, 'price': price, 'stopPrice': undefined, @@ -424,7 +425,7 @@ module.exports = class bitflyer extends Exchange { async fetchMyTrades (symbol = undefined, since = undefined, limit = undefined, params = {}) { if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' fetchMyTrades requires a `symbol` argument'); + throw new ArgumentsRequired (this.id + ' fetchMyTrades() requires a `symbol` argument'); } await this.loadMarkets (); const market = this.market (symbol); @@ -440,7 +441,7 @@ module.exports = class bitflyer extends Exchange { async fetchPositions (symbols = undefined, since = undefined, limit = undefined, params = {}) { if (symbols === undefined) { - throw new ArgumentsRequired (this.id + ' fetchPositions requires a `symbols` argument, exactly one symbol in an array'); + throw new ArgumentsRequired (this.id + ' fetchPositions() requires a `symbols` argument, exactly one symbol in an array'); } await this.loadMarkets (); const request = { diff --git a/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/bitforex.js b/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/bitforex.js index 9932a4d34..8fa337979 100644 --- a/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/bitforex.js +++ b/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/bitforex.js @@ -3,7 +3,7 @@ // --------------------------------------------------------------------------- const Exchange = require ('./base/Exchange'); -const { ExchangeError, AuthenticationError, OrderNotFound, InsufficientFunds, DDoSProtection, PermissionDenied } = require ('./base/errors'); +const { ExchangeError, AuthenticationError, OrderNotFound, InsufficientFunds, DDoSProtection, PermissionDenied, BadSymbol } = require ('./base/errors'); // --------------------------------------------------------------------------- @@ -223,6 +223,7 @@ module.exports = class bitforex extends Exchange { }, 'commonCurrencies': { 'CREDIT': 'TerraCredit', + 'HBC': 'Hybrid Bank Cash', 'IQ': 'IQ.Cash', 'UOS': 'UOS Network', }, @@ -231,6 +232,7 @@ module.exports = class bitforex extends Exchange { '1013': AuthenticationError, '1016': AuthenticationError, '1017': PermissionDenied, // {"code":"1017","success":false,"time":1602670594367,"message":"IP not allow"} + '1019': BadSymbol, // {"code":"1019","success":false,"time":1607087743778,"message":"Symbol Invalid"} '3002': InsufficientFunds, '10204': DDoSProtection, }, @@ -499,6 +501,7 @@ module.exports = class bitforex extends Exchange { 'symbol': symbol, 'type': type, 'timeInForce': undefined, + 'postOnly': undefined, 'side': side, 'price': price, 'stopPrice': undefined, diff --git a/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/bitget.js b/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/bitget.js index 78e7fe8aa..3c9581955 100644 --- a/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/bitget.js +++ b/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/bitget.js @@ -1704,7 +1704,7 @@ module.exports = class bitget extends Exchange { const type = this.safeString (params, 'type', defaultType); params = this.omit (params, 'type'); if (type === undefined) { - throw new ArgumentsRequired (this.id + " requires an 'accountId' parameter"); + throw new ArgumentsRequired (this.id + " getAccountId() requires an 'accountId' parameter"); } const account = await this.findAccountByType (type); return account['id']; @@ -1716,7 +1716,7 @@ module.exports = class bitget extends Exchange { const defaultType = this.safeString2 (this.options, 'fetchBalance', 'defaultType'); const type = this.safeString (params, 'type', defaultType); if (type === undefined) { - throw new ArgumentsRequired (this.id + " fetchBalance requires a 'type' parameter, one of 'spot', 'swap'"); + throw new ArgumentsRequired (this.id + " fetchBalance() requires a 'type' parameter, one of 'spot', 'swap'"); } let method = undefined; const query = this.omit (params, 'type'); @@ -1960,6 +1960,7 @@ module.exports = class bitget extends Exchange { 'symbol': symbol, 'type': type, 'timeInForce': undefined, + 'postOnly': undefined, 'side': side, 'price': price, 'stopPrice': undefined, @@ -2042,7 +2043,7 @@ module.exports = class bitget extends Exchange { request['client_oid'] = clientOrderId; const orderType = this.safeString (params, 'type'); if (orderType === undefined) { - throw new ArgumentsRequired (this.id + " createOrder requires a type parameter, '1' = open long, '2' = open short, '3' = close long, '4' = close short for " + market['type'] + ' orders'); + throw new ArgumentsRequired (this.id + " createOrder() requires a type parameter, '1' = open long, '2' = open short, '3' = close long, '4' = close short for " + market['type'] + ' orders'); } request['size'] = this.amountToPrecision (symbol, amount); request['type'] = orderType; @@ -2084,7 +2085,7 @@ module.exports = class bitget extends Exchange { const type = this.safeString (params, 'type', defaultType); if (type === 'spot') { if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' cancelOrder requires a symbol argument for spot orders'); + throw new ArgumentsRequired (this.id + ' cancelOrder() requires a symbol argument for spot orders'); } } } else { @@ -2125,14 +2126,15 @@ module.exports = class bitget extends Exchange { async cancelOrders (ids, symbol = undefined, params = {}) { if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' cancelOrders requires a symbol argument'); + throw new ArgumentsRequired (this.id + ' cancelOrders() requires a symbol argument'); } await this.loadMarkets (); const market = this.market (symbol); const type = this.safeString (params, 'type', market['type']); if (type === undefined) { - throw new ArgumentsRequired (this.id + " cancelOrders requires a type parameter (one of 'spot', 'swap')."); + throw new ArgumentsRequired (this.id + " cancelOrders() requires a type parameter (one of 'spot', 'swap')."); } + params = this.omit (params, 'type'); const request = {}; let method = undefined; if (type === 'spot') { @@ -2189,13 +2191,13 @@ module.exports = class bitget extends Exchange { async fetchOrder (id, symbol = undefined, params = {}) { if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' fetchOrder requires a symbol argument'); + throw new ArgumentsRequired (this.id + ' fetchOrder() requires a symbol argument'); } await this.loadMarkets (); const market = this.market (symbol); const type = this.safeString (params, 'type', market['type']); if (type === undefined) { - throw new ArgumentsRequired (this.id + " fetchOrder requires a type parameter (one of 'spot', 'swap')."); + throw new ArgumentsRequired (this.id + " fetchOrder() requires a type parameter (one of 'spot', 'swap')."); } let method = undefined; const request = {}; @@ -2266,7 +2268,7 @@ module.exports = class bitget extends Exchange { async fetchOpenOrders (symbol = undefined, since = undefined, limit = undefined, params = {}) { if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' fetchOpenOrders requires a symbol argument'); + throw new ArgumentsRequired (this.id + ' fetchOpenOrders() requires a symbol argument'); } await this.loadMarkets (); const market = this.market (symbol); @@ -2351,7 +2353,7 @@ module.exports = class bitget extends Exchange { async fetchClosedOrders (symbol = undefined, since = undefined, limit = undefined, params = {}) { if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' fetchClosedOrders requires a symbol argument'); + throw new ArgumentsRequired (this.id + ' fetchClosedOrders() requires a symbol argument'); } await this.loadMarkets (); const market = this.market (symbol); @@ -2443,7 +2445,7 @@ module.exports = class bitget extends Exchange { async fetchDeposits (code = undefined, since = undefined, limit = undefined, params = {}) { if (code === undefined) { - throw new ArgumentsRequired (this.id + ' fetchDeposits requires a currency code argument'); + throw new ArgumentsRequired (this.id + ' fetchDeposits() requires a currency code argument'); } await this.loadMarkets (); const currency = this.currency (code); @@ -2480,7 +2482,7 @@ module.exports = class bitget extends Exchange { async fetchWithdrawals (code = undefined, since = undefined, limit = undefined, params = {}) { if (code === undefined) { - throw new ArgumentsRequired (this.id + ' fetchWithdrawals requires a currency code argument'); + throw new ArgumentsRequired (this.id + ' fetchWithdrawals() requires a currency code argument'); } await this.loadMarkets (); const currency = this.currency (code); @@ -2603,14 +2605,14 @@ module.exports = class bitget extends Exchange { async fetchMyTrades (symbol = undefined, since = undefined, limit = undefined, params = {}) { if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' fetchMyTrades requires a symbol argument'); + throw new ArgumentsRequired (this.id + ' fetchMyTrades() requires a symbol argument'); } await this.loadMarkets (); const market = this.market (symbol); const type = this.safeString (params, 'type', market['type']); const query = this.omit (params, 'type'); if (type === 'swap') { - throw new ArgumentsRequired (this.id + ' fetchMyTrades is not supported for ' + type + ' type'); + throw new ArgumentsRequired (this.id + ' fetchMyTrades() is not supported for ' + type + ' type'); } // // spot @@ -2667,12 +2669,12 @@ module.exports = class bitget extends Exchange { async fetchOrderTrades (id, symbol = undefined, since = undefined, limit = undefined, params = {}) { if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' fetchOrderTrades requires a symbol argument'); + throw new ArgumentsRequired (this.id + ' fetchOrderTrades() requires a symbol argument'); } await this.loadMarkets (); const market = this.market (symbol); const type = this.safeString (params, 'type', market['type']); - const query = this.omit (params, 'type'); + params = this.omit (params, 'type'); let method = undefined; const request = {}; if (type === 'spot') { @@ -2684,7 +2686,7 @@ module.exports = class bitget extends Exchange { request['symbol'] = market['id']; method = 'swapGetOrderFills'; } - const response = await this[method] (this.extend (request, query)); + const response = await this[method] (this.extend (request, params)); // // spot // diff --git a/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/bithumb.js b/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/bithumb.js index 904b8715d..ef4e7d479 100644 --- a/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/bithumb.js +++ b/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/bithumb.js @@ -22,6 +22,7 @@ module.exports = class bithumb extends Exchange { 'createOrder': true, 'fetchBalance': true, 'fetchMarkets': true, + 'fetchOHLCV': true, 'fetchOpenOrders': true, 'fetchOrder': true, 'fetchOrderBook': true, @@ -45,10 +46,13 @@ module.exports = class bithumb extends Exchange { 'get': [ 'ticker/{currency}', 'ticker/all', + 'ticker/ALL_BTC', + 'ticker/ALL_KRW', 'orderbook/{currency}', 'orderbook/all', 'transaction_history/{currency}', 'transaction_history/all', + 'candlestick/{currency}/{interval}', ], }, 'private': { @@ -92,6 +96,27 @@ module.exports = class bithumb extends Exchange { 'Unknown Error': ExchangeError, 'After May 23th, recent_transactions is no longer, hence users will not be able to connect to recent_transactions': ExchangeError, // {"status":"5100","message":"After May 23th, recent_transactions is no longer, hence users will not be able to connect to recent_transactions"} }, + 'timeframes': { + '1m': '1m', + '3m': '3m', + '5m': '5m', + '10m': '10m', + '30m': '30m', + '1h': '1h', + '6h': '6h', + '12h': '12h', + '1d': '24h', + }, + 'options': { + 'quoteCurrencies': { + 'BTC': { + 'precision': { + 'price': 8, + }, + }, + 'KRW': {}, + }, + }, }); } @@ -100,54 +125,61 @@ module.exports = class bithumb extends Exchange { } async fetchMarkets (params = {}) { - const response = await this.publicGetTickerAll (params); - const data = this.safeValue (response, 'data'); - const currencyIds = Object.keys (data); const result = []; - const quote = this.safeCurrencyCode ('KRW'); - for (let i = 0; i < currencyIds.length; i++) { - const currencyId = currencyIds[i]; - if (currencyId === 'date') { - continue; - } - const market = data[currencyId]; - const base = this.safeCurrencyCode (currencyId); - const symbol = currencyId + '/' + quote; - let active = true; - if (Array.isArray (market)) { - const numElements = market.length; - if (numElements === 0) { - active = false; + const quoteCurrencies = this.safeValue (this.options, 'quoteCurrencies', {}); + const quotes = Object.keys (quoteCurrencies); + for (let i = 0; i < quotes.length; i++) { + const quote = quotes[i]; + const extension = this.safeValue (quoteCurrencies, quote, {}); + const method = 'publicGetTickerALL' + quote; + const response = await this[method] (params); + const data = this.safeValue (response, 'data'); + const currencyIds = Object.keys (data); + for (let j = 0; j < currencyIds.length; j++) { + const currencyId = currencyIds[j]; + if (currencyId === 'date') { + continue; } + const market = data[currencyId]; + const base = this.safeCurrencyCode (currencyId); + const symbol = currencyId + '/' + quote; + let active = true; + if (Array.isArray (market)) { + const numElements = market.length; + if (numElements === 0) { + active = false; + } + } + const entry = this.deepExtend ({ + 'id': currencyId, + 'symbol': symbol, + 'base': base, + 'quote': quote, + 'info': market, + 'active': active, + 'precision': { + 'amount': 4, + 'price': 4, + }, + 'limits': { + 'amount': { + 'min': undefined, + 'max': undefined, + }, + 'price': { + 'min': undefined, + 'max': undefined, + }, + 'cost': { + 'min': 500, + 'max': 5000000000, + }, + }, + 'baseId': undefined, + 'quoteId': undefined, + }, extension); + result.push (entry); } - result.push ({ - 'id': currencyId, - 'symbol': symbol, - 'base': base, - 'quote': quote, - 'info': market, - 'active': active, - 'precision': { - 'amount': 4, - 'price': 4, - }, - 'limits': { - 'amount': { - 'min': undefined, - 'max': undefined, - }, - 'price': { - 'min': undefined, - 'max': undefined, - }, - 'cost': { - 'min': 500, - 'max': 5000000000, - }, - }, - 'baseId': undefined, - 'quoteId': undefined, - }); } return result; } @@ -349,6 +381,62 @@ module.exports = class bithumb extends Exchange { return this.parseTicker (data, market); } + parseOHLCV (ohlcv, market = undefined) { + // + // [ + // 1576823400000, // 기준 시간 + // '8284000', // 시가 + // '8286000', // 종가 + // '8289000', // 고가 + // '8276000', // 저가 + // '15.41503692' // 거래량 + // ] + // + return [ + this.safeInteger (ohlcv, 0), + this.safeFloat (ohlcv, 1), + this.safeFloat (ohlcv, 3), + this.safeFloat (ohlcv, 4), + this.safeFloat (ohlcv, 2), + this.safeFloat (ohlcv, 5), + ]; + } + + async fetchOHLCV (symbol, timeframe = '1m', since = undefined, limit = undefined, params = {}) { + await this.loadMarkets (); + const market = this.market (symbol); + const request = { + 'currency': market['base'], + 'interval': this.timeframes[timeframe], + }; + const response = await this.publicGetCandlestickCurrencyInterval (this.extend (request, params)); + // + // { + // 'status': '0000', + // 'data': { + // [ + // 1576823400000, // 기준 시간 + // '8284000', // 시가 + // '8286000', // 종가 + // '8289000', // 고가 + // '8276000', // 저가 + // '15.41503692' // 거래량 + // ], + // [ + // 1576824000000, // 기준 시간 + // '8284000', // 시가 + // '8281000', // 종가 + // '8289000', // 고가 + // '8275000', // 저가 + // '6.19584467' // 거래량 + // ], + // } + // } + // + const data = this.safeValue (response, 'data', []); + return this.parseOHLCVs (data, market, timeframe, since, limit); + } + parseTrade (trade, market = undefined) { // // fetchTrades (public) @@ -470,7 +558,7 @@ module.exports = class bithumb extends Exchange { const market = this.market (symbol); const request = { 'order_currency': market['id'], - 'Payment_currency': market['quote'], + 'payment_currency': market['quote'], 'units': amount, }; let method = 'privatePostTradePlace'; @@ -483,7 +571,7 @@ module.exports = class bithumb extends Exchange { const response = await this[method] (this.extend (request, params)); const id = this.safeString (response, 'order_id'); if (id === undefined) { - throw new InvalidOrder (this.id + ' createOrder did not return an order id'); + throw new InvalidOrder (this.id + ' createOrder() did not return an order id'); } return { 'info': response, @@ -496,7 +584,7 @@ module.exports = class bithumb extends Exchange { async fetchOrder (id, symbol = undefined, params = {}) { if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' fetchOrder requires a symbol argument'); + throw new ArgumentsRequired (this.id + ' fetchOrder() requires a symbol argument'); } await this.loadMarkets (); const market = this.market (symbol); @@ -708,6 +796,7 @@ module.exports = class bithumb extends Exchange { 'symbol': symbol, 'type': type, 'timeInForce': undefined, + 'postOnly': undefined, 'side': side, 'price': price, 'stopPrice': undefined, @@ -730,7 +819,7 @@ module.exports = class bithumb extends Exchange { async fetchOpenOrders (symbol = undefined, since = undefined, limit = undefined, params = {}) { if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' fetchOpenOrders requires a symbol argument'); + throw new ArgumentsRequired (this.id + ' fetchOpenOrders() requires a symbol argument'); } await this.loadMarkets (); const market = this.market (symbol); @@ -770,10 +859,10 @@ module.exports = class bithumb extends Exchange { async cancelOrder (id, symbol = undefined, params = {}) { const side_in_params = ('side' in params); if (!side_in_params) { - throw new ArgumentsRequired (this.id + ' cancelOrder requires a `symbol` argument and a `side` parameter (sell or buy)'); + throw new ArgumentsRequired (this.id + ' cancelOrder() requires a `symbol` argument and a `side` parameter (sell or buy)'); } if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' cancelOrder requires a `symbol` argument and a `side` parameter (sell or buy)'); + throw new ArgumentsRequired (this.id + ' cancelOrder() requires a `symbol` argument and a `side` parameter (sell or buy)'); } const market = this.market (symbol); const side = (params['side'] === 'buy') ? 'bid' : 'ask'; @@ -804,7 +893,7 @@ module.exports = class bithumb extends Exchange { 'address': address, 'currency': currency['id'], }; - if (currency === 'XRP' || currency === 'XMR') { + if (currency === 'XRP' || currency === 'XMR' || currency === 'EOS' || currency === 'STEEM') { const destination = this.safeString (params, 'destination'); if ((tag === undefined) && (destination === undefined)) { throw new ArgumentsRequired (this.id + ' ' + code + ' withdraw() requires a tag argument or an extra destination param'); diff --git a/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/bitkk.js b/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/bitkk.js index 055657b41..f416bef33 100644 --- a/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/bitkk.js +++ b/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/bitkk.js @@ -21,6 +21,9 @@ module.exports = class bitkk extends zb { 'doc': 'https://www.bitkk.com/i/developer', 'fees': 'https://www.bitkk.com/i/rate', }, + 'commonCurrencies': { + 'BCH': 'BCHOLD', + }, }); } }; diff --git a/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/bitmart.js b/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/bitmart.js index d99c5d095..4ad47118a 100644 --- a/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/bitmart.js +++ b/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/bitmart.js @@ -48,7 +48,7 @@ module.exports = class bitmart extends Exchange { 'logo': 'https://user-images.githubusercontent.com/1294454/61835713-a2662f80-ae85-11e9-9d00-6442919701fd.jpg', 'api': 'https://api-cloud.{hostname}', // bitmart.info for Hong Kong users 'www': 'https://www.bitmart.com/', - 'doc': 'https://github.com/bitmartexchange/bitmart-official-api-docs', + 'doc': 'https://developer-pro.bitmart.com/', 'referral': 'http://www.bitmart.com/?r=rQCFLh', 'fees': 'https://www.bitmart.com/fee/en', }, @@ -161,8 +161,8 @@ module.exports = class bitmart extends Exchange { 'trading': { 'tierBased': true, 'percentage': true, - 'taker': 0.002, - 'maker': 0.001, + 'taker': 0.0025, + 'maker': 0.0025, 'tiers': { 'taker': [ [0, 0.20 / 100], @@ -296,6 +296,8 @@ module.exports = class bitmart extends Exchange { 'broad': {}, }, 'commonCurrencies': { + 'COT': 'Community Coin', + 'CPC': 'CPCoin', 'ONE': 'Menlo One', 'PLA': 'Plair', }, @@ -1241,7 +1243,7 @@ module.exports = class bitmart extends Exchange { async fetchMyTrades (symbol = undefined, since = undefined, limit = undefined, params = {}) { if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' fetchMyTrades requires a symbol argument'); + throw new ArgumentsRequired (this.id + ' fetchMyTrades() requires a symbol argument'); } await this.loadMarkets (); const market = this.market (symbol); @@ -1249,7 +1251,7 @@ module.exports = class bitmart extends Exchange { const request = {}; if (market['spot']) { request['symbol'] = market['id']; - request['offset'] = 1; + request['offset'] = 1; // max offset * limit < 500 if (limit === undefined) { limit = 100; // max 100 } @@ -1322,7 +1324,7 @@ module.exports = class bitmart extends Exchange { async fetchOrderTrades (id, symbol = undefined, since = undefined, limit = undefined, params = {}) { if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' fetchOrderTrades requires a symbol argument'); + throw new ArgumentsRequired (this.id + ' fetchOrderTrades() requires a symbol argument'); } await this.loadMarkets (); const market = this.market (symbol); @@ -1600,6 +1602,7 @@ module.exports = class bitmart extends Exchange { 'symbol': symbol, 'type': type, 'timeInForce': undefined, + 'postOnly': undefined, 'side': side, 'price': price, 'stopPrice': undefined, @@ -1705,7 +1708,7 @@ module.exports = class bitmart extends Exchange { async cancelOrder (id, symbol = undefined, params = {}) { if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' cancelOrder requires a symbol argument'); + throw new ArgumentsRequired (this.id + ' cancelOrder() requires a symbol argument'); } await this.loadMarkets (); const market = this.market (symbol); @@ -1733,6 +1736,15 @@ module.exports = class bitmart extends Exchange { // } // } // + // spot alternative + // + // { + // "code": 1000, + // "trace":"886fb6ae-456b-4654-b4e0-d681ac05cea1", + // "message": "OK", + // "data": true + // } + // // contract // // { @@ -1748,16 +1760,19 @@ module.exports = class bitmart extends Exchange { // } // const data = this.safeValue (response, 'data'); + if (data === true) { + return this.parseOrder (id, market); + } const succeeded = this.safeValue (data, 'succeed'); if (succeeded !== undefined) { id = this.safeString (succeeded, 0); if (id === undefined) { - throw new InvalidOrder (this.id + ' cancelOrder failed to cancel ' + symbol + ' order id ' + id); + throw new InvalidOrder (this.id + ' cancelOrder() failed to cancel ' + symbol + ' order id ' + id); } } else { const result = this.safeValue (data, 'result'); if (!result) { - throw new InvalidOrder (this.id + ' cancelOrder ' + symbol + ' order id ' + id + ' is filled or canceled'); + throw new InvalidOrder (this.id + ' cancelOrder() ' + symbol + ' order id ' + id + ' is filled or canceled'); } } const order = this.parseOrder (id, market); @@ -1766,16 +1781,16 @@ module.exports = class bitmart extends Exchange { async cancelAllOrders (symbol = undefined, params = {}) { if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' cancelAllOrders requires a symbol argument'); + throw new ArgumentsRequired (this.id + ' cancelAllOrders() requires a symbol argument'); } const side = this.safeString (params, 'side'); if (side === undefined) { - throw new ArgumentsRequired (this.id + " cancelAllOrders requires a `side` parameter ('buy' or 'sell')"); + throw new ArgumentsRequired (this.id + " cancelAllOrders() requires a `side` parameter ('buy' or 'sell')"); } await this.loadMarkets (); const market = this.market (symbol); if (!market['spot']) { - throw new NotSupported (this.id + ' cancelAllOrders does not support ' + market['type'] + ' orders, only spot orders are accepted'); + throw new NotSupported (this.id + ' cancelAllOrders() does not support ' + market['type'] + ' orders, only spot orders are accepted'); } const request = { 'symbol': market['id'], @@ -1795,12 +1810,12 @@ module.exports = class bitmart extends Exchange { async cancelOrders (ids, symbol = undefined, params = {}) { if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' canelOrders requires a symbol argument'); + throw new ArgumentsRequired (this.id + ' canelOrders() requires a symbol argument'); } await this.loadMarkets (); const market = this.market (symbol); if (!market['spot']) { - throw new NotSupported (this.id + ' cancelOrders does not support ' + market['type'] + ' orders, only contract orders are accepted'); + throw new NotSupported (this.id + ' cancelOrders() does not support ' + market['type'] + ' orders, only contract orders are accepted'); } const orders = []; for (let i = 0; i < ids.length; i++) { @@ -1841,7 +1856,7 @@ module.exports = class bitmart extends Exchange { async fetchOrdersByStatus (status, symbol = undefined, since = undefined, limit = undefined, params = {}) { if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' fetchOrdersByStatus requires a symbol argument'); + throw new ArgumentsRequired (this.id + ' fetchOrdersByStatus() requires a symbol argument'); } await this.loadMarkets (); const market = this.market (symbol); @@ -1963,7 +1978,7 @@ module.exports = class bitmart extends Exchange { async fetchOrders (symbol = undefined, since = undefined, limit = undefined, params = {}) { if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' fetchOrders requires a symbol argument'); + throw new ArgumentsRequired (this.id + ' fetchOrders() requires a symbol argument'); } await this.loadMarkets (); const market = this.market (symbol); @@ -1975,7 +1990,7 @@ module.exports = class bitmart extends Exchange { async fetchOrder (id, symbol = undefined, params = {}) { if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' fetchOrder requires a symbol argument'); + throw new ArgumentsRequired (this.id + ' fetchOrder() requires a symbol argument'); } await this.loadMarkets (); const request = {}; @@ -2053,7 +2068,7 @@ module.exports = class bitmart extends Exchange { const orders = this.safeValue (data, 'orders', []); const firstOrder = this.safeValue (orders, 0); if (firstOrder === undefined) { - throw new OrderNotFound (this.id + ' fetchOrder could not find ' + symbol + ' order id ' + id); + throw new OrderNotFound (this.id + ' fetchOrder() could not find ' + symbol + ' order id ' + id); } return this.parseOrder (firstOrder, market); } else { diff --git a/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/bitmax.js b/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/bitmax.js index 0fa940d42..62cbf55d5 100644 --- a/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/bitmax.js +++ b/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/bitmax.js @@ -133,8 +133,8 @@ module.exports = class bitmax extends Exchange { 'trading': { 'tierBased': true, 'percentage': true, - 'taker': 0.001, - 'maker': 0.001, + 'taker': 0.002, + 'maker': 0.002, }, }, 'precisionMode': TICK_SIZE, @@ -1039,6 +1039,7 @@ module.exports = class bitmax extends Exchange { 'symbol': symbol, 'type': type, 'timeInForce': undefined, + 'postOnly': undefined, 'side': side, 'price': price, 'stopPrice': stopPrice, @@ -1089,7 +1090,7 @@ module.exports = class bitmax extends Exchange { if ((type === 'stop_limit') || (type === 'stop_market')) { const stopPrice = this.safeFloat (params, 'stopPrice'); if (stopPrice === undefined) { - throw new InvalidOrder (this.id + ' createOrder requires a stopPrice parameter for ' + type + ' orders'); + throw new InvalidOrder (this.id + ' createOrder() requires a stopPrice parameter for ' + type + ' orders'); } else { request['stopPrice'] = this.priceToPrecision (symbol, stopPrice); params = this.omit (params, 'stopPrice'); @@ -1344,7 +1345,7 @@ module.exports = class bitmax extends Exchange { async cancelOrder (id, symbol = undefined, params = {}) { if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' cancelOrder requires a symbol argument'); + throw new ArgumentsRequired (this.id + ' cancelOrder() requires a symbol argument'); } await this.loadMarkets (); await this.loadAccounts (); diff --git a/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/bitmex.js b/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/bitmex.js index 536120bf6..4f5a0552a 100644 --- a/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/bitmex.js +++ b/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/bitmex.js @@ -4,7 +4,7 @@ const Exchange = require ('./base/Exchange'); const { TICK_SIZE } = require ('./base/functions/number'); -const { AuthenticationError, BadRequest, DDoSProtection, ExchangeError, ExchangeNotAvailable, InsufficientFunds, InvalidOrder, OrderNotFound, PermissionDenied } = require ('./base/errors'); +const { AuthenticationError, BadRequest, DDoSProtection, ExchangeError, ExchangeNotAvailable, InsufficientFunds, InvalidOrder, OrderNotFound, PermissionDenied, ArgumentsRequired } = require ('./base/errors'); // --------------------------------------------------------------------------- @@ -167,6 +167,7 @@ module.exports = class bitmex extends Exchange { 'Account has insufficient Available Balance': InsufficientFunds, 'Service unavailable': ExchangeNotAvailable, // {"error":{"message":"Service unavailable","name":"HTTPError"}} 'Server Error': ExchangeError, // {"error":{"message":"Server Error","name":"HTTPError"}} + 'Unable to cancel order due to existing state': InvalidOrder, }, }, 'precisionMode': TICK_SIZE, @@ -1219,6 +1220,43 @@ module.exports = class bitmex extends Exchange { } parseOrder (order, market = undefined) { + // + // { + // "orderID":"56222c7a-9956-413a-82cf-99f4812c214b", + // "clOrdID":"", + // "clOrdLinkID":"", + // "account":1455728, + // "symbol":"XBTUSD", + // "side":"Sell", + // "simpleOrderQty":null, + // "orderQty":1, + // "price":40000, + // "displayQty":null, + // "stopPx":null, + // "pegOffsetValue":null, + // "pegPriceType":"", + // "currency":"USD", + // "settlCurrency":"XBt", + // "ordType":"Limit", + // "timeInForce":"GoodTillCancel", + // "execInst":"", + // "contingencyType":"", + // "exDestination":"XBME", + // "ordStatus":"New", + // "triggered":"", + // "workingIndicator":true, + // "ordRejReason":"", + // "simpleLeavesQty":null, + // "leavesQty":1, + // "simpleCumQty":null, + // "cumQty":0, + // "avgPx":null, + // "multiLegReportingType":"SingleSecurity", + // "text":"Submitted via API.", + // "transactTime":"2021-01-02T21:38:49.246Z", + // "timestamp":"2021-01-02T21:38:49.246Z" + // } + // const status = this.parseOrderStatus (this.safeString (order, 'ordStatus')); const marketId = this.safeString (order, 'symbol'); const symbol = this.safeSymbol (marketId, market); @@ -1248,6 +1286,8 @@ module.exports = class bitmex extends Exchange { const clientOrderId = this.safeString (order, 'clOrdID'); const timeInForce = this.parseTimeInForce (this.safeString (order, 'timeInForce')); const stopPrice = this.safeFloat (order, 'stopPx'); + const execInst = this.safeString (order, 'execInst'); + const postOnly = (execInst === 'ParticipateDoNotInitiate'); return { 'info': order, 'id': id, @@ -1258,6 +1298,7 @@ module.exports = class bitmex extends Exchange { 'symbol': symbol, 'type': type, 'timeInForce': timeInForce, + 'postOnly': postOnly, 'side': side, 'price': price, 'stopPrice': stopPrice, @@ -1326,18 +1367,21 @@ module.exports = class bitmex extends Exchange { const request = { 'symbol': market['id'], 'side': this.capitalize (side), - 'orderQty': amount, + 'orderQty': parseFloat (this.amountToPrecision (symbol, amount)), 'ordType': orderType, }; - if (price !== undefined) { - if (orderType === 'Stop') { - const stopPrice = this.safeFloat2 (params, 'stopPx', 'stopPrice'); - request['stopPx'] = stopPrice; - params = this.omit (params, [ 'stopPx', 'stopPrice' ]); + if ((orderType === 'Stop') || (orderType === 'StopLimit') || (orderType === 'MarketIfTouched') || (orderType === 'LimitIfTouched')) { + const stopPrice = this.safeFloat2 (params, 'stopPx', 'stopPrice'); + if (stopPrice === undefined) { + throw new ArgumentsRequired (this.id + ' createOrder() requires a stopPx or stopPrice parameter for the ' + orderType + ' order type'); } else { - request['price'] = price; + request['stopPx'] = parseFloat (this.priceToPrecision (symbol, stopPrice)); + params = this.omit (params, [ 'stopPx', 'stopPrice' ]); } } + if ((orderType === 'Limit') || (orderType === 'StopLimit') || (orderType === 'LimitIfTouched')) { + request['price'] = parseFloat (this.priceToPrecision (symbol, price)); + } const clientOrderId = this.safeString2 (params, 'clOrdID', 'clientOrderId'); if (clientOrderId !== undefined) { request['clOrdID'] = clientOrderId; diff --git a/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/bitpanda.js b/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/bitpanda.js index 41f855168..b440aba7d 100644 --- a/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/bitpanda.js +++ b/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/bitpanda.js @@ -790,7 +790,10 @@ module.exports = class bitpanda extends Exchange { // const feeInfo = this.safeValue (trade, 'fee', {}); trade = this.safeValue (trade, 'trade', trade); - const timestamp = this.parse8601 (this.safeString (trade, 'time')); + let timestamp = this.safeInteger (trade, 'trade_timestamp'); + if (timestamp === undefined) { + timestamp = this.parse8601 (this.safeString (trade, 'time')); + } const side = this.safeStringLower2 (trade, 'side', 'taker_side'); const price = this.safeFloat (trade, 'price'); const amount = this.safeFloat (trade, 'amount'); @@ -965,7 +968,7 @@ module.exports = class bitpanda extends Exchange { if (since !== undefined) { const to = this.safeString (params, 'to'); if (to === undefined) { - throw new ArgumentsRequired (this.id + ' fetchDeposits requires a "to" iso8601 string param with the since argument is specified'); + throw new ArgumentsRequired (this.id + ' fetchDeposits() requires a "to" iso8601 string param with the since argument is specified'); } request['from'] = this.iso8601 (since); } @@ -1020,7 +1023,7 @@ module.exports = class bitpanda extends Exchange { if (since !== undefined) { const to = this.safeString (params, 'to'); if (to === undefined) { - throw new ArgumentsRequired (this.id + ' fetchWithdrawals requires a "to" iso8601 string param with the since argument is specified'); + throw new ArgumentsRequired (this.id + ' fetchWithdrawals() requires a "to" iso8601 string param with the since argument is specified'); } request['from'] = this.iso8601 (since); } @@ -1325,6 +1328,7 @@ module.exports = class bitpanda extends Exchange { } const timeInForce = this.parseTimeInForce (this.safeString (order, 'time_in_force')); const stopPrice = this.safeFloat (order, 'trigger_price'); + const postOnly = this.safeValue (order, 'is_post_only'); const result = { 'id': id, 'clientOrderId': clientOrderId, @@ -1335,6 +1339,7 @@ module.exports = class bitpanda extends Exchange { 'symbol': symbol, 'type': type, 'timeInForce': timeInForce, + 'postOnly': postOnly, 'side': side, 'price': price, 'stopPrice': stopPrice, @@ -1409,7 +1414,7 @@ module.exports = class bitpanda extends Exchange { if (uppercaseType === 'STOP') { const triggerPrice = this.safeFloat (params, 'trigger_price'); if (triggerPrice === undefined) { - throw new ArgumentsRequired (this.id + ' createOrder requires a trigger_price param for ' + type + ' orders'); + throw new ArgumentsRequired (this.id + ' createOrder() requires a trigger_price param for ' + type + ' orders'); } request['trigger_price'] = this.priceToPrecision (symbol, triggerPrice); params = this.omit (params, 'trigger_price'); @@ -1560,7 +1565,7 @@ module.exports = class bitpanda extends Exchange { if (since !== undefined) { const to = this.safeString (params, 'to'); if (to === undefined) { - throw new ArgumentsRequired (this.id + ' fetchOrders requires a "to" iso8601 string param with the since argument is specified, max range is 100 days'); + throw new ArgumentsRequired (this.id + ' fetchOrders() requires a "to" iso8601 string param with the since argument is specified, max range is 100 days'); } request['from'] = this.iso8601 (since); } @@ -1724,7 +1729,7 @@ module.exports = class bitpanda extends Exchange { if (since !== undefined) { const to = this.safeString (params, 'to'); if (to === undefined) { - throw new ArgumentsRequired (this.id + ' fetchMyTrades requires a "to" iso8601 string param with the since argument is specified, max range is 100 days'); + throw new ArgumentsRequired (this.id + ' fetchMyTrades() requires a "to" iso8601 string param with the since argument is specified, max range is 100 days'); } request['from'] = this.iso8601 (since); } diff --git a/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/bitso.js b/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/bitso.js index 8ef7dc93c..d8bc07145 100644 --- a/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/bitso.js +++ b/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/bitso.js @@ -4,7 +4,7 @@ const Exchange = require ('./base/Exchange'); const { ExchangeError, InvalidNonce, AuthenticationError, OrderNotFound } = require ('./base/errors'); -const { TICK_SIZE } = require ('./base/functions/number'); +const { TICK_SIZE, ROUND } = require ('./base/functions/number'); // --------------------------------------------------------------------------- @@ -181,23 +181,25 @@ module.exports = class bitso extends Exchange { const taker = this.safeFloat (flatRate, 'taker'); const feeTiers = this.safeValue (fees, 'structure', []); const fee = { - 'maker': maker, - 'taker': taker, + 'taker': parseFloat (this.decimalToPrecision (taker / 100, ROUND, 0.00000001, TICK_SIZE)), + 'maker': parseFloat (this.decimalToPrecision (maker / 100, ROUND, 0.00000001, TICK_SIZE)), 'percentage': true, 'tierBased': true, }; const takerFees = []; const makerFees = []; - for (let i = 0; i < feeTiers.length; i++) { - const tier = feeTiers[i]; + for (let j = 0; j < feeTiers.length; j++) { + const tier = feeTiers[j]; const volume = this.safeFloat (tier, 'volume'); const takerFee = this.safeFloat (tier, 'taker'); const makerFee = this.safeFloat (tier, 'maker'); - takerFees.push ([ volume, takerFee ]); - makerFees.push ([ volume, makerFee ]); - if (i === 0) { - fee['taker'] = taker; - fee['maker'] = maker; + const takerFeeToPrecision = parseFloat (this.decimalToPrecision (takerFee / 100, ROUND, 0.00000001, TICK_SIZE)); + const makerFeeToPrecision = parseFloat (this.decimalToPrecision (makerFee / 100, ROUND, 0.00000001, TICK_SIZE)); + takerFees.push ([ volume, takerFeeToPrecision ]); + makerFees.push ([ volume, makerFeeToPrecision ]); + if (j === 0) { + fee['taker'] = parseFloat (this.decimalToPrecision (taker / 100, ROUND, 0.00000001, TICK_SIZE)); + fee['maker'] = parseFloat (this.decimalToPrecision (maker / 100, ROUND, 0.00000001, TICK_SIZE)); } } const tiers = { @@ -434,6 +436,7 @@ module.exports = class bitso extends Exchange { 'symbol': symbol, 'type': orderType, 'timeInForce': undefined, + 'postOnly': undefined, 'side': side, 'price': price, 'stopPrice': undefined, diff --git a/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/bitstamp.js b/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/bitstamp.js index 1b4a33a46..4671385bf 100644 --- a/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/bitstamp.js +++ b/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/bitstamp.js @@ -3,7 +3,7 @@ // --------------------------------------------------------------------------- const Exchange = require ('./base/Exchange'); -const { AuthenticationError, ExchangeError, NotSupported, PermissionDenied, InvalidNonce, OrderNotFound, InsufficientFunds, InvalidAddress, InvalidOrder, ArgumentsRequired, OnMaintenance } = require ('./base/errors'); +const { AuthenticationError, ExchangeError, NotSupported, PermissionDenied, InvalidNonce, OrderNotFound, InsufficientFunds, InvalidAddress, InvalidOrder, ArgumentsRequired, OnMaintenance, ExchangeNotAvailable } = require ('./base/errors'); // --------------------------------------------------------------------------- @@ -223,6 +223,7 @@ module.exports = class bitstamp extends Exchange { 'Order not found': OrderNotFound, 'Price is more than 20% below market price.': InvalidOrder, 'Bitstamp.net is under scheduled maintenance.': OnMaintenance, // { "error": "Bitstamp.net is under scheduled maintenance. We'll be back soon." } + 'Order could not be placed.': ExchangeNotAvailable, // Order could not be placed (perhaps due to internal error or trade halt). Please retry placing order. }, 'broad': { 'Minimum order size is': InvalidOrder, // Minimum order size is 5.0 EUR. @@ -705,7 +706,7 @@ module.exports = class bitstamp extends Exchange { const duration = this.parseTimeframe (timeframe); if (limit === undefined) { if (since === undefined) { - throw new ArgumentsRequired (this.id + ' fetchOHLCV requires a since argument or a limit argument'); + throw new ArgumentsRequired (this.id + ' fetchOHLCV() requires a since argument or a limit argument'); } else { limit = 1000; const start = parseInt (since / 1000); @@ -771,8 +772,8 @@ module.exports = class bitstamp extends Exchange { return { 'info': balance, 'symbol': symbol, - 'maker': balance.fee, - 'taker': balance.fee, + 'maker': balance['fee'], + 'taker': balance['fee'], }; } @@ -1262,6 +1263,7 @@ module.exports = class bitstamp extends Exchange { 'symbol': symbol, 'type': undefined, 'timeInForce': undefined, + 'postOnly': undefined, 'side': side, 'price': price, 'stopPrice': undefined, diff --git a/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/bittrex.js b/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/bittrex.js index 36d09cbb8..1e11d600a 100644 --- a/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/bittrex.js +++ b/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/bittrex.js @@ -3,7 +3,7 @@ // --------------------------------------------------------------------------- const Exchange = require ('./base/Exchange'); -const { BadSymbol, ExchangeError, ExchangeNotAvailable, AuthenticationError, InvalidOrder, InsufficientFunds, OrderNotFound, DDoSProtection, PermissionDenied, AddressPending, OnMaintenance, BadRequest } = require ('./base/errors'); +const { BadSymbol, ExchangeError, ExchangeNotAvailable, AuthenticationError, InvalidOrder, InsufficientFunds, OrderNotFound, DDoSProtection, PermissionDenied, AddressPending, OnMaintenance, BadRequest, InvalidAddress } = require ('./base/errors'); const { TRUNCATE, DECIMAL_PLACES } = require ('./base/functions/number'); // --------------------------------------------------------------------------- @@ -23,6 +23,7 @@ module.exports = class bittrex extends Exchange { 'CORS': false, 'cancelAllOrders': true, 'cancelOrder': true, + 'createDepositAddress': true, 'createMarketOrder': true, 'createOrder': true, 'fetchBalance': true, @@ -137,10 +138,10 @@ module.exports = class bittrex extends Exchange { }, 'fees': { 'trading': { - 'tierBased': false, + 'tierBased': true, 'percentage': true, - 'maker': 0.0025, - 'taker': 0.0025, + 'maker': 0.0035, + 'taker': 0.0035, }, 'funding': { 'tierBased': false, @@ -758,7 +759,22 @@ module.exports = class bittrex extends Exchange { const isCeilingMarket = (uppercaseType === 'CEILING_MARKET'); const isCeilingOrder = isCeilingLimit || isCeilingMarket; if (isCeilingOrder) { - request['ceiling'] = this.priceToPrecision (symbol, price); + let cost = undefined; + if (isCeilingLimit) { + request['limit'] = this.priceToPrecision (symbol, price); + cost = this.safeFloat2 (params, 'ceiling', 'cost', amount); + } else if (isCeilingMarket) { + cost = this.safeFloat2 (params, 'ceiling', 'cost'); + if (cost === undefined) { + if (price === undefined) { + cost = amount; + } else { + cost = amount * price; + } + } + } + params = this.omit (params, [ 'ceiling', 'cost' ]); + request['ceiling'] = this.costToPrecision (symbol, cost); // bittrex only accepts IMMEDIATE_OR_CANCEL or FILL_OR_KILL for ceiling orders request['timeInForce'] = 'IMMEDIATE_OR_CANCEL'; } else { @@ -975,7 +991,7 @@ module.exports = class bittrex extends Exchange { 'GOOD_TIL_CANCELLED': 'GTC', 'IMMEDIATE_OR_CANCEL': 'IOC', 'FILL_OR_KILL': 'FOK', - 'POST_ONLY_GOOD_TIL_CANCELLED': 'POST_ONLY_GOOD_TIL_CANCELLED', + 'POST_ONLY_GOOD_TIL_CANCELLED': 'PO', }; return this.safeString (timeInForces, timeInForce, timeInForce); } @@ -1045,6 +1061,7 @@ module.exports = class bittrex extends Exchange { status = 'canceled'; } const timeInForce = this.parseTimeInForce (this.safeString (order, 'timeInForce')); + const postOnly = (timeInForce === 'PO'); return { 'id': this.safeString (order, 'id'), 'clientOrderId': undefined, @@ -1054,6 +1071,7 @@ module.exports = class bittrex extends Exchange { 'symbol': symbol, 'type': type, 'timeInForce': timeInForce, + 'postOnly': postOnly, 'side': direction, 'price': limit, 'stopPrice': undefined, @@ -1191,6 +1209,40 @@ module.exports = class bittrex extends Exchange { return this.parseOrders (response, market, since, limit); } + async createDepositAddress (code, params = {}) { + await this.loadMarkets (); + const currency = this.currency (code); + const request = { + 'currencySymbol': currency['id'], + }; + const response = await this.privatePostAddresses (this.extend (request, params)); + // + // { + // "status":"PROVISIONED", + // "currencySymbol":"XRP", + // "cryptoAddress":"rPVMhWBsfF9iMXYj3aAzJVkPDTFNSyWdKy", + // "cryptoAddressTag":"392034158" + // } + // + let address = this.safeString (response, 'cryptoAddress'); + const message = this.safeString (response, 'status'); + if (!address || message === 'REQUESTED') { + throw new AddressPending (this.id + ' the address for ' + code + ' is being generated (pending, not ready yet, retry again later)'); + } + let tag = this.safeString (response, 'cryptoAddressTag'); + if ((tag === undefined) && (currency['type'] in this.options['tag'])) { + tag = address; + address = currency['address']; + } + this.checkAddress (address); + return { + 'currency': code, + 'address': address, + 'tag': tag, + 'info': response, + }; + } + async fetchDepositAddress (code, params = {}) { await this.loadMarkets (); const currency = this.currency (code); @@ -1198,18 +1250,21 @@ module.exports = class bittrex extends Exchange { 'currencySymbol': currency['id'], }; const response = await this.privateGetAddressesCurrencySymbol (this.extend (request, params)); - // { - // "status": "PROVISIONED", - // "currencySymbol": "BTC", - // "cryptoAddress": "1PhmYjnJPZH5NUwV8AUjqkeDkCBpbE2xqX" - // } + // + // { + // "status":"PROVISIONED", + // "currencySymbol":"XRP", + // "cryptoAddress":"rPVMhWBsfF9iMXYj3aAzJVkPDTFNSyWdKy", + // "cryptoAddressTag":"392034158" + // } + // let address = this.safeString (response, 'cryptoAddress'); const message = this.safeString (response, 'status'); if (!address || message === 'REQUESTED') { throw new AddressPending (this.id + ' the address for ' + code + ' is being generated (pending, not ready yet, retry again later)'); } - let tag = undefined; - if (currency['type'] in this.options['tag']) { + let tag = this.safeString (response, 'cryptoAddressTag'); + if ((tag === undefined) && (currency['type'] in this.options['tag'])) { tag = address; address = currency['address']; } @@ -1309,6 +1364,9 @@ module.exports = class bittrex extends Exchange { this.throwExactlyMatchedException (this.exceptions['exact'], code, feedback); this.throwBroadlyMatchedException (this.exceptions['broad'], code, feedback); } + if ((code === 'NOT_FOUND') && (url.indexOf ('addresses') >= 0)) { + throw new InvalidAddress (feedback); + } // throw new ExchangeError (this.id + ' malformed response ' + this.json (response)); return; } diff --git a/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/bitvavo.js b/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/bitvavo.js index 10d62cfeb..e6633b568 100644 --- a/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/bitvavo.js +++ b/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/bitvavo.js @@ -4,7 +4,7 @@ const Exchange = require ('./base/Exchange'); const { ExchangeError, BadSymbol, AuthenticationError, InsufficientFunds, InvalidOrder, ArgumentsRequired, OrderNotFound, InvalidAddress, BadRequest, RateLimitExceeded, PermissionDenied, ExchangeNotAvailable, AccountSuspended, OnMaintenance } = require ('./base/errors'); -const { TRUNCATE } = require ('./base/functions/number'); +const { SIGNIFICANT_DIGITS, DECIMAL_PLACES, TRUNCATE, ROUND } = require ('./base/functions/number'); // ---------------------------------------------------------------------------- @@ -221,12 +221,33 @@ module.exports = class bitvavo extends Exchange { 'expires': 1000, // 1 second }, }, + 'precisionMode': SIGNIFICANT_DIGITS, 'commonCurrencies': { 'MIOTA': 'IOTA', // https://github.com/ccxt/ccxt/issues/7487 }, }); } + currencyToPrecision (currency, fee) { + return this.decimalToPrecision (fee, 0, this.currencies[currency]['precision']); + } + + amountToPrecision (symbol, amount) { + // https://docs.bitfinex.com/docs/introduction#amount-precision + // The amount field allows up to 8 decimals. + // Anything exceeding this will be rounded to the 8th decimal. + return this.decimalToPrecision (amount, TRUNCATE, this.markets[symbol]['precision']['amount'], DECIMAL_PLACES); + } + + priceToPrecision (symbol, price) { + price = this.decimalToPrecision (price, ROUND, this.markets[symbol]['precision']['price'], this.precisionMode); + // https://docs.bitfinex.com/docs/introduction#price-precision + // The precision level of all trading prices is based on significant figures. + // All pairs on Bitfinex use up to 5 significant digits and up to 8 decimals (e.g. 1.2345, 123.45, 1234.5, 0.00012345). + // Prices submit with a precision larger than 5 will be cut by the API. + return this.decimalToPrecision (price, TRUNCATE, 8, DECIMAL_PLACES); + } + async fetchTime (params = {}) { const response = await this.publicGetTime (params); // @@ -768,16 +789,18 @@ module.exports = class bitvavo extends Exchange { const request = { 'market': market['id'], 'side': side, - 'orderType': type, + 'orderType': type, // 'market', 'limit', 'stopLoss', 'stopLossLimit', 'takeProfit', 'takeProfitLimit' // 'amount': this.amountToPrecision (symbol, amount), // 'price': this.priceToPrecision (symbol, price), // 'amountQuote': this.costToPrecision (symbol, cost), - // 'timeInForce': 'GTC', // "GTC" "IOC" "FOK" - // 'selfTradePrevention': "decrementAndCancel", // "decrementAndCancel" "cancelOldest" "cancelNewest" "cancelBoth" + // 'timeInForce': 'GTC', // 'GTC', 'IOC', 'FOK' + // 'selfTradePrevention': 'decrementAndCancel', // 'decrementAndCancel', 'cancelOldest', 'cancelNewest', 'cancelBoth' // 'postOnly': false, // 'disableMarketProtection': false, // don't cancel if the next fill price is 10% worse than the best fill price // 'responseRequired': true, // false is faster }; + const isStopLimit = (type === 'stopLossLimit') || (type === 'takeProfitLimit'); + const isStopMarket = (type === 'stopLoss') || (type === 'takeProfit'); if (type === 'market') { let cost = undefined; if (price !== undefined) { @@ -795,6 +818,26 @@ module.exports = class bitvavo extends Exchange { } else if (type === 'limit') { request['price'] = this.priceToPrecision (symbol, price); request['amount'] = this.amountToPrecision (symbol, amount); + } else if (isStopMarket || isStopLimit) { + let stopPrice = this.safeFloat2 (params, 'stopPrice', 'triggerAmount'); + if (stopPrice === undefined) { + if (isStopLimit) { + throw new ArgumentsRequired (this.id + ' createOrder requires a stopPrice parameter for a ' + type + ' order'); + } else if (isStopMarket) { + if (price === undefined) { + throw new ArgumentsRequired (this.id + ' createOrder requires a price argument or a stopPrice parameter for a ' + type + ' order'); + } else { + stopPrice = price; + } + } + } + if (isStopLimit) { + request['price'] = this.priceToPrecision (symbol, price); + } + params = this.omit (params, [ 'stopPrice', 'triggerAmount' ]); + request['triggerAmount'] = this.priceToPrecision (symbol, stopPrice); + request['triggerType'] = 'price'; + request['amount'] = this.amountToPrecision (symbol, amount); } const response = await this.privatePostOrder (this.extend (request, params)); // @@ -856,13 +899,13 @@ module.exports = class bitvavo extends Exchange { const response = await this.privatePutOrder (this.extend (request, params)); return this.parseOrder (response, market); } else { - throw new ArgumentsRequired (this.id + ' editOrder requires an amount argument, or a price argument, or non-empty params'); + throw new ArgumentsRequired (this.id + ' editOrder() requires an amount argument, or a price argument, or non-empty params'); } } async cancelOrder (id, symbol = undefined, params = {}) { if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' cancelOrder requires a symbol argument'); + throw new ArgumentsRequired (this.id + ' cancelOrder() requires a symbol argument'); } await this.loadMarkets (); const market = this.market (symbol); @@ -900,7 +943,7 @@ module.exports = class bitvavo extends Exchange { async fetchOrder (id, symbol = undefined, params = {}) { if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' fetchOrder requires a symbol argument'); + throw new ArgumentsRequired (this.id + ' fetchOrder() requires a symbol argument'); } await this.loadMarkets (); await this.loadMarkets (); @@ -949,7 +992,7 @@ module.exports = class bitvavo extends Exchange { async fetchOrders (symbol = undefined, since = undefined, limit = undefined, params = {}) { if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' fetchOrders requires a symbol argument'); + throw new ArgumentsRequired (this.id + ' fetchOrders() requires a symbol argument'); } await this.loadMarkets (); const market = this.market (symbol); @@ -1010,24 +1053,13 @@ module.exports = class bitvavo extends Exchange { async fetchOpenOrders (symbol = undefined, since = undefined, limit = undefined, params = {}) { await this.loadMarkets (); const request = { - // 'market': market['id'], - // 'limit': 500, - // 'start': since, - // 'end': this.milliseconds (), - // 'orderIdFrom': 'af76d6ce-9f7c-4006-b715-bb5d430652d0', - // 'orderIdTo': 'af76d6ce-9f7c-4006-b715-bb5d430652d0', + // 'market': market['id'], // rate limit 25 without a market, 1 with market specified }; let market = undefined; if (symbol !== undefined) { market = this.market (symbol); request['market'] = market['id']; } - if (since !== undefined) { - request['start'] = since; - } - if (limit !== undefined) { - request['limit'] = limit; // default 500, max 1000 - } const response = await this.privateGetOrdersOpen (this.extend (request, params)); // // [ @@ -1082,6 +1114,7 @@ module.exports = class bitvavo extends Exchange { 'partiallyFilled': 'open', 'expired': 'canceled', 'rejected': 'canceled', + 'awaitingTrigger': 'open', // https://github.com/ccxt/ccxt/issues/8489 }; return this.safeString (statuses, status, status); } @@ -1183,6 +1216,9 @@ module.exports = class bitvavo extends Exchange { } } const timeInForce = this.safeString (order, 'timeInForce'); + const postOnly = this.safeValue (order, 'postOnly'); + // https://github.com/ccxt/ccxt/issues/8489 + const stopPrice = this.safeFloat (order, 'triggerPrice'); return { 'info': order, 'id': id, @@ -1193,9 +1229,10 @@ module.exports = class bitvavo extends Exchange { 'symbol': symbol, 'type': type, 'timeInForce': timeInForce, + 'postOnly': postOnly, 'side': side, 'price': price, - 'stopPrice': undefined, + 'stopPrice': stopPrice, 'amount': amount, 'cost': cost, 'average': average, @@ -1209,7 +1246,7 @@ module.exports = class bitvavo extends Exchange { async fetchMyTrades (symbol = undefined, since = undefined, limit = undefined, params = {}) { if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' fetchMyTrades requires a symbol argument'); + throw new ArgumentsRequired (this.id + ' fetchMyTrades() requires a symbol argument'); } await this.loadMarkets (); const market = this.market (symbol); diff --git a/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/bitz.js b/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/bitz.js index 9b28cd463..816bb15a4 100644 --- a/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/bitz.js +++ b/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/bitz.js @@ -675,7 +675,7 @@ module.exports = class bitz extends Exchange { } } else { if (since !== undefined) { - throw new ArgumentsRequired (this.id + ' fetchOHLCV requires a limit argument if the since argument is specified'); + throw new ArgumentsRequired (this.id + ' fetchOHLCV() requires a limit argument if the since argument is specified'); } } const response = await this.marketGetKline (this.extend (request, params)); @@ -779,6 +779,7 @@ module.exports = class bitz extends Exchange { 'symbol': symbol, 'type': 'limit', 'timeInForce': undefined, + 'postOnly': undefined, 'side': side, 'price': price, 'stopPrice': undefined, @@ -948,7 +949,7 @@ module.exports = class bitz extends Exchange { async fetchOrdersWithMethod (method, symbol = undefined, since = undefined, limit = undefined, params = {}) { if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' fetchOpenOrders requires a symbol argument'); + throw new ArgumentsRequired (this.id + ' fetchOpenOrders() requires a symbol argument'); } await this.loadMarkets (); const market = this.market (symbol); diff --git a/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/bleutrade.js b/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/bleutrade.js index 385e7e455..67262da33 100644 --- a/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/bleutrade.js +++ b/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/bleutrade.js @@ -662,6 +662,7 @@ module.exports = class bleutrade extends Exchange { 'symbol': symbol, 'type': 'limit', 'timeInForce': undefined, + 'postOnly': undefined, 'side': side, 'price': price, 'stopPrice': undefined, diff --git a/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/braziliex.js b/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/braziliex.js index ac9d460c0..0c54e4840 100644 --- a/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/braziliex.js +++ b/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/braziliex.js @@ -460,6 +460,7 @@ module.exports = class braziliex extends Exchange { 'symbol': symbol, 'type': 'limit', 'timeInForce': undefined, + 'postOnly': undefined, 'side': side, 'price': price, 'stopPrice': undefined, diff --git a/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/btcalpha.js b/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/btcalpha.js index 441947aa1..820234604 100644 --- a/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/btcalpha.js +++ b/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/btcalpha.js @@ -348,6 +348,7 @@ module.exports = class btcalpha extends Exchange { 'symbol': symbol, 'type': 'limit', 'timeInForce': undefined, + 'postOnly': undefined, 'side': side, 'price': price, 'stopPrice': undefined, diff --git a/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/btcbox.js b/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/btcbox.js index af988de09..1a5f82456 100644 --- a/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/btcbox.js +++ b/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/btcbox.js @@ -306,6 +306,7 @@ module.exports = class btcbox extends Exchange { 'side': side, 'type': undefined, 'timeInForce': undefined, + 'postOnly': undefined, 'status': status, 'symbol': symbol, 'price': price, diff --git a/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/btcmarkets.js b/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/btcmarkets.js index 15bbd9610..2340d1960 100644 --- a/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/btcmarkets.js +++ b/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/btcmarkets.js @@ -865,6 +865,7 @@ module.exports = class btcmarkets extends Exchange { const clientOrderId = this.safeString (order, 'clientOrderId'); const timeInForce = this.safeString (order, 'timeInForce'); const stopPrice = this.safeFloat (order, 'triggerPrice'); + const postOnly = this.safeValue (order, 'postOnly'); return { 'info': order, 'id': id, @@ -875,6 +876,7 @@ module.exports = class btcmarkets extends Exchange { 'symbol': symbol, 'type': type, 'timeInForce': timeInForce, + 'postOnly': postOnly, 'side': side, 'price': price, 'stopPrice': stopPrice, diff --git a/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/btctradeua.js b/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/btctradeua.js index 4d6743bf5..011bc33b6 100644 --- a/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/btctradeua.js +++ b/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/btctradeua.js @@ -335,6 +335,7 @@ module.exports = class btctradeua extends Exchange { 'symbol': symbol, 'type': undefined, 'timeInForce': undefined, + 'postOnly': undefined, 'side': this.safeString (order, 'type'), 'price': this.safeFloat (order, 'price'), 'stopPrice': undefined, @@ -351,7 +352,7 @@ module.exports = class btctradeua extends Exchange { async fetchOpenOrders (symbol = undefined, since = undefined, limit = undefined, params = {}) { if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' fetchOpenOrders requires a symbol argument'); + throw new ArgumentsRequired (this.id + ' fetchOpenOrders() requires a symbol argument'); } await this.loadMarkets (); const market = this.market (symbol); diff --git a/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/btcturk.js b/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/btcturk.js index 24f79880b..32ea74550 100644 --- a/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/btcturk.js +++ b/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/btcturk.js @@ -275,7 +275,7 @@ module.exports = class btcturk extends Exchange { }; if (type === 'market') { if (!('Total' in params)) { - throw new ExchangeError (this.id + ' createOrder requires the "Total" extra parameter for market orders (amount and price are both ignored)'); + throw new ExchangeError (this.id + ' createOrder() requires the "Total" extra parameter for market orders (amount and price are both ignored)'); } } else { request['Price'] = price; diff --git a/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/buda.js b/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/buda.js index 96da5d093..e78c228ea 100644 --- a/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/buda.js +++ b/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/buda.js @@ -537,29 +537,65 @@ module.exports = class buda extends Exchange { } parseOrder (order, market = undefined) { + // + // { + // 'id': 63679183, + // 'uuid': 'f9697bee-627e-4175-983f-0d5a41963fec', + // 'market_id': 'ETH-CLP', + // 'account_id': 51590, + // 'type': 'Ask', + // 'state': 'received', + // 'created_at': '2021-01-04T08:29:52.730Z', + // 'fee_currency': 'CLP', + // 'price_type': 'limit', + // 'source': None, + // 'limit': ['741000.0', 'CLP'], + // 'amount': ['0.001', 'ETH'], + // 'original_amount': ['0.001', 'ETH'], + // 'traded_amount': ['0.0', 'ETH'], + // 'total_exchanged': ['0.0', 'CLP'], + // 'paid_fee': ['0.0', 'CLP'] + // } + // const id = this.safeString (order, 'id'); const timestamp = this.parse8601 (this.safeString (order, 'created_at')); const marketId = this.safeString (order, 'market_id'); - const symbol = this.safeSymbol (marketId, market); + const symbol = this.safeSymbol (marketId, market, '-'); const type = this.safeString (order, 'price_type'); const side = this.safeStringLower (order, 'type'); const status = this.parseOrderStatus (this.safeString (order, 'state')); - const amount = parseFloat (order['original_amount'][0]); - const remaining = parseFloat (order['amount'][0]); - const filled = parseFloat (order['traded_amount'][0]); - const cost = parseFloat (order['total_exchanged'][0]); - let price = this.safeFloat (order, 'limit'); - if (price !== undefined) { - price = parseFloat (price[0]); + const originalAmount = this.safeValue (order, 'original_amount', []); + const amount = this.safeFloat (originalAmount, 0); + const remainingAmount = this.safeValue (order, 'amount', []); + const remaining = this.safeFloat (remainingAmount, 0); + const tradedAmount = this.safeValue (order, 'traded_amount', []); + const filled = this.safeFloat (tradedAmount, 0); + const totalExchanged = this.safeValue (order, 'totalExchanged', []); + const cost = this.safeFloat (totalExchanged, 0); + const limitPrice = this.safeValue (order, 'limit', []); + let price = this.safeFloat (limitPrice, 0); + if (price === undefined) { + if (limitPrice !== undefined) { + price = limitPrice; + } } - if (cost > 0 && filled > 0) { - price = this.priceToPrecision (symbol, cost / filled); + let average = undefined; + if ((cost !== undefined) && (filled !== undefined) && (filled > 0)) { + average = this.priceToPrecision (symbol, cost / filled); + } + const paidFee = this.safeValue (order, 'paid_fee', []); + const feeCost = this.safeFloat (paidFee, 0); + let fee = undefined; + if (feeCost !== undefined) { + const feeCurrencyId = this.safeString (paidFee, 1); + const feeCurrencyCode = this.safeCurrencyCode (feeCurrencyId); + fee = { + 'cost': feeCost, + 'code': feeCurrencyCode, + }; } - const fee = { - 'cost': parseFloat (order['paid_fee'][0]), - 'currency': order['paid_fee'][1], - }; return { + 'info': order, 'id': id, 'clientOrderId': undefined, 'datetime': this.iso8601 (timestamp), @@ -569,17 +605,17 @@ module.exports = class buda extends Exchange { 'symbol': symbol, 'type': type, 'timeInForce': undefined, + 'postOnly': undefined, 'side': side, 'price': price, 'stopPrice': undefined, + 'average': average, 'cost': cost, 'amount': amount, 'filled': filled, 'remaining': remaining, 'trades': undefined, 'fee': fee, - 'info': order, - 'average': undefined, }; } diff --git a/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/bw.js b/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/bw.js index 57a8a64c7..388946b39 100644 --- a/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/bw.js +++ b/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/bw.js @@ -761,6 +761,7 @@ module.exports = class bw extends Exchange { 'symbol': symbol, 'type': 'limit', 'timeInForce': undefined, + 'postOnly': undefined, 'side': side, 'price': price, 'stopPrice': undefined, @@ -777,7 +778,7 @@ module.exports = class bw extends Exchange { async fetchOrder (id, symbol = undefined, params = {}) { if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' fetchOrder requires a symbol argument'); + throw new ArgumentsRequired (this.id + ' fetchOrder() requires a symbol argument'); } await this.loadMarkets (); const market = this.market (symbol); @@ -812,7 +813,7 @@ module.exports = class bw extends Exchange { async cancelOrder (id, symbol = undefined, params = {}) { if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' cancelOrder requires a symbol argument'); + throw new ArgumentsRequired (this.id + ' cancelOrder() requires a symbol argument'); } await this.loadMarkets (); const market = this.market (symbol); diff --git a/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/bybit.js b/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/bybit.js index 7a9159515..f74d0db18 100644 --- a/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/bybit.js +++ b/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/bybit.js @@ -17,6 +17,7 @@ module.exports = class bybit extends Exchange { 'version': 'v2', 'userAgent': undefined, 'rateLimit': 100, + 'hostname': 'bybit.com', // bybit.com, bytick.com 'has': { 'cancelOrder': true, 'CORS': true, @@ -59,9 +60,9 @@ module.exports = class bybit extends Exchange { '1y': 'Y', }, 'urls': { - 'test': 'https://api-testnet.bybit.com', + 'test': 'https://api-testnet.{hostname}', 'logo': 'https://user-images.githubusercontent.com/51840849/76547799-daff5b80-649e-11ea-87fb-3be9bac08954.jpg', - 'api': 'https://api.bybit.com', + 'api': 'https://api.{hostname}', 'www': 'https://www.bybit.com', 'doc': [ 'https://bybit-exchange.github.io/docs/inverse/', @@ -72,117 +73,112 @@ module.exports = class bybit extends Exchange { 'referral': 'https://www.bybit.com/app/register?ref=X7Prm', }, 'api': { + 'v2': { + 'public': { + 'get': [ + 'orderBook/L2', + 'kline/list', + 'tickers', + 'trading-records', + 'symbols', + 'liq-records', + 'mark-price-kline', + 'index-price-kline', + 'premium-index-kline', + 'open-interest', + 'big-deal', + 'account-ratio', + 'time', + 'announcement', + ], + }, + 'private': { + 'get': [ + 'order/list', + 'order', + 'stop-order/list', + 'stop-order', + 'position/list', + 'execution/list', + 'trade/closed-pnl/list', + 'funding/prev-funding-rate', + 'funding/prev-funding', + 'funding/predicted-funding', + 'account/api-key', + 'account/lcp', + 'wallet/balance', + 'wallet/fund/records', + 'wallet/withdraw/list', + 'exchange-order/list', + ], + 'post': [ + 'order/create', + 'order/cancel', + 'order/cancelAll', + 'order/replace', + 'stop-order/create', + 'stop-order/cancel', + 'stop-order/cancelAll', + 'stop-order/replace', + 'position/change-position-margin', + 'position/trading-stop', + 'position/leverage/save', + ], + }, + }, 'public': { - 'get': [ - 'orderBook/L2', - 'kline/list', - 'tickers', - 'trading-records', - 'symbols', - 'liq-records', - 'mark-price-kline', - 'open-interest', - 'big-deal', - 'account-ratio', - 'time', - 'announcement', - ], + 'linear': { + 'get': [ + 'kline', + 'recent-trading-records', + 'funding/prev-funding-rate', + 'mark-price-kline', + 'index-price-kline', + 'premium-index-kline', + 'risk-limit', + ], + }, }, 'private': { - 'get': [ - 'order/list', - 'order', - 'stop-order/list', - 'stop-order', - 'position/list', - 'wallet/balance', - 'execution/list', - 'trade/closed-pnl/list', - 'account/lcp', - 'exchange-order/list', - ], - 'post': [ - 'order/create', - 'order/cancel', - 'order/cancelAll', - 'order/replace', - 'stop-order/create', - 'stop-order/cancel', - 'stop-order/cancelAll', - 'stop-order/replace', - ], + 'linear': { + 'get': [ + 'order/list', + 'order/search', + 'stop-order/list', + 'stop-order/search', + 'position/list', + 'trade/execution/list', + 'trade/closed-pnl/list', + 'funding/predicted-funding', + 'funding/prev-funding', + ], + 'post': [ + 'order/create', + 'order/cancel', + 'order/cancel-all', + 'order/replace', + 'stop-order/create', + 'stop-order/cancel', + 'stop-order/cancel-all', + 'stop-order/replace', + 'position/set-auto-add-margin', + 'position/switch-isolated', + 'tpsl/switch-mode', + 'position/add-margin', + 'position/set-leverage', + 'position/trading-stop', + ], + }, }, 'openapi': { - 'get': [ - 'order/list', // deprecated - 'stop-order/list', // deprecated - 'wallet/risk-limit/list', - 'funding/prev-funding-rate', - 'funding/prev-funding', - 'funding/predicted-funding', - 'api-key', - 'wallet/fund/records', - 'wallet/withdraw/list', - ], - 'post': [ - 'order/replace', // deprecated - 'stop-order/create', // deprecated - 'stop-order/cancel', // deprecated - 'stop-order/replace', // deprecated - 'position/trading-stop', - 'wallet/risk-limit', - ], - }, - 'publicLinear': { - 'get': [ - 'kline', - 'recent-trading-records', - 'funding/prev-funding-rate', - 'mark-price-kline', - 'risk-limit', - ], - }, - 'privateLinear': { - 'get': [ - 'order/list', - 'order/search', - 'stop-order/list', - 'stop-order/search', - 'position/list', - 'trade/execution/list', - 'trade/closed-pnl/list', - 'funding/prev-funding', - 'funding/predicted-funding', - ], - 'post': [ - 'order/create', - 'order/cancel', - 'order/cancel-all', - 'order/replace', - 'stop-order/create', - 'stop-order/cancel', - 'stop-order/cancel-all', - 'stop-order/replace', - 'position/switch-isolated', - 'position/set-auto-add-margin', - 'tpsl/switch-mode', - 'position/set-leverage', - 'position/trading-stop', - 'position/add-margin', - ], - }, - 'position': { - 'post': [ - 'change-position-margin', - ], - }, - 'user': { - 'get': [ - 'leverage', // deprecated - ], - 'post': [ - 'leverage/save', - ], + 'wallet': { + 'get': [ + 'risk-limit/list', + ], + 'post': [ + 'risk-limit', + ], + }, }, }, 'httpExceptions': { @@ -285,6 +281,7 @@ module.exports = class bybit extends Exchange { 'options': { 'marketTypes': { 'BTC/USDT': 'linear', + 'BCH/USDT': 'linear', 'ETH/USDT': 'linear', 'LTC/USDT': 'linear', 'XTZ/USDT': 'linear', @@ -292,10 +289,10 @@ module.exports = class bybit extends Exchange { }, 'code': 'BTC', 'cancelAllOrders': { - 'method': 'privatePostOrderCancelAll', // privatePostStopOrderCancelAll + // 'method': 'v2PrivatePostOrderCancelAll', // v2PrivatePostStopOrderCancelAll }, 'recvWindow': 5 * 1000, // 5 sec default - 'timeDifference': 0, // the difference between system clock and Binance clock + 'timeDifference': 0, // the difference between system clock and exchange server clock 'adjustForTimeDifference': false, // controls the adjustment logic upon instantiation }, 'fees': { @@ -327,7 +324,7 @@ module.exports = class bybit extends Exchange { } async fetchTime (params = {}) { - const response = await this.publicGetTime (params); + const response = await this.v2PublicGetTime (params); // // { // ret_code: 0, @@ -345,30 +342,7 @@ module.exports = class bybit extends Exchange { if (this.options['adjustForTimeDifference']) { await this.loadTimeDifference (); } - const response = await this.publicGetSymbols (params); - // - // { - // ret_code: 0, - // ret_msg: 'OK', - // ext_code: '', - // ext_info: '', - // result: [ - // { - // name: 'BTCUSD', - // base_currency: 'BTC', - // quote_currency: 'USD', - // price_scale: 2, - // taker_fee: '0.00075', - // maker_fee: '-0.00025', - // leverage_filter: { min_leverage: 1, max_leverage: 100, leverage_step: '0.01' }, - // price_filter: { min_price: '0.5', max_price: '999999.5', tick_size: '0.5' }, - // lot_size_filter: { max_trading_qty: 1000000, min_trading_qty: 1, qty_step: 1 } - // }, - // ], - // time_now: '1583930495.454196' - // } - // - // sandbox/testnet + const response = await this.v2PublicGetSymbols (params); // // { // "ret_code":0, @@ -377,8 +351,8 @@ module.exports = class bybit extends Exchange { // "ext_info":"", // "result":[ // { - // "symbol":"BTCUSD", - // "symbol_alias":"BTCUSD", + // "name":"BTCUSD", + // "alias":"BTCUSD", // "status":"Trading", // "base_currency":"BTC", // "quote_currency":"USD", @@ -388,9 +362,22 @@ module.exports = class bybit extends Exchange { // "leverage_filter":{"min_leverage":1,"max_leverage":100,"leverage_step":"0.01"}, // "price_filter":{"min_price":"0.5","max_price":"999999.5","tick_size":"0.5"}, // "lot_size_filter":{"max_trading_qty":1000000,"min_trading_qty":1,"qty_step":1} - // } + // }, + // { + // "name":"BTCUSDT", + // "alias":"BTCUSDT", + // "status":"Trading", + // "base_currency":"BTC", + // "quote_currency":"USDT", + // "price_scale":2, + // "taker_fee":"0.00075", + // "maker_fee":"-0.00025", + // "leverage_filter":{"min_leverage":1,"max_leverage":100,"leverage_step":"0.01"}, + // "price_filter":{"min_price":"0.5","max_price":"999999.5","tick_size":"0.5"}, + // "lot_size_filter":{"max_trading_qty":100,"min_trading_qty":0.001,"qty_step":0.001} + // }, // ], - // "time_now":"1605916574.118500" + // "time_now":"1610539664.818033" // } // const markets = this.safeValue (response, 'result', []); @@ -457,65 +444,6 @@ module.exports = class bybit extends Exchange { return result; } - async fetchBalance (params = {}) { - await this.loadMarkets (); - const request = {}; - const coin = this.safeString (params, 'coin'); - const code = this.safeString (params, 'code'); - if (coin !== undefined) { - request['coin'] = coin; - } else if (code !== undefined) { - const currency = this.currency (code); - request['coin'] = currency['id']; - } - const response = await this.privateGetWalletBalance (this.extend (request, params)); - // - // { - // ret_code: 0, - // ret_msg: 'OK', - // ext_code: '', - // ext_info: '', - // result: { - // BTC: { - // equity: 0, - // available_balance: 0, - // used_margin: 0, - // order_margin: 0, - // position_margin: 0, - // occ_closing_fee: 0, - // occ_funding_fee: 0, - // wallet_balance: 0, - // realised_pnl: 0, - // unrealised_pnl: 0, - // cum_realised_pnl: 0, - // given_cash: 0, - // service_cash: 0 - // } - // }, - // time_now: '1583937810.370020', - // rate_limit_status: 119, - // rate_limit_reset_ms: 1583937810367, - // rate_limit: 120 - // } - // - const result = { - 'info': response, - }; - const balances = this.safeValue (response, 'result', {}); - const currencyIds = Object.keys (balances); - for (let i = 0; i < currencyIds.length; i++) { - const currencyId = currencyIds[i]; - const balance = balances[currencyId]; - const code = this.safeCurrencyCode (currencyId); - const account = this.account (); - account['free'] = this.safeFloat (balance, 'available_balance'); - account['used'] = this.safeFloat (balance, 'used_margin'); - account['total'] = this.safeFloat (balance, 'equity'); - result[code] = account; - } - return this.parseBalance (result); - } - parseTicker (ticker, market = undefined) { // // fetchTicker @@ -594,7 +522,7 @@ module.exports = class bybit extends Exchange { const request = { 'symbol': market['id'], }; - const response = await this.publicGetTickers (this.extend (request, params)); + const response = await this.v2PublicGetTickers (this.extend (request, params)); // // { // ret_code: 0, @@ -642,7 +570,7 @@ module.exports = class bybit extends Exchange { async fetchTickers (symbols = undefined, params = {}) { await this.loadMarkets (); - const response = await this.publicGetTickers (params); + const response = await this.v2PublicGetTickers (params); // // { // ret_code: 0, @@ -740,7 +668,7 @@ module.exports = class bybit extends Exchange { const now = this.seconds (); if (since === undefined) { if (limit === undefined) { - throw new ArgumentsRequired (this.id + ' fetchOHLCV requires a since argument or a limit argument'); + throw new ArgumentsRequired (this.id + ' fetchOHLCV() requires a since argument or a limit argument'); } else { request['from'] = now - limit * duration; } @@ -752,7 +680,7 @@ module.exports = class bybit extends Exchange { } const marketTypes = this.safeValue (this.options, 'marketTypes', {}); const marketType = this.safeString (marketTypes, symbol); - const method = (marketType === 'linear') ? 'publicLinearGetKline' : 'publicGetKlineList'; + const method = (marketType === 'linear') ? 'publicLinearGetKline' : 'v2PublicGetKlineList'; const response = await this[method] (this.extend (request, params)); // // inverse perpetual BTC/USD @@ -907,7 +835,7 @@ module.exports = class bybit extends Exchange { } const marketTypes = this.safeValue (this.options, 'marketTypes', {}); const marketType = this.safeString (marketTypes, symbol); - const method = (marketType === 'linear') ? 'publicLinearGetRecentTradingRecords' : 'publicGetTradingRecords'; + const method = (marketType === 'linear') ? 'publicLinearGetRecentTradingRecords' : 'v2PublicGetTradingRecords'; const response = await this[method] (this.extend (request, params)); // // { @@ -961,7 +889,7 @@ module.exports = class bybit extends Exchange { const request = { 'symbol': market['id'], }; - const response = await this.publicGetOrderBookL2 (this.extend (request, params)); + const response = await this.v2PublicGetOrderBookL2 (this.extend (request, params)); // // { // ret_code: 0, @@ -984,6 +912,65 @@ module.exports = class bybit extends Exchange { return this.parseOrderBook (result, timestamp, 'Buy', 'Sell', 'price', 'size'); } + async fetchBalance (params = {}) { + await this.loadMarkets (); + const request = {}; + const coin = this.safeString (params, 'coin'); + const code = this.safeString (params, 'code'); + if (coin !== undefined) { + request['coin'] = coin; + } else if (code !== undefined) { + const currency = this.currency (code); + request['coin'] = currency['id']; + } + const response = await this.v2PrivateGetWalletBalance (this.extend (request, params)); + // + // { + // ret_code: 0, + // ret_msg: 'OK', + // ext_code: '', + // ext_info: '', + // result: { + // BTC: { + // equity: 0, + // available_balance: 0, + // used_margin: 0, + // order_margin: 0, + // position_margin: 0, + // occ_closing_fee: 0, + // occ_funding_fee: 0, + // wallet_balance: 0, + // realised_pnl: 0, + // unrealised_pnl: 0, + // cum_realised_pnl: 0, + // given_cash: 0, + // service_cash: 0 + // } + // }, + // time_now: '1583937810.370020', + // rate_limit_status: 119, + // rate_limit_reset_ms: 1583937810367, + // rate_limit: 120 + // } + // + const result = { + 'info': response, + }; + const balances = this.safeValue (response, 'result', {}); + const currencyIds = Object.keys (balances); + for (let i = 0; i < currencyIds.length; i++) { + const currencyId = currencyIds[i]; + const balance = balances[currencyId]; + const code = this.safeCurrencyCode (currencyId); + const account = this.account (); + account['free'] = this.safeFloat (balance, 'available_balance'); + account['used'] = this.safeFloat (balance, 'used_margin'); + account['total'] = this.safeFloat (balance, 'equity'); + result[code] = account; + } + return this.parseBalance (result); + } + parseOrderStatus (status) { const statuses = { // basic orders @@ -1166,6 +1153,7 @@ module.exports = class bybit extends Exchange { } const timeInForce = this.parseTimeInForce (this.safeString (order, 'time_in_force')); const stopPrice = this.safeFloat (order, 'stop_px'); + const postOnly = (timeInForce === 'PO'); return { 'info': order, 'id': id, @@ -1176,6 +1164,7 @@ module.exports = class bybit extends Exchange { 'symbol': symbol, 'type': type, 'timeInForce': timeInForce, + 'postOnly': postOnly, 'side': side, 'price': price, 'stopPrice': stopPrice, @@ -1192,7 +1181,7 @@ module.exports = class bybit extends Exchange { async fetchOrder (id, symbol = undefined, params = {}) { if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' fetchOrder requires a symbol argument'); + throw new ArgumentsRequired (this.id + ' fetchOrder() requires a symbol argument'); } await this.loadMarkets (); const market = this.market (symbol); @@ -1206,7 +1195,7 @@ module.exports = class bybit extends Exchange { }; const marketTypes = this.safeValue (this.options, 'marketTypes', {}); const marketType = this.safeString (marketTypes, symbol); - let method = (marketType === 'linear') ? 'privateLinearGetOrderSearch' : 'privateGetOrder'; + let method = (marketType === 'linear') ? 'privateLinearGetOrderSearch' : 'v2PrivateGetOrder'; const stopOrderId = this.safeString (params, 'stop_order_id'); if (stopOrderId === undefined) { const orderLinkId = this.safeString (params, 'order_link_id'); @@ -1214,7 +1203,7 @@ module.exports = class bybit extends Exchange { request['order_id'] = id; } } else { - method = (marketType === 'linear') ? 'privateLinearGetStopOrderSearch' : 'privateGetStopOrder'; + method = (marketType === 'linear') ? 'privateLinearGetStopOrderSearch' : 'v2PrivateGetStopOrder'; } const response = await this[method] (this.extend (request, params)); // @@ -1327,7 +1316,7 @@ module.exports = class bybit extends Exchange { if (price !== undefined) { request['price'] = parseFloat (this.priceToPrecision (symbol, price)); } else { - throw new ArgumentsRequired (this.id + ' createOrder requires a price argument for a ' + type + ' order'); + throw new ArgumentsRequired (this.id + ' createOrder() requires a price argument for a ' + type + ' order'); } } const clientOrderId = this.safeString2 (params, 'order_link_id', 'clientOrderId'); @@ -1339,7 +1328,7 @@ module.exports = class bybit extends Exchange { const basePrice = this.safeValue (params, 'base_price'); const marketTypes = this.safeValue (this.options, 'marketTypes', {}); const marketType = this.safeString (marketTypes, symbol); - let method = (marketType === 'linear') ? 'privateLinearPostOrderCreate' : 'privatePostOrderCreate'; + let method = (marketType === 'linear') ? 'privateLinearPostOrderCreate' : 'v2PrivatePostOrderCreate'; if (marketType === 'linear') { method = 'privateLinearPostOrderCreate'; request['reduce_only'] = false; @@ -1347,15 +1336,15 @@ module.exports = class bybit extends Exchange { } if (stopPx !== undefined) { if (basePrice === undefined) { - throw new ArgumentsRequired (this.id + ' createOrder requires both the stop_px and base_price params for a conditional ' + type + ' order'); + throw new ArgumentsRequired (this.id + ' createOrder() requires both the stop_px and base_price params for a conditional ' + type + ' order'); } else { - method = (marketType === 'linear') ? 'privateLinearPostStopOrderCreate' : 'openapiPostStopOrderCreate'; + method = (marketType === 'linear') ? 'privateLinearPostStopOrderCreate' : 'v2PrivatePostStopOrderCreate'; request['stop_px'] = parseFloat (this.priceToPrecision (symbol, stopPx)); request['base_price'] = parseFloat (this.priceToPrecision (symbol, basePrice)); params = this.omit (params, [ 'stop_px', 'stopPrice', 'base_price' ]); } } else if (basePrice !== undefined) { - throw new ArgumentsRequired (this.id + ' createOrder requires both the stop_px and base_price params for a conditional ' + type + ' order'); + throw new ArgumentsRequired (this.id + ' createOrder() requires both the stop_px and base_price params for a conditional ' + type + ' order'); } const response = await this[method] (this.extend (request, params)); // @@ -1441,7 +1430,7 @@ module.exports = class bybit extends Exchange { async editOrder (id, symbol, type, side, amount = undefined, price = undefined, params = {}) { if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' editOrder requires an symbol argument'); + throw new ArgumentsRequired (this.id + ' editOrder() requires an symbol argument'); } const marketTypes = this.safeValue (this.options, 'marketTypes', {}); const marketType = this.safeString (marketTypes, symbol); @@ -1457,17 +1446,23 @@ module.exports = class bybit extends Exchange { // 'stop_order_id': id, // only for conditional orders // 'p_r_trigger_price': 123.45, // new trigger price also known as stop_px }; - let method = (marketType === 'linear') ? 'privateLinearPostOrderReplace' : 'openapiPostOrderReplace'; + let method = (marketType === 'linear') ? 'privateLinearPostOrderReplace' : 'v2PrivatePostOrderReplace'; const stopOrderId = this.safeString (params, 'stop_order_id'); if (stopOrderId !== undefined) { - method = (marketType === 'linear') ? 'privateLinearPostStopOrderReplace' : 'openapiPostStopOrderReplace'; + method = (marketType === 'linear') ? 'privateLinearPostStopOrderReplace' : 'v2PrivatePostStopOrderReplace'; request['stop_order_id'] = stopOrderId; params = this.omit (params, [ 'stop_order_id' ]); } else { request['order_id'] = id; } if (amount !== undefined) { - request['p_r_qty'] = parseInt (this.amountToPrecision (symbol, amount)); + let qty = this.amountToPrecision (symbol, amount); + if (market['inverse']) { + qty = parseInt (qty); + } else { + qty = parseFloat (qty); + } + request['p_r_qty'] = qty; } if (price !== undefined) { request['p_r_price'] = parseFloat (this.priceToPrecision (symbol, price)); @@ -1510,7 +1505,7 @@ module.exports = class bybit extends Exchange { async cancelOrder (id, symbol = undefined, params = {}) { if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' cancelOrder requires a symbol argument'); + throw new ArgumentsRequired (this.id + ' cancelOrder() requires a symbol argument'); } await this.loadMarkets (); const market = this.market (symbol); @@ -1524,7 +1519,7 @@ module.exports = class bybit extends Exchange { }; const marketTypes = this.safeValue (this.options, 'marketTypes', {}); const marketType = this.safeValue (marketTypes, symbol); - let method = (marketType === 'linear') ? 'privateLinearPostOrderCancel' : 'privatePostOrderCancel'; + let method = (marketType === 'linear') ? 'privateLinearPostOrderCancel' : 'v2PrivatePostOrderCancel'; const stopOrderId = this.safeString (params, 'stop_order_id'); if (stopOrderId === undefined) { const orderLinkId = this.safeString (params, 'order_link_id'); @@ -1532,7 +1527,7 @@ module.exports = class bybit extends Exchange { request['order_id'] = id; } } else { - method = (marketType === 'linear') ? 'privateLinearPostStopOrderCancel' : 'openapiPostStopOrderCancel'; + method = (marketType === 'linear') ? 'privateLinearPostStopOrderCancel' : 'v2PrivatePostStopOrderCancel'; } const response = await this[method] (this.extend (request, params)); const result = this.safeValue (response, 'result', {}); @@ -1541,17 +1536,17 @@ module.exports = class bybit extends Exchange { async cancelAllOrders (symbol = undefined, params = {}) { if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' cancelAllOrders requires a symbol argument'); + throw new ArgumentsRequired (this.id + ' cancelAllOrders() requires a symbol argument'); } await this.loadMarkets (); const market = this.market (symbol); const request = { 'symbol': market['id'], }; - const options = this.safeValue (this.options, 'cancelAllOrders'); + const options = this.safeValue (this.options, 'cancelAllOrders', {}); const marketTypes = this.safeValue (this.options, 'marketTypes', {}); const marketType = this.safeString (marketTypes, symbol); - const defaultMethod = (marketType === 'linear') ? 'privateLinearPostOrderCancelAll' : 'privatePostOrderCancelAll'; + const defaultMethod = (marketType === 'linear') ? 'privateLinearPostOrderCancelAll' : 'v2PrivatePostOrderCancelAll'; const method = this.safeString (options, 'method', defaultMethod); const response = await this[method] (this.extend (request, params)); const result = this.safeValue (response, 'result', []); @@ -1583,7 +1578,7 @@ module.exports = class bybit extends Exchange { const options = this.safeValue (this.options, 'fetchOrders', {}); const marketTypes = this.safeValue (this.options, 'marketTypes', {}); const marketType = this.safeString (marketTypes, symbol); - let defaultMethod = (marketType === 'linear') ? 'privateLinearGetOrderList' : 'openapiGetOrderList'; + let defaultMethod = (marketType === 'linear') ? 'privateLinearGetOrderList' : 'v2PrivateGetOrderList'; let query = params; if (('stop_order_id' in params) || ('stop_order_status' in params)) { let stopOrderStatus = this.safeValue (params, 'stopOrderStatus'); @@ -1594,7 +1589,7 @@ module.exports = class bybit extends Exchange { request['stop_order_status'] = stopOrderStatus; query = this.omit (params, 'stop_order_status'); } - defaultMethod = (marketType === 'linear') ? 'privateLinearGetStopOrderList' : 'openapiGetStopOrderList'; + defaultMethod = (marketType === 'linear') ? 'privateLinearGetStopOrderList' : 'v2PrivateGetStopOrderList'; } const method = this.safeString (options, 'method', defaultMethod); const response = await this[method] (this.extend (request, query)); @@ -1760,7 +1755,7 @@ module.exports = class bybit extends Exchange { if (symbol === undefined) { const orderId = this.safeString (params, 'order_id'); if (orderId === undefined) { - throw new ArgumentsRequired (this.id + ' fetchMyTrades requires a symbol argument or an order_id param'); + throw new ArgumentsRequired (this.id + ' fetchMyTrades() requires a symbol argument or an order_id param'); } else { request['order_id'] = orderId; params = this.omit (params, 'order_id'); @@ -1777,7 +1772,7 @@ module.exports = class bybit extends Exchange { } const marketTypes = this.safeValue (this.options, 'marketTypes', {}); const marketType = this.safeString (marketTypes, symbol); - const method = (marketType === 'linear') ? 'privateLinearGetTradeExecutionList' : 'privateGetExecutionList'; + const method = (marketType === 'linear') ? 'privateLinearGetTradeExecutionList' : 'v2PrivateGetExecutionList'; const response = await this[method] (this.extend (request, params)); // // inverse @@ -1867,41 +1862,60 @@ module.exports = class bybit extends Exchange { } async fetchDeposits (code = undefined, since = undefined, limit = undefined, params = {}) { - if (code === undefined) { - throw new ArgumentsRequired (this.id + ' fetchWithdrawals() requires a currency code argument'); - } await this.loadMarkets (); - const currency = this.currency (code); const request = { - 'currency': currency['id'], + // 'coin': currency['id'], + // 'currency': currency['id'], // alias + // 'start_date': this.iso8601 (since), + // 'end_date': this.iso8601 (till), + 'wallet_fund_type': 'Deposit', // Deposit, Withdraw, RealisedPNL, Commission, Refund, Prize, ExchangeOrderWithdraw, ExchangeOrderDeposit + // 'page': 1, + // 'limit': 20, // max 50 }; - if (limit !== undefined) { - request['count'] = limit; + let currency = undefined; + if (code !== undefined) { + currency = this.currency (code); + request['coin'] = currency['id']; } - const response = await this.privateGetGetDeposits (this.extend (request, params)); + if (since !== undefined) { + request['start_date'] = this.ymd (since); + } + if (limit !== undefined) { + request['limit'] = limit; + } + const response = await this.v2PrivateGetWalletFundRecords (this.extend (request, params)); // // { - // "jsonrpc": "2.0", - // "id": 5611, + // "ret_code": 0, + // "ret_msg": "ok", + // "ext_code": "", // "result": { - // "count": 1, // "data": [ // { - // "address": "2N35qDKDY22zmJq9eSyiAerMD4enJ1xx6ax", - // "amount": 5, - // "currency": "BTC", - // "received_timestamp": 1549295017670, - // "state": "completed", - // "transaction_id": "230669110fdaf0a0dbcdc079b6b8b43d5af29cc73683835b9bc6b3406c065fda", - // "updated_timestamp": 1549295130159 + // "id": 234467, + // "user_id": 1, + // "coin": "BTC", + // "wallet_id": 27913, + // "type": "Realized P&L", + // "amount": "-0.00000006", + // "tx_id": "", + // "address": "BTCUSD", + // "wallet_balance": "0.03000330", + // "exec_time": "2019-12-09T00:00:25.000Z", + // "cross_seq": 0 // } // ] - // } + // }, + // "ext_info": null, + // "time_now": "1577481867.115552", + // "rate_limit_status": 119, + // "rate_limit_reset_ms": 1577481867122, + // "rate_limit": 120 // } // const result = this.safeValue (response, 'result', {}); const data = this.safeValue (result, 'data', []); - return this.parseTransactions (data, currency, since, limit, params); + return this.parseTransactions (data, currency, since, limit); } async fetchWithdrawals (code = undefined, since = undefined, limit = undefined, params = {}) { @@ -1920,12 +1934,12 @@ module.exports = class bybit extends Exchange { request['coin'] = currency['id']; } if (since !== undefined) { - request['start_date'] = this.iso8601 (since); + request['start_date'] = this.ymd (since); } if (limit !== undefined) { request['limit'] = limit; } - const response = await this.openapiGetWalletWithdrawList (this.extend (request, params)); + const response = await this.v2PrivateGetWalletWithdrawList (this.extend (request, params)); // // { // "ret_code": 0, @@ -1991,9 +2005,25 @@ module.exports = class bybit extends Exchange { // "updated_at": "2019-06-11T02:20:24.000Z" // } // + // fetchDeposits ledger entries + // + // { + // "id": 234467, + // "user_id": 1, + // "coin": "BTC", + // "wallet_id": 27913, + // "type": "Realized P&L", + // "amount": "-0.00000006", + // "tx_id": "", + // "address": "BTCUSD", + // "wallet_balance": "0.03000330", + // "exec_time": "2019-12-09T00:00:25.000Z", + // "cross_seq": 0 + // } + // const currencyId = this.safeString (transaction, 'coin'); const code = this.safeCurrencyCode (currencyId, currency); - const timestamp = this.parse8601 (this.safeString (transaction, 'submited_at')); + const timestamp = this.parse8601 (this.safeString2 (transaction, 'submited_at', 'exec_time')); const updated = this.parse8601 (this.safeString (transaction, 'updated_at')); const status = this.parseTransactionStatus (this.safeString (transaction, 'status')); const address = this.safeString (transaction, 'address'); @@ -2043,12 +2073,12 @@ module.exports = class bybit extends Exchange { request['coin'] = currency['id']; } if (since !== undefined) { - request['start_date'] = this.iso8601 (since); + request['start_date'] = this.ymd (since); } if (limit !== undefined) { request['limit'] = limit; } - const response = await this.openapiGetWalletFundRecords (this.extend (request, params)); + const response = await this.v2PrivateGetWalletFundRecords (this.extend (request, params)); // // { // "ret_code": 0, @@ -2147,45 +2177,28 @@ module.exports = class bybit extends Exchange { } sign (path, api = 'public', method = 'GET', params = {}, headers = undefined, body = undefined) { - let url = this.urls['api']; - let request = path; + let url = this.implodeParams (this.urls['api'], { 'hostname': this.hostname }); + const type = this.safeString (api, 0); + const section = this.safeString (api, 1); + let request = '/' + type + '/' + section + '/' + path; // public v2 - if (api === 'public') { - request = '/' + this.version + '/' + api + '/' + request; + if (section === 'public') { if (Object.keys (params).length) { request += '?' + this.rawencode (params); } - } else if (api === 'publicLinear') { - request = '/public/linear/' + request; + } else if (type === 'public') { if (Object.keys (params).length) { request += '?' + this.rawencode (params); } } else { this.checkRequiredCredentials (); - if (api === 'openapi') { - request = '/open-api/' + request; - } else if (api === 'private') { - // private v2 - request = '/' + this.version + '/' + api + '/' + request; - } else if (api === 'privateLinear') { - request = '/private/linear/' + request; - } else { - // position, user - request = '/' + api + '/' + request; - } const timestamp = this.nonce (); const query = this.extend (params, { 'api_key': this.apiKey, 'recv_window': this.options['recvWindow'], 'timestamp': timestamp, }); - let auth = this.rawencode (this.keysort (query)); - // https://github.com/ccxt/ccxt/issues/7377 - // https://github.com/ccxt/ccxt/issues/7515 - // bybit encodes whole floats as integers without .0 for conditional stop-orders only - if (path.indexOf ('stop-order') >= 0) { - auth = auth.replace ('.0&', '&'); - } + const auth = this.rawencode (this.keysort (query)); const signature = this.hmac (this.encode (auth), this.encode (this.secret)); if (method === 'POST') { body = this.json (this.extend (query, { diff --git a/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/bytetrade.js b/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/bytetrade.js index bbd1af6f6..25953b6f7 100644 --- a/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/bytetrade.js +++ b/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/bytetrade.js @@ -285,7 +285,7 @@ module.exports = class bytetrade extends Exchange { async fetchBalance (params = {}) { if (!('userid' in params) && (this.apiKey === undefined)) { - throw new ArgumentsRequired (this.id + ' fetchDeposits requires this.apiKey or userid argument'); + throw new ArgumentsRequired (this.id + ' fetchDeposits() requires this.apiKey or userid argument'); } await this.loadMarkets (); const request = { @@ -580,6 +580,7 @@ module.exports = class bytetrade extends Exchange { 'symbol': symbol, 'type': type, 'timeInForce': undefined, + 'postOnly': undefined, 'side': side, 'price': price, 'stopPrice': undefined, @@ -597,7 +598,7 @@ module.exports = class bytetrade extends Exchange { async createOrder (symbol, type, side, amount, price = undefined, params = {}) { this.checkRequiredDependencies (); if (this.apiKey === undefined) { - throw new ArgumentsRequired ('createOrder requires this.apiKey or userid in params'); + throw new ArgumentsRequired ('createOrder() requires this.apiKey or userid in params'); } await this.loadMarkets (); const market = this.market (symbol); @@ -781,7 +782,7 @@ module.exports = class bytetrade extends Exchange { async fetchOrder (id, symbol = undefined, params = {}) { if (!('userid' in params) && (this.apiKey === undefined)) { - throw new ArgumentsRequired ('fetchOrder requires this.apiKey or userid argument'); + throw new ArgumentsRequired ('fetchOrder() requires this.apiKey or userid argument'); } await this.loadMarkets (); const request = { @@ -799,7 +800,7 @@ module.exports = class bytetrade extends Exchange { async fetchOpenOrders (symbol = undefined, since = undefined, limit = undefined, params = {}) { if (!('userid' in params) && (this.apiKey === undefined)) { - throw new ArgumentsRequired ('fetchOpenOrders requires this.apiKey or userid argument'); + throw new ArgumentsRequired ('fetchOpenOrders() requires this.apiKey or userid argument'); } await this.loadMarkets (); const request = { @@ -819,7 +820,7 @@ module.exports = class bytetrade extends Exchange { async fetchClosedOrders (symbol = undefined, since = undefined, limit = undefined, params = {}) { if (!('userid' in params) && (this.apiKey === undefined)) { - throw new ArgumentsRequired ('fetchClosedOrders requires this.apiKey or userid argument'); + throw new ArgumentsRequired ('fetchClosedOrders() requires this.apiKey or userid argument'); } await this.loadMarkets (); let market = undefined; @@ -839,7 +840,7 @@ module.exports = class bytetrade extends Exchange { async fetchOrders (symbol = undefined, since = undefined, limit = undefined, params = {}) { if (!('userid' in params) && (this.apiKey === undefined)) { - throw new ArgumentsRequired ('fetchOrders requires this.apiKey or userid argument'); + throw new ArgumentsRequired ('fetchOrders() requires this.apiKey or userid argument'); } await this.loadMarkets (); let market = undefined; @@ -859,10 +860,10 @@ module.exports = class bytetrade extends Exchange { async cancelOrder (id, symbol = undefined, params = {}) { if (this.apiKey === undefined) { - throw new ArgumentsRequired ('cancelOrder requires hasAlreadyAuthenticatedSuccessfully'); + throw new ArgumentsRequired ('cancelOrder() requires hasAlreadyAuthenticatedSuccessfully'); } if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' cancelOrder requires a symbol argument'); + throw new ArgumentsRequired (this.id + ' cancelOrder() requires a symbol argument'); } await this.loadMarkets (); const market = this.market (symbol); @@ -960,7 +961,7 @@ module.exports = class bytetrade extends Exchange { async transfer (code, amount, address, message = '', params = {}) { this.checkRequiredDependencies (); if (this.apiKey === undefined) { - throw new ArgumentsRequired ('transfer requires this.apiKey'); + throw new ArgumentsRequired ('transfer() requires this.apiKey'); } await this.loadMarkets (); const currency = this.currency (code); @@ -1066,7 +1067,7 @@ module.exports = class bytetrade extends Exchange { async fetchMyTrades (symbol = undefined, since = undefined, limit = undefined, params = {}) { if (!('userid' in params) && (this.apiKey === undefined)) { - throw new ArgumentsRequired ('fetchMyTrades requires this.apiKey or userid argument'); + throw new ArgumentsRequired ('fetchMyTrades() requires this.apiKey or userid argument'); } await this.loadMarkets (); const market = this.market (symbol); @@ -1086,7 +1087,7 @@ module.exports = class bytetrade extends Exchange { async fetchDeposits (code = undefined, since = undefined, limit = undefined, params = {}) { await this.loadMarkets (); if (!('userid' in params) && (this.apiKey === undefined)) { - throw new ArgumentsRequired ('fetchDeposits requires this.apiKey or userid argument'); + throw new ArgumentsRequired ('fetchDeposits() requires this.apiKey or userid argument'); } let currency = undefined; const request = { @@ -1109,7 +1110,7 @@ module.exports = class bytetrade extends Exchange { async fetchWithdrawals (code = undefined, since = undefined, limit = undefined, params = {}) { await this.loadMarkets (); if (!('userid' in params) && (this.apiKey === undefined)) { - throw new ArgumentsRequired ('fetchWithdrawals requires this.apiKey or userid argument'); + throw new ArgumentsRequired ('fetchWithdrawals() requires this.apiKey or userid argument'); } let currency = undefined; const request = { @@ -1193,7 +1194,7 @@ module.exports = class bytetrade extends Exchange { async fetchDepositAddress (code, params = {}) { await this.loadMarkets (); if (!('userid' in params) && (this.apiKey === undefined)) { - throw new ArgumentsRequired ('fetchDepositAddress requires this.apiKey or userid argument'); + throw new ArgumentsRequired ('fetchDepositAddress() requires this.apiKey or userid argument'); } const currency = this.currency (code); const request = { @@ -1219,7 +1220,7 @@ module.exports = class bytetrade extends Exchange { this.checkAddress (address); await this.loadMarkets (); if (this.apiKey === undefined) { - throw new ArgumentsRequired ('withdraw requires this.apiKey'); + throw new ArgumentsRequired (this.id + ' withdraw() requires this.apiKey'); } const addressResponse = await this.fetchDepositAddress (code); const chainTypeString = this.safeString (addressResponse, 'chainType'); diff --git a/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/huobiru.js b/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/cdax.js similarity index 53% rename from Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/huobiru.js rename to Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/cdax.js index 21e0de149..8bd27989d 100644 --- a/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/node_modules/ccxt/js/huobiru.js +++ b/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/cdax.js @@ -6,25 +6,27 @@ const huobipro = require ('./huobipro.js'); // --------------------------------------------------------------------------- -module.exports = class huobiru extends huobipro { +module.exports = class cdax extends huobipro { describe () { return this.deepExtend (super.describe (), { - 'id': 'huobiru', - 'name': 'Huobi Russia', + 'id': 'cdax', + 'name': 'CDAX', 'countries': [ 'RU' ], - 'hostname': 'www.huobi.com.ru', - 'pro': true, + 'hostname': 'cdax.io', + 'pro': false, 'urls': { - 'logo': 'https://user-images.githubusercontent.com/1294454/52978816-e8552e00-33e3-11e9-98ed-845acfece834.jpg', + 'logo': 'https://user-images.githubusercontent.com/1294454/102157692-fd406280-3e90-11eb-8d46-4511b617cd17.jpg', 'api': { 'market': 'https://{hostname}/api', 'public': 'https://{hostname}/api', 'private': 'https://{hostname}/api', + 'v2Public': 'https://{hostname}/api', + 'v2Private': 'https://{hostname}/api', }, - 'www': 'https://www.huobi.com.ru/ru-ru', - 'referral': 'https://www.huobi.com.ru/invite?invite_code=esc74', - 'doc': 'https://github.com/cloudapidoc/API_Docs_en', - 'fees': 'https://www.huobi.com.ru/ru-ru/about/fee/', + 'www': 'https://cdax.io', + 'referral': 'https://cdax.io/invite?invite_code=esc74', + 'doc': 'https://github.com/cloudapidoc/API_Docs', + 'fees': 'https://cdax.io/about/fee', }, }); } diff --git a/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/cex.js b/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/cex.js index 082db07c7..77473d391 100644 --- a/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/cex.js +++ b/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/cex.js @@ -676,10 +676,9 @@ module.exports = class cex extends Exchange { let cost = undefined; if (market !== undefined) { symbol = market['symbol']; - cost = this.safeFloat (order, 'ta:' + market['quote']); - if (cost === undefined) { - cost = this.safeFloat (order, 'tta:' + market['quote']); - } + const taCost = this.safeFloat (order, 'ta:' + market['quote']); + const ttaCost = this.safeFloat (order, 'tta:' + market['quote']); + cost = this.sum (taCost, ttaCost); const baseFee = 'fa:' + market['base']; const baseTakerFee = 'tfa:' + market['base']; const quoteFee = 'fa:' + market['quote']; @@ -883,6 +882,7 @@ module.exports = class cex extends Exchange { 'symbol': symbol, 'type': (price === undefined) ? 'market' : 'limit', 'timeInForce': undefined, + 'postOnly': undefined, 'side': side, 'price': price, 'stopPrice': undefined, @@ -918,7 +918,7 @@ module.exports = class cex extends Exchange { await this.loadMarkets (); const method = 'privatePostArchivedOrdersPair'; if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' fetchClosedOrders requires a symbol argument'); + throw new ArgumentsRequired (this.id + ' fetchClosedOrders() requires a symbol argument'); } const market = this.market (symbol); const request = { 'pair': market['id'] }; @@ -1252,10 +1252,10 @@ module.exports = class cex extends Exchange { async editOrder (id, symbol, type, side, amount = undefined, price = undefined, params = {}) { if (amount === undefined) { - throw new ArgumentsRequired (this.id + ' editOrder requires a amount argument'); + throw new ArgumentsRequired (this.id + ' editOrder() requires a amount argument'); } if (price === undefined) { - throw new ArgumentsRequired (this.id + ' editOrder requires a price argument'); + throw new ArgumentsRequired (this.id + ' editOrder() requires a price argument'); } await this.loadMarkets (); const market = this.market (symbol); diff --git a/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/coinbase.js b/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/coinbase.js index 61fc650dc..cfceba2a4 100644 --- a/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/coinbase.js +++ b/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/coinbase.js @@ -3,7 +3,7 @@ // ---------------------------------------------------------------------------- const Exchange = require ('./base/Exchange'); -const { ExchangeError, ArgumentsRequired, AuthenticationError, RateLimitExceeded } = require ('./base/errors'); +const { ExchangeError, ArgumentsRequired, AuthenticationError, RateLimitExceeded, InvalidNonce } = require ('./base/errors'); // ---------------------------------------------------------------------------- @@ -123,23 +123,28 @@ module.exports = class coinbase extends Exchange { }, }, 'exceptions': { - 'two_factor_required': AuthenticationError, // 402 When sending money over 2fa limit - 'param_required': ExchangeError, // 400 Missing parameter - 'validation_error': ExchangeError, // 400 Unable to validate POST/PUT - 'invalid_request': ExchangeError, // 400 Invalid request - 'personal_details_required': AuthenticationError, // 400 User’s personal detail required to complete this request - 'identity_verification_required': AuthenticationError, // 400 Identity verification is required to complete this request - 'jumio_verification_required': AuthenticationError, // 400 Document verification is required to complete this request - 'jumio_face_match_verification_required': AuthenticationError, // 400 Document verification including face match is required to complete this request - 'unverified_email': AuthenticationError, // 400 User has not verified their email - 'authentication_error': AuthenticationError, // 401 Invalid auth (generic) - 'invalid_token': AuthenticationError, // 401 Invalid Oauth token - 'revoked_token': AuthenticationError, // 401 Revoked Oauth token - 'expired_token': AuthenticationError, // 401 Expired Oauth token - 'invalid_scope': AuthenticationError, // 403 User hasn’t authenticated necessary scope - 'not_found': ExchangeError, // 404 Resource not found - 'rate_limit_exceeded': RateLimitExceeded, // 429 Rate limit exceeded - 'internal_server_error': ExchangeError, // 500 Internal server error + 'exact': { + 'two_factor_required': AuthenticationError, // 402 When sending money over 2fa limit + 'param_required': ExchangeError, // 400 Missing parameter + 'validation_error': ExchangeError, // 400 Unable to validate POST/PUT + 'invalid_request': ExchangeError, // 400 Invalid request + 'personal_details_required': AuthenticationError, // 400 User’s personal detail required to complete this request + 'identity_verification_required': AuthenticationError, // 400 Identity verification is required to complete this request + 'jumio_verification_required': AuthenticationError, // 400 Document verification is required to complete this request + 'jumio_face_match_verification_required': AuthenticationError, // 400 Document verification including face match is required to complete this request + 'unverified_email': AuthenticationError, // 400 User has not verified their email + 'authentication_error': AuthenticationError, // 401 Invalid auth (generic) + 'invalid_token': AuthenticationError, // 401 Invalid Oauth token + 'revoked_token': AuthenticationError, // 401 Revoked Oauth token + 'expired_token': AuthenticationError, // 401 Expired Oauth token + 'invalid_scope': AuthenticationError, // 403 User hasn’t authenticated necessary scope + 'not_found': ExchangeError, // 404 Resource not found + 'rate_limit_exceeded': RateLimitExceeded, // 429 Rate limit exceeded + 'internal_server_error': ExchangeError, // 500 Internal server error + }, + 'broad': { + 'request timestamp expired': InvalidNonce, // {"errors":[{"id":"authentication_error","message":"request timestamp expired"}]} + }, }, 'commonCurrencies': { 'CGLD': 'CELO', @@ -172,7 +177,11 @@ module.exports = class coinbase extends Exchange { } async fetchAccounts (params = {}) { - const response = await this.privateGetAccounts (params); + await this.loadMarkets (); + const request = { + 'limit': 100, + }; + const response = await this.privateGetAccounts (this.extend (request, params)); // // { // "id": "XLM", @@ -703,7 +712,10 @@ module.exports = class coinbase extends Exchange { async fetchBalance (params = {}) { await this.loadMarkets (); - const response = await this.privateGetAccounts (params); + const request = { + 'limit': 100, + }; + const response = await this.privateGetAccounts (this.extend (request, params)); const balances = this.safeValue (response, 'data'); const accounts = this.safeValue (params, 'type', this.options['accounts']); const result = { 'info': response }; @@ -1175,7 +1187,9 @@ module.exports = class coinbase extends Exchange { // let errorCode = this.safeString (response, 'error'); if (errorCode !== undefined) { - this.throwExactlyMatchedException (this.exceptions, errorCode, feedback); + const errorMessage = this.safeString (response, 'error_description'); + this.throwExactlyMatchedException (this.exceptions['exact'], errorCode, feedback); + this.throwBroadlyMatchedException (this.exceptions['broad'], errorMessage, feedback); throw new ExchangeError (feedback); } const errors = this.safeValue (response, 'errors'); @@ -1184,8 +1198,10 @@ module.exports = class coinbase extends Exchange { const numErrors = errors.length; if (numErrors > 0) { errorCode = this.safeString (errors[0], 'id'); + const errorMessage = this.safeString (errors[0], 'message'); if (errorCode !== undefined) { - this.throwExactlyMatchedException (this.exceptions, errorCode, feedback); + this.throwExactlyMatchedException (this.exceptions['exact'], errorCode, feedback); + this.throwBroadlyMatchedException (this.exceptions['broad'], errorMessage, feedback); throw new ExchangeError (feedback); } } diff --git a/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/coinbasepro.js b/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/coinbasepro.js index f28b951c4..582c03a61 100644 --- a/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/coinbasepro.js +++ b/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/coinbasepro.js @@ -345,6 +345,7 @@ module.exports = class coinbasepro extends Exchange { } async fetchAccounts (params = {}) { + await this.loadMarkets (); const response = await this.privateGetAccounts (params); // // [ @@ -523,12 +524,20 @@ module.exports = class coinbasepro extends Exchange { // trade_id: 82047307, // maker_order_id: '0f358725-2134-435e-be11-753912a326e0', // taker_order_id: '252b7002-87a3-425c-ac73-f5b9e23f3caf', + // order_id: 'd50ec984-77a8-460a-b958-66f114b0de9b', // side: 'sell', // size: '0.00513192', // price: '9314.78', // product_id: 'BTC-USD', + // profile_id: '6244401d-c078-40d9-b305-7ad3551bc3b0', // sequence: 12038915443, // time: '2020-01-31T20:03:41.158814Z' + // created_at: '2014-11-07T22:19:28.578544Z', + // liquidity: 'T', + // fee: '0.00025', + // settled: true, + // usd_volume: '0.0924556000000000', + // user_id: '595eb864313c2b02ddf2937d' // } // const timestamp = this.parse8601 (this.safeString2 (trade, 'time', 'created_at')); @@ -537,10 +546,15 @@ module.exports = class coinbasepro extends Exchange { let feeRate = undefined; let feeCurrency = undefined; let takerOrMaker = undefined; + let cost = undefined; if (market !== undefined) { + const feeCurrencyId = this.safeStringLower (market, 'quoteId'); + const costField = feeCurrencyId + '_value'; + cost = this.safeFloat (trade, costField); feeCurrency = market['quote']; - if ('liquidity' in trade) { - takerOrMaker = (trade['liquidity'] === 'T') ? 'taker' : 'maker'; + const liquidity = this.safeString (trade, 'liquidity'); + if (liquidity !== undefined) { + takerOrMaker = (liquidity === 'T') ? 'taker' : 'maker'; feeRate = market[takerOrMaker]; } } @@ -560,6 +574,9 @@ module.exports = class coinbasepro extends Exchange { } const price = this.safeFloat (trade, 'price'); const amount = this.safeFloat (trade, 'size'); + if (cost === undefined) { + cost = amount * price; + } return { 'id': id, 'order': orderId, @@ -573,14 +590,14 @@ module.exports = class coinbasepro extends Exchange { 'price': price, 'amount': amount, 'fee': fee, - 'cost': price * amount, + 'cost': cost, }; } async fetchMyTrades (symbol = undefined, since = undefined, limit = undefined, params = {}) { // as of 2018-08-23 if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' fetchMyTrades requires a symbol argument'); + throw new ArgumentsRequired (this.id + ' fetchMyTrades() requires a symbol argument'); } await this.loadMarkets (); const market = this.market (symbol); @@ -600,6 +617,9 @@ module.exports = class coinbasepro extends Exchange { const request = { 'id': market['id'], // fixes issue #2 }; + if (limit !== undefined) { + request['limit'] = limit; // default 100 + } const response = await this.publicGetProductsIdTrades (this.extend (request, params)); return this.parseTrades (response, market, since, limit); } @@ -676,6 +696,27 @@ module.exports = class coinbasepro extends Exchange { } parseOrder (order, market = undefined) { + // + // createOrder + // + // { + // "id": "d0c5340b-6d6c-49d9-b567-48c4bfca13d2", + // "price": "0.10000000", + // "size": "0.01000000", + // "product_id": "BTC-USD", + // "side": "buy", + // "stp": "dc", + // "type": "limit", + // "time_in_force": "GTC", + // "post_only": false, + // "created_at": "2016-12-08T20:02:28.53864Z", + // "fill_fees": "0.0000000000000000", + // "filled_size": "0.00000000", + // "executed_value": "0.0000000000000000", + // "status": "pending", + // "settled": false + // } + // const timestamp = this.parse8601 (this.safeString (order, 'created_at')); const marketId = this.safeString (order, 'product_id'); market = this.safeMarket (marketId, market, '-'); @@ -706,9 +747,13 @@ module.exports = class coinbasepro extends Exchange { const id = this.safeString (order, 'id'); const type = this.safeString (order, 'type'); const side = this.safeString (order, 'side'); + const timeInForce = this.safeString (order, 'time_in_force'); + const postOnly = this.safeValue (order, 'post_only'); + const stopPrice = this.safeFloat (order, 'stop_price'); + const clientOrderId = this.safeString (order, 'client_oid'); return { 'id': id, - 'clientOrderId': undefined, + 'clientOrderId': clientOrderId, 'info': order, 'timestamp': timestamp, 'datetime': this.iso8601 (timestamp), @@ -716,10 +761,11 @@ module.exports = class coinbasepro extends Exchange { 'status': status, 'symbol': market['symbol'], 'type': type, - 'timeInForce': undefined, + 'timeInForce': timeInForce, + 'postOnly': postOnly, 'side': side, 'price': price, - 'stopPrice': undefined, + 'stopPrice': stopPrice, 'cost': cost, 'amount': amount, 'filled': filled, @@ -732,10 +778,18 @@ module.exports = class coinbasepro extends Exchange { async fetchOrder (id, symbol = undefined, params = {}) { await this.loadMarkets (); - const request = { - 'id': id, - }; - const response = await this.privateGetOrdersId (this.extend (request, params)); + const request = {}; + const clientOrderId = this.safeString2 (params, 'clientOrderId', 'client_oid'); + let method = undefined; + if (clientOrderId === undefined) { + method = 'privateGetOrdersId'; + request['id'] = id; + } else { + method = 'privateGetOrdersClientClientOid'; + request['client_oid'] = clientOrderId; + params = this.omit (params, [ 'clientOrderId', 'client_oid' ]); + } + const response = await this[method] (this.extend (request, params)); return this.parseOrder (response); } @@ -753,17 +807,10 @@ module.exports = class coinbasepro extends Exchange { } async fetchOrders (symbol = undefined, since = undefined, limit = undefined, params = {}) { - await this.loadMarkets (); const request = { 'status': 'all', }; - let market = undefined; - if (symbol !== undefined) { - market = this.market (symbol); - request['product_id'] = market['id']; - } - const response = await this.privateGetOrders (this.extend (request, params)); - return this.parseOrders (response, market, since, limit); + return await this.fetchOpenOrders (symbol, since, limit, this.extend (request, params)); } async fetchOpenOrders (symbol = undefined, since = undefined, limit = undefined, params = {}) { @@ -774,47 +821,131 @@ module.exports = class coinbasepro extends Exchange { market = this.market (symbol); request['product_id'] = market['id']; } + if (limit !== undefined) { + request['limit'] = limit; // default 100 + } const response = await this.privateGetOrders (this.extend (request, params)); return this.parseOrders (response, market, since, limit); } async fetchClosedOrders (symbol = undefined, since = undefined, limit = undefined, params = {}) { - await this.loadMarkets (); const request = { 'status': 'done', }; - let market = undefined; - if (symbol !== undefined) { - market = this.market (symbol); - request['product_id'] = market['id']; - } - const response = await this.privateGetOrders (this.extend (request, params)); - return this.parseOrders (response, market, since, limit); + return await this.fetchOpenOrders (symbol, since, limit, this.extend (request, params)); } async createOrder (symbol, type, side, amount, price = undefined, params = {}) { await this.loadMarkets (); - // let oid = this.nonce ().toString (); + const market = this.market (symbol); const request = { - 'product_id': this.marketId (symbol), - 'side': side, - 'size': this.amountToPrecision (symbol, amount), + // common params -------------------------------------------------- + // 'client_oid': clientOrderId, 'type': type, + 'side': side, + 'product_id': market['id'], + // 'size': this.amountToPrecision (symbol, amount), + // 'stp': 'dc', // self-trade prevention, dc = decrease and cancel, co = cancel oldest, cn = cancel newest, cb = cancel both + // 'stop': 'loss', // "loss" = stop loss below price, "entry" = take profit above price + // 'stop_price': this.priceToPrecision (symbol, price), + // limit order params --------------------------------------------- + // 'price': this.priceToPrecision (symbol, price), + // 'size': this.amountToPrecision (symbol, amount), + // 'time_in_force': 'GTC', // GTC, GTT, IOC, or FOK + // 'cancel_after' [optional]* min, hour, day, requires time_in_force to be GTT + // 'post_only': false, // invalid when time_in_force is IOC or FOK + // market order params -------------------------------------------- + // 'size': this.amountToPrecision (symbol, amount), + // 'funds': this.costToPrecision (symbol, amount), }; + const clientOrderId = this.safeString2 (params, 'clientOrderId', 'client_oid'); + if (clientOrderId !== undefined) { + request['client_oid'] = clientOrderId; + params = this.omit (params, [ 'clientOrderId', 'client_oid' ]); + } + const stopPrice = this.safeFloat2 (params, 'stopPrice', 'stop_price'); + if (stopPrice !== undefined) { + request['stop_price'] = this.priceToPrecision (symbol, stopPrice); + params = this.omit (params, [ 'stopPrice', 'stop_price' ]); + } + const timeInForce = this.safeString2 (params, 'timeInForce', 'time_in_force'); + if (timeInForce !== undefined) { + request['time_in_force'] = timeInForce; + params = this.omit (params, [ 'timeInForce', 'time_in_force' ]); + } if (type === 'limit') { request['price'] = this.priceToPrecision (symbol, price); + request['size'] = this.amountToPrecision (symbol, amount); + } else if (type === 'market') { + let cost = this.safeFloat2 (params, 'cost', 'funds'); + if (cost === undefined) { + if (price !== undefined) { + cost = amount * price; + } + } else { + params = this.omit (params, [ 'cost', 'funds' ]); + } + if (cost !== undefined) { + request['funds'] = this.costToPrecision (symbol, cost); + } else { + request['size'] = this.amountToPrecision (symbol, amount); + } } const response = await this.privatePostOrders (this.extend (request, params)); - return this.parseOrder (response); + // + // { + // "id": "d0c5340b-6d6c-49d9-b567-48c4bfca13d2", + // "price": "0.10000000", + // "size": "0.01000000", + // "product_id": "BTC-USD", + // "side": "buy", + // "stp": "dc", + // "type": "limit", + // "time_in_force": "GTC", + // "post_only": false, + // "created_at": "2016-12-08T20:02:28.53864Z", + // "fill_fees": "0.0000000000000000", + // "filled_size": "0.00000000", + // "executed_value": "0.0000000000000000", + // "status": "pending", + // "settled": false + // } + // + return this.parseOrder (response, market); } async cancelOrder (id, symbol = undefined, params = {}) { await this.loadMarkets (); - return await this.privateDeleteOrdersId ({ 'id': id }); + const request = { + // 'product_id': market['id'], // the request will be more performant if you include it + }; + const clientOrderId = this.safeString2 (params, 'clientOrderId', 'client_oid'); + let method = undefined; + if (clientOrderId === undefined) { + method = 'privateDeleteOrdersId'; + request['id'] = id; + } else { + method = 'privateDeleteOrdersClientClientOid'; + request['client_oid'] = clientOrderId; + params = this.omit (params, [ 'clientOrderId', 'client_oid' ]); + } + let market = undefined; + if (symbol !== undefined) { + market = this.market (symbol); + request['product_id'] = market['symbol']; // the request will be more performant if you include it + } + return await this[method] (this.extend (request, params)); } async cancelAllOrders (symbol = undefined, params = {}) { - return await this.privateDeleteOrders (params); + await this.loadMarkets (); + const request = {}; + let market = undefined; + if (symbol !== undefined) { + market = this.market (symbol); + request['product_id'] = market['symbol']; // the request will be more performant if you include it + } + return await this.privateDeleteOrders (this.extend (request, params)); } calculateFee (symbol, type, side, amount, price, takerOrMaker = 'taker', params = {}) { @@ -880,6 +1011,9 @@ module.exports = class coinbasepro extends Exchange { } else { method += 'Crypto'; request['crypto_address'] = address; + if (tag !== undefined) { + request['destination_tag'] = tag; + } } const response = await this[method] (this.extend (request, params)); if (!response) { @@ -965,7 +1099,7 @@ module.exports = class coinbasepro extends Exchange { const currencyId = this.safeString (transaction, 'currency'); const code = this.safeCurrencyCode (currencyId, currency); const status = this.parseTransactionStatus (transaction); - const amount = this.safeFloat (transaction, 'amount'); + let amount = this.safeFloat (transaction, 'amount'); let type = this.safeString (transaction, 'type'); let address = this.safeString (details, 'crypto_address'); const tag = this.safeString (details, 'destination_tag'); @@ -976,9 +1110,12 @@ module.exports = class coinbasepro extends Exchange { address = this.safeString (details, 'sent_to_address', address); const feeCost = this.safeFloat (details, 'fee'); if (feeCost !== undefined) { + if (amount !== undefined) { + amount -= feeCost; + } fee = { 'cost': feeCost, - 'code': code, + 'currency': code, }; } } diff --git a/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/coincheck.js b/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/coincheck.js index 6b2618ad3..807882d02 100644 --- a/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/coincheck.js +++ b/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/coincheck.js @@ -81,10 +81,11 @@ module.exports = class coincheck extends Exchange { 'markets': { 'BTC/JPY': { 'id': 'btc_jpy', 'symbol': 'BTC/JPY', 'base': 'BTC', 'quote': 'JPY', 'baseId': 'btc', 'quoteId': 'jpy' }, // the only real pair // 'ETH/JPY': { 'id': 'eth_jpy', 'symbol': 'ETH/JPY', 'base': 'ETH', 'quote': 'JPY', 'baseId': 'eth', 'quoteId': 'jpy' }, - // 'ETC/JPY': { 'id': 'etc_jpy', 'symbol': 'ETC/JPY', 'base': 'ETC', 'quote': 'JPY', 'baseId': 'etc', 'quoteId': 'jpy' }, + 'ETC/JPY': { 'id': 'etc_jpy', 'symbol': 'ETC/JPY', 'base': 'ETC', 'quote': 'JPY', 'baseId': 'etc', 'quoteId': 'jpy' }, // 'DAO/JPY': { 'id': 'dao_jpy', 'symbol': 'DAO/JPY', 'base': 'DAO', 'quote': 'JPY', 'baseId': 'dao', 'quoteId': 'jpy' }, // 'LSK/JPY': { 'id': 'lsk_jpy', 'symbol': 'LSK/JPY', 'base': 'LSK', 'quote': 'JPY', 'baseId': 'lsk', 'quoteId': 'jpy' }, - // 'FCT/JPY': { 'id': 'fct_jpy', 'symbol': 'FCT/JPY', 'base': 'FCT', 'quote': 'JPY', 'baseId': 'fct', 'quoteId': 'jpy' }, + 'FCT/JPY': { 'id': 'fct_jpy', 'symbol': 'FCT/JPY', 'base': 'FCT', 'quote': 'JPY', 'baseId': 'fct', 'quoteId': 'jpy' }, + 'MONA/JPY': { 'id': 'mona_jpy', 'symbol': 'MONA/JPY', 'base': 'MONA', 'quote': 'JPY', 'baseId': 'mona', 'quoteId': 'jpy' }, // 'XMR/JPY': { 'id': 'xmr_jpy', 'symbol': 'XMR/JPY', 'base': 'XMR', 'quote': 'JPY', 'baseId': 'xmr', 'quoteId': 'jpy' }, // 'REP/JPY': { 'id': 'rep_jpy', 'symbol': 'REP/JPY', 'base': 'REP', 'quote': 'JPY', 'baseId': 'rep', 'quoteId': 'jpy' }, // 'XRP/JPY': { 'id': 'xrp_jpy', 'symbol': 'XRP/JPY', 'base': 'XRP', 'quote': 'JPY', 'baseId': 'xrp', 'quoteId': 'jpy' }, @@ -93,7 +94,7 @@ module.exports = class coincheck extends Exchange { // 'LTC/JPY': { 'id': 'ltc_jpy', 'symbol': 'LTC/JPY', 'base': 'LTC', 'quote': 'JPY', 'baseId': 'ltc', 'quoteId': 'jpy' }, // 'DASH/JPY': { 'id': 'dash_jpy', 'symbol': 'DASH/JPY', 'base': 'DASH', 'quote': 'JPY', 'baseId': 'dash', 'quoteId': 'jpy' }, // 'ETH/BTC': { 'id': 'eth_btc', 'symbol': 'ETH/BTC', 'base': 'ETH', 'quote': 'BTC', 'baseId': 'eth', 'quoteId': 'btc' }, - // 'ETC/BTC': { 'id': 'etc_btc', 'symbol': 'ETC/BTC', 'base': 'ETC', 'quote': 'BTC', 'baseId': 'etc', 'quoteId': 'btc' }, + 'ETC/BTC': { 'id': 'etc_btc', 'symbol': 'ETC/BTC', 'base': 'ETC', 'quote': 'BTC', 'baseId': 'etc', 'quoteId': 'btc' }, // 'LSK/BTC': { 'id': 'lsk_btc', 'symbol': 'LSK/BTC', 'base': 'LSK', 'quote': 'BTC', 'baseId': 'lsk', 'quoteId': 'btc' }, // 'FCT/BTC': { 'id': 'fct_btc', 'symbol': 'FCT/BTC', 'base': 'FCT', 'quote': 'BTC', 'baseId': 'fct', 'quoteId': 'btc' }, // 'XMR/BTC': { 'id': 'xmr_btc', 'symbol': 'XMR/BTC', 'base': 'XMR', 'quote': 'BTC', 'baseId': 'xmr', 'quoteId': 'btc' }, @@ -197,6 +198,7 @@ module.exports = class coincheck extends Exchange { 'side': side, 'type': undefined, 'timeInForce': undefined, + 'postOnly': undefined, 'status': status, 'symbol': symbol, 'price': price, @@ -210,11 +212,12 @@ module.exports = class coincheck extends Exchange { } async fetchOrderBook (symbol, limit = undefined, params = {}) { - if (symbol !== 'BTC/JPY') { - throw new BadSymbol (this.id + ' fetchOrderBook () supports BTC/JPY only'); - } await this.loadMarkets (); - const response = await this.publicGetOrderBooks (params); + const market = this.market (symbol); + const request = { + 'pair': market['id'], + }; + const response = await this.publicGetOrderBooks (this.extend (request, params)); return this.parseOrderBook (response); } @@ -223,7 +226,11 @@ module.exports = class coincheck extends Exchange { throw new BadSymbol (this.id + ' fetchTicker () supports BTC/JPY only'); } await this.loadMarkets (); - const ticker = await this.publicGetTicker (params); + const market = this.market (symbol); + const request = { + 'pair': market['id'], + }; + const ticker = await this.publicGetTicker (this.extend (request, params)); const timestamp = this.safeTimestamp (ticker, 'timestamp'); const last = this.safeFloat (ticker, 'last'); return { @@ -337,9 +344,6 @@ module.exports = class coincheck extends Exchange { } async fetchTrades (symbol, since = undefined, limit = undefined, params = {}) { - if (symbol !== 'BTC/JPY') { - throw new BadSymbol (this.id + ' fetchTrades () supports BTC/JPY only'); - } await this.loadMarkets (); const market = this.market (symbol); const request = { diff --git a/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/coinegg.js b/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/coinegg.js index 0918ef9a0..e270e3bf7 100644 --- a/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/coinegg.js +++ b/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/coinegg.js @@ -154,6 +154,7 @@ module.exports = class coinegg extends Exchange { }, 'commonCurrencies': { 'JBC': 'JubaoCoin', + 'SBTC': 'Super Bitcoin', }, }); } @@ -367,6 +368,7 @@ module.exports = class coinegg extends Exchange { 'symbol': symbol, 'type': type, 'timeInForce': undefined, + 'postOnly': undefined, 'side': side, 'price': price, 'stopPrice': undefined, diff --git a/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/coinex.js b/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/coinex.js index 91f4c2052..cc344ee72 100644 --- a/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/coinex.js +++ b/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/coinex.js @@ -92,6 +92,8 @@ module.exports = class coinex extends Exchange { 'order/status', 'order/status/batch', 'order/user/deals', + 'sub_account/balance', + 'sub_account/transfer/history', ], 'post': [ 'balance/coin/withdraw', @@ -499,6 +501,7 @@ module.exports = class coinex extends Exchange { 'symbol': symbol, 'type': type, 'timeInForce': undefined, + 'postOnly': undefined, 'side': side, 'price': price, 'stopPrice': undefined, @@ -562,7 +565,7 @@ module.exports = class coinex extends Exchange { async fetchOrder (id, symbol = undefined, params = {}) { if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' fetchOrder requires a symbol argument'); + throw new ArgumentsRequired (this.id + ' fetchOrder() requires a symbol argument'); } await this.loadMarkets (); const market = this.market (symbol); @@ -759,7 +762,7 @@ module.exports = class coinex extends Exchange { const timestamp = this.safeTimestamp (transaction, 'create_time'); const type = ('coin_withdraw_id' in transaction) ? 'withdraw' : 'deposit'; const status = this.parseTransactionStatus (this.safeString (transaction, 'status')); - const amount = this.safeFloat (transaction, 'amount'); + let amount = this.safeFloat (transaction, 'amount'); let feeCost = this.safeFloat (transaction, 'tx_fee'); if (type === 'deposit') { feeCost = 0; @@ -768,6 +771,10 @@ module.exports = class coinex extends Exchange { 'cost': feeCost, 'currency': code, }; + // https://github.com/ccxt/ccxt/issues/8321 + if (amount !== undefined) { + amount = amount - feeCost; + } return { 'info': transaction, 'id': id, @@ -787,7 +794,7 @@ module.exports = class coinex extends Exchange { async fetchWithdrawals (code = undefined, since = undefined, limit = undefined, params = {}) { if (code === undefined) { - throw new ArgumentsRequired (this.id + ' fetchWithdrawals requires a currency code argument'); + throw new ArgumentsRequired (this.id + ' fetchWithdrawals() requires a currency code argument'); } await this.loadMarkets (); const currency = this.currency (code); @@ -845,7 +852,7 @@ module.exports = class coinex extends Exchange { async fetchDeposits (code = undefined, since = undefined, limit = undefined, params = {}) { if (code === undefined) { - throw new ArgumentsRequired (this.id + ' fetchDeposits requires a currency code argument'); + throw new ArgumentsRequired (this.id + ' fetchDeposits() requires a currency code argument'); } await this.loadMarkets (); const currency = this.currency (code); @@ -910,7 +917,7 @@ module.exports = class coinex extends Exchange { 'tonce': nonce.toString (), }, query); query = this.keysort (query); - const urlencoded = this.urlencode (query); + const urlencoded = this.rawencode (query); const signature = this.hash (this.encode (urlencoded + '&secret_key=' + this.secret)); headers = { 'Authorization': signature.toUpperCase (), diff --git a/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/coinfalcon.js b/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/coinfalcon.js index 563a4c987..6c264b4ec 100644 --- a/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/coinfalcon.js +++ b/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/coinfalcon.js @@ -217,7 +217,7 @@ module.exports = class coinfalcon extends Exchange { async fetchMyTrades (symbol = undefined, since = undefined, limit = undefined, params = {}) { if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' fetchMyTrades requires a symbol argument'); + throw new ArgumentsRequired (this.id + ' fetchMyTrades() requires a symbol argument'); } await this.loadMarkets (); const market = this.market (symbol); @@ -320,6 +320,7 @@ module.exports = class coinfalcon extends Exchange { type = type[0]; } const side = this.safeString (order, 'order_type'); + const postOnly = this.safeValue (order, 'post_only'); return { 'id': this.safeString (order, 'id'), 'clientOrderId': undefined, @@ -329,6 +330,7 @@ module.exports = class coinfalcon extends Exchange { 'symbol': symbol, 'type': type, 'timeInForce': undefined, + 'postOnly': postOnly, 'side': side, 'price': price, 'stopPrice': undefined, diff --git a/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/coinfloor.js b/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/coinfloor.js index 5d59bdf98..7fff650de 100644 --- a/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/coinfloor.js +++ b/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/coinfloor.js @@ -27,7 +27,7 @@ module.exports = class coinfloor extends Exchange { }, 'urls': { 'logo': 'https://user-images.githubusercontent.com/51840849/87153925-ef265e80-c2c0-11ea-91b5-020c804b90e0.jpg', - 'api': 'https://webapi.coinfloor.co.uk/bist', + 'api': 'https://webapi.coinfloor.co.uk/v2/bist', 'www': 'https://www.coinfloor.co.uk', 'doc': [ 'https://github.com/coinfloor/api', @@ -90,7 +90,7 @@ module.exports = class coinfloor extends Exchange { market = this.markets_by_id[marketId]; } if (market === undefined) { - throw new ArgumentsRequired (this.id + ' fetchBalance requires a symbol param'); + throw new ArgumentsRequired (this.id + ' fetchBalance() requires a symbol param'); } const request = { 'id': market['id'], @@ -223,7 +223,7 @@ module.exports = class coinfloor extends Exchange { if (code !== undefined) { market = this.market (code); if (market === undefined) { - throw new ArgumentsRequired (this.id + ' fetchTransactions requires a code argument (a market symbol)'); + throw new ArgumentsRequired (this.id + ' fetchTransactions() requires a code argument (a market symbol)'); } } const request = { @@ -431,7 +431,7 @@ module.exports = class coinfloor extends Exchange { async cancelOrder (id, symbol = undefined, params = {}) { if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' cancelOrder requires a symbol argument'); + throw new ArgumentsRequired (this.id + ' cancelOrder() requires a symbol argument'); } await this.loadMarkets (); const market = this.market (symbol); @@ -480,6 +480,7 @@ module.exports = class coinfloor extends Exchange { 'symbol': symbol, 'type': 'limit', 'timeInForce': undefined, + 'postOnly': undefined, 'side': side, 'price': price, 'stopPrice': undefined, @@ -495,7 +496,7 @@ module.exports = class coinfloor extends Exchange { async fetchOpenOrders (symbol = undefined, since = undefined, limit = undefined, params = {}) { if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' fetchOpenOrders requires a symbol param'); + throw new ArgumentsRequired (this.id + ' fetchOpenOrders() requires a symbol param'); } await this.loadMarkets (); const market = this.market (symbol); diff --git a/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/coinmarketcap.js b/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/coinmarketcap.js index 3d983cc88..171a65889 100644 --- a/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/coinmarketcap.js +++ b/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/coinmarketcap.js @@ -150,6 +150,8 @@ module.exports = class coinmarketcap extends Exchange { // https://github.com/ccxt/ccxt/issues/6081 // https://github.com/ccxt/ccxt/issues/3365 // https://github.com/ccxt/ccxt/issues/2873 + 'SBTCT': 'SiamBitcoin', // conflict with sBTC + 'Super Bitcoin': 'Super Bitcoin', // conflict with sBTC 'TerraCredit': 'TerraCredit', // conflict with CREDIT (PROXI) 'Themis': 'Themis', // conflict with GET (Guaranteed Entrance Token, GET Protocol) 'UNI COIN': 'UNI COIN', // conflict with UNI (Uniswap) diff --git a/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/coinmate.js b/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/coinmate.js index 844bc0011..b03ce8783 100644 --- a/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/coinmate.js +++ b/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/coinmate.js @@ -529,7 +529,7 @@ module.exports = class coinmate extends Exchange { async fetchOrders (symbol = undefined, since = undefined, limit = undefined, params = {}) { if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' fetchOrders requires a symbol argument'); + throw new ArgumentsRequired (this.id + ' fetchOrders() requires a symbol argument'); } await this.loadMarkets (); const market = this.market (symbol); @@ -641,6 +641,7 @@ module.exports = class coinmate extends Exchange { 'symbol': symbol, 'type': type, 'timeInForce': undefined, + 'postOnly': undefined, 'side': side, 'price': price, 'stopPrice': stopPrice, diff --git a/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/coinone.js b/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/coinone.js index eb14695fa..0c86365b6 100644 --- a/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/coinone.js +++ b/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/coinone.js @@ -373,7 +373,7 @@ module.exports = class coinone extends Exchange { async fetchOrder (id, symbol = undefined, params = {}) { if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' fetchOrder requires a symbol argument'); + throw new ArgumentsRequired (this.id + ' fetchOrder() requires a symbol argument'); } await this.loadMarkets (); const market = this.market (symbol); @@ -518,6 +518,7 @@ module.exports = class coinone extends Exchange { 'symbol': symbol, 'type': 'limit', 'timeInForce': undefined, + 'postOnly': undefined, 'side': side, 'price': price, 'stopPrice': undefined, @@ -567,7 +568,7 @@ module.exports = class coinone extends Exchange { async fetchMyTrades (symbol = undefined, since = undefined, limit = undefined, params = {}) { if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' fetchMyTrades requires a symbol argument'); + throw new ArgumentsRequired (this.id + ' fetchMyTrades() requires a symbol argument'); } await this.loadMarkets (); const market = this.market (symbol); @@ -602,14 +603,14 @@ module.exports = class coinone extends Exchange { async cancelOrder (id, symbol = undefined, params = {}) { if (symbol === undefined) { // eslint-disable-next-line quotes - throw new ArgumentsRequired (this.id + " cancelOrder requires a symbol argument. To cancel the order, pass a symbol argument and {'price': 12345, 'qty': 1.2345, 'is_ask': 0} in the params argument of cancelOrder."); + throw new ArgumentsRequired (this.id + " cancelOrder() requires a symbol argument. To cancel the order, pass a symbol argument and {'price': 12345, 'qty': 1.2345, 'is_ask': 0} in the params argument of cancelOrder."); } const price = this.safeFloat (params, 'price'); const qty = this.safeFloat (params, 'qty'); const isAsk = this.safeInteger (params, 'is_ask'); if ((price === undefined) || (qty === undefined) || (isAsk === undefined)) { // eslint-disable-next-line quotes - throw new ArgumentsRequired (this.id + " cancelOrder requires {'price': 12345, 'qty': 1.2345, 'is_ask': 0} in the params argument."); + throw new ArgumentsRequired (this.id + " cancelOrder() requires {'price': 12345, 'qty': 1.2345, 'is_ask': 0} in the params argument."); } await this.loadMarkets (); const request = { diff --git a/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/coinspot.js b/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/coinspot.js index 2da1a5ee7..e04c42b5d 100644 --- a/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/coinspot.js +++ b/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/coinspot.js @@ -3,7 +3,7 @@ // --------------------------------------------------------------------------- const Exchange = require ('./base/Exchange'); -const { ExchangeError, AuthenticationError, NotSupported } = require ('./base/errors'); +const { ExchangeError, ArgumentsRequired, AuthenticationError } = require ('./base/errors'); // --------------------------------------------------------------------------- @@ -70,27 +70,72 @@ module.exports = class coinspot extends Exchange { }, 'markets': { 'BTC/AUD': { 'id': 'btc', 'symbol': 'BTC/AUD', 'base': 'BTC', 'quote': 'AUD', 'baseId': 'btc', 'quoteId': 'aud' }, + 'ETH/AUD': { 'id': 'eth', 'symbol': 'ETH/AUD', 'base': 'ETH', 'quote': 'AUD', 'baseId': 'eth', 'quoteId': 'aud' }, + 'XRP/AUD': { 'id': 'xrp', 'symbol': 'XRP/AUD', 'base': 'XRP', 'quote': 'AUD', 'baseId': 'xrp', 'quoteId': 'aud' }, 'LTC/AUD': { 'id': 'ltc', 'symbol': 'LTC/AUD', 'base': 'LTC', 'quote': 'AUD', 'baseId': 'ltc', 'quoteId': 'aud' }, 'DOGE/AUD': { 'id': 'doge', 'symbol': 'DOGE/AUD', 'base': 'DOGE', 'quote': 'AUD', 'baseId': 'doge', 'quoteId': 'aud' }, + 'RFOX/AUD': { 'id': 'rfox', 'symbol': 'RFOX/AUD', 'base': 'RFOX', 'quote': 'AUD', 'baseId': 'rfox', 'quoteId': 'aud' }, + 'POWR/AUD': { 'id': 'powr', 'symbol': 'POWR/AUD', 'base': 'POWR', 'quote': 'AUD', 'baseId': 'powr', 'quoteId': 'aud' }, + 'NEO/AUD': { 'id': 'neo', 'symbol': 'NEO/AUD', 'base': 'NEO', 'quote': 'AUD', 'baseId': 'neo', 'quoteId': 'aud' }, + 'TRX/AUD': { 'id': 'trx', 'symbol': 'TRX/AUD', 'base': 'TRX', 'quote': 'AUD', 'baseId': 'trx', 'quoteId': 'aud' }, + 'EOS/AUD': { 'id': 'eos', 'symbol': 'EOS/AUD', 'base': 'EOS', 'quote': 'AUD', 'baseId': 'eos', 'quoteId': 'aud' }, + 'XLM/AUD': { 'id': 'xlm', 'symbol': 'XLM/AUD', 'base': 'XLM', 'quote': 'AUD', 'baseId': 'xlm', 'quoteId': 'aud' }, + 'RHOC/AUD': { 'id': 'rhoc', 'symbol': 'RHOC/AUD', 'base': 'RHOC', 'quote': 'AUD', 'baseId': 'rhoc', 'quoteId': 'aud' }, + 'GAS/AUD': { 'id': 'gas', 'symbol': 'GAS/AUD', 'base': 'GAS', 'quote': 'AUD', 'baseId': 'gas', 'quoteId': 'aud' }, }, 'commonCurrencies': { 'DRK': 'DASH', }, + 'options': { + 'fetchBalance': 'private_post_my_balances', + }, }); } async fetchBalance (params = {}) { await this.loadMarkets (); - const response = await this.privatePostMyBalances (params); + const method = this.safeString (this.options, 'fetchBalance', 'private_post_my_balances'); + const response = await this[method] (params); + // + // read-write api keys + // + // ... + // + // read-only api keys + // + // { + // "status":"ok", + // "balances":[ + // { + // "LTC":{"balance":0.1,"audbalance":16.59,"rate":165.95} + // } + // ] + // } + // const result = { 'info': response }; - const balances = this.safeValue (response, 'balance', {}); - const currencyIds = Object.keys (balances); - for (let i = 0; i < currencyIds.length; i++) { - const currencyId = currencyIds[i]; - const code = this.safeCurrencyCode (currencyId); - const account = this.account (); - account['total'] = this.safeFloat (balances, currencyId); - result[code] = account; + const balances = this.safeValue2 (response, 'balance', 'balances'); + if (Array.isArray (balances)) { + for (let i = 0; i < balances.length; i++) { + const currencies = balances[i]; + const currencyIds = Object.keys (currencies); + for (let j = 0; j < currencyIds.length; j++) { + const currencyId = currencyIds[j]; + const balance = currencies[currencyId]; + const code = this.safeCurrencyCode (currencyId); + const account = this.account (); + account['total'] = this.safeFloat (balance, 'balance'); + result[code] = account; + } + } + } else { + const currencyIds = Object.keys (balances); + for (let i = 0; i < currencyIds.length; i++) { + const currencyId = currencyIds[i]; + const code = this.safeCurrencyCode (currencyId); + const account = this.account (); + account['total'] = this.safeFloat (balances, currencyId); + result[code] = account; + } } return this.parseBalance (result); } @@ -210,9 +255,16 @@ module.exports = class coinspot extends Exchange { } async cancelOrder (id, symbol = undefined, params = {}) { - throw new NotSupported (this.id + ' cancelOrder () is not fully implemented yet'); - // let method = 'privatePostMyBuy'; - // return await this[method] ({ 'id': id }); + const side = this.safeString (params, 'side'); + if (side !== 'buy' && side !== 'sell') { + throw new ArgumentsRequired (this.id + ' cancelOrder() requires a side parameter, "buy" or "sell"'); + } + params = this.omit (params, 'side'); + const method = 'privatePostMy' + this.capitalize (side) + 'Cancel'; + const request = { + 'id': id, + }; + return await this[method] (this.extend (request, params)); } sign (path, api = 'public', method = 'GET', params = {}, headers = undefined, body = undefined) { diff --git a/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/crex24.js b/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/crex24.js index 5ea3e826c..7c1298090 100644 --- a/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/crex24.js +++ b/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/crex24.js @@ -133,6 +133,7 @@ module.exports = class crex24 extends Exchange { 'GHOST': 'GHOSTPRISM', 'IQ': 'IQ.Cash', 'PUT': 'PutinCoin', + 'SBTC': 'SBTCT', // SiamBitcoin 'UNI': 'Universe', 'YOYO': 'YOYOW', }, @@ -158,6 +159,7 @@ module.exports = class crex24 extends Exchange { "Parameter 'instrument' contains invalid value.": BadSymbol, }, 'broad': { + 'try again later': ExchangeNotAvailable, // {"errorDescription":"Failed to process the request. Please, try again later."} 'API Key': AuthenticationError, // "API Key '9edc48de-d5b0-4248-8e7e-f59ffcd1c7f1' doesn't exist." 'Insufficient funds': InsufficientFunds, // "Insufficient funds: new order requires 10 ETH which is more than the available balance." 'has been delisted.': BadSymbol, // {"errorDescription":"Instrument '$PAC-BTC' has been delisted."} @@ -757,14 +759,14 @@ module.exports = class crex24 extends Exchange { } if (priceIsRequired) { if (price === undefined) { - throw new InvalidOrder (this.id + ' createOrder method requires a price argument for a ' + type + ' order'); + throw new InvalidOrder (this.id + ' createOrder() requires a price argument for a ' + type + ' order'); } request['price'] = this.priceToPrecision (symbol, price); } if (stopPriceIsRequired) { const stopPrice = this.safeFloat (params, 'stopPrice'); if (stopPrice === undefined) { - throw new InvalidOrder (this.id + ' createOrder method requires a stopPrice extra param for a ' + type + ' order'); + throw new InvalidOrder (this.id + ' createOrder() requires a stopPrice extra param for a ' + type + ' order'); } else { request['stopPrice'] = this.priceToPrecision (symbol, stopPrice); } diff --git a/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/currencycom.js b/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/currencycom.js index 3914c1bfc..c8570f1d4 100644 --- a/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/currencycom.js +++ b/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/currencycom.js @@ -916,7 +916,7 @@ module.exports = class currencycom extends Exchange { if (market['margin']) { accountId = this.safeInteger (params, 'accountId'); if (accountId === undefined) { - throw new ArgumentsRequired (this.id + ' createOrder requires an accountId parameter for ' + market['type'] + ' market ' + symbol); + throw new ArgumentsRequired (this.id + ' createOrder() requires an accountId parameter for ' + market['type'] + ' market ' + symbol); } } const uppercaseType = type.toUpperCase (); @@ -977,7 +977,7 @@ module.exports = class currencycom extends Exchange { const symbols = this.symbols; const numSymbols = symbols.length; const fetchOpenOrdersRateLimit = parseInt (numSymbols / 2); - throw new ExchangeError (this.id + ' fetchOpenOrders WARNING: fetching open orders without specifying a symbol is rate-limited to one call per ' + fetchOpenOrdersRateLimit.toString () + ' seconds. Do not call this method frequently to avoid ban. Set ' + this.id + '.options["warnOnFetchOpenOrdersWithoutSymbol"] = false to suppress this warning message.'); + throw new ExchangeError (this.id + ' fetchOpenOrders() WARNING: fetching open orders without specifying a symbol is rate-limited to one call per ' + fetchOpenOrdersRateLimit.toString () + ' seconds. Do not call this method frequently to avoid ban. Set ' + this.id + '.options["warnOnFetchOpenOrdersWithoutSymbol"] = false to suppress this warning message.'); } const response = await this.privateGetOpenOrders (this.extend (request, params)); return this.parseOrders (response, market, since, limit); @@ -985,7 +985,7 @@ module.exports = class currencycom extends Exchange { async cancelOrder (id, symbol = undefined, params = {}) { if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' cancelOrder requires a symbol argument'); + throw new ArgumentsRequired (this.id + ' cancelOrder() requires a symbol argument'); } await this.loadMarkets (); const market = this.market (symbol); @@ -1020,7 +1020,7 @@ module.exports = class currencycom extends Exchange { async fetchMyTrades (symbol = undefined, since = undefined, limit = undefined, params = {}) { if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' fetchMyTrades requires a symbol argument'); + throw new ArgumentsRequired (this.id + ' fetchMyTrades() requires a symbol argument'); } await this.loadMarkets (); const market = this.market (symbol); diff --git a/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/delta.js b/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/delta.js new file mode 100644 index 000000000..9b3c559bf --- /dev/null +++ b/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/delta.js @@ -0,0 +1,1483 @@ +'use strict'; + +// --------------------------------------------------------------------------- + +const Exchange = require ('./base/Exchange'); +const { ExchangeError, InsufficientFunds, BadRequest, BadSymbol, InvalidOrder, AuthenticationError, ArgumentsRequired, OrderNotFound, ExchangeNotAvailable } = require ('./base/errors'); +const { TICK_SIZE } = require ('./base/functions/number'); + +// --------------------------------------------------------------------------- + +module.exports = class delta extends Exchange { + describe () { + return this.deepExtend (super.describe (), { + 'id': 'delta', + 'name': 'Delta Exchange', + 'countries': [ 'VC' ], // Saint Vincent and the Grenadines + 'rateLimit': 300, + 'version': 'v2', + // new metainfo interface + 'has': { + 'cancelAllOrders': true, + 'cancelOrder': true, + 'createOrder': true, + 'editOrder': true, + 'fetchBalance': true, + 'fetchClosedOrders': true, + 'fetchDepositAddress': true, + 'fetchCurrencies': true, + 'fetchLedger': true, + 'fetchMarkets': true, + 'fetchMyTrades': true, + 'fetchOHLCV': true, + 'fetchOpenOrders': true, + 'fetchOrderBook': true, + 'fetchStatus': true, + 'fetchTicker': true, + 'fetchTickers': true, + 'fetchTime': true, + 'fetchTrades': true, + }, + 'timeframes': { + '1m': '1m', + '3m': '3m', + '5m': '5m', + '15m': '15m', + '30m': '30m', + '1h': '1h', + '2h': '2h', + '4h': '4h', + '6h': '6h', + '1d': '1d', + '7d': '7d', + '1w': '1w', + '2w': '2w', + '1M': '30d', + }, + 'urls': { + 'logo': 'https://user-images.githubusercontent.com/1294454/99450025-3be60a00-2931-11eb-9302-f4fd8d8589aa.jpg', + 'test': { + 'public': 'https://testnet-api.delta.exchange', + 'private': 'https://testnet-api.delta.exchange', + }, + 'api': { + 'public': 'https://api.delta.exchange', + 'private': 'https://api.delta.exchange', + }, + 'www': 'https://www.delta.exchange', + 'doc': [ + 'https://docs.delta.exchange', + ], + 'fees': 'https://www.delta.exchange/fees', + 'referral': 'https://www.delta.exchange/app/signup/?code=IULYNB', + }, + 'api': { + 'public': { + 'get': [ + 'assets', + 'settings', + 'indices', + 'products', + 'tickers', + 'tickers/{symbol}', + 'l2orderbook/{symbol}', + 'trades/{symbol}', + 'history/candles', + 'history/sparklines', + ], + }, + 'private': { + 'get': [ + 'orders', + 'orders/leverage', + 'positions', + 'positions/margined', + 'orders/history', + 'fills', + 'fills/history/download/csv', + 'wallet/balances', + 'wallet/transactions', + 'wallet/transactions/download', + 'deposits/address', + ], + 'post': [ + 'orders', + 'orders/batch', + 'orders/leverage', + 'positions/change_margin', + ], + 'put': [ + 'orders', + 'orders/batch', + ], + 'delete': [ + 'orders', + 'orders/all', + 'orders/batch', + ], + }, + }, + 'fees': { + 'trading': { + 'tierBased': true, + 'percentage': true, + 'taker': 0.15 / 100, + 'maker': 0.10 / 100, + 'tiers': { + 'taker': [ + [0, 0.15 / 100], + [100, 0.13 / 100], + [250, 0.13 / 100], + [1000, 0.1 / 100], + [5000, 0.09 / 100], + [10000, 0.075 / 100], + [20000, 0.065 / 100], + ], + 'maker': [ + [0, 0.1 / 100], + [100, 0.1 / 100], + [250, 0.09 / 100], + [1000, 0.075 / 100], + [5000, 0.06 / 100], + [10000, 0.05 / 100], + [20000, 0.05 / 100], + ], + }, + }, + }, + 'precisionMode': TICK_SIZE, + 'requiredCredentials': { + 'apiKey': true, + 'secret': false, + }, + 'exceptions': { + 'exact': { + // Margin required to place order with selected leverage and quantity is insufficient. + 'insufficient_margin': InsufficientFunds, // {"error":{"code":"insufficient_margin","context":{"available_balance":"0.000000000000000000","required_additional_balance":"1.618626000000000000000000000"}},"success":false} + 'order_size_exceed_available': InvalidOrder, // The order book doesn't have sufficient liquidity, hence the order couldnt be filled, for example, ioc orders + 'risk_limits_breached': BadRequest, // orders couldn't be placed as it will breach allowed risk limits. + 'invalid_contract': BadSymbol, // The contract/product is either doesn't exist or has already expired. + 'immediate_liquidation': InvalidOrder, // Order will cause immediate liquidation. + 'out_of_bankruptcy': InvalidOrder, // Order prices are out of position bankruptcy limits. + 'self_matching_disrupted_post_only': InvalidOrder, // Self matching is not allowed during auction. + 'immediate_execution_post_only': InvalidOrder, // orders couldn't be placed as it includes post only orders which will be immediately executed + 'bad_schema': BadRequest, // {"error":{"code":"bad_schema","context":{"schema_errors":[{"code":"validation_error","message":"id is required","param":""}]}},"success":false} + 'invalid_api_key': AuthenticationError, // {"success":false,"error":{"code":"invalid_api_key"}} + 'invalid_signature': AuthenticationError, // {"success":false,"error":{"code":"invalid_signature"}} + 'open_order_not_found': OrderNotFound, // {"error":{"code":"open_order_not_found"},"success":false} + 'unavailable': ExchangeNotAvailable, // {"error":{"code":"unavailable"},"success":false} + }, + 'broad': { + }, + }, + }); + } + + async fetchTime (params = {}) { + const response = await this.publicGetSettings (params); + // + // { + // "result":{ + // "server_time":1605472733766141, + // "deto_referral_mining_daily_reward":"25000", + // "deto_total_reward_pool":"100000000", + // "deto_trade_mining_daily_reward":"75000", + // "kyc_deposit_limit":"20", + // "kyc_withdrawal_limit":"2", + // "under_maintenance":"false" + // }, + // "success":true + // } + // + const result = this.safeValue (response, 'result', {}); + return this.safeIntegerProduct (result, 'server_time', 0.001); + } + + async fetchStatus (params = {}) { + const response = await this.publicGetSettings (params); + const result = this.safeValue (response, 'result', {}); + const underMaintenance = this.safeValue (result, 'under_maintenance'); + const status = (underMaintenance === 'true') ? 'maintenance' : 'ok'; + const updated = this.safeIntegerProduct (result, 'server_time', 0.001); + this.status = this.extend (this.status, { + 'status': status, + 'updated': updated, + }); + return this.status; + } + + async fetchCurrencies (params = {}) { + const response = await this.publicGetAssets (params); + // + // { + // "result":[ + // { + // "base_withdrawal_fee":"0.0005", + // "deposit_status":"enabled", + // "id":2, + // "interest_credit":true, + // "interest_slabs":[ + // {"limit":"0.1","rate":"0"}, + // {"limit":"1","rate":"0.05"}, + // {"limit":"5","rate":"0.075"}, + // {"limit":"10","rate":"0.1"}, + // {"limit":"9999999999999999","rate":"0"} + // ], + // "kyc_deposit_limit":"10", + // "kyc_withdrawal_limit":"2", + // "min_withdrawal_amount":"0.001", + // "minimum_precision":4, + // "name":"Bitcoin", + // "precision":8, + // "sort_priority":1, + // "symbol":"BTC", + // "variable_withdrawal_fee":"0", + // "withdrawal_status":"enabled" + // }, + // ], + // "success":true + // } + // + const currencies = this.safeValue (response, 'result', []); + const result = {}; + for (let i = 0; i < currencies.length; i++) { + const currency = currencies[i]; + const id = this.safeString (currency, 'symbol'); + const numericId = this.safeInteger (currency, 'id'); + const code = this.safeCurrencyCode (id); + const depositStatus = this.safeString (currency, 'deposit_status'); + const withdrawalStatus = this.safeString (currency, 'withdrawal_status'); + const depositsEnabled = (depositStatus === 'enabled'); + const withdrawalsEnabled = (withdrawalStatus === 'enabled'); + const active = depositsEnabled && withdrawalsEnabled; + const precision = this.safeInteger (currency, 'precision'); + result[code] = { + 'id': id, + 'numericId': numericId, + 'code': code, + 'name': this.safeString (currency, 'name'), + 'info': currency, // the original payload + 'active': active, + 'fee': this.safeFloat (currency, 'base_withdrawal_fee'), + 'precision': 1 / Math.pow (10, precision), + 'limits': { + 'amount': { 'min': undefined, 'max': undefined }, + 'price': { 'min': undefined, 'max': undefined }, + 'cost': { 'min': undefined, 'max': undefined }, + 'withdraw': { + 'min': this.safeFloat (currency, 'min_withdrawal_amount'), + 'max': undefined, + }, + }, + }; + } + return result; + } + + async loadMarkets (reload = false, params = {}) { + const markets = await super.loadMarkets (reload, params); + const currenciesByNumericId = this.safeValue (this.options, 'currenciesByNumericId'); + if ((currenciesByNumericId === undefined) || reload) { + this.options['currenciesByNumericId'] = this.indexBy (this.currencies, 'numericId'); + } + const marketsByNumericId = this.safeValue (this.options, 'marketsByNumericId'); + if ((marketsByNumericId === undefined) || reload) { + this.options['marketsByNumericId'] = this.indexBy (this.markets, 'numericId'); + } + return markets; + } + + async fetchMarkets (params = {}) { + const response = await this.publicGetProducts (params); + // + // { + // "meta":{ + // "after":null, + // "before":null, + // "limit":100, + // "total_count":81 + // }, + // "result":[ + // { + // "annualized_funding":"5.475000000000000000", + // "is_quanto":false, + // "ui_config":{ + // "default_trading_view_candle":"15", + // "leverage_slider_values":[1,3,5,10,25,50], + // "price_clubbing_values":[0.001,0.005,0.05,0.1,0.5,1,5], + // "show_bracket_orders":false, + // "sort_priority":29, + // "tags":[] + // }, + // "basis_factor_max_limit":"0.15", + // "symbol":"P-LINK-D-151120", + // "id":1584, + // "default_leverage":"5.000000000000000000", + // "maker_commission_rate":"0.0005", + // "contract_unit_currency":"LINK", + // "strike_price":"12.507948", + // "settling_asset":{ + // // asset structure + // }, + // "auction_start_time":null, + // "auction_finish_time":null, + // "settlement_time":"2020-11-15T12:00:00Z", + // "launch_time":"2020-11-14T11:55:05Z", + // "spot_index":{ + // // index structure + // }, + // "trading_status":"operational", + // "tick_size":"0.001", + // "position_size_limit":100000, + // "notional_type":"vanilla", // vanilla, inverse + // "price_band":"0.4", + // "barrier_price":null, + // "description":"Daily LINK PUT options quoted in USDT and settled in USDT", + // "insurance_fund_margin_contribution":"1", + // "quoting_asset":{ + // // asset structure + // }, + // "liquidation_penalty_factor":"0.2", + // "product_specs":{"max_volatility":3,"min_volatility":0.3,"spot_price_band":"0.40"}, + // "initial_margin_scaling_factor":"0.0001", + // "underlying_asset":{ + // // asset structure + // }, + // "state":"live", + // "contract_value":"1", + // "initial_margin":"2", + // "impact_size":5000, + // "settlement_price":null, + // "contract_type":"put_options", // put_options, call_options, move_options, perpetual_futures, interest_rate_swaps, futures, spreads + // "taker_commission_rate":"0.0005", + // "maintenance_margin":"1", + // "short_description":"LINK Daily PUT Options", + // "maintenance_margin_scaling_factor":"0.00005", + // "funding_method":"mark_price", + // "max_leverage_notional":"20000" + // }, + // ], + // "success":true + // } + // + const markets = this.safeValue (response, 'result', []); + const result = []; + for (let i = 0; i < markets.length; i++) { + const market = markets[i]; + let type = this.safeString (market, 'contract_type'); + // const settlingAsset = this.safeValue (market, 'settling_asset', {}); + const quotingAsset = this.safeValue (market, 'quoting_asset', {}); + const underlyingAsset = this.safeValue (market, 'underlying_asset', {}); + const baseId = this.safeString (underlyingAsset, 'symbol'); + const quoteId = this.safeString (quotingAsset, 'symbol'); + const id = this.safeString (market, 'symbol'); + const numericId = this.safeInteger (market, 'id'); + const base = this.safeCurrencyCode (baseId); + const quote = this.safeCurrencyCode (quoteId); + let symbol = id; + let swap = false; + let future = false; + let option = false; + if (type === 'perpetual_futures') { + type = 'swap'; + swap = true; + future = false; + option = false; + if (id.indexOf ('_') < 0) { + symbol = base + '/' + quote; + } + } else if ((type === 'call_options') || (type === 'put_options') || (type === 'move_options')) { + type = 'option'; + swap = false; + option = true; + future = false; + } else if (type === 'futures') { + type = 'future'; + swap = false; + option = false; + future = true; + } + const precision = { + 'amount': 1.0, // number of contracts + 'price': this.safeFloat (market, 'tick_size'), + }; + const limits = { + 'amount': { + 'min': 1.0, + 'max': this.safeFloat (market, 'position_size_limit'), + }, + 'price': { + 'min': precision['price'], + 'max': undefined, + }, + 'cost': { + 'min': this.safeFloat (market, 'min_size'), + 'max': undefined, + }, + }; + const state = this.safeString (market, 'state'); + const active = (state === 'live'); + const maker = this.safeFloat (market, 'maker_commission_rate'); + const taker = this.safeFloat (market, 'taker_commission_rate'); + result.push ({ + 'id': id, + 'numericId': numericId, + 'symbol': symbol, + 'base': base, + 'quote': quote, + 'baseId': baseId, + 'quoteId': quoteId, + 'type': type, + 'option': option, + 'swap': swap, + 'future': future, + 'maker': maker, + 'taker': taker, + 'precision': precision, + 'limits': limits, + 'info': market, + 'active': active, + }); + } + return result; + } + + parseTicker (ticker, market = undefined) { + // + // fetchTicker, fetchTickers + // + // { + // "close":15837.5, + // "high":16354, + // "low":15751.5, + // "mark_price":"15820.100867", + // "open":16140.5, + // "product_id":139, + // "size":640552, + // "spot_price":"15827.050000000001", + // "symbol":"BTCUSDT", + // "timestamp":1605373550208262, + // "turnover":10298630.3735, + // "turnover_symbol":"USDT", + // "turnover_usd":10298630.3735, + // "volume":640.5520000000001 + // } + // + const timestamp = this.safeIntegerProduct (ticker, 'timestamp', 0.001); + const marketId = this.safeString (ticker, 'symbol'); + const symbol = this.safeSymbol (marketId, market); + const last = this.safeFloat (ticker, 'close'); + const open = this.safeFloat (ticker, 'open'); + let change = undefined; + let average = undefined; + let percentage = undefined; + if ((open !== undefined) && (last !== undefined)) { + change = last - open; + average = this.sum (last, open) / 2; + if (open !== 0.0) { + percentage = (change / open) * 100; + } + } + const baseVolume = this.safeFloat (ticker, 'volume'); + const quoteVolume = this.safeFloat (ticker, 'turnover'); + const vwap = this.vwap (baseVolume, quoteVolume); + return { + 'symbol': symbol, + 'timestamp': timestamp, + 'datetime': this.iso8601 (timestamp), + 'high': this.safeFloat (ticker, 'high'), + 'low': this.safeFloat (ticker, 'low'), + 'bid': undefined, + 'bidVolume': undefined, + 'ask': undefined, + 'askVolume': undefined, + 'vwap': vwap, + 'open': open, + 'close': last, + 'last': last, + 'previousClose': undefined, + 'change': change, + 'percentage': percentage, + 'average': average, + 'baseVolume': baseVolume, + 'quoteVolume': quoteVolume, + 'info': ticker, + }; + } + + async fetchTicker (symbol, params = {}) { + await this.loadMarkets (); + const market = this.market (symbol); + const request = { + 'symbol': market['id'], + }; + const response = await this.publicGetTickersSymbol (this.extend (request, params)); + // + // { + // "result":{ + // "close":15837.5, + // "high":16354, + // "low":15751.5, + // "mark_price":"15820.100867", + // "open":16140.5, + // "product_id":139, + // "size":640552, + // "spot_price":"15827.050000000001", + // "symbol":"BTCUSDT", + // "timestamp":1605373550208262, + // "turnover":10298630.3735, + // "turnover_symbol":"USDT", + // "turnover_usd":10298630.3735, + // "volume":640.5520000000001 + // }, + // "success":true + // } + // + const result = this.safeValue (response, 'result', {}); + return this.parseTicker (result, market); + } + + async fetchTickers (symbols = undefined, params = {}) { + await this.loadMarkets (); + const response = await this.publicGetTickers (params); + // + // { + // "result":[ + // { + // "close":0.003966, + // "high":0.004032, + // "low":0.003606, + // "mark_price":"0.00396328", + // "open":0.003996, + // "product_id":1327, + // "size":6242, + // "spot_price":"0.0039555", + // "symbol":"AAVEBTC", + // "timestamp":1605374143864107, + // "turnover":23.997904999999996, + // "turnover_symbol":"BTC", + // "turnover_usd":387957.4544782897, + // "volume":6242 + // }, + // ], + // "success":true + // } + // + const tickers = this.safeValue (response, 'result', []); + const result = {}; + for (let i = 0; i < tickers.length; i++) { + const ticker = this.parseTicker (tickers[i]); + const symbol = ticker['symbol']; + result[symbol] = ticker; + } + return this.filterByArray (result, 'symbol', symbols); + } + + async fetchOrderBook (symbol, limit = undefined, params = {}) { + await this.loadMarkets (); + const request = { + 'symbol': this.marketId (symbol), + }; + if (limit !== undefined) { + request['depth'] = limit; + } + const response = await this.publicGetL2orderbookSymbol (this.extend (request, params)); + // + // { + // "result":{ + // "buy":[ + // {"price":"15814.0","size":912}, + // {"price":"15813.5","size":1279}, + // {"price":"15813.0","size":1634}, + // ], + // "sell":[ + // {"price":"15814.5","size":625}, + // {"price":"15815.0","size":982}, + // {"price":"15815.5","size":1328}, + // ], + // "symbol":"BTCUSDT" + // }, + // "success":true + // } + // + const result = this.safeValue (response, 'result', {}); + return this.parseOrderBook (result, undefined, 'buy', 'sell', 'price', 'size'); + } + + parseTrade (trade, market = undefined) { + // + // public fetchTrades + // + // { + // "buyer_role":"maker", + // "price":"15896.5", + // "seller_role":"taker", + // "size":241, + // "symbol":"BTCUSDT", + // "timestamp":1605376684714595 + // } + // + // private fetchMyTrades + // + // { + // "commission":"0.008335000000000000", + // "created_at":"2020-11-16T19:07:19Z", + // "fill_type":"normal", + // "id":"e7ff05c233a74245b72381f8dd91d1ce", + // "meta_data":{ + // "effective_commission_rate":"0.0005", + // "order_price":"16249", + // "order_size":1, + // "order_type":"market_order", + // "order_unfilled_size":0, + // "trading_fee_credits_used":"0" + // }, + // "order_id":"152999629", + // "price":"16669", + // "product":{ + // "contract_type":"perpetual_futures", + // "contract_unit_currency":"BTC", + // "contract_value":"0.001", + // "id":139, + // "notional_type":"vanilla", + // "quoting_asset":{"minimum_precision":2,"precision":6,"symbol":"USDT"}, + // "settling_asset":{"minimum_precision":2,"precision":6,"symbol":"USDT"}, + // "symbol":"BTCUSDT", + // "tick_size":"0.5", + // "underlying_asset":{"minimum_precision":4,"precision":8,"symbol":"BTC"} + // }, + // "product_id":139, + // "role":"taker", + // "side":"sell", + // "size":1 + // } + // + const id = this.safeString (trade, 'id'); + const orderId = this.safeString (trade, 'order_id'); + let timestamp = this.parse8601 (this.safeString (trade, 'created_at')); + timestamp = this.safeIntegerProduct (trade, 'timestamp', 0.001, timestamp); + const price = this.safeFloat (trade, 'price'); + const amount = this.safeFloat (trade, 'size'); + let cost = undefined; + if ((amount !== undefined) && (price !== undefined)) { + cost = amount * price; + } + const product = this.safeValue (trade, 'product', {}); + const marketId = this.safeString (product, 'symbol'); + const symbol = this.safeSymbol (marketId, market); + const sellerRole = this.safeString (trade, 'seller_role'); + let side = this.safeString (trade, 'side'); + if (side === undefined) { + if (sellerRole === 'taker') { + side = 'sell'; + } else if (sellerRole === 'maker') { + side = 'buy'; + } + } + const takerOrMaker = this.safeString (trade, 'role'); + const metaData = this.safeValue (trade, 'meta_data', {}); + let type = this.safeString (metaData, 'order_type'); + if (type !== undefined) { + type = type.replace ('_order', ''); + } + const feeCost = this.safeFloat (trade, 'commission'); + let fee = undefined; + if (feeCost !== undefined) { + const settlingAsset = this.safeValue (product, 'settling_asset', {}); + const feeCurrencyId = this.safeString (settlingAsset, 'symbol'); + const feeCurrencyCode = this.safeCurrencyCode (feeCurrencyId); + fee = { + 'cost': feeCost, + 'currency': feeCurrencyCode, + }; + } + return { + 'id': id, + 'order': orderId, + 'timestamp': timestamp, + 'datetime': this.iso8601 (timestamp), + 'symbol': symbol, + 'type': type, + 'side': side, + 'price': price, + 'amount': amount, + 'cost': cost, + 'takerOrMaker': takerOrMaker, + 'fee': fee, + 'info': trade, + }; + } + + async fetchTrades (symbol, since = undefined, limit = undefined, params = {}) { + await this.loadMarkets (); + const market = this.market (symbol); + const request = { + 'symbol': market['id'], + }; + const response = await this.publicGetTradesSymbol (this.extend (request, params)); + // + // { + // "result":[ + // { + // "buyer_role":"maker", + // "price":"15896.5", + // "seller_role":"taker", + // "size":241, + // "symbol":"BTCUSDT", + // "timestamp":1605376684714595 + // } + // ], + // "success":true + // } + // + const result = this.safeValue (response, 'result', []); + return this.parseTrades (result, market, since, limit); + } + + parseOHLCV (ohlcv, market = undefined) { + // + // { + // "time":1605393120, + // "open":15989, + // "high":15989, + // "low":15987.5, + // "close":15987.5, + // "volume":565 + // } + // + return [ + this.safeTimestamp (ohlcv, 'time'), + this.safeFloat (ohlcv, 'open'), + this.safeFloat (ohlcv, 'high'), + this.safeFloat (ohlcv, 'low'), + this.safeFloat (ohlcv, 'close'), + this.safeFloat (ohlcv, 'volume'), + ]; + } + + async fetchOHLCV (symbol, timeframe = '1m', since = undefined, limit = undefined, params = {}) { + await this.loadMarkets (); + const market = this.market (symbol); + const request = { + 'symbol': market['id'], + 'resolution': this.timeframes[timeframe], + }; + const duration = this.parseTimeframe (timeframe); + limit = limit ? limit : 2000; // max 2000 + if (since === undefined) { + const end = this.seconds (); + request['end'] = end; + request['start'] = end - limit * duration; + } else { + const start = parseInt (since / 1000); + request['start'] = start; + request['end'] = this.sum (start, limit * duration); + } + const response = await this.publicGetHistoryCandles (this.extend (request, params)); + // + // { + // "success":true, + // "result":[ + // {"time":1605393120,"open":15989,"high":15989,"low":15987.5,"close":15987.5,"volume":565}, + // {"time":1605393180,"open":15966,"high":15966,"low":15959,"close":15959,"volume":24}, + // {"time":1605393300,"open":15973,"high":15973,"low":15973,"close":15973,"volume":1288}, + // ] + // } + // + const result = this.safeValue (response, 'result', []); + return this.parseOHLCVs (result, market, timeframe, since, limit); + } + + async fetchBalance (params = {}) { + await this.loadMarkets (); + const response = await this.privateGetWalletBalances (params); + // + // { + // "result":[ + // { + // "asset_id":1, + // "available_balance":"0", + // "balance":"0", + // "commission":"0", + // "id":154883, + // "interest_credit":"0", + // "order_margin":"0", + // "pending_referral_bonus":"0", + // "pending_trading_fee_credit":"0", + // "position_margin":"0", + // "trading_fee_credit":"0", + // "user_id":22142 + // }, + // ], + // "success":true + // } + // + const balances = this.safeValue (response, 'result', []); + const result = { 'info': response }; + const currenciesByNumericId = this.safeValue (this.options, 'currenciesByNumericId', {}); + for (let i = 0; i < balances.length; i++) { + const balance = balances[i]; + const currencyId = this.safeString (balance, 'asset_id'); + const currency = this.safeValue (currenciesByNumericId, currencyId); + const code = (currency === undefined) ? currencyId : currency['code']; + const account = this.account (); + account['total'] = this.safeFloat (balance, 'balance'); + account['free'] = this.safeFloat (balance, 'available_balance'); + result[code] = account; + } + return this.parseBalance (result); + } + + async fetchPosition (symbol, params = undefined) { + await this.loadMarkets (); + const market = this.market (symbol); + const request = { + 'product_id': market['numericId'], + }; + const response = await this.privateGetPositions (this.extend (request, params)); + // + // { + // "result":{ + // "entry_price":null, + // "size":0, + // "timestamp":1605454074268079 + // }, + // "success":true + // } + // + const result = this.safeValue (response, 'result', {}); + return result; + } + + async fetchPositions (symbols = undefined, since = undefined, limit = undefined, params = {}) { + await this.loadMarkets (); + const response = await this.privateGetPositionsMargined (params); + // + // { + // "success": true, + // "result": [ + // { + // "user_id": 0, + // "size": 0, + // "entry_price": "string", + // "margin": "string", + // "liquidation_price": "string", + // "bankruptcy_price": "string", + // "adl_level": 0, + // "product_id": 0 + // } + // ] + // } + // + const result = this.safeValue (response, 'result', []); + return result; + } + + parseOrderStatus (status) { + const statuses = { + 'open': 'open', + 'pending': 'open', + 'closed': 'closed', + 'cancelled': 'canceled', + }; + return this.safeString (statuses, status, status); + } + + parseOrder (order, market = undefined) { + // + // createOrder, cancelOrder, editOrder, fetchOpenOrders, fetchClosedOrders + // + // { + // "average_fill_price":null, + // "bracket_order":null, + // "bracket_stop_loss_limit_price":null, + // "bracket_stop_loss_price":null, + // "bracket_take_profit_limit_price":null, + // "bracket_take_profit_price":null, + // "bracket_trail_amount":null, + // "cancellation_reason":null, + // "client_order_id":null, + // "close_on_trigger":"false", + // "commission":"0", + // "created_at":"2020-11-16T02:38:26Z", + // "id":152870626, + // "limit_price":"10000", + // "meta_data":{"source":"api"}, + // "order_type":"limit_order", + // "paid_commission":"0", + // "product_id":139, + // "reduce_only":false, + // "side":"buy", + // "size":0, + // "state":"open", + // "stop_order_type":null, + // "stop_price":null, + // "stop_trigger_method":"mark_price", + // "time_in_force":"gtc", + // "trail_amount":null, + // "unfilled_size":0, + // "user_id":22142 + // } + // + const id = this.safeString (order, 'id'); + const clientOrderId = this.safeString (order, 'client_order_id'); + const timestamp = this.parse8601 (this.safeString (order, 'created_at')); + const marketId = this.safeString (order, 'product_id'); + const marketsByNumericId = this.safeValue (this.options, 'marketsByNumericId', {}); + market = this.safeValue (marketsByNumericId, marketId, market); + const symbol = (market === undefined) ? marketId : market['symbol']; + const status = this.parseOrderStatus (this.safeString (order, 'state')); + const side = this.safeString (order, 'side'); + let type = this.safeString (order, 'order_type'); + type = type.replace ('_order', ''); + const price = this.safeFloat (order, 'limit_price'); + const amount = this.safeFloat (order, 'size'); + const remaining = this.safeFloat (order, 'unfilled_size'); + let filled = undefined; + if ((amount !== undefined) && (remaining !== undefined)) { + filled = Math.max (0, amount - remaining); + } + let cost = undefined; + const average = this.safeFloat (order, 'average_fill_price'); + if ((average !== undefined) && filled) { + cost = average * filled; + } + let fee = undefined; + const feeCost = this.safeFloat (order, 'paid_commission'); + if (feeCost !== undefined) { + let feeCurrencyCode = undefined; + if (market !== undefined) { + const settlingAsset = this.safeValue (market['info'], 'settling_asset', {}); + const feeCurrencyId = this.safeString (settlingAsset, 'symbol'); + feeCurrencyCode = this.safeCurrencyCode (feeCurrencyId); + } + fee = { + 'cost': feeCost, + 'currency': feeCurrencyCode, + }; + } + return { + 'info': order, + 'id': id, + 'clientOrderId': clientOrderId, + 'timestamp': timestamp, + 'datetime': this.iso8601 (timestamp), + 'lastTradeTimestamp': undefined, + 'symbol': symbol, + 'type': type, + 'side': side, + 'price': price, + 'amount': amount, + 'cost': cost, + 'average': average, + 'filled': filled, + 'remaining': remaining, + 'status': status, + 'fee': fee, + 'trades': undefined, + }; + } + + async createOrder (symbol, type, side, amount, price = undefined, params = {}) { + await this.loadMarkets (); + const orderType = type + '_order'; + const market = this.market (symbol); + const request = { + 'product_id': market['numericId'], + // 'limit_price': this.priceToPrecision (symbol, price), + 'size': this.amountToPrecision (symbol, amount), + 'side': side, + 'order_type': orderType, + // 'client_order_id': 'string', + // 'time_in_force': 'gtc', // gtc, ioc, fok + // 'post_only': 'false', // 'true', + // 'reduce_only': 'false', // 'true', + }; + if (type === 'limit') { + request['limit_price'] = this.priceToPrecision (symbol, price); + } + const clientOrderId = this.safeString2 (params, 'clientOrderId', 'client_order_id'); + params = this.omit (params, [ 'clientOrderId', 'client_order_id' ]); + if (clientOrderId !== undefined) { + request['client_order_id'] = clientOrderId; + } + const response = await this.privatePostOrders (this.extend (request, params)); + // + // { + // "result":{ + // "average_fill_price":null, + // "bracket_order":null, + // "bracket_stop_loss_limit_price":null, + // "bracket_stop_loss_price":null, + // "bracket_take_profit_limit_price":null, + // "bracket_take_profit_price":null, + // "bracket_trail_amount":null, + // "cancellation_reason":null, + // "client_order_id":null, + // "close_on_trigger":"false", + // "commission":"0", + // "created_at":"2020-11-16T02:38:26Z", + // "id":152870626, + // "limit_price":"10000", + // "meta_data":{"source":"api"}, + // "order_type":"limit_order", + // "paid_commission":"0", + // "product_id":139, + // "reduce_only":false, + // "side":"buy", + // "size":0, + // "state":"open", + // "stop_order_type":null, + // "stop_price":null, + // "stop_trigger_method":"mark_price", + // "time_in_force":"gtc", + // "trail_amount":null, + // "unfilled_size":0, + // "user_id":22142 + // }, + // "success":true + // } + // + const result = this.safeValue (response, 'result', {}); + return this.parseOrder (result, market); + } + + async editOrder (id, symbol, type, side, amount, price = undefined, params = {}) { + await this.loadMarkets (); + const market = this.market (symbol); + const request = { + 'id': parseInt (id), + 'product_id': market['numericId'], + // 'limit_price': this.priceToPrecision (symbol, price), + // 'size': this.amountToPrecision (symbol, amount), + }; + if (amount !== undefined) { + request['size'] = parseInt (this.amountToPrecision (symbol, amount)); + } + if (price !== undefined) { + request['limit_price'] = this.priceToPrecision (symbol, price); + } + const response = await this.privatePutOrders (this.extend (request, params)); + // + // { + // "success": true, + // "result": { + // "id": "ashb1212", + // "product_id": 27, + // "limit_price": "9200", + // "side": "buy", + // "size": 100, + // "unfilled_size": 50, + // "user_id": 1, + // "order_type": "limit_order", + // "state": "open", + // "created_at": "..." + // } + // } + // + const result = this.safeValue (response, 'result'); + return this.parseOrder (result, market); + } + + async cancelOrder (id, symbol = undefined, params = {}) { + if (symbol === undefined) { + throw new ArgumentsRequired (this.id + ' cancelOrder() requires a symbol argument'); + } + await this.loadMarkets (); + const market = this.market (symbol); + const request = { + 'id': parseInt (id), + 'product_id': market['numericId'], + }; + const response = await this.privateDeleteOrders (this.extend (request, params)); + // + // { + // "result":{ + // "average_fill_price":null, + // "bracket_order":null, + // "bracket_stop_loss_limit_price":null, + // "bracket_stop_loss_price":null, + // "bracket_take_profit_limit_price":null, + // "bracket_take_profit_price":null, + // "bracket_trail_amount":null, + // "cancellation_reason":"cancelled_by_user", + // "client_order_id":null, + // "close_on_trigger":"false", + // "commission":"0", + // "created_at":"2020-11-16T02:38:26Z", + // "id":152870626, + // "limit_price":"10000", + // "meta_data":{"source":"api"}, + // "order_type":"limit_order", + // "paid_commission":"0", + // "product_id":139, + // "reduce_only":false, + // "side":"buy", + // "size":0, + // "state":"cancelled", + // "stop_order_type":null, + // "stop_price":null, + // "stop_trigger_method":"mark_price", + // "time_in_force":"gtc", + // "trail_amount":null, + // "unfilled_size":0, + // "user_id":22142 + // }, + // "success":true + // } + // + const result = this.safeValue (response, 'result'); + return this.parseOrder (result, market); + } + + async cancelAllOrders (symbol = undefined, params = {}) { + if (symbol === undefined) { + throw new ArgumentsRequired (this.id + ' cancelAllOrders() requires a symbol argument'); + } + await this.loadMarkets (); + const market = this.market (symbol); + const request = { + 'product_id': market['numericId'], + // 'cancel_limit_orders': 'true', + // 'cancel_stop_orders': 'true', + }; + const response = this.privateDeleteOrdersAll (this.extend (request, params)); + // + // { + // "result":{}, + // "success":true + // } + // + return response; + } + + async fetchOpenOrders (symbol = undefined, since = undefined, limit = undefined, params = {}) { + return await this.fetchOrdersWithMethod ('privateGetOrders', symbol, since, limit, params); + } + + async fetchClosedOrders (symbol = undefined, since = undefined, limit = undefined, params = {}) { + return await this.fetchOrdersWithMethod ('privateGetOrdersHistory', symbol, since, limit, params); + } + + async fetchOrdersWithMethod (method, symbol = undefined, since = undefined, limit = undefined, params = {}) { + await this.loadMarkets (); + const request = { + // 'product_ids': market['id'], // comma-separated + // 'contract_types': types, // comma-separated, futures, perpetual_futures, call_options, put_options, interest_rate_swaps, move_options, spreads + // 'order_types': types, // comma-separated, market, limit, stop_market, stop_limit, all_stop + // 'start_time': since * 1000, + // 'end_time': this.microseconds (), + // 'after': string, // after cursor for pagination + // 'before': string, // before cursor for pagination + // 'page_size': limit, // number of records per page + }; + let market = undefined; + if (symbol !== undefined) { + market = this.market (symbol); + request['product_ids'] = market['numericId']; // accepts a comma-separated list of ids + } + if (since !== undefined) { + request['start_time'] = since.toString () + '000'; + } + if (limit !== undefined) { + request['page_size'] = limit; + } + const response = await this[method] (this.extend (request, params)); + // + // { + // "success": true, + // "result": [ + // { + // "id": "ashb1212", + // "product_id": 27, + // "limit_price": "9200", + // "side": "buy", + // "size": 100, + // "unfilled_size": 50, + // "user_id": 1, + // "order_type": "limit_order", + // "state": "open", + // "created_at": "..." + // } + // ], + // "meta": { + // "after": "string", + // "before": "string" + // } + // } + // + const result = this.safeValue (response, 'result', []); + return this.parseOrders (result, market, since, limit); + } + + async fetchMyTrades (symbol = undefined, since = undefined, limit = undefined, params = {}) { + await this.loadMarkets (); + const request = { + // 'product_ids': market['id'], // comma-separated + // 'contract_types': types, // comma-separated, futures, perpetual_futures, call_options, put_options, interest_rate_swaps, move_options, spreads + // 'start_time': since * 1000, + // 'end_time': this.microseconds (), + // 'after': string, // after cursor for pagination + // 'before': string, // before cursor for pagination + // 'page_size': limit, // number of records per page + }; + let market = undefined; + if (symbol !== undefined) { + market = this.market (symbol); + request['product_ids'] = market['numericId']; // accepts a comma-separated list of ids + } + if (since !== undefined) { + request['start_time'] = since.toString () + '000'; + } + if (limit !== undefined) { + request['page_size'] = limit; + } + const response = await this.privateGetFills (this.extend (request, params)); + // + // { + // "meta":{ + // "after":null, + // "before":null, + // "limit":10, + // "total_count":2 + // }, + // "result":[ + // { + // "commission":"0.008335000000000000", + // "created_at":"2020-11-16T19:07:19Z", + // "fill_type":"normal", + // "id":"e7ff05c233a74245b72381f8dd91d1ce", + // "meta_data":{ + // "effective_commission_rate":"0.0005", + // "order_price":"16249", + // "order_size":1, + // "order_type":"market_order", + // "order_unfilled_size":0, + // "trading_fee_credits_used":"0" + // }, + // "order_id":"152999629", + // "price":"16669", + // "product":{ + // "contract_type":"perpetual_futures", + // "contract_unit_currency":"BTC", + // "contract_value":"0.001", + // "id":139, + // "notional_type":"vanilla", + // "quoting_asset":{"minimum_precision":2,"precision":6,"symbol":"USDT"}, + // "settling_asset":{"minimum_precision":2,"precision":6,"symbol":"USDT"}, + // "symbol":"BTCUSDT", + // "tick_size":"0.5", + // "underlying_asset":{"minimum_precision":4,"precision":8,"symbol":"BTC"} + // }, + // "product_id":139, + // "role":"taker", + // "side":"sell", + // "size":1 + // } + // ], + // "success":true + // } + // + const result = this.safeValue (response, 'result', []); + return this.parseTrades (result, market, since, limit); + } + + async fetchLedger (code = undefined, since = undefined, limit = undefined, params = {}) { + await this.loadMarkets (); + const request = { + // 'asset_id': currency['numericId'], + // 'end_time': this.seconds (), + // 'after': 'string', // after cursor for pagination + // 'before': 'string', // before cursor for pagination + // 'page_size': limit, + }; + let currency = undefined; + if (code !== undefined) { + currency = this.currency (code); + request['asset_id'] = currency['numericId']; + } + if (limit !== undefined) { + request['page_size'] = limit; + } + const response = await this.privateGetWalletTransactions (this.extend (request, params)); + // + // { + // "meta":{"after":null,"before":null,"limit":10,"total_count":1}, + // "result":[ + // { + // "amount":"29.889184", + // "asset_id":5, + // "balance":"29.889184", + // "created_at":"2020-11-15T21:25:01Z", + // "meta_data":{ + // "deposit_id":3884, + // "transaction_id":"0x41a60174849828530abb5008e98fc63c9b598288743ec4ba9620bcce900a3b8d" + // }, + // "transaction_type":"deposit", + // "user_id":22142, + // "uuid":"70bb5679da3c4637884e2dc63efaa846" + // } + // ], + // "success":true + // } + // + const result = this.safeValue (response, 'result', []); + return this.parseLedger (result, currency, since, limit); + } + + parseLedgerEntryType (type) { + const types = { + 'pnl': 'pnl', + 'deposit': 'transaction', + 'withdrawal': 'transaction', + 'commission': 'fee', + 'conversion': 'trade', + // 'perpetual_futures_funding': 'perpetual_futures_funding', + // 'withdrawal_cancellation': 'withdrawal_cancellation', + 'referral_bonus': 'referral', + 'commission_rebate': 'rebate', + // 'promo_credit': 'promo_credit', + }; + return this.safeString (types, type, type); + } + + parseLedgerEntry (item, currency = undefined) { + // + // { + // "amount":"29.889184", + // "asset_id":5, + // "balance":"29.889184", + // "created_at":"2020-11-15T21:25:01Z", + // "meta_data":{ + // "deposit_id":3884, + // "transaction_id":"0x41a60174849828530abb5008e98fc63c9b598288743ec4ba9620bcce900a3b8d" + // }, + // "transaction_type":"deposit", + // "user_id":22142, + // "uuid":"70bb5679da3c4637884e2dc63efaa846" + // } + // + const id = this.safeString (item, 'uuid'); + let direction = undefined; + const account = undefined; + const metaData = this.safeValue (item, 'meta_data', {}); + const referenceId = this.safeString (metaData, 'transaction_id'); + const referenceAccount = undefined; + let type = this.safeString (item, 'transaction_type'); + if ((type === 'deposit') || (type === 'commission_rebate') || (type === 'referral_bonus') || (type === 'pnl') || (type === 'withdrawal_cancellation') || (type === 'promo_credit')) { + direction = 'in'; + } else if ((type === 'withdrawal') || (type === 'commission') || (type === 'conversion') || (type === 'perpetual_futures_funding')) { + direction = 'out'; + } + type = this.parseLedgerEntryType (type); + const currencyId = this.safeInteger (item, 'asset_id'); + const currenciesByNumericId = this.safeValue (this.options, 'currenciesByNumericId'); + currency = this.safeValue (currenciesByNumericId, currencyId, currency); + const code = (currency === undefined) ? undefined : currency['code']; + const amount = this.safeFloat (item, 'amount'); + const timestamp = this.parse8601 (this.safeString (item, 'created_at')); + const after = this.safeFloat (item, 'balance'); + const before = Math.max (0, after - amount); + const status = 'ok'; + return { + 'info': item, + 'id': id, + 'direction': direction, + 'account': account, + 'referenceId': referenceId, + 'referenceAccount': referenceAccount, + 'type': type, + 'currency': code, + 'amount': amount, + 'before': before, + 'after': after, + 'status': status, + 'timestamp': timestamp, + 'datetime': this.iso8601 (timestamp), + 'fee': undefined, + }; + } + + async fetchDepositAddress (code, params = {}) { + await this.loadMarkets (); + const currency = this.currency (code); + const request = { + 'asset_symbol': currency['id'], + }; + const response = await this.privateGetDepositsAddress (this.extend (request, params)); + // + // { + // "success":true, + // "result":{ + // "id":19628, + // "user_id":22142, + // "address":"0x0eda26523397534f814d553a065d8e46b4188e9a", + // "status":"active", + // "updated_at":"2020-11-15T20:25:53.000Z", + // "created_at":"2020-11-15T20:25:53.000Z", + // "asset_symbol":"USDT", + // "custodian":"onc" + // } + // } + // + const result = this.safeValue (response, 'result', {}); + const address = this.safeString (result, 'address'); + this.checkAddress (address); + return { + 'currency': code, + 'address': address, + 'tag': undefined, + 'info': response, + }; + } + + sign (path, api = 'public', method = 'GET', params = {}, headers = undefined, body = undefined) { + const requestPath = '/' + this.version + '/' + this.implodeParams (path, params); + let url = this.urls['api'][api] + requestPath; + const query = this.omit (params, this.extractParams (path)); + if (api === 'public') { + if (Object.keys (query).length) { + url += '?' + this.urlencode (query); + } + } else if (api === 'private') { + this.checkRequiredCredentials (); + const timestamp = this.seconds ().toString (); + headers = { + 'api-key': this.apiKey, + 'timestamp': timestamp, + }; + let auth = method + timestamp + requestPath; + if ((method === 'GET') || (method === 'DELETE')) { + if (Object.keys (query).length) { + const queryString = '?' + this.urlencode (query); + auth += queryString; + url += queryString; + } + } else { + body = this.json (query); + auth += body; + headers['Content-Type'] = 'application/json'; + } + const signature = this.hmac (this.encode (auth), this.encode (this.secret)); + headers['signature'] = signature; + } + return { 'url': url, 'method': method, 'body': body, 'headers': headers }; + } + + handleErrors (code, reason, url, method, headers, body, response, requestHeaders, requestBody) { + if (response === undefined) { + return; + } + // + // {"error":{"code":"insufficient_margin","context":{"available_balance":"0.000000000000000000","required_additional_balance":"1.618626000000000000000000000"}},"success":false} + // + const error = this.safeValue (response, 'error', {}); + const errorCode = this.safeString (error, 'code'); + if (errorCode !== undefined) { + const feedback = this.id + ' ' + body; + this.throwExactlyMatchedException (this.exceptions['exact'], errorCode, feedback); + this.throwBroadlyMatchedException (this.exceptions['broad'], errorCode, feedback); + throw new ExchangeError (feedback); // unknown message + } + } +}; diff --git a/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/deribit.js b/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/deribit.js index 9f88f869b..f277c3975 100644 --- a/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/deribit.js +++ b/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/deribit.js @@ -778,7 +778,7 @@ module.exports = class deribit extends Exchange { const now = this.milliseconds (); if (since === undefined) { if (limit === undefined) { - throw new ArgumentsRequired (this.id + ' fetchOHLCV requires a since argument or a limit argument'); + throw new ArgumentsRequired (this.id + ' fetchOHLCV() requires a since argument or a limit argument'); } else { request['start_timestamp'] = now - (limit - 1) * duration * 1000; request['end_timestamp'] = now; @@ -1011,7 +1011,7 @@ module.exports = class deribit extends Exchange { 'cancelled': 'canceled', 'filled': 'closed', 'rejected': 'rejected', - // 'untriggered': 'open', + 'untriggered': 'open', }; return this.safeString (statuses, status, status); } @@ -1096,7 +1096,8 @@ module.exports = class deribit extends Exchange { trades = this.parseTrades (trades, market); } const timeInForce = this.parseTimeInForce (this.safeString (order, 'time_in_force')); - const stopPrice = undefined; + const stopPrice = this.safeValue (order, 'stop_price'); + const postOnly = this.safeValue (order, 'post_only'); return { 'info': order, 'id': id, @@ -1107,6 +1108,7 @@ module.exports = class deribit extends Exchange { 'symbol': market['symbol'], 'type': type, 'timeInForce': timeInForce, + 'postOnly': postOnly, 'side': side, 'price': price, 'stopPrice': stopPrice, @@ -1191,13 +1193,13 @@ module.exports = class deribit extends Exchange { if (price !== undefined) { request['price'] = this.priceToPrecision (symbol, price); } else { - throw new ArgumentsRequired (this.id + ' createOrder requires a price argument for a ' + type + ' order'); + throw new ArgumentsRequired (this.id + ' createOrder() requires a price argument for a ' + type + ' order'); } } if (stopPriceIsRequired) { const stopPrice = this.safeFloat2 (params, 'stop_price', 'stopPrice'); if (stopPrice === undefined) { - throw new ArgumentsRequired (this.id + ' createOrder requires a stop_price or stopPrice param for a ' + type + ' order'); + throw new ArgumentsRequired (this.id + ' createOrder() requires a stop_price or stopPrice param for a ' + type + ' order'); } else { request['stop_price'] = this.priceToPrecision (symbol, stopPrice); } @@ -1266,10 +1268,10 @@ module.exports = class deribit extends Exchange { async editOrder (id, symbol, type, side, amount = undefined, price = undefined, params = {}) { if (amount === undefined) { - throw new ArgumentsRequired (this.id + ' editOrder requires an amount argument'); + throw new ArgumentsRequired (this.id + ' editOrder() requires an amount argument'); } if (price === undefined) { - throw new ArgumentsRequired (this.id + ' editOrder requires a price argument'); + throw new ArgumentsRequired (this.id + ' editOrder() requires a price argument'); } await this.loadMarkets (); const request = { @@ -1631,7 +1633,7 @@ module.exports = class deribit extends Exchange { const request = { 'instrument_name': market['id'], }; - const response = await this.privateGetPosition (this.extend (request, params)); + const response = await this.privateGetGetPosition (this.extend (request, params)); // // { // "jsonrpc": "2.0", @@ -1670,7 +1672,7 @@ module.exports = class deribit extends Exchange { const request = { 'currency': currency['id'], }; - const response = await this.privateGetPositions (this.extend (request, params)); + const response = await this.privateGetGetPositions (this.extend (request, params)); // // { // "jsonrpc": "2.0", diff --git a/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/digifinex.js b/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/digifinex.js index 25a9fcabb..6584b919c 100644 --- a/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/digifinex.js +++ b/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/digifinex.js @@ -502,7 +502,7 @@ module.exports = class digifinex extends Exchange { async fetchTickers (symbols = undefined, params = {}) { const apiKey = this.safeValue (params, 'apiKey', this.apiKey); if (!apiKey) { - throw new ArgumentsRequired (this.id + ' fetchTicker is a private v2 endpoint that requires an `exchange.apiKey` credential or an `apiKey` extra parameter'); + throw new ArgumentsRequired (this.id + ' fetchTickers() is a private v2 endpoint that requires an `exchange.apiKey` credential or an `apiKey` extra parameter'); } await this.loadMarkets (); const request = { @@ -548,7 +548,7 @@ module.exports = class digifinex extends Exchange { async fetchTicker (symbol, params = {}) { const apiKey = this.safeValue (params, 'apiKey', this.apiKey); if (!apiKey) { - throw new ArgumentsRequired (this.id + ' fetchTicker is a private v2 endpoint that requires an `exchange.apiKey` credential or an `apiKey` extra parameter'); + throw new ArgumentsRequired (this.id + ' fetchTicker() is a private v2 endpoint that requires an `exchange.apiKey` credential or an `apiKey` extra parameter'); } await this.loadMarkets (); const market = this.market (symbol); @@ -994,6 +994,7 @@ module.exports = class digifinex extends Exchange { 'symbol': symbol, 'type': type, 'timeInForce': undefined, + 'postOnly': undefined, 'side': side, 'price': price, 'stopPrice': undefined, @@ -1284,7 +1285,7 @@ module.exports = class digifinex extends Exchange { const address = this.safeString (depositAddress, 'address'); const tag = this.safeString (depositAddress, 'addressTag'); const currencyId = this.safeStringUpper (depositAddress, 'currency'); - const code = this.safeCurrencCode (currencyId); + const code = this.safeCurrencyCode (currencyId); return { 'info': depositAddress, 'code': code, diff --git a/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/dsx.js b/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/dsx.js index cff6ab255..349fc2489 100644 --- a/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/dsx.js +++ b/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/dsx.js @@ -653,7 +653,7 @@ module.exports = class dsx extends Exchange { await this.loadMarkets (); const market = this.market (symbol); if (type === 'market' && price === undefined) { - throw new ArgumentsRequired (this.id + ' createOrder requires a price argument even for market orders, that is the worst price that you agree to fill your order for'); + throw new ArgumentsRequired (this.id + ' createOrder() requires a price argument even for market orders, that is the worst price that you agree to fill your order for'); } const request = { 'pair': market['id'], @@ -840,6 +840,7 @@ module.exports = class dsx extends Exchange { 'lastTradeTimestamp': lastTradeTimestamp, 'type': orderType, 'timeInForce': undefined, + 'postOnly': undefined, 'side': side, 'price': price, 'stopPrice': undefined, diff --git a/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/equos.js b/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/equos.js new file mode 100644 index 000000000..5dc44a2ac --- /dev/null +++ b/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/equos.js @@ -0,0 +1,1548 @@ +'use strict'; + +// ---------------------------------------------------------------------------- + +const Exchange = require ('./base/Exchange'); +const { ExchangeError, ArgumentsRequired, BadSymbol } = require ('./base/errors'); + +// ---------------------------------------------------------------------------- + +module.exports = class equos extends Exchange { + describe () { + return this.deepExtend (super.describe (), { + 'id': 'equos', + 'name': 'EQUOS', + 'countries': [ 'US', 'SG' ], // United States, Singapore + 'rateLimit': 10, + 'has': { + 'CORS': false, + 'cancelOrder': true, + 'createOrder': true, + 'editOrder': true, + 'fetchBalance': true, + 'fetchCanceledOrders': true, + 'fetchClosedOrders': true, + 'fetchCurrencies': true, + 'fetchDepositAddress': true, + 'fetchDeposits': true, + 'fetchMarkets': true, + 'fetchMyTrades': true, + 'fetchOHLCV': true, + 'fetchOrder': true, + 'fetchOrderBook': true, + 'fetchOrders': true, + 'fetchTicker': false, + 'fetchTrades': true, + 'fetchTradingFees': true, + 'fetchWithdrawals': true, + 'withdraw': true, + }, + 'timeframes': { + '1m': 1, + '5m': 2, + '15m': 3, + '1h': 4, + '6h': 5, + '1d': 6, + '7d': 7, + }, + 'urls': { + 'logo': 'https://user-images.githubusercontent.com/1294454/107758499-05edd180-6d38-11eb-9e09-0b69602a7a15.jpg', + 'test': { + 'public': 'https://testnet.equos.io/api', + 'private': 'https://testnet.equos.io/api', + }, + 'api': { + 'public': 'https://equos.io/api', + 'private': 'https://equos.io/api', + }, + 'www': 'https://equos.io', + 'doc': [ + 'https://developer.equos.io', + ], + 'referral': 'https://equos.io?referredByCode=zpa8kij4ouvBFup3', + }, + 'api': { + 'public': { + 'get': [ + 'health', + 'getInstruments', + 'getInstrumentPairs', + 'getOrderBook', + 'getRisk', + 'getTradeHistory', + 'getFundingRateHistory', + 'getChart', + 'getExchangeInfo', // not documented + ], + }, + 'private': { + 'post': [ + 'logon', + 'order', + 'cancelOrder', + 'cancelReplaceOrder', + 'getOrder', + 'getOrders', + 'getOrderStatus', + 'getOrderHistory', + 'userTrades', + 'getPositions', + 'cancelAll', + 'getUserHistory', + 'getRisk', + 'getDepositAddresses', + 'getDepositHistory', // not documented + 'getWithdrawRequests', + 'sendWithdrawRequest', + 'getTransferHistory', + ], + }, + }, + 'requiredCredentials': { + 'apiKey': true, + 'secret': true, + 'uid': true, + }, + 'exceptions': { + 'broad': { + 'symbol not found': BadSymbol, + }, + }, + }); + } + + async fetchMarkets (params = {}) { + const request = { + 'verbose': true, + }; + const response = await this.publicGetGetInstrumentPairs (this.extend (request, params)); + // + // { + // "instrumentPairs":[ + // { + // "instrumentId":52, + // "symbol":"BTC/USDC", + // "quoteId":1, + // "baseId":3, + // "price_scale":2, + // "quantity_scale":6, + // "securityStatus":1, + // "securityDesc":"BTC/USDC", // "BTC/USDC[F]" + // "assetType":"PAIR", // "PERPETUAL_SWAP" + // "currency":"BTC", + // "contAmtCurr":"USDC", + // "settlCurrency":"USDC", + // "commCurrency":"USDC", + // "cfiCode":"XXXXXX", + // "securityExchange":"XXXX", + // "instrumentPricePrecision":2, + // "minPriceIncrement":1.0, + // "minPriceIncrementAmount":1.0, + // "roundLot":1, + // "minTradeVol":0.001000, + // "maxTradeVol":0.000000 + // // contracts onlye + // "qtyType":0, + // "contractMultiplier":1.0, + // "issueDate":1598608087000 + // }, + // ] + // } + // + const instrumentPairs = this.safeValue (response, 'instrumentPairs', []); + const markets = []; + for (let i = 0; i < instrumentPairs.length; i++) { + const market = this.parseMarket (instrumentPairs[i]); + markets.push (market); + } + return markets; + } + + parseMarket (market) { + // + // { + // "instrumentId":52, + // "symbol":"BTC/USDC", // "BTC/USDC[F]" + // "quoteId":1, + // "baseId":3, + // "price_scale":2, + // "quantity_scale":6, + // "securityStatus":1, + // "securityDesc":"BTC/USDC", // "BTC/USDC[F]" + // "assetType":"PAIR", // "PERPETUAL_SWAP" + // "currency":"BTC", + // "contAmtCurr":"USDC", + // "settlCurrency":"USDC", + // "commCurrency":"USDC", + // "cfiCode":"XXXXXX", + // "securityExchange":"XXXX", + // "instrumentPricePrecision":2, + // "minPriceIncrement":1.0, + // "minPriceIncrementAmount":1.0, + // "roundLot":1, + // "minTradeVol":0.001000, + // "maxTradeVol":0.000000 + // // contracts onlye + // "qtyType":0, + // "contractMultiplier":1.0, + // "issueDate":1598608087000 + // } + // + const id = this.safeString (market, 'instrumentId'); + const uppercaseId = this.safeString (market, 'symbol'); + const assetType = this.safeString (market, 'assetType'); + const spot = (assetType === 'PAIR'); + const swap = (assetType === 'PERPETUAL_SWAP'); + const type = swap ? 'swap' : 'spot'; + const baseId = this.safeString (market, 'currency'); + const quoteId = this.safeString (market, 'contAmtCurr'); + const base = this.safeCurrencyCode (baseId); + const quote = this.safeCurrencyCode (quoteId); + const symbol = swap ? uppercaseId : (base + '/' + quote); + const status = this.safeInteger (market, 'securityStatus'); + const active = (status === 1); + const precision = { + 'amount': this.safeInteger (market, 'quantity_scale'), + 'price': this.safeInteger (market, 'price_scale'), + }; + return { + 'id': id, + 'uppercaseId': uppercaseId, + 'symbol': symbol, + 'base': base, + 'quote': quote, + 'baseId': baseId, + 'quoteId': quoteId, + 'type': type, + 'spot': spot, + 'swap': swap, + 'active': active, + 'precision': precision, + 'limits': { + 'amount': { + 'min': this.safeFloat (market, 'minTradeVol'), + 'max': undefined, + }, + 'price': { + 'min': undefined, + 'max': undefined, + }, + 'cost': { + 'min': undefined, + 'max': undefined, + }, + }, + 'info': market, + }; + } + + async fetchCurrencies (params = {}) { + const response = await this.publicGetGetInstruments (params); + // + // { + // "instruments": [ + // [ + // 3, // id + // "BTC", // symbol + // 2, // price_scale + // 6, // amount_scale + // 1, // status + // 0, // withdraw_fee + // "BTC", // name + // true, // withdrawal_pct + // ], + // ] + // } + // + const currencies = {}; + const instruments = this.safeValue (response, 'instruments', []); + for (let i = 0; i < instruments.length; i++) { + const currency = this.parseCurrency (instruments[i]); + const code = currency['code']; + currencies[code] = currency; + } + return currencies; + } + + parseCurrency (currency) { + // + // [ + // 3, // 0 id + // "BTC", // 1 symbol + // 2, // 2 price_scale + // 6, // 3 amount_scale + // 1, // 4 status + // 0, // 5 withdraw_fee + // "BTC", // 6 name + // true, // 7 withdrawal_pct + // ], + // + const id = this.safeString (currency, 0); + const uppercaseId = this.safeString (currency, 1); + const code = this.safeCurrencyCode (uppercaseId); + const priceScale = this.safeInteger (currency, 2); + const amountScale = this.safeInteger (currency, 3); + const precision = Math.max (priceScale, amountScale); + const name = this.safeString (currency, 6); + const status = this.safeInteger (currency, 4); + const active = (status === 1); + const fee = this.safeFloat (currency, 5); // withdraw_fee + return { + 'id': id, + 'info': currency, + 'uppercaseId': uppercaseId, + 'code': code, + 'name': name, + 'precision': precision, + 'fee': fee, + 'active': active, + 'limits': { + 'amount': { + 'min': undefined, + 'max': undefined, + }, + 'price': { + 'min': undefined, + 'max': undefined, + }, + 'cost': { + 'min': undefined, + 'max': undefined, + }, + 'withdraw': { + 'min': undefined, + 'max': undefined, + }, + }, + }; + } + + async fetchOHLCV (symbol, timeframe = '1m', since = undefined, limit = undefined, params = {}) { + await this.loadMarkets (); + const market = this.market (symbol); + const request = { + 'pairId': parseInt (market['id']), + 'timespan': this.timeframes[timeframe], + }; + if (limit !== undefined) { + request['limit'] = limit; + } + const response = await this.publicGetGetChart (this.extend (request, params)); + // + // { + // "pairId":57, + // "t":1, + // "s":"ETH/BTC", + // "lastPx":44099, + // "lastQty":100000, + // "o":0.043831000000000016, + // "h":0.04427100000000002, + // "l":0.032000000000000015, + // "c":0.04409900000000002, + // "v":0.21267333000000016, + // "q":4.850000000000001, + // "chart":[ + // [1612519260000,44099,44099,44099,44099,0,441], + // [1612519200000,44099,44099,44099,44099,0,440], + // [1612519140000,44269,44271,44269,44271,0,439], + // ] + // } + // + const chart = this.safeValue (response, 'chart', []); + return this.parseOHLCVs (chart, market, timeframe, since, limit); + } + + parseOHLCV (ohlcv, market = undefined) { + // + // [ + // 1612519260000, // timestamp + // 44099, // open + // 44099, // high + // 44099, // low + // 44099, // close + // 0, // base volume + // 441, // seqNumber + // ] + // + const timestamp = this.safeInteger (ohlcv, 0); + const open = this.convertFromScale (ohlcv[1], market['precision']['price']); + const high = this.convertFromScale (ohlcv[2], market['precision']['price']); + const low = this.convertFromScale (ohlcv[3], market['precision']['price']); + const close = this.convertFromScale (ohlcv[4], market['precision']['price']); + const volume = this.convertFromScale (ohlcv[5], market['precision']['amount']); + // volume = ohlcv[5]; + return [timestamp, open, high, low, close, volume]; + } + + parseBidAsk (bidask, priceKey = 0, amountKey = 1, market = undefined) { + if (market === undefined) { + throw new ArgumentsRequired (this.id + ' parseBidAsk() requires a market argument'); + } + const price = this.safeFloat (bidask, priceKey); + const amount = this.safeFloat (bidask, amountKey); + return [ + this.convertFromScale (price, market['precision']['price']), + this.convertFromScale (amount, market['precision']['amount']), + ]; + } + + parseOrderBook (orderbook, timestamp = undefined, bidsKey = 'bids', asksKey = 'asks', priceKey = 0, amountKey = 1, market = undefined) { + const result = { + 'timestamp': timestamp, + 'datetime': this.iso8601 (timestamp), + 'nonce': undefined, + }; + const sides = [ bidsKey, asksKey ]; + for (let i = 0; i < sides.length; i++) { + const side = sides[i]; + const orders = []; + const bidasks = this.safeValue (orderbook, side); + for (let k = 0; k < bidasks.length; k++) { + orders.push (this.parseBidAsk (bidasks[k], priceKey, amountKey, market)); + } + result[side] = orders; + } + result[bidsKey] = this.sortBy (result[bidsKey], 0, true); + result[asksKey] = this.sortBy (result[asksKey], 0); + return result; + } + + async fetchOrderBook (symbol, limit = undefined, params = {}) { + await this.loadMarkets (); + const market = this.market (symbol); + const request = { + 'pairId': parseInt (market['id']), + }; + const response = await this.publicGetGetOrderBook (this.extend (request, params)); + // + // { + // "bids":[ + // [4000480,30000,1612644984667], + // [3999304,200000,1612644984667], + // [3998862,50000,1612644984667], + // ], + // "asks":[ + // [4001962,1790000,1612644984667], + // [4002616,1000,1612644984667], + // [4003889,1000,1612644984667], + // ], + // "usdMark":40011.02, + // "marketStatus":0, + // "estFundingRate":0.0, + // "fundingRateTime":0, + // "auctionPrice":0.0, + // "auctionVolume":0.0 + // } + // + return this.parseOrderBook (response, undefined, 'bids', 'asks', 0, 1, market); + } + + async fetchTrades (symbol, since = undefined, limit = undefined, params = {}) { + await this.loadMarkets (); + const market = this.market (symbol); + const request = { + 'pairId': parseInt (market['id']), + }; + const response = await this.publicGetGetTradeHistory (this.extend (request, params)); + // + // { + // "trades":[ + // [4022800,47000,"20210206-21:39:12.886",256323,1], + // [4023066,1000,"20210206-21:38:55.030",256322,1], + // [4022406,50000,"20210206-21:36:56.334",256321,1], + // ] + // } + // + const trades = this.safeValue (response, 'trades', []); + return this.parseTrades (trades, market, since, limit, params); + } + + parseTrade (trade, market = undefined) { + // + // public fetchTrades + // + // [ + // 4022800, // 0 price + // 47000, // 1 quantity + // "20210206-21:39:12.886", // 2 timestamp + // 256323, // 3 sequence number + // 1 // 4 taker side 1 = buy, 2 = sell + // ] + // + // private fetchMyTrades + // + // { + // "account":3583, + // "commission":"-0.015805", + // "commCurrency":"USDC", + // "execId":265757, + // "ordType":"2", + // "ordStatus":"2", + // "execType":"F", + // "aggressorIndicator":true, + // "orderId":388953019, + // "price":"1842.04", + // "qty":"0.010000", + // "lastPx":"1756.22", + // "avgPx":"1756.22", + // "cumQty":"0.010000", + // "quoteQty":"0.010000", + // "side":"BUY", + // "symbol":"ETH/USDC", + // "clOrdId":"1613106766970339107", + // "submitterId":3583, + // "targetStrategy":"0", + // "time":1613106766971, + // "date":"20210212-05:12:46.971" + // } + // + let id = undefined; + let timestamp = undefined; + let orderId = undefined; + let type = undefined; + let side = undefined; + let price = undefined; + let amount = undefined; + let cost = undefined; + let fee = undefined; + let symbol = undefined; + if (Array.isArray (trade)) { + id = this.safeString (trade, 3); + price = this.convertFromScale (this.safeInteger (trade, 0), market['precision']['price']); + amount = this.convertFromScale (this.safeInteger (trade, 1), market['precision']['amount']); + timestamp = this.toMilliseconds (this.safeString (trade, 2)); + const takerSide = this.safeInteger (trade, 4); + if (takerSide === 1) { + side = 'buy'; + } else if (takerSide === 2) { + side = 'sell'; + } + } else { + id = this.safeString (trade, 'execId'); + timestamp = this.safeInteger (trade, 'time'); + const marketId = this.safeString (trade, 'symbol'); + symbol = this.safeSymbol (marketId, market); + orderId = this.safeString (trade, 'orderId'); + side = this.safeStringLower (trade, 'side'); + type = this.parseOrderType (this.safeString (trade, 'ordType')); + price = this.safeFloat (trade, 'lastPx'); + amount = this.safeFloat (trade, 'quoteQty'); + let feeCost = this.safeFloat (trade, 'commission'); + if (feeCost !== undefined) { + feeCost = -feeCost; + const feeCurrencyId = this.safeString (trade, 'commCurrency'); + const feeCurrencyCode = this.safeCurrencyCode (feeCurrencyId); + fee = { + 'cost': feeCost, + 'currency': feeCurrencyCode, + }; + } + } + if ((symbol === undefined) && (market !== undefined)) { + symbol = market['symbol']; + } + if (cost === undefined) { + if ((amount !== undefined) && (price !== undefined)) { + cost = amount * price; + } + } + return { + 'info': trade, + 'id': id, + 'timestamp': timestamp, + 'datetime': this.iso8601 (timestamp), + 'symbol': symbol, + 'order': orderId, + 'type': type, + 'side': side, + 'takerOrMaker': undefined, + 'price': price, + 'amount': amount, + 'cost': cost, + 'fee': fee, + }; + } + + async fetchBalance (params = {}) { + await this.loadMarkets (); + const response = await this.privatePostGetPositions (params); + // { + // "positions":[ + // { + // "instrumentId":1, + // "userId":3583, + // "quantity":0, + // "availableQuantity":0, + // "quantity_scale":6, + // "symbol":"USDC", + // "assetType":"ASSET", + // "usdCostBasis":0.0, + // "usdAvgCostBasis":0.0, + // "usdValue":0.0, + // "usdUnrealized":0.0, + // "usdRealized":0.0, + // "baseUsdMark":1.0, + // "settleCoinUsdMark":0.0, + // "settleCoinUnrealized":0.0, + // "settleCoinRealized":0.0 + // }, + // ] + // } + const positions = this.safeValue (response, 'positions', []); + const result = { + 'info': response, + }; + for (let i = 0; i < positions.length; i++) { + const position = positions[i]; + const assetType = this.safeString (position, 'assetType'); + if (assetType === 'ASSET') { + const currencyId = this.safeString (position, 'symbol'); + const code = this.safeCurrencyCode (currencyId); + const quantity = this.safeFloat (position, 'quantity'); + const availableQuantity = this.safeFloat (position, 'availableQuantity'); + const scale = this.safeInteger (position, 'quantity_scale'); + const account = this.account (); + account['free'] = this.convertFromScale (availableQuantity, scale); + account['total'] = this.convertFromScale (quantity, scale); + result[code] = account; + } + } + return this.parseBalance (result); + } + + async createOrder (symbol, type, side, amount, price = undefined, params = {}) { + await this.loadMarkets (); + const market = this.market (symbol); + const orderSide = (side === 'buy') ? 1 : 2; + const quantityScale = this.getScale (amount); + const request = { + // 'id': 0, + // 'account': 0, // required for institutional users + 'instrumentId': parseInt (market['id']), + 'symbol': market['uppercaseId'], + // 'clOrdId': '', + 'side': orderSide, // 1 = buy, 2 = sell + // 'ordType': 1, // 1 = market, 2 = limit, 3 = stop market, 4 = stop limit + // 'price': this.priceToPrecision (symbol, price), // required for limit and stop limit orders + // 'price_scale': this.getScale (price), + 'quantity': this.convertToScale (amount, quantityScale), + 'quantity_scale': quantityScale, + // 'stopPx': this.priceToPrecision (symbol, stopPx), + // 'stopPx_scale': this.getScale (stopPx), + // 'targetStrategy': 0, + // 'isHidden': false, + // 'timeInForce': 1, // 1 = Good Till Cancel (GTC), 3 = Immediate or Cancel (IOC), 4 = Fill or Kill (FOK), 5 = Good Till Crossing (GTX), 6 = Good Till Date (GTD) + // 'interval': 0, + // 'intervalCount': 0, + // 'intervalDelay': 0, + // 'price2': 0, + // 'price2_scale': this.getScale (price2), + // 'blockWaitAck': 0, // 1 = wait for order acknowledgement, when set, response will include the matching engine "orderId" field + }; + if (type === 'market') { + request['ordType'] = 1; + } else if (type === 'limit') { + request['ordType'] = 2; + request['price'] = this.convertToScale (price, this.getScale (price)); + } else { + const stopPrice = this.safeFloat2 (params, 'stopPrice', 'stopPx'); + params = this.omit (params, [ 'stopPrice', 'stopPx' ]); + if (stopPrice === undefined) { + if (type === 'stop') { + if (price === undefined) { + throw new ArgumentsRequired (this.id + ' createOrder() requires a price argument or a stopPrice parameter or a stopPx parameter for ' + type + ' orders'); + } + request['ordType'] = 3; + request['stopPx'] = this.convertToScale (price, this.getScale (price)); + } else if (type === 'stop limit') { + throw new ArgumentsRequired (this.id + ' createOrder() requires a stopPrice parameter or a stopPx parameter for ' + type + ' orders'); + } + } else { + if (type === 'stop') { + request['ordType'] = 3; + request['stopPx'] = this.convertToScale (stopPrice, this.getScale (stopPrice)); + } else if (type === 'stop limit') { + request['ordType'] = 4; + const priceScale = this.getScale (price); + const stopPriceScale = this.getScale (stopPrice); + request['price_scale'] = priceScale; + request['stopPx_scale'] = stopPriceScale; + request['stopPx'] = this.convertToScale (stopPrice, stopPriceScale); + request['price'] = this.convertToScale (price, priceScale); + } + } + } + const response = await this.privatePostOrder (this.extend (request, params)); + // + // { + // "status":"sent", + // "id":385617863, + // "instrumentId":53, + // "clOrdId":"1613037510849637345", + // "userId":3583, + // "price":2000, + // "quantity":200, + // "ordType":2 + // } + // + return this.parseOrder (response, market); + } + + async cancelOrder (id, symbol = undefined, params = {}) { + if (symbol === undefined) { + throw new ArgumentsRequired (this.id + ' cancelOrder() requires a symbol argument'); + } + await this.loadMarkets (); + const market = this.market (symbol); + const request = { + 'origOrderId': parseInt (id), + 'instrumentId': parseInt (market['id']), + }; + const response = await this.privatePostCancelOrder (this.extend (request, params)); + // + // { + // "status":"sent", + // "id":0, + // "origOrderId":385613629, + // "instrumentId":53, + // "userId":3583, + // "price":0, + // "quantity":0, + // "ordType":0 + // } + // + return this.parseOrder (response, market); + } + + async editOrder (id, symbol, type, side, amount, price = undefined, params = {}) { + await this.loadMarkets (); + const market = this.market (symbol); + const orderSide = (side === 'buy') ? 1 : 2; + const quantityScale = this.getScale (amount); + const request = { + // 'id': 0, + 'origOrderId': id, + // 'account': 0, // required for institutional users + 'instrumentId': parseInt (market['id']), + 'symbol': market['uppercaseId'], + // 'clOrdId': '', + 'side': orderSide, // 1 = buy, 2 = sell + // 'ordType': 1, // 1 = market, 2 = limit, 3 = stop market, 4 = stop limit + // 'price': this.priceToPrecision (symbol, price), // required for limit and stop limit orders + // 'price_scale': this.getScale (price), + 'quantity': this.convertToScale (amount, quantityScale), + 'quantity_scale': quantityScale, + // 'stopPx': this.priceToPrecision (symbol, stopPx), + // 'stopPx_scale': this.getScale (stopPx), + // 'timeInForce': 1, // 1 = Good Till Cancel (GTC), 3 = Immediate or Cancel (IOC), 4 = Fill or Kill (FOK), 5 = Good Till Crossing (GTX), 6 = Good Till Date (GTD) + }; + if (type === 'market') { + request['ordType'] = 1; + } else if (type === 'limit') { + request['ordType'] = 2; + request['price'] = this.convertToScale (price, this.getScale (price)); + } else { + const stopPrice = this.safeFloat2 (params, 'stopPrice', 'stopPx'); + params = this.omit (params, [ 'stopPrice', 'stopPx' ]); + if (stopPrice === undefined) { + if (type === 'stop') { + if (price === undefined) { + throw new ArgumentsRequired (this.id + ' editOrder() requires a price argument or a stopPrice parameter or a stopPx parameter for ' + type + ' orders'); + } + request['ordType'] = 3; + request['stopPx'] = this.convertToScale (price, this.getScale (price)); + } else if (type === 'stop limit') { + throw new ArgumentsRequired (this.id + ' editOrder() requires a stopPrice parameter or a stopPx parameter for ' + type + ' orders'); + } + } else { + if (type === 'stop') { + request['ordType'] = 3; + request['stopPx'] = this.convertToScale (stopPrice, this.getScale (stopPrice)); + } else if (type === 'stop limit') { + request['ordType'] = 4; + const priceScale = this.getScale (price); + const stopPriceScale = this.getScale (stopPrice); + request['price_scale'] = priceScale; + request['stopPx_scale'] = stopPriceScale; + request['stopPx'] = this.convertToScale (stopPrice, stopPriceScale); + request['price'] = this.convertToScale (price, priceScale); + } + } + } + const response = await this.privatePostOrder (this.extend (request, params)); + // + // { + // "status":"sent", + // "id":385617863, + // "instrumentId":53, + // "clOrdId":"1613037510849637345", + // "userId":3583, + // "price":2000, + // "quantity":200, + // "ordType":2 + // } + // + return this.parseOrder (response, market); + } + + async fetchOrder (id, symbol = undefined, params = {}) { + await this.loadMarkets (); + const request = { + 'orderId': parseInt (id), + }; + const response = await this.privatePostGetOrderStatus (this.extend (request, params)); + // + // { + // "orderId":388953019, + // "clOrdId":"1613106766970339107", + // "symbol":"ETH/USDC", + // "instrumentId":53, + // "side":"1", + // "userId":3583, + // "account":3583, + // "execType":"F", + // "ordType":"2", + // "ordStatus":"2", + // "timeInForce":"3", + // "timeStamp":"20210212-05:12:46.971", + // "execId":265757, + // "targetStrategy":0, + // "isHidden":false, + // "isReduceOnly":false, + // "isLiquidation":false, + // "fee":0, + // "fee_scale":6, + // "feeInstrumentId":1, + // "price":184204, + // "price_scale":2, + // "quantity":10000, + // "quantity_scale":6, + // "leavesQty":0, + // "leavesQty_scale":6, + // "cumQty":10000, + // "cumQty_scale":6, + // "lastPx":175622, + // "lastPx_scale":2, + // "avgPx":175622, + // "avgPx_scale":2, + // "lastQty":10000, + // "lastQty_scale":6 + // } + // + return this.parseOrder (response); + } + + async fetchClosedOrders (symbol = undefined, since = undefined, limit = undefined, params = {}) { + const request = { + 'ordStatus': '2', // '0' = New, '1' = Partially filled, '2' = Filled, '4' = Cancelled, '8' = Rejected, 'C' = Expired + }; + return await this.fetchOrders (symbol, since, limit, this.extend (request, params)); + } + + async fetchCanceledOrders (symbol = undefined, since = undefined, limit = undefined, params = {}) { + const request = { + 'ordStatus': '4', // '0' = New, '1' = Partially filled, '2' = Filled, '4' = Cancelled, '8' = Rejected, 'C' = Expired + }; + return await this.fetchOrders (symbol, since, limit, this.extend (request, params)); + } + + async fetchOrders (symbol = undefined, since = undefined, limit = undefined, params = {}) { + await this.loadMarkets (); + let market = undefined; + const request = { + // 'account': id, // for institutional users + // 'symbol': marketSymbol, // cannot be used with instrumentId + // 'instrumentId': market['numericId'], + // 'limit': limit, + // 'execType': execType, // '0' = New, '4' = Canceled, '5' = Replace, '8' = Rejected, 'C' = Expired, 'F' = Fill Status, 'I' = Order Status + // 'ordStatus': ordStatus, // '0' = New, '1' = Partially filled, '2' = Filled, '4' = Cancelled, '8' = Rejected, 'C' = Expired + }; + if (symbol !== undefined) { + market = this.market (symbol); + request['instrumentId'] = parseInt (market['id']); + } + if (limit !== undefined) { + request['limit'] = limit; + } + const response = await this.privatePostGetOrders (this.extend (request, params)); + // + // { + // "isInitialSnap":false, + // "orders":[ + // { + // "orderId":385613629, + // "orderUpdateSeq":1, + // "clOrdId":"1613037448945798198", + // "symbol":"ETH/USDC", + // "instrumentId":53, + // "side":"1", + // "userId":3583, + // "account":3583, + // "execType":"4", + // "ordType":"2", + // "ordStatus":"C", + // "timeInForce":"3", + // "timeStamp":"20210211-09:57:28.944", + // "execId":0, + // "targetStrategy":0, + // "isHidden":false, + // "isReduceOnly":false, + // "isLiquidation":false, + // "fee":0, + // "feeTotal":0, + // "fee_scale":0, + // "feeInstrumentId":0, + // "price":999, + // "price_scale":2, + // "quantity":10000000, + // "quantity_scale":6, + // "leavesQty":10000000, + // "leavesQty_scale":6, + // "cumQty":0, + // "cumQty_scale":0, + // "lastPx":0, + // "lastPx_scale":2, + // "avgPx":0, + // "avgPx_scale":0, + // "lastQty":0, + // "lastQty_scale":6 + // } + // ] + // } + // + const orders = this.safeValue (response, 'orders', []); + return this.parseOrders (orders, market, since, limit, params); + } + + async fetchMyTrades (symbol = undefined, since = undefined, limit = undefined, params = {}) { + await this.loadMarkets (); + const request = { + // 'account': 123, // for institutional users + // 'instrumentId': market['id'], + // 'startTime': since, + // 'endTime': this.milliseconds (), + }; + let market = undefined; + if (symbol !== undefined) { + market = this.market (symbol); + request['instrumentId'] = market['id']; + } + if (since !== undefined) { + request['startTime'] = since; + } + const response = await this.privatePostUserTrades (this.extend (request, params)); + // + // { + // "trades":[ + // { + // "account":3583, + // "commission":"-0.015805", + // "commCurrency":"USDC", + // "execId":265757, + // "ordType":"2", + // "ordStatus":"2", + // "execType":"F", + // "aggressorIndicator":true, + // "orderId":388953019, + // "price":"1842.04", + // "qty":"0.010000", + // "lastPx":"1756.22", + // "avgPx":"1756.22", + // "cumQty":"0.010000", + // "quoteQty":"0.010000", + // "side":"BUY", + // "symbol":"ETH/USDC", + // "clOrdId":"1613106766970339107", + // "submitterId":3583, + // "targetStrategy":"0", + // "time":1613106766971, + // "date":"20210212-05:12:46.971" + // } + // ] + // } + // + const trades = this.safeValue (response, 'trades', []); + return this.parseTrades (trades, market, since, limit, params); + } + + async fetchDepositAddress (code, params = {}) { + await this.loadMarkets (); + const currency = this.currency (code); + const request = { + 'instrumentId': parseInt (currency['id']), + }; + const response = await this.privatePostGetDepositAddresses (this.extend (request, params)); + // + // { + // "addresses":[ + // {"instrumentId":1,"userId":3583,"symbol":"USDC","address":"0xdff47af071ea3c537e57278290516cda32a78b97","status":1} + // ] + // } + // + const addresses = this.safeValue (response, 'addresses', []); + const address = this.safeValue (addresses, 0); + return this.parseDepositAddress (address, currency); + } + + parseDepositAddress (depositAddress, currency = undefined) { + // + // { + // "instrumentId":1, + // "userId":3583, + // "symbol":"USDC", + // "address":"0xdff47af071ea3c537e57278290516cda32a78b97", + // "status":1 + // } + // + const currencyId = this.safeString (depositAddress, 'symbol'); + const code = this.safeCurrencyCode (currencyId, currency); + const address = this.safeString (depositAddress, 'address'); + this.checkAddress (address); + return { + 'currency': code, + 'address': address, + 'tag': undefined, + 'info': depositAddress, + }; + } + + async fetchDeposits (code = undefined, since = undefined, limit = undefined, params = {}) { + await this.loadMarkets (); + const request = {}; + let currency = undefined; + if (code !== undefined) { + currency = this.currency (code); + request['instrumentId'] = parseInt (currency['id']); + } + const response = await this.privatePostGetDepositHistory (this.extend (request, params)); + // + // { + // "deposits":[ + // { + // "id":4309, + // "instrumentId":1, + // "userId":3583, + // "symbol":"USDC", + // "address":"null", + // "timestamp":"1613021112189", + // "status":1, + // "balance":0.0, + // "balance_change":100.0, + // "confirms":1, + // "transactionId":"caba4500-489f-424e-abd7-b4dabc09a800" + // } + // ] + // } + // + const deposits = this.safeValue (response, 'deposits', []); + return this.parseTransactions (deposits, currency, since, limit, { 'type': 'deposit' }); + } + + async fetchWithdrawals (code = undefined, since = undefined, limit = undefined, params = {}) { + await this.loadMarkets (); + const request = {}; + let currency = undefined; + if (code !== undefined) { + currency = this.currency (code); + request['instrumentId'] = parseInt (currency['id']); + } + const response = await this.privatePostGetWithdrawRequests (this.extend (request, params)); + // + // { + // "addresses":[ + // { + // "id":3841, + // "instrumentId":3, + // "userId":4245, + // "symbol":"BTC", + // "address":"XXXXXYYYYYZZZZZ", + // "timestamp":"20200806-11:04:35.053", + // "status":0, + // "balance":1, + // "balance_scale":3, + // "confirms":0, + // "transactionId":"null" + // } + // ] + // } + // + const withdrawals = this.safeValue (response, 'addresses', []); + return this.parseTransactions (withdrawals, currency, since, limit, { 'type': 'withdrawal' }); + } + + parseTransaction (transaction, currency = undefined) { + // + // fetchDeposits, fetchWithdrawals + // + // { + // "id":4309, + // "instrumentId":1, + // "userId":3583, + // "symbol":"USDC", + // "address":"null", + // "timestamp":"1613021112189", + // "status":1, + // "balance":0.0, + // "balance_change":100.0, + // "confirms":1, + // "transactionId":"caba4500-489f-424e-abd7-b4dabc09a800" + // } + // + // withdraw + // + // { + // "instrumentId": 1, + // "userId": 23750, + // "symbol": "USDC", + // "timestamp": "20200201-05:37:16.584", + // "status": 1, + // "userUuid": "b9e33713-c28f-468f-99bd-f6deab0dd854", + // "currencyCode": "USDC", + // "address": "2MvW97yT6E2Kq8bWc1aj1DqfbgMzjRNk2LE", + // "quantity": 20, + // "requestUuid": "56782b34-8a78-4f5f-b164-4b8f7d583b7f", + // "transactionUuid": "1004eb0f-41e1-41e9-9d48-8eefcc6c09f2", + // "transactionId": "WS23436", + // "destinationWalletAlias": "Test", + // "quantity_scale": 0 + // } + // + const id = this.safeString (transaction, 'id', 'transactionId'); + const txid = this.safeString (transaction, 'transactionUuid'); + const timestamp = this.safeInteger (transaction, 'timestamp'); + let address = this.safeString (transaction, 'address'); + if (address === 'null') { + address = undefined; + } + const type = this.safeString (transaction, 'type'); + let amount = this.safeFloat (transaction, 'balance_change'); + if (amount === undefined) { + amount = this.safeInteger (transaction, 'quantity'); + const amountScale = this.safeInteger (transaction, 'quantity_scale'); + amount = this.convertFromScale (amount, amountScale); + } + const currencyId = this.safeString (transaction, 'symbol'); + const code = this.safeCurrencyCode (currencyId, currency); + const status = this.parseTransactionStatus (this.safeString (transaction, 'status')); + return { + 'info': transaction, + 'id': id, + 'txid': txid, + 'timestamp': timestamp, + 'datetime': this.iso8601 (timestamp), + 'addressFrom': undefined, + 'address': address, + 'addressTo': undefined, + 'tagFrom': undefined, + 'tag': undefined, + 'tagTo': undefined, + 'type': type, + 'amount': amount, + 'currency': code, + 'status': status, + 'updated': undefined, + 'comment': undefined, + 'fee': undefined, + }; + } + + parseTransactionStatus (status) { + const statuses = { + '0': 'pending', + '1': 'ok', + }; + return this.safeString (statuses, status, status); + } + + async withdraw (code, amount, address, tag = undefined, params = {}) { + this.checkAddress (address); + await this.loadMarkets (); + const currency = this.currency (code); + const scale = this.getScale (amount); + const quantity = this.convertToScale (amount, scale); + const request = { + 'instrumentId': parseInt (currency['id']), + 'symbol': currency['uppercaseId'], + 'quantity': quantity, + 'quantity_scale': scale, + 'address': address, + }; + const response = await this.privatePostSendWithdrawRequest (this.extend (request, params)); + // + // { + // "instrumentId": 1, + // "userId": 23750, + // "symbol": "USDC", + // "timestamp": "20200201-05:37:16.584", + // "status": 1, + // "userUuid": "b9e33713-c28f-468f-99bd-f6deab0dd854", + // "currencyCode": "USDC", + // "address": "2MvW97yT6E2Kq8bWc1aj1DqfbgMzjRNk2LE", + // "quantity": 20, + // "requestUuid": "56782b34-8a78-4f5f-b164-4b8f7d583b7f", + // "transactionUuid": "1004eb0f-41e1-41e9-9d48-8eefcc6c09f2", + // "transactionId": "WS23436", + // "destinationWalletAlias": "Test", + // "quantity_scale": 0 + // } + // + return this.parseTransaction (response, currency); + } + + async fetchTradingFees (params = {}) { + // getExchangeInfo + const response = await this.publicGetGetExchangeInfo (params); + const tradingFees = this.safeValue (response, 'spotFees', []); + const taker = {}; + const maker = {}; + for (let i = 0; i < tradingFees.length; i++) { + const tradingFee = tradingFees[i]; + if (this.safeString (tradingFee, 'tier') !== undefined) { + taker[tradingFee['tier']] = this.safeFloat (tradingFee, 'taker'); + maker[tradingFee['tier']] = this.safeFloat (tradingFee, 'maker'); + } + } + return { + 'info': tradingFees, + 'tierBased': true, + 'maker': maker, + 'taker': taker, + }; + } + + async fetchTradingLimits (symbols = undefined, params = {}) { + await this.loadMarkets (); + // getExchangeInfo + const response = await this.publicGetGetExchangeInfo (params); + const tradingLimits = this.safeValue (response, 'tradingLimits', []); + // To-do parsing response when available + return { + 'info': tradingLimits, + 'limits': { + 'amount': { + 'min': undefined, + 'max': undefined, + }, + 'price': { + 'min': undefined, + 'max': undefined, + }, + 'cost': { + 'min': undefined, + 'max': undefined, + }, + }, + }; + } + + async fetchFundingLimits (params = {}) { + // getExchangeInfo + const response = await this.publicGetGetExchangeInfo (params); + const withdrawLimits = this.safeValue (response, 'withdrawLimits', []); + // TO-DO parse response when available + return { + 'info': withdrawLimits, + 'withdraw': undefined, + }; + } + + parseOrder (order, market = undefined) { + // + // createOrder, editOrder, cancelOrder + // + // { + // "status":"sent", + // "id":385617863, + // "instrumentId":53, + // "clOrdId":"1613037510849637345", + // "userId":3583, + // "price":2000, + // "quantity":200, + // "ordType":2 + // } + // + // fetchOrders, fetchOrder + // + // { + // "orderId":385613629, + // "orderUpdateSeq":1, + // "clOrdId":"1613037448945798198", + // "symbol":"ETH/USDC", + // "instrumentId":53, + // "side":"1", + // "userId":3583, + // "account":3583, + // "execType":"4", + // "ordType":"2", + // "ordStatus":"C", + // "timeInForce":"3", + // "timeStamp":"20210211-09:57:28.944", + // "execId":0, + // "targetStrategy":0, + // "isHidden":false, + // "isReduceOnly":false, + // "isLiquidation":false, + // "fee":0, + // "feeTotal":0, + // "fee_scale":0, + // "feeInstrumentId":0, + // "price":999, + // "price_scale":2, + // "quantity":10000000, + // "quantity_scale":6, + // "leavesQty":10000000, + // "leavesQty_scale":6, + // "cumQty":0, + // "cumQty_scale":0, + // "lastPx":0, + // "lastPx_scale":2, + // "avgPx":0, + // "avgPx_scale":0, + // "lastQty":0, + // "lastQty_scale":6 + // } + // + let id = this.safeString2 (order, 'orderId', 'id'); + id = this.safeString (order, 'origOrderId', id); + const clientOrderId = this.safeString (order, 'clOrdId'); + const type = this.parseOrderType (this.safeString (order, 'ordType')); + const side = this.parseOrderSide (this.safeString (order, 'side')); + const status = this.parseOrderStatus (this.safeString (order, 'ordStatus')); + const marketId = this.safeString (order, 'instrumentId'); + const symbol = this.safeSymbol (marketId, market); + const timestamp = this.toMilliseconds (this.safeString (order, 'timeStamp')); + const lastTradeTimestamp = undefined; + let price = this.safeInteger (order, 'price'); + if (price === 0) { + price = undefined; + } + const priceScale = this.safeInteger (order, 'price_scale'); + price = this.convertFromScale (price, priceScale); + let amount = this.safeInteger (order, 'quantity'); + if (amount === 0) { + amount = undefined; + } + const amountScale = this.safeInteger (order, 'quantity_scale'); + amount = this.convertFromScale (amount, amountScale); + let filled = this.safeInteger (order, 'cumQty'); + const filledScale = this.safeInteger (order, 'cumQty_scale'); + filled = this.convertFromScale (filled, filledScale); + let remaining = this.safeInteger (order, 'leavesQty'); + const remainingScale = this.safeInteger (order, 'leavesQty_scale'); + remaining = this.convertFromScale (remaining, remainingScale); + if (remaining <= 0) { + if ((filled !== undefined) && (amount !== undefined) && (filled < amount)) { + remaining = undefined; + } + } + if ((remaining === undefined) && (amount !== undefined) && (filled !== undefined)) { + remaining = Math.max (amount - filled, 0); + } + let average = this.safeInteger (order, 'price', 0); + if (average === 0) { + average = undefined; + } + const averageScale = this.safeInteger (order, 'price_scale'); + average = this.convertFromScale (average, averageScale); + let cost = undefined; + if (filled !== 0) { + if (average > 0) { + cost = average * filled; + } else if (price > 0) { + cost = price * filled; + } + } + let fee = undefined; + const currencyId = this.safeInteger (order, 'feeInstrumentId'); + const feeCurrencyCode = this.safeCurrencyCode (currencyId); + let feeCost = this.safeInteger (order, 'feeTotal'); + const feeScale = this.safeInteger (order, 'fee_scale'); + if (feeCost !== undefined) { + feeCost = -feeCost; + feeCost = this.convertFromScale (feeCost, feeScale); + } + if (feeCost !== undefined) { + fee = { + 'currency': feeCurrencyCode, + 'cost': feeCost, + 'rate': undefined, + }; + } + let timeInForce = this.parseTimeInForce (this.safeString (order, 'timeInForce')); + if (timeInForce === '0') { + timeInForce = undefined; + } + const stopPriceScale = this.safeInteger (order, 'stopPx_scale', 0); + const stopPrice = this.convertFromScale (this.safeInteger (order, 'stopPx'), stopPriceScale); + return { + 'info': order, + 'id': id, + 'clientOrderId': clientOrderId, + 'timestamp': timestamp, + 'datetime': this.iso8601 (timestamp), + 'lastTradeTimestamp': lastTradeTimestamp, + 'symbol': symbol, + 'type': type, + 'timeInForce': timeInForce, + 'postOnly': undefined, + 'side': side, + 'price': price, + 'stopPrice': stopPrice, + 'amount': amount, + 'cost': cost, + 'average': average, + 'filled': filled, + 'remaining': remaining, + 'status': status, + 'fee': fee, + 'trades': undefined, + }; + } + + parseOrderStatus (status) { + const statuses = { + '0': 'open', + '1': 'open', // 'partially filled', + '2': 'closed', // 'filled', + '3': 'open', // 'done for day', + '4': 'canceled', + '5': 'canceled', // 'replaced', + '6': 'canceling', // 'pending cancel', + '7': 'canceled', // 'stopped', + '8': 'rejected', // 'rejected', + '9': 'canceled', // 'suspended', + 'A': 'open', // 'pending new', + 'B': 'open', // 'calculated', + 'C': 'expired', + 'D': 'open', // 'accepted for bidding', + 'E': 'canceling', // 'pending replace', + 'F': 'open', // 'partial fill or fill', + }; + return this.safeString (statuses, status, status); + } + + parseOrderSide (side) { + const sides = { + '1': 'buy', + '2': 'sell', + }; + return this.safeString (sides, side, side); + } + + parseOrderType (type) { + const types = { + '1': 'market', + '2': 'limit', + '3': 'stop', + '4': 'stop limit', + }; + return this.safeString (types, type, type); + } + + parseTimeInForce (timeInForce) { + const timeInForces = { + '1': 'GTC', // Good Till Canceled + '3': 'IOC', // Immediate or Cancel + '4': 'FOK', // Fill or Kill + '5': 'GTX', // Good Till Crossing (GTX) + '6': 'GTD', // Good Till Date + }; + return this.safeString (timeInForces, timeInForce, timeInForce); + } + + toMilliseconds (dateString) { + if (dateString === undefined) { + return dateString; + } + // '20200328-10:31:01.575' -> '2020-03-28 12:42:48.000' + const splits = dateString.split ('-'); + const partOne = this.safeString (splits, 0); + const partTwo = this.safeString (splits, 1); + if (partOne === undefined || partTwo === undefined) { + return undefined; + } + if (partOne.length !== 8) { + return undefined; + } + const date = partOne.slice (0, 4) + '-' + partOne.slice (4, 6) + '-' + partOne.slice (6, 8); + return this.parse8601 (date + ' ' + partTwo); + } + + convertFromScale (number, scale) { + if ((number === undefined) || (scale === undefined)) { + return undefined; + } + return this.fromWei (number, scale); + } + + getScale (num) { + const s = this.numberToString (num); + return this.precisionFromString (s); + } + + convertToScale (number, scale) { + if ((number === undefined) || (scale === undefined)) { + return undefined; + } + return parseInt (this.toWei (number, scale)); + } + + nonce () { + return this.milliseconds (); + } + + handleErrors (code, reason, url, method, headers, body, response, requestHeaders, requestBody) { + if (response === undefined) { + return; // fallback to default error handler + } + const error = this.safeString (response, 'error'); + if (error !== undefined) { + const feedback = this.id + ' ' + body; + this.throwExactlyMatchedException (this.exceptions, error, feedback); + this.throwBroadlyMatchedException (this.exceptions, body, feedback); + throw new ExchangeError (this.id + ' ' + body); + } + } + + sign (path, api = 'public', method = 'GET', params = {}, headers = undefined, body = undefined) { + let url = this.implodeParams (path, params); + let query = this.omit (params, this.extractParams (path)); + if (api === 'public') { + if (Object.keys (query).length) { + url += '?' + this.urlencode (query); + } + } else if (api === 'private') { + // special case for getUserHistory + const format = this.safeValue (params, 'format'); + const type = this.safeValue (params, 'type'); + const extension = {}; + if (format !== undefined) { + extension['format'] = format; + } + if (type !== undefined) { + extension['type'] = type; + } + if (Object.keys (extension).length) { + url += '?' + this.urlencode (extension); + } + params = this.omit (params, [ 'format', 'type' ]); + this.checkRequiredCredentials (); + const nonce = this.nonce (); + query = this.extend (query, { + 'userId': this.uid, + 'nonce': nonce, + }); + params['nonce'] = this.nonce (); + body = this.json (query); + const signature = this.hmac (this.encode (body), this.encode (this.secret), 'sha384'); + headers = { + 'Content-Type': 'application/json', + 'requestToken': this.apiKey, + 'signature': signature, + }; + } + url = this.urls['api'][api] + '/' + url; + return { 'url': url, 'method': method, 'body': body, 'headers': headers }; + } +}; diff --git a/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/eterbase.js b/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/eterbase.js index 56d975d44..40d2893d3 100644 --- a/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/eterbase.js +++ b/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/eterbase.js @@ -605,7 +605,7 @@ module.exports = class eterbase extends Exchange { request['start'] = now - duration * limit * 1000; request['end'] = now; } else { - throw new ArgumentsRequired (this.id + ' fetchOHLCV requires a since argument, or a limit argument, or both'); + throw new ArgumentsRequired (this.id + ' fetchOHLCV() requires a since argument, or a limit argument, or both'); } await this.loadMarkets (); const market = this.market (symbol); @@ -807,6 +807,7 @@ module.exports = class eterbase extends Exchange { } const timeInForce = this.safeString (order, 'timeInForce'); const stopPrice = this.safeFloat (order, 'stopPrice'); + const postOnly = this.safeValue (order, 'postOnly'); return { 'info': order, 'id': id, @@ -816,8 +817,9 @@ module.exports = class eterbase extends Exchange { 'lastTradeTimestamp': undefined, 'symbol': symbol, 'type': type, - 'side': side, 'timeInForce': timeInForce, + 'postOnly': postOnly, + 'side': side, 'price': price, 'stopPrice': stopPrice, 'amount': amount, diff --git a/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/exmo.js b/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/exmo.js index 52c2ba65e..c9e19479d 100644 --- a/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/exmo.js +++ b/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/exmo.js @@ -702,7 +702,7 @@ module.exports = class exmo extends Exchange { const now = this.milliseconds (); if (since === undefined) { if (limit === undefined) { - throw new ArgumentsRequired (this.id + ' fetchOHLCV requires a since argument or a limit argument'); + throw new ArgumentsRequired (this.id + ' fetchOHLCV() requires a since argument or a limit argument'); } else { if (limit > maxLimit) { throw new BadRequest (this.id + ' fetchOHLCV will serve ' + maxLimit.toString () + ' candles at most'); @@ -1318,6 +1318,7 @@ module.exports = class exmo extends Exchange { 'symbol': symbol, 'type': 'limit', 'timeInForce': undefined, + 'postOnly': undefined, 'side': side, 'price': price, 'stopPrice': undefined, @@ -1436,12 +1437,21 @@ module.exports = class exmo extends Exchange { const type = this.safeString (transaction, 'type'); const currencyId = this.safeString (transaction, 'curr'); const code = this.safeCurrencyCode (currencyId, currency); - let address = this.safeString (transaction, 'account'); - if (address !== undefined) { - const parts = address.split (':'); - const numParts = parts.length; - if (numParts === 2) { - address = parts[1].replace (' ', ''); + let address = undefined; + const tag = undefined; + let comment = undefined; + const account = this.safeString (transaction, 'account'); + if (type === 'deposit') { + comment = account; + } else if (type === 'withdrawal') { + address = account; + if (address !== undefined) { + const parts = address.split (':'); + const numParts = parts.length; + if (numParts === 2) { + address = this.safeString (parts, 1); + address = address.replace (' ', ''); + } } } let fee = undefined; @@ -1469,16 +1479,21 @@ module.exports = class exmo extends Exchange { return { 'info': transaction, 'id': undefined, + 'timestamp': timestamp, + 'datetime': this.iso8601 (timestamp), 'currency': code, 'amount': amount, 'address': address, - 'tag': undefined, // refix it properly + 'addressTo': address, + 'addressFrom': undefined, + 'tag': tag, + 'tagTo': tag, + 'tagFrom': undefined, 'status': status, 'type': type, 'updated': undefined, + 'comment': comment, 'txid': txid, - 'timestamp': timestamp, - 'datetime': this.iso8601 (timestamp), 'fee': fee, }; } diff --git a/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/exx.js b/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/exx.js index 925d4a2f2..c4c12d03f 100644 --- a/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/exx.js +++ b/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/exx.js @@ -326,6 +326,7 @@ module.exports = class exx extends Exchange { 'symbol': symbol, 'type': 'limit', 'timeInForce': undefined, + 'postOnly': undefined, 'side': order['type'], 'price': price, 'stopPrice': undefined, @@ -387,7 +388,7 @@ module.exports = class exx extends Exchange { async fetchOpenOrders (symbol = undefined, since = undefined, limit = undefined, params = {}) { await this.loadMarkets (); if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' fetchOpenOrders requires a symbol argument'); + throw new ArgumentsRequired (this.id + ' fetchOpenOrders() requires a symbol argument'); } const market = this.market (symbol); const request = { diff --git a/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/fcoin.js b/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/fcoin.js index 1bdb5920d..2d1c845ab 100644 --- a/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/fcoin.js +++ b/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/fcoin.js @@ -592,6 +592,7 @@ module.exports = class fcoin extends Exchange { 'symbol': symbol, 'type': orderType, 'timeInForce': undefined, + 'postOnly': undefined, 'side': side, 'price': price, 'stopPrice': undefined, diff --git a/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/flowbtc.js b/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/flowbtc.js index d38ebfea9..12646489b 100644 --- a/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/flowbtc.js +++ b/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/flowbtc.js @@ -246,7 +246,7 @@ module.exports = class flowbtc extends Exchange { }; return await this.privatePostCancelOrder (this.extend (request, params)); } - throw new ExchangeError (this.id + ' requires `ins` symbol parameter for cancelling an order'); + throw new ExchangeError (this.id + ' cancelOrder() requires an `ins` symbol parameter for cancelling an order'); } sign (path, api = 'public', method = 'GET', params = {}, headers = undefined, body = undefined) { diff --git a/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/ftx.js b/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/ftx.js index 8e3992ac5..18b572cc6 100644 --- a/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/ftx.js +++ b/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/ftx.js @@ -4,7 +4,7 @@ const Exchange = require ('./base/Exchange'); const { TICK_SIZE } = require ('./base/functions/number'); -const { ExchangeError, InvalidOrder, BadRequest, InsufficientFunds, OrderNotFound, AuthenticationError } = require ('./base/errors'); +const { ExchangeError, InvalidOrder, BadRequest, InsufficientFunds, OrderNotFound, AuthenticationError, RateLimitExceeded, ExchangeNotAvailable, CancelPending } = require ('./base/errors'); // --------------------------------------------------------------------------- @@ -14,7 +14,7 @@ module.exports = class ftx extends Exchange { 'id': 'ftx', 'name': 'FTX', 'countries': [ 'HK' ], - 'rateLimit': 100, + 'rateLimit': 50, 'certified': true, 'pro': true, 'hostname': 'ftx.com', // or ftx.us @@ -99,9 +99,12 @@ module.exports = class ftx extends Exchange { 'wallet/coins', 'wallet/balances', 'wallet/all_balances', - 'wallet/deposit_address/{coin}', + 'wallet/deposit_address/{coin}', // ?method={method} 'wallet/deposits', 'wallet/withdrawals', + 'wallet/withdrawal_fee', + 'wallet/airdrops', + 'wallet/saved_addresses', 'orders', // ?market={market} 'orders/history', // ?market={market} 'orders/{order_id}', @@ -109,6 +112,14 @@ module.exports = class ftx extends Exchange { 'conditional_orders', // ?market={market} 'conditional_orders/{conditional_order_id}/triggers', 'conditional_orders/history', // ?market={market} + 'spot_margin/borrow_rates', + 'spot_margin/lending_rates', + 'spot_margin/borrow_summary', + 'spot_margin/market_info', // ?market={market} + 'spot_margin/borrow_history', + 'spot_margin/lending_history', + 'spot_margin/offers', + 'spot_margin/lending_info', 'fills', // ?market={market} 'funding_payments', // leverage tokens @@ -127,15 +138,23 @@ module.exports = class ftx extends Exchange { 'options/account_info', 'options/positions', 'options/fills', + // staking + 'staking/stakes', + 'staking/unstake_requests', + 'staking/balances', + 'staking/staking_rewards', ], 'post': [ 'account/leverage', 'wallet/withdrawals', + 'wallet/saved_addresses', 'orders', 'conditional_orders', 'orders/{order_id}/modify', 'orders/by_client_id/{client_order_id}/modify', 'conditional_orders/{order_id}/modify', + // spot margin + 'spot_margin/offers', // leverage tokens 'lt/{token_name}/create', 'lt/{token_name}/redeem', @@ -150,8 +169,12 @@ module.exports = class ftx extends Exchange { 'options/requests', 'options/requests/{request_id}/quotes', 'options/quotes/{quote_id}/accept', + // staking + 'staking/unstake_requests', + 'srm_stakes/stakes', ], 'delete': [ + 'wallet/saved_addresses/{saved_address_id}', 'orders/{order_id}', 'orders/by_client_id/{client_order_id}', 'orders', @@ -161,6 +184,8 @@ module.exports = class ftx extends Exchange { // options 'options/requests/{request_id}', 'options/quotes/{quote_id}', + // staking + 'staking/unstake_requests/{request_id}', ], }, }, @@ -195,6 +220,8 @@ module.exports = class ftx extends Exchange { }, 'exceptions': { 'exact': { + 'Please slow down': RateLimitExceeded, // {"error":"Please slow down","success":false} + 'Size too small for provide': InvalidOrder, // {"error":"Size too small for provide","success":false} 'Not logged in': AuthenticationError, // {"error":"Not logged in","success":false} 'Not enough balances': InsufficientFunds, // {"error":"Not enough balances","success":false} 'InvalidPrice': InvalidOrder, // {"error":"Invalid price","success":false} @@ -202,13 +229,20 @@ module.exports = class ftx extends Exchange { 'Missing parameter price': InvalidOrder, // {"error":"Missing parameter price","success":false} 'Order not found': OrderNotFound, // {"error":"Order not found","success":false} 'Order already closed': InvalidOrder, // {"error":"Order already closed","success":false} + 'Trigger price too high': InvalidOrder, // {"error":"Trigger price too high","success":false} + 'Trigger price too low': InvalidOrder, // {"error":"Trigger price too low","success":false} + 'Order already queued for cancellation': CancelPending, // {"error":"Order already queued for cancellation","success":false} }, 'broad': { + 'Account does not have enough margin for order': InsufficientFunds, 'Invalid parameter': BadRequest, // {"error":"Invalid parameter start_time","success":false} 'The requested URL was not found on the server': BadRequest, 'No such coin': BadRequest, 'No such market': BadRequest, - 'An unexpected error occurred': ExchangeError, // {"error":"An unexpected error occurred, please try again later (58BC21C795).","success":false} + 'Do not send more than': RateLimitExceeded, + 'An unexpected error occurred': ExchangeNotAvailable, // {"error":"An unexpected error occurred, please try again later (58BC21C795).","success":false} + 'Please retry request': ExchangeNotAvailable, // {"error":"Please retry request","success":false} + 'Please try again': ExchangeNotAvailable, // {"error":"Please try again","success":false} }, }, 'precisionMode': TICK_SIZE, @@ -338,7 +372,7 @@ module.exports = class ftx extends Exchange { 'amount': sizeIncrement, 'price': priceIncrement, }; - const entry = { + result.push ({ 'id': id, 'symbol': symbol, 'base': base, @@ -365,8 +399,7 @@ module.exports = class ftx extends Exchange { }, }, 'info': market, - }; - result.push (entry); + }); } return result; } @@ -665,22 +698,39 @@ module.exports = class ftx extends Exchange { // "type": "order" // } // + // { + // "baseCurrency": "BTC", + // "fee": 0, + // "feeCurrency": "USD", + // "feeRate": 0, + // "future": null, + // "id": 664079556, + // "liquidity": "taker", + // "market": null, + // "orderId": null, + // "price": 34830.61359, + // "quoteCurrency": "USD", + // "side": "sell", + // "size": 0.0005996, + // "time": "2021-01-15T16:05:29.246135+00:00", + // "tradeId": null, + // "type": "otc" + // } + // const id = this.safeString (trade, 'id'); const takerOrMaker = this.safeString (trade, 'liquidity'); const marketId = this.safeString (trade, 'market'); let symbol = undefined; - if (marketId !== undefined) { - if (marketId in this.markets_by_id) { - market = this.markets_by_id[marketId]; - symbol = market['symbol']; + if (marketId in this.markets_by_id) { + market = this.markets_by_id[marketId]; + symbol = market['symbol']; + } else { + const base = this.safeCurrencyCode (this.safeString (trade, 'baseCurrency')); + const quote = this.safeCurrencyCode (this.safeString (trade, 'quoteCurrency')); + if ((base !== undefined) && (quote !== undefined)) { + symbol = base + '/' + quote; } else { - const base = this.safeCurrencyCode (this.safeString (trade, 'baseCurrency')); - const quote = this.safeCurrencyCode (this.safeString (trade, 'quoteCurrency')); - if ((base !== undefined) && (quote !== undefined)) { - symbol = base + '/' + quote; - } else { - symbol = marketId; - } + symbol = marketId; } } const timestamp = this.parse8601 (this.safeString (trade, 'time')); @@ -998,6 +1048,7 @@ module.exports = class ftx extends Exchange { const lastTradeTimestamp = this.parse8601 (this.safeString (order, 'triggeredAt')); const clientOrderId = this.safeString (order, 'clientId'); const stopPrice = this.safeFloat (order, 'triggerPrice'); + const postOnly = this.safeValue (order, 'postOnly'); return { 'info': order, 'id': id, @@ -1008,6 +1059,7 @@ module.exports = class ftx extends Exchange { 'symbol': symbol, 'type': type, 'timeInForce': undefined, + 'postOnly': postOnly, 'side': side, 'price': price, 'stopPrice': stopPrice, @@ -1145,12 +1197,12 @@ module.exports = class ftx extends Exchange { } } else { if (clientOrderId === undefined) { + method = 'privatePostOrdersOrderIdModify'; + request['order_id'] = id; + } else { method = 'privatePostOrdersByClientIdClientOrderIdModify'; request['client_order_id'] = clientOrderId; // request['clientId'] = clientOrderId; - } else { - method = 'privatePostOrdersOrderIdModify'; - request['order_id'] = id; } if (price !== undefined) { request['price'] = parseFloat (this.priceToPrecision (symbol, price)); @@ -1216,9 +1268,7 @@ module.exports = class ftx extends Exchange { async cancelOrder (id, symbol = undefined, params = {}) { await this.loadMarkets (); - const request = { - 'order_id': parseInt (id), - }; + const request = {}; // support for canceling conditional orders // https://github.com/ccxt/ccxt/issues/6669 const options = this.safeValue (this.options, 'cancelOrder', {}); @@ -1251,8 +1301,8 @@ module.exports = class ftx extends Exchange { await this.loadMarkets (); const request = { // 'market': market['id'], // optional - 'conditionalOrdersOnly': false, // cancel conditional orders only - 'limitOrdersOnly': false, // cancel existing limit orders (non-conditional orders) only + // 'conditionalOrdersOnly': false, // cancel conditional orders only + // 'limitOrdersOnly': false, // cancel existing limit orders (non-conditional orders) only }; const marketId = this.getMarketId (symbol, 'market', params); if (marketId !== undefined) { @@ -1421,6 +1471,7 @@ module.exports = class ftx extends Exchange { } if (since !== undefined) { request['start_time'] = parseInt (since / 1000); + request['end_time'] = this.seconds (); } const response = await this.privateGetFills (this.extend (request, params)); // @@ -1610,6 +1661,15 @@ module.exports = class ftx extends Exchange { // "txid": "0x8078356ae4b06a036d64747546c274af19581f1c78c510b60505798a7ffcaf1" // } // + // { + // "coin": 'BTC', + // "id": 1969806, + // "notes": 'Transfer to Dd6gi7m2Eg4zzBbPAxuwfEaHs6tYvyUX5hbPpsTcNPXo', + // "size": 0.003, + // "status": 'complete', + // "time": '2021-02-03T20:28:54.918146+00:00' + // } + // const code = this.safeCurrencyCode (this.safeString (transaction, 'coin')); const id = this.safeString (transaction, 'id'); const amount = this.safeFloat (transaction, 'size'); @@ -1622,8 +1682,14 @@ module.exports = class ftx extends Exchange { tag = this.safeString (address, 'tag'); address = this.safeString (address, 'address'); } + if (address === undefined) { + // parse address from internal transfer + const notes = this.safeString (transaction, 'notes'); + if (notes !== undefined) { + address = notes.slice (12); + } + } const fee = this.safeFloat (transaction, 'fee'); - const type = ('destinationName' in transaction) ? 'withdrawal' : 'deposit'; return { 'info': transaction, 'id': id, @@ -1636,7 +1702,7 @@ module.exports = class ftx extends Exchange { 'tagFrom': undefined, 'tag': tag, 'tagTo': tag, - 'type': type, + 'type': undefined, 'amount': amount, 'currency': code, 'status': status, @@ -1674,7 +1740,7 @@ module.exports = class ftx extends Exchange { if (code !== undefined) { currency = this.currency (code); } - return this.parseTransactions (result, currency, since, limit); + return this.parseTransactions (result, currency, since, limit, { 'type': 'deposit' }); } async fetchWithdrawals (code = undefined, since = undefined, limit = undefined, params = {}) { @@ -1701,7 +1767,7 @@ module.exports = class ftx extends Exchange { if (code !== undefined) { currency = this.currency (code); } - return this.parseTransactions (result, currency, since, limit); + return this.parseTransactions (result, currency, since, limit, { 'type': 'withdrawal' }); } sign (path, api = 'public', method = 'GET', params = {}, headers = undefined, body = undefined) { diff --git a/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/gateio.js b/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/gateio.js index d03f929d8..f0835c774 100644 --- a/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/gateio.js +++ b/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/gateio.js @@ -167,6 +167,7 @@ module.exports = class gateio extends Exchange { 'BOX': 'DefiBox', 'BTCBEAR': 'BEAR', 'BTCBULL': 'BULL', + 'SBTC': 'Super Bitcoin', 'TNC': 'Trinity Network Credit', }, }); @@ -690,6 +691,7 @@ module.exports = class gateio extends Exchange { 'symbol': symbol, 'type': 'limit', 'timeInForce': undefined, + 'postOnly': undefined, 'side': side, 'price': price, 'stopPrice': undefined, @@ -730,7 +732,7 @@ module.exports = class gateio extends Exchange { async cancelOrder (id, symbol = undefined, params = {}) { if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' cancelOrder requires symbol argument'); + throw new ArgumentsRequired (this.id + ' cancelOrder() requires symbol argument'); } await this.loadMarkets (); const request = { @@ -753,13 +755,13 @@ module.exports = class gateio extends Exchange { if ((address !== undefined) && (address.indexOf ('address') >= 0)) { throw new InvalidAddress (this.id + ' queryDepositAddress ' + address); } - if (code === 'XRP') { + if ((code === 'XRP') || (code === 'HBAR') || (code === 'STEEM') || (code === 'XLM') || (code === 'EOS')) { const parts = address.split (' '); address = parts[0]; tag = parts[1]; } return { - 'currency': currency, + 'currency': code, 'address': address, 'tag': tag, 'info': response, @@ -786,7 +788,7 @@ module.exports = class gateio extends Exchange { async fetchOrderTrades (id, symbol = undefined, since = undefined, limit = undefined, params = {}) { if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' fetchMyTrades requires a symbol argument'); + throw new ArgumentsRequired (this.id + ' fetchOrderTrades() requires a symbol argument'); } await this.loadMarkets (); const market = this.market (symbol); @@ -800,7 +802,7 @@ module.exports = class gateio extends Exchange { async fetchMyTrades (symbol = undefined, since = undefined, limit = undefined, params = {}) { if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' fetchMyTrades requires symbol argument'); + throw new ArgumentsRequired (this.id + ' fetchMyTrades() requires symbol argument'); } await this.loadMarkets (); const market = this.market (symbol); @@ -882,21 +884,21 @@ module.exports = class gateio extends Exchange { // withdrawal // // { - // 'id': 'w5864259', - // 'currency': 'ETH', - // 'address': '0x72632f462....', - // 'amount': '0.4947', - // 'txid': '0x111167d120f736....', - // 'timestamp': '1553123688', - // 'status': 'DONE', - // 'type': 'withdrawal' - // } + // "id": "w6754336", + // "fee": "0.1", + // "txid": "zzyy", + // "amount": "1", + // "status": "DONE", + // "address": "tz11234", + // "currency": "XTZ", + // "timestamp": "1561030206" + // } // const currencyId = this.safeString (transaction, 'currency'); const code = this.safeCurrencyCode (currencyId, currency); const id = this.safeString (transaction, 'id'); const txid = this.safeString (transaction, 'txid'); - const amount = this.safeFloat (transaction, 'amount'); + let amount = this.safeFloat (transaction, 'amount'); let address = this.safeString (transaction, 'address'); if (address === 'false') { address = undefined; @@ -904,6 +906,17 @@ module.exports = class gateio extends Exchange { const timestamp = this.safeTimestamp (transaction, 'timestamp'); const status = this.parseTransactionStatus (this.safeString (transaction, 'status')); const type = this.parseTransactionType (id[0]); + const feeCost = this.safeFloat (transaction, 'fee'); + let fee = undefined; + if (feeCost !== undefined) { + fee = { + 'currency': code, + 'cost': feeCost, + }; + if (amount !== undefined) { + amount = amount - feeCost; + } + } return { 'info': transaction, 'id': id, @@ -916,7 +929,7 @@ module.exports = class gateio extends Exchange { 'type': type, 'timestamp': timestamp, 'datetime': this.iso8601 (timestamp), - 'fee': undefined, + 'fee': fee, }; } diff --git a/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/gemini.js b/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/gemini.js index a0894c364..6f28ef220 100644 --- a/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/gemini.js +++ b/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/gemini.js @@ -669,6 +669,7 @@ module.exports = class gemini extends Exchange { 'symbol': symbol, 'type': type, 'timeInForce': undefined, + 'postOnly': undefined, 'side': side, 'price': price, 'stopPrice': undefined, @@ -732,7 +733,7 @@ module.exports = class gemini extends Exchange { async fetchMyTrades (symbol = undefined, since = undefined, limit = undefined, params = {}) { if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' fetchMyTrades requires a symbol argument'); + throw new ArgumentsRequired (this.id + ' fetchMyTrades() requires a symbol argument'); } await this.loadMarkets (); const market = this.market (symbol); diff --git a/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/gopax.js b/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/gopax.js new file mode 100644 index 000000000..e3150163a --- /dev/null +++ b/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/gopax.js @@ -0,0 +1,1347 @@ +'use strict'; + +// --------------------------------------------------------------------------- + +const Exchange = require ('./base/Exchange'); +const { ExchangeError, InvalidOrder, AuthenticationError, InsufficientFunds, BadSymbol, OrderNotFound, InvalidAddress, BadRequest } = require ('./base/errors'); +const { TRUNCATE, ROUND, TICK_SIZE } = require ('./base/functions/number'); + +// --------------------------------------------------------------------------- + +module.exports = class gopax extends Exchange { + describe () { + return this.deepExtend (super.describe (), { + 'id': 'gopax', + 'name': 'GOPAX', + 'countries': [ 'KR' ], // South Korea + 'version': 'v1', + 'rateLimit': 50, + 'hostname': 'gopax.co.kr', // or 'gopax.com' + 'certified': true, + 'pro': true, + 'has': { + 'cancelOrder': true, + 'createMarketOrder': true, + 'createOrder': true, + 'fetchBalance': true, + 'fetchCurrencies': true, + 'fetchDepositAddress': 'emulated', + 'fetchDepositAddresses': true, + 'fetchMarkets': true, + 'fetchMyTrades': true, + 'fetchOHLCV': true, + 'fetchOpenOrders': true, + 'fetchOrder': true, + 'fetchOrderBook': true, + 'fetchOrders': true, + 'fetchTicker': true, + 'fetchTickers': true, + 'fetchTime': true, + 'fetchTrades': true, + 'fetchTransactions': true, + }, + 'timeframes': { + '1m': '1', + '5m': '5', + '30m': '30', + '1d': '1440', + }, + 'urls': { + 'logo': 'https://user-images.githubusercontent.com/1294454/102897212-ae8a5e00-4478-11eb-9bab-91507c643900.jpg', + 'api': { + 'public': 'https://api.{hostname}', // or 'https://api.gopax.co.kr' + 'private': 'https://api.{hostname}', + }, + 'www': 'https://www.gopax.co.kr', + 'doc': 'https://gopax.github.io/API/index.en.html', + 'fees': 'https://www.gopax.com/feeinfo', + }, + 'api': { + 'public': { + 'get': [ + 'notices', + 'assets', + 'price-tick-size', + 'trading-pairs', + 'trading-pairs/{tradingPair}/ticker', + 'trading-pairs/{tradingPair}/book', + 'trading-pairs/{tradingPair}/trades', + 'trading-pairs/{tradingPair}/stats', + 'trading-pairs/{tradingPair}/price-tick-size', + 'trading-pairs/stats', + 'trading-pairs/{tradingPair}/candles', + 'time', + ], + }, + 'private': { + 'get': [ + 'balances', + 'balances/{assetName}', + 'orders', + 'orders/{orderId}', + 'orders/clientOrderId/{clientOrderId}', + 'trades', + 'deposit-withdrawal-status', + 'crypto-deposit-addresses', + 'crypto-withdrawal-addresses', + ], + 'post': [ + 'orders', + ], + 'delete': [ + 'orders/{orderId}', + 'orders/clientOrderId/{clientOrderId}', + ], + }, + }, + 'fees': { + 'trading': { + 'percentage': true, + 'tierBased': false, + 'maker': 0.04 / 100, + 'taker': 0.04 / 100, + }, + }, + 'exceptions': { + 'broad': { + 'ERROR_INVALID_ORDER_TYPE': InvalidOrder, + 'ERROR_INVALID_AMOUNT': InvalidOrder, + 'ERROR_INVALID_TRADING_PAIR': BadSymbol, // Unlikely to be triggered, due to ccxt.gopax.js implementation + 'No such order ID': OrderNotFound, // {"errorMessage":"No such order ID","errorCode":202,"errorData":"Order server error: 202"} + // 'Not enough amount': InsufficientFunds, // {"errorMessage":"Not enough amount, try increasing your order amount","errorCode":10212,"errorData":{}} + 'Forbidden order type': InvalidOrder, + 'the client order ID will be reusable which order has already been completed or canceled': InvalidOrder, + 'ERROR_NO_SUCH_TRADING_PAIR': BadSymbol, // Unlikely to be triggered, due to ccxt.gopax.js implementation + 'ERROR_INVALID_ORDER_SIDE': InvalidOrder, + 'ERROR_NOT_HEDGE_TOKEN_USER': InvalidOrder, + 'ORDER_EVENT_ERROR_NOT_ALLOWED_BID_ORDER': InvalidOrder, // Triggered only when the exchange is locked + 'ORDER_EVENT_ERROR_INSUFFICIENT_BALANCE': InsufficientFunds, + 'Invalid option combination': InvalidOrder, + 'No such client order ID': OrderNotFound, + }, + 'exact': { + '100': BadSymbol, // Invalid asset name + '101': BadSymbol, // Invalid trading pair + '103': InvalidOrder, // Invalid order type + '104': BadSymbol, // Invalid trading pair + '105': BadSymbol, // Trading pair temporarily disabled + '106': BadSymbol, // Invalid asset name + '107': InvalidOrder, // Invalid order amount + '108': InvalidOrder, // Invalid order price + '111': InvalidOrder, // Invalid event type + '201': InsufficientFunds, // Not enough balance + '202': InvalidOrder, // Invalid order ID + '203': InvalidOrder, // Order amount X order price too large + '204': InvalidOrder, // Bid order temporarily unavailable + '205': InvalidOrder, // Invalid side + '206': InvalidOrder, // Invalid order option combination + '10004': AuthenticationError, // Not authorized + // '10004': ExchangeError, // API key not exist + // '10004': ExchangeError, // User KYC not approved + // '10004': ExchangeError, // User account is frozen + // '10004': ExchangeError, // User is under deactivation process + // '10004': ExchangeError, // 2FA is not enabled + // '10004': ExchangeError, // Invalid signature + '10041': BadRequest, // Invalid exchange + '10056': BadRequest, // No registered asset + '10057': BadSymbol, // No registered trading pair + '10059': BadSymbol, // Invalid trading pair + '10062': BadRequest, // Invalid chart interval + '10069': OrderNotFound, // {"errorMessage":"No such order ID: 73152094","errorCode":10069,"errorData":"73152094"} + '10155': AuthenticationError, // {"errorMessage":"Invalid API key","errorCode":10155} + '10166': BadRequest, // Invalid chart range + '10212': InvalidOrder, // {"errorMessage":"Not enough amount, try increasing your order amount","errorCode":10212,"errorData":{}} + '10221': OrderNotFound, // No such client order ID + '10222': InvalidOrder, // Client order ID being used + '10223': InvalidOrder, // Soon the client order ID will be reusable which order has already been completed or canceled + '10227': InvalidOrder, // Invalid client order ID format + '10319': BadRequest, // Pagination is required as you have too many orders + '10358': InvalidOrder, // Invalid order type + '10359': InvalidOrder, // Invalid order side + '10360': InvalidOrder, // Invalid order status + '10361': InvalidOrder, // Invalid order time in force + '10362': InvalidOrder, // Invalid order protection + '10363': InvalidOrder, // Invalid forced completion reason + }, + }, + 'options': { + 'createMarketBuyOrderRequiresPrice': true, + }, + }); + } + + async fetchTime (params = {}) { + const response = await this.publicGetTime (params); + // + // {"serverTime":1608327726656} + // + return this.safeInteger (response, 'serverTime'); + } + + async fetchMarkets (params = {}) { + const response = await this.publicGetTradingPairs (params); + // + // [ + // { + // "id":1, + // "name":"ETH-KRW", + // "baseAsset":"ETH", + // "quoteAsset":"KRW", + // "baseAssetScale":8, + // "quoteAssetScale":0, + // "priceMin":1, + // "restApiOrderAmountMin":{ + // "limitAsk":{"amount":10000,"unit":"KRW"}, + // "limitBid":{"amount":10000,"unit":"KRW"}, + // "marketAsk":{"amount":0.001,"unit":"ETH"}, + // "marketBid":{"amount":10000,"unit":"KRW"}, + // }, + // "makerFeePercent":0.2, + // "takerFeePercent":0.2, + // }, + // ] + // + const result = []; + for (let i = 0; i < response.length; i++) { + const market = response[i]; + const id = this.safeString (market, 'name'); + const numericId = this.safeInteger (market, 'id'); + const baseId = this.safeString (market, 'baseAsset'); + const quoteId = this.safeString (market, 'quoteAsset'); + const base = this.safeCurrencyCode (baseId); + const quote = this.safeCurrencyCode (quoteId); + const symbol = base + '/' + quote; + const precision = { + 'price': this.safeInteger (market, 'quoteAssetScale'), + 'amount': this.safeInteger (market, 'baseAssetScale'), + }; + const minimums = this.safeValue (market, 'restApiOrderAmountMin', {}); + const marketAsk = this.safeValue (minimums, 'marketAsk', {}); + const marketBid = this.safeValue (minimums, 'marketBid', {}); + const takerFeePercent = this.safeFloat (market, 'takerFeePercent'); + const makerFeePercent = this.safeFloat (market, 'makerFeePercent'); + const taker = parseFloat (this.decimalToPrecision (takerFeePercent / 100, ROUND, 0.00000001, TICK_SIZE)); + const maker = parseFloat (this.decimalToPrecision (makerFeePercent / 100, ROUND, 0.00000001, TICK_SIZE)); + result.push ({ + 'id': id, + 'info': market, + 'numericId': numericId, + 'symbol': symbol, + 'base': base, + 'quote': quote, + 'baseId': this.safeString (market, 'baseAsset'), + 'quoteId': this.safeString (market, 'quoteAsset'), + 'active': true, + 'taker': taker, + 'maker': maker, + 'precision': precision, + 'limits': { + 'amount': { + 'min': this.safeFloat (marketAsk, 'amount'), + 'max': undefined, + }, + 'price': { + 'min': this.safeFloat (market, 'priceMin'), + 'max': undefined, + }, + 'cost': { + 'min': this.safeFloat (marketBid, 'amount'), + 'max': undefined, + }, + }, + }); + } + return result; + } + + async fetchCurrencies (params = {}) { + const response = await this.publicGetAssets (params); + // + // [ + // { + // "id":"KRW", + // "name":"대한민국 원", + // "scale":0, + // "withdrawalFee":1000, + // "withdrawalAmountMin":5000 + // }, + // { + // "id":"ETH", + // "name":"이더리움", + // "scale":8, + // "withdrawalFee":0.03, + // "withdrawalAmountMin":0.015 + // }, + // ] + // + const result = {}; + for (let i = 0; i < response.length; i++) { + const currency = response[i]; + const id = this.safeString (currency, 'id'); + const code = this.safeCurrencyCode (id); + const name = this.safeString (currency, 'name'); + const fee = this.safeFloat (currency, 'withdrawalFee'); + const precision = this.safeFloat (currency, 'scale'); + result[code] = { + 'id': id, + 'info': currency, + 'code': code, + 'name': name, + 'active': true, + 'fee': fee, + 'precision': precision, + 'limits': { + 'amount': { + 'min': undefined, + 'max': undefined, + }, + 'price': { + 'min': undefined, + 'max': undefined, + }, + 'cost': { + 'min': undefined, + 'max': undefined, + }, + 'withdraw': { + 'min': this.safeFloat (currency, 'withdrawalAmountMin'), + 'max': undefined, + }, + }, + }; + } + return result; + } + + async fetchOrderBook (symbol, limit = undefined, params = {}) { + await this.loadMarkets (); + const market = this.market (symbol); + const request = { + 'tradingPair': market['id'], + // 'level': 3, // 1 best bidask, 2 top 50 bidasks, 3 all bidasks + }; + const response = await this.publicGetTradingPairsTradingPairBook (this.extend (request, params)); + // + // { + // "sequence":17691957, + // "bid":[ + // ["17690499",25019000,0.00008904,"1608326468921"], + // ["17691894",25010000,0.4295,"1608326499940"], + // ["17691895",25009000,0.2359,"1608326499953"], + // ], + // "ask":[ + // ["17689176",25024000,0.000098,"1608326442006"], + // ["17691351",25031000,0.206,"1608326490418"], + // ["17691571",25035000,0.3996,"1608326493742"], + // ] + // } + // + const nonce = this.safeInteger (response, 'sequence'); + const result = this.parseOrderBook (response, undefined, 'bid', 'ask', 1, 2); + result['nonce'] = nonce; + return result; + } + + parseTicker (ticker, market = undefined) { + // + // fetchTicker + // + // { + // "price":25087000, + // "ask":25107000, + // "askVolume":0.05837704, + // "bid":25087000, + // "bidVolume":0.00398628, + // "volume":350.09171591, + // "quoteVolume":8721016926.06529, + // "time":"2020-12-18T21:42:13.774Z", + // } + // + // fetchTickers + // + // { + // "name":"ETH-KRW", + // "open":690500, + // "high":719500, + // "low":681500, + // "close":709500, + // "volume":2784.6081544, + // "time":"2020-12-18T21:54:50.795Z" + // } + // + const marketId = this.safeString (ticker, 'name'); + const symbol = this.safeSymbol (marketId, market, '-'); + const timestamp = this.parse8601 (this.safeString (ticker, 'time')); + const open = this.safeFloat (ticker, 'open'); + const last = this.safeFloat2 (ticker, 'price', 'close'); + let change = undefined; + let percentage = undefined; + let average = undefined; + if ((last !== undefined) && (open !== undefined)) { + average = this.sum (last, open) / 2; + change = last - open; + if (open > 0) { + percentage = change / open * 100; + } + } + const baseVolume = this.safeFloat (ticker, 'volume'); + const quoteVolume = this.safeFloat (ticker, 'quoteVolume'); + const vwap = this.vwap (baseVolume, quoteVolume); + return { + 'symbol': symbol, + 'info': ticker, + 'timestamp': timestamp, + 'datetime': this.iso8601 (timestamp), + 'high': this.safeFloat (ticker, 'high'), + 'low': this.safeFloat (ticker, 'low'), + 'bid': this.safeFloat (ticker, 'bid'), + 'bidVolume': this.safeFloat (ticker, 'bidVolume'), + 'ask': this.safeFloat (ticker, 'ask'), + 'askVolume': this.safeFloat (ticker, 'askVolume'), + 'vwap': vwap, + 'open': open, + 'close': last, + 'last': last, + 'previousClose': undefined, + 'change': change, + 'percentage': percentage, + 'average': average, + 'baseVolume': baseVolume, + 'quoteVolume': quoteVolume, + }; + } + + async fetchTicker (symbol, params = {}) { + await this.loadMarkets (); + const market = this.market (symbol); + const request = { + 'tradingPair': market['id'], + }; + const response = await this.publicGetTradingPairsTradingPairTicker (this.extend (request, params)); + // + // { + // "price":25087000, + // "ask":25107000, + // "askVolume":0.05837704, + // "bid":25087000, + // "bidVolume":0.00398628, + // "volume":350.09171591, + // "quoteVolume":8721016926.06529, + // "time":"2020-12-18T21:42:13.774Z", + // } + // + return this.parseTicker (response, market); + } + + parseTickers (rawTickers, symbols = undefined) { + const tickers = []; + for (let i = 0; i < rawTickers.length; i++) { + tickers.push (this.parseTicker (rawTickers[i])); + } + return this.filterByArray (tickers, 'symbol', symbols); + } + + async fetchTickers (symbols = undefined, params = {}) { + await this.loadMarkets (); + const response = await this.publicGetTradingPairsStats (params); + // + // [ + // { + // "name":"ETH-KRW", + // "open":690500, + // "high":719500, + // "low":681500, + // "close":709500, + // "volume":2784.6081544, + // "time":"2020-12-18T21:54:50.795Z" + // } + // ] + // + return this.parseTickers (response, symbols); + } + + parsePublicTrade (trade, market = undefined) { + const timestamp = this.parse8601 (this.safeString (trade, 'time')); + const price = this.safeFloat (trade, 'price'); + const amount = this.safeFloat (trade, 'amount'); + let symbol = undefined; + if ('symbol' in market) { + symbol = this.safeString (market, 'symbol'); + } + return { + 'info': trade, + 'id': this.safeString (trade, 'id'), + 'timestamp': timestamp, + 'datetime': this.iso8601 (timestamp), + 'symbol': symbol, + 'order': undefined, // Not mandatory to specify + 'type': undefined, // Not mandatory to specify + 'side': this.safeString (trade, 'side'), + 'takerOrMaker': undefined, + 'price': price, + 'amount': amount, + 'cost': price * amount, + 'fee': undefined, + }; + } + + parsePrivateTrade (trade, market = undefined) { + const timestamp = this.parse8601 (this.safeString (trade, 'timestamp')); + const symbol = this.safeString (trade, 'tradingPairName').replace ('-', '/'); + const side = this.safeString (trade, 'side'); + const price = this.safeFloat (trade, 'price'); + const amount = this.safeFloat (trade, 'baseAmount'); + let feeCurrency = symbol.slice (0, 3); + if (side === 'sell') { + feeCurrency = symbol.slice (4); + } + const fee = { + 'cost': this.safeFloat (trade, 'fee'), + 'currency': feeCurrency, + 'rate': undefined, + }; + return { + 'info': trade, + 'id': this.safeString (trade, 'id'), + 'timestamp': timestamp, + 'datetime': this.iso8601 (timestamp), + 'symbol': symbol, + 'order': this.safeInteger (trade, 'orderId'), + 'type': undefined, + 'side': side, + 'takerOrMaker': this.safeString (trade, 'position'), + 'price': price, + 'amount': amount, + 'cost': price * amount, + 'fee': fee, + }; + } + + parseTrade (trade, market = undefined) { + // + // public fetchTrades + // + // { + // "time":"2020-12-19T12:17:43.000Z", + // "date":1608380263, + // "id":23903608, + // "price":25155000, + // "amount":0.0505, + // "side":"sell", + // } + // + // private fetchMyTrades + // + // { + // "id": 73953, // trading event ID + // "orderId": 453324, // order ID + // "baseAmount": 3, // traded base asset amount + // "quoteAmount": 3000000, // traded quote asset amount + // "fee": 0.0012, // fee + // "price": 1000000, // price + // "timestamp": "2020-09-25T04:06:30.000Z", // trading time + // "side": "buy", // buy, sell + // "tradingPairName": "ZEC-KRW", // order book + // "position": "maker" // maker, taker + // } + // + // { + // "tradeId": 74072, // trade ID + // "orderId": 453529, // order ID + // "side": 2, // 1(bid), 2(ask) + // "type": 1, // 1(limit), 2(market) + // "baseAmount": 0.01, // filled base asset amount (in ZEC for this case) + // "quoteAmount": 1, // filled quote asset amount (in KRW for this case) + // "fee": 0.0004, // fee + // "price": 100, // price + // "isSelfTrade": false, // whether both of matching orders are yours + // "occurredAt": 1603932107, // trade occurrence time + // "tradingPairName": "ZEC-KRW" // order book + // } + // + const id = this.safeString2 (trade, 'id', 'tradeId'); + const orderId = this.safeInteger (trade, 'orderId'); + let timestamp = this.parse8601 (this.safeString2 (trade, 'time', 'timestamp')); + timestamp = this.safeTimestamp (trade, 'occuredAt', timestamp); + const marketId = this.safeString (trade, 'tradingPairName'); + market = this.safeMarket (marketId, market, '-'); + const symbol = market['symbol']; + let side = this.safeString (trade, 'side'); + if (side === '1') { + side = 'buy'; + } else if (side === '2') { + side = 'sell'; + } + let type = this.safeString (trade, 'type'); + if (type === '1') { + type = 'limit'; + } else if (type === '2') { + type = 'market'; + } + const price = this.safeFloat (trade, 'price'); + const amount = this.safeFloat2 (trade, 'amount', 'baseAmount'); + let cost = this.safeFloat (trade, 'quoteAmount'); + if (cost === undefined) { + if ((price !== undefined) && (amount !== undefined)) { + cost = price * amount; + } + } + const feeCost = this.safeFloat (trade, 'fee'); + let fee = undefined; + if (feeCost !== undefined) { + fee = { + 'cost': feeCost, + 'currency': market['base'], + }; + } + const takerOrMaker = this.safeString (trade, 'position'); + return { + 'info': trade, + 'id': id, + 'timestamp': timestamp, + 'datetime': this.iso8601 (timestamp), + 'symbol': symbol, + 'order': orderId, + 'type': undefined, + 'side': side, + 'takerOrMaker': takerOrMaker, + 'price': price, + 'amount': amount, + 'cost': cost, + 'fee': fee, + }; + } + + async fetchTrades (symbol, since = undefined, limit = undefined, params = {}) { + await this.loadMarkets (); + const market = this.market (symbol); + const request = { + 'tradingPair': market['id'], + // 'limit': limit, + // 'pastmax': id, // read data older than this ID + // 'latestmin': id, // read data newer than this ID + // 'after': parseInt (since / 1000), + // 'before': this.seconds (), + }; + if (since !== undefined) { + request['after'] = parseInt (since / 1000); + } + if (limit !== undefined) { + request['limit'] = limit; + } + const response = await this.publicGetTradingPairsTradingPairTrades (this.extend (request, params)); + // + // [ + // {"time":"2020-12-19T12:17:43.000Z","date":1608380263,"id":23903608,"price":25155000,"amount":0.0505,"side":"sell"}, + // {"time":"2020-12-19T12:17:13.000Z","date":1608380233,"id":23903604,"price":25140000,"amount":0.019,"side":"sell"}, + // {"time":"2020-12-19T12:16:49.000Z","date":1608380209,"id":23903599,"price":25140000,"amount":0.0072,"side":"sell"}, + // ] + // + return this.parseTrades (response, market, since, limit); + } + + parseOHLCV (ohlcv, market = undefined) { + // + // [ + // 1606780800000, // timestamp + // 21293000, // low + // 21300000, // high + // 21294000, // open + // 21300000, // close + // 1.019126, // volume + // ] + // + return [ + this.safeInteger (ohlcv, 0), + this.safeFloat (ohlcv, 3), + this.safeFloat (ohlcv, 2), + this.safeFloat (ohlcv, 1), + this.safeFloat (ohlcv, 4), + this.safeFloat (ohlcv, 5), + ]; + } + + async fetchOHLCV (symbol, timeframe = '1m', since = undefined, limit = undefined, params = {}) { + await this.loadMarkets (); + const market = this.market (symbol); + limit = (limit === undefined) ? 1024 : limit; // default 1024 + const request = { + 'tradingPair': market['id'], + // 'start': since, + // 'end': this.milliseconds (), + 'interval': this.timeframes[timeframe], + }; + const duration = this.parseTimeframe (timeframe); + if (since === undefined) { + const end = this.milliseconds (); + request['end'] = end; + request['start'] = end - limit * duration * 1000; + } else { + request['start'] = since; + request['end'] = this.sum (since, limit * duration * 1000); + } + const response = await this.publicGetTradingPairsTradingPairCandles (this.extend (request, params)); + // + // [ + // [1606780800000,21293000,21300000,21294000,21300000,1.019126], + // [1606780860000,21237000,21293000,21293000,21263000,0.96800057], + // [1606780920000,21240000,21240000,21240000,21240000,0.11068715], + // ] + // + return this.parseOHLCVs (response, market, timeframe, since, limit); + } + + parseBalanceResponse (response) { + const result = { 'info': response }; + for (let i = 0; i < response.length; i++) { + const balance = response[i]; + const currencyId = this.safeString2 (balance, 'asset', 'isoAlpha3'); + const code = this.safeCurrencyCode (currencyId); + const hold = this.safeFloat (balance, 'hold'); + const pendingWithdrawal = this.safeFloat (balance, 'pendingWithdrawal'); + const account = this.account (); + account['free'] = this.safeFloat (balance, 'avail'); + account['used'] = this.sum (hold, pendingWithdrawal); + result[code] = account; + } + return this.parseBalance (result); + } + + async fetchBalance (params = {}) { + await this.loadMarkets (); + const response = await this.privateGetBalances (params); + // + // [ + // { + // "asset": "KRW", // asset name + // "avail": 1759466.76, // available amount to place order + // "hold": 16500, // outstanding amount on order books + // "pendingWithdrawal": 0, // amount being withdrawn + // "lastUpdatedAt": "1600684352032", // balance last update time + // }, + // ] + // + return this.parseBalanceResponse (response); + } + + parseOrderStatus (status) { + const statuses = { + 'placed': 'open', + 'cancelled': 'canceled', + 'completed': 'closed', + 'updated': 'open', + 'reserved': 'open', + }; + return this.safeString (statuses, status, status); + } + + parseOrder (order, market = undefined) { + // + // cancelOrder + // + // {} // empty object + // + // fetchOrder, fetchOrders, fetchOpenOrders, createOrder + // + // { + // "id": "453324", // order ID + // "clientOrderId": "zeckrw23456", // client order ID (showed only when it exists) + // "status": "updated", // placed, cancelled, completed, updated, reserved + // "forcedCompletionReason": undefined, // the reason in case it was canceled in the middle (protection or timeInForce) + // "tradingPairName": "ZEC-KRW", // order book + // "side": "buy", // buy, sell + // "type": "limit", // limit, market + // "price": 1000000, // price + // "stopPrice": undefined, // stop price (showed only for stop orders) + // "amount": 4, // initial amount + // "remaining": 1, // outstanding amount + // "protection": "yes", // whether protection is activated (yes or no) + // "timeInForce": "gtc", // limit order's time in force (gtc/po/ioc/fok) + // "createdAt": "2020-09-25T04:06:20.000Z", // order placement time + // "updatedAt": "2020-09-25T04:06:29.000Z", // order last update time + // "balanceChange": { + // "baseGross": 3, // base asset balance's gross change (in ZEC for this case) + // "baseFee": { + // "taking": 0, // base asset fee imposed as taker + // "making": -0.0012 // base asset fee imposed as maker + // }, + // "baseNet": 2.9988, // base asset balance's net change (in ZEC for this case) + // "quoteGross": -3000000, // quote asset balance's gross change (in KRW for + // "quoteFee": { + // "taking": 0, // quote asset fee imposed as taker + // "making": 0 // quote asset fee imposed as maker + // }, + // "quoteNet": -3000000 // quote asset balance's net change (in KRW for this case) + // } + // } + // + const id = this.safeString (order, 'id'); + const clientOrderId = this.safeString (order, 'clientOrderId'); + const timestamp = this.parse8601 (this.safeString (order, 'createdAt')); + const type = this.safeString (order, 'type'); + const side = this.safeString (order, 'side'); + const timeInForce = this.safeStringUpper (order, 'timeInForce'); + const price = this.safeFloat (order, 'price'); + const amount = this.safeFloat (order, 'amount'); + const stopPrice = this.safeFloat (order, 'stopPrice'); + const remaining = this.safeFloat (order, 'remaining'); + const marketId = this.safeString (order, 'tradingPairName'); + market = this.safeMarket (marketId, market, '-'); + const status = this.parseOrderStatus (this.safeString (order, 'status')); + const balanceChange = this.safeValue (order, 'balanceChange', {}); + let filled = this.safeFloat (balanceChange, 'baseNet'); + let cost = this.safeFloat (balanceChange, 'quoteNet'); + if (cost !== undefined) { + cost = Math.abs (cost); + } + let updated = undefined; + if ((filled === undefined) && (amount !== undefined) && (remaining !== undefined)) { + filled = Math.max (0, amount - remaining); + } + if ((filled !== undefined) && (filled > 0)) { + updated = this.parse8601 (this.safeString (order, 'updatedAt')); + } + if ((cost === undefined) && (price !== undefined) && (filled !== undefined)) { + cost = filled * price; + } + let fee = undefined; + if (side === 'buy') { + const baseFee = this.safeValue (balanceChange, 'baseFee', {}); + const taking = this.safeFloat (baseFee, 'taking'); + const making = this.safeFloat (baseFee, 'making'); + fee = { + 'currency': market['base'], + 'cost': this.sum (taking, making), + }; + } else { + const quoteFee = this.safeValue (balanceChange, 'quoteFee', {}); + const taking = this.safeFloat (quoteFee, 'taking'); + const making = this.safeFloat (quoteFee, 'making'); + fee = { + 'currency': market['quote'], + 'cost': this.sum (taking, making), + }; + } + let postOnly = undefined; + if (timeInForce !== undefined) { + postOnly = (timeInForce === 'PO'); + } + return { + 'id': id, + 'clientOrderId': clientOrderId, + 'datetime': this.iso8601 (timestamp), + 'timestamp': timestamp, + 'lastTradeTimestamp': updated, + 'status': status, + 'symbol': market['symbol'], + 'type': type, + 'timeInForce': timeInForce, + 'postOnly': postOnly, + 'side': side, + 'price': price, + 'stopPrice': stopPrice, + 'average': undefined, + 'amount': amount, + 'filled': filled, + 'remaining': remaining, + 'cost': cost, + 'trades': undefined, + 'fee': fee, + 'info': order, + }; + } + + async fetchOrder (id, symbol = undefined, params = {}) { + await this.loadMarkets (); + let method = undefined; + const clientOrderId = this.safeString (params, 'clientOrderId'); + params = this.omit (params, 'clientOrderId'); + const request = {}; + if (clientOrderId === undefined) { + method = 'privateGetOrdersOrderId'; + request['orderId'] = id; + } else { + method = 'privateGetOrdersClientOrderIdClientOrderId'; + request['clientOrderId'] = clientOrderId; + } + const response = await this[method] (this.extend (request, params)); + // + // { + // "id": "453324", // order ID + // "clientOrderId": "zeckrw23456", // client order ID (showed only when it exists) + // "status": "updated", // placed, cancelled, completed, updated, reserved + // "forcedCompletionReason": undefined, // the reason in case it was canceled in the middle (protection or timeInForce) + // "tradingPairName": "ZEC-KRW", // order book + // "side": "buy", // buy, sell + // "type": "limit", // limit, market + // "price": 1000000, // price + // "stopPrice": undefined, // stop price (showed only for stop orders) + // "amount": 4, // initial amount + // "remaining": 1, // outstanding amount + // "protection": "yes", // whether protection is activated (yes or no) + // "timeInForce": "gtc", // limit order's time in force (gtc/po/ioc/fok) + // "createdAt": "2020-09-25T04:06:20.000Z", // order placement time + // "updatedAt": "2020-09-25T04:06:29.000Z", // order last update time + // "balanceChange": { + // "baseGross": 3, // base asset balance's gross change (in ZEC for this case) + // "baseFee": { + // "taking": 0, // base asset fee imposed as taker + // "making": -0.0012 // base asset fee imposed as maker + // }, + // "baseNet": 2.9988, // base asset balance's net change (in ZEC for this case) + // "quoteGross": -3000000, // quote asset balance's gross change (in KRW for + // "quoteFee": { + // "taking": 0, // quote asset fee imposed as taker + // "making": 0 // quote asset fee imposed as maker + // }, + // "quoteNet": -3000000 // quote asset balance's net change (in KRW for this case) + // } + // } + // + return this.parseOrder (response); + } + + async fetchOrders (symbol = undefined, since = undefined, limit = undefined, params = {}) { + await this.loadMarkets (); + const request = { + 'includePast': 'true', // if true, completed and canceled orders are included as the result, they are accessible for one hour only from its completion or cancellation time + // 'pagination': 'false', // if the result is more than 3,000 orders, set this value as true to access 1000 orders at max per each page + }; + let market = undefined; + if (symbol !== undefined) { + market = this.market (symbol); + } + const response = await this.privateGetOrders (this.extend (request, params)); + // + // [ + // { + // "id": "453324", // order ID + // "clientOrderId": "zeckrw23456", // client order ID (showed only when it exists) + // "status": "updated", // placed, cancelled, completed, updated, reserved + // "forcedCompletionReason": undefined, // the reason in case it was canceled in the middle (protection or timeInForce) + // "tradingPairName": "ZEC-KRW", // order book + // "side": "buy", // buy, sell + // "type": "limit", // limit, market + // "price": 1000000, // price + // "stopPrice": undefined, // stop price (showed only for stop orders) + // "amount": 4, // initial amount + // "remaining": 1, // outstanding amount + // "protection": "yes", // whether protection is activated (yes or no) + // "timeInForce": "gtc", // limit order's time in force (gtc/po/ioc/fok) + // "createdAt": "2020-09-25T04:06:20.000Z", // order placement time + // "updatedAt": "2020-09-25T04:06:29.000Z", // order last update time + // "balanceChange": { + // "baseGross": 3, // base asset balance's gross change (in ZEC for this case) + // "baseFee": { + // "taking": 0, // base asset fee imposed as taker + // "making": -0.0012 // base asset fee imposed as maker + // }, + // "baseNet": 2.9988, // base asset balance's net change (in ZEC for this case) + // "quoteGross": -3000000, // quote asset balance's gross change (in KRW for + // "quoteFee": { + // "taking": 0, // quote asset fee imposed as taker + // "making": 0 // quote asset fee imposed as maker + // }, + // "quoteNet": -3000000 // quote asset balance's net change (in KRW for this case) + // } + // }, + // ] + // + return this.parseOrders (response, market, since, limit); + } + + async fetchOpenOrders (symbol = undefined, since = undefined, limit = undefined, params = {}) { + const request = { + 'includePast': 'false', + }; + return await this.fetchOrders (symbol, since, limit, this.extend (request, params)); + } + + async createOrder (symbol, type, side, amount, price = undefined, params = {}) { + await this.loadMarkets (); + const market = this.market (symbol); + const request = { + // 'clientOrderId': 'test4321', // max 20 characters of [a-zA-Z0-9_-] + 'tradingPairName': market['id'], + 'side': side, // buy, sell + 'type': type, // limit, market + // 'price': this.priceToPrecision (symbol, price), + // 'stopPrice': this.priceToPrecision (symbol, stopPrice), // optional, becomes a stop order if set + // 'amount': this.amountToPrecision (symbol, amount), + // 'protection': 'no', // whether protection is activated + // 'timeInForce': 'gtc', // gtc, po, ioc, fok + }; + if (type === 'limit') { + request['price'] = this.priceToPrecision (symbol, price); + request['amount'] = this.amountToPrecision (symbol, amount); + } else if (type === 'market') { + // for market buy it requires the amount of quote currency to spend + if (side === 'buy') { + let total = amount; + const createMarketBuyOrderRequiresPrice = this.safeValue (this.options, 'createMarketBuyOrderRequiresPrice', true); + if (createMarketBuyOrderRequiresPrice) { + if (price === undefined) { + throw new InvalidOrder (this.id + " createOrder() requires the price argument with market buy orders to calculate total order cost (amount to spend), where cost = amount * price. Supply a price argument to createOrder() call if you want the cost to be calculated for you from price and amount, or, alternatively, add .options['createMarketBuyOrderRequiresPrice'] = false and supply the total cost value in the 'amount' argument"); + } + total = price * amount; + } + const precision = market['precision']['price']; + request['amount'] = this.decimalToPrecision (total, TRUNCATE, precision, this.precisionMode); + } else { + request['amount'] = this.amountToPrecision (symbol, amount); + } + } + const clientOrderId = this.safeString (params, 'clientOrderId'); + if (clientOrderId !== undefined) { + request['clientOrderId'] = clientOrderId; + params = this.omit (params, 'clientOrderId'); + } + const stopPrice = this.safeFloat (params, 'stopPrice'); + if (stopPrice !== undefined) { + request['stopPrice'] = this.priceToPrecision (symbol, stopPrice); + params = this.omit (params, 'stopPrice'); + } + const timeInForce = this.safeStringLower (params, 'timeInForce'); + if (timeInForce !== undefined) { + request['timeInForce'] = timeInForce; + params = this.omit (params, 'timeInForce'); + } + const response = await this.privatePostOrders (this.extend (request, params)); + // + // { + // "id": "453327", // order ID + // "clientOrderId": "test4321", // client order ID (showed only when it exists) + // "status": "reserved", // placed, cancelled, completed, updated, reserved + // "forcedCompletionReason": undefined, // the reason in case it was canceled in the middle (protection or timeInForce) + // "tradingPairName": "BCH-KRW", // order book + // "side": "sell", // buy, sell + // "type": "limit", // limit, market + // "price": 11000000, // price + // "stopPrice": 12000000, // stop price (showed only for stop orders) + // "amount": 0.5, // initial amount + // "remaining": 0.5, // outstanding amount + // "protection": "no", // whether protection is activated (yes or no) + // "timeInForce": "gtc", // limit order's time in force (gtc/po/ioc/fok) + // "createdAt": "2020-09-25T04:51:31.000Z", // order placement time + // "balanceChange": { + // "baseGross": 0, // base asset balance's gross change (in BCH for this case) + // "baseFee": { + // "taking": 0, // base asset fee imposed as taker + // "making": 0 // base asset fee imposed as maker + // }, + // "baseNet": 0, // base asset balance's net change (in BCH for this case) + // "quoteGross": 0, // quote asset balance's gross change (in KRW for + // "quoteFee": { + // "taking": 0, // quote asset fee imposed as taker + // "making": 0 // quote asset fee imposed as maker + // }, + // "quoteNet": 0 // quote asset balance's net change (in KRW for this case) + // } + // } + // + return this.parseOrder (response, market); + } + + async cancelOrder (id, symbol = undefined, params = {}) { + await this.loadMarkets (); + const request = {}; + const clientOrderId = this.safeString (params, 'clientOrderId'); + let method = undefined; + if (clientOrderId === undefined) { + method = 'privateDeleteOrdersOrderId'; + request['orderId'] = id; + } else { + method = 'privateDeleteOrdersClientOrderIdClientOrderId'; + request['clientOrderId'] = clientOrderId; + params = this.omit (params, 'clientOrderId'); + } + const response = await this[method] (this.extend (request, params)); + // + // {} + // + const order = this.parseOrder (response); + return this.extend (order, { 'id': id }); + } + + async fetchMyTrades (symbol = undefined, since = undefined, limit = undefined, params = {}) { + await this.loadMarkets (); + const request = { + // 'limit': limit, // max 100 + // 'pastmax': id, // read data older than this id + // 'latestmin': id, // read data newer than this id + // 'after': parseInt (since / 1000), // Read data after this timestamp in seconds + // 'before': this.seconds (), // Read data before this timestamp in seconds + 'deepSearch': 'true', // read data older than one month ago are inclusively looked up only when it is "true" + }; + if (since !== undefined) { + request['after'] = parseInt (since / 1000); + } + if (limit !== undefined) { + request['limit'] = limit; + } + const response = await this.privateGetTrades (this.extend (request, params)); + // + // [ + // { + // "id": 73953, // trading event ID + // "orderId": 453324, // order ID + // "baseAmount": 3, // traded base asset amount + // "quoteAmount": 3000000, // traded quote asset amount + // "fee": 0.0012, // fee + // "price": 1000000, // price + // "timestamp": "2020-09-25T04:06:30.000Z", // trading time + // "side": "buy", // buy, sell + // "tradingPairName": "ZEC-KRW", // order book + // "position": "maker" // maker, taker + // }, + // ] + // + let market = undefined; + if (symbol !== undefined) { + market = this.market (symbol); + } + return this.parseTrades (response, market, since, limit); + } + + parseDepositAddress (depositAddress, currency = undefined) { + // + // { + // "asset": "BTC", // asset name + // "address": "1CwC2cMFu1jRQUBtw925cENbT1kctJBMdm", // deposit address + // "memoId": null, // memo ID (showed only for assets using memo ID) + // "createdAt": 1594802312 // deposit address creation time + // } + // + const address = this.safeString (depositAddress, 'address'); + const tag = this.safeString (depositAddress, 'memoId'); + const currencyId = this.safeString (depositAddress, 'asset'); + const code = this.safeCurrencyCode (currencyId); + this.checkAddress (address); + return { + 'currency': code, + 'address': address, + 'tag': tag, + 'info': depositAddress, + }; + } + + parseDepositAddresses (addresses, codes = undefined) { + let result = []; + for (let i = 0; i < addresses.length; i++) { + const address = this.parseDepositAddress (addresses[i]); + result.push (address); + } + if (codes) { + result = this.filterByArray (result, 'currency', codes); + } + return this.indexBy (result, 'currency'); + } + + async fetchDepositAddresses (codes = undefined, params = {}) { + await this.loadMarkets (); + const response = await this.privateGetCryptoDepositAddresses (params); + // + // [ + // { + // "asset": "BTC", // asset name + // "address": "1CwC2cMFu1jRQUBtw925cENbT1kctJBMdm", // deposit address + // "memoId": null, // memo ID (showed only for assets using memo ID) + // "createdAt": 1594802312 // deposit address creation time + // }, + // ] + // + return this.parseDepositAddresses (response, codes); + } + + async fetchDepositAddress (code, params = {}) { + await this.loadMarkets (); + const response = await this.fetchDepositAddresses (undefined, params); + const address = this.safeValue (response, code); + if (address === undefined) { + throw new InvalidAddress (this.id + ' fetchDepositAddress() ' + code + ' address not found'); + } + return address; + } + + parseTransactionStatus (status) { + const statuses = { + 'reviewing': 'pending', + 'rejected': 'rejected', + 'processing': 'pending', + 'failed': 'failed', + 'completed': 'ok', + }; + return this.safeString (statuses, status, status); + } + + parseTransaction (transaction, currency = undefined) { + // + // { + // "id": 640, // deposit/withdrawal event ID + // "asset": "BTC", // asset name + // "type": "crypto_withdrawal", // fiat_withdrawal, fiat_deposit, crypto_withdrawal, crypto_deposit + // "netAmount": 0.0001, // amount + // "feeAmount": 0.0005, // fee (null if there is no imposed fee) + // "status": "completed", // reviewing, rejected, processing, failed, completed + // "reviewStartedAt": 1595556218, // request time + // "completedAt": 1595556902, // completion time (showed only in case of completed) + // "txId": "eaca5ad3...", // tx ID + // "sourceAddress": null, // sender address (showed only in case of crypto_deposit) + // "destinationAddress: "3H8...", // recipient address (showed only in case of crypto_withdrawal) + // "destinationMemoId": null // recipient address's memo ID + // } + // + const id = this.safeString (transaction, 'id'); + const txid = this.safeString (transaction, 'txId'); + const currencyId = this.safeString (transaction, 'asset'); + const code = this.safeCurrencyCode (currencyId, currency); + let type = this.safeString (transaction, 'type'); + if ((type === 'crypto_withdrawal') || (type === 'fiat_withdrawal')) { + type = 'withdrawal'; + } else if ((type === 'crypto_deposit' || type === 'fiat_deposit')) { + type = 'deposit'; + } + const amount = this.safeFloat (transaction, 'netAmount'); + const feeCost = this.safeFloat (transaction, 'feeAmount'); + let fee = undefined; + if (feeCost !== undefined) { + fee = { + 'cost': feeCost, + 'currency': code, + }; + } + const timestamp = this.safeTimestamp (transaction, 'reviewStartedAt'); + const updated = this.safeTimestamp (transaction, 'completedAt'); + const addressFrom = this.safeString (transaction, 'sourceAddress'); + const addressTo = this.safeString (transaction, 'destinationAddress'); + const tagFrom = this.safeString (transaction, 'sourceMemoId'); + const tagTo = this.safeString (transaction, 'destinationMemoId'); + const status = this.parseTransactionStatus (this.safeString (transaction, 'status')); + return { + 'info': transaction, + 'id': id, + 'txid': txid, + 'timestamp': timestamp, + 'datetime': this.iso8601 (timestamp), + 'addressFrom': addressFrom, + 'address': addressTo, + 'addressTo': addressTo, + 'tagFrom': tagFrom, + 'tag': tagTo, + 'tagTo': tagTo, + 'type': type, + 'amount': amount, + 'currency': code, + 'status': status, + 'updated': updated, + 'comment': undefined, + 'fee': fee, + }; + } + + async fetchTransactions (code = undefined, since = undefined, limit = undefined, params = {}) { + await this.loadMarkets (); + const request = { + // 'limit': limit, // max 20 + // 'latestmin': limit, // read data older than this id + // 'after': this.milliseconds (), + // 'before': since, + // 'completedOnly': 'no', + }; + if (since !== undefined) { + request['before'] = since; + } + if (limit !== undefined) { + request['limit'] = limit; + } + const response = await this.privateGetDepositWithdrawalStatus (this.extend (request, params)); + // + // [ + // { + // "id": 640, // deposit/withdrawal event ID + // "asset": "BTC", // asset name + // "type": "crypto_withdrawal", // fiat_withdrawal, fiat_deposit, crypto_withdrawal, crypto_deposit + // "netAmount": 0.0001, // amount + // "feeAmount": 0.0005, // fee (null if there is no imposed fee) + // "status": "completed", // reviewing, rejected, processing, failed, completed + // "reviewStartedAt": 1595556218, // request time + // "completedAt": 1595556902, // completion time (showed only in case of completed) + // "txId": "eaca5ad3...", // tx ID + // "sourceAddress": null, // sender address (showed only in case of crypto_deposit) + // "destinationAddress: "3H8...", // recipient address (showed only in case of crypto_withdrawal) + // "destinationMemoId": null // recipient address's memo ID + // }, + // ] + // + let currency = undefined; + if (code !== undefined) { + currency = this.currency (code); + } + return this.parseTransactions (response, currency, since, limit, params); + } + + nonce () { + return this.milliseconds (); + } + + sign (path, api = 'public', method = 'GET', params = {}, headers = undefined, body = undefined) { // for authentication in private API calls + const endpoint = '/' + this.implodeParams (path, params); + let url = this.implodeParams (this.urls['api'][api], { 'hostname': this.hostname }) + endpoint; + const query = this.omit (params, this.extractParams (path)); + if (api === 'public') { + if (Object.keys (query).length) { + url += '?' + this.urlencode (query); + } + } else if (api === 'private') { + this.checkRequiredCredentials (); + const timestamp = this.nonce ().toString (); + let auth = 't' + timestamp + method + endpoint; + headers = { + 'api-key': this.apiKey, + 'timestamp': timestamp, + }; + if (method === 'POST') { + headers['Content-Type'] = 'application/json'; + body = this.json (params); + auth += body; + } else if (endpoint === '/orders') { + if (Object.keys (query).length) { + const urlQuery = '?' + this.urlencode (query); + auth += urlQuery; + url += urlQuery; + } + } else if (method === 'GET') { + if (Object.keys (query).length) { + url += '?' + this.urlencode (query); + } + } + const rawSecret = this.base64ToBinary (this.secret); + const signature = this.hmac (this.encode (auth), rawSecret, 'sha512', 'base64'); + headers['signature'] = signature; + } + return { 'url': url, 'method': method, 'body': body, 'headers': headers }; + } + + handleErrors (code, reason, url, method, headers, body, response, requestHeaders, requestBody) { + if (response === undefined) { + return; + } + // + // {"errorMessage":"Invalid API key","errorCode":10155} + // + if (!Array.isArray (response)) { + const errorCode = this.safeString (response, 'errorCode'); + const errorMessage = this.safeString (response, 'errorMessage'); + const feedback = this.id + ' ' + body; + if (errorMessage !== undefined) { + this.throwBroadlyMatchedException (this.exceptions['broad'], body, feedback); + } + if (errorCode !== undefined) { + this.throwExactlyMatchedException (this.exceptions['exact'], errorCode, feedback); + } + if ((errorCode !== undefined) || (errorMessage !== undefined)) { + throw new ExchangeError (feedback); + } + } + } +}; diff --git a/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/hbtc.js b/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/hbtc.js index d7bde5c6c..d819c3d77 100644 --- a/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/hbtc.js +++ b/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/hbtc.js @@ -841,7 +841,7 @@ module.exports = class hbtc extends Exchange { method = 'optionGetMyTrades'; } else { if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' fetchMyTrades requires a `symbol` argument for ' + type + ' markets'); + throw new ArgumentsRequired (this.id + ' fetchMyTrades() requires a `symbol` argument for ' + type + ' markets'); } const market = this.market (symbol); request['symbol'] = market['id']; @@ -1954,6 +1954,7 @@ module.exports = class hbtc extends Exchange { 'NEW': 'open', 'CANCELED': 'canceled', 'FILLED': 'closed', + 'PARTIALLY_FILLED': 'open', 'PENDING_CANCEL': 'canceled', }; return this.safeString (statuses, status, status); diff --git a/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/hitbtc.js b/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/hitbtc.js index 0ec19ca80..b66392816 100644 --- a/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/hitbtc.js +++ b/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/hitbtc.js @@ -59,6 +59,10 @@ module.exports = class hitbtc extends Exchange { }, 'urls': { 'logo': 'https://user-images.githubusercontent.com/1294454/27766555-8eaec20e-5edc-11e7-9c5b-6dc69fc42f5e.jpg', + 'test': { + 'public': 'https://api.demo.hitbtc.com', + 'private': 'https://api.demo.hitbtc.com', + }, 'api': { 'public': 'https://api.hitbtc.com', 'private': 'https://api.hitbtc.com', @@ -160,6 +164,7 @@ module.exports = class hitbtc extends Exchange { 'LNC': 'LinkerCoin', 'PLA': 'PlayChip', 'PNT': 'Penta', + 'SBTC': 'Super Bitcoin', 'TV': 'Tokenville', 'USD': 'USDT', 'XPNT': 'PNT', @@ -797,22 +802,44 @@ module.exports = class hitbtc extends Exchange { // // createMarketOrder // - // { clientOrderId: "fe36aa5e190149bf9985fb673bbb2ea0", - // createdAt: "2018-10-25T16:41:44.780Z", - // cumQuantity: "1", - // id: "66799540063", - // quantity: "1", - // side: "sell", - // status: "filled", - // symbol: "XRPUSDT", - // timeInForce: "FOK", - // tradesReport: [ { fee: "0.0004644", - // id: 386394956, - // price: "0.4644", - // quantity: "1", - // timestamp: "2018-10-25T16:41:44.780Z" } ], - // type: "market", - // updatedAt: "2018-10-25T16:41:44.780Z" } + // { + // clientOrderId: "fe36aa5e190149bf9985fb673bbb2ea0", + // createdAt: "2018-10-25T16:41:44.780Z", + // cumQuantity: "1", + // id: "66799540063", + // quantity: "1", + // side: "sell", + // status: "filled", + // symbol: "XRPUSDT", + // timeInForce: "FOK", + // tradesReport: [ + // { + // fee: "0.0004644", + // id: 386394956, + // price: "0.4644", + // quantity: "1", + // timestamp: "2018-10-25T16:41:44.780Z" + // } + // ], + // type: "market", + // updatedAt: "2018-10-25T16:41:44.780Z" + // } + // + // { + // "id": 119499457455, + // "clientOrderId": "87baab109d58401b9202fa0749cb8288", + // "symbol": "ETHUSD", + // "side": "buy", + // "status": "filled", + // "type": "market", + // "timeInForce": "FOK", + // "quantity": "0.0007", + // "price": "181.487", + // "avgPrice": "164.989", + // "cumQuantity": "0.0007", + // "createdAt": "2019-04-17T13:27:38.062Z", + // "updatedAt": "2019-04-17T13:27:38.062Z" + // } // const created = this.parse8601 (this.safeString (order, 'createdAt')); const updated = this.parse8601 (this.safeString (order, 'updatedAt')); @@ -842,7 +869,7 @@ module.exports = class hitbtc extends Exchange { const side = this.safeString (order, 'side'); let trades = this.safeValue (order, 'tradesReport'); let fee = undefined; - let average = undefined; + let average = this.safeValue (order, 'avgPrice'); if (trades !== undefined) { trades = this.parseTrades (trades, market); let feeCost = undefined; @@ -861,7 +888,9 @@ module.exports = class hitbtc extends Exchange { } cost = tradesCost; if ((filled !== undefined) && (filled > 0)) { - average = cost / filled; + if (average === undefined) { + average = cost / filled; + } if (type === 'market') { if (price === undefined) { price = average; diff --git a/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/hollaex.js b/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/hollaex.js index 47b127d50..52e81fec3 100644 --- a/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/hollaex.js +++ b/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/hollaex.js @@ -520,7 +520,7 @@ module.exports = class hollaex extends Exchange { const duration = this.parseTimeframe (timeframe); if (since === undefined) { if (limit === undefined) { - throw new ArgumentsRequired (this.id + " fetchOHLCV requires a 'since' or a 'limit' argument"); + throw new ArgumentsRequired (this.id + " fetchOHLCV() requires a 'since' or a 'limit' argument"); } else { const end = this.seconds (); const start = end - duration * limit; @@ -702,6 +702,7 @@ module.exports = class hollaex extends Exchange { 'symbol': symbol, 'type': type, 'timeInForce': undefined, + 'postOnly': undefined, 'side': side, 'price': price, 'stopPrice': undefined, diff --git a/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/huobipro.js b/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/huobipro.js index 62edb18d3..52dc315e8 100644 --- a/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/huobipro.js +++ b/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/huobipro.js @@ -98,6 +98,7 @@ module.exports = class huobipro extends Exchange { 'user/api-key', // 母子用户API key信息查询 ], 'post': [ + 'account/transfer', 'point/transfer', // 点卡划转 'sub-user/management', // 冻结/解冻子用户 'sub-user/creation', // 子用户创建 @@ -195,9 +196,14 @@ module.exports = class huobipro extends Exchange { }, }, 'exceptions': { + 'broad': { + 'contract is restricted of closing positions on API. Please contact customer service': OnMaintenance, + 'maintain': OnMaintenance, + }, 'exact': { // err-code 'bad-request': BadRequest, + 'base-date-limit-error': BadRequest, // {"status":"error","err-code":"base-date-limit-error","err-msg":"date less than system limit","data":null} 'api-not-support-temp-addr': PermissionDenied, // {"status":"error","err-code":"api-not-support-temp-addr","err-msg":"API withdrawal does not support temporary addresses","data":null} 'timeout': RequestTimeout, // {"ts":1571653730865,"status":"error","err-code":"timeout","err-msg":"Request Timeout"} 'gateway-internal-error': ExchangeNotAvailable, // {"status":"error","err-code":"gateway-internal-error","err-msg":"Failed to load data. Try again later.","data":null} @@ -208,6 +214,8 @@ module.exports = class huobipro extends Exchange { 'order-marketorder-amount-min-error': InvalidOrder, // market order amount error, min: `0.01` 'order-limitorder-price-min-error': InvalidOrder, // limit order price error 'order-limitorder-price-max-error': InvalidOrder, // limit order price error + 'order-holding-limit-failed': InvalidOrder, // {"status":"error","err-code":"order-holding-limit-failed","err-msg":"Order failed, exceeded the holding limit of this currency","data":null} + 'order-orderprice-precision-error': InvalidOrder, // {"status":"error","err-code":"order-orderprice-precision-error","err-msg":"order price precision error, scale: `4`","data":null} 'order-orderstate-error': OrderNotFound, // canceling an already canceled order 'order-queryorder-invalid': OrderNotFound, // querying a non-existent order 'order-update-error': ExchangeNotAvailable, // undocumented error @@ -243,6 +251,7 @@ module.exports = class huobipro extends Exchange { // https://coinmarketcap.com/currencies/penta/markets/ // https://en.cryptonomist.ch/blog/eidoo/the-edo-to-pnt-upgrade-what-you-need-to-know-updated/ 'PNT': 'Penta', + 'SBTC': 'Super Bitcoin', }, }); } @@ -675,7 +684,8 @@ module.exports = class huobipro extends Exchange { request['size'] = limit; // 1-100 orders, default is 100 } if (since !== undefined) { - request['start-date'] = this.ymd (since); // maximum query window size is 2 days, query window shift should be within past 120 days + request['start-date'] = this.ymd (since); // a date within 61 days from today + request['end-date'] = this.ymd (this.sum (since, 86400000)); } const response = await this.privateGetOrderMatchresults (this.extend (request, params)); const trades = this.parseTrades (response['data'], market, since, limit); @@ -943,7 +953,7 @@ module.exports = class huobipro extends Exchange { async fetchOpenOrdersV1 (symbol = undefined, since = undefined, limit = undefined, params = {}) { if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' fetchOpenOrdersV1 requires a symbol argument'); + throw new ArgumentsRequired (this.id + ' fetchOpenOrdersV1() requires a symbol argument'); } return await this.fetchOrdersByStates ('pre-submitted,submitted,partial-filled', symbol, since, limit, params); } @@ -955,7 +965,7 @@ module.exports = class huobipro extends Exchange { async fetchOpenOrdersV2 (symbol = undefined, since = undefined, limit = undefined, params = {}) { await this.loadMarkets (); if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' fetchOpenOrders requires a symbol argument'); + throw new ArgumentsRequired (this.id + ' fetchOpenOrders() requires a symbol argument'); } const market = this.market (symbol); let accountId = this.safeString (params, 'account-id'); @@ -1105,6 +1115,7 @@ module.exports = class huobipro extends Exchange { 'symbol': symbol, 'type': type, 'timeInForce': undefined, + 'postOnly': undefined, 'side': side, 'price': price, 'stopPrice': undefined, @@ -1484,6 +1495,7 @@ module.exports = class huobipro extends Exchange { if (status === 'error') { const code = this.safeString (response, 'err-code'); const feedback = this.id + ' ' + body; + this.throwBroadlyMatchedException (this.exceptions['broad'], body, feedback); this.throwExactlyMatchedException (this.exceptions['exact'], code, feedback); const message = this.safeString (response, 'err-msg'); this.throwExactlyMatchedException (this.exceptions['exact'], message, feedback); diff --git a/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/ice3x.js b/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/ice3x.js index 42e54b79f..f228076d1 100644 --- a/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/ice3x.js +++ b/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/ice3x.js @@ -225,7 +225,7 @@ module.exports = class ice3x extends Exchange { const type = this.safeString (params, 'type'); if ((type !== 'ask') && (type !== 'bid')) { // eslint-disable-next-line quotes - throw new ArgumentsRequired (this.id + " fetchOrderBook requires an exchange-specific extra 'type' param ('bid' or 'ask') when used with a limit"); + throw new ArgumentsRequired (this.id + " fetchOrderBook() requires an exchange-specific extra 'type' param ('bid' or 'ask') when used with a limit"); } else { request['items_per_page'] = limit; } @@ -345,6 +345,7 @@ module.exports = class ice3x extends Exchange { 'symbol': symbol, 'type': 'limit', 'timeInForce': undefined, + 'postOnly': undefined, 'side': this.safeString (order, 'type'), 'price': price, 'stopPrice': undefined, diff --git a/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/idex.js b/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/idex.js index d70fa94f4..7d52a5286 100644 --- a/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/idex.js +++ b/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/idex.js @@ -56,8 +56,8 @@ module.exports = class idex extends Exchange { }, 'logo': 'https://user-images.githubusercontent.com/51840849/94481303-2f222100-01e0-11eb-97dd-bc14c5943a86.jpg', 'api': { - 'public': 'https://api.idex.io', - 'private': 'https://api.idex.io', + 'ETH': 'https://api-eth.idex.io', + 'BSC': 'https://api-bsc.idex.io', }, 'www': 'https://idex.io', 'doc': [ @@ -103,6 +103,7 @@ module.exports = class idex extends Exchange { 'options': { 'defaultTimeInForce': 'gtc', 'defaultSelfTradePrevention': 'cn', + 'network': 'ETH', // also supports BSC }, 'exceptions': { 'INVALID_ORDER_QUANTITY': InvalidOrder, @@ -822,16 +823,8 @@ module.exports = class idex extends Exchange { const type = this.safeString (order, 'type'); const amount = this.safeFloat (order, 'originalQuantity'); const filled = this.safeFloat (order, 'executedQuantity'); - let remaining = undefined; - if ((amount !== undefined) && (filled !== undefined)) { - remaining = amount - filled; - } const average = this.safeFloat (order, 'avgExecutionPrice'); - const price = this.safeFloat (order, 'price', average); // for market orders - let cost = undefined; - if ((amount !== undefined) && (price !== undefined)) { - cost = amount * price; - } + const price = this.safeFloat (order, 'price'); const rawStatus = this.safeString (order, 'status'); const status = this.parseOrderStatus (rawStatus); const fee = { @@ -845,7 +838,7 @@ module.exports = class idex extends Exchange { fee['cost'] = this.sum (fee['cost'], lastTrade['fee']['cost']); } const lastTradeTimestamp = this.safeInteger (lastTrade, 'timestamp'); - return { + return this.safeOrder ({ 'info': order, 'id': id, 'clientOrderId': clientOrderId, @@ -855,18 +848,19 @@ module.exports = class idex extends Exchange { 'symbol': symbol, 'type': type, 'timeInForce': undefined, + 'postOnly': undefined, 'side': side, 'price': price, 'stopPrice': undefined, 'amount': amount, - 'cost': cost, + 'cost': undefined, 'average': average, 'filled': filled, - 'remaining': remaining, + 'remaining': undefined, 'status': status, 'fee': fee, 'trades': trades, - }; + }); } async associateWallet (walletAddress, params = {}) { @@ -943,7 +937,8 @@ module.exports = class idex extends Exchange { } const sideEnum = (side === 'buy') ? 0 : 1; const walletBytes = this.remove0xPrefix (this.walletAddress); - const orderVersion = 1; + const network = this.safeString (this.options, 'network', 'ETH'); + const orderVersion = (network === 'ETH') ? 1 : 2; const amountString = this.amountToPrecision (symbol, amount); // https://docs.idex.io/#time-in-force const timeInForceEnums = { @@ -1272,8 +1267,9 @@ module.exports = class idex extends Exchange { } sign (path, api = 'public', method = 'GET', params = {}, headers = undefined, body = undefined) { + const network = this.safeString (this.options, 'network', 'ETH'); const version = this.safeString (this.options, 'version', 'v1'); - let url = this.urls['api'][api] + '/' + version + '/' + path; + let url = this.urls['api'][network] + '/' + version + '/' + path; const keys = Object.keys (params); const length = keys.length; let query = undefined; diff --git a/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/independentreserve.js b/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/independentreserve.js index 30f75d9a6..119a216d5 100644 --- a/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/independentreserve.js +++ b/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/independentreserve.js @@ -287,6 +287,7 @@ module.exports = class independentreserve extends Exchange { 'symbol': symbol, 'type': orderType, 'timeInForce': undefined, + 'postOnly': undefined, 'side': side, 'price': price, 'stopPrice': undefined, @@ -394,10 +395,13 @@ module.exports = class independentreserve extends Exchange { cost = price * amount; } } - let symbol = undefined; - if (market !== undefined) { - symbol = market['symbol']; + const baseId = this.safeString (trade, 'PrimaryCurrencyCode'); + const quoteId = this.safeString (trade, 'SecondaryCurrencyCode'); + let marketId = undefined; + if ((baseId !== undefined) && (quoteId !== undefined)) { + marketId = baseId + '/' + quoteId; } + const symbol = this.safeSymbol (marketId, market, '/'); let side = this.safeString (trade, 'OrderType'); if (side !== undefined) { if (side.indexOf ('Bid') >= 0) { diff --git a/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/indodax.js b/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/indodax.js index 30457eca2..f1cc33732 100644 --- a/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/indodax.js +++ b/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/indodax.js @@ -399,6 +399,7 @@ module.exports = class indodax extends Exchange { 'symbol': symbol, 'type': 'limit', 'timeInForce': undefined, + 'postOnly': undefined, 'side': side, 'price': price, 'stopPrice': undefined, @@ -415,7 +416,7 @@ module.exports = class indodax extends Exchange { async fetchOrder (id, symbol = undefined, params = {}) { if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' fetchOrder requires a symbol'); + throw new ArgumentsRequired (this.id + ' fetchOrder() requires a symbol'); } await this.loadMarkets (); const market = this.market (symbol); @@ -462,7 +463,7 @@ module.exports = class indodax extends Exchange { async fetchClosedOrders (symbol = undefined, since = undefined, limit = undefined, params = {}) { if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' fetchOrders requires a symbol argument'); + throw new ArgumentsRequired (this.id + ' fetchOrders() requires a symbol argument'); } await this.loadMarkets (); const request = {}; @@ -506,11 +507,11 @@ module.exports = class indodax extends Exchange { async cancelOrder (id, symbol = undefined, params = {}) { if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' cancelOrder requires a symbol argument'); + throw new ArgumentsRequired (this.id + ' cancelOrder() requires a symbol argument'); } const side = this.safeValue (params, 'side'); if (side === undefined) { - throw new ArgumentsRequired (this.id + ' cancelOrder requires an extra "side" param'); + throw new ArgumentsRequired (this.id + ' cancelOrder() requires an extra "side" param'); } await this.loadMarkets (); const market = this.market (symbol); diff --git a/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/itbit.js b/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/itbit.js index f26cf47eb..552bb0de5 100644 --- a/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/itbit.js +++ b/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/itbit.js @@ -268,7 +268,7 @@ module.exports = class itbit extends Exchange { await this.loadMarkets (); const walletId = this.safeString (params, 'walletId'); if (walletId === undefined) { - throw new ArgumentsRequired (this.id + ' fetchMyTrades requires a walletId parameter'); + throw new ArgumentsRequired (this.id + ' fetchMyTrades() requires a walletId parameter'); } const request = { 'walletId': walletId, @@ -337,7 +337,7 @@ module.exports = class itbit extends Exchange { await this.loadMarkets (); const walletId = this.safeString (params, 'walletId'); if (walletId === undefined) { - throw new ExchangeError (this.id + ' fetchMyTrades requires a walletId parameter'); + throw new ExchangeError (this.id + ' fetchMyTrades() requires a walletId parameter'); } const request = { 'walletId': walletId, @@ -427,7 +427,7 @@ module.exports = class itbit extends Exchange { async fetchWallets (params = {}) { await this.loadMarkets (); if (!this.uid) { - throw new AuthenticationError (this.id + ' fetchWallets requires uid API credential'); + throw new AuthenticationError (this.id + ' fetchWallets() requires uid API credential'); } const request = { 'userId': this.uid, @@ -465,7 +465,7 @@ module.exports = class itbit extends Exchange { } const walletIdInParams = ('walletId' in params); if (!walletIdInParams) { - throw new ExchangeError (this.id + ' fetchOrders requires a walletId parameter'); + throw new ExchangeError (this.id + ' fetchOrders() requires a walletId parameter'); } const walletId = params['walletId']; const request = { @@ -529,6 +529,8 @@ module.exports = class itbit extends Exchange { } const clientOrderId = this.safeString (order, 'clientOrderIdentifier'); const id = this.safeString (order, 'id'); + const postOnlyString = this.safeString (order, 'postOnly'); + const postOnly = (postOnlyString === 'True'); return { 'id': id, 'clientOrderId': clientOrderId, @@ -540,6 +542,7 @@ module.exports = class itbit extends Exchange { 'symbol': symbol, 'type': type, 'timeInForce': undefined, + 'postOnly': postOnly, 'side': side, 'price': price, 'stopPrice': undefined, @@ -565,7 +568,7 @@ module.exports = class itbit extends Exchange { } const walletIdInParams = ('walletId' in params); if (!walletIdInParams) { - throw new ExchangeError (this.id + ' createOrder requires a walletId parameter'); + throw new ExchangeError (this.id + ' createOrder() requires a walletId parameter'); } amount = amount.toString (); price = price.toString (); @@ -590,7 +593,7 @@ module.exports = class itbit extends Exchange { await this.loadMarkets (); const walletIdInParams = ('walletId' in params); if (!walletIdInParams) { - throw new ExchangeError (this.id + ' fetchOrder requires a walletId parameter'); + throw new ExchangeError (this.id + ' fetchOrder() requires a walletId parameter'); } const request = { 'id': id, @@ -602,7 +605,7 @@ module.exports = class itbit extends Exchange { async cancelOrder (id, symbol = undefined, params = {}) { const walletIdInParams = ('walletId' in params); if (!walletIdInParams) { - throw new ExchangeError (this.id + ' cancelOrder requires a walletId parameter'); + throw new ExchangeError (this.id + ' cancelOrder() requires a walletId parameter'); } const request = { 'id': id, diff --git a/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/kraken.js b/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/kraken.js index 78e997c6d..198ee4cf8 100644 --- a/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/kraken.js +++ b/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/kraken.js @@ -3,7 +3,7 @@ // --------------------------------------------------------------------------- const Exchange = require ('./base/Exchange'); -const { BadSymbol, ExchangeNotAvailable, ArgumentsRequired, PermissionDenied, AuthenticationError, ExchangeError, OrderNotFound, DDoSProtection, InvalidNonce, InsufficientFunds, CancelPending, InvalidOrder, InvalidAddress } = require ('./base/errors'); +const { BadSymbol, ExchangeNotAvailable, ArgumentsRequired, PermissionDenied, AuthenticationError, ExchangeError, OrderNotFound, DDoSProtection, InvalidNonce, InsufficientFunds, CancelPending, InvalidOrder, InvalidAddress, RateLimitExceeded } = require ('./base/errors'); const { TRUNCATE, DECIMAL_PLACES } = require ('./base/functions/number'); // --------------------------------------------------------------------------- @@ -19,6 +19,7 @@ module.exports = class kraken extends Exchange { 'certified': true, 'pro': true, 'has': { + 'cancelAllOrders': true, 'cancelOrder': true, 'CORS': false, 'createDepositAddress': true, @@ -179,6 +180,7 @@ module.exports = class kraken extends Exchange { 'AddOrder', 'AddExport', 'Balance', + 'CancelAll', 'CancelOrder', 'ClosedOrders', 'DepositAddresses', @@ -206,6 +208,7 @@ module.exports = class kraken extends Exchange { }, 'commonCurrencies': { 'XBT': 'BTC', + 'XBT.M': 'BTC.M', // https://support.kraken.com/hc/en-us/articles/360039879471-What-is-Asset-S-and-Asset-M- 'XDG': 'DOGE', 'REPV2': 'REP', 'REP': 'REPV1', @@ -349,13 +352,17 @@ module.exports = class kraken extends Exchange { return result; } - safeCurrencyCode (currencyId, currency = undefined) { + safeCurrency (currencyId, currency = undefined) { if (currencyId.length > 3) { if ((currencyId.indexOf ('X') === 0) || (currencyId.indexOf ('Z') === 0)) { - currencyId = currencyId.slice (1); + if (currencyId.indexOf ('.') > 0) { + return super.safeCurrency (currencyId, currency); + } else { + currencyId = currencyId.slice (1); + } } } - return super.safeCurrencyCode (currencyId, currency); + return super.safeCurrency (currencyId, currency); } appendInactiveMarkets (result) { @@ -820,7 +827,7 @@ module.exports = class kraken extends Exchange { let amount = undefined; let cost = undefined; let id = undefined; - let order = undefined; + let orderId = undefined; let fee = undefined; let symbol = undefined; if (Array.isArray (trade)) { @@ -844,7 +851,7 @@ module.exports = class kraken extends Exchange { // delisted market ids go here market = this.getDelistedMarketById (marketId); } - order = trade['ordertxid']; + orderId = this.safeString (trade, 'ordertxid'); id = this.safeString2 (trade, 'id', 'postxid'); timestamp = this.safeTimestamp (trade, 'time'); side = this.safeString (trade, 'type'); @@ -872,7 +879,7 @@ module.exports = class kraken extends Exchange { } return { 'id': id, - 'order': order, + 'order': orderId, 'info': trade, 'timestamp': timestamp, 'datetime': this.iso8601 (timestamp), @@ -935,6 +942,7 @@ module.exports = class kraken extends Exchange { } async fetchBalance (params = {}) { + await this.loadMarkets (); const response = await this.privatePostBalance (params); const balances = this.safeValue (response, 'result', {}); const result = { 'info': balances }; @@ -959,18 +967,50 @@ module.exports = class kraken extends Exchange { 'volume': this.amountToPrecision (symbol, amount), }; const clientOrderId = this.safeString2 (params, 'userref', 'clientOrderId'); - const query = this.omit (params, [ 'userref', 'clientOrderId' ]); + params = this.omit (params, [ 'userref', 'clientOrderId' ]); if (clientOrderId !== undefined) { request['userref'] = clientOrderId; } - const priceIsDefined = (price !== undefined); - const marketOrder = (type === 'market'); - const limitOrder = (type === 'limit'); - const shouldIncludePrice = limitOrder || (!marketOrder && priceIsDefined); - if (shouldIncludePrice) { + // + // market + // limit (price = limit price) + // stop-loss (price = stop loss price) + // take-profit (price = take profit price) + // stop-loss-limit (price = stop loss trigger price, price2 = triggered limit price) + // take-profit-limit (price = take profit trigger price, price2 = triggered limit price) + // settle-position + // + if (type === 'limit') { request['price'] = this.priceToPrecision (symbol, price); + } else if ((type === 'stop-loss') || (type === 'take-profit')) { + const stopPrice = this.safeFloat2 (params, 'price', 'stopPrice', price); + if (stopPrice === undefined) { + throw new ArgumentsRequired (this.id + ' createOrder() requires a price argument or a price/stopPrice parameter for a ' + type + ' order'); + } else { + request['price'] = this.priceToPrecision (symbol, stopPrice); + } + } else if ((type === 'stop-loss-limit') || (type === 'take-profit-limit')) { + const stopPrice = this.safeFloat2 (params, 'price', 'stopPrice'); + const limitPrice = this.safeFloat (params, 'price2'); + const stopPriceDefined = (stopPrice !== undefined); + const limitPriceDefined = (limitPrice !== undefined); + if (stopPriceDefined && limitPriceDefined) { + request['price'] = this.priceToPrecision (symbol, stopPrice); + request['price2'] = this.priceToPrecision (symbol, limitPrice); + } else if ((price === undefined) || (!(stopPriceDefined || limitPriceDefined))) { + throw new ArgumentsRequired (this.id + ' createOrder() requires a price argument and/or price/stopPrice/price2 parameters for a ' + type + ' order'); + } else { + if (stopPriceDefined) { + request['price'] = this.priceToPrecision (symbol, stopPrice); + request['price2'] = this.priceToPrecision (symbol, price); + } else if (limitPriceDefined) { + request['price'] = this.priceToPrecision (symbol, price); + request['price2'] = this.priceToPrecision (symbol, limitPrice); + } + } } - const response = await this.privatePostAddOrder (this.extend (request, query)); + params = this.omit (params, [ 'price', 'stopPrice', 'price2' ]); + const response = await this.privatePostAddOrder (this.extend (request, params)); // // { // error: [], @@ -1133,6 +1173,7 @@ module.exports = class kraken extends Exchange { 'symbol': symbol, 'type': type, 'timeInForce': undefined, + 'postOnly': undefined, 'side': side, 'price': price, 'stopPrice': stopPrice, @@ -1199,8 +1240,11 @@ module.exports = class kraken extends Exchange { // } // } // - const orders = this.safeValue (response, 'result', []); - const order = this.parseOrder (this.extend ({ 'id': id }, orders[id])); + const result = this.safeValue (response, 'result', []); + if (!(id in result)) { + throw new OrderNotFound (this.id + ' fetchOrder() could not find order id ' + id); + } + const order = this.parseOrder (this.extend ({ 'id': id }, result[id])); return this.extend ({ 'info': response }, order); } @@ -1208,7 +1252,7 @@ module.exports = class kraken extends Exchange { const orderTrades = this.safeValue (params, 'trades'); const tradeIds = []; if (orderTrades === undefined) { - throw new ArgumentsRequired (this.id + " fetchOrderTrades requires a unified order structure in the params argument or a 'trades' param (an array of trade id strings)"); + throw new ArgumentsRequired (this.id + " fetchOrderTrades() requires a unified order structure in the params argument or a 'trades' param (an array of trade id strings)"); } else { for (let i = 0; i < orderTrades.length; i++) { const orderTrade = orderTrades[i]; @@ -1357,6 +1401,11 @@ module.exports = class kraken extends Exchange { return response; } + async cancelAllOrders (symbol = undefined, params = {}) { + await this.loadMarkets (); + return await this.privatePostCancelAll (params); + } + async fetchOpenOrders (symbol = undefined, since = undefined, limit = undefined, params = {}) { await this.loadMarkets (); const request = {}; @@ -1528,7 +1577,7 @@ module.exports = class kraken extends Exchange { async fetchDeposits (code = undefined, since = undefined, limit = undefined, params = {}) { // https://www.kraken.com/en-us/help/api#deposit-status if (code === undefined) { - throw new ArgumentsRequired (this.id + ' fetchDeposits requires a currency code argument'); + throw new ArgumentsRequired (this.id + ' fetchDeposits() requires a currency code argument'); } await this.loadMarkets (); const currency = this.currency (code); @@ -1571,7 +1620,7 @@ module.exports = class kraken extends Exchange { async fetchWithdrawals (code = undefined, since = undefined, limit = undefined, params = {}) { // https://www.kraken.com/en-us/help/api#withdraw-status if (code === undefined) { - throw new ArgumentsRequired (this.id + ' fetchWithdrawals requires a currency code argument'); + throw new ArgumentsRequired (this.id + ' fetchWithdrawals() requires a currency code argument'); } await this.loadMarkets (); const currency = this.currency (code); @@ -1662,7 +1711,65 @@ module.exports = class kraken extends Exchange { 'id': response['result'], }; } - throw new ExchangeError (this.id + " withdraw requires a 'key' parameter (withdrawal key name, as set up on your account)"); + throw new ExchangeError (this.id + " withdraw() requires a 'key' parameter (withdrawal key name, as set up on your account)"); + } + + async fetchPositions (symbols = undefined, since = undefined, limit = undefined, params = {}) { + await this.loadMarkets (); + const request = { + // 'txid': 'comma delimited list of transaction ids to restrict output to', + // 'docalcs': false, // whether or not to include profit/loss calculations + // 'consolidation': 'market', // what to consolidate the positions data around, market will consolidate positions based on market pair + }; + const response = await this.privatePostOpenPositions (this.extend (request, params)); + // + // no consolidation + // + // { + // error: [], + // result: { + // 'TGUFMY-FLESJ-VYIX3J': { + // ordertxid: "O3LRNU-ZKDG5-XNCDFR", + // posstatus: "open", + // pair: "ETHUSDT", + // time: 1611557231.4584, + // type: "buy", + // ordertype: "market", + // cost: "28.49800", + // fee: "0.07979", + // vol: "0.02000000", + // vol_closed: "0.00000000", + // margin: "14.24900", + // terms: "0.0200% per 4 hours", + // rollovertm: "1611571631", + // misc: "", + // oflags: "" + // } + // } + // } + // + // consolidation by market + // + // { + // error: [], + // result: [ + // { + // pair: "ETHUSDT", + // positions: "1", + // type: "buy", + // leverage: "2.00000", + // cost: "28.49800", + // fee: "0.07979", + // vol: "0.02000000", + // vol_closed: "0.00000000", + // margin: "14.24900" + // } + // ] + // } + // + const result = this.safeValue (response, 'result'); + // todo unify parsePosition/parsePositions + return result; } sign (path, api = 'public', method = 'GET', params = {}, headers = undefined, body = undefined) { @@ -1717,6 +1824,12 @@ module.exports = class kraken extends Exchange { if (body.indexOf ('Invalid arguments:volume') >= 0) { throw new InvalidOrder (this.id + ' ' + body); } + if (body.indexOf ('Rate limit exceeded') >= 0) { + throw new RateLimitExceeded (this.id + ' ' + body); + } + if (response === undefined) { + return; + } if (body[0] === '{') { if (typeof response !== 'string') { if ('error' in response) { diff --git a/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/kucoin.js b/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/kucoin.js index 84a9bebe8..bcb058989 100644 --- a/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/kucoin.js +++ b/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/kucoin.js @@ -20,30 +20,31 @@ module.exports = class kucoin extends Exchange { 'comment': 'Platform 2.0', 'has': { 'CORS': false, - 'fetchStatus': true, - 'fetchTime': true, - 'fetchMarkets': true, + 'cancelAllOrders': true, + 'cancelOrder': true, + 'createDepositAddress': true, + 'createOrder': true, + 'fetchAccounts': true, + 'fetchBalance': true, + 'fetchClosedOrders': true, 'fetchCurrencies': true, + 'fetchDepositAddress': true, + 'fetchDeposits': true, + 'fetchFundingFee': true, + 'fetchLedger': true, + 'fetchMarkets': true, + 'fetchMyTrades': true, + 'fetchOHLCV': true, + 'fetchOpenOrders': true, + 'fetchOrder': true, + 'fetchOrderBook': true, + 'fetchStatus': true, 'fetchTicker': true, 'fetchTickers': true, - 'fetchOrderBook': true, - 'fetchOrder': true, - 'fetchClosedOrders': true, - 'fetchOpenOrders': true, - 'fetchDepositAddress': true, - 'createDepositAddress': true, - 'withdraw': true, - 'fetchDeposits': true, - 'fetchWithdrawals': true, - 'fetchBalance': true, + 'fetchTime': true, 'fetchTrades': true, - 'fetchMyTrades': true, - 'createOrder': true, - 'cancelOrder': true, - 'fetchAccounts': true, - 'fetchFundingFee': true, - 'fetchOHLCV': true, - 'fetchLedger': true, + 'fetchWithdrawals': true, + 'withdraw': true, }, 'urls': { 'logo': 'https://user-images.githubusercontent.com/51840849/87295558-132aaf80-c50e-11ea-9801-a2fb0c57c799.jpg', @@ -74,6 +75,7 @@ module.exports = class kucoin extends Exchange { 'symbols', 'markets', 'market/allTickers', + 'market/orderbook/level{level}_{limit}', 'market/orderbook/level{level}', 'market/orderbook/level2', 'market/orderbook/level2_20', @@ -110,6 +112,7 @@ module.exports = class kucoin extends Exchange { 'withdrawals', 'withdrawals/quotas', 'orders', + 'order/client-order/{clientOid}', 'orders/{orderId}', 'limit/orders', 'fills', @@ -125,6 +128,9 @@ module.exports = class kucoin extends Exchange { 'margin/lend/assets', 'margin/market', 'margin/trade/last', + 'stop-order/{orderId}', + 'stop-order', + 'stop-order/queryOrderByClientOid', ], 'post': [ 'accounts', @@ -135,17 +141,23 @@ module.exports = class kucoin extends Exchange { 'orders', 'orders/multi', 'margin/borrow', + 'margin/order', 'margin/repay/all', 'margin/repay/single', 'margin/lend', 'margin/toggle-auto-lend', 'bullet-private', + 'stop-order', ], 'delete': [ 'withdrawals/{withdrawalId}', 'orders', + 'orders/client-order/{clientOid}', 'orders/{orderId}', 'margin/lend/{orderId}', + 'stop-order/cancelOrderByClientOid', + 'stop-order/{orderId}', + 'stop-order/cancel', ], }, }, @@ -236,10 +248,12 @@ module.exports = class kucoin extends Exchange { 'public': { 'GET': { 'status': 'v1', - 'market/orderbook/level{level}': 'v1', 'market/orderbook/level2': 'v2', + 'market/orderbook/level3': 'v2', 'market/orderbook/level2_20': 'v1', 'market/orderbook/level2_100': 'v1', + 'market/orderbook/level{level}': 'v2', + 'market/orderbook/level{level}_{limit}': 'v1', }, }, 'private': { @@ -371,23 +385,23 @@ module.exports = class kucoin extends Exchange { const response = await this.publicGetCurrencies (params); // // { - // "currency": "OMG", - // "name": "OMG", - // "fullName": "OmiseGO", - // "precision": 8, - // "confirms": 12, - // "withdrawalMinSize": "4", - // "withdrawalMinFee": "1.25", - // "isWithdrawEnabled": false, - // "isDepositEnabled": false, - // "isMarginEnabled": false, - // "isDebitEnabled": false + // "currency": "OMG", + // "name": "OMG", + // "fullName": "OmiseGO", + // "precision": 8, + // "confirms": 12, + // "withdrawalMinSize": "4", + // "withdrawalMinFee": "1.25", + // "isWithdrawEnabled": false, + // "isDepositEnabled": false, + // "isMarginEnabled": false, + // "isDebitEnabled": false // } // - const responseData = response['data']; + const data = this.safeValue (response, 'data', []); const result = {}; - for (let i = 0; i < responseData.length; i++) { - const entry = responseData[i]; + for (let i = 0; i < data.length; i++) { + const entry = data[i]; const id = this.safeString (entry, 'currency'); const name = this.safeString (entry, 'fullName'); const code = this.safeCurrencyCode (id); @@ -682,7 +696,10 @@ module.exports = class kucoin extends Exchange { address = address.replace ('bitcoincash:', ''); } const tag = this.safeString (data, 'memo'); - this.checkAddress (address); + if (code !== 'NIM') { + // contains spaces + this.checkAddress (address); + } return { 'info': response, 'currency': code, @@ -699,13 +716,12 @@ module.exports = class kucoin extends Exchange { // BCH {"code":"200000","data":{"address":"bitcoincash:qza3m4nj9rx7l9r0cdadfqxts6f92shvhvr5ls4q7z","memo":""}} // BTC {"code":"200000","data":{"address":"36SjucKqQpQSvsak9A7h6qzFjrVXpRNZhE","memo":""}} const data = this.safeValue (response, 'data', {}); - let address = this.safeString (data, 'address'); - // BCH/BSV is returned with a "bitcoincash:" prefix, which we cut off here and only keep the address - if (address !== undefined) { - address = address.replace ('bitcoincash:', ''); - } + const address = this.safeString (data, 'address'); const tag = this.safeString (data, 'memo'); - this.checkAddress (address); + if (code !== 'NIM') { + // contains spaces + this.checkAddress (address); + } return { 'info': response, 'currency': code, @@ -719,20 +735,22 @@ module.exports = class kucoin extends Exchange { } async fetchOrderBook (symbol, limit = undefined, params = {}) { - const level = this.safeInteger (params, 'level', 2); - let levelLimit = level.toString (); - if (levelLimit === '2') { - if (limit !== undefined) { - if ((limit !== 20) && (limit !== 100)) { - throw new ExchangeError (this.id + ' fetchOrderBook limit argument must be undefined, 20 or 100'); - } - levelLimit += '_' + limit.toString (); - } - } await this.loadMarkets (); const marketId = this.marketId (symbol); - const request = { 'symbol': marketId, 'level': levelLimit }; - const response = await this.publicGetMarketOrderbookLevelLevel (this.extend (request, params)); + const level = this.safeInteger (params, 'level', 2); + const request = { 'symbol': marketId, 'level': level }; + let method = 'publicGetMarketOrderbookLevelLevel'; + if (level === 2) { + if (limit !== undefined) { + if ((limit === 20) || (limit === 100)) { + request['limit'] = limit; + method = 'publicGetMarketOrderbookLevelLevelLimit'; + } else { + throw new ExchangeError (this.id + ' fetchOrderBook limit argument must be undefined, 20 or 100'); + } + } + } + const response = await this[method] (this.extend (request, params)); // // 'market/orderbook/level2' // 'market/orderbook/level2_20' @@ -794,7 +812,29 @@ module.exports = class kucoin extends Exchange { 'clientOid': clientOrderId, 'side': side, 'symbol': marketId, - 'type': type, + 'type': type, // limit or market + // 'remark': '', // optional remark for the order, length cannot exceed 100 utf8 characters + // 'stp': '', // self trade prevention, CN, CO, CB or DC + // To improve the system performance and to accelerate order placing and processing, KuCoin has added a new interface for margin orders + // The current one will no longer accept margin orders by May 1st, 2021 (UTC) + // At the time, KuCoin will notify users via the announcement, please pay attention to it + // 'tradeType': 'TRADE', // TRADE, MARGIN_TRADE // not used with margin orders + // limit orders --------------------------------------------------- + // 'timeInForce': 'GTC', // GTC, GTT, IOC, or FOK (default is GTC), limit orders only + // 'cancelAfter': long, // cancel after n seconds, requires timeInForce to be GTT + // 'postOnly': false, // Post only flag, invalid when timeInForce is IOC or FOK + // 'hidden': false, // Order will not be displayed in the order book + // 'iceberg': false, // Only a portion of the order is displayed in the order book + // 'visibleSize': this.amountToPrecision (symbol, visibleSize), // The maximum visible size of an iceberg order + // market orders -------------------------------------------------- + // 'size': this.amountToPrecision (symbol, amount), // Amount in base currency + // 'funds': this.costToPrecision (symbol, cost), // Amount of quote currency to use + // stop orders ---------------------------------------------------- + // 'stop': 'loss', // loss or entry, the default is loss, requires stopPrice + // 'stopPrice': this.priceToPrecision (symbol, amount), // need to be defined if stop is specified + // margin orders -------------------------------------------------- + // 'marginMode': 'cross', // cross (cross mode) and isolated (isolated mode), set to cross by default, the isolated mode will be released soon, stay tuned + // 'autoBorrow': false, // The system will first borrow you funds at the optimal interest rate and then place an order for you }; if (type !== 'market') { request['price'] = this.priceToPrecision (symbol, price); @@ -846,9 +886,32 @@ module.exports = class kucoin extends Exchange { } async cancelOrder (id, symbol = undefined, params = {}) { - const request = { 'orderId': id }; - const response = await this.privateDeleteOrdersOrderId (this.extend (request, params)); - return response; + await this.loadMarkets (); + const request = {}; + const clientOrderId = this.safeString2 (params, 'clientOid', 'clientOrderId'); + let method = 'privateDeleteOrdersOrderId'; + if (clientOrderId !== undefined) { + request['clientOid'] = clientOrderId; + method = 'privateDeleteOrdersClientOrderClientOid'; + } else { + request['orderId'] = id; + } + params = this.omit (params, [ 'clientOid', 'clientOrderId' ]); + return await this[method] (this.extend (request, params)); + } + + async cancelAllOrders (symbol = undefined, params = {}) { + await this.loadMarkets (); + const request = { + // 'symbol': market['id'], + // 'tradeType': 'TRADE', // default is to cancel the spot trading order + }; + let market = undefined; + if (symbol !== undefined) { + market = this.market (symbol); + request['symbol'] = market['id']; + } + return await this.privateDeleteOrders (this.extend (request, params)); } async fetchOrdersByStatus (status, symbol = undefined, since = undefined, limit = undefined, params = {}) { @@ -926,20 +989,27 @@ module.exports = class kucoin extends Exchange { async fetchOrder (id, symbol = undefined, params = {}) { await this.loadMarkets (); - // a special case for undefined ids - // otherwise a wrong endpoint for all orders will be triggered - // https://github.com/ccxt/ccxt/issues/7234 - if (id === undefined) { - throw new InvalidOrder (this.id + ' fetchOrder requires an order id'); + const request = {}; + const clientOrderId = this.safeString2 (params, 'clientOid', 'clientOrderId'); + let method = 'privateGetOrdersOrderId'; + if (clientOrderId !== undefined) { + request['clientOid'] = clientOrderId; + method = 'privateGetOrdersClientOrderClientOid'; + } else { + // a special case for undefined ids + // otherwise a wrong endpoint for all orders will be triggered + // https://github.com/ccxt/ccxt/issues/7234 + if (id === undefined) { + throw new InvalidOrder (this.id + ' fetchOrder() requires an order id'); + } + request['orderId'] = id; } - const request = { - 'orderId': id, - }; + params = this.omit (params, [ 'clientOid', 'clientOrderId' ]); + const response = await this[method] (this.extend (request, params)); let market = undefined; if (symbol !== undefined) { market = this.market (symbol); } - const response = await this.privateGetOrdersOrderId (this.extend (request, params)); const responseData = this.safeValue (response, 'data'); return this.parseOrder (responseData, market); } @@ -1016,12 +1086,14 @@ module.exports = class kucoin extends Exchange { const clientOrderId = this.safeString (order, 'clientOid'); const timeInForce = this.safeString (order, 'timeInForce'); const stopPrice = this.safeFloat (order, 'stopPrice'); + const postOnly = this.safeValue (order, 'postOnly'); return { 'id': orderId, 'clientOrderId': clientOrderId, 'symbol': symbol, 'type': type, 'timeInForce': timeInForce, + 'postOnly': postOnly, 'side': side, 'amount': amount, 'price': price, @@ -1350,6 +1422,7 @@ module.exports = class kucoin extends Exchange { // "status": "SUCCESS", // "createdAt": 1544178843000, // "updatedAt": 1544178891000 + // "remark":"foobar" // } // // fetchWithdrawals @@ -1366,6 +1439,7 @@ module.exports = class kucoin extends Exchange { // "status": "FAILURE", // "createdAt": 1546503758000, // "updatedAt": 1546504603000 + // "remark":"foobar" // } // const currencyId = this.safeString (transaction, 'currency'); @@ -1416,20 +1490,26 @@ module.exports = class kucoin extends Exchange { updated = updated * 1000; } } + const comment = this.safeString (transaction, 'remark'); return { 'id': id, + 'info': transaction, + 'timestamp': timestamp, + 'datetime': this.iso8601 (timestamp), 'address': address, + 'addressTo': address, + 'addressFrom': undefined, 'tag': tag, + 'tagTo': tag, + 'tagFrom': undefined, 'currency': code, 'amount': amount, 'txid': txid, 'type': type, 'status': status, + 'comment': comment, 'fee': fee, - 'timestamp': timestamp, - 'datetime': this.iso8601 (timestamp), 'updated': updated, - 'info': transaction, }; } @@ -1477,6 +1557,7 @@ module.exports = class kucoin extends Exchange { // "status": "SUCCESS", // "createdAt": 1544178843000, // "updatedAt": 1544178891000 + // "remark":"foobar" // }, // //-------------------------------------------------- // // version 1 (historical) deposit response structure @@ -1606,7 +1687,7 @@ module.exports = class kucoin extends Exchange { async fetchLedger (code = undefined, since = undefined, limit = undefined, params = {}) { if (code === undefined) { - throw new ArgumentsRequired (this.id + ' fetchLedger requires a code param'); + throw new ArgumentsRequired (this.id + ' fetchLedger() requires a code param'); } await this.loadMarkets (); await this.loadAccounts (); @@ -1749,7 +1830,7 @@ module.exports = class kucoin extends Exchange { // † ↑ // const versions = this.safeValue (this.options, 'versions', {}); - const apiVersions = this.safeValue (versions, api); + const apiVersions = this.safeValue (versions, api, {}); const methodVersions = this.safeValue (apiVersions, method, {}); const defaultVersion = this.safeString (methodVersions, path, this.options['version']); const version = this.safeString (params, 'version', defaultVersion); @@ -1772,10 +1853,17 @@ module.exports = class kucoin extends Exchange { this.checkRequiredCredentials (); const timestamp = this.nonce ().toString (); headers = this.extend ({ + 'KC-API-KEY-VERSION': '2', 'KC-API-KEY': this.apiKey, 'KC-API-TIMESTAMP': timestamp, - 'KC-API-PASSPHRASE': this.password, }, headers); + const apiKeyVersion = this.safeString (headers, 'KC-API-KEY-VERSION'); + if (apiKeyVersion === '2') { + const passphrase = this.hmac (this.encode (this.password), this.encode (this.secret), 'sha256', 'base64'); + headers['KC-API-PASSPHRASE'] = passphrase; + } else { + headers['KC-API-PASSPHRASE'] = this.password; + } const payload = timestamp + method + endpoint + endpart; const signature = this.hmac (this.encode (payload), this.encode (this.secret), 'sha256', 'base64'); headers['KC-API-SIGN'] = signature; diff --git a/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/kuna.js b/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/kuna.js index 8b80f40a4..e652171d1 100644 --- a/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/kuna.js +++ b/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/kuna.js @@ -120,7 +120,7 @@ module.exports = class kuna extends acx { async fetchOpenOrders (symbol = undefined, since = undefined, limit = undefined, params = {}) { if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' fetchOpenOrders requires a symbol argument'); + throw new ArgumentsRequired (this.id + ' fetchOpenOrders() requires a symbol argument'); } await this.loadMarkets (); const market = this.market (symbol); @@ -182,7 +182,7 @@ module.exports = class kuna extends acx { async fetchMyTrades (symbol = undefined, since = undefined, limit = undefined, params = {}) { if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' fetchOpenOrders requires a symbol argument'); + throw new ArgumentsRequired (this.id + ' fetchMyTrades() requires a symbol argument'); } await this.loadMarkets (); const market = this.market (symbol); diff --git a/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/latoken.js b/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/latoken.js index f7e8b4a69..45cb5951d 100644 --- a/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/latoken.js +++ b/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/latoken.js @@ -534,7 +534,7 @@ module.exports = class latoken extends Exchange { async fetchMyTrades (symbol = undefined, since = undefined, limit = undefined, params = {}) { if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' fetchMyTrades requires a symbol argument'); + throw new ArgumentsRequired (this.id + ' fetchMyTrades() requires a symbol argument'); } await this.loadMarkets (); const market = this.market (symbol); @@ -646,6 +646,7 @@ module.exports = class latoken extends Exchange { 'symbol': symbol, 'type': type, 'timeInForce': undefined, + 'postOnly': undefined, 'side': side, 'price': price, 'stopPrice': undefined, @@ -680,7 +681,7 @@ module.exports = class latoken extends Exchange { async fetchOrdersWithMethod (method, symbol = undefined, since = undefined, limit = undefined, params = {}) { if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' fetchOrdersWithMethod requires a symbol argument'); + throw new ArgumentsRequired (this.id + ' fetchOrdersWithMethod() requires a symbol argument'); } await this.loadMarkets (); const market = this.market (symbol); @@ -796,7 +797,7 @@ module.exports = class latoken extends Exchange { async cancelAllOrders (symbol = undefined, params = {}) { if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' cancelAllOrders requires a symbol argument'); + throw new ArgumentsRequired (this.id + ' cancelAllOrders() requires a symbol argument'); } await this.loadMarkets (); const marketId = this.marketId (symbol); diff --git a/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/lbank.js b/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/lbank.js index c90433927..9b39a0236 100644 --- a/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/lbank.js +++ b/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/lbank.js @@ -358,10 +358,10 @@ module.exports = class lbank extends Exchange { await this.loadMarkets (); const market = this.market (symbol); if (since === undefined) { - throw new ArgumentsRequired (this.id + ' fetchOHLCV requires a `since` argument'); + throw new ArgumentsRequired (this.id + ' fetchOHLCV() requires a `since` argument'); } if (limit === undefined) { - throw new ArgumentsRequired (this.id + ' fetchOHLCV requires a `limit` argument'); + throw new ArgumentsRequired (this.id + ' fetchOHLCV() requires a `limit` argument'); } const request = { 'symbol': market['id'], @@ -486,6 +486,7 @@ module.exports = class lbank extends Exchange { 'symbol': symbol, 'type': type, 'timeInForce': undefined, + 'postOnly': undefined, 'side': side, 'price': price, 'stopPrice': undefined, diff --git a/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/liquid.js b/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/liquid.js index ddb1e0acc..732eda853 100644 --- a/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/liquid.js +++ b/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/liquid.js @@ -186,6 +186,7 @@ module.exports = class liquid extends Exchange { 'must_be_positive': InvalidOrder, 'less_than_order_size': InvalidOrder, 'price_too_high': InvalidOrder, + 'price_too_small': InvalidOrder, // {"errors":{"order":["price_too_small"]}} }, 'commonCurrencies': { 'WIN': 'WCOIN', @@ -723,7 +724,7 @@ module.exports = class liquid extends Exchange { async editOrder (id, symbol, type, side, amount, price = undefined, params = {}) { await this.loadMarkets (); if (price === undefined) { - throw new ArgumentsRequired (this.id + ' editOrder requires the price argument'); + throw new ArgumentsRequired (this.id + ' editOrder() requires the price argument'); } const request = { 'order': { @@ -864,6 +865,7 @@ module.exports = class liquid extends Exchange { 'lastTradeTimestamp': lastTradeTimestamp, 'type': type, 'timeInForce': undefined, + 'postOnly': undefined, 'status': status, 'symbol': symbol, 'side': side, diff --git a/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/livecoin.js b/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/livecoin.js deleted file mode 100644 index 0a8aa1aa0..000000000 --- a/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/livecoin.js +++ /dev/null @@ -1,931 +0,0 @@ -'use strict'; - -// --------------------------------------------------------------------------- - -const Exchange = require ('./base/Exchange'); -const { ExchangeError, OnMaintenance, BadResponse, ArgumentsRequired, AuthenticationError, NotSupported, InvalidOrder, OrderNotFound, ExchangeNotAvailable, RateLimitExceeded, InsufficientFunds } = require ('./base/errors'); -const { TRUNCATE, DECIMAL_PLACES } = require ('./base/functions/number'); - -// --------------------------------------------------------------------------- - -module.exports = class livecoin extends Exchange { - describe () { - return this.deepExtend (super.describe (), { - 'id': 'livecoin', - 'name': 'LiveCoin', - 'countries': [ 'US', 'UK', 'RU' ], - 'rateLimit': 1000, - 'userAgent': this.userAgents['chrome'], - 'has': { - 'cancelOrder': true, - 'CORS': false, - 'createOrder': true, - 'fetchBalance': true, - 'fetchClosedOrders': true, - 'fetchCurrencies': true, - 'fetchDepositAddress': true, - 'fetchDeposits': true, - 'fetchMarkets': true, - 'fetchMyTrades': true, - 'fetchOpenOrders': true, - 'fetchOrder': true, - 'fetchOrderBook': true, - 'fetchOrders': true, - 'fetchTicker': true, - 'fetchTickers': true, - 'fetchTrades': true, - 'fetchTradingFee': true, - 'fetchTradingFees': true, - 'fetchWithdrawals': true, - 'withdraw': true, - }, - 'urls': { - 'logo': 'https://user-images.githubusercontent.com/1294454/27980768-f22fc424-638a-11e7-89c9-6010a54ff9be.jpg', - 'api': 'https://api.livecoin.net', - 'www': 'https://www.livecoin.net', - 'doc': 'https://www.livecoin.net/api?lang=en', - 'referral': 'https://livecoin.net/?from=Livecoin-CQ1hfx44', - }, - 'api': { - 'public': { - 'get': [ - 'exchange/all/order_book', - 'exchange/last_trades', - 'exchange/maxbid_minask', - 'exchange/order_book', - 'exchange/restrictions', - 'exchange/ticker', // omit params to get all tickers at once - 'info/coinInfo', - ], - }, - 'private': { - 'get': [ - 'exchange/client_orders', - 'exchange/order', - 'exchange/trades', - 'exchange/commission', - 'exchange/commissionCommonInfo', - 'payment/balances', - 'payment/balance', - 'payment/get/address', - 'payment/history/size', - 'payment/history/transactions', - ], - 'post': [ - 'exchange/buylimit', - 'exchange/buymarket', - 'exchange/cancellimit', - 'exchange/selllimit', - 'exchange/sellmarket', - 'payment/out/capitalist', - 'payment/out/card', - 'payment/out/coin', - 'payment/out/okpay', - 'payment/out/payeer', - 'payment/out/perfectmoney', - 'payment/voucher/amount', - 'payment/voucher/make', - 'payment/voucher/redeem', - ], - }, - }, - 'fees': { - 'trading': { - 'tierBased': false, - 'percentage': true, - 'maker': 0.18 / 100, - 'taker': 0.18 / 100, - }, - }, - 'commonCurrencies': { - 'BIT': 'First Bitcoin', - 'BTCH': 'Bithash', - 'CPC': 'Capricoin', - 'CBC': 'CryptoBossCoin', // conflict with CBC (CashBet Coin) - 'CPT': 'Cryptos', // conflict with CPT = Contents Protocol https://github.com/ccxt/ccxt/issues/4920 and https://github.com/ccxt/ccxt/issues/6081 - 'EDR': 'E-Dinar Coin', // conflicts with EDR for Endor Protocol and EDRCoin - 'eETT': 'EETT', - 'FirstBlood': '1ST', - 'FORTYTWO': '42', - 'LEO': 'LeoCoin', - 'MIOTA': 'IOTA', // https://github.com/ccxt/ccxt/issues/7487 - 'ORE': 'Orectic', - 'PLN': 'Plutaneum', // conflict with Polish Zloty - 'RUR': 'RUB', - 'SCT': 'SpaceCoin', - 'TPI': 'ThaneCoin', - 'UNUS': 'LEO', // https://github.com/ccxt/ccxt/issues/7496 - 'WAX': 'WAXP', - 'wETT': 'WETT', - 'XBT': 'Bricktox', - }, - 'exceptions': { - 'exact': { - '1': ExchangeError, - '10': AuthenticationError, - '100': ExchangeError, // invalid parameters - '101': AuthenticationError, - '102': AuthenticationError, - '103': InvalidOrder, // invalid currency - '104': InvalidOrder, // invalid amount - '105': InvalidOrder, // unable to block funds - '11': AuthenticationError, - '12': AuthenticationError, - '2': AuthenticationError, // "User not found" - '20': AuthenticationError, - '30': AuthenticationError, - '31': NotSupported, - '32': ExchangeError, - '429': RateLimitExceeded, - '503': ExchangeNotAvailable, - }, - 'broad': { - 'insufficient funds': InsufficientFunds, // https://github.com/ccxt/ccxt/issues/5749 - 'NOT FOUND': OrderNotFound, - 'Cannot find order': OrderNotFound, - 'Minimal amount is': InvalidOrder, - }, - }, - }); - } - - async fetchMarkets (params = {}) { - const response = await this.publicGetExchangeTicker (params); - const restrictions = await this.publicGetExchangeRestrictions (); - const restrictionsById = this.indexBy (restrictions['restrictions'], 'currencyPair'); - const result = []; - for (let i = 0; i < response.length; i++) { - const market = response[i]; - const id = this.safeString (market, 'symbol'); - const [ baseId, quoteId ] = id.split ('/'); - const base = this.safeCurrencyCode (baseId); - const quote = this.safeCurrencyCode (quoteId); - const symbol = base + '/' + quote; - const coinRestrictions = this.safeValue (restrictionsById, symbol); - const precision = { - 'price': 5, - 'amount': 8, - 'cost': 8, - }; - const limits = { - 'amount': { - 'min': Math.pow (10, -precision['amount']), - 'max': Math.pow (10, precision['amount']), - }, - }; - if (coinRestrictions) { - precision['price'] = this.safeInteger (coinRestrictions, 'priceScale', 5); - limits['amount']['min'] = this.safeFloat (coinRestrictions, 'minLimitQuantity', limits['amount']['min']); - } - limits['price'] = { - 'min': Math.pow (10, -precision['price']), - 'max': Math.pow (10, precision['price']), - }; - result.push ({ - 'id': id, - 'symbol': symbol, - 'base': base, - 'quote': quote, - 'baseId': baseId, - 'quoteId': quoteId, - 'active': true, - 'precision': precision, - 'limits': limits, - 'info': market, - }); - } - return result; - } - - async fetchCurrencies (params = {}) { - const response = await this.publicGetInfoCoinInfo (params); - if (typeof response === 'string') { - if (response.indexOf ('site is under maintenance') >= 0) { - throw new OnMaintenance (this.id + ' fetchCurrencies() failed to fetch the currencies, the exchange is on maintenance'); - } else { - throw new BadResponse (this.id + ' fetchCurrencies() failed to fetch the currencies'); - } - } - const currencies = this.safeValue (response, 'info'); - let result = {}; - for (let i = 0; i < currencies.length; i++) { - const currency = currencies[i]; - const id = this.safeString (currency, 'symbol'); - // todo: will need to rethink the fees - // to add support for multiple withdrawal/deposit methods and - // differentiated fees for each particular method - const code = this.safeCurrencyCode (id); - const precision = 8; // default precision, todo: fix "magic constants" - const walletStatus = this.safeString (currency, 'walletStatus'); - const active = (walletStatus === 'normal'); - const name = this.safeString (currency, 'name'); - const fee = this.safeFloat (currency, 'withdrawFee'); - result[code] = { - 'id': id, - 'code': code, - 'info': currency, - 'name': name, - 'active': active, - 'fee': fee, - 'precision': precision, - 'limits': { - 'amount': { - 'min': this.safeFloat (currency, 'minOrderAmount'), - 'max': Math.pow (10, precision), - }, - 'price': { - 'min': Math.pow (10, -precision), - 'max': Math.pow (10, precision), - }, - 'cost': { - 'min': this.safeFloat (currency, 'minOrderAmount'), - 'max': undefined, - }, - 'withdraw': { - 'min': this.safeFloat (currency, 'minWithdrawAmount'), - 'max': Math.pow (10, precision), - }, - 'deposit': { - 'min': this.safeFloat (currency, 'minDepositAmount'), - 'max': undefined, - }, - }, - }; - } - result = this.appendFiatCurrencies (result); - return result; - } - - appendFiatCurrencies (result) { - const precision = 8; - const defaults = { - 'info': undefined, - 'active': true, - 'fee': undefined, - 'precision': precision, - 'limits': { - 'withdraw': { 'min': undefined, 'max': undefined }, - 'deposit': { 'min': undefined, 'max': undefined }, - 'amount': { 'min': undefined, 'max': undefined }, - 'cost': { 'min': undefined, 'max': undefined }, - 'price': { - 'min': Math.pow (10, -precision), - 'max': Math.pow (10, precision), - }, - }, - 'id': undefined, - 'code': undefined, - 'name': undefined, - }; - const currencies = [ - { 'id': 'USD', 'code': 'USD', 'name': 'US Dollar' }, - { 'id': 'EUR', 'code': 'EUR', 'name': 'Euro' }, - // { 'id': 'RUR', 'code': 'RUB', 'name': 'Russian ruble' }, - ]; - currencies.push ({ - 'id': 'RUR', - 'code': this.safeCurrencyCode ('RUR'), - 'name': 'Russian ruble', - }); - for (let i = 0; i < currencies.length; i++) { - const currency = currencies[i]; - const code = currency['code']; - result[code] = this.extend (defaults, currency); - } - return result; - } - - async fetchBalance (params = {}) { - await this.loadMarkets (); - const response = await this.privateGetPaymentBalances (params); - const result = { 'info': response }; - for (let i = 0; i < response.length; i++) { - const balance = response[i]; - const currencyId = this.safeString (balance, 'currency'); - const code = this.safeCurrencyCode (currencyId); - let account = undefined; - if (code in result) { - account = result[code]; - } else { - account = this.account (); - } - if (balance['type'] === 'total') { - account['total'] = this.safeFloat (balance, 'value'); - } - if (balance['type'] === 'available') { - account['free'] = this.safeFloat (balance, 'value'); - } - if (balance['type'] === 'trade') { - account['used'] = this.safeFloat (balance, 'value'); - } - result[code] = account; - } - return this.parseBalance (result); - } - - async fetchTradingFees (params = {}) { - await this.loadMarkets (); - const response = await this.privateGetExchangeCommissionCommonInfo (params); - const commission = this.safeFloat (response, 'commission'); - return { - 'info': response, - 'maker': commission, - 'taker': commission, - }; - } - - async fetchOrderBook (symbol, limit = undefined, params = {}) { - await this.loadMarkets (); - const request = { - 'currencyPair': this.marketId (symbol), - 'groupByPrice': 'false', - }; - if (limit !== undefined) { - request['depth'] = limit; // 100 - } - const response = await this.publicGetExchangeOrderBook (this.extend (request, params)); - const timestamp = this.safeInteger (response, 'timestamp'); - return this.parseOrderBook (response, timestamp); - } - - parseTicker (ticker, market = undefined) { - const timestamp = this.milliseconds (); - let symbol = undefined; - if (market) { - symbol = market['symbol']; - } - const vwap = this.safeFloat (ticker, 'vwap'); - const baseVolume = this.safeFloat (ticker, 'volume'); - let quoteVolume = undefined; - if (baseVolume !== undefined && vwap !== undefined) { - quoteVolume = baseVolume * vwap; - } - const last = this.safeFloat (ticker, 'last'); - return { - 'symbol': symbol, - 'timestamp': timestamp, - 'datetime': this.iso8601 (timestamp), - 'high': this.safeFloat (ticker, 'high'), - 'low': this.safeFloat (ticker, 'low'), - 'bid': this.safeFloat (ticker, 'best_bid'), - 'bidVolume': undefined, - 'ask': this.safeFloat (ticker, 'best_ask'), - 'askVolume': undefined, - 'vwap': this.safeFloat (ticker, 'vwap'), - 'open': undefined, - 'close': last, - 'last': last, - 'previousClose': undefined, - 'change': undefined, - 'percentage': undefined, - 'average': undefined, - 'baseVolume': baseVolume, - 'quoteVolume': quoteVolume, - 'info': ticker, - }; - } - - async fetchTickers (symbols = undefined, params = {}) { - await this.loadMarkets (); - const response = await this.publicGetExchangeTicker (params); - const tickers = this.indexBy (response, 'symbol'); - const ids = Object.keys (tickers); - const result = {}; - for (let i = 0; i < ids.length; i++) { - const id = ids[i]; - const market = this.safeMarket (id); - const symbol = market['symbol']; - const ticker = tickers[id]; - result[symbol] = this.parseTicker (ticker, market); - } - return this.filterByArray (result, 'symbol', symbols); - } - - async fetchTicker (symbol, params = {}) { - await this.loadMarkets (); - const market = this.market (symbol); - const request = { - 'currencyPair': market['id'], - }; - const ticker = await this.publicGetExchangeTicker (this.extend (request, params)); - return this.parseTicker (ticker, market); - } - - parseTrade (trade, market = undefined) { - // - // fetchTrades (public) - // - // { - // "time": 1409935047, - // "id": 99451, - // "price": 350, - // "quantity": 2.85714285, - // "type": "BUY" - // } - // - // fetchMyTrades (private) - // - // { - // "datetime": 1435844369, - // "id": 30651619, - // "type": "sell", - // "symbol": "BTC/EUR", - // "price": 230, - // "quantity": 0.1, - // "commission": 0, - // "clientorderid": 1472837650 - // } - const timestamp = this.safeTimestamp2 (trade, 'time', 'datetime'); - let fee = undefined; - const feeCost = this.safeFloat (trade, 'commission'); - if (feeCost !== undefined) { - const feeCurrency = market ? market['quote'] : undefined; - fee = { - 'cost': feeCost, - 'currency': feeCurrency, - }; - } - const orderId = this.safeString (trade, 'clientorderid'); - const id = this.safeString (trade, 'id'); - const side = this.safeStringLower (trade, 'type'); - const amount = this.safeFloat (trade, 'quantity'); - const price = this.safeFloat (trade, 'price'); - let cost = undefined; - if (amount !== undefined) { - if (price !== undefined) { - cost = amount * price; - } - } - const marketId = this.safeString (trade, 'symbol'); - const symbol = this.safeSymbol (marketId, market, '/'); - return { - 'id': id, - 'info': trade, - 'timestamp': timestamp, - 'datetime': this.iso8601 (timestamp), - 'symbol': symbol, - 'order': orderId, - 'type': undefined, - 'side': side, - 'takerOrMaker': undefined, - 'price': price, - 'amount': amount, - 'cost': cost, - 'fee': fee, - }; - } - - async fetchMyTrades (symbol = undefined, since = undefined, limit = undefined, params = {}) { - await this.loadMarkets (); - const request = { - // 'currencyPair': market['id'], - // 'orderDesc': 'true', // or 'false', if true then new orders will be first, otherwise old orders will be first. - // 'offset': 0, // page offset, position of the first item on the page - }; - let market = undefined; - if (symbol !== undefined) { - market = this.market (symbol); - request['currencyPair'] = market['id']; - } - if (limit !== undefined) { - request['limit'] = limit; - } - const response = await this.privateGetExchangeTrades (this.extend (request, params)); - // - // [ - // { - // "datetime": 1435844369, - // "id": 30651619, - // "type": "sell", - // "symbol": "BTC/EUR", - // "price": 230, - // "quantity": 0.1, - // "commission": 0, - // "clientorderid": 1472837650 - // }, - // { - // "datetime": 1435844356, - // "id": 30651618, - // "type": "sell", - // "symbol": "BTC/EUR", - // "price": 230, - // "quantity": 0.2, - // "commission": 0.092, - // "clientorderid": 1472837651 - // } - // ] - // - return this.parseTrades (response, market, since, limit); - } - - async fetchTrades (symbol, since = undefined, limit = undefined, params = {}) { - await this.loadMarkets (); - const market = this.market (symbol); - const request = { - 'currencyPair': market['id'], - }; - const response = await this.publicGetExchangeLastTrades (this.extend (request, params)); - // - // [ - // { - // "time": 1409935047, - // "id": 99451, - // "price": 350, - // "quantity": 2.85714285, - // "type": "BUY" - // }, - // { - // "time": 1409934792, - // "id": 99450, - // "price": 350, - // "quantity": 0.57142857, - // "type": "SELL" - // } - // ] - // - return this.parseTrades (response, market, since, limit); - } - - async fetchOrder (id, symbol = undefined, params = {}) { - await this.loadMarkets (); - const request = { - 'orderId': id, - }; - const response = await this.privateGetExchangeOrder (this.extend (request, params)); - return this.parseOrder (response); - } - - parseOrderStatus (status) { - const statuses = { - 'OPEN': 'open', - 'PARTIALLY_FILLED': 'open', - 'EXECUTED': 'closed', - 'CANCELLED': 'canceled', - 'PARTIALLY_FILLED_AND_CANCELLED': 'canceled', - }; - return this.safeString (statuses, status, status); - } - - parseOrder (order, market = undefined) { - let timestamp = undefined; - if ('lastModificationTime' in order) { - timestamp = this.safeString (order, 'lastModificationTime'); - if (timestamp !== undefined) { - if (timestamp.indexOf ('T') >= 0) { - timestamp = this.parse8601 (timestamp); - } else { - timestamp = this.safeInteger (order, 'lastModificationTime'); - } - } - } - // TODO currently not supported by livecoin - // let trades = this.parseTrades (order['trades'], market, since, limit); - const trades = undefined; - const status = this.parseOrderStatus (this.safeString2 (order, 'status', 'orderStatus')); - const marketId = this.safeString2 (order, 'symbol', 'currencyPair'); - const symbol = this.safeSymbol (marketId, market, '/'); - let type = this.safeStringLower (order, 'type'); - let side = undefined; - if (type !== undefined) { - const orderType = type.split ('_'); - type = orderType[0]; - side = orderType[1]; - } - const price = this.safeFloat (order, 'price'); - // of the next two lines the latter overrides the former, if present in the order structure - let remaining = this.safeFloat (order, 'remainingQuantity'); - remaining = this.safeFloat (order, 'remaining_quantity', remaining); - const amount = this.safeFloat (order, 'quantity', remaining); - let filled = undefined; - if (remaining !== undefined) { - filled = amount - remaining; - } - let cost = undefined; - if (filled !== undefined && price !== undefined) { - cost = filled * price; - } - const feeRate = this.safeFloat (order, 'commission_rate'); - let feeCost = undefined; - if (cost !== undefined && feeRate !== undefined) { - feeCost = cost * feeRate; - } - if ((market === undefined) && (symbol in this.markets)) { - market = this.markets[symbol]; - } - let feeCurrency = undefined; - if (market !== undefined) { - feeCurrency = market['quote']; - } - return { - 'info': order, - 'id': order['id'], - 'clientOrderId': undefined, - 'timestamp': timestamp, - 'datetime': this.iso8601 (timestamp), - 'lastTradeTimestamp': undefined, - 'status': status, - 'symbol': symbol, - 'type': type, - 'timeInForce': undefined, - 'side': side, - 'price': price, - 'stopPrice': undefined, - 'amount': amount, - 'cost': cost, - 'filled': filled, - 'remaining': remaining, - 'trades': trades, - 'fee': { - 'cost': feeCost, - 'currency': feeCurrency, - 'rate': feeRate, - }, - 'average': undefined, - }; - } - - async fetchOrders (symbol = undefined, since = undefined, limit = undefined, params = {}) { - await this.loadMarkets (); - let market = undefined; - const request = {}; - if (symbol !== undefined) { - market = this.market (symbol); - request['currencyPair'] = market['id']; - } - if (since !== undefined) { - request['issuedFrom'] = parseInt (since); - } - if (limit !== undefined) { - request['endRow'] = limit - 1; - } - const response = await this.privateGetExchangeClientOrders (this.extend (request, params)); - const result = []; - let rawOrders = []; - if (response['data']) { - rawOrders = response['data']; - } - for (let i = 0; i < rawOrders.length; i++) { - const order = rawOrders[i]; - result.push (this.parseOrder (order, market)); - } - return this.sortBy (result, 'timestamp'); - } - - async fetchOpenOrders (symbol = undefined, since = undefined, limit = undefined, params = {}) { - const request = { - 'openClosed': 'OPEN', - }; - return await this.fetchOrders (symbol, since, limit, this.extend (request, params)); - } - - async fetchClosedOrders (symbol = undefined, since = undefined, limit = undefined, params = {}) { - const request = { - 'openClosed': 'CLOSED', - }; - return await this.fetchOrders (symbol, since, limit, this.extend (request, params)); - } - - async createOrder (symbol, type, side, amount, price = undefined, params = {}) { - await this.loadMarkets (); - const method = 'privatePostExchange' + this.capitalize (side) + type; - const market = this.market (symbol); - const request = { - 'quantity': this.amountToPrecision (symbol, amount), - 'currencyPair': market['id'], - }; - if (type === 'limit') { - request['price'] = this.priceToPrecision (symbol, price); - } - const response = await this[method] (this.extend (request, params)); - const result = { - 'info': response, - 'id': response['orderId'].toString (), - }; - const success = this.safeValue (response, 'success'); - if (success) { - result['status'] = 'open'; - } - return result; - } - - async cancelOrder (id, symbol = undefined, params = {}) { - if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' cancelOrder requires a symbol argument'); - } - await this.loadMarkets (); - const market = this.market (symbol); - const request = { - 'orderId': id, - 'currencyPair': market['id'], - }; - const response = await this.privatePostExchangeCancellimit (this.extend (request, params)); - const message = this.safeString (response, 'message', this.json (response)); - if ('success' in response) { - if (!response['success']) { - throw new InvalidOrder (message); - } else if ('cancelled' in response) { - if (response['cancelled']) { - return { - 'status': 'canceled', - 'info': response, - }; - } else { - throw new OrderNotFound (message); - } - } - } - throw new ExchangeError (this.id + ' cancelOrder() failed: ' + this.json (response)); - } - - async withdraw (code, amount, address, tag = undefined, params = {}) { - // Sometimes the response with be { key: null } for all keys. - // An example is if you attempt to withdraw more than is allowed when withdrawal fees are considered. - this.checkAddress (address); - await this.loadMarkets (); - const currency = this.currency (code); - let wallet = address; - if (tag !== undefined) { - wallet += '::' + tag; - } - const request = { - 'amount': this.decimalToPrecision (amount, TRUNCATE, currency['precision'], DECIMAL_PLACES), - 'currency': currency['id'], - 'wallet': wallet, - }; - const response = await this.privatePostPaymentOutCoin (this.extend (request, params)); - const id = this.safeInteger (response, 'id'); - if (id === undefined) { - throw new InsufficientFunds (this.id + ' insufficient funds to cover requested withdrawal amount post fees ' + this.json (response)); - } - return { - 'info': response, - 'id': id, - }; - } - - parseTransaction (transaction, currency = undefined) { - // { - // "id": "c853093d5aa06df1c92d79c2...", (tx on deposits, address on withdrawals) - // "type": "DEPOSIT", - // "date": 1553186482676, - // "amount": 712.61266, - // "fee": 0, - // "fixedCurrency": "XVG", - // "taxCurrency": "XVG", - // "variableAmount": null, - // "variableCurrency": null, - // "external": "Coin", - // "login": "USERNAME", - // "externalKey": "....87diPBy......3hTtuwUT78Yi", (address on deposits, tx on withdrawals) - // "documentId": 1110662453 - // }, - let txid = undefined; - let address = undefined; - const id = this.safeString (transaction, 'documentId'); - const amount = this.safeFloat (transaction, 'amount'); - const timestamp = this.safeInteger (transaction, 'date'); - const type = this.safeStringLower (transaction, 'type'); - const currencyId = this.safeString (transaction, 'fixedCurrency'); - const feeCost = this.safeFloat (transaction, 'fee'); - const code = this.safeCurrencyCode (currencyId, currency); - if (type === 'withdrawal') { - txid = this.safeString (transaction, 'externalKey'); - address = this.safeString (transaction, 'id'); - } else if (type === 'deposit') { - address = this.safeString (transaction, 'externalKey'); - txid = this.safeString (transaction, 'id'); - } - let status = undefined; - if (type === 'deposit') { - status = 'ok'; // Deposits is not registered until they are in account. Withdrawals are left as undefined, not entirely sure about theyre status. - } - return { - 'info': transaction, - 'id': id, - 'currency': code, - 'amount': amount, - 'address': address, - 'tag': undefined, - 'status': status, - 'type': type, - 'updated': undefined, - 'txid': txid, - 'timestamp': timestamp, - 'datetime': this.iso8601 (timestamp), - 'fee': { - 'currency': code, - 'cost': feeCost, - }, - }; - } - - async fetchDeposits (code = undefined, since = undefined, limit = undefined, params = {}) { - await this.loadMarkets (); - const endtime = 2505600000; // 29 days - exchange has maximum 30 days. - const now = this.milliseconds (); - const request = { - 'types': 'DEPOSIT', - 'end': now, - 'start': (since !== undefined) ? parseInt (since) : now - endtime, - }; - let currency = undefined; - if (code !== undefined) { - currency = this.currency (code); - } - if (limit !== undefined) { - request['limit'] = limit; // default is 100 - } - const response = await this.privateGetPaymentHistoryTransactions (this.extend (request, params)); - return this.parseTransactions (response, currency, since, limit); - } - - async fetchWithdrawals (code = undefined, since = undefined, limit = undefined, params = {}) { - await this.loadMarkets (); - const endtime = 2505600000; // 29 days - exchange has maximum 30 days. - const now = this.milliseconds (); - const request = { - 'types': 'WITHDRAWAL', - 'end': now, - 'start': (since !== undefined) ? parseInt (since) : now - endtime, - }; - let currency = undefined; - if (code !== undefined) { - currency = this.currency (code); - } - if (limit !== undefined) { - request['limit'] = limit; // default is 100 - } - if (since !== undefined) { - request['start'] = since; - } - const response = await this.privateGetPaymentHistoryTransactions (this.extend (request, params)); - return this.parseTransactions (response, currency, since, limit); - } - - async fetchDepositAddress (currency, params = {}) { - const request = { - 'currency': currency, - }; - const response = await this.privateGetPaymentGetAddress (this.extend (request, params)); - let address = this.safeString (response, 'wallet'); - let tag = undefined; - if (address.indexOf (':') >= 0) { - const parts = address.split (':'); - address = parts[0]; - tag = parts[2]; - } - this.checkAddress (address); - return { - 'currency': currency, - 'address': address, - 'tag': tag, - 'info': response, - }; - } - - sign (path, api = 'public', method = 'GET', params = {}, headers = undefined, body = undefined) { - let url = this.urls['api'] + '/' + path; - const query = this.urlencode (this.keysort (params)); - if (method === 'GET') { - if (Object.keys (params).length) { - url += '?' + query; - } - } - if (api === 'private') { - this.checkRequiredCredentials (); - if (method === 'POST') { - body = query; - } - const signature = this.hmac (this.encode (query), this.encode (this.secret), 'sha256'); - headers = { - 'Api-Key': this.apiKey, - 'Sign': signature.toUpperCase (), - 'Content-Type': 'application/x-www-form-urlencoded', - }; - } - return { 'url': url, 'method': method, 'body': body, 'headers': headers }; - } - - handleErrors (code, reason, url, method, headers, body, response, requestHeaders, requestBody) { - if (response === undefined) { - return; // fallback to default error handler - } - if (code >= 300) { - const feedback = this.id + ' ' + body; - const errorCode = this.safeString (response, 'errorCode'); - this.throwExactlyMatchedException (this.exceptions['exact'], errorCode, feedback); - throw new ExchangeError (feedback); - } - // returns status code 200 even if success === false - const success = this.safeValue (response, 'success', true); - if (!success) { - const feedback = this.id + ' ' + body; - const message = this.safeString2 (response, 'message', 'exception'); - if (message !== undefined) { - this.throwBroadlyMatchedException (this.exceptions['broad'], message, feedback); - } - throw new ExchangeError (feedback); - } - } -}; - diff --git a/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/luno.js b/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/luno.js index 068e1c184..2bbec0ec1 100644 --- a/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/luno.js +++ b/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/luno.js @@ -38,7 +38,11 @@ module.exports = class luno extends Exchange { 'urls': { 'referral': 'https://www.luno.com/invite/44893A', 'logo': 'https://user-images.githubusercontent.com/1294454/27766607-8c1a69d8-5ede-11e7-930c-540b5eb9be24.jpg', - 'api': 'https://api.luno.com/api', + 'api': { + 'public': 'https://api.luno.com/api', + 'private': 'https://api.luno.com/api', + 'exchange': 'https://api.luno.com/api/exchange', + }, 'www': 'https://www.luno.com', 'doc': [ 'https://www.luno.com/en/api', @@ -47,6 +51,11 @@ module.exports = class luno extends Exchange { ], }, 'api': { + 'exchange': { + 'get': [ + 'markets', + ], + }, 'public': { 'get': [ 'orderbook', @@ -97,16 +106,42 @@ module.exports = class luno extends Exchange { } async fetchMarkets (params = {}) { - const response = await this.publicGetTickers (params); + const response = await this.exchangeGetMarkets (params); + // + // { + // "markets":[ + // { + // "market_id":"BCHXBT", + // "trading_status":"ACTIVE", + // "base_currency":"BCH", + // "counter_currency":"XBT", + // "min_volume":"0.01", + // "max_volume":"100.00", + // "volume_scale":2, + // "min_price":"0.0001", + // "max_price":"1.00", + // "price_scale":6, + // "fee_scale":8, + // }, + // ] + // } + // const result = []; - for (let i = 0; i < response['tickers'].length; i++) { - const market = response['tickers'][i]; - const id = market['pair']; - const baseId = id.slice (0, 3); - const quoteId = id.slice (3, 6); + const markets = this.safeValue (response, 'markets', []); + for (let i = 0; i < markets.length; i++) { + const market = markets[i]; + const id = this.safeString (market, 'market_id'); + const baseId = this.safeString (market, 'base_currency'); + const quoteId = this.safeString (market, 'counter_currency'); const base = this.safeCurrencyCode (baseId); const quote = this.safeCurrencyCode (quoteId); const symbol = base + '/' + quote; + const status = this.safeString (market, 'trading_status'); + const active = (status === 'ACTIVE'); + const precision = { + 'amount': this.safeInteger (market, 'volume_scale'), + 'price': this.safeInteger (market, 'price_scale'), + }; result.push ({ 'id': id, 'symbol': symbol, @@ -114,10 +149,23 @@ module.exports = class luno extends Exchange { 'quote': quote, 'baseId': baseId, 'quoteId': quoteId, + 'active': active, + 'precision': precision, + 'limits': { + 'amount': { + 'min': this.safeFloat (market, 'min_volume'), + 'max': this.safeFloat (market, 'max_volume'), + }, + 'price': { + 'min': this.safeFloat (market, 'min_price'), + 'max': this.safeFloat (market, 'max_price'), + }, + 'cost': { + 'min': undefined, + 'max': undefined, + }, + }, 'info': market, - 'active': undefined, - 'precision': this.precision, - 'limits': this.limits, }); } return result; @@ -145,6 +193,16 @@ module.exports = class luno extends Exchange { async fetchBalance (params = {}) { await this.loadMarkets (); const response = await this.privateGetBalance (params); + // + // { + // 'balance': [ + // {'account_id': '119...1336','asset': 'XBT','balance': '0.00','reserved': '0.00','unconfirmed': '0.00'}, + // {'account_id': '66...289','asset': 'XBT','balance': '0.00','reserved': '0.00','unconfirmed': '0.00'}, + // {'account_id': '718...5300','asset': 'ETH','balance': '0.00','reserved': '0.00','unconfirmed': '0.00'}, + // {'account_id': '818...7072','asset': 'ZAR','balance': '0.001417','reserved': '0.00','unconfirmed': '0.00'}]} + // ] + // } + // const wallets = this.safeValue (response, 'balance', []); const result = { 'info': response }; for (let i = 0; i < wallets.length; i++) { @@ -154,10 +212,15 @@ module.exports = class luno extends Exchange { const reserved = this.safeFloat (wallet, 'reserved'); const unconfirmed = this.safeFloat (wallet, 'unconfirmed'); const balance = this.safeFloat (wallet, 'balance'); - const account = this.account (); - account['used'] = this.sum (reserved, unconfirmed); - account['total'] = this.sum (balance, unconfirmed); - result[code] = account; + if (code in result) { + result[code]['used'] = this.sum (result[code]['used'], reserved, unconfirmed); + result[code]['total'] = this.sum (result[code]['total'], balance, unconfirmed); + } else { + const account = this.account (); + account['used'] = this.sum (reserved, unconfirmed); + account['total'] = this.sum (balance, unconfirmed); + result[code] = account; + } } return this.parseBalance (result); } @@ -245,6 +308,7 @@ module.exports = class luno extends Exchange { 'symbol': symbol, 'type': undefined, 'timeInForce': undefined, + 'postOnly': undefined, 'side': side, 'price': price, 'stopPrice': undefined, @@ -425,7 +489,7 @@ module.exports = class luno extends Exchange { async fetchMyTrades (symbol = undefined, since = undefined, limit = undefined, params = {}) { if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' fetchMyTrades requires a symbol argument'); + throw new ArgumentsRequired (this.id + ' fetchMyTrades() requires a symbol argument'); } await this.loadMarkets (); const market = this.market (symbol); @@ -462,15 +526,16 @@ module.exports = class luno extends Exchange { if (type === 'market') { method += 'Marketorder'; request['type'] = side.toUpperCase (); + // todo add createMarketBuyOrderRequires price logic as it is implemented in the other exchanges if (side === 'buy') { - request['counter_volume'] = amount; + request['counter_volume'] = parseFloat (this.amountToPrecision (symbol, amount)); } else { - request['base_volume'] = amount; + request['base_volume'] = parseFloat (this.amountToPrecision (symbol, amount)); } } else { method += 'Postorder'; - request['volume'] = amount; - request['price'] = price; + request['volume'] = parseFloat (this.amountToPrecision (symbol, amount)); + request['price'] = parseFloat (this.priceToPrecision (symbol, price)); request['type'] = (side === 'buy') ? 'BID' : 'ASK'; } const response = await this[method] (this.extend (request, params)); @@ -629,7 +694,7 @@ module.exports = class luno extends Exchange { } sign (path, api = 'public', method = 'GET', params = {}, headers = undefined, body = undefined) { - let url = this.urls['api'] + '/' + this.version + '/' + this.implodeParams (path, params); + let url = this.urls['api'][api] + '/' + this.version + '/' + this.implodeParams (path, params); const query = this.omit (params, this.extractParams (path)); if (Object.keys (query).length) { url += '?' + this.urlencode (query); diff --git a/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/lykke.js b/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/lykke.js index c513b8d80..edc0fe73a 100644 --- a/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/lykke.js +++ b/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/lykke.js @@ -499,6 +499,7 @@ module.exports = class lykke extends Exchange { 'symbol': symbol, 'type': undefined, 'timeInForce': undefined, + 'postOnly': undefined, 'side': side, 'price': price, 'stopPrice': undefined, diff --git a/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/mercado.js b/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/mercado.js index 228e82f69..a2fd9593e 100644 --- a/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/mercado.js +++ b/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/mercado.js @@ -21,6 +21,8 @@ module.exports = class mercado extends Exchange { 'createMarketOrder': true, 'createOrder': true, 'fetchBalance': true, + 'fetchMarkets': true, + 'fetchMyTrades': 'emulated', 'fetchOHLCV': true, 'fetchOpenOrders': true, 'fetchOrder': true, @@ -60,6 +62,7 @@ module.exports = class mercado extends Exchange { 'api': { 'public': { 'get': [ + 'coins', '{coin}/orderbook/', // last slash critical '{coin}/ticker/', '{coin}/trades/', @@ -90,23 +93,90 @@ module.exports = class mercado extends Exchange { ], }, }, - 'markets': { - 'BTC/BRL': { 'id': 'BRLBTC', 'symbol': 'BTC/BRL', 'base': 'BTC', 'quote': 'BRL', 'precision': { 'amount': 8, 'price': 5 }, 'suffix': 'Bitcoin' }, - 'LTC/BRL': { 'id': 'BRLLTC', 'symbol': 'LTC/BRL', 'base': 'LTC', 'quote': 'BRL', 'precision': { 'amount': 8, 'price': 5 }, 'suffix': 'Litecoin' }, - 'BCH/BRL': { 'id': 'BRLBCH', 'symbol': 'BCH/BRL', 'base': 'BCH', 'quote': 'BRL', 'precision': { 'amount': 8, 'price': 5 }, 'suffix': 'BCash' }, - 'XRP/BRL': { 'id': 'BRLXRP', 'symbol': 'XRP/BRL', 'base': 'XRP', 'quote': 'BRL', 'precision': { 'amount': 8, 'price': 5 }, 'suffix': 'Ripple' }, - 'ETH/BRL': { 'id': 'BRLETH', 'symbol': 'ETH/BRL', 'base': 'ETH', 'quote': 'BRL', 'precision': { 'amount': 8, 'price': 5 }, 'suffix': 'Ethereum' }, - 'USDC/BRL': { 'id': 'BRLUSDC', 'symbol': 'USDC/BRL', 'base': 'USDC', 'quote': 'BRL', 'precision': { 'amount': 8, 'price': 5 }, 'suffix': 'USDC' }, - }, 'fees': { 'trading': { - 'maker': 0.3 / 100, - 'taker': 0.7 / 100, + 'maker': 0.003, + 'taker': 0.007, + }, + }, + 'options': { + 'limits': { + 'BTC': 0.001, + 'BCH': 0.001, + 'ETH': 0.01, + 'LTC': 0.01, + 'XRP': 0.1, }, }, }); } + async fetchMarkets (params = {}) { + const response = await this.publicGetCoins (params); + // + // [ + // "BCH", + // "BTC", + // "ETH", + // "LTC", + // "XRP", + // "MBPRK01", + // "MBPRK02", + // "MBPRK03", + // "MBPRK04", + // "MBCONS01", + // "USDC", + // "WBX", + // "CHZ", + // "MBCONS02", + // "PAXG", + // "MBVASCO01", + // "LINK" + // ] + // + const result = []; + const amountLimits = this.safeValue (this.options, 'limits', {}); + for (let i = 0; i < response.length; i++) { + const coin = response[i]; + const baseId = coin; + const quoteId = 'BRL'; + const base = this.safeCurrencyCode (baseId); + const quote = this.safeCurrencyCode (quoteId); + const symbol = base + '/' + quote; + const id = quote + base; + const precision = { + 'amount': 8, + 'price': 5, + }; + result.push ({ + 'id': id, + 'symbol': symbol, + 'base': base, + 'quote': quote, + 'baseId': baseId, + 'quoteId': quoteId, + 'active': undefined, + 'info': coin, + 'precision': precision, + 'limits': { + 'amount': { + 'min': this.safeFloat (amountLimits, baseId), + 'max': undefined, + }, + 'price': { + 'min': 1 / Math.pow (10, precision['price']), + 'max': undefined, + }, + 'cost': { + 'min': undefined, + 'max': undefined, + }, + }, + }); + } + return result; + } + async fetchOrderBook (symbol, limit = undefined, params = {}) { await this.loadMarkets (); const market = this.market (symbol); @@ -152,22 +222,30 @@ module.exports = class mercado extends Exchange { } parseTrade (trade, market = undefined) { - const timestamp = this.safeTimestamp (trade, 'date'); + const timestamp = this.safeTimestamp2 (trade, 'date', 'executed_timestamp'); let symbol = undefined; if (market !== undefined) { symbol = market['symbol']; } - const id = this.safeString (trade, 'tid'); + const id = this.safeString2 (trade, 'tid', 'operation_id'); const type = undefined; const side = this.safeString (trade, 'type'); const price = this.safeFloat (trade, 'price'); - const amount = this.safeFloat (trade, 'amount'); + const amount = this.safeFloat2 (trade, 'amount', 'quantity'); let cost = undefined; if (price !== undefined) { if (amount !== undefined) { cost = price * amount; } } + const feeCost = this.safeFloat (trade, 'fee_rate'); + let fee = undefined; + if (feeCost !== undefined) { + fee = { + 'cost': feeCost, + 'currency': undefined, + }; + } return { 'id': id, 'info': trade, @@ -181,7 +259,7 @@ module.exports = class mercado extends Exchange { 'price': price, 'amount': amount, 'cost': cost, - 'fee': undefined, + 'fee': fee, }; } @@ -349,6 +427,11 @@ module.exports = class mercado extends Exchange { const remaining = amount - filled; const cost = filled * average; const lastTradeTimestamp = this.safeTimestamp (order, 'updated_timestamp'); + const rawTrades = this.safeValue (order, 'operations', []); + const trades = this.parseTrades (rawTrades, market, undefined, undefined, { + 'side': side, + 'order': id, + }); return { 'info': order, 'id': id, @@ -359,6 +442,7 @@ module.exports = class mercado extends Exchange { 'symbol': market['symbol'], 'type': 'limit', 'timeInForce': undefined, + 'postOnly': undefined, 'side': side, 'price': price, 'stopPrice': undefined, @@ -369,7 +453,7 @@ module.exports = class mercado extends Exchange { 'remaining': remaining, 'status': status, 'fee': fee, - 'trades': undefined, // todo parse trades (operations) + 'trades': trades, }; } @@ -401,17 +485,17 @@ module.exports = class mercado extends Exchange { if (code === 'BRL') { const account_ref = ('account_ref' in params); if (!account_ref) { - throw new ArgumentsRequired (this.id + ' requires account_ref parameter to withdraw ' + code); + throw new ArgumentsRequired (this.id + ' withdraw() requires account_ref parameter to withdraw ' + code); } } else if (code !== 'LTC') { const tx_fee = ('tx_fee' in params); if (!tx_fee) { - throw new ArgumentsRequired (this.id + ' requires tx_fee parameter to withdraw ' + code); + throw new ArgumentsRequired (this.id + ' withdraw() requires tx_fee parameter to withdraw ' + code); } if (code === 'XRP') { if (tag === undefined) { if (!('destination_tag' in params)) { - throw new ArgumentsRequired (this.id + ' requires a tag argument or destination_tag parameter to withdraw ' + code); + throw new ArgumentsRequired (this.id + ' withdraw() requires a tag argument or destination_tag parameter to withdraw ' + code); } } else { request['destination_tag'] = tag; @@ -473,6 +557,51 @@ module.exports = class mercado extends Exchange { return this.parseOrders (orders, market, since, limit); } + async fetchOpenOrders (symbol = undefined, since = undefined, limit = undefined, params = {}) { + if (symbol === undefined) { + throw new ArgumentsRequired (this.id + ' fetchOpenOrders () requires a symbol argument'); + } + await this.loadMarkets (); + const market = this.market (symbol); + const request = { + 'coin_pair': market['id'], + 'status_list': '[2]', // open only + }; + const response = await this.privatePostListOrders (this.extend (request, params)); + const responseData = this.safeValue (response, 'response_data', {}); + const orders = this.safeValue (responseData, 'orders', []); + return this.parseOrders (orders, market, since, limit); + } + + async fetchMyTrades (symbol = undefined, since = undefined, limit = undefined, params = {}) { + if (symbol === undefined) { + throw new ArgumentsRequired (this.id + ' fetchMyTrades () requires a symbol argument'); + } + await this.loadMarkets (); + const market = this.market (symbol); + const request = { + 'coin_pair': market['id'], + 'has_fills': true, + }; + const response = await this.privatePostListOrders (this.extend (request, params)); + const responseData = this.safeValue (response, 'response_data', {}); + const ordersRaw = this.safeValue (responseData, 'orders', []); + const orders = this.parseOrders (ordersRaw, market, since, limit); + const trades = this.ordersToTrades (orders); + return this.filterBySymbolSinceLimit (trades, symbol, since, limit); + } + + ordersToTrades (orders) { + const result = []; + for (let i = 0; i < orders.length; i++) { + const trades = this.safeValue (orders[i], 'trades', []); + for (let y = 0; y < trades.length; y++) { + result.push (trades[y]); + } + } + return result; + } + sign (path, api = 'public', method = 'GET', params = {}, headers = undefined, body = undefined) { let url = this.urls['api'][api] + '/'; const query = this.omit (params, this.extractParams (path)); diff --git a/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/ndax.js b/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/ndax.js new file mode 100644 index 000000000..0367c2695 --- /dev/null +++ b/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/ndax.js @@ -0,0 +1,2015 @@ +'use strict'; + +// --------------------------------------------------------------------------- + +const Exchange = require ('./base/Exchange'); +const { ExchangeError, AuthenticationError, InsufficientFunds, BadSymbol, OrderNotFound } = require ('./base/errors'); +const { TICK_SIZE } = require ('./base/functions/number'); + +// --------------------------------------------------------------------------- + +module.exports = class ndax extends Exchange { + describe () { + return this.deepExtend (super.describe (), { + 'id': 'ndax', + 'name': 'NDAX', + 'countries': [ 'US' ], // United States + 'rateLimit': 1000, + 'pro': true, + 'has': { + 'cancelAllOrders': true, + 'cancelOrder': true, + 'createDepositAddress': true, + 'createOrder': true, + 'editOrder': true, + 'fetchAccounts': true, + 'fetchBalance': true, + 'fetchCurrencies': true, + 'fetchDepositAddress': true, + 'fetchDeposits': true, + 'fetchLedger': true, + 'fetchMarkets': true, + 'fetchMyTrades': true, + 'fetchOHLCV': true, + 'fetchOpenOrders': true, + 'fetchOrders': true, + 'fetchOrder': true, + 'fetchOrderBook': true, + 'fetchOrderTrades': true, + 'fetchTicker': true, + 'fetchTrades': true, + }, + 'timeframes': { + '1m': '60', + '5m': '300', + '15m': '900', + '30m': '1800', + '1h': '3600', + '2h': '7200', + '4h': '14400', + '6h': '21600', + '12h': '43200', + '1d': '86400', + '1w': '604800', + '1M': '2419200', + '4M': '9676800', + }, + 'urls': { + 'logo': 'https://user-images.githubusercontent.com/1294454/108623144-67a3ef00-744e-11eb-8140-75c6b851e945.jpg', + 'test': { + 'public': 'https://ndaxmarginstaging.cdnhop.net:8443/AP', + 'private': 'https://ndaxmarginstaging.cdnhop.net:8443/AP', + }, + 'api': { + 'public': 'https://api.ndax.io:8443/AP', + 'private': 'https://api.ndax.io:8443/AP', + }, + 'www': 'https://ndax.io', + 'doc': [ + 'https://apidoc.ndax.io/', + ], + 'fees': 'https://ndax.io/fees', + 'referral': 'https://one.ndax.io/bfQiSL', + }, + 'api': { + 'public': { + 'get': [ + 'Activate2FA', + 'Authenticate2FA', + 'AuthenticateUser', + 'GetL2Snapshot', + 'GetLevel1', + 'GetValidate2FARequiredEndpoints', + 'LogOut', + 'GetTickerHistory', + 'GetProduct', + 'GetProducts', + 'GetInstrument', + 'GetInstruments', + 'Ping', + 'trades', // undocumented + 'GetLastTrades', // undocumented + 'SubscribeLevel1', + 'SubscribeLevel2', + 'SubscribeTicker', + 'SubscribeTrades', + 'SubscribeBlockTrades', + 'UnsubscribeBlockTrades', + 'UnsubscribeLevel1', + 'UnsubscribeLevel2', + 'UnsubscribeTicker', + 'UnsubscribeTrades', + 'Authenticate', // undocumented + ], + }, + 'private': { + 'get': [ + 'GetUserAccountInfos', + 'GetUserAccounts', + 'GetUserAffiliateCount', + 'GetUserAffiliateTag', + 'GetUserConfig', + 'GetAllUnredactedUserConfigsForUser', + 'GetUnredactedUserConfigByKey', + 'GetUserDevices', + 'GetUserReportTickets', + 'GetUserReportWriterResultRecords', + 'GetAccountInfo', + 'GetAccountPositions', + 'GetAllAccountConfigs', + 'GetTreasuryProductsForAccount', + 'GetAccountTrades', + 'GetAccountTransactions', + 'GetOpenTradeReports', + 'GetAllOpenTradeReports', + 'GetTradesHistory', + 'GetOpenOrders', + 'GetOpenQuotes', + 'GetOrderFee', + 'GetOrderHistory', + 'GetOrdersHistory', + 'GetOrderStatus', + 'GetOmsFeeTiers', + 'GetAccountDepositTransactions', + 'GetAccountWithdrawTransactions', + 'GetAllDepositRequestInfoTemplates', + 'GetDepositInfo', + 'GetDepositRequestInfoTemplate', + 'GetDeposits', + 'GetDepositTicket', + 'GetDepositTickets', + 'GetOMSWithdrawFees', + 'GetWithdrawFee', + 'GetWithdraws', + 'GetWithdrawTemplate', + 'GetWithdrawTemplateTypes', + 'GetWithdrawTicket', + 'GetWithdrawTickets', + ], + 'post': [ + 'AddUserAffiliateTag', + 'CancelUserReport', + 'RegisterNewDevice', + 'SubscribeAccountEvents', + 'UpdateUserAffiliateTag', + 'GenerateTradeActivityReport', + 'GenerateTransactionActivityReport', + 'GenerateTreasuryActivityReport', + 'ScheduleTradeActivityReport', + 'ScheduleTransactionActivityReport', + 'ScheduleTreasuryActivityReport', + 'CancelAllOrders', + 'CancelOrder', + 'CancelQuote', + 'CancelReplaceOrder', + 'CreateQuote', + 'ModifyOrder', + 'SendOrder', + 'SubmitBlockTrade', + 'UpdateQuote', + 'CancelWithdraw', + 'CreateDepositTicket', + 'CreateWithdrawTicket', + 'SubmitDepositTicketComment', + 'SubmitWithdrawTicketComment', + 'GetOrderHistoryByOrderId', + ], + }, + }, + 'fees': { + 'trading': { + 'tierBased': false, + 'percentage': true, + 'maker': 0.2 / 100, + 'taker': 0.25 / 100, + }, + }, + 'requiredCredentials': { + 'apiKey': true, + 'secret': true, + 'uid': true, + }, + 'precisionMode': TICK_SIZE, + 'exceptions': { + 'exact': { + 'Not_Enough_Funds': InsufficientFunds, // {"status":"Rejected","errormsg":"Not_Enough_Funds","errorcode":101} + 'Server Error': ExchangeError, // {"result":false,"errormsg":"Server Error","errorcode":102,"detail":null} + 'Resource Not Found': OrderNotFound, // {"result":false,"errormsg":"Resource Not Found","errorcode":104,"detail":null} + }, + 'broad': { + 'Invalid InstrumentId': BadSymbol, // {"result":false,"errormsg":"Invalid InstrumentId: 10000","errorcode":100,"detail":null} + }, + }, + 'options': { + 'omsId': 1, + 'orderTypes': { + 'Market': 1, + 'Limit': 2, + 'StopMarket': 3, + 'StopLimit': 4, + 'TrailingStopMarket': 5, + 'TrailingStopLimit': 6, + 'BlockTrade': 7, + }, + }, + }); + } + + async fetchCurrencies (params = {}) { + const omsId = this.safeInteger (this.options, 'omsId', 1); + const request = { + 'omsId': omsId, + }; + const response = await this.publicGetGetProducts (this.extend (request, params)); + // + // [ + // { + // "OMSId":1, + // "ProductId":1, + // "Product":"BTC", + // "ProductFullName":"Bitcoin", + // "ProductType":"CryptoCurrency", + // "DecimalPlaces":8, + // "TickSize":0.0000000100000000000000000000, + // "NoFees":false, + // "IsDisabled":false, + // "MarginEnabled":false + // }, + // ] + // + const result = {}; + for (let i = 0; i < response.length; i++) { + const currency = response[i]; + const id = this.safeString (currency, 'ProductId'); + const name = this.safeString (currency, 'ProductFullName'); + const type = this.safeString (currency, 'ProductType'); + const code = this.safeCurrencyCode (this.safeString (currency, 'Product')); + const precision = this.safeFloat (currency, 'TickSize'); + const isDisabled = this.safeValue (currency, 'IsDisabled'); + const active = !isDisabled; + result[code] = { + 'id': id, + 'name': name, + 'code': code, + 'type': type, + 'precision': precision, + 'info': currency, + 'active': active, + 'fee': undefined, + 'limits': this.limits, + }; + } + return result; + } + + async fetchMarkets (params = {}) { + const omsId = this.safeInteger (this.options, 'omsId', 1); + const request = { + 'omsId': omsId, + }; + const response = await this.publicGetGetInstruments (this.extend (request, params)); + // + // [ + // { + // "OMSId":1, + // "InstrumentId":3, + // "Symbol":"LTCBTC", + // "Product1":3, + // "Product1Symbol":"LTC", + // "Product2":1, + // "Product2Symbol":"BTC", + // "InstrumentType":"Standard", + // "VenueInstrumentId":3, + // "VenueId":1, + // "SortIndex":0, + // "SessionStatus":"Running", + // "PreviousSessionStatus":"Stopped", + // "SessionStatusDateTime":"2020-11-25T19:42:15.245Z", + // "SelfTradePrevention":true, + // "QuantityIncrement":0.0000000100000000000000000000, + // "PriceIncrement":0.0000000100000000000000000000, + // "MinimumQuantity":0.0100000000000000000000000000, + // "MinimumPrice":0.0000010000000000000000000000, + // "VenueSymbol":"LTCBTC", + // "IsDisable":false, + // "MasterDataId":0, + // "PriceCollarThreshold":0.0000000000000000000000000000, + // "PriceCollarPercent":0.0000000000000000000000000000, + // "PriceCollarEnabled":false, + // "PriceFloorLimit":0.0000000000000000000000000000, + // "PriceFloorLimitEnabled":false, + // "PriceCeilingLimit":0.0000000000000000000000000000, + // "PriceCeilingLimitEnabled":false, + // "CreateWithMarketRunning":true, + // "AllowOnlyMarketMakerCounterParty":false, + // "PriceCollarIndexDifference":0.0000000000000000000000000000, + // "PriceCollarConvertToOtcEnabled":false, + // "PriceCollarConvertToOtcClientUserId":0, + // "PriceCollarConvertToOtcAccountId":0, + // "PriceCollarConvertToOtcThreshold":0.0000000000000000000000000000, + // "OtcConvertSizeThreshold":0.0000000000000000000000000000, + // "OtcConvertSizeEnabled":false, + // "OtcTradesPublic":true, + // "PriceTier":0 + // }, + // ] + // + const result = []; + for (let i = 0; i < response.length; i++) { + const market = response[i]; + const id = this.safeString (market, 'InstrumentId'); + // const lowercaseId = this.safeStringLower (market, 'symbol'); + const baseId = this.safeString (market, 'Product1'); + const quoteId = this.safeString (market, 'Product2'); + const base = this.safeCurrencyCode (this.safeString (market, 'Product1Symbol')); + const quote = this.safeCurrencyCode (this.safeString (market, 'Product2Symbol')); + const symbol = base + '/' + quote; + const precision = { + 'amount': this.safeFloat (market, 'QuantityIncrement'), + 'price': this.safeFloat (market, 'PriceIncrement'), + }; + const sessionStatus = this.safeString (market, 'SessionStatus'); + const isDisable = this.safeValue (market, 'IsDisable'); + const sessionRunning = (sessionStatus === 'Running'); + const active = (sessionRunning && !isDisable) ? true : false; + result.push ({ + 'id': id, + 'symbol': symbol, + 'base': base, + 'quote': quote, + 'baseId': baseId, + 'quoteId': quoteId, + 'info': market, + 'active': active, + 'precision': precision, + 'limits': { + 'amount': { + 'min': this.safeFloat (market, 'MinimumQuantity'), + 'max': undefined, + }, + 'price': { + 'min': this.safeFloat (market, 'MinimumPrice'), + 'max': undefined, + }, + 'cost': { + 'min': undefined, + 'max': undefined, + }, + }, + }); + } + return result; + } + + parseOrderBook (orderbook, timestamp = undefined, bidsKey = 'bids', asksKey = 'asks', priceKey = 6, amountKey = 8) { + let nonce = undefined; + const result = { + 'bids': [], + 'asks': [], + 'timestamp': undefined, + 'datetime': undefined, + 'nonce': undefined, + }; + for (let i = 0; i < orderbook.length; i++) { + const level = orderbook[i]; + if (timestamp === undefined) { + timestamp = this.safeInteger (level, 2); + } else { + const newTimestamp = this.safeInteger (level, 2); + timestamp = Math.max (timestamp, newTimestamp); + } + if (nonce === undefined) { + nonce = this.safeInteger (level, 0); + } else { + const newNonce = this.safeInteger (level, 0); + nonce = Math.max (nonce, newNonce); + } + const bidask = this.parseBidAsk (level, priceKey, amountKey); + const levelSide = this.safeValue (level, 9); + const side = levelSide ? asksKey : bidsKey; + result[side].push (bidask); + } + result['bids'] = this.sortBy (result['bids'], 0, true); + result['asks'] = this.sortBy (result['asks'], 0); + result['timestamp'] = timestamp; + result['datetime'] = this.iso8601 (timestamp); + result['nonce'] = nonce; + return result; + } + + async fetchOrderBook (symbol, limit = undefined, params = {}) { + const omsId = this.safeInteger (this.options, 'omsId', 1); + await this.loadMarkets (); + const market = this.market (symbol); + limit = (limit === undefined) ? 100 : limit; // default 100 + const request = { + 'omsId': omsId, + 'InstrumentId': market['id'], + 'Depth': limit, // default 100 + }; + const response = await this.publicGetGetL2Snapshot (this.extend (request, params)); + // + // [ + // [ + // 0, // 0 MDUpdateId + // 1, // 1 Number of Unique Accounts + // 123, // 2 ActionDateTime in Posix format X 1000 + // 0, // 3 ActionType 0 (New), 1 (Update), 2(Delete) + // 0.0, // 4 LastTradePrice + // 0, // 5 Number of Orders + // 0.0, // 6 Price + // 0, // 7 ProductPairCode + // 0.0, // 8 Quantity + // 0, // 9 Side + // ], + // [97244115,1,1607456142963,0,19069.32,1,19069.31,8,0.140095,0], + // [97244115,0,1607456142963,0,19069.32,1,19068.64,8,0.0055,0], + // [97244115,0,1607456142963,0,19069.32,1,19068.26,8,0.021291,0], + // [97244115,1,1607456142964,0,19069.32,1,19069.32,8,0.099636,1], + // [97244115,0,1607456142964,0,19069.32,1,19069.98,8,0.1,1], + // [97244115,0,1607456142964,0,19069.32,1,19069.99,8,0.141604,1], + // ] + // + return this.parseOrderBook (response); + } + + parseTicker (ticker, market = undefined) { + // + // fetchTicker + // + // { + // "OMSId":1, + // "InstrumentId":8, + // "BestBid":19069.31, + // "BestOffer":19069.32, + // "LastTradedPx":19069.32, + // "LastTradedQty":0.0001, + // "LastTradeTime":1607040406424, + // "SessionOpen":19069.32, + // "SessionHigh":19069.32, + // "SessionLow":19069.32, + // "SessionClose":19069.32, + // "Volume":0.0001, + // "CurrentDayVolume":0.0001, + // "CurrentDayNotional":1.906932, + // "CurrentDayNumTrades":1, + // "CurrentDayPxChange":0.00, + // "Rolling24HrVolume":0.000000000000000000000000000, + // "Rolling24HrNotional":0.00000000000000000000000, + // "Rolling24NumTrades":0, + // "Rolling24HrPxChange":0, + // "TimeStamp":"1607040406425", + // "BidQty":0, + // "AskQty":0, + // "BidOrderCt":0, + // "AskOrderCt":0, + // "Rolling24HrPxChangePercent":0, + // } + // + const timestamp = this.safeInteger (ticker, 'TimeStamp'); + const marketId = this.safeString (ticker, 'InstrumentId'); + const symbol = this.safeSymbol (marketId, market); + const last = this.safeFloat (ticker, 'LastTradedPx'); + const percentage = this.safeFloat (ticker, 'Rolling24HrPxChangePercent'); + const change = this.safeFloat (ticker, 'Rolling24HrPxChange'); + const open = this.safeFloat (ticker, 'SessionOpen'); + let average = undefined; + if ((last !== undefined) && (change !== undefined)) { + average = this.sum (last, open) / 2; + } + const baseVolume = this.safeFloat (ticker, 'Rolling24HrVolume'); + const quoteVolume = this.safeFloat (ticker, 'Rolling24HrNotional'); + const vwap = this.vwap (baseVolume, quoteVolume); + return { + 'symbol': symbol, + 'timestamp': timestamp, + 'datetime': this.iso8601 (timestamp), + 'high': this.safeFloat (ticker, 'SessionHigh'), + 'low': this.safeFloat (ticker, 'SessionLow'), + 'bid': this.safeFloat (ticker, 'BestBid'), + 'bidVolume': undefined, // this.safeFloat (ticker, 'BidQty'), always shows 0 + 'ask': this.safeFloat (ticker, 'BestOffer'), + 'askVolume': undefined, // this.safeFloat (ticker, 'AskQty'), always shows 0 + 'vwap': vwap, + 'open': open, + 'close': last, + 'last': last, + 'previousClose': undefined, + 'change': change, + 'percentage': percentage, + 'average': average, + 'baseVolume': baseVolume, + 'quoteVolume': quoteVolume, + 'info': ticker, + }; + } + + async fetchTicker (symbol, params = {}) { + const omsId = this.safeInteger (this.options, 'omsId', 1); + await this.loadMarkets (); + const market = this.market (symbol); + const request = { + 'omsId': omsId, + 'InstrumentId': market['id'], + }; + const response = await this.publicGetGetLevel1 (this.extend (request, params)); + // + // { + // "OMSId":1, + // "InstrumentId":8, + // "BestBid":19069.31, + // "BestOffer":19069.32, + // "LastTradedPx":19069.32, + // "LastTradedQty":0.0001, + // "LastTradeTime":1607040406424, + // "SessionOpen":19069.32, + // "SessionHigh":19069.32, + // "SessionLow":19069.32, + // "SessionClose":19069.32, + // "Volume":0.0001, + // "CurrentDayVolume":0.0001, + // "CurrentDayNotional":1.906932, + // "CurrentDayNumTrades":1, + // "CurrentDayPxChange":0.00, + // "Rolling24HrVolume":0.000000000000000000000000000, + // "Rolling24HrNotional":0.00000000000000000000000, + // "Rolling24NumTrades":0, + // "Rolling24HrPxChange":0, + // "TimeStamp":"1607040406425", + // "BidQty":0, + // "AskQty":0, + // "BidOrderCt":0, + // "AskOrderCt":0, + // "Rolling24HrPxChangePercent":0, + // } + // + return this.parseTicker (response, market); + } + + parseOHLCV (ohlcv, market = undefined) { + // + // [ + // 1501603632000, // 0 DateTime + // 2700.33, // 1 High + // 2687.01, // 2 Low + // 2687.01, // 3 Open + // 2687.01, // 4 Close + // 24.86100992, // 5 Volume + // 0, // 6 Inside Bid Price + // 2870.95, // 7 Inside Ask Price + // 1 // 8 InstrumentId + // ] + // + return [ + this.safeInteger (ohlcv, 0), + this.safeFloat (ohlcv, 3), + this.safeFloat (ohlcv, 1), + this.safeFloat (ohlcv, 2), + this.safeFloat (ohlcv, 4), + this.safeFloat (ohlcv, 5), + ]; + } + + async fetchOHLCV (symbol, timeframe = '1m', since = undefined, limit = undefined, params = {}) { + const omsId = this.safeInteger (this.options, 'omsId', 1); + await this.loadMarkets (); + const market = this.market (symbol); + const request = { + 'omsId': omsId, + 'InstrumentId': market['id'], + 'Interval': this.timeframes[timeframe], + }; + const duration = this.parseTimeframe (timeframe); + const now = this.milliseconds (); + if (since === undefined) { + if (limit !== undefined) { + request['FromDate'] = this.ymd (now - duration * limit * 1000); + request['ToDate'] = this.ymd (now); + } + } else { + request['FromDate'] = this.ymd (since); + if (limit === undefined) { + request['ToDate'] = this.ymd (now); + } else { + request['ToDate'] = this.ymd (this.sum (since, duration * limit * 1000)); + } + } + const response = await this.publicGetGetTickerHistory (this.extend (request, params)); + // + // [ + // [1607299260000,19069.32,19069.32,19069.32,19069.32,0,19069.31,19069.32,8,1607299200000], + // [1607299320000,19069.32,19069.32,19069.32,19069.32,0,19069.31,19069.32,8,1607299260000], + // [1607299380000,19069.32,19069.32,19069.32,19069.32,0,19069.31,19069.32,8,1607299320000], + // ] + // + return this.parseOHLCVs (response, market, timeframe, since, limit); + } + + parseTrade (trade, market = undefined) { + // + // fetchTrades (public) + // + // [ + // 6913253, // 0 TradeId + // 8, // 1 ProductPairCode + // 0.03340802, // 2 Quantity + // 19116.08, // 3 Price + // 2543425077, // 4 Order1 + // 2543425482, // 5 Order2 + // 1606935922416, // 6 Tradetime + // 0, // 7 Direction + // 1, // 8 TakerSide + // 0, // 9 BlockTrade + // 0, // 10 Either Order1ClientId or Order2ClientId + // ] + // + // fetchMyTrades (private) + // + // { + // "OMSId":1, + // "ExecutionId":16916567, + // "TradeId":14476351, + // "OrderId":2543565231, + // "AccountId":449, + // "AccountName":"igor@ccxt.trade", + // "SubAccountId":0, + // "ClientOrderId":0, + // "InstrumentId":8, + // "Side":"Sell", + // "OrderType":"Market", + // "Quantity":0.1230000000000000000000000000, + // "RemainingQuantity":0.0000000000000000000000000000, + // "Price":19069.310000000000000000000000, + // "Value":2345.5251300000000000000000000, + // "CounterParty":"7", + // "OrderTradeRevision":1, + // "Direction":"NoChange", + // "IsBlockTrade":false, + // "Fee":1.1727625650000000000000000000, + // "FeeProductId":8, + // "OrderOriginator":446, + // "UserName":"igor@ccxt.trade", + // "TradeTimeMS":1607565031569, + // "MakerTaker":"Taker", + // "AdapterTradeId":0, + // "InsideBid":19069.310000000000000000000000, + // "InsideBidSize":0.2400950000000000000000000000, + // "InsideAsk":19069.320000000000000000000000, + // "InsideAskSize":0.0997360000000000000000000000, + // "IsQuote":false, + // "CounterPartyClientUserId":1, + // "NotionalProductId":2, + // "NotionalRate":1.0000000000000000000000000000, + // "NotionalValue":2345.5251300000000000000000000, + // "NotionalHoldAmount":0, + // "TradeTime":637431618315686826 + // } + // + // fetchOrderTrades + // + // { + // "Side":"Sell", + // "OrderId":2543565235, + // "Price":18600.000000000000000000000000, + // "Quantity":0.0000000000000000000000000000, + // "DisplayQuantity":0.0000000000000000000000000000, + // "Instrument":8, + // "Account":449, + // "AccountName":"igor@ccxt.trade", + // "OrderType":"Limit", + // "ClientOrderId":0, + // "OrderState":"FullyExecuted", + // "ReceiveTime":1607585844956, + // "ReceiveTimeTicks":637431826449564182, + // "LastUpdatedTime":1607585844959, + // "LastUpdatedTimeTicks":637431826449593893, + // "OrigQuantity":0.1230000000000000000000000000, + // "QuantityExecuted":0.1230000000000000000000000000, + // "GrossValueExecuted":2345.3947500000000000000000000, + // "ExecutableValue":0.0000000000000000000000000000, + // "AvgPrice":19068.250000000000000000000000, + // "CounterPartyId":0, + // "ChangeReason":"Trade", + // "OrigOrderId":2543565235, + // "OrigClOrdId":0, + // "EnteredBy":446, + // "UserName":"igor@ccxt.trade", + // "IsQuote":false, + // "InsideAsk":19069.320000000000000000000000, + // "InsideAskSize":0.0997360000000000000000000000, + // "InsideBid":19068.250000000000000000000000, + // "InsideBidSize":1.3300010000000000000000000000, + // "LastTradePrice":19068.250000000000000000000000, + // "RejectReason":"", + // "IsLockedIn":false, + // "CancelReason":"", + // "OrderFlag":"0", + // "UseMargin":false, + // "StopPrice":0.0000000000000000000000000000, + // "PegPriceType":"Unknown", + // "PegOffset":0.0000000000000000000000000000, + // "PegLimitOffset":0.0000000000000000000000000000, + // "IpAddress":"5.228.233.138", + // "ClientOrderIdUuid":null, + // "OMSId":1 + // } + // + let price = undefined; + let amount = undefined; + let cost = undefined; + let timestamp = undefined; + let id = undefined; + let marketId = undefined; + let side = undefined; + let orderId = undefined; + let takerOrMaker = undefined; + let fee = undefined; + let type = undefined; + if (Array.isArray (trade)) { + price = this.safeFloat (trade, 3); + amount = this.safeFloat (trade, 2); + if ((price !== undefined) && (amount !== undefined)) { + cost = price * amount; + } + timestamp = this.safeInteger (trade, 6); + id = this.safeString (trade, 0); + marketId = this.safeInteger (trade, 1); + const takerSide = this.safeValue (trade, 8); + side = takerSide ? 'sell' : 'buy'; + orderId = this.safeString (trade, 4); + } else { + timestamp = this.safeInteger2 (trade, 'TradeTimeMS', 'ReceiveTime'); + id = this.safeString (trade, 'TradeId'); + orderId = this.safeString2 (trade, 'OrderId', 'OrigOrderId'); + marketId = this.safeString2 (trade, 'InstrumentId', 'Instrument'); + price = this.safeFloat (trade, 'Price'); + amount = this.safeFloat (trade, 'Quantity'); + cost = this.safeFloat2 (trade, 'Value', 'GrossValueExecuted'); + takerOrMaker = this.safeStringLower (trade, 'MakerTaker'); + side = this.safeStringLower (trade, 'Side'); + type = this.safeStringLower (trade, 'OrderType'); + const feeCost = this.safeFloat (trade, 'Fee'); + if (feeCost !== undefined) { + const feeCurrencyId = this.safeString (trade, 'FeeProductId'); + const feeCurrencyCode = this.safeCurrencyCode (feeCurrencyId); + fee = { + 'cost': feeCost, + 'currency': feeCurrencyCode, + }; + } + } + const symbol = this.safeSymbol (marketId, market); + return { + 'info': trade, + 'id': id, + 'symbol': symbol, + 'timestamp': timestamp, + 'datetime': this.iso8601 (timestamp), + 'order': orderId, + 'type': type, + 'side': side, + 'takerOrMaker': takerOrMaker, + 'price': price, + 'amount': amount, + 'cost': cost, + 'fee': fee, + }; + } + + async fetchTrades (symbol, since = undefined, limit = undefined, params = {}) { + const omsId = this.safeInteger (this.options, 'omsId', 1); + await this.loadMarkets (); + const market = this.market (symbol); + const request = { + 'omsId': omsId, + 'InstrumentId': market['id'], + }; + if (limit !== undefined) { + request['Count'] = limit; + } + const response = await this.publicGetGetLastTrades (this.extend (request, params)); + // + // [ + // [6913253,8,0.03340802,19116.08,2543425077,2543425482,1606935922416,0,1,0,0], + // [6913254,8,0.01391671,19117.42,2543427510,2543427811,1606935927998,1,1,0,0], + // [6913255,8,0.000006,19107.81,2543430495,2543430793,1606935933881,2,0,0,0], + // ] + // + return this.parseTrades (response, market, since, limit); + } + + async fetchAccounts (params = {}) { + const omsId = this.safeInteger (this.options, 'omsId', 1); + this.checkRequiredCredentials (); + const request = { + 'omsId': omsId, + 'UserId': this.uid, + 'UserName': 'igor@ccxt.trade', + }; + const response = await this.privateGetGetUserAccounts (this.extend (request, params)); + // + // [ 449 ] // comma-separated list of account ids + // + const result = []; + for (let i = 0; i < response.length; i++) { + const accountId = this.safeString (response, i); + result.push ({ + 'id': accountId, + 'type': undefined, + 'currency': undefined, + 'info': accountId, + }); + } + return result; + } + + async fetchBalance (params = {}) { + const omsId = this.safeInteger (this.options, 'omsId', 1); + await this.loadMarkets (); + await this.loadAccounts (); + const defaultAccountId = this.safeInteger2 (this.options, 'accountId', 'AccountId', parseInt (this.accounts[0]['id'])); + const accountId = this.safeInteger2 (params, 'accountId', 'AccountId', defaultAccountId); + params = this.omit (params, [ 'accountId', 'AccountId' ]); + const request = { + 'omsId': omsId, + 'AccountId': accountId, + }; + const response = await this.privateGetGetAccountPositions (this.extend (request, params)); + // + // [ + // { + // "OMSId":1, + // "AccountId":449, + // "ProductSymbol":"BTC", + // "ProductId":1, + // "Amount":10.000000000000000000000000000, + // "Hold":0, + // "PendingDeposits":0.0000000000000000000000000000, + // "PendingWithdraws":0.0000000000000000000000000000, + // "TotalDayDeposits":10.000000000000000000000000000, + // "TotalMonthDeposits":10.000000000000000000000000000, + // "TotalYearDeposits":10.000000000000000000000000000, + // "TotalDayDepositNotional":10.000000000000000000000000000, + // "TotalMonthDepositNotional":10.000000000000000000000000000, + // "TotalYearDepositNotional":10.000000000000000000000000000, + // "TotalDayWithdraws":0, + // "TotalMonthWithdraws":0, + // "TotalYearWithdraws":0, + // "TotalDayWithdrawNotional":0, + // "TotalMonthWithdrawNotional":0, + // "TotalYearWithdrawNotional":0, + // "NotionalProductId":8, + // "NotionalProductSymbol":"USDT", + // "NotionalValue":10.000000000000000000000000000, + // "NotionalHoldAmount":0, + // "NotionalRate":1 + // }, + // ] + // + const result = { 'info': response }; + for (let i = 0; i < response.length; i++) { + const balance = response[i]; + const currencyId = this.safeString (balance, 'ProductId'); + const code = this.safeCurrencyCode (currencyId); + const account = this.account (); + account['total'] = this.safeFloat (balance, 'Amount'); + account['used'] = this.safeFloat (balance, 'Hold'); + result[code] = account; + } + return this.parseBalance (result); + } + + parseLedgerEntryType (type) { + const types = { + 'Trade': 'trade', + 'Deposit': 'transaction', + 'Withdraw': 'transaction', + 'Transfer': 'transfer', + 'OrderHold': 'trade', + 'WithdrawHold': 'transaction', + 'DepositHold': 'transaction', + 'MarginHold': 'trade', + 'ManualHold': 'trade', + 'ManualEntry': 'trade', + 'MarginAcquisition': 'trade', + 'MarginRelinquish': 'trade', + 'MarginQuoteHold': 'trade', + }; + return this.safeString (types, type, type); + } + + parseLedgerEntry (item, currency = undefined) { + // + // { + // "TransactionId":2663709493, + // "ReferenceId":68, + // "OMSId":1, + // "AccountId":449, + // "CR":10.000000000000000000000000000, + // "DR":0.0000000000000000000000000000, + // "Counterparty":3, + // "TransactionType":"Other", + // "ReferenceType":"Deposit", + // "ProductId":1, + // "Balance":10.000000000000000000000000000, + // "TimeStamp":1607532331591 + // } + // + const id = this.safeString (item, 'TransactionId'); + const account = this.safeString (item, 'AccountId'); + const referenceId = this.safeString (item, 'ReferenceId'); + const referenceAccount = this.safeString (item, 'Counterparty'); + const type = this.parseLedgerEntryType (this.safeString (item, 'ReferenceType')); + const currencyId = this.safeString (item, 'ProductId'); + const code = this.safeCurrencyCode (currencyId, currency); + const credit = this.safeFloat (item, 'CR'); + const debit = this.safeFloat (item, 'DR'); + let amount = undefined; + let direction = undefined; + if (credit > 0) { + amount = credit; + direction = 'in'; + } else if (debit > 0) { + amount = debit; + direction = 'out'; + } + const timestamp = this.safeInteger (item, 'TimeStamp'); + let before = undefined; + const after = this.safeFloat (item, 'Balance'); + if (direction === 'out') { + before = this.sum (after, amount); + } else if (direction === 'in') { + before = Math.max (0, after - amount); + } + const status = 'ok'; + return { + 'info': item, + 'id': id, + 'direction': direction, + 'account': account, + 'referenceId': referenceId, + 'referenceAccount': referenceAccount, + 'type': type, + 'currency': code, + 'amount': amount, + 'before': before, + 'after': after, + 'status': status, + 'timestamp': timestamp, + 'datetime': this.iso8601 (timestamp), + 'fee': undefined, + }; + } + + async fetchLedger (code = undefined, since = undefined, limit = undefined, params = {}) { + const omsId = this.safeInteger (this.options, 'omsId', 1); + await this.loadMarkets (); + await this.loadAccounts (); + const defaultAccountId = this.safeInteger2 (this.options, 'accountId', 'AccountId', parseInt (this.accounts[0]['id'])); + const accountId = this.safeInteger2 (params, 'accountId', 'AccountId', defaultAccountId); + params = this.omit (params, [ 'accountId', 'AccountId' ]); + const request = { + 'omsId': omsId, + 'AccountId': accountId, + }; + if (limit !== undefined) { + request['Depth'] = limit; + } + const response = await this.privateGetGetAccountTransactions (this.extend (request, params)); + // + // [ + // { + // "TransactionId":2663709493, + // "ReferenceId":68, + // "OMSId":1, + // "AccountId":449, + // "CR":10.000000000000000000000000000, + // "DR":0.0000000000000000000000000000, + // "Counterparty":3, + // "TransactionType":"Other", + // "ReferenceType":"Deposit", + // "ProductId":1, + // "Balance":10.000000000000000000000000000, + // "TimeStamp":1607532331591 + // }, + // ] + // + let currency = undefined; + if (code !== undefined) { + currency = this.currency (code); + } + return this.parseLedger (response, currency, since, limit); + } + + parseOrderStatus (status) { + const statuses = { + 'Accepted': 'open', + 'Rejected': 'rejected', + 'Working': 'open', + 'Canceled': 'canceled', + 'Expired': 'expired', + 'FullyExecuted': 'closed', + }; + return this.safeString (statuses, status, status); + } + + parseOrder (order, market = undefined) { + // + // createOrder + // + // { + // "status":"Accepted", + // "errormsg":"", + // "OrderId": 2543565231 + // } + // + // editOrder + // + // { + // "ReplacementOrderId": 1234, + // "ReplacementClOrdId": 1561, + // "OrigOrderId": 5678, + // "OrigClOrdId": 91011, + // } + // + // fetchOpenOrders, fetchClosedOrders + // + // { + // "Side":"Buy", + // "OrderId":2543565233, + // "Price":19010, + // "Quantity":0.345, + // "DisplayQuantity":0.345, + // "Instrument":8, + // "Account":449, + // "AccountName":"igor@ccxt.trade", + // "OrderType":"Limit", + // "ClientOrderId":0, + // "OrderState":"Working", + // "ReceiveTime":1607579326003, + // "ReceiveTimeTicks":637431761260028981, + // "LastUpdatedTime":1607579326005, + // "LastUpdatedTimeTicks":637431761260054714, + // "OrigQuantity":0.345, + // "QuantityExecuted":0, + // "GrossValueExecuted":0, + // "ExecutableValue":0, + // "AvgPrice":0, + // "CounterPartyId":0, + // "ChangeReason":"NewInputAccepted", + // "OrigOrderId":2543565233, + // "OrigClOrdId":0, + // "EnteredBy":446, + // "UserName":"igor@ccxt.trade", + // "IsQuote":false, + // "InsideAsk":19069.32, + // "InsideAskSize":0.099736, + // "InsideBid":19068.25, + // "InsideBidSize":1.330001, + // "LastTradePrice":19068.25, + // "RejectReason":"", + // "IsLockedIn":false, + // "CancelReason":"", + // "OrderFlag":"AddedToBook", + // "UseMargin":false, + // "StopPrice":0, + // "PegPriceType":"Unknown", + // "PegOffset":0, + // "PegLimitOffset":0, + // "IpAddress":null, + // "ClientOrderIdUuid":null, + // "OMSId":1 + // } + // + const id = this.safeString2 (order, 'ReplacementOrderId', 'OrderId'); + const timestamp = this.safeInteger (order, 'ReceiveTime'); + let lastTradeTimestamp = undefined; + const marketId = this.safeString (order, 'Instrument'); + const symbol = this.safeSymbol (marketId, market); + const side = this.safeStringLower (order, 'Side'); + const type = this.safeStringLower (order, 'OrderType'); + const clientOrderId = this.safeString2 (order, 'ReplacementClOrdId', 'ClientOrderId'); + let price = this.safeFloat (order, 'Price', 0.0); + price = (price > 0.0) ? price : undefined; + const amount = this.safeFloat (order, 'OrigQuantity'); + const filled = this.safeFloat (order, 'QuantityExecuted'); + const cost = this.safeFloat (order, 'GrossValueExecuted'); + let remaining = undefined; + let average = undefined; + if (filled !== undefined) { + if (amount !== undefined) { + remaining = Math.max (0, amount - filled); + } + if (filled > 0) { + lastTradeTimestamp = this.safeInteger (order, 'LastUpdatedTime'); + average = this.safeFloat (order, 'AvgPrice', 0.0); + average = (average > 0) ? average : undefined; + } + } + let stopPrice = this.safeFloat (order, 'StopPrice', 0.0); + stopPrice = (stopPrice > 0.0) ? stopPrice : undefined; + const timeInForce = undefined; + const status = this.parseOrderStatus (this.safeString (order, 'OrderState')); + const fee = undefined; + const trades = undefined; + return { + 'id': id, + 'clientOrderId': clientOrderId, + 'info': order, + 'timestamp': timestamp, + 'datetime': this.iso8601 (timestamp), + 'lastTradeTimestamp': lastTradeTimestamp, + 'status': status, + 'symbol': symbol, + 'type': type, + 'timeInForce': timeInForce, + 'postOnly': undefined, + 'side': side, + 'price': price, + 'stopPrice': stopPrice, + 'cost': cost, + 'amount': amount, + 'filled': filled, + 'average': average, + 'remaining': remaining, + 'fee': fee, + 'trades': trades, + }; + } + + async createOrder (symbol, type, side, amount, price = undefined, params = {}) { + const omsId = this.safeInteger (this.options, 'omsId', 1); + await this.loadMarkets (); + await this.loadAccounts (); + const defaultAccountId = this.safeInteger2 (this.options, 'accountId', 'AccountId', parseInt (this.accounts[0]['id'])); + const accountId = this.safeInteger2 (params, 'accountId', 'AccountId', defaultAccountId); + const clientOrderId = this.safeInteger2 (params, 'ClientOrderId', 'clientOrderId'); + params = this.omit (params, [ 'accountId', 'AccountId', 'clientOrderId', 'ClientOrderId' ]); + const market = this.market (symbol); + const orderSide = (side === 'buy') ? 0 : 1; + const request = { + 'InstrumentId': parseInt (market['id']), + 'omsId': omsId, + 'AccountId': accountId, + 'TimeInForce': 1, // 0 Unknown, 1 GTC by default, 2 OPG execute as close to opening price as possible, 3 IOC immediate or canceled, 4 FOK fill-or-kill, 5 GTX good 'til executed, 6 GTD good 'til date + // 'ClientOrderId': clientOrderId, // defaults to 0 + // If this order is order A, OrderIdOCO refers to the order ID of an order B (which is not the order being created by this call). + // If order B executes, then order A created by this call is canceled. + // You can also set up order B to watch order A in the same way, but that may require an update to order B to make it watch this one, which could have implications for priority in the order book. + // See CancelReplaceOrder and ModifyOrder. + // 'OrderIdOCO': 0, // The order ID if One Cancels the Other. + // 'UseDisplayQuantity': false, // If you enter a Limit order with a reserve, you must set UseDisplayQuantity to true + 'Side': orderSide, // 0 Buy, 1 Sell, 2 Short, 3 unknown an error condition + 'Quantity': parseFloat (this.amountToPrecision (symbol, amount)), + 'OrderType': this.safeInteger (this.options['orderTypes'], this.capitalize (type)), // 0 Unknown, 1 Market, 2 Limit, 3 StopMarket, 4 StopLimit, 5 TrailingStopMarket, 6 TrailingStopLimit, 7 BlockTrade + // 'PegPriceType': 3, // 1 Last, 2 Bid, 3 Ask, 4 Midpoint + // 'LimitPrice': parseFloat (this.priceToPrecision (symbol, price)), + }; + // If OrderType=1 (Market), Side=0 (Buy), and LimitPrice is supplied, the Market order will execute up to the value specified + if (price !== undefined) { + request['LimitPrice'] = parseFloat (this.priceToPrecision (symbol, price)); + } + if (clientOrderId !== undefined) { + request['ClientOrderId'] = clientOrderId; + } + const response = await this.privatePostSendOrder (this.extend (request, params)); + // + // { + // "status":"Accepted", + // "errormsg":"", + // "OrderId": 2543565231 + // } + // + return this.parseOrder (response, market); + } + + async editOrder (id, symbol, type, side, amount, price = undefined, params = {}) { + const omsId = this.safeInteger (this.options, 'omsId', 1); + await this.loadMarkets (); + await this.loadAccounts (); + const defaultAccountId = this.safeInteger2 (this.options, 'accountId', 'AccountId', parseInt (this.accounts[0]['id'])); + const accountId = this.safeInteger2 (params, 'accountId', 'AccountId', defaultAccountId); + const clientOrderId = this.safeInteger2 (params, 'ClientOrderId', 'clientOrderId'); + params = this.omit (params, [ 'accountId', 'AccountId', 'clientOrderId', 'ClientOrderId' ]); + const market = this.market (symbol); + const orderSide = (side === 'buy') ? 0 : 1; + const request = { + 'OrderIdToReplace': parseInt (id), + 'InstrumentId': parseInt (market['id']), + 'omsId': omsId, + 'AccountId': accountId, + 'TimeInForce': 1, // 0 Unknown, 1 GTC by default, 2 OPG execute as close to opening price as possible, 3 IOC immediate or canceled, 4 FOK fill-or-kill, 5 GTX good 'til executed, 6 GTD good 'til date + // 'ClientOrderId': clientOrderId, // defaults to 0 + // If this order is order A, OrderIdOCO refers to the order ID of an order B (which is not the order being created by this call). + // If order B executes, then order A created by this call is canceled. + // You can also set up order B to watch order A in the same way, but that may require an update to order B to make it watch this one, which could have implications for priority in the order book. + // See CancelReplaceOrder and ModifyOrder. + // 'OrderIdOCO': 0, // The order ID if One Cancels the Other. + // 'UseDisplayQuantity': false, // If you enter a Limit order with a reserve, you must set UseDisplayQuantity to true + 'Side': orderSide, // 0 Buy, 1 Sell, 2 Short, 3 unknown an error condition + 'Quantity': parseFloat (this.amountToPrecision (symbol, amount)), + 'OrderType': this.safeInteger (this.options['orderTypes'], this.capitalize (type)), // 0 Unknown, 1 Market, 2 Limit, 3 StopMarket, 4 StopLimit, 5 TrailingStopMarket, 6 TrailingStopLimit, 7 BlockTrade + // 'PegPriceType': 3, // 1 Last, 2 Bid, 3 Ask, 4 Midpoint + // 'LimitPrice': parseFloat (this.priceToPrecision (symbol, price)), + }; + // If OrderType=1 (Market), Side=0 (Buy), and LimitPrice is supplied, the Market order will execute up to the value specified + if (price !== undefined) { + request['LimitPrice'] = parseFloat (this.priceToPrecision (symbol, price)); + } + if (clientOrderId !== undefined) { + request['ClientOrderId'] = clientOrderId; + } + const response = await this.privatePostCancelReplaceOrder (this.extend (request, params)); + // + // { + // "replacementOrderId": 1234, + // "replacementClOrdId": 1561, + // "origOrderId": 5678, + // "origClOrdId": 91011, + // } + // + return this.parseOrder (response, market); + } + + async fetchMyTrades (symbol = undefined, since = undefined, limit = undefined, params = {}) { + const omsId = this.safeInteger (this.options, 'omsId', 1); + await this.loadMarkets (); + await this.loadAccounts (); + const defaultAccountId = this.safeInteger2 (this.options, 'accountId', 'AccountId', parseInt (this.accounts[0]['id'])); + const accountId = this.safeInteger2 (params, 'accountId', 'AccountId', defaultAccountId); + params = this.omit (params, [ 'accountId', 'AccountId' ]); + const request = { + 'omsId': omsId, + 'AccountId': accountId, + // 'InstrumentId': market['id'], + // 'TradeId': 123, // If you specify TradeId, GetTradesHistory can return all states for a single trade + // 'OrderId': 456, // If specified, the call returns all trades associated with the order + // 'UserId': integer. The ID of the logged-in user. If not specified, the call returns trades associated with the users belonging to the default account for the logged-in user of this OMS. + // 'StartTimeStamp': long integer. The historical date and time at which to begin the trade report, in POSIX format. If not specified, reverts to the start date of this account on the trading venue. + // 'EndTimeStamp': long integer. Date at which to end the trade report, in POSIX format. + // 'Depth': integer. In this case, the count of trades to return, counting from the StartIndex. If Depth is not specified, returns all trades between BeginTimeStamp and EndTimeStamp, beginning at StartIndex. + // 'StartIndex': 0 // from the most recent trade 0 and moving backwards in time + // 'ExecutionId': 123, // The ID of the individual buy or sell execution. If not specified, returns all. + }; + let market = undefined; + if (symbol !== undefined) { + market = this.market (symbol); + request['InstrumentId'] = market['id']; + } + if (since !== undefined) { + request['StartTimeStamp'] = since; + } + if (limit !== undefined) { + request['Depth'] = limit; + } + const response = await this.privateGetGetTradesHistory (this.extend (request, params)); + // + // [ + // { + // "OMSId":1, + // "ExecutionId":16916567, + // "TradeId":14476351, + // "OrderId":2543565231, + // "AccountId":449, + // "AccountName":"igor@ccxt.trade", + // "SubAccountId":0, + // "ClientOrderId":0, + // "InstrumentId":8, + // "Side":"Sell", + // "OrderType":"Market", + // "Quantity":0.1230000000000000000000000000, + // "RemainingQuantity":0.0000000000000000000000000000, + // "Price":19069.310000000000000000000000, + // "Value":2345.5251300000000000000000000, + // "CounterParty":"7", + // "OrderTradeRevision":1, + // "Direction":"NoChange", + // "IsBlockTrade":false, + // "Fee":1.1727625650000000000000000000, + // "FeeProductId":8, + // "OrderOriginator":446, + // "UserName":"igor@ccxt.trade", + // "TradeTimeMS":1607565031569, + // "MakerTaker":"Taker", + // "AdapterTradeId":0, + // "InsideBid":19069.310000000000000000000000, + // "InsideBidSize":0.2400950000000000000000000000, + // "InsideAsk":19069.320000000000000000000000, + // "InsideAskSize":0.0997360000000000000000000000, + // "IsQuote":false, + // "CounterPartyClientUserId":1, + // "NotionalProductId":2, + // "NotionalRate":1.0000000000000000000000000000, + // "NotionalValue":2345.5251300000000000000000000, + // "NotionalHoldAmount":0, + // "TradeTime":637431618315686826 + // } + // ] + // + return this.parseTrades (response, market, since, limit); + } + + async cancelAllOrders (symbol = undefined, params = {}) { + const omsId = this.safeInteger (this.options, 'omsId', 1); + await this.loadMarkets (); + await this.loadAccounts (); + const defaultAccountId = this.safeInteger2 (this.options, 'accountId', 'AccountId', parseInt (this.accounts[0]['id'])); + const accountId = this.safeInteger2 (params, 'accountId', 'AccountId', defaultAccountId); + params = this.omit (params, [ 'accountId', 'AccountId' ]); + const request = { + 'omsId': omsId, + 'AccountId': accountId, + }; + if (symbol !== undefined) { + const market = this.market (symbol); + request['IntrumentId'] = market['id']; + } + const response = await this.privatePostCancelAllOrders (this.extend (request, params)); + // + // { + // "result":true, + // "errormsg":null, + // "errorcode":0, + // "detail":null + // } + // + return response; + } + + async cancelOrder (id, symbol = undefined, params = {}) { + const omsId = this.safeInteger (this.options, 'omsId', 1); + await this.loadMarkets (); + await this.loadAccounts (); + // const defaultAccountId = this.safeInteger2 (this.options, 'accountId', 'AccountId', parseInt (this.accounts[0]['id'])); + // const accountId = this.safeInteger2 (params, 'accountId', 'AccountId', defaultAccountId); + // params = this.omit (params, [ 'accountId', 'AccountId' ]); + let market = undefined; + if (symbol !== undefined) { + market = this.market (symbol); + } + const request = { + 'omsId': omsId, + // 'AccountId': accountId, + }; + const clientOrderId = this.safeInteger2 (params, 'clientOrderId', 'ClOrderId'); + if (clientOrderId !== undefined) { + request['ClOrderId'] = clientOrderId; + } else { + request['OrderId'] = parseInt (id); + } + params = this.omit (params, [ 'clientOrderId', 'ClOrderId' ]); + const response = await this.privatePostCancelOrder (this.extend (request, params)); + const order = this.parseOrder (response, market); + return this.extend (order, { + 'id': id, + 'clientOrderId': clientOrderId, + }); + } + + async fetchOpenOrders (symbol = undefined, since = undefined, limit = undefined, params = {}) { + const omsId = this.safeInteger (this.options, 'omsId', 1); + await this.loadMarkets (); + await this.loadAccounts (); + const defaultAccountId = this.safeInteger2 (this.options, 'accountId', 'AccountId', parseInt (this.accounts[0]['id'])); + const accountId = this.safeInteger2 (params, 'accountId', 'AccountId', defaultAccountId); + params = this.omit (params, [ 'accountId', 'AccountId' ]); + let market = undefined; + if (symbol !== undefined) { + market = this.market (symbol); + } + const request = { + 'omsId': omsId, + 'AccountId': accountId, + }; + const response = await this.privateGetGetOpenOrders (this.extend (request, params)); + // + // [ + // { + // "Side":"Buy", + // "OrderId":2543565233, + // "Price":19010, + // "Quantity":0.345, + // "DisplayQuantity":0.345, + // "Instrument":8, + // "Account":449, + // "AccountName":"igor@ccxt.trade", + // "OrderType":"Limit", + // "ClientOrderId":0, + // "OrderState":"Working", + // "ReceiveTime":1607579326003, + // "ReceiveTimeTicks":637431761260028981, + // "LastUpdatedTime":1607579326005, + // "LastUpdatedTimeTicks":637431761260054714, + // "OrigQuantity":0.345, + // "QuantityExecuted":0, + // "GrossValueExecuted":0, + // "ExecutableValue":0, + // "AvgPrice":0, + // "CounterPartyId":0, + // "ChangeReason":"NewInputAccepted", + // "OrigOrderId":2543565233, + // "OrigClOrdId":0, + // "EnteredBy":446, + // "UserName":"igor@ccxt.trade", + // "IsQuote":false, + // "InsideAsk":19069.32, + // "InsideAskSize":0.099736, + // "InsideBid":19068.25, + // "InsideBidSize":1.330001, + // "LastTradePrice":19068.25, + // "RejectReason":"", + // "IsLockedIn":false, + // "CancelReason":"", + // "OrderFlag":"AddedToBook", + // "UseMargin":false, + // "StopPrice":0, + // "PegPriceType":"Unknown", + // "PegOffset":0, + // "PegLimitOffset":0, + // "IpAddress":null, + // "ClientOrderIdUuid":null, + // "OMSId":1 + // } + // ] + // + return this.parseOrders (response, market, since, limit); + } + + async fetchOrders (symbol = undefined, since = undefined, limit = undefined, params = {}) { + const omsId = this.safeInteger (this.options, 'omsId', 1); + await this.loadMarkets (); + await this.loadAccounts (); + const defaultAccountId = this.safeInteger2 (this.options, 'accountId', 'AccountId', parseInt (this.accounts[0]['id'])); + const accountId = this.safeInteger2 (params, 'accountId', 'AccountId', defaultAccountId); + params = this.omit (params, [ 'accountId', 'AccountId' ]); + const request = { + 'omsId': omsId, + 'AccountId': accountId, + // 'ClientOrderId': clientOrderId, + // 'OriginalOrderId': id, + // 'OriginalClientOrderId': long integer, + // 'UserId': integer, + // 'InstrumentId': market['id'], + // 'StartTimestamp': since, + // 'EndTimestamp': this.milliseconds (), + // 'Depth': limit, + // 'StartIndex': 0, + }; + let market = undefined; + if (symbol !== undefined) { + market = this.market (symbol); + request['InstrumentId'] = market['id']; + } + if (since !== undefined) { + request['StartTimeStamp'] = since; + } + if (limit !== undefined) { + request['Depth'] = limit; + } + const response = await this.privateGetGetOrdersHistory (this.extend (request, params)); + // + // [ + // { + // "Side":"Buy", + // "OrderId":2543565233, + // "Price":19010.000000000000000000000000, + // "Quantity":0.0000000000000000000000000000, + // "DisplayQuantity":0.3450000000000000000000000000, + // "Instrument":8, + // "Account":449, + // "AccountName":"igor@ccxt.trade", + // "OrderType":"Limit", + // "ClientOrderId":0, + // "OrderState":"Canceled", + // "ReceiveTime":1607579326003, + // "ReceiveTimeTicks":637431761260028981, + // "LastUpdatedTime":1607580965346, + // "LastUpdatedTimeTicks":637431777653463754, + // "OrigQuantity":0.3450000000000000000000000000, + // "QuantityExecuted":0.0000000000000000000000000000, + // "GrossValueExecuted":0.0000000000000000000000000000, + // "ExecutableValue":0.0000000000000000000000000000, + // "AvgPrice":0.0000000000000000000000000000, + // "CounterPartyId":0, + // "ChangeReason":"UserModified", + // "OrigOrderId":2543565233, + // "OrigClOrdId":0, + // "EnteredBy":446, + // "UserName":"igor@ccxt.trade", + // "IsQuote":false, + // "InsideAsk":19069.320000000000000000000000, + // "InsideAskSize":0.0997360000000000000000000000, + // "InsideBid":19068.250000000000000000000000, + // "InsideBidSize":1.3300010000000000000000000000, + // "LastTradePrice":19068.250000000000000000000000, + // "RejectReason":"", + // "IsLockedIn":false, + // "CancelReason":"UserModified", + // "OrderFlag":"AddedToBook, RemovedFromBook", + // "UseMargin":false, + // "StopPrice":0.0000000000000000000000000000, + // "PegPriceType":"Unknown", + // "PegOffset":0.0000000000000000000000000000, + // "PegLimitOffset":0.0000000000000000000000000000, + // "IpAddress":"5.228.233.138", + // "ClientOrderIdUuid":null, + // "OMSId":1 + // }, + // ] + // + return this.parseOrders (response, market, since, limit); + } + + async fetchOrder (id, symbol = undefined, params = {}) { + const omsId = this.safeInteger (this.options, 'omsId', 1); + await this.loadMarkets (); + await this.loadAccounts (); + const defaultAccountId = this.safeInteger2 (this.options, 'accountId', 'AccountId', parseInt (this.accounts[0]['id'])); + const accountId = this.safeInteger2 (params, 'accountId', 'AccountId', defaultAccountId); + params = this.omit (params, [ 'accountId', 'AccountId' ]); + let market = undefined; + if (symbol !== undefined) { + market = this.market (symbol); + } + const request = { + 'omsId': omsId, + 'AccountId': accountId, + 'OrderId': parseInt (id), + }; + const response = await this.privateGetGetOrderStatus (this.extend (request, params)); + // + // { + // "Side":"Sell", + // "OrderId":2543565232, + // "Price":0.0000000000000000000000000000, + // "Quantity":0.0000000000000000000000000000, + // "DisplayQuantity":0.0000000000000000000000000000, + // "Instrument":8, + // "Account":449, + // "AccountName":"igor@ccxt.trade", + // "OrderType":"Market", + // "ClientOrderId":0, + // "OrderState":"FullyExecuted", + // "ReceiveTime":1607569475591, + // "ReceiveTimeTicks":637431662755912377, + // "LastUpdatedTime":1607569475596, + // "LastUpdatedTimeTicks":637431662755960902, + // "OrigQuantity":1.0000000000000000000000000000, + // "QuantityExecuted":1.0000000000000000000000000000, + // "GrossValueExecuted":19068.270478610000000000000000, + // "ExecutableValue":0.0000000000000000000000000000, + // "AvgPrice":19068.270478610000000000000000, + // "CounterPartyId":0, + // "ChangeReason":"Trade", + // "OrigOrderId":2543565232, + // "OrigClOrdId":0, + // "EnteredBy":446, + // "UserName":"igor@ccxt.trade", + // "IsQuote":false, + // "InsideAsk":19069.320000000000000000000000, + // "InsideAskSize":0.0997360000000000000000000000, + // "InsideBid":19069.310000000000000000000000, + // "InsideBidSize":0.2400950000000000000000000000, + // "LastTradePrice":19069.310000000000000000000000, + // "RejectReason":"", + // "IsLockedIn":false, + // "CancelReason":"", + // "OrderFlag":"0", + // "UseMargin":false, + // "StopPrice":0.0000000000000000000000000000, + // "PegPriceType":"Unknown", + // "PegOffset":0.0000000000000000000000000000, + // "PegLimitOffset":0.0000000000000000000000000000, + // "IpAddress":"5.228.233.138", + // "ClientOrderIdUuid":null, + // "OMSId":1 + // } + // + return this.parseOrder (response, market); + } + + async fetchOrderTrades (id, symbol = undefined, since = undefined, limit = undefined, params = {}) { + const omsId = this.safeInteger (this.options, 'omsId', 1); + await this.loadMarkets (); + await this.loadAccounts (); + // const defaultAccountId = this.safeInteger2 (this.options, 'accountId', 'AccountId', parseInt (this.accounts[0]['id'])); + // const accountId = this.safeInteger2 (params, 'accountId', 'AccountId', defaultAccountId); + // params = this.omit (params, [ 'accountId', 'AccountId' ]); + let market = undefined; + if (symbol !== undefined) { + market = this.market (symbol); + } + const request = { + 'OMSId': parseInt (omsId), + // 'AccountId': accountId, + 'OrderId': id, + }; + const response = await this.privatePostGetOrderHistoryByOrderId (this.extend (request, params)); + // + // [ + // { + // "Side":"Sell", + // "OrderId":2543565235, + // "Price":18600.000000000000000000000000, + // "Quantity":0.0000000000000000000000000000, + // "DisplayQuantity":0.0000000000000000000000000000, + // "Instrument":8, + // "Account":449, + // "AccountName":"igor@ccxt.trade", + // "OrderType":"Limit", + // "ClientOrderId":0, + // "OrderState":"FullyExecuted", + // "ReceiveTime":1607585844956, + // "ReceiveTimeTicks":637431826449564182, + // "LastUpdatedTime":1607585844959, + // "LastUpdatedTimeTicks":637431826449593893, + // "OrigQuantity":0.1230000000000000000000000000, + // "QuantityExecuted":0.1230000000000000000000000000, + // "GrossValueExecuted":2345.3947500000000000000000000, + // "ExecutableValue":0.0000000000000000000000000000, + // "AvgPrice":19068.250000000000000000000000, + // "CounterPartyId":0, + // "ChangeReason":"Trade", + // "OrigOrderId":2543565235, + // "OrigClOrdId":0, + // "EnteredBy":446, + // "UserName":"igor@ccxt.trade", + // "IsQuote":false, + // "InsideAsk":19069.320000000000000000000000, + // "InsideAskSize":0.0997360000000000000000000000, + // "InsideBid":19068.250000000000000000000000, + // "InsideBidSize":1.3300010000000000000000000000, + // "LastTradePrice":19068.250000000000000000000000, + // "RejectReason":"", + // "IsLockedIn":false, + // "CancelReason":"", + // "OrderFlag":"0", + // "UseMargin":false, + // "StopPrice":0.0000000000000000000000000000, + // "PegPriceType":"Unknown", + // "PegOffset":0.0000000000000000000000000000, + // "PegLimitOffset":0.0000000000000000000000000000, + // "IpAddress":"5.228.233.138", + // "ClientOrderIdUuid":null, + // "OMSId":1 + // }, + // ] + // + const grouped = this.groupBy (response, 'ChangeReason'); + const trades = this.safeValue (grouped, 'Trade', []); + return this.parseTrades (trades, market, since, limit); + } + + async fetchDepositAddress (code, params = {}) { + const omsId = this.safeInteger (this.options, 'omsId', 1); + await this.loadMarkets (); + await this.loadAccounts (); + const defaultAccountId = this.safeInteger2 (this.options, 'accountId', 'AccountId', parseInt (this.accounts[0]['id'])); + const accountId = this.safeInteger2 (params, 'accountId', 'AccountId', defaultAccountId); + params = this.omit (params, [ 'accountId', 'AccountId' ]); + const currency = this.currency (code); + const request = { + 'omsId': omsId, + 'AccountId': accountId, + 'ProductId': currency['id'], + 'GenerateNewKey': false, + }; + const response = await this.privateGetGetDepositInfo (this.extend (request, params)); + // + // { + // "result":true, + // "errormsg":null, + // "statuscode":0, + // "AssetManagerId":1, + // "AccountId":57922, + // "AssetId":16, + // "ProviderId":23, + // "DepositInfo":"[\"0x8A27564b5c30b91C93B1591821642420F323a210\"]" + // } + // + return this.parseDepositAddress (response, currency); + } + + parseDepositAddress (depositAddress, currency = undefined) { + // + // fetchDepositAddress, createDepositAddress + // + // { + // "result":true, + // "errormsg":null, + // "statuscode":0, + // "AssetManagerId":1, + // "AccountId":449, + // "AssetId":1, + // "ProviderId":1, + // "DepositInfo":"[\"r3e95RwVsLH7yCbnMfyh7SA8FdwUJCB4S2?memo=241452010\"]" + // } + // + const depositInfoString = this.safeString (depositAddress, 'DepositInfo'); + const depositInfo = JSON.parse (depositInfoString); + const depositInfoLength = depositInfo.length; + const lastString = this.safeString (depositInfo, depositInfoLength - 1); + const parts = lastString.split ('?memo='); + const address = this.safeString (parts, 0); + const tag = this.safeString (parts, 1); + let code = undefined; + if (currency !== undefined) { + code = currency['code']; + } + this.checkAddress (address); + return { + 'currency': code, + 'address': address, + 'tag': tag, + 'info': depositAddress, + }; + } + + async createDepositAddress (code, params = {}) { + const request = { + 'GenerateNewKey': true, + }; + return await this.fetchDepositAddress (code, this.extend (request, params)); + } + + async fetchDeposits (code = undefined, since = undefined, limit = undefined, params = {}) { + const omsId = this.safeInteger (this.options, 'omsId', 1); + await this.loadMarkets (); + await this.loadAccounts (); + const defaultAccountId = this.safeInteger2 (this.options, 'accountId', 'AccountId', parseInt (this.accounts[0]['id'])); + const accountId = this.safeInteger2 (params, 'accountId', 'AccountId', defaultAccountId); + params = this.omit (params, [ 'accountId', 'AccountId' ]); + let currency = undefined; + if (code !== undefined) { + currency = this.currency (code); + } + const request = { + 'omsId': omsId, + 'AccountId': accountId, + }; + const response = await this.privateGetGetDeposits (this.extend (request, params)); + // + // [ + // { + // "OMSId":1, + // "DepositId":44, + // "AccountId":449, + // "SubAccountId":0, + // "ProductId":4, + // "Amount":200.00000000000000000000000000, + // "LastUpdateTimeStamp":637431291261187806, + // "ProductType":"CryptoCurrency", + // "TicketStatus":"FullyProcessed", + // "DepositInfo":"{}", + // "DepositCode":"ab0e23d5-a9ce-4d94-865f-9ab464fb1de3", + // "TicketNumber":71, + // "NotionalProductId":13, + // "NotionalValue":200.00000000000000000000000000, + // "FeeAmount":0.0000000000000000000000000000, + // }, + // ] + // + return this.parseTransactions (response, currency, since, limit); + } + + async fetchWithdrawals (code = undefined, since = undefined, limit = undefined, params = {}) { + const omsId = this.safeInteger (this.options, 'omsId', 1); + await this.loadMarkets (); + await this.loadAccounts (); + const defaultAccountId = this.safeInteger2 (this.options, 'accountId', 'AccountId', parseInt (this.accounts[0]['id'])); + const accountId = this.safeInteger2 (params, 'accountId', 'AccountId', defaultAccountId); + params = this.omit (params, [ 'accountId', 'AccountId' ]); + let currency = undefined; + if (code !== undefined) { + currency = this.currency (code); + } + const request = { + 'omsId': omsId, + 'AccountId': accountId, + }; + const response = await this.privateGetGetWithdraws (this.extend (request, params)); + // + // [ + // { + // "Amount": 0.0, + // "FeeAmount": 0.0, + // "NotionalValue": 0.0, + // "WithdrawId": 0, + // "AssetManagerId": 0, + // "AccountId": 0, + // "AssetId": 0, + // "TemplateForm": "{\"TemplateType\": \"TetherRPCWithdraw\",\"Comment\": \"TestWithdraw\",\"ExternalAddress\": \"ms6C3pKAAr8gRCcnVebs8VRkVrjcvqNYv3\"}", + // "TemplateFormType": "TetherRPCWithdraw", + // "omsId": 0, + // "TicketStatus": 0, + // "TicketNumber": 0, + // "WithdrawTransactionDetails": "", + // "WithdrawType": "", + // "WithdrawCode": "490b4fa3-53fc-44f4-bd29-7e16be86fba3", + // "AssetType": 0, + // "Reaccepted": true, + // "NotionalProductId": 0 + // }, + // ] + // + return this.parseTransactions (response, currency, since, limit); + } + + parseTransactionStatusByType (status, type = undefined) { + const statusesByType = { + 'deposit': { + 'New': 'pending', // new ticket awaiting operator review + 'AdminProcessing': 'pending', // an admin is looking at the ticket + 'Accepted': 'pending', // an admin accepts the ticket + 'Rejected': 'rejected', // admin rejects the ticket + 'SystemProcessing': 'pending', // automatic processing; an unlikely status for a deposit + 'FullyProcessed': 'ok', // the deposit has concluded + 'Failed': 'failed', // the deposit has failed for some reason + 'Pending': 'pending', // Account Provider has set status to pending + 'Confirmed': 'pending', // Account Provider confirms the deposit + 'AmlProcessing': 'pending', // anti-money-laundering process underway + 'AmlAccepted': 'pending', // anti-money-laundering process successful + 'AmlRejected': 'rejected', // deposit did not stand up to anti-money-laundering process + 'AmlFailed': 'failed', // anti-money-laundering process failed/did not complete + 'LimitsAccepted': 'pending', // deposit meets limits for fiat or crypto asset + 'LimitsRejected': 'rejected', // deposit does not meet limits for fiat or crypto asset + }, + 'withdrawal': { + 'New': 'pending', // awaiting operator review + 'AdminProcessing': 'pending', // An admin is looking at the ticket + 'Accepted': 'pending', // withdrawal will proceed + 'Rejected': 'rejected', // admin or automatic rejection + 'SystemProcessing': 'pending', // automatic processing underway + 'FullyProcessed': 'ok', // the withdrawal has concluded + 'Failed': 'failed', // the withdrawal failed for some reason + 'Pending': 'pending', // the admin has placed the withdrawal in pending status + 'Pending2Fa': 'pending', // user must click 2-factor authentication confirmation link + 'AutoAccepted': 'pending', // withdrawal will be automatically processed + 'Delayed': 'pending', // waiting for funds to be allocated for the withdrawal + 'UserCanceled': 'canceled', // withdraw canceled by user or Superuser + 'AdminCanceled': 'canceled', // withdraw canceled by Superuser + 'AmlProcessing': 'pending', // anti-money-laundering process underway + 'AmlAccepted': 'pending', // anti-money-laundering process complete + 'AmlRejected': 'rejected', // withdrawal did not stand up to anti-money-laundering process + 'AmlFailed': 'failed', // withdrawal did not complete anti-money-laundering process + 'LimitsAccepted': 'pending', // withdrawal meets limits for fiat or crypto asset + 'LimitsRejected': 'rejected', // withdrawal does not meet limits for fiat or crypto asset + 'Submitted': 'pending', // withdrawal sent to Account Provider; awaiting blockchain confirmation + 'Confirmed': 'pending', // Account Provider confirms that withdrawal is on the blockchain + 'ManuallyConfirmed': 'pending', // admin has sent withdrawal via wallet or admin function directly; marks ticket as FullyProcessed; debits account + 'Confirmed2Fa': 'pending', // user has confirmed withdraw via 2-factor authentication. + }, + }; + const statuses = this.safeValue (statusesByType, type, {}); + return this.safeString (statuses, status, status); + } + + parseTransaction (transaction, currency = undefined) { + // + // fetchDeposits + // + // { + // "OMSId":1, + // "DepositId":44, + // "AccountId":449, + // "SubAccountId":0, + // "ProductId":4, + // "Amount":200.00000000000000000000000000, + // "LastUpdateTimeStamp":637431291261187806, + // "ProductType":"CryptoCurrency", + // "TicketStatus":"FullyProcessed", + // "DepositInfo":"{}", + // "DepositCode":"ab0e23d5-a9ce-4d94-865f-9ab464fb1de3", + // "TicketNumber":71, + // "NotionalProductId":13, + // "NotionalValue":200.00000000000000000000000000, + // "FeeAmount":0.0000000000000000000000000000, + // } + // + // fetchWithdrawals + // + // { + // "Amount": 0.0, + // "FeeAmount": 0.0, + // "NotionalValue": 0.0, + // "WithdrawId": 0, + // "AssetManagerId": 0, + // "AccountId": 0, + // "AssetId": 0, + // "TemplateForm": "{\"TemplateType\": \"TetherRPCWithdraw\",\"Comment\": \"TestWithdraw\",\"ExternalAddress\": \"ms6C3pKAAr8gRCcnVebs8VRkVrjcvqNYv3\"}", + // "TemplateFormType": "TetherRPCWithdraw", + // "omsId": 0, + // "TicketStatus": 0, + // "TicketNumber": 0, + // "WithdrawTransactionDetails": "", + // "WithdrawType": "", + // "WithdrawCode": "490b4fa3-53fc-44f4-bd29-7e16be86fba3", + // "AssetType": 0, + // "Reaccepted": true, + // "NotionalProductId": 0 + // } + // + const id = this.safeString (transaction, 'DepositId'); + let txid = undefined; + const currencyId = this.safeString (transaction, 'ProductId'); + const code = this.safeCurrencyCode (currencyId, currency); + let timestamp = undefined; + let type = undefined; + if ('DepositId' in transaction) { + type = 'deposit'; + } else if ('WithdrawId' in transaction) { + type = 'withdrawal'; + } + const templateFormString = this.safeString (transaction, 'TemplateForm'); + let address = undefined; + let updated = this.safeInteger (transaction, 'LastUpdateTimeStamp'); + if (templateFormString !== undefined) { + const templateForm = JSON.parse (templateFormString); + address = this.safeString (templateForm, 'ExternalAddress'); + txid = this.safeString (templateForm, 'TxId'); + timestamp = this.safeInteger (templateForm, 'TimeSubmitted'); + updated = this.safeInteger (templateForm, 'LastUpdated', updated); + } + const addressTo = address; + const status = this.parseTransactionStatusByType (this.safeString (transaction, 'TicketStatus'), type); + const amount = this.safeFloat (transaction, 'Amount'); + const feeCost = this.safeFloat (transaction, 'FeeAmount'); + let fee = undefined; + if (feeCost !== undefined) { + fee = { 'currency': code, 'cost': feeCost }; + } + return { + 'info': transaction, + 'id': id, + 'txid': txid, + 'timestamp': timestamp, + 'datetime': this.iso8601 (timestamp), + 'address': address, + 'addressTo': addressTo, + 'addressFrom': undefined, + 'tag': undefined, + 'tagTo': undefined, + 'tagFrom': undefined, + 'type': type, + 'amount': amount, + 'currency': code, + 'status': status, + 'updated': updated, + 'fee': fee, + }; + } + + nonce () { + return this.milliseconds (); + } + + sign (path, api = 'public', method = 'GET', params = {}, headers = undefined, body = undefined) { + let url = this.urls['api'][api] + '/' + this.implodeParams (path, params); + const query = this.omit (params, this.extractParams (path)); + if (api === 'public') { + if (Object.keys (query).length) { + url += '?' + this.urlencode (query); + } + } else if (api === 'private') { + this.checkRequiredCredentials (); + const nonce = this.nonce ().toString (); + const auth = nonce + this.uid + this.apiKey; + const signature = this.hmac (this.encode (auth), this.encode (this.secret)); + headers = { + 'Nonce': nonce, + 'APIKey': this.apiKey, + 'Signature': signature, + 'UserId': this.uid, + }; + if (method === 'POST') { + headers['Content-Type'] = 'application/json'; + body = this.json (query); + } else { + if (Object.keys (query).length) { + url += '?' + this.urlencode (query); + } + } + } + return { 'url': url, 'method': method, 'body': body, 'headers': headers }; + } + + handleErrors (code, reason, url, method, headers, body, response, requestHeaders, requestBody) { + if (code === 404) { + throw new AuthenticationError (this.id + ' ' + body); + } + if (response === undefined) { + return; + } + // + // {"status":"Rejected","errormsg":"Not_Enough_Funds","errorcode":101} + // {"result":false,"errormsg":"Server Error","errorcode":102,"detail":null} + // + const message = this.safeString (response, 'errormsg'); + if ((message !== undefined) && (message !== '')) { + const feedback = this.id + ' ' + body; + this.throwExactlyMatchedException (this.exceptions['exact'], message, feedback); + this.throwBroadlyMatchedException (this.exceptions['broad'], body, feedback); + throw new ExchangeError (feedback); + } + } +}; diff --git a/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/novadax.js b/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/novadax.js index c02d4f1a9..dfc6569d2 100644 --- a/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/novadax.js +++ b/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/novadax.js @@ -871,6 +871,7 @@ module.exports = class novadax extends Exchange { 'symbol': symbol, 'type': type, 'timeInForce': undefined, + 'postOnly': undefined, 'side': side, 'price': price, 'stopPrice': undefined, diff --git a/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/oceanex.js b/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/oceanex.js index b77c3dde7..28cb8e857 100644 --- a/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/oceanex.js +++ b/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/oceanex.js @@ -512,7 +512,7 @@ module.exports = class oceanex extends Exchange { async fetchOrders (symbol = undefined, since = undefined, limit = undefined, params = {}) { if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' fetchOrders requires a `symbol` argument'); + throw new ArgumentsRequired (this.id + ' fetchOrders() requires a `symbol` argument'); } await this.loadMarkets (); const market = this.market (symbol); @@ -573,6 +573,7 @@ module.exports = class oceanex extends Exchange { 'symbol': symbol, 'type': this.safeValue (order, 'ord_type'), 'timeInForce': undefined, + 'postOnly': undefined, 'side': this.safeValue (order, 'side'), 'price': this.safeFloat (order, 'price'), 'stopPrice': undefined, diff --git a/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/okex.js b/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/okex.js index a1d6e3c48..b9b09c4e0 100644 --- a/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/okex.js +++ b/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/okex.js @@ -3,7 +3,7 @@ // --------------------------------------------------------------------------- const Exchange = require ('./base/Exchange'); -const { ExchangeError, ExchangeNotAvailable, OnMaintenance, ArgumentsRequired, BadRequest, AccountSuspended, InvalidAddress, PermissionDenied, DDoSProtection, InsufficientFunds, InvalidNonce, CancelPending, InvalidOrder, OrderNotFound, AuthenticationError, RequestTimeout, NotSupported, BadSymbol } = require ('./base/errors'); +const { ExchangeError, ExchangeNotAvailable, OnMaintenance, ArgumentsRequired, BadRequest, AccountSuspended, InvalidAddress, PermissionDenied, DDoSProtection, InsufficientFunds, InvalidNonce, CancelPending, InvalidOrder, OrderNotFound, AuthenticationError, RequestTimeout, NotSupported, BadSymbol, RateLimitExceeded } = require ('./base/errors'); const { TICK_SIZE, TRUNCATE } = require ('./base/functions/number'); // --------------------------------------------------------------------------- @@ -108,6 +108,7 @@ module.exports = class okex extends Exchange { 'accounts/{currency}', 'accounts/{currency}/ledger', 'orders', + 'amend_order/{instrument_id}', 'orders_pending', 'orders/{order_id}', 'orders/{client_oid}', @@ -198,6 +199,7 @@ module.exports = class okex extends Exchange { 'post': [ 'accounts/{underlying}/leverage', 'order', + 'amend_order/{instrument_id}', 'orders', 'cancel_order/{instrument_id}/{order_id}', 'cancel_order/{instrument_id}/{client_oid}', @@ -244,12 +246,17 @@ module.exports = class okex extends Exchange { 'post': [ 'accounts/{instrument_id}/leverage', 'order', + 'amend_order/{instrument_id}', 'orders', 'cancel_order/{instrument_id}/{order_id}', 'cancel_order/{instrument_id}/{client_oid}', 'cancel_batch_orders/{instrument_id}', 'order_algo', 'cancel_algos', + 'close_position', + 'cancel_all', + 'order_algo', + 'cancel_algos', ], }, 'option': { @@ -526,7 +533,7 @@ module.exports = class okex extends Exchange { '34021': InvalidAddress, // { "code": 34021, "message": "Not verified address" } '34022': ExchangeError, // { "code": 34022, "message": "Withdrawals are not available for sub accounts" } '34023': PermissionDenied, // { "code": 34023, "message": "Please enable futures trading before transferring your funds" } - '34026': ExchangeError, // transfer too frequently(transfer too frequently) + '34026': RateLimitExceeded, // transfer too frequently(transfer too frequently) '34036': ExchangeError, // Parameter is incorrect, please refer to API documentation '34037': ExchangeError, // Get the sub-account balance interface, account type is not supported '34038': ExchangeError, // Since your C2C transaction is unusual, you are restricted from fund transfer. Please contact our customer support to cancel the restriction @@ -555,7 +562,7 @@ module.exports = class okex extends Exchange { '35031': InvalidOrder, // { "code": 35031, "message": "Cancel order size too large" } '35032': ExchangeError, // { "code": 35032, "message": "Invalid user status" } '35037': ExchangeError, // No last traded price in cache - '35039': ExchangeError, // { "code": 35039, "message": "Open order quantity exceeds limit" } + '35039': InsufficientFunds, // { "code": 35039, "message": "Open order quantity exceeds limit" } '35040': InvalidOrder, // {"error_message":"Invalid order type","result":"true","error_code":"35040","order_id":"-1"} '35044': ExchangeError, // { "code": 35044, "message": "Invalid order status" } '35046': InsufficientFunds, // { "code": 35046, "message": "Negative account balance" } @@ -608,6 +615,7 @@ module.exports = class okex extends Exchange { '35097': ExchangeError, // Order status and order ID cannot exist at the same time '35098': ExchangeError, // An order status or order ID must exist '35099': ExchangeError, // Algo order ID error + '35102': RateLimitExceeded, // {"error_message":"The operation that close all at market price is too frequent","result":"true","error_code":"35102","order_id":"-1"} // option '36001': BadRequest, // Invalid underlying index. '36002': BadRequest, // Instrument does not exist. @@ -677,6 +685,7 @@ module.exports = class okex extends Exchange { 'HOT': 'Hydro Protocol', 'HSR': 'HC', 'MAG': 'Maggie', + 'SBTC': 'Super Bitcoin', 'YOYO': 'YOYOW', 'WIN': 'WinToken', // https://github.com/ccxt/ccxt/issues/5701 }, @@ -976,7 +985,7 @@ module.exports = class okex extends Exchange { const currency = response[i]; const id = this.safeString (currency, 'currency'); const code = this.safeCurrencyCode (id); - const precision = 8; // default precision, todo: fix "magic constants" + const precision = 0.00000001; // default precision, todo: fix "magic constants" const name = this.safeString (currency, 'name'); const canDeposit = this.safeInteger (currency, 'can_deposit'); const canWithdraw = this.safeInteger (currency, 'can_withdraw'); @@ -1712,7 +1721,7 @@ module.exports = class okex extends Exchange { const defaultType = this.safeString2 (this.options, 'fetchBalance', 'defaultType'); const type = this.safeString (params, 'type', defaultType); if (type === undefined) { - throw new ArgumentsRequired (this.id + " fetchBalance requires a type parameter (one of 'account', 'spot', 'margin', 'futures', 'swap')"); + throw new ArgumentsRequired (this.id + " fetchBalance() requires a type parameter (one of 'account', 'spot', 'margin', 'futures', 'swap')"); } await this.loadMarkets (); const suffix = (type === 'account') ? 'Wallet' : 'Accounts'; @@ -1958,7 +1967,7 @@ module.exports = class okex extends Exchange { type = this.safeString (params, 'type', defaultType); } if (type === undefined) { - throw new ArgumentsRequired (this.id + " cancelOrder requires a type parameter (one of 'spot', 'margin', 'futures', 'swap')."); + throw new ArgumentsRequired (this.id + " cancelOrder() requires a type parameter (one of 'spot', 'margin', 'futures', 'swap')."); } let method = type + 'PostCancelOrder'; const request = { @@ -2165,6 +2174,7 @@ module.exports = class okex extends Exchange { 'symbol': symbol, 'type': type, 'timeInForce': undefined, + 'postOnly': undefined, 'side': side, 'price': price, 'stopPrice': stopPrice, @@ -2181,14 +2191,14 @@ module.exports = class okex extends Exchange { async fetchOrder (id, symbol = undefined, params = {}) { if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' fetchOrder requires a symbol argument'); + throw new ArgumentsRequired (this.id + ' fetchOrder() requires a symbol argument'); } await this.loadMarkets (); const market = this.market (symbol); const defaultType = this.safeString2 (this.options, 'fetchOrder', 'defaultType', market['type']); const type = this.safeString (params, 'type', defaultType); if (type === undefined) { - throw new ArgumentsRequired (this.id + " fetchOrder requires a type parameter (one of 'spot', 'margin', 'futures', 'swap')."); + throw new ArgumentsRequired (this.id + " fetchOrder() requires a type parameter (one of 'spot', 'margin', 'futures', 'swap')."); } const instrumentId = (market['futures'] || market['swap']) ? 'InstrumentId' : ''; let method = type + 'GetOrders' + instrumentId; @@ -2256,7 +2266,7 @@ module.exports = class okex extends Exchange { async fetchOrdersByState (state, symbol = undefined, since = undefined, limit = undefined, params = {}) { if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' fetchOrdersByState requires a symbol argument'); + throw new ArgumentsRequired (this.id + ' fetchOrdersByState() requires a symbol argument'); } await this.loadMarkets (); const market = this.market (symbol); @@ -2268,7 +2278,7 @@ module.exports = class okex extends Exchange { type = this.safeString (params, 'type', defaultType); } if (type === undefined) { - throw new ArgumentsRequired (this.id + " fetchOrder requires a type parameter (one of 'spot', 'margin', 'futures', 'swap')."); + throw new ArgumentsRequired (this.id + " fetchOrdersByState() requires a type parameter (one of 'spot', 'margin', 'futures', 'swap')."); } const request = { 'instrument_id': market['id'], @@ -2598,6 +2608,7 @@ module.exports = class okex extends Exchange { // "currency": "XMR", // "from": "", // "to": "48PjH3ksv1fiXniKvKvyH5UtFs5WhfS2Vf7U3TwzdRJtCc7HJWvCQe56dRahyhQyTAViXZ8Nzk4gQg6o4BJBMUoxNy8y8g7", + // "tag": "1234567", // "deposit_id": 11571659, <-- we can use this // "timestamp": "2019-10-01T14:54:19.000Z", // "status": "2" @@ -2609,6 +2620,7 @@ module.exports = class okex extends Exchange { const withdrawalId = this.safeString (transaction, 'withdrawal_id'); const addressFrom = this.safeString (transaction, 'from'); const addressTo = this.safeString (transaction, 'to'); + const tagTo = this.safeString (transaction, 'tag'); if (withdrawalId !== undefined) { type = 'withdrawal'; id = withdrawalId; @@ -2649,8 +2661,8 @@ module.exports = class okex extends Exchange { 'addressTo': addressTo, 'address': address, 'tagFrom': undefined, - 'tagTo': undefined, - 'tag': undefined, + 'tagTo': tagTo, + 'tag': tagTo, 'status': status, 'type': type, 'updated': undefined, @@ -2823,7 +2835,7 @@ module.exports = class okex extends Exchange { // this aspect renders the 'fills' endpoint unusable for fetchOrderTrades // until either OKEX fixes the API or we workaround this on our side somehow if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' fetchMyTrades requires a symbol argument'); + throw new ArgumentsRequired (this.id + ' fetchMyTrades() requires a symbol argument'); } await this.loadMarkets (); const market = this.market (symbol); @@ -3212,16 +3224,28 @@ module.exports = class okex extends Exchange { request['limit'] = limit; } let currency = undefined; - if ((type === 'spot') || (type === 'futures')) { + if (type === 'spot') { if (code === undefined) { - throw new ArgumentsRequired (this.id + " fetchLedger requires a currency code argument for '" + type + "' markets"); + throw new ArgumentsRequired (this.id + " fetchLedger() requires a currency code argument for '" + type + "' markets"); } argument = 'Currency'; currency = this.currency (code); request['currency'] = currency['id']; + } else if (type === 'futures') { + if (code === undefined) { + throw new ArgumentsRequired (this.id + " fetchLedger() requires an underlying symbol for '" + type + "' markets"); + } + argument = 'Underlying'; + const market = this.market (code); // we intentionally put a market inside here for the margin and swap ledgers + const marketInfo = this.safeValue (market, 'info', {}); + const settlementCurrencyId = this.safeString (marketInfo, 'settlement_currency'); + const settlementCurrencyСode = this.safeCurrencyCode (settlementCurrencyId); + currency = this.currency (settlementCurrencyСode); + const underlyingId = this.safeString (marketInfo, 'underlying'); + request['underlying'] = underlyingId; } else if ((type === 'margin') || (type === 'swap')) { if (code === undefined) { - throw new ArgumentsRequired (this.id + " fetchLedger requires a code argument (a market symbol) for '" + type + "' markets"); + throw new ArgumentsRequired (this.id + " fetchLedger() requires a code argument (a market symbol) for '" + type + "' markets"); } argument = 'InstrumentId'; const market = this.market (code); // we intentionally put a market inside here for the margin and swap ledgers diff --git a/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/phemex.js b/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/phemex.js index 5fa317455..b1c294ab2 100644 --- a/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/phemex.js +++ b/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/phemex.js @@ -102,6 +102,7 @@ module.exports = class phemex extends Exchange { 'exchange/spot/order/trades', // ?symbol=&start=&end=&limit=&offset= // swap 'accounts/accountPositions', // ?currency= + 'accounts/positions', // ?currency= 'orders/activeList', // ?symbol= 'exchange/order/list', // ?symbol=&start=&end=&offset=&limit=&ordStatus=&withCount= 'exchange/order', // ?symbol=&orderID= @@ -728,7 +729,7 @@ module.exports = class phemex extends Exchange { parseBidAsk (bidask, priceKey = 0, amountKey = 1, market = undefined) { if (market === undefined) { - throw new ArgumentsRequired (this.id + ' parseBidAsk requires a market argument'); + throw new ArgumentsRequired (this.id + ' parseBidAsk() requires a market argument'); } let amount = this.safeFloat (bidask, amountKey); if (market['spot']) { @@ -821,6 +822,9 @@ module.exports = class phemex extends Exchange { } fromEn (en, scale, precision, precisionMode = undefined) { + if (en === undefined) { + return en; + } precisionMode = (precisionMode === undefined) ? this.precisionMode : precisionMode; return parseFloat (this.decimalToPrecision (en * Math.pow (10, -scale), ROUND, precision, precisionMode)); } @@ -864,13 +868,19 @@ module.exports = class phemex extends Exchange { // 48759063370, // quote volume // ] // + let baseVolume = undefined; + if ((market !== undefined) && market['spot']) { + baseVolume = this.fromEv (this.safeFloat (ohlcv, 7), market); + } else { + baseVolume = this.safeInteger (ohlcv, 7); + } return [ this.safeTimestamp (ohlcv, 0), this.fromEp (this.safeFloat (ohlcv, 3), market), this.fromEp (this.safeFloat (ohlcv, 4), market), this.fromEp (this.safeFloat (ohlcv, 5), market), this.fromEp (this.safeFloat (ohlcv, 6), market), - this.fromEv (this.safeFloat (ohlcv, 7), market), + baseVolume, ]; } @@ -897,7 +907,7 @@ module.exports = class phemex extends Exchange { request['from'] = now - duration * this.sum (limit, 1); request['to'] = now; } else { - throw new ArgumentsRequired (this.id + ' fetchOHLCV requires a since argument, or a limit argument, or both'); + throw new ArgumentsRequired (this.id + ' fetchOHLCV() requires a since argument, or a limit argument, or both'); } await this.loadMarkets (); const market = this.market (symbol); @@ -1402,7 +1412,7 @@ module.exports = class phemex extends Exchange { } else { const currency = this.safeString (params, 'currency'); if (currency === undefined) { - throw new ArgumentsRequired (this.id + ' fetchBalance requires a code parameter or a currency parameter for ' + type + ' type'); + throw new ArgumentsRequired (this.id + ' fetchBalance() requires a code parameter or a currency parameter for ' + type + ' type'); } } method = 'privateGetAccountsAccountPositions'; @@ -1637,8 +1647,9 @@ module.exports = class phemex extends Exchange { filled = Math.min (0, amount - remaining); } } - const timeInForce = this.parseTimeInForce (this.safeStirng (order, 'timeInForce')); + const timeInForce = this.parseTimeInForce (this.safeString (order, 'timeInForce')); const stopPrice = this.fromEp (this.safeFloat (order, 'stopPxEp', market)); + const postOnly = (timeInForce === 'PO'); return { 'info': order, 'id': id, @@ -1649,6 +1660,7 @@ module.exports = class phemex extends Exchange { 'symbol': symbol, 'type': type, 'timeInForce': timeInForce, + 'postOnly': postOnly, 'side': side, 'price': price, 'stopPrice': stopPrice, @@ -1721,6 +1733,7 @@ module.exports = class phemex extends Exchange { } const timeInForce = this.parseTimeInForce (this.safeString (order, 'timeInForce')); const stopPrice = this.safeFloat (order, 'stopPx'); + const postOnly = (timeInForce === 'PO'); return { 'info': order, 'id': id, @@ -1731,6 +1744,7 @@ module.exports = class phemex extends Exchange { 'symbol': symbol, 'type': type, 'timeInForce': timeInForce, + 'postOnly': postOnly, 'side': side, 'price': price, 'stopPrice': stopPrice, @@ -1786,8 +1800,10 @@ module.exports = class phemex extends Exchange { }; if (market['spot']) { let qtyType = this.safeValue (params, 'qtyType', 'ByBase'); - if (price !== undefined) { - qtyType = 'ByQuote'; + if ((type === 'Market') || (type === 'Stop') || (type === 'MarketIfTouched')) { + if (price !== undefined) { + qtyType = 'ByQuote'; + } } request['qtyType'] = qtyType; if (qtyType === 'ByQuote') { @@ -1797,7 +1813,7 @@ module.exports = class phemex extends Exchange { if (price !== undefined) { cost = amount * price; } else if (cost === undefined) { - throw new ArgumentsRequired (this.id + ' createOrder ' + qtyType + ' requires a price argument or a cost parameter'); + throw new ArgumentsRequired (this.id + ' createOrder() ' + qtyType + ' requires a price argument or a cost parameter'); } } cost = (cost === undefined) ? amount : cost; @@ -1900,7 +1916,7 @@ module.exports = class phemex extends Exchange { async cancelOrder (id, symbol = undefined, params = {}) { if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' cancelOrder requires a symbol argument'); + throw new ArgumentsRequired (this.id + ' cancelOrder() requires a symbol argument'); } await this.loadMarkets (); const market = this.market (symbol); @@ -1940,7 +1956,7 @@ module.exports = class phemex extends Exchange { async fetchOrder (id, symbol = undefined, params = {}) { if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' fetchOrder requires a symbol argument'); + throw new ArgumentsRequired (this.id + ' fetchOrder() requires a symbol argument'); } await this.loadMarkets (); const market = this.market (symbol); @@ -1974,7 +1990,7 @@ module.exports = class phemex extends Exchange { async fetchOrders (symbol = undefined, since = undefined, limit = undefined, params = {}) { if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' fetchOrders requires a symbol argument'); + throw new ArgumentsRequired (this.id + ' fetchOrders() requires a symbol argument'); } await this.loadMarkets (); const market = this.market (symbol); @@ -1996,7 +2012,7 @@ module.exports = class phemex extends Exchange { async fetchOpenOrders (symbol = undefined, since = undefined, limit = undefined, params = {}) { if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' fetchOpenOrders requires a symbol argument'); + throw new ArgumentsRequired (this.id + ' fetchOpenOrders() requires a symbol argument'); } await this.loadMarkets (); const market = this.market (symbol); @@ -2020,7 +2036,7 @@ module.exports = class phemex extends Exchange { async fetchClosedOrders (symbol = undefined, since = undefined, limit = undefined, params = {}) { if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' fetchClosedOrders requires a symbol argument'); + throw new ArgumentsRequired (this.id + ' fetchClosedOrders() requires a symbol argument'); } await this.loadMarkets (); const market = this.market (symbol); @@ -2082,7 +2098,7 @@ module.exports = class phemex extends Exchange { async fetchMyTrades (symbol = undefined, since = undefined, limit = undefined, params = {}) { if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' fetchClosedOrders requires a symbol argument'); + throw new ArgumentsRequired (this.id + ' fetchClosedOrders() requires a symbol argument'); } await this.loadMarkets (); const market = this.market (symbol); @@ -2317,7 +2333,7 @@ module.exports = class phemex extends Exchange { const currencyId = this.safeString (transaction, 'currency'); currency = this.safeCurrency (currencyId, currency); const code = currency['code']; - const timestamp = this.safeInteger (transaction, 'createdAt'); + const timestamp = this.safeInteger2 (transaction, 'createdAt', 'submitedAt'); let type = this.safeStringLower (transaction, 'type'); const feeCost = this.fromEn (this.safeFloat (transaction, 'feeEv'), currency['valueScale'], currency['precision']); let fee = undefined; diff --git a/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/poloniex.js b/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/poloniex.js index f0b874031..30eee15c9 100644 --- a/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/poloniex.js +++ b/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/poloniex.js @@ -204,7 +204,6 @@ module.exports = class poloniex extends Exchange { 'Error pulling ': ExchangeError, // {"error":"Error pulling order book"} }, }, - 'orders': {}, // orders cache / emulation }); } @@ -923,6 +922,7 @@ module.exports = class poloniex extends Exchange { 'symbol': symbol, 'type': type, 'timeInForce': undefined, + 'postOnly': undefined, 'side': side, 'price': price, 'stopPrice': undefined, diff --git a/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/probit.js b/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/probit.js index 9fb49b9d1..522045f2c 100644 --- a/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/probit.js +++ b/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/probit.js @@ -121,6 +121,7 @@ module.exports = class probit extends Exchange { 'RATE_LIMIT_EXCEEDED': RateLimitExceeded, // You are sending requests too frequently. Please try it later. 'MARKET_UNAVAILABLE': ExchangeNotAvailable, // Market is closed today 'INVALID_MARKET': BadSymbol, // Requested market is not exist + 'MARKET_CLOSED': BadSymbol, // {"errorCode":"MARKET_CLOSED"} 'INVALID_CURRENCY': BadRequest, // Requested currency is not exist on ProBit system 'TOO_MANY_OPEN_ORDERS': DDoSProtection, // Too many open orders 'DUPLICATE_ADDRESS': InvalidAddress, // Address already exists in withdrawal address list @@ -142,6 +143,7 @@ module.exports = class probit extends Exchange { 'BTCBEAR': 'BEAR', 'BTCBULL': 'BULL', 'CBC': 'CryptoBharatCoin', + 'HBC': 'Hybrid Bank Cash', 'UNI': 'UNICORN Token', }, }); @@ -299,7 +301,18 @@ module.exports = class probit extends Exchange { const withdrawalSuspended = this.safeValue (platform, 'withdrawal_suspended'); const active = !(depositSuspended && withdrawalSuspended); const withdrawalFees = this.safeValue (platform, 'withdrawal_fee', {}); - const withdrawalFeesByPriority = this.sortBy (withdrawalFees, 'priority'); + const fees = []; + // sometimes the withdrawal fee is an empty object + // [ { 'amount': '0.015', 'priority': 1, 'currency_id': 'ETH' }, {} ] + for (let j = 0; j < withdrawalFees.length; j++) { + const withdrawalFee = withdrawalFees[j]; + const amount = this.safeFloat (withdrawalFee, 'amount'); + const priority = this.safeInteger (withdrawalFee, 'priority'); + if ((amount !== undefined) && (priority !== undefined)) { + fees.push (withdrawalFee); + } + } + const withdrawalFeesByPriority = this.sortBy (fees, 'priority'); const withdrawalFee = this.safeValue (withdrawalFeesByPriority, 0, {}); const fee = this.safeFloat (withdrawalFee, 'amount'); result[code] = { @@ -729,7 +742,7 @@ module.exports = class probit extends Exchange { let endTime = now; if (since === undefined) { if (limit === undefined) { - throw new ArgumentsRequired (this.id + ' fetchOHLCV requires either a since argument or a limit argument'); + throw new ArgumentsRequired (this.id + ' fetchOHLCV() requires either a since argument or a limit argument'); } else { startTime = now - limit * duration * 1000; } @@ -829,7 +842,7 @@ module.exports = class probit extends Exchange { async fetchOrder (id, symbol = undefined, params = {}) { if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' fetchOrder requires a symbol argument'); + throw new ArgumentsRequired (this.id + ' fetchOrder() requires a symbol argument'); } await this.loadMarkets (); const market = this.market (symbol); @@ -1022,7 +1035,7 @@ module.exports = class probit extends Exchange { async cancelOrder (id, symbol = undefined, params = {}) { if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' cancelOrder requires a symbol argument'); + throw new ArgumentsRequired (this.id + ' cancelOrder() requires a symbol argument'); } await this.loadMarkets (); const market = this.market (symbol); diff --git a/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/qtrade.js b/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/qtrade.js index b1a3ab46e..aa66545bf 100644 --- a/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/qtrade.js +++ b/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/qtrade.js @@ -915,6 +915,7 @@ module.exports = class qtrade extends Exchange { 'symbol': symbol, 'type': orderType, 'timeInForce': undefined, + 'postOnly': undefined, 'side': side, 'price': price, 'stopPrice': undefined, diff --git a/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/rightbtc.js b/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/rightbtc.js index ca2de52dd..d22048303 100644 --- a/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/rightbtc.js +++ b/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/rightbtc.js @@ -431,7 +431,7 @@ module.exports = class rightbtc extends Exchange { async cancelOrder (id, symbol = undefined, params = {}) { if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' cancelOrder requires a symbol argument'); + throw new ArgumentsRequired (this.id + ' cancelOrder() requires a symbol argument'); } await this.loadMarkets (); const market = this.market (symbol); @@ -541,6 +541,7 @@ module.exports = class rightbtc extends Exchange { 'symbol': symbol, 'type': type, 'timeInForce': undefined, + 'postOnly': undefined, 'side': side, 'price': price, 'stopPrice': undefined, @@ -557,7 +558,7 @@ module.exports = class rightbtc extends Exchange { async fetchOrder (id, symbol = undefined, params = {}) { if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' fetchOrder requires a symbol argument'); + throw new ArgumentsRequired (this.id + ' fetchOrder() requires a symbol argument'); } await this.loadMarkets (); const market = this.market (symbol); @@ -595,7 +596,7 @@ module.exports = class rightbtc extends Exchange { async fetchOpenOrders (symbol = undefined, since = undefined, limit = undefined, params = {}) { if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' fetchOpenOrders requires a symbol argument'); + throw new ArgumentsRequired (this.id + ' fetchOpenOrders() requires a symbol argument'); } await this.loadMarkets (); const market = this.market (symbol); @@ -632,7 +633,7 @@ module.exports = class rightbtc extends Exchange { async fetchOrders (symbol = undefined, since = undefined, limit = undefined, params = {}) { let ids = this.safeString (params, 'ids'); if ((symbol === undefined) || (ids === undefined)) { - throw new ArgumentsRequired (this.id + " fetchOrders requires a 'symbol' argument and an extra 'ids' parameter. The 'ids' should be an array or a string of one or more order ids separated with slashes."); // eslint-disable-line quotes + throw new ArgumentsRequired (this.id + " fetchOrders() requires a 'symbol' argument and an extra 'ids' parameter. The 'ids' should be an array or a string of one or more order ids separated with slashes."); // eslint-disable-line quotes } if (Array.isArray (ids)) { ids = ids.join ('/'); @@ -671,7 +672,7 @@ module.exports = class rightbtc extends Exchange { async fetchMyTrades (symbol = undefined, since = undefined, limit = undefined, params = {}) { if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' fetchMyTrades requires a symbol argument'); + throw new ArgumentsRequired (this.id + ' fetchMyTrades() requires a symbol argument'); } await this.loadMarkets (); const market = this.market (symbol); diff --git a/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/ripio.js b/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/ripio.js index 4c6595d11..b3a30607e 100644 --- a/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/ripio.js +++ b/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/ripio.js @@ -830,6 +830,7 @@ module.exports = class ripio extends Exchange { 'symbol': symbol, 'type': type, 'timeInForce': undefined, + 'postOnly': undefined, 'side': side, 'price': price, 'stopPrice': stopPrice, diff --git a/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/southxchange.js b/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/southxchange.js index 126cfdfb3..d2bdd8cec 100644 --- a/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/southxchange.js +++ b/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/southxchange.js @@ -264,6 +264,7 @@ module.exports = class southxchange extends Exchange { 'symbol': symbol, 'type': type, 'timeInForce': undefined, + 'postOnly': undefined, 'side': side, 'price': price, 'stopPrice': undefined, diff --git a/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/static_dependencies/elliptic/package.json b/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/static_dependencies/elliptic/package.json new file mode 100644 index 000000000..ec6f8c8e5 --- /dev/null +++ b/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/static_dependencies/elliptic/package.json @@ -0,0 +1,84 @@ +{ + "_args": [ + [ + "elliptic@6.4.0", + "/Users/carlorevelli/Documents/important/code/ccxt" + ] + ], + "_development": true, + "_from": "elliptic@6.4.0", + "_id": "elliptic@6.4.0", + "_inBundle": false, + "_integrity": "sha1-ysmvh2LIWDYYcAPI3+GT5eLq5d8=", + "_location": "/elliptic", + "_phantomChildren": {}, + "_requested": { + "type": "version", + "registry": true, + "raw": "elliptic@6.4.0", + "name": "elliptic", + "escapedName": "elliptic", + "rawSpec": "6.4.0", + "saveSpec": null, + "fetchSpec": "6.4.0" + }, + "_requiredBy": [ + "/browserify-sign", + "/create-ecdh" + ], + "_resolved": "https://registry.npmjs.org/elliptic/-/elliptic-6.4.0.tgz", + "_spec": "6.4.0", + "_where": "/Users/carlorevelli/Documents/important/code/ccxt", + "author": { + "name": "Fedor Indutny", + "email": "fedor@indutny.com" + }, + "bugs": { + "url": "https://github.com/indutny/elliptic/issues" + }, + "dependencies": { + }, + "description": "EC cryptography", + "devDependencies": { + "brfs": "^1.4.3", + "coveralls": "^2.11.3", + "grunt": "^0.4.5", + "grunt-browserify": "^5.0.0", + "grunt-cli": "^1.2.0", + "grunt-contrib-connect": "^1.0.0", + "grunt-contrib-copy": "^1.0.0", + "grunt-contrib-uglify": "^1.0.1", + "grunt-mocha-istanbul": "^3.0.1", + "grunt-saucelabs": "^8.6.2", + "istanbul": "^0.4.2", + "jscs": "^2.9.0", + "jshint": "^2.6.0", + "mocha": "^2.1.0" + }, + "files": [ + "lib" + ], + "homepage": "https://github.com/indutny/elliptic", + "keywords": [ + "EC", + "Elliptic", + "curve", + "Cryptography" + ], + "license": "MIT", + "main": "lib/elliptic.js", + "name": "elliptic", + "repository": { + "type": "git", + "url": "git+ssh://git@github.com/indutny/elliptic.git" + }, + "scripts": { + "jscs": "jscs benchmarks/*.js lib/*.js lib/**/*.js lib/**/**/*.js test/index.js", + "jshint": "jscs benchmarks/*.js lib/*.js lib/**/*.js lib/**/**/*.js test/index.js", + "lint": "npm run jscs && npm run jshint", + "test": "npm run lint && npm run unit", + "unit": "istanbul test _mocha --reporter=spec test/index.js", + "version": "grunt dist && git add dist/" + }, + "version": "6.4.0" +} diff --git a/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/stex.js b/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/stex.js index aaf34ea4a..af2e256f3 100644 --- a/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/stex.js +++ b/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/stex.js @@ -185,6 +185,8 @@ module.exports = class stex extends Exchange { 'BITS': 'Bitcoinus', 'BITSW': 'BITS', 'BHD': 'Bithold', + 'BTH': 'Bithereum', + 'SBTC': 'SBTCT', // SiamBitcoin }, 'options': { 'parseOrderToPrecision': false, @@ -926,6 +928,7 @@ module.exports = class stex extends Exchange { 'symbol': symbol, 'type': type, 'timeInForce': undefined, + 'postOnly': undefined, 'side': side, 'price': price, 'stopPrice': stopPrice, @@ -1222,7 +1225,7 @@ module.exports = class stex extends Exchange { async fetchMyTrades (symbol = undefined, since = undefined, limit = undefined, params = {}) { if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' fetchMyTrades requires a symbol argument'); + throw new ArgumentsRequired (this.id + ' fetchMyTrades() requires a symbol argument'); } await this.loadMarkets (); const market = this.market (symbol); diff --git a/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/test/Exchange/test.fetchCurrencies.js b/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/test/Exchange/test.fetchCurrencies.js index 79c018d74..563ed1eea 100644 --- a/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/test/Exchange/test.fetchCurrencies.js +++ b/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/test/Exchange/test.fetchCurrencies.js @@ -27,7 +27,9 @@ module.exports = async (exchange) => { const method = 'fetchCurrencies' const currencies = await exchange[method] () - Object.values (currencies).forEach ((currency) => testCurrency (exchange, currency, method)) + if (currencies !== undefined) { + Object.values (currencies).forEach ((currency) => testCurrency (exchange, currency, method)) + } return currencies } else { diff --git a/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/test/Exchange/test.ticker.js b/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/test/Exchange/test.ticker.js index 33a86ceaf..7d91ea0ba 100644 --- a/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/test/Exchange/test.ticker.js +++ b/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/test/Exchange/test.ticker.js @@ -82,8 +82,12 @@ module.exports = (exchange, ticker, method, symbol) => { 'okex', 'southxchange', // https://user-images.githubusercontent.com/1294454/59953532-314bea80-9489-11e9-85b3-2a711ca49aa7.png 'bitmart', + 'ftx', 'gateio', // some ticker bids are greaters than asks 'timex', + 'poloniex', + 'qtrade', + 'bigone', ].includes (exchange.id)) { diff --git a/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/therock.js b/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/therock.js index c26b1b8fe..12217e2b2 100644 --- a/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/therock.js +++ b/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/therock.js @@ -965,6 +965,7 @@ module.exports = class therock extends Exchange { 'symbol': symbol, 'type': type, 'timeInForce': undefined, + 'postOnly': undefined, 'side': side, 'price': price, 'stopPrice': stopPrice, @@ -994,7 +995,7 @@ module.exports = class therock extends Exchange { async fetchOrders (symbol = undefined, since = undefined, limit = undefined, params = {}) { if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' fetchOrders requires a symbol argument'); + throw new ArgumentsRequired (this.id + ' fetchOrders() requires a symbol argument'); } await this.loadMarkets (); const market = this.market (symbol); @@ -1039,7 +1040,7 @@ module.exports = class therock extends Exchange { async fetchOrder (id, symbol = undefined, params = {}) { if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' fetchOrder requires a symbol argument'); + throw new ArgumentsRequired (this.id + ' fetchOrder() requires a symbol argument'); } await this.loadMarkets (); const market = this.market (symbol); @@ -1078,7 +1079,7 @@ module.exports = class therock extends Exchange { async fetchMyTrades (symbol = undefined, since = undefined, limit = undefined, params = {}) { if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' fetchMyTrades requires a symbol argument'); + throw new ArgumentsRequired (this.id + ' fetchMyTrades() requires a symbol argument'); } await this.loadMarkets (); const market = this.market (symbol); diff --git a/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/tidebit.js b/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/tidebit.js index 1f2ef5cd9..acf65de25 100644 --- a/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/tidebit.js +++ b/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/tidebit.js @@ -422,6 +422,7 @@ module.exports = class tidebit extends Exchange { 'symbol': symbol, 'type': type, 'timeInForce': undefined, + 'postOnly': undefined, 'side': side, 'price': price, 'stopPrice': undefined, diff --git a/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/tidex.js b/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/tidex.js index 5b2504114..0988a4ad1 100644 --- a/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/tidex.js +++ b/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/tidex.js @@ -580,6 +580,7 @@ module.exports = class tidex extends Exchange { 'lastTradeTimestamp': undefined, 'type': 'limit', 'timeInForce': undefined, + 'postOnly': undefined, 'side': this.safeString (order, 'type'), 'price': price, 'stopPrice': undefined, diff --git a/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/timex.js b/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/timex.js index 3937e4660..4c71ac4ff 100644 --- a/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/timex.js +++ b/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/timex.js @@ -460,16 +460,19 @@ module.exports = class timex extends Exchange { async createOrder (symbol, type, side, amount, price = undefined, params = {}) { await this.loadMarkets (); const market = this.market (symbol); + const uppercaseSide = side.toUpperCase (); + const uppercaseType = type.toUpperCase (); const request = { 'symbol': market['id'], 'quantity': this.amountToPrecision (symbol, amount), - 'side': side.toUpperCase (), + 'side': uppercaseSide, + 'orderTypes': uppercaseType, // 'clientOrderId': '123', // 'expireIn': 1575523308, // in seconds // 'expireTime': 1575523308, // unix timestamp }; let query = params; - if (type === 'limit') { + if (uppercaseType === 'LIMIT') { request['price'] = this.priceToPrecision (symbol, price); const defaultExpireIn = this.safeInteger (this.options, 'expireIn'); const expireTime = this.safeValue (params, 'expireTime'); @@ -479,7 +482,7 @@ module.exports = class timex extends Exchange { } else if (expireIn !== undefined) { request['expireIn'] = expireIn; } else { - throw new InvalidOrder (this.id + ' createOrder method requires a expireTime or expireIn param for a ' + type + ' order, you can also set the expireIn exchange-wide option'); + throw new InvalidOrder (this.id + ' createOrder() method requires a expireTime or expireIn param for a ' + type + ' order, you can also set the expireIn exchange-wide option'); } query = this.omit (params, [ 'expireTime', 'expireIn' ]); } else { @@ -1182,6 +1185,7 @@ module.exports = class timex extends Exchange { 'symbol': symbol, 'type': type, 'timeInForce': undefined, + 'postOnly': undefined, 'side': side, 'price': price, 'stopPrice': undefined, diff --git a/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/upbit.js b/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/upbit.js index b7665f041..829aa6586 100644 --- a/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/upbit.js +++ b/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/upbit.js @@ -15,7 +15,6 @@ module.exports = class upbit extends Exchange { 'countries': [ 'KR' ], 'version': 'v1', 'rateLimit': 1000, - 'certified': true, 'pro': true, // new metainfo interface 'has': { @@ -221,7 +220,7 @@ module.exports = class upbit extends Exchange { const walletLocked = this.safeValue (memberInfo, 'wallet_locked'); const locked = this.safeValue (memberInfo, 'locked'); let active = true; - if ((canWithdraw !== undefined) && canWithdraw) { + if ((canWithdraw !== undefined) && !canWithdraw) { active = false; } else if (walletState !== 'working') { active = false; @@ -1204,6 +1203,7 @@ module.exports = class upbit extends Exchange { 'symbol': market['symbol'], 'type': type, 'timeInForce': undefined, + 'postOnly': undefined, 'side': side, 'price': price, 'stopPrice': undefined, diff --git a/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/vcc.js b/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/vcc.js index 006c36ec6..bd3a9602d 100644 --- a/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/vcc.js +++ b/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/vcc.js @@ -1056,6 +1056,7 @@ module.exports = class vcc extends Exchange { 'symbol': symbol, 'type': type, 'timeInForce': undefined, + 'postOnly': undefined, 'side': side, 'price': price, 'stopPrice': stopPrice, diff --git a/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/wavesexchange.js b/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/wavesexchange.js index 976435981..139780062 100644 --- a/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/wavesexchange.js +++ b/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/wavesexchange.js @@ -1056,7 +1056,7 @@ module.exports = class wavesexchange extends Exchange { this.checkRequiredDependencies (); this.checkRequiredKeys (); if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' fetchOrders requires symbol argument'); + throw new ArgumentsRequired (this.id + ' fetchOrders() requires symbol argument'); } await this.loadMarkets (); const market = this.market (symbol); @@ -1269,6 +1269,7 @@ module.exports = class wavesexchange extends Exchange { 'symbol': symbol, 'type': type, 'timeInForce': undefined, + 'postOnly': undefined, 'side': side, 'price': price, 'stopPrice': undefined, diff --git a/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/xena.js b/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/xena.js index 8be88d342..2facd429b 100644 --- a/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/xena.js +++ b/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/xena.js @@ -38,6 +38,10 @@ module.exports = class xena extends Exchange { }, 'urls': { 'logo': 'https://user-images.githubusercontent.com/51840849/87489843-bb469280-c64c-11ea-91aa-69c6326506af.jpg', + 'test': { + 'public': 'https://trading.demo.xena.io/api', + 'private': 'https://api.demo.xena.io', + }, 'api': { 'public': 'https://trading.xena.exchange/api', 'private': 'https://api.xena.exchange', @@ -958,6 +962,7 @@ module.exports = class xena extends Exchange { 'symbol': symbol, 'type': type, 'timeInForce': undefined, + 'postOnly': undefined, 'side': side, 'price': price, 'stopPrice': undefined, @@ -1017,14 +1022,14 @@ module.exports = class xena extends Exchange { }; if ((type === 'limit') || (type === 'stop-limit')) { if (price === undefined) { - throw new InvalidOrder (this.id + ' createOrder requires a price argument for order type ' + type); + throw new InvalidOrder (this.id + ' createOrder() requires a price argument for order type ' + type); } request['price'] = this.priceToPrecision (symbol, price); } if ((type === 'stop') || (type === 'stop-limit')) { const stopPx = this.safeFloat (params, 'stopPx'); if (stopPx === undefined) { - throw new InvalidOrder (this.id + ' createOrder requires a stopPx param for order type ' + type); + throw new InvalidOrder (this.id + ' createOrder() requires a stopPx param for order type ' + type); } request['stopPx'] = this.priceToPrecision (symbol, stopPx); params = this.omit (params, 'stopPx'); @@ -1062,7 +1067,7 @@ module.exports = class xena extends Exchange { async editOrder (id, symbol, type, side, amount = undefined, price = undefined, params = {}) { if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' cancelOrder requires a symbol argument'); + throw new ArgumentsRequired (this.id + ' cancelOrder() requires a symbol argument'); } await this.loadMarkets (); await this.loadAccounts (); @@ -1117,7 +1122,7 @@ module.exports = class xena extends Exchange { async cancelOrder (id, symbol = undefined, params = {}) { if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' cancelOrder requires a symbol argument'); + throw new ArgumentsRequired (this.id + ' cancelOrder() requires a symbol argument'); } await this.loadMarkets (); await this.loadAccounts (); diff --git a/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/yobit.js b/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/yobit.js index 46fc1d99d..0ab100f68 100644 --- a/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/yobit.js +++ b/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/yobit.js @@ -133,6 +133,7 @@ module.exports = class yobit extends Exchange { 'LOCX': 'LOC', 'LUNYR': 'LUN', 'LUN': 'LunarCoin', // they just change the ticker if it is already taken + 'MASK': 'Yobit MASK', 'MDT': 'Midnight', 'NAV': 'NavajoCoin', 'NBT': 'NiceBytes', @@ -149,6 +150,7 @@ module.exports = class yobit extends Exchange { 'RCN': 'RCoin', 'REP': 'Republicoin', 'RUR': 'RUB', + 'SBTC': 'Super Bitcoin', 'TTC': 'TittieCoin', 'UNI': 'Universe', 'UST': 'Uservice', @@ -595,6 +597,7 @@ module.exports = class yobit extends Exchange { 'lastTradeTimestamp': undefined, 'type': type, 'timeInForce': undefined, + 'postOnly': undefined, 'side': side, 'price': price, 'stopPrice': undefined, @@ -639,7 +642,7 @@ module.exports = class yobit extends Exchange { async fetchMyTrades (symbol = undefined, since = undefined, limit = undefined, params = {}) { if (symbol === undefined) { - throw new ArgumentsRequired (this.id + ' fetchMyTrades requires a `symbol` argument'); + throw new ArgumentsRequired (this.id + ' fetchMyTrades() requires a `symbol` argument'); } await this.loadMarkets (); const market = this.market (symbol); @@ -727,24 +730,6 @@ module.exports = class yobit extends Exchange { }; } - calculateFee (symbol, type, side, amount, price, takerOrMaker = 'taker', params = {}) { - const market = this.markets[symbol]; - let key = 'quote'; - const rate = market[takerOrMaker]; - let cost = parseFloat (this.costToPrecision (symbol, amount * rate)); - if (side === 'sell') { - cost *= price; - } else { - key = 'base'; - } - return { - 'type': takerOrMaker, - 'currency': market[key], - 'rate': rate, - 'cost': cost, - }; - } - sign (path, api = 'public', method = 'GET', params = {}, headers = undefined, body = undefined) { let url = this.urls['api'][api]; const query = this.omit (params, this.extractParams (path)); diff --git a/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/zaif.js b/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/zaif.js index b9618184e..2c6454a05 100644 --- a/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/zaif.js +++ b/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/zaif.js @@ -357,6 +357,7 @@ module.exports = class zaif extends Exchange { 'symbol': symbol, 'type': 'limit', 'timeInForce': undefined, + 'postOnly': undefined, 'side': side, 'price': price, 'stopPrice': undefined, diff --git a/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/zb.js b/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/zb.js index 9b4d81872..1f8f61cdf 100644 --- a/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/zb.js +++ b/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/js/zb.js @@ -3,7 +3,7 @@ // --------------------------------------------------------------------------- const Exchange = require ('./base/Exchange'); -const { BadRequest, ExchangeError, ArgumentsRequired, AuthenticationError, InsufficientFunds, OrderNotFound, ExchangeNotAvailable, DDoSProtection, InvalidOrder } = require ('./base/errors'); +const { BadRequest, ExchangeError, ArgumentsRequired, AuthenticationError, InsufficientFunds, OrderNotFound, ExchangeNotAvailable, DDoSProtection, InvalidOrder, InvalidAddress } = require ('./base/errors'); // --------------------------------------------------------------------------- @@ -22,15 +22,19 @@ module.exports = class zb extends Exchange { 'createOrder': true, 'fetchBalance': true, 'fetchDepositAddress': true, + 'fetchDepositAddresses': true, + 'fetchDeposits': true, 'fetchMarkets': true, 'fetchOHLCV': true, 'fetchOpenOrders': true, 'fetchOrder': true, 'fetchOrderBook': true, 'fetchOrders': true, + 'fetchClosedOrders': true, 'fetchTicker': true, 'fetchTickers': true, 'fetchTrades': true, + 'fetchWithdrawals': true, 'withdraw': true, }, 'timeframes': { @@ -49,33 +53,38 @@ module.exports = class zb extends Exchange { '1w': '1week', }, 'exceptions': { - // '1000': 'Successful operation', - '1001': ExchangeError, // 'General error message', - '1002': ExchangeError, // 'Internal error', - '1003': AuthenticationError, // 'Verification does not pass', - '1004': AuthenticationError, // 'Funding security password lock', - '1005': AuthenticationError, // 'Funds security password is incorrect, please confirm and re-enter.', - '1006': AuthenticationError, // 'Real-name certification pending approval or audit does not pass', - '1009': ExchangeNotAvailable, // 'This interface is under maintenance', - '2001': InsufficientFunds, // 'Insufficient CNY Balance', - '2002': InsufficientFunds, // 'Insufficient BTC Balance', - '2003': InsufficientFunds, // 'Insufficient LTC Balance', - '2005': InsufficientFunds, // 'Insufficient ETH Balance', - '2006': InsufficientFunds, // 'Insufficient ETC Balance', - '2007': InsufficientFunds, // 'Insufficient BTS Balance', - '2009': InsufficientFunds, // 'Account balance is not enough', - '3001': OrderNotFound, // 'Pending orders not found', - '3002': InvalidOrder, // 'Invalid price', - '3003': InvalidOrder, // 'Invalid amount', - '3004': AuthenticationError, // 'User does not exist', - '3005': BadRequest, // 'Invalid parameter', - '3006': AuthenticationError, // 'Invalid IP or inconsistent with the bound IP', - '3007': AuthenticationError, // 'The request time has expired', - '3008': OrderNotFound, // 'Transaction records not found', - '3009': InvalidOrder, // 'The price exceeds the limit', - '3011': InvalidOrder, // 'The entrusted price is abnormal, please modify it and place order again', - '4001': ExchangeNotAvailable, // 'API interface is locked or not enabled', - '4002': DDoSProtection, // 'Request too often', + 'exact': { + // '1000': 'Successful operation', + '1001': ExchangeError, // 'General error message', + '1002': ExchangeError, // 'Internal error', + '1003': AuthenticationError, // 'Verification does not pass', + '1004': AuthenticationError, // 'Funding security password lock', + '1005': AuthenticationError, // 'Funds security password is incorrect, please confirm and re-enter.', + '1006': AuthenticationError, // 'Real-name certification pending approval or audit does not pass', + '1009': ExchangeNotAvailable, // 'This interface is under maintenance', + '2001': InsufficientFunds, // 'Insufficient CNY Balance', + '2002': InsufficientFunds, // 'Insufficient BTC Balance', + '2003': InsufficientFunds, // 'Insufficient LTC Balance', + '2005': InsufficientFunds, // 'Insufficient ETH Balance', + '2006': InsufficientFunds, // 'Insufficient ETC Balance', + '2007': InsufficientFunds, // 'Insufficient BTS Balance', + '2009': InsufficientFunds, // 'Account balance is not enough', + '3001': OrderNotFound, // 'Pending orders not found', + '3002': InvalidOrder, // 'Invalid price', + '3003': InvalidOrder, // 'Invalid amount', + '3004': AuthenticationError, // 'User does not exist', + '3005': BadRequest, // 'Invalid parameter', + '3006': AuthenticationError, // 'Invalid IP or inconsistent with the bound IP', + '3007': AuthenticationError, // 'The request time has expired', + '3008': OrderNotFound, // 'Transaction records not found', + '3009': InvalidOrder, // 'The price exceeds the limit', + '3011': InvalidOrder, // 'The entrusted price is abnormal, please modify it and place order again', + '4001': ExchangeNotAvailable, // 'API interface is locked or not enabled', + '4002': DDoSProtection, // 'Request too often', + }, + 'broad': { + '提币地址有误,请先添加提币地址。': InvalidAddress, // {"code":1001,"message":"提币地址有误,请先添加提币地址。"} + }, }, 'urls': { 'logo': 'https://user-images.githubusercontent.com/1294454/32859187-cd5214f0-ca5e-11e7-967d-96568e2e2bd1.jpg', @@ -102,20 +111,28 @@ module.exports = class zb extends Exchange { 'get': [ // spot API 'order', + 'orderMoreV2', 'cancelOrder', 'getOrder', 'getOrders', 'getOrdersNew', 'getOrdersIgnoreTradeType', 'getUnfinishedOrdersIgnoreTradeType', + 'getFinishedAndPartialOrders', 'getAccountInfo', 'getUserAddress', + 'getPayinAddress', 'getWithdrawAddress', 'getWithdrawRecord', 'getChargeRecord', 'getCnyWithdrawRecord', 'getCnyChargeRecord', 'withdraw', + // sub accounts + 'addSubUser', + 'getSubUserList', + 'doTransferFunds', + 'createSubUserKey', // leverage API 'getLeverAssetsInfo', 'getLeverBills', @@ -126,8 +143,21 @@ module.exports = class zb extends Exchange { 'getLoans', 'getLoanRecords', 'borrow', + 'autoBorrow', 'repay', + 'doAllRepay', 'getRepayments', + 'getFinanceRecords', + 'changeInvestMark', + 'changeLoop', + // cross API + 'getCrossAssets', + 'getCrossBills', + 'transferInCross', + 'transferOutCross', + 'doCrossLoan', + 'doCrossRepay', + 'getCrossRepayRecords', ], }, }, @@ -245,8 +275,96 @@ module.exports = class zb extends Exchange { return this.parseBalance (result); } - getMarketFieldName () { - return 'market'; + parseDepositAddress (depositAddress, currency = undefined) { + // + // fetchDepositAddress + // + // { + // "key": "0x0af7f36b8f09410f3df62c81e5846da673d4d9a9" + // } + // + // fetchDepositAddresses + // + // { + // "blockChain": "btc", + // "isUseMemo": false, + // "address": "1LL5ati6pXHZnTGzHSA3rWdqi4mGGXudwM", + // "canWithdraw": true, + // "canDeposit": true + // } + // { + // "blockChain": "bts", + // "isUseMemo": true, + // "account": "btstest", + // "memo": "123", + // "canWithdraw": true, + // "canDeposit": true + // } + // + let address = this.safeString (depositAddress, 'key'); + let tag = undefined; + const memo = this.safeString (depositAddress, 'memo'); + if (memo !== undefined) { + tag = memo; + } else if (address.indexOf ('_') >= 0) { + const parts = address.split ('_'); + address = parts[0]; // WARNING: MAY BE tag_address INSTEAD OF address_tag FOR SOME CURRENCIES!! + tag = parts[1]; + } + const currencyId = this.safeString (depositAddress, 'blockChain'); + const code = this.safeCurrencyCode (currencyId, currency); + return { + 'currency': code, + 'address': address, + 'tag': tag, + 'info': depositAddress, + }; + } + + parseDepositAddresses (addresses, codes = undefined) { + let result = []; + for (let i = 0; i < addresses.length; i++) { + const address = this.parseDepositAddress (addresses[i]); + result.push (address); + } + if (codes) { + result = this.filterByArray (result, 'currency', codes); + } + return this.indexBy (result, 'currency'); + } + + async fetchDepositAddresses (codes = undefined, params = {}) { + await this.loadMarkets (); + const response = await this.privateGetGetPayinAddress (params); + // + // { + // "code": 1000, + // "message": { + // "des": "success", + // "isSuc": true, + // "datas": [ + // { + // "blockChain": "btc", + // "isUseMemo": false, + // "address": "1LL5ati6pXHZnTGzHSA3rWdqi4mGGXudwM", + // "canWithdraw": true, + // "canDeposit": true + // }, + // { + // "blockChain": "bts", + // "isUseMemo": true, + // "account": "btstest", + // "memo": "123", + // "canWithdraw": true, + // "canDeposit": true + // }, + // ] + // } + // } + // + const message = this.safeValue (response, 'message', {}); + const datas = this.safeValue (message, 'datas', []); + return this.parseDepositAddresses (datas, codes); } async fetchDepositAddress (code, params = {}) { @@ -256,27 +374,29 @@ module.exports = class zb extends Exchange { 'currency': currency['id'], }; const response = await this.privateGetGetUserAddress (this.extend (request, params)); - let address = response['message']['datas']['key']; - let tag = undefined; - if (address.indexOf ('_') >= 0) { - const parts = address.split ('_'); - address = parts[0]; // WARNING: MAY BE tag_address INSTEAD OF address_tag FOR SOME CURRENCIES!! - tag = parts[1]; - } - return { - 'currency': code, - 'address': address, - 'tag': tag, - 'info': response, - }; + // + // { + // "code": 1000, + // "message": { + // "des": "success", + // "isSuc": true, + // "datas": { + // "key": "0x0af7f36b8f09410f3df62c81e5846da673d4d9a9" + // } + // } + // } + // + const message = this.safeValue (response, 'message', {}); + const datas = this.safeValue (message, 'datas', {}); + return this.parseDepositAddress (datas, currency); } async fetchOrderBook (symbol, limit = undefined, params = {}) { await this.loadMarkets (); const market = this.market (symbol); - const marketFieldName = this.getMarketFieldName (); - const request = {}; - request[marketFieldName] = market['id']; + const request = { + 'market': market['id'], + }; if (limit !== undefined) { request['size'] = limit; } @@ -305,9 +425,9 @@ module.exports = class zb extends Exchange { async fetchTicker (symbol, params = {}) { await this.loadMarkets (); const market = this.market (symbol); - const marketFieldName = this.getMarketFieldName (); - const request = {}; - request[marketFieldName] = market['id']; + const request = { + 'market': market['id'], + }; const response = await this.publicGetTicker (this.extend (request, params)); const ticker = response['ticker']; return this.parseTicker (ticker, market); @@ -400,9 +520,9 @@ module.exports = class zb extends Exchange { async fetchTrades (symbol, since = undefined, limit = undefined, params = {}) { await this.loadMarkets (); const market = this.market (symbol); - const marketFieldName = this.getMarketFieldName (); - const request = {}; - request[marketFieldName] = market['id']; + const request = { + 'market': market['id'], + }; const response = await this.publicGetTrades (this.extend (request, params)); return this.parseTrades (response, market, since, limit); } @@ -462,7 +582,7 @@ module.exports = class zb extends Exchange { async fetchOrders (symbol = undefined, since = undefined, limit = 50, params = {}) { if (symbol === undefined) { - throw new ArgumentsRequired (this.id + 'fetchOrders requires a symbol argument'); + throw new ArgumentsRequired (this.id + 'fetchOrders() requires a symbol argument'); } await this.loadMarkets (); const market = this.market (symbol); @@ -488,9 +608,24 @@ module.exports = class zb extends Exchange { return this.parseOrders (response, market, since, limit); } + async fetchClosedOrders (symbol = undefined, since = undefined, limit = undefined, params = {}) { + if (symbol === undefined) { + throw new ArgumentsRequired (this.id + 'fetchClosedOrders() requires a symbol argument'); + } + await this.loadMarkets (); + const market = this.market (symbol); + const request = { + 'currency': market['id'], + 'pageIndex': 1, // default pageIndex is 1 + 'pageSize': 10, // default pageSize is 10, doesn't work with other values now + }; + const response = await this.privateGetGetFinishedAndPartialOrders (this.extend (request, params)); + return this.parseOrders (response, market, since, limit); + } + async fetchOpenOrders (symbol = undefined, since = undefined, limit = 10, params = {}) { if (symbol === undefined) { - throw new ArgumentsRequired (this.id + 'fetchOpenOrders requires a symbol argument'); + throw new ArgumentsRequired (this.id + 'fetchOpenOrders() requires a symbol argument'); } await this.loadMarkets (); const market = this.market (symbol); @@ -517,29 +652,26 @@ module.exports = class zb extends Exchange { } parseOrder (order, market = undefined) { - // - // fetchOrder // // { - // 'total_amount': 0.01, - // 'id': '20180910244276459', - // 'price': 180.0, - // 'trade_date': 1536576744960, - // 'status': 2, - // 'trade_money': '1.96742', - // 'trade_amount': 0.01, - // 'type': 0, - // 'currency': 'eth_usdt' - // } + // acctType: 0, + // currency: 'btc_usdt', + // fees: 3.6e-7, + // id: '202102282829772463', + // price: 45177.5, + // status: 2, + // total_amount: 0.0002, + // trade_amount: 0.0002, + // trade_date: 1614515104998, + // trade_money: 8.983712, + // type: 1, + // useZbFee: false + // }, // let side = this.safeInteger (order, 'type'); side = (side === 1) ? 'buy' : 'sell'; const type = 'limit'; // market order is not availalbe in ZB - let timestamp = undefined; - const createDateField = this.getCreateDateField (); - if (createDateField in order) { - timestamp = order[createDateField]; - } + const timestamp = this.safeInteger (order, 'trade_date'); const marketId = this.safeString (order, 'currency'); const symbol = this.safeSymbol (marketId, market, '_'); const price = this.safeFloat (order, 'price'); @@ -558,6 +690,21 @@ module.exports = class zb extends Exchange { average = cost / filled; } const id = this.safeString (order, 'id'); + const feeCost = this.safeFloat (order, 'fees'); + let fee = undefined; + if (feeCost !== undefined) { + let feeCurrency = undefined; + const zbFees = this.safeValue (order, 'useZbFee'); + if (zbFees === true) { + feeCurrency = 'ZB'; + } else if (market !== undefined) { + feeCurrency = (side === 'sell') ? market['quote'] : market['base']; + } + fee = { + 'cost': feeCost, + 'currency': feeCurrency, + }; + } return { 'info': order, 'id': id, @@ -568,6 +715,7 @@ module.exports = class zb extends Exchange { 'symbol': symbol, 'type': type, 'timeInForce': undefined, + 'postOnly': undefined, 'side': side, 'price': price, 'stopPrice': undefined, @@ -577,7 +725,7 @@ module.exports = class zb extends Exchange { 'filled': filled, 'remaining': remaining, 'status': status, - 'fee': undefined, + 'fee': fee, 'trades': undefined, }; } @@ -592,8 +740,241 @@ module.exports = class zb extends Exchange { return this.safeString (statuses, status, status); } - getCreateDateField () { - return 'trade_date'; + parseTransactionStatus (status) { + const statuses = { + '0': 'pending', // submitted, pending confirmation + '1': 'failed', + '2': 'ok', + '3': 'canceled', + '5': 'ok', // confirmed + }; + return this.safeString (statuses, status, status); + } + + parseTransaction (transaction, currency = undefined) { + // + // withdraw + // + // { + // "code": 1000, + // "message": "success", + // "id": "withdrawalId" + // } + // + // fetchWithdrawals + // + // { + // "amount": 0.01, + // "fees": 0.001, + // "id": 2016042556231, + // "manageTime": 1461579340000, + // "status": 3, + // "submitTime": 1461579288000, + // "toAddress": "14fxEPirL9fyfw1i9EF439Pq6gQ5xijUmp", + // } + // + // fetchDeposits + // + // { + // "address": "1FKN1DZqCm8HaTujDioRL2Aezdh7Qj7xxx", + // "amount": "1.00000000", + // "confirmTimes": 1, + // "currency": "BTC", + // "description": "Successfully Confirm", + // "hash": "7ce842de187c379abafadd64a5fe66c5c61c8a21fb04edff9532234a1dae6xxx", + // "id": 558, + // "itransfer": 1, + // "status": 2, + // "submit_time": "2016-12-07 18:51:57", + // } + // + const id = this.safeString (transaction, 'id'); + const txid = this.safeString (transaction, 'hash'); + const amount = this.safeFloat (transaction, 'amount'); + let timestamp = this.parse8601 (this.safeString (transaction, 'submit_time')); + timestamp = this.safeInteger (transaction, 'submitTime', timestamp); + let address = this.safeString2 (transaction, 'toAddress', 'address'); + let tag = undefined; + if (address !== undefined) { + const parts = address.split ('_'); + address = this.safeString (parts, 0); + tag = this.safeString (parts, 1); + } + const confirmTimes = this.safeInteger (transaction, 'confirmTimes'); + const updated = this.safeInteger (transaction, 'manageTime'); + let type = undefined; + const currencyId = this.safeString (transaction, 'currency'); + const code = this.safeCurrencyCode (currencyId, currency); + if (address !== undefined) { + type = (confirmTimes === undefined) ? 'withdrawal' : 'deposit'; + } + const status = this.parseTransactionStatus (this.safeString (transaction, 'status')); + let fee = undefined; + const feeCost = this.safeFloat (transaction, 'fees'); + if (feeCost !== undefined) { + fee = { + 'cost': feeCost, + 'currency': code, + }; + } + return { + 'info': transaction, + 'id': id, + 'txid': txid, + 'timestamp': timestamp, + 'datetime': this.iso8601 (timestamp), + 'addressFrom': undefined, + 'address': address, + 'addressTo': address, + 'tagFrom': undefined, + 'tag': tag, + 'tagTo': tag, + 'type': type, + 'amount': amount, + 'currency': code, + 'status': status, + 'updated': updated, + 'fee': fee, + }; + } + + async withdraw (code, amount, address, tag = undefined, params = {}) { + const password = this.safeString (params, 'safePwd', this.password); + if (password === undefined) { + throw new ArgumentsRequired (this.id + ' withdraw() requires exchange.password or a safePwd parameter'); + } + const fees = this.safeFloat (params, 'fees'); + if (fees === undefined) { + throw new ArgumentsRequired (this.id + ' withdraw() requires a fees parameter'); + } + this.checkAddress (address); + await this.loadMarkets (); + const currency = this.currency (code); + if (tag !== undefined) { + address += '_' + tag; + } + const request = { + 'amount': this.currencyToPrecision (code, amount), + 'currency': currency['id'], + 'fees': this.currencyToPrecision (code, fees), + // 'itransfer': 0, // agree for an internal transfer, 0 disagree, 1 agree, the default is to disagree + 'method': 'withdraw', + 'receiveAddr': address, + 'safePwd': password, + }; + const response = await this.privateGetWithdraw (this.extend (request, params)); + // + // { + // "code": 1000, + // "message": "success", + // "id": "withdrawalId" + // } + // + const transaction = this.parseTransaction (response, currency); + return this.extend (transaction, { + 'type': 'withdrawal', + 'address': address, + 'addressTo': address, + 'amount': amount, + }); + } + + async fetchWithdrawals (code = undefined, since = undefined, limit = undefined, params = {}) { + await this.loadMarkets (); + const request = { + // 'currency': currency['id'], + // 'pageIndex': 1, + // 'pageSize': limit, + }; + let currency = undefined; + if (code !== undefined) { + currency = this.currency (code); + request['currency'] = currency['id']; + } + if (limit !== undefined) { + request['pageSize'] = limit; + } + const response = await this.privateGetGetWithdrawRecord (this.extend (request, params)); + // + // { + // "code": 1000, + // "message": { + // "des": "success", + // "isSuc": true, + // "datas": { + // "list": [ + // { + // "amount": 0.01, + // "fees": 0.001, + // "id": 2016042556231, + // "manageTime": 1461579340000, + // "status": 3, + // "submitTime": 1461579288000, + // "toAddress": "14fxEPirL9fyfw1i9EF439Pq6gQ5xijUmp", + // }, + // ], + // "pageIndex": 1, + // "pageSize": 10, + // "totalCount": 4, + // "totalPage": 1 + // } + // } + // } + // + const message = this.safeValue (response, 'message', {}); + const datas = this.safeValue (message, 'datas', {}); + const withdrawals = this.safeValue (datas, 'list', []); + return this.parseTransactions (withdrawals, currency, since, limit); + } + + async fetchDeposits (code = undefined, since = undefined, limit = undefined, params = {}) { + await this.loadMarkets (); + const request = { + // 'currency': currency['id'], + // 'pageIndex': 1, + // 'pageSize': limit, + }; + let currency = undefined; + if (code !== undefined) { + currency = this.currency (code); + request['currency'] = currency['id']; + } + if (limit !== undefined) { + request['pageSize'] = limit; + } + const response = await this.privateGetGetChargeRecord (this.extend (request, params)); + // + // { + // "code": 1000, + // "message": { + // "des": "success", + // "isSuc": true, + // "datas": { + // "list": [ + // { + // "address": "1FKN1DZqCm8HaTujDioRL2Aezdh7Qj7xxx", + // "amount": "1.00000000", + // "confirmTimes": 1, + // "currency": "BTC", + // "description": "Successfully Confirm", + // "hash": "7ce842de187c379abafadd64a5fe66c5c61c8a21fb04edff9532234a1dae6xxx", + // "id": 558, + // "itransfer": 1, + // "status": 2, + // "submit_time": "2016-12-07 18:51:57", + // }, + // ], + // "pageIndex": 1, + // "pageSize": 10, + // "total": 8 + // } + // } + // } + // + const message = this.safeValue (response, 'message', {}); + const datas = this.safeValue (message, 'datas', {}); + const deposits = this.safeValue (datas, 'list', []); + return this.parseTransactions (deposits, currency, since, limit); } nonce () { @@ -629,9 +1010,10 @@ module.exports = class zb extends Exchange { } if (body[0] === '{') { const feedback = this.id + ' ' + body; + this.throwBroadlyMatchedException (this.exceptions['broad'], body, feedback); if ('code' in response) { const code = this.safeString (response, 'code'); - this.throwExactlyMatchedException (this.exceptions, code, feedback); + this.throwExactlyMatchedException (this.exceptions['exact'], code, feedback); if (code !== '1000') { throw new ExchangeError (feedback); } diff --git a/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/package.json b/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/package.json index 7323b5b24..1521ec10e 100644 --- a/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/package.json +++ b/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/node_modules/ccxt/package.json @@ -1,28 +1,28 @@ { - "_from": "ccxt", - "_id": "ccxt@1.38.75", + "_from": "ccxt@1.42.77", + "_id": "ccxt@1.42.77", "_inBundle": false, - "_integrity": "sha512-cfyucvOi2WQnpR7HLuSuc2uc1vJkVVXfAQGc4D5HxJ2QYzjoez/1mjTm/iQ6+7El7Af1v3lJTtU+NJ9TpzPYFw==", + "_integrity": "sha512-vPaw8G3hr9iq1iJ59EHuA6iqjufgK6dNC7MjT3qV8YQbpEJoD2ynoFwfl1hbuvlyKlFjiOa3gHwhRV64UacBDQ==", "_location": "/ccxt", "_phantomChildren": {}, "_requested": { - "type": "tag", + "type": "version", "registry": true, - "raw": "ccxt", + "raw": "ccxt@1.42.77", "name": "ccxt", "escapedName": "ccxt", - "rawSpec": "", + "rawSpec": "1.42.77", "saveSpec": null, - "fetchSpec": "latest" + "fetchSpec": "1.42.77" }, "_requiredBy": [ "#USER", "/" ], - "_resolved": "https://registry.npmjs.org/ccxt/-/ccxt-1.38.75.tgz", - "_shasum": "1fb943c55da5e4c9aeb5fe267a5f230cbe18450c", - "_spec": "ccxt", - "_where": "c:\\Superalgos\\Projects\\Superalgos\\TS\\Bot-Modules\\Trading-Bot\\Low-Frequency-Trading\\APIs", + "_resolved": "https://registry.npmjs.org/ccxt/-/ccxt-1.42.77.tgz", + "_shasum": "8ab5f8e7190854e163da6d4fcf44530794d0a21c", + "_spec": "ccxt@1.42.77", + "_where": "C:\\Superalgos\\Projects\\Superalgos\\TS\\Bot-Modules\\Trading-Bot\\Low-Frequency-Trading\\APIs", "author": { "name": "Igor Kroitor", "email": "igor.kroitor@gmail.com", @@ -529,7 +529,21 @@ "bitcoin.com", "bibox365.com", "vcc.exchange", - "VCC Exchange" + "VCC Exchange", + "cdax.io", + "CDAX", + "delta.exchange", + "Delta Exchange", + "gopax.co.kr", + "Gopax", + "GOPAX", + "aax.com", + "AAX", + "aaxpro.com", + "equos.io", + "EQUOS", + "ndax.io", + "NDAX" ], "license": "MIT", "main": "./ccxt.js", @@ -540,9 +554,8 @@ }, "scripts": { "browserify": "browserify ./ccxt.browser.js > ./dist/ccxt.browser.js", - "build": "npm run build-without-docs && npm run update-badges", - "build-without-docs": "npm run export-exchanges && npm run vss && npm run copy-python-files && npm run check-js-syntax && npm run browserify && npm run transpile && npm run check-python-syntax && npm run check-php-syntax", - "check-js-syntax": "pwd && eslint --version && eslint \"js/*.js\"", + "build": "npm run pre-transpile && npm run transpile && npm run post-transpile && npm run update-badges", + "check-js-syntax": "node -e \"console.log(process.cwd())\" && eslint --version && eslint \"js/*.js\"", "check-php-syntax": "php -f php/test/syntax.php", "check-python-syntax": "cd python && tox -e qa && cd ..", "check-syntax": "npm run transpile && npm run check-js-syntax && npm run check-python-syntax && npm run check-php-syntax", @@ -554,20 +567,25 @@ "docker": "docker-compose run --rm ccxt", "export-exchanges": "node build/export-exchanges", "fast-test": "node run-tests --js", + "force-build": "npm run pre-transpile && npm run force-transpile && npm run post-transpile && npm run update-badges", + "force-transpile": "node build/transpile --force", "git-ignore-generated-files": "node build/git-ignore-generated-files", "git-unignore-generated-files": "node build/git-ignore-generated-files --unignore", "lint": "eslint", + "post-transpile": "npm run check-python-syntax && npm run check-php-syntax", "postinstall": "node postinstall", + "pre-transpile": "npm run export-exchanges && npm run vss && npm run copy-python-files && npm run check-js-syntax && npm run browserify", "test": "npm run build && node run-tests", "test-base": "npm run test-js-base && npm run test-python-base && npm run test-php-base", "test-js-base": "mocha js/test/base/test.base.js --reporter ololog/reporter", "test-php-base": "php -f php/test/decimal_to_precision.php && php -f php/test/test_crypto.php", - "test-python-base": "python python/test/test_decimal_to_precision.py", + "test-python-base": "python python/ccxt/test/test_decimal_to_precision.py", "transpile": "node build/transpile", "update-badges": "node build/update-badges", + "update-links": "node build/update-links", "vss": "node build/vss" }, "types": "./ccxt.d.ts", "unpkg": "dist/ccxt.browser.js", - "version": "1.38.75" + "version": "1.42.77" } diff --git a/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/package-lock.json b/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/package-lock.json index 9ad8e702a..976144cc2 100644 --- a/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/package-lock.json +++ b/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/package-lock.json @@ -3,9 +3,9 @@ "lockfileVersion": 1, "dependencies": { "ccxt": { - "version": "1.38.75", - "resolved": "https://registry.npmjs.org/ccxt/-/ccxt-1.38.75.tgz", - "integrity": "sha512-cfyucvOi2WQnpR7HLuSuc2uc1vJkVVXfAQGc4D5HxJ2QYzjoez/1mjTm/iQ6+7El7Af1v3lJTtU+NJ9TpzPYFw==" + "version": "1.42.77", + "resolved": "https://registry.npmjs.org/ccxt/-/ccxt-1.42.77.tgz", + "integrity": "sha512-vPaw8G3hr9iq1iJ59EHuA6iqjufgK6dNC7MjT3qV8YQbpEJoD2ynoFwfl1hbuvlyKlFjiOa3gHwhRV64UacBDQ==" } } } diff --git a/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/TradingStages.js b/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/TradingStages.js index df0e92cae..cbae4558a 100644 --- a/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/TradingStages.js +++ b/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/TradingStages.js @@ -975,39 +975,28 @@ exports.newSuperalgosBotModulesTradingStages = function (processIndex) { ABSOLUTE_DUST_IN_QUOTED_ASSET = tradingSystemStage.config.absoluteDustInQuotedAsset } - switch (tradingEngineStage.stageDefinedIn.value) { - case 'Base Asset': { - if ( - tradingEngineStage.stageBaseAsset.sizeFilled.value - * - ROUNDING_ERROR_CORRECTION_FACTOR - + - ABSOLUTE_DUST_IN_BASE_ASSET - >= - tradingEngineStage.stageBaseAsset.targetSize.value - ) { - positionFilled() - } else { - checkCloseStageEvent(tradingSystemStage) - } - break - } - case 'Quoted Asset': { - if ( - tradingEngineStage.stageQuotedAsset.sizeFilled.value - * - ROUNDING_ERROR_CORRECTION_FACTOR - + - ABSOLUTE_DUST_IN_QUOTED_ASSET - >= - tradingEngineStage.stageQuotedAsset.targetSize.value - ) { - positionFilled() - } else { - checkCloseStageEvent(tradingSystemStage) - } - break - } + if ( + tradingEngineStage.stageBaseAsset.sizeFilled.value + * + ROUNDING_ERROR_CORRECTION_FACTOR + + + ABSOLUTE_DUST_IN_BASE_ASSET + >= + tradingEngineStage.stageBaseAsset.targetSize.value + ) { + positionFilled() + } else if ( + tradingEngineStage.stageQuotedAsset.sizeFilled.value + * + ROUNDING_ERROR_CORRECTION_FACTOR + + + ABSOLUTE_DUST_IN_QUOTED_ASSET + >= + tradingEngineStage.stageQuotedAsset.targetSize.value + ) { + positionFilled() + } else { + checkCloseStageEvent(tradingSystemStage) } function positionFilled() { @@ -1181,4 +1170,4 @@ exports.newSuperalgosBotModulesTradingStages = function (processIndex) { } throw 'Error Already Recorded' } -} \ No newline at end of file +} diff --git a/Projects/Superalgos/UI/Function-Libraries/WebhookFunctions.js b/Projects/Superalgos/UI/Function-Libraries/WebhookFunctions.js index 64f476412..112b1347f 100644 --- a/Projects/Superalgos/UI/Function-Libraries/WebhookFunctions.js +++ b/Projects/Superalgos/UI/Function-Libraries/WebhookFunctions.js @@ -13,8 +13,10 @@ function newSuperalgosFunctionLibraryWebhookFunctions() { function onResponse(err) { if (err.result === GLOBAL.DEFAULT_OK_RESPONSE.result) { + node.payload.uiObject.setInfoMessage('Test Message sent to the Client.') callBackFunction(GLOBAL.DEFAULT_OK_RESPONSE) } else { + node.payload.uiObject.resetErrorMessage('Could not send Test Message to the Client.') callBackFunction(GLOBAL.DEFAULT_FAIL_RESPONSE) } } diff --git a/Projects/Superalgos/UI/Spaces/Docs-Space/ContextMenu.js b/Projects/Superalgos/UI/Spaces/Docs-Space/ContextMenu.js index 6c636076f..b2dd3d6f1 100644 --- a/Projects/Superalgos/UI/Spaces/Docs-Space/ContextMenu.js +++ b/Projects/Superalgos/UI/Spaces/Docs-Space/ContextMenu.js @@ -293,7 +293,7 @@ function newSuperalgosDocsContextMenu() { We need to locate the parent node that it is a Paragraph, otherwise we could end up in an inner html element. */ - let paragraphNode = selection.baseNode + let paragraphNode = selection.anchorNode if (paragraphNode.id !== undefined && paragraphNode.parentNode.className === "docs-tooltip") { return false @@ -457,4 +457,4 @@ function newSuperalgosDocsContextMenu() { return true } } -} \ No newline at end of file +} diff --git a/Projects/Superalgos/UI/Spaces/Floating-Space/FloatingSpace.js b/Projects/Superalgos/UI/Spaces/Floating-Space/FloatingSpace.js index ba8292de5..4131368d7 100644 --- a/Projects/Superalgos/UI/Spaces/Floating-Space/FloatingSpace.js +++ b/Projects/Superalgos/UI/Spaces/Floating-Space/FloatingSpace.js @@ -100,6 +100,7 @@ function newSuperalgosFloatingSpace() { } }, physics: true, + detachUsingMouse: false } return thisObject @@ -536,6 +537,9 @@ function newSuperalgosFloatingSpace() { if (configSettings.physics !== undefined) { thisObject.settings.physics = configSettings.physics } + if (configSettings.detachUsingMouse !== undefined) { + thisObject.settings.detachUsingMouse = configSettings.detachUsingMouse + } } function positionContraintsPhysics() { diff --git a/Projects/Superalgos/UI/Spaces/Floating-Space/UiObject.js b/Projects/Superalgos/UI/Spaces/Floating-Space/UiObject.js index 7d5910a89..80380a401 100644 --- a/Projects/Superalgos/UI/Spaces/Floating-Space/UiObject.js +++ b/Projects/Superalgos/UI/Spaces/Floating-Space/UiObject.js @@ -560,6 +560,7 @@ function newUiObject() { function chainDetachingPhysics() { if (isDragging !== true) { return } if (rightDragging === false) { return } + if (UI.projects.superalgos.spaces.floatingSpace.settings.detachUsingMouse !== true) {return} let distanceToChainParent = Math.sqrt(Math.pow(thisObject.payload.position.x - thisObject.payload.targetPosition.x, 2) + Math.pow(thisObject.payload.position.y - thisObject.payload.targetPosition.y, 2)) let ratio = distanceToChainParent / previousDistanceToChainParent @@ -665,6 +666,7 @@ function newUiObject() { if (thisObject.payload === undefined) { return } if (thisObject.payload.floatingObject.isFrozen === true) { return } if (rightDragging === false) { return } + if (UI.projects.superalgos.spaces.floatingSpace.settings.detachUsingMouse !== true) {return} if (thisObject.payload.referenceParent === undefined) { return } diff --git a/README.md b/README.md index fe60c7529..60b4c4af8 100644 --- a/README.md +++ b/README.md @@ -71,22 +71,16 @@ Before you begin, it is recommended that you set up Chrome/Safari as your defaul # Superalgos Client Installation -**1.** Scroll the page all the way to the top. Find and click the **Fork** button to create your fork/copy of this repository. To fork Superalgos you need a GitHub account. If you don't have one, go ahead and create it. +**1.** Scroll the page all the way to the top. Find and click the **Fork** button to create your fork/copy of this repository. To fork Superalgos you need a Github account. If you don't have one, go ahead and create it. **NOTE:** A Fork is required for your contributions to the project. The reason why Superalgos is free and open-source is that the project has set up a Collective Business in which all users may participate. The way to participate is to contribute to make Superalgos better. The project's token is distributed among contributors. **2.** Once the fork is created, you will land on the page of your fork. Copy the URL from your browser's address bar. -**3.** In your computer/laptop/server, open a command prompt or terminal as an administrator (to avoid issues with permissions) and type: +**3.** In your computer/laptop/server, open a command prompt or terminal. Make sure you are in a directory where you have write permissions (on most systems the terminal will open in your user’s home directory, so you’re good). Clone the git repository using the command ``` -git clone -``` - -**5.** Don't hit Enter yet! Complete the command by pasting the URL of your fork! - -``` -git clone + URL of your Superalgos fork. +git clone ``` For example, if your Github username is John, the command will look like this: @@ -95,7 +89,7 @@ For example, if your Github username is John, the command will look like this: git clone https://github.com/John/Superalgos ``` -Ok, you have installed Superalgos. To run the App, jump to the section Usage below. +This creates the `Superalgos` folder in the current directory, which contains the whole installation. To run the App, jump to the section Usage below. ## Installation Notes @@ -103,9 +97,7 @@ Ok, you have installed Superalgos. To run the App, jump to the section Usage bel **2.** The software includes an in-app self-update command / feature. It will help you stay up-to-date with the latest version of the software. Updates are on-demand, so don't worry about undesired updates. The project moves very fast and new features become available regularly, particularly if you choose to run the software in the ```develop``` branch (you may switch branches from within the app). -**3.** You are better off running the git clone command as an administrator to avoid permission issues while creating the Superalgos folder and downloading the repository. It may work without admin powers depending on your setup, particularly if you are running the command on a folder where you've got write permissions. - -**4.** Before installing the client on a remote computer in an attempt to access the UI from a different machine, we highly recommend you do a standard installation on your PC / laptop first. Leave your Raspberry Pi or server for later, once you have done all available tutorials. This single tip will save you a lot of time: you don't need to add complexity before you learn how to handle the app. +**3.** Before installing the client on a remote computer in an attempt to access the UI from a different machine, we highly recommend you do a standard installation on your PC / laptop first. Leave your Raspberry Pi or server for later, once you have done all available tutorials. This single tip will save you a lot of time: you don't need to add complexity before you learn how to handle the app. ## Migrating from Superalgos Beta 8 @@ -162,6 +154,47 @@ node run minMemo noBrowser **1.** We are testing the UI on Google Chrome and Safari on macOS only. It may work on other browsers as well — or not. If you are running on a different browser and ever need support, make sure you mention that fact upfront, or even better, try on Chrome/Safari first. **TIP:** If your computer has 8 GB of RAM or less, use ```node run minMemo``` to run the system with minimal RAM requirements. + +# Running Superalgos on a headless linux server as a daemon + +If you’re running Superalgos on a headless linux server like a Raspberry Pi, you might want to run it as a daemon so it isn’t attached to your current login session. The easiest, most standard way to go about this is probably using `systemd`. Most linux distributions use it as default init system/service manager. + +## Using `systemd` + +Create a `superalgos.service` file looking like this (change `` to your user name and `/path/to/Superalgos` to your Superalgos folder, for instance `/home/John/Superalgos`): +``` +[Unit] +Description=Superalgos client + +[Service] +Type=simple +User= +WorkingDirectory=/path/to/Superalgos +ExecStart=/usr/bin/node run minMemo noBrowser + +[Install] +WantedBy=multi-user.target + +``` +There is no need to run Superalgos as root so we’re running it as a user. The `minMemo` option assumes you’re running on a small machine like a Raspberry Pi, while `noBrowser` makes sense for running daemonized. + +Now, as root (or using `sudo`), put the file `superalgos.service` you just created in `/etc/systemd/system/` and issue the command +``` +systemctl enable superalgos +``` +This will install the service so that Superalgos is started on boot. To start it manually, do (again as root or with `sudo`) +``` +systemctl start superalgos +``` + +To see the output of Superalgos, use +``` +journalctl -u superalgos +``` +or to follow the output, +``` +journalctl -u superalgos -f +``` # Uninstall