
    !: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    F/var/www/html/turnos/venv/lib/python3.12/site-packages/ccxt/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                     ddi}| j                  | j                  ||            }| j                  |dg       }| j                  |      S )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_detailsTdata)publicGetMarketsextend
safe_valueparse_markets)r   paramsrequestresponserm   s        r   fetch_marketszoceanex.fetch_markets   sN     (.((Wf)EF //(FB7!!'**r   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                     | j                          | j                  |      }d|d   i}| j                  | j                  ||            }| j	                  |di       }| j                  ||      S )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_tickerzoceanex.fetch_tickerE  sr     	V$F4L
 ,,T[[&-IJ$ ~~h3  v..r   Nsymbolsc                    | j                          | j                  |      }|| j                  }| j                  |      }d|i}| j	                  | j                  ||            }| j                  |dg       }i }t        dt        |            D ]D  }||   }	| j                  |	d      }
| j                  |
      }|d   }| j                  |	|      ||<   F | j                  |d|      S )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>`
        rm   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.--dkk'6.JK$ x4q#d)$ 	?A!WF''9H%%h/FH%F!..vv>F6N	? ++FHgFFr   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                    | j                          | j                  |      }d|d   i}|||d<   | j                  | j                  ||            }| j	                  |di       }| j                  |d      }| j                  |||      S )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   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**4;;w+GH( OOHfb9	''	;?	$$Y	BBr   c                    | j                          || j                  }| j                  |      }d|i}|||d<   | j                  | j	                  ||            }| j                  |dg       }i }t        dt        |            D ]R  }	||	   }
| j                  |
d      }| j                  |      }| j                  |
d      }| j                  |
||      ||<   T |S )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
        rm   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//GV0LM0 x4q#d)$ 	QAQI''	8<H%%h/F++I{CI!229fiPF6N	Q r   sincec                    | j                          | j                  |      }d|d   i}|t        |d      |d<   | j                  | j	                  ||            }| j                  |d      }| j                  ||||      S )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   r)  r   r   r   r   r   r   s	            r   fetch_tradeszoceanex.fetch_trades  s     	V$fTl
 "5$/GG''GV(DE& ~~h/  vue<<r   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                 H    | j                  |      }| j                  |d      S )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
        r   )publicGetTimestampr  r   r   r   s      r   
fetch_timezoceanex.fetch_timeq  s)     **62 ""8V44r   c                 x   | j                  |      }| j                  |dg       }i }t        dt        |            D ]{  }||   }| j                  |di       }| j                  |di       }| j	                  |d      }	| j                  |	      }
||
| j                  |d      | j                  |d      dd||
<   } |S )	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
        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_feeszoceanex.fetch_trading_fees  s     ,,V4x4q#d)$ 	AGEOOE9b9EOOE9b9E''x8H%%h/F ))%9))%9"F6N	 r   c                 H    | j                  |      }| j                  |d      S )Nr   )privateGetKeyr   r>  s      r   	fetch_keyzoceanex.fetch_key  s#    %%f-x00r   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  rM  
currencyIdcoderQ  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                 f    | j                          | j                  |      }| j                  |      S )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>`
        )r   privateGetMembersMerV  r>  s      r   fetch_balancezoceanex.fetch_balance  s1     	++F3!!(++r   r   r1  r   r   c                 6   | j                          | j                  |      }|d   ||| j                  ||      d}|dk(  r| j                  ||      |d<   | j	                  | j                  ||            }	| j                  |	d      }
| j                  |
|      S )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>`
        r   )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))$++gv*FG~~h/f--r   r   c                    | j                          d}|| j                  |      }|g}d|i}| j                  | j                  ||            }| j	                  |d      }t        |      }	|t        | j                  dz         t        |t              r| j                  ||      }
|
d   S |	dk(  rt        | j                  dz         | j                  |d   |      S )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   rb  r   r   r   
dataLengthrw   s              r   fetch_orderzoceanex.fetch_order  s     	[[(Fd((Wf)EFx0Y
<*K KLLb$&&tV4F!9?*K KLLQ00r   c           	      T    ddgi}| j                  |||| j                  ||            S )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   r)  r   r   r   s         r   fetch_open_orderszoceanex.fetch_open_orders  s6     vh
   t{{7F7STTr   c           	      V    dddgi}| j                  |||| j                  ||            S )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>`
        rj  donecancelrl  rn  s         r   fetch_closed_orderszoceanex.fetch_closed_orders  s9     vx(
   t{{7F7STTr   c           	      P   |t        | j                  dz         | j                          | j                  |      }| j	                  |dg d      }| j                  |d      }|d   |dd}|||d<   | j                  | j                  ||            }	| j	                  |	dg       }
