ccxt 4.2.77__py2.py3-none-any.whl → 4.4.48__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 (546) hide show
  1. ccxt/__init__.py +36 -14
  2. ccxt/abstract/alpaca.py +4 -0
  3. ccxt/abstract/bigone.py +1 -1
  4. ccxt/abstract/binance.py +112 -48
  5. ccxt/abstract/binancecoinm.py +112 -48
  6. ccxt/abstract/binanceus.py +147 -83
  7. ccxt/abstract/binanceusdm.py +112 -48
  8. ccxt/abstract/bingx.py +133 -78
  9. ccxt/abstract/bitbank.py +5 -0
  10. ccxt/abstract/bitfinex.py +136 -65
  11. ccxt/abstract/bitfinex1.py +69 -0
  12. ccxt/abstract/bitflyer.py +1 -0
  13. ccxt/abstract/bitget.py +8 -1
  14. ccxt/abstract/bitmart.py +13 -1
  15. ccxt/abstract/bitopro.py +1 -0
  16. ccxt/abstract/bitpanda.py +0 -12
  17. ccxt/abstract/bitrue.py +3 -3
  18. ccxt/abstract/bitstamp.py +26 -3
  19. ccxt/abstract/blofin.py +24 -0
  20. ccxt/abstract/btcbox.py +1 -0
  21. ccxt/abstract/bybit.py +29 -14
  22. ccxt/abstract/cex.py +28 -29
  23. ccxt/abstract/coinbase.py +6 -0
  24. ccxt/abstract/coinbaseadvanced.py +94 -0
  25. ccxt/abstract/{coinbasepro.py → coinbaseexchange.py} +1 -0
  26. ccxt/abstract/coinbaseinternational.py +1 -1
  27. ccxt/abstract/coincatch.py +94 -0
  28. ccxt/abstract/coinex.py +233 -123
  29. ccxt/abstract/coinmetro.py +1 -0
  30. ccxt/abstract/cryptocom.py +14 -0
  31. ccxt/abstract/defx.py +69 -0
  32. ccxt/abstract/deribit.py +1 -0
  33. ccxt/abstract/digifinex.py +1 -0
  34. ccxt/abstract/ellipx.py +25 -0
  35. ccxt/abstract/gate.py +20 -0
  36. ccxt/abstract/gateio.py +20 -0
  37. ccxt/abstract/gemini.py +1 -0
  38. ccxt/abstract/hashkey.py +67 -0
  39. ccxt/abstract/hyperliquid.py +1 -1
  40. ccxt/abstract/independentreserve.py +6 -0
  41. ccxt/abstract/kraken.py +4 -3
  42. ccxt/abstract/krakenfutures.py +4 -0
  43. ccxt/abstract/kucoin.py +24 -0
  44. ccxt/abstract/kucoinfutures.py +34 -0
  45. ccxt/abstract/luno.py +2 -0
  46. ccxt/abstract/mexc.py +4 -0
  47. ccxt/abstract/myokx.py +340 -0
  48. ccxt/abstract/oceanex.py +5 -0
  49. ccxt/abstract/okx.py +30 -0
  50. ccxt/abstract/onetrading.py +0 -12
  51. ccxt/abstract/oxfun.py +34 -0
  52. ccxt/abstract/paradex.py +40 -0
  53. ccxt/abstract/phemex.py +1 -0
  54. ccxt/abstract/upbit.py +4 -0
  55. ccxt/abstract/vertex.py +19 -0
  56. ccxt/abstract/whitebit.py +31 -1
  57. ccxt/abstract/woo.py +6 -2
  58. ccxt/abstract/woofipro.py +119 -0
  59. ccxt/abstract/xt.py +153 -0
  60. ccxt/abstract/zonda.py +6 -0
  61. ccxt/ace.py +164 -60
  62. ccxt/alpaca.py +727 -63
  63. ccxt/ascendex.py +395 -249
  64. ccxt/async_support/__init__.py +36 -14
  65. ccxt/async_support/ace.py +164 -60
  66. ccxt/async_support/alpaca.py +727 -63
  67. ccxt/async_support/ascendex.py +396 -249
  68. ccxt/async_support/base/exchange.py +531 -155
  69. ccxt/async_support/base/ws/aiohttp_client.py +28 -5
  70. ccxt/async_support/base/ws/cache.py +3 -2
  71. ccxt/async_support/base/ws/client.py +26 -5
  72. ccxt/async_support/base/ws/fast_client.py +4 -3
  73. ccxt/async_support/base/ws/functions.py +1 -1
  74. ccxt/async_support/base/ws/future.py +40 -31
  75. ccxt/async_support/base/ws/order_book_side.py +3 -0
  76. ccxt/async_support/bequant.py +1 -1
  77. ccxt/async_support/bigone.py +329 -202
  78. ccxt/async_support/binance.py +3030 -1087
  79. ccxt/async_support/binancecoinm.py +2 -1
  80. ccxt/async_support/binanceus.py +12 -1
  81. ccxt/async_support/binanceusdm.py +3 -1
  82. ccxt/async_support/bingx.py +3104 -880
  83. ccxt/async_support/bit2c.py +119 -38
  84. ccxt/async_support/bitbank.py +215 -76
  85. ccxt/async_support/bitbns.py +124 -53
  86. ccxt/async_support/bitfinex.py +3236 -1078
  87. ccxt/async_support/bitfinex1.py +1711 -0
  88. ccxt/async_support/bitflyer.py +238 -49
  89. ccxt/async_support/bitget.py +1513 -563
  90. ccxt/async_support/bithumb.py +199 -65
  91. ccxt/async_support/bitmart.py +1320 -435
  92. ccxt/async_support/bitmex.py +308 -111
  93. ccxt/async_support/bitopro.py +256 -96
  94. ccxt/async_support/bitrue.py +365 -233
  95. ccxt/async_support/bitso.py +201 -89
  96. ccxt/async_support/bitstamp.py +438 -269
  97. ccxt/async_support/bitteam.py +179 -73
  98. ccxt/async_support/bitvavo.py +180 -70
  99. ccxt/async_support/bl3p.py +92 -25
  100. ccxt/async_support/blockchaincom.py +193 -79
  101. ccxt/async_support/blofin.py +392 -148
  102. ccxt/async_support/btcalpha.py +161 -55
  103. ccxt/async_support/btcbox.py +250 -34
  104. ccxt/async_support/btcmarkets.py +232 -85
  105. ccxt/async_support/btcturk.py +159 -60
  106. ccxt/async_support/bybit.py +2231 -1193
  107. ccxt/async_support/cex.py +1409 -1329
  108. ccxt/async_support/coinbase.py +1454 -287
  109. ccxt/async_support/coinbaseadvanced.py +17 -0
  110. ccxt/async_support/{coinbasepro.py → coinbaseexchange.py} +233 -99
  111. ccxt/async_support/coinbaseinternational.py +428 -88
  112. ccxt/async_support/coincatch.py +5152 -0
  113. ccxt/async_support/coincheck.py +121 -38
  114. ccxt/async_support/coinex.py +4020 -3339
  115. ccxt/async_support/coinlist.py +273 -116
  116. ccxt/async_support/coinmate.py +204 -97
  117. ccxt/async_support/coinmetro.py +203 -110
  118. ccxt/async_support/coinone.py +142 -68
  119. ccxt/async_support/coinsph.py +206 -89
  120. ccxt/async_support/coinspot.py +137 -62
  121. ccxt/async_support/cryptocom.py +515 -185
  122. ccxt/async_support/currencycom.py +203 -85
  123. ccxt/async_support/defx.py +2066 -0
  124. ccxt/async_support/delta.py +404 -109
  125. ccxt/async_support/deribit.py +557 -323
  126. ccxt/async_support/digifinex.py +340 -223
  127. ccxt/async_support/ellipx.py +1826 -0
  128. ccxt/async_support/exmo.py +259 -128
  129. ccxt/async_support/gate.py +1472 -463
  130. ccxt/async_support/gemini.py +206 -84
  131. ccxt/async_support/hashkey.py +4164 -0
  132. ccxt/async_support/hitbtc.py +334 -178
  133. ccxt/async_support/hollaex.py +134 -83
  134. ccxt/async_support/htx.py +1095 -563
  135. ccxt/async_support/huobijp.py +105 -56
  136. ccxt/async_support/hyperliquid.py +1633 -268
  137. ccxt/async_support/idex.py +148 -95
  138. ccxt/async_support/independentreserve.py +236 -31
  139. ccxt/async_support/indodax.py +165 -62
  140. ccxt/async_support/kraken.py +871 -354
  141. ccxt/async_support/krakenfutures.py +324 -100
  142. ccxt/async_support/kucoin.py +917 -357
  143. ccxt/async_support/kucoinfutures.py +1004 -149
  144. ccxt/async_support/kuna.py +138 -106
  145. ccxt/async_support/latoken.py +135 -79
  146. ccxt/async_support/lbank.py +290 -113
  147. ccxt/async_support/luno.py +112 -62
  148. ccxt/async_support/lykke.py +104 -55
  149. ccxt/async_support/mercado.py +36 -29
  150. ccxt/async_support/mexc.py +995 -429
  151. ccxt/async_support/myokx.py +43 -0
  152. ccxt/async_support/ndax.py +163 -82
  153. ccxt/async_support/novadax.py +121 -75
  154. ccxt/async_support/oceanex.py +175 -59
  155. ccxt/async_support/okcoin.py +222 -163
  156. ccxt/async_support/okx.py +1776 -454
  157. ccxt/async_support/onetrading.py +132 -414
  158. ccxt/async_support/oxfun.py +2832 -0
  159. ccxt/async_support/p2b.py +79 -51
  160. ccxt/async_support/paradex.py +2017 -0
  161. ccxt/async_support/paymium.py +56 -32
  162. ccxt/async_support/phemex.py +572 -196
  163. ccxt/async_support/poloniex.py +218 -95
  164. ccxt/async_support/poloniexfutures.py +260 -92
  165. ccxt/async_support/probit.py +143 -110
  166. ccxt/async_support/timex.py +123 -70
  167. ccxt/async_support/tokocrypto.py +129 -93
  168. ccxt/async_support/tradeogre.py +39 -25
  169. ccxt/async_support/upbit.py +322 -113
  170. ccxt/async_support/vertex.py +2983 -0
  171. ccxt/async_support/wavesexchange.py +227 -173
  172. ccxt/async_support/wazirx.py +145 -65
  173. ccxt/async_support/whitebit.py +533 -138
  174. ccxt/async_support/woo.py +1137 -296
  175. ccxt/async_support/woofipro.py +2716 -0
  176. ccxt/async_support/xt.py +4628 -0
  177. ccxt/async_support/yobit.py +160 -92
  178. ccxt/async_support/zaif.py +80 -33
  179. ccxt/async_support/zonda.py +140 -69
  180. ccxt/base/errors.py +51 -20
  181. ccxt/base/exchange.py +1722 -480
  182. ccxt/base/precise.py +10 -0
  183. ccxt/base/types.py +223 -4
  184. ccxt/bequant.py +1 -1
  185. ccxt/bigone.py +329 -202
  186. ccxt/binance.py +3030 -1087
  187. ccxt/binancecoinm.py +2 -1
  188. ccxt/binanceus.py +12 -1
  189. ccxt/binanceusdm.py +3 -1
  190. ccxt/bingx.py +3104 -880
  191. ccxt/bit2c.py +119 -38
  192. ccxt/bitbank.py +215 -76
  193. ccxt/bitbns.py +124 -53
  194. ccxt/bitfinex.py +3235 -1078
  195. ccxt/bitfinex1.py +1710 -0
  196. ccxt/bitflyer.py +238 -49
  197. ccxt/bitget.py +1513 -563
  198. ccxt/bithumb.py +198 -65
  199. ccxt/bitmart.py +1320 -435
  200. ccxt/bitmex.py +308 -111
  201. ccxt/bitopro.py +256 -96
  202. ccxt/bitrue.py +365 -233
  203. ccxt/bitso.py +201 -89
  204. ccxt/bitstamp.py +438 -269
  205. ccxt/bitteam.py +179 -73
  206. ccxt/bitvavo.py +180 -70
  207. ccxt/bl3p.py +92 -25
  208. ccxt/blockchaincom.py +193 -79
  209. ccxt/blofin.py +392 -148
  210. ccxt/btcalpha.py +161 -55
  211. ccxt/btcbox.py +250 -34
  212. ccxt/btcmarkets.py +232 -85
  213. ccxt/btcturk.py +159 -60
  214. ccxt/bybit.py +2231 -1193
  215. ccxt/cex.py +1408 -1329
  216. ccxt/coinbase.py +1454 -287
  217. ccxt/coinbaseadvanced.py +17 -0
  218. ccxt/{coinbasepro.py → coinbaseexchange.py} +233 -99
  219. ccxt/coinbaseinternational.py +428 -88
  220. ccxt/coincatch.py +5152 -0
  221. ccxt/coincheck.py +121 -38
  222. ccxt/coinex.py +4020 -3339
  223. ccxt/coinlist.py +273 -116
  224. ccxt/coinmate.py +204 -97
  225. ccxt/coinmetro.py +203 -110
  226. ccxt/coinone.py +142 -68
  227. ccxt/coinsph.py +206 -89
  228. ccxt/coinspot.py +137 -62
  229. ccxt/cryptocom.py +515 -185
  230. ccxt/currencycom.py +203 -85
  231. ccxt/defx.py +2065 -0
  232. ccxt/delta.py +404 -109
  233. ccxt/deribit.py +557 -323
  234. ccxt/digifinex.py +340 -223
  235. ccxt/ellipx.py +1826 -0
  236. ccxt/exmo.py +259 -128
  237. ccxt/gate.py +1472 -463
  238. ccxt/gemini.py +206 -84
  239. ccxt/hashkey.py +4164 -0
  240. ccxt/hitbtc.py +334 -178
  241. ccxt/hollaex.py +134 -83
  242. ccxt/htx.py +1095 -563
  243. ccxt/huobijp.py +105 -56
  244. ccxt/hyperliquid.py +1632 -268
  245. ccxt/idex.py +148 -95
  246. ccxt/independentreserve.py +235 -31
  247. ccxt/indodax.py +165 -62
  248. ccxt/kraken.py +871 -354
  249. ccxt/krakenfutures.py +324 -100
  250. ccxt/kucoin.py +917 -357
  251. ccxt/kucoinfutures.py +1004 -149
  252. ccxt/kuna.py +138 -106
  253. ccxt/latoken.py +135 -79
  254. ccxt/lbank.py +290 -113
  255. ccxt/luno.py +112 -62
  256. ccxt/lykke.py +104 -55
  257. ccxt/mercado.py +36 -29
  258. ccxt/mexc.py +994 -429
  259. ccxt/myokx.py +43 -0
  260. ccxt/ndax.py +163 -82
  261. ccxt/novadax.py +121 -75
  262. ccxt/oceanex.py +175 -59
  263. ccxt/okcoin.py +222 -163
  264. ccxt/okx.py +1776 -454
  265. ccxt/onetrading.py +132 -414
  266. ccxt/oxfun.py +2831 -0
  267. ccxt/p2b.py +79 -51
  268. ccxt/paradex.py +2017 -0
  269. ccxt/paymium.py +56 -32
  270. ccxt/phemex.py +572 -196
  271. ccxt/poloniex.py +218 -95
  272. ccxt/poloniexfutures.py +260 -92
  273. ccxt/pro/__init__.py +29 -5
  274. ccxt/pro/alpaca.py +32 -17
  275. ccxt/pro/ascendex.py +62 -14
  276. ccxt/pro/bequant.py +4 -0
  277. ccxt/pro/binance.py +1596 -329
  278. ccxt/pro/binancecoinm.py +1 -0
  279. ccxt/pro/binanceus.py +2 -9
  280. ccxt/pro/binanceusdm.py +2 -0
  281. ccxt/pro/bingx.py +527 -134
  282. ccxt/pro/bitcoincom.py +4 -1
  283. ccxt/pro/bitfinex.py +731 -266
  284. ccxt/pro/bitfinex1.py +635 -0
  285. ccxt/pro/bitget.py +726 -357
  286. ccxt/pro/bithumb.py +380 -0
  287. ccxt/pro/bitmart.py +138 -39
  288. ccxt/pro/bitmex.py +199 -40
  289. ccxt/pro/bitopro.py +25 -13
  290. ccxt/pro/bitrue.py +31 -32
  291. ccxt/pro/bitstamp.py +7 -6
  292. ccxt/pro/bitvavo.py +203 -81
  293. ccxt/pro/blockchaincom.py +30 -17
  294. ccxt/pro/blofin.py +692 -0
  295. ccxt/pro/bybit.py +791 -82
  296. ccxt/pro/cex.py +99 -51
  297. ccxt/pro/coinbase.py +220 -30
  298. ccxt/{async_support/hitbtc3.py → pro/coinbaseadvanced.py} +5 -5
  299. ccxt/pro/{coinbasepro.py → coinbaseexchange.py} +19 -19
  300. ccxt/pro/coinbaseinternational.py +193 -30
  301. ccxt/pro/coincatch.py +1464 -0
  302. ccxt/pro/coincheck.py +11 -6
  303. ccxt/pro/coinex.py +965 -665
  304. ccxt/pro/coinone.py +17 -10
  305. ccxt/pro/cryptocom.py +446 -66
  306. ccxt/pro/currencycom.py +11 -10
  307. ccxt/pro/defx.py +832 -0
  308. ccxt/pro/deribit.py +167 -31
  309. ccxt/pro/exmo.py +252 -20
  310. ccxt/pro/gate.py +729 -64
  311. ccxt/pro/gemini.py +44 -26
  312. ccxt/pro/hashkey.py +802 -0
  313. ccxt/pro/hitbtc.py +208 -103
  314. ccxt/pro/hollaex.py +25 -9
  315. ccxt/pro/htx.py +83 -39
  316. ccxt/pro/huobijp.py +17 -16
  317. ccxt/pro/hyperliquid.py +502 -31
  318. ccxt/pro/idex.py +28 -13
  319. ccxt/pro/independentreserve.py +21 -16
  320. ccxt/pro/kraken.py +298 -51
  321. ccxt/pro/krakenfutures.py +166 -75
  322. ccxt/pro/kucoin.py +395 -77
  323. ccxt/pro/kucoinfutures.py +400 -99
  324. ccxt/pro/lbank.py +52 -31
  325. ccxt/pro/luno.py +12 -10
  326. ccxt/pro/mexc.py +400 -50
  327. ccxt/pro/myokx.py +28 -0
  328. ccxt/pro/ndax.py +25 -12
  329. ccxt/pro/okcoin.py +28 -9
  330. ccxt/pro/okx.py +935 -124
  331. ccxt/pro/onetrading.py +41 -24
  332. ccxt/pro/oxfun.py +1054 -0
  333. ccxt/pro/p2b.py +100 -24
  334. ccxt/pro/paradex.py +352 -0
  335. ccxt/pro/phemex.py +92 -33
  336. ccxt/pro/poloniex.py +128 -49
  337. ccxt/pro/poloniexfutures.py +53 -32
  338. ccxt/pro/probit.py +92 -85
  339. ccxt/pro/upbit.py +401 -8
  340. ccxt/pro/vertex.py +943 -0
  341. ccxt/pro/wazirx.py +46 -28
  342. ccxt/pro/whitebit.py +65 -12
  343. ccxt/pro/woo.py +437 -65
  344. ccxt/pro/woofipro.py +1271 -0
  345. ccxt/pro/xt.py +1067 -0
  346. ccxt/probit.py +143 -110
  347. ccxt/static_dependencies/__init__.py +1 -1
  348. ccxt/static_dependencies/lark/__init__.py +38 -0
  349. ccxt/static_dependencies/lark/__pyinstaller/__init__.py +6 -0
  350. ccxt/static_dependencies/lark/__pyinstaller/hook-lark.py +14 -0
  351. ccxt/static_dependencies/lark/ast_utils.py +59 -0
  352. ccxt/static_dependencies/lark/common.py +86 -0
  353. ccxt/static_dependencies/lark/exceptions.py +292 -0
  354. ccxt/static_dependencies/lark/grammar.py +130 -0
  355. ccxt/static_dependencies/lark/grammars/__init__.py +0 -0
  356. ccxt/static_dependencies/lark/indenter.py +143 -0
  357. ccxt/static_dependencies/lark/lark.py +658 -0
  358. ccxt/static_dependencies/lark/lexer.py +678 -0
  359. ccxt/static_dependencies/lark/load_grammar.py +1428 -0
  360. ccxt/static_dependencies/lark/parse_tree_builder.py +391 -0
  361. ccxt/static_dependencies/lark/parser_frontends.py +257 -0
  362. ccxt/static_dependencies/lark/parsers/__init__.py +0 -0
  363. ccxt/static_dependencies/lark/parsers/cyk.py +340 -0
  364. ccxt/static_dependencies/lark/parsers/earley.py +314 -0
  365. ccxt/static_dependencies/lark/parsers/earley_common.py +42 -0
  366. ccxt/static_dependencies/lark/parsers/earley_forest.py +801 -0
  367. ccxt/static_dependencies/lark/parsers/grammar_analysis.py +203 -0
  368. ccxt/static_dependencies/lark/parsers/lalr_analysis.py +332 -0
  369. ccxt/static_dependencies/lark/parsers/lalr_interactive_parser.py +158 -0
  370. ccxt/static_dependencies/lark/parsers/lalr_parser.py +122 -0
  371. ccxt/static_dependencies/lark/parsers/lalr_parser_state.py +110 -0
  372. ccxt/static_dependencies/lark/parsers/xearley.py +165 -0
  373. ccxt/static_dependencies/lark/py.typed +0 -0
  374. ccxt/static_dependencies/lark/reconstruct.py +107 -0
  375. ccxt/static_dependencies/lark/tools/__init__.py +70 -0
  376. ccxt/static_dependencies/lark/tools/nearley.py +202 -0
  377. ccxt/static_dependencies/lark/tools/serialize.py +32 -0
  378. ccxt/static_dependencies/lark/tools/standalone.py +196 -0
  379. ccxt/static_dependencies/lark/tree.py +267 -0
  380. ccxt/static_dependencies/lark/tree_matcher.py +186 -0
  381. ccxt/static_dependencies/lark/tree_templates.py +180 -0
  382. ccxt/static_dependencies/lark/utils.py +343 -0
  383. ccxt/static_dependencies/lark/visitors.py +596 -0
  384. ccxt/static_dependencies/marshmallow/__init__.py +81 -0
  385. ccxt/static_dependencies/marshmallow/base.py +65 -0
  386. ccxt/static_dependencies/marshmallow/class_registry.py +94 -0
  387. ccxt/static_dependencies/marshmallow/decorators.py +231 -0
  388. ccxt/static_dependencies/marshmallow/error_store.py +60 -0
  389. ccxt/static_dependencies/marshmallow/exceptions.py +71 -0
  390. ccxt/static_dependencies/marshmallow/fields.py +2114 -0
  391. ccxt/static_dependencies/marshmallow/orderedset.py +89 -0
  392. ccxt/static_dependencies/marshmallow/py.typed +0 -0
  393. ccxt/static_dependencies/marshmallow/schema.py +1228 -0
  394. ccxt/static_dependencies/marshmallow/types.py +12 -0
  395. ccxt/static_dependencies/marshmallow/utils.py +378 -0
  396. ccxt/static_dependencies/marshmallow/validate.py +678 -0
  397. ccxt/static_dependencies/marshmallow/warnings.py +2 -0
  398. ccxt/static_dependencies/marshmallow_dataclass/__init__.py +1047 -0
  399. ccxt/static_dependencies/marshmallow_dataclass/collection_field.py +51 -0
  400. ccxt/static_dependencies/marshmallow_dataclass/lazy_class_attribute.py +45 -0
  401. ccxt/static_dependencies/marshmallow_dataclass/mypy.py +71 -0
  402. ccxt/static_dependencies/marshmallow_dataclass/py.typed +0 -0
  403. ccxt/static_dependencies/marshmallow_dataclass/typing.py +14 -0
  404. ccxt/static_dependencies/marshmallow_dataclass/union_field.py +82 -0
  405. ccxt/static_dependencies/marshmallow_oneofschema/__init__.py +1 -0
  406. ccxt/static_dependencies/marshmallow_oneofschema/one_of_schema.py +193 -0
  407. ccxt/static_dependencies/marshmallow_oneofschema/py.typed +0 -0
  408. ccxt/static_dependencies/starknet/__init__.py +0 -0
  409. ccxt/static_dependencies/starknet/cairo/__init__.py +0 -0
  410. ccxt/static_dependencies/starknet/cairo/data_types.py +123 -0
  411. ccxt/static_dependencies/starknet/cairo/deprecated_parse/__init__.py +0 -0
  412. ccxt/static_dependencies/starknet/cairo/deprecated_parse/cairo_types.py +77 -0
  413. ccxt/static_dependencies/starknet/cairo/deprecated_parse/parser.py +46 -0
  414. ccxt/static_dependencies/starknet/cairo/deprecated_parse/parser_transformer.py +138 -0
  415. ccxt/static_dependencies/starknet/cairo/felt.py +64 -0
  416. ccxt/static_dependencies/starknet/cairo/type_parser.py +121 -0
  417. ccxt/static_dependencies/starknet/cairo/v1/__init__.py +0 -0
  418. ccxt/static_dependencies/starknet/cairo/v1/type_parser.py +59 -0
  419. ccxt/static_dependencies/starknet/cairo/v2/__init__.py +0 -0
  420. ccxt/static_dependencies/starknet/cairo/v2/type_parser.py +77 -0
  421. ccxt/static_dependencies/starknet/ccxt_utils.py +7 -0
  422. ccxt/static_dependencies/starknet/common.py +15 -0
  423. ccxt/static_dependencies/starknet/constants.py +39 -0
  424. ccxt/static_dependencies/starknet/hash/__init__.py +0 -0
  425. ccxt/static_dependencies/starknet/hash/address.py +79 -0
  426. ccxt/static_dependencies/starknet/hash/compiled_class_hash_objects.py +111 -0
  427. ccxt/static_dependencies/starknet/hash/selector.py +16 -0
  428. ccxt/static_dependencies/starknet/hash/storage.py +12 -0
  429. ccxt/static_dependencies/starknet/hash/utils.py +78 -0
  430. ccxt/static_dependencies/starknet/models/__init__.py +0 -0
  431. ccxt/static_dependencies/starknet/models/typed_data.py +45 -0
  432. ccxt/static_dependencies/starknet/serialization/__init__.py +24 -0
  433. ccxt/static_dependencies/starknet/serialization/_calldata_reader.py +40 -0
  434. ccxt/static_dependencies/starknet/serialization/_context.py +142 -0
  435. ccxt/static_dependencies/starknet/serialization/data_serializers/__init__.py +10 -0
  436. ccxt/static_dependencies/starknet/serialization/data_serializers/_common.py +82 -0
  437. ccxt/static_dependencies/starknet/serialization/data_serializers/array_serializer.py +43 -0
  438. ccxt/static_dependencies/starknet/serialization/data_serializers/bool_serializer.py +37 -0
  439. ccxt/static_dependencies/starknet/serialization/data_serializers/byte_array_serializer.py +66 -0
  440. ccxt/static_dependencies/starknet/serialization/data_serializers/cairo_data_serializer.py +71 -0
  441. ccxt/static_dependencies/starknet/serialization/data_serializers/enum_serializer.py +71 -0
  442. ccxt/static_dependencies/starknet/serialization/data_serializers/felt_serializer.py +50 -0
  443. ccxt/static_dependencies/starknet/serialization/data_serializers/named_tuple_serializer.py +58 -0
  444. ccxt/static_dependencies/starknet/serialization/data_serializers/option_serializer.py +43 -0
  445. ccxt/static_dependencies/starknet/serialization/data_serializers/output_serializer.py +40 -0
  446. ccxt/static_dependencies/starknet/serialization/data_serializers/payload_serializer.py +72 -0
  447. ccxt/static_dependencies/starknet/serialization/data_serializers/struct_serializer.py +36 -0
  448. ccxt/static_dependencies/starknet/serialization/data_serializers/tuple_serializer.py +36 -0
  449. ccxt/static_dependencies/starknet/serialization/data_serializers/uint256_serializer.py +76 -0
  450. ccxt/static_dependencies/starknet/serialization/data_serializers/uint_serializer.py +100 -0
  451. ccxt/static_dependencies/starknet/serialization/data_serializers/unit_serializer.py +32 -0
  452. ccxt/static_dependencies/starknet/serialization/errors.py +10 -0
  453. ccxt/static_dependencies/starknet/serialization/factory.py +229 -0
  454. ccxt/static_dependencies/starknet/serialization/function_serialization_adapter.py +110 -0
  455. ccxt/static_dependencies/starknet/serialization/tuple_dataclass.py +59 -0
  456. ccxt/static_dependencies/starknet/utils/__init__.py +0 -0
  457. ccxt/static_dependencies/starknet/utils/constructor_args_translator.py +86 -0
  458. ccxt/static_dependencies/starknet/utils/iterable.py +13 -0
  459. ccxt/static_dependencies/starknet/utils/schema.py +13 -0
  460. ccxt/static_dependencies/starknet/utils/typed_data.py +182 -0
  461. ccxt/static_dependencies/starkware/__init__.py +0 -0
  462. ccxt/static_dependencies/starkware/crypto/__init__.py +0 -0
  463. ccxt/static_dependencies/starkware/crypto/fast_pedersen_hash.py +50 -0
  464. ccxt/static_dependencies/starkware/crypto/math_utils.py +78 -0
  465. ccxt/static_dependencies/starkware/crypto/signature.py +2344 -0
  466. ccxt/static_dependencies/starkware/crypto/utils.py +63 -0
  467. ccxt/static_dependencies/sympy/__init__.py +0 -0
  468. ccxt/static_dependencies/sympy/core/__init__.py +0 -0
  469. ccxt/static_dependencies/sympy/core/intfunc.py +35 -0
  470. ccxt/static_dependencies/sympy/external/__init__.py +0 -0
  471. ccxt/static_dependencies/sympy/external/gmpy.py +345 -0
  472. ccxt/static_dependencies/sympy/external/importtools.py +187 -0
  473. ccxt/static_dependencies/sympy/external/ntheory.py +637 -0
  474. ccxt/static_dependencies/sympy/external/pythonmpq.py +341 -0
  475. ccxt/static_dependencies/typing_inspect/__init__.py +0 -0
  476. ccxt/static_dependencies/typing_inspect/typing_inspect.py +851 -0
  477. ccxt/test/{test_async.py → tests_async.py} +456 -391
  478. ccxt/test/tests_helpers.py +285 -0
  479. ccxt/test/tests_init.py +39 -0
  480. ccxt/test/{test_sync.py → tests_sync.py} +456 -393
  481. ccxt/timex.py +123 -70
  482. ccxt/tokocrypto.py +129 -93
  483. ccxt/tradeogre.py +39 -25
  484. ccxt/upbit.py +322 -113
  485. ccxt/vertex.py +2983 -0
  486. ccxt/wavesexchange.py +227 -173
  487. ccxt/wazirx.py +145 -65
  488. ccxt/whitebit.py +533 -138
  489. ccxt/woo.py +1137 -296
  490. ccxt/woofipro.py +2716 -0
  491. ccxt/xt.py +4627 -0
  492. ccxt/yobit.py +159 -92
  493. ccxt/zaif.py +80 -33
  494. ccxt/zonda.py +140 -69
  495. ccxt-4.4.48.dist-info/LICENSE.txt +21 -0
  496. ccxt-4.4.48.dist-info/METADATA +646 -0
  497. ccxt-4.4.48.dist-info/RECORD +669 -0
  498. {ccxt-4.2.77.dist-info → ccxt-4.4.48.dist-info}/WHEEL +1 -1
  499. ccxt/abstract/bitbay.py +0 -47
  500. ccxt/abstract/bitfinex2.py +0 -139
  501. ccxt/abstract/hitbtc3.py +0 -115
  502. ccxt/async_support/bitbay.py +0 -17
  503. ccxt/async_support/bitfinex2.py +0 -3496
  504. ccxt/async_support/flowbtc.py +0 -34
  505. ccxt/bitbay.py +0 -17
  506. ccxt/bitfinex2.py +0 -3496
  507. ccxt/flowbtc.py +0 -34
  508. ccxt/hitbtc3.py +0 -16
  509. ccxt/pro/bitfinex2.py +0 -1081
  510. ccxt/test/base/__init__.py +0 -28
  511. ccxt/test/base/test_account.py +0 -26
  512. ccxt/test/base/test_balance.py +0 -56
  513. ccxt/test/base/test_borrow_interest.py +0 -35
  514. ccxt/test/base/test_borrow_rate.py +0 -32
  515. ccxt/test/base/test_calculate_fee.py +0 -51
  516. ccxt/test/base/test_crypto.py +0 -127
  517. ccxt/test/base/test_currency.py +0 -76
  518. ccxt/test/base/test_datetime.py +0 -103
  519. ccxt/test/base/test_decimal_to_precision.py +0 -392
  520. ccxt/test/base/test_deep_extend.py +0 -68
  521. ccxt/test/base/test_deposit_withdrawal.py +0 -50
  522. ccxt/test/base/test_exchange_datetime_functions.py +0 -76
  523. ccxt/test/base/test_funding_rate_history.py +0 -29
  524. ccxt/test/base/test_last_price.py +0 -32
  525. ccxt/test/base/test_ledger_entry.py +0 -45
  526. ccxt/test/base/test_ledger_item.py +0 -48
  527. ccxt/test/base/test_leverage_tier.py +0 -33
  528. ccxt/test/base/test_margin_mode.py +0 -24
  529. ccxt/test/base/test_margin_modification.py +0 -35
  530. ccxt/test/base/test_market.py +0 -190
  531. ccxt/test/base/test_number.py +0 -411
  532. ccxt/test/base/test_ohlcv.py +0 -32
  533. ccxt/test/base/test_open_interest.py +0 -32
  534. ccxt/test/base/test_order.py +0 -64
  535. ccxt/test/base/test_order_book.py +0 -63
  536. ccxt/test/base/test_position.py +0 -60
  537. ccxt/test/base/test_shared_methods.py +0 -345
  538. ccxt/test/base/test_status.py +0 -24
  539. ccxt/test/base/test_throttle.py +0 -126
  540. ccxt/test/base/test_ticker.py +0 -86
  541. ccxt/test/base/test_trade.py +0 -47
  542. ccxt/test/base/test_trading_fee.py +0 -26
  543. ccxt/test/base/test_transaction.py +0 -39
  544. ccxt-4.2.77.dist-info/METADATA +0 -626
  545. ccxt-4.2.77.dist-info/RECORD +0 -534
  546. {ccxt-4.2.77.dist-info → ccxt-4.4.48.dist-info}/top_level.txt +0 -0
