
    E#i                        S SK Jr  S SKJr  S SKrS SKrS SKJrJrJ	r	J
r
JrJrJrJrJrJrJrJrJrJrJrJrJrJrJrJrJrJrJrJrJrJ r J!r!J"r"J#r#J$r$J%r%J&r&J'r'J(r(J)r)J*r*J+r+  S SK,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KBJCrC  S SKDJErE   " S S\\5      rFg)    )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    E/home/james-whalen/.local/lib/python3.13/site-packages/ccxt/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                 n    U R                  U5      nU R                  US0 5      nU R                  US5      $ )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
data
serverTime)publicCommonGetV2PublicTime
safe_valuesafe_integer)r  r  responser  s       r  
fetch_timebitget.fetch_timeB  s;     33F; x4  |44r  c                     U R                   S   (       a  U R                  5         SnU R                  USSS5      u  p!U(       a  U R                  U5      $ U R	                  U5      $ )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_marketsY  s`     <<12%%'33FNESXY))&11--f55r  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   U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 R-                  U R#                  US5      5      5      n!U R+                  U R-                  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 R/                  US5      n%U R1                  U%5      n&U&R3                  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 R/                  US"5      n3U R/                  US#5      n4U R#                  US$5      n5U R#                  US%5      n6[5        U55      n7[7        U7R8                  U35      U7l        U7R;                  5         [=        U75      n8U R+                  U85      n![5        U65      n9[7        U9R8                  U45      U9l        U9R;                  5         [=        U95      n:U R+                  U:5      n"S
S
S.n(U R?                  US&S'5      n;S n<U;b  U;S(:H  =(       d    U;S):H  n<S n=US*:X  a  U RA                  US+5      n=U (       a  S!OS n>UR                  U RC                  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 RA                  US95      U RA                  US:5      U>U%U&S S U"U!S;.U RA                  US<5      U RA                  US=5      S>.U RE                  US?S@5      U RA                  USA5      S>.S S S>.U=S S>.SB.U R/                  USC5      USD.E5      5        GM     U$ )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   	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_marketso  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+,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 (\ r  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;     U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
$ )@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;  publicUtaGetV3MarketInstrumentsr7  r8  rD  rE  rF  r  rI  rJ  r  rH  rO  rN  )3r  r  rV  rS  rU  reqrX  rY  rZ  r  r]  r  r  r^  r  r  r  r  r  r  r  r  rT   rR   rU   r  r  r_  r  r  r/  r0  r  r  r`  isUtaMarginisolatedBaseisolatedQuoter  maxCrossLeverager  rc  rd  re  rf  rg  rh  ri  r  r  r.  s3                                                      r  r  bitget.fetch_uta_marketsa  s   Kq#h-(A++fHK' C OOD@@EF	 )
 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 r  c                 .   U R                  U5      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$ )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
r  r  r   coinchainsNF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:  rE  rF  network_id_to_codeupperrN  r  rH  rG  safe_currency_structure)r  r  r  r]  r  r  rU  entryrE   r  r  r  r   r  chainsLengthrW  r  	networkIdr  r  r  r  isFiats                          r  fetch_currenciesbitget.fetch_currenciesO	  sy    66v>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 r  r  c                    U R                  5         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(       a9  US:X  a  Ub  SnUS   US	'   XtS
'   U R                  U R                  XB5      5      nGOUS   (       d
  US   (       a-  XtS'   US   US	'   U R                  U R                  XB5      5      nOUS:X  a)  US   US	'   U R                  U R                  XB5      5      nOUS:X  ay  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      nO[        U R                  S-   US	   -   5      eU R!                  US/ 5      nU R#                  X5      $ )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(privateMarginGetV2MarginIsolatedTierDatarE  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<<T[[=YZHVn&"2%0M" &tGHEEdkkRYFbcH:% &tGHDDT[[QXEabH7"##FF3D|'2h(hiiYYvv.F}}T*H&tnGFOCCDKKPWD`aHTWW'ddgmnvgwwxxV 626//??r  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:  rP  safe_number_nr  rE  r;  safe_integer_2safe_symbolrF  rN  )r  r6  r  tiersr  rU  itemminimumNotionalr  marginCurrency
currencyIdr^  s               r  r  "bitget.parse_market_leverage_tiersF
  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         SnU R                  USS5      u  pTU(       a  U R                  SSX#USSSS5	      $ 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      nU R                  US/ 5      n	U R                  U	SX#5      $ )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>`
Fr   paginateN
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
  s    	88R\]33OT5Y_amo{  ~B  DG  H  H=%%'*4E((*
 }}T*H&tnGFO$G229gN@@WA]^0 ..62>&&eKKr  r!  addresstagc                 `   U R                  U5        SnU R                  U5      u  peUc  [        U R                  S-   5      eU R	                  5         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      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$ )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  r@  )r  r  r!  r  r  r  networkCoder  r  r  r  r  r]  withdrawOptionsr  s                  r  r   bitget.withdraw
  sL    	7#"AA&I#DGG.Z$Z[[==&++K8	TN..t[I&
 ? EN==dkk'>Z[ x4''7%v//$,,
BG"&..B[]a"b"!%:%85M '9"); +9r  c                    U R                  5         SnU R                  USS5      u  pTU(       a  U R                  SSX#USSSS5	      $ 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      nU R                  US/ 5      n	U R                  XX#5      $ )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>`
Fr   r  Nr  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  s#    	88ASU_`334Fe\bdpr~  AE  GJ  K  K}}T*H=%%'*4E((*
 &tnGFO229gN$GCCDKKPWD`a6 ..62>&&%OOr  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  )
rE  rF  r  r?   
string_absr  
string_subrI  r  parse_transaction_status)r  r  r  r  r  r  r  r  r  feeCostStringfeeCostAbsStringr  rq  s                r  r  bitget.parse_transactionB  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rE  r  r  statusess      r  r  bitget.parse_transaction_status  s-     '#+
 &99r  c                 2   U R                  5         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      nU R                  US0 5      nU R                  Xt5      $ )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@@WA]^ ~~h3))$99r  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  )rE  rF  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                 V   U R                  5         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      nOOUS	   (       a!  U R                  U R                  XS5      5      nO$XeS
'   U R                  U R                  XS5      5      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      $ )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
r  rE   Nr  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  s2    	V$fTl
 $G"AA&Q33F<LeUZ["-J99$++g:VWHF^>>t{{7?[\H%0M"==dkk'>Z[H4 x4#&#&%%dD1	$$T(+;YQXYYr  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)rA  open24hopenPrice24hcloser  previousClosechange
percentageaverage
baseVolume	volume24hquoteVolumeturnover24h
indexPrice)rI  rK  rM  r+  r6  )	rE  r  safe_integer_omit_zeror?   
string_mulsafe_tickerr  rI  safe_string_n)r  r&  r  r^  rD  r  rF  r  r+  
marketTyperG  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                    U R                  5         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      nOOUS   (       a!  U R                  U R                  XB5      5      nO$XTS	'   U R                  U R                  XB5      5      nU R                  US
/ 5      nU R                  US   U5      $ )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>`
r  rE   Nr   r   Fr  rR   r  r  r   )
r  r  r  r  publicUtaGetV3MarketTickersr=   publicSpotGetV2SpotMarketTickerspublicMixGetV2MixMarketTickerr8  rS  )	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77G8TUHF^<<T[[=YZH%0M"99$++g:VWHx ~~h3  a&11r  c                 \   U R                  5         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      nU R                  US/ 5      nU R                  US   U5      $ )	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>`
r  rE   NrR   z3 fetchMarkPrice() is not supported for spot marketsr  r  r   )	r  r  r6   rE   r  "publicMixGetV2MixMarketSymbolPricer=  r8  rS  )r  r  r  r  r  r  r  r  s           r  fetch_mark_pricebitget.fetch_mark_priceC  s     	V$fTl
 &>tww)^^__K"&"E"Ef"UK%0M">>t{{7?[\H~~h3  a&11r  symbolsc                    U R                  5         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
