ccxt-ir 4.3.46.0.2__py2.py3-none-any.whl → 4.5.0__py2.py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (528) hide show
  1. ccxt/__init__.py +39 -35
  2. ccxt/abantether.py +9 -9
  3. ccxt/abstract/alpaca.py +4 -0
  4. ccxt/abstract/apex.py +31 -0
  5. ccxt/abstract/bigone.py +1 -1
  6. ccxt/abstract/binance.py +106 -48
  7. ccxt/abstract/binancecoinm.py +106 -48
  8. ccxt/abstract/binanceus.py +141 -83
  9. ccxt/abstract/binanceusdm.py +106 -48
  10. ccxt/abstract/bingx.py +50 -1
  11. ccxt/abstract/bitbank.py +5 -0
  12. ccxt/abstract/bitfinex.py +136 -65
  13. ccxt/abstract/bitflyer.py +1 -0
  14. ccxt/abstract/bitget.py +67 -0
  15. ccxt/abstract/bitmart.py +19 -1
  16. ccxt/abstract/bitopro.py +1 -0
  17. ccxt/abstract/bitrue.py +68 -68
  18. ccxt/abstract/bitstamp.py +1 -0
  19. ccxt/abstract/blofin.py +30 -0
  20. ccxt/abstract/btcbox.py +2 -0
  21. ccxt/abstract/bybit.py +28 -13
  22. ccxt/abstract/cex.py +28 -29
  23. ccxt/abstract/coinbaseexchange.py +1 -0
  24. ccxt/abstract/coinbaseinternational.py +1 -1
  25. ccxt/abstract/cryptocom.py +16 -0
  26. ccxt/abstract/cryptomus.py +20 -0
  27. ccxt/abstract/defx.py +69 -0
  28. ccxt/abstract/deribit.py +1 -0
  29. ccxt/abstract/derive.py +117 -0
  30. ccxt/abstract/digifinex.py +1 -0
  31. ccxt/abstract/ellipx.py +25 -0
  32. ccxt/abstract/foxbit.py +26 -0
  33. ccxt/abstract/gate.py +19 -0
  34. ccxt/abstract/gateio.py +19 -0
  35. ccxt/abstract/gemini.py +1 -0
  36. ccxt/abstract/hibachi.py +26 -0
  37. ccxt/abstract/hyperliquid.py +1 -1
  38. ccxt/abstract/independentreserve.py +6 -0
  39. ccxt/abstract/kraken.py +1 -0
  40. ccxt/abstract/krakenfutures.py +4 -0
  41. ccxt/abstract/kucoin.py +10 -0
  42. ccxt/abstract/kucoinfutures.py +18 -0
  43. ccxt/abstract/lbank.py +2 -1
  44. ccxt/abstract/luno.py +1 -0
  45. ccxt/abstract/mexc.py +2 -0
  46. ccxt/abstract/modetrade.py +119 -0
  47. ccxt/abstract/myokx.py +349 -0
  48. ccxt/abstract/oceanex.py +5 -0
  49. ccxt/abstract/okx.py +25 -0
  50. ccxt/abstract/okxus.py +349 -0
  51. ccxt/abstract/onetrading.py +0 -12
  52. ccxt/abstract/paradex.py +23 -0
  53. ccxt/abstract/phemex.py +2 -0
  54. ccxt/abstract/poloniex.py +36 -0
  55. ccxt/abstract/tradeogre.py +3 -1
  56. ccxt/abstract/upbit.py +51 -34
  57. ccxt/abstract/whitebit.py +16 -0
  58. ccxt/abstract/woo.py +64 -6
  59. ccxt/abstract/xt.py +10 -5
  60. ccxt/afratether.py +7 -7
  61. ccxt/alpaca.py +828 -51
  62. ccxt/apex.py +1875 -0
  63. ccxt/arzinja.py +7 -7
  64. ccxt/arzplus.py +9 -9
  65. ccxt/ascendex.py +501 -306
  66. ccxt/async_support/__init__.py +39 -35
  67. ccxt/async_support/abantether.py +10 -10
  68. ccxt/async_support/afratether.py +9 -9
  69. ccxt/async_support/alpaca.py +828 -51
  70. ccxt/async_support/apex.py +1875 -0
  71. ccxt/async_support/arzinja.py +10 -10
  72. ccxt/async_support/arzplus.py +12 -12
  73. ccxt/async_support/ascendex.py +502 -306
  74. ccxt/async_support/base/exchange.py +303 -89
  75. ccxt/async_support/base/ws/cache.py +9 -3
  76. ccxt/async_support/base/ws/client.py +173 -38
  77. ccxt/async_support/base/ws/future.py +25 -37
  78. ccxt/async_support/bequant.py +5 -3
  79. ccxt/async_support/bigone.py +279 -144
  80. ccxt/async_support/binance.py +2347 -1158
  81. ccxt/async_support/binancecoinm.py +9 -3
  82. ccxt/async_support/binanceus.py +17 -3
  83. ccxt/async_support/binanceusdm.py +9 -4
  84. ccxt/async_support/bingx.py +2962 -920
  85. ccxt/async_support/bit2c.py +147 -27
  86. ccxt/async_support/bitbank.py +151 -23
  87. ccxt/async_support/bitbns.py +104 -30
  88. ccxt/async_support/bitfinex.py +3291 -1113
  89. ccxt/async_support/bitflyer.py +202 -27
  90. ccxt/async_support/bitget.py +3683 -1538
  91. ccxt/async_support/bithumb.py +195 -38
  92. ccxt/async_support/bitimen.py +12 -12
  93. ccxt/async_support/bitir.py +38 -38
  94. ccxt/async_support/bitmart.py +1288 -350
  95. ccxt/async_support/bitmex.py +260 -75
  96. ccxt/async_support/bitopro.py +262 -62
  97. ccxt/async_support/bitpin.py +17 -16
  98. ccxt/async_support/bitrue.py +459 -290
  99. ccxt/async_support/bitso.py +199 -54
  100. ccxt/async_support/bitstamp.py +230 -96
  101. ccxt/async_support/bitteam.py +167 -25
  102. ccxt/async_support/{huobijp.py → bittrade.py} +158 -30
  103. ccxt/async_support/bitvavo.py +213 -49
  104. ccxt/async_support/blockchaincom.py +160 -46
  105. ccxt/async_support/blofin.py +502 -120
  106. ccxt/async_support/btcalpha.py +169 -31
  107. ccxt/async_support/btcbox.py +292 -23
  108. ccxt/async_support/btcmarkets.py +211 -58
  109. ccxt/async_support/btcturk.py +161 -38
  110. ccxt/async_support/bybit.py +1775 -1030
  111. ccxt/async_support/cex.py +1440 -1303
  112. ccxt/async_support/coinbase.py +724 -212
  113. ccxt/async_support/coinbaseadvanced.py +2 -1
  114. ccxt/async_support/coinbaseexchange.py +388 -89
  115. ccxt/async_support/coinbaseinternational.py +412 -57
  116. ccxt/async_support/coincatch.py +177 -78
  117. ccxt/async_support/coincheck.py +135 -19
  118. ccxt/async_support/coinex.py +606 -232
  119. ccxt/async_support/coinmate.py +189 -63
  120. ccxt/async_support/coinmetro.py +195 -54
  121. ccxt/async_support/coinone.py +158 -51
  122. ccxt/async_support/coinsph.py +336 -61
  123. ccxt/async_support/coinspot.py +151 -52
  124. ccxt/async_support/cryptocom.py +661 -111
  125. ccxt/async_support/cryptomus.py +1137 -0
  126. ccxt/async_support/defx.py +2071 -0
  127. ccxt/async_support/delta.py +299 -99
  128. ccxt/async_support/deribit.py +348 -126
  129. ccxt/async_support/derive.py +2572 -0
  130. ccxt/async_support/digifinex.py +430 -214
  131. ccxt/async_support/ellipx.py +2029 -0
  132. ccxt/async_support/eterex.py +10 -10
  133. ccxt/async_support/excoino.py +31 -31
  134. ccxt/async_support/exir.py +14 -14
  135. ccxt/async_support/exmo.py +344 -131
  136. ccxt/async_support/exnovin.py +10 -10
  137. ccxt/async_support/farhadexchange.py +12 -12
  138. ccxt/async_support/fmfwio.py +2 -1
  139. ccxt/async_support/foxbit.py +1935 -0
  140. ccxt/async_support/gate.py +1351 -529
  141. ccxt/async_support/gateio.py +2 -1
  142. ccxt/async_support/gemini.py +144 -39
  143. ccxt/async_support/hashkey.py +152 -109
  144. ccxt/async_support/hibachi.py +2080 -0
  145. ccxt/async_support/hitbtc.py +395 -167
  146. ccxt/async_support/hitobit.py +12 -12
  147. ccxt/async_support/hollaex.py +307 -119
  148. ccxt/async_support/htx.py +851 -383
  149. ccxt/async_support/huobi.py +2 -1
  150. ccxt/async_support/hyperliquid.py +1848 -536
  151. ccxt/async_support/independentreserve.py +288 -15
  152. ccxt/async_support/indodax.py +190 -33
  153. ccxt/async_support/jibitex.py +12 -12
  154. ccxt/async_support/kraken.py +795 -351
  155. ccxt/async_support/krakenfutures.py +214 -62
  156. ccxt/async_support/kucoin.py +715 -396
  157. ccxt/async_support/kucoinfutures.py +652 -89
  158. ccxt/async_support/latoken.py +217 -113
  159. ccxt/async_support/lbank.py +425 -97
  160. ccxt/async_support/luno.py +382 -35
  161. ccxt/async_support/mercado.py +113 -6
  162. ccxt/async_support/mexc.py +874 -437
  163. ccxt/async_support/modetrade.py +2818 -0
  164. ccxt/async_support/myokx.py +54 -0
  165. ccxt/async_support/ndax.py +221 -64
  166. ccxt/async_support/nobitex.py +31 -37
  167. ccxt/async_support/novadax.py +190 -34
  168. ccxt/async_support/oceanex.py +217 -28
  169. ccxt/async_support/okcoin.py +253 -145
  170. ccxt/async_support/okexchange.py +11 -11
  171. ccxt/async_support/okx.py +1088 -351
  172. ccxt/async_support/okxus.py +54 -0
  173. ccxt/async_support/ompfinex.py +25 -24
  174. ccxt/async_support/onetrading.py +213 -392
  175. ccxt/async_support/oxfun.py +245 -166
  176. ccxt/async_support/p2b.py +151 -29
  177. ccxt/async_support/paradex.py +562 -49
  178. ccxt/async_support/paymium.py +82 -19
  179. ccxt/async_support/phemex.py +713 -172
  180. ccxt/async_support/poloniex.py +1602 -283
  181. ccxt/async_support/probit.py +224 -95
  182. ccxt/async_support/ramzinex.py +30 -27
  183. ccxt/async_support/sarmayex.py +9 -9
  184. ccxt/async_support/sarrafex.py +13 -13
  185. ccxt/async_support/tabdeal.py +14 -13
  186. ccxt/async_support/tetherland.py +9 -9
  187. ccxt/async_support/timex.py +210 -51
  188. ccxt/async_support/tokocrypto.py +167 -47
  189. ccxt/async_support/tradeogre.py +266 -31
  190. ccxt/async_support/twox.py +9 -9
  191. ccxt/async_support/ubitex.py +12 -12
  192. ccxt/async_support/upbit.py +568 -165
  193. ccxt/async_support/vertex.py +160 -32
  194. ccxt/async_support/wallex.py +12 -12
  195. ccxt/async_support/wavesexchange.py +165 -30
  196. ccxt/async_support/whitebit.py +975 -127
  197. ccxt/async_support/woo.py +1918 -1016
  198. ccxt/async_support/woofipro.py +433 -141
  199. ccxt/async_support/xt.py +649 -193
  200. ccxt/async_support/yobit.py +195 -70
  201. ccxt/async_support/zaif.py +91 -15
  202. ccxt/async_support/zonda.py +151 -36
  203. ccxt/base/decimal_to_precision.py +14 -10
  204. ccxt/base/errors.py +49 -18
  205. ccxt/base/exchange.py +1556 -450
  206. ccxt/base/precise.py +10 -0
  207. ccxt/base/types.py +114 -6
  208. ccxt/bequant.py +5 -3
  209. ccxt/bigone.py +279 -144
  210. ccxt/binance.py +2347 -1158
  211. ccxt/binancecoinm.py +9 -3
  212. ccxt/binanceus.py +17 -3
  213. ccxt/binanceusdm.py +9 -4
  214. ccxt/bingx.py +2962 -920
  215. ccxt/bit2c.py +147 -27
  216. ccxt/bitbank.py +151 -23
  217. ccxt/bitbns.py +104 -30
  218. ccxt/bitfinex.py +3290 -1113
  219. ccxt/bitflyer.py +202 -27
  220. ccxt/bitget.py +3683 -1538
  221. ccxt/bithumb.py +194 -38
  222. ccxt/bitimen.py +9 -9
  223. ccxt/bitir.py +35 -35
  224. ccxt/bitmart.py +1288 -350
  225. ccxt/bitmex.py +260 -75
  226. ccxt/bitopro.py +262 -62
  227. ccxt/bitpin.py +15 -14
  228. ccxt/bitrue.py +459 -290
  229. ccxt/bitso.py +199 -54
  230. ccxt/bitstamp.py +230 -96
  231. ccxt/bitteam.py +167 -25
  232. ccxt/{huobijp.py → bittrade.py} +158 -30
  233. ccxt/bitvavo.py +213 -49
  234. ccxt/blockchaincom.py +160 -46
  235. ccxt/blofin.py +502 -120
  236. ccxt/btcalpha.py +169 -31
  237. ccxt/btcbox.py +291 -23
  238. ccxt/btcmarkets.py +211 -58
  239. ccxt/btcturk.py +161 -38
  240. ccxt/bybit.py +1775 -1030
  241. ccxt/cex.py +1439 -1303
  242. ccxt/coinbase.py +724 -212
  243. ccxt/coinbaseadvanced.py +2 -1
  244. ccxt/coinbaseexchange.py +388 -89
  245. ccxt/coinbaseinternational.py +412 -57
  246. ccxt/coincatch.py +177 -78
  247. ccxt/coincheck.py +135 -19
  248. ccxt/coinex.py +606 -232
  249. ccxt/coinmate.py +189 -63
  250. ccxt/coinmetro.py +194 -54
  251. ccxt/coinone.py +158 -51
  252. ccxt/coinsph.py +336 -61
  253. ccxt/coinspot.py +151 -52
  254. ccxt/cryptocom.py +661 -111
  255. ccxt/cryptomus.py +1137 -0
  256. ccxt/defx.py +2070 -0
  257. ccxt/delta.py +299 -99
  258. ccxt/deribit.py +348 -126
  259. ccxt/derive.py +2571 -0
  260. ccxt/digifinex.py +430 -214
  261. ccxt/ellipx.py +2029 -0
  262. ccxt/eterex.py +7 -7
  263. ccxt/excoino.py +29 -29
  264. ccxt/exir.py +11 -11
  265. ccxt/exmo.py +343 -131
  266. ccxt/exnovin.py +8 -8
  267. ccxt/farhadexchange.py +10 -10
  268. ccxt/fmfwio.py +2 -1
  269. ccxt/foxbit.py +1935 -0
  270. ccxt/gate.py +1351 -529
  271. ccxt/gateio.py +2 -1
  272. ccxt/gemini.py +144 -39
  273. ccxt/hashkey.py +152 -109
  274. ccxt/hibachi.py +2079 -0
  275. ccxt/hitbtc.py +395 -167
  276. ccxt/hitobit.py +9 -9
  277. ccxt/hollaex.py +307 -119
  278. ccxt/htx.py +851 -383
  279. ccxt/huobi.py +2 -1
  280. ccxt/hyperliquid.py +1848 -536
  281. ccxt/independentreserve.py +287 -15
  282. ccxt/indodax.py +190 -33
  283. ccxt/jibitex.py +9 -9
  284. ccxt/kraken.py +794 -351
  285. ccxt/krakenfutures.py +214 -62
  286. ccxt/kucoin.py +715 -396
  287. ccxt/kucoinfutures.py +652 -89
  288. ccxt/latoken.py +217 -113
  289. ccxt/lbank.py +425 -97
  290. ccxt/luno.py +382 -35
  291. ccxt/mercado.py +113 -6
  292. ccxt/mexc.py +873 -437
  293. ccxt/modetrade.py +2818 -0
  294. ccxt/myokx.py +54 -0
  295. ccxt/ndax.py +221 -64
  296. ccxt/nobitex.py +29 -35
  297. ccxt/novadax.py +190 -34
  298. ccxt/oceanex.py +217 -28
  299. ccxt/okcoin.py +253 -145
  300. ccxt/okexchange.py +9 -9
  301. ccxt/okx.py +1088 -351
  302. ccxt/okxus.py +54 -0
  303. ccxt/ompfinex.py +22 -21
  304. ccxt/onetrading.py +213 -392
  305. ccxt/oxfun.py +245 -166
  306. ccxt/p2b.py +151 -29
  307. ccxt/paradex.py +562 -49
  308. ccxt/paymium.py +82 -19
  309. ccxt/phemex.py +712 -172
  310. ccxt/poloniex.py +1601 -283
  311. ccxt/pro/__init__.py +76 -17
  312. ccxt/pro/alpaca.py +21 -6
  313. ccxt/pro/apex.py +984 -0
  314. ccxt/pro/ascendex.py +58 -10
  315. ccxt/pro/bequant.py +6 -1
  316. ccxt/pro/binance.py +728 -156
  317. ccxt/pro/binancecoinm.py +6 -2
  318. ccxt/pro/binanceus.py +8 -4
  319. ccxt/pro/binanceusdm.py +7 -2
  320. ccxt/pro/bingx.py +333 -142
  321. ccxt/pro/bitfinex.py +727 -262
  322. ccxt/pro/bitget.py +570 -79
  323. ccxt/pro/bithumb.py +20 -6
  324. ccxt/pro/bitmart.py +216 -87
  325. ccxt/pro/bitmex.py +47 -9
  326. ccxt/pro/bitopro.py +26 -14
  327. ccxt/pro/bitrue.py +22 -22
  328. ccxt/pro/bitstamp.py +54 -21
  329. ccxt/pro/{huobijp.py → bittrade.py} +7 -6
  330. ccxt/pro/bitvavo.py +191 -67
  331. ccxt/pro/blockchaincom.py +21 -8
  332. ccxt/pro/blofin.py +9 -1
  333. ccxt/pro/bybit.py +632 -245
  334. ccxt/pro/cex.py +59 -24
  335. ccxt/pro/coinbase.py +102 -73
  336. ccxt/pro/coinbaseadvanced.py +2 -1
  337. ccxt/pro/coinbaseexchange.py +8 -8
  338. ccxt/pro/coinbaseinternational.py +181 -25
  339. ccxt/pro/coincatch.py +6 -7
  340. ccxt/pro/coincheck.py +11 -6
  341. ccxt/pro/coinex.py +967 -665
  342. ccxt/pro/coinone.py +16 -9
  343. ccxt/pro/cryptocom.py +448 -45
  344. ccxt/pro/defx.py +831 -0
  345. ccxt/pro/deribit.py +150 -14
  346. ccxt/pro/derive.py +704 -0
  347. ccxt/pro/exmo.py +239 -6
  348. ccxt/pro/gate.py +623 -65
  349. ccxt/pro/gateio.py +2 -1
  350. ccxt/pro/gemini.py +27 -11
  351. ccxt/pro/hashkey.py +2 -2
  352. ccxt/pro/hitbtc.py +196 -91
  353. ccxt/pro/hollaex.py +23 -7
  354. ccxt/pro/htx.py +51 -14
  355. ccxt/pro/huobi.py +2 -1
  356. ccxt/pro/hyperliquid.py +591 -27
  357. ccxt/pro/independentreserve.py +9 -6
  358. ccxt/pro/kraken.py +640 -320
  359. ccxt/pro/krakenfutures.py +62 -35
  360. ccxt/pro/kucoin.py +267 -46
  361. ccxt/pro/kucoinfutures.py +165 -21
  362. ccxt/pro/lbank.py +102 -21
  363. ccxt/pro/luno.py +12 -8
  364. ccxt/pro/mexc.py +877 -111
  365. ccxt/pro/modetrade.py +1271 -0
  366. ccxt/pro/myokx.py +38 -0
  367. ccxt/pro/ndax.py +15 -2
  368. ccxt/pro/okcoin.py +23 -4
  369. ccxt/pro/okx.py +573 -98
  370. ccxt/pro/okxus.py +38 -0
  371. ccxt/pro/onetrading.py +30 -13
  372. ccxt/pro/oxfun.py +131 -27
  373. ccxt/pro/p2b.py +88 -22
  374. ccxt/pro/paradex.py +3 -3
  375. ccxt/pro/phemex.py +75 -21
  376. ccxt/pro/poloniex.py +124 -41
  377. ccxt/pro/probit.py +87 -80
  378. ccxt/pro/tradeogre.py +272 -0
  379. ccxt/pro/upbit.py +152 -12
  380. ccxt/pro/vertex.py +8 -3
  381. ccxt/pro/whitebit.py +58 -5
  382. ccxt/pro/woo.py +228 -37
  383. ccxt/pro/woofipro.py +106 -18
  384. ccxt/pro/xt.py +111 -5
  385. ccxt/probit.py +224 -95
  386. ccxt/protobuf/__init__.py +0 -0
  387. ccxt/protobuf/mexc/PrivateAccountV3Api_pb2.py +37 -0
  388. ccxt/protobuf/mexc/PrivateDealsV3Api_pb2.py +37 -0
  389. ccxt/protobuf/mexc/PrivateOrdersV3Api_pb2.py +37 -0
  390. ccxt/protobuf/mexc/PublicAggreBookTickerV3Api_pb2.py +37 -0
  391. ccxt/protobuf/mexc/PublicAggreDealsV3Api_pb2.py +39 -0
  392. ccxt/protobuf/mexc/PublicAggreDepthsV3Api_pb2.py +39 -0
  393. ccxt/protobuf/mexc/PublicBookTickerBatchV3Api_pb2.py +38 -0
  394. ccxt/protobuf/mexc/PublicBookTickerV3Api_pb2.py +37 -0
  395. ccxt/protobuf/mexc/PublicDealsV3Api_pb2.py +39 -0
  396. ccxt/protobuf/mexc/PublicIncreaseDepthsBatchV3Api_pb2.py +38 -0
  397. ccxt/protobuf/mexc/PublicIncreaseDepthsV3Api_pb2.py +39 -0
  398. ccxt/protobuf/mexc/PublicLimitDepthsV3Api_pb2.py +39 -0
  399. ccxt/protobuf/mexc/PublicMiniTickerV3Api_pb2.py +37 -0
  400. ccxt/protobuf/mexc/PublicMiniTickersV3Api_pb2.py +38 -0
  401. ccxt/protobuf/mexc/PublicSpotKlineV3Api_pb2.py +37 -0
  402. ccxt/protobuf/mexc/PushDataV3ApiWrapper_pb2.py +52 -0
  403. ccxt/protobuf/mexc/__init__.py +0 -0
  404. ccxt/ramzinex.py +28 -25
  405. ccxt/sarmayex.py +7 -7
  406. ccxt/sarrafex.py +10 -10
  407. ccxt/static_dependencies/__init__.py +1 -1
  408. ccxt/static_dependencies/lark/py.typed +0 -0
  409. ccxt/static_dependencies/marshmallow/py.typed +0 -0
  410. ccxt/static_dependencies/marshmallow_dataclass/py.typed +0 -0
  411. ccxt/static_dependencies/marshmallow_oneofschema/py.typed +0 -0
  412. ccxt/tabdeal.py +12 -11
  413. ccxt/test/tests_async.py +261 -57
  414. ccxt/test/tests_helpers.py +1 -3
  415. ccxt/test/tests_init.py +4 -3
  416. ccxt/test/tests_sync.py +261 -57
  417. ccxt/tetherland.py +7 -7
  418. ccxt/timex.py +210 -51
  419. ccxt/tokocrypto.py +167 -47
  420. ccxt/tradeogre.py +266 -31
  421. ccxt/twox.py +7 -7
  422. ccxt/ubitex.py +9 -9
  423. ccxt/upbit.py +568 -165
  424. ccxt/vertex.py +160 -32
  425. ccxt/wallex.py +9 -9
  426. ccxt/wavesexchange.py +165 -30
  427. ccxt/whitebit.py +975 -127
  428. ccxt/woo.py +1917 -1016
  429. ccxt/woofipro.py +432 -141
  430. ccxt/xt.py +649 -193
  431. ccxt/yobit.py +194 -70
  432. ccxt/zaif.py +91 -15
  433. ccxt/zonda.py +151 -36
  434. {ccxt_ir-4.3.46.0.2.dist-info → ccxt_ir-4.5.0.dist-info}/METADATA +225 -73
  435. ccxt_ir-4.5.0.dist-info/RECORD +743 -0
  436. {ccxt_ir-4.3.46.0.2.dist-info → ccxt_ir-4.5.0.dist-info}/WHEEL +1 -1
  437. ccxt/abstract/ace.py +0 -15
  438. ccxt/abstract/bitbay.py +0 -53
  439. ccxt/abstract/bitcoincom.py +0 -115
  440. ccxt/abstract/bitfinex2.py +0 -139
  441. ccxt/abstract/bitpanda.py +0 -35
  442. ccxt/abstract/bl3p.py +0 -19
  443. ccxt/abstract/coinlist.py +0 -54
  444. ccxt/abstract/currencycom.py +0 -68
  445. ccxt/abstract/hitbtc3.py +0 -115
  446. ccxt/abstract/idex.py +0 -26
  447. ccxt/abstract/kuna.py +0 -182
  448. ccxt/abstract/lykke.py +0 -29
  449. ccxt/abstract/poloniexfutures.py +0 -48
  450. ccxt/abstract/wazirx.py +0 -30
  451. ccxt/ace.py +0 -1012
  452. ccxt/async_support/ace.py +0 -1012
  453. ccxt/async_support/base/ws/aiohttp_client.py +0 -125
  454. ccxt/async_support/base/ws/fast_client.py +0 -96
  455. ccxt/async_support/bitbay.py +0 -17
  456. ccxt/async_support/bitcoincom.py +0 -17
  457. ccxt/async_support/bitfinex2.py +0 -3552
  458. ccxt/async_support/bitpanda.py +0 -16
  459. ccxt/async_support/bl3p.py +0 -485
  460. ccxt/async_support/coinlist.py +0 -2243
  461. ccxt/async_support/currencycom.py +0 -1950
  462. ccxt/async_support/hitbtc3.py +0 -16
  463. ccxt/async_support/idex.py +0 -1766
  464. ccxt/async_support/kuna.py +0 -1841
  465. ccxt/async_support/lykke.py +0 -1270
  466. ccxt/async_support/poloniexfutures.py +0 -1717
  467. ccxt/async_support/wazirx.py +0 -1224
  468. ccxt/bitbay.py +0 -17
  469. ccxt/bitcoincom.py +0 -17
  470. ccxt/bitfinex2.py +0 -3552
  471. ccxt/bitpanda.py +0 -16
  472. ccxt/bl3p.py +0 -485
  473. ccxt/coinlist.py +0 -2243
  474. ccxt/currencycom.py +0 -1950
  475. ccxt/hitbtc3.py +0 -16
  476. ccxt/idex.py +0 -1766
  477. ccxt/kuna.py +0 -1841
  478. ccxt/lykke.py +0 -1270
  479. ccxt/poloniexfutures.py +0 -1717
  480. ccxt/pro/bitcoincom.py +0 -34
  481. ccxt/pro/bitfinex2.py +0 -1083
  482. ccxt/pro/bitpanda.py +0 -15
  483. ccxt/pro/currencycom.py +0 -536
  484. ccxt/pro/idex.py +0 -672
  485. ccxt/pro/poloniexfutures.py +0 -990
  486. ccxt/pro/wazirx.py +0 -749
  487. ccxt/test/base/__init__.py +0 -29
  488. ccxt/test/base/test_account.py +0 -26
  489. ccxt/test/base/test_balance.py +0 -56
  490. ccxt/test/base/test_borrow_interest.py +0 -35
  491. ccxt/test/base/test_borrow_rate.py +0 -32
  492. ccxt/test/base/test_calculate_fee.py +0 -51
  493. ccxt/test/base/test_crypto.py +0 -127
  494. ccxt/test/base/test_currency.py +0 -76
  495. ccxt/test/base/test_datetime.py +0 -109
  496. ccxt/test/base/test_decimal_to_precision.py +0 -392
  497. ccxt/test/base/test_deep_extend.py +0 -68
  498. ccxt/test/base/test_deposit_withdrawal.py +0 -50
  499. ccxt/test/base/test_exchange_datetime_functions.py +0 -76
  500. ccxt/test/base/test_funding_rate_history.py +0 -29
  501. ccxt/test/base/test_last_price.py +0 -31
  502. ccxt/test/base/test_ledger_entry.py +0 -45
  503. ccxt/test/base/test_ledger_item.py +0 -48
  504. ccxt/test/base/test_leverage_tier.py +0 -33
  505. ccxt/test/base/test_liquidation.py +0 -50
  506. ccxt/test/base/test_margin_mode.py +0 -24
  507. ccxt/test/base/test_margin_modification.py +0 -35
  508. ccxt/test/base/test_market.py +0 -193
  509. ccxt/test/base/test_number.py +0 -411
  510. ccxt/test/base/test_ohlcv.py +0 -33
  511. ccxt/test/base/test_open_interest.py +0 -32
  512. ccxt/test/base/test_order.py +0 -64
  513. ccxt/test/base/test_order_book.py +0 -69
  514. ccxt/test/base/test_position.py +0 -60
  515. ccxt/test/base/test_shared_methods.py +0 -353
  516. ccxt/test/base/test_status.py +0 -24
  517. ccxt/test/base/test_throttle.py +0 -126
  518. ccxt/test/base/test_ticker.py +0 -92
  519. ccxt/test/base/test_trade.py +0 -47
  520. ccxt/test/base/test_trading_fee.py +0 -26
  521. ccxt/test/base/test_transaction.py +0 -39
  522. ccxt/test/test_async.py +0 -1649
  523. ccxt/test/test_sync.py +0 -1648
  524. ccxt/wazirx.py +0 -1224
  525. ccxt_ir-4.3.46.0.2.dist-info/RECORD +0 -772
  526. /ccxt/abstract/{huobijp.py → bittrade.py} +0 -0
  527. {ccxt_ir-4.3.46.0.2.dist-info → ccxt_ir-4.5.0.dist-info/licenses}/LICENSE.txt +0 -0
  528. {ccxt_ir-4.3.46.0.2.dist-info → ccxt_ir-4.5.0.dist-info}/top_level.txt +0 -0
