
    E#i?
                    8   S SK Jr  S SKJ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.J/r/J0r0  S SK1J2r2  S SK3J4r4  S SK3J5r5  S SK3J6r6  S S	K3J7r7  S S
K3J8r8  S SK3J9r9  S SK3J:r:  S SK3J;r;  S SK3J<r<  S SK3J=r=  S SK3J>r>  S SK3J?r?  S SK3J@r@  S SK3JArA  S SK3JBrB  S SK3JCrC  S SK3JDrD  S SK3JErE  S SK3JFrF  S SK3JGrG  S SK3JHrH  S SK3JIrI  S SK3JJrJ  S SKKJLrL  S SKKJMrM  S SKNJOrO   " S  S!\\5      rPg)"    )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/datarL   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)r@  rA  )r$  r#  r(  r'  r@  rA  r:  rC  zalgo/spot/orderzalgo/futures/orderz.sub-account/subAccountApi/ipRestriction/ipList)getpostputdelete)r8  r3  r4  r5  r+  r-  r.  r/  zloan/flexible/loanable/datazloan/flexible/collateral/datar;  )rD  r6  zloan/flexible/borrowrE  rF  )rG  rH  zsub-account/assetszasset/getUserAssetrG  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   )rl  rn  batchOrderscountdownCancelAllleverage
marginTypepositionMargin	listenKey)r  rn  r  )rn  allOpenOrdersr  r  rd  )	ra  rc  	indexInfo
assetIndexrb  apiTradingStatus	lvtKlinesr0  insuranceBalance)re  rf  rg  rh  ri  takerlongshortRatiork  rateLimit/orderr  multiAssetsMarginzapiReferral/traderNumzapiReferral/overviewzapiReferral/tradeVolzapiReferral/rebateVolzapiReferral/traderSummaryr  r{  r~  r  r|  r}  )feeBurnsymbolConfigaccountConfigr1  	algoOrderopenAlgoOrdersallAlgoOrdersr  r  r  
order/testr  r  r  r     r  )r  rn  r  r  r  algoOpenOrdersr   )rs  rr  rt  )rK  rL  rM  indextickermarkrN  rX  rS  rT  exerciseHistoryrc  positionhistoryOrdersexerciseRecordbillmarginAccountmmpzblock/order/ordersblock/order/executezblock/user-tradesblockTrades)	rn  r  r  mmpSetmmpResetr  countdownCancelAllHeartBeatblock/order/creater  )r  r  )rn  r  r  allOpenOrdersByUnderlyingr  r  g?i  g?   g?)rK  rL  rN  rS  rU  rT  rX  uiKlinesr^  r  zticker/tradingDayr`  ra  rM  avgPrice)rG  rI  rH  rJ  g333333?   )allOrderListopenOrderList	orderListrn  rp  rq  rs  myTradesr  myPreventedMatchesmyAllocationszaccount/commission)	z	order/ocozorderList/ocozorderList/otozorderList/otoco	sor/orderzsor/order/testrn  zorder/cancelReplacer  )rp  r  rn  )rG  rH  rJ  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=  triggerrI  rM  )r=  r  rN  rI  rM  )r=  r  rK  rL  rN  rI  rM  )r=  r  rK  daysBackCanceledrL  rN  rI  rM  r  )
r   r   ro   rp   r   r   r   r   r   r   )r  lastr  )r=  r>  r?  rA  rB  rC  rD  rE  rH  rI  icebergr  rG  rF  max   )r=  rK  r  rL  rM  Z     )	r   ro   rp   r   r   r   r   r   r   extendsforDerivatives)r  r  )rY   rW  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)
rZ  -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-4408r`  ra  rb  rc  rd  re  rf  rg  rh  ri  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]   portfolioMarginrY  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    F/home/james-whalen/.local/lib/python3.13/site-packages/ccxt/binance.pyrp  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   rs  rx  ry  s      ru  
is_inversebinance.is_inverse[
  s    ?:%&i''rw  c                 4    Uc  US:H  =(       d    US:H  $ US:H  $ )Nr\   r[   r  r{  r|  s      ru  	is_linearbinance.is_lineara
  s&    ?8#88h&&rw  enablec                 H   > [         [        U ]  U5        XR                  S'   g )Nr  )ro  rK   set_sandbox_moder  )rs  r  rt  s     ru  r  binance.set_sandbox_modeg
  s    gt-f5&,]#rw  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activerx  r]   r  r  rY   Fr[   r\   TrZ   contractcontractSizeCcallrI  )amountpriceminrR  )r  r  r)  )	expiryexpiryDatetime
optionTypestrikesettlesettleIdr  limitsinfo)splitfindsafe_stringsafe_integerconvert_expire_date	parse8601)rs  r  r  optionParts
symbolBaser  r  r  strikeAsStringr  datetime	timestamps               ru  create_expired_option_market$binance.create_expired_option_marketk
  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+
 +	
rw  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   )rs  r  r  r  isLegacyLinearisLegacyInverseisLegacyr  r  futuresSymbolr  ir  r  s                 ru  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Krw  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  ro  rK   safe_market)rs  r  r  r  r  isOptionrt  s         ru  r  binance.safe_market
  sh    D(hd0Cb0H/ghmm\`NadfNfX););;44X>>Wd/)XXrw  c                     U R                  U[        U R                  U   S   S   U R                  U R                  5      $ )Nr  r  )decimal_to_precisionrG   r  r  paddingMode)rs  r  r)  s      ru  cost_to_precisionbinance.cost_to_precision
  sK    ((xf9Mk9Z[b9ceiewewy}  zJ  zJ  K  	Krw  c                 B    U R                  5       U R                  S   -
  $ )Nr  )millisecondsr  )rs  s    ru  noncebinance.nonce
  s       "T\\2B%CCCrw  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  )rs  r  newUrlss      ru  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()rw  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      nO9U R                  X55      (       a  U R                  U5      nOU R                  U5      nU R                  US5      $ )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   rx  N
serverTime)safe_string_2r  r  r  handle_sub_type_and_paramsr  fapiPublicGetTimer}  dapiPublicGetTimepublicGetTimer  )rs  paramsr  rx  queryry  responses          ru  
fetch_timebinance.fetch_time
  s     (({MSYZ<		&&)99+tVT>>$((--e4H__T++--e4H))%0H  <88rw  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        U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 R,                  U R                  U%S"5      S#.X'   GM     U
$ )$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  withdrawInternalMinr3  withdrawMinwithdrawMaxr  depositDustr   deposit)	r  rO   r  r  r  r   feer  r  r  fiatcryptoisBorrowable)rO   rP   r  rx  r  r  r  r  r   r.  r  r  r  rZ   )	safe_boolr  check_required_credentials
safe_valuer   sapiGetCapitalConfigGetallappendsapiGetMarginAllPairsindex_byr  r  r  safe_currency_code	safe_listnetwork_id_to_codesafe_numberrI   	string_eq
string_min	omit_zerorq  	safe_dictr  )&rs  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&                                         ru  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>?$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 rw  c                    / 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   U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 R-                  USS/ 5      nU R/                  UU5      nM     U R                  S   (       a  U R1                  5         / n[        S
[        U5      5       H&  nUR                  U R3                  UU   5      5        M(     U$ )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  listr  keyssafe_list_2array_concatload_time_differenceparse_market)rs  r  promisesRawrawFetchMarketsdefaultTypesfetchMarketsOptionsr  r  demoMode	isDemoEnvr   r  rx  r  r  r  r  reskeysListlengthresultMarketsr  s                         ru  fetch_marketsbinance.fetch_markets  sv    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 - /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 (rw  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  rx  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  maxNotionalrR  )r  r  safe_string_lowerr  safe_integer_2r  r  r  r  yymmddnumber_to_stringparse_to_numericsafe_number_2rq  r  r  r  r  r   r  iso8601parse_precisionr  r  safe_dict_2))rs  r  r[   r\   r]   r9  rO   r  
optionBaserM  r  r  r  r  r<  r  r  r  r  rY   rA  filtersByTyperC  r  r  r  r  r  r  feesTyper  rI  r  rK  rN  hasCrossMarginhasIsolatedMarginunifiedTypeparsedStriker  filters)                                            ru  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*rw  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)rs  r  rI   
string_add)rs  r  rs  r|  r~  s        ru  parse_balance_helperbinance.parse_balance_helper  sv    ,,.**5(;**5&9##E:6z2!,,T<rw  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  rL  rZ   r  r   assetr  umWalletBalancer{  umUnrealizedPNLrz  r  cmWalletBalancecmUnrealizedPNLcrossMarginBorrowedcrossMarginInterestr~  crossMarginFreecrossMarginLockedcrossMarginAssettotaltotalWalletBalancerY   
updateTimebalances
userAssetsry  r}  r|  assetsr  r:  r;  savingspositionAmountVosr  r  freezewithdrawingavailableBalanceinitialMarginmarginBalancerr  r  r  )r  r  rs  r  r  rI   r  r  r(  r  safe_symbolr  r  safe_balancer  r&  r  rl  )%rs  r  rx  r=  isPortfolioMarginr  r  rL  r  r  r  rs  
currencyIdr  r}  r|  
usedLinearusedInverse	totalUsedr  r  rr  r~  r  r  r  r  r  r  baseCode	quoteCode	subResultr  usedAndTotalfrozenr  ry  s%                                        ru  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'@@rw  c                     U R                  5         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  aU  U R                  X45      (       a  S	nOU R                  X45      (       a  S
nSnU R                  U R                  X5      5      nGOU R                  X45      (       aX  S	nSn
U R                  USSS5      u  pU R                  X5      nU
(       d  U R                  U5      nGOU R                  U5      nGOU R                  X45      (       a$  S
nU R                  U R                  X5      5      nGOTU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      nOUS:X  d  US:X  a!  U R/                  U R                  X5      5      nOnUS:X  a!  U R1                  U R                  X5      5      nOGUS:X  a!  U R3                  U R                  X5      5      nO U R5                  U R                  X5      5      nU R7                  XXe5      $ )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>`
r   r  rY   rx  Nr  rl  Fr  r  TuseV2rL  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  )rs  r  r  rx  ry  r  r=  r  r  requestr  paramSymbolsr  r  r  rO   s                   ru  fetch_balancebinance.fetch_balance3  s   * 	((~}V\]<99.$PVW $($C$CFN\bduw|$}!
 >>~vV
		%(~~d,,//  $**4;;w+FGH^^D**DE 99&.RY[`aME[[0F77?77?__T++D11$++g2MNH:%>>&)<LIIeY/E'lD11"nn\!_=G"1c,&78!-!^^F338+ 9
 +G%,	"88W9TUHhJ'$900W1LMHY66t{{77RSHY88W9TUH--dkk'.IJHj ((WWrw  r  c                    U R                  5         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      nOvUS   (       a!  U R	                  U R                  XS5      5      nOKUS   (       a!  U R                  U R                  XS5      5      nO U R                  U R                  XS5      5      nU R                  US5      nU R                  XaU5      nU R                  US	S
5      US'   U$ )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
r  rO   Nr  r]   r  r  TlastUpdateIdur  )
r  r  eapiPublicGetDepthr  fapiPublicGetDepthdapiPublicGetDepthpublicGetDepthr  parse_order_bookrg  )	rs  r  r  r  r  r  r  r  	orderbooks	            ru  fetch_order_bookbinance.fetch_order_book5  s    	V$fTl
 $G(..t{{7/KLHH..t{{7/KLHI..t{{7/KLH**4;;w+GHHJ %%h4	))(IF	!00>3O	'rw  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	closeTimerL  r  bidQtyrY   r  	lastPriceweightedAvgPrice
baseVolumevolumequoteVolumer  r  r  high	highPricelowlowPricebidbidPrice	bidVolumeaskaskPrice	askVolumeaskQtyvwapopen	openPricecloserP  previousCloseprevClosePricechangepriceChanger  priceChangePercentaverage	markPrice
indexPrice)r  r  r  r  r  )rg  r  r  rI   
string_mulr  safe_tickerrl  )rs  r  r  r  r  r  r  rP  wAvgisCoinmr  r  s               ru  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<@-!
. / 	rw  c                 ~    U R                  U5      nU R                  US5      nU R                  SSS.X35      SSSUS.$ )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>`
rC  okmaintenance)r  rG  N)rC  updatedetar  r  )sapiGetSystemStatusr  )rs  r  r  	statusRaws       ru  fetch_statusbinance.fetch_status4  sS     ++F3 $$Xx8	&&T'F	]
 	
rw  c                    U R                  5         U R                  U5      nSUS   0nSnUS   (       a!  U R                  U R                  XB5      5      nOUS   (       a!  U R	                  U R                  XB5      5      nOUS   (       a!  U R                  U R                  XB5      5      nOmU R                  USS5      nU R                  US5      nU(       a!  U R                  U R                  XB5      5      nO U R                  U R                  XB5      5      n[        U[        5      (       a$  U R                  US	0 5      nU R                  Xs5      $ U R                  XS5      $ )
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>`
r  rO   Nr]   r  r  rollingFr   )r  r  eapiPublicGetTickerr  fapiPublicGetTicker24hrdapiPublicGetTicker24hrr  r  publicGetTickerpublicGetTicker24hrr  r&  r  r  )rs  r  r  r  r  r  r  firstTickers           ru  fetch_tickerbinance.fetch_tickerM  s0    	V$fTl
 (//G0LMHH33DKK4PQHI33DKK4PQHnnVY>GYYvy1F//G0LM33DKK4PQh%%..1b9K$$[99  22rw  r  c                 f   U R                  5         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      nOU R                  XE5      (       a  U R                  U5      nOmUS:X  aI  0 nUb#  U R                  U R                  U5      5      US'   U R                  U R                  Xr5      5      nO[        U R                  S-   U-   S-   5      eU R                  Xa5      $ )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)rs  r  r  r  rx  ry  r  r  s           ru  fetch_bids_asksbinance.fetch_bids_askst  s&    	%%gtT4F--g699/6Z99/6Z>>$((99&AH__T++99&AHV^G"%)YYtw/G%H	"55dkk'6RSHtww)MMPTTWeeff!!(44rw  c                    U R                  5         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      nO^U R                  XE5      (       a  U R                  U5      nO6US:X  a  U R                  U5      nO[        U R                  S-   U-   S-   5      eU R                  Xa5      $ )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rs  r  r  r  rx  ry  r  s          ru  fetch_last_pricesbinance.fetch_last_prices  s     	%%gtT4F--g699:KV\99:KV\>>$((66v>H __T++44V<H V^008H tww)OORVVYgghh%%h88rw  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.$ )NrL  rY   r[   r  r  )r  r  r  r  rO  r  )r  r  r  rl  safe_number_omit_zero)rs  r  r  r  rx  r  s         ru  parse_last_pricebinance.parse_last_price  s    6 %%eV4	#+v&##E84!!(D$?X&"Y///w?
 	
rw  c                    U R                  5         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      nGO>U R                  XE5      (       a  U R                  U5      nGOUS:X  a  U R                  USS5      nU R                  US5      nU(       ad  U R                  U5      nSU R                  U R                  U5      5      0nU R                  U R                  X5      5      nU R                  Xa5      $ 0 nUb#  U R                  U R                  U5      5      US'   U R!                  U R                  X5      5      nO6US:X  a  U R#                  U5      nO[%        U R&                  S	-   U-   S
-   5      eU R)                  Xa5      $ )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  )	rs  r  r  r  rx  ry  r  r  r  s	            ru  fetch_tickersbinance.fetch_tickers  s    	%%gtT4F--g699.&Y99.&Y>>$((33F;H__T++33F;HV^nnVY>GYYvy1F--g6tyy)AB!  //G0LM55hHH "&)-4??73K)LGI&33DKK4PQX//7Htww)LLtSVddee!!(44rw  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)rs  r  r  r  r  r  tickerMarketparsedTickers           ru  r  !binance.parse_tickers_for_rolling+  s    q#h-(A''X>H++HdD&IL,,X[9L%1(%;L"NN<( ) ##GXw??rw  c                 \   U R                  5         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      nOUU R                  XE5      (       a!  U R                  U R                  Xb5      5      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      $ )
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  )rs  r  r  r  rx  ry  r  r  s           ru  fetch_mark_pricebinance.fetch_mark_price5  s    	V$99:JF\bc99:JF\defTl
 >>$((55dkk'6RSH__T++55dkk'6RSHtww)NNQUUXffggh%%$$T^^Ha%DfMM  22rw  c                    U R                  5         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      nOFU R                  XE5      (       a  U R                  U5      nO[        U R                  S-   U-   S-   5      eU R                  Xa5      $ )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          ru  fetch_mark_pricesbinance.fetch_mark_pricesU  s     	%%gtT4F--g699:KV]cd99:KV]ef>>$((55f=H__T++55f=Htww)OORVVYgghh!!(44rw  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  rS  r&  r   openTimer   r  r  r  r<  r  r  r  r  )r  rg  rk  )rs  ohlcvr  r  volumeIndexs        ru  parse_ohlcvbinance.parse_ohlcvq  s    h ..3"aq*5ua0ua0ua/ua1u8<
 	
