
    E#i1                         S SK Jr  S SKJr  S SKJrJrJrJrJ	r	J
r
JrJrJrJrJrJrJrJrJrJrJrJr  S SKJr  S SKJr  S SKJr  S SKJr  S SKJr  S S	KJr  S S
KJr  S SKJ r   S SKJ!r!  S SK"J#r#   " S S\\5      r$g)    )Exchange)ImplicitAPI)AnyBalancesCurrencyDepositAddressIntMarketNumOrder	OrderBook	OrderSide	OrderTypeStrStringsTickerTickers
OrderBooksTradeTradingFees)List)ExchangeError)AuthenticationError)PermissionDenied)ArgumentsRequired)
BadRequest)InsufficientFunds)InvalidOrder)OrderNotFound)	TICK_SIZEc                   d  ^  \ rS rSrS\4U 4S jjr0 4S\\   4S jjrS\	S\4S jr
0 4S\S\4S jjrS	0 4S
\S\4S jjrS=S\4S jjrS	0 4S\S\S\4S jjrS	S	0 4S
\S\S\4S jjrS	S	0 4S\S\S\S\\   4S jjrS=S\	S\S\4S jjr0 4S\4S jjr0 4S\4S jjr0 4S jrS\4S jr0 4S\4S jjr S	0 4S\S\!S\"S\#S\$4
S jjr%S	0 4S\S\&4S jjr'S	S	S	0 4S\&S\S\S\\(   4S  jjr)S	S	S	0 4S\&S\S\S\\(   4S! jjr*S	S	S	0 4S\&S\S\S\\(   4S" jjr+S=S\S\,4S# jjr-S$S	S	0 4S\S%\S\S\S\\,   4
S& jjr.S=S'\	S\S\(4S( jjr/S)\&4S* jr0S	0 4S\S\&4S+ jjr1S	0 4S,\\   S\&4S- jjr2S	0 4S\&4S. jjr30 4S/\S\\4   4S0 jjr5S=S1\6S\44S2 jjr7S3S40 S	S	4S5 jr8S/\9S6\S7\S8\S9\	S:\4S; jr:S<r;U =r<$ )>oceanex   returnc                     > U R                  [        [        U ]  5       SSS/SSSSS0S	S
SS.0 SS _SS_SS_SS _SS _SS _SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_0 S S_S!S"_S#S _S$S_S%S_S&S_S'S_S(S_S)S_S*S_S+S_S,S_S-S_S.S_S/S_S0S_S1S_ESSSSS S2.ES3S4S5S6S7S8S9S:S;S<S=S>S?./ S@QSA/SB./ SCQ/ SDQSB.SE.SFSSU R	                  SG5      U R	                  SG5      SH.0SISJ0[
        SSSSS SSS SSSSSK.SSSSSSSSL.S S SSSSSM.SSNSSSSO.SSNSPSPSSSSQ.SSNSPSRSPSSSSS.STSN0SU.	S S SV.S S SV.SW.[        [        [        [        [        [        [        [        [        [        [        [        SX.[        [        [        [        SY.SZ.S[.5      $ )\Nr"   OceanExBSv1i  zchttps://user-images.githubusercontent.com/1294454/58385970-794e2d80-8001-11e9-889c-0567cd79b78e.jpgrestzhttps://api.oceanex.prozhttps://www.oceanex.pro.comzhttps://api.oceanex.pro/doc/v1z*https://oceanex.pro/signup?referral=VE24QX)logoapiwwwdocreferralCORSspotTmarginFswapfutureoptioncancelAllOrderscancelOrdercancelOrderscreateMarketOrdercreateOrderfetchBalancefetchBorrowRateHistoriesfetchBorrowRateHistoryfetchClosedOrdersfetchCrossBorrowRatefetchCrossBorrowRatesfetchCurrenciesfetchDepositAddressemulatedfetchDepositAddressesfetchDepositAddressesByNetworkfetchFundingRateHistoryfetchFundingRatesfetchIsolatedBorrowRatefetchIsolatedBorrowRatesfetchMarkets
fetchOHLCVfetchOpenOrders
fetchOrderfetchOrderBookfetchOrderBooksfetchOrdersfetchTickerfetchTickers)	fetchTimefetchTradesfetchTradingFeefetchTradingFeesfetchTransactionFees151530601202403607201440432010080)1m5m15m30m1h2h4h6h12h1d3d1w)marketsztickers/{pair}tickers_multi
order_bookorder_book/multizfees/tradingtrades	timestampk)getpost)keyz
members/meorderszorders/filter)
ry   zorders/multizorder/deletezorder/delete/multizorders/clearz/withdraws/special/newz/deposit_addressz/deposit_addressesz/deposit_historyz/withdraw_history)publicprivatetradingz0.001)	tierBased
percentagemakertakerPLAPlair)IOCFOKPOGTD)
marginModetriggerPricetriggerDirectiontriggerPriceTypestopLossPricetakeProfitPriceattachedStopLossTakeProfittimeInForcehedgedtrailingleveragemarketBuyByCostmarketBuyRequiresPriceselfTradePreventioniceberg)r   triggerr   symbolRequiredd   )r   limitr   r   r   i )r   r   daysBack	untilDaysr   r   r      )r   r   r   daysBackCanceledr   r   r   r   r   )	sandboxr9   createOrdersfetchMyTradesrL   rK   rO   r=   rJ   )linearinverse)r0   r2   r3   )z-1z-21001100410061008101010112001200220049003)z"market does not have a valid valuez side does not have a valid valuez(Account::AccountError: Cannot lock fundszThe account does not exist)codesexact)idname	countriesversion	rateLimiturlshas
timeframesr+   feescommonCurrenciesprecisionModefeatures
exceptions)deep_extendsuperr"   describeparse_numberr    r   r   r   r   r   r   r   )self	__class__s    T/home/james-whalen/.local/lib/python3.13/site-packages/ccxt/async_support/oceanex.pyr   oceanex.describe   s   gt = ?}5 57H((( %( 	(
 $( $( "4( t( ( $T( t( ( +E( )%( $T(  '!(" (#($ "5%(& &z'(( ()(* 1$+(, *5-(. $U/(0 *51(2 +E3(4 5(6 d7(8 "49(: d;(< !$=(> "4?(@ tA(B tC(D E(F "##($((,O(T  	  !$L !&"&!..w7!..w7	 w! '  %&+(,,0,0).+06:#(#("'#(	( #($)$)+027/4#()$, %)%)&+#($)*/	# ',!$#($)*/( ',!$$*%+#($)*/$ ',!$$*,-%+#($)*/	*  #u=@ ##
 ##IHV %$&-///,/(), ;E8B@Q2E	AVB
 V V	    c                    #    SS0nU R                  U R                  X!5      5      I Sh  vN nU R                  US/ 5      nU R                  U5      $  N(7f)z
retrieves data on all markets for oceanex

https://api.oceanex.pro/doc/v1/#markets-post

:param dict [params]: extra parameters specific to the exchange API endpoint
:returns dict[]: an array of objects representing market data
show_detailsTNdata)publicGetMarketsextend
safe_valueparse_markets)r   paramsrequestresponsero   s        r   fetch_marketsoceanex.fetch_markets   sX      (...t{{7/KLL //(FB7!!'** Ms   (AA)Amarketc                    U R                  US5      nU R                  US5      nUR                  S5      u  pEU R                  U5      nU R                  U5      nUR                  5       nUR                  5       nUS-   U-   n0 SU_SU_SU_SU_SS _SU_S	U_S
S _SS_SS_SS_SS_SS_SS_SS _SS_SS _S S S S S S U R	                  U R                  U R                  US5      5      5      U R	                  U R                  U R                  US5      5      5      S.S S S.S S S.S S S.U R                  US5      S S.S.S US.
E$ )Nr   r   /symbolbasequotesettlebaseIdquoteIdsettleIdtyper0   Tr1   Fr2   r3   r4   activecontractr   amount_precisionprice_precision)amountprice)minmaxminimum_trading_amount)r   r   r   cost)
r   contractSizeexpiryexpiryDatetimestrike
optionType	precisionlimitscreatedinfo)r   splitsafe_currency_codelowerr   parse_precisionsafe_stringsafe_number)	r   r   r   r   r   r   r   r   r   s	            r   parse_marketoceanex.parse_market  s   __VT*vv.**S/&&v.''0--/e#0
"0
f0
 D0
 U	0

 d0
 f0
 w0
 0
 F0
 D0
 e0
 E0
 e0
 e0
 d0
  !0
