PageRenderTime 1368ms CodeModel.GetById 12ms RepoModel.GetById 1ms app.codeStats 1ms

/python/ccxt/okex.py

https://github.com/kroitor/ccxt
Python | 3180 lines | 2264 code | 38 blank | 878 comment | 158 complexity | 5580fc887fc6fa5c3b3cbe63ce95a293 MD5 | raw file
Possible License(s): MIT

Large files files are truncated, but you can click here to view the full file

  1. # -*- coding: utf-8 -*-
  2. # PLEASE DO NOT EDIT THIS FILE, IT IS GENERATED AND WILL BE OVERWRITTEN:
  3. # https://github.com/ccxt/ccxt/blob/master/CONTRIBUTING.md#how-to-contribute-code
  4. from ccxt.base.exchange import Exchange
  5. # -----------------------------------------------------------------------------
  6. try:
  7. basestring # Python 3
  8. except NameError:
  9. basestring = str # Python 2
  10. import hashlib
  11. from ccxt.base.errors import ExchangeError
  12. from ccxt.base.errors import AuthenticationError
  13. from ccxt.base.errors import PermissionDenied
  14. from ccxt.base.errors import AccountSuspended
  15. from ccxt.base.errors import ArgumentsRequired
  16. from ccxt.base.errors import BadRequest
  17. from ccxt.base.errors import BadSymbol
  18. from ccxt.base.errors import InsufficientFunds
  19. from ccxt.base.errors import InvalidAddress
  20. from ccxt.base.errors import InvalidOrder
  21. from ccxt.base.errors import OrderNotFound
  22. from ccxt.base.errors import CancelPending
  23. from ccxt.base.errors import NotSupported
  24. from ccxt.base.errors import DDoSProtection
  25. from ccxt.base.errors import ExchangeNotAvailable
  26. from ccxt.base.errors import OnMaintenance
  27. from ccxt.base.errors import InvalidNonce
  28. from ccxt.base.errors import RequestTimeout
  29. from ccxt.base.decimal_to_precision import TRUNCATE
  30. from ccxt.base.decimal_to_precision import TICK_SIZE
  31. class okex(Exchange):
  32. def describe(self):
  33. return self.deep_extend(super(okex, self).describe(), {
  34. 'id': 'okex',
  35. 'name': 'OKEX',
  36. 'countries': ['CN', 'US'],
  37. 'version': 'v3',
  38. 'rateLimit': 1000, # up to 3000 requests per 5 minutes 600 requests per minute 10 requests per second 100 ms
  39. 'pro': True,
  40. 'has': {
  41. 'cancelOrder': True,
  42. 'CORS': False,
  43. 'createOrder': True,
  44. 'fetchBalance': True,
  45. 'fetchClosedOrders': True,
  46. 'fetchCurrencies': False, # see below
  47. 'fetchDepositAddress': True,
  48. 'fetchDeposits': True,
  49. 'fetchLedger': True,
  50. 'fetchMarkets': True,
  51. 'fetchMyTrades': True,
  52. 'fetchOHLCV': True,
  53. 'fetchOpenOrders': True,
  54. 'fetchOrder': True,
  55. 'fetchOrderBook': True,
  56. 'fetchOrders': False,
  57. 'fetchOrderTrades': True,
  58. 'fetchTime': True,
  59. 'fetchTicker': True,
  60. 'fetchTickers': True,
  61. 'fetchTrades': True,
  62. 'fetchTransactions': False,
  63. 'fetchWithdrawals': True,
  64. 'futures': True,
  65. 'withdraw': True,
  66. },
  67. 'timeframes': {
  68. '1m': '60',
  69. '3m': '180',
  70. '5m': '300',
  71. '15m': '900',
  72. '30m': '1800',
  73. '1h': '3600',
  74. '2h': '7200',
  75. '4h': '14400',
  76. '6h': '21600',
  77. '12h': '43200',
  78. '1d': '86400',
  79. '1w': '604800',
  80. '1M': '2678400',
  81. '3M': '8035200',
  82. '6M': '16070400',
  83. '1y': '31536000',
  84. },
  85. 'hostname': 'okex.com',
  86. 'urls': {
  87. 'logo': 'https://user-images.githubusercontent.com/1294454/32552768-0d6dd3c6-c4a6-11e7-90f8-c043b64756a7.jpg',
  88. 'api': {
  89. 'rest': 'https://www.{hostname}',
  90. },
  91. 'www': 'https://www.okex.com',
  92. 'doc': 'https://www.okex.com/docs/en/',
  93. 'fees': 'https://www.okex.com/pages/products/fees.html',
  94. 'referral': 'https://www.okex.com/join/1888677',
  95. 'test': {
  96. 'rest': 'https://testnet.okex.com',
  97. },
  98. },
  99. 'api': {
  100. 'general': {
  101. 'get': [
  102. 'time',
  103. ],
  104. },
  105. 'account': {
  106. 'get': [
  107. 'wallet',
  108. 'sub-account',
  109. 'asset-valuation',
  110. 'wallet/{currency}',
  111. 'withdrawal/history',
  112. 'withdrawal/history/{currency}',
  113. 'ledger',
  114. 'deposit/address',
  115. 'deposit/history',
  116. 'deposit/history/{currency}',
  117. 'currencies',
  118. 'withdrawal/fee',
  119. ],
  120. 'post': [
  121. 'transfer',
  122. 'withdrawal',
  123. ],
  124. },
  125. 'spot': {
  126. 'get': [
  127. 'accounts',
  128. 'accounts/{currency}',
  129. 'accounts/{currency}/ledger',
  130. 'orders',
  131. 'orders_pending',
  132. 'orders/{order_id}',
  133. 'orders/{client_oid}',
  134. 'trade_fee',
  135. 'fills',
  136. 'algo',
  137. # public
  138. 'instruments',
  139. 'instruments/{instrument_id}/book',
  140. 'instruments/ticker',
  141. 'instruments/{instrument_id}/ticker',
  142. 'instruments/{instrument_id}/trades',
  143. 'instruments/{instrument_id}/candles',
  144. 'instruments/{instrument_id}/history/candles',
  145. ],
  146. 'post': [
  147. 'order_algo',
  148. 'orders',
  149. 'batch_orders',
  150. 'cancel_orders/{order_id}',
  151. 'cancel_orders/{client_oid}',
  152. 'cancel_batch_algos',
  153. 'cancel_batch_orders',
  154. ],
  155. },
  156. 'margin': {
  157. 'get': [
  158. 'accounts',
  159. 'accounts/{instrument_id}',
  160. 'accounts/{instrument_id}/ledger',
  161. 'accounts/availability',
  162. 'accounts/{instrument_id}/availability',
  163. 'accounts/borrowed',
  164. 'accounts/{instrument_id}/borrowed',
  165. 'orders',
  166. 'accounts/{instrument_id}/leverage',
  167. 'orders/{order_id}',
  168. 'orders/{client_oid}',
  169. 'orders_pending',
  170. 'fills',
  171. # public
  172. 'instruments/{instrument_id}/mark_price',
  173. ],
  174. 'post': [
  175. 'accounts/borrow',
  176. 'accounts/repayment',
  177. 'orders',
  178. 'batch_orders',
  179. 'cancel_orders',
  180. 'cancel_orders/{order_id}',
  181. 'cancel_orders/{client_oid}',
  182. 'cancel_batch_orders',
  183. 'accounts/{instrument_id}/leverage',
  184. ],
  185. },
  186. 'futures': {
  187. 'get': [
  188. 'position',
  189. '{instrument_id}/position',
  190. 'accounts',
  191. 'accounts/{underlying}',
  192. 'accounts/{underlying}/leverage',
  193. 'accounts/{underlying}/ledger',
  194. 'order_algo/{instrument_id}',
  195. 'orders/{instrument_id}',
  196. 'orders/{instrument_id}/{order_id}',
  197. 'orders/{instrument_id}/{client_oid}',
  198. 'fills',
  199. 'trade_fee',
  200. 'accounts/{instrument_id}/holds',
  201. 'order_algo/{instrument_id}',
  202. # public
  203. 'instruments',
  204. 'instruments/{instrument_id}/book',
  205. 'instruments/ticker',
  206. 'instruments/{instrument_id}/ticker',
  207. 'instruments/{instrument_id}/trades',
  208. 'instruments/{instrument_id}/candles',
  209. 'instruments/{instrument_id}/history/candles',
  210. 'instruments/{instrument_id}/index',
  211. 'rate',
  212. 'instruments/{instrument_id}/estimated_price',
  213. 'instruments/{instrument_id}/open_interest',
  214. 'instruments/{instrument_id}/price_limit',
  215. 'instruments/{instrument_id}/mark_price',
  216. 'instruments/{instrument_id}/liquidation',
  217. ],
  218. 'post': [
  219. 'accounts/{underlying}/leverage',
  220. 'order',
  221. 'orders',
  222. 'cancel_order/{instrument_id}/{order_id}',
  223. 'cancel_order/{instrument_id}/{client_oid}',
  224. 'cancel_batch_orders/{instrument_id}',
  225. 'accounts/margin_mode',
  226. 'close_position',
  227. 'cancel_all',
  228. 'order_algo',
  229. 'cancel_algos',
  230. ],
  231. },
  232. 'swap': {
  233. 'get': [
  234. 'position',
  235. '{instrument_id}/position',
  236. 'accounts',
  237. '{instrument_id}/accounts',
  238. 'accounts/{instrument_id}/settings',
  239. 'accounts/{instrument_id}/ledger',
  240. 'orders/{instrument_id}',
  241. 'orders/{instrument_id}/{order_id}',
  242. 'orders/{instrument_id}/{client_oid}',
  243. 'fills',
  244. 'accounts/{instrument_id}/holds',
  245. 'trade_fee',
  246. 'order_algo/{instrument_id}',
  247. # public
  248. 'instruments',
  249. 'instruments/{instrument_id}/depth',
  250. 'instruments/ticker',
  251. 'instruments/{instrument_id}/ticker',
  252. 'instruments/{instrument_id}/trades',
  253. 'instruments/{instrument_id}/candles',
  254. 'instruments/{instrument_id}/history/candles',
  255. 'instruments/{instrument_id}/index',
  256. 'rate',
  257. 'instruments/{instrument_id}/open_interest',
  258. 'instruments/{instrument_id}/price_limit',
  259. 'instruments/{instrument_id}/liquidation',
  260. 'instruments/{instrument_id}/funding_time',
  261. 'instruments/{instrument_id}/mark_price',
  262. 'instruments/{instrument_id}/historical_funding_rate',
  263. ],
  264. 'post': [
  265. 'accounts/{instrument_id}/leverage',
  266. 'order',
  267. 'orders',
  268. 'cancel_order/{instrument_id}/{order_id}',
  269. 'cancel_order/{instrument_id}/{client_oid}',
  270. 'cancel_batch_orders/{instrument_id}',
  271. 'order_algo',
  272. 'cancel_algos',
  273. ],
  274. },
  275. 'option': {
  276. 'get': [
  277. 'accounts',
  278. '{underlying}/position',
  279. 'accounts/{underlying}',
  280. 'orders/{underlying}',
  281. 'fills/{underlying}',
  282. 'accounts/{underlying}/ledger',
  283. 'trade_fee',
  284. 'orders/{underlying}/{order_id}',
  285. 'orders/{underlying}/{client_oid}',
  286. # public
  287. 'underlying',
  288. 'instruments/{underlying}',
  289. 'instruments/{underlying}/summary',
  290. 'instruments/{underlying}/summary/{instrument_id}',
  291. 'instruments/{instrument_id}/book',
  292. 'instruments/{instrument_id}/trades',
  293. 'instruments/{instrument_id}/ticker',
  294. 'instruments/{instrument_id}/candles',
  295. ],
  296. 'post': [
  297. 'order',
  298. 'orders',
  299. 'cancel_order/{underlying}/{order_id}',
  300. 'cancel_order/{underlying}/{client_oid}',
  301. 'cancel_batch_orders/{underlying}',
  302. 'amend_order/{underlying}',
  303. 'amend_batch_orders/{underlying}',
  304. ],
  305. },
  306. 'index': {
  307. 'get': [
  308. '{instrument_id}/constituents',
  309. ],
  310. },
  311. },
  312. 'fees': {
  313. 'trading': {
  314. 'taker': 0.0015,
  315. 'maker': 0.0010,
  316. },
  317. 'spot': {
  318. 'taker': 0.0015,
  319. 'maker': 0.0010,
  320. },
  321. 'futures': {
  322. 'taker': 0.0005,
  323. 'maker': 0.0002,
  324. },
  325. 'swap': {
  326. 'taker': 0.00075,
  327. 'maker': 0.00020,
  328. },
  329. },
  330. 'requiredCredentials': {
  331. 'apiKey': True,
  332. 'secret': True,
  333. 'password': True,
  334. },
  335. 'exceptions': {
  336. # http error codes
  337. # 400 Bad Request Invalid request format
  338. # 401 Unauthorized Invalid API Key
  339. # 403 Forbidden You do not have access to the requested resource
  340. # 404 Not Found
  341. # 429 Client Error: Too Many Requests for url
  342. # 500 Internal Server Error We had a problem with our server
  343. 'exact': {
  344. '1': ExchangeError, # {"code": 1, "message": "System error"}
  345. # undocumented
  346. 'failure to get a peer from the ring-balancer': ExchangeNotAvailable, # {"message": "failure to get a peer from the ring-balancer"}
  347. 'Server is busy, please try again': ExchangeNotAvailable, # {"message": "Server is busy, please try again."}
  348. 'An unexpected error occurred': ExchangeError, # {"message": "An unexpected error occurred"}
  349. 'System error': ExchangeError, # {"error_message":"System error","message":"System error"}
  350. '4010': PermissionDenied, # {"code": 4010, "message": "For the security of your funds, withdrawals are not permitted within 24 hours after changing fund password / mobile number / Google Authenticator settings "}
  351. # common
  352. # '0': ExchangeError, # 200 successful,when the order placement / cancellation / operation is successful
  353. '4001': ExchangeError, # no data received in 30s
  354. '4002': ExchangeError, # Buffer full. cannot write data
  355. # --------------------------------------------------------
  356. '30001': AuthenticationError, # {"code": 30001, "message": 'request header "OK_ACCESS_KEY" cannot be blank'}
  357. '30002': AuthenticationError, # {"code": 30002, "message": 'request header "OK_ACCESS_SIGN" cannot be blank'}
  358. '30003': AuthenticationError, # {"code": 30003, "message": 'request header "OK_ACCESS_TIMESTAMP" cannot be blank'}
  359. '30004': AuthenticationError, # {"code": 30004, "message": 'request header "OK_ACCESS_PASSPHRASE" cannot be blank'}
  360. '30005': InvalidNonce, # {"code": 30005, "message": "invalid OK_ACCESS_TIMESTAMP"}
  361. '30006': AuthenticationError, # {"code": 30006, "message": "invalid OK_ACCESS_KEY"}
  362. '30007': BadRequest, # {"code": 30007, "message": 'invalid Content_Type, please use "application/json" format'}
  363. '30008': RequestTimeout, # {"code": 30008, "message": "timestamp request expired"}
  364. '30009': ExchangeError, # {"code": 30009, "message": "system error"}
  365. '30010': AuthenticationError, # {"code": 30010, "message": "API validation failed"}
  366. '30011': PermissionDenied, # {"code": 30011, "message": "invalid IP"}
  367. '30012': AuthenticationError, # {"code": 30012, "message": "invalid authorization"}
  368. '30013': AuthenticationError, # {"code": 30013, "message": "invalid sign"}
  369. '30014': DDoSProtection, # {"code": 30014, "message": "request too frequent"}
  370. '30015': AuthenticationError, # {"code": 30015, "message": 'request header "OK_ACCESS_PASSPHRASE" incorrect'}
  371. '30016': ExchangeError, # {"code": 30015, "message": "you are using v1 apiKey, please use v1 endpoint. If you would like to use v3 endpoint, please subscribe to v3 apiKey"}
  372. '30017': ExchangeError, # {"code": 30017, "message": "apikey's broker id does not match"}
  373. '30018': ExchangeError, # {"code": 30018, "message": "apikey's domain does not match"}
  374. '30019': ExchangeNotAvailable, # {"code": 30019, "message": "Api is offline or unavailable"}
  375. '30020': BadRequest, # {"code": 30020, "message": "body cannot be blank"}
  376. '30021': BadRequest, # {"code": 30021, "message": "Json data format error"}, {"code": 30021, "message": "json data format error"}
  377. '30022': PermissionDenied, # {"code": 30022, "message": "Api has been frozen"}
  378. '30023': BadRequest, # {"code": 30023, "message": "{0} parameter cannot be blank"}
  379. '30024': BadSymbol, # {"code":30024,"message":"\"instrument_id\" is an invalid parameter"}
  380. '30025': BadRequest, # {"code": 30025, "message": "{0} parameter category error"}
  381. '30026': DDoSProtection, # {"code": 30026, "message": "requested too frequent"}
  382. '30027': AuthenticationError, # {"code": 30027, "message": "login failure"}
  383. '30028': PermissionDenied, # {"code": 30028, "message": "unauthorized execution"}
  384. '30029': AccountSuspended, # {"code": 30029, "message": "account suspended"}
  385. '30030': ExchangeNotAvailable, # {"code": 30030, "message": "endpoint request failed. Please try again"}
  386. '30031': BadRequest, # {"code": 30031, "message": "token does not exist"}
  387. '30032': BadSymbol, # {"code": 30032, "message": "pair does not exist"}
  388. '30033': BadRequest, # {"code": 30033, "message": "exchange domain does not exist"}
  389. '30034': ExchangeError, # {"code": 30034, "message": "exchange ID does not exist"}
  390. '30035': ExchangeError, # {"code": 30035, "message": "trading is not supported in self website"}
  391. '30036': ExchangeError, # {"code": 30036, "message": "no relevant data"}
  392. '30037': ExchangeNotAvailable, # {"code": 30037, "message": "endpoint is offline or unavailable"}
  393. # '30038': AuthenticationError, # {"code": 30038, "message": "user does not exist"}
  394. '30038': OnMaintenance, # {"client_oid":"","code":"30038","error_code":"30038","error_message":"Matching engine is being upgraded. Please try in about 1 minute.","message":"Matching engine is being upgraded. Please try in about 1 minute.","order_id":"-1","result":false}
  395. '30044': RequestTimeout, # {"code":30044, "message":"Endpoint request timeout"}
  396. # futures
  397. '32001': AccountSuspended, # {"code": 32001, "message": "futures account suspended"}
  398. '32002': PermissionDenied, # {"code": 32002, "message": "futures account does not exist"}
  399. '32003': CancelPending, # {"code": 32003, "message": "canceling, please wait"}
  400. '32004': ExchangeError, # {"code": 32004, "message": "you have no unfilled orders"}
  401. '32005': InvalidOrder, # {"code": 32005, "message": "max order quantity"}
  402. '32006': InvalidOrder, # {"code": 32006, "message": "the order price or trigger price exceeds USD 1 million"}
  403. '32007': InvalidOrder, # {"code": 32007, "message": "leverage level must be the same for orders on the same side of the contract"}
  404. '32008': InvalidOrder, # {"code": 32008, "message": "Max. positions to open(cross margin)"}
  405. '32009': InvalidOrder, # {"code": 32009, "message": "Max. positions to open(fixed margin)"}
  406. '32010': ExchangeError, # {"code": 32010, "message": "leverage cannot be changed with open positions"}
  407. '32011': ExchangeError, # {"code": 32011, "message": "futures status error"}
  408. '32012': ExchangeError, # {"code": 32012, "message": "futures order update error"}
  409. '32013': ExchangeError, # {"code": 32013, "message": "token type is blank"}
  410. '32014': ExchangeError, # {"code": 32014, "message": "your number of contracts closing is larger than the number of contracts available"}
  411. '32015': ExchangeError, # {"code": 32015, "message": "margin ratio is lower than 100% before opening positions"}
  412. '32016': ExchangeError, # {"code": 32016, "message": "margin ratio is lower than 100% after opening position"}
  413. '32017': ExchangeError, # {"code": 32017, "message": "no BBO"}
  414. '32018': ExchangeError, # {"code": 32018, "message": "the order quantity is less than 1, please try again"}
  415. '32019': ExchangeError, # {"code": 32019, "message": "the order price deviates from the price of the previous minute by more than 3%"}
  416. '32020': ExchangeError, # {"code": 32020, "message": "the price is not in the range of the price limit"}
  417. '32021': ExchangeError, # {"code": 32021, "message": "leverage error"}
  418. '32022': ExchangeError, # {"code": 32022, "message": "self function is not supported in your country or region according to the regulations"}
  419. '32023': ExchangeError, # {"code": 32023, "message": "self account has outstanding loan"}
  420. '32024': ExchangeError, # {"code": 32024, "message": "order cannot be placed during delivery"}
  421. '32025': ExchangeError, # {"code": 32025, "message": "order cannot be placed during settlement"}
  422. '32026': ExchangeError, # {"code": 32026, "message": "your account is restricted from opening positions"}
  423. '32027': ExchangeError, # {"code": 32027, "message": "cancelled over 20 orders"}
  424. '32028': ExchangeError, # {"code": 32028, "message": "account is suspended and liquidated"}
  425. '32029': ExchangeError, # {"code": 32029, "message": "order info does not exist"}
  426. '32030': InvalidOrder, # The order cannot be cancelled
  427. '32031': ArgumentsRequired, # client_oid or order_id is required.
  428. '32038': AuthenticationError, # User does not exist
  429. '32040': ExchangeError, # User have open contract orders or position
  430. '32044': ExchangeError, # {"code": 32044, "message": "The margin ratio after submitting self order is lower than the minimum requirement({0}) for your tier."}
  431. '32045': ExchangeError, # String of commission over 1 million
  432. '32046': ExchangeError, # Each user can hold up to 10 trade plans at the same time
  433. '32047': ExchangeError, # system error
  434. '32048': InvalidOrder, # Order strategy track range error
  435. '32049': ExchangeError, # Each user can hold up to 10 track plans at the same time
  436. '32050': InvalidOrder, # Order strategy rang error
  437. '32051': InvalidOrder, # Order strategy ice depth error
  438. '32052': ExchangeError, # String of commission over 100 thousand
  439. '32053': ExchangeError, # Each user can hold up to 6 ice plans at the same time
  440. '32057': ExchangeError, # The order price is zero. Market-close-all function cannot be executed
  441. '32054': ExchangeError, # Trade not allow
  442. '32055': InvalidOrder, # cancel order error
  443. '32056': ExchangeError, # iceberg per order average should between {0}-{1} contracts
  444. '32058': ExchangeError, # Each user can hold up to 6 initiative plans at the same time
  445. '32059': InvalidOrder, # Total amount should exceed per order amount
  446. '32060': InvalidOrder, # Order strategy type error
  447. '32061': InvalidOrder, # Order strategy initiative limit error
  448. '32062': InvalidOrder, # Order strategy initiative range error
  449. '32063': InvalidOrder, # Order strategy initiative rate error
  450. '32064': ExchangeError, # Time Stringerval of orders should set between 5-120s
  451. '32065': ExchangeError, # Close amount exceeds the limit of Market-close-all(999 for BTC, and 9999 for the rest tokens)
  452. '32066': ExchangeError, # You have open orders. Please cancel all open orders before changing your leverage level.
  453. '32067': ExchangeError, # Account equity < required margin in self setting. Please adjust your leverage level again.
  454. '32068': ExchangeError, # The margin for self position will fall short of the required margin in self setting. Please adjust your leverage level or increase your margin to proceed.
  455. '32069': ExchangeError, # Target leverage level too low. Your account balance is insufficient to cover the margin required. Please adjust the leverage level again.
  456. '32070': ExchangeError, # Please check open position or unfilled order
  457. '32071': ExchangeError, # Your current liquidation mode does not support self action.
  458. '32072': ExchangeError, # The highest available margin for your orders tier is {0}. Please edit your margin and place a new order.
  459. '32073': ExchangeError, # The action does not apply to the token
  460. '32074': ExchangeError, # The number of contracts of your position, open orders, and the current order has exceeded the maximum order limit of self asset.
  461. '32075': ExchangeError, # Account risk rate breach
  462. '32076': ExchangeError, # Liquidation of the holding position(s) at market price will require cancellation of all pending close orders of the contracts.
  463. '32077': ExchangeError, # Your margin for self asset in futures account is insufficient and the position has been taken over for liquidation.(You will not be able to place orders, close positions, transfer funds, or add margin during self period of time. Your account will be restored after the liquidation is complete.)
  464. '32078': ExchangeError, # Please cancel all open orders before switching the liquidation mode(Please cancel all open orders before switching the liquidation mode)
  465. '32079': ExchangeError, # Your open positions are at high risk.(Please add margin or reduce positions before switching the mode)
  466. '32080': ExchangeError, # Funds cannot be transferred out within 30 minutes after futures settlement
  467. '32083': ExchangeError, # The number of contracts should be a positive multiple of %%. Please place your order again
  468. # token and margin trading
  469. '33001': PermissionDenied, # {"code": 33001, "message": "margin account for self pair is not enabled yet"}
  470. '33002': AccountSuspended, # {"code": 33002, "message": "margin account for self pair is suspended"}
  471. '33003': InsufficientFunds, # {"code": 33003, "message": "no loan balance"}
  472. '33004': ExchangeError, # {"code": 33004, "message": "loan amount cannot be smaller than the minimum limit"}
  473. '33005': ExchangeError, # {"code": 33005, "message": "repayment amount must exceed 0"}
  474. '33006': ExchangeError, # {"code": 33006, "message": "loan order not found"}
  475. '33007': ExchangeError, # {"code": 33007, "message": "status not found"}
  476. '33008': InsufficientFunds, # {"code": 33008, "message": "loan amount cannot exceed the maximum limit"}
  477. '33009': ExchangeError, # {"code": 33009, "message": "user ID is blank"}
  478. '33010': ExchangeError, # {"code": 33010, "message": "you cannot cancel an order during session 2 of call auction"}
  479. '33011': ExchangeError, # {"code": 33011, "message": "no new market data"}
  480. '33012': ExchangeError, # {"code": 33012, "message": "order cancellation failed"}
  481. '33013': InvalidOrder, # {"code": 33013, "message": "order placement failed"}
  482. '33014': OrderNotFound, # {"code": 33014, "message": "order does not exist"}
  483. '33015': InvalidOrder, # {"code": 33015, "message": "exceeded maximum limit"}
  484. '33016': ExchangeError, # {"code": 33016, "message": "margin trading is not open for self token"}
  485. '33017': InsufficientFunds, # {"code": 33017, "message": "insufficient balance"}
  486. '33018': ExchangeError, # {"code": 33018, "message": "self parameter must be smaller than 1"}
  487. '33020': ExchangeError, # {"code": 33020, "message": "request not supported"}
  488. '33021': BadRequest, # {"code": 33021, "message": "token and the pair do not match"}
  489. '33022': InvalidOrder, # {"code": 33022, "message": "pair and the order do not match"}
  490. '33023': ExchangeError, # {"code": 33023, "message": "you can only place market orders during call auction"}
  491. '33024': InvalidOrder, # {"code": 33024, "message": "trading amount too small"}
  492. '33025': InvalidOrder, # {"code": 33025, "message": "base token amount is blank"}
  493. '33026': ExchangeError, # {"code": 33026, "message": "transaction completed"}
  494. '33027': InvalidOrder, # {"code": 33027, "message": "cancelled order or order cancelling"}
  495. '33028': InvalidOrder, # {"code": 33028, "message": "the decimal places of the trading price exceeded the limit"}
  496. '33029': InvalidOrder, # {"code": 33029, "message": "the decimal places of the trading size exceeded the limit"}
  497. '33034': ExchangeError, # {"code": 33034, "message": "You can only place limit order after Call Auction has started"}
  498. '33035': ExchangeError, # This type of order cannot be canceled(This type of order cannot be canceled)
  499. '33036': ExchangeError, # Exceeding the limit of entrust order
  500. '33037': ExchangeError, # The buy order price should be lower than 130% of the trigger price
  501. '33038': ExchangeError, # The sell order price should be higher than 70% of the trigger price
  502. '33039': ExchangeError, # The limit of callback rate is 0 < x <= 5%
  503. '33040': ExchangeError, # The trigger price of a buy order should be lower than the latest transaction price
  504. '33041': ExchangeError, # The trigger price of a sell order should be higher than the latest transaction price
  505. '33042': ExchangeError, # The limit of price variance is 0 < x <= 1%
  506. '33043': ExchangeError, # The total amount must be larger than 0
  507. '33044': ExchangeError, # The average amount should be 1/1000 * total amount <= x <= total amount
  508. '33045': ExchangeError, # The price should not be 0, including trigger price, order price, and price limit
  509. '33046': ExchangeError, # Price variance should be 0 < x <= 1%
  510. '33047': ExchangeError, # Sweep ratio should be 0 < x <= 100%
  511. '33048': ExchangeError, # Per order limit: Total amount/1000 < x <= Total amount
  512. '33049': ExchangeError, # Total amount should be X > 0
  513. '33050': ExchangeError, # Time interval should be 5 <= x <= 120s
  514. '33051': ExchangeError, # cancel order number not higher limit: plan and track entrust no more than 10, ice and time entrust no more than 6
  515. '33059': BadRequest, # {"code": 33059, "message": "client_oid or order_id is required"}
  516. '33060': BadRequest, # {"code": 33060, "message": "Only fill in either parameter client_oid or order_id"}
  517. '33061': ExchangeError, # Value of a single market price order cannot exceed 100,000 USD
  518. '33062': ExchangeError, # The leverage ratio is too high. The borrowed position has exceeded the maximum position of self leverage ratio. Please readjust the leverage ratio
  519. '33063': ExchangeError, # Leverage multiple is too low, there is insufficient margin in the account, please readjust the leverage ratio
  520. '33064': ExchangeError, # The setting of the leverage ratio cannot be less than 2, please readjust the leverage ratio
  521. '33065': ExchangeError, # Leverage ratio exceeds maximum leverage ratio, please readjust leverage ratio
  522. '33085': InvalidOrder, # The value of the position and buying order has reached the position limit, and no further buying is allowed.
  523. # account
  524. '21009': ExchangeError, # Funds cannot be transferred out within 30 minutes after swap settlement(Funds cannot be transferred out within 30 minutes after swap settlement)
  525. '34001': PermissionDenied, # {"code": 34001, "message": "withdrawal suspended"}
  526. '34002': InvalidAddress, # {"code": 34002, "message": "please add a withdrawal address"}
  527. '34003': ExchangeError, # {"code": 34003, "message": "sorry, self token cannot be withdrawn to xx at the moment"}
  528. '34004': ExchangeError, # {"code": 34004, "message": "withdrawal fee is smaller than minimum limit"}
  529. '34005': ExchangeError, # {"code": 34005, "message": "withdrawal fee exceeds the maximum limit"}
  530. '34006': ExchangeError, # {"code": 34006, "message": "withdrawal amount is lower than the minimum limit"}
  531. '34007': ExchangeError, # {"code": 34007, "message": "withdrawal amount exceeds the maximum limit"}
  532. '34008': InsufficientFunds, # {"code": 34008, "message": "insufficient balance"}
  533. '34009': ExchangeError, # {"code": 34009, "message": "your withdrawal amount exceeds the daily limit"}
  534. '34010': ExchangeError, # {"code": 34010, "message": "transfer amount must be larger than 0"}
  535. '34011': ExchangeError, # {"code": 34011, "message": "conditions not met"}
  536. '34012': ExchangeError, # {"code": 34012, "message": "the minimum withdrawal amount for NEO is 1, and the amount must be an integer"}
  537. '34013': ExchangeError, # {"code": 34013, "message": "please transfer"}
  538. '34014': ExchangeError, # {"code": 34014, "message": "transfer limited"}
  539. '34015': ExchangeError, # {"code": 34015, "message": "subaccount does not exist"}
  540. '34016': PermissionDenied, # {"code": 34016, "message": "transfer suspended"}
  541. '34017': AccountSuspended, # {"code": 34017, "message": "account suspended"}
  542. '34018': AuthenticationError, # {"code": 34018, "message": "incorrect trades password"}
  543. '34019': PermissionDenied, # {"code": 34019, "message": "please bind your email before withdrawal"}
  544. '34020': PermissionDenied, # {"code": 34020, "message": "please bind your funds password before withdrawal"}
  545. '34021': InvalidAddress, # {"code": 34021, "message": "Not verified address"}
  546. '34022': ExchangeError, # {"code": 34022, "message": "Withdrawals are not available for sub accounts"}
  547. '34023': PermissionDenied, # {"code": 34023, "message": "Please enable futures trading before transferring your funds"}
  548. '34026': ExchangeError, # transfer too frequently(transfer too frequently)
  549. '34036': ExchangeError, # Parameter is incorrect, please refer to API documentation
  550. '34037': ExchangeError, # Get the sub-account balance interface, account type is not supported
  551. '34038': ExchangeError, # Since your C2C transaction is unusual, you are restricted from fund transfer. Please contact our customer support to cancel the restriction
  552. '34039': ExchangeError, # You are now restricted from transferring out your funds due to abnormal trades on C2C Market. Please transfer your fund on our website or app instead to verify your identity
  553. # swap
  554. '35001': ExchangeError, # {"code": 35001, "message": "Contract does not exist"}
  555. '35002': ExchangeError, # {"code": 35002, "message": "Contract settling"}
  556. '35003': ExchangeError, # {"code": 35003, "message": "Contract paused"}
  557. '35004': ExchangeError, # {"code": 35004, "message": "Contract pending settlement"}
  558. '35005': AuthenticationError, # {"code": 35005, "message": "User does not exist"}
  559. '35008': InvalidOrder, # {"code": 35008, "message": "Risk ratio too high"}
  560. '35010': InvalidOrder, # {"code": 35010, "message": "Position closing too large"}
  561. '35012': InvalidOrder, # {"code": 35012, "message": "Incorrect order size"}
  562. '35014': InvalidOrder, # {"code": 35014, "message": "Order price is not within limit"}
  563. '35015': InvalidOrder, # {"code": 35015, "message": "Invalid leverage level"}
  564. '35017': ExchangeError, # {"code": 35017, "message": "Open orders exist"}
  565. '35019': InvalidOrder, # {"code": 35019, "message": "Order size too large"}
  566. '35020': InvalidOrder, # {"code": 35020, "message": "Order price too high"}
  567. '35021': InvalidOrder, # {"code": 35021, "message": "Order size exceeded current tier limit"}
  568. '35022': BadRequest, # {"code": 35022, "message": "Contract status error"}
  569. '35024': BadRequest, # {"code": 35024, "message": "Contract not initialized"}
  570. '35025': InsufficientFunds, # {"code": 35025, "message": "No account balance"}
  571. '35026': BadRequest, # {"code": 35026, "message": "Contract settings not initialized"}
  572. '35029': OrderNotFound, # {"code": 35029, "message": "Order does not exist"}
  573. '35030': InvalidOrder, # {"code": 35030, "message": "Order size too large"}
  574. '35031': InvalidOrder, # {"code": 35031, "message": "Cancel order size too large"}
  575. '35032': ExchangeError, # {"code": 35032, "message": "Invalid user status"}
  576. '35037': ExchangeError, # No last traded price in cache
  577. '35039': ExchangeError, # {"code": 35039, "message": "Open order quantity exceeds limit"}
  578. '35040': InvalidOrder, # {"error_message":"Invalid order type","result":"true","error_code":"35040","order_id":"-1"}
  579. '35044': ExchangeError, # {"code": 35044, "message": "Invalid order status"}
  580. '35046': InsufficientFunds, # {"code": 35046, "message": "Negative account balance"}
  581. '35047': InsufficientFunds, # {"code": 35047, "message": "Insufficient account balance"}
  582. '35048': ExchangeError, # {"code": 35048, "message": "User contract is frozen and liquidating"}
  583. '35049': InvalidOrder, # {"code": 35049, "message": "Invalid order type"}
  584. '35050': InvalidOrder, # {"code": 35050, "message": "Position settings are blank"}
  585. '35052': InsufficientFunds, # {"code": 35052, "message": "Insufficient cross margin"}
  586. '35053': ExchangeError, # {"code": 35053, "message": "Account risk too high"}
  587. '35055': InsufficientFunds, # {"code": 35055, "message": "Insufficient account balance"}
  588. '35057': ExchangeError, # {"code": 35057, "message": "No last traded price"}
  589. '35058': ExchangeError, # {"code": 35058, "message": "No limit"}
  590. '35059': BadRequest, # {"code": 35059, "message": "client_oid or order_id is required"}
  591. '35060': BadRequest, # {"code": 35060, "message": "Only fill in either parameter client_oid or order_id"}
  592. '35061': BadRequest, # {"code": 35061, "message": "Invalid instrument_id"}
  593. '35062': InvalidOrder, # {"code": 35062, "message": "Invalid match_price"}
  594. '35063': InvalidOrder, # {"code": 35063, "message": "Invalid order_size"}
  595. '35064': InvalidOrder, # {"code": 35064, "message": "Invalid client_oid"}
  596. '35066': InvalidOrder, # Order interval error
  597. '35067': InvalidOrder, # Time-weighted order ratio error
  598. '35068': InvalidOrder, # Time-weighted order range error
  599. '35069': InvalidOrder, # Time-weighted single transaction limit error
  600. '35070': InvalidOrder, # Algo order type error
  601. '35071': InvalidOrder, # Order total must be larger than single order limit
  602. '35072': InvalidOrder, # Maximum 6 unfulfilled time-weighted orders can be held at the same time
  603. '35073': InvalidOrder, # Order price is 0. Market-close-all not available
  604. '35074': InvalidOrder, # Iceberg order single transaction average error
  605. '35075': InvalidOrder, # Failed to cancel order
  606. '35076': InvalidOrder, # LTC 20x leverage. Not allowed to open position
  607. '35077': InvalidOrder, # Maximum 6 unfulfilled iceberg orders can be held at the same time
  608. '35078': InvalidOrder, # Order amount exceeded 100,000
  609. '35079': InvalidOrder, # Iceberg order price variance error
  610. '35080': InvalidOrder, # Callback rate error
  611. '35081': InvalidOrder, # Maximum 10 unfulfilled trail orders can be held at the same time
  612. '35082': InvalidOrder, # Trail order callback rate error
  613. '35083': InvalidOrder, # Each user can only hold a maximum of 10 unfulfilled stop-limit orders at the same time
  614. '35084': InvalidOrder, # Order amount exceeded 1 million
  615. '35085': InvalidOrder, # Order amount is not in the correct range
  616. '35086': InvalidOrder, # Price exceeds 100 thousand
  617. '35087': InvalidOrder, # Price exceeds 100 thousand
  618. '35088': InvalidOrder, # Average amount error
  619. '35089': InvalidOrder, # Price exceeds 100 thousand
  620. '35090': ExchangeError, # No stop-limit orders available for cancelation
  621. '35091': ExchangeError, # No trail orders available for cancellation
  622. '35092': ExchangeError, # No iceberg orders available for cancellation
  623. '35093': ExchangeError, # No trail orders available for cancellation
  624. '35094': ExchangeError, # Stop-limit order last traded price error
  625. '35095': BadRequest, # Instrument_id error
  626. '35096': ExchangeError, # Algo order status error
  627. '35097': ExchangeError, # Order status and order ID cannot exist at the same time
  628. '35098': ExchangeError, # An order status or order ID must exist
  629. '35099': ExchangeError, # Algo order ID error
  630. # option
  631. '36001': BadRequest, # Invalid underlying index.
  632. '36002': BadRequest, # Instrument does not exist.
  633. '36005': ExchangeError, # Instrument status is invalid.
  634. '36101': AuthenticationError, # Account does not exist.
  635. '36102': PermissionDenied, # Account status is invalid.
  636. '36103': PermissionDenied, # Account is suspended due to ongoing liquidation.
  637. '36104': PermissionDenied, # Account is not enabled for options trading.
  638. '36105': PermissionDenied, # Please enable the account for option contract.
  639. '36106': PermissionDenied, # Funds cannot be transferred in or out, as account is suspended.
  640. '36107': PermissionDenied, # Funds cannot be transferred out within 30 minutes after option exercising or settlement.
  641. '36108': InsufficientFunds, # Funds cannot be transferred in or out, as equity of the account is less than zero.
  642. '36109': PermissionDenied, # Funds cannot be transferred in or out during option exercising or settlement.
  643. '36201': PermissionDenied, # New order function is blocked.
  644. '36202': PermissionDenied, # Account does not have permission to short option.
  645. '36203': InvalidOrder, # Invalid format for client_oid.
  646. '36204': ExchangeError, # Invalid format for request_id.
  647. '36205': BadRequest, # Instrument id does not match underlying index.
  648. '36206': BadRequest, # Order_id and client_oid can not be used at the same time.
  649. '36207': InvalidOrder, # Either order price or fartouch price must be present.
  650. '36208': InvalidOrder, # Either order price or size must be present.
  651. '36209': InvalidOrder, # Either order_id or client_oid must be present.
  652. '36210': InvalidOrder, # Either order_ids or client_oids must be present.
  653. '36211': InvalidOrder, # Exceeding max batch size for order submission.
  654. '36212': InvalidOrder, # Exceeding max batch size for oder cancellation.
  655. '36213': InvalidOrder, # Exceeding max batch size for order amendment.
  656. '36214': ExchangeError, # Instrument does not have valid bid/ask quote.
  657. '36216': OrderNotFound, # Order does not exist.
  658. '36217': InvalidOrder, # Order submission failed.
  659. '36218': InvalidOrder, # Order cancellation failed.
  660. '36219': InvalidOrder, # Order amendment failed.
  661. '36220': InvalidOrder, # Order is pending cancel.
  662. '36221': InvalidOrder, # Order qty is not valid multiple of lot size.
  663. '36222': InvalidOrder, # Order price is breaching highest buy limit.
  664. '36223': InvalidOrder, # Order price is breaching lowest sell limit.
  665. '36224': InvalidOrder, # Exceeding max order size.
  666. '36225': InvalidOrder, # Exceeding max open order count for instrument.
  667. '36226': InvalidOrder, # Exceeding max open order count for underlying.
  668. '36227': InvalidOrder, # Exceeding max open size across all orders for underlying
  669. '36228': InvalidOrder, # Exceeding max available qty for instrument.
  670. '36229': InvalidOrder, # Exceeding max available qty for underlying.
  671. '36230': InvalidOrder, # Exceeding max position limit for underlying.
  672. },
  673. 'broad': {
  674. },
  675. },
  676. 'precisionMode': TICK_SIZE,
  677. 'options': {
  678. 'fetchOHLCV': {
  679. 'type': 'Candles', # Candles or HistoryCandles
  680. },
  681. 'createMarketBuyOrderRequiresPrice': True,
  682. 'fetchMarkets': ['spot', 'futures', 'swap', 'option'],
  683. 'defaultType': 'spot', # 'account', 'spot', 'margin', 'futures', 'swap', 'option'
  684. 'auth': {
  685. 'time': 'p…

Large files files are truncated, but you can click here to view the full file