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