" d#0
$  "++D,@,@AQAQRXZlAm,no**4+?+?@P@PQWYj@k+lm  
  
  
  ++F4LM$ _0
 0	
r   r   c                 
  #    U R                  5       I Sh  vN   U R                  U5      nSUS   0nU R                  U R                  XB5      5      I Sh  vN nU R	                  US0 5      nU R                  Xc5      $  Nh N*7f)a  
fetches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market

https://api.oceanex.pro/doc/v1/#ticker-post

:param str symbol: unified symbol of the market to fetch the ticker for
:param dict [params]: extra parameters specific to the exchange API endpoint
:returns dict: a `ticker structure <https://docs.ccxt.com/#/?id=ticker-structure>`
Npairr   r   )load_marketsr   publicGetTickersPairr   	safe_dictparse_ticker)r   r   r   r   r   r   r   s          r   fetch_tickeroceanex.fetch_tickerF  s      !!!V$F4L
 224;;w3OPP$ ~~h3  ..1 	"
 Qs!   BA??BB)BBNsymbolsc                   #    U R                  5       I Sh  vN   U R                  U5      nUc  U R                  nU R                  U5      nSU0nU R	                  U R                  XB5      5      I Sh  vN nU R                  US/ 5      n0 n[        S[        U5      5       HB  nXh   n	U R                  U	S5      n