ccxt/cryptocom.py CHANGED
@@ -6,7 +6,8 @@
6
6
  from ccxt.base.exchange import Exchange
7
7
  from ccxt.abstract.cryptocom import ImplicitAPI
8
8
  import hashlib
9
- from ccxt.base.types import Account, Balances, Currency, Int, Market, Num, Order, OrderBook, OrderRequest, CancellationRequest, OrderSide, OrderType, Str, Strings, Ticker, Tickers, Trade, Transaction
9
+ import math
10
+ from ccxt.base.types import Account, Any, Balances, Currencies, Currency, DepositAddress, Int, LedgerEntry, Market, Num, Order, OrderBook, OrderRequest, CancellationRequest, OrderSide, OrderType, Position, Str, Strings, Ticker, Tickers, FundingRate, Trade, TradingFeeInterface, TradingFees, Transaction
10
11
  from typing import List
11
12
  from ccxt.base.errors import ExchangeError
12
13
  from ccxt.base.errors import AuthenticationError
@@ -17,17 +18,20 @@ from ccxt.base.errors import BadRequest
17
18
  from ccxt.base.errors import BadSymbol
18
19
  from ccxt.base.errors import InsufficientFunds
19
20
  from ccxt.base.errors import InvalidOrder
21
+ from ccxt.base.errors import OrderNotFound
20
22
  from ccxt.base.errors import NotSupported
