
    ei!                       d dl mZ d dlmZ d dlZd dl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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- d dl$m.Z. d dl$m/Z/ d dl$m0Z0 d dl$m1Z1 d dl$m2Z2 d dl$m3Z3 d dl4m5Z5  G d dee          Z6dS )    )Exchange)ImplicitAPIN)AccountAnyBalancesBool
CurrenciesCurrencyDepositAddressIntLeverageTierLeverageTiersMarketNumOrder	OrderBookOrderRequest	OrderSide	OrderTypePositionStrStringsTickerTickersFundingRateFundingRatesTradeTransactionTransferEntry)List)ExchangeError)AuthenticationError)AccountNotEnabled)ArgumentsRequired)
BadRequest)	BadSymbol)MarketClosed)InsufficientFunds)InvalidOrder)OrderNotFound)NotSupported)OperationFailed)NetworkError)RateLimitExceeded)RequestTimeout)	TICK_SIZEc                   0    e Zd Zdef fdZi fdee         fdZdee         fdZdefdZ	i fde
fdZdi fdedefd	Zi fd
edefdZdSdedefdZdddi fd
ededededee         f
dZdSdedefdZdi fd
ededefdZdi fdedefdZi fd
edefdZdSdedefdZdddi fd
ededefdZdSdefdZ dddi fd
ededefdZ!dSdefdZ"di fdede#fdZ$dSdedee%         fdZ&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fdZ)dSdede'fd Z*i fde+fd!Z,de+fd"Z-i fdee.         fd#Z/d$ Z0i fd%ed&e1d'ed(ede2f
d)Z3dddi fd%ededefd*Z4dSd+e5fd,Z6d- Z7i fd%ede8fd.Z9dSd+e5de8fd/Z:dddi fd%edededee;         fd0Z<dddi fd%edededee;         fd1Z=dddi fd+e5dededee;         fd2Z>dSd+e5de;fd3Z?d4 Z@d5 ZAdi fd%ed&e1d6ed7ede;f
d8ZBdi fdedeeC         fd9ZDdSdefd:ZEdi fd
ed;eFd<eGd&e1d=eHdeIfd>ZJi fd?eeK         deeI         fd@ZLdi fd
ed;ed<efdAZMi fd
edBe1fdCZNdi fdDed
edeIfdEZOdddi fd
edededeeI         fdFZPdi fdDed
efdGZQdi fd
efdHZRdi fdIee         d
efdJZSdSdedeIfdKZTdL ZUdM ZVdN ZWdOdPi ddfdQZXdR ZY xZZS )Toxfunreturnc           #      
   |                      t          t          |                                           dddg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
d(d
d)d
i d*d
d+d
d,dd-d
d.dd/d
d0d
d1dd2d
d3d
d4dd5dd6dd7dd8d
d9d
d:d
i d;d
d<d
d=d
d>dd?d@dAddBd
dCddDddEd
dFd
dGddHddIddJd
dKd
dLd
i dMd
dNd
dOd
dPddQd
dRd
dSd
dTd
dUd
dVddWddXd
dYddZd
d[d
d\d
d]d
i d^d
d_d
d`ddad
dbddcd
ddd
ded
dfd
dgddhd
did
djd
dkd
dld
dmddnddodidpdqdrdsdtdudvdwdxdydzd{d{d|d}d}d|d~ddddddddddddddd
iddddddddddddddddddddddddd|ddd|                     d          |                     d          |                     d          |                     d          g|                     d          |                     d          g|                     d          |                     d          gg|                     d          |                     d          g|                     d          |                     d          g|                     d          |                     d          ggddit
          d
dddddddddd	ddddddddddd
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ddid
dddd
dd
d
d
d
dd
d d
d
d
dd d ddid	ddiddid dd d ddi dt          dt          dt          dt          dt          dt          dt          dt          dt          dt          dt          dt          dt          dt          dt          dt          dt          i dt          dt          dt          dt          dt          dt          dt          dt          dt          dt          dt          dt          dt          dt          dt          dt          dt          i dt          dt          dt          dt          dt          dt          dt          dt          dt          dt          dt           dt"          dt"          dt$          dt"          dt          dt          t          t          t          t          t&          t&          t&          t          t          d	t          t(          ddd          S )Nr2   OXFUNPAv3x   TCORSspotmarginFswapfutureoption	addMargincancelAllOrderscancelOrdercancelOrderscloseAllPositionsclosePositioncreateDepositAddresscreateMarketBuyOrderWithCostcreateMarketOrderWithCostcreateMarketSellOrderWithCostcreateOrdercreateOrderscreatePostOnlyOrdercreateReduceOnlyOrdercreateStopLimitOrdercreateStopMarketOrdercreateStopOrderdeposit	editOrderfetchAccountsfetchBalancefetchBidsAsksfetchBorrowInterestfetchBorrowRateHistoriesfetchBorrowRateHistoryfetchCanceledOrdersfetchClosedOrderfetchClosedOrdersfetchCrossBorrowRatefetchCrossBorrowRatesfetchCurrenciesfetchDepositfetchDepositAddressfetchDepositAddressesfetchDepositAddressesByNetworkfetchDepositsfetchDepositWithdrawFeefetchDepositWithdrawFeesfetchFundingHistoryfetchFundingRatefetchFundingRateHistoryfetchFundingRatesfetchIndexOHLCVfetchIsolatedBorrowRatefetchIsolatedBorrowRatesfetchL3OrderBookfetchLedgerfetchLeveragefetchLeverageTiersfetchMarketLeverageTiersemulatedfetchMarketsfetchMarkOHLCVfetchMyTrades
fetchOHLCVfetchOpenInterestHistoryfetchOpenOrderfetchOpenOrders
fetchOrderfetchOrderBookfetchOrderBooksfetchOrdersfetchOrderTradesfetchPositionfetchPositionHistoryfetchPositionModefetchPositionsfetchPositionsForSymbolfetchPositionsHistoryfetchPositionsRiskfetchPremiumIndexOHLCVfetchStatusfetchTickerfetchTickers	fetchTimefetchTradesfetchTradingFeefetchTradingFeesfetchTradingLimitsfetchTransactionFeefetchTransactionFeesfetchTransactionsfetchTransfersfetchWithdrawalfetchWithdrawalsfetchWithdrawalWhitelistreduceMarginrepayCrossMarginrepayIsolatedMarginsandboxsetLeverage	setMarginsetMarginModesetPositionModesignIntransferwithdrawws60s300s900s1800s3600s7200s14400s86400s)1m5m15m30m1h2h4h1dzQhttps://github.com/ccxt/ccxt/assets/43336371/6a196124-c1ee-4fae-8573-962071b61a85z/https://ox.fun/register?shareAccountId=5ZUD4a7Gzhttps://api.ox.fun)publicprivatezhttps://stgapi.ox.funzhttps://ox.fun/zhttps://docs.ox.fun/z7https://support.ox.fun/en/articles/8819866-trading-fees)logoreferralapitestwwwdocfeesget   )
z
v3/marketsz	v3/assetsz
v3/tickerszv3/funding/estimatesz
v3/candleszv3/depthzv3/markets/operationalzv3/exchange-tradeszv3/funding/rateszv3/leverage/tiers)z
v3/accountzv3/account/namesz	v3/walletv3/transferzv3/balanceszv3/positionsz
v3/fundingzv3/deposit-addressesz
v3/depositzv3/withdrawal-addressesv3/withdrawalzv3/withdrawal-feeszv3/orders/statuszv3/orders/workingz	v3/trades)r   r   zv3/orders/place)zv3/orders/cancelzv3/orders/cancel-all)r   postdeletetradingz0.00020z0.0007002500000z0.0001025000000z0.00050z0.00040)makertaker)	tierBased
percentager   r   tiersBitcoinEthereum	AvalancheSolanaArbitrumPolygonFantomBNBSmartChainOptimism)	BTCERC20AVAXSOLARBMATICFTMBNBOPTIMISMr   r   r   r   r   r   r   BASEr   r   )
r   r   r   r   r   r   r   Baser   r   )sandboxModenetworksnetworksById)IOCFOKPOGTD)EXPIRE_MAKEREXPIRE_TAKEREXPIRE_BOTHNONE)
marginModetriggerPricetriggerDirectiontriggerPriceTypestopLossPricetakeProfitPriceattachedStopLossTakeProfittimeInForcehedgedtrailingleveragemarketBuyByCostmarketBuyRequiresPriceselfTradePreventionicebergmax
   i  i    )r   limitdaysBack	untilDayssymbolRequired)r   triggerr   r   )r   r   r   r   r   r   )	r   rI   rJ   rt   ry   rx   r|   rZ   ru   extendsdefault)linearinverse)r   r:   r<   r=   z-0010z-429z-05001z-10001z-20000-20001z-20002z-20003z-20005z-20006z-20007z-20008z-20009z-20010z-20011z-20012z-20013z-20014z-20015z-20016z-20017z-20018z-20019z-20020z-20021z-20022z-20023z-20024z-20025z-20026z-20027z-20028z-20029z-20030z-20031z-20032z-20033z-20034z-20050z-30001z-35034z-35046z-40001z-50001z-300001z-300011z-300012z-100005z-100006z-100008z-100015)	z-710001z-710002z-710003z-710004z-710005z-710006z-710007z-000101z-000201)r  z-200050)exactbroad)idname	countriesversion	rateLimitprohas
timeframesurlsr   r   precisionModeoptionsfeatures
exceptions)deep_extendsuperr2   describeparse_numberr0   r,   r.   r"   r!   r%   r+   r$   r&   r'   r-   r#   r)   r*   r(   r/   )self	__class__s    V/var/www/html/volatility/venv/lib/python3.11/site-packages/ccxt/async_support/oxfun.pyr  zoxfun.describe    s%   eT 2 2 ; ; = =hhh %h 	h
 %h %h Uh "4h th h $Uh  h 'h /h ,Uh  0!h" t#h h$ %h& &t'h( ()h* '+h, (-h. "4/h0 51h2 U3h4  5h6 7h8  9h: &u;h< +E=h> )%?h@ &uAhB #EChD $UEh h hF 'GhH (IhJ "4KhL MhN &tOhP (QhR 1%ShT  UhV *5WhX +EYhZ &t[h\ #D]h^ *4_h` $Tahb "5chd *5ehf +Egh h hh #Eihj ukhl  mhn %dohp +Jqhr sht !%uhv  whx dyhz +E{h| !%}h~ "4h@ dAhB !$ChD "5EhF uGhH #EIh h hJ  KhL 'MhN $UOhP !$QhR *5ShT (UhV %eWhX )%YhZ u[h\ t]h^ _h` Uahb tchd "5ehf #Eghh %eihj &ukh h hl 'mhn $Uohp !$qhr "5sht #Duhv +Ewhx yhz #E{h| &u}h~ 4h@ uAhB UChD  EhF "5GhH %IhJ DKhL DMh hN dOh hT 	 	 lM23 
 66  )-Q " &'%&&'01&'$%23./,--.   '(,-%&'('(()&'01&'34)*./,--.%& $ ())*+,  -.01 / + +Z !%"&!..y99!..y99 "..s33T5F5Fy5Q5QR!..y994;L;LY;W;WX!..z::D<M<Mc<R<RS" "..s33T5F5Fy5Q5QR!..y994;L;LY;W;WX!..z::D<M<Mi<X<XY"  ( '  %$''#%&#* *
 
  % '!'# %&#"%* *! ! 8  $&+(,,1,0).+06:#'#'"&#(	( ( #($)$)+/27,0,0+/$(	0 0 $(3$ $8 r% ',!$$*%&*/& & ',#($)*/	# # ',!%#($)*/( ( $()-#m9 9v y
 "9  $	  ## IH HT=_=-= 1= m	=
 j= j= j= l= 1= j= 1= j= j= /= /=  /!=" /#= =$ j%=& i'=( j)=* j+=, j-=. j/=0 j1=2 j3=4 /5=6 /7=8 m9=: 1;=< j==> j?=@ jA=B jC=D jE= = =F lG=H lI=J jK=L jM=N mO=P jQ=R 1S=T 1U=V mW=X mY=Z 0[=\ |]=^ |_=` }a=b |c=d ze=f |g= =h  -)))000++y= = =~ .- C C]	r@
 r@
 r r r	    c                 6  K   t          j        |                     |          |                     |          g  d{V \  }}|                     |dg           }|                     |dg           }|                     ||          }|                     |          S )a  
        retrieves data on all markets for bitmex

        https://docs.ox.fun/?json#get-v3-markets

        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict[]: an array of objects representing market data
        Ndata)asynciogatherpublicGetV3MarketspublicGetV3Tickers	safe_listarray_concatparse_markets)r  paramsresponseFromMarketsresponseFromTickersmarketsFromMarketsmarketsFromTickersmarketss          r  fetch_marketszoxfun.fetch_markets  s       :A$JaJabhJiJiko  lC  lC  DJ  lK  lK  JL  :M  4M  4M  4M  4M  4M  4M00!^^,?LLr "^^,?LL, ##$68JKK!!'***r  c                 0   g }g }t          dt          |                    D ]s}||         }|                     |d          }|                     ||          s=|                    |           |                    |                     |                     t|S )Nr   