g }t        d	t        |
            D ]e  }| j	                  |
|   d
g       }| j                  | j	                  |
|   d            }| j                  ||||d|i      }| j                  ||      }g |S )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>`
        z) fetchOrders() requires a symbol argumentrj  rk  rq  rr  r   True)r   rj  
need_pricer   r   r   rw   statestatus)r   r   r   r   r   omitprivateGetOrdersFilterr   r   r   parse_order_statusrf  array_concat)r   r   r)  r   r   r   rj  queryr   r   r   r  r  rw   ry  parsedOrderss                   r   rm  zoceanex.fetch_orders  s9    >#DGG.Y$YZZV$3MN		&(+Tl 

 $GG..t{{7E/JKx4q#d)$ 	=A__T!Wh;F,,T__T!Wg-NOF,,VVUEHV\K]^L&&v|<F		=
 r   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                 L   | j                          | j                  |      }|d   | j                  | j                  ||      d}|||d<   |t	        |d      |d<   | j                  | j                  ||            }| j                  |dg       }	| j                  |	||||      S )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   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##DKK$@A&"5  E5IIr   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 )Nrx  r   	market_idr2  r3  r   	avg_pricer  remaining_volumeexecuted_volumer   r   clientOrderIdrr   r
  lastTradeTimestampr   r   r[  r   postOnlyr1  r   r  r   	remainingfilled)ry  r   rq   r6  )	r|  r   safe_string_2r  r  r7  r   
safe_orderr   )r   r4  r   ry  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   ry  c                 4    dddd}| j                  |||      S )Nr  closedcanceledru  )r   )r   ry  statusess      r   r|  zoceanex.parse_order_status  s)     

 &&99r   c                     | j                          | j                  | j                  d|i|            }| j                  |d      }| j	                  |      S )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>`
        r   r   )r   privatePostOrderDeleter   r   r_  )r   r   r   r   r   r   s         r   cancel_orderzoceanex.cancel_order  sP     	..t{{D":v/NO~~h/%%r   c                     | j                          | j                  | j                  d|i|            }| j                  |d      }| j	                  |      S )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>`
        rb  r   )r   privatePostOrderDeleteMultir   r,  rf  )r   rb  r   r   r   r   s         r   cancel_orderszoceanex.cancel_orders  sP     	33DKKf4UV~~h/  &&r   c                     | j                          | j                  |      }| j                  |d      }| j                  |      S )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>`
        r   )r   privatePostOrdersClearr,  rf  )r   r   r   r   r   s        r   cancel_all_orderszoceanex.cancel_all_orders  sA     	..v6~~h/  &&r   rU  c                    | j                          | j                  |      }d|d   i}| j                  | j                  ||            }| j	                  |di       }| j	                  |di       }| j                  |dg       }i }	t        dt        |            D ]9  }
||
   }| j                  |d      }|dk(  s | j                  ||      }||	|d   <   ; |	S )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
        rL  r   r   	resourcesr   deposit_statusenabled)
r   rL  privatePostDepositAddressesr   r   r,  r   r   r   parse_deposit_address)r   rU  r   rL  r   r   r   data2r  r  r  resourcer  parsedAddresss                 r   "fetch_deposit_addresses_by_networkz*oceanex.fetch_deposit_addresses_by_network  s     	==&
 33DKK4PQ0 ~~h3tVR0NN5+r:	q#i.) 	BA |H&&x1ABG)# $ : :8X N4A}Z01	B r   rL  c                     | j                  |d      }| j                  |       | j                  |d      }| j                  |d      }|| j                  ||      | j                  |      || j                  |d      dS )Naddresscurrency_id
chain_namememo)r   rL  networkr  tag)r   check_addressr   network_id_to_code)r   depositAddressrL  r  rT  	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_paramsrz  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 )NrU  message0 r   r   )r   r   throw_exactly_matched_exceptionr   r   )r   rU  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   rF  rI  r   rV  rY  r   r   floatr   r`  r   rh  r   ro  rs  rm  re  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 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 
$ 26DW[df J# Jc JQT Jkoptku J63 3v 3 3j: : 37r &s &C &  04B ' '  /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   <module>r     sY    ( - }  }  }  }  }  * 0 - . ' . ) * 4oh or   