(       aA  [        U5      nUb  US:X  a  US   US	'   XS
'   U R                  U R                  Xb5      5      nONUS:X  a$  Uc!  U R                  U R                  Xb5      5      nO$XS'   U R                  U R                  Xb5      5      nU R                  US/ 5      nU R                  X5      $ )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_paramsrE  r  r  r:  rV  r=  rW  publicMixGetV2MixMarketTickersr8  parse_tickers)r  r_  r  r  r  r  r  r  passedSubTyper  r   symbolsLengthr  s                r  fetch_tickersbitget.fetch_tickers]  sZ    	__Wa0F[[(F99.&Y ((;"AA&Q33FNESXYLM#-1*<$*4L!"-J77G8TUHV^ 5<<T[[=YZH%0M"::4;;w;WXHj ~~h3!!$00r  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)rI  r  execQty)rK  r!  	execValue)r6  rE   orderr  rq  r  takerOrMakerr  r!  r+  r  r  r  )rE  r  safe_integer_nr  rF  r  r?   
string_neg
safe_tradesafe_string_lowerrQ  rI  )r  rh  r  r^  r  r  r  rk  rl  r  isFeeStructurefeeStructurecurrencyCoder  ro  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         SnU R                  USS5      u  pTU(       a  U R                  SXX4SS5      $ 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(       aG  US:X  a  SnU R                  SU5      u  pUb  SnXS'   U R                  U R                  Xt5      5      n
GOuU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  a<  U R                  SXt5      u  ptUb  X'S'   U R                  U R                  Xt5      5      n
OUS:X  a   U R                  U R                  Xt5      5      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  a<  U R                  SXt5      u  ptUb  X'S'   U R!                  U R                  Xt5      5      n
O&US:X  a   U R#                  U R                  Xt5      5      n
U R%                  U
S/ 5      nU R'                  UXbU5      $ )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>`
Fr   r  r  r  rE   Nr   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=  rE  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  s   & 	88PZ[33M6RWamo{||V$fTl
 33FM5RWX#&uc? 
##&ud#3 #( //$,,rB"AA&Qf$!
%)%G%GW]%^"
)"*K"-J55dkk'6RSHF^//'62>K $ 0 0hHo p))&(<MNJYYvx0FDD"&":":9g"V$+0K(EEdkkRYFbc??>>t{{7?[\//'62>K $ 0 0hHm n))&(<MNJYYvx0F%0M"BB"&":":9g"V$+0K(CCDKKPWD`a==<<T[[=YZn ~~h3  ve<<r  c                 B   U R                  5         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      nU R                  US	0 5      nU R                  Xs5      $ )
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>`
r  rE   Nr   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#99$++g:VW x4%%d33r  c                    U R                  5         SnSnSnU R                  SU5      u  p1U R                  SSU5      u  pAUS:X  aS  U R                  USS5      nU R	                  US5      nUc  U(       a  U R                  U5      nOhU R                  U5      nOVUS:X  d  US:X  a,  SnU R                  SU5      u  paXaS'   U R                  U5      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$ )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  ra  r@  r  r?  r>  r  r<  r6   rE   r  r9  r:  rE  r  r  r  )r  r  r  r  rR  rS   r  r  r]  rU  r  r^  r  r  r  s                  r  fetch_trading_feesbitget.fetch_trading_feesB  s    	

!??@RTZ[
!??@RTXZ`a
^^FHe<FYYvx0F&6AA&I@@HF"
h(>K"&"E"EdF"SK$/=!<<VDHtww)==
JYVWWP x4q#d)$AGE''x8H%%hdJGF[[(F((7C 6N % r  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   rG  	tierBased)rE  r  rN  )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   )r@  r  rN  )r  ohlcvr  r  volumeIndexs        r  parse_ohlcvbitget.parse_ohlcv  s     ..3"aeQ'UA&UA&UA&UA&U0
 	
r  r   	timeframec           	      L	   U R                  5         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      $ 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(       aA  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      n%GO$US   (       aW  U#(       a!  U R%                  U R#                  X5      5      n%OU(       d  SUS'   SnU R'                  U R#                  X5      5      n%OU&US#'   U R#                  X5      n(U#(       d>  U'S:X  d  U'S :X  a2  U(       d  SU(S'   SnU R)                  U R#                  S$U'0U(5      5      n%OhU'S:X  a  U R+                  U(5      n%OPU'S :X  a  U R-                  U(5      n%O8U#(       a  U R/                  U(5      n%OU(       d  SU(S'   SnU R)                  U(5      n%U%S%:X  a  / $ U R1                  U%S&U%5      n)U R3                  U)XX45      $ )'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
r  r  r   useHistoryEndpointFuseHistoryEndpointForPaginationTr   r  r  rE   Nr   r   intervalrR   rT   granularity \&untilr  r  r   r  r  r  r  r  r  MARKr  r  INDEXr  r  	kLineType r  )r  r@  r  "fetch_paginated_call_deterministicr  r  rE  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  rR  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  sV   2 	$(!%("!^^F4H%P*...Abdh*i'88zZ?^!;d}::<X]jp  F  F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77G8TUHF^'GGT[Hde#'+GG$ E@@WA]^%0GM"{{73H+f1D	U\H\#(,HW% E  >>t{{KYbKcem?nof$II(Sg%JJ8T+#II(SH',0) $#BB8LHr>I~~h9  v%GGr  c                 l   U R                  5         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(       aW  U R	                  U R                  X!5      5      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  a;  Sn	U R                  SU5      u  pXS	'   U R                  U R                  X!5      5      nOUS
:X  a!  U R                  U R                  X!5      5      nOlUS:X  a!  U R                  U R                  X!5      5      nOEUS:X  a!  U R                  U R                  X!5      5      nO[        U R                  S-   U-   S-   5      eU R!                  US/ 5      n
U R#                  U
5      $ )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  ra  r  privateUtaGetV3AccountAssetsr=  r7  r8  parse_uta_balancer  !privateMixGetV2MixAccountAccounts-privateMarginGetV2MarginIsolatedAccountAssets,privateMarginGetV2MarginCrossedAccountAssets!privateSpotGetV2SpotAccountAssetsr6   rE   r  parse_balance)r  r  r  rR  r  r  r   rX  r  r  r  s              r  fetch_balancebitget.fetch_balance{  s   " 	

33FNESXY!??PTV\]
!??PVW
88W9UVHnnXvr:G^^GXr:F))&11F"
h(>K"&"E"EdF"SK%0M"==dkk'>Z[H:%II$++V]JfgH. 7"HHU\IefH, 6!==dkk'>Z[Htww)LLzY\gghhZ x4!!$''r  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:  accountrE  rF  safe_balance)r  r  r]  rU  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  rF  rE  r?   
string_addr  )r  r  r]  rU  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newrA  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  rx  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  ctimerj  r  updatedTime)r  stateorderStatus
planStatusr  r  )r+  r  rk  r  r   feeCoinCodern  forcer  	POST_ONLYTr  
reduceOnlyNOF	basePricert  )r  executePriceslLimitPricetpLimitPricebaseSizer  qtyrI  
cumExecQtyrq  rl  
hedge_modebuysellrr  r  r6  rE   r  r  r  lastTradeTimestamplastUpdateTimestampr  r!  r+  rK  	quoteSizerH  r  	remainingr  )presetStopSurplusPricestopSurplusTriggerPrice
takeProfit)presetStopLossPricestopLossTriggerPricestopLoss)postOnlyr  r  r  r  r  r  trades)rE  
safe_orderr  safe_marketrz  r  rQ  r  r?   r{  r  r7  jsonloadsrA  valuesr9  r:  rF  safe_string_upper_2rI  rN  r  r
  )$r  rx  r  errorMessager  isContractOrderrR  r^  r  updateTimestamp	rawStatusr  r  rk  r   	feeResultutaFeeparsedFeeDetail	feeValues	feeObjectrU  feeValuer0  r  r  reduceOnlyRawr  rH  r  r  r  r   rq  rl  rr  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         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      $ )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>`
rR   z9 createMarketBuyOrderWithCost() supports spot orders onlyr  Fr  r$  N)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  sm     	V$f~tww)ddee/
   5$dkkRUF^__r  r  rq  r  c                    U R                  5         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(       a>  U R                  XX4XV5      nU(       a  U R                  U5      nOU R                  U5      nOU R                  XX4XV5      nUS   (       a[  U(       a  U R                  U5      nOU	S:X  a  U R                  U5      nOtU	S:X  a  U R                  U5      nO\U R                  U5      nOJU(       d  U(       a  U R                  U5      nO*U(       a  U R!                  U5      nOU R#                  U5      nU R%                  US0 5      nU R'                  UU5      $ )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>`