U R                  U
5      nUS   nU R                  X5      X|'   MD     U R                  USU5      $  N N7f)a  
fetches price tickers for multiple markets, statistical information calculated over the past 24 hours for each market

https://api.oceanex.pro/doc/v1/#multiple-tickers-post

:param str[]|None symbols: unified symbols of the markets to fetch the ticker for, all market tickers are returned if not assigned
:param dict [params]: extra parameters specific to the exchange API endpoint
:returns dict: a dictionary of `ticker structures <https://docs.ccxt.com/#/?id=ticker-structure>`
Nro   r   r   r   r   )r   market_symbolsr   
market_idspublicGetTickersMultir   r   rangelenr   safe_marketr   filter_by_array_tickers)r   r   r   	marketIdsr   r   r   resultitickermarketIdr   r   s                r   fetch_tickersoceanex.fetch_tickersj  s     !!!%%g.?llGOOG,	"I.33DKK4PQQ$ x4q#d)$AWF''9H%%h/FH%F!..v>FN % ++FHgFFA 	" Rs#   C?C;AC?3C=4BC?=C?c                    U R                  US0 5      nU R                  US5      nU R                  S U5      nU R                  0 SU_SU_SU R	                  U5      _SU R                  US5      _SU R                  US5      _SU R                  US	5      _S
S _SU R                  US5      _SS _SS _SS _SU R                  US5      _SU R                  US5      _SS _SS _SS _SS _U R                  US5      S US.EU5      $ )Nr  atr   rt   datetimehighlowbidbuy	bidVolumeasksell	askVolumevwapopencloselastpreviousClosechanger~   averagevolume)
baseVolumequoteVolumer   )r   safe_timestampsafe_symbolsafe_tickeriso8601r   )r   r   r   r  rt   r   s         r   r   oceanex.parse_ticker  s    x4''d3	!!$/ !
f!
!
 Y/!
 D$$VV4	!

 4##FE2!
 4##FE2!
 !
 4##FF3!
 !
 D!
 D!
 T%%ff5!
 D$$VV4!
 T!
 d!
  $!!
" t#!
$ **68<)!
* + 	r   r   c                 >  #    U R                  5       I Sh  vN   U R                  U5      nSUS   0nUb  X%S'   U R                  U R                  XS5      5      I Sh  vN nU R	                  US0 5      nU R                  US5      nU R                  XqU5      $  N N=7f)a  
fetches information on open orders with bid(buy) and ask(sell) prices, volumes and other data

https://api.oceanex.pro/doc/v1/#order-book-post

