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
@@ -0,0 +1,2832 @@
1
+ # -*- coding: utf-8 -*-
2
+
3
+ # PLEASE DO NOT EDIT THIS FILE, IT IS GENERATED AND WILL BE OVERWRITTEN:
4
+ # https://github.com/ccxt/ccxt/blob/master/CONTRIBUTING.md#how-to-contribute-code
5
+
6
+ from ccxt.async_support.base.exchange import Exchange
7
+ from ccxt.abstract.oxfun import ImplicitAPI
8
+ import asyncio
9
+ import hashlib
10
+ from ccxt.base.types import Account, Balances, Bool, Currencies, Currency, DepositAddress, Int, LeverageTier, LeverageTiers, Market, Num, Order, OrderBook, OrderRequest, OrderSide, OrderType, Str, Strings, Ticker, Tickers, FundingRate, FundingRates, Trade, Transaction, TransferEntry
11
+ from typing import List
12
+ from ccxt.base.errors import ExchangeError
13
+ from ccxt.base.errors import AuthenticationError
14
+ from ccxt.base.errors import AccountNotEnabled
15
+ from ccxt.base.errors import ArgumentsRequired
16
+ from ccxt.base.errors import BadRequest
17
+ from ccxt.base.errors import BadSymbol
18
+ from ccxt.base.errors import MarketClosed
19
+ from ccxt.base.errors import InsufficientFunds
20
+ from ccxt.base.errors import InvalidOrder
21
+ from ccxt.base.errors import OrderNotFound
22
+ from ccxt.base.errors import NotSupported
23
+ from ccxt.base.errors import OperationFailed
24
+ from ccxt.base.errors import NetworkError
25
+ from ccxt.base.errors import RateLimitExceeded
26
+ from ccxt.base.errors import RequestTimeout
27
+ from ccxt.base.decimal_to_precision import TICK_SIZE
28
+ from ccxt.base.precise import Precise
29
+
30
+
31
+ class oxfun(Exchange, ImplicitAPI):
32
+
33
+ def describe(self):
34
+ return self.deep_extend(super(oxfun, self).describe(), {
35
+ 'id': 'oxfun',
36
+ 'name': 'OXFUN',
37
+ 'countries': ['PA'], # Panama todo check
38
+ 'version': 'v3',
39
+ 'rateLimit': 120, # 100 requests per second and 25000 per 5 minutes
40
+ 'pro': True,
41
+ 'has': {
42
+ 'CORS': None,
43
+ 'spot': True,
44
+ 'margin': False,
45
+ 'swap': True,
46
+ 'future': False,
47
+ 'option': False,
48
+ 'addMargin': False,
49
+ 'cancelAllOrders': True,
50
+ 'cancelOrder': True,
51
+ 'cancelOrders': True,
52
+ 'closeAllPositions': False,
53
+ 'closePosition': False,
54
+ 'createDepositAddress': False,
55
+ 'createMarketBuyOrderWithCost': True,
56
+ 'createMarketOrderWithCost': False,
57
+ 'createMarketSellOrderWithCost': False,
58
+ 'createOrder': True,
59
+ 'createOrders': True,
60
+ 'createPostOnlyOrder': True,
61
+ 'createReduceOnlyOrder': False,
62
+ 'createStopLimitOrder': True,
63
+ 'createStopMarketOrder': True,
64
+ 'createStopOrder': True,
65
+ 'deposit': False,
66
+ 'editOrder': False,
67
+ 'fetchAccounts': True,
68
+ 'fetchBalance': True,
69
+ 'fetchBidsAsks': False,
70
+ 'fetchBorrowInterest': False,
71
+ 'fetchBorrowRateHistories': False,
72
+ 'fetchBorrowRateHistory': False,
73
+ 'fetchCanceledOrders': False,
74
+ 'fetchClosedOrder': False,
75
+ 'fetchClosedOrders': False,
76
+ 'fetchCrossBorrowRate': False,
77
+ 'fetchCrossBorrowRates': False,
78
+ 'fetchCurrencies': True,
79
+ 'fetchDeposit': False,
80
+ 'fetchDepositAddress': True,
81
+ 'fetchDepositAddresses': False,
82
+ 'fetchDepositAddressesByNetwork': False,
83
+ 'fetchDeposits': True,
84
+ 'fetchDepositWithdrawFee': False,
85
+ 'fetchDepositWithdrawFees': False,
86
+ 'fetchFundingHistory': True,
87
+ 'fetchFundingRate': 'emulated',
88
+ 'fetchFundingRateHistory': True,
89
+ 'fetchFundingRates': True,
90
+ 'fetchIndexOHLCV': False,
91
+ 'fetchIsolatedBorrowRate': False,
92
+ 'fetchIsolatedBorrowRates': False,
93
+ 'fetchL3OrderBook': False,
94
+ 'fetchLedger': False,
95
+ 'fetchLeverage': False,
96
+ 'fetchLeverageTiers': True,
97
+ 'fetchMarketLeverageTiers': 'emulated',
98
+ 'fetchMarkets': True,
99
+ 'fetchMarkOHLCV': False,
100
+ 'fetchMyTrades': True,
101
+ 'fetchOHLCV': True,
102
+ 'fetchOpenInterestHistory': False,
103
+ 'fetchOpenOrder': False,
104
+ 'fetchOpenOrders': True,
105
+ 'fetchOrder': True,
106
+ 'fetchOrderBook': True,
107
+ 'fetchOrderBooks': False,
108
+ 'fetchOrders': False,
109
+ 'fetchOrderTrades': False,
110
+ 'fetchPosition': False,
111
+ 'fetchPositionHistory': False,
112
+ 'fetchPositionMode': False,
113
+ 'fetchPositions': True,
114
+ 'fetchPositionsForSymbol': False,
115
+ 'fetchPositionsHistory': False,
116
+ 'fetchPositionsRisk': False,
117
+ 'fetchPremiumIndexOHLCV': False,
118
+ 'fetchStatus': False,
119
+ 'fetchTicker': True,
120
+ 'fetchTickers': True,
121
+ 'fetchTime': False,
122
+ 'fetchTrades': True,
123
+ 'fetchTradingFee': False,
124
+ 'fetchTradingFees': False,
125
+ 'fetchTradingLimits': False,
126
+ 'fetchTransactionFee': False,
127
+ 'fetchTransactionFees': False,
128
+ 'fetchTransactions': False,
129
+ 'fetchTransfers': True,
130
+ 'fetchWithdrawal': False,
131
+ 'fetchWithdrawals': True,
132
+ 'fetchWithdrawalWhitelist': False,
133
+ 'reduceMargin': False,
134
+ 'repayCrossMargin': False,
135
+ 'repayIsolatedMargin': False,
136
+ 'setLeverage': False,
137
+ 'setMargin': False,
138
+ 'setMarginMode': False,
139
+ 'setPositionMode': False,
140
+ 'signIn': False,
141
+ 'transfer': True,
142
+ 'withdraw': True,
143
+ 'ws': True,
144
+ },
145
+ 'timeframes': {
146
+ '1m': '60s',
147
+ '5m': '300s',
148
+ '15m': '900s',
149
+ '30m': '1800s',
150
+ '1h': '3600s',
151
+ '2h': '7200s',
152
+ '4h': '14400s',
153
+ '1d': '86400s',
154
+ },
155
+ 'urls': {
156
+ 'logo': 'https://github.com/ccxt/ccxt/assets/43336371/6a196124-c1ee-4fae-8573-962071b61a85',
157
+ 'referral': 'https://ox.fun/register?shareAccountId=5ZUD4a7G',
158
+ 'api': {
159
+ 'public': 'https://api.ox.fun',
160
+ 'private': 'https://api.ox.fun',
161
+ },
162
+ 'test': {
163
+ 'public': 'https://stgapi.ox.fun',
164
+ 'private': 'https://stgapi.ox.fun',
165
+ },
166
+ 'www': 'https://ox.fun/',
167
+ 'doc': 'https://docs.ox.fun/',
168
+ 'fees': 'https://support.ox.fun/en/articles/8819866-trading-fees',
169
+ },
170
+ 'api': {
171
+ 'public': {
172
+ 'get': {
173
+ 'v3/markets': 1,
174
+ 'v3/assets': 1,
175
+ 'v3/tickers': 1,
176
+ 'v3/funding/estimates': 1,
177
+ 'v3/candles': 1,
178
+ 'v3/depth': 1,
179
+ 'v3/markets/operational': 1,
180
+ 'v3/exchange-trades': 1,
181
+ 'v3/funding/rates': 1,
182
+ 'v3/leverage/tiers': 1,
183
+ },
184
+ },
185
+ 'private': {
186
+ 'get': {
187
+ 'v3/account': 1,
188
+ 'v3/account/names': 1,
189
+ 'v3/wallet': 1, # retruns only FUNDING in OX
190
+ 'v3/transfer': 1,
191
+ 'v3/balances': 1,
192
+ 'v3/positions': 1,
193
+ 'v3/funding': 1,
194
+ 'v3/deposit-addresses': 1,
195
+ 'v3/deposit': 1,
196
+ 'v3/withdrawal-addresses': 1,
197
+ 'v3/withdrawal': 1,
198
+ 'v3/withdrawal-fees': 1,
199
+ 'v3/orders/status': 1,
200
+ 'v3/orders/working': 1,
201
+ 'v3/trades': 1,
202
+ },
203
+ 'post': {
204
+ 'v3/transfer': 1,
205
+ 'v3/withdrawal': 1,
206
+ 'v3/orders/place': 1,
207
+ },
208
+ 'delete': {
209
+ 'v3/orders/cancel': 1,
210
+ 'v3/orders/cancel-all': 1,
211
+ },
212
+ },
213
+ },
214
+ 'fees': {
215
+ 'trading': {
216
+ 'tierBased': True,
217
+ 'percentage': True,
218
+ 'maker': self.parse_number('0.00020'),
219
+ 'taker': self.parse_number('0.00070'),
220
+ 'tiers': {
221
+ 'maker': [
222
+ [self.parse_number('0'), self.parse_number('0.00020')],
223
+ [self.parse_number('2500000'), self.parse_number('0.00010')],
224
+ [self.parse_number('25000000'), self.parse_number('0')],
225
+ ],
226
+ 'taker': [
227
+ [self.parse_number('0'), self.parse_number('0.00070')],
228
+ [self.parse_number('2500000'), self.parse_number('0.00050')],
229
+ [self.parse_number('25000000'), self.parse_number('0.00040')],
230
+ ],
231
+ },
232
+ },
233
+ },
234
+ 'precisionMode': TICK_SIZE,
235
+ # exchange-specific options
236
+ 'options': {
237
+ 'sandboxMode': False,
238
+ 'networks': {
239
+ 'BTC': 'Bitcoin',
240
+ 'ERC20': 'Ethereum',
241
+ 'AVAX': 'Avalanche',
242
+ 'SOL': 'Solana',
243
+ 'ARB': 'Arbitrum',
244
+ 'MATIC': 'Polygon',
245
+ 'FTM': 'Fantom',
246
+ 'BNB': 'BNBSmartChain',
247
+ 'OPTIMISM': 'Optimism',
248
+ },
249
+ 'networksById': {
250
+ 'Bitcoin': 'BTC',
251
+ 'Ethereum': 'ERC20',
252
+ 'Avalanche': 'AVAX',
253
+ 'Solana': 'SOL',
254
+ 'Arbitrum': 'ARB',
255
+ 'Polygon': 'MATIC',
256
+ 'Fantom': 'FTM',
257
+ 'Base': 'BASE',
258
+ 'BNBSmartChain': 'BNB',
259
+ 'Optimism': 'OPTIMISM',
260
+ },
261
+ },
262
+ 'exceptions': {
263
+ 'exact': {
264
+ '-0010': OperationFailed, # {"event":null,"success":false,"message":"Validation failed","code":"0010","data":null} - failed transfer
265
+ '-429': RateLimitExceeded, # Rate limit reached
266
+ '-05001': AuthenticationError, # Your operation authority is invalid
267
+ '-10001': ExchangeError, # General networking failure
268
+ '-20000': BadRequest, # Signature is invalid
269
+ '-20001': BadRequest, # "success":false,"code":"20001","message":"marketCode is invalid"
270
+ '-20002': BadRequest, # Unexpected error, please check if your request data complies with the specification.
271
+ '-20003': NotSupported, # Unrecognized operation
272
+ '-20005': AuthenticationError, # Already logged in
273
+ '-20006': BadRequest, # Quantity must be greater than zero
274
+ '-20007': AuthenticationError, # You are accessing server too rapidly
275
+ '-20008': BadRequest, # clientOrderId must be greater than zero if provided
276
+ '-20009': BadRequest, # JSON data format is invalid
277
+ '-20010': ArgumentsRequired, # Either clientOrderId or orderId is required
278
+ '-20011': ArgumentsRequired, # marketCode is required
279
+ '-20012': ArgumentsRequired, # side is required
280
+ '-20013': ArgumentsRequired, # orderType is required
281
+ '-20014': BadRequest, # clientOrderId is not long type
282
+ '-20015': BadSymbol, # marketCode is invalid
283
+ '-20016': BadRequest, # side is invalid
284
+ '-20017': BadRequest, # orderType is invalid
285
+ '-20018': BadRequest, # timeInForce is invalid
286
+ '-20019': BadRequest, # orderId is invalid
287
+ '-20020': BadRequest, # stopPrice or limitPrice is invalid
288
+ '-20021': BadRequest, # price is invalid
289
+ '-20022': ArgumentsRequired, # price is required for LIMIT order
290
+ '-20023': ArgumentsRequired, # timestamp is required
291
+ '-20024': ExchangeError, # timestamp exceeds the threshold
292
+ '-20025': AuthenticationError, # API key is invalid
293
+ '-20026': BadRequest, # Token is invalid or expired
294
+ '-20027': BadRequest, # The length of the message exceeds the maximum length
295
+ '-20028': BadRequest, # price or stopPrice or limitPrice must be greater than zero
296
+ '-20029': BadRequest, # stopPrice must be less than limitPrice for Buy Stop Order
297
+ '-20030': BadRequest, # limitPrice must be less than stopPrice for Sell Stop Order
298
+ '-20031': MarketClosed, # The marketCode is closed for trading temporarily
299
+ '-20032': NetworkError, # Failed to submit due to timeout in server side
300
+ '-20033': BadRequest, # triggerType is invalid
301
+ '-20034': BadRequest, # The size of tag must be less than 32
302
+ '-20050': ExchangeError, # selfTradePreventionMode is invalid
303
+ '-30001': BadRequest, # {"success":false,"code":"30001","message":"Required parameter 'marketCode' is missing"}
304
+ '-35034': AuthenticationError, # {"success":false,"code":"35034","message":"Wallet API is not functioning properly, please try again or contact support."}
305
+ '-35046': AuthenticationError, # {"success":false,"code":"35046","message":"Error. Please refresh the page."}
306
+ '-40001': ExchangeError, # Alert from the server
307
+ '-50001': ExchangeError, # Unknown server error
308
+ '-300001': AccountNotEnabled, # Invalid account status xxx, please contact administration if any questions
309
+ '-300011': InvalidOrder, # Repo market orders are not allowed during the auction window
310
+ '-300012': InvalidOrder, # Repo bids above 0 and offers below 0 are not allowed during the auction window
311
+ '-100005': OrderNotFound, # Open order not found
312
+ '-100006': InvalidOrder, # Open order is not owned by the user
313
+ '-100008': BadRequest, # Quantity cannot be less than the quantity increment xxx
314
+ '-100015': NetworkError, # recvWindow xxx has expired
315
+ '-710001': ExchangeError, # System failure, exception thrown -> xxx
316
+ '-710002': BadRequest, # The price is lower than the minimum
317
+ '-710003': BadRequest, # The price is higher than the maximum
318
+ '-710004': BadRequest, # Position quantity exceeds the limit
319
+ '-710005': InsufficientFunds, # Insufficient margin
320
+ '-710006': InsufficientFunds, # Insufficient balance
321
+ '-710007': InsufficientFunds, # Insufficient position
322
+ '-000101': NetworkError, # Internal server is unavailable temporary, try again later
323
+ '-000201': NetworkError, # Trade service is busy, try again later
324
+ },
325
+ 'broad': {
326
+ '-20001': OperationFailed, # Operation failed, please contact system administrator
327
+ '-200050': RequestTimeout, # The market is not active
328
+ },
329
+ },
330
+ })
331
+
332
+ async def fetch_markets(self, params={}) -> List[Market]:
333
+ """
334
+ retrieves data on all markets for bitmex
335
+
336
+ https://docs.ox.fun/?json#get-v3-markets
337
+
338
+ :param dict [params]: extra parameters specific to the exchange API endpoint
339
+ :returns dict[]: an array of objects representing market data
340
+ """
341
+ responseFromMarkets, responseFromTickers = await asyncio.gather(*[self.publicGetV3Markets(params), self.publicGetV3Tickers(params)])
342
+ marketsFromMarkets = self.safe_list(responseFromMarkets, 'data', [])
343
+ #
344
+ # {
345
+ # success: True,
346
+ # data: [
347
+ # {
348
+ # marketCode: 'OX-USD-SWAP-LIN',
349
+ # name: 'OX/USD Perp',
350
+ # referencePair: 'OX/USDT',
351
+ # base: 'OX',
352
+ # counter: 'USD',
353
+ # type: 'FUTURE',
354
+ # tickSize: '0.00001',
355
+ # minSize: '1',
356
+ # listedAt: '1704766320000',
357
+ # upperPriceBound: '0.02122',
358
+ # lowerPriceBound: '0.01142',
359
+ # markPrice: '0.01632',
360
+ # indexPrice: '0.01564',
361
+ # lastUpdatedAt: '1714762235569'
362
+ # },
363
+ # {
364
+ # marketCode: 'BTC-USD-SWAP-LIN',
365
+ # name: 'BTC/USD Perp',
366
+ # referencePair: 'BTC/USDT',
367
+ # base: 'BTC',
368
+ # counter: 'USD',
369
+ # type: 'FUTURE',
370
+ # tickSize: '1',
371
+ # minSize: '0.0001',
372
+ # listedAt: '1704686640000',
373
+ # upperPriceBound: '67983',
374
+ # lowerPriceBound: '55621',
375
+ # markPrice: '61802',
376
+ # indexPrice: '61813',
377
+ # lastUpdatedAt: '1714762234765'
378
+ # },
379
+ # {
380
+ # "marketCode": "MILK-OX",
381
+ # "name": "MILK/OX",
382
+ # "referencePair": "MILK/OX",
383
+ # "base": "MILK",
384
+ # "counter": "OX",
385
+ # "type": "SPOT",
386
+ # "tickSize": "0.0001",
387
+ # "minSize": "1",
388
+ # "listedAt": "1706608500000",
389
+ # "upperPriceBound": "1.0000",
390
+ # "lowerPriceBound": "-1.0000",
391
+ # "markPrice": "0.0269",
392
+ # "indexPrice": "0.0269",
393
+ # "lastUpdatedAt": "1714757402185"
394
+ # },
395
+ # ...
396
+ # ]
397
+ # }
398
+ #
399
+ marketsFromTickers = self.safe_list(responseFromTickers, 'data', [])
400
+ #
401
+ # {
402
+ # "success": True,
403
+ # "data": [
404
+ # {
405
+ # "marketCode": "DYM-USD-SWAP-LIN",
406
+ # "markPrice": "3.321",
407
+ # "open24h": "3.315",
408
+ # "high24h": "3.356",
409
+ # "low24h": "3.255",
410
+ # "volume24h": "0",
411
+ # "currencyVolume24h": "0",
412
+ # "openInterest": "1768.1",
413
+ # "lastTradedPrice": "3.543",
414
+ # "lastTradedQuantity": "1.0",
415
+ # "lastUpdatedAt": "1714853388102"
416
+ # },
417
+ # ...
418
+ # ]
419
+ # }
420
+ #
421
+ markets = self.array_concat(marketsFromMarkets, marketsFromTickers)
422
+ return self.parse_markets(markets)
423
+
424
+ def parse_markets(self, markets) -> List[Market]:
425
+ marketIds = []
426
+ result = []
427
+ for i in range(0, len(markets)):
428
+ market = markets[i]
429
+ marketId = self.safe_string(market, 'marketCode')
430
+ if not (self.in_array(marketId, marketIds)):
431
+ marketIds.append(marketId)
432
+ result.append(self.parse_market(market))
433
+ return result
434
+
435
+ def parse_market(self, market) -> Market:
436
+ id = self.safe_string(market, 'marketCode', '')
437
+ parts = id.split('-')
438
+ baseId = self.safe_string(parts, 0)
439
+ quoteId = self.safe_string(parts, 1)
440
+ base = self.safe_currency_code(baseId)
441
+ quote = self.safe_currency_code(quoteId)
442
+ symbol = base + '/' + quote
443
+ type = self.safe_string_lower(market, 'type', 'spot') # markets from v3/tickers are spot and have no type
444
+ settleId: Str = None
445
+ settle: Str = None
446
+ isFuture = (type == 'future') # the exchange has only perpetual futures
447
+ if isFuture:
448
+ type = 'swap'
449
+ settleId = 'OX'
450
+ settle = self.safe_currency_code('OX')
451
+ symbol = symbol + ':' + settle
452
+ isSpot = type == 'spot'
453
+ return self.safe_market_structure({
454
+ 'id': id,
455
+ 'numericId': None,
456
+ 'symbol': symbol,
457
+ 'base': base,
458
+ 'quote': quote,
459
+ 'settle': settle,
460
+ 'baseId': baseId,
461
+ 'quoteId': quoteId,
462
+ 'settleId': settleId,
463
+ 'type': type,
464
+ 'spot': isSpot,
465
+ 'margin': False,
466
+ 'swap': isFuture,
467
+ 'future': False,
468
+ 'option': False,
469
+ 'active': True,
470
+ 'contract': isFuture,
471
+ 'linear': True if isFuture else None,
472
+ 'inverse': False if isFuture else None,
473
+ 'taker': self.fees['trading']['taker'],
474
+ 'maker': self.fees['trading']['maker'],
475
+ 'contractSize': 1 if isFuture else None,
476
+ 'expiry': None,
477
+ 'expiryDatetime': None,
478
+ 'strike': None,
479
+ 'optionType': None,
480
+ 'precision': {
481
+ 'amount': None, # todo find it out
482
+ 'price': self.safe_number(market, 'tickSize'),
483
+ },
484
+ 'limits': {
485
+ 'leverage': {
486
+ 'min': None,
487
+ 'max': None,
488
+ },
489
+ 'amount': {
490
+ 'min': self.safe_number(market, 'minSize'),
491
+ 'max': None,
492
+ },
493
+ 'price': {
494
+ 'min': None,
495
+ 'max': None,
496
+ },
497
+ 'cost': {
498
+ 'min': None,
499
+ 'max': None,
500
+ },
501
+ },
502
+ 'created': self.safe_integer(market, 'listedAt'),
503
+ 'index': None,
504
+ 'info': market,
505
+ })
506
+
507
+ async def fetch_currencies(self, params={}) -> Currencies:
508
+ """
509
+ fetches all available currencies on an exchange
510
+
511
+ https://docs.ox.fun/?json#get-v3-assets
512
+
513
+ :param dict [params]: extra parameters specific to the exchange API endpoint
514
+ :returns dict: an associative dictionary of currencies
515
+ """
516
+ response = await self.publicGetV3Assets(params)
517
+ #
518
+ # {
519
+ # "success": True,
520
+ # "data": [
521
+ # {
522
+ # "asset": "OX",
523
+ # "isCollateral": True,
524
+ # "loanToValue": "1.000000000",
525
+ # "loanToValueFactor": "0.000000000",
526
+ # "networkList": [
527
+ # {
528
+ # "network": "BNBSmartChain",
529
+ # "tokenId": "0x78a0A62Fba6Fb21A83FE8a3433d44C73a4017A6f",
530
+ # "transactionPrecision": "18",
531
+ # "isWithdrawalFeeChargedToUser": True,
532
+ # "canDeposit": True,
533
+ # "canWithdraw": False,
534
+ # "minDeposit": "0.00010",
535
+ # "minWithdrawal": "0.00010"
536
+ # },
537
+ # {
538
+ # "network": "Polygon",
539
+ # "tokenId": "0x78a0A62Fba6Fb21A83FE8a3433d44C73a4017A6f",
540
+ # "transactionPrecision": "18",
541
+ # "isWithdrawalFeeChargedToUser": True,
542
+ # "canDeposit": True,
543
+ # "canWithdraw": False,
544
+ # "minDeposit": "0.00010",
545
+ # "minWithdrawal": "0.00010"
546
+ # },
547
+ # {
548
+ # "network": "Arbitrum",
549
+ # "tokenId": "0xba0Dda8762C24dA9487f5FA026a9B64b695A07Ea",
550
+ # "transactionPrecision": "18",
551
+ # "isWithdrawalFeeChargedToUser": True,
552
+ # "canDeposit": True,
553
+ # "canWithdraw": True,
554
+ # "minDeposit": "0.00010",
555
+ # "minWithdrawal": "0.00010"
556
+ # },
557
+ # {
558
+ # "network": "Ethereum",
559
+ # "tokenId": "0xba0Dda8762C24dA9487f5FA026a9B64b695A07Ea",
560
+ # "transactionPrecision": "18",
561
+ # "isWithdrawalFeeChargedToUser": True,
562
+ # "canDeposit": True,
563
+ # "canWithdraw": True,
564
+ # "minDeposit": "0.00010",
565
+ # "minWithdrawal": "0.00010"
566
+ # },
567
+ # {
568
+ # "network": "Arbitrum",
569
+ # "tokenId": "0x78a0A62Fba6Fb21A83FE8a3433d44C73a4017A6f",
570
+ # "transactionPrecision": "18",
571
+ # "isWithdrawalFeeChargedToUser": True,
572
+ # "canDeposit": True,
573
+ # "canWithdraw": False,
574
+ # "minDeposit": "0.00010",
575
+ # "minWithdrawal": "0.00010"
576
+ # },
577
+ # {
578
+ # "network": "Avalanche",
579
+ # "tokenId": "0x78a0A62Fba6Fb21A83FE8a3433d44C73a4017A6f",
580
+ # "transactionPrecision": "18",
581
+ # "isWithdrawalFeeChargedToUser": True,
582
+ # "canDeposit": True,
583
+ # "canWithdraw": False,
584
+ # "minDeposit": "0.00010",
585
+ # "minWithdrawal": "0.00010"
586
+ # },
587
+ # {
588
+ # "network": "Solana",
589
+ # "tokenId": "DV3845GEAVXfwpyVGGgWbqBVCtzHdCXNCGfcdboSEuZz",
590
+ # "transactionPrecision": "8",
591
+ # "isWithdrawalFeeChargedToUser": True,
592
+ # "canDeposit": True,
593
+ # "canWithdraw": True,
594
+ # "minDeposit": "0.00010",
595
+ # "minWithdrawal": "0.00010"
596
+ # },
597
+ # {
598
+ # "network": "Ethereum",
599
+ # "tokenId": "0x78a0A62Fba6Fb21A83FE8a3433d44C73a4017A6f",
600
+ # "transactionPrecision": "18",
601
+ # "isWithdrawalFeeChargedToUser": True,
602
+ # "canDeposit": True,
603
+ # "canWithdraw": False,
604
+ # "minDeposit": "0.00010",
605
+ # "minWithdrawal": "0.00010"
606
+ # }
607
+ # ]
608
+ # },
609
+ # {
610
+ # "asset": "BTC",
611
+ # "isCollateral": True,
612
+ # "loanToValue": "0.950000000",
613
+ # "loanToValueFactor": "0.000000000",
614
+ # "networkList": [
615
+ # {
616
+ # "network": "Bitcoin",
617
+ # "transactionPrecision": "8",
618
+ # "isWithdrawalFeeChargedToUser": True,
619
+ # "canDeposit": True,
620
+ # "canWithdraw": True,
621
+ # "minDeposit": "0.00010",
622
+ # "minWithdrawal": "0.00010"
623
+ # }
624
+ # ]
625
+ # },
626
+ # {
627
+ # "asset": "USDT.ARB",
628
+ # "isCollateral": True,
629
+ # "loanToValue": "0.950000000",
630
+ # "loanToValueFactor": "0.000000000",
631
+ # "networkList": [
632
+ # {
633
+ # "network": "Arbitrum",
634
+ # "tokenId": "0xFd086bC7CD5C481DCC9C85ebE478A1C0b69FCbb9",
635
+ # "transactionPrecision": "18",
636
+ # "isWithdrawalFeeChargedToUser": True,
637
+ # "canDeposit": True,
638
+ # "canWithdraw": True,
639
+ # "minDeposit": "0.00010",
640
+ # "minWithdrawal": "0.00010"
641
+ # }
642
+ # ]
643
+ # },
644
+ # ...
645
+ # ]
646
+ # }
647
+ #
648
+ data = self.safe_list(response, 'data', [])
649
+ result: dict = {}
650
+ for i in range(0, len(data)):
651
+ currency = data[i]
652
+ fullId = self.safe_string(currency, 'asset', '')
653
+ parts = fullId.split('.')
654
+ id = parts[0]
655
+ code = self.safe_currency_code(id)
656
+ networks: dict = {}
657
+ chains = self.safe_list(currency, 'networkList', [])
658
+ currencyMaxPrecision: Str = None
659
+ currencyDepositEnabled: Bool = None
660
+ currencyWithdrawEnabled: Bool = None
661
+ for j in range(0, len(chains)):
662
+ chain = chains[j]
663
+ networkId = self.safe_string(chain, 'network')
664
+ networkCode = self.network_id_to_code(networkId)
665
+ deposit = self.safe_bool(chain, 'canDeposit')
666
+ withdraw = self.safe_bool(chain, 'canWithdraw')
667
+ active = (deposit and withdraw)
668
+ minDeposit = self.safe_string(chain, 'minDeposit')
669
+ minWithdrawal = self.safe_string(chain, 'minWithdrawal')
670
+ precision = self.parse_precision(self.safe_string(chain, 'transactionPrecision'))
671
+ networks[networkCode] = {
672
+ 'id': networkId,
673
+ 'network': networkCode,
674
+ 'margin': None,
675
+ 'deposit': deposit,
676
+ 'withdraw': withdraw,
677
+ 'active': active,
678
+ 'fee': None,
679
+ 'precision': self.parse_number(precision),
680
+ 'limits': {
681
+ 'deposit': {
682
+ 'min': minDeposit,
683
+ 'max': None,
684
+ },
685
+ 'withdraw': {
686
+ 'min': minWithdrawal,
687
+ 'max': None,
688
+ },
689
+ },
690
+ 'info': chain,
691
+ }
692
+ if (currencyDepositEnabled is None) or deposit:
693
+ currencyDepositEnabled = deposit
694
+ if (currencyWithdrawEnabled is None) or withdraw:
695
+ currencyWithdrawEnabled = withdraw
696
+ if (currencyMaxPrecision is None) or Precise.string_gt(currencyMaxPrecision, precision):
697
+ currencyMaxPrecision = precision
698
+ if code in result:
699
+ # checking for specific ids.ARB
700
+ networks = self.extend(result[code]['networks'], networks)
701
+ result[code] = {
702
+ 'id': id,
703
+ 'code': code,
704
+ 'name': None,
705
+ 'type': None,
706
+ 'active': None,
707
+ 'deposit': currencyDepositEnabled,
708
+ 'withdraw': currencyWithdrawEnabled,
709
+ 'fee': None,
710
+ 'precision': self.parse_number(currencyMaxPrecision),
711
+ 'limits': {
712
+ 'amount': {
713
+ 'min': None,
714
+ 'max': None,
715
+ },
716
+ 'withdraw': {
717
+ 'min': None,
718
+ 'max': None,
719
+ },
720
+ },
721
+ 'networks': networks,
722
+ 'info': currency,
723
+ }
724
+ return result
725
+
726
+ async def fetch_tickers(self, symbols: Strings = None, params={}) -> Tickers:
727
+ """
728
+ fetches price tickers for multiple markets, statistical information calculated over the past 24 hours for each market
729
+
730
+ https://docs.ox.fun/?json#get-v3-tickers
731
+
732
+ :param str[]|None symbols: unified symbols of the markets to fetch the ticker for, all market tickers are returned if not assigned
733
+ :param dict [params]: extra parameters specific to the exchange API endpoint
734
+ :returns dict: a dictionary of `ticker structures <https://docs.ccxt.com/#/?id=ticker-structure>`
735
+ """
736
+ await self.load_markets()
737
+ symbols = self.market_symbols(symbols)
738
+ response = await self.publicGetV3Tickers(params)
739
+ #
740
+ # {
741
+ # "success": True,
742
+ # "data": [
743
+ # {
744
+ # "marketCode": "NII-USDT",
745
+ # "markPrice": "0",
746
+ # "open24h": "0",
747
+ # "high24h": "0",
748
+ # "low24h": "0",
749
+ # "volume24h": "0",
750
+ # "currencyVolume24h": "0",
751
+ # "openInterest": "0",
752
+ # "lastTradedPrice": "0",
753
+ # "lastTradedQuantity": "0",
754
+ # "lastUpdatedAt": "1714853388621"
755
+ # },
756
+ # {
757
+ # "marketCode": "GEC-USDT",
758
+ # "markPrice": "0",
759
+ # "open24h": "0",
760
+ # "high24h": "0",
761
+ # "low24h": "0",
762
+ # "volume24h": "0",
763
+ # "currencyVolume24h": "0",
764
+ # "openInterest": "0",
765
+ # "lastTradedPrice": "0",
766
+ # "lastTradedQuantity": "0",
767
+ # "lastUpdatedAt": "1714853388621"
768
+ # },
769
+ # {
770
+ # "marketCode": "DYM-USD-SWAP-LIN",
771
+ # "markPrice": "3.321",
772
+ # "open24h": "3.315",
773
+ # "high24h": "3.356",
774
+ # "low24h": "3.255",
775
+ # "volume24h": "0",
776
+ # "currencyVolume24h": "0",
777
+ # "openInterest": "1768.1",
778
+ # "lastTradedPrice": "3.543",
779
+ # "lastTradedQuantity": "1.0",
780
+ # "lastUpdatedAt": "1714853388102"
781
+ # },
782
+ # ...
783
+ # ]
784
+ # }
785
+ #
786
+ tickers = self.safe_list(response, 'data', [])
787
+ return self.parse_tickers(tickers, symbols)
788
+
789
+ async def fetch_ticker(self, symbol: str, params={}) -> Ticker:
790
+ """
791
+ fetches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market
792
+
793
+ https://docs.ox.fun/?json#get-v3-tickers
794
+
795
+ :param str symbol: unified symbol of the market to fetch the ticker for
796
+ :param dict [params]: extra parameters specific to the exchange API endpoint
797
+ :returns dict: a `ticker structure <https://docs.ccxt.com/#/?id=ticker-structure>`
798
+ """
799
+ await self.load_markets()
800
+ market = self.market(symbol)
801
+ request: dict = {
802
+ 'marketCode': market['id'],
803
+ }
804
+ response = await self.publicGetV3Tickers(self.extend(request, params))
805
+ #
806
+ # {
807
+ # "success": True,
808
+ # "data": [
809
+ # {
810
+ # "marketCode": "BTC-USD-SWAP-LIN",
811
+ # "markPrice": "64276",
812
+ # "open24h": "63674",
813
+ # "high24h": "64607",
814
+ # "low24h": "62933",
815
+ # "volume24h": "306317655.80000",
816
+ # "currencyVolume24h": "48.06810",
817
+ # "openInterest": "72.39250",
818
+ # "lastTradedPrice": "64300.0",
819
+ # "lastTradedQuantity": "1.0",
820
+ # "lastUpdatedAt": "1714925196034"
821
+ # }
822
+ # ]
823
+ # }
824
+ #
825
+ data = self.safe_list(response, 'data', [])
826
+ ticker = self.safe_dict(data, 0, {})
827
+ return self.parse_ticker(ticker, market)
828
+
829
+ def parse_ticker(self, ticker, market: Market = None) -> Ticker:
830
+ #
831
+ # {
832
+ # "marketCode": "BTC-USD-SWAP-LIN",
833
+ # "markPrice": "64276",
834
+ # "open24h": "63674",
835
+ # "high24h": "64607",
836
+ # "low24h": "62933",
837
+ # "volume24h": "306317655.80000",
838
+ # "currencyVolume24h": "48.06810",
839
+ # "openInterest": "72.39250",
840
+ # "lastTradedPrice": "64300.0",
841
+ # "lastTradedQuantity": "1.0",
842
+ # "lastUpdatedAt": "1714925196034"
843
+ # }
844
+ #
845
+ timestamp = self.safe_integer(ticker, 'lastUpdatedAt')
846
+ marketId = self.safe_string(ticker, 'marketCode')
847
+ market = self.safe_market(marketId, market)
848
+ symbol = market['symbol']
849
+ last = self.safe_string(ticker, 'lastTradedPrice')
850
+ return self.safe_ticker({
851
+ 'symbol': symbol,
852
+ 'timestamp': timestamp,
853
+ 'datetime': self.iso8601(timestamp),
854
+ 'high': self.safe_string(ticker, 'high24h'),
855
+ 'low': self.safe_string(ticker, 'low24h'),
856
+ 'bid': None,
857
+ 'bidVolume': None,
858
+ 'ask': None,
859
+ 'askVolume': None,
860
+ 'vwap': None,
861
+ 'open': self.safe_string(ticker, 'open24h'),
862
+ 'close': last,
863
+ 'last': last,
864
+ 'previousClose': None,
865
+ 'change': None,
866
+ 'percentage': None,
867
+ 'average': None,
868
+ 'baseVolume': self.safe_string(ticker, 'currencyVolume24h'),
869
+ 'quoteVolume': None, # the exchange returns cost in OX
870
+ 'markPrice': self.safe_string(ticker, 'markPrice'),
871
+ 'info': ticker,
872
+ }, market)
873
+
874
+ async def fetch_ohlcv(self, symbol: str, timeframe='1m', since: Int = None, limit: Int = None, params={}) -> List[list]:
875
+ """
876
+ fetches historical candlestick data containing the open, high, low, and close price, and the volume of a market
877
+
878
+ https://docs.ox.fun/?json#get-v3-candles
879
+
880
+ :param str symbol: unified symbol of the market to fetch OHLCV data for
881
+ :param str timeframe: the length of time each candle represents
882
+ :param int [since]: timestamp in ms of the earliest candle to fetch(default 24 hours ago)
883
+ :param int [limit]: the maximum amount of candles to fetch(default 200, max 500)
884
+ :param dict [params]: extra parameters specific to the exchange API endpoint
885
+ :param int [params.until]: timestamp in ms of the latest candle to fetch(default now)
886
+ :returns int[][]: A list of candles ordered, open, high, low, close, volume
887
+ """
888
+ await self.load_markets()
889
+ market = self.market(symbol)
890
+ timeframe = self.safe_string(self.timeframes, timeframe, timeframe)
891
+ request: dict = {
892
+ 'marketCode': market['id'],
893
+ 'timeframe': timeframe,
894
+ }
895
+ if since is not None:
896
+ request['startTime'] = since # startTime and endTime must be within 7 days of each other
897
+ if limit is not None:
898
+ request['limit'] = limit
899
+ until = self.safe_integer(params, 'until')
900
+ if until is not None:
901
+ request['endTime'] = until
902
+ params = self.omit(params, 'until')
903
+ elif since is not None:
904
+ request['endTime'] = self.sum(since, 7 * 24 * 60 * 60 * 1000) # for the exchange not to raise an exception if since is younger than 7 days
905
+ response = await self.publicGetV3Candles(self.extend(request, params))
906
+ #
907
+ # {
908
+ # "success": True,
909
+ # "timeframe": "3600s",
910
+ # "data": [
911
+ # {
912
+ # "open": "0.03240000",
913
+ # "high": "0.03240000",
914
+ # "low": "0.03240000",
915
+ # "close": "0.03240000",
916
+ # "volume": "0",
917
+ # "currencyVolume": "0",
918
+ # "openedAt": "1714906800000"
919
+ # },
920
+ # {
921
+ # "open": "0.03240000",
922
+ # "high": "0.03240000",
923
+ # "low": "0.03240000",
924
+ # "close": "0.03240000",
925
+ # "volume": "0",
926
+ # "currencyVolume": "0",
927
+ # "openedAt": "1714903200000"
928
+ # },
929
+ # ...
930
+ # ]
931
+ # }
932
+ #
933
+ result = self.safe_list(response, 'data', [])
934
+ return self.parse_ohlcvs(result, market, timeframe, since, limit)
935
+
936
+ def parse_ohlcv(self, ohlcv, market: Market = None) -> list:
937
+ #
938
+ # {
939
+ # "open": "0.03240000",
940
+ # "high": "0.03240000",
941
+ # "low": "0.03240000",
942
+ # "close": "0.03240000",
943
+ # "volume": "0",
944
+ # "currencyVolume": "0",
945
+ # "openedAt": "1714906800000"
946
+ # }
947
+ #
948
+ return [
949
+ self.safe_integer(ohlcv, 'openedAt'),
950
+ self.safe_number(ohlcv, 'open'),
951
+ self.safe_number(ohlcv, 'high'),
952
+ self.safe_number(ohlcv, 'low'),
953
+ self.safe_number(ohlcv, 'close'),
954
+ self.safe_number(ohlcv, 'currencyVolume'),
955
+ ]
956
+
957
+ async def fetch_order_book(self, symbol: str, limit: Int = None, params={}) -> OrderBook:
958
+ """
959
+ fetches information on open orders with bid(buy) and ask(sell) prices, volumes and other data
960
+
961
+ https://docs.ox.fun/?json#get-v3-depth
962
+
963
+ :param str symbol: unified symbol of the market to fetch the order book for
964
+ :param int [limit]: the maximum amount of order book entries to return(default 5, max 100)
965
+ :param dict [params]: extra parameters specific to the exchange API endpoint
966
+ :returns dict: A dictionary of `order book structures <https://docs.ccxt.com/#/?id=order-book-structure>` indexed by market symbols
967
+ """
968
+ await self.load_markets()
969
+ market = self.market(symbol)
970
+ request: dict = {
971
+ 'marketCode': market['id'],
972
+ }
973
+ if limit is not None:
974
+ request['level'] = limit
975
+ response = await self.publicGetV3Depth(self.extend(request, params))
976
+ #
977
+ # {
978
+ # "success": True,
979
+ # "level": "5",
980
+ # "data": {
981
+ # "marketCode": "BTC-USD-SWAP-LIN",
982
+ # "lastUpdatedAt": "1714933499266",
983
+ # "asks": [
984
+ # [64073.0, 8.4622],
985
+ # [64092.0, 8.1912],
986
+ # [64111.0, 8.0669],
987
+ # [64130.0, 11.7195],
988
+ # [64151.0, 10.1798]
989
+ # ],
990
+ # "bids": [
991
+ # [64022.0, 10.1292],
992
+ # [64003.0, 8.1619],
993
+ # [64000.0, 1.0],
994
+ # [63984.0, 12.7724],
995
+ # [63963.0, 11.0073]
996
+ # ]
997
+ # }
998
+ # }
999
+ #
1000
+ data = self.safe_dict(response, 'data', {})
1001
+ timestamp = self.safe_integer(data, 'lastUpdatedAt')
1002
+ return self.parse_order_book(data, market['symbol'], timestamp)
1003
+
1004
+ async def fetch_funding_rates(self, symbols: Strings = None, params={}) -> FundingRates:
1005
+ """
1006
+ fetch the current funding rates for multiple markets
1007
+
1008
+ https://docs.ox.fun/?json#get-v3-funding-estimates
1009
+
1010
+ :param str[] symbols: unified market symbols
1011
+ :param dict [params]: extra parameters specific to the exchange API endpoint
1012
+ :returns Order[]: an array of `funding rate structures <https://docs.ccxt.com/#/?id=funding-rate-structure>`
1013
+ """
1014
+ await self.load_markets()
1015
+ symbols = self.market_symbols(symbols)
1016
+ response = await self.publicGetV3FundingEstimates(params)
1017
+ #
1018
+ # {
1019
+ # "success": True,
1020
+ # "data": [
1021
+ # {
1022
+ # "marketCode": "OX-USD-SWAP-LIN",
1023
+ # "fundingAt": "1715515200000",
1024
+ # "estFundingRate": "0.000200000"
1025
+ # },
1026
+ # {
1027
+ # "marketCode": "BTC-USD-SWAP-LIN",
1028
+ # "fundingAt": "1715515200000",
1029
+ # "estFundingRate": "0.000003"
1030
+ # },
1031
+ # ...
1032
+ # ]
1033
+ # }
1034
+ #
1035
+ data = self.safe_list(response, 'data', [])
1036
+ return self.parse_funding_rates(data, symbols)
1037
+
1038
+ def parse_funding_rate(self, fundingRate, market: Market = None) -> FundingRate:
1039
+ #
1040
+ # {
1041
+ # "marketCode": "OX-USD-SWAP-LIN",
1042
+ # "fundingAt": "1715515200000",
1043
+ # "estFundingRate": "0.000200000"
1044
+ # }
1045
+ #
1046
+ symbol = self.safe_string(fundingRate, 'marketCode')
1047
+ market = self.market(symbol)
1048
+ estFundingRateTimestamp = self.safe_integer(fundingRate, 'fundingAt')
1049
+ return {
1050
+ 'info': fundingRate,
1051
+ 'symbol': market['symbol'],
1052
+ 'markPrice': None,
1053
+ 'indexPrice': None,
1054
+ 'interestRate': self.parse_number('0'),
1055
+ 'estimatedSettlePrice': None,
1056
+ 'timestamp': estFundingRateTimestamp,
1057
+ 'datetime': self.iso8601(estFundingRateTimestamp),
1058
+ 'fundingRate': self.safe_number(fundingRate, 'estFundingRate'),
1059
+ 'fundingTimestamp': None,
1060
+ 'fundingDatetime': None,
1061
+ 'nextFundingRate': None,
1062
+ 'nextFundingTimestamp': None,
1063
+ 'nextFundingDatetime': None,
1064
+ 'previousFundingRate': None,
1065
+ 'previousFundingTimestamp': None,
1066
+ 'previousFundingDatetime': None,
1067
+ 'interval': None,
1068
+ }
1069
+
1070
+ async def fetch_funding_rate_history(self, symbol: Str = None, since: Int = None, limit: Int = None, params={}):
1071
+ """
1072
+ Fetches the history of funding rates
1073
+
1074
+ https://docs.ox.fun/?json#get-v3-funding-rates
1075
+
1076
+ :param str symbol: unified symbol of the market to fetch trades for
1077
+ :param int [since]: timestamp in ms of the earliest trade to fetch(default 24 hours ago)
1078
+ :param int [limit]: the maximum amount of trades to fetch(default 200, max 500)
1079
+ :param dict [params]: extra parameters specific to the exchange API endpoint
1080
+ :param int [params.until]: timestamp in ms of the latest trade to fetch(default now)
1081
+ :returns Trade[]: a list of `trade structures <https://docs.ccxt.com/#/?id=public-trades>`
1082
+ """
1083
+ await self.load_markets()
1084
+ market = self.market(symbol)
1085
+ request: dict = {
1086
+ 'marketCode': market['id'],
1087
+ }
1088
+ if since is not None:
1089
+ request['startTime'] = since # startTime and endTime must be within 7 days of each other
1090
+ if limit is not None:
1091
+ request['limit'] = limit
1092
+ until = self.safe_integer(params, 'until')
1093
+ if until is not None:
1094
+ request['endTime'] = until
1095
+ params = self.omit(params, 'until')
1096
+ response = await self.publicGetV3FundingRates(self.extend(request, params))
1097
+ #
1098
+ # {
1099
+ # success: True,
1100
+ # data: [
1101
+ # {
1102
+ # marketCode: 'NEAR-USD-SWAP-LIN',
1103
+ # fundingRate: '-0.000010000',
1104
+ # createdAt: '1715428870755'
1105
+ # },
1106
+ # {
1107
+ # marketCode: 'ENA-USD-SWAP-LIN',
1108
+ # fundingRate: '0.000150000',
1109
+ # createdAt: '1715428868616'
1110
+ # },
1111
+ # ...
1112
+ # }
1113
+ #
1114
+ data = self.safe_list(response, 'data', [])
1115
+ return self.parse_funding_rate_histories(data, market, since, limit)
1116
+
1117
+ def parse_funding_rate_history(self, info, market: Market = None):
1118
+ #
1119
+ # {
1120
+ # success: True,
1121
+ # data: [
1122
+ # {
1123
+ # marketCode: 'NEAR-USD-SWAP-LIN',
1124
+ # fundingRate: '-0.000010000',
1125
+ # createdAt: '1715428870755'
1126
+ # },
1127
+ # {
1128
+ # marketCode: 'ENA-USD-SWAP-LIN',
1129
+ # fundingRate: '0.000150000',
1130
+ # createdAt: '1715428868616'
1131
+ # },
1132
+ # ...
1133
+ # }
1134
+ #
1135
+ marketId = self.safe_string(info, 'marketCode')
1136
+ market = self.safe_market(marketId, market)
1137
+ symbol = market['symbol']
1138
+ timestamp = self.safe_integer(info, 'createdAt')
1139
+ return {
1140
+ 'info': info,
1141
+ 'symbol': symbol,
1142
+ 'fundingRate': self.safe_number(info, 'fundingRate'),
1143
+ 'timestamp': timestamp,
1144
+ 'datetime': self.iso8601(timestamp),
1145
+ }
1146
+
1147
+ async def fetch_funding_history(self, symbol: Str = None, since: Int = None, limit: Int = None, params={}):
1148
+ """
1149
+ fetches the history of funding payments
1150
+
1151
+ https://docs.ox.fun/?json#get-v3-funding
1152
+
1153
+ :param str symbol: unified symbol of the market to fetch trades for
1154
+ :param int [since]: timestamp in ms of the earliest trade to fetch(default 24 hours ago)
1155
+ :param int [limit]: the maximum amount of trades to fetch(default 200, max 500)
1156
+ :param dict [params]: extra parameters specific to the exchange API endpoint
1157
+ :param int [params.until]: timestamp in ms of the latest trade to fetch(default now)
1158
+ :returns Trade[]: a list of `trade structures <https://docs.ccxt.com/#/?id=public-trades>`
1159
+ """
1160
+ await self.load_markets()
1161
+ market = self.market(symbol)
1162
+ request: dict = {
1163
+ 'marketCode': market['id'],
1164
+ }
1165
+ if since is not None:
1166
+ request['startTime'] = since # startTime and endTime must be within 7 days of each other
1167
+ if limit is not None:
1168
+ request['limit'] = limit
1169
+ until = self.safe_integer(params, 'until')
1170
+ if until is not None:
1171
+ request['endTime'] = until
1172
+ params = self.omit(params, 'until')
1173
+ response = await self.privateGetV3Funding(self.extend(request, params))
1174
+ #
1175
+ # {
1176
+ # success: True,
1177
+ # data: [
1178
+ # {
1179
+ # id: '966709913041305605',
1180
+ # marketCode: 'ETH-USD-SWAP-LIN',
1181
+ # payment: '-0.00430822',
1182
+ # fundingRate: '0.000014',
1183
+ # position: '0.001',
1184
+ # indexPrice: '3077.3',
1185
+ # createdAt: '1715086852890'
1186
+ # },
1187
+ # {
1188
+ # id: '966698111997509637',
1189
+ # marketCode: 'ETH-USD-SWAP-LIN',
1190
+ # payment: '-0.0067419',
1191
+ # fundingRate: '0.000022',
1192
+ # position: '0.001',
1193
+ # indexPrice: '3064.5',
1194
+ # createdAt: '1715083251516'
1195
+ # },
1196
+ # ...
1197
+ # ]
1198
+ # }
1199
+ #
1200
+ result = self.safe_list(response, 'data', [])
1201
+ return self.parse_incomes(result, market, since, limit)
1202
+
1203
+ def parse_income(self, income, market: Market = None):
1204
+ #
1205
+ # {
1206
+ # id: '966709913041305605',
1207
+ # marketCode: 'ETH-USD-SWAP-LIN',
1208
+ # payment: '-0.00430822',
1209
+ # fundingRate: '0.000014',
1210
+ # position: '0.001',
1211
+ # indexPrice: '3077.3',
1212
+ # createdAt: '1715086852890'
1213
+ # },
1214
+ #
1215
+ marketId = self.safe_string(income, 'marketCode')
1216
+ symbol = self.safe_symbol(marketId, market)
1217
+ amount = self.safe_number(income, 'payment')
1218
+ code = self.safe_currency_code('OX')
1219
+ id = self.safe_string(income, 'id')
1220
+ timestamp = self.safe_timestamp(income, 'createdAt')
1221
+ rate = self.safe_number(income, 'fundingRate')
1222
+ return {
1223
+ 'info': income,
1224
+ 'symbol': symbol,
1225
+ 'code': code,
1226
+ 'timestamp': timestamp,
1227
+ 'datetime': self.iso8601(timestamp),
1228
+ 'id': id,
1229
+ 'amount': amount,
1230
+ 'rate': rate,
1231
+ }
1232
+
1233
+ async def fetch_leverage_tiers(self, symbols: Strings = None, params={}) -> LeverageTiers:
1234
+ """
1235
+ retrieve information on the maximum leverage, and maintenance margin for trades of varying trade sizes, if a market has a leverage tier of 0, then the leverage tiers cannot be obtained for self market
1236
+
1237
+ https://docs.ox.fun/?json#get-v3-leverage-tiers
1238
+
1239
+ :param str[] [symbols]: list of unified market symbols
1240
+ :param dict [params]: extra parameters specific to the exchange API endpoint
1241
+ :returns dict: a dictionary of `leverage tiers structures <https://docs.ccxt.com/#/?id=leverage-tiers-structure>`, indexed by market symbols
1242
+ """
1243
+ await self.load_markets()
1244
+ response = await self.publicGetV3LeverageTiers(params)
1245
+ #
1246
+ # {
1247
+ # success: True,
1248
+ # data: [
1249
+ # {
1250
+ # marketCode: 'SOL-USD-SWAP-LIN',
1251
+ # tiers: [
1252
+ # {
1253
+ # tier: '1',
1254
+ # leverage: '10',
1255
+ # positionFloor: '0',
1256
+ # positionCap: '200000000',
1257
+ # initialMargin: '0.1',
1258
+ # maintenanceMargin: '0.05',
1259
+ # maintenanceAmount: '0'
1260
+ # },
1261
+ # {
1262
+ # tier: '2',
1263
+ # leverage: '5',
1264
+ # positionFloor: '200000000',
1265
+ # positionCap: '280000000',
1266
+ # initialMargin: '0.2',
1267
+ # maintenanceMargin: '0.1',
1268
+ # maintenanceAmount: '7000000'
1269
+ # },
1270
+ # {
1271
+ # tier: '3',
1272
+ # leverage: '4',
1273
+ # positionFloor: '280000000',
1274
+ # positionCap: '460000000',
1275
+ # initialMargin: '0.25',
1276
+ # maintenanceMargin: '0.125',
1277
+ # maintenanceAmount: '14000000'
1278
+ # },
1279
+ # ...
1280
+ # ]
1281
+ # },
1282
+ # ...
1283
+ # ]
1284
+ # }
1285
+ #
1286
+ data = self.safe_list(response, 'data', [])
1287
+ return self.parse_leverage_tiers(data, symbols, 'marketCode')
1288
+
1289
+ def parse_market_leverage_tiers(self, info, market: Market = None) -> List[LeverageTier]:
1290
+ #
1291
+ # {
1292
+ # marketCode: 'SOL-USD-SWAP-LIN',
1293
+ # tiers: [
1294
+ # {
1295
+ # tier: '1',
1296
+ # leverage: '10',
1297
+ # positionFloor: '0',
1298
+ # positionCap: '200000000',
1299
+ # initialMargin: '0.1',
1300
+ # maintenanceMargin: '0.05',
1301
+ # maintenanceAmount: '0'
1302
+ # ...
1303
+ # ]
1304
+ # },
1305
+ #
1306
+ marketId = self.safe_string(info, 'marketCode')
1307
+ market = self.safe_market(marketId, market)
1308
+ listOfTiers = self.safe_list(info, 'tiers', [])
1309
+ tiers = []
1310
+ for j in range(0, len(listOfTiers)):
1311
+ tier = listOfTiers[j]
1312
+ tiers.append({
1313
+ 'tier': self.safe_number(tier, 'tier'),
1314
+ 'symbol': self.safe_symbol(marketId, market),
1315
+ 'currency': market['settle'],
1316
+ 'minNotional': self.safe_number(tier, 'positionFloor'),
1317
+ 'maxNotional': self.safe_number(tier, 'positionCap'),
1318
+ 'maintenanceMarginRate': self.safe_number(tier, 'maintenanceMargin'),
1319
+ 'maxLeverage': self.safe_number(tier, 'leverage'),
1320
+ 'info': tier,
1321
+ })
1322
+ return tiers
1323
+
1324
+ async def fetch_trades(self, symbol: str, since: Int = None, limit: Int = None, params={}) -> List[Trade]:
1325
+ """
1326
+ get the list of most recent trades for a particular symbol
1327
+
1328
+ https://docs.ox.fun/?json#get-v3-exchange-trades
1329
+
1330
+ :param str symbol: unified symbol of the market to fetch trades for
1331
+ :param int [since]: timestamp in ms of the earliest trade to fetch(default 24 hours ago)
1332
+ :param int [limit]: the maximum amount of trades to fetch(default 200, max 500)
1333
+ :param dict [params]: extra parameters specific to the exchange API endpoint
1334
+ :param int [params.until]: timestamp in ms of the latest trade to fetch(default now)
1335
+ :returns Trade[]: a list of `trade structures <https://docs.ccxt.com/#/?id=public-trades>`
1336
+ """
1337
+ await self.load_markets()
1338
+ market = self.market(symbol)
1339
+ request: dict = {
1340
+ 'marketCode': market['id'],
1341
+ }
1342
+ if since is not None:
1343
+ request['startTime'] = since # startTime and endTime must be within 7 days of each other
1344
+ if limit is not None:
1345
+ request['limit'] = limit
1346
+ until = self.safe_integer(params, 'until')
1347
+ if until is not None:
1348
+ request['endTime'] = until
1349
+ params = self.omit(params, 'until')
1350
+ elif since is not None:
1351
+ request['endTime'] = self.sum(since, 7 * 24 * 60 * 60 * 1000) # for the exchange not to raise an exception if since is younger than 7 days
1352
+ response = await self.publicGetV3ExchangeTrades(self.extend(request, params))
1353
+ #
1354
+ # {
1355
+ # "success": True,
1356
+ # "data": [
1357
+ # {
1358
+ # "marketCode": "BTC-USD-SWAP-LIN",
1359
+ # "matchPrice": "63900",
1360
+ # "matchQuantity": "1",
1361
+ # "side": "SELL",
1362
+ # "matchType": "TAKER",
1363
+ # "matchedAt": "1714934112352"
1364
+ # },
1365
+ # ...
1366
+ # ]
1367
+ # }
1368
+ #
1369
+ data = self.safe_list(response, 'data', [])
1370
+ return self.parse_trades(data, market, since, limit)
1371
+
1372
+ async def fetch_my_trades(self, symbol: Str = None, since: Int = None, limit: Int = None, params={}):
1373
+ """
1374
+ fetch all trades made by the user
1375
+
1376
+ https://docs.ox.fun/?json#get-v3-trades
1377
+
1378
+ :param str symbol: unified market symbol
1379
+ :param int [since]: the earliest time in ms to fetch trades for
1380
+ :param int [limit]: the maximum amount of trades to fetch(default 200, max 500)
1381
+ :param dict [params]: extra parameters specific to the exchange API endpoint
1382
+ :param int [params.until]: timestamp in ms of the latest trade to fetch(default now)
1383
+ :returns Trade[]: a list of `trade structures <https://github.com/ccxt/ccxt/wiki/Manual#trade-structure>`
1384
+ """
1385
+ await self.load_markets()
1386
+ request: dict = {}
1387
+ market: Market = None
1388
+ if symbol is not None:
1389
+ market = self.market(symbol)
1390
+ request['marketCode'] = market['id']
1391
+ if since is not None: # startTime and endTime must be within 7 days of each other
1392
+ request['startTime'] = since
1393
+ if limit is not None:
1394
+ request['limit'] = limit
1395
+ until = self.safe_integer(params, 'until')
1396
+ if until is not None:
1397
+ request['endTime'] = until
1398
+ params = self.omit(params, 'until')
1399
+ elif since is not None:
1400
+ request['endTime'] = self.sum(since, 7 * 24 * 60 * 60 * 1000) # for the exchange not to raise an exception if since is younger than 7 days
1401
+ response = await self.privateGetV3Trades(self.extend(request, params))
1402
+ #
1403
+ # {
1404
+ # "success": True,
1405
+ # "data": [
1406
+ # {
1407
+ # "orderId": "1000104903698",
1408
+ # "clientOrderId": "1715000260094",
1409
+ # "matchId": "400017129522773178",
1410
+ # "marketCode": "ETH-USD-SWAP-LIN",
1411
+ # "side": "BUY",
1412
+ # "matchedQuantity": "0.001",
1413
+ # "matchPrice": "3100.2",
1414
+ # "total": "310.02",
1415
+ # "orderMatchType": "MAKER",
1416
+ # "feeAsset": "OX",
1417
+ # "fee": "0.062004",
1418
+ # "source": "0",
1419
+ # "matchedAt": "1715000267420"
1420
+ # }
1421
+ # ]
1422
+ # }
1423
+ #
1424
+ result = self.safe_list(response, 'data', [])
1425
+ return self.parse_trades(result, market, since, limit)
1426
+
1427
+ def parse_trade(self, trade, market: Market = None) -> Trade:
1428
+ #
1429
+ # public fetchTrades
1430
+ #
1431
+ # {
1432
+ # "marketCode": "BTC-USD-SWAP-LIN",
1433
+ # "matchPrice": "63900",
1434
+ # "matchQuantity": "1",
1435
+ # "side": "SELL",
1436
+ # "matchType": "TAKER",
1437
+ # "matchedAt": "1714934112352"
1438
+ # }
1439
+ #
1440
+ #
1441
+ # private fetchMyTrades
1442
+ #
1443
+ # {
1444
+ # "orderId": "1000104903698",
1445
+ # "clientOrderId": "1715000260094",
1446
+ # "matchId": "400017129522773178",
1447
+ # "marketCode": "ETH-USD-SWAP-LIN",
1448
+ # "side": "BUY",
1449
+ # "matchedQuantity": "0.001",
1450
+ # "matchPrice": "3100.2",
1451
+ # "total": "310.02",
1452
+ # "orderMatchType": "MAKER",
1453
+ # "feeAsset": "OX",
1454
+ # "fee": "0.062004",
1455
+ # "source": "0",
1456
+ # "matchedAt": "1715000267420"
1457
+ # }
1458
+ #
1459
+ marketId = self.safe_string(trade, 'marketCode')
1460
+ market = self.safe_market(marketId, market)
1461
+ symbol = market['symbol']
1462
+ timestamp = self.safe_integer(trade, 'matchedAt')
1463
+ fee = {
1464
+ 'cost': self.safe_string(trade, 'fee'),
1465
+ 'currency': self.safe_currency_code(self.safe_string(trade, 'feeAsset')),
1466
+ }
1467
+ return self.safe_trade({
1468
+ 'id': self.safe_string(trade, 'matchId'),
1469
+ 'timestamp': timestamp,
1470
+ 'datetime': self.iso8601(timestamp),
1471
+ 'symbol': symbol,
1472
+ 'type': None,
1473
+ 'order': self.safe_string(trade, 'orderId'),
1474
+ 'side': self.safe_string_lower(trade, 'side'),
1475
+ 'takerOrMaker': self.safe_string_lower_2(trade, 'matchType', 'orderMatchType'),
1476
+ 'price': self.safe_string(trade, 'matchPrice'),
1477
+ 'amount': self.safe_string_2(trade, 'matchQuantity', 'matchedQuantity'),
1478
+ 'cost': None, # the exchange returns total cost in OX
1479
+ 'fee': fee,
1480
+ 'info': trade,
1481
+ }, market)
1482
+
1483
+ async def fetch_balance(self, params={}) -> Balances:
1484
+ """
1485
+ query for balance and get the amount of funds available for trading or funds locked in orders
1486
+
1487
+ https://docs.ox.fun/?json#get-v3-balances
1488
+
1489
+ :param dict [params]: extra parameters specific to the exchange API endpoint
1490
+ :param str [params.asset]: currency id, if empty the exchange returns info about all currencies
1491
+ :param str [params.subAcc]: Name of sub account. If no subAcc is given, then the response contains only the account linked to the API-Key.
1492
+ :returns dict: a `balance structure <https://docs.ccxt.com/#/?id=balance-structure>`
1493
+ """
1494
+ await self.load_markets()
1495
+ response = await self.privateGetV3Balances(params)
1496
+ #
1497
+ # {
1498
+ # "success": True,
1499
+ # "data": [
1500
+ # {
1501
+ # "accountId": "106490",
1502
+ # "name": "main",
1503
+ # "balances": [
1504
+ # {
1505
+ # "asset": "OX",
1506
+ # "total": "-7.55145065000",
1507
+ # "available": "-71.16445065000",
1508
+ # "reserved": "0",
1509
+ # "lastUpdatedAt": "1715000448946"
1510
+ # },
1511
+ # {
1512
+ # "asset": "ETH",
1513
+ # "total": "0.01",
1514
+ # "available": "0.01",
1515
+ # "reserved": "0",
1516
+ # "lastUpdatedAt": "1714914512750"
1517
+ # },
1518
+ # ...
1519
+ # ]
1520
+ # },
1521
+ # ...
1522
+ # ]
1523
+ # }
1524
+ #
1525
+ data = self.safe_list(response, 'data', [])
1526
+ balance = data[0]
1527
+ subAcc = self.safe_string(params, 'subAcc')
1528
+ if subAcc is not None:
1529
+ for i in range(0, len(data)):
1530
+ b = data[i]
1531
+ name = self.safe_string(b, 'name')
1532
+ if name == subAcc:
1533
+ balance = b
1534
+ break
1535
+ return self.parse_balance(balance)
1536
+
1537
+ def parse_balance(self, balance) -> Balances:
1538
+ #
1539
+ # {
1540
+ # "accountId": "106490",
1541
+ # "name": "main",
1542
+ # "balances": [
1543
+ # {
1544
+ # "asset": "OX",
1545
+ # "total": "-7.55145065000",
1546
+ # "available": "-71.16445065000",
1547
+ # "reserved": "0",
1548
+ # "lastUpdatedAt": "1715000448946"
1549
+ # },
1550
+ # {
1551
+ # "asset": "ETH",
1552
+ # "total": "0.01",
1553
+ # "available": "0.01",
1554
+ # "reserved": "0",
1555
+ # "lastUpdatedAt": "1714914512750"
1556
+ # },
1557
+ # ...
1558
+ # ]
1559
+ # }
1560
+ #
1561
+ result: dict = {
1562
+ 'info': balance,
1563
+ }
1564
+ balances = self.safe_list(balance, 'balances', [])
1565
+ for i in range(0, len(balances)):
1566
+ balanceEntry = balances[i]
1567
+ currencyId = self.safe_string(balanceEntry, 'asset')
1568
+ code = self.safe_currency_code(currencyId)
1569
+ account = self.account()
1570
+ account['total'] = self.safe_string(balanceEntry, 'total')
1571
+ account['free'] = self.safe_string(balanceEntry, 'available')
1572
+ account['used'] = self.safe_string(balanceEntry, 'reserved')
1573
+ result[code] = account
1574
+ return self.safe_balance(result)
1575
+
1576
+ async def fetch_accounts(self, params={}) -> List[Account]:
1577
+ """
1578
+ fetch subaccounts associated with a profile
1579
+
1580
+ https://docs.ox.fun/?json#get-v3-account-names
1581
+
1582
+ :param dict [params]: extra parameters specific to the exchange API endpoint
1583
+ :returns dict: a dictionary of `account structures <https://docs.ccxt.com/#/?id=account-structure>` indexed by the account type
1584
+ """
1585
+ await self.load_markets()
1586
+ # self endpoint can only be called using API keys paired with the parent account! Returns all active subaccounts.
1587
+ response = await self.privateGetV3AccountNames(params)
1588
+ #
1589
+ # {
1590
+ # "success": True,
1591
+ # "data": [
1592
+ # {
1593
+ # "accountId": "106526",
1594
+ # "name": "testSubAccount"
1595
+ # },
1596
+ # ...
1597
+ # ]
1598
+ # }
1599
+ #
1600
+ data = self.safe_list(response, 'data', [])
1601
+ return self.parse_accounts(data, params)
1602
+
1603
+ def parse_account(self, account):
1604
+ #
1605
+ # {
1606
+ # "accountId": "106526",
1607
+ # "name": "testSubAccount"
1608
+ # },
1609
+ #
1610
+ return {
1611
+ 'id': self.safe_string(account, 'accountId'),
1612
+ 'type': None,
1613
+ 'code': None,
1614
+ 'info': account,
1615
+ }
1616
+
1617
+ async def transfer(self, code: str, amount: float, fromAccount: str, toAccount: str, params={}) -> TransferEntry:
1618
+ """
1619
+ transfer currency internally between wallets on the same account
1620
+
1621
+ https://docs.ox.fun/?json#post-v3-transfer
1622
+
1623
+ :param str code: unified currency code
1624
+ :param float amount: amount to transfer
1625
+ :param str fromAccount: account id to transfer from
1626
+ :param str toAccount: account id to transfer to
1627
+ :param dict [params]: extra parameters specific to the exchange API endpoint
1628
+ :returns dict: a `transfer structure <https://docs.ccxt.com/#/?id=transfer-structure>`
1629
+ """
1630
+ # transferring funds between sub-accounts is restricted to API keys linked to the parent account.
1631
+ await self.load_markets()
1632
+ currency = self.currency(code)
1633
+ request: dict = {
1634
+ 'asset': currency['id'],
1635
+ 'quantity': self.currency_to_precision(code, amount),
1636
+ 'fromAccount': fromAccount,
1637
+ 'toAccount': toAccount,
1638
+ }
1639
+ response = await self.privatePostV3Transfer(self.extend(request, params))
1640
+ #
1641
+ # {
1642
+ # timestamp: 1715430036267,
1643
+ # datetime: '2024-05-11T12:20:36.267Z',
1644
+ # currency: 'OX',
1645
+ # amount: 10,
1646
+ # fromAccount: '106464',
1647
+ # toAccount: '106570',
1648
+ # info: {
1649
+ # asset: 'OX',
1650
+ # quantity: '10',
1651
+ # fromAccount: '106464',
1652
+ # toAccount: '106570',
1653
+ # transferredAt: '1715430036267'
1654
+ # }
1655
+ # }
1656
+ #
1657
+ data = self.safe_dict(response, 'data', {})
1658
+ return self.parse_transfer(data, currency)
1659
+
1660
+ async def fetch_transfers(self, code: Str = None, since: Int = None, limit: Int = None, params={}):
1661
+ """
1662
+ fetch a history of internal transfers made on an account
1663
+
1664
+ https://docs.ox.fun/?json#get-v3-transfer
1665
+
1666
+ :param str code: unified currency code of the currency transferred
1667
+ :param int [since]: the earliest time in ms to fetch transfers for(default 24 hours ago)
1668
+ :param int [limit]: the maximum number of transfer structures to retrieve(default 50, max 200)
1669
+ :param dict [params]: extra parameters specific to the exchange API endpoint
1670
+ :param int [params.until]: the latest time in ms to fetch transfers for(default time now)
1671
+ :returns dict[]: a list of `transfer structures <https://docs.ccxt.com/#/?id=transfer-structure>`
1672
+ """
1673
+ # API keys linked to the parent account can get all account transfers, while API keys linked to a sub-account can only see transfers where the sub-account is either the "fromAccount" or "toAccount"
1674
+ await self.load_markets()
1675
+ request: dict = {}
1676
+ currency: Currency = None
1677
+ if code is not None:
1678
+ currency = self.currency(code)
1679
+ request['asset'] = currency['id']
1680
+ if since is not None:
1681
+ request['startTime'] = since # startTime and endTime must be within 7 days of each other
1682
+ if limit is not None:
1683
+ request['limit'] = limit
1684
+ until = self.safe_integer(params, 'until')
1685
+ if until is not None:
1686
+ request['endTime'] = until
1687
+ params = self.omit(params, 'until')
1688
+ elif since is not None:
1689
+ request['endTime'] = self.sum(since, 7 * 24 * 60 * 60 * 1000) # for the exchange not to raise an exception if since is younger than 7 days
1690
+ response = await self.privateGetV3Transfer(self.extend(request, params))
1691
+ #
1692
+ # {
1693
+ # "success": True,
1694
+ # "data": [
1695
+ # {
1696
+ # "asset": "USDT",
1697
+ # "quantity": "5",
1698
+ # "fromAccount": "106490",
1699
+ # "toAccount": "106526",
1700
+ # "id": "966706320886267905",
1701
+ # "status": "COMPLETED",
1702
+ # "transferredAt": "1715085756708"
1703
+ # },
1704
+ # ...
1705
+ # ]
1706
+ # }
1707
+ #
1708
+ data = self.safe_list(response, 'data', [])
1709
+ return self.parse_transfers(data, currency, since, limit)
1710
+
1711
+ def parse_transfer(self, transfer, currency: Currency = None):
1712
+ #
1713
+ # fetchTransfers
1714
+ #
1715
+ # {
1716
+ # "asset": "USDT",
1717
+ # "quantity": "5",
1718
+ # "fromAccount": "106490",
1719
+ # "toAccount": "106526",
1720
+ # "id": "966706320886267905",
1721
+ # "status": "COMPLETED",
1722
+ # "transferredAt": "1715085756708"
1723
+ # }
1724
+ #
1725
+ timestamp = self.safe_integer(transfer, 'transferredAt')
1726
+ currencyId = self.safe_string(transfer, 'asset')
1727
+ return {
1728
+ 'id': self.safe_string(transfer, 'id'),
1729
+ 'timestamp': timestamp,
1730
+ 'datetime': self.iso8601(timestamp),
1731
+ 'currency': self.safe_currency_code(currencyId, currency),
1732
+ 'amount': self.safe_number(transfer, 'quantity'),
1733
+ 'fromAccount': self.safe_string(transfer, 'fromAccount'),
1734
+ 'toAccount': self.safe_string(transfer, 'toAccount'),
1735
+ 'status': self.parse_transfer_status(self.safe_string(transfer, 'status')),
1736
+ 'info': transfer,
1737
+ }
1738
+
1739
+ def parse_transfer_status(self, status):
1740
+ statuses: dict = {
1741
+ 'COMPLETED': 'ok',
1742
+ }
1743
+ return self.safe_string(statuses, status, status)
1744
+
1745
+ async def fetch_deposit_address(self, code: str, params={}) -> DepositAddress:
1746
+ """
1747
+ fetch the deposit address for a currency associated with self account
1748
+
1749
+ https://docs.ox.fun/?json#get-v3-deposit-addresses
1750
+
1751
+ :param str code: unified currency code
1752
+ :param dict [params]: extra parameters specific to the exchange API endpoint
1753
+ :param str [params.network]: network for fetch deposit address
1754
+ :returns dict: an `address structure <https://docs.ccxt.com/#/?id=address-structure>`
1755
+ """
1756
+ networkCode = self.safe_string(params, 'network')
1757
+ networkId = self.network_code_to_id(networkCode, code)
1758
+ if networkId is None:
1759
+ raise BadRequest(self.id + ' fetchDepositAddress() require network parameter')
1760
+ await self.load_markets()
1761
+ currency = self.currency(code)
1762
+ request: dict = {
1763
+ 'asset': currency['id'],
1764
+ 'network': networkId,
1765
+ }
1766
+ params = self.omit(params, 'network')
1767
+ response = await self.privateGetV3DepositAddresses(self.extend(request, params))
1768
+ #
1769
+ # {"success":true,"data":{"address":"0x998dEc76151FB723963Bd8AFD517687b38D33dE8"}}
1770
+ #
1771
+ data = self.safe_dict(response, 'data', {})
1772
+ return self.parse_deposit_address(data, currency)
1773
+
1774
+ def parse_deposit_address(self, depositAddress, currency: Currency = None) -> DepositAddress:
1775
+ #
1776
+ # {"address":"0x998dEc76151FB723963Bd8AFD517687b38D33dE8"}
1777
+ #
1778
+ address = self.safe_string(depositAddress, 'address')
1779
+ self.check_address(address)
1780
+ return {
1781
+ 'info': depositAddress,
1782
+ 'currency': currency['code'],
1783
+ 'network': None,
1784
+ 'address': address,
1785
+ 'tag': None,
1786
+ }
1787
+
1788
+ async def fetch_deposits(self, code: Str = None, since: Int = None, limit: Int = None, params={}) -> List[Transaction]:
1789
+ """
1790
+ fetch all deposits made to an account
1791
+
1792
+ https://docs.ox.fun/?json#get-v3-deposit
1793
+
1794
+ :param str code: unified currency code of the currency transferred
1795
+ :param int [since]: the earliest time in ms to fetch transfers for(default 24 hours ago)
1796
+ :param int [limit]: the maximum number of transfer structures to retrieve(default 50, max 200)
1797
+ :param dict [params]: extra parameters specific to the exchange API endpoint
1798
+ :param int [params.until]: the latest time in ms to fetch transfers for(default time now)
1799
+ :returns dict[]: a list of `transfer structures <https://docs.ccxt.com/#/?id=transfer-structure>`
1800
+ """
1801
+ await self.load_markets()
1802
+ request: dict = {}
1803
+ currency: Currency = None
1804
+ if code is not None:
1805
+ currency = self.currency(code)
1806
+ request['asset'] = currency['id']
1807
+ if since is not None:
1808
+ request['startTime'] = since # startTime and endTime must be within 7 days of each other
1809
+ if limit is not None:
1810
+ request['limit'] = limit
1811
+ until = self.safe_integer(params, 'until')
1812
+ if until is not None:
1813
+ request['endTime'] = until
1814
+ params = self.omit(params, 'until')
1815
+ response = await self.privateGetV3Deposit(self.extend(request, params))
1816
+ #
1817
+ # {
1818
+ # "success": True,
1819
+ # "data": [
1820
+ # {
1821
+ # "asset":"USDC",
1822
+ # "network":"Ethereum",
1823
+ # "address": "0x998dEc76151FB723963Bd8AFD517687b38D33dE8",
1824
+ # "quantity":"50",
1825
+ # "id":"5914",
1826
+ # "status": "COMPLETED",
1827
+ # "txId":"0xf5e79663830a0c6f94d46638dcfbc134566c12facf1832396f81ecb55d3c75dc",
1828
+ # "creditedAt":"1714821645154"
1829
+ # }
1830
+ # ]
1831
+ # }
1832
+ #
1833
+ data = self.safe_list(response, 'data', [])
1834
+ for i in range(0, len(data)):
1835
+ data[i]['type'] = 'deposit'
1836
+ return self.parse_transactions(data, currency, since, limit)
1837
+
1838
+ async def fetch_withdrawals(self, code: Str = None, since: Int = None, limit: Int = None, params={}) -> List[Transaction]:
1839
+ """
1840
+ fetch all withdrawals made from an account
1841
+
1842
+ https://docs.ox.fun/?json#get-v3-withdrawal
1843
+
1844
+ :param str code: unified currency code of the currency transferred
1845
+ :param int [since]: the earliest time in ms to fetch transfers for(default 24 hours ago)
1846
+ :param int [limit]: the maximum number of transfer structures to retrieve(default 50, max 200)
1847
+ :param dict [params]: extra parameters specific to the exchange API endpoint
1848
+ :param int [params.until]: the latest time in ms to fetch transfers for(default time now)
1849
+ :returns dict[]: a list of `transaction structures <https://docs.ccxt.com/#/?id=transaction-structure>`
1850
+ """
1851
+ await self.load_markets()
1852
+ request: dict = {}
1853
+ currency: Currency = None
1854
+ if code is not None:
1855
+ currency = self.currency(code)
1856
+ request['asset'] = currency['id']
1857
+ if since is not None:
1858
+ request['startTime'] = since # startTime and endTime must be within 7 days of each other
1859
+ if limit is not None:
1860
+ request['limit'] = limit
1861
+ until = self.safe_integer(params, 'until')
1862
+ if until is not None:
1863
+ request['endTime'] = until
1864
+ params = self.omit(params, 'until')
1865
+ response = await self.privateGetV3Withdrawal(self.extend(request, params))
1866
+ #
1867
+ # {
1868
+ # success: True,
1869
+ # data: [
1870
+ # {
1871
+ # id: '968163212989431811',
1872
+ # asset: 'OX',
1873
+ # network: 'Arbitrum',
1874
+ # address: '0x90fc1fB49a4ED8f485dd02A2a1Cf576897f6Bfc9',
1875
+ # quantity: '11.7444',
1876
+ # fee: '1.744400000',
1877
+ # status: 'COMPLETED',
1878
+ # txId: '0xe96b2d128b737fdbca927edf355cff42202e65b0fb960e64ffb9bd68c121f69f',
1879
+ # requestedAt: '1715530365450',
1880
+ # completedAt: '1715530527000'
1881
+ # }
1882
+ # ]
1883
+ # }
1884
+ #
1885
+ data = self.safe_list(response, 'data', [])
1886
+ for i in range(0, len(data)):
1887
+ data[i]['type'] = 'withdrawal'
1888
+ return self.parse_transactions(data, currency, since, limit)
1889
+
1890
+ def parse_transactions(self, transactions, currency: Currency = None, since: Int = None, limit: Int = None, params={}) -> List[Transaction]:
1891
+ result = []
1892
+ for i in range(0, len(transactions)):
1893
+ transactions[i] = self.extend(transactions[i], params)
1894
+ transaction = self.parse_transaction(transactions[i], currency)
1895
+ result.append(transaction)
1896
+ result = self.sort_by(result, 'timestamp')
1897
+ code = currency['code'] if (currency is not None) else None
1898
+ return self.filter_by_currency_since_limit(result, code, since, limit)
1899
+
1900
+ def parse_transaction(self, transaction, currency: Currency = None) -> Transaction:
1901
+ #
1902
+ # fetchDeposits
1903
+ # {
1904
+ # "asset":"USDC",
1905
+ # "network":"Ethereum",
1906
+ # "address": "0x998dEc76151FB723963Bd8AFD517687b38D33dE8",
1907
+ # "quantity":"50",
1908
+ # "id":"5914",
1909
+ # "status": "COMPLETED",
1910
+ # "txId":"0xf5e79663830a0c6f94d46638dcfbc134566c12facf1832396f81ecb55d3c75dc",
1911
+ # "creditedAt":"1714821645154"
1912
+ # }
1913
+ #
1914
+ # fetchWithdrawals
1915
+ # {
1916
+ # id: '968163212989431811',
1917
+ # asset: 'OX',
1918
+ # network: 'Arbitrum',
1919
+ # address: '0x90fc1fB49a4ED8f485dd02A2a1Cf576897f6Bfc9',
1920
+ # quantity: '11.7444',
1921
+ # fee: '1.744400000',
1922
+ # status: 'COMPLETED',
1923
+ # txId: '0xe96b2d128b737fdbca927edf355cff42202e65b0fb960e64ffb9bd68c121f69f',
1924
+ # requestedAt: '1715530365450',
1925
+ # completedAt: '1715530527000'
1926
+ # }
1927
+ #
1928
+ # withdraw
1929
+ # {
1930
+ # "id": "968364664449302529",
1931
+ # "asset": "OX",
1932
+ # "network": "Arbitrum",
1933
+ # "address": "0x90fc1fB49a4ED8f485dd02A2a1Cf576897f6Bfc9",
1934
+ # "quantity": "10",
1935
+ # "externalFee": False,
1936
+ # "fee": "1.6728",
1937
+ # "status": "PENDING",
1938
+ # "requestedAt": "1715591843616"
1939
+ # }
1940
+ #
1941
+ id = self.safe_string(transaction, 'id')
1942
+ type = self.safe_string(transaction, 'type')
1943
+ transaction = self.omit(transaction, 'type')
1944
+ address: Str = None
1945
+ addressTo: Str = None
1946
+ status: Str = None
1947
+ if type == 'deposit':
1948
+ address = self.safe_string(transaction, 'address')
1949
+ status = self.parse_deposit_status(self.safe_string(transaction, 'status'))
1950
+ elif type == 'withdrawal':
1951
+ addressTo = self.safe_string(transaction, 'address')
1952
+ status = self.parse_withdrawal_status(self.safe_string(transaction, 'status'))
1953
+ txid = self.safe_string(transaction, 'txId')
1954
+ currencyId = self.safe_string(transaction, 'asset')
1955
+ code = self.safe_currency_code(currencyId, currency)
1956
+ network = self.safe_string(transaction, 'network')
1957
+ networkCode = self.network_id_to_code(network)
1958
+ timestamp = self.safe_integer_2(transaction, 'creditedAt', 'requestedAt')
1959
+ amount = self.safe_number(transaction, 'quantity')
1960
+ feeCost = self.safe_number(transaction, 'fee')
1961
+ fee = None
1962
+ if feeCost is not None:
1963
+ fee = {
1964
+ 'cost': feeCost,
1965
+ 'currency': code,
1966
+ }
1967
+ return {
1968
+ 'info': transaction,
1969
+ 'id': id,
1970
+ 'txid': txid,
1971
+ 'timestamp': timestamp,
1972
+ 'datetime': self.iso8601(timestamp),
1973
+ 'network': networkCode,
1974
+ 'address': address,
1975
+ 'addressTo': addressTo,
1976
+ 'addressFrom': None,
1977
+ 'tag': None,
1978
+ 'tagTo': None,
1979
+ 'tagFrom': None,
1980
+ 'type': type,
1981
+ 'amount': amount,
1982
+ 'currency': code,
1983
+ 'status': status,
1984
+ 'updated': None,
1985
+ 'internal': None,
1986
+ 'comment': None,
1987
+ 'fee': fee,
1988
+ }
1989
+
1990
+ def parse_deposit_status(self, status):
1991
+ statuses: dict = {
1992
+ 'COMPLETED': 'ok',
1993
+ }
1994
+ return self.safe_string(statuses, status, status)
1995
+
1996
+ def parse_withdrawal_status(self, status):
1997
+ statuses: dict = {
1998
+ 'COMPLETED': 'ok',
1999
+ 'PROCESSING': 'pending',
2000
+ 'IN SWEEPING': 'pending',
2001
+ 'PENDING': 'pending',
2002
+ 'ON HOLD': 'pending',
2003
+ 'CANCELED': 'canceled',
2004
+ 'FAILED': 'failed',
2005
+ }
2006
+ return self.safe_string(statuses, status, status)
2007
+
2008
+ async def withdraw(self, code: str, amount: float, address: str, tag=None, params={}) -> Transaction:
2009
+ """
2010
+ make a withdrawal
2011
+
2012
+ https://docs.ox.fun/?json#post-v3-withdrawal
2013
+
2014
+ :param str code: unified currency code
2015
+ :param float amount: the amount to withdraw
2016
+ :param str address: the address to withdraw to
2017
+ :param str tag:
2018
+ :param dict [params]: extra parameters specific to the exchange API endpoint
2019
+ :param str [params.network]: network for withdraw
2020
+ :param bool [params.externalFee]: if False, then the fee is taken from the quantity, also with the burn fee for asset SOLO
2021
+
2022
+ EXCHANGE SPECIFIC PARAMETERS
2023
+ :param str [params.tfaType]: GOOGLE, or AUTHY_SECRET, or YUBIKEY, for 2FA
2024
+ :param str [params.code]: 2FA code
2025
+ :returns dict: a `transaction structure <https://docs.ccxt.com/#/?id=transaction-structure>`
2026
+ """
2027
+ tag, params = self.handle_withdraw_tag_and_params(tag, params)
2028
+ await self.load_markets()
2029
+ currency = self.currency(code)
2030
+ stringAmount = self.currency_to_precision(code, amount)
2031
+ request: dict = {
2032
+ 'asset': currency['id'],
2033
+ 'address': address,
2034
+ 'quantity': stringAmount,
2035
+ }
2036
+ if tag is not None:
2037
+ request['memo'] = tag
2038
+ networkCode: Str = None
2039
+ networkCode, params = self.handle_network_code_and_params(params)
2040
+ if networkCode is not None:
2041
+ request['network'] = self.network_code_to_id(networkCode)
2042
+ request['externalFee'] = False
2043
+ response = await self.privatePostV3Withdrawal(self.extend(request, params))
2044
+ #
2045
+ # {
2046
+ # "success": True,
2047
+ # "data": {
2048
+ # "id": "968364664449302529",
2049
+ # "asset": "OX",
2050
+ # "network": "Arbitrum",
2051
+ # "address": "0x90fc1fB49a4ED8f485dd02A2a1Cf576897f6Bfc9",
2052
+ # "quantity": "10",
2053
+ # "externalFee": False,
2054
+ # "fee": "1.6728",
2055
+ # "status": "PENDING",
2056
+ # "requestedAt": "1715591843616"
2057
+ # }
2058
+ # }
2059
+ #
2060
+ data = self.safe_dict(response, 'data', {})
2061
+ data['type'] = 'withdrawal'
2062
+ return self.parse_transaction(data, currency)
2063
+
2064
+ async def fetch_positions(self, symbols: Strings = None, params={}):
2065
+ """
2066
+ fetch all open positions
2067
+
2068
+ https://docs.ox.fun/?json#get-v3-positions
2069
+
2070
+ :param str[]|None symbols: list of unified market symbols
2071
+ :param dict [params]: extra parameters specific to the exchange API endpoint
2072
+ :param boolean [params.subAcc]:
2073
+ :returns dict[]: a list of `position structure <https://docs.ccxt.com/#/?id=position-structure>`
2074
+ """
2075
+ # Calling self endpoint using an API key pair linked to the parent account with the parameter "subAcc"
2076
+ # allows the caller to include positions of additional sub-accounts in the response.
2077
+ # This feature does not work when using API key pairs linked to a sub-account
2078
+ await self.load_markets()
2079
+ symbols = self.market_symbols(symbols)
2080
+ response = await self.privateGetV3Positions(params)
2081
+ #
2082
+ # {
2083
+ # "success": True,
2084
+ # "data": [
2085
+ # {
2086
+ # "accountId": "106490",
2087
+ # "name": "main",
2088
+ # "positions": [
2089
+ # {
2090
+ # "marketCode": "BTC-USD-SWAP-LIN",
2091
+ # "baseAsset": "BTC",
2092
+ # "counterAsset": "USD",
2093
+ # "position": "0.00010",
2094
+ # "entryPrice": "64300.0",
2095
+ # "markPrice": "63278",
2096
+ # "positionPnl": "-10.1900",
2097
+ # "estLiquidationPrice": "0",
2098
+ # "lastUpdatedAt": "1714915841448"
2099
+ # },
2100
+ # ...
2101
+ # ]
2102
+ # },
2103
+ # {
2104
+ # "accountId": "106526",
2105
+ # "name": "testSubAccount",
2106
+ # "positions": [
2107
+ # {
2108
+ # "marketCode": "ETH-USD-SWAP-LIN",
2109
+ # "baseAsset": "ETH",
2110
+ # "counterAsset": "USD",
2111
+ # "position": "0.001",
2112
+ # "entryPrice": "3080.5",
2113
+ # "markPrice": "3062.0",
2114
+ # "positionPnl": "-1.8500",
2115
+ # "estLiquidationPrice": "0",
2116
+ # "lastUpdatedAt": "1715089678013"
2117
+ # },
2118
+ # ...
2119
+ # ]
2120
+ # }
2121
+ # ]
2122
+ # }
2123
+ #
2124
+ data = self.safe_list(response, 'data', [])
2125
+ allPositions = []
2126
+ for i in range(0, len(data)):
2127
+ account = data[i]
2128
+ positions = self.safe_list(account, 'positions', [])
2129
+ allPositions = self.array_concat(allPositions, positions)
2130
+ return self.parse_positions(allPositions, symbols)
2131
+
2132
+ def parse_position(self, position, market: Market = None):
2133
+ #
2134
+ # {
2135
+ # "marketCode": "ETH-USD-SWAP-LIN",
2136
+ # "baseAsset": "ETH",
2137
+ # "counterAsset": "USD",
2138
+ # "position": "0.001",
2139
+ # "entryPrice": "3080.5",
2140
+ # "markPrice": "3062.0",
2141
+ # "positionPnl": "-1.8500",
2142
+ # "estLiquidationPrice": "0",
2143
+ # "lastUpdatedAt": "1715089678013"
2144
+ # }
2145
+ #
2146
+ marketId = self.safe_string(position, 'marketCode')
2147
+ market = self.safe_market(marketId, market)
2148
+ return self.safe_position({
2149
+ 'info': position,
2150
+ 'id': None,
2151
+ 'symbol': market['symbol'],
2152
+ 'notional': None,
2153
+ 'marginMode': 'cross',
2154
+ 'liquidationPrice': self.safe_number(position, 'estLiquidationPrice'),
2155
+ 'entryPrice': self.safe_number(position, 'entryPrice'),
2156
+ 'unrealizedPnl': self.safe_number(position, 'positionPnl'),
2157
+ 'realizedPnl': None,
2158
+ 'percentage': None,
2159
+ 'contracts': self.safe_number(position, 'position'),
2160
+ 'contractSize': None,
2161
+ 'markPrice': self.safe_number(position, 'markPrice'),
2162
+ 'lastPrice': None,
2163
+ 'side': None,
2164
+ 'hedged': None,
2165
+ 'timestamp': None,
2166
+ 'datetime': None,
2167
+ 'lastUpdateTimestamp': self.safe_integer(position, 'lastUpdatedAt'),
2168
+ 'maintenanceMargin': None,
2169
+ 'maintenanceMarginPercentage': None,
2170
+ 'collateral': None,
2171
+ 'initialMargin': None,
2172
+ 'initialMarginPercentage': None,
2173
+ 'leverage': None,
2174
+ 'marginRatio': None,
2175
+ 'stopLossPrice': None,
2176
+ 'takeProfitPrice': None,
2177
+ })
2178
+
2179
+ async def create_order(self, symbol: str, type: OrderType, side: OrderSide, amount: float, price: Num = None, params={}) -> Order:
2180
+ """
2181
+ create a trade order
2182
+
2183
+ https://docs.ox.fun/?json#post-v3-orders-place
2184
+
2185
+ :param str symbol: unified symbol of the market to create an order in
2186
+ :param str type: 'market', 'limit', 'STOP_LIMIT' or 'STOP_MARKET'
2187
+ :param str side: 'buy' or 'sell'
2188
+ :param float amount: how much of currency you want to trade in units of base currency
2189
+ :param float [price]: the price at which the order is to be fulfilled, in units of the quote currency, ignored in market orders
2190
+ :param dict [params]: extra parameters specific to the exchange API endpoint
2191
+ :param int [params.clientOrderId]: a unique id for the order
2192
+ :param int [params.timestamp]: in milliseconds. If an order reaches the matching engine and the current timestamp exceeds timestamp + recvWindow, then the order will be rejected.
2193
+ :param int [params.recvWindow]: in milliseconds. If an order reaches the matching engine and the current timestamp exceeds timestamp + recvWindow, then the order will be rejected. If timestamp is provided without recvWindow, then a default recvWindow of 1000ms is used.
2194
+ :param str [params.responseType]: FULL or ACK
2195
+ :param float [params.cost]: the quote quantity that can be used alternative for the amount for market buy orders
2196
+ :param float [params.triggerPrice]: The price at which a trigger order is triggered at
2197
+ :param float [params.limitPrice]: Limit price for the STOP_LIMIT order
2198
+ :param bool [params.postOnly]: if True, the order will only be posted if it will be a maker order
2199
+ :param str [params.timeInForce]: GTC(default), IOC, FOK, PO, MAKER_ONLY or MAKER_ONLY_REPRICE(reprices order to the best maker only price if the specified price were to lead to a taker trade)
2200
+ :param str [params.selfTradePreventionMode]: NONE, EXPIRE_MAKER, EXPIRE_TAKER or EXPIRE_BOTH for more info check here {@link https://docs.ox.fun/?json#self-trade-prevention-modes}
2201
+ :param str [params.displayQuantity]: for an iceberg order, pass both quantity and displayQuantity fields in the order request
2202
+ :returns dict: an `order structure <https://docs.ccxt.com/#/?id=order-structure>`
2203
+ """
2204
+ await self.load_markets()
2205
+ request: dict = {
2206
+ 'responseType': self.safe_string(params, 'responseType', 'FULL'),
2207
+ 'timestamp': self.safe_integer(params, 'timestamp', self.milliseconds()),
2208
+ }
2209
+ params = self.omit(params, ['responseType', 'timestamp'])
2210
+ recvWindow = self.safe_integer(params, 'recvWindow')
2211
+ if recvWindow is not None:
2212
+ request['recvWindow'] = recvWindow
2213
+ params = self.omit(params, 'recvWindow')
2214
+ orderRequest = self.create_order_request(symbol, type, side, amount, price, params)
2215
+ request['orders'] = [orderRequest]
2216
+ response = await self.privatePostV3OrdersPlace(request)
2217
+ #
2218
+ # accepted market order responseType FULL
2219
+ # {
2220
+ # "success": True,
2221
+ # "data": [
2222
+ # {
2223
+ # "notice": "OrderMatched",
2224
+ # "accountId": "106490",
2225
+ # "orderId": "1000109901865",
2226
+ # "submitted": True,
2227
+ # "clientOrderId": "0",
2228
+ # "marketCode": "OX-USDT",
2229
+ # "status": "FILLED",
2230
+ # "side": "SELL",
2231
+ # "isTriggered": False,
2232
+ # "quantity": "150.0",
2233
+ # "amount": "0.0",
2234
+ # "remainQuantity": "0.0",
2235
+ # "matchId": "100017047880451399",
2236
+ # "matchPrice": "0.01465",
2237
+ # "matchQuantity": "150.0",
2238
+ # "feeInstrumentId": "USDT",
2239
+ # "fees": "0.0015382500",
2240
+ # "orderType": "MARKET",
2241
+ # "createdAt": "1715592472236",
2242
+ # "lastMatchedAt": "1715592472200",
2243
+ # "displayQuantity": "150.0"
2244
+ # }
2245
+ # ]
2246
+ # }
2247
+ #
2248
+ # accepted limit order responseType FULL
2249
+ # {
2250
+ # "success": True,
2251
+ # "data": [
2252
+ # {
2253
+ # "notice": "OrderOpened",
2254
+ # "accountId": "106490",
2255
+ # "orderId": "1000111482406",
2256
+ # "submitted": True,
2257
+ # "clientOrderId": "0",
2258
+ # "marketCode": "ETH-USD-SWAP-LIN",
2259
+ # "status": "OPEN",
2260
+ # "side": "SELL",
2261
+ # "price": "4000.0",
2262
+ # "isTriggered": False,
2263
+ # "quantity": "0.01",
2264
+ # "amount": "0.0",
2265
+ # "orderType": "LIMIT",
2266
+ # "timeInForce": "GTC",
2267
+ # "createdAt": "1715763507682",
2268
+ # "displayQuantity": "0.01"
2269
+ # }
2270
+ # ]
2271
+ # }
2272
+ #
2273
+ # accepted order responseType ACK
2274
+ # {
2275
+ # "success": True,
2276
+ # "data": [
2277
+ # {
2278
+ # "accountId": "106490",
2279
+ # "orderId": "1000109892193",
2280
+ # "submitted": True,
2281
+ # "marketCode": "OX-USDT",
2282
+ # "side": "BUY",
2283
+ # "price": "0.01961",
2284
+ # "isTriggered": False,
2285
+ # "quantity": "100",
2286
+ # "orderType": "MARKET",
2287
+ # "timeInForce": "IOC",
2288
+ # "createdAt": "1715591529057",
2289
+ # "selfTradePreventionMode": "NONE"
2290
+ # }
2291
+ # ]
2292
+ # }
2293
+ #
2294
+ # rejected order(balance insufficient)
2295
+ # {
2296
+ # "success": True,
2297
+ # "data": [
2298
+ # {
2299
+ # "code": "710001",
2300
+ # "message": "System failure, exception thrown -> null",
2301
+ # "submitted": False,
2302
+ # "marketCode": "OX-USDT",
2303
+ # "side": "BUY",
2304
+ # "price": "0.01961",
2305
+ # "amount": "100",
2306
+ # "orderType": "MARKET",
2307
+ # "timeInForce": "IOC",
2308
+ # "createdAt": "1715591678835",
2309
+ # "source": 11,
2310
+ # "selfTradePreventionMode": "NONE"
2311
+ # }
2312
+ # ]
2313
+ # }
2314
+ #
2315
+ # rejected order(bad request)
2316
+ # {
2317
+ # "success": True,
2318
+ # "data": [
2319
+ # {
2320
+ # "code": "20044",
2321
+ # "message": "Amount is not supported for self order type",
2322
+ # "submitted": False,
2323
+ # "marketCode": "OX-USDT",
2324
+ # "side": "SELL",
2325
+ # "amount": "200",
2326
+ # "orderType": "MARKET",
2327
+ # "createdAt": "1715592079986",
2328
+ # "source": 11
2329
+ # }
2330
+ # ]
2331
+ # }
2332
+ #
2333
+ data = self.safe_list(response, 'data', [])
2334
+ order = self.safe_dict(data, 0, {})
2335
+ return self.parse_order(order)
2336
+
2337
+ async def create_orders(self, orders: List[OrderRequest], params={}) -> List[Order]:
2338
+ """
2339
+ create a list of trade orders
2340
+
2341
+ https://docs.ox.fun/?json#post-v3-orders-place
2342
+
2343
+ :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
2344
+ :param dict [params]: extra parameters specific to the exchange API endpoint
2345
+ :param int [params.timestamp]: *for all orders* in milliseconds. If orders reach the matching engine and the current timestamp exceeds timestamp + recvWindow, then all orders will be rejected.
2346
+ :param int [params.recvWindow]: *for all orders* in milliseconds. If orders reach the matching engine and the current timestamp exceeds timestamp + recvWindow, then all orders will be rejected. If timestamp is provided without recvWindow, then a default recvWindow of 1000ms is used.
2347
+ :param str [params.responseType]: *for all orders* FULL or ACK
2348
+ :returns dict: an `order structure <https://docs.ccxt.com/#/?id=order-structure>`
2349
+ """
2350
+ await self.load_markets()
2351
+ ordersRequests = []
2352
+ for i in range(0, len(orders)):
2353
+ rawOrder = orders[i]
2354
+ symbol = self.safe_string(rawOrder, 'symbol')
2355
+ type = self.safe_string(rawOrder, 'type')
2356
+ side = self.safe_string(rawOrder, 'side')
2357
+ amount = self.safe_number(rawOrder, 'amount')
2358
+ price = self.safe_number(rawOrder, 'price')
2359
+ orderParams = self.safe_dict(rawOrder, 'params', {})
2360
+ orderRequest = self.create_order_request(symbol, type, side, amount, price, orderParams)
2361
+ ordersRequests.append(orderRequest)
2362
+ request: dict = {
2363
+ 'responseType': 'FULL',
2364
+ 'timestamp': self.milliseconds(),
2365
+ 'orders': ordersRequests,
2366
+ }
2367
+ response = await self.privatePostV3OrdersPlace(self.extend(request, params))
2368
+ data = self.safe_list(response, 'data', [])
2369
+ return self.parse_orders(data)
2370
+
2371
+ def create_order_request(self, symbol: str, type: str, side: str, amount, price=None, params={}):
2372
+ """
2373
+ :param str symbol: unified symbol of the market to create an order in
2374
+ :param str type: 'market', 'limit', 'STOP_LIMIT' or 'STOP_MARKET'
2375
+ :param str side: 'buy' or 'sell'
2376
+ :param float amount: how much of currency you want to trade in units of base currency
2377
+ :param float [price]: the price at which the order is to be fulfilled, in units of the quote currency, ignored in market orders
2378
+ :param dict [params]: extra parameters specific to the exchange API endpoint
2379
+ :param int [params.clientOrderId]: a unique id for the order
2380
+ :param float [params.cost]: the quote quantity that can be used alternative for the amount for market buy orders
2381
+ :param float [params.triggerPrice]: The price at which a trigger order is triggered at
2382
+ :param float [params.limitPrice]: Limit price for the STOP_LIMIT order
2383
+ :param bool [params.postOnly]: if True, the order will only be posted if it will be a maker order
2384
+ :param str [params.timeInForce]: GTC(default), IOC, FOK, PO, MAKER_ONLY or MAKER_ONLY_REPRICE(reprices order to the best maker only price if the specified price were to lead to a taker trade)
2385
+ :param str [params.selfTradePreventionMode]: NONE, EXPIRE_MAKER, EXPIRE_TAKER or EXPIRE_BOTH for more info check here {@link https://docs.ox.fun/?json#self-trade-prevention-modes}
2386
+ :param str [params.displayQuantity]: for an iceberg order, pass both quantity and displayQuantity fields in the order request
2387
+ """
2388
+ market = self.market(symbol)
2389
+ request: dict = {
2390
+ 'marketCode': market['id'],
2391
+ 'side': side.upper(),
2392
+ 'source': 1000,
2393
+ }
2394
+ cost = self.safe_string_2(params, 'cost', 'amount')
2395
+ if cost is not None:
2396
+ request['amount'] = cost # todo costToPrecision
2397
+ params = self.omit(params, ['cost', 'amount'])
2398
+ else:
2399
+ request['quantity'] = amount # todo amountToPrecision
2400
+ triggerPrice = self.safe_string_2(params, 'triggerPrice', 'stopPrice')
2401
+ orderType = type.upper()
2402
+ if triggerPrice is not None:
2403
+ if orderType == 'MARKET':
2404
+ orderType = 'STOP_MARKET'
2405
+ elif orderType == 'LIMIT':
2406
+ orderType = 'STOP_LIMIT'
2407
+ request['stopPrice'] = triggerPrice # todo priceToPrecision
2408
+ params = self.omit(params, ['triggerPrice', 'stopPrice'])
2409
+ request['orderType'] = orderType
2410
+ if orderType == 'STOP_LIMIT':
2411
+ request['limitPrice'] = price # todo priceToPrecision
2412
+ elif price is not None:
2413
+ request['price'] = price # todo priceToPrecision
2414
+ postOnly: Bool = None
2415
+ isMarketOrder = (orderType == 'MARKET') or (orderType == 'STOP_MARKET')
2416
+ postOnly, params = self.handle_post_only(isMarketOrder, False, params)
2417
+ timeInForce = self.safe_string_upper(params, 'timeInForce')
2418
+ if postOnly and (timeInForce != 'MAKER_ONLY_REPRICE'):
2419
+ request['timeInForce'] = 'MAKER_ONLY'
2420
+ return self.extend(request, params)
2421
+
2422
+ async def create_market_buy_order_with_cost(self, symbol: str, cost: float, params={}):
2423
+ """
2424
+ create a market buy order by providing the symbol and cost
2425
+
2426
+ https://open.big.one/docs/spot_orders.html#create-order
2427
+
2428
+ :param str symbol: unified symbol of the market to create an order in
2429
+ :param float cost: how much you want to trade in units of the quote currency
2430
+ :param dict [params]: extra parameters specific to the exchange API endpoint
2431
+ :returns dict: an `order structure <https://docs.ccxt.com/#/?id=order-structure>`
2432
+ """
2433
+ await self.load_markets()
2434
+ market = self.market(symbol)
2435
+ if not market['spot']:
2436
+ raise NotSupported(self.id + ' createMarketBuyOrderWithCost() supports spot orders only')
2437
+ request: dict = {
2438
+ 'cost': cost,
2439
+ }
2440
+ return await self.create_order(symbol, 'market', 'buy', None, None, self.extend(request, params))
2441
+
2442
+ async def fetch_order(self, id: str, symbol: Str = None, params={}) -> Order:
2443
+ """
2444
+
2445
+ https://docs.ox.fun/?json#get-v3-orders-status
2446
+
2447
+ fetches information on an order made by the user
2448
+ :param str id: a unique id for the order
2449
+ :param str [symbol]: not used by oxfun fetchOrder
2450
+ :param dict [params]: extra parameters specific to the exchange API endpoint
2451
+ :param int [params.clientOrderId]: the client order id of the order
2452
+ :returns dict: An `order structure <https://docs.ccxt.com/#/?id=order-structure>`
2453
+ """
2454
+ await self.load_markets()
2455
+ request: dict = {
2456
+ 'orderId': id,
2457
+ }
2458
+ response = await self.privateGetV3OrdersStatus(self.extend(request, params))
2459
+ #
2460
+ # {
2461
+ # "success": True,
2462
+ # "data": {
2463
+ # "orderId": "1000111762980",
2464
+ # "clientOrderId": "0",
2465
+ # "marketCode": "ETH-USD-SWAP-LIN",
2466
+ # "status": "OPEN",
2467
+ # "side": "BUY",
2468
+ # "price": "2700.0",
2469
+ # "isTriggered": False,
2470
+ # "remainQuantity": "0.01",
2471
+ # "totalQuantity": "0.01",
2472
+ # "amount": "0",
2473
+ # "displayQuantity": "0.01",
2474
+ # "cumulativeMatchedQuantity": "0",
2475
+ # "orderType": "STOP_LIMIT",
2476
+ # "timeInForce": "GTC",
2477
+ # "source": "11",
2478
+ # "createdAt": "1715794191277"
2479
+ # }
2480
+ # }
2481
+ #
2482
+ data = self.safe_dict(response, 'data', {})
2483
+ return self.parse_order(data)
2484
+
2485
+ async def fetch_open_orders(self, symbol: Str = None, since: Int = None, limit: Int = None, params={}) -> List[Order]:
2486
+ """
2487
+ fetch all unfilled currently open orders
2488
+
2489
+ https://docs.ox.fun/?json#get-v3-orders-working
2490
+
2491
+ :param str symbol: unified market symbol
2492
+ :param int [since]: the earliest time in ms to fetch open orders for
2493
+ :param int [limit]: the maximum number of open orders structures to retrieve
2494
+ :param dict [params]: extra parameters specific to the exchange API endpoint
2495
+ :param int [params.orderId]: a unique id for the order
2496
+ :param int [params.clientOrderId]: the client order id of the order
2497
+ :returns Order[]: a list of `order structures <https://docs.ccxt.com/#/?id=order-structure>`
2498
+ """
2499
+ await self.load_markets()
2500
+ request: dict = {}
2501
+ market: Market = None
2502
+ if symbol is not None:
2503
+ market = self.market(symbol)
2504
+ response = await self.privateGetV3OrdersWorking(self.extend(request, params))
2505
+ data = self.safe_list(response, 'data', [])
2506
+ return self.parse_orders(data, market, since, limit)
2507
+
2508
+ async def cancel_order(self, id: str, symbol: Str = None, params={}):
2509
+ """
2510
+ cancels an open order
2511
+
2512
+ https://docs.ox.fun/?json#delete-v3-orders-cancel
2513
+
2514
+ :param str id: order id
2515
+ :param str symbol: unified symbol of the market the order was made in
2516
+ :param dict [params]: extra parameters specific to the exchange API endpoint
2517
+ :param int [params.clientOrderId]: a unique id for the order
2518
+ :param int [params.timestamp]: in milliseconds
2519
+ :param int [params.recvWindow]: in milliseconds
2520
+ :param str [params.responseType]: 'FULL' or 'ACK'
2521
+ :returns dict: An `order structure <https://docs.ccxt.com/#/?id=order-structure>`
2522
+ """
2523
+ if symbol is None:
2524
+ raise ArgumentsRequired(self.id + ' cancelOrder() requires a symbol argument')
2525
+ market = self.market(symbol)
2526
+ marketId = market['id']
2527
+ request: dict = {
2528
+ 'timestamp': self.milliseconds(),
2529
+ 'responseType': 'FULL',
2530
+ }
2531
+ orderRequest = {
2532
+ 'marketCode': marketId,
2533
+ 'orderId': id,
2534
+ }
2535
+ clientOrderId = self.safe_integer(params, 'clientOrderId')
2536
+ if clientOrderId is not None:
2537
+ orderRequest['clientOrderId'] = clientOrderId
2538
+ request['orders'] = [orderRequest]
2539
+ response = await self.privateDeleteV3OrdersCancel(self.extend(request, params))
2540
+ data = self.safe_list(response, 'data', [])
2541
+ order = self.safe_dict(data, 0, {})
2542
+ return self.parse_order(order)
2543
+
2544
+ async def cancel_all_orders(self, symbol: Str = None, params={}):
2545
+ """
2546
+ cancel all open orders
2547
+
2548
+ https://docs.ox.fun/?json#delete-v3-orders-cancel-all
2549
+
2550
+ :param str symbol: unified market symbol, only orders in the market of self symbol are cancelled when symbol is not None
2551
+ :param dict [params]: extra parameters specific to the exchange API endpoint
2552
+ :returns dict: response from exchange
2553
+ """
2554
+ request: dict = {}
2555
+ if symbol is not None:
2556
+ market = self.market(symbol)
2557
+ request['marketCode'] = market['id']
2558
+ #
2559
+ # {
2560
+ # "success": True,
2561
+ # "data": {"notice": "Orders queued for cancelation"}
2562
+ # }
2563
+ #
2564
+ # {
2565
+ # "success": True,
2566
+ # "data": {"notice": "No working orders found"}
2567
+ # }
2568
+ #
2569
+ return await self.privateDeleteV3OrdersCancelAll(self.extend(request, params))
2570
+
2571
+ async def cancel_orders(self, ids: List[str], symbol: Str = None, params={}):
2572
+ """
2573
+ cancel multiple orders
2574
+
2575
+ https://docs.ox.fun/?json#delete-v3-orders-cancel
2576
+
2577
+ :param str[] ids: order ids
2578
+ :param str [symbol]: unified market symbol
2579
+ :param dict [params]: extra parameters specific to the exchange API endpoint
2580
+ :param int [params.timestamp]: in milliseconds
2581
+ :param int [params.recvWindow]: in milliseconds
2582
+ :param str [params.responseType]: 'FULL' or 'ACK'
2583
+ :returns dict: an list of `order structures <https://docs.ccxt.com/#/?id=order-structure>`
2584
+ """
2585
+ if symbol is None:
2586
+ raise ArgumentsRequired(self.id + ' cancelOrders() requires a symbol argument')
2587
+ await self.load_markets()
2588
+ market = self.market(symbol)
2589
+ marketId = market['id']
2590
+ request: dict = {
2591
+ 'timestamp': self.milliseconds(),
2592
+ 'responseType': 'FULL',
2593
+ }
2594
+ orders = []
2595
+ for i in range(0, len(ids)):
2596
+ order = {
2597
+ 'marketCode': marketId,
2598
+ 'orderId': ids[i],
2599
+ }
2600
+ orders.append(order)
2601
+ request['orders'] = orders
2602
+ response = await self.privateDeleteV3OrdersCancel(self.extend(request, params))
2603
+ data = self.safe_list(response, 'data', [])
2604
+ return self.parse_orders(data, market)
2605
+
2606
+ def parse_order(self, order, market: Market = None) -> Order:
2607
+ #
2608
+ # accepted market order responseType FULL
2609
+ # {
2610
+ # "notice": "OrderMatched",
2611
+ # "accountId": "106490",
2612
+ # "orderId": "1000109901865",
2613
+ # "submitted": True,
2614
+ # "clientOrderId": "0",
2615
+ # "marketCode": "OX-USDT",
2616
+ # "status": "FILLED",
2617
+ # "side": "SELL",
2618
+ # "isTriggered": False,
2619
+ # "quantity": "150.0",
2620
+ # "amount": "0.0",
2621
+ # "remainQuantity": "0.0",
2622
+ # "matchId": "100017047880451399",
2623
+ # "matchPrice": "0.01465",
2624
+ # "matchQuantity": "150.0",
2625
+ # "feeInstrumentId": "USDT",
2626
+ # "fees": "0.0015382500",
2627
+ # "orderType": "MARKET",
2628
+ # "createdAt": "1715592472236",
2629
+ # "lastMatchedAt": "1715592472200",
2630
+ # "displayQuantity": "150.0"
2631
+ # }
2632
+ #
2633
+ # accepted limit order responseType FULL
2634
+ # {
2635
+ # "notice": "OrderOpened",
2636
+ # "accountId": "106490",
2637
+ # "orderId": "1000111482406",
2638
+ # "submitted": True,
2639
+ # "clientOrderId": "0",
2640
+ # "marketCode": "ETH-USD-SWAP-LIN",
2641
+ # "status": "OPEN",
2642
+ # "side": "SELL",
2643
+ # "price": "4000.0",
2644
+ # "isTriggered": False,
2645
+ # "quantity": "0.01",
2646
+ # "amount": "0.0",
2647
+ # "orderType": "LIMIT",
2648
+ # "timeInForce": "GTC",
2649
+ # "createdAt": "1715763507682",
2650
+ # "displayQuantity": "0.01"
2651
+ # }
2652
+ #
2653
+ # accepted order responseType ACK
2654
+ # {
2655
+ # "accountId": "106490",
2656
+ # "orderId": "1000109892193",
2657
+ # "submitted": True,
2658
+ # "marketCode": "OX-USDT",
2659
+ # "side": "BUY",
2660
+ # "price": "0.01961",
2661
+ # "isTriggered": False,
2662
+ # "quantity": "100",
2663
+ # "orderType": "MARKET",
2664
+ # "timeInForce": "IOC",
2665
+ # "createdAt": "1715591529057",
2666
+ # "selfTradePreventionMode": "NONE"
2667
+ # }
2668
+ #
2669
+ # rejected order(balance insufficient)
2670
+ # {
2671
+ # "code": "710001",
2672
+ # "message": "System failure, exception thrown -> null",
2673
+ # "submitted": False,
2674
+ # "marketCode": "OX-USDT",
2675
+ # "side": "BUY",
2676
+ # "price": "0.01961",
2677
+ # "amount": "100",
2678
+ # "orderType": "MARKET",
2679
+ # "timeInForce": "IOC",
2680
+ # "createdAt": "1715591678835",
2681
+ # "source": 11,
2682
+ # "selfTradePreventionMode": "NONE"
2683
+ # }
2684
+ #
2685
+ # rejected order(bad request)
2686
+ # {
2687
+ # "code": "20044",
2688
+ # "message": "Amount is not supported for self order type",
2689
+ # "submitted": False,
2690
+ # "marketCode": "OX-USDT",
2691
+ # "side": "SELL",
2692
+ # "amount": "200",
2693
+ # "orderType": "MARKET",
2694
+ # "createdAt": "1715592079986",
2695
+ # "source": 11
2696
+ # }
2697
+ #
2698
+ # fetchOrder
2699
+ # {
2700
+ # "orderId": "1000111762980",
2701
+ # "clientOrderId": "0",
2702
+ # "marketCode": "ETH-USD-SWAP-LIN",
2703
+ # "status": "OPEN",
2704
+ # "side": "BUY",
2705
+ # "price": "2700.0",
2706
+ # "isTriggered": False,
2707
+ # "remainQuantity": "0.01",
2708
+ # "totalQuantity": "0.01",
2709
+ # "amount": "0",
2710
+ # "displayQuantity": "0.01",
2711
+ # "cumulativeMatchedQuantity": "0",
2712
+ # "orderType": "STOP_LIMIT",
2713
+ # "timeInForce": "GTC",
2714
+ # "source": "11",
2715
+ # "createdAt": "1715794191277"
2716
+ # }
2717
+ #
2718
+ marketId = self.safe_string(order, 'marketCode')
2719
+ market = self.safe_market(marketId, market)
2720
+ timestamp = self.safe_integer(order, 'createdAt')
2721
+ fee = None
2722
+ feeCurrency = self.safe_string(order, 'feeInstrumentId')
2723
+ if feeCurrency is not None:
2724
+ fee = {
2725
+ 'currency': self.safe_currency_code(feeCurrency),
2726
+ 'cost': self.safe_number(order, 'fees'),
2727
+ }
2728
+ status = self.safe_string(order, 'status')
2729
+ code = self.safe_integer(order, 'code') # rejected orders have code of the error
2730
+ if code is not None:
2731
+ status = 'rejected'
2732
+ triggerPrice = self.safe_string(order, 'stopPrice')
2733
+ return self.safe_order({
2734
+ 'id': self.safe_string(order, 'orderId'),
2735
+ 'clientOrderId': self.safe_string(order, 'clientOrderId'),
2736
+ 'timestamp': timestamp,
2737
+ 'datetime': self.iso8601(timestamp),
2738
+ 'lastTradeTimestamp': self.safe_integer(order, 'lastMatchedAt'),
2739
+ 'lastUpdateTimestamp': self.safe_integer(order, 'lastModifiedAt'),
2740
+ 'status': self.parse_order_status(status),
2741
+ 'symbol': market['symbol'],
2742
+ 'type': self.parse_order_type(self.safe_string(order, 'orderType')),
2743
+ 'timeInForce': self.parse_order_time_in_force(self.safe_string(order, 'timeInForce')), # only for limit orders
2744
+ 'side': self.safe_string_lower(order, 'side'),
2745
+ 'price': self.safe_string_n(order, ['price', 'matchPrice', 'limitPrice']),
2746
+ 'average': None,
2747
+ 'amount': self.safe_string_2(order, 'totalQuantity', 'quantity'),
2748
+ 'filled': self.safe_string_2(order, 'cumulativeMatchedQuantity', 'matchQuantity'),
2749
+ 'remaining': self.safe_string(order, 'remainQuantity'),
2750
+ 'triggerPrice': triggerPrice,
2751
+ 'stopLossPrice': triggerPrice,
2752
+ 'cost': self.omit_zero(self.safe_string(order, 'amount')),
2753
+ 'trades': None,
2754
+ 'fee': fee,
2755
+ 'info': order,
2756
+ }, market)
2757
+
2758
+ def parse_order_status(self, status):
2759
+ statuses: dict = {
2760
+ 'OPEN': 'open',
2761
+ 'PARTIALLY_FILLED': 'open',
2762
+ 'PARTIAL_FILL': 'open',
2763
+ 'FILLED': 'closed',
2764
+ 'CANCELED': 'canceled',
2765
+ 'CANCELED_BY_USER': 'canceled',
2766
+ 'CANCELED_BY_MAKER_ONLY': 'rejected',
2767
+ 'CANCELED_BY_FOK': 'rejected',
2768
+ 'CANCELED_ALL_BY_IOC': 'rejected',
2769
+ 'CANCELED_PARTIAL_BY_IOC': 'canceled',
2770
+ 'CANCELED_BY_SELF_TRADE_PROTECTION': 'rejected',
2771
+ }
2772
+ return self.safe_string(statuses, status, status)
2773
+
2774
+ def parse_order_type(self, type):
2775
+ types: dict = {
2776
+ 'LIMIT': 'limit',
2777
+ 'STOP_LIMIT': 'limit',
2778
+ 'MARKET': 'market',
2779
+ 'STOP_MARKET': 'market',
2780
+ }
2781
+ return self.safe_string(types, type, type)
2782
+
2783
+ def parse_order_time_in_force(self, type):
2784
+ types: dict = {
2785
+ 'GTC': 'GTC',
2786
+ 'IOC': 'IOC',
2787
+ 'FOK': 'FOK',
2788
+ 'MAKER_ONLY': 'PO',
2789
+ 'MAKER_ONLY_REPRICE': 'PO',
2790
+ }
2791
+ return self.safe_string(types, type, type)
2792
+
2793
+ def sign(self, path, api='public', method='GET', params={}, headers=None, body=None):
2794
+ baseUrl = self.urls['api'][api]
2795
+ url = baseUrl + '/' + path
2796
+ queryString = ''
2797
+ if method == 'GET':
2798
+ queryString = self.urlencode(params)
2799
+ if len(queryString) != 0:
2800
+ url += '?' + queryString
2801
+ if api == 'private':
2802
+ self.check_required_credentials()
2803
+ timestamp = self.milliseconds()
2804
+ isoDatetime = self.iso8601(timestamp)
2805
+ datetimeParts = isoDatetime.split('.')
2806
+ datetime = datetimeParts[0]
2807
+ nonce = self.nonce()
2808
+ urlParts = baseUrl.split('//')
2809
+ if (method == 'POST') or (method == 'DELETE'):
2810
+ body = self.json(params)
2811
+ queryString = body
2812
+ msgString = datetime + '\n' + str(nonce) + '\n' + method + '\n' + urlParts[1] + '\n/' + path + '\n' + queryString
2813
+ signature = self.hmac(self.encode(msgString), self.encode(self.secret), hashlib.sha256, 'base64')
2814
+ headers = {
2815
+ 'Content-Type': 'application/json',
2816
+ 'AccessKey': self.apiKey,
2817
+ 'Timestamp': datetime,
2818
+ 'Signature': signature,
2819
+ 'Nonce': nonce,
2820
+ }
2821
+ return {'url': url, 'method': method, 'body': body, 'headers': headers}
2822
+
2823
+ def handle_errors(self, code, reason, url, method, headers, body, response, requestHeaders, requestBody):
2824
+ if response is None:
2825
+ return None
2826
+ if code != 200:
2827
+ responseCode = self.safe_string(response, 'code', None)
2828
+ feedback = self.id + ' ' + body
2829
+ self.throw_broadly_matched_exception(self.exceptions['broad'], body, feedback)
2830
+ self.throw_exactly_matched_exception(self.exceptions['exact'], responseCode, feedback)
2831
+ raise ExchangeError(feedback)
2832
+ return None