rd   r   	stopPricer  r  r  trailingPercentcallbackRatioNr   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  rD  )r  r  r  rq  r!  r  r  r  marginParamsr  r  r.  takeProfitTriggerPricerL  isTrailingPercentOrderisTriggerOrderisStopLossTriggerOrderisTakeProfitTriggerOrderisStopLossOrTakeProfitTriggerr  r   r  r  s                          r  rG  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,GGP??H//dEZGf~!#LLWUH:-#OOPWXH7*#NNwWH#HHQH!%;#JJ7SH2#JJ7SH#FFwOH ~~h3f--r  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!  rq  r  r  r  r  r/  r,  slTriggerByr  r  slOrderTyper  r  tpTriggerByr  tpOrderTyper  rK  r  rr  r  	post_onlyr  r  gtcr  fokr  iocr  Fr  r%  longshortr  yesr$  )r/  r,  r0  r  r  )r  r  r  amount_to_precisionr  r  rN  r  rE  price_to_precisionrP  handle_post_onlysafe_string_upperr  r@  handle_param_boolr=  )$r  r  r  rq  r!  r  r  r  r  r  r  r  r.  r[  r/  r,  
isStopLossisTakeProfitisStopLossTriggerisTakeProfitTriggerr`  slTypetpTypeslTriggerPricer  tpTriggerPricer  isMarketOrderexchangeSpecificTifParamr0  r  r  r  r  reduceOnlyPosSider  s$                                       r  rO  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  rr  r  F
oneWayModer  rK  r  r  r  r/  r,  trailingTriggerPricerL  rM  r   zk createOrder() params can only contain one of triggerPrice, stopLossPrice, takeProfitPrice, trailingPercentr  r  r  triggerType
mark_pricer  r  r  r  r  rg  r  r  r  r  )rK  r  r  r  r/  r,  r0  r  r  rL  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  r.  stopLossExecutePricer  stopLossTriggerTyper+  stopSurplusExecutePricestopSurplusTriggerTypezI createOrder() bitget stopLoss or takeProfit orders must be market ordersr%  rk  rl  holdSider$  pos_loss
pos_profitr-  r*  r  crossedr  r  rw  Close	tradeSideOpenrq  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  ra  r  rr  rN  r  rE  number_to_stringr  r  r+   rE   ro  r@  rp  rq  r  r  rn  r  r0   r/   r4   r  rN  cost_to_precisionr?   rO  r6   r=  )4r  r  r  rq  r!  r  r  r  rR  r  r  r  r  r{  r  r.  r[  r/  r,  r]  r^  r_  rs  rt  r`  isStopLossOrTakeProfitr  rL  r\  r  r  r  r|  r0  r  r  r  ry  slPricerw  rz  tpPricerx  marginModeRequestrequestSidequantityr  r  r+  rq  ro  quoteAmounts4                                                       r  rR  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         / 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      nU R                  US/ 5      nU R                  UU5      $ )Nr   r  ; createOrders() requires all orders to have the same symbolr  rq  r!  r  r  re   S createOrders() requires all orders to have the same margin mode(isolated or cross)r  )r  r9  r:  rE  r0   rE   r  r  rO  r;  r  privateUtaPostV3TradePlaceBatchr8  parse_orders)r  r  r  ordersRequestsr  r  rU  rawOrderr^  r  rq  r!  r  orderParamsmarginResultcurrentMarginModeorderRequestr  r  r  s                       r  create_uta_ordersbitget.create_uta_ordersr  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$77G ~~h3  v..r  c           	         U R                  5         SnU R                  USSS5      u  p2U(       a  U R                  X5      $ / 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   (       aJ  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      nOAUS:X  a  U R                  U5      nO)US:X  a  U R!                  U5      nOU R#                  U5      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      $ )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  rq  r!  r  r  r  rE   )r  	orderListrT   rU   r  r  r  r  r  r  r  r  failureListsuccessList)r  r  r  r9  r:  rE  r0   rE   r  r  rR  r;  r  r  'privateMixPostV2MixOrderBatchPlaceOrder0privateMarginPostV2MarginIsolatedBatchPlaceOrder/privateMarginPostV2MarginCrossedBatchPlaceOrder%privateSpotPostV2SpotTradeBatchOrdersrD  r  )r  r  r  r   r  r  r  rU  r  r^  r  rq  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))&99
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"CCGLH:%LLWUH7"KKGTHAA'JH0 x4//$r:OOD-<	  G4  v..r  rE   c                    U R                  5         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      nGO	Ub  U R                  X&5      U	S'   U R#                  U R!                  X5      5      nGOUS   (       Gaq  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      nGO~US(   U	S)'   U R1                  U R!                  X5      5      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(       a^  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      nGOmU(       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      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      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      nU RC                  USA0 5      n)U RE                  U)U5      $ )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>`
r  r  Nr  r  rK  r  r  r  r/  r,  r  rL  newCallbackRatior   zi editOrder() params can only contain one of triggerPrice, stopLossPrice, takeProfitPrice, trailingPercent)	rK  r  r  r  r/  r,  r  r  rL  rq   r   Fr!  rc  r  r  rd  r  re  r  rf  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  rr  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  rN  r  rE  r  r  r+   rE   r  r  rn  ro  (privateUtaPostV3TradeModifyStrategyOrderr=   privateUtaPostV3TradeModifyOrderr@  r  r4   r?   rO  )privateSpotPostV2SpotTradeModifyPlanOrder,privateSpotPostV2SpotTradeCancelReplaceOrderr6   r0   'privateMixPostV2MixOrderModifyPlanOrder'privateMixPostV2MixOrderModifyTpslOrderrP  rN  uuid#privateMixPostV2MixOrderModifyOrderr7  rD  )*r  rE   r  r  rq  r!  r  r  r  r  r  r{  r  r]  r  isStopLossOrderr  isTakeProfitOrderr/  r,  rs  rt  r  rL  r\  r  r  r   rw  rx  r+  r  rq  ro  	finalCostry  r  rz  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HHU\Ief$'+'>'>v'MGG$@@WA]^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 'II$++V]Jfg$*4L!LLT[[Y`Mij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-..=*+GGT[Hde"o(.z(:%"&":":6"J$.2.E.Ef.TGN+".2.E.Ef.\GN+&.2.E.Efo.^GN+GGT[Hde-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GGT[Hde*.))+'#'#5#5fnN`by#z 6+=>*:'%)%6%6xQ\%]N8<8O8OPVXf8gG45%)%6%6z>S^%_N;?;R;RSY[i;jG78CCDKKPWD`a ~~h3f--r  c                 $   Uc  [        U R                  S-   5      eU R                  5         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
(       aK  U	(       a"  U R                  U R                  Xs5      5      nGOU R                  U R                  Xs5      5      nGO~US   (       d
  US   (       a  SnU R                  XC5      u  nnUUS'   U(       a:  U R                  USS5      nUUS'   U R!                  U R                  Xs5      5      nGOU	(       a!  U R!                  U R                  Xs5      5      nOU R#                  U R                  Xs5      5      nOUS   (       a  UbN  US:X  a!  U R%                  U R                  Xs5      5      nOUS:X  a   U R'                  U R                  Xs5      5      nOjU	(       a!  U R)                  U R                  Xs5      5      nOBU R+                  U R                  Xs5      5      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      $ )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  rN  r  r  r  r;  (privateUtaPostV3TradeCancelStrategyOrderr=   privateUtaPostV3TradeCancelOrderr  rE  'privateMixPostV2MixOrderCancelPlanOrder#privateMixPostV2MixOrderCancelOrder,privateMarginPostV2MarginIsolatedCancelOrder+privateMarginPostV2MarginCrossedCancelOrder)privateSpotPostV2SpotTradeCancelPlanOrder%privateSpotPostV2SpotTradeCancelOrderr6   rD  )r  rE   r  r  r  r  r  r  r  r  r   isPlanOrder
isContractisContractTriggerEndpointr  r  r  r  r  r  rx  r  s                         r  cancel_orderbitget.cancel_order  sg   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$%'	"HHU\Ief@@WA]^Vn&"2K"&"E"Ef"UK%0GM"++FJM&.
#GGT[HdeGGT[HdeCCDKKPWD`aF^%+#PPQUQ\Q\]dQmnH7*#OOPTP[P[\cPlmH#MMdkkZaNjkH#II$++V]JfgHtww)KKfU[n\_hhiif x4$mR@IaLEw v..r  c                    Uc  [        U R                  S-   5      eU R                  5         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      n
U R                  U
S/ 5      nU R                  X5      $ )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  requestListrU  individualIdrx  r  r  s               r  cancel_uta_ordersbitget.cancel_uta_ordersW  s    >#DGG.Z$Z[[V$"AA&Qq#c(#A6L' ,'E
 u% $ 88E ~~h3  ..r  r  c                     Uc  [        U R                  S-   5      eU R                  5         U R                  U5      nSnU R	                  USSS5      u  pSU(       a  U R                  XU5      $ 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   (       al  UbH  US:X  a!  U R                  U R                  X5      5      nOU R                  U R                  X5      5      nOU R                  U R                  X5      5      nOaSnU R!                  XC5      u  pXS'   U(       a!  U R#                  U R                  X5      5      nO U R%                  U R                  X5      5      nU R'                  US0 5      nU R)                  US/ 5      nU R+                  UU5      $ )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  rN  r  r9  r:  r;  0privateMarginPostV2MarginCrossedBatchCancelOrderr=  1privateMarginPostV2MarginIsolatedBatchCancelOrder*privateSpotPostV2SpotTradeBatchCancelOrderr  r  )privateMixPostV2MixOrderBatchCancelOrdersr  r8  r  )r  r  r  r  r  r   r  r  r  rU  r  r  r  r  r  r  r  s                    r  cancel_ordersbitget.cancel_ordersx  s   & >#DGG.Z$Z[[V$33FNESXY))#v>>
!??PVW
##FFI>6FI#67q#c(#A6L<G w' $ fTl
 &>z1#.K %0M"&>%(#TTUYU`U`ahUqrH#UUVZVaVabiVrsHJJ4;;W^KghK"&"E"Ef"UK%0M"GGT[HdeII$++V]Jfg" x4mR8  00r  c           	         Uc  [        U R                  S-   5      eU R                  5         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	(       a1  US
:X  a  Ub  SnXVS'   U R                  U R                  Xb5      5      nGO/US   (       a  Ub  [        U R                  S-   5      eU(       a)  SUS   /0n
U R                  U R                  X5      5      nO U R                  U R                  Xb5      5      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      nO U R+                  U R                  Xb5      5      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      $ )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  rA  r  r  )r/   rE   r  r  r  r  safe_bool_2r  r  &privateUtaPostV3TradeCancelSymbolOrderr=  r6   .privateSpotPostV2SpotTradeBatchCancelPlanOrder+privateSpotPostV2SpotTradeCancelSymbolOrderr  r7  rE  r2  r  rI  r  r  safe_list_nsafe_list_2rD  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BB4;;wC_`H  F^%"477  .F  $F  G  G$vd|n)K  $RRSWS^S^_jSstH#OOPTP[P[\cPlmH !--hF	#~~h?++L(COO ("&"2"28T4"P%.$(LL$;	%   &1M"GGT[HdeII$++V]Jfg ~~h/%%d,QR
&&tYF")@,,ZEL%L  ..r  c                 t   Uc  [        U R                  S-   5      eU R                  5         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      nOUS	   (       a!  U R                  U R                  XS5      5      nOwUS
   (       d
  US   (       aB  US   US'   Sn	U R                  XC5      u  pXS'   U R                  U R                  XS5      5      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      $ )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   
isinstancerM  r4  r5  r7  rA  rD  r8  r:  r5   )r  rE   r  r  r  r  r  r  r   r  r  dataListdataListLengthfirsts                 r  fetch_orderbitget.fetch_order>  s$    >#DGG.X$XYYV$
 **6?KP$YYv'89F#0K !#I33FL%QVW99$++g:VWHF^>>t{{7?[\HF^vh/ &tGHK"&"E"Ef"UK%0M"99$++g:VWH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/..r  c           	      	   U R                  5         SnSn0 nSnU R                  SU5      u  pSn	U R                  USSS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(       a6  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      $ 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	(       a[  US:X  a  Ub  SnUUS'   U(       a"  U R                  U R                  Xt5      5      nGOU R                  U R                  Xt5      5      nGO`US:X  a  Ubi  Uc  U R!                  5       S-
  nX'S'   US:X  a"  U R#                  U R                  Xt5      5      nGOUS:X  a   U R%                  U R                  Xt5      5      nOU(       a!  U R'                  U R                  Xt5      5      nOU R)                  U R                  Xt5      5      nOUUS '   U(       a9  U R                  USS!5      nUUS'   U R+                  U R                  Xt5      5      nO`U(       a9  U R                  USS"5      nUUS'   U R+                  U R                  Xt5      5      nO U R-                  U R                  Xt5      5      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      $ )'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  rA  r  entrustedList)r  r  r  r  r  r  rE  r  r@  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  rR  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!()
