
    ei                       d dl mZ d dlm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#m/Z/ d dl#m0Z0 d dl#m1Z1 d dl#m2Z2 d dl3m4Z4  G d dee          Z5d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    H/var/www/html/volatility/venv/lib/python3.11/site-packages/ccxt/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                    |                      |          |                     |          g\  }}|                     |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
        data)publicGetV3MarketspublicGetV3Tickers	safe_listarray_concatparse_markets)r  paramsresponseFromMarketsresponseFromTickersmarketsFromMarketsmarketsFromTickersmarketss          r  fetch_marketszoxfun.fetch_markets  s     594K4KF4S4SUYUlUlmsUtUt3u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   rH  rI  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  r4  r  partsrB  rC  r?  r@  r>  r:  rD  rA  isFutureisSpots                 r  r0  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                     |                      |          }|                     |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
        r  r   assetr7  .NrJ  )r   rP   )r  coderT  r:  r  rE  rP   r   feerU  r   rX  networkListnetwork
canDepositcanWithdrawtransactionPrecision
minDepositminWithdrawal)rP   r   )
r  rh  r;   rP   r   rE  rf  rT  rU  rX  r   rX  )publicGetV3Assetsr  r+  r,  r-  rY  rZ  network_id_to_code	safe_boolr  parse_precisionr]  r/  listkeyssafe_currency_structure)r  r"  responser  r2  r3  currencyfullIdr_  r  re  chainsjchain	networkIdnetworkCodeinfosallKeyss                     r  fetch_currencieszoxfun.fetch_currenciesC  s    ))&11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                     |                                   |                     |          }|                     |          }|                     |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>`
        r  )load_marketsmarket_symbolsr  r  parse_tickers)r  r  r"  ru  tickerss        r  fetch_tickerszoxfun.fetch_tickers  sj     	%%g..**622` ..6266!!'7333r  r>  c                 B   |                                   |                     |          }d|d         i}|                     |                     ||                    }|                     |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>`
        r*  r  r  r   )r  r4  r  extendr  	safe_dictparse_ticker)r  r>  r"  r4  requestru  r  tickers           r  fetch_tickerzoxfun.fetch_ticker  s     	V$$&,
 **4;;w+G+GHH* ~~h33a,,  000r  r4  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  rX  )r^  r-  safe_marketsafe_tickeriso8601)r  r  r4  r  r5  r>  r  s          r  r  zoxfun.parse_ticker@  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                    |                                   |                     |          }|                     | j        ||          }|d         |d}|||d<   |||d<   |                     |d          }|||d<   |                     |d          }n||                     |d          |d<   |                     |                     ||                    }	| 	                    |	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
        r  )r*  r  N	startTimer   untilendTime $r  )r  r4  r-  r  r^  omitsumpublicGetV3Candlesr  r  parse_ohlcvs)r  r>  r  r  r   r"  r4  r  r  ru  r2  s              r  fetch_ohlcvzoxfun.fetch_ohlcvm  s%    	V$$$$T_iKK	 ,"
 
 #(GK $GG!!&'22!&GIYYvw//FF!%%1H!I!IGI**4;;w+G+GHH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  ohlcvr4  s      r  parse_ohlcvzoxfun.parse_ohlcv  s     eZ00UF++UF++UE**UG,,U$455
 	
r  c                 \   |                                   |                     |          }d|d         i}|||d<   |                     |                     ||                    }|                     |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
        r*  r  Nlevelr  r  r>  )r  r4  publicGetV3Depthr  r  r^  parse_order_book)	r  r>  r   r"  r4  r  ru  r  r  s	            r  fetch_order_bookzoxfun.fetch_order_book  s     	V$$&,
 $GG((Wf)E)EFF2 ~~h33%%dO<<	$$T6(+;YGGGr  c                     |                                   |                     |          }|                     |          }|                     |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>`
        r  )r  r  publicGetV3FundingEstimatesr  parse_funding_ratesr  r  r"  ru  r  s        r  fetch_funding_rateszoxfun.fetch_funding_rates  si     	%%g..33F;;& ~~h33''g666r  c                 X   |                                   d|                     |          i}|                     |                     ||                    }|                     |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>`
        r*  r  r   )r  	market_idr  r  r  r  parse_funding_rater4  )r  r>  r"  r  ru  r  firsts          r  fetch_funding_ratezoxfun.fetch_funding_rate  s     	$..00
 33DKK4P4PQQ~~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*  	fundingAtrX  r>  r  