ccxt/whitebit.py CHANGED
@@ -6,9 +6,10 @@
6
6
  from ccxt.base.exchange import Exchange
7
7
  from ccxt.abstract.whitebit import ImplicitAPI
8
8
  import hashlib
9
- from ccxt.base.types import Balances, Bool, Currency, Int, Market, MarketType, Num, Order, OrderBook, OrderSide, OrderType, Str, Strings, Ticker, Tickers, Trade, Transaction, TransferEntry
9
+ from ccxt.base.types import Balances, BorrowInterest, Bool, Currencies, Currency, DepositAddress, Int, Market, MarketType, Num, Order, OrderBook, OrderSide, OrderType, Str, Strings, Ticker, Tickers, FundingRate, FundingRates, Trade, TradingFees, Transaction, TransferEntry
10
10
  from typing import List
11
11
  from ccxt.base.errors import ExchangeError
12
+ from ccxt.base.errors import AuthenticationError
12
13
  from ccxt.base.errors import PermissionDenied
13
14
  from ccxt.base.errors import ArgumentsRequired
14
15
  from ccxt.base.errors import BadRequest
@@ -19,7 +20,6 @@ from ccxt.base.errors import OrderNotFound
19
20
  from ccxt.base.errors import NotSupported
20
21
  from ccxt.base.errors import DDoSProtection