334EvV[es  A  A>>&*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JJ4;;W^KghBB4;;wC_`V^%= --/*<E+0K(+#NNt{{[bOklH7*#MMdkkZaNjkH#MMdkkZaNjkH#KKDKKX_LhiH%0GM"++FJM&.
#HHU\Ief++FJN&.
#HHU\IefDDT[[QXEab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<<r  c                 l    U R                  5         U R                  XX45      nU R                  USS5      $ )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>`
r  r  r   fetch_canceled_and_closed_orders	filter_byr  r  r  r  r  r  s         r  fetch_closed_ordersbitget.fetch_closed_ordersc  s5    0 	66veT~~fh99r  c                 l    U R                  5         U R                  XX45      nU R                  USS5      $ )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>`
r  r  r$  r'  s         r  fetch_canceled_ordersbitget.fetch_canceled_orders  s5    0 	66veT~~fh
;;r  c           	          SnU R                  USSS5      u  pTU(       a  U R                  XX45      $ U R                  5         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      $ 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  a  U	b\  Uc	  US-
  nX'S'   U	S:X  a"  U R                  U R                  Xt5      5      nGOU	S:X  a   U R                  U R                  Xt5      5      nGOuU(       aw  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      nOU R)                  U R                  Xt5      5      nOSnU R+                  Xd5      u  nnUUS'   U R-                  US5      SLnU(       a9  U R-                  USS5      nUUS'   U R/                  U R                  Xt5      5      nOgU(       d  U(       a9  U R-                  USS5      nUUS'   U R/                  U R                  Xt5      5      nO U R1                  U R                  Xt5      5      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      $ )#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  ra  r  r  r@  r  r  r  r  r  -privateMarginGetV2MarginIsolatedHistoryOrdersr=  ,privateMarginGetV2MarginCrossedHistoryOrdersr/   rE   rz  )privateSpotGetV2SpotTradeHistoryPlanOrder&privateSpotGetV2SpotTradeHistoryOrdersr  rE  (privateMixGetV2MixOrderOrdersPlanHistory$privateMixGetV2MixOrderOrdersHistoryr  r  r
  rM  r4  r5  r8  )r  r  r  r  r  r   r  r  rR  r  r  r  r  r  r  r  r  r  r  r  r  r  r  s                          r  r%  'bitget.fetch_canceled_and_closed_orders  sf   4 33F<Z\achi<<VEZZ[[(F &tGH
!??@^`fo

