
    iy.	                       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#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l'm4Z4 d dl'm5Z5 d dl'm6Z6 d dl'm7Z7 d dl'm8Z8 d dl'm9Z9 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lAmBZB  G d d ee          ZCdS )!    )Exchange)ImplicitAPIN)Balances
Conversion
CurrenciesCurrencyGreeksIntLeverage	Leverages
MarginModeMarginModesMarginModificationMarketMarketInterfaceNumOptionOrder	OrderBookOrderRequest	OrderSide	OrderTypeStrStringsTickerTickersTradeTradingFeeInterfaceTradingFeesTransactionTransferEntry)List)ExchangeError)AuthenticationError)PermissionDenied)AccountSuspended)ArgumentsRequired)
BadRequest)	BadSymbol)OperationRejected)MarginModeAlreadySet)BadResponse)InsufficientFunds)InvalidOrder)OrderNotFound)OrderImmediatelyFillable)OrderNotFillable)NotSupported)OperationFailed)DDoSProtection)RateLimitExceeded)OnMaintenance)InvalidNonce)RequestTimeout)TRUNCATE)DECIMAL_PLACES)Precisec                       e Zd Z fdZddededefdZddededefdZdef fd	Z	d
efdZ
d
edefdZddededededef
 fdZd ZddZd Zi fdZi fdefdZi fdee         fdZdefdZd ZddefdZi fdefdZdi fd
ededefdZddedefdZ i fd Z!i fd
edefd!Z"di fd"e#fd#Z$di fd"e#fd$Z%dd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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.di fd-ed
ede/d.e0d/e1d0e2fd1Z3di fd-ed
ede/d.e0d/e1d0e2fd2Z4di fd-ed
ede/d.e0d/e1d0e2fd3Z5ddi fd-ed
ede/d.e0d/e2d0e2fd4Z6d5 Z7ddede8fd6Z9i fd7ee:         fd8Z;di fd
ede/d.e0d/e1d0e2f
d9Z<di fd
ede/d.e0d/e1d0e2f
d:Z=i fd
ed.e0d;e1fd<Z>i fd
ed;e1fd=Z?i fd
ed;e1fd>Z@di fd-ed
efd?ZAdddi fd
ed)ededee8         fd@ZBdddi fd
ed)ededee8         fdAZCdi fd-ed
efdBZDdddi fd
ed)ededee8         fdCZEdddi fd
ed)edefdDZFdddi fd
ed)ededee8         fdEZGdi fd-ed
efdFZHdi fd
efdGZIdi fdHee         d
efdIZJdddi fd-ed
ed)edefdJZKdddi fd
ed)edefdKZLdddi fd
ed)edefdLZMddefdMZNdddi fdNed)ededeeO         fdOZPdddi fdNed)ededeeO         fdPZQddQZRddReSdeOfdSZTdT ZUddReSfdUZVddefdVZWi fdNed/e1dWedXedeXf
dYZYdddi fdNed)edefdZZZi fdNefd[Z[di fd\ee         fd]Z\di fd\e#fd^Z]ddReSfd_Z^di fdNed/e1fd`Z_ddede`fdaZai fd
ede`fdbZbi fdecfdcZdi fdNefddZei fd
efdeZfdddi fd
ed)edefdfZgdi fd"e#fdgZhddefdhZiddiZjddefdjZkddefdkZldi fdlZmdi fd"e#fdmZnddefdnZoi fd
efdoZpdi fd"e#fdpZqddefdqZrdi fd"e#fdrZsdi fd"e#fdsZtdi fd"e#fdtZudddi fd
ed)edefduZvdi fdved
efdwZwdi fdxed
efdyZxdi fdzed
efd{Zydi fd"ee         dezfd|Z{dde|fd}Z}dddi fd
ed)edefd~Z~dddi fd
ed)edefdZd Zd Zdi fd-edNefdZdddi fdNed)edefdZddReSfdZd Zddi ddfdZd Zd Zi fdZddi ddi fdZi fd
efdZddedefdZi fd
edefdZi fd
edefdZi fdNefdZddi fdNed)edefdZd ZddReSfdZi fdNefdZi fdZi fd-efdZddddi fdNed
ed)edefdZddefdZi fdNefdZi fd
edNefdZi fdNed/e1fdZi fd
edNed/e1fdZddReSfdZdddi fd
ed)edefdZi fd
efdZddefdZdddi fd
ed)edefdZddefdZi fd
edefdZddefdZdi fd"e#fdZdi fd
efdZdi fd"ee         defdZddefdZi fd
edefdZddReSdefdZddddi fd
eded)e2de2dee         f
dZi fdefdZdi fd-ededed/e2def
dZddeSdeSdefdZ xZS )binancec           '      k   |                      t          t          |                                           ddddgdddi dd ddd	dd
dddddddddddddddddddddddddddi ddddddddddddddd dd!dd"dd#dd$dd%dd&dd'dd(dd)di d*dd+dd,d d-dd.dd/dd0dd1dd2d3d4d3d5dd6d3d7dd8dd9dd:dd;di d<dd=dd>dd?dd@ddAddBd3dCddDddEddFddGddHddIddJddKddLdi dMddNddOddPd3dQddRddSddTddUd3dVddWd3dXddYddZdd[dd\dd]di d^dd_dd`ddaddbddcdddddeddfddgddhddiddjddkddlddmddndi doddpddqddrddsddtdduddvd3dwd3dxddyddzdd{dd|dd}dd~ddddddddddddddddi dddddddddddddddddddddddddddddddddddddddddddd
i ddddddddddddddddddddddddddddddddddddddddddgdddi di ddddÓddœddœddddddœdd˓ddœddddddddddғddԓdd֓dd֓i ddœddœddœddœddddddddœddœddddœddddddœddddœddœi ddœddddddœddddœdddddddddddddddddd˓ddddddd d˓i dd˓dddddddddd	d
d	ddddddddddddddddddddi ddddddddddddddd dœd!dd"d#d$dœd%dœd&dœd'dd(dd)dd*d+i d,dғd-dd.dd/d˓d0dd1dd2dd3dd4dd5dd6dœd7dd8dœd9dd:dd;dœd<dœi d=dd>dœd?dd@ddAddBdœdCdDdEddFddGdÓdHddIdDdJdDdKddLdDdMdNdOdDi dPddQddRddSddTddUddVddWddXddYddZd[d\d[d]d[d^d[d_d[d`d[dad[i dbd[dcd[ddddeddfddgddhddiddjddkddlddmddŐdndoddpdqdrddsdqdtdqi dudqdvdwdxdwdyddzdd{dd|dd}dœd~dœddœddœddœddœddœddœddœddœi ddœddœddœddœddœddœddœddœddœddœddœddœddœddœddddddi ddddddddddddddddddddddddddddddddddi ddddddddddddddddddddddddddddddddddi dddd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[ddddd͜i dΐdϓdddΐdѓddddԓddddddғd,dғddddddғdddddߐdؓdِdؓddi ddddғddړdېdܓd5dddddғddddddd9ddddddAdddddddi ddddd ddddddddddddrdddwddddd~dœddœddœddœddœi ddœddœddœddœddœddœddœddœddœddœddœddœddœddœddœddœddœi ddœddddddddd ddddddddddd[dd[dd[ddd	dd
dddi dddddddddddddddddddddddddddd֓dddddddddddddddd[d[ddddddddNdNddddddddd d!dd[dddddddddd"
d[ddddd#d$dd%dDid&did$dd'd%dDiidd'i d(dœd)dœd*dœd+dddgd,dgd-dgd.dggd/d0dd1dd2dd3d˓d4dœd5dŐd6dgd7dgd.dgd8dggd/d9dŐd6dgd7dgd.dgd8dggd/d:dŐd6dgd7dgd.dgd8dggd/d;dŐd6dgd7dgd.dgd8dggd/d<dŐd6dgd7dgd.dgd8dggd/d=dŐdd>d?ddd>d@ddd>ddŐdAidd'dddddddŐdBidi dCddDdœdEdœdFdœdGddd>dHddd>dIdœdJddKdœdLdœdMddd>dNddOdœdPddd>dQddRddSdddddTdŐdUddddddŐdVddddWddddŐdXd!dd'dOdiidd'i d(dœd)dœd*dœd+dddgd,dgd-dgd.dggd/d0dd1dd2dd5dŐd6dgd7dgd.dgd8dggd/d9dŐd6dgd7dgd.dgd8dggd/d;dŐd6dgd7dgd.dgd8dggd/d:dŐd6dgd7dgd.dgd8dggd/d4dœdYdœd3dœd=dŐdd>d?ddd>d@ddd>ddddːd>dddːd>dŐdZidd'dddddddŐd[idi dPddd>dHddFdœdGdœdEdœdJddIddOdœdKdœdLddCddMddNddRdd\dœd]dœd^di d}dœd~dœddœd_dœd`dœdadœdbdœdcdœdQdddddDdœdSd.ded˓dfd.dgd˓dhd.did˓ddddŐdUddddddŐdjddddWddddŐdkd!dd'd?dliidd'dddŐdmidd'dddddddddddddniddddŐdd>ddddddddddŐdodddddddːdpdqdidddddŐdrd!ddsdsdŐd,dgd-dgd.dgdtdggd/dduddudududvd>dudvd>dwdudwd>dudwd>dUdudxdduidduidduidyddUdzdwdwdzdvd>dUdUdUd{dUdUdUd|dsdsdsdsdsdsdsd}dsdsdsd~ddi d(dœddœddœddœddddœddœddœddddœddddœddddœddddœddi dddddd,dddd,dddddIddJdddddddddœddddddddi ddœddœddœddddddœdddddd˓dd˓ddœdddddddddddddddi ddœddœddœddœdߐddddddِdddœddœddœddœdddddddddqdœddidqdiddddddddddddŐdd!id'dd|                     d          |                     d          ddddd|                     d          |                     d          |                     d          |                     d          g|                     d          |                     d          g|                     d          |                     d          g|                     d          |                     d¦          g|                     dæ          |                     dĦ          g|                     dŦ          |                     dƦ          g|                     dǦ          |                     dȦ          g|                     dɦ          |                     dʦ          g|                     d˦          |                     d          g|                     d̦          |                     dͦ          gg
|                     d          |                     d          g|                     d          |                     dΦ          g|                     d          |                     dϦ          g|                     d          |                     dЦ          g|                     dæ          |                     dѦ          g|                     dŦ          |                     dҦ          g|                     dǦ          |                     dӦ          g|                     dɦ          |                     dԦ          g|                     d˦          |                     dզ          g|                     d̦          |                     d          gg
d֜dלidddd|                     d٦          |                     dѦ          |                     d          |                     d٦          g|                     d          |                     dڦ          g|                     d          |                     d          g|                     d          |                     dĦ          g|                     dæ          |                     dȦ          g|                     dŦ          |                     dۦ          g|                     dǦ          |                     dۦ          g|                     dɦ          |                     dۦ          g|                     d˦          |                     dۦ          g|                     d̦          |                     dۦ          gg
|                     d          |                     dѦ          g|                     d          |                     dҦ          g|                     d          |                     dܦ          g|                     d          |                     dݦ          g|                     dæ          |                     d          g|                     dŦ          |                     dަ          g|                     dǦ          |                     dߦ          g|                     dɦ          |                     d          g|                     d˦          |                     d          g|                     d̦          |                     d          gg
d֜dלii ddddt
          i dddXg dd;ddddddd dddddddkdLdd8ddldddddddd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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/d0d1d2d3d4d5d6d7d8d9d:d;d<d=d>d?d@dAdBdCdDdEdFdGdHdIdJdKdLdMdNdOi dPdQdRdSdTdUdVdWdXdYdZd[d\d]d^d_d`dadbdcdddedfdgdhdidjdkdldmdndodpdqi drdsdtdudvdwdxdydzd{d|d}d~dddddddddddddddddddddi dddddddddddddddddddddddddddddddddd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/d0d1d2d3d4d5d6d7d8d9d:d;d<d=d>d?d@dAdBdCdDdEdFdGdHdIdJdKdLdMdNdOi dPdQdRdSdTdUdVdWdXdYdZd[d\d]d^d_d`dadbdcdddedfdgdhdidjdkdldmdndodpdqi drdsdtdudvdwdxdydzd{d|d}d~dddddddddddddddddddddi ddddddddddddddddddddddddddddddddddddddddddddiddidi ddddddddddddddddddddddddddddddddddddddddddddddddddϜdАdidќdi dt          dt          dt          dt          dt          dt          dt          dt          dt          dt          dt          dt          dt          dt          dt          dt          dt          i dt          dt          dt          dt          dt          dt          dt          dt          dt          dt          dt          dt          dt          dt          dt          dt          dt          i dt          dt          dt          dt          dt          dt          dt          dt          dt          dt          dt          d t          dt          dt          dt          dt          dt          i dt          dt          dt           d	t          d
t          dt          dt          dt"          dt          dt          dt          dt           dt          dt          dt          dt          dt          i dt          dt          dt          dt          dt          dt           dt          dt          dt          d t          d!t          d"t          d#t          d$t          d%t          d&t          d't          i d(t          d)t          d*t          d+t          d,t          d-t          d.t          d/t          d0t          d1t          d2t          d3t          d4t          d5t          d6t          d7t          d8t           i d9t           d:t           d;t           d<t           d=t           d>t           d?t           d@t           dAt           dBt           dCt           dDt          dEt           dFt           dGt           dHt           dIt           i dJt           dKt           dLt           dMt           dNt           dOt           dPt           dQt           dRt           dSt           dTt           dUt           dVt           dWt           dXt           dYt           dZt           i d[t           d\t           d]t           d^t           d_t           d`t           dat           dbt           dct           ddt           det           dft           dgt           dht           dit           djt           dkt           i dlt           dmt           dnt           dot           dpt           dqt           drt           dst           dtt           dut           dvt           dwt           dxt           dyt           dzt           d{t           d|t           i d}t           d~t           dt           dt           dt           dt           dt           dt           dt           dt           dt           dt           dt           dt           dt           dt           dt           i dt           dt           dt           dt           dt           dt           dt           dt           dt           dt           dt           dt           dt           dt          dt          dt          dt          i dt          dt          dt          dt          dt          dt          dt          dt          dt          dt          dt          dt          dt          dt          dt          dt          dt          i dt          dt"          dt          dt          dt          dt          dt          dt          dt          dt          dt          dt          dt          dt          dt          dt          dt          i dt          dt          dt          dt          dt          dt          dt          dt          dt          dt          dt          dt          dt          dt          dt          dt          dt          i dt          dt          dt          dt          dt          dt          dt          dt          dt          dt          dt          dt          dt          dt          dt          dt          dt          i dt          dt"          dt          dt          dt          dt          dt          dt          dt          dt          dt          dt          dt          dt          dt          dt          dt          t          t          t          t          t          t          t          t          t          t          d
idi dt          dt          dt          dt          dt          dt          dt          dt          dt          dt          dt          dt          dt          dt          d t          dt          dt          i dt$          dt          dt          dt          dt          dt          dt          dt          dGt          dHt          dIt          dJt          dMt          dNt          dOt          dPt          dQt          i dRt          dSt          dTt          dUt          dVt          dWt          dXt          dYt          d]t          d_t          d`t          dwt          dxt          d{t          dt          dt          dt          i dt          d	t          d
t          dt          dt          dt          dt          dt          dt          dt          dt          dt          dt          dt          dt          dt          dt          i dt          dt          dt          dt          dt          dt          dt          dt&          dt&          d t          d!t          d"t          d#t          d$t          d%t          d&t          d't          t          t          d(idi dt          dt          dt          dt          dt          dt          d)t          dt          dt          d t          dt          dt          dt$          dt          dt          dt          dt          i dt          dt          dt          d^t          d_t          d`t          dat          d*t          dtt          d+t          dut          dvt          dt          d,t          d-t          d.t          d/t          t          t          t          t          t          t          t          t          t          t          t          t          d0idi d1t           dt           d2t           d3t           dt"          d4t           d5t           dt           d6t           d7t           d)t          d8t          dt          d9t           d t          dt          dt          i dt           dt           dt           dt           dt           dt           dt           dt           dt           dt           dt           dt           dt           dt           dt           dt           dt           i d t           d!t           d"t           d#t           d$t           d't           d(t           d)t           d*t           d+t           d,t           d-t           d.t           d/t           d0t           d1t           d2t           i d3t           d4t           d5t           d6t           d7t           d8t           d9t           d:t           d;t           d<t           d=t           d>t           d@t           dAt           dBt           dCt           dDt           i dEt           dFt           dGt           dHt           dIt           dJt           dKt           dLt           dMt           dNt           dOt           dPt           dQt           dRt           dSt           dTt           dUt           i dVt           dWt           dXt           dYt           dZt           d[t           d\t           d]t           d^t           d_t           d`t           dat           dbt           dct           ddt           det           dft           i dgt           dht           dit           djt           dkt           dlt           dmt           dnt           dot           dpt           dqt           drt           dst           dtt           dut           dvt           dwt           i dxt           dyt           dzt           d{t           d|t           d}t           d~t           dt           dt           dt           dt           dt           dt           dt           dt           dt           dt           i dt           dt           dt           dt           dt           dt           dt           dt           dt           dt           dt           dt           dt           dt           dt           dt           dt           t           t           t           t           t           t           t           t           t           t           d:
idi dt          dt          dt          dt          dt          dt          d)t          dt          dt          d t          dt          dt&          dt$          dt          dt          dt          dt          i dt          dt          dt          dGt          dHt          dIt          dJt          dMt          dNt          dOt          dPt          dQt          dRt          dSt          dTt          dUt          dVt          i dWt          dXt          dYt          d]t          d^t          d_t          d`t          dwt          dxt          d{t          dt          dt          dt          dt          d;t          d	t          d
t          i dt          dt          dt&          dt&          d<t           d=t           d>t           d?t           d@t           dAt           dBt           dCt           dDt           dt          dEt          dFt          dGt          t          t          t          dHii dIt          dJt          dKt          d1t"          dt          d2t          d3t(          d4t          d5t          dLt          dMt"          dNt          dOt          dPt*          dQt          dRt          dSt          i dTt          dUt          dVt          dWt          dXt          dt          dYt          d6t          d7t          dZt          d[t          d\t          d]t          d^t          d_t          d`t          dat          i dbt          d)t          dct          ddt          d9t,          det,          dft          dgt          dt          d	t          d
t          dt          dt          dt          dt          dt          dt          i dt          dt          dt          dt          dt          dt          dt          dt          dt          dt          dt          dt          dt          dt          dt          d t          d!t          i d"t          d#t          d$t          d%t          d&t          d't          d(t          d)t          d4t          d5t          d6t          d7t          d8t          d9t          d:t          d;t          d<t          i d=t          d>t          d?t          d@t          dAt          dBt          dCt          dDt          dEt          dFt          dKt          dLt          dZt          d[t          d\t          d^t          dnt          i dt          dt          dt          dt          dt$          d<t          d=t          d>t          d?t          d@t          dAt          dBt          dCt          dDt          dht.          dit          djt          i dkt          dlt$          dmt$          dnt$          dot          dpt          dqt          drt          dst          dtt"          dut          dvt          dwt          dxt          dyt          dzt          t          t          d{d|d}          S (~  Nr=   BinanceJPMT2   TCORSspotmarginswapfutureoption	addMarginborrowCrossMarginborrowIsolatedMargincancelAllOrderscancelOrdercancelOrderscloseAllPositionsFclosePositioncreateConvertTradecreateDepositAddresscreateLimitBuyOrdercreateLimitSellOrdercreateMarketBuyOrdercreateMarketBuyOrderWithCostcreateMarketOrderWithCostcreateMarketSellOrdercreateMarketSellOrderWithCostcreateOrdercreateOrders$createOrderWithTakeProfitAndStopLosscreatePostOnlyOrdercreateReduceOnlyOrdercreateStopLimitOrdercreateStopLossOrdercreateStopMarketOrdercreateStopOrdercreateTakeProfitOrdercreateTrailingPercentOrdercreateTriggerOrder	editOrderfetchAccountsfetchBalancefetchBidsAsksfetchBorrowInterestfetchBorrowRateHistoriesfetchBorrowRateHistoryfetchCanceledAndClosedOrdersemulatedfetchCanceledOrdersfetchClosedOrderfetchClosedOrdersfetchConvertCurrenciesfetchConvertQuotefetchCrossBorrowRatefetchCrossBorrowRatesfetchCurrenciesfetchDepositfetchDepositAddressfetchDepositAddressesfetchDepositAddressesByNetworkfetchDepositsfetchDepositsWithdrawalsfetchDepositWithdrawFeefetchDepositWithdrawFeesfetchFundingHistoryfetchFundingRatefetchFundingRateHistoryfetchFundingRatesfetchGreeksfetchIndexOHLCVfetchIsolatedBorrowRatefetchIsolatedBorrowRatesfetchL3OrderBookfetchLastPricesfetchLedgerfetchLedgerEntryfetchLeveragefetchLeveragesfetchLeverageTiersfetchLiquidationsfetchMarginAdjustmentHistoryfetchMarginModefetchMarginModesfetchMarketLeverageTiersfetchMarketsfetchMarkOHLCVfetchMyLiquidationsfetchMySettlementHistoryfetchMyTrades
fetchOHLCVfetchOpenInterestfetchOpenInterestHistoryfetchOpenOrderfetchOpenOrdersfetchOptionfetchOptionChain
fetchOrderfetchOrderBookfetchOrderBooksfetchOrdersfetchOrderTradesfetchPositionfetchPositionModefetchPositionsfetchPositionsRiskfetchPremiumIndexOHLCVfetchSettlementHistoryfetchStatusfetchTickerfetchTickers	fetchTimefetchTradesfetchTradingFeefetchTradingFeesfetchTradingLimitsfetchTransactionFeefetchTransactionFeesfetchTransactionsfetchTransferfetchTransfersfetchUnderlyingAssetsfetchVolatilityHistoryfetchWithdrawAddressesfetchWithdrawal)fetchWithdrawalsfetchWithdrawalWhitelistreduceMarginrepayCrossMarginrepayIsolatedMarginsetLeverage	setMarginsetMarginModesetPositionModesignIntransferwithdraw1s1m3m5m15m30m1h2h4h6h8h12h1d3d1w1Mzchttps://user-images.githubusercontent.com/1294454/29604020-d5483cdc-87ee-11e7-94c7-d1a8d9169293.jpgz)https://testnet.binancefuture.com/dapi/v1z)https://testnet.binancefuture.com/dapi/v2z)https://testnet.binancefuture.com/fapi/v1z)https://testnet.binancefuture.com/fapi/v2z%https://testnet.binance.vision/api/v3z%https://testnet.binance.vision/api/v1)

dapiPublicdapiPrivatedapiPrivateV2
fapiPublicfapiPublicV2fapiPrivatefapiPrivateV2publicprivatev1sapizhttps://api.binance.com/sapi/v1sapiV2zhttps://api.binance.com/sapi/v2sapiV3zhttps://api.binance.com/sapi/v3sapiV4zhttps://api.binance.com/sapi/v4r   z https://dapi.binance.com/dapi/v1r   
eapiPublicz https://eapi.binance.com/eapi/v1eapiPrivater   z https://dapi.binance.com/dapi/v2dapiDataz%https://dapi.binance.com/futures/datar   z https://fapi.binance.com/fapi/v1r   z https://fapi.binance.com/fapi/v2r   fapiDataz%https://fapi.binance.com/futures/datar   r   zhttps://api.binance.com/api/v3r   zhttps://api.binance.com/api/v1z https://papi.binance.com/papi/v1)r   papizhttps://www.binance.comz5https://accounts.binance.com/en/register?ref=D7YA7CLYg?)urldiscountz.https://binance-docs.github.io/apidocs/spot/enz=https://www.binance.com/en/usercenter/settings/api-managementz'https://www.binance.com/en/fee/schedule)logotestapiwwwreferraldocapi_managementfeessystem/statusaccountSnapshot   zmargin/asset   zmargin/pairzmargin/allAssetszmargin/allPairszmargin/priceIndexzspot/delist-schedule
   zasset/assetDividendzasset/dribbletzasset/transferzasset/assetDetailzasset/tradeFeez.asset/ledger-transfer/cloud-mining/queryByPageg9m4 @z"asset/convert-transfer/queryByPagegoӟH?zasset/wallet/balance   zasset/custody/transfer-historyzmargin/borrow-repayzmargin/loanzmargin/repayzmargin/accountzmargin/transferzmargin/interestHistoryzmargin/forceLiquidationRecmargin/ordermargin/openOrderszmargin/allOrders   zmargin/myTradeszmargin/maxBorrowable   zmargin/maxTransferablezmargin/tradeCoeffzmargin/isolated/transfermargin/isolated/accountzmargin/isolated/pairzmargin/isolated/allPairszmargin/isolated/accountLimitzmargin/interestRateHistorymargin/orderListzmargin/allOrderListzmargin/openOrderListzmargin/crossMarginDatag      ?)costnoCoinzmargin/isolatedMarginDatazmargin/isolatedMarginTierzmargin/rateLimit/order   zmargin/dribbletzmargin/dustgK7A 4@z!margin/crossMarginCollateralRatiozmargin/exchange-small-liabilitygK=U?z'margin/exchange-small-liability-historyz margin/next-hourly-interest-ratezmargin/capital-flowzmargin/delist-schedulezmargin/available-inventoryg-!lV?zmargin/leverageBracketzloan/vip/loanable/data(   zloan/vip/collateral/datazloan/vip/request/datagK=U@zloan/vip/request/interestRatezloan/incomegK7A D@zloan/ongoing/orderszloan/ltv/adjustment/historyzloan/borrow/historyzloan/repay/historyzloan/loanable/datazloan/collateral/datazloan/repay/collateral/rateiX  loan/flexible/ongoing/orders   loan/flexible/borrow/historyloan/flexible/repay/history$loan/flexible/ltv/adjustment/historyzloan/vip/ongoing/orderszloan/vip/repay/historyzloan/vip/collateral/accountzfiat/ordersg
ףp=@zfiat/paymentszfutures/transferzfutures/histDataLinkzrebate/taxQuerygK7A T@zcapital/config/getallzcapital/deposit/addresszcapital/deposit/address/listzcapital/deposit/hisreczcapital/deposit/subAddresszcapital/deposit/subHisreczcapital/withdraw/historyi  z"capital/contract/convertible-coinszconvert/tradeFlowzconvert/exchangeInfozconvert/assetInfozconvert/orderStatuszconvert/limit/queryOpenOrderszaccount/statuszaccount/apiTradingStatusz%account/apiRestrictions/ipRestrictionbnbBurnsub-account/futures/account"sub-account/futures/accountSummary sub-account/futures/positionRiskz$sub-account/futures/internalTransferzsub-account/listzsub-account/margin/accountz!sub-account/margin/accountSummaryzsub-account/spotSummaryzsub-account/statusz sub-account/sub/transfer/historyz#sub-account/transfer/subUserHistoryzsub-account/universalTransferz8sub-account/apiRestrictions/ipRestriction/thirdPartyListz"sub-account/transaction-statisticsg'o|?'sub-account/subAccountApi/ipRestrictionzmanaged-subaccount/assetz"managed-subaccount/accountSnapshotz+managed-subaccount/queryTransLogForInvestorz.managed-subaccount/queryTransLogForTradeParentz%managed-subaccount/fetch-future-assetzmanaged-subaccount/marginAssetzmanaged-subaccount/infoz"managed-subaccount/deposit/addressgf/N{?z"managed-subaccount/query-trans-logzlending/daily/product/listzlending/daily/userLeftQuotaz!lending/daily/userRedemptionQuotazlending/daily/token/positionzlending/union/accountzlending/union/purchaseRecordzlending/union/redemptionRecordzlending/union/interestHistoryzlending/project/listzlending/project/position/listz&eth-staking/eth/history/stakingHistory   z)eth-staking/eth/history/redemptionHistoryz&eth-staking/eth/history/rewardsHistoryzeth-staking/eth/quotaz#eth-staking/eth/history/rateHistoryeth-staking/accountz%eth-staking/wbeth/history/wrapHistoryz'eth-staking/wbeth/history/unwrapHistoryz+eth-staking/eth/history/wbethRewardsHistoryzmining/pub/algoListzmining/pub/coinListzmining/worker/detailzmining/worker/listzmining/payment/listzmining/statistics/user/statuszmining/statistics/user/listzmining/payment/uidzbswap/poolszbswap/liquidity)r   noPoolIdzbswap/liquidityOpszbswap/quoteg9m4 ?z
bswap/swapzbswap/poolConfigurezbswap/addLiquidityPreviewzbswap/removeLiquidityPreviewzbswap/unclaimedRewardsg^I@zbswap/claimedHistoryzblvt/tokenInfozblvt/subscribe/recordzblvt/redeem/recordzblvt/userLimitzapiReferral/ifNewUserapiReferral/customizationapiReferral/userCustomizationzapiReferral/rebate/recentRecordz#apiReferral/rebate/historicalRecordz!apiReferral/kickback/recentRecordz%apiReferral/kickback/historicalRecordbroker/subAccountApizbroker/subAccountz'broker/subAccountApi/commission/futuresz+broker/subAccountApi/commission/coinFutureszbroker/infozbroker/transferzbroker/transfer/futureszbroker/rebate/recentRecordzbroker/rebate/historicalRecordz broker/subAccount/bnbBurn/statuszbroker/subAccount/depositHistzbroker/subAccount/spotSummaryzbroker/subAccount/marginSummaryz broker/subAccount/futuresSummaryz"broker/rebate/futures/recentRecordz"broker/subAccountApi/ipRestrictionzbroker/universalTransferzaccount/apiRestrictionsz#c2c/orderMatch/listUserOrderHistoryznft/history/transactionsznft/history/depositznft/history/withdrawznft/user/getAssetzpay/transactionszgiftcard/verifyz$giftcard/cryptography/rsa-public-keyzgiftcard/buyCode/token-limitzalgo/spot/openOrderszalgo/spot/historicalOrderszalgo/spot/subOrderszalgo/futures/openOrderszalgo/futures/historicalOrderszalgo/futures/subOrderszportfolio/accountzportfolio/collateralRatezportfolio/pmLoang^I
@zportfolio/interest-historyzportfolio/asset-index-pricezportfolio/repay-futures-switch   zportfolio/margin-asset-leveragezstaking/productListzstaking/positionzstaking/stakingRecordzstaking/personalLeftQuotaz%lending/auto-invest/target-asset/listz)lending/auto-invest/target-asset/roi/listzlending/auto-invest/all/assetz%lending/auto-invest/source-asset/listzlending/auto-invest/plan/listzlending/auto-invest/plan/idz lending/auto-invest/history/listzlending/auto-invest/index/infoz&lending/auto-invest/index/user-summaryz"lending/auto-invest/one-off/statusz"lending/auto-invest/redeem/historyz%lending/auto-invest/rebalance/historyzsimple-earn/flexible/listzsimple-earn/locked/listz&simple-earn/flexible/personalLeftQuotaz$simple-earn/locked/personalLeftQuotaz(simple-earn/flexible/subscriptionPreviewz&simple-earn/locked/subscriptionPreviewz(simple-earn/flexible/history/rateHistoryzsimple-earn/flexible/positionzsimple-earn/locked/positionzsimple-earn/accountz/simple-earn/flexible/history/subscriptionRecordz-simple-earn/locked/history/subscriptionRecordz-simple-earn/flexible/history/redemptionRecordz+simple-earn/locked/history/redemptionRecordz*simple-earn/flexible/history/rewardsRecord)z(simple-earn/locked/history/rewardsRecordz-simple-earn/flexible/history/collateralRecordzdci/product/listzdci/product/positionszdci/product/accounts
asset/dustgoӟH?zasset/dust-btcgUN @zasset/get-funding-assetzasset/convert-transferz!account/disableFastWithdrawSwitchz account/enableFastWithdrawSwitchcapital/withdraw/applyzcapital/deposit/credit-applygSc${?zmargin/order/ocog9m4  @zmargin/max-leveragei,  zsub-account/virtualSubAccountzsub-account/margin/transferzsub-account/margin/enablezsub-account/futures/enablezsub-account/futures/transferzsub-account/transfer/subToSubz sub-account/transfer/subToMasterzsub-account/options/enablezmanaged-subaccount/depositzmanaged-subaccount/withdrawuserDataStreamuserDataStream/isolatedz lending/customizedFixed/purchasezlending/daily/purchasezlending/daily/redeemzbswap/liquidityAdd<   zbswap/liquidityRemovezbswap/claimRewardszblvt/subscribezblvt/redeemzbroker/subAccount/marginzbroker/subAccount/futureszbroker/subAccountApi/permissionzbroker/subAccountApi/commissionzbroker/subAccount/bnbBurn/spotz(broker/subAccount/bnbBurn/marginInterestzbroker/subAccount/blvt)broker/subAccountApi/ipRestriction/ipListz1broker/subAccountApi/permission/universalTransferz.broker/subAccountApi/permission/vanillaOptionszgiftcard/createCodezgiftcard/redeemCodezgiftcard/buyCodezalgo/spot/newOrderTwapzalgo/futures/newOrderVpzalgo/futures/newOrderTwapzstaking/purchasezstaking/redeemzstaking/setAutoStakingeth-staking/eth/stakezeth-staking/eth/redeemzeth-staking/wbeth/wrapzmining/hash-transfer/configz"mining/hash-transfer/config/cancelzportfolio/repayzloan/vip/renewzloan/vip/borrowzloan/borrowz
loan/repayzloan/adjust/ltvzloan/customize/margin_callloan/flexible/repayloan/flexible/adjust/ltvzloan/vip/repayzconvert/getQuotegK=U?zconvert/acceptQuotezconvert/limit/placeOrderzconvert/limit/cancelOrderzportfolio/auto-collection   zportfolio/asset-collectionzportfolio/bnb-transferz(portfolio/repay-futures-negative-balance)zlending/auto-invest/plan/addzlending/auto-invest/plan/editz$lending/auto-invest/plan/edit-statuszlending/auto-invest/one-offzlending/auto-invest/redeemzsimple-earn/flexible/subscribezsimple-earn/locked/subscribezsimple-earn/flexible/redeemzsimple-earn/locked/redeemz%simple-earn/flexible/setAutoSubscribez#simple-earn/locked/setAutoSubscribezdci/product/subscribezdci/product/auto_compound/edit)r  r  )r   r   r   r   r  r  r  r  zalgo/spot/orderzalgo/futures/orderz.sub-account/subAccountApi/ipRestriction/ipList)getpostputdelete)
r  r
  r  r  r  r  r  r  zloan/flexible/loanable/datazloan/flexible/collateral/data)r  r  zloan/flexible/borrowr  r  )r  r   zsub-account/assetszasset/getUserAssetr  pingtimeexchangeInfodepthd       )r   byLimittradeshistoricalTrades	aggTradespremiumIndexfundingRateklinesc   i  i'  continuousKlinesindexPriceKlinesmarkPriceKlinespremiumIndexKlinesticker/24hr)r   noSymbolticker/priceticker/bookTicker)constituentsopenInterest)delivery-priceopenInterestHisttopLongShortAccountRatiotopLongShortPositionRatioglobalLongShortAccountRatiotakerBuySellVolbasispositionSide/dualorderAmendmentorder	openOrder
