
    E#i߬                         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    F/home/james-whalen/.local/lib/python3.13/site-packages/ccxt/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      nU R                  US/ 5      nU R                  U5      $ )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_detailsTdata)publicGetMarketsextend
safe_valueparse_markets)r   paramsrequestresponsero   s        r   fetch_marketsoceanex.fetch_markets   sL     (.((W)EF //(FB7!!'**r   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         U R                  U5      nSUS   0nU R                  U R                  XB5      5      nU R	                  US0 5      nU R                  Xc5      $ )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>`
pairr   r   )load_marketsr   publicGetTickersPairr   	safe_dictparse_ticker)r   r   r   r   r   r   r   s          r   fetch_tickeroceanex.fetch_tickerF  sn     	V$F4L
 ,,T[[-IJ$ ~~h3  ..r   Nsymbolsc                    U R                  5         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      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      $ )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>`
ro   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.--dkk'.JK$ x4q#d)$AWF''9H%%h/FH%F!..v>FN % ++FHgFFr   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         U R                  U5      nSUS   0nUb  X%S'   U R                  U R                  XS5      5      nU R	                  US0 5      nU R                  US5      nU R                  XqU5      $ )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
r   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**4;;w+GH( OOHfb9	''	;?	$$Y	BBr   c                    U R                  5         Uc  U R                  nU R                  U5      nSU0nUb  X%S'   U R                  U R	                  XS5      5      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$ )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
ro   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//G0LM0 x4q#d)$AI''	8<H%%h/F++I{CI!229iPFN % r   sincec                     U R                  5         U R                  U5      nSUS   0nUb  [        US5      US'   U R                  U R	                  Xd5      5      nU R                  US5      nU R                  XX#5      $ )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>`
r   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''G(DE& ~~h/  u<<r   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                 H    U R                  U5      nU R                  US5      $ )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
r   )publicGetTimestampr$  r   r   r   s      r   
fetch_timeoceanex.fetch_timer  s)     **62 ""8V44r   c                 x   U R                  U5      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$ )	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
r   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     ,,V4x4q#d)$AGEOOE9b9EOOE9b9E''x8H%%h/F ))%9))%9"FN % r   c                 H    U R                  U5      nU R                  US5      $ )Nr   )privateGetKeyr   rJ  s      r   	fetch_keyoceanex.fetch_key  s#    %%f-x00r   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coder`  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                 f    U R                  5         U R                  U5      nU R                  U5      $ )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>`
)r   privateGetMembersMere  rJ  s      r   fetch_balanceoceanex.fetch_balance  s1     	++F3!!(++r   r   r<  r   r   c                 0   U R                  5         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      n	U R                  U	S5      n
U R                  X5      $ )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>`
r   )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))$++g*FG~~h/--r   r   c                    U R                  5         SnUb  U R                  U5      nU/nSU0nU R                  U R                  Xc5      5      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      $ )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_ordersrp  )r   r   r   r   r   rt  r   r   r   
dataLengthry   s              r   fetch_orderoceanex.fetch_order  s     	[[(Fd((W)EFx0Y
<*K KLLb$&&t4F!9?*K KLLQ00r   c           	      N    SS/0nU R                  XX0R                  XT5      5      $ )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waitfetch_ordersr   r   r   r3  r   r   r   s         r   fetch_open_ordersoceanex.fetch_open_orders  s0     vh
   {{77STTr   c           	      P    SSS/0nU R                  XX0R                  XT5      5      $ )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cancelr  r  s         r   fetch_closed_ordersoceanex.fetch_closed_orders  s3     vx(
   {{77STTr   c           	      J   Uc  [        U R                  S-   5      eU R                  5         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      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$ )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>`
z) 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_statusrx  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..t{{7/JKx4q#d)$A__TWh;F,,T__TWg-NOF,,VUHV\K]^L&&v<F	 %
 r   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                 F   U R                  5         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      nU R                  US/ 5      n	U R                  XX#U5      $ )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
r   )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##DKK$@A&"5  5IIr   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   rl  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   rp  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         U R                  U R                  SU0U5      5      nU R                  US5      nU R	                  U5      $ )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>`
r   r   )r   privatePostOrderDeleter   r   rp  )r   r   r   r   r   r   s         r   cancel_orderoceanex.cancel_order  sP     	..t{{D":v/NO~~h/%%r   rt  c                     U R                  5         U R                  U R                  SU0U5      5      nU R                  US5      nU R	                  U5      $ )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>`
rt  r   )r   privatePostOrderDeleteMultir   r6  rx  )r   rt  r   r   r   r   s         r   cancel_ordersoceanex.cancel_orders  sP     	33DKKf4UV~~h/  &&r   c                     U R                  5         U R                  U5      nU R                  US5      nU R                  U5      $ )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>`
r   )r   privatePostOrdersClearr6  rx  )r   r   r   r   r   s        r   cancel_all_ordersoceanex.cancel_all_orders  sA     	..v6~~h/  &&r   rd  c                    U R                  5         U R                  U5      nSUS   0nU R                  U R                  XB5      5      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	$ )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
r[  r   r   	resourcesr   deposit_statusenabled)
r   r[  privatePostDepositAddressesr   r   r6  r  r  r   parse_deposit_address)r   rd  r   r[  r   r   r   data2r  r	  r
  resourcer  parsedAddresss                 r   "fetch_deposit_addresses_by_network*oceanex.fetch_deposit_addresses_by_network  s     	==&
 33DKK4PQ0 ~~h3tVR0NN5+r:	q#i.)A |H&&x1ABG)# $ : :8 N4A}Z01 * r   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  rc  	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 )Nrd  message0 r   r   )r   r   throw_exactly_matched_exceptionr   r   )r   rd  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   rS  rW  r   re  ri  r   r   floatr   rq  r   rz  r   r  r  r  rw  r  r  rp  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 02 "/3 "/f "/H 04B *GW *G7 *GX& &P :>b (Cs (C3 (CY (CT 48dSU 4 4 4Zd 4l 6:UW '=3 '=s '=# '=\`af\g '=R) )v ) )V !# 5s 5 )+ { 6  " 1) ) $& ,( , gksu .3 .i .y .RW .`c .8 26b 1c 13 1: /3TXac U U3 Uc Uhlmrhs U" 154VZce U# US UPS Ujnotju U" *.Dt\^ !3 !c ! !cghmcn !F
 
4 
$ 9=4^bkm J# J# JS JX[ Jrvw{r| J63 3v 3 3j: : 37r &s &C &  ;?r 'c 'C '  /32 ' ' DF 1s 1$~J^ 1f
h 
R` 
, &eBSW P:# s  c TX `c  r   r"   N)%ccxt.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    ( - }  }  }  }  }  * 0 - . ' . ) * 4ph pr   