!??@^`fg
88A_akl!NV#)%,N!(334RTZch  sA  CO  P  P>>&*5""669=6#BC229gN#(K $G& jH&<*BX ..v{OTMYYv7F('4$!%=*,E+0K(+#QQRVR]R]^eRnoH7*#PPQUQ\Q\]dQmnH>+DGG6r,rss--fy'6JK6G95=*,E+0K(?),GI&II$++V]JfgFFt{{SZGcdK"&"E"Ef"UK%0GM""..vzB$NO++FJM&.
#HHU\IefO++FJN&.
#HHU\IefDDT[[QXEabf x4&7(({B)OQW`eff ,3 $$T__T?B%OQW`effh$$zz(+H&"5  >>r  c           	         U R                  5         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      $ 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      n
O U R                  U R                  X5      5      n
U R                  U
S0 5      nU R                  US/ 5      nU R                  XX#5      $ )Nr  rw   r  r  Fr  r  r  r  r  r  r  r  rA  )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  r.  +bitget.fetch_uta_canceled_and_closed_orders  s   [[(F"AA&Q& J!%!C!CDbdj!kJ%&
 88A_akl334RTZchrz  }E  F  F229gN#(K $G""669=6FI#67EEdkkRYFbcH==dkk'>Z[Hh ~~h3fb1  >>r  c           	      D   U R                  5         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      $ 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      nODUb  US	   US'   SnU R                  Xd5      u  pXS'   U R                  U R                  X5      5      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      $ )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>`
r  Nr   Fr  rR   r  r  rE   r  r  r  r  r  r  rT   rU   bills)r  rE  r  r  ra  r  r  r  r   privateSpotGetV2SpotAccountBillsr=  r  privateMixGetV2MixAccountBillr  parse_ledger)r  r  r  r  r  r  r  rR  r  r  r  r  r  r  r  r;  s                   r  fetch_ledgerbitget.fetch_ledger4  s   " 	!!&(368,[[(F
!??v^
88PZ[!NV#!(33M6RWaoq}~~}}T*H&tnGFO229gN#(K $G<<T[[=YZH!$*4L!K"&"E"Ef"UK%0M"99$++g:VWHZ x0& jH&<OOD'26E$$UeCC  >>r  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  )rE  rF  safe_currencyr  rN  rP  r  r  r?   r  findsafe_ledger_entryrI  parse_ledger_type)r  r  r  r  r  r  rI  r  	amountRawr!  rE  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_longrh  
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  rM  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         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(       a:  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      $ SnU(       a!  U R                  U R                  Xt5      5      nOUS   US'   US   (       a  U	bg  Uc  U R                  5       S-
  US'   U	S:X  a!  U R                  U R                  Xt5      5      nOU	S:X  a   U R                  U R                  Xt5      5      nOZU R                  U R                  Xt5      5      nO9SnU R                  Xd5      u  pXS'   U R                  U R                  Xt5      5      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      $ )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  rA  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!()
33OVTYcq~~55dkk'6RSH &tGHf~)}/3/@/@/BZ/O,!Z/#'#M#MdkkZaNj#k#w.#'#L#LT[[Y`Mi#j#BB4;;wC_`H"&*&I&I&&Y#)4&<<T[[=YZH x0NN44E$$UEAAVn!1NN4R8E$$UEAA#NN4"5E$$UEAA  u<<r  c                    U R                  5         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(       aK  XES'   U R	                  U R                  XR5      5      nU R                  US0 5      n	U R                  U	S	/ 5      nO?US
   US'   XES'   U R                  U R                  XR5      5      nU R                  US/ 5      nU R                  US0 5      n
U R                  X5      $ )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  rA  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  s#    	V$"AA&QfTl
 33FOUTYZ"-JBB4;;wC_`HN >>(FB7D^^D&"5F$*:$6GL!%0M"DDT[[QXEabH> ^^Hfb9Fvq"-""511r  c           	         U R                  5         SnU R                  USS5      u  p2U(       a  U R                  SSSSUSS5      $ 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      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      n
O1SnUb  US   U	S'   XS'   U R                  U R                  X5      5      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      $ )!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>`
Fr   r  Nr  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  rA  )r  r  r  r@  rE  r  r  r  r=  r/   rE   r  r  r7  r8  r9  r:  r;  r  market_symbolsfilter_by_array_positions)r  r_  r  r  r  r  r  r  r  r  r  	isHistoryr   r  positionr  r]  rU  s                     r  fetch_positionsbitget.fetch_positions?  s   $ 	88AQS]^334DdDRVX^`giuvv!^^F4H%P@F!::6CSU]  `G  HNF$$Wa0E U+"AA&Q	33F<LeUZ["-JBB4;;wC_`H>>))&,GJ!#J/
.#
.#
/$
/$
0k^6S%+DGG  7G  -G  H  H$.L!%0M"AA$++gB^_HI!$*4L!%0M"EEdkkRYFbcHL )>>(FB7D~~dFB7H~~h;Hq#h-(AMM$--hqk6BC )%%g.--fhOOr  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  rl  holdModer#  Tone_way_modeFr  r  r*  r.  r  openTotalPos)openPriceAvgopenAvgPriceavgPricer  closeTotalPosr+  liquidationPricer   z0.9994ry  rl  r   rk  r   r-  r6  rE   r  
positionIdnotional
entryPriceunrealizedPnlrealizedPnl)pnlcurRealisedPnlcumRealisedPnlrG  	contractsr)  closeAvgPriceclosePriceAvgrq  r  r  utimer  marginRatior  )r  r'  maintenanceMarginmaintenanceMarginPercentage
collateralinitialMargininitialMarginPercentager*  r  r  r  )rE  r3  rz  r  r?   r  r  r  rQ  rO  
string_divr  rN  	omit_zero	string_gtr{  r  safe_positionr  rP  rI  r  )#r  r  r  r^  r  r  r  r  r  r  rawCollateralr  r  rq  r*  contractSizeNumberr.  
baseAmountr  r  openNotionalr  r+  r  r  r  calcTakerFeeRatecalcTakerFeeMultsignedMargin	signedMmpmmrMinusOne	numerator
feeToCloser  rG  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           
         Uc  [        U R                  S-   5      eU R                  5         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(       aR  Ub  X6S'   XvS	'   U R                  U R                  Xd5      5      n	U R                  U	S
0 5      nU R                  US/ 5      n
OqSnU R                  USS5      u  pU(       a  U R                  SXX4SS5      $ Ub  X6S'   XvS'   U R                  U R                  Xd5      5      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      $ )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:  rE  r  r  r;  rN  rI  sort_byfilter_by_symbol_since_limit)r  r  r  r  r  r  r  r  r   r  r]  r  r  ratesrU  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??G@\]H" >>(FB7D^^D,;FH#<<VE^`jkH<<=VX^glv~  AD  E  E &+
#%0M"BB4;;wC_`H ^^Hfb9Fq#f+&AIE''x8H**8V<K++E=BXYILL%#//}E& LL3  ' e[1009I5XXr  c                 f   U R                  5         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      nOiXES	'   SnU R                  USS
S5      u  pUS:X  a!  U R                  U R                  XR5      5      nO&US:X  a   U R                  U R                  XR5      5      nU R                  US/ 5      n	U R                  U	S   U5      $ )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>`
rT   z0 fetchFundingRate() supports swap contracts onlyNr  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(  sH    	V$f~DGG&XXYY"AA&QfTl
 33F<NPUW\]??G@\]H& &1M"F!::6CUW_  bJ  KNFAAFFt{{SZGcd$ ??BB4;;wC_` ~~h3&&tAw77r  c                    U R                  5         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      nO&US:X  a   U R                  U R                  XR5      5      nU R                  U5      nU R                  US/ 5      n	U R                  X5      $ )	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   rb  r   r  r  r  r  )r  r  r  r  r  rb  r=  r  r  r8  parse_funding_rates)