rw  r   	timeframesincec           	      8   U R                  5         SnU R                  USSS5      u  peU(       a  U R                  SXXBUS5      $ 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      nGOnU
S:X  aN  US   (       a"  U R                  U R                  X5      5      nGO<U R!                  U R                  X5      5      nGOU
S:X  aL  US   (       a!  U R#                  U R                  X5      5      nOU R%                  U R                  X5      5      nOU
S:X  aL  US   (       a!  U R'                  U R                  X5      5      nOU R)                  U R                  X5      5      nOvUS   (       a!  U R+                  U R                  X5      5      nOKUS   (       a!  U R-                  U R                  X5      5      nO U R/                  U R                  X5      5      nU R1                  UXrX45      nU$ )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
Fr   paginaterQ  rP  rU  r  untilN)intervalr  rO   r  _r   pairr  	startTimer  r   endTimer]   r  rV  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)rs  r  r3  r4  r  r  r6  r  defaultLimitmaxLimitr  r7  r  r  partsr:  durationr<  nowr  candless                        ru  fetch_ohlcvbinance.fetch_ohlcv  s   2 	88z[`a::<X]jprvww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(//G0LMHf_i <<T[[=YZ<<T[[=YZgi ==dkk'>Z[==dkk'>Z[n$i ??G@\]??G@\]H//G0LMHI//G0LMH++DKK,HIH6 ##HfNrw  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  rL  qqtyquantityr  
isIsolatedMorderListIdisMakerrY   r  misBuyerMakersellbuyrO  isBuyer
commissioncommissionAsset)r)  currencyr  r  
optionSider]   r;  r  	liquidityr  rG  -1)tatradeIdrO   orderIdrx  pr  quoteQtybaseQty)r  r  r  r  rO   rn  rx  rO  takerOrMakerr  r  r)  r  )parse_dust_traderg  r  r  r  safe_bool_2rf  r  rI   r  
safe_traderl  safe_string_n)rs  rS  r  r  r  r  isSpotTrader  r  rO  
buyerMakerro  r  r  s                 ru  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 
  	rw  c                    U R                  5         SnU R                  USS5      u  pTU(       a  U R                  SXX45      $ 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      nOUS   (       d  U	S:X  a!  U R                  U R                  Xt5      5      nOQUS   (       d  U	S:X  a!  U R                  U R                  Xt5      5      nO U R!                  U R                  Xt5      5      nU R#                  XX#5      $ )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>`
       Fr   r6  r  rO   r]   Nr;  i6 r<  r7  fetchTradesMethodmethodr[   r\   GetHistoricalTradesr   rP  rQ  r  eapiPublicGetTradesr  fapiPublicGetAggTradesr  dapiPublicGetAggTrades)r  r  fetch_paginated_call_dynamicr  r?  r  r  r  r  r  r  r  r|  r  r}  r~  publicGetAggTradesparse_trades)rs  r  r4  r  r  r6  r  r  r7  rz  isFutureOrSwapisHistoricalEndpointmaxLimitForContractHistoricalr  s                 ru  fetch_tradesbinance.fetch_trades(  s   @ 	88PZ[44]FSXaa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)>>//G0LMHH+C!C224;;w3OPHI&,D"D224;;w3OPH..t{{7/KLHF   5@@rw  rO   rO  r  r  c           	      *   U R                  5         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      n
U R                  U
S5      nU R                  X5      $ )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>`
       rY   z" editSpotOrder() does not support rx   ordersnewOrderResponse)r  r  r?   rO   edit_spot_order_requestprivatePostOrderCancelReplacer  parse_order)rs  rO   r  rx  rO  r  r  r  r  payloadr  datas               ru  edit_spot_orderbinance.edit_spot_order  s    " 	V$f~tww)MMPVW]P^^ajjkk..r4vV\]55g>P ~~h(:;--rw  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  rO  MARKETLIMIT_MAKER	stopPricer>  	STOP_LOSSLIMITSTOP_LOSS_LIMITrx  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_LIMITrX  z- editOrder() requires a price argument for a  orderrD  r  z7 editOrder() requires a triggerPrice extra param for a STOP_ON_FAILUREcancelReplaceModecancelNewClientOrderIdcancelOrigClientOrderIdcancelOrderIdr7  )r*  r)  r  r  r  postOnly)r  rs  upperis_post_onlyrk  r  r   r;   rO   r  r  r  uuid22r  r  safe_value_2r  rG   r  ri  rI   r  amount_to_precisionprice_to_precisionr  r  r  )rs  rO   r  rx  rO  r  r  r  r  r  r  initialUppercaseTypeuppercaseTyper  r>  validOrderTypesr+  brokerIdtimeInForceIsRequiredpriceIsRequiredtriggerPriceIsRequiredquantityIsRequiredr*  quoteOrderQtyNewr  amountStringpriceStringquoteOrderQuantitycancelIds                                ru  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++rw  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 rx  r  rO   )r  rO  rk  rX  r  r  r  r  r  )r  r?   rO   r  r  rs  r  r  )rs  rO   r  rx  rO  r  r  r  r  r  r  s              ru  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rw  c           	      r   U R                  5         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   (       aI  U	(       a!  U R                  U R                  X5      5      nOsU R                  U R                  X5      5      nORUS	   (       aH  U	(       a!  U R                  U R                  X5      5      nO U R                  U R                  X5      5      nU R                  X5      $ )
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  rl  Fr  
priceMatchzM editOrder() requires a price argument for portfolio margin and linear ordersr  )r  r  r  r4   rO   r  papiPutUmOrderr  fapiPrivatePutOrderpapiPutCmOrderdapiPrivatePutOrderr  )rs  rO   r  rx  rO  r  r  r  r  r  r  r  s               ru  edit_contract_orderbinance.edit_contract_ordero  s,   & 	V$ $($C$CFL_agiz  }B  %C!(0(>'  3B  )B  C  C222t6Z`a( ..t{{7/KL33DKK4PQI ..t{{7/KL33DKK4PQ8 11rw  c           	          U R                  5         U R                  U5      nUS   (       a!  [        U R                  S-   US   -   S-   5      eUS   (       a  U R	                  XX4XVU5      $ U R                  XX4XVU5      $ )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>`
r]   z editOrder() does not support rx  r  rY   )r  r  r?   rO   r  r  )	rs  rO   r  rx  rO  r  r  r  r  s	            ru  
edit_orderbinance.edit_order  s    " 	V$(tww)IIFSYNZ]ffgg&>''DvVV++BFSYZZrw  ordersc           
         U R                  5         / 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      nOUS   (       a  U R                  U5      nU R!                  U5      $ )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>`
r   r  rO   rx  rO  r  r  r  Nr|   r  rl  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)rs  r  r  ordersRequestsorderSymbolsr  rawOrderr  rO   rx  rO  r  r  orderParamsr  orderRequestr  r  r  s                      ru  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.(55g>HI55g>HF   **rw  rC  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  rs  rC  statusess      ru  parse_order_statusbinance.parse_order_status  s<     &"#)"  )
 &99rw  rn  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  rC  rC  strategyStatusr  positionSidecumQuoter  rY   executedQtyr  )rL  
createTimeworkingTimetransactTimer  r  r  r  r  r  r  origQtyrX  cummulativeQuoteQtycumBaserx  rO  fillsrD  GTXr7  limit_makerr  r  r  r;  )rd  r)  rater  rO   
strategyIdrk  r  newClientStrategyIdr  r  lastTradeTimestamplastUpdateTimestampr  
reduceOnlyr>  r  r)  )r  filled	remainingrC  r  rS  )r  
safe_orderr  r  r  safe_integer_nrg  rI   	string_gtrf  r  rq  r  r  rl  r  )rs  rn  r  r  rC  r  
isContractr  r  r  r  r  timestampValuer  r  r  r  r)  rx  rO  r  rD  r  stopPriceStringr>  feeCostr  s                              ru  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 	rw  c           	      :   U R                  5         / 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      nO-US   (       a  U R                  U5      nOU R                  U5      nU R!                  U5      $ )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>`
r   r  rx  rO  r  r  r  NFTrY   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  )rs  r  r  r  r  r  r  r  rx  rO  r  r  r  r  r  r  r  s                    ru  create_ordersbinance.create_ordersW  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.(66w?HH66w?H66w?HF   **rw  c                 J   U R                  5         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      nGO5U(       a-  U(       a  U R                  U5      nGOU R                  U5      nGOUS   (       aD  U(       a+  U(       a  U R                  U5      nOU R                  U5      nOU R                  U5      nOUS   (       aD  U(       a+  U(       a  U R                  U5      nOU R!                  U5      nOwU R#                  U5      nOeUS:X  d
  U	c  U(       a+  U(       a  U R%                  U5      nO<U R'                  U5      nO*U(       a  U R)                  U5      nOU R+                  U5      nU R-                  UU5      $ )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>`