indexPriceinterestRater   estimatedSettlePricer  r  fundingRateestFundingRatefundingTimestampfundingDatetimenextFundingRatenextFundingTimestampnextFundingDatetimepreviousFundingRatepreviousFundingTimestamppreviousFundingDatetimeinterval)r-  r4  r^  r  r  r]  )r  r  r4  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                    |                                   |                     |          }d|d         i}|||d<   |||d<   |                     |d          }|||d<   |                     |d          }|                     |                     ||                    }|                     |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>`
        r*  r  Nr  r   r  r  r  )r  r4  r^  r  publicGetV3FundingRatesr  r  parse_funding_rate_histories
r  r>  r  r   r"  r4  r  r  ru  r  s
             r  fetch_funding_rate_historyz oxfun.fetch_funding_rate_historyE  s     	V$$&,
 #(GK $GG!!&'22!&GIYYvw//F//GV0L0LMM$ ~~h3300vueLLLr  c                     |                      |d          }|                     ||          }|d         }|                     |d          }|||                     |d          ||                     |          dS )Nr*  r>  	createdAtr  )rX  r>  r  r  r  )r-  r  r^  r]  r  )r  rX  r4  r5  r>  r  s         r  parse_funding_rate_historyz oxfun.parse_funding_rate_historyt  s    $ ##D,77!!(F33!%%dK88	++D-@@"Y//
 
 	
r  c                    |                                   |                     |          }d|d         i}|||d<   |||d<   |                     |d          }|||d<   |                     |d          }|                     |                     ||                    }|                     |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>`
        r*  r  Nr  r   r  r  r  )r  r4  r^  r  privateGetV3Fundingr  r  parse_incomes)
r  r>  r  r   r"  r4  r  r  ru  r2  s
             r  fetch_funding_historyzoxfun.fetch_funding_history  s     	V$$&,
 #(GK $GG!!&'22!&GIYYvw//F++DKK,H,HII6 &"55!!&&%???r  c           	      p   |                      |d          }|                     ||          }|                     |d          }|                     d          }|                      |d          }|                     |d          }|                     |d          }	|||||                     |          |||	dS )Nr*  paymentr;  r  r  r  )rX  r>  re  r  r  r  rH  rate)r-  safe_symbolr]  rZ  safe_timestampr  )
r  incomer4  r5  r>  rH  re  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                     |                                   |                     |          }|                     |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
        r  r*  )r  publicGetV3LeverageTiersr  parse_leverage_tiersr  s        r  fetch_leverage_tierszoxfun.fetch_leverage_tiers  sY     	0088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   tierrA  positionFloorpositionCapmaintenanceMarginr   )r  r>  rv  minNotionalmaxNotionalmaintenanceMarginRatemaxLeveragerX  )r-  r  r  r+  r,  r/  r]  r  )r  rX  r4  r5  listOfTiersr   ry  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                    |                                   |                     |          }d|d         i}|||d<   |||d<   |                     |d          }|||d<   |                     |d          }n||                     |d          |d<   |                     |                     ||                    }|                     |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>`
        r*  r  Nr  r   r  r  r  r  )	r  r4  r^  r  r  publicGetV3ExchangeTradesr  r  parse_tradesr  s
             r  fetch_tradeszoxfun.fetch_tradesC  s    	V$$&,
 #(GK $GG!!&'22!&GIYYvw//FF!%%1H!I!IGI11$++gv2N2NOO" ~~h33  vue<<<r  c                    |                                   i }d}| |                     |          }|d         |d<   |||d<   |||d<   |                     |d          }|||d<   |                     |d          }n||                     |d          |d<   |                     |                     ||                    }|                     |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  r4  r^  r  r  privateGetV3Tradesr  r  r  )
r  r>  r  r   r"  r  r4  r  ru  r2  s
             r  fetch_my_tradeszoxfun.fetch_my_tradess  s    	[[((F$*4LGL!#(GK $GG!!&'22!&GIYYvw//FF!%%1H!I!IGI**4;;w+G+GHH. &"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>  	matchedAtrf  feeAssetrM  rv  matchIdorderIdside	matchTypeorderMatchType
matchPricematchQuantitymatchedQuantity)r  r  r  r>  r:  orderr
  takerOrMakerrI  rH  rM  rf  rX  )	r-  r  r^  rZ  
safe_trader  r[  safe_string_lower_2safe_string_2)r  trader4  r5  r>  r  rf  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                 |   |                                   |                     |          }|                     |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>`
        r  r   subAccNr  )r  privateGetV3Balancesr  r-  r+  r,  parse_balance)	r  r"  ru  r  balancer  r3  br  s	            r  fetch_balancezoxfun.fetch_balance  s     	,,V44< ~~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 )