r  r_  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 ::4;;w;WXH??$ BB4;;wC_`H%%g.~~h3''66r  c                 l    U R                  5         U R                  SS0U5      nU R                  X5      $ )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>`
r  r  )r  r=  r  )r  r_  r  s      r  fetch_funding_intervalsbitget.fetch_funding_intervals  s8     	h(PQSYZ''88r  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+  rM  hr6  interestRateestimatedSettlePricer  r  r  fundingTimestampfundingDatetimenextFundingRatenextFundingTimestampnextFundingDatetimepreviousFundingRatepreviousFundingTimestamppreviousFundingDatetimer  )rE  r  r  r  r  rN  rI  )r  r  r  r^  r  r  r  r  r+  rM  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         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      $ 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      n	U R                  U	S0 5      n
U R                  U
S/ 5      nU R                  XX#5      $ )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  rk  )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_history8   sJ    	>#DGG.a$abb88AVXbc334I6Z_ipr~V$f~DGG&[[\\"AA&QTl ,1&	
 229gN#(K $G55dkk'6RS. x4w3++FEIIr  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!  rD  )r6  r  r  r  r  r!  rE   )rE  r  r  rI  rF  rN  )r  r  r  r^  r  r  s         r  parse_funding_historybitget.parse_funding_historyx   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  rk  r  r  )r9  r:  rE  r;  r  r  r  )r  r  r  r  r  r]  rU  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         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      n	U R                  U R                  X5      U R                  U5      US.5      $ )Nr  rE   r  )r  r  r!  r  r  )r!  r  )
r  rE  r  r  rn  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:.;;DKK<XY {{499(K''/N
  	r  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      $ )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  zC reduceMargin() requires a holdSide parameter, either long or shortrL  )r0   rE   rE  r/   r  r  r  r!  r  r  s        r  rn  bitget.reduce_margin   sb     A:TWW'bbcc##FJ7#DGG.s$stt((6JJr  c                     U R                  US5      nUc  [        U R                  S-   5      eU R                  XSU5      $ )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  z@ addMargin() requires a holdSide parameter, either long or shortadd)rE  r/   rE   r  r  s        r  
add_marginbitget.add_margin   sF     ##FJ7#DGG.p$pqq((GGr  c                    U R                  5         U R                  U5      nSnU R                  X25      u  pBUS   US   US.nU R                  U R	                  XR5      5      nU R                  US0 5      nU R                  Xs5      $ )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 ,&

 88W9UV: ~~h3""400r  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)rE  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                    Uc  [        U R                  S-   5      eU R                  5         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(       aO  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      nU$ US   US'   XVS'   U R                  U R                  Xc5      5      nU$ )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_leverage7!  s1    >#DGG.Y$YZZV$"AA&QTl--h7
 33FM5RWXf$!
%)%G%GW]%^"
)"*K$Z0GFO"-J>>t{{7?[\H8 % %+:$6GL!%0M"AA$++gB^_H  r  r  c                 z   Uc  [        U R                  S-   5      eUR                  5       nUS:X  a  SnUS:w  a  US:w  a  [        U R                  S-   5      eU R                  5         U R	                  U5      nSnU R                  XC5      u  pSUS   US   UUS	.nU R                  U R                  Xc5      5      nU$ )
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_modey!  s     >#DGG.[$[\\%%'
 "J*$:+B#DGG.u$uvvV$"AA&QTl ,$&	
 ??G@\] r  r  c                 t   U R                  5         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      n	U	$ XES'   XuS	'   U R                  U R                  XS5      5      n	U	$ )
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
r#  r  Nr   r   Fr  rl  r  )r  r  r  r  "privateUtaPostV3AccountSetHoldModer=  )privateMixPostV2MixAccountSetPositionMode)
r  r  r  r  rl  r  r  r  r   r  s
             r  set_position_modebitget.set_position_mode!  s     	"(,n[[(F"AA&Q33F<MuV[\")J>>t{{7?[\H.  ")I%0M"EEdkkRYFbcH r  c                    U R                  5         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      nO$XES
'   U R                  U R                  XR5      5      nU R                  US0 5      nU R                  X5      $ )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:
r  z3 fetchOpenInterest() supports contract markets onlyNr  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<<T[[=YZH$ &1M"??G@\]H" ~~h3''55r  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openInterestListrA  r  r   r  r  r  openInterest)r  openInterestAmountopenInterestValuer  r  r6  )r   r  rE  safe_open_interestr  rP  rI  )r  r  r  r  r  r^  s         r  r-  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         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      n
U R                  U
S/ 5      nU R                  XX#5      $ )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  ra  rE  r  r  r  r  r  *privateSpotGetV2SpotAccountTransferRecordsr=  r8  parse_transfers)r  r  r  r  r  r  r8  r  r  r  r  r  s               r  fetch_transfersbitget.fetch_transfersA"  s#    <#DGG.Z$Z[[99:JDRXY&&v}dC6=17GL<==&TN
 #(K $G229gNBB4;;wC_`, ~~h3##DEAAr  r8  	toAccountc                    U R                  5         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      nU R                  US0 5      nU R                  US5      US'   U R                  X5      $ )	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>`