21
23
  from ccxt.base.errors import DDoSProtection
24
+ from ccxt.base.errors import RateLimitExceeded
22
25
  from ccxt.base.errors import OnMaintenance
23
26
  from ccxt.base.errors import InvalidNonce
27
+ from ccxt.base.errors import RequestTimeout
24
28
  from ccxt.base.decimal_to_precision import TICK_SIZE
25
29
  from ccxt.base.precise import Precise
26
30
 
27
31
 
28
32
  class cryptocom(Exchange, ImplicitAPI):
29
33
 
30
- def describe(self):
34
+ def describe(self) -> Any:
31
35
  return self.deep_extend(super(cryptocom, self).describe(), {
32
36
  'id': 'cryptocom',
33
37
  'name': 'Crypto.com',
@@ -55,6 +59,9 @@ class cryptocom(Exchange, ImplicitAPI):
55
59
  'createMarketSellOrderWithCost': False,
56
60
  'createOrder': True,
57
61
  'createOrders': True,
62
+ 'createStopOrder': True,
63
+ 'createTriggerOrder': True,
64
+ 'editOrder': True,
58
65
  'fetchAccounts': True,
59
66
  'fetchBalance': True,
60
67
  'fetchBidsAsks': False,
@@ -64,15 +71,16 @@ class cryptocom(Exchange, ImplicitAPI):
64
71
  'fetchClosedOrders': 'emulated',
65
72
  'fetchCrossBorrowRate': False,
66
73
  'fetchCrossBorrowRates': False,
67
- 'fetchCurrencies': False,
74
+ 'fetchCurrencies': True,
68
75
  'fetchDepositAddress': True,
76
+ 'fetchDepositAddresses': False,
69
77
  'fetchDepositAddressesByNetwork': True,
70
78
  'fetchDeposits': True,
71
79
  'fetchDepositsWithdrawals': False,
72
80
  'fetchDepositWithdrawFee': 'emulated',
73
81
  'fetchDepositWithdrawFees': True,
74
82
  'fetchFundingHistory': False,
75
- 'fetchFundingRate': False,
83
+ 'fetchFundingRate': True,
76
84
  'fetchFundingRateHistory': True,
77
85
  'fetchFundingRates': False,
78
86
  'fetchGreeks': False,
@@ -106,8 +114,8 @@ class cryptocom(Exchange, ImplicitAPI):
106
114
  'fetchTickers': True,
107
115
  'fetchTime': False,
108
116
  'fetchTrades': True,
109
- 'fetchTradingFee': False,
110
- 'fetchTradingFees': False,
117
+ 'fetchTradingFee': True,
118
+ 'fetchTradingFees': True,
111
119
  'fetchTransactionFees': False,
112
120
  'fetchTransactions': False,
113
121
  'fetchTransfers': False,
@@ -146,6 +154,7 @@ class cryptocom(Exchange, ImplicitAPI):
146
154
  'derivatives': 'https://uat-api.3ona.co/v2',
147
155
  },
148
156
  'api': {
157
+ 'base': 'https://api.crypto.com',
149
158
  'v1': 'https://api.crypto.com/exchange/v1',
150
159
  'v2': 'https://api.crypto.com/v2',
151
160
  'derivatives': 'https://deriv-api.crypto.com/v1',
@@ -153,7 +162,7 @@ class cryptocom(Exchange, ImplicitAPI):
153
162
  'www': 'https://crypto.com/',
154
163
  'referral': {
155
164
  'url': 'https://crypto.com/exch/kdacthrnxt',
156
- 'discount': 0.15,
165
+ 'discount': 0.75,
157
166
  },
158
167
  'doc': [
159
168
  'https://exchange-docs.crypto.com/exchange/v1/rest-ws/index.html',
@@ -163,6 +172,13 @@ class cryptocom(Exchange, ImplicitAPI):
163
172
  'fees': 'https://crypto.com/exchange/document/fees-limits',
164
173
  },
165
174
  'api': {
175
+ 'base': {
176
+ 'public': {
177
+ 'get': {
178
+ 'v1/public/get-announcements': 1, # no description of rate limit
179
+ },
180
+ },
181
+ },
166
182
  'v1': {
167
183
  'public': {
168
184
  'get': {
@@ -175,6 +191,10 @@ class cryptocom(Exchange, ImplicitAPI):
175
191
  'public/get-valuations': 1,
176
192
  'public/get-expired-settlement-price': 10 / 3,
177
193
  'public/get-insurance': 1,
194
+ 'public/get-risk-parameters': 1,
195
+ },
196
+ 'post': {
197
+ 'public/staking/get-conversion-rate': 2,
178
198
  },
179
199
  },
180
200
  'private': {
@@ -185,6 +205,7 @@ class cryptocom(Exchange, ImplicitAPI):
185
205
  'private/user-balance-history': 10 / 3,
186
206
  'private/get-positions': 10 / 3,
187
207
  'private/create-order': 2 / 3,
208
+ 'private/amend-order': 4 / 3, # no description of rate limit
188
209
  'private/create-order-list': 10 / 3,
189
210
  'private/cancel-order': 2 / 3,
190
211
  'private/cancel-order-list': 10 / 3,
@@ -205,6 +226,18 @@ class cryptocom(Exchange, ImplicitAPI):
205
226
  'private/get-accounts': 10 / 3,
206
227
  'private/get-withdrawal-history': 10 / 3,
207
228
  'private/get-deposit-history': 10 / 3,
229
+ 'private/get-fee-rate': 2,
230
+ 'private/get-instrument-fee-rate': 2,
231
+ 'private/staking/stake': 2,
232
+ 'private/staking/unstake': 2,
233
+ 'private/staking/get-staking-position': 2,
234
+ 'private/staking/get-staking-instruments': 2,
235
+ 'private/staking/get-open-stake': 2,
236
+ 'private/staking/get-stake-history': 2,
237
+ 'private/staking/get-reward-history': 2,
238
+ 'private/staking/convert': 2,
239
+ 'private/staking/get-open-convert': 2,
240
+ 'private/staking/get-convert-history': 2,
208
241
  },
209
242
  },
210
243
  },
@@ -344,6 +377,102 @@ class cryptocom(Exchange, ImplicitAPI):
344
377
  },
345
378
  'broker': 'CCXT',
346
379
  },