rx  r=  r  rl  Fr>  r  rA  rB  trailingPercentcallbackRateNsorSORr  )r  r  r  r]   r  r  rZ   )r  r  r  rq  r  r  r  r  r  eapiPrivatePostOrderprivatePostSorOrderTestprivatePostSorOrderpapiPostUmConditionalOrderpapiPostUmOrderfapiPrivatePostOrderpapiPostCmConditionalOrderpapiPostCmOrderdapiPrivatePostOrderpapiPostMarginOrdersapiPostMarginOrderprivatePostOrderTestprivatePostOrderr  )rs  r  rx  rO  r  r  r  r  r  r=  porfolioOptionsValuer  r>  rA  rB  r  isTrailingPercentOrder
isStopLossisTakeProfitisConditionalr  r  r  r  s                           ru  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(009H77@33G<H  #>>wGH#33G<H44W=I  #>>wGH#33G<H44W=8#z'=AR 33G<33G<44W=009&11rw  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
       rx  r  r  r  r  rO   r  Nro   r  rl  Fr  rZ   r  
AUTO_REPAYsideEffectTyper>  r  rA  rB  trailingDeltatrailingTriggerPriceactivationPrice)r  r  r1  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  rL  rY  r  rD  r  r  r  strategyTypere   r*  r)  r  r  z6 createOrder() requires a trailingPercent param for a r  r  rX  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  r7  rE  r`  r_  LONGSHORTr  rH  selfTradePreventionModerJ  
icebergQty)rx  r  r  r  rA  rB  r  r>  r2  r  r*  r)  r  rE  rJ  )r  r  r  r  r  r  r  r  rs  r  r;   rO   rI   r  r  r   r  r  r  r  r  rG   r  ri  r  rj  r  r  r  )?rs  r  rx  rO  r  r  r  r  r  r  r  isMarketOrderisLimitOrderr  r  r=  r  r>  rA  rB  r1  r2  r  r  r(  r)  r*  isTriggerOrderr+  isPortfolioMarginConditionalisPriceMatchpriceRequiredForTrailingr  r  r5  trailingPercentConvertedr  clientOrderIdRequestr+  	defaultIdidMarketTyper  r  typeRequestre   r  r  r  r  r*  r  r  r  r  r  marketAmountPrecisionisPrecisionAvailablerR  isPricePrecisionAvailablerE  rH  rJ  requestParamss?                                                                  ru  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2rw  r)  c                     U R                  5         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      $ )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>`
rY   z6 createMarketOrderWithCost() supports spot orders onlyr)  r  Nr  r  r?   rO   r,  r  )rs  r  rO  r)  r  r  reqs          ru  create_market_order_with_cost%binance.create_market_order_with_cost  sk     	V$f~tww)aabbD
   4tT[[QTE]^^rw  c                     U R                  5         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      $ )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>`
rY   z9 createMarketBuyOrderWithCost() supports spot orders onlyr)  r  r`  NrR  )rs  r  r)  r  r  rS  s         ru  !create_market_buy_order_with_cost)binance.create_market_buy_order_with_cost"  sm     	V$f~tww)ddeeD
   5$dkkRUF^__rw  c                     U R                  5         U R                  U5      nUS   (       d  [        U R                  S-   5      eX#S'   U R	                  USSUSU5      $ )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>`
rY   z: createMarketSellOrderWithCost() supports spot orders onlyr*  r  r_  N)r  r  r?   rO   r,  )rs  r  r)  r  r  s        ru  "create_market_sell_order_with_cost*binance.create_market_sell_order_with_cost6  s]     	V$f~tww)eeff"&  64vNNrw  c                    Uc  [        U R                  S-   5      eU R                  5         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      nGO*US   (       aI  U(       a!  U R                  U R                  X5      5      nOU R                  U R                  X5      5      nOUS   (       aI  U(       a!  U R                  U R                  X5      5      nOU R                  U R                  X5      5      nOUS:X  d
  Uc  U(       aT  U(       a!  U R!                  U R                  X5      5      nOLUS:X  a  SU	S'   U R#                  U R                  X5      5      nO U R%                  U R                  X5      5      nU R'                  X5      $ )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   rx  r  rl  Fr  rO   r  r  r]   rk  )rx  r  r  r  r  rZ   rL  TrY  )r4   rO   r  r  r  r  r  r  r  r  eapiPrivateGetOrderr  papiGetUmOrderfapiPrivateGetOrderpapiGetCmOrderdapiPrivateGetOrderpapiGetMarginOrdersapiGetMarginOrderprivateGetOrderr  )rs  rO   r  r  r  r  rx  r=  r  r  r  r  s               ru  fetch_orderbinance.fetch_orderH  s&   & >#DGG.X$XYYV$((|]TZ[<
!??fU
 $($C$CFLZ`bsuz${!fTl
 **63FX$h+8(/<+,!#I6#QR(//G0LMHH ..t{{7/KL33DKK4PQI ..t{{7/KL33DKK4PQhJ$:?P 224;;w3OP+,0GL)224;;w3OP++DKK,HIH11rw  c                    Uc  [        U R                  S-   5      eU R                  5         SnU R                  USS5      u  pTU(       a  U R	                  SXX45      $ 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      nGOuUS   (       as  U
(       aK  U(       a"  U R!                  U R                  X5      5      nGO;U R#                  U R                  X5      5      nGOU R%                  U R                  X5      5      nOUS   (       aq  U
(       aI  U(       a!  U R'                  U R                  X5      5      nOU R)                  U R                  X5      5      nOU R+                  U R                  X5      5      nO}U
(       a!  U R-                  U R                  X5      5      nOUUS:X  d  U	b,  U	S:X  a  SUS'   U R/                  U R                  X5      5      nO U R1                  U R                  X5      5      nU R3                  XX#5      $ )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   r6  r  rx  r  rl  stoprN  conditional)ri  rN  rj  rx  r  rO   r<  r;  r  r]   r  r  rZ   rL  TrY  )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  )rs  r  r4  r  r  r6  r  r  rx  r=  r  r+  r  r  s                 ru  fetch_ordersbinance.fetch_orders  s   2 >#DGG.Y$YZZ88PZ[44]FSXaaV$((}mU[\bUcd<
!??vV
 $($C$CFM[actv{$|!((1ST6#MNfTl
 229gN#(K $G(77G8TUHH  #AA$++gB^_H#66t{{77STH77G8TUI  #AA$++gB^_H#66t{{77STH77G8TU 66t{{77ST!Z%;+,0GL)66t{{77ST33DKK4PQj   5@@rw  c                    U R                  5         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  a0  Ub  X'S'   Ub  X7S'   U R                  U R                  Xt5      5      nGOU R                  Xm5      (       at  U	(       aK  U
(       a"  U R                  U R                  Xt5      5      nGOjU R!                  U R                  Xt5      5      nGOHU R#                  U R                  Xt5      5      nGO&U R%                  Xm5      (       aq  U	(       aI  U
(       a!  U R'                  U R                  Xt5      5      nOU R)                  U R                  Xt5      5      nOU R+                  U R                  Xt5      5      nOUS:X  d
  Uc  U	(       ao  U	(       a!  U R-                  U R                  Xt5      5      nOgUS:X  a   SUS'   Uc  [/        U R                  S-   5      eU R1                  U R                  Xt5      5      nO U R3                  U R                  Xt5      5      nU R5                  XX#5      $ )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  rl  Frh  rO   r  r  rY   rx  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.rx  ri  rN  rj  r]   r;  r  rZ   rL  TrY  zB fetchOpenOrders() requires a symbol argument for isolated markets)r  r  r  rk  r  r  r  r  r0   rO   r  r  eapiPrivateGetOpenOrdersr  r  papiGetUmConditionalOpenOrderspapiGetUmOpenOrdersfapiPrivateGetOpenOrdersr}  papiGetCmConditionalOpenOrderspapiGetCmOpenOrdersdapiPrivateGetOpenOrderspapiGetMarginOpenOrdersr4   sapiGetMarginOpenOrdersprivateGetOpenOrdersr  )rs  r  r4  r  r  r  rx  r  r=  r  r+  r  r  ry  r  s                  ru  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4T[[5QRH^^D**  #BB4;;wC_`H#77G8TUH88W9UV__T++  #BB4;;wC_`H#77G8TUH88W9UVX!7;L 77G8TU+,0GL)~/:~0~77G8TU00W1MNH  5@@rw  c                    Uc  [        U R                  S-   5      eU R                  5         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   (       ar  U(       aJ  U(       a"  U R                  U R                  XS5      5      n
GOU R                  U R                  XS5      5      n
OU R                  U R                  XS5      5      n
OUS   (       aq  U(       aI  U(       a!  U R                  U R                  XS5      5      n
OU R                  U R                  XS5      5      n
OeU R                  U R                  XS5      5      n
ODUS   (       a  [        U R                  S-   5      eUS   (       a  [        U R                  S-   5      eU R                  X5      $ )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  rl  Frh  r  rk  r  r  r]   z1 fetchOpenOrder() does not support option marketsrY   z/ fetchOpenOrder() does not support spot markets)r4   rO   r  r  r  rk  r  papiGetUmConditionalOpenOrderr  papiGetUmOpenOrderfapiPrivateGetOpenOrderpapiGetCmConditionalOpenOrderpapiGetCmOpenOrderdapiPrivateGetOpenOrderr?   r  )rs  rO   r  r  r  r  r  r+  rD  orderIdRequestr  s              ru  fetch_open_orderbinance.fetch_open_order  s   $ >#DGG.\$\]]V$fTl
 !$($C$CFL\^dfwy~$!((1ST6#EF(9(Km$)E9"$(  #AA$++gB^_H#66t{{77STH77G8TUI  #AA$++gB^_H#66t{{77STH77G8TUh"477-`#`aa"477-^#^__j 11rw  c                     Uc  [        U R                  S-   5      eU R                  XSU5      nU R                  USS5      nU R	                  XbU5      $ )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 argumentrC  r  r4   rO   rw  	filter_byfilter_by_since_limitrs  r  r4  r  r  r  filteredOrderss          ru  fetch_closed_ordersbinance.fetch_closed_orders  sW    . >#DGG._$_``""6$?(C)).GGrw  c                     Uc  [        U R                  S-   5      eU R                  XSU5      nU R                  USS5      nU R	                  XbU5      $ )  
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 argumentrC  r  r  r  s          ru  fetch_canceled_ordersbinance.fetch_canceled_orders  sW    . >#DGG.a$abb""6$?*E)).GGrw  c                    Uc  [        U R                  S-   5      eU R                  XSU5      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      $ )r  Nz: fetchCanceledAndClosedOrders() requires a symbol argumentrC  r  r  r  )r4   rO   rw  r  r)  sort_byr  )
rs  r  r4  r  r  r  canceledOrdersclosedOrdersr  sortedOrderss
             ru   fetch_canceled_and_closed_orders(binance.fetch_canceled_and_closed_orders  s    . >#DGG.j$jkk""6$?*E~~fhA**>H||NK@)),uEErw  c                    Uc  [        U R                  S-   5      eU R                  5         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      nGO|US   (       as  U(       aK  U	(       a"  U R                  U R                  X5      5      nGOBU R                  U R                  X5      5      nGO U R!                  U R                  X5      5      nOUS   (       aq  U(       aI  U	(       a!  U R#                  U R                  X5      5      nOU R%                  U R                  X5      5      nOU R'                  U R                  X5      5      nOUS:X  d
  Uc  U(       aT  U(       a!  U R)                  U R                  X5      5      nOLUS:X  a  SU
S'   U R+                  U R                  X5      5      nO U R-                  U R                  X5      5      nU R/                  X5      $ )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   rx  r  rl  Frh  r  rO   )r  r  r   r]   r  r   r  r  rk  )rx  r  r  r   ri  rN  rj  r  r  rZ   rL  TrY  )r4   rO   r  r  r  r  r  r  r  rk  rs  r  eapiPrivateDeleteOrderr  papiDeleteUmConditionalOrderpapiDeleteUmOrderfapiPrivateDeleteOrderpapiDeleteCmConditionalOrderpapiDeleteCmOrderdapiPrivateDeleteOrderpapiDeleteMarginOrdersapiDeleteMarginOrderprivateDeleteOrderr  )rs  rO   r  r  r  r  rx  r=  r  r+  r  r  r  s                ru  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(224;;w3OPHH  #@@WA]^H#55dkk'6RSH66t{{77STI  #@@WA]^H#55dkk'6RSH66t{{77SThJ$:?P 55dkk'6RS+,0GL)55dkk'6RS..t{{7/KLH11rw  c                 *   Uc  [        U R                  S-   5      eU R                  5         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      n	GO|US   (       as  U(       aK  U(       a"  U R                  U R                  XB5      5      n	GOBU R                  U R                  XB5      5      n	GO U R                  U R                  XB5      5      n	OUS   (       aq  U(       aI  U(       a!  U R                  U R                  XB5      5      n	OU R                  U R                  XB5      5      n	OU R!                  U R                  XB5      5      n	OUS:X  d
  Uc  U(       aT  U(       a!  U R#                  U R                  XB5      5      n	OLUS:X  a  SUS'   U R%                  U R                  XB5      5      n	O U R'                  U R                  XB5      5      n	[)        U	[*        5      (       a  U R-                  X5      $ U R/                  SU	05      /$ )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  rl  Frh  rx  rz  r]   r  r  rZ   rL  TrY  r  )r4   rO   r  r  r  rk  r  r  r  eapiPrivateDeleteAllOpenOrdersr  $papiDeleteUmConditionalAllOpenOrderspapiDeleteUmAllOpenOrdersfapiPrivateDeleteAllOpenOrders$papiDeleteCmConditionalAllOpenOrderspapiDeleteCmAllOpenOrdersdapiPrivateDeleteAllOpenOrderspapiDeleteMarginAllOpenOrderssapiDeleteMarginOpenOrdersprivateDeleteOpenOrdersr  r&  r  r  )
rs  r  r  r  r  r  r+  rx  r=  r  s
             ru  cancel_all_ordersbinance.cancel_all_ordersV  sg   , >#DGG.]$]^^V$fTl
 !$($C$CFL]_egxz  %A!((1STv?6#MN
!??@QSYZ
(::4;;w;WXH H  #HHU\IefH  $==dkk'>Z[H  >>t{{7?[\ I  #HHU\IefH  $==dkk'>Z[H  >>t{{7?[\ hJ$:?P ==dkk'>Z[+,0GL)::4;;w;WX0 33DKK4PQH, h%%$$X66 H!  rw  idsc                     Uc  [        U R                  S-   5      eU R                  5         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      nO*US   (       a   U R                  U R                  XS5      5      nU R                  Xt5      $ )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  )rs  r  r  r  r  r  r  r  s           ru  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"(88W9UVHI88W9UVHH   22rw  c           	      P   Uc  [        U R                  S-   5      eU R                  5         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      $ )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>`
z. fetchOrderTrades() requires a symbol argumentrx  rY   z. fetchOrderTrades() supports spot markets onlyrk  )	r4   rO   r  r  r  r  r?   fetch_my_tradesr  )	rs  rO   r  r4  r  r  r  rx  r  s	            ru  fetch_order_tradesbinance.fetch_order_trades?  s      >#DGG.^$^__V$v?66*6>tww)YYZZr
 ##F5++g:VWWrw  c                    U R                  5         SnU R                  USS5      u  pTU(       a  U R                  SXX45      $ 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      nGOwU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      nOUS:X  d  U	b,  U	S:X  a  SUS'   U R#                  U R                  Xd5      5      nOU R%                  U R                  Xd5      5      nOUS   (       aI  U(       a!  U R'                  U R                  Xd5      5      nOsU R)                  U R                  Xd5      5      nORUS   (       aH  U(       a!  U R+                  U R                  Xd5      5      nO U R-                  U R                  Xd5      5      nU R/                  XX#5      $ )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>`
Fr   r6  NrO   r  r7  r<  r;  i $r  r]   r  rQ  r  z+ fetchMyTrades() requires a symbol argumentr  rl  rY   rZ   rL  TrY  r  )r  r  r  r  r  rg  r  r?  r  r  eapiPrivateGetUserTradesr  r4   rO   r  r  papiGetMarginMyTradessapiGetMarginMyTradesprivateGetMyTradespapiGetUmUserTradesfapiPrivateGetUserTradespapiGetCmUserTradesdapiPrivateGetUserTradesr  )rs  r  r4  r  r  r6  r  r  rx  r=  r<  r;  currentTimestamponeWeekr  r  s                   ru  r  binance.fetch_my_trades\  s   * 	88R\]44_fUZcc
[[(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4T[[5QRH~'2_(_``!%!C!COU[!\J $(,(G(GP_agiz  }B  )C%v~!1$#99$++g:VWHh&J,B!Z/04-#99$++g:VWH#66t{{77STH!$#77G8TUH#<<T[[=YZH	"$#77G8TUH#<<T[[=YZHD   5@@rw  c                 J   U R                  5         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      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      $ )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<  rx  accountTypeuserAssetDribbletsr  r   userAssetDribbletDetailsTrU  )r  r?  safe_string_upperr  sapiGetAssetDribbletr  r  r  r  r  r  r  r  )rs  r  r4  r  r  r  r  r  r  rowsr  r  logsr  rS  s                  ru  fetch_my_dust_tradesbinance.fetch_my_dust_trades1  s,   & 	#(K !%%!<GI,,VV<66*"%0M",,T[[-IJ< ..+?D  7A6q$A>>'*.H"MD1c$i()-&DG$ )  
 ""4u<))&??rw  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rd  r)  transferedAmountr  r`  r_  )rO   r  r  r  rn  rx  ro  rO  r  r  r)  r  r  )	r  r  r  rd  r  rq  rI   
string_divrl  )rs  rS  r  rk  r  r  tradedCurrencybnbearnedCurrencyapplicantSymboltradedCurrencyIsQuotefeeCostStringr  r  r  
costStringrO  r  rO   r  r  r)  rx  ro  s                           ru  rp  binance.parse_dust_tradev  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/(
 	
rw  r  c                 p   U R                  5         SnU R                  USS5      u  pTU(       a  U R                  SXX45      $ 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;   a[  Ub  U R                  U5      nS	US
'   Ub  X(S'   Ub  XS'   U R                  U R                  X5      5      nU R                  US/ 5      nOnU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      n[        S	[!        U5      5       H
  nSX~   S'   M     U R#                  XvX#5      $ )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>`
Fr   r6  Nr1  r  fiatOnlyr7  r   transactionType	beginTimer<  r  rO   r  r;  r  r  r  rx  )r  r  r  r  r  r  r  r  rd  sapiGetFiatOrdersr  r  r?  r  sapiGetCapitalDepositHisrecr  r  parse_transactions)rs  r  r4  r  r  r6  rd  r  r  r1  r  r7  rawr<  r  s                  ru  fetch_depositsbinance.fetch_deposits  s     	88R\]44_dSXaa^^DLL,C
>>&&%86:.!!&'267+*==.)*G%& ',$ %*	"((W)EFC~~c626H* ==."*4. ',$((5*5$!'1G%,	" #( 77G8TUH6 q#h-(A"+HK )&&x5HHrw  c                 R   U R                  5         SnU R                  USS5      u  pTU(       a  U R                  SXX45      $ 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;   aT  Ub  U R                  U5      nS
US'   Ub  X(S'   U R                  U R                  X5      5      nU R                  US/ 5      n
O_U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      n
[        S[        U
5      5       H
  nSX   S'   M     U R!                  XX#5      $ )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>`
Fr   r6  r1  r  r  r7  Nr<  r   r  r  r  rO   r  r;  r  r  r   
withdrawalrx  )r  r  r  r  r  r  r  r  rd  r  r  r  r?  sapiGetCapitalWithdrawHistoryr  r  r  )rs  r  r4  r  r  r6  r1  r  r  r7  r  rd  r  r  s                 ru  fetch_withdrawalsbinance.fetch_withdrawals  s     	88ASU_`445GV[dd^^DLL,C
>>&&%86:.!!&'2YYvw/F!&I*==.)*G%& ',$((W)EFC~~c626H@ ==."*4. ',$%)XXeZ%@	" #( 99$++g:VWHP q#h-(A".HK )&&x5HHrw  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  rG  6
ProcessingFailed
Successful	RefundingRefundedRefund Failed)r  rG  2345r  r  r  r  r  r	  r
  )r  r  )r  r  )rs  rC  rx  statusesByTyper  s        ru   parse_transaction_status_by_type(binance.parse_transaction_status_by_type  s    <M  (""'&!)  (""'&!) 
@ >>.;&99rw  transactionrd  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  rx  r  r  r  r  r2  rC  r  transactionFeetotalFeer  transferTypeTFr  r  txidr  r  	addressToaddressFromtagtagTotagFromrd  r  )internalcommentr  )r  r  r  r  r  rg  r  r  r  r  r  rk  r  rl  )rs  r  rd  rO   r  r#  r   r  r  r  r  rx  txTyper2  rC  r  r  r  internalIntegerr&  r  s                        ru  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#
$ !)
 	
rw  c                 .    SS0nU R                  X!U5      $ )N	CONFIRMEDr  r  r  s      ru  parse_transfer_statusbinance.parse_transfer_status:   s#    
 &99rw  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  rd  r  rx  r-  r9  r   r   
walletType	payerInforeceiverInfo	accountIdr  transactionTimerC  )	r  rO   r  r  rd  r  fromAccount	toAccountrC  )r  r  r  r  r  r  r  r  r  rg  r.  rl  )rs  r   rd  rO   r  r  r  rx  r8  r9  r-  rM  r3  payerreceiverr  rC  s                    ru  parse_transferbinance.parse_transfer@   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/&"

 
	
rw  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  rL  r[   r1  rv  )r  r  r  r  r  rO   r  )r  r  r  r  rl  r  )rs  rv  r  r  r  r  s         ru  parse_incomebinance.parse_income   s     ##FH5%%fg6
%%ff5	&&xvF++J7"Y/""684&&vx8
 	
rw  r8  r9  c                    U R                  5         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      nU R                  UU5      $ )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>`
rO   r  r  rx  Nr  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ISOLATEDMARGINr9  )r  rd  currency_to_precisionr  r  r  convert_type_to_accountr  r4   rO   r  r  r5   sapiPostAssetTransferr  r<  )rs  r  r  r8  r9  r  rd  r  r  r  fromIdtoIdisolatedSymbolr-  fromIsolated
toIsolated
fromFuturetoFuturefromSpottoSpotr  r]   prohibitedWithIsolatedr  s                           ru  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--dkk'.JK ""8X66rw  c                    U R                  5         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      $ 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      nO U R%                  U R#                  X5      5      nU R'                  USS/ 5      nU R)                  UXrU5      $ )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>`
r&  Fr   r6  Nr  r  rY   r8  r\   r9  rx  r,  z& fromAccount parameter must be one of z, z$ toAccount parameter must be one of r9  sizer;  r7  r<  r  r  )r  r  r  r  r  rd  r  r  r  r  r&  r'  r0   rO   joinr  sapiGetPayTransactionsr  sapiGetAssetTransferr(  parse_transfers)rs  r  r4  r  r  r&  r6  rd  r  limitKeyr  r8  	defaultTor9  rx  r,  rK  rL  r'  r7  r  r  s                         ru  fetch_transfersbinance.fetch_transfers!  s    	>>&*56:.88AQS]^H445EtTYbb}}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224;;w3OPHv 00W1MNH  &&"=##D(5AArw  c                 h   U R                  5         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      nU R                  Xs5      $ )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>`
r  rO   r.  r  )
r  rd  r  r  r  r  r  sapiGetCapitalDepositAddressr  parse_deposit_address)rs  r  r  rd  r  r.  r  r  s           ru  fetch_deposit_addressbinance.fetch_deposit_address!  s     	==&HTN
 >>$,,
B?((;""8g>!(IYYvy1F44T[[5QR ))(==rw  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  rd  r#  r  r   )r  rd  r  r  r#  )r  r  get_network_code_by_network_urlr  check_address)	rs  r  rd  r  r  r  r  r  r#  s	            ru  rb  binance.parse_deposit_address!  s     x/""8Y7%%h
;
&&z< ::4Ex3s8q=C7#"
 	
rw  codesc                    U R                  5         U R                  U5      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.$ )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>`
       r   r  r  r  r  )r   r  r  )r  r  r  r  r  r  r  r  )rs  ri  r  r  withdrawFeesr  r  r  r  r  r  networkEntry	networkIdr  r  s                  ru  fetch_transaction_feesbinance.fetch_transaction_fees!  s     	226:d  q#h-(AKE))%8J**:6D..rBK!#L1c+./*~ ,,\9E	"55i@&&|]C25T";/ 0 ) %
 	
rw  c                 h    U R                  5         U R                  U5      nU R                  X1S5      $ )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>`
r  )r  r  parse_deposit_withdraw_fees)rs  ri  r  r  s       ru  fetch_deposit_withdraw_fees#binance.fetch_deposit_withdraw_feesQ"  s6     	226:V //HHrw  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  )rs  r  rd  r  r  r  rl  rm  r  r  r  s              ru  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:{+ ,* rw  r  r#  c                    U R                  XE5      u  pEU R                  U5        U R                  5         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      n
U R                  X5      $ )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>`
rO   )r  r  r  r.  r  r  )handle_withdraw_tag_and_paramsrg  r  rd  r  r  r  r  r  rH  sapiPostCapitalWithdrawApplyr  r*  )rs  r  r  r  r#  r  rd  r  r.  r  r  s              ru  r   binance.withdraw"  s     99#F7#==&TN
 ?$'L!>>$,,
B?((;""8g>!(IYYvy1F 66tWM44T[[5QR%%h99rw  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  rk  )rs  r  r  r  r  s        ru  parse_trading_feebinance.parse_trading_fee"  sh    $ ##C2!!(D&A''->@UV''->@UV
 	
rw  c                    U R                  5         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(       aI  U(       a!  U R                  U R                  X5      5      n
OU R                  U R                  X5      5      n
OpU(       aI  U(       a!  U R                  U R                  X5      5      n
OAU R                  U R                  X5      5      n
O U R                  U R                  X5      5      n
U
n[        U[        5      (       a  U R                  US	0 5      nU R                  X5      $ )
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>`
rx  Nr   r  rl  Fr  rO   r   )r  r  r  r  r  r}  papiGetUmCommissionRater  fapiPrivateGetCommissionRatepapiGetCmCommissionRatedapiPrivateGetCommissionRatesapiGetAssetTradeFeer  r&  r  r  )rs  r  r  r  rx  ry  r  isLinear	isInverser  r  r  s               ru  fetch_trading_feebinance.fetch_trading_fee#  s]     	V$f~99:KV\ $($C$CFL]_egxz  %A!>>$0OOD2	fTl
  77G8TU<<T[[=YZ 77G8TU<<T[[=YZ00W1MNH( dD!!>>$2.D%%d33rw  c                    U R                  5         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      nO1U(       a  U R                  U5      nOU(       a  U R                  U5      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)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  )rs  r  rx  ry  isSpotOrMarginr  r  r  r  r  r  r  r  r  feeTiersr  r  r  s                     ru  fetch_trading_feesbinance.fetch_trading_feesM#  s    	99:LdTZ[99:LdTZ\de&.?dh.>>>$0OOD2	008H77?H11&9Hb  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rw  c                     US:  d  US:  a  [        U R                  S-   5      eU R                  5         U R                  U5      nUS   UUS.nU R	                  U R                  Xd5      5      nU R                  Xu5      $ )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 4rO   )r  r  rx  )r4   rO   r  rd  sapiPostFuturesTransferr  r<  )rs  r  r  rx  r  rd  r  r  s           ru  futures_transferbinance.futures_transfer#  s     1H$(#DGG.M$MNN==&d^

 //G0LM ""866rw  c                 r   U R                  5         U R                  U5      nSUS   0nSnUS   (       a!  U R                  U R                  XB5      5      nOCUS   (       a!  U R	                  U R                  XB5      5      nO[        U R                  S-   5      eUS   (       a  US   nU R                  XS5      $ )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>`
r  rO   Nr  r  z> fetchFundingRate() supports linear and inverse contracts onlyr   )r  r  r&  r  r'  r?   rO   parse_funding_raters  r  r  r  r  r  s         ru  fetch_funding_ratebinance.fetch_funding_rate$  s     	V$fTl
 (55dkk'6RSHI55dkk'6RSHtww)iijj){H &&x88rw  c                 b   U R                  5         0 nSnU R                  USS5      u  pdU(       a  U R                  SXUSU5      $ 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      nOUU R                  X5      (       a!  U R                  U R                  XT5      5      nO[        U R                   S-   U-   S-   5      eU R#                  XX#5      $ )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>`
Fr   r6  r   r  r\   rx  Nr  rO   r  r;  r7  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)rs  r  r4  r  r  r  r6  r  rx  r  ry  r7  r<  r  s                 ru  fetch_funding_rate_history"binance.fetch_funding_rate_history<$  s     	88AZ\fg::;TV\ejlprxyy((7PR_aij<[[(FH%F &tGH99:SU[emn66*#(K !!&'2##FIu=6Iw#78!(I$G>>$((44T[[5QRH__T++44T[[5QRHtww)[[^bbeoopp 005PPrw  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[   rW  )r  r  rW  r  r  )r  r  r  r  rl  )rs  r  r  r  s       ru  parse_funding_rate_history"binance.parse_funding_rate_historyu$  se     %%h>	&&t'7'7('KTSWY_`++HmD"Y/
 	
rw  c                    U R                  5         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      nO@U R                  XE5      (       a  U R                  U5      nO[        U R                  S-   5      eU R                  Xq5      $ )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
r   r  r\   rx  Nr  z? fetchFundingRates() supports linear and inverse contracts only)r  r  r  r  r  r  r  r  r&  r}  r'  r?   rO   parse_funding_rates)rs  r  r  r  rx  ry  r  r  s           ru  fetch_funding_ratesbinance.fetch_funding_rates$  s     	%%g.((7JM[cd<99:MtU[]ef		&&)>>$((55e<H__T++55e<Htww)jjkk''::rw  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$ )NrL  r  r  r  r  interestRateestimatedSettlePricelastFundingRatenextFundingTimefundingIntervalHourshr  r  r  rW  fundingTimestampfundingDatetimenextFundingRatenextFundingTimestampnextFundingDatetimepreviousFundingRatepreviousFundingTimestamppreviousFundingDatetimer8  )r  r  r  r  rl  )rs  r  r  r  r  r  r  r  r  r  rW  r  r8  intervalStrings                 ru  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#
$ %
 	
rw  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  )rs  rs  filterClosedr  r  r  r  r  r  r  r  r  r  r  r  r  maintenanceMarginisPositionOpenparseds                      ru  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&) *  rw  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  rG  r  rQ  1e-8rd  r  
entryPricenotionalValuepositionAmtr  z0.5r   leverageBracketsr   unrealizedProfitr  rL  isolatedMarginr  isolatedWalletr  r  r  shortlong5e-5r  r8  rg  r  r  z5e-r  r  BOTHr  rO   r  r  initialMarginPercentager  maintenanceMarginPercentageunrealizedPnl	contractsmarginRatioliquidationPrice)r  
collateralr=  rO  rE  r  )r  r  intrq  rI   r  is_round_numberr  r  
string_absr  r  r  r  r  r  	string_ltr  r  r  r  ri  string_equals
string_subprecision_from_stringr  rl  )<rs  r  r  r  r  leverageStringr  initialMarginStringr  initialMarginPercentageStringrationalusdmmaintenanceMarginStringr  entryPriceStringr  notionalStringnotionalStringAbsrd  contractsStringcontractsStringAbsentryNotionalcontractSizeNewr  r  rw  !maintenanceMarginPercentageStringr  bracketr  unrealizedPnlStringr  r  rL  isolatedMarginRawr=  collateralStringwalletBalancer  r  rO  r  liquidationPriceStringRawr  r  contractSizeString(onePlusMaintenanceMarginPercentageStringentryPriceSignStringleftSide	rightSiderW  rR  pricePrecisionPlusOnepricePrecisionPlusOneStringrounderrounderStringliquidationPriceRoundedStringtruncatedLiquidationPricer  rE  s<                                                               ru  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#
$ $$$/
 	
rw  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  rd  r  r   r   r  unRealizedProfitr  r  r  r  rL  r  r  r  r  r  r  r  r  rG  rg  r  r  r  r  rQ  r  r  r  r  r  r8  r  r  r  rO   r  r  r  r  r  r  r  )	r  r  r=  r  rO  rE  r  rA  rB  )r  r  r  r  r  r  rI   r  r  r  r  rq  r  r  r  r  ri  r  r  r  r  r  r  r  r  r  rl  )7rs  r  r  r  r  isolatedMarginStringr  rw  r  r  r  r  r  rd  contractsAbsr  r  r  liquidationPriceStringr  r  r=  rO  r  r  r  r  r  r  basePrecisionValuequotePrecisionValueprecisionIsUndefinedr  r  innerr  rU  r  basePrecisionr  r  r  r  r  r  r  r  r  r  r  	unroundedr  r  r  rE  s7                                                          ru  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
 	