marketCode)rangelensafe_stringin_arrayappendparse_market)r  r)  	marketIdsresultimarketmarketIds          r  r#  zoxfun.parse_markets  s    	q#g,,'' 	9 	9AQZF''==HMM(I66 9  ***d//77888r  c                 X   |                      |dd          }|                    d          }|                      |d          }|                      |d          }|                     |          }|                     |          }|dz   |z   }|                     |dd          }	d }
d }|	d	k    }|r!d
}	d}
|                     d          }|dz   |z   }|	dk    }|                     i d|dd d|d|d|d|d|d|d|
d|	d|ddd
|d	dddddd||rdnd |rdnd | j        d         d         | j        d         d         |rdnd d d d d d |                     |d          d d d d!|                     |d"          d d!d d d!d d d!d#|                     |d$          d |d%          S )&Nr,   -r   r   /typer:   r=   r<   OX:r  	numericIdsymbolbasequotesettlebaseIdquoteIdsettleIdr;   Fr>   activeTcontractr   r   r   tickSize)amountpriceminr   minSize)r   rJ  rK  costlistedAt)r  r  r   r   contractSizeexpiryexpiryDatetimestrike
optionType	precisionlimitscreatedindexinfo)r/  splitsafe_currency_codesafe_string_lowersafe_market_structurer   safe_numbersafe_integer)r  r6  r  partsrD  rE  rA  rB  r@  r<  rF  rC  isFutureisSpots                 r  r2  zoxfun.parse_market  s   flB77!!%++""5!,,&&v..''00e#%%fff==H$ 	+DH,,T22Fc\F*F)) 4+
"4+
4+
 f4+
 D	4+

 U4+
 f4+
 f4+
 w4+
 4+
 D4+
 F4+
 e4+
 H4+
 e4+
 e4+
  d!4+
" #4+
$ '0ddD (2uudYy)'2Yy)'2!)3AAt"))&*==    
  ++FI>> 
   
    $ ((<<g4+
 4+
 4+
 4 4 4	r  c                   K   |                      |           d{V }|                     |dg           }i }t          dt          |                    D ]}||         }|                     |dd          }|                    d          }|d         }	|                     |	          }
|
|vr|	|
ddddddddddddddi g d	||
<   |                     |d
g           }t          dt          |                    D ]}||         }|                     |d          }|                     |          }||d|                     |d          |                     |d          dd| 	                    | 
                    |                     |d                              |                     |d          dd|                     |d          ddd|d
||
         d         |<   |                     ||
         dg           }|                    |           |||
         d<   t          |                                          }t          dt          |                    D ](}||         }
|                     ||
                   ||
<   )|S )a  
        fetches all available currencies on an exchange

        https://docs.ox.fun/?json#get-v3-assets

        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: an associative dictionary of currencies
        Nr  r   assetr9  .rL  )r   rP   )r  coderV  r<  r  rG  rP   r   feerW  r   rZ  networkListnetwork