380
+ 'features': {
381
+ 'default': {
382
+ 'sandbox': True,
383
+ 'createOrder': {
384
+ 'marginMode': True,
385
+ 'triggerPrice': True,
386
+ # todo: implementation fix
387
+ 'triggerPriceType': {
388
+ 'last': True,
389
+ 'mark': True,
390
+ 'index': True,
391
+ },
392
+ 'triggerDirection': False,
393
+ 'stopLossPrice': True,
394
+ 'takeProfitPrice': True,
395
+ 'attachedStopLossTakeProfit': None,
396
+ 'timeInForce': {
397
+ 'IOC': True,
398
+ 'FOK': True,
399
+ 'PO': True,
400
+ 'GTD': False,
401
+ },
402
+ 'hedged': False,
403
+ 'selfTradePrevention': True, # todo: implement
404
+ 'trailing': False,
405
+ 'iceberg': False,
406
+ 'leverage': False,
407
+ 'marketBuyByCost': True,
408
+ 'marketBuyRequiresPrice': True,
409
+ },
410
+ 'createOrders': {
411
+ 'max': 10,
412
+ },
413
+ 'fetchMyTrades': {
414
+ 'marginMode': False,
415
+ 'limit': 100,
416
+ 'daysBack': None,
417
+ 'untilDays': 1,
418
+ 'symbolRequired': False,
419
+ },
420
+ 'fetchOrder': {
421
+ 'marginMode': False,
422
+ 'trigger': False,
423
+ 'trailing': False,
424
+ 'symbolRequired': False,
425
+ },
426
+ 'fetchOpenOrders': {
427
+ 'marginMode': True,
428
+ 'limit': 100,
429
+ 'trigger': False,
430
+ 'trailing': False,
431
+ 'symbolRequired': False,
432
+ },
433
+ 'fetchOrders': {
434
+ 'marginMode': False,
435
+ 'limit': 100,
436
+ 'daysBack': None,
437
+ 'untilDays': 1,
438
+ 'trigger': False,
439
+ 'trailing': False,
440
+ 'symbolRequired': False,
441
+ },
442
+ 'fetchClosedOrders': {
443
+ 'marginMode': False,
444
+ 'limit': 100,
445
+ 'daysBack': None,
446
+ 'daysBackCanceled': None,
447
+ 'untilDays': 1,
448
+ 'trigger': False,
449
+ 'trailing': False,
450
+ 'symbolRequired': False,
451
+ },
452
+ 'fetchOHLCV': {
453
+ 'limit': 300,
454
+ },
455
+ },
456
+ 'spot': {
457
+ 'extends': 'default',
458
+ },
459
+ 'swap': {
460
+ 'linear': {
461
+ 'extends': 'default',
462
+ },
463
+ 'inverse': {
464
+ 'extends': 'default',
465
+ },
466
+ },
467
+ 'future': {
468
+ 'linear': {
469
+ 'extends': 'default',
470
+ },
471
+ 'inverse': {
472
+ 'extends': 'default',
473
+ },
474
+ },
475
+ },
347
476
  # https://exchange-docs.crypto.com/spot/index.html#response-and-reason-codes
348
477
  'commonCurrencies': {
349
478
  'USD_STABLE_COIN': 'USDC',
@@ -352,7 +481,10 @@ class cryptocom(Exchange, ImplicitAPI):
352
481
  'exceptions': {
353
482
  'exact': {
354
483
  '219': InvalidOrder,
484
+ '306': InsufficientFunds, # {"id" : 1753xxx, "method" : "private/amend-order", "code" : 306, "message" : "INSUFFICIENT_AVAILABLE_BALANCE", "result" : {"client_oid" : "1753xxx", "order_id" : "6530xxx"}}
355
485
  '314': InvalidOrder, # {"id" : 1700xxx, "method" : "private/create-order", "code" : 314, "message" : "EXCEEDS_MAX_ORDER_SIZE", "result" : {"client_oid" : "1700xxx", "order_id" : "6530xxx"}}
486
+ '325': InvalidOrder, # {"id" : 1741xxx, "method" : "private/create-order", "code" : 325, "message" : "EXCEED_DAILY_VOL_LIMIT", "result" : {"client_oid" : "1741xxx", "order_id" : "6530xxx"}}
487
+ '415': InvalidOrder, # {"id" : 1741xxx, "method" : "private/create-order", "code" : 415, "message" : "BELOW_MIN_ORDER_SIZE", "result" : {"client_oid" : "1741xxx", "order_id" : "6530xxx"}}
356
488
  '10001': ExchangeError,
357
489
  '10002': PermissionDenied,
358
490
  '10003': PermissionDenied,
@@ -388,16 +520,151 @@ class cryptocom(Exchange, ImplicitAPI):
388
520
  '40006': BadRequest,
389
521
  '40007': BadRequest,
390
522
  '40101': AuthenticationError,
391
- '50001': BadRequest,
523
+ '40102': InvalidNonce, # Nonce value differs by more than 60 seconds from server
524
+ '40103': AuthenticationError, # IP address not whitelisted
525
+ '40104': AuthenticationError, # Disallowed based on user tier
526
+ '40107': BadRequest, # Session subscription limit has been exceeded
527
+ '40401': OrderNotFound,
528
+ '40801': RequestTimeout,
529
+ '42901': RateLimitExceeded,
530
+ '43005': InvalidOrder, # Rejected POST_ONLY create-order request(normally happened when exec_inst contains POST_ONLY but time_in_force is NOT GOOD_TILL_CANCEL)
531
+ '43003': InvalidOrder, # FOK order has not been filled and cancelled
532
+ '43004': InvalidOrder, # IOC order has not been filled and cancelled
533
+ '43012': BadRequest, # Canceled due to Self Trade Prevention
534
+ '50001': ExchangeError,
392
535
  '9010001': OnMaintenance, # {"code":9010001,"message":"SYSTEM_MAINTENANCE","details":"Crypto.com Exchange is currently under maintenance. Please refer to https://status.crypto.com for more details."}
393
536
  },
394
537
  'broad': {},
395
538
  },
396
539
  })
397
540
 
541
+ def fetch_currencies(self, params={}) -> Currencies:
542
+ """
543
+ fetches all available currencies on an exchange
544
+
545
+ https://exchange-docs.crypto.com/exchange/v1/rest-ws/index.html#private-get-currency-networks
546
+
547
+ :param dict [params]: extra parameters specific to the exchange API endpoint
548
+ :returns dict: an associative dictionary of currencies
549
+ """
550
+ # self endpoint requires authentication
551
+ if not self.check_required_credentials(False):
552
+ return None
553
+ skipFetchCurrencies = False
554
+ skipFetchCurrencies, params = self.handle_option_and_params(params, 'fetchCurrencies', 'skipFetchCurrencies', False)
555
+ if skipFetchCurrencies:
556
+ # sub-accounts can't access self endpoint
557
+ return None
558
+ response = {}
559
+ try:
560
+ response = self.v1PrivatePostPrivateGetCurrencyNetworks(params)
561
+ except Exception as e:
562
+ if isinstance(e, ExchangeError):
563
+ # sub-accounts can't access self endpoint
564
+ # {"code":"10001","msg":"SYS_ERROR"}
565
+ return None
566
+ raise e
567
+ # do nothing
568
+ # sub-accounts can't access self endpoint
569
+ #
570
+ # {
571
+ # "id": "1747502328559",
572
+ # "method": "private/get-currency-networks",
573
+ # "code": "0",
574
+ # "result": {
575
+ # "update_time": "1747502281000",
576
+ # "currency_map": {
577
+ # "USDT": {
578
+ # "full_name": "Tether USD",
579
+ # "default_network": "ETH",
580
+ # "network_list": [
581
+ # {
582
+ # "network_id": "ETH",
583
+ # "withdrawal_fee": "10.00000000",
584
+ # "withdraw_enabled": True,
585
+ # "min_withdrawal_amount": "20.0",
586
+ # "deposit_enabled": True,
587
+ # "confirmation_required": "32"
588
+ # },
589
+ # {
590
+ # "network_id": "CRONOS",
591
+ # "withdrawal_fee": "0.18000000",
592
+ # "withdraw_enabled": True,
593
+ # "min_withdrawal_amount": "0.35",
594
+ # "deposit_enabled": True,
595
+ # "confirmation_required": "15"
596
+ # },
597
+ # {
598
+ # "network_id": "SOL",
599
+ # "withdrawal_fee": "5.31000000",
600
+ # "withdraw_enabled": True,
601
+ # "min_withdrawal_amount": "10.62",
602
+ # "deposit_enabled": True,
603
+ # "confirmation_required": "1"
604
+ # }
605
+ # ]
606
+ # }
607
+ # }
608
+ # }
609
+ # }
610
+ #
611
+ resultData = self.safe_dict(response, 'result', {})
612
+ currencyMap = self.safe_dict(resultData, 'currency_map', {})
613
+ keys = list(currencyMap.keys())
614
+ result: dict = {}
615
+ for i in range(0, len(keys)):
616
+ key = keys[i]
617
+ currency = currencyMap[key]
618
+ id = key
619
+ code = self.safe_currency_code(id)
620
+ networks: dict = {}
621
+ chains = self.safe_list(currency, 'network_list', [])
622
+ for j in range(0, len(chains)):
623
+ chain = chains[j]
624
+ networkId = self.safe_string(chain, 'network_id')
625
+ network = self.network_id_to_code(networkId)
626
+ networks[network] = {
627
+ 'info': chain,
628
+ 'id': networkId,
629
+ 'network': network,
630
+ 'active': None,
631
+ 'deposit': self.safe_bool(chain, 'deposit_enabled', False),
632
+ 'withdraw': self.safe_bool(chain, 'withdraw_enabled', False),
633
+ 'fee': self.safe_number(chain, 'withdrawal_fee'),
634
+ 'precision': None,
635
+ 'limits': {
636
+ 'withdraw': {
637
+ 'min': self.safe_number(chain, 'min_withdrawal_amount'),
638
+ 'max': None,
639
+ },
640
+ },
641
+ }
642
+ result[code] = self.safe_currency_structure({
643
+ 'info': currency,
644
+ 'id': id,
645
+ 'code': code,
646
+ 'name': self.safe_string(currency, 'full_name'),
647
+ 'active': None,
648
+ 'deposit': None,
649
+ 'withdraw': None,
650
+ 'fee': None,
651
+ 'precision': None,
652
+ 'limits': {
653
+ 'amount': {
654
+ 'min': None,
655
+ 'max': None,
656
+ },
657
+ },
658
+ 'type': 'crypto', # only crypto now
659
+ 'networks': networks,
660
+ })
661
+ return result
662
+
398
663
  def fetch_markets(self, params={}) -> List[Market]:
399
664
  """
400
- :see: https://exchange-docs.crypto.com/exchange/v1/rest-ws/index.html#public-get-instruments
665
+
666
+ https://exchange-docs.crypto.com/exchange/v1/rest-ws/index.html#public-get-instruments
667
+
401
668
  retrieves data on all markets for cryptocom
402
669
  :param dict [params]: extra parameters specific to the exchange API endpoint
403
670
  :returns dict[]: an array of objects representing market data
@@ -490,8 +757,8 @@ class cryptocom(Exchange, ImplicitAPI):
490
757
  # }
491
758
  # }
492
759
  #
493
- resultResponse = self.safe_value(response, 'result', {})
494
- data = self.safe_value(resultResponse, 'data', [])
760
+ resultResponse = self.safe_dict(response, 'result', {})
761
+ data = self.safe_list(resultResponse, 'data', [])
495
762
  result = []
496
763
  for i in range(0, len(data)):
497
764
  market = data[i]
@@ -508,8 +775,8 @@ class cryptocom(Exchange, ImplicitAPI):
508
775
  settle = None if spot else self.safe_currency_code(settleId)
509
776
  optionType = self.safe_string_lower(market, 'put_call')
510
777
  strike = self.safe_string(market, 'strike')
511
- marginBuyEnabled = self.safe_value(market, 'margin_buy_enabled')
512
- marginSellEnabled = self.safe_value(market, 'margin_sell_enabled')
778
+ marginBuyEnabled = self.safe_bool(market, 'margin_buy_enabled')
779
+ marginSellEnabled = self.safe_bool(market, 'margin_sell_enabled')
513
780
  expiryString = self.omit_zero(self.safe_string(market, 'expiry_timestamp_ms'))
514
781
  expiry = int(expiryString) if (expiryString is not None) else None
515
782
  symbol = base + '/' + quote
@@ -546,7 +813,7 @@ class cryptocom(Exchange, ImplicitAPI):
546
813
  'swap': swap,
547
814
  'future': future,
548
815
  'option': option,
549
- 'active': self.safe_value(market, 'tradable'),
816
+ 'active': self.safe_bool(market, 'tradable'),
550
817
  'contract': contract,
551
818
  'linear': True if (contract) else None,
552
819
  'inverse': False if (contract) else None,
@@ -585,8 +852,10 @@ class cryptocom(Exchange, ImplicitAPI):
585
852
  def fetch_tickers(self, symbols: Strings = None, params={}) -> Tickers:
586
853
  """
587
854
  fetches price tickers for multiple markets, statistical information calculated over the past 24 hours for each market