21
22
  from ccxt.base.errors import ExchangeNotAvailable
22
- from ccxt.base.errors import AuthenticationError
23
23
  from ccxt.base.decimal_to_precision import TICK_SIZE
24
24
  from ccxt.base.precise import Precise
25
25
 
@@ -41,9 +41,13 @@ class whitebit(Exchange, ImplicitAPI):
41
41
  'swap': False,
42
42
  'future': False,
43
43
  'option': False,
44
- 'cancelAllOrders': False,
44
+ 'cancelAllOrders': True,
45
+ 'cancelAllOrdersAfter': True,
45
46
  'cancelOrder': True,
46
47
  'cancelOrders': False,
48
+ 'createMarketBuyOrderWithCost': True,
49
+ 'createMarketOrderWithCost': False,
50
+ 'createMarketSellOrderWithCost': False,
47
51
  'createOrder': True,
48
52
  'createStopLimitOrder': True,
49
53
  'createStopMarketOrder': True,
@@ -58,7 +62,10 @@ class whitebit(Exchange, ImplicitAPI):
58
62
  'fetchCurrencies': True,
59
63
  'fetchDeposit': True,
60
64
  'fetchDepositAddress': True,
65
+ 'fetchDepositAddresses': False,
66
+ 'fetchDepositAddressesByNetwork': False,
61
67
  'fetchDeposits': True,
68
+ 'fetchDepositsWithdrawals': True,
62
69
  'fetchDepositWithdrawFee': 'emulated',
63
70
  'fetchDepositWithdrawFees': True,
64
71
  'fetchFundingHistory': False,
@@ -186,11 +193,13 @@ class whitebit(Exchange, ImplicitAPI):
186
193
  'ping',
187
194
  'markets',
188
195
  'futures',
196
+ 'platform/status',
189
197
  ],
190
198
  },
191
199
  'private': {
192
200
  'post': [
193
201
  'collateral-account/balance',
202
+ 'collateral-account/balance-summary',
194
203
  'collateral-account/positions/history',
195
204
  'collateral-account/leverage',
196
205
  'collateral-account/positions/open',
@@ -207,21 +216,49 @@ class whitebit(Exchange, ImplicitAPI):
207
216
  'main-account/withdraw',
208
217
  'main-account/withdraw-pay',
209
218
  'main-account/transfer',
219
+ 'main-account/smart/plans',
220
+ 'main-account/smart/investment',
221
+ 'main-account/smart/investment/close',
222
+ 'main-account/smart/investments',
223
+ 'main-account/fee',
224
+ 'main-account/smart/interest-payment-history',
210
225
  'trade-account/balance',
211
226
  'trade-account/executed-history',
212
227
  'trade-account/order',
213
228
  'trade-account/order/history',
214
229
  'order/collateral/limit',
215
230
  'order/collateral/market',
216
- 'order/collateral/trigger_market',
231
+ 'order/collateral/stop-limit',
232
+ 'order/collateral/trigger-market',
217
233
  'order/new',
218
234
  'order/market',
219
235
  'order/stock_market',
220
236
  'order/stop_limit',
221
237
  'order/stop_market',
222
238
  'order/cancel',
239
+ 'order/cancel/all',
240
+ 'order/kill-switch',
241
+ 'order/kill-switch/status',
242
+ 'order/bulk',
243
+ 'order/modify',
223
244
  'orders',
245
+ 'oco-orders',
246
+ 'order/collateral/oco',
247
+ 'order/oco-cancel',
248
+ 'order/oto-cancel',
224
249
  'profile/websocket_token',
250
+ 'convert/estimate',
251
+ 'convert/confirm',
252
+ 'convert/history',
253
+ 'sub-account/create',
254
+ 'sub-account/delete',
255
+ 'sub-account/edit',
256
+ 'sub-account/list',
257
+ 'sub-account/transfer',
258
+ 'sub-account/block',
259
+ 'sub-account/unblock',
260
+ 'sub-account/balances',
261
+ 'sub-account/transfer/history',
225
262
  ],
226
263
  },
227
264
  },