:param str symbol: unified symbol of the market to fetch the order book for
:param int [limit]: the maximum amount of order book entries to return
:param dict [params]: extra parameters specific to the exchange API endpoint
:returns dict: A dictionary of `order book structures <https://docs.ccxt.com/#/?id=order-book-structure>` indexed by market symbols
Nr   r   r   r   rt   )r   r   publicGetOrderBookr   r   r$  parse_order_book)	r   r   r   r   r   r   r   	orderbookrt   s	            r   fetch_order_bookoceanex.fetch_order_book  s      !!!V$fTl
 $G00W1MNN( OOHfb9	''	;?	$$Y	BB; 	" Os"   BBABB<BBc                   #    U R                  5       I Sh  vN   Uc  U R                  nU R                  U5      nSU0nUb  X%S'   U R                  U R	                  XS5      5      I Sh  vN nU R                  US/ 5      n0 n[        S[        U5      5       HP  n	Xy   n
U R                  U
S5      nU R                  U5      nU R                  U
S5      nU R                  XU5      X'   MR     U$  N N7f)a;  
fetches information on open orders with bid(buy) and ask(sell) prices, volumes and other data for multiple markets

https://api.oceanex.pro/doc/v1/#multiple-order-books-post

:param str[]|None symbols: list of unified market symbols, all symbols fetched if None, default is None
:param int [limit]: max number of entries per orderbook to return, default is None
:param dict [params]: extra parameters specific to the exchange API endpoint
:returns dict: a dictionary of `order book structures <https://docs.ccxt.com/#/?id=order-book-structure>` indexed by market symbol
Nro   r   r   r   r   rt   )r   r   r  publicGetOrderBookMultir   r   r  r  r   r%  r$  r+  )r   r   r   r   r  r   r   r   r	  r
  r,  r  r   rt   s                 r   fetch_order_booksoceanex.fetch_order_books  s      !!!?llGOOG,	y
 $G55dkk'6RSS0 x4q#d)$AI''	8<H%%h/F++I{CI!229iPFN % S 	" Ts#   C2C.AC2)C0*BC20C2sincec                 .  #    U R                  5       I Sh  vN   U R                  U5      nSUS   0nUb  [        US5      US'   U R                  U R	                  Xd5      5      I Sh  vN nU R                  US5      nU R                  XX#5      $  Nz N*7f)a  
get the list of most recent trades for a particular symbol

https://api.oceanex.pro/doc/v1/#trades-post

:param str symbol: unified symbol of the market to fetch trades for
:param int [since]: timestamp in ms of the earliest trade to fetch
:param int [limit]: the maximum amount of trades to fetch
:param dict [params]: extra parameters specific to the exchange API endpoint
:returns Trade[]: a list of `trade structures <https://docs.ccxt.com/#/?id=public-trades>`
Nr   r   i  r   r   )r   r   r   publicGetTradesr   	safe_listparse_trades)	r   r   r3  r   r   r   r   r   r   s	            r   fetch_tradesoceanex.fetch_trades  s      !!!V$fTl
 "5$/GG--dkk'.JKK& ~~h/  u<<7 	" Ls"   BBAB(B))BBtradec                    U R                  US5      nUS:X  a  SnOUS:X  a  SnU R                  US5      nU R                  XB5      nU R                  US5      nUc!  U R                  U R	                  US5      5      nU R	                  US	5      nU R	                  US
5      nU R                  UUU R                  U5      UU R	                  US5      S SS UUUS S S.U5      $ )Nsider  r  r  r  r   
created_on
created_atr   r!  r   r   )r   rt   r  r   r   orderr   takerOrMakerr<  r   r   r   fee)r   r%  r$  	parse8601r   
safe_trader'  )	r   r:  r   r<  r  r   rt   priceStringamountStrings	            r   parse_tradeoceanex.parse_tradeG  s     uf-5=DU]D??5(3!!(3''|<	t'7'7|'LMI&&ug6''x8"Y/""5$/  " 
  	r   c                 d   #    U R                  U5      I Sh  vN nU R                  US5      $  N7f)a)  
fetches the current integer timestamp in milliseconds from the exchange server

https://api.oceanex.pro/doc/v1/#api-server-time-post

:param dict [params]: extra parameters specific to the exchange API endpoint
:returns int: the current integer timestamp in milliseconds from the exchange server
Nr   )publicGetTimestampr$  r   r   r   s      r   
fetch_timeoceanex.fetch_timer  s4      0088 ""8V44	 9   0.0c                   #    U R                  U5      I Sh  vN nU R                  US/ 5      n0 n[        S[        U5      5       Hz  nX5   nU R                  US0 5      nU R                  US0 5      nU R	                  US5      n	U R                  U	5      n
UU
U R                  US5      U R                  US5      SS	.XJ'   M|     U$  N7f)
a$  
fetch the trading fees for multiple markets

https://api.oceanex.pro/doc/v1/#trading-fees-post