588
- :see: https://exchange-docs.crypto.com/spot/index.html#public-get-ticker
589
- :see: https://exchange-docs.crypto.com/derivatives/index.html#public-get-tickers
855
+
856
+ https://exchange-docs.crypto.com/exchange/v1/rest-ws/index.html#public-get-tickers
857
+ https://exchange-docs.crypto.com/derivatives/index.html#public-get-tickers
858
+
590
859
  :param str[]|None symbols: unified symbols of the markets to fetch the ticker for, all market tickers are returned if not assigned
591
860
  :param dict [params]: extra parameters specific to the exchange API endpoint
592
861
  :returns dict: a dictionary of `ticker structures <https://docs.ccxt.com/#/?id=ticker-structure>`
@@ -630,13 +899,15 @@ class cryptocom(Exchange, ImplicitAPI):
630
899
  # }
631
900
  # }
632
901
  #
633
- result = self.safe_value(response, 'result', {})
902
+ result = self.safe_dict(response, 'result', {})
634
903
  data = self.safe_list(result, 'data', [])
635
904
  return self.parse_tickers(data, symbols)
636
905
 
637
906
  def fetch_ticker(self, symbol: str, params={}) -> Ticker:
638
907
  """
639
- :see: https://exchange-docs.crypto.com/exchange/v1/rest-ws/index.html#public-get-tickers
908
+
909
+ https://exchange-docs.crypto.com/exchange/v1/rest-ws/index.html#public-get-tickers
910
+
640
911
  fetches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market
641
912
  :param str symbol: unified symbol of the market to fetch the ticker for
642
913
  :param dict [params]: extra parameters specific to the exchange API endpoint
@@ -650,7 +921,9 @@ class cryptocom(Exchange, ImplicitAPI):
650
921
  def fetch_orders(self, symbol: Str = None, since: Int = None, limit: Int = None, params={}) -> List[Order]:
651
922
  """
652
923
  fetches information on multiple orders made by the user
653
- :see: https://exchange-docs.crypto.com/exchange/v1/rest-ws/index.html#private-get-order-history
924
+
925
+ https://exchange-docs.crypto.com/exchange/v1/rest-ws/index.html#private-get-order-history
926
+
654
927
  :param str symbol: unified market symbol of the market the orders were made in
655
928
  :param int [since]: the earliest time in ms to fetch orders for, max date range is one day
656
929
  :param int [limit]: the maximum number of order structures to retrieve, default 100 max 100
@@ -717,14 +990,16 @@ class cryptocom(Exchange, ImplicitAPI):
717
990
  # }
718
991
  # }
719
992
  #
720
- data = self.safe_value(response, 'result', {})
993
+ data = self.safe_dict(response, 'result', {})
721
994
  orders = self.safe_list(data, 'data', [])
722
995
  return self.parse_orders(orders, market, since, limit)
723
996
 
724
997
  def fetch_trades(self, symbol: str, since: Int = None, limit: Int = None, params={}) -> List[Trade]:
725
998
  """
726
999
  get a list of the most recent trades for a particular symbol
727
- :see: https://exchange-docs.crypto.com/exchange/v1/rest-ws/index.html#public-get-trades
1000
+
1001
+ https://exchange-docs.crypto.com/exchange/v1/rest-ws/index.html#public-get-trades
1002
+
728
1003
  :param str symbol: unified symbol of the market to fetch trades for
729
1004
  :param int [since]: timestamp in ms of the earliest trade to fetch, maximum date range is one day
730
1005
  :param int [limit]: the maximum number of trades to fetch
@@ -771,14 +1046,16 @@ class cryptocom(Exchange, ImplicitAPI):
771
1046
  # }
772
1047
  # }
773
1048
  #
774
- result = self.safe_value(response, 'result', {})
1049
+ result = self.safe_dict(response, 'result', {})
775
1050
  trades = self.safe_list(result, 'data', [])
776
1051
  return self.parse_trades(trades, market, since, limit)
777
1052
 
778
1053
  def fetch_ohlcv(self, symbol: str, timeframe='1m', since: Int = None, limit: Int = None, params={}) -> List[list]:
779
1054
  """
780
1055
  fetches historical candlestick data containing the open, high, low, and close price, and the volume of a market
781
- :see: https://exchange-docs.crypto.com/exchange/v1/rest-ws/index.html#public-get-candlestick
1056
+
1057
+ https://exchange-docs.crypto.com/exchange/v1/rest-ws/index.html#public-get-candlestick
1058
+
782
1059
  :param str symbol: unified symbol of the market to fetch OHLCV data for
783
1060
  :param str timeframe: the length of time each candle represents
784
1061
  :param int [since]: timestamp in ms of the earliest candle to fetch
@@ -798,13 +1075,21 @@ class cryptocom(Exchange, ImplicitAPI):
798
1075
  'instrument_name': market['id'],
799
1076
  'timeframe': self.safe_string(self.timeframes, timeframe, timeframe),
800
1077
  }
801
- if since is not None:
802
- request['start_ts'] = since
803
1078
  if limit is not None:
1079
+ if limit > 300:
1080
+ limit = 300
804
1081
  request['count'] = limit
805
- until = self.safe_integer(params, 'until')
1082
+ now = self.microseconds()
1083
+ duration = self.parse_timeframe(timeframe)
1084
+ until = self.safe_integer(params, 'until', now)
806
1085
  params = self.omit(params, ['until'])
807
- if until is not None:
1086
+ if since is not None:
1087
+ request['start_ts'] = since - duration * 1000
1088
+ if limit is not None:
1089
+ request['end_ts'] = self.sum(since, duration * limit * 1000)
1090
+ else:
1091
+ request['end_ts'] = until
1092
+ else:
808
1093
  request['end_ts'] = until
809
1094
  response = self.v1PublicGetPublicGetCandlestick(self.extend(request, params))
810
1095
  #
@@ -828,14 +1113,16 @@ class cryptocom(Exchange, ImplicitAPI):
828
1113
  # }
829
1114
  # }
830
1115
  #
831
- result = self.safe_value(response, 'result', {})
1116
+ result = self.safe_dict(response, 'result', {})
832
1117
  data = self.safe_list(result, 'data', [])
833
1118
  return self.parse_ohlcvs(data, market, timeframe, since, limit)
834
1119
 
835
1120
  def fetch_order_book(self, symbol: str, limit: Int = None, params={}) -> OrderBook:
836
1121
  """
837
1122
  fetches information on open orders with bid(buy) and ask(sell) prices, volumes and other data
838
- :see: https://exchange-docs.crypto.com/exchange/v1/rest-ws/index.html#public-get-book
1123
+
1124
+ https://exchange-docs.crypto.com/exchange/v1/rest-ws/index.html#public-get-book
1125
+
839
1126
  :param str symbol: unified symbol of the market to fetch the order book for
840
1127
  :param int [limit]: the number of order book entries to return, max 50
841
1128
  :param dict [params]: extra parameters specific to the exchange API endpoint
@@ -847,7 +1134,7 @@ class cryptocom(Exchange, ImplicitAPI):
847
1134
  'instrument_name': market['id'],
848
1135
  }
849
1136
  if limit:
850
- request['depth'] = limit
1137
+ request['depth'] = min(limit, 50) # max 50
851
1138
  response = self.v1PublicGetPublicGetBook(self.extend(request, params))
852
1139
  #
853
1140
  # {
@@ -867,15 +1154,15 @@ class cryptocom(Exchange, ImplicitAPI):
867
1154
  # }
868
1155
  # }
869
1156
  #
870
- result = self.safe_value(response, 'result', {})
871
- data = self.safe_value(result, 'data', [])
1157
+ result = self.safe_dict(response, 'result', {})
1158
+ data = self.safe_list(result, 'data', [])
872
1159
  orderBook = self.safe_value(data, 0)
873
1160
  timestamp = self.safe_integer(orderBook, 't')
874
1161
  return self.parse_order_book(orderBook, symbol, timestamp)
875
1162
 
876
1163
  def parse_balance(self, response) -> Balances:
877
- responseResult = self.safe_value(response, 'result', {})
878
- data = self.safe_value(responseResult, 'data', [])
1164
+ responseResult = self.safe_dict(response, 'result', {})
1165
+ data = self.safe_list(responseResult, 'data', [])
879
1166
  positionBalances = self.safe_value(data[0], 'position_balances', [])
880
1167
  result: dict = {'info': response}
881
1168
  for i in range(0, len(positionBalances)):
@@ -891,7 +1178,9 @@ class cryptocom(Exchange, ImplicitAPI):
891
1178
  def fetch_balance(self, params={}) -> Balances:
892
1179
  """
893
1180
  query for balance and get the amount of funds available for trading or funds locked in orders
894
- :see: https://exchange-docs.crypto.com/exchange/v1/rest-ws/index.html#private-user-balance
1181
+
1182
+ https://exchange-docs.crypto.com/exchange/v1/rest-ws/index.html#private-user-balance
1183
+
895
1184
  :param dict [params]: extra parameters specific to the exchange API endpoint
896
1185
  :returns dict: a `balance structure <https://docs.ccxt.com/#/?id=balance-structure>`
897
1186
  """
@@ -945,7 +1234,10 @@ class cryptocom(Exchange, ImplicitAPI):
945
1234
  def fetch_order(self, id: str, symbol: Str = None, params={}):
946
1235
  """
947
1236
  fetches information on an order made by the user
948
- :see: https://exchange-docs.crypto.com/exchange/v1/rest-ws/index.html#private-get-order-detail
1237
+
1238
+ https://exchange-docs.crypto.com/exchange/v1/rest-ws/index.html#private-get-order-detail
1239
+
1240
+ :param str id: order id
949
1241
  :param str symbol: unified symbol of the market the order was made in
950
1242
  :param dict [params]: extra parameters specific to the exchange API endpoint
951
1243
  :returns dict: An `order structure <https://docs.ccxt.com/#/?id=order-structure>`
@@ -1079,16 +1371,18 @@ class cryptocom(Exchange, ImplicitAPI):
1079
1371
  def create_order(self, symbol: str, type: OrderType, side: OrderSide, amount: float, price: Num = None, params={}):
1080
1372
  """
1081
1373
  create a trade order
1082
- :see: https://exchange-docs.crypto.com/exchange/v1/rest-ws/index.html#private-create-order
1374
+
1375
+ https://exchange-docs.crypto.com/exchange/v1/rest-ws/index.html#private-create-order
1376
+
1083
1377
  :param str symbol: unified symbol of the market to create an order in
1084
1378
  :param str type: 'market', 'limit', 'stop_loss', 'stop_limit', 'take_profit', 'take_profit_limit'
1085
1379
  :param str side: 'buy' or 'sell'
1086
1380
  :param float amount: how much you want to trade in units of base currency
1087
- :param float [price]: the price at which the order is to be fullfilled, in units of the quote currency, ignored in market orders
1381
+ :param float [price]: the price at which the order is to be fulfilled, in units of the quote currency, ignored in market orders
1088
1382
  :param dict [params]: extra parameters specific to the exchange API endpoint
1089
1383
  :param str [params.timeInForce]: 'GTC', 'IOC', 'FOK' or 'PO'
1090
1384
  :param str [params.ref_price_type]: 'MARK_PRICE', 'INDEX_PRICE', 'LAST_PRICE' which trigger price type to use, default is MARK_PRICE
1091
- :param float [params.stopPrice]: price to trigger a stop order
1385
+ :param float [params.triggerPrice]: price to trigger a trigger order
1092
1386
  :param float [params.stopLossPrice]: price to trigger a stop-loss trigger order
1093
1387
  :param float [params.takeProfitPrice]: price to trigger a take-profit trigger order
1094
1388
  :returns dict: an `order structure <https://docs.ccxt.com/#/?id=order-structure>`
@@ -1114,9 +1408,12 @@ class cryptocom(Exchange, ImplicitAPI):
1114
1408
  def create_orders(self, orders: List[OrderRequest], params={}):
1115
1409
  """
1116
1410
  create a list of trade orders
1117
- :see: https://exchange-docs.crypto.com/exchange/v1/rest-ws/index.html#private-create-order-list-list
1118
- :see: https://exchange-docs.crypto.com/exchange/v1/rest-ws/index.html#private-create-order-list-oco
1411
+
1412
+ https://exchange-docs.crypto.com/exchange/v1/rest-ws/index.html#private-create-order-list-list
1413
+ https://exchange-docs.crypto.com/exchange/v1/rest-ws/index.html#private-create-order-list-oco
1414
+
1119
1415
  :param Array orders: list of orders to create, each object should contain the parameters required by createOrder, namely symbol, type, side, amount, price and params
1416
+ :param dict [params]: extra parameters specific to the exchange API endpoint
1120
1417
  :returns dict: an `order structure <https://docs.ccxt.com/#/?id=order-structure>`
