
    eit                       d dl mZ d dlmZ d dl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"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 d dl6m7Z7  G d dee          Z8dS )    )Exchange)ImplicitAPIN)AnyBalances
CurrenciesCurrencyDepositAddressIntLeverageLeverageTier
MarginModeMarginModificationMarketNumOrder	OrderBookOrderRequest	OrderSide	OrderTypePositionStrStringsTickerTickersFundingRateFundingRatesTradeTradingFeeInterfaceTransactionTransferEntry)List)ExchangeError)AuthenticationError)PermissionDenied)AccountSuspended)ArgumentsRequired)
BadRequest)	BadSymbol)InsufficientFunds)InvalidOrder)OrderNotFound)NotSupported)OperationFailed)DDoSProtection)	TICK_SIZE)Precisec                       e Zd Zdef fdZi fdefdZi fdefdZde	e
         fdZd Zd Zdede
fd	Zi fde	e
         fd
Zdddi fdedededede	e         f
dZdde
defdZddi fdededede	e         fdZddede
defdZdi fdededefdZi fdedefdZdi fdedefdZdde
defdZdddi fde dedefdZ!dde
fdZ"dddi fde dedefdZ#dde
fdZ$i fdefdZ%dde
fd Z&i f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+di fdede)fd$Z,dd%ede
de'fd&Z-i fde.fd'Z/de.fd(Z0ddi fdededede	e1         fd)Z2di fdede	e1         fd*Z3i fdefd+Z4dd,ede
fd-Z5i fded.e6d/e7fd0Z8i fded/e7fd1Z9i fded/e7fd2Z:di fded3e;d.e6d4e7d5e<f
d6Z=di fded3e;d.e6d4e7d5e<f
d7Z>i fd8e	e?         fd9Z@d: ZAd3e fd;ZBdd<ede
deCfd=ZDd>e fd?ZEdi fd@ede fdAZFdi fde fdBZGdi fdCe	e         de fdDZHi fdEefdFZIdi fd@ede fdGZJdddi fde dedede	eC         fdHZKdddi fde dedede	eC         fdIZLdddi fde dedede	eC         fdJZMdddi fde dedefdKZNdddi fde dedefdLZOi fdMed4e7dNedOedePf
dPZQdddi fdMe dedede	eP         fdQZRddRedSeSdePfdTZTd>e defdUZUi fdMede	eV         fdVZWi fdMedeVfdWZXddSeSdeVfdXZYdddi fdMe dedede	eZ         fdYZ[dddi fdMe dedede	eZ         fdZZ\dd[edSeSdeZfd\Z]d>efd]Z^di fd^ede fd_Z_i fded4e7de`fd`Zai fded4e7de`fdaZbi fded4e7de`fdbZcddcede
de`fddZdi fdedeefdeZfddfede
deefdgZgdi fdfehde fdhZidddi fde dedefdiZjddSeSfdjZkdi fdkefdlZldi fdMed4e7dmedne deZf
doZmdp Zndddi fde dedefdqZodde
fdrZpdi fded.e6deCfdsZqi fde	e1         fdtZrdi fde fduZsdi fdvetde fdwZuddi fd@eded3e;d.e6d4e<d5e<deCfdxZvi fdedewfdyZxdd^edewfdzZyi fdedezfd{Z{dd|ede
dezfd}Z|d~ Z}i fdede	e~         fdZdde
de	e~         fdZddi ddfdZd Zdetf fdZdehdededededefdZ xZS )bingxreturnc                 v
   |                      t          t          |                                           i ddddddg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d'dd(dd)dd*dd+dd,dd-dd.dd/dd0dd1di d2dd3dd4dd5dd6dd7dd8dd9dd:dd;dd<dd=dd>dd?d@dAddBddCdi dDddEddFddGddHddIddJddKddLddMddNddOddPddQddRddSddTdi dUddVddWddXddYddZdd[dd\dd]dd^dd_dd`ddaddbddcdddddeddddddddddddddfdgdhdidjdkdkdkdkdkdkdkdkdkdkdkdldmdmdmdmdmdmdmdmdmdmdmdldndodpdqdrdds|                     dt          |                     dt          dudv|                     dw          |                     dx          dudydzddd{d|d
d}dsd~diiiidsdddddddddidddddddddd	dddddddddd	ddddsddddiid}dddddddididdsddddddidddddddddddddddddddddddddddsddddddddddddidddddddddddddddddddddddddd	dddddddsddiidsddiiddd
dsdddddddiddddddddddd
ddddddddddddid
d}dsddddiiid
d}ddddddddddddddiid
d}dddddddddddiid}dddddddidid
d}ddiddddiiddd}ddiddiddidiid
d}dddddddddd	ddddddiid}dddddddidid
dddiidsddiididd
d}dsdddddddddiiiddddddddddddddddddt
          di 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          t          t           t          t          d՜i d֜dddddddݜdddddddddddddddddddddddddddd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ddiddddddddddddd ddddddd dddddddd d dddddddid	ddd d dd d	dd}did d dd
ddddd dd ddddiddiddd dddiddidddd          S (  Nidr2   nameBingX	countriesUS	rateLimitd   versionv1	certifiedTprohasCORSspotmarginFswapfutureoption	addMarginborrowCrossMarginborrowIsolatedMarginborrowMargincancelAllOrderscancelAllOrdersAftercancelOrdercancelOrderscloseAllPositionsclosePositioncreateMarketBuyOrderWithCostcreateMarketOrderWithCostcreateMarketSellOrderWithCostcreateOrdercreateOrders$createOrderWithTakeProfitAndStopLosscreateReduceOnlyOrdercreateStopLossOrdercreateStopOrdercreateTakeProfitOrdercreateTrailingAmountOrdercreateTrailingPercentOrdercreateTriggerOrder	editOrderfetchAllGreeksfetchBalancefetchBorrowInterestfetchBorrowRatefetchBorrowRateHistoriesfetchBorrowRateHistoryfetchBorrowRatesfetchBorrowRatesPerSymbolfetchCanceledOrdersfetchClosedOrdersfetchCrossBorrowRatefetchCrossBorrowRatesfetchCurrenciesfetchDepositAddressfetchDepositAddressesfetchDepositAddressesByNetworkfetchDepositsfetchDepositWithdrawFeeemulatedfetchDepositWithdrawFeesfetchFundingHistoryfetchFundingRatefetchFundingRateHistoryfetchFundingRatesfetchGreeksfetchIsolatedBorrowRatefetchIsolatedBorrowRatesfetchLeveragefetchLiquidationsfetchMarginAdjustmentHistoryfetchMarginModefetchMarketLeverageTiersfetchMarketsfetchMarkOHLCVfetchMarkPricefetchMarkPricesfetchMyLiquidationsfetchMyTrades
fetchOHLCVfetchOpenInterestfetchOpenOrdersfetchOptionfetchOptionChain
fetchOrderfetchOrderBookfetchOrdersfetchPositionfetchPositionHistoryfetchPositionModefetchPositionsfetchPositionsHistoryfetchTickerfetchTickers	fetchTimefetchTradesfetchTradingFee)fetchTransfersfetchVolatilityHistoryfetchWithdrawalsreduceMarginrepayCrossMarginrepayIsolatedMarginsandboxsetLeverage	setMarginsetMarginModesetPositionModetransferhostnamez	bingx.comurlszwhttps://github-production-user-asset-6210df.s3.amazonaws.com/1294454/253675376-6983b72e-4999-4549-b177-33b374c195e3.jpgz#https://open-api.{hostname}/openApi)fundrB   rD   contractwalletsuser
subAccountaccountcopyTradingcswapapiz'https://open-api-vst.{hostname}/openApizhttps://bingx.com/z!https://bingx-api.github.io/docs/zhttps://bingx.com/invite/OHETOM)logor   testwwwdocreferralfeesgetz0.001)feeSidemakertakerquotez0.0002z0.0005)	tierBasedrB   rD   requiredCredentials)apiKeysecretr   privateaccount/balance   )server/timezcommon/symbolszmarket/tradesmarket/depthmarket/klinezticker/24hrticker/pricezticker/bookTicker      )	ztrade/querytrade/openOrdersztrade/historyOrdersztrade/myTradesuser/commissionRater   zoco/orderListzoco/openOrderListzoco/historyOrderList)	trade/orderztrade/canceltrade/batchOrdersztrade/order/cancelReplaceztrade/cancelOrdersztrade/cancelOpenOrderstrade/cancelAllAfterz	oco/orderz
oco/cancel)r   post)publicr   r   )r   r   r   )zget/asset/transferasset/transfercapital/deposit/hisreccapital/withdraw/historyzpost/asset/transfer)r=   v2v3)r   zmarket/historicalTradeszmarket/markPriceKlinesztrade/multiAssetsRulestradingRules)positionSide/dualtrade/batchCancelReplaceztrade/fullOrdermaintMarginRatioztrade/positionHistoryzpositionMargin/historyztwap/openOrdersztwap/historyOrdersztwap/orderDetailtrade/assetModezuser/marginAssets)ztrade/amendztrade/cancelReplacer   r   ztrade/closePositiontrade/getVstz
twap/orderztwap/cancelOrderr   ztrade/reverseztrade/autoAddMargin)r   zquote/contractszquote/pricezquote/depthzquote/tradeszquote/premiumIndexzquote/fundingRatequote/klineszquote/openInterestzquote/tickerquote/bookTicker)user/balanceuser/positionszuser/incomer   ztrade/openOrderr   trade/marginTypetrade/leveragetrade/forceOrdersztrade/allOrderstrade/allFillOrdersztrade/fillHistoryzuser/income/exportr   r   )	r   r   r   trade/closeAllPositionsr   r   r   trade/positionMarginztrade/order/test)r   r   trade/allOpenOrders)r   r   deleter   r   )zmarket/contractszmarket/premiumIndexzmarket/openInterestzmarket/klinesr   zmarket/ticker)
r   r   r   r   ztrade/orderDetailztrade/orderHistoryr   r   r   r   )r   r   r   r   r   r   )r   ztrade/cancelOrder)allPosition	allOrdersbalance)zcapital/config/getallzcapital/deposit/addresszcapital/innerTransfer/recordsz"capital/subAccount/deposit/addresszcapital/deposit/subHisrecz(capital/subAccount/innerTransfer/recordszcapital/deposit/riskRecords)zcapital/withdraw/applyzcapital/innerTransfer/applyz%capital/subAccountInnerTransfer/applyz capital/deposit/createSubAddress
   )listassetsallAccountBalance)createzapiKey/createzapiKey/editz
apiKey/delupdateStatus)uidzapiKey/queryaccount/apiPermissionsr   z!innerTransfer/authorizeSubAccountz subAccount/asset/transferHistory)z%subAccount/transferAsset/supportCoinszsubAccount/transferAsset)r=   r   authuserDataStream)r   putr   )	zswap/trace/currentTrackzPFutures/traderDetailzPFutures/profitHistorySummaryszPFutures/profitDetailzPFutures/tradingPairszspot/traderDetailzspot/profitHistorySummaryszspot/profitDetailzspot/historyOrder)zswap/trace/closeTrackOrderzswap/trace/setTPSLzPFutures/setCommissionzspot/trader/sellOrder)r   zasset/transferRecordr   r   r   r   ztransfer/supportCoins)r   r   )r   asset)zaccount/inviteAccountListzreward/commissionDataListzaccount/inviteRelationCheckzasset/depositDetailListzreward/third/commissionDataListzasset/partnerDatazcommissionDataList/referralCodezaccount/superiorCheck)r   rB   rD   r   r   r   r   r   r   r   r   agent
timeframes1m3m5m15m30m1h2h4h6h12h1d3d1w1M)r   r   r   r   r   r   r   r   r   r   r   r   r  r  precisionMode
exceptions400401403404429418500504100001100412100202100204100400100410100421100440100500)1005038000180012800148001680017100414100419100437101204110425zInsufficient assetszillegal transferType)exactbroadcommonCurrenciesSnowmanOmniCatz$NAP	TRUMPMAGATRUMP)SNOWOMNINAPr'  TRUMPSOLr   
stdFutures	USDTMPerp	coinMPerp)fundingrB   rE   rD   linearinverser/  r0  r1  )r   rB   r,  r-  r.  i  CCXTETHERC20BTCLTC)r3  USDTUSDCr5  r6  ARBPOLYGON	ZKSYNCERAzAVAX-CHEDERA)ARBITRUMMATICZKSYNCAVAXCHBAR)defaultTypeaccountsByTypeaccountsById
recvWindowbrokerdefaultNetworksnetworks)lastmarkindex)triggerPriceTypeprice)IOCFOKPOGTD)
marginModetriggerPricerL  triggerDirectionstopLossPricetakeProfitPriceattachedStopLossTakeProfittimeInForcehedgedtrailingleveragemarketBuyRequiresPricemarketBuyByCostselfTradePreventionicebergmaxi      )rR  limitdaysBack	untilDayssymbolRequired)rR  triggerrZ  re  )rR  rb  rf  rZ  re    i N     )rR  rb  rc  rd  rf  rZ  re  )rR  rb  rc  daysBackCanceledrd  rf  rZ  re  rb    )	r   rT   rU   r   r   r   r   rh   r   defaultForLinear)rb  rc  rd  )extendsr   r   )rL  rW  rZ  )rb  rd  )rl  rk   rT   r   r   rh   rl  defaultForInverse)r0  r1  )rl  r   defaultForFuture)rk  rm  rB   rD   rn  rE   g     @@)optionsfeaturesrollingWindowSize)deep_extendsuperr2   describeparse_numberr/   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/bingx.pyrt  zbingx.describe    sZ   eT 2 2 ; ; = = |@
'|@
G|@
 $|@
 	|@

 t|@
 |@
 4|@
  bbb %b 	b
 %b %b Tb $Ub 'b b "4b 'b tb b $Tb   !b" /#b b$ ,T%b& 0'b( t)b* +b, 7-b. (/b0 &t1b2 "43b4 (5b6 ,T7b8 -d9b: %d;b< T=b> !%?b@ AbB &uCbD "5Eb b bF +EGbH )%IbJ #EKbL ,UMbN &tObP $TQbR 'SbT (UbV "4WbX &tYbZ ([b\ 1$]b^  _b` *:abb +Dcbd &tebf #Dgb b bh *4ibj $Tkbl umbn *5obp +Eqbr  sbt $Uubv /wbx "4ybz +D{b| }b~ !$b@ !$AbB "4CbD &tEbF  GbH dIb b bJ $TKbL "4MbN uObP #EQbR dSbT !$UbV tWbX  YbZ '[b\ $T]b^ !$_b` (abb tcbd ebf Tgbh tibj "4kb bl #'*/$( $$)',#!!%#' Cb b b|@
V W|@
X  RAAA EDA"GD#HB@  FEE IHE"KH#LFD  ,:== Y|@
X !$!..w77!..w77   '!..x88!..x88  Y|@
r "$ $s|@
z !! 11$$ "/023120101/00156	$ 	$# 014578237834125689
$ 
$ 010156=>67:;89-../
% 
%$ $% %N !!010101$ $# "6723:;<=	$ $ !6q%
$ 
$a= =B "01;<:;:;01$ $# 67<=34459::;3467453456$ $ 017856<=7801./45341278% %$ $& &R "/034/0/001675601670145$ $#" 1223/04534/0452356347856677845$ $$ 12/056;<8945238945
% 
% 015678' ';"$ "$!3 3l " .$# " .$$ yh hT !457878120112$ $	# 34567845566745782301$ $ 012378;<4589% % 8956' '+$ $% %'R !!/0-.+,$ $$
 !9:;<ABFG=>LM?@$ $ ;<?@IJDE	% %$ $, !(**+56$ $ +-12/0./02% %$ $( "'(01:;56	$ $ !DQ%
$ 
$ %$F(" NO@A)" )"	( (
! : ! 0!% !1!$ !1!'
$ 
$  !;<9:BC9:9:56>?5656
$ 
$ ?@67:;9;	% %$ $ 2 "2389:;<=	$ $ !6q%
$ 
$  &$.)"( !&$;Q("'  < !!=>=>?@;<CD56CD9:	$ 	$$Uz z{|@
p  q|@
P YQ|@
R :. + :	
 > + = = 1 1 / j j o i  m!" o#$ ,'.'**..(/*+<,6=  @ C" "S|@
X !!$#! !Y|@
h  &%"*')*# # &""*!)!*! ! '  ##  $ $ !&&)%$ 5! !H  $&+(,$($(%)- -
 -2)-+/ )-(,)-1 1
 &*7 7 $(#'"&#(	( ( #'$($)27+//4#(? $  $D q% ',!$$&%'*.& & ',#($)*.	# # ',!%#($)*/( ( ',!%$)%&#($)*.$ $ ',!%$(,0%&#($)*.	* 	*  #[P% P%d  2!%$(%)& &
 $(& &  2!4( -16:$)$ $ "&$%%&& &
 $(!$%)* *! . "#5 "#6 	   2#'% % "#5 "#5 	 {E EL "(w|@
 |@
 |@
 | | |	    c                    K   |                      |           d{V }|                     |d          }|                     |d          S )ac  
        fetches the current integer timestamp in milliseconds from the bingx server

        https://bingx-api.github.io/docs/#/swapV2/base-info.html#Get%20Server%20Time

        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns int: the current integer timestamp in milliseconds from the bingx server
        Ndata
serverTime)swapV2PublicGetServerTime	safe_dictsafe_integer)rv  paramsresponser{  s       rx  
fetch_timezbingx.fetch_time  sX       77???????? ~~h//  |444ry  c                 2  K   |                      d          si S |                     | j        dd          }|ri S |                     |           d{V }|                     |dg           }i }t          dt          |                    D ]!}||         }|                     |d          }|                     |          }	|                     |d          }
|                     |d          }i }t          dt          |                    D ]}||         }|                     |d	          }| 	                    |          }| 
                    |d
          | 
                    |d          d| 
                    |d          ddd}|                     |                     |                     |d                              }|||| 
                    |d          d|                     |d          |                     |d          ||d	||<   |	|vr||	|d|