@@ -273,6 +310,7 @@ class whitebit(Exchange, ImplicitAPI):
273
310
  'broad': {
274
311
  'This action is unauthorized': PermissionDenied, # {"code":2,"message":"This action is unauthorized. Enable your key in API settings"}
275
312
  'Given amount is less than min amount': InvalidOrder, # {"code":0,"message":"Validation failed","errors":{"amount":["Given amount is less than min amount 200000"],"total":["Total is less than 5.05"]}}
313
+ 'Min amount step': InvalidOrder, # {"code":32,"errors":{"amount":["Min amount step = 0.01"]},"message":"Validation failed"}
276
314
  'Total is less than': InvalidOrder, # {"code":0,"message":"Validation failed","errors":{"amount":["Given amount is less than min amount 200000"],"total":["Total is less than 5.05"]}}
277
315
  'fee must be no less than': InvalidOrder, # {"code":0,"message":"Validation failed","errors":{"amount":["Total amount + fee must be no less than 5.05505"]}}
278
316
  'Enable your key in API settings': PermissionDenied, # {"code":2,"message":"This action is unauthorized. Enable your key in API settings"}
@@ -281,10 +319,12 @@ class whitebit(Exchange, ImplicitAPI):
281
319
  },
282
320
  })
283
321
 
284
- def fetch_markets(self, params={}):
322
+ def fetch_markets(self, params={}) -> List[Market]:
285
323
  """
286
324
  retrieves data on all markets for whitebit
287
- :see: https://docs.whitebit.com/public/http-v4/#market-info
325
+
326
+ https://docs.whitebit.com/public/http-v4/#market-info
327
+
288
328
  :param dict [params]: extra parameters specific to the exchange API endpoint
289
329
  :returns dict[]: an array of objects representing market data
290
330
  """
@@ -314,7 +354,7 @@ class whitebit(Exchange, ImplicitAPI):
314
354
  #
315
355
  return self.parse_markets(markets)
316
356
 
317
- def parse_market(self, market) -> Market:
357
+ def parse_market(self, market: dict) -> Market:
318
358
  id = self.safe_string(market, 'name')
319
359
  baseId = self.safe_string(market, 'stock')
320
360
  quoteId = self.safe_string(market, 'money')
@@ -401,10 +441,12 @@ class whitebit(Exchange, ImplicitAPI):
401
441
  'info': market,
402
442
  }
403
443
 
404
- def fetch_currencies(self, params={}):
444
+ def fetch_currencies(self, params={}) -> Currencies:
405
445
  """
406
446
  fetches all available currencies on an exchange
407
- :see: https://docs.whitebit.com/public/http-v4/#asset-status-list
447
+
448
+ https://docs.whitebit.com/public/http-v4/#asset-status-list
449
+
408
450
  :param dict [params]: extra parameters specific to the exchange API endpoint
409
451
  :returns dict: an associative dictionary of currencies
410
452
  """
@@ -424,7 +466,7 @@ class whitebit(Exchange, ImplicitAPI):
424
466
  # },
425
467
  #
426
468
  ids = list(response.keys())
427
- result = {}
469
+ result: dict = {}
428
470
  for i in range(0, len(ids)):
429
471
  id = ids[i]
430
472
  currency = response[id]
@@ -457,11 +499,13 @@ class whitebit(Exchange, ImplicitAPI):
457
499
  }
458
500
  return result
459
501
 
460
- def fetch_transaction_fees(self, codes: List[str] = None, params={}):
502
+ def fetch_transaction_fees(self, codes: Strings = None, params={}):
461
503
  """
462
- * @deprecated
504
+ @deprecated
463
505
  please use fetchDepositWithdrawFees instead
464
- :see: https://docs.whitebit.com/public/http-v4/#fee
506
+
507
+ https://docs.whitebit.com/public/http-v4/#fee
508
+
465
509
  :param str[]|None codes: not used by fetchTransactionFees()
466
510
  :param dict [params]: extra parameters specific to the exchange API endpoint
467
511
  :returns dict: a list of `fee structures <https://docs.ccxt.com/#/?id=fee-structure>`
@@ -494,8 +538,8 @@ class whitebit(Exchange, ImplicitAPI):
494
538
  # }
495
539
  #
496
540
  currenciesIds = list(response.keys())
497
- withdrawFees = {}
498
- depositFees = {}
541
+ withdrawFees: dict = {}
542
+ depositFees: dict = {}
499
543
  for i in range(0, len(currenciesIds)):
500
544
  currency = currenciesIds[i]
501
545
  data = response[currency]
@@ -513,7 +557,9 @@ class whitebit(Exchange, ImplicitAPI):
513
557
  def fetch_deposit_withdraw_fees(self, codes: Strings = None, params={}):
514
558
  """
515
559
  fetch deposit and withdraw fees
516
- :see: https://docs.whitebit.com/public/http-v4/#fee
560
+
561
+ https://docs.whitebit.com/public/http-v4/#fee
562
+
517
563
  :param str[]|None codes: not used by fetchDepositWithdrawFees()
518
564
  :param dict [params]: extra parameters specific to the exchange API endpoint
519
565
  :returns dict: a list of `fee structures <https://docs.ccxt.com/#/?id=fee-structure>`
@@ -607,7 +653,7 @@ class whitebit(Exchange, ImplicitAPI):
607
653
  # ...
608
654
  # }
609
655
  #
610
- depositWithdrawFees = {}
656
+ depositWithdrawFees: dict = {}
611
657
  codes = self.market_codes(codes)
612
658
  currencyIds = list(response.keys())
613
659
  for i in range(0, len(currencyIds)):
@@ -626,11 +672,11 @@ class whitebit(Exchange, ImplicitAPI):
626
672
  deposit = self.safe_value(feeInfo, 'deposit')
627
673
  withdrawFee = self.safe_number(withdraw, 'fixed')
628
674
  depositFee = self.safe_number(deposit, 'fixed')