1121
1418
  """
1122
1419
  self.load_markets()
@@ -1128,7 +1425,7 @@ class cryptocom(Exchange, ImplicitAPI):
1128
1425
  side = self.safe_string(rawOrder, 'side')
1129
1426
  amount = self.safe_value(rawOrder, 'amount')
1130
1427
  price = self.safe_value(rawOrder, 'price')
1131
- orderParams = self.safe_value(rawOrder, 'params', {})
1428
+ orderParams = self.safe_dict(rawOrder, 'params', {})
1132
1429
  orderRequest = self.create_advanced_order_request(marketId, type, side, amount, price, orderParams)
1133
1430
  ordersRequests.append(orderRequest)
1134
1431
  contigency = self.safe_string(params, 'contingency_type', 'LIST')
@@ -1281,10 +1578,51 @@ class cryptocom(Exchange, ImplicitAPI):
1281
1578
  params = self.omit(params, ['postOnly', 'clientOrderId', 'timeInForce', 'stopPrice', 'triggerPrice', 'stopLossPrice', 'takeProfitPrice'])
1282
1579
  return self.extend(request, params)
1283
1580
 
1581
+ def edit_order(self, id: str, symbol: str, type: OrderType, side: OrderSide, amount: Num = None, price: Num = None, params={}):
1582
+ """
1583
+ edit a trade order
1584
+
1585
+ https://exchange-docs.crypto.com/exchange/v1/rest-ws/index.html#private-amend-order
1586
+
1587
+ :param str id: order id
1588
+ :param str symbol: unified market symbol of the order to edit
1589
+ :param str [type]: not used by cryptocom editOrder
1590
+ :param str [side]: not used by cryptocom editOrder
1591
+ :param float amount:(mandatory) how much of the currency you want to trade in units of the base currency
1592
+ :param float price:(mandatory) the price for the order, in units of the quote currency, ignored in market orders
1593
+ :param dict [params]: extra parameters specific to the exchange API endpoint
1594
+ :param str [params.clientOrderId]: the original client order id of the order to edit, required if id is not provided
1595
+ :returns dict: an `order structure <https://docs.ccxt.com/#/?id=order-structure>`
1596
+ """
1597
+ self.load_markets()
1598
+ request = self.edit_order_request(id, symbol, amount, price, params)
1599
+ response = self.v1PrivatePostPrivateAmendOrder(request)
1600
+ result = self.safe_dict(response, 'result', {})
1601
+ return self.parse_order(result)
1602
+
1603
+ def edit_order_request(self, id: str, symbol: str, amount: float, price: Num = None, params={}):
1604
+ request: dict = {}
1605
+ if id is not None:
1606
+ request['order_id'] = id
1607
+ else:
1608
+ originalClientOrderId = self.safe_string_2(params, 'orig_client_oid', 'clientOrderId')
1609
+ if originalClientOrderId is None:
1610
+ raise ArgumentsRequired(self.id + ' editOrder() requires an id argument or orig_client_oid parameter')
1611
+ else:
1612
+ request['orig_client_oid'] = originalClientOrderId
1613
+ params = self.omit(params, ['orig_client_oid', 'clientOrderId'])
1614
+ if (amount is None) or (price is None):
1615
+ raise ArgumentsRequired(self.id + ' editOrder() requires both amount and price arguments. If you do not want to change the amount or price, you should pass the original values')
1616
+ request['new_quantity'] = self.amount_to_precision(symbol, amount)
1617
+ request['new_price'] = self.price_to_precision(symbol, price)
1618
+ return self.extend(request, params)
1619
+
1284
1620
  def cancel_all_orders(self, symbol: Str = None, params={}):
1285
1621
  """
1286
1622
  cancel all open orders
1287
- :see: https://exchange-docs.crypto.com/exchange/v1/rest-ws/index.html#private-cancel-all-orders
1623
+
1624
+ https://exchange-docs.crypto.com/exchange/v1/rest-ws/index.html#private-cancel-all-orders
1625
+
1288
1626
  :param str symbol: unified market symbol of the orders to cancel
1289
1627
  :param dict [params]: extra parameters specific to the exchange API endpoint