rw  c                 p   U R                  5         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      n	OkU R                  U5      n	OYU R                  XW5      (       a+  U(       a  U R                  U5      n	O*U R                  U5      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   $ )Nr  r  r\   rx  loadLeverageBracketsr  r  rl  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  )rs  reloadr  r  r  rx  r  ry  r  r  r  r  r  r  r  r  r  r  
floorValuer  s                       ru  load_leverage_bracketsbinance.load_leverage_brackets&  s,     >>$,,8JK$&**4<<QK##FFK@DIIff-EG"==>TVZ\bdlmOG $(,(G(GPfhn  qB  DI  )J%H~~d,,$#<<UCH#AA%HH//$#<<UCH#CCEJH"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 - ||.//rw  c                    U R                  5         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      nOkU R                  U5      nOYU R                  X45      (       a+  U(       a  U R                  U5      nO*U R                  U5      nO[        U R                  S-   5      eU R                  XaS5      $ )	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  rl  Fz@ fetchLeverageTiers() supports linear and inverse contracts onlyr  )r  r  r  r  r  r  r  r}  r  r  r?   rO   parse_leverage_tiers)rs  r  r  rx  ry  r  r  s          ru  fetch_leverage_tiersbinance.fetch_leverage_tiers&  s    	99:NPTV\]99:NPTV\^fg $($C$CFL`bhj{  ~C  %D!>>$(( 88@==fE__T++ 88@??Gtww)kkllN ((HEErw  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  rd  rc  re  maintenanceMarginRatemaxLeverager  )	r  r  r  r  r  r  r  r  rk  )rs  r  r  r  r  r  r  r  s           ru  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	 	 ) rw  c                     U R                  5         U R                  U5      nUS   (       d  [        U R                  S-   5      eSUS   0nU R	                  U R                  XB5      5      nU R                  US   U5      $ )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>`
r]   z- fetchPosition() supports option markets onlyr  rO   r   )r  r  r?   rO   eapiPrivateGetPositionr  parse_positionr  s         ru  fetch_positionbinance.fetch_positione'  s     	V$htww)XXYYfTl
 ..t{{7/KL0 ""8A;77rw  c                    U R                  5         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      n/ n[        S[	        U5      5       H&  n	UR                  U R                  Xy   U5      5        M(     U R                  USUS5      $ )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  r/  r  r  r  r0  filter_by_array_positions)
rs  r  r  r  r  r  symbolsLengthr  r  r  s
             ru  fetch_option_positionsbinance.fetch_option_positions'  s     	%%g.F'4(( #G 1$$TWW/u%uvv  [[(F &tGH..t{{7/KL0 q#h-(AMM$--hk6BC )--fhOOrw  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[   rO  rX  r  rg  rL  r  rO   r  r  rd  	markValuer  positionCostr  unrealizedPNLr  r  r  r  rE  r  r  r  )r  r  r  r  r=  r  )
r  r  rf  rI   r  r  safe_positionr  rq  rl  )rs  r  r  r  r  rO  rX  r  s           ru  r0  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##
$ (, $/#
  	rw  c                 z   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      $ US:X  a  U R                  X5      $ US:X  a  U R                  X5      $ [        U R                  S-   U-   S-   5      e)	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   rz  rt  rs  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_positionsr6  r?   rO   )rs  r  r  defaultMethodr  s        ru  fetch_positionsbinance.fetch_positions'  s    "  $ = =fFVX` a nnT\\3CDG $ 0 0?OQ_ ` .N*,,W==i'//@@h&..w??tww)ggjww  {G   G  H  Hrw  c                    Ub-  [        U[        5      (       d  [        U R                  S-   5      eU R	                  5         U R                  SU5        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      (       a\  U(       a  U R                  U5      nOSnU R                  USSS5      u  pU(       d  U R                  U5      nOkU R                  U5      nOYU R!                  XE5      (       a+  U(       a  U R#                  U5      nO*U R%                  U5      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      $ )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\   rx  fetchAccountPositionsr  r  rl  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  r4  )rs  r  r  r  rx  ry  r  r  r  r  r  s              ru  r@  binance.fetch_account_positions (  s   & gt,,'2l(lmm##E62&&t||]HM<66*99:QSWY_aij $($C$CFLcekm~  AF  %G!>>$(( 226: $ = =fF]_fhm n#;;FCH#;;FCHF __T++ 00855f=tww)gghh#<<VE\^lnst--hE%%g.--fhOOrw  c                    Ub-  [        U[        5      (       d  [        U R                  S-   5      eU R	                  5         U R                  SU5        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      nOSn	U R                  USSS5      u  pU R                  X25      nU	(       d  U R                  U5      nOU R!                  U5      nOwU R#                  XV5      (       aI  U(       a!  U R%                  U R                  X25      5      nO9U R'                  U R                  X25      5      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      $ )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  rx  r   r  r  rl  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  r4  )rs  r  r  r  r  rx  ry  r  r  r  r  r  rawPositionr  s                 ru  r?  binance.fetch_positions_risk(  sE   $ gt,,'2p(pqq##E62&&t||]KP<99:NPTV\^fg $($C$CFL`bhj{  ~C  %D!66*>>$(( 55dkk'6RS $ = =fFZ\cej kW5#@@HH#@@HH6 __T++ 55dkk'6RS::4;;w;WXtww)kklld q#h-(A"+K#//\J  !1377d66x{CD	 )
 %%g.--fhOOrw  c                    U R                  5         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      (       aI  U(       a!  U R                  U R                  Xd5      5      nOU R                  U R                  Xd5      5      nOwU R                  X5      (       aI  U(       a!  U R!                  U R                  Xd5      5      nO9U R#                  U R                  Xd5      5      nO[        U R                  S-   5      eU R%                  XX#5      $ )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  rl  Fr<  r;  r  r  r\   rx  zA fetchFundingHistory() supports linear and inverse contracts only)r  r  r?   rO   r  r  rl  r  r  r  r  r  papiGetUmIncomer  fapiPrivateGetIncomer}  papiGetCmIncomedapiPrivateGetIncomeparse_incomes)rs  r  r4  r  r  r  r  ry  r  r  rx  r  s               ru  fetch_funding_historybinance.fetch_funding_history@)  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*>>$(( //G0LM44T[[5QR__T++ //G0LM44T[[5QRtww)llmm!!(EAArw  r  c                    Uc  [        U R                  S-   5      eUS:  d  US:  a  [        U R                  S-   5      eU R                  5         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   (       aL  U(       a"  U R                  U R                  XS5      5      nU$ U R                  U R                  XS5      5      n U$ US   (       aL  U(       a"  U R                  U R                  XS5      5      nU$ U R                  U R                  XS5      5      n U$ [        U R                  S-   5      e)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  rl  Fr  r  z9 setLeverage() supports linear and inverse contracts only)r4   rO   r5   r  r  r  papiPostUmLeverager  fapiPrivatePostLeveragepapiPostCmLeveragedapiPrivatePostLeverager?   )rs  r  r  r  r  r  r  r  s           ru  set_leveragebinance.set_leveragew)  sL    >#DGG.Y$YZZ qLhnTWW'NNOOV$Tl 
 !$($C$CFM[actv{$|!( 224;;w3OP   77G8TU  I 224;;w3OP
   77G8TU  tww)ddeerw  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         U R                  U5      nUS   US.nSn US	   (       a"  U R                  U R                  XS5      5      nU$ US
   (       a"  U R                  U R                  XS5      5      nU$ [        U R                  S-   5      e! [         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)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CROSSEDrC  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  )	rs  r=  r  r  r  r  r  er  s	            ru  set_margin_modebinance.set_margin_mode)  sY    >#DGG.[$[\\  %%'
 "J*$:+BTWW'UUVVV$Tl$
 	h99$++g:VW& % 	"99$++g:VW"  #477-j#jkk 	 !122,0NN4<<Idfk,l),G(-6VWH  	s+   *C4 0*C4 C4 4
E>A EEErE  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      (       aL  U(       a"  U R                  U R                  X5      5      n
U
$ U R                  U R                  X5      5      n
 U
$ U R                  XV5      (       aL  U(       a"  U R                  U R                  X5      5      n
U
$ U R                  U R                  X5      5      n
 U
$ [        U R                  S	-   5      e)
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  rl  FtruefalsedualSidePositionz= setPositionMode() supports linear and inverse contracts only)r  r  r  r  r}  papiPostCmPositionSideDualr  dapiPrivatePostPositionSideDualr  papiPostUmPositionSideDualfapiPrivatePostPositionSideDualr5   rO   )rs  rE  r  r  r  rx  ry  r  rq  r  r  s              ru  set_position_modebinance.set_position_mode)  sd     [[(F99:KV\99:KV\ $($C$CFL]_egxz  %A!%& 0
 ??4)) ::4;;w;WX    ??G@\]  ^^D** ::4;;w;WX   ??G@\]  TWW'ffggrw  c                    U R                  5         U R                  SU5        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      nOkU R                  U5      nOYU R                  X45      (       a+  U(       a  U R                  U5      nO*U R                  U5      nO[        U R                  S-   5      eU R                  US/ 5      n[        U[        5      (       a  UnU R!                  XqS	5      $ )
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>`
FNr   r  r  rl  z< fetchLeverages() supports linear and inverse contracts onlyr  r  )r  r  r  r  r  r  papiGetUmAccountfapiPrivateGetSymbolConfigr}  rG  r  r?   rO   r  r  r&  parse_leverages)rs  r  r  rx  ry  r  r  	leveragess           ru  fetch_leveragesbinance.fetch_leverages*  s8    	##E6299:JDRXY99:JDRXZbc $($C$CFL\^dfwy~$!>>$(( 008::6B__T++ 00855f=tww)gghhNN8["=	h%% I##IAArw  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  rL  r  r  crossedr  r  bothr  r  )r  r  r=  longLeverageshortLeverage)r  r  rf  r  r  )rs  r  r  r  marginModeRawr=  marginTypeRawrO  r  r  leverageValues              ru  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$(*
 	
rw  c                    U R                  5         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      nU R                  X5      n	U R                  U	S5      n
U R                  XX#5      $ )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  r9  r;  r  r  )
r  r  r  r?   rO   eapiPublicGetExerciseHistoryr  parse_settlementsr  filter_by_symbol_since_limitrs  r  r4  r  r  r  rx  r  r  settlementssorteds              ru  fetch_settlement_history binance.fetch_settlement_historyV*  s     	 .t{{6/B99:RTZc8tww)aabbH%F$*8$4vi7H$HGL!#(K $G44T[[5QR ,,X>k;700NNrw  c                    U R                  5         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      nU R                  X5      n	U R                  U	S	5      n
U R                  XX#5      $ )
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              ru  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4T[[5QR* ,,X>k;700NNrw  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.$ )Nr>  
createDater  realStrikePriceexercisePrice)r  r  r  r  r  )rg  r  r  rk  rl  )rs  
settlementr  r  r  s        ru  parse_settlementbinance.parse_settlement*  sg    > ''
L,O	##J9&&x8''
4EW"Y/
 	
rw  c                     / n[        S[        U5      5       H&  nUR                  U R                  X   U5      5        M(     U$ )Nr   )r  r  r  r  )rs  r  r  r  r  s        ru  r  binance.parse_settlements*  s@    F q#k*+AMM$//GH ,rw  c                 l   U R                  5         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      nU R                  USU5      nU R                  X5      $ )	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   )recordIdrd  r   )
r  r  r5   rO   check_required_argumentrd  eapiPrivateGetBillr  r  parse_ledger_entry)	rs  rO   r  r  rx  rd  r  r  firsts	            ru  fetch_ledger_entrybinance.fetch_ledger_entry+  s     	99:LdTZ[8TWW']]^^$$%7vF==& 
 **4;;w+GH xH5&&u77rw  c           	         U R                  5         SnU R                  USS5      u  pTU(       a  U R                  SXX4SS5      $ 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  a<  U R                  SUS5        US   U	S'   U R                  U R                  X5      5      nOU R                  Xg5      (       aI  U(       a!  U R                  U R                  X5      5      nOU R                  U R                  X5      5      nOwU R                  Xg5      (       aI  U(       a!  U R!                  U R                  X5      5      nO9U R#                  U R                  X5      5      nO[%        U R&                  S-   5      eU R)                  XX#5      $ )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>`
Fr   r6  Nr;  r  r7  r<  r  rl  r]   r  rO   rd  z- fetchLedger() supports contract wallets only)r  r  r  rd  r  r  r  r  r  r  r  r  r  rT  rU  r}  rV  rW  r?   rO   parse_ledger)rs  r  r4  r  r  r6  rx  ry  rd  r  r7  r  r  s                ru  fetch_ledgerbinance.fetch_ledger)+  s	   ( 	88PZ[44]DQV`dfkll}}T*H99-vV99-vV#(K $G!!&'2YYvw/F!&I $($C$CFM[actv{$|!8((fE"*4.GJ..t{{7/KLH^^D** //G0LM44T[[5QR__T++ //G0LM44T[[5QRtww)XXYY:   UBBrw  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  rv  r  outrg  inr  r  rL  rx  rR  rO   r1  rj  )r  rO   	directionrs  referenceAccountreferenceIdrx  rd  r  r  r  beforeafterrC  r  )r  rI   	string_ler  r  r  safe_currencyrg  safe_ledger_entryparse_ledger_entry_typerq  rl  )	rs  r  rd  r  r  r  r  r  rx  s	            ru  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/'
  ! 	rw  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  rS  OPTIONS_PREMIUM_FEEPOSITION_LIMIT_INCREASE_FEECONTRACTrS  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  rb  )REFERRAL_KICKBACK
COMMISSIONr  )rs  rx  
ledgerTypes      ru  r  binance.parse_ledger_entry_type+  s    
5
5
 "5
 *5	

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

* 
$77rw  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)	rd  r  r&  r'  r  r  r  
startswithget_base_domain_from_url)rs  r  r  r  rd  r.  networkCodesr  currentNetworkCoder  siteUrls              ru  rf  '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 - rw  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  )rs  r  urlPartsschemedomains        ru  r   binance.get_base_domain_from_url+  s_    ;99S>!!(A.>!!(A.>}v%++rw  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  rT  X-MBX-APIKEYz7 historicalTrades endpoint requires `apiKey` credentialr@  r  z!application/x-www-form-urlencoded)r  Content-Typer  z5 userDataStream endpoint requires `apiKey` credentialr  r  r  r  r  r	  r
  r   r   r  r  r  r  r  rK  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.POSTrn  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  rz  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	rawencoderX  secretrsaeddsaencodehmachashlibr  )rs  pathr  rz  r  r  r  r   r  r@  r  r  r  rI  r+  r  r  r  checkedBatchOrdersr  
batchOrder
queryBatchdefaultRecvWindowextendedParamsr  r  r  orderidlistLengthorigclientorderidlistLengthnewClientOrderIds	signatures                                  ru  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Orw  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.rl  )hostnamer  r  rX  )rs  r  r  r  r	  exceptionsForMarketTypes         ru  get_exceptions_by_urlbinance.get_exceptions_by_urla,  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	rw  reasonrz  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 r^  z5 order amount should be evenly divisible by lot size rZ  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) successTrg  rY  rm  r  200r  rj  r  rf  r   )rA   rO   r  r  r;   r  r  r
  loadsrj  throw_exactly_matched_exceptionr  rX  throw_broadly_matched_exceptionrI   r  r  r8   r0   r  r&  r  )rs  r  r  r  rz  r  r  r  requestHeadersrequestBodyr  
messageNewparsedMessagerk  messageerrorfeedbackarrayLengthelement	errorCodes                       ru  handle_errorsbinance.handle_errorss,  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  r9  poolIdrR  r  r   r   r)  )r  r  r  )
rs  r  rz  r  r  configr  rR  r  r  s
             ru  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1rw  c           	      X    U R                  XX4XVU5      nUS:X  a  SU R                  S'   U$ )Nr  Tr  )fetch2r  )	rs  r  r  rz  r  r  r  r"  r  s	            ru  r  binance.request,  s2    ;;t&'P)BFDLL>?rw  c                 (   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         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      n	O%US   n
U R                  U R                  X5      5      n	U R                  U R                  X5      SU
05      $ )Nr  r\   rY   rx  rZ   z@ add / reduce margin only supported with type future or deliveryrO   )rx  r  r  r  r  r  r  )r  r  r?   rO   r  r  r  fapiPrivatePostPositionMarginr  dapiPrivatePostPositionMarginparse_margin_modification)rs  r  r  addOrReducer  r  rx  r  r  r  r  s              ru  modify_margin_helperbinance.modify_margin_helper,  s   &&t||]HM& "K<H$&.tww)kkllV$))&9Tl

 ('?D99$++g:VWH&>D99$++g:VWH {{499(KDN
  	rw  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.
$ )Nrx  r  r  rL  r[   r  r   addreducerL  r  r  r  r  )
r  r  rx  r=  r  r  r  rC  r  r  )r  r  r  r  rl  )	rs  r  r  rawTyper  r  r  noErrorCoder  s	            ru  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/
 	
rw  c                 (    U R                  XSU5      $ )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  r-  rs  r  r  r  s       ru  reduce_marginbinance.reduce_margin -       ((FCCrw  c                 (    U R                  XSU5      $ )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   r6  r7  s       ru  
add_marginbinance.add_margin.-  r:  rw  c                     U R                  5         U R                  U5      nSUS   0nU R                  U R                  XB5      5      nU R	                  US5      nU R                  U5      $ )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>`
r  rO   r   )r  rd   sapiGetMarginInterestRateHistoryr  r  parse_borrow_rate)rs  r  r  rd  r  r  r  s          ru  fetch_cross_borrow_ratebinance.fetch_cross_borrow_rate<-  sl     	==&Xd^
 88W9UV ~~h*%%d++rw  c                 l    SU0nU R                  U R                  X25      5      nU R                  XA5      $ )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  )fetch_isolated_borrow_ratesr  r  )rs  r  r  r  borrowRatess        ru  fetch_isolated_borrow_rate"binance.fetch_isolated_borrow_rateZ-  s:     f
 66t{{77ST~~k22rw  c                    U R                  5         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      nU R                  U5      $ )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>`
       r  rO   )r  r  r  r  sapiGetMarginIsolatedMarginDatar  parse_isolated_borrow_rates)rs  r  r  r  r  r  s         ru  rD  #binance.fetch_isolated_borrow_ratesm-  s     	!!&(368,[[(F &tGH77G8TU, //99rw  c                 x   U R                  5         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      n	U R                  XX#5      $ )	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>`
]   z: fetchBorrowRateHistory() limit parameter cannot exceed 92rO   )r  r  r;   \&r   r<  )
r  r5   rO   rd  r?  r  r  r?  r  parse_borrow_rate_history)
rs  r  r4  r  r  rd  r  r<  rO  r  s
             ru  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88W9UV --heKKrw  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  dailyInterestRaterN  )rd  r  periodr  r  r  )r  r  r  r  rl  )rs  r  rd  r  r  s        ru  r@  binance.parse_borrow_rate-  sf     %%dK8	%%dG4
