
    E#i
                    @   S SK Jr  S SKJr  S SKrS SKrS SKrS SKJrJ	r	J
r
JrJrJrJrJrJrJrJrJrJrJrJrJrJrJrJrJrJrJrJrJrJ r J!r!J"r"J#r#J$r$J%r%J&r&J'r'J(r(J)r)J*r*J+r+J,r,J-r-J.r.J/r/J0r0J1r1  S SK2J3r3  S SK4J5r5  S SK4J6r6  S SK4J7r7  S S	K4J8r8  S S
K4J9r9  S SK4J:r:  S SK4J;r;  S SK4J<r<  S SK4J=r=  S SK4J>r>  S SK4J?r?  S SK4J@r@  S SK4JArA  S SK4JBrB  S SK4JCrC  S SK4JDrD  S SK4JErE  S SK4JFrF  S SK4JGrG  S SK4JHrH  S SK4JIrI  S SK4JJrJ  S SK4JKrK  S SKLJMrM  S SKLJNrN  S SKOJPrP   " S  S!\\5      rQg)"    )Exchange)ImplicitAPIN)*AnyBalancesBorrowInterest
ConversionCrossBorrowRate
CurrenciesCurrencyDepositAddressGreeksIntIsolatedBorrowRateIsolatedBorrowRatesLedgerEntryLeverage	LeveragesLeverageTierLeverageTiersLongShortRatio
MarginModeMarginModesMarginModificationMarketNumOptionOrder	OrderBookOrderRequest	OrderSide	OrderTypePositionStrStringsTickerTickersFundingRateFundingRatesTradeTradingFeeInterfaceTradingFeesTransactionMarketInterfaceTransferEntry)List)ExchangeError)AuthenticationError)PermissionDenied)AccountSuspended)ArgumentsRequired)
BadRequest)	BadSymbol)OperationRejected)MarginModeAlreadySet)MarketClosed)InsufficientFunds)InvalidOrder)OrderNotFound)OrderImmediatelyFillable)OrderNotFillable)NotSupported)OperationFailed)DDoSProtection)RateLimitExceeded)OnMaintenance)InvalidNonce)RequestTimeout)BadResponse)TRUNCATE)	TICK_SIZE)Precisec                     ^  \ rS rSrS\4U 4S jjrSS\S\S\4S jjr	SS\S\S\4S jjr
S	\4U 4S
 jjrS\4S jrS\S\4S jrSS\S\S\S\S\4
U 4S jjjrS rS rS	\4S jr0 4S\4S jjr0 4S\4S jjr0 4S\\   4S jjrS\S\4S jrS rSS\4S jjr0 4S\4S jjrS0 4S\S\S\ 4S jjr!SS \S\S\"4S! jjr#0 4S" jr$0 4S\S\"4S# jjr%S0 4S$\&4S% jjr'S0 4S$\&4S& jjr(SS\4S' jjr)S0 4S$\&S\*4S( jjr+S) r,0 4S\S\"4S* jjr-S0 4S$\&S\*4S+ jjr.SS\S\/4S, jjr0S-SS0 4S\S.\S/\S\S\\/   4
S0 jjr1SS1\S\S\24S2 jjr3SS0 4S\S/\S\S\\2   4S3 jjr4S0 4S4\S\S\5S5\6S6\7S7\84S8 jjr9S0 4S4\S\S\5S5\6S6\7S7\84S9 jjr:S0 4S4\S\S\5S5\6S6\7S7\84S: jjr;S0 4S4\S\S\5S5\6S6\7S7\84S; jjr<SS0 4S4\S\S\5S5\6S6\8S7\84S< jjr=0 4S=\\>   4S> jjr?S?\4S@ jr@SSA\S\S\A4SB jjrB0 4S=\\>   4SC jjrCS0 4S\S\5S5\6S6\7S7\84
SD jjrDS0 4S\S\5S5\6S6\7S7\84
SE jjrE0 4S\S5\6SF\74SG jjrF0 4S\SF\74SH jjrG0 4S\SF\74SI jjrHS0 4S4\S\4SJ jjrISSS0 4S\S/\S\S\\A   4SK jjrJSSS0 4S\S/\S\S\\A   4SL jjrKS0 4S4\S\4SM jjrLSSS0 4S\S/\S\S\\A   4SN jjrMSSS0 4S\S/\S\4SO jjrNSSS0 4S\S/\S\S\\A   4SP jjrOS0 4S4\S\4SQ jjrPS0 4S\4SR jjrQS0 4SS\\   S\4ST jjrRSSS0 4S4\S\S/\S\4SU jjrSSSS0 4S\S/\S\4SV jjrTSSS0 4S\S/\S\4SW jjrUSS\4SX jjrVSSS0 4SY\S/\S\S\\W   4SZ jjrXSSS0 4SY\S/\S\S\\W   4S[ jjrYSS\ jrZSS]\S^\[S\W4S_ jjr\S?\S\4S` jr]SSa\S^\[S\^4Sb jjr_SS\4Sc jjr`0 4SY\S6\7Sd\Se\S\^4
Sf jjraSSS0 4SY\S/\S\S\\^   4Sg jjrb0 4SY\S\c4Sh jjrdSS^\[S\c4Si jjreS0 4Sj\&4Sk jjrfS0 4Sj\&4Sl jjrgSS^\[4Sm jjrhS0 4SY\S6\7Sn\So\S\W4
Sp jjriSSq\S\S\j4Sr jjrk0 4S\S\j4Ss jjrl0 4S\m4St jjrn0 4SY\4Su jjro0 4S\S\p4Sv jjrqSSS0 4S\S/\S\4Sw jjrrSS\4Sx jjrsS0 4S$\&S\t4Sy jjruSS\S\p4Sz jjrvSS{ jrwSS\4S| jjrxSS\4S} jjryS0 4S~ jrzS0 4S$\&S\{4S jjr|SS\S\\}   4S jjr~0 4S\4S jjrS0 4S$\&4S jjrSS\S\4S jjrS0 4S$\&S\\   4S jjrS0 4S$\&4S jjrS0 4S$\&4S jjrSSS0 4S\S/\S\4S jjrS0 4S\S\4S jjrS0 4S\S\4S jjrS0 4S\S\4S jjrS0 4S$\&S\4S jjrSS\S\S\4S jjrSSS0 4S\S/\S\4S jjrSSS0 4S\S/\S\4S jjrS rS rS0 4S4\SY\S\4S jjrSSS0 4SY\S/\S\S\\   4S jjrSS\S^\[S\4S jjrS rSS\S\S\4S jjrS\S\4S jrSS0 SS4S jrS\S\4S jrSY\S\S\S\S\S\4S jr0 4S jrSS0 SS0 4S jr0 4S\4S jjrSS\S\S\4S jjr0 4S\S6\7S\4S jjr0 4S\S6\7S\4S jjr0 4SY\S\4S jjr0 4S\S\4S jjr0 4S\4S jjrSS0 4SY\S/\S\4S jjrSS^\[4S jjrSS\S\S\4S jjr0 4SY\4S jjr0 4S jr0 4S4\4S jjrSSSS0 4SY\S\S/\S\S\\   4
S jjrSS\S\S\4S jjr0 4SY\4S jjr0 4S\SY\4S jjr0 4SY\S6\74S jjr0 4S\SY\S6\74S jjrSS^\[4S jjrSSS0 4S\S/\S\4S jjr0 4S\4S jjrSS\4S jjrSSS0 4S\S/\S\4S jjrSS\4S jjr0 4S\S\4S jjrS0 4S$\&S\\   4S jjrSS\S\S\4S jjrS0 4S$\&4S jjrS0 4S\4S jjrS0 4S$\&S\4S jjr0 4S\S\4S jjrSS\S\4S jjr0 4S\S\4S jjrSS\S^\[S\S\4S jjrSSSS0 4S\S\S/\8S\8S\\   4
S jjr0 4S\4S jjrS0 4S\S\S6\8S\4S jjrS0 4S4\S\S\S6\8S\4
S jjrS0 4S4\SY\S\4S jjrSSS0 4SY\S/\S\S\\   4S jjrSS\S\[S\[S\4S jjrS0 4S$\&S\t4S jjrSSSS0 4S\S.\S/\S\S\\   4
S jjrSS\S\S\4S jjrSrU =r$ )binance)   returnc                 i  > U R                  [        [        U ]  5       0 SS_SS_S/ _SS_SS	_S
S	_S0 SS _SS	_SS	_SS	_SS	_SS	_SS	_SS	_SS	_SS	_SS	_SS	_SS_SS_SS	_SS_SS	_0 SS	_SS	_S S	_S!S	_S"S	_S#S	_S$S	_S%S	_S&S_S'S	_S(S	_S)S	_S*S	_S+S_S,S	_S-S	_S.S	_E0 S/S	_S0S	_S1S	_S2S _S3S	_S4S	_S5S	_S6S	_S7S_S8S	_S9S:_S;S:_S<S_S=S:_S>S	_S?S	_S@S	_E0 SAS	_SBS	_SCS_SDS	_SES_SFS	_SGS_SHS_SIS	_SJS_SKS:_SLS	_SMS	_SNS:_SOS	_SPS	_SQS	_E0 SRS	_SSS	_STS	_SUS:_SVS	_SWS_SXS	_SYS	_SZS	_S[S:_S\S	_S]S	_S^S_S_S_S`S	_SaS	_SbS	_E0 ScS	_SdS:_SeS	_SfS	_SgS	_ShS	_SiS	_SjS	_SkS	_SlS	_SmS	_SnS	_SoS	_SpS	_SqS	_SrS_SsS	_E0 StS	_SuS_SvS	_SwS	_SxS	_SyS_SzS	_S{S	_S|S_S}S	_S~S	_SS	_SS	_SS	_SS	_SS	_SS	_E0 SS	_SS	_SS:_SS:_SS	_SS_SS_SS	_SS_SS_SS_SS_SS	_SS_SS	_SS	_SS	_ES	S	SS	S	SS	S	S.E_S0 SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS__SSSSSSSSSSSSSSS.SSSSSSSSSSSSS.0 SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SSSSSS.ESSSS.S/SSS.	_S0 S0 SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_0 SS_SS_SS_SS_GS S_GSS_GSS_GSS_GSS_GSS_GSS_GSS_GSGS	_GS
S_GSGS_GSGS_GSS_E0 GSS_GSS_GSS_GSS_GSS_GSS_GSS_GSGS	_GSS_GSSGSGS._GSSSGS._GSS_GSS_GSS_GSGS _GS!S_GS"GS#_E0 GS$GS#_GS%GS#_GS&S_GS'S_GS(GS)_GS*S_GS+GS,_GS-GS,_GS.GS/_GS0GS/_GS1GS2_GS3GS,_GS4GS,_GS5GS,_GS6GS,_GS7GS,_GS8GS,_E0 GS9GS:_GS;GS<_GS=GS,_GS>GS,_GS?GS,_GS@GS,_GSAGS,_GSBGS:_GSCGSD_GSES_GSFS_GSGS_GSHGSI_GSJS_GSKS_GSLS_GSMS_E0 GSNS_GSOS_GSPS_GSQS_GSRS_GSSGS _GSTS_GSUS_GSVGS#_GSWGS _GSXS_GSYS_GSZS_GS[S_GS\S_GS]S_GS^S_E0 GS_S_GS`S_GSaS_GSbS_GScS_GSdS_GSeS_GSfS_GSgS_GShS_GSiGSj_GSkGS _GSlS_GSmS_GSnS_GSoGSj_GSpGSj_E0 GSqS_GSrGSj_GSsGSt_GSuGSj_GSvS_GSwS_GSxS_GSyS_GSzS_GS{S_GS|S_GS}S_GS~S_GSS_GSGS_GSGS_GSGS_E0 GSGS_GSGS_GSGS_GSGS_GSGS_GSGS_GSGS_GSGS_GSGS_GSGS_GSGS_GSGS_GSS_GSS_GSGS_GSGS_GSGS_E0 GSGS_GSGS_GSGS_GSS_GSSSGS._GSGS _GSGS_GSGS _GSGS_GSGS_GSGS_GSGS_GSGS_GSS_GSS_GSS_GSS_E0 GSS_GSS_GSS_GSS_GSS_GSS_GSS_GSS_GSS_GSS_GSS_GSS_GSS_GSS_GSS_GSS_GSS_E0 GSS_GSS_GSS_GSS_GSS_GSS_GSS_GSS_GSS_GSGS _GSGS _GSGS _GSGS _GSGS _GSS_GSS_GSS_E0 GSS_GSS_GSS_GSS_GSS_GSS_GSS_GSGS_GSGS_GSGS#_GSS_GSGS_GSGS_GSS_GSS_GSGS_GSGS_E0 GSS_GSS_GSS_GSS_GSS_GSS_GSS_GSS_GSS_GSS_GSS_GSS_GSS_GSS_GSS_GSS_GSGS_E0 GSGS_GSGS_GSGS_GSGS_GSGS_GSGS_GSGS_GSGS_GSGS_GSGS_GSGS_GSGS_GSGS_GSGS_GSGS_GSS_GS S_ESSGS.E0 GSGS_GSS_SGS_GSS_GSS_GSS_GS	S_GS
S_GSRS_GSS_SGS _GSS_GS GS _GSGS _GSGS_GSGS_GSGS _0 GS"GS _GSS_GSGS_GSGS_GS[S_GSS_GSS_GSS_GSS_GSS_GS_S_GSS_GSS_GSgS_GSS_GSS_GSS_E0 GSS_GSS_GSFS_GSS_GSS_GSS_GS GS!_GS"GS!_GSGS!_GS#GS_GS$S_GS%S_GSS_GSS_GSS_GSS_GSS_E0 GS&S_GS'S_GSS_GS(S_GS)S_GSS_GSS_GSS_GSS_GSS_GS*S_GS+S_GS,S_GSS_GS-S_GSS_GS.S_E0 GS/S_GS0S_GS1S_GS2S_GS3GS _GS4GS _GS5GS _GS6S_GS7S_GS8S_GS9GS_GS:GS_GS;GS_GS<GS_GS=GS_GS>GS_GS?GS_E0 GS@GS _GSAGS2_GSBGS2_GSCGS2_GSDGS2_GSEGS2_GSFGS2_GSGGS2_GSHGS2_GSIGS2_GSJGSK_GSLGS_GSMGS_GSNGSK_GSOGS_GSPS_GSQGS_E0 GSGS_GSRGS_GSSGS	_GSTGS	_GSUGS_GSVS_GSWS_GSXS_GSYS_GSZS_GS[S_GS\S_GS]S_GS^S_GS_GS_GS`GS_GSaGS_ESSGSb.ESSGSc.SGStGStGSSSSSSSGS GSd.GSe._SGSSSSGS<GS,GS,GS,GS,GS,SGSf.GSGS GS2GS2GS2GSg.GSh._SGSiGSj0GSjGS0GSh._SGSkGSiGSj00_SGSk0 GSlS_GSmS_GSnS_GSoSSS/GSpGS/GSqS/GSrGS	//GSs._GStGS_GSuGS	_GSvGS	_GSwS_GSxS_GSySGSzS/GS{S/GSrGS/GS|S//GSs._GS}SGSzS/GS{S/GSrGS/GS|S//GSs._GS~SGSzS/GS{S/GSrGS/GS|S//GSs._GSSGSzS/GS{S/GSrGS/GS|S//GSs._GSSGSzS/GS{S/GSrGS/GS|S//GSs._GSSGS,GS._GSSSGS._GSSGSGS._SSSGS.E0_SGSkSSSSSSSGS.0_S0 GSGS<_GSS_GSS_GSS_GSSGSGS._GSGS	GS,GS._GSS_GSGS_GSS_GSS_GSGS	GS,GS._GSGS	_GSS_GSGS	SGS._GSGS_GSGS	_GSGS_GSGSGSGSGSGSGSGS.ESGSGSSSSSSGS.SSGSGS.SSGSSGS.GSe._SGSkGSS00_SGSk0 GSlS_GSmS_GSnS_GSoSSS/GSpGS/GSqS/GSrGS	//GSs._GStGS_GSuGS	_GSvGS	_GSySGSzS/GS{S/GSrGS/GS|S//GSs._GS}SGSzS/GS{S/GSrGS/GS|S//GSs._GSSGSzS/GS{S/GSrGS/GS|S//GSs._GS~SGSzS/GS{S/GSrGS/GS|S//GSs._GSSGSzS/GS{S/GSrGS/GS|S//GSs._GSxS_GSS_GSwS_GSSGS,GS._GSSSGS._SSGS.SSSSGS.SSSGS.SGSSGS.	E0_SGSkSSSSSSSGS.0_S0 GSGS	SGS._GSGS_GSS_GSSGS,GS._GSS_GSGS_GSGS_GSS_GSS_GSGS_GSGS<_GSGS_GSGS<_GSGS	_GSS_GSS_GSGS<_0 GSS_GSS_GSS_GSS_GSS_GSS_GSS_GSS_GSGS_GSGS_GSS_GSGSr_GSS_GSGSr_GSS_GSGSr_GSS_ESGSGSGSSSGSGS.E0 GSGS_GSS_GSS_GSS_GSGS_GSS_GSS_GSS_GSS_GSS_GSS_GSS_GSS_GSJGS_GSLGS	_GSS_SSGSGS.SSSSSSGS.GSe._SGSkGSGS00_SGSkSSSGS.0_SGSk0 0_SGSkSSSGS.0_SGSkSSSSGSGSSSGSGS	GSGSGS.0_S0 GSGS_GSGS_GSSGS,GS._GSGS_GSGS_GSGS_GSS_GSGS_GSGS_GSGS_GSS_GSS_GSS_GSGS_GSGS_GSGS_GSGS_SGSSSSSSGSGSGS.	SGSGS.SSSSSGSGS.GSe._GSGSSGSpS/GSqGS/GSrS/GSS//GSs.SGSSGSGSGSGSGS.GSGSGS.GSGSGSGS.GSGSGS.GSGSGS.GSGS0GSGS0GSGS0GS.GSGSGSGSGSGSGS.GSGSGSGSGSGSGSGS.GSGSGSGSGSGSGSGSGSGS.	GSGSGSGS.GS.0 GSlGS_GSS_GSS_GSSGS,GS._GSGS_GSS_GSS_GSSGS,GS._GSGS	_GSS_GSSGS,GS._GSS_GSSGS,GS._GSS_GSSGS,GS._GSS_GSGS,_0 GSS_GSGS_GSGSp_GSGS_GSGSp_GSGS_GS
GS_GSGS_GSGS_GSS_GSS_GSS_GSGS_GSS_GSS_GSGS_GSGS	_E0 GSGS_GSGS_GSS_GSGS	SGS._GSGS	SGS._GSGSSGS._GSGS_GSGS_GSS_GSS_GSGS_GSS_GSS_GSS_GSS_GSS_GSS_E0 GSGS_GSGS_GS GS_GSS_GSGS_GSS_GSGS_GSS_GSS_GSS_GSGS<_GS	S_GS
S_GSS_GSS_GSS_E0 GSS_GSS_GSS_GSS_GSS_GSGSp_GSGSp_GSS_GSGS_GSGS_GSGS_GSGS_GSGS_GSGS_GSGS_GSGS_GSGS_SGSSGS.EGSSSGS.SSSSSSSSSGSSGSGS.GSe.GSkGSS00GS.E_GSGSkSS	U R	                  GS5      U R	                  GS5      GS.GSGSS	S	U R	                  GS 5      U R	                  GS!5      U R	                  GS"5      U R	                  GS#5      /U R	                  GS$5      U R	                  GS#5      /U R	                  GS%5      U R	                  GS&5      /U R	                  GS'5      U R	                  GS(5      /U R	                  GS)5      U R	                  GS*5      /U R	                  GS+5      U R	                  GS,5      /U R	                  GS-5      U R	                  GS.5      /U R	                  GS/5      U R	                  GS05      /U R	                  GS15      U R	                  GS!5      /U R	                  GS25      U R	                  GS35      //
U R	                  GS"5      U R	                  GS!5      /U R	                  GS$5      U R	                  GS45      /U R	                  GS%5      U R	                  GS55      /U R	                  GS'5      U R	                  GS65      /U R	                  GS)5      U R	                  GS75      /U R	                  GS+5      U R	                  GS85      /U R	                  GS-5      U R	                  GS95      /U R	                  GS/5      U R	                  GS:5      /U R	                  GS15      U R	                  GS;5      /U R	                  GS25      U R	                  GS"5      //
GS<.GS=.0GSGS>S	S	U R	                  GS 5      U R	                  GS75      U R	                  GS"5      U R	                  GS 5      /U R	                  GS$5      U R	                  GS?5      /U R	                  GS%5      U R	                  GS#5      /U R	                  GS'5      U R	                  GS*5      /U R	                  GS)5      U R	                  GS.5      /U R	                  GS+5      U R	                  GS@5      /U R	                  GS-5      U R	                  GS@5      /U R	                  GS/5      U R	                  GS@5      /U R	                  GS15      U R	                  GS@5      /U R	                  GS25      U R	                  GS@5      //
U R	                  GS"5      U R	                  GS75      /U R	                  GS$5      U R	                  GS85      /U R	                  GS%5      U R	                  GSA5      /U R	                  GS'5      U R	                  GSB5      /U R	                  GS)5      U R	                  GS"5      /U R	                  GS+5      U R	                  GSC5      /U R	                  GS-5      U R	                  GSD5      /U R	                  GS/5      U R	                  GSE5      /U R	                  GS15      U R	                  GSF5      /U R	                  GS25      U R	                  GSG5      //
GS<.GS=.00 GSH._GSIGSJU R                  GSJGSJU R	                  GS5      GSK.5      0_GSLGSMGSNGSO._GSP[        _GSQ0 GSRS_GSSS	_SeGST/ GSUQ0_GSVS_SDS	_GSWGSX_GSYS_GSZS _GS[S_GS\S	_GS][        _GS^S_S{GS_GS_GS|_GS`GS_GSaS_GSbGScGScGSd._S	GSeGSeGSfGSgGSfGSgGSgGSh.GSiGSiGSjGSkGSkGSlGSmGSlGSlGSmGSnGSo.SGSpSGSqGSrSGSs.GStGSuGSvGSwGSxGSyGSzGSzGS{.GSzGSz0GS|GSt0GS}GSu0GS~.0 GSS	_GSS	_GSS	_GSS	_GSS	_GSS	_GSS	_GSS	_GSS	_GSS	_GSS	_GSS	_GSS	_GSS	_GSS	_GSS	_GSS	_S	S	S	S	S	S	S	S	S	S	S	S	S	S	S	GS.EGSGS0GSGS.
E_GSS	GSS	0S	S	S SS	S	S S	S	S	SGS.S	SS	SS	S	S	S	GS.SS	GS.S SGSrS SS	GS.S	SSS	GS.S	S SSSGS.S	GSrS GS|SSS	GS.S	GSrS S GS|SSS	GS.GSGSr0GS.
S	SS	S	S	SGS.S	S	S S	S	S	S	GS.S	S	S	SSSS	GS.GSGS0SS GSrGSS	GS.SSSS	GS.S	GSqSSSGS.S	GSrGSGSSSS	GS.S	GSrGSGSGSSSS	GS.GSGS0GS.	GSGS0GSGS0GS.GSGS0GSGS0GS.GS._GSGS0 GS[        _GS[        _GS[        _GS[        _GS[        _GS[        _GS[        _GS[        _GS[        _GS[        _GS[        _GS[        _GS[        _GS[        _GS[        _GS[        _GS[        _0 GS[        _GS[        _GS[        _GS[        _GS[        _GS[        _GS[        _GS[        _GS[        _GS[        _GS[        _GS[        _GS[        _GS[        _GS[        _GS[        _GS[        _E0 GS[        _GS[        _GS[        _GS[        _GS[        _GS[        _GS[        _GS[        _GS[        _GS[        _GS[        _GS[        _GS[        _GS[         _GS[        _GS["        _GS[        _E0 GS[        _GS["        _GS[$        _GS[        _GS[        _GS[        _GS[        _GS[&        _GS[        _GS["        _GS["        _GS[$        _GS["        _GS[        _GS["        _GS[        _GS[        _E0 GS["        _GS["        _GS["        _GS[        _GS[        _GS[$        _GS[        _GS[        _GS[        _GS[         _GS[         _GS[         _GS[        _GS[        _GS [        _GS[        _GS[        _E0 GS[        _GS[        _GS[        _GS["        _GS["        _GS[        _GS	[        _GS
["        _GS[        _GS[        _GS[        _GS[        _GS["        _GS[        _GS[        _GS[        _GS[$        _E0 GS[$        _GS[$        _GS[$        _GS[$        _GS[$        _GS[$        _GS[$        _GS[$        _GS[$        _GS[$        _GS[$        _GS[        _GS [$        _GS![$        _GS"[$        _GS#[$        _GS$[$        _E0 GS%[$        _GS&[$        _GS'[$        _GS([$        _GS)[$        _GS*[$        _GS+[$        _GS,[$        _GS-[$        _GS.[$        _GS/[$        _GS0[$        _GS1[$        _GS2[$        _GS3[$        _GS4[$        _GS5[$        _E0 GS6[$        _GS7[$        _GS8[$        _GS9[$        _GS:[$        _GS;[$        _GS<[$        _GS=[$        _GS>[$        _GS?[$        _GS@[$        _GSA[$        _GSB[$        _GSC[$        _GSD[$        _GSE[$        _GSF[$        _E0 GSG[$        _GSH[$        _GSI[$        _GSJ[$        _GSK[$        _GSL[$        _GSM[$        _GSN[$        _GSO[$        _GSP[$        _GSQ[$        _GSR[$        _GSS[$        _GST[$        _GSU[$        _GSV[$        _GSW[$        _E0 GSX[$        _GSY[$        _GSZ[$        _GS[[$        _GS\[$        _GS][$        _GS^[$        _GS_[$        _GS`[$        _GSa[$        _GSb[$        _GSc[$        _GSd[$        _GSe[$        _GSf[$        _GSg[$        _GSh[$        _E0 GSi[$        _GSj[$        _GSk[$        _GSl[$        _GSm[$        _GSn[$        _GSo[$        _GSp[$        _GSq[$        _GSr[$        _GSs[$        _GSt[$        _GSu[$        _GSv[        _GSw[         _GSx[         _GSy[        _E0 GSz[        _GS{[        _GS|[        _GS}[        _GS~[        _GS[        _GS[        _GS[        _GS[         _GS[        _GS[        _GS[        _GS["        _GS[        _GS[        _GS[        _GS[        _E0 GS[        _GS[&        _GS[        _GS[         _GS[        _GS[        _GS[        _GS[        _GS["        _GS[         _GS[        _GS[        _GS[        _GS[        _GS[        _GS[        _GS[        _E0 GS[        _GS[        _GS[        _GS[        _GS[         _GS[        _GS[         _GS[        _GS[        _GS[        _GS[        _GS[        _GS[        _GS[        _GS[        _GS[        _GS[        _E0 GS[        _GS[        _GS[        _GS[        _GS[        _GS[        _GS[        _GS[        _GS[        _GS[        _GS[        _GS[        _GS[        _GS[        _GS[        _GS[        _GS["        _E0 GS[        _GS[&        _GS[        _GS[        _GS[        _GS["        _GS[        _GS[        _GS[        _GS["        _GS[        _GS[        _GS[        _GS["        _GS[        _GS[        _GS[        _E[        [        [        [         [        [        [        [        [        [        GS.
E0GS0 GS["        _GS[        _GS["        _GS[        _GS[        _GS["        _GS[        _GS[        _GS[        _GS[        _GS[        _GS[        _GS[        _GS["        _GS[         _GS[         _GS[        _0 GS[(        _GS[        _GS[        _GS[         _GS[        _GS[        _GS[        _GS[        _GS"[        _GS#[        _GS$[        _GS%[        _GS([        _GS)[        _GS*[        _GS+[        _GS,[        _E0 GS-[        _GS.[        _GS/[        _GS0[        _GS1[        _GS2[        _GS3["        _GS4[        _GS8[        _GS:["        _GS;["        _GSR[        _GSS[        _GST[        _GSU[        _GSV[        _GSc[        _E0 GS[        _GSl[        _GSo[        _GS[        _GSh[        _GS[        _GS[        _GS[        _GS[        _GS[        _GS[        _GS[        _GS[        _GS[        _GS["        _GS["        _GS["        _E0 GS["        _GS["        _GS[        _GS[        _GS[        _GS[        _GS["        _GS["        _GS["        _GS["        _GS[*        _GS[*        _GS[        _GS[        _GS[        _GS[        _GS[        _E[        [        [        [        [        GS .E0GS0 GS["        _GS["        _GS[        _GS[        _GS[        _GS[        _GS[        _GS[        _GS[        _GS[         _GS[         _GS[        _GS[(        _GS[        _GS[        _GS[        _GS[        _0 GS[        _GS[        _GS[        _GS9[        _GS:[        _GS;[        _GS<["        _GS["        _GSO[        _GS[        _GSP[        _GSQ[        _GSu[        _GS[        _GS[        _GS[        _GS[        _E[        [        ["        ["        ["        [        [        [        [        ["        ["        [        GS.E0GS0 GS	[$        _GS[$        _GS
[$        _GS[$        _GS[&        _GS[$        _GS[$        _GS[$        _GS[$        _GS[$        _GS[        _GS[        _GS[        _GS[$        _GS[         _GS[         _GS[        _0 GS[$        _GS[$        _GS[$        _GS[$        _GS[$        _GS[$        _GS[$        _GS[$        _GS[$        _GS[$        _GS[$        _GS[$        _GS[$        _GS[$        _GS[$        _GS[$        _GS[$        _E0 GS[$        _GS[$        _GS[$        _GS[$        _GS[$        _GS[$        _GS[$        _GS[$        _GS[$        _GS[$        _GS[$        _GS[$        _GS	[$        _GS
[$        _GS[$        _GS[$        _GS[$        _E0 GS[$        _GS[$        _GS[$        _GS[$        _GS[$        _GS[$        _GS[$        _GS[$        _GS[$        _GS[$        _GS[$        _GS[$        _GS[$        _GS[$        _GS[$        _GS[$        _GS[$        _E0 GS [$        _GS![$        _GS"[$        _GS#[$        _GS$[$        _GS%[$        _GS&[$        _GS'[$        _GS([$        _GS)[$        _GS*[$        _GS+[$        _GS,[$        _GS-[$        _GS.[$        _GS/[$        _GS0[$        _E0 GS1[$        _GS2[$        _GS3[$        _GS4[$        _GS5[$        _GS6[$        _GS7[$        _GS8[$        _GS9[$        _GS:[$        _GS;[$        _GS<[$        _GS=[$        _GS>[$        _GS?[$        _GS@[$        _GSA[$        _E0 GSB[$        _GSC[$        _GSD[$        _GSE[$        _GSF[$        _GSG[$        _GSH[$        _GSI[$        _GSJ[$        _GSK[$        _GSL[$        _GSM[$        _GSN[$        _GSO[$        _GSP[$        _GSQ[$        _GSR[$        _E0 GSS[$        _GST[$        _GSU[$        _GSV[$        _GSW[$        _GSX[$        _GSY[$        _GSZ[$        _GS[[$        _GS\[$        _GS][$        _GS^[$        _GS_[$        _GS`[$        _GSa[$        _GSb[$        _GSc[$        _E0 GSd[$        _GSe[$        _GSf[$        _GSg[$        _GSh[$        _GSi[$        _GSj[$        _GSk[$        _GSl[$        _GSm[$        _GSn[$        _GSo[$        _GSp[$        _GSq[$        _GSr[$        _GSs[$        _GSt[$        _E[$        [$        [$        [$        [$        [$        [$        [$        [$        [$        GS.
E0GS0 GS[        _GS[$        _GS["        _GS	[&        _GS[        _GS["        _GS
[        _GS[        _GS[        _GS[$        _GS["        _GS[$        _GS[        _GS[        _GS[,        _GS[,        _GS[        _0 GS[        _GS[        _GS[        _GS[        _GS[        _GS[        _GS[        _GS [        _GS![        _GS"[        _GS[        _GS[        _GS[        _GS#[        _GS[        _GS[        _GS[        _E0 GS$[        _GS%[        _GS&[        _GS'[        _GS([        _GS)[        _GS*[        _GS+[        _GS,[        _GS[        _GS-[        _GS[        _GS[        _GS[        _GS[        _GS[        _GS.[        _E0 GS[        _GS/[.        _GS0[        _GS1[        _GS[        _GS[        _GS[        _GS[*        _GS[(        _GS[        _GS[        _GS[        _GS[        _GS[        _GS[        _GS[        _GS[        _E0 GS[        _GS[        _GS[        _GS[        _GS[        _GS[        _GS[        _GS[        _GS[        _GS[        _GS[        _GS[        _GS[        _GS[        _GS[        _GS[        _GS[        _E0 GS[        _GS[        _GS[        _GS[        _GS[        _GS[        _GS[        _GS[        _GS[        _GS[        _GS[        _GS [        _GS[        _GS[        _GS[        _GS[        _GS[        _E0 GS[        _GS[        _GS[        _GS[        _GS[        _GS[        _GS[        _GS[        _GS[        _GS[        _GS[        _GS["        _GS["        _GS[        _GS[        _GS[        _GS [        _E0 GS![        _GS"[        _GS#[        _GS$[        _GS%[        _GS&[        _GS'[        _GS([        _GS)[        _GS*[        _GS+[        _GS,[        _GS-[        _GS.[        _GS/[        _GS0[        _GS1[        _E0 GS2[        _GS3["        _GS4[        _GS5[        _GS6[        _GS7[,        _GS8[        _GS9[        _GS:["        _GS;["        _GSI[        _GSR[        _GSS[        _GSV[        _GSc[        _GSg[        _GSi[        _E0 GSj[        _GSk[        _GS[(        _GSl[        _GSm[(        _GSo[        _GS2[        _GS[        _GS[        _GS[        _GS[        _GS3[        _GS[*        _GS[*        _GS[        _GS4[&        _E00 GS[        _GS[        _GS[        _GS	[&        _GS[        _GS
[        _GS[0        _GS[        _GS[        _GS[        _GS[&        _GS[        _GS[        _GS[2        _GS[        _GS[        _GS[        _0 GS[        _GS[        _GS [        _GS![        _GS"[        _GS[        _GS#[        _GS[        _GS[        _GS$[        _GS%[        _GS&[        _GS'[        _GS([        _GS)[        _GS*[        _GS+[        _E0 GS,[        _GS[        _GS-[        _GS.[        _GS[.        _GS/[.        _GS0[        _GS1[        _GS[        _GS[        _GS[        _GS[        _GS[        _GS[        _GS[        _GS[        _GS[        _E0 GS[        _GS[        _GS[        _GS[        _GS[        _GS[        _GS[        _GS[        _GS[        _GS[        _GS[        _GS[        _GS[        _GS[        _GS[        _GS[        _GS[        _E0 GS[        _GS[        _GS[        _GS [        _GS[        _GS[        _GS[        _GS[        _GS[        _GS[        _GS[        _GS[        _GS[        _GS[        _GS[         _GS[         _GS[        _E0 GS[        _GS[        _GS[        _GS[        _GS[        _GS[        _GS[        _GS[        _GS [        _GS![        _GS&[        _GS'[        _GS5[        _GS6[        _GS7[        _GS9[        _GSI[        _E0 GSg[        _GSi[        _GSj[        _GSk[        _GSm[(        _GS5[        _GS6[        _GS7[        _GS8[        _GS9[        _GS:[        _GS;[        _GS<[        _GS=[        _GS>[4        _GS?[        _GS@["        _E0 GSA[        _GSB[(        _GSC[(        _GSD[(        _GSE[         _GSF["        _GSG["        _GSH["        _GSI[6        _GSJ[&        _GSK[        _GSL[        _GSM[        _GSN[        _GSO["        _GSP["        _E["        [        GSQ.GSR._5      $ (S  NidrK   nameBinance	countries	rateLimit2   	certifiedTprohas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
editOrdersfetchAccountsfetchAllGreeksfetchBalancefetchBidsAsksfetchBorrowInterestfetchBorrowRateHistoriesfetchBorrowRateHistoryfetchCanceledAndClosedOrdersemulatedfetchCanceledOrdersfetchClosedOrderfetchClosedOrdersfetchConvertCurrenciesfetchConvertQuotefetchConvertTradefetchConvertTradeHistoryfetchCrossBorrowRatefetchCrossBorrowRatesfetchCurrenciesfetchDepositfetchDepositAddressfetchDepositAddressesfetchDepositAddressesByNetworkfetchDepositsfetchDepositsWithdrawalsfetchDepositWithdrawFeefetchDepositWithdrawFeesfetchFundingHistoryfetchFundingIntervalfetchFundingIntervalsfetchFundingRatefetchFundingRateHistoryfetchFundingRatesfetchGreeksfetchIndexOHLCVfetchIsolatedBorrowRatefetchIsolatedBorrowRatesfetchL3OrderBookfetchLastPricesfetchLedgerfetchLedgerEntryfetchLeveragefetchLeveragesfetchLeverageTiersfetchLiquidationsfetchLongShortRatiofetchLongShortRatioHistoryfetchMarginAdjustmentHistoryfetchMarginModefetchMarginModesfetchMarketLeverageTiersfetchMarketsfetchMarkOHLCVfetchMarkPricefetchMarkPricesfetchMyLiquidationsfetchMySettlementHistoryfetchMyTrades
fetchOHLCVfetchOpenInterestfetchOpenInterestHistoryfetchOpenOrderfetchOpenOrdersfetchOptionfetchOptionChain
fetchOrderfetchOrderBookfetchOrderBooksfetchOrdersfetchOrderTradesfetchPositionfetchPositionHistoryfetchPositionModefetchPositionsfetchPositionsHistory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)sandboxsetLeverage	setMarginsetMarginModesetPositionModesignIntransferwithdraw
timeframes1s1m3m5m15m30m1h2h4h6h8h12h1d3d1w1MurlszOhttps://github.com/user-attachments/assets/e9419b93-ccb0-46aa-9bff-c883f096274bz)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.binancefuture.com/fapi/v3z%https://testnet.binance.vision/api/v3z%https://testnet.binance.vision/api/v1)
dapiPublicdapiPrivatedapiPrivateV2
fapiPublicfapiPublicV2fapiPublicV3fapiPrivatefapiPrivateV2fapiPrivateV3publicprivatev1z%https://demo-dapi.binance.com/dapi/v1z%https://demo-dapi.binance.com/dapi/v2z%https://demo-fapi.binance.com/fapi/v1z%https://demo-fapi.binance.com/fapi/v2z%https://demo-fapi.binance.com/fapi/v3z#https://demo-api.binance.com/api/v3z#https://demo-api.binance.com/api/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   z https://fapi.binance.com/fapi/v3r  r  r  fapiDataz%https://fapi.binance.com/futures/datazhttps://api.binance.com/api/v3zhttps://api.binance.com/api/v1z https://papi.binance.com/papi/v1z https://papi.binance.com/papi/v2)r  r  r  papipapiV2zhttps://www.binance.comz1https://accounts.binance.com/register?ref=CCXTCOMg?)urldiscountz!https://developers.binance.com/enz=https://www.binance.com/en/usercenter/settings/api-managementz'https://www.binance.com/en/fee/schedule)	logotestdemoapiwwwreferraldocapi_managementfeesr  zcopyTrading/futures/userStatus   zcopyTrading/futures/leadSymbolsystem/statusaccountSnapshot   zaccount/infoz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/orderz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/historyzcapital/withdraw/address/listz"capital/contract/convertible-coinszconvert/tradeFlowconvert/exchangeInfozconvert/assetInfo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&sol-staking/sol/history/stakingHistoryz)sol-staking/sol/history/redemptionHistoryz+sol-staking/sol/history/bnsolRewardsHistoryz#sol-staking/sol/history/rateHistoryzsol-staking/accountzsol-staking/sol/quotaz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/ifNewUserzapiReferral/customizationz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/subOrdersportfolio/accountzportfolio/collateralRatezportfolio/pmLoang^I
@zportfolio/interest-historyzportfolio/asset-index-pricezportfolio/repay-futures-switch   zportfolio/margin-asset-leveragezportfolio/balancez*portfolio/negative-balance-exchange-recordzportfolio/pmloan-historyzportfolio/earn-asset-balance   z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/rewardsRecordz(simple-earn/locked/history/rewardsRecordz-simple-earn/flexible/history/collateralRecordzdci/product/list)z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sol-staking/sol/stakezsol-staking/sol/redeemz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-collectionzportfolio/asset-collectionzportfolio/bnb-transferz(portfolio/repay-futures-negative-balancezportfolio/mintzportfolio/redeemzportfolio/earn-asset-transferz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"simple-earn/locked/setRedeemOption)zdci/product/subscribezdci/product/auto_compound/edit)rA  rB  )r$  r#  r(  r'  rA  rB  r;  rD  zalgo/spot/orderzalgo/futures/orderz.sub-account/subAccountApi/ipRestriction/ipList)getpostputdelete)r9  r4  r5  r6  r,  r.  r/  r0  zloan/flexible/loanable/datazloan/flexible/collateral/datar<  )rE  r7  zloan/flexible/borrowrF  rG  )rH  rI  zsub-account/assetszasset/getUserAssetrH  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fundingInfo)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commissionRatezincome/asyn)income/asyn/id
trade/asyntrade/asyn/id
order/asynorder/asyn/idpmExchangeInfopmAccountInfo   )rm  ro  batchOrderscountdownCancelAllleverage
marginTypepositionMargin	listenKey)r  ro  r  )ro  allOpenOrdersr  r  re  )	rb  rd  	indexInfo
assetIndexrc  apiTradingStatus	lvtKlinesr1  insuranceBalance)rf  rg  rh  ri  rj  takerlongshortRatiorl  rateLimit/orderr  multiAssetsMarginzapiReferral/traderNumzapiReferral/overviewzapiReferral/tradeVolzapiReferral/rebateVolzapiReferral/traderSummaryr  r|  r  r  r}  r~  )feeBurnsymbolConfigaccountConfigr2  	algoOrderopenAlgoOrdersallAlgoOrdersr  r  r  
order/testr  r  r  r     r  )r  ro  r  r  r  algoOpenOrdersr   )rt  rs  ru  )rL  rM  rN  indextickermarkrO  rY  rT  rU  exerciseHistoryrd  positionhistoryOrdersexerciseRecordbillmarginAccountmmpzblock/order/ordersblock/order/executezblock/user-tradesblockTrades)	ro  r  r  mmpSetmmpResetr  countdownCancelAllHeartBeatblock/order/creater  )r  r  )ro  r  r  allOpenOrdersByUnderlyingr  r  g?i  g?   g?)rL  rM  rO  rT  rV  rU  rY  uiKlinesr_  r  zticker/tradingDayra  rb  rN  avgPrice)rH  rJ  rI  rK  g333333?   )allOrderListopenOrderList	orderListro  rq  rr  rt  myTradesr  myPreventedMatchesmyAllocationszaccount/commission)	z	order/ocozorderList/ocozorderList/otozorderList/otoco	sor/orderzsor/order/testro  zorder/cancelReplacer  )rq  r  ro  )rH  rI  rK  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-switchzum/adlQuantilezcm/adlQuantilezum/trade/asynzum/trade/asyn/idzum/order/asynzum/order/asyn/idzum/income/asynzum/income/asyn/idzum/orderAmendmentzcm/orderAmendment
um/feeBurnzum/accountConfigzum/symbolConfigzcm/accountConfigzcm/symbolConfigum/conditional/ordercm/conditional/order
marginLoan	repayLoanzum/leveragezcm/leveragezauto-collectionzbnb-transferzrepay-futures-negative-balancei  )zasset-collectionzmargin/repay-debtr  )r  r  r  )r  r  zum/allOpenOrderszum/conditional/allOpenOrdersr  r  zcm/allOpenOrderszcm/conditional/allOpenOrdersr#  zmargin/allOpenOrdersr(  r  )r  r  r  r  r  z0.001)feeSide	tierBased
percentagetakermakertradingquotez0.000500z0.0002000z0.000400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.000450z0.000240z0.000050z	0.0000030z	-0.000050z	-0.000060z	-0.000070z	-0.000080z	-0.000090)r  linearinverser]   
currenciesBNFCR)rO   code	precisioncommonCurrenciesBCCYOYOW)r  YOYOprecisionModeoptionssandboxModefetchMarginstypesrY   r  r  loadAllOptionsdefaultTimeInForceGTCdefaultTypedefaultSubType#hasAlreadyAuthenticatedSuccessfully"warnOnFetchOpenOrdersWithoutSymbolcurrencyToPrecisionRoundingModethrowMarginModeAlreadySet
recvWindowtimeDifferenceadjustForTimeDifferencenewOrderRespTypeFULL)marketlimit
x-TKT5PX2Fz
x-cvBPrNm9
x-xcKtGhcu)rY   rZ   r\   deliveryr[   r]   r  MAINFUNDINGMARGINUMFUTURECMFUTUREOPTION)mainrY   fundingrZ   crossr\   r  r  r[   r  r]   r  r  r  )r  r  r  r  r  r  ETHTRXBNBBSCOMNIEOSSOL)ERC20TRC20BEP2BEP20r  r  SPLr  r  r  )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BUSDg:0yE>)
quoteOrderQtybrokeraccountsByTypeaccountsByIdnetworksnetworksByIdimpliedNetworks
legalMoneylegalMoneyCurrenciesByIddefaultWithdrawPrecisionfeaturesr  )IOCFOKPOGTD)EXPIRE_MAKEREXPIRE_TAKEREXPIRE_BOTHNONE)
marginModetriggerPricetriggerPriceTypetriggerDirectionstopLossPricetakeProfitPriceattachedStopLossTakeProfittimeInForcehedgedr  marketBuyByCostmarketBuyRequiresPriceselfTradePreventiontrailingicebergAmount)r>  r  daysBack	untilDayssymbolRequired)r>  triggerrJ  rN  )r>  r  rO  rJ  rN  )r>  r  rL  rM  rO  rJ  rN  )r>  r  rL  daysBackCanceledrM  rO  rJ  rN  r  )
r   r   ro   rp   r   r   r   r   r   r   )r  lastr  )r>  r?  r@  rB  rC  rD  rE  rF  rI  rJ  icebergr  rH  rG  max   )r>  rL  r  rM  rN  Z     )	r   ro   rp   r   r   r   r   r   r   extendsforDerivatives)r  r  )rY   rX  r[   r\   
exceptions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)
z-21002z-21003z-21004z-21005z-21006z-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-5028)z-5037z-5038z-5039z-5040-5041z-1128z-4090z-4111z-4151z-4152z-4154z-4155)z-4178z-4188r_  z-4194z-4195z-4196z-4197z-4198z-4199z-4200z-4201r`  z-1003z-1006z-1007z-1010z-1013z-1112z-1114z-1129z-2011)
r[  -20121-20124-20130-20132-20194-20195-20196-20198-20204z-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-4161z-4408ra  rb  rc  rd  re  rf  rg  rh  ri  rj  z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)rY   r  r  r]   portfolioMarginrZ  broad)deep_extendsuperrK   describeparse_numbersafe_currency_structurerH   rG   r@   r1   r5   r6   r7   rF   r;   r3   r:   r2   r0   rB   r=   r>   r?   r<   rE   rD   rC   r9   )self	__class__s    T/home/james-whalen/.local/lib/python3.13/site-packages/ccxt/async_support/binance.pyrq  binance.describe+   sHp   gt = ? n(B
)n(B
In(B
 n(B
 	n(B

 n(B
 4n(B
  QQQ $Q 	Q
 $Q $Q TQ $TQ 'Q "4Q tQ Q $UQ  Q %dQ  '!Q" &t#Q$ '%Q& ''Q( /)Q* ,T+Q, (-Q. 0/Q0 t1Q2 3Q4 75Q6 &t7Q8 (9Q: ';Q< &t=Q> (?Q@ "4AQB (CQD -dEQF %dGQH TIQJ dKQL  MQN !$OQP QQR  SQT &tUQV +EWQX )$YQZ /
[Q\ &z]Q^ #E_Q` $ZaQb )$cQd $TeQf $TgQh +DiQj 'kQl (mQn "4oQp qQr &tsQt (uQv 1%wQx  yQz +E{Q| *:}Q~ +DQ@ &tAQB '
CQD (EQF #DGQH *4IQJ $TKQL tMQN "4OQP *:QQR +DSQT #EUQV "4WQX tYQZ #D[Q\  ]Q^ !$_Q` %daQb $UcQd &ueQf -dgQh /iQj "4kQl #DmQn +JoQp qQr !$sQt !$uQv "4wQx &tyQz +D{Q|  }Q~ dQ@ $TAQB +DCQD !$EQF "4GQH tIQJ #EKQL dMQN !$OQP "5QQR tSQT #DUQV  WQX 'YQZ $T[Q\ !$]Q^ (_Q` %daQb )$cQd )$eQf tgQh tiQj kQl TmQn toQp "4qQr #DsQt %juQv &zwQx 'yQz $U{Q|  }Q~ !$Q@ (AQB )%CQD )%EQF "5GQH #DIQJ +EKQL MQN #DOQP &tQQR  #"!%#'  aQn(B
t  dd d d	
 u u d d d d d u d d d  d!un(B
X i"M#N%P"M$O$O#N%P%PEFA #J#J%L"I$K$K#J%L%LCD?=? ? ?	
 !"D "#E !"D "#E $%G  G !"D #$F #$F "#E $%G  $%G!"  G#$ ??:>@-0 1N #
 8 #bA@Yn(B
Z  tS8!S 9!S (	S *3S 'S 'S &qS +CS *3S ,QS /S .qS  )#!S" )##S$ ,S%S& )#'S( I&)S* =h+S, /-S. 9!/S0 .q1S2 &q3S4 '5S6 )!7S8 *39S: 1#;S< 5c=S> '?S@ ,QASB +BCSD *1ESF /GSH 1!ISJ ,QKSL 3CMSN 21OSP /QSR 3ASST 7USV 5cWSX +AYSZ .r[S\ /]S^ 13#2N_S` 4cQ5OaSb 4ScSd 1!eSf *3gSh &viSj <RkSl :6mSn B6oSp ;FqSr .rsSt 1"uSv 5fwSx 1#ySz 1"{S| 3B}S~ 0S@ 8ASB &vCSD .rESF 6rGSH .rISJ -bKSL -bMSN /OSP 5cQSR 7SST 7USV 6rWSX ?YSZ 22[S\ 1"]S^ 6s_S` &vaSb (cSd +AeSf /gSh *6iSj 0kSl 21mSn 7oSp 1#qSr 5csSt 4SuSv 3AwSx 8ySz =f{S| ,V}S~ /S@ ,RASB .vCSD 8ESF )#GSH 3CISJ @KSL "3MSN 6qOSP =cQSR ;ASST ?USV +CWSX 5aYSZ <Q[S\ 23]S^ -a_S` ;CaSb >scSd 8eSf STUgSh =giSj B6kSl 3CmSn =coSp FsqSr I'sSt @uSv 9#wSx 27ySz =h{S| =g}S@ 5cASB 6sCSD <SESF 7GSH 0ISJ 7KSL 9#MSN 8OSP /QSR 8SSV A"WSX DRYSZ A"[S\ 0]S^ >r_S` .raSb @cSd B2eSf FrgSh A"iSj DRkSl FrmSn >roSp .rqSr 0sSv .swSx .sySz /{S| -c}S~ .sS@ 8ASB 6sCSD -cESH &sISJ *CQ+GKSL -fMSN &wOSP %fQSR .wSST 4WUSV 7WSX 1%YSZ /[S^ )#_S` 0aSb -ccSd )#eSh 0iSj 4QkSl 8mSn :1oSp >qqSr <QsSt @uSx /ySz ,Q{S| B1}S~ FqS@ &qASB *1CSD 21ESF 5aGSH 9!ISJ ;AKSL 8MSN 8OSP :1QSR ;ASST =aUSV =aWSX 3AYS^ 23_Sb >scSf 3FgSh .viSj /kSl ,VmSn +FoSp *3qSr ?sSt 7uSv /wSx 5cySz .s{S| 23}S~ 8S@ 1#ASB ,SCSD 3AESF +FGSH 5fISJ 6sKSL 9!MSN :1OSP ,QQSR EaSST 3AUSV 7WSZ .s[S\ +C]S^ 0_S` 4SaSb @cSd DSeSf 8gSh @iSj 8kSl 6smSn ;CoSp 9#qSr A#sSt =cuSv =cwSx @yS| 4R}S~ 22S@ A"ASB ?CSD CBESF A"GSH CBISJ 8KSL 6rMSN .rOSP J2QSR HSST HUSV FrWSX EbYSZ CB[S\ H]S` +CaSb 2503eShG$gG(#G )&G 23	G
 1(G <SG ;CG 1&G =fG 7G .vG *6G &vG  '!G" '#G$ +H%G& &v'G( :6)G, 3F-G. 26/G0 .s1G2 "33G4 85G6 6v7G8 4S9G: 5c;G< 7=G> ??G@ 8AGB ;CCGD 8EGF 5cGGH 5cIGJ 6sKGL )#MGN 23OGP +CQGT ;CUGV 1#WGX /YG\ -b]G^ 0_G` %baGb -ecGf )#gGh &siGl 4QmGn 8oGp >qqGr @sGt ,QuGv 3AwGx 4QyGz /{G| :1}G~ :1G@ B1AGB FqCGD *1EGF 21GGH 9!IGJ 9!KGL CAMGN 1!OGP =aQGR DQSGT 3AUGV LQWGX I!YG\ .s]G^ .s_G` +CaGb 1&cGd 26eGf 4VgGj +CkGl )#mGn 1#oGr 0sGt 1"uGv 1"wGx 0yGz 1"{G~ 6sG@ =cAGB *6CGD )&EGF *6GGH &vIGJ %fKGL *6MGN 5fOGP .vQGR 3FSGT )&UGV +FWGX .vYGZ 3F[G\ 4V]G^ 4S_G` 5aaGb 1#cGd 9#eGf CCgGh )"iGj +BkGl 8mGn 7oGp 8qGr ?sGt 6suGv 5cwGz 9#{G| 7}G~ 6sG@ 4SAGB @CGD >rEGF =aGGJ 25:=MGR +.36 .1(0,439*-3601EF+..1JPMutp /17:>?<?8:8:79@B799;-. 24CI06/54:qt\ ,g -c	]tl ,gmtv   '  !"a3(SRTIX\^`Wa8b!c	
 !! +B $R ' &q !12q'C8dTUYY^`bXc9d"e +QRGcSTXX\^_W`chjlbmCn,o +QRGcSTXX\^_W`chjlbmCn,o *AB7SRSHW[]^V_bgikalBm+n -qr1gPSUVxZ^`aYbejlndoEp.q &r'B  '(B!" ,aQ-G#$ )*()'()wtf *+,-455678+,!"
gt| +R(!   $Q	
 %qa&@ $bb%A "1 "1 1! ' %rr&B !" *1 &'C &q  )"!" &q#$ +,&)),&)),*-),16 ./!"'(.0$%&'*+%&	 &'!"'( "#)*'(%&	U0 }t^  )1"_th   '  !"a3(SRTIX\^`Wa8b!c	
 !! +B $R !12q'C8dTUYY^`bXc9d"e +QRGcSTXX\^_W`chjlbmCn,o *AB7SRSHW[]^V_bgikalBm+n +QRGcSTXX\^_W`chjlbmCn,o -qr1gPSUVxZ^`aYbejlndoEp.q &q &q '  &r'B!" '(B#$ 78Q-G()%&/0b&A()56B,G%&01,-5itd *+,-455678/0!"
etz +%'C+#Q+ $Q+ %qb&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+H $%())*/0%&*+)*U+X%q+Q )! %a	
   %a #A $Q -b ,Q 4Q 8 "1 +C  .r!" $Q#( &'!"'( ()!")*%&%&*+KM {tV &!Wt`  #$#$()"atn 2!ott  #$#$()"utB  ! !()!""# !!""#"#,.+,()Ctb !1"A %qb&A (	
 %a )!  &q )! ( q -a   -a .q  ,Q!" &q#( "#'(%&"#$%./79.//0
 &'./
 "#'()*56%&./G+ ctB !$ #*+#qC8dTVZZ^`bYc8d!e"#%(,-"%$'03'D+.B"?-014#(F69s-K()$'$ )# )# )#5@ )*),%(!$/2&C%&#$$%+,./)*./ &)),),+.%(*-!$/2&)
 '*%(!$5JDD"AD 'D (!)D	D
 'D #AD 'D (!)DD 'D 3AD 4aR5PD 6qD 3QB4OD 3AD 4aR5PD  6q!D" 3B#D$ '%D& ,Q'D( +C)D* +A+D, .s-D. //D0 *11D2 "13D4 "15D6 /7D8 -a9D: *1;D< *3=D> /?D@ /ADB (CDD (EDF -cGDH -cIDJ -aKDL )22*FMDN )22*FODP ./KQDR ,QSDT ,QUDV ,QWDX +AYDZ 7[D\ 5b]D^ $Q_D` $QaDb %acDd %aeDf /gDh )!iDj )!kDl (mDn +AoDp (qDr +AsDt )#uDv ,QwDx ,QyDz ,Q{D| %b}D~ +AD@ *1ADB +ACDD *1EDF *1GDJ"A. #A /	
 ' %c $S +A &s &s / / *3 ' /  9#!" $S#$ -.-1&'). &)$%$% %&01,-89$%01,-89()01,-%(Ksj $a_t[n(B
D% $!&"&!..w7!..w7 #*%)&*!%!2!2:!>!%!2!2:!> "&!2!23!79J9J:9V W!%!2!25!94;L;LZ;X Y!%!2!26!:D<M<Mj<Y Z!%!2!26!:D<M<Mj<Y Z!%!2!27!;T=N=Nz=Z [!%!2!27!;T=N=Nz=Z [!%!2!28!<d>O>OPZ>[ \!%!2!28!<d>O>OPZ>[ \!%!2!28!<d>O>OPZ>[ \!%!2!28!<d>O>OPZ>[ \& "&!2!23!79J9J:9V W!%!2!25!94;L;LZ;X Y!%!2!26!:D<M<Mj<Y Z!%!2!26!:D<M<Mj<Y Z!%!2!27!;T=N=Nz=Z [!%!2!27!;T=N=Nz=Z [!%!2!28!<d>O>OPZ>[ \!%!2!28!<d>O>OPZ>[ \!%!2!28!<d>O>OPZ>[ \!%!2!28!<d>O>OPS>T U&"  "H #)%)&*!%!2!2:!>!%!2!2:!> "&!2!23!79J9J:9V W!%!2!25!94;L;LZ;X Y!%!2!26!:D<M<Mj<Y Z!%!2!26!:D<M<Mj<Y Z!%!2!27!;T=N=Nz=Z [!%!2!27!;T=N=Nz=Z [!%!2!28!<d>O>OPZ>[ \!%!2!28!<d>O>OPZ>[ \!%!2!28!<d>O>OPZ>[ \!%!2!28!<d>O>OPZ>[ \& "&!2!23!79J9J:9V W!%!2!25!94;L;LZ;X Y!%!2!26!:D<M<Mj<Y Z!%!2!26!:D<M<Mk<Z [!%!2!27!;T=N=Ns=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E%n(B
d' 55Wgdhduduv}d~6  Ae'n(B
j' !k'n(B
r' Ys'n(B
v'  yuyy  !y !%y "4y %ey  v!y" !$#y$ 6u%y& 5d'y( 28)y4 ,U5y6 !.7y8 i9y: !!;y< *5=y> #$#%?yF "&(** ,(*+ #"(&%( *(&)&# #(& ( )&! #"!""   	 5! $U+#U+$!4!4! 4! 4	!
 4! 4! 4! 4! 4! 4! 4! 4! 4! 4! 4!  4!!" 4#!$  A!F E- -7qyw'n(B
j+ #!4( '+(,,0,1)-+/6:#'#'"&#(	( #'$)+/27,0,0+/$(	0 %*)-3$6 %)&+!%$(%&*.& '+#($)*.	# '+!%#($)*/( '+!%$(%*#($)*.$ '+!%$(,0%*#($)*.	*  #QKZ  $&+(,$($(%*-
 *.+/6:#'#'"&#'	( #'/3$(#($)27+/3$8 q% ',$(!%%&*.& ',#($)*.	# '+!$#($)*/( '+!%$&%&#($)*.$ '+!%$&,-%&#($)*.	*  #OJ#Z "#3 "#3 	 "#3 "#3 	Ahk+n(B
|0  M  	M
  M  !4M  M  M  M  M  M  M   !4!M"  !2#M$  %M&  'M(  )M0  1M2  !43M4  5M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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z  !2{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`  !2a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  !2sMt  !2uMv  !2wMx  !2yMz  {M|  }M~  M@  AMB  CMD  !2E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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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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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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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x  !2yMz  !2{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^  !2_M`  !2a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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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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@
 #-"-"3"3"1"1 #-",%8%8Y
MOb
  g  !1	g
  g  !1g  g  !4g  !1g  g  g  g  g  g$  %g&  !2'g(  !1)g*  !2+g,  !2-g.  /g0  !91g2  3g4  5g6  !27g8  !29g:  ;g<  !2=g>  !2?gF  GgH  IgJ  KgL  MgN  OgP  QgR  SgT  !2UgV  WgX  !2YgZ  [g\  !2]g^  !2_g`  agb  cgd  !1egf  ggh  igj  !1kgl  !1mgn  ogp  qgr  sgt  !2ugv  !2wgx  !2ygz  {g|  !2}g~  g@  AgB  CgD  EgF  GgH  IgJ  !2KgL  !2MgN  !2OgP  !2QgR  SgT  UgV  !1WgX  !1YgZ  !1[g\  !1]g^  !1_g`  !2agb  !2cgd  egf  ggh  !1igj  !1kgl  !1mgn  !1ogv  !1wgx  !1ygz  !2{g|  !2}g~  !2g@  !2AgB  CgD ",!+!+!+!0MgiV  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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X ",!+!1!1!1!+!2!2!+!1!1!2o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|~@  y  	y
  y  !1y  !2y  y  !1y  y  y  y  y  !1y  y   !y"  #y$  %y&  'y(  )y*  +y,  -y.  /y6  7y8  9y:  ;y<  =y>  ?y@  AyB  CyD  EyF  GyH  IyJ  KyL  MyN  OyP  QyR  SyT  UyV  WyX  YyZ  [y\  ]y^  _y`  ayb  cyd  eyf  gyh  iyj  kyl  myn  oyp  qyx  yyz  !2{y|  }y~  !2y@  !2AyB  CyD  EyF  GyH  !1IyJ  !9KyL  MyN  OyP  !2QyR  !2SyT  UyV  !2WyX  !2Yy`  ayb  cyd  eyf  gyh  iyj  kyl  myn  oyp  qyr  syt  uyv  wyx  yyz  {y|  }y~  y@  AyB  CyD  EyF  GyH  IyJ  KyL  MyN  OyP  QyR  SyT  UyV  WyX  YyZ  [y\  ]y^  _y`  ayb  cyd  eyf  gyh  iyj  kyl  myn  oyp  qyr  syt  uyv  wyx  yyz  {y|  !1}y~  !1y@  AyB  CyD  EyF  GyH  IyJ  KyL  MyN  OyP  QyR  SyT  UyV  WyX  YyZ  [y\  !2]y^  _y`  ayb  cyd  !2eyf  !2gyh  iyj  kyl  !1myn  oyp  qyr  syt  uyv  wyx  yyz  !1{y|  !1}y~  y@  AyB  CyD  !2EyF  !2GyH  IyJ  KyL  MyN  OyP  !9QyR  SyT  !9UyV  WyX  !2YyZ  [y\  ]y^  _y`  ayb  cyj  !1kyl  !1myn  oyp  !2qy{$x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, 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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| 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^ 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@ 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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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v 3C$.W O}0n(B
 n( n(	    NtypesubTypec                     Uc  US:H  $ US:H  $ )Nr  r   rt  ry  rz  s      rv  
is_inversebinance.is_inverse\
  s    ?:%&i''rx  c                 4    Uc  US:H  =(       d    US:H  $ US:H  $ )Nr\   r[   r  r|  r}  s      rv  	is_linearbinance.is_linearb
  s&    ?8#88h&&rx  enablec                 H   > [         [        U ]  U5        XR                  S'   g )Nr  )rp  rK   set_sandbox_moder  )rt  r  ru  s     rv  r  binance.set_sandbox_modeh
  s    gt-f5&,]#rx  symbolc                    SnUR                  S5      nUR                  S5      nS nUR                  S5      S:  a  U R                  US5      nOU R                  US5      nU R                  US5      nU R                  US5      nU R                  US5      nU R                  US5      n	U R	                  U5      n
U R                  U
5      n0 S	US-   U-   S-   U-   S-   U	-   _S
US-   U-   S-   U-   S-   U-   S-   U-   S-   U	-   _SU_SU_SU_SU_SS _SS_SS _SS _SS_SS_SS_SS_SS_SS_SS _UU
U	S:X  a  SOSUUUS S S .S S S!.S S S!.S S S!.S".S S#.	E$ )$NUSDT-/r   r   r  r=  rO   r  :r  r  baseIdquoteIdactivery  r]   r  r  rY   Fr[   r\   TrZ   contractcontractSizeCcallrJ  )amountpriceminrS  )r  r  r)  )	expiryexpiryDatetime
optionTypestrikesettlesettleIdr  limitsinfo)splitfindsafe_stringsafe_integerconvert_expire_date	parse8601)rt  r  r  optionParts
symbolBaser  r  r  strikeAsStringr  datetime	timestamps               rv  create_expired_option_market$binance.create_expired_option_marketl
  sE   ll3'\\#&
;;sb ##J2D##K3D!!+q1"";2))+q9%%k15
++F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&U  
  
   U+
 +	
rx  c                 R   U R                   c  [        U R                  S-   5      eU R                  U R                  S5      nU R                  U R                  S5      nUS:H  nUS:H  nU=(       d    Un[        U[        5      (       Ga  XR                   ;   a[  U R                   U   nU(       aC  US   (       a9  U(       a  US   OUS   nUS	-   U-   n	XR                   ;   a  U R                   U	   $ GOU$ XR                  ;   aZ  U R                  U   n
U(       a  S
nOU(       a  SnOUc  Un[        S[        U
5      5       H  nX   nXr   (       d  M  Us  $    U
S   $ UR                  S5      S:  ab  UR                  S	5      S:  aM  UbI  US:w  aC  UR                  S5      u  pUS:X  a  UOUnUS	-   U-   n	XR                   ;   a  U R                   U	   $ O;UR                  S5      S:  d  UR                  S5      S:  a  U R                  U5      $ [        U R                  S-   U-   5      e)Nz markets not loadedr  r  r\   r  rY   r  r  r  r  r  r   r  r  r  -C-Pz does not have market symbol )marketsr0   rO   r  r  
isinstancestrmarkets_by_idrangelenr  r  r  r6   )rt  r  r  r  isLegacyLinearisLegacyInverseisLegacyr  r  futuresSymbolr  ir  r  s                 rv  r  binance.market
  s
   <<*? ?@@&&t||]C))$,,8HI$0%3!4_fc""%f-v0>VG_F6NF$*SL6$9M$4#||M:: 5 "M---,,V4!"*K$"+K ("0Kq#g,/A$ZF**% 0 qz!++c"R'fkk#.>.B++2G"(,,s"3KD&+unT5F$*SL6$9M$4#||M::++d#b(fkk$.?".D88@@"AAFJKKrx  marketIdr  	delimiter
marketTypec                    > US L=(       a/    UR                  S5      S:  =(       d    UR                  S5      S:  nU(       a   XR                  ;  a  U R                  U5      $ [        [        U ]  XX45      $ )Nr  r  r  )r  r  r  rp  rK   safe_market)rt  r  r  r  r  isOptionru  s         rv  r  binance.safe_market
  sh    D(hd0Cb0H/ghmm\`NadfNfX););;44X>>Wd/)XXrx  c                     U R                  U[        U R                  U   S   S   U R                  U R                  5      $ )Nr  r  )decimal_to_precisionrG   r  r  paddingMode)rt  r  r)  s      rv  cost_to_precisionbinance.cost_to_precision
  sK    ((xf9Mk9Z[b9ceiewewy}  zJ  zJ  K  	Krx  c                 B    U R                  5       U R                  S   -
  $ )Nr  )millisecondsr  )rt  s    rv  noncebinance.nonce
  s       "T\\2B%CCCrx  c                    U R                   (       a  [        U R                  S-   5      eU(       a9  U R                  S   U R                  S'   U R                  S   U R                  S'   ONSU R                  ;   a>  U R                  S   U R                  S'   U R	                  U R                  S5      nX l        XR
                  S'   g)a   
enables or disables demo trading mode

https://www.binance.com/en/support/faq/detail/9be58f73e5e14338809e3b705b9687dd
https://demo.binance.com/en/my/settings/api-management

:param boolean [enable]: True if demo trading should be enabled, False otherwise
z demo trading is not supported in the sandbox environment. Please check https://www.binance.com/en/support/faq/detail/9be58f73e5e14338809e3b705b9687dd to see the differencesr  apiBackupDemoTradingr  enableDemoTradingN)isSandboxModeEnabledr?   rO   r   omitr  )rt  r  newUrlss      rv  enable_demo_tradingbinance.enable_demo_trading
  s     $$tww  *Y   Y  Z  Z04		%0@DII,-#yy0DIIe#tyy0#yy)?@DIIeii		+ABGI,2()rx  c                   #    U R                  U R                  SSS5      nU R                  USU5      nU R                  US5      nSnU R	                  SSU5      u  pQSnU R                  X55      (       a  U R                  U5      I Sh  vN nOIU R                  X55      (       a  U R                  U5      I Sh  vN nOU R                  U5      I Sh  vN nU R                  US5      $  N` N2 N7f)a  
fetches the current integer timestamp in milliseconds from the exchange server

https://developers.binance.com/docs/binance-spot-api-docs/rest-api/general-endpoints#check-server-time          # spot
https://developers.binance.com/docs/derivatives/usds-margined-futures/market-data/rest-api/Check-Server-Time    # swap
https://developers.binance.com/docs/derivatives/coin-margined-futures/market-data/rest-api/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  rY   ry  N
serverTime)safe_string_2r  r  r  handle_sub_type_and_paramsr  fapiPublicGetTimer~  dapiPublicGetTimepublicGetTimer  )rt  paramsr  ry  queryrz  responses          rv  
fetch_timebinance.fetch_time
  s      (({MSYZ<		&&)99+tVT>>$((!33E::H__T++!33E::H!//66H  <88 ;:6s6   BC0	C*
/C09C,:C0C.C0,C0.C0c                   #    U R                  U R                  S5      nU(       d  0 $ U R                  S5      (       d  0 $ U R                  U R                  S5      nUb  0 $ U R                  U R                  SS5      (       a  0 $ U R                  U5      /nU R                  U R                  SS5      nU(       a   UR                  U R                  U5      5        [        R                  " U6 I Sh  vN nUS   nSnU(       a  US   n	U R                  U	S	5      n0 n
[        S[        U5      5       GH  nX{   nU R                  US
5      nU R                  US5      nU R                  U5      nU R                  US5      nSnSnSnU R                  US/ 5      n0 nSn0 n[        S[        U5      5       GH  nUU   nU R                  US5      nU R!                  U5      nUS:H  nU R#                  US5      nU R                  US5      nU R                  US5      nU=(       d    UnU=(       d    UnUUU'   U R                  US5      n U (       d  Uc  UnU R                  US5      n!U!n"[$        R&                  " U!S5      (       d  Uc  U!O[$        R(                  " UU!5      nONU(       dG  U(       d@  U R+                  U R                  US5      5      n"U"c  U R                  U R                  S5      n"UUUU=(       a    UUUUU R-                  U"5      U R#                  US5      U R#                  US5      S.U R#                  US5      SS.S.S.	UU'   GM     U R                  US5      n#U=(       a    U=(       a    U#n$U R/                  X0 5      n%UUUU(       a  S OS!U R-                  U5      UU$UUUUUU R0                  U R                  U%S"5      S#.X'   GM     U
$  GN7f)$aN  
fetches all available currencies on an exchange

https://developers.binance.com/docs/wallet/capital/all-coins-info
https://developers.binance.com/docs/margin_trading/market-data/Get-All-Margin-Assets

:param dict [params]: extra parameters specific to the exchange API endpoint
:returns dict: an associative dictionary of currencies
r   F	apiBackupNr  r  r   r   	assetNamecoinrP   isLegalMoneyTnetworkListnetworkETFwithdrawFeedepositEnablewithdrawEnable	isDefaultwithdrawIntegerMultipler  withdrawInternalMinr4  withdrawMinwithdrawMaxr  depositDustr   deposit)	r  rO   r  r  r  r   feer  r  r  fiatcryptoisBorrowable)rO   rP   r  ry  r  r  r  r  r   r/  r  r  r  rZ   )	safe_boolr  check_required_credentials
safe_valuer   sapiGetCapitalConfigGetallappendsapiGetMarginAllPairsasynciogatherindex_byr  r  r  safe_currency_code	safe_listnetwork_id_to_codesafe_numberrI   	string_eq
string_min	omit_zerorr  	safe_dictr  )&rt  r  fetchCurrenciesEnabledr  promisesr  resultsresponseCurrenciesmarginablesByIdresponseMarginablesresultr  entryrO   rP   r  isFiatminPrecisionisWithdrawEnabledisDepositEnabledr  r  r  r/  jnetworkItemr  networkCodeisETFr  r  r  r  precisionTickwithdrawPrecisionr  r  marginEntrys&                                         rv  fetch_currenciesbinance.fetch_currencies  s     "&>O!P%I
 ..u55IOODII{;	 I>>$,,(;UCCI33F;<~~dllNEJOOD66v>?11$QZ")!*"mm,?MOq#012A@ ')E!!%0B##E62D**2.D^^E>:FL $#..rBKDCH1c+./)!n**;	B"55g> E)"..{MJ ${O L!%=M!N#3#D} $5$G! +W NN;D	%C
 !% 0 0>W X$1!((<<5A5I=PWPbPbcoq~PL!% -1NN4;K;KKYn;o,p),4040@0@Oi0j-'!*+>, .&!%!2!23D!E $(#3#3K#O#'#3#3K#O%
 $(#3#3K#O#'$	)%? 0f nnUI6G'H,<HF..bAK "(h!..|< +-$++..nEFLY 3x G 2s   C/O1O2K(Oc                 8  #    / nSn/ SQnU R                  U R                  S5      nUb  U R                  USU5      nOU R                  U R                  SU5      nU R                  U R                  SS5      nU(       a(  U R	                  SU5      (       d  UR                  S5        U R                  U R                  SS5      nU R                  U R                  S	S5      nU=(       d    Un	/ n
[        S
[        U5      5       H'  nX;   nUS:X  a	  U	(       a  M  U
R                  U5        M)     U R                  U R                  SS5      n[        S
[        U
5      5       GH.  nX   nUS:X  a  UR                  U R                  U5      5        U(       ac  U R                  S5      (       aK  U	(       dB  UR                  U R                  U5      5        UR                  U R                  U5      5        M  M  M  M  US:X  a"  UR                  U R                  U5      5        M  US:X  a"  UR                  U R                  U5      5        M  US:X  a#  UR                  U R                  U5      5        GM  [        U R                   S-   U-   S-   5      e   ["        R$                  " U6 I Sh  vN n/ n/ U R                  S'   / U R                  S'   [        S
[        U5      5       H  nU R'                  X5      nU(       a~  [)        U[*        5      (       ai  [+        U R-                  US5      R/                  5       5      n[        U R                  S   5      nUS
:X  a  UU R                  S'   M  UU R                  S'   M  U R1                  USS/ 5      nU R3                  UU5      nM     U R                  S   (       a  U R5                  5       I Sh  vN   / n[        S
[        U5      5       H&  nUR                  U R7                  UU   5      5        M(     U$  GNl NJ7f)a  
retrieves data on all markets for binance

https://developers.binance.com/docs/binance-spot-api-docs/rest-api/general-endpoints#exchange-information           # spot
https://developers.binance.com/docs/derivatives/usds-margined-futures/market-data/rest-api/Exchange-Information     # swap
https://developers.binance.com/docs/derivatives/coin-margined-futures/market-data/rest-api/Exchange-Information     # future
https://developers.binance.com/docs/derivatives/option/market-data/Exchange-Information                             # option
https://developers.binance.com/docs/margin_trading/market-data/Get-All-Cross-Margin-Pairs                           # cross margin
https://developers.binance.com/docs/margin_trading/market-data/Get-All-Isolated-Margin-Symbol                       # isolated margin

:param dict [params]: extra parameters specific to the exchange API endpoint
:returns dict[]: an array of objects representing market data
Nr  r   r  r  Fr]   r  r  r   r  rY   r  r  z+ fetchMarkets() self.options fetchMarkets "z " is not a supported market typecrossMarginPairsDataisolatedMarginPairsDatar  symbolsoptionSymbolsr  )r  r  r  r  in_arrayr  r  r  publicGetExchangeInfor  r  sapiGetMarginIsolatedAllPairsfapiPublicGetExchangeInfodapiPublicGetExchangeInfoeapiPublicGetExchangeInfor0   rO   r  r  r  r  listr   keyssafe_list_2array_concatload_time_differenceparse_market)rt  r  promisesRawrawFetchMarketsdefaultTypesfetchMarketsOptionsr  r  demoMode	isDemoEnvr   r  ry  r  r  r  r  reskeysListlengthresultMarketsr  s                         rv  fetch_marketsbinance.fetch_markets  s     4"nnT\\>J*"nn-@'<XO #nnT\\><XO6FN==?;;&&x0nnT\\=%H>>$,,0CUK+	q#o./A"%DxI%	 0
 ~~dllNEJq#l+,A%JV#""4#=#=f#EFD$C$CE$J$JS\&&t'A'A&'IJ&&t'I'I&'QR T]$J< x'""4#A#A&#IJy(""4#A#A&#IJx'""4#A#A&#IJ#DGG.[$[^h$h  lN  %N  O  O -  44/1+,24./q#g,'A//'-C
3 5 5c8 < A A CDT\\*@ABQ;;CDLL!78>FDLL!:; $ 0 0iRT U++G]C (J <<12++---q#g,'AMM$++GAJ78 (] 5T .s&   J'P)P*D#PPAPPc                 |   SnSnSnU R                  US5      nU R                  US5      nUR                  S5      nU R                  US5      nU R                  US5      n	U R                  USU5      n
U R                  US5      nU R                  U
5      nU R                  U5      nU R                  US5      nSU;   nU R	                  US	S
5      nU R                  US5      nUS:X  d  US:X  a  S nSnOUb  SnSnUc  SOUnOUb  SnU R                  U5      nU(       + nU R                  US/ 5      nU R                  US5      nU R                  USS5      nS nU R                  nS nS nUS-   U-   nS nU(       a  U(       a	  US-   U-   nOU(       a  US-   U-   S-   U R                  U5      -   nOpU(       ai  U R                  U R                  U R                  US5      5      5      nUS-   U-   S-   U R                  U5      -   S-   U-   S-   U R                  US5      -   nU R                  USSU R                  S5      5      nUU:H  nUU:H  nU(       a  SOSnU R                  U R                  U0 5      nUS:H  nU(       a<  U R                  US/ 5      n[        S[!        U5      5       H  n UU    S:X  d  M  Sn  O   U R#                  US S5      n!S n"U(       aB  U R%                  X`R&                  S!   5      n#U R%                  X`R&                  S"   5      n$U#U$S#.n"OU(       d  U(       a  SSS#.n"S n%U(       a  S$n%OU(       a  S%n%OU(       a  S&n%OU(       a  S'n%S nS n&Ub  U R                  U5      n&0 S(U_S)U	_SU_S*U_S+U_S,U_S-U
_S.U_S/U_S0U%_S$U_S1U=(       a    U!_S2U"_S%U_S&U_S'U_S3U_UUUUS4   S5   US4   S6   UUU R)                  U5      U&U R                  US75      U R                  U R+                  U R                  US8S95      5      5      U R                  U R+                  U R                  US:S;5      5      5      U R                  U R+                  U R                  US<5      5      5      U R                  U R+                  U R                  US=5      5      5      S>.S S S?.U R-                  US@5      U R-                  USA5      S?.S S S?.S S S?.SB.UU R/                  USC5      SD.En'SEU;   aV  U R                  USE0 5      n(U R-                  U(SF5      U R-                  U(SG5      S?.U'SH   SI'   U R-                  U(SJ5      U'SK   SI'   SLU;   aV  U R                  USL0 5      n(U R-                  U(SM5      U'SK   SN'   U R-                  U(S@5      U R-                  U(SA5      S?.U'SH   SN'   SOU;   a>  U R                  USO0 5      n(U R-                  U(S@5      U R-                  U(SA5      S?.U'SH   SP'   SQU;   d  SRU;   aK  U R1                  USQSR0 5      n(U R                  U(SSST5      U'SH   SU   SV'   U R-                  U(SW5      U'SH   SU   SX'   U'$ )YNF
underlyingr  r  r   	baseAsset
quoteAssetcontractTypedeliveryDate
expiryDatemarginAsset	PERPETUALl    t?D	Tr  filters
filterTypestatuscontractStatusr  r  strikePricer=  r  unit1r  r  TRADINGpermissionsTRD_GRP_003isMarginTradingAllowedr  r   )r  isolatedrY   r[   r\   r]   rO   lowercaseIdr  r  r  r  r  r  ry  rZ   marginModesr  r  r  r  sidequantityPrecisionquantityScalepricePrecision
priceScalebaseAssetPrecisionquotePrecision)r  r  r  r  r  minQtymaxQty)r  r  r  r)  onboardDate)r  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  maxNotionalrS  )r  r  safe_string_lowerr  safe_integer_2r  r   r  r  yymmddnumber_to_stringparse_to_numericsafe_number_2rr  r  r  r  r  r#  r  iso8601parse_precisionr  r  safe_dict_2))rt  r  r[   r\   r]   r<  rO   r  
optionBaserP  r  r  r  r  r?  r  r  r  r  rY   rD  filtersByTyperF  r  r  r  r  r  r  feesTyper  rL  r  rN  rQ  hasCrossMarginhasIsolatedMarginunifiedTypeparsedStriker  filters)                                            rv  r.  binance.parse_market  s   %%fl;
fh/hhsm%%k15
,,VX>!!&+zB""6<8&&v.''0''?"f,$$V^\J##FM:K'V}-DFD#HF"*"2vHF((2|..B7g|<##FH6FGyye##.#.4t{{67JJ..t/D/DTEUEUV\^kEl/mn#.4t{{67JJSPSYY\__bfbrbrs~  AB  cC  C--fnfdN_N_`cNdeLu_FnG#)xyH>>$))Xr:DI%..CK1c+./q>]2"F 0 "&8PRW!X!]]2||<R/STN $b,,?X2Y Z'-K w K  K K"K"KF008L6
"6
;6
 f6
 D	6

 U6
 f6
 f6
 w6
 6
 K6
 D6
 d556
 ;6
 D6
 f6
  f!6
" f#6
$ !)_W-)_W-("ll62"00@++D,@,@ASASTZ\o  rA  BB  -C  D**4+?+?@R@RSY[kmy@z+{|))$*>*>t?O?OPVXl?m*no**4+?+?@P@PQWYi@j+kl	  
  ++FH=++FH=
  
  $ ((?k6
n ]*^^M>2FF ''
;''
;(E(OG$ +/*:*:6:*NE+w'&^^M:rBF+/+;+;FJ+OE+x(''9''9)E(OH% -^^M3DbIF''9''9)E(OH% m+}1L%%m^ZQSTF-1-?-?Wa-bE(OF#E*-1-=-=fm-TE(OF#E*rx  c                     U R                  5       nU R                  US5      US'   U R                  US5      US'   U R                  US5      nU R                  US5      n[        R                  " XC5      US'   U$ )Nlockedusedfreeinterestborroweddebt)rt  r  rI   
string_add)rt  r  rt  r  r  s        rv  parse_balance_helperbinance.parse_balance_helper  sv    ,,.**5(;**5&9##E:6z2!,,T<rx  Fc                 j   SU0nS nUS:H  nUS:H  =(       d    US:H  nU(       Ga  [        S[        U5      5       GH  n	X   n
U R                  5       nU R                  U
S5      nU R	                  U5      nUS:X  a,  U R                  U
S5      US	'   U R                  U
S
5      US'   GOUS:X  a+  U R                  U
S5      US	'   U R                  U
S5      US'   OU(       a}  U R                  U
S5      nU R                  U
S5      n[
        R                  " X5      US'   U R                  U
S5      US	'   U R                  U
S5      US'   U R                  U
S5      US'   OgU R                  U
S
5      nU R                  U
S5      n[
        R                  " UU5      nU R                  U
S5      n[
        R                  " UU5      US'   XU'   GM     GO5U(       d  US:X  d  U(       a  U R                  US5      nU R                  USS/ 5      n[        S[        U5      5       H  n	UU	   nU R                  US5      nU R	                  U5      nU R                  5       nU R                  US	5      US	'   U R                  US5      US'   U(       a>  U R                  US5      nU R                  US5      n[
        R                  " UU5      US'   XU'   M     GO2U(       Ga  U R                  US5      n[        S[        U5      5       H  n	UU	   nU R                  US5      nU R                  US S S5      nU R                  US 0 5      nU R                  US!0 5      nU R	                  U R                  US5      5      nU R	                  U R                  US5      5      n0 nU R                  U5      UU'   U R                  U5      UU'   U R                  U5      UU'   M     GO)US":X  a  U R                  US#/ 5      n [        S[        U 5      5       H[  n	U U	   n
U R                  U
S5      nU R	                  U5      nU R                  5       nU R                  U
S$5      n!U!US'   U!US'   XU'   M]     GOUS%:X  a  [        S[        U5      5       H  n	X   n
U R                  5       nU R                  U
S5      nU R	                  U5      nU R                  U
S	5      US	'   U R                  U
S&5      n"U R                  U
S'5      n#U R                  U
S5      n$[
        R                  " U"[
        R                  " U$U#5      5      US'   XU'   M     OUn[        U[        5      (       d  U R                  US/ 5      n[        S[        U5      5       H  n	UU	   nU R                  US5      nU R	                  U5      nU R                  5       nU R                  US(5      US	'   U R                  US)5      US'   U R!                  US*S+5      US'   XU'   M     XeS,'   U R#                  U5      US-'   U(       a  U$ U R                  U5      $ ).Nr  rO  rZ   r  r   assetr  umWalletBalancer~  umUnrealizedPNLr}  r  cmWalletBalancecmUnrealizedPNLcrossMarginBorrowedcrossMarginInterestr  crossMarginFreecrossMarginLockedcrossMarginAssettotaltotalWalletBalancerY   
updateTimebalances
userAssetsr|  r  r  assetsr  r=  r>  savingspositionAmountVosr  r  freezewithdrawingavailableBalanceinitialMarginmarginBalancers  r  r  )r  r  rt  r  r  rI   r  r  r+  r  safe_symbolr  r  safe_balancer  r)  r  ro  )%rt  r  ry  r>  isPortfolioMarginr  r  rO  r  r  r  rt  
currencyIdr  r  r  
usedLinearusedInverse	totalUsedr  r  rs  r  r  r  r  r  r  r  baseCode	quoteCode	subResultr  usedAndTotalfrozenr  r|  s%                                        rv  parse_balance_custombinance.parse_balance_custom  s   H
 	+!=zW'<1c(m, ,,.!--eW=
..z:8#&*&6&6u>O&PGFO&*&6&6u>O&PGFOY&&*&6&6u>O&PGFO&*&6&6u>O&PGFO#//7LMH#//7LMH&-&8&8&LGFO&*&6&6u>O&PGFO&*&6&6u>Q&RGFO'+'7'7?Q'RGG$!%!1!1%9J!KJ"&"2"25:K"LK ' 2 2:{ KI)-)9)9%AU)V&'.'9'9)EW'XGG$&t1 -2 5))(LAI''*lBOH1c(m,"1+!--gw?
..z:,,."&"2"27F"C"&"2"27H"E++GZ@D#//DH&-&8&8x&HGFO&t - ^^Hh7F1c&k*q	++E8<))(D$G~~e["=ulB?2243C3CD'3RS 33D4D4DUG4TU	"$	&*&?&?&E	(#'+'@'@'G	)$!%!2!29!=v + Y $x9Lb Q1c"345)!,!--eW=
..z:,,.#//x@#/ ".&t 6 Y1c(m, ,,.!--eW=
..z:"&"2"25&"A))%:"..umD))%:")"4"4VW=O=OPVXc=d"e&t -  Hh-->>(HbA1c(m,"1+!--gw?
..z:,,."&"2"27<N"O"&"2"27O"L#'#5#5gPY#Z &t - ({!\\)4z!v@t'8'8'@@rx  c                   #    U R                  5       I Sh  vN   U R                  U R                  SSS5      nU R                  USU5      nSnU R	                  SSU5      u  pASnU R                  USSSS5      u  pQSnSnU R                  SU5      u  pgU R                  US5      nSn0 n	U(       d  US:X  a]  U R                  X45      (       a  S	nOU R                  X45      (       a  S
nSnU R                  U R                  X5      5      I Sh  vN nGO<U R                  X45      (       ah  S	nSn
U R                  USSS5      u  pU R                  X5      nU
(       d  U R                  U5      I Sh  vN nGOU R                  U5      I Sh  vN nGOU R                  X45      (       a,  S
nU R                  U R                  X5      5      I Sh  vN nGO|US:X  a  U R!                  US5      nU R                  US5      nUbk  Sn[#        U[$        5      (       aN  U R'                  US   5      n[)        S[+        U5      5       H   nX   nU R'                  U5      nUSU-   -  nM"     OUnXS'   U R-                  U R                  X5      5      I Sh  vN nOUS:X  d  US:X  a)  U R/                  U R                  X5      5      I Sh  vN nOUS:X  a)  U R1                  U R                  X5      5      I Sh  vN nOWUS:X  a)  U R3                  U R                  X5      5      I Sh  vN nO(U R5                  U R                  X5      5      I Sh  vN nU R7                  XXe5      $  GNL GNX GN GN GN N N N NT N-7f)a   
query for balance and get the amount of funds available for trading or funds locked in orders

https://developers.binance.com/docs/binance-spot-api-docs/rest-api/account-endpoints#account-information-user_data  # spot
https://developers.binance.com/docs/margin_trading/account/Query-Cross-Margin-Account-Details                       # cross margin
https://developers.binance.com/docs/margin_trading/account/Query-Isolated-Margin-Account-Info                       # isolated margin
https://developers.binance.com/docs/wallet/asset/funding-wallet                                                     # funding
https://developers.binance.com/docs/derivatives/usds-margined-futures/account/rest-api/Futures-Account-Balance-V2   # swap
https://developers.binance.com/docs/derivatives/coin-margined-futures/account/rest-api/Futures-Account-Balance      # future
https://developers.binance.com/docs/derivatives/option/account/Option-Account-Information                           # option
https://developers.binance.com/docs/derivatives/portfolio-margin/account/Account-Balance                            # 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>`
Nr   r  rY   ry  r  rm  Fr  r  TuseV2rO  r!   r   r   ,rZ   r  r  r  )load_marketsr  r  r  r  handle_option_and_params_2handle_margin_mode_and_paramsr  r  r~  papiGetBalanceextendhandle_option_and_paramsfapiPrivateV3GetAccountfapiPrivateV2GetAccountdapiPrivateGetAccountr  r  r)  	market_idr  r  sapiGetMarginIsolatedAccountsapiGetMarginAccountsapiGetLendingUnionAccountsapiPostAssetGetFundingAssetprivateGetAccountr  )rt  r  r  ry  rz  r  r>  r  r  requestr  paramSymbolsr!  r  r  rO   s                   rv  fetch_balancebinance.fetch_balance4  s7    * !!!((~}V\]<99.$PVW $($C$CFN\bduw|$}!
 >>~vV
		%(~~d,,//  $!00W1LMMH^^D**DE 99&.RY[`aME[[0F!%!=!=f!EE!%!=!=f!EE__T++D!77G8STTH:%>>&)<LIIeY/E'lD11"nn\!_=G"1c,&78!-!^^F338+ 9
 +G%,	"!>>t{{7?Z[[HhJ'$9!66t{{77RSSHY!<<T[[=XYYHY!>>t{{7?Z[[H!33DKK4OPPHj ((WWW 	"& N FE U \SY[Ps   M;M"C6M;M%A"M;0M(1M;M+AM;M.CM;M14M;M3.M;3M54.M;"M7#(M;M9M;%M;(M;+M;.M;1M;3M;5M;7M;9M;r  c                   #    U R                  5       I Sh  vN   U R                  U5      nSUS   0nUb  X%S'   SnUS   (       a)  U R                  U R                  XS5      5      I Sh  vN nOUS   (       a)  U R	                  U R                  XS5      5      I Sh  vN nO[US   (       a)  U R                  U R                  XS5      5      I Sh  vN nO(U R                  U R                  XS5      5      I Sh  vN nU R                  US5      nU R                  XaU5      nU R                  US	S
5      US'   U$  GN# N N Np NI7f)a  
fetches information on open orders with bid(buy) and ask(sell) prices, volumes and other data

https://developers.binance.com/docs/binance-spot-api-docs/rest-api/market-data-endpoints#order-book     # spot
https://developers.binance.com/docs/derivatives/usds-margined-futures/market-data/rest-api/Order-Book   # swap
https://developers.binance.com/docs/derivatives/coin-margined-futures/market-data/rest-api/Order-Book   # future
https://developers.binance.com/docs/derivatives/option/market-data/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  rO   r  r]   r  r  TlastUpdateIdur  )
r  r  eapiPublicGetDepthr  fapiPublicGetDepthdapiPublicGetDepthpublicGetDepthr  parse_order_bookrj  )	rt  r  r  r  r  r  r  r  	orderbooks	            rv  fetch_order_bookbinance.fetch_order_book6  s/     !!!V$fTl
 $G(!44T[[5QRRHH!44T[[5QRRHI!44T[[5QRRH!00W1MNNHJ %%h4	))(IF	!00>3O	'o 	" SRRNsY   ED9AE)D<*2ED>2EE (E8E9AE<E>E EEr  c           
         U R                  USS5      nS nSU;   a  SnUc
  SU;   a  SOSnU R                  US5      nU R                  XRS U5      nU R                  US5      nU R                  US5      nS	U;   n	S n
S nU	(       a)  U R                  US	5      n
[        R                  " X5      nO%U R                  US
5      n
U R                  USS5      nU R                  0 SU_SU_SU R                  U5      _SU R                  USS5      _SU R                  USS5      _SU R                  US5      _SU R                  US5      _SU R                  US5      _SU R                  US5      _SU_SU R                  USS5      _SU_SU_SU R                  US 5      _S!U R                  US"5      _S#U R                  US$5      _S%S _U
UU R                  US&5      U R                  US'5      US(.EU5      $ ))N	closeTimerM  r  bidQtyrY   r  	lastPriceweightedAvgPrice
baseVolumevolumequoteVolumer  r  r  high	highPricelowlowPricebidbidPrice	bidVolumeaskaskPrice	askVolumeaskQtyvwapopen	openPricecloserQ  previousCloseprevClosePricechangepriceChanger  priceChangePercentaverage	markPrice
indexPrice)r  r  r  r  r  )rj  r  r  rI   
string_mulr  safe_tickerro  )rt  r  r  r  r  r  r  rQ  wAvgisCoinmr  r  s               rv  parse_tickerbinance.parse_ticker}  s   V ''VD	
f#J$,$6ZJ##FH5!!(D*E4(:;6)
))&,?J!,,Z>K))&(;J,,V]HMK !
f!
!
 Y/!
 D&&v{FC	!

 4%%fj%@!
 4##FJ7!
 ))&(;!
 4##FJ7!
 ))&(;!
 D!
 D&&v{FC!
 T!
 D!
 T--f6FG!
 d&&v}=!
  $**63GH!!
" t#!
$ %&))&+>**6<@-!
. / 	rx  c                    #    U R                  U5      I Sh  vN nU R                  US5      nU R                  SSS.X35      SSSUS.$  N17f)a1  
the latest known information on the availability of the exchange API

https://developers.binance.com/docs/wallet/others/system-status

:param dict [params]: extra parameters specific to the exchange API endpoint
:returns dict: a `status structure <https://docs.ccxt.com/#/?id=exchange-status-structure>`
NrF  okmaintenance)r  rJ  )rF  updatedetar  r  )sapiGetSystemStatusr  )rt  r  r  	statusRaws       rv  fetch_statusbinance.fetch_status5  s^      11&99 $$Xx8	&&T'F	]
 	
 :s   AA	2Ac                 L  #    U R                  5       I Sh  vN   U R                  U5      nSUS   0nSnUS   (       a)  U R                  U R                  XB5      5      I Sh  vN nOUS   (       a)  U R	                  U R                  XB5      5      I Sh  vN nOUS   (       a)  U R                  U R                  XB5      5      I Sh  vN nO}U R                  USS5      nU R                  US5      nU(       a)  U R                  U R                  XB5      5      I Sh  vN nO(U R                  U R                  XB5      5      I Sh  vN n[        U[        5      (       a$  U R                  US	0 5      nU R                  Xs5      $ U R                  XS5      $  GN GN6 GN N N N[7f)
a  
fetches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market

https://developers.binance.com/docs/binance-spot-api-docs/rest-api/market-data-endpoints#24hr-ticker-price-change-statistics     # spot
https://developers.binance.com/docs/binance-spot-api-docs/rest-api/market-data-endpoints#rolling-window-price-change-statistics  # spot
https://developers.binance.com/docs/derivatives/usds-margined-futures/market-data/rest-api/24hr-Ticker-Price-Change-Statistics   # swap
https://developers.binance.com/docs/derivatives/coin-margined-futures/market-data/rest-api/24hr-Ticker-Price-Change-Statistics   # future
https://developers.binance.com/docs/derivatives/option/market-data/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  rO   r]   r  r  rollingFr   )r  r  eapiPublicGetTickerr  fapiPublicGetTicker24hrdapiPublicGetTicker24hrr  r  publicGetTickerpublicGetTicker24hrr  r)  r  r  )rt  r  r  r  r  r  r  firstTickers           rv  fetch_tickerbinance.fetch_tickerN  sb     !!!V$fTl
 (!55dkk'6RSSHH!99$++g:VWWHI!99$++g:VWWHnnVY>GYYvy1F!%!5!5dkk'6R!SS!%!9!9$++g:V!WWh%%..1b9K$$[99  22- 	" TWW
 TWsl   F$FAF$"F#2F$F2F$F	AF$F (F$F"AF$F$F$F$ F$"F$r!  c                   #    U R                  5       I Sh  vN   U R                  USSSS5      nU R                  U5      nSnU R                  SX25      u  pBSnU R	                  SX25      u  pRSnU R                  XE5      (       a  U R                  U5      I Sh  vN nOU R                  XE5      (       a  U R                  U5      I Sh  vN nOuUS:X  aQ  0 nUb#  U R                  U R                  U5      5      US'   U R                  U R                  Xr5      5      I Sh  vN nO[        U R                  S-   U-   S-   5      eU R                  Xa5      $  GN? N N N;7f)a  
fetches the bid and ask price and volume for multiple markets

https://developers.binance.com/docs/binance-spot-api-docs/rest-api/market-data-endpoints#symbol-order-book-ticker   # spot
https://developers.binance.com/docs/derivatives/usds-margined-futures/market-data/rest-api/Symbol-Order-Book-Ticker  # swap
https://developers.binance.com/docs/derivatives/coin-margined-futures/market-data/rest-api/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>`
NTr   rY   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  r?   rO   parse_tickers)rt  r!  r  r  ry  rz  r  r  s           rv  fetch_bids_asksbinance.fetch_bids_asksu  sL     !!!%%gtT4F--g699/6Z99/6Z>>$((!??GGH__T++!??GGHV^G"%)YYtw/G%H	"!;;DKK<XYYHtww)MMPTTWeeff!!(44' 	" HG
 ZsG   EEBEE/E	E
AE E!5EEEEc                 R  #    U R                  5       I Sh  vN   U R                  USSSS5      nU R                  U5      nSnU R                  SX25      u  pBSnU R	                  SX25      u  pRSnU R                  XE5      (       a  U R                  U5      I Sh  vN nOnU R                  XE5      (       a  U R                  U5      I Sh  vN nO>US:X  a  U R                  U5      I Sh  vN nO[        U R                  S-   U-   S-   5      eU R                  Xa5      $  GN N NY N;7f)a  
fetches the last price for multiple markets

https://developers.binance.com/docs/binance-spot-api-docs/rest-api/market-data-endpoints#symbol-price-ticker    # spot
https://developers.binance.com/docs/derivatives/usds-margined-futures/market-data/rest-api/Symbol-Price-Ticker  # swap
https://developers.binance.com/docs/derivatives/coin-margined-futures/market-data/rest-api/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   rY   z$ fetchLastPrices() does not support r  )r  r  r	  r
  r  r  fapiPublicV2GetTickerPricer~  dapiPublicGetTickerPricepublicGetTickerPricer?   rO   parse_last_pricesrt  r!  r  r  ry  rz  r  s          rv  fetch_last_pricesbinance.fetch_last_prices  s'     !!!%%gtT4F--g699:KV\99:KV\>>$((!<<VDDH __T++!::6BBH V^!66v>>H tww)OORVVYgghh%%h88[ 	" E C ?sF   D'DBD'D!/D'	D#
D')D%*5D'!D'#D'%D'c                     U R                  US5      nUc  SOSnU R                  US5      nU R                  XRS U5      nUS   UU R                  U5      U R	                  US5      S US.$ )NrM  rY   r[   r  r  )r  r  r  r  rR  r  )r  r  r  ro  safe_number_omit_zero)rt  r  r  r  ry  r  s         rv  parse_last_pricebinance.parse_last_price  s    6 %%eV4	#+v&##E84!!(D$?X&"Y///w?
 	
rx  c                 @  #    U R                  5       I Sh  vN   U R                  USSSS5      nU R                  U5      nSnU R                  SX25      u  pBSnU R	                  SX25      u  pRSnU R                  XE5      (       a  U R                  U5      I Sh  vN nGO^U R                  XE5      (       a  U R                  U5      I Sh  vN nGO-US:X  a  U R                  USS5      nU R                  US5      nU(       al  U R                  U5      nSU R                  U R                  U5      5      0nU R                  U R                  X5      5      I Sh  vN nU R                  Xa5      $ 0 nUb#  U R                  U R                  U5      5      US'   U R!                  U R                  X5      5      I Sh  vN nO>US:X  a  U R#                  U5      I Sh  vN nO[%        U R&                  S	-   U-   S
-   5      eU R)                  Xa5      $  GN GNy GNK N N_ NA7f)aY  
fetches price tickers for multiple markets, statistical information calculated over the past 24 hours for each market

https://developers.binance.com/docs/binance-spot-api-docs/rest-api/market-data-endpoints#24hr-ticker-price-change-statistics    # spot
https://developers.binance.com/docs/derivatives/usds-margined-futures/market-data/rest-api/24hr-Ticker-Price-Change-Statistics  # swap
https://developers.binance.com/docs/derivatives/coin-margined-futures/market-data/rest-api/24hr-Ticker-Price-Change-Statistics  # future
https://developers.binance.com/docs/derivatives/option/market-data/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"
:param str [params.type]: 'spot', 'option', use params["subType"] for swap and future markets
:returns dict: a dictionary of `ticker structures <https://docs.ccxt.com/#/?id=ticker-structure>`
NTr   rY   r  Fr!  r]   z! fetchTickers() does not support r  )r  r  r	  r
  r  r  r  r~  r   r  r  r  r  r  r  parse_tickers_for_rollingr  r  r?   rO   r  )	rt  r!  r  r  ry  rz  r  r  r  s	            rv  fetch_tickersbinance.fetch_tickers  s     !!!%%gtT4F--g699.&Y99.&Y>>$((!99&AAH__T++!99&AAHV^nnVY>GYYvy1F--g6tyy)AB! "&!5!5dkk'6R!SS55hHH "&)-4??73K)LGI&!%!9!9$++g:V!WWX!55f==Htww)LLtSVddee!!(44A 	" BA T X=sl   HHBHH0H
HBHHA H:H;HH5HHHHHHc                    / n[        S[        U5      5       HW  nU R                  X   S5      nU R                  US S S5      nU R	                  X   5      nUS   US'   UR                  U5        MY     U R                  USU5      $ )Nr   r  rY   )r  r  r  r  r  r  filter_by_array)rt  r  r!  r  r  r  tickerMarketparsedTickers           rv  r   !binance.parse_tickers_for_rolling,  s    q#h-(A''X>H++HdD&IL,,X[9L%1(%;L"NN<( ) ##GXw??rx  c                   #    U R                  5       I Sh  vN   U R                  U5      nSnU R                  SX2S5      u  pBSnU R                  SX2S5      u  pRSUS   0nSnU R	                  XE5      (       a)  U R                  U R                  Xb5      5      I Sh  vN nO]U R                  XE5      (       a)  U R                  U R                  Xb5      5      I Sh  vN nO[        U R                  S-   U-   S-   5      e[        U[        5      (       a#  U R                  U R                  US	0 5      U5      $ U R                  Xs5      $  GN2 N Nq7f)
a+  
fetches mark price for the market

https://developers.binance.com/docs/derivatives/coin-margined-futures/market-data/rest-api/Index-Price-and-Mark-Price
https://developers.binance.com/docs/derivatives/usds-margined-futures/market-data/rest-api/Mark-Price

: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 str [params.subType]: "linear" or "inverse"
:returns dict: a dictionary of `ticker structures <https://docs.ccxt.com/#/?id=ticker-structure>`
Nr   r[   r  r  rO   z# fetchMarkPrice() does not support r  r   )r  r  r
  r  r  fapiPublicGetPremiumIndexr  r~  dapiPublicGetPremiumIndexr?   rO   r  r)  r  r  )rt  r  r  r  ry  rz  r  r  s           rv  fetch_mark_pricebinance.fetch_mark_price6  s;     !!!V$99:JF\bc99:JF\defTl
 >>$((!;;DKK<XYYH__T++!;;DKK<XYYHtww)NNQUUXffggh%%$$T^^Ha%DfMM  22% 	" ZYs5   EEBEE>EEA-EEEc                   #    U R                  5       I Sh  vN   U R                  USSSS5      nU R                  U5      nSnU R                  SX2S5      u  pBSnU R	                  SX2S5      u  pRSnU R                  XE5      (       a  U R                  U5      I Sh  vN nONU R                  XE5      (       a  U R                  U5      I Sh  vN nO[        U R                  S-   U-   S-   5      eU R                  Xa5      $  N Nf N87f)aj  
fetches mark prices for multiple markets

https://developers.binance.com/docs/derivatives/coin-margined-futures/market-data/rest-api/Index-Price-and-Mark-Price
https://developers.binance.com/docs/derivatives/usds-margined-futures/market-data/rest-api/Mark-Price

: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   r[   r  z$ fetchMarkPrices() does not support r  )r  r  r	  r
  r  r  r)  r~  r*  r?   rO   r  r  s          rv  fetch_mark_pricesbinance.fetch_mark_pricesV  s     !!!%%gtT4F--g699:KV]cd99:KV]ef>>$((!;;FCCH__T++!;;FCCHtww)OORVVYgghh!!(44 	" DCs4   DD BDD/DD5DDDc           
         U R                  US5      nU(       a  SOSnU R                  USS5      U R                  USS5      U R                  USS	5      U R                  US
S5      U R                  USS5      U R                  XS5      /$ )Nr  rT  r&  r   openTimer   r  r  r  r=  r  r  r  r  )r  rj  rn  )rt  ohlcvr  r  volumeIndexs        rv  parse_ohlcvbinance.parse_ohlcvr  s    h ..3"aq*5ua0ua0ua/ua1u8<
 	
rx  r   	timeframesincec           	      @  #    U R                  5       I Sh  vN   SnU R                  USSS5      u  peU(       a  U R                  SXXBUS5      I Sh  vN $ U R                  U5      nSnSn	U R	                  US5      n
U R                  US	5      nU R                  USS	/5      nUb  Ub  Uc  U	nUc  UO
[        XI5      nU R	                  U R                  X"5      US
.nUS   nU
S:X  a(  UR                  S5      nU R	                  US5      nXS'   OXS'   Ub^  X<S'   US   (       aP  US:  aJ  U R                  U5      nU R                  X4U-  S-  S-
  5      nU R                  5       n[        UU5      US'   Ub  XS'   SnUS   (       a*  U R                  U R                  X5      5      I Sh  vN nGOU
S:X  a^  US   (       a*  U R                  U R                  X5      5      I Sh  vN nGO}U R!                  U R                  X5      5      I Sh  vN nGOSU
S:X  a]  US   (       a*  U R#                  U R                  X5      5      I Sh  vN nGOU R%                  U R                  X5      5      I Sh  vN nOU
S:X  a\  US   (       a)  U R'                  U R                  X5      5      I Sh  vN nOU R)                  U R                  X5      5      I Sh  vN nOUS   (       a)  U R+                  U R                  X5      5      I Sh  vN nO[US   (       a)  U R-                  U R                  X5      5      I Sh  vN nO(U R/                  U R                  X5      5      I Sh  vN nU R1                  UXrX45      nU$  GNi GN0 GN GN GN{ GND GN N N N N] N67f)a&  
fetches historical candlestick data containing the open, high, low, and close price, and the volume of a market

https://developers.binance.com/docs/binance-spot-api-docs/rest-api/market-data-endpoints#klinecandlestick-data
https://developers.binance.com/docs/derivatives/option/market-data/Kline-Candlestick-Data
https://developers.binance.com/docs/derivatives/usds-margined-futures/market-data/rest-api/Kline-Candlestick-Data
https://developers.binance.com/docs/derivatives/usds-margined-futures/market-data/rest-api/Index-Price-Kline-Candlestick-Data
https://developers.binance.com/docs/derivatives/usds-margined-futures/market-data/rest-api/Mark-Price-Kline-Candlestick-Data
https://developers.binance.com/docs/derivatives/usds-margined-futures/market-data/rest-api/Premium-Index-Kline-Data
https://developers.binance.com/docs/derivatives/coin-margined-futures/market-data/rest-api/Kline-Candlestick-Data
https://developers.binance.com/docs/derivatives/coin-margined-futures/market-data/rest-api/Index-Price-Kline-Candlestick-Data
https://developers.binance.com/docs/derivatives/coin-margined-futures/market-data/rest-api/Mark-Price-Kline-Candlestick-Data
https://developers.binance.com/docs/derivatives/coin-margined-futures/market-data/rest-api/Premium-Index-Kline-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 [available parameters](https://github.com/ccxt/ccxt/wiki/Manual#pagination-params)
:returns int[][]: A list of candles ordered, open, high, low, close, volume
NFr   paginaterR  rQ  rV  r  until)intervalr  rO   r  _r   pairr  	startTimer  r   endTimer]   r  rW  r  )r  r  "fetch_paginated_call_deterministicr  r  r  r  r  r   r  parse_timeframesumr  eapiPublicGetKlinesr  dapiPublicGetMarkPriceKlinesfapiPublicGetMarkPriceKlinesdapiPublicGetIndexPriceKlinesfapiPublicGetIndexPriceKlinesdapiPublicGetPremiumIndexKlinesfapiPublicGetPremiumIndexKlinesfapiPublicGetKlinesdapiPublicGetKlinespublicGetKlinesparse_ohlcvs)rt  r  r6  r7  r  r  r9  r  defaultLimitmaxLimitr  r:  r  r  partsr=  durationr?  nowr  candless                        rv  fetch_ohlcvbinance.fetch_ohlcv  sd    2 !!!88z[`a@@v^cpvx|}}}V$   1!!&'26GW#56!2u}E!&S5I(()O
 $<GNN3'E##E1-D"FO (H#(K 
 i 19#33I>H"hhuh.>.E.IJG++-C),S'):GI&!&I(!55dkk'6RSSHf_i !%!B!B4;;wC_!``!%!B!B4;;wC_!``gi !%!C!CDKKPWD`!aa!%!C!CDKKPWD`!aan$i !%!E!EdkkRYFb!cc!%!E!EdkkRYFb!ccH!55dkk'6RSSHI!55dkk'6RSSH!11$++g2NOOH6 ##HfN{ 	" ~P T a` ba dcSSOs   NM?;NNEN,N-9N&N')NN9N
N)N4N58N-N.(NN2N	N
2N<N=(N%N&NNNNNNNNNNNNtradec                    SU;   a  U R                  X5      $ U R                  USS5      nU R                  USS5      nU R                  USU5      nU R                  US5      nSU;   =(       d    S	U;   =(       d    S
U;   =(       d    SU;   nU(       a  SOSnU R	                  XRS U5      nUS   nS n	U R                  USS5      n
S nU
b  U
(       a  SOSn	O-SU;   a  U R                  US5      n	OSU;   a  US   (       a  SOSn	S nSU;   a4  U R                  US5      U R                  U R                  US5      5      S.nSU;   a  US   (       a  SOSnSU;   a  US   (       a  SOSnSU;   d
  US   (       a  U R                  U R                  USS5      5      nU R                  US5      nSU;   a  U R                  US5      US.nU	S:w  a  U	S:w  a
  U	S:X  a  SOSn	SU;   a  U	S:w  a  [        R                  " S U5      nU R                  UUU R                  U5      UU R                  U/ S!Q5      U R                  US"5      U R                  US#5      U	UU R                  US$S%5      UU R                  US&S'5      US(.U5      $ ))NisDustTrader  rM  qqtyquantityr  
isIsolatedMorderListIdisMakerrY   r  misBuyerMakersellbuyrR  isBuyer
commissioncommissionAsset)r)  currencyr  r  
optionSider]   r>  r  	liquidityr  rJ  -1)tatradeIdrO   orderIdry  pr  quoteQtybaseQty)r  r  r  r  rO   ro  ry  rR  takerOrMakerr  r  r)  r  )parse_dust_traderj  r  r  r  safe_bool_2ri  r  rI   r  
safe_tradero  safe_string_n)rt  rV  r  r  r  r  isSpotTrader  r  rR  
buyerMakerrr  r  r  s                 rv  parse_tradebinance.parse_trade)  s   E!((77J ''sF;	##E36!!%V<##E84#u,s#,sMUZDZs`imr`r*V

!!(D*E!%%eS.A
!'6UDu_))%8DE! %i 0uf5 ((= 33D4D4DUL]4^_C &+I&67GLe&+Gn7'LE!fX&6,,T-=-=e\SY-Z[F11%EL~ ,,UE: & DFN!%u6u$5=$//f=F"Y/$$U,GH%%eY7**5&9(''sG<&&uj)D 
  	rx  c                 v  #    U R                  5       I Sh  vN   SnU R                  USS5      u  pTU(       a  U R                  SXX45      I Sh  vN $ U R                  U5      nSUS   0nUS   (       d5  Ub  X'S'   U R	                  US	5      US
'   U R                  US5      nUb  XS
'   U R                  U R                  S5      n	U R                  USSU	5      n	UbR  US   =(       d    US   n
U	SL=(       a    U	R                  S5      S:  nU(       a  SOSnU
(       a  [        X<5      OUUS'   U R                  USS/5      nSnUS   (       d  U	S:X  a)  U R                  U R                  Xt5      5      I Sh  vN nOUS   (       d  U	S:X  a)  U R                  U R                  Xt5      5      I Sh  vN nOaUS   (       d  U	S:X  a)  U R                  U R                  Xt5      5      I Sh  vN nO(U R!                  U R                  Xt5      5      I Sh  vN nU R#                  XX#5      $  GN GN N N NI N"7f)aH  
       get the list of most recent trades for a particular symbol
Default fetchTradesMethod

       https://developers.binance.com/docs/binance-spot-api-docs/rest-api/market-data-endpoints#compressedaggregate-trades-list    # publicGetAggTrades(spot)
       https://developers.binance.com/docs/derivatives/usds-margined-futures/market-data/rest-api/Compressed-Aggregate-Trades-List  # fapiPublicGetAggTrades(swap)
       https://developers.binance.com/docs/derivatives/coin-margined-futures/market-data/rest-api/Compressed-Aggregate-Trades-List  # dapiPublicGetAggTrades(future)
       https://developers.binance.com/docs/derivatives/option/market-data/Recent-Trades-List                                       # eapiPublicGetTrades(option)

Other fetchTradesMethod

       https://developers.binance.com/docs/binance-spot-api-docs/rest-api/market-data-endpoints#recent-trades-list                 # publicGetTrades(spot)
       https://developers.binance.com/docs/derivatives/usds-margined-futures/market-data/rest-api/Recent-Trades-List               # fapiPublicGetTrades(swap)
       https://developers.binance.com/docs/derivatives/coin-margined-futures/market-data/rest-api/Recent-Trades-List               # dapiPublicGetTrades(future)
       https://developers.binance.com/docs/binance-spot-api-docs/rest-api/market-data-endpoints#old-trade-lookup                   # publicGetHistoricalTrades(spot)
       https://developers.binance.com/docs/derivatives/usds-margined-futures/market-data/rest-api/Old-Trades-Lookup                # fapiPublicGetHistoricalTrades(swap)
       https://developers.binance.com/docs/derivatives/coin-margined-futures/market-data/rest-api/Old-Trades-Lookup                # dapiPublicGetHistoricalTrades(future)
       https://developers.binance.com/docs/derivatives/option/market-data/Old-Trades-Lookup                                        # 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   r9  r  rO   r]   r>  i6 r?  r:  fetchTradesMethodmethodr[   r\   GetHistoricalTradesr   rQ  rR  r  eapiPublicGetTradesr  fapiPublicGetAggTradesr  dapiPublicGetAggTrades)r  r  fetch_paginated_call_dynamicr  rB  r  r  r  r  r  r  r  r  r  r  r  publicGetAggTradesparse_trades)rt  r  r7  r  r  r9  r  r  r:  r}  isFutureOrSwapisHistoricalEndpointmaxLimitForContractHistoricalr  s                 rv  fetch_tradesbinance.fetch_trades)  s1    @ !!!88PZ[::=&Y^gggV$fTl
 h ',$ &*XXeW%=	"%%fg6E %*	"!!$,,0CD##F,?6R$Vn@x0@N$*$$6#eV[[I^=_cd=d 3GCT)LZs5H`eGG6G-@#AB(v)>>!55dkk'6RSSHH+C!C!88W9UVVHI&,D"D!88W9UVVH!44T[[5QRRHF   5@@S 	" h8 TVVRsj   H9H+8H9H.D)H99H1:8H92H338H9+H5,(H9H7H9.H91H93H95H97H9rO   rR  r  r  c           	      Z  #    U R                  5       I Sh  vN   U R                  U5      nUS   (       d!  [        U R                  S-   US   -   S-   5      eU R	                  XX4XVU5      n	U R                  U	5      I Sh  vN n
U R                  U
S5      nU R                  X5      $  N N)7f)a  
@ignore
       edit a trade order

       https://developers.binance.com/docs/binance-spot-api-docs/rest-api/trading-endpoints#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 fulfilled, in units of the quote currency, ignored in market orders
       :param dict [params]: extra parameters specific to the exchange API endpoint
       :param str [params.marginMode]: 'cross' or 'isolated', for spot margin trading
       :returns dict: an `order structure <https://docs.ccxt.com/#/?id=order-structure>`
       NrY   z" editSpotOrder() does not support ry   ordersnewOrderResponse)r  r  r?   rO   edit_spot_order_requestprivatePostOrderCancelReplacer  parse_order)rt  rO   r  ry  rR  r  r  r  r  payloadr  datas               rv  edit_spot_orderbinance.edit_spot_order  s     " !!!V$f~tww)MMPVW]P^^ajjkk..r4vV\];;GDDP ~~h(:;--] 	"
 Es"   B+B'A(B+?B) (B+)B+c                    U R                  U5      nU R                  U/ SQ5      n	US   UR                  5       S.n
UR                  5       nUnU R                  US:H  US:H  U5      nU(       a  SnU R	                  USS5      nUb  US:X  a  SnOUS	:X  a  S
nXS'   U R                  US   S5      nU R                  X5      (       dM  X:w  a$  [        U R                  S-   U-   S-   U-   S-   5      e[        U R                  S-   U-   S-   U-   S-   5      eU	cK  U R                  U R                  S5      nUb+  U R                  US5      nUb  UU R                  5       -   U
S'   OXS'   U R                  U R                  S   US5      U
S'   SnSnSnSnUS:X  a  U R                  U R                  SS5      nU(       a  U R                  USS5      nUS   S   nUb&  U R!                  U["        UU R$                  5      U
S'   OUb_  U R'                  U5      nU R'                  U5      n[(        R*                  " UU5      nU R!                  U["        UU R$                  5      U
S'   OCSnO@SnO=US	:X  a  SnSnSnO0US:X  d  US:X  a  SnSnOUS
:X  d  US:X  a	  SnSnSnSnO
US:X  a  SnSnU(       a  U R-                  X%5      U
S '   U(       a5  Uc  [        U R                  S!-   U-   S"-   5      eU R/                  X&5      U
S'   U(       a%  U R                  US#5      c  U R                  S$   U
S#'   U(       a5  Uc  [        U R                  S%-   U-   S"-   5      eU R/                  X.5      U
S'   S&U
S''   U R1                  US(S)5      nUc  XS*'   U R                  US#5      S+:X  a  U R3                  US#/5      nU R3                  U/ S,Q5      nU R5                  X5      $ )-a2  
@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 fulfilled, in units of the quote currency, ignored in market orders
       :param dict params: extra parameters specific to the exchange API endpoint
       :param str [params.marginMode]: 'cross' or 'isolated', for spot margin trading
       :returns dict: request to be sent to the exchange
       newClientOrderIdclientOrderIdorigClientOrderIdrO   r  rR  MARKETLIMIT_MAKER	stopPricer?  	STOP_LOSSLIMITSTOP_LOSS_LIMITry  r  
orderTypes+ triggerPrice parameter is not allowed for  r  # is not a valid order type for the  marketr,  rY   r  r  RESULTFr+  Tr)  r  r  TAKE_PROFITTAKE_PROFIT_LIMITr[  z- editOrder() requires a price argument for a  orderrE  r  z7 editOrder() requires a triggerPrice extra param for a STOP_ON_FAILUREcancelReplaceModecancelNewClientOrderIdcancelOrigClientOrderIdcancelOrderIdr8  )r+  r)  r  r  r  postOnly)r  rv  upperis_post_onlyrn  r  r#  r;   rO   r  r  r  uuid22r  r  safe_value_2r  rG   r  rl  rI   r  amount_to_precisionprice_to_precisionr  r  r  )rt  rO   r  ry  rR  r  r  r  r  r  r  initialUppercaseTypeuppercaseTyper  r?  validOrderTypesr,  brokerIdtimeInForceIsRequiredpriceIsRequiredtriggerPriceIsRequiredquantityIsRequiredr+  quoteOrderQtyNewr  amountStringpriceStringquoteOrderQuantitycancelIds                                rv  r  binance.edit_spot_order_request  sZ    V$**63mnTlJJL
  $zz|,$$%9X%EG[_lGlntu)M))&+~N#( +') 1'..F}}]<<#4"477-Z#Z]c#cfi#ilp#ps|#|}}"477S=4#7:_#_bh#hkt#tuu ^^DLL(;F!++FF;'2:T[[]2JG./*7&'&*oodllCU6VX\^f&g"# %!&"H$ NN4<<$OM#'#4#4V_f#U ";/8	#//3/H/HIY[cenpt  qC  qC  0DGO,&#'#8#8#@L"&"7"7">K)0););L+)V&/3/H/HI[]egprv  sE  sE  0FGO,)-&%)"g%"O$(!!%{*0N%)"!%00mGZ6Z!%%)""O$(!m+"O!%"&":":6"JGJ}"477-\#\_c#cfn#noo#66vEGG d&6&6v}&M&U%)\\2F%GGM"!#"477-f#fim#mpx#xyy'+'>'>v'T$'8#$%%f.FHab')O$FM2d:YYv7F6#z{{{7++rx  c                 X   U R                  U5      nUS   (       d!  [        U R                  S-   US   -   S-   5      eUS   UR                  5       UU R	                  X%5      S.n	U R                  U/ SQ5      n
Ub  U R                  X&5      U	S'   U
b  XS	'   U R                  US
S/5      nU	$ )Nr  z& editContractOrder() does not support ry  r  rO   )r  rR  rn  r[  r  r  r  r  r  )r  r?   rO   r  r  rv  r  r  )rt  rO   r  ry  rR  r  r  r  r  r  r  s              rv  edit_contract_order_request#binance.edit_contract_order_request^  s    V$j!tww)QQTZ[aTbbennooTlJJL00@	
 **63mn#66vEGG$+8'(6O5G#HIrx  c           	        #    U R                  5       I Sh  vN   U R                  U5      nSn	U R                  USSSS5      u  pUS   (       d  U	(       a!  Uc  SU;  a  [        U R                  S-   5      eU R                  XX4XVU5      n
SnUS   (       aY  U	(       a)  U R                  U R                  X5      5      I Sh  vN nOU R                  U R                  X5      5      I Sh  vN nObUS	   (       aX  U	(       a)  U R                  U R                  X5      5      I Sh  vN nO(U R                  U R                  X5      5      I Sh  vN nU R                  X5      $  GNM N N} NE N7f)
a  
edit a trade order

https://developers.binance.com/docs/derivatives/usds-margined-futures/trade/rest-api/Modify-Order
https://developers.binance.com/docs/derivatives/coin-margined-futures/trade/rest-api/Modify-Order
https://developers.binance.com/docs/derivatives/portfolio-margin/trade/Modify-UM-Order
https://developers.binance.com/docs/derivatives/portfolio-margin/trade/Modify-CM-Order

: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 fulfilled, in units of the quote currency, ignored in market orders
:param dict [params]: extra parameters specific to the exchange API endpoint
:param boolean [params.portfolioMargin]: set to True if you would like to edit an order in a portfolio margin account
:returns dict: an `order structure <https://docs.ccxt.com/#/?id=order-structure>`
NeditContractOrderr  rm  Fr  
priceMatchzM editOrder() requires a price argument for portfolio margin and linear ordersr  )r  r  r  r4   rO   r  papiPutUmOrderr  fapiPrivatePutOrderpapiPutCmOrderdapiPrivatePutOrderr  )rt  rO   r  ry  rR  r  r  r  r  r  r  r  s               rv  edit_contract_orderbinance.edit_contract_orderp  sY    & !!!V$ $($C$CFL_agiz  }B  %C!(0(>'  3B  )B  C  C222t6Z`a( !%!4!4T[[5Q!RR!%!9!9$++g:V!WWI !%!4!4T[[5Q!RR!%!9!9$++g:V!WW8 11] 	" SW SWsX   E.E#B*E.E&(E.*E(+9E.$E*%(E.E,E.&E.(E.*E.,E.c           	      B  #    U R                  5       I Sh  vN   U R                  U5      nUS   (       a!  [        U R                  S-   US   -   S-   5      eUS   (       a  U R	                  XX4XVU5      I Sh  vN $ U R                  XX4XVU5      I Sh  vN $  N N" N7f)a  
edit a trade order

https://developers.binance.com/docs/binance-spot-api-docs/rest-api/trading-endpoints#cancel-an-existing-order-and-send-a-new-order-trade
https://developers.binance.com/docs/derivatives/usds-margined-futures/trade/rest-api/Modify-Order
https://developers.binance.com/docs/derivatives/coin-margined-futures/trade/rest-api/Modify-Order

: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 fulfilled, in units of the quote currency, ignored in market orders
:param dict [params]: extra parameters specific to the exchange API endpoint
:returns dict: an `order structure <https://docs.ccxt.com/#/?id=order-structure>`
Nr]   z editOrder() does not support ry  r  rY   )r  r  r?   rO   r  r  )	rt  rO   r  ry  rR  r  r  r  r  s	            rv  
edit_orderbinance.edit_order  s     " !!!V$(tww)IIFSYNZ]ffgg&>--b$fU[\\\11"d&Y_``` 	"
 ]`s4   BBA!B8B9BBBBBordersc           
        #    U R                  5       I Sh  vN   / n/ n[        S[        U5      5       H  nX   nU R                  US5      nUR	                  U5        U R                  US5      nU R                  US5      n	U R                  US5      n
U R                  US5      nU R                  US5      nU R                  US	0 5      nSnU R                  US
SSS5      u  pU(       a  [        U R                  S-   5      eU R                  XXXU5      nUR	                  U5        M     U R                  USSSS5      nU R                  US   5      nUS   (       d
  US   (       a!  [        U R                  S-   US   -   S-   5      eSnSU0nU R                  UU5      nUS   (       a  U R                  U5      I Sh  vN nO#US   (       a  U R                  U5      I Sh  vN nU R!                  U5      $  GN N< N7f)a<  
edit a list of trade orders

https://developers.binance.com/docs/derivatives/usds-margined-futures/trade/rest-api/Modify-Multiple-Orders
https://developers.binance.com/docs/derivatives/coin-margined-futures/trade/rest-api/Modify-Multiple-Orders

:param Array orders: list of orders to create, each object should contain the parameters required by createOrder, namely symbol, type, side, amount, price and params
:param dict [params]: extra parameters specific to the exchange API endpoint
:returns dict: an `order structure <https://docs.ccxt.com/#/?id=order-structure>`
Nr   r  rO   ry  rR  r  r  r  r|   r  rm  Fz6 editOrders() does not support portfolio margin ordersTrY   r]   z editOrders() does not support r  r  r  r  )r  r  r  r  r  r  r  r  r?   rO   r  r  r  r  fapiPrivatePutBatchOrdersdapiPrivatePutBatchOrdersparse_orders)rt  r  r  ordersRequestsorderSymbolsr  rawOrderr  rO   ry  rR  r  r  orderParamsr  orderRequestr  r  r  s                      rv  edit_ordersbinance.edit_orders  s     !!!q#f+&AyH''(;H)!!(D1B##Hf5D##Hf5D__Xx8FOOHg6E..8R@K $-1-L-L[Zfhn  qB  DI  .J* "477-e#eff;;B$V\epqL!!,/ '  **<udDQ\!_-&>VH-tww)JJVTZ^[^gghh>
 ++gv.(!;;GDDHI!;;GDDHF   **E 	": EDs4   HG:F)H G=#H$G?%H=H?HrF  c                 @    SSSSSSSSSSS.
nU R                  X!U5      $ )Nr  closedcanceled	cancelingrejectedexpired)
NEWPARTIALLY_FILLEDACCEPTEDFILLEDCANCELED	CANCELLEDPENDING_CANCELREJECTEDEXPIREDEXPIRED_IN_MATCHr  rt  rF  statusess      rv  parse_order_statusbinance.parse_order_status  s<     &"#)"  )
 &99rx  ro  c           
         U R                  US5      nUb  U R                  USS.U5      $ U R                  U R                  USS5      5      nU R                  US5      nSU;   =(       d    SU;   nU(       a  S	OS
nU R	                  XRS U5      nU R                  USS5      n	U R                  U/ SQ5      n
S nSU;   d  SU;   a@  U R                  USS5      nUS:X  a  [        R                  " U	S5      (       a  UnOUS:X  a  UnU R                  USS5      nU R                  US5      nU R                  US5      nU R                  USS5      nU R                  USS5      nU R                  USU5      nU R                  US5      nU R                  US5      nU R                  US/ 5      nU R                  US5      nUS:X  a  SnUS:H  =(       d    US:H  nUS:X  a  SnU R                  US 5      nU R                  U R                  U5      5      nU R                  US!5      nS nUb  U R                  US"5      US S#.nU R                  0 S$U_S%U R                  US&S'5      _S(U R                  US(S)5      _S*U
_S+U R                  U
5      _S,U_S-U_SU_SU_SU_S.U_S/U R                  US/5      _SU_SU_S0U_S1U_S2U_UU	S UUUS3.EU5      $ )4Nr  r  )r  rF  rF  strategyStatusr  positionSidecumQuoter  rY   executedQtyr  )rM  
createTimeworkingTimetransactTimer  r  r  r  r  r  r  origQtyr[  cummulativeQuoteQtycumBasery  rR  fillsrE  GTXr8  limit_makerr  r  r  r>  )rg  r)  rater  rO   
strategyIdrn  r  newClientStrategyIdr  r  lastTradeTimestamplastUpdateTimestampr  
reduceOnlyr?  r  r)  )r  filled	remainingrF  r  rT  )r  
safe_orderr  r  r  safe_integer_nrj  rI   	string_gtri  r  rr  r  r  ro  r  )rt  ro  r  r  rF  r  
isContractr  r  r  r  r  timestampValuer  r  r  r  r)  ry  rR  r  rE  r  stopPriceStringr?  feeCostr  s                              rv  r  binance.parse_order+  s   F v.??EZ#H&QQ((););E8M])^_##E84$-G:3F
#-Z6
!!(D*E!!%<''/rs	!e#)>!00nUN$$VS11)7&8#%3""11%V""5*5  0##E9jA !!%)>
Ky$7%%eV4%%eV4ugr2&&um<%KM)C{d/B= D**5+>(()HI""5%0 ,,ULAC
   
E 
$$$UL)D 
 T//H]^ 
 	 

 Y/ 
 !"4 
 "#6 
 f 
 D 
 ; 
  
 $..= 
 D 
 U 
 L 
  f! 
" D# 
$ / 
0 1 	rx  c           	        #    U R                  5       I Sh  vN   / n/ n[        S[        U5      5       H  nX   nU R                  US5      nUR	                  U5        U R                  US5      nU R                  US5      n	U R                  US5      n
U R                  US5      nU R                  US0 5      nU R                  XxXX5      nUR	                  U5        M     U R                  USS	S
S
5      nU R                  US   5      nUS   (       a!  [        U R                  S-   US   -   S-   5      eSnSU0nU R                  UU5      nUS   (       a  U R                  U5      I Sh  vN nO=US   (       a  U R                  U5      I Sh  vN nOU R                  U5      I Sh  vN nU R!                  U5      $  GN NV N4 N7f)a  
*contract only* create a list of trade orders

https://developers.binance.com/docs/derivatives/coin-margined-futures/trade/rest-api/Place-Multiple-Orders
https://developers.binance.com/docs/derivatives/usds-margined-futures/trade/rest-api/Place-Multiple-Orders
https://developers.binance.com/docs/derivatives/option/trade/Place-Multiple-Orders

:param Array orders: list of orders to create, each object should contain the parameters required by createOrder, namely symbol, type, side, amount, price and params
:param dict [params]: extra parameters specific to the exchange API endpoint
:returns dict: an `order structure <https://docs.ccxt.com/#/?id=order-structure>`
Nr   r  ry  rR  r  r  r  FTrY   z! createOrders() does not support r  r  r  r]   )r  r  r  r  r  r  r  create_order_requestr  r  r?   rO   r  fapiPrivatePostBatchOrderseapiPrivatePostBatchOrdersdapiPrivatePostBatchOrdersr  )rt  r  r  r  r  r  r  r  ry  rR  r  r  r  r  r  r  r  s                    rv  create_ordersbinance.create_ordersX  s     !!!q#f+&AyH''(;H)##Hf5D##Hf5D__Xx8FOOHg6E..8R@K44XTSXfL!!,/ ' **<udDQ\!_-&>tww)LLvV\~]`iijj>
 ++gv.(!<<WEEHH!<<WEEH!<<WEEHF   ** 	"0 FEEsF   GF?EG+G,#GGG)G*GGGGc                 |  #    U R                  5       I Sh  vN   U R                  U5      nU R                  USUS   5      nU R                  US5      n	U R                  U R                  SSS5      n
U R                  USSU
5      nU R                  USS5      nU R                  US	5      nU R                  US
5      nU R                  USS5      nUSLnUSLnUSLnUSL=(       d    U=(       d    U=(       d    UnU R                  USSS5      nU R                  USS5      nU R                  U/ SQ5      nU R                  XX4XV5      nSnUS   (       a  U R                  U5      I Sh  vN nGOU(       a=  U(       a  U R                  U5      I Sh  vN nGOnU R                  U5      I Sh  vN nGOSUS   (       a^  U(       a=  U(       a  U R                  U5      I Sh  vN nGO U R                  U5      I Sh  vN nGOU R                  U5      I Sh  vN nOUS   (       a\  U(       a;  U(       a  U R                  U5      I Sh  vN nOU R!                  U5      I Sh  vN nOU R#                  U5      I Sh  vN nOUS:X  d
  U	c  U(       a;  U(       a  U R%                  U5      I Sh  vN nOTU R'                  U5      I Sh  vN nO:U(       a  U R)                  U5      I Sh  vN nOU R+                  U5      I Sh  vN nU R-                  UU5      $  GN GN GN GNu GNE GN- GN N N N N Nn NO N77f)a?  
create a trade order

https://developers.binance.com/docs/binance-spot-api-docs/rest-api/trading-endpoints#new-order-trade
https://developers.binance.com/docs/binance-spot-api-docs/testnet/rest-api/trading-endpoints#test-new-order-trade
https://developers.binance.com/docs/derivatives/usds-margined-futures/trade/rest-api/New-Order
https://developers.binance.com/docs/derivatives/coin-margined-futures/trade/rest-api
https://developers.binance.com/docs/derivatives/option/trade/New-Order
https://developers.binance.com/docs/binance-spot-api-docs/rest-api/trading-endpoints#sor
https://developers.binance.com/docs/binance-spot-api-docs/testnet/rest-api/trading-endpoints#sor
https://developers.binance.com/docs/derivatives/portfolio-margin/trade/New-UM-Order
https://developers.binance.com/docs/derivatives/portfolio-margin/trade/New-CM-Order
https://developers.binance.com/docs/derivatives/portfolio-margin/trade/New-Margin-Order
https://developers.binance.com/docs/derivatives/portfolio-margin/trade/New-UM-Conditional-Order
https://developers.binance.com/docs/derivatives/portfolio-margin/trade/New-CM-Conditional-Order

: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 fulfilled, in units of the quote currency, ignored in market orders
:param dict [params]: extra parameters specific to the exchange API endpoint
:param str [params.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
:param str [params.selfTradePrevention]: set unified value for stp, one of NONE, EXPIRE_MAKER, EXPIRE_TAKER or EXPIRE_BOTH
:param float [params.icebergAmount]: set iceberg amount for limit orders
:param str [params.stopLossOrTakeProfit]: 'stopLoss' or 'takeProfit', required for spot trailing orders
:param str [params.positionSide]: *swap and portfolio margin only* "BOTH" for one-way mode, "LONG" for buy side of hedged mode, "SHORT" for sell side of hedged mode
:param bool [params.hedged]: *swap and portfolio margin only* True for hedged mode, False for one way mode, default is False
:returns dict: an `order structure <https://docs.ccxt.com/#/?id=order-structure>`
Nry  r>  r  rm  Fr?  r  rB  rC  trailingPercentcallbackRatesorSORr  )r  r  r  r]   r  r  rZ   )r  r  r  rt  r  r  r  r  r  eapiPrivatePostOrderprivatePostSorOrderTestprivatePostSorOrderpapiPostUmConditionalOrderpapiPostUmOrderfapiPrivatePostOrderpapiPostCmConditionalOrderpapiPostCmOrderdapiPrivatePostOrderpapiPostMarginOrdersapiPostMarginOrderprivatePostOrderTestprivatePostOrderr  )rt  r  ry  rR  r  r  r  r  r  r>  porfolioOptionsValuer  r?  rB  rC  r  isTrailingPercentOrder
isStopLossisTakeProfitisConditionalr  r  r  r  s                           rv  create_orderbinance.create_order  s    P !!!V$%%fffVnE
%%fl;
#//fFWY^_ ,,VV=NPde))&.+N((A**63DE,,V5FW!0!<"$.
&d2%T1j6LjPZj^jvueU;~~ffe46#9: ++F$V(!66w??H!%!=!=g!FF!%!9!9'!BBH  %)%D%DW%MMH%)%9%9'%BBH!%!:!:7!CCI  %)%D%DW%MMH%)%9%9'%BBH!%!:!:7!CC8#z'=AR !%!9!9'!BB!%!9!9'!BB!%!:!:7!CC!%!6!6w!??&11q 	"0 @ GB  NBC  NBC CB D?s   L<LEL<)L*(L<LL<-L".2L< L%!L<;L(<L<L+1L<L.	L<"L0#L<<L2=0L<-L4.L<L6 L<(L8)L<L:L<L<L<"L<%L<(L<+L<.L<0L<2L<4L<6L<8L<:L<c                 
   U R                  U5      nU R                  USUS   5      nU R                  USS5      n	UR                  5       n
U
S:H  nU
S:H  nUS   UR                  5       S.nSnU R	                  US	S
SS5      u  pSnU R                  S	U5      u  pU R                  USS5      nU(       a*  US:X  d  US   (       d  Ub  U R                  US5      nSUS'   U R                  USS5      nU R                  USU5      nU R                  US5      nU R                  US5      nU R                  USS5      nU R                  U/ SQ5      nU R                  US5      nUSLnUSL=(       d    USLnUSLnUSLnU=(       d    U=(       d    U=(       d    UnU=(       a    UnUSLnSnUR                  5       n Sn!U(       a  US   (       a!  Sn UUS'   Ub  U R                  UU5      US'   GO6U S:w  a  U S :w  a  U S!:w  a{  U S":w  au  U R                  US#5      n"U R                  US#5      nU"S$:w  a!  U"S%:w  a  [        U R                  U-   S&-   5      eU(       a  U"S$:X  a  Sn OU"S%:X  a  S n OU"S$:X  a  S!n OU"S%:X  a  S"n U S:X  d  U S :X  a  SnUb  U R                  UU5      n![        R                  " US'5      n#U#US'   OiU(       a.  Un!U(       a  US   (       a  S(OSn OJU(       a  US   (       a  S)OS!n O4U(       a-  Un!U(       a  US   (       a  S*OS n OU(       a  US   (       a  S OS"n US+   (       a+  US,:X  a$  [        U R                  S--   U-   S.-   U-   S/-   5      eOzU R                  US0   S15      n$U R                  U U$5      (       dN  U
U :w  a$  [        U R                  S2-   U-   S--   U-   S3-   5      e[        U R                  S--   U-   S.-   U-   S/-   5      eU(       a  S4OSn%U	cy  U R!                  U R"                  S50 5      n&US   (       a  S6OS7n'S8n(US   (       a  US   (       a  US9   (       a  SOS:n(U R                  U&U(U'5      n)U)U R%                  5       -   UU%'   OXU%'   Sn*U(       d:  U R'                  XS;:H  U5      n*US8   (       d  US:X  a  U*(       a  S;n US<:X  a  SUS='   O.U R'                  XS;:H  U5      n*U*(       a  US   (       d  S;n OS>US?'   US8:X  d  US:X  a+  U(       d$  U R                  U R"                  S@   USA5      US@'   OSBUS@'   U(       a  SCOSn+U UU+'   U R                  USDS5      n,Sn-Sn.Sn/Sn0U S:X  a  US8   (       a  U R                  U R"                  SES5      n1U1(       a  U R                  USESF5      n2USG   SH   n3U2b'  U R)                  U2[*        U3U R,                  5      USE'   GOUb_  U R/                  U5      n4U R/                  U5      n5[        R                  " U4U55      n6U R)                  U6[*        U3U R,                  5      USE'   OSn0OSn0OSn0OU S:X  a  Sn.Sn-Sn0OU S:X  d  U S :X  a"  Sn/Sn0US9   (       d
  US:   (       a	  U(       a  Sn.OuU S!:X  d  U S":X  a	  Sn0Sn/Sn.Sn-O`U S;:X  a  Sn.Sn0OUU S):X  a  Sn0Sn/Sn.OHU S(:X  d  U S*:X  a  U,(       d  Sn0Sn/O0U S:X  a*  U,(       d  Sn0Uc  [        U R                  SI-   U-   SJ-   5      eU0(       aI  U R                  USG   SK5      n7U7SLn8U8(       a  U R1                  X5      USL'   OU R3                  U5      USL'   U.(       aq  U(       dj  Uc  [        U R                  SM-   U-   SJ-   5      eU R                  USG   SH5      n9U9SLn:U:(       a  U R                  X5      USH'   OU R3                  U5      USH'   U/(       ak  US   (       a"  U!c  [        U R                  SN-   U-   SJ-   5      eO'Uc$  U!c!  Uc  [        U R                  SO-   U-   SJ-   5      eU!b  U R                  UU!5      US'   U-(       aE  U R                  US?5      c2  U R                  US?5      c  U R                  U R"                  SP5      US?'   U(       d  US   (       a  U*(       a  S>US?'   U R                  US?5      SQ:X  a  U R                  US?5      nU R                  USRS5      n;US8   (       dA  US+   (       d7  U;(       a0  U(       a  U R                  US5      nUSS:X  a  STOSSnUSS:X  a  SUOSVUSW'   Sn<U R5                  US	SX5      u  n<nU<b  US8   (       a  U<R                  5       USY'   U R7                  USZ5      n=U=b  US8   (       a  U R1                  UU=5      US['   U R                  U/ S\Q5      n>U R9                  UU>5      $ )]aB  
@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 fulfilled, in units of the quote currency, ignored in market orders
       :param dict [params]: extra parameters specific to the exchange API endpoint
       :returns dict: request to be sent to the exchange
       ry  r  r  r  r  rO   r  Nro   r  rm  Fr  rZ   r  
AUTO_REPAYsideEffectTyper?  r  rB  rC  trailingDeltatrailingTriggerPriceactivationPrice)r  r  r4  r  Tr[   TRAILING_STOP_MARKETr  r  r  r  r  stopLossOrTakeProfitstopLoss
takeProfitza trailingPercent orders require a stopLossOrTakeProfit parameter of either stopLoss or takeProfit100STOP_MARKETSTOPTAKE_PROFIT_MARKETr]   r  r  r  r  r  r  r  r  r  r,  r  r  rY   r  r  r  rO  r\  r  rE  r  r  r  strategyTypere   r+  r)  r  r  z6 createOrder() requires a trailingPercent param for a r  r  r[  z/ createOrder() requires a price argument for a z9 createOrder() requires a triggerPrice extra param for a zU createOrder() requires a triggerPrice, trailingDelta or trailingPercent param for a r  r8  rF  rc  rb  LONGSHORTr  rI  selfTradePreventionModerK  
icebergQty)ry  r  r  r  rB  rC  r  r?  r5  r  r+  r)  r  rF  rK  )r  r  r  r  r  r  r  r  rv  r  r;   rO   rI   r  r  r#  r  r  r  r  r  rG   r  rl  r  rm  r  r  r  )?rt  r  ry  rR  r  r  r  r  r  r  r  isMarketOrderisLimitOrderr  r  r>  r  r?  rB  rC  r4  r5  r  r  r+  r,  r-  isTriggerOrderr.  isPortfolioMarginConditionalisPriceMatchpriceRequiredForTrailingr  r  r8  trailingPercentConvertedr  clientOrderIdRequestr,  	defaultIdidMarketTyper  r  typeRequestre   r  r  r  r  r+  r  r  r  r  r  marketAmountPrecisionisPrecisionAvailablerU  isPricePrecisionAvailablerF  rI  rK  requestParamss?                                                                  rv  r  binance.create_order_request  s
    V$%%fffVnE
**63EW#zz|,8+w6TlJJL
 !$($C$CFM[actv{$|!
!??vV
^^FL%@
X%fZ.@jF\6<8,8()))&.+N((,O**63DE((A#11&:PRcd,,V5ij%%fl;
!0!<"$.K-t2K
&d2%T1&^*@^J^R^(9(Km$!-#' 

	!f~ 6*9''3151H1HQe1fG-.![0}7U\im~\~  FS  Wj  Fj+/+;+;FDZ+[(!YYv/EFF,
:AUYeAe*477V+;  ?b  ,b  c  c$/:=,7M1\A,9M/:=,=M1\A,?M![0m}6T/4,'3 $ 7 7@T UI+2+=+=ou+U(+C(%I17
1C*0*<BS'I8>z8J 4P]17
1CI\(x"477S=4#7:_#_bh#hkt#tuu   #nnVF^\JO==@@'=8&tww1^'^ag'gjm'mpt't  xA  (A  B  B&tww}t';>c'cfl'lox'xyy8T4Zl ^^DLL(B?F)/
);,I!Lj!*0.VH=MvT]''iHH,4t{{},DG(),9() ((P]8]_efHf~x!7$1M+,0GL)((P]8]_efHj)$1M-2GM*6!zX'=HY*.*:*:4<<HZ;[]aci*jG&' +3G&'(Dn&,vF %!&"* H$f~ $t||_d S '+'9'9&/SY'Z$ &{ 3G <I'3373L3LM]_girtx  uG  uG  4H0*'+'<'<V'D&*&;&;E&B-4-?-?k-Z*373L3LM_aiktvz  wI  wI  4J0-1*)-&%)"g%"O$(!!%{*0N%)"!%x F9$5;S"&00mGZ6Z!%%)""O$(!m+"O!%f$!%%)""O},-CW2W %)"%)"44 %)"&"477-e#ehl#low#wxx$($4$4VK5H($S!$9$E #&*&>&>v&N
#&*&;&;F&C
#<}"477-^#^ae#ehp#pqq!--f[.A7KN)7t)C%(#'#:#:6#I #'#8#8#? !j!$&tww1l'los'sv~'~ % !(Y->?CZ&tww  2I  (I  LP  (P  S[  ([  \  \$'+'>'>vy'Q$ d&6&6v}&M&U\`\l\lmt  wD  ]E  ]M%)%5%5dllDX%YGM" VJ%7H%*GM"FM2d:YYv}5F%8f~fX&666<8"&%-ve15fWGN#"&*&C&CFM[p&q#V*f~5H5N5N5P12((A$f~(,(@(@(W%		&  +L  M{{7M22rx  r)  c                   #    U R                  5       I Sh  vN   U R                  U5      nUS   (       d  [        U R                  S-   5      eSU0nU R	                  USX#SU R                  Xd5      5      I Sh  vN $  Ng N7f)a  
create a market order by providing the symbol, side and cost

https://developers.binance.com/docs/binance-spot-api-docs/rest-api/trading-endpoints#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>`
NrY   z6 createMarketOrderWithCost() supports spot orders onlyr)  r  r  r  r?   rO   r/  r  )rt  r  rR  r)  r  r  reqs          rv  create_market_order_with_cost%binance.create_market_order_with_cost  s      !!!V$f~tww)aabbD
 &&vxT4;;WZKcddd 	" es"   BA>A"B9B :B Bc                 
  #    U R                  5       I Sh  vN   U R                  U5      nUS   (       d  [        U R                  S-   5      eSU0nU R	                  USSUSU R                  XS5      5      I Sh  vN $  Nh N7f)a  
create a market buy order by providing the symbol and cost

https://developers.binance.com/docs/binance-spot-api-docs/rest-api/trading-endpoints#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>`
NrY   z9 createMarketBuyOrderWithCost() supports spot orders onlyr)  r  rc  rU  )rt  r  r)  r  r  rV  s         rv  !create_market_buy_order_with_cost)binance.create_market_buy_order_with_cost#  s      !!!V$f~tww)ddeeD
 &&vxdDKKX[Ldeee 	" fs"   BA?A#B:B;BBc                    #    U R                  5       I Sh  vN   U R                  U5      nUS   (       d  [        U R                  S-   5      eX#S'   U R	                  USSUSU5      I Sh  vN $  NY N7f)a  
create a market sell order by providing the symbol and cost

https://developers.binance.com/docs/binance-spot-api-docs/rest-api/trading-endpoints#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>`
NrY   z: createMarketSellOrderWithCost() supports spot orders onlyr+  r  rb  )r  r  r?   rO   r/  )rt  r  r)  r  r  s        rv  "create_market_sell_order_with_cost*binance.create_market_sell_order_with_cost7  st      !!!V$f~tww)eeff"&&&vxtVTTT 	"
 Us"   A4A0AA4+A2,A42A4c                 d  #    Uc  [        U R                  S-   5      eU R                  5       I Sh  vN   U R                  U5      nU R	                  U R
                  SSS5      nU R                  USU5      nSnU R                  SU5      u  psSnU R                  USSSS	5      u  pS
US   0n	U R	                  USS5      n
U
b  US   (       a  XS'   O	XS'   OXS'   U R                  U/ SQ5      nSnUS   (       a*  U R                  U R                  X5      5      I Sh  vN nGOcUS   (       aZ  U(       a*  U R                  U R                  X5      5      I Sh  vN nGO(U R                  U R                  X5      5      I Sh  vN nOUS   (       aY  U(       a)  U R                  U R                  X5      5      I Sh  vN nOU R                  U R                  X5      5      I Sh  vN nOUS:X  d
  Uc  U(       ad  U(       a)  U R!                  U R                  X5      5      I Sh  vN nO\US:X  a  SU	S'   U R#                  U R                  X5      5      I Sh  vN nO(U R%                  U R                  X5      5      I Sh  vN nU R'                  X5      $  GNi GN~ GNF GN N N N NP N)7f)ax  
fetches information on an order made by the user

https://developers.binance.com/docs/binance-spot-api-docs/rest-api/trading-endpoints#query-order-user_data
https://developers.binance.com/docs/derivatives/usds-margined-futures/trade/rest-api/Query-Order
https://developers.binance.com/docs/derivatives/coin-margined-futures/trade/rest-api/Query-Order
https://developers.binance.com/docs/derivatives/option/trade/Query-Single-Order
https://developers.binance.com/docs/margin_trading/trade/Query-Margin-Account-Order
https://developers.binance.com/docs/derivatives/portfolio-margin/trade/Query-UM-Order
https://developers.binance.com/docs/derivatives/portfolio-margin/trade/Query-CM-Order

: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  rY   ry  r  rm  Fr  rO   r  r  r]   rn  )ry  r  r  r  r  rZ   rO  Tr\  )r4   rO   r  r  r  r  r  r  r  r  eapiPrivateGetOrderr  papiGetUmOrderfapiPrivateGetOrderpapiGetCmOrderdapiPrivateGetOrderpapiGetMarginOrdersapiGetMarginOrderprivateGetOrderr  )rt  rO   r  r  r  r  ry  r>  r  r  r  r  s               rv  fetch_orderbinance.fetch_orderI  st    & >#DGG.X$XYY!!!V$((|]TZ[<
!??fU
 $($C$CFLZ`bsuz${!fTl
 **63FX$h+8(/<+,!#I6#QR(!55dkk'6RSSHH !%!4!4T[[5Q!RR!%!9!9$++g:V!WWI !%!4!4T[[5Q!RR!%!9!9$++g:V!WWhJ$:?P !%!8!8W9U!VV+,0GL)!%!8!8W9U!VV!11$++g2NOOH11U 	", T SW SW W WOs   /J0JC-J0J :J0J )J0J#9J0>J&?(J0'J((?J0'J*(3J0J,(J0J.J0J0 J0#J0&J0(J0*J0,J0.J0c                   #    Uc  [        U R                  S-   5      eU R                  5       I Sh  vN   SnU R                  USS5      u  pTU(       a  U R	                  SXX45      I Sh  vN $ U R                  U5      nU R                  U R                  SSUS   5      nU R                  USU5      nSn	U R                  SU5      u  pSn
U R                  USSS	S5      u  pU R                  U/ S
Q5      nU R                  U/ SQ5      nSUS   0nU R                  SX5      u  pUb  X,S'   Ub  X<S'   SnUS   (       a*  U R                  U R                  X5      5      I Sh  vN nGOUS   (       a  U
(       a[  U(       a*  U R!                  U R                  X5      5      I Sh  vN nGO|U R#                  U R                  X5      5      I Sh  vN nGORU R%                  U R                  X5      5      I Sh  vN nGO(US   (       a  U
(       aY  U(       a)  U R'                  U R                  X5      5      I Sh  vN nOU R)                  U R                  X5      5      I Sh  vN nOU R+                  U R                  X5      5      I Sh  vN nOU
(       a)  U R-                  U R                  X5      5      I Sh  vN nOeUS:X  d  U	b4  U	S:X  a  SUS'   U R/                  U R                  X5      5      I Sh  vN nO(U R1                  U R                  X5      5      I Sh  vN nU R3                  XX#5      $  GN	 GN GN GN GNw GNP GN N N N NZ N37f)a  
fetches information on multiple orders made by the user

https://developers.binance.com/docs/binance-spot-api-docs/rest-api/trading-endpoints#all-orders-user_data
https://developers.binance.com/docs/derivatives/usds-margined-futures/trade/rest-api/All-Orders
https://developers.binance.com/docs/derivatives/coin-margined-futures/trade/rest-api/All-Orders
https://developers.binance.com/docs/derivatives/option/trade/Query-Option-Order-History
https://developers.binance.com/docs/margin_trading/trade/Query-Margin-Account-All-Orders
https://developers.binance.com/docs/derivatives/portfolio-margin/trade/Query-All-UM-Orders
https://developers.binance.com/docs/derivatives/portfolio-margin/trade/Query-All-CM-Orders
https://developers.binance.com/docs/derivatives/portfolio-margin/trade/Query-All-UM-Conditional-Orders
https://developers.binance.com/docs/derivatives/portfolio-margin/trade/Query-All-CM-Conditional-Orders

: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.trigger]: set to True if you would like to fetch portfolio margin account trigger or conditional orders
:returns Order[]: a list of `order structures <https://docs.ccxt.com/#/?id=order-structure>`
Nz) fetchOrders() requires a symbol argumentFr   r9  r  ry  r  rm  stoprO  conditional)rl  rO  rm  ry  r  rO   r?  r>  r  r]   r  r  rZ   rO  Tr\  )r4   rO   r  r  r  r  r  r  r  r  r  safe_bool_nr  handle_until_optioneapiPrivateGetHistoryOrdersr  papiGetUmConditionalAllOrderspapiGetUmAllOrdersfapiPrivateGetAllOrderspapiGetCmConditionalAllOrderspapiGetCmAllOrdersdapiPrivateGetAllOrderspapiGetMarginAllOrderssapiGetMarginAllOrdersprivateGetAllOrdersr  )rt  r  r7  r  r  r9  r  r  ry  r>  r  r.  r  r  s                 rv  fetch_ordersbinance.fetch_orders  s    2 >#DGG.Y$YZZ!!!88PZ[::=&Y^gggV$((}mU[\bUcd<
!??vV
 $($C$CFM[actv{$|!((1ST6#MNfTl
 229gN#(K $G(!==dkk'>Z[[HH  %)%G%GT[Hd%eeH%)%<%<T[[=Y%ZZH!%!=!=dkk'>Z![[I  %)%G%GT[Hd%eeH%)%<%<T[[=Y%ZZH!%!=!=dkk'>Z![[ !%!<!<T[[=Y!ZZ!Z%;+,0GL)!%!<!<T[[=Y!ZZ!%!9!9$++g:V!WWj   5@@M 	" h( \  fZ[  fZ[ [ [Ws   /ML:8M*L=+C8M#M $AM%M&)MM)M9M	:AM;M<(M$M%(MM/M=M><M:M;(M#M$M=M MMM	MMMMMMMc                   #    U R                  5       I Sh  vN   SnSn0 nSnU R                  SU5      u  pSn	U R                  USSSS5      u  pU R                  U/ SQ5      n
UbX  U R	                  U5      nUS   US'   U R                  U R                  SS	S
5      nSU;   a  US   OUnU R                  USU5      nOmU R                  S   (       a(  [        U R                  S-   U R                  -   S-   5      eU R                  U R                  SS	S
5      nU R                  USU5      nSnU R                  SXT5      u  pU R                  U/ SQ5      nSnUS:X  a8  Ub  X'S'   Ub  X7S'   U R                  U R                  Xt5      5      I Sh  vN nGOU R                  Xm5      (       a  U	(       a[  U
(       a*  U R                  U R                  Xt5      5      I Sh  vN nGOU R!                  U R                  Xt5      5      I Sh  vN nGOU R#                  U R                  Xt5      5      I Sh  vN nGOWU R%                  Xm5      (       a  U	(       aZ  U
(       a*  U R'                  U R                  Xt5      5      I Sh  vN nGO	U R)                  U R                  Xt5      5      I Sh  vN nOU R+                  U R                  Xt5      5      I Sh  vN nOUS:X  d
  Uc  U	(       a  U	(       a)  U R-                  U R                  Xt5      5      I Sh  vN nOwUS:X  a   SUS'   Uc  [/        U R                  S-   5      eU R1                  U R                  Xt5      5      I Sh  vN nO(U R3                  U R                  Xt5      5      I Sh  vN nU R5                  XX#5      $  GN GN GN GN GN| GN1 GN
 N N NX N17f)a  
fetch all unfilled currently open orders

https://developers.binance.com/docs/binance-spot-api-docs/rest-api/trading-endpoints#current-open-orders-user_data
https://developers.binance.com/docs/derivatives/usds-margined-futures/trade/rest-api/Current-All-Open-Orders
https://developers.binance.com/docs/derivatives/coin-margined-futures/trade/rest-api/Current-All-Open-Orders
https://developers.binance.com/docs/derivatives/option/trade/Query-Current-Open-Option-Orders
https://developers.binance.com/docs/margin_trading/trade/Query-Margin-Account-Open-Orders
https://developers.binance.com/docs/derivatives/portfolio-margin/trade/Query-All-Current-UM-Open-Orders
https://developers.binance.com/docs/derivatives/portfolio-margin/trade/Query-All-Current-UM-Open-Conditional-Orders
https://developers.binance.com/docs/derivatives/portfolio-margin/trade/Query-All-Current-CM-Open-Orders
https://developers.binance.com/docs/derivatives/portfolio-margin/trade/Query-All-Current-CM-Open-Conditional-Orders

: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.trigger]: 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  rm  Frk  rO   r  r  rY   ry  r  z fetchOpenOrders() WARNING: fetching open orders without specifying a symbol has stricter rate limits(10 times more for spot, 40 times more for other markets) compared to requesting with symbol argument. To acknowledge self warning, set zX.options["warnOnFetchOpenOrdersWithoutSymbol"] = False to suppress self warning message.ry  rl  rO  rm  r]   r>  r  rZ   rO  Tr\  zB fetchOpenOrders() requires a symbol argument for isolated markets)r  r  r  rn  r  r  r  r  r0   rO   r  r  eapiPrivateGetOpenOrdersr  r  papiGetUmConditionalOpenOrderspapiGetUmOpenOrdersfapiPrivateGetOpenOrdersr~  papiGetCmConditionalOpenOrderspapiGetCmOpenOrdersdapiPrivateGetOpenOrderspapiGetMarginOpenOrdersr4   sapiGetMarginOpenOrdersprivateGetOpenOrdersr  )rt  r  r7  r  r  r  ry  r  r>  r  r.  r  r  rz  r  s                  rv  fetch_open_ordersbinance.fetch_open_orders  s    0 !!!
!??@QSYZ
 $($C$CFL]_egxz  %A!((1ST[[(F &tGH,,T\\;Lm]cdK,2f,<;J##FFJ?D\\>?  +Z  !Z  ]a  ]d  ]d  !d  gA  !A  B  B,,T\\;Lm]cdK##FFK@D99:KV\6#MN8 ',$ #( !::4;;w;WXXH^^D**  %)%H%HU\Ie%ffH%)%=%=dkk'>Z%[[H!%!>!>t{{7?[!\\__T++  %)%H%HU\Ie%ffH%)%=%=dkk'>Z%[[H!%!>!>t{{7?[!\\X!7;L !%!=!=dkk'>Z![[+,0GL)~/:~0~!%!=!=dkk'>Z![[!66t{{77STTH  5@@s 	": Y  g[\  g[\ \ \Ts   N>N!E8N>N$AN>N')N>N*)N>1N-2AN>?N0 )N>)N3*(N>N6?N>N8AN>!N:"(N>
N<N>$N>'N>*N>-N>0N>3N>6N>8N>:N><N>c                 v  #    Uc  [        U R                  S-   5      eU R                  5       I Sh  vN   U R                  U5      nSUS   0nSnU R	                  USSSS5      u  pcU R                  U/ S	Q5      nU R                  U/ S	Q5      nU=(       a    UnU(       a  S
OSn	XU	'   Sn
US   (       a  U(       a[  U(       a*  U R                  U R                  XS5      5      I Sh  vN n
GO*U R                  U R                  XS5      5      I Sh  vN n
GO U R                  U R                  XS5      5      I Sh  vN n
OUS   (       a  U(       aY  U(       a)  U R                  U R                  XS5      5      I Sh  vN n
OU R                  U R                  XS5      5      I Sh  vN n
OmU R                  U R                  XS5      5      I Sh  vN n
ODUS   (       a  [        U R                  S-   5      eUS   (       a  [        U R                  S-   5      eU R                  X5      $  GN GNE GN N N N Ni7f)ah  
fetch an open order by the id

https://developers.binance.com/docs/derivatives/usds-margined-futures/trade/rest-api/Query-Current-Open-Order
https://developers.binance.com/docs/derivatives/coin-margined-futures/trade/rest-api/Query-Current-Open-Order
https://developers.binance.com/docs/derivatives/portfolio-margin/trade/Query-Current-UM-Open-Order
https://developers.binance.com/docs/derivatives/portfolio-margin/trade/Query-Current-UM-Open-Conditional-Order
https://developers.binance.com/docs/derivatives/portfolio-margin/trade/Query-Current-CM-Open-Order
https://developers.binance.com/docs/derivatives/portfolio-margin/trade/Query-Current-CM-Open-Conditional-Order

: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
:param boolean [params.portfolioMargin]: set to True if you would like to fetch for a portfolio margin account
:returns dict: an `order structure <https://docs.ccxt.com/#/?id=order-structure>`
Nz, fetchOpenOrder() requires a symbol argumentr  rO   r   r  rm  Frk  r  rn  r  r  r]   z1 fetchOpenOrder() does not support option marketsrY   z/ fetchOpenOrder() does not support spot markets)r4   rO   r  r  r  rn  r  papiGetUmConditionalOpenOrderr  papiGetUmOpenOrderfapiPrivateGetOpenOrderpapiGetCmConditionalOpenOrderpapiGetCmOpenOrderdapiPrivateGetOpenOrderr?   r  )rt  rO   r  r  r  r  r  r.  rG  orderIdRequestr  s              rv  fetch_open_orderbinance.fetch_open_order  s    $ >#DGG.\$\]]!!!V$fTl
 !$($C$CFL\^dfwy~$!((1ST6#EF(9(Km$)E9"$(  %)%G%GT[Hd%eeH%)%<%<T[[=Y%ZZH!%!=!=dkk'>Z![[I  %)%G%GT[Hd%eeH%)%<%<T[[=Y%ZZH!%!=!=dkk'>Z![[h"477-`#`aa"477-^#^__j 11m 	"   fZ[  fZ[s~   /H9H(B4H9&H+')H9H.)H9:H1;A H9;H3<(H9$H5%(H9H7AH9+H9.H91H93H95H97H9c                    #    Uc  [        U R                  S-   5      eU R                  XSU5      I Sh  vN nU R                  USS5      nU R	                  XbU5      $  N)7f)a  
fetches information on multiple closed orders made by the user

https://developers.binance.com/docs/binance-spot-api-docs/rest-api/trading-endpoints#all-orders-user_data
https://developers.binance.com/docs/derivatives/usds-margined-futures/trade/rest-api/All-Orders
https://developers.binance.com/docs/derivatives/coin-margined-futures/trade/rest-api/All-Orders
https://developers.binance.com/docs/derivatives/option/trade/Query-Option-Order-History
https://developers.binance.com/docs/margin_trading/trade/Query-Margin-Account-All-Orders
https://developers.binance.com/docs/derivatives/portfolio-margin/trade/Query-All-UM-Orders
https://developers.binance.com/docs/derivatives/portfolio-margin/trade/Query-All-CM-Orders
https://developers.binance.com/docs/derivatives/portfolio-margin/trade/Query-All-UM-Conditional-Orders
https://developers.binance.com/docs/derivatives/portfolio-margin/trade/Query-All-CM-Conditional-Orders

: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.trigger]: set to True if you would like to fetch portfolio margin account trigger or conditional orders
:returns Order[]: a list of `order structures <https://docs.ccxt.com/#/?id=order-structure>`
Nz/ fetchClosedOrders() requires a symbol argumentrF  r  r4   rO   rz  	filter_byfilter_by_since_limitrt  r  r7  r  r  r  filteredOrderss          rv  fetch_closed_ordersbinance.fetch_closed_orders  sc     . >#DGG._$_``((fEE(C)).GG F   2A A*A c                    #    Uc  [        U R                  S-   5      eU R                  XSU5      I Sh  vN nU R                  USS5      nU R	                  XbU5      $  N)7f)  
fetches information on multiple canceled orders made by the user

https://developers.binance.com/docs/binance-spot-api-docs/rest-api/trading-endpoints#all-orders-user_data
https://developers.binance.com/docs/derivatives/usds-margined-futures/trade/rest-api/All-Orders
https://developers.binance.com/docs/derivatives/coin-margined-futures/trade/rest-api/All-Orders
https://developers.binance.com/docs/derivatives/option/trade/Query-Option-Order-History
https://developers.binance.com/docs/margin_trading/trade/Query-Margin-Account-All-Orders
https://developers.binance.com/docs/derivatives/portfolio-margin/trade/Query-All-UM-Orders
https://developers.binance.com/docs/derivatives/portfolio-margin/trade/Query-All-CM-Orders
https://developers.binance.com/docs/derivatives/portfolio-margin/trade/Query-All-UM-Conditional-Orders
https://developers.binance.com/docs/derivatives/portfolio-margin/trade/Query-All-CM-Conditional-Orders

: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.trigger]: set to True if you would like to fetch portfolio margin account trigger or conditional orders
:returns dict[]: a list of `order structures <https://docs.ccxt.com/#/?id=order-structure>`
Nz1 fetchCanceledOrders() requires a symbol argumentrF  r  r  r  s          rv  fetch_canceled_ordersbinance.fetch_canceled_orders  sc     . >#DGG.a$abb((fEE*E)).GG Fr  c                 0  #    Uc  [        U R                  S-   5      eU R                  XSU5      I Sh  vN nU R                  USS5      nU R                  USS5      nU R	                  Xg5      nU R                  US5      n	U R                  XU5      $  N_7f)r  Nz: fetchCanceledAndClosedOrders() requires a symbol argumentrF  r  r  r  )r4   rO   rz  r  r,  sort_byr  )
rt  r  r7  r  r  r  canceledOrdersclosedOrdersr  sortedOrderss
             rv   fetch_canceled_and_closed_orders(binance.fetch_canceled_and_closed_orders  s     . >#DGG.j$jkk((fEE*E~~fhA**>H||NK@)),uEE Fs   2BBA Bc                   #    Uc  [        U R                  S-   5      eU R                  5       I Sh  vN   U R                  U5      nU R	                  U R
                  SSS5      nU R                  USU5      nSnU R                  SU5      u  psSnU R                  USSSS	5      u  pU R                  U/ S
Q5      n	SUS   0n
U R                  U/ SQ5      nUb'  US   (       a  XS'   O/U(       a  U	(       a  XS'   OXS'   OU(       a  U	(       a  XS'   OXS'   U R                  U/ SQ5      nSnUS   (       a*  U R                  U R                  X5      5      I Sh  vN nGOUS   (       a  U(       a[  U	(       a*  U R                  U R                  X5      5      I Sh  vN nGOU R                  U R                  X5      5      I Sh  vN nGOYU R!                  U R                  X5      5      I Sh  vN nGO/US   (       a  U(       aY  U	(       a)  U R#                  U R                  X5      5      I Sh  vN nOU R%                  U R                  X5      5      I Sh  vN nOU R'                  U R                  X5      5      I Sh  vN nOUS:X  d
  Uc  U(       ad  U(       a)  U R)                  U R                  X5      5      I Sh  vN nO\US:X  a  SU
S'   U R+                  U R                  X5      5      I Sh  vN nO(U R-                  U R                  X5      5      I Sh  vN nU R/                  X5      $  GN GN GN GNz GNS GN N N N NV N/7f)a  
cancels an open order

https://developers.binance.com/docs/binance-spot-api-docs/rest-api/trading-endpoints#cancel-order-trade
https://developers.binance.com/docs/derivatives/usds-margined-futures/trade/rest-api/Cancel-Order
https://developers.binance.com/docs/derivatives/coin-margined-futures/trade/rest-api/Cancel-Order
https://developers.binance.com/docs/derivatives/option/trade/Cancel-Option-Order
https://developers.binance.com/docs/margin_trading/trade/Margin-Account-Cancel-Order
https://developers.binance.com/docs/derivatives/portfolio-margin/trade/Cancel-UM-Order
https://developers.binance.com/docs/derivatives/portfolio-margin/trade/Cancel-CM-Order
https://developers.binance.com/docs/derivatives/portfolio-margin/trade/Cancel-UM-Conditional-Order
https://developers.binance.com/docs/derivatives/portfolio-margin/trade/Cancel-CM-Conditional-Order
https://developers.binance.com/docs/derivatives/portfolio-margin/trade/Cancel-Margin-Account-Order

: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.trigger]: 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 argumentrb   r  rY   ry  r  rm  Frk  r  rO   )r  r  r  r]   r  r  r  r  rn  )ry  r  r  r  rl  rO  rm  r  r  rZ   rO  Tr\  )r4   rO   r  r  r  r  r  r  r  rn  rv  r  eapiPrivateDeleteOrderr  papiDeleteUmConditionalOrderpapiDeleteUmOrderfapiPrivateDeleteOrderpapiDeleteCmConditionalOrderpapiDeleteCmOrderdapiPrivateDeleteOrderpapiDeleteMarginOrdersapiDeleteMarginOrderprivateDeleteOrderr  )rt  rO   r  r  r  r  ry  r>  r  r.  r  r  r  s                rv  cancel_orderbinance.cancel_order  s    , >#DGG.Y$YZZ!!!V$((}mU[\<
!??vV
 $($C$CFM[actv{$|!((1STfTl
 **63pq$h+8($5B123@/0 ](*%%'	"6  $K  L(!88W9UVVHH  %)%F%Ft{{SZGc%ddH%)%;%;DKK<X%YYH!%!<!<T[[=Y!ZZI  %)%F%Ft{{SZGc%ddH%)%;%;DKK<X%YYH!%!<!<T[[=Y!ZZhJ$:?P !%!;!;DKK<X!YY+,0GL)!%!;!;DKK<X!YY!44T[[5QRRH11o 	": W  eYZ  eYZ Z ZRs   /ML7D(ML:AML=)MM )M0M1AM2M3(MM	(MM?MM3M8M9(M!M"M:M=M MMM	MMMMMc                   #    Uc  [        U R                  S-   5      eU R                  5       I Sh  vN   U R                  U5      nSUS   0nSnU R	                  USSSS5      u  pRU R                  U/ S	Q5      nU R                  US
US
   5      nU R                  U/ SQ5      nSnU R                  SU5      u  pSn	US   (       a*  U R                  U R                  XB5      5      I Sh  vN n	GOUS   (       a  U(       a[  U(       a*  U R                  U R                  XB5      5      I Sh  vN n	GOU R                  U R                  XB5      5      I Sh  vN n	GOYU R                  U R                  XB5      5      I Sh  vN n	GO/US   (       a  U(       aY  U(       a)  U R                  U R                  XB5      5      I Sh  vN n	OU R                  U R                  XB5      5      I Sh  vN n	OU R!                  U R                  XB5      5      I Sh  vN n	OUS:X  d
  Uc  U(       ad  U(       a)  U R#                  U R                  XB5      5      I Sh  vN n	O\US:X  a  SUS'   U R%                  U R                  XB5      5      I Sh  vN n	O(U R'                  U R                  XB5      5      I Sh  vN n	[)        U	[*        5      (       a  U R-                  X5      $ U R/                  SU	05      /$  GN GN	 GN GN GN| GN= GN N N N NY7f)a  
cancel all open orders in a market

https://developers.binance.com/docs/binance-spot-api-docs/rest-api/trading-endpoints#cancel-all-open-orders-on-a-symbol-trade
https://developers.binance.com/docs/derivatives/usds-margined-futures/trade/rest-api/Cancel-All-Open-Orders
https://developers.binance.com/docs/derivatives/coin-margined-futures/trade/rest-api/Cancel-All-Open-Orders
https://developers.binance.com/docs/derivatives/option/trade/Cancel-all-Option-orders-on-specific-symbol
https://developers.binance.com/docs/margin_trading/trade/Margin-Account-Cancel-All-Open-Orders
https://developers.binance.com/docs/derivatives/portfolio-margin/trade/Cancel-All-UM-Open-Orders
https://developers.binance.com/docs/derivatives/portfolio-margin/trade/Cancel-All-UM-Open-Conditional-Orders
https://developers.binance.com/docs/derivatives/portfolio-margin/trade/Cancel-All-CM-Open-Orders
https://developers.binance.com/docs/derivatives/portfolio-margin/trade/Cancel-All-CM-Open-Conditional-Orders
https://developers.binance.com/docs/derivatives/portfolio-margin/trade/Cancel-Margin-Account-All-Open-Orders-on-a-Symbol

: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.trigger]: 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  rO   ra   r  rm  Frk  ry  r}  r]   r  r  rZ   rO  Tr\  r  )r4   rO   r  r  r  rn  r  r  r  eapiPrivateDeleteAllOpenOrdersr  $papiDeleteUmConditionalAllOpenOrderspapiDeleteUmAllOpenOrdersfapiPrivateDeleteAllOpenOrders$papiDeleteCmConditionalAllOpenOrderspapiDeleteCmAllOpenOrdersdapiPrivateDeleteAllOpenOrderspapiDeleteMarginAllOpenOrderssapiDeleteMarginOpenOrdersprivateDeleteOpenOrdersr  r)  r  r	  )
rt  r  r  r  r  r  r.  ry  r>  r  s
             rv  cancel_all_ordersbinance.cancel_all_ordersW  s    , >#DGG.]$]^^!!!V$fTl
 !$($C$CFL]_egxz  %A!((1STv?6#MN
!??@QSYZ
(!@@WA]^^H H  %)%N%Nt{{[bOk%llH &*%C%CDKKPWD`%aaH "&!D!DT[[QXEa!bb I  %)%N%Nt{{[bOk%llH &*%C%CDKKPWD`%aaH "&!D!DT[[QXEa!bb hJ$:?P !%!C!CDKKPWD`!aa+,0GL)!%!@!@WA]!^^0 "99$++g:VWWH, h%%$$X66 H!  A 	" _  m  b c  m  b c b _0 Xs   /LK0B8L*K3+AL,K6-)LK9)L K<ALK?(L+L,(LL?LL3LL		(L1L2?L3L6L9L<L?LLLL	LLidsc                 D  #    Uc  [        U R                  S-   5      eU R                  5       I Sh  vN   U R                  U5      nUS   (       d  [	        U R                  S-   5      eSUS   0nU R                  USS5      nUb  U R                  US/5      nXeS'   OXS	'   SnUS
   (       a)  U R                  U R                  XS5      5      I Sh  vN nO2US   (       a(  U R                  U R                  XS5      5      I Sh  vN nU R                  Xt5      $  N NJ N7f)aH  
       cancel multiple orders

       https://developers.binance.com/docs/derivatives/usds-margined-futures/trade/rest-api/Cancel-Multiple-Orders
       https://developers.binance.com/docs/derivatives/coin-margined-futures/trade/rest-api/Cancel-Multiple-Orders

       :param str[] ids: order ids
       :param str [symbol]: unified market symbol
       :param dict [params]: extra parameters specific to the exchange API endpoint
       :param str[] [params.clientOrderIds]: alternative to ids, array of client order ids

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  rO   origClientOrderIdListclientOrderIdsorderidlistr  r  )r4   rO   r  r  r5   r+  r  fapiPrivateDeleteBatchOrdersr  dapiPrivateDeleteBatchOrdersr  )rt  r  r  r  r  r  r  r  s           rv  cancel_ordersbinance.cancel_orders  s"    " >#DGG.Z$Z[[!!!V$j!TWW'ZZ[[fTl
 !% 0 09PRb c ,YYv(8'9:F/D+,%(M"(!>>t{{7?[\\HI!>>t{{7?[\\HH   22m 	"  ]\s4   /D DBD D2D DD D D c           	        #    Uc  [        U R                  S-   5      eU R                  5       I Sh  vN   U R                  U5      nU R	                  USUS   5      nU R                  US5      nUS:w  a  [        U R                  S-   5      eSU0nU R                  X#X@R                  X5      5      I Sh  vN $  N N7f)a3  
fetch all the trades made from a single order

https://developers.binance.com/docs/binance-spot-api-docs/rest-api/account-endpoints#account-trade-list-user_data
https://developers.binance.com/docs/derivatives/usds-margined-futures/trade/rest-api/Account-Trade-List
https://developers.binance.com/docs/derivatives/coin-margined-futures/trade/rest-api/Account-Trade-List
https://developers.binance.com/docs/margin_trading/trade/Query-Margin-Account-Trade-List

: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 argumentry  rY   z. fetchOrderTrades() supports spot markets onlyrn  )	r4   rO   r  r  r  r  r?   fetch_my_tradesr  )	rt  rO   r  r7  r  r  r  ry  r  s	            rv  fetch_order_tradesbinance.fetch_order_trades@  s       >#DGG.^$^__!!!V$v?66*6>tww)YYZZr
 ))&G@\]]] 	" ^s"   /B>B:BB>5B<6B><B>c                 p  #    U R                  5       I Sh  vN   SnU R                  USS5      u  pTU(       a  U R                  SXX45      I Sh  vN $ 0 nSnSnSn	Ub  U R                  U5      nUS   US'   U R	                  SXt5      u  pU R                  USS5      n
UbI  UnXS	'   U R                  5       nS
nX-
  U:  a)  U
c&  US   (       a  U R                  X5      n
[        X5      n
U
b  XS'   U R                  USS/5      nUb   US:X  d
  US   (       a  [        US5      nX6S'   SnUS:X  a*  U R                  U R                  Xd5      5      I Sh  vN nGOUc  [        U R                  S-   5      eU R                  SU5      u  pSnU R                  USSSS5      u  pUS:X  d  US:X  a  U(       a*  U R!                  U R                  Xd5      5      I Sh  vN nGO+US:X  d  U	b4  U	S:X  a  SUS'   U R#                  U R                  Xd5      5      I Sh  vN nOU R%                  U R                  Xd5      5      I Sh  vN nOUS   (       aY  U(       a)  U R'                  U R                  Xd5      5      I Sh  vN nOU R)                  U R                  Xd5      5      I Sh  vN nObUS   (       aX  U(       a)  U R+                  U R                  Xd5      5      I Sh  vN nO(U R-                  U R                  Xd5      5      I Sh  vN nU R/                  XX#5      $  GN GN GN GNM GN N N N NT N-7f)a  
fetch all trades made by the user

https://developers.binance.com/docs/binance-spot-api-docs/rest-api/account-endpoints#account-trade-list-user_data
https://developers.binance.com/docs/derivatives/usds-margined-futures/trade/rest-api/Account-Trade-List
https://developers.binance.com/docs/derivatives/coin-margined-futures/trade/rest-api/Account-Trade-List
https://developers.binance.com/docs/margin_trading/trade/Query-Margin-Account-Trade-List
https://developers.binance.com/docs/derivatives/option/trade/Account-Trade-List
https://developers.binance.com/docs/derivatives/portfolio-margin/trade/UM-Account-Trade-List
https://developers.binance.com/docs/derivatives/portfolio-margin/trade/CM-Account-Trade-List

: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   r9  rO   r  r:  r?  r>  i $r  r]   r  rR  r  z+ fetchMyTrades() requires a symbol argumentr  rm  rY   rZ   rO  Tr\  r  )r  r  r  r  r
  rj  r  rB  r  r  eapiPrivateGetUserTradesr  r4   rO   r  r  papiGetMarginMyTradessapiGetMarginMyTradesprivateGetMyTradespapiGetUmUserTradesfapiPrivateGetUserTradespapiGetCmUserTradesdapiPrivateGetUserTradesr  )rt  r  r7  r  r  r9  r  r  ry  r>  r?  r>  currentTimestamponeWeekr  r  s                   rv  r  binance.fetch_my_trades]  s-    * !!!88R\]::?F[`iii
[[(F &tGH99/6Z%%fgyAI#,K   $002-G ,8O)9"hhy:G!'<G!(IYYv	7';<F VJ%7E4($G8!::4;;w;WXXH~'2_(_``!%!C!COU[!\J $(,(G(GP_agiz  }B  )C%v~!1$%)%?%?G@\%]]Hh&J,B!Z/04-%)%?%?G@\%]]H%)%<%<T[[=Y%ZZH!$%)%=%=dkk'>Z%[[H%)%B%B4;;wC_%``H	"$%)%=%=dkk'>Z%[[H%)%B%B4;;wC_%``HD   5@@} 	" j> Y  ^  ^Z  \`  \`s   L6L8L6L DL6L#BL6L&=L6L)(L6 L,9L6:L.;(L6#L0$9L6L2(L6L4L6 L6#L6&L6)L6,L6.L60L62L64L6c                 |  #    U R                  5       I Sh  vN   0 nUb  X%S'   U R                  US5      US'   U R                  US5      nU R                  US5      nUb  XeS'   U R	                  U R                  XT5      5      I Sh  vN nU R                  US/ 5      nU R                  USS	5      n	/ n
[        S	U	5       HN  nU R                  X   S
/ 5      n[        S	[        U5      5       H  nSX   S'   U
R                  X   5        M     MP     U R                  U
SX#5      nU R                  XU5      $  GN! N7f)a  
fetch all dust trades made by the user

https://developers.binance.com/docs/wallet/asset/dust-log

: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?  ry  accountTypeuserAssetDribbletsr  r   userAssetDribbletDetailsTrX  )r  rB  safe_string_upperr  sapiGetAssetDribbletr  r  r  r  r  r  r  r  )rt  r  r7  r  r  r  r  r  r  rowsr  r  logsr  rT  s                  rv  fetch_my_dust_tradesbinance.fetch_my_dust_trades2  sD    & !!!#(K !%%!<GI,,VV<66*"%0M"224;;w3OPP< ..+?D  7A6q$A>>'*.H"MD1c$i()-&DG$ )  
 ""4u<))&??a 	" Qs#   D<D7A0D<D:B0D<:D<c                    U R                  US5      nU R                  US5      nU R                  US5      nU R                  U5      nU R                  S5      nUS   nUS-   U-   n	Sn
XR                  ;   a  Sn
U R                  US	5      nUU R                  U5      S
.nS nS nS nS nU
(       a)  U	nU R                  US5      nU R                  US5      nSnO.US-   U-   nU R                  US5      nU R                  US5      nSnS nUb  U(       a  [        R                  " X5      nS nU R                  U5      nU R                  U5      nU R                  U5      nS nS nUUU R                  U5      UUUUUUUUUUS.$ )NtransIdoperateTime	fromAssetr   r  r  FTserviceChargeAmountrg  r)  transferedAmountr  rc  rb  )rO   r  r  r  ro  ry  rr  rR  r  r  r)  r  r  )	r  r  r  rg  r  rr  rI   
string_divro  )rt  rV  r  rn  r  r  tradedCurrencybnbearnedCurrencyapplicantSymboltradedCurrencyIsQuotefeeCostStringr  r  r  
costStringrR  r  rO   r  r  r)  ry  rr  s                           rv  rs  binance.parse_dust_tradew  s    ""5)4%%e];	%%e[9
00<mmE"V(3.? %ll*$(!((0EF&%%m4
 
 $F++E3EFL))%:JD#c)N:F++E8<L))%1CDJD!%00J""<0!!+.  ,"Y/(
 	
rx  r  c                   #    U R                  5       I Sh  vN   SnU R                  USS5      u  pTU(       a  U R                  SXX45      I Sh  vN $ SnSn0 nU R                  U R                  S0 5      n	U R                  USS5      n
U R                  US5      nU R                  US5      nU R                  US5      nU
(       d  X;   ac  Ub  U R                  U5      nS	US
'   Ub  X(S'   Ub  XS'   U R                  U R                  X5      5      I Sh  vN nU R                  US/ 5      nOvUb  U R                  U5      nUS   US'   Ub(  X(S'   U R                  US5      nUb  [        X5      nXS'   Ub  X8S'   U R                  U R                  X5      5      I Sh  vN n[        S	[!        U5      5       H
  nSX~   S'   M     U R#                  XvX#5      $  GN GN N NA7f)a  
fetch all deposits made to an account

https://developers.binance.com/docs/wallet/capital/deposite-history
https://developers.binance.com/docs/fiat/rest-api/Get-Fiat-Deposit-Withdraw-History

: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 [available 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   r9  r2  r  fiatOnlyr:  r   transactionType	beginTimer?  r  rO   r  r>  r  r  r  ry  )r  r  r  r  r  r  r  r  rg  sapiGetFiatOrdersr  r  rB  r  sapiGetCapitalDepositHisrecr  r  parse_transactions)rt  r  r7  r  r  r9  rg  r  r  r2  r  r:  rawr?  r  s                  rv  fetch_depositsbinance.fetch_deposits  s      !!!88R\]::?DY^ggg^^DLL,C
>>&&%86:.!!&'267+*==.)*G%& ',$ %*	"..t{{7/KLLC~~c626H* ==."*4. ',$((5*5$!'1G%,	" #( !==dkk'>Z[[H6 q#h-(A"+HK )&&x5HHi 	" h" MD \sG   G$G8G$GCG$G B	G$ G"!:G$G$ G$"G$c                   #    U R                  5       I Sh  vN   SnU R                  USS5      u  pTU(       a  U R                  SXX45      I Sh  vN $ U R                  U R                  S0 5      nU R                  USS5      nU R                  US5      n0 nU R                  US5      n	U	b  U R                  US5      nXS	'   Sn
SnU(       d  X;   a\  Ub  U R                  U5      nS
US'   Ub  X(S'   U R                  U R                  X5      5      I Sh  vN nU R                  US/ 5      n
OgUb  U R                  U5      nUS   US'   Ub  X(S'   U R                  US5      US	'   Ub  X8S'   U R                  U R                  X5      5      I Sh  vN n
[        S[        U
5      5       H
  nSX   S'   M     U R!                  XX#5      $  GN GN N NA7f)a  
fetch all withdrawals made from an account

https://developers.binance.com/docs/wallet/capital/withdraw-history
https://developers.binance.com/docs/fiat/rest-api/Get-Fiat-Deposit-Withdraw-History

: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 [available 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   r9  r2  r  r  r:  r?  r   r  r  r  rO   r  r>  r  r  r   
withdrawalry  )r  r  r  r  r  r  r  r  rg  r  r  r  rB  sapiGetCapitalWithdrawHistoryr  r  r  )rt  r  r7  r  r  r9  r2  r  r  r:  r  rg  r  r  s                 rv  fetch_withdrawalsbinance.fetch_withdrawals   s      !!!88ASU_`::;Mt\ajjj^^DLL,C
>>&&%86:.!!&'2YYvw/F!&I*==.)*G%& ',$..t{{7/KLLC~~c626H@ ==."*4. ',$%)XXeZ%@	" #( !??G@\]]HP q#h-(A".HK )&&x5HHS 	" k" MT ^sG   GG8GGCGGA:GG:GGGGc                     Uc  U$ SSSSSSSSSS.	SSSSSSSSSSSSSS.S.nU R                  X20 5      nU R                  XAU5      $ )Npendingr  failedr  )	r  rJ  6
ProcessingFailed
Successful	RefundingRefundedRefund Failed)r  rJ  2345r  r	  r
  r  r  r  r  )r  r  )r  r  )rt  rF  ry  statusesByTyper  s        rv   parse_transaction_status_by_type(binance.parse_transaction_status_by_type  s    <M  (""'&!)  (""'&!) 
@ >>.;&99rx  transactionrg  c                 6   U R                  USS5      nU R                  US5      nU R                  US5      nUb  [        U5      S:  a  S nU R                  US5      nUb  UR                  S5      S:  a  US	S  nU R                  US
S5      nU R	                  Xr5      nS n	U R                  USS5      n	U	c!  U R                  U R                  US5      5      n	U R                  USS5      n
U R                  US5      nUcM  U R                  US5      nUb
  US:X  a  SOSnU R                  U R                  S5      nU R                  XU5      nU R                  U R                  US5      U5      nU R                  US5      nU R                  USS5      nS nUb  UUS.nU R                  US5      nS nUb
  US:w  a  SOSnU R                  US5      n0 S U_SU_S!U_S"U	_S#U R                  U	5      _SU_SU_S$U_S%S _S&U_S'U_S(S _SU_SU_S)U_SU_S*U
_US US+.E$ ),NrO   orderNoaddress
addressTagr   txIdzInternal transfer r      r  fiatCurrency
insertTimer  	applyTimesuccessTimer  ry  r  r  r  r  r3  rF  r  transactionFeetotalFeer  transferTypeTFr  r  txidr  r  	addressToaddressFromtagtagTotagFromrg  r  )internalcommentr  )r  r  r  r  r  rj  r  r  r  r  r  rn  r  ro  )rt  r  rg  rO   r  r'  r$  r  r  r  r  ry  txTyper3  rF  r  r  r  internalIntegerr*  r  s                        rv  parse_transactionbinance.parse_transaction  s   B T9="";	:{L9?3x!|V4499-A#Ba#G9D''V^L
&&z<	''\<P	t'7'7['QRI%%k=,OV4<%%k3DEF!%+s]y'+~~dllD^'_$##$<DID66t7G7GU]7^`de!!+x8$$[2BJO#W5C++KH& /1 4t5H"";	:
K
"
 D
 	

 Y/
 w
 w
 
 4
 3
 S
 t
 D
 f
 
  f!
" w#
$ !)
 	
rx  c                 .    SS0nU R                  X!U5      $ )N	CONFIRMEDr  r  r  s      rv  parse_transfer_statusbinance.parse_transfer_status;   s#    
 &99rx  r   c           
         U R                  USS5      nU R                  USS5      nU R                  XB5      nU R                  US5      nU R                  US5      nS nS n	U R	                  U R
                  S0 5      n
UbY  UR                  S5      nU R                  US	5      nU R                  US
5      n	U R                  XU5      nU R                  XU	5      n	U R                  US5      nUbJ  U R	                  US0 5      nU R	                  US0 5      nU R                  US5      nU R                  US5      n	U R                  USS5      nU R                  U R                  US5      5      nUUUU R                  U5      UUUU	US.	$ )NtranIdtransactionIdr  rg  r  ry  r.  r<  r   r   
walletType	payerInforeceiverInfo	accountIdr  transactionTimerF  )	r  rO   r  r  rg  r  fromAccount	toAccountrF  )r  r  r  r  r  r  r  r  r  rj  r2  ro  )rt  r   rg  rO   r  r  r  ry  r<  r=  r.  rP  r7  payerreceiverr  rF  s                    rv  parse_transferbinance.parse_transferA   s   F (OD''':F
&&z<!!(H5&1	~~dllNBGJJsOE//%3Kq1I**<kRK(()LI&&x>
!NN8["=E~~hCH**5+>K((;?I''+?PQ	++D,<,<Xx,PQ"Y/&"

 
	
rx  c           
          U R                  US5      nU R                  US5      nU R                  US5      nUU R                  X2S S5      U R                  U5      UU R	                  U5      U R                  US5      U R                  US5      S.$ )Nr  r  rM  r[   r5  rw  )r  r  r  r  r  rO   r  )r  r  r  r  ro  r  )rt  rw  r  r  r  r  s         rv  parse_incomebinance.parse_income   s     ##FH5%%fg6
%%ff5	&&xvF++J7"Y/""684&&vx8
 	
rx  r<  r=  c                   #    U R                  5       I Sh  vN   U R                  U5      nUS   U R                  X5      S.nU R                  US5      US'   U R	                  US5      nUS   Gc-  U R                  US5      nSn	Ub#  U R                  U5      n	U R	                  US5      nU R                  U5      R                  5       n
U R                  U5      R                  5       nSnU	b  U	S   nU
S:X  a  Uc  [        U R                  S-   U-   5      eUS:X  a  Uc  [        U R                  S-   U-   5      eU R                  U R                  S	0 5      nX;  nX;  nU(       a  U	c  U
nU(       a  U	c  UnU(       d  U(       Ga  U
S
:H  =(       d    U
S:H  nUS
:H  =(       d    US:H  nU
S:H  nUS:H  nU
S:H  =(       d    US:H  nU
S:H  =(       d    US:H  nU=(       d    U=(       d    U=(       d    UnU(       d  U(       a(  U(       a!  [        U R                  S-   U-   S-   U-   5      eU(       a  U(       a  Sn
XS'   OJU(       a  U(       a  SnXS'   O5U(       a  U(       a  XS'   XS'   Sn
SnOU(       a  XS'   Sn
U(       a  XS'   SnU
S-   U-   US'   OU
S-   U-   US'   U R                  U R                  Xu5      5      I Sh  vN nU R                  UU5      $  GN N7f)ao  
transfer currency internally between wallets on the same account

https://developers.binance.com/docs/wallet/asset/user-universal-transfer

: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>`
NrO   r  r  ry  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  rg  currency_to_precisionr  r  r  convert_type_to_accountr  r4   rO   r  r  r5   sapiPostAssetTransferr  r@  )rt  r  r  r<  r=  r  rg  r  r  r  fromIdtoIdisolatedSymbolr.  fromIsolated
toIsolated
fromFuturetoFuturefromSpottoSpotr  r]   prohibitedWithIsolatedr  s                           rv  r   binance.transfer   s     !!!==&d^00>
 **66:66*6?"%%fh7FF!V,68411+>DDFF//	:@@BD!N!!'#>+DGG6r,r  vA  -A  B  Bz!>+DGG6p,ps|,|}}>>$,,KL & 6L"2J!'v~!%z#z1IVz5I
:-C1C!V+ I-B1B8+?tx/?)3)Tx)T7)Tf& J4J$TWW/^%^al%lov%v  zC  &C  D  D.F,:L)*,D*8J'#
06-.2
+!1/'4BL1%5F%2@J/#3D"(3,"5"(3,"533DKK4PQQ ""8X66M 	"@ Rs"   KKJ*KKKKc                 H  #    U R                  5       I Sh  vN   U R                  US5      nU R                  US5      nSnU R                  USS5      u  pdU(       a"  U(       d  U R	                  SXX45      I Sh  vN $ SnUb  U R                  U5      n0 nSn	U(       Gd<  U R                  U R                  SSS5      n
U R                  US	U
5      nUS
:X  a  SOS
nU R                  USU5      nU R                  US5      nU R                  U R                  S0 5      nU R                  X5      nU R                  X5      nUc  UcC  [        UR                  5       5      n[        U R                  S-   SR                  U5      -   5      eUcC  [        UR                  5       5      n[        U R                  S-   SR                  U5      -   5      eUS-   U-   nXS'   Sn	Ub  X8U	'   Ub  X(S'   U R                  US5      nUb  U R                  US5      nUUS'   SnU(       a)  U R!                  U R#                  X5      5      I Sh  vN nO(U R%                  U R#                  X5      5      I Sh  vN nU R'                  USS/ 5      nU R)                  UXrU5      $  GN GN! NZ N37f)a  
fetch a history of internal transfers made on an account

https://developers.binance.com/docs/wallet/asset/query-user-universal-transfer

: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 [available parameters](https://github.com/ccxt/ccxt/wiki/Manual#pagination-params)
:param boolean [params.internal]: default False, when True will fetch pay trade history
:returns dict[]: a list of `transfer structures <https://docs.ccxt.com/#/?id=transfer-structure>`
Nr*  Fr   r9  r  r  rY   r<  r\   r=  ry  r-  z& fromAccount parameter must be one of z, z$ toAccount parameter must be one of r<  sizer>  r:  r?  r  r  )r  r  r  r  r  rg  r  r  r  r  r)  r*  r0   rO   joinr  sapiGetPayTransactionsr  sapiGetAssetTransferr+  parse_transfers)rt  r  r7  r  r  r*  r9  rg  r  limitKeyr  r<  	defaultTor=  ry  r-  rO  rP  r*  r:  r  r  s                         rv  fetch_transfersbinance.fetch_transfers!  s     !!!>>&*56:.88AQS]^H::;KTZ_hhh}}T*H,,T\\;K]\bcK**6=+NK#.(#:I((iHI##FF3D!^^DLL:JBON%%nBF##N>D|> 3 3 56D'2Z(Z]a]f]fgk]l(lmm< 3 3 56D'2X(X[_[d[dei[j(jkk|d*"FOH %H#(K !!&'2YYvw/F!&GI!88W9UVVHv "66t{{77STTH  &&"=##D(5AAk 	" iF Wv UsG   J"JA#J":J;GJ"J(J",J -,J"J"J" J"c                   #    U R                  5       I Sh  vN   U R                  U5      nSUS   0nU R                  U R                  S0 5      nU R	                  US5      nU R                  XVU5      nUb  XdS'   U R                  US5      nU R                  U R                  XB5      5      I Sh  vN nU R                  Xs5      $  N N7f)a  
fetch the deposit address for a currency associated with self account

https://developers.binance.com/docs/wallet/capital/deposite-address

:param str code: unified currency code
:param dict [params]: extra parameters specific to the exchange API endpoint
:param str [params.network]: network for fetch deposit address
:returns dict: an `address structure <https://docs.ccxt.com/#/?id=address-structure>`
Nr  rO   r/  r  )
r  rg  r  r  r  r  r  sapiGetCapitalDepositAddressr  parse_deposit_address)rt  r  r  rg  r  r/  r  r  s           rv  fetch_deposit_addressbinance.fetch_deposit_address!  s      !!!==&HTN
 >>$,,
B?((;""8g>!(IYYvy1F::4;;w;WXX ))(==7 	" Ys"   C
CBC
0C1C
C
c                 ,   U R                  US5      nU R                  US5      nU R                  US5      nU R                  XR5      nU R                  Xc5      nU R                  USS5      n[        U5      S:X  a  S nU R	                  U5        UUUUUS.$ )Nr  r  rg  r'  r  r   )r  rg  r  r  r'  )r  r  get_network_code_by_network_urlr  check_address)	rt  r  rg  r  r  r  r  r  r'  s	            rv  rf  binance.parse_deposit_address!  s     x/""8Y7%%h
;
&&z< ::4Ex3s8q=C7#"
 	
rx  codesc                   #    U R                  5       I Sh  vN   U R                  U5      I Sh  vN n0 n[        S[        U5      5       H  nX5   nU R	                  US5      nU R                  U5      nU R                  US/ 5      n	0 XH'   [        S[        U	5      5       HC  n
X   nU R	                  US5      nU R                  U5      nU R                  US5      nXU   U'   ME     M     U0 US.$  N N7f)a  
@deprecated
       please use fetchDepositWithdrawFees instead

       https://developers.binance.com/docs/wallet/capital/all-coins-info

       :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  )rt  rm  r  r  withdrawFeesr  r  r  r  r  r  networkEntry	networkIdr  r  s                  rv  fetch_transaction_feesbinance.fetch_transaction_fees!  s     !!!88@@d  q#h-(AKE))%8J**:6D..rBK!#L1c+./*~ ,,\9E	"55i@&&|]C25T";/ 0 ) %
 	
A 	"@s    C6C2C6C4CC64C6c                    #    U R                  5       I Sh  vN   U R                  U5      I Sh  vN nU R                  X1S5      $  N/ N7f)aR  
fetch deposit and withdraw fees

https://developers.binance.com/docs/wallet/capital/all-coins-info

: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)rt  rm  r  r  s       rv  fetch_deposit_withdraw_fees#binance.fetch_deposit_withdraw_feesR"  sK      !!!88@@V //HHY 	"@s   A
AA
AA
A
c                 X   U R                  US/ 5      nU R                  U5      n[        S[        U5      5       Hl  nX5   nU R	                  US5      nU R                  U5      nU R                  US5      n	U R                  US5      n
U
SL a  U	S S.US'   U	S S.S S S.S	.US
   U'   Mn     U$ )Nr  r   r  r  r  T)r  r  r   r  r/  )r  deposit_withdraw_feer  r  r  r  r  r  )rt  r  rg  r  r  r  rp  rq  r  r  r  s              rv  parse_deposit_withdraw_fee"binance.parse_deposit_withdraw_fee"  s    R nnS-<**3/q#k*+A&>L((yAI11)<K**<GK|[AID &"&&z" '"&
  "&	/F:{+ ,* rx  r  r'  c                   #    U R                  XE5      u  pEU R                  U5        U R                  5       I Sh  vN   U R                  U5      nUS   US.nUb  XGS'   U R	                  U R
                  S0 5      nU R                  US5      n	U R                  XU	5      n	U	b  XS'   U R                  US5      nU R                  XU	5      US'   U R                  U R                  Xu5      5      I Sh  vN n
U R                  X5      $  N N7f)a  
make a withdrawal

https://developers.binance.com/docs/wallet/capital/withdraw

:param str code: unified currency code
:param float amount: the amount to withdraw
:param str address: the address to withdraw to
:param str tag:
:param dict [params]: extra parameters specific to the exchange API endpoint
:returns dict: a `transaction structure <https://docs.ccxt.com/#/?id=transaction-structure>`
NrO   )r  r  r  r/  r  r  )handle_withdraw_tag_and_paramsrk  r  rg  r  r  r  r  r  rL  sapiPostCapitalWithdrawApplyr  r.  )rt  r  r  r  r'  r  rg  r  r/  r  r  s              rv  r   binance.withdraw"  s     99#F7#!!!==&TN
 ?$'L!>>$,,
B?((;""8g>!(IYYvy1F 66tWM::4;;w;WXX%%h99' 	"" Ys"   8DDB6D1D	2D	Dr  c                     U R                  US5      nU R                  X2S S5      nUUU R                  USS5      U R                  USS5      S S S.$ )Nr  rY   makerCommissionmakerCommissionRatetakerCommissiontakerCommissionRate)r  r  r  r  r  r  )r  r  rn  )rt  r  r  r  r  s        rv  parse_trading_feebinance.parse_trading_fee"  sh    $ ##C2!!(D&A''->@UV''->@UV
 	
rx  c                 z  #    U R                  5       I Sh  vN   U R                  U5      nUS   nSnU R                  SX25      u  pRSnU R                  USSSS5      u  pbU R	                  XE5      nU R                  XE5      nSUS   0n	Sn
U(       aY  U(       a)  U R                  U R                  X5      5      I Sh  vN n
OU R                  U R                  X5      5      I Sh  vN n
OU(       aY  U(       a)  U R                  U R                  X5      5      I Sh  vN n
OQU R                  U R                  X5      5      I Sh  vN n
O(U R                  U R                  X5      5      I Sh  vN n
U
n[        U[        5      (       a  U R                  US	0 5      nU R                  X5      $  GN N N N Nq NJ7f)
a}  
fetch the trading fees for a market

https://developers.binance.com/docs/wallet/asset/trade-fee
https://developers.binance.com/docs/derivatives/usds-margined-futures/account/rest-api/User-Commission-Rate
https://developers.binance.com/docs/derivatives/coin-margined-futures/account/rest-api/User-Commission-Rate
https://developers.binance.com/docs/derivatives/portfolio-margin/account/Get-User-Commission-Rate-for-UM
https://developers.binance.com/docs/derivatives/portfolio-margin/account/Get-User-Commission-Rate-for-CM

: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>`
Nry  r   r  rm  Fr  rO   r   )r  r  r  r  r  r~  papiGetUmCommissionRater  fapiPrivateGetCommissionRatepapiGetCmCommissionRatedapiPrivateGetCommissionRatesapiGetAssetTradeFeer  r)  r  r  )rt  r  r  r  ry  rz  r  isLinear	isInverser  r  r  s               rv  fetch_trading_feebinance.fetch_trading_fee#  s      !!!V$f~99:KV\ $($C$CFL]_egxz  %A!>>$0OOD2	fTl
  !%!=!=dkk'>Z![[!%!B!B4;;wC_!`` !%!=!=dkk'>Z![[!%!B!B4;;wC_!``!66t{{77STTH( dD!!>>$2.D%%d33_ 	" \` \`Tsk   F;F.B%F;<F1=(F;%F3&6F;F5(F;F7(F;.F9/A F;1F;3F;5F;7F;9F;c                 *  #    U R                  5       I Sh  vN   SnU R                  SSU5      u  p!SnU R                  SSUS5      u  p1US:H  =(       d    US:H  nU R                  X#5      nU R	                  X#5      nSnU(       a  U R                  U5      I Sh  vN nOAU(       a  U R                  U5      I Sh  vN nO U(       a  U R                  U5      I Sh  vN nU(       a<  0 n[        S[        U5      5       H  n	U R                  Xy   5      n
U
S   nXU'   M!     U$ U(       a  [        U R                  R                  5       5      n0 nU R                  US5      nU R                  S   S	   S
   nUS   U   S   nUS   U   S   n[        S[        U5      5       H-  n	X   nU R                  U   nUS   (       d  M"  SU0UUUS.X'   M/     U$ U(       a  [        U R                  R                  5       5      n0 nU R                  US5      nU R                  S   S	   S
   nUS   U   S   nUS   U   S   n[        S[        U5      5       H-  n	X   nU R                  U   nUS   (       d  M"  SU0UUUS.X'   M/     U$ g GNq GN GN GN7f)a  
fetch the trading fees for multiple markets

https://developers.binance.com/docs/wallet/asset/trade-fee
https://developers.binance.com/docs/derivatives/usds-margined-futures/account/rest-api/Account-Information-V2
https://developers.binance.com/docs/derivatives/coin-margined-futures/account/rest-api/Account-Information
https://developers.binance.com/docs/derivatives/usds-margined-futures/account/rest-api/Account-Config

: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  rY   rZ   r   r  feeTierr  r  r  r   r  )r  r  r  r  r  )r  r
  r  r  r~  r  fapiPrivateGetAccountConfigr  r  r  r  r)  r  r*  r  r  )rt  r  ry  rz  isSpotOrMarginr  r  r  r  r  r  r  r!  r  feeTiersr  r  r  s                     rv  fetch_trading_feesbinance.fetch_trading_feesN#  s     !!!99:LdTZ[99:LdTZ\de&.?dh.>>>$0OOD2	!66v>>H!==fEEH!77??Hb  F1c(m,,,X[9X!$v - M, 4<<,,./GF'')<Gyy*95g>HW%g.q1EW%g.q1E1c'l+ f-(## &w! #)!&!&&FN	 , M 4<<,,./GF'')<Gyy+I6w?HW%g.q1EW%g.q1E1c'l+ f-)$$ &w! #)!&!&&FN	 , Mu 	" ?E?sT   JJBJJ
 J;J< JJC#JB-J5J
JJJc                 0  #    US:  d  US:  a  [        U R                  S-   5      eU R                  5       I Sh  vN   U R                  U5      nUS   UUS.nU R	                  U R                  Xd5      5      I Sh  vN nU R                  Xu5      $  NW N7f)u  
@ignore
       transfer between futures account

       https://developers.binance.com/docs/derivatives/usds-margined-futures/account/rest-api/New-Future-Account-Transfer

       :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   r  z type must be between 1 and 4NrO   )r  r  ry  )r4   rO   r  rg  sapiPostFuturesTransferr  r@  )rt  r  r  ry  r  rg  r  r  s           rv  futures_transferbinance.futures_transfer#  s      1H$(#DGG.M$MNN!!!==&d^

 55dkk'6RSS ""866 	" Ts"   8BBAB<B=BBc                   #    U R                  5       I Sh  vN   U R                  U5      nSUS   0nSnUS   (       a)  U R                  U R                  XB5      5      I Sh  vN nOKUS   (       a)  U R	                  U R                  XB5      5      I Sh  vN nO[        U R                  S-   5      eUS   (       a  US   nU R                  XS5      $  N Nr NA7f)a  
fetch the current funding rate

https://developers.binance.com/docs/derivatives/usds-margined-futures/market-data/rest-api/Mark-Price
https://developers.binance.com/docs/derivatives/coin-margined-futures/market-data/rest-api/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  rO   r  r  z> fetchFundingRate() supports linear and inverse contracts onlyr   )r  r  r)  r  r*  r?   rO   parse_funding_ratert  r  r  r  r  r  s         rv  fetch_funding_ratebinance.fetch_funding_rate$  s      !!!V$fTl
 (!;;DKK<XYYHI!;;DKK<XYYHtww)iijj){H &&x885 	" ZYs4   CCAC"C#2CC>CCCc                   #    U R                  5       I Sh  vN   0 nSnU R                  USS5      u  pdU(       a  U R                  SXUSU5      I Sh  vN $ U R                  U R                  SSS5      nU R                  USU5      nSn	Ub  U R                  U5      n	U	S	   nU	S
   US	'   Sn
U R                  SXS5      u  pU R                  US5      nUb  X%S'   U R                  US5      nU R                  USU5      nU R                  USS/5      nUb  XS'   Ub  X5S'   SnU R                  X5      (       a)  U R                  U R                  XT5      5      I Sh  vN nO]U R                  X5      (       a)  U R                  U R                  XT5      5      I Sh  vN nO[        U R                   S-   U-   S-   5      eU R#                  XX#5      $  GN GN Nz N=7f)at  
fetches historical funding rate prices

https://developers.binance.com/docs/derivatives/usds-margined-futures/market-data/rest-api/Get-Funding-Rate-History
https://developers.binance.com/docs/derivatives/coin-margined-futures/market-data/rest-api/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 [available 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   r9  r   r  r\   ry  r  rO   r  r>  r:  r?  r  z0 fetchFundingRateHistory() is not supported for  markets)r  r  r@  r  r  r  r  r  r  r  r  fapiPublicGetFundingRater  r~  dapiPublicGetFundingRater?   rO   parse_funding_rate_histories)rt  r  r7  r  r  r  r9  r  ry  r  rz  r:  r?  r  s                 rv  fetch_funding_rate_history"binance.fetch_funding_rate_history=$  s      !!!88AZ\fg@@AZ\bkprvx~((7PR_aij<[[(FH%F &tGH99:SU[emn66*#(K !!&'2##FIu=6Iw#78!(I$G>>$((!::4;;w;WXXH__T++!::4;;w;WXXHtww)[[^bbeoopp 005PPO 	"
 @, YXsF   GG<GGD
GG>GG6GGGGc                     U R                  US5      nUU R                  U R                  US5      S S S5      U R                  US5      UU R	                  U5      S.$ )NfundingTimer  r[   rX  )r  r  rX  r  r  )r  r  r  r  ro  )rt  r  r  r  s       rv  parse_funding_rate_history"binance.parse_funding_rate_historyv$  se     %%h>	&&t'7'7('KTSWY_`++HmD"Y/
 	
rx  c                 4  #    U R                  5       I Sh  vN   U R                  U5      nU R                  U R                  SSS5      nU R	                  USU5      nSnU R                  SSUS5      u  pRU R                  US5      nSnU R                  XE5      (       a  U R                  U5      I Sh  vN nOHU R                  XE5      (       a  U R                  U5      I Sh  vN nO[        U R                  S-   5      eU R                  Xq5      $  N N` N27f)aK  
fetch the funding rate for multiple markets

https://developers.binance.com/docs/derivatives/usds-margined-futures/market-data/rest-api/Mark-Price
https://developers.binance.com/docs/derivatives/coin-margined-futures/market-data/rest-api/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 list of `funding rate structures <https://docs.ccxt.com/#/?id=funding-rates-structure>`, indexed by market symbols
Nr   r  r\   ry  r  z? fetchFundingRates() supports linear and inverse contracts only)r  r  r  r  r  r  r  r  r)  r~  r*  r?   rO   parse_funding_rates)rt  r!  r  r  ry  rz  r  r  s           rv  fetch_funding_ratesbinance.fetch_funding_rates$  s     !!!%%g.((7JM[cd<99:MtU[]ef		&&)>>$((!;;EBBH__T++!;;EBBHtww)jjkk'':: 	" CBs4   DDBD3D4/D#D$/DDDc                 .   U R                  US5      nU R                  US5      nU R                  XBS S5      nU R                  US5      nU R                  US5      nU R                  US5      nU R                  US5      n	U R                  US5      n
U R                  US	5      nU R                  US
5      nS nUb  US-   n0 SU_SU_SU_SU_SU_SU	_SU_SU R	                  U5      _SU
_SU_SU R	                  U5      _SS _SS _SS _SS _SS _SS _SU0E$ )NrM  r  r  r  r  interestRateestimatedSettlePricelastFundingRatenextFundingTimefundingIntervalHourshr  r  r  rX  fundingTimestampfundingDatetimenextFundingRatenextFundingTimestampnextFundingDatetimepreviousFundingRatepreviousFundingTimestamppreviousFundingDatetimer;  )r  r  r  r  ro  )rt  r  r  r  r  r  r  r  r  r  rX  r  r;  intervalStrings                 rv  r  binance.parse_funding_rate$  s   4 %%h7	##Hh7!!(D*E$$X{;	%%h=
''.A#//:PQ&&x1BC''2CD##H.DE%^N
H
f
 
 *	

 L
 #$8
 
 Y/
 ;
 
 t||K8
 t
 #D
 "4
 "4
  '!
" &t#
$ %
 	
rx  c           	         U R                  US5      nU R                  US/ 5      n0 n[        S[        U5      5       Hi  nXF   nU R                  US5      nU R	                  U5      n	U R                  US5      n
U R                  US5      n[
        R                  " X5      U
S.XY'   Mk     / n[        S[        U5      5       H  nX6   nU R                  US5      nU R                  US S S	5      nUS
   (       a  US   OUS   n	U R                  US5      nUS:g  =(       a    US:g  nU(       a	  U(       d  Mt  X;   d  M{  U R                  U R                  UXY   S   XY   S   S.5      U5      nUR                  U5        M     U$ )N	positionsr  r   r  crossWalletBalance
crossUnPnl)crossMarginr  r  r  r  r  r  maintMarginr  z
0.00000000r  )r  r  r  r  r  rI   r  r  parse_account_positionr  r  )rt  rt  filterClosedr  r  r  r  r  r  r  r  r  r  r  r  r  maintenanceMarginisPositionOpenparseds                      rv  parse_account_positionsbinance.parse_account_positions$  s   NN7K8	26q#f+&AIE))%9J**:6D!%!1!1%9M!N))%>J&112DQ&8HN ' q#i.)A |H''(;H%%hdJGF&,X&66'?F6ND $ 0 0= I/36_=NR^=^N>>#!88X'/~m'D.6n=Q.RP :  F MM&) *  rx  c           
      t   U R                  US5      nU R                  X2S S5      nU R                  US5      nU R                  US5      nUb  [        U5      OS nU R                  US5      nU R                  U5      nS n	Ub`  [        R
                  " SUS5      n	U R                  SU-  5      n
U
(       d-  [        R
                  " [        R                  " U	S5      SS5      n	S	U;   nU R                  US
5      nU R                  U5      nU R                  US5      nU R                  U5      nU R                  US	S5      n[        R                  " U5      nU R                  U5      nU R                  US5      n[        R                  " U5      nUc  [        R                  " [        R                  " XW5      U5      nU R                  US5      n[        R
                  " UU5      n[        R
                  " [        R                  " US5      SS5      nU R                  U5      nU R                  U R                  S0 5      nU R                  UU/ 5      nS n[        S[        U5      5       H.  nUU   n[        R                   " UUS   5      (       a    O	US   nM0     U R                  U5      nU R                  US5      nU R                  U5      nU R#                  US5      n U S:X  a  S n U R%                  US5      n!U!c.  U R                  US5      n"[        R&                  " U"S5      (       + n!S n#S n$S n%U!(       a,  Sn#U R                  US5      n%[        R                  " U%U5      n$O&Sn#U R                  US5      n%U R                  US5      n$U R                  U$5      n&S n'S n(S n)S n*S n+U R)                  US5      n,U R+                  U,5      n-[        R,                  " US5      (       a  S nGO[        R                   " US5      (       a  SOSn(U R                  [        R
                  " [        R                  " [        R
                  " UU$5      S5      SS5      5      n'U R                  [        R                  " [        R
                  " UUS5      S 5      5      n)U(       a  S n.Un/U(S:X  a  [        R                  " SU5      n.O.[        R                  " S!U5      n.[        R                  " S!U/5      n/[        R
                  " U%[        R                  " UU.5      5      n0[        R
                  " U/U.5      n1[        R                  " U0U15      n*OS n.Un/U(S:X  a  [        R.                  " SU5      n.O.[        R.                  " S!U5      n.[        R                  " S!U/5      n/[        R                  " UU-5      n2[        R                  " U2U.5      n0[        R.                  " [        R                  " [        R
                  " SU/5      U25      U%5      n1[        R
                  " U0U15      n*U R1                  U R                  US"   S#5      5      n3U3S-   n4[3        U45      n5[	        S$U5-   5      n6[3        U65      n7[        R                  " U7U*5      n8[        R
                  " U8SU35      n9U9S   S%:X  a  S n9U R                  U95      n+U R                  US&5      n:U:S':g  n;0 S(U_S)S _SU_S*U _S+U R5                  U 5      _SU_S,U R                  U	5      _S-U_S.U_SU_S	U_SU R                  U5      _S/U_S0U_SU,_S1U'_S2U+_S U&U#U(U;U)S3.E$ )4Nr  r  r  r  rJ  r  rR  1e-8rg  r  
entryPricenotionalValuepositionAmtr  z0.5r   leverageBracketsr   unrealizedProfitr  rO  isolatedMarginr  isolatedWalletr  r  r  shortlong5e-5r  r;  rj  r  r  z5e-r  r  BOTHr  rO   r  r  initialMarginPercentager  maintenanceMarginPercentageunrealizedPnl	contractsmarginRatioliquidationPrice)r  
collateralr>  rR  rF  r  )r  r  intrr  rI   r  is_round_numberr  r  
string_absr  r  r  r  r  r  	string_ltr  r  r  r  rl  string_equals
string_subprecision_from_stringr  ro  )<rt  r  r  r  r  leverageStringr  initialMarginStringr  initialMarginPercentageStringrationalusdmmaintenanceMarginStringr  entryPriceStringr  notionalStringnotionalStringAbsrg  contractsStringcontractsStringAbsentryNotionalcontractSizeNewr  r  rx  !maintenanceMarginPercentageStringr  bracketr  unrealizedPnlStringr  r  rO  isolatedMarginRawr>  collateralStringwalletBalancer  r  rR  r  liquidationPriceStringRawr  r  contractSizeString(onePlusMaintenanceMarginPercentageStringentryPriceSignStringleftSide	rightSider[  rU  pricePrecisionPlusOnepricePrecisionPlusOneStringrounderrounderStringliquidationPriceRoundedStringtruncatedLiquidationPricer  rF  s<                                                               rv  r  binance.parse_account_position %  s   p ##Hh7!!(D*E!!&(3))(J?+9+E3~&D"..xI))*=>(,%%,3,>,>sNTU,V)++D8O<H070B0B7CUCUVsu{C|  B  DE  1F-h&"&"2"28]"K --.EF++HlC&&'78
++Hj/R#..~>$$%67**8]C$//@"#..w/A/A./fhxyM"..v~FO%00PO!(!3!3G4F4FX]4^`cef!g%%&89	>>$,,8JBO..)962F,0)q#o./A%a(G  !2GAJ??07
-	 0
 '+&7&78Y&Z#"..x9KL))*=>%%h=	>I>>(J7 $ 0 0;K L",,->DDH
#J ,,X7GHM&11-ATU J ,,X7KLM#//-H&&'78

$(!v~>!22<@  55J%//DD7&D++G,>,>w?Q?QRYRdRde|  O  SP  RX  @Y  [^  `a  -b  cK**7+=+=g>P>PQdfy{|>}  @E  ,F  GJ <@8'7$7??F?Q?QRUWx?y<?F?Q?QRVXy?z<+2+=+=dDX+Y("--mW=O=OPb  eM  >N  O#../CEmn	,3,>,>x,S) <@8'7$7??F?Q?QRUWx?y<?F?Q?QRVXy?z<+2+=+=dDX+Y())*<>PQ"--d4\]#..w/A/A'BTBTUXZnBoqu/v  yF  G	,3,>,>x,S)!778H8HP[I\^e8fgN$2Q$6!*-.C*D'e&AABGLM,3,>,>}Ng,h)(/(:(:;XZ]_m(n%(+s2 -1)#001JK''.A'
H
$
 f
 	

 Y/
 ]
 &t'8'89V'W
  !2
 *+F
 *
 
 )).9
 ]
 
 L
  ;!
"  0#
$ $$$/
 	
rx  c                    U R                  US5      nU R                  X2S S5      nU R                  US5      nU R                  US5      nU R                  U R                  S0 5      nU R	                  Xd/ 5      nU R                  USS5      n[        R                  " U5      n	S n
[        S[        U5      5       H,  nX{   n[        R                  " XS   5      (       a    O	US   n
M.     U R                  U	5      n[        R                  " U R                  US	5      5      nU R                  U5      nU R                  US
5      nU R                  U5      nU R                  U R                  US5      5      nU R                  U5      nS nU R                  US5      nUc#  Ub   [        R                  " US5      (       a  SOSnS n[        R                  " US5      (       a  SnO[        R                  " US5      (       a  SnU R                  US5      nU R                  U5      nU R                  US5      nU R!                  U5      nSU;   nUS:X  Ga"  U R                  US0 5      nU R                  US5      nU R                  USS5      nUS L =(       a    US L nU(       Gd  U(       a  S n Un!US:X  a/  [        R"                  " SU
5      n [        R$                  " SU!5      n!O[        R"                  " SU
5      n [        R$                  " UU 5      n"[        R"                  " U"U!5      n#U R'                  U R                  USS5      5      n$U$b-  [        R(                  " [        R$                  " U#U5      SU$5      nGOS n Un!US:X  a  [        R*                  " SU
5      n O.[        R*                  " SU
5      n [        R$                  " SU!5      n![        R$                  " UU5      n#[        R*                  " [        R(                  " SU!5      [        R(                  " U U5      5      n%U R'                  U R                  US5      5      n&U&b-  [        R(                  " [        R$                  " U#U%5      SU&5      nOU R                  US5      nUc  SOUnU R                  U5      n'U R                  U R                  U R                  US5      5      5      n(U R-                  US5      n)U)S:X  a  S n)U R                  U
5      n*[        R$                  " X5      n+U+c  U R                  US5      n+U R                  U+5      n,S n-S n.U R                  US5      n/U/b  [/        U/5      n0U R1                  SU0-  5      n1[        R(                  " SU/S5      n.U1(       d  [        R"                  " U.S 5      n.[        R$                  " U	U.5      n2[        R(                  " U2SS5      n-OAU R                  US!5      n-[        R$                  " U-S5      n2[        R(                  " U2U	S5      n.S n3S n4[        R2                  " US5      (       d  U R                  [        R(                  " [        R"                  " [        R(                  " U+U5      S"5      SS#5      5      n3U R                  [        R$                  " [        R(                  " UU-S#5      S$5      5      n4U R                  US%5      n5U5S&:g  n60 S'U_S(S _SU_S)U_SU_S*U_SU R                  U/5      _SU_S+U'_SU_SU(_SU_S,U)_S!U R                  U-5      _S-U R                  U.5      _S.U,_S/U*_U3U R5                  U)5      UUUU6U4S S S0.	E$ )1Nr  r  r  r  rg  r  r   r   r  unRealizedProfitr  r  r  r  rO  r  r  r  r  r  r  r  r  rJ  rj  r  r  r  r  rR  r  r  r  r  r  r;  r  r  r  rO   r  r  r  r  r  r  r  )	r  r  r>  r  rR  rF  r  rB  rC  )r  r  r  r  r  r  rI   r  r  r  r  rr  r  r  r  r  rl  r  r  r  r  r  r  r  r  r  ro  )7rt  r  r  r  r  isolatedMarginStringr  rx  r  r  r  r  r  rg  contractsAbsr  r  r  liquidationPriceStringr  r  r>  rR  r  r  r  r  r  r  basePrecisionValuequotePrecisionValueprecisionIsUndefinedr  r  innerr   rX  r  basePrecisionr  r  r  r  r  r  r  r  r  r  r  	unroundedr  r  r  rF  s7                                                          rv  parse_position_riskbinance.parse_position_risk%  s   l ##Hh7!!(D*E!!&(3#//:JK>>$,,8JBO..)92F++Hj/R#..~>,0)q#o./A%(G  !2AJ??07
-	 0
 $$%67))$*:*:8]*ST%%l3	"..x9KL))*=>!%0@0@K]0^!_,,-CD%%h=
"6"B$+$5$56JC$P$PV`J^S11D~s33D++HlC&&'78
v~>!22<@( v{B?I!%!1!1)V!D"&"4"4Y"Q$6$$>#aEX\`E` '?C<+;(wCJCUCUVY[|C}@/6/A/A$H\/],CJCUCUVZ\}C~@#../EGopE&11%9MNH%)%?%?@R@RS\^egn@o%pN%1+2+=+=g>P>PQY[g>hjmo}+~( @D<+;(wCJCUCUVY[|C}@CJCUCUVZ\}C~@/6/A/A$H\/],&11,@RSH ' 2 273E3EcK_3`bibtbt  v^  `v  cw  !xI$($>$>t?O?OPY[a?b$cM$0+2+=+=g>P>PQY[d>egjly+z(#//:JK#3#;3BR&&'78
%%dnnT5E5EhP[5\&]^	%%h=	>I&*&7&78Y&Z#")"4"45V"j"*&*&6&6x&O# --.EF"(,%))(J?%>*H++D8O<H,3,>,>sNTU,V)070B0BC`bh0i-**+<>[\I")"4"4YQ"G"&"2"28_"M**+>DI,3,>,>yJ[]^,_)
$$%5s;;++G,>,>w?Q?QRYRdRde|  O  SP  RX  @Y  [^  `a  -b  cK**7+=+=g>P>PQdfy{|>}  @E  ,F  GJ''.A'
H
$
 f
 	

 L
 ]
 )).9
  0
 *
 
 
 *
 
 T../BC
 &t'8'89V'W
   !2!
" *+F#
$ 'Y/$$$!#5
 	
rx  c                   #    U R                  5       I S h  vN   U R                  U R                  S5      nUb  U(       Ga  U R                  U R                  SS5      nU R                  USU5      nU R	                  US5      nS nU R                  SS US5      u  prS nU R                  USSSS	5      u  pS n	U R                  XW5      (       a;  U(       a  U R                  U5      I S h  vN n	OU R                  U5      I S h  vN n	OiU R                  XW5      (       a;  U(       a  U R                  U5      I S h  vN n	O2U R                  U5      I S h  vN n	O[        U R                  S
-   5      eU R                  5       U R                  S'   [!        S[#        U	5      5       H  n
X   nU R                  US5      nU R%                  US S S5      nU R'                  US/ 5      n/ n[!        S[#        U5      5       H@  nUU   nU R)                  USS5      nU R                  US5      nUR+                  UU/5        MB     XR                  S   U'   M     U R                  S   $  GNL GN} GNf GN2 GN7f)Nr  r  r\   ry  loadLeverageBracketsr  r  rm  FzB loadLeverageBrackets() supports linear and inverse contracts onlyr   r  r  bracketsnotionalFloorqtyFloormaintMarginRatio)r  r  r  r  r  r  r  r  papiGetUmLeverageBracketfapiPrivateGetLeverageBracketr~  papiGetCmLeverageBracketdapiPrivateV2GetLeverageBracketr?   rO   create_safe_dictionaryr  r  r  r  r  r  )rt  reloadr  r  r  ry  r  rz  r  r  r  r  r  r  r  r  r  r  
floorValuer  s                       rv  load_leverage_bracketsbinance.load_leverage_brackets&  sY    !!!  >>$,,8JK$&**4<<QK##FFK@DIIff-EG"==>TVZ\bdlmOG $(,(G(GPfhn  qB  DI  )J%H~~d,,$%)%B%B5%IIH%)%G%G%NNH//$%)%B%B5%IIH%)%I%I%%PPH"477-q#qrr/3/J/J/LDLL+,1c(m, ++E8<))(D$
K>>%R@q#h-0A&qkG!%!3!3G_j!YJ262B2B7L^2_/MM:/J"KL	 1
 <B/08 - ||.//M 	"  JN  JPsY   I1I"CI1(I%)I1I(6I19I+:I1I.DI1%I1(I1+I1.I1c                 |  #    U R                  5       I Sh  vN   SnU R                  SSU5      u  p2SnU R                  SSUS5      u  pBSnU R                  USSSS5      u  pRSnU R	                  X45      (       a;  U(       a  U R                  U5      I Sh  vN nOU R                  U5      I Sh  vN nOiU R                  X45      (       a;  U(       a  U R                  U5      I Sh  vN nO2U R                  U5      I Sh  vN nO[        U R                  S-   5      eU R                  XaS5      $  GN N N NP N87f)	a  
retrieve information on the maximum leverage, and maintenance margin for trades of varying trade sizes

https://developers.binance.com/docs/derivatives/usds-margined-futures/account/rest-api/Notional-and-Leverage-Brackets
https://developers.binance.com/docs/derivatives/coin-margined-futures/account/rest-api/Notional-Bracket-for-Pair
https://developers.binance.com/docs/derivatives/portfolio-margin/account/UM-Notional-and-Leverage-Brackets
https://developers.binance.com/docs/derivatives/portfolio-margin/account/CM-Notional-and-Leverage-Brackets

: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  rm  Fz@ fetchLeverageTiers() supports linear and inverse contracts onlyr  )r  r
  r  r  r  r  r  r~  r  r  r?   rO   parse_leverage_tiers)rt  r!  r  ry  rz  r  r  s          rv  fetch_leverage_tiersbinance.fetch_leverage_tiers&  s=     !!!99:NPTV\]99:NPTV\^fg $($C$CFL`bhj{  ~C  %D!>>$(( !%!>!>v!FF!%!C!CF!KK__T++ !%!>!>v!FF!%!E!Ef!MMtww)kkllN ((HEEu 	" GK GMsX   D<D1A?D<D4D<0D616D<'D8(D<D:0D<4D<6D<8D<:D<c                    U R                  US5      nU R                  X2SS5      nU R                  US/ 5      n/ n[        S[	        U5      5       H  nXF   nUR                  U R                  US5      U R                  X25      US   U R                  USS	5      U R                  US
S5      U R                  US5      U R                  US5      US.5        M     U$ )zo
@ignore
       :param dict info: Exchange response for 1 market
       :param dict market: CCXT market
       r  Nr  r  r   r  r  r  r  notionalCapqtyCapr  initialLeverage)tierr  rg  rf  rh  maintenanceMarginRatemaxLeverager  )	r  r  r  r  r  r  r  r  rn  )rt  r  r  r  r  r  r  r  s           rv  parse_market_leverage_tiers#binance.parse_market_leverage_tiers>'  s    , ##D(3!!(D*E>>$
B7q#h-(AkGLL(()<**8<"7O#11'?JW#11'=(S)-)9)9'CU)V#//9JK	 	 ) rx  c                 0  #    U R                  5       I Sh  vN   U R                  U5      nUS   (       d  [        U R                  S-   5      eSUS   0nU R	                  U R                  XB5      5      I Sh  vN nU R                  US   U5      $  N{ N7f)an  
fetch data on an open position

https://developers.binance.com/docs/derivatives/option/trade/Option-Position-Information

: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>`
Nr]   z- fetchPosition() supports option markets onlyr  rO   r   )r  r  r?   rO   eapiPrivateGetPositionr  parse_positionr  s         rv  fetch_positionbinance.fetch_positionf'  s      !!!V$htww)XXYYfTl
 44T[[5QRR0 ""8A;77? 	" Ss"   BBA!B8B9BBc                 .  #    U R                  5       I Sh  vN   U R                  U5      n0 nSnUba  Sn[        U[        5      (       a/  [	        U5      nUS:  a  [        U R                  S-   5      eUS   nOUnU R                  U5      nUS   US'   U R                  U R                  X25      5      I Sh  vN n/ n[        S[	        U5      5       H&  n	UR                  U R                  Xy   U5      5        M(     U R                  USUS5      $  N N[7f)aj  
fetch data on open options positions

https://developers.binance.com/docs/derivatives/option/trade/Option-Position-Information

: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   rO   r  F)r  r  r  r)  r  r5   rO   r  r3  r  r  r  r4  filter_by_array_positions)
rt  r!  r  r  r  r  symbolsLengthr  r  r  s
             rv  fetch_option_positionsbinance.fetch_option_positions'  s     !!!%%g.F'4(( #G 1$$TWW/u%uvv  [[(F &tGH44T[[5QRR0 q#h-(AMM$--hk6BC )--fhOOU 	" Ss#   DDB D7D8ADDr  c           
      r   U R                  US5      nU R                  X2S S5      nUS   nU R                  US5      nU R                  US5      nUS:w  a  [        R                  " SU5      nU R                  US5      nU R                  0 SU_S	S _SU_S
U R                  US
5      _SU R                  US5      _SU R                  US5      _SU R                  US5      _SU R                  US5      _SU_SU R                  U5      _SS _SU_SU R                  U5      _SS _SS _SS _SS _S S S S S S S.E5      $ )Nr  r[   rR  r[  r  rj  rM  r  rO   r  r  rg  	markValuer  positionCostr  unrealizedPNLr  r  r  r  rF  r  r  r  )r  r  r  r  r>  r  )
r  r  ri  rI   r  r  safe_positionr  rr  ro  )rt  r  r  r  r  rR  r[  r  s           rv  r4  binance.parse_position'  s   , ##Hh7!!(D&A!%%h7##Hj96>))$9H%%h7	!! #
H#
$#
 f#
 $**8\B	#

 ))(K@#
 ((;?#
 $**8^D#
 T--hH#
 D#
 **84#
 D#
 #
 Y/#
 d#
  #
  *4!#
" T##
$ (, $/#
  	rx  c                   #    SnU R                  USS5      u  p2Uc?  U R                  U R                  S5      nUc  U R                  U R                  SS5      nOSnUS:X  a  U R	                  X5      I Sh  vN $ US:X  a  U R                  X5      I Sh  vN $ US:X  a  U R                  X5      I Sh  vN $ [        U R                  S-   U-   S-   5      e N` NC N&7f)	aR  
fetch all open positions

https://developers.binance.com/docs/derivatives/usds-margined-futures/account/rest-api/Account-Information-V2
https://developers.binance.com/docs/derivatives/coin-margined-futures/account/rest-api/Account-Information
https://developers.binance.com/docs/derivatives/usds-margined-futures/trade/rest-api/Position-Information-V2
https://developers.binance.com/docs/derivatives/coin-margined-futures/trade/rest-api/Position-Information
https://developers.binance.com/docs/derivatives/option/trade/Option-Position-Information

:param str[] [symbols]: list of unified market symbols
:param dict [params]: extra parameters specific to the exchange API endpoint
:param dict [params.params]: extra parameters specific to the exchange API endpoint
:param str [params.method]: method name to call, "positionRisk", "account" or "option", default is "positionRisk"
:param bool [params.useV2]: set to True if you want to use the obsolete endpoint, where some more additional fields were provided
:returns dict[]: a list of `position structure <https://docs.ccxt.com/#/?id=position-structure>`
Nr   r}  ru  rt  r]   z<.options["fetchPositions"]["method"] or params["method"] = "zJ" is invalid, please choose between "account", "positionRisk" and "option")	r  r  r  r  fetch_positions_riskfetch_account_positionsr:  r?   rO   )rt  r!  r  defaultMethodr  s        rv  fetch_positionsbinance.fetch_positions'  s     "  $ = =fFVX` a nnT\\3CDG $ 0 0?OQ_ ` .N*227CCCi'55gFFFh&44WEEEtww)ggjww  {G   G  H  H DFEs6   A4C6C7CCC4C5#CCCc                 \  #    Ub-  [        U[        5      (       d  [        U R                  S-   5      eU R	                  5       I Sh  vN   U R                  SU5      I Sh  vN   U R                  U R                  SS5      nU R                  USU5      nU R                  US5      nSnU R                  SSUS5      u  pRSnU R                  USS	S
S5      u  pbSnU R                  XE5      (       at  U(       a  U R                  U5      I Sh  vN nOSnU R                  USSS5      u  pU(       d  U R                  U5      I Sh  vN nOU R                  U5      I Sh  vN nOiU R!                  XE5      (       a;  U(       a  U R#                  U5      I Sh  vN nO2U R%                  U5      I Sh  vN nO['        U R                  S-   5      eSn	U R                  USSS5      u  pU R)                  Xy5      n
U R+                  U5      nU R-                  U
SUS5      $  GN GN GN N N N Nz7f)a  
@ignore
       fetch account positions

       https://developers.binance.com/docs/derivatives/usds-margined-futures/account/rest-api/Account-Information-V2
       https://developers.binance.com/docs/derivatives/coin-margined-futures/account/rest-api/Account-Information
       https://developers.binance.com/docs/derivatives/usds-margined-futures/trade/rest-api/Position-Information-V2
       https://developers.binance.com/docs/derivatives/coin-margined-futures/trade/rest-api/Position-Information
       https://developers.binance.com/docs/derivatives/usds-margined-futures/account/rest-api/Account-Information-V3

       :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
       :param boolean [params.useV2]: set to True if you want to use obsolete endpoint, where some more additional fields were provided
       :returns dict: data on account positions
       Nz8 fetchPositions() requires an array argument for symbolsFr  r\   ry  fetchAccountPositionsr  r  rm  r  z< fetchPositions() supports linear and inverse contracts onlyr  r  )r  r)  r4   rO   r  r#  r  r  r  r  r  r  papiV2GetUmAccountr  r  r  r~  papiGetCmAccountr  r?   r  r  r8  )rt  r!  r  r  ry  rz  r  r  r  r  r  s              rv  rD  binance.fetch_account_positions!(  s    & gt,,'2l(lmm!!!))%888&&t||]HM<66*99:QSWY_aij $($C$CFLcekm~  AF  %G!>>$(( !%!8!8!@@ $ = =fF]_fhm n%)%A%A&%IIH%)%A%A&%IIHF __T++ !%!6!6v!>>!%!;!;F!CCtww)gghh#<<VE\^lnst--hE%%g.--fhOOC 	"8 A
  JIJ ?Cs   AH,HH, H!B*H,H!8H,H$H,H&6H,H(H,/H*0A,H,H,!H,$H,&H,(H,*H,c                 z  #    Ub-  [        U[        5      (       d  [        U R                  S-   5      eU R	                  5       I Sh  vN   U R                  SU5      I Sh  vN   0 nSnU R                  U R                  SU5      nU R                  USU5      nSnU R                  SSUS5      u  pbSnU R                  USS	S
S5      u  prU R                  US5      nSnU R                  XV5      (       a  U(       a)  U R                  U R                  X25      5      I Sh  vN nOSn	U R                  USSS5      u  pU R                  X25      nU	(       d  U R                  U5      I Sh  vN nOU R!                  U5      I Sh  vN nOU R#                  XV5      (       aY  U(       a)  U R%                  U R                  X25      5      I Sh  vN nOAU R'                  U R                  X25      5      I Sh  vN nO[)        U R                  S-   5      e/ n
[+        S[-        U5      5       HY  nX   nU R                  US5      n[.        R0                  " US5      (       d  M7  U
R3                  U R5                  X   5      5        M[     U R7                  U5      nU R9                  U
SUS5      $  GNb GNK GN GNI GN2 N N7f)al  
@ignore
       fetch positions risk

       https://developers.binance.com/docs/derivatives/usds-margined-futures/trade/rest-api/Position-Information-V2
       https://developers.binance.com/docs/derivatives/coin-margined-futures/trade/rest-api/Position-Information
       https://developers.binance.com/docs/derivatives/portfolio-margin/account/Query-UM-Position-Information
       https://developers.binance.com/docs/derivatives/portfolio-margin/account/Query-CM-Position-Information
       https://developers.binance.com/docs/derivatives/usds-margined-futures/trade/rest-api/Position-Information-V3

       :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"
       :param bool [params.useV2]: set to True if you want to use the obsolete endpoint, where some more additional fields were provided
       :returns dict: data on the positions risk
       Nz< fetchPositionsRisk() requires an array argument for symbolsFr\   r  ry  r   r  r  rm  r  z@ fetchPositionsRisk() supports linear and inverse contracts onlyr   r  r  r  )r  r)  r4   rO   r  r#  r  r  r  r  r  r  papiGetUmPositionRiskr  r  fapiPrivateV3GetPositionRiskfapiPrivateV2GetPositionRiskr~  papiGetCmPositionRiskdapiPrivateGetPositionRiskr?   r  r  rI   r  r  r  r  r8  )rt  r!  r  r  r  ry  rz  r  r  r  r  r  rawPositionr  s                 rv  rC  binance.fetch_positions_risk(  s    $ gt,,'2p(pqq!!!))%888&&t||]KP<99:NPTV\^fg $($C$CFL`bhj{  ~C  %D!66*>>$(( !%!;!;DKK<X!YY $ = =fFZ\cej kW5%)%F%Fv%NNH%)%F%Fv%NNH6 __T++ !%!;!;DKK<X!YY!%!@!@WA]!^^tww)kklld q#h-(A"+K#//\J  !1377d66x{CD	 )
 %%g.--fhOOa 	"8 Z  ON: Z^s   AJ;J(J; J+!B=J;J.A	J;(J1)J;J4AJ;J7	(J;1J92A'J;AJ;+J;.J;1J;4J;7J;9J;c                   #    U R                  5       I Sh  vN   SnSS0nUb;  U R                  U5      nUS   US'   US   (       d  [        U R                  S-   5      eSnU R	                  SXTS	5      u  ptSnU R                  USS
SS5      u  pU R                  SXd5      u  pdUb  X&S'   Ub  X6S'   U R                  U R                  SSS5      n	U R                  USU	5      n
U R                  US5      nSnU R                  X5      (       aY  U(       a)  U R                  U R                  Xd5      5      I Sh  vN nOU R                  U R                  Xd5      5      I Sh  vN nOU R                  X5      (       aY  U(       a)  U R!                  U R                  Xd5      5      I Sh  vN nOAU R#                  U R                  Xd5      5      I Sh  vN nO[        U R                  S-   5      eU R%                  XX#5      $  GN N N N_ N87f)aW  
fetch the history of funding payments paid and received on self account

https://developers.binance.com/docs/derivatives/usds-margined-futures/account/rest-api/Get-Income-History
https://developers.binance.com/docs/derivatives/coin-margined-futures/account/rest-api/Get-Income-History
https://developers.binance.com/docs/derivatives/portfolio-margin/account/Get-UM-Income-History
https://developers.binance.com/docs/derivatives/portfolio-margin/account/Get-CM-Income-History

: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_FEErO   r  r[   z3 fetchFundingHistory() supports swap contracts onlyr   r  r  rm  Fr?  r>  r  r  r\   ry  zA fetchFundingHistory() supports linear and inverse contracts only)r  r  r?   rO   r  r  ro  r  r  r  r  r  papiGetUmIncomer  fapiPrivateGetIncomer~  papiGetCmIncomedapiPrivateGetIncomeparse_incomes)rt  r  r7  r  r  r  r  rz  r  r  ry  r  s               rv  fetch_funding_historybinance.fetch_funding_historyA)  s    $ !!!-
 [[(F &tGH&>"477-b#bcc99:OQWaij $($C$CFLacik|  D  %E!229gN#(K $G((7Lm]ef<66*>>$(( !%!5!5dkk'6R!SS!%!:!:4;;w;W!XX__T++ !%!5!5dkk'6R!SS!%!:!:4;;w;W!XXtww)llmm!!(EAAG 	"2 TX TXsY   H	G>DH	6H7(H	H AH	%H&(H	H0H	H	H	H	H	r  c                   #    Uc  [        U R                  S-   5      eUS:  d  US:  a  [        U R                  S-   5      eU R                  5       I Sh  vN   U R	                  U5      nUS   US.nSnU R                  USS	S
S5      u  pcSnUS   (       a\  U(       a*  U R                  U R                  XS5      5      I Sh  vN nU$ U R                  U R                  XS5      5      I Sh  vN n U$ US   (       a\  U(       a*  U R                  U R                  XS5      5      I Sh  vN nU$ U R                  U R                  XS5      5      I Sh  vN n U$ [        U R                  S-   5      e GN N N NP N(7f)a$  
set the level of leverage for a market

https://developers.binance.com/docs/derivatives/usds-margined-futures/trade/rest-api/Change-Initial-Leverage
https://developers.binance.com/docs/derivatives/coin-margined-futures/trade/rest-api/Change-Initial-Leverage
https://developers.binance.com/docs/derivatives/portfolio-margin/account/Change-UM-Initial-Leverage
https://developers.binance.com/docs/derivatives/portfolio-margin/account/Change-CM-Initial-Leverage

: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 125rO   )r  r  r   r  rm  Fr  r  z9 setLeverage() supports linear and inverse contracts only)r4   rO   r5   r  r  r  papiPostUmLeverager  fapiPrivatePostLeveragepapiPostCmLeveragedapiPrivatePostLeverager?   )rt  r  r  r  r  r  r  r  s           rv  set_leveragebinance.set_leveragex)  sx     >#DGG.Y$YZZ qLhnTWW'NNOO!!!V$Tl 
 !$($C$CFM[actv{$|!( !%!8!8W9U!VV  "&!=!=dkk'>Z![[  I !%!8!8W9U!VV
  "&!=!=dkk'>Z![[  tww)ddee) 	" W[ W[s[   AE=E2A,E=E5)E=,E7-;E=(E9))E=E; E=5E=7E=9E=;E=r>  c                   #    Uc  [        U R                  S-   5      eUR                  5       nUS:X  a  SnUS:w  a  US:w  a  [        U R                  S-   5      eU R	                  5       I Sh  vN   U R                  U5      nUS   US.nSn US	   (       a*  U R                  U R                  XS5      5      I Sh  vN nU$ US
   (       a*  U R                  U R                  XS5      5      I Sh  vN nU$ [        U R                  S-   5      e N NT N"! [         aM  n[        U[        5      (       a1  U R                  U R                  SS5      nU(       a  UeSSS.n SnAU$ UeSnAff = f7f)a  
set margin mode to 'cross' or 'isolated'

https://developers.binance.com/docs/derivatives/usds-margined-futures/trade/rest-api/Change-Margin-Type
https://developers.binance.com/docs/derivatives/coin-margined-futures/trade/rest-api/Change-Margin-Type

: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CROSSEDrG  z, marginMode must be either isolated or crossrO   )r  r  r  r  z; setMarginMode() supports linear and inverse contracts onlyr  Fi2No need to change margin type.)r  msg)r4   rO   r  r5   r  r  fapiPrivatePostMarginTyper  dapiPrivatePostMarginTyper?   	Exceptionr  r8   r  r  )	rt  r>  r  r  r  r  r  er  s	            rv  set_margin_modebinance.set_margin_mode)  sw     >#DGG.[$[\\  %%'
 "J*$:+BTWW'UUVV!!!V$Tl$
 	h!%!?!?G@\!]]& % 	"!%!?!?G@\!]]"  #477-j#jkk 	" ^]  	 !122,0NN4<<Idfk,l),G(-6VWH  	s   A+E.-D.E.-D ;D<D  E.-D /D0D 4E.6D E.D D 
E+A E&E.$E&&E++E.rF  c                   #    SnUb  U R                  U5      nSnU R                  SXC5      u  pSSnU R                  SXC5      u  pcSnU R                  USSSS5      u  psSnU(       a  SnOSnSU0n	Sn
U R	                  XV5      (       a\  U(       a*  U R                  U R                  X5      5      I Sh  vN n
U
$ U R                  U R                  X5      5      I Sh  vN n
 U
$ U R                  XV5      (       a\  U(       a*  U R                  U R                  X5      5      I Sh  vN n
U
$ U R                  U R                  X5      5      I Sh  vN n
 U
$ [        U R                  S	-   5      e N N NM N%7f)
af  
set hedged to True or False for a market

https://developers.binance.com/docs/derivatives/usds-margined-futures/trade/rest-api/Change-Position-Mode
https://developers.binance.com/docs/derivatives/coin-margined-futures/trade/rest-api/Change-Position-Mode
https://developers.binance.com/docs/derivatives/portfolio-margin/account/Get-UM-Current-Position-Mode
https://developers.binance.com/docs/derivatives/portfolio-margin/account/Get-CM-Current-Position-Mode

: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
Nr   r  rm  FtruefalsedualSidePositionz= setPositionMode() supports linear and inverse contracts only)r  r
  r  r  r~  papiPostCmPositionSideDualr  dapiPrivatePostPositionSideDualr  papiPostUmPositionSideDualfapiPrivatePostPositionSideDualr5   rO   )rt  rF  r  r  r  ry  rz  r  ru  r  r  s              rv  set_position_modebinance.set_position_mode)  s      [[(F99:KV\99:KV\ $($C$CFL]_egxz  %A!%& 0
 ??4)) !%!@!@WA]!^^   "&!E!EdkkRYFb!cc  ^^D** !%!@!@WA]!^^  "&!E!EdkkRYFb!cc  TWW'ffgg _c _csI   B0E62E.3)E6E0AE6$E2%)E6E4 E60E62E64E6c                 
  #    U R                  5       I Sh  vN   U R                  SU5      I Sh  vN   SnU R                  SSU5      u  p2SnU R                  SSUS5      u  pBSnU R	                  USSSS5      u  pRSnU R                  X45      (       a;  U(       a  U R                  U5      I Sh  vN nOU R                  U5      I Sh  vN nOiU R                  X45      (       a;  U(       a  U R                  U5      I Sh  vN nO2U R                  U5      I Sh  vN nO[        U R                  S-   5      eU R                  US/ 5      n[        U[        5      (       a  UnU R!                  XqS	5      $  GN_ GNH N N N} Ne7f)
a?  
fetch the set leverage for all markets

https://developers.binance.com/docs/derivatives/usds-margined-futures/account/rest-api/Account-Information-V2
https://developers.binance.com/docs/derivatives/coin-margined-futures/account/rest-api/Account-Information
https://developers.binance.com/docs/derivatives/portfolio-margin/account/Get-UM-Account-Detail
https://developers.binance.com/docs/derivatives/portfolio-margin/account/Get-CM-Account-Detail
https://developers.binance.com/docs/derivatives/usds-margined-futures/account/rest-api/Symbol-Config

: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  rm  z< fetchLeverages() supports linear and inverse contracts onlyr  r  )r  r#  r
  r  r  r  papiGetUmAccountfapiPrivateGetSymbolConfigr~  rK  r  r?   rO   r  r  r)  parse_leverages)rt  r!  r  ry  rz  r  r  	leveragess           rv  fetch_leveragesbinance.fetch_leverages*  sk     !!!))%88899:JDRXY99:JDRXZbc $($C$CFL\^dfwy~$!>>$(( !%!6!6v!>>!%!@!@!HH__T++ !%!6!6v!>>!%!;!;F!CCtww)gghhNN8["=	h%% I##IAA1 	"8 ?H ?Csi   FE5FE8A?F0E;1F
E=6FE?FFAF8F;F=F?FFc                 d   U R                  US5      nU R                  US5      nS nUb  U(       a  SOSnU R                  US5      nUb
  US:X  a  SOSnU R                  US5      nS nS n	U R                  US5      n
Ub  US:X  a  U
nU
n	OUS	:X  a  U
nOUS
:X  a  U
n	UU R	                  X25      UUU	S.$ )Nr  rO  r  r  crossedr  r  bothr  r  )r  r  r>  longLeverageshortLeverage)r  r  ri  r  r  )rt  r  r  r  marginModeRawr>  marginTypeRawrR  r  r  leverageValues              rv  parse_leveragebinance.parse_leverage;*  s    ##Hh7x<
$'4'J..xF$%2i%?jJ%%h?))(J?Ldfn(L)MV^(LW_)M&&x8$(*
 	
rx  c                   #    U R                  5       I Sh  vN   Uc  SOU R                  U5      nSnU R                  SXT5      u  pdUS:w  a  [        U R                  S-   5      e0 nUb  US   nUS   US   -   US'   Ub  X'S	'   Ub  X7S
'   U R                  U R                  Xt5      5      I Sh  vN nU R                  X5      n	U R                  U	S5      n
U R                  XX#5      $  N N;7f)a  
fetches historical settlement records

https://developers.binance.com/docs/derivatives/option/market-data/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   r]   z6 fetchSettlementHistory() supports option markets onlyr  r  r  r<  r>  r  r  )
r  r  r
  r?   rO   eapiPublicGetExerciseHistoryr  parse_settlementsr  filter_by_symbol_since_limitrt  r  r7  r  r  r  ry  r  r  settlementssorteds              rv  fetch_settlement_history binance.fetch_settlement_historyW*  s     !!! .t{{6/B99:RTZc8tww)aabbH%F$*8$4vi7H$HGL!#(K $G::4;;w;WXX ,,X>k;700NN9 	" Ys"   C,C(BC,.C*/:C,*C,c                   #    U R                  5       I Sh  vN   Uc  SOU R                  U5      nSnU R                  SXT5      u  pdUS:w  a  [        U R                  S-   5      e0 nUb  US   US'   US   nUb  X'S'   Ub  X7S'   U R                  U R                  Xt5      5      I Sh  vN nU R                  X5      n	U R                  U	S	5      n
U R                  XX#5      $  N N;7f)
a{  
fetches historical settlement records of the user

https://developers.binance.com/docs/derivatives/option/trade/User-Exercise-Record

: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   r]   z8 fetchMySettlementHistory() supports option markets onlyrO   r  r>  r  r  )
r  r  r
  r?   rO   eapiPrivateGetExerciseRecordr  r  r  r  r  s              rv  fetch_my_settlement_history#binance.fetch_my_settlement_history*  s     !!! .t{{6/B99:TV\e8tww)ccdd &tGHH%F#(K $G::4;;w;WXX* ,,X>k;700NNK 	" Ys"   C&C"BC&(C$):C&$C&c                     U R                  USS5      nU R                  US5      nUU R                  XB5      U R                  USS5      UU R	                  U5      S.$ )NrA  
createDater  realStrikePriceexercisePrice)r  r  r  r  r  )rj  r  r  rn  ro  )rt  
settlementr  r  r  s        rv  parse_settlementbinance.parse_settlement*  sg    > ''
L,O	##J9&&x8''
4EW"Y/
 	
rx  c                     / n[        S[        U5      5       H&  nUR                  U R                  X   U5      5        M(     U$ )Nr   )r  r  r  r  )rt  r  r  r  r  s        rv  r  binance.parse_settlements*  s@    F q#k*+AMM$//GH ,rx  c                   #    U R                  5       I Sh  vN   SnU R                  SSU5      u  pCUS:w  a  [        U R                  S-   5      eU R	                  SUS5        U R                  U5      nUUS   S.nU R                  U R                  Xc5      5      I Sh  vN nU R                  USU5      nU R                  X5      $  N N*7f)	a  
fetch the history of changes, actions done by the user or operations that altered the balance of the user

https://developers.binance.com/docs/derivatives/option/account/Account-Funding-Flow

:param str id: the identification number of the ledger entry
:param str code: unified currency code
:param dict [params]: extra parameters specific to the exchange API endpoint
:returns dict: a `ledger structure <https://docs.ccxt.com/#/?id=ledger>`
Nr   r]   z4 fetchLedgerEntry() can only be used for type optionr  rO   )recordIdrg  r   )
r  r
  r5   rO   check_required_argumentrg  eapiPrivateGetBillr  r  parse_ledger_entry)	rt  rO   r  r  ry  rg  r  r  firsts	            rv  fetch_ledger_entrybinance.fetch_ledger_entry+  s      !!!99:LdTZ[8TWW']]^^$$%7vF==& 
 00W1MNN xH5&&u771 	" Os"   CCBCC
 )C
Cc           	        #    U R                  5       I Sh  vN   SnU R                  USS5      u  pTU(       a  U R                  SXX4SS5      I Sh  vN $ SnSnSnUb  U R                  U5      n0 n	U R	                  SSU5      u  pdU R                  SSU5      u  ptUb  X)S'   Ub  X9S'   U R                  US5      n
U
b  U R                  US5      nXS'   SnU R                  USS	S
S5      u  pSnUS:X  aD  U R                  SUS5        US   U	S'   U R                  U R                  X5      5      I Sh  vN nOU R                  Xg5      (       aY  U(       a)  U R                  U R                  X5      5      I Sh  vN nOU R                  U R                  X5      5      I Sh  vN nOU R                  Xg5      (       aY  U(       a)  U R!                  U R                  X5      5      I Sh  vN nOAU R#                  U R                  X5      5      I Sh  vN nO[%        U R&                  S-   5      eU R)                  XX#5      $  GN, GN GN N N Ne N>7f)al  
fetch the history of changes, actions done by the user or operations that altered the balance of the user

https://developers.binance.com/docs/derivatives/option/account/Account-Funding-Flow
https://developers.binance.com/docs/derivatives/usds-margined-futures/account/rest-api/Get-Income-History
https://developers.binance.com/docs/derivatives/coin-margined-futures/account/rest-api/Get-Income-History
https://developers.binance.com/docs/derivatives/portfolio-margin/account/Get-UM-Income-History
https://developers.binance.com/docs/derivatives/portfolio-margin/account/Get-CM-Income-History

:param str [code]: unified currency code
:param int [since]: timestamp in ms of the earliest ledger entry
:param int [limit]: max number of ledger entries 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>`
NFr   r9  r>  r  r:  r?  r  rm  r]   r  rO   rg  z- fetchLedger() supports contract wallets only)r  r  r  rg  r
  r  r  r  r  r  r  r  r  rX  rY  r~  rZ  r[  r?   rO   parse_ledger)rt  r  r7  r  r  r9  ry  rz  rg  r  r:  r  r  s                rv  fetch_ledgerbinance.fetch_ledger*+  sH    ( !!!88PZ[::=$W\fjlqrrr}}T*H99-vV99-vV#(K $G!!&'2YYvw/F!&I $($C$CFM[actv{$|!8((fE"*4.GJ!44T[[5QRRH^^D** !%!5!5dkk'6R!SS!%!:!:4;;w;W!XX__T++ !%!5!5dkk'6R!SS!%!:!:4;;w;W!XXtww)XXYY:   UBBI 	" s. S TX TXs~   II:IIC"I4I5AI:I;(I#I$AI)I*(II0IIIIIIIitemc                 0   U R                  USS5      nS n[        R                  " US5      (       a  Sn[        R                  " SU5      nOSnU R	                  US5      nU R                  XR5      nU R                  XR5      nU R                  USS	5      nU R                  US
S5      nU R                  UU R                  USS5      US S U R	                  US5      U R                  U5      UU R                  U5      UU R                  U5      S S S S S.U5      $ )Nr  rw  r  outrj  inr  r  rM  ry  rV  rO   r5  rm  )r  rO   	directionrt  referenceAccountreferenceIdry  rg  r  r  r  beforeafterrF  r  )r  rI   	string_ler  r  r  safe_currencyrj  safe_ledger_entryparse_ledger_entry_typerr  ro  )	rt  r  rg  r  r  r  r  r  ry  s	            rv  r  binance.parse_ledger_entry+  s+   2 ##D(H=	VS))I''f5FI%%dG4
&&z<%%j;''lFC	!!$=%%$$T4:" $++D)<006''/"Y/'
  ! 	rx  c                     0 SS_SS_SS_SS_SS_SS_S	S
_SS
_SS
_SS_SS_SS_SS_SS_SS_SS_SS_SSS.EnU R                  X!U5      $ )NFEEr  rW  OPTIONS_PREMIUM_FEEPOSITION_LIMIT_INCREASE_FEECONTRACTrV  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  re  )REFERRAL_KICKBACK
COMMISSIONr  )rt  ry  
ledgerTypes      rv  r  binance.parse_ledger_entry_type+  s    
5
5
 "5
 *5	

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

* 
$77rx  currencyCode
depositUrlc                 v   Uc  g S nU R                  U5      nU R                  US0 5      n[        UR                  5       5      n[	        S[        U5      5       H\  nXg   nU R                  XX   S0 5      n	U R                  U	S5      n
U
c  M3  UR                  U R                  U
5      5      (       d  MZ  UnM^     U$ )Nr/  r   r  contractAddressUrl)	rg  r  r)  r*  r  r  r  
startswithget_base_domain_from_url)rt  r  r  r  rg  r/  networkCodesr  currentNetworkCoder  siteUrls              rv  rj  'binance.get_network_code_by_network_url+  s    ==.>>(J;HMMO,q#l+,A!->>(">KD&&t-ABG"z'<'<T=Z=Z[b=c'd'd0 - rx  r  c                     Uc  g UR                  S5      nU R                  US5      nUc  g U R                  US5      nUc  g US-   U-   S-   $ )Nr  r   r  z//)r  r  )rt  r  urlPartsschemedomains        rv  r   binance.get_base_domain_from_url+  s_    ;99S>!!(A.>!!(A.>}v%++rx  r  GETc                    U R                   nX'S   ;  a  [        U R                  S-   U-   S-   5      eU R                   S   U   nUSU-   -  nUS:X  a8  U R                  (       a  SU R                  0nO[	        U R                  S-   5      eUS:H  =(       d    US	:H  n	U	(       aQ  U R                  (       a(  U R                  S
S.nUS:w  a  U R                  U5      nGO[	        U R                  S-   5      eUS:X  dV  US:X  dP  US:X  a  US:w  dD  US:X  d>  US:X  d8  US:X  d2  US:X  d,  US:X  d&  US:X  d   US:X  d  US:X  d  US:X  d  US:X  Ga  US:w  Ga  U R                  5         UR                  S5      S:  aJ  U R                  (       a9  U R                  U R                  S5      (       d  [        U R                  S -   5      eUS!:X  a  US":X  d  US#:X  a  U R                  US$5      n
U
cz  UR                  S5      S:  =(       d    US:H  nU(       a  S%OS&nU(       d  S'OS(nU R                  U R                  S)0 5      nU R                  XU5      nXR                  5       -   US$'   S nUS*:X  a  US!:X  d  US+:X  a  U R                  US*5      nUnUS!:X  a  US:X  a  / n[        S,[!        U5      5       Hw  nUU   nU R                  US$5      n
U
cI  S'nU R                  U R                  S)0 5      nU R                  US&U5      nXR                  5       -   n
U
US$'   UR#                  U5        My     U R%                  U5      nUUS*'   U R'                  U R                  S-5      nU R)                  S.U R+                  5       0U5      nUb  UUS-'   U R'                  US-5      nUb  UUS-'   US:X  a  US/:X  a  U R-                  U5      nGOpUS*:X  dF  UR                  S05      S,:  d1  US1:X  d+  UR                  S25      S,:  d  UR                  S35      S,:  Ga  US4:X  a  US*:X  a  U R                  US5/ 5      nU R/                  US6S7/ 5      nU R1                  U/ S8Q5      nS9U;   a  U R3                  US9   5      US9'   U R5                  U5      n[!        U5      n[!        U5      nUS,:  a  US:-   S;-   S<R7                  U5      -   S=-   nUS,:  aL  / n[        S,U5       H  nUR#                  S>UU   -   S>-   5        M     US:-   S?-   S<R7                  U5      -   S=-   nO#U R5                  U5      nOU R                  U5      nS nU R8                  R                  S@5      S:  a  [!        U R8                  5      SA:  a-  U R3                  U R;                  UU R8                  SB5      5      nOU R3                  U R=                  U R?                  U5      U R8                  SC5      5      nOIU RA                  U R?                  U5      U R?                  U R8                  5      [B        RD                  5      nUSDU-   -  nSU R                  0nUS:X  d  US4:X  a	  USEU-   -  nO&UnS
USF'   OU(       a  USEU R                  U5      -   -  nXXeSG.$ )HNr  z) does not have a testnet/sandbox URL for z
 endpointsr  rU  X-MBX-APIKEYz7 historicalTrades endpoint requires `apiKey` credentialrA  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  r  rL  ztestnet.binancefuture.comr  disableFuturesSandboxWarningz testnet/sandbox mode is not supported for futures anymore, please check the deprecation announcement https://t.me/ccxt_announcements/92 and consider using the demo trading instead.POSTro  r  r  rY   r\   r  r  r,  r  PUTr   r  r  r?  zsub-accountr@  stakingzsimple-earnDELETEr  origclientorderidlistr  )r  r  r  r  &zorderidlist=%5Bz%2Cz%5Dz%22zorigclientorderidlist=%5BzPRIVATE KEYx   sha256ed25519z&signature=?r  )r  r}  bodyheaders)#r   r?   rO   apiKeyr1   	urlencoder  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  urlencode_with_array_repeatr+  r  encode_uri_component	rawencoder\  secretrsaeddsaencodehmachashlibr  )rt  pathr  r}  r  r  r  r   r  rA  r  r  r  rL  r,  r  r  r  checkedBatchOrdersr  
batchOrder
queryBatchdefaultRecvWindowextendedParamsr  r  r  orderidlistLengthorigclientorderidlistLengthnewClientOrderIds	signatures                                  rv  signbinance.sign+  sO   yyE{"tww)TTWZZ]iijjiis#sTz%%{{"DKK *$''4m*mnn"22L8K{{ %)KK$G U?>>&1D)$''4k*kllYC=$8cVmPTXgPgmpt|m|  CF  JR  CR  X[  _g  Xg  mp  tA  mA  GJ  N]  G]  cf  jw  cw  }@  DS  }S  Y\  `o  Yo  ux  |D  uD  HK  OU  HU  Z^  bh  Zh++-45:@Y@Ycgcqcqrvr~r~  A_  d`  d`"477  .e  $e  f  fdgo4;;N#'#3#3F<N#O #+&)hhv&6&;&Osi?ON+9xJ5C,I!^^DLL(BGF#//INH19KKM1IF-.E%Vv-=6U?"nnV]C%0"V#}(<)+&"1c+&67%0^
+/+;+;JHZ+[(+3(4I%)^^DLL(B%OF'+'7'7)'TH/7++-/G,=MJ'9:*11*= 8 #ii(:;
(2}% $ 1 1$,, M![[TZZ\*N !,/@|,**6<@J%/9|,vDL$888H-'TYY}-E-JPTXpPpvzvv  AJ  wK  OP  wP  VZ  V_  V_  `m  Vn  rs  Vsh&T]-B"&..PR"SK,0,<,<^Mdf}  @B  -C)%)YY~  @A  &BN>1373L3L^\dMe3fx0 NN>:E(+K(8%256K2L/(1, %.? ?%**[BY Y\a a2Q6,.)!&q*E!FA-44U=RST=U5UX]5]^ "G %.I IEJJWhLi ilq q NN>:E~6I{{.3t{{#c) $ 9 9$((5$++W_:` aI $ 9 9$**T[[QVEWY]YdYdfo:p qI IIdkk%&8$++dkk:RT[TbTbc	')33EG %Vx%7sU{"*M'sT^^F333dOOrx  exactOrBroadc                 \   S nU R                   b  U R                   OSnUR                  SU-   S-   5      (       d  UR                  S5      (       a  SnOUR                  SU-   S-   5      (       d  UR                  S5      (       a  SnOrUR                  S	U-   S-   5      (       d  UR                  S
5      (       a  SnO=UR                  SU-   S-   5      (       a  SnOUR                  SU-   S-   5      (       a  SnUb/  U R                  U R                  U0 5      nU R                  XR0 5      $ 0 $ )Nzbinance.comzhttps://api.r  zhttps://testnet.binance.visionrY   zhttps://dapi.z&https://testnet.binancefuture.com/dapir  zhttps://fapi.z&https://testnet.binancefuture.com/fapir  zhttps://eapi.r]   zhttps://papi.rm  )hostnamer  r  rY  )rt  r  r  r  r  exceptionsForMarketTypes         rv  get_exceptions_by_urlbinance.get_exceptions_by_urlb,  s   
%)]]%>4==]>>.83c9::cnnMm>n>nJ^^Oh6<==PxAyAy"J^^Oh6<==PxAyAy!J^^Oh6<==!J^^Oh6<==*J!&*nnT__jRT&U#>>"9LL	rx  reasonr}  r  r  c
                 r   US:X  d  US:X  a0  [        U R                  S-   [        U5      -   S-   U-   S-   U-   5      eUS:  a  UR                  S5      S:  a  [	        U R                  S-   U-   5      eUR                  S5      S:  a  [	        U R                  S	-   U-   5      eUR                  S
5      S:  a  [	        U R                  S-   U-   5      eUc  g U R                  USS5      n
U
(       d3  U R                  US5      nS nUb   [        R                  " U5      nUb  UnU R                  US5      nUb  U R                  U R                  US5      XR                  S-   U-   5        U R                  U R                  S   XR                  S-   U-   5        U R                  U R                  US5      XR                  S-   U-   5        U R                  U R                  S   XR                  S-   U-   5        U R                  US5      nUb  US:X  d  [        R                  " US5      (       a  g US:X  a/  U R                   S   (       a  [        U R                  S-   U-   5      eU R                  S-   U-   nUS:X  a  [#        U5      eU R                  U R                  US5      UU5        U R                  U R                  S   UU5        [%        U5      eU
(       d  [%        U R                  S-   U-   5      e['        U[(        5      (       a  [+        U5      nUS:X  a}  US   nU R                  US5      nUbc  U R                  U R                  US5      UU R                  S-   U-   5        U R                  U R                  S   UU R                  S-   U-   5        g ! [         a  nS n S nAGNS nAff = f)Ni  i  r  i  zPrice * QTY is zero or lessr   z- order cost = amount * price is zero or less ra  z5 order amount should be evenly divisible by lot size r]  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) successTrk  rZ  rn  r  200r  rk  r  rj  r   )rA   rO   r  r  r;   r  r  r  loadsrn  throw_exactly_matched_exceptionr  rY  throw_broadly_matched_exceptionrI   r  r  r8   r0   r  r)  r  )rt  r  r  r  r}  r  r  r  requestHeadersrequestBodyr  
messageNewparsedMessagero  messageerrorfeedbackarrayLengthelement	errorCodes                       rv  handle_errorsbinance.handle_errorst,  s   CKTS[ 3T!:S!@6!IC!ORV!VWW 3;yy671<"477-\#\_c#cddyy$)"477-d#dgk#kllyy(A-"477  .a  $a  dh  $h  i  i..9d;))(E:J M%)$(JJz$:M !,,H""8U3001K1KCQX1Y[bdkdknqdqt{d{|001I7T[T[^aTadkTkl001K1KCQX1Y[bdkdknqdqt{d{|001I7T[T[^aTadkTkl  62 7#8#8#D#D  dll3X&Y$TWWs]T%9::ww}t+H:: +844001K1KCQX1Y[`bjk001I5RZ[))# 455h%%h-Ka"1+ ,,Wf=	(889S9STWY`9aclnrnunux{n{  C  oC  D889QS\^b^e^ehk^knr^rs[ ! )$(M)s   	N 
N6)N11N6c                    SU;   a  SU;  a  US   $ SU;   a  SU;  a  US   $ SU;   a  SU;  a  US   $ SU;   a?  SU;   a9  US   nUS   n[        S	[        U5      5       H  nXx   n	XiS	   ::  d  M  U	S
   s  $    U R                  USS
5      $ )Nr*  r  r`  r  r:  poolIdrS  r  r   r   r)  )r  r  r  )
rt  r  r}  r  r  configr  rS  r  r  s
             rv  calculate_rate_limiter_cost#binance.calculate_rate_limiter_cost,  s    6)9(##F"X-?*%%F"X-?*%%6!6(97OEY'G1c'l+
!H$ 8O , vvq11rx  c           	      t   #    U R                  XX4XVU5      I S h  vN nUS:X  a  SU R                  S'   U$  N7f)Nr  Tr  )fetch2r  )	rt  r  r  r}  r  r  r  r&  r  s	            rv  r  binance.request,  s>     TvVV)BFDLL>?	 Ws   868c                 l  #    U R                  U R                  SS5      nUS:X  a  SnU R                  USU5      nUS:X  d  US:X  a  [        U R                  S-   5      eU R	                  5       I S h  vN   U R                  U5      nU R                  X5      nUUS   US.nS n	S n
US	   (       a.  US
   n
U R                  U R                  X5      5      I S h  vN n	O-US   n
U R                  U R                  X5      5      I S h  vN n	U R                  U R                  X5      SU
05      $  N NW N+7f)Nr  r\   rY   ry  rZ   z@ add / reduce margin only supported with type future or deliveryrO   )ry  r  r  r  r  r  r  )r  r  r?   rO   r  r  r  fapiPrivatePostPositionMarginr  dapiPrivatePostPositionMarginparse_margin_modification)rt  r  r  addOrReducer  r  ry  r  r  r  r  s              rv  modify_margin_helperbinance.modify_margin_helper,  s?    &&t||]HM& "K<H$&.tww)kkll!!!V$))&9Tl

 ('?D!??G@\]]H&>D!??G@\]]H {{499(KDN
  	1 	" ^ ^s7   A0D42D.3A%D4D0-D4D2(D40D42D4r  c                 x   U R                  US5      nU R                  US5      nU R                  US5      nU R                  US5      nU R                  XRS S5      nUS L nUS:H  nUUS   US:X  a  SOS	S
U R                  US5      U R                  US5      S U(       d  U(       a  SOSUU R	                  U5      S.
$ )Nry  r  r  rM  r[   r  r   addreducerO  r  r  r  r  )
r  r  ry  r>  r  r  r  rF  r  r  )r  r  r  r  ro  )	rt  r  r  rawTyper!  r  r  noErrorCoder  s	            rv  r/  !binance.parse_margin_modification,  s    0 ##D&1$$T62	##D(3%%dF3	!!(D&A4'u$X&%lE$&&tX6$$T73&+dH"Y/
 	
rx  c                 D   #    U R                  XSU5      I Sh  vN $  N7f)a  
remove margin from a position

https://developers.binance.com/docs/derivatives/usds-margined-futures/trade/rest-api/Modify-Isolated-Position-Margin
https://developers.binance.com/docs/derivatives/coin-margined-futures/trade/rest-api/Modify-Isolated-Position-Margin

: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r1  rt  r  r  r  s       rv  reduce_marginbinance.reduce_margin!-  "      ..vq&IIII     c                 D   #    U R                  XSU5      I Sh  vN $  N7f)a  
add margin

https://developers.binance.com/docs/derivatives/usds-margined-futures/trade/rest-api/Modify-Isolated-Position-Margin
https://developers.binance.com/docs/derivatives/coin-margined-futures/trade/rest-api/Modify-Isolated-Position-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   Nr:  r;  s       rv  
add_marginbinance.add_margin/-  r>  r?  c                   #    U R                  5       I Sh  vN   U R                  U5      nSUS   0nU R                  U R                  XB5      5      I Sh  vN nU R	                  US5      nU R                  U5      $  Ng N)7f)a~  
fetch the rate of interest to borrow a currency for margin trading

https://developers.binance.com/docs/margin_trading/borrow-and-repay/Query-Margin-Interest-Rate-History

: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>`
Nr  rO   r   )r  rg   sapiGetMarginInterestRateHistoryr  r  parse_borrow_rate)rt  r  r  rg  r  r  r  s          rv  fetch_cross_borrow_ratebinance.fetch_cross_borrow_rate=-  s      !!!==&Xd^
 >>t{{7?[\\ ~~h*%%d++% 	" ]s!   BA>?BB (B Bc                    #    SU0nU R                  U R                  X25      5      I Sh  vN nU R                  XA5      $  N7f)a@  
       fetch the rate of interest to borrow a currency for margin trading

       https://developers.binance.com/docs/margin_trading/account/Query-Isolated-Margin-Fee-Data

       :param str symbol: unified market symbol
       :param dict [params]: extra parameters specific to the exchange API endpoint

EXCHANGE SPECIFIC PARAMETERS
       :param dict [params.vipLevel]: user's current specific margin data will be returned if viplevel is omitted
       :returns dict: an `isolated borrow rate structure <https://docs.ccxt.com/#/?id=isolated-borrow-rate-structure>`
       r  N)fetch_isolated_borrow_ratesr  r  )rt  r  r  r  borrowRatess        rv  fetch_isolated_borrow_rate"binance.fetch_isolated_borrow_rate[-  sF      f
 !<<T[[=YZZ~~k22 [s   (AA Ac                 8  #    U R                  5       I Sh  vN   0 nU R                  US5      nU R                  US5      nUb  U R                  U5      nUS   US'   U R	                  U R                  X!5      5      I Sh  vN nU R                  U5      $  N N7f)a&  
       fetch the borrow interest rates of all currencies

       https://developers.binance.com/docs/margin_trading/account/Query-Isolated-Margin-Fee-Data

       :param dict [params]: extra parameters specific to the exchange API endpoint
       :param dict [params.symbol]: unified market symbol

EXCHANGE SPECIFIC PARAMETERS
       :param dict [params.vipLevel]: user's current specific margin data will be returned if viplevel is omitted
       :returns dict: a `borrow rate structure <https://docs.ccxt.com/#/?id=borrow-rate-structure>`
       Nr  rO   )r  r  r  r  sapiGetMarginIsolatedMarginDatar  parse_isolated_borrow_rates)rt  r  r  r  r  r  s         rv  rI  #binance.fetch_isolated_borrow_ratesn-  s      !!!!!&(368,[[(F &tGH==dkk'>Z[[, //99; 	" \s"   BBA)B BBBc                   #    U R                  5       I Sh  vN   Uc  SnOUS:  a  [        U R                  S-   5      eU R                  U5      nUS   US.nUb9  X&S'   U R	                  X#S-  5      S-
  nU R                  5       n[        Xx5      US	'   U R                  U R                  Xd5      5      I Sh  vN n	U R                  XX#5      $  N N7f)
aV  
retrieves a history of a currencies borrow interest rate at specific time slots

https://developers.binance.com/docs/margin_trading/borrow-and-repay/Query-Margin-Interest-Rate-History

: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 92rO   )r  r  r>   \&r   r?  )
r  r5   rO   rg  rB  r  r  rD  r  parse_borrow_rate_history)
rt  r  r7  r  r  rg  r  r?  rR  r  s
             rv  fetch_borrow_rate_history!binance.fetch_borrow_rate_history-  s      !!!=ERZTWW'ccdd==&d^
 #(K hhuh&67!;G##%C!$W!2GI>>t{{7?[\\ --heKK7 	"  ]s"   CCB C7C8CCc                     U R                  US5      nU R                  US5      nU R                  XB5      U R                  US5      SUU R	                  U5      US.$ )Nr  r  dailyInterestRaterS  )rg  r  periodr  r  r  )r  r  r  r  ro  )rt  r  rg  r  r  s        rv  rE  binance.parse_borrow_rate-  sf     %%dK8	%%dG4
//
E$$T+>?"Y/
 	
rx  r  c           
      p   U R                  US5      nU R                  X2S S5      nU R                  US5      nU R                  US5      nU R                  US5      nUU R                  US5      U R                  US5      U R	                  US5      U R                  US5      U R	                  US5      SS S S	.	$ )
Nr  rY   r  r   r   r  dailyInterestrS  )	r  r  r  baseRater  	quoteRaterY  r  r  )r  r  r  r  r  )rt  r  r  r  r  baseInfo	quoteInfos          rv  parse_isolated_borrow_rate"binance.parse_isolated_borrow_rate-  s    ( ##D(3!!(D&A~~dF+>>$*NN4+	&&vx8$$Xv6((?C%%i8)))_E

 
	
rx  c                 @  #    U R                  5       I Sh  vN   U R                  U5      nUS   US.nU R                  U R                  XS5      5      I Sh  vN nU R	                  US5      nU R                  US5      nU R                  US5      n	UU	UUUS.$  N ND7f)aF  
create gift code

https://developers.binance.com/docs/gift_card/market-data/Create-a-single-token-gift-card

: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
NrO   )tokenr  r  r  referenceNo)r  rO   r  rg  r  )r  rg  sapiPostGiftcardCreateCoder  r  r  )
rt  r  r  r  rg  r  r  r  giftcardCoderO   s
             rv  create_gift_codebinance.create_gift_code-  s      !!!==& d^
 88W9UVV ~~h/''f5dM2 
 	
' 	" Ws#   BBA BBABBc                 j   #    SU0nU R                  U R                  X25      5      I Sh  vN nU$  N7f)z
redeem gift code

https://developers.binance.com/docs/gift_card/market-data/Redeem-a-Binance-Gift-Card

:param str giftcardCode:
:param dict [params]: extra parameters specific to the exchange API endpoint
:returns dict: response from the exchange
r  N)sapiPostGiftcardRedeemCoder  )rt  rg  r  r  r  s        rv  redeem_gift_codebinance.redeem_gift_code".  s>      L
 88W9UVV  W   (313c                 j   #    SU0nU R                  U R                  X25      5      I Sh  vN nU$  N7f)a  
verify gift code

https://developers.binance.com/docs/gift_card/market-data/Verify-Binance-Gift-Card-by-Gift-Card-Number

:param str id: reference number id
:param dict [params]: extra parameters specific to the exchange API endpoint
:returns dict: response from the exchange
re  N)sapiGetGiftcardVerifyr  )rt  rO   r  r  r  s        rv  verify_gift_codebinance.verify_gift_code=.  s>      2
 33DKK4PQQ  Rrn  c                 T  #    U R                  5       I Sh  vN   SnU R                  USSSS5      u  pe0 nSnUb  U R                  U5      n	U	S   US'   Ub  X7S'   Ub  XGS	'   U R                  S
Xu5      u  puSn
U(       a)  U R	                  U R                  Xu5      5      I Sh  vN n
ODUb  U R                  U5      nUS   US'   U R                  U R                  Xu5      5      I Sh  vN n
U R                  U
S5      nU R                  X5      nU R                  XX45      $  GN N N>7f)a`  
fetch the interest owed by the user for borrowing currency for margin trading

https://developers.binance.com/docs/margin_trading/borrow-and-repay/Get-Interest-History
https://developers.binance.com/docs/derivatives/portfolio-margin/account/Get-Margin-BorrowLoan-Interest-History

: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>`
Nr   r  rm  FrO   r  r>  r[  r?  rQ  r  )r  r  rg  ro  "papiGetMarginMarginInterestHistoryr  r  sapiGetMarginInterestHistoryr  parse_borrow_interestsfilter_by_currency_since_limit)rt  r  r  r7  r  r  r  r  r  rg  r  r  r  s                rv  fetch_borrow_interestbinance.fetch_borrow_interestU.  sM     !!! $($C$CFLacik|  D  %E!}}T*H'~GG#(K #FO229gN!DDT[[QXEabbH!V,,24L()!>>t{{7?[\\HJ ~~h/..t<2285PPw 	" c
 ]s5   D(D!BD("D$#AD('D&(:D($D(&D(c                 ,   U R                  US5      nU R                  US5      nUc  SOSnUUU R                  U R                  US5      5      U R                  US5      U R                  US5      U R                  US5      UUU R	                  U5      S	.	$ )
NrQ  interestAccuredTimer  rO  r  r  r  	principal)	r  r  rg  r  r  amountBorrowedr>  r  r  r  r  r  r  ro  )rt  r  r  r  r  r>  s         rv  parse_borrow_interestbinance.parse_borrow_interest.  s    !!$(89%%d,AB	!'Wj
//0@0@w0OP((z: ,,T>B"..t[A$"Y/

 
	
rx  c                 F  #    U R                  5       I Sh  vN   U R                  U5      nUS   U R                  X5      S.nSnSnU R                  USSSS5      u  psU(       ap  SnU R                  USSS	5      u  pUS
:X  a)  U R	                  U R                  XS5      5      I Sh  vN nO[U R                  U R                  XS5      5      I Sh  vN nO2SUS'   SUS'   U R                  U R                  XS5      5      I Sh  vN nU R                  Xd5      $  GN Nt NM N7f)a  
repay borrowed margin and interest

https://developers.binance.com/docs/derivatives/portfolio-margin/trade/Margin-Account-Repay
https://developers.binance.com/docs/margin_trading/borrow-and-repay/Margin-Account-Borrow-Repay
https://developers.binance.com/docs/derivatives/portfolio-margin/trade/Margin-Account-Repay-Debt

: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
:param str [params.repayCrossMarginMethod]: *portfolio margin only* 'papiPostRepayLoan'(default), 'papiPostMarginRepayDebt'(alternative)
:param str [params.specifyRepayAssets]: *portfolio margin papiPostMarginRepayDebt only* specific asset list to repay debt
:returns dict: a `margin loan structure <https://docs.ccxt.com/#/?id=margin-loan-structure>`
NrO   rF  r   r  rm  FrepayCrossMarginMethodr}  papiPostMarginRepayDebtFALSEr\  REPAYry  )	r  rg  rL  r  r  r  papiPostRepayLoansapiPostMarginBorrowRepayparse_margin_loan)	rt  r  r  r  rg  r  r  r  r}  s	            rv  repay_cross_marginbinance.repay_cross_margin.  s9      !!!==&d^00>
  $($C$CFL^`fhy  |A  %B!F!<<VEWYqs{|NF22!%!=!=dkk'>Z![[ "&!7!7G8T!UU %,GL!%GFO!;;DKK<XYYH %%h99S 	" \ V ZsF   D!DBD!&D'(D!D2D!DD!D!D!D!c                 2  #    U R                  5       I Sh  vN   U R                  U5      nU R                  U5      nUS   U R                  X#5      US   SSS.nU R	                  U R                  Xt5      5      I Sh  vN nU R                  X5      $  N| N7f)a  
repay borrowed margin and interest

https://developers.binance.com/docs/margin_trading/borrow-and-repay/Margin-Account-Borrow-Repay

: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>`
NrO   TRUEr  r  r  r  r\  ry  r  rg  r  rL  r  r  r  	rt  r  r  r  r  rg  r  r  r  s	            rv  repay_isolated_marginbinance.repay_isolated_margin.  s      !!!==&V$d^00>Tl 
 77G8TUU %%h99# 	" V"   BBA&B=B>BBc                   #    U R                  5       I Sh  vN   U R                  U5      nUS   U R                  X5      S.nSnSnU R                  USSSS5      u  psU(       a)  U R	                  U R                  XS5      5      I Sh  vN nO2SUS	'   S
US'   U R                  U R                  XS5      5      I Sh  vN nU R                  Xd5      $  N NJ N7f)aj  
create a loan to borrow margin

https://developers.binance.com/docs/margin_trading/borrow-and-repay/Margin-Account-Borrow-Repay
https://developers.binance.com/docs/derivatives/portfolio-margin/trade/Margin-Account-Borrow

: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>`
NrO   rF  r_   r  rm  Fr  r\  BORROWry  )r  rg  rL  r  papiPostMarginLoanr  r  r  )rt  r  r  r  rg  r  r  r  s           rv  borrow_cross_marginbinance.borrow_cross_margin/  s      !!!==&d^00>
  $($C$CFL_agiz  }B  %C!!44T[[5QRRH$+GL!&GFO!;;DKK<XYYH %%h99+ 	" S Zs4   CCA1CC	2C;C<CCCc                 2  #    U R                  5       I Sh  vN   U R                  U5      nU R                  U5      nUS   U R                  X#5      US   SSS.nU R	                  U R                  Xt5      5      I Sh  vN nU R                  X5      $  N| N7f)a  
create a loan to borrow margin

https://developers.binance.com/docs/margin_trading/borrow-and-repay/Margin-Account-Borrow-Repay

: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>`
NrO   r  r  r  r  r  s	            rv  borrow_isolated_marginbinance.borrow_isolated_margin//  s      !!!==&V$d^00>Tl 
 77G8TUU %%h99# 	" Vr  c                     U R                  US5      nU R                  US5      nU R                  US5      U R                  X25      U R                  US5      S UU R	                  U5      US.$ )Nr  r  r5  r  )rO   rg  r  r  r  r  r  r~  )rt  r  rg  r  r  s        rv  r  binance.parse_margin_loanN/  su    " %%dG4
%%dL9	##D(3//
E&&tX6"Y/
 	
rx  r   c           	        #    US:X  a  [        U R                  S-   5      eU R                  5       I Sh  vN   SnU R                  USSS5      u  peU(       a  U R	                  SXXBUS5      I Sh  vN $ U R                  U5      nSU R                  U R                  X"5      0nUb  XHS	'   US
   (       a  SOSn	US   X'   US   (       a  U R                  USS5      US'   Ub  X8S'   U R                  US5      n
U R                  USU
5      nU R                  USS/5      nU(       a  XS'   O7U(       a0  Uc  SnU R                  U5      nU R                  X<U-  S-  5      US'   SnUS   (       a)  U R                  U R                  X5      5      I Sh  vN nO(U R                  U R                  X5      5      I Sh  vN nU R                  XX45      $  GN GNe NE N7f)a  
Retrieves the open interest history of a currency

https://developers.binance.com/docs/derivatives/usds-margined-futures/market-data/rest-api/Open-Interest-Statistics
https://developers.binance.com/docs/derivatives/coin-margined-futures/market-data/rest-api/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   z5 fetchOpenInterestHistory cannot use the 1m timeframeNFr   r9  rQ  rY  r  r  r  r=  rO   r  r?  CURRENT_QUARTERr>  r:  r?  r-  rR  )r5   rO   r  r  r@  r  r  r   r  r  rA  rB  dapiDataGetOpenInterestHistr  fapiDataGetOpenInterestHistparse_open_interests_history)rt  r  r6  r7  r  r  r9  r  r  	symbolKeyr:  r?  rQ  r  s                 rv  fetch_open_interest_history#binance.fetch_open_interest_historyk/  s       TWW'^^__!!!88A[]gino@@A[]clq  E  GJ  K  K  KV$d&&t	M
 $G &x 0Hf	#D\)&*&6&6v~O`&aGN##(K !!&'2##FIu=6Iw#78!(I}++I6H!%%E1AD1H!IGI)!==dkk'>Z[[H!==dkk'>Z[[H 005PPW 	" K2 \[sF   2GG;G0G1D!GG(G;G<GGGGc                   #    U R                  5       I Sh  vN   U R                  U5      n0 nUS   (       aA  US   US'   US   c  [        U R                  S-   U-   5      eU R	                  US   5      US'   OUS   US	'   SnUS   (       a)  U R                  U R                  XB5      5      I Sh  vN nO[US
   (       a)  U R                  U R                  XB5      5      I Sh  vN nO(U R                  U R                  XB5      5      I Sh  vN nUS   (       aD  US	   nU R                  XS5      n[        S[        U5      5       H  nXg   nUS	   U:X  d  M  Us  $    gU R                  XS5      $  GNZ N N Nj7f)a#  
retrieves the open interest of a contract trading pair

https://developers.binance.com/docs/derivatives/usds-margined-futures/market-data/rest-api/Open-Interest
https://developers.binance.com/docs/derivatives/coin-margined-futures/market-data/rest-api/Open-Interest
https://developers.binance.com/docs/derivatives/option/market-data/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:
Nr]   r  underlyingAssetr  z$ fetchOpenInterest does not support 
expirationrO   r  r  r   )r  r  r?   rO   rk  eapiPublicGetOpenInterestr  dapiPublicGetOpenInterestfapiPublicGetOpenInterestr  r  r  parse_open_interest)	rt  r  r  r  r  r  r  r  r  s	            rv  fetch_open_interestbinance.fetch_open_interest/  st     !!!V$()/)9G%&h'"477-S#SV\#\]]$(KKx0@$AGL! &tGH(!;;DKK<XYYHI!;;DKK<XYYH!;;DKK<XYYH> (H%F66xHF1c&k*y>V+K +  ++H==o 	" ZYYsM   E9E0BE90E312E9#E5$(E9E7AE9E93E95E97E9c                 &   U R                  USS5      nU R                  US5      nU R                  USS5      nU R                  USS5      nU R                  U R	                  XBS S5      US	   (       a  S OUUUUUU R                  U5      US
.U5      $ )Nr  rM  r  sumOpenInterestrd  sumOpenInterestValuesumOpenInterestUsdr  r  )r  r  r  openInterestAmountopenInterestValuer  r  r  )rj  r  rn  safe_open_interestr  ro  )rt  r  r  r  rO   r  values          rv  r  binance.parse_open_interest/  s    ''+vF	h1##H.?P""8-CEYZ &&&&r4D"("3$ "(!&"Y/	(
 	 		rx  c           	        #    U R                  5       I Sh  vN   SnU R                  USS5      u  pTU(       a  U R                  SXX4SS5      I Sh  vN $ SnUb  U R                  U5      nSnU R	                  SXd5      u  ptSnU R                  SXdS5      u  pSn	U R                  USSS	S5      u  p0 n
US
:w  a  SU
S'   Ub  US
   (       a  SOSnU	(       d  US   X'   Ub  X*S'   Ub  US
:X  a  X:S'   OX:S'   U R                  SX5      u  pSnUS
:X  aZ  U	(       a*  U R                  U R                  X5      5      I Sh  vN nGOU R                  U R                  X5      5      I Sh  vN nOUS:X  aY  U	(       a)  U R                  U R                  X5      5      I Sh  vN nOU R                  U R                  X5      5      I Sh  vN nOUS:X  aY  U	(       a)  U R                  U R                  X5      5      I Sh  vN nOJU R                  U R                  X5      5      I Sh  vN nO![        U R                   S-   US   -   S-   5      eU R#                  USU5      nU R%                  XX#5      $  GN[ GN# GN: GN N N N N]7f)a  
retrieves the users liquidated positions

https://developers.binance.com/docs/margin_trading/trade/Get-Force-Liquidation-Record
https://developers.binance.com/docs/derivatives/usds-margined-futures/trade/rest-api/Users-Force-Orders
https://developers.binance.com/docs/derivatives/coin-margined-futures/trade/rest-api/Users-Force-Orders
https://developers.binance.com/docs/derivatives/portfolio-margin/trade/Query-Users-UM-Force-Orders
https://developers.binance.com/docs/derivatives/portfolio-margin/trade/Query-Users-CM-Force-Orders

: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   r9  currentrP  r  r  rm  rY   LIQUIDATIONautoCloseTyperQ  r  rO   r>  r[  r  r?  r  z( fetchMyLiquidations() does not support ry  r  r  )r  r   fetch_paginated_call_incrementalr  r
  r  r  ro  papiGetMarginForceOrdersr   sapiGetMarginForceLiquidationRecpapiGetUmForceOrdersfapiPrivateGetForceOrderspapiGetCmForceOrdersdapiPrivateGetForceOrdersr?   rO   r  parse_liquidations)rt  r  r7  r  r  r9  r  ry  rz  r  r  r  r  liquidationss                 rv  fetch_my_liquidationsbinance.fetch_my_liquidations0  s    * !!!88AVXbc>>?TV\ejt}  @C  D  D  D[[(F99:OQW`99:OQWaij $($C$CFLacik|  D  %E!6>'4GO$,26N(I$%+D\"#(K v~"'#( 229gN6> !%!>!>t{{7?[!\\!%!F!Ft{{SZGc!dd  !%!:!:4;;w;W!XX!%!?!?G@\!]]	! !%!:!:4;;w;W!XX!%!?!?G@\!]]tww)SSV\]cVddgqqrr\ ~~hA&&|UJJ{ 	" D8 ]d Y] Y]s   JI1:JI4C+J=I7>)J'I:(5JI=(JI?5J<J=(J%J&AJ4J7J:J=J?JJJc                    U R                  US5      nU R                  USS5      nU R                  UU R                  X25      U R	                  US5      U R	                  US5      U R	                  US5      U R                  US5      U R	                  US5      U R	                  US	5      UU R                  U5      S
.
5      $ )Nr  updatedTimer  r  r  r  rR  r  r  )
r  r  r  r  r  rR  	baseValue
quoteValuer  r  )r  rj  safe_liquidationr  r  ri  ro  )rt  liquidationr  r  r  s        rv  parse_liquidationbinance.parse_liquidation0  s    J ##K:'']LQ	$$&&x8))+}E ,,V^D%%k:>**;?))+yA**;
C"Y/&
  	rx  c                    #    U R                  5       I Sh  vN   U R                  U5      nSUS   0nU R                  U R                  XB5      5      I Sh  vN nU R	                  US   U5      $  NY N7f)a  
fetches an option contracts greeks, financial metrics used to measure the factors that affect the price of an options contract

https://developers.binance.com/docs/derivatives/option/market-data/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  rO   r   )r  r  eapiPublicGetMarkr  parse_greeksr  s         rv  fetch_greeksbinance.fetch_greeks0  sy      !!!V$fTl
 //G0LMM$   !f55/ 	"
 Ns!   A4A0?A4A2A42A4c                 F  #    U R                  5       I Sh  vN   U R                  USSSS5      n0 nSnUb-  [        U5      nUS:X  a  U R                  US   5      nUS   US'   U R	                  U R                  X25      5      I Sh  vN nU R                  Xa5      $  N N7f)a  
fetches all option contracts greeks, financial metrics used to measure the factors that affect the price of an options contract

https://developers.binance.com/docs/derivatives/option/market-data/Option-Mark-Price

:param str[] [symbols]: unified symbols of the markets to fetch greeks for, all markets are returned if not assigned
:param dict [params]: extra parameters specific to the exchange API endpoint
:returns dict: a `greeks structure <https://docs.ccxt.com/#/?id=greeks-structure>`
NTr   r   rO   r  )r  r  r  r  r  r  parse_all_greeks)rt  r!  r  r  r  r9  r  s          rv  fetch_all_greeksbinance.fetch_all_greeks1  s      !!!%%gtT4FLM!WQZ0$*4L!//G0LMM$ $$X777 	" Ns"   B!BA0B!BB!B!greeksc                    U R                  US5      nU R                  X25      n0 SU_SS _SS _SU R                  US5      _SU R                  US5      _SU R                  US5      _SU R                  US5      _SS _S	S _S
S _SU R                  US5      _SU R                  US5      _SU R                  US5      _SS _SS _SU R                  US5      _SS _S US.E$ )Nr  r  r  deltagammathetavegarhobidSizeaskSizebidImpliedVolatilitybidIVaskImpliedVolatilityaskIVmarkImpliedVolatilitymarkIVr  r  r  r  )underlyingPricer  )r  r  r  )rt  r  r  r  r  s        rv  r  binance.parse_greeks41  sm     ##FH5!!(3
f

 
 T%%fg6	

 T%%fg6
 T%%fg6
 D$$VV4
 4
 t
 t
 #D$4$4VW$E
 #D$4$4VW$E
 $T%5%5fh%G
 
 
  ))&+>!
" #
$  $'
 	
rx  c                    #    U R                  5       I S h  vN n0 n[        S[        U5      5       H1  nX5   nUS   nUb  U R                  Xq5      (       d  M'  US   S   XG'   M3     U$  NR7f)Nr   r  r  r  )r9  r  r  r#  )rt  r!  r  r  tradingLimitsr  r  r  s           rv  fetch_trading_limitsbinance.fetch_trading_limits\1  ss     **,, q#g,'AZFH%FT]]6%C%C(.x(8(B%	 (
  -s   A+A)>A+A+c                 L  #    SnUb  U R                  U5      nSnU R                  SX25      u  pBSnUS:X  a  U R                  U5      I Sh  vN nO8US:X  a  U R                  U5      I Sh  vN nO[	        U R
                  S-   5      eU R                  US5      nUUS.$  NT N67f)a  
fetchs the position mode, hedged or one way, hedged for binance is set identically for all linear markets or all inverse markets

https://developers.binance.com/docs/derivatives/usds-margined-futures/account/rest-api/Get-Current-Position-Mode
https://developers.binance.com/docs/derivatives/coin-margined-futures/account/rest-api/Get-Current-Position-Mode

: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"]ru  )r  rF  )r  r  fapiPrivateGetPositionSideDualdapiPrivateGetPositionSideDualr5   rO   r  )rt  r  r  r  rz  r  ru  s          rv  fetch_position_modebinance.fetch_position_modeg1  s      [[(F99:Mv^h!@@HHH	!!@@HHHTWW'rrss  >>(4FG&
 	
 IHs$   A	B$B B$+B",5B$"B$c                   #    U R                  5       I Sh  vN   SnUb%  U R                  U5      nU R                  US   5      nSnU R                  SX25      u  pBSnUS:X  a  U R	                  U5      I Sh  vN nO8US:X  a  U R                  U5      I Sh  vN nO[        U R                  S-   5      eU R                  US/ 5      n[        U[        5      (       a  UnU R                  XaSS	5      $  N N| N^7f)
a  
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

https://developers.binance.com/docs/derivatives/coin-margined-futures/account/rest-api/Account-Information
https://developers.binance.com/docs/derivatives/usds-margined-futures/account/rest-api/Account-Information-V2
https://developers.binance.com/docs/derivatives/usds-margined-futures/account/rest-api/Symbol-Config

:param str[] symbols: 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 `margin mode structures <https://docs.ccxt.com/#/?id=margin-mode-structure>`
Nr   r   r  r  z= fetchMarginModes() supports linear and inverse subTypes onlyr  r  r[   )r  r  r  r  r~  r  r5   rO   r  r  r)  parse_margin_modes)rt  r!  r  r  rz  r  r  s          rv  fetch_margin_modesbinance.fetch_margin_modes1  s      !!!))'2G[[,F99:KV\h!<<VDDH 	!!77??Hd TWW'ffgg+r:h%%F&&v&IIY 	" E @s5   C8C2A C87C48C8C6AC84C86C8c                   #    U R                  5       I Sh  vN   U R                  U5      nSnU R                  SX25      u  pBSnUS:X  a0  SUS   0nU R                  U R	                  Xb5      5      I Sh  vN nO=US:X  a  U R                  U/U5      I Sh  vN nXq   $ [        U R                  S-   5      eU R                  US   U5      $  N NY N97f)	a#  
fetches the margin mode of a specific symbol

https://developers.binance.com/docs/derivatives/usds-margined-futures/account/rest-api/Symbol-Config
https://developers.binance.com/docs/derivatives/coin-margined-futures/account/rest-api/Account-Information

: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 `margin mode structure <https://docs.ccxt.com/#/?id=margin-mode-structure>`
Nr   r  r  rO   r  z< fetchMarginMode() supports linear and inverse subTypes onlyr   )	r  r  r  r~  r  r  r5   rO   parse_margin_mode)rt  r  r  r  rz  r  r  fetchMarginModesResponses           rv  fetch_margin_modebinance.fetch_margin_mode1  s      !!!V$99:KV\h&,G "<<T[[=YZZH 	!-1-D-DfXv-V'V$+33TWW'eeff%%hqk6::5 	" [ (Ws4   CCAC4C5!CC6CCCc                     U R                  US5      nU R                  X25      nU R                  US5      nS nUb  U(       a  SOSnU R                  US5      nUb
  US:X  a  SOSnUUS   US.$ )Nr  rO  r  r  r  )r  r  r>  )r  r  r  ri  )rt  r>  r  r  r  reMarginModer  s          rv  r  binance.parse_margin_mode2  s    ##J9!!(3z:>$)6:GL..z<H$'4	'A7
LX&&
 	
rx  c                   #    U R                  5       I Sh  vN   U R                  U5      nSUS   0nU R                  U R                  XB5      5      I Sh  vN nU R	                  US0 5      nU R                  USU5      $  Nj N,7f)a~  
fetches option data that is commonly found in an option chain

https://developers.binance.com/docs/derivatives/option/market-data/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  rO   r   )r  r  r  r  r  parse_option)rt  r  r  r  r  r  chains          rv  fetch_optionbinance.fetch_option2  s      !!!V$fTl
 11$++g2NOO2 xB/  f55? 	"
 Ps!   BB?BB+BBr  c                    U R                  US5      nU R                  XC5      n0 SU_SS _SUS   _SS _SS _SS _SS _SU R                  US5      _S	U R                  US	5      _S
S _SS _SU R                  US5      _SU R                  US5      _SU R                  US5      _SU R                  US5      _SU R                  US5      _SS _$ )Nr  r  rg  r  r  impliedVolatilityrd  r  r  midPricer  r  r  r  r  r  r  r  r  r  r  )r  r  r  )rt  r  rg  r  r  s        rv  r  binance.parse_optionH2  sY   . ##E84!!(3
E

 fX&
 	

 
  
 D
 ((
;
 ((
;
 
 
 ))%=
 t//G
 d&&um<
 $**52FG
  $**5(;!
" 4#
 	
rx  c                   #    U R                  5       I Sh  vN   Uc  [        U R                  S-   5      eU R                  U5      nU R	                  US5      nU R                  US5      nSUS   0nUb  US:X  a  SOSUS	'   Ub  X8S
'   Ub  XHS'   Ub  XxS'   Sn	US   (       a)  U R                  U R                  X5      5      I Sh  vN n	OQUS   (       a)  U R                  U R                  X5      5      I Sh  vN n	O[        U R                  S-   US	   -   5      eU R                  U	5      n
U R                  XX45      $  GN* N| NK7f)a  
fetches the history of margin added or reduced from contract isolated positions

https://developers.binance.com/docs/derivatives/usds-margined-futures/trade/rest-api/Get-Position-Margin-Change-History
https://developers.binance.com/docs/derivatives/coin-margined-futures/trade/rest-api/Get-Position-Margin-Change-History

: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  rO   r4  r   r  ry  r>  r  r?  r  r  zE fetchMarginAdjustmentHistory() is not supported for markets of type )r  r4   rO   r  r  r  #fapiPrivateGetPositionMarginHistoryr  #dapiPrivateGetPositionMarginHistoryr5   parse_margin_modificationsr  )rt  r  ry  r7  r  r  r  r:  r  r  modificationss              rv  fetch_margin_adjustment_history'binance.fetch_margin_adjustment_historyu2  s`     !!!>#DGG.j$jkkV$!!&'267+fTl
 $(EMaGFO#(K $G!&I(!EEdkkRYFbccHI!EEdkkRYFbccHTWW'nnqwx~q  A  A  77A00UUQ 	"& dcs5   EE B/EE2E9E:AEEEc                   #    U R                  5       I Sh  vN   U R                  U5      I Sh  vN n0 n[        S[        U5      5       Hw  nX$   nU R	                  US5      nU R                  U5      nUUUSSSSSSSU R                  U R                  U R	                  US5      5      5      SSS.SSS.SSS.S.SS.X7'   My     U$  N N7f)a  
fetches all available currencies that can be converted

https://developers.binance.com/docs/convert/market-data/Query-order-quantity-precision-per-asset

:param dict [params]: extra parameters specific to the exchange API endpoint
:returns dict: an associative dictionary of currencies
Nr   r  fractionr  )r  r   r  )r  rO   r  r/  ry  rP   r  r  r   r  r  r  r\  )r  sapiGetConvertAssetInfor  r  r  r  rr  rp  )rt  r  r  r  r  r  rO   r  s           rv  fetch_convert_currencies binance.fetch_convert_currencies2  s     !!!55f== q#h-(AKE!!%1B**2.D  !..t/C/CDDTDTUZ\fDg/hi  $#
  $#!
  $#   5FL	 )@ W 	"=s    CCCC
BC
CfromCodetoCodec                 <  #    Uc  [        U R                  S-   5      eU R                  5       I Sh  vN   UUUS.nU R                  U R	                  XT5      5      I Sh  vN nU R                  U5      nU R                  U5      nU R                  XgU5      $  Nf N:7f)aY  
fetch a quote for converting from one currency to another

https://developers.binance.com/docs/convert/trade/Send-quote-request

: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
:param str [params.walletType]: either 'SPOT' or 'FUNDING', the default is 'SPOT'
:returns dict: a `conversion structure <https://docs.ccxt.com/#/?id=conversion-structure>`
Nz0 fetchConvertQuote() requires an amount argument)r  toAsset
fromAmount)r4   rO   r  sapiPostConvertGetQuoter  rg  parse_conversion)	rt  r	  r	  r  r  r  r  fromCurrency
toCurrencys	            rv  fetch_convert_quotebinance.fetch_convert_quote2  s      >#DGG.`$`aa!!!! 

 55dkk'6RSS }}X.]]6*
$$XZHH' 	" Ts!   /BB-BB 9BBc                   #    U R                  5       I Sh  vN   0 nSnUS:X  d  US:X  aT  Uc  [        U R                  S-   5      eXS'   X&S'   X6S'   XFS'   U R                  U R	                  Xe5      5      I Sh  vN nO,XS'   U R                  U R	                  Xe5      5      I Sh  vN nU R                  U5      nU R                  U5      n	U R                  XxU	5      $  N Ng N<7f)	a'  
convert from one currency to another

https://developers.binance.com/docs/convert/trade/Accept-Quote

: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>`
Nr*  z1 createConvertTrade() requires an amount argumentclientTranIdr  targetAssetr  r  )r  r4   rO   sapiPostAssetConvertTransferr  sapiPostConvertAcceptQuoterg  r	  )
rt  rO   r	  r	  r  r  r  r  r	  r	  s
             rv  create_convert_tradebinance.create_convert_trade3  s      !!!Ff$4~'2e(eff&(N#'G%+M" &H!>>t{{7?[\\H "$I!<<T[[=YZZH }}X.]]6*
$$XZHH; 	" ] [s4   C%CA"C%9C!:,C%&C#'9C%!C%#C%c                   #    U R                  5       I Sh  vN   0 nSnUS:X  af  SnU R                  5       nUb  U R                  U5      nUS   US'   XS'   Xv-
  US'   XtS'   U R                  U R	                  XC5      5      I Sh  vN nO,XS	'   U R                  U R	                  XC5      5      I Sh  vN nUn	US:X  a&  U R                  US
/ 5      n
U R                  U
S0 5      n	U R                  U	SS5      nU R                  U	SS5      nSnSnUb  U R                  U5      nUb  U R                  U5      nU R                  XU5      $  GN3 N N7f)a  
fetch the data for a conversion trade

https://developers.binance.com/docs/convert/trade/Order-Status

:param str id: the id of the trade that you want to fetch
:param str [code]: the unified currency code of the conversion trade
:param dict [params]: extra parameters specific to the exchange API endpoint
:returns dict: a `conversion structure <https://docs.ccxt.com/#/?id=conversion-structure>`
Nr*  rS  rO   r  r5  r>  r?  rn  r  r   deductedAssetr  r	  r	  )
r  r  rg  &sapiGetAssetConvertTransferQueryByPager  sapiGetConvertOrderStatusr  r  r  r	  )rt  rO   r  r  r  r  msInDayrR  rg  r  r  fromCurrencyIdtoCurrencyIdr	  r	  s                  rv  fetch_convert_tradebinance.fetch_convert_trade43  so     !!!6>G##%C==.#+D>  "H#&=GK !$I!HHU\IeffH( "$I!;;DKK<XYYH 6>>>(FB7D>>$2.D++D/;O))$yI
%==8L#|4J$$TDDw 	" g* Zs5   EE	A.EE,E2E3BEEEc                   #    U R                  5       I Sh  vN   0 nSnU R                  5       nUb  X%S'   OXv-
  US'   U R                  USS5      nUb  XS'   OXuS'   U R                  US5      nSn	Sn
SnSnUS:X  aO  U R	                  U5      nUS   US'   Ub  X5S	'   S
nSnSn
U R                  U R                  XT5      5      I Sh  vN n	O\US   US   -
  U:  a  [        U R                  S-   5      eUb  X5S'   SnSnSn
U R                  U R                  XT5      5      I Sh  vN n	U R                  X/ 5      nU R                  XXX#5      $  GN7 N N.7f)a:  
fetch the users history of conversion trades

https://developers.binance.com/docs/convert/trade/Get-Convert-Trade-History

:param str [code]: the unified currency code
:param int [since]: the earliest time in ms to fetch conversions for
:param int [limit]: the maximum number of conversion structures to retrieve
:param dict [params]: extra parameters specific to the exchange API endpoint
:param int [params.until]: timestamp in ms of the latest conversion to fetch
:returns dict[]: a list of `conversion structures <https://docs.ccxt.com/#/?id=conversion-structure>`
Nl    H4 r>  r?  r:  r*  rO   r  r[  r%	  r	  r  zV fetchConvertTradeHistory() the max interval between startTime and endTime is 30 days.r  r  r	  r)  )r  r  rj  r  rg  r&	  r  r5   rO   sapiGetConvertTradeFlowr  parse_conversions)rt  r  r7  r  r  r  msInThirtyDaysrR  r?  r  responseQueryfromCurrencyKeytoCurrencyKeyrg  r  s                  rv  fetch_convert_trade_history#binance.fetch_convert_trade_history|3  s     !!!#!#(K #&#7GK %%fiA!(I!$I67+6>}}T*H'~GG "'-O)M"M!HHU\IeffH( 	"W[%99^K   ,D  "D  E  E #( )O%M"M!99$++g:VWWH. ~~hr:%%d/RW__[ 	"4 g6 Xs5   EEB/EEAE#E$*EEE
conversionr	  r	  c                 Z   U R                  U/ SQ5      nU R                  USS5      nU R                  XR5      nU R                  USS5      nU R                  Xs5      nUUU R                  U5      U R	                  U/ SQ5      UU R                  USS5      UU R                  US	S
5      S S S.
$ )N)rM  validTimestampr  r%	  r  r	  r	  )r5  rn  r  deductedAmountr	  targetAmounttoAmount)
r  r  r  rO   r	  r	  r	  r;	  r  r  )r
  r  r  ro  rv  rn  )	rt  r6	  r	  r	  r  fromCurr	  tor	  s	            rv  r	  binance.parse_conversion3  s    N ''
4\]	$$Z+N**7A
M9E((8"Y/$$Z1QR$,,Z9I<X **:~zR
 	
rx  c                   #    U R                  5       I Sh  vN   SnUb%  U R                  U5      nU R                  US   5      nSnSnU R                  SX2S5      u  pRSnU R	                  XE5      (       a  U R                  U5      I Sh  vN nOHU R                  XE5      (       a  U R                  U5      I Sh  vN nO[        U R                  S-   5      eU R                  Xa5      $  N N` N27f)a6  
fetch the funding rate interval for multiple markets

https://developers.binance.com/docs/derivatives/usds-margined-futures/market-data/rest-api/Get-Funding-Rate-Info
https://developers.binance.com/docs/derivatives/coin-margined-futures/market-data/rest-api/Get-Funding-Info

:param str[] [symbols]: list of unified market symbols
:param dict [params]: extra parameters specific to the exchange API endpoint
:param str [params.subType]: "linear" or "inverse"
:returns dict[]: a list of `funding rate structures <https://docs.ccxt.com/#/?id=funding-rate-structure>`
Nr   r[   r   r  zH fetchFundingIntervals() supports linear and inverse swap contracts only)r  r  r  r  r  fapiPublicGetFundingInfor~  dapiPublicGetFundingInfor?   rO   r  r  s          rv  fetch_funding_intervalsbinance.fetch_funding_intervals14  s      !!!))'2G[[,F99:QSYckl>>$((!::6BBH__T++!::6BBHtww)sstt ''::5 	" CBs4   C/C)A3C/
C+/C/:C-;/C/+C/-C/c                 "  #    U R                  5       I Sh  vN   U R                  U5      nUc  SnSU0nU R                  SXu5      u  puUb  X7S'   Ub  XGS'   SnU R                  SXe5      u  pSn	US:X  a1  US	   US
'   U R	                  U R                  Xu5      5      I Sh  vN n	ORUS:X  a4  US   S   US'   U R                  U R                  Xu5      5      I Sh  vN n	O[        U R                  S-   5      eU R                  X5      $  N Nj N27f)aO  
fetches the long short ratio history for a unified market symbol

https://developers.binance.com/docs/derivatives/usds-margined-futures/market-data/rest-api/Long-Short-Ratio
https://developers.binance.com/docs/derivatives/coin-margined-futures/market-data/rest-api/Long-Short-Ratio

:param str symbol: unified symbol of the market to fetch the long short ratio for
:param str [timeframe]: the period for the ratio, default is 24 hours
:param int [since]: the earliest time in ms to fetch ratios for
:param int [limit]: the maximum number of long short ratio structures to retrieve
:param dict [params]: extra parameters specific to the exchange API endpoint
:param int [params.until]: timestamp in ms of the latest ratio to fetch
:returns dict[]: an array of `long short ratio structures <https://docs.ccxt.com/#/?id=long-short-ratio-structure>`
Nr   rY  r?  r>  r  r   r  rO   r  r  r  r=  zG fetchLongShortRatioHistory() supports linear and inverse subTypes only)
r  r  ro  r  &fapiDataGetGlobalLongShortAccountRatior  &dapiDataGetGlobalLongShortAccountRatior5   rO   parse_long_short_ratio_history)
rt  r  r6  r7  r  r  r  r  rz  r  s
             rv  fetch_long_short_ratio_history&binance.fetch_long_short_ratio_historyY4  s6     !!!V$Ii
 229gN#(K $G99:VX^gh &tGH!HHU\IeffH 	!$VnV4GFO!HHU\IeffH TWW'ppqq228DD[ 	"" g gs4   DD	B	D D!9DD/DDDc           	          U R                  US5      nU R                  US5      nUU R                  X2S S5      UU R                  U5      S U R	                  US5      S.$ )Nr  r  r  longShortRatio)r  r  r  r  r6  rK	  )r  safe_integer_omit_zeror  ro  r  )rt  r  r  r  r  s        rv  parse_long_short_ratiobinance.parse_long_short_ratio4  sj    , ##D(3//kB	&&xzJ"Y/"..t5EF
 	
rx  )r   )N)NNNN)NNF)F)NN)__name__
__module____qualname____firstlineno__r   rq  r  r#   boolr~  r  r  r  r-   r  r   r  r  r  r  r   r  r
   r  r/   r9  dictr.  r  r   r  r  r   r  r%   r  r  r  r$   r  r  r  r&   r!  r   r+  r.  r)  r4  rT  r)   ry  r  r!   r    floatr   r  r  r  r  r  r   r  r  r   r  r  r/  r  rW  rZ  r]  rh  rz  r  r  r  r  r  r  r  r  r  r  r  rs  r,   r  r  r  r   r.  r2  r.   r@  rC  r   rb  r   rg  rf  rr  rv  rz  r   r*   r  r  r+   r  r  r'   r  r  r  r(   r  r  r  r  r  r#  r   r'  r   r0  r5  r:  r4  r"   rF  rD  rC  r]  r  re  rp  rz  r   r  r   r  r  r  r  r  r   r  r  r  r  rj  r  r	  r  r"  r'  r  r1  r   r/  r<  rA  r	   rF  r   rK  r   rI  rU  rE  ra  rh  rl  rq  r   rx  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"	  r+	  r4	  r	  rB	  r   rH	  rM	  __static_attributes____classcell__)ru  s   @rv  rK   rK   )   s   o(# o(bQ(s (S (D ('c 'C '4 '-t -;
3 ;
z.LS .L_ .L`YC Y YRU Yjm Y  zI Y YKD3$ 3( ') 9S 94 -/ a: aF *, cV cJ	g4 gF gRdAem dAL *, @X @XD @DB ES E ES\ ENv4 v v6 vp )+ 
2 68 %3 %3F %3N 8<B  5W  5D :>b :9w :9x&
f &
P 6:" /57 /5 /5b@ :< 3S 3 3@ :>b 5w 5W 58=
 =
4 =
~ ?CQUdhqs v v v3 v^a vx|  ~B  yC vp~ ~v ~ ~@ <@d[] IA IAS IA IAbfglbm IAV y}  FH ?. ?.S ?.	 ?.QZ ?.di ?.ru ?.B {  HJ g,# g,s g,) g,S\ g,fk g,tw g,R C  LN c 3 i W` jo x{ $ }A  JL A2C A2 A2I A2U^ A2hm A2vy A2F fjx|  FH a3 a a9 aI a_b aru a4 DF M+\(: M+^: :k kv k kZ FH K+$|*< K+Z mqy{ `2 `2I `2Y `2X] `2fi `2D os{} E33 E3i E3y E3Z_ E3hk E3N eg e# eY eV[ e* XZ fc f f( Y[ Us U% U$ 8<B ?2C ?2 ?2B 04$UYbd AA AAC AAs AAimnsit AAF 59tZ^gi QAc QA QATW QAnrsxny QAf =A J2 J2c J2X 7;\`ik H H3 HVY Hptuzp{ H: 9=4^bkm H# HS HX[ H: DHVZimvx FS FPS Fcf F  ~B  CH  ~I F@ 9=R O2S O2# O2b 59 \c \| AER I3tCy I3# I3V ?CQUdhqs ^3 ^ ^3 ^^a ^: 37TX\eg SAC SAs SARU SAj 8<$]ajl C@ C@C C@WZ C@JA
f A
F 04$UYbd dI dIC dIs dIimnyiz dIL 37TX\eg yIC yIs yIRU yIlpq|l} yIv$:Lx
T x
X x
Q\ x
t:C :C :c
t c
x c
= c
J
6 
4 ac U73 U7 U7C U7TW U7gt U7n 154VZce DB# DBS DBPS DBjno|j} DBL =? &> &>> &>P
 
N 
8 =A o
' o
b BFb 6Iw 6Ip@ @D QU]_ ":3 ": ": ":# ":do ":H
T 
6 
EX 
: ;= ?4c ?4AT ?4B /1 g[ gR FH 73 7> <> %9s %9+ %9N >BPTcgpr 7Qs 7Q# 7Q]` 7Qr
6 
" <@ ; ;| ;8:
6 :
[ :
xBj
v j
X\
F \
| 38 '0R =A IF' IFP] IFV& &$|J\ &P 8: )83 )8V ?C2 4PG 4Pl6t 6V 6p 8<B  HW  H4PX>  HD @DB wPW wPr =A eP' ePN 9=4^bkm 5B# 5BS 5BX[ 5Bn ?C2 *3 * *X DHPR 6 6S 6p CGr 4d 4C 4l 8<B 'BW 'B9 'BR
t 
V 
x 
8 <@daenp (OS (O (O[^ (OT ?CQUdhqs 1O 1O3 1O^a 1Of'
R&P =A #83 #8c #8P[ #8J .2SW`b XCs XC# XCS XCgklwgx XCt5t 5x 5; 5n80C S \_ "
,C 
,C 
, &eBSW pPd C $D# Ds D Dc DTX D`c DL MO 2  '/uRQU\`ik  SU " "H*
d *
F *
N` *
X FH J# Ju JL^ J CE Js JE JI[ J ?A ,# ,_ ,< DF 3s 3J\ 3& 8: *:>Q *:X GKY]fh 'LC 'L 'LSV 'LR
 
(#
t #
V #
Oa #
J @B $
3 $
L ;= 6 68  0 7;$]apt} JQ JQC JQWZ JQjm JQ  EI  JX  EY JQX
$ 
 
. 
  BD 9:S 9:v RT :# :S :> JL ":c ":5 ":H Z\ :3 :c :5 :>
 
: HLZ^mqz| =Q =QTW =Qgj =Q~ =? D DLF $ 9=4^bkm RK# RKS RKX[ RKhRV Rh 68 !6 !6F !6F 9=R %8g %8DQWL %8N&
4 &
 &
6 &
P =A 	' 	 7;2 !
 !
F ;?r YJ YJk YJv ;= &;c &; &;P
D 
* 
  68 )6 )6F )6V+
$ +
( +
6 +
]c +
Z CGTXgkz~  HJ 7VC 7Vc 7Vad 7Vtw 7V  OS  Tf  Og 7Vr 57 4: 4l SW_a "I# "Is "IC "Ifp "IH ]aik *IS *IC *I *IVY *Ipz *IX >B" FEC FEs FEQ[ FEP =Atbfoq Z`c Z` Z`\_ Z`vz  |F  wG Z`xW
4 W
x W
\d W
pz W
r @DB &;W &;S_ &;P BFX\ko  C  LN <E3 <ERU <Eeh <Ex{ <E  SW  Xf  Sg <E|
4 
 
> 
 
rx  rK   )R 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!   r"   r#   r$   r%   r&   r'   r(   r)   r*   r+   r,   r-   r.   typingr/   ccxt.base.errorsr0   r1   r2   r3   r4   r5   r6   r7   r8   r9   r:   r;   r<   r=   r>   r?   r@   rA   rB   rC   rD   rE   rF   ccxt.base.decimal_to_precisionrG   rH   ccxt.base.preciserI   rK   r|  rx  rv  <module>r_	     s    6 -    T  T  T  T  T  T  T  T  T  T  T  * 0 - - . ' & . 1 ) . ) * 5 - ) , + . * ) + ( 3 4 %MR
h MR
rx  