NrX  balancesr   rc  total	availablefreereservedused)r  r+  r,  r-  rZ  accountsafe_balance)	r  r  r2  r  r3  balanceEntry
currencyIdre  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                     |                                   |                     |          }|                     |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
        r  )r  privateGetV3AccountNamesr  parse_accounts)r  r"  ru  r  s       r  fetch_accountszoxfun.fetch_accounts?  sV     	0088 ~~h33""4000r  c                 8    |                      |d          d d |dS )N	accountId)r  r:  re  rX  r-  )r  r%  s     r  parse_accountzoxfun.parse_accountZ  s/     ""7K88	
 
 	
r  re  rH  fromAccount	toAccountc                 B   |                                   |                     |          }|d         |                     ||          ||d}|                     |                     ||                    }|                     |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>`
        r  )rc  quantityr1  r2  r  )r  rv  currency_to_precisionprivatePostV3Transferr  r  parse_transfer)
r  re  rH  r1  r2  r"  rv  r  ru  r  s
             r  r   zoxfun.transferh  s     	==&&d^224@@&"	
 
 --dkk'6.J.JKK$ ~~h33""4222r  c                    |                                   i }d}| |                     |          }|d         |d<   |||d<   |||d<   |                     |d          }|||d<   |                     |d          }n||                     |d          |d<   |                     |                     ||                    }|                     |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  rc  r  r   r  r  r  r  )	r  rv  r^  r  r  privateGetV3Transferr  r  parse_transfers)
r  re  r  r   r"  r  rv  r  ru  r  s
             r  fetch_transferszoxfun.fetch_transfers  s    	!}}T**H'~GG#(GK $GG!!&'22!&GIYYvw//FF!%%1H!I!IGI,,T[[&-I-IJJ$ ~~h33##D(E5AAAr  rv  c                    |                      |d          }|                     |d          }|                     |d          ||                     |          |                     ||          |                     |d          |                     |d          |                     |d          |                     |                     |d                    |d	S )	NtransferredAtrc  r  r4  r1  r2  status)	r  r  r  rv  rH  r1  r2  r>  rX  )r^  r-  r  rZ  r]  parse_transfer_status)r  r   rv  r  r(  s        r  r7  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okr/  r  r>  statusess      r  r?  zoxfun.parse_transfer_status  (    
 &&999r  c                    |                      |d          }|                     ||          }|t          | j        dz             |                                  |                     |          }|d         |d}|                     |d          }|                     |                     ||                    }| 	                    |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>`
        rh  Nz0 fetchDepositAddress() require network parameterr  )rc  rh  r  )r-  network_code_to_idr%   r  r  rv  r  privateGetV3DepositAddressesr  r  parse_deposit_address)	r  re  r"  r|  r{  rv  r  ru  r  s	            r  fetch_deposit_addresszoxfun.fetch_deposit_address  s     &&vy99++K>>	TW'YYZZZ==&&d^ 
 
 69--44T[[&5Q5QRR ~~h33))$999r  c                 t    |                      |d          }|                     |           ||d         d |d dS )Naddressre  )rX  rv  rh  rM  tag)r-  check_address)r  depositAddressrv  rM  s       r  rJ  zoxfun.parse_deposit_address  sP     "">9==7###" (
 
 	