:param dict [params]: extra parameters specific to the exchange API endpoint
:returns dict: a dictionary of `fee structures <https://docs.ccxt.com/#/?id=fee-structure>` indexed by market symbols
Nr   r   ask_feebid_feer   valueT)r   r   r   r   r~   )publicGetFeesTradingr   r  r  r   r%  r   )r   r   r   r   r	  r
  groupr   r   r  r   s              r   fetch_trading_feesoceanex.fetch_trading_fees  s      226::x4q#d)$AGEOOE9b9EOOE9b9E''x8H%%h/F ))%9))%9"FN % ! ;s   CCB/Cc                 d   #    U R                  U5      I S h  vN nU R                  US5      $  N7f)Nr   )privateGetKeyr   rJ  s      r   	fetch_keyoceanex.fetch_key  s.     ++F33x00 4rM  c                 x   U R                  US5      nU R                  US/ 5      nSU0n[        S[        U5      5       Hh  nX5   nU R                  US5      nU R                  U5      nU R	                  5       n	U R                  US5      U	S'   U R                  US5      U	S	'   XU'   Mj     U R                  U5      $ )
Nr   accountsr   r   currencybalancefreelockedused)r   r  r  r   accountr   safe_balance)
r   r   r   balancesr	  r
  r]  
currencyIdcodera  s
             r   parse_balanceoceanex.parse_balance  s    x0??4R8)q#h-(AkG*=J**:6DllnG"..w	BGFO"..wAGFO"4L )   ((r   c                    #    U R                  5       I Sh  vN   U R                  U5      I Sh  vN nU R                  U5      $  N. N7f)a5  
query for balance and get the amount of funds available for trading or funds locked in orders

https://api.oceanex.pro/doc/v1/#account-info-post

:param dict [params]: extra parameters specific to the exchange API endpoint
:returns dict: a `balance structure <https://docs.ccxt.com/#/?id=balance-structure>`
N)r   privateGetMembersMerf  rJ  s      r   fetch_balanceoceanex.fetch_balance  sE      !!!11&99!!(++ 	"9s   A	AA	AA	A	r   r<  r   r   c                 `  #    U R                  5       I Sh  vN   U R                  U5      nUS   UUU R                  X5      S.nUS:X  a  U R                  X5      US'   U R	                  U R                  X5      5      I Sh  vN n	U R                  U	S5      n
U R                  X5      $  N N)7f)aH  
create a trade order

https://api.oceanex.pro/doc/v1/#new-order-post

:param str symbol: unified symbol of the market to create an order in
:param str type: 'market' or 'limit'
:param str side: 'buy' or 'sell'
:param float amount: how much of currency you want to trade in units of base currency
:param float [price]: the price at which the order is to be fulfilled, in units of the quote currency, ignored in market orders
:param dict [params]: extra parameters specific to the exchange API endpoint
:returns dict: an `order structure <https://docs.ccxt.com/#/?id=order-structure>`
Nr   )r   r<  ord_typer!  r   r   r   )r   r   amount_to_precisionprice_to_precisionprivatePostOrdersr   r   parse_order)r   r   r   r<  r   r   r   r   r   r   r   s              r   create_orderoceanex.create_order  s      !!!V$Tl..v>	
 7?#66vEGG//G0LMM~~h/-- 	" Ns"   B.B*A+B.B,(B.,B.r   c                   #    U R                  5       I Sh  vN   SnUb  U R                  U5      nU/nSU0nU R                  U R                  Xc5      5      I Sh  vN nU R	                  US5      n[        U5      n	Uc  [        U R                  S-   5      e[        U[        5      (       a  U R                  X5      n
U
S   $ U	S:X  a  [        U R                  S-   5      eU R                  US   U5      $  N N7f)ab  
fetches information on an order made by the user

https://api.oceanex.pro/doc/v1/#order-status-get