ddd|dddd||	<   ||	         }|                     |di           }t          |                                          }t          dt          |                    D ]}||         }||vr||         ||<   |||	         d<   #t          |                                          }t          dt          |                    D ]*}||         }	||	         }|                     |          ||	<   +|S )az  
        fetches all available currencies on an exchange

        https://bingx-api.github.io/docs-v3/#/en/Account%20and%20Wallet/Wallet%20Deposits%20and%20Withdrawals/Query%20currency%20deposit%20and%20withdrawal%20data

        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: an associative dictionary of currencies
        FsandboxModeNr{  r   coinr6   networkListnetworkwithdrawMinwithdrawMaxminr`  
depositMin)withdrawdepositwithdrawPrecisionwithdrawFeedepositEnablewithdrawEnable)	infor5   r  feeactiver  r  	precisionlimitscrypto)r  coder5   r  r6   r  r  r  rH  r  r  typerH  )check_required_credentials	safe_boolro  &walletsV1PrivateGetCapitalConfigGetall	safe_listrangelensafe_stringsafe_currency_codenetwork_id_to_codesafe_numberru  parse_precisionr~  r   keyssafe_currency_structure)rv  r  	isSandboxr  r{  resultientry
currencyIdr  r6   r  rH  j
rawNetworkr  networkCoder  r  existingexistingNetworksnewNetworkCodesnewNetworkCodecodescurrencys                            rx  fetch_currencieszbingx.fetch_currencies5  s      ..u55 	INN4<FF	 	IDDVLLLLLLLLN ~~h33q#d))$$ 8	< 8	<AGE))%88J**:66D##E622D..>>KH1c+..//  (^
**:yAA"55g>>  $//
MJJ#//
MJJ! !
  $//
LII#   	  	  !--d.B.B4CSCST^`sCtCt.u.uvv	&!*++JFF"#~~j/JJ $z;K L L!*$
) 
)%% FNN! $!% "# $ ("$   t "$<#'>>(J#K#K "&x}}"7"7q#o"6"677 T TA%4Q%7N*.>>>;CN;S(8+;tZ((V[[]]##q#e**%% 	B 	BA8Dd|H77AAF4LLry  c                    K   |                      |           d {V }|                     |d          }|                     |dg           }|                     |          S )Nr{  symbols)spotV1PublicGetCommonSymbolsr~  r  parse_markets)rv  r  r  r{  marketss        rx  fetch_spot_marketszbingx.fetch_spot_markets  si      ::6BBBBBBBB8 ~~h//..y"55!!'***ry  c                    K   |                      |           d {V }|                     |dg           }|                     |          S Nr{  )swapV2PublicGetQuoteContractsr  r  rv  r  r  r  s       rx  fetch_swap_marketszbingx.fetch_swap_markets  sW      ;;FCCCCCCCC@ ..6266!!'***ry  c                    K   |                      |           d {V }|                     |dg           }|                     |          S r  )cswapV1PublicGetMarketContractsr  r  r  s       rx  fetch_inverse_swap_marketsz bingx.fetch_inverse_swap_markets  sV      ==fEEEEEEEE& ..6266!!'***ry  marketc                    |                      |d          }|                    d          }|d         }|d         }|                     |          }|                     |          }|                      |d          }d}	d}
|                     |d          }||}d}	d}
|                     |          }|                     |d	          }|<|                     |                     |                      |d
                              }|                     |d          }|<|                     |                     |                      |d                              }|dnd}|dk    }|dk    }|dz   |z   }||d|z   z  }|                     | j        |i           }|r|                     d          nd }d}|                      |d          dk    r|                      |d          dk    rd}nH|                     |d          r2|                     |d          r|                      |d          dk    rd}|rd n|	}|rd n|
}d }|s| 	                    |dd          }| 
                    |d          }|dk    r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-|                     |g d.          |                     |d/          d-d0||d1          S )2Nsymbol-r   r   r  FTminTickSizetickSizepricePrecisionstepSizequantityPrecisionrD   rB   /:1apiStateOpentrueapiStateCloseapiStateSellapiStateBuystatusminQtytradeMinQuantity
timeOnliner5   baser   settlebaseIdquoteIdsettleIdr  rC   rE   rF   r  r   r0  r   r   r   )amountrM  r  )minNotionaltradeMinUSDTminTradeValuemaxNotional)r[  r  rM  cost)r1  r   r   r   contractSizeexpiryexpiryDatetimestrike
optionTyper  r  createdr  )r  splitr  r  ru  r  r~  r   r  safe_number_2r  safe_market_structuresafe_number_n)rv  r  r5   symbolPartsr  r  r  r   r  checkIsInversecheckIsLinearr  r  r  r  r  rB   rD   r  r   r  isActive	isInverseisLinear	minAmountr  s                             rx  parse_marketzbingx.parse_market  s   fh//hhsmmQa.&&v..''00##FJ77&&v}=="H!N!M((22))&*==!!..t/C/CDDTDTU[]mDnDn/o/oppN ,,VZ@@$ $ 1 1$2F2FtGWGWX^`sGtGt2u2u v v ,vv6v~v~e#cFl"F~~dir2226At((---TV^44>>TEUEUV\^mEnEnrxExExHH^^FN33 	v}8]8] 	cgcscstz  }E  dF  dF  JM  dM  dMH!6DD	 444}	 	Q**68=OPPI&&v|<<
??J)) 3+
"3+
f3+
 D3+
 U	3+

 f3+
 f3+
 w3+
 3+
 D3+
 D3+
 e3+
 D3+
 e3+
 e3+
 h3+
  !3+
" h#3+
$ !%%dG44%%dG44''i88("+'    
 % 
 ' 
  --f6f6f6fgg++FMBB  $ "e3+
 3+
 3+
 3 3 3	ry  c                   K   |                      |          g}|                     | j        dd          }|sP|                    |                     |                     |                    |                     |                     t          j        |  d{V }|                     |dg           }|                     |dg           }|                     |dg           }| 	                    ||          }| 	                    ||          S )a   
        retrieves data on all markets for bingx

        https://bingx-api.github.io/docs-v3/#/en/Spot/Market%20Data/Spot%20trading%20symbols
        https://bingx-api.github.io/docs-v3/#/en/Swap/Market%20Data/USDT-M%20Perp%20Futures%20symbols
        https://bingx-api.github.io/docs-v3/#/en/Coin-M%20Futures/Market%20Data/Contract%20Information

        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict[]: an array of objects representing market data
        r  FNr   r   r   )
r  r  ro  appendr  r  asynciogatherr  array_concat)	rv  r  requestsr  promiseslinearSwapMarketsinverseSwapMarketsspotMarketsswapMarketss	            rx  fetch_marketszbingx.fetch_marketsi  s	      ++F334NN4<FF	 	=OOD;;FCCDDDOOD33F;;<<< 2222222 NN8Q;;!^^Ha<<nnXq"55''(9;MNN  k:::ry  r   Nr  	timeframesincerb  c           	      t  K   |                                   d{V  d}|                     |ddd          \  }}|r!|                     d|||||d           d{V S |                     |          }d|d         i}|                     | j        ||          |d<   |t          |d	z
  d
          |d<   |||d<   |                     |dd          }	|	|                     |dg          }|	|d<   d}
|d         r0| 	                    | 
                    ||                     d{V }
n|d         r0|                     | 
                    ||                     d{V }
n|                     |d          }|                     |d          }|dk    r0|                     | 
                    ||                     d{V }
n/|                     | 
                    ||                     d{V }
|                     |
dg           }t          |t                     s|g}|                     |||||          S )a'  
        fetches historical candlestick data containing the open, high, low, and close price, and the volume of a market

        https://bingx-api.github.io/docs-v3/#/en/Spot/Market%20Data/Kline%2FCandlestick%20Data
        https://bingx-api.github.io/docs-v3/#/en/Swap/Market%20Data/Kline%2FCandlestick%20Data
        https://bingx-api.github.io/docs-v3/#/en/Swap/Market%20Data/Mark%20Price%20Kline%2FCandlestick%20Data
        https://bingx-api.github.io/docs-v3/#/en/Coin-M%20Futures/Market%20Data/Get%20K-line%20Data

        :param str symbol: unified symbol of the market to fetch OHLCV data for
        :param str timeframe: the length of time each candle represents
        :param int [since]: timestamp in ms of the earliest candle to fetch
        :param int [limit]: the maximum amount of candles to fetch
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :param int [params.until]: timestamp in ms of the latest candle to fetch
        :param boolean [params.paginate]: default False, when True will automatically paginate by calling self endpoint multiple times. See in the docs all the [available parameters](https://github.com/ccxt/ccxt/wiki/Manual#pagination-params)
        :returns int[][]: A list of candles ordered, open, high, low, close, volume
        NFr   paginaterj  r  r5   intervalr   r   	startTimerb  untilendTimerB   r1  rM  rJ  r{  )load_marketshandle_option_and_params"fetch_paginated_call_deterministicr  r  r   r`  safe_integer_2omitspotV1PublicGetMarketKlineextendcswapV1PublicGetMarketKlines$swapV1PublicGetMarketMarkPriceKlinesswapV3PublicGetQuoteKlines
safe_value
isinstancer   parse_ohlcvs)rv  r  r  r  rb  r  r  r  requestr	  r  rM  ohlcvss                rx  fetch_ohlcvzbingx.fetch_ohlcv  s     $ !!!!!!!!!88z[`aa& 	~@@vW\^cenpvx|}}}}}}}}}V$$fTl
 #..t	9UU
#&uqy!#4#4GK $GG##FGY??YYvy11F!&GI&> 	c!<<T[[RX=Y=YZZZZZZZZHHi  c!%!B!B4;;wX^C_C_!`!```````((996733F??%)%N%Nt{{[bdjOkOk%l%lllllllHH%)%D%DT[[QXZ`EaEa%b%bbbbbbbHH 6266&$'' 	XF  E5IIIry  c           	      .   t          |t                    r|                     |d          |                     |d          |                     |d          |                     |d          |                     |d          |                     |d          gS |                     |dd          |                     |d	          |                     |d
          |                     |d          |                     |d          |                     |d          gS )Nr   r   r         r   time	closeTimeopenhighlowclosevolume)r  r   r  r  r  )rv  ohlcvr  s      rx  parse_ohlcvzbingx.parse_ohlcv  s   D eT"" 	!!%++  **  **  **  **  **  v{;;UF++UF++UE**UG,,UH--
 	
ry  c                   K   |                                   d{V  |                     |          }d|d         i}|t          |d          |d<   d}d}|                     d||          \  }}|dk    r0|                     |                     ||                     d{V }n/|                     |                     ||                     d{V }|                     |dg           }	|                     |	|||          S )	a  
        get the list of most recent trades for a particular symbol

        https://bingx-api.github.io/docs-v3/#/en/Spot/Market%20Data/Recent%20Trades%20List
        https://bingx-api.github.io/docs-v3/#/en/Swap/Market%20Data/Recent%20Trades%20List

        :param str symbol: unified symbol of the market to fetch trades for
        :param int [since]: timestamp in ms of the earliest trade to fetch
        :param int [limit]: the maximum amount of trades to fetch
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict[]: a list of `trade structures <https://docs.ccxt.com/?id=public-trades>`
        Nr  r5   r;   rb  r   rB   r{  )	r  r  r  handle_market_type_and_paramsspotV1PublicGetMarketTradesr  swapV2PublicGetQuoteTradesr  parse_trades)
rv  r  r  rb  r  r  r  r  
marketTypetradess
             rx  fetch_tradeszbingx.fetch_trades  s5      !!!!!!!!!V$$fTl
 "5#GG
!??vW]^^
F!==dkk'SY>Z>Z[[[[[[[[HH!<<T[[RX=Y=YZZZZZZZZHD &"55  >>>ry  tradec                 J   |                      |g d          }|                     |d          }||                     |          }|dk    rd }|                     |d          }|                     |g d          }|                     |          }|                     |d          }|                     |dd          }	|                     |g d	          }
d }|
||
s|rd
nd}|                     |dd          }||
|
|
s|rdnd}d}|                     |d          }||rdnd}|                     |d          }||rd
nd}|                     |g d          }|S|d         rKd|v rG|                     |d         d          }|                     |d          }t          j
        ||          }|                     |                     |ddg          |||                     |          |                     |	|d          |                     |dd          |                     |d          |                     |          ||                     |g d          |||                     t          j        |                     |dd                              |d d!|          S )"N)r  filledTmT	tradeTimer1  r   quoteQty)r  NcommissionAssetmsr  )
buyerMakerisBuyerMakerr   r   r   sideSsellbuyisBuyerisMaker)qtyr  qrD   r$  r  r  r5   tr  orderIdr  o)rM  p
tradePrice
commissionn)r  r  )r5   r  	timestampdatetimer  orderr  r;  takerOrMakerrM  r  r  r  )safe_integer_nr  	parse8601safe_string_nr  r  safe_string_2safe_bool_nsafe_string_lower_2r0   
string_mul
safe_tradeiso8601safe_symbolsafe_string_lowerparse_order_sideru  
string_abs)rv  r/  r  r  
datetimeIdr  r  currencyCoder7  marketIdr:  takeOrMakerr;  r?  r@  r  r  r$  s                     rx  parse_tradezbingx.parse_tradeL  s	   X ""5*P*P*PQQ%%eZ88
!>>*--D199Dz22''/S/S/STT
..z::NN5#&&%%eS(;;''/V/V/VWW$!-&2EaE''gK''vs;;<(am".?!?vv%%..	22#/55D..	22%,9'''K##E+A+A+ABBF6NE8I8I++F6N<NOOL%%eX66F'==F$$UT3K88T**&&x==''y#>>**5#66))$//'''/K/K/KLL))'*<T=O=OPUWceh=i=i*j*jkk(  
  
" #  	ry  c           	        K   |                                   d{V  |                     |          }d|d         i}|||d<   d}d}|                     d||          \  }}|dk    r0|                     |                     ||                     d{V }ng|d         r0|                     |                     ||                     d{V }n/|                     |                     ||                     d{V }|                     |di           }|                     |d	          }	| 	                    |d
d          }
| 
                    ||d         |
dddd          }|	|d<   |S )a  
        fetches information on open orders with bid(buy) and ask(sell) prices, volumes and other data

        https://bingx-api.github.io/docs-v3/#/en/Spot/Market%20Data/Order%20Book
        https://bingx-api.github.io/docs-v3/#/en/Swap/Market%20Data/Order%20Book
        https://bingx-api.github.io/docs-v3/#/en/Coin-M%20Futures/Market%20Data/Query%20Depth%20Data

        :param str symbol: unified symbol of the market to fetch the order book for
        :param int [limit]: the maximum amount of order book entries to return
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: A dictionary of `order book structures <https://docs.ccxt.com/?id=order-book-structure>` indexed by market symbols
        Nr  r5   rb  r   rB   r1  r{  lastUpdateIdr2  tsbidsasksr   r   nonce)r  r  r(  spotV1PublicGetMarketDepthr  cswapV1PublicGetMarketDepthswapV2PublicGetQuoteDepthr~  r  r  parse_order_book)rv  r  rb  r  r  r  r  r,  	orderbookre  rJ  r  s               rx  fetch_order_bookzbingx.fetch_order_book  s      !!!!!!!!!V$$fTl
 $GG
!??@PRXZ`aa
F!<<T[[RX=Y=YZZZZZZZZHHi  ^!%!A!A$++gW]B^B^!_!_______!%!?!?GU[@\@\!]!]]]]]]]V NN8VR88	!!)^<<''	3==	&&y&2BIvW]_`bcddwry  c                   K   |                                   d{V  |                     |          }d|d         i}d}|d         r0|                     |                     ||                     d{V }n/|                     |                     ||                     d{V }|                     |d          }|                     ||          S )a  
        fetch the current funding rate

        https://bingx-api.github.io/docs-v3/#/en/Swap/Market%20Data/Mark%20Price%20and%20Funding%20Rate
        https://bingx-api.github.io/docs-v3/#/en/Coin-M%20Futures/Market%20Data/Price%20%26%20Current%20Funding%20Rate

        :param str symbol: unified market symbol
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: a `funding rate structure <https://docs.ccxt.com/?id=funding-rate-structure>`
        Nr  r5   r1  r{  )r  r  "cswapV1PublicGetMarketPremiumIndexr   swapV2PublicGetQuotePremiumIndexr~  parse_funding_raterv  r  r  r  r  r  r{  s          rx  fetch_funding_ratezbingx.fetch_funding_rate[  s       !!!!!!!!!V$$fTl
 ) 	a!DDT[[QXZ`EaEabbbbbbbbHH!BB4;;wX^C_C_````````H" ~~h//&&tV444ry  r  c                   K   |                                   d{V  |                     |dddd          }|                     |          }d}|                     d|||          \  }}d}|dk    r/|                     |                     |                     d{V }n.|                     |                     |                     d{V }|                     |dg           }|                     ||          S )ax  
        fetch the current funding rate for multiple symbols

        https://bingx-api.github.io/docs-v3/#/en/Swap/Market%20Data/Mark%20Price%20and%20Funding%20Rate
        https://bingx-api.github.io/docs-v3/#/en/Coin-M%20Futures/Market%20Data/Price%20%26%20Current%20Funding%20Rate

        :param str[] [symbols]: list of unified market symbols
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :param str [params.subType]: "linear" or "inverse"(default is linear)
        :returns dict[]: a list of `funding rate structures <https://docs.ccxt.com/?id=funding-rate-structure>`
        NrD   Tr0  rv   r1  r{  )	r  market_symbolsget_market_from_symbolshandle_sub_type_and_paramsrm  r  rn  r  parse_funding_rates)rv  r  r  firstMarketsubTyper  r{  s          rx  fetch_funding_rateszbingx.fetch_funding_rates  s      !!!!!!!!!%%gvtT4HH227;;99:M{\bdklli!DDT[[QWEXEXYYYYYYYYHH!BB4;;vCVCVWWWWWWWWH~~h33''g666ry  c                    |                      |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S )Nr  nextFundingTimer  r  rD   	markPrice
indexPriceinterestRateestimatedSettlePricerJ  rK  fundingRatelastFundingRatefundingTimestampfundingDatetimenextFundingRatenextFundingTimestampnextFundingDatetimepreviousFundingRatepreviousFundingTimestamppreviousFundingDatetimer  )r  r  rW  r  rV  )rv  r   r  r]  r  s        rx  ro  zbingx.parse_funding_rate  sf    ##Hh77#00;LMM
H
d&&xfEE
 ))(K@@
 $**8\BB	

 D
 #D
 
 
 4++H6GHH
 
 t
 t
 #$8
 "4<<0D#E#E
 "4
  '!
" &t#
$ %
 
 	
ry  c                 h  K   |t          | j        dz             |                                  d{V  d}|                     |dd          \  }}|r |                     d|||d|           d{V S |                     |          }d|d         i}|||d	<   |||d
<   |                     |dd	          }||                     |dg          }||d	<   |                     | 	                    ||                     d{V }	| 
                    |	dg           }