canDepositcanWithdrawtransactionPrecision
minDepositminWithdrawal)rP   r   )
r  rj  r;   rP   r   rG  rh  rV  rW  rZ  r   rZ  )publicGetV3Assetsr!  r-  r.  r/  r[  r\  network_id_to_code	safe_boolr  parse_precisionr_  r1  listkeyssafe_currency_structure)r  r$  responser  r4  r5  currencyfullIdra  r  rg  chainsjchain	networkIdnetworkCodeinfosallKeyss                     r  fetch_currencieszoxfun.fetch_currenciesD  s      //77777777R ~~h33q#d))$$ :	) :	)AAwH%%h<<FLL%%EqB**2..DFNN !%  "# $ $(#'% %
 $(#'$ $	 	 !#+   t. ^^HmR@@F1c&kk**  q	 ,,UI>>	"55i@@#*"#~~e\BB $um D D"!%!2!243G3GHXHXY^`vHwHw3x3x!y!y $(#3#3E<#H#H#'$ $
 $(#3#3E?#K#K#'% %	 	 "'9 9tZ(55* NN6$<<<ELL"""#(F4L  v{{}}%%q#g,,'' 	F 	FA1:D77tEEF4LLr  Nsymbolsc                    K   |                                   d{V  |                     |          }|                     |           d{V }|                     |dg           }|                     ||          S )a  
        fetches price tickers for multiple markets, statistical information calculated over the past 24 hours for each market

        https://docs.ox.fun/?json#get-v3-tickers

        :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>`
        Nr  )load_marketsmarket_symbolsr   r!  parse_tickers)r  r  r$  rw  tickerss        r  fetch_tickerszoxfun.fetch_tickers  s       !!!!!!!!!%%g..0088888888` ..6266!!'7333r  r@  c                 ^  K   |                                   d{V  |                     |          }d|d         i}|                     |                     ||                     d{V }|                     |dg           }|                     |di           }|                     ||          S )a  
        fetches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market

        https://docs.ox.fun/?json#get-v3-tickers

        :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>`
        Nr,  r  r  r   )r  r6  r   extendr!  	safe_dictparse_ticker)r  r@  r$  r6  requestrw  r  tickers           r  fetch_tickerzoxfun.fetch_ticker  s       !!!!!!!!!V$$&,
 00Wf1M1MNNNNNNNN* ~~h33a,,  000r  r6  c           	      P   |                      |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|          S )NlastUpdatedAtr,  r@  lastTradedPrice	timestampdatetimehighhigh24hlowlow24hbid	bidVolumeask	askVolumevwapopenopen24hcloselastpreviousClosechanger   averagecurrencyVolume24h	markPrice)
baseVolumequoteVolumer  rZ  )r`  r/  safe_marketsafe_tickeriso8601)r  r  r6  r  r7  r@  r  s          r  r  zoxfun.parse_tickerA  s     %%fo>>	##FL99!!(F33!(9:: !
f!
!
 Y//!
 D$$VY77	!

 4##FH55!
 4!
 !
 4!
 !
 D!
 D$$VY77!
 T!
 D!
 T!
 d!
  $!!
" t#!
$ **63FGG))&+>>+!
 !
 !
, -  	r  r   	timeframesincer   c                 *  K   |                                   d{V  |                     |          }|                     | j        ||          }|d         |d}|||d<   |||d<   |                     |d          }|||d<   |                     |d          }n||                     |d          |d<   |                     |                     ||                     d{V }	| 	                    |	d	g           }
| 
                    |
||||          S )
a  
        fetches historical candlestick data containing the open, high, low, and close price, and the volume of a market

        https://docs.ox.fun/?json#get-v3-candles

        :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(default 24 hours ago)
        :param int [limit]: the maximum amount of candles to fetch(default 200, max 500)
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :param int [params.until]: timestamp in ms of the latest candle to fetch(default now)
        :returns int[][]: A list of candles ordered, open, high, low, close, volume
        Nr  )r,  r  	startTimer   untilendTime $r  )r  r6  r/  r  r`  omitsumpublicGetV3Candlesr  r!  parse_ohlcvs)r  r@  r  r  r   r$  r6  r  r  rw  r4  s              r  fetch_ohlcvzoxfun.fetch_ohlcvn  sM      !!!!!!!!!V$$$$T_iKK	 ,"
 
 #(GK $GG!!&'22!&GIYYvw//FF!%%1H!I!IGI00Wf1M1MNNNNNNNN8 &"55  E5IIIr  c           	         |                      |d          |                     |d          |                     |d          |                     |d          |                     |d          |                     |d          gS )NopenedAtr  r  r  r  currencyVolume)r`  r_  )r  ohlcvr6  s      r  parse_ohlcvzoxfun.parse_ohlcv  s     eZ00UF++UF++UE**UG,,U$455
 	
r  c                 x  K   |                                   d{V  |                     |          }d|d         i}|||d<   |                     |                     ||                     d{V }|                     |di           }|                     |d          }|                     ||d         |          S )a6  
        fetches information on open orders with bid(buy) and ask(sell) prices, volumes and other data

        https://docs.ox.fun/?json#get-v3-depth

        :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(default 5, max 100)
        :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  levelr  r  r@  )r  r6  publicGetV3Depthr  r  r`  parse_order_book)	r  r@  r   r$  r6  r  rw  r  r  s	            r  fetch_order_bookzoxfun.fetch_order_book  s       !!!!!!!!!V$$&,
 $GG..t{{7F/K/KLLLLLLLL2 ~~h33%%dO<<	$$T6(+;YGGGr  c                    K   |                                   d{V  |                     |          }|                     |           d{V }|                     |dg           }|                     ||          S )a  
        fetch the current funding rates for multiple markets

        https://docs.ox.fun/?json#get-v3-funding-estimates

        :param str[] symbols: unified market symbols
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns Order[]: an array of `funding rate structures <https://docs.ccxt.com/?id=funding-rate-structure>`
        Nr  )r  r  publicGetV3FundingEstimatesr!  parse_funding_ratesr  r  r$  rw  r  s        r  fetch_funding_rateszoxfun.fetch_funding_rates  s       !!!!!!!!!%%g..99&AAAAAAAA& ~~h33''g666r  c                 t  K   |                                   d{V  d|                     |          i}|                     |                     ||                     d{V }|                     |dg           }|                     |di           }|                     ||                     |                    S )au  
        fetch the current funding rates for a symbol

        https://docs.ox.fun/?json#get-v3-funding-estimates

        :param str symbol: unified market symbols
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns Order[]: an array of `funding rate structures <https://docs.ccxt.com/?id=funding-rate-structure>`
        Nr,  r  r   )r  	market_idr  r  r!  r  parse_funding_rater6  )r  r@  r$  r  rw  r  firsts          r  fetch_funding_ratezoxfun.fetch_funding_rate  s       !!!!!!!!!$..00
 99$++gv:V:VWWWWWWWW~~h33tQ++&&udkk&.A.ABBBr  c                 v   |                      |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 iS )Nr,  	fundingAtrZ  r@  r  
indexPriceinterestRater   estimatedSettlePricer  r  fundingRateestFundingRatefundingTimestampfundingDatetimenextFundingRatenextFundingTimestampnextFundingDatetimepreviousFundingRatepreviousFundingTimestamppreviousFundingDatetimeinterval)r/  r6  r`  r  r  r_  )r  r  r6  r@  estFundingRateTimestamps        r  r  zoxfun.parse_funding_rate&  sU    !!+|<<V$$"&"3"3K"M"M
K
fX&
 
 $	

 D--c22
 #D
 0
 %<==
 4++K9IJJ
 
 t
 t
 #D
 "4
 "4
  '!
" &t#
$ %
 
 	
r  c                   K   |                                   d{V  |                     |          }d|d         i}|||d<   |||d<   |                     |d          }|||d<   |                     |d          }|                     |                     ||                     d{V }|                     |dg           }	|                     |	|||          S )	a  
        Fetches the history of funding rates

        https://docs.ox.fun/?json#get-v3-funding-rates

        :param str symbol: unified symbol of the market to fetch trades for
        :param int [since]: timestamp in ms of the earliest trade to fetch(default 24 hours ago)
        :param int [limit]: the maximum amount of trades to fetch(default 200, max 500)
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :param int [params.until]: timestamp in ms of the latest trade to fetch(default now)
        :returns Trade[]: a list of `trade structures <https://docs.ccxt.com/?id=public-trades>`
        Nr,  r  r  r   r  r  r  )r  r6  r`  r  publicGetV3FundingRatesr  r!  parse_funding_rate_histories
r  r@  r  r   r$  r6  r  r  rw  r  s
             r  fetch_funding_rate_historyz oxfun.fetch_funding_rate_historyF  s      !!!!!!!!!V$$&,
 #(GK $GG!!&'22!&GIYYvw//F55dkk'66R6RSSSSSSSS$ ~~h3300vueLLLr  c                     |                      |d          }|                     ||          }|d         }|                     |d          }|||                     |d          ||                     |          dS )Nr,  r@  	createdAtr  )rZ  r@  r  r  r  )r/  r  r`  r_  r  )r  rZ  r6  r7  r@  r  s         r  parse_funding_rate_historyz oxfun.parse_funding_rate_historyu  s    $ ##D,77!!(F33!%%dK88	++D-@@"Y//
 
 	