:param str id: order id
:param str symbol: unified symbol of the market the order was made in
:param dict [params]: extra parameters specific to the exchange API endpoint
:returns dict: An `order structure <https://docs.ccxt.com/#/?id=order-structure>`
Nidsr   z could not found matching orderr   )r   r   privateGetOrdersr   r   r  r   r   
isinstancelistparse_ordersrq  )r   r   r   r   r   ru  r   r   r   
dataLengthry   s              r   fetch_orderoceanex.fetch_order  s      !!![[(Fd..t{{7/KLLx0Y
<*K KLLb$&&t4F!9?*K KLLQ00! 	" Ms#   C:C6AC:C8BC:8C:c           	      j   #    SS/0nU R                  XX0R                  XT5      5      I Sh  vN $  N7f)a  
fetch all unfilled currently open orders

https://api.oceanex.pro/doc/v1/#order-status-get

:param str symbol: unified market symbol
:param int [since]: the earliest time in ms to fetch open orders for
:param int [limit]: the maximum number of  open orders structures to retrieve
:param dict [params]: extra parameters specific to the exchange API endpoint
:returns Order[]: a list of `order structures <https://docs.ccxt.com/#/?id=order-structure>`
stateswaitNfetch_ordersr   r   r   r3  r   r   r   s         r   fetch_open_ordersoceanex.fetch_open_orders  s9      vh
 &&ve[[=YZZZZs   *313c           	      l   #    SSS/0nU R                  XX0R                  XT5      5      I Sh  vN $  N7f)a  
fetches information on multiple closed orders made by the user

https://api.oceanex.pro/doc/v1/#order-status-get

:param str symbol: unified market symbol of the market orders were made in
:param int [since]: the earliest time in ms to fetch orders for
:param int [limit]: the maximum number of order structures to retrieve
:param dict [params]: extra parameters specific to the exchange API endpoint
:returns Order[]: a list of `order structures <https://docs.ccxt.com/#/?id=order-structure>`
r~  donecancelNr  r  s         r   fetch_closed_ordersoceanex.fetch_closed_orders  s<      vx(
 &&ve[[=YZZZZs   +424c           	      |  #    Uc  [        U R                  S-   5      eU R                  5       I Sh  vN   U R                  U5      nU R	                  US/ SQ5      nU R                  US5      nUS   USS.nUb  X8S'   U R                  U R                  X5      5      I Sh  vN n	U R	                  U	S	/ 5      n
/ n[        S
[        U
5      5       Ha  nU R	                  X   S/ 5      nU R                  U R	                  X   S5      5      nU R                  XX#SU05      nU R                  X5      nMc     U$  GN N7f)a  
fetches information on multiple orders made by the user

https://api.oceanex.pro/doc/v1/#order-status-with-filters-post

:param str symbol: unified market symbol of the market orders were made in
:param int [since]: the earliest time in ms to fetch orders for
:param int [limit]: the maximum number of order structures to retrieve
:param dict [params]: extra parameters specific to the exchange API endpoint
:returns Order[]: a list of `order structures <https://docs.ccxt.com/#/?id=order-structure>`
Nz) fetchOrders() requires a symbol argumentr~  r  r  r  r   True)r   r~  
need_pricer   r   r   ry   statestatus)r   r   r   r   r   omitprivateGetOrdersFilterr   r  r  parse_order_statusry  array_concat)r   r   r3  r   r   r   r~  queryr   r   r   r	  r
  ry   r  parsedOrderss                   r   r  oceanex.fetch_orders  s=     >#DGG.Y$YZZ!!!V$3MN		&(+Tl 

 $G44T[[5PQQx4q#d)$A__TWh;F,,T__TWg-NOF,,VUHV\K]^L&&v<F	 %
 ' 	" Rs#   /D<D7A/D<!D:"BD<:D<c           	          U R                  US5      U R                  US5      U R                  US5      U R                  US5      U R                  US5      U R                  US5      /$ )Nr   r               )r$  r   )r   ohlcvr   s      r   parse_ohlcvoceanex.parse_ohlcv9  sn     q)UA&UA&UA&UA&UA&
 	
r   rc   	timeframec                 v  #    U R                  5       I Sh  vN   U R                  U5      nUS   U R                  U R                  X"5      S.nUb  X7S'   Ub  [	        US5      US'   U R                  U R                  Xu5      5      I Sh  vN nU R                  US/ 5      n	U R                  XX#U5      $  N N,7f)a?  
fetches historical candlestick data containing the open, high, low, and close price, and the volume of a market

https://api.oceanex.pro/doc/v1/#k-line-post

:param str symbol: unified symbol of the market to fetch OHLCV data for
:param str timeframe: the length of time each candle represents
:param int [since]: timestamp in ms of the earliest candle to fetch
:param int [limit]: the maximum amount of candles to fetch
:param dict [params]: extra parameters specific to the exchange API endpoint
:returns int[][]: A list of candles ordered, open, high, low, close, volume
Nr   )r   periodrt   i'  r   r   )	r   r   r   r   r   publicPostKr   r6  parse_ohlcvs)
r   r   r  r3  r   r   r   r   r   ohlcvss
             r   fetch_ohlcvoceanex.fetch_ohlcvK  s      !!!V$Tl&&t	M
 #(K "5%0GG))$++g*FGG&"5  5II 	" Hs"   B9B5A3B9
B7+B97B9r?  c                    U R                  U R                  US5      5      nU R                  USS5      nU R                  XB5      nU R	                  US5      nUc!  U R                  U R                  US5      5      nU R                  US5      nU R                  US5      nU R                  US5      n	U R                  US	5      n
U R                  US
5      nU R                  0 SU_SU R                  US5      _SS _SU_SU R                  U5      _SS _SU_SU R                  US5      _SS _SS _SU R                  US5      _SU_SS _SU_SU	_SU
_SU_US S S S.EU5      $ )Nr  r   	market_idr=  r>  r   	avg_pricer!  remaining_volumeexecuted_volumer   r   clientOrderIdrt   r  lastTradeTimestampr   r   rm  r   postOnlyr<  r   r   r   	remainingfilled)r  r   rs   rA  )	r  r   safe_string_2r%  r$  rB  r   
safe_orderr'  )r   r?  r   r  r  r   rt   r   r   r   r  r  s               r   rq  oceanex.parse_orderf  s   $ (()HI%%eX{C!!(3''|<	t'7'7|'LMI  0""5+6!!%2$$U,>?	!!%):;  
E 
$""5$/ 
 T 
 	 

 Y/ 
 !$ 
 f 
 DOOE:6 
 4 
  
 DOOE62 
 U 
 D 
 w 
 f 
  ! 
" f# 
$ + 
, - 	r   r  c                 2    SSSS.nU R                  X!U5      $ )Nr  closedcanceledr  )r   )r   r  statusess      r   r  oceanex.parse_order_status  s'     

 &99r   c                    #    U R                  5       I Sh  vN   U R                  U R                  SU0U5      5      I Sh  vN nU R                  US5      nU R	                  U5      $  NR N)7f)a7  
cancels an open order

https://api.oceanex.pro/doc/v1/#cancel-order-post

:param str id: order id
:param str symbol: not used by oceanex cancelOrder()
:param dict [params]: extra parameters specific to the exchange API endpoint
:returns dict: An `order structure <https://docs.ccxt.com/#/?id=order-structure>`
Nr   r   )r   privatePostOrderDeleter   r   rq  )r   r   r   r   r   r   s         r   cancel_orderoceanex.cancel_order  sd      !!!44T[[$V5TUU~~h/%% 	"U!   A-A)*A-A+(A-+A-ru  c                    #    U R                  5       I Sh  vN   U R                  U R                  SU0U5      5      I Sh  vN nU R                  US5      nU R	                  U5      $  NR N)7f)aP  
cancel multiple orders

https://api.oceanex.pro/doc/v1/#cancel-multiple-orders-post

:param str[] ids: order ids
:param str symbol: not used by oceanex cancelOrders()
:param dict [params]: extra parameters specific to the exchange API endpoint
:returns dict: an list of `order structures <https://docs.ccxt.com/#/?id=order-structure>`
Nru  r   )r   privatePostOrderDeleteMultir   r6  ry  )r   ru  r   r   r   r   s         r   cancel_ordersoceanex.cancel_orders  se      !!!99$++uclTZ:[\\~~h/  && 	"\r  c                    #    U R                  5       I Sh  vN   U R                  U5      I Sh  vN nU R                  US5      nU R                  U5      $  N@ N)7f)as  
cancel all open orders

https://api.oceanex.pro/doc/v1/#cancel-all-orders-post

:param str symbol: unified market symbol, only orders in the market of self symbol are cancelled when symbol is not None
:param dict [params]: extra parameters specific to the exchange API endpoint
:returns dict[]: a list of `order structures <https://docs.ccxt.com/#/?id=order-structure>`
Nr   )r   privatePostOrdersClearr6  ry  )r   r   r   r   r   s        r   cancel_all_ordersoceanex.cancel_all_orders  sU      !!!44V<<~~h/  && 	"<s   AAAA(AAre  c                   #    U R                  5       I Sh  vN   U R                  U5      nSUS   0nU R                  U R                  XB5      5      I Sh  vN nU R	                  US0 5      nU R	                  US0 5      nU R                  US/ 5      n0 n	[        S[        U5      5       H9  n
X   nU R                  US5      nUS:X  d  M!  U R                  X5      nXUS   '   M;     U	$  N N7f)	ao  
fetch the deposit addresses for a currency associated with self account