openOrders	allOrdersbalanceaccountzpositionMargin/historypositionRisk
userTradesincomeleverageBracketforceOrdersadlQuantilecommissionRateincome/asyn)income/asyn/idpmExchangeInfopmAccountInfo   )rC  rE  batchOrderscountdownCancelAllleverage
marginTypepositionMargin	listenKey)r\  rE  rW  )rE  allOpenOrdersrW  r\  fundingInfo)r;  	indexInfo
assetIndexr:  apiTradingStatus	lvtKlines)r<  r=  r>  r?  r@  takerlongshortRatiorB  rateLimit/orderra  multiAssetsMarginzapiReferral/traderNumzapiReferral/overviewzapiReferral/tradeVolzapiReferral/rebateVolzapiReferral/traderSummaryrU  rS  z
order/asynzorder/asyn/idz
trade/asynztrade/asyn/id)rW  rC  r[  rZ  rE  rY  r\  rX  re  r  r  )rW  rE  r]  r\  r   )rJ  rI  rK  )r#  r$  r%  indextickermarkr&  r0  r+  r,  exerciseHistoryr;  )rJ  positionrG  historyOrdersrL  exerciseRecordbillrR  rS  marginAccountmmprX  rE  )rE  rW  r\  mmpSetmmpResetrX  countdownCancelAllHeartBeatr\  )rE  rW  r]  allOpenOrdersByUnderlyingr\  g?i  g?   g?)r#  r$  r&  r+  r-  r,  r0  uiKlinesr6  rg  zticker/tradingDayr8  r9  r%  avgPrice)r  r!  r   r"  g333333?   )allOrderListopenOrderList	orderListrE  rG  rH  rJ  myTradesrd  myPreventedMatchesmyAllocationszaccount/commission)z	order/ocozorderList/oco	sor/orderzsor/order/testrE  zorder/cancelReplacez
order/test)rG  rz  rE  )r  r   r"  r   um/orderzum/openOrderzum/openOrderszum/allOrderscm/orderzcm/openOrderzcm/openOrderszcm/allOrderszum/conditional/openOrderzum/conditional/openOrderszum/conditional/orderHistoryzum/conditional/allOrderszcm/conditional/openOrderzcm/conditional/openOrderszcm/conditional/orderHistoryzcm/conditional/allOrderszmargin/maxWithdrawzum/positionRiskzcm/positionRiskzum/positionSide/dualzcm/positionSide/dualzum/userTradeszcm/userTradeszum/leverageBracketzcm/leverageBracketzmargin/forceOrderszum/forceOrderszcm/forceOrderszum/apiTradingStatuszum/commissionRatezcm/commissionRatezmargin/marginLoanzmargin/repayLoanzmargin/marginInterestHistoryz	um/incomez	cm/incomez
um/accountz
cm/accountzrepay-futures-switch)zum/adlQuantilezcm/adlQuantileum/conditional/ordercm/conditional/orderg]K=?
marginLoang9EGr?	repayLoang{Gz?zum/leveragezcm/leveragezauto-collectionzbnb-transferzrepay-futures-negative-balancezasset-collection)r  r  zum/allOpenOrderszum/conditional/allOpenOrdersr  r  zcm/allOpenOrderszcm/conditional/allOpenOrdersr   zmargin/allOpenOrdersr   r\  z0.001)feeSide	tierBased
percentagetakermakertradingquotez0.000400z0.00020002502500z0.0003507500z0.00032022500z0.00030050000z0.000270100000z0.000250200000z0.000220400000750000z0.000170z0.000160z0.000140z0.000120z0.000100z0.000080z0.000060z0.000040z0.000020)r  r  )r  r  r  r  r  tiersbasez0.000500z0.000450z0.000240z0.000050z	0.0000030z	-0.000050z	-0.000060z	-0.000070z	-0.000080z	-0.000090)r  linearinverserH   BCCYOYOW)r  YOYOsandboxModerD   r  r  defaultTimeInForceGTCdefaultTypedefaultSubType#hasAlreadyAuthenticatedSuccessfully"warnOnFetchOpenOrdersWithoutSymbolthrowMarginModeAlreadySet
recvWindowtimeDifferenceadjustForTimeDifferencenewOrderRespTypeFULL)marketlimitquoteOrderQtybroker
x-R4BD3S82
x-xcKtGhcu)rD   rE   rG   deliveryrF   rH   accountsByTypeMAINFUNDINGMARGINUMFUTURECMFUTUREOPTION)
mainrD   fundingrE   crossrG   r  r  r  rH   r  r  r  )r  r  r  r  r  r  ETHTRXBNBBSCOMNIEOSSOL)ERC20TRC20BEP2BEP20r  r  SPLztronscan.orgr  zetherscan.ior  zbscscan.comzexplorer.binance.orgr  zbithomp.comXRPzbloks.iozstellar.expertXLMzblockchair.com/bitcoinBTCzblockchair.com/bitcoin-cashBCHzblockchair.com/ecashXECzexplorer.litecoin.netLTCzexplorer.avax.networkAVAXz
solscan.iozpolkadot.subscan.ioDOTzdashboard.internetcomputer.orgICPzexplorer.chiliz.comCHZzcardanoscan.ioADAzmainnet.theoan.comAIONzalgoexplorer.ioALGOzexplorer.ambrosus.comAMBzviewblock.io/zilliqaZILzviewblock.io/arweaveARzexplorer.ark.ioARKzatomscan.comATOMzwww.mintscan.ioCTKzexplorer.bitcoindiamond.orgBCDzbtgexplorer.comBTGzbts.aiBTSzexplorer.celo.orgCELOzexplorer.nervos.orgCKBzcerebro.cortexlabs.aiCTXCzchainz.cryptoid.infoVIAzexplorer.dcrdata.orgDCRzdigiexplorer.infoDGBzdock.subscan.ioDOCKzdogechain.infoDOGEzexplorer.elrond.comEGLDzblockscout.comETCzexplore-fetchhub.fetch.aiFETzfilfox.infoFILzfio.bloks.ioFIOzexplorer.firo.orgFIROz
neoscan.ioNEOzftmscan.comFTMzexplorer.gochain.ioGOzblock.gxb.ioGXSzhash-hash.infoHBARzwww.hiveblockexplorer.comHIVEzexplorer.helium.comHNTztracker.icon.foundationICXzwww.iostabc.comIOSTzexplorer.iota.orgIOTAziotexscan.ioIOTXzirishub.iobscan.ioIRISzkava.mintscan.ioKAVAzscope.klaytn.comKLAYzkmdexplorer.ioKMDzkusama.subscan.ioKSMzexplorer.lto.networkLTOzpolygonscan.comPOLYGONzexplorer.ont.ioONTzminaexplorer.comMINAznanolooker.comNANOzexplorer.nebulas.ioNASzexplorer.nbs.plusNBSzexplorer.nebl.ioNEBLz
nulscan.ioNULSz
nxscan.comNXSzexplorer.harmony.oneONEzexplorer.poa.networkPOAz	qtum.infoQTUMzexplorer.rsk.coRSKzwww.oasisscan.comROSEzravencoin.networkRVNzsc.tokenview.comSCzsecretnodes.comSCRTzexplorer.skycoin.comSKYzsteemscan.comSTEEMzexplorer.stacks.coSTXzwww.thetascan.ioTHETAzscan.tomochain.comTOMOzexplore.vechain.orgVETzexplorer.vite.netVITEzwww.wanscan.orgWANzwavesexplorer.comWAVESWAXPWTCXEMXVGZECZEN)zwax.eosx.iozwaltonchain.prozchain.nem.ninjazverge-blockchain.infozexplorer.yoyow.orgzexplorer.zcha.inzexplorer.zensystem.ior  r  MXNUGXSEKCHFVNDAEDDKKKZTHUFPENPHPUSDTRYEURNGNPLNBRL)ZARKESARSRUBAUDNOKCZKGBPUAHGHSHKDCADINRJPYNZDBUSD)accountsByIdnetworksreverseNetworksnetworksByIdimpliedNetworks
legalMoneylegalMoneyCurrenciesByIdexactz-1004z-1008z-1099z-1108z-1131z-1134z-1135z-1145z-1151z-2008z-2016z-2021z-2022z-2026z-3000z-3001z-3002z-3003z-3004z-3005z-3006z-3007z-3008z-3009z-3010z-3011z-3012z-3013z-3014z-3015z-3016z-3017z-3018z-3019z-3020z-3021z-3022z-3023z-3024z-3025z-3026z-3027z-3028z-3029z-3036z-3037z-3038z-3041z-3042z-3043z-3044z-3045z-3999z-4000z-4001z-4002z-4003z-4004z-4005z-4006z-4007z-4008z-4009z-4010z-4011z-4012z-4013z-4014z-4015z-4016z-4017z-4018z-4019z-4020z-4021z-4022z-4023z-4024z-4025z-4026z-4027z-4028z-4029z-4030z-4031z-4032z-4033z-4034z-4035z-4036z-4037z-4038z-4039z-4040z-4041z-4042z-4043z-4044z-4045z-4046z-4047z-4048z-4049z-4050z-4051z-4052z-4053z-4054z-4055z-4056z-4057z-4058z-4059z-4060z-4061z-4062z-4063z-4064z-4065z-4066z-4067z-4068z-4069z-4070z-4071z-4072z-4073z-4074z-4075z-4076z-4077z-4078z-4079z-4080z-4081z-4082z-4083z-4084z-4085z-4086z-4087z-4088z-4089z-4091z-4092z-4093z-4094z-4095z-4096z-4097z-4098z-4099z-4101z-4102z-4103z-4104z-4105z-4106z-4107z-4108z-4109z-4110z-4112z-4113z-4114z-4115z-4116z-4117z-4118z-4119z-4120z-4121z-4122z-4123z-4124z-4125z-4126z-4127z-4128z-4129z-4130z-4131z-4132z-4133z-4134z-4135z-4136z-4137z-4138z-4139z-4141z-4142z-4143z-4144z-4145z-4146z-4147z-4148z-4149-4150z-5001z-5002z-5003z-5004z-5005z-5006z-5007z-5008z-5009z-5010z-5011z-5012z-5013z-5021z-5022z-6001z-6003z-6004z-6005z-6006z-6007z-6008z-6009z-6011z-6012z-6013z-6014z-6015z-6016z-6017z-6018z-6019z-6020z-7001z-7002z-10001z-10002z-10005z-10007z-10008z-10009z-10010z-10011z-10012z-10013z-10015z-10016z-10017z-10018z-10019z-10020z-10021z-10022z-10023z-10024z-10025z-10026z-10028z-10029z-10030z-10031z-10032z-10034z-10039z-10040z-10041z-10042z-10043z-10044z-10045z-10046z-10047z-11008z-12014z-13000z-13001z-13002z-13003z-13004z-13005z-13006z-13007z-18002z-18003z-18004z-18005z-18006z-18007z-21001)
-21002-21003-21004-21005-21006-21007z-32603400002	100001003	200003903z-1005z-1011z-1023z-1109z-1110z-1113z-1122z-1126z-1136z-2012z-2017z-2018z-2019z-2020z-2023z-2024z-2025z-2027z-2028z-4140z-4164z-4165z-4167z-4168z-4169z-4170z-4171z-4172z-4183z-4184-4192-4202z-4203z-4205z-4206z-4208z-4209z-4210z-4211z-4400z-4401z-4402z-4403z-5024z-5025z-5026z-5027z-5028z-5037z-5038z-5039)z-5040z-5041z-1128z-4090z-4111z-4151z-4152z-4154z-4155)z-4178z-4188rQ  z-4194z-4195z-4196z-4197z-4198z-4199z-4200z-4201rR  z-1003z-1006z-1007z-1010z-1013z-1112z-1114z-1129z-2011)
rG  -20121-20124-20130-20132-20194-20195-20196-20198-20204z-4161rS  rT  rU  rV  rW  rX  rY  rZ  r[  rH  rI  rJ  )rK  rL  rM  z-1000z-1001z-1002z-1014z-1015z-1016z-1020z-1021z-1022z-1100z-1101z-1102z-1103z-1104z-1105z-1106z-1111z-1115z-1116z-1117z-1118z-1119z-1120z-1121z-1125z-1127z-1130z-2010z-2013z-2014-2015zSystem is under maintenance.zSystem abnormalityz/You are not authorized to execute self request.zAPI key does not existz Order would trigger immediately.z%Stop price would trigger immediately.z'Order would immediately match and take.z6Account has insufficient balance for requested action.z Rest API trading is not enabled.z,This account may not place or cancel orders.zYou don't have permission.zMarket is closed.z*Too many requests. Please try again later.z(This action is disabled on self account.z(Limit orders require GTC for self phase.z=This order type is not hasattr(self, possible) trading phase.z9This type of sub-account exceeds the maximum number limitz+This symbol is restricted for self account.z.This symbol is not permitted for self account.)zhas no operation privilegeMAX_POSITION)rD   r  r  rH   portfolioMarginrF  broad)idname	countries	rateLimit	certifiedprohas
timeframesurlsr   r   commonCurrenciesprecisionModeoptions
exceptions)deep_extendsuperr=   describeparse_numberr:   r3   r$   r(   r)   r*   r,   r.   r&   r-   r%   r#   r5   r0   r1   r8   r7   r/   r6   )self	__class__s    `/var/www/html/crypto-bot/backend/venv/lib/python3.11/site-packages/ccxt/async_support/binance.pyro  zbinance.describe*   skq   gt 4 4 = = ? ?DDD $D 	D
 $D $D TD $TD 'D "4D tD D $UD  D %dD  '!D" &t#D D$ '%D& ''D( /)D* ,T+D, (-D. 0/D0 t1D2 3D4 75D6 &t7D8 (9D: ';D< &t=D> (?D@ "4ADB (CDD -dED D DF %dGDH TIDJ  KDL MDN  ODP &tQDR +ESDT )$UDV /
WDX &zYDZ #E[D\ $Z]D^ )$_D` $UaDb 'cDd (eDf "4gD D Dh iDj &tkDl (mDn 1%oDp  qDr +EsDt *:uDv +DwDx &tyDz #D{D| *4}D~ $TD@ tADB "4CDD *5EDF +EGDH #EID D DJ "4KDL tMDN #DODP  QDR !$SDT %dUDV $UWDX /YDZ ":[D\ #D]D^ +J_D` aDb !$cDd &teDf +DgDh  iDj dkD D Dl $TmDn +DoDp !$qDr "4sDt tuDv #EwDx dyDz !${D| "5}D~ tD@ #DADB  CDD $TEDF !$GDH %dIDJ )%KDL )$MD D DN tODP tQDR SDT TUDV tWDX "4YDZ #D[D\ %j]D^ &z_D` 'aDb $UcDd  eDf !$gDh (iDj )%kDl )%mDn "5oD Dp %),1 $$('+#"!%#'  GD D DJdd d d	
 u u d d d d d u d d d  d!& ~"M#N%P"M$O#N%PEFA =? ? ?	
 !"D "#E !"D "#E $%G  G !"D #$F "#E  G $%G  >!" ?#$ ;>'  * 1R # 
 E #bAY- -\ZE'E *3E '	E
 &qE +CE *3E ,QE /E .qE )#E )#E ,SE )#E  I&!E" =h#E$ /%E& 9!'E E( .q)E* &q+E, '-E. )!/E0 *31E2 1#3E4 5c5E6 '7E8 ,Q9E: +B;E< *1=E> /?E@ 1!AEB ,QCED 3CEEF 21GEH /IE E EJ 3AKEL 7MEN 5cOEP +AQER .rSET /UEV 13#2N2NWEX 4cQ5O5OYEZ 4S[E\ 1!]E^ *3_E` &vaEb <RcEd :6eEf B6gEh ;FiEj .rkE E El 1"mEn 5foEp 1#qEr 1"sEt 3BuEv 0wEx 8yEz &v{E| .r}E~ 6rE@ .rAEB -bCED -bEEF /GEH 5cIEJ 7KEL 7ME E EN 6rOEP ?QER 22SET 1"UEV 6sWEX &vYEZ ([E\ +A]E^ /_E` *6aEd 0eEf 21gEh 7iEj 1#kEl 5cmEn 4SoEp 3DqE E Er =fsEt ,VuEv /wEx ,RyEz .v{E| 8}E~ )#E@ 3CAEB @CED "3EEF 6qGEH =cIEJ ;AKEL ?MEN +COEP 5aQER <QSE E ET 23UEV -aWEX ;CYEZ >s[E\ 8]E^ STU_E` =gaEb B6cEd 3CeEf =cgEh FsiEj I'kEl @mEn 9#oEp 27qEr =hsEt =guE E Ex 5cyEz 6s{E| <S}E~ 7E@ 0AEB 7CED 9#EEF 8GEH /IEJ 8KEN A"OEP DRQER A"SET 0UEV >rWEX .rYEZ @[E E E\ B2]E^ Fr_Eb .scEd .seEf /gEh -ciEj .skEl 8mEn 6soEp -cqEt &suEv *CQ+G+GwEx -fyEz &w{E| %f}E~ .wE@ 4WAE E EB 7CED 1%EEF /GEJ )#KEL 0MEN -cOEP )#QET 0UEV 4QWEX 8YEZ :1[E\ >q]E^ <Q_E` @aEd /eEf ,QgEh B1iE E Ej FqkEl &qmEn *1oEp 21qEr 5asEt 9!uEv ;AwEx 8yEz 8{E| :1}E~ ;AE@ =aAEB =aCED 3AEEJ 23KEN >sOER 3FSE E ET .vUEV /WEX ,VYEZ +F[E\ *3]E^ ?_E` 7aEb /cEd 5ceEf .sgEh 23iEj 8kEl 1#mEn ,SoEp 3AqEr +FsEt 5fuE E Ev 6swEx 9!yEz :1{E~ .sE@ +CAEB 0CED 4SEEF @GEH DSIEJ 8KEL @MEN 8OEP 6sQER ;CSET 9#UEV A#WEX =cYE E EZ =c[E\ @]E` 4RaEb 22cEd A"eEf ?gEh CBiEj A"kEl CBmEn 8oEp 6rqEr .rsEt J2uEv HwEx HyEz Fr{E| Eb}E E~ EGIL,/1403IE E ELA$gA(#A )&A 23	A
 1(A <SA ;CA 1&A =fA 7A .vA *6A &vA  '!A" '#A$ +H%A& &v'A A( :6)A, 3F-A. 26/A0 .s1A2 "33A4 85A6 6v7A8 4S9A: 5c;A< 7=A> ??A@ 8AAB ;CCAD 8EAF 5cGAH 5cIAJ 6sKA A AL )#MAN 23OAP +CQAT ;CUAV 1#WAX /YA\ -b]A^ 0_A` %baAb -ecAf )#gAh &siAl 4QmAn 8oAp >qqAr @sAt ,QuA A Av 3AwAx 4QyAz /{A| :1}A~ :1A@ B1AAB FqCAD *1EAF 21GAH 9!IAJ 9!KAL CAMAN 1!OAP =aQAR DQSAT 3AUAV LQWA A AX I!YA\ .s]A^ .s_A` +CaAb 1&cAd 26eAf 4VgAj +CkAl )#mAn 1#oAr 0sAt 1"uAv 1"wAz 6s{A| =c}A~ *6A@ )&AA A AB *6CAD &vEAF %fGAH *6IAJ 5fKAL .vMAN 3FOAP )&QAR +FSAT .vUAV 3FWAX 4VYAZ 4S[A\ 5a]A^ 1#_A` 9#aAb CCcA Ad 9<9<@C7:69:=8;7:58AC?A14:=AA A AF +.36  .1(0,439*-3601EF+..1JP ea aZH /17:>?<?8:8:79@B799;  24CI06/54:  IZr ,g -c	 sZB ,gCZL   '  !"a3(SRTIX\^`Wa8b!c!c	
 !! +B $R ' &q !12q'C8dTUYY^`bXc9d"e"e +QRGcSTXX\^_W`chjlbmCn,o,o +QRGcSTXX\^_W`chjlbmCn,o,o *AB7SRSHW[]^V_bgikalBm+n+n -qr1gPSUVxZ^`aYbejlndoEp.q.q &r'B'B  '(B(B!" ,aQ-G-G#$ )*()'  MZz *+,-455678+,!" 
{ZP +R(!   $Q	
 %qa&@&@ $bb%A%A "1 "1 1! ' %rr&B&B !" *1 &'C'C &q  )"!" &q#$ +,*-),)  . ./!"'(.0$%&'*+%&	 	 &'!"'(  "#)*'(%&	 M,  , QZj  )1"kZt   '  !"a3(SRTIX\^`Wa8b!c!c	
 !! +B $R !12q'C8dTUYY^`bXc9d"e"e +QRGcSTXX\^_W`chjlbmCn,o,o *AB7SRSHW[]^V_bgikalBm+n+n +QRGcSTXX\^_W`chjlbmCn,o,o &q &q ' &r'B'B  '(B(B!" ,aQ-G-G#$ )*%&/0b&A&A()56B,G,G%&/  uZj *+,-455678/0!" 
kZ@ $%'C'C$#Q$ $Q$ %a	$
  $ "1$ "1$ *1$ 1!$ '$ ,R$ %a$ !"$ )"$ *1$  +A!$" ,R#$ $& 0'$( 4Q)$* 8+$, 0-$. //$0 /1$2 03$4 4Q5$6 &q7$8 (9$: )!;$< &t=$> )"?$@ %dA$B (C$D %dE$F (G$ $L ()-.*+&'!"$%%&.0-.569:  &'!"'(  ()!")*%&	 s?  ? AZ@ &!AZJ  #$#$() "KZX  ! !()!""# !!""#"#,.+,() YZx #$$%/0b&A&A)*&'*+ !'(*+)* ./!"   "#'(%&"#$%./79  $Q "#'()*56%& 9#  # yZ@  !$ #*+#qC8dTVZZ^`bYc8d!e!e"#%(,-"%$'03'D'D+.B"?"?-014#(F(F69s-K-K()$' $ )# )# )#5 AZ| ()),%(!$/2&C&C%&#$$%+,./)*./  &)),%(*-!$/2&)  '*%(!$ 1 }Zx 66"A6 '6 (	6
 '6 #A6 '6 (6 '6 3A6 4R6 6q6 3B6 3A6 4R6  6q!6" 3B#6 6$ '%6& ,Q'6( +C)6* +A+6, .s-6. //60 *1162 "2364 "2566 /768 -a96: *1;6< *1=6> /?6@ /A6B (C6D (E6 6 6F -aG6H -aI6J -aK6L )"M6N )"O6P .qQ6R ,RS6T ,RU6V ,RW6X +BY6Z 7[6\ 5b]6^ $R_6` $Ra6b %ac6d %ae6f /g6 6h +,*+k6 6 6n"A. #A /	
 ' %f $V +F &q &q / / *6 ' /  9#!" $Q#$ +A% * $Q %&01,-89$%01,-89()01,-%& _] ]yZ Zz  %!&"&!..w77!..w77  #*%)&*!%!2!2:!>!>!%!2!2:!>!> "&!2!23!7!79J9J:9V9V W!%!2!25!9!94;L;LZ;X;X Y!%!2!26!:!:D<M<Mj<Y<Y Z!%!2!26!:!:D<M<Mj<Y<Y Z!%!2!27!;!;T=N=Nz=Z=Z [!%!2!27!;!;T=N=Nz=Z=Z [!%!2!28!<!<d>O>OPZ>[>[ \!%!2!28!<!<d>O>OPZ>[>[ \!%!2!28!<!<d>O>OPZ>[>[ \!%!2!28!<!<d>O>OPZ>[>[ \& "&!2!23!7!79J9J:9V9V W!%!2!25!9!94;L;LZ;X;X Y!%!2!26!:!:D<M<Mj<Y<Y Z!%!2!26!:!:D<M<Mj<Y<Y Z!%!2!27!;!;T=N=Nz=Z=Z [!%!2!27!;!;T=N=Nz=Z=Z [!%!2!28!<!<d>O>OPZ>[>[ \!%!2!28!<!<d>O>OPZ>[>[ \!%!2!28!<!<d>O>OPZ>[>[ \!%!2!28!<!<d>O>OPS>T>T U&" "     "H #)%)&*!%!2!2:!>!>!%!2!2:!>!> "&!2!23!7!79J9J:9V9V W!%!2!25!9!94;L;LZ;X;X Y!%!2!26!:!:D<M<Mj<Y<Y Z!%!2!26!:!:D<M<Mj<Y<Y Z!%!2!27!;!;T=N=Nz=Z=Z [!%!2!27!;!;T=N=Nz=Z=Z [!%!2!28!<!<d>O>OPZ>[>[ \!%!2!28!<!<d>O>OPZ>[>[ \!%!2!28!<!<d>O>OPZ>[>[ \!%!2!28!<!<d>O>OPZ>[>[ \& "&!2!23!7!79J9J:9V9V W!%!2!25!9!94;L;LZ;X;X Y!%!2!26!:!:D<M<Mj<Y<Y Z!%!2!26!:!:D<M<Mk<Z<Z [!%!2!27!;!;T=N=Ns=S=S T!%!2!27!;!;T=N=N{=[=[ \!%!2!28!<!<d>O>OP[>\>\ ]!%!2!28!<!<d>O>OP[>\>\ ]!%!2!28!<!<d>O>OP[>\>\ ]!%!2!28!<!<d>O>OP[>\>\ ]&" "     "F ]O Ob ! ! ,iui ! ! !i "4i %ei vi !$i 6ui 5di( ,U)i* !.+i, i-i. !!/i0 *51i2 #$#% %3i:  ;i< (** ,(* =iL !""(&%( *()&# #Mif #(& ( )&! ! #"!""   ]$"G]$"G]$ "5]$ +F	]$
 "5]$ ]$ %e]$ -e]$ 25]$ +E]$ ,U]$ ,V]$ !%]$ *5]$ 5e]$  *5!]$" %e#]$ ]$$ )&%]$& &v']$( ,U)]$* +E+]$, +D-]$. &u/]$0 #F1]$2 &u3]$4 255]$6 &u7]$8 e9]$: (;]$< *5=]$> ,V?]$@ +EA]$B +EC]$D (E]$ ]$ ]$F &vG]$H %fI]$J *6K]$L %eM]$N 0O]$P "5Q]$R #ES]$T (U]$V !%W]$X "5Y]$Z *4[]$\ #E]]$^ %f_]$` 0a]$b *5c]$d .ue]$f &vg]$ ]$ ]$h (i]$j #Fk]$l )&m]$n 'o]$p 'q]$r %es]$t (u]$v +Ew]$x &yy]$z &u{]$| '}]$~ %f]$@ *5A]$B (C]$D 'E]$F !&G]$H !%I]$ ]$ ]$J +EK]$L +EM]$N  O]$P &uQ]$R (S]$T (U]$V 'W]$X &vY]$Z +E[]$\ $W]]$^ )%_]$` 'a]$b )&c]$d *5e]$f (g]$h &ui]$j (k]$ ]$l $*',',-2*1(--2y]$ ]$ ]$|]!"G]!"G]! "5]! +F	]!
 "5]! ]! %e]! -e]! 25]! +E]! ,U]! ,V]! !%]! *5]! 5e]!  *5!]!" %e#]! ]!$ )&%]!& &v']!( ,U)]!* +E+]!, +D-]!. &u/]!0 #F1]!2 &u3]!4 255]!6 &u7]!8 e9]!: (;]!< *5=]!> ,V?]!@ +EA]!B +EC]!D (E]! ]! ]!F &vG]!H %fI]!J *6K]!L %eM]!N 0O]!P "5Q]!R #ES]!T (U]!V !%W]!X "5Y]!Z *4[]!\ #E]]!^ %f_]!` 0a]!b *5c]!d .ue]!f &vg]! ]! ]!h (i]!j #Fk]!l )&m]!n 'o]!p 'q]!r %es]!t (u]!v +Ew]!x &yy]!z &u{]!| '}]!~ %f]!@ *5A]!B (C]!D 'E]!F !&G]!H !%I]! ]! ]!J +EK]!L +EM]!N  O]!P &uQ]!R (S]!T (U]!V 'W]!X &vY]!Z +E[]!\ $W]]!^ )%_]!` 'a]!b )&c]!d *5e]!f (g]!h &ui]!j (k]! ]!l $*',',-2*1(--2y]! ]! ]!~ $U+#U+$ $!4!4! 4! 4	!
 4! 4! 4! 4! 4! 4! 4! 4! 4! 4! 4!  4!!" 4#!$  A! ! !F E-M	i i iX	  M  	M
  M  !4M  M  M  M  M  M  M   !4!M"  !2#M$  %M&  'M(  )M0  1M2  !43M4  5M M6  7M8  !29M:  ;M<  =M>  ?M@  AMB  !2CMD  EMF  GMH  !2IMJ  KML  !1MMN  OMP  QMR  !2SMT  !1UMV  !1WM M MX  YMZ  [M\  !1]M^  !2_M`  !2aMb  cMd  eMf  gMh  iMj  kMl  !1mMn  oMp  qMr  !2sMt  uMv  !1wMx  yM M Mz  {M|  !1}MD  EMF  GMH  IMJ  KML  !4MMN  !2OMP  QMR  !1SMT  !1UMV  WMX  !1YMZ  [M\  !1]M^  !4_M`  aM M Mb  !1cMd  !1eMf  !1gMh  iMj  kMl  mMn  oMp  qMr  sMt  !2uMv  !2wMx  !2yMz  {M|  }M~  M@  AMB  CM M MD  EMF  GMH  !2IMJ  !1KML  !1MMN  OMP  QMR  !1SMT  !2UMV  WMX  !2YMZ  !2[M\  !1]M^  _M`  !4aMb  cMd  eM M Mf  gMh  iMj  kMl  mMn  oMp  qMr  sMt  uMv  wMx  yMz  {M|  }M~  M@  AMB  CMD  EMF  GM M MH  IMJ  KML  MMN  OMP  QMR  SMT  UMV  WMX  YMZ  [M\  ]M^  _M`  aMb  cMd  eMf  gMh  iM M Mj  kMl  mMn  oMp  qMr  sMt  uMv  wMx  yMz  {M|  }M~  M@  AMB  CMD  EMF  GMH  IMJ  KM M ML  MMN  OMP  QMR  SMT  UMV  WMX  YMZ  [M\  ]M^  _M`  aMb  cMd  eMf  gMh  iMj  kMl  mM M Mn  oMp  qMr  sMt  uMv  wMx  yMz  {M|  }M~  M@  AMB  CMD  EMF  GMH  IMJ  KML  MMN  OM M MP  QMR  SMT  UMV  WMX  YMZ  [M\  ]M^  _M`  aMb  cMd  eMf  gMh  iMp  qMr  !2sMt  !2uMv  !2wM M Mx  !2yMz  {M|  }M~  !2M@  AMB  CMD  EMF  GMH  !2IMJ  KML  MMT  UMV  !1WMX  YMZ  [M\  ]M^  _M M M`  aMb  !2cMd  !2eMf  !2gMh  iMj  !2kMl  mMn  oMp  !1qMr  !2sMt  !2uMv  wM~  M@  AMH !/IMJ !*KML !+MM M MN !*OMP !*QMR !*SMT !*UMV !"3WMX !*YMZ !"3[M\ !/]M^ !/_M` !"3aMb !*cMd !*eMf !*gMh !,iMj !*kMl !/mMn !*oM M Mp !/qMr !*sMt !*uMv !"3wMx !"3yMz !"3{M| !/}M~ !"3M@	 !"3A	MB	 !"3C	MD	 !/E	MF	 !)G	MH	 !"3I	MJ	 !"3K	ML	 !"3M	MN	 !"3O	MP	 !"2Q	M M MR	 !"3S	MT	 !"3U	MX	 !"3Y	MZ	 !"3[	M\	 !"3]	M^	 !"2_	M`	 !"3a	Mb	 !"3c	Md	 !"3e	Mf	 !"2g	Mj	 !"3k	Ml	 !"3m	Mn	 !"3o	Mp	 !"2q	Mr	 !"3s	Mt	 !"3u	M~	 !*	M M@
 #-"-"3"3"1"1 #-",%8%8Y
M M MOb
  d  !1	d
  d  !1d  d  !4d  !1d  d  d  d  d  d$  %d&  !2'd(  !1)d*  !2+d,  !2-d.  /d d0  !91d2  3d4  5d6  !27d8  !29d:  ;d<  !2=d>  !2?dF  GdH  IdJ  KdL  MdN  OdP  QdR  SdT  !2UdV  Wd d dX  !2YdZ  [d\  !2]d^  !2_d`  adb  cdd  !1edf  gdh  idj  !1kdl  !1mdn  odp  qdr  !2sdt  !2udv  wdx  !2yd d dz  {d|  }d~  d@  AdB  CdD  !2EdF  !2GdH  !2IdJ  !2KdL  MdN  OdP  !1QdR  !1SdT  !1UdV  !1WdX  !1YdZ  !2[d d d\  !2]d^  _d`  adb  !1cdd  !1edf  !1gdh  !1idp  !1qdr  !1sdt  !2udv  !2wdx  !2ydz  !2{d|  }d~  d@  AdB  Cd dD ",!0Gd d dfP  8  !1	8
  !18  8  !48  8  8  8  8  !28   !2!8"  !2#8$  %8&  !9'8(  )8*  +8,  -8.  !2/8 80  182  !2384  !258<  =8>  ?8@  A8B  !1C8D  !1E8F  G8H  I8J  !2K8L  !2M8N  !2O8P  Q8R  S8T  U8V  W8 8X ",!+!1!1!1!+!2!2!+!1!1!2o8 8 8:x  |  	|
  |  |  |  !2|  |  |  |  |  |  |  |   !|(  )|*  !2+|,  !2-|4  5| |F  G|H  I|J  K|L  M|N  O|P  Q|R  S|V  W|X  Y|Z  [|\  ]|^  _|`  a|b  c|d  e|f  g|h  i| | |j  k|l  m|n  o|p  q|r  s|x  y|z  {||  }|~  |@  A|B  C|D  E|F  G|H  I|J  K|L  M|N  O| | |P  Q|R  S|T  U|V  W|X  Y|Z  [|\  ]|^  _|`  a|b  c|d  e|f  g|j  k|l  m|n  o|p  q|r  s| | |t  u|v  w|x  y|z  {||  }|~  |@  A|B  C|D  E|F  G|H  I|J  K|L  M|N  O|P  Q|R  S|T  U| | |V  W|X  Y|Z  [|\  ]|^  _|`  a|b  c|d  e|f  g|h  i|j  k|l  m|n  o|p  q|r  s|t  u|v  w| | |x  y|z  {||  }|~  |@  A|B  C|D  E|F  G|H  I|J  K|L  M|N  O|P  Q|R  S|T  U|V  W|X  Y| | |Z  [|\  ]|^  _|`  a|b  c|d  e|f  g|h  i|j  k|l  m|n  o|p  q|r  s|t  u|v  w|x  y|z  {| | ||  }|~  |@  A|B  C|D  E|F  G|H  I|J  K|L  M|N  O|P  Q|R  S|T  U|V  W|X  Y|Z  [|\  ]| |^ "/ #0"/"/"/"/"/"/"/"/w| | |~@  X  !1	X
  !1X  X  X  X  X  X  X  !2X   !2!X"  !2#X$  !1%X&  !9'X(  )X*  +X,  !2-X.  !2/X X0  1X2  !23X4  !25X<  =X>  ?X@  AXB  CXD  EXF  GXH  IXJ  !2KXL  MXN  OXP  QXR  !2SXT  !2UXV  WX X XX  YXZ  !1[X\  ]X^  _X`  aXb  !1cXd  !1eXf  gXh  iXj  !2kXl  !2mXn  oXp  qXr  sXt  !2uXv  !2wXx  yX X Xz  {X|  }XD  !1EXF  !1GXN !-OXP !-QXR !-SXT !-UXV !-WXX !-YXZ !-[X\ !-]X^ !-_Xb !*cXd !*eXf !+gXh !"3iX Xj #4"1"1oX X XZ$vY
 _Y _Y 0Y .Y .Y _Y ^Y _Y ZY \Y .Y  Z!Y" Z#Y$ \%Y& 0'Y( Z)Y* Z+Y Y, Z-Y. Z/Y0 Z1Y2 Z3Y4 Z5Y6 Y7Y8 Z9Y: _;Y< Z=Y> Z?Y@ ZAYB ZCYD ZEYF ZGYH ZIYJ YKYL 0MY Y YN ZOYP ZQYR ZSYZ \[Y\ ]]Y^ ]_Y` 0aYb 0cYj \kYl ZmYn ZoYp ZqYr ZsYt ZuYv ZwYx ZyYz Z{Y Y Y| Z}Y~ ZY@ ZAYB ZCYD ZEYF ZGYH ZIYJ ZKYL ZMYN ZOYP .QYR ZSYT ZUYV ZWYX ZYYZ Z[Y\ Z]Y Y Y^ Z_Y` ZaYb ZcYd ZeYf ZgYh ZiYj .kYl ZmYn ZoYp .qYr .sYt .uYv .wYx ZyYz .{Y| .}Y~ .Y Y Y@ ZAYB .CYD ZEYF 0GYH 0IYJ ZKYL .MYN ZOYP .QYR ZSYT .UYV .WYX ZYYZ .[Y\ Z]Y^ Z_Y` ZaY Y Yb ZcYd ZeYf ZgYh ZiYj 5kYt iuYv jwYx jyYz j{Y| j}Y~ jY@ jAYB /CYD jEYL 3MMYN )/OYP FGWQY Y YR -.ASYT 78PUYV <=UWYX >?WYYZ MN_[Y\ 78H]Y^ CDT_Y` 12BaYb ():cYd ABSeYf ?@PgYh ?
iYj TU_kYl PQbmYn BCSoYp EFVqY Yv 3C$. Ok kQ-T%B
 T%B
 T% T% T%	    NtypesubTypereturnc                     ||dk    S |dk    S )Nr  r   rq  ru  rv  s      rs  
is_inversezbinance.is_inverse	  s    ?:%&i''rt  c                 *    ||dk    p|dk    S |dk    S )NrG   rF   r  ry  rz  s      rs  	is_linearzbinance.is_linear	  s&    ?8#88h&&rt  enablec                 l    t          t          |                               |           || j        d<   d S )Nr  )rn  r=   set_sandbox_moderk  )rq  r~  rr  s     rs  r  zbinance.set_sandbox_mode	  s3    gt--f555&,]###rt  symbolc                     d}|                     d          }|                     d          }d }|                    d          dk    r|                     |d          }n|                     |d          }|                     |d          }|                     |d          }|                     |d          }|                     |d          }	|                     |          }
|                     |
          }i d	|dz   |z   dz   |z   dz   |	z   d
|dz   |z   dz   |z   dz   |z   dz   |z   dz   |	z   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k    rdnd|||d d d d d d!d d d!d d d!d"d d#	S )$NUSDT-/r   r   r  r  r`  r  :r  r  baseIdquoteIdactiveru  rH   r  r  rD   FrF   rG   TrE   contractcontractSizeCcallr!  )amountpriceminmax)r  r  r   )	expiryexpiryDatetime
optionTypestrikesettlesettleId	precisionlimitsinfo)splitfindsafe_stringsafe_integerconvert_expire_date	parse8601)rq  r  r  optionParts
symbolBaser  r  r  strikeAsStringr  datetime	timestamps               rs  create_expired_option_marketz$binance.create_expired_option_market	  s   ll3''\\#&&
;;sb  ##J22DD##K33D!!+q11"";22))+q99%%k155
++F33NN8,,	+
$*v%+n<sBZO+
dSj6)C/&83>G#MP^^addgqq+
 D+
 V	+

 d+
 v+
 d+
 H+
 d+
 t+
 E+
 E+
 e+
 d+
 e+
  !+
" D#+
$  &%/3%6%6&&U    
   
     U+
 +
 +
 +	
rt  c                    | j         t          | j        dz             |                     | j        d          }|                     | j        d          }|dk    }|dk    }|p|}t          |t                    rn|| j         v rK| j         |         }|r:|d         r2|r|d         n|d         }|d	z   |z   }	|	| j         v r| j         |	         S n|S || j        v rW| j        |         }
|rd
}n	|rd}n||}t          dt          |
                    D ]}|
|         }||         r|c S |
d         S |
                    d          dk    rZ|
                    d	          dk     rA|                    d          \  }}|dk    r|n|}|d	z   |z   }	|	| j         v r| j         |	         S nG|
                    d          dk    s|
                    d          dk    r|                     |          S t          | j        dz   |z             )Nz markets not loadedr  r  rG   r  rD   r  r  r  r  r  r   r  r  r)  -C-Pz does not have market symbol )marketsr#   r`  r  rk  