r  c                   K   |                                   d{V  |                     |          }d|d         i}|||d<   |||d<   |                     |d          }|||d<   |                     |d          }|                     |                     ||                     d{V }|                     |dg           }	|                     |	|||          S )	a  
        fetches the history of funding payments

        https://docs.ox.fun/?json#get-v3-funding

        :param str symbol: unified symbol of the market to fetch trades for
        :param int [since]: timestamp in ms of the earliest trade to fetch(default 24 hours ago)
        :param int [limit]: the maximum amount of trades to fetch(default 200, max 500)
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :param int [params.until]: timestamp in ms of the latest trade to fetch(default now)
        :returns Trade[]: a list of `trade structures <https://docs.ccxt.com/?id=public-trades>`
        Nr,  r  r  r   r  r  r  )r  r6  r`  r  privateGetV3Fundingr  r!  parse_incomes)
r  r@  r  r   r$  r6  r  r  rw  r4  s
             r  fetch_funding_historyzoxfun.fetch_funding_history  s      !!!!!!!!!V$$&,
 #(GK $GG!!&'22!&GIYYvw//F11$++gv2N2NOOOOOOOO6 &"55!!&&%???r  c           	      p   |                      |d          }|                     ||          }|                     |d          }|                     d          }|                      |d          }|                     |d          }|                     |d          }	|||||                     |          |||	dS )Nr,  paymentr=  r  r  r  )rZ  r@  rg  r  r  r  rJ  rate)r/  safe_symbolr_  r\  safe_timestampr  )
r  incomer6  r7  r@  rJ  rg  r  r  r  s
             r  parse_incomezoxfun.parse_income  s     ##FL99!!(F33!!&)44&&t,,fd++''<<	66"Y//	
 	
 		
r  c                    K   |                                   d{V  |                     |           d{V }|                     |dg           }|                     ||d          S )a;  
        retrieve information on the maximum leverage, and maintenance margin for trades of varying trade sizes, if a market has a leverage tier of 0, then the leverage tiers cannot be obtained for self market

        https://docs.ox.fun/?json#get-v3-leverage-tiers

        :param str[] [symbols]: list of unified market symbols
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: a dictionary of `leverage tiers structures <https://docs.ccxt.com/?id=leverage-tiers-structure>`, indexed by market symbols
        Nr  r,  )r  publicGetV3LeverageTiersr!  parse_leverage_tiersr  s        r  fetch_leverage_tierszoxfun.fetch_leverage_tiers  s       !!!!!!!!!66v>>>>>>>>T ~~h33((wEEEr  c                    |                      |d          }|                     ||          }|                     |dg           }g }t          dt	          |                    D ]}||         }|                    |                     |d          |                     ||          |d         |                     |d          |                     |d          |                     |d          |                     |d	          |d
           |S )Nr,  r   r   tierrC  positionFloorpositionCapmaintenanceMarginr   )r  r@  rx  minNotionalmaxNotionalmaintenanceMarginRatemaxLeveragerZ  )r/  r  r!  r-  r.  r1  r_  r  )r  rZ  r6  r7  listOfTiersr   r{  r  s           r  parse_market_leverage_tiersz!oxfun.parse_market_leverage_tiers!  s   " ##D,77!!(F33nnT7B77q#k**++ 	 	Aq>DLL((v66**8V<<"8,#//oFF#//mDD)-)9)9$@S)T)T#//jAA	 	 	 	 	 	 r  c                   K   |                                   d{V  |                     |          }d|d         i}|||d<   |||d<   |                     |d          }|||d<   |                     |d          }n||                     |d          |d<   |                     |                     ||                     d{V }|                     |d	g           }	|                     |	|||          S )
a  
        get the list of most recent trades for a particular symbol

        https://docs.ox.fun/?json#get-v3-exchange-trades

        :param str symbol: unified symbol of the market to fetch trades for
        :param int [since]: timestamp in ms of the earliest trade to fetch(default 24 hours ago)
        :param int [limit]: the maximum amount of trades to fetch(default 200, max 500)
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :param int [params.until]: timestamp in ms of the latest trade to fetch(default now)
        :returns Trade[]: a list of `trade structures <https://docs.ccxt.com/?id=public-trades>`
        Nr,  r  r  r   r  r  r  r  )	r  r6  r`  r  r  publicGetV3ExchangeTradesr  r!  parse_tradesr  s
             r  fetch_tradeszoxfun.fetch_tradesD  s,      !!!!!!!!!V$$&,
 #(GK $GG!!&'22!&GIYYvw//FF!%%1H!I!IGI77GV8T8TUUUUUUUU" ~~h33  vue<<<r  c                   K   |                                   d{V  i }d}| |                     |          }|d         |d<   |||d<   |||d<   |                     |d          }|||d<   |                     |d          }n||                     |d          |d<   |                     |                     ||                     d{V }|                     |d	g           }	|                     |	|||          S )
aZ  
        fetch all trades made by the user

        https://docs.ox.fun/?json#get-v3-trades

        :param str symbol: unified market symbol
        :param int [since]: the earliest time in ms to fetch trades for
        :param int [limit]: the maximum amount of trades to fetch(default 200, max 500)
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :param int [params.until]: timestamp in ms of the latest trade to fetch(default now)
        :returns Trade[]: a list of `trade structures <https://github.com/ccxt/ccxt/wiki/Manual#trade-structure>`
        Nr  r,  r  r   r  r  r  r  )	r  r6  r`  r  r  privateGetV3Tradesr  r!  r  )
r  r@  r  r   r$  r  r6  r  rw  r4  s
             r  fetch_my_tradeszoxfun.fetch_my_tradest  s8      !!!!!!!!![[((F$*4LGL!#(GK $GG!!&'22!&GIYYvw//FF!%%1H!I!IGI00Wf1M1MNNNNNNNN. &"55  >>>r  c                 x   |                      |d          }|                     ||          }|d         }|                     |d          }|                      |d          |                     |                      |d                    d}|                     |                      |d          ||                     |          |d |                      |d          |                     |d	          |                     |d
d          |                      |d          |                     |dd          d ||d|          S )Nr,  r@  	matchedAtrh  feeAssetrO  rx  matchIdorderIdside	matchTypeorderMatchType
matchPricematchQuantitymatchedQuantity)r  r  r  r@  r<  orderr  takerOrMakerrK  rJ  rO  rh  rZ  )	r/  r  r`  r\  
safe_trader  r]  safe_string_lower_2safe_string_2)r  trader6  r7  r@  r  rh  s          r  parse_tradezoxfun.parse_trade  sN   @ ##E<88!!(F33!%%e[99	$$UE22//0@0@
0S0STT
 
 ""5)44"Y//%%eY77**5&99 44UKIYZZ%%e\::((ARSS 
  
   	r  c                   K   |                                   d{V  |                     |           d{V }|                     |dg           }|d         }|                     |d          }|Ht	          dt          |                    D ]*}||         }|                     |d          }||k    r|} n+|                     |          S )aN  
        query for balance and get the amount of funds available for trading or funds locked in orders

        https://docs.ox.fun/?json#get-v3-balances

        :param dict [params]: extra parameters specific to the exchange API endpoint
        :param str [params.asset]: currency id, if empty the exchange returns info about all currencies
        :param str [params.subAcc]: Name of sub account. If no subAcc is given, then the response contains only the account linked to the API-Key.
        :returns dict: a `balance structure <https://docs.ccxt.com/?id=balance-structure>`
        Nr  r   subAccr  )r  privateGetV3Balancesr!  r/  r-  r.  parse_balance)	r  r$  rw  r  balancer  r5  br  s	            r  fetch_balancezoxfun.fetch_balance  s       !!!!!!!!!226::::::::< ~~h33q'!!&(331c$ii((  G''6226>>GE " !!'***r  c                    d|i}|                      |dg           }t          dt          |                    D ]}||         }|                     |d          }|                     |          }|                                 }|                     |d          |d<   |                     |d          |d<   |                     |d          |d	<   |||<   |                     |          S )