https://api.oceanex.pro/doc/v1/#deposit-addresses-post

:param str code: unified currency code
:param dict [params]: extra parameters specific to the exchange API endpoint
:returns dict: a dictionary `address structures <https://docs.ccxt.com/#/?id=address-structure>`, indexed by the network
Nr\  r   r   	resourcesr   deposit_statusenabled)
r   r\  privatePostDepositAddressesr   r   r6  r  r  r   parse_deposit_address)r   re  r   r\  r   r   r   data2r  r	  r
  resourcer  parsedAddresss                 r   "fetch_deposit_addresses_by_network*oceanex.fetch_deposit_addresses_by_network  s      !!!==&
 99$++g:VWW0 ~~h3tVR0NN5+r:	q#i.)A |H&&x1ABG)# $ : :8 N4A}Z01 * O 	"
 Xs(   C.C*?C.C,A1C.C.,C.r\  c                     U R                  US5      nU R                  U5        U R                  US5      nU R                  US5      nUU R                  XB5      U R                  U5      UU R                  US5      S.$ )Naddresscurrency_id
chain_namememo)r   r\  networkr  tag)r   check_addressr   network_id_to_code)r   depositAddressr\  r  rd  	networkIds         r   r  oceanex.parse_deposit_address  s     "">9=7#%%nmD
$$^\B	"//
E..y9##NF;
 	