//
E$$T+>?"Y/
 	
rw  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  dailyInterestrN  )	r  r  r  baseRater  	quoteRaterT  r  r  )r  r  r  r  r  )rs  r  r  r  r  baseInfo	quoteInfos          ru  parse_isolated_borrow_rate"binance.parse_isolated_borrow_rate-  s    ( ##D(3!!(D&A~~dF+>>$*NN4+	&&vx8$$Xv6((?C%%i8)))_E

 
	
rw  c                    U R                  5         U R                  U5      nUS   US.nU R                  U R                  XS5      5      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.$ )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
rO   )tokenr  r  r  referenceNo)r  rO   r  rd  r  )r  rd  sapiPostGiftcardCreateCoder  r  r  )
rs  r  r  r  rd  r  r  r  giftcardCoderO   s
             ru  create_gift_codebinance.create_gift_code-  s     	==& d^
 224;;w3OP ~~h/''f5dM2 
 	
rw  c                 N    SU0nU R                  U R                  X25      5      nU$ )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  )sapiPostGiftcardRedeemCoder  )rs  rb  r  r  r  s        ru  redeem_gift_codebinance.redeem_gift_code!.  s2     L
 224;;w3OP rw  c                 N    SU0nU R                  U R                  X25      5      nU$ )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
r`  )sapiGetGiftcardVerifyr  )rs  rO   r  r  r  s        ru  verify_gift_codebinance.verify_gift_code<.  s2     2
 --dkk'.JK rw  c                    U R                  5         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      n
O<Ub  U R                  U5      nUS   US'   U R                  U R                  Xu5      5      n
U R                  U
S5      nU R                  X5      nU R                  XX45      $ )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  rl  FrO   r  r;  rW  r<  rM  r  )r  r  rd  rl  "papiGetMarginMarginInterestHistoryr  r  sapiGetMarginInterestHistoryr  parse_borrow_interestsfilter_by_currency_since_limit)rs  r  r  r4  r  r  r  r  r  rd  r  r  r|  s                ru  fetch_borrow_interestbinance.fetch_borrow_interestT.  s+    	 $($C$CFLacik|  D  %E!}}T*H'~GG#(K #FO229gN>>t{{7?[\H!V,,24L()88W9UVHJ ~~h/..t<2285PPrw  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	.	$ )
NrM  interestAccuredTimer  rL  r  r|  r  	principal)	r  r  rd  r|  r  amountBorrowedr=  r  r  r  r  r  r  rl  )rs  r  r  r  r  r=  s         ru  parse_borrow_interestbinance.parse_borrow_interest.  s    !!$(89%%d,AB	!'Wj
//0@0@w0OP((z: ,,T>B"..t[A$"Y/

 
	
rw  c                    U R                  5         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`  SnU R                  USSS	5      u  pUS
:X  a!  U R	                  U R                  XS5      5      nOKU R                  U R                  XS5      5      nO*SUS'   SUS'   U R                  U R                  XS5      5      nU R                  Xd5      $ )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>`
rO   rB  Nr   r  rl  FrepayCrossMarginMethodrz  papiPostMarginRepayDebtFALSErY  REPAYrx  )	r  rd  rH  r  r}  r  papiPostRepayLoansapiPostMarginBorrowRepayparse_margin_loan)	rs  r  r  r  rd  r  r  r  rz  s	            ru  repay_cross_marginbinance.repay_cross_margin.  s     	==&d^00>
  $($C$CFL^`fhy  |A  %B!F!<<VEWYqs{|NF2277G8TU  11$++g2NO %,GL!%GFO55dkk'6RSH %%h99rw  c                    U R                  5         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      nU R                  X5      $ )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>`
rO   TRUEr  r  r  r  rY  rx  r  rd  r  rH  r  r  r  	rs  r  r  r  r  rd  r  r  r  s	            ru  repay_isolated_marginbinance.repay_isolated_margin.  s     	==&V$d^00>Tl 
 11$++g2NO %%h99rw  c                 n   U R                  5         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      nO*SUS	'   S
US'   U R                  U R                  XS5      5      nU R                  Xd5      $ )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>`
rO   rB  Nr_   r  rl  Fr~  rY  BORROWrx  )r  rd  rH  r  papiPostMarginLoanr  r  r  )rs  r  r  r  rd  r  r  r  s           ru  borrow_cross_marginbinance.borrow_cross_margin
/  s     	==&d^00>
  $($C$CFL_agiz  }B  %C!..t{{7/KLH$+GL!&GFO55dkk'6RSH %%h99rw  c                    U R                  5         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      nU R                  X5      $ )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>`
rO   r  r  r  r  r  s	            ru  borrow_isolated_marginbinance.borrow_isolated_margin./  s     	==&V$d^00>Tl 
 11$++g2NO %%h99rw  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  r1  r  )rO   rd  r  r  r  r  r  rx  )rs  r  rd  r  r  s        ru  r  binance.parse_margin_loanM/  su    " %%dG4