NrZ  balancesr   re  total	availablefreereservedused)r!  r-  r.  r/  r\  accountsafe_balance)	r  r  r4  r!  r5  balanceEntry
currencyIdrg  r'  s	            r  r  zoxfun.parse_balance  s    2 G
 >>':r::q#h--(( 	# 	#A#A;L)),@@J**:66DllnnG#//gFFGG"..|[IIGFO"..|ZHHGFO"F4LL  (((r  c                    K   |                                   d{V  |                     |           d{V }|                     |dg           }|                     ||          S )aQ  
        fetch subaccounts associated with a profile

        https://docs.ox.fun/?json#get-v3-account-names

        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: a dictionary of `account structures <https://docs.ccxt.com/?id=account-structure>` indexed by the account type
        Nr  )r  privateGetV3AccountNamesr!  parse_accounts)r  r$  rw  r  s       r  fetch_accountszoxfun.fetch_accounts@  s~       !!!!!!!!!66v>>>>>>>> ~~h33""4000r  c                 8    |                      |d          d d |dS )N	accountId)r  r<  rg  rZ  r/  )r  r'  s     r  parse_accountzoxfun.parse_account[  s/     ""7K88	
 
 	
r  rg  rJ  fromAccount	toAccountc                 ^  K   |                                   d{V  |                     |          }|d         |                     ||          ||d}|                     |                     ||                     d{V }|                     |di           }	|                     |	|          S )a  
        transfer currency internally between wallets on the same account

        https://docs.ox.fun/?json#post-v3-transfer

        :param str code: unified currency code
        :param float amount: amount to transfer
        :param str fromAccount: account id to transfer from
        :param str toAccount: account id to transfer to
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: a `transfer structure <https://docs.ccxt.com/?id=transfer-structure>`
        Nr  )re  quantityr3  r4  r  )r  rx  currency_to_precisionprivatePostV3Transferr  r  parse_transfer)
r  rg  rJ  r3  r4  r$  rx  r  rw  r  s
             r  r   zoxfun.transferi  s       !!!!!!!!!==&&d^224@@&"	
 
 33DKK4P4PQQQQQQQQ$ ~~h33""4222r  c                   K   |                                   d{V  i }d}| |                     |          }|d         |d<   |||d<   |||d<   |                     |d          }|||d<   |                     |d          }n||                     |d          |d<   |                     |                     ||                     d{V }|                     |d	g           }	|                     |	|||          S )
a  
        fetch a history of internal transfers made on an account

        https://docs.ox.fun/?json#get-v3-transfer

        :param str code: unified currency code of the currency transferred
        :param int [since]: the earliest time in ms to fetch transfers for(default 24 hours ago)
        :param int [limit]: the maximum number of transfer structures to retrieve(default 50, max 200)
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :param int [params.until]: the latest time in ms to fetch transfers for(default time now)
        :returns dict[]: a list of `transfer structures <https://docs.ccxt.com/?id=transfer-structure>`
        Nr  re  r  r   r  r  r  r  )	r  rx  r`  r  r  privateGetV3Transferr  r!  parse_transfers)
r  rg  r  r   r$  r  rx  r  rw  r  s
             r  fetch_transferszoxfun.fetch_transfers  s8      !!!!!!!!!!}}T**H'~GG#(GK $GG!!&'22!&GIYYvw//FF!%%1H!I!IGI224;;w3O3OPPPPPPPP$ ~~h33##D(E5AAAr  rx  c                    |                      |d          }|                     |d          }|                     |d          ||                     |          |                     ||          |                     |d          |                     |d          |                     |d          |                     |                     |d                    |d	S )	NtransferredAtre  r  r6  r3  r4  status)	r  r  r  rx  rJ  r3  r4  r@  rZ  )r`  r/  r  r\  r_  parse_transfer_status)r  r   rx  r  r*  s        r  r9  zoxfun.parse_transfer  s     %%h@@	%%h88
""8T22"Y////
HEE&&x<<++HmDD))(K@@001A1A(H1U1UVV

 

 
	
r  c                 8    ddi}|                      |||          S N	COMPLETEDokr1  r  r@  statusess      r  rA  zoxfun.parse_transfer_status  (    
 &&999r  c                   K   |                      |d          }|                     ||          }|t          | j        dz             |                                  d{V  |                     |          }|d         |d}|                     |d          }|                     |                     ||                     d{V }| 	                    |di           }| 
                    ||          S )a  
        fetch the deposit address for a currency associated with self account

        https://docs.ox.fun/?json#get-v3-deposit-addresses

        :param str code: unified currency code
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :param str [params.network]: network for fetch deposit address
        :returns dict: an `address structure <https://docs.ccxt.com/?id=address-structure>`
        rj  Nz0 fetchDepositAddress() require network parameterr  )re  rj  r  )r/  network_code_to_idr%   r  r  rx  r  privateGetV3DepositAddressesr  r  parse_deposit_address)	r  rg  r$  r~  r}  rx  r  rw  r  s	            r  fetch_deposit_addresszoxfun.fetch_deposit_address  s      &&vy99++K>>	TW'YYZZZ!!!!!!!!!==&&d^ 
 
 69--::4;;wPV;W;WXXXXXXXX ~~h33))$999r  c                 t    |                      |d          }|                     |           ||d         d |d dS )Naddressrg  )rZ  rx  rj  rO  tag)r/  check_address)r  depositAddressrx  rO  s       r  rL  zoxfun.parse_deposit_address  sP     "">9==7###" (
 
 	
r  c                   K   |                                   d{V  i }d}| |                     |          }|d         |d<   |||d<   |||d<   |                     |d          }|||d<   |                     |d          }|                     |                     ||                     d{V }|                     |dg           }	t          d	t          |	                    D ]}
d
|	|
         d<   | 	                    |	|||          S )a  
        fetch all deposits made to an account

        https://docs.ox.fun/?json#get-v3-deposit

        :param str code: unified currency code of the currency transferred
        :param int [since]: the earliest time in ms to fetch transfers for(default 24 hours ago)
        :param int [limit]: the maximum number of transfer structures to retrieve(default 50, max 200)
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :param int [params.until]: the latest time in ms to fetch transfers for(default time now)
        :returns dict[]: a list of `transfer structures <https://docs.ccxt.com/?id=transfer-structure>`
        Nr  re  r  r   r  r  r  r   rP   r<  )
r  rx  r`  r  privateGetV3Depositr  r!  r-  r.  parse_transactionsr  rg  r  r   r$  r  rx  r  rw  r  r5  s              r  fetch_depositszoxfun.fetch_deposits  sE      !!!!!!!!!!}}T**H'~GG#(GK $GG!!&'22!&GIYYvw//F11$++gv2N2NOOOOOOOO$ ~~h33q#d))$$ 	( 	(A'DGFOO&&tXueDDDr  c                   K   |                                   d{V  i }d}| |                     |          }|d         |d<   |||d<   |||d<   |                     |d          }|||d<   |                     |d          }|                     |                     ||                     d{V }|                     |dg           }	t          d	t          |	                    D ]}
d
|	|
         d<   | 	                    |	|||          S )a  
        fetch all withdrawals made from an account

        https://docs.ox.fun/?json#get-v3-withdrawal

        :param str code: unified currency code of the currency transferred
        :param int [since]: the earliest time in ms to fetch transfers for(default 24 hours ago)
        :param int [limit]: the maximum number of transfer structures to retrieve(default 50, max 200)
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :param int [params.until]: the latest time in ms to fetch transfers for(default time now)
        :returns dict[]: a list of `transaction structures <https://docs.ccxt.com/?id=transaction-structure>`
        Nr  re  r  r   r  r  r  r   