r  c                    |                                   i }d}| |                     |          }|d         |d<   |||d<   |||d<   |                     |d          }|||d<   |                     |d          }|                     |                     ||                    }|                     |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  rc  r  r   r  r  r  r   rP   r:  )
r  rv  r^  r  privateGetV3Depositr  r  r+  r,  parse_transactionsr  re  r  r   r"  r  rv  r  ru  r  r3  s              r  fetch_depositszoxfun.fetch_deposits  s    	!}}T**H'~GG#(GK $GG!!&'22!&GIYYvw//F++DKK,H,HII$ ~~h33q#d))$$ 	( 	(A'DGFOO&&tXueDDDr  c                    |                                   i }d}| |                     |          }|d         |d<   |||d<   |||d<   |                     |d          }|||d<   |                     |d          }|                     |                     ||                    }|                     |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  rc  r  r   r  r  r  r   
withdrawalr:  )
r  rv  r^  r  privateGetV3Withdrawalr  r  r+  r,  rS  rT  s              r  fetch_withdrawalszoxfun.fetch_withdrawalsE  s    	!}}T**H'~GG#(GK $GG!!&'22!&GIYYvw//F..t{{7F/K/KLL( ~~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  re  )r+  r,  r  parse_transactionr/  sort_byfilter_by_currency_since_limit)
r  transactionsrv  r  r   r"  r2  r3  transactionre  s
             r  rS  zoxfun.parse_transactionsy  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   rM  r>  rW  txIdrc  rh  
creditedAtrequestedAtr4  rf  r  rX  txidr  r  	addressToaddressFromrN  tagTotagFromrH  rv  updated)internalcommentrf  )	r-  r  parse_deposit_statusparse_withdrawal_statusrZ  ro  safe_integer_2r]  r  )r  r_  rv  r  r:  rM  re  r>  rd  r(  re  rh  r|  r  rH  feeCostrf  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 rA  r/  rD  s      r  rl  zoxfun.parse_deposit_status  rF  r  c                 D    dddddddd}|                      |||          S )NrC  pendingcanceledfailed)rB  
PROCESSINGzIN SWEEPINGPENDINGzON HOLDCANCELEDFAILEDr/  rD  s      r  rm  zoxfun.parse_withdrawal_status  s=    #$  "
 
 &&999r  rM  rN  c                     |                      ||          \  }}|                                  |                     |          }|                     ||          }|d         ||d}|||d<   d}	|                     |          \  }	}|	|                     |	          |d<   d|d<   |                     |                     ||                    }
|                     |
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>`
        r  )rc  rM  r4  Nmemorh  FexternalFeer  rW  r:  )
handle_withdraw_tag_and_paramsr  rv  r5  handle_network_code_and_paramsrH  privatePostV3Withdrawalr  r  r[  )r  re  rH  rM  rN  r"  rv  stringAmountr  r|  ru  r  s               r  r   zoxfun.withdraw  s   & 99#vFFV==&&11$??d^$
 

 ?!GFO"AA&IIV"!%!8!8!E!EGI!&//GV0L0LMM" ~~h33#V%%dH555r  c                    |                                   |                     |          }|                     |          }|                     |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>`
        r  r   	positions)r  r  privateGetV3Positionsr  r+  r,  r   parse_positions)	r  r  r"  ru  r  allPositionsr3  r%  r  s	            r  fetch_positionszoxfun.fetch_positions'  s     	%%g..--f55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*  rX  r  r>  notionalr   crossliquidationPriceestLiquidationPrice
entryPriceunrealizedPnlpositionPnlrealizedPnlr   	contractspositionrO  r  	lastPricer
  r   r  r  )r  lastUpdateTimestampr  maintenanceMarginPercentage
collateralinitialMargininitialMarginPercentager   marginRatior   r   )r-  r  safe_positionr]  r^  )r  r  r4  r5  s       r  parse_positionzoxfun.parse_positionk  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
  rI  c                 2   |                                   |                     |dd          |                     |d|                                           d}|                     |ddg          }|                     |d          }|||d<   |                     |d          }|                     ||||||          }	|	g|d<   |                     |          }