r  rE   )r9  toTyper!  r  r  Nr  r  r  )r  r  r  r  rE  r  r  #privateSpotPostV2SpotWalletTransferr=  r  parse_transfer)r  r  r!  r8  r>  r  r  r  r9  r@  r  r  r  r  r  s                  r  r   bitget.transferz"  s    	==&7GL##N@!!.< TN	
 !!&(368,[[(F &tGH;;DKK<XY x4&&x?T
""422r  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  r9  r  r@  
transferIdr  )	r6  rE   r  r  r  r!  r8  r>  r  )	r  r}  rE  r  r  rI  rF  rN  parse_transfer_status)r  r   r  r  r  r  fromAccountRawr  r8  toAccountRawr>  s              r  rB  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  rF  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  rG  )r6  r   r  r  r   r  r  r  F)r  r   r  r   r   r  rG  )r  r:  r9  rE  r  rN  )r  r  r  r  r  r]  rU  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         U R                  U5      nU R                  US/ 5      nU R                  XAS5      $ )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>`
r  r  )r  r  r8  parse_deposit_withdraw_fees)r  rP  r  r  r  s        r  fetch_deposit_withdraw_fees"bitget.fetch_deposit_withdraw_fees#  sG     	66v>< ~~h3//VDDr  c                     U R                  5         U R                  U5      nUS   U R                  X5      S.nU R                  U R	                  XS5      5      nU R                  US0 5      nU R                  Xt5      $ )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>`
rE   )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
 EEdkkRYFbc x4%%d55r  c                 &   U R                  5         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      nU R                  US0 5      n	U R                  XU5      $ )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>`
rE   )r  rV  r  r  )r  r  r  r  .privateMarginPostV2MarginIsolatedAccountBorrowr=  r  rX  
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

 FFt{{SZGcd x4%%df==r  c                 &   U R                  5         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      nU R                  US0 5      n	U R                  XU5      $ )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>`
rE   )r  repayAmountr  r  )r  r  r  r  -privateMarginPostV2MarginIsolatedAccountRepayr=  r  rX  r^  s
             r  repay_isolated_marginbitget.repay_isolated_margin#  s     	==&V$TN55dCTl

 EEdkkRYFbc x4%%df==r  c                     U R                  5         U R                  U5      nUS   U R                  X5      S.nU R                  U R	                  XS5      5      nU R                  US0 5      nU R                  Xt5      $ )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>`
rE   )r  rb  r  )r  r  r  ,privateMarginPostV2MarginCrossedAccountRepayr=  r  rX  rY  s           r  repay_cross_marginbitget.repay_cross_margin#  s{     	==&TN55dC
 DDT[[QXEab x4%%d55r  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repayIdrV  rb  )rE   r  r!  r  r  r  r6  )rE  r  r  rF  rP  )r  r6  r  r  r  r^  r  s          r  rX  bitget.parse_margin_loan#  s    L %%dF3
##D(3%%hfEF$$T8Y?//
E((~}M
 	
r  c           	         U R                  5         SnU R                  USS5      u  pTU(       a  U R                  SXX4SS5      $ SnUb  U R                  U5      nSnU R	                  SXd5      u  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  aD  Uc  [        U R                  S-   5      eUS   US'   U R                  U R                  X5      5      n	O&U
S:X  a   U R                  U R                  X5      5      n	U R                  U	S0 5      nU R                  US/ 5      nU R!                  XX#5      $ )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>`
Fr   r  r  r  NrR   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  ra  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334I6Z_ipr~[[(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NNt{{[bOklH7"MMdkkZaNjkHj x4~~dL"=&&|UJJr  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  )	rE  r  r  r?   r  safe_liquidationr  r  rI  )r  liquidationr  r^  r  liquidationFeery  quoteValueStrings           r  parse_liquidationbitget.parse_liquidatione$  s    > ##K:%%k<@	++K8L$$[+>	"--nH$$&&x8 ++,<="Y/
&
 
 
	r  c                 ,   U R                  5         U R                  U5      nSUS   0nU R                  U R                  XB5      5      nU R	                  US5      nU R                  US/ 5      nU R                  US0 5      nXhS'   U R                  X5      $ )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>`
r  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
 LLT[[Y`MijT %%h>	x4a,&k..u==r  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  )rE  r  r  rF  rN  rI  )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         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(       a4  U R                  U R	                  XB5      5      nU R                  US0 5      nOFU R                  U R	                  XB5      5      nU R                  US/ 5      nU R                  US0 5      nU R                  US	5      n	XS
'   U R                  Xs5      $ )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>`
r  rE   Nr~   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;;DKK<XYH ^^Hfb9FOOPTP[P[\cPlmH6 ??8VR8D__T1b1F%%h>	'{%%f77r  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  )rE  r  rF  rP  rI  )r  r6  r  r  r  s        r  r  bitget.parse_borrow_rateN%  sh    < %%dF3
%%dK8	//
E&&t-@/R"Y/
 	
r  c           	         U R                  5         SnU R                  USS5      u  peU(       a  U R                  SX#XESS5      $ 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  aD  Uc  [        U R                  S-   5      eUS   US'   U R                  U R                  X5      5      n
O&US:X  a   U R                  U R                  X5      5      n
U R                  U
S0 5      nU R                  US/ 5      nU R                  X5      nU R                  XX45      $ )a  
fetch the interest owed by the user for borrowing currency for margin trading

https://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>`
Frt   r  r  r  NrE   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_interestw%  s    	88AVXbc334I6Z_ipr~[[(F}}T*H&tnGFO#(K #'#4#4#6#CGK $G
!??@UW]_fg
#~'2e(eff &tGHKKDKKX_LhiH7"JJ4;;W^KghHf x4t\26..t<2285PPr  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  )rE  r3  r  rF  rN  rI  )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         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(       a,  Ub  X%S'   XeS'   U R	                  U R                  XS5      5      nO+Ub  X%S	'   XeS
'   U R                  U R                  XS5      5      nU R                  US0 5      n	U R                  U	SS/ 5      n
U R                  U
S   U5      $ )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>`
r  rE   Nr^   r   Fr  r  r  r  r  r  rA  r   )
r  r  r  r  #privateUtaPostV3TradeClosePositionsr=  &privateMixPostV2MixOrderClosePositionsr  r   rD  )r  r  rq  r  r  r  r  r   r  r  rx  s              r  close_positionbitget.close_position&  s    	V$fTl
 "AA&Q33FOUTYZ%)	""-J??G@\]H" &*
#%0M"BB4;;wC_`H$ x4  }fbAa&11r  c                    U R                  5         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      nO$X2S'   U R                  U R	                  X!5      5      nU R                  US0 5      nU R                  USS	/ 5      nU R                  USU5      $ )
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  rA  )	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_positionsL&  s     	"AA$O33F<OQVX]^"-J??G@\]H" &1M"BB4;;wC_`H$ x4$$T=&"E	##ItV<<r  c                    U R                  5         U R                  U5      nSnU R                  X25      u  pBUS   US   US.nU R                  U R	                  XR5      5      nU R                  US0 5      nU R                  Xs5      $ )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 ,&

 88W9UV: ~~h3%%d33r  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                 X   U R                  5         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      n	O U R                  U R                  XT5      5      n	U R                  U	S0 5      nU R                  US/ 5      nU R                  XU5      nU R                  XU5      $ )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  rA  )r  r:  r  r  r  r  &privateUtaGetV3PositionHistoryPositionr=  r  r7  r8  r  filter_by_since_limit)r  r_  r  r  r  r  r  r  r   r  re  r  r  	positionss                 r  fetch_positions_historybitget.fetch_positions_history&  sJ     	LMq WQZ0$*4L!#(K $G229gN"AA&Q33F<SUZ\ab"-JBB4;;wC_`HD EEdkkRYFbcH< ~~h3~~dFB7((G	)))EBBr  fromCodetoCodec                 f   U R                  5         UUU R                  U5      S.nU R                  U R                  XT5      5      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      $ )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>`
)fromCointoCoinfromCoinSizer  r  r  )r  r  %privateConvertGetV2ConvertQuotedPricer=  r7  rE  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

 ==dkk'>Z[" ~~h3))$
HE}}^4''h?]]<0
$$TDDr  c                    U R                  5         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      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      $ )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>`
r  	cnvtPriceNz0 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  rE  r  r  )r  rE   r  r  r!  r  r  r  r  r  r  r  r  s                r  create_convert_tradebitget.create_convert_tradeX'  s    	""67K@=#DGG.`$`aa%%fj,G#DGG.c$cdd6GZ#89  11&9"
 88W9UV ~~h3''h?]]<0