withdrawalr<  )
r  rx  r`  r  privateGetV3Withdrawalr  r!  r-  r.  rU  rV  s              r  fetch_withdrawalszoxfun.fetch_withdrawalsF  sE      !!!!!!!!!!}}T**H'~GG#(GK $GG!!&'22!&GIYYvw//F44T[[&5Q5QRRRRRRRR( ~~h33q#d))$$ 	+ 	+A*DGFOO&&tXueDDDr  c                 Z   g }t          dt          |                    D ]R}|                     ||         |          ||<   |                     ||         |          }|                    |           S|                     |d          }||d         nd }	|                     ||	||          S )Nr   r  rg  )r-  r.  r  parse_transactionr1  sort_byfilter_by_currency_since_limit)
r  transactionsrx  r  r   r$  r4  r5  transactionrg  s
             r  rU  zoxfun.parse_transactionsz  s    q#l++,, 	' 	'A"kk,q/6BBLO00a(KKKMM+&&&&fk22$,$8xt2264NNNr  c                    |                      |d          }|                      |d          }|                     |d          }d }d }d }|dk    r@|                      |d          }|                     |                      |d                    }nE|dk    r?|                      |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S )Nr  r<  rP   rO  r@  rY  txIdre  rj  
creditedAtrequestedAtr6  rh  r	  rZ  txidr  r  	addressToaddressFromrP  tagTotagFromrJ  rx  updated)internalcommentrh  )	r/  r  parse_deposit_statusparse_withdrawal_statusr\  rq  safe_integer_2r_  r  )r  ra  rx  r  r<  rO  rg  r@  rf  r*  rg  rj  r~  r  rJ  feeCostrh  s                    r  r]  zoxfun.parse_transaction  s   R k400V44iiV44	9&&{I>>G..t/?/?X/V/VWWFF\!!((i@@I11$2B2B;PX2Y2YZZFV44%%k7;;
&&z8<<"";	::--g66''\=QQ	!!+z::"";66  C
K
"
 D
 	

 Y//
 {
 w
 
 4
 4
 T
 t
 D
 f
 
  f!
" t#
$ )
 
 
 	
r  c                 8    ddi}|                      |||          S rC  r1  rF  s      r  rn  zoxfun.parse_deposit_status  rH  r  c                 D    dddddddd}|                      |||          S )NrE  pendingcanceledfailed)rD  
PROCESSINGzIN SWEEPINGPENDINGzON HOLDCANCELEDFAILEDr1  rF  s      r  ro  zoxfun.parse_withdrawal_status  s=    #$  "
 
 &&999r  rO  rP  c                   K   |                      ||          \  }}|                                  d{V  |                     |          }|                     ||          }|d         ||d}|||d<   d}	|                     |          \  }	}|	|                     |	          |d<   d|d<   |                     |                     ||                     d{V }
|                     |
di           }d	|d
<   | 	                    ||          S )a  
        make a withdrawal

        https://docs.ox.fun/?json#post-v3-withdrawal

        :param str code: unified currency code
        :param float amount: the amount to withdraw
        :param str address: the address to withdraw to
        :param str tag:
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :param str [params.network]: network for withdraw
        :param bool [params.externalFee]: if False, then the fee is taken from the quantity, also with the burn fee for asset SOLO

 EXCHANGE SPECIFIC PARAMETERS
        :param str [params.tfaType]: GOOGLE, or AUTHY_SECRET, or YUBIKEY, for 2FA
        :param str [params.code]: 2FA code
        :returns dict: a `transaction structure <https://docs.ccxt.com/?id=transaction-structure>`
        Nr  )re  rO  r6  memorj  FexternalFeer  rY  r<  )
handle_withdraw_tag_and_paramsr  rx  r7  handle_network_code_and_paramsrJ  privatePostV3Withdrawalr  r  r]  )r  rg  rJ  rO  rP  r$  rx  stringAmountr  r~  rw  r  s               r  r   zoxfun.withdraw  sB     & 99#vFFV!!!!!!!!!==&&11$??d^$
 

 ?!GFO"AA&IIV"!%!8!8!E!EGI!&55dkk'66R6RSSSSSSSS" ~~h33#V%%dH555r  c                   K   |                                   d{V  |                     |          }|                     |           d{V }|                     |dg           }g }t	          dt          |                    D ]7}||         }|                     |dg           }|                     ||          }8|                     ||          S )a  
        fetch all open positions

        https://docs.ox.fun/?json#get-v3-positions

        :param str[]|None symbols: list of unified market symbols
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :param boolean [params.subAcc]:
        :returns dict[]: a list of `position structure <https://docs.ccxt.com/?id=position-structure>`
        Nr  r   	positions)r  r  privateGetV3Positionsr!  r-  r.  r"  parse_positions)	r  r  r$  rw  r  allPositionsr5  r'  r  s	            r  fetch_positionszoxfun.fetch_positions(  s       !!!!!!!!!%%g..33F;;;;;;;;X ~~h33q#d))$$ 	F 	FA1gGwR@@I,,\9EELL##L':::r  c                    |                      |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 |                     |d          d d d d d d d d d d          S )Nr,  rZ  r  r@  notionalr   crossliquidationPriceestLiquidationPrice
entryPriceunrealizedPnlpositionPnlrealizedPnlr   	contractspositionrQ  r  	lastPricer  r   r  r  )r  lastUpdateTimestampr  maintenanceMarginPercentage
collateralinitialMargininitialMarginPercentager   marginRatior   r   )r/  r  safe_positionr_  r`  )r  r  r6  r7  s       r  parse_positionzoxfun.parse_positionl  s    ##Hl;;!!(F33!! #
H#
$#
 fX&#
 	#

 '#
  0 0;P Q Q#
 $**8\BB#
 T--hFF#
 4#
 $#
 ))(J??#
 D#
 ))(K@@#
 #
 D#
  d!#
" ##
$ #'#4#4X#O#O!%+/!'+!#9#
 #
 #
   	r  r<  r  rK  c                 N  K   |                                   d{V  |                     |dd          |                     |d|                                           d}|                     |ddg          }|                     |d          }|||d<   |                     |d          }|                     ||||||          }	|	g|d<   |                     |           d{V }
|                     |
dg           }|                     |d	i           }| 	                    |          S )
a  
        create a trade order

        https://docs.ox.fun/?json#post-v3-orders-place

        :param str symbol: unified symbol of the market to create an order in
        :param str type: 'market', 'limit', 'STOP_LIMIT' or 'STOP_MARKET'
        :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
        :param int [params.clientOrderId]: a unique id for the order
        :param int [params.timestamp]: in milliseconds. If an order reaches the matching engine and the current timestamp exceeds timestamp + recvWindow, then the order will be rejected.
        :param int [params.recvWindow]: in milliseconds. If an order reaches the matching engine and the current timestamp exceeds timestamp + recvWindow, then the order will be rejected. If timestamp is provided without recvWindow, then a default recvWindow of 1000ms is used.
        :param str [params.responseType]: FULL or ACK
        :param float [params.cost]: the quote quantity that can be used alternative for the amount for market buy orders
        :param float [params.triggerPrice]: The price at which a trigger order is triggered at
        :param float [params.limitPrice]: Limit price for the STOP_LIMIT order
        :param bool [params.postOnly]: if True, the order will only be posted if it will be a maker order
        :param str [params.timeInForce]: GTC(default), IOC, FOK, PO, MAKER_ONLY or MAKER_ONLY_REPRICE(reprices order to the best maker only price if the specified price were to lead to a taker trade)
        :param str [params.selfTradePrevention]: NONE, EXPIRE_MAKER, EXPIRE_TAKER or EXPIRE_BOTH for more info check here {@link https://docs.ox.fun/?json#self-trade-prevention-modes}
        :param str [params.displayQuantity]: for an iceberg order, pass both quantity and displayQuantity fields in the order request
        :returns dict: an `order structure <https://docs.ccxt.com/?id=order-structure>`
        NresponseTypeFULLr  )r  r  
recvWindowordersr  r   )
r  r/  r`  millisecondsr  create_order_requestprivatePostV3OrdersPlacer!  r  parse_order)r  r@  r<  r  rJ  rK  r$  r  r  orderRequestrw  r  r  s                r  create_orderzoxfun.create_order  sP     2 !!!!!!!!! ,,V^VLL**6;@Q@Q@S@STT
 
 6NK#@AA&&v|<<
!$.GL!YYv|44F00tVUTZ[[)N66w????????j ~~h33tQ++&&&r  r  c           	        K   |                                   d{V  g }t          dt          |                    D ]}||         }|                     |d          }|                     |d          }|                     |d          }|                     |d          }	|                     |d          }
|                     |di           }|                     ||||	|
|          }|                    |           d	|                                 |d
}| 	                    | 
                    ||                     d{V }|                     |dg           }|                     |          S )a  
        create a list of trade orders

        https://docs.ox.fun/?json#post-v3-orders-place

        :param Array orders: list of orders to create, each object should contain the parameters required by createOrder, namely symbol, type, side, amount, price and params
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :param int [params.timestamp]: *for all orders* in milliseconds. If orders reach the matching engine and the current timestamp exceeds timestamp + recvWindow, then all orders will be rejected.
        :param int [params.recvWindow]: *for all orders* in milliseconds. If orders reach the matching engine and the current timestamp exceeds timestamp + recvWindow, then all orders will be rejected. If timestamp is provided without recvWindow, then a default recvWindow of 1000ms is used.
        :param str [params.responseType]: *for all orders* FULL or ACK
        :returns dict: an `order structure <https://docs.ccxt.com/?id=order-structure>`
        Nr   r@  r<  r  rJ  rK  r$  r  )r  r  r  r  )r  r-  r.  r/  r_  r  r  r1  r  r  r  r!  parse_orders)r  r  r$  ordersRequestsr5  rawOrderr@  r<  r  rJ  rK  orderParamsr  r  rw  r  s                   r  create_orderszoxfun.create_orders9	  s      !!!!!!!!!q#f++&& 		0 		0AayH%%h99F##Hf55D##Hf55D%%h99F$$Xw77E..8R@@K44VT4QVXcddL!!,////"**,,$
 

 66t{{7F7S7STTTTTTTT~~h33  &&&r  c                    |                      |          }|d         |                                dd}|                     |dd          }	|	|	|d<   |                     |ddg          }n||d<   |                     |dd	          }