r   rz   GETc                    U R                   S   S   S-   U R                  -   S-   U R                  X5      -   nU R                  X@R	                  U5      5      nUS:X  a  US:X  d  US:X  a_  Sn	U R                  US5      n
[        S	[        U
5      5       H  nU	S
X   -   S-   -  n	M     U R                  US5      nUb  U	SU-   -  n	Xy-  nOxU(       a  USU R                  U5      -   -  nOYUS:X  aS  U R                  5         U R                  US.n	U R                  XR                  U R                  5      SS5      nUSU-   -  nSS0nXsXeS.$ )Nr+   r)   r   rz   rp   rr   ?ro   r   z
markets[]=&r   zlimit=r{   )uidr   sha256Tz
?user_jwt=zContent-Typezapplication/json)urlmethodbodyheaders)r   r   implode_paramsr  extract_paramsr   r  r  	urlencodecheck_required_credentialsapiKeyjwtencodesecret)r   pathr+   r  r   r  r  r  r  r   ro   r
  r   	jwt_tokens                 r   signoceanex.sign  s\   iiv&,t||;cADDWDWX\Dee		&"5"5d";<(?&$2D*D//&)<q#g,/A|gj83>>G 08$x%//GsT^^E222I++-{{G ++dkk*BHdSI<)++C!#56dOOr   reasonr  r  r  r  c
                    Uc  g U R                  US5      n
U R                  US5      nU
ba  U
S:w  a[  U R                  S-   U-   nU R                  U R                  S   X5        U R                  U R                  S   X5        [	        U5      eg )Nre  message0 r   r   )r   r   throw_exactly_matched_exceptionr   r   )r   re  r  r  r  r  r  r   requestHeadersrequestBody	errorCoder  feedbacks                r   handle_errorsoceanex.handle_errors8  s     $$Xv6	""8Y7!	S(8ww}t+H001I9_001I7]))r    )N)=__name__
__module____qualname____firstlineno__r   r   r   r
   r   dictr   strr   r   r   r   r  r   r	   r   r-  r   r1  r   r8  rF  rK  r   rT  rX  r   rf  rj  r   r   floatr   rr  r   r{  r   r  r  r  rx  r  r  rq  r  r  r  r  r   r  r   r  r  intr  __static_attributes____classcell__)r   s   @r   r"   r"      s   W# Wr *, +V +69
4 9
F 9
v 68 "/ "/F "/H 6:" *G7 *G *GX& &P @DB (CS (C (CS\ (CT :>DY[ 4w 4c 4`j 4l <@d[] '= '=S '= '=bfglbm '=R) )v ) )V ') 5S 5 /1 [ 6 &( 1) ) *, , , mqy{ . .I .Y .X] .fi .8 8<B 1C 1 1: 59tZ^gi [c [ [TW [nrsxny [" 7;\`ik [ [3 [VY [ptuzp{ [" 04$UYbd ! !C !s !imnsit !F
 
4 
$ ?CQUdhqs J J J3 J^a Jx|  ~B  yC J63 3v 3 3j: : 9=R &S &# &  AER 'tCy '# '  59 'c ' JL 1S 1PTUcPd 1f
h 
R` 
, &eBSW P:# s  c TX `c  r   r"   N)% ccxt.async_support.base.exchanger   ccxt.abstract.oceanexr   ccxt.base.typesr   r   r   r   r	   r
   r   r   r   r   r   r   r   r   r   r   r   r   typingr   ccxt.base.errorsr   r   r   r   r   r   r   r   ccxt.base.decimal_to_precisionr    r"   r  r   r   <module>r     sY    6 - }  }  }  }  }  * 0 - . ' . ) * 4ph pr   