629
- withdrawResult = {
675
+ withdrawResult: dict = {
630
676
  'fee': withdrawFee,
631
677
  'percentage': False if (withdrawFee is not None) else None,
632
678
  }
633
- depositResult = {
679
+ depositResult: dict = {
634
680
  'fee': depositFee,
635
681
  'percentage': False if (depositFee is not None) else None,
636
682
  }
@@ -652,10 +698,12 @@ class whitebit(Exchange, ImplicitAPI):
652
698
  depositWithdrawFees[code] = self.assign_default_deposit_withdraw_fees(depositWithdrawFees[code], currency)
653
699
  return depositWithdrawFees
654
700
 
655
- def fetch_trading_fees(self, params={}):
701
+ def fetch_trading_fees(self, params={}) -> TradingFees:
656
702
  """
657
703
  fetch the trading fees for multiple markets
658
- :see: https://docs.whitebit.com/public/http-v4/#asset-status-list
704
+
705
+ https://docs.whitebit.com/public/http-v4/#asset-status-list
706
+
659
707
  :param dict [params]: extra parameters specific to the exchange API endpoint
660
708
  :returns dict: a dictionary of `fee structures <https://docs.ccxt.com/#/?id=fee-structure>` indexed by market symbols
661
709
  """
@@ -678,7 +726,7 @@ class whitebit(Exchange, ImplicitAPI):
678
726
  # ...
679
727
  # }
680
728
  #
681
- result = {}
729
+ result: dict = {}
682
730
  for i in range(0, len(self.symbols)):
683
731
  symbol = self.symbols[i]
684
732
  market = self.market(symbol)
@@ -700,14 +748,16 @@ class whitebit(Exchange, ImplicitAPI):
700
748
  def fetch_ticker(self, symbol: str, params={}) -> Ticker:
701
749
  """
702
750
  fetches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market
703
- :see: https://docs.whitebit.com/public/http-v4/#market-activity
751
+
752
+ https://docs.whitebit.com/public/http-v4/#market-activity
753
+
704
754
  :param str symbol: unified symbol of the market to fetch the ticker for
705
755
  :param dict [params]: extra parameters specific to the exchange API endpoint
706
756
  :returns dict: a `ticker structure <https://docs.ccxt.com/#/?id=ticker-structure>`
707
757
  """
708
758
  self.load_markets()
709
759
  market = self.market(symbol)
710
- request = {
760
+ request: dict = {
711
761
  'market': market['id'],
712
762
  }
713
763
  response = self.v1PublicGetTicker(self.extend(request, params))
@@ -728,10 +778,10 @@ class whitebit(Exchange, ImplicitAPI):
728
778
  # },
729
779
  # }
730
780
  #
731
- ticker = self.safe_value(response, 'result', {})
781
+ ticker = self.safe_dict(response, 'result', {})
732
782
  return self.parse_ticker(ticker, market)
733
783
 
734
- def parse_ticker(self, ticker, market: Market = None) -> Ticker:
784
+ def parse_ticker(self, ticker: dict, market: Market = None) -> Ticker:
735
785
  #
736
786
  # FetchTicker(v1)
737
787
  #
@@ -759,42 +809,79 @@ class whitebit(Exchange, ImplicitAPI):
759
809
  # "change": "2.12" # in percent
760
810
  # }
761
811
  #
762
- market = self.safe_market(None, market)
763
- last = self.safe_string(ticker, 'last_price')
812
+ # WS market_update
813
+ #
814
+ # {
815
+ # "open": "52853.04",
816
+ # "close": "55913.88",
817
+ # "high": "56272",
818
+ # "low": "49549.67",
819
+ # "volume": "57331.067185",
820
+ # "deal": "3063860382.42985338",
821
+ # "last": "55913.88",
822
+ # "period": 86400
823
+ # }
824
+ # v2
825
+ # {
826
+ # lastUpdateTimestamp: '2025-01-02T09:16:36.000Z',
827
+ # tradingPairs: 'ARB_USDC',
828
+ # lastPrice: '0.7727',
829
+ # lowestAsk: '0.7735',
830
+ # highestBid: '0.7732',
831
+ # baseVolume24h: '1555793.74',
832
+ # quoteVolume24h: '1157602.622406',
833
+ # tradesEnabled: True
834
+ # }
835
+ #
836
+ marketId = self.safe_string(ticker, 'tradingPairs')
837
+ market = self.safe_market(marketId, market)
838
+ # last price is provided as "last" or "last_price"
839
+ last = self.safe_string_n(ticker, ['last', 'last_price', 'lastPrice'])
840
+ # if "close" is provided, use it, otherwise use <last>
841
+ close = self.safe_string(ticker, 'close', last)
764
842
  return self.safe_ticker({
765
843
  'symbol': market['symbol'],
766
844
  'timestamp': None,
767
845
  'datetime': None,
768
846
  'high': self.safe_string(ticker, 'high'),
769
847
  'low': self.safe_string(ticker, 'low'),
770
- 'bid': self.safe_string(ticker, 'bid'),
848
+ 'bid': self.safe_string_2(ticker, 'bid', 'highestBid'),
771
849
  'bidVolume': None,
772
- 'ask': self.safe_string(ticker, 'ask'),
850
+ 'ask': self.safe_string_2(ticker, 'ask', 'lowestAsk'),
773
851
  'askVolume': None,
774
852
  'vwap': None,
775
853
  'open': self.safe_string(ticker, 'open'),
776
- 'close': last,
854
+ 'close': close,
777
855
  'last': last,
778
856
  'previousClose': None,
779
857
  'change': None,
780
858
  'percentage': self.safe_string(ticker, 'change'),
781
859
  'average': None,
782
- 'baseVolume': self.safe_string_2(ticker, 'base_volume', 'volume'),
783
- 'quoteVolume': self.safe_string_2(ticker, 'quote_volume', 'deal'),
860
+ 'baseVolume': self.safe_string_n(ticker, ['base_volume', 'volume', 'baseVolume24h']),
861
+ 'quoteVolume': self.safe_string_n(ticker, ['quote_volume', 'deal', 'quoteVolume24h']),
784
862
  'info': ticker,
785
863
  }, market)
786
864
 
787
865
  def fetch_tickers(self, symbols: Strings = None, params={}) -> Tickers:
788
866
  """
789
867
  fetches price tickers for multiple markets, statistical information calculated over the past 24 hours for each market
790
- :see: https://docs.whitebit.com/public/http-v4/#market-activity
791
- :param str[]|None symbols: unified symbols of the markets to fetch the ticker for, all market tickers are returned if not assigned
868
+
869
+ https://docs.whitebit.com/public/http-v4/#market-activity
870
+
871
+ :param str[] [symbols]: unified symbols of the markets to fetch the ticker for, all market tickers are returned if not assigned
792
872
  :param dict [params]: extra parameters specific to the exchange API endpoint
873
+ :param str [params.method]: either v2PublicGetTicker or v4PublicGetTicker default is v4PublicGetTicker
793
874
  :returns dict: a dictionary of `ticker structures <https://docs.ccxt.com/#/?id=ticker-structure>`
794
875
  """
795
876
  self.load_markets()
796
877
  symbols = self.market_symbols(symbols)
797
- response = self.v4PublicGetTicker(params)
878
+ method = 'v4PublicGetTicker'
879
+ method, params = self.handle_option_and_params(params, 'fetchTickers', 'method', method)
880
+ response = None
881
+ if method == 'v4PublicGetTicker':
882
+ response = self.v4PublicGetTicker(params)
883
+ else:
884
+ response = self.v2PublicGetTicker(params)
798
885
  #
799
886
  # "BCH_RUB": {
800
887
  # "base_id":1831,
@@ -806,8 +893,11 @@ class whitebit(Exchange, ImplicitAPI):
806
893
  # "change":"2.12"
807
894
  # },
808
895
  #
896
+ resultList = self.safe_list(response, 'result')
897
+ if resultList is not None:
898
+ return self.parse_tickers(resultList, symbols)
809
899
  marketIds = list(response.keys())
810
- result = {}
900
+ result: dict = {}
811
901
  for i in range(0, len(marketIds)):
812
902
  marketId = marketIds[i]
813
903
  market = self.safe_market(marketId)
@@ -819,7 +909,9 @@ class whitebit(Exchange, ImplicitAPI):
819
909
  def fetch_order_book(self, symbol: str, limit: Int = None, params={}) -> OrderBook:
820
910
  """
821
911
  fetches information on open orders with bid(buy) and ask(sell) prices, volumes and other data
822
- :see: https://docs.whitebit.com/public/http-v4/#orderbook
912
+
913
+ https://docs.whitebit.com/public/http-v4/#orderbook
914
+
823
915
  :param str symbol: unified symbol of the market to fetch the order book for
824
916
  :param int [limit]: the maximum amount of order book entries to return
825
917
  :param dict [params]: extra parameters specific to the exchange API endpoint
@@ -827,7 +919,7 @@ class whitebit(Exchange, ImplicitAPI):
827
919
  """
828
920
  self.load_markets()
829
921
  market = self.market(symbol)
830
- request = {
922
+ request: dict = {
831
923
  'market': market['id'],
832
924
  }
833
925
  if limit is not None:
@@ -858,7 +950,9 @@ class whitebit(Exchange, ImplicitAPI):
858
950
  def fetch_trades(self, symbol: str, since: Int = None, limit: Int = None, params={}) -> List[Trade]:
859
951
  """
860
952
  get the list of most recent trades for a particular symbol
861
- :see: https://docs.whitebit.com/public/http-v4/#recent-trades
953
+
954
+ https://docs.whitebit.com/public/http-v4/#recent-trades
955
+
862
956
  :param str symbol: unified symbol of the market to fetch trades for
863
957
  :param int [since]: timestamp in ms of the earliest trade to fetch
864
958
  :param int [limit]: the maximum amount of trades to fetch
@@ -867,7 +961,7 @@ class whitebit(Exchange, ImplicitAPI):
867
961
  """
868
962
  self.load_markets()
869
963
  market = self.market(symbol)
870
- request = {
964
+ request: dict = {
871
965
  'market': market['id'],
872
966
  }
873
967
  response = self.v4PublicGetTradesMarket(self.extend(request, params))
@@ -888,7 +982,9 @@ class whitebit(Exchange, ImplicitAPI):
888
982
  def fetch_my_trades(self, symbol: Str = None, since: Int = None, limit: Int = None, params={}):
889
983
  """
890
984
  fetch all trades made by the user
891
- :see: https://docs.whitebit.com/private/http-trade-v4/#query-executed-order-history
985
+
986
+ https://docs.whitebit.com/private/http-trade-v4/#query-executed-order-history
987
+
892
988
  :param str symbol: unified symbol of the market to fetch trades for
893
989
  :param int [since]: timestamp in ms of the earliest trade to fetch
894
990
  :param int [limit]: the maximum amount of trades to fetch
@@ -897,7 +993,7 @@ class whitebit(Exchange, ImplicitAPI):
897
993
  """
898
994
  self.load_markets()
899
995
  market: Market = None
900
- request = {}
996
+ request: dict = {}
901
997
  if symbol is not None:
902
998
  market = self.market(symbol)
903
999
  request['market'] = market['id']
@@ -953,7 +1049,7 @@ class whitebit(Exchange, ImplicitAPI):
953
1049
  results = self.sort_by_2(results, 'timestamp', 'id')
954
1050
  return self.filter_by_since_limit(results, since, limit, 'timestamp')
955
1051
 
956
- def parse_trade(self, trade, market: Market = None) -> Trade:
1052
+ def parse_trade(self, trade: dict, market: Market = None) -> Trade:
957
1053
  #
958
1054
  # fetchTradesV4
959
1055
  #
@@ -1034,7 +1130,9 @@ class whitebit(Exchange, ImplicitAPI):
1034
1130
  def fetch_ohlcv(self, symbol: str, timeframe='1m', since: Int = None, limit: Int = None, params={}) -> List[list]:
1035
1131
  """
1036
1132
  fetches historical candlestick data containing the open, high, low, and close price, and the volume of a market
1037
- :see: https://docs.whitebit.com/public/http-v1/#kline
1133
+
1134
+ https://docs.whitebit.com/public/http-v1/#kline
1135
+
1038
1136
  :param str symbol: unified symbol of the market to fetch OHLCV data for
1039
1137
  :param str timeframe: the length of time each candle represents
1040
1138
  :param int [since]: timestamp in ms of the earliest candle to fetch
@@ -1044,7 +1142,7 @@ class whitebit(Exchange, ImplicitAPI):
1044
1142
  """
1045
1143
  self.load_markets()
1046
1144
  market = self.market(symbol)
1047
- request = {
1145
+ request: dict = {
1048
1146
  'market': market['id'],
1049
1147
  'interval': self.safe_string(self.timeframes, timeframe, timeframe),
1050
1148
  }
@@ -1069,7 +1167,7 @@ class whitebit(Exchange, ImplicitAPI):
1069
1167
  # ]
1070
1168
  # }
1071
1169
  #
1072
- result = self.safe_value(response, 'result', [])
1170
+ result = self.safe_list(response, 'result', [])
1073
1171
  return self.parse_ohlcvs(result, market, timeframe, since, limit)
1074
1172
 
1075
1173
  def parse_ohlcv(self, ohlcv, market: Market = None) -> list:
@@ -1096,7 +1194,9 @@ class whitebit(Exchange, ImplicitAPI):
1096
1194
  def fetch_status(self, params={}):
1097
1195
  """
1098
1196
  the latest known information on the availability of the exchange API
1099
- :see: https://docs.whitebit.com/public/http-v4/#server-status
1197
+
1198
+ https://docs.whitebit.com/public/http-v4/#server-status
1199
+
1100
1200
  :param dict [params]: extra parameters specific to the exchange API endpoint
1101
1201
  :returns dict: a `status structure <https://docs.ccxt.com/#/?id=exchange-status-structure>`
1102
1202
  """
@@ -1118,7 +1218,9 @@ class whitebit(Exchange, ImplicitAPI):
1118
1218
  def fetch_time(self, params={}):
1119
1219
  """
1120
1220
  fetches the current integer timestamp in milliseconds from the exchange server
1121
- :see: https://docs.whitebit.com/public/http-v4/#server-time
1221
+
1222
+ https://docs.whitebit.com/public/http-v4/#server-time
1223
+
1122
1224
  :param dict [params]: extra parameters specific to the exchange API endpoint
1123
1225
  :returns int: the current integer timestamp in milliseconds from the exchange server
1124
1226
  """
@@ -1130,29 +1232,64 @@ class whitebit(Exchange, ImplicitAPI):
1130
1232
  #
1131
1233
  return self.safe_integer(response, 'time')
1132
1234
 
1235
+ def create_market_order_with_cost(self, symbol: str, side: OrderSide, cost: float, params={}):
1236
+ """
1237
+ create a market order by providing the symbol, side and cost
1238
+ :param str symbol: unified symbol of the market to create an order in
1239
+ :param str side: 'buy' or 'sell'
1240
+ :param float cost: how much you want to trade in units of the quote currency
1241
+ :param dict [params]: extra parameters specific to the exchange API endpoint
1242
+ :returns dict: an `order structure <https://docs.ccxt.com/#/?id=order-structure>`
1243
+ """
1244
+ req = {
1245
+ 'cost': cost,
1246
+ }
1247
+ # only buy side is supported
1248
+ return self.create_order(symbol, 'market', side, 0, None, self.extend(req, params))
1249
+
1250
+ def create_market_buy_order_with_cost(self, symbol: str, cost: float, params={}) -> Order:
1251
+ """
1252
+ create a market buy order by providing the symbol and cost
1253
+ :param str symbol: unified symbol of the market to create an order in
1254
+ :param float cost: how much you want to trade in units of the quote currency
1255
+ :param dict [params]: extra parameters specific to the exchange API endpoint
1256
+ :returns dict: an `order structure <https://docs.ccxt.com/#/?id=order-structure>`
1257
+ """
1258
+ return self.create_market_order_with_cost(symbol, 'buy', cost, params)
1259
+
1133
1260
  def create_order(self, symbol: str, type: OrderType, side: OrderSide, amount: float, price: Num = None, params={}):
1134
1261
  """
1135
1262
  create a trade order
1136
- :see: https://docs.whitebit.com/private/http-trade-v4/#create-limit-order
1137
- :see: https://docs.whitebit.com/private/http-trade-v4/#create-market-order
1138
- :see: https://docs.whitebit.com/private/http-trade-v4/#create-buy-stock-market-order
1139
- :see: https://docs.whitebit.com/private/http-trade-v4/#create-stop-limit-order
1140
- :see: https://docs.whitebit.com/private/http-trade-v4/#create-stop-market-order
1263
+
1264
+ https://docs.whitebit.com/private/http-trade-v4/#create-limit-order
1265
+ https://docs.whitebit.com/private/http-trade-v4/#create-market-order
1266
+ https://docs.whitebit.com/private/http-trade-v4/#create-buy-stock-market-order
1267
+ https://docs.whitebit.com/private/http-trade-v4/#create-stop-limit-order
1268
+ https://docs.whitebit.com/private/http-trade-v4/#create-stop-market-order
1269
+
1141
1270
  :param str symbol: unified symbol of the market to create an order in
1142
1271
  :param str type: 'market' or 'limit'
1143
1272
  :param str side: 'buy' or 'sell'
1144
1273
  :param float amount: how much of currency you want to trade in units of base currency
1145
- :param float [price]: the price at which the order is to be fullfilled, in units of the quote currency, ignored in market orders
1274
+ :param float [price]: the price at which the order is to be fulfilled, in units of the quote currency, ignored in market orders
1146
1275
  :param dict [params]: extra parameters specific to the exchange API endpoint
1276
+ :param float [params.cost]: *market orders only* the cost of the order in units of the base currency
1147
1277
  :returns dict: an `order structure <https://docs.ccxt.com/#/?id=order-structure>`
1148
1278
  """
1149
1279
  self.load_markets()
1150
1280
  market = self.market(symbol)
1151
- request = {
1281
+ request: dict = {
1152
1282
  'market': market['id'],
1153
1283
  'side': side,
1154
- 'amount': self.amount_to_precision(symbol, amount),
1155
1284
  }
1285
+ cost = None
1286
+ cost, params = self.handle_param_string(params, 'cost')
1287
+ if cost is not None:
1288
+ if (side != 'buy') or (type != 'market'):
1289
+ raise InvalidOrder(self.id + ' createOrder() cost is only supported for market buy orders')
1290
+ request['amount'] = self.cost_to_precision(symbol, cost)
1291
+ else:
1292
+ request['amount'] = self.amount_to_precision(symbol, amount)
1156
1293
  clientOrderId = self.safe_string_2(params, 'clOrdId', 'clientOrderId')
1157
1294
  if clientOrderId is None:
1158
1295
  brokerId = self.safe_string(self.options, 'brokerId')
@@ -1164,8 +1301,8 @@ class whitebit(Exchange, ImplicitAPI):
1164
1301
  marketType = self.safe_string(market, 'type')
1165
1302
  isLimitOrder = type == 'limit'
1166
1303
  isMarketOrder = type == 'market'
1167
- stopPrice = self.safe_number_n(params, ['triggerPrice', 'stopPrice', 'activation_price'])
1168
- isStopOrder = (stopPrice is not None)
1304
+ triggerPrice = self.safe_number_n(params, ['triggerPrice', 'stopPrice', 'activation_price'])
1305
+ isStopOrder = (triggerPrice is not None)
1169
1306
  postOnly = self.is_post_only(isMarketOrder, False, params)
1170
1307
  marginMode, query = self.handle_margin_mode_and_params('createOrder', params)
1171
1308
  if postOnly:
@@ -1176,7 +1313,7 @@ class whitebit(Exchange, ImplicitAPI):
1176
1313
  useCollateralEndpoint = marginMode is not None or marketType == 'swap'
1177
1314
  response = None
1178
1315
  if isStopOrder:
1179
- request['activation_price'] = self.price_to_precision(symbol, stopPrice)
1316
+ request['activation_price'] = self.price_to_precision(symbol, triggerPrice)
1180
1317
  if isLimitOrder:
1181
1318
  # stop limit order
1182
1319
  request['price'] = self.price_to_precision(symbol, price)
@@ -1200,13 +1337,72 @@ class whitebit(Exchange, ImplicitAPI):
1200
1337
  if useCollateralEndpoint:
1201
1338
  response = self.v4PrivatePostOrderCollateralMarket(self.extend(request, params))
1202
1339
  else:
1203
- response = self.v4PrivatePostOrderStockMarket(self.extend(request, params))
1340
+ if cost is not None:
1341
+ response = self.v4PrivatePostOrderMarket(self.extend(request, params))
1342
+ else:
1343
+ response = self.v4PrivatePostOrderStockMarket(self.extend(request, params))
1344
+ return self.parse_order(response)
1345
+
1346
+ def edit_order(self, id: str, symbol: str, type: OrderType, side: OrderSide, amount: Num = None, price: Num = None, params={}):
1347
+ """
1348
+ edit a trade order
1349
+
1350
+ https://docs.whitebit.com/private/http-trade-v4/#modify-order
1351
+
1352
+ :param str id: cancel order id
1353
+ :param str symbol: unified symbol of the market to create an order in
1354
+ :param str type: 'market' or 'limit'
1355
+ :param str side: 'buy' or 'sell'
1356
+ :param float amount: how much of currency you want to trade in units of base currency
1357
+ :param float price: the price at which the order is to be fulfilled, in units of the quote currency, ignored in market orders
1358
+ :param dict [params]: extra parameters specific to the exchange API endpoint
1359
+ :returns dict: an `order structure <https://docs.ccxt.com/#/?id=order-structure>`
1360
+ """
1361
+ if id is None:
1362
+ raise ArgumentsRequired(self.id + ' editOrder() requires a id argument')
1363
+ if symbol is None:
1364
+ raise ArgumentsRequired(self.id + ' editOrder() requires a symbol argument')
1365
+ self.load_markets()
1366
+ market = self.market(symbol)
1367
+ request: dict = {
1368
+ 'orderId': id,
1369
+ 'market': market['id'],
1370
+ }
1371
+ clientOrderId = self.safe_string_2(params, 'clOrdId', 'clientOrderId')
1372
+ if clientOrderId is not None:
1373
+ # Update clientOrderId of the order
1374
+ request['clientOrderId'] = clientOrderId
1375
+ isLimitOrder = type == 'limit'
1376
+ triggerPrice = self.safe_number_n(params, ['triggerPrice', 'stopPrice', 'activation_price'])
1377
+ isStopOrder = (triggerPrice is not None)
1378
+ params = self.omit(params, ['clOrdId', 'clientOrderId', 'triggerPrice', 'stopPrice'])
1379
+ if isStopOrder:
1380
+ request['activation_price'] = self.price_to_precision(symbol, triggerPrice)
1381
+ if isLimitOrder:
1382
+ # stop limit order
1383
+ request['amount'] = self.amount_to_precision(symbol, amount)
1384
+ request['price'] = self.price_to_precision(symbol, price)
1385
+ else:
1386
+ # stop market order
1387
+ if side == 'buy':
1388
+ # Use total parameter instead of amount for modify buy stop market order
1389
+ request['total'] = self.amount_to_precision(symbol, amount)
1390
+ else:
1391
+ request['amount'] = self.amount_to_precision(symbol, amount)
1392
+ else:
1393
+ request['amount'] = self.amount_to_precision(symbol, amount)
1394
+ if isLimitOrder:
1395
+ # limit order
1396
+ request['price'] = self.price_to_precision(symbol, price)
1397
+ response = self.v4PrivatePostOrderModify(self.extend(request, params))
1204
1398
  return self.parse_order(response)
1205
1399
 
1206
1400
  def cancel_order(self, id: str, symbol: Str = None, params={}):
1207
1401
  """
1208
1402
  cancels an open order
1209
- :see: https://docs.whitebit.com/private/http-trade-v4/#cancel-order
1403
+
1404
+ https://docs.whitebit.com/private/http-trade-v4/#cancel-order
1405
+
1210
1406
  :param str id: order id
1211
1407
  :param str symbol: unified symbol of the market the order was made in
1212
1408
  :param dict [params]: extra parameters specific to the exchange API endpoint
@@ -1216,22 +1412,119 @@ class whitebit(Exchange, ImplicitAPI):
1216
1412
  raise ArgumentsRequired(self.id + ' cancelOrder() requires a symbol argument')
1217
1413
  self.load_markets()
1218
1414
  market = self.market(symbol)
1219
- request = {
1415
+ request: dict = {
1220
1416
  'market': market['id'],
1221
1417
  'orderId': int(id),
1222
1418
  }
1223
- return self.v4PrivatePostOrderCancel(self.extend(request, params))
1419
+ response = self.v4PrivatePostOrderCancel(self.extend(request, params))
1420
+ #
1421
+ # {
1422
+ # "orderId": 4180284841, # order id
1423
+ # "clientOrderId": "customId11", # custom order identifier; "clientOrderId": "" - if not specified.
1424
+ # "market": "BTC_USDT", # deal market
1425
+ # "side": "buy", # order side
1426
+ # "type": "stop market", # order type
1427
+ # "timestamp": 1595792396.165973, # current timestamp
1428
+ # "dealMoney": "0", # if order finished - amount in money currency that is finished
1429
+ # "dealStock": "0", # if order finished - amount in stock currency that is finished
1430
+ # "amount": "0.001", # amount
1431
+ # "takerFee": "0.001", # maker fee ratio. If the number less than 0.0001 - it will be rounded to zero
1432
+ # "makerFee": "0.001", # maker fee ratio. If the number less than 0.0001 - it will be rounded to zero
1433
+ # "left": "0.001", # if order not finished - rest of the amount that must be finished
1434
+ # "dealFee": "0", # fee in money that you pay if order is finished
1435
+ # "price": "40000", # price if price isset
1436
+ # "activation_price": "40000" # activation price if activation price is set
1437
+ # }
1438
+ #
1439
+ return self.parse_order(response)
1440
+
1441
+ def cancel_all_orders(self, symbol: Str = None, params={}):
1442
+ """
1443
+ cancel all open orders
1444
+
1445
+ https://docs.whitebit.com/private/http-trade-v4/#cancel-all-orders
1446
+
1447
+ :param str symbol: unified market symbol, only orders in the market of self symbol are cancelled when symbol is not None
1448
+ :param dict [params]: extra parameters specific to the exchange API endpoint
1449
+ :param str [params.type]: market type, ['swap', 'spot']
1450
+ :param boolean [params.isMargin]: cancel all margin orders
1451
+ :returns dict[]: a list of `order structures <https://docs.ccxt.com/#/?id=order-structure>`
1452
+ """
1453
+ self.load_markets()
1454
+ market = None
1455
+ request: dict = {}
1456
+ if symbol is not None:
1457
+ market = self.market(symbol)
1458
+ request['market'] = market['id']
1459
+ type = None
1460
+ type, params = self.handle_market_type_and_params('cancelAllOrders', market, params)
1461
+ requestType = []
1462
+ if type == 'spot':
1463
+ isMargin = None
1464
+ isMargin, params = self.handle_option_and_params(params, 'cancelAllOrders', 'isMargin', False)
1465
+ if isMargin:
1466
+ requestType.append('margin')
1467
+ else:
1468
+ requestType.append('spot')
1469
+ elif type == 'swap':
1470
+ requestType.append('futures')
1471
+ else:
1472
+ raise NotSupported(self.id + ' cancelAllOrders() does not support ' + type + ' type')
1473
+ request['type'] = requestType
1474
+ response = self.v4PrivatePostOrderCancelAll(self.extend(request, params))
1475
+ #
1476
+ # []
1477
+ #
1478
+ return self.parse_orders(response, market)
1479
+
1480
+ def cancel_all_orders_after(self, timeout: Int, params={}):
1481
+ """
1482
+ dead man's switch, cancel all orders after the given timeout
1483
+
1484
+ https://docs.whitebit.com/private/http-trade-v4/#sync-kill-switch-timer
1485
+
1486
+ :param number timeout: time in milliseconds, 0 represents cancel the timer
1487
+ :param dict [params]: extra parameters specific to the exchange API endpoint
1488
+ :param str [params.types]: Order types value. Example: "spot", "margin", "futures" or None
1489
+ :param str [params.symbol]: symbol unified symbol of the market the order was made in
1490
+ :returns dict: the api result
1491
+ """
1492
+ self.load_markets()
1493
+ symbol = self.safe_string(params, 'symbol')
1494
+ if symbol is None:
1495
+ raise ArgumentsRequired(self.id + ' cancelAllOrdersAfter() requires a symbol argument in params')
1496
+ market = self.market(symbol)
1497
+ params = self.omit(params, 'symbol')
1498
+ isBiggerThanZero = (timeout > 0)
1499
+ request: dict = {
1500
+ 'market': market['id'],
1501
+ # 'timeout': self.number_to_string(timeout / 1000) if (timeout > 0) else null,
1502
+ }
1503
+ if isBiggerThanZero:
1504
+ request['timeout'] = self.number_to_string(timeout / 1000)
1505
+ else:
1506
+ request['timeout'] = 'null'
1507
+ response = self.v4PrivatePostOrderKillSwitch(self.extend(request, params))
1508
+ #
1509
+ # {
1510
+ # "market": "BTC_USDT", # currency market,
1511
+ # "startTime": 1662478154, # now timestamp,
1512
+ # "cancellationTime": 1662478154, # now + timer_value,
1513
+ # "types": ["spot", "margin"]
1514
+ # }
1515
+ #
1516
+ return response
1224
1517
 
1225
1518
  def parse_balance(self, response) -> Balances:
1226
1519
  balanceKeys = list(response.keys())
1227
- result = {}
1520
+ result: dict = {}
1228
1521
  for i in range(0, len(balanceKeys)):
1229
1522
  id = balanceKeys[i]
1230
1523
  code = self.safe_currency_code(id)
1231
1524
  balance = response[id]
1232
1525
  if isinstance(balance, dict) and balance is not None:
1233
1526
  account = self.account()
1234
- account['free'] = self.safe_string(balance, 'available')
1527
+ account['free'] = self.safe_string_2(balance, 'available', 'main_balance')
1235
1528
  account['used'] = self.safe_string(balance, 'freeze')
1236
1529
  account['total'] = self.safe_string(balance, 'main_balance')
1237
1530
  result[code] = account
@@ -1244,8 +1537,10 @@ class whitebit(Exchange, ImplicitAPI):
1244
1537
  def fetch_balance(self, params={}) -> Balances:
1245
1538
  """
1246
1539
  query for balance and get the amount of funds available for trading or funds locked in orders
1247
- :see: https://docs.whitebit.com/private/http-main-v4/#main-balance
1248
- :see: https://docs.whitebit.com/private/http-trade-v4/#trading-balance
1540
+
1541
+ https://docs.whitebit.com/private/http-main-v4/#main-balance
1542
+ https://docs.whitebit.com/private/http-trade-v4/#trading-balance
1543
+
1249
1544
  :param dict [params]: extra parameters specific to the exchange API endpoint
1250
1545
  :returns dict: a `balance structure <https://docs.ccxt.com/#/?id=balance-structure>`
1251
1546
  """
@@ -1291,20 +1586,21 @@ class whitebit(Exchange, ImplicitAPI):
1291
1586
  def fetch_open_orders(self, symbol: Str = None, since: Int = None, limit: Int = None, params={}) -> List[Order]:
1292
1587
  """
1293
1588
  fetch all unfilled currently open orders
1294
- :see: https://docs.whitebit.com/private/http-trade-v4/#query-unexecutedactive-orders
1295
- :param str symbol: unified market symbol
1589
+
1590
+ https://docs.whitebit.com/private/http-trade-v4/#query-unexecutedactive-orders
1591
+
1592
+ :param str [symbol]: unified market symbol
1296
1593
  :param int [since]: the earliest time in ms to fetch open orders for
1297
1594
  :param int [limit]: the maximum number of open order structures to retrieve
1298
1595
  :param dict [params]: extra parameters specific to the exchange API endpoint
1299
1596
  :returns Order[]: a list of `order structures <https://docs.ccxt.com/#/?id=order-structure>`
1300
1597
  """
1301
- if symbol is None:
1302
- raise ArgumentsRequired(self.id + ' fetchOpenOrders() requires a symbol argument')
1303
1598
  self.load_markets()
1304
- market = self.market(symbol)
1305
- request = {
1306
- 'market': market['id'],
1307
- }
1599
+ market = None
1600
+ request: dict = {}
1601
+ if symbol is not None:
1602
+ market = self.market(symbol)
1603
+ request['market'] = market['id']
1308
1604
  if limit is not None:
1309
1605
  request['limit'] = min(limit, 100)
1310
1606
  response = self.v4PrivatePostOrders(self.extend(request, params))
@@ -1333,7 +1629,9 @@ class whitebit(Exchange, ImplicitAPI):
1333
1629
  def fetch_closed_orders(self, symbol: Str = None, since: Int = None, limit: Int = None, params={}) -> List[Order]:
1334
1630
  """
1335
1631
  fetches information on multiple closed orders made by the user
1336
- :see: https://docs.whitebit.com/private/http-trade-v4/#query-executed-orders
1632
+
1633
+ https://docs.whitebit.com/private/http-trade-v4/#query-executed-orders
1634
+
1337
1635
  :param str symbol: unified market symbol of the market orders were made in
1338
1636
  :param int [since]: the earliest time in ms to fetch orders for
1339
1637
  :param int [limit]: the maximum number of order structures to retrieve
@@ -1341,7 +1639,7 @@ class whitebit(Exchange, ImplicitAPI):
1341
1639
  :returns Order[]: a list of `order structures <https://docs.ccxt.com/#/?id=order-structure>`
1342
1640
  """
1343
1641
  self.load_markets()
1344
- request = {}
1642
+ request: dict = {}
1345
1643
  market = None
1346
1644
  if symbol is not None:
1347
1645
  market = self.market(symbol)
@@ -1380,8 +1678,8 @@ class whitebit(Exchange, ImplicitAPI):
1380
1678
  results = self.filter_by_symbol_since_limit(results, symbol, since, limit)
1381
1679
  return results
1382
1680
 
1383
- def parse_order_type(self, type):
1384
- types = {
1681
+ def parse_order_type(self, type: Str):
1682
+ types: dict = {
1385
1683
  'limit': 'limit',
1386
1684
  'market': 'market',
1387
1685
  'stop market': 'market',
@@ -1392,9 +1690,9 @@ class whitebit(Exchange, ImplicitAPI):
1392
1690
  }
1393
1691
  return self.safe_string(types, type, type)
1394
1692
 
1395
- def parse_order(self, order, market: Market = None) -> Order:
1693
+ def parse_order(self, order: dict, market: Market = None) -> Order:
1396
1694
  #
1397
- # createOrder, fetchOpenOrders
1695
+ # createOrder, fetchOpenOrders, cancelOrder
1398
1696
  #
1399
1697
  # {
1400
1698
  # "orderId":105687928629,
@@ -1409,6 +1707,7 @@ class whitebit(Exchange, ImplicitAPI):
1409
1707
  # "takerFee":"0.001",
1410
1708
  # "makerFee":"0",
1411
1709
  # "left":"100",
1710
+ # "price": "40000", # price if price isset
1412
1711
  # "dealFee":"0",
1413
1712
  # "activation_price":"0.065" # stop price(if stop limit or stop market)
1414
1713
  # }
@@ -1441,9 +1740,12 @@ class whitebit(Exchange, ImplicitAPI):
1441
1740
  if clientOrderId == '':
1442
1741
  clientOrderId = None
1443
1742
  price = self.safe_string(order, 'price')
1444
- stopPrice = self.safe_number(order, 'activation_price')
1743
+ triggerPrice = self.safe_number(order, 'activation_price')
1445
1744
  orderId = self.safe_string_2(order, 'orderId', 'id')
1446
1745
  type = self.safe_string(order, 'type')
1746
+ orderType = self.parse_order_type(type)
1747
+ if orderType == 'market':
1748
+ remaining = None
1447
1749
  amount = self.safe_string(order, 'amount')
1448
1750
  cost = self.safe_string(order, 'dealMoney')
1449
1751
  if (side == 'buy') and ((type == 'market') or (type == 'stop market')):
@@ -1470,9 +1772,8 @@ class whitebit(Exchange, ImplicitAPI):
1470
1772
  'status': None,
1471
1773
  'side': side,
1472
1774
  'price': price,
1473
- 'type': self.parse_order_type(type),
1474
- 'stopPrice': stopPrice,
1475
- 'triggerPrice': stopPrice,
1775
+ 'type': orderType,
1776
+ 'triggerPrice': triggerPrice,
1476
1777
  'amount': amount,
1477
1778
  'filled': filled,
1478
1779
  'remaining': remaining,
@@ -1485,7 +1786,9 @@ class whitebit(Exchange, ImplicitAPI):
1485
1786
  def fetch_order_trades(self, id: str, symbol: Str = None, since: Int = None, limit: Int = None, params={}):
1486
1787
  """
1487
1788
  fetch all the trades made from a single order
1488
- :see: https://docs.whitebit.com/private/http-trade-v4/#query-executed-order-deals
1789
+
1790
+ https://docs.whitebit.com/private/http-trade-v4/#query-executed-order-deals
1791
+
1489
1792
  :param str id: order id
1490
1793
  :param str symbol: unified market symbol
1491
1794
  :param int [since]: the earliest time in ms to fetch trades for
@@ -1494,7 +1797,7 @@ class whitebit(Exchange, ImplicitAPI):
1494
1797
  :returns dict[]: a list of `trade structures <https://docs.ccxt.com/#/?id=trade-structure>`
1495
1798
  """
1496
1799
  self.load_markets()
1497
- request = {
1800
+ request: dict = {
1498
1801
  'orderId': int(id),
1499
1802
  }
1500
1803
  market = None
@@ -1523,21 +1826,23 @@ class whitebit(Exchange, ImplicitAPI):
1523
1826
  # "limit": 100
1524
1827
  # }
1525
1828
  #
1526
- data = self.safe_value(response, 'records', [])
1829
+ data = self.safe_list(response, 'records', [])
1527
1830
  return self.parse_trades(data, market)
1528
1831
 
1529
- def fetch_deposit_address(self, code: str, params={}):
1832
+ def fetch_deposit_address(self, code: str, params={}) -> DepositAddress:
1530
1833
  """
1531
1834
  fetch the deposit address for a currency associated with self account
1532
- :see: https://docs.whitebit.com/private/http-main-v4/#get-fiat-deposit-address
1533
- :see: https://docs.whitebit.com/private/http-main-v4/#get-cryptocurrency-deposit-address
1835
+
1836
+ https://docs.whitebit.com/private/http-main-v4/#get-fiat-deposit-address
1837
+ https://docs.whitebit.com/private/http-main-v4/#get-cryptocurrency-deposit-address
1838
+
1534
1839
  :param str code: unified currency code
1535
1840
  :param dict [params]: extra parameters specific to the exchange API endpoint
1536
1841
  :returns dict: an `address structure <https://docs.ccxt.com/#/?id=address-structure>`
1537
1842
  """
1538
1843
  self.load_markets()
1539
1844
  currency = self.currency(code)
1540
- request = {
1845
+ request: dict = {
1541
1846
  'ticker': currency['id'],
1542
1847
  }
1543
1848
  response = None
@@ -1588,17 +1893,19 @@ class whitebit(Exchange, ImplicitAPI):
1588
1893
  tag = self.safe_string(account, 'memo')
1589
1894
  self.check_address(address)
1590
1895
  return {
1896
+ 'info': response,
1591
1897
  'currency': code,
1898
+ 'network': None,
1592
1899
  'address': address,
1593
1900
  'tag': tag,
1594
- 'network': None,
1595
- 'info': response,
1596
1901
  }
1597
1902
 
1598
1903
  def set_leverage(self, leverage: Int, symbol: Str = None, params={}):
1599
1904
  """
1600
1905
  set the level of leverage for a market
1601
- :see: https://docs.whitebit.com/private/http-trade-v4/#change-collateral-account-leverage
1906
+
1907
+ https://docs.whitebit.com/private/http-trade-v4/#change-collateral-account-leverage
1908
+
1602
1909
  :param float leverage: the rate of leverage
1603
1910
  :param str symbol: unified market symbol
1604
1911
  :param dict [params]: extra parameters specific to the exchange API endpoint
@@ -1609,7 +1916,7 @@ class whitebit(Exchange, ImplicitAPI):
1609
1916
  raise NotSupported(self.id + ' setLeverage() does not allow to set per symbol')
1610
1917
  if (leverage < 1) or (leverage > 20):
1611
1918
  raise BadRequest(self.id + ' setLeverage() leverage should be between 1 and 20')
1612
- request = {
1919
+ request: dict = {
1613
1920
  'leverage': leverage,
1614
1921
  }
1615
1922
  return self.v4PrivatePostCollateralAccountLeverage(self.extend(request, params))
@@ -1620,7 +1927,9 @@ class whitebit(Exchange, ImplicitAPI):
1620
1927
  def transfer(self, code: str, amount: float, fromAccount: str, toAccount: str, params={}) -> TransferEntry:
1621
1928
  """
1622
1929
  transfer currency internally between wallets on the same account
1623
- :see: https://docs.whitebit.com/private/http-main-v4/#transfer-between-main-and-trade-balances
1930
+
1931
+ https://docs.whitebit.com/private/http-main-v4/#transfer-between-main-and-trade-balances
1932
+
1624
1933
  :param str code: unified currency code
1625
1934
  :param float amount: amount to transfer
1626
1935
  :param str fromAccount: account to transfer from - main, spot, collateral
@@ -1634,7 +1943,7 @@ class whitebit(Exchange, ImplicitAPI):
1634
1943
  fromAccountId = self.safe_string(accountsByType, fromAccount, fromAccount)
1635
1944
  toAccountId = self.safe_string(accountsByType, toAccount, toAccount)
1636
1945
  amountString = self.currency_to_precision(code, amount)
1637
- request = {
1946
+ request: dict = {
1638
1947
  'ticker': currency['id'],
1639
1948
  'amount': amountString,
1640
1949
  'from': fromAccountId,
@@ -1646,7 +1955,7 @@ class whitebit(Exchange, ImplicitAPI):
1646
1955
  #
1647
1956
  return self.parse_transfer(response, currency)
1648
1957
 
1649
- def parse_transfer(self, transfer, currency: Currency = None):
1958
+ def parse_transfer(self, transfer: dict, currency: Currency = None) -> TransferEntry:
1650
1959
  #
1651
1960
  # []
1652
1961
  #
@@ -1662,10 +1971,12 @@ class whitebit(Exchange, ImplicitAPI):
1662
1971
  'status': None,
1663
1972
  }
1664
1973
 
1665
- def withdraw(self, code: str, amount: float, address, tag=None, params={}):
1974
+ def withdraw(self, code: str, amount: float, address: str, tag=None, params={}) -> Transaction:
1666
1975
  """
1667
1976
  make a withdrawal
1668
- :see: https://docs.whitebit.com/private/http-main-v4/#create-withdraw-request
1977
+
1978
+ https://docs.whitebit.com/private/http-main-v4/#create-withdraw-request
1979
+
1669
1980
  :param str code: unified currency code
1670
1981
  :param float amount: the amount to withdraw
1671
1982
  :param str address: the address to withdraw to
@@ -1675,7 +1986,7 @@ class whitebit(Exchange, ImplicitAPI):
1675
1986
  """
1676
1987
  self.load_markets()
1677
1988
  currency = self.currency(code) # check if it has canDeposit
1678
- request = {
1989
+ request: dict = {
1679
1990
  'ticker': currency['id'],
1680
1991
  'amount': self.currency_to_precision(code, amount),
1681
1992
  'address': address,
@@ -1700,11 +2011,12 @@ class whitebit(Exchange, ImplicitAPI):
1700
2011
  #
1701
2012
  return self.extend({'id': uniqueId}, self.parse_transaction(response, currency))
1702
2013
 
1703
- def parse_transaction(self, transaction, currency: Currency = None) -> Transaction:
2014
+ def parse_transaction(self, transaction: dict, currency: Currency = None) -> Transaction:
1704
2015
  #
1705
2016
  # {
1706
2017
  # "address": "3ApEASLcrQtZpg1TsssFgYF5V5YQJAKvuE", # deposit address
1707
2018
  # "uniqueId": null, # unique Id of deposit
2019
+ # "transactionId": "a6d71d69-2b17-4ad8-8b15-2d686c54a1a5",
1708
2020
  # "createdAt": 1593437922, # timestamp of deposit
1709
2021
  # "currency": "Bitcoin", # deposit currency
1710
2022
  # "ticker": "BTC", # deposit currency ticker
@@ -1728,6 +2040,7 @@ class whitebit(Exchange, ImplicitAPI):
1728
2040
  # "actual": 1, # current block confirmations
1729
2041
  # "required": 2 # required block confirmation for successful deposit
1730
2042
  # }
2043
+ # "centralized": False,
1731
2044
  # }
1732
2045
  #
1733
2046
  currency = self.safe_currency(None, currency)
@@ -1738,7 +2051,7 @@ class whitebit(Exchange, ImplicitAPI):
1738
2051
  method = self.safe_string(transaction, 'method')
1739
2052
  return {
1740
2053
  'id': self.safe_string(transaction, 'uniqueId'),
1741
- 'txid': self.safe_string(transaction, 'transactionHash'),
2054
+ 'txid': self.safe_string(transaction, 'transactionId'),
1742
2055
  'timestamp': timestamp,
1743
2056
  'datetime': self.iso8601(timestamp),
1744
2057
  'network': self.safe_string(transaction, 'network'),
@@ -1762,8 +2075,8 @@ class whitebit(Exchange, ImplicitAPI):
1762
2075
  'info': transaction,
1763
2076
  }
1764
2077
 
1765
- def parse_transaction_status(self, status):
1766
- statuses = {
2078
+ def parse_transaction_status(self, status: Str):
2079
+ statuses: dict = {
1767
2080
  '1': 'pending',
1768
2081
  '2': 'pending',
1769
2082
  '3': 'ok',
@@ -1786,7 +2099,9 @@ class whitebit(Exchange, ImplicitAPI):
1786
2099
  def fetch_deposit(self, id: str, code: Str = None, params={}):
1787
2100
  """
1788
2101
  fetch information on a deposit
1789
- :see: https://docs.whitebit.com/private/http-main-v4/#get-depositwithdraw-history
2102
+
2103
+ https://docs.whitebit.com/private/http-main-v4/#get-depositwithdraw-history
2104
+
1790
2105
  :param str id: deposit id
1791
2106
  :param str code: not used by whitebit fetchDeposit()
1792
2107
  :param dict [params]: extra parameters specific to the exchange API endpoint
@@ -1794,7 +2109,7 @@ class whitebit(Exchange, ImplicitAPI):
1794
2109
  """
1795
2110
  self.load_markets()
1796
2111
  currency = None
1797
- request = {
2112
+ request: dict = {
1798
2113
  'transactionMethod': 1,
1799
2114
  'uniqueId': id,
1800
2115
  'limit': 1,
@@ -1842,13 +2157,15 @@ class whitebit(Exchange, ImplicitAPI):
1842
2157
  # }
1843
2158
  #
1844
2159
  records = self.safe_value(response, 'records', [])
1845
- first = self.safe_value(records, 0, {})
2160
+ first = self.safe_dict(records, 0, {})
1846
2161
  return self.parse_transaction(first, currency)
1847
2162
 
1848
2163
  def fetch_deposits(self, code: Str = None, since: Int = None, limit: Int = None, params={}) -> List[Transaction]:
1849
2164
  """
1850
2165
  fetch all deposits made to an account
1851
- :see: https://docs.whitebit.com/private/http-main-v4/#get-depositwithdraw-history
2166
+
2167
+ https://docs.whitebit.com/private/http-main-v4/#get-depositwithdraw-history
2168
+
1852
2169
  :param str code: unified currency code
1853
2170
  :param int [since]: the earliest time in ms to fetch deposits for
1854
2171
  :param int [limit]: the maximum number of deposits structures to retrieve
@@ -1857,7 +2174,7 @@ class whitebit(Exchange, ImplicitAPI):
1857
2174
  """
1858
2175
  self.load_markets()
1859
2176
  currency = None
1860
- request = {
2177
+ request: dict = {
1861
2178
  'transactionMethod': 1,
1862
2179
  'limit': 100,
1863
2180
  'offset': 0,
@@ -1905,13 +2222,15 @@ class whitebit(Exchange, ImplicitAPI):
1905
2222
  # "total": 300 # total number of transactions, use self for calculating ‘limit’ and ‘offset'
1906
2223
  # }
1907
2224
  #
1908
- records = self.safe_value(response, 'records', [])
2225
+ records = self.safe_list(response, 'records', [])
1909
2226
  return self.parse_transactions(records, currency, since, limit)
1910
2227
 
1911
- def fetch_borrow_interest(self, code: Str = None, symbol: Str = None, since: Int = None, limit: Int = None, params={}):
2228
+ def fetch_borrow_interest(self, code: Str = None, symbol: Str = None, since: Int = None, limit: Int = None, params={}) -> List[BorrowInterest]:
1912
2229
  """
1913
2230
  fetch the interest owed by the user for borrowing currency for margin trading
1914
- :see: https://docs.whitebit.com/private/http-trade-v4/#open-positions
2231
+
2232
+ https://docs.whitebit.com/private/http-trade-v4/#open-positions
2233
+
1915
2234
  :param str code: unified currency code
1916
2235
  :param str symbol: unified market symbol
1917
2236
  :param int [since]: the earliest time in ms to fetch borrrow interest for
@@ -1920,7 +2239,7 @@ class whitebit(Exchange, ImplicitAPI):
1920
2239
  :returns dict[]: a list of `borrow interest structures <https://docs.ccxt.com/#/?id=borrow-interest-structure>`
1921
2240
  """
1922
2241
  self.load_markets()
1923
- request = {}
2242
+ request: dict = {}
1924
2243
  market = None
1925
2244
  if symbol is not None:
1926
2245
  market = self.market(symbol)
@@ -1950,7 +2269,7 @@ class whitebit(Exchange, ImplicitAPI):
1950
2269
  interest = self.parse_borrow_interests(response, market)
1951
2270
  return self.filter_by_currency_since_limit(interest, code, since, limit)
1952
2271
 
1953
- def parse_borrow_interest(self, info, market: Market = None):
2272
+ def parse_borrow_interest(self, info: dict, market: Market = None) -> BorrowInterest:
1954
2273
  #
1955
2274
  # {
1956
2275
  # "positionId": 191823,
@@ -1974,21 +2293,23 @@ class whitebit(Exchange, ImplicitAPI):
1974
2293
  symbol = self.safe_symbol(marketId, market, '_')
1975
2294
  timestamp = self.safe_timestamp(info, 'modifyDate')
1976
2295
  return {
2296
+ 'info': info,
1977
2297
  'symbol': symbol,
1978
- 'marginMode': 'cross',
1979
2298
  'currency': 'USDT',
1980
2299
  'interest': self.safe_number(info, 'unrealizedFunding'),
1981
2300
  'interestRate': 0.00098, # https://whitebit.com/fees
1982
2301
  'amountBorrowed': self.safe_number(info, 'amount'),
2302
+ 'marginMode': 'cross',
1983
2303
  'timestamp': timestamp,
1984
2304
  'datetime': self.iso8601(timestamp),
1985
- 'info': info,
1986
2305
  }
1987
2306
 
1988
- def fetch_funding_rate(self, symbol: str, params={}):
2307
+ def fetch_funding_rate(self, symbol: str, params={}) -> FundingRate:
1989
2308
  """
1990
- :see: https://docs.whitebit.com/public/http-v4/#available-futures-markets-list
1991
2309
  fetch the current funding rate
2310
+
2311
+ https://docs.whitebit.com/public/http-v4/#available-futures-markets-list
2312
+
1992
2313
  :param str symbol: unified market symbol
1993
2314
  :param dict [params]: extra parameters specific to the exchange API endpoint
1994
2315
  :returns dict: a `funding rate structure <https://docs.ccxt.com/#/?id=funding-rate-structure>`
@@ -1998,13 +2319,15 @@ class whitebit(Exchange, ImplicitAPI):
1998
2319
  response = self.fetch_funding_rates([symbol], params)
1999
2320
  return self.safe_value(response, symbol)
2000
2321
 
2001
- def fetch_funding_rates(self, symbols: Strings = None, params={}):
2322
+ def fetch_funding_rates(self, symbols: Strings = None, params={}) -> FundingRates:
2002
2323
  """
2003
- :see: https://docs.whitebit.com/public/http-v4/#available-futures-markets-list
2004
2324
  fetch the funding rate for multiple markets
2325
+
2326
+ https://docs.whitebit.com/public/http-v4/#available-futures-markets-list
2327
+
2005
2328
  :param str[]|None symbols: list of unified market symbols
2006
2329
  :param dict [params]: extra parameters specific to the exchange API endpoint
2007
- :returns dict: a dictionary of `funding rates structures <https://docs.ccxt.com/#/?id=funding-rates-structure>`, indexe by market symbols
2330
+ :returns dict[]: a list of `funding rate structures <https://docs.ccxt.com/#/?id=funding-rates-structure>`, indexed by market symbols
2008
2331
  """
2009
2332
  self.load_markets()
2010
2333
  symbols = self.market_symbols(symbols)
@@ -2053,11 +2376,10 @@ class whitebit(Exchange, ImplicitAPI):
2053
2376
  # }
2054
2377
  # ]
2055
2378
  #
2056
- data = self.safe_value(response, 'result', [])
2057
- result = self.parse_funding_rates(data)
2058
- return self.filter_by_array(result, 'symbol', symbols)
2379
+ data = self.safe_list(response, 'result', [])
2380
+ return self.parse_funding_rates(data, symbols)
2059
2381
 
2060
- def parse_funding_rate(self, contract, market: Market = None):
2382
+ def parse_funding_rate(self, contract, market: Market = None) -> FundingRate:
2061
2383
  #
2062
2384
  # {
2063
2385
  # "ticker_id":"ADA_PERP",
@@ -2096,7 +2418,7 @@ class whitebit(Exchange, ImplicitAPI):
2096
2418
  indexPrice = self.safe_number(contract, 'indexPrice')
2097
2419
  interestRate = self.safe_number(contract, 'interestRate')
2098
2420
  fundingRate = self.safe_number(contract, 'funding_rate')
2099
- nextFundingTime = self.safe_integer(contract, 'next_funding_rate_timestamp')
2421
+ fundingTime = self.safe_integer(contract, 'next_funding_rate_timestamp')
2100
2422
  return {
2101
2423
  'info': contract,
2102
2424
  'symbol': symbol,
@@ -2106,17 +2428,88 @@ class whitebit(Exchange, ImplicitAPI):
2106
2428
  'timestamp': None,
2107
2429
  'datetime': None,
2108
2430
  'fundingRate': fundingRate,
2109
- 'fundingTimestamp': None,
2110
- 'fundingDatetime': self.iso8601(None),
2431
+ 'fundingTimestamp': fundingTime,
2432
+ 'fundingDatetime': self.iso8601(fundingTime),
2111
2433
  'nextFundingRate': None,
2112
- 'nextFundingTimestamp': nextFundingTime,
2113
- 'nextFundingDatetime': self.iso8601(nextFundingTime),
2434
+ 'nextFundingTimestamp': None,
2435
+ 'nextFundingDatetime': None,
2114
2436
  'previousFundingRate': None,
2115
2437
  'previousFundingTimestamp': None,
2116
2438
  'previousFundingDatetime': None,
2439
+ 'interval': None,
2117
2440
  }
2118
2441
 
2119
- def is_fiat(self, currency):
2442
+ def fetch_deposits_withdrawals(self, code: Str = None, since: Int = None, limit: Int = None, params={}) -> List[Transaction]:
2443
+ """
2444
+ fetch history of deposits and withdrawals
2445
+
2446
+ https://github.com/whitebit-exchange/api-docs/blob/main/pages/private/http-main-v4.md#get-depositwithdraw-history
2447
+
2448
+ :param str [code]: unified currency code for the currency of the deposit/withdrawals, default is None
2449
+ :param int [since]: timestamp in ms of the earliest deposit/withdrawal, default is None
2450
+ :param int [limit]: max number of deposit/withdrawals to return, default = 50, Min: 1, Max: 100
2451
+ :param dict [params]: extra parameters specific to the exchange API endpoint
2452
+
2453
+ EXCHANGE SPECIFIC PARAMETERS
2454
+ :param number [params.transactionMethod]: Method. Example: 1 to display deposits / 2 to display withdraws. Do not send self parameter in order to receive both deposits and withdraws.
2455
+ :param str [params.address]: Can be used for filtering transactions by specific address or memo.
2456
+ :param str[] [params.addresses]: Can be used for filtering transactions by specific addresses or memos(max: 20).
2457
+ :param str [params.uniqueId]: Can be used for filtering transactions by specific unique id
2458
+ :param int [params.offset]: If you want the request to return entries starting from a particular line, you can use OFFSET clause to tell it where it should start. Default: 0, Min: 0, Max: 10000
2459
+ :param str[] [params.status]: Can be used for filtering transactions by status codes. Caution: You must use self parameter with appropriate transactionMethod and use valid status codes for self method. You can find them below. Example: "status": [3,7]
2460
+ :returns dict: a list of `transaction structure <https://docs.ccxt.com/#/?id=transaction-structure>`
2461
+ """
2462
+ self.load_markets()
2463
+ request: dict = {}
2464
+ currency = None
2465
+ if code is not None:
2466
+ currency = self.currency(code)
2467
+ request['ticker'] = currency['id']
2468
+ if limit is not None:
2469
+ request['limit'] = limit # default 1000
2470
+ response = self.v4PrivatePostMainAccountHistory(self.extend(request, params))
2471
+ #
2472
+ # {
2473
+ # "limit": 100,
2474
+ # "offset": 0,
2475
+ # "records": [
2476
+ # {
2477
+ # "address": "3ApEASLcrQtZpg1TsssFgYF5V5YQJAKvuE", # deposit address
2478
+ # "uniqueId": null, # unique Id of deposit
2479
+ # "createdAt": 1593437922, # timestamp of deposit
2480
+ # "currency": "Bitcoin", # deposit currency
2481
+ # "ticker": "BTC", # deposit currency ticker
2482
+ # "method": 1, # called method 1 - deposit, 2 - withdraw
2483
+ # "amount": "0.0006", # amount of deposit
2484
+ # "description": "", # deposit description
2485
+ # "memo": "", # deposit memo
2486
+ # "fee": "0", # deposit fee
2487
+ # "status": 15, # transactions status
2488
+ # "network": null, # if currency is multinetwork
2489
+ # "transactionHash": "a275a514013e4e0f927fd0d1bed215e7f6f2c4c6ce762836fe135ec22529d886", # deposit transaction hash
2490
+ # "transactionId": "5e112b38-9652-11ed-a1eb-0242ac120002", # transaction id
2491
+ # "details": {
2492
+ # "partial": { # details about partially successful withdrawals
2493
+ # "requestAmount": "50000", # requested withdrawal amount
2494
+ # "processedAmount": "39000", # processed withdrawal amount
2495
+ # "processedFee": "273", # fee for processed withdrawal amount
2496
+ # "normalizeTransaction": "" # deposit id
2497
+ # }
2498
+ # },
2499
+ # "confirmations": { # if transaction status == 15(Pending) you can see self object
2500
+ # "actual": 1, # current block confirmations
2501
+ # "required": 2 # required block confirmation for successful deposit
2502
+ # }
2503
+ # },
2504
+ # {...},
2505
+ # ],
2506
+ # "total": 300 # total number of transactions, use self for calculating ‘limit’ and ‘offset'
2507
+ # }
2508
+ #
2509
+ records = self.safe_list(response, 'records')
2510
+ return self.parse_transactions(records, currency, since, limit)
2511
+
2512
+ def is_fiat(self, currency: str) -> bool:
2120
2513
  fiatCurrencies = self.safe_value(self.options, 'fiatCurrencies', [])
2121
2514
  return self.in_array(currency, fiatCurrencies)
2122
2515
 
@@ -2148,7 +2541,7 @@ class whitebit(Exchange, ImplicitAPI):
2148
2541
  }
2149
2542
  return {'url': url, 'method': method, 'body': body, 'headers': headers}
2150
2543
 
2151
- def handle_errors(self, code, reason, url, method, headers, body, response, requestHeaders, requestBody):
2544
+ def handle_errors(self, code: int, reason: str, url: str, method: str, headers: dict, body: str, response, requestHeaders, requestBody):
2152
2545
  if (code == 418) or (code == 429):
2153
2546
  raise DDoSProtection(self.id + ' ' + str(code) + ' ' + reason + ' ' + body)
2154
2547
  if code == 404:
@@ -2169,9 +2562,11 @@ class whitebit(Exchange, ImplicitAPI):
2169
2562
  if hasErrorStatus:
2170
2563
  errorInfo = status
2171
2564
  else:
2172
- errorObject = self.safe_value(response, 'errors')
2173
- if errorObject is not None:
2174
- errorKey = list(errorObject.keys())[0]
2565
+ errorObject = self.safe_dict(response, 'errors', {})
2566
+ errorKeys = list(errorObject.keys())
2567
+ errorsLength = len(errorKeys)
2568
+ if errorsLength > 0:
2569
+ errorKey = errorKeys[0]
2175
2570
  errorMessageArray = self.safe_value(errorObject, errorKey, [])
2176
2571
  errorMessageLength = len(errorMessageArray)
2177
2572
  errorInfo = errorMessageArray[0] if (errorMessageLength > 0) else body