|                                }|
.|d
k    rd}n|dk    rd}|
|d	<   |                     |dd	g          }||d<   |dk    r||d<   n|||d<   d}|d
k    p|dk    }|                     |d|          \  }}|                     |d          }|r|dk    rd|d<   d}|                     |dd          \  }}||                                |d<   |                     ||          S )a  
        :param str symbol: unified symbol of the market to create an order in
        :param str type: 'market', 'limit', 'STOP_LIMIT' or 'STOP_MARKET'
        :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
        :param int [params.clientOrderId]: a unique id for the order
        :param float [params.cost]: the quote quantity that can be used alternative for the amount for market buy orders
        :param float [params.triggerPrice]: The price at which a trigger order is triggered at
        :param float [params.limitPrice]: Limit price for the STOP_LIMIT order
        :param bool [params.postOnly]: if True, the order will only be posted if it will be a maker order
        :param str [params.timeInForce]: GTC(default), IOC, FOK, PO, MAKER_ONLY or MAKER_ONLY_REPRICE(reprices order to the best maker only price if the specified price were to lead to a taker trade)
        :param str [params.selfTradePrevention]: NONE, EXPIRE_MAKER, EXPIRE_TAKER or EXPIRE_BOTH for more info check here {@link https://docs.ox.fun/?json#self-trade-prevention-modes}
        :param str [params.displayQuantity]: for an iceberg order, pass both quantity and displayQuantity fields in the order request
        r  i  )r,  r  sourcerO  rJ  Nr6  r   	stopPriceMARKETSTOP_MARKETLIMIT
STOP_LIMIT	orderType
limitPricerK  Fr   MAKER_ONLY_REPRICE
MAKER_ONLYrI   r   selfTradePreventionMode)r6  upperr  r  handle_post_onlysafe_string_upperhandle_option_and_paramsr  )r  r@  r<  r  rJ  rK  r$  r6  r  rO  r   r  postOnlyisMarketOrderr   r   s                   r  r  zoxfun.create_order_request[	  s   " V$$ ,JJLL
 

 !!&&(;; $GHYYv'9::FF"(GJ))&.+NNJJLL	#H$$)		g%%(	#/GK YYv'DEEF($$$)GL!!$GG"h.OI4N00vNN&,,V]CC 	2(<<<%1GM""&*&C&CFM[p&q&q#V*1D1J1J1L1LG-.{{7F+++r  rO  c                   K   |                                   d{V  |                     |          }|d         st          | j        dz             d|i}|                     |dddd|                     ||                     d{V S )a  
        create a market buy order by providing the symbol and cost

        https://open.big.one/docs/spot_orders.html#create-order

        :param str symbol: unified symbol of the market to create an order in
        :param float cost: how much you want to trade in units of the quote currency
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: an `order structure <https://docs.ccxt.com/?id=order-structure>`
        Nr:   z9 createMarketBuyOrderWithCost() supports spot orders onlyrO  r6  buy)r  r6  r+   r  r  r  )r  r@  rO  r$  r6  r  s         r  !create_market_buy_order_with_costz'oxfun.create_market_buy_order_with_cost	  s       !!!!!!!!!V$$f~ 	ftw)ddeeeD
 &&vxdDKKX_agLhLhiiiiiiiiir  r  c                    K   |                                   d{V  d|i}|                     |                     ||                     d{V }|                     |di           }|                     |          S )a  

        https://docs.ox.fun/?json#get-v3-orders-status

        fetches information on an order made by the user
        :param str id: a unique id for the order
        :param str [symbol]: not used by oxfun fetchOrder
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :param int [params.clientOrderId]: the client order id of the order
        :returns dict: An `order structure <https://docs.ccxt.com/?id=order-structure>`
        Nr  r  )r  privateGetV3OrdersStatusr  r  r  )r  r  r@  r$  r  rw  r  s          r  fetch_orderzoxfun.fetch_order	  s       !!!!!!!!!r
 66t{{7F7S7STTTTTTTT0 ~~h33%%%r  c                 ,  K   |                                   d{V  i }d}||                     |          }|                     |                     ||                     d{V }|                     |dg           }|                     ||||          S )a  
        fetch all unfilled currently open orders

        https://docs.ox.fun/?json#get-v3-orders-working

        :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
        :param int [params.orderId]: a unique id for the order
        :param int [params.clientOrderId]: the client order id of the order
        :returns Order[]: a list of `order structures <https://docs.ccxt.com/?id=order-structure>`
        Nr  )r  r6  privateGetV3OrdersWorkingr  r!  r  )	r  r@  r  r   r$  r  r6  rw  r  s	            r  fetch_open_orderszoxfun.fetch_open_orders	  s       !!!!!!!!![[((F77GV8T8TUUUUUUUU~~h33  vue<<<r  c                   K   |t          | j        dz             |                     |          }|d         }|                                 dd}||d}|                     |d          }|||d<   |g|d<   |                     |                     ||                     d{V }	|                     |	d	g           }
|                     |
d
i           }| 	                    |          S )al  
        cancels an open order

        https://docs.ox.fun/?json#delete-v3-orders-cancel

        :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
        :param int [params.clientOrderId]: a unique id for the order
        :param int [params.timestamp]: in milliseconds
        :param int [params.recvWindow]: in milliseconds
        :param str [params.responseType]: 'FULL' or 'ACK'
        :returns dict: An `order structure <https://docs.ccxt.com/?id=order-structure>`
        Nz) cancelOrder() requires a symbol argumentr  r  r  r  r,  r  clientOrderIdr  r  r   )
