
    E#i	                       S SK Jr  S SKJr  S SKrS SKrS SKrS SKJrJ	r	J
r
JrJrJrJrJrJrJrJrJrJrJrJrJrJrJrJrJrJrJrJrJrJ r J!r!J"r"J#r#J$r$J%r%J&r&J'r'J(r(J)r)J*r*J+r+J,r,  S SK-J.r.  S SK/J0r0  S SK/J1r1  S SK/J2r2  S S	K/J3r3  S S
K/J4r4  S SK/J5r5  S SK/J6r6  S SK/J7r7  S SK/J8r8  S SK/J9r9  S SK/J:r:  S SK/J;r;  S SK/J<r<  S SK/J=r=  S SK/J>r>  S SK/J?r?  S SK/J@r@  S SK/JArA  S SK/JBrB  S SKCJDrD  S SKEJFrF   " S S\\5      rGg)    )Exchange)ImplicitAPIN)%AnyBalancesBorrowInterest
ConversionCrossBorrowRate
CurrenciesCurrencyDepositAddressFundingHistoryIntIsolatedBorrowRateLedgerEntryLeverageLeverageTierLiquidationLongShortRatio
MarginModeMarginModificationMarketNumOrder	OrderBookOrderRequest	OrderSide	OrderTypePositionStrStringsTickerTickersFundingRateFundingRatesTradeTradingFeeInterfaceTradingFeesTransactionTransferEntry)List)ExchangeError)AuthenticationError)PermissionDenied)AccountSuspended)ArgumentsRequired)
BadRequest)	BadSymbol)InsufficientFunds)InvalidAddress)InvalidOrder)OrderNotFound)NotSupported)DDoSProtection)RateLimitExceeded)ExchangeNotAvailable)OnMaintenance)InvalidNonce)RequestTimeout)CancelPending)	TICK_SIZE)Precisec                   (  ^  \ rS rSrS\4U 4S jjrS\4S jrS\4S jrS0 4S jr	0 4S\
4S	 jjr0 4S\\   4S
 jjrS\\   4S jrS\\   4S jr0 4S\4S jjr0 4S\S\\   4S jjrSS\S\\   4S jjrSSS0 4S\S\
S\
S\\   4S jjrS0 4S\S\S\S\S\4
S jjrSSS0 4S\S\
S\
S\\   4S jjrSS\S\S\4S jjrS\4S jr 0 4S\S\!4S  jjr"SS\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\S\&4S% jjr(0 4S\S\&4S& jjr)S0 4S'\*S\+4S( jjr,SS)\S\S\-4S* jjr.SS0 4S\S\
S\
S\\-   4S+ jjr/0 4S\S\04S, jjr10 4S\24S- jjr3SS\4S. jjr4SS\S\54S/ jjr6S0SS0 4S\S1\S\
S\
S\\5   4
S2 jjr70 4S\84S3 jjr9S\84S4 jr:S\84S5 jr;S\4S6 jr<SS7\S\S\=4S8 jjr>0 4S\S9\4S: jjr?S0 4S\S;\@S<\AS\S=\B4
S> jjrCS0 4S\S;\@S<\AS\S=\B4
S? jjrDS0 4S\S;\@S<\AS\S=\B4
S@ jjrE0 4SA\\F   4SB jjrG0 4SA\\F   4SC jjrHSS0 4SD\S\S;\@S<\AS\BS=\B4SE jjrIS0 4SD\S\4SF jjrJS0 4S\4SG jjrKS0 4SH\\   S\4SI jjrLS0 4S\4SJ jjrMS0 4SD\S\4SK jjrNSSS0 4S\S\
S\
S\\=   4SL jjrOSSS0 4S\S\
S\
S\\=   4SM jjrPSSS0 4S\S\
S\
4SN jjrQSSS0 4S\S\
S\
4SO jjrRSSS0 4S\S\
S\
4SP jjrSSSS0 4S\S\
S\
S\\T   4SQ jjrUSSR\S\S\T4SS jjrVST rWSSS0 4S\S\
S\
S\\-   4SU jjrX0 4S\4SV jjrYS0 4S'\*S\\Z   4SW jjr[SSX\S\4SY jjr\SSS0 4S\S\
S\
4SZ jjr]0 4S\S\^4S[ jjr_S0 4S'\*S\`4S\ jjraS0 4S'\*S\`4S] jjrbSS\S\^4S^ jjrcSSS0 4S\S\
S\
S\\d   4S_ jjreSS\4S` jjrfSS\
S\
S\\d   4Sa jjrg0 4S\S\h4Sb jjriSSc\S\S\h4Sd jjrj0 4S\S\S\h4Se jjrk0 4S\S\S\h4Sf jjrl0 4S\S\m4Sg jjrnSSh\S\S\m4Si jjroS0 4Sh\pS\4Sj jjrqS0 4Sk\S\4Sl jjrrS0 4Sm\S\4Sn jjrs0 4S\4So jjrtSS\4Sp jjruSSS0 4S\S\
S\
S\\v   4Sq jjrw0 4S\S\Sr\Ss\S\v4
St jjrxSSu\S\S\v4Sv jjryS\S\4Sw jrzSS\4Sx jjr{S0 4Sy\*4Sz jjr|0 4S\S\4S{ jjr}0 4S\S\S\4S| jjr~0 4S\S\4S} jjr0 4S\4S~ jjrSS\S\4S jjrSSS0 4S\S\
S\
S\\   4S jjrSS\4S jjr0 4S\S\4S jjrSS\S\S\4S jjr0 4S\S\4S jjrSS\4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rS0 4S\S<\AS\=4S jjr0 4S\\Z   4S jjr0 4S\S\4S jjrSSk\S\4S jjrSSS0 4S'\*S\
S\
S\\Z   4S jjrS0 4S\S\S\BS\4S jjrS0 4SD\S\S\S\BS\4
S jjrSSS0 4S\S\
S\
S\\   4S jjrSS\S\S\S\4S jjr0 4S\4S jjr0 4S\S\^4S jjrSSSS0 4S\S1\S\
S\
S\\   4
S jjrSS\S\S\4S jjrS\pS\S\S\S\S\4S jrS r/ S0 SS4S jrSrU =r$ )bitget$   returnc                 9  > U R                  [        [        U ]  5       0 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_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_S0S_S1S_E0 S2S_S3S_S4S_S5S_S6S_S7S_S8S_S9S_S:S_S;S_S<S_S=S_S>S_S?S_S@S_SAS_SBS_E0 SCS_SDS_SES_SFSG_SHS_SIS_SJS_SKS_SLS_SMS_SNS_SOS_SPS_SQS_SRS_SSS_STS_E0 SUS_SVS_SWS_SXS_SYS_SZS_S[S_S\S_S]S_S^S_S_S_S`S_SaS_SbS_ScS_SdS_SeS_E0 SfS_SgS_ShS_SiS_SjSG_SkS_SlS_SmS_SnS_SoS_SpS_SqS_SrS_SsS_StS_SuS_SvS_E0 SwS_SxS_SyS_SzS_S{S_S|S_S}S_S~S_SS_SS_SS_SS_SS_SS_SS_SS_E_SSSSSSSSSSSSSSSS._SS_SSSSSSSSSSSSSSS.S/ SQSSS._SSSSS.0S0 SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SSSSSSSSSS.	E0S0 SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_0 SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_ESSSSSS.E0SSSSSSSSS.0SSSS.0SSSSSSSSSSSSSSSS.0S.0 SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SSSSSSSSSSSSSSS.E0 SS_SS_SS_SS_SS_SS_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_0 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SS_GSS_GSS_GSS_GSS_GSS_GS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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_E0 GS)S_GS*S_GS+S_GS,S_GS-S_GS.S_GS/S_GS0S_GS1S_GS2S_GS3S_GS4S_GS5S_GS6S_GS7S_GS8S_EGS9.0 GS:S_GS;S_GS<S_GS=S_GS>S_GS?S_GS@S_GSAS_GSBS_GSCS_GSDS_GSES_GSFS_GSGS_GSHS_GSIS_GSJS_0 GSKS_GSLS_GSMS_GSNS_GSOS_GSPS_GSQS_GSRS_GSSS_GSTS_GSUS_GSVS_GSWS_GSXS_GSYS_GSZS_GS[S_ESSSSSSSSSSSSSSGS\.E0 GS]S_GS^S_GS_S_GS`S_GSaS_GSbS_GScS_GSdS_GSeS_GSfS_GSgS_GShS_GSiS_GSjS_GSkS_GSlS_GSmS_0 GSnS_GSoS_GSpS_GSqS_GSrS_GSsS_GStS_GSuS_GSvS_GSwS_GSxS_GSyS_GSzS_GS{S_GS|S_GS}S_GS~S_E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_ESSSSSSSGS.EGS9.SSSSSSSSSGS.	SSSSSSSSSSGS.
GS9.SSSSSSSSSGS.0SSSSSSSSSSSSSSSGS.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S9.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_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SSSSSSSSSSSSSSSG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SS_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GSS0EGS9.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_SSSSSSSSSSSSSGS.E0 GSS_GSS_G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S_GS	S_GS
S_GSS_GSS_GSS_GSS0EGS9.SSSSSGS.0SSSSSGS.SSGS.GS9.0 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SS_GSS_GSS_GSS_GSS_GS S_GS!S_GS"S_SSSGS#.ESSSSSSGS$.GS9.SGS%S000 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S/S_GS0S_GS1S_GS2S_GS3S_GS4S_GS5S_GS6S_SSSSSSSSSSGS7.
E0 GS8S_GS9S_GS:S_GS;S_GS<S_GS=S_GS>S_GS?S_GS@S_GSAS_GSBS_GSCS_GSDS_GSES_GSFS_GSGS_GSHS_SSSSSSGSI.EGS9.GSJ.GSK._GSLU R	                  GSM5      U R	                  GSM5      GSN.U R	                  GSO5      U R	                  GSP5      GSN.GSQ._GSRSSSGSS._GST0 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[
        _GSd[        _GSe[        _0 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[        _GSu[        _GSv[        _E0 GSw[        _GSx[
        _GSy[        _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["        _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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S<[
        _GS=[
        _GS>[        _GS?[        _GS@[        _GSA["        _GSB["        _E0 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["        _GSS["        _E0 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[
        _GSd[
        _E0 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["        _GSu[
        _E0 GSv[        _GSw[        _GSx["        _GSy["        _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["        _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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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GSB[
        0GSC._GSD[.        _GSEGSFGSGGSHGSIGSJGSKGSL._0 GSMS_GSNGSO_GSPS_SGSQGSRGSSGSTGSUSSGSVGSWGSXGSYGSZGS[GS\.SSSSSGS]GS^GS_GSVGSWGSXGSYGSZGS[S.SSSSSGS]GS^GS_GS`GSaGSbGSc.GSd._S[GSeSS/0_GSfS_GSgGSh_GSiS_GSjGSk_SGSlS0_S`GSmGSmGSmGSmGSmGSnGSoGSpGSqGSrGSsGStGSuGSvS.GSwGSxGSxGSxGSy.GSzGS{.GS|GSqGS}GS~GSmGSSGS.GSGS{.GS._StGSGS0GSGS0GSQ._SLGSGS0_GSSGSGSGSGSGSGSGS._GSSGSGSSGSSGSGS._GSS_GS0 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SGS_GSGS_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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SGS_GSG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SKGSK_GSGS_GSGS_GSGS_GSGS_GSGS_E0 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_GSGS_GSGS	_GS
GS
_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SGS0GS/ GSQGS.ESSSSSSGS.SSSSSSGS.SGS.SSSSGS.SSSSGS.GSS
0SGSxS GS~SGS.SSSSGS.SGSxSSSGS.S SGSxS S GS~SSSGS .GS!S0GS".	SSSSSGS.SSSSSSGS.SGS.SSSSGS.SSSSGS#.GS$GS%0GS&S0GS'.GS(GS)0GS(GS)0GS*.GS(GS)0GS(GS)0GS*.GS+.GS,.E5      $ (-  NidrA   nameBitget	countriesSGversionv2	rateLimit2   	certifiedTprohasCORSspotmarginswapfutureoptionF	addMarginborrowCrossMarginborrowIsolatedMargincancelAllOrderscancelOrdercancelOrderscloseAllPositionsclosePositioncreateConvertTradecreateDepositAddresscreateMarketBuyOrderWithCostcreateMarketOrderWithCostcreateMarketSellOrderWithCostcreateOrdercreateOrders$createOrderWithTakeProfitAndStopLosscreatePostOnlyOrdercreateReduceOnlyOrdercreateStopLimitOrdercreateStopLossOrdercreateStopMarketOrdercreateStopOrdercreateTakeProfitOrdercreateTrailingAmountOrdercreateTrailingPercentOrdercreateTriggerOrder	editOrderfetchAccountsfetchBalancefetchBorrowInterestfetchBorrowRateHistoriesfetchBorrowRateHistoryfetchCanceledAndClosedOrdersfetchCanceledOrdersfetchClosedOrdersfetchConvertCurrenciesfetchConvertQuotefetchConvertTradefetchConvertTradeHistoryfetchCrossBorrowRatefetchCrossBorrowRatesfetchCurrenciesfetchDepositfetchDepositAddressfetchDepositAddressesfetchDepositAddressesByNetworkfetchDepositsfetchDepositsWithdrawalsfetchDepositWithdrawFeeemulatedfetchDepositWithdrawFeesfetchFundingHistoryfetchFundingIntervalfetchFundingIntervalsfetchFundingRatefetchFundingRateHistoryfetchFundingRatesfetchIndexOHLCVfetchIsolatedBorrowRatefetchIsolatedBorrowRatesfetchLedgerfetchLeveragefetchLeverageTiersfetchLiquidationsfetchLongShortRatiofetchLongShortRatioHistoryfetchMarginAdjustmentHistoryfetchMarginModefetchMarketLeverageTiersfetchMarketsfetchMarkOHLCVfetchMarkPricefetchMyLiquidationsfetchMyTrades
fetchOHLCVfetchOpenInterestfetchOpenInterestHistoryfetchOpenOrders
fetchOrderfetchOrderBookfetchOrderBooksfetchOrdersfetchOrderTradesfetchPositionfetchPositionHistoryfetchPositionModefetchPositionsfetchPositionsHistoryfetchPositionsRiskfetchPremiumIndexOHLCVfetchStatusfetchTickerfetchTickers	fetchTimefetchTradesfetchTradingFeefetchTradingFeesfetchTransactionsfetchTransferfetchTransfersfetchWithdrawAddressesfetchWithdrawalfetchWithdrawalsreduceMarginrepayCrossMarginrepayIsolatedMarginsetLeverage	setMarginsetMarginModesetPositionModesignIntransferwithdraw
timeframes1m3m5m15m30m1h2h4h6h12h1d3d1w)r   r   r   r   r   r   r   r   r   r   r   r   r   1Mhostnamez
bitget.comurlszOhttps://github.com/user-attachments/assets/fbaa10cc-a277-441d-a5b7-997dd9a87658zhttps://api.{hostname})rR   mixuserp2pbrokerrS   commontaxconvertcopyearnutazhttps://www.bitget.com)z+https://www.bitget.com/api-doc/common/introz)https://www.bitget.com/api-doc/spot/introz-https://www.bitget.com/api-doc/contract/introz+https://www.bitget.com/api-doc/broker/introz+https://www.bitget.com/api-doc/margin/introz0https://www.bitget.com/api-doc/copytrading/introz)https://www.bitget.com/api-doc/earn/introz-https://bitgetlimited.github.io/apidoc/en/mixz.https://bitgetlimited.github.io/apidoc/en/spotz0https://bitgetlimited.github.io/apidoc/en/brokerz0https://bitgetlimited.github.io/apidoc/en/marginz&https://www.bitget.cc/zh-CN/rate?tab=1zMhttps://www.bitget.com/expressly?languageType=0&channelCode=ccxt&vipCode=tg9j)logoapiwwwdocfeesreferralr   get   )zv2/public/annoucementsv2/public/timezspot/v1/notice/queryAllNoticeszspot/v1/public/timezspot/v1/public/currenciesg	g@zspot/v1/public/productszspot/v1/public/productzspot/v1/market/tickerzspot/v1/market/tickerszspot/v1/market/fills   zspot/v1/market/fills-historyzspot/v1/market/candleszspot/v1/market/depthzspot/v1/market/spot-vip-levelzspot/v1/market/merge-depthzspot/v1/market/history-candleszspot/v1/public/loan/coinInfosz!spot/v1/public/loan/hour-interestzv2/spot/public/coins)	zv2/spot/public/symbolszv2/spot/market/vip-fee-ratezv2/spot/market/tickerszv2/spot/market/merge-depthzv2/spot/market/orderbookzv2/spot/market/candleszv2/spot/market/history-candleszv2/spot/market/fillszv2/spot/market/fills-historyzmix/v1/market/contractszmix/v1/market/depthzmix/v1/market/tickerzmix/v1/market/tickersz mix/v1/market/contract-vip-levelzmix/v1/market/fillszmix/v1/market/fills-historyzmix/v1/market/candleszmix/v1/market/indexzmix/v1/market/funding-timezmix/v1/market/history-fundRatezmix/v1/market/current-fundRatezmix/v1/market/open-interestzmix/v1/market/mark-pricezmix/v1/market/symbol-leveragez mix/v1/market/queryPositionLeverzmix/v1/market/open-limitzmix/v1/market/history-candlesz#mix/v1/market/history-index-candlesz"mix/v1/market/history-mark-candleszmix/v1/market/merge-depthzv2/mix/market/vip-fee-ratezv2/mix/market/merge-depthzv2/mix/market/tickerzv2/mix/market/tickerszv2/mix/market/fillszv2/mix/market/fills-historyzv2/mix/market/candleszv2/mix/market/history-candlesz#v2/mix/market/history-index-candlesz"v2/mix/market/history-mark-candleszv2/mix/market/open-interestzv2/mix/market/funding-timezv2/mix/market/symbol-price   )zv2/mix/market/history-fund-ratezv2/mix/market/current-fund-ratezv2/mix/market/contracts"v2/mix/market/query-position-leverz v2/mix/market/account-long-short)z+margin/v1/cross/public/interestRateAndLimitz.margin/v1/isolated/public/interestRateAndLimitzmargin/v1/cross/public/tierDataz"margin/v1/isolated/public/tierDatazmargin/v1/public/currencieszv2/margin/currenciesz!v2/margin/market/long-short-ratio)zv2/earn/loan/public/coinInfosz!v2/earn/loan/public/hour-interest)zv3/market/instrumentszv3/market/tickerszv3/market/orderbookzv3/market/fillszv3/market/open-interestzv3/market/candleszv3/market/history-candlesv3/market/current-fund-ratezv3/market/history-fund-ratezv3/market/risk-reservezv3/market/discount-ratezv3/market/margin-loanszv3/market/position-tierzv3/market/oi-limit)r   rR   r   rS   r   r   zspot/v1/wallet/deposit-address   zspot/v1/wallet/withdrawal-listzspot/v1/wallet/deposit-listzspot/v1/account/getInfozspot/v1/account/assetszspot/v1/account/assets-litezspot/v1/account/transferRecordszspot/v1/convert/currencieszspot/v1/convert/convert-recordzspot/v1/loan/ongoing-orderszspot/v1/loan/repay-historyzspot/v1/loan/revise-historyzspot/v1/loan/borrow-historyzspot/v1/loan/debtszv2/spot/trade/orderInfozv2/spot/trade/unfilled-orderszv2/spot/trade/history-orders)zv2/spot/trade/fillsz v2/spot/trade/current-plan-orderz v2/spot/trade/history-plan-orderzv2/spot/account/infozv2/spot/account/assetsz!v2/spot/account/subaccount-assetszv2/spot/account/billszv2/spot/account/transferRecordszv2/account/funding-assetszv2/account/bot-assetszv2/account/all-account-balancezv2/spot/wallet/deposit-addresszv2/spot/wallet/deposit-recordsz!v2/spot/wallet/withdrawal-recordszspot/v1/wallet/transferzspot/v1/wallet/transfer-v2zspot/v1/wallet/subTransfer
   zspot/v1/wallet/withdrawalzspot/v1/wallet/withdrawal-v2zspot/v1/wallet/withdrawal-innerz"spot/v1/wallet/withdrawal-inner-v2z'spot/v1/account/sub-account-spot-assets   zspot/v1/account/billszspot/v1/trade/orderszspot/v1/trade/batch-orderszspot/v1/trade/cancel-orderzspot/v1/trade/cancel-order-v2z!spot/v1/trade/cancel-symbol-orderz!spot/v1/trade/cancel-batch-ordersz$spot/v1/trade/cancel-batch-orders-v2zspot/v1/trade/orderInfozspot/v1/trade/open-orderszspot/v1/trade/historyzspot/v1/trade/fillszspot/v1/plan/placePlanzspot/v1/plan/modifyPlanzspot/v1/plan/cancelPlanzspot/v1/plan/currentPlanzspot/v1/plan/historyPlanzspot/v1/plan/batchCancelPlanzspot/v1/convert/quoted-pricezspot/v1/convert/tradezspot/v1/loan/borrowzspot/v1/loan/repayzspot/v1/loan/revise-pledgez$spot/v1/trace/order/orderCurrentListz$spot/v1/trace/order/orderHistoryListz&spot/v1/trace/order/closeTrackingOrderzspot/v1/trace/order/updateTpslz$spot/v1/trace/order/followerEndOrderz spot/v1/trace/order/spotInfoListz&spot/v1/trace/config/getTraderSettingsz(spot/v1/trace/config/getFollowerSettingszspot/v1/trace/user/myTradersz&spot/v1/trace/config/setFollowerConfigzspot/v1/trace/user/myFollowersz#spot/v1/trace/config/setProductCodezspot/v1/trace/user/removeTraderz"spot/v1/trace/getRemovableFollowerz!spot/v1/trace/user/removeFollowerz$spot/v1/trace/profit/totalProfitInfoz$spot/v1/trace/profit/totalProfitListz"spot/v1/trace/profit/profitHisListz(spot/v1/trace/profit/profitHisDetailListz)spot/v1/trace/profit/waitProfitDetailListz spot/v1/trace/user/getTraderInfozv2/spot/trade/place-orderzv2/spot/trade/cancel-orderzv2/spot/trade/batch-ordersz v2/spot/trade/batch-cancel-orderz!v2/spot/trade/cancel-symbol-orderzv2/spot/trade/place-plan-orderzv2/spot/trade/modify-plan-orderzv2/spot/trade/cancel-plan-orderz"v2/spot/trade/cancel-replace-orderz%v2/spot/trade/batch-cancel-plan-orderzv2/spot/wallet/transferz"v2/spot/wallet/subaccount-transferzv2/spot/wallet/withdrawalz v2/spot/wallet/cancel-withdrawalz%v2/spot/wallet/modify-deposit-account)r   postzmix/v1/account/accountzmix/v1/account/accountszmix/v1/position/singlePositionz!mix/v1/position/singlePosition-v2zmix/v1/position/allPositionzmix/v1/position/allPosition-v2z mix/v1/position/history-positionzmix/v1/account/accountBillz"mix/v1/account/accountBusinessBillzmix/v1/order/currentzmix/v1/order/marginCoinCurrentzmix/v1/order/historyzmix/v1/order/historyProductTypezmix/v1/order/detailzmix/v1/order/fillszmix/v1/order/allFillszmix/v1/plan/currentPlanzmix/v1/plan/historyPlanzmix/v1/trace/currentTrackzmix/v1/trace/followerOrderz"mix/v1/trace/followerHistoryOrderszmix/v1/trace/historyTrackzmix/v1/trace/summaryz%mix/v1/trace/profitSettleTokenIdGroupz mix/v1/trace/profitDateGroupListzmix/v1/trade/profitDateListzmix/v1/trace/waitProfitDateListzmix/v1/trace/traderSymbolszmix/v1/trace/traderListzmix/v1/trace/traderDetailzmix/v1/trace/queryTraceConfigzv2/mix/account/accountzv2/mix/account/accountsz!v2/mix/account/sub-account-assets)zv2/mix/account/open-countzv2/mix/account/billr   zv2/mix/position/single-positionzv2/mix/position/all-positionz v2/mix/position/history-positionzv2/mix/order/detailzv2/mix/order/fillszv2/mix/order/fill-historyzv2/mix/order/orders-pendingzv2/mix/order/orders-historyz v2/mix/order/orders-plan-pendingz v2/mix/order/orders-plan-historyz!v2/mix/market/position-long-shortz*mix/v1/account/sub-account-contract-assetszmix/v1/account/open-countzmix/v1/account/setLeveragezmix/v1/account/setMarginzmix/v1/account/setMarginModezmix/v1/account/setPositionModezmix/v1/order/placeOrderzmix/v1/order/batch-orderszmix/v1/order/cancel-orderz mix/v1/order/cancel-batch-orderszmix/v1/order/modifyOrderz!mix/v1/order/cancel-symbol-orderszmix/v1/order/cancel-all-ordersz mix/v1/order/close-all-positionszmix/v1/plan/placePlanzmix/v1/plan/modifyPlanzmix/v1/plan/modifyPlanPresetzmix/v1/plan/placeTPSLzmix/v1/plan/placeTrailStopzmix/v1/plan/placePositionsTPSLzmix/v1/plan/modifyTPSLPlanzmix/v1/plan/cancelPlanzmix/v1/plan/cancelSymbolPlanzmix/v1/plan/cancelAllPlanzmix/v1/trace/closeTrackOrderzmix/v1/trace/modifyTPSLz$mix/v1/trace/closeTrackOrderBySymbolzmix/v1/trace/setUpCopySymbolsz(mix/v1/trace/followerSetBatchTraceConfigz&mix/v1/trace/followerCloseByTrackingNozmix/v1/trace/followerCloseByAllzmix/v1/trace/followerSetTpslzmix/v1/trace/cancelCopyTraderzmix/v1/trace/traderUpdateConfigzmix/v1/trace/myTraderListzmix/v1/trace/myFollowerListzmix/v1/trace/removeFollowerz%mix/v1/trace/public/getFollowerConfigz%mix/v1/trace/report/order/historyListz%mix/v1/trace/report/order/currentListz'mix/v1/trace/queryTraderTpslRatioConfigz(mix/v1/trace/traderUpdateTpslRatioConfigzv2/mix/account/set-leveragezv2/mix/account/set-marginzv2/mix/account/set-margin-modez v2/mix/account/set-position-modezv2/mix/order/place-orderzv2/mix/order/click-backhandzv2/mix/order/batch-place-orderzv2/mix/order/modify-orderzv2/mix/order/cancel-order)z v2/mix/order/batch-cancel-orderszv2/mix/order/close-positionszv2/mix/order/place-tpsl-orderzv2/mix/order/place-plan-orderzv2/mix/order/modify-tpsl-orderzv2/mix/order/modify-plan-orderzv2/mix/order/cancel-plan-order)	zuser/v1/fee/queryzuser/v1/sub/virtual-listzuser/v1/sub/virtual-api-listzuser/v1/tax/spot-recordzuser/v1/tax/future-recordzuser/v1/tax/margin-recordzuser/v1/tax/p2p-recordzv2/user/virtual-subaccount-listz&v2/user/virtual-subaccount-apikey-list)
zuser/v1/sub/virtual-createzuser/v1/sub/virtual-modifyz$user/v1/sub/virtual-api-batch-createzuser/v1/sub/virtual-api-createzuser/v1/sub/virtual-api-modifyz!v2/user/create-virtual-subaccountz!v2/user/modify-virtual-subaccountz*v2/user/batch-create-subaccount-and-apikeyz(v2/user/create-virtual-subaccount-apikeyz(v2/user/modify-virtual-subaccount-apikey)zp2p/v1/merchant/merchantListzp2p/v1/merchant/merchantInfozp2p/v1/merchant/advListzp2p/v1/merchant/orderListzv2/p2p/merchantListzv2/p2p/merchantInfozv2/p2p/orderListzv2/p2p/advList)zbroker/v1/account/infozbroker/v1/account/sub-listzbroker/v1/account/sub-emailz!broker/v1/account/sub-spot-assetsz#broker/v1/account/sub-future-assetsz%broker/v1/account/subaccount-transferz$broker/v1/account/subaccount-depositz'broker/v1/account/subaccount-withdrawalzbroker/v1/account/sub-api-listzv2/broker/account/infoz!v2/broker/account/subaccount-listz"v2/broker/account/subaccount-emailz(v2/broker/account/subaccount-spot-assetsz*v2/broker/account/subaccount-future-assetsz'v2/broker/manage/subaccount-apikey-listzbroker/v1/account/sub-createzbroker/v1/account/sub-modifyz"broker/v1/account/sub-modify-emailzbroker/v1/account/sub-addressz broker/v1/account/sub-withdrawalz#broker/v1/account/sub-auto-transferz broker/v1/account/sub-api-createz broker/v1/account/sub-api-modifyz)v2/broker/account/modify-subaccount-emailz#v2/broker/account/create-subaccountz#v2/broker/account/modify-subaccountz$v2/broker/account/subaccount-addressz'v2/broker/account/subaccount-withdrawalz-v2/broker/account/set-subaccount-autotransferz)v2/broker/manage/create-subaccount-apikeyz)v2/broker/manage/modify-subaccount-apikeyz margin/v1/cross/account/riskRatez,margin/v1/cross/account/maxTransferOutAmountz/margin/v1/isolated/account/maxTransferOutAmountz#margin/v1/isolated/order/openOrdersz margin/v1/isolated/order/historyzmargin/v1/isolated/order/fillszmargin/v1/isolated/loan/listzmargin/v1/isolated/repay/listz margin/v1/isolated/interest/listz#margin/v1/isolated/liquidation/listzmargin/v1/isolated/fin/listz margin/v1/cross/order/openOrderszmargin/v1/cross/order/historyzmargin/v1/cross/order/fillszmargin/v1/cross/loan/listzmargin/v1/cross/repay/listzmargin/v1/cross/interest/listz margin/v1/cross/liquidation/listzmargin/v1/cross/fin/listzmargin/v1/cross/account/assetsz!margin/v1/isolated/account/assetsz v2/margin/crossed/borrow-historyzv2/margin/crossed/repay-historyz"v2/margin/crossed/interest-historyz%v2/margin/crossed/liquidation-historyz#v2/margin/crossed/financial-recordsz v2/margin/crossed/account/assetsz#v2/margin/crossed/account/risk-ratez/v2/margin/crossed/account/max-borrowable-amountz1v2/margin/crossed/account/max-transfer-out-amountz)v2/margin/crossed/interest-rate-and-limitzv2/margin/crossed/tier-datazv2/margin/crossed/open-ordersz v2/margin/crossed/history-orders)zv2/margin/crossed/fillsz!v2/margin/isolated/borrow-historyz v2/margin/isolated/repay-historyz#v2/margin/isolated/interest-historyz&v2/margin/isolated/liquidation-historyz$v2/margin/isolated/financial-recordsz!v2/margin/isolated/account/assetsz$v2/margin/isolated/account/risk-ratez0v2/margin/isolated/account/max-borrowable-amountz2v2/margin/isolated/account/max-transfer-out-amountz*v2/margin/isolated/interest-rate-and-limitzv2/margin/isolated/tier-datazv2/margin/isolated/open-ordersz!v2/margin/isolated/history-orderszv2/margin/isolated/fillszmargin/v1/cross/account/borrowz!margin/v1/isolated/account/borrowzmargin/v1/cross/account/repayz margin/v1/isolated/account/repayz#margin/v1/isolated/account/riskRatez+margin/v1/cross/account/maxBorrowableAmountz.margin/v1/isolated/account/maxBorrowableAmountz%margin/v1/isolated/account/flashRepayz0margin/v1/isolated/account/queryFlashRepayStatusz"margin/v1/cross/account/flashRepayz-margin/v1/cross/account/queryFlashRepayStatusz#margin/v1/isolated/order/placeOrderz(margin/v1/isolated/order/batchPlaceOrderz$margin/v1/isolated/order/cancelOrderz)margin/v1/isolated/order/batchCancelOrderz margin/v1/cross/order/placeOrderz%margin/v1/cross/order/batchPlaceOrderz!margin/v1/cross/order/cancelOrderz&margin/v1/cross/order/batchCancelOrderz v2/margin/crossed/account/borrowzv2/margin/crossed/account/repayz%v2/margin/crossed/account/flash-repayz2v2/margin/crossed/account/query-flash-repay-statuszv2/margin/crossed/place-orderz#v2/margin/crossed/batch-place-orderzv2/margin/crossed/cancel-orderz$v2/margin/crossed/batch-cancel-orderz!v2/margin/isolated/account/borrowz v2/margin/isolated/account/repayz&v2/margin/isolated/account/flash-repayz3v2/margin/isolated/account/query-flash-repay-statuszv2/margin/isolated/place-orderz$v2/margin/isolated/batch-place-orderzv2/margin/isolated/cancel-orderz%v2/margin/isolated/batch-cancel-orderz&v2/copy/mix-trader/order-current-trackz&v2/copy/mix-trader/order-history-trackz%v2/copy/mix-trader/order-total-detailz*v2/copy/mix-trader/profit-history-summarysz)v2/copy/mix-trader/profit-history-detailsz!v2/copy/mix-trader/profit-detailsz*v2/copy/mix-trader/profits-group-coin-datez'v2/copy/mix-trader/config-query-symbolsz)v2/copy/mix-trader/config-query-followersz)v2/copy/mix-follower/query-current-ordersz)v2/copy/mix-follower/query-history-ordersz#v2/copy/mix-follower/query-settingsz"v2/copy/mix-follower/query-tradersz)v2/copy/mix-follower/query-quantity-limitz v2/copy/mix-broker/query-tradersz'v2/copy/mix-broker/query-history-tracesz'v2/copy/mix-broker/query-current-traces)z#v2/copy/spot-trader/profit-summarysz*v2/copy/spot-trader/profit-history-detailsz"v2/copy/spot-trader/profit-detailsz&v2/copy/spot-trader/order-total-detailz'v2/copy/spot-trader/order-history-trackz'v2/copy/spot-trader/order-current-trackz)v2/copy/spot-trader/config-query-settingsz*v2/copy/spot-trader/config-query-followersz#v2/copy/spot-follower/query-tradersz*v2/copy/spot-follower/query-trader-symbolsz$v2/copy/spot-follower/query-settingsz*v2/copy/spot-follower/query-history-ordersz*v2/copy/spot-follower/query-current-ordersz$v2/copy/mix-trader/order-modify-tpslz(v2/copy/mix-trader/order-close-positionsz)v2/copy/mix-trader/config-setting-symbolsz&v2/copy/mix-trader/config-setting-basez)v2/copy/mix-trader/config-remove-followerz!v2/copy/mix-follower/setting-tpslzv2/copy/mix-follower/settingsz$v2/copy/mix-follower/close-positionsz"v2/copy/mix-follower/cancel-traderz%v2/copy/spot-trader/order-modify-tpslz(v2/copy/spot-trader/order-close-trackingz*v2/copy/spot-trader/config-setting-symbolsz*v2/copy/spot-trader/config-remove-followerz v2/copy/spot-follower/stop-orderzv2/copy/spot-follower/settingsz"v2/copy/spot-follower/setting-tpslz*v2/copy/spot-follower/order-close-trackingz#v2/copy/spot-follower/cancel-trader)zv2/tax/spot-recordzv2/tax/future-recordzv2/tax/margin-recordzv2/tax/p2p-record)zv2/convert/currencieszv2/convert/quoted-pricezv2/convert/convert-recordz v2/convert/bgb-convert-coin-listzv2/convert/bgb-convert-records)zv2/convert/tradezv2/convert/bgb-convertzv2/earn/savings/productzv2/earn/savings/accountzv2/earn/savings/assetszv2/earn/savings/recordszv2/earn/savings/subscribe-infoz v2/earn/savings/subscribe-resultzv2/earn/savings/redeem-resultzv2/earn/sharkfin/productzv2/earn/sharkfin/accountzv2/earn/sharkfin/assetszv2/earn/sharkfin/recordszv2/earn/sharkfin/subscribe-infoz!v2/earn/sharkfin/subscribe-resultzv2/earn/loan/ongoing-orderszv2/earn/loan/repay-historyzv2/earn/loan/revise-historyzv2/earn/loan/borrow-history)zv2/earn/loan/debtszv2/earn/loan/reduceszv2/earn/account/assets)zv2/earn/savings/subscribezv2/earn/savings/redeemzv2/earn/sharkfin/subscribezv2/earn/loan/borrowzv2/earn/loan/repayzv2/earn/loan/revise-pledgezv2/common/trade-ratezv3/account/assetszv3/account/settingszv3/account/deposit-recordszv3/account/financial-recordszv3/account/repayable-coinszv3/account/payment-coinszv3/account/convert-recordszv3/account/transferable-coinszv3/account/sub-transfer-recordzv3/ins-loan/transferedzv3/ins-loan/symbolszv3/ins-loan/risk-unitzv3/ins-loan/repaid-historyzv3/ins-loan/product-infoszv3/ins-loan/loan-orderzv3/ins-loan/ltv-convertz v3/ins-loan/ensure-coins-convert)
zv3/position/current-positionzv3/position/history-positionzv3/trade/order-infozv3/trade/unfilled-ordersz!v3/trade/unfilled-strategy-orderszv3/trade/history-ordersz v3/trade/history-strategy-orderszv3/trade/fillszv3/user/sub-listzv3/user/sub-api-listzv3/account/set-leveragezv3/account/set-hold-modezv3/account/repayzv3/account/transferzv3/account/sub-transferzv3/account/max-open-availablezv3/ins-loan/bind-uidzv3/trade/place-orderzv3/trade/place-strategy-orderzv3/trade/modify-orderzv3/trade/modify-strategy-orderzv3/trade/cancel-orderzv3/trade/cancel-strategy-orderzv3/trade/place-batchzv3/trade/batch-modify-orderzv3/trade/cancel-batchzv3/trade/cancel-symbol-order)zv3/trade/close-positionszv3/user/create-subzv3/user/freeze-subzv3/user/create-sub-apizv3/user/update-sub-apizv3/user/delete-sub-api)rR   r   r   r   r   rS   r   r   r   r   r   r   )publicprivater   z0.002)takermaker0.0006z0.0004)rR   rT   requiredCredentials)apiKeysecretpassword
exceptions1z,failure to get a peer from the ring-balancer40104001400240020300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003832001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320383204032044320453204632047320483204932050320513205232053320573205432055320563205832059320603206132062320633206432065320663206732068320693207032071320723207332074320753207632077320783207932080320833300133002330033300433005330063300733008330093301033011330123301333014330153301633017330183302033021330223302333024330253302633027330283302933034330353303633037330383303933040330413304233043330443304533046330473304833049330503305133059330603306133062330633306433065210093400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340263403634037340383403935001350023500335004350053500835010350123501435015350173501935020350213502235024350253502635029350303503135032350373503935040350443504635047350483504935050350523505335055350573505835059350603506135062350633506435066350673506835069350703507135072350733507435075350763507735078350793508035081350823508335084350853508635087350883508935090350913509235093350943509535096350973509835099360013600236005361013610236103361043610536106361073610836109362013620236203362043620536206362073620836209362103621136212362133621436216362173621836219362203622136222362233622436225362263622736228362293623040040140340440541542950010011002100340001400024000340004400054000640007400084000940010400114001240013400144001540016400174001840019400314003740102401034010440105401064010740108401094020040201402024020340204402054020640207402084020940300403014030240303403044030540306403084030940400404014040240403404044040540406404074040840409405004050140502405034050440505405064050740508405094060040601406024060340604406054060640607406084060940700407014070240703407044070540706407074070840709407104071140712407134071440762407684080841103411144301143001430124302543115451104077445122zinvalid signzinvalid currencyzinvalid symbolzinvalid periodzinvalid userzinvalid amountzinvalid typezinvalid orderIdzinvalid recordzinvalid accountIdzinvalid addresszaccesskey not Nonezillegal accesskeyzsign not nullz0req_time is too much difference from server timezpermissions not rightzillegal sign invalidzuser lockedzRequest Frequency Is Too Highzmore than a daily rate of cashz-more than the maximum daily withdrawal amountzneed to bind email or mobilezuser forbidzUser Prohibited Cash Withdrawalz.Cash Withdrawal Is Less Than The Minimum Valuez.Cash Withdrawal Is More Than The Maximum Valuez%the account with in 24 hours ban coinzorder cancel failzbase symbol errorzbase date errorzapi signature not validzgateway internal errorzaudit failedzorder queryorder invalidzmarket no need pricezlimit need pricezuserid not equal to account_idzyour balance is lowzaddress invalid cointypezsystem exception50003500045000650007500085000950010500145001550016500175001850019500205002150026zinvalid order query timezinvalid start timezinvalid end time200030100143111zinvalid size, valid range)exactbroadprecisionModecommonCurrencies
AstroPepeXDegenRebornEvadorezJade ProtocolomniTON)APXDEGENEVAJADEOMNITONCOINr   timeDifferencer   adjustForTimeDifference1min5min3min15min30min6Hutc12Hutc1Dutc3Dutc1Wutc1Mutc)r   r   r   r   r   r   r   r   r   r   r   r   r   1H2H4H6H12H1D)r   r   r   r   r   r   r   r   r   r   r   )rR   rT   r   typesdefaultTypedefaultSubTypelinear!createMarketBuyOrderRequiresPricer   p4svefillResponseFromRequest   <   x      ih  i  i  i  i`'  i  i,  d   )r   r   r   r    publicSpotGetV2SpotMarketCandles)maxLimitPerTimeframemethodi     Z      )r   r   r   r   r   r   r   publicMixGetV2MixMarketCandles)maxRecentDaysPerTimeframerR   rT   r  %publicSpotGetV2SpotMarketFillsHistory#publicMixGetV2MixMarketFillsHistory&publicMixGetV2MixMarketCurrentFundRateaccountsByTypecrossed_marginisolated_marginusdt_futuresusdc_futurescoin_futuresr   )rR   crossisolatedrT   	usdc_swaprU   r   accountsByIdr  r  r   )rR   r  r  r  r  r  r   sandboxModenetworksTRC20ERC20BEP20BSCATOMACA
AcalaTokenAPTAptosARBONEArbitrumOneARBNOVAArbitrumNovaAVAXCzC-ChainAVAXXzX-ChainARArweaveBCHBCHABITCIBTCCELOCSPRADACardanoCHZChilizChainCRC20CronosChainDOGEDOTEOSETHFETHFAIRETHWETCEGLDElrondFILFIOFTMFantomHRC20HECOONEHarmonyHNTHeliumICPIOTXIoTeXKARDIAKAIKAVAKDAKLAYKlaytnKSMKusamaLATLTCMINAMOVRMETIS
MetisTokenGLMRMoonbeamNEARNEARProtocolNULSOASYSOASISROSEr  ONTOntologyOPTIMISMOptimismOSMOOsmosisPOKTPocketNetworkMATICPolygonQTUMREEFSOLSYSSXPSolarXYMSymbolTTTLOSTelosTHETA
ThetaTokenVITEWAVESWAXWAXPWEMIXWEMIXMainnetXDCXDCNetworkXDCXRPFETFETCHNEMREI
REINetworkZILABBCABBCCoinRSKAZEROTRC10JUNOZKSYNC	zkSyncEraSTARKNETStarknetVICVICTION%privateMixGetV2MixPositionAllPositionGTC)EURVNDPLNCZKHUFDKKAUDCADNOKSEKCHFMXNCOPARSGBPBRLUAHZAR)networksByIdr   defaultTimeInForcefiatCurrencies)lastmarkindex)triggerPriceTypeprice)IOCFOKPOGTD)
marginModetriggerPricer  triggerDirectionstopLossPricetakeProfitPriceattachedStopLossTakeProfittimeInForcehedgedtrailingmarketBuyRequiresPricemarketBuyByCostmax)r  limitdaysBack	untilDayssymbolRequired)r  triggerr  r  )r  r  r  r  r  )r  r  r  daysBackCanceledr  r  r  r  r  )	sandboxrd   re   r   r   r   r   ry   r   )r  r  r  r  r  r  r  r  r  r  r  r     r  )extendsrd   r   ry   r  forPerps)r  inverse)rR   r  rT   rU   )optionsfeatures)deep_extendsuperrA   describeparse_numberr+   r9   r-   r0   r,   r;   r<   r7   r1   r.   r:   r=   r4   r/   r2   r5   r3   r8   r>   )self	__class__s    S/home/james-whalen/.local/lib/python3.13/site-packages/ccxt/async_support/bitget.pyr  bitget.describe&   sE   fd < > eA
(eA
HeA
 $eA
 t	eA

 eA
 eA
 4eA
  www $w 	w
 $w %w Tw $Tw 'w "4w tw w $Tw  w %dw  '!w" /#w$ ,U%w& 0'w( t)w* +w, 7-w. &t/w0 (1w2 '3w4 &t5w6 (7w8 "49w: (;w< ,U=w> -d?w@ %dAwB TCwD  EwF GwH &tIwJ +EKwL )%MwN /OwP &tQwR $TSwT )$UwV $TWwX $UYwZ +D[w\ ']w^ (_w` "4awb cwd &tewf (gwh 1%iwj  kwl +Emwn *:owp +Dqwr &tswt 'uwv (wwx #Dywz *4{w| $T}w~ "4w@ *4AwB +ECwD tEwF  GwH %eIwJ $UKwL &uMwN -dOwP /QwR "4SwT +DUwV WwX !$YwZ !$[w\ &t]w^  _w` dawb $Tcwd +Eewf "4gwh diwj !$kwl "5mwn uowp #Eqwr  swt '
uwv $Uwwx !$ywz ({w| %e}w~ )%w@ uAwB tCwD EwF TGwH tIwJ "4KwL #DMwN $UOwP  QwR !$SwT )%UwV "5WwX #DYwZ [w\ #D]w^ &t_w` tawb Ucwd  ewf "4gwh %iwj Dkwl DmweA
@ AeA
` aeA
b i434366637443 0 Ak? ceA
d  67./    <a 11  8  6q	 
 5a  4Q  5a  3A  ;A  5a  3A  <Q  9!  =a  <Q   @! " 3F# $ 78;<67:;8967>?45<=5 >  ( 5q( 11(  3A(  4Q	( 
 ?(  21(  :1(  4Q(  21(  9!(  =a(  =a(  :1(  7(  <Q(   ?!( " 7#( $ <Q%( & B1'( ( A!)( * 8+( , 9!-( . 8/( 0 3A1( 2 4Q3( 4 215( 6 :17( 8 4Q9( : <Q;( < B1=( > A!?( @ :1A( B 9!C( D 9!E( F @A?@78BC@BO( *X KLNO?@BC;<45AC 
 =>AB  561234/078129:;<;<6778677823 Csl  <a  <a   :1   6r	  
 5a   :1   >q   9!   =a   :1   9!   :1   :1   1!   6q    <Q!  " ;A#  $ 45@A@A4667AB56?@9:56>@>?>?AB?  BD!5qD!8!D! 9"D! 8	D!
 ;AD! >qD! A!D! FsD! 4QD! 3AD! 9!D! 9!D! <QD! @D! @D!  CA!D!" 6q#D!$ 8%D!& 4Q'D!( 21)D!* 5a+D!, 6q-D!. 6q/D!0 71D!2 73D!4 ;A5D!6 ;A7D!8 4Q9D!: 21;D!< 1!=D!> 9!?D!@ CAAD!B CACD!D EaED!F =aGD!H CAID!J ?KD!L EaMD!N GOD!P ;AQD!R EaSD!T =aUD!V B1WD!X >qYD!Z A![D!\ @]D!^ CA_D!` CAaD!b A!cD!d GeD!f HgD!h ?iD!j 8kD!l 9!mD!n 9"oD!p ?qD!r @sD!t =auD!v >qwD!x >qyD!z A!{D!| DQ}D!~ 6qD!@ A!AD!B 8CD!D ?ED!F DQGD!EgR1 4a1 5q1  =a1  @	1 
 :11  =a1  ?1  9!1  A!1  3A1  =a1  3A1  >q1  211  1!1   4Q!1 " 6q#1 $ 6q%1 & 8'1 ( 9!)1 * A!+1 , 8-1 . 3A/1 0 DQ11 2 ?31 4 :151 6 >q71 8 9!91 : 6q;1 < 8=1 > <Q?1 @ 5aA1 B 6qC1 D @E1 F :;34BC?@<=@A34239:;<;<@A@AACa1 d;!H#;!7;! 9!;! 7	;!
 ;A;! =a;! 6q;! 8;! 8;! ?;! 7;! @;! =a;! ?;! 4Q;!  5a!;!" ;A#;!$ 4Q%;!& 9!';!( =a);!* 9!+;!, 5a-;!. ;A/;!0 81;!2 ;A3;!4 6q5;!6 CA7;!8 <Q9;!: G;;!< Ea=;!> >q?;!@ ;AA;!B <QC;!D >qE;!F 8G;!H :1I;!J :1K;!L DQM;!N DQO;!P DQQ;!R FqS;!T GU;!V :1W;!X 8Y;!Z =a[;!\ ?];!^ 7_;!` :2a;!b =bc;!d 8e;!f 8g;!h AB<>=>=>>?>?>?u;!god 2389<=789:9:67?@FG
  ;<:;DF>?>?ABABJLHIHI!4 <=<=789:343401./	  78:<;=ABCDEFDEGH>?67ACBCHIJKGH "!:B!:B! A"! <Q	!
 ?! B1! ?! ?! H! B2! B2! CA! Fq! LQ! H!  H!!%$L2 >2 JA2  Nq2  B1	2 
 ?2  =a2  ;A2  <Q2  ?2  B12  :12  ?2  <Q2  :12  82   9!!2 " <Q#2 $ ?%2 & 7'2 ( =a)2 * @+2 , ?-2 . >q/2 0 A!12 2 DQ32 4 B152 6 ?72 8 B192 : Nq;2 < PQR=2 > H?2 @ :1A2 B <QC2 D ?E2 F 89AB@ACDFGDEABDEPQRSJK<=>?AB89c2 f$!<a$!?$! <Q$! ?	$!
 B1$! J1$! Ma$! DQ$! OPQ$! A!$! LQ$! B1$! G$! CA$! H$!  ?!$!" DQ#$!$ @%$!& Ea'$!( ?)$!* >q+$!, DQ-$!. QRS/$!0 <Q1$!2 B13$!4 =a5$!6 CA7$!8 @9$!: ?;$!< Ea=$!> RST?$!@ =aA$!B CAC$!D >qE$!F DQG$!iYv Da Da  DQ  I!	 
 H  @  I!  Fq  H  H  H  B1  A!  H  ?   Fq! " Fq# $ DEJKBCFGGHGHIJJKCDJKDEJKJK= @!BA!F! H! Ea	!
 H! @! <Q! CA! A!! DQ! G! I!! I!! ?! =a!  A!!!" I!#!$ B1%!C5n 24464613	  67789:@A>?  1267!  5q 5q  5a  6q	 
 =a  ?  <Q  7  7  6q  7  >q  @  :1  9!   :1! " :1# $ 344567) . :;67:;3423:;!/B 2A  / 11  9!  ;A	 
 9!  7  9!  <Q  =a  5f  26  4V  9&  8  5f   6v! " ?# $ =><=3489AB78@A./01457 :!5q!6! /! 21	!
 6q! <Q! 3F! 3A! <Q! 4Q! =a! 4Q! =a! 3A! :1!  4Q!!" ;A#!$ 9:2323676767/!=7[ek[
eeA
\ !..w7!..w7
 "..x8!..x8	]eA
p " $qeA
z || CDX| ,	| M| M| Z| 0| 0| 0| 0| \|  0!|" Z#|$ ^%|& ]'|( 0)|* -+|, 0-|. 0/|0 ^1|2 03|4 ]5|6 ]7|8 ]9|: 1;|< Z=|> Z?|@ -A|B ZC|D YE|F ZG|H ^I|J 0K|L -M|N -O|P ]Q|R ZS|T YU|V ZW|X ]Y|Z ][|\ ]]|^ 1_|b ]c|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 0e|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|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 ][|\ 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 ZS|T ZU|V ]W|X ]Y|Z ][|\ ]]|^ ]_|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 0G|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 0g|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 Zg|h Zi|j Zk|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 Zm|n ]o|p ]q|r ]s|t ]u|x Zy|z Z{|| ]}|~ 0|@	 -A	|B	 -C	|D	 -E	|F	 -G	|H	 -I	|J	 -K	|L	 .M	|N	 -O	|P	 -Q	|R	 -S	|T	 \U	|V	 ]W	|X	 ZY	|Z	 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
|N
 :O
|P
 .Q
|R
 +S
|T
 :U
|V
 :W
|X
 :Y
|Z
 >[
|\
 /]
|^
 -_
|`
 Ma
|b
 Mc
|f
 0g
|h
 0i
|j
 0k
|l
 \m
|n
 \o
|p
 0q
|r
 Zs
|t
 \u
|v
 0w
|x
 0y
|z
 0{
||
 0}
|~
 ]
|@ -A|B ]C|D -E|F ]G|H -I|J ZK|L -M|N 0O|P ZQ|R ZS|T ]U|V ]W|X ]Y|Z ][|\ \]|^ ]_|` ]a|b \c|d ]e|f Zg|h Zi|j Zk|l Zm|n Zo|p Zq|r Zs|t ]u|v -w|x Zy|z Z{|| Z}|~ Z|@ ]A|B ]C|D YE|F ]G|H ]I|J ZK|L ZM|N ZO|P ZQ|R ZS|T ]U|V ]W|X ]Y|Z \[|\ ]]|^ ]_|` ]a|b ]c|d ]e|f 0g|h 0i|j ]k|l ]m|n ]o|p ]q|r ]s|t ]u|v 1w|x ]y|z ]{|| ]}|~ ]|@ ]A|B ZC|D ]E|F ]G|H ]I|J ]K|L ZM|N \O|P ZQ|R ZS|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|| #$7}|~ '	|@ %iA|B %jC|D #ME|F %lG|H #LI|J &|K|L %mM|N (O|P &zQ|R )*=S|T ()<U|V $%8W|X GY|Z ,-=[|\ +,?]|^ "#3_|` 45Fa|b 5jc|d DZe|f 3Mg|h "#3i|j 67Gk|l Ejm|n Ejo|p <=Mq|r (s|t (u|v &}w|x ./By|z -m{|| #M}|~ /
|@ +LA|B 'C|D 5mE|F *+<G|H /I|J 'K|L ]M|N YO|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|| 0IG{eA
J+ YK+eA
L+ #& ' !M+eA
\+mum !m *5m $$$&&""%'%%%%  #""$$"""%'%%%%" #""$$""""$"A-	md ff-!emj vkml !(mmn 4Tomp 'qmr -tsmx 
 !  !! !!!""&&'2$ #&"%"%"%	1 #E #&"%#&"$"$"$"#1 #C;)ymL  "I !"G	 Mm\ #F%]mb !"- 1*!/, #cmt "&-'1$*$/$, !umF uGmH  `W` W	`
 U` F` <` 7` m` ~` Y` Y` )` 5`  F!`" W#`$ 5%`& F'`( F)`* 9+`, =-`. ]/`0 F1`2 53`4 55`6 I7`8 F9`: 5;`< H=`> 5?`@ 5A`B 8C`D VE`F 9G`H 8I`J 5K`L GM`N eO`P FQ`R 5S`T HU`V 8W`X 5Y`Z 5[`\ F]`^ F_`` \a`b Jc`d Ne`f Fg`h Wi`j Vk`l Fm`n :o`p 
q`r Is`t Ou`v Yw`x Fy`z F{`| 5}`~ 5`@ 7A`B 8C`D 5E`F $G`H GI`J \K`L FM`N WO`P 6Q`R ^S`T ?U`V 5W`X 7Y`Z 5[`\ <]`^ 5_`` Ja`b 5c`d We`f Wg`h Fi`z k{`| 
}`~ 9`ImJ! E# ', #aYm`  $&*(,$($(%*-
 -2)-+/ ).(-).1
 &*7 $(#'"&#(	( #($)26+/9"$H r% '+!$$(%'*.& ',#($)*.	# '+!$#'$)*/( $(&*!$$(,0%'#'$)*/	*  #OJX  &(,$($(%*-
 -2)-+/ )-(,)-1
 &+7 $(#'"&#(	( #'$(27+07"$H $Q& #D*Q+\ ": ": 	 ": ": 	AHy2eA
 e e	    enabledc                      XR                   S'   g)r
       enables or disables demo trading mode, if enabled will send PAPTRADING=1 in headers
@param enabled
       r  N)r  r  r  s     r  set_sandbox_modebitget.set_sandbox_mode  s    
 '.]#r  c                 &    U R                  U5        g)r  N)r  r  s     r  enable_demo_tradingbitget.enable_demo_trading  s    
 	g&r  Nc                    S nU R                  SS U5      u  p2S nUb  Uc
  US:X  a  SOSnU R                  USSU5      nUcl  Ubi  US   nUS   (       a  S nU R                  SU5      u  prUb  S	nO>S
nO;US:X  a  SnO2US:X  a  SnO)US:X  a  SnO US:X  a  SnOUS:X  d  US:X  d  US:X  a  SnOSnUc  [        U R                  S-   5      eU R                  USS/5      nXR/$ )NhandleProductTypeAndParamsr  USDT-FUTURESCOIN-FUTURESproductTypecategorysettlerR   MARGINSPOTUSDTUSDCUSDC-FUTURESSUSDTSUSDT-FUTURESSUSDCSUSDC-FUTURESSBTCSETHSEOSSCOIN-FUTURESz requires a productType param, one of "USDT-FUTURES", "USDC-FUTURES", "COIN-FUTURES", "SUSDT-FUTURES", "SUSDC-FUTURES", "SCOIN-FUTURES" or for uta only "SPOT")handle_sub_type_and_paramssafe_string_2handle_margin_mode_and_paramsr/   rE   omit)r  marketparamssubTypedefaultProductTyper  r  r  s           r  handle_product_type_and_params%bitget.handle_product_type_and_params  s9   99:VX\^de!fn 5<x4Gn((
L^_f&8H%Ff~!
%)%G%GHdfl%m"
)"*K"(K6!,6!,7"-7"-F"&(8f>N-,#DGG  /O  %O  P  P6M:#>?$$r  c                    #    U R                  U5      I Sh  vN nU R                  US0 5      nU R                  US5      $  N)7f)a1  
fetches the current integer timestamp in milliseconds from the exchange server

https://www.bitget.com/api-doc/common/public/Get-Server-Time

:param dict [params]: extra parameters specific to the exchange API endpoint
:returns int: the current integer timestamp in milliseconds from the exchange server
Ndata
serverTime)publicCommonGetV2PublicTime
safe_valuesafe_integer)r  r  responser  s       r  
fetch_timebitget.fetch_timeC  sG      99&AA x4  |44 Bs   AA*Ac                   #    U R                   S   (       a  U R                  5       I Sh  vN   SnU R                  USSS5      u  p!U(       a  U R                  U5      I Sh  vN $ U R	                  U5      I Sh  vN $  NU N N7f)a  
retrieves data on all markets for bitget

https://www.bitget.com/api-doc/spot/market/Get-Symbols
https://www.bitget.com/api-doc/contract/market/Get-All-Symbols-Contracts
https://www.bitget.com/api-doc/margin/common/support-currencies
https://www.bitget.com/api-doc/uta/public/Instruments

:param dict [params]: extra parameters specific to the exchange API endpoint
:param boolean [params.uta]: set to True for the unified trading account(uta), defaults to False
:returns dict[]: an array of objects representing market data
r  Nr   r   F)r  load_time_differencehandle_option_and_paramsfetch_uta_marketsfetch_default_markets)r  r  r   s      r  fetch_marketsbitget.fetch_marketsZ  s|      <<12++---33FNESXY//77733F;;; . 8;s3   (BB 7B"B#B;B<BBBc                   #    S nU R                  U R                  S5      nSS/nUb  U R                  USU5      nOU R                  U R                  SU5      n/ nSn[        S[	        U5      5       H  nX'   nUS:X  d  US:X  aV  / SQn	[        S[	        U	5      5       H7  n
UR                  U R                  U R                  US	X   05      5      5        M9     Mi  US:X  aD  UR                  U R                  U5      5        S
nUR                  U R                  U5      5        M  [        U R                  S-   U-   S-   5      e   [        R                  " U6 I S h  vN n/ n/ U R                  S'   / U R                  S'   [        S[	        U5      5       H  nU R                  X5      nU R                  US/ 5      nU R                  US0 5      nU R                  US5      nU(       aL  UbI  [        U R!                  US5      R#                  5       5      nUU R                  S'   UU R                  S'   M  U R%                  X5      nM     / 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S5      nU R)                  U5      nU R)                  U5      nU R+                  US/ 5      nS nU R-                  UU5      (       a  UnO,U R-                  UU5      (       a  UnOU R'                  US5      nU R)                  U5      nUS-   U-   nS nSnSnSnSn S n!S n"S n#S n$S n%S n&U R'                  US5      n'S n(Sn)U'c  SnS
nU R/                  U R1                  U R'                  US5      5      5      n!U R/                  U R1                  U R'                  US5      5      5      n"U R-                  UU R                  S   5      n*U R-                  UU R                  S   5      n+U*U+S.n(U*=(       d    U+n)GOU'S:X  a  SnS
nUS-   U-   nOU'S:X  a  U R3                  US5      n%U R5                  U%5      n&U&R7                  S5      n,U R'                  U,S5      n-U R'                  U,S5      n.U-SS  n/U R'                  U,S!5      n0U.SS n1U/U0-   U1-   n2SnS
nUS-   U-   S-   U2-   nS
n UU:H  n$U$(       + n#U R3                  US"5      n3U R3                  US#5      n4U R'                  US$5      n5U R'                  US%5      n6[9        U55      n7[;        U7R<                  U35      U7l        U7R?                  5         [A        U75      n8U R/                  U85      n![9        U65      n9[;        U9R<                  U45      U9l        U9R?                  5         [A        U95      n:U R/                  U:5      n"S
S
S.n(U RC                  US&S'5      n;S n<U;b  U;S(:H  =(       d    U;S):H  n<S n=US*:X  a  U RE                  US+5      n=U (       a  S!OS n>UR                  U RG                  0 S,U_SU_S-U_S.U_S/U_S0U_S1U_S2U_S3U_SU_S4U=(       a    U)_S5U(_SU_SU_S6S_S7U<_S8U _U#U$U RE                  US95      U RE                  US:5      U>U%U&S S U"U!S;.U RE                  US<5      U RE                  US=5      S>.U RI                  US?S@5      U RE                  USA5      S>.S S S>.U=S S>.SB.U R3                  USC5      USD.E5      5        GM     U$  GN7f)ENr   rR   rT   r  Fr   rU   )r  r  r  r  r  r  r  T does not support  marketcrossMarginPairsDataisolatedMarginPairsDatar  isBorrowablesymbol	quoteCoinbaseCoinsupportMarginCoins/
symbolTypepricePrecisionquantityPrecisionr  r  	perpetual:deliverydeliveryTime-r   r   r   
pricePlacevolumePlacepriceEndStepsizeMultiplierstatussymbolStatusonlinenormalr  minTradeUSDTrE   basequoter  baseIdquoteIdsettleIdtyperS   marginModesrV   activecontracttakerFeeRatemakerFeeRateamountr  minLevermaxLeverminr  minTradeNumminTradeAmountmaxTradeAmountleverager!  r  cost
launchTimer  r  r   r   contractSizeexpiryexpiryDatetimestrike
optionType	precisionlimitscreatedinfo)%	safe_dictr  	safe_listrangelenappend publicMixGetV2MixMarketContractsextend publicSpotGetV2SpotPublicSymbols!publicMarginGetV2MarginCurrenciesr6   rE   asynciogather	safe_boollistindex_bykeysarray_concatsafe_stringsafe_currency_coder  in_arrayr  parse_precisionr  iso8601splitr?   r  decimalsreducestrr  safe_numbersafe_market_structuresafe_number_2)?r  r  r  fetchMarketsOptionsdefaultMarketspromisesfetchMarginsir  subTypesjresultsmarketsresr  	firstDatar  keysListresultr  marketIdr  r  r  r  r  r  r  r  rT   rR   rU   r  r  amountPrecisionr  r  r/  r0  r  r  isMarginTradingAllowedhasCrossMarginhasIsolatedMarginexpiryPartsyearPartdayPartyearmonthdayexpiryStringpriceDecimalsamountDecimals	priceStep
amountStepprecisepriceStringpreciseAmountamountStringr  r  minCostr.  s?                                                                  r  r  bitget.fetch_default_marketsp  s    "nnT\\>J &)*NN#6PE NN4<<PEq#e*%A8DDH$4~q#h-0AOOD$I$I$++V\%x{_ K %  1  E Ef MN# F Fv NO"477-A#AD#H9#TUU &  11/1+,24./q#g,'A..,C>>#vr2DtQ3I>>)^DL 8dH = B B DE7?34:B67++G: (H q#g,'AZF''9H&&v{;G%%fj9F++G4E**62D!%9Mr!RH}}V%788!w(:;;"++,>B,,X6FCZ%'FDDDFH!N"OFGF!N))&,?JK%*"!!%!2!243G3GHXHXY_aqHr3s!t"&"3"3D4H4HIYIYZ`buIv4w"x!%xF\9]!^$(MM(DLLIb<c$d!+ 1 *8)L;L&,!DD#c\F2F:-!..v~FF%)\\&%9N"0"6"6s";K#//Q?H"..{A>G#Aa=D ,,[!<E!!A,C#'%<##5L#D!F#c\F2S8<GF6>$ $ 1 1&, G!%!2!26=!I ,,V^D	!--f6FG
!),#&w'7'7#G  !'l!%!2!2;!? '
 3),]-C-C^)T&$$&"=1"&"3"3L"A! $ ''.IFF!!X-F6X3EG**6>B (1dLMM$44 36h36&36 36 	36
 &36 &36 736 H36 36 36 $9#936 {36 36 &36 %36  &!36" H#36$ !"))&.A))&.A , "0"-+  $//
C#//
C!
  $11&-IYZ#//8HI
  $#
  '#$  ,,V\Be36 3 3u (\ o 2s   E\\V(\c                   #    / SQn/ n[        S[        U5      5       H9  nU R                  USX$   05      nUR                  U R	                  U5      5        M;     [
        R                  " U6 I S h  vN n/ n[        S[        U5      5       H8  nU R                  Xd5      nU R                  US/ 5      n	U R                  Xy5      nM:     / n
[        S[        U5      5       GH  nXt   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S nS nUS:X  a  S	nOUS
:X  a  SnOUS:X  a  UnUb  U R                  U5      nUS-   U-   nS nSnSnSnSnS nS nS nS nS nS nU R                  US5      n S n!Sn"US:H  n#U#(       d  US:X  a_  SnSnU#(       aS  U R                  US5      n$U R                  US5      n%U$S:H  =(       d    U%S:H  n&U R                  US5      n'U'S:g  n(U(U&S.n!Sn"OU S:X  a  SnSnUS-   U-   nOU S:X  a  U R                  US5      nU R                  U5      nUR                  S5      n)U R                  U)S5      n*U R                  U)S 5      n+U*S S! n,U R                  U)S"5      n-U+SS  n.U,U--   U.-   n/S#nSnUS-   U-   S-   U/-   nSnUU:H  nU(       + nSSS.n!U R                  U R!                  U R                  US$5      5      5      nU R                  U R!                  U R                  US%5      5      5      nU R                  US&5      n0S n1U0b  U0S':H  =(       d    U0S(:H  n1U(       a  S"OS n2U
R                  U R#                  0 S)U_SU_S*U_S+U_S,U_S-U_S.U_S/U_SU_SU_S0U=(       a    U"_S1U!_SU_S#U_S2S_S3U1_S4U_UUU R%                  US55      U R%                  US65      U2UUS S UUS7.U R%                  US85      U R%                  US95      S:.U R%                  US;5      U R%                  US<5      S:.S S S:.S S S:.S=.U R                  US>5      US?.E5      5        GM     U
$  GN7f)@N)r  r  r  r  r   r  r  r  r  r   r  r  r  r  r  r  Fr  r  r  rR   TisIsolatedBaseBorrowableisIsolatedQuotedBorrowableYESmaxCrossedLeverage0r  r  rT   r  r	  r
  r  r   r   r   rU   r  r  r  r  r  rE   r  r  r  r  r  r  rS   r  rV   r  r  r  r  r   minLeveragemaxLeverager$  minOrderQtymaxOrderQtyr)  r,  r-  )r9  r:  r=  r;  publicUtaGetV3MarketInstrumentsr@  rA  r7  r8  rF  rG  rH  r  rK  rL  r  rJ  rQ  rP  )3r  r  rX  rU  rW  reqrZ  r[  r\  r  r_  r  r  r`  r  r  r  r  r  r  r  r  rT   rR   rU   r  r  ra  r  r  r/  r0  r  r  rb  isUtaMarginisolatedBaseisolatedQuoter  maxCrossLeverager  re  rf  rg  rh  ri  rj  rk  r  r  r.  s3                                                      r  r  bitget.fetch_uta_marketsb  s    Kq#h-(A++fHK' C OOD@@EF	 )
  11q#g,'A..,C>>#vr2D''6G (z q#g,'AZF''
;H''9H&&v{;G%%fj9F++G4E**62DHF>)!^+!^+#00:CZ%'FDDDFH!N"OFGF!N))&&9JK%*"#x/Kx61#'#3#3F<V#WL$($4$4V=Y$ZM , 5R=E;QH'+'7'7@T'U$-4E!&$,#K .2*,!DD#c\F2F:-!..v~FF%)\\&%9N"0"6"6s";K#//Q?H"..{A>G#Aa=D ,,[!<E!!A,C#'%<##5L#D!F#c\F2S8<GF6>$! $ "..t/C/CDDTDTU[]mDn/opN"//0D0DTEUEUV\^qEr0stO%%fh7FF!!X-F6X3E (1dLMM$44 36h36&36 36 	36
 &36 &36 736 H36 36 36 $9#936 {36 36 &36 %36  &!36" H#36$ !"))&.A))&.A , "0"-+  $//F#//F!
  $//F#//F
  $#
  $#$  ,,V\Be36 3 3a (H I 2s   A/Q01Q-2O<Q0c                 L  #    U R                  U5      I Sh  vN n0 nU R                  US/ 5      nU R                  U R                  S/ 5      n[	        S[        U5      5       GH  nXF   nU R                  US5      nU R                  U5      n	U R                  US/ 5      n
0 nSnSn[        U
5      nUS:X  a  SnSn[	        SU5       H  nX   nU R                  US5      nU R                  UU	5      nUR                  5       nU R                  US	5      S
:H  nU R                  US5      S
:H  nUc  UO
U=(       d    UnUc  UO
U=(       d    UnUUUU R                  US5      SS.U R                  US5      SS.S.SUUU R                  US5      U R                  U R                  U R                  US5      5      5      S.	UU'   M     U=(       a    UnU R                  X5      nU R                  UUU	UU(       a  SOSSUUUSSSSS.SSS.SSS.S.SS.5      X9'   GM     U$  GN
7f)z
fetches all available currencies on an exchange

https://www.bitget.com/api-doc/spot/market/Get-Coin-List

:param dict [params]: extra parameters specific to the exchange API endpoint
:returns dict: an associative dictionary of currencies
Nr  r  r   coinchainsFchainwithdrawabletruerechargeableminWithdrawAmountr$  minDepositAmount)r   depositwithdrawFeewithdrawMinScale)	r6  rE   networkr4  r  r   r  feer3  fiatcryptor!  r   r  r6  rE   coder  r  rF   r  r  r   r  r3  r4  r5  )publicSpotGetV2SpotPublicCoinsr  r8  r  r9  r:  rG  rH  network_id_to_codeupperrP  r  rJ  rI  safe_currency_structure)r  r  r  r_  r  r  rW  entryrE   r  r  r  r   r  chainsLengthrY  r  	networkIdr  r  r  r  isFiats                          r  fetch_currenciesbitget.fetch_currenciesP	  s     <<VDDD x46FKq#d)$AGE!!%0B**2.D__UHb9FHHGv;Lq  1l+	 ,,UG<	11)TB!--/ $ 0 0 G6 Q $ 0 0 G6 Q,4,<<HD\P\+2?,'BY\!#& $(#3#3E;N#O#'%
 $(#3#3E;M#N#'$	 # ,+++E=A!%!2!243G3GHXHXY^`rHs3t!u%%! ,: )'F]]48F77$"(h "$!  $#
  $#!
  $#   59 FLW %N Y Es   H$H!H
H$r  c                 (  #    U R                  5       I Sh  vN   U R                  U5      n0 nSnSnSnSnU R                  SUS5      u  pbU R                  X25      u  prU R	                  USSS5      u  pU(       aA  US:X  a  Ub  SnUS   US	'   XtS
'   U R                  U R                  XB5      5      I Sh  vN nGO%US   (       d
  US   (       a5  XtS'   US   US	'   U R                  U R                  XB5      5      I Sh  vN nOUS:X  a1  US   US	'   U R                  U R                  XB5      5      I Sh  vN nOUS:X  a  U R                  US5      n	U	c  [        U R                  S-   5      eU R                  US5      nU R                  U	5      n
U
S   US'   U R                  U R                  XB5      5      I Sh  vN nO[        U R                  S-   US	   -   5      eU R!                  US/ 5      nU R#                  X5      $  GN GNS GN N NR7f)a  
retrieve information on the maximum leverage, and maintenance margin for trades of varying trade sizes for a single market

https://www.bitget.com/api-doc/contract/position/Get-Query-Position-Lever
https://www.bitget.com/api-doc/margin/cross/account/Cross-Tier-Data
https://www.bitget.com/api-doc/margin/isolated/account/Isolated-Tier-Data
https://www.bitget.com/api-doc/uta/public/Get-Position-Tier-Data

:param str symbol: unified market symbol
:param dict [params]: extra parameters specific to the exchange API endpoint
:param str [params.marginMode]: for spot margin 'cross' or 'isolated', default is 'isolated'
:param str [params.code]: required for cross spot margin
:param str [params.productType]: *contract and uta only* 'USDT-FUTURES', 'USDC-FUTURES', 'COIN-FUTURES', 'SUSDT-FUTURES', 'SUSDC-FUTURES' or 'SCOIN-FUTURES'
:param boolean [params.uta]: set to True for the unified trading account(uta), defaults to False
:returns dict: a `leverage tiers structure <https://docs.ccxt.com/#/?id=leverage-tiers-structure>`
Nr   r  r   Fr  r  rE   r  r  rT   rU   r  r  r  z4 fetchMarketLeverageTiers() requires a code argumentr  z; fetchMarketLeverageTiers() symbol does not support market r  )load_marketsr  r  r  r   publicUtaGetV3MarketPositionTierr=  )publicMixGetV2MixMarketQueryPositionLever(privateMarginGetV2MarginIsolatedTierDatarG  r/   rE   r  currency'privateMarginGetV2MarginCrossedTierDatar0   r  parse_market_leverage_tiers)r  r  r  r  requestr  r  r  r   r  r  r_  s               r  fetch_market_leverage_tiers"bitget.fetch_market_leverage_tiers	  s%    " !!!V$
!??@Z\bdno
"AA&Q33F<VX]_def$)"*K &tGH"-J!BB4;;wC_``HVn&"2%0M" &tGH!KKDKKX_LhiiH:% &tGH!JJ4;;W^KghhH7"##FF3D|'2h(hiiYYvv.F}}T*H&tnGFO!II$++V]JfggHTWW'ddgmnvgwwxxV 626//??[ 	"  a j i hs[   HHBH5H6A	H?H 6H6H7BH=H>AHHHHHr  c                    / nSn[        S[        U5      5       H  nX   nU R                  USS5      nUb  UnU R                  U/ SQ5      nU R	                  USS5      n	U	b  U	OUS   n
U R                  US5      nUR                  U R                  US	S
5      U R                  X5      U R                  U
5      UUU R                  U/ SQ5      U R                  US5      US.5        UnM     U$ )Nr   	startUnitminTierValue)endUnitmaxBorrowableAmountbaseMaxBorrowableAmountmaxTierValuer  r   r  r  leveltier)keepMarginRatemaintainMarginRatemmrr*  )r  r  r  minNotionalmaxNotionalmaintenanceMarginRater}  r6  )r9  r:  rR  safe_number_nr  rG  r;  safe_integer_2safe_symbolrH  rP  )r  r6  r  tiersr  rW  itemminimumNotionalr  marginCurrency
currencyIdr`  s               r  r  "bitget.parse_market_leverage_tiersG
  s   ^ q#d)$A7D"00{NSO*-,,T  4A  BK!//fjIN,:,FVTZ^J''h7HLL++D'6B**8< 33J?**)-););DBq)r#//jA	 	 &K' %( r  r  sincer  c                 "  #    U R                  5       I Sh  vN   SnU R                  USS5      u  pTU(       a   U R                  SSX#USSSS5	      I Sh  vN $ Uc  U R                  5       S-
  nUU R                  5       S.nSnUb  U R	                  U5      nUS	   US
'   Ub  X6S'   U R                  SXd5      u  pdU R                  U R                  Xd5      5      I Sh  vN nU R                  US/ 5      n	U R                  U	SX#5      $  N N N.7f)aC  
fetch all deposits made to an account

https://www.bitget.com/api-doc/spot/account/Get-Deposit-Record

: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 int [params.until]: end time in milliseconds
:param str [params.idLessThan]: return records with id less than the provided value
:param boolean [params.paginate]: default False, when True will automatically paginate by calling self endpoint multiple times. See in the docs all the [available parameters](https://github.com/ccxt/ccxt/wiki/Manual#pagination-params)
:returns dict[]: a list of `transaction structures <https://docs.ccxt.com/#/?id=transaction-structure>`
NFr   paginate
idLessThanr      X 	startTimeendTimerE   r  r  r  r  )
r  r  fetch_paginated_call_cursormillisecondsr  handle_until_option(privateSpotGetV2SpotWalletDepositRecordsr=  r8  parse_transactions)
r  r  r  r  r  r  r  r  r  rawTransactionss
             r  fetch_depositsbitget.fetch_deposits
  sF     !!!88R\]99/4QV_egs  vB  DH  JM  N  N  N=%%'*4E((*
 }}T*H&tnGFO$G229gNFFt{{SZGcdd0 ..62>&&eKKW 	" N es4   DD	=DDB	DD+DDDr!  addresstagc                   #    U R                  U5        SnU R                  U5      u  peUc  [        U R                  S-   5      eU R	                  5       I Sh  vN   U R                  U5      nU R                  U5      nUS   UUU R                  XU5      SS.n	Ub  XIS'   U R                  U R                  X5      5      I Sh  vN n
U R                  U
S0 5      nU R                  X5      nSUS	'   U R                  U R                  S
0 5      nU R                  USS5      nU(       a  XS'   X,S'   XLS'   X<S'   X<S'   XlS'   U$  N N7f)a  
make a withdrawal

https://www.bitget.com/api-doc/spot/account/Wallet-Withdrawal

:param str code: unified currency code
:param float amount: the amount to withdraw
:param str address: the address to withdraw to
:param str tag:
:param dict [params]: extra parameters specific to the exchange API endpoint
:param str [params.chain]: the blockchain network the withdrawal is taking place on
:returns dict: a `transaction structure <https://docs.ccxt.com/#/?id=transaction-structure>`
Nz* withdraw() requires a "network" parameterrE   on_chain)r  r  r  sizetransferTyper  r  
withdrawalr  r   r  Tr  r!  r  	addressTor  )check_addresshandle_network_code_and_paramsr/   rE   r  r  network_code_to_idcurrency_to_precision%privateSpotPostV2SpotWalletWithdrawalr=  r  parse_transactionr  rB  )r  r  r!  r  r  r  networkCoder  r  r  r  r  r_  withdrawOptionsr  s                  r  r   bitget.withdraw
  se     	7#"AA&I#DGG.Z$Z[[!!!==&++K8	TN..t[I&
 ? ENCCDKKPWD`aa x4''7%v//$,,
BG"&..B[]a"b"!%:%85M '9"); +9I 	" bs&   AEEA+EEA?EEc                 &  #    U R                  5       I Sh  vN   SnU R                  USS5      u  pTU(       a   U R                  SSX#USSSS5	      I Sh  vN $ SnUb  U R                  U5      nUc  U R	                  5       S-
  nUU R	                  5       S.nUb  US	   US
'   U R                  SXt5      u  ptUb  X7S'   U R                  U R                  Xt5      5      I Sh  vN nU R                  US/ 5      n	U R                  XX#5      $  N N N-7f)aO  
fetch all withdrawals made from an account

https://www.bitget.com/api-doc/spot/account/Get-Withdraw-Record

: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 int [params.until]: end time in milliseconds
:param str [params.idLessThan]: return records with id less than the provided value
:param boolean [params.paginate]: default False, when True will automatically paginate by calling self endpoint multiple times. See in the docs all the [available parameters](https://github.com/ccxt/ccxt/wiki/Manual#pagination-params)
:returns dict[]: a list of `transaction structures <https://docs.ccxt.com/#/?id=transaction-structure>`
NFr   r  r  r  r  r  rE   r  r  r  r  )
r  r  r  r  r  r  +privateSpotGetV2SpotWalletWithdrawalRecordsr=  r8  r  )
r  r  r  r  r  r  r  r  r  r  s
             r  fetch_withdrawalsbitget.fetch_withdrawals  sL     !!!88ASU_`99:LdTYbhjv  yE  GK  MP  Q  Q  Q}}T*H=%%'*4E((*
 &tnGFO229gN$GII$++V]Jfgg6 ..62>&&%OO_ 	" Q hs4   DD=DDBD!D"*DDDtransactionr  c                    U R                  US5      nU R                  X25      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  [        R                  " U	5      n
S nU R                  US5      nU
b)  X@R                  U
5      S.n[        R                  " X5      n0 S	U R                  US
5      _SU_SU R                  US5      _SU_SU R                  U5      _SU R                  U5      _SU R                  US5      _SU R                  US5      _SU R                  US5      _SU R                  U5      _SU R                  US5      _SU_SU R                  U5      _SU R                  US5      _SS _SU_SU_S S US.E$ )Nr  cTimer  r  r  r  r  r  r+  rE   orderIdr6  txidtradeId	timestampdatetimer  addressFromfromAddressr  	toAddressr  r!  r  r  updateduTimetagFromtagTo)commentinternalr  )
rG  rH  r  r?   
string_absr  
string_subrK  r  parse_transaction_status)r  r  r  r  r  r  r  r  r  feeCostStringfeeCostAbsStringr  rs  s                r  r  bitget.parse_transactionC  sF   N %%k6:
&&z<%%k7;	$$[':	!!+x8{E2((e<$&11-@''V<'#->->?O-PQC"--lML
$"";	:
K
 D$$[)<
 	

 Y/
 t..y9
 4++KG
 t''[A
 ))+{C
 d''5
 D$$[&9
 
 d33F;
 t((g>
 t
  3!
" S#
$ )
 	
r  r  c                 6    SSSSSS.nU R                  X!U5      $ )Nokpendingfailed)successPendingpending_reviewpending_review_failrejectrG  r  r  statusess      r  r   bitget.parse_transaction_status  s-     '#+
 &99r  c                 b  #    U R                  5       I Sh  vN   SnU R                  U5      u  p2U R                  U5      nSUS   0nUb  U R                  X15      US'   U R	                  U R                  XR5      5      I Sh  vN nU R                  US0 5      nU R                  Xt5      $  N N*7f)aS  
fetch the deposit address for a currency associated with self account

https://www.bitget.com/api-doc/spot/account/Get-Deposit-Address

:param str code: unified currency code
:param dict [params]: extra parameters specific to the exchange API endpoint
:returns dict: an `address structure <https://docs.ccxt.com/#/?id=address-structure>`
Nr  rE   r  r  )r  r  r  r  (privateSpotGetV2SpotWalletDepositAddressr=  r7  parse_deposit_address)r  r  r  r  r  r  r  r  s           r  fetch_deposit_addressbitget.fetch_deposit_address  s      !!!"AA&I==&HTN
 "#66{IGGFFt{{SZGcdd ~~h3))$993 	" es"   B/B+A+B/B-)B/-B/c                     U R                  US5      nU R                  US5      nU R                  X25      nS nUb  U R                  XE5      nUUUU R                  US5      U R                  US5      S.$ )Nr  r  r  r  )r6  r  r  r  r  )rG  rH  r  )r  depositAddressr  r  r  parsedCurrencyr  s          r  r  bitget.parse_deposit_address  s     %%nf=
$$^W=	00F --iHG"&''	B##NE:
 	
r  c                   #    U R                  5       I Sh  vN   U R                  U5      nSUS   0nUb  X%S'   SnU R                  XC5      u  pcSnSnU R                  USSS5      u  pU(       a-  XeS'   U R	                  U R                  XS5      5      I Sh  vN nO_US	   (       a)  U R                  U R                  XS5      5      I Sh  vN nO,XeS
'   U R                  U R                  XS5      5      I Sh  vN nU R                  US0 5      n	U(       a  SOSn
U(       a  SOSnU R                  U	S5      nU R                  XS   XU5      $  GN7 N N N\7f)a  
fetches information on open orders with bid(buy) and ask(sell) prices, volumes and other data

https://www.bitget.com/api-doc/spot/market/Get-Orderbook
https://www.bitget.com/api-doc/contract/market/Get-Merge-Depth
https://www.bitget.com/api-doc/uta/public/OrderBook

: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
:param boolean [params.uta]: set to True for the unified trading account(uta), defaults to False
:returns dict: A dictionary of `order book structures <https://docs.ccxt.com/#/?id=order-book-structure>` indexed by market symbols
Nr  rE   r  r   r   Fr  rR   r  r  bbidsaasksts)r  r  r  r  publicUtaGetV3MarketOrderbookr=  "publicSpotGetV2SpotMarketOrderbook!publicMixGetV2MixMarketMergeDepthr  r  parse_order_book)r  r  r  r  r  r  r  r  r   r  bidsKeyasksKeyr  s                r  fetch_order_bookbitget.fetch_order_book  s[     !!!V$fTl
 $G"AA&Q33F<LeUZ["-J!??G@\]]HF^!DDT[[QXEabbH%0M"!CCDKKPWD`aaH4 x4#&#&%%dD1	$$T(+;YQXYYc 	" ^b bsG   EEB EE2E
E,E7E8AEEEEtickerc           
      ~   U R                  US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 R                  US5      nUb	  US:w  a  S	n	OS
n	U R                  US5      n
U
c  [        R                  " US5      n
U R                  0 SU R                  X2S U	5      _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S5      _SU R                  USS5      _SU R                  USS5      _SU R                  USS 5      _S!S _S"U R                  U/ S#Q5      _S$U_S%U_S&S _S'U_S(U
_S)S _U R                  US*S+5      U R                  US,S-5      U R                  US.5      UUS/.EU5      $ )0Nr  lastPr	lastPricer  	change24hr  	markPricer  r  rR   price24hPcnt100r  r  highhigh24hhighPrice24hlowlow24hlowPrice24hbidbidPr	bid1Price	bidVolumebidSzbid1SizeaskaskPr	ask1Price	askVolumeaskSzask1Sizevwapopen)rC  open24hopenPrice24hcloser  previousClosechange
percentageaverage
baseVolume	volume24hquoteVolumeturnover24h
indexPrice)rK  rM  rO  r-  r6  )	rG  r  safe_integer_omit_zeror?   
string_mulsafe_tickerr  rK  safe_string_n)r  r(  r  r`  rF  r  rH  r  r-  
marketTyperI  s              r  parse_tickerbitget.parse_ticker  sZ   P ##FH5""68[A//=	!!&+6##FJ7$$V[9	!F(:#JJ%%fn=
 ++FE:J !
d&&xzJ!
!
 Y/!
 D&&vy.I	!

 4%%fhF!
 4%%fg{C!
 ++FGZH!
 4%%fg{C!
 ++FGZH!
 D!
 D&&v/RS!
 U!
 E!
 T!
 f!
  *!!
" t#!
$ ,,V\;O--fm]S**6<@"-!
. / 	r  c                 P  #    U R                  5       I Sh  vN   U R                  U5      nSUS   0nSnU R                  X25      u  pRSnSnU R                  USSS5      u  prU(       a-  XTS'   U R	                  U R                  XB5      5      I Sh  vN nO_US   (       a)  U R                  U R                  XB5      5      I Sh  vN nO,XTS	'   U R                  U R                  XB5      5      I Sh  vN nU R                  US
/ 5      nU R                  US   U5      $  GN N N^ N37f)an  
fetches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market

https://www.bitget.com/api-doc/spot/market/Get-Tickers
https://www.bitget.com/api-doc/contract/market/Get-Ticker
https://www.bitget.com/api-doc/uta/public/Tickers

:param str symbol: unified symbol of the market to fetch the ticker for
:param dict [params]: extra parameters specific to the exchange API endpoint
:param boolean [params.uta]: set to True for the unified trading account(uta), defaults to False
:returns dict: a `ticker structure <https://docs.ccxt.com/#/?id=ticker-structure>`
Nr  rE   r   r   Fr  rR   r  r  r   )
r  r  r  r  publicUtaGetV3MarketTickersr=   publicSpotGetV2SpotMarketTickerspublicMixGetV2MixMarketTickerr8  rU  )	r  r  r  r  r  r  r  r   r  s	            r  fetch_tickerbitget.fetch_ticker  s#     !!!V$fTl
 "AA&Q33FM5RWX"-J!==dkk'>Z[[HF^!BB4;;wC_``H%0M"!??G@\]]Hx ~~h3  a&11] 	" \` ^sF   D&DA9D&D 2D&D",D&0D$1-D& D&"D&$D&c                   #    U R                  5       I Sh  vN   U R                  U5      nSUS   0nSnUS   (       a  [        U R                  S-   5      eSnU R	                  X25      u  pbXdS'   U R                  U R                  XB5      5      I Sh  vN nU R                  US/ 5      nU R                  US   U5      $  N N.7f)	aX  
fetches the mark price for a specific market

https://www.bitget.com/api-doc/contract/market/Get-Symbol-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
:returns dict: a `ticker structure <https://docs.ccxt.com/#/?id=ticker-structure>`
Nr  rE   rR   z3 fetchMarkPrice() is not supported for spot marketsr  r  r   )	r  r  r6   rE   r  "publicMixGetV2MixMarketSymbolPricer=  r8  rU  )r  r  r  r  r  r  r  r  s           r  fetch_mark_pricebitget.fetch_mark_priceD  s      !!!V$fTl
 &>tww)^^__K"&"E"Ef"UK%0M"!DDT[[QXEabbH~~h3  a&11 	" cs"   CC A<CC-CCsymbolsc                   #    U R                  5       I Sh  vN   SnUb#  U R                  US5      nU R                  U5      nSn0 nSnU R                  SX25      u  prU R	                  US5      nSn	U R                  X25      u  pSn
U R                  USSS5      u  pU
(       aI  [        U5      nUb  US:X  a  US   US	'   XS
'   U R                  U R                  Xb5      5      I Sh  vN nO^US:X  a,  Uc)  U R                  U R                  Xb5      5      I Sh  vN nO,XS'   U R                  U R                  Xb5      5      I Sh  vN nU R                  US/ 5      nU R                  X5      $  GNX N NZ N/7f)a  
fetches price tickers for multiple markets, statistical information calculated over the past 24 hours for each market

https://www.bitget.com/api-doc/spot/market/Get-Tickers
https://www.bitget.com/api-doc/contract/market/Get-All-Symbol-Ticker
https://www.bitget.com/api-doc/uta/public/Tickers

:param str[]|None symbols: unified symbols of the markets to fetch the ticker for, all market tickers are returned if not assigned
:param dict [params]: extra parameters specific to the exchange API endpoint
:param boolean [params.uta]: set to True for the unified trading account(uta), defaults to False
:param str [params.subType]: *contract only* 'linear', 'inverse'
:param str [params.productType]: *contract only* 'USDT-FUTURES', 'USDC-FUTURES', 'COIN-FUTURES', 'SUSDT-FUTURES', 'SUSDC-FUTURES' or 'SCOIN-FUTURES'
:returns dict: a dictionary of `ticker structures <https://docs.ccxt.com/#/?id=ticker-structure>`
Nr   r   r  r   Fr   rE   r  r  rR   r  r  )r  r  r  handle_market_type_and_paramsrG  r  r  r:  rX  r=  rY  publicMixGetV2MixMarketTickersr8  parse_tickers)r  ra  r  r  r  r  r  r  passedSubTyper  r   symbolsLengthr  s                r  fetch_tickersbitget.fetch_tickers^  s     !!!__Wa0F[[(F99.&Y ((;"AA&Q33FNESXYLM#-1*<$*4L!"-J!==dkk'>Z[[HV^ 5!BB4;;wC_``H%0M"!@@WA]^^Hj ~~h3!!$00e 	". \` _sF   E7E.CE7&E1'1E7E3,E7E5)E71E73E75E7tradec                 n   U R                  US5      nU R                  X25      nU R                  U/ SQ5      nS nU R                  US5      nU R                  US5      nU R                  US5      n	US L=(       d    U	S Ln
U
(       a  US   OUnUbq  U R	                  U R                  US5      5      nSU0nU R                  US	S
5      nU R                  US5      SL nU(       a  XS'   O[        R                  " U5      US'   U R                  UU R                  USS5      U R                  US5      UU R                  US5      U R                  US5      U R                  US5      U R                  U/ SQ5      U R                  U/ SQ5      U R                  U/ SQ5      UU R                  U5      US.U5      $ )Nr  )r  r  createdTime	feeDetailposModer  r   feeCoinr  totalFeer  	deductionTr+  r  execIdr  side	orderType
tradeScope)priceAvgr  	execPrice)rK  r  execQty)rM  r!  	execValue)r6  rE   orderr  rs  r  takerOrMakerr  r!  r+  r  r  r  )rG  r  safe_integer_nr  rH  r  r?   
string_neg
safe_tradesafe_string_lowerrS  rK  )r  rj  r  r`  r  r  r  rm  rn  r  isFeeStructurefeeStructurecurrencyCoder  rq  s                  r  parse_tradebitget.parse_trade  s   f ##E84!!(3''/MN	OOE;7	""5)4##E:6!-H843G'5y|9#2243C3CLR[3\]LLC !..|ZOM(({CtKI+F%00?F$$UIx@%%eY7**5&9$$UK8 ,,ULA''/QR((0QR&&u.TU"Y/ 
  	r  c           	      .  #    U R                  5       I Sh  vN   SnU R                  USS5      u  pTU(       a  U R                  SXX4SS5      I Sh  vN $ U R                  U5      nSUS   0nSnU R                  USSS5      u  pUb5  U(       a  [	        US	5      US
'   OUS   (       a  [	        US5      US
'   OX7S
'   U R                  U R                  S0 5      n	Sn
SnU R                  Xd5      u  pU(       aO  US:X  a  SnU R                  SU5      u  pUb  SnXS'   U R                  U R                  Xt5      5      I Sh  vN n
GOUS   (       a  U R                  U	S0 5      nU R                  USS5      nU R                  USU5      nU R                  US5      nUS:X  aD  U R                  SXt5      u  ptUb  X'S'   U R                  U R                  Xt5      5      I Sh  vN n
OUS:X  a(  U R                  U R                  Xt5      5      I Sh  vN n
OU R                  U	S0 5      nU R                  USS5      nU R                  USU5      nU R                  US5      nXS'   US:X  aD  U R                  SXt5      u  ptUb  X'S'   U R!                  U R                  Xt5      5      I Sh  vN n
O.US:X  a(  U R#                  U R                  Xt5      5      I Sh  vN n
U R%                  U
S/ 5      nU R'                  UXbU5      $  GN GN GN GN+ N Ng N:7f)a  
get the list of most recent trades for a particular symbol

https://www.bitget.com/api-doc/spot/market/Get-Recent-Trades
https://www.bitget.com/api-doc/spot/market/Get-Market-Trades
https://www.bitget.com/api-doc/contract/market/Get-Recent-Fills
https://www.bitget.com/api-doc/contract/market/Get-Fills-History
https://www.bitget.com/api-doc/uta/public/Fills

:param str symbol: unified symbol of the market to fetch trades for
:param int [since]: timestamp in ms of the earliest trade to fetch
:param int [limit]: the maximum amount of trades to fetch
:param dict [params]: extra parameters specific to the exchange API endpoint
:param boolean [params.uta]: set to True for the unified trading account(uta), defaults to False
:param int [params.until]: *only applies to publicSpotGetV2SpotMarketFillsHistory and publicMixGetV2MixMarketFillsHistory* the latest time in ms to fetch trades for
:param boolean [params.paginate]: *only applies to publicSpotGetV2SpotMarketFillsHistory and publicMixGetV2MixMarketFillsHistory* default False, when True will automatically paginate by calling self endpoint multiple times
:returns Trade[]: a list of `trade structures <https://docs.ccxt.com/#/?id=public-trades>`
NFr   r  r  r  rE   r   r  r  r    r  r  r  rR   r  r  r  r  publicSpotGetV2SpotMarketFillsrT   r  r  publicMixGetV2MixMarketFillsr  )r  r  r  r  r%  r  r  r  r  publicUtaGetV3MarketFillsr=  rG  r  r  r  r  r  r  r8  parse_trades)r  r  r  r  r  r  r  r  r   r  r  r  r  spotOptionsdefaultSpotMethod
spotMethodswapOptionsdefaultSwapMethod
swapMethodr  s                       r  fetch_tradesbitget.fetch_trades  s8    & !!!88PZ[99-X]gs  vB  C  C  CV$fTl
 33FM5RWX#&uc? 
##&ud#3 #( //$,,rB"AA&Qf$!
%)%G%GW]%^"
)"*K"-J!;;DKK<XYYHF^//'62>K $ 0 0hHo p))&(<MNJYYvx0FDD"&":":9g"V$+0K(!%!K!KDKKX_Lh!ii??!%!D!DT[[QXEa!bb//'62>K $ 0 0hHm n))&(<MNJYYvx0F%0M"BB"&":":9g"V$+0K(!%!I!I$++V]Jf!gg==!%!B!B4;;wC_!``n ~~h3  ve<<] 	" C2 Z jb h`s~   LL:LLC/LL	BL!L".LLBL)L*.LL+LL	LLLLLc                 r  #    U R                  5       I Sh  vN   U R                  U5      nSUS   0nSnU R                  SU5      u  pRUS   (       a  Ub  SUS'   OSUS'   OSUS'   U R                  U R	                  XB5      5      I Sh  vN nU R                  US	0 5      nU R                  Xs5      $  N N*7f)
a  
fetch the trading fees for a market

https://www.bitget.com/api-doc/common/public/Get-Trade-Rate

:param str symbol: unified market symbol
:param dict [params]: extra parameters specific to the exchange API endpoint
:param str [params.marginMode]: 'isolated' or 'cross', for finding the fee rate of spot margin trading pairs
:returns dict: a `fee structure <https://docs.ccxt.com/#/?id=fee-structure>`
Nr  rE   r   rR   rS   businessTyper   r  )r  r  r  !privateCommonGetV2CommonTradeRater=  r  parse_trading_fee)r  r  r  r  r  r  r  r  s           r  fetch_trading_feebitget.fetch_trading_fee  s      !!!V$fTl
 
!??@QSYZ
&>%*2'*0'&+GN#??G@\]] x4%%d337 	" ^s"   B7B3A3B7
B5)B75B7c                 @  #    U R                  5       I Sh  vN   SnSnSnU R                  SU5      u  p1U R                  SSU5      u  pAUS:X  ac  U R                  USS5      nU R	                  US5      nUc  U(       a  U R                  U5      I Sh  vN nOxU R                  U5      I Sh  vN nO^US:X  d  US:X  a4  SnU R                  SU5      u  paXaS'   U R                  U5      I Sh  vN nO[        U R                  S	-   U-   S
-   5      eU R                  US/ 5      n0 n[        S[        U5      5       HS  n	Xy   n
U R                  U
S5      nU R                  USSU5      nU R!                  U5      nU R#                  X5      nXU'   MU     U$  GN~ GN N N7f)a  
fetch the trading fees for multiple markets

https://www.bitget.com/api-doc/spot/market/Get-Symbols
https://www.bitget.com/api-doc/contract/market/Get-All-Symbols-Contracts
https://www.bitget.com/api-doc/margin/common/support-currencies

:param dict [params]: extra parameters specific to the exchange API endpoint
:param str [params.productType]: *contract only* 'USDT-FUTURES', 'USDC-FUTURES', 'COIN-FUTURES', 'SUSDT-FUTURES', 'SUSDC-FUTURES' or 'SCOIN-FUTURES'
:param boolean [params.margin]: set to True for spot margin
:returns dict: a dictionary of `fee structures <https://docs.ccxt.com/#/?id=fee-structure>` indexed by market symbols
Nr   rR   rS   FrT   rU   r  r  r  r  r   r  )r  r  rc  rB  r  r?  r>  r  r<  r6   rE   r  r9  r:  rG  r  r  r  )r  r  r  r  rT  rS   r  r  r_  rW  r  r`  r  r  r  s                  r  fetch_trading_feesbitget.fetch_trading_feesC  s     !!!

!??@RTZ[
!??@RTXZ`a
^^FHe<FYYvx0F&6!%!G!G!OO!%!F!Fv!NNF"
h(>K"&"E"EdF"SK$/=!!BB6JJHtww)==
JYVWWP x4q#d)$AGE''x8H%%hdJGF[[(F((7C 6N % I 	" PN
 KsG   FFA<FFF-F.?F-F.B'FFFFc                     U R                  US5      nUU R                  X25      U R                  US5      U R                  US5      S S S.$ )Nr  r  r  )r6  r  r   r   rI  	tierBased)rG  r  rP  )r  r  r  r`  s       r  r  bitget.parse_trading_fee  sU    ##D(3&&x8%%dN;%%dN;
 	
r  c           	      
   U R                  US5      nU(       a  SOSn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                  X5      /$ )	Nr        r   r   r      r   )rB  r  rP  )r  ohlcvr  r  volumeIndexs        r  parse_ohlcvbitget.parse_ohlcv  s     ..3"aeQ'UA&UA&UA&UA&U0
 	
r  r   	timeframec           	      (
  #    U R                  5       I Sh  vN   SnSnSnU R                  USS5      n	U R                  USS5      n
SnU R                  US	S
5      u  pU(       a'  U
(       a  UOUnU R                  S	XXBX\5      I Sh  vN $ U R	                  U5      nSUS   0nSnSnSnU R                  US	SS5      u  nnU(       a(  U R
                  S   S   nU R                  UX"5      US'   O5US   (       a  SOSnU R
                  S   U   nU R                  UX"5      US'   SnU R                  5       nU R                  U5      S-  nU R                  US5      nUSLnUSLnUSLnU R                  US/5      nUS   (       a  SOSnU R                  U R
                  S	   U0 5      nU R                  US0 5      nU R                  UX$5      nU R                  U R
                  S	   S0 5      nU R                  UU5      nUUS-
  U-  -
  nU(       a  [        XG5      n[        UU5      nOUnUU-  n Sn!Sn"U(       a,  Un!X>S'   U(       d  U R                  U!U 5      n"U"U:  a  Un"U"US'   U(       a  Un"U"U:  a  Un"U"US'   U(       d  U"U -
  n!Sn#U!b  U!U::  d  U	(       aN  Sn#[        XH5      nUU-  n U"U -
  n!U!US'   US   (       d(  Sn$U"U!-
  U$U-  :  a  U R                  U!U$U-  5      n"U"US'   XNS'   Sn%Sn&Sn'U R                  US5      u  n'nU R                  X5      u  n&nU(       aI  U'b  U'S:X  a  SUS'   OU'S :X  a  S!US'   U&US"'   U R!                  U R#                  X5      5      I Sh  vN n%GO]US   (       ah  U#(       a*  U R%                  U R#                  X5      5      I Sh  vN n%GO"U(       d  SUS'   SnU R'                  U R#                  X5      5      I Sh  vN n%OU&US#'   U R#                  X5      n(U#(       dF  U'S:X  d  U'S :X  a:  U(       d  SU(S'   SnU R)                  U R#                  S$U'0U(5      5      I Sh  vN n%OU'S:X  a  U R+                  U(5      I Sh  vN n%OhU'S :X  a  U R-                  U(5      I Sh  vN n%OHU#(       a  U R/                  U(5      I Sh  vN n%O'U(       d  SU(S'   SnU R)                  U(5      I Sh  vN n%U%S%:X  a  / $ U R1                  U%S&U%5      n)U R3                  U)XX45      $  GN GNu GN GN` GN+ N N N No NI7f)'a  
fetches historical candlestick data containing the open, high, low, and close price, and the volume of a market

https://www.bitget.com/api-doc/spot/market/Get-Candle-Data
https://www.bitget.com/api-doc/spot/market/Get-History-Candle-Data
https://www.bitget.com/api-doc/contract/market/Get-Candle-Data
https://www.bitget.com/api-doc/contract/market/Get-History-Candle-Data
https://www.bitget.com/api-doc/contract/market/Get-History-Index-Candle-Data
https://www.bitget.com/api-doc/contract/market/Get-History-Mark-Candle-Data
https://www.bitget.com/api-doc/uta/public/Get-Candle-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 boolean [params.uta]: set to True for the unified trading account(uta), defaults to False
:param int [params.until]: timestamp in ms of the latest candle to fetch
:param boolean [params.useHistoryEndpoint]: whether to force to use historical endpoint(it has max limit of 200)
:param boolean [params.useHistoryEndpointForPagination]: whether to force to use historical endpoint for pagination(default True)
: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.price]: *swap only* "mark"(to fetch mark price candles) or "index"(to fetch index price candles)
:returns int[][]: A list of candles ordered, open, high, low, close, volume
Nr  r  r   useHistoryEndpointFuseHistoryEndpointForPaginationTr   r  r  rE   r   r   intervalrR   rT   granularity \&untilr  r  r   r  r  r  r  r  r  MARKr  r  INDEXr  r  	kLineType r  )r  rB  r  "fetch_paginated_call_deterministicr  r  rG  r  parse_timeframer  r  r7  r%  sumhandle_param_stringr  publicUtaGetV3MarketCandlesr=  'publicSpotGetV2SpotMarketHistoryCandlesr  r  )publicMixGetV2MixMarketHistoryMarkCandles*publicMixGetV2MixMarketHistoryIndexCandles%publicMixGetV2MixMarketHistoryCandlesr8  parse_ohlcvs)*r  r  r  r  r  r  defaultLimitmaxLimitForRecentEndpointmaxLimitForHistoryEndpointr  r  r  limitForPaginationr  r  rT  r   r   msInDaynowdurationr  limitDefinedsinceDefineduntilDefinedkeyohlcOptionsr  maxLimitForThisTimeframerecentEndpointDaysMaprecentEndpointAvailableDaysrecentEndpointBoundaryTslimitMultipliedDurationcalculatedStartTimecalculatedEndTimehistoricalEndpointNeededmaxDistanceDaysForContractsr  r  	priceTypeextendedr  s*                                             r  fetch_ohlcvbitget.fetch_ohlcv  s    2 !!!$(!%("!^^F4H%P*...Abdh*i'88zZ?^!;d}@@v^cpv  L  L  LV$fTl
 

33FL%QVWVl3E:J"&"2"2:y"TGJ#)&>vJl3J?J%)%5%5j)%WGM"!''	2T9!!&'2D(D(D(6G9- vfFnnT\\,%?bI#~~k;QSUV#'#4#45I9#\  $t||L/IKfhj k&*&7&78My&Y##&*E*IW)T#T 9E78E E"'("2 # "'#(K $(HH-@BY$Z!$s*(+%%6	" % 3&$'!!2GI&7:Q&Q# $) +0CG_0_dv'+$:E&+h&6#"36M"M#6GK &>.0+$'::=X[b=bb(,1DFadkFk(l%):GI& 	 44VWE	6"AA&QV$&&,GFO')&-GFO"-GJ!==dkk'>Z[[HF^'!%!M!MdkkZaNj!kk#'+GG$ E!%!F!Ft{{SZGc!dd%0GM"{{73H+f1D	U\H\#(,HW% E "&!D!DT[[R]_hQiksEt!uuf$!%!O!OPX!YYg%!%!P!PQY!ZZ+%)%O%OPX%YYH',0) $%)%H%H%RRHr>I~~h9  v%GGS 	" Lv \ l
 e vYZ  Z
  Ss   TS9A0TS<KT'S?(:T"T#7TTA"T=T>TT
T=T> TT'TT3T<T?TTTT
TTTTc                   #    U R                  5       I Sh  vN   0 nSnSnSnSnU R                  USSS5      u  paU R                  SSU5      u  p1U R                  SU5      u  pAU(       a_  U R	                  U R                  X!5      5      I Sh  vN nU R                  US0 5      nU R                  US/ 5      nU R                  U5      $ US:X  d  US:X  aC  Sn	U R                  SU5      u  pXS	'   U R                  U R                  X!5      5      I Sh  vN nOUS
:X  a)  U R                  U R                  X!5      5      I Sh  vN nO|US:X  a)  U R                  U R                  X!5      5      I Sh  vN nOMUS:X  a)  U R                  U R                  X!5      5      I Sh  vN nO[        U R                  S-   U-   S-   5      eU R!                  US/ 5      n
U R#                  U
5      $  GN GN] N N N NS7f)a  
query for balance and get the amount of funds available for trading or funds locked in orders

https://www.bitget.com/api-doc/spot/account/Get-Account-Assets
https://www.bitget.com/api-doc/contract/account/Get-Account-List
https://www.bitget.com/api-doc/margin/cross/account/Get-Cross-Assets
https://www.bitget.com/api-doc/margin/isolated/account/Get-Isolated-Assets
https://bitgetlimited.github.io/apidoc/en/margin/#get-cross-assets
https://bitgetlimited.github.io/apidoc/en/margin/#get-isolated-assets
https://www.bitget.com/api-doc/uta/account/Get-Account

:param dict [params]: extra parameters specific to the exchange API endpoint
:param str [params.productType]: *contract only* 'USDT-FUTURES', 'USDC-FUTURES', 'COIN-FUTURES', 'SUSDT-FUTURES', 'SUSDC-FUTURES' or 'SCOIN-FUTURES'
:param str [params.uta]: set to True for the unified trading account(uta), defaults to False
:returns dict: a `balance structure <https://docs.ccxt.com/#/?id=balance-structure>`
Nrs   r   Fr  assetsrT   rU   r  r  r  rR   z! fetchBalance() does not support z	 accounts)r  r  rc  r  privateUtaGetV3AccountAssetsr=  r7  r8  parse_uta_balancer  !privateMixGetV2MixAccountAccounts-privateMarginGetV2MarginIsolatedAccountAssets,privateMarginGetV2MarginCrossedAccountAssets!privateSpotGetV2SpotAccountAssetsr6   rE   r  parse_balance)r  r  r  rT  r  r  r   rZ  r  r  r  s              r  fetch_balancebitget.fetch_balance|  s    " !!!

33FNESXY!??PTV\]
!??PVW
!>>t{{7?[\\HnnXvr:G^^GXr:F))&11F"
h(>K"&"E"EdF"SK%0M"!CCDKKPWD`aaH:%!OOPTP[P[\cPlmmH. 7"!NNt{{[bOkllH, 6!!CCDKKPWD`aaHtww)LLzY\gghhZ x4!!$''g 	" ] bm0 m. bsl   G6G(A7G6G+BG6G..G6G0.G61G22.G6 G4!AG6+G6.G60G62G64G6c                    SU0n[        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      US'   U R                  US5      US'   U R                  US	5      US
'   XRU'   M     U R                  U5      $ )Nr6  r   r  debtlockedused	availablefreebalancetotal)r9  r:  accountrG  rH  safe_balance)r  r  r_  rW  r  r  r  r  s           r  r  bitget.parse_uta_balance"  s    ( q#g,'AJEllnG))%8J**:6D"..uf=GFO"..uh?GFO"..ukBGFO#//yAGG"4L (   ((r  c                    SU0n[        S[        U5      5       GH-  nX   nU R                  5       nU R                  USS5      nU R	                  U5      nU R                  US5      nUbV  U R                  US5      n	U R                  US5      US'   U R                  US	5      US
'   [        R                  " X5      US'   OU R                  US5      n
U R                  US5      nUb  XS'   U R                  US5      US
'   OAXS'   U R                  US5      nU R                  US5      n[        R                  " X5      US'   XRU'   GM0     U R                  U5      $ )Nr6  r   
marginCoinr  borrowinteresttransferabler  totalAmountr  r  r  maxTransferOutaccountEquityfrozenr  r  )	r9  r:  r  r  rH  rG  r?   
string_addr  )r  r  r_  rW  r  r  r  r  r  r  spotAccountFreecontractAccountFreer  r  s                 r  r  bitget.parse_balance;  sj   (` q#g,'AJEllnG++E<HJ**:6D%%eX6F!++E:>"&"2"25."I#'#3#3E=#I ")"4"4V"F #'"2"25+"F&*&6&6u>N&O#&2&9FO'+'7'7'OGG$&5FO!--eX>F!--eX>F&-&8&8&HGFO"4L/ (0   ((r  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	_nU R                  X!U5      $ )NnewrC  initnot_triggerpartial_fillpartially_fillpartially_filled	triggeredclosed	full_fillfilledfail_triggerrejectedcancelcanceled	cancelledlivefail_executeexecutedr  r  s      r  parse_order_statusbitget.parse_order_status  s    
6
F
 6
 F	

 f
 
 
 
 h
 J
 j
 
 

 F
 J
  !
$ &99r  rz  c                 V	   U R                  US5      nUb8  U R                  UU R                  US5      U R                  USS5      SS.U5      $ U R                  US5      nUS LnU(       a  SOS	nUb  US
   nU R                  US5      nU R                  XrS U5      nU R	                  U/ SQ5      nU R                  USS5      n	U R                  U/ SQ5      n
S nU R                  US5      nUb+  U R                  [        R                  " U5      5      US   S.nU R                  US5      nU R                  US5      S LnU(       aQ  U R                  US0 5      nU R                  US5      nU R                  [        R                  " U5      5      US   S.nOUb  [        R                  " U5      n[        UR                  5       5      nS n[!        S[#        U5      5       H  nUU   nU R                  US5      c  M  Un  O   U R                  [        R                  " U R                  US5      5      5      U R%                  U R                  US5      5      S.nS nU R'                  USS5      nUS:X  a  SnSnS nU R                  US5      nUb
  US:X  a  SOSnS nS nU R                  US 5      nUb%  U R                  US!5      nU R                  US 5      nO&U R                  U/ S"Q5      nU R                  US!5      nS nS nU R                  US#5      nUb  UnU R                  US$5      nO&U R                  US$S%5      nU R                  US&S'5      nU R                  US(5      n U R                  US)5      n!U!S*:X  a  U(       a
  U S+:X  a  S,OS+n U R                  US-5      n"U S+:H  =(       a    U"S.:H  n#US	   (       a  U#(       a  U R                  US&5      nU R                  0 S/U_S0U R                  USS15      _SU R                  USS5      _S2U_S3U R)                  U5      _S4U	_S5U	_SUS   _S
U"_S(U _S6U_S7U_S8U R                  US9S:5      _S;U_S<U_S=S _SU_UUU R+                  US>5      U R-                  U/ S?Q5      U R-                  U/ S@Q5      U R/                  U
5      US SA.EU5      $ )BNerrorMsgr  clientOrderId	clientOidr  )r6  rE   r  r  posSider  rR   r  r  r  ctimerl  r  updatedTime)r  stateorderStatus
planStatusr  r  )r+  r  rm  r  r   feeCoinCoderp  forcer  	POST_ONLYTr  
reduceOnlyNOF	basePricerv  )r  executePriceslLimitPricetpLimitPricebaseSizer  qtyrK  
cumExecQtyrs  rn  
hedge_modebuysellrt  r  r6  rE   r  r  r  lastTradeTimestamplastUpdateTimestampr  r!  r+  rM  	quoteSizerJ  r  	remainingr  )presetStopSurplusPricestopSurplusTriggerPrice
takeProfit)presetStopLossPricestopLossTriggerPricestopLoss)postOnlyr  r  r  r  r  r  trades)rG  
safe_orderr  safe_marketr|  r  rS  r  r?   r}  r  r7  jsonloadsrC  valuesr9  r:  rH  safe_string_upper_2rK  rP  r  r  )$r  rz  r  errorMessager  isContractOrderrT  r`  r  updateTimestamp	rawStatusr  r  rm  r   	feeResultutaFeeparsedFeeDetail	feeValues	feeObjectrW  feeValuer2  r  r  reduceOnlyRawr  rJ  r  r  r  r"  rs  rn  rt  isBuyMarkets$                                       r  parse_orderbitget.parse_order  sy   j ''z:#??&&ui8!%!3!3E?K!X$	$
   ""5)4"$.#2Z
J##E84!!(D*E''/PQ	--eWmL&&u.^_	((6$ ))'*<*<]*KL"8,C OOE;7	uj1=y!R8I%%i7F))'*<*<V*DE"8,C
 $"&**Y"7 !7!7!9:	 	q#i.1A(|Hx?K$,		 2 !--g.@.@AQAQR[]gAh.ij $ 7 78H8HTa8b c ..ug}M+%HK
((=$#0D#8tJ$$UK8	 $$UJ7E&&uk:G&&u.ghE&&uj9G##E:6D%%eV4F%%eVU;D''|\JFv.""5)4l"z"em6%D $$UK8	u}A9+@&>k##E<8D  
E 
$$$UIv> 
 T//T 
 	 

 Y/ 
 !/ 
 "? 
 fX& 
 I 
 D 
 U 
 d 
 D&&um[I 
 w 
 f 
  ! 
" ;# 
$ !$ ,,UNC#11%9|}!//7rs--i83 
4 5 	r  r+  c                 
  #    U R                  5       I Sh  vN   U R                  U5      nUS   (       d  [        U R                  S-   5      eSS0nU R	                  USSUSU R                  XS5      5      I Sh  vN $  Nh N7f)a4  
create a market buy order by providing the symbol and cost

https://www.bitget.com/api-doc/spot/trade/Place-Order
https://www.bitget.com/api-doc/margin/cross/trade/Cross-Place-Order
https://www.bitget.com/api-doc/margin/isolated/trade/Isolated-Place-Order

:param str symbol: unified symbol of the market to create an order in
:param float cost: how much you want to trade in units of the quote currency
:param dict [params]: extra parameters specific to the exchange API endpoint
:returns dict: an `order structure <https://docs.ccxt.com/#/?id=order-structure>`
NrR   z9 createMarketBuyOrderWithCost() supports spot orders onlyr  Fr  r&  )r  r  r6   rE   create_orderr=  )r  r  r+  r  r  r  s         r  !create_market_buy_order_with_cost(bitget.create_market_buy_order_with_cost  s      !!!V$f~tww)ddee/
 &&vxdDKKX[Ldeee 	" fs"   BA?A#B:B;BBr  rs  r  c                   #    U R                  5       I Sh  vN   U R                  U5      nU R                  SU5      nUS   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nU=(       d    UnSnSnU R                  USS
S5      u  nnU(       aO  U R                  XX4XV5      nU(       a  U R                  U5      I Sh  vN nGOU R                  U5      I Sh  vN nOU R                  XX4XV5      nUS   (       a{  U(       a  U R                  U5      I Sh  vN nOU	S:X  a  U R                  U5      I Sh  vN nOU	S:X  a  U R                  U5      I Sh  vN nO|U R                  U5      I Sh  vN nObU(       d  U(       a  U R                  U5      I Sh  vN nO:U(       a  U R!                  U5      I Sh  vN nOU R#                  U5      I Sh  vN nU R%                  US0 5      nU R'                  UU5      $  GN" GNC GN+ N N N N Nu NV N>7f)a  
create a trade order

https://www.bitget.com/api-doc/spot/trade/Place-Order
https://www.bitget.com/api-doc/spot/plan/Place-Plan-Order
https://www.bitget.com/api-doc/contract/trade/Place-Order
https://www.bitget.com/api-doc/contract/plan/Place-Tpsl-Order
https://www.bitget.com/api-doc/contract/plan/Place-Plan-Order
https://www.bitget.com/api-doc/margin/cross/trade/Cross-Place-Order
https://www.bitget.com/api-doc/margin/isolated/trade/Isolated-Place-Order
https://www.bitget.com/api-doc/uta/trade/Place-Order
https://www.bitget.com/api-doc/uta/strategy/Place-Strategy-Order

:param str symbol: unified symbol of the market to create an order in
:param str type: 'market' or 'limit'
:param str side: 'buy' or 'sell'
:param float amount: how much you want to trade in units of the base currency
:param float [price]: the price at which the order is to be fulfilled, in units of the quote currency, ignored in market orders
:param dict [params]: extra parameters specific to the exchange API endpoint
:param float [params.cost]: *spot only* how much you want to trade in units of the quote currency, for market buy orders only
:param float [params.triggerPrice]: *swap only* The price at which a trigger order is triggered at
:param float [params.stopLossPrice]: *swap only* The price at which a stop loss order is triggered at
:param float [params.takeProfitPrice]: *swap only* The price at which a take profit order is triggered at
:param dict [params.takeProfit]: *takeProfit object in params* containing the triggerPrice at which the attached take profit order will be triggered(perpetual swap markets only)
:param float [params.takeProfit.triggerPrice]: *swap only* take profit trigger price
:param dict [params.stopLoss]: *stopLoss object in params* containing the triggerPrice at which the attached stop loss order will be triggered(perpetual swap markets only)
:param float [params.stopLoss.triggerPrice]: *swap only* stop loss trigger price
:param str [params.timeInForce]: "GTC", "IOC", "FOK", or "PO"
:param str [params.marginMode]: 'isolated' or 'cross' for spot margin trading
:param str [params.loanType]: *spot margin only* 'normal', 'autoLoan', 'autoRepay', or 'autoLoanAndRepay' default is 'normal'
:param str [params.holdSide]: *contract stopLossPrice, takeProfitPrice only* Two-way position: ('long' or 'short'), one-way position: ('buy' or 'sell')
:param float [params.stopLoss.price]: *swap only* the execution price for a stop loss attached to a trigger order
:param float [params.takeProfit.price]: *swap only* the execution price for a take profit attached to a trigger order
:param str [params.stopLoss.type]: *swap only* the type for a stop loss attached to a trigger order, 'fill_price', 'index_price' or 'mark_price', default is 'mark_price'
:param str [params.takeProfit.type]: *swap only* the type for a take profit attached to a trigger order, 'fill_price', 'index_price' or 'mark_price', default is 'mark_price'
:param str [params.trailingPercent]: *swap and future only* the percent to trail away from the current market price, rate can not be greater than 10
:param str [params.trailingTriggerPrice]: *swap and future only* the price to trigger a trailing stop order, default uses the price argument
:param str [params.triggerType]: *swap and future only* 'fill_price', 'mark_price' or 'index_price'
:param boolean [params.oneWayMode]: *swap and future only* required to set self to True in one_way_mode and you can leave self in hedge_mode, can adjust the mode using the setPositionMode() method
:param bool [params.hedged]: *swap and future only* True for hedged mode, False for one way mode, default is False
:param bool [params.reduceOnly]: True or False whether the order is reduce-only
:param boolean [params.uta]: set to True for the unified trading account(uta), defaults to False
:param str [params.posSide]: *uta only* hedged two-way position side, long or short
:returns dict: an `order structure <https://docs.ccxt.com/#/?id=order-structure>`
Nrd   r   	stopPricer  r  r  trailingPercentcallbackRatior   FrR   r  r  r  )r  r  r  safe_value_2r  r  r  create_uta_order_request'privateUtaPostV3TradePlaceStrategyOrderprivateUtaPostV3TradePlaceOrdercreate_order_request(privateSpotPostV2SpotTradePlacePlanOrder+privateMarginPostV2MarginIsolatedPlaceOrder*privateMarginPostV2MarginCrossedPlaceOrder$privateSpotPostV2SpotTradePlaceOrder&privateMixPostV2MixOrderPlacePlanOrder&privateMixPostV2MixOrderPlaceTpslOrder"privateMixPostV2MixOrderPlaceOrderr7  rF  )r  r  r  rs  r!  r  r  r  marginParamsr  r  r0  takeProfitTriggerPricerN  isTrailingPercentOrderisTriggerOrderisStopLossTriggerOrderisTakeProfitTriggerOrderisStopLossOrTakeProfitTriggerr  r   r  r  s                          r  rI  bitget.create_order  s>    \ !!!V$99-P!!_
((nM#vG!%9J!K,,V5FX!0!<%T1!5T!A#9#E (>(ZBZ%33FM5RWXV33F$PU^G,!%!M!Mg!VV!%!E!Eg!NN//dEZGf~!%)%R%RSZ%[[H:-%)%U%UV]%^^H7*%)%T%TU\%]]H%)%N%Nw%WWH!%;%)%P%PQX%YYH2%)%P%PQX%YYH%)%L%LW%UUH ~~h3f--i 	"& WN
  \^]W  ZYUs   IH8C!I8H;9IH>=III1I2III+I,'II	 I4I5II*I;I>IIIII	IIIc                    U R                  U5      nS nU R                  Xv5      u  pUS:X  a  S n	U R                  SU5      u  pU	b  SnUUS   U R                  X5      US.n
U R	                  USS5      nUb  XS'   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S LnUS LnUS LnUS LnU=(       d    UnU(       Ga  U(       aq  U R                  USS5      nUU
S'   U R                  X5      U
S
'   Ub+  U R                  X5      U
S'   U R                  USS5      U
S'   OU R                  USS5      U
S'   OwU(       ap  U R                  USS5      nUU
S'   U R                  X5      U
S'   Ub+  U R                  X5      U
S'   U R                  USS5      U
S'   OU R                  USS5      U
S'   U R                  USS	/5      nGOU(       a  U R                  USS5      nU R                  US5      nU R                  UU5      U
S
'   Ub,  U R                  UU5      U
S'   U R                  USS5      U
S'   OU R                  USS5      U
S'   U(       a  U R                  USS5      nU R                  US5      nU R                  UU5      U
S'   Ub,  U R                  UU5      U
S'   U R                  USS5      U
S'   OU R                  USS5      U
S'   US:H  nU(       d  U R                  X5      U
S'   X*S'   U R                  US5      nS nU R                  UUS:H  U5      u  nnU R                  U R                  S5      nU R                  USU5      nU(       a  SU
S'   O#US:X  a  SU
S'   OUS:X  a  SU
S'   OUS :X  a  S!U
S'   U R                  US"S#5      n S n!U R                  US$S#5      u  n!nU (       a+  U!(       d  U(       a  US%:X  a  S&OS'n"U"U
S('   O#U(       d  S)U
S"'   OU!(       a  US*:X  a  S&OS'n#U#U
S('   U R                  U/ S+Q5      nU R!                  X5      $ ),Nr  rd   r  rE   )r  r  r#  rs  r  r  r  r  r1  r.  slTriggerByr  r   slOrderTyper  r  tpTriggerByr!  tpOrderTyper  rM  r  rt  r  	post_onlyr  r  gtcr  fokr  iocr  Fr  r'  longshortr  yesr&  )r1  r.  r2  r  r  )r  r  r  amount_to_precisionr  r  rP  r  rG  price_to_precisionrR  handle_post_onlysafe_string_upperr  rB  handle_param_boolr=  )$r  r  r  rs  r!  r  r  r  r  r  r  r  r0  r]  r1  r.  
isStopLossisTakeProfitisStopLossTriggerisTakeProfitTriggerrb  slTypetpTypeslTriggerPricer   tpTriggerPricer!  isMarketOrderexchangeSpecificTifParamr2  r  r  r  r  reduceOnlyPosSider  s$                                       r  rQ  bitget.create_uta_order_request_  s   V$"AA&Q& J!%!C!CMSY!ZJ%&#Tl++F;	
 **6;P$#0K YYv7F#//H!%!1!1&:K!L??6:6__V\:
T)
!-0<4D@(9(P=P%( ))&-H)/&&*&=&=f&[
#$.2.E.Ef.TGN+-1-=-=fmU\-]GM*-1-=-=fmU]-^GM*$))&-H)/&(,(?(?(_%$.2.E.Ef.TGN+-1-=-=fmU\-]GM*-1-=-=fmU]-^GM*YYv9J'KLF!%!3!3Hnk!Z#//'B&*&=&=fn&U
#+.2.E.Efl.[GN+-1-=-=fmU\-]GM*-1-=-=fmU]-^GM*!%!3!3JP[!\#//
GD(,(?(?(W%+.2.E.Efl.[GN+-1-=-=fmU\-]GM*-1-=-=fmU]-^GM* H,M #'#:#:6#I #'K '+'7'7'N$H#44]D\`kDkmstHf!%!7!7FZ![00HZ[K)4&%).&%).&%).&^^FL%@
//%H6/3v~FG!%6	"2(-%%)U]&%,	"6#ab{{7++r  c                    U R                  U5      nS nS n	U R                  SXv5      u  pU R                  SU5      u  pUS   US.n
S nU R                  USS5      u  pS nU R                  US5      u  pUb  U(       + nUS:H  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 R                  US5      nUS LnUS LnUS LnUS LnUS LnU=(       d    UnU=(       d    UnU R                  USU R                  U5      5      nU R                  USS5      nUS LnU R                  UUUU5      S:  a  [        U R                  S-   5      eUS:X  a  U R                  X5      U
S'   U R                  USSS5      nU R                  USS5      nU R                  USS5      nU R                  USS5      n S n!U R                  UU S:H  U5      u  n!nU R                  U R                   S5      n"U R                  USU"5      n#U!(       a  SU
S'   O#U#S:X  a  SU
S'   OU#S :X  a  S U
S'   OU#S!:X  a  S!U
S'   U R#                  U/ S"Q5      nUS#:X  d  US$:X  Ga  US%   U
S&'   U R%                  X5      U
S''   S n$U R'                  Xv5      u  n$nU$U
S('   Ub  UU
S'   U(       d  U(       d  U(       a  UU
S'   U(       a[  U(       d  [)        U R                  S)-   5      eUc  [+        U R                  S*-   5      eS+U
S,'   U R                  UU5      U
S	'   UU
S'   GOU(       Ga  S-U
S,'   U R                  X5      U
S	'   Ub  U R                  X5      U
S.'   U(       ag  U R                  US	S5      n%U R                  UU%5      U
S/'   U R                  US5      n&U R                  UU&5      U
S0'   U R                  US1S5      n'U'U
S2'   U(       ag  U R                  US	S5      n(U R                  UU(5      U
S3'   U R                  US5      n)U R                  UU)5      U
S4'   U R                  US1S5      n*U*U
S5'   OU(       a  U(       d  [        U R                  S6-   5      eU(       a  US7:X  a  S8OS9U
S:'   OUS7:X  a  S;OS7U
S:'   U(       a  U R                  X5      U
S	'   S<U
S,'   OU(       a  U R                  UU5      U
S	'   S=U
S,'   O^U(       a(  U R	                  US	S5      n%U R                  UU%5      U
S>'   U(       a(  U R	                  US	S5      n(U R                  UU(5      U
S?'   U(       dK  U	c  S@n	U	S@:X  a  SAOSBn+U+U
SC'   Un,U(       a  U(       d  SDU
S'   OUS;:X  a  S7OS;n,SEU
SF'   OU(       a  SGU
SF'   U,U
SH'   GOUSI:X  Ga  U(       d  U(       a  [-        U R                  SJ-   5      eX:SH'   S n-S n.SKn/U R/                  USSLSK5      u  n/nU(       a  US;:X  a  SMn.U R1                  USN5      n0U R#                  USN5      nU0b  U R3                  UU05      n-OU/(       ag  Uc  [-        U R                  SO-   5      eU R                  U5      n1U R                  U5      n2[4        R6                  " U1U25      n3U R3                  UU35      n-O%U R3                  X5      n-OSPn.U R%                  X5      n-Ub  UU
S'   U	b  SQU
SR'   U(       a  US;:X  a  U-U
SS'   OeU-U
ST'   O_U-b  U-U
S''   Ub5  U.U
S,'   UU
S'   U R                  X5      U
S	'   Ub  U R                  X5      U
S.'   O[9        U R                  SU-   U-   SV-   5      eU R;                  X5      $ )WNrd   rE   )r  rt  r  F
oneWayModer  rM  r  r  r  r1  r.  trailingTriggerPricerN  rO  r   zk createOrder() params can only contain one of triggerPrice, stopLossPrice, takeProfitPrice, trailingPercentr  r  r  triggerType
mark_pricer  r  r  r  r  ri  r  r  r  r  )rM  r  r  r  r1  r.  r2  r  r  rN  r  rT   rU   r  r  r  r  z; createOrder() bitget trailing orders must be market orderszL createOrder() bitget trailing orders must have a trailingTriggerPrice param
track_planplanTypenormal_planr  r0  stopLossExecutePricer  stopLossTriggerTyper-  stopSurplusExecutePricestopSurplusTriggerTypezI createOrder() bitget stopLoss or takeProfit orders must be market ordersr'  rm  rn  holdSider&  pos_loss
pos_profitr/  r,  r  crossedr  r  ry  Close	tradeSideOpenrs  rR   z_ createOrder() does not support stop loss/take profit orders on spot markets, only swap marketsTr  r  r+  z createOrder() requires the price argument for market buy orders to calculate the total cost to spend(amount * price), alternatively set the createMarketBuyOrderRequiresPrice option or param to False and pass the cost to spend in the amount argumentr!  r  loanTyper*  r"  z  createOrder() does not support  orders)r  rc  r  rt  rP  r  rG  number_to_stringr  r  r+   rE   rq  rB  rr  rs  r  r  rp  r  r0   r/   r4   r  rP  cost_to_precisionr?   rQ  r6   r=  )4r  r  r  rs  r!  r  r  r  rT  r  r  r  r  r}  r  r0  r]  r1  r.  r_  r`  ra  ru  rv  rb  isStopLossOrTakeProfitr  rN  r^  r  r  r  r~  r2  r  r  r  r{  slPricery  r|  tpPricerz  marginModeRequestrequestSidequantityr  r  r+  rs  rq  quoteAmounts4                                                       r  rT  bitget.create_order_request  sh   V$

!??v^
!??vV
Tl
 //%H
!33FLI
!#^F(((nM#vG!%9J!K??6:6__V\:
%T1!5T!A#9#E T)
!-(>(ZBZ%!+!;|#//8NPTPePefkPlm,,V5FX!0!<88N$:<TVlmpqq  +X  !X  Y  Y7?#66vEGG--f6H-Yef^^FL%@
**6;P#'#5#5fg}#U 00@X\g@giop&!33DLLBVW,,V]DVW*GGE!$GGE!$GGE!$GG6  $T  U& jH&<$*:$6GL!"66vFGFOK"&"E"Ef"UK%0GM"('4$!>BX)9&%$$TWW/l%lmm'/+DGG  7E  -E  F  F&2
#*.*A*A&J^*_'+:(&3
#*.*A*A&*W'$.2.E.Ef.TGN+%)%7%7.R]%^N6:6M6MfVd6eG23"..xAG6:6M6MfV]6^G23!--hMF5;G12%)%7%7
NT_%`N9=9P9PQWYg9hG56"..z7CG9=9P9PQWY`9aG56!--j&,OF8>G45.$'2}(}~~59V^&'GJ'48FN%GJ').2.E.Ef.cGN+*4GJ'-.2.E.EfNd.eGN+*6GJ'%)%6%6xQ\%]N595L5LVUc5dG12%)%6%6z>S^%_N8<8O8OPVXf8gG450%!(J2<2GIj!(9%"!05- 26fU/6,/5,"-6!,0F"477  .O  $O  P  P"FOHH04-8<8U8UV\^k  nQ  SW  9X5-v$%-"''7662##55fdCH6}*477  6q  ,q  r  r'+'<'<V'D&*&;&;E&B&-&8&8{&S#'#9#9&+#N#55fEH#33FC('4$%&.
# dem+3GK(*2GJ''&.GFO+*2GJ'-=GM*.2.E.Ef.[GN+(262I2I&2X/tww)KKjX[ddee{{7++r  ordersc           	        #    U R                  5       I S h  vN   / nS nS n[        S[        U5      5       H  nX   nU R                  US5      nUc  UnOXH:w  a  [	        U R
                  S-   5      e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                  S	U5      nUS   nUb#  Uc  UnOX_:w  a  [	        U R
                  S
-   5      eU R                  XXX5      nUR                  U5        M     U R                  U5      nU R                  U5      I S h  vN nU R                  US/ 5      nU R                  UU5      $  GNk N,7f)Nr   r  ; createOrders() requires all orders to have the same symbolr  rs  r!  r  r  re   S createOrders() requires all orders to have the same margin mode(isolated or cross)r  )r  r9  r:  rG  r0   rE   r  r  rQ  r;  r  privateUtaPostV3TradePlaceBatchr8  parse_orders)r  r  r  ordersRequestsr  r  rW  rawOrderr`  r  rs  r!  r  orderParamsmarginResultcurrentMarginModeorderRequestr  r  r  s                       r  create_uta_ordersbitget.create_uta_orderss  s    !!!
q#f+&AyH''(;H~!%$TWW/l%lmm##Hf5D##Hf5D__Xx8FOOHg6E//(HbAK==nkZL ,Q ,%!2J!6(  4I  *I  J  J88W\jL!!,/- '. V$==nMM ~~h3  v..W 	"8 Ns"   FFE FF*FFc           	      d  #    U R                  5       I Sh  vN   SnU R                  USSS5      u  p2U(       a  U R                  X5      I Sh  vN $ / nSnSn[        S[	        U5      5       H  nX   nU R                  US5      n	Uc  U	nOXY:w  a  [        U R                  S-   5      e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                  SU5      nUS   nUb$  Uc  UnOUU:w  a  [        U R                  S-   5      eU R                  XXX5      nUR                  U5        M     U R                  U5      nUS   US.nSnUS   (       d
  US   (       aR  Uc  SnUS:X  a  SOSnUUS'   US   US'   SnU R                  UU5      u  nnUUS'   U R                  U5      I Sh  vN nOYUS:X  a  U R                  U5      I Sh  vN nO9US:X  a  U R!                  U5      I Sh  vN nOU R#                  U5      I Sh  vN nU R                  US0 5      nU R                  US/ 5      nU R                  US/ 5      nU R%                  UU5      nU R'                  UU5      $  GN GNW N N N Nm7f)a!  
create a list of trade orders(all orders should be of the same symbol)

https://www.bitget.com/api-doc/spot/trade/Batch-Place-Orders
https://www.bitget.com/api-doc/contract/trade/Batch-Order
https://www.bitget.com/api-doc/margin/isolated/trade/Isolated-Batch-Order
https://www.bitget.com/api-doc/margin/cross/trade/Cross-Batch-Order
https://www.bitget.com/api-doc/uta/trade/Place-Batch

: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 api endpoint
:param boolean [params.uta]: set to True for the unified trading account(uta), defaults to False
:returns dict: an `order structure <https://docs.ccxt.com/#/?id=order-structure>`
Nre   r   Fr   r  r  r  rs  r!  r  r  r  rE   )r  	orderListrT   rU   r  r  r  r  r  r  r  r  failureListsuccessList)r  r  r  r9  r:  rG  r0   rE   r  r  rT  r;  r  r  'privateMixPostV2MixOrderBatchPlaceOrder0privateMarginPostV2MarginIsolatedBatchPlaceOrder/privateMarginPostV2MarginCrossedBatchPlaceOrder%privateSpotPostV2SpotTradeBatchOrdersrF  r  )r  r  r  r   r  r  r  rW  r  r`  r  rs  r!  r  r  r  r  r  r  r  r  r  r  r  failure	orderInfoboths                              r  create_ordersbitget.create_orders  s     !!!33FNESXY//???
q#f+&AyH''(;H~!%$TWW/l%lmm##Hf5D##Hf5D__Xx8FOOHg6E//(HbAK==nkZL ,Q ,%!2J!%66(  4I  *I  J  J44XTSXfL!!,/- '. V$Tl'
 6Nx 0!$
.8G.C	*$5GL!$*:$6GL!K"&"E"Eff"UK%0GM"!II'RRH:%!RRSZ[[H7"!QQRYZZH!GGPPH0 x4//$r:OOD-<	  G4  v..a 	" @T S[ZPsk   J0J"7J0J%FJ0&J('J0J*J0&J,'J0 J.A"J0%J0(J0*J0,J0.J0rE   c                   #    U R                  5       I Sh  vN   U R                  U5      n0 n	U R                  USS5      n
U
b  U R                  US/5      nXS'   OXS'   US:H  nU R	                  USS5      nUSLnU R                  US5      nUSLnU R                  US	5      nUSLnU R                  US
5      nU R                  US5      nUSLnUSLnU R                  USU R                  U5      5      nU R                  USS5      nUSLnU R                  XUU5      S:  a  [        U R                  S-   5      eU R                  U/ SQ5      nSnSnSnU R                  X5      u  nnU R                  USSS5      u  nnU(       Ga  Ub  U R                  X%5      U	S'   U(       d  U(       Ga.  U(       aq  U R                  USS5      nUU	S'   U R                  X.5      U	S
'   Ub+  U R                  X&5      U	S'   U R                  USS5      U	S'   OU R                  USS5      U	S'   OxU(       aq  U R                  USS5      nUU	S'   U R                  UU5      U	S'   Ub+  U R                  X&5      U	S'   U R                  USS5      U	S'   OU R                  USS5      U	S'   U R                  USS	/5      nU R                  U R!                  X5      5      I Sh  vN nGOAUb  U R                  X&5      U	S'   U R#                  U R!                  X5      5      I Sh  vN nGO US   (       Ga  U R                  US 5      nU R                  US 5      nU R%                  U R&                  S!S"5      nU(       d  Ub  U(       ax  US#:X  ar  Uc  Uc  [)        U R                  S$-   5      eU R                  U5      n U R                  U5      n!Uc  [*        R,                  " U U!5      OUn"U R                  UU"5      U	S%'   OU R                  X%5      U	S%'   X9S&'   Ub)  U R                  X,5      U	S'   U R                  X&5      U	S''   OU R                  X&5      U	S'   Ub*  U R/                  U R!                  X5      5      I Sh  vN nGOUS(   U	S)'   U R1                  U R!                  X5      5      I Sh  vN nGOtUS*   (       d+  US+   (       d!  [3        U R                  S,-   US-   -   S.-   5      eUS(   U	S)'   UU	S/'   U(       d9  U(       d2  U R                  X%5      U	S0'   Ub  U(       d  U R                  X&5      U	S1'   U(       af  U(       d  [5        U R                  S2-   5      eUb  U R                  UU5      U	S3'   UU	S'   U R7                  U R!                  X5      5      I Sh  vN nGOU(       d  U(       a  US4   U	S5'   U R                  X%5      U	S%'   Ub  U R                  X&5      U	S''   U(       a  U R                  X.5      U	S'   OU(       a  U R                  UU5      U	S'   U R9                  U R!                  X5      5      I Sh  vN nGOU(       Ga  U R                  X,5      U	S3'   U(       ag  U R;                  USS5      n#U R                  UU#5      U	S6'   U R=                  US5      n$U R                  UU$5      U	S7'   U R                  US-S85      nUU	S9'   U(       ag  U R;                  USS5      n%U R                  UU%5      U	S:'   U R=                  US5      n&U R                  UU&5      U	S;'   U R                  US-S85      nUU	S<'   U R7                  U R!                  X5      5      I Sh  vN nOU R?                  5       n'U R                  US=S>U'5      n(U R                  US>5      nU(U	S='   U(       a(  U R	                  USS5      n#U R                  UU#5      U	S?'   U(       a(  U R	                  USS5      n%U R                  UU%5      U	S@'   U RA                  U R!                  X5      5      I Sh  vN nU RC                  USA0 5      n)U RE                  U)U5      $  GN- GNp GN2 GN GN GN GN  GN NA7f)Ba*  
edit a trade order

https://www.bitget.com/api-doc/spot/plan/Modify-Plan-Order
https://www.bitget.com/api-doc/spot/trade/Cancel-Replace-Order
https://www.bitget.com/api-doc/contract/trade/Modify-Order
https://www.bitget.com/api-doc/contract/plan/Modify-Tpsl-Order
https://www.bitget.com/api-doc/contract/plan/Modify-Plan-Order
https://www.bitget.com/api-doc/uta/trade/Modify-Order
https://www.bitget.com/api-doc/uta/strategy/Modify-Strategy-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 you want to trade in units of the base currency
:param float [price]: the price at which the order is to be fulfilled, in units of the quote currency, ignored in market orders
:param dict [params]: extra parameters specific to the exchange API endpoint
:param float [params.triggerPrice]: the price that a trigger order is triggered at
:param float [params.stopLossPrice]: *swap only* The price at which a stop loss order is triggered at
:param float [params.takeProfitPrice]: *swap only* The price at which a take profit order is triggered at
:param dict [params.takeProfit]: *takeProfit object in params* containing the triggerPrice at which the attached take profit order will be triggered(perpetual swap markets only)
:param float [params.takeProfit.triggerPrice]: *swap only* take profit trigger price
:param dict [params.stopLoss]: *stopLoss object in params* containing the triggerPrice at which the attached stop loss order will be triggered(perpetual swap markets only)
:param float [params.stopLoss.triggerPrice]: *swap only* stop loss trigger price
:param float [params.stopLoss.price]: *swap only* the execution price for a stop loss attached to a trigger order
:param float [params.takeProfit.price]: *swap only* the execution price for a take profit attached to a trigger order
:param str [params.stopLoss.type]: *swap only* the type for a stop loss attached to a trigger order, 'fill_price', 'index_price' or 'mark_price', default is 'mark_price'
:param str [params.takeProfit.type]: *swap only* the type for a take profit attached to a trigger order, 'fill_price', 'index_price' or 'mark_price', default is 'mark_price'
:param str [params.trailingPercent]: *swap and future only* the percent to trail away from the current market price, rate can not be greater than 10
:param str [params.trailingTriggerPrice]: *swap and future only* the price to trigger a trailing stop order, default uses the price argument
:param str [params.newTriggerType]: *swap and future only* 'fill_price', 'mark_price' or 'index_price'
:param boolean [params.uta]: set to True for the unified trading account(uta), defaults to False
:returns dict: an `order structure <https://docs.ccxt.com/#/?id=order-structure>`
Nr  r  r  r  rM  r  r  r  r1  r.  r  rN  newCallbackRatior   zi editOrder() params can only contain one of triggerPrice, stopLossPrice, takeProfitPrice, trailingPercent)	rM  r  r  r  r1  r.  r  r  rN  rq   r   Fr#  re  r  r   rf  r  rg  r!  rh  r  rR   r+  editMarketBuyOrderRequiresPriceTr&  z editOrder() requires price argument for market buy orders on spot markets to calculate the total amount to spend(amount * price), alternatively provide `cost` in the paramsr  rt  r  rE   r  rT   rU   z editOrder() does not support r  r  r  newSizenewPricez9 editOrder() bitget trailing orders must be market ordersnewTriggerPricer  r  newStopLossTriggerPricenewStopLossExecutePricer  newStopLossTriggerTypenewSurplusTriggerPricenewStopSurplusExecutePricenewStopSurplusTriggerTypenewClientOidnewClientOrderIdnewPresetStopLossPricenewPresetStopSurplusPricer  )#r  r  r  r  rP  r  rG  r  r  r+   rE   r  r  rp  rq  (privateUtaPostV3TradeModifyStrategyOrderr=   privateUtaPostV3TradeModifyOrderrB  r  r4   r?   rQ  )privateSpotPostV2SpotTradeModifyPlanOrder,privateSpotPostV2SpotTradeCancelReplaceOrderr6   r0   'privateMixPostV2MixOrderModifyPlanOrder'privateMixPostV2MixOrderModifyTpslOrderrR  rP  uuid#privateMixPostV2MixOrderModifyOrderr7  rF  )*r  rE   r  r  rs  r!  r  r  r  r  r  r}  r  r_  r  isStopLossOrderr  isTakeProfitOrderr1  r.  ru  rv  r  rN  r^  r  r  r   ry  rz  r+  r  rs  rq  	finalCostr{  r  r|  r  defaultNewClientOrderIdr  r  s*                                             r  
edit_orderbitget.edit_order  s    H !!!V$
 **6?KP$YYv'89F#0K !#I(((nM%T1@'t3//&2CD+47??6:6__V\:
T)
!-#//8NPTPePefkPlm,,V5FHZ[!0!<88N5FH^_bcc  +V  !V  W  W6  $z  {"AA&QV33FKPUVV!!%!9!9&!I"3"!--fmVLF-3GM**.*A*A&*XGJ'(262I2I&2X/151A1A&-Y`1a.151A1A&-Ya1b.&!--fmVLF-3GM*,0,C,CFO,\GL)(262I2I&2X/151A1A&-Y`1a.151A1A&-Ya1b.6O=N+OP!%!N!Nt{{[bOk!ll$'+'>'>v'MGG$!%!F!Ft{{SZGc!ddF^^##FF3DYYvv.F.2nnT\\Klnr.s+/D4D=^bfk^k=T\&tww  2a  (a  b  b#'#8#8#@L"&"7"7">KTXT`!3!3L+!NgkI&*&=&=fi&PGFO"&":":6"J#'K '*.*A*A&*W'*.*A*A&*P'#'#:#:6#I '!%!O!OPTP[P[\cPl!mm$*4L!!%!R!RSWS^S^_fSo!pp6NVH-="477-M#MPVW]P^#^aj#jkk &tGH%0GM"$_%)%=%=f%M	"%/E*.*A*A&*PGJ'%$$TWW/j%jkk'3151H1HQe1fG-..=*+!%!M!MdkkZaNj!kk"o(.z(:%"&":":6"J$.2.E.Ef.TGN+".2.E.Ef.\GN+&.2.E.Efo.^GN+!%!M!MdkkZaNj!kk-1-D-DV-Z)*%)%7%7.R]%^N9=9P9PQWYg9hG56"..xAG9=9P9PQWY`9aG56!--hMF8>G45%)%7%7
NT_%`N8<8O8OPVXf8gG45"..z7CG<@<S<STZ\c<dG89!--j&,OF;AG78!%!M!MdkkZaNj!kk*.))+'#'#5#5fnN`by#z 6+=>*:'%)%6%6xQ\%]N8<8O8OPVXf8gG45%)%6%6z>S^%_N;?;R;RSY[i;jG78!%!I!I$++V]Jf!gg ~~h3f--s 	"p m e, n q  l l" l hs   aaJ?aaA aa	Ea1a21a#a$C.aaB"a5a6D!aaCaa*aa	aaaaaaac                   #    Uc  [        U R                  S-   5      eU R                  5       I Sh  vN   U R                  U5      nSnSnU R	                  SU5      u  pS0 nU R                  US5      nU R                  USS5      n	U R                  U/ SQ5      nUS   (       a  U	(       d  US	   US
'   Sn
U R                  USSS5      u  pU	=(       d    UnUS   =(       d    US   nU=(       a    U=(       a    U
(       + nU R                  USS5      nU(       a:  / n0 nUb  U R                  US5      nUUS'   OUUS'   UR                  U5        XS'   OUb  U R                  US5      nXS'   OXS'   U
(       a[  U	(       a*  U R                  U R                  Xs5      5      I Sh  vN nGOU R                  U R                  Xs5      5      I Sh  vN nGOUS   (       d
  US   (       a  SnU R                  XC5      u  nnUUS'   U(       aB  U R                  USS5      nUUS'   U R!                  U R                  Xs5      5      I Sh  vN nGO?U	(       a*  U R!                  U R                  Xs5      5      I Sh  vN nGOU R#                  U R                  Xs5      5      I Sh  vN nOUS   (       a  Ub^  US:X  a)  U R%                  U R                  Xs5      5      I Sh  vN nOUS:X  a(  U R'                  U R                  Xs5      5      I Sh  vN nOzU	(       a)  U R)                  U R                  Xs5      5      I Sh  vN nOJU R+                  U R                  Xs5      5      I Sh  vN nO![-        U R                  S-   US   -   S-   5      eU R                  US0 5      nSnU(       a  U R                  US/ 5      nUS   nOU
(       a
  U	(       a  UnOUnU R/                  UU5      $  GN GNE GN GN GN{ GNT GN N N N7f)a^  
cancels an open order

https://www.bitget.com/api-doc/spot/trade/Cancel-Order
https://www.bitget.com/api-doc/spot/plan/Cancel-Plan-Order
https://www.bitget.com/api-doc/contract/trade/Cancel-Order
https://www.bitget.com/api-doc/contract/plan/Cancel-Plan-Order
https://www.bitget.com/api-doc/margin/cross/trade/Cross-Cancel-Order
https://www.bitget.com/api-doc/margin/isolated/trade/Isolated-Cancel-Order
https://www.bitget.com/api-doc/uta/trade/Cancel-Order
https://www.bitget.com/api-doc/uta/strategy/Cancel-Strategy-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 str [params.marginMode]: 'isolated' or 'cross' for spot margin trading
:param boolean [params.trigger]: set to True for canceling trigger orders
:param str [params.planType]: *swap only* either profit_plan, loss_plan, normal_plan, pos_profit, pos_loss, moving_plan or track_plan
:param boolean [params.trailing]: set to True if you want to cancel a trailing order
:param boolean [params.uta]: set to True for the unified trading account(uta), defaults to False
:param str [params.clientOrderId]: the clientOrderId of the order, id does not need to be provided if clientOrderId is provided
:returns dict: An `order structure <https://docs.ccxt.com/#/?id=order-structure>`
Nz) cancelOrder() requires a symbol argumentr[   r  stopr  r  r  r  rR   rE   r  r   FrT   rU   r  r  r  orderIdListr  r  r  r  r  z  cancelOrder() does not support r  r  r  r  r   )r/   rE   r  r  r  r  rP  r  r  r  r;  (privateUtaPostV3TradeCancelStrategyOrderr=   privateUtaPostV3TradeCancelOrderr  rG  'privateMixPostV2MixOrderCancelPlanOrder#privateMixPostV2MixOrderCancelOrder,privateMarginPostV2MarginIsolatedCancelOrder+privateMarginPostV2MarginCrossedCancelOrder)privateSpotPostV2SpotTradeCancelPlanOrder%privateSpotPostV2SpotTradeCancelOrderr6   rF  )r  rE   r  r  r  r  r  r  r  r  r   isPlanOrder
isContractisContractTriggerEndpointr  r  r  r  r  r  rz  r  s                         r  cancel_orderbitget.cancel_order  s    0 >#DGG.Y$YZZ!!!V$
!??vV
??6:6##FFI>6#BCv7 &tGH33FM5RWX)F^7vh'7
$.$J;$Js7!**6?KP$KG(6?;'4$%'	"w'%0M"(6?;'4$%'	"!%!N!Nt{{[bOk!ll!%!F!Ft{{SZGc!ddVn&"2K"&"E"Ef"UK%0GM"++FJM&.
#!%!M!MdkkZaNj!kk!%!M!MdkkZaNj!kk!%!I!I$++V]Jf!ggF^%+%)%V%VW[WbWbcjWs%ttH7*%)%U%UVZVaVabiVr%ssH%)%S%STXT_T_`gTp%qqH%)%O%OPTP[P[\cPl%mmHtww)KKfU[n\_hhiif x4$mR@IaLEw v..w 	"F md lkg  us  rms   /P O%E1P #O($)P O+A7P O.0P 6O17)P  O4!;P O7.P O:/P ;O<<(P $O>%BP (P +P .P 1P 4P 7P :P <P >P c                   #    Uc  [        U R                  S-   5      eU R                  5       I S h  vN   U R                  U5      nS nU R	                  XC5      u  pS/ n[        S[        U5      5       H!  nX   nUUS   US.n	UR                  U	5        M#     U R                  U5      I S h  vN n
U R                  U
S/ 5      nU R                  X5      $  N N*7f)N* cancelOrders() requires a symbol argumentr   rE   )r  r  r  r  )r/   rE   r  r  r  r9  r:  r;   privateUtaPostV3TradeCancelBatchr8  r  )r  idsr  r  r  r  requestListrW  individualIdrz  r  r  s               r  cancel_uta_ordersbitget.cancel_uta_ordersX  s     >#DGG.Z$Z[[!!!V$"AA&Qq#c(#A6L' ,'E
 u% $ >>{KK ~~h3  ..9 	" Ls"   /CCA:C,C-)CCr  c                   #    Uc  [        U R                  S-   5      eU R                  5       I Sh  vN   U R                  U5      nSnU R	                  USSS5      u  pSU(       a  U R                  XU5      I Sh  vN $ SnU R                  SU5      u  pcU R                  USS5      nU R                  USS/5      n/ n[        S[        U5      5       H  n	X   n
S	U
0nUR                  U5        M     S
US   0nUS   (       a  Uc  XS'   OXS'   SnUS   (       a  UbX  US:X  a)  U R                  U R                  X5      5      I Sh  vN nOU R                  U R                  X5      5      I Sh  vN nOU R                  U R                  X5      5      I Sh  vN nOqSnU R!                  XC5      u  pXS'   U(       a)  U R#                  U R                  X5      5      I Sh  vN nO(U R%                  U R                  X5      5      I Sh  vN nU R'                  US0 5      nU R)                  US/ 5      nU R+                  UU5      $  GN GN GN N N Nr NK7f)a  
cancel multiple orders

https://www.bitget.com/api-doc/spot/trade/Batch-Cancel-Orders
https://www.bitget.com/api-doc/contract/trade/Batch-Cancel-Orders
https://www.bitget.com/api-doc/contract/plan/Cancel-Plan-Order
https://www.bitget.com/api-doc/margin/cross/trade/Cross-Batch-Cancel-Order
https://www.bitget.com/api-doc/margin/isolated/trade/Isolated-Batch-Cancel-Orders
https://www.bitget.com/api-doc/uta/trade/Cancel-Batch

:param str[] ids: order ids
:param str symbol: unified market symbol, default is None
:param dict [params]: extra parameters specific to the exchange API endpoint
:param str [params.marginMode]: 'isolated' or 'cross' for spot margin trading
:param boolean [params.trigger]: *contract only* set to True for canceling trigger orders
:param boolean [params.uta]: set to True for the unified trading account(uta), defaults to False
:returns dict: an array of `order structures <https://docs.ccxt.com/#/?id=order-structure>`
Nr  r\   r   Fr  r  r   r  r  rE   rR   r  r  r  r  r  r  )r/   rE   r  r  r  r  r  rP  r  r9  r:  r;  0privateMarginPostV2MarginCrossedBatchCancelOrderr=  1privateMarginPostV2MarginIsolatedBatchCancelOrder*privateSpotPostV2SpotTradeBatchCancelOrderr  r  )privateMixPostV2MixOrderBatchCancelOrdersr  r8  r  )r  r  r  r  r  r   r  r  r  rW  r  r  r  r  r  r  r  s                    r  cancel_ordersbitget.cancel_ordersy  s]    & >#DGG.Z$Z[[!!!V$33FNESXY//VDDD
!??PVW
##FFI>6FI#67q#c(#A6L<G w' $ fTl
 &>z1#.K %0M"&>%(%)%Z%Z[_[f[fgn[w%xxH%)%[%[\`\g\gho\x%yyH!%!P!PQUQ\Q\]dQm!nnK"&"E"Ef"UK%0M"!%!M!MdkkZaNj!kk!%!O!OPTP[P[\cPl!mm" x4mR8  00w 	"
 E.  yyn lms~   /II
A	I;I<CI	I
(I2I3(IIAI$I%(II=IIIIIIIc           	        #    Uc  [        U R                  S-   5      eU R                  5       I Sh  vN   U R                  U5      nSnU R	                  SU5      u  pBSnU R                  X25      u  pRSUS   0nU R                  USS5      nU R                  USS/5      nSnSn	U R                  USSS	5      u  pU	(       a9  US
:X  a  Ub  SnXVS'   U R                  U R                  Xb5      5      I Sh  vN nGOOUS   (       a  Ub  [        U R                  S-   5      eU(       a1  SUS   /0n
U R                  U R                  X5      5      I Sh  vN nO(U R                  U R                  Xb5      5      I Sh  vN nU R                  US5      nU R                  US5      nU R!                  US5      nU R#                  UU R%                  USSS5      UU R'                  U5      S.5      /$ XVS'   U(       a)  U R)                  U R                  Xb5      5      I Sh  vN nO(U R+                  U R                  Xb5      5      I Sh  vN nU R                  US5      nU R-                  U/ SQ5      nU R/                  USS5      nSnUb  Ub  U R1                  UU5      nOUnU R3                  U5      $  GN GN GNe GN? N Ny7f)aT  
cancel all open orders

https://www.bitget.com/api-doc/spot/trade/Cancel-Symbol-Orders
https://www.bitget.com/api-doc/spot/plan/Batch-Cancel-Plan-Order
https://www.bitget.com/api-doc/contract/trade/Batch-Cancel-Orders
https://www.bitget.com/api-doc/margin/cross/trade/Cross-Batch-Cancel-Order
https://www.bitget.com/api-doc/margin/isolated/trade/Isolated-Batch-Cancel-Orders

:param str symbol: unified market symbol
:param dict [params]: extra parameters specific to the exchange API endpoint
:param str [params.marginMode]: 'isolated' or 'cross' for spot margin trading
:param boolean [params.trigger]: *contract only* set to True for canceling trigger orders
:param boolean [params.uta]: set to True for the unified trading account(uta), defaults to False
:returns dict[]: a list of `order structures <https://docs.ccxt.com/#/?id=order-structure>`
Nz- cancelAllOrders() requires a symbol argumentrZ   r  rE   r  r  r   Fr  r  r  rR   zV cancelAllOrders() does not support margin markets, you can use cancelOrders() instead
symbolListrequestTimer  )r6  r  r  r  r  )
resultListr  rC  r  r  )r/   rE   r  r  r  r  safe_bool_2r  r  &privateUtaPostV3TradeCancelSymbolOrderr=  r6   .privateSpotPostV2SpotTradeBatchCancelPlanOrder+privateSpotPostV2SpotTradeCancelSymbolOrderr  r7  rG  r4  r  rK  r  r  safe_list_nsafe_list_2rF  r  )r  r  r  r  r  r  r  r  r  r   stopRequestr  responseDatar`  r  r  r  responseLists                     r  cancel_all_ordersbitget.cancel_all_orders  s    " >#DGG.]$]^^!!!V$
!??@QSYZ
"AA&QfTl
 ""669=6FI#6733F<MuV[\f$)"*K"-J!HHU\IeffH  F^%"477  .F  $F  G  G$vd|n)K &*%X%XY]YdYdepYy%zzH%)%U%UVZVaVabiVr%ssH !--hF	#~~h?++L(COO ("&"2"28T4"P%.$(LL$;	%   &1M"!%!M!MdkkZaNj!kk!%!O!OPTP[P[\cPl!mm ~~h/%%d,QR
&&tYF")@,,ZEL%L  .. 	"& g0  {s2 lmsm   /K J0CK 3J34AK J6(K :J9;B K J<(K J>A,K 3K 6K 9K <K >K c                   #    Uc  [        U R                  S-   5      eU R                  5       I Sh  vN   U R                  U5      n0 nU R	                  USS5      nUb  U R                  US/5      nXeS'   OXS'   SnSnU R                  USSS5      u  pU(       a)  U R                  U R                  XS5      5      I Sh  vN nOUS	   (       a)  U R                  U R                  XS5      5      I Sh  vN nOUS
   (       d
  US   (       aJ  US   US'   Sn	U R                  XC5      u  pXS'   U R                  U R                  XS5      5      I Sh  vN nO![        U R                  S-   US   -   S-   5      eU(       d+  [        U[        5      (       a  [        R                   " U5      nU R#                  US5      n
U
b&  [        U
[$        5      (       d  U R'                  X5      $ U R)                  US/ 5      n[+        U5      nUS:X  a0  [-        U R                  S-   U-   S-   U R                  U5      -   5      eU R#                  US0 5      nU R'                  X5      $  GN+ GN GNp GN7f)a  
fetches information on an order made by the user

https://www.bitget.com/api-doc/spot/trade/Get-Order-Info
https://www.bitget.com/api-doc/contract/trade/Get-Order-Details
https://www.bitget.com/api-doc/uta/trade/Get-Order-Details

:param str id: the order id
:param str symbol: unified symbol of the market the order was made in
:param dict [params]: extra parameters specific to the exchange API endpoint
:param boolean [params.uta]: set to True for the unified trading account(uta), defaults to False
:param str [params.clientOrderId]: the clientOrderId of the order, id does not need to be provided if clientOrderId is provided
:returns dict: An `order structure <https://docs.ccxt.com/#/?id=order-structure>`
Nz( fetchOrder() requires a symbol argumentr  r  r  r   r   FrR   rT   rU   rE   r  r  z fetchOrder() does not support r  r  r  r   z& fetchOrder() could not find order id z in )r/   rE   r  r  r  r  r  privateUtaGetV3TradeOrderInfor=  "privateSpotGetV2SpotTradeOrderInfor  privateMixGetV2MixOrderDetailr6   
isinstancerO  r6  r7  r7  rC  rF  r8  r:  r5   )r  rE   r  r  r  r  r  r  r   r  r  dataListdataListLengthfirsts                 r  fetch_orderbitget.fetch_order?  sL     >#DGG.X$XYY!!!V$
 **6?KP$YYv'89F#0K !#I33FL%QVW!??G@\]]HF^!DDT[[QXEabbHF^vh/ &tGHK"&"E"Ef"UK%0M"!??G@\]]Htww)JJVTZ^[^gghh` 
8S11zz(+H~~h/dD))''55>>(FB7XQ*R RUW WZ` `cgclclmucv vwwxB/..i 	" ^b ^sH   /I(IBI(?I 2I(2I"3AI(I%DI(I("I(%I(c           	      

  #    U R                  5       I Sh  vN   SnSn0 nSnU R                  SU5      u  pSn	U R                  USSS5      u  pU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O1U R	                  U R
                  SSS5      n
U R                  US	U
5      nSnU R                  USS
5      u  pU(       a>  SnSnU	(       a  SnSnOUS:X  a  Ub  SnSnOSnSnU R                  SXX4X5      I Sh  vN $ SnU R                  US5      nU R                  USS5      nU R                  US5      SLnU=(       d    UnU R                  SXt5      u  ptUb  X'S'   Ub  X7S'   U	(       d<  US:X  d	  US:X  d  Ub-  U R	                  USS5      nU R                  US5      nUb  UUS'   SnU R                  XT5      u  nnU R                  U/ SQ5      nU	(       ak  US:X  a  Ub  SnUUS'   U(       a*  U R                  U R                  Xt5      5      I Sh  vN nGOU R                  U R                  Xt5      5      I Sh  vN nGOUS:X  a  Ubz  Uc  U R!                  5       S-
  nX'S'   US:X  a*  U R#                  U R                  Xt5      5      I Sh  vN nGOFUS:X  a(  U R%                  U R                  Xt5      5      I Sh  vN nGOU(       a)  U R'                  U R                  Xt5      5      I Sh  vN nOU R)                  U R                  Xt5      5      I Sh  vN nOUUS '   U(       aA  U R                  USS!5      nUUS'   U R+                  U R                  Xt5      5      I Sh  vN nOpU(       aA  U R                  USS"5      nUUS'   U R+                  U R                  Xt5      5      I Sh  vN nO(U R-                  U R                  Xt5      5      I Sh  vN nU R/                  US#5      nU	(       aC  SnU(       a  U R1                  US#/ 5      nOU R1                  US$/ 5      nU R3                  UXRU5      $ US:X  a1  Uc  U(       a&  U R1                  US%/ 5      nU R3                  UXRU5      $ O&U R1                  US&/ 5      nU R3                  UXRU5      $ U R3                  UXRU5      $  GN GN GN GNu GN% GN GN GN GNZ GN N7f)'a  
fetch all unfilled currently open orders

https://www.bitget.com/api-doc/spot/trade/Get-Unfilled-Orders
https://www.bitget.com/api-doc/spot/plan/Get-Current-Plan-Order
https://www.bitget.com/api-doc/contract/trade/Get-Orders-Pending
https://www.bitget.com/api-doc/contract/plan/get-orders-plan-pending
https://www.bitget.com/api-doc/margin/cross/trade/Get-Cross-Open-Orders
https://www.bitget.com/api-doc/margin/isolated/trade/Isolated-Open-Orders
https://www.bitget.com/api-doc/uta/strategy/Get-Unfilled-Strategy-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 order structures to retrieve
:param dict [params]: extra parameters specific to the exchange API endpoint
:param int [params.until]: the latest time in ms to fetch orders for
:param str [params.planType]: *contract stop only* 'normal_plan': average trigger order, 'profit_loss': opened tp/sl orders, 'track_plan': trailing stop order, default is 'normal_plan'
:param boolean [params.trigger]: set to True for fetching trigger orders
: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.isPlan]: *swap only* 'plan' for stop orders and 'profit_loss' for tp/sl orders, default is 'plan'
:param boolean [params.trailing]: set to True if you want to fetch trailing orders
:param boolean [params.uta]: set to True for the unified trading account(uta), defaults to False
:returns Order[]: a list of `order structures <https://docs.ccxt.com/#/?id=order-structure>`
Nr   r   FrE   r  r  rR   r  r  cursorminIdr  endIdr  r  r  r  r  r  r  rT   rU   r  r  )r  r  r  r  r  r  r  r  r  r  r  r  r  rC  r  entrustedList)r  r  r  r  r  r  rG  r  rB  r  r  r  r  *privateUtaGetV3TradeUnfilledStrategyOrdersr=  "privateUtaGetV3TradeUnfilledOrdersr  *privateMarginGetV2MarginIsolatedOpenOrders)privateMarginGetV2MarginCrossedOpenOrders)privateSpotGetV2SpotTradeCurrentPlanOrder'privateSpotGetV2SpotTradeUnfilledOrders(privateMixGetV2MixOrderOrdersPlanPending$privateMixGetV2MixOrderOrdersPendingr  r8  r  )r  r  r  r  r  r  r  r  r  r   r  rT  r  cursorReceived
cursorSentr  r  r  planTypeDefined	isTriggerr  r  r  r  r_  r  s                             r  fetch_open_ordersbitget.fetch_open_orders  s/    2 !!!
!??@QSYZ
33F<MuV[\[[(F &tGH,,T\\;Lm]cdK,2f,<;J##FFJ?D,,T\\;Lm]cdK##FFK@D88ART^_!NJ!)%
)%,N!-J!()
99:KV\aky  G  G  G>>&*5""669=**6:>dJ/	229gN#(K $GTX-=:CY ..v{OTMYYv7F('4$"AA&QV6#JKv~)"*K"-GJ!%!P!PQUQ\Q\]dQm!nn!%!H!HU\Ie!ffV^%= --/*<E+0K(+%)%T%TUYU`U`ahUq%rrH7*%)%S%STXT_T_`gTp%qqH%)%S%STXT_T_`gTp%qqH%)%Q%QRVR]R]^eRn%ooH%0GM"++FJM&.
#!%!N!Nt{{[bOk!ll++FJN&.
#!%!N!Nt{{[bOk!ll!%!J!J4;;W^Kg!hhz x0F&"=fb9$$VVEBBV^&7!^^D+rB
((VEJJ ,3 ^^D/2>F$$VVEBB  ve<<C 	"@ G2 of  sq  ro m mhs   TS#DT2S&3DTS))T7S,8AT
S//T:S2;0T+S5,(TS8AT!S;"AT)S>*(TTCT&T)T,T/T2T5T8T;T>TTc                    #    U R                  5       I Sh  vN   U R                  XX45      I Sh  vN nU R                  USS5      $  N1 N7f)ap  
fetches information on multiple closed orders made by the user

https://www.bitget.com/api-doc/spot/trade/Get-History-Orders
https://www.bitget.com/api-doc/spot/plan/Get-History-Plan-Order
https://www.bitget.com/api-doc/contract/trade/Get-Orders-History
https://www.bitget.com/api-doc/contract/plan/orders-plan-history
https://www.bitget.com/api-doc/margin/cross/trade/Get-Cross-Order-History
https://www.bitget.com/api-doc/margin/isolated/trade/Get-Isolated-Order-History
https://www.bitget.com/api-doc/uta/trade/Get-Order-History

:param str symbol: unified market symbol of the closed orders
:param int [since]: timestamp in ms of the earliest order
:param int [limit]: the max number of closed orders to return
:param dict [params]: extra parameters specific to the exchange API endpoint
:param int [params.until]: the latest time in ms to fetch orders for
:param str [params.planType]: *contract stop only* 'normal_plan': average trigger order, 'profit_loss': opened tp/sl orders, 'track_plan': trailing stop order, default is 'normal_plan'
:param boolean [params.trigger]: set to True for fetching trigger orders
: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.isPlan]: *swap only* 'plan' for stop orders and 'profit_loss' for tp/sl orders, default is 'plan'
:param boolean [params.trailing]: set to True if you want to fetch trailing orders
:returns Order[]: a list of `order structures <https://docs.ccxt.com/#/?id=order-structure>`
Nr  r  r   fetch_canceled_and_closed_orders	filter_byr  r  r  r  r  r  s         r  fetch_closed_ordersbitget.fetch_closed_ordersd  sI     0 !!!<<VEZZ~~fh99 	"Z   AAAA
A
Ac                    #    U R                  5       I Sh  vN   U R                  XX45      I Sh  vN nU R                  USS5      $  N1 N7f)as  
fetches information on multiple canceled orders made by the user

https://www.bitget.com/api-doc/spot/trade/Get-History-Orders
https://www.bitget.com/api-doc/spot/plan/Get-History-Plan-Order
https://www.bitget.com/api-doc/contract/trade/Get-Orders-History
https://www.bitget.com/api-doc/contract/plan/orders-plan-history
https://www.bitget.com/api-doc/margin/cross/trade/Get-Cross-Order-History
https://www.bitget.com/api-doc/margin/isolated/trade/Get-Isolated-Order-History
https://www.bitget.com/api-doc/uta/trade/Get-Order-History

:param str symbol: unified market symbol of the canceled orders
:param int [since]: timestamp in ms of the earliest order
:param int [limit]: the max number of canceled orders to return
:param dict [params]: extra parameters specific to the exchange API endpoint
:param int [params.until]: the latest time in ms to fetch orders for
:param str [params.planType]: *contract stop only* 'normal_plan': average trigger order, 'profit_loss': opened tp/sl orders, 'track_plan': trailing stop order, default is 'normal_plan'
:param boolean [params.trigger]: set to True for fetching trigger orders
: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.isPlan]: *swap only* 'plan' for stop orders and 'profit_loss' for tp/sl orders, default is 'plan'
:param boolean [params.trailing]: set to True if you want to fetch trailing orders
:returns dict: a list of `order structures <https://docs.ccxt.com/#/?id=order-structure>`
Nr  r  r&  r)  s         r  fetch_canceled_ordersbitget.fetch_canceled_orders  sI     0 !!!<<VEZZ~~fh
;; 	"Zr,  c           	      	  #    SnU R                  USSS5      u  pTU(       a  U R                  XX45      I Sh  vN $ U R                  5       I Sh  vN   Sn0 nUb  U R                  U5      nUS   US'   SnU R	                  SXd5      u  pSn	U R                  SU5      u  pSn
U R                  USS5      u  pU
(       a-  SnUS:X  a  U	b  S	nOS
nU R                  SXX4US5      I Sh  vN $ SnU R                  US5      nU R                  USS5      nU R                  U/ SQ5      nU R                  SXt5      u  ptUb  X'S'   Ub  X7S'   US:X  d	  US:X  d  U	b,  U R                  USS5      nU R                  US5      nUb  XS'   U R                  5       nUS:X  Ga  U	bl  Uc	  US-
  nX'S'   U	S:X  a*  U R                  U R                  Xt5      5      I Sh  vN nGOU	S:X  a(  U R                  U R                  Xt5      5      I Sh  vN nGOU(       a  Uc  [!        U R"                  S-   5      eU R%                  USS/5      nU R                  US/5      nUc	  US-
  nX'S'   Uc  UUS'   U R'                  U R                  Xt5      5      I Sh  vN nGOU R)                  U R                  Xt5      5      I Sh  vN nOSnU R+                  Xd5      u  nnUUS'   U R-                  US5      SLnU(       aA  U R-                  USS5      nUUS'   U R/                  U R                  Xt5      5      I Sh  vN nOwU(       d  U(       aA  U R-                  USS5      nUUS'   U R/                  U R                  Xt5      5      I Sh  vN nO(U R1                  U R                  Xt5      5      I Sh  vN nU R3                  US 0 5      nUS:X  a/  U	c  U(       a$  U R5                  U R3                  US!/ 5      XbU5      $ O$U R5                  U R3                  US"/ 5      XbU5      $ [7        U[8        5      (       a  [:        R<                  " U5      nU R?                  US / 5      nU R5                  UXbU5      $  GN- GN GN GN GNn GN GN GNO GN N7f)#aB  

https://www.bitget.com/api-doc/spot/trade/Get-History-Orders
https://www.bitget.com/api-doc/spot/plan/Get-History-Plan-Order
https://www.bitget.com/api-doc/contract/trade/Get-Orders-History
https://www.bitget.com/api-doc/contract/plan/orders-plan-history
https://www.bitget.com/api-doc/margin/cross/trade/Get-Cross-Order-History
https://www.bitget.com/api-doc/margin/isolated/trade/Get-Isolated-Order-History
https://www.bitget.com/api-doc/uta/trade/Get-Order-History
https://www.bitget.com/api-doc/uta/strategy/Get-History-Strategy-Orders

fetches information on multiple canceled and closed orders made by the user
:param str symbol: unified market symbol of the market orders were made in
:param int [since]: the earliest time in ms to fetch orders for
:param int [limit]: the maximum number of order structures to retrieve
:param dict [params]: extra parameters specific to the exchange API endpoint
:param int [params.until]: the latest time in ms to fetch orders for
:param str [params.planType]: *contract stop only* 'normal_plan': average trigger order, 'profit_loss': opened tp/sl orders, 'track_plan': trailing stop order, default is 'normal_plan'
:param boolean [params.trigger]: set to True for fetching trigger orders
: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.isPlan]: *swap only* 'plan' for stop orders and 'profit_loss' for tp/sl orders, default is 'plan'
:param boolean [params.trailing]: set to True if you want to fetch trailing orders
:param boolean [params.uta]: set to True for the unified trading account(uta), defaults to False
:returns Order[]: a list of `order structures <https://docs.ccxt.com/#/?id=order-structure>`
Nrw   r   FrE   r  r  rR   r  r  r  r  r  r  r  r  r  r  rT   rU   r  r  r  r  r  z: fetchCanceledAndClosedOrders() requires a symbol argumentr  r  r  r  r  r  r  r  ) r  $fetch_uta_canceled_and_closed_ordersr  r  rc  r  r  rB  r  r  r  r  r  -privateMarginGetV2MarginIsolatedHistoryOrdersr=  ,privateMarginGetV2MarginCrossedHistoryOrdersr/   rE   r|  )privateSpotGetV2SpotTradeHistoryPlanOrder&privateSpotGetV2SpotTradeHistoryOrdersr  rG  (privateMixGetV2MixOrderOrdersPlanHistory$privateMixGetV2MixOrderOrdersHistoryr  r  r  rO  r6  r7  r8  )r  r  r  r  r  r   r  r  rT  r  r  r  r  r  r  r  r  r  r  r!  r  r  r  s                          r  r'  'bitget.fetch_canceled_and_closed_orders  s    4 33F<Z\achiBB6RW```!!![[(F &tGH
!??@^`fo

!??@^`fg
88A_akl!NV#)%,N!(99:XZ`in  yG  IU  V  V  V>>&*5""669=6#BC229gN#(K $G& jH&<*BX ..v{OTMYYv7F('4$!%=*,E+0K(+%)%W%WX\XcXcdkXt%uuH7*%)%V%VW[WbWbcjWs%ttH>+DGG6r,rss--fy'6JK6G95=*,E+0K(?),GI&!%!O!OPTP[P[\cPl!mm!%!L!LT[[Y`Mi!jjK"&"E"Ef"UK%0GM""..vzB$NO++FJM&.
#!%!N!Nt{{[bOk!llO++FJN&.
#!%!N!Nt{{[bOk!ll!%!J!J4;;W^Kg!hhf x4&7(({B)OQW`eff ,3 $$T__T?B%OQW`effh$$zz(+H&"5  >>I a!& V,  vt nj m mhs   5RQ$RQ'BR&Q*'C+RQ-/RQ0BR	Q3
)R3Q64A6R*Q9+AR9Q<:(R"Q?#CR'R*R-R0R3R6R9R<R?Rc           	        #    U R                  5       I S h  vN   S nUb  U R                  U5      nS nU R                  XT5      u  pdUS:X  a  S nU R                  SU5      u  ptUb  SnSU0nSn	U R	                  USS5      u  pU	(       a  U R                  SXX4SS5      I S h  vN $ U R                  SX5      u  pUb  X(S	'   Ub  X8S
'   S n
U R                  USS5      nU R                  USS/5      nU(       a)  U R                  U R                  X5      5      I S h  vN n
O(U R                  U R                  X5      5      I S h  vN n
U R                  U
S0 5      nU R                  US/ 5      nU R                  XX#5      $  GNk N Nj NC7f)Nr  rw   r  r  Fr  r  r  r  r  r  r  r  rC  )r  r  r  r  r  r  r  r  r  )privateUtaGetV3TradeHistoryStrategyOrdersr=  !privateUtaGetV3TradeHistoryOrdersr7  r8  r  )r  r  r  r  r  r  r  r  r  r  r  r  r  r  s                 r  r1  +bitget.fetch_uta_canceled_and_closed_orders  s    !!![[(F"AA&Q& J!%!C!CDbdj!kJ%&
 88A_akl99:XZ`in  yA  CK  L  L  L229gN#(K $G""669=6FI#67!KKDKKX_LhiiH!CCDKKPWD`aaHh ~~h3fb1  >>g 	"" L jasG   F
FB
F
!F"A9F
F(F
F=F
F
F
F
c           	        #    U R                  5       I Sh  vN   U R                  US5      nU R                  US5      nSnUb  U R                  U5      nSnU R	                  SXd5      u  ptSnU R                  USS5      u  pU(       a'  Sn	US:w  a  Sn	U R                  SXRX4U	S5      I Sh  vN $ Sn
0 nUb  U R                  U5      n
U
S	   US
'   U R                  SX5      u  pUb  X+S'   Ub  X;S'   SnUS:X  a)  U R                  U R                  X5      5      I Sh  vN nOLUb  US	   US'   SnU R                  Xd5      u  pXS'   U R                  U R                  X5      5      I Sh  vN nU R                  US5      nUS:X  d  US:X  a%  U R                  US/ 5      nU R                  XX#5      $ U R                  XX#5      $  GN GN N Na7f)aF  
fetch the history of changes, actions done by the user or operations that altered the balance of the user

https://www.bitget.com/api-doc/spot/account/Get-Account-Bills
https://www.bitget.com/api-doc/contract/account/Get-Account-Bill

:param str [code]: unified currency code, default is None
:param int [since]: timestamp in ms of the earliest ledger entry, default is None
:param int [limit]: max number of ledger entries to return, default is None
:param dict [params]: extra parameters specific to the exchange API endpoint
:param int [params.until]: end time in ms
:param str [params.symbol]: *contract only* unified market symbol
:param str [params.productType]: *contract only* 'USDT-FUTURES', 'USDC-FUTURES', 'COIN-FUTURES', 'SUSDT-FUTURES', 'SUSDC-FUTURES' or 'SCOIN-FUTURES'
: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 `ledger structure <https://docs.ccxt.com/#/?id=ledger>`
Nr  r   Fr  rR   r  r  rE   r  r  r  r  r  r  rT   rU   bills)r  rG  r  r  rc  r  r  r  r   privateSpotGetV2SpotAccountBillsr=  r  privateMixGetV2MixAccountBillr  parse_ledger)r  r  r  r  r  r  r  rT  r  r  r  r  r  r  r  r>  s                   r  fetch_ledgerbitget.fetch_ledger5  s    " !!!!!&(368,[[(F
!??v^
88PZ[!NV#!(99-X]gu  xD  E  E  E}}T*H&tnGFO229gN#(K $G!BB4;;wC_``H!$*4L!K"&"E"Ef"UK%0M"!??G@\]]HZ x0& jH&<OOD'26E$$UeCC  >>g 	" E a ^sI   GGBG+G,A1GG
AG*G+AGG
GGr  c                 @   U R                  US5      nU R                  X25      nU R                  X25      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                  [        R                  " U5      5      n	Sn
UR                  S	5      S
:  a  Sn
U R                  UU R                  US5      UU R                  U5      U
S S S U R                  U R                  US5      5      UU	S US UUS.S.U5      $ )Nr  r  r  r   r  r  r!  inr  r   outbillIdr  r  )r6  rE   r  r  	directionr  referenceIdreferenceAccountr  r  r!  beforeafterr  r  )rG  rH  safe_currencyr  rP  rR  r  r  r?   r  findsafe_ledger_entryrK  parse_ledger_type)r  r  r  r  r  r  rL  r  	amountRawr!  rH  s              r  parse_ledger_entrybitget.parse_ledger_entry  s8   8 %%dF3
&&z<%%j;%%dG4	  y1  vu5&&tVX>	""7#5#5i#@A	>>#!#I%%""42"Y/" $**4+;+;D.+QR '
& ' 	r  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_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SSS*S+SSS,.EnU R                  X!U5      $ )-Ntrans_to_crossr   trans_from_crosstrans_to_exchangetrans_from_exchangetrans_to_isolatedtrans_from_isolatedtrans_to_contracttrans_from_contracttrans_to_otctrans_from_otc	open_longrj  
close_long
open_shortclose_shortforce_close_longforce_close_shortburst_long_loss_queryburst_short_loss_query	force_buy
force_sell	burst_buy
burst_selldelivery_long
settlementdelivery_shortcontract_settle_feer  append_marginr  adjust_down_lever_append_marginreduce_marginauto_append_margincash_gift_issuecashbackcash_gift_recyclebonus_issuerebatebonus_recyclebonus_expiredr  r  )transfer_intransfer_outr  r   r&  r'  r  )r  r  r  s      r  rP  bitget.parse_ledger_type  s   )
j)

)
  )
 ":	)

  )
 ":)
  )
 ":)
 J)
 j)
 )
 ')
 ')
 7)
 )
   !)
" $W#)
$ %g%)
& ')
( '))
* +)
, '-)
. \/)
0 l1)
2 "53)
4 ]5)
6 .}7)
8 ]9)
: !-;)
< z=)
>  ?)
@ 8A)
B XC)
D XE)
F && $Q)
T T22r  c           	        #    SnU R                  USSS5      u  pTU(       d  Uc  [        U R                  S-   5      eU R                  5       I Sh  vN   U R	                  U5      n0 nU R                  SXt5      u  ptUb  X'S'   Ub  X7S'   SnSn	U R                  USS	5      u  pU R                  SU5      u  pU(       aB  Sn
SnU(       a  S
n
S
nOUS   (       a  U	b  Sn
SnOSn
SnU R                  SXX4X5      I Sh  vN $ SnU(       a)  U R                  U R                  Xt5      5      I Sh  vN nOUS   US'   US   (       a  U	bw  Uc  U R                  5       S-
  US'   U	S:X  a)  U R                  U R                  Xt5      5      I Sh  vN nOU	S:X  a(  U R                  U R                  Xt5      5      I Sh  vN nOjU R                  U R                  Xt5      5      I Sh  vN nOASnU R                  Xd5      u  pXS'   U R                  U R                  Xt5      5      I Sh  vN nU R!                  US5      nU(       a%  U R#                  US/ 5      nU R%                  XX#5      $ US   (       d
  US   (       a%  U R#                  US/ 5      nU R%                  XX#5      $ U	b%  U R#                  US/ 5      nU R%                  XX#5      $ U R%                  XX#5      $  GN GN GN GNY GN- GN N7f)aZ  
fetch all trades made by the user

https://www.bitget.com/api-doc/spot/trade/Get-Fills
https://www.bitget.com/api-doc/contract/trade/Get-Order-Fills
https://www.bitget.com/api-doc/margin/cross/trade/Get-Cross-Order-Fills
https://www.bitget.com/api-doc/margin/isolated/trade/Get-Isolated-Transaction-Details
https://www.bitget.com/api-doc/uta/trade/Get-Order-Fills

:param str symbol: unified market symbol
:param int [since]: the earliest time in ms to fetch trades for
:param int [limit]: the maximum number of trades structures to retrieve
:param dict [params]: extra parameters specific to the exchange API endpoint
:param int [params.until]: the latest time in ms to fetch trades for
:param boolean [params.uta]: set to True for the unified trading account(uta), defaults to False
: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 Trade[]: a list of `trade structures <https://docs.ccxt.com/#/?id=trade-structure>`
Nr   r   Fz+ fetchMyTrades() requires a symbol argumentr  r  r  r  r  rR   r  r  r  rE   r  r  r  r  r  r  rC  rT   rU   fillListfills)r  r/   rE   r  r  r  r  r  privateUtaGetV3TradeFillsr=  r  %privateMarginGetV2MarginIsolatedFills$privateMarginGetV2MarginCrossedFillsprivateSpotGetV2SpotTradeFillsr  privateMixGetV2MixOrderFillsr  r8  r  )r  r  r  r  r  r   r  r  r  r  r  r   r  r  r  r  s                   r  fetch_my_tradesbitget.fetch_my_trades  s    & 33FOUTYZ#DGG.[$[\\!!!V$229gN#(K $G
88R\]!??QWX
!NJ!)%
)%,N!-J!()
99/6Z_iw  E  E  E!;;DKK<XYYH &tGHf~)}/3/@/@/BZ/O,!Z/)-)S)STXT_T_`gTp)q#q#w.)-)R)RSWS^S^_fSo)p#p%)%H%HU\Ie%ffH"&*&I&I&&Y#)4&!%!B!B4;;wC_!``H x0NN44E$$UEAAVn!1NN4R8E$$UEAA#NN4"5E$$UEAA  u<<w 	"2 E Z $r#pf
 as   AK-KB*K-;K<0K-,K-AK-	K"
.K-8K%9(K-!K("AK-#K+$B6K-K-K-"K-%K-(K-+K-c                 d  #    U R                  5       I Sh  vN   U R                  U5      nSnU R                  X25      u  pBSUS   0nSnSnSnU R                  USSS5      u  prU(       aS  XES'   U R	                  U R                  XR5      5      I Sh  vN nU R                  US0 5      n	U R                  U	S	/ 5      nOGUS
   US'   XES'   U R                  U R                  XR5      5      I Sh  vN nU R                  US/ 5      nU R                  US0 5      n
U R                  X5      $  GN N N@7f)a  
fetch data on a single open contract trade position

https://www.bitget.com/api-doc/contract/position/get-single-position
https://www.bitget.com/api-doc/uta/trade/Get-Position

:param str symbol: unified market symbol of the market the position is held in
:param dict [params]: extra parameters specific to the exchange API endpoint
:param boolean [params.uta]: set to True for the unified trading account(uta), defaults to False
:returns dict: a `position structure <https://docs.ccxt.com/#/?id=position-structure>`
Nr  rE   r   r   Fr  r  rC  r  r  r  r   )
r  r  r  r  &privateUtaGetV3PositionCurrentPositionr=  r7  r8  (privateMixGetV2MixPositionSinglePositionparse_position)r  r  r  r  r  r  r  r   r_  r  r  s              r  fetch_positionbitget.fetch_position  sF     !!!V$"AA&QfTl
 33FOUTYZ"-J!HHU\IeffHN >>(FB7D^^D&"5F$*:$6GL!%0M"!JJ4;;W^KghhH> ^^Hfb9Fvq"-""511u 	" gX is5   D0D)A;D0D,AD0-D..<D0,D0.D0c           	      l  #    U R                  5       I Sh  vN   SnU R                  USS5      u  p2U(       a  U R                  SSSSUSS5      I Sh  vN $ SnU R                  USS5      nU(       a  SnOU R                  USS	S
5      u  pBSnUb&  U R	                  US5      nUb  U R                  U5      nSnU R                  Xb5      u  p0 n	Sn
SnSnU R                  USSS5      u  pU(       a-  XS'   U R                  U R                  X5      5      I Sh  vN n
OUS
:X  a  U R	                  USS5      nUb  US   nOKUS:X  a  SnOBUS:X  a  SnO9US:X  a  SnO0US:X  a  SnO'US:X  d  US:X  a  Uc  [        U R                  S-   5      eXS'   XS'   U R                  U R                  X5      5      I Sh  vN n
O9SnUb  US   U	S'   XS'   U R                  U R                  X5      5      I Sh  vN n
/ nU(       d  U(       a'  U R                  U
S0 5      nU R                  US / 5      nOU R                  U
S/ 5      n/ n[        S[!        U5      5       H'  nUR#                  U R%                  UU   U5      5        M)     U R'                  U5      nU R)                  USUS5      $  GN GNW GN N N7f)!a  
fetch all open positions

https://www.bitget.com/api-doc/contract/position/get-all-position
https://www.bitget.com/api-doc/contract/position/Get-History-Position
https://www.bitget.com/api-doc/uta/trade/Get-Position

:param str[] [symbols]: list of unified market symbols
:param dict [params]: extra parameters specific to the exchange API endpoint
:param str [params.marginCoin]: the settle currency of the positions, needs to match the productType
:param str [params.productType]: 'USDT-FUTURES', 'USDC-FUTURES', 'COIN-FUTURES', 'SUSDT-FUTURES', 'SUSDC-FUTURES' or 'SCOIN-FUTURES'
: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.useHistoryEndpoint]: default False, when True  will use the historic endpoint to fetch positions
:param str [params.method]: either(default) 'privateMixGetV2MixPositionAllPosition', 'privateMixGetV2MixPositionHistoryPosition', or 'privateUtaGetV3PositionCurrentPosition'
:param boolean [params.uta]: set to True for the unified trading account(uta), defaults to False
:returns dict[]: a list of `position structure <https://docs.ccxt.com/#/?id=position-structure>`
NFr   r  r  r  r  )privateMixGetV2MixPositionHistoryPositionr  r  r   r   r  r  r  r  r  r  r  r  r  r  r  r  r  zN fetchPositions() requires a marginCoin parameter that matches the productTyper  TrE   r  r  rC  )r  r  r  rB  rG  r  r  r  r=  r/   rE   r  r  r7  r8  r9  r:  r;  r  market_symbolsfilter_by_array_positions)r  ra  r  r  r  r  r  r  r  r  r  	isHistoryr   r  positionr  r_  rW  s                     r  fetch_positionsbitget.fetch_positions@  s    $ !!!88AQS]^99:JDRVX\^dfmo{|||!^^F4H%P@F!::6CSU]  `G  HNF$$Wa0E U+"AA&Q	33F<LeUZ["-J!HHU\IeffH>>))&,GJ!#J/
.#
.#
/$
/$
0k^6S%+DGG  7G  -G  H  H$.L!%0M"!GGT[HdeeHI!$*4L!%0M"!KKDKKX_LhiiHL )>>(FB7D~~dFB7H~~h;Hq#h-(AMM$--hqk6BC )%%g.--fhOOE 	" }, g$ f jsZ   J4J'<J4J*CJ4J-BJ47J089J41J22B6J4*J4-J40J42J4r  c                 	   U R                  US5      nU R                  X2S S5      nUS   nU R                  U/ SQ5      nU R                  US5      nS nS nU R                  USS5      n	U R                  USS5      n
US	:X  a  [        R
                  " X5      nO
US
:X  a  SnU
nU R                  USS5      nS nUS:X  a  SnOUS:X  a  SnU R                  USS5      nU R                  US5      nU R                  US5      nU R                  U5      nU R                  USS5      nU R                  U/ SQ5      nU R                  US5      n[        R                  " UU5      nUc  [        R                  " UU5      nU R                  [        R                  " UU5      5      nUc  U R                  US5      nU R                  US5      n[        R                  " UU5      n[        R                  " UU5      nU R                  U R                  U R                  US5      5      5      nSnSnUc  US	:X  a  [        R                  " US5      (       a  [        R                  " U
U5      nUnUS :X  a,  [        R                  " U5      n[        R                  " U5      n[        R                   " S!U5      n[        R                   " UU5      nUS":X  a  [        R                  " UU5      nO[        R                  " UU5      nU R                  [        R                  " UU5      5      n[        R                  " UU5      n [        R
                  " [        R                  " UU5      U 5      n![        R                  " [        R                  " XS#5      S$5      n"U R#                  0 S%U_S&U R                  US'S(5      _SU_S)U R                  U5      _SU_SU_S*U R                  U5      _S+U R                  U	5      _S,U R%                  U/ S-Q5      _S.U R                  U"5      _S/U_SU_SU R                  U5      _S0U R'                  US1S25      _S3U_S4U_S5U_U R)                  U5      U R+                  US6S75      U R                  U!5      U R                  U5      U R                  U5      U R                  U5      U R                  U5      U R                  U5      U R'                  US8S95      S S S:.E5      $ );Nr  r  r  r  unrealizedPLunrealisedPnl
marginSizepositionBalancer  r  r  rn  holdModer%  Tone_way_modeFr  r  r*  r.  r  openTotalPos)openPriceAvgopenAvgPriceavgPricer  closeTotalPosr-  liquidationPricer   z0.9994r{  rn  r   rm  r   r/  r6  rE   r  
positionIdnotional
entryPriceunrealizedPnlrealizedPnl)pnlcurRealisedPnlcumRealisedPnlrI  	contractsr+  closeAvgPriceclosePriceAvgrs  r  r  utimer  marginRatior  )r  r)  maintenanceMarginmaintenanceMarginPercentage
collateralinitialMargininitialMarginPercentager*  r  r  r  )rG  r5  r|  r  r?   r  r  r  rS  rQ  
string_divr  rP  	omit_zero	string_gtr}  r  safe_positionr  rR  rK  r  )#r  r  r  r`  r  r  r  r  r  r  rawCollateralr  r  rs  r*  contractSizeNumberr.  
baseAmountr  r  openNotionalr  r-  r  r  r  calcTakerFeeRatecalcTakerFeeMultsignedMargin	signedMmpmmrMinusOne	numerator
feeToCloser  rI  s#                                      r  r  bitget.parse_position  s5   D ##Hh7!!(D*E!''2ST	%%h=

**8^_U**8\CTU# ++MIJ9$ J)M%%h	:F|#F'F!!(J	B##Hj9!__V^D,,-?@'''>J
''2^_
&*&6&6xAQ&R#))*jA #..|XFM%%g&8&8\&RS	((?CI$$X{;	%%j)<")"4"4]H"M,,T^^D<L<LXWi<j-kl##$:+CIZIZ[egjIkIk"--mZHL3Iw&11,?#..y9	!,,S)<K**:|DIv~%00>NO#..y:JK	#001C1CI{1[\''2BC
#..w/A/AB]_g/hjtu''(:(:=YZ([]bc
!! #
H#
$$$Xy,G#
 f#
 ))(3	#

 *#
  0#
 $++J7#
 T..}=#
 4--h8cd#
 $++J7#
 #
 .#
 **95#
 ++HoW#
 D#
  f!#
" ##
$ Y/#'#6#6x-#X!%!2!23D!E+/+<+<=X+Y++J7!..}='+'8'89P'Q))(3--huM!#9#
  	r  c           
      J  #    Uc  [        U R                  S-   5      eU R                  5       I Sh  vN   U R                  U5      nSUS   0nSnSnSn	Sn
U R	                  XT5      u  ptU R                  USSS5      u  pU(       aZ  Ub  X6S'   XvS	'   U R                  U R                  Xd5      5      I Sh  vN n	U R                  U	S
0 5      nU R                  US/ 5      n
OSnU R                  USS5      u  pU(       a  U R                  SXX4SS5      I Sh  vN $ Ub  X6S'   XvS'   U R                  U R                  Xd5      5      I Sh  vN n	U R                  U	S
/ 5      n
/ n[        S[        U
5      5       Ht  nX   nU R                  US5      nU R                  UU5      nU R!                  USS5      nUR#                  UUU R%                  US5      UU R'                  U5      S.5        Mv     U R)                  US5      nU R+                  UUS   X#5      $  GN GNg GN N7f)a  
fetches historical funding rate prices

https://www.bitget.com/api-doc/contract/market/Get-History-Funding-Rate
https://www.bitget.com/api-doc/uta/public/Get-History-Funding-Rate

: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 to fetch
:param dict [params]: extra parameters specific to the exchange API endpoint
:param boolean [params.uta]: set to True for the unified trading account(uta), defaults to False
:param boolean [params.paginate]: default False, when True will automatically paginate by calling self endpoint multiple times. See in the docs all the [availble parameters](https://github.com/ccxt/ccxt/wiki/Manual#pagination-params)
:returns dict[]: a list of `funding rate structures <https://docs.ccxt.com/#/?id=funding-rate-history-structure>`
Nz5 fetchFundingRateHistory() requires a symbol argumentr  rE   r   r   Fr  r  r  r  r  pageNor  pageSizer  r   fundingTimefundingRateTimestampfundingRate)r6  r  r  r  r  r  )r/   rE   r  r  r  r  #publicUtaGetV3MarketHistoryFundRater=  r7  r8   fetch_paginated_call_incremental&publicMixGetV2MixMarketHistoryFundRater9  r:  rG  r  r  r;  rP  rK  sort_byfilter_by_symbol_since_limit)r  r  r  r  r  r  r  r  r   r  r_  r  r  ratesrW  r  r`  symbolInnerr  sorteds                       r  fetch_funding_rate_history!bitget.fetch_funding_rate_history  s_     >#DGG.e$eff!!!V$fTl
 "AA&Q33F<UW\^cd #( "-J!EEdkkRYFbccH" >>(FB7D^^D,;FH#<<VE^`jkH!BBC\^dmr  }E  GJ  K  K  K &+
#%0M"!HHU\IeffH ^^Hfb9Fq#f+&AIE''x8H**8V<K++E=BXYILL%#//}E& LL3  ' e[1009I5XXQ 	" d. K gsH   /H#HBH#4H5A!H#H2H#	H!
CH#H#H#!H#c                   #    U R                  5       I Sh  vN   U R                  U5      nUS   (       d  [        U R                  S-   5      eSnU R	                  X25      u  pBSUS   0nSnSnU R                  USSS5      u  pbU(       a)  U R                  U R                  XR5      5      I Sh  vN nOyXES	'   SnU R                  USS
S5      u  pUS:X  a)  U R                  U R                  XR5      5      I Sh  vN nO.US:X  a(  U R                  U R                  XR5      5      I Sh  vN nU R                  US/ 5      n	U R                  U	S   U5      $  GN? N N` N37f)a  
fetch the current funding rate

https://www.bitget.com/api-doc/contract/market/Get-Current-Funding-Rate
https://www.bitget.com/api-doc/contract/market/Get-Symbol-Next-Funding-Time
https://www.bitget.com/api-doc/uta/public/Get-Current-Funding-Rate

:param str symbol: unified market symbol
:param dict [params]: extra parameters specific to the exchange API endpoint
:param boolean [params.uta]: set to True for the unified trading account(uta), defaults to False
:param str [params.method]: either(default) 'publicMixGetV2MixMarketCurrentFundRate' or 'publicMixGetV2MixMarketFundingTime'
:returns dict: a `funding rate structure <https://docs.ccxt.com/#/?id=funding-rate-structure>`
NrT   z0 fetchFundingRate() supports swap contracts onlyr  rE   r   r   Fr  r  r  "publicMixGetV2MixMarketFundingTimer  r   )r  r  r1   rE   r  r  #publicUtaGetV3MarketCurrentFundRater=  r  r  r8  parse_funding_rate)
r  r  r  r  r  r  r   r  r  r  s
             r  fetch_funding_ratebitget.fetch_funding_rate)  st     !!!V$f~DGG&XXYY"AA&QfTl
 33F<NPUW\]!EEdkkRYFbccH& &1M"F!::6CUW_  bJ  KNFAA!%!L!LT[[Y`Mi!jj$ ??!%!H!HU\Ie!ff ~~h3&&tAw77O 	" d. k& gsG   EEBE.E/A
E9E:.E(E)-EEEEc                 $  #    U R                  5       I Sh  vN   SnUb#  U R                  US5      nU R                  U5      n0 nSnU R                  X25      u  pbSnU R	                  USSU5      u  prSnXeS'   US:X  a)  U R                  U R                  XR5      5      I Sh  vN nO.US:X  a(  U R                  U R                  XR5      5      I Sh  vN nU R                  U5      nU R                  US/ 5      n	U R                  X5      $  N Nj N=7f)	a  
fetch the current funding rates for all markets

https://www.bitget.com/api-doc/contract/market/Get-All-Symbol-Ticker

:param str[] [symbols]: list of unified market symbols
:param dict [params]: extra parameters specific to the exchange API endpoint
:param str [params.subType]: *contract only* 'linear', 'inverse'
:param str [params.productType]: *contract only* 'USDT-FUTURES', 'USDC-FUTURES', 'COIN-FUTURES', 'SUSDT-FUTURES', 'SUSDC-FUTURES' or 'SCOIN-FUTURES'
:param str [params.method]: either(default) 'publicMixGetV2MixMarketTickers' or 'publicMixGetV2MixMarketCurrentFundRate'
:returns dict: a dictionary of `funding rate structures <https://docs.ccxt.com/#/?id=funding-rates-structure>`, indexed by market symbols
Nr   rd  r   r  r  r  r  )r  r  r  r  r  rd  r=  r  r  r8  parse_funding_rates)
r  ra  r  r  r  r  r  r  r  r  s
             r  fetch_funding_ratesbitget.fetch_funding_rates  s"     !!!__Wa0F[[(F"AA&Q166v?RT\^de!,55B "@@WA]^^H??$ "HHU\IeffH%%g.~~h3''66G 	"Z _& gs4   DD
B
D!D".DD:DDDc                    #    U R                  5       I Sh  vN   U R                  SS0U5      nU R                  X5      I Sh  vN $  N1 N7f)a  
fetch the funding rate interval for multiple markets

https://www.bitget.com/api-doc/contract/market/Get-All-Symbol-Ticker

:param str[] [symbols]: list of unified market symbols
:param dict [params]: extra parameters specific to the exchange API endpoint
:param str [params.productType]: 'USDT-FUTURES'(default), 'USDC-FUTURES', 'COIN-FUTURES', 'SUSDT-FUTURES', 'SUSDC-FUTURES' or 'SCOIN-FUTURES'
:returns dict[]: a list of `funding rate structures <https://docs.ccxt.com/#/?id=funding-rate-structure>`
Nr  r  )r  r=  r  )r  ra  r  s      r  fetch_funding_intervalsbitget.fetch_funding_intervals  sL      !!!h(PQSYZ--g>>> 	">s!   AA,AA
A
Ac                    U R                  US5      nU R                  X2S S5      nU R                  USS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	S n
Ub  US
-   n
0 SU_SU_SU_S	U	_SS _SS _SU_SU R                  U5      _SU R                  US5      _SU_SU R                  U5      _SS _SS _SS _SS _SS _SS _SU
0E$ )Nr  rT   nextFundingTime
nextUpdate
ratePeriodfundingRateIntervalr  r-  rO  hr6  interestRateestimatedSettlePricer  r  r  fundingTimestampfundingDatetimenextFundingRatenextFundingTimestampnextFundingDatetimepreviousFundingRatepreviousFundingTimestamppreviousFundingDatetimer  )rG  r  r  r  r  rP  rK  )r  r  r  r`  r  r  r  r  r-  rO  intervalStrings              r  r  bitget.parse_funding_rate  s   r ##Hh7!!(D&A..x9JLY%%h>ST%%h5	$$X{;	%%h=
%^N
H
f
 
 *	

 D
 #D
 
 Y/
 4++HmD
  0
 t||,<=
 t
 #D
 "4
 "4
  '!
" &t#
$ %
 	
r  c           	        #    U R                  5       I Sh  vN   Uc  [        U R                  S-   5      eSnU R                  USS5      u  pTU(       a  U R	                  SXX4SS5      I Sh  vN $ U R                  U5      nUS   (       d  [        U R                  S	-   5      eSnU R                  Xd5      u  ptUS
   US   SUS.nU R                  SX5      u  pUb  X(S'   Ub  X8S'   U R                  U R                  X5      5      I Sh  vN n	U R                  U	S0 5      n
U R                  U
S/ 5      nU R                  XX#5      $  GN2 N NA7f)a  
fetch the funding history

https://www.bitget.com/api-doc/contract/account/Get-Account-Bill

:param str symbol: unified market symbol
:param int [since]: the starting timestamp in milliseconds
:param int [limit]: the number of entries to return
:param dict [params]: extra parameters specific to the exchange API endpoint
:param int [params.until]: the latest time in ms to fetch funding history 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 `funding history structures <https://docs.ccxt.com/#/?id=funding-history-structure>`
Nz1 fetchFundingHistory() requires a symbol argumentFr   r  r  r  rT   z3 fetchFundingHistory() supports swap contracts onlyrE   r  rn  )r  r  r  r  r  r  r  r  r>  )r  r/   rE   r  r  r  r1   r  r  r@  r=  r  parse_funding_histories)r  r  r  r  r  r  r  r  r  r  r  r_  s               r  fetch_funding_historybitget.fetch_funding_history9   sy     !!!>#DGG.a$abb88AVXbc99:OQW`eov  yE  F  F  FV$f~DGG&[[\\"AA&QTl ,1&	
 229gN#(K $G;;DKK<XYY. x4w3++FEIIa 	" F" Zs5   EEAE,E-BEE=EEE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U R                  U5      U R	                  U5      U R                  US5      U R                  US5      S.$ )Nr  r  r  rT   r!  rG  )r6  r  r  r  r  r!  rE   )rG  r  r  rK  rH  rP  )r  r  r  r`  r  r  s         r  parse_funding_historybitget.parse_funding_historyy   s     ##Hh7%%h7
%%h8	&&xvF"Y/++J7&&x:""8X6
 	
r  c                    / n[        S[        U5      5       HA  nX   nU R                  US5      nUS:w  a  M!  UR                  U R	                  Xr5      5        MC     U R                  US5      n	S n
Ub  US   n
U R                  XX45      $ )Nr   r  rn  r  r  )r9  r:  rG  r;  r  r  r  )r  r  r  r  r  r_  rW  r  businessr  r  s              r  r  bitget.parse_funding_histories   s    q#i.)A |H''.AH00MM$44XFG * fk2H%F00NNr  c                   #    U R                  5       I S h  vN   U R                  US5      nU R                  U5      nS nU R                  Xd5      u  ptUS   US   U R	                  X5      UUS.nU R                  US5      nU R                  U R                  X5      5      I S h  vN n	U R                  U R                  X5      U R                  U5      US.5      $  N N97f)Nr  rE   r  )r  r  r!  r  r  )r!  r  )
r  rG  r  r  rp  r  #privateMixPostV2MixAccountSetMarginr=  parse_margin_modificationr  )
r  r  r!  r  r  r  r  r  r  r  s
             r  modify_margin_helperbitget.modify_margin_helper   s     !!!##FJ7V$"AA&QTl ,..v> &
 6:.AA$++gB^__ {{499(K''/N
  	- 	" `s"   C!CBC!%C&8C!C!r  c                 `    U R                  US5      nUS:X  a  SOSnUUS   S SS S US   US S S.
$ )	Nr  00000r  r  r  r  r  )
r6  r  r  r  r!  r  r  r  r  r  r  )r  r  r  	errorCoder  s        r  r   bitget.parse_margin_modification   sV     $$T62	#w.XX&$8$
 	
r  c                    #    US:  a  [        U R                  S-   5      eU R                  US5      nUc  [        U R                  S-   5      eU R	                  XSU5      I Sh  vN $  N7f)ac  
remove margin from a position

https://www.bitget.com/api-doc/contract/account/Change-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   z9 reduceMargin() amount parameter must be a negative valuer  NzC reduceMargin() requires a holdSide parameter, either long or shortrN  )r0   rE   rG  r/   r   r  r  r!  r  r  s        r  rq  bitget.reduce_margin   sk      A:TWW'bbcc##FJ7#DGG.s$stt..vxPPPPs   A"A+$A)%A+c                    #    U R                  US5      nUc  [        U R                  S-   5      eU R                  XSU5      I Sh  vN $  N7f)aJ  
add margin

https://www.bitget.com/api-doc/contract/account/Change-Margin

:param str symbol: unified market symbol
:param float amount: the 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  Nz@ addMargin() requires a holdSide parameter, either long or shortadd)rG  r/   rE   r   r  s        r  
add_marginbitget.add_margin   sO      ##FJ7#DGG.p$pqq..vufMMMMs   AAAAc                 >  #    U R                  5       I Sh  vN   U R                  U5      nSnU R                  X25      u  pBUS   US   US.nU R                  U R	                  XR5      5      I Sh  vN nU R                  US0 5      nU R                  Xs5      $  N N*7f)a7  
fetch the set leverage for a market

https://www.bitget.com/api-doc/contract/account/Get-Single-Account

:param str symbol: unified market symbol
:param dict [params]: extra parameters specific to the exchange API endpoint
:returns dict: a `leverage structure <https://docs.ccxt.com/#/?id=leverage-structure>`
NrE   r  r  r  r  r  )r  r  r   privateMixGetV2MixAccountAccountr=  r7  parse_leverager  r  r  r  r  r  r  r  s           r  fetch_leveragebitget.fetch_leverage   s      !!!V$"AA&QTl ,&

 >>t{{7?[\\: ~~h3""400O 	" ]"   BBAB0B1)BBr*  c                     U R                  US5      S:H  nU(       a  SOSnU(       a  SOSnUUS   U(       a  SOSU R                  X5      U R                  X5      S	.$ )
Nr  r  crossedMarginLeverageisolatedLongLeverisolatedShortLeverr  r  r  )r6  r  r  longLeverageshortLeverage)rG  r  )r  r*  r  isCrossMarginMode
longLevKeyshortLevKeys         r  r  bitget.parse_leverage,!  sh     ,,X|D	Q0A,GZ
1B-H\X&%6'J --hC!..xE
 	
r  c                 R  #    Uc  [        U R                  S-   5      eU R                  5       I Sh  vN   U R                  U5      nSnU R	                  XC5      u  pSUS   U R                  U5      S.nSnSnU R                  USSS5      u  psU(       aW  US:X  a  Sn	U R                  S	U5      u  pU	b  S
nUS   US'   XVS'   U R                  U R                  Xc5      5      I Sh  vN nU$ US   US'   XVS'   U R                  U R                  Xc5      5      I Sh  vN nU$  N N> N
7f)au  
set the level of leverage for a market

https://www.bitget.com/api-doc/contract/account/Change-Leverage
https://www.bitget.com/api-doc/uta/account/Change-Leverage

:param int leverage: the rate of leverage
:param str symbol: unified market symbol
:param dict [params]: extra parameters specific to the exchange API endpoint
:param str [params.holdSide]: *isolated only* position direction, 'long' or 'short'
:param boolean [params.uta]: set to True for the unified trading account(uta), defaults to False
:param boolean [params.posSide]: required for uta isolated margin, long or short
:returns dict: response from the exchange
Nz) setLeverage() requires a symbol argumentrE   )r  r*  r   r   Fr  r   r  r  r  r  r  r  )r/   rE   r  r  r  r  r  r  "privateUtaPostV3AccountSetLeverager=  %privateMixPostV2MixAccountSetLeverage)
r  r*  r  r  r  r  r  r   r  r  s
             r  set_leveragebitget.set_leverage8!  sT     >#DGG.Y$YZZ!!!V$"AA&QTl--h7
 33FM5RWXf$!
%)%G%GW]%^"
)"*K$Z0GFO"-J!DDT[[QXEabbH8 % %+:$6GL!%0M"!GGT[HdeeH  _ 	"& c fs4   /D'D!B2D'$D#%5D'D%D'#D'%D'r  c                   #    Uc  [        U R                  S-   5      eUR                  5       nUS:X  a  SnUS:w  a  US:w  a  [        U R                  S-   5      eU R                  5       I Sh  vN   U R	                  U5      nSnU R                  XC5      u  pSUS   US   UUS	.nU R                  U R                  Xc5      5      I Sh  vN nU$  Na N7f)
a<  
set margin mode to 'cross' or 'isolated'

https://www.bitget.com/api-doc/contract/account/Change-Margin-Mode

:param str marginMode: 'cross' or 'isolated'
:param str symbol: unified market symbol
:param dict [params]: extra parameters specific to the exchange API endpoint
:returns dict: response from the exchange
Nz+ setMarginMode() requires a symbol argumentr  r  r  zE setMarginMode() marginMode must be either isolated or crossed(cross)rE   r  )r  r  r  r  )r/   rE   lowerr  r  r  'privateMixPostV2MixAccountSetMarginModer=  )r  r  r  r  r  r  r  r  s           r  set_margin_modebitget.set_margin_modez!  s      >#DGG.[$[\\%%'
 "J*$:+B#DGG.u$uvv!!!V$"AA&QTl ,$&	
 EEdkkRYFbcc 3 	" ds%   A+C-C.ACC	CCr  c                   #    U R                  5       I Sh  vN   U(       a  SOSn0 nSnUb  U R                  U5      nSnSnSn	U R                  Xc5      u  psU R                  USSS5      u  pU(       a.  XES'   U R	                  U R                  XS5      5      I Sh  vN n	U	$ XES'   XuS	'   U R                  U R                  XS5      5      I Sh  vN n	U	$  N N: N
7f)
a  
set hedged to True or False for a market

https://www.bitget.com/api-doc/contract/account/Change-Hold-Mode
https://www.bitget.com/api-doc/uta/account/Change-Position-Mode

:param bool hedged: set to True to use dualSidePosition
:param str symbol: not used by bitget setPositionMode()
:param dict [params]: extra parameters specific to the exchange API endpoint
:param str [params.productType]: required if not uta and symbol is None: 'USDT-FUTURES', 'USDC-FUTURES', 'COIN-FUTURES', 'SUSDT-FUTURES', 'SUSDC-FUTURES' or 'SCOIN-FUTURES'
:param boolean [params.uta]: set to True for the unified trading account(uta), defaults to False
:returns dict: response from the exchange
Nr%  r  r   r   Fr  rn  r  )r  r  r  r  "privateUtaPostV3AccountSetHoldModer=  )privateMixPostV2MixAccountSetPositionMode)
r  r  r  r  rn  r  r  r  r   r  s
             r  set_position_modebitget.set_position_mode!  s      !!!"(,n[[(F"AA&Q33F<MuV[\")J!DDT[[QXEabbH.  ")I%0M"!KKDKKX_LhiiH I 	" c js4   CCBCC1CCCCCc                    #    U R                  5       I Sh  vN   U R                  U5      nUS   (       d  [        U R                  S-   5      eSnU R	                  X25      u  pBSUS   0nSnSnU R                  USSS5      u  pbU(       a-  XES	'   U R                  U R                  XR5      5      I Sh  vN nO,XES
'   U R                  U R                  XR5      5      I Sh  vN nU R                  US0 5      nU R                  X5      $  N NW N,7f)a  
retrieves the open interest of a contract trading pair

https://www.bitget.com/api-doc/contract/market/Get-Open-Interest
https://www.bitget.com/api-doc/uta/public/Get-Open-Interest

:param str symbol: unified CCXT market symbol
:param dict [params]: exchange specific parameters
:param boolean [params.uta]: set to True for the unified trading account(uta), defaults to False
:returns dict} an open interest structure{@link https://docs.ccxt.com/#/?id=open-interest-structure:
Nr  z3 fetchOpenInterest() supports contract markets onlyr  rE   r   r   Fr  r  r  )r  r  r0   rE   r  r   publicUtaGetV3MarketOpenInterestr=  #publicMixGetV2MixMarketOpenInterestr7  parse_open_interest)	r  r  r  r  r  r  r   r  r  s	            r  fetch_open_interestbitget.fetch_open_interest!  s     !!!V$j!TWW'\\]]"AA&QfTl
 33F<OQVX]^"-J!BB4;;wC_``H$ &1M"!EEdkkRYFbccH" ~~h3''55g 	" a& ds4   DDBD2D
3,DD )D
DDc           	         U R                  USS/ 5      nU R                  US5      nU R                  US   S5      nU R                  U R	                  XRS S5      U R                  US   SS5      S UU R                  U5      US	.U5      $ )
NopenInterestListrC  r  r   r  r  r  openInterest)r  openInterestAmountopenInterestValuer  r  r6  )r  r  rG  safe_open_interestr  rR  rK  )r  r  r  r  r  r`  s         r  r1  bitget.parse_open_interest"  s    4 *<fbI%%h5	##DGX6&&&&xzJ"&"4"4T!Wfn"U!%"Y/(
  	r  c                 \  #    Uc  [        U R                  S-   5      eU R                  5       I Sh  vN   SnU R                  SSU5      u  pTU R	                  USU5      nU R                  US5      nU R                  U R                  S0 5      nU R	                  Xv5      nU R                  U5      nUS   US.n	Ub  X)S'   Ub  X9S	'   U R                  S
X5      u  pU R                  U R                  X5      5      I Sh  vN n
U R                  U
S/ 5      nU R                  XX#5      $  N N+7f)aJ  
fetch a history of internal transfers made on an account

https://www.bitget.com/api-doc/spot/account/Get-Account-TransferRecords

: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 entries for
:returns dict[]: a list of `transfer structures <https://docs.ccxt.com/#/?id=transfer-structure>`
Nz* fetchTransfers() requires a code argumentr   fromAccountr  rE   )r  fromTyper  r  r  r  )r/   rE   r  rc  rG  r  r  r  r  r  *privateSpotGetV2SpotAccountTransferRecordsr=  r8  parse_transfers)r  r  r  r  r  r  r<  r  r  r  r  r  s               r  fetch_transfersbitget.fetch_transfersB"  s<     <#DGG.Z$Z[[!!!99:JDRXY&&v}dC6=17GL<==&TN
 #(K $G229gNHHU\Ieff, ~~h3##DEAAQ 	"" gs"   /D,D(CD,>D*?*D,*D,r<  	toAccountc                 >  #    U R                  5       I Sh  vN   U R                  U5      nU R                  U R                  S0 5      nU R	                  Xs5      nU R	                  Xt5      n	UU	UUS   S.n
U R	                  US5      nU R                  US5      nSnUb  U R                  U5      nUS   U
S'   U R                  U R                  X5      5      I Sh  vN nU R                  US0 5      nU R                  US5      US'   U R                  X5      $  GN N@7f)	a  
transfer currency internally between wallets on the same account

https://www.bitget.com/api-doc/spot/account/Wallet-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.symbol]: unified CCXT market symbol, required when transferring to or from an account type that is a leveraged position-by-position account
:param str [params.clientOid]: custom id
:returns dict: a `transfer structure <https://docs.ccxt.com/#/?id=transfer-structure>`
Nr  rE   )r=  toTyper!  r  r  r  r  r  )r  r  r  r  rG  r  r  #privateSpotPostV2SpotWalletTransferr=  r  parse_transfer)r  r  r!  r<  rB  r  r  r  r=  rD  r  r  r  r  r  s                  r  r   bitget.transfer{"  s"     !!!==&7GL##N@!!.< TN	
 !!&(368,[[(F &tGHAA$++gB^__ x4&&x?T
""422? 	"" `s"   DDCDD>DDr   c                    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 R                  S0 5      nU R                  XvU5      nU R                  US5      n	U R                  XyU	5      n
UU R                  US5      UU R                  U5      U R                  XR5      U R                  US5      UU
U R                  U5      S	.	$ )
Nr  r  r  r=  r  rD  
transferIdr  )	r6  rE   r  r  r  r!  r<  rB  r  )	r  r  rG  r  r  rK  rH  rP  parse_transfer_status)r  r   r  r  r  r  fromAccountRawr  r<  toAccountRawrB  s              r  rF  bitget.parse_transfer"  s    2 %%h5	''(;%%h7
))(J?t||^RH&&|^T''(;$$\N	""8\:"Y///
E&&x8&"008

 
	
r  c                 .    SS0nU R                  X!U5      $ )N
successfulr  r  r  s      r  rJ  bitget.parse_transfer_status"  s#    $
 &99r  c                    U R                  US/ 5      n[        U5      nUS S S.S S S.0 S.n[        SU5       H  nX6   nU R                  US5      nU R                  US5      n	U R	                  X5      n
S S S.U R                  US5      SS.S	.US
   U
'   US:X  d  Me  U R                  US5      US   S'   SUS   S'   M     U$ )Nr  )r  rI  )r6  r   r  r  r   r  r  r  F)r  r   r  r   r   r  rI  )r  r:  r9  rG  r  rP  )r  r  r  r  r  r_  rW  r  r  r  r  s              r  parse_deposit_withdraw_fee!bitget.parse_deposit_withdraw_fee"  s    . h36{"
 " 
 q,'AIE((8I++Hf=L11)JK#'t<$($4$4UM$JZ_`/F:{+ q ,0,<,<UM,Rz"5)38z"<0 ( r  codesc                    #    U R                  5       I Sh  vN   U R                  U5      I Sh  vN nU R                  US/ 5      nU R                  XAS5      $  NB N+7f)a7  
fetch deposit and withdraw fees

https://www.bitget.com/api-doc/spot/market/Get-Coin-List

:param str[]|None codes: list of unified currency codes
:param dict [params]: extra parameters specific to the exchange API endpoint
:returns dict: a list of `fee structures <https://docs.ccxt.com/#/?id=fee-structure>`
Nr  r  )r  r  r8  parse_deposit_withdraw_fees)r  rT  r  r  r  s        r  fetch_deposit_withdraw_fees"bitget.fetch_deposit_withdraw_fees#  s\      !!!<<VDD< ~~h3//VDDA 	"Ds   AAAA*AAc                 *  #    U R                  5       I Sh  vN   U R                  U5      nUS   U R                  X5      S.nU R                  U R	                  XS5      5      I Sh  vN nU R                  US0 5      nU R                  Xt5      $  Nx N*7f)av  
create a loan to borrow margin

https://www.bitget.com/api-doc/margin/cross/account/Cross-Borrow

:param str code: unified currency code of the currency to borrow
:param str 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>`
NrE   )r  borrowAmountr  )r  r  r  -privateMarginPostV2MarginCrossedAccountBorrowr=  r  parse_margin_loanr  r  r!  r  r  r  r  r  s           r  borrow_cross_marginbitget.borrow_cross_margin=#  s      !!!==&TN 66tD
 KKDKKX_Lhii x4%%d55) 	" j"   BBAB&B')BBc                 V  #    U R                  5       I Sh  vN   U R                  U5      nU R                  U5      nUS   U R                  X#5      US   S.nU R	                  U R                  Xt5      5      I Sh  vN nU R                  US0 5      n	U R                  XU5      $  N N+7f)a  
create a loan to borrow margin

https://www.bitget.com/api-doc/margin/isolated/account/Isolated-Borrow

:param str symbol: unified market symbol
:param str code: unified currency code of the currency to borrow
:param str 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>`
NrE   )r  rZ  r  r  )r  r  r  r  .privateMarginPostV2MarginIsolatedAccountBorrowr=  r  r\  
r  r  r  r!  r  r  r  r  r  r  s
             r  borrow_isolated_marginbitget.borrow_isolated_margin^#  s      !!!==&V$TN 66tDTl

 LLT[[Y`Mijj x4%%df==/ 	" k"   B)B%A$B);B'<*B)'B)c                 V  #    U R                  5       I Sh  vN   U R                  U5      nU R                  U5      nUS   U R                  X#5      US   S.nU R	                  U R                  Xt5      5      I Sh  vN nU R                  US0 5      n	U R                  XU5      $  N N+7f)a  
repay borrowed margin and interest

https://www.bitget.com/api-doc/margin/isolated/account/Isolated-Repay

:param str symbol: unified market symbol
:param str code: unified currency code of the currency to repay
:param str 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>`
NrE   )r  repayAmountr  r  )r  r  r  r  -privateMarginPostV2MarginIsolatedAccountRepayr=  r  r\  rc  s
             r  repay_isolated_marginbitget.repay_isolated_margin#  s      !!!==&V$TN55dCTl

 KKDKKX_Lhii x4%%df==1 	" jrf  c                 *  #    U R                  5       I Sh  vN   U R                  U5      nUS   U R                  X5      S.nU R                  U R	                  XS5      5      I Sh  vN nU R                  US0 5      nU R                  Xt5      $  Nx N*7f)aw  
repay borrowed margin and interest

https://www.bitget.com/api-doc/margin/cross/account/Cross-Repay

:param str code: unified currency code of the currency to repay
:param str 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>`
NrE   )r  rh  r  )r  r  r  ,privateMarginPostV2MarginCrossedAccountRepayr=  r  r\  r]  s           r  repay_cross_marginbitget.repay_cross_margin#  s      !!!==&TN55dC
 JJ4;;W^Kghh x4%%d55+ 	" ir`  c                     U R                  US5      nU R                  US5      nS nUb  U R                  XSS S5      nU R                  USS5      U R                  XB5      U R	                  USS5      US S US.$ )	Nr  r  rR   loanIdrepayIdrZ  rh  )rE   r  r!  r  r  r  r6  )rG  r  r  rH  rR  )r  r6  r  r  r  r`  r  s          r  r\  bitget.parse_margin_loan#  s    L %%dF3
##D(3%%hfEF$$T8Y?//
E((~}M
 	
r  c           	      p  #    U R                  5       I Sh  vN   SnU R                  USS5      u  pTU(       a  U R                  SXX4SS5      I Sh  vN $ SnUb  U R                  U5      nSnU R	                  SXd5      u  ptUS:w  a  [        U R                  S-   5      e0 nU R                  S	X5      u  pUb  X(S
'   OU R                  5       S-
  US
'   Ub  X8S'   Sn	Sn
U R                  SUS5      u  pU
S:X  aL  Uc  [        U R                  S-   5      eUS   US'   U R                  U R                  X5      5      I Sh  vN n	O.U
S:X  a(  U R                  U R                  X5      5      I Sh  vN n	U R                  U	S0 5      nU R                  US/ 5      nU R!                  XX#5      $  GN GN^ Nq ND7f)a  
retrieves the users liquidated positions

https://www.bitget.com/api-doc/margin/cross/record/Get-Cross-Liquidation-Records
https://www.bitget.com/api-doc/margin/isolated/record/Get-Isolated-Liquidation-Records

: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 bitget api endpoint
:param int [params.until]: timestamp in ms of the latest liquidation
:param str [params.marginMode]: 'cross' or 'isolated' default value is 'cross'
: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: an array of `liquidation structures <https://docs.ccxt.com/#/?id=liquidation-structure>`
NFr   r  r  r  rR   z8 fetchMyLiquidations() supports spot margin markets onlyr  r  r  r  r  r  z1 fetchMyLiquidations() requires a symbol argumentrE   r  r  r  )r  r  r  r  rc  r6   rE   r  r  r  r/   2privateMarginGetV2MarginIsolatedLiquidationHistoryr=  1privateMarginGetV2MarginCrossedLiquidationHistoryr  r8  parse_liquidations)r  r  r  r  r  r  r  r  r  r  r  r  liquidationss                r  fetch_my_liquidationsbitget.fetch_my_liquidations $  s      !!!88AVXbc99:OQW`eov  yE  F  F  F[[(F99:OQW`6>tww)ccdd229gN#(K #'#4#4#6#CGK $G
!??@UW]_fg
#~'2e(eff &tGH!TTUYU`U`ahUqrrH7"!SSTXT_T_`gTpqqHj x4~~dL"=&&|UJJi 	" F. sqsF   F6F,:F6F/C.F6 F2.F6/F40=F6/F62F64F6c                 P   U R                  US5      nU R                  US5      nU R                  USS5      nU R                  US5      n[        R                  " XV5      nU R                  UU R                  X25      S S S S U R                  U5      UU R                  U5      S.	5      $ )Nr  
liqEndTimeLiqFeeliqFee	totalDebt)	r6  r  r  r.  r  	baseValue
quoteValuer  r  )	rG  r  r  r?   r  safe_liquidationr  r  rK  )r  liquidationr  r`  r  liquidationFeer  quoteValueStrings           r  parse_liquidationbitget.parse_liquidationf$  s    > ##K:%%k<@	++K8L$$[+>	"--nH$$&&x8 ++,<="Y/
&
 
 
	r  c                 \  #    U R                  5       I Sh  vN   U R                  U5      nSUS   0nU R                  U R                  XB5      5      I Sh  vN nU R	                  US5      nU R                  US/ 5      nU R                  US0 5      nXhS'   U R                  X5      $  N NS7f)a  
fetch the rate of interest to borrow a currency for margin trading

https://www.bitget.com/api-doc/margin/isolated/account/Isolated-Margin-Interest-Rate-And-Max-Borrowable-Amount

:param str symbol: unified market symbol
:param dict [params]: extra parameters specific to the exchange API endpoint
:returns dict: an `isolated borrow rate structure <https://docs.ccxt.com/#/?id=isolated-borrow-rate-structure>`
Nr  rE   r  r  r   r  )r  r  4privateMarginGetV2MarginIsolatedInterestRateAndLimitr=  r  r  parse_isolated_borrow_rate)	r  r  r  r  r  r  r  r  r  s	            r  fetch_isolated_borrow_rate!bitget.fetch_isolated_borrow_rate$  s      !!!V$fTl
 RRSWS^S^_fSoppT %%h>	x4a,&k..u==g 	"
 qs"   B,B(?B,B*AB,*B,r6  c           
      j   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5      U R	                  US5      U R                  U5      U R	                  US5      SUU R                  U5      US	.	$ )
Nr  rR   r   r  r  baseDailyInterestRatequoteDailyInterestRater  )	r  r  baseRater  	quoteRateperiodr  r  r6  )rG  r  r  rH  rP  rK  )r  r6  r  r`  r  r  r  r  s           r  r  !bitget.parse_isolated_borrow_rate$  s    F ##D(3!!(D&A!!$
3""45%%dK8	++F3((/FG,,W5))$0HI"Y/

 
	
r  c                   #    U R                  5       I Sh  vN   U R                  U5      nSUS   0nSnSnSnU R                  USSS5      u  pRU(       a<  U R                  U R	                  XB5      5      I Sh  vN nU R                  US0 5      nONU R                  U R	                  XB5      5      I Sh  vN nU R                  US/ 5      nU R                  US0 5      nU R                  US	5      n	XS
'   U R                  Xs5      $  N N NU7f)a"  
fetch the rate of interest to borrow a currency for margin trading

https://www.bitget.com/api-doc/margin/cross/account/Get-Cross-Margin-Interest-Rate-And-Borrowable
https://www.bitget.com/api-doc/uta/public/Get-Margin-Loans

:param str code: unified currency code
:param dict [params]: extra parameters specific to the exchange API endpoint
:param boolean [params.uta]: set to True for the unified trading account(uta), defaults to False
:returns dict: a `borrow rate structure <https://github.com/ccxt/ccxt/wiki/Manual#borrow-rate-structure>`
Nr  rE   r~   r   Fr  r   r  r  )
r  r  r  publicUtaGetV3MarketMarginLoansr=  r7  3privateMarginGetV2MarginCrossedInterestRateAndLimitr  r  parse_borrow_rate)
r  r  r  r  r  r   r  r_  r  r  s
             r  fetch_cross_borrow_ratebitget.fetch_cross_borrow_rate	%  s     !!!==&HTN
 33F<RTY[`a!AA$++gB^__H ^^Hfb9F!UUVZVaVabiVrssH6 ??8VR8D__T1b1F%%h>	'{%%f77q 	" ` ts5   DDA"D9D	:;D5D6AD	DDc                     U R                  US5      nU R                  US5      nU R                  X25      U R                  USS5      SUU R	                  U5      US.$ )Nr  r  dailyInterestRatedailyInterestr  )r  rater  r  r  r6  )rG  r  rH  rR  rK  )r  r6  r  r  r  s        r  r  bitget.parse_borrow_rateO%  sh    < %%dF3
%%dK8	//
E&&t-@/R"Y/
 	
r  c           	      >  #    U R                  5       I Sh  vN   SnU R                  USS5      u  peU(       a  U R                  SX#XESS5      I Sh  vN $ SnUb  U R                  U5      n0 nSn	Ub  U R	                  U5      n	U	S   US'   Ub  X8S	'   OU R                  5       S
-
  US	'   Ub  XHS'   Sn
SnU R                  SUS5      u  pUS:X  aL  Uc  [        U R                  S-   5      eUS   US'   U R                  U R                  X5      5      I Sh  vN n
O.US:X  a(  U R                  U R                  X5      5      I Sh  vN n
U R                  U
S0 5      nU R                  US/ 5      nU R                  X5      nU R                  XX45      $  GN} GNE N NU7f)a  
fetch the interest owed by the user for borrowing currency for margin trading

https://www.bitget.com/api-doc/margin/cross/record/Get-Cross-Interest-Records
https://www.bitget.com/api-doc/margin/isolated/record/Get-Isolated-Interest-Records

:param str [code]: unified currency code
:param str [symbol]: unified market symbol when fetching interest in isolated markets
:param int [since]: the earliest time in ms to fetch borrow 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.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 `borrow interest structures <https://docs.ccxt.com/#/?id=borrow-interest-structure>`
NFrt   r  r  r  rE   r  r  r  r  r  r  z1 fetchBorrowInterest() requires a symbol argumentr  r  r  )r  r  r  r  r  r  r  r/   rE   /privateMarginGetV2MarginIsolatedInterestHistoryr=  .privateMarginGetV2MarginCrossedInterestHistoryr  parse_borrow_interestsfilter_by_currency_since_limit)r  r  r  r  r  r  r  r  r  r  r  r  r  rowsr  s                  r  fetch_borrow_interestbitget.fetch_borrow_interestx%  s     !!!88AVXbc99:OQW`eov  yE  F  F  F[[(F}}T*H&tnGFO#(K #'#4#4#6#CGK $G
!??@UW]_fg
#~'2e(eff &tGH!QQRVR]R]^eRnooH7"!PPQUQ\Q\]dQmnnHf x4t\26..t<2285PPe 	" F, pnsG   FF:FFCFF.FFAFFFFc                 N   U R                  US5      nU R                  X25      nUb  SOSnU R                  US5      nUU R                  US5      U R                  U R                  US5      5      U R	                  US5      U R	                  US5      S UUU R                  U5      S.	$ )	Nr  r  r  r  interestCoininterestAmountr  )	r6  r  r  r  r  amountBorrowedr  r  r  )rG  r5  r  rH  rP  rK  )r  r6  r  r`  r  r  s         r  parse_borrow_interestbitget.parse_borrow_interest%  s    : ##D(3!!(3$,$8Zw
%%dG4	&&vx8//0@0@~0VW((/?@ ,,T3FG"$"Y/

 
	
r  c                 (  #    U R                  5       I Sh  vN   U R                  U5      nSUS   0nSnSnSnU R                  XC5      u  pcU R                  USSS5      u  psU(       a4  Ub  X%S'   XeS'   U R	                  U R                  XS5      5      I Sh  vN nO3Ub  X%S	'   XeS
'   U R                  U R                  XS5      5      I Sh  vN nU R                  US0 5      n	U R                  U	SS/ 5      n
U R                  U
S   U5      $  N Nv ND7f)a&  
closes an open position for a market

https://www.bitget.com/api-doc/contract/trade/Flash-Close-Position
https://www.bitget.com/api-doc/uta/trade/Close-All-Positions

:param str symbol: unified CCXT market symbol
:param str [side]: one-way mode: 'buy' or 'sell', hedge-mode: 'long' or 'short'
:param dict [params]: extra parameters specific to the exchange API endpoint
:param boolean [params.uta]: set to True for the unified trading account(uta), defaults to False
:returns dict: An `order structure <https://docs.ccxt.com/#/?id=order-structure>`
Nr  rE   r^   r   Fr  r  r  r  r  r  rC  r   )
r  r  r  r  #privateUtaPostV3TradeClosePositionsr=  &privateMixPostV2MixOrderClosePositionsr  r  rF  )r  r  rs  r  r  r  r  r   r  r  rz  s              r  close_positionbitget.close_position&  s2     !!!V$fTl
 "AA&Q33FOUTYZ%)	""-J!EEdkkRYFbccH" &*
#%0M"!HHU\IeffH$ x4  }fbAa&11m 	" d( gs5   DDB DD3DDADDDc                   #    U R                  5       I Sh  vN   0 nSnSnSnU R                  SU5      u  p1U R                  USSS5      u  pAU(       a-  X2S'   U R                  U R	                  X!5      5      I Sh  vN nO,X2S'   U R                  U R	                  X!5      5      I Sh  vN nU R                  US0 5      nU R                  USS	/ 5      nU R                  USU5      $  N Nm NB7f)
aD  
closes all open positions for a market type

https://www.bitget.com/api-doc/contract/trade/Flash-Close-Position
https://www.bitget.com/api-doc/uta/trade/Close-All-Positions

:param dict [params]: extra parameters specific to the exchange API endpoint
:param str [params.productType]: 'USDT-FUTURES', 'USDC-FUTURES', 'COIN-FUTURES', 'SUSDT-FUTURES', 'SUSDC-FUTURES' or 'SCOIN-FUTURES'
:param boolean [params.uta]: set to True for the unified trading account(uta), defaults to False
:returns dict[]: A list of `position structures <https://docs.ccxt.com/#/?id=position-structure>`
Nr]   r   Fr  r  r  r  rC  )	r  r  r  r  r=  r  r  r  parse_positions)r  r  r  r  r   r  r  r  s           r  close_all_positionsbitget.close_all_positionsM&  s      !!!"AA$O33F<OQVX]^"-J!EEdkkRYFbccH" &1M"!HHU\IeffH$ x4$$T=&"E	##ItV<<_ 	" d$ gs4   C-C'A$C-;C)<,C-(C+)?C-)C-+C-c                 >  #    U R                  5       I Sh  vN   U R                  U5      nSnU R                  X25      u  pBUS   US   US.nU R                  U R	                  XR5      5      I Sh  vN nU R                  US0 5      nU R                  Xs5      $  N N*7f)ag  
fetches the margin mode of a trading pair

https://www.bitget.com/api-doc/contract/account/Get-Single-Account

:param str symbol: unified symbol of the market to fetch the margin mode for
:param dict [params]: extra parameters specific to the exchange API endpoint
:returns dict: a `margin mode structure <https://docs.ccxt.com/#/?id=margin-mode-structure>`
NrE   r  r  r  )r  r  r  r  r=  r7  parse_margin_moder  s           r  fetch_margin_modebitget.fetch_margin_mode&  s      !!!V$"AA&QTl ,&

 >>t{{7?[\\: ~~h3%%d33O 	" ]r  c                 L    U R                  US5      nUS:X  a  SOUnUUS   US.$ )Nr  r  r  r  )r6  r  r  r  )r  r  r  
marginTypes       r  r  bitget.parse_margin_mode&  s:    %%j,?
!+y!8Wz
X&$
 	
r  c                   #    U R                  5       I Sh  vN   0 nSnSnSnSn	Ub-  [        U5      n
U
S:  a  U R                  US   5      nUS   US'   Ub  X%S'   Ub  X5S'   U R                  SXT5      u  pTU R	                  Xd5      u  ptU R                  USS	S
5      u  pU(       a-  XuS'   U R                  U R                  XT5      5      I Sh  vN n	O(U R                  U R                  XT5      5      I Sh  vN n	U R                  U	S0 5      nU R                  US/ 5      nU R                  XU5      nU R                  XU5      $  GN0 Nz NS7f)a  
fetches historical positions

https://www.bitget.com/api-doc/contract/position/Get-History-Position
https://www.bitget.com/api-doc/uta/trade/Get-Position-History

:param str[] [symbols]: unified contract symbols
:param int [since]: timestamp in ms of the earliest position to fetch, default=3 months ago, max range for params["until"] - since is 3 months
:param int [limit]: the maximum amount of records to fetch, default=20, max=100
:param dict params: extra parameters specific to the exchange api endpoint
:param int [params.until]: timestamp in ms of the latest position to fetch, max range for params["until"] - since is 3 months
:param str [params.productType]: USDT-FUTURES(default), COIN-FUTURES, USDC-FUTURES, SUSDT-FUTURES, SCOIN-FUTURES, or SUSDC-FUTURES
:param boolean [params.uta]: set to True for the unified trading account(uta), defaults to False
:returns dict[]: a list of `position structures <https://docs.ccxt.com/#/?id=position-structure>`
Nr   rE   r  r  r  r  r   r   Fr  r  rC  )r  r:  r  r  r  r  &privateUtaGetV3PositionHistoryPositionr=  r  r7  r8  r  filter_by_since_limit)r  ra  r  r  r  r  r  r  r   r  rg  r  r  	positionss                 r  fetch_positions_historybitget.fetch_positions_history&  sm      !!!LMq WQZ0$*4L!#(K $G229gN"AA&Q33F<SUZ\ab"-J!HHU\IeffHD "KKDKKX_LhiiH< ~~h3~~dFB7((G	)))EBBo 	"( gD js5   EEB7EE	(E7E8AE	EEfromCodetoCodec                   #    U R                  5       I Sh  vN   UUU R                  U5      S.nU R                  U R                  XT5      5      I Sh  vN nU R	                  US0 5      nU R                  USU5      nU R                  U5      n	U R                  USU5      n
U R                  U
5      nU R                  XyU5      $  N Ns7f)a  
fetch a quote for converting from one currency to another

https://www.bitget.com/api-doc/common/convert/Get-Quoted-Price

:param str fromCode: the currency that you want to sell and convert from
:param str toCode: the currency that you want to buy and convert into
:param float [amount]: how much you want to trade in units of the from currency
:param dict [params]: extra parameters specific to the exchange API endpoint
:returns dict: a `conversion structure <https://docs.ccxt.com/#/?id=conversion-structure>`
N)fromCointoCoinfromCoinSizer  r  r  )r  r  %privateConvertGetV2ConvertQuotedPricer=  r7  rG  r  parse_conversion)r  r  r  r!  r  r  r  r  fromCurrencyIdfromCurrencytoCurrencyId
toCurrencys               r  fetch_convert_quotebitget.fetch_convert_quote/'  s      !!!  11&9

 CCDKKPWD`aa" ~~h3))$
HE}}^4''h?]]<0
$$TDD9 	" bs"   C	C<C	CA2C	C	c                 6  #    U R                  5       I Sh  vN   U R                  USS5      nUc  [        U R                  S-   5      eU R                  USS5      nUc  [        U R                  S-   5      eU R	                  USS/5      nUUUU R                  U5      UUS.nU R                  U R                  X5      5      I Sh  vN n	U R                  U	S	0 5      n
U R                  U
S
U5      nU R                  U5      nU R                  U
SU5      $  N NP7f)a  
convert from one currency to another

https://www.bitget.com/api-doc/common/convert/Trade

:param str id: the id of the trade that you want to make
:param str fromCode: the currency that you want to sell and convert from
:param str toCode: the currency that you want to buy and convert into
:param float amount: how much you want to trade in units of the from currency
:param dict [params]: extra parameters specific to the exchange API endpoint
:param str params['price']: the price of the conversion, obtained from fetchConvertQuote()
:param str params['toAmount']: the amount you want to trade in units of the toCurrency, obtained from fetchConvertQuote()
:returns dict: a `conversion structure <https://docs.ccxt.com/#/?id=conversion-structure>`
Nr  	cnvtPricez0 createConvertTrade() requires a price parametertoAmount
toCoinSizez3 createConvertTrade() requires a toAmount parameter)traceIdr  r  r  r  r  r  r  )r  r  r/   rE   r  r   privateConvertPostV2ConvertTrader=  r7  rG  r  r  )r  rE   r  r  r!  r  r  r  r  r  r  r  r  s                r  create_convert_tradebitget.create_convert_tradeY'  s$     !!!""67K@=#DGG.`$`aa%%fj,G#DGG.c$cdd6GZ#89  11&9"
 >>t{{7?[\\ ~~h3''h?]]<0
$$T4<<C 	"  ]s#   DDB/DDADDc                   #    U R                  5       I Sh  vN   0 nSnU R                  5       nUb  X%S'   OXv-
  US'   U R                  USS5      nUb  XS'   OXuS'   Ub  X5S'   U R                  US5      nU R	                  U R                  XT5      5      I Sh  vN n	U R                  U	S0 5      n
U R                  U
S/ 5      nU R                  XS	S
X#5      $  N N@7f)a  
fetch the users history of conversion trades

https://www.bitget.com/api-doc/common/convert/Get-Convert-Record

: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
:returns dict[]: a list of `conversion structures <https://docs.ccxt.com/#/?id=conversion-structure>`
Nr  r  r  r  r  r  r  r  r  )	r  r  r  r  'privateConvertGetV2ConvertConvertRecordr=  r7  r8  parse_conversions)r  r  r  r  r  r  r  r  r  r  r  r  s               r  fetch_convert_trade_history"bitget.fetch_convert_trade_history'  s      !!!!#(K #&=GK $$VY@!(I!$I$G67+EEdkkRYFbcc. ~~h3>>$
B7%%hj(EYYS 	"  ds"   CCBCC?CC
conversionr  r  c                    U R                  US5      nU R                  US5      nU R                  XR5      nU R                  US5      nU R                  Xs5      nUUU R                  U5      U R	                  USS5      UU R                  US5      UU R                  US5      U R                  US5      U R                  US	5      S
.
$ )Nr  r  r  rE   r  r  r  r  r  )
r6  r  r  rE   r  
fromAmountr  r  r  r  )r  rG  rH  rK  r  rP  )	r  r  r  r  r  r  r  tor  s	            r  r  bitget.parse_conversion'  s    H %%j$7	##J
;**8Bj(3((8"Y/$$ZyA$**:~F ((\B%%j+>##J6
 	
r  c                   #    U R                  5       I Sh  vN   U R                  U5      I Sh  vN n0 nU R                  US/ 5      n[        S[	        U5      5       Hy  nXE   nU R                  US5      nU R                  U5      nUUUSSSSSU R                  US5      SSU R                  US5      U R                  US5      S.SSS.SSS.S	.SS
.X8'   M{     U$  N N7f)a  
fetches all available currencies that can be converted

https://www.bitget.com/api-doc/common/convert/Get-Convert-Currencies

:param dict [params]: extra parameters specific to the exchange API endpoint
:returns dict: an associative dictionary of currencies
Nr  r   r  r  	minAmount	maxAmountr$  r  r  )r  $privateConvertGetV2ConvertCurrenciesr8  r9  r:  rG  rH  rP  )	r  r  r  r_  r  rW  r  rE   r  s	            r  fetch_convert_currenciesbitget.fetch_convert_currencies'  s     !!!BB6JJ  ~~h3q#d)$AGE!!%0B**2.D  ,,UK@!  $//{C#//{C
  $#!
  $#   5FL	 %@ g 	"Js    C!CC!CB.C!C!c                   #    U R                  5       I Sh  vN   U R                  U5      nSnU R                  X25      u  pBSUS   0nSnSnU R                  USSS5      u  prU(       a)  U R	                  U R                  XR5      5      I Sh  vN nO,XES'   U R                  U R                  XR5      5      I Sh  vN nU R                  US/ 5      nU R                  US	0 5      n	U R                  X5      $  N Nj N?7f)
a  
fetch the current funding rate interval

https://www.bitget.com/api-doc/contract/market/Get-Symbol-Next-Funding-Time
https://www.bitget.com/api-doc/uta/public/Get-Current-Funding-Rate

:param str symbol: unified market symbol
:param dict [params]: extra parameters specific to the exchange API endpoint
:param boolean [params.uta]: set to True for the unified trading account(uta), defaults to False
:returns dict: a `funding rate structure <https://docs.ccxt.com/#/?id=funding-rate-structure>`
Nr  rE   r   r   Fr  r  r   )
r  r  r  r  r  r=  r  r8  r7  r  )
r  r  r  r  r  r  r  r   r  r  s
             r  fetch_funding_intervalbitget.fetch_funding_interval6(  s     !!!V$"AA&QfTl
 33F<RTY[`a!EEdkkRYFbccH& &1M"!DDT[[QXEabbH ~~h3tQ+&&u55a 	" d( cs4   C;C5A5C;C7,C;9C9:<C;7C;9C;c                   #    U R                  5       I Sh  vN   U R                  U5      nSUS   0nUb  X'S'   SnUS   (       d
  US   (       a)  U R                  U R                  Xu5      5      I Sh  vN nO(U R	                  U R                  Xu5      5      I Sh  vN nU R                  US/ 5      n	U R                  X5      $  N NS N,7f)a  
fetches the long short ratio history for a unified market symbol

https://www.bitget.com/api-doc/common/apidata/Margin-Ls-Ratio
https://www.bitget.com/api-doc/common/apidata/Account-Long-Short

:param str symbol: unified symbol of the market to fetch the long short ratio for
:param str [timeframe]: the period for the ratio
: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
:returns dict[]: an array of `long short ratio structures <https://docs.ccxt.com/#/?id=long-short-ratio-structure>`
Nr  rE   r  rT   rU   r  )r  r  'publicMixGetV2MixMarketAccountLongShortr=  +publicMarginGetV2MarginMarketLongShortRatior8  parse_long_short_ratio_history)
r  r  r  r  r  r  r  r  r  r  s
             r  fetch_long_short_ratio_history%bitget.fetch_long_short_ratio_historyt(  s      !!!V$fTl
   )H&>VH-!II$++V]JfggH" "MMdkkZaNjkkH ~~h3224@@S 	" h" ls4   CCAC3C4(CC	)CC	C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S5      S.$ )Nr  r  r  longShortRatiolongShortAccountRatio)r6  r  r  r  r  r  )rG  rP  r  rK  rR  )r  r6  r  r`  r  s        r  parse_long_short_ratiobitget.parse_long_short_ratio(  sk    ##D(3//d;	&&xzJ"Y/"007GI`a
 	
r  reasonurlr  headersbodyc
                    U(       d  g U R                  USS5      n
U R                  S-   U-   nU
S L=(       a    U
S:g  =(       a    U
S:g  nU(       a>  U R                  U R                  S   X5        U R	                  U R                  S   X5        U R                  USS	5      nUS L=(       a    US
:g  nU(       a  U R                  U R                  S   X5        U(       d  U(       a  [        U5      eg )Nerr_msgmsg r  r  r  r  r  err_coder  )r  rE   throw_exactly_matched_exceptionr   throw_broadly_matched_exceptionr+   )r  r  r  r  r  r  r  r  requestHeadersrequestBodymessagefeedbacknonEmptyMessager  nonZeroErrorCodes                  r  handle_errorsbitget.handle_errors(  s    6 $$Xy%@77S=4'#4/_gm_'U^J^001I7]001I7]&&xD	%T1M	W8L001I9_))r  c                 B    U R                  5       U R                  S   -
  $ )Nr  )r  r  )r  s    r  noncebitget.nonce(  s       "T\\2B%CCCr  GETc                    US   S:H  nUS   nSn	SU R                  X5      -   n
X-   nU R                  U R                  S   U   5      U-   nU R                  X@R	                  U5      5      nU(       dG  US:X  aA  [        UR                  5       5      n[        U5      nUS:  a  US-   U R                  U5      -   nU(       Ga6  U R                  5         [        U R                  5       5      nUU-   U-   nUS	:X  a  U R                  U5      nUU-  nO[U(       aT  SU R                  U R                  U5      5      -   nUR                  S
5      S:  a  UR                  S
S5      nUU-  nUU-  nU R!                  U R#                  U5      U R#                  U R$                  5      [&        R(                  S5      nU R+                  U R,                  S5      nU R.                  UUU R0                  US.nUS	:X  a  SUS'   U R3                  U R,                  SSS5      nU(       a:  US:w  a4  US:w  a.  Uc  0 nU R+                  US5      nUS:w  a  US:w  a  US:w  a  SUS'   XXeS.$ )Nr   r   r   z/apir  r   r	  ?POSTz%24$base64r   )z
ACCESS-KEYzACCESS-SIGNzACCESS-TIMESTAMPzACCESS-PASSPHRASEzX-CHANNEL-API-CODEzapplication/jsonzContent-Typer  r  Fr   r   r  r  r  r  r   
PAPTRADING)r  r  r  r  )implode_paramsimplode_hostnamer   r  extract_paramsrC  rE  r:  	urlencodecheck_required_credentialsrO  r	  r6  keysortrN  replacehmacencoder   hashlibsha256rG  r  r   r   r  )r  pathr   r  r  r  r  signedendpointpathPartr  payloadr  queryrE  
keysLengthr  auth
queryInner	signaturer   r  r  s                          r  signbitget.sign(  sG   Q9$q6++D99$##DIIe$4X$>?'I		&"5"5d";<6U?

%DTJA~Ci$.."77++-DJJL)Iv%/Dyy(!$t~~dll66J'K!KJ!u-2%/%7%7s%C
:%CJ&D		$++d"3T[[5Mw~~_ghI%%dllH=F"kk($-%)]]&,G *<'&&t||]IuUD$444C`;`**6=AK.[O5SZeixZx(+%dOOr   )N)NNN)NN)__name__
__module____qualname____firstlineno__r   r  boolr  r  r  r   r  r*   r   r  r  r  r
   r  rO  r   r  r  r   r(   r  floatr   r  dictr   r  r   r   r  r  r   r&  r!   rU  r[  r_  r    r"   rh  r%   r  r  r&   r  r'   r  r  rC  r  r  r   r  r  r  r  r   rF  rJ  r   r   r   rI  rQ  rT  r   r  r  r  r  r  r  r  r  r#  r*  r.  r'  r1  r   rB  rR  rP  r  r  r   r  r  r  r#   r  r$   r  r  r  r   r  r  r  r   r   r  rq  r  r   r  r  intr"  r'  r,  r2  r1  r)   r@  r   rF  rJ  rR  rW  r^  rd  rj  rn  r\  r   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*	  __static_attributes____classcell__)r  s   @r  rA   rA   $   s   f# fP7. .'4 ' 59 %%N ') 5S 5. *, <V <,pT&\ pdlf l\ -/ u: un EG ~@ ~@4P\K] ~@@E E$|J\ EN 04$UYbd :L :LC :Ls :Limnyiz :Lx QU]_ 73 7 7 7# 7do 7r 37TX\eg >PC >Ps >PRU >Plpq|l} >P@K
T K
X K
Q\ K
Z:s : =? #: #:> #:J
h 
R` 
0 @DB ?ZS ?Z ?ZS\ ?ZBM4 M M6 M^ 68 [2 [2F [2z :< 2S 2 24 6:" a17 a1 a1FU Uv U Un <@d[] A= A=S A= A=bfglbm A=F ;= &4c &4AT &4P /1 q[ qf	
f 	

 
4 
. ?CQUdhqs bH bH bH3 bH^a bHx|  ~B  yC bHH *, d( d(L)H )2I) I)V: :*H Hv H HT
 XZ fc f f, mqy{ b. b.I b.Y b.X] b.fi b.H sw  @B b,s b,) b,9 b,^c b,lo b,H os{} n,3 n,i n,y n,Z_ n,hk n,` JL ,/d<.@ ,/\ FH _/$|*< _/B fjx|  FH }.3 }. }.9 }.I }._b }.ru }.~ 9=R U/S U/# U/n :>b /3 /B AER P1tCy P1# P1d 59 r/c r/h 8<B e/C e/ e/R 59tZ^gi z=c z= z=TW z=nrsxny z=x 7;\`ik : :3 :VY :ptuzp{ :8 9=4^bkm <# <S <X[ <8 DHVZimvx a?S a?PS a?cf a?F	 HLZ^mqz| t? t?TW t?gj t?l .2SW`b d?s d?# d?S d?gklwgx d?L:t :x :; :x+3Z 37TX\eg R=C R=s R=RU R=lpqvlw R=h 8: f23 f2P 8<B tPW tP4PX> tPlVt VV Vp >BPTcgpr YYs YY# YY]` YYv <> U8s U8+ U8n <@ P7 P7| P7d @DB ?W ?S_ ?V
6 V
[ V
p 9=4^bkm >J# >JS >JX[ >Jrv  xF  sG >J@
f 
4OS OX[ Ogklzg{ O LN  Rd 8
d 
F 
N` 
4 FH Q# Qu QL^ Q$ CE Ns NE NI[ N  8: 113 11h 11f

t 

V 

x 

 ?C2 @3 @ @D DHPR + +S +Z CGr 2d 2C 2h =? ?6 ?6B$F $L 154VZce 7B# 7BS 7BPS 7Bjno|j} 7Br ac .33 .3 .3C .3TW .3gt .3`+
t +
x +
= +
Z:C :C :1 1f BFb *Ew *EX JL 6c 65 6B Z\ #>3 #>c #>5 #>J RT $># $>S $>L BD  6S  6D3
 3
 3
j 9=4^bkm dK# dKS dKX[ dKrv  xC  sD dKL.V .` DF =>s =>J\ =>~2
t 2
V 2
Oa 2
h ?A D8# D8_ D8L'
 '
R 7;$]apt} aQ aQC aQWZ aQjm aQ  EI  JX  EY aQF+
$ +
 +
. +
Z CGr C23 C2i C2V[ C2J 02 ;=d8n ;=z ;= 14c 14 14f
D 
* 
 @DRVeirt gCW gCC gC_b gCy}  G  zH gCR SW_a (E# (Es (EC (Efp (ET ]aik 0=S 0=C 0= 0=VY 0=pz 0=d =Atbfoq 5Zc 5Z 5Z\_ 5Zvz  |F  wG 5Zn4
4 4
x 4
\d 4
pz 4
l 57 <: <| @B <63 <6k <6| BFX\ko  C  LN 7A3 7ARU 7Aeh 7Ax{ 7A  SW  Xf  Sg 7Ar

4 

 

> 

)# )s ) )c )TX )`c )VD  b$T /P /Pr  rA   )H ccxt.async_support.base.exchanger   ccxt.abstract.bitgetr   r@  r	  r6  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)   typingr*   ccxt.base.errorsr+   r,   r-   r.   r/   r0   r1   r2   r3   r4   r5   r6   r7   r8   r9   r:   r;   r<   r=   ccxt.base.decimal_to_precisionr>   ccxt.base.preciser?   rA   r,	  r  r  <module>r>	     s    6 ,    T  T  T  T  T  T  T  T  T  T  * 0 - - . ' & . + ) * ) + . 1 * ) + * 4 %rcPX{ rcPr  