|                     |
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>`
        responseTypeFULLr  )r  r  
recvWindowNordersr  r   )
r  r-  r^  millisecondsr  create_order_requestprivatePostV3OrdersPlacer  r  parse_order)r  r>  r:  r
  rH  rI  r"  r  r  orderRequestru  r  r  s                r  create_orderzoxfun.create_order  s(   2 	 ,,V^VLL**6;@Q@Q@S@STT
 
 6NK#@AA&&v|<<
!$.GL!YYv|44F00tVUTZ[[)N0099j ~~h33tQ++&&&r  r  c           	         |                                   g }t          dt          |                    D ]}||         }|                     |d          }|                     |d          }|                     |d          }|                     |d          }	|                     |d          }
|                     |di           }|                     ||||	|
|          }|                    |           d|                                 |d	}| 	                    | 
                    ||                    }|                     |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>`
        r   r>  r:  r
  rH  rI  r"  r  )r  r  r  r  )r  r+  r,  r-  r]  r  r  r/  r  r  r  r  parse_orders)r  r  r"  ordersRequestsr3  rawOrderr>  r:  r
  rH  rI  orderParamsr  r  ru  r  s                   r  create_orderszoxfun.create_orders8	  sd    	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!!,////"**,,$
 

 00Wf1M1MNN~~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
  sourcerM  rH  Nr4  r   	stopPriceMARKETSTOP_MARKETLIMIT