1290
1628
  :returns dict} Returns exchange raw message{@link https://docs.ccxt.com/#/?id=order-structure:
@@ -1295,12 +1633,15 @@ class cryptocom(Exchange, ImplicitAPI):
1295
1633
  if symbol is not None:
1296
1634
  market = self.market(symbol)
1297
1635
  request['instrument_name'] = market['id']
1298
- return self.v1PrivatePostPrivateCancelAllOrders(self.extend(request, params))
1636
+ response = self.v1PrivatePostPrivateCancelAllOrders(self.extend(request, params))
1637
+ return [self.safe_order({'info': response})]
1299
1638
 
1300
1639
  def cancel_order(self, id: str, symbol: Str = None, params={}):
1301
1640
  """
1302
1641
  cancels an open order
1303
- :see: https://exchange-docs.crypto.com/exchange/v1/rest-ws/index.html#private-cancel-order
1642
+
1643
+ https://exchange-docs.crypto.com/exchange/v1/rest-ws/index.html#private-cancel-order
1644
+
1304
1645
  :param str id: the order id of the order to cancel
1305
1646
  :param str [symbol]: unified symbol of the market the order was made in
1306
1647
  :param dict [params]: extra parameters specific to the exchange API endpoint
@@ -1332,7 +1673,9 @@ class cryptocom(Exchange, ImplicitAPI):
1332
1673
  def cancel_orders(self, ids, symbol: Str = None, params={}):
1333
1674
  """
1334
1675
  cancel multiple orders
1335
- :see: https://exchange-docs.crypto.com/exchange/v1/rest-ws/index.html#private-cancel-order-list-list
1676
+
1677
+ https://exchange-docs.crypto.com/exchange/v1/rest-ws/index.html#private-cancel-order-list-list
1678
+
1336
1679
  :param str[] ids: order ids
1337
1680
  :param str symbol: unified market symbol
1338
1681
  :param dict [params]: extra parameters specific to the exchange API endpoint
@@ -1361,8 +1704,10 @@ class cryptocom(Exchange, ImplicitAPI):
1361
1704
  def cancel_orders_for_symbols(self, orders: List[CancellationRequest], params={}):
1362
1705
  """
1363
1706
  cancel multiple orders for multiple symbols
1364
- :see: https://exchange-docs.crypto.com/exchange/v1/rest-ws/index.html#private-cancel-order-list-list
1365
- :param CancellationRequest[] orders: each order should contain the parameters required by cancelOrder namely id and symbol
1707
+
1708
+ https://exchange-docs.crypto.com/exchange/v1/rest-ws/index.html#private-cancel-order-list-list
1709
+
1710
+ :param CancellationRequest[] orders: each order should contain the parameters required by cancelOrder namely id and symbol, example [{"id": "a", "symbol": "BTC/USDT"}, {"id": "b", "symbol": "ETH/USDT"}]
1366
1711
  :param dict [params]: extra parameters specific to the exchange API endpoint
1367
1712
  :returns dict: an list of `order structures <https://docs.ccxt.com/#/?id=order-structure>`
1368
1713
  """
@@ -1389,7 +1734,9 @@ class cryptocom(Exchange, ImplicitAPI):
1389
1734
  def fetch_open_orders(self, symbol: Str = None, since: Int = None, limit: Int = None, params={}) -> List[Order]:
1390
1735
  """
1391
1736
  fetch all unfilled currently open orders
1392
- :see: https://exchange-docs.crypto.com/exchange/v1/rest-ws/index.html#private-get-open-orders
1737
+
1738
+ https://exchange-docs.crypto.com/exchange/v1/rest-ws/index.html#private-get-open-orders
1739
+
1393
1740
  :param str symbol: unified market symbol
1394
1741
  :param int [since]: the earliest time in ms to fetch open orders for
1395
1742
  :param int [limit]: the maximum number of open order structures to retrieve
@@ -1440,14 +1787,16 @@ class cryptocom(Exchange, ImplicitAPI):
1440
1787
  # }
1441
1788
  # }
1442
1789
  #
1443
- data = self.safe_value(response, 'result', {})
1790
+ data = self.safe_dict(response, 'result', {})
1444
1791
  orders = self.safe_list(data, 'data', [])
1445
1792
  return self.parse_orders(orders, market, since, limit)
1446
1793
 
1447
1794
  def fetch_my_trades(self, symbol: Str = None, since: Int = None, limit: Int = None, params={}):
1448
1795
  """
1449
1796
  fetch all trades made by the user
1450
- :see: https://exchange-docs.crypto.com/exchange/v1/rest-ws/index.html#private-get-trades
1797
+
1798
+ https://exchange-docs.crypto.com/exchange/v1/rest-ws/index.html#private-get-trades
1799
+
1451
1800
  :param str symbol: unified market symbol
1452
1801
  :param int [since]: the earliest time in ms to fetch trades for, maximum date range is one day
1453
1802
  :param int [limit]: the maximum number of trade structures to retrieve
@@ -1460,7 +1809,7 @@ class cryptocom(Exchange, ImplicitAPI):
1460
1809
  paginate = False
1461
1810
  paginate, params = self.handle_option_and_params(params, 'fetchMyTrades', 'paginate')
1462
1811
  if paginate:
1463
- return self.fetch_paginated_call_dynamic('fetchMyTrades', symbol, since, limit, params)
1812
+ return self.fetch_paginated_call_dynamic('fetchMyTrades', symbol, since, limit, params, 100)
1464
1813
  request: dict = {}
1465
1814
  market = None
1466
1815
  if symbol is not None:
@@ -1504,7 +1853,7 @@ class cryptocom(Exchange, ImplicitAPI):
1504
1853
  # }
1505
1854
  # }
1506
1855
  #
1507
- result = self.safe_value(response, 'result', {})
1856
+ result = self.safe_dict(response, 'result', {})
1508
1857
  trades = self.safe_list(result, 'data', [])
1509
1858
  return self.parse_trades(trades, market, since, limit)
1510
1859
 
@@ -1520,10 +1869,12 @@ class cryptocom(Exchange, ImplicitAPI):
1520
1869
  address = addressString
1521
1870
  return [address, tag]
1522
1871
 
1523
- def withdraw(self, code: str, amount: float, address: str, tag=None, params={}):
1872
+ def withdraw(self, code: str, amount: float, address: str, tag: Str = None, params={}) -> Transaction:
1524
1873
  """
1525
1874
  make a withdrawal
1526
- :see: https://exchange-docs.crypto.com/exchange/v1/rest-ws/index.html#private-create-withdrawal
1875
+
1876
+ https://exchange-docs.crypto.com/exchange/v1/rest-ws/index.html#private-create-withdrawal
1877
+
1527
1878
  :param str code: unified currency code
1528
1879
  :param float amount: the amount to withdraw
1529
1880
  :param str address: the address to withdraw to
@@ -1566,10 +1917,12 @@ class cryptocom(Exchange, ImplicitAPI):
1566
1917
  result = self.safe_dict(response, 'result')
1567
1918
  return self.parse_transaction(result, currency)
1568
1919
 
1569
- def fetch_deposit_addresses_by_network(self, code: str, params={}):
1920
+ def fetch_deposit_addresses_by_network(self, code: str, params={}) -> List[DepositAddress]:
1570
1921
  """
1571
1922
  fetch a dictionary of addresses for a currency, indexed by network
1572
- :see: https://exchange-docs.crypto.com/exchange/v1/rest-ws/index.html#private-get-deposit-address
1923
+
1924
+ https://exchange-docs.crypto.com/exchange/v1/rest-ws/index.html#private-get-deposit-address
1925
+
1573
1926
  :param str code: unified currency code of the currency for the deposit address
1574
1927
  :param dict [params]: extra parameters specific to the exchange API endpoint
1575
1928
  :returns dict: a dictionary of `address structures <https://docs.ccxt.com/#/?id=address-structure>` indexed by the network
@@ -1599,14 +1952,14 @@ class cryptocom(Exchange, ImplicitAPI):
1599
1952
  # }
1600
1953
  # }
1601
1954
  #
1602
- data = self.safe_value(response, 'result', {})
1603
- addresses = self.safe_value(data, 'deposit_address_list', [])
1955
+ data = self.safe_dict(response, 'result', {})
1956
+ addresses = self.safe_list(data, 'deposit_address_list', [])
1604
1957
  addressesLength = len(addresses)
1605
1958
  if addressesLength == 0:
1606
1959
  raise ExchangeError(self.id + ' fetchDepositAddressesByNetwork() generating address...')
1607
1960
  result: dict = {}
1608
1961
  for i in range(0, addressesLength):
1609
- value = self.safe_value(addresses, i)
1962
+ value = self.safe_dict(addresses, i)
1610
1963
  addressString = self.safe_string(value, 'address')
1611
1964
  currencyId = self.safe_string(value, 'currency')
1612
1965
  responseCode = self.safe_currency_code(currencyId)
@@ -1617,15 +1970,18 @@ class cryptocom(Exchange, ImplicitAPI):
1617
1970
  result[network] = {
1618
1971
  'info': value,
1619
1972
  'currency': responseCode,
1973
+ 'network': network,
1620
1974
  'address': address,
1621
1975
  'tag': tag,
1622
- 'network': network,
1623
1976
  }
1624
1977
  return result
1625
1978
 
1626
- def fetch_deposit_address(self, code: str, params={}):
1979
+ def fetch_deposit_address(self, code: str, params={}) -> DepositAddress:
1627
1980
  """
1628
1981
  fetch the deposit address for a currency associated with self account
1982
+
1983
+ https://exchange-docs.crypto.com/exchange/v1/rest-ws/index.html#private-get-deposit-address
1984
+
1629
1985
  :param str code: unified currency code
1630
1986
  :param dict [params]: extra parameters specific to the exchange API endpoint
1631
1987
  :returns dict: an `address structure <https://docs.ccxt.com/#/?id=address-structure>`
@@ -1639,22 +1995,12 @@ class cryptocom(Exchange, ImplicitAPI):
1639
1995
  keys = list(depositAddresses.keys())
1640
1996
  return depositAddresses[keys[0]]
1641
1997
 
1642
- def safe_network(self, networkId):
1643
- networksById: dict = {
1644
- 'BTC': 'BTC',
1645
- 'ETH': 'ETH',
1646
- 'SOL': 'SOL',
1647
- 'BNB': 'BNB',
1648
- 'CRONOS': 'CRONOS',
1649
- 'MATIC': 'MATIC',
1650
- 'OP': 'OP',
1651
- }
1652
- return self.safe_string(networksById, networkId, networkId)
1653
-
1654
1998
  def fetch_deposits(self, code: Str = None, since: Int = None, limit: Int = None, params={}) -> List[Transaction]:
1655
1999
  """
1656
2000
  fetch all deposits made to an account
1657
- :see: https://exchange-docs.crypto.com/exchange/v1/rest-ws/index.html#private-get-deposit-history
2001
+
2002
+ https://exchange-docs.crypto.com/exchange/v1/rest-ws/index.html#private-get-deposit-history
2003
+
1658
2004
  :param str code: unified currency code
1659
2005
  :param int [since]: the earliest time in ms to fetch deposits for
1660
2006
  :param int [limit]: the maximum number of deposits structures to retrieve
@@ -1700,14 +2046,16 @@ class cryptocom(Exchange, ImplicitAPI):
1700
2046
  # }
1701
2047
  # }
1702
2048
  #
1703
- data = self.safe_value(response, 'result', {})
2049
+ data = self.safe_dict(response, 'result', {})
1704
2050
  depositList = self.safe_list(data, 'deposit_list', [])
1705
2051
  return self.parse_transactions(depositList, currency, since, limit)
1706
2052
 
1707
2053
  def fetch_withdrawals(self, code: Str = None, since: Int = None, limit: Int = None, params={}) -> List[Transaction]:
1708
2054
  """
1709
2055
  fetch all withdrawals made from an account
1710
- :see: https://exchange-docs.crypto.com/exchange/v1/rest-ws/index.html#private-get-withdrawal-history
2056
+
2057
+ https://exchange-docs.crypto.com/exchange/v1/rest-ws/index.html#private-get-withdrawal-history
2058
+
1711
2059
  :param str code: unified currency code
1712
2060
  :param int [since]: the earliest time in ms to fetch withdrawals for
1713
2061
  :param int [limit]: the maximum number of withdrawals structures to retrieve
@@ -1755,7 +2103,7 @@ class cryptocom(Exchange, ImplicitAPI):
1755
2103
  # }
1756
2104
  # }
1757
2105
  #
1758
- data = self.safe_value(response, 'result', {})
2106
+ data = self.safe_dict(response, 'result', {})
1759
2107
  withdrawalList = self.safe_list(data, 'withdrawal_list', [])
1760
2108
  return self.parse_transactions(withdrawalList, currency, since, limit)
1761
2109
 
@@ -2119,7 +2467,7 @@ class cryptocom(Exchange, ImplicitAPI):
2119
2467
 
2120
2468
  def custom_handle_margin_mode_and_params(self, methodName, params={}):
2121
2469
  """
2122
- * @ignore
2470
+ @ignore
2123
2471
  marginMode specified by params["marginMode"], self.options["marginMode"], self.options["defaultMarginMode"], params["margin"] = True or self.options["defaultType"] = 'margin'
2124
2472
  :param dict [params]: extra parameters specific to the exchange API endpoint
2125
2473
  :returns Array: the marginMode in lowercase
@@ -2154,7 +2502,7 @@ class cryptocom(Exchange, ImplicitAPI):
2154
2502
  # ]
2155
2503
  # }
2156
2504
  #
2157
- networkList = self.safe_value(fee, 'network_list')
2505
+ networkList = self.safe_list(fee, 'network_list', [])
2158
2506
  networkListLength = len(networkList)
2159
2507
  result: dict = {
2160
2508
  'info': fee,
@@ -2186,7 +2534,9 @@ class cryptocom(Exchange, ImplicitAPI):
2186
2534
  def fetch_deposit_withdraw_fees(self, codes: Strings = None, params={}):
2187
2535
  """
2188
2536
  fetch deposit and withdraw fees
2189
- :see: https://exchange-docs.crypto.com/exchange/v1/rest-ws/index.html#private-get-currency-networks
2537
+
2538
+ https://exchange-docs.crypto.com/exchange/v1/rest-ws/index.html#private-get-currency-networks
2539
+
2190
2540
  :param str[]|None codes: list of unified currency codes
2191
2541
  :param dict [params]: extra parameters specific to the exchange API endpoint
2192
2542
  :returns dict: a list of `fee structures <https://docs.ccxt.com/#/?id=fee-structure>`
@@ -2197,16 +2547,18 @@ class cryptocom(Exchange, ImplicitAPI):
2197
2547
  currencyMap = self.safe_list(data, 'currency_map')
2198
2548
  return self.parse_deposit_withdraw_fees(currencyMap, codes, 'full_name')
2199
2549
 
2200
- def fetch_ledger(self, code: Str = None, since: Int = None, limit: Int = None, params={}):
2550
+ def fetch_ledger(self, code: Str = None, since: Int = None, limit: Int = None, params={}) -> List[LedgerEntry]:
2201
2551
  """
2202
2552
  fetch the history of changes, actions done by the user or operations that altered the balance of the user
2203
- :see: https://exchange-docs.crypto.com/exchange/v1/rest-ws/index.html#private-get-transactions
2204
- :param str code: unified currency code
2553
+
2554
+ https://exchange-docs.crypto.com/exchange/v1/rest-ws/index.html#private-get-transactions
2555
+
2556
+ :param str [code]: unified currency code
2205
2557
  :param int [since]: timestamp in ms of the earliest ledger entry
2206
2558
  :param int [limit]: max number of ledger entries to return
2207
2559
  :param dict [params]: extra parameters specific to the exchange API endpoint
2208
2560
  :param int [params.until]: timestamp in ms for the ending date filter, default is the current time
2209
- :returns dict: a `ledger structure <https://docs.ccxt.com/#/?id=ledger-structure>`
2561
+ :returns dict: a `ledger structure <https://docs.ccxt.com/#/?id=ledger>`
2210
2562
  """
2211
2563
  self.load_markets()
2212
2564
  request: dict = {}
@@ -2251,11 +2603,11 @@ class cryptocom(Exchange, ImplicitAPI):
2251
2603
  # }
2252
2604
  # }
2253
2605
  #
2254
- result = self.safe_value(response, 'result', {})
2255
- ledger = self.safe_value(result, 'data', [])
2606
+ result = self.safe_dict(response, 'result', {})
2607
+ ledger = self.safe_list(result, 'data', [])
2256
2608
  return self.parse_ledger(ledger, currency, since, limit)
2257
2609
 
2258
- def parse_ledger_entry(self, item: dict, currency: Currency = None):
2610
+ def parse_ledger_entry(self, item: dict, currency: Currency = None) -> LedgerEntry:
2259
2611
  #
2260
2612
  # {
2261
2613
  # "account_id": "ce075cef-1234-4321-bd6e-gf9007351e64",
@@ -2278,6 +2630,8 @@ class cryptocom(Exchange, ImplicitAPI):
2278
2630
  #
2279
2631
  timestamp = self.safe_integer(item, 'event_timestamp_ms')
2280
2632
  currencyId = self.safe_string(item, 'instrument_name')
2633
+ code = self.safe_currency_code(currencyId, currency)
2634
+ currency = self.safe_currency(currencyId, currency)
2281
2635
  amount = self.safe_string(item, 'transaction_qty')
2282
2636
  direction = None
2283
2637
  if Precise.string_lt(amount, '0'):
@@ -2285,14 +2639,15 @@ class cryptocom(Exchange, ImplicitAPI):
2285
2639
  amount = Precise.string_abs(amount)
2286
2640
  else:
2287
2641
  direction = 'in'
2288
- return {
2642
+ return self.safe_ledger_entry({
2643
+ 'info': item,
2289
2644
  'id': self.safe_string(item, 'order_id'),
2290
2645
  'direction': direction,
2291
2646
  'account': self.safe_string(item, 'account_id'),
2292
2647
  'referenceId': self.safe_string(item, 'trade_id'),
2293
2648
  'referenceAccount': self.safe_string(item, 'trade_match_id'),
2294
2649
  'type': self.parse_ledger_entry_type(self.safe_string(item, 'journal_type')),
2295
- 'currency': self.safe_currency_code(currencyId, currency),
2650
+ 'currency': code,
2296
2651
  'amount': self.parse_number(amount),
2297
2652
  'timestamp': timestamp,
2298
2653
  'datetime': self.iso8601(timestamp),
@@ -2303,8 +2658,7 @@ class cryptocom(Exchange, ImplicitAPI):
2303
2658
  'currency': None,
2304
2659
  'cost': None,
2305
2660
  },
2306
- 'info': item,
2307
- }
2661
+ }, currency)
2308
2662
 
2309
2663
  def parse_ledger_entry_type(self, type):
2310
2664
  ledgerType: dict = {
@@ -2335,7 +2689,9 @@ class cryptocom(Exchange, ImplicitAPI):
2335
2689
  def fetch_accounts(self, params={}) -> List[Account]:
2336
2690
  """
2337
2691
  fetch all the accounts associated with a profile
2338
- :see: https://exchange-docs.crypto.com/exchange/v1/rest-ws/index.html#private-get-accounts
2692
+
2693
+ https://exchange-docs.crypto.com/exchange/v1/rest-ws/index.html#private-get-accounts
2694
+
2339
2695
  :param dict [params]: extra parameters specific to the exchange API endpoint
2340
2696
  :returns dict: a dictionary of `account structures <https://docs.ccxt.com/#/?id=account-structure>` indexed by the account type
2341
2697
  """
@@ -2372,9 +2728,9 @@ class cryptocom(Exchange, ImplicitAPI):
2372
2728
  # }
2373
2729
  # }
2374
2730
  #
2375
- result = self.safe_value(response, 'result', {})
2376
- masterAccount = self.safe_value(result, 'master_account', {})
2377
- accounts = self.safe_value(result, 'sub_account_list', [])
2731
+ result = self.safe_dict(response, 'result', {})
2732
+ masterAccount = self.safe_dict(result, 'master_account', {})
2733
+ accounts = self.safe_list(result, 'sub_account_list', [])
2378
2734
  accounts.append(masterAccount)
2379
2735
  return self.parse_accounts(accounts, params)
2380
2736
 
@@ -2414,7 +2770,9 @@ class cryptocom(Exchange, ImplicitAPI):
2414
2770
  def fetch_settlement_history(self, symbol: Str = None, since: Int = None, limit: Int = None, params={}):
2415
2771
  """
2416
2772
  fetches historical settlement records
2417
- :see: https://exchange-docs.crypto.com/exchange/v1/rest-ws/index.html#public-get-expired-settlement-price
2773
+
2774
+ https://exchange-docs.crypto.com/exchange/v1/rest-ws/index.html#public-get-expired-settlement-price
2775
+
2418
2776
  :param str symbol: unified market symbol of the settlement history
2419
2777
  :param int [since]: timestamp in ms
2420
2778
  :param int [limit]: number of records
@@ -2452,8 +2810,8 @@ class cryptocom(Exchange, ImplicitAPI):
2452
2810
  # }
2453
2811
  # }
2454
2812
  #
2455
- result = self.safe_value(response, 'result', {})
2456
- data = self.safe_value(result, 'data', [])
2813
+ result = self.safe_dict(response, 'result', {})
2814
+ data = self.safe_list(result, 'data', [])
2457
2815
  settlements = self.parse_settlements(data, market)
2458
2816
  sorted = self.sort_by(settlements, 'timestamp')
2459
2817
  return self.filter_by_symbol_since_limit(sorted, symbol, since, limit)
@@ -2493,10 +2851,85 @@ class cryptocom(Exchange, ImplicitAPI):
2493
2851
  result.append(self.parse_settlement(settlements[i], market))
2494
2852
  return result
2495
2853
 
2854
+ def fetch_funding_rate(self, symbol: str, params={}):
2855
+ """
2856
+ fetches historical funding rates
2857
+
2858
+ https://exchange-docs.crypto.com/exchange/v1/rest-ws/index.html#public-get-valuations
2859
+
2860
+ :param str symbol: unified symbol of the market to fetch the funding rate history for
2861
+ :param dict [params]: extra parameters specific to the exchange API endpoint
2862
+ :returns dict[]: a list of `funding rate structures <https://docs.ccxt.com/#/?id=funding-rate-history-structure>`
2863
+ """
2864
+ self.load_markets()
2865
+ market = self.market(symbol)
2866
+ if not market['swap']:
2867
+ raise BadSymbol(self.id + ' fetchFundingRate() supports swap contracts only')
2868
+ request: dict = {
2869
+ 'instrument_name': market['id'],
2870
+ 'valuation_type': 'estimated_funding_rate',
2871
+ 'count': 1,
2872
+ }
2873
+ response = self.v1PublicGetPublicGetValuations(self.extend(request, params))
2874
+ #
2875
+ # {
2876
+ # "id": -1,
2877
+ # "method": "public/get-valuations",
2878
+ # "code": 0,
2879
+ # "result": {
2880
+ # "data": [
2881
+ # {
2882
+ # "v": "-0.000001884",
2883
+ # "t": 1687892400000
2884
+ # },
2885
+ # ],
2886
+ # "instrument_name": "BTCUSD-PERP"
2887
+ # }
2888
+ # }
2889
+ #
2890
+ result = self.safe_dict(response, 'result', {})
2891
+ data = self.safe_list(result, 'data', [])
2892
+ entry = self.safe_dict(data, 0, {})
2893
+ return self.parse_funding_rate(entry, market)
2894
+
2895
+ def parse_funding_rate(self, contract, market: Market = None) -> FundingRate:
2896
+ #
2897
+ # {
2898
+ # "v": "-0.000001884",
2899
+ # "t": 1687892400000
2900
+ # },
2901
+ #
2902
+ timestamp = self.safe_integer(contract, 't')
2903
+ fundingTimestamp = None
2904
+ if timestamp is not None:
2905
+ fundingTimestamp = int(math.ceil(timestamp / 3600000)) * 3600000 # end of the next hour
2906
+ return {
2907
+ 'info': contract,
2908
+ 'symbol': self.safe_symbol(None, market),
2909
+ 'markPrice': None,
2910
+ 'indexPrice': None,
2911
+ 'interestRate': None,
2912
+ 'estimatedSettlePrice': None,
2913
+ 'timestamp': timestamp,
2914
+ 'datetime': self.iso8601(timestamp),
2915
+ 'fundingRate': self.safe_number(contract, 'v'),
2916
+ 'fundingTimestamp': fundingTimestamp,
2917
+ 'fundingDatetime': self.iso8601(fundingTimestamp),
2918
+ 'nextFundingRate': None,
2919
+ 'nextFundingTimestamp': None,
2920
+ 'nextFundingDatetime': None,
2921
+ 'previousFundingRate': None,
2922
+ 'previousFundingTimestamp': None,
2923
+ 'previousFundingDatetime': None,
2924
+ 'interval': '1h',
2925
+ }
2926
+
2496
2927
  def fetch_funding_rate_history(self, symbol: Str = None, since: Int = None, limit: Int = None, params={}):
2497
2928
  """
2498
2929
  fetches historical funding rates
2499
- :see: https://exchange-docs.crypto.com/exchange/v1/rest-ws/index.html#public-get-valuations
2930
+
2931
+ https://exchange-docs.crypto.com/exchange/v1/rest-ws/index.html#public-get-valuations
2932
+
2500
2933
  :param str symbol: unified symbol of the market to fetch the funding rate history for
2501
2934
  :param int [since]: timestamp in ms of the earliest funding rate to fetch
2502
2935
  :param int [limit]: the maximum amount of [funding rate structures] to fetch
@@ -2544,8 +2977,8 @@ class cryptocom(Exchange, ImplicitAPI):
2544
2977
  # }
2545
2978
  # }
2546
2979
  #
2547
- result = self.safe_value(response, 'result', {})
2548
- data = self.safe_value(result, 'data', [])
2980
+ result = self.safe_dict(response, 'result', {})
2981
+ data = self.safe_list(result, 'data', [])
2549
2982
  marketId = self.safe_string(result, 'instrument_name')
2550
2983
  rates = []
2551
2984
  for i in range(0, len(data)):
@@ -2564,7 +2997,9 @@ class cryptocom(Exchange, ImplicitAPI):
2564
2997
  def fetch_position(self, symbol: str, params={}):
2565
2998
  """
2566
2999
  fetch data on a single open contract trade position
2567
- :see: https://exchange-docs.crypto.com/exchange/v1/rest-ws/index.html#private-get-positions
3000
+
3001
+ https://exchange-docs.crypto.com/exchange/v1/rest-ws/index.html#private-get-positions
3002
+
2568
3003
  :param str symbol: unified market symbol of the market the position is held in
2569
3004
  :param dict [params]: extra parameters specific to the exchange API endpoint
2570
3005
  :returns dict: a `position structure <https://docs.ccxt.com/#/?id=position-structure>`
@@ -2601,10 +3036,12 @@ class cryptocom(Exchange, ImplicitAPI):
2601
3036
  data = self.safe_list(result, 'data', [])
2602
3037
  return self.parse_position(self.safe_dict(data, 0), market)
2603
3038
 
2604
- def fetch_positions(self, symbols: Strings = None, params={}):
3039
+ def fetch_positions(self, symbols: Strings = None, params={}) -> List[Position]:
2605
3040
  """
2606
3041
  fetch all open positions
2607
- :see: https://exchange-docs.crypto.com/exchange/v1/rest-ws/index.html#private-get-positions
3042
+
3043
+ https://exchange-docs.crypto.com/exchange/v1/rest-ws/index.html#private-get-positions
3044
+
2608
3045
  :param str[]|None symbols: list of unified market symbols
2609
3046
  :param dict [params]: extra parameters specific to the exchange API endpoint
2610
3047
  :returns dict[]: a list of `position structure <https://docs.ccxt.com/#/?id=position-structure>`
@@ -2647,8 +3084,8 @@ class cryptocom(Exchange, ImplicitAPI):
2647
3084
  # }
2648
3085
  # }
2649
3086
  #
2650
- responseResult = self.safe_value(response, 'result', {})
2651
- positions = self.safe_value(responseResult, 'data', [])
3087
+ responseResult = self.safe_dict(response, 'result', {})
3088
+ positions = self.safe_list(responseResult, 'data', [])
2652
3089
  result = []
2653
3090
  for i in range(0, len(positions)):
2654
3091
  entry = positions[i]
@@ -2736,13 +3173,14 @@ class cryptocom(Exchange, ImplicitAPI):
2736
3173
  def close_position(self, symbol: str, side: OrderSide = None, params={}) -> Order:
2737
3174
  """
2738
3175
  closes open positions for a market
2739
- :see: https://exchange-docs.crypto.com/exchange/v1/rest-ws/index.html#private-close-position
3176
+
3177
+ https://exchange-docs.crypto.com/exchange/v1/rest-ws/index.html#private-close-position
3178
+
2740
3179
  :param str symbol: Unified CCXT market symbol
2741
- :param str [marginMode]: not used by cryptocom.closePositions
2742
3180
  :param str [side]: not used by cryptocom.closePositions
2743
3181
  :param dict [params]: extra parameters specific to the okx api endpoint
2744
- *
2745
- * EXCHANGE SPECIFIC PARAMETERS
3182
+
3183
+ EXCHANGE SPECIFIC PARAMETERS
2746
3184
  :param str [params.type]: LIMIT or MARKET
2747
3185
  :param number [params.price]: for limit orders only
2748
3186
  :returns dict[]: `A list of position structures <https://docs.ccxt.com/#/?id=position-structure>`
@@ -2774,6 +3212,118 @@ class cryptocom(Exchange, ImplicitAPI):
2774
3212
  result = self.safe_dict(response, 'result')
2775
3213
  return self.parse_order(result, market)
2776
3214
 
3215
+ def fetch_trading_fee(self, symbol: str, params={}) -> TradingFeeInterface:
3216
+ """
3217
+ fetch the trading fees for a market
3218
+
3219
+ https://exchange-docs.crypto.com/exchange/v1/rest-ws/index.html#private-get-instrument-fee-rate
3220
+
3221
+ :param str symbol: unified market symbol
3222
+ :param dict [params]: extra parameters specific to the exchange API endpoint
3223
+ :returns dict: a `fee structure <https://docs.ccxt.com/#/?id=fee-structure>`
3224
+ """
3225
+ self.load_markets()
3226
+ market = self.market(symbol)
3227
+ request: dict = {
3228
+ 'instrument_name': market['id'],
3229
+ }
3230
+ response = self.v1PrivatePostPrivateGetInstrumentFeeRate(self.extend(request, params))
3231
+ #
3232
+ # {
3233
+ # "id": 1,
3234
+ # "code": 0,
3235
+ # "method": "private/staking/unstake",
3236
+ # "result": {
3237
+ # "staking_id": "1",
3238
+ # "instrument_name": "SOL.staked",
3239
+ # "status": "NEW",
3240
+ # "quantity": "1",
3241
+ # "underlying_inst_name": "SOL",
3242
+ # "reason": "NO_ERROR"
3243
+ # }
3244
+ # }
3245
+ #
3246
+ data = self.safe_dict(response, 'result', {})
3247
+ return self.parse_trading_fee(data, market)
3248
+
3249
+ def fetch_trading_fees(self, params={}) -> TradingFees:
3250
+ """
3251
+
3252
+ https://exchange-docs.crypto.com/exchange/v1/rest-ws/index.html#private-get-fee-rate
3253
+
3254
+ fetch the trading fees for multiple markets
3255
+ :param dict [params]: extra parameters specific to the exchange API endpoint
3256
+ :returns dict: a dictionary of `fee structures <https://docs.ccxt.com/#/?id=fee-structure>` indexed by market symbols
3257
+ """
3258
+ self.load_markets()
3259
+ response = self.v1PrivatePostPrivateGetFeeRate(params)
3260
+ #
3261
+ # {
3262
+ # "id": 1,
3263
+ # "method": "/private/get-fee-rate",
3264
+ # "code": 0,
3265
+ # "result": {
3266
+ # "spot_tier": "3",
3267
+ # "deriv_tier": "3",
3268
+ # "effective_spot_maker_rate_bps": "6.5",
3269
+ # "effective_spot_taker_rate_bps": "6.9",
3270
+ # "effective_deriv_maker_rate_bps": "1.1",
3271
+ # "effective_deriv_taker_rate_bps": "3"
3272
+ # }
3273
+ # }
3274
+ #
3275
+ result = self.safe_dict(response, 'result', {})
3276
+ return self.parse_trading_fees(result)
3277
+
3278
+ def parse_trading_fees(self, response):
3279
+ #
3280
+ # {
3281
+ # "spot_tier": "3",
3282
+ # "deriv_tier": "3",
3283
+ # "effective_spot_maker_rate_bps": "6.5",
3284
+ # "effective_spot_taker_rate_bps": "6.9",
3285
+ # "effective_deriv_maker_rate_bps": "1.1",
3286
+ # "effective_deriv_taker_rate_bps": "3"
3287
+ # }
3288
+ #
3289
+ result: dict = {}
3290
+ result['info'] = response
3291
+ for i in range(0, len(self.symbols)):
3292
+ symbol = self.symbols[i]
3293
+ market = self.market(symbol)
3294
+ isSwap = market['swap']
3295
+ takerFeeKey = 'effective_deriv_taker_rate_bps' if isSwap else 'effective_spot_taker_rate_bps'
3296
+ makerFeeKey = 'effective_deriv_maker_rate_bps' if isSwap else 'effective_spot_maker_rate_bps'
3297
+ tradingFee = {
3298
+ 'info': response,
3299
+ 'symbol': symbol,
3300
+ 'maker': self.parse_number(Precise.string_div(self.safe_string(response, makerFeeKey), '10000')),
3301
+ 'taker': self.parse_number(Precise.string_div(self.safe_string(response, takerFeeKey), '10000')),
3302
+ 'percentage': None,
3303
+ 'tierBased': None,
3304
+ }
3305
+ result[symbol] = tradingFee
3306
+ return result
3307
+
3308
+ def parse_trading_fee(self, fee: dict, market: Market = None) -> TradingFeeInterface:
3309
+ #
3310
+ # {
3311
+ # "instrument_name": "BTC_USD",
3312
+ # "effective_maker_rate_bps": "6.5",
3313
+ # "effective_taker_rate_bps": "6.9"
3314
+ # }
3315
+ #
3316
+ marketId = self.safe_string(fee, 'instrument_name')
3317
+ symbol = self.safe_symbol(marketId, market)
3318
+ return {
3319
+ 'info': fee,
3320
+ 'symbol': symbol,
3321
+ 'maker': self.parse_number(Precise.string_div(self.safe_string(fee, 'effective_maker_rate_bps'), '10000')),
3322
+ 'taker': self.parse_number(Precise.string_div(self.safe_string(fee, 'effective_taker_rate_bps'), '10000')),
3323
+ 'percentage': None,
3324
+ 'tierBased': None,
3325
+ }
3326
+
2777
3327
  def sign(self, path, api='public', method='GET', params={}, headers=None, body=None):
2778
3328
  type = self.safe_string(api, 0)
2779
3329
  access = self.safe_string(api, 1)