diff --git a/Projects/Superalgos/Schemas/AppSchema.json b/Projects/Superalgos/Schemas/AppSchema.json
index c088ebefb..82b1587f1 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",
@@ -15127,7 +15125,8 @@
"config": "{ \n\"webhookURL\": \"Webhook/New-Message/Trading-View/Binance/BTC-USDT\",\n\"testMessage\": \"\" \n}"
},
"propertyNameAtParent": "signalsProviders",
- "childrenNodesProperties": []
+ "childrenNodesProperties": [],
+ "icon": "bitcoin"
},
{
"type": "Crypto Exchanges",
@@ -19794,4 +19793,4 @@
}
]
}
-]
\ 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..839718771 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,10 +7,31 @@
"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",
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/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/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..41c26d98d 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
-[](https://travis-ci.com/ccxt/ccxt) [](https://npmjs.com/package/ccxt) [](https://pypi.python.org/pypi/ccxt) [](https://www.npmjs.com/package/ccxt) [](https://discord.gg/dhzSKYU) [](https://github.com/ccxt/ccxt/wiki/Exchange-Markets) [](https://opencollective.com/ccxt)
+[](https://travis-ci.com/ccxt/ccxt) [](https://npmjs.com/package/ccxt) [](https://pypi.python.org/pypi/ccxt) [](https://www.npmjs.com/package/ccxt) [](https://discord.gg/dhzSKYU) [](https://github.com/ccxt/ccxt/wiki/Exchange-Markets) [](https://opencollective.com/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
-[](https://ccxt.pro) **[A JavaScript / Python / PHP cryptocurrency exchange trading WebSocket API for professionals](https://ccxt.pro)**
+[](https://ccxt.pro)
## See Also
- [](https://quadency.com?utm_source=ccxt) **[Quadency](https://quadency.com?utm_source=ccxt)** — trading automation terminal for leading exchanges with streaming APIs + Python IDE.
- [](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).
+- [](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)!
+- [](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 |
-|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---------------|-----------------------------------------------------------------------------|:---:|:----------------------------------------------------------------------------------:|-----------------------------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------|
-| [](https://www.binance.com/?ref=10205187) | binance | [Binance](https://www.binance.com/?ref=10205187) | * | [API](https://binance-docs.github.io/apidocs/spot/en) | [](https://github.com/ccxt/ccxt/wiki/Certification) | [](https://ccxt.pro) |
-| [](https://www.bitfinex.com/?refcode=P61eYxFL) | bitfinex | [Bitfinex](https://www.bitfinex.com/?refcode=P61eYxFL) | 1 | [API](https://docs.bitfinex.com/v1/docs) | [](https://github.com/ccxt/ccxt/wiki/Certification) | [](https://ccxt.pro) |
-| [](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) | [](https://github.com/ccxt/ccxt/wiki/Certification) | [](https://ccxt.pro) |
-| [](https://bitvavo.com/?a=24F34952F7) | bitvavo | [Bitvavo](https://bitvavo.com/?a=24F34952F7) | 2 | [API](https://docs.bitvavo.com/) | [](https://github.com/ccxt/ccxt/wiki/Certification) | [](https://ccxt.pro) |
-| [](https://www.byte-trade.com) | bytetrade | [ByteTrade](https://www.byte-trade.com) | * | [API](https://docs.byte-trade.com/#description) | [](https://github.com/ccxt/ccxt/wiki/Certification) | |
-| [](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) | [](https://github.com/ccxt/ccxt/wiki/Certification) | [](https://ccxt.pro) |
-| [](https://eterbase.exchange/invite/1wjjh4Pe) | eterbase | [Eterbase](https://eterbase.exchange/invite/1wjjh4Pe) | 1 | [API](https://developers.eterbase.exchange) | [](https://github.com/ccxt/ccxt/wiki/Certification) | |
-| [](https://ftx.com/#a=1623029) | ftx | [FTX](https://ftx.com/#a=1623029) | * | [API](https://github.com/ftexchange/ftx) | [](https://github.com/ccxt/ccxt/wiki/Certification) | [](https://ccxt.pro) |
-| [](https://idex.io) | idex | [IDEX](https://idex.io) | 2 | [API](https://docs.idex.io/) | [](https://github.com/ccxt/ccxt/wiki/Certification) | [](https://ccxt.pro) |
-| [](https://www.kraken.com) | kraken | [Kraken](https://www.kraken.com) | 0 | [API](https://www.kraken.com/features/api) | [](https://github.com/ccxt/ccxt/wiki/Certification) | [](https://ccxt.pro) |
-| [](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) | [](https://github.com/ccxt/ccxt/wiki/Certification) | [](https://ccxt.pro) |
-| [](https://waves.exchange) | wavesexchange | [Waves.Exchange](https://waves.exchange) | * | [API](https://docs.waves.exchange) | [](https://github.com/ccxt/ccxt/wiki/Certification) | |
-| [](https://xena.exchange) | xena | [Xena Exchange](https://xena.exchange) | * | [API](https://support.xena.exchange/support/solutions/44000808700) | [](https://github.com/ccxt/ccxt/wiki/Certification) | |
+| logo | id | name | ver | doc | certified | pro |
+|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---------------|-----------------------------------------------------------------------------|:---:|:------------------------------------------------------------------:|-----------------------------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------|
+| [](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) | [](https://github.com/ccxt/ccxt/wiki/Certification) | |
+| [](https://www.binance.com/?ref=10205187) | binance | [Binance](https://www.binance.com/?ref=10205187) | * | [API](https://binance-docs.github.io/apidocs/spot/en) | [](https://github.com/ccxt/ccxt/wiki/Certification) | [](https://ccxt.pro) |
+| [](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) | [](https://github.com/ccxt/ccxt/wiki/Certification) | [](https://ccxt.pro) |
+| [](https://bitvavo.com/?a=24F34952F7) | bitvavo | [Bitvavo](https://bitvavo.com/?a=24F34952F7) | 2 | [API](https://docs.bitvavo.com/) | [](https://github.com/ccxt/ccxt/wiki/Certification) | [](https://ccxt.pro) |
+| [](https://www.byte-trade.com) | bytetrade | [ByteTrade](https://www.byte-trade.com) | * | [API](https://docs.byte-trade.com/#description) | [](https://github.com/ccxt/ccxt/wiki/Certification) | |
+| [](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) | [](https://github.com/ccxt/ccxt/wiki/Certification) | [](https://ccxt.pro) |
+| [](https://eterbase.exchange/invite/1wjjh4Pe) | eterbase | [Eterbase](https://eterbase.exchange/invite/1wjjh4Pe) | 1 | [API](https://developers.eterbase.exchange) | [](https://github.com/ccxt/ccxt/wiki/Certification) | |
+| [](https://ftx.com/#a=1623029) | ftx | [FTX](https://ftx.com/#a=1623029) | * | [API](https://github.com/ftexchange/ftx) | [](https://github.com/ccxt/ccxt/wiki/Certification) | [](https://ccxt.pro) |
+| [](https://www.gopax.co.kr) | gopax | [GOPAX](https://www.gopax.co.kr) | 1 | [API](https://gopax.github.io/API/index.en.html) | [](https://github.com/ccxt/ccxt/wiki/Certification) | [](https://ccxt.pro) |
+| [](https://idex.io) | idex | [IDEX](https://idex.io) | 2 | [API](https://docs.idex.io/) | [](https://github.com/ccxt/ccxt/wiki/Certification) | [](https://ccxt.pro) |
+| [](https://www.kraken.com) | kraken | [Kraken](https://www.kraken.com) | 0 | [API](https://www.kraken.com/features/api) | [](https://github.com/ccxt/ccxt/wiki/Certification) | [](https://ccxt.pro) |
+| [](https://waves.exchange) | wavesexchange | [Waves.Exchange](https://waves.exchange) | * | [API](https://docs.waves.exchange) | [](https://github.com/ccxt/ccxt/wiki/Certification) | |
+| [](https://xena.exchange) | xena | [Xena Exchange](https://xena.exchange) | * | [API](https://support.xena.exchange/support/solutions/44000808700) | [](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 |
|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|--------------------|-----------------------------------------------------------------------------------------|:---:|:-------------------------------------------------------------------------------------------:|-----------------------------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------|
+| [](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) | [](https://github.com/ccxt/ccxt/wiki/Certification) | |
| [](https://acx.io) | acx | [ACX](https://acx.io) | 2 | [API](https://acx.io/documents/api_v2) | | |
| [](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) | | |
-| [](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) | | |
| [](https://bequant.io) | bequant | [Bequant](https://bequant.io) | 2 | [API](https://api.bequant.io/) | | [](https://ccxt.pro) |
| [](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/) | | |
| [](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
| [](https://bitbank.cc/) | bitbank | [bitbank](https://bitbank.cc/) | 1 | [API](https://docs.bitbank.cc/) | | |
| [](https://auth.bitbay.net/ref/jHlbB4mIkdS1) | bitbay | [BitBay](https://auth.bitbay.net/ref/jHlbB4mIkdS1) | * | [API](https://bitbay.net/public-api) | | |
| [](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) | | [](https://ccxt.pro) |
-| [](https://www.bitfinex.com/?refcode=P61eYxFL) | bitfinex | [Bitfinex](https://www.bitfinex.com/?refcode=P61eYxFL) | 1 | [API](https://docs.bitfinex.com/v1/docs) | [](https://github.com/ccxt/ccxt/wiki/Certification) | [](https://ccxt.pro) |
+| [](https://www.bitfinex.com/?refcode=P61eYxFL) | bitfinex | [Bitfinex](https://www.bitfinex.com/?refcode=P61eYxFL) | 1 | [API](https://docs.bitfinex.com/v1/docs) | | [](https://ccxt.pro) |
| [](https://www.bitfinex.com/?refcode=P61eYxFL) | bitfinex2 | [Bitfinex](https://www.bitfinex.com/?refcode=P61eYxFL) | 2 | [API](https://docs.bitfinex.com/v2/docs/) | | |
| [](https://bitflyer.com) | bitflyer | [bitFlyer](https://bitflyer.com) | 1 | [API](https://lightning.bitflyer.com/docs?lang=en) | | |
| [](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) | | |
| [](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) | | |
| [](https://www.bithumb.com) | bithumb | [Bithumb](https://www.bithumb.com) | * | [API](https://apidocs.bithumb.com) | | |
| [](https://www.bitkk.com) | bitkk | [bitkk](https://www.bitkk.com) | 1 | [API](https://www.bitkk.com/i/developer) | | |
-| [](http://www.bitmart.com/?r=rQCFLh) | bitmart | [BitMart](http://www.bitmart.com/?r=rQCFLh) | 1 | [API](https://github.com/bitmartexchange/bitmart-official-api-docs) | | |
+| [](http://www.bitmart.com/?r=rQCFLh) | bitmart | [BitMart](http://www.bitmart.com/?r=rQCFLh) | 1 | [API](https://developer-pro.bitmart.com/) | | |
| [](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) | | |
| [](https://www.bitmex.com/register/upZpOX) | bitmex | [BitMEX](https://www.bitmex.com/register/upZpOX) | 1 | [API](https://www.bitmex.com/app/apiOverview) | | [](https://ccxt.pro) |
| [](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
| [](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) | | |
| [](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/) | | |
| [](https://www.byte-trade.com) | bytetrade | [ByteTrade](https://www.byte-trade.com) | * | [API](https://docs.byte-trade.com/#description) | [](https://github.com/ccxt/ccxt/wiki/Certification) | |
+| [](https://cdax.io/invite?invite_code=esc74) | cdax | [CDAX](https://cdax.io/invite?invite_code=esc74) | 1 | [API](https://github.com/cloudapidoc/API_Docs) | | |
| [](https://cex.io/r/0/up105393824/0/) | cex | [CEX.IO](https://cex.io/r/0/up105393824/0/) | * | [API](https://cex.io/cex-api) | | |
| [](https://chilebit.net) | chilebit | [ChileBit](https://chilebit.net) | 1 | [API](https://blinktrade.com/docs) | | |
| [](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
| [](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) | | |
| [](https://crex24.com/?refid=slxsjsjtil8xexl9hksr) | crex24 | [CREX24](https://crex24.com/?refid=slxsjsjtil8xexl9hksr) | 2 | [API](https://docs.crex24.com/trade-api/v2) | | |
| [](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) | [](https://github.com/ccxt/ccxt/wiki/Certification) | [](https://ccxt.pro) |
+| [](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) | | |
| [](https://www.deribit.com/reg-1189.4038) | deribit | [Deribit](https://www.deribit.com/reg-1189.4038) | 2 | [API](https://docs.deribit.com/v2) | | |
| [](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) | | |
| [](https://dsxglobal.com) | dsx | [DSX](https://dsxglobal.com) | 3 | [API](https://dsxglobal.com/developers/publicApi) | | |
+| [](https://equos.io?referredByCode=zpa8kij4ouvBFup3) | equos | [EQUOS](https://equos.io?referredByCode=zpa8kij4ouvBFup3) | * | [API](https://developer.equos.io) | | |
| [](https://eterbase.exchange/invite/1wjjh4Pe) | eterbase | [Eterbase](https://eterbase.exchange/invite/1wjjh4Pe) | 1 | [API](https://developers.eterbase.exchange) | [](https://github.com/ccxt/ccxt/wiki/Certification) | |
| [](https://exmo.me/?ref=131685) | exmo | [EXMO](https://exmo.me/?ref=131685) | 1.1 | [API](https://exmo.me/en/api_doc?ref=131685) | | |
| [](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
| [](https://ftx.com/#a=1623029) | ftx | [FTX](https://ftx.com/#a=1623029) | * | [API](https://github.com/ftexchange/ftx) | [](https://github.com/ccxt/ccxt/wiki/Certification) | [](https://ccxt.pro) |
| [](https://www.gate.io/signup/2436035) | gateio | [Gate.io](https://www.gate.io/signup/2436035) | 2 | [API](https://gate.io/api2) | | [](https://ccxt.pro) |
| [](https://gemini.com/) | gemini | [Gemini](https://gemini.com/) | 1 | [API](https://docs.gemini.com/rest-api) | | |
+| [](https://www.gopax.co.kr) | gopax | [GOPAX](https://www.gopax.co.kr) | 1 | [API](https://gopax.github.io/API/index.en.html) | [](https://github.com/ccxt/ccxt/wiki/Certification) | [](https://ccxt.pro) |
| [](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) | | |
| [](https://hitbtc.com/?ref_id=5a5d39a65d466) | hitbtc | [HitBTC](https://hitbtc.com/?ref_id=5a5d39a65d466) | 2 | [API](https://api.hitbtc.com) | | [](https://ccxt.pro) |
| [](https://pro.hollaex.com/signup?affiliation_code=QSWA6G) | hollaex | [HollaEx](https://pro.hollaex.com/signup?affiliation_code=QSWA6G) | 1 | [API](https://apidocs.hollaex.com) | | |
| [](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) | | [](https://ccxt.pro) |
| [](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/) | | [](https://ccxt.pro) |
-| [](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) | | [](https://ccxt.pro) |
| [](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) | | |
| [](https://idex.io) | idex | [IDEX](https://idex.io) | 2 | [API](https://docs.idex.io/) | [](https://github.com/ccxt/ccxt/wiki/Certification) | [](https://ccxt.pro) |
| [](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
| [](https://latoken.com) | latoken | [Latoken](https://latoken.com) | 1 | [API](https://api.latoken.com) | | |
| [](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) | | |
| [](https://www.liquid.com/sign-up/?affiliate=SbzC62lt30976) | liquid | [Liquid](https://www.liquid.com/sign-up/?affiliate=SbzC62lt30976) | 2 | [API](https://developers.liquid.com) | | |
-| [](https://livecoin.net/?from=Livecoin-CQ1hfx44) | livecoin | [LiveCoin](https://livecoin.net/?from=Livecoin-CQ1hfx44) | * | [API](https://www.livecoin.net/api?lang=en) | | |
| [](https://www.luno.com/invite/44893A) | luno | [luno](https://www.luno.com/invite/44893A) | 1 | [API](https://www.luno.com/en/api) | | |
| [](https://www.lykke.com) | lykke | [Lykke](https://www.lykke.com) | 1 | [API](https://hft-api.lykke.com/swagger/ui/) | | |
| [](https://www.mercadobitcoin.com.br) | mercado | [Mercado Bitcoin](https://www.mercadobitcoin.com.br) | 3 | [API](https://www.mercadobitcoin.com.br/api-doc) | | |
| [](https://mixcoins.com) | mixcoins | [MixCoins](https://mixcoins.com) | 1 | [API](https://mixcoins.com/help/api/) | | |
+| [](https://one.ndax.io/bfQiSL) | ndax | [NDAX](https://one.ndax.io/bfQiSL) | * | [API](https://apidoc.ndax.io/) | | [](https://ccxt.pro) |
| [](https://www.novadax.com.br/?s=ccxt) | novadax | [NovaDAX](https://www.novadax.com.br/?s=ccxt) | 1 | [API](https://doc.novadax.com/pt-BR/) | | |
| [](https://oceanex.pro/signup?referral=VE24QX) | oceanex | [OceanEx](https://oceanex.pro/signup?referral=VE24QX) | 1 | [API](https://api.oceanex.pro/doc/v1) | | |
| [](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/) | | [](https://ccxt.pro) |
@@ -166,7 +171,7 @@ The CCXT library currently supports the following 123 cryptocurrency exchange ma
| [](http://bit.ly/2IX0LrM) | tidebit | [TideBit](http://bit.ly/2IX0LrM) | 2 | [API](https://www.tidebit.com/documents/api/guide) | | |
| [](https://tidex.com/exchange/?ref=57f5638d9cd7) | tidex | [Tidex](https://tidex.com/exchange/?ref=57f5638d9cd7) | 3 | [API](https://tidex.com/exchange/public-api) | | |
| [](https://timex.io/?refcode=1x27vNkTbP1uwkCck) | timex | [TimeX](https://timex.io/?refcode=1x27vNkTbP1uwkCck) | 1 | [API](https://docs.timex.io) | | |
-| [](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) | [](https://github.com/ccxt/ccxt/wiki/Certification) | [](https://ccxt.pro) |
+| [](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) | | [](https://ccxt.pro) |
| [](https://www.vaultoro.com) | vaultoro | [Vaultoro](https://www.vaultoro.com) | 1 | [API](https://api.vaultoro.com) | | |
| [](https://vbtc.exchange) | vbtc | [VBTC](https://vbtc.exchange) | 1 | [API](https://blinktrade.com/docs) | | |
| [](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.67/dist/ccxt.browser.js
+* unpkg: https://unpkg.com/ccxt@1.42.67/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..a5dd8e087 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)
@@ -1092,7 +1146,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 +1211,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 +1223,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 +1252,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 +1266,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 +1337,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 +1349,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 +1406,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 +1443,6 @@ class Transpiler {
])
const pythonHeader = [
- '',
'import numbers # noqa: E402',
'try:',
' basestring # basestring was removed in Python 3',
@@ -1400,7 +1453,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 +1476,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 +1541,10 @@ class Transpiler {
this.transpilePythonAsyncToSync ()
+ this.transpilePhpAsyncToSync ()
+
+ this.transpilePhpBaseClassMethods ()
+
log.bright.green ('Transpiled successfully.')
}
}
@@ -1469,12 +1557,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..cfe45fb0d 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 {}
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..d4dfef7b1 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.67'
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..1df9f81a0 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.67'
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 () {
@@ -3169,7 +4959,7 @@ module.exports = class Exchange {
}
-},{"../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 +5005,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 +5038,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 +5062,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 +5092,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 +5252,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 +5372,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 +5610,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 +5750,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 +6091,7 @@ module.exports = {
/* ------------------------------------------------------------------------ */
-},{}],14:[function(require,module,exports){
+},{}],15:[function(require,module,exports){
(function (process){
"use strict";
@@ -4338,30 +6132,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 +6218,7 @@ module.exports = {
/* ------------------------------------------------------------------------ */
-},{"./time":17}],17:[function(require,module,exports){
+},{"./time":18}],18:[function(require,module,exports){
'use strict';
/* ------------------------------------------------------------------------ */
@@ -4631,7 +6422,7 @@ module.exports =
/* ------------------------------------------------------------------------ */
-},{}],18:[function(require,module,exports){
+},{}],19:[function(require,module,exports){
"use strict";
/* ------------------------------------------------------------------------ */
@@ -4699,696 +6490,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 +6524,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 +6598,7 @@ module.exports = class bibox extends Exchange {
'get': [
'cquery',
'mdata',
+ 'cdata',
],
},
'private': {
@@ -5533,9 +6636,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 +6659,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 +6962,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 +7046,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 +7406,7 @@ module.exports = class bibox extends Exchange {
'symbol': symbol,
'type': type,
'timeInForce': undefined,
+ 'postOnly': undefined,
'side': side,
'price': price,
'stopPrice': undefined,
@@ -6276,7 +7459,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 +7479,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 +7606,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 +7656,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 +7737,7 @@ module.exports = class bigone extends Exchange {
'private': {
'get': [
'accounts',
+ 'fund/accounts',
'assets/{asset_symbol}/address',
'orders',
'orders/{id}',
@@ -6567,6 +7751,7 @@ module.exports = class bigone extends Exchange {
'orders/{id}/cancel',
'orders/cancel',
'withdrawals',
+ 'transfer',
],
},
},
@@ -7121,7 +8306,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 +8385,7 @@ module.exports = class bigone extends Exchange {
'symbol': symbol,
'type': undefined,
'timeInForce': undefined,
+ 'postOnly': undefined,
'side': side,
'price': price,
'stopPrice': undefined,
@@ -7234,7 +8423,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 +8931,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 +8957,7 @@ module.exports = class binance extends Exchange {
'cancelOrder': true,
'CORS': false,
'createOrder': true,
+ 'fetchCurrencies': true,
'fetchBalance': true,
'fetchBidsAsks': true,
'fetchClosedOrders': 'emulated',
@@ -7858,6 +9048,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 +9090,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 +9116,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 +9150,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 +9165,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 +9284,7 @@ module.exports = class binance extends Exchange {
'historicalTrades',
'aggTrades',
'klines',
+ 'continuousKlines',
'fundingRate',
'premiumIndex',
'ticker/24hr',
@@ -8102,6 +9319,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 +9338,9 @@ module.exports = class binance extends Exchange {
'leverage',
'listenKey',
'countdownCancelAll',
+ // broker endpoints
+ 'apiReferral/customization',
+ 'apiReferral/userCustomization',
],
'put': [
'listenKey',
@@ -8191,6 +9420,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 +9435,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 +9492,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 +9530,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 +9845,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 +9924,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 +10326,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 +10431,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 +10477,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 +10597,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 +10723,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 +10735,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 +10783,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 +10870,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 +10878,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 +10888,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 +10900,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 +10921,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 +10930,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 +11043,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 +11053,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 +11076,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 +11087,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 +11155,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 +11455,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 +11507,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 +11705,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 +11816,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 +11861,10 @@ module.exports = class binanceus extends binance {
},
});
}
+
+ async fetchCurrencies (params = {}) {
+ return undefined;
+ }
};
@@ -10728,6 +12177,7 @@ module.exports = class bit2c extends Exchange {
'symbol': symbol,
'type': undefined,
'timeInForce': undefined,
+ 'postOnly': undefined,
'side': side,
'price': price,
'stopPrice': undefined,
@@ -10879,7 +12329,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 +12414,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 +12424,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 +12542,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 +12702,7 @@ module.exports = class bitbank extends Exchange {
'symbol': symbol,
'type': type,
'timeInForce': undefined,
+ 'postOnly': undefined,
'side': side,
'price': price,
'stopPrice': undefined,
@@ -11267,7 +12721,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 +12957,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 +13311,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 +13323,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 +14233,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 +14269,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 +14288,6 @@ module.exports = class bitfinex extends Exchange {
'countries': [ 'VG' ],
'version': 'v1',
'rateLimit': 1500,
- 'certified': true,
'pro': true,
// new metainfo interface
'has': {
@@ -12870,6 +14325,7 @@ module.exports = class bitfinex extends Exchange {
'30m': '30m',
'1h': '1h',
'3h': '3h',
+ '4h': '4h',
'6h': '6h',
'12h': '12h',
'1d': '1D',
@@ -13416,13 +14872,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 +15060,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 +15178,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 +15554,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 +15610,7 @@ module.exports = class bitfinex2 extends bitfinex {
'30m': '30m',
'1h': '1h',
'3h': '3h',
+ '4h': '4h',
'6h': '6h',
'12h': '12h',
'1d': '1D',
@@ -14252,7 +15729,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 +16143,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 +16487,7 @@ module.exports = class bitfinex2 extends bitfinex {
'symbol': symbol,
'type': type,
'timeInForce': undefined,
+ 'postOnly': undefined,
'side': side,
'price': price,
'stopPrice': undefined,
@@ -15022,16 +16506,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 +17128,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 +17496,7 @@ module.exports = class bitflyer extends Exchange {
'symbol': symbol,
'type': type,
'timeInForce': undefined,
+ 'postOnly': undefined,
'side': side,
'price': price,
'stopPrice': undefined,
@@ -16044,7 +17556,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 +17572,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 +17654,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 +17880,7 @@ module.exports = class bitforex extends Exchange {
},
'commonCurrencies': {
'CREDIT': 'TerraCredit',
+ 'HBC': 'Hybrid Bank Cash',
'IQ': 'IQ.Cash',
'UOS': 'UOS Network',
},
@@ -16376,6 +17889,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 +18158,7 @@ module.exports = class bitforex extends Exchange {
'symbol': symbol,
'type': type,
'timeInForce': undefined,
+ 'postOnly': undefined,
'side': side,
'price': price,
'stopPrice': undefined,
@@ -16772,7 +18287,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 +19994,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 +20006,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 +20250,7 @@ module.exports = class bitget extends Exchange {
'symbol': symbol,
'type': type,
'timeInForce': undefined,
+ 'postOnly': undefined,
'side': side,
'price': price,
'stopPrice': undefined,
@@ -18817,7 +20333,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 +20375,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 +20416,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 +20481,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 +20558,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 +20643,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 +20735,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 +20772,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 +20895,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 +20959,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 +20976,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 +21195,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 +21220,7 @@ module.exports = class bithumb extends Exchange {
'createOrder': true,
'fetchBalance': true,
'fetchMarkets': true,
+ 'fetchOHLCV': true,
'fetchOpenOrders': true,
'fetchOrder': true,
'fetchOrderBook': true,
@@ -19726,10 +21244,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 +21294,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 +21323,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 +21579,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 +21756,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 +21769,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 +21782,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 +21994,7 @@ module.exports = class bithumb extends Exchange {
'symbol': symbol,
'type': type,
'timeInForce': undefined,
+ 'postOnly': undefined,
'side': side,
'price': price,
'stopPrice': undefined,
@@ -20411,7 +22017,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 +22057,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 +22091,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 +22172,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 +22196,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 +22254,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 +22367,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 +22502,8 @@ module.exports = class bitmart extends Exchange {
'broad': {},
},
'commonCurrencies': {
+ 'COT': 'Community Coin',
+ 'CPC': 'CPCoin',
'ONE': 'Menlo One',
'PLA': 'Plair',
},
@@ -21838,7 +23449,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 +23457,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 +23530,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 +23808,7 @@ module.exports = class bitmart extends Exchange {
'symbol': symbol,
'type': type,
'timeInForce': undefined,
+ 'postOnly': undefined,
'side': side,
'price': price,
'stopPrice': undefined,
@@ -22302,7 +23914,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 +23942,15 @@ module.exports = class bitmart extends Exchange {
// }
// }
//
+ // spot alternative
+ //
+ // {
+ // "code": 1000,
+ // "trace":"886fb6ae-456b-4654-b4e0-d681ac05cea1",
+ // "message": "OK",
+ // "data": true
+ // }
+ //
// contract
//
// {
@@ -22345,16 +23966,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 +23987,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 +24016,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 +24062,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 +24184,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 +24196,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 +24274,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 +24568,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 +24704,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 +25610,7 @@ module.exports = class bitmax extends Exchange {
'symbol': symbol,
'type': type,
'timeInForce': undefined,
+ 'postOnly': undefined,
'side': side,
'price': price,
'stopPrice': stopPrice,
@@ -24036,7 +25661,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 +25916,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 +26296,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 +26466,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 +27519,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 +27585,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 +27597,7 @@ module.exports = class bitmex extends Exchange {
'symbol': symbol,
'type': type,
'timeInForce': timeInForce,
+ 'postOnly': postOnly,
'side': side,
'price': price,
'stopPrice': stopPrice,
@@ -26000,18 +27666,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 +27982,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 +28775,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 +28953,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 +29008,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 +29313,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 +29324,7 @@ module.exports = class bitpanda extends Exchange {
'symbol': symbol,
'type': type,
'timeInForce': timeInForce,
+ 'postOnly': postOnly,
'side': side,
'price': price,
'stopPrice': stopPrice,
@@ -27725,7 +29399,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 +29550,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 +29714,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 +29800,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 +29984,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 +30239,7 @@ module.exports = class bitso extends Exchange {
'symbol': symbol,
'type': orderType,
'timeInForce': undefined,
+ 'postOnly': undefined,
'side': side,
'price': price,
'stopPrice': undefined,
@@ -28750,13 +30427,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 +30653,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 +31136,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 +31202,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 +31693,7 @@ module.exports = class bitstamp extends Exchange {
'symbol': symbol,
'type': undefined,
'timeInForce': undefined,
+ 'postOnly': undefined,
'side': side,
'price': price,
'stopPrice': undefined,
@@ -30357,7 +32036,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 +32337,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 +32363,7 @@ module.exports = class bittrex extends Exchange {
'CORS': false,
'cancelAllOrders': true,
'cancelOrder': true,
+ 'createDepositAddress': true,
'createMarketOrder': true,
'createOrder': true,
'fetchBalance': true,
@@ -30798,10 +32478,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 +33099,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 +33331,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 +33401,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 +33411,7 @@ module.exports = class bittrex extends Exchange {
'symbol': symbol,
'type': type,
'timeInForce': timeInForce,
+ 'postOnly': postOnly,
'side': direction,
'price': limit,
'stopPrice': undefined,
@@ -31852,6 +33549,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 +33590,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 +33704,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 +33770,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 +33994,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 +34562,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 +34591,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 +34672,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 +34716,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 +34765,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 +34826,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 +34887,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 +34989,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 +35002,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 +35019,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 +35304,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 +35982,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 +36086,7 @@ module.exports = class bitz extends Exchange {
'symbol': symbol,
'type': 'limit',
'timeInForce': undefined,
+ 'postOnly': undefined,
'side': side,
'price': price,
'stopPrice': undefined,
@@ -34481,7 +36256,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 +36592,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 +36830,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 +37495,7 @@ module.exports = class bleutrade extends Exchange {
'symbol': symbol,
'type': 'limit',
'timeInForce': undefined,
+ 'postOnly': undefined,
'side': side,
'price': price,
'stopPrice': undefined,
@@ -35870,7 +37646,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 +38109,7 @@ module.exports = class braziliex extends Exchange {
'symbol': symbol,
'type': 'limit',
'timeInForce': undefined,
+ 'postOnly': undefined,
'side': side,
'price': price,
'stopPrice': undefined,
@@ -36513,7 +38290,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 +38641,7 @@ module.exports = class btcalpha extends Exchange {
'symbol': symbol,
'type': 'limit',
'timeInForce': undefined,
+ 'postOnly': undefined,
'side': side,
'price': price,
'stopPrice': undefined,
@@ -37017,7 +38795,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 +39104,7 @@ module.exports = class btcbox extends Exchange {
'side': side,
'type': undefined,
'timeInForce': undefined,
+ 'postOnly': undefined,
'status': status,
'symbol': symbol,
'price': price,
@@ -37444,7 +39223,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 +40091,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 +40102,7 @@ module.exports = class btcmarkets extends Exchange {
'symbol': symbol,
'type': type,
'timeInForce': timeInForce,
+ 'postOnly': postOnly,
'side': side,
'price': price,
'stopPrice': stopPrice,
@@ -38501,7 +40282,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 +40620,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 +40637,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 +40678,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 +40956,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 +41007,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 +41547,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 +41615,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 +41833,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 +42597,7 @@ module.exports = class bw extends Exchange {
'symbol': symbol,
'type': 'limit',
'timeInForce': undefined,
+ 'postOnly': undefined,
'side': side,
'price': price,
'stopPrice': undefined,
@@ -40795,7 +42614,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 +42649,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 +43041,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 +43061,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 +43104,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 +43117,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 +43325,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 +43333,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 +43368,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 +43386,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 +43395,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 +43406,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 +43488,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 +43566,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 +43614,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 +43712,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 +43724,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 +43879,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 +43933,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 +43956,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 +44197,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 +44208,7 @@ module.exports = class bybit extends Exchange {
'symbol': symbol,
'type': type,
'timeInForce': timeInForce,
+ 'postOnly': postOnly,
'side': side,
'price': price,
'stopPrice': stopPrice,
@@ -42417,7 +44225,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 +44239,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 +44247,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 +44360,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 +44372,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 +44380,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 +44474,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 +44490,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 +44549,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 +44563,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 +44571,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 +44580,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 +44622,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 +44633,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 +44799,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 +44816,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 +44906,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 +44978,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 +45049,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 +45117,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 +45221,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 +45285,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 +45573,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 +45868,7 @@ module.exports = class bytetrade extends Exchange {
'symbol': symbol,
'type': type,
'timeInForce': undefined,
+ 'postOnly': undefined,
'side': side,
'price': price,
'stopPrice': undefined,
@@ -44053,7 +45886,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 +46070,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 +46088,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 +46108,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 +46128,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 +46148,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 +46249,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 +46355,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 +46375,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 +46398,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 +46482,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 +46508,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 +46718,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 +47432,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 +47638,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 +47674,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 +48008,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 +48103,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 +48137,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 +48263,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 +48317,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 +48852,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 +49327,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 +49338,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 +49355,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 +49388,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 +49736,7 @@ module.exports = class coinbasepro extends Exchange {
}
async fetchAccounts (params = {}) {
+ await this.loadMarkets ();
const response = await this.privateGetAccounts (params);
//
// [
@@ -48030,12 +49915,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 +49937,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 +49965,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 +49981,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 +50008,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 +50087,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 +50138,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 +50152,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 +50169,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 +50198,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 +50212,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 +50402,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 +50490,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 +50501,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 +50613,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';
// ---------------------------------------------------------------------------
@@ -48792,6 +50813,7 @@ module.exports = class coincheck extends Exchange {
'side': side,
'type': undefined,
'timeInForce': undefined,
+ 'postOnly': undefined,
'status': status,
'symbol': symbol,
'price': price,
@@ -49024,7 +51046,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 +51203,7 @@ module.exports = class coinegg extends Exchange {
},
'commonCurrencies': {
'JBC': 'JubaoCoin',
+ 'SBTC': 'Super Bitcoin',
},
});
}
@@ -49394,6 +51417,7 @@ module.exports = class coinegg extends Exchange {
'symbol': symbol,
'type': type,
'timeInForce': undefined,
+ 'postOnly': undefined,
'side': side,
'price': price,
'stopPrice': undefined,
@@ -49541,7 +51565,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 +51660,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 +52069,7 @@ module.exports = class coinex extends Exchange {
'symbol': symbol,
'type': type,
'timeInForce': undefined,
+ 'postOnly': undefined,
'side': side,
'price': price,
'stopPrice': undefined,
@@ -50106,7 +52133,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 +52330,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 +52339,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 +52362,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 +52420,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 +52485,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 +52522,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 +52742,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 +52845,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 +52855,7 @@ module.exports = class coinfalcon extends Exchange {
'symbol': symbol,
'type': type,
'timeInForce': undefined,
+ 'postOnly': postOnly,
'side': side,
'price': price,
'stopPrice': undefined,
@@ -50945,7 +52978,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 +53008,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 +53071,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 +53204,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 +53412,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 +53461,7 @@ module.exports = class coinfloor extends Exchange {
'symbol': symbol,
'type': 'limit',
'timeInForce': undefined,
+ 'postOnly': undefined,
'side': side,
'price': price,
'stopPrice': undefined,
@@ -51443,7 +53477,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 +53531,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 +53881,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 +54034,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 +54230,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 +54762,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 +54874,7 @@ module.exports = class coinmate extends Exchange {
'symbol': symbol,
'type': type,
'timeInForce': undefined,
+ 'postOnly': undefined,
'side': side,
'price': price,
'stopPrice': stopPrice,
@@ -52955,7 +54992,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 +55368,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 +55513,7 @@ module.exports = class coinone extends Exchange {
'symbol': symbol,
'type': 'limit',
'timeInForce': undefined,
+ 'postOnly': undefined,
'side': side,
'price': price,
'stopPrice': undefined,
@@ -53525,7 +55563,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 +55598,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 +55676,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 +55749,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 +55934,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 +55965,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 +56101,7 @@ module.exports = class crex24 extends Exchange {
'GHOST': 'GHOSTPRISM',
'IQ': 'IQ.Cash',
'PUT': 'PutinCoin',
+ 'SBTC': 'SBTCT', // SiamBitcoin
'UNI': 'Universe',
'YOYO': 'YOYOW',
},
@@ -54036,6 +56127,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 +56727,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 +57277,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 +58196,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 +58257,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 +58265,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 +58300,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 +58398,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 +60664,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 +60897,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 +60982,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 +60994,7 @@ module.exports = class deribit extends Exchange {
'symbol': market['symbol'],
'type': type,
'timeInForce': timeInForce,
+ 'postOnly': postOnly,
'side': side,
'price': price,
'stopPrice': stopPrice,
@@ -57500,13 +61079,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 +61154,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 +61519,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 +61558,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 +61672,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 +62177,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 +62223,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 +62669,7 @@ module.exports = class digifinex extends Exchange {
'symbol': symbol,
'type': type,
'timeInForce': undefined,
+ 'postOnly': undefined,
'side': side,
'price': price,
'stopPrice': undefined,
@@ -59380,7 +62960,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 +63203,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 +63859,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 +64046,7 @@ module.exports = class dsx extends Exchange {
'lastTradeTimestamp': lastTradeTimestamp,
'type': orderType,
'timeInForce': undefined,
+ 'postOnly': undefined,
'side': side,
'price': price,
'stopPrice': undefined,
@@ -60898,7 +64479,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 +66637,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 +66839,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 +66849,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 +67174,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 +67879,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 +68495,7 @@ module.exports = class exmo extends Exchange {
'symbol': symbol,
'type': 'limit',
'timeInForce': undefined,
+ 'postOnly': undefined,
'side': side,
'price': price,
'stopPrice': undefined,
@@ -63480,12 +68614,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 +68656,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 +68782,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 +69111,7 @@ module.exports = class exx extends Exchange {
'symbol': symbol,
'type': 'limit',
'timeInForce': undefined,
+ 'postOnly': undefined,
'side': order['type'],
'price': price,
'stopPrice': undefined,
@@ -64024,7 +69173,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 +69248,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 +69843,7 @@ module.exports = class fcoin extends Exchange {
'symbol': symbol,
'type': orderType,
'timeInForce': undefined,
+ 'postOnly': undefined,
'side': side,
'price': price,
'stopPrice': undefined,
@@ -64843,7 +69993,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 +70019,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 +70268,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 +70305,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 +70570,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 +70587,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 +70672,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 +70685,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 +70711,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 +70742,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 +70757,8 @@ module.exports = class ftx extends Exchange {
// options
'options/requests/{request_id}',
'options/quotes/{quote_id}',
+ // staking
+ 'staking/unstake_requests/{request_id}',
],
},
},
@@ -65618,6 +70793,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 +70802,18 @@ 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}
+ '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 +70943,7 @@ module.exports = class ftx extends Exchange {
'amount': sizeIncrement,
'price': priceIncrement,
};
- const entry = {
+ result.push ({
'id': id,
'symbol': symbol,
'base': base,
@@ -65788,8 +70970,7 @@ module.exports = class ftx extends Exchange {
},
},
'info': market,
- };
- result.push (entry);
+ });
}
return result;
}
@@ -66088,22 +71269,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 +71619,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 +71630,7 @@ module.exports = class ftx extends Exchange {
'symbol': symbol,
'type': type,
'timeInForce': undefined,
+ 'postOnly': postOnly,
'side': side,
'price': price,
'stopPrice': stopPrice,
@@ -66568,12 +71768,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 +71839,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 +71872,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 +72042,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 +72232,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 +72253,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 +72273,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 +72311,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 +72338,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 +72395,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 +72565,7 @@ module.exports = class gateio extends Exchange {
'BOX': 'DefiBox',
'BTCBEAR': 'BEAR',
'BTCBULL': 'BULL',
+ 'SBTC': 'Super Bitcoin',
'TNC': 'Trinity Network Credit',
},
});
@@ -67874,6 +73089,7 @@ module.exports = class gateio extends Exchange {
'symbol': symbol,
'type': 'limit',
'timeInForce': undefined,
+ 'postOnly': undefined,
'side': side,
'price': price,
'stopPrice': undefined,
@@ -67914,7 +73130,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 +73153,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 +73186,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 +73200,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 +73282,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 +73304,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 +73327,7 @@ module.exports = class gateio extends Exchange {
'type': type,
'timestamp': timestamp,
'datetime': this.iso8601 (timestamp),
- 'fee': undefined,
+ 'fee': fee,
};
}
@@ -68166,7 +73393,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 +74065,7 @@ module.exports = class gemini extends Exchange {
'symbol': symbol,
'type': type,
'timeInForce': undefined,
+ 'postOnly': undefined,
'side': side,
'price': price,
'stopPrice': undefined,
@@ -68901,7 +74129,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 +74306,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 +76499,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 +77612,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 +77666,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';
// ---------------------------------------------------------------------------
@@ -71251,6 +77829,7 @@ module.exports = class hitbtc extends Exchange {
'LNC': 'LinkerCoin',
'PLA': 'PlayChip',
'PNT': 'Penta',
+ 'SBTC': 'Super Bitcoin',
'TV': 'Tokenville',
'USD': 'USDT',
'XPNT': 'PNT',
@@ -71888,22 +78467,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 +78534,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 +78553,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 +78852,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 +79375,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 +79557,7 @@ module.exports = class hollaex extends Exchange {
'symbol': symbol,
'type': type,
'timeInForce': undefined,
+ 'postOnly': undefined,
'side': side,
'price': price,
'stopPrice': undefined,
@@ -73423,7 +80027,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 +80068,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 +80169,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 +80267,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 +80285,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 +80322,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 +80755,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 +81024,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 +81036,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 +81186,7 @@ module.exports = class huobipro extends Exchange {
'symbol': symbol,
'type': type,
'timeInForce': undefined,
+ 'postOnly': undefined,
'side': side,
'price': price,
'stopPrice': undefined,
@@ -74951,6 +81566,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 +81576,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 +81804,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 +81924,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 +82073,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 +82132,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 +82179,7 @@ module.exports = class idex extends Exchange {
'options': {
'defaultTimeInForce': 'gtc',
'defaultSelfTradePrevention': 'cn',
+ 'network': 'ETH', // also supports BSC
},
'exceptions': {
'INVALID_ORDER_QUANTITY': InvalidOrder,
@@ -76347,6 +82932,7 @@ module.exports = class idex extends Exchange {
'symbol': symbol,
'type': type,
'timeInForce': undefined,
+ 'postOnly': undefined,
'side': side,
'price': price,
'stopPrice': undefined,
@@ -76435,7 +83021,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 +83351,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 +83384,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 +83674,7 @@ module.exports = class independentreserve extends Exchange {
'symbol': symbol,
'type': orderType,
'timeInForce': undefined,
+ 'postOnly': undefined,
'side': side,
'price': price,
'stopPrice': undefined,
@@ -77193,10 +83782,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 +83894,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 +84296,7 @@ module.exports = class indodax extends Exchange {
'symbol': symbol,
'type': 'limit',
'timeInForce': undefined,
+ 'postOnly': undefined,
'side': side,
'price': price,
'stopPrice': undefined,
@@ -77720,7 +84313,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 +84360,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 +84404,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 +84515,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 +84786,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 +84855,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 +84945,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 +84983,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 +85047,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 +85060,7 @@ module.exports = class itbit extends Exchange {
'symbol': symbol,
'type': type,
'timeInForce': undefined,
+ 'postOnly': postOnly,
'side': side,
'price': price,
'stopPrice': undefined,
@@ -78490,7 +85086,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 +85111,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 +85123,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 +85170,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 +85192,7 @@ module.exports = class kraken extends Exchange {
'certified': true,
'pro': true,
'has': {
+ 'cancelAllOrders': true,
'cancelOrder': true,
'CORS': false,
'createDepositAddress': true,
@@ -78756,6 +85353,7 @@ module.exports = class kraken extends Exchange {
'AddOrder',
'AddExport',
'Balance',
+ 'CancelAll',
'CancelOrder',
'ClosedOrders',
'DepositAddresses',
@@ -78783,6 +85381,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 +85525,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 +86000,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 +86024,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 +86052,7 @@ module.exports = class kraken extends Exchange {
}
return {
'id': id,
- 'order': order,
+ 'order': orderId,
'info': trade,
'timestamp': timestamp,
'datetime': this.iso8601 (timestamp),
@@ -79512,6 +86115,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 +86140,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 +86346,7 @@ module.exports = class kraken extends Exchange {
'symbol': symbol,
'type': type,
'timeInForce': undefined,
+ 'postOnly': undefined,
'side': side,
'price': price,
'stopPrice': stopPrice,
@@ -79776,8 +86413,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 +86425,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 +86574,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 +86750,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 +86793,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 +86884,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 +86997,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 +87021,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 +87044,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 +87099,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 +87136,7 @@ module.exports = class kucoin extends Exchange {
'withdrawals',
'withdrawals/quotas',
'orders',
+ 'order/client-order/{clientOid}',
'orders/{orderId}',
'limit/orders',
'fills',
@@ -80440,6 +87152,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 +87165,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 +87272,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 +87720,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 +87740,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 +87759,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 +87836,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 +87910,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 +88013,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 +88110,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 +88446,7 @@ module.exports = class kucoin extends Exchange {
// "status": "SUCCESS",
// "createdAt": 1544178843000,
// "updatedAt": 1544178891000
+ // "remark":"foobar"
// }
//
// fetchWithdrawals
@@ -81681,6 +88463,7 @@ module.exports = class kucoin extends Exchange {
// "status": "FAILURE",
// "createdAt": 1546503758000,
// "updatedAt": 1546504603000
+ // "remark":"foobar"
// }
//
const currencyId = this.safeString (transaction, 'currency');
@@ -81731,20 +88514,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 +88581,7 @@ module.exports = class kucoin extends Exchange {
// "status": "SUCCESS",
// "createdAt": 1544178843000,
// "updatedAt": 1544178891000
+ // "remark":"foobar"
// },
// //--------------------------------------------------
// // version 1 (historical) deposit response structure
@@ -81921,7 +88711,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 +88854,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 +88877,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 +88922,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 +89045,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 +89107,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 +89138,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 +89468,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 +90005,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 +90117,7 @@ module.exports = class latoken extends Exchange {
'symbol': symbol,
'type': type,
'timeInForce': undefined,
+ 'postOnly': undefined,
'side': side,
'price': price,
'stopPrice': undefined,
@@ -83354,7 +90152,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 +90268,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 +90358,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 +90719,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 +90847,7 @@ module.exports = class lbank extends Exchange {
'symbol': symbol,
'type': type,
'timeInForce': undefined,
+ 'postOnly': undefined,
'side': side,
'price': price,
'stopPrice': undefined,
@@ -84260,7 +91059,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 +91248,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 +91786,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 +91927,7 @@ module.exports = class liquid extends Exchange {
'lastTradeTimestamp': lastTradeTimestamp,
'type': type,
'timeInForce': undefined,
+ 'postOnly': undefined,
'status': status,
'symbol': symbol,
'side': side,
@@ -85396,940 +92197,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 +92238,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 +92251,11 @@ module.exports = class luno extends Exchange {
],
},
'api': {
+ 'exchange': {
+ 'get': [
+ 'markets',
+ ],
+ },
'public': {
'get': [
'orderbook',
@@ -86429,16 +92306,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 +92349,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 +92393,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 +92412,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 +92508,7 @@ module.exports = class luno extends Exchange {
'symbol': symbol,
'type': undefined,
'timeInForce': undefined,
+ 'postOnly': undefined,
'side': side,
'price': price,
'stopPrice': undefined,
@@ -86757,7 +92689,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);
@@ -86961,7 +92893,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 +92917,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 +93419,7 @@ module.exports = class lykke extends Exchange {
'symbol': symbol,
'type': undefined,
'timeInForce': undefined,
+ 'postOnly': undefined,
'side': side,
'price': price,
'stopPrice': undefined,
@@ -87600,7 +93533,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 +93557,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 +93598,7 @@ module.exports = class mercado extends Exchange {
'api': {
'public': {
'get': [
+ 'coins',
'{coin}/orderbook/', // last slash critical
'{coin}/ticker/',
'{coin}/trades/',
@@ -87693,23 +93629,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 +93758,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 +93795,7 @@ module.exports = class mercado extends Exchange {
'price': price,
'amount': amount,
'cost': cost,
- 'fee': undefined,
+ 'fee': fee,
};
}
@@ -87952,6 +93963,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 +93978,7 @@ module.exports = class mercado extends Exchange {
'symbol': market['symbol'],
'type': 'limit',
'timeInForce': undefined,
+ 'postOnly': undefined,
'side': side,
'price': price,
'stopPrice': undefined,
@@ -87972,7 +93989,7 @@ module.exports = class mercado extends Exchange {
'remaining': remaining,
'status': status,
'fee': fee,
- 'trades': undefined, // todo parse trades (operations)
+ 'trades': trades,
};
}
@@ -88004,17 +94021,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 +94093,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 +94173,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 +94404,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 +97295,7 @@ module.exports = class novadax extends Exchange {
'symbol': symbol,
'type': type,
'timeInForce': undefined,
+ 'postOnly': undefined,
'side': side,
'price': price,
'stopPrice': undefined,
@@ -89532,7 +97612,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 +98127,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 +98188,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 +98298,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 +98335,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 +98446,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 +98537,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 +98584,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 +98871,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 +98900,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 +98953,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 +99023,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 +99323,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 +100059,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 +100305,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 +100512,7 @@ module.exports = class okex extends Exchange {
'symbol': symbol,
'type': type,
'timeInForce': undefined,
+ 'postOnly': undefined,
'side': side,
'price': price,
'stopPrice': stopPrice,
@@ -92438,14 +100529,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 +100604,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 +100616,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 +100946,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 +100958,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 +100999,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 +101173,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 +101562,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 +101977,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 +102242,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 +102347,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 +102974,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 +103067,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 +103113,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 +103152,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 +103657,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 +103892,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 +103905,7 @@ module.exports = class phemex extends Exchange {
'symbol': symbol,
'type': type,
'timeInForce': timeInForce,
+ 'postOnly': postOnly,
'side': side,
'price': price,
'stopPrice': stopPrice,
@@ -95861,6 +103978,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 +103989,7 @@ module.exports = class phemex extends Exchange {
'symbol': symbol,
'type': type,
'timeInForce': timeInForce,
+ 'postOnly': postOnly,
'side': side,
'price': price,
'stopPrice': stopPrice,
@@ -95926,8 +104045,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 +104058,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 +104161,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 +104201,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 +104235,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 +104257,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 +104281,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 +104343,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 +104578,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 +104765,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 +104972,6 @@ module.exports = class poloniex extends Exchange {
'Error pulling ': ExchangeError, // {"error":"Error pulling order book"}
},
},
- 'orders': {}, // orders cache / emulation
});
}
@@ -97570,6 +105690,7 @@ module.exports = class poloniex extends Exchange {
'symbol': symbol,
'type': type,
'timeInForce': undefined,
+ 'postOnly': undefined,
'side': side,
'price': price,
'stopPrice': undefined,
@@ -98131,7 +106252,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 +106376,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 +106398,7 @@ module.exports = class probit extends Exchange {
'BTCBEAR': 'BEAR',
'BTCBULL': 'BULL',
'CBC': 'CryptoBharatCoin',
+ 'HBC': 'Hybrid Bank Cash',
'UNI': 'UNICORN Token',
},
});
@@ -98433,7 +106556,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 +106997,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 +107097,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 +107290,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 +107538,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 +108456,7 @@ module.exports = class qtrade extends Exchange {
'symbol': symbol,
'type': orderType,
'timeInForce': undefined,
+ 'postOnly': undefined,
'side': side,
'price': price,
'stopPrice': undefined,
@@ -100946,7 +109081,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 +109515,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 +109625,7 @@ module.exports = class rightbtc extends Exchange {
'symbol': symbol,
'type': type,
'timeInForce': undefined,
+ 'postOnly': undefined,
'side': side,
'price': price,
'stopPrice': undefined,
@@ -101506,7 +109642,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 +109680,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 +109717,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 +109756,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 +109841,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 +110674,7 @@ module.exports = class ripio extends Exchange {
'symbol': symbol,
'type': type,
'timeInForce': undefined,
+ 'postOnly': undefined,
'side': side,
'price': price,
'stopPrice': stopPrice,
@@ -102652,7 +110789,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 +111056,7 @@ module.exports = class southxchange extends Exchange {
'symbol': symbol,
'type': type,
'timeInForce': undefined,
+ 'postOnly': undefined,
'side': side,
'price': price,
'stopPrice': undefined,
@@ -103351,7 +111489,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 +115017,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 +121006,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 +121030,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 +121407,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 +121842,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 +121852,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 +122034,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 +122974,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 +123180,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 +123422,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 +123543,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 +123569,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 +123716,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 +123818,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 +123885,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 +124667,7 @@ module.exports = {
}
};
-},{}],139:[function(require,module,exports){
+},{}],142:[function(require,module,exports){
'use strict';
var utils = exports;
@@ -116745,7 +124883,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 +124999,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 +125040,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 +126608,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 +126835,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 +126850,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 +126873,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 +127139,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 +127177,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 +127196,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 +127269,7 @@ module.exports = {
}
};
-},{"../utils":157}],150:[function(require,module,exports){
+},{"../utils":160}],153:[function(require,module,exports){
var _ = require('../utils')._;
module.exports = {
@@ -119164,7 +127302,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 +127454,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 +127645,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 +128901,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 +129050,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 +129230,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 +129253,7 @@ module.exports = {
}
};
-},{"./pkcs1":155}],157:[function(require,module,exports){
+},{"./pkcs1":158}],160:[function(require,module,exports){
/*
* Utils functions
*
@@ -121215,7 +129353,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 +129373,7 @@ module.exports = {
RFC3986: 'RFC3986'
};
-},{}],159:[function(require,module,exports){
+},{}],162:[function(require,module,exports){
'use strict';
var stringify = require('./stringify');
@@ -121248,7 +129386,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 +129630,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 +129901,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 +130133,7 @@ module.exports = {
merge: merge
};
-},{}],163:[function(require,module,exports){
+},{}],166:[function(require,module,exports){
'use strict';
// ---------------------------------------------------------------------------
@@ -122183,6 +130321,8 @@ module.exports = class stex extends Exchange {
'BITS': 'Bitcoinus',
'BITSW': 'BITS',
'BHD': 'Bithold',
+ 'BTH': 'Bithereum',
+ 'SBTC': 'SBTCT', // SiamBitcoin
},
'options': {
'parseOrderToPrecision': false,
@@ -122924,6 +131064,7 @@ module.exports = class stex extends Exchange {
'symbol': symbol,
'type': type,
'timeInForce': undefined,
+ 'postOnly': undefined,
'side': side,
'price': price,
'stopPrice': stopPrice,
@@ -123220,7 +131361,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 +131940,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 +131974,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 +132942,7 @@ module.exports = class therock extends Exchange {
'symbol': symbol,
'type': type,
'timeInForce': undefined,
+ 'postOnly': undefined,
'side': side,
'price': price,
'stopPrice': stopPrice,
@@ -124830,7 +132972,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 +133017,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 +133056,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 +133208,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 +133633,7 @@ module.exports = class tidebit extends Exchange {
'symbol': symbol,
'type': type,
'timeInForce': undefined,
+ 'postOnly': undefined,
'side': side,
'price': price,
'stopPrice': undefined,
@@ -125610,7 +133753,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 +134336,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 +134538,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 +135001,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,
+ 'type': 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 +135023,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 +135726,7 @@ module.exports = class timex extends Exchange {
'symbol': symbol,
'type': type,
'timeInForce': undefined,
+ 'postOnly': undefined,
'side': side,
'price': price,
'stopPrice': undefined,
@@ -127631,7 +135779,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 +135797,6 @@ module.exports = class upbit extends Exchange {
'countries': [ 'KR' ],
'version': 'v1',
'rateLimit': 1000,
- 'certified': true,
'pro': true,
// new metainfo interface
'has': {
@@ -127855,7 +136002,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 +136985,7 @@ module.exports = class upbit extends Exchange {
'symbol': market['symbol'],
'type': type,
'timeInForce': undefined,
+ 'postOnly': undefined,
'side': side,
'price': price,
'stopPrice': undefined,
@@ -129162,7 +137310,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 +137515,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 +137549,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 +138608,7 @@ module.exports = class vcc extends Exchange {
'symbol': symbol,
'type': type,
'timeInForce': undefined,
+ 'postOnly': undefined,
'side': side,
'price': price,
'stopPrice': stopPrice,
@@ -130741,7 +138890,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 +139949,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 +140162,7 @@ module.exports = class wavesexchange extends Exchange {
'symbol': symbol,
'type': type,
'timeInForce': undefined,
+ 'postOnly': undefined,
'side': side,
'price': price,
'stopPrice': undefined,
@@ -132409,7 +140559,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 +141214,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 +141586,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 +141627,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 +142551,7 @@ module.exports = class xena extends Exchange {
'symbol': symbol,
'type': type,
'timeInForce': undefined,
+ 'postOnly': undefined,
'side': side,
'price': price,
'stopPrice': undefined,
@@ -134456,14 +142611,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 +142656,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 +142711,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 +143308,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 +143444,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 +143461,7 @@ module.exports = class yobit extends Exchange {
'RCN': 'RCoin',
'REP': 'Republicoin',
'RUR': 'RUB',
+ 'SBTC': 'Super Bitcoin',
'TTC': 'TittieCoin',
'UNI': 'Universe',
'UST': 'Uservice',
@@ -135751,6 +143908,7 @@ module.exports = class yobit extends Exchange {
'lastTradeTimestamp': undefined,
'type': type,
'timeInForce': undefined,
+ 'postOnly': undefined,
'side': side,
'price': price,
'stopPrice': undefined,
@@ -135795,7 +143953,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 +144041,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 +144132,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 +144492,7 @@ module.exports = class zaif extends Exchange {
'symbol': symbol,
'type': 'limit',
'timeInForce': undefined,
+ 'postOnly': undefined,
'side': side,
'price': price,
'stopPrice': undefined,
@@ -136482,13 +144623,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 +144648,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 +144679,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 +144737,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 +144769,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 +144901,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 +145000,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 +145051,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 +145146,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 +145208,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 +145234,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 +145278,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 +145316,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 +145341,7 @@ module.exports = class zb extends Exchange {
'symbol': symbol,
'type': type,
'timeInForce': undefined,
+ 'postOnly': undefined,
'side': side,
'price': price,
'stopPrice': undefined,
@@ -137062,7 +145351,7 @@ module.exports = class zb extends Exchange {
'filled': filled,
'remaining': remaining,
'status': status,
- 'fee': undefined,
+ 'fee': fee,
'trades': undefined,
};
}
@@ -137077,8 +145366,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 +145636,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 +145660,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 +146154,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 +146270,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 +146684,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 +147296,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 +149012,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 +149078,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 +149289,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 +149400,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 +149704,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 +149737,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 +149823,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 +149848,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 +149871,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 +149985,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 +150038,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 +150108,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 +150169,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 +152045,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 +152392,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 +153950,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 +154295,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 +154329,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 +155551,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 +155600,7 @@ function ZStream() {
module.exports = ZStream;
-},{}],206:[function(require,module,exports){
+},{}],209:[function(require,module,exports){
(function (process){
'use strict';
@@ -147124,7 +155647,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 +155833,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 +156370,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 +156456,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 +156543,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 +156677,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 +156725,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 +157735,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 +157950,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 +158617,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 +158692,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 +158765,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 +158780,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 +158850,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 +158979,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 +159061,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 +159134,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 +159444,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 +159630,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 +159903,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 +159932,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 +160666,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 +160684,7 @@ module.exports = {
}
};
-},{}],235:[function(require,module,exports){
+},{}],238:[function(require,module,exports){
(function (global){
/**
@@ -152232,16 +160755,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 +161354,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..e43d18285 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 () {
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..c4c20f0da 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
@@ -197,6 +197,7 @@ module.exports = class coincheck 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/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..8030b8004 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,18 @@ 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}
+ '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 +370,7 @@ module.exports = class ftx extends Exchange {
'amount': sizeIncrement,
'price': priceIncrement,
};
- const entry = {
+ result.push ({
'id': id,
'symbol': symbol,
'base': base,
@@ -365,8 +397,7 @@ module.exports = class ftx extends Exchange {
},
},
'info': market,
- };
- result.push (entry);
+ });
}
return result;
}
@@ -665,22 +696,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 +1046,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 +1057,7 @@ module.exports = class ftx extends Exchange {
'symbol': symbol,
'type': type,
'timeInForce': undefined,
+ 'postOnly': postOnly,
'side': side,
'price': price,
'stopPrice': stopPrice,
@@ -1145,12 +1195,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 +1266,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 +1299,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 +1469,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 +1659,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 +1680,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 +1700,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 +1738,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 +1765,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..29b5bd6ae 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
@@ -160,6 +160,7 @@ module.exports = class hitbtc extends Exchange {
'LNC': 'LinkerCoin',
'PLA': 'PlayChip',
'PNT': 'Penta',
+ 'SBTC': 'Super Bitcoin',
'TV': 'Tokenville',
'USD': 'USDT',
'XPNT': 'PNT',
@@ -797,22 +798,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 +865,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 +884,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..1b8ef5921 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,
@@ -855,6 +856,7 @@ module.exports = class idex extends Exchange {
'symbol': symbol,
'type': type,
'timeInForce': undefined,
+ 'postOnly': undefined,
'side': side,
'price': price,
'stopPrice': undefined,
@@ -943,7 +945,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 +1275,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..41192a486 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);
@@ -629,7 +693,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..8221cb234 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,
+ 'type': 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..4b75d2695 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.67",
+ "_id": "ccxt@1.42.67",
"_inBundle": false,
- "_integrity": "sha512-t2XalR99Uv4YdRMyBk/sCKwynA7voPl3TRF/IfzICQf8vr7EyGh3CTuV9o3TYAHSNliotitk3SNC8cp1e/ULjw==",
+ "_integrity": "sha512-AOq5kwJpPVHHQC+V1Nh/Ab7/sP0UGfjZ49pF2kP/lW68gtP6XTFA4J/O76UYFHbfzBgwQJHzH3IkMIC1PG96Cw==",
"_location": "/ccxt",
"_phantomChildren": {},
"_requested": {
- "type": "tag",
+ "type": "version",
"registry": true,
- "raw": "ccxt",
+ "raw": "ccxt@1.42.67",
"name": "ccxt",
"escapedName": "ccxt",
- "rawSpec": "",
+ "rawSpec": "1.42.67",
"saveSpec": null,
- "fetchSpec": "latest"
+ "fetchSpec": "1.42.67"
},
"_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.67.tgz",
+ "_shasum": "3032fa256d75891af2834f0c5777012ab155cf6f",
+ "_spec": "ccxt@1.42.67",
+ "_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.67"
}
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..c6f795053 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.67",
+ "resolved": "https://registry.npmjs.org/ccxt/-/ccxt-1.42.67.tgz",
+ "integrity": "sha512-AOq5kwJpPVHHQC+V1Nh/Ab7/sP0UGfjZ49pF2kP/lW68gtP6XTFA4J/O76UYFHbfzBgwQJHzH3IkMIC1PG96Cw=="
}
}
}
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..41c26d98d 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
-[](https://travis-ci.com/ccxt/ccxt) [](https://npmjs.com/package/ccxt) [](https://pypi.python.org/pypi/ccxt) [](https://www.npmjs.com/package/ccxt) [](https://discord.gg/dhzSKYU) [](https://github.com/ccxt/ccxt/wiki/Exchange-Markets) [](https://opencollective.com/ccxt)
+[](https://travis-ci.com/ccxt/ccxt) [](https://npmjs.com/package/ccxt) [](https://pypi.python.org/pypi/ccxt) [](https://www.npmjs.com/package/ccxt) [](https://discord.gg/dhzSKYU) [](https://github.com/ccxt/ccxt/wiki/Exchange-Markets) [](https://opencollective.com/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
-[](https://ccxt.pro) **[A JavaScript / Python / PHP cryptocurrency exchange trading WebSocket API for professionals](https://ccxt.pro)**
+[](https://ccxt.pro)
## See Also
- [](https://quadency.com?utm_source=ccxt) **[Quadency](https://quadency.com?utm_source=ccxt)** — trading automation terminal for leading exchanges with streaming APIs + Python IDE.
- [](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).
+- [](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)!
+- [](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 |
-|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---------------|-----------------------------------------------------------------------------|:---:|:----------------------------------------------------------------------------------:|-----------------------------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------|
-| [](https://www.binance.com/?ref=10205187) | binance | [Binance](https://www.binance.com/?ref=10205187) | * | [API](https://binance-docs.github.io/apidocs/spot/en) | [](https://github.com/ccxt/ccxt/wiki/Certification) | [](https://ccxt.pro) |
-| [](https://www.bitfinex.com/?refcode=P61eYxFL) | bitfinex | [Bitfinex](https://www.bitfinex.com/?refcode=P61eYxFL) | 1 | [API](https://docs.bitfinex.com/v1/docs) | [](https://github.com/ccxt/ccxt/wiki/Certification) | [](https://ccxt.pro) |
-| [](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) | [](https://github.com/ccxt/ccxt/wiki/Certification) | [](https://ccxt.pro) |
-| [](https://bitvavo.com/?a=24F34952F7) | bitvavo | [Bitvavo](https://bitvavo.com/?a=24F34952F7) | 2 | [API](https://docs.bitvavo.com/) | [](https://github.com/ccxt/ccxt/wiki/Certification) | [](https://ccxt.pro) |
-| [](https://www.byte-trade.com) | bytetrade | [ByteTrade](https://www.byte-trade.com) | * | [API](https://docs.byte-trade.com/#description) | [](https://github.com/ccxt/ccxt/wiki/Certification) | |
-| [](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) | [](https://github.com/ccxt/ccxt/wiki/Certification) | [](https://ccxt.pro) |
-| [](https://eterbase.exchange/invite/1wjjh4Pe) | eterbase | [Eterbase](https://eterbase.exchange/invite/1wjjh4Pe) | 1 | [API](https://developers.eterbase.exchange) | [](https://github.com/ccxt/ccxt/wiki/Certification) | |
-| [](https://ftx.com/#a=1623029) | ftx | [FTX](https://ftx.com/#a=1623029) | * | [API](https://github.com/ftexchange/ftx) | [](https://github.com/ccxt/ccxt/wiki/Certification) | [](https://ccxt.pro) |
-| [](https://idex.io) | idex | [IDEX](https://idex.io) | 2 | [API](https://docs.idex.io/) | [](https://github.com/ccxt/ccxt/wiki/Certification) | [](https://ccxt.pro) |
-| [](https://www.kraken.com) | kraken | [Kraken](https://www.kraken.com) | 0 | [API](https://www.kraken.com/features/api) | [](https://github.com/ccxt/ccxt/wiki/Certification) | [](https://ccxt.pro) |
-| [](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) | [](https://github.com/ccxt/ccxt/wiki/Certification) | [](https://ccxt.pro) |
-| [](https://waves.exchange) | wavesexchange | [Waves.Exchange](https://waves.exchange) | * | [API](https://docs.waves.exchange) | [](https://github.com/ccxt/ccxt/wiki/Certification) | |
-| [](https://xena.exchange) | xena | [Xena Exchange](https://xena.exchange) | * | [API](https://support.xena.exchange/support/solutions/44000808700) | [](https://github.com/ccxt/ccxt/wiki/Certification) | |
+| logo | id | name | ver | doc | certified | pro |
+|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---------------|-----------------------------------------------------------------------------|:---:|:------------------------------------------------------------------:|-----------------------------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------|
+| [](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) | [](https://github.com/ccxt/ccxt/wiki/Certification) | |
+| [](https://www.binance.com/?ref=10205187) | binance | [Binance](https://www.binance.com/?ref=10205187) | * | [API](https://binance-docs.github.io/apidocs/spot/en) | [](https://github.com/ccxt/ccxt/wiki/Certification) | [](https://ccxt.pro) |
+| [](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) | [](https://github.com/ccxt/ccxt/wiki/Certification) | [](https://ccxt.pro) |
+| [](https://bitvavo.com/?a=24F34952F7) | bitvavo | [Bitvavo](https://bitvavo.com/?a=24F34952F7) | 2 | [API](https://docs.bitvavo.com/) | [](https://github.com/ccxt/ccxt/wiki/Certification) | [](https://ccxt.pro) |
+| [](https://www.byte-trade.com) | bytetrade | [ByteTrade](https://www.byte-trade.com) | * | [API](https://docs.byte-trade.com/#description) | [](https://github.com/ccxt/ccxt/wiki/Certification) | |
+| [](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) | [](https://github.com/ccxt/ccxt/wiki/Certification) | [](https://ccxt.pro) |
+| [](https://eterbase.exchange/invite/1wjjh4Pe) | eterbase | [Eterbase](https://eterbase.exchange/invite/1wjjh4Pe) | 1 | [API](https://developers.eterbase.exchange) | [](https://github.com/ccxt/ccxt/wiki/Certification) | |
+| [](https://ftx.com/#a=1623029) | ftx | [FTX](https://ftx.com/#a=1623029) | * | [API](https://github.com/ftexchange/ftx) | [](https://github.com/ccxt/ccxt/wiki/Certification) | [](https://ccxt.pro) |
+| [](https://www.gopax.co.kr) | gopax | [GOPAX](https://www.gopax.co.kr) | 1 | [API](https://gopax.github.io/API/index.en.html) | [](https://github.com/ccxt/ccxt/wiki/Certification) | [](https://ccxt.pro) |
+| [](https://idex.io) | idex | [IDEX](https://idex.io) | 2 | [API](https://docs.idex.io/) | [](https://github.com/ccxt/ccxt/wiki/Certification) | [](https://ccxt.pro) |
+| [](https://www.kraken.com) | kraken | [Kraken](https://www.kraken.com) | 0 | [API](https://www.kraken.com/features/api) | [](https://github.com/ccxt/ccxt/wiki/Certification) | [](https://ccxt.pro) |
+| [](https://waves.exchange) | wavesexchange | [Waves.Exchange](https://waves.exchange) | * | [API](https://docs.waves.exchange) | [](https://github.com/ccxt/ccxt/wiki/Certification) | |
+| [](https://xena.exchange) | xena | [Xena Exchange](https://xena.exchange) | * | [API](https://support.xena.exchange/support/solutions/44000808700) | [](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 |
|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|--------------------|-----------------------------------------------------------------------------------------|:---:|:-------------------------------------------------------------------------------------------:|-----------------------------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------|
+| [](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) | [](https://github.com/ccxt/ccxt/wiki/Certification) | |
| [](https://acx.io) | acx | [ACX](https://acx.io) | 2 | [API](https://acx.io/documents/api_v2) | | |
| [](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) | | |
-| [](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) | | |
| [](https://bequant.io) | bequant | [Bequant](https://bequant.io) | 2 | [API](https://api.bequant.io/) | | [](https://ccxt.pro) |
| [](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/) | | |
| [](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
| [](https://bitbank.cc/) | bitbank | [bitbank](https://bitbank.cc/) | 1 | [API](https://docs.bitbank.cc/) | | |
| [](https://auth.bitbay.net/ref/jHlbB4mIkdS1) | bitbay | [BitBay](https://auth.bitbay.net/ref/jHlbB4mIkdS1) | * | [API](https://bitbay.net/public-api) | | |
| [](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) | | [](https://ccxt.pro) |
-| [](https://www.bitfinex.com/?refcode=P61eYxFL) | bitfinex | [Bitfinex](https://www.bitfinex.com/?refcode=P61eYxFL) | 1 | [API](https://docs.bitfinex.com/v1/docs) | [](https://github.com/ccxt/ccxt/wiki/Certification) | [](https://ccxt.pro) |
+| [](https://www.bitfinex.com/?refcode=P61eYxFL) | bitfinex | [Bitfinex](https://www.bitfinex.com/?refcode=P61eYxFL) | 1 | [API](https://docs.bitfinex.com/v1/docs) | | [](https://ccxt.pro) |
| [](https://www.bitfinex.com/?refcode=P61eYxFL) | bitfinex2 | [Bitfinex](https://www.bitfinex.com/?refcode=P61eYxFL) | 2 | [API](https://docs.bitfinex.com/v2/docs/) | | |
| [](https://bitflyer.com) | bitflyer | [bitFlyer](https://bitflyer.com) | 1 | [API](https://lightning.bitflyer.com/docs?lang=en) | | |
| [](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) | | |
| [](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) | | |
| [](https://www.bithumb.com) | bithumb | [Bithumb](https://www.bithumb.com) | * | [API](https://apidocs.bithumb.com) | | |
| [](https://www.bitkk.com) | bitkk | [bitkk](https://www.bitkk.com) | 1 | [API](https://www.bitkk.com/i/developer) | | |
-| [](http://www.bitmart.com/?r=rQCFLh) | bitmart | [BitMart](http://www.bitmart.com/?r=rQCFLh) | 1 | [API](https://github.com/bitmartexchange/bitmart-official-api-docs) | | |
+| [](http://www.bitmart.com/?r=rQCFLh) | bitmart | [BitMart](http://www.bitmart.com/?r=rQCFLh) | 1 | [API](https://developer-pro.bitmart.com/) | | |
| [](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) | | |
| [](https://www.bitmex.com/register/upZpOX) | bitmex | [BitMEX](https://www.bitmex.com/register/upZpOX) | 1 | [API](https://www.bitmex.com/app/apiOverview) | | [](https://ccxt.pro) |
| [](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
| [](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) | | |
| [](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/) | | |
| [](https://www.byte-trade.com) | bytetrade | [ByteTrade](https://www.byte-trade.com) | * | [API](https://docs.byte-trade.com/#description) | [](https://github.com/ccxt/ccxt/wiki/Certification) | |
+| [](https://cdax.io/invite?invite_code=esc74) | cdax | [CDAX](https://cdax.io/invite?invite_code=esc74) | 1 | [API](https://github.com/cloudapidoc/API_Docs) | | |
| [](https://cex.io/r/0/up105393824/0/) | cex | [CEX.IO](https://cex.io/r/0/up105393824/0/) | * | [API](https://cex.io/cex-api) | | |
| [](https://chilebit.net) | chilebit | [ChileBit](https://chilebit.net) | 1 | [API](https://blinktrade.com/docs) | | |
| [](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
| [](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) | | |
| [](https://crex24.com/?refid=slxsjsjtil8xexl9hksr) | crex24 | [CREX24](https://crex24.com/?refid=slxsjsjtil8xexl9hksr) | 2 | [API](https://docs.crex24.com/trade-api/v2) | | |
| [](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) | [](https://github.com/ccxt/ccxt/wiki/Certification) | [](https://ccxt.pro) |
+| [](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) | | |
| [](https://www.deribit.com/reg-1189.4038) | deribit | [Deribit](https://www.deribit.com/reg-1189.4038) | 2 | [API](https://docs.deribit.com/v2) | | |
| [](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) | | |
| [](https://dsxglobal.com) | dsx | [DSX](https://dsxglobal.com) | 3 | [API](https://dsxglobal.com/developers/publicApi) | | |
+| [](https://equos.io?referredByCode=zpa8kij4ouvBFup3) | equos | [EQUOS](https://equos.io?referredByCode=zpa8kij4ouvBFup3) | * | [API](https://developer.equos.io) | | |
| [](https://eterbase.exchange/invite/1wjjh4Pe) | eterbase | [Eterbase](https://eterbase.exchange/invite/1wjjh4Pe) | 1 | [API](https://developers.eterbase.exchange) | [](https://github.com/ccxt/ccxt/wiki/Certification) | |
| [](https://exmo.me/?ref=131685) | exmo | [EXMO](https://exmo.me/?ref=131685) | 1.1 | [API](https://exmo.me/en/api_doc?ref=131685) | | |
| [](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
| [](https://ftx.com/#a=1623029) | ftx | [FTX](https://ftx.com/#a=1623029) | * | [API](https://github.com/ftexchange/ftx) | [](https://github.com/ccxt/ccxt/wiki/Certification) | [](https://ccxt.pro) |
| [](https://www.gate.io/signup/2436035) | gateio | [Gate.io](https://www.gate.io/signup/2436035) | 2 | [API](https://gate.io/api2) | | [](https://ccxt.pro) |
| [](https://gemini.com/) | gemini | [Gemini](https://gemini.com/) | 1 | [API](https://docs.gemini.com/rest-api) | | |
+| [](https://www.gopax.co.kr) | gopax | [GOPAX](https://www.gopax.co.kr) | 1 | [API](https://gopax.github.io/API/index.en.html) | [](https://github.com/ccxt/ccxt/wiki/Certification) | [](https://ccxt.pro) |
| [](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) | | |
| [](https://hitbtc.com/?ref_id=5a5d39a65d466) | hitbtc | [HitBTC](https://hitbtc.com/?ref_id=5a5d39a65d466) | 2 | [API](https://api.hitbtc.com) | | [](https://ccxt.pro) |
| [](https://pro.hollaex.com/signup?affiliation_code=QSWA6G) | hollaex | [HollaEx](https://pro.hollaex.com/signup?affiliation_code=QSWA6G) | 1 | [API](https://apidocs.hollaex.com) | | |
| [](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) | | [](https://ccxt.pro) |
| [](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/) | | [](https://ccxt.pro) |
-| [](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) | | [](https://ccxt.pro) |
| [](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) | | |
| [](https://idex.io) | idex | [IDEX](https://idex.io) | 2 | [API](https://docs.idex.io/) | [](https://github.com/ccxt/ccxt/wiki/Certification) | [](https://ccxt.pro) |
| [](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
| [](https://latoken.com) | latoken | [Latoken](https://latoken.com) | 1 | [API](https://api.latoken.com) | | |
| [](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) | | |
| [](https://www.liquid.com/sign-up/?affiliate=SbzC62lt30976) | liquid | [Liquid](https://www.liquid.com/sign-up/?affiliate=SbzC62lt30976) | 2 | [API](https://developers.liquid.com) | | |
-| [](https://livecoin.net/?from=Livecoin-CQ1hfx44) | livecoin | [LiveCoin](https://livecoin.net/?from=Livecoin-CQ1hfx44) | * | [API](https://www.livecoin.net/api?lang=en) | | |
| [](https://www.luno.com/invite/44893A) | luno | [luno](https://www.luno.com/invite/44893A) | 1 | [API](https://www.luno.com/en/api) | | |
| [](https://www.lykke.com) | lykke | [Lykke](https://www.lykke.com) | 1 | [API](https://hft-api.lykke.com/swagger/ui/) | | |
| [](https://www.mercadobitcoin.com.br) | mercado | [Mercado Bitcoin](https://www.mercadobitcoin.com.br) | 3 | [API](https://www.mercadobitcoin.com.br/api-doc) | | |
| [](https://mixcoins.com) | mixcoins | [MixCoins](https://mixcoins.com) | 1 | [API](https://mixcoins.com/help/api/) | | |
+| [](https://one.ndax.io/bfQiSL) | ndax | [NDAX](https://one.ndax.io/bfQiSL) | * | [API](https://apidoc.ndax.io/) | | [](https://ccxt.pro) |
| [](https://www.novadax.com.br/?s=ccxt) | novadax | [NovaDAX](https://www.novadax.com.br/?s=ccxt) | 1 | [API](https://doc.novadax.com/pt-BR/) | | |
| [](https://oceanex.pro/signup?referral=VE24QX) | oceanex | [OceanEx](https://oceanex.pro/signup?referral=VE24QX) | 1 | [API](https://api.oceanex.pro/doc/v1) | | |
| [](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/) | | [](https://ccxt.pro) |
@@ -166,7 +171,7 @@ The CCXT library currently supports the following 123 cryptocurrency exchange ma
| [](http://bit.ly/2IX0LrM) | tidebit | [TideBit](http://bit.ly/2IX0LrM) | 2 | [API](https://www.tidebit.com/documents/api/guide) | | |
| [](https://tidex.com/exchange/?ref=57f5638d9cd7) | tidex | [Tidex](https://tidex.com/exchange/?ref=57f5638d9cd7) | 3 | [API](https://tidex.com/exchange/public-api) | | |
| [](https://timex.io/?refcode=1x27vNkTbP1uwkCck) | timex | [TimeX](https://timex.io/?refcode=1x27vNkTbP1uwkCck) | 1 | [API](https://docs.timex.io) | | |
-| [](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) | [](https://github.com/ccxt/ccxt/wiki/Certification) | [](https://ccxt.pro) |
+| [](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) | | [](https://ccxt.pro) |
| [](https://www.vaultoro.com) | vaultoro | [Vaultoro](https://www.vaultoro.com) | 1 | [API](https://api.vaultoro.com) | | |
| [](https://vbtc.exchange) | vbtc | [VBTC](https://vbtc.exchange) | 1 | [API](https://blinktrade.com/docs) | | |
| [](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.67/dist/ccxt.browser.js
+* unpkg: https://unpkg.com/ccxt@1.42.67/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..a5dd8e087 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)
@@ -1092,7 +1146,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 +1211,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 +1223,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 +1252,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 +1266,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 +1337,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 +1349,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 +1406,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 +1443,6 @@ class Transpiler {
])
const pythonHeader = [
- '',
'import numbers # noqa: E402',
'try:',
' basestring # basestring was removed in Python 3',
@@ -1400,7 +1453,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 +1476,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 +1541,10 @@ class Transpiler {
this.transpilePythonAsyncToSync ()
+ this.transpilePhpAsyncToSync ()
+
+ this.transpilePhpBaseClassMethods ()
+
log.bright.green ('Transpiled successfully.')
}
}
@@ -1469,12 +1557,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..cfe45fb0d 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 {}
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..d4dfef7b1 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.67'
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..1df9f81a0 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.67'
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 () {
@@ -3169,7 +4959,7 @@ module.exports = class Exchange {
}
-},{"../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 +5005,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 +5038,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 +5062,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 +5092,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 +5252,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 +5372,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 +5610,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 +5750,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 +6091,7 @@ module.exports = {
/* ------------------------------------------------------------------------ */
-},{}],14:[function(require,module,exports){
+},{}],15:[function(require,module,exports){
(function (process){
"use strict";
@@ -4338,30 +6132,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 +6218,7 @@ module.exports = {
/* ------------------------------------------------------------------------ */
-},{"./time":17}],17:[function(require,module,exports){
+},{"./time":18}],18:[function(require,module,exports){
'use strict';
/* ------------------------------------------------------------------------ */
@@ -4631,7 +6422,7 @@ module.exports =
/* ------------------------------------------------------------------------ */
-},{}],18:[function(require,module,exports){
+},{}],19:[function(require,module,exports){
"use strict";
/* ------------------------------------------------------------------------ */
@@ -4699,696 +6490,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 +6524,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 +6598,7 @@ module.exports = class bibox extends Exchange {
'get': [
'cquery',
'mdata',
+ 'cdata',
],
},
'private': {
@@ -5533,9 +6636,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 +6659,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 +6962,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 +7046,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 +7406,7 @@ module.exports = class bibox extends Exchange {
'symbol': symbol,
'type': type,
'timeInForce': undefined,
+ 'postOnly': undefined,
'side': side,
'price': price,
'stopPrice': undefined,
@@ -6276,7 +7459,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 +7479,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 +7606,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 +7656,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 +7737,7 @@ module.exports = class bigone extends Exchange {
'private': {
'get': [
'accounts',
+ 'fund/accounts',
'assets/{asset_symbol}/address',
'orders',
'orders/{id}',
@@ -6567,6 +7751,7 @@ module.exports = class bigone extends Exchange {
'orders/{id}/cancel',
'orders/cancel',
'withdrawals',
+ 'transfer',
],
},
},
@@ -7121,7 +8306,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 +8385,7 @@ module.exports = class bigone extends Exchange {
'symbol': symbol,
'type': undefined,
'timeInForce': undefined,
+ 'postOnly': undefined,
'side': side,
'price': price,
'stopPrice': undefined,
@@ -7234,7 +8423,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 +8931,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 +8957,7 @@ module.exports = class binance extends Exchange {
'cancelOrder': true,
'CORS': false,
'createOrder': true,
+ 'fetchCurrencies': true,
'fetchBalance': true,
'fetchBidsAsks': true,
'fetchClosedOrders': 'emulated',
@@ -7858,6 +9048,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 +9090,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 +9116,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 +9150,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 +9165,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 +9284,7 @@ module.exports = class binance extends Exchange {
'historicalTrades',
'aggTrades',
'klines',
+ 'continuousKlines',
'fundingRate',
'premiumIndex',
'ticker/24hr',
@@ -8102,6 +9319,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 +9338,9 @@ module.exports = class binance extends Exchange {
'leverage',
'listenKey',
'countdownCancelAll',
+ // broker endpoints
+ 'apiReferral/customization',
+ 'apiReferral/userCustomization',
],
'put': [
'listenKey',
@@ -8191,6 +9420,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 +9435,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 +9492,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 +9530,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 +9845,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 +9924,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 +10326,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 +10431,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 +10477,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 +10597,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 +10723,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 +10735,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 +10783,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 +10870,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 +10878,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 +10888,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 +10900,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 +10921,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 +10930,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 +11043,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 +11053,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 +11076,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 +11087,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 +11155,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 +11455,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 +11507,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 +11705,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 +11816,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 +11861,10 @@ module.exports = class binanceus extends binance {
},
});
}
+
+ async fetchCurrencies (params = {}) {
+ return undefined;
+ }
};
@@ -10728,6 +12177,7 @@ module.exports = class bit2c extends Exchange {
'symbol': symbol,
'type': undefined,
'timeInForce': undefined,
+ 'postOnly': undefined,
'side': side,
'price': price,
'stopPrice': undefined,
@@ -10879,7 +12329,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 +12414,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 +12424,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 +12542,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 +12702,7 @@ module.exports = class bitbank extends Exchange {
'symbol': symbol,
'type': type,
'timeInForce': undefined,
+ 'postOnly': undefined,
'side': side,
'price': price,
'stopPrice': undefined,
@@ -11267,7 +12721,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 +12957,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 +13311,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 +13323,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 +14233,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 +14269,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 +14288,6 @@ module.exports = class bitfinex extends Exchange {
'countries': [ 'VG' ],
'version': 'v1',
'rateLimit': 1500,
- 'certified': true,
'pro': true,
// new metainfo interface
'has': {
@@ -12870,6 +14325,7 @@ module.exports = class bitfinex extends Exchange {
'30m': '30m',
'1h': '1h',
'3h': '3h',
+ '4h': '4h',
'6h': '6h',
'12h': '12h',
'1d': '1D',
@@ -13416,13 +14872,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 +15060,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 +15178,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 +15554,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 +15610,7 @@ module.exports = class bitfinex2 extends bitfinex {
'30m': '30m',
'1h': '1h',
'3h': '3h',
+ '4h': '4h',
'6h': '6h',
'12h': '12h',
'1d': '1D',
@@ -14252,7 +15729,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 +16143,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 +16487,7 @@ module.exports = class bitfinex2 extends bitfinex {
'symbol': symbol,
'type': type,
'timeInForce': undefined,
+ 'postOnly': undefined,
'side': side,
'price': price,
'stopPrice': undefined,
@@ -15022,16 +16506,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 +17128,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 +17496,7 @@ module.exports = class bitflyer extends Exchange {
'symbol': symbol,
'type': type,
'timeInForce': undefined,
+ 'postOnly': undefined,
'side': side,
'price': price,
'stopPrice': undefined,
@@ -16044,7 +17556,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 +17572,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 +17654,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 +17880,7 @@ module.exports = class bitforex extends Exchange {
},
'commonCurrencies': {
'CREDIT': 'TerraCredit',
+ 'HBC': 'Hybrid Bank Cash',
'IQ': 'IQ.Cash',
'UOS': 'UOS Network',
},
@@ -16376,6 +17889,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 +18158,7 @@ module.exports = class bitforex extends Exchange {
'symbol': symbol,
'type': type,
'timeInForce': undefined,
+ 'postOnly': undefined,
'side': side,
'price': price,
'stopPrice': undefined,
@@ -16772,7 +18287,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 +19994,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 +20006,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 +20250,7 @@ module.exports = class bitget extends Exchange {
'symbol': symbol,
'type': type,
'timeInForce': undefined,
+ 'postOnly': undefined,
'side': side,
'price': price,
'stopPrice': undefined,
@@ -18817,7 +20333,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 +20375,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 +20416,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 +20481,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 +20558,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 +20643,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 +20735,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 +20772,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 +20895,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 +20959,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 +20976,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 +21195,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 +21220,7 @@ module.exports = class bithumb extends Exchange {
'createOrder': true,
'fetchBalance': true,
'fetchMarkets': true,
+ 'fetchOHLCV': true,
'fetchOpenOrders': true,
'fetchOrder': true,
'fetchOrderBook': true,
@@ -19726,10 +21244,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 +21294,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 +21323,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 +21579,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 +21756,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 +21769,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 +21782,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 +21994,7 @@ module.exports = class bithumb extends Exchange {
'symbol': symbol,
'type': type,
'timeInForce': undefined,
+ 'postOnly': undefined,
'side': side,
'price': price,
'stopPrice': undefined,
@@ -20411,7 +22017,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 +22057,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 +22091,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 +22172,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 +22196,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 +22254,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 +22367,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 +22502,8 @@ module.exports = class bitmart extends Exchange {
'broad': {},
},
'commonCurrencies': {
+ 'COT': 'Community Coin',
+ 'CPC': 'CPCoin',
'ONE': 'Menlo One',
'PLA': 'Plair',
},
@@ -21838,7 +23449,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 +23457,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 +23530,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 +23808,7 @@ module.exports = class bitmart extends Exchange {
'symbol': symbol,
'type': type,
'timeInForce': undefined,
+ 'postOnly': undefined,
'side': side,
'price': price,
'stopPrice': undefined,
@@ -22302,7 +23914,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 +23942,15 @@ module.exports = class bitmart extends Exchange {
// }
// }
//
+ // spot alternative
+ //
+ // {
+ // "code": 1000,
+ // "trace":"886fb6ae-456b-4654-b4e0-d681ac05cea1",
+ // "message": "OK",
+ // "data": true
+ // }
+ //
// contract
//
// {
@@ -22345,16 +23966,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 +23987,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 +24016,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 +24062,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 +24184,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 +24196,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 +24274,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 +24568,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 +24704,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 +25610,7 @@ module.exports = class bitmax extends Exchange {
'symbol': symbol,
'type': type,
'timeInForce': undefined,
+ 'postOnly': undefined,
'side': side,
'price': price,
'stopPrice': stopPrice,
@@ -24036,7 +25661,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 +25916,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 +26296,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 +26466,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 +27519,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 +27585,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 +27597,7 @@ module.exports = class bitmex extends Exchange {
'symbol': symbol,
'type': type,
'timeInForce': timeInForce,
+ 'postOnly': postOnly,
'side': side,
'price': price,
'stopPrice': stopPrice,
@@ -26000,18 +27666,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 +27982,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 +28775,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 +28953,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 +29008,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 +29313,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 +29324,7 @@ module.exports = class bitpanda extends Exchange {
'symbol': symbol,
'type': type,
'timeInForce': timeInForce,
+ 'postOnly': postOnly,
'side': side,
'price': price,
'stopPrice': stopPrice,
@@ -27725,7 +29399,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 +29550,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 +29714,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 +29800,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 +29984,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 +30239,7 @@ module.exports = class bitso extends Exchange {
'symbol': symbol,
'type': orderType,
'timeInForce': undefined,
+ 'postOnly': undefined,
'side': side,
'price': price,
'stopPrice': undefined,
@@ -28750,13 +30427,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 +30653,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 +31136,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 +31202,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 +31693,7 @@ module.exports = class bitstamp extends Exchange {
'symbol': symbol,
'type': undefined,
'timeInForce': undefined,
+ 'postOnly': undefined,
'side': side,
'price': price,
'stopPrice': undefined,
@@ -30357,7 +32036,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 +32337,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 +32363,7 @@ module.exports = class bittrex extends Exchange {
'CORS': false,
'cancelAllOrders': true,
'cancelOrder': true,
+ 'createDepositAddress': true,
'createMarketOrder': true,
'createOrder': true,
'fetchBalance': true,
@@ -30798,10 +32478,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 +33099,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 +33331,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 +33401,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 +33411,7 @@ module.exports = class bittrex extends Exchange {
'symbol': symbol,
'type': type,
'timeInForce': timeInForce,
+ 'postOnly': postOnly,
'side': direction,
'price': limit,
'stopPrice': undefined,
@@ -31852,6 +33549,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 +33590,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 +33704,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 +33770,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 +33994,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 +34562,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 +34591,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 +34672,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 +34716,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 +34765,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 +34826,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 +34887,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 +34989,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 +35002,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 +35019,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 +35304,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 +35982,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 +36086,7 @@ module.exports = class bitz extends Exchange {
'symbol': symbol,
'type': 'limit',
'timeInForce': undefined,
+ 'postOnly': undefined,
'side': side,
'price': price,
'stopPrice': undefined,
@@ -34481,7 +36256,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 +36592,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 +36830,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 +37495,7 @@ module.exports = class bleutrade extends Exchange {
'symbol': symbol,
'type': 'limit',
'timeInForce': undefined,
+ 'postOnly': undefined,
'side': side,
'price': price,
'stopPrice': undefined,
@@ -35870,7 +37646,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 +38109,7 @@ module.exports = class braziliex extends Exchange {
'symbol': symbol,
'type': 'limit',
'timeInForce': undefined,
+ 'postOnly': undefined,
'side': side,
'price': price,
'stopPrice': undefined,
@@ -36513,7 +38290,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 +38641,7 @@ module.exports = class btcalpha extends Exchange {
'symbol': symbol,
'type': 'limit',
'timeInForce': undefined,
+ 'postOnly': undefined,
'side': side,
'price': price,
'stopPrice': undefined,
@@ -37017,7 +38795,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 +39104,7 @@ module.exports = class btcbox extends Exchange {
'side': side,
'type': undefined,
'timeInForce': undefined,
+ 'postOnly': undefined,
'status': status,
'symbol': symbol,
'price': price,
@@ -37444,7 +39223,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 +40091,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 +40102,7 @@ module.exports = class btcmarkets extends Exchange {
'symbol': symbol,
'type': type,
'timeInForce': timeInForce,
+ 'postOnly': postOnly,
'side': side,
'price': price,
'stopPrice': stopPrice,
@@ -38501,7 +40282,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 +40620,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 +40637,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 +40678,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 +40956,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 +41007,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 +41547,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 +41615,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 +41833,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 +42597,7 @@ module.exports = class bw extends Exchange {
'symbol': symbol,
'type': 'limit',
'timeInForce': undefined,
+ 'postOnly': undefined,
'side': side,
'price': price,
'stopPrice': undefined,
@@ -40795,7 +42614,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 +42649,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 +43041,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 +43061,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 +43104,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 +43117,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 +43325,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 +43333,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 +43368,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 +43386,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 +43395,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 +43406,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 +43488,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 +43566,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 +43614,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 +43712,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 +43724,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 +43879,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 +43933,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 +43956,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 +44197,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 +44208,7 @@ module.exports = class bybit extends Exchange {
'symbol': symbol,
'type': type,
'timeInForce': timeInForce,
+ 'postOnly': postOnly,
'side': side,
'price': price,
'stopPrice': stopPrice,
@@ -42417,7 +44225,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 +44239,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 +44247,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 +44360,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 +44372,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 +44380,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 +44474,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 +44490,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 +44549,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 +44563,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 +44571,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 +44580,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 +44622,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 +44633,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 +44799,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 +44816,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 +44906,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 +44978,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 +45049,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 +45117,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 +45221,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 +45285,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 +45573,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 +45868,7 @@ module.exports = class bytetrade extends Exchange {
'symbol': symbol,
'type': type,
'timeInForce': undefined,
+ 'postOnly': undefined,
'side': side,
'price': price,
'stopPrice': undefined,
@@ -44053,7 +45886,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 +46070,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 +46088,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 +46108,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 +46128,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 +46148,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 +46249,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 +46355,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 +46375,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 +46398,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 +46482,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 +46508,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 +46718,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 +47432,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 +47638,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 +47674,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 +48008,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 +48103,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 +48137,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 +48263,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 +48317,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 +48852,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 +49327,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 +49338,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 +49355,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 +49388,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 +49736,7 @@ module.exports = class coinbasepro extends Exchange {
}
async fetchAccounts (params = {}) {
+ await this.loadMarkets ();
const response = await this.privateGetAccounts (params);
//
// [
@@ -48030,12 +49915,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 +49937,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 +49965,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 +49981,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 +50008,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 +50087,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 +50138,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 +50152,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 +50169,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 +50198,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 +50212,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 +50402,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 +50490,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 +50501,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 +50613,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';
// ---------------------------------------------------------------------------
@@ -48792,6 +50813,7 @@ module.exports = class coincheck extends Exchange {
'side': side,
'type': undefined,
'timeInForce': undefined,
+ 'postOnly': undefined,
'status': status,
'symbol': symbol,
'price': price,
@@ -49024,7 +51046,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 +51203,7 @@ module.exports = class coinegg extends Exchange {
},
'commonCurrencies': {
'JBC': 'JubaoCoin',
+ 'SBTC': 'Super Bitcoin',
},
});
}
@@ -49394,6 +51417,7 @@ module.exports = class coinegg extends Exchange {
'symbol': symbol,
'type': type,
'timeInForce': undefined,
+ 'postOnly': undefined,
'side': side,
'price': price,
'stopPrice': undefined,
@@ -49541,7 +51565,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 +51660,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 +52069,7 @@ module.exports = class coinex extends Exchange {
'symbol': symbol,
'type': type,
'timeInForce': undefined,
+ 'postOnly': undefined,
'side': side,
'price': price,
'stopPrice': undefined,
@@ -50106,7 +52133,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 +52330,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 +52339,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 +52362,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 +52420,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 +52485,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 +52522,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 +52742,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 +52845,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 +52855,7 @@ module.exports = class coinfalcon extends Exchange {
'symbol': symbol,
'type': type,
'timeInForce': undefined,
+ 'postOnly': postOnly,
'side': side,
'price': price,
'stopPrice': undefined,
@@ -50945,7 +52978,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 +53008,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 +53071,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 +53204,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 +53412,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 +53461,7 @@ module.exports = class coinfloor extends Exchange {
'symbol': symbol,
'type': 'limit',
'timeInForce': undefined,
+ 'postOnly': undefined,
'side': side,
'price': price,
'stopPrice': undefined,
@@ -51443,7 +53477,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 +53531,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 +53881,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 +54034,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 +54230,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 +54762,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 +54874,7 @@ module.exports = class coinmate extends Exchange {
'symbol': symbol,
'type': type,
'timeInForce': undefined,
+ 'postOnly': undefined,
'side': side,
'price': price,
'stopPrice': stopPrice,
@@ -52955,7 +54992,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 +55368,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 +55513,7 @@ module.exports = class coinone extends Exchange {
'symbol': symbol,
'type': 'limit',
'timeInForce': undefined,
+ 'postOnly': undefined,
'side': side,
'price': price,
'stopPrice': undefined,
@@ -53525,7 +55563,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 +55598,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 +55676,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 +55749,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 +55934,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 +55965,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 +56101,7 @@ module.exports = class crex24 extends Exchange {
'GHOST': 'GHOSTPRISM',
'IQ': 'IQ.Cash',
'PUT': 'PutinCoin',
+ 'SBTC': 'SBTCT', // SiamBitcoin
'UNI': 'Universe',
'YOYO': 'YOYOW',
},
@@ -54036,6 +56127,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 +56727,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 +57277,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 +58196,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 +58257,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 +58265,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 +58300,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 +58398,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 +60664,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 +60897,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 +60982,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 +60994,7 @@ module.exports = class deribit extends Exchange {
'symbol': market['symbol'],
'type': type,
'timeInForce': timeInForce,
+ 'postOnly': postOnly,
'side': side,
'price': price,
'stopPrice': stopPrice,
@@ -57500,13 +61079,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 +61154,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 +61519,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 +61558,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 +61672,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 +62177,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 +62223,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 +62669,7 @@ module.exports = class digifinex extends Exchange {
'symbol': symbol,
'type': type,
'timeInForce': undefined,
+ 'postOnly': undefined,
'side': side,
'price': price,
'stopPrice': undefined,
@@ -59380,7 +62960,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 +63203,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 +63859,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 +64046,7 @@ module.exports = class dsx extends Exchange {
'lastTradeTimestamp': lastTradeTimestamp,
'type': orderType,
'timeInForce': undefined,
+ 'postOnly': undefined,
'side': side,
'price': price,
'stopPrice': undefined,
@@ -60898,7 +64479,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 +66637,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 +66839,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 +66849,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 +67174,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 +67879,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 +68495,7 @@ module.exports = class exmo extends Exchange {
'symbol': symbol,
'type': 'limit',
'timeInForce': undefined,
+ 'postOnly': undefined,
'side': side,
'price': price,
'stopPrice': undefined,
@@ -63480,12 +68614,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 +68656,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 +68782,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 +69111,7 @@ module.exports = class exx extends Exchange {
'symbol': symbol,
'type': 'limit',
'timeInForce': undefined,
+ 'postOnly': undefined,
'side': order['type'],
'price': price,
'stopPrice': undefined,
@@ -64024,7 +69173,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 +69248,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 +69843,7 @@ module.exports = class fcoin extends Exchange {
'symbol': symbol,
'type': orderType,
'timeInForce': undefined,
+ 'postOnly': undefined,
'side': side,
'price': price,
'stopPrice': undefined,
@@ -64843,7 +69993,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 +70019,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 +70268,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 +70305,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 +70570,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 +70587,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 +70672,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 +70685,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 +70711,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 +70742,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 +70757,8 @@ module.exports = class ftx extends Exchange {
// options
'options/requests/{request_id}',
'options/quotes/{quote_id}',
+ // staking
+ 'staking/unstake_requests/{request_id}',
],
},
},
@@ -65618,6 +70793,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 +70802,18 @@ 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}
+ '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 +70943,7 @@ module.exports = class ftx extends Exchange {
'amount': sizeIncrement,
'price': priceIncrement,
};
- const entry = {
+ result.push ({
'id': id,
'symbol': symbol,
'base': base,
@@ -65788,8 +70970,7 @@ module.exports = class ftx extends Exchange {
},
},
'info': market,
- };
- result.push (entry);
+ });
}
return result;
}
@@ -66088,22 +71269,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 +71619,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 +71630,7 @@ module.exports = class ftx extends Exchange {
'symbol': symbol,
'type': type,
'timeInForce': undefined,
+ 'postOnly': postOnly,
'side': side,
'price': price,
'stopPrice': stopPrice,
@@ -66568,12 +71768,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 +71839,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 +71872,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 +72042,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 +72232,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 +72253,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 +72273,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 +72311,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 +72338,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 +72395,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 +72565,7 @@ module.exports = class gateio extends Exchange {
'BOX': 'DefiBox',
'BTCBEAR': 'BEAR',
'BTCBULL': 'BULL',
+ 'SBTC': 'Super Bitcoin',
'TNC': 'Trinity Network Credit',
},
});
@@ -67874,6 +73089,7 @@ module.exports = class gateio extends Exchange {
'symbol': symbol,
'type': 'limit',
'timeInForce': undefined,
+ 'postOnly': undefined,
'side': side,
'price': price,
'stopPrice': undefined,
@@ -67914,7 +73130,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 +73153,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 +73186,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 +73200,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 +73282,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 +73304,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 +73327,7 @@ module.exports = class gateio extends Exchange {
'type': type,
'timestamp': timestamp,
'datetime': this.iso8601 (timestamp),
- 'fee': undefined,
+ 'fee': fee,
};
}
@@ -68166,7 +73393,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 +74065,7 @@ module.exports = class gemini extends Exchange {
'symbol': symbol,
'type': type,
'timeInForce': undefined,
+ 'postOnly': undefined,
'side': side,
'price': price,
'stopPrice': undefined,
@@ -68901,7 +74129,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 +74306,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 +76499,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 +77612,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 +77666,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';
// ---------------------------------------------------------------------------
@@ -71251,6 +77829,7 @@ module.exports = class hitbtc extends Exchange {
'LNC': 'LinkerCoin',
'PLA': 'PlayChip',
'PNT': 'Penta',
+ 'SBTC': 'Super Bitcoin',
'TV': 'Tokenville',
'USD': 'USDT',
'XPNT': 'PNT',
@@ -71888,22 +78467,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 +78534,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 +78553,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 +78852,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 +79375,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 +79557,7 @@ module.exports = class hollaex extends Exchange {
'symbol': symbol,
'type': type,
'timeInForce': undefined,
+ 'postOnly': undefined,
'side': side,
'price': price,
'stopPrice': undefined,
@@ -73423,7 +80027,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 +80068,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 +80169,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 +80267,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 +80285,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 +80322,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 +80755,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 +81024,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 +81036,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 +81186,7 @@ module.exports = class huobipro extends Exchange {
'symbol': symbol,
'type': type,
'timeInForce': undefined,
+ 'postOnly': undefined,
'side': side,
'price': price,
'stopPrice': undefined,
@@ -74951,6 +81566,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 +81576,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 +81804,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 +81924,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 +82073,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 +82132,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 +82179,7 @@ module.exports = class idex extends Exchange {
'options': {
'defaultTimeInForce': 'gtc',
'defaultSelfTradePrevention': 'cn',
+ 'network': 'ETH', // also supports BSC
},
'exceptions': {
'INVALID_ORDER_QUANTITY': InvalidOrder,
@@ -76347,6 +82932,7 @@ module.exports = class idex extends Exchange {
'symbol': symbol,
'type': type,
'timeInForce': undefined,
+ 'postOnly': undefined,
'side': side,
'price': price,
'stopPrice': undefined,
@@ -76435,7 +83021,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 +83351,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 +83384,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 +83674,7 @@ module.exports = class independentreserve extends Exchange {
'symbol': symbol,
'type': orderType,
'timeInForce': undefined,
+ 'postOnly': undefined,
'side': side,
'price': price,
'stopPrice': undefined,
@@ -77193,10 +83782,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 +83894,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 +84296,7 @@ module.exports = class indodax extends Exchange {
'symbol': symbol,
'type': 'limit',
'timeInForce': undefined,
+ 'postOnly': undefined,
'side': side,
'price': price,
'stopPrice': undefined,
@@ -77720,7 +84313,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 +84360,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 +84404,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 +84515,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 +84786,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 +84855,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 +84945,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 +84983,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 +85047,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 +85060,7 @@ module.exports = class itbit extends Exchange {
'symbol': symbol,
'type': type,
'timeInForce': undefined,
+ 'postOnly': postOnly,
'side': side,
'price': price,
'stopPrice': undefined,
@@ -78490,7 +85086,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 +85111,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 +85123,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 +85170,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 +85192,7 @@ module.exports = class kraken extends Exchange {
'certified': true,
'pro': true,
'has': {
+ 'cancelAllOrders': true,
'cancelOrder': true,
'CORS': false,
'createDepositAddress': true,
@@ -78756,6 +85353,7 @@ module.exports = class kraken extends Exchange {
'AddOrder',
'AddExport',
'Balance',
+ 'CancelAll',
'CancelOrder',
'ClosedOrders',
'DepositAddresses',
@@ -78783,6 +85381,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 +85525,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 +86000,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 +86024,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 +86052,7 @@ module.exports = class kraken extends Exchange {
}
return {
'id': id,
- 'order': order,
+ 'order': orderId,
'info': trade,
'timestamp': timestamp,
'datetime': this.iso8601 (timestamp),
@@ -79512,6 +86115,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 +86140,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 +86346,7 @@ module.exports = class kraken extends Exchange {
'symbol': symbol,
'type': type,
'timeInForce': undefined,
+ 'postOnly': undefined,
'side': side,
'price': price,
'stopPrice': stopPrice,
@@ -79776,8 +86413,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 +86425,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 +86574,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 +86750,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 +86793,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 +86884,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 +86997,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 +87021,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 +87044,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 +87099,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 +87136,7 @@ module.exports = class kucoin extends Exchange {
'withdrawals',
'withdrawals/quotas',
'orders',
+ 'order/client-order/{clientOid}',
'orders/{orderId}',
'limit/orders',
'fills',
@@ -80440,6 +87152,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 +87165,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 +87272,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 +87409,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 +87720,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 +87740,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 +87759,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 +87836,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 +87910,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 +88013,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 +88110,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 +88446,7 @@ module.exports = class kucoin extends Exchange {
// "status": "SUCCESS",
// "createdAt": 1544178843000,
// "updatedAt": 1544178891000
+ // "remark":"foobar"
// }
//
// fetchWithdrawals
@@ -81681,6 +88463,7 @@ module.exports = class kucoin extends Exchange {
// "status": "FAILURE",
// "createdAt": 1546503758000,
// "updatedAt": 1546504603000
+ // "remark":"foobar"
// }
//
const currencyId = this.safeString (transaction, 'currency');
@@ -81731,20 +88514,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 +88581,7 @@ module.exports = class kucoin extends Exchange {
// "status": "SUCCESS",
// "createdAt": 1544178843000,
// "updatedAt": 1544178891000
+ // "remark":"foobar"
// },
// //--------------------------------------------------
// // version 1 (historical) deposit response structure
@@ -81921,7 +88711,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 +88854,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 +88877,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 +88922,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 +89045,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 +89107,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 +89138,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 +89468,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 +90005,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 +90117,7 @@ module.exports = class latoken extends Exchange {
'symbol': symbol,
'type': type,
'timeInForce': undefined,
+ 'postOnly': undefined,
'side': side,
'price': price,
'stopPrice': undefined,
@@ -83354,7 +90152,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 +90268,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 +90358,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 +90719,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 +90847,7 @@ module.exports = class lbank extends Exchange {
'symbol': symbol,
'type': type,
'timeInForce': undefined,
+ 'postOnly': undefined,
'side': side,
'price': price,
'stopPrice': undefined,
@@ -84260,7 +91059,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 +91248,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 +91786,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 +91927,7 @@ module.exports = class liquid extends Exchange {
'lastTradeTimestamp': lastTradeTimestamp,
'type': type,
'timeInForce': undefined,
+ 'postOnly': undefined,
'status': status,
'symbol': symbol,
'side': side,
@@ -85396,940 +92197,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 +92238,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 +92251,11 @@ module.exports = class luno extends Exchange {
],
},
'api': {
+ 'exchange': {
+ 'get': [
+ 'markets',
+ ],
+ },
'public': {
'get': [
'orderbook',
@@ -86429,16 +92306,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 +92349,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 +92393,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 +92412,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 +92508,7 @@ module.exports = class luno extends Exchange {
'symbol': symbol,
'type': undefined,
'timeInForce': undefined,
+ 'postOnly': undefined,
'side': side,
'price': price,
'stopPrice': undefined,
@@ -86757,7 +92689,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);
@@ -86961,7 +92893,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 +92917,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 +93419,7 @@ module.exports = class lykke extends Exchange {
'symbol': symbol,
'type': undefined,
'timeInForce': undefined,
+ 'postOnly': undefined,
'side': side,
'price': price,
'stopPrice': undefined,
@@ -87600,7 +93533,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 +93557,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 +93598,7 @@ module.exports = class mercado extends Exchange {
'api': {
'public': {
'get': [
+ 'coins',
'{coin}/orderbook/', // last slash critical
'{coin}/ticker/',
'{coin}/trades/',
@@ -87693,23 +93629,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 +93758,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 +93795,7 @@ module.exports = class mercado extends Exchange {
'price': price,
'amount': amount,
'cost': cost,
- 'fee': undefined,
+ 'fee': fee,
};
}
@@ -87952,6 +93963,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 +93978,7 @@ module.exports = class mercado extends Exchange {
'symbol': market['symbol'],
'type': 'limit',
'timeInForce': undefined,
+ 'postOnly': undefined,
'side': side,
'price': price,
'stopPrice': undefined,
@@ -87972,7 +93989,7 @@ module.exports = class mercado extends Exchange {
'remaining': remaining,
'status': status,
'fee': fee,
- 'trades': undefined, // todo parse trades (operations)
+ 'trades': trades,
};
}
@@ -88004,17 +94021,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 +94093,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 +94173,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 +94404,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 +97295,7 @@ module.exports = class novadax extends Exchange {
'symbol': symbol,
'type': type,
'timeInForce': undefined,
+ 'postOnly': undefined,
'side': side,
'price': price,
'stopPrice': undefined,
@@ -89532,7 +97612,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 +98127,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 +98188,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 +98298,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 +98335,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 +98446,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 +98537,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 +98584,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 +98871,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 +98900,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 +98953,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 +99023,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 +99323,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 +100059,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 +100305,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 +100512,7 @@ module.exports = class okex extends Exchange {
'symbol': symbol,
'type': type,
'timeInForce': undefined,
+ 'postOnly': undefined,
'side': side,
'price': price,
'stopPrice': stopPrice,
@@ -92438,14 +100529,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 +100604,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 +100616,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 +100946,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 +100958,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 +100999,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 +101173,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 +101562,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 +101977,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 +102242,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 +102347,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 +102974,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 +103067,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 +103113,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 +103152,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 +103657,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 +103892,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 +103905,7 @@ module.exports = class phemex extends Exchange {
'symbol': symbol,
'type': type,
'timeInForce': timeInForce,
+ 'postOnly': postOnly,
'side': side,
'price': price,
'stopPrice': stopPrice,
@@ -95861,6 +103978,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 +103989,7 @@ module.exports = class phemex extends Exchange {
'symbol': symbol,
'type': type,
'timeInForce': timeInForce,
+ 'postOnly': postOnly,
'side': side,
'price': price,
'stopPrice': stopPrice,
@@ -95926,8 +104045,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 +104058,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 +104161,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 +104201,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 +104235,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 +104257,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 +104281,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 +104343,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 +104578,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 +104765,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 +104972,6 @@ module.exports = class poloniex extends Exchange {
'Error pulling ': ExchangeError, // {"error":"Error pulling order book"}
},
},
- 'orders': {}, // orders cache / emulation
});
}
@@ -97570,6 +105690,7 @@ module.exports = class poloniex extends Exchange {
'symbol': symbol,
'type': type,
'timeInForce': undefined,
+ 'postOnly': undefined,
'side': side,
'price': price,
'stopPrice': undefined,
@@ -98131,7 +106252,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 +106376,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 +106398,7 @@ module.exports = class probit extends Exchange {
'BTCBEAR': 'BEAR',
'BTCBULL': 'BULL',
'CBC': 'CryptoBharatCoin',
+ 'HBC': 'Hybrid Bank Cash',
'UNI': 'UNICORN Token',
},
});
@@ -98433,7 +106556,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 +106997,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 +107097,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 +107290,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 +107538,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 +108456,7 @@ module.exports = class qtrade extends Exchange {
'symbol': symbol,
'type': orderType,
'timeInForce': undefined,
+ 'postOnly': undefined,
'side': side,
'price': price,
'stopPrice': undefined,
@@ -100946,7 +109081,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 +109515,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 +109625,7 @@ module.exports = class rightbtc extends Exchange {
'symbol': symbol,
'type': type,
'timeInForce': undefined,
+ 'postOnly': undefined,
'side': side,
'price': price,
'stopPrice': undefined,
@@ -101506,7 +109642,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 +109680,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 +109717,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 +109756,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 +109841,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 +110674,7 @@ module.exports = class ripio extends Exchange {
'symbol': symbol,
'type': type,
'timeInForce': undefined,
+ 'postOnly': undefined,
'side': side,
'price': price,
'stopPrice': stopPrice,
@@ -102652,7 +110789,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 +111056,7 @@ module.exports = class southxchange extends Exchange {
'symbol': symbol,
'type': type,
'timeInForce': undefined,
+ 'postOnly': undefined,
'side': side,
'price': price,
'stopPrice': undefined,
@@ -103351,7 +111489,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 +115017,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 +121006,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 +121030,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 +121407,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 +121842,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 +121852,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 +122034,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 +122974,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 +123180,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 +123422,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 +123543,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 +123569,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 +123716,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 +123818,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 +123885,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 +124667,7 @@ module.exports = {
}
};
-},{}],139:[function(require,module,exports){
+},{}],142:[function(require,module,exports){
'use strict';
var utils = exports;
@@ -116745,7 +124883,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 +124999,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 +125040,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 +126608,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 +126835,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 +126850,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 +126873,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 +127139,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 +127177,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 +127196,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 +127269,7 @@ module.exports = {
}
};
-},{"../utils":157}],150:[function(require,module,exports){
+},{"../utils":160}],153:[function(require,module,exports){
var _ = require('../utils')._;
module.exports = {
@@ -119164,7 +127302,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 +127454,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 +127645,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 +128901,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 +129050,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 +129230,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 +129253,7 @@ module.exports = {
}
};
-},{"./pkcs1":155}],157:[function(require,module,exports){
+},{"./pkcs1":158}],160:[function(require,module,exports){
/*
* Utils functions
*
@@ -121215,7 +129353,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 +129373,7 @@ module.exports = {
RFC3986: 'RFC3986'
};
-},{}],159:[function(require,module,exports){
+},{}],162:[function(require,module,exports){
'use strict';
var stringify = require('./stringify');
@@ -121248,7 +129386,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 +129630,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 +129901,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 +130133,7 @@ module.exports = {
merge: merge
};
-},{}],163:[function(require,module,exports){
+},{}],166:[function(require,module,exports){
'use strict';
// ---------------------------------------------------------------------------
@@ -122183,6 +130321,8 @@ module.exports = class stex extends Exchange {
'BITS': 'Bitcoinus',
'BITSW': 'BITS',
'BHD': 'Bithold',
+ 'BTH': 'Bithereum',
+ 'SBTC': 'SBTCT', // SiamBitcoin
},
'options': {
'parseOrderToPrecision': false,
@@ -122924,6 +131064,7 @@ module.exports = class stex extends Exchange {
'symbol': symbol,
'type': type,
'timeInForce': undefined,
+ 'postOnly': undefined,
'side': side,
'price': price,
'stopPrice': stopPrice,
@@ -123220,7 +131361,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 +131940,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 +131974,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 +132942,7 @@ module.exports = class therock extends Exchange {
'symbol': symbol,
'type': type,
'timeInForce': undefined,
+ 'postOnly': undefined,
'side': side,
'price': price,
'stopPrice': stopPrice,
@@ -124830,7 +132972,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 +133017,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 +133056,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 +133208,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 +133633,7 @@ module.exports = class tidebit extends Exchange {
'symbol': symbol,
'type': type,
'timeInForce': undefined,
+ 'postOnly': undefined,
'side': side,
'price': price,
'stopPrice': undefined,
@@ -125610,7 +133753,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 +134336,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 +134538,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 +135001,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,
+ 'type': 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 +135023,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 +135726,7 @@ module.exports = class timex extends Exchange {
'symbol': symbol,
'type': type,
'timeInForce': undefined,
+ 'postOnly': undefined,
'side': side,
'price': price,
'stopPrice': undefined,
@@ -127631,7 +135779,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 +135797,6 @@ module.exports = class upbit extends Exchange {
'countries': [ 'KR' ],
'version': 'v1',
'rateLimit': 1000,
- 'certified': true,
'pro': true,
// new metainfo interface
'has': {
@@ -127855,7 +136002,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 +136985,7 @@ module.exports = class upbit extends Exchange {
'symbol': market['symbol'],
'type': type,
'timeInForce': undefined,
+ 'postOnly': undefined,
'side': side,
'price': price,
'stopPrice': undefined,
@@ -129162,7 +137310,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 +137515,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 +137549,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 +138608,7 @@ module.exports = class vcc extends Exchange {
'symbol': symbol,
'type': type,
'timeInForce': undefined,
+ 'postOnly': undefined,
'side': side,
'price': price,
'stopPrice': stopPrice,
@@ -130741,7 +138890,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 +139949,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 +140162,7 @@ module.exports = class wavesexchange extends Exchange {
'symbol': symbol,
'type': type,
'timeInForce': undefined,
+ 'postOnly': undefined,
'side': side,
'price': price,
'stopPrice': undefined,
@@ -132409,7 +140559,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 +141214,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 +141586,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 +141627,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 +142551,7 @@ module.exports = class xena extends Exchange {
'symbol': symbol,
'type': type,
'timeInForce': undefined,
+ 'postOnly': undefined,
'side': side,
'price': price,
'stopPrice': undefined,
@@ -134456,14 +142611,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 +142656,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 +142711,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 +143308,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 +143444,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 +143461,7 @@ module.exports = class yobit extends Exchange {
'RCN': 'RCoin',
'REP': 'Republicoin',
'RUR': 'RUB',
+ 'SBTC': 'Super Bitcoin',
'TTC': 'TittieCoin',
'UNI': 'Universe',
'UST': 'Uservice',
@@ -135751,6 +143908,7 @@ module.exports = class yobit extends Exchange {
'lastTradeTimestamp': undefined,
'type': type,
'timeInForce': undefined,
+ 'postOnly': undefined,
'side': side,
'price': price,
'stopPrice': undefined,
@@ -135795,7 +143953,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 +144041,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 +144132,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 +144492,7 @@ module.exports = class zaif extends Exchange {
'symbol': symbol,
'type': 'limit',
'timeInForce': undefined,
+ 'postOnly': undefined,
'side': side,
'price': price,
'stopPrice': undefined,
@@ -136482,13 +144623,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 +144648,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 +144679,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 +144737,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 +144769,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 +144901,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 +145000,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 +145051,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 +145146,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 +145208,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 +145234,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 +145278,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 +145316,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 +145341,7 @@ module.exports = class zb extends Exchange {
'symbol': symbol,
'type': type,
'timeInForce': undefined,
+ 'postOnly': undefined,
'side': side,
'price': price,
'stopPrice': undefined,
@@ -137062,7 +145351,7 @@ module.exports = class zb extends Exchange {
'filled': filled,
'remaining': remaining,
'status': status,
- 'fee': undefined,
+ 'fee': fee,
'trades': undefined,
};
}
@@ -137077,8 +145366,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 +145636,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 +145660,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 +146154,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 +146270,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 +146684,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 +147296,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 +149012,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 +149078,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 +149289,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 +149400,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 +149704,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 +149737,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 +149823,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 +149848,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 +149871,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 +149985,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 +150038,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 +150108,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 +150169,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 +152045,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 +152392,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 +153950,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 +154295,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 +154329,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 +155551,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 +155600,7 @@ function ZStream() {
module.exports = ZStream;
-},{}],206:[function(require,module,exports){
+},{}],209:[function(require,module,exports){
(function (process){
'use strict';
@@ -147124,7 +155647,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 +155833,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 +156370,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 +156456,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 +156543,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 +156677,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 +156725,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 +157735,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 +157950,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 +158617,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 +158692,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 +158765,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 +158780,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 +158850,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 +158979,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 +159061,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 +159134,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 +159444,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 +159630,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 +159903,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 +159932,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 +160666,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 +160684,7 @@ module.exports = {
}
};
-},{}],235:[function(require,module,exports){
+},{}],238:[function(require,module,exports){
(function (global){
/**
@@ -152232,16 +160755,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 +161354,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..e43d18285 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 () {
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..c4c20f0da 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
@@ -197,6 +197,7 @@ module.exports = class coincheck 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/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..8030b8004 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,18 @@ 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}
+ '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 +370,7 @@ module.exports = class ftx extends Exchange {
'amount': sizeIncrement,
'price': priceIncrement,
};
- const entry = {
+ result.push ({
'id': id,
'symbol': symbol,
'base': base,
@@ -365,8 +397,7 @@ module.exports = class ftx extends Exchange {
},
},
'info': market,
- };
- result.push (entry);
+ });
}
return result;
}
@@ -665,22 +696,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 +1046,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 +1057,7 @@ module.exports = class ftx extends Exchange {
'symbol': symbol,
'type': type,
'timeInForce': undefined,
+ 'postOnly': postOnly,
'side': side,
'price': price,
'stopPrice': stopPrice,
@@ -1145,12 +1195,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 +1266,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 +1299,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 +1469,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 +1659,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 +1680,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 +1700,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 +1738,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 +1765,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..29b5bd6ae 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
@@ -160,6 +160,7 @@ module.exports = class hitbtc extends Exchange {
'LNC': 'LinkerCoin',
'PLA': 'PlayChip',
'PNT': 'Penta',
+ 'SBTC': 'Super Bitcoin',
'TV': 'Tokenville',
'USD': 'USDT',
'XPNT': 'PNT',
@@ -797,22 +798,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 +865,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 +884,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..1b8ef5921 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,
@@ -855,6 +856,7 @@ module.exports = class idex extends Exchange {
'symbol': symbol,
'type': type,
'timeInForce': undefined,
+ 'postOnly': undefined,
'side': side,
'price': price,
'stopPrice': undefined,
@@ -943,7 +945,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 +1275,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..41192a486 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);
@@ -629,7 +693,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..8221cb234 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,
+ 'type': 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..552c75f3b 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.67",
+ "_id": "ccxt@1.42.67",
"_inBundle": false,
- "_integrity": "sha512-cfyucvOi2WQnpR7HLuSuc2uc1vJkVVXfAQGc4D5HxJ2QYzjoez/1mjTm/iQ6+7El7Af1v3lJTtU+NJ9TpzPYFw==",
+ "_integrity": "sha512-AOq5kwJpPVHHQC+V1Nh/Ab7/sP0UGfjZ49pF2kP/lW68gtP6XTFA4J/O76UYFHbfzBgwQJHzH3IkMIC1PG96Cw==",
"_location": "/ccxt",
"_phantomChildren": {},
"_requested": {
- "type": "tag",
+ "type": "version",
"registry": true,
- "raw": "ccxt",
+ "raw": "ccxt@1.42.67",
"name": "ccxt",
"escapedName": "ccxt",
- "rawSpec": "",
+ "rawSpec": "1.42.67",
"saveSpec": null,
- "fetchSpec": "latest"
+ "fetchSpec": "1.42.67"
},
"_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.67.tgz",
+ "_shasum": "3032fa256d75891af2834f0c5777012ab155cf6f",
+ "_spec": "ccxt@1.42.67",
+ "_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.67"
}
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..c6f795053 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.67",
+ "resolved": "https://registry.npmjs.org/ccxt/-/ccxt-1.42.67.tgz",
+ "integrity": "sha512-AOq5kwJpPVHHQC+V1Nh/Ab7/sP0UGfjZ49pF2kP/lW68gtP6XTFA4J/O76UYFHbfzBgwQJHzH3IkMIC1PG96Cw=="
}
}
}
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
+}