
    !:h                         d dl mZ d dlmZ d dlmZmZmZmZm	Z	m
Z
mZmZmZmZmZmZmZmZmZmZmZmZ d dlmZ d dlmZ d dlmZ d dlmZ d dlmZ d d	lmZ d d
lmZ d dlm Z  d dlm!Z! d dl"m#Z#  G d dee      Z$y)    )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                       e Zd Zdef fdZi fdee   fdZdedefdZ	i fde
defdZdi fd	edefd
Zd9defdZdi fde
dedefdZddi fd	ededefdZddi fde
dededee   fdZd9dededefdZi fdefdZi fdefdZi fdZdefdZi fdefdZdi fde
de de!de"de#f
dZ$di fde
de%fdZ&dddi fde%dededee'   fdZ(dddi fde%dededee'   fd Z)dddi fde%dededee'   fd!Z*d9dede+fd"Z,d#ddi fde
dededee+   fd$Z-d9d%edede'fd&Z.d'e%fd(Z/di fde
de%fd)Z0di fde%fd*Z1di fde%fd+Z2i fd,e
dee3   fd-Z4d9d.e5de3fd/Z6d0d1i ddfd2Z7d,e8d3e
d4e
d5e
d6ed7e
fd8Z9 xZ:S ):oceanexreturnc                     | j                  t        t        |          dddgdddddid	d
ddi dd dddddd dd dd ddddddddddddddddddddddi d d!d"d d#dd$dd%dd&dd'dd(dd)dd*dd+dd,dd-dd.dd/dd0dd1ddddd d2d3d4d5d6d7d8d9d:d;d<d=d>d?g d@dAgdBg dCg dDdBdEdFdd| j	                  dG      | j	                  dG      dHidIdJit
        ddddd ddd dddddKddddddddLd d dddddMddNddddOddNdPdPddddQddNdPdRdPddddSdTdNidU	d d dVd d dVdWt        t        t        t        t        t        t        t        t        t        t        t        dXt        t        t        t        dYdZd[      S )\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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)