isinstancestrmarkets_by_idrangelenr  r  r  r)   )rq  r  r  r  isLegacyLinearisLegacyInverseisLegacyr  r  futuresSymbolr  ir  r  s                 rs  r  zbinance.market	  sc   <*? ?@@@&&t|]CC))$,8HII$0%3!4_fc"" #	A%%f- "v "0>RVG__F6NF$*SL6$9M$44#|M:: 5 "M4---,V4! 1"*KK$ 1"+KK ("0Kq#g,,// & &A$QZFk* &%&qz!++c""R''fkk#.>.>.B.B$ll3//e"'5..u &v 5 DL00<66 1++d##b((fkk$.?.?".D.D88@@@"AAFJKKKrt  marketIdr  	delimiter
marketTypec                    |d uo1|                     d          dk    p|                     d          dk    }|r|| j        vr|                     |          S t          t          |                               ||||          S )Nr  r  r  )r  r  r  rn  r=   safe_market)rq  r  r  r  r  isOptionrr  s         rs  r  zbinance.safe_market	  s    D(hd0C0Cb0H/ghmm\`NaNadfNf 	?X);;;44X>>>Wd##//&)ZXXXrt  c                     |                      |t          | j        |         d         d         | j        | j                  S )Nr  r  )decimal_to_precisionr9   r  rj  paddingMode)rq  r  r   s      rs  cost_to_precisionzbinance.cost_to_precision
  sE    ((xf9Mk9Z[b9ceiewy}  zJ  K  K  	Krt  c                     |                      | j        |         d          9|                     |t          | j        |         d         | j        | j                  S |                     |          S )Nr  )
safe_value
currenciesr  r9   rj  r  number_to_string)rq  codefeenetworkCodes       rs  currency_to_precisionzbinance.currency_to_precision
  so    ??4?40+>>J,,S(DOD<QR]<^`d`rtx  uE  F  F  F((---rt  c                 F    |                                  | j        d         z
  S )Nr  )millisecondsrk  )rq  s    rs  noncezbinance.nonce
  s!      ""T\2B%CCCrt  c                    K   |                      | j        ddd          }|                     |d|          }|                     |d          }d}|                     dd|          \  }}d}|                     ||          r|                     |           d{V }nM|                     ||          r|                     |           d{V }n| 	                    |           d{V }| 
                    |d          S )af  
        fetches the current integer timestamp in milliseconds from the exchange server
        :see: https://binance-docs.github.io/apidocs/spot/en/#check-server-time       # spot
        :see: https://binance-docs.github.io/apidocs/futures/en/#check-server-time    # swap
        :see: https://binance-docs.github.io/apidocs/delivery/en/#check-server-time   # future
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :param str [params.subType]: "linear" or "inverse"
        :returns int: the current integer timestamp in milliseconds from the exchange server
        r   r  rD   ru  N
serverTime)safe_string_2rk  r  omithandle_sub_type_and_paramsr}  fapiPublicGetTimer{  dapiPublicGetTimepublicGetTimer  )rq  paramsr  ru  queryrv  responses          rs  
fetch_timezbinance.fetch_time
  s(      (({MSYZZ<<		&&))99+tVTT>>$(( 	7!33E::::::::HH__T7++ 	7!33E::::::::HH!//66666666H  <888rt  c                   K   |                      | j        d          }|sdS |                     d          sdS |                      | j        d          }|dS |                     |           d{V }i }t          dt          |                    D ]4}||         }|                     |d          }|                     |d          }	|                     |          }
d}d}d}| 	                    |d	g           }i }d}i }t          dt          |                    D ]:}||         }|                     |d
          }| 
                    |          }|                     |d          }|                     |d          }|                     |d          }|p|}|p|}|||<   |                     |d          }|s||}|                     |d          }t          j        |d          s||nt          j        ||          }||||o||||                     |          ||                     |d          |                     |d          dddddd	||<   <|                     |d          }|o|o|}d}|5t#          |                     |                     |                              }||	|
||||||||| j        d||
<   6|S )a6  
        fetches all available currencies on an exchange
        :see: https://binance-docs.github.io/apidocs/spot/en/#all-coins-39-information-user_data
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: an associative dictionary of currencies
        rv   NF	apiBackupr   coinra  TnetworkListnetworkwithdrawFeedepositEnablewithdrawEnable	isDefaultwithdrawIntegerMultipler  withdrawMinwithdrawMaxr  r   deposit)	r  r`  r  r  r  r   r  r  r  r  )r`  ra  r  r  r  r  r  r   r@  r  r   r  )r  rk  check_required_credentialsrh  sapiGetCapitalConfigGetallr  r  r  safe_currency_code	safe_listnetwork_id_to_codesafe_number	safe_boolr;   	string_eq
string_minrp  intr  precision_from_stringr  )rq  r  fetchCurrenciesEnabledr  r  resultr  entryr`  ra  r  minPrecisionisWithdrawEnabledisDepositEnabledr  r   r  r@  jnetworkItemr  r  r  r  r  r  precisionTickr  r  maxDecimalPlacess                                 rs  fetch_currencieszbinance.fetch_currencies)
  sw      "&?P!Q!Q% 	4
 ..u55 	4OODI{;;	 488@@@@@@@@q#h--(( d	 d	A@ QKE!!%00B##E622D**2..DL $#..rBBKDCH1c+..// & &)!n**;	BB"55g>>"..{MJJ ${O L L!%=M!N!N#3#D} $5$G! +W NN;DD	 &%C $ 0 0>W X X (<< @5A5I==PWPbcoq~PPL'!*+>, .,,S11!- $(#3#3K#O#O#'#3#3K#O#O% %
 $(#'$ $	 	) )%%( nnUI66G'H,<HF#'#&t'<'<T=W=WXd=e=e'f'f#g#g - +-$+ F4LL rt  c                   K   g }|                      | j        dg d          }|                     | j        dd          }g }t          dt	          |                    D ](}||         }|dk    r|r|                    |           )t          dt	          |                    D ]}||         }|dk    r)|                    |                     |                     9|dk    r)|                    |                     |                     h|d	k    r)|                    |                     |                     |dk    r)|                    | 	                    |                     t          | j        d
z   |z   dz             t          j        |  d{V }	g }
t          dt	          |                    D ]F}|                     |	|          }|                     |ddg           }|                     |
|          }
G| j        d         r|                                  d{V  g }t          dt	          |
                    D ]0}|                    |                     |
|                              1|S )ab  
        retrieves data on all markets for binance
        :see: https://binance-docs.github.io/apidocs/spot/en/#exchange-information         # spot
        :see: https://binance-docs.github.io/apidocs/futures/en/#exchange-information      # swap
        :see: https://binance-docs.github.io/apidocs/delivery/en/#exchange-information     # future
        :see: https://binance-docs.github.io/apidocs/voptions/en/#exchange-information     # option
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict[]: an array of objects representing market data
        r   r  r  Fr   rH   rD   r  r  z+ fetchMarkets() self.options fetchMarkets "z " is not a supported market typeNsymbolsoptionSymbolsr  )r  rk  r  r  r  appendpublicGetExchangeInfofapiPublicGetExchangeInfodapiPublicGetExchangeInfoeapiPublicGetExchangeInfor#   r`  asynciogather	safe_dictsafe_list_2array_concatload_time_differenceparse_market)rq  r  promisesRawrawFetchMarketsr  r   r  ru  r  promisesr  promisepromiseMarketsr  s                 rs  fetch_marketszbinance.fetch_markets
  s      ..~GdGdGdeennT\=%HHq#o..// 	& 	&A"1%DxK%%%%q#l++,, 	O 	OA%aJV##""4#=#=f#E#EFFFFx''""4#A#A&#I#IJJJJy((""4#A#A&#I#IJJJJx''""4#A#A&#I#IJJJJ#DG.[$[^h$h  lN  %N  O  O  O 5555555q#l++,, 	A 	AAnnXq11G!--gy/SUVVN''@@GGV <12 	.++---------q#g,,'' 	9 	9AMM$++GAJ778888rt  c                     d}d}d}|                      |d          }|                      |d          }|                    d          }|                      |d          }|                     |d          }	|                      |d|          }
|                      |d          }|                     |
          }|                     |          }|                      |d          }d|v }|                     |d	d
          }|                      |d          }|dk    s|dk    rd }d}n|d}d}|dn|}n|d}|                     |          }| }|                     |dg           }|                     |d          }|                     |dd          }d }| j        }d }d }|                      |d          }|dz   |z   }|r|r	|dz   |z   }ng|r"|dz   |z   dz   | 	                    |          z   }nC|rA|dz   |z   dz   | 	                    |          z   dz   |z   dz   |                      |d          z   }| 
                    |dd|                     d                    }||k    }||k    }|rdnd}|                     | j        |i           }|dk    }|rG|                     |dg           }t          dt          |                    D ]} ||          dk    rd} n|                     |d d          }!d }"|rd!}"n|rd"}"n|rd#}"n|rd$}"d }d }#||                     |          }#i d%|d&|	d|d'|d(|d)|d*|
d+|d,|d-|"d!|d.|o|!d"|d#|d$|d/|d0||||d1         d2         |d1         d3         |||                     |          |#|                     |d4          |                     |d5d6          |                     |d7d8          |                     |d9          |                     |d:          d;d d d<|                     |d=          |                     |d>          d<d d d<d d d<d?||                     |d@          dA}$dB|v rq|                     |dBi           }%|                     |%dC          |                     |%dD          d<|$dE         dF<   |                     |%dG                   |$dH         dF<   dI|v r|                     |dIi           }%|                      |%dJ          }&|                     |&          |$dH         dK<   |                     |%d=          |                     |%d>          d<|$dE         dK<   dL|v rM|                     |dLi           }%|                     |%d=          |                     |%d>          d<|$dE         dM<   dN|v sdO|v rc|                     |dNdOi           }%| 
                    |%dPdQ          |$dE         dR         dS<   |                     |%dT          |$dE         dR         dU<   |$S )VNF
underlyingr  r  r   	baseAsset
quoteAssetcontractTypedeliveryDate
expiryDatemarginAsset	PERPETUALl    t?D	Tr  filters
filterTypestatuscontractStatusstrikePricer  r  r  r  unit1r  r  TRADINGpermissionsTRD_GRP_003isMarginTradingAllowedrD   rF   rG   rH   r`  lowercaseIdr  r  r  r  r  r  ru  rE   r  r  r  r  r  sidequantityPrecisionquantityScalepricePrecision
priceScalebaseAssetPrecisionquotePrecision)r  r  r  r  r  minQtymaxQty)rY  r  r  r   onboardDate)r  r  r  r  r  r  r  r  r  r  r  r  createdPRICE_FILTERminPricemaxPricer  r  tickSizer  LOT_SIZEstepSizer  MARKET_LOT_SIZEr  MIN_NOTIONALNOTIONALminNotionalnotionalr   r  maxNotionalr  )r  r  safe_string_lowerr  safe_integer_2r  index_byr  r   yymmddsafe_number_2rp  r  r  r  r  parse_to_numericiso8601r  r  r  safe_dict_2)'rq  r  rF   rG   rH   r  r`  r  
optionBaser%  r  r  r  r  r  r  r  r  r  rD   r  filtersByTyper  r  r   r  r  r  r  feesTyper  r"  r  r$  unifiedTypeparsedStriker  filterr6  s'                                          rs  r
  zbinance.parse_market  s   %%fl;;
fh//hhsmm%%k155
,,VX>>!!&+zBB""6<88&&v..''00''??"f,$$V^\JJ##FM::K''V}-D-DFDD#HF"*"2vvHHF((22|..B77g|<<##FH6FGGy!!&-88e# 	; C#. C#.4t{{67J7JJ C#.4t{{67J7JJSPSYY\__bfbrbrs~  AB  cC  cC  C--fnfdN_N_`cNdNdeeLu_FnG#)8xxyH>>$)Xr::DI% 	..CCK1c+..//  q>]22"FE 3 "&8PRW!X!X 	 KK 	 KK 	"KK 	"KF0088L5
"5
;5
 f5
 D	5

 U5
 f5
 f5
 w5
 5
 K5
 D5
 d555
 D5
 f5
 f5
  f!5