|                     |
|||          S )a  
        fetches historical funding rate prices

        https://bingx-api.github.io/docs-v3/#/en/Swap/Market%20Data/Get%20Funding%20Rate%20History

        :param str symbol: unified symbol of the market to fetch the funding rate history for
        :param int [since]: timestamp in ms of the earliest funding rate to fetch
        :param int [limit]: the maximum amount of `funding rate structures <https://docs.ccxt.com/?id=funding-rate-history-structure>` to fetch
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :param int [params.until]: timestamp in ms of the latest funding rate to fetch
        :param boolean [params.paginate]: default False, when True will automatically paginate by calling self endpoint multiple times. See in the docs all the [availble parameters](https://github.com/ccxt/ccxt/wiki/Manual#pagination-params)
        :returns dict[]: a list of `funding rate structures <https://docs.ccxt.com/?id=funding-rate-history-structure>`
        Nz5 fetchFundingRateHistory() requires a symbol argumentFru   r  8hr  r5   r  rb  r	  r{  )r&   r5   r  r  r  r  r  r  swapV2PublicGetQuoteFundingRater  r  parse_funding_rate_histories)rv  r  r  rb  r  r  r  r  r	  r  r{  s              rx  fetch_funding_rate_historyz bingx.fetch_funding_rate_history  s      >#DG.e$efff!!!!!!!!!88AZ\fgg& 	@@@AZ\bdikprvx~V$$fTl
 #(GK $GG##FG[AAYYvy11F#(GK ==dkk'SY>Z>Z[[[[[[[[ ~~h3300vueLLLry  c                     |                      |d          }||                     |                     |d          |dd          |                     |d          ||                     |          dS )NfundingTimer  r  rD   r  )r  r  r  rJ  rK  )r  rW  r  r  rV  )rv  r   r  rJ  s       rx  parse_funding_rate_historyz bingx.parse_funding_rate_history  sy     %%h>>	&&t'7'7('K'KVUXZ`aa++HmDD"Y//
 
 	
ry  c                 H  K   |                                   d{V  d}|                     |dd          \  }}|r |                     d|||d|           d{V S ddi}d}| |                     |          }|d         |d	<   |||d
<   |||d<   |                     |dd          }||                     |dg          }||d<   |                     |                     ||                     d{V }	|                     |	dg           }
| 	                    |
|||          S )a  
        fetches historical funding received

        https://bingx-api.github.io/docs-v3/#/en/Swap/Account%20Endpoints/Get%20Account%20Profit%20and%20Loss%20Fund%20Flow

        :param str symbol: unified symbol of the market to fetch the funding history for
        :param int [since]: timestamp in ms of the earliest funding to fetch
        :param int [limit]: the maximum amount of `funding history structures <https://docs.ccxt.com/?id=funding-history-structure>` to fetch
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :param int [params.until]: timestamp in ms of the latest funding to fetch
        :returns dict[]: a list of `funding history structures <https://docs.ccxt.com/?id=funding-history-structure>`
        NFrs   r  24h
incomeTypeFUNDING_FEEr5   r  r  rb  r	  r
  r{  )
r  r  r  r  r  r  swapV2PrivateGetUserIncomer  r  parse_incomes)rv  r  r  rb  r  r  r  r  r	  r  r{  s              rx  fetch_funding_historyzbingx.fetch_funding_history  s      !!!!!!!!!88AVXbcc& 	}@@AVX^`eglnsu{|||||||||-
 [[((F &tGH#(GK $GG##FGY??YYvy11F!&GI88Wf9U9UVVVVVVVV" ~~h33!!$u===ry  c           
      d   |                      |d          }|                      |d          }|                     |d          }||                     ||d d          |                     |          ||                     |          |                      |d          |                     |d          ddS )	Nr  r   r  rD   tranIdincomer/  )r  r  r  rJ  rK  r5   r  r  )r  r  rW  r  rV  r  )rv  r  r  r]  r  rJ  s         rx  parse_incomezbingx.parse_income6  s     ##FH55%%fg66
%%ff55	&&xvFF++J77"Y//""6844&&vx88	
 	
 		
ry  c                   K   |                                   d{V  |                     |          }d|d         i}d}|d         r0|                     |                     ||                     d{V }n/|                     |                     ||                     d{V }i }|d         r/|                     |dg           }|                     |di           }n|                     |di           }|                     ||          S )a  
        retrieves the open interest of a trading pair

        https://bingx-api.github.io/docs-v3/#/en/Swap/Market%20Data/Open%20Interest%20Statistics
        https://bingx-api.github.io/docs-v3/#/en/Coin-M%20Futures/Market%20Data/Get%20Swap%20Open%20Positions

        :param str symbol: unified CCXT market symbol
        :param dict [params]: exchange specific parameters
        :returns dict} an open interest structure{@link https://docs.ccxt.com/?id=open-interest-structure:
        Nr  r5   r1  r{  r   )r  r  "cswapV1PublicGetMarketOpenInterestr   swapV2PublicGetQuoteOpenInterestr  r~  parse_open_interest)rv  r  r  r  r  r  r  r{  s           rx  fetch_open_interestzbingx.fetch_open_interestO  s8      !!!!!!!!!V$$fTl
 ) 	a!DDT[[QXZ`EaEabbbbbbbbHH!BB4;;wX^C_C_````````H: ) 	:>>(FB77D^^D!R00FF^^Hfb99F''777ry  c                    |                      |dd          }|                     |d          }|                     ||dd          }|                     |d          }|                     |d d d |||                     |          |d|          S )Nr  rJ  r  r  rD   openInterest)r  
baseVolumequoteVolumeopenInterestAmountopenInterestValuerJ  rK  r  )r  r  rW  r  safe_open_interestrV  )rv  interestr  rJ  r5   r  r  s          rx  r  zbingx.parse_open_interest  s    $ ''&+FF	h11!!"fc6::''.AA&&"&!-"Y//	(
 	(
 	 	 		ry  c                   K   |                                   d{V  |                     |          }d|d         i}d}|d         r0|                     |                     ||                     d{V }ng|d         r0|                     |                     ||                     d{V }n/|                     |                     ||                     d{V }|                     |d          }|-|                     |di           }|                     ||          S |                     |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://bingx-api.github.io/docs-v3/#/en/Spot/Market%20Data/24hr%20Ticker%20Price%20Change%20Statistics
        https://bingx-api.github.io/docs-v3/#/en/Swap/Market%20Data/24hr%20Ticker%20Price%20Change%20Statistics
        https://bingx-api.github.io/docs-v3/#/en/Coin-M%20Futures/Market%20Data/Query%2024-Hour%20Price%20Change

        :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  r5   rB   r1  r{  r   )	r  r  spotV1PublicGetTicker24hrr  cswapV1PublicGetMarketTickerswapV2PublicGetQuoteTickerr  r~  parse_ticker)	rv  r  r  r  r  r  r{  firstdataDicts	            rx  fetch_tickerzbingx.fetch_ticker  s      !!!!!!!!!V$$fTl
 &> 	_!;;DKKQW<X<XYYYYYYYYHHi  _!%!B!B4;;wX^C_C_!`!```````!%!@!@WV\A]A]!^!^^^^^^^: ~~h//NN4B//E$$UF333>>(FB77  6222ry  c                 P  K   |                                   d{V  d}|B|                     |          }|                     |d          }||                     |          }d}|                     d||          \  }}d}|                     d||          \  }}d}|dk    r|                     |           d{V }n=|dk    r|                     |           d{V }n|                     |           d{V }| 	                    |d          }| 
                    ||          S )a"  
        fetches price tickers for multiple markets, statistical information calculated over the past 24 hours for each market

        https://bingx-api.github.io/docs-v3/#/en/Spot/Market%20Data/24hr%20Ticker%20Price%20Change%20Statistics
        https://bingx-api.github.io/docs-v3/#/en/Swap/Market%20Data/24hr%20Ticker%20Price%20Change%20Statistics
        https://bingx-api.github.io/docs-v3/#/en/Coin-M%20Futures/Market%20Data/Query%2024-Hour%20Price%20Change

        :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   r   rB   r1  r{  )r  rs  r  r  r(  ru  r  r  r  r  parse_tickers)	rv  r  r  r  firstSymbolr  rx  r  tickerss	            rx  fetch_tickerszbingx.fetch_tickers  so      !!!!!!!!!))'22G**7A66K&[1199.&RXYYf99.&RXYY6>>!;;FCCCCCCCCHH)##!%!B!B6!J!JJJJJJJ!%!@!@!H!HHHHHHH< ..622!!'7333ry  c                 P  K   |                                   d{V  |                     |          }d}|                     d||d          \  }}d|d         i}d}|dk    r0|                     |                     ||                     d{V }n/|                     |                     ||                     d{V }t          |d         t                    r1|                     | 	                    |d         di           |          S |                     |d         |          S )	a"  
        fetches mark prices for the market

        https://bingx-api.github.io/docs-v3/#/en/Swap/Market%20Data/Mark%20Price%20and%20Funding%20Rate
        https://bingx-api.github.io/docs-v3/#/en/Coin-M%20Futures/Market%20Data/Price%20%26%20Current%20Funding%20Rate

        :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 dictionary of `ticker structures <https://docs.ccxt.com/?id=ticker-structure>`
        Nr   r0  r  r5   r1  r{  r   )
r  r  ru  rm  r  rn  r  r   r  r~  )rv  r  r  r  rx  r  r  s          rx  fetch_mark_pricezbingx.fetch_mark_price$  sQ      !!!!!!!!!V$$99:JFTZ\deefTl
 i!DDT[[QXZ`EaEabbbbbbbbHH$ "BB4;;wX^C_C_````````H hv&-- 	V$$T^^HV4Da%L%LfUUU  &!16:::ry  c                   K   |                                   d{V  d}|B|                     |          }|                     |d          }||                     |          }d}|                     d||d          \  }}d}|dk    r|                     |           d{V }n|                     |           d{V }|                     |d          }|                     ||          S )a`  
        fetches mark prices for multiple markets

        https://bingx-api.github.io/docs-v3/#/en/Swap/Market%20Data/Mark%20Price%20and%20Funding%20Rate
        https://bingx-api.github.io/docs-v3/#/en/Coin-M%20Futures/Market%20Data/Price%20%26%20Current%20Funding%20Rate

        :param str[] [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   r   r0  r1  r{  )	r  rs  r  r  ru  rm  rn  r  r  )rv  r  r  r  r  rx  r  r  s           rx  fetch_mark_priceszbingx.fetch_mark_prices\  s"      !!!!!!!!!))'22G**7A66K&[1199:KVU[]effi!DDVLLLLLLLLHH!BB6JJJJJJJJH< ..622!!'7333ry  tickerc           
      >   |                      |d          }|                      |d          }|dnd}|                     ||d |          }|d         }|                      |d          }|                      |d          }|                      |d          }	|                      |d          }
|                      |d	          }|                      |d
          }|                      |d          }||                    dd          }|                      |d          }|                     |d          }|dk    r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'|          S )(Nr  lastQtyrB   rD   	openPrice	highPricelowPrice	lastPricer  r$  priceChangePercent% priceChanger  r   bidPricebidQtyaskPriceaskQtyrJ  rK  r!  r"  bid	bidVolumeask	askVolumevwapr   r#  rI  previousClosechange
percentageaverager|  r}  )r  r  r|  r}  r  )r  safe_marketreplacer  rV  safe_ticker)rv  r  r  r]  r  r  r  r   r!  r"  r#  r  r  r  r  rb  rK  r  r  r  r  s                        rx  r  zbingx.parse_ticker  s   d ##FH55""6955 "/vv!!(FD$??!4444vz22  55&&v}==%%fh77
%%f.BCC
!#++C44J!!&-88v{3377B<<##vz22$$VX66	vz22$$VX66	 !
f!
!
 !
 D	!

 3!
 3!
 !
 3!
 !
 D!
 D!
 U!
 D!
 T!
 f!
  *!!
" t#!
$ %&))&+>>**6<@@-!
 !
 !
. /  	ry  c                 X  K   |                                   d{V  d}d}|                     |ddd          \  }}d}|                     dd|          \  }}|                     dd|          \  }}|r|                     |           d{V }n|dk    s|dk    r|                     |           d{V }n_|dk    r|                     |           d{V }n=|dk    r|                     |           d{V }n|                     |           d{V }| 	                    |          S )	ak  
        query for balance and get the amount of funds available for trading or funds locked in orders

        https://bingx-api.github.io/docs-v3/#/en/Spot/Account%20Endpoints/Query%20Assets
        https://bingx-api.github.io/docs-v3/#/en/Swap/Account%20Endpoints/Query%20account%20data
        https://bingx-api.github.io/docs-v3/#/en/Coin-M%20Futures/Trades%20Endpoints/Query%20Account%20Assets
        https://bingx-api.github.io/docs-v3/#/en/Account%20and%20Wallet/Fund%20Account/Query%20Assets

        :param dict [params]: extra parameters specific to the exchange API endpoint
        :param boolean [params.standard]: whether to fetch standard contract balances
        :param str [params.type]: the type of balance to fetch(spot, swap, funding) default is `spot`
        :returns dict: a `balance structure <https://docs.ccxt.com/?id=balance-structure>`
        Nr`   standardFr/  r   rB   r1  )
r  r  ru  r(  contractV1PrivateGetBalancefundV1PrivateGetAccountBalancespotV1PrivateGetAccountBalancecswapV1PrivateGetUserBalanceswapV3PrivateGetUserBalanceparse_balance)rv  r  r  r  rx  r,  marketTypeQuerys          rx  fetch_balancezbingx.fetch_balance  s      !!!!!!!!!88Q[]bcc&99.$PVWW&*&H&HY]_e&f&f#
O L	S!==oNNNNNNNNHH& I%%:+?+?!@@QQQQQQQQHH 6!!!@@QQQQQQQQHH$ )##!%!B!B?!S!SSSSSSS* "&!A!A/!R!RRRRRRR( !!(+++ry  c                    d|i}|                      |d          }|                     |d          }|d u}|                     |di           }|                     |ddg           }|rt          dt	          |                    D ]}||         }	|                     |	d          }
|
 n{|                     |
          }|                                 }|                     |	dd          |d	<   |                     |	d
          |d<   |                     |	d          |d<   |||<   nt          dt	          |                    D ]}||         }	|                     |	d          }
|                     |
          }|                                 }|                     |	d	          |d	<   |                     |	d          |d<   |||<   | 	                    |          S )Nr  r{  r   balancesr   r   availableMarginavailableBalancefree
usedMarginusedmaxWithdrawAmounttotallocked)
r  r~  safe_list_2r  r  r  r  r   rQ  safe_balance)rv  r  r  contractBalancesfirstContractBalances
isContractspotDataspotBalancesr  r   r  r  r   s                rx  r  zbingx.parse_balancep	  s   ^ )>>(F;; $/? C C*$6
>>(FB77''*hKK 	'1c"23344 
' 
'*1-!--gw??
%E..z::,,.."&"4"4W>OQc"d"d"&"2"27L"I"I#'#3#3G=P#Q#Q &t1c,//00 ' '&q/!--gw??
..z::,,.."&"2"27F"C"C"&"2"27H"E"E&t  (((ry  c                    K   |                                   d{V  |                     |          }d|d         i}|||d<   |||d<   |                     d||          \  }}d}|d         r0|                     |                     ||                     d{V }nt          | j        dz             |                     |d	i           }|                     |d
g           }	| 	                    |	          }
| 
                    |
|||          S )ab  
        fetches historical positions

        https://bingx-api.github.io/docs-v3/#/en/Swap/Trades%20Endpoints/Query%20Position%20History

        :param str symbol: unified contract symbol
        :param int [since]: the earliest time in ms to fetch positions for
        :param int [limit]: the maximum amount of records to fetch
        :param dict [params]: extra parameters specific to the exchange api endpoint
        :param int [params.until]: the latest time in ms to fetch positions for
        :returns dict[]: a list of `position structures <https://docs.ccxt.com/?id=position-structure>`
        Nr  r5   pageSizestartTsendTsr0  zC fetchPositionHistory() is not supported for inverse swap positionsr{  positionHistory)r  r  handle_until_option$swapV1PrivateGetTradePositionHistoryr  r,   r5   r~  r  parse_positionsfilter_by_symbol_since_limit)rv  r  r  rb  r  r  r  r  r{  records	positionss              rx  fetch_position_historyzbingx.fetch_position_history	  sD      !!!!!!!!!V$$fTl
 "'GJ!&GI227GVLL( 	p!FFt{{SZ\bGcGcddddddddHHtw)nnooo: ~~h33..'8"==((11	00FE5QQQry  c                 v  K   |                                   d{V  |                     |          }d}|                     |ddd          \  }}d}|r|                     |           d{V }nd}|B|                     |          }|                     |d          }||                     |          }d}|                     d||          \  }}|dk    r|                     |           d{V }n|                     |           d{V }| 	                    |dg           }| 
                    ||          S )a  
        fetch all open positions

        https://bingx-api.github.io/docs-v3/#/en/Swap/Account%20Endpoints/Query%20position%20data
        https://bingx-api.github.io/docs/#/en-us/standard/contract-interface.html#position
        https://bingx-api.github.io/docs-v3/#/en/Coin-M%20Futures/Trades%20Endpoints/Query%20warehouse

        :param str[]|None symbols: list of unified market symbols
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :param boolean [params.standard]: whether to fetch standard contract positions
        :returns dict[]: a list of `position structures <https://docs.ccxt.com/?id=position-structure>`
        Nr   r  Fr   r1  r{  )r  rs  r  contractV1PrivateGetAllPositionr  r  ru  cswapV1PrivateGetUserPositionsswapV2PrivateGetUserPositionsr  r  )	rv  r  r  r  r  r  r  rx  r  s	            rx  fetch_positionszbingx.fetch_positions
  s      !!!!!!!!!%%g..88AQS]_dee& (	L!AA&IIIIIIIIHHF"--g66"..w::*![[55FG"==>NPVX^__OGV)##!%!D!DV!L!LLLLLLL8 "&!C!CF!K!KKKKKKK@ NN8VR88	##Iw777ry  c                   K   |                                   d{V  |                     |          }|d         st          | j        dz             d|d         i}d}|d         r0|                     |                     ||                     d{V }n/|                     |                     ||                     d{V }|                     |dg           }|                     |di           }| 	                    ||          S )	a  
        fetch data on a single open contract trade position

        https://bingx-api.github.io/docs-v3/#/en/Swap/Account%20Endpoints/Query%20position%20data
        https://bingx-api.github.io/docs-v3/#/en/Coin-M%20Futures/Trades%20Endpoints/Query%20warehouse

        :param str symbol: unified market symbol of the market the position is held in
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: a `position structure <https://docs.ccxt.com/?id=position-structure>`
        NrD   z+ fetchPosition() supports swap markets onlyr  r5   r1  r{  r   )
r  r  r'   r5   r  r  r   r  r~  parse_position)rv  r  r  r  r  r  r{  r  s           rx  fetch_positionzbingx.fetch_positionv
  s4      !!!!!!!!!V$$f~ 	VTW'TTUUUfTl
 ) 	^!@@WV\A]A]^^^^^^^^HH8 "??GU[@\@\]]]]]]]]H@ ~~h33tQ++""5&111ry  positionc                    |                      |dd          }|                    dd          }|                     |d          }d }||rdn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           d d d |                     |d!          d |                     |d"          d d d d#          S )$Nr  r  r  r  isolatedcrossopenTimer  r5   
positionIdrD   notionalpositionValuerR  liquidationPrice
entryPriceavgPriceunrealizedPnlunrealizedProfitrealizedPnlrealisedProfitr  	contractspositionAmtr  r|  r  r;  positionSiderY  rJ  
updateTimeinitialMarginr[  )rK  lastUpdateTimestampmaintenanceMarginmaintenanceMarginPercentage
collateralr  initialMarginPercentager[  marginRatiorU  rV  )
r  r  r  r  safe_positionrW  r  r  rX  rV  )rv  r  r  r]  r  rR  rJ  s          rx  r  zbingx.parse_position
  s]   f ##Hh;;##C-->>(J77
'/<WJ%%h
;;	!! #
H#
$""8\::#
 d&&xfEE#
 ((?CC	#

 *#
 #
 $,,Xz<PP#
 T--h8JKK#
 4++H6FGG#
 $#
 ))(MBB#
 D#
 ))(K@@#
 #
 D**8^DD#
  d!#
" ##
$ Y//#'#4#4X|#L#L!%+/!--hHH'+((:>>!#9#
 #
 #
   	ry  r;  r  c                 P   K   ||d<   |                      |d||d|           d{V S )a  
        create a market order by providing the symbol, side and cost
        :param str symbol: unified symbol of the market to create an order in
        :param str side: 'buy' or 'sell'
        :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>`
        quoteOrderQtyr  Ncreate_order)rv  r  r;  r  r  s        rx  create_market_order_with_costz#bingx.create_market_order_with_costC  sB       #'&&vxtT6RRRRRRRRRry  c                 P   K   ||d<   |                      |dd|d|           d{V S )a  
        create a market buy order by providing the symbol and cost
        :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!  r  r>  Nr"  rv  r  r  r  s       rx  !create_market_buy_order_with_costz'bingx.create_market_buy_order_with_costO  sB       #'&&vxdFSSSSSSSSSry  c                 P   K   ||d<   |                      |dd|d|           d{V S )a  
        create a market sell order by providing the symbol and cost
        :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!  r  r=  Nr"  r&  s       rx  "create_market_sell_order_with_costz(bingx.create_market_sell_order_with_costZ  sB       #'&&vxtVTTTTTTTTTry  r  r  rM  c           
         |                      |          }d}d}	|                     d||          \  }	}|                                }|d         ||                                d}
|dk    }|	dk    }|dk    }|r|rt          | j        dz             |                     |d	          }|                     |d
          }|                     |dd          }|du}|du}|du}|rdnd}|                     ||d          }|||
|<   |                     |d          }|                     ||dk    |          \  }}|s|dk    rd|
d<   n|dk    rd|
d<   n|dk    rd|
d<   |r|                     |dd          }| 	                    |d          }|-| 
                    |                     ||                    |
d<   n|rV|Tt          j        |                     |          |                     |                    }| 
                    |          |
d<   n,| 
                    |                     ||                    |
d<   |s,| 
                    |                     ||                    |
d<   |b|r-|                     |
d          t#          | j        dz             |                     ||          |
d<   |dk    rd|
d<   n|dk    rd|
d<   n||I||n|}|dk    rd|
d<   n|dk    rd|
d<   | 
                    |                     ||                    |
d<   n||r|
d         |
d          |d!k    rd"nd#| 
                    |                     ||                    | 
                    |                     ||                    d$}|                     ||          S |d%k    rd%|
d<   |                     |d&          }|                     |d'd(          }|                     |d)d*          }|du}|du}|p|} |                     |d+          }!|                     |d,          }"|!du}#|"du}$|dk    s|dk    s|d-k    s|d.k    r.| s,| 
                    |                     ||                    |
d<   |                     |d/d0          }%|rM| 
                    |                     ||                    |
d<   |s|dk    rd|
d<   n|dk    s|dk    rd|
d<   n|s|rd1}%|rL| 
                    |                     ||                    |
d<   |s|d2k    rd2|
d<   n|dk    s|d-k    rd-|
d<   n|rK| 
                    |                     ||                    |
d<   |s|d3k    rd3|
d<   nc|dk    s|d.k    rd.|
d<   nQ| rO||
d<   |r| 
                    |          |
d<   n/|r-t          j        |d4          }&| 
                    |&          |
d(<   |#s|$r?|                     |          }'|#r|                     |!dd|!          }(|                     |!d5d6          })|                     |!dd2          }*| 
                    |                     ||(                    |)|*d7}+|                     |!d          },|,,| 
                    |                     ||,                    |+d<   |                     |!d|'          }-| 
                    |                     ||-                    |+d<   |                     |+          |
d+<   |$r|                     |"dd|"          }.|                     |"d5d6          }/|                     |"dd3          }0| 
                    |                     ||.                    |/|0d7}1|                     |"d          },|,,| 
                    |                     ||,                    |1d<   |                     |"d|'          }2| 
                    |                     ||2                    |1d<   |                     |1          |
d,<   d}3|                     |d8d0          }4|4r.| 	                    |d/          }|%r|d!k    rd#nd"}3n|d!k    rd"nd#}3nd9}3|3|
d:<   |}5|d;         s)| 
                    |                     ||                    }5|5|
d<   | 	                    |g d<          }|                     |
|          S )=aL  
 @ignore
        helper function to build request
        :param str symbol: unified symbol of the market to create an order in
        :param str type: 'market' or 'limit'
        :param str side: 'buy' or 'sell'
        :param float amount: how much you want to trade in units of the base currency
        :param float [price]: the price at which the order is to be fulfilled, in units of the quote currency, ignored in market orders
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: request to be sent to the exchange
        NrT   r5   )r  r  r;  MARKETrB   TWAPz6 createOrder() twap order supports swap contracts onlyrU  rV  	stopPricerS  newClientOrderIdclientOrderIDclientOrderIdrX  PostOnlyrN  GTCr  r!  quantityrM  zl createOrder() requires the cost parameter(or the amount + price) for placing spot market-buy trigger ordersLIMITTRIGGER_LIMITr  TRIGGER_MARKETTAKE_STOP_LIMITTAKE_STOP_MARKETr  r;  r>  LONGSHORT)r  r;  r  rS  totalAmountrO  trailingAmounttrailingPercent	priceRatetrailingTypeTRAILING_STOP_MARKETstopLoss
takeProfitSTOPTAKE_PROFIT
reduceOnlyFTSTOP_MARKETTAKE_PROFIT_MARKET100workingType
MARK_PRICE)r-  rI  r  rY  BOTHr  r1  )
rY  rS  rU  rV  r<  r=  r?  rB  rA  r0  )r  r(  upperr(   r5   r  rQ  safe_string_upperhandle_post_onlyr  parse_to_numericcost_to_precisionr0   rT  number_to_stringamount_to_precisionprice_to_precisionr&   r  r  r  
string_divjson)6rv  r  r  r;  r  rM  r  r  postOnlyr,  r  isMarketOrderisSpotisTwapOrderrU  rV  rS  isTriggerOrderisStopLossPriceOrderisTakeProfitPriceOrderexchangeClientOrderIdr0  rX  r  calculatedCoststopTakePricetwapRequestr<  r=  r?  isTrailingAmountOrderisTrailingPercentOrder
isTrailingrA  rB  hasStopLosshasTakeProfitrE  requestTrailingPercentstringifiedAmountslTriggerPriceslWorkingTypeslType	slRequestslPrice
slQuantitytkTriggerPricetkWorkingTypetpType	tpRequest
tkQuantityr  rY  	amountReqs6                                                         rx  create_order_requestzbingx.create_order_requeste  s
    V$$
!??vW]^^
Fzz||TlJJLL
 

 (v%fn 	`6 	`DG&^^___((AA**63DEE))&+~NN%T1,D8!0!<6< Q 2 2/**63H/ZZ$-:G)*,,V]CC00z@Y[abb& 	+z11%/GM""E!!%*GM""E!!%*GM" K	,%%ffoFFDYYvv..F+/+@+@AWAWX^`dAeAe+f+f((  je&7%,%78M8Mf8U8UW[WlWlmrWsWs%t%tN/3/D/D^/T/TGO,,*.*?*?@X@XY_ag@h@h*i*iGJ'  a#'#8#89P9PQWY^9_9_#`#` '  fT%5%5g%O%O%W+DG  7e  -e  f  f  f'+'>'>v|'T'T$7??&5GFOOX%%&6GFO+1L2?2KRa7??&7GFOOX%%&8GFO'+'<'<T=T=TU[]j=k=k'l'l$ 8%h/#FO/3u}}FF7$($9$9$:Q:QRXZf:g:g$h$h#'#8#89Q9QRXZ`9a9a#b#b% %$ {{;777e##).&!--f6FGGN"009JKXXO++FNDZ[[L$2$$>!%4D%@".H2HJvz::H>>J"$.K&d2Mdo&=&=46>>W[_lWlWl  xBWl#'#8#89P9PQWY^9_9_#`#` eDDJ Y'+'<'<T=T=TU[]i=j=j'k'k$  6T-=%=%=&6GFOOgoo4?+B+B&5GFO% Y)? Y!
' 8+/+@+@AXAXY_anAoAo+p+pGK($ 1)>)>*7'//tv~~*0+ 8+/+@+@AXAXY_apAqAq+r+rGK($ 81E)E)E*>'//t}/D/D*7 Y".( Y'+'<'<^'L'LGG$$+ Y-4-?QV-W-W*+/+@+@AW+X+XGK( Am A$($9$9&$A$A! ?%)%7%7.R]_g%h%hN$($4$4X}l$[$[M!--hNNF%)%:%:4;R;RSY[i;j;j%k%k'4 &' 'I
 #..xAAG*-1-B-B4CZCZ[acjCkCk-l-l	'*!%!1!1(JHY!Z!ZJ,0,A,A$BZBZ[acmBnBn,o,oIj)*.))I*>*>GJ'  A%)%7%7
NT_ak%l%lN$($4$4ZP\$]$]M!--j&BVWWF%)%:%:4;R;RSY[i;j;j%k%k'4 &' 'I
 #..z7CCG*-1-B-B4CZCZ[acjCkCk-l-l	'*!%!1!1*jJ[!\!\J,0,A,A$BZBZ[acmBnBn,o,oIj),0IIi,@,@GL)L^^FHe<<F &6<88 J/3u}}776LL.2emm66'LL%&2GN#I)$ \ 11$2J2J6SY2Z2Z[[	"+GJ6  $B  $B  $B  C  C{{7F+++ry  c                 r  K   |                                   d{V  |                     |          }|                     |dd          }|                     |d          }|                     ||||||          }	d}
|d         r|r|                     |	           d{V }
n}|d         r|                     |	           d{V }
nY|dk    r|                     |	           d{V }
n7|                     |	           d{V }
n| 	                    |	           d{V }
t          |
t                    r*|                     |
          }
|                     |
          }
|                     |
di           }i }|d         r#|d         r|
}n|                     |d|          }n|}|                     ||          S )	a
  
        create a trade order

        https://bingx-api.github.io/docs-v3/#/en/Spot/Trades%20Endpoints/Place%20order
        https://bingx-api.github.io/docs-v3/#/en/Swap/Trades%20Endpoints/Place%20order
        https://bingx-api.github.io/docs-v3/#/en/Swap/Trades%20Endpoints/Place%20TWAP%20Order
        https://bingx-api.github.io/docs-v3/#/en/Coin-M%20Futures/Trades%20Endpoints/Trade%20order

        :param str symbol: unified symbol of the market to create an order in
        :param str type: 'market' or 'limit'
        :param str side: 'buy' or 'sell'
        :param float amount: how much you want to trade in units of the 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 str [params.clientOrderId]: a unique id for the order
        :param bool [params.postOnly]: True to place a post only order
        :param str [params.timeInForce]: spot supports 'PO', 'GTC' and 'IOC', swap supports 'PO', 'GTC', 'IOC' and 'FOK'
        :param bool [params.reduceOnly]: *swap only* True or False whether the order is reduce only
        :param float [params.triggerPrice]: triggerPrice at which the attached take profit / stop loss order will be triggered
        :param float [params.stopLossPrice]: stop loss trigger price
        :param float [params.takeProfitPrice]: take profit trigger price
        :param float [params.cost]: the quote quantity that can be used alternative for the amount
        :param float [params.trailingAmount]: *swap only* the quote amount to trail away from the current market price
        :param float [params.trailingPercent]: *swap only* the percent to trail away from the current market price
        :param dict [params.takeProfit]: *takeProfit object in params* containing the triggerPrice at which the attached take profit order will be triggered
        :param float [params.takeProfit.triggerPrice]: take profit trigger price
        :param dict [params.stopLoss]: *stopLoss object in params* containing the triggerPrice at which the attached stop loss order will be triggered
        :param float [params.stopLoss.triggerPrice]: stop loss trigger price
        :param boolean [params.test]: *swap only* whether to use the test endpoint or not, default is False
        :param str [params.positionSide]: *contracts only* "BOTH" for one way mode, "LONG" for buy side of hedged mode, "SHORT" for sell side of hedged mode
        :param boolean [params.hedged]: *swap only* whether the order is in hedged mode or one way mode
        :returns dict: an `order structure <https://docs.ccxt.com/?id=order-structure>`
        Nr   FrD   r1  twapr{  rL  )r  r  r  r  rt  swapV2PrivatePostTradeOrderTestcswapV1PrivatePostTradeOrderswapV1PrivatePostTwapOrderswapV2PrivatePostTradeOrderspotV1PrivatePostTradeOrderr  strfix_stringified_json_members
parse_jsonr~  parse_order)rv  r  r  r;  r  rM  r  r  r   r  r  r{  r  s                rx  r#  zbingx.create_order!  s     D !!!!!!!!!V$$~~ffe4466**++FD$vVV&> 
	G K!%!E!Eg!N!NNNNNNN	" K!%!B!B7!K!KKKKKKK!%!@!@!I!IIIIIII!%!A!A'!J!JJJJJJJ!==gFFFFFFFFHB h$$ 	1 88BBHx00H~~h33&> 	i  =!gt<<F///ry  ordersc           	        K   |                                   d{V  g }g }t          dt          |                    D ]}||         }|                     |d          }|                     |d          }|                    |           |                     |d          }	|                     |d          }
|                     |d          }|                     |di           }|                     |||	|
||          }|                    |           |                     |dd	d
d
          }t          |          }| 	                    |d                   }i }d}|d         rQ|dk    rt          | j        dz             |                     |          |d<   |                     |           d{V }nQ|                     |dd	          }|rd
|d<   |                     |          |d<   |                     |           d{V }t!          |t"                    r*|                     |          }|                     |          }|                     |di           }|                     |dg           }|                     ||          S )a  
        create a list of trade orders

        https://bingx-api.github.io/docs-v3/#/en/Spot/Trades%20Endpoints/Place%20multiple%20orders
        https://bingx-api.github.io/docs-v3/#/en/Swap/Trades%20Endpoints/Place%20multiple%20orders

        :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 boolean [params.sync]: *spot only* if True, multiple orders are ordered serially and all orders do not require the same symbol/side/type
        :returns dict: an `order structure <https://docs.ccxt.com/?id=order-structure>`
        Nr   r  r  r;  r  rM  r  FTrD   r   zJ createOrders() can not create more than 5 orders at once for swap marketsbatchOrderssyncr{  r  )r  r  r  r  r  r  r~  rt  rs  r  r*   r5   rU  !swapV2PrivatePostTradeBatchOrdersr  !spotV1PrivatePostTradeBatchOrdersr  r|  r}  r~  r  parse_orders)rv  r  r  ordersRequests	marketIdsr  rawOrderr]  r  r;  r  rM  orderParamsorderRequestr  symbolsLengthr  r  r  r  r{  r  s                         rx  create_orderszbingx.create_orders  s      !!!!!!!!!	q#f++&& 
	0 
	0AayH''(;;H##Hf55DX&&&##Hf55D%%h99F$$Xw77E..8R@@K44XtT6SXZeffL!!,////%%iudDIIGWQZ((&> 
	Mq  "47-y#yzzz%)YY~%>%>GM"!CCGLLLLLLLLHH>>&&%88D '"&"ii77GFO!CCGLLLLLLLLH\ h$$ 	1 88BBHx00H~~h33h33  000ry  c                 B    ddddddd}|                      |||          S )Nr>  r=  )BUYSELLr:  r9  r  r  r  )rv  r;  sidess      rx  rY  zbingx.parse_order_side  s:    
 
 tT222ry  c                 B    ddddddd}|                      |||          S )Nr  rb  )trigger_markettrigger_limit
stop_limitstop_markettake_profit_marketstopr  )rv  r  typess      rx  parse_order_typezbingx.parse_order_type  s:    &$!#"*
 
 tT222ry  rL  c                 ~	   |}|                      |dd          }||}|                     |dd          }|dnd}|                     |dd          }||                     |d d |          }|                     |d	d
          }|                     |g d          }	|                     |dd          }
|                     |g d          }|                     |dd          }|                     |g d          }|(|d         r|dk    r	|d         }n|d         }n|d         }|                     |d          }d }|/|dk    r)| 	                    | 
                    |d                    }|st          |t          j                  sY|dk    rSt          |t                    r|                     |          }| 	                    | 
                    |d                    }|                     |d          }d }|/|dk    r)| 	                    | 
                    |d                    }|st          |t          j                  sY|dk    rSt          |t                    r|                     |          }| 	                    | 
                    |d                    }|                     |dd          }| 	                    |                     |dd                    }|}|>|                    d          dk    r||}d }|                    d          dk    r||}d }|                     i d|d |                     |g d!          d"|                     |g d#          d|                     ||d$|          d%|	d&|                     |	          d'|
d(|                     |d          d|                     |          d)| 
                    |d)          d*d d	|                     |          d+|                     |d+d,          d-|d.|d/|d0|                     |d1d2          | 
                    |d3          |                     |g d4          |                     |d5d6          d |                     |          |t1          j        |          d7d |                     |d8d9          d:|          S );NnewOrderResponseorderOpenResponser  psrB   rD   r  r8  r;  r<  )r  transactTimeEcreatedTimer  r2  )r  XorderStatusfeeAssetr5  )r  rH  rI  r>  r  r   rA  r  r-  rB  r  rE  	StopPricer  taker  r5   )rD  r  mainOrderIdr0  )r/  r0  origClientOrderIdcr  rJ  rK  lastTradeTimestampr  rX  rV  rM  rF  rS  rU  rV  r  r  apcummulativeQuoteQty)origQtyrB  r3  r;  executedQtyz)r  r  rE  ro)r  r  filled	remainingr  r  r-  rE  )safe_dict_2rQ  r  rS  rN  r  safe_string_upper_nrP  r  	omit_zeror  r  numbersRealr|  r~  find
safe_orderrW  rV  r  r  rY  parse_order_statusr0   rZ  safe_bool_2)rv  rL  r  r  newOrderr  r,  r]  r;  rJ  r  statusIdfeeCurrencyCodefeeCostrA  rU  rB  rV  rawTyper-  rS  s                        rx  r  zbingx.parse_order  s   v ##E+=?RSSE))%FF , 4VV6
%%eXs;;>%%hdJGGF''vs;;''/[/[/[\\	!00cJJ++E3Q3Q3QRR,,UJDD$$U,F,F,FGG#f~ 25==&,VnOO&,WoOO"(/??5*55 x2~~ NN4+;+;Hj+Q+QRRM Jx,N,N V^bdVdVd(C(( 5??844 NN4+;+;Hk+R+RSSM__UL99
!zR'7'7"nnT-=-=j,-W-WXXO"jW\.R.R"ZdhjZjZj*c** 9!__Z88
"nnT-=-=j+-V-VWWO**5&#>>NN4#5#5e[+#V#VWW	  V$$r))0E )#V$$r))0G"+#  
D 
$$$U,K,K,KLL 
 T//7s7s7stt 
 d&&xjII	 

  
 Y// 
 !"4 
 "4#4#4UL#I#I 
 D))'22 
 4++E=AA 
  
 D))$// 
 T''w<< 
 L 
 ] 
  ! 
" t))%TBB# 
$ $$U,ABB((0[0[0[\\((sCC--h77+*733  **5,EE9 
  
  
: ;  	ry  r  c           	      F    ddddddddd}|                      |||          S )Nr   closedcanceled)NEWPENDINGPARTIALLY_FILLEDRUNNINGFILLEDCANCELED	CANCELLEDFAILEDr  rv  r  statusess      rx  r  zbingx.parse_order_status  s@     &"# 	
 	
 &&999ry  r5   c                   K   |                                   d{V  |                     |dd          }|                     |d          }d}d}|r5d|i}|                     |                     ||                     d{V }nF|t          | j        dz             |                     |          }d|d         i}|                     |dd	          }	|                     |dg          }|	|	|d	<   n||d
<   d}
d}| 	                    d||          \  }
}| 
                    d||          \  }}|
dk    r0|                     |                     ||                     d{V }ne|dk    r0|                     |                     ||                     d{V }n/|                     |                     ||                     d{V }|                     |di           }|                     |d|          }|                     ||          S )a  
        cancels an open order

        https://bingx-api.github.io/docs-v3/#/en/Spot/Trades%20Endpoints/Cancel%20Order
        https://bingx-api.github.io/docs-v3/#/en/Swap/Trades%20Endpoints/Cancel%20Order
        https://bingx-api.github.io/docs-v3/#/en/Swap/Trades%20Endpoints/Cancel%20TWAP%20Order
        https://bingx-api.github.io/docs-v3/#/en/Coin-M%20Futures/Trades%20Endpoints/Cancel%20an%20Order

        :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 str [params.clientOrderId]: a unique id for the order
        :returns dict: an `order structure <https://docs.ccxt.com/?id=order-structure>`
        Nrv  Fr  z) cancelOrder() requires a symbol argumentr  r5   r0  r/  rD  rM   rB   r1  r{  rL  )r  r  r   swapV1PrivatePostTwapCancelOrderr  r&   r5   r  rQ  r(  ru  spotV1PrivatePostTradeCancel$cswapV1PrivateDeleteTradeCancelOrderswapV2PrivateDeleteTradeOrderr~  r  )rv  r5   r  r  rY  r  r  r`  r  r0  r  rx  r{  rL  s                 rx  cancel_orderzbingx.cancel_order  sp      !!!!!!!!!nnVVU;;66** 4	fr!K "BB4;;{\bCcCcddddddddHH4 ~'2](]^^^[[((F&,G !..vXXMYYv'899F(+8((%'	"DG==mVU[\\LD&"==mVU[\\OGVv~~!%!B!B4;;wX^C_C_!`!```````i''%)%N%Nt{{[bdjOkOk%l%lllllllHH%)%G%GT[]cHdHd%e%eeeeeeeHF ~~h33tWd33v...ry  c                   K   |                                   d{V  d}i }| |                     |          }|d         |d<   d}d}|                     d||          \  }}|                     d||          \  }}d}|dk    r0|                     |                     ||                     d{V }n|dk    rf|dk    r0|                     |                     ||                     d{V }nG|                     |                     ||                     d{V }nt          | j	        dz             | 
                    |d	i           }|                     |d
dg           }	|                     |	          S )a  
        cancel all open orders

        https://bingx-api.github.io/docs-v3/#/en/Spot/Trades%20Endpoints/Cancel%20all%20Open%20Orders%20on%20a%20Symbol
        https://bingx-api.github.io/docs-v3/#/en/Swap/Trades%20Endpoints/Cancel%20All%20Open%20Orders
        https://bingx-api.github.io/docs-v3/#/en/Coin-M%20Futures/Trades%20Endpoints/Cancel%20all%20orders

        :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
        :param str [params.type]: 'spot' or 'swap'(default is 'spot' if symbol is not provided)
        :param str [params.subType]: 'linear' or 'inverse' for swap markets(default is 'linear' if symbol is not provided)
        :returns dict[]: a list of `order structures <https://docs.ccxt.com/?id=order-structure>`
        Nr5   r  rB   rK   rD   r1  z= cancelAllOrders is only supported for spot and swap markets.r{  successr  )r  r  r(  ru  &spotV1PrivatePostTradeCancelOpenOrdersr  &cswapV1PrivateDeleteTradeAllOpenOrders%swapV2PrivateDeleteTradeAllOpenOrdersr'   r5   r~  r  r  )
rv  r  r  r  r  r,  rx  r  r{  r  s
             rx  cancel_all_orderszbingx.cancel_all_ordersE  s      !!!!!!!!![[((F &tGH
!??@QSY[abb
F99:KVU[\\!HHU\^dIeIeffffffffHH. 6!!)##!%!L!LT[[Y`bhMiMi!j!jjjjjjjr "&!K!KDKKX_agLhLh!i!iiiiiii> TW'ffggg~~h33!!$	8R@@  (((ry  idsc                   K   |t          | j        dz             |                                  d{V  |                     |          }d|d         i}|                     |d          }|                     |d          }|}|du}|r|}g }	t          dt          |                    D ].}
||
         }t          |          }|		                    |           /d}|d         rN|rdnd	}d

                    |	          ||<   |                     |                     ||                     d{V }nO|r|                     |	          |d<   n|	|d<   |                     |                     ||                     d{V }|                     |di           }|                     |ddg           }|                     |          S )aM  
        cancel multiple orders

        https://bingx-api.github.io/docs-v3/#/en/Spot/Trades%20Endpoints/Cancel%20multiple%20orders
        https://bingx-api.github.io/docs-v3/#/en/Swap/Trades%20Endpoints/Cancel%20multiple%20orders

        :param str[] ids: order ids
        :param str symbol: unified market symbol, default is None
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :param str[] [params.clientOrderIds]: client order ids
        :returns dict: an list of `order structures <https://docs.ccxt.com/?id=order-structure>`
        Nz* cancelOrders() requires a symbol argumentr  r5   clientOrderIdsr   rB   clientOrderIDsorderIds,clientOrderIDListorderIdListr{  r  r  )r&   r5   r  r  r  r  r  r  r|  r  join"spotV1PrivatePostTradeCancelOrdersr  rU  #swapV2PrivateDeleteTradeBatchOrdersr~  r  r  )rv  r  r  r  r  r  r  
idsToParseareClientOrderIds	parsedIdsr  r5   stringIdr  
spotReqKeyr{  r  s                    rx  cancel_orderszbingx.cancel_orders  s      >#DG.Z$Z[[[!!!!!!!!!V$$fTl
 1ABB6#344
+47 	('J	q#j//** 	' 	'AAB2wwHX&&&&&> #	d->N))JJ"%((9"5"5GJ!DDT[[QXZ`EaEabbbbbbbbHH8 ! 3/3yy/C/C+,,)2&!EEdkkRY[aFbFbccccccccH< ~~h33""4HbAA  )))ry  timeoutc                   K   |                                   d{V  |dk    }|rdnd|r|                     |dz            ndd}d}d}|                     dd|          \  }}|dk    r0|                     |                     ||                     d{V }nS|d	k    r0|                     |                     ||                     d{V }nt          | j        d
z   |z   dz             |S )a  
        dead man's switch, cancel all orders after the given timeout

        https://bingx-api.github.io/docs-v3/#/en/Spot/Trades%20Endpoints/Cancel%20All%20After
        https://bingx-api.github.io/docs-v3/#/en/Swap/Trades%20Endpoints/Cancel%20All%20After

        :param number timeout: time in milliseconds, 0 represents cancel the timer
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :param str [params.type]: spot or swap market
        :returns dict: the api result
        Nr   ACTIVATECLOSErg  )r  timeOutrL   rB   rD   z- cancelAllOrdersAfter() is not supported for  markets)r  parse_to_intr(  $spotV1PrivatePostTradeCancelAllAfterr  $swapV2PrivatePostTradeCancelAllAfterr,   r5   )rv  r  r  r  r  r  r  s          rx  cancel_all_orders_afterzbingx.cancel_all_orders_after:  s?      !!!!!!!!!aK#+9JJ'?GO))'D.999a
 
 99:PRVX^__f6>>!FFt{{SZ\bGcGcddddddddHHV^^!FFt{{SZ\bGcGcddddddddHHtw)XX[__bllmmm ry  c                   K   |                                   d{V  |                     |dd          }|                     |d          }d}d}|r5d|i}|                     |                     ||                     d{V }n|t          | j        dz             |                     |          }|d         |d}d}	d}
|                     d||          \  }	}| 	                    d||          \  }
}|	d	k    r0| 
                    |                     ||                     d{V }ne|
d
k    r0|                     |                     ||                     d{V }n/|                     |                     ||                     d{V }|                     |di           }|                     |d|          }|                     ||          S )a%  
        fetches information on an order made by the user

        https://bingx-api.github.io/docs-v3/#/en/Spot/Trades%20Endpoints/Query%20Order%20details
        https://bingx-api.github.io/docs-v3/#/en/Swap/Trades%20Endpoints/Query%20Order%20details
        https://bingx-api.github.io/docs-v3/#/en/Swap/Trades%20Endpoints/TWAP%20Order%20Details
        https://bingx-api.github.io/docs-v3/#/en/Coin-M%20Futures/Trades%20Endpoints/Query%20Order

        :param str id: the 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 boolean [params.twap]: if fetching twap order
        :returns dict: an `order structure <https://docs.ccxt.com/?id=order-structure>`
        Nrv  Fr  z( fetchOrder() requires a symbol argumentr5   )r  rD  r   rB   r1  r{  rL  )r  r  r  swapV1PrivateGetTwapOrderDetailr  r&   r5   r  r(  ru  spotV1PrivateGetTradeQuery!cswapV1PrivateGetTradeOrderDetailswapV2PrivateGetTradeOrderr~  r  )rv  r5   r  r  rY  r  r  r`  r  r  rx  r{  rL  s                rx  fetch_orderzbingx.fetch_orderb  s1      !!!!!!!!!nnVVU;;66** y	cr!K "AA$++k[aBbBbccccccccHH6 ~'2\(\]]][[((F , G DG==lFTZ[[LD&"==lFTZ[[OGVv~~!%!@!@WV\A]A]!^!^^^^^^^0 i''%)%K%KDKKX_agLhLh%i%iiiiiiiHHj &*%D%DT[[QXZ`EaEa%b%bbbbbbbH6 ~~h33tWd33v...ry  c                 2  K   |                                   d{V  i }d}| |                     |          }|d         |d<   d}|                     d||          \  }}|dk    rt          | j        dz             |||d<   |||d<   |                     d	||          \  }}|                     |                     ||                     d{V }|                     |d
i           }	| 	                    |	dg           }
| 
                    |
|||          S )a}  
        fetches information on multiple orders made by the user

        https://bingx-api.github.io/docs-v3/#/en/Swap/Trades%20Endpoints/All%20Orders
        https://bingx-api.github.io/docs-v3/#/en/Swap/Trades%20Endpoints/Query%20Order%20history(returns less fields than above)

        :param str symbol: unified market symbol of the market orders were made in
        :param int [since]: the earliest time in ms to fetch orders for
        :param int [limit]: the maximum number of order structures to retrieve
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :param int [params.until]: the latest time in ms to fetch entries for
        :param int [params.orderId]: Only return subsequent orders, and return the latest order by default
        :returns Order[]: a list of `order structures <https://docs.ccxt.com/?id=order-structure>`
        Nr5   r  r   rD   z1 fetchOrders() is only supported for swap marketsrb  r  r
  r{  r  )r  r  r(  r,   r5   r  swapV1PrivateGetTradeFullOrderr  r~  r  r  )rv  r  r  rb  r  r  r  r  r  r{  r  s              rx  fetch_orderszbingx.fetch_orders  sQ      !!!!!!!!![[((F &tGH99-QWXXf6>>tw)\\]]]$GG#(GK 229gvNN<<T[[RX=Y=YZZZZZZZZj ~~h33h33  >>>ry  c                 |  K   |                                   d{V  d}i }| |                     |          }|d         |d<   d}d}d}	|                     d||          \  }}|                     d||          \  }}|dk    r0|                     |                     ||                     d{V }	n|                     |dd          }
|                     |d          }|
r0|                     |                     ||                     d{V }	ne|dk    r0| 	                    |                     ||                     d{V }	n/| 
                    |                     ||                     d{V }	|                     |	d	i           }|                     |d
dg           }|                     ||||          S )a  
        fetch all unfilled currently open orders

        https://bingx-api.github.io/docs-v3/#/en/Spot/Trades%20Endpoints/Current%20Open%20Orders
        https://bingx-api.github.io/docs-v3/#/en/Swap/Trades%20Endpoints/Current%20All%20Open%20Orders
        https://bingx-api.github.io/docs-v3/#/en/Coin-M%20Futures/Trades%20Endpoints/Query%20all%20current%20pending%20orders
        https://bingx-api.github.io/docs-v3/#/en/Swap/Trades%20Endpoints/Query%20TWAP%20Entrusted%20Order

        :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 order structures to retrieve
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :param boolean [params.twap]: if fetching twap open orders
        :returns dict[]: a list of `order structures <https://docs.ccxt.com/?id=order-structure>`
        Nr5   r  r   rB   rv  Fr1  r{  r  r   )r  r  r(  ru  spotV1PrivateGetTradeOpenOrdersr  r  r  swapV1PrivateGetTwapOpenOrders cswapV1PrivateGetTradeOpenOrdersswapV2PrivateGetTradeOpenOrdersr~  r  r  )rv  r  r  rb  r  r  r  r  rx  r  rY  r{  r  s                rx  fetch_open_orderszbingx.fetch_open_orderse  s       !!!!!!!!![[((F &tGH99:KVU[\\f99:KVU[\\6>>!AA$++gW]B^B^________HH..??KYYvv..F d!%!D!DT[[QXZ`EaEa!b!bbbbbbbI%%!%!F!Ft{{SZ\bGcGc!d!ddddddd!%!E!EdkkRY[aFbFb!c!cccccccX ~~h33!!$&"==  >>>ry  c                    K   |                                   d{V  |                     ||||           d{V }|                     |dd          S )a	  
        fetches information on multiple closed orders made by the user

        https://bingx-api.github.io/docs-v3/#/en/Spot/Trades%20Endpoints/Query%20Order%20history
        https://bingx-api.github.io/docs-v3/#/en/Swap/Trades%20Endpoints/Query%20Order%20history
        https://bingx-api.github.io/docs-v3/#/en/Coin-M%20Futures/Trades%20Endpoints/User's%20History%20Orders
        https://bingx-api.github.io/docs/#/standard/contract-interface.html#Historical%20order

        :param str symbol: unified market symbol of the closed orders
        :param int [since]: timestamp in ms of the earliest order
        :param int [limit]: the max number of closed orders to return
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :param int [params.until]: the latest time in ms to fetch orders for
        :param boolean [params.standard]: whether to fetch standard contract orders
        :returns Order[]: a list of `order structures <https://docs.ccxt.com/?id=order-structure>`
        Nr  r  r   fetch_canceled_and_closed_orders	filter_byrv  r  r  rb  r  r  s         rx  fetch_closed_orderszbingx.fetch_closed_orders  sn      " !!!!!!!!!<<VUESYZZZZZZZZ~~fh999ry  c                    K   |                                   d{V  |                     ||||           d{V }|                     |dd          S )a  
        fetches information on multiple canceled orders made by the user

        https://bingx-api.github.io/docs-v3/#/en/Spot/Trades%20Endpoints/Query%20Order%20history
        https://bingx-api.github.io/docs-v3/#/en/Swap/Trades%20Endpoints/Query%20Order%20history
        https://bingx-api.github.io/docs-v3/#/en/Coin-M%20Futures/Trades%20Endpoints/User's%20History%20Orders
        https://bingx-api.github.io/docs/#/standard/contract-interface.html#Historical%20order

        :param str symbol: unified market symbol of the canceled orders
        :param int [since]: timestamp in ms of the earliest order
        :param int [limit]: the max number of canceled orders to return
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :param int [params.until]: the latest time in ms to fetch orders for
        :param boolean [params.standard]: whether to fetch standard contract orders
        :returns dict: a list of `order structures <https://docs.ccxt.com/?id=order-structure>`
        Nr  r  r  r
  s         rx  fetch_canceled_orderszbingx.fetch_canceled_orders/  sn      " !!!!!!!!!<<VUESYZZZZZZZZ~~fh
;;;ry  c                   K   |                                   d{V  d}i }| |                     |          }|d         |d<   d}d}d}	d}
|                     d||          \  }}|                     d||          \  }}|                     |ddd          \  }	}|	r1|                     |                     ||                     d{V }
n]|dk    r8|||d<   |                     |                     ||                     d{V }
n|                     |d	d          }| 	                    |d	          }|rd
|d<   |dn||d<   |d
n||d<   | 
                    |d|                                           }| 	                    |d          }||d<   |                     |                     ||                     d{V }
ne|dk    r0|                     |                     ||                     d{V }
n/|                     |                     ||                     d{V }
|                     |
di           }|                     |ddg           }|                     ||||          S )a  
        fetches information on multiple closed orders made by the user

        https://bingx-api.github.io/docs-v3/#/en/Spot/Trades%20Endpoints/Query%20Order%20history
        https://bingx-api.github.io/docs-v3/#/en/Swap/Trades%20Endpoints/Query%20Order%20history
        https://bingx-api.github.io/docs-v3/#/en/Coin-M%20Futures/Trades%20Endpoints/User's%20History%20Orders
        https://bingx-api.github.io/docs/#/standard/contract-interface.html#Historical%20order
        https://bingx-api.github.io/docs-v3/#/en/Swap/Trades%20Endpoints/Query%20TWAP%20Historical%20Orders

        :param str [symbol]: unified market symbol of the market orders were made in
        :param int [since]: the earliest time in ms to fetch orders for
        :param int [limit]: the maximum number of order structures to retrieve
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :param int [params.until]: the latest time in ms to fetch orders for
        :param boolean [params.standard]: whether to fetch standard contract orders
        :param boolean [params.twap]: if fetching twap orders
        :returns dict[]: a list of `order structures <https://docs.ccxt.com/?id=order-structure>`
        Nr5   r  rh   r  FrB   r  rv  r   	pageIndexr;   r  r	  r
  r1  r{  r  r   )r  r  r(  ru  r  contractV1PrivateGetAllOrdersr  "spotV1PrivateGetTradeHistoryOrdersr  r  r  milliseconds!swapV1PrivateGetTwapHistoryOrders"cswapV1PrivateGetTradeOrderHistoryswapV2PrivateGetTradeAllOrdersr~  r  r  )rv  r  r  rb  r  r  r  r  rx  r  r  rY  r	  r{  r  s                  rx  r  z&bingx.fetch_canceled_and_closed_ordersD  s     & !!!!!!!!![[((F &tGH99:MvW]^^f99:MvW]^^88ATV`bghh& ~	c!??GU[@\@\]]]]]]]]HHV^^ &+
#!DDT[[QXZ`EaEabbbbbbbbHH4 ..??KYYvv..F ]c'($.3mcc%
#-2]qq$))&'4;L;L;N;NOO6733%*	"!%!G!GT[]cHdHd!e!eeeeeee< I%%!%!H!HU\^dIeIe!f!fffffffn "&!D!DT[[QXZ`EaEa!b!bbbbbbb: ~~h33!!$&"==  >>>ry  r  fromAccount	toAccountc           
      T  K   |                                   d{V  |                     |          }|                     | j        di           }d}|                     dd|          \  }}|                     |||          }	|                     |||          }
|	dk    r|dk    rd}	nd}	|
dk    r|dk    rd}
nd}
|	|
|d         |                     ||          d	}|                     |                     ||                     d{V }||                     |d
          dd||||dd	S )a  
        transfer currency internally between wallets on the same account

        https://bingx-api.github.io/docs-v3/#/en/Account%20and%20Wallet/Fund%20Account/Asset%20Transfer%20New

        :param str code: unified currency code
        :param float amount: amount to transfer
        :param str fromAccount: account to transfer from(spot, swap, futures, or funding)
        :param str toAccount: account to transfer to(spot, swap(linear or inverse), future, or funding)
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: a `transfer structure <https://docs.ccxt.com/?id=transfer-structure>`
        NrC  r   rD   r1  r.  r-  r5   )r  r  r   r  
transferId	r  r5   rJ  rK  r  r  r  r  r  )	r  r  r~  ro  ru  r  currency_to_precisionapiAssetV1PrivatePostTransferr  )rv  r  r  r  r  r  r  rC  rx  fromIdtoIdr  r  s                rx  r   zbingx.transfer  s      !!!!!!!!!==&&6FKK99*dFSS!!.+{KK	9EEV)##$$6>>)##""!d^00v>>	
 
 ;;DKKQW<X<XYYYYYYYY ""8\::&"

 

 
	
ry  c                 l  K   |                                   d{V  i }d}||                     |          }|                     | j        di           }|                     |d          }|                     |d          }	|                     |||          }
|                     ||	|	          }|
|t          | j        dz             ||
|d<   |	||d<   |                     |ddg          }d}d}|                     |dd	d          \  }}|r | 	                    dd||||           d{V S |||d
<   |||d<   | 
                    d||          \  }}|                     |                     ||                     d{V }|                     |dg           }|                     ||||          S )a  
        fetch a history of internal transfers made on an account

        https://bingx-api.github.io/docs-v3/#/en/Account%20and%20Wallet/Fund%20Account/Asset%20transfer%20records%20new

        :param str [code]: unified currency code of the currency transferred
        :param int [since]: the earliest time in ms to fetch transfers for
        :param int [limit]: the maximum number of transfers structures to retrieve(default 10, max 100)
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :param str params.fromAccount:(mandatory) transfer from(spot, swap(linear or inverse), future, or funding)
        :param str params.toAccount:(mandatory) transfer to(spot, swap(linear or inverse), future, or funding)
        :param boolean [params.paginate]: whether to paginate the results(default False)
        :returns dict[]: a list of `transfer structures <https://docs.ccxt.com/?id=transfer-structure>`
        NrC  r  r  z0 fromAccount & toAccount parameters are requiredr;   Fr   r  r  r  r
  rows)r  r  r~  ro  r  r"   r5   r  r  fetch_paginated_call_dynamicr  "apiV3PrivateGetAssetTransferRecordr  r  parse_transfers)rv  r  r  rb  r  r  r  rC  r  r  r  r  maxLimitr  r  r   s                   rx  fetch_transferszbingx.fetch_transfers:  s      !!!!!!!!!}}T**H6FKK&&v}==$$V[99	!!.+{KK	9EE>T\*\ \]]]"%+GM" #'GK 6M;#?@@88AQS]_dee& 	s::;KTSXZ_agiqrrrrrrrrr#(GK "'GJ229gvNN@@WV\A]A]^^^^^^^^" ~~h33##D(E5AAAry  r   r  c                 V   |                      |d          }|                     |d          }|                      |d          }|                     ||          }|                      |d          }|                     | j        di           }|                      |d          }	|                      |d          }
|                      ||	|	          }|                      ||
|
          }||||                     |          ||                     |d          |||                     |          d		S )
Nr  rJ  r   r  rD  r  r  r  r  )r  r  r  r~  ro  rV  r  parse_transfer_status)rv  r   r  r  rJ  r  r\  r  rD  r  r  r  r  s                rx  parse_transferzbingx.parse_transferx  s.   !!(L99%%h<<	%%h88
..z8DD!!(H55~~dlNBGG!!(M::+66&&|VVDD$$\4>>	"Y//$&&x::&"0088

 

 
	
ry  c                 8    ddi}|                      |||          S )N	CONFIRMEDokr  r  s      rx  r'  zbingx.parse_transfer_status  s(    
 &&999ry  c                   K   |                                   d{V  |                     |          }|                     | j        d          }|                     | j        d|          }|d         dd|d}|                     |                     ||                     d{V }|                     |                     |d          d          }| 	                    ||d         gd	          }	| 
                    |	d
          S )a  
        fetch the deposit addresses for a currency associated with self account

        https://bingx-api.github.io/docs-v3/#/en/Account%20and%20Wallet/Wallet%20Deposits%20and%20Withdrawals/Main%20Account%20Deposit%20Address

        :param str code: unified currency code
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: a dictionary `address structures <https://docs.ccxt.com/?id=address-structure>`, indexed by the network
        NrE  r5   r   rg  )r  offsetrb  rE  r{  r  Fr  )r  r  r  ro  parse_params(walletsV1PrivateGetCapitalDepositAddressr  r  r~  parse_deposit_addressesindex_by)
rv  r  r  r  defaultRecvWindowrE  r  r  r{  parseds
             rx  "fetch_deposit_addresses_by_networkz(bingx.fetch_deposit_addresses_by_network  s      !!!!!!!!!==&& --dlLII&&t'8,HYZZ
TN$	
 
 FFt{{SZ\bGcGcdddddddd& ~~dnnXv>>GG--dXf5E4FNN}}VY///ry  c                   K   |                      |d          }|                     |dg          }|                     ||           d{V }||                     ||          S |                     | j        d          }|                      ||          }||                     ||          S t          |                                          }|                      |d          }|                     ||          S )a_  
        fetch the deposit address for a currency associated with self account

        https://bingx-api.github.io/docs-v3/#/en/Account%20and%20Wallet/Wallet%20Deposits%20and%20Withdrawals/Main%20Account%20Deposit%20Address

        :param str code: unified currency code
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :param str [params.network]: The chain of currency. This only apply for multi-chain currency, and there is no need for single chain currency
        :returns dict: an `address structure <https://docs.ccxt.com/?id=address-structure>`
        r  NrG  r   )r  r  r4  r~  ro  r   r  )	rv  r  r  r  addressStructuresro  defaultNetworkForCurrencyr  keys	            rx  fetch_deposit_addresszbingx.fetch_deposit_address  s      ""69556I;//"&"I"I$PV"W"WWWWWWW>>"3W===nnT\3DEEG(,(8(8$(G(G%(4~~&79RSSS-224455&&tQ//~~&7===ry  c                 T   |                      |d          }|                      |d          }|                     ||          }|d         }|                      |d          }|                      |d          }|                     ||          }|                     |           |||||dS )Ntagr  r  addressWithPrefixr  )r  r  r  addressr;  )r  safe_currencyr  check_address)	rv  depositAddressr  r;  r  r  r=  
networkdIdr  s	            rx  parse_deposit_addresszbingx.parse_deposit_address  s     ~u55%%nf==
%%j(;;"">3FGG%%ni@@
--j$??7###""
 
 	
ry  c                 0  K   |                                   d{V  i }d}| |                     |          }|d         |d<   |||d<   |||d<   |                     |                     ||                     d{V }|                     ||||          S )a7  
        fetch all deposits made to an account

        https://bingx-api.github.io/docs-v3/#/en/Spot/Wallet%20deposits%20and%20withdrawals/Deposit%20records

        :param str [code]: unified currency code
        :param int [since]: the earliest time in ms to fetch deposits for
        :param int [limit]: the maximum number of deposits structures to retrieve
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict[]: a list of `transaction structures <https://docs.ccxt.com/?id=transaction-structure>`
        Nr5   r  r  rb  )r  r  $spotV3PrivateGetCapitalDepositHisrecr  parse_transactionsrv  r  r  rb  r  r  r  r  s           rx  fetch_depositszbingx.fetch_deposits  s       !!!!!!!!!
}}T**H&tnGFO#(GK $GGBB4;;wX^C_C_````````$ &&x5%HHHry  c                 0  K   |                                   d{V  i }d}| |                     |          }|d         |d<   |||d<   |||d<   |                     |                     ||                     d{V }|                     ||||          S )aC  
        fetch all withdrawals made from an account

        https://bingx-api.github.io/docs-v3/#/en/Spot/Wallet%20deposits%20and%20withdrawals/Withdraw%20records

        :param str [code]: unified currency code
        :param int [since]: the earliest time in ms to fetch withdrawals for
        :param int [limit]: the maximum number of withdrawals structures to retrieve
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict[]: a list of `transaction structures <https://docs.ccxt.com/?id=transaction-structure>`
        Nr5   r  r  rb  )r  r  &spotV3PrivateGetCapitalWithdrawHistoryr  rE  rF  s           rx  fetch_withdrawalszbingx.fetch_withdrawals  s       !!!!!!!!!
}}T**H&tnGFO#(GK $GGDDT[[QXZ`EaEabbbbbbbb( &&x5%HHHry  transactionc                 b   |                      |d          }|d n|                     |d          }|                     |d|          }|                     |d          }|                     |d          }|                     |dd          }|                     |          }	|+|                     |d          }	|                     |	          }|                     |d          }
|                     |d	          }|                     ||          }|7||
k    r1|                    |
          d
k    r|
|                    |
d          }|                     |d          }|dk    rdn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 S )!Nr{  r5   r=  
addressTag
insertTimerJ  	applyTimer  r  r   r  transferType0r  
withdrawalr  txidtxIdr  r  r  r  rK  addressFrom	addressTor;  tagFromtagToupdatedtransactionFee)r  r  rate)commentr  internal)r  r  r  rV  rO  r  r  r  r  r  parse_transaction_status)rv  rK  r  r{  dataIdr5   r=  r;  rJ  rK  r  r  r  r  r  s                  rx  parse_transactionzbingx.parse_transactionL  s   ` {F33,T-=-=dD-I-Ik488"";	::{L99''\;OO	<<	**''[AAHx00I"";	::%%k6::
&&z8<<47??		'8J8Ja8O8O"||GR00"";??$^^yy,
K
"
 D$$[&99
 D	

 
 t..w77
 d&&{H==
 d33D4D4D[RZ4[4[\\
 
 
 w
 4
 
 3
 s
  T!
" t#
$ ''V<< ((6FGG 
 1
 
 
 	
ry  c                 R    ddddddddddddddd}|                      |||          S )Npendingr+  rejected)rQ  r  1020304050607023456r  r  s      rx  r^  zbingx.parse_transaction_status  sR    
 
  &&999ry  rR  c                 p  K   |t          | j        dz             |                                  d{V  |                     |          }|d         dk    rt	          | j        dz             |                                }|dk    rd}|dk    r|dk    rt          | j        d	z             |d
         |d}d}|                     d||          \  }}|dk    r/|                     | 	                    ||                     d{V S | 
                    | 	                    ||                     d{V S )a  
        set margin mode to 'cross' or 'isolated'

        https://bingx-api.github.io/docs-v3/#/en/Swap/Trades%20Endpoints/Change%20Margin%20Type
        https://bingx-api.github.io/docs-v3/#/en/Coin-M%20Futures/Trades%20Endpoints/Set%20Margin%20Type

        :param str marginMode: 'cross' or 'isolated'
        :param str symbol: unified market symbol
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: response from the exchange
        Nz+ setMarginMode() requires a symbol argumentr  rD   z- setMarginMode() supports swap contracts onlyCROSSCROSSEDISOLATEDz@ setMarginMode() marginMode argument should be isolated or crossr5   )r  
marginTyper   r1  )r&   r5   r  r  r(   rL  r'   ru  !cswapV1PrivatePostTradeMarginTyper   swapV2PrivatePostTradeMarginType)rv  rR  r  r  r  r  rx  s          rx  set_margin_modezbingx.set_margin_mode  sw      >#DG.[$[\\\!!!!!!!!!V$$&>V##DG&UUVVV%%''
  "J##
i(?(?TW'iijjjTl$
 
 99/6SYZZi??GU[@\@\]]]]]]]]]>>t{{7TZ?[?[\\\\\\\\\ry  c                 p   K   ddi}|                      |||                     ||                     d {V S )Nr  r   
set_marginr  rv  r  r  r  r  s        rx  
add_marginzbingx.add_margin  J      A
 __VVT[[&5Q5QRRRRRRRRRry  c                 p   K   ddi}|                      |||                     ||                     d {V S )Nr  r   ry  r{  s        rx  reduce_marginzbingx.reduce_margin  r}  ry  c                   K   |                      |d          }|t          | j        dz             |                     |ddg          st          | j        dz             |                                  d{V  |                     |          }|d         |                     |d         |          |d}|                     |                     ||                     d{V }| 	                    ||          S )	a  
        Either adds or reduces margin in an isolated position in order to set the margin to a specific value

        https://bingx-api.github.io/docs-v3/#/en/Swap/Trades%20Endpoints/Modify%20Isolated%20Position%20Margin

        :param str symbol: unified market symbol of the market to set margin in
        :param float amount: the amount to set the margin to
        :param dict [params]: parameters specific to the bingx api endpoint
        :returns dict: A `margin structure <https://docs.ccxt.com/?id=margin-structure>`
        r  NzV setMargin() requires a type parameter either 1(increase margin) or 2(decrease margin)r   r   r5   r  )r  r  r  )
r  r&   r5   in_arrayr  r  rR  $swapV2PrivatePostTradePositionMarginr  parse_margin_modification)rv  r  r  r  r  r  r  r  s           rx  rz  zbingx.set_margin  s8        00<#DG  /G  %G  H  H  H}}TAq6** 	H#DG  /G  %G  H  H  H!!!!!!!!!V$$Tl..vh/?HH
 

 BB4;;wX^C_C_```````` --h???ry  r{  c                     |                      |d          }||                      |d          |dk    rdndd|                     |d          |                     |d          |                      |d	          d d d d

S )Nr  r  r  addreducer  r  rC   r  )
r  r  r  rR  r  r  r  r  rJ  rK  )r  r  )rv  r{  r  r  s       rx  r  zbingx.parse_margin_modification  s     f--&&vx88"ckkEE$&&tX66%%dH55$$VX66
 
 	
ry  c                   K   |                                   d{V  |                     |          }d|d         i}d}|d         r0|                     |                     ||                     d{V }n/|                     |                     ||                     d{V }|                     |di           }|                     ||          S )a  
        fetch the set leverage for a market

        https://bingx-api.github.io/docs-v3/#/en/Swap/Trades%20Endpoints/Query%20Leverage%20and%20Available%20Positions
        https://bingx-api.github.io/docs-v3/#/en/Coin-M%20Futures/Trades%20Endpoints/Query%20Leverage

        :param str symbol: unified market symbol
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: a `leverage structure <https://docs.ccxt.com/?id=leverage-structure>`
        Nr  r5   r1  r{  )r  r  cswapV1PrivateGetTradeLeverager  swapV2PrivateGetTradeLeverager~  parse_leveragerp  s          rx  fetch_leveragezbingx.fetch_leverage#  s       !!!!!!!!!V$$fTl
 ) 	^!@@WV\A]A]^^^^^^^^HH$ "??GU[@\@\]]]]]]]]H& ~~h33""4000ry  r[  c                     |                      |d          }||                     ||          d |                     |d          |                     |d          dS )Nr  longLeverageshortLeverage)r  r  rR  r  r  )r  rW  r  )rv  r[  r  r]  s       rx  r  zbingx.parse_leverage]  sg    : ##Hh77&&x88 --hGG!..xII
 
 	
ry  c                   K   |t          | j        dz             |                     |d          }|                     d|dg d           |                                  d{V  |                     |          }|d         ||d}|d         r/|                     |                     ||                     d{V S |                     |                     ||                     d{V S )	a6  
        set the level of leverage for a market

        https://bingx-api.github.io/docs-v3/#/en/Swap/Trades%20Endpoints/Set%20Leverage
        https://bingx-api.github.io/docs-v3/#/en/Coin-M%20Futures/Trades%20Endpoints/Modify%20Leverage

        :param float leverage: the rate of leverage
        :param str symbol: unified market symbol
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :param str [params.side]: hedged: ['long' or 'short']. one way: ['both']
        :returns dict: response from the exchange
        Nz) setLeverage() requires a symbol argumentr;  r   )r9  r:  rK  r5   )r  r;  r[  r1  )	r&   r5   rM  check_required_argumentr  r  cswapV1PrivatePostTradeLeverager  swapV2PrivatePostTradeLeverage)rv  r[  r  r  r;  r  r  s          rx  set_leveragezbingx.set_leverage  s#      >#DG.Y$YZZZ%%ff55$$]D&B[B[B[\\\!!!!!!!!!V$$Tl 
 

 ) 	[==dkk'SY>Z>Z[[[[[[[[[$ <<T[[RX=Y=YZZZZZZZZZry  c                   K   |t          | j        dz             |                                  d{V  |                     |          }i }d}d}d}	|                     d||          \  }	}|	dk    rw|                     |d          }
|
t          | j        dz             |                     |                     ||                     d{V }|                     |dg           }n|d         |d	<   | 	                                }||d
         rdnd}|||<   n|d         r|dz
  |d<   | 
                    |d          }|                     |d          }||d
         rdnd}|||<   n|d         r||d<   |d
         re|||d<   |                     |                     ||                     d{V }|                     |di           }|                     |dg           }n|                     |dd          }|                     |d          }||d<   |                     |                     ||                     d{V }|                     |di           }|                     |dg           }|                     |||||          S )a;  
        fetch all trades made by the user

        https://bingx-api.github.io/docs-v3/#/en/Spot/Trades%20Endpoints/Query%20transaction%20details
        https://bingx-api.github.io/docs-v3/#/en/Swap/Trades%20Endpoints/Query%20historical%20transaction%20orders
        https://bingx-api.github.io/docs-v3/#/en/Coin-M%20Futures/Trades%20Endpoints/Query%20Order%20Trade%20Detail

        :param str [symbol]: unified market symbol
        :param int [since]: the earliest time in ms to fetch trades for
        :param int [limit]: the maximum number of trades structures to retrieve
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :param int [params.until]: timestamp in ms for the ending date filter, default is None
        :param str params['trandingUnit']: COIN(directly represent assets such and ETH) or CONT(represents the number of contract sheets)
        :param str params['orderId']: the order id required for inverse swap
        :returns dict[]: a list of `trade structures <https://docs.ccxt.com/?id=trade-structure>`
        Nz+ fetchMyTrades() requires a symbol argumentr   r1  rD  zE fetchMyTrades() requires an orderId argument for inverse swap tradesr{  r5   r  rB   r  r  rD   l    H4 r	  r
  r  rb  fillstradingUnitCONTfill_orders)r&   r5   r  r  ru  r  #cswapV1PrivateGetTradeAllFillOrdersr  r  r  r  r  spotV1PrivateGetTradeMyTradesr~  rM  "swapV2PrivateGetTradeAllFillOrdersr+  )rv  r  r  rb  r  r  r  r  r  rx  rD  nowstartTimeReqr	  
endTimeReqr{  r  s                    rx  fetch_my_tradeszbingx.fetch_my_trades  s     " >#DG.[$[\\\!!!!!!!!!V$$99/6SYZZi&&vy99G'2y(yzzz!EEdkkRY[aFbFbccccccccHNN8VR88EE8 !'tGH##%%C .4VnK{{)(-%% D%(+C%C	"%%fg66EYYvw//F *0.EYYg
&+
## '#& f~ $@$',GG$!%!C!CDKKPWY_D`D`!a!aaaaaaa~~h;;tWb994 #44V]FSS6=99)4&!%!H!HU\^dIeIe!f!fffffff~~h;;t]B??*   ufEEEry  c                    |                      |di           }t          |                                          }t          |          }|d d dd d di d}|dk    r{t	          d|          D ]j}||         }||         }	d d d|                     |	d          ddd|d         |<   |dk    r*|                     |	d	          |d
         d<   d|d
         d<   k|S )NrH  )r  r  )r  r  r  rH  r   r  F)r  r  r   r  r  r  )r~  r   r  r  r  r  )
rv  r  r  rH  networkCodesnetworksLengthr  r  r  r  s
             rx  parse_deposit_withdraw_feez bingx.parse_deposit_withdraw_feeD  s(    >>#z266HMMOO,,\**" 
 "  
 
 Q1n-- 	= 	=*1o";/'+4@@(,(8(8%(H(HX] ^ ^3 3z";/ "Q&&040@0@-0X0XF:&u-7<F:&|4ry  r  c                 z  K   |                                   d{V  |                     |           d{V }i }t          |                                          }t	          dt          |                    D ]B}||         }||                     ||          r ||         }|                     |          ||<   C|S )a  
        fetch deposit and withdraw fees

        https://bingx-api.github.io/docs-v3/#/en/Account%20and%20Wallet/Wallet%20Deposits%20and%20Withdrawals/Query%20currency%20deposit%20and%20withdrawal%20data

        :param str[]|None codes: list of unified currency codes
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: a list of `fee structures <https://docs.ccxt.com/?id=fee-structure>`
        Nr   )r  r  r   r  r  r  r  r  )	rv  r  r  r  depositWithdrawFeesresponseCodesr  r  r  s	            rx  fetch_deposit_withdraw_feesz!bingx.fetch_deposit_withdraw_feesd  s       !!!!!!!!!..v66666666$&X]]__--q#m,,-- 	S 	SA #D4==u#=#= ,0,K,KE,R,R#D)""ry  r=  r;  c                   K   |                      ||          \  }}|                     |           |                                  d{V  |                     |          }d}d}|                     |ddd|          \  }}dddddd	}	|                     |	||          }|d
         ||                     ||          |d}
|                     |d          }||                     |          |
d<   |||
d<   | 	                    |ddg          }| 
                    |                     |
|                     d{V }|                     |d          }|                     |          S )a  
        make a withdrawal

        https://bingx-api.github.io/docs-v3/#/en/Account%20and%20Wallet/Wallet%20Deposits%20and%20Withdrawals/Withdraw

        :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 int [params.walletType]: 1 fund(funding) account, 2 standard account, 3 perpetual account, 15 spot account
        :returns dict: a `transaction structure <https://docs.ccxt.com/?id=transaction-structure>`
        N   r  r  
walletTyper   r   r  )r/  r   r  	perpetualrB   r5   )r  r=  r  r  r  rM  r{  )handle_withdraw_tag_and_paramsr?  r  r  handle_option_and_params_2r  r  rM  network_code_to_idr  (walletsV1PrivatePostCapitalWithdrawApplyr  r  r`  )rv  r  r  r=  r;  r  r  defaultWalletTyper  walletTypesr  r  r  r{  s                 rx  r  zbingx.withdrawy  s      99#vFFV7###!!!!!!!!!==&&
!<<VZQWYegxyy
F
 
 &&{J@QRR
TN00v>>$	
 
 ((;;!%!8!8!A!AGI?$'GL!6L)#<==FFt{{SZ\bGcGcddddddddx00 %%d+++ry  c                    t          |                                          }|                     |          }t          dt	          |                    D ]x}||         }||         }t          |t                     rQd}t          dt	          |                    D ]'}||         }	|dk    r|dz  }|t          |	          z  }(|dz  }|||<   y|S )Nr   [r  ]r   r  sortr  r  r  r|  )
rv  r  rawKeysr  r  r8  valuearrStrr  arrayElements
             rx  r.  zbingx.parse_params  s    v{{}}%%yy!!q#d))$$ 	% 	%Aq'C3KE%&& %q#e**-- 0 0A#(8L1uu#c,///FF#$sry  c                   K   |                                   d{V  ddi}|                     d||          \  }}d}| |                     |          }|d         |d<   |||d<   |||d<   d}|                     d	||          \  }}d}d}	|d
k    rG|                     |                     ||                     d{V }|                     |dg           }	n]|                     |                     ||                     d{V }|                     |di           }
|                     |
dg           }	| 	                    |	|||          S )a  
        retrieves the users liquidated positions

        https://bingx-api.github.io/docs-v3/#/en/Swap/Trades%20Endpoints/User's%20Force%20Orders
        https://bingx-api.github.io/docs-v3/#/en/Coin-M%20Futures/Trades%20Endpoints/Query%20force%20orders

        :param str [symbol]: unified CCXT market symbol
        :param int [since]: the earliest time in ms to fetch liquidations for
        :param int [limit]: the maximum number of liquidation structures to retrieve
        :param dict [params]: exchange specific parameters for the bingx api endpoint
        :param int [params.until]: timestamp in ms of the latest liquidation
        :returns dict: an array of `liquidation structures <https://docs.ccxt.com/?id=liquidation-structure>`
        NautoCloseTypeLIQUIDATIONr
  r5   r  r  rb  r   r1  r{  r  )
r  r  r  ru  !cswapV1PrivateGetTradeForceOrdersr  r   swapV2PrivateGetTradeForceOrdersr~  parse_liquidations)rv  r  r  rb  r  r  r  rx  r  liquidationsr{  s              rx  fetch_my_liquidationszbingx.fetch_my_liquidations  s      !!!!!!!!!]
 229gvNN[[((F &tGH#(GK $GG99:OQWY_``i!CCDKKPWY_D`D`aaaaaaaaH8  >>(FB??LL!BB4;;wX^C_C_````````H< >>(FB77D>>$"==L&&|VUEJJJry  c                 |   |                      |d          }|                     |d          }|                      |d          }|                      |d          }|                      |d          }t          j        ||          }t          j        ||          }	|                     ||                     ||          |                     |          |                     |          |                     |          |                     |          |                     |	          ||                     |          d	          S )Nr  r  r  r  r  )	r  r  r  r  rM  	baseValue
quoteValuerJ  rK  )r  r  r0   rT  safe_liquidationrW  ru  rV  )
rv  liquidationr  r]  rJ  contractsStringcontractSizeStringpriceStringbaseValueStringquoteValueStrings
             rx  parse_liquidationzbingx.parse_liquidation  s5   , ##K::%%k6::	**;FF!--fnEE&&{J??!,_>PQQ"-o{KK$$&&x88**?;; --.@AA&&{33**?;;++,<=="Y//
&
 
&
 
 
 
	ry  c                 8  K   |                                   d{V  |                     |          }|                     |d          }i }d}|0|                     |                     ||                     d{V }nr|d         |d<   |d         r0|                     |                     ||                     d{V }n/|                     |                     ||                     d{V }|                     |d          }|                     ||          S )a  
        closes open positions for a market

        https://bingx-api.github.io/docs-v3/#/en/Swap/Trades%20Endpoints/Close%20All%20Positions
        https://bingx-api.github.io/docs-v3/#/en/Swap/Trades%20Endpoints/Close%20position%20by%20position%20ID
        https://bingx-api.github.io/docs-v3/#/en/Coin-M%20Futures/Trades%20Endpoints/Close%20all%20positions%20in%20bulk

        :param str symbol: Unified CCXT market symbol
        :param str [side]: not used by bingx
        :param dict [params]: extra parameters specific to the bingx api endpoint
        :param str|None [params.positionId]: the id of the position you would like to close
        :returns dict: an `order structure <https://docs.ccxt.com/?id=order-structure>`
        Nr
  r5   r  r1  r{  )	r  r  r  #swapV1PrivatePostTradeClosePositionr  (cswapV1PrivatePostTradeCloseAllPositions'swapV2PrivatePostTradeCloseAllPositionsr~  r  )	rv  r  r;  r  r  r
  r  r  r{  s	            rx  close_positionzbingx.close_positionH  sP      !!!!!!!!!V$$%%fl;;
!!EEdkkRY[aFbFbccccccccHH$ !'tGHi  l!%!N!Nt{{[bdjOkOk!l!lllllll "&!M!MdkkZaciNjNj!k!kkkkkkk ~~h//f---ry  c                 <  K   |                                   d{V  |                     | j        d          }|                     | j        d|          }d}|                     dd|          \  }}d}|                     dd|          \  }}|dk    rt          | j        dz   |z   dz             d|i}d}|dk    r0|                     | 	                    ||                     d{V }n/| 
                    | 	                    ||                     d{V }|                     |di           }|                     |d	g           }	g }
t          d
t          |	                    D ]4}|                     d|	|         i          }|
                    |           5|
S )a  
        closes open positions for a market

        https://bingx-api.github.io/docs-v3/#/en/Swap/Trades%20Endpoints/Close%20All%20Positions
        https://bingx-api.github.io/docs-v3/#/en/Coin-M%20Futures/Trades%20Endpoints/Close%20all%20positions%20in%20bulk

        :param dict [params]: extra parameters specific to the bingx api endpoint
        :param str [params.recvWindow]: request valid time window value
        :returns dict[]: `a list of position structures <https://docs.ccxt.com/?id=position-structure>`
        NrE  rO   rC   z% closePositions() cannot be used for r  r1  r{  r  r   r
  )r  r  ro  r.  r(  ru  r'   r5   r  r  r  r~  r  r  r  r  r  )rv  r  r2  rE  r,  rx  r  r  r{  r  r  r  r  s                rx  close_all_positionszbingx.close_all_positions  s      !!!!!!!!! --dlLII&&t'8,HYZZ

!??@SUY[abb
F99:MtU[\\!!TW'NNQ[[^hhiii*
 i!JJ4;;W^`fKgKghhhhhhhhHH "II$++V]_eJfJfggggggggH ~~h33..y"55	q#g,,'' 	' 	'A**L'!*+EFFHX&&&&ry  c                    K   |                      |           d{V }|                     |di           }|                     |d          }||dk    dS )a  
        fetchs the position mode, hedged or one way, hedged for binance is set identically for all linear markets or all inverse markets

        https://bingx-api.github.io/docs-v3/#/en/Swap/Trades%20Endpoints/Query%20position%20mode

        :param str symbol: unified symbol of the market to fetch the order book for
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: an object detailing whether the market is in hedged or one-way mode
        Nr{  dualSidePositionr  )r  rY  ) swapV1PrivateGetPositionSideDualr~  r  )rv  r  r  r  r{  r  s         rx  fetch_position_modezbingx.fetch_position_mode  su       >>vFFFFFFFF ~~h33++D2DEE'61
 
 	
ry  rY  c                 ~   K   d}|rd}nd}d|i}|                      |                     ||                     d{V S )a  
        set hedged to True or False for a market

        https://bingx-api.github.io/docs-v3/#/en/Swap/Trades%20Endpoints/Set%20Position%20Mode

        :param bool hedged: set to True to use dualSidePosition
        :param str symbol: not used by bingx setPositionMode()
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: response from the exchange
        Nr  falser  )!swapV1PrivatePostPositionSideDualr  )rv  rY  r  r  r  r  s         rx  set_position_modezbingx.set_position_mode  si         	'%& 0
 ;;DKKQW<X<XYYYYYYYYYry  c                   K   |                                   d{V  |                     |          }|                     ||||||          }	||	d<   d|	d<   d}
|d         r0|                     |                     |	|                     d{V }
n/|                     |                     |	|                     d{V }
|                     |
d          }|                     ||          S )a   
        cancels an order and places a new order

        https://bingx-api.github.io/docs-v3/#/en/Spot/Trades%20Endpoints/Cancel%20an%20Existing%20Order%20and%20Send%20a%20New%20Order  # spot
        https://bingx-api.github.io/docs-v3/#/en/Swap/Trades%20Endpoints/Cancel%20an%20Existing%20Order%20and%20Send%20a%20New%20Orde  # swap

        :param str id: order id
        :param str symbol: unified symbol of the market to create an order in
        :param str type: 'market' or 'limit'
        :param str side: 'buy' or 'sell'
        :param float amount: how much of the currency you want to trade in units of the 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 str [params.triggerPrice]: Trigger price used for TAKE_STOP_LIMIT, TAKE_STOP_MARKET, TRIGGER_LIMIT, TRIGGER_MARKET order types.
        :param dict [params.takeProfit]: *takeProfit object in params* containing the triggerPrice at which the attached take profit order will be triggered
        :param float [params.takeProfit.triggerPrice]: take profit trigger price
        :param dict [params.stopLoss]: *stopLoss object in params* containing the triggerPrice at which the attached stop loss order will be triggered
        :param float [params.stopLoss.triggerPrice]: stop loss trigger price

 EXCHANGE SPECIFIC PARAMETERS
        :param str [params.cancelClientOrderID]: the user-defined id of the order to be canceled, 1-40 characters, different orders cannot use the same clientOrderID, only supports a query range of 2 hours
        :param str [params.cancelRestrictions]: cancel orders with specified status, NEW: New order, PENDING: Pending order, PARTIALLY_FILLED: Partially filled
        :param str [params.cancelReplaceMode]: STOP_ON_FAILURE - if the cancel order fails, it will not continue to place a new order, ALLOW_FAILURE - regardless of whether the cancel order succeeds or fails, it will continue to place a new order
        :param float [params.quoteOrderQty]: order amount
        :param str [params.newClientOrderId]: custom order id consisting of letters, numbers, and _, 1-40 characters, different orders cannot use the same newClientOrderId.
        :param str [params.positionSide]: *contract only* position direction, required for single position, for both long and short positions only LONG or SHORT can be chosen, defaults to LONG if empty
        :param str [params.reduceOnly]: *contract only* True or False, default=false for single position mode. self parameter is not accepted for both long and short positions mode
        :param float [params.priceRate]: *contract only* for type TRAILING_STOP_Market or TRAILING_TP_SL, Max = 1
        :param str [params.workingType]: *contract only* StopPrice trigger price types, MARK_PRICE(default), CONTRACT_PRICE, or INDEX_PRICE
        :returns dict: an `order structure <https://docs.ccxt.com/?id=order-structure>`
        NcancelOrderIdSTOP_ON_FAILUREcancelReplaceModerD   r{  )r  r  rt  #swapV1PrivatePostTradeCancelReplacer  (spotV1PrivatePostTradeOrderCancelReplacer~  r  )rv  r5   r  r  r;  r  rM  r  r  r  r  r{  s               rx  
edit_orderzbingx.edit_order  s     @ !!!!!!!!!V$$++FD$vVV#% '8#$&> 9	i!EEdkkRY[aFbFbccccccccHHp "JJ4;;W^`fKgKghhhhhhhhHL ~~h//f---ry  c                   K   |                                   d{V  |                     |          }d|d         i}d}d}|                     d||          \  }}|dk    r0|                     |                     ||                     d{V }n/|                     |                     ||                     d{V }|                     |di           }|                     ||          S )a  
        fetches the margin mode of the trading pair

        https://bingx-api.github.io/docs-v3/#/en/Swap/Trades%20Endpoints/Query%20Margin%20Type
        https://bingx-api.github.io/docs-v3/#/en/Coin-M%20Futures/Trades%20Endpoints/Query%20Margin%20Type

        :param str symbol: unified symbol of the market to fetch the margin mode for
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: a `margin mode structure <https://docs.ccxt.com/?id=margin-mode-structure>`
        Nr  r5   r}   r1  r{  )r  r  ru   cswapV1PrivateGetTradeMarginTyper  swapV2PrivateGetTradeMarginTyper~  parse_margin_mode)rv  r  r  r  r  rx  r  r{  s           rx  fetch_margin_modezbingx.fetch_margin_mode  s      !!!!!!!!!V$$fTl
 99:KVU[\\i!BB4;;wX^C_C_````````HH "AA$++gW]B^B^________H ~~h33%%dF333ry  c                     |                      |d          }|                     |d          }|dk    rdn|}||                     ||dd          |dS )Nr  rt  crossedr  r  rD   )r  r  rR  )r  rX  rW  )rv  rR  r  r]  rt  s        rx  r  zbingx.parse_margin_mode  sk    ##J99++JEE
!+y!8!8WWz
&&xfEE$
 
 	
ry  c                   K   |                                   d{V  |                     |          }d|d         i}d}i }|                     |di           }|d         r2|                     |                     ||                     d{V }|}nX|d         r|                     |           d{V }|}n2|                     |           d{V }|                     |di           }|                     ||          S )ab  
        fetch the trading fees for a market

        https://bingx-api.github.io/docs-v3/#/en/Spot/Trades%20Endpoints/Query%20Trading%20Commission%20Rate
        https://bingx-api.github.io/docs-v3/#/en/Swap/Account%20Endpoints/Query%20Trading%20Commission%20Rate
        https://bingx-api.github.io/docs-v3/#/en/Coin-M%20Futures/Trades%20Endpoints/Query%20Trade%20Commission%20Rate

        :param str symbol: unified market symbol
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: a `fee structure <https://docs.ccxt.com/?id=fee-structure>`
        Nr  r5   r{  rB   r1  rH  )r  r  r~  "spotV1PrivateGetUserCommissionRater  #cswapV1PrivateGetUserCommissionRate"swapV2PrivateGetUserCommissionRateparse_trading_fee)rv  r  r  r  r  r  rH  r{  s           rx  fetch_trading_feezbingx.fetch_trading_fee  sG      !!!!!!!!!V$$fTl
 
~~h33&> +	D!DDT[[QXZ`EaEabbbbbbbbH JJi  D!%!I!I&!Q!QQQQQQQ "

!%!H!H!P!PPPPPPP "^^D,CC
%%j&999ry  r  c                 |    ||d         nd }|||                      |d          |                      |d          dddS )Nr  makerCommissionRatetakerCommissionRateF)r  r  r   r   r  r   )r  )rv  r  r  r  s       rx  r  zbingx.parse_trading_fee  s[     '-&8!!t%%c+@AA%%c+@AA
 
 	
ry  c                    t          |                                          }|                     |          }d }d }t          dt	          |                    D ]}||         }||         }t          |t                     rd }	t          dt	          |                    D ]}
||
         }t          |t                    }|r5|
dk    r|	dt          |          z   dz   z  }	@dt          |          z   dz   }	V|
dk    r|	dt          |          z   z  }	rt          |          }	d|	z   dz   }|}|dk    r	|dz   |z   }|d|z   dz   |z   z  }|S )	Nr   z,""r  r  r  =&r  )rv  r  r  r  adjustedValuer  r  r8  r  r  r  r  isStrings                rx  custom_encodezbingx.custom_encode  st   v{{}}%%yy!!q#d))$$ 	2 	2Aq'C3KE%&& &q#e**-- 7 7A#(8L *< = =H 	7q55"i#l2C2C&Cc&IIFF%(3|+<+<%<s%BFFq55"cC,=,=&==FF%(%6%6FF #fs 2%AvvsU*#)c/E11ry  c                 n  K   |                                   d{V  |                     |          }|d         st          | j        dz             d|d         i}|                     |                     ||                     d{V }|                     |dg           }|                     ||          S )a  
        retrieve information on the maximum leverage, for different trade sizes for a single market

        https://bingx-api.github.io/docs-v3/#/en/Swap/Trades%20Endpoints/Position%20and%20Maintenance%20Margin%20Ratio

        :param str symbol: unified market symbol
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: a `leverage tiers structure <https://docs.ccxt.com/?id=leverage-tiers-structure>`
        NrD   z6 fetchMarketLeverageTiers() supports swap markets onlyr  r5   r{  )r  r  r'   r5    swapV1PrivateGetMaintMarginRatior  r  parse_market_leverage_tiersrp  s          rx  fetch_market_leverage_tiersz!bingx.fetch_market_leverage_tiers5  s       !!!!!!!!!V$$f~ 	aTW'__```fTl
 >>t{{7TZ?[?[\\\\\\\\$ ~~h33//f===ry  c                 X   g }t          dt          |                    D ]}|                     ||          }|                     |d          }|                    d          }|                     |d          }|                     ||d d          }|                    |                     |d          |                     ||          |                     |d          |                     |d          |                     |d	          |                     |d
          d |d           
|S )Nr   tier r  rD   r   r  minPositionValmaxPositionValr   )r   r  r  r  r  maintenanceMarginRatemaxLeverager  )	r  r  r~  r  r  r  r  r  rW  )	rv  r  r  tiersr  r   
tierString	tierPartsr]  s	            rx  r  z!bingx.parse_market_leverage_tiers[  s8    q#d))$$ 	 	A>>$**D))$77J"((--I''h77H%%hfEEFLL((A66**8V<< ,,VX>>#//6FGG#//6FGG)-)9)9$@R)S)S#	 	 	 	 	 	 ry  r   GETc                 *   |d         }|d         }|d         }	|                      | j        dd          }
|                     | j        d         |                   }|
r|t	          | j        dz   |z   dz             |                     ||          }|d	k    }|d
k    }|s|r|rd}nd}|d         }|d         }	|dk    r|dk    r|dk    r|dz  }n|d|z   z  }|d|z   dz   |z   z  }|                     ||                     |                    }| 	                                |d<   | 
                    |          }|	dk    r|r|d|                     |          z   z  }n-|	dk    r&|                                  |dk    s|dk    o|dk    }d }d }|r|                     |          }n+|                     |          }|                     |d          }|                     |                     |          |                     | j                  t&          j                  }| j        |                     | j        dd          d}|r d|d<   ||d<   |                     |          }n'|                     |d          }|d|z   d z   d!z   |z   z  }||||d"S )#Nr   r   r   r  Fr   z) does not have a testnet/sandbox URL for z
 endpointsr   r   zaccount/transferz	api/assetr  r   rB   r   z/apir  rJ  r   ?r   r   POSTTrF  r2  )zX-BX-APIKEYzX-SOURCE-KEYzapplication/jsonzContent-Type	signaturer  z
signature=)urlmethodbodyheaders)r  ro  implode_hostnamer   r,   r5   implode_paramsr  extract_paramsre  keysort	urlencoder  r  r.  	rawencodehmacencoder   hashlibsha256r   r  rU  )rv  pathsectionr  r  r  r  r  r<   accessr  r  versionIsTransferversionIsAssetisJsonContentTypeparsedParamsencodeRequestr  querys                      rx  signz
bingx.sign{  s   qz!*NN4<FF	##DIe$4T$:;; 	ltw)TTW[[^jjkkk""400$
2!W, 	  	   #)"ajGQZF+++v~~'T//vsTz!sW}s"T))64#6#6t#<#<=="jjll{f%%X 4sT^^F3333y  ++---#'<#7"XTEW=W!p_eio_oL M  C $ 2 26 : :#0088 $|T B B		$++m"<"<dkk$+>V>VX_XfggI#{ $ 0 0x P P G ! D*<'&/{#yy((|T::sU{S(<7)CCfdwOOOry  c                 *    |                                  S N)r  )rv  s    rx  re  zbingx.nonce  s      """ry  enablec                 l    t          t          |                               |           || j        d<   d S )Nr  )rs  r2   set_sandbox_modero  )rv  r(  rw  s     rx  r*  zbingx.set_sandbox_mode  s3    eT++F333&,]###ry  httpCodereasonr  r  r  r  c
                    |d S |                      |d          }
|                      |d          }|                      |d          }||
|
dk    r||}| j        dz   |z   }|                     | j        d         ||           |                     | j        d         |
|           |                     | j        d         ||           t          |          d S )Nr  msgtransferErrorMsgrQ  r  r!  r"  )r  r5   throw_exactly_matched_exceptionr  throw_broadly_matched_exceptionr"   )rv  r+  r,  r  r  r  r  r  requestHeadersrequestBodyr  messager/  feedbacks                 rx  handle_errorszbingx.handle_errors  s    4 &11""8U33++H6HII(d.>43;;+*w}t+H001I7T\]]]001I4QYZZZ001I7T\]]])))try  r'  )__name__
__module____qualname__r   rt  r
   r  r   r  r!   r   r  r  r  dictr  r  r|  r   r  r&  r   r.  r_  r   rk  r   rq  r   r   ry  ro  r   r  r  r  r  r  r  r   r  r   r  r  r  r  r   r  r  r   r  r  r  r  r   floatr$  r'  r)  r   r   rt  r#  r   r  rY  r  r   r  r  r  r  r  r  r  r  r  r  r  r  r    r   r%  r   r(  r'  r	   r4  r9  rB  r   rG  rJ  r`  r^  rw  r   r|  r  rz  r  r   r  r  intr  r  r  r  r  r.  r  r  r  r  r  boolr  r  r   r  r  r   r  r  r  r   r  r  r%  re  r*  r6  __classcell__)rw  s   @rx  r2   r2      s)       }# } } } } } }~ ') 5 5S 5 5 5 5, -/ u u: u u u un+$v, + + + +B"+ "+ "+H+ + +._4 _F _ _ _ _B *, ; ;V ; ; ; ;. ?CQUdhqs WJ WJ WJ WJ3 WJ^a WJx|  ~B  yC WJ WJ WJ WJr2
 2
 2
4 2
 2
 2
 2
h <@d[] =? =? =?S =? =?bfglbm =? =? =? =?~^ ^ ^v ^ ^ ^ ^ ^@ @DB m mS m mS\ m m m m^ <> &5 &5s &5+ &5 &5 &5 &5P <@ 7 7 7| 7 7 7 72
 
6 
[ 
 
 
 
B >BPTcgpr 1M 1Ms 1M# 1M]` 1M 1M 1M 1Mf
 
6 
 
 
 
" 9=4^bkm 3> 3># 3>S 3>X[ 3> 3> 3> 3>j
 
6 
 
 
 
2 =? 78 78 78 78 78 78r F    B 68 :3 :3 :3F :3 :3 :3 :3x 6:" =4 =47 =4 =4 =4 =4 =4~ :< 6; 6;S 6; 6; 6; 6; 6;p :>b 74 74w 74W 74 74 74 74rb b4 b b6 b b b bH *, u, u, u, u, u, u,nj) j) j) j) j)X FJX\eg ;R ;R3 ;Rs ;RRU ;Rlpqylz ;R ;R ;R ;Rz 8<B [8 [8W [84PX> [8 [8 [8 [8z 8: R2 R23 R2 R2 R2 R2hw wt wV w w w wr eg 
S 
S# 
SY 
SV[ 
S 
S 
S 
S XZ 	T 	Tc 	T 	T 	T 	T 	T Y[ 	U 	Us 	U% 	U 	U 	U 	U os{} z, z,3 z,i z,y z,Z_ z,hk z, z, z, z,x mqy{ B0 B0 B0I B0Y B0X] B0fi B0 B0 B0 B0H FH _1 _1$|*< _1 _1 _1 _1B	3 	3 	3	3S 	3 	3 	3 	3k k kv k k k k kZ: : : : : 9=R m/ m/S m/# m/ m/ m/ m/^ 59 N) N)c N) N) N) N)` AER c* c*tCy c*# c* c* c* c*J BD & &S & & & &P 8<B j/ j/C j/ j/ j/ j/ j/X 04$UYbd U? U? U?C U?s U?imnsit U? U? U? U?n 59tZ^gi s? s?c s? s?TW s?nrsxny s? s? s? s?j 7;\`ik : : :3 :VY :ptuzp{ : : : :* 9=4^bkm < <# <S <X[ < < < <* DHVZimvx }? }?S }?PS }?cf }? }? }? }?~ ac 5
 5
3 5
 5
C 5
TW 5
gt 5
 5
 5
 5
n 154VZce <B <B# <BS <BPS <Bjno|j} <B <B <B <B|
 
t 
x 
= 
 
 
 
.:C :C : : : : JL )0 )0S )0PTUcPd )0 )0 )0 )0V =? > > >> > > > >4
 
h 
R` 
 
 
 
4 04$UYbd )I )I )IC )Is )Iimnyiz )I )I )I )IV 37TX\eg +I +IC +Is +IRU +Ilpq|l} +I +I +I +IZ[
 [
T [
X [
Q\ [
 [
 [
 [
z:s : : : :& DHPR  ]  ]  ]S  ]  ]  ]  ]D CE S Ss SE SI[ S S S S FH S S# Su SL^ S S S S CE  @  @s  @E  @I[  @  @  @  @D
 
d 
F 
N` 
 
 
 
. 8: 81 813 81h 81 81 81 81t$
 $
t $
V $
x $
 $
 $
 $
L ?C2 +[ +[3 +[ +[ +[ +[ +[z 37TX\eg BF BFC BFs BFRU BF BF BF BFH     @ BFb # #w # # # #* QU]_ 2, 2,3 2, 2, 2,# 2,do 2, 2, 2, 2,h  $ 9=4^bkm ^K ^K# ^KS ^KX[ ^K ^K ^K ^K@' 'V ' ' ' 'R CGr C. C.3 C.i C.V[ C. C. C. C.J 02 : :d8n : : : :x 7;2 
 
 
 
 
 
8 CGr Z Zd ZC Z Z Z Z: fjx|  FH F. F.3 F. F.9 F.I F._b F.ru F.  MR F. F. F. F.P ;= ,4 ,4c ,4 ,4 ,4 ,4 ,4\
 
D 
* 
 
 
 
 ;= @: @:c @:AT @: @: @: @:D
 
T 
6 
EX 
 
 
 
"  @ EG $> $> $>4P\K] $> $> $> $>L  $|J\    @ "*%DW[ 4P 4P 4P 4Pl# # #-t - - - - - -c 3 S # X\ dg        ry  r2   )9 ccxt.async_support.base.exchanger   ccxt.abstract.bingxr   r  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   r    typingr!   ccxt.base.errorsr"   r#   r$   r%   r&   r'   r(   r)   r*   r+   r,   r-   r.   ccxt.base.decimal_to_precisionr/   ccxt.base.preciser0   r2    ry  rx  <module>rG     s   6 5 5 5 5 5 + + + + + +    L  L  L  L  L  L  L  L  L  L  L  L  L  L  L  L  L  L  L  L  L  L  L  L  L  L  L  L  L  L  L  L  L  L  L  L  L  L  L  L  L  L  L  L  L  L  L  L  L  L  L  L  L  L  L  L  L  L  L  L       * * * * * * 0 0 0 0 0 0 - - - - - - - - - - - - . . . . . . ' ' ' ' ' ' & & & & & & . . . . . . ) ) ) ) ) ) * * * * * * ) ) ) ) ) ) , , , , , , + + + + + + 4 4 4 4 4 4 % % % % % %pf pf pf pf pfHk pf pf pf pf pfry  