rw   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   )	sandboxr8   createOrdersfetchMyTradesrJ   rI   rM   r<   rH   )linearinverse)r/   r1   r2   )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/var/www/html/turnos/venv/lib/python3.12/site-packages/ccxt/async_support/oceanex.pyr   zoceanex.describe   s   gt = ?}5 57H''' %' 	'
 $' $' "4' t' ' $T' t' ' +E' )%' $T'  '!'" (#'$ &z%'& (''( 1$)'* *5+', $U-'. *5/'0 +E1'2 3'4 d5'6 "47'8 d9': !$;'< "4='> t?'@ tA'B C'D TE'F  $#($((,M'R  	  !$L !&"&!..w7!..w7	 w! '  %&+(,,0,0).+06:#(#("'#(	( #($)$)+027/4#()$, %)%)&+#($)*/	# ',!$#($)*/( ',!$$*%+#($)*/$ ',!$$*,-%+#($)*/	*  #u=@ ##
 ##IHV %$&-///,/(), ;E8B@Q2E	UB
 U U	    c                    K   ddi}| j                  | j                  ||             d{   }| j                  |dg       }| j                  |      S 7 (w)a  
        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responserm   s        r   fetch_marketszoceanex.fetch_markets   s[      (...t{{7F/KLL //(FB7!!'** Ms   )AA)Amarketc                    | j                  |d      }| j                  |d      }|j                  d      \  }}| j                  |      }| j                  |      }|j                         }|j                         }|dz   |z   }i d|d|d|d|dd d|d	|d
d dddddddddddddd dddd d d d d d d | j	                  | j                  | j                  |d                  | j	                  | j                  | j                  |d                  dd d dd d dd d d| j                  |d      d ddd |d
S )Nr   r   /symbolbasequotesettlebaseIdquoteIdsettleIdtyper/   Tr0   Fr1   r2   r3   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_marketz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                   K   | j                          d{    | j                  |      }d|d   i}| j                  | j                  ||             d{   }| j	                  |di       }| j                  ||      S 7 j7 +w)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_tickerzoceanex.fetch_tickerE  s      !!!V$F4L
 224;;w3OPP$ ~~h3  v..1 	"
 Qs"   BBA BB*BBNsymbolsc                   K   | j                          d{    | j                  |      }|| j                  }| j                  |      }d|i}| j	                  | j                  ||             d{   }| j                  |dg       }i }t        dt        |            D ]D  }||   }	| j                  |	d      }
| j                  |
      }|d   }| j                  |	|      ||<   F | j                  |d|      S 7 7 w)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>`
        Nrm   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_tickerszoceanex.fetch_tickersi  s     !!!%%g.?llGOOG,	"I.33DKK4PQQ$ x4q#d)$ 	?A!WF''9H%%h/FH%F!..vv>F6N	? ++FHgFFA 	" Rs#   D C<AD 3C>4B	D >D c                    | j                  |di       }| j                  |d      }| j                  d |      }| j                  i d|d|d| j	                  |      d| j                  |d      d| j                  |d      d| j                  |d	      d
d d| j                  |d      dd dd dd d| j                  |d      d| j                  |d      dd dd dd dd | j                  |d      d |d|      S )Nr  atr   rr   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  rr   r   s         r   r   z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                 B  K   | j                          d{    | j                  |      }d|d   i}|||d<   | j                  | j                  ||             d{   }| j	                  |di       }| j                  |d      }| j                  |||      S 7 7 >w)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   rr   )r   r   publicGetOrderBookr   r   r  parse_order_book)	r   r   r   r   r   r   r   	orderbookrr   s	            r   fetch_order_bookzoceanex.fetch_order_book  s      !!!V$fTl
 $GG00Wf1MNN( OOHfb9	''	;?	$$Y	BB; 	" Os"   BBABB=BBc                   K   | j                          d{    || j                  }| j                  |      }d|i}|||d<   | j                  | j	                  ||             d{   }| j                  |dg       }i }t        dt        |            D ]R  }	||	   }
| j                  |
d      }| j                  |      }| j                  |
d      }| j                  |
||      ||<   T |S 7 7 w)as  
        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
        Nrm   r   r   r   r   rr   )r   r   r   publicGetOrderBookMultir   r   r   r   r   r  r  r#  )r   r   r   r   r  r   r   r   r  r  r$  r  r   rr   s                 r   fetch_order_bookszoceanex.fetch_order_books  s     !!!?llGOOG,	y
 $GG55dkk'66RSS0 x4q#d)$ 	QAQI''	8<H%%h/F++I{CI!229fiPF6N	Q S 	" Ts#   C3C/AC3)C1*BC31C3sincec                 2  K   | j                          d{    | j                  |      }d|d   i}|t        |d      |d<   | j                  | j	                  ||             d{   }| j                  |d      }| j                  ||||      S 7 |7 ,w)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   r)  r   r   r   r   r   r   s	            r   fetch_tradeszoceanex.fetch_trades  s      !!!V$fTl
 "5$/GG--dkk'6.JKK& ~~h/  vue<<7 	" Ls"   BBAB(B)+BBtradec                    | j                  |d      }|dk(  rd}n|dk(  rd}| j                  |d      }| j                  ||      }| j                  |d      }|!| j                  | j	                  |d            }| j	                  |d	      }| j	                  |d
      }| j                  ||| j                  |      || j	                  |d      d dd |||d d d|      S )Nsider  r  r  r  r   
created_on
created_atr   r  r   r   )r   rr   r
  r   r   orderr   takerOrMakerr1  r   r   r   fee)r   r  r  	parse8601r   
safe_trader   )	r   r/  r   r1  r  r   rr   priceStringamountStrings	            r   parse_tradezoceanex.parse_tradeF  s     uf-5=DU]D??5(3!!(F3''|<	t'7'7|'LMI&&ug6''x8"Y/""5$/  " 
  	r   c                 d   K   | j                  |       d{   }| j                  |d      S 7 w)aQ  
        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_timezoceanex.fetch_timeq  s5      0088 ""8V44	 9   0.0c                   K   | j                  |       d{   }| j                  |dg       }i }t        dt        |            D ]{  }||   }| j                  |di       }| j                  |di       }| j	                  |d      }	| j                  |	      }
||
| j                  |d      | j                  |d      dd	||
<   } |S 7 w)
aL  
        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_feeszoceanex.fetch_trading_fees  s      226::x4q#d)$ 	AGEOOE9b9EOOE9b9E''x8H%%h/F ))%9))%9"F6N	 ! ;s   CCB/Cc                 d   K   | j                  |       d {   }| j                  |d      S 7 w)Nr   )privateGetKeyr   r>  s      r   	fetch_keyzoceanex.fetch_key  s/     ++F33x00 4r@  c                 x   | j                  |d      }| j                  |dg       }d|i}t        dt        |            D ]i  }||   }| j                  |d      }| j                  |      }| j	                         }	| j                  |d      |	d<   | j                  |d      |	d	<   |	||<   k | j                  |      S )
Nr   accountsr   r   currencybalancefreelockedused)r   r   r   r   accountr   safe_balance)
r   r   r   balancesr  r  rN  
currencyIdcoderR  s
             r   parse_balancezoceanex.parse_balance  s    x0??4R8)q#h-( 	#AqkG*=J**:6DllnG"..w	BGFO"..wAGFO"F4L	#   ((r   c                    K   | j                          d{    | j                  |       d{   }| j                  |      S 7 .7 w)a]  
        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   privateGetMembersMerW  r>  s      r   fetch_balancezoceanex.fetch_balance  sG      !!!11&99!!(++ 	"9s   A	AA	AA	A	r   r1  r   r   c                 f  K   | j                          d{    | j                  |      }|d   ||| j                  ||      d}|dk(  r| j                  ||      |d<   | j	                  | j                  ||             d{   }	| j                  |	d      }
| j                  |
|      S 7 7 *w)a  
        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   r1  ord_typer  r   r   r   )r   r   amount_to_precisionprice_to_precisionprivatePostOrdersr   r   parse_order)r   r   r   r1  r   r   r   r   r   r   r   s              r   create_orderzoceanex.create_order  s      !!!V$Tl..vv>	
 7?#66vuEGG//GV0LMM~~h/f-- 	" Ns"   B1B-A-B1B/)B1/B1r   c                   K   | j                          d{    d}|| j                  |      }|g}d|i}| j                  | j                  ||             d{   }| j	                  |d      }t        |      }	|t        | j                  dz         t        |t              r| j                  ||      }
|
d   S |	dk(  rt        | j                  dz         | j                  |d   |      S 7 7 w)a  
        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_ordersr`  )r   r   r   r   r   rc  r   r   r   
dataLengthrw   s              r   fetch_orderzoceanex.fetch_order  s      !!![[(Fd..t{{7F/KLLx0Y
<*K KLLb$&&tV4F!9?*K KLLQ00! 	" Ms#   C4C0AC4C2BC42C4c           	      p   K   ddgi}| j                  |||| j                  ||             d{   S 7 w)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   r)  r   r   r   s         r   fetch_open_orderszoceanex.fetch_open_orders  sA      vh
 &&vueT[[RX=YZZZZs   -646c           	      r   K   dddgi}| j                  |||| j                  ||             d{   S 7 w)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>`
        rk  donecancelNrm  ro  s         r   fetch_closed_orderszoceanex.fetch_closed_orders  sD      vx(
 &&vueT[[RX=YZZZZs   .757c           	        K   |t        | j                  dz         | j                          d{    | j                  |      }| j	                  |dg d      }| j                  |d      }|d   |dd}|||d<   | j                  | j                  ||             d{   }	| j	                  |	d	g       }
g }t        d
t        |
            D ]e  }| j	                  |
|   dg       }| j                  | j	                  |
|   d            }| j                  ||||d|i      }| j                  ||      }g |S 7 
7 w)a6  
        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 argumentrk  rl  rr  rs  r   True)r   rk  
need_pricer   r   r   rw   statestatus)r   r   r   r   r   omitprivateGetOrdersFilterr   r   r   parse_order_statusrg  array_concat)r   r   r)  r   r   r   rk  queryr   r   r   r  r  rw   rz  parsedOrderss                   r   rn  zoceanex.fetch_orders  sR     >#DGG.Y$YZZ!!!V$3MN		&(+Tl 

 $GG44T[[%5PQQx4q#d)$ 	=A__T!Wh;F,,T__T!Wg-NOF,,VVUEHV\K]^L&&v|<F		=
 ' 	" Rs#   .D?D:A0D?!D="BD?=D?c           	          | j                  |d      | j                  |d      | j                  |d      | j                  |d      | j                  |d      | j                  |d      gS )Nr   r               )r  r   )r   ohlcvr   s      r   parse_ohlcvzoceanex.parse_ohlcv8  sn     q)UA&UA&UA&UA&UA&
 	
r   ra   c                 |  K   | j                          d{    | j                  |      }|d   | j                  | j                  ||      d}|||d<   |t	        |d      |d<   | j                  | j                  ||             d{   }| j                  |dg       }	| j                  |	||||      S 7 7 .w)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   periodrr   i'  r   r   )	r   r   r   r   r   publicPostKr   r,  parse_ohlcvs)
r   r   	timeframer)  r   r   r   r   r   ohlcvss
             r   fetch_ohlcvzoceanex.fetch_ohlcvJ  s      !!!V$Tl&&t	9M
 #(GK "5%0GG))$++gv*FGG&"5  E5II 	" Hs"   B<B8A4B<B:-B<:B<r4  c                    | j                  | j                  |d            }| j                  |dd      }| j                  ||      }| j	                  |d      }|!| j                  | j                  |d            }| j                  |d      }| j                  |d      }| j                  |d      }	| j                  |d	      }
| j                  |d
      }| j                  i d|d| j                  |d      dd d|d| j                  |      dd d|d| j                  |d      dd dd d| j                  |d      d|dd d|d|	d|
d||d d d d|      S )Nry  r   	market_idr2  r3  r   	avg_pricer  remaining_volumeexecuted_volumer   r   clientOrderIdrr   r
  lastTradeTimestampr   r   r\  r   postOnlyr1  r   r  r   	remainingfilled)rz  r   rq   r6  )	r}  r   safe_string_2r  r  r7  r   
safe_orderr   )r   r4  r   rz  r  r   rr   r   r  r   r  r  s               r   r`  zoceanex.parse_ordere  s   $ (()HI%%eX{C!!(F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   rz  c                 4    dddd}| j                  |||      S )Nr  closedcanceledrv  )r   )r   rz  statusess      r   r}  zoceanex.parse_order_status  s)     

 &&99r   c                    K   | j                          d{    | j                  | j                  d|i|             d{   }| j                  |d      }| j	                  |      S 7 R7 )w)ao  
        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   r`  )r   r   r   r   r   r   s         r   cancel_orderzoceanex.cancel_order  sf      !!!44T[[$V5TUU~~h/%% 	"U!   A-A)*A-A+(A-+A-c                    K   | j                          d{    | j                  | j                  d|i|             d{   }| j                  |d      }| j	                  |      S 7 R7 )w)a  
        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>`
        Nrc  r   )r   privatePostOrderDeleteMultir   r,  rg  )r   rc  r   r   r   r   s         r   cancel_orderszoceanex.cancel_orders  sg      !!!99$++uclTZ:[\\~~h/  && 	"\r  c                    K   | j                          d{    | j                  |       d{   }| j                  |d      }| j                  |      S 7 @7 )w)a  
        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   privatePostOrdersClearr,  rg  )r   r   r   r   r   s        r   cancel_all_orderszoceanex.cancel_all_orders  sW      !!!44V<<~~h/  && 	"<s   AAAA(AArV  c                   K   | j                          d{    | j                  |      }d|d   i}| j                  | j                  ||             d{   }| j	                  |di       }| j	                  |di       }| j                  |dg       }i }	t        dt        |            D ]9  }
||
   }| j                  |d      }|dk(  s | j                  ||      }||	|d   <   ; |	S 7 7 w)	a  
        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
        NrM  r   r   	resourcesr   deposit_statusenabled)
r   rM  privatePostDepositAddressesr   r   r,  r   r   r   parse_deposit_address)r   rV  r   rM  r   r   r   data2r  r  r  resourcer  parsedAddresss                 r   "fetch_deposit_addresses_by_networkz*oceanex.fetch_deposit_addresses_by_network  s
     !!!==&
 99$++gv:VWW0 ~~h3tVR0NN5+r:	q#i.) 	BA |H&&x1ABG)# $ : :8X N4A}Z01	B O 	"
 Xs)   C.C*A C.C,A3C.C.,C.rM  c                     | j                  |d      }| j                  |       | j                  |d      }| j                  |d      }|| j                  ||      | j                  |      || j                  |d      dS )Naddresscurrency_id
chain_namememo)r   rM  networkr  tag)r   check_addressr   network_id_to_code)r   depositAddressrM  r  rU  	networkIds         r   r  zoceanex.parse_deposit_address  s     "">9=7#%%nmD
$$^\B	"//
HE..y9##NF;
 	
r   rx   GETc                    | j                   d   d   dz   | j                  z   dz   | j                  ||      z   }| j                  || j	                  |            }|dk(  r|dk(  s|dk(  r^d}	| j                  |d      }
t        d	t        |
            D ]  }|	d
|
|   z   dz   z  }	 | j                  |d      }||	d|z   z  }	||	z  }ns|rq|d| j                  |      z   z  }nY|dk(  rT| j                          | j                  |d}	| j                  |	| j                  | j                        dd      }|d|z   z  }ddi}||||dS )Nr*   r(   r   rx   rn   rp   ?rm   r   z
markets[]=&r   zlimit=ry   )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   rm   r  r   	jwt_tokens                 r   signzoceanex.sign  so   iiv&,t||;cADDWDWX\^dDee		&$"5"5d";<(?&$2D*D//&)<q#g,/ ?A|gaj83>>G?8$x%//GwsT^^E222I++-{{G $++dkk*BHdSI<)++C!#56fdwOOr   reasonr  r  r  r  c
                    |y | j                  |d      }
| j                  |d      }|
b|
dk7  r]| j                  dz   |z   }| j                  | j                  d   |
|       | j                  | j                  d   ||       t	        |      y )NrV  message0 r   r   )r   r   throw_exactly_matched_exceptionr   r   )r   rV  r  r  r  r  r  r   requestHeadersrequestBody	errorCoder  feedbacks                r   handle_errorszoceanex.handle_errors7  s     $$Xv6	""8Y7!	S(8ww}t+H001I9V^_001I7T\]))r   )N);__name__
__module____qualname__r   r   r   r
   r   dictr   strr   r   r   r   r  r   r	   r   r%  r   r(  r   r.  r;  r?  r   rG  rJ  r   rW  rZ  r   r   floatr   ra  r   ri  r   rp  rt  rn  rf  r  r  r`  r}  r  r  r  r   r  r   r  r  intr  __classcell__)r   s   @r   r"   r"      s   V# Vp *, +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 
$ 8<$]ajl J JC JWZ Jquvzq{ J63 3v 3 3j: : 9=R &S &# &  6:" 's '  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   <module>r     sY    6 - }  }  }  }  }  * 0 - . ' . ) * 4oh or   