%%dL9	##D(3//
E&&tX6"Y/
 	
rw  r   c           	      `   US:X  a  [        U R                  S-   5      eU R                  5         SnU R                  USSS5      u  peU(       a  U R	                  SXXBUS5      $ 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      nO U R                  U R                  X5      5      nU R                  XX45      $ )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 timeframeFr   r6  rP  rT  Nr  r  r  r:  rO   r  r<  CURRENT_QUARTERr;  r7  r<  r,  rQ  )r5   rO   r  r  r=  r  r  r   r  r  r>  r?  dapiDataGetOpenInterestHistr  fapiDataGetOpenInterestHistparse_open_interests_history)rs  r  r3  r4  r  r  r6  r  r  	symbolKeyr7  r<  rN  r  s                 ru  fetch_open_interest_history#binance.fetch_open_interest_historyj/  s     TWW'^^__88A[]gino::;UW]fkx~  AD  E  EV$d&&t	M
 $G &x 0Hf	#D\)&*&6&6v~O`&aGN##(K !!&'2##FIu=6Iw#78!(I}++I6H!%%E1AD1H!IGI)77G8TUH77G8TUH 005PPrw  c                    U R                  5         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      nOKUS
   (       a!  U R                  U R                  XB5      5      nO U R                  U R                  XB5      5      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      $ )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:
r]   r  underlyingAssetr  Nz$ fetchOpenInterest does not support 
expirationrO   r  r  r   )r  r  r?   rO   rh  eapiPublicGetOpenInterestr  dapiPublicGetOpenInterestfapiPublicGetOpenInterestr  r  r  parse_open_interest)	rs  r  r  r  r  r  r  r  r  s	            ru  fetch_open_interestbinance.fetch_open_interest/  sP    	V$()/)9G%&h'"477-S#SV\#\]]$(KKx0@$AGL! &tGH(55dkk'6RSHI55dkk'6RSH55dkk'6RSH> (H%F66xHF1c&k*y>V+K +  ++H==rw  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  rL  r  sumOpenInterestrc  sumOpenInterestValuesumOpenInterestUsdr  r  )r  r  r  openInterestAmountopenInterestValuer  r  r  )rg  r  rk  safe_open_interestr  rl  )rs  r|  r  r  rO   r  values          ru  r  binance.parse_open_interest/  s    ''+vF	h1##H.?P""8-CEYZ &&&&r4D"("3$ "(!&"Y/	(
 	 		rw  c           	      \   U R                  5         SnU R                  USS5      u  pTU(       a  U R                  SXX4SS5      $ 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  aI  U	(       a!  U R                  U R                  X5      5      nOU R                  U R                  X5      5      nOUS:X  aI  U	(       a!  U R                  U R                  X5      5      nOU R                  U R                  X5      5      nOpUS:X  aI  U	(       a!  U R                  U R                  X5      5      nOBU R                  U R                  X5      5      nO![        U R                   S-   US   -   S-   5      eU R#                  USU5      nU R%                  XX#5      $ )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>`
Fr   r6  currentrO  Nr  r  rl  rY   LIQUIDATIONautoCloseTyperM  r  rO   r;  rW  r  r<  r  z( fetchMyLiquidations() does not support rx  r  r  )r  r   fetch_paginated_call_incrementalr  r  r  r  rl  papiGetMarginForceOrdersr   sapiGetMarginForceLiquidationRecpapiGetUmForceOrdersfapiPrivateGetForceOrderspapiGetCmForceOrdersdapiPrivateGetForceOrdersr?   rO   r  parse_liquidations)rs  r  r4  r  r  r6  r  rx  ry  r  r  r  r  liquidationss                 ru  fetch_my_liquidationsbinance.fetch_my_liquidations0  sO   * 	88AVXbc889NPV_dnwy|}}[[(F99:OQW`99:OQWaij $($C$CFLacik|  D  %E!6>'4GO$,26N(I$%+D\"#(K v~"'#( 229gN6> 88W9UV@@WA]^  44T[[5QR99$++g:VW	! 44T[[5QR99$++g:VWtww)SSV\]cVddgqqrr\ ~~hA&&|UJJrw  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  rO  r  r  )
r  r  r  r  r  rO  	baseValue
quoteValuer  r  )r  rg  safe_liquidationr  r  rf  rl  )rs  liquidationr  r  r  s        ru  parse_liquidationbinance.parse_liquidation0  s    J ##K:'']LQ	$$&&x8))+}E ,,V^D%%k:>**;?))+yA**;
C"Y/&
  	rw  c                     U R                  5         U R                  U5      nSUS   0nU R                  U R                  XB5      5      nU R	                  US   U5      $ )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>`
r  rO   r   )r  r  eapiPublicGetMarkr  parse_greeksr  s         ru  fetch_greeksbinance.fetch_greeks0  sb     	V$fTl
 ))$++g*FG$   !f55rw  c                    U R                  5         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      nU R                  Xa5      $ )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)rs  r  r  r  r  r5  r  s          ru  fetch_all_greeksbinance.fetch_all_greeks1  s     	%%gtT4FLM!WQZ0$*4L!))$++g*FG$ $$X77rw  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  )rs  r  r  r  r  s        ru  r  binance.parse_greeks31  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
 
 
  ))&+>!
" #
$  $'
 	
rw  c                     U R                  5       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$ )Nr   r  r  r  )r6  r  r  r   )rs  r  r  r  tradingLimitsr  r  r  s           ru  fetch_trading_limitsbinance.fetch_trading_limits[1  sh    $$& q#g,'AZFH%FT]]6%C%C(.x(8(B%	 (
 rw  c                    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      nO0US:X  a  U R                  U5      nO[	        U R
                  S-   5      eU R                  US5      nUUS.$ )a  
fetchs the position mode, hedged or one way, hedged for binance is set identically for all linear markets or all inverse markets

https://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"]rq  )r  rE  )r  r  fapiPrivateGetPositionSideDualdapiPrivateGetPositionSideDualr5   rO   r  )rs  r  r  r  ry  r  rq  s          ru  fetch_position_modebinance.fetch_position_modef1  s     [[(F99:Mv^h::6BH	!::6BHTWW'rrss  >>(4FG&
 	
rw  c                    U R                  5         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      nO0US:X  a  U R                  U5      nO[        U R                  S-   5      eU R                  US/ 5      n[        U[        5      (       a  UnU R                  XaSS	5      $ )
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  rz  r  r5   rO   r  r  r&  parse_margin_modes)rs  r  r  r  ry  r  r  s          ru  fetch_margin_modesbinance.fetch_margin_modes1  s     	))'2G[[,F99:KV\h66v>H 	!11&9Hd TWW'ffgg+r:h%%F&&v&IIrw  c                 d   U R                  5         U R                  U5      nSnU R                  SX25      u  pBSnUS:X  a(  SUS   0nU R                  U R	                  Xb5      5      nO5US:X  a  U R                  U/U5      nXq   $ [        U R                  S-   5      eU R                  US   U5      $ )	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  rz  r  r  r5   rO   parse_margin_mode)rs  r  r  r  ry  r  r  fetchMarginModesResponses           ru  fetch_margin_modebinance.fetch_margin_mode1  s     	V$99:KV\h&,G 66t{{77STH 	!'+'>'>x'P$+33TWW'eeff%%hqk6::rw  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  rL  r  r  r  )r  r  r=  )r  r  r  rf  )rs  r=  r  r  r  reMarginModer  s          ru  r  binance.parse_margin_mode2  s    ##J9!!(3z:>$)6:GL..z<H$'4	'A7
LX&&
 	
rw  c                     U R                  5         U R                  U5      nSUS   0nU R                  U R                  XB5      5      nU R	                  US0 5      nU R                  USU5      $ )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>`
r  rO   r   N)r  r  r  r  r  parse_option)rs  r  r  r  r  r  chains          ru  fetch_optionbinance.fetch_option2  sr     	V$fTl
 ++DKK,HI2 xB/  f55rw  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  rd  r  r  impliedVolatilityrc  r  r  midPricer  r  r  r  r  r  r  r  r  r  r  )r  r  r  )rs  r  rd  r  r  s        ru  r  binance.parse_optionG2  sY   . ##E84!!(3
E

 fX&
 	

 
  
 D
 ((
;
 ((
;
 
 
 ))%=
 t//G
 d&&um<
 $**52FG
  $**5(;!
" 4#
 	
rw  c                 L   U R                  5         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      n	OIUS   (       a!  U R                  U R                  X5      5      n	O[        U R                  S-   US	   -   5      eU R                  U	5      n
U R                  XX45      $ )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 argumentr7  r  rO   r0  r   r  rx  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  )rs  r  rx  r4  r  r  r  r7  r  r  modificationss              ru  fetch_margin_adjustment_history'binance.fetch_margin_adjustment_historyt2  s@    	>#DGG.j$jkkV$!!&'267+fTl
 $(EMaGFO#(K $G!&I(??G@\]HI??G@\]HTWW'nnqwx~q  A  A  77A00UUrw  c                 l   U R                  5         U R                  U5      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$ )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
r   r  Nfractionr  )r  r   r  )r  rO   r  r.  rx  rP   r  r  r   r  r  r  rY  )r  sapiGetConvertAssetInfor  r  r  r  rq  rm  )rs  r  r  r  r  r  rO   r  s           ru  fetch_convert_currencies binance.fetch_convert_currencies2  s     	//7 q#h-(AKE!!%1B**2.D  !..t/C/CDDTDTUZ\fDg/hi  $#
  $#!
  $#   5FL	 )@ rw  fromCodetoCodec                    Uc  [        U R                  S-   5      eU R                  5         UUUS.nU R                  U R	                  XT5      5      nU R                  U5      nU R                  U5      nU R                  XgU5      $ )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>`
z0 fetchConvertQuote() requires an amount argument)r  toAsset
fromAmount)r4   rO   r  sapiPostConvertGetQuoter  rd  parse_conversion)	rs  r	  r	  r  r  r  r  fromCurrency
toCurrencys	            ru  fetch_convert_quotebinance.fetch_convert_quote2  s     >#DGG.`$`aa! 

 //G0LM }}X.]]6*