STOP_LIMIT	orderType
limitPricerI  Fr   MAKER_ONLY_REPRICE
MAKER_ONLYrI   r   selfTradePreventionMode)r4  upperr  r  handle_post_onlysafe_string_upperhandle_option_and_paramsr  )r  r>  r:  r
  rH  rI  r"  r4  r  rM  r   r  postOnlyisMarketOrderr   r   s                   r  r  zoxfun.create_order_requestZ	  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  rM  c                     |                                   |                     |          }|d         st          | j        dz             d|i}|                     |dddd|                     ||                    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>`
        r:   z9 createMarketBuyOrderWithCost() supports spot orders onlyrM  r4  buyN)r  r4  r+   r  r  r  )r  r>  rM  r"  r4  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
   5$dkkRY[aFbFbcccr  r  c                     |                                   d|i}|                     |                     ||                    }|                     |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>`
        r	  r  )r  privateGetV3OrdersStatusr  r  r  )r  r  r>  r"  r  ru  r  s          r  fetch_orderzoxfun.fetch_order	  sp     	r
 00Wf1M1MNN0 ~~h33%%%r  c                    |                                   i }d}||                     |          }|                     |                     ||                    }|                     |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  r4  privateGetV3OrdersWorkingr  r  r  )	r  r>  r  r   r"  r  r4  ru  r  s	            r  fetch_open_orderszoxfun.fetch_open_orders	  s     	[[((F11$++gv2N2NOO~~h33  vue<<<r  c                    |t          | j        dz             |                     |          }|d         }|                                 dd}||d}|                     |d          }|||d<   |g|d<   |                     |                     ||                    }	|                     |	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  r4  r  r^  privateDeleteV3OrdersCancelr  r  r  r  )r  r  r>  r"  r4  r5  r  r  r  ru  r  r  s               r  cancel_orderzoxfun.cancel_order	  s     >#DG.Y$YZZZV$$$<**,,"
 

 #
 
 ))&/BB$,9L))N33DKK4P4PQQ~~h33tQ++&&&r  c                     i }| |                      |          }|d         |d<   |                     |                     ||                    }|                     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*  rX  )r4  privateDeleteV3OrdersCancelAllr  
safe_order)r  r>  r"  r  r4  ru  s         r  cancel_all_orderszoxfun.cancel_all_orders
  sk     [[((F$*4LGL! 66t{{7F7S7STT 23344r  idsc                    |t          | j        dz             |                                  |                     |          }|d         }|                                 dd}g }t          dt          |                    D ]"}|||         d}	|                    |	           #||d<   |                     | 	                    ||                    }
| 
                    |
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  r4  r  r+  r,  r/  r  r  r  r  )r  r  r>  r"  r4  r5  r  r  r3  r  ru  r  s               r  cancel_orderszoxfun.cancel_orders'
  s    >#DG.Z$Z[[[V$$$<**,,"
 
 q#c((## 	! 	!A&q6 E MM%    "33DKK4P4PQQ~~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   )rv  rM  r>  re  rejectedr  r  r	  r  r  r  lastTradeTimestamplastMatchedAtr  lastModifiedAtr>  r:  r  r   r
  rI  )rI  r  r  r  rH  totalQuantityr4  filledcumulativeMatchedQuantityr  	remainingremainQuantityr   )r   rM  tradesrf  rX  )r-  r  r^  rZ  r]  r  r  parse_order_statusparse_order_typeparse_order_time_in_forcer[  safe_string_nr  	omit_zero)
r  r  r4  r5  r  rf  feeCurrencyr>  re  r   s
             r  r  zoxfun.parse_orderJ
  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  closedrs  r  )OPENPARTIALLY_FILLEDPARTIAL_FILLFILLEDrw  CANCELED_BY_USERCANCELED_BY_MAKER_ONLYCANCELED_BY_FOKCANCELED_ALL_BY_IOCCANCELED_PARTIAL_BY_IOC!CANCELED_BY_SELF_TRADE_PROTECTIONr/  rD  s      r  r  zoxfun.parse_order_status
  sI     &"" *&0)#-'11;
 
 &&999r  c                 >    ddddd}|                      |||          S )Nr   r4  )r  r  r  r  r/  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  r/  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   r9  r7  r  r   ?r   rd  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  rY  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   re   r  r  )r-  r  throw_broadly_matched_exceptionr  throw_exactly_matched_exceptionr!   )r  re  reasonr  r  r  r  ru  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!  r0  r	   r  r   r   r  r	  r   r  r  r   rr  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,  r0  floatr   r   r;  r
   r7  r?  r   rK  rJ  r   rU  rY  rS  r[  rl  rm  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Z T T T Tl 04B =4 =4W =47 =4 =4 =4 =4~ 02 &1 &13 &1f &1 &1 &1 &1P+ +6 +V + + + +Z 9=4^bkm <J <J# <J# <JS <JX[ <Jrvw{r| <J <J <J <J|
 
 
4 
 
 
 
* :>b -H -Hs -H3 -HY -H -H -H -H^ 6:"  7  77  7  7  7  7  7D 68 C C CK C C C C(
 
f 
 
 
 
 
@ 8<$]ajl -M -M -MC -MWZ -M -M -M -M^
 
v 
 
 
 
< 37TX\eg 6@ 6@C 6@s 6@RU 6@ 6@ 6@ 6@p
 
6 
 
 
 
< 7;2 6F 6FG 6F- 6F 6F 6F 6Fp! ! !$|J\ ! ! ! !F 6:UW .= .=3 .=s .=# .=\`af\g .= .= .= .=` -1tRV_a 5? 5?c 5? 5?C 5? 5? 5? 5?n6 6 65 6 6 6 6p $& 4+ 4+( 4+ 4+ 4+ 4+l%) %) %) %) %)N %' 1 14= 1 1 1 16
 
 
 [] )3 )3S )3% )3c )3c )3an )3 )3 )3 )3V +/TPT]_ 1B 1BC 1Bs 1B# 1B 1B 1B 1Bf
 
 
 
 
 
8: : : 79 : :# :^ : : : ::
 
h 
R` 
 
 
 
 *.Dt\^ 0E 0E3 0Ec 0E 0Ecghsct 0E 0E 0E 0Ed -1tRV_a 2E 2Ec 2E 2EC 2Efjkvfw 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: : :
: 
: 
: KOWY 66 66S 66% 66# 66C 66^i 66 66 66 66p 26b B; B;w B;T(^ B; B; B; B;H- -v - - - -^ gksu \' \'3 \'i \'y \'RW \'`c \'z \' \' \' \'| @B  '  'D$6  'd5k  '  '  '  'D UYac 5, 5,3 5,c 5, 5, 5, 5, 5,n RT d d d5 d d d d( 26b )& )&c )&3 )&U )& )& )& )&V /3TXac = = =3 =c =hlmrhs = = = =. 37r "' "'s "'C "' "' "' "'H /32 5 5 5 5 5 58 ;?r !/ !/c !/C !/ !/ !/ !/FV V V5 V V V Vp: : : 3 3 33 3 3 &eBSW P P P P<	 	 	 	 	 	 	r  r2   )6ccxt.base.exchanger   ccxt.abstract.oxfunr   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>r0     s   ( ' ' ' ' ' + + + + + +  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  