r$   r  r6  r  r`  privateDeleteV3OrdersCancelr  r!  r  r  )r  r  r@  r$  r6  r7  r  r  r  rw  r  r  s               r  cancel_orderzoxfun.cancel_order	  s      >#DG.Y$YZZZV$$$<**,,"
 

 #
 
 ))&/BB$,9L))N99$++gv:V:VWWWWWWWW~~h33tQ++&&&r  c                    K   i }| |                      |          }|d         |d<   |                     |                     ||                     d{V }|                     d|i          gS )al  
        cancel all open orders

        https://docs.ox.fun/?json#delete-v3-orders-cancel-all

        :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: response from exchange
        Nr  r,  rZ  )r6  privateDeleteV3OrdersCancelAllr  
safe_order)r  r@  r$  r  r6  rw  s         r  cancel_all_orderszoxfun.cancel_all_orders
  s       [[((F$*4LGL! <<T[[RX=Y=YZZZZZZZZ 23344r  idsc                   K   |t          | j        dz             |                                  d{V  |                     |          }|d         }|                                 dd}g }t          dt          |                    D ]"}|||         d}	|                    |	           #||d<   |                     | 	                    ||                     d{V }
| 
                    |
d	g           }|                     ||          S )
a  
        cancel multiple orders

        https://docs.ox.fun/?json#delete-v3-orders-cancel

        :param str[] ids: order ids
        :param str [symbol]: unified market symbol
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :param int [params.timestamp]: in milliseconds
        :param int [params.recvWindow]: in milliseconds
        :param str [params.responseType]: 'FULL' or 'ACK'
        :returns dict: an list of `order structures <https://docs.ccxt.com/?id=order-structure>`
        Nz* cancelOrders() requires a symbol argumentr  r  r  r   r  r  r  )r$   r  r  r6  r  r-  r.  r1  r  r  r!  r  )r  r  r@  r$  r6  r7  r  r  r5  r  rw  r  s               r  cancel_orderszoxfun.cancel_orders(
  s:      >#DG.Z$Z[[[!!!!!!!!!V$$$<**,,"
 
 q#c((## 	! 	!A&q6 E MM%    "99$++gv:V:VWWWWWWWW~~h33  v...r  c           
         |                      |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|                     |g d          dd d|                     |dd          d|                     |dd           d!|                      |d"          d#|	|	|                     |                      |d                    d ||d$|          S )%Nr,  r  feeInstrumentIdr   )rx  rO  r@  rg  rejectedr  r  r  r  r  r  lastTradeTimestamplastMatchedAtr  lastModifiedAtr@  r<  r  r   r  rK  )rK  r  r  r  rJ  totalQuantityr6  filledcumulativeMatchedQuantityr  	remainingremainQuantityr   )r   rO  tradesrh  rZ  )r/  r  r`  r\  r_  r  r  parse_order_statusparse_order_typeparse_order_time_in_forcer]  safe_string_nr  	omit_zero)
r  r  r6  r7  r  rh  feeCurrencyr@  rg  r   s
             r  r  zoxfun.parse_orderK
  s   ` ##E<88!!(F33%%e[99	&&u.?@@" 33K@@((77 C !!%22  //F''{;;  
$""5)44 
T--e_EE 
  
 Y//	 

 !$"3"3E?"K"K 
 "4#4#4U<L#M#M 
 d--f55 
 fX& 
 D))$*:*:5+*N*NOO 
 499$:J:J5R_:`:`aa 
 D**5&99 
 T''/T/T/TUU 
 t 
 d((LL 
 d((0K_]] 
  ))%1ABB! 
" L# 
$ *NN4#3#3E8#D#DEE- 
  
  
. /  	r  c                 L    dddddddddddd}|                      |||          S )Nr  closedru  r  )OPENPARTIALLY_FILLEDPARTIAL_FILLFILLEDry  CANCELED_BY_USERCANCELED_BY_MAKER_ONLYCANCELED_BY_FOKCANCELED_ALL_BY_IOCCANCELED_PARTIAL_BY_IOC!CANCELED_BY_SELF_TRADE_PROTECTIONr1  rF  s      r  r  zoxfun.parse_order_status
  sI     &"" *&0)#-'11;
 
 &&999r  c                 >    ddddd}|                      |||          S )Nr   r6  )r  r  r  r  r1  r  r<  typess      r  r  zoxfun.parse_order_type
  s4    !#	
 
 tT222r  c                 @    dddddd}|                      |||          S )NGTCr   r   r   )r  r   r   r  r  r1  r  s      r  r  zoxfun.parse_order_time_in_force
  s7    "&
 
 tT222r  r   GETc                 D   | j         d         |         }|dz   |z   }d}	|dk    r0|                     |          }	t          |	          dk    r|d|	z   z  }|dk    r@|                                  |                                 }
|                     |
          }|                    d          }|d         }|                                 }|                    d	          }|d
k    s|dk    r|                     |          }|}	|dz   t          |          z   dz   |z   dz   |d         z   dz   |z   dz   |	z   }| 
                    |                     |          |                     | j                  t          j        d          }d| j        ||t          |          d}||||dS )Nr   r;  r9  r  r   ?r   rf  z//POSTDELETE
r   z
/base64zapplication/json)zContent-Type	AccessKey	Timestamp	SignatureNonce)urlmethodbodyheaders)r  	urlencoder.  check_required_credentialsr  r  r[  noncejsonstrhmacencodesecrethashlibsha256apiKey)r  pathr   r  r$  r  r  baseUrlr  queryStringr  isoDatetimedatetimePartsr  r	  urlParts	msgString	signatures                     r  signz
oxfun.sign  s   )E"3'md"U??..00K;1$$s[(()++---))++I,,y11K'--c22M$Q'HJJLLE}}T**H&  f&8&8yy((" 4#e**4t;fDtKhWXkY\aadhhkoor}}I		$++i"8"8$++dk:R:RT[TbdlmmI 2![%&U G fdwOOOr  c
                    |d S |dk    rw|                      |dd           }
| j        dz   |z   }|                     | j        d         ||           |                     | j        d         |
|           t          |          d S )N   rg   r  r  )r/  r  throw_broadly_matched_exceptionr  throw_exactly_matched_exceptionr!   )r  rg  reasonr  r  r  r  rw  requestHeadersrequestBodyresponseCodefeedbacks               r  handle_errorszoxfun.handle_errors$  s    43;;++HfdCCLw}t+H001I4QYZZZ001I<Yabbb)))tr  )N)[__name__
__module____qualname__r   r  r    r   r*  r#  r2  r	   r  r   r   r  r  r   r  r  r   rt  r  r  r   r  r   r  r   r  r  r   r  r  r  r  r   r  r   r  r   r  r  r  r   r  r  r   r.  r2  floatr   r   r=  r
   r9  rA  r   rM  rL  r   rW  r[  rU  r]  rn  ro  r   r   r  r  r   r   r   r   r  r   r  r  r  r  r  r  r  r  r  r  r  r  r  r%  __classcell__)r  s   @r  r2   r2      s
       s# s s s s s sj *, Z+ Z+V Z+ Z+ Z+ Z+x	V 	 	 	 	Ff F F F FP -/ T T: T T T Tl 6:" =4 =47 =4 =4 =4 =4 =4~ 68 &1 &1 &1F &1 &1 &1 &1P+ +6 +V + + + +Z ?CQUdhqs <J <J <J <J3 <J^a <Jx|  ~B  yC <J <J <J <J|
 
 
4 
 
 
 
* @DB -H -HS -H -HS\ -H -H -H -H^ <@  7  7  7|  7  7  7  7D <> C Cs C+ C C C C(
 
f 
 
 
 
 
@ >BPTcgpr -M -Ms -M# -M]` -M -M -M -M^
 
v 
 
 
 
< 9=4^bkm 6@ 6@# 6@S 6@X[ 6@ 6@ 6@ 6@p
 
6 
 
 
 
< =A 6F 6F' 6FP] 6F 6F 6F 6Fp! ! !$|J\ ! ! ! !F <@d[] .= .= .=S .= .=bfglbm .= .= .= .=` 37TX\eg 5? 5?C 5?s 5?RU 5? 5? 5? 5?n6 6 65 6 6 6 6p *, 4+ 4+ 4+ 4+ 4+ 4+l%) %) %) %) %)N +- 1 1g 1 1 1 16
 
 
 ac )3 )33 )3 )3C )3TW )3gt )3 )3 )3 )3V 154VZce 1B 1B# 1BS 1BPS 1B 1B 1B 1Bf
 
 
 
 
 
8: : : =? : : :> : : : ::
 
h 
R` 
 
 
 
 04$UYbd 0E 0E 0EC 0Es 0Eimnyiz 0E 0E 0E 0Ed 37TX\eg 2E 2EC 2Es 2ERU 2Elpq|l} 2E 2E 2E 2Eh EIW[jnwy O O OQT Odg O  C  DO  P O O O OX
 X
x X
; X
 X
 X
 X
t: : :
: 
: 
: QU]_ 66 663 66 66 66# 66do 66 66 66 66p 8<B B; B;W B;4PX> B; B; B; B;H- -v - - - -^ mqy{ \' \' \'I \'Y \'X] \'fi \'  AF \' \' \' \'| FH  '  '$|*<  'DQVK  '  '  '  'D UYac 5, 5,3 5,c 5, 5, 5, 5, 5,n XZ j jc j j j j j( 8<B )& )&C )& )&5 )& )& )& )&V 59tZ^gi = =c = =TW =nrsxny = = = =. 9=R "' "'S "'# "' "' "' "'H 59 5 5c 5 5 5 58 AER !/ !/tCy !/# !/ !/ !/ !/FV V V5 V V V Vp: : : 3 3 33 3 3 &eBSW P P P P<	 	 	 	 	 	 	r  r2   )7 ccxt.async_support.base.exchanger   ccxt.abstract.oxfunr   r  r  ccxt.base.typesr   r   r   r   r	   r
   r   r   r   r   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(   r)   r*   r+   r,   r-   r.   r/   ccxt.base.decimal_to_precisionr0   r2    r  r  <module>r2     s   6 5 5 5 5 5 + + + + + +   k  k  k  k  k  k  k  k  k  k  k  k  k  k  k  k  k  k  k  k  k  k  k  k  k  k  k  k  k  k  k  k  k  k  k  k  k  k  k  k  k  k  k  k  k  k  k  k  k  k  k  k  k  k  k  k  k  k       * * * * * * 0 0 0 0 0 0 . . . . . . . . . . . . ' ' ' ' ' ' & & & & & & ) ) ) ) ) ) . . . . . . ) ) ) ) ) ) * * * * * * ) ) ) ) ) ) , , , , , , ) ) ) ) ) ) . . . . . . + + + + + + 4 4 4 4 4 4O, O, O, O, O,Hk O, O, O, O, O,r  