$$XZHHrw  c                    U R                  5         0 nSnUS:X  d  US:X  aL  Uc  [        U R                  S-   5      eXS'   X&S'   X6S'   XFS'   U R                  U R	                  Xe5      5      nO$XS'   U R                  U R	                  Xe5      5      nU R                  U5      nU R                  U5      n	U R                  XxU	5      $ )	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  sapiPostConvertAcceptQuoterd  r	  )
rs  rO   r	  r	  r  r  r  r  r	  r	  s
             ru  create_convert_tradebinance.create_convert_trade3  s     	Ff$4~'2e(eff&(N#'G%+M" &H88W9UVH "$I66t{{77STH }}X.]]6*
$$XZHHrw  c                 ^   U R                  5         0 nSnUS:X  a^  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      nO$XS	'   U R                  U R	                  XC5      5      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      $ )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)  rN  rO   r  r1  r;  r<  rk  r  r   deductedAssetr  r	  r	  )
r  r  rd  &sapiGetAssetConvertTransferQueryByPager  sapiGetConvertOrderStatusr  r  r  r	  )rs  rO   r  r  r  r  msInDayrO  rd  r  r  fromCurrencyIdtoCurrencyIdr	  r	  s                  ru  fetch_convert_tradebinance.fetch_convert_trade33  sM    	6>G##%C==.#+D>  "H#&=GK !$IBB4;;wC_`H( "$I55dkk'6RSH 6>>>(FB7D>>$2.D++D/;O))$yI
%==8L#|4J$$TDDrw  c                 f   U R                  5         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  aG  U R	                  U5      nUS   US'   Ub  X5S	'   S
nSnSn
U R                  U R                  XT5      5      n	OTU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      n	U R                  X/ 5      nU R                  XXX#5      $ )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>`
l    H4 Nr;  r<  r7  r)  rO   r  rW  r	  r	  r  zV fetchConvertTradeHistory() the max interval between startTime and endTime is 30 days.r  r  r	  r&  )r  r  rg  r  rd  r	  r  r5   rO   sapiGetConvertTradeFlowr  parse_conversions)rs  r  r4  r  r  r  msInThirtyDaysrO  r<  r  responseQueryfromCurrencyKeytoCurrencyKeyrd  r  s                  ru  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BB4;;wC_`H( 	"W[%99^K   ,D  "D  E  E #( )O%M"M33DKK4PQH. ~~hr:%%d/RW__rw  
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)rL  validTimestampr  r	  r  r	  r	  )r1  rk  r  deductedAmountr	  targetAmounttoAmount)
r  r  r  rO   r	  r	  r	  r4	  r  r  )r  r  r  rl  rs  rk  )	rs  r/	  r	  r	  r  fromCurr	  tor	  s	            ru  r	  binance.parse_conversion3  s    N ''
4\]	$$Z+N**7A
M9E((8"Y/$$Z1QR$,,Z9I<X **:~zR
 	
rw  c                    U R                  5         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      nO@U R                  XE5      (       a  U R                  U5      nO[        U R                  S-   5      eU R                  Xa5      $ )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          ru  fetch_funding_intervalsbinance.fetch_funding_intervals04  s     	))'2G[[,F99:QSYckl>>$((44V<H__T++44V<Htww)sstt ''::rw  c                    U R                  5         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  a)  US	   US
'   U R	                  U R                  Xu5      5      n	OJUS:X  a,  US   S   US'   U R                  U R                  Xu5      5      n	O[        U R                  S-   5      eU R                  X5      $ )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   rT  r<  r;  r  r   r  rO   r  r  r  r:  zG fetchLongShortRatioHistory() supports linear and inverse subTypes only)
r  r  rl  r  &fapiDataGetGlobalLongShortAccountRatior  &dapiDataGetGlobalLongShortAccountRatior5   rO   parse_long_short_ratio_history)
rs  r  r3  r4  r  r  r  r  ry  r  s
             ru  fetch_long_short_ratio_history&binance.fetch_long_short_ratio_historyX4  s    	V$Ii
 229gN#(K $G99:VX^gh &tGHBB4;;wC_`H 	!$VnV4GFOBB4;;wC_`H TWW'ppqq228DDrw  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  r3  rD	  )r  safe_integer_omit_zeror  rl  r  )rs  r  r  r  r  s        ru  parse_long_short_ratiobinance.parse_long_short_ratio4  sj    , ##D(3//kB	&&xzJ"Y/"..t5EF
 	
rw  )r   )N)NNNN)NNF)F)NN)__name__
__module____qualname____firstlineno__r   rp  r  r#   boolr}  r  r  r  r-   r  r   r  r  r  r  r   r  r
   r  r/   r6  dictr+  r  r   r  r  r   r  r%   r  r  r  r$   r  r  r  r&   r  r  r(  r+  r&  r1  rQ  r)   rv  r  r!   r    floatr   r  r  r  r  r  r   r  r  r   r  r  r,  r  rT  rW  rZ  re  rw  r  r  r  r  r  r  r  r  r  r  r  rp  r,   r  r  r  r   r*  r.  r.   r<  r?  r   r^  r   rc  rb  rn  rr  rv  r   r*   r  r  r+   r  r  r'   r  r  r  r(   r  r  r  r  r  r  r   r#  r   r,  r1  r6  r0  r"   rB  r@  r?  rY  r  ra  rl  rv  r   r}  r   r  r  r  r  r  r   r  r  r  r  rf  r  r  r  r  r#  r  r-  r   r+  r8  r<  r	   rA  r   rF  r   rD  rP  r@  r\  rc  rg  rk  r   rr  ry  r  r  r  r  r  r  r  r  r  r  r   r  r  r  r  r  r   r  r   r  r  r   r  r  r	  r		  r   r	  r	  r$	  r-	  r	  r;	  r   rA	  rF	  __static_attributes____classcell__)rt  s   @ru  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Z aF $& c$v, cJ	g4 gF gRdAem dAL $& @X( @XD :>b Es E3 EY ENv4 v v6 vp #% 
2 02 %33 %3f %3N 26b  5w  5D 48 :9 :9x&
f &
P 04B /5W /57 /5b@ 46 3s 3& 3@ 48 5 5w 58=
 =
4 =
~ 9=4^bkm v# v# vS vX[ vrvw{r| vp~ ~v ~ ~@ 6:UW IA3 IAs IA# IA\`af\g IAV sw  @B ?.# ?.s ?.) ?.9 ?.^c ?.lo ?.B {  HJ g,# g,s g,) g,S\ g,fk g,tw g,R C  LN c 3 i W` jo x{ $ w{  DF A2c A23 A2i A2y A2bg A2ps A2F `drv  @B [S [# [Y [i [Y\ [lo [4 >@ M+$|"4 M+^: :k kv k kZ @B K+D$6 K+Z gksu `23 `2i `2y `2RW `2`c `2D os{} E33 E3i E3y E3Z_ E3hk E3N _a _C _y _PU _* RT ` `5 `( SU O OE O$ 26b ?2c ?23 ?2B *.Dt\^ AA3 AAc AA AAcghmcn AAF /3TXac QA QA3 QAc QAhlmrhs QAf 7;2 J23 J2 J2X 154VZce H# HS HPS Hjnotju H: 37TX\eg HC Hs HRU H: >BPTcgpr Fs F# F]` Fw{  }B  xC F@ 37r O2s O2C O2b /32 \ \| ;?r I3c I3C I3V 9=4^bkm XS X# XS XX[ X: -1tRV_a SAc SA SAC SAj 26DW[df C@3 C@c C@QT C@JA
f A
F *.Dt\^ dI3 dIc dI dIcghsct dIL -1tRV_a yIc yI yIC yIfjkvfw yIv$:Lx
T x
X x
Q\ x
t:C :C :c
t c
x c
= c
J
6 
4 [] U7S U7% U7c U7c U7an U7n +/TPT]_ DBC DBs DB# DBdhivdw DBL 79 &># &>^ &>P
 
N 
8 7;2 o
G o
b <@ 6I 6Ip@ @D KOWY ":S ":% ":# ":C ":^i ":H
T 
6 
EX 
: 57 ?4 ?4;N ?4B )+ g{ gR @B 7S 7> 68 %9 %9K %9N 8<$]ajl 7Q 7QC 7QWZ 7Qr
6 
" 6:" ;7 ; ;8:
6 :
[ :
xBj
v j
X\
F \
| -2" '0R 7;2 IFG IF- IFV& &$|J\ &P 24 )8S )8V 9=R 4Pg 4Pl6t 6V 6p 26b  Hw  HT(^  HD :>b wPw wPr 7;2 ePG ePN 37TX\eg 5BC 5Bs 5BRU 5Bn 9=R *S *# *X >B" 6# 6s 6p =A 4 4c 4l 26b 'Bw 'BY 'BR
t 
V 
x 
8 6:[_hj (Os (O# (OUX (OT 9=4^bkm 1O# 1OS 1OX[ 1Of'
R&P 7;2 #8S #8 #8+ #8J (,$TZ\ XC XCC XCs XCaefqar 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  !)r4VZce  MO "3 "H*
d *
F *
N` *
X @B DC D DFX D =? D De DCU D 9; ,C , ,< >@ 3 3DV 3& 24 *:8K *:X AESW`b 'Lc 'L# 'LS 'LR
 
(#
t #
V #
Oa #
J :< $
S $
L 57 6 02 3 0 15DW[jnwy JQ# JQc JQQT JQdg JQ  C  DR  S JQX
$ 
 
. 
  <> 9:s 9:v LN :C :s :> DF ": ":U ":H TV :S : :U :>
 
: BFTXgktv =Q# =Qc =Qad =Q~ 79 D# DLF $ 37TX\eg RKC RKs RKRU RKhRV Rh 02 !63 !6f !6F 37r %8 %8d6l %8N&
4 &
 &
6 &
P 7;2 	G 	 15R !
# !
F 59 YJ' YJ YJv 57 &; &;: &;P
D 
* 
  02 )63 )6f )6V+
$ +
( +
6 +
]c +
Z =Adaetx  BD 7Vc 7V 7V[^ 7Vnq 7V  IM  N`  Ia 7Vr /1 4Z 4l MQY[ "IC "I "Ic "I`j "IH W[ce *Is *Ic *I3 *IPS *Ijt *IX 8<B FEc FE FE: FEP 7;\`ik Z` Z`3 Z`VY Z`ptu  qA Z`xW
4 W
x W
\d W
pz W
r :>b &;w &;\ &;P <@RVeix|  FH <ES <EC <E_b <Eru <E  MQ  R`  Ma <E|
4 
 
> 
 
rw  rK   )Qccxt.base.exchanger   ccxt.abstract.binancer   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{  rw  ru  <module>rX	     s    ( -   T  T  T  T  T  T  T  T  T  T  T  * 0 - - . ' & . 1 ) . ) * 5 - ) , + . * ) + ( 3 4 %MR
h MR
rw  