$$T4<<r  c                    U R                  5         0 nSnU R                  5       nUb  X%S'   OXv-
  US'   U R                  USS5      nUb  XS'   OXuS'   Ub  X5S'   U R                  US5      nU R	                  U R                  XT5      5      n	U R                  U	S0 5      n
U R                  U
S/ 5      nU R                  XSS	X#5      $ )
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>`
r  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+??G@\]. ~~h3>>$
B7%%hj(EYYr  
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  rE  rF  rI  r  rN  )	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         U R                  U5      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$ )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
r  r   r  Nr  	minAmount	maxAmountr$  r  r  )r  $privateConvertGetV2ConvertCurrenciesr8  r9  r:  rE  rF  rN  )	r  r  r  r]  r  rU  r  rE   r  s	            r  fetch_convert_currenciesbitget.fetch_convert_currencies'  s    	<<VD  ~~h3q#d)$AGE!!%0B**2.D  ,,UK@!  $//{C#//{C
  $#!
  $#   5FL	 %@ r  c                    U R                  5         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      nO$XES'   U R                  U R                  XR5      5      nU R                  US/ 5      nU R                  US	0 5      n	U R                  X5      $ )
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_interval5(  s     	V$"AA&QfTl
 33F<RTY[`a??G@\]H& &1M">>t{{7?[\H ~~h3tQ+&&u55r  c                 V   U R                  5         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      nO U R	                  U R                  Xu5      5      nU R                  US/ 5      n	U R                  X5      $ )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>`
r  rE   Nr  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_historys(  s     	V$fTl
   )H&>VH-CCDKKPWD`aH" GGT[HdeH ~~h3224@@r  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  )rE  rN  r  rI  rP  )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_paramsrA  rC  r:  	urlencodecheck_required_credentialsrM  r	  r4  keysortrK  replacehmacencoder   hashlibsha256rE  r  r   r   r  )r  pathr   r  r  r  r  signedendpointpathPartr  payloadr  queryrC  
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  rM  r   r  r  r   r(   r  floatr   r  dictr   r  r  r   r  r  r   r$  r!   rS  rY  r]  r    r"   rf  r%   r  r  r&   r  r'   r  r  rA  r  r  r   r  r  r  r
  r   rD  rH  r   r   r   rG  rO  rR  r   r  r  r  r  r  r  r  r  r!  r(  r+  r%  r.  r   r?  rO  rM  r  r  r   r  r  r  r#   r  r$   r  r  r  r   r  r  r  r   r  r  rn  r  r   r  r  intr  r#  r(  r.  r-  r)   r<  r   rB  rF  rN  rS  rZ  r_  rd  rh  rX  r   rs  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   #   sr   f# fP7. .'4 ' 59 %%N !# 5s 5. $& 6$v, 6,ptF| pdl4< l\ ') uZ un ?A ~@# ~@T,EW ~@@E E$|J\ EN *.Dt\^ :L3 :Lc :L :Lcghsct :Lx KOWY 7S 7% 7# 7C 7^i 7r -1tRV_a >Pc >P >PC >Pfjkvfw >P@K
T K
X K
Q\ K
Z:s : 79 #:# #:^ #:J
h 
R` 
0 :>b ?Zs ?Z3 ?ZY ?ZBM4 M M6 M^ 02 [23 [2f [2z 46 2s 2& 24 04B a1W a17 a1FU Uv U Un 6:UW A=3 A=s A=# A=\`af\g A=F 57 &4 &4;N &4P )+ q{ qf	
f 	

 
4 
. 9=4^bkm bH# bH# bHS bHX[ bHrvw{r| bHH $& d(( d(L)H )2I) I)V: :*H Hv H HT
 RT ` `5 `, gksu b.3 b.i b.y b.RW b.`c 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,` DF ,/\(: ,/\ @B _/D$6 _/B `drv  @B }.S }.# }.Y }.i }.Y\ }.lo }.~ 37r U/s U/C U/n 48 /S /B ;?r P1c P1C P1d /32 r/ r/h 26b e/c e/3 e/R /3TXac z= z=3 z=c z=hlmrhs z=x 154VZce :# :S :PS :jnotju :8 37TX\eg <C <s <RU <8 >BPTcgpr a?s a?# a?]` a?F	 BFTXgktv t?3 t?c t?ad t?l (,$TZ\ d? d?C d?s d?aefqar d?L:t :x :; :x+3Z -1tRV_a R=c R= R=C R=fjkpfq R=h 24 f2S f2P 26b tPw tPT(^ tPlVt VV Vp 8<$]ajl YY YYC YYWZ YYv 68 U8 U8K U8n 6:" P77 P7 P7d :>b 9w 9\ 9V
6 V
[ V
p 37TX\eg >JC >Js >JRU >Jlpq  mA >J@
f 
4OS OX[ Ogklzg{ O FH 3 L^ 8
d 
F 
N` 
4 @B KC K KFX K$ =? H He HCU H  24 11S 11 11f

t 

V 

x 

 9=R @S @# @D >B" +# +s +Z =A 2 2c 2h 79 ?6# ?6B$F $L +/TPT]_ 7BC 7Bs 7B# 7Bdhivdw 7Br [] .3S .3% .3c .3c .3an .3`+
t +
x +
= +
Z:C :C :1 1f <@ *E *EX DF 6 6U 6B TV #>S #> #>U #>J LN $>C $>s $>L <>  6s  6D3
 3
 3
j 37TX\eg dKC dKs dKRU dKlpq|l} dKL.V .` >@ => =>DV =>~2
t 2
V 2
Oa 2
h 9; D8C D8 D8L'
 '
R 15DW[jnwy aQ# aQc aQQT aQdg aQ  C  DR  S aQF+
$ +
 +
. +
Z =A C2S C2	 C2PU C2J *, ;=X ;=z 57 14 14: 14f
D 
* 
 :>D_cln gCw gCc gCY\ gCsw  yA  tB gCR MQY[ (EC (E (Ec (E`j (ET W[ce 0=s 0=c 0=3 0=PS 0=jt 0=d 7;\`ik 5Z 5Z3 5ZVY 5Zptu  qA 5Zn4
4 4
x 4
\d 4
pz 4
l /1 <Z <| :< <6S <6 <6| <@RVeix|  FH 7AS 7AC 7A_b 7Aru 7A  MQ  R`  Ma 7Ar

4 

 

> 

)# )s ) )c )TX )`c )VD  b$T /P /Pr  rA   )Gccxt.base.exchanger   ccxt.abstract.bitgetr   r	  r4  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>r8	     s    ( ,   T  T  T  T  T  T  T  T  T  T  * 0 - - . ' & . + ) * ) + . 1 * ) + * 4 %rcPX{ rcPr  