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