" #5
$ )_W-)_W-("ll622"00@@--f6I?[[,,V5E|TT))&2FGG**63CDD	    
  ++FH==++FH== 
   
    $ ((??i5
 5
 5
l ]**^^M>2FFF ''
;;''
;;( (E(OG$ +/*D*DVJEW*X*XE+w'&&^^M:rBBF''
;;H+/+E+Eh+O+OE+x(''99''99) )E(OH% --^^M3DbIIF''99''99) )E(OH% m++}1L1L%%m^ZQSTTF-1-?-?Wa-b-bE(OF#E*-1-=-=fm-T-TE(OF#E*rt  c                    |                                  }|                     |d          |d<   |                     |d          |d<   |                     |d          }|                     |d          }t          j        ||          |d<   |S )Nlockedusedfreeinterestborroweddebt)rJ  r  r;   
string_add)rq  r  rJ  rO  rQ  s        rs  parse_balance_helperzbinance.parse_balance_helperw  s    ,,..**5(;;**5&99##E:66z22!,T8<<rt  Fc                    d|i}d }|dk    }|dk    p|dk    }|rt          dt          |                    D ]l}	||	         }
|                                 }|                     |
d          }|                     |          }|dk    r3|                     |
d          |d	<   |                     |
d
          |d<   n|dk    r3|                     |
d          |d	<   |                     |
d          |d<   n|r|                     |
d          }|                     |
d          }t          j        ||          |d<   |                     |
d          |d	<   |                     |
d          |d<   |                     |
d          |d<   n|                     |
d          |d<   |||<   nn|s|dk    s|r|                     |d          }|                     |ddg           }t          dt          |                    D ]}	||	         }|                     |d          }|                     |          }|                                 }|                     |d	          |d	<   |                     |d          |d<   |rD|                     |d          }|                     |d          }t          j        ||          |d<   |||<   ǐn|r:| 	                    |d          }t          dt          |                    D ]}	||	         }|                     |d          }| 
                    |d d d          }|                     |d i           }|                     |d!i           }|                     |                     |d                    }|                     |                     |d                    }i }|                     |          ||<   |                     |          ||<   |                     |          ||<   n|d"k    r| 	                    |d#g           }t          dt          |                    D ]n}	||	         }
|                     |
d          }|                     |          }|                                 }|                     |
d$          }||d<   ||d<   |||<   on|d%k    rt          dt          |                    D ]}	||	         }
|                                 }|                     |
d          }|                     |          }|                     |
d	          |d	<   |                     |
d&          }|                     |
d'          }|                     |
d          } t          j        |t          j        | |                    |d<   |||<   n|}t          |t                    s| 	                    |dg           }t          dt          |                    D ]}	||	         }|                     |d          }|                     |          }|                                 }|                     |d(          |d	<   |                     |d)          |d<   |                     |d*d+          |d<   |||<   ||d,<   |                     |          |d-<   |r|n|                     |          S ).Nr  isolatedrE   r  r   assetr  umWalletBalancerN  umUnrealizedPNLrM  r  cmWalletBalancecmUnrealizedPNLcrossMarginBorrowedcrossMarginInterestrQ  crossMarginFreecrossMarginLockedcrossMarginAssettotaltotalWalletBalancerD   
updateTimebalances
userAssetsrL  rP  rO  assetsr  r  r  savingspositionAmountVosr  r  freezewithdrawingavailableBalanceinitialMarginmarginBalancerI  r  r  )r  r  rJ  r  r  r;   rR  r  r  r  safe_symbolr  rS  safe_balancer  listr  rC  )!rq  r  ru  
marginModeisPortfolioMarginr  r  rU  r  r  r  rJ  
currencyIdr  rP  rO  rc  rI  rQ  re  rV  r  r  r  r  baseCode	quoteCode	subResultrg  usedAndTotalfrozenri  rL  s!                                    rs  parse_balance_customzbinance.parse_balance_custom  s   H
 	+!=zW'< V	'1c(mm,, ' ' ,,..!--eW==
..z::8##&*&6&6u>O&P&PGFO&*&6&6u>O&P&PGFOOY&&&*&6&6u>O&P&PGFO&*&6&6u>O&P&PGFOO U#//7LMMH#//7LMMH&-&88&L&LGFO&*&6&6u>O&P&PGFO&*&6&6u>Q&R&RGFO'+'7'7?Q'R'RGG$$'+'7'7?S'T'TGG$&t)'*  @	'5))(LAAI''*lBOOH1c(mm,, ' '"1+!--gw??
..z::,,.."&"2"27F"C"C"&"2"27H"E"E I++GZ@@D#//DDH&-&8x&H&HGFO&t'  1	'^^Hh77F1c&kk** > >q	++E8<<))(D$GG~~e["==ulB??2243C3CD'3R3RSS 33D4D4DUG4T4TUU		&*&?&?&E&E	(#'+'@'@'G'G	)$!%!2!29!=!=v> Y $x9Lb Q Q1c"34455 ' ')!,!--eW==
..z::,,..#//x@@#/ ".&t' Y1c(mm,, 
' 
' ,,..!--eW==
..z::"&"2"25&"A"A))%::"..umDD))%::")"4VW=OPVXc=d=d"e"e&t
'  Hh-- B>>(HbAA1c(mm,, ' '"1+!--gw??
..z::,,.."&"2"27<N"O"O"&"2"27O"L"L#'#5#5gPY#Z#Z &t'{!\\)44z!@vvt'8'8'@'@@rt  c                 $  K   |                                   d{V  |                     | j        ddd          }|                     |d|          }d}|                     dd|          \  }}d}|                     |dddd          \  }}d}d}|                     d|          \  }}|                     |d          }d}i }	|s|dk    rd|                     ||          rd	}n| 	                    ||          rd
}d}| 
                    |                     |	|                     d{V }nL|                     ||          r3d	}|                     |                     |	|                     d{V }n| 	                    ||          r3d
}|                     |                     |	|                     d{V }n|dk    r|                     |d          }
|                     |d          }|
d}t          |
t                     ra|                     |
d                   }t%          dt'          |
                    D ]'}|
|         }|                     |          }|d|z   z  }(n|
}||	d<   |                     |                     |	|                     d{V }n|dk    s|dk    r0|                     |                     |	|                     d{V }n|dk    r0|                     |                     |	|                     d{V }ne|dk    r0|                     |                     |	|                     d{V }n/|                     |                     |	|                     d{V }|                     ||||          S )a  
        query for balance and get the amount of funds available for trading or funds locked in orders
        :see: https://binance-docs.github.io/apidocs/spot/en/#account-information-user_data                  # spot
        :see: https://binance-docs.github.io/apidocs/spot/en/#query-cross-margin-account-details-user_data   # cross margin
        :see: https://binance-docs.github.io/apidocs/spot/en/#query-isolated-margin-account-info-user_data   # isolated margin
        :see: https://binance-docs.github.io/apidocs/spot/en/#lending-account-user_data                      # lending
        :see: https://binance-docs.github.io/apidocs/spot/en/#funding-wallet-user_data                       # funding
        :see: https://binance-docs.github.io/apidocs/futures/en/#account-information-v2-user_data            # swap
        :see: https://binance-docs.github.io/apidocs/delivery/en/#account-information-user_data              # future
        :see: https://binance-docs.github.io/apidocs/voptions/en/#option-account-information-trade           # option
        :see: https://binance-docs.github.io/apidocs/pm/en/#account-balance-user_data                        # portfolio margin
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :param str [params.type]: 'future', 'delivery', 'savings', 'funding', or 'spot' or 'papi'
        :param str [params.marginMode]: 'cross' or 'isolated', for margin trading, uses self.options.defaultMarginMode if not passed, defaults to None/None/None
        :param str[]|None [params.symbols]: unified market symbols, only used in isolated margin mode
        :param boolean [params.portfolioMargin]: set to True if you would like to fetch the balance for a portfolio margin account
        :param str [params.subType]: "linear" or "inverse"
        :returns dict: a `balance structure <https://docs.ccxt.com/#/?id=balance-structure>`
        Nrh   r  rD   ru  r   r^  Fr  r  TrU  r   r   r   ,rE   r  rf  r  )load_marketsr  rk  r  r  handle_option_and_params_2handle_margin_mode_and_paramsr  r}  r{  papiGetBalanceextendfapiPrivateV2GetAccountdapiPrivateGetAccountr  r  ro  	market_idr  r  sapiGetMarginIsolatedAccountsapiGetMarginAccountsapiGetLendingUnionAccountsapiPostAssetGetFundingAssetprivateGetAccountrx  )rq  r  r  ru  rv  rq  rp  r  r  requestparamSymbolsr  r  r  r`  s                  rs  fetch_balancezbinance.fetch_balance  s(     ( !!!!!!!!!((~}V\]]<<99.$PVWW $($C$CFN\bduw|$}$}!6
 >>~vVV
E		%(( #	Q~~dG,, !w// !  $!00We1L1LMMMMMMMMHH^^D'** 	QD!99$++gu:U:UVVVVVVVVHH__T7++ 	QD!77GU8S8STTTTTTTTHH:%%>>&)<<LIIeY//E'lD11 +"nn\!_==G"1c,&7&788 , ,!-a!^^F3338+,
 +G%,	"!>>t{{7TY?Z?Z[[[[[[[[HHhJ'$9$9!66t{{7E7R7RSSSSSSSSHHY!<<T[[RW=X=XYYYYYYYYHHY!>>t{{7TY?Z?Z[[[[[[[[HH!33DKK4O4OPPPPPPPPH\ ((4EVWWWrt  r  c                   K   |                                   d{V  |                     |          }d|d         i}|||d<   d}|d         r0|                     |                     ||                     d{V }n|d         r0|                     |                     ||                     d{V }ng|d         r0|                     |                     ||                     d{V }n/|                     |                     ||                     d{V }|                     |d          }|                     |||          }| 	                    |d	d
          |d<   |S )aK  
        fetches information on open orders with bid(buy) and ask(sell) prices, volumes and other data
        :see: https://binance-docs.github.io/apidocs/spot/en/#order-book      # spot
        :see: https://binance-docs.github.io/apidocs/futures/en/#order-book   # swap
        :see: https://binance-docs.github.io/apidocs/delivery/en/#order-book  # future
        :see: https://binance-docs.github.io/apidocs/voptions/en/#order-book  # option
        :param str symbol: unified symbol of the market to fetch the order book for
        :param int [limit]: the maximum amount of order book entries to return
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: A dictionary of `order book structures <https://docs.ccxt.com/#/?id=order-book-structure>` indexed by market symbols
        Nr  r`  r  rH   r  r  TlastUpdateIdur  )
r|  r  eapiPublicGetDepthr  fapiPublicGetDepthdapiPublicGetDepthpublicGetDepthr  parse_order_bookr>  )	rq  r  r  r  r  r  r  r  	orderbooks	            rs  fetch_order_bookzbinance.fetch_order_book  s      !!!!!!!!!V$$fTl
 $GG( 	O!44T[[&5Q5QRRRRRRRRHHH 	O!44T[[&5Q5QRRRRRRRRHHI 	O!44T[[&5Q5QRRRRRRRRHH!00Wf1M1MNNNNNNNNHJ %%h44	))(FIFF	!00>3OO	'rt  c           	      $   |                      |d          }d }d|v rd}|d|v rdnd}|                     |d          }|                     ||d |          }|                     |d          }d|v }d }	d }
|r-|                     |d          }	|                     |d	          }
n-|                     |d	          }	|                     |d
d          }
|                     i d|d|d|                     |          d|                     |dd          d|                     |dd          d|                     |d          d|                     |d          d|                     |d          d|                     |d          d|                     |d          d|                     |dd          d|d|d|                     |d           d!|                     |d"          d#|                     |d$          d%d |	|
|d&|          S )'N	closeTimer$  r  bidQtyrD   r  	lastPrice
baseVolumevolumequoteVolumer  r  r  high	highPricelowlowPricebidbidPrice	bidVolumeaskaskPrice	askVolumeaskQtyvwapweightedAvgPriceopen	openPricecloselastpreviousCloseprevClosePricechangepriceChanger  priceChangePercentaverage)r  r  r  )r  r  rm  r  safe_tickerrC  )rq  rg  r  r  r  r  r  r  isCoinmr  r  s              rs  parse_tickerzbinance.parse_ticker;  s   P %%fk::	
f#J$,$6$6ZJ##FH55!!(FD*EE446)
 	N))&,??J**68<<KK))&(;;J,,V]HMMK !
f!
!
 Y//!
 D&&v{FCC	!

 4%%fj%@@!
 4##FJ77!
 ))&(;;!
 4##FJ77!
 ))&(;;!
 D$$V-?@@!
 D&&v{FCC!
 T!
 D!
 T--f6FGG!
 d&&v}==!
  $**63GHH!!
" t#!
$ %&)!
 !
 !
* +  	rt  c                    K   |                      |           d{V }|                     |d          }|                     ddd||          ddd|dS )ab  
        the latest known information on the availability of the exchange API
        :see: https://binance-docs.github.io/apidocs/spot/en/#system-status-system
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: a `status structure <https://docs.ccxt.com/#/?id=exchange-status-structure>`
        Nr  okmaintenance)r  r   )r  updatedetar   r  )sapiGetSystemStatusr  )rq  r  r  	statusRaws       rs  fetch_statuszbinance.fetch_status  s}       11&99999999 $$Xx88	&&T'F'F	S\]]
 
 	
rt  c                   K   |                                   d{V  |                     |          }d|d         i}d}|d         r0|                     |                     ||                     d{V }n|d         r0|                     |                     ||                     d{V }n|d         r0|                     |                     ||                     d{V }n|                     |dd          }|                     |d          }|r0|                     |                     ||                     d{V }n/| 	                    |                     ||                     d{V }t          |t                    r-|                     |d	i           }|                     ||          S |                     ||          S )
aM  
        fetches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market
        :see: https://binance-docs.github.io/apidocs/spot/en/#24hr-ticker-price-change-statistics         # spot
        :see: https://binance-docs.github.io/apidocs/spot/en/#rolling-window-price-change-statistics      # spot
        :see: https://binance-docs.github.io/apidocs/futures/en/#24hr-ticker-price-change-statistics      # swap
        :see: https://binance-docs.github.io/apidocs/delivery/en/#24hr-ticker-price-change-statistics     # future
        :see: https://binance-docs.github.io/apidocs/voptions/en/#24hr-ticker-price-change-statistics     # option
        :param str symbol: unified symbol of the market to fetch the ticker for
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :param boolean [params.rolling]:(spot only) default False, if True, uses the rolling 24 hour ticker endpoint /api/v3/ticker
        :returns dict: a `ticker structure <https://docs.ccxt.com/#/?id=ticker-structure>`
        Nr  r`  rH   r  r  rollingFr   )r|  r  eapiPublicGetTickerr  fapiPublicGetTicker24hrdapiPublicGetTicker24hrr  r  publicGetTickerpublicGetTicker24hrr  ro  r  r  )rq  r  r  r  r  r  r  firstTickers           rs  fetch_tickerzbinance.fetch_ticker  s	      !!!!!!!!!V$$fTl
 ( 	X!55dkk'66R6RSSSSSSSSHHH 
	X!99$++gv:V:VWWWWWWWWHHI 	X!99$++gv:V:VWWWWWWWWHHnnVY>>GYYvy11F X!%!5!5dkk'66R6R!S!SSSSSSS!%!9!9$++gv:V:V!W!WWWWWWWh%% 	:..1b99K$$[&999  6222rt  r  c                   K   |                                   d{V  |                     |dddd          }|                     |          }d}|                     d||          \  }}d}|                     d||          \  }}d}|                     ||          r|                     |           d{V }n|                     ||          r|                     |           d{V }n|dk    r_i }|+| 	                    | 
                    |                    |d<   |                     |                     ||                     d{V }nt          | j        dz   |z   dz             |                     ||          S )a  
        fetches the bid and ask price and volume for multiple markets
        :see: https://binance-docs.github.io/apidocs/spot/en/#symbol-order-book-ticker        # spot
        :see: https://binance-docs.github.io/apidocs/futures/en/#symbol-order-book-ticker     # swap
        :see: https://binance-docs.github.io/apidocs/delivery/en/#symbol-order-book-ticker    # future
        :param str[]|None symbols: unified symbols of the markets to fetch the bids and asks for, all markets are returned if not assigned
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :param str [params.subType]: "linear" or "inverse"
        :returns dict: a dictionary of `ticker structures <https://docs.ccxt.com/#/?id=ticker-structure>`
        NTri   rD   r  z" fetchBidsAsks() does not support  markets yet)r|  market_symbolsget_market_from_symbolshandle_market_type_and_paramsr  r}  fapiPublicGetTickerBookTickerr{  dapiPublicGetTickerBookTickerjson
market_idspublicGetTickerBookTickerr  r2   r`  parse_tickersrq  r  r  r  ru  rv  r  r  s           rs  fetch_bids_askszbinance.fetch_bids_asks  s      !!!!!!!!!%%gtT4FF--g6699/6SYZZf99/6SYZZ>>$(( 
	g!??GGGGGGGGHH__T7++ 	g!??GGGGGGGGHHV^^G"%)YYtw/G/G%H%H	"!;;DKKQW<X<XYYYYYYYYHHtw)MMPTTWeefff!!(G444rt  c                 |  K   |                                   d{V  |                     |dddd          }|                     |          }d}|                     d||          \  }}d}|                     d||          \  }}d}|                     ||          r|                     |           d{V }nq|                     ||          r|                     |           d{V }n?|dk    r| 	                    |           d{V }nt          | j        dz   |z   dz             |                     ||          S )a  
        fetches the last price for multiple markets
        :see: https://binance-docs.github.io/apidocs/spot/en/#symbol-price-ticker         # spot
        :see: https://binance-docs.github.io/apidocs/future/en/#symbol-price-ticker       # swap
        :see: https://binance-docs.github.io/apidocs/delivery/en/#symbol-price-ticker     # future
        :param str[]|None symbols: unified symbols of the markets to fetch the last prices
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :param str [params.subType]: "linear" or "inverse"
        :returns dict: a dictionary of lastprices structures
        NTr   rD   z$ fetchLastPrices() does not support r  )r|  r  r  r  r  r}  fapiPublicV2GetTickerPricer{  dapiPublicGetTickerPricepublicGetTickerPricer2   r`  parse_last_prices)rq  r  r  r  ru  rv  r  s          rs  fetch_last_priceszbinance.fetch_last_prices(  s      !!!!!!!!!%%gtT4FF--g6699:KVU[\\f99:KVU[\\>>$(( $	i!<<VDDDDDDDDHH __T7++ 	i!::6BBBBBBBBHH V^^!66v>>>>>>>>HH tw)OORVVYgghhh%%h888rt  c                    |                      |d          }|dnd}|                     |d          }|                     ||d |          }|                     |d          }|d         ||                     |          |d |dS )Nr$  rD   rF   r  r  )r  r  r  r  r&  r  r  r  r  r  rC  )rq  r  r  r  ru  r  r  s          rs  parse_last_pricezbinance.parse_last_priceb  s    6 %%eV44	#+vv&##E844!!(FD$??  00X&"Y//
 
 	
rt  c                 F  K   |                                   d{V  |                     |dddd          }|                     |          }d}|                     d||          \  }}d}|                     d||          \  }}d}|                     ||          r|                     |           d{V }n|                     ||          r|                     |           d{V }n|dk    r_i }|+| 	                    | 
                    |                    |d<   |                     |                     ||                     d{V }n?|dk    r|                     |           d{V }nt          | j        dz   |z   dz             |                     ||          S )	a  
        fetches price tickers for multiple markets, statistical information calculated over the past 24 hours for each market
        :see: https://binance-docs.github.io/apidocs/spot/en/#24hr-ticker-price-change-statistics         # spot
        :see: https://binance-docs.github.io/apidocs/futures/en/#24hr-ticker-price-change-statistics      # swap
        :see: https://binance-docs.github.io/apidocs/delivery/en/#24hr-ticker-price-change-statistics     # future
        :see: https://binance-docs.github.io/apidocs/voptions/en/#24hr-ticker-price-change-statistics     # option
        :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
        :param str [params.subType]: "linear" or "inverse"
        :returns dict: a dictionary of `ticker structures <https://docs.ccxt.com/#/?id=ticker-structure>`
        NTr   rD   r  rH   z! fetchTickers() does not support r  )r|  r  r  r  r  r}  r  r{  r  r  r  r  r  r  r2   r`  r  r  s           rs  fetch_tickerszbinance.fetch_tickers  s      !!!!!!!!!%%gtT4FF--g6699.&RXYYf99.&RXYY>>$(( 	f!99&AAAAAAAAHH__T7++ 
	f!99&AAAAAAAAHHV^^G"%)YYtw/G/G%H%H	"!55dkk'66R6RSSSSSSSSHHX!55f========HHtw)LLtSVddeee!!(G444rt  c           
      F   |                      |d          }|rdnd}|                     |dd          |                     |dd          |                     |dd	          |                     |d
d          |                     |dd          |                     ||d          gS )Nr     r   r   openTimer   r  r  r  r  r  rV  r  r  )r  r>  rA  )rq  ohlcvr  r  volumeIndexs        rs  parse_ohlcvzbinance.parse_ohlcv  s    h ..33")aaq*55ua00ua00ua//ua11uk8<<
 	
rt  r   sincec           	        K   |                                   d{V  d}|                     |ddd          \  }}|r!|                     d|||||d           d{V S |                     |          }d}d}	|                     |d          }
|                     |d	          }|                     |dd	g          }||nt          ||	          }|                     | j        ||          |d
}|d         }|
dk    r1|	                    d          }|                     |d          }||d<   n||d<   |n||d<   |d         ra|dk    r[| 
                    |          }|                     |||z  dz  dz
            }|                                 }t          ||          |d<   |||d<   d}|d         r1|                     |                     ||                     d{V }n}|
dk    rj|d         r1|                     |                     ||                     d{V }n>|                     |                     ||                     d{V }n|
dk    rh|d         r0|                     |                     ||                     d{V }n|                     |                     ||                     d{V }n|d         r0|                     |                     ||                     d{V }ng|d         r0|                     |                     ||                     d{V }n/|                     |                     ||                     d{V }|                     |||||          S )a  
        fetches historical candlestick data containing the open, high, low, and close price, and the volume of a market
        :see: https://binance-docs.github.io/apidocs/spot/en/#kline-candlestick-data
        :see: https://binance-docs.github.io/apidocs/voptions/en/#kline-candlestick-data
        :see: https://binance-docs.github.io/apidocs/futures/en/#index-price-kline-candlestick-data
        :see: https://binance-docs.github.io/apidocs/futures/en/#mark-price-kline-candlestick-data
        :see: https://binance-docs.github.io/apidocs/futures/en/#kline-candlestick-data
        :see: https://binance-docs.github.io/apidocs/delivery/en/#index-price-kline-candlestick-data
        :see: https://binance-docs.github.io/apidocs/delivery/en/#mark-price-kline-candlestick-data
        :see: https://binance-docs.github.io/apidocs/delivery/en/#kline-candlestick-data
        :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 str [params.price]: "mark" or "index" for mark price and index price candles
        :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 [availble parameters](https://github.com/ccxt/ccxt/wiki/Manual#pagination-params)
        :returns int[][]: A list of candles ordered, open, high, low, close, volume
        NFr   paginater)  r(  i  r  until)intervalr  r`  rf  _r   pairr  	startTimer  r   endTimerH   rh  r  )r|  handle_option_and_params"fetch_paginated_call_deterministicr  r  r  r  r  rg  r  parse_timeframesumr  eapiPublicGetKlinesr  dapiPublicGetMarkPriceKlinesfapiPublicGetMarkPriceKlinesdapiPublicGetIndexPriceKlinesfapiPublicGetIndexPriceKlinesfapiPublicGetKlinesdapiPublicGetKlinespublicGetKlinesparse_ohlcvs)rq  r  	timeframer  r  r  r  r  defaultLimitmaxLimitr  r  r  r  partsr  durationr  nowr  s                       rs  fetch_ohlcvzbinance.fetch_ohlcv  s8     * !!!!!!!!!88z[`aa& 	~@@vW\^cenpvx|}}}}}}}}}V$$   11!!&'226GW#566!&S5I5I(()YOO
 
 $<GNN3''E##E1--D"GFOO (GH#(GK 
 i  ;199#33I>>H"hhueh.>.E.IJJG++--C),S'):):GI&!&GI( 	P!55dkk'66R6RSSSSSSSSHHf__i  a!%!B!B4;;wX^C_C_!`!```````!%!B!B4;;wX^C_C_!`!```````gi  b!%!C!CDKKPWY_D`D`!a!aaaaaaa!%!C!CDKKPWY_D`D`!a!aaaaaaaH 	P!55dkk'66R6RSSSSSSSSHHI 	P!55dkk'66R6RSSSSSSSSHH!11$++gv2N2NOOOOOOOOH6   69eUKKKrt  c                 <   d|v r|                      ||          S |                     |dd          }|                     |dd          }|                     |d|          }|                     |d          }d|v pd	|v pd
|v pd|v }|rdnd}|                     ||d |          }|d         }d }	|                     |dd          }
d }|
|
rdnd}	n+d|v r|                     |d          }	nd|v r|d         rdnd}	d }d|v r@|                     |d          |                     |                     |d                    d}d|v r|d         rdnd}d|v r|d         rdnd}d|v s|d         r|                     |                     |dd                    }|                     |d          }d|v r|                     |d          |d}|	dk    r|	dk    r
|	dk    rdnd}	d|v r|	dk    rt          j	        d |          }| 
                    |||                     |          ||                     |g d!          |                     |d"          |                     |d#          |	||                     |d$d%          ||                     |d&d'          |d(|          S ))NisDustTrader  r$  qqtyquantityr  
isIsolatedMorderListIdisMakerrD   r  misBuyerMakersellbuyr&  isBuyer
commissioncommissionAsset)r   currencyr  r  
optionSiderH   r  r  	liquidityr  r   -1)tatradeIdr`  orderIdru  pr  quoteQtybaseQty)r  r  r  r  r`  rE  ru  r&  takerOrMakerr  r  r   r  )parse_dust_trader>  r  r  r  safe_value_2r=  r  r;   
string_mul
safe_traderC  safe_string_n)rq  trader  r  r  r  isSpotTrader  r  r&  
buyerMakerr  r  r  s                 rs  parse_tradezbinance.parse_tradeY  sV   E!!((777L ''sF;;	##E366!!%V<<##E844#u,s#,sMUZDZs`imr`r*:VV

!!(FD*EE!&&uc>BB
!'266UDDu__))%88DDE!! %i 0<uuf5  ((== 33D4D4DUL]4^4^__ C &+I&6C77GLe&+GnA77'LE!!fX&6!,,T-=-=e\SY-Z-Z[[F11%EEL~~ ,,UE:: &  DFNN!%uu6u$$5==$/f==F"Y//$$U,G,G,GHH%%eY77**5&99(''sG<<&&uj)DD 
  
   	rt  c                 j  K   |                                   d{V  d}|                     |dd          \  }}|r|                     d||||           d{V S |                     |          }d|d         i}|d         s=|||d<   |                     |d	          |d
<   |                     |d          }|||d
<   |'|d         p|d         }	|	rt          |d          n||d<   |                     | j        d          }
| 	                    |dd|
          }
| 
                    |ddg          }d}|d         s|
dk    r0|                     |                     ||                     d{V }n|d         s|
dk    r0|                     |                     ||                     d{V }nm|d         s|
dk    r0|                     |                     ||                     d{V }n/|                     |                     ||                     d{V }|                     ||||          S )a9  
        get the list of most recent trades for a particular symbol
         * Default fetchTradesMethod
        :see: https://binance-docs.github.io/apidocs/spot/en/#compressed-aggregate-trades-list        # publicGetAggTrades(spot)
        :see: https://binance-docs.github.io/apidocs/futures/en/#compressed-aggregate-trades-list     # fapiPublicGetAggTrades(swap)
        :see: https://binance-docs.github.io/apidocs/delivery/en/#compressed-aggregate-trades-list    # dapiPublicGetAggTrades(future)
        :see: https://binance-docs.github.io/apidocs/voptions/en/#recent-trades-list                  # eapiPublicGetTrades(option)
         * Other fetchTradesMethod
        :see: https://binance-docs.github.io/apidocs/spot/en/#recent-trades-list                      # publicGetTrades(spot)
        :see: https://binance-docs.github.io/apidocs/futures/en/#recent-trades-list                   # fapiPublicGetTrades(swap)
        :see: https://binance-docs.github.io/apidocs/delivery/en/#recent-trades-list                  # dapiPublicGetTrades(future)
        :see: https://binance-docs.github.io/apidocs/spot/en/#old-trade-lookup-market_data            # publicGetHistoricalTrades(spot)
        :see: https://binance-docs.github.io/apidocs/future/en/#old-trade-lookup-market_data          # fapiPublicGetHistoricalTrades(swap)
        :see: https://binance-docs.github.io/apidocs/delivery/en/#old-trade-lookup-market_data        # dapiPublicGetHistoricalTrades(future)
        :see: https://binance-docs.github.io/apidocs/voptions/en/#old-trade-lookup-market_data        # eapiPublicGetHistoricalTrades(option)
        :param str symbol: unified symbol of the market to fetch trades for
        :param int [since]: only used when fetchTradesMethod is 'publicGetAggTrades', 'fapiPublicGetAggTrades', or 'dapiPublicGetAggTrades'
        :param int [limit]: default 500, max 1000
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :param int [params.until]: only used when fetchTradesMethod is 'publicGetAggTrades', 'fapiPublicGetAggTrades', or 'dapiPublicGetAggTrades'
        :param int [params.fetchTradesMethod]: 'publicGetAggTrades'(spot default), 'fapiPublicGetAggTrades'(swap default), 'dapiPublicGetAggTrades'(future default), 'eapiPublicGetTrades'(option default), 'publicGetTrades', 'fapiPublicGetTrades', 'dapiPublicGetTrades', 'publicGetHistoricalTrades', 'fapiPublicGetHistoricalTrades', 'dapiPublicGetHistoricalTrades', 'eapiPublicGetHistoricalTrades'
        :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)
         *
         * EXCHANGE SPECIFIC PARAMETERS
        :param int [params.fromId]: trade id to fetch from, default gets most recent trades, not used when fetchTradesMethod is 'publicGetTrades', 'fapiPublicGetTrades', 'dapiPublicGetTrades', or 'eapiPublicGetTrades'
        :returns Trade[]: a list of `trade structures <https://docs.ccxt.com/#/?id=public-trades>`
        NFr   r  r  r`  rH   r  i6 r  r  rF   rG   r)  r  fetchTradesMethodmethodeapiPublicGetTradesr  fapiPublicGetAggTradesr  dapiPublicGetAggTrades)r|  r  fetch_paginated_call_dynamicr  r  r  r  r  rk  r  r  r,  r  r-  r.  publicGetAggTradesparse_trades)rq  r  r  r  r  r  r  r  r  isFutureOrSwapr+  r  s               rs  fetch_tradeszbinance.fetch_tradesZ  s     8 !!!!!!!!!88PZ[[& 	h::=&RWY^`fgggggggggV$$fTl
 h 	+ ',$ &*XXeW%=%=	"%%fg66E %*	"$Vn@x0@N3ALs5$///uGG!!$,0CDD##F,?6RR6G-@#ABB( 	Sv)>>>!55dkk'66R6RSSSSSSSSHHH 	S+C!C!C!88Wf9U9UVVVVVVVVHHI 	S&,D"D"D!88Wf9U9UVVVVVVVVHH!44T[[&5Q5QRRRRRRRRHF   65%@@@rt  r`  r&  r  r  c           	      ~  K   |                                   d{V  |                     |          }|d         s#t          | j        dz   |d         z   dz             |                     |||||||          }	|                     |	           d{V }
|                     |
d          }|                     ||          S )a  
         * @ignore
        edit a trade order
        :see: https://binance-docs.github.io/apidocs/spot/en/#cancel-an-existing-order-and-send-a-new-order-trade
        :param str id: cancel order id
        :param str symbol: unified symbol of the market to create an order in
        :param str type: 'market' or 'limit' or 'STOP_LOSS' or 'STOP_LOSS_LIMIT' or 'TAKE_PROFIT' or 'TAKE_PROFIT_LIMIT' or 'STOP'
        :param str side: 'buy' or 'sell'
        :param float amount: how much of currency you want to trade in units of base currency
        :param float [price]: the price at which the order is to be fullfilled, in units of the base currency, ignored in market orders
        :param str [params.marginMode]: 'cross' or 'isolated', for spot margin trading
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: an `order structure <https://docs.ccxt.com/#/?id=order-structure>`
        NrD   z" editSpotOrder() does not support ru   ordersnewOrderResponse)r|  r  r2   r`  edit_spot_order_requestprivatePostOrderCancelReplacer  parse_order)rq  r`  r  ru  r&  r  r  r  r  payloadr  datas               rs  edit_spot_orderzbinance.edit_spot_order  s       !!!!!!!!!V$$f~ 	ltw)MMPVW]P^^ajjkkk..r64vuV\]];;GDDDDDDDDP ~~h(:;;f---rt  c                    |                      |          }|                     |g d          }	|d         |                                d}
|                                }|}|                     |dk    |dk    |          }|rd}||
d<   |                     |dd          }||dk    rd
}n|dk    rd}|                     |d         d          }|                     ||          sL||k    r#t          | j        dz   |z   dz   |z   dz             t          | j        dz   |z   dz   |z   dz             |	P|                     | j	        d          }|2| 
                    |d          }|||                                 z   |
d<   n|	|
d<   |                     | j	        d         |d          |
d<   d}d}d}d}|dk    r|                     | j	        dd          }|r|                     |dd          }|d         d         }|&|                     |t          || j                  |
d<   n|e|                     |          }|                     |          }t%          j        ||          }|                     |t          || j                  |
d<   nCd}n@d}n=|dk    rd}d}d}n0|d
k    s|dk    rd}d}n|dk    s|d k    r	d}d}d}d}n
|dk    rd}d}|r|                     ||          |
d!<   |r8|t          | j        d"z   |z   d#z             |                     ||          |
d<   |r&| 
                    |d$          | j	        d%         |
d$<   |r8|t          | j        d&z   |z   d#z             |                     ||          |
d<   d'|
d(<   |                     |d)d*          }|||
d+<   | 
                    |d$          d,k    r|                     |d$g          }|                     |g d-          }|                     |
|          S ).aI  
         * @ignore
        helper function to build request for editSpotOrder
        :param str id: order id to be edited
        :param str symbol: unified symbol of the market to create an order in
        :param str type: 'market' or 'limit' or 'STOP_LOSS' or 'STOP_LOSS_LIMIT' or 'TAKE_PROFIT' or 'TAKE_PROFIT_LIMIT' or 'STOP'
        :param str side: 'buy' or 'sell'
        :param float amount: how much of currency you want to trade in units of base currency
        :param float [price]: the price at which the order is to be fullfilled, in units of the quote currency, ignored in market orders
        :param dict params: extra parameters specific to the exchange API endpoint
        :param str [params.marginMode]: 'cross' or 'isolated', for spot margin trading
        :returns dict: request to be sent to the exchange
        newClientOrderIdclientOrderIdorigClientOrderIdr`  r  r&  MARKETLIMIT_MAKERru  	stopPricetriggerPriceN	STOP_LOSSLIMITSTOP_LOSS_LIMITr  
orderTypes( stopPrice parameter is not allowed for  r5  # is not a valid order type for the  marketr  rD   r?  r  RESULTFr  Tr   r  r  TAKE_PROFITTAKE_PROFIT_LIMITr  z- editOrder() requires a price argument for a  ordertimeInForcer  z4 editOrder() requires a stopPrice extra param for a STOP_ON_FAILUREcancelReplaceModecancelNewClientOrderIdcancelOrigClientOrderIdcancelOrderIdPO)r  r   rE  r?  r@  postOnly)r  r$  upperis_post_onlyrA  r  in_arrayr.   r`  rk  r  uuid22r  r!  r  r9   rj  r  r;   r"  amount_to_precisionprice_to_precisionr  r  r  )rq  r`  r  ru  r&  r  r  r  r  r@  r  initialUppercaseTypeuppercaseTyperZ  rE  validOrderTypesr  brokerIdtimeInForceIsRequiredpriceIsRequiredstopPriceIsRequiredquantityIsRequiredr  quoteOrderQtyNewr  amountStringpriceStringquoteOrderQuantitycancelIds                                rs  r7  zbinance.edit_spot_order_request  s    V$$**63m3m3mnnTlJJLL
 
  $zz||,$$%9X%EG[_lGlntuu 	*)M'&&v{NKK	 (( +')) 1//&.,GG}}]O<< 	v#}44"47-W#WZ`#`cf#fim#mpy#yzzz"47S=4#7:_#_bh#hkt#tuuu __T\8<<F!++FF;;'2:T[[]]2JG./*7G&'&*oodlCU6VX\^f&g&g"# %#"H$$ NN4<$OOM *#'#4#4V_f#U#U ";/8	#//3/H/HIY[cenpt  qC  0D  0DGO,,&#'#8#8#@#@L"&"7"7">">K)0);L+)V)V&/3/H/HI[]egprv  sE  0F  0FGO,,)-&&%)""g%%"O$(!!%{**0N0N"&!%000mGZ6Z6Z!%"&"O$(!!m++"O!% 	K"&":":66"J"JGJ 	F}"47-\#\_c#cfn#nooo#66vuEEGG  	Hd&6&6v}&M&M&U%)\2F%GGM" 	R "47-c#cfj#jmu#uvvv'+'>'>vy'Q'Q$'8#$%%f.FHabb')GO$FM22d::YYv77F6#z#z#z{{{{7F+++rt  c                   K   |                                   d{V  |                     |          }|d         s#t          | j        dz   |d         z   dz             |d         |                                d}	|                     |g d          }
||	d	<   |                     ||          |	d
<   ||                     ||          |	d<   |
|
|	d<   |                     |ddg          }d}|d         r0| 	                    | 
                    |	|                     d{V }n7|d         r/|                     | 
                    |	|                     d{V }|                     ||          S )a-  
        edit a trade order
        :see: https://binance-docs.github.io/apidocs/futures/en/#modify-order-trade
        :see: https://binance-docs.github.io/apidocs/delivery/en/#modify-order-trade
        :param str id: cancel 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 currency you want to trade in units of base currency
        :param float [price]: the price at which the order is to be fullfilled, in units of the base currency, ignored in market orders
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: an `order structure <https://docs.ccxt.com/#/?id=order-structure>`
        Nr  z& editContractOrder() does not support ru  r5  r`  rB  r>  r  r  r  rA  r@  r?  r  r  )r|  r  r2   r`  r[  r$  r_  r`  r  fapiPrivatePutOrderr  dapiPrivatePutOrderr9  )rq  r`  r  ru  r&  r  r  r  r  r  r@  r  s               rs  edit_contract_orderzbinance.edit_contract_order  s      !!!!!!!!!V$$j! 	ptw)QQTZ[aTbbennoooTlJJLL
 
 **63m3m3mnn	"66vvFF
#66vuEEGG$+8G'(6O5G#HII( 	T!55dkk'66R6RSSSSSSSSHHI 	T!55dkk'66R6RSSSSSSSSH8 &111rt  c           	      N  K   |                                   d{V  |                     |          }|d         r#t          | j        dz   |d         z   dz             |d         r!|                     |||||||           d{V S |                     |||||||           d{V S )a  
        edit a trade order
        :see: https://binance-docs.github.io/apidocs/spot/en/#cancel-an-existing-order-and-send-a-new-order-trade
        :see: https://binance-docs.github.io/apidocs/futures/en/#modify-order-trade
        :see: https://binance-docs.github.io/apidocs/delivery/en/#modify-order-trade
        :param str id: cancel 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 currency you want to trade in units of base currency
        :param float [price]: the price at which the order is to be fullfilled, in units of the base currency, ignored in market orders
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: an `order structure <https://docs.ccxt.com/#/?id=order-structure>`
        NrH   z editOrder() does not support ru  r5  rD   )r|  r  r2   r`  r<  rq  )	rq  r`  r  ru  r&  r  r  r  r  s	            rs  
edit_orderzbinance.edit_order  s       !!!!!!!!!V$$( 	htw)IIFSYNZ]ffggg&> 	a--b&$feU[\\\\\\\\\11"fdD&RWY_`````````rt  c                 J    ddddddddddd
}|                      |||          S )Nr  closedcanceled	cancelingrejectedexpired)
NEWPARTIALLY_FILLEDACCEPTEDFILLEDCANCELED	CANCELLEDPENDING_CANCELREJECTEDEXPIREDEXPIRED_IN_MATCHr  rq  r  statusess      rs  parse_order_statuszbinance.parse_order_status  sF     &"#)"  )
 
 &&999rt  c           
      @   |                      |d          }||                     |dd|          S |                     |                     |dd                    }|                      |d          }d|v pd|v }|rd	nd
}|                     ||d |          }|                      |dd          }	|                     |g d          }
d }d|v sd|v r=|                     |dd          }|dk    rt          j        |	d          r|}n|dk    r|}|                     |dd          }|                      |d          }|                      |d          }|                     |dd          }|                     |dd          }|                      |d|          }| 	                    |d          }| 	                    |d          }| 
                    |dg           }|                      |d          }|dk    rd}|dk    p|dk    }|dk    r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|d0|d1|d2|||	d |||d3|          S )4Nr  rx  )r  r  r  strategyStatusr  positionSidecumQuoter  rD   executedQtyr  )r$  
createTimeworkingTimetransactTimerb  r  rb  r  ru  rv  r  origQtyr  cummulativeQuoteQtycumBaseru  r&  fillsrS  GTXrY  limit_makerr  rE  r  r  )r  r   rater  r`  
strategyIdr  r@  newClientStrategyIdr  r  lastTradeTimestamplastUpdateTimestamprZ  
reduceOnlyrF  r  r   )r  filled	remainingr  r  r+  )r  
safe_orderr  r  rm  safe_integer_nr>  r;   	string_gtr=  r  rp  	omit_zeror  rC  r  )rq  rE  r  r  r  r  
isContractr  r  r  r  r  timestampValuer  r  r  r  r   ru  r&  r  rS  rZ  stopPriceStringrE  feeCostr  s                              rs  r9  zbinance.parse_order  s(   F v..??EZ#H#H&QQQ((););E8M])^)^__##E844$-G:3F
#-9ZZ6
!!(FD*EE!!%<<''/r/r/rss	!e##)>)>!00nUUN$VS11 8)7&8##%3""11%VV""5*55  00##E9jAA !!%)>
KKy$77%%eV44%%eV44ugr22&&um<<%KM)C{d/B=  D**5+>>%%dnn_&E&EFF	""5%00 ,,ULAA C
   
E 
$$$UL)DD 
 T//H]^^ 
 	 

 Y// 
 !"4 
 "#6 
 f 
 D 
 ; 
  
 $..== 
 D 
 U 
 I 
  f! 
" D# 
$ / 
  
  
0 1  	rt  ordersc           	      
  K   |                                   d{V  g }g }t          dt          |                    D ]}||         }|                     |d          }|                    |           |                     |d          }|                     |d          }	|                     |d          }
|                     |d          }|                     |di           }|                     |||	|
||          }|                    |           |                     |dd	d
d
          }| 	                    |d                   }|d         r#t          | j        dz   |d         z   dz             d}d|i}|                     ||          }|d         r|                     |           d{V }n?|d         r|                     |           d{V }n|                     |           d{V }|                     |          S )a  
        *contract only* create a list of trade orders
        :see: https://binance-docs.github.io/apidocs/futures/en/#place-multiple-orders-trade
        :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
        :returns dict: an `order structure <https://docs.ccxt.com/#/?id=order-structure>`
        Nr   r  ru  r&  r  r  r  FTrD   z! createOrders() does not support r5  rW  r  rH   )r|  r  r  r  r  r  r  create_order_requestr  r  r2   r`  r  fapiPrivatePostBatchOrderseapiPrivatePostBatchOrdersdapiPrivatePostBatchOrdersparse_orders)rq  r  r  ordersRequestsorderSymbolsr  rawOrderr  ru  r&  r  r  orderParamsorderRequestr  r  r  s                    rs  create_orderszbinance.create_orders  sQ      !!!!!!!!!q#f++&& 
	0 
	0AayH''(;;H)))##Hf55D##Hf55D__Xx88FOOHg66E..8R@@K44XtT6SXZeffL!!,////**<udDQQ\!_--&> 	ktw)LLvV\~]`iijjj>
 ++gv..( 	F!<<WEEEEEEEEHHH 	F!<<WEEEEEEEEHH!<<WEEEEEEEEHF   ***rt  c                 2  K   |                                   d{V  |                     |          }|                     |d|d                   }d}	|                     d|          \  }	}d}
|                     |dddd          \  }
}|                     |dd          }|                     |d	          }|                     |d
          }|                     |dd          }|du}|du}|du}|dup|p|p|}|                     |ddd          }|                     |dd          }|                     |g d          }|
r|
|d<   | 	                    ||||||          }d}|d         r| 
                    |           d{V }n||r<|r|                     |           d{V }n[|                     |           d{V }n>|d         rY|
r;|r|                     |           d{V }n|                     |           d{V }n|                     |           d{V }n|d         rX|
r:|r|                     |           d{V }n|                     |           d{V }n|                     |           d{V }n}|dk    s|	|
r:|
r|                     |           d{V }nU|                     |           d{V }n9|r|                     |           d{V }n|                     |           d{V }|                     ||          S )a.  
        create a trade order
        :see: https://binance-docs.github.io/apidocs/spot/en/#new-order-trade
        :see: https://binance-docs.github.io/apidocs/spot/en/#test-new-order-trade
        :see: https://binance-docs.github.io/apidocs/futures/en/#new-order-trade
        :see: https://binance-docs.github.io/apidocs/delivery/en/#new-order-trade
        :see: https://binance-docs.github.io/apidocs/voptions/en/#new-order-trade
        :see: https://binance-docs.github.io/apidocs/spot/en/#new-order-using-sor-trade
        :see: https://binance-docs.github.io/apidocs/spot/en/#test-new-order-using-sor-trade
        :see: https://binance-docs.github.io/apidocs/pm/en/#new-um-order-trade
        :see: https://binance-docs.github.io/apidocs/pm/en/#new-cm-order-trade
        :see: https://binance-docs.github.io/apidocs/pm/en/#new-margin-order-trade
        :see: https://binance-docs.github.io/apidocs/pm/en/#new-um-conditional-order-trade
        :see: https://binance-docs.github.io/apidocs/pm/en/#new-cm-conditional-order-trade
        :param str symbol: unified symbol of the market to create an order in
        :param str type: 'market' or 'limit' or 'STOP_LOSS' or 'STOP_LOSS_LIMIT' or 'TAKE_PROFIT' or 'TAKE_PROFIT_LIMIT' or 'STOP'
        :param str side: 'buy' or 'sell'
        :param float amount: how much of you want to trade in units of the base currency
        :param float [price]: the price that the order is to be fullfilled, in units of the quote currency, ignored in market orders
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :param str [params.reduceOnly]: for swap and future reduceOnly is a string 'true' or 'false' that cant be sent with close position set to True or in hedge mode. For spot margin and option reduceOnly is a boolean.
        :param str [params.marginMode]: 'cross' or 'isolated', for spot margin trading
        :param boolean [params.sor]: *spot only* whether to use SOR(Smart Order Routing) or not, default is False
        :param boolean [params.test]: *spot only* whether to use the test endpoint or not, default is False
        :param float [params.trailingPercent]: the percent to trail away from the current market price
        :param float [params.trailingTriggerPrice]: the price to trigger a trailing order, default uses the price argument
        :param float [params.triggerPrice]: the price that a trigger order is triggered at
        :param float [params.stopLossPrice]: the price that a stop loss order is triggered at
        :param float [params.takeProfitPrice]: the price that a take profit order is triggered at
        :param boolean [params.portfolioMargin]: set to True if you would like to create an order in a portfolio margin account
        :returns dict: an `order structure <https://docs.ccxt.com/#/?id=order-structure>`
        Nru  rZ   r   r^  FrF  rE  stopLossPricetakeProfitPricetrailingPercentcallbackRatesorSORr   )r  r  r   rH   r  r  rE   )r|  r  r  r~  r}  r  safe_bool_2r  r  r  eapiPrivatePostOrderprivatePostSorOrderTestprivatePostSorOrderpapiPostUmConditionalOrderpapiPostUmOrderfapiPrivatePostOrderpapiPostCmConditionalOrderpapiPostCmOrderdapiPrivatePostOrderpapiPostMarginOrdersapiPostMarginOrderprivatePostOrderTestprivatePostOrderr9  )rq  r  ru  r&  r  r  r  r  r  rp  rq  rF  r  r  r  isTrailingPercentOrder
isStopLossisTakeProfitisConditionalr  r   r  r  s                          rs  create_orderzbinance.create_orderc  sK     B !!!!!!!!!V$$%%fffVnEE

!??vVV
F $($C$CFM[actv{$|$|!6))&.+NN((AA**63DEE,,V5FWW!0!<"$.
&d2%T1j6LjPZj^jvueU;;~~ffe446#9#9#9:: 	:(9F$%++FD$vVV(  	@!66w????????HH 	@ C!%!=!=g!F!FFFFFFF!%!9!9'!B!BBBBBBBH 	@  D  C%)%D%DW%M%MMMMMMMHH%)%9%9'%B%BBBBBBBHH!%!:!:7!C!CCCCCCCI 	@  D  C%)%D%DW%M%MMMMMMMHH%)%9%9'%B%BBBBBBBHH!%!:!:7!C!CCCCCCC8##z'=AR'=  C!%!9!9'!B!BBBBBBB!%!9!9'!B!BBBBBBB @!%!:!:7!C!CCCCCCC!%!6!6w!?!???????&111rt  c                    |                      |          }|                     |d|d                   }|                     |dd          }	|                                }
|
dk    }|
dk    }|d         |                                d}d}|                     |d	d
dd          \  }}d}|                     d	|          \  }}|dk    s
||d         rB|                     |dd          }|                     |d          }|d         r||d<   n|rd|d<   |                     |dd          }|                     |d|          }|                     |d          }|                     |d          }|                     |dd|                     |                    }|                     |dd          }|                     |d          }|du}|dup|du}|du}|du}|p|p|p|}|o|}|du}|                                }d} |r#d}||d<   || 	                    ||          |d<   nC|r |} |r|d         rdnd}n0|r|d         rd nd!}n!|r|} |r|d         rd"nd#}n|r|d         rd#nd$}|d         r*|d%k    r#t          | j        d&z   |z   d'z   |z   d(z             n~|                     |d)         d*          }!|                     ||!          sL|
|k    r#t          | j        d+z   |z   d&z   |z   d,z             t          | j        d&z   |z   d'z   |z   d(z             |rd-nd}"|	Z|                     | j        d.i           }#|d         rd/nd0}$|                     |#||$          }%|%|                                 z   ||"<   n|	||"<   d}&|s8|                     ||
d1k    |          }&|d2         s|dk    r|&rd1}|d3k    rd4|d5<   |d2k    s|dk    r(|s&|                     | j        d6         |d7          |d6<   nd8|d6<   |rd9nd}'|||'<   d}(d})d}*d}+|dk    r|d2         r|                     | j        d:d4          },|,r|                     |d:d;          }-|d<         d=         }.|-'|                     |-t&          |.| j                  |d:<   n|e|                     |          }/|                     |          }0t+          j        |/|0          }1|                     |1t&          |.| j                  |d:<   nd4}+nd4}+nd4}+n|dk    rd4})d4}(d4}+n|dk    s|d#k    rd4}*d4}+|d>         s|d?         rd4})n}|d!k    s|d$k    r	d4}+d4}*d4})d4}(nh|d1k    rd4})d4}+n]|d k    rd4}+d4}*d4})nP|dk    s|d"k    r|                     |d@          }2|2d4}+d4}*n'|dk    r!d4}+|t          | j        dAz   |z   dBz             |+r4|r|                     |          |dC<   n|                     ||          |dC<   |)r:|s8|t          | j        dDz   |z   dBz             | 	                    ||          |d=<   |*rd|d         r | t          | j        dEz   |z   dBz             n!|| t          | j        dFz   |z   dBz             | | 	                    ||           |d<   |(r&|                     |dG          | j        dH         |dG<   |s|d         r|&rdI|dG<   |                     |dG          dJk    r|                     |dG          }|                     |g dK          }3|                     ||3          S )LaW  
         * @ignore
        helper function to build the 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 that the order is to be fullfilled, 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
        ru  r?  r@  rC  rH  r`  rB  NrZ   r   r^  FrE   rH   r  
AUTO_REPAYsideEffectTyperF  rE  r  r  trailingDeltatrailingTriggerPriceactivationPricer  r  
priceMatchTRAILING_STOP_MARKETr  STOP_MARKETrG  STOPrI  TAKE_PROFIT_MARKETrP  rQ  r  rL  rM  rN  r  rJ  rK  r5  r  r  r  r  rD  rD   rU  Tr	  r  r  rO  strategyTyper  r   r  r  r  r  rP   z6 createOrder() requires a trailingPercent param for a rR  r  z/ createOrder() requires a price argument for a z6 createOrder() requires a stopPrice extra param for a zA createOrder() requires a stopPrice or trailingDelta param for a rS  r  r  rY  )ru  r?  r@  rZ  r  r  rE  rF  r  r  r  r   r   )r  r  r  r[  r}  r~  r  r  r  r`  r.   r`  r  r]  r  rk  r^  r\  r  r9   rj  r;   r"  rB  r_  r  )4rq  r  ru  r&  r  r  r  r  r  r@  ra  isMarketOrderisLimitOrderr  rq  rp  r  rF  r  r  r  r  r  r  r  r  r  isTriggerOrderr  isPortfolioMarginConditionalisPriceMatchrb  rE  rc  clientOrderIdRequestr  	defaultIdrd  rZ  typeRequestre  rf  rg  rh  r  ri  r  rj  rk  rl  rP   requestParamss4                                                       rs  r  zbinance.create_order_request  s	    V$$%%fffVnEE
**63EWW#zz||,8+w6TlJJLL
 
 !$($C$CFM[actv{$|$|!6
!??vVV
F(""
(>6(CS(>eDDJYYv|44Fh =(2%% =0<G,-))&.+NN((,OO**63DEE((AA#11&:PRceiezez  |A  fB  fB   C   C,,V5FWW%%fl;;
!0!<"$.K-t2K
&d2%T1&^*@^J^R^(9(Km$!-

	! 	]2M&5GN##/-1-D-DVMa-b-b)* 	]%I T17
1C T T*0*< SBS 	]'I ]8>z8J ] 4 4P] ]17
1C \I\( 		zx"47S=4#7:_#_bh#hkt#tuuu   #nnVF^\JJO==@@ z'=88&tw1['[^d'dgj'jmq'qt}'}~~~&tw}t';>c'cfl'lox'xyyy8Tl44Zl ^^DL(B??F)/
);N,I''
IFFH,4t{{}},DG()),9G()  	1((8LP]8]_effHf~ 1x!7!7 2$1M++,0GL)6!!zX'='=HY'=*.*:*:4<HZ;[]aci*j*jG&'' +3G&'(DPnn&, %#"* H$$f~ * $t|_d S S  .'+'9'9&/SY'Z'Z$ &{ 3G <I'3373L3LM]_girtx  uG  4H  4H00*'+'<'<V'D'D&*&;&;E&B&B-4-?k-Z-Z*373L3LM_aiktvz  wI  4J  4J00-1**)-&&%)""g%%"O$(!!%{**0N0N"&!%h '6)#4 '"&000mGZ6Z6Z!%"&"O$(!!m++"O!%f$$!%"&"OO},,-CW2W2W NN6?CCM$%)""&444!%&"47-e#ehl#low#wxxx 	O  O&*&;&;F&C&C
##&*&>&>vv&N&N
# 	F< 	F}"47-^#^ae#ehp#pqqq#66vuEEGG 		Rj! H$&tw1i'ilp'ps{'{||| % !(Y->&tw1t'tw{'{  G  (G  H  H  H$'+'>'>vy'Q'Q$  	Hd&6&6v}&M&M&U%)\2F%GGM"  	+VJ%7 	+H 	+%*GM"FM22d::YYv}55F		&  +q  +q  +q  r  r{{7M222rt  r   c                    K   |                                   d{V  |                     |          }|d         st          | j        dz             ||d<   |                     |d||d|           d{V S )a  
        create a market order by providing the symbol, side and cost
        :see: https://binance-docs.github.io/apidocs/spot/en/#new-order-trade
        :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>`
        NrD   z6 createMarketOrderWithCost() supports spot orders onlyr  r  r|  r  r2   r`  r  )rq  r  r&  r   r  r  s         rs  create_market_order_with_costz%binance.create_market_order_with_cost  s       !!!!!!!!!V$$f~ 	ctw)aabbb"&&&vxtT6RRRRRRRRRrt  c                    K   |                                   d{V  |                     |          }|d         st          | j        dz             ||d<   |                     |dd|d|           d{V S )a  
        create a market buy order by providing the symbol and cost
        :see: https://binance-docs.github.io/apidocs/spot/en/#new-order-trade
        :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>`
        NrD   z9 createMarketBuyOrderWithCost() supports spot orders onlyr  r  r  r  rq  r  r   r  r  s        rs  !create_market_buy_order_with_costz)binance.create_market_buy_order_with_cost  s       !!!!!!!!!V$$f~ 	ftw)ddeee"&&&vxdFSSSSSSSSSrt  c                    K   |                                   d{V  |                     |          }|d         st          | j        dz             ||d<   |                     |dd|d|           d{V S )a  
        create a market sell order by providing the symbol and cost
        :see: https://binance-docs.github.io/apidocs/spot/en/#new-order-trade
        :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>`
        NrD   z: createMarketSellOrderWithCost() supports spot orders onlyr  r  r  r  r  s        rs  "create_market_sell_order_with_costz*binance.create_market_sell_order_with_cost  s       !!!!!!!!!V$$f~ 	gtw)eefff"&&&vxtVTTTTTTTTTrt  c                   K   |t          | j        dz             |                                  d{V  |                     |          }|                     | j        ddd          }|                     |d|          }d}|                     d|          \  }}d}|                     |dddd	          \  }}d
|d         i}	|                     |dd          }
|
|d         r|
|	d<   n|
|	d<   n||	d<   | 	                    |g d          }d}|d         r1| 
                    |                     |	|                     d{V }n||d         rd|r1|                     |                     |	|                     d{V }nA|                     |                     |	|                     d{V }n|d         rb|r0|                     |                     |	|                     d{V }n|                     |                     |	|                     d{V }n|dk    s||rm|r0|                     |                     |	|                     d{V }nj|dk    rd|	d<   |                     |                     |	|                     d{V }n/|                     |                     |	|                     d{V }|                     ||          S )a
  
        fetches information on an order made by the user
        :see: https://binance-docs.github.io/apidocs/spot/en/#query-order-user_data
        :see: https://binance-docs.github.io/apidocs/futures/en/#query-order-user_data
        :see: https://binance-docs.github.io/apidocs/delivery/en/#query-order-user_data
        :see: https://binance-docs.github.io/apidocs/voptions/en/#query-single-order-trade
        :see: https://binance-docs.github.io/apidocs/spot/en/#query-margin-account-39-s-order-user_data
        :see: https://binance-docs.github.io/apidocs/pm/en/#query-um-order-user_data
        :see: https://binance-docs.github.io/apidocs/pm/en/#query-cm-order-user_data
        :see: https://binance-docs.github.io/apidocs/pm/en/#query-margin-account-order-user_data
        :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 str [params.marginMode]: 'cross' or 'isolated', for spot margin trading
        :param boolean [params.portfolioMargin]: set to True if you would like to fetch an order in a portfolio margin account
        :returns dict: An `order structure <https://docs.ccxt.com/#/?id=order-structure>`
        Nz( fetchOrder() requires a symbol argumentr   r  rD   ru  r   r^  Fr  r`  rA  r@  rH   r  )ru  r@  rA  r  r  rE   rU  Tr	  )r'   r`  r|  r  r  rk  r  r~  r}  r  eapiPrivateGetOrderr  papiGetUmOrderfapiPrivateGetOrderpapiGetCmOrderdapiPrivateGetOrderpapiGetMarginOrdersapiGetMarginOrderprivateGetOrderr9  )rq  r`  r  r  r  r  ru  rp  rq  r  r@  r  s               rs  fetch_orderzbinance.fetch_order  s     $ >#DG.X$XYYY!!!!!!!!!V$$((|]TZ[[<<
!??fUU
F $($C$CFLZ`bsuz${${!6fTl
 **63FXX$h =+8((/<+,,!#GI6#Q#Q#QRR( 	P!55dkk'66R6RSSSSSSSSHHH 	P  X!%!4!4T[[&5Q5Q!R!RRRRRRR!%!9!9$++gv:V:V!W!WWWWWWWI 	P  X!%!4!4T[[&5Q5Q!R!RRRRRRR!%!9!9$++gv:V:V!W!WWWWWWWhJ$:?P$:  W!%!8!8Wf9U9U!V!VVVVVVV++,0GL)!%!8!8Wf9U9U!V!VVVVVVV!11$++gv2N2NOOOOOOOOH&111rt  c                   K   |t          | j        dz             |                                  d{V  d}|                     |dd          \  }}|r|                     d||||           d{V S |                     |          }|                     | j        dd|d                   }|                     |d|          }d}	| 	                    d|          \  }	}d}
| 
                    |ddd	d          \  }
}|                     |d
d          }|                     |g d          }d|d         i}|                     d||          \  }}|||d<   |||d<   d}|d         r1|                     |                     ||                     d{V }n|d         r|
rd|r1|                     |                     ||                     d{V }n|                     |                     ||                     d{V }nr|                     |                     ||                     d{V }nA|d         r|
rc|r1|                     |                     ||                     d{V }n|                     |                     ||                     d{V }n|                     |                     ||                     d{V }n|
r0|                     |                     ||                     d{V }nr|dk    s|	;|	dk    rd|d<   |                     |                     ||                     d{V }n/|                     |                     ||                     d{V }|                     ||||          S )a8  
        fetches information on multiple orders made by the user
        :see: https://binance-docs.github.io/apidocs/spot/en/#all-orders-user_data
        :see: https://binance-docs.github.io/apidocs/futures/en/#all-orders-user_data
        :see: https://binance-docs.github.io/apidocs/delivery/en/#all-orders-user_data
        :see: https://binance-docs.github.io/apidocs/voptions/en/#query-option-order-history-trade
        :see: https://binance-docs.github.io/apidocs/spot/en/#query-margin-account-39-s-all-orders-user_data
        :see: https://binance-docs.github.io/apidocs/pm/en/#query-all-um-orders-user_data
        :see: https://binance-docs.github.io/apidocs/pm/en/#query-all-cm-orders-user_data
        :see: https://binance-docs.github.io/apidocs/pm/en/#query-all-um-conditional-orders-user_data
        :see: https://binance-docs.github.io/apidocs/pm/en/#query-all-cm-conditional-orders-user_data
        :see: https://binance-docs.github.io/apidocs/pm/en/#query-all-margin-account-orders-user_data
        :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 str [params.marginMode]: 'cross' or 'isolated', for spot margin trading
        :param int [params.until]: the latest time in ms to fetch orders for
        :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)
        :param boolean [params.portfolioMargin]: set to True if you would like to fetch orders in a portfolio margin account
        :param boolean [params.stop]: set to True if you would like to fetch portfolio margin account stop or conditional orders
        :returns Order[]: a list of `order structures <https://docs.ccxt.com/#/?id=order-structure>`
        Nz) fetchOrders() requires a symbol argumentFr   r  r  ru  r   r^  stopconditional)r  r  ru  r  r`  r  r  r  rH   r  r  rE   rU  Tr	  )r'   r`  r|  r  r/  r  r  rk  r  r~  r}  r  r  handle_until_optioneapiPrivateGetHistoryOrdersr  papiGetUmConditionalAllOrderspapiGetUmAllOrdersfapiPrivateGetAllOrderspapiGetCmConditionalAllOrderspapiGetCmAllOrdersdapiPrivateGetAllOrderspapiGetMarginAllOrderssapiGetMarginAllOrdersprivateGetAllOrdersr  )rq  r  r  r  r  r  r  r  ru  rp  rq  r  r  r  s                 rs  fetch_orderszbinance.fetch_orders  sm     0 >#DG.Y$YZZZ!!!!!!!!!88PZ[[& 	h::=&RWY^`fgggggggggV$$((}mU[\bUcdd<<
!??vVV
F $($C$CFM[actv{$|$|!6((GG6#B#B#BCCfTl
 229gvNN#(GK $GG( 	X!==dkk'SY>Z>Z[[[[[[[[HHH 	X  \  [%)%G%GT[]cHdHd%e%eeeeeeeHH%)%<%<T[[RX=Y=Y%Z%ZZZZZZZHH!%!=!=dkk'SY>Z>Z![![[[[[[[I 	X  \  [%)%G%GT[]cHdHd%e%eeeeeeeHH%)%<%<T[[RX=Y=Y%Z%ZZZZZZZHH!%!=!=dkk'SY>Z>Z![![[[[[[[  X!%!<!<T[[RX=Y=Y!Z!ZZZZZZZ!!Z%;++,0GL)!%!<!<T[[RX=Y=Y!Z!ZZZZZZZ!%!9!9$++gv:V:V!W!WWWWWWWj   65%@@@rt  c                 N  K   |                                   d{V  d}d}i }d}|                     d|          \  }}d}	|                     |dddd          \  }	}|                     |g d          }
|c|                     |          }|d         |d<   |                     | j        dd	d
          }d|v r|d         n|}|                     |d|          }n| j        d         rc| j        }t          |          }| 
                    |dz            }t          | j        dz   t          |          z   dz   | j        z   dz             |                     | j        dd	d
          }|                     |d|          }d}|                     d||          \  }}|                     |g d          }d}|dk    r?|||d<   |||d<   |                     |                     ||                     d{V }n|                     ||          r|	rd|
r1|                     |                     ||                     d{V }n|                     |                     ||                     d{V }n|                     |                     ||                     d{V }nj|                     ||          r|	rc|
r1|                     |                     ||                     d{V }n|                     |                     ||                     d{V }n|                     |                     ||                     d{V }n|dk    s||	r|	r0|                     |                     ||                     d{V }n|dk    rd|d<   |t7          | j        dz             |                     |                     ||                     d{V }n/|                     |                     ||                     d{V }|                     ||||          S )a	  
        fetch all unfilled currently open orders
        :see: https://binance-docs.github.io/apidocs/spot/en/#cancel-an-existing-order-and-send-a-new-order-trade
        :see: https://binance-docs.github.io/apidocs/futures/en/#current-all-open-orders-user_data
        :see: https://binance-docs.github.io/apidocs/delivery/en/#current-all-open-orders-user_data
        :see: https://binance-docs.github.io/apidocs/voptions/en/#query-current-open-option-orders-user_data
        :see: https://binance-docs.github.io/apidocs/spot/en/#current-open-orders-user_data
        :see: https://binance-docs.github.io/apidocs/futures/en/#current-all-open-orders-user_data
        :see: https://binance-docs.github.io/apidocs/delivery/en/#current-all-open-orders-user_data
        :see: https://binance-docs.github.io/apidocs/voptions/en/#query-current-open-option-orders-user_data
        :see: https://binance-docs.github.io/apidocs/spot/en/#query-margin-account-39-s-open-orders-user_data
        :see: https://binance-docs.github.io/apidocs/pm/en/#query-all-current-um-open-orders-user_data
        :see: https://binance-docs.github.io/apidocs/pm/en/#query-all-current-cm-open-orders-user_data
        :see: https://binance-docs.github.io/apidocs/pm/en/#query-all-current-um-open-conditional-orders-user_data
        :see: https://binance-docs.github.io/apidocs/pm/en/#query-all-current-cm-open-conditional-orders-user_data
        :see: https://binance-docs.github.io/apidocs/pm/en/#query-current-margin-open-order-user_data
        :param str symbol: unified market symbol
        :param int [since]: the earliest time in ms to fetch open orders for
        :param int [limit]: the maximum number of open orders structures to retrieve
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :param str [params.marginMode]: 'cross' or 'isolated', for spot margin trading
        :param boolean [params.portfolioMargin]: set to True if you would like to fetch open orders in the portfolio margin account
        :param boolean [params.stop]: set to True if you would like to fetch portfolio margin account conditional orders
        :param str [params.subType]: "linear" or "inverse"
        :returns Order[]: a list of `order structures <https://docs.ccxt.com/#/?id=order-structure>`
        Nr   r   r^  Fr  r  triggerr`  r  r  rD   ru  r  r  zm fetchOpenOrders() WARNING: fetching open orders without specifying a symbol is rate-limited to one call per z? seconds. Do not call self method frequently to avoid ban. Set zX.options["warnOnFetchOpenOrdersWithoutSymbol"] = False to suppress self warning message.)ru  r  r  r  rH   r  r  rE   rU  Tr	  zB fetchOpenOrders() requires a symbol argument for isolated markets)r|  r~  r}  safe_bool_nr  r  rk  r  r  r  parse_to_intr#   r`  r  r  r  eapiPrivateGetOpenOrdersr  r}  papiGetUmConditionalOpenOrderspapiGetUmOpenOrdersfapiPrivateGetOpenOrdersr{  papiGetCmConditionalOpenOrderspapiGetCmOpenOrdersdapiPrivateGetOpenOrderspapiGetMarginOpenOrdersr'   sapiGetMarginOpenOrdersprivateGetOpenOrdersr  )rq  r  r  r  r  r  ru  r  rp  rq  r  r  r  r  
numSymbolsfetchOpenOrdersRateLimitrv  r  s                     rs  fetch_open_orderszbinance.fetch_open_orders  sA     6 !!!!!!!!!
!??@QSYZZ
F $($C$CFL]_egxz  %A  %A!6((1S1S1STT[[((F &tGH,,T\;Lm]cddK,2f,<,<;J##FFJ??DD\>? 	AlGWJ'+'8'8a'H'H$  +Z  !Z  ]`  ay  ]z  ]z  !z  }~  !~  AE  AH  !H  Ke  !e  f  f  f,,T\;Lm]cddK##FFK@@D99:KVU[\\6#M#M#MNN8 ',$ #( !::4;;wPV;W;WXXXXXXXXHH^^D'** 	U  ]  \%)%H%HU\^dIeIe%f%fffffffHH%)%=%=dkk'SY>Z>Z%[%[[[[[[[HH!%!>!>t{{7TZ?[?[!\!\\\\\\\__T7++ 	U  ]  \%)%H%HU\^dIeIe%f%fffffffHH%)%=%=dkk'SY>Z>Z%[%[[[[[[[HH!%!>!>t{{7TZ?[?[!\!\\\\\\\X!7;L!7  \!%!=!=dkk'SY>Z>Z![![[[[[[[++,0GL)~/:~0~!%!=!=dkk'SY>Z>Z![![[[[[[[!66t{{7F7S7STTTTTTTTH  65%@@@rt  c                   K   |t          | j        dz             |                                  d{V  |                     |          }d|d         i}d}|                     |dddd          \  }}|                     |g d	          }|                     |g d	          }|o|}|rd
nd}	|||	<   d}
|d         r|rd|r1|                     |                     ||                     d{V }
n;| 	                    |                     ||                     d{V }
n
| 
                    |                     ||                     d{V }
n|d         r|rb|r0|                     |                     ||                     d{V }
n|                     |                     ||                     d{V }
nn|                     |                     ||                     d{V }
n>|d         rt          | j        dz             |d         rt          | j        dz             |                     |
|          S )a  
        fetch an open order by the id
        :see: https://binance-docs.github.io/apidocs/futures/en/#query-current-open-order-user_data
        :see: https://binance-docs.github.io/apidocs/delivery/en/#query-current-open-order-user_data
        :see: https://binance-docs.github.io/apidocs/pm/en/#query-current-um-open-order-user_data
        :see: https://binance-docs.github.io/apidocs/pm/en/#query-current-cm-open-order-user_data
        :see: https://binance-docs.github.io/apidocs/pm/en/#query-current-um-open-conditional-order-user_data
        :see: https://binance-docs.github.io/apidocs/pm/en/#query-current-cm-open-conditional-order-user_data
        :param str id: order id
        :param str symbol: unified market symbol
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :param str [params.trigger]: set to True if you would like to fetch portfolio margin account stop or conditional orders
        :returns dict: an `order structure <https://docs.ccxt.com/#/?id=order-structure>`
        Nz, fetchOpenOrder() requires a symbol argumentr  r`  r   r   r^  Fr  r  r  r  r  rH   z1 fetchOpenOrder() does not support option marketsrD   z/ fetchOpenOrder() does not support spot markets)r'   r`  r|  r  r}  r  r  papiGetUmConditionalOpenOrderr  papiGetUmOpenOrderfapiPrivateGetOpenOrderpapiGetCmConditionalOpenOrderpapiGetCmOpenOrderdapiPrivateGetOpenOrderr2   r9  )rq  r`  r  r  r  r  rq  r  r  orderIdRequestr  s              rs  fetch_open_orderzbinance.fetch_open_orderZ  s      >#DG.\$\]]]!!!!!!!!!V$$fTl
 !$($C$CFL\^dfwy~$$!6((1S1S1STT6#E#E#EFF(9(Km$)ET9"$( 	`  \  [%)%G%GT[]cHdHd%e%eeeeeeeHH%)%<%<T[[RX=Y=Y%Z%ZZZZZZZHH!%!=!=dkk'SY>Z>Z![![[[[[[[I 	`  \  [%)%G%GT[]cHdHd%e%eeeeeeeHH%)%<%<T[[RX=Y=Y%Z%ZZZZZZZHH!%!=!=dkk'SY>Z>Z![![[[[[[[h `"47-`#`aaa `"47-^#^___j &111rt  c                    K   |t          | j        dz             |                     ||d|           d{V }|                     |dd          }|                     |||          S )a  
        fetches information on multiple closed orders made by the user
        :see: https://binance-docs.github.io/apidocs/spot/en/#all-orders-user_data
        :see: https://binance-docs.github.io/apidocs/futures/en/#all-orders-user_data
        :see: https://binance-docs.github.io/apidocs/delivery/en/#all-orders-user_data
        :see: https://binance-docs.github.io/apidocs/voptions/en/#query-option-order-history-trade
        :see: https://binance-docs.github.io/apidocs/spot/en/#query-margin-account-39-s-all-orders-user_data
        :see: https://binance-docs.github.io/apidocs/pm/en/#query-all-um-orders-user_data
        :see: https://binance-docs.github.io/apidocs/pm/en/#query-all-cm-orders-user_data
        :see: https://binance-docs.github.io/apidocs/pm/en/#query-all-um-conditional-orders-user_data
        :see: https://binance-docs.github.io/apidocs/pm/en/#query-all-cm-conditional-orders-user_data
        :see: https://binance-docs.github.io/apidocs/pm/en/#query-all-margin-account-orders-user_data
        :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 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)
        :param boolean [params.portfolioMargin]: set to True if you would like to fetch orders in a portfolio margin account
        :param boolean [params.stop]: set to True if you would like to fetch portfolio margin account stop or conditional orders
        :returns Order[]: a list of `order structures <https://docs.ccxt.com/#/?id=order-structure>`
        Nz/ fetchClosedOrders() requires a symbol argumentr  ru  r'   r`  r  	filter_byfilter_by_since_limitrq  r  r  r  r  r  filteredOrderss          rs  fetch_closed_orderszbinance.fetch_closed_orders#  s{      , >#DG._$_```((fEEEEEEEE(CC)).%GGGrt  c                    K   |t          | j        dz             |                     ||d|           d{V }|                     |dd          }|                     |||          S )  
        fetches information on multiple canceled orders made by the user
        :see: https://binance-docs.github.io/apidocs/spot/en/#all-orders-user_data
        :see: https://binance-docs.github.io/apidocs/spot/en/#query-margin-account-39-s-all-orders-user_data
        :see: https://binance-docs.github.io/apidocs/voptions/en/#query-option-order-history-trade
        :see: https://binance-docs.github.io/apidocs/pm/en/#query-all-um-orders-user_data
        :see: https://binance-docs.github.io/apidocs/pm/en/#query-all-cm-orders-user_data
        :see: https://binance-docs.github.io/apidocs/pm/en/#query-all-um-conditional-orders-user_data
        :see: https://binance-docs.github.io/apidocs/pm/en/#query-all-cm-conditional-orders-user_data
        :see: https://binance-docs.github.io/apidocs/pm/en/#query-all-margin-account-orders-user_data
        :param str symbol: unified market symbol of the market the 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 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)
        :param boolean [params.portfolioMargin]: set to True if you would like to fetch orders in a portfolio margin account
        :param boolean [params.stop]: set to True if you would like to fetch portfolio margin account stop or conditional orders
        :returns dict[]: a list of `order structures <https://docs.ccxt.com/#/?id=order-structure>`
        Nz1 fetchCanceledOrders() requires a symbol argumentr  rv  r  r"  s          rs  fetch_canceled_orderszbinance.fetch_canceled_orders?  s{      ( >#DG.a$abbb((fEEEEEEEE*EE)).%GGGrt  c                 V  K   |t          | j        dz             |                     ||d|           d{V }|                     |dd          }|                     |dd          }|                     ||          }|                     |d          }	|                     |	||          S )r&  Nz: fetchCanceledAndClosedOrders() requires a symbol argumentr  rv  ru  r  )r'   r`  r  r   r  sort_byr!  )
rq  r  r  r  r  r  canceledOrdersclosedOrdersr#  sortedOrderss
             rs   fetch_canceled_and_closed_ordersz(binance.fetch_canceled_and_closed_ordersY  s      ( >#DG.j$jkkk((fEEEEEEEE*EE~~fhAA**><HH||NK@@)),uEEErt  c                   K   |t          | j        dz             |                                  d{V  |                     |          }|                     | j        ddd          }|                     |d|          }d}|                     d|          \  }}d}|                     |dddd	          \  }}| 	                    |d
d          }	d|d         i}
| 
                    |g d          }||d         r||
d<   n|r|	r||
d<   n||
d<   n|r|	r||
d<   n||
d<   |                     |g d          }d}|d         r1|                     |                     |
|                     d{V }n|d         r|rd|	r1|                     |                     |
|                     d{V }n|                     |                     |
|                     d{V }nt|                     |                     |
|                     d{V }nC|d         r|rc|	r1|                     |                     |
|                     d{V }n|                     |                     |
|                     d{V }n|                     |                     |
|                     d{V }n|dk    s||rm|r0|                     |                     |
|                     d{V }nj|dk    rd|
d<   |                     |                     |
|                     d{V }n/|                     |                     |
|                     d{V }|                     ||          S )a  
        cancels an open order
        :see: https://binance-docs.github.io/apidocs/spot/en/#cancel-order-trade
        :see: https://binance-docs.github.io/apidocs/futures/en/#cancel-order-trade
        :see: https://binance-docs.github.io/apidocs/delivery/en/#cancel-order-trade
        :see: https://binance-docs.github.io/apidocs/voptions/en/#cancel-option-order-trade
        :see: https://binance-docs.github.io/apidocs/spot/en/#margin-account-cancel-order-trade
        :see: https://binance-docs.github.io/apidocs/pm/en/#cancel-um-order-trade
        :see: https://binance-docs.github.io/apidocs/pm/en/#cancel-cm-order-trade
        :see: https://binance-docs.github.io/apidocs/pm/en/#cancel-um-conditional-order-trade
        :see: https://binance-docs.github.io/apidocs/pm/en/#cancel-cm-conditional-order-trade
        :see: https://binance-docs.github.io/apidocs/pm/en/#cancel-margin-account-order-trade
        :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 boolean [params.portfolioMargin]: set to True if you would like to cancel an order in a portfolio margin account
        :param boolean [params.stop]: set to True if you would like to cancel a portfolio margin account conditional order
        :returns dict: An `order structure <https://docs.ccxt.com/#/?id=order-structure>`
        Nz) cancelOrder() requires a symbol argumentrM   r  rD   ru  r   r^  Fr  r  r  r`  )rA  r@  r  rH   r@  r  rA  r  r  )ru  rA  r@  r  r  r  r  r  rE   rU  Tr	  )r'   r`  r|  r  r  rk  r  r~  r}  r  r$  r  eapiPrivateDeleteOrderr  papiDeleteUmConditionalOrderpapiDeleteUmOrderfapiPrivateDeleteOrderpapiDeleteCmConditionalOrderpapiDeleteCmOrderdapiPrivateDeleteOrderpapiDeleteMarginOrdersapiDeleteMarginOrderprivateDeleteOrderr9  )rq  r`  r  r  r  r  ru  rp  rq  r  r  r@  r  s                rs  cancel_orderzbinance.cancel_orderv  sd     ( >#DG.Y$YZZZ!!!!!!!!!V$$((}mU[\\<<
!??vVV
F $($C$CFM[actv{$|$|!6((GGfTl
 **63p3p3pqq$h A+8(($ A A5BG1223@G/00  (] ((*%%%'	"6###  A  A( 	S!88Wf9U9UVVVVVVVVHHH 	S  [  Z%)%F%Ft{{SZ\bGcGc%d%dddddddHH%)%;%;DKKQW<X<X%Y%YYYYYYYHH!%!<!<T[[RX=Y=Y!Z!ZZZZZZZI 	S  [  Z%)%F%Ft{{SZ\bGcGc%d%dddddddHH%)%;%;DKKQW<X<X%Y%YYYYYYYHH!%!<!<T[[RX=Y=Y!Z!ZZZZZZZhJ$:?P$:  Z!%!;!;DKKQW<X<X!Y!YYYYYYY++,0GL)!%!;!;DKKQW<X<X!Y!YYYYYYY!44T[[&5Q5QRRRRRRRRH&111rt  c                 H  K   |t          | j        dz             |                                  d{V  |                     |          }d|d         i}d}|                     |dddd          \  }}|                     |d	d
          }|                     |d|d                   }|                     |g d          }d}|                     d|          \  }}d}	|d         r1| 	                    | 
                    ||                     d{V }	n|d         r|rd|r1|                     | 
                    ||                     d{V }	n|                     | 
                    ||                     d{V }	nt|                     | 
                    ||                     d{V }	nC|d         r|rc|r1|                     | 
                    ||                     d{V }	n|                     | 
                    ||                     d{V }	n|                     | 
                    ||                     d{V }	n|dk    s||rm|r0|                     | 
                    ||                     d{V }	nj|dk    rd|d<   |                     | 
                    ||                     d{V }	n/|                     | 
                    ||                     d{V }	t)          |	t*                    r|                     |	|          S |	S )a  
        cancel all open orders in a market
        :see: https://binance-docs.github.io/apidocs/spot/en/#cancel-all-open-orders-on-a-symbol-trade
        :see: https://binance-docs.github.io/apidocs/futures/en/#cancel-all-open-orders-trade
        :see: https://binance-docs.github.io/apidocs/delivery/en/#cancel-all-open-orders-trade
        :see: https://binance-docs.github.io/apidocs/voptions/en/#cancel-all-option-orders-on-specific-symbol-trade
        :see: https://binance-docs.github.io/apidocs/spot/en/#margin-account-cancel-order-trade
        :see: https://binance-docs.github.io/apidocs/pm/en/#cancel-all-um-open-orders-trade
        :see: https://binance-docs.github.io/apidocs/pm/en/#cancel-all-cm-open-orders-trade
        :see: https://binance-docs.github.io/apidocs/pm/en/#cancel-all-um-open-conditional-orders-trade
        :see: https://binance-docs.github.io/apidocs/pm/en/#cancel-all-cm-open-conditional-orders-trade
        :see: https://binance-docs.github.io/apidocs/pm/en/#cancel-margin-account-all-open-orders-on-a-symbol-trade
        :param str symbol: unified market symbol of the market to cancel orders in
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :param str [params.marginMode]: 'cross' or 'isolated', for spot margin trading
        :param boolean [params.portfolioMargin]: set to True if you would like to cancel orders in a portfolio margin account
        :param boolean [params.stop]: set to True if you would like to cancel portfolio margin account conditional orders
        :returns dict[]: a list of `order structures <https://docs.ccxt.com/#/?id=order-structure>`
        Nz- cancelAllOrders() requires a symbol argumentr  r`  rL   r   r^  Fr  r  ru  )ru  r  r  rH   r  r  rE   rU  Tr	  )r'   r`  r|  r  r}  r  r  r  r~  eapiPrivateDeleteAllOpenOrdersr  $papiDeleteUmConditionalAllOpenOrderspapiDeleteUmAllOpenOrdersfapiPrivateDeleteAllOpenOrders$papiDeleteCmConditionalAllOpenOrderspapiDeleteCmAllOpenOrdersdapiPrivateDeleteAllOpenOrderspapiDeleteMarginAllOpenOrderssapiDeleteMarginOpenOrdersprivateDeleteOpenOrdersr  ro  r  )
rq  r  r  r  r  rq  r  ru  rp  r  s
             rs  cancel_all_orderszbinance.cancel_all_orders  s     ( >#DG.]$]^^^!!!!!!!!!V$$fTl
 !$($C$CFL]_egxz  %A  %A!6((GGv??6#B#B#BCC
!??@QSYZZ
F( 	X!@@WV\A]A]^^^^^^^^HHH 	X  c  b%)%N%Nt{{[bdjOkOk%l%lllllllHH%)%C%CDKKPWY_D`D`%a%aaaaaaaHH!%!D!DT[[QXZ`EaEa!b!bbbbbbbI 	X  c  b%)%N%Nt{{[bdjOkOk%l%lllllllHH%)%C%CDKKPWY_D`D`%a%aaaaaaaHH!%!D!DT[[QXZ`EaEa!b!bbbbbbbhJ$:?P$:  _!%!C!CDKKPWY_D`D`!a!aaaaaaa++,0GL)!%!@!@WV\A]A]!^!^^^^^^^!99$++gv:V:VWWWWWWWWHh%% 	$$Xv666Ort  idsc                   K   |t          | j        dz             |                                  d{V  |                     |          }|d         st	          | j        dz             |d         |d}d}|d         r0|                     |                     ||                     d{V }n7|d         r/|                     |                     ||                     d{V }|                     ||          S )	a  
        cancel multiple orders
        :see: https://binance-docs.github.io/apidocs/futures/en/#cancel-multiple-orders-trade
        :see: https://binance-docs.github.io/apidocs/delivery/en/#cancel-multiple-orders-trade
        :param str[] ids: order ids
        :param str [symbol]: unified market symbol
        :param dict [params]: extra parameters specific to the exchange API endpoint
         *
         * EXCHANGE SPECIFIC PARAMETERS
        :param str[] [params.origClientOrderIdList]: max length 10 e.g. ["my_id_1","my_id_2"], encode the double quotes. No space after comma
        :param int[] [params.recvWindow]:
        :returns dict: an list of `order structures <https://docs.ccxt.com/#/?id=order-structure>`
        Nz* cancelOrders() requires a symbol argumentr  z1 cancelOrders is only supported for swap markets.r`  )r  orderidlistr  r  )	r'   r`  r|  r  r(   fapiPrivateDeleteBatchOrdersr  dapiPrivateDeleteBatchOrdersr  )rq  rF  r  r  r  r  r  s          rs  cancel_orderszbinance.cancel_orders  s8      >#DG.Z$Z[[[!!!!!!!!!V$$j! 	\TW'ZZ[[[Tl
 
 ( 	]!>>t{{7TZ?[?[\\\\\\\\HHI 	]!>>t{{7TZ?[?[\\\\\\\\HH   6222rt  c           	        K   |t          | j        dz             |                                  d{V  |                     |          }|                     |d|d                   }|                     |d          }|dk    rt          | j        dz             d|i}|                     ||||                     ||                     d{V S )a[  
        fetch all the trades made from a single order
        :see: https://binance-docs.github.io/apidocs/spot/en/#account-trade-list-user_data
        :see: https://binance-docs.github.io/apidocs/futures/en/#account-trade-list-user_data
        :see: https://binance-docs.github.io/apidocs/delivery/en/#account-trade-list-user_data
        :see: https://binance-docs.github.io/apidocs/spot/en/#query-margin-account-39-s-trade-list-user_data
        :param str id: order id
        :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 to retrieve
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict[]: a list of `trade structures <https://docs.ccxt.com/#/?id=trade-structure>`
        Nz. fetchOrderTrades() requires a symbol argumentru  rD   z. fetchOrderTrades() supports spot markets onlyr  )	r'   r`  r|  r  r  r  r2   fetch_my_tradesr  )	rq  r`  r  r  r  r  r  ru  r  s	            rs  fetch_order_tradeszbinance.fetch_order_tradesJ  s       >#DG.^$^___!!!!!!!!!V$$v??66**6>>tw)YYZZZr
 ))&%GU[@\@\]]]]]]]]]rt  c                   K   |                                   d{V  d}|                     |dd          \  }}|r|                     d||||           d{V S i }d}d}d}	| |                     |          }|d         |d<   |                     d||          \  }}|                     |dd          }
|V|}||d	<   |                                 }d
}||z
  |k    r0|
.|d         r&|                     ||          }
t          |
|          }
|
|
|d<   | 	                    |ddg          }|#|dk    s|d         rt          |d          }||d<   d}|dk    r1| 
                    |                     ||                     d{V }n|t          | j        dz             |                     d|          \  }	}d}|                     |dddd          \  }}|dk    s|dk    r|r1|                     |                     ||                     d{V }nG|dk    s|	<|	dk    rd|d<   |                     |                     ||                     d{V }n|                     |                     ||                     d{V }n|d         rb|r0|                     |                     ||                     d{V }n|                     |                     ||                     d{V }ni|d         ra|r0|                     |                     ||                     d{V }n/|                     |                     ||                     d{V }|                     ||||          S )a  
        fetch all trades made by the user
        :see: https://binance-docs.github.io/apidocs/spot/en/#account-trade-list-user_data
        :see: https://binance-docs.github.io/apidocs/futures/en/#account-trade-list-user_data
        :see: https://binance-docs.github.io/apidocs/delivery/en/#account-trade-list-user_data
        :see: https://binance-docs.github.io/apidocs/spot/en/#query-margin-account-39-s-trade-list-user_data
        :see: https://binance-docs.github.io/apidocs/pm/en/#margin-account-trade-list-user_data
        :see: https://binance-docs.github.io/apidocs/pm/en/#um-account-trade-list-user_data
        :see: https://binance-docs.github.io/apidocs/pm/en/#cm-account-trade-list-user_data
        :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 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)
        :param int [params.until]: the latest time in ms to fetch entries for
        :param boolean [params.portfolioMargin]: set to True if you would like to fetch trades for a portfolio margin account
        :returns Trade[]: a list of `trade structures <https://docs.ccxt.com/#/?id=trade-structure>`
        NFr   r  r`  r  r  r  r  i $r  rH   r  r)  r  z+ fetchMyTrades() requires a symbol argumentr   r^  rD   rE   rU  Tr	  r  )r|  r  r/  r  r  r>  r  r  r  r  eapiPrivateGetUserTradesr  r'   r`  r~  r}  papiGetMarginMyTradessapiGetMarginMyTradesprivateGetMyTradespapiGetUmUserTradesfapiPrivateGetUserTradespapiGetCmUserTradesdapiPrivateGetUserTradesr1  )rq  r  r  r  r  r  r  r  ru  rp  r  r  currentTimestamponeWeekr  rq  s                   rs  rM  zbinance.fetch_my_tradese  st     & !!!!!!!!!88R\]]& 	j::?FTY[`bhiiiiiiiii
[[((F &tGH99/6SYZZf%%fgyAAI#,GK 
  $0022-G 9,88O)9O"hhy'::G!'+;<<G!(GIYYv	7';<<F  VJ%7 E4(($GG8!::4;;wPV;W;WXXXXXXXXHH~'2_(_```!%!C!COU[!\!\J $(,(G(GP_agiz  }B  )C  )C%vv~~!1!1$ [%)%?%?GU[@\@\%]%]]]]]]]HHh&&J,B!Z//04-%)%?%?GU[@\@\%]%]]]]]]]HH%)%<%<T[[RX=Y=Y%Z%ZZZZZZZHH! 	a$ a%)%=%=dkk'SY>Z>Z%[%[[[[[[[HH%)%B%B4;;wX^C_C_%`%```````HH	" a$ a%)%=%=dkk'SY>Z>Z%[%[[[[[[[HH%)%B%B4;;wX^C_C_%`%```````HD   65%@@@rt  c                   K   |                                   d{V  i }|||d<   |                     |d          |d<   |                     |d          }|                     |d          }|||d<   |                     |                     ||                     d{V }|                     |dg           }|                     |dd	          }	g }
t          d	|	          D ]e}|                     ||         d
g           }t          d	t          |                    D ](}d||         d<   |

                    ||                    )f|                     |
d||          }|                     |||          S )aa  
        fetch all dust trades made by the user
        :see: https://binance-docs.github.io/apidocs/spot/en/#dustlog-user_data
        :param str symbol: not used by binance fetchMyDustTrades()
        :param int [since]: the earliest time in ms to fetch my dust trades for
        :param int [limit]: the maximum number of dust trades to retrieve
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :param str [params.type]: 'spot' or 'margin', default spot
        :returns dict[]: a list of `trade structures <https://docs.ccxt.com/#/?id=trade-structure>`
        Nr      X r  ru  accountTypeuserAssetDribbletsr`  r   userAssetDribbletDetailsTr  )r|  r  safe_string_upperr  sapiGetAssetDribbletr  r  r  r  r  r  r1  r!  )rq  r  r  r  r  r  r\  r  resultsrowsr;  r  logsr  r+  s                  rs  fetch_my_dust_tradeszbinance.fetch_my_dust_trades9  s     " !!!!!!!!!#(GK !%%!<!<GI,,VV<<66**"%0GM"224;;w3O3OPPPPPPPP< ..+?DD  7A66q$ 	% 	%A>>'!*.H"MMD1c$ii(( % %)-Q&DG$$$$% ""4ue<<))&%???rt  c                 X   |                      |d          }|                     |d          }|                      |d          }|                     |          }|                     d          }|d         }|dz   |z   }	d}
|	| j        v rd}
|                      |d	          }||                     |          d
}d }d }d }d }|
r1|	}|                      |d          }|                      |d          }d}n6|dz   |z   }|                      |d          }|                      |d          }d}d }||rt          j        ||          }d }|                     |          }|                     |          }|                     |          }d }d }|||                     |          ||||||||||dS )NtransIdoperateTime	fromAssetr  r  r  FTserviceChargeAmountr  r   transferedAmountr  r  r  )r`  r  r  r  rE  ru  r  r&  r  r  r   r  r  )	r  r  r  r  r  rp  r;   
string_divrC  )rq  r%  r  r  r  rr  tradedCurrencybnbearnedCurrencyapplicantSymboltradedCurrencyIsQuotefeeCostStringr  r  rj  
costStringr&  rk  r`  r  r  r   ru  r  s                           rs  r   zbinance.parse_dust_trade|  s    ""5)44%%e];;	%%e[99
00<<mmE""V(3.? %dl**$(!((0EFF&%%m44
 
 
  		$F++E3EFFL))%::JDD#c)N:F++E8<<L))%1CDDJD! K%0\JJ""<00!!+..  ,,"Y//(
 
 	
rt  r  c                 4  K   |                                   d{V  d}|                     |dd          \  }}|r|                     d||||           d{V S d}d}i }|                     | j        di           }	|                     |dd          }
|                     |d          }|                     |d          }|                     |d          }|
s||	v rp||                     |          }d	|d
<   |||d<   |||d<   | 	                    | 
                    ||                     d{V }|                     |d          }n| |                     |          }|d         |d<   |2||d<   |                     |d          }|t          ||          }||d<   |||d<   |                     | 
                    ||                     d{V }t          d	t!          |                    D ]}d||         d<   |                     ||||          S )a  
        :see: https://binance-docs.github.io/apidocs/spot/en/#get-fiat-deposit-withdraw-history-user_data
        fetch all deposits made to an account
        :see: https://binance-docs.github.io/apidocs/spot/en/#get-fiat-deposit-withdraw-history-user_data
        :see: https://binance-docs.github.io/apidocs/spot/en/#deposit-history-supporting-network-user_data
        :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
        :param bool [params.fiat]: if True, only fiat deposits will be returned
        :param int [params.until]: the latest time in ms to fetch entries for
        :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 `transaction structures <https://docs.ccxt.com/#/?id=transaction-structure>`
        NFr{   r  rD  fiatfiatOnlyr  r   transactionType	beginTimer  r;  r`  r  r  r[  r  r  ru  )r|  r  r/  r  rk  r  r  r  r  sapiGetFiatOrdersr  r  r  r  sapiGetCapitalDepositHisrecr  r  parse_transactions)rq  r  r  r  r  r  r  r  r  rD  rv  r  rawr  r  s                  rs  fetch_depositszbinance.fetch_deposits  s      !!!!!!!!!88R\]]& 	h::?DRWY^`fggggggggg^^DL,CC
>>&&%886:..!!&'2267++ *	\
**==..)*G%& ',$ %*	"..t{{7F/K/KLLLLLLLLCsF33HH* ==.."*4. ',$((5*55$!'511G%,	" #( !==dkk'SY>Z>Z[[[[[[[[H6 q#h--(( 	, 	,A"+HQK&&x5%HHHrt  c                   K   |                                   d{V  d}|                     |dd          \  }}|r|                     d||||           d{V S |                     | j        di           }|                     |dd          }|                     |d          }i }|                     |d          }	|	|                     |d          }|	|d	<   d}
d}|s||v ri||                     |          }d
|d<   |||d<   | 	                    | 
                    ||                     d{V }|                     |d          }
nx| |                     |          }|d         |d<   |||d<   |                     |d          |d	<   |||d<   |                     | 
                    ||                     d{V }
t          dt          |
                    D ]}d|
|         d<   |                     |
|||          S )a  
        :see: https://binance-docs.github.io/apidocs/spot/en/#get-fiat-deposit-withdraw-history-user_data
        :see: https://binance-docs.github.io/apidocs/spot/en/#withdraw-history-supporting-network-user_data
        fetch all withdrawals made from an account
        :see: https://binance-docs.github.io/apidocs/spot/en/#get-fiat-deposit-withdraw-history-user_data
        :see: https://binance-docs.github.io/apidocs/spot/en/#withdraw-history-supporting-network-user_data
        :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
        :param bool [params.fiat]: if True, only fiat withdrawals will be returned
        :param int [params.until]: the latest time in ms to fetch withdrawals for
        :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 `transaction structures <https://docs.ccxt.com/#/?id=transaction-structure>`
        NFr   r  rD  ru  rv  r  r  r   rw  rx  r;  r`  r  r  r[  r  r   
withdrawalru  )r|  r  r/  r  rk  r  r  r  r  ry  r  r  r  sapiGetCapitalWithdrawHistoryr  r  r{  )rq  r  r  r  r  r  rD  rv  r  r  r  r  r|  r  s                 rs  fetch_withdrawalszbinance.fetch_withdrawals$  s}       !!!!!!!!!88ASU_``& 	k::;MtUZ\acijjjjjjjjj^^DL,CC
>>&&%886:..!!&'22YYvw//F!&GI 0	^
**==..)*G%& ',$..t{{7F/K/KLLLLLLLLCsF33HH@ ==.."*4. ',$%)XXeZ%@%@	" #( !??GU[@\@\]]]]]]]]HP q#h--(( 	/ 	/A".HQK&&x5%HHHrt  c                     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 )Npendingr  failedrv  )	r  r   6
ProcessingFailed
Successful	RefundingRefundedRefund Failed)r  r   2345r  r  r  r  r  r  r  )r  r  )r  r  )rq  r  ru  statusesByTyper  s        rs   parse_transaction_status_by_typez(binance.parse_transaction_status_by_type  s      (""'&!)   (""'&!) 
 
@ >>.$;;&&999rt  r  c                    |                      |dd          }|                     |d          }|                     |d          }|t          |          dk     rd }|                     |d          }|#|                    d          dk    r
|d	d          }|                      |d
d          }|                     ||          }d }	|                     |dd          }	|	)|                     |                     |d                    }	|                     |dd          }
|                     |d          }|T|                     |d          }|
|dk    rdnd}|                     | j        d          }|                     |||          }| 	                    |                     |d          |          }| 
                    |d          }|                     |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+S ),Nr`  orderNoaddress
addressTagr   txIdzInternal transfer r      r  fiatCurrency
insertTimer  	applyTimesuccessTimerb  ru  rw  r  r  r  rE  r  r  transactionFeetotalFeerj  transferTypeTFr  r  txidr  r  	addressToaddressFromtagtagTotagFromr  r  )internalcommentr  )r  r  r  r  r  r>  r  r  rk  r  r  rA  r  rC  )rq  transactionr  r`  r  r  r  rr  r  r  r  ru  txTyperE  r  r  r  r  internalIntegerr  r  s                        rs  parse_transactionzbinance.parse_transaction  sA   B T9=="";	::{L99?3xx!||V44499-A#B#Ba#G#G9D''V^LL
&&z8<<	''\<PP	t'7'7['Q'QRRI%%k=,OOV44<%%k3DEEF!%+s]]yy'+t|E_'`'`$##$<dDIID66t7G7GU]7^7^`dee!!+x88$$[2BJOO#W55C++KHH&.9ttEH"";	::
K
"
 D
 	

 Y//
 w
 w
 
 4
 3
 S
 t
 D
 f
 
  f!
" w#
$ !)
 
 
 	
rt  c                 8    ddi}|                      |||          S )N	CONFIRMEDr  r  r  s      rs  parse_transfer_statuszbinance.parse_transfer_status=  s(    
 &&999rt  c           
         |                      |d          }|                      |d          }|                     ||          }|                     |d          }|                      |d          }d }d }	|                     | j        di           }
|o|                    d          }|                     |d          }|                     |d          }	|                      |
||          }|                      |
|	|	          }	|                     |d	          }|                     |                      |d
                    }|||| 	                    |          ||||	|d	S )NtranIdrV  r  ru  r?  r  r   r   r  r  )	r  r`  r  r  r  r  fromAccount	toAccountr  )
r  r  r  r  rk  r  r  r  r  rC  )rq  r   r  r`  rr  r  r  ru  r  r  r?  r   r  r  s                 rs  parse_transferzbinance.parse_transferC  se   & h11%%h88
&&z8<<!!(H55&11	~~dlNBGGJJsOOE//%33Kq11I**<kRRK((y)LLI%%h<<	++D,<,<Xx,P,PQQ"Y//&"

 

 
	
rt  c           
      b   |                      |d          }|                      |d          }|                     |d          }||                     ||d d          |                     |          ||                     |          |                      |d          |                     |d          dS )Nr  rV  r$  rF   r  rM  )r  r  r  r  r  r`  r  )r  r  rm  r  rC  r  )rq  rM  r  r  rr  r  s         rs  parse_incomezbinance.parse_incomer  s     ##FH55%%fg66
%%ff55	&&xvFF++J77"Y//""6844&&vx88
 
 	
rt  r  r  c                 F  K   |                                   d{V  |                     |          }|d         |                     ||          d}|                     |d          |d<   |                     |d          }|d         |                     |d          }d}	|+|                     |          }	|                     |d          }|                     |                                          }
|                     |                                          }d}|	|	d         }|
dk    r|t          | j	        dz   |z             |dk    r|t          | j	        dz   |z             | 
                    | j        d	i           }|
|v}||v}|r|	|
}|r|	|}|s|r|
d
k    p|
dk    }|d
k    p|dk    }|
dk    }|dk    }|
dk    p|dk    }|
dk    p|dk    }|p|p|p|}|s|r"|r t          | j	        dz   |z   dz   |z             |r
|rd}
||d<   n1|r
|rd}||d<   n%|r|r|
|d<   ||d<   d}
d}n|r||d<   d}
|r||d<   d}|
dz   |z   |d<   n|
dz   |z   |d<   |                     |                     ||                     d{V }|                     ||          S )a  
        transfer currency internally between wallets on the same account
        :see: https://binance-docs.github.io/apidocs/spot/en/#user-universal-transfer-user_data
        :param str code: unified currency code
        :param float amount: amount to transfer
        :param str fromAccount: account to transfer from
        :param str toAccount: account to transfer to
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :param str [params.type]: exchange specific transfer type
        :param str [params.symbol]: the unified symbol, required for isolated margin transfers
        :returns dict: a `transfer structure <https://docs.ccxt.com/#/?id=transfer-structure>`
        Nr`  rV  r  ru  r  ISOLATEDz: transfer() requires params["symbol"] when fromAccount is z8 transfer() requires params["symbol"] when toAccount is r?  r  r  r  r  r  z- transfer() does not allow transfers between z and ISOLATED_MARGIN
fromSymboltoSymbolISOLATEDMARGINr  )r|  r  r  r  r  r  convert_type_to_accountr[  r'   r`  r  rk  r(   sapiPostAssetTransferr  r  )rq  r  r  r  r  r  r  r  r  r  fromIdtoIdisolatedSymbolr?  fromIsolated
toIsolated
fromFuturetoFuturefromSpottoSpotr  rH   prohibitedWithIsolatedr  s                           rs  r   zbinance.transfer  s      !!!!!!!!!==&&d^00v>>
 
 **66::66**6?"%%fh77FF!V,,684411+>>DDFFF//	::@@BBD!N!!'##>+DG6r,r  vA  -A  B  B  Bz!!>+DG6p,ps|,|}}}>>$,KKL &, 6L"l2J (!' &v~!% 6z 6#z1IVz5I
:-C1C!V+ I-B1B8+?tx/?)3)Tx)T7)Tf&  4J 44J 4$TW/^%^al%lov%v  zC  &C  D  D  D 4 4.F,:GL)) 4* 4,D*8GJ''# 4
 406-.2
+!1/' 64BGL1%5F% 42@GJ/#3D"(3,"5"(3,"533DKK4P4PQQQQQQQQ ""8X666rt  c                   K   |                                   d{V  d}|                     |dd          \  }}|r|                     d||||           d{V S d}||                     |          }|                     | j        ddd          }|                     |d|          }|dk    rdnd}	|                     |d	|	          }
|                     |d
          }|                     | j        di           }|                     ||          }|                     ||
          }||Nt          |	                                          }t          | j        dz   d                    |          z             |Nt          |	                                          }t          | j        dz   d                    |          z             |dz   |z   }d
|i}|||d<   |||d<   |                     |d          }||                     |d          }||d<   |                     |                     ||                     d{V }|                     |dg           }|                     ||||          S )a  
        fetch a history of internal transfers made on an account
        :see: https://binance-docs.github.io/apidocs/spot/en/#query-user-universal-transfer-history-user_data
        :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
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :param int [params.until]: the latest time in ms to fetch transfers for
        :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 `transfer structures <https://docs.ccxt.com/#/?id=transfer-structure>`
        NFr   r  r  rD   r  rG   r  ru  r  z& fromAccount parameter must be one of z, z$ toAccount parameter must be one of r  r  sizer  r  rb  )r|  r  r/  r  r  rk  r  r  ro  keysr#   r`  joinr  r  sapiGetAssetTransferr  r  parse_transfers)rq  r  r  r  r  r  r  r  r  	defaultTor  ru  r  r  r  r  r  r  r  rb  s                       rs  fetch_transferszbinance.fetch_transfers  s      !!!!!!!!!88AQS]^^& 	i::;KTSXZ_aghhhhhhhhh}}T**H((7GX^__&&v}kJJ*h66FFX	$$V[)DD	//6FKK!!.+>>	::<~N//1122#DG.V$VY]YbYbcgYhYh$hiii|N//1122#DG.T$TW[W`W`aeWfWf$fgggC<$&DD
 #(GK #GFO!!&'22YYvw//F!&GI224;;w3O3OPPPPPPPP  ~~h33##D(E5AAArt  c                 P  K   |                                   d{V  |                     |          }d|d         i}|                     | j        di           }|                     |d          }|                     |||          }|||d<   |                     |d          }|                     |                     ||                     d{V }|                     |d          }|                     |d          }	d}
|	|                     | j        di           }|		                    d	          }|                     |d
          }|dk    s|dk    r |                     |d          }||d	z   |z   }|                     ||          }
| 
                    | j        dddiddid          }||v r.|                     ||i           }|                     ||
|
          }
|                     |dd          }t          |          dk    rd}|                     |           ||||
|dS )a  
        fetch the deposit address for a currency associated with self account
        :see: https://binance-docs.github.io/apidocs/spot/en/#deposit-address-supporting-network-user_data
        :param str code: unified currency code
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: an `address structure <https://docs.ccxt.com/#/?id=address-structure>`
        Nr  r`  r@  r  r  r   rA  r  r  zblockchair.comzviewblock.ior  rC  r  r  r  r  r  r  rz  r   )r  r  r  r  r  )r|  r  r  rk  r_  r  r  sapiGetCapitalDepositAddressr  r  r  r  check_address)rq  r  r  r  r  r@  r  r  r  r   impliedNetworkrA  r   topLevelsubLevelrC  
conversionr  s                     rs  fetch_deposit_addresszbinance.fetch_deposit_address#  s}      !!!!!!!!!==&&HTN
 >>$,
B??((;;""8Wg>>!(GIYYvy11F ::4;;wPV;W;WXXXXXXXX ""8Y77x//?"nnT\;LbQQOIIcNNE''q11H,,,(n2L2L++E155''#~8H!--oxHHN"oodl<M''P P  O &&!^^OT2FF
!%!1!1*nn!]!]x33s88q==C7###%
 
 	
rt  codesc                 F  K   |                                   d{V  |                     |           d{V }i }t          dt          |                    D ]}||         }|                     |d          }|                     |          }|                     |dg           }	i ||<   t          dt          |	                    D ]V}
|	|
         }|                     |d          }|                     |          }|                     |d          }|||         |<   W|i |dS )a  
         * @deprecated
        please use fetchDepositWithdrawFees instead
        :see: https://binance-docs.github.io/apidocs/spot/en/#all-coins-39-information-user_data
        :param str[]|None codes: not used by binance fetchTransactionFees()
        :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|  r  r  r  r  r  r  r  )rq  r  r  r  withdrawFeesr  r  rr  r  r  r  networkEntry	networkIdr  r  s                  rs  fetch_transaction_feeszbinance.fetch_transaction_feesf  s`      !!!!!!!!!88@@@@@@@@d q#h--(( 	6 	6AQKE))%88J**:66D..rBBK!#L1c+..// 6 6*1~ ,,\9EE	"55i@@&&|]CC25T";//6 %
 
 	
rt  c                    K   |                                   d{V  |                     |           d{V }|                     ||d          S )a  
        fetch deposit and withdraw fees
        :see: https://binance-docs.github.io/apidocs/spot/en/#all-coins-39-information-user_data
        :param str[]|None codes: not used by binance fetchDepositWithdrawFees()
        :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  parse_deposit_withdraw_fees)rq  r  r  r  s       rs  fetch_deposit_withdraw_feesz#binance.fetch_deposit_withdraw_fees  sl       !!!!!!!!!88@@@@@@@@V //%HHHrt  c                    |                      |dg           }|                     |          }t          dt          |                    D ]}||         }|                     |d          }|                     |          }|                     |d          }	|                     |d          }
|
du r|	d d|d<   |	d dd d dd	|d
         |<   |S )Nr  r   r  r  r  T)r  r  r   r  r@  )r  deposit_withdraw_feer  r  r  r  r  r  )rq  r  r  r  r  r  r  r  r  r  r  s              rs  parse_deposit_withdraw_feez"binance.parse_deposit_withdraw_fee  s   R nnS-<<**3//q#k**++ 	 	A&q>L((yAAI11)<<K**<GGK|[AAID  &"&& &z" '"& 
  "& 	/ 	/F:{++ rt  c                 <  K   |                      ||          \  }}|                     |           |                                  d{V  |                     |          }|d         ||d}|||d<   |                     | j        di           }|                     |d          }	|                     ||	|	          }	|	|	|d<   |                     |d          }| 	                    | 
                    ||                     d{V }
|                     |
|          S )a  
        make a withdrawal
        :see: https://binance-docs.github.io/apidocs/spot/en/#withdraw-user_data
        :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
        :returns dict: a `transaction structure <https://docs.ccxt.com/#/?id=transaction-structure>`
        Nr`  )r  r  r  r  r@  r  )handle_withdraw_tag_and_paramsr  r|  r  r  rk  r_  r  r  sapiPostCapitalWithdrawApplyr  r  )rq  r  r  r  r  r  r  r  r@  r  r  s              rs  r   zbinance.withdrawM  sD      99#vFFV7###!!!!!!!!!==&&TN
 
 ?$'GL!>>$,
B??((;;""8Wg>>!(GIYYvy11F::4;;wPV;W;WXXXXXXXX%%h999rt  c                     |                      |d          }|                     ||d d          }|||                     |dd          |                     |dd          d d dS )Nr  rD   makerCommissionmakerCommissionRatetakerCommissiontakerCommissionRate)r  r  r  r  r  r  )r  rm  rA  )rq  r  r  r  r  s        rs  parse_trading_feezbinance.parse_trading_feep  s{    $ ##C22!!(FD&AA''->@UVV''->@UVV
 
 	
rt  c                   K   |                                   d{V  |                     |          }|d         }d}|                     d||          \  }}d}|                     |dddd          \  }}|                     ||          }|                     ||          }d|d         i}	d}
|rb|r0|                     |                     |	|                     d{V }
n|                     |                     |	|                     d{V }
n|rb|r0| 	                    |                     |	|                     d{V }
n_| 
                    |                     |	|                     d{V }
n/|                     |                     |	|                     d{V }
|
}t          |t                    r|                     |d	i           }|                     ||          S )
a  
        fetch the trading fees for a market
        :see: https://binance-docs.github.io/apidocs/spot/en/#trade-fee-user_data
        :see: https://binance-docs.github.io/apidocs/futures/en/#user-commission-rate-user_data
        :see: https://binance-docs.github.io/apidocs/delivery/en/#user-commission-rate-user_data
        :see: https://binance-docs.github.io/apidocs/pm/en/#get-user-commission-rate-for-um-user_data
        :see: https://binance-docs.github.io/apidocs/pm/en/#get-user-commission-rate-for-cm-user_data
        :param str symbol: unified market symbol
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :param boolean [params.portfolioMargin]: set to True if you would like to fetch trading fees in a portfolio margin account
        :param str [params.subType]: "linear" or "inverse"
        :returns dict: a `fee structure <https://docs.ccxt.com/#/?id=fee-structure>`
        Nru  r   r   r^  Fr  r`  r   )r|  r  r  r}  r}  r{  papiGetUmCommissionRater  fapiPrivateGetCommissionRatepapiGetCmCommissionRatedapiPrivateGetCommissionRatesapiGetAssetTradeFeer  ro  r  r  )rq  r  r  r  ru  rv  rq  isLinear	isInverser  r  r;  s               rs  fetch_trading_feezbinance.fetch_trading_fee  sI      !!!!!!!!!V$$f~99:KVU[\\ $($C$CFL]_egxz  %A  %A!6>>$00OOD'22	fTl
  	U  a!%!=!=dkk'SY>Z>Z![![[[[[[[!%!B!B4;;wX^C_C_!`!``````` 	U  a!%!=!=dkk'SY>Z>Z![![[[[[[[!%!B!B4;;wX^C_C_!`!```````!66t{{7F7S7STTTTTTTTH( dD!! 	/>>$2..D%%dF333rt  c                   K   |                                   d{V  d}|                     dd|          \  }}d}|                     dd|d          \  }}|dk    p|dk    }|                     ||          }|                     ||          }d}|r|                     |           d{V }n;|r|                     |           d{V }n|r|                     |           d{V }|rLi }t          dt          |                    D ]*}	| 
                    ||	                   }
|
d         }|
||<   +|S |rt          | j                                                  }i }|                     |d          }| j        d         d	         d
         }|d         |         d         }|d         |         d         }t          dt          |                    D ]+}	||	         }| j        |         }|d         rd|i|||d||<   ,|S |rt          | j                                                  }i }|                     |d          }| j        d         d	         d
         }|d         |         d         }|d         |         d         }t          dt          |                    D ]+}	||	         }| j        |         }|d         rd|i|||d||<   ,|S dS )a_  
        fetch the trading fees for multiple markets
        :see: https://binance-docs.github.io/apidocs/spot/en/#trade-fee-user_data
        :see: https://binance-docs.github.io/apidocs/futures/en/#account-information-v2-user_data
        :see: https://binance-docs.github.io/apidocs/delivery/en/#account-information-user_data
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :param str [params.subType]: "linear" or "inverse"
        :returns dict: a dictionary of `fee structures <https://docs.ccxt.com/#/?id=fee-structure>` indexed by market symbols
        Nr   r  rD   rE   r   r  feeTierr  r  r  r   r  )r  r  r  r  r  )r|  r  r  r}  r{  r  r  r  r  r  r  ro  r  r  r  r   )rq  r  ru  rv  isSpotOrMarginr  r  r  r  r  r  r  r  r  feeTiersr  r  r  s                     rs  fetch_trading_feeszbinance.fetch_trading_fees  s      !!!!!!!!!99:LdTZ[[f99:LdTZ\dee&.?dh.>>>$00OOD'22	 	@!66v>>>>>>>>HH 	@!99&AAAAAAAAHH 	@!77????????Hb  Z	 F1c(mm,, % %,,Xa[99X!$vM E	, 4<,,..//GF'')<<Gy*95g>HW%g.q1EW%g.q1E1c'll++   f-(#  &w! #)!&!&& &F6N M 	 4<,,..//GF'')<<Gy+I6w?HW%g.q1EW%g.q1E1c'll++   f-)$  &w! #)!&!&& &F6N Mtrt  c                 L  K   |dk     s|dk    rt          | j        dz             |                                  d{V  |                     |          }|d         ||d}|                     |                     ||                     d{V }|                     ||          S )u  
         * @ignore
        transfer between futures account
        :see: https://binance-docs.github.io/apidocs/spot/en/#new-future-account-transfer-user_data
        :param str code: unified currency code
        :param float amount: the amount to transfer
        :param str type: 1 - transfer from spot account to USDT-Ⓜ futures account, 2 - transfer from USDT-Ⓜ futures account to spot account, 3 - transfer from spot account to COIN-Ⓜ futures account, 4 - transfer from COIN-Ⓜ futures account to spot account
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :param float params.recvWindow:
        :returns dict: a `transfer structure <https://docs.ccxt.com/#/?id=futures-transfer-structure>`
        r   rV  z type must be between 1 and 4Nr`  )rV  r  ru  )r'   r`  r|  r  sapiPostFuturesTransferr  r  )rq  r  r  ru  r  r  r  r  s           rs  futures_transferzbinance.futures_transferr   s       1HH$((#DG.M$MNNN!!!!!!!!!==&&d^
 

 55dkk'66R6RSSSSSSSS ""8X666rt  c                   K   |                                   d{V  |                     |          }d|d         i}d}|d         r0|                     |                     ||                     d{V }nO|d         r0|                     |                     ||                     d{V }nt          | j        dz             |d         r|d         }|                     ||          S )a  
        fetch the current funding rate
        :see: https://binance-docs.github.io/apidocs/futures/en/#mark-price
        :see: https://binance-docs.github.io/apidocs/delivery/en/#index-price-and-mark-price
        :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  r`  r  r  z> fetchFundingRate() supports linear and inverse contracts onlyr   )r|  r  fapiPublicGetPremiumIndexr  dapiPublicGetPremiumIndexr2   r`  parse_funding_raterq  r  r  r  r  r  s         rs  fetch_funding_ratezbinance.fetch_funding_rate   s       !!!!!!!!!V$$fTl
 ( 	k!;;DKKQW<X<XYYYYYYYYHHI 	k!;;DKKQW<X<XYYYYYYYYHHtw)iijjj) 	#{H &&x888rt  c           
        K   |                                   d{V  i }d}|                     |dd          \  }}|r |                     d|||d|           d{V S |                     | j        ddd          }|                     |d|          }d}	|(|                     |          }	|	d	         }|	d
         |d	<   d}
|                     d|	|d          \  }
}|                     |d          }|||d<   | 	                    |dd          }| 
                    |d|          }|                     |g d          }|||d<   |||d<   d}|                     ||
          r0|                     |                     ||                     d{V }nc|                     ||
          r0|                     |                     ||                     d{V }nt!          | j        dz   |z   dz             g }t%          dt'          |                    D ]}||         }| 
                    |d          }|                    ||                     |                     |d	          ddd          |                     |d          ||                     |          d           |                     |d          }|                     ||||          S )a  
        fetches historical funding rate prices
        :see: https://binance-docs.github.io/apidocs/futures/en/#get-funding-rate-history
        :see: https://binance-docs.github.io/apidocs/delivery/en/#get-funding-rate-history-of-perpetual-futures
        :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
        :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)
        :param str [params.subType]: "linear" or "inverse"
        :returns dict[]: a list of `funding rate structures <https://docs.ccxt.com/#/?id=funding-rate-history-structure>`
        NFr   r  r   r  rG   ru  r  r`  r  r  r  tillr  )r  r  r  r  z0 fetchFundingRateHistory() is not supported for  marketsr   fundingTimerF   r/  )r  r  r/  r  r  r  )r|  r  r  r  rk  r  r  r  r  r>  r  r}  fapiPublicGetFundingRater  r{  dapiPublicGetFundingRater2   r`  r  r  r  rm  r  rC  r)  filter_by_symbol_since_limit)rq  r  r  r  r  r  r  r  ru  r  rv  r  r  r  ratesr  r  r  sorteds                      rs  fetch_funding_rate_historyz"binance.fetch_funding_rate_history   sW      !!!!!!!!!88AZ\fgg& 	@@@AZ\bdikprvx~((7PR_aijj<<[[((FH%F &tGH99:SU[]cemnn66**#(GK ##FGV<<##FIu==6#?#?#?@@!(GI$GG>>$(( 	q!::4;;wPV;W;WXXXXXXXXHH__T7++ 	q!::4;;wPV;W;WXXXXXXXXHHtw)[[^bbeooppp q#h--(( 		 		AQKE))%??ILL**4+;+;E8+L+LdTXZ`aa#//}EE& LL33      e[1100NNNrt  c                   K   |                                   d{V  |                     |          }|                     | j        ddd          }|                     |d|          }d}|                     dd|d          \  }}|                     |d          }d}|                     ||          r|                     |           d{V }nI| 	                    ||          r| 
                    |           d{V }nt          | j        dz             g }t          dt          |                    D ]4}	||	         }
|                     |
          }|                    |           5|                     |d	|          S )
aJ  
        fetch the funding rate for multiple markets
        :see: https://binance-docs.github.io/apidocs/futures/en/#mark-price
        :see: https://binance-docs.github.io/apidocs/delivery/en/#index-price-and-mark-price
        :param str[]|None symbols: list of unified market symbols
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :param str [params.subType]: "linear" or "inverse"
        :returns dict: a dictionary of `funding rates structures <https://docs.ccxt.com/#/?id=funding-rates-structure>`, indexe by market symbols
        Nr   r  rG   ru  r  z? fetchFundingRates() supports linear and inverse contracts onlyr   r  )r|  r  r  rk  r  r  r  r}  r  r{  r   r2   r`  r  r  r  r  filter_by_array)rq  r  r  r  ru  rv  r  r  r  r  r  parseds               rs  fetch_funding_rateszbinance.fetch_funding_rates   s      !!!!!!!!!%%g..((7JM[cdd<<99:MtU[]eff		&&))>>$(( 	l!;;EBBBBBBBBHH__T7++ 	l!;;EBBBBBBBBHHtw)jjkkkq#h--(( 	" 	"AQKE,,U33FMM&!!!!##FHg>>>rt  c                 H   |                      |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 S )Nr$  r  r  	markPrice
indexPriceinterestRateestimatedSettlePricelastFundingRatenextFundingTimer  r  r  r/  fundingTimestampfundingDatetimenextFundingRatenextFundingTimestampnextFundingDatetimepreviousFundingRatepreviousFundingTimestamppreviousFundingDatetime)r  r  rm  r  rC  )rq  r  r  r  r  r  r  r  r  r  r/  r  s               rs  r  zbinance.parse_funding_rate!  s    %%h77	##Hh77!!(FD*EE$$X{;;	%%h==
''.AA#//:PQQ&&x1BCC''2CDD
H
f
 
 *	

 L
 #$8
 
 Y//
 ;
 
 t||K88
 t
 #D
 "4
 "4
  '!
" &t#
 	
rt  c           	         |                      |d          }|                      |dg           }i }t          dt          |                    D ]|}||         }|                     |d          }|                     |          }	|                     |d          }
|                     |d          }t          j        |
|          |
d||	<   }g }t          dt          |                    D ]}||         }|                     |d          }|                     |d d d	          }|d
         r|d         n|d         }	|                     |d          }|dk    o|dk    }|r|r^|	|v rZ|                     | 	                    |||	         d         ||	         d         d          |          }|
                    |           |S )N	positionsre  r   rV  crossWalletBalance
crossUnPnl)crossMarginr#  r  r  r  r  r  maintMarginr  
0.00000000r%  )r  r  r  r  r  r;   rR  r  parse_account_positionr  r  )rq  rJ  filterClosedr"  re  rc  r  r  rr  r  r#  r$  r  rj  r  r  maintenanceMarginisPositionOpenr  s                      rs  parse_account_positionszbinance.parse_account_positionsA!  s   NN7K88	266q#f++&& 		 		A1IE))%99J**:66D!%!1!1%9M!N!N))%>>J&12DjQQ&8 HTNN q#i..)) 	* 	*A |H''(;;H%%hdJGGF&,X&6J6'??F6ND $ 0 0= I I/36_=NR^=^N *> *8##!88X'/~m'D.6tn=Q.RP P : :    F MM&)))rt  c           
      Z   |                      |d          }|                     ||d d          }|                      |d          }|                      |d          }t          |          }|                      |d          }|                     |          }t	          j        d|d          }	|                     d|z            }
|
s)t	          j        t	          j        |	d          dd          }	d	|v }|                      |d
          }|                     |          }|                      |d          }|                     |          }|                     |d	d          }t	          j	        |          }|                     |          }|                      |d          }t	          j	        |          }||t	          j
        t	          j
        ||          |          }|                      |d          }t	          j        ||          }t	          j        t	          j        |d          dd          }|                     |          }|                     | j        di           }|                     ||g           }d }t          dt          |                    D ]/}||         }t	          j        ||d                   r n	|d         }0|                     |          }|                      |d          }|                     |          }|                     |d          } | dk    rd } |                     |d          }!d }"d }#d }$|!r.d}"|                      |d          }$t	          j        |$|          }#n.d}"|                      |d          }$|                      |d          }#|                     |#          }%d }&d }'d }(d })d }*|                     |d          }+|                     |+          },t	          j        |d          rd }nt	          j        |d          rdnd}'|                     t	          j        t	          j        t	          j        ||#          d          dd                    }&|                     t	          j
        t	          j        ||d          d                    }(|rd }-|}.|'dk    rt	          j        d|          }-n*t	          j        d |          }-t	          j
        d |.          }.t	          j        |$t	          j
        ||-                    }/t	          j        |.|-          }0t	          j        |/|0          })nd }-|}.|'dk    rt	          j        d|          }-n*t	          j        d |          }-t	          j
        d |.          }.t	          j
        ||,          }1t	          j
        |1|-          }/t	          j        t	          j
        t	          j        d|.          |1          |$          }0t	          j        |/|0          })|d!         d"         }2|2dz   }3t/          |3          }4t	          d#|4z             }5t/          |5          }6t	          j        |6|)          }7t	          j        |7d|2          }8|8d         d$k    rd }8|                     |8          }*|                      |d%          }9|9d&k    }:i d'|d(d d|d)| d*|                     |           d|d+|                     |	          d,|d-|d|d	|d|                     |          d.|d/|d|+d0|&d1|*d |%|"|'|:|(d2S )3Nr  r  rY  rk  r   rw  r)  1e-8r;  r&  
entryPricenotionalValuepositionAmtr  z0.5r   leverageBracketsr   unrealizedProfitrb  rU  isolatedWalletr  r#  r%  r  shortlong5e-5rV  100r  r  r  z5e-r  r  BOTHr  r`  r  r  initialMarginPercentager*  maintenanceMarginPercentageunrealizedPnl	contractsmarginRatioliquidationPrice)r  
collateralrp  r&  hedgedr  )r  r  r  rp  r;   rl  is_round_numberrR  r  
string_absr"  r  rk  r  r  r  	string_ltr  r  r  r  string_equals
string_subr  rC  );rq  rj  r  r  r  leverageStringrY  initialMarginStringrk  initialMarginPercentageStringrationalusdmmaintenanceMarginStringr*  entryPriceStringr/  notionalStringnotionalStringAbsr;  contractsStringcontractsStringAbsentryNotionalcontractSizeNewr=  r2  rN  !maintenanceMarginPercentageStringr  bracketr;  unrealizedPnlStringr<  r  rU  rp  collateralStringwalletBalancer@  r>  r&  r  liquidationPriceStringRawr?  r  contractSizeString(onePlusMaintenanceMarginPercentageStringentryPriceSignStringleftSide	rightSider  r)  pricePrecisionPlusOnepricePrecisionPlusOneStringrounderrounderStringliquidationPriceRoundedStringtruncatedLiquidationPricer  rA  s;                                                              rs  r(  zbinance.parse_account_positionb!  si   f ##Hh77!!(FD*EE!!&(33))(J??~&&"..xII))*=>>(/(:3PQ(R(R%''x88 	B,3,>w?QRoqw?x?xz}  @A  -B  -B)h&"&"2"28]"K"K --.EFF++HlCC&&'788
++Hj/RR#.~>>$$%677**8]CC$/@@"#.w/A.Re/f/fhxyyM"..v~FFO%0PPO!(!3G4FX]4^4^`cef!g!g%%&899	>>$,8JBOO..)962FF,0)q#o..// 	; 	;A%a(G !2GAJ?? 07
--&*&7&78Y&Z&Z#"..x9KLL))*=>>%%h==	>>I>>(J77
 	I#J ,,X7GHHM&1-ATUU J ,,X7KLLM#//-HH&&'788

$(!v~>>!22<@@ 55 4	LJJ%/DDP77&D++G,>w?QRYRde|  O  SP  SP  RX  @Y  @Y  [^  `a  -b  -b  c  cK**7+=g>PQdfy{|>}>}  @E  ,F  ,F  G  GJ !T <@8'7$7???F?QRUWx?y?y<<?F?QRVXy?z?z<+2+=dDX+Y+Y("-mW=OPb  eM  >N  >N  O  O#./CEmnn	,3,>x,S,S)) <@8'7$7???F?QRUWx?y?y<<?F?QRVXy?z?z<+2+=dDX+Y+Y()*<>PQQ"-d4\]]#.w/A'BTUXZnBoBoqu/v/v  yF  G  G	,3,>x,S,S)#K09N$2Q$6!*-.C*D*D'e&AABBGLLM,3,>}Ng,h,h)(/(:;XZ]_m(n(n%(+s22 -1)#001JKK''.AA'
H
$
 f
 	

 Y//
 ]
 &t'8'89V'W'W
  !2
 *+F
 *
 
 )).99
 ]
 
 L
  ;!
"  0#
$ $$$/
 
 
 	
rt  c                    |                      |d          }|                     ||d d          }|                      |d          }|                     | j        di           }|                     ||g           }|                     |dd          }t          j        |          }d }	t          dt          |                    D ]/}
||
         }t          j
        ||d                   r n	|d         }	0|                     |          }t          j        |                      |d                    }|                     |          }|                      |d	          }|                     |          }|                      |d
          }t          |          }|                     |                      |d                    }|                     |          }d }|                      |d          }d }t          j        |d          rd}nt          j
        |d          rd}|                      |d          }|                     |          }|                     |d          }|                     |          }d|v }|dk    r|                     |di           }|rd }|}|dk    r+t          j        d|	          }t          j        d|          }nt          j        d|	          }t          j        ||          } t          j        | |          }!|                     |d          }"|                     |d|"          }#|#)t          j        t          j        |!|          d|#          }nd }|}|dk    rt          j        d|	          }n*t          j        d|	          }t          j        d|          }t          j        ||          }!t          j        t          j        d|          t          j        ||                    }$|                     |d          }%|%)t          j        t          j        |!|$          d|%          }n|                      |d          }|dn|}|                     |          }&|                     |                     |                      |d                              }'|                     |d          }(|(dk    rd }(|                     |	          })t          j        |	|          }*|                     |*          }+t          j        d|d          },|                     d|z            }-|-st          j        |,d          },t          j        t          j        ||,          dd          }.|                     |.          }/d }0d }1t          j        |d          s|                     t          j        t          j        t          j        |*|          d          dd                     }0|                     t          j        t          j        ||.d           d!                    }1|                      |d"          }2|2d#k    }3i d$|d%d d|d&|d|d'|d
|                     |          d|d(|&d|d|'d|d)|(d*|/d+|                     |,          d,|+d-|)|0|                     |(          ||||3|1d d d.	S )/Nr  r  r2  r;  r0  r   r   r1  unRealizedProfitrY  r?  rZ  r  r6  r5  r/  r  r  r  r   r  r  r  r  isolatedMarginr  rb  rw  r)  r.  r7  rV  r8  r  r9  r  r`  r=  r<  r@  r  rk  r:  r*  r;  )	r>  r  rp  rZ  r&  rA  r  r  r  )r  r  r  rk  r  r  r;   rC  r  r  rD  rp  r  r  r  r  r  rR  r"  r  rl  rF  rB  rE  rC  )4rq  rj  r  r  r  r2  rN  rN  rO  rT  r  rU  r;  contractsAbsr=  rV  r<  rG  rY  liquidationPriceStringr?  rW  rp  r&  rM  r/  r  rZ  r  r  r[  r\  innerr]  r)  r,  r^  basePrecisionr@  r  r  r;  rL  r*  rI  rJ  rH  rk  r>  r  r  rA  s4                                                       rs  parse_position_riskzbinance.parse_position_riskD"  s   V ##Hh77!!(FD*EE!!&(33>>$,8JBOO..)962FF++Hj/RR#.~>>,0)q#o..// 	; 	;A%a(G !2GAJ?? 07
--$$%677)$*:*:8]*S*STT%%l33	"..x9KLL))*=>>))(J??~&&!%0@0@K]0^0^!_!_,,-CDD%%h==
^S11 	DD~s33 	D++HlCC&&'788
v~>>!22<@@(  v{B??I w;?8'7$7???F?QRUWx?y?y<+2+=dDX+Y+Y((?F?QRVXy?z?z<*+ACkll"-e5IJJ!%!2!29g!F!F!%!2!29g~!V!V!-'.'9':LXWc:d:dfiky'z'z$ <@8'7$7???F?QRUWx?y?y<<?F?QRVXy?z?z<+2+=dDX+Y+Y("-l<NOO#.w/A#G[/\/\^e^p  rZ  \r  _s  _s  t  t	 $ 1 1)V D D ,'.'9':LXW`:a:acfhu'v'v$#//:JKK#3#;33BR&&'788
%%dnnT5E5EhP[5\5\&]&]^^	%%h==	>>I&*&7&78Y&Z&Z#")"45VXi"j"j --.EFF(/(:3PQ(R(R%''x88 	f,3,>?\^d,e,e)%01CDUWt1u1uwz|}~~))*=>>
$%5s;; 	G++G,>w?QRYRde|  O  SP  SP  RX  @Y  @Y  [^  `a  -b  -b  c  cK**7+=g>PQdfy{|>}>}  @E  ,F  ,F  G  GJ''.AA'
H
$
 f
 	

 L
 ]
 )).99
  0
 *
 
 
 *
 
 ]
 &t'8'89V'W'W
   !2!
" *+F#
$ 'Y//$$$!#5
 
 
 	
rt  c                   K   |                                   d {V  |                     | j        d          }||r2|                     | j        dd          }|                     |d|          }|                     |d          }d }|                     dd |d          \  }}d }|                     |dddd	          \  }}d }	|                     ||          r:|r|                     |           d {V }	n| 	                    |           d {V }	ng| 
                    ||          r:|r|                     |           d {V }	n3|                     |           d {V }	nt          | j        d
z             i | j        d<   t          dt!          |	                    D ]}
|	|
         }|                     |d          }|                     |d d d          }|                     |dg           }g }t          dt!          |                    D ]N}||         }|                     |dd          }|                     |d          }|                    ||g           O|| j        d         |<   | j        d         S )Nr2  r  rG   ru  loadLeverageBracketsr  r   r^  FzB loadLeverageBrackets() supports linear and inverse contracts onlyr   r  r  bracketsnotionalFloorqtyFloormaintMarginRatio)r|  r  rk  r  r  r  r}  r}  papiGetUmLeverageBracketfapiPrivateGetLeverageBracketr{  papiGetCmLeverageBracketdapiPrivateV2GetLeverageBracketr2   r`  r  r  rm  r  r  r  )rq  reloadr  r2  r  ru  r  rv  rq  r  r  r  r  r  ro  r  r  rU  
floorValuer;  s                       rs  load_leverage_bracketszbinance.load_leverage_brackets#  s     !!!!!!!!!  ??4<9KLL$&$**4<QQK##FFK@@DIIff--EG"==>TVZ\bdlmmOGV $(,(G(GPfhn  qB  DI  )J  )J%vH~~dG,, s$ O%)%B%B5%I%IIIIIIIHH%)%G%G%N%NNNNNNNHHw// s$ Q%)%B%B5%I%IIIIIIIHH%)%I%I%%P%PPPPPPPHH"47-q#qrrr/1DL+,1c(mm,, B B ++E8<<))(D$
KK>>%R@@q#h--00 M MA&qkG!%!3!3G_j!Y!YJ262B2B7L^2_2_/MM:/J"KLLLL;A/088|.//rt  c                   K   |                                   d{V  d}|                     dd|          \  }}d}|                     dd|d          \  }}d}|                     |dddd          \  }}d}|                     ||          r:|r|                     |           d{V }n|                     |           d{V }ng|                     ||          r:|r|                     |           d{V }n3| 	                    |           d{V }nt          | j        dz             |                     ||d          S )	a  
        retrieve information on the maximum leverage, and maintenance margin for trades of varying trade sizes
        :see: https://binance-docs.github.io/apidocs/futures/en/#notional-and-leverage-brackets-user_data
        :see: https://binance-docs.github.io/apidocs/delivery/en/#notional-bracket-for-symbol-user_data
        :see: https://binance-docs.github.io/apidocs/pm/en/#um-notional-and-leverage-brackets-user_data
        :see: https://binance-docs.github.io/apidocs/pm/en/#cm-notional-and-leverage-brackets-user_data
        :param str[]|None symbols: list of unified market symbols
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :param boolean [params.portfolioMargin]: set to True if you would like to fetch the leverage tiers for a portfolio margin account
        :param str [params.subType]: "linear" or "inverse"
        :returns dict: a dictionary of `leverage tiers structures <https://docs.ccxt.com/#/?id=leverage-tiers-structure>`, indexed by market symbols
        Nr   r  r   r^  Fz@ fetchLeverageTiers() supports linear and inverse contracts onlyr  )r|  r  r  r}  r}  rs  rt  r{  ru  rv  r2   r`  parse_leverage_tiers)rq  r  r  ru  rv  rq  r  s          rs  fetch_leverage_tierszbinance.fetch_leverage_tiers0#  s      !!!!!!!!!99:NPTV\]]f99:NPTV\^fgg $($C$CFL`bhj{  ~C  %D  %D!6>>$(( 	m  L!%!>!>v!F!FFFFFFF!%!C!CF!K!KKKKKKK__T7++ 	m  N!%!>!>v!F!FFFFFFF!%!E!Ef!M!MMMMMMMtw)kklllN ((7HEEErt  c                    |                      |d          }|                     ||dd          }|                     |dg           }g }t          dt	          |                    D ]}||         }|                    |                     |d          |d         |                     |dd	          |                     |d
d          |                     |d          |                     |d          |d           |S )z}
         * @ignore
        :param dict info: Exchange response for 1 market
        :param dict market: CCXT market
        r  Nr  ro  r   rU  r  rp  rq  notionalCapqtyCaprr  initialLeverage)tierr  r:  r<  maintenanceMarginRatemaxLeverager  )r  r  r  r  r  r  r  rA  )rq  r  r  r  ro  r  r  rU  s           rs  parse_market_leverage_tiersz#binance.parse_market_leverage_tiersy#  s   , ##D(33!!(FD*EE>>$
B77q#h--(( 
	 
	AqkGLL(()<<"7O#11'?JWW#11'=(SS)-)9)9'CU)V)V#//9JKK      rt  c                 L  K   |                                   d{V  |                     |          }|d         st          | j        dz             d|d         i}|                     |                     ||                     d{V }|                     |d         |          S )a  
        :see: https://binance-docs.github.io/apidocs/voptions/en/#option-position-information-user_data
        fetch data on an open position
        :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>`
        NrH   z- fetchPosition() supports option markets onlyr  r`  r   )r|  r  r2   r`  eapiPrivateGetPositionr  parse_positionr  s         rs  fetch_positionzbinance.fetch_position#  s       !!!!!!!!!V$$h 	Ztw)XXYYYfTl
 44T[[&5Q5QRRRRRRRR0 ""8A;777rt  c                 |  K   |                                   d{V  |                     |          }i }d}|nd}t          |t                    r5t	          |          }|dk    rt          | j        dz             |d         }n|}|                     |          }|d         |d<   |                     | 	                    ||                     d{V }g }t          dt	          |                    D ]1}	|                    |                     ||	         |                     2|                     |d|d          S )a  
        :see: https://binance-docs.github.io/apidocs/voptions/en/#option-position-information-user_data
        fetch data on open options positions
        :param str[]|None symbols: list of unified market symbols
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict[]: a list of `position structures <https://docs.ccxt.com/#/?id=position-structure>`
        Nr   zD fetchPositions() symbols argument cannot contain more than 1 symbolr   r`  r  F)r|  r  r  ro  r  r(   r`  r  r  r  r  r  r  filter_by_array_positions)
rq  r  r  r  r  r  symbolsLengthr  r  r  s
             rs  fetch_option_positionszbinance.fetch_option_positions#  s_      !!!!!!!!!%%g..F'4(( ! #G 1$$$TW/u%uvvv  [[((F &tGH44T[[&5Q5QRRRRRRRR0 q#h--(( 	D 	DAMM$--hqk6BBCCCC--fhOOOrt  c           
         |                      |d          }|                     ||          }|d         }|                     |d          }|                      |d          }|dk    rt          j        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          S )Nr  r&  r  r6  r  r$  r  r`  r/  r  r;  	markValuer@  positionCostr<  unrealizedPNLr=  r  r  r  rA  r*  r;  rk  )r:  rY  r?  r>  rp  r  )
r  r  r=  r;   r"  r  safe_positionr  rp  rC  )rq  rj  r  r  r  r&  r  r  s           rs  r  zbinance.parse_position#  s   , ##Hh77!!(F33!%%h77##Hj996>>)$99H%%h77	!! #
H#
$#
 f#
 $**8\BB	#

 ))(K@@#
 ((;??#
 $**8^DD#
 T--hHH#
 D#
 **844#
 D#
 #
 Y//#
 d#
  #
  *4!#
" T##
$ (, $/#
 #
 #
   	rt  c                 ~  K   |                      | j        dd          }d}|                     |dd|          \  }}|dk    r|                     ||           d{V S |dk    r|                     ||           d{V S |dk    r|                     ||           d{V S t          | j        dz   |z   dz             )	a  
        fetch all open positions
        :see: https://binance-docs.github.io/apidocs/futures/en/#position-information-v2-user_data
        :see: https://binance-docs.github.io/apidocs/delivery/en/#position-information-user_data
        :see: https://binance-docs.github.io/apidocs/futures/en/#account-information-v2-user_data
        :see: https://binance-docs.github.io/apidocs/delivery/en/#account-information-user_data
        :see: https://binance-docs.github.io/apidocs/voptions/en/#option-position-information-user_data
        :param str[] [symbols]: list of unified market symbols
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :param str [method]: method name to call, "positionRisk", "account" or "option", default is "positionRisk"
        :returns dict[]: a list of `position structure <https://docs.ccxt.com/#/?id=position-structure>`
        r   rK  Nr+  rJ  rH   z/.options["fetchPositions"]/params["method"] = "zJ" is invalid, please choose between "account", "positionRisk" and "option")r  rk  r  fetch_positions_riskfetch_account_positionsr  r2   r`  )rq  r  r  defaultValuedefaultMethods        rs  fetch_positionszbinance.fetch_positions5$  s      ''6FWW $ = =fFVX`bn o ovN**227FCCCCCCCCCi''55gvFFFFFFFFFh&&44WfEEEEEEEEEtw)ZZ]jj  nz   z  {  {  {rt  c                   K   |,t          |t                    st          | j        dz             |                                  d{V  |                     d|           d{V  |                     | j        dd          }|                     |d|          }|                     |d          }d}| 	                    dd|d          \  }}d}| 
                    |dd	d
d          \  }}d}|                     ||          r:|r|                     |           d{V }n|                     |           d{V }ng|                     ||          r:|r|                     |           d{V }n3|                     |           d{V }nt#          | j        dz             d}|                     |ddd          \  }}|                     ||          }	|                     |          }|                     |	d|d          S )a  
         * @ignore
        fetch account positions
        :see: https://binance-docs.github.io/apidocs/futures/en/#account-information-v2-user_data
        :see: https://binance-docs.github.io/apidocs/delivery/en/#account-information-user_data
        :see: https://binance-docs.github.io/apidocs/pm/en/#get-um-account-detail-user_data
        :see: https://binance-docs.github.io/apidocs/pm/en/#get-cm-account-detail-user_data
        :param str[] [symbols]: list of unified market symbols
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :param boolean [params.portfolioMargin]: set to True if you would like to fetch positions in a portfolio margin account
        :param str [params.subType]: "linear" or "inverse"
        :param boolean [params.filterClosed]: set to True if you would like to filter out closed positions, default is False
        :returns dict: data on account positions
        Nz8 fetchPositions() requires an array argument for symbolsFr  rG   ru  fetchAccountPositionsr  r   r^  z< fetchPositions() supports linear and inverse contracts onlyr)  r  )r  ro  r'   r`  r|  ry  r  rk  r  r  r}  r}  papiGetUmAccountr  r{  papiGetCmAccountr  r2   r  r,  r  r  )
rq  r  r  r  ru  rv  rq  r  r)  r  s
             rs  r  zbinance.fetch_account_positionsN$  s      gt,, n'2l(lmmm!!!!!!!!!))%888888888&&t|]HMM<<66**99:QSWY_aijj $($C$CFLcekm~  AF  %G  %G!6>>$(( 	i  F!%!6!6v!>!>>>>>>>!%!=!=f!E!EEEEEEE__T7++ 	i  D!%!6!6v!>!>>>>>>>!%!;!;F!C!CCCCCCCtw)gghhh#<<VE\^lnsttf--hEE%%g..--fhOOOrt  c                 >  K   |,t          |t                    st          | j        dz             |                                  d{V  |                     d|           d{V  i }d}|                     | j        d|          }|                     |d|          }d}|                     dd|d          \  }}d}| 	                    |dd	d
d          \  }}| 
                    |d          }d}|                     ||          rb|r0|                     |                     ||                     d{V }n|                     |                     ||                     d{V }n|                     ||          rb|r0|                     |                     ||                     d{V }nG|                     |                     ||                     d{V }nt%          | j        dz             g }	t'          dt)          |                    D ]Z}
|                     ||
                   }|                     |d          }|dk    r!|dk    r|dk    r|	                    |           [|                     |          }|                     |	d|d          S )aJ  
         * @ignore
        fetch positions risk
        :see: https://binance-docs.github.io/apidocs/futures/en/#position-information-v2-user_data
        :see: https://binance-docs.github.io/apidocs/delivery/en/#position-information-user_data
        :see: https://binance-docs.github.io/apidocs/pm/en/#query-um-position-information-user_data
        :see: https://binance-docs.github.io/apidocs/pm/en/#query-cm-position-information-user_data
        :param str[]|None symbols: list of unified market symbols
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :param boolean [params.portfolioMargin]: set to True if you would like to fetch positions for a portfolio margin account
        :param str [params.subType]: "linear" or "inverse"
        :returns dict: data on the positions risk
        Nz< fetchPositionsRisk() requires an array argument for symbolsFrG   r  ru  r   r  r   r^  z@ fetchPositionsRisk() supports linear and inverse contracts onlyr   r/  r  z0.0r'  r  )r  ro  r'   r`  r|  ry  r  rk  r  r}  r  r}  papiGetUmPositionRiskr  fapiPrivateV2GetPositionRiskr{  papiGetCmPositionRiskdapiPrivateGetPositionRiskr2   r  r  rl  r  r  r  )rq  r  r  r  r  ru  rv  rq  r  r  r  r  r/  s                rs  r  zbinance.fetch_positions_risk|$  s      gt,, r'2p(pqqq!!!!!!!!!))%888888888&&t|]KPP<<99:NPTV\^fgg $($C$CFL`bhj{  ~C  %D  %D!666**>>$(( 	m  a!%!;!;DKKQW<X<X!Y!YYYYYYY!%!B!B4;;wX^C_C_!`!```````__T7++ 	m  _!%!;!;DKKQW<X<X!Y!YYYYYYY!%!@!@WV\A]A]!^!^^^^^^^tw)kklll@ q#h--(( 	& 	&A--hqk::F))&,??Jc!!
e(;(;*P\B\B\f%%%%%g..--fhOOOrt  c                 d  K   |                                   d{V  d}ddi}|?|                     |          }|d         |d<   |d         st          | j        dz             d}|                     d||d	          \  }}d}|                     |dd
dd          \  }}|                     d||          \  }}|||d<   |||d<   |                     | j        ddd          }	| 	                    |d|	          }
| 
                    |d          }d}|                     |
|          rb|r0|                     |                     ||                     d{V }n|                     |                     ||                     d{V }n|                     |
|          rb|r0|                     |                     ||                     d{V }nG|                     |                     ||                     d{V }nt          | j        dz             |                     ||||          S )a  
        fetch the history of funding payments paid and received on self account
        :see: https://binance-docs.github.io/apidocs/futures/en/#get-income-history-user_data
        :see: https://binance-docs.github.io/apidocs/delivery/en/#get-income-history-user_data
        :see: https://binance-docs.github.io/apidocs/pm/en/#get-um-income-history-user_data
        :see: https://binance-docs.github.io/apidocs/pm/en/#get-cm-income-history-user_data
        :param str symbol: unified market symbol
        :param int [since]: the earliest time in ms to fetch funding history for
        :param int [limit]: the maximum number of funding history structures to retrieve
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :param int [params.until]: timestamp in ms of the latest funding history entry
        :param boolean [params.portfolioMargin]: set to True if you would like to fetch the funding history for a portfolio margin account
        :param str [params.subType]: "linear" or "inverse"
        :returns dict: a `funding history structure <https://docs.ccxt.com/#/?id=funding-history-structure>`
        N
incomeTypeFUNDING_FEEr`  r  rF   z3 fetchFundingHistory() supports swap contracts onlyr   r  r   r^  Fr  r  r  r  rG   ru  zA fetchFundingHistory() supports linear and inverse contracts only)r|  r  r2   r`  r  r}  r  r  rk  r  r  r}  papiGetUmIncomer  fapiPrivateGetIncomer{  papiGetCmIncomedapiPrivateGetIncomeparse_incomes)rq  r  r  r  r  r  r  rv  rq  r  ru  r  s               rs  fetch_funding_historyzbinance.fetch_funding_history%  s       !!!!!!!!!-
 [[((F &tGH&> d"47-b#bccc99:OQWY_aijj $($C$CFLacik|  D  %E  %E!6229gvNN#(GK $GG((7Lm]eff<<66**>>$(( 	n  Y!%!5!5dkk'66R6R!S!SSSSSSS!%!:!:4;;wPV;W;W!X!XXXXXXX__T7++ 	n  Y!%!5!5dkk'66R6R!S!SSSSSSS!%!:!:4;;wPV;W;W!X!XXXXXXXtw)llmmm!!(FE5AAArt  rY  c                   K   |t          | j        dz             |dk     s|dk    rt          | j        dz             |                                  d{V  |                     |          }|d         |d}d}|                     |dd	d
d          \  }}d}|d         rb|r0|                     |                     ||                     d{V }n|                     |                     ||                     d{V }n|d         rb|r0| 	                    |                     ||                     d{V }nG| 
                    |                     ||                     d{V }nt          | j        dz             |S )a1  
        set the level of leverage for a market
        :see: https://binance-docs.github.io/apidocs/futures/en/#change-initial-leverage-trade
        :see: https://binance-docs.github.io/apidocs/delivery/en/#change-initial-leverage-trade
        :see: https://binance-docs.github.io/apidocs/pm/en/#change-um-initial-leverage-trade
        :see: https://binance-docs.github.io/apidocs/pm/en/#change-cm-initial-leverage-trade
        :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 boolean [params.portfolioMargin]: set to True if you would like to set the leverage for a trading pair in a portfolio margin account
        :returns dict: response from the exchange
        Nz) setLeverage() requires a symbol argumentr   }   z% leverage should be between 1 and 125r`  )r  rY  r   r   r^  Fr  r  z9 setLeverage() supports linear and inverse contracts only)r'   r`  r(   r|  r  r}  papiPostUmLeverager  fapiPrivatePostLeveragepapiPostCmLeveragedapiPrivatePostLeverager2   )rq  rY  r  r  r  r  rq  r  s           rs  set_leveragezbinance.set_leverageB%  s      >#DG.Y$YZZZ qLLhnnTW'NNOOO!!!!!!!!!V$$Tl 
 
 !$($C$CFM[actv{$|$|!6( 	f  \!%!8!8Wf9U9U!V!VVVVVVV!%!=!=dkk'SY>Z>Z![![[[[[[[I 	f  \!%!8!8Wf9U9U!V!VVVVVVV!%!=!=dkk'SY>Z>Z![![[[[[[[tw)ddeeert  rp  c                   K   |t          | j        dz             |                                }|dk    rd}|dk    r|dk    rt          | j        dz             |                                  d{V  |                     |          }|d         |d}d}	 |d	         r0|                     |                     ||                     d{V }nO|d
         r0|                     |                     ||                     d{V }nt          | j        dz             nT# t          $ rG}t          |t                    r&|                     | j        dd          }|r|ddd}n|Y d}~nd}~ww xY w|S )a  
        set margin mode to 'cross' or 'isolated'
        :see: https://binance-docs.github.io/apidocs/futures/en/#change-margin-type-trade
        :see: https://binance-docs.github.io/apidocs/delivery/en/#change-margin-type-trade
        :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 argumentCROSSCROSSEDr  z, marginMode must be either isolated or crossr`  )r  rZ  r  r  z; setMarginMode() supports linear and inverse contracts onlyr  Fi2No need to change margin type.)r  msg)r'   r`  r[  r(   r|  r  fapiPrivatePostMarginTyper  dapiPrivatePostMarginTyper2   	Exceptionr  r+   r  rk  )	rq  rp  r  r  r  r  r  er  s	            rs  set_margin_modezbinance.set_margin_model%  s      >#DG.[$[\\\  %%''
  "J*$$:+B+BTW'UUVVV!!!!!!!!!V$$Tl$
 
 	h l!%!?!?GU[@\@\!]!]]]]]]]	" l!%!?!?GU[@\@\!]!]]]]]]]"47-j#jkkk 	 	 	 !122 ,0NN4<Idfk,l,l), XG(-6VWWHH HHHH	 s   BD   
E1*=E,,E1rA  c                 >  K   |                      | j        dd          }|                      |d|          }|                     |dg          }d}|                     dd|          \  }}d}|                     |dddd          \  }}d}|rd	}nd
}d|i}	d}
|                     ||          rb|r0|                     |                     |	|                     d{V }
n|                     |                     |	|                     d{V }
n| 	                    ||          rb|r0| 
                    |                     |	|                     d{V }
nG|                     |                     |	|                     d{V }
nt          | j        dz             |
S )aq  
        set hedged to True or False for a market
        :see: https://binance-docs.github.io/apidocs/futures/en/#change-position-mode-trade
        :see: https://binance-docs.github.io/apidocs/delivery/en/#change-position-mode-trade
        :see: https://binance-docs.github.io/apidocs/pm/en/#change-um-position-mode-trade
        :see: https://binance-docs.github.io/apidocs/pm/en/#change-cm-position-mode-trade
        :param bool hedged: set to True to use dualSidePosition
        :param str symbol: not used by binance setPositionMode()
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :param boolean [params.portfolioMargin]: set to True if you would like to set the position mode for a portfolio margin account
        :param str [params.subType]: "linear" or "inverse"
        :returns dict: response from the exchange
        r  rG   ru  Nr   r   r^  FtruefalsedualSidePositionz= setPositionMode() supports linear and inverse contracts only)r  rk  r  r  r}  r{  papiPostCmPositionSideDualr  dapiPrivatePostPositionSideDualr}  papiPostUmPositionSideDualfapiPrivatePostPositionSideDualr(   r`  )rq  rA  r  r  r  ru  rv  rq  r  r  r  s              rs  set_position_modezbinance.set_position_mode%  s      &&t|]HMM<<6F8,,99:KTSYZZ $($C$CFL]_egxz  %A  %A!6 	'%& 0
 ??4)) 	h  d!%!@!@WV\A]A]!^!^^^^^^^!%!E!EdkkRY[aFbFb!c!ccccccc^^D'** 	h  d!%!@!@WV\A]A]!^!^^^^^^^!%!E!EdkkRY[aFbFb!c!cccccccTW'ffggg rt  c                   K   |                                   d{V  |                     d|           d{V  d}|                     dd|          \  }}d}|                     dd|d          \  }}d}|                     |dddd          \  }}d}|                     ||          r:|r|                     |           d{V }n|                     |           d{V }ng|                     ||          r:|r| 	                    |           d{V }n3| 
                    |           d{V }nt          | j        dz             |                     |dg           }|                     ||d	          S )
a  
        fetch the set leverage for all markets
        :see: https://binance-docs.github.io/apidocs/futures/en/#account-information-v2-user_data
        :see: https://binance-docs.github.io/apidocs/delivery/en/#account-information-user_data
        :see: https://binance-docs.github.io/apidocs/pm/en/#get-um-account-detail-user_data
        :see: https://binance-docs.github.io/apidocs/pm/en/#get-cm-account-detail-user_data
        :param str[] [symbols]: a list of unified market symbols
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :param str [params.subType]: "linear" or "inverse"
        :returns dict: a list of `leverage structures <https://docs.ccxt.com/#/?id=leverage-structure>`
        NFr   r  r   r^  z< fetchLeverages() supports linear and inverse contracts onlyr"  r  )r|  ry  r  r  r}  r}  r  r  r{  r  r  r2   r`  r  parse_leverages)rq  r  r  ru  rv  rq  r  	leveragess           rs  fetch_leverageszbinance.fetch_leverages%  s      !!!!!!!!!))%88888888899:JDRXYYf99:JDRXZbcc $($C$CFL\^dfwy~$$!6>>$(( 	i  F!%!6!6v!>!>>>>>>>!%!=!=f!E!EEEEEEE__T7++ 	i  D!%!6!6v!>!>>>>>>>!%!;!;F!C!CCCCCCCtw)gghhhNN8["==	##IwAAArt  c                 >   |                      |d          }|                     |d          }d }||rdnd}|                     |d          }d }d }|                     |d          }	|dk    r|	}|	}n|dk    r|	}n|dk    r|	}||                     ||          |||d	S )
Nr  rU  r  r  rY  bothr6  r5  )r  r  rp  longLeverageshortLeverage)r  r  r=  r  rm  )
rq  rY  r  r  marginModeRawrp  r&  r  r  leverageValues
             rs  parse_leveragezbinance.parse_leverage%  s    ##Hh77x<<
$'4A'J%%h??))(J??6>>(L)MMV^^(LLW__)M&&x88$(*
 
 	
rt  c                    K   |                                   d{V  |dn|                     |          }d}|                     d||          \  }}|dk    rt          | j        dz             i }||d         }|d         |d         z   |d<   |||d	<   |||d
<   |                     |                     ||                     d{V }|                     ||          }	|                     |	d          }
| 	                    |
|||          S )a  
        fetches historical settlement records
        :see: https://binance-docs.github.io/apidocs/voptions/en/#historical-exercise-records
        :param str symbol: unified market symbol of the settlement history
        :param int [since]: timestamp in ms
        :param int [limit]: number of records, default 100, max 100
        :param dict [params]: exchange specific params
        :returns dict[]: a list of `settlement history objects <https://docs.ccxt.com/#/?id=settlement-history-structure>`
        Nr   rH   z6 fetchSettlementHistory() supports option markets onlyr  r  r  r  r  r  r  )
r|  r  r  r2   r`  eapiPublicGetExerciseHistoryr  parse_settlementsr)  r
  rq  r  r  r  r  r  ru  r  r  settlementsr  s              rs  fetch_settlement_historyz binance.fetch_settlement_history&  sO      !!!!!!!!! .t{{6/B/B99:RTZ\bccf8tw)aabbbH%F$*8$4vi7H$HGL!#(GK $GG::4;;wPV;W;WXXXXXXXX ,,Xv>>k;7700NNNrt  c                 
  K   |                                   d{V  |dn|                     |          }d}|                     d||          \  }}|dk    rt          | j        dz             i }||d         |d<   |||d<   |||d<   |                     |                     ||                     d{V }|                     ||          }	|                     |	d	          }
| 	                    |
|d         ||          S )
a  
        fetches historical settlement records of the user
        :see: https://binance-docs.github.io/apidocs/voptions/en/#user-exercise-record-user_data
        :param str symbol: unified market symbol of the settlement history
        :param int [since]: timestamp in ms
        :param int [limit]: number of records
        :param dict [params]: exchange specific params
        :returns dict[]: a list of [settlement history objects]
        Nr   rH   z8 fetchMySettlementHistory() supports option markets onlyr`  r  r  r  r  )
r|  r  r  r2   r`  eapiPrivateGetExerciseRecordr  r  r)  r
  r  s              rs  fetch_my_settlement_historyz#binance.fetch_my_settlement_history9&  s@      !!!!!!!!! .t{{6/B/B99:TV\^deef8tw)ccddd &tGH#(GK $GG::4;;wPV;W;WXXXXXXXX* ,,Xv>>k;77009I5RWXXXrt  c                     |                      |dd          }|                     |d          }||                     ||          |                     |dd          ||                     |          dS )Nr  
createDater  realStrikePriceexercisePrice)r  r  r  r  r  )r>  r  rm  rA  rC  )rq  
settlementr  r  r  s        rs  parse_settlementzbinance.parse_settlementi&  s}    > ''
L,OO	##J99&&x88''
4EWW"Y//
 
 	
rt  c                     g }t          dt          |                    D ]1}|                    |                     ||         |                     2|S )Nr   )r  r  r  r  )rq  r  r  r  r  s        rs  r  zbinance.parse_settlements&  s[    F q#k**++ 	I 	IAMM$//AGGHHHHrt  c           	        K   |                                   d {V  d }|                     dd |          \  }}||d}|dk    rt          | j        dz             |                     |d d |                     ||                     d {V S )Nr   )recordIdru  rH   z4 fetchLedgerEntry() can only be used for type option)r|  r  r(   r`  fetch_ledgerr  )rq  r`  r  r  ru  r  s         rs  fetch_ledger_entryzbinance.fetch_ledger_entry&  s      !!!!!!!!!99:LdTZ[[f
 
 8TW']]^^^&&tT4UF9S9STTTTTTTTTrt  c                   K   |                                   d{V  d}|                     |dd          \  }}|r|                     d||||           d{V S d}d}d}||                     |          }i }	|                     dd|          \  }}|                     dd|          \  }}|||	d<   |||	d<   |                     |d          }
|
|                     |d          }|
|	d<   d}|                     |dd	d
d          \  }}d}|dk    rS| 	                    d|d           |d         |	d<   | 
                    |                     |	|                     d{V }n|                     ||          rb|r0|                     |                     |	|                     d{V }n|                     |                     |	|                     d{V }n|                     ||          rb|r0|                     |                     |	|                     d{V }nG|                     |                     |	|                     d{V }nt%          | j        dz             |                     ||||          S )a  
        fetch the history of changes, actions done by the user or operations that altered the balance of the user
        :see: https://binance-docs.github.io/apidocs/voptions/en/#account-funding-flow-user_data
        :see: https://binance-docs.github.io/apidocs/futures/en/#get-income-history-user_data
        :see: https://binance-docs.github.io/apidocs/delivery/en/#get-income-history-user_data
        :see: https://binance-docs.github.io/apidocs/pm/en/#get-um-income-history-user_data
        :see: https://binance-docs.github.io/apidocs/pm/en/#get-cm-income-history-user_data
        :param str code: unified currency code
        :param int [since]: timestamp in ms of the earliest ledger entry
        :param int [limit]: max number of ledger entrys to return
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :param int [params.until]: timestamp in ms of the latest ledger entry
        :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)
        :param boolean [params.portfolioMargin]: set to True if you would like to fetch the ledger for a portfolio margin account
        :param str [params.subType]: "linear" or "inverse"
        :returns dict: a `ledger structure <https://docs.ccxt.com/#/?id=ledger-structure>`
        NFr   r  r  r  r  r  r   r^  rH   r  r`  r  z- fetchLedger() supports contract wallets only)r|  r  r/  r  r  r  r  r  r}  check_required_argumenteapiPrivateGetBillr  r}  r  r  r{  r  r  r2   r`  parse_ledger)rq  r  r  r  r  r  ru  rv  r  r  r  rq  r  s                rs  r  zbinance.fetch_ledger&  s     $ !!!!!!!!!88PZ[[& 	f::=$PUW\^deeeeeeeee}}T**H99-vVVf99-vVV#(GK $GG!!&'22YYvw//F!&GI $($C$CFM[actv{$|$|!68((fEEE"*4.GJ!44T[[&5Q5QRRRRRRRRHH^^D'** 	Z  Y!%!5!5dkk'66R6R!S!SSSSSSS!%!:!:4;;wPV;W;W!X!XXXXXXX__T7++ 	Z  Y!%!5!5dkk'66R6R!S!SSSSSSS!%!:!:4;;wPV;W;W!X!XXXXXXXtw)XXYYY:   8UEBBBrt  c                 *   |                      |dd          }d }t          j        |d          rd}t          j        d|          }nd}|                     |d          }|                     |dd	          }|                      |d
d          }|                      |dd          |d d |                     |d          |                     |          |                     ||          |                     |          || 	                    |          d d d d |dS )Nr  rM  r  outr  inrV  r  r$  ru  r  r`  r  r  )r`  	directionrJ  referenceAccountreferenceIdru  r  r  r  r  beforeafterr  r  r  )
r  r;   	string_ler"  r  r>  parse_ledger_entry_typer  rp  rC  )rq  itemr  r  r  rr  r  ru  s           rs  parse_ledger_entryzbinance.parse_ledger_entry'  s,   2 ##D(H==	VS)) 	I'f55FFI%%dG44
''lFCC	!!$==$$T4::" $++D)<<0066//
HEE''//"Y//
 
 	
rt  c                     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}|                      |||          S )NFEEr  r  OPTIONS_PREMIUM_FEEPOSITION_LIMIT_INCREASE_FEECONTRACTr%  REALIZED_PNLTRANSFERr   CROSS_COLLATERAL_TRANSFERINTERNAL_TRANSFERCOIN_SWAP_DEPOSITr  COIN_SWAP_WITHDRAWr  OPTIONS_SETTLE_PROFITr  DELIVERED_SETTELMENTWELCOME_BONUScashbackCONTEST_REWARDCOMMISSION_REBATErebate
API_REBATEr   r  )REFERRAL_KICKBACK
COMMISSIONr  )rq  ru  
ledgerTypes      rs  r  zbinance.parse_ledger_entry_typeS'  s   
5
5
 "5
 *5	

 
 G
 

 (
  
  
 !,
 $\
 #L
 Z
 j
   !
" (#
$ ",&'
 
 

* 
D$777rt  r   GETc                 B
   | j         }||d         vrt          | j        dz   |z   dz             | j         d         |         }|d|z   z  }|dk    r(| j        r
d| j        i}nt	          | j        dz             |dk    p|d	k    }	|	rE| j        r'| j        d
d}|dk    r|                     |          }nft	          | j        dz             |dk    sJ|dk    sD|dk    r|dk    s8|dk    s2|dk    s,|dk    s&|dk    s |dk    s|dk    s|dk    s|dk    r|dk    r|                                  |dk    r|dk    s|dk    r|                     |d          }
|
x|                    d          dk    p|dk    }|rd nd!}|sd"nd#}| 	                    | j
        d$i           }|                     |||          }||                                 z   |d<   d }|d%k    r6|dk    r0|                     |d%          }|                     |          }||d%<   |                     | j
        d&          }|                     d'|                                 i|          }|||d&<   |                     |d&          }|||d&<   |dk    r|d(k    r|                     |          }n=|d%k    s8|                    d)          d*k    s|d+k    s|                    d,          d*k    r|d-k    r|d%k    r|                     |d.g           }|                     |d/g           }|                     |d.d/g          }|                     |          }t+          |          }t+          |          }|d*k    r!|d0z   d1z   d2                    |          z   d3z   }|d*k    r!|d0z   d4z   d2                    |          z   d3z   }n+|                     |          }n|                     |          }d }| j                            d5          dk    rt+          | j                  d6k    r0|                     |                     || j        d7                    }n|                     |                     |                     |          | j        d8                    }nL|                     |                     |          |                     | j                  t:          j                  }|d9|z   z  }d| j        i}|dk    s|d-k    r	|d:|z   z  }n%|}d
|d;<   n|r|d:|                     |          z   z  }||||d<S )=Nr   z) does not have a testnet/sandbox URL for z
 endpointsr  r,  X-MBX-APIKEYz7 historicalTrades endpoint requires `apiKey` credentialr  r\  z!application/x-www-form-urlencoded)r  Content-Typer	  z5 userDataStream endpoint requires `apiKey` credentialr   r   r   r   r   r   r   r   r   r   r   r   r#  POSTrE  r~  r?  r  rD   rG   r  r  r  rW  r  r  r  zsub-accountr   r  stakingDELETErH  origclientorderidlist&zorderidlist=[r{  ]zorigclientorderidlist=[zPRIVATE KEYx   sha256ed25519z&signature=?r  )r   r+  bodyheaders)rh  r2   r`  apiKeyr$   	urlencoder  r  r  r  rk  r^  r  r  r  r  r  urlencode_with_array_repeatr  r  	rawencoder  r  secretencode_uri_componentrsaeddsaencodehmachashlibr  )rq  pathr   r+  r  r  r  rh  r   r  r?  r  r  r  r  rd  r  rW  
queryBatchdefaultRecvWindowextendedParamsr  rH  r  orderidlistLengthorigclientorderidlistLength	signatures                              rs  signzbinance.signk'  s   ytE{""tw)TTWZZ]iijjjis#sTz%%%{ o"DK *$'4m*mnnn"22L8K K	4{ 	m %)K$G  U??>>&11D)$'4k*klllYC=$8$8cVmmPTXgPgPgmpt|m|m|  CF  JR  CR  CR  X[  _g  Xg  Xg  mp  tA  mA  mA  GJ  N]  G]  G]  cf  jw  cw  cw  }@  DS  }S  }S  Y\  `f  Yf  Yf  ko  sy  ky  ky++---dgoo4;;N;N#'#3#3F<N#O#O #+&)hhv&6&6&;&Osi?ON+9!GxJ5C V,I!^^DL(BGGF#//
INNH19DKKMM1IF-.E%%Ff,<,<"oofmDD"ii44
(2}% $ 1 1$, M M![[TZZ\\* N !,/@|,**6<@@J%/9|,vDL$8$888HH-''TYY}-E-E-J-JPTXpPpPpvzvv  AJ  wK  wK  OP  wP  wPh&&T]-B-B"&..PR"S"SK,0NN>Kbdf,g,g)%)YY~Of?g%h%hN NN>::E(+K(8(8%256K2L2L/(1,, %o =@U@U UX[ [2Q66 %.G G#((ShJiJi ilo o NN>::EE~66I{..33t{##c)) $ 9 9$((5$+W_:`:` a aII $ 9 9$**T[[QVEWEWY]Ydfo:p:p q qII IIdkk%&8&8$++dk:R:RT[Tbcc	')33EG %Vx%7%7sU{"*M'' 4sT^^F3333fdwOOOrt  c                    d }| j         | j         nd}|                    d|z   dz             rd}nw|                    d|z   dz             rd}nY|                    d|z   dz             rd}n;|                    d	|z   dz             rd
}n|                    d|z   dz             rd}|3|                     | j        |i           }|                     ||i           S i S )Nzbinance.comzhttps://api.r  rD   zhttps://dapi.r  zhttps://fapi.r  zhttps://eapi.rH   zhttps://papi.portfoliomargin)hostname
startswithr  rl  )rq  r   exactOrBroadr  r.  exceptionsForMarketTypes         rs  get_exceptions_by_urlzbinance.get_exceptions_by_url'  s   
%)]%>4==]>>.83c9:: 		+JJ^^Oh6<== 	+"JJ^^Oh6<== 	+!JJ^^Oh6<== 	+!JJ^^Oh6<== 	+*J!&*nnT_jRT&U&U#>>"9<LLL	rt  c
                    |dk    s|dk    r3t          | j        dz   t          |          z   dz   |z   dz   |z             |dk    r|                    d          dk    rt	          | j        dz   |z             |                    d          dk    rt	          | j        d	z   |z             |                    d
          dk    rt	          | j        dz   |z             |d S |                     |dd          }
|
sM|                     |d          }d }|3	 t          j        |          }n# t          $ r}d }Y d }~nd }~ww xY w||}|                     |d          }|| 
                    |                     |d          || j        dz   |z              | 
                    | j        d         || j        dz   |z              |                     |                     |d          || j        dz   |z              |                     | j        d         || j        dz   |z              |                     |d          }||dk    st          j        |d          rd S |dk    r'| j        d         rt          | j        dz   |z             | j        dz   |z   }|dk    rt#          |          | 
                    |                     |d          ||           | 
                    | j        d         ||           t%          |          |
st%          | j        dz   |z             t'          |t(                    rt+          |          }|dk    r|d         }|                     |d          }|c| 
                    |                     |d          || j        dz   |z              | 
                    | j        d         || j        dz   |z              d S )Ni  i  rL  i  zPrice * QTY is zero or lessr   z- order cost = amount * price is zero or less r5  z5 order amount should be evenly divisible by lot size r1  z order price is invalid, i.e. exceeds allowed price precision, exceeds min price or max price limits or is invalid value in general, use self.price_to_precision(symbol, amount) successTr  rF  r_  r  200r  r\  r  r  r   )r4   r`  r  r  r.   r  r  r  loadsr  throw_exactly_matched_exceptionr2  rl  throw_broadly_matched_exceptionr;   rE  rk  r+   r#   r  ro  r  )rq  r  reasonr   r+  r  r  r  requestHeadersrequestBodyr4  
messageNewparsedMessager  messageerrorfeedbackarrayLengthelement	errorCodes                       rs  handle_errorszbinance.handle_errors'  sk   CKKTS[[ 3T!:S!@6!IC!ORV!VWWW 3;;yy6771<<"47-\#\_c#cdddyy$$))"47-d#dgk#klllyy((A--"47  .a  $a  dh  $h  i  i  i4..9d;; 
	-))(E::J M%)$(Jz$:$:MM  ) ) )$(MMMMMM) !,,H""8U33001K1KCQX1Y1Y[bdhdknqdqt{d{|||001I7TXT[^aTadkTklll001K1KCQX1Y1Y[bdhdknqdqt{d{|||001I7TXT[^aTadkTklll  622 7#8#D#Dt   dl3X&Y $TWs]T%9:::w}t+H::: +8444001K1KCQX1Y1Y[`bjkkk001I5RZ[[[))) 	6# 4555h%% 	th--Ka"1+ ,,Wf==	(889S9STWY`9a9aclnrnux{n{  C  oC  D  D  D889QS\^b^ehk^knr^rsssts   D, ,
E6D==Ec                 <   d|v rd|vr|d         S d|v rd|vr|d         S d|v rd|vr|d         S d|v rRd|v rN|d         }|d         }t          d	t          |                    D ] }||         }	||	d	         k    r
|	d
         c S !|                     |dd
          S )Nr  r  r7  r  r  poolIdr*  r  r   r   r   )r  r  r  )
rq  r   r+  r$  r  configr  r*  r  r  s
             rs  calculate_rate_limiter_costz#binance.calculate_rate_limiter_cost(  s    6)9)9(##F""X-?-?*%%F""X-?-?*%%6!!6(9(97OEY'G1c'll++ $ $
E!H$$ 8OOO %vvq111rt  c           	      l   K   |                      |||||||           d {V }|dk    r
d| j        d<   |S )Nr   Tr  )fetch2rk  )	rq  r$  r   r+  r  r  r  rG  r  s	            rs  r  zbinance.request/(  sR      T3vVVVVVVVV)BFDL>?rt  c                   K   |                      | j        dd          }|dk    rd}|                      |d|          }|dk    s|dk    rt          | j        dz             |                                  d {V  |                     |          }|                     ||          }||d         |d}d }	d }
|d	         r8|d
         }
|                     |                     ||                     d {V }	n7|d         }
| 	                    |                     ||                     d {V }	|                     | 
                    |	|          d|
i          S )Nr  rG   rD   ru  rE   z@ add / reduce margin only supported with type future or deliveryr`  )ru  r  r  r  r  r  r  )r  rk  r2   r`  r|  r  r_  fapiPrivatePostPositionMarginr  dapiPrivatePostPositionMarginparse_margin_modification)rq  r  r  addOrReducer  r  ru  r  r  r  r  s              rs  modify_margin_helperzbinance.modify_margin_helper6(  s     &&t|]HMM&  "K<<H$&..tw)kklll!!!!!!!!!V$$))&&99Tl
 

 ( 	^'?D!??GU[@\@\]]]]]]]]HH&>D!??GU[@\@\]]]]]]]]H {{499(FKKDN
   	rt  c                    |                      |d          }|                     |d          }|                     |d          }|                      |d          }|                     ||d d          }|d u }|dk    }||d         |dk    rdnd	d
|                     |d          |                     |d          d |s|rdnd||                     |          d
S )Nru  r  r  r$  rF   r5  r   addreducerU  r  rV  r  r  )
r  r  ru  rp  r  r  r`  r  r  r  r  )	rq  r;  r  rawTyperC  r  r  noErrorCoder4  s	            rs  rN  z!binance.parse_margin_modificationZ(  s    0 ##D&11$$T622	##D(33%%dF33	!!(FD&AA4'u$X&%llEE$&&tX66$$T733&D+DddH"Y//
 
 	
rt  c                 B   K   |                      ||d|           d{V S )a"  
        :see: https://binance-docs.github.io/apidocs/delivery/en/#modify-isolated-position-margin-trade
        :see: https://binance-docs.github.io/apidocs/futures/en/#modify-isolated-position-margin-trade
        remove margin from a position
        :param str symbol: unified market symbol
        :param float amount: the amount of margin to remove
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: a `margin structure <https://docs.ccxt.com/#/?id=reduce-margin-structure>`
        r  NrP  rq  r  r  r  s       rs  reduce_marginzbinance.reduce_margin(  4       ..vvq&IIIIIIIIIrt  c                 B   K   |                      ||d|           d{V S )a  
        :see: https://binance-docs.github.io/apidocs/delivery/en/#modify-isolated-position-margin-trade
        :see: https://binance-docs.github.io/apidocs/futures/en/#modify-isolated-position-margin-trade
        add margin
        :param str symbol: unified market symbol
        :param float amount: amount of margin to add
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: a `margin structure <https://docs.ccxt.com/#/?id=add-margin-structure>`
        r   NrW  rX  s       rs  
add_marginzbinance.add_margin(  rZ  rt  c                 ,  K   |                                   d{V  |                     |          }d|d         i}|                     |                     ||                     d{V }|                     |d          }|                     |          S )a  
        fetch the rate of interest to borrow a currency for margin trading
        :see: https://binance-docs.github.io/apidocs/spot/en/#query-margin-interest-rate-history-user_data
        :param str code: unified currency code
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: a `borrow rate structure <https://docs.ccxt.com/#/?id=borrow-rate-structure>`
        NrV  r`  r   )r|  r   sapiGetMarginInterestRateHistoryr  r  parse_borrow_rate)rq  r  r  r  r  r  r  s          rs  fetch_cross_borrow_ratezbinance.fetch_cross_borrow_rate(  s       !!!!!!!!!==&&Xd^
 >>t{{7TZ?[?[\\\\\\\\ ~~h**%%d+++rt  c                   K   |                                   d{V  |d}n|dk    rt          | j        dz             |                     |          }|d         |d}|H||d<   |                     ||dz            dz
  }|                                 }t          ||          |d	<   |                     |                     ||                     d{V }	| 	                    |	|||          S )
a  
        retrieves a history of a currencies borrow interest rate at specific time slots
        :see: https://binance-docs.github.io/apidocs/spot/en/#query-margin-interest-rate-history-user_data
        :param str code: unified currency code
        :param int [since]: timestamp for the earliest borrow rate
        :param int [limit]: the maximum number of `borrow rate structures <https://docs.ccxt.com/#/?id=borrow-rate-structure>` to retrieve
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict[]: an array of `borrow rate structures <https://docs.ccxt.com/#/?id=borrow-rate-structure>`
        N]   z: fetchBorrowRateHistory() limit parameter cannot exceed 92r`  )rV  r  r   \&r   r  )
r|  r(   r`  r  r  r  r  r^  r  parse_borrow_rate_history)
rq  r  r  r  r  r  r  r  r  r  s
             rs  fetch_borrow_rate_historyz!binance.fetch_borrow_rate_history(  s"      !!!!!!!!!=EERZZTW'ccddd==&&d^
 
 #(GK hhueh&677!;G##%%C!$Wc!2!2GI>>t{{7TZ?[?[\\\\\\\\ --heUKKKrt  c                    g }t          dt          |                    D ]4}||         }|                     |          }|                    |           5|                     |d          }	|                     |	|||          S )Nr   r  )r  r  r_  r  r)  filter_by_currency_since_limit)
rq  r  r  r  r  r  r  r  
borrowRater  s
             rs  rd  z!binance.parse_borrow_rate_history(  s    q#h--(( 	& 	&AA;D//55JMM*%%%%fk222264NNNrt  c                     |                      |d          }|                     |d          }|                     ||          |                     |d          d||                     |          |dS )Nr  rV  dailyInterestRaterc  )r  r  periodr  r  r  )r  r  r  r  rC  )rq  r  r  r  rr  s        rs  r_  zbinance.parse_borrow_rate(  s|     %%dK88	%%dG44
//
HEE$$T+>??"Y//
 
 	
rt  c                 l  K   |                                   d{V  |                     |          }|d         |d}|                     |                     ||                     d{V }|                     |d          }|                     |d          }|                     |d          }	||	|||dS )a  
        create gift code
        :see: https://binance-docs.github.io/apidocs/spot/en/#create-a-single-token-gift-card-user_data
        :param str code: gift code
        :param float amount: amount of currency for the gift
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: The gift code id, code, currency and amount
        Nr`  )tokenr  r;  r  referenceNo)r  r`  r  r  r  )r|  r  sapiPostGiftcardCreateCoder  r  r  )
rq  r  r  r  r  r  r  r;  giftcardCoder`  s
             rs  create_gift_codezbinance.create_gift_code(  s       !!!!!!!!!==&& d^
 
 88Wf9U9UVVVVVVVV ~~h//''f55dM22 
 
 	
rt  c                 p   K   d|i}|                      |                     ||                     d{V }|S )a-  
        redeem gift code
        :see: https://binance-docs.github.io/apidocs/spot/en/#redeem-a-binance-gift-card-user_data
        :param str giftcardCode:
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: response from the exchange
        r  N)sapiPostGiftcardRedeemCoder  )rq  rp  r  r  r  s        rs  redeem_gift_codezbinance.redeem_gift_code")  sP       L
 88Wf9U9UVVVVVVVV rt  c                 p   K   d|i}|                      |                     ||                     d{V }|S )aI  
        verify gift code
        :see: https://binance-docs.github.io/apidocs/spot/en/#verify-binance-gift-card-by-gift-card-number-user_data
        :param str id: reference number id
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: response from the exchange
        rn  N)sapiGetGiftcardVerifyr  )rq  r`  r  r  r  s        rs  verify_gift_codezbinance.verify_gift_code;)  sP       2
 33DKK4P4PQQQQQQQQ rt  c                   K   |                                   d{V  d}|                     |dddd          \  }}i }d}| |                     |          }	|	d         |d<   |||d<   |||d	<   |                     d
||          \  }}d}
|r0|                     |                     ||                     d{V }
nQ| |                     |          }|d         |d<   |                     |                     ||                     d{V }
|                     |
d          }| 	                    ||          }| 
                    ||||          S )a  
        fetch the interest owed by the user for borrowing currency for margin trading
        :see: https://binance-docs.github.io/apidocs/spot/en/#get-interest-history-user_data
        :see: https://binance-docs.github.io/apidocs/pm/en/#get-margin-borrow-loan-interest-history-user_data
        :param str [code]: unified currency code
        :param str [symbol]: unified market symbol when fetch interest in isolated markets
        :param int [since]: the earliest time in ms to fetch borrrow interest for
        :param int [limit]: the maximum number of structures to retrieve
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :param boolean [params.portfolioMargin]: set to True if you would like to fetch the borrow interest in a portfolio margin account
        :returns dict[]: a list of `borrow interest structures <https://docs.ccxt.com/#/?id=borrow-interest-structure>`
        Nrj   r   r^  Fr`  rV  r  r  r  r  rb  )r|  r}  r  r  "papiGetMarginMarginInterestHistoryr  r  sapiGetMarginInterestHistoryr  parse_borrow_interestsrg  )rq  r  r  r  r  r  rq  r  r  r  r  rb  rO  s                rs  fetch_borrow_interestzbinance.fetch_borrow_interestQ)  s      !!!!!!!!! $($C$CFLacik|  D  %E  %E!6}}T**H'~GG#(GK #GFO229gvNN 	]!DDT[[QXZ`EaEabbbbbbbbHH!V,,,24L()!>>t{{7TZ?[?[\\\\\\\\HJ ~~h//..tV<<228T5%PPPrt  c                 t   |                      |d          }|                     |d          }|dnd}|dn||||                     |                      |d                    |                     |d          |                     |d          |                     |d          ||                     |          |d	
S )
Nr  interestAccuredTimer  rU  rV  rO  r  	principal)
rJ  r  rp  r  rO  r  amountBorrowedr  r  r  )r  r  r  r  rC  )rq  r  r  r  r  rp  s         rs  parse_borrow_interestzbinance.parse_borrow_interest)  s    !!$(899%%d,ABB	!'WWj
#)>ww$//0@0@w0O0OPP((z:: ,,T>BB"..t[AA"Y//
 
 	
rt  c                   K   |                                   d{V  |                     |          }|d         |                     ||          d}d}d}|                     |dddd          \  }}|r0|                     |                     ||                     d{V }n9d|d	<   d
|d<   |                     |                     ||                     d{V }|                     ||          S )a  
        repay borrowed margin and interest
        :see: https://binance-docs.github.io/apidocs/spot/en/#margin-account-borrow-repay-margin
        :see: https://binance-docs.github.io/apidocs/pm/en/#margin-account-repay-margin
        :param str code: unified currency code of the currency to repay
        :param float amount: the amount to repay
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :param boolean [params.portfolioMargin]: set to True if you would like to repay margin in a portfolio margin account
        :returns dict: a `margin loan structure <https://docs.ccxt.com/#/?id=margin-loan-structure>`
        Nr`  r  r   r   r^  FFALSEr	  REPAYru  )r|  r  r  r}  papiPostRepayLoanr  sapiPostMarginBorrowRepayparse_margin_loanrq  r  r  r  r  r  r  rq  s           rs  repay_cross_marginzbinance.repay_cross_margin)  s<      !!!!!!!!!==&&d^00v>>
 
  $($C$CFL^`fhy  |A  %B  %B!6 	Z!33DKK4P4PQQQQQQQQHH$+GL!%GFO!;;DKKQW<X<XYYYYYYYYH %%h999rt  c                 h  K   |                                   d{V  |                     |          }|                     |          }|d         |                     ||          |d         ddd}|                     |                     ||                     d{V }|                     ||          S )a  
        repay borrowed margin and interest
        :see: https://binance-docs.github.io/apidocs/spot/en/#margin-account-borrow-repay-margin
        :param str symbol: unified market symbol, required for isolated margin
        :param str code: unified currency code of the currency to repay
        :param float amount: the amount to repay
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: a `margin loan structure <https://docs.ccxt.com/#/?id=margin-loan-structure>`
        Nr`  TRUEr  rV  r  r  r	  ru  r|  r  r  r  r  r  r  	rq  r  r  r  r  r  r  r  r  s	            rs  repay_isolated_marginzbinance.repay_isolated_margin)  s       !!!!!!!!!==&&V$$d^00v>>Tl 
 
 77GV8T8TUUUUUUUU %%h999rt  c                   K   |                                   d{V  |                     |          }|d         |                     ||          d}d}d}|                     |dddd          \  }}|r0|                     |                     ||                     d{V }n9d|d	<   d
|d<   |                     |                     ||                     d{V }|                     ||          S )a  
        create a loan to borrow margin
        :see: https://binance-docs.github.io/apidocs/spot/en/#margin-account-borrow-repay-margin
        :see: https://binance-docs.github.io/apidocs/pm/en/#margin-account-borrow-margin
        :param str code: unified currency code of the currency to borrow
        :param float amount: the amount to borrow
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :param boolean [params.portfolioMargin]: set to True if you would like to borrow margin in a portfolio margin account
        :returns dict: a `margin loan structure <https://docs.ccxt.com/#/?id=margin-loan-structure>`
        Nr`  r  rJ   r   r^  Fr  r	  BORROWru  )r|  r  r  r}  papiPostMarginLoanr  r  r  r  s           rs  borrow_cross_marginzbinance.borrow_cross_margin)  s<      !!!!!!!!!==&&d^00v>>
 
  $($C$CFL_agiz  }B  %C  %C!6 	Z!44T[[&5Q5QRRRRRRRRHH$+GL!&GFO!;;DKKQW<X<XYYYYYYYYH %%h999rt  c                 h  K   |                                   d{V  |                     |          }|                     |          }|d         |                     ||          |d         ddd}|                     |                     ||                     d{V }|                     ||          S )a  
        create a loan to borrow margin
        :see: https://binance-docs.github.io/apidocs/spot/en/#margin-account-borrow-repay-margin
        :param str symbol: unified market symbol, required for isolated margin
        :param str code: unified currency code of the currency to borrow
        :param float amount: the amount to borrow
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: a `margin loan structure <https://docs.ccxt.com/#/?id=margin-loan-structure>`
        Nr`  r  r  r  r  r  s	            rs  borrow_isolated_marginzbinance.borrow_isolated_margin*  s       !!!!!!!!!==&&V$$d^00v>>Tl 
 
 77GV8T8TUUUUUUUU %%h999rt  c                 f    |                      |d          |                     d |          d d d d |dS )Nr  )r`  r  r  r  r  r  r  )r  r  )rq  r  r  s      rs  r  zbinance.parse_margin_loan**  sH     ##D(33//h??
 
 	
rt  r   c           	        K   |dk    rt          | j        dz             |                                  d{V  d}|                     |ddd          \  }}|r!|                     d|||||d           d{V S |                     |          }d|                     | j        ||          i}|||d	<   |d
         rdnd}	|d         ||	<   |d         r|                     |dd          |d<   |||d<   |                     |dd          }
| 	                    |d|
          }| 
                    |g d          }|r||d<   n:|r8|d}|                     |          }|                     |||z  dz            |d<   d}|d         r0|                     |                     ||                     d{V }n/|                     |                     ||                     d{V }|                     ||||          S )a  
        Retrieves the open interest history of a currency
        :see: https://binance-docs.github.io/apidocs/delivery/en/#open-interest-statistics
        :see: https://binance-docs.github.io/apidocs/futures/en/#open-interest-statistics
        :param str symbol: Unified CCXT market symbol
        :param str timeframe: "5m","15m","30m","1h","2h","4h","6h","12h", or "1d"
        :param int [since]: the time(ms) of the earliest record to retrieve unix timestamp
        :param int [limit]: default 30, max 500
        :param dict [params]: exchange specific parameters
        :param int [params.until]: the time(ms) of the latest record to retrieve unix timestamp
        :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: an array of `open interest structure <https://docs.ccxt.com/#/?id=open-interest-structure>`
        r   z4fetchOpenInterestHistory cannot use the 1m timeframeNFr   r  r(  rk  r  r  r  r  r`  r  r  CURRENT_QUARTERr  r  r  r  )r  r  r  r  r)  )r(   r`  r|  r  r  r  r  rg  r>  r  r  r  r  dapiDataGetOpenInterestHistr  fapiDataGetOpenInterestHistparse_open_interests)rq  r  r  r  r  r  r  r  r  	symbolKeyr  r  r  r  s                 rs  fetch_open_interest_historyz#binance.fetch_open_interest_history;*  s      TW']]^^^!!!!!!!!!88A[]ginoo& 	K@@A[]cejlqs|  E  GJ  K  K  K  K  K  K  K  K  KV$$d&&t	9MM
 $GG &x 0<HHf	#D\	) 	b&*&6&6v~O`&a&aGN##(GK ##FGV<<##FIu==6#?#?#?@@ 	J!(GI 	J}++I66H!%%E1AD1H!I!IGI) 	\!==dkk'SY>Z>Z[[[[[[[[HH!==dkk'SY>Z>Z[[[[[[[[H ((65%HHHrt  c                   K   |                                   d{V  |                     |          }i }|d         r*|d         |d<   |                     |d                   |d<   n|d         |d<   d}|d         r0|                     |                     ||                     d{V }ng|d	         r0|                     |                     ||                     d{V }n/|                     |                     ||                     d{V }|d         rO|                     ||          }t          d
t          |                    D ]}||         }|d         |k    r|c S n| 
                    ||          S dS )a  
        retrieves the open interest of a contract trading pair
        :see: https://binance-docs.github.io/apidocs/futures/en/#open-interest
        :see: https://binance-docs.github.io/apidocs/delivery/en/#open-interest
        :see: https://binance-docs.github.io/apidocs/voptions/en/#open-interest
        :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:
        NrH   r  underlyingAssetr  
expirationr`  r  r  r   )r|  r  r@  eapiPublicGetOpenInterestr  dapiPublicGetOpenInterestfapiPublicGetOpenInterestr  r  r  parse_open_interest)	rq  r  r  r  r  r  r  r  r  s	            rs  fetch_open_interestzbinance.fetch_open_interestx*  s      !!!!!!!!!V$$( 	-)/)9G%&$(KKx0@$A$AGL!! &tGH( 	Z!;;DKKQW<X<XYYYYYYYYHHI 	Z!;;DKKQW<X<XYYYYYYYYHH!;;DKKQW<X<XYYYYYYYYH> ( 	>..x@@F1c&kk**    ay>V++KKK , 
 ++Hf===trt  c                 \   |                      |dd          }|                     |d          }|                     |dd          }|                     |dd          }|                     |                     ||d d          |d	         rd n||||||                     |          |d
|          S )Nr  r$  r  sumOpenInterestr;  sumOpenInterestValuesumOpenInterestUsdr  r  )r  r  r  openInterestAmountopenInterestValuer  r  r  )r>  r  rA  safe_open_interestrm  rC  )rq  rO  r  r  r`  r  values          rs  r  zbinance.parse_open_interest*  s    ''+vFF	h11##H.?PP""8-CEYZZ &&&&r64DD"("3?$$ "(!&"Y//	(
 	(
 	 	 		rt  c           	      j  K   |                                   d{V  d}|                     |dd          \  }}|r!|                     d||||dd           d{V S d}||                     |          }d}|                     d||          \  }}d}|                     d||d          \  }}d}	|                     |ddd	d          \  }	}i }
|d
k    rd|
d<   ||d
         rdnd}|	s|d         |
|<   |||
d<   ||d
k    r||
d<   n||
d<   |                     d|
|          \  }
}d}|d
k    rc|	r1|                     | 	                    |
|                     d{V }n#| 
                    | 	                    |
|                     d{V }n|dk    rb|	r0|                     | 	                    |
|                     d{V }n|                     | 	                    |
|                     d{V }n|dk    rb|	r0|                     | 	                    |
|                     d{V }nS|                     | 	                    |
|                     d{V }n#t          | j        dz   |d         z   dz             |                     |d|          }|                     ||||          S )ap  
        retrieves the users liquidated positions
        :see: https://binance-docs.github.io/apidocs/spot/en/#get-force-liquidation-record-user_data
        :see: https://binance-docs.github.io/apidocs/futures/en/#user-39-s-force-orders-user_data
        :see: https://binance-docs.github.io/apidocs/delivery/en/#user-39-s-force-orders-user_data
        :see: https://binance-docs.github.io/apidocs/pm/en/#query-user-39-s-margin-force-orders-user_data
        :see: https://binance-docs.github.io/apidocs/pm/en/#query-user-39-s-um-force-orders-user_data
        :see: https://binance-docs.github.io/apidocs/pm/en/#query-user-39-s-cm-force-orders-user_data
        :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 binance api endpoint
        :param int [params.until]: timestamp in ms of the latest liquidation
        :param boolean [params.paginate]: *spot only* 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)
        :param boolean [params.portfolioMargin]: set to True if you would like to fetch liquidations in a portfolio margin account
        :param str [params.type]: "spot"
        :param str [params.subType]: "linear" or "inverse"
        :returns dict: an array of `liquidation structures <https://docs.ccxt.com/#/?id=liquidation-structure>`
        NFr   r  currentr'  r  r   r^  rD   LIQUIDATIONautoCloseTyper  r  r`  r  r  r  r  r  z( fetchMyLiquidations() does not support ru  r  rb  )r|  r   fetch_paginated_call_incrementalr  r  r  r}  r  papiGetMarginForceOrdersr   sapiGetMarginForceLiquidationRecpapiGetUmForceOrdersfapiPrivateGetForceOrderspapiGetCmForceOrdersdapiPrivateGetForceOrdersr2   r`  r  parse_liquidations)rq  r  r  r  r  r  r  ru  rv  rq  r  r  r  liquidationss                 rs  fetch_my_liquidationszbinance.fetch_my_liquidations*  s     ( !!!!!!!!!88AVXbcc& 	D>>?TV\^cejlrt}  @C  D  D  D  D  D  D  D  D  D[[((F99:OQWY_``f99:OQWY_aijj $($C$CFLacik|  D  %E  %E!66>>'4GO$,26NH((I$ 2%+D\	"#(GK v~~"'#( 229gvNN6>>  e!%!>!>t{{7TZ?[?[!\!\\\\\\\!%!F!Ft{{SZ\bGcGc!d!ddddddd    ^!%!:!:4;;wPV;W;W!X!XXXXXXX!%!?!?GU[@\@\!]!]]]]]]]	!!  ^!%!:!:4;;wPV;W;W!X!XXXXXXX!%!?!?GU[@\@\!]!]]]]]]]tw)SSV\]cVddgqqrrr\ ~~hAA&&|VUEJJJrt  c                    |                      |d          }|                     |dd          }|                     ||                     ||          |                     |d          |                     |d          |                     |d          |                     |d          |                     |d          ||                     |          d		          S )
Nr  updatedTimerb  r  r  rv  r  r  )	r  r  r=  r  r  	baseValue
quoteValuer  r  )r  r>  safe_liquidationrm  r  rC  )rq  liquidationr  r  r  s        rs  parse_liquidationzbinance.parse_liquidation^+  s    J ##K::'']LQQ	$$&&x88))+}EE ,,V^DD%%k:>>))+yAA**;
CC"Y//
&
 
&
 
 
 
	rt  c                   K   |                                   d{V  |                     |          }d|d         i}|                     |                     ||                     d{V }|                     |d         |          S )a  
        fetches an option contracts greeks, financial metrics used to measure the factors that affect the price of an options contract
        :see: https://binance-docs.github.io/apidocs/voptions/en/#option-mark-price
        :param str symbol: unified symbol of the market to fetch greeks for
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: a `greeks structure <https://docs.ccxt.com/#/?id=greeks-structure>`
        Nr  r`  r   )r|  r  eapiPublicGetMarkr  parse_greeksr  s         rs  fetch_greekszbinance.fetch_greeks+  s       !!!!!!!!!V$$fTl
 //GV0L0LMMMMMMMM$   !f555rt  c                    |                      |d          }|                     ||          }i d|dd dd d|                     |d          d|                     |d          d|                     |d          d|                     |d          dd d	d d
d d|                     |d          d|                     |d          d|                     |d          dd dd d|                     |d          dd d |dS )Nr  r  r  deltagammathetavegarhobidSizeaskSizebidImpliedVolatilitybidIVaskImpliedVolatilityaskIVmarkImpliedVolatilitymarkIVr  r  r  r  )underlyingPricer  )r  rm  r  )rq  greeksr  r  r  s        rs  r  zbinance.parse_greeks+  s     ##FH55!!(F33
f

 
 T%%fg66	

 T%%fg66
 T%%fg66
 D$$VV44
 4
 t
 t
 #D$4$4VW$E$E
 #D$4$4VW$E$E
 $T%5%5fh%G%G
 
 
  ))&+>>!
" #
$  $'
 
 
 	
rt  c                    K   |                                   d {V }i }t          dt          |                    D ];}||         }|d         }||                     ||          r|d         d         ||<   <|S )Nr   r  r  r  )r  r  r  r]  )rq  r  r  r  tradingLimitsr  r  r  s           rs  fetch_trading_limitszbinance.fetch_trading_limits+  s      **,,,,,,,,q#g,,'' 	C 	CAQZFH%FT]]67%C%C(.x(8(Bf%rt  c                 `  K   d}||                      |          }d}|                     d||          \  }}d}|dk    r|                     |           d{V }n9|dk    r|                     |           d{V }nt	          | j        dz             |                     |d          }||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
        :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
        :param str [params.subType]: "linear" or "inverse"
        :returns dict: an object detailing whether the market is in hedged or one-way mode
        Nr   r  r  zI fetchPositionMode requires either a symbol argument or params["subType"]r  )r  rA  )r  r  fapiPrivateGetPositionSideDualdapiPrivateGetPositionSideDualr(   r`  r  )rq  r  r  r  rv  r  r  s          rs  fetch_position_modezbinance.fetch_position_mode,  s       [[((F99:MvW]^^h!@@HHHHHHHHHH	!!!@@HHHHHHHHHHTW'rrsss  >>(4FGG&
 
 	
rt  c                   K   |                                   d{V  d}|0|                     |          }|                     |d                   }d}|                     d||          \  }}d}|dk    r|                     |           d{V }n9|dk    r|                     |           d{V }nt          | j        dz             |                     |dg           }| 	                    ||dd	          S )
aY  
        fetches margin modes("isolated" or "cross") that the market for the symbol in in, with symbol=None all markets for a subType(linear/inverse) are returned
        :see: https://binance-docs.github.io/apidocs/futures/en/#account-information-v2-user_data
        :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.subType]: "linear" or "inverse"
        :returns dict: a list of `margin mode structures <https://docs.ccxt.com/#/?id=margin-mode-structure>`
        Nr   r   r  r  z= fetchMarginModes() supports linear and inverse subTypes onlyr"  r  rF   )
r|  r  r  r  r  r  r(   r`  r  parse_margin_modes)rq  r  r  r  rv  r  re  s          rs  fetch_margin_modeszbinance.fetch_margin_modes$,  s5      !!!!!!!!!))'22G[[,,F99:KVU[\\h!99&AAAAAAAAHHB 	!!!77????????HHd TW'ffggg+r::&&vw&IIIrt  c                     |                      |d          }|                     ||          }|                     |d          }||d         |rdnddS )Nr  rU  r  )r  r  rp  )r  r  r  )rq  rp  r  r  r	  s        rs  parse_margin_modezbinance.parse_margin_mode,  se    ##J99!!(F33^^J
;;
X&(2?**
 
 	
rt  c                 2  K   |                                   d{V  |                     |          }d|d         i}|                     |                     ||                     d{V }|                     |di           }|                     |d|          S )a  
        fetches option data that is commonly found in an option chain
        :see: https://binance-docs.github.io/apidocs/voptions/en/#24hr-ticker-price-change-statistics
        :param str symbol: unified market symbol
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: an `option chain structure <https://docs.ccxt.com/#/?id=option-chain-structure>`
        Nr  r`  r   )r|  r  r  r  r  parse_option)rq  r  r  r  r  r  chains          rs  fetch_optionzbinance.fetch_option,  s       !!!!!!!!!V$$fTl
 11$++gv2N2NOOOOOOOO2 xB//  f555rt  c                    |                      |d          }|                     ||          }i d|dd d|d         dd dd dd dd d|                     |d          d	|                     |d	          d
d dd d|                     |d          d|                     |d          d|                     |d          d|                     |d          d|                     |d          dd S )Nr  r  r  r  r  impliedVolatilityr;  r  r  midPricer  r  r  r  r  r  r  r  r  r  r  )r  r  r  )rq  r  r  r  r  s        rs  r  zbinance.parse_option,  sv   . ##E844!!(F33
E

 fX&
 	

 
  
 D
 ((
;;
 ((
;;
 
 
 ))%==
 t//GG
 d&&um<<
 $**52FGG
  $**5(;;!
" 4#
 	
rt  c                   K   |                                   d{V  |t          | j        dz             |                     |          }|                     |d          }|                     |d          }d|d         i}||dk    rdnd|d	<   |||d
<   |||d<   |||d<   d}	|d         r0|                     |                     ||                     d{V }	nX|d         r0|                     |                     ||                     d{V }	n t          | j        dz   |d	         z             | 
                    |	          }
|                     |
|||          S )a2  
        fetches the history of margin added or reduced from contract isolated positions
        :see: https://binance-docs.github.io/apidocs/futures/en/#get-position-margin-change-history-trade
        :see: https://binance-docs.github.io/apidocs/delivery/en/#get-position-margin-change-history-trade
        :param str symbol: unified market symbol
        :param str [type]: "add" or "reduce"
        :param int [since]: timestamp in ms of the earliest change to fetch
        :param int [limit]: the maximum amount of changes to fetch
        :param dict params: extra parameters specific to the exchange api endpoint
        :param int [params.until]: timestamp in ms of the latest change to fetch
        :returns dict[]: a list of `margin structures <https://docs.ccxt.com/#/?id=margin-loan-structure>`
        Nz: fetchMarginAdjustmentHistory() requires a symbol argumentr  r  r`  rR  r   r  ru  r  r  r  r  r  zDfetchMarginAdjustmentHistory() is not supported for markets of type )r|  r'   r`  r  r  r  #fapiPrivateGetPositionMarginHistoryr  #dapiPrivateGetPositionMarginHistoryr(   parse_margin_modificationsr
  )rq  r  ru  r  r  r  r  r  r  r  modificationss              rs  fetch_margin_adjustment_historyz'binance.fetch_margin_adjustment_history-  s      !!!!!!!!!>#DG.j$jkkkV$$!!&'2267++fTl
 $(EMMaaGFO#(GK $GG!&GI( 	@!EEdkkRY[aFbFbccccccccHHI 	@!EEdkkRY[aFbFbccccccccHHTW'mmpvw}p~~  77AA00uUUUrt  c                   K   |                                   d{V  |                     |           d{V }i }t          dt          |                    D ]i}||         }|                     |d          }|                     |          }|||ddddddd|                     |d          dddddddddddd||<   j|S )aM  
        fetches all available currencies that can be converted
        :see: https://binance-docs.github.io/apidocs/spot/en/#query-order-quantity-precision-per-asset-user_data
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: an associative dictionary of currencies
        Nr   rV  fractionr  )r  r   r  )r  r`  r  r@  ru  ra  r  r  r   r  r  r  r0  )r|  sapiGetConvertAssetInfor  r  r  r  r  )rq  r  r  r  r  r  r`  r  s           rs  fetch_convert_currenciesz binance.fetch_convert_currenciesE-  s7      !!!!!!!!!55f======== q#h--(( 	 	AQKE!!%11B**2..D  !..ujAA  $# 
  $#! !
  $#      5 F4LL8 rt  fromCodetoCodec                 (  K   |                                   d{V  ||||d}|                     |                     ||                     d{V }|                     |          }|                     |          }	|                     |||	          S )aw  
        convert from one currency to another
        :see: https://binance-docs.github.io/apidocs/spot/en/#busd-convert-trade
        :param str id: the id of the trade that you want to make
        :param str fromCode: the currency that you want to sell and convert from
        :param str toCode: the currency that you want to buy and convert into
        :param float [amount]: how much you want to trade in units of the from currency
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: a `conversion structure <https://docs.ccxt.com/#/?id=conversion-structure>`
        N)clientTranIdrV  targetAssetr  )r|  sapiPostAssetConvertTransferr  r  parse_conversion)
rq  r`  r  r  r  r  r  r  fromCurrency
toCurrencys
             rs  create_convert_tradezbinance.create_convert_tradey-  s       !!!!!!!!!!	
 
 ::4;;wPV;W;WXXXXXXXX }}X..]]6**
$$X|ZHHHrt  r  r  c                     |                      d |          }|                      d |          }|d d |                     |d          |d |d d d d
S )Nr  )
r  r  r  r`  r  
fromAmountr  toAmountr  r  )r  r  )rq  r  r  r  r  r  s         rs  r  zbinance.parse_conversion-  sk     **4>>((z::"":x88$ 
 
 	
rt  )N)NNNN)NNF)F)NN)__name__
__module____qualname__ro  r  r   boolr{  r}  r  r  r   r  r   r  r  r  r  r  r   r  r"   r  r
  rS  r   rx  r  r
   r   r  r   r  r  r  r   r  r  r  r   r  ro  r  r  r   r(  r3  r   r   floatr   r<  r7  rq  rs  r  r   r9  r   r  r  r  r  r  r  r  r  r  r  r$  r'  r-  r9  rE  rK  rN  rM  rd  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  r  r,  r(  rl  ry  r|  r  r  r  r  r  r  r  r  r  r  r  r   r  r   r  r  r  r  r  r  r  r  r  r+  r2  rD  rH  r  rP  r   rN  rY  r\  r`  re  rd  r_  rq  rt  rw  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   r  r  __classcell__)rr  s   @rs  r=   r=   (   s       U% U% U% U% U%nJ( (s (S (D ( ( ( (' 'c 'C '4 ' ' ' '-t - - - - - -;
3 ;
 ;
 ;
 ;
z-LS -L_ -L -L -L -L^Y YC Y YRU Yjm Y  zI Y Y Y Y Y YK K K. . . .D D D ') 9 9 9 90 -/ { {: { { { {z *, t tV t t t tlYf Y Y Y Yv  `A `Aem `A `A `A `AD *, RX RX RX RX RX RXh @DB C CS C CS\ C C C CJO O6 OV O O O Ob )+ 
 
 
 
. 68 #3 #3 #3F #3 #3 #3 #3J 8<B 5 5W 5 5 5 5@ :>b 89 89w 89 89 89 89t'
 '
f '
 '
 '
 '
R 6:" !5 !57 !5 !5 !5 !5 !5F=
 =
 =
4 =
 =
 =
 =
~ 8<$]ajl jL jL jLC jLWZ jLquvzq{ jL jL jL jLX  5    B <@d[] CA CA CAS CA CAbfglbm CA CA CA CAJ y}  FH =. =. =.S =.	 =.QZ =.di =.ru =. =. =. =.~ {  HJ g, g,# g,s g,) g,S\ g,fk g,tw g, g, g, g,R }A  JL >2 >2C >2 >2I >2U^ >2hm >2vy >2 >2 >2 >2@ fjx|  FH a a3 a a9 aI a_b aru a a a a0: : :k k k5 k k k kZ FH F+ F+$|*< F+ F+ F+ F+P mqy{ X2 X2 X2I X2Y X2X] X2fi X2 X2 X2 X2t os{} O3 O33 O3i O3y O3Z_ O3hk O3 O3 O3 O3b 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  8<B >2 >2C >2 >2 >2 >2 >2@ 04$UYbd @A @A @AC @As @Aimnsit @A @A @A @AD 59tZ^gi WA WAc WA WATW WAnrsxny WA WA WA WAr =A G2 G2 G2c G2 G2 G2 G2R 7;\`ik H H H3 HVY Hptuzp{ H H H H8 9=4^bkm H H# HS HX[ H H H H4 DHVZimvx F FS FPS Fcf F  ~B  CH  ~I F F F F: 9=R M2 M2S M2# M2 M2 M2 M2^ 59 A Ac A A A AF AER @3 @3tCy @3# @3 @3 @3 @3D ?CQUdhqs ^ ^3 ^ ^3 ^^a ^ ^ ^ ^6 37TX\eg RA RAC RAs RARU RA RA RA RAh 8<$]ajl A@ A@ A@C A@WZ A@ A@ A@ A@FA
 A
f A
 A
 A
 A
F 04$UYbd cI cI cIC cIs cIimnyiz cI cI cI cIJ 37TX\eg yI yIC yIs yIRU yIlpq|l} yI yI yI yIv": ": ": ":Hx
 x
x x
; x
 x
 x
 x
t: : :-
 -
 -
 -
 -
 -
^
 
6 
 
 
 
4 ac S7 S73 S7 S7C S7TW S7gt S7 S7 S7 S7j 154VZce @B @B# @BS @BPS @B @B @B @BD =? A
 A
 A
 A
 A
 A
F ?C2 m
 m
$s) m
 m
 m
 m
^ BFb 4I 4Iw 4I 4I 4I 4Il@ @ @ @ @ @D EIQS !: !:3 !: !: !: !: !:F
 
V 
?R 
 
 
 
: ;= =4 =4c =4AT =4 =4 =4 =4~ /1 d d[ d d d dL FH 7 73 7 7 7 7: <> #9 #9s #9 #9 #9 #9J >BPTcgpr AO AOs AO# AO]` AO AO AO AOF <@ ? ? ? ? ? ?>)
 )
6 )
 )
 )
 )
V   B`
 `
v `
 `
 `
 `
DA
 A
F A
 A
 A
 A
F 38 '0 '0 '0 '0R =A GF GF' GF GF GF GFR% % % % % %N 8: '8 '83 '8 '8 '8 '8R ?C2 2P 2PG 2P 2P 2P 2Ph6 6v 6 6 6 6p 8<B { {W { { { {2 @DB ,P ,PW ,P ,P ,P ,P\ =A OP OP' OP OP OP OPb 9=4^bkm 3B 3B# 3BS 3BX[ 3B 3B 3B 3Bj ?C2 ( (3 ( ( ( ( (T DHPR 4 4 4S 4 4 4 4l CGr 0 0d 0C 0 0 0 0d :>b "B "BT#Y "BY "B "B "B "BH
 
x 
 
 
 
2 <@daenp &O &OS &O &O[^ &O &O &O &OP ?CQUdhqs .Y .Y .Y3 .Y^a .Y .Y .Y .Y`'
 '
 '
R& & &P =A 
U 
U3 
Uc 
U 
U 
U 
U .2SW`b VC VCs VC# VCS VC VC VC VCp3
 3
 3
 3
 3
 3
j8 8 80 &eBSW ZP ZP ZP ZPx  $D D DL MO 2 2 2 2  '/uRQU\`ik     SU " " " " " "H*
 *
f *
HZ *
 *
 *
 *
X ?A 
J 
J# 
JEW 
J 
J 
J 
J <> 
J 
Js 
JBT 
J 
J 
J 
J ?A , ,# , , , ,8 GKY]fh %L %LC %L %LSV %L %L %L %LNO O O
 
 
 
 
 
( @B "
 "
3 "
 "
 "
 "
H ;=    2 68      , 7;$]apt} HQ HQ HQC HQWZ HQjm HQ HQ HQ HQT
 
& 
 
 
 
" BD  :  :S  :  :  :  :D RT : :# :S : : : :: JL  :  :c  :5  :  :  :  :D Z\ : :3 :c :5 : : : ::
 
 
 
 
 
" HLZ^mqz| ;I ;I ;ITW ;Igj ;I ;I ;I ;Iz =? ? ? ? ? ? ?B F    $ 9=4^bkm QK QK# QKS QKX[ QK QK QK QKfQ QV Q Q Q Qf 68 6 6 6F 6 6 6 6B&
 &
6 &
 &
 &
 &
P =A 	 	' 	 	 	 	 7;2 
 
 
 
 
 
> =A HJ HJS	 HJP[ HJ HJ HJ HJT
 
J 
 
 
 
 68 '6 '6 '6F '6 '6 '6 '6R+
 +
H +
V +
 +
 +
 +
Z CGTXgkz~  HJ 5V 5VC 5Vc 5Vad 5Vtw 5V  OS  Tf  Og 5V 5V 5V 5Vn 57 2 2: 2 2 2 2h ]aik I IS IC I IVY Ipz I I I I:
 
 
V^ 
jt 
 
 
 
 
 
 
 
rt  r=   )D ccxt.async_support.base.exchanger   ccxt.abstract.binancer   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    r!   typingr"   ccxt.base.errorsr#   r$   r%   r&   r'   r(   r)   r*   r+   r,   r-   r.   r/   r0   r1   r2   r3   r4   r5   r6   r7   r8   ccxt.base.decimal_to_precisionr9   r:   ccxt.base.preciser;   r=   ry  rt  rs  <module>r     s   6 5 5 5 5 5 - - - - - -    V  V  V  V  V  V  V  V  V  V  V  V  V  V  V  V  V  V  V  V  V  V  V  V  V  V  V  V  V  V  V  V  V  V  V  V  V  V  V  V  V  V  V  V  V  V  V  V  V  V  V  V  V  V  V  V  V  V  V  V  V  V       * * * * * * 0 0 0 0 0 0 - - - - - - - - - - - - . . . . . . ' ' ' ' ' ' & & & & & & . . . . . . 1 1 1 1 1 1 ( ( ( ( ( ( . . . . . . ) ) ) ) ) ) * * * * * * 5 5 5 5 5 5 - - - - - - ) ) ) ) ) ) , , , , , , + + + + + + . . . . . . * * * * * * ) ) ) ) ) ) + + + + + + 3 3 3 3 3 3 9 9 9 9 9 9 % % % % % %Dv
 Dv
 Dv
 Dv
 Dv
h Dv
 Dv
 Dv
 Dv
 Dv
rt  