
    ei\                       d dl mZ d dlmZ d dlZd dlZd dlmZmZm	Z	m
Z
mZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZm Z m!Z!m"Z"m#Z#m$Z$m%Z%m&Z&m'Z'm(Z(m)Z)m*Z*m+Z+ d dl,m-Z- d dl.m/Z/ d dl.m0Z0 d dl.m1Z1 d d	l.m2Z2 d d
l.m3Z3 d dl.m4Z4 d dl.m5Z5 d dl.m6Z6 d dl.m7Z7 d dl.m8Z8 d dl.m9Z9 d dl.m:Z: d dl.m;Z; d dl.m<Z< d dl.m=Z= d dl.m>Z> d dl.m?Z? d dl.m@Z@ d dl.mAZA d dl.mBZB d dlCmDZD d dlEmFZF  G d dee          ZGdS )    )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)RestrictedLocation)InsufficientFunds)InvalidAddress)InvalidOrder)OrderNotFound)NotSupported)DDoSProtection)RateLimitExceeded)ExchangeNotAvailable)OnMaintenance)InvalidNonce)RequestTimeout)CancelPending)	TICK_SIZE)Precisec                       e Zd Zdef fdZdefdZdefdZdi fdZi fde	fdZ
i fdee         fd	Zdee         fd
Zdee         fdZi fdefdZi fdedee         fdZddedee         fdZdddi fdede	de	dee         fdZdi fdededededef
dZdddi fdede	de	dee         fdZddededefdZdefdZi fdede fdZ!ddede fd Z"di fdede	de#fd!Z$dd"edede%fd#Z&i fdede%fd$Z'i fdede%fd%Z(di fd&e)de*fd'Z+dd(edede,fd)Z-ddi fdede	de	dee,         fd*Z.i fdede/fd+Z0i fde1fd,Z2ddefd-Z3ddede4fd.Z5d/ddi fded0ede	de	dee4         f
d1Z6i fde7fd2Z8de7fd3Z9de7fd4Z:defd5Z;dd6edede<fd7Z=i fded8efd9Z>di fded:e?d;e@ded<eAf
d=ZBdi fded:e?d;e@ded<eAf
d>ZCdi fded:e?d;e@ded<eAf
d?ZDi fd@eeE         fdAZFi fd@eeE         fdBZGddi fdCeded:e?d;e@deAd<eAfdDZHdi fdCedefdEZIdi fdefdFZJdi fdGee         defdHZKdi fdefdIZLdi fdCedefdJZMdddi fdede	de	dee<         fdKZNdddi fdede	de	dee<         fdLZOdddi fdede	de	fdMZPdddi fdede	de	fdNZQdddi fdede	de	fdOZRdddi fdede	de	deeS         fdPZTddQededeSfdRZUdS ZVdddi fdede	de	dee,         fdTZWi fdefdUZXdi fd&e)deeY         fdVZZddWedefdXZ[dddi fdede	de	fdYZ\i fdede]fdZZ^di fd&e)de_fd[Z`di fd&e)de_fd\Zaddede]fd]Zbdddi fdede	de	deec         fd^Zdddefd_Zedde	de	deec         fd`Zfi fdedegfdaZhddbededegfdcZii fdededegfddZji fdededegfdeZki fdedelfdfZmddgededelfdhZndi fdgeodefdiZpdi fdjedefdkZqdi fdledefdmZri fdefdnZsddefdoZtdddi fdede	de	deeu         fdpZvi fdededqedredeuf
dsZwddtededeufduZxdedefdvZyddefdwZzdi fdxe)fdyZ{i fdedefdzZ|i fdededefd{Z}i fdedefd|Z~i fdefd}Zddedefd~Zdddi fdede	de	dee         fdZddefdZi fdedefdZddededefdZi fdedefdZddefdZddddi fdedede	de	dee         f
dZddededefdZdi fded;e@de<fdZi fdeeY         fdZi fdedefdZddjedefdZdddi fd&e)de	de	deeY         fdZdi fdededeAdefdZdi fdCedededeAdef
dZdddi fdede	de	dee         fdZddedededefdZi fdefdZi fdede]fdZddddi fded0ede	de	dee         f
dZddededefdZdeodededededefdZd Zg di ddfdZ xZS )bitgetreturnc                 @   |                      t          t          |                                           i ddddddgddd	d
dddddi dd ddddddddddddddddddddddddddddddd di d!dd"dd#dd$dd%dd&dd'dd(dd)dd*dd+dd,dd-dd.dd/dd0dd1di d2dd3dd4dd5dd6dd7dd8dd9dd:dd;dd<dd=dd>dd?dd@ddAddBdi dCddDddEddFdGdHddIddJddKddLddMddNddOddPddQddRddSddTdi dUddVddWddXddYddZdd[dd\dd]dd^dd_dd`ddaddbddcdddddedi dfddgddhddiddjdGdkddlddmddnddoddpddqddrddsddtdduddvdi dwddxddyddzdd{dd|dd}dd~dddddddddddddddddddddddddddddddddddddddddddddddddddg dddddddddidi dddddddddddddddddddddddddddddddddddddddddddd	idi ddddddddddddddddddddddddddddddddddi ddddddddddddГddГddГddddddddddddddddddddddddddddݜ	idddddddddޜiddddߜidi ddddddddddddddddddddddddddddddddidi ddГddddddܓddddddddddddddddddddddd ddddddddddddddddddܐdi ddГddГddddГddГd	dГd
dГddddddddГddddddddГddГddi ddddddddddddddddddddГd dГd!dd"dd#dd$dd%dd&di d'dd(dd)dd*dd+dd,dd-dd.dd/dd0dd1dd2dd3dd4dd5dd6dd7di d8dd9dd:dd;dܓd<dd=dГd>dd?dd@ddAddBddCddDddEddFddGddHdܓdIi dJddKddLddMddNdГdOdГdPddQddRdГdSddTddUddVdГdWddXddYddZdi d[dd\dd]dd^dd_dd`ddaddbddcdddddeddfddgddhddiddjddkdi dldГdmddnddoddpddqdܓdrdܓdsdܓdtdduddvddwdГdxdГdyddzdd{dd|dddddddܐd}i d~dddddГddГddГddГddddddddddddddddܓddddddi ddddddddddddddddddddddddddddddddГddi ddddddddddddddddddГddГddГddГddddГddܓddГdddddddddddddddddIdddddddddd	ddddddddddАd
dIddddddddddiddddddddddddddddi ddܓddܓddܓddddddГddddddddܓddܓdddddddddddIi ddddddddddddddddddddddddddddddddddi ddddddddddddddddddddddddddddddddddddddddddddddddddi ddddddddddddddddddddddddГddГddddddddi ddddddddddddd dddddddddddddddddd	dd
dddidIi ddddddddddddddddddddddddddddddddddddddddddddddddi ddddd dd!dd"dd#dd$dd%dd&dГd'dd(dd)dd*dd+dd,dd-dd.dd/didIdddddܐd0idddddd1ddd2dIi d3dd4dd5dd6dd7dd8dd9dd:dd;dd<dd=dd>dd?dГd@ddAddBddCdddddDdddddddEdIddFdiii dGddHddIddJddKddLddMddNdܓdOddPdГdQddRdГdSdܓdTddUdГdVddWdi dXddYddZdd[dd\dd]dd^dd_dd`ddaddbddcdddddeddfddgddhdi diddjddkddlddmddnddoddpddqdܓdrdܓdsddtdduddvddwddxddyddzdii d{dd|dd}dГd~dܓddܓddܓddܓddГddГddГddГddܓddddddddddi ddddddddddddddddddddddddddГddddГddГddГddddddddIddd|                     d          |                     d          d|                     d          |                     d          ddddddddi dt
          dt          dt          dt
          dt
          dt          dt          dt          dt          dt          dt          dt          dt          dt          dt
          dt          dt          i dt          dt          dt          dt          dt
          dt
          dt
          dt          dt          dt          dt          dt          dt          dt          dt          dt          dt          i dt          dt
          dt          dt          dt          dt
          dt
          dt
          dt          dt          dt          dt          dt           dt
          dt"          dt"          dt"          i dt"          dt"          dt
          dt
          dt
          dt
          dt
          dt
          dt
          dt
          dt
          dt
          dt
          dt
          dt
          dt
          dt
          i dt
          dt
          dt
          dt          dt
          dt"          dt$          dt          dt
          dt
          dt
          dt
          dt
          dt"          dt
          dt"          dt"          i dt
          dt
          d t
          dt
          dt"          dt
          dt
          dt"          dt"          dt"          dt"          d	t"          d
t
          dt
          dt
          dt
          dt
          i dt
          dt
          dt
          dt
          dt
          dt
          dt
          dt
          dt
          dt
          dt
          dt
          dt
          dt          dt          dt&          dt
          i d t
          d!t
          d"t
          d#t&          d$t
          d%t
          d&t
          d't
          d(t"          d)t(          d*t"          d+t
          d,t&          d-t
          d.t
          d/t          d0t"          i d1t
          d2t"          d3t"          d4t
          d5t"          d6t"          d7t"          d8t
          d9t
          d:t
          d;t
          d<t
          d=t
          d>t
          d?t
          d@t
          dAt
          i dBt
          dCt
          dDt
          dEt
          dFt
          dGt
          dHt
          dIt
          dJt          dKt          dLt
          dMt
          dNt
          dOt
          dPt
          dQt
          dRt          i dSt*          dTt
          dUt
          dVt
          dWt
          dXt
          dYt&          dZt
          d[t
          d\t
          d]t
          d^t
          d_t
          d`t
          dat          dbt          dct          i ddt          det          dft*          dgt
          dht          dit
          djt
          dkt
          dlt
          dmt
          dnt
          dot
          dpt
          dqt
          drt          dst"          dtt"          i dut"          dvt"          dwt"          dxt
          dyt"          dzt"          d{t"          d|t
          d}t
          d~t&          dt
          dt(          dt"          dt"          dt
          dt
          dt
          i dt"          dt
          dt&          dt&          dt
          dt"          dt"          dt&          dt
          dt&          dt
          dt
          dt          dt          dt          dt"          dt"          i dt"          dt"          dt"          dt"          dt"          dt"          dt"          dt"          dt"          dt"          dt"          dt"          dt"          dt"          dt"          dt"          dt"          i dt"          dt"          dt"          dt"          dt"          dt"          dt"          dt"          dt
          dt
          dt
          dt
          dt
          dt          dt
          dt
          dt
          i dt
          dt          dt          dt
          dt          dt          dt          dt          dt          dt          dt          dt&          dt          dt          dt          dt"          dt
          i dt          dt          dt"          dt"          dt"          dt"          dt"          dt"          dt"          dt
          dt(          dt"          dt"          dt"          dt"          dt"          dt"          i dt"          dt"          dt"          dt"          dt"          dt"          dt"          dt"          dt          dt          dt          dt          dt          dt          dt          dt          dt,          i dt
          dt
          dt          dt          dt          dt          dt          dt          dt          dt          dt          dt          dt          dt          dt
          dt          dt
          i dt          dt
          dt          d t          dt          dt          dt          dt          dt
          dt
          dt
          dt
          d	t"          d
t(          dt          dt"          dt
          i dt          dt          dt          dt          dt          dt          dt          dt
          dt          dt          dt          dt          dt          dt
          dt          dt          dt
          i dt
          d t          d!t          d"t          d#t          d$t          d%t
          d&t
          d't
          d(t"          d)t
          d*t
          d+t
          d,t
          d-t
          d.t          d/t          i d0t
          d1t
          d2t
          d3t
          d4t
          d5t
          d6t          d7t
          d8t
          d9t
          d:t
          d;t
          d<t          d=t
          d>t
          d?t
          d@t
          i dAt          dBt"          dCt          dDt          dEt
          dFt
          dGt&          dHt&          dIt
          dJt
          dKt&          dLt(          dMt"          dNt"          dOt          dPt"          dQt(          i dRt&          dSt"          dTt          dUt"          dVt"          dWt"          dXt          dYt          dZt          d[t          d\t
          d]t"          d^t"          d_t"          d`t
          dat          dbt          i dct          ddt          det          dft          dgt          dht          dit          djt,          dkt          dlt          dmt
          dnt          dot          dpt          dqt          drt          dst          i dtt          dut
          dvt          dwt
          dxt
          dyt          dzt"          d{t"          d|t
          d}t&          d~t
          dt
          dt
          dt          dt          dt          dt          i dt,          dt
          dt"          dt"          dt"          dt"          dt"          dt"          dt&          dt"          dt"          dt
          dt          dt          dt
          dt
          dt.          t"          t          t"          ddt
          iddt0          ddddddddi dddddddddddddddddddddddddddddddddddddddddddddddddd[dddgidddddddddddid`ddddddÐdĐdŐdƐdǐdȐdɐdʐddd̐d͐d͐d͐dΜdϐdМdѐdƐdҐdӐdddАd՜d֐dМdלdtdؐdidؐdiddLdؐdidddݐdސdߐddddddddddddddddi ddddddddddddddddddddddddddd d ddddddi dddddd	d
d
ddddddddddddddddddddddddddi ddd d!d"d"d#d#d$d%d&d'd(d(d)d)d*d*d+d+d,d-d.d/d0d1d2d2d3d3d4d5d6d6i d7d8d9d:d;d<d=d>d?d@dAdAdBdBdCdCdDdDdEdFdGdHdddIdIdJdKdLdMdNdNdOdOi dPdQdRdSdTdUdVdVdWdXdYdYdZd[d\d\d]d^d_d_d`d`dadadbdbdcdddedfdgdhi dؐdiidjg dkdldmdddddddndddddddnddodddddpdddddqdrd
iddd dddsdddddtddddddud ddd d dddddvdwdidx	ddddddndddddddnddodddddpdddddydzd{id|did}d~did~didd~did~diddd          S (  NidrB   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/union-interest-rate-history   zv2/mix/market/exchange-ratezv2/mix/market/discount-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-candles   )	zv2/mix/market/open-interestzv2/mix/market/funding-timezv2/mix/market/symbol-pricezv2/mix/market/history-fund-ratezv2/mix/market/current-fund-ratezv2/mix/market/oi-limitz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-interestzv3/market/instrumentszv3/market/tickerszv3/market/orderbookzv3/market/fillszv3/market/proof-of-reservesz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-limitzv3/market/index-components)r   rR   r   rS   r   r   zspot/v1/wallet/deposit-addressz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v2/spot/account/upgrade-statusz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-accountzv2/spot/account/upgrade)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-assetszv2/mix/account/interest-historyzv2/mix/account/max-openzv2/mix/account/liq-pricezv2/mix/account/open-countzv2/mix/account/billzv2/mix/account/transfer-limitszv2/mix/account/union-configz v2/mix/account/switch-union-usdtzv2/mix/account/isolated-symbolsr   zv2/mix/position/single-positionzv2/mix/position/all-positionzv2/mix/position/adlRankz v2/mix/position/history-positionzv2/mix/order/detailzv2/mix/order/fillszv2/mix/order/fill-history)zv2/mix/order/orders-pendingzv2/mix/order/orders-historyzv2/mix/order/plan-sub-orderz 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-auto-marginzv2/mix/account/set-leveragezv2/mix/account/set-all-leveragezv2/mix/account/set-marginzv2/mix/account/set-asset-modezv2/mix/account/set-margin-modezv2/mix/account/union-convertz v2/mix/account/set-position-modezv2/mix/order/place-order)zv2/mix/order/click-backhandzv2/mix/order/batch-place-orderzv2/mix/order/modify-orderzv2/mix/order/cancel-orderz v2/mix/order/batch-cancel-orderszv2/mix/order/close-positionszv2/mix/order/cancel-all-orderszv2/mix/order/place-tpsl-orderzv2/mix/order/place-pos-tpslz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/funding-assetszv3/account/settingszv3/account/financial-recordszv3/account/repayable-coinszv3/account/payment-coinszv3/account/convert-recordszv3/account/deduct-infozv3/account/fee-ratezv3/account/switch-statuszv3/account/max-transferablezv3/account/open-interest-limitzv3/account/sub-unified-assetszv3/account/transferable-coinszv3/account/sub-transfer-recordzv3/account/deposit-addresszv3/account/sub-deposit-addresszv3/account/deposit-recordszv3/account/sub-deposit-recordszv3/account/withdrawal-recordszv3/broker/sub-listz$v3/broker/all-sub-deposit-withdrawalzv3/broker/commissionzv3/broker/query-sub-apikeyz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-convertzv3/loan/coinszv3/loan/interestzv3/loan/borrow-ongoingzv3/loan/borrow-historyzv3/loan/repay-historyzv3/loan/pledge-rate-historyzv3/loan/debtszv3/loan/reduceszv3/position/current-positionzv3/position/history-positionzv3/position/adlRankzv3/tax/recordsz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/switch-deductzv3/account/deposit-accountzv3/account/switchzv3/account/adjust-account-modezv3/account/transferzv3/account/sub-transferzv3/account/sub-master-transferzv3/account/max-open-availablezv3/account/withdrawalzv3/broker/create-subzv3/broker/modify-subzv3/broker/sub-withdrawalzv3/broker/sub-deposit-addresszv3/broker/create-sub-apikeyzv3/broker/modify-sub-apikeyzv3/broker/delete-sub-apikeyzv3/ins-loan/bind-uidzv3/loan/borrowzv3/loan/repayzv3/loan/revise-pledgez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-orderzv3/trade/close-positions)zv3/trade/countdown-cancel-allz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40024)411174311145113z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fiatCurrenciesg     @@)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rollingWindowSizefeatures)deep_extendsuperrB   describeparse_numberr+   r:   r-   r0   r,   r<   r=   r8   r1   r.   r;   r>   r5   r/   r3   r6   r4   r9   r2   r?   )self	__class__s    I/var/www/html/volatility/venv/lib/python3.11/site-packages/ccxt/bitget.pyr  zbitget.describe&   sN   fd 3 3 < < > > jA
(jA
HjA
 $jA
 t	jA

 jA
 jA
 4j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 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 w 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 w 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 w 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 w 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 w 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 wjA
@  AjA
` ajA
b i434366637443  0   Ak?   cj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!-, . H/, 0 :11, 2 :13, 4 85, 6 3A7, 8 4Q9, : 21;, < :1=, > 4Q?, @ <QA, B B1C, D A!E,  , F <=:;:;?@?@6778BC@BW,  ,  , .` KLNO?@BC;<45AC   
 =>AB      3Q /  21  .q	 
 :1  6q  0  8  :1  :1  5a  6q  5a  6q  1!   9!! Ky yx! <a! <a!  :1!  6r	! 
 5a!  :1!  >q!  9!!  =a!  :1!  9!!  :1!  :1!  1!!  6q!   <Q!! " ;A#! $ 45@A@A4667AB56?@9:56>@>?>?AB>@A!  !  ! DE!5qE!8!E! 9"E! 8	E!
 ;AE! >qE! A!E! FsE! 4QE! 3AE! 9!E! 9!E! <QE! @E! @E!  CA!E!" 6q#E! E!$ 8%E!& 4Q'E!( 21)E!* 5a+E!, 6q-E!. 6q/E!0 71E!2 73E!4 ;A5E!6 ;A7E!8 4Q9E!: 21;E!< 1!=E!> 9!?E!@ CAAE!B CACE!D EaEE! E! E!F =aGE!H CAIE!J ?KE!L EaME!N GOE!P ;AQE!R EaSE!T =aUE!V B1WE!X >qYE!Z A![E!\ @]E!^ CA_E!` CAaE!b A!cE!d GeE!f HgE! E! E!h ?iE!j 8kE!l 9!mE!n 9"oE!p ?qE!r @sE!t =auE!v >qwE!x >qyE!z A!{E!| DQ}E!~ 6qE!@ A!AE!B 8CE!D ?EE!F DQGE!H 6rIE! E!Gi iV: 4a: 5q:  =a:  @	: 
 :1:  =a:  ?:  9!:  A!:  3A:  =a:  3A:  >q:  21:  1!:   4Q!: " 6q#:  : $ 6q%: & 8': ( 9!): * A!+: , 8-: . 3A/: 0 DQ1: 2 ?3: 4 :15: 6 >q7: 8 9!9: : 6q;: < 8=: > <Q?: @ 5aA: B 6qC: D @E:  :  : F >qG: H 6qI: J 7K: L 8M: N 21O: P =bQ: R :2S: T ?U: V >qW: X A!Y: Z >q[: \ ;A]: ^ 6q_: ` ?a: b 21c: d 1!e: f 8g:  : h <=;<;<@A@AACs:  :  : vA!H#A!7A! 9!A! 7	A!
 ;AA! =aA! 6qA! 8A! 8A! ?A! 7A! @A! =aA! ?A! 4QA!  5a!A!" ;A#A! A!$ 4Q%A!& 9!'A!( =a)A!* 9!+A!, 5a-A!. ;A/A!0 81A!2 ;A3A!4 6q5A!6 CA7A!8 <Q9A!: G;A!< Ea=A!> >q?A!@ ;AAA!B <QCA!D >qEA! A! A!F 8GA!H :1IA!J :1KA!L DQMA!N DQOA!P DQQA!R FqSA!T GUA!V =aWA!X :1YA!Z >q[A!\ 8]A!^ <R_A!` =aaA!b ;BcA!d ?eA!f 7gA! A!h <>>@9:9:@A<>>@=>;<=>>?>?>?AA! A! A!y~ ~B 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 $ ?%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  2 F 89AB@ACDFGDEABDEPQRSJK<=>?AB89c2  2  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 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 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 5 /5 75  215  ;A	5 
 9!5  75  9!5  5b5  265  75  :65  =a5  <R5  <Q5  =a5   9!!5 " =a#5  5 $ 9!%5 & =a'5 ( <Q)5 * 1!+5 , CA-5 . 3A/5 0 9!15 2 5f35 4 2655 6 4V75 8 9&95 : 8;5 < 5f=5 > 6v?5 @ ?A5 B ,QC5 D /E5  5  5 F 5aG5 H 5aI5 J 4QK5 L :1M5 N ,QO5 P .qQ5 R ;AS5 T ;AU5 V 22W5 X -bY5 Z 21[5 \ 7]5 ^ @_5 ` 6qa5 b ?c5 d -ae5 f /g5  5 h 3Ai5  5 l)!5q)!6)! /)! 7	)!
 9")! 0)! =b)! 21)! 6q)! =a)! <Q)! 4R)! 3A)! 3A)! 7)!  <Q!)!" :1#)! )!$ :1%)!& :1')!( 3F))!* -a+)!, ,Q-)!. 4Q/)!0 3A1)!2 <Q3)!4 4Q5)!6 =a7)!8 4Q9)!: =a;)!< 3A=)!> :1?)!@ 4QA)!B ;AC)!D 7E)! )!F >@2323676767Q)! )! )!oa a}`	 `	w\ \ejA
^ !..w77!..w77 
 "..x88!..x88 	 	_jA
r " $ $sjA
|  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 x *-)}  B 0OJ J}jA
R- YS-jA
T- #& ' ! !U-jA
d-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 2$ #&"%"%"%	1 1 #E  #&"%#&"$"$"$"#1 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  #a  #aYm m m\ "(  $&*(,$($(%*- -
 -2)-+/ ).(-).1 1
 &*7 7 $(#'"&#(	( ( #($)26+/9"$ "$H r% '+!$$(%'*.& & ',#($)*.	# # '+!$#'$)*/( ( $(&*!$$(,0%'#'$)*/	* 	*  #OJ JX  &(,$($(%*- -
 -2)-+/ )-(,)-1 1
 &+7 7 $(#'"&#(	( ( #'$(27+07"$ "$H $Q& #D*Q+ +\ ": ": 	  ": ": 	 AH HC5jA
 jA
 jA
 j j j	    enabledc                     || j         d<   dS )u
        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_modezbitget.set_sandbox_modeS  s    
 '.]###r  c                 0    |                      |           dS )r  N)r  r  s     r  enable_demo_tradingzbitget.enable_demo_tradingZ  s    
 	g&&&&&r  Nc                    d }|                      dd |          \  }}d }||
|dk    rdnd}|                     |dd|          }|p|n|d         }|d         r#d }|                     d|          \  }}|d	}n>d
}n;|dk    rd}n2|dk    rd}n)|dk    rd}n |dk    rd}n|dk    s|dk    s|dk    rd}nd}|t          | j        dz             |                     |ddg          }||gS )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_paramsz%bitget.handle_product_type_and_paramsa  s|   99:VX\^dee!fn 5<x4G4Gn((
L^__f&8H%Ff~ -!
%)%G%GHdfl%m%m"
F)"*KK"(KK6!!,6!!,7""-7""-F""&(8(8f>N>N-,#DG  /O  %O  P  P  P6M:#>??V$$r  c                     |                      |          }|                     |di           }|                     |d          S )aY  
        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_timezbitget.fetch_time  sD     33F;; x44  |444r  c                     | j         d         r|                                  d}|                     |ddd          \  }}|r|                     |          S |                     |          S )aV  
        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_marketszbitget.fetch_markets  sy     <12 	(%%'''33FNESXYYV 	6))&111--f555r  c                    d }|                      | j        d          }ddg}||                     |d|          }n|                     | j        d|          }g }d}t          dt	          |                    D ]}||         }|dk    s|dk    rig d}	t          dt	          |	                    D ]F}
|                    |                     |                     |d	|	|
         i                               G|dk    rS|                    |                     |                     d
}|                    | 	                    |                     t          | j        dz   |z   dz             |}g }g | j        d<   g | j        d<   t          dt	          |                    D ]}|                      ||          }|                     |dg           }|                      |di           }|                     |d          }|rL|Jt          |                     |d                                                    }|| j        d<   || j        d<   |                     ||          }g }t          dt	          |                    D ]<}||         }|                     |d          }|                     |d          }|                     |d          }|                     |          }|                     |          }|                     |dg           }d }|                     ||          r|}n/|                     ||          r|}n|                     |d          }|                     |          }|dz   |z   }d }d}d}d}d} d }!d }"d }#d }$d }%d }&|                     |d          }'d }(d})|'d}d
}|                     |                     |                     |d                              }!|                     |                     |                     |d                              }"|                     || j        d                   }*|                     || j        d                   }+|*|+d}(|*p|+})n|'dk    rd}d
}|dz   |z   }n|'dk    r|                     |d          }%|                     |%          }&|&                    d          },|                     |,d          }-|                     |,d          }.|-dd          }/|                     |,d!          }0|.dd         }1|/|0z   |1z   }2d}d
}|dz   |z   dz   |2z   }d
} ||k    }$|$ }#|                     |d"          }3|                     |d#          }4|                     |d$          }5|                     |d%          }6t5          |5          }7t7          |7j        |3          |7_        |7                                 t=          |7          }8|                     |8          }!t5          |6          }9t7          |9j        |4          |9_        |9                                 t=          |9          }:|                     |:          }"d
d
d}(|                     |d&d'          };d }<|;|;d(k    p|;d)k    }<d }=|d*k    r|                      |d+          }=| rd!nd }>|                    | !                    i d,|d|d-|d.|d/|d0|d1|d2|d3|d|d4|o|)d5|(d|d|d6dd7|<d8| |#|$|                      |d9          |                      |d:          |>|%|&d d |"|!d;|                      |d<          |                      |d=          d>| "                    |d?d@          |                      |dA          d>d d d>|=d d>dB|                     |dC          |dD                     >|S )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!publicMarginGetV2MarginCurrenciesr7   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-  r.  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  zbitget.fetch_default_markets  sp	   "nnT\>JJ &)*NN#6PPEE NN4<PPEq#e**%% 	V 	VA8DDH$4$4~~~q#h--00  AOOD$I$I$++V\%x{_ K K % %      E Ef M MNNN# F Fv N NOOOO"47-A#AD#H9#TUUU/1+,24./q#g,,'' 
	; 
	;A..!,,C>>#vr22DtQ33I>>)^DDL ; 8dH = = B B D DEE7?34:B677++GT::t q#g,,'' M	 M	AQZF''99H&&v{;;G%%fj99F++G44E**622D!%9Mr!R!RH}}V%788 C!w(:;; C"++,>BB,,X66FCZ%'FDDDFH!N"OFGF!N))&,??JK%*"!!%!2!243G3GHXHXY_aqHrHr3s3s!t!t"&"3"3D4H4HIYIYZ`buIvIv4w4w"x"x!%xF\9]!^!^$(MM(DLIb<c$d$d!+ 1  *8)L;L&&,,!DD#c\F2FF:--!..v~FFF%)\\&%9%9N"0"6"6s";";K#//Q??H"..{A>>G#AaC=D ,,[!<<E!!A#,C#'%<##5L#D!F#c\F2S8<GF6>$ $ 1 1&, G G!%!2!26=!I!I ,,V^DD	!--f6FGG
!),,#&w'7#G#G    !'ll!%!2!2;!?!? '
 3 3),]-C^)T)T&$$&&&"=11"&"3"3L"A"A! $  ''.IIFF!!X-F6X3EG**6>BB (211dL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))&.AA , "0"-+   $//
CC#//
CC! !
  $11&-IYZZ#//8HII 
  $# 
  '#  $  ,,V\BBe36 36 36 3 3 3 3 3 3h r  c                 	   g d}g }t          dt          |                    D ]H}|                     |d||         i          }|                    |                     |                     I|}g }t          dt          |                    D ]E}|                     ||          }|                     |dg           }	|                     ||	          }Fg }
t          dt          |                    D ]}||         }|                     |d          }|                     |d          }|                     |d          }|                     |d          }| 	                    |          }| 	                    |          }d }d }|dk    rd	}n|d
k    rd}n|dk    r|}|| 	                    |          }|dz   |z   }d }d}d}d}d}d }d }d }d }d }d }|                     |d          } d }!d}"|dk    }#|#s|dk    rbd}d}|#r[|                     |d          }$|                     |d          }%|$dk    p|%dk    }&|                     |d          }'|'dk    }(|(|&d}!d}"n| dk    rd}d}|dz   |z   }n| dk    r| 
                    |d          }|                     |          }|                    d          })|                     |)d          }*|                     |)d           }+|*d d!         },|                     |)d"          }-|+dd          }.|,|-z   |.z   }/d#}d}|dz   |z   dz   |/z   }d}||k    }| }ddd}!|                     |                     |                     |d$                              }|                     |                     |                     |d%                              }|                     |d&          }0d }1|0|0d'k    p|0d(k    }1|rd"nd }2|
                    |                     i d)|d|d*|d+|d,|d-|d.|d/|d|d|d0|o|"d1|!d|d#|d2dd3|1d4||||                     |d5          |                     |d6          |2||d d ||d7|                     |d8          |                     |d9          d:|                     |d;          |                     |d<          d:d d d:|                     |d=          d d:d>| 
                    |d?          |d@                     
|
S )AN)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maxOrderQtyminOrderAmountr'  r*  r+  )r7  r8  r;  r9  publicUtaGetV3MarketInstrumentsr5  r6  rB  rC  rD  r  rG  rH  r  rF  rM  rL  )3r  r  rT  rQ  rS  reqrV  rW  rX  r  r[  r  r  r\  r  r  r  r  r  r  r  r  rT   rR   rU   r  r  r]  r  r  r-  r.  r  r  r^  isUtaMarginisolatedBaseisolatedQuoter  maxCrossLeverager  ra  rb  rc  rd  re  rf  rg  r  r  r,  s3                                                      r  r  zbitget.fetch_uta_markets  s   KKKq#h--(( 	G 	GA++fHQK'  C OOD@@EEFFFFq#g,,'' 	7 	7A..!,,C>>#vr22D''66GGt q#g,,'' C	 C	AQZF''
;;H''99H&&v{;;G%%fj99F++G44E**622DHF>))!^++!^++#00::CZ%'FDDDFH!N"OFGF!N))&&99JK%*"#x/K &x611 
2#'#3#3F<V#W#WL$($4$4V=Y$Z$ZM , 5R=E;QH'+'7'7@T'U'U$-4E!&$,# #K .2*,,!DD#c\F2FF:--!..v~FFF%)\\&%9%9N"0"6"6s";";K#//Q??H"..{A>>G#AaC=D ,,[!<<E!!A#,C#'%<##5L#D!F#c\F2S8<GF6>$! $  "..t/C/CDDTDTU[]mDnDn/o/oppN"//0D0DTEUEUV\^qErEr0s0sttO%%fh77FF!!X-F6X3E (211dL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))&.AA , "0"-+   $//FF#//FF! !
  $//FF#//FF 
  $# 
  $//8HII#  $  ,,V\BBe36 36 36 3 3 3 3 3 3h r  c                    |                      |          }i }|                     |dg           }|                     | j        dg           }t	          dt          |                    D ]}||         }|                     |d          }|                     |          }	|                     |dg           }
i }d}d}t          |
          }|dk    rd}d}t	          d|          D ]}|
|         }|                     |d          }|                     ||	          }|	                                }|                     |d	          d
k    }|                     |d          d
k    }||n|p|}||n|p|}|||| 
                    |d          dd| 
                    |d          dddd||| 
                    |d          |                     |                     |                     |d                              d	||<   |o|}|                     |	|          }|                     |||	||rdndd|||dddddddddddddd          ||	<   |S )a  
        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)	r4  rE   networkr2  r  r   r  feer1  fiatcryptor  r   r  r4  rE   coder  r  rF   r  r  r   r  r1  r2  r3  )publicSpotGetV2SpotPublicCoinsr  r6  r  r7  r8  rC  rD  network_id_to_codeupperrL  r  rF  rE  safe_currency_structure)r  r  r  r[  r  r  rS  entryrE   r  r  r  r   r  chainsLengthrU  r  	networkIdr  r  r  r  isFiats                          r  fetch_currencieszbitget.fetch_currencies	  s    66v>>D x446FKKq#d))$$ F	 F	AGE!!%00B**2..D__UHb99FHHGv;;Lq   1l++  q	 ,,UG<<	11)TBB!--// $ 0 0 G G6 Q $ 0 0 G G6 Q,4,<<<HD\P\+2?,,'BY\!#& $(#3#3E;N#O#O#'% %
 $(#3#3E;M#N#N#'$ $	 	 # ,+++E=AA!%!2!243G3GHXHXY^`rHsHs3t3t!u!u%% %!!( )'F]]488F77$"(6h "$!  $# 
  $#! !
  $#      59 9  F4LL8 r  r  c                 `   |                                   |                     |          }i }d}d}d}d}|                     d|d          \  }}|                     ||          \  }}|                     |ddd          \  }}|rE|dk    r|d}|d         |d	<   ||d
<   |                     |                     ||                    }n:|d         s|d         r:||d<   |d         |d	<   |                     |                     ||                    }n|dk    r5|d         |d	<   |                     |                     ||                    }n|dk    r| 	                    |d          }	|	t          | j        dz             |                     |d          }|                     |	          }
|
d         |d<   |                     |                     ||                    }n t          | j        dz   |d	         z             |                     |dg           }|                     ||          S )aj  
        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(privateMarginGetV2MarginIsolatedTierDatarC  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_tiersz"bitget.fetch_market_leverage_tiers
  sj   " 	V$$
!??@Z\bdnoo
F"AA&&QQV33F<VX]_deeV 	yf$$)"*K &tGH"-GJ<<T[[RX=Y=YZZHHVn 	y&"2 	y%0GM" &tGHEEdkkRY[aFbFbccHH:%% &tGHDDT[[QXZ`EaEabbHH7""##FF33D|'2h(hiiiYYvv..F}}T**H&tnGFOCCDKKPWY_D`D`aaHHTW'ddgmnvgwwxxxV 6266//???r  r  c                 B   g }d}t          dt          |                    D ]}||         }|                     |dd          }||}|                     |g d          }|                     |dd          }	|	|	n|d         }
|                     |d          }|                    |                     |d	d
          |                     ||          | 	                    |
          |||                     |g d          | 
                    |d          |d           |}|S )Nr   	startUnitminTierValue)endUnitmaxBorrowableAmountbaseMaxBorrowableAmountmaxTierValuer  r  r  r  leveltier)keepMarginRatemaintainMarginRatemmrr(  )r  r  r  minNotionalmaxNotionalmaintenanceMarginRaterx  r4  )r7  r8  rN  safe_number_nr  rC  r9  safe_integer_2safe_symbolrD  rL  )r  r4  r  tiersr  rS  itemminimumNotionalr  marginCurrency
currencyIdr\  s               r  r  z"bitget.parse_market_leverage_tiers
  s`   ^ q#d))$$ 	& 	&A7D"00{NSSO*-,,T  4A  4A  4A  B  BK!//fjIIN,:,FVTZ^J''h77HLL++D'6BB**8V<< 33J??**)-););DBqBqBq)r)r#//jAA	 	 	 	 	 &KKr  r  sincer  c                 :   |                                   d}|                     |dd          \  }}|r|                     dd|||dddd	  	        S ||                                 dz
  }||                                 d}d}| |                     |          }|d	         |d
<   |||d<   |                     d||          \  }}|                     |                     ||                    }|                     |dg           }	| 	                    |	d||          S )a  
        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;  r6  parse_transactions)
r  r  r  r  r  r  r  r  r  rawTransactionss
             r  fetch_depositszbitget.fetch_deposits
  s^    	88R\]]& 	H33OT5RWY_amo{  ~B  DG  H  H  H=%%''*4E((**
 
 }}T**H&tnGFO$GG229gvNN@@WV\A]A]^^0 ..62>>&&eUKKKr  r  addresstagc                    |                      |           d}|                     |          \  }}|t          | j        dz             |                                  |                     |          }|                     |          }|d         |||                     |||          dd}	|||	d<   |                     | 	                    |	|                    }
| 
                    |
di           }|                     ||          }d|d	<   | 
                    | j        d
i           }|                     |dd          }|r||d<   ||d<   ||d<   ||d<   ||d<   ||d<   |S )a1  
        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   zbitget.withdraw  s    	7###"AA&IIV#DG.Z$Z[[[==&&++K88	TN..tV[II&
 
 ? GEN==dkk'SY>Z>Z[[ x44''h77%v//$,
BGG"&..B[]a"b"b" 	,!%F:%F8F5M 'F9")F; +F9r  c                 >   |                                   d}|                     |dd          \  }}|r|                     dd|||dddd	  	        S d}||                     |          }||                                 dz
  }||                                 d}||d	         |d
<   |                     d||          \  }}|||d<   |                     |                     ||                    }|                     |dg           }	| 	                    |	|||          S )a  
        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;  r6  r  )
r  r  r  r  r  r  r  r  r  r  s
             r  fetch_withdrawalszbitget.fetch_withdrawalsH  sg    	88ASU_``& 	K334FeUZ\bdpr~  AE  GJ  K  K  K}}T**H=%%''*4E((**
 
 &tnGFO229gvNN$GGCCDKKPWY_D`D`aa6 ..62>>&&%OOOr  transactionr  c                    |                      |d          }|                     ||          }|                     |d          }|                      |d          }|                      |d          }|                      |d          }|                      |d          }	d }
|	t          j        |	          }
d }|                      |d          }|
-||                     |
          d}t          j        ||
          }i d	|                      |d
          d|d|                      |d          d|d|                     |          d|                     |          d|                      |d          d|                      |d          d|                      |d          d|                     |          d|                      |d          d|d| 	                    |          d|                     |d          dd d|d|d d |dS )Nr  cTimer  r  r  r  r  r  r)  rE   orderIdr4  txidtradeId	timestampdatetimer  addressFromfromAddressr  	toAddressr  r  r  r  updateduTimetagFromtagTo)commentinternalr  )
rC  rD  r  r@   
string_absr  
string_subrG  r  parse_transaction_status)r  r  r  r  r  r  r  r  r  feeCostStringfeeCostAbsStringr  ro  s                r  r  zbitget.parse_transaction  s   N %%k6::
&&z8<<%%k7;;	$$['::	!!+x88{E22((e<<$&1-@@''V<<'#T->->?O-P-PQQC"-l<LMML
$"";	::
K
 D$$[)<<
 	

 Y//
 t..y99
 4++KGG
 t''[AA
 ))+{CC
 d''55
 D$$[&99
 
 d33F;;
 t((g>>
 t
  3!
" S#
$ )
 
 
 	
r  r  c                 @    dddddd}|                      |||          S )Nokpendingfailed)successPendingpending_reviewpending_review_failrejectrC  r  r  statusess      r  r  zbitget.parse_transaction_status  s7     '#+
 
 &&999r  c                 ~   |                                   d}|                     |          \  }}|                     |          }d|d         i}||                     ||          |d<   |                     |                     ||                    }|                     |di           }|                     ||          S )a  
        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;  r5  parse_deposit_address)r  r  r  r  r  r  r  r  s           r  fetch_deposit_addresszbitget.fetch_deposit_address  s     	"AA&IIV==&&HTN
 "#66{DIIGG@@WV\A]A]^^ ~~h33))$999r  c                    |                      |d          }|                      |d          }|                     ||          }d }||                     ||          }||||                      |d          |                      |d          dS )Nr  r  r  r  )r4  r  r  r  r  )rC  rD  r  )r  depositAddressr  r  r  parsedCurrencyr  s          r  r  zbitget.parse_deposit_address  s     %%nf==
$$^W==	00XFF --iHHG"&''	BB##NE::
 
 	
r  c                    |                                   |                     |          }d|d         i}|||d<   d}|                     ||          \  }}d}d}|                     |ddd          \  }}|r/||d<   |                     |                     ||                    }n`|d	         r*|                     |                     ||                    }n.||d
<   |                     |                     ||                    }|                     |di           }	|rdnd}
|rdnd}| 	                    |	d          }| 
                    |	|d         ||
|          S )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_bookzbitget.fetch_order_book  s    	V$$fTl
 $GG"AA&&QQV33F<LeUZ[[V 	\"-GJ99$++gv:V:VWWHHF^ 	\>>t{{7TZ?[?[\\HH%0GM"==dkk'SY>Z>Z[[H4 x44(##&(##&%%dD11	$$T6(+;YQXYYYr  tickerc           
         |                      |d          }|                     |dd          }|                     |d          }|                      |d          }|                      |d          }|	|dk    rd}nd	}|                      |d
          }	|	+|                      |d          }
t          j        |
d          }	|                     i d|                     ||d |          d|d|                     |          d|                     |dd          d|                     |dd          d|                     |dd          d|                     |dd          d|                     |dd          d|                     |dd           d!d d"|                     |g d#          d$|d%|d&d d'd d(|	d)d |                     |d*d+          |                     |d,d-          |                      |d.          ||d/|          S )0Nr  lastPr	lastPricer  r  	markPricer  r  rR   price24hPcnt	change24h100r  r  highhigh24hhighPrice24hlowlow24hlowPrice24hbidbidPr	bid1Price	bidVolumebidSzbid1SizeaskaskPr	ask1Price	askVolumeaskSzask1Sizevwapopen)r3  open24hopenPrice24hcloser  previousClosechange
percentageaverage
baseVolume	volume24hquoteVolumeturnover24h
indexPrice)r;  r=  r?  r  r4  )	rC  r  safe_integer_omit_zeror@   
string_mulsafe_tickerr  rG  safe_string_n)r  r  r  r\  r6  r  r  r  
marketTyper9  r  s              r  parse_tickerzbitget.parse_ticker]  s   P ##FH55""68[AA//==	##FJ77$$V[99	!F(:(:#JJJ%%fn==
((==I +Iu==J !
d&&xzJJ!
!
 Y//!
 D&&vy.II	!

 4%%fhFF!
 4%%fg{CC!
 ++FGZHH!
 4%%fg{CC!
 ++FGZHH!
 D!
 D&&v/R/R/RSS!
 U!
 E!
 T!
 d!
  *!!
" t#!
$ ,,V\;OO--fm]SS**6<@@"-!
 !
 !
. /  	r  c                 d   |                                   |                     |          }d|d         i}d}|                     ||          \  }}d}d}|                     |ddd          \  }}|r/||d<   |                     |                     ||                    }n`|d         r*|                     |                     ||                    }n.||d	<   |                     |                     ||                    }|                     |d
g           }| 	                    |d         |          S )a  
        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publicMixGetV2MixMarketTickerr6  rE  )	r  r  r  r  r  r  r  r   r  s	            r  fetch_tickerzbitget.fetch_ticker  sD    	V$$fTl
 "AA&&QQV33FM5RWXXV 	X"-GJ77GV8T8TUUHHF^ 	X<<T[[RX=Y=YZZHH%0GM"99$++gv:V:VWWHx ~~h33  a&111r  c                    |                                   |                     |          }d|d         i}d}|d         rt          | j        dz             d}|                     ||          \  }}||d<   |                     |                     ||                    }|                     |dg           }|                     |d         |          S )	a  
        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  r7   rE   r  "publicMixGetV2MixMarketSymbolPricer;  r6  rE  )r  r  r  r  r  r  r  r  s           r  fetch_mark_pricezbitget.fetch_mark_price  s     	V$$fTl
 &> 	]tw)^^___K"&"E"Eff"U"UK%0GM">>t{{7TZ?[?[\\H~~h33  a&111r  symbolsc                 $   |                                   d}|+|                     |d          }|                     |          }d}i }d}|                     d||          \  }}|                     |d          }d}	|                     ||          \  }	}d}
|                     |ddd          \  }
}|
rQt          |          }||dk    r|d         |d	<   |	|d
<   |                     | 	                    ||                    }n`|dk    r,|*| 
                    | 	                    ||                    }n.|	|d<   |                     | 	                    ||                    }|                     |dg           }|                     ||          S )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_paramsrC  r  r  r8  rG  r;  rH  publicMixGetV2MixMarketTickersr6  parse_tickers)r  rN  r  r  r  r  r  r  passedSubTyper  r   symbolsLengthr  s                r  fetch_tickerszbitget.fetch_tickers  s    	__Wa00F[[((F99.&RXYYf ((;;"AA&&QQV33FNESXYYV 
	YLLM#-1*<*<$*4L!"-GJ77GV8T8TUUHHV^^ 5<<T[[RX=Y=YZZHH%0GM"::4;;wPV;W;WXXHj ~~h33!!$000r  tradec                    |                      |d          }|                     ||          }|                     |g d          }d }|                     |d          }|                      |d          }|                      |d          }	|d up|	d u}
|
r|d         n|}|{|                     |                      |d                    }d|i}|                     |d	d
          }|                      |d          du }|r||d<   nt          j        |          |d<   |                     ||                     |dd          |                      |d          || 	                    |d          |                      |d          |                      |d          | 
                    |g d          | 
                    |g d          | 
                    |g d          ||                     |          |d|          S )Nr  )r  r  createdTime	feeDetailposModer  r   feeCoinr  totalFeer  yes	deductionTFr)  r  execIdr  side	orderType
tradeScope)priceAvgr  	execPrice)r;  r  execQty)r=  r  	execValue)r4  rE   orderr  r`  r  takerOrMakerr  r  r)  r  r  r  )rC  r  safe_integer_nr  rD  r  r@   
string_neg
safe_tradesafe_string_lowerrC  rG  )r  rV  r  r\  r  r  r  rY  rZ  r  isFeeStructurefeeStructurecurrencyCoder  r^  s                  r  parse_tradezbitget.parse_tradeF  s3   f ##E844!!(F33''/M/M/MNN	OOE;77	""5)44##E:66!-H843G'5Dy||9#2243C3CLR[3\3\]]LLC !..|ZOOM(({CCtKI @+F%0??F$$UIx@@%%eY77**5&99$$UK88 ,,ULAA''/Q/Q/QRR((0Q0Q0QRR&&u.T.T.TUU"Y// 
  
   	r  c           	         |                                   d}|                     |dd          \  }}|r|                     d||||dd          S |                     |          }d|d         i}d}|                     |ddd          \  }}|7|rt	          |d	          |d
<   n!|d         rt	          |d          |d
<   n||d
<   |                     | j        di           }	d}
d}|                     ||          \  }}|rU|dk    rd}|                     d|          \  }}|d}||d<   | 	                    | 
                    ||                    }
n|d         r|                     |	di           }|                     |dd          }|                     |d|          }|                     |d          }|dk    rL|                     d||          \  }}|||d<   |                     | 
                    ||                    }
n|dk    r)|                     | 
                    ||                    }
n|                     |	di           }|                     |dd          }|                     |d|          }|                     |d          }||d<   |dk    rK|                     d||          \  }}|||d<   |                     | 
                    ||                    }
n/|dk    r)|                     | 
                    ||                    }
|                     |
dg           }|                     ||||          S )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;  rC  r  r  r  rs  r  rt  r6  parse_trades)r  r  r  r  r  r  r  r  r   r  r  r  r  spotOptionsdefaultSpotMethod
spotMethodswapOptionsdefaultSwapMethod
swapMethodr  s                       r  fetch_tradeszbitget.fetch_trades  s   & 	88PZ[[& 	}33M65RWY_amo{|||V$$fTl
 33FM5RWXXV )#&uc??  
# )#&ud#3#3  #( //$,rBB"AA&&QQV  	[f$$!
%)%G%GW]%^%^"
F)"*K"-GJ55dkk'66R6RSSHHF^ 	[//'62>>K $ 0 0hHo p p))&(<MNNJYYvx00FDDD"&":":9gv"V"V$+0GK(EEdkkRY[aFbFbcc???>>t{{7TZ?[?[\\//'62>>K $ 0 0hHm n n))&(<MNNJYYvx00F%0GM"BBB"&":":9gv"V"V$+0GK(CCDKKPWY_D`D`aa===<<T[[RX=Y=YZZn ~~h33  vue<<<r  c                    |                                   |                     |          }d|d         i}d}|                     d|          \  }}|d         r|d|d<   nd|d<   nd|d<   |                     |                     ||                    }|                     |d	i           }|                     ||          S )
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_feezbitget.fetch_trading_fee`  s     	V$$fTl
 
!??@QSYZZ
F&> 	,%*2''*0''&+GN#99$++gv:V:VWW x44%%dF333r  c                 b   |                                   d}d}d}|                     d|          \  }}|                     dd|          \  }}|dk    r]|                     |dd          }|                     |d          }||r|                     |          }nu|                     |          }n_|dk    s|dk    r6d}|                     d|          \  }}||d<   |                     |          }nt          | j
        d	z   |z   d
z             |                     |dg           }i }t          dt          |                    D ]h}	||	         }
|                     |
d          }|                     |dd|          }|                     |          }|                     |
|          }|||<   i|S )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  rP  r>  r  r=  r<  r  r:  r7   rE   r  r7  r8  rC  r  r  r  )r  r  r  r  rD  rS   r  r  r[  rS  r  r\  r  r  r  s                  r  fetch_trading_feeszbitget.fetch_trading_fees  s    	

!??@RTZ[[
F!??@RTXZ`aa
F^^FHe<<FYYvx00F&6&AA&II@@HHF""
h(>(>K"&"E"EdF"S"SK$/F=!<<VDDHHtw)==
JYVWWWP x44q#d))$$ 	! 	!AGE''x88H%%hdJGGF[[((F((77C F6NNr  c                     |                      |d          }||                     ||          |                     |d          |                     |d          d d dS )Nr  r  r  )r4  r  r   r   r9  	tierBased)rC  r  rL  )r  r  r  r\  s       r  r  zbitget.parse_trading_fee  sh    ##D(33&&x88%%dN;;%%dN;;
 
 	
r  c           	      :   |                      |d          }|rdnd}|                     |d          |                     |d          |                     |d          |                     |d          |                     |d          |                     ||          gS )	Nr        r   r   r      r   )r>  r  rL  )r  ohlcvr  r  volumeIndexs        r  parse_ohlcvzbitget.parse_ohlcv  s     ..33")aaeQ''UA&&UA&&UA&&UA&&UK00
 	
r  r   	timeframec           	      	   |                                   d}d}d}|                     |dd          }	|                     |dd          }
d}|                     |dd	          \  }}|r!|
r|n|}|                     d||||||          S |                     |          }d
|d         i}d}d}d}|                     |ddd          \  }}|r.| j        d         d         }|                     |||          |d<   n9|d         rdnd}| j        d         |         }|                     |||          |d<   d}|                                 }|                     |          dz  }| 	                    |d          }|du}|du}|du}| 
                    |dg          }|d         rdnd}|                     | j        d         |i           }|                     |di           }| 	                    |||          }|                     | j        d         di           }| 	                    ||          }||dz
  |z  z
  }|r!t          ||          }t          ||          }n|}||z  } d}!d}"|r,|}!||d<   |s#|                     |!|           }"|"|k    r|}"|"|d<   |r|}"|"|k    r|}"|"|d<   |s|"| z
  }!d}#|!|!|k    s|	rUd}#t          ||          }||z  } |"| z
  }!|!|d<   |d         s,d}$|"|!z
  |$|z  k    r|                     |!|$|z            }"|"|d<   ||d<   d}%d}&d}'|                     |d          \  }'}|                     ||          \  }&}|rI|'|'dk    rd|d<   n|'d k    rd!|d<   |&|d"<   |                     |                     ||                    }%n3|d         r_|#r*|                     |                     ||                    }%n|sd|d<   d}|                     |                     ||                    }%n|&|d#<   |                     ||          }(|#sA|'dk    s|'d k    r5|sd|(d<   d}|                     |                     d$|'i|(                    }%nn|'dk    r|                     |(          }%nR|'d k    r|                     |(          }%n6|#r|                     |(          }%n|sd|(d<   d}|                     |(          }%|%d%k    rg S |                     |%d&|%          })|                     |)||||          S )'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  rr  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  rC  r  parse_timeframer  r  r5  r#  sumhandle_param_stringr  publicUtaGetV3MarketCandlesr;  'publicSpotGetV2SpotMarketHistoryCandlesr  r  )publicMixGetV2MixMarketHistoryMarkCandles*publicMixGetV2MixMarketHistoryIndexCandles%publicMixGetV2MixMarketHistoryCandlesr6  parse_ohlcvs)*r  r  r  r  r  r  defaultLimitmaxLimitForRecentEndpointmaxLimitForHistoryEndpointr  r  r  limitForPaginationr  r  rD  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_ohlcvzbitget.fetch_ohlcv  s   2 	$(!%("!^^F4H%PP*...Abdh*i*i'88zZZ& 	F?^!}!;!;d}::<QVX]_hjp  sE  F  F  FV$$fTl
 

33FL%QVWWV 	Xl3E:J"&"2"2:y)"T"TGJ#)&>=vJl3J?J%)%5%5j)Y%W%WGM"!!''	22T9!!&'22D(D(D(6G9-- v2ffFnnT\,%?bII#~~k;QSUVV#'#4#45I9V[#\#\  $t|L/IKfhj k k&*&7&78My&Y&Y##&*E*IW)T#T  	!899E788EE E"'("2 #  	7"'#(GK  7$(HH-@BY$Z$Z!$s**(+%%6	" 	R % 3&&$'!!2GI R&7:Q&Q# $) +0CG_0_0_dv0_'+$9::E&+h&6#"36M"M#6GK &> ;.0+$'::=X[b=bbb(,1DFadkFk(l(l%):GI& 	 44VWEE	6"AA&&QQV &	M$&&&,GFOO'))&-GFO"-GJ77GV8T8TUUHHF^ 	M' _GGT[]cHdHdee# !'+GG$ E@@WV\A]A]^^%0GM"{{7F33H+ Mf1D1D	U\H\H\# !(,HW% E  >>t{{KYbKcem?n?noof$$II(SSg%%JJ8TT+ M#II(SSHH' %,0) $#BB8LLHr>>I~~h99  vy%GGGr  c                    |                                   i }d}d}d}d}|                     |ddd          \  }}|                     dd|          \  }}|                     d|          \  }}|rl|                     |                     ||                    }|                     |di           }|                     |dg           }|                     |          S |dk    s|dk    rJd}	| 	                    d|          \  }	}|	|d	<   | 
                    |                     ||                    }n|d
k    r*|                     |                     ||                    }n}|dk    r*|                     |                     ||                    }nM|dk    r*|                     |                     ||                    }nt          | j        dz   |z   dz             |                     |dg           }
|                     |
          S )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  rP  r  privateUtaGetV3AccountAssetsr;  r5  r6  parse_uta_balancer  !privateMixGetV2MixAccountAccounts-privateMarginGetV2MarginIsolatedAccountAssets,privateMarginGetV2MarginCrossedAccountAssets!privateSpotGetV2SpotAccountAssetsr7   rE   r  parse_balance)r  r  r  rD  r  r  r   rV  r  r  r  s              r  fetch_balancezbitget.fetch_balance  s0   " 	

33FNESXYYV!??PTV\]]
F!??PVWW
F <	i88Wf9U9UVVHnnXvr::G^^GXr::F))&111F""
h(>(>K"&"E"EdF"S"SK%0GM"==dkk'SY>Z>Z[[HH:%%II$++V]_eJfJfggHH. 7""HHU\^dIeIeffHH, 6!!==dkk'SY>Z>Z[[HHtw)LLzY\gghhhZ x44!!$'''r  c                    d|i}t          dt          |                    D ]}||         }|                                 }|                     |d          }|                     |          }|                     |d          |d<   |                     |d          |d<   |                     |d          |d<   |                     |d	          |d
<   |||<   |                     |          S )Nr4  r   r  debtlockedused	availablefreebalancetotal)r7  r8  accountrC  rD  safe_balance)r  r  r[  rS  r  r  r  r  s           r  r  zbitget.parse_uta_balanceg  s    ( q#g,,'' 		# 		#AAJEllnnG))%88J**:66D"..uf==GFO"..uh??GFO"..ukBBGFO#//yAAGG"F4LL  (((r  c                 0   d|i}t          dt          |                    D ]_}||         }|                                 }|                     |dd          }|                     |          }|                     |d          }|a|                     |d          }	|                     |d          |d<   |                     |d	          |d
<   t          j        ||	          |d<   n|                     |d          }
|                     |d          }|||d<   |                     |d          |d
<   nI|
|d<   |                     |d          }|                     |d          }t          j        ||          |d<   |||<   a|                     |          S )Nr4  r   
marginCoinr  borrowinteresttransferabler  totalAmountr  r  r  maxTransferOutaccountEquityfrozenr  r  )	r7  r8  r  r  rD  rC  r@   
string_addr  )r  r  r[  rS  r  r  r  r  r  r  spotAccountFreecontractAccountFreer  r  s                 r  r  zbitget.parse_balance  s   (` q#g,,'' 	# 	#AAJEllnnG++E<HHJ**:66D%%eX66F!++E:>>"&"2"25."I"I#'#3#3E=#I#I ")"4VX"F"F #'"2"25+"F"F&*&6&6u>N&O&O#&2&9GFO'+'7'7'O'OGG$$&5GFO!--eX>>F!--eX>>F&-&8&H&HGFO"F4LL  (((r  c                     i dddddddddddddd	d
d	dd	dddddddddddddd	}|                      |||          S )Nnewr3  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_statuszbitget.parse_order_status  s    
6
F
 6
 F	

 f
 
 
 
 h
 J
 j
 
 

 F
 J
  !
$ &&999r  rg  c                 
   |                      |d          }|D|                     ||                      |d          |                     |dd          dd|          S |                      |d          }|d u}|rdnd	}||d
         }|                      |d          }|                     ||d |          }|                     |g d          }|                     |dd          }	|                     |g d          }
d }|                      |d          }|0|                     t          j	        |                    |d         d}| 
                    |d          }|                      |d          d u}|r^|                     |di           }|                      |d          }|                     t          j	        |                    |d         d}n|t          j        |          }t          |                                          }d }t!          dt#          |                    D ]$}||         }| 
                    |d          |} n%|                     t          j	        |                      |d                              |                     |                      |d                    d}d }|                     |dd          }|dk    rd}d}d }|                      |d          }|
|dk    rdnd}d }d }|                      |d           }|-|                      |d!          }|                      |d           }n.|                     |g d"          }|                      |d!          }d }d }|                      |d#          }||}|                      |d$          }n.|                     |d$d%          }|                     |d&d'          }|                      |d(          } |                      |d)          }!|!d*k    r|r
| d+k    rd,nd+} |                      |d-          }"| d+k    o|"d.k    }#|d	         r|#r|                      |d&          }|                     i d/|d0|                     |dd1          d|                     |dd          d2|d3|                     |          d4|	d5|	d|d         d
|"d(| d6|d7|d8|                     |d9d:          d;|d<|d=d d||||                     |d>          |                     |g d?          |                     |g d@          |                     |
          |d dA|          S )BNerrorMsgr  clientOrderId	clientOidr  )r4  rE   r  r  posSider  rR   r  r  r  ctimerX  r  updatedTime)r  stateorderStatus
planStatusr  r  )r)  r  rY  r  r   feeCoinCoder\  forcer  	POST_ONLYTr  
reduceOnlyNOF	basePricerc  )r  executePriceslLimitPricetpLimitPricebaseSizer  qtyr;  
cumExecQtyr`  rZ  
hedge_modebuysellra  r  r4  rE   r  r  r  lastTradeTimestamplastUpdateTimestampr  r  r)  r=  	quoteSizer:  r  	remainingr  )presetStopSurplusPricestopSurplusTriggerPrice
takeProfit)presetStopLossPricestopLossTriggerPricestopLoss)postOnlyr  r  r  r  r  r  trades)rC  
safe_orderr  safe_marketri  r  rC  r  r@   rj  r  r5  jsonloadsr?  valuesr7  r8  rD  safe_string_upper_2rG  rL  r  r  )$r  rg  r  errorMessager  isContractOrderrD  r\  r  updateTimestamp	rawStatusr  r  rY  r   	feeResultutaFeeparsedFeeDetail	feeValues	feeObjectrS  feeValuer  r  r  reduceOnlyRawr  r:  r   r  r  r  r`  rZ  ra  isBuyMarkets$                                       r  parse_orderzbitget.parse_order  s   j ''z::#??&&ui88!%!3!3E?K!X!X$	$ $
    ""5)44"$.#2>ZZ
J##E844!!(FD*EE''/P/P/PQQ	--eWmLL&&u.^.^.^__	((66$ ))'*<]*K*KLL"8, C OOE;77	uj11= 	y!R88I%%i77F))'*<V*D*DEE"8, CC
 $"&*Y"7"7 !7!7!9!9::	 	q#i..11  A(|Hx??K$,	 L !--g.@AQAQR[]gAhAh.i.ijj $ 7 78H8HTa8b8b c c  ..ug}MM+%%HK
((==$#0D#8#8tJ$$UK88	 $$UJ77E&&uk::GG&&u.g.g.ghhE&&uj99G##E:66D%%eV44FF%%eVU;;D''|\JJFv..""5)44l""z""emm66%D $$UK88	u}A9+@&> 	9k 	9##E<88D  
E 
$$$UIv>> 
 T//TT 
 	 

 Y// 
 !/ 
 "? 
 fX& 
 I 
 D 
 U 
 d 
 D&&um[II 
 w 
 f 
  ! 
" ;# 
$ !$ ,,UNCC#11%9|9|9|}}!//7r7r7rss--i883 
  
  
4 5  	r  r)  c                     |                                   |                     |          }|d         st          | j        dz             ddi}|                     |dd|d|                     ||                    S )az  
        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  r7   rE   create_orderr;  )r  r  r)  r  r  r}  s         r  !create_market_buy_order_with_costz(bitget.create_market_buy_order_with_cost*  s     	V$$f~ 	ftw)ddeee/
   5$dkkRUW]F^F^___r  r  r`  r  c                 6   |                                   |                     |          }|                     d|          }|d         }	|                     |dd          }
|                     |d          }|                     |d          }|                     |dd          }|d	u}|
d	u}|d	u}|d	u}|p|}d	}d	}|                     |dd
d          \  }}|rH|                     ||||||          }|r|                     |          }n| 	                    |          }n| 
                    ||||||          }|d         rf|r|                     |          }n|	dk    r|                     |          }ny|	dk    r|                     |          }n]|                     |          }nG|s|r|                     |          }n-|r|                     |          }n|                     |          }|                     |di           }|                     ||          S )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"privateMixPostV2MixOrderPlaceOrderr5  r(  )r  r  r  r`  r  r  r  r  marginParamsr  r  r  takeProfitTriggerPricer.  isTrailingPercentOrderisTriggerOrderisStopLossTriggerOrderisTakeProfitTriggerOrderisStopLossOrTakeProfitTriggerr  r   r  r  s                          r  r*  zbitget.create_order@  s|   \ 	V$$99-PP!!_
((nMM#vGG!%9J!K!K,,V5FXX!0!<%T1!5T!A#9#E (>(ZBZ%33FM5RWXXV 	P33FD$PUW]^^G, IGGPP??HH//dFESYZZGf~ P! R#LLWUUHH:--#OOPWXXHH7**#NNwWWHH#HHQQHH! P%; P#JJ7SSHH2 P#JJ7SSHH#FFwOOH ~~h33f---r  c                 x	   |                      |          }d }|                     ||          \  }}|dk    rd }	|                     d|          \  }	}|	d}||d         |                     ||          |d}
|                     |dd          }|||
d<   |                     |d          }|                     |d          }|                     |d	          }|                     |d
          }|                     |d          }|d u}|d u}|d u}|d u}|p|}|r)|r|                     |dd          }||
d<   | 	                    ||          |
d
<   |4| 	                    ||          |
d<   |                     |dd          |
d<   n|                     |dd          |
d<   n|r|                     |dd          }||
d<   | 	                    ||          |
d<   |4| 	                    ||          |
d<   |                     |dd          |
d<   n|                     |dd          |
d<   |                     |dd	g          }n|r| 
                    |dd          }|                     |d          }| 	                    ||          |
d
<   |4| 	                    ||          |
d<   |                     |dd          |
d<   n|                     |dd          |
d<   |r| 
                    |dd          }|                     |d          }| 	                    ||          |
d<   |4| 	                    ||          |
d<   |                     |dd          |
d<   n|                     |dd          |
d<   |dk    }|s| 	                    ||          |
d<   ||
d<   |                     |d          }d }|                     ||dk    |          \  }}|                     | j        d          }|                     |d|          }|rd|
d<   n#|dk    rd|
d<   n|dk    rd|
d<   n|d k    rd!|
d<   |                     |d"d#          } d }!|                     |d$d#          \  }!}| r|!s|r|d%k    rd&nd'}"|"|
d(<   n|sd)|
d"<   n|!r|d*k    rd&nd'}#|#|
d(<   |                     |g d+          }|                     |
|          S ),Nr  rd   r  rE   )r  r  r  r`  r  r  r  r  r  r  slTriggerByr  r  slOrderTyper  r  tpTriggerByr  tpOrderTyper  r-  r  ra  r  	post_onlyr  r  gtcr  fokr  iocr  Fr  r	  longshortr  r]  r  )r  r  r  r  r  )r  r  r  amount_to_precisionr  r  rL  r  rC  price_to_precisionrN  handle_post_onlysafe_string_upperr  r>  handle_param_boolr;  )$r  r  r  r`  r  r  r  r  r  r  r  r  r  r=  r  r  hasStopLosshasTakeProfitisStopLossTriggerisTakeProfitTriggerrB  slTypetpTypeslTriggerPricer  tpTriggerPricer  isMarketOrderexchangeSpecificTifParamr  r  r  r  r  reduceOnlyPosSider  s$                                       r  r1  zbitget.create_uta_order_request  s   V$$"AA&&QQV&  J!%!C!CMSY!Z!ZJ%&#Tl++FF;;	
 
 **6;PP$#0GK YYv77F#//HH!%!1!1&:K!L!L??6:66__V\::
d*"$.0<4D@(9(P=P%( 7	/  _))&-HH)/&&*&=&=fFZ&[&[
#$.2.E.Efe.T.TGN+-1-=-=fmU\-]-]GM**-1-=-=fmU]-^-^GM**$ _))&-HH)/&(,(?(?H^(_(_%$.2.E.Efe.T.TGN+-1-=-=fmU\-]-]GM**-1-=-=fmU]-^-^GM*YYv9J'KLLFF _!%!3!3Hnk!Z!Z#//'BB&*&=&=fn&U&U
#+.2.E.Efl.[.[GN+-1-=-=fmU\-]-]GM**-1-=-=fmU]-^-^GM* _!%!3!3JP[!\!\#//
GDD(,(?(?(W(W%+.2.E.Efl.[.[GN+-1-=-=fmU\-]-]GM**-1-=-=fmU]-^-^GM* H,M  J#'#:#:65#I#I #'GK '+'7'7'N'N$H#44]D\`kDkmsttHf!%!7!7FZ![![00HZ[[K /)4&&%%).&&%%).&&%%).&^^FL%@@
//%HH 		- .6 ./3v~~FFG!%6	""2 .(-% -%)U]]&&%,	"6#a#a#abb{{7F+++r  c                 $   |                      |          }d }d }	|                     d||          \  }}|                     d|          \  }	}|d         |d}
d }|                     |dd          \  }}d }|                     |d          \  }}|| }|dk    }|                     |dd	          }|                     |d
          }|                     |d          }|                     |d          }|                     |d          }|d u}|d u}|d u}|d u}|d u}|p|}|p|}|                     |d|                     |                    }|                     |dd          }|d u}| 	                    ||||          dk    rt          | j        dz             |dk    r|                     ||          |
d<   |                     |ddd          }|                     |dd          }|                     |dd          }|                     |dd          } d }!|                     || dk    |          \  }!}|                     | j        d          }"|                     |d|"          }#|!rd|
d<   n#|#dk    rd|
d<   n|#d k    rd |
d<   n|#d!k    rd!|
d<   |                     |g d"          }|d#k    s|d$k    r|d%         |
d&<   |                     ||          |
d'<   d }$|                     ||          \  }$}|$|
d(<   |||
d<   |s|s|r||
d<   |rW|st)          | j        d)z             |t+          | j        d*z             d+|
d,<   |                     ||          |
d	<   ||
d<   n|r4d-|
d,<   |                     ||          |
d	<   ||                     ||          |
d.<   |r{|                     |d	d          }%|                     ||%          |
d/<   |                     |d          }&|                     ||&          |
d0<   |                     |d1d          }'|'|
d2<   |r{|                     |d	d          }(|                     ||(          |
d3<   |                     |d          })|                     ||)          |
d4<   |                     |d1d          }*|*|
d5<   n|rx|st          | j        d6z             |r|d7k    rd8nd9|
d:<   n|d7k    rd;nd7|
d:<   |r|                     ||          |
d	<   d<|
d,<   n|r|                     ||          |
d	<   d=|
d,<   nd|r0|                     |d	d          }%|                     ||%          |
d><   |r0|                     |d	d          }(|                     ||(          |
d?<   |s;|	d@}	|	d@k    rdAndB}+|+|
dC<   |},|r|sdD|
d<   n|d;k    rd7nd;},dE|
dF<   n|rdG|
dF<   |,|
dH<   n|dIk    r|s|rt-          | j        dJz             ||
dH<   d }-d }.dK}/|                     |ddLdK          \  }/}|r|d;k    rdM}.|                     |dN          }0|                     |dN          }|0|                     ||0          }-n|/ro|t-          | j        dOz             |                     |          }1|                     |          }2t5          j        |1|2          }3|                     ||3          }-n/|                     ||          }-ndP}.|                     ||          }-|||
d<   |	dQ|
dR<   |r|d;k    r|-|
dS<   nk|-|
dT<   ne|-|-|
d'<   |>|.|
d,<   ||
d<   |                     ||          |
d	<   ||                     ||          |
d.<   nt9          | j        dUz   |z   dVz             |                     |
|          S )WNrd   rE   )r  ra  r  F
oneWayModer  r-  r  r  r  r  r  trailingTriggerPricer.  r/  r   zk createOrder() params can only contain one of triggerPrice, stopLossPrice, takeProfitPrice, trailingPercentr  r  r  triggerType
mark_pricer  r  r  r  r  rH  r  r  r  r  )r-  ra  r  r  r  r  r  r  r  r.  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	  rL  rM  holdSider  pos_loss
pos_profitr  r  r  crossedr  r  rt  Close	tradeSideOpenr`  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  rP  r  rR  r0  r  rC  number_to_stringr  r  r+   rE   rO  r>  rP  rQ  r  r  rN  r  r0   r/   r5   r  rL  cost_to_precisionr@   rA  r7   r;  )4r  r  r  r`  r  r  r  r  rD  r  r  r  r_  r[  r  r  r=  r  r  r?  r@  rA  rS  rT  rB  isStopLossOrTakeProfitr`  r.  r>  r  r  r  r\  r  r  r  r  rY  slPricerW  rZ  tpPricerX  marginModeRequestrequestSidequantityrd  r  r)  ro  rm  quoteAmounts4                                                       r  r4  zbitget.create_order_request  s6
   V$$

!??vW]^^
F!??vVV
FTl
 
 //%HH
!33FLII
F!#^F(((nMM#vGG!%9J!K!K??6:66__V\::
%T1!5T!A#9#E d*"$.(>(ZBZ%!,!=#//8NPTPePefkPlPlmm,,V5FXX!0!<88N$:<TVlmmpqqq  +X  !X  Y  Y  Y7??#66vuEEGG--f6H-Yeff^^FL%@@
**6;PP#'#5#5fg}#U#U 00@X\g@giopp&!33DLBVWW,,V]DVWW 	%*GGE!!$GGE!!$GGE!!$GG6  $T  $T  $T  U  U&  jH&<&<$*:$6GL!"66vvFFGFOK"&"E"Eff"U"UK%0GM"('4$ :!> :BX :)9&% .h$ n$TW/l%lmmm'/+DG  7E  -E  F  F  F&2
#*.*A*A&J^*_*_'+:(( &h&3
#*.*A*A&,*W*W'$.2.E.Efe.T.TGN+ <%)%7%7.R]%^%^N6:6M6MfVd6e6eG23"..xAAG6:6M6MfV]6^6^G23!--hMMF5;G12  ?%)%7%7
NT_%`%`N9=9P9PQWYg9h9hG56"..z7CCG9=9P9PQWY`9a9aG56!--j&,OOF8>G45. h$ '2}(}~~~ P59V^^&&'GJ''48FNN%%GJ') 7.2.E.EfNb.c.cGN+*4GJ''- 7.2.E.EfNd.e.eGN+*6GJ' e%)%6%6xQ\%]%]N595L5LVUc5d5dG12  h%)%6%6z>S^%_%_N8<8O8OPVXf8g8gG450 .%!(J2<2G2GIIj!(9%" 	6! 705-- 26ffU/6,, 6/5,"-6!!, P0F P"47  .O  $O  P  P  P"GFOHH04-8<8U8UV\^k  nQ  SW  9X  9X5-v D$%--"''776622##55fdCCHH6 	F}*47  6q  ,q  r  r  r'+'<'<V'D'D&*&;&;E&B&B&-&8{&S&S#'#9#9&+#N#N#55ffEEHH#33FFCC('4$%&.
#  3demm+3GK((*2GJ'''&.GFO+*2GJ'-=GM*.2.E.Efl.[.[GN+(262I2I&RW2X2X/tw)KKjX[ddeee{{7F+++r  ordersc           	      h   |                                   g }d }d }t          dt          |                    D ]#}||         }|                     |d          }||}n||k    rt	          | j        dz             |                     |d          }	|                     |d          }
|                     |d          }|                     |d          }|                     |di           }|                     d	|          }|d         }|"||}n||k    rt	          | j        d
z             |                     ||	|
|||          }|	                    |           %| 
                    |          }|                     |          }|                     |dg           }|                     ||          S )Nr   r  ; createOrders() requires all orders to have the same symbolr  r`  r  r  r  re   S createOrders() requires all orders to have the same margin mode(isolated or cross)r  )r  r7  r8  rC  r0   rE   r  r  r1  r9  r  privateUtaPostV3TradePlaceBatchr6  parse_orders)r  r|  r  ordersRequestsr  r  rS  rawOrderr\  r  r`  r  r  orderParamsmarginResultcurrentMarginModeorderRequestr  r  r  s                       r  create_uta_orderszbitget.create_uta_orders  s   
q#f++&& 	0 	0AayH''(;;H~!X%%$TW/l%lmmm##Hf55D##Hf55D__Xx88FOOHg66E//(HbAAK==nkZZL ,Q ,%!2JJ!%666(  4I  *I  J  J  J884vW\^ijjL!!,////V$$77GG ~~h33  v...r  c           	         |                                   d}|                     |ddd          \  }}|r|                     ||          S g }d}d}t          dt	          |                    D ]#}||         }|                     |d          }	||	}n||	k    rt          | j        dz             |                     |d          }
|                     |d	          }|                     |d
          }|                     |d          }|                     |di           }| 	                    d|          }|d         }|"||}n||k    rt          | j        dz             | 
                    |	|
||||          }|                    |           %|                     |          }|d         |d}d}|d         s|d         rT|d}|dk    rdnd}||d<   |d         |d<   d}|                     ||          \  }}||d<   |                     |          }nM|dk    r|                     |          }n1|dk    r|                     |          }n|                     |          }|                     |di           }|                     |dg           }|                     |dg           }|                     ||          }|                     ||          S )aw  
        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  r`  r  r  r  r  rE   )r  	orderListrT   rU   r  rm  r  r  r  r  r  r  failureListsuccessList)r  r  r  r7  r8  rC  r0   rE   r  r  r4  r9  r  r  'privateMixPostV2MixOrderBatchPlaceOrder0privateMarginPostV2MarginIsolatedBatchPlaceOrder/privateMarginPostV2MarginCrossedBatchPlaceOrder%privateSpotPostV2SpotTradeBatchOrdersrB  r  )r  r|  r  r   r  r  r  rS  r  r\  r  r`  r  r  r  r  r  r  r  r  r  rx  r  r  failure	orderInfoboths                              r  create_orderszbitget.create_orders  sK    	33FNESXYYV 	:))&&999
q#f++&& 	0 	0AayH''(;;H~!X%%$TW/l%lmmm##Hf55D##Hf55D__Xx88FOOHg66E//(HbAAK==nkZZL ,Q ,%!2JJ!%666(  4I  *I  J  J  J44XtT6SXZeffL!!,////V$$Tl'
 
 6N 	Kx 0 	K!$
.8G.C.C		*$5GL!$*:$6GL!K"&"E"Eff"U"UK%0GM"CCGLLHH:%%LLWUUHH7""KKGTTHHAA'JJH0 x44//$r::OOD-<<	  G44  v...r  rE   c                    |                                   |                     |          }i }	|                     |dd          }
|
|                     |dg          }|
|	d<   n||	d<   |dk    }|                     |dd          }|du}|                     |d          }|du}|                     |d	          }|du}|                     |d
          }|                     |d          }|du}|du}|                     |d|                     |                    }|                     |dd          }|du}|                     ||||          dk    rt          | j
        dz             |                     |g d          }d}d}d}|                     ||          \  }}|                     |ddd          \  }}|r||                     ||          |	d<   |s|rR|r|                     |dd          }||	d<   |                     ||          |	d
<   |4|                     ||          |	d<   |                     |dd          |	d<   n|                     |dd          |	d<   n|r|                     |dd          }||	d<   |                     ||          |	d<   |4|                     ||          |	d<   |                     |dd          |	d<   n|                     |dd          |	d<   |                     |dd	g          }|                     |                     |	|                    }n||                     ||          |	d<   |                     |                     |	|                    }nB|d         r|                     |d           }|                     |d           }|                     | j        d!d"          }|s||r~|d#k    rx||t)          | j
        d$z             |                     |          } |                     |          }!|t+          j        | |!          n|}"|                     ||"          |	d%<   n|                     ||          |	d%<   ||	d&<   |3|                     ||          |	d<   |                     ||          |	d'<   n|                     ||          |	d<   |+|                     |                     |	|                    }n|d(         |	d)<   |                     |                     |	|                    }n|d*         s+|d+         s#t3          | j
        d,z   |d-         z   d.z             |d(         |	d)<   ||	d/<   |s:|s8||                     ||          |	d0<   ||s|                     ||          |	d1<   |rd|st5          | j
        d2z             ||                     ||          |	d3<   ||	d<   |                     |                     |	|                    }n|s|r|d4         |	d5<   |                     ||          |	d%<   ||                     ||          |	d'<   |r|                     ||          |	d<   n|r|                     ||          |	d<   |                     |                     |	|                    }n|r=|                     ||          |	d3<   |r{|                     |dd          }#|                     ||#          |	d6<   |                     |d          }$|                     ||$          |	d7<   |                     |d-d8          }||	d9<   |r{|                     |dd          }%|                     ||%          |	d:<   |                     |d          }&|                     ||&          |	d;<   |                     |d-d8          }||	d<<   |                     |                     |	|                    }n|                                 }'|                     |d=d>|'          }(|                     |d>          }|(|	d=<   |r0|                     |dd          }#|                     ||#          |	d?<   |r0|                     |dd          }%|                     ||%          |	d@<   |                      |                     |	|                    }| !                    |dAi           })| "                    |)|          S )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  r-  r  r  r  r  r  r`  r.  newCallbackRatior   zi editOrder() params can only contain one of triggerPrice, stopLossPrice, takeProfitPrice, trailingPercent)	r-  ra  r  r  r  r  r  r`  r.  rq   r   Fr  rD  r  r  rE  r  rF  r  rG  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  ra  r  rE   r  rT   rU   z editOrder() does not support r  rr  r  newSizenewPricez9 editOrder() bitget trailing orders must be market ordersnewTriggerPricer  r  newStopLossTriggerPricenewStopLossExecutePricerb  newStopLossTriggerTypenewSurplusTriggerPricenewStopSurplusExecutePricenewStopSurplusTriggerTypenewClientOidnewClientOrderIdnewPresetStopLossPricenewPresetStopSurplusPricer  )#r  r  r  r  r0  r  rC  rs  r  r+   rE   r  r  rN  rO  (privateUtaPostV3TradeModifyStrategyOrderr;   privateUtaPostV3TradeModifyOrderr>  r  r5   r@   rA  )privateSpotPostV2SpotTradeModifyPlanOrder,privateSpotPostV2SpotTradeCancelReplaceOrderr7   r0   'privateMixPostV2MixOrderModifyPlanOrder'privateMixPostV2MixOrderModifyTpslOrderrN  rL  uuid#privateMixPostV2MixOrderModifyOrderr5  r(  )*r  rE   r  r  r`  r  r  r  r  r  r  r[  r  r?  r  isStopLossOrderr  isTakeProfitOrderr  r  rS  rT  r`  r.  r>  r  r  r   rW  rX  r)  r  ro  rm  	finalCostrY  rv  rZ  rw  defaultNewClientOrderIdr  r  s*                                             r  
edit_orderzbitget.edit_orderG  sg
   H 	V$$
 **6?KPP$YYv'899F#0GK  !#GI(((nMM%T1@@'t3//&2CDD+47??6:66__V\::
d*"$.#//8NPTPePefkPlPlmm,,V5FHZ[[!0!<88NO5FH^__bccc  +V  !V  W  W  W6  $z  $z  $z  {  {"AA&&QQV33FKPUVVV l	b!!%!9!9&&!I!I _"3 _" c!--fmVLLF-3GM**.*A*A&-*X*XGJ'(262I2I&RW2X2X/151A1A&-Y`1a1a..151A1A&-Ya1b1b..& c!--fmVLLF-3GM*,0,C,CFO,\,\GL)(262I2I&RW2X2X/151A1A&-Y`1a1a..151A1A&-Ya1b1b.6O=N+OPPHHU\^dIeIeff$'+'>'>vu'M'MGG$@@WV\A]A]^^F^ P	b##FF33DYYvv..F.2nnT\Klnr.s.s+/ 	KD4D=4D^bfk^k^k=T\&tw  2a  (a  b  b  b#'#8#8#@#@L"&"7"7">">KTXT`!3L+!N!N!NgkI&*&=&=fi&P&PGFOO"&":":66"J"J#'GK '*.*A*A&,*W*W'*.*A*A&%*P*P''#'#:#:65#I#I 'II$++V]_eJfJfgg$*4L!LLT[[Y`bhMiMijj6N lVH-= l"47-M#MPVW]P^#^aj#jkkk &tGH%0GM"$ Q_ Q%)-)A)A&&)Q)QGI&%/E%*.*A*A&%*P*PGJ'% -b$ l$TW/j%jkkk'3151H1HQe1f1fG-..=*+GGT[]cHdHdee" &bo &b(.z(:%"&":":66"J"J$.2.E.Efe.T.TGN+" _.2.E.Efm.\.\GN++& _.2.E.Efo.^.^GN+GGT[]cHdHdee b-1-D-DV\-Z-Z)* ?%)%7%7.R]%^%^N9=9P9PQWYg9h9hG56"..xAAG9=9P9PQWY`9a9aG56!--hMMF8>G45  B%)%7%7
NT_%`%`N8<8O8OPVXf8g8gG45"..z7CCG<@<S<STZ\c<d<dG89!--j&,OOF;AG78GGT[]cHdHdee*.))++'#'#5#5fnN`by#z#z 6+=>>*:' h%)%6%6xQ\%]%]N8<8O8OPVXf8g8gG45  k%)%6%6z>S^%_%_N;?;R;RSY[i;j;jG78CCDKKPWY_D`D`aa ~~h33f---r  c                    |t          | j        dz             |                                  |                     |          }d}d}|                     d|          \  }}i }|                     |d          }|                     |dd          }	|                     |g d          }|d         r|	s|d	         |d
<   d}
|                     |ddd          \  }
}|	p|}|d         p|d         }|o|o|
 }| 	                    |dd          }|rBg }i }||                     |d          }||d<   n||d<   |
                    |           ||d<   n#||                     |d          }||d<   n||d<   |
rX|	r+|                     |                     ||                    }n|                     |                     ||                    }n|d         s|d         rd}|                     ||          \  }}||d<   |rG|                     |dd          }||d<   |                     |                     ||                    }n:|	r+|                     |                     ||                    }n|                     |                     ||                    }n|d         r|`|dk    r*|                     |                     ||                    }n|dk    r)|                     |                     ||                    }ny|	r*|                     |                     ||                    }nM|                     |                     ||                    }n#t-          | j        dz   |d         z   dz             |                     |di           }d}|r |                     |dg           }|d         }n	|
r|	r|}n|}|                     ||          S )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  rd  rc  r  r  z  cancelOrder() does not support r  rr  r  r  r   )r/   rE   r  r  r  r  r0  r  r  r  r9  (privateUtaPostV3TradeCancelStrategyOrderr;   privateUtaPostV3TradeCancelOrderr  rC  'privateMixPostV2MixOrderCancelPlanOrder#privateMixPostV2MixOrderCancelOrder,privateMarginPostV2MarginIsolatedCancelOrder+privateMarginPostV2MarginCrossedCancelOrder)privateSpotPostV2SpotTradeCancelPlanOrder%privateSpotPostV2SpotTradeCancelOrderr7   r(  )r  rE   r  r  r  r  r  r  r  r  r   isPlanOrder
isContractisContractTriggerEndpointr  r  r  r  rd  r  rg  r  s                         r  cancel_orderzbitget.cancel_order  ss   0 >#DG.Y$YZZZV$$
!??vVV
F??6:66##FFI>>6#B#B#BCCv 	-7 	- &tGH33FM5RWXXV)F^7vh'7
$.$J;$Js7!**6?KPP$ 	(KG(6?;;'4$$%'	"w'''%0GM""(6?;;'4$$%'	" 	j _HHU\^dIeIeff@@WV\A]A]^^Vn 	j&"2 	jK"&"E"Eff"U"UK%0GM" b++FJMM&.
#GGT[]cHdHdee bGGT[]cHdHdeeCCDKKPWY_D`D`aaF^ 	j%++#PPQUQ\Q\]dflQmQmnnHH7**#OOPTP[P[\cekPlPlmmH h#MMdkkZaciNjNjkkHH#II$++V]_eJfJfggHHtw)KKfU[n\_hhiiif x44$ 	mR@@IaLEE w  v...r  c                    |t          | j        dz             |                                  |                     |          }d }|                     ||          \  }}g }t          dt          |                    D ]+}||         }||d         |d}	|                    |	           ,|                     |          }
| 	                    |
dg           }| 
                    ||          S )N* cancelOrders() requires a symbol argumentr   rE   )r  r  r  r  )r/   rE   r  r  r  r7  r8  r9   privateUtaPostV3TradeCancelBatchr6  r  )r  idsr  r  r  r  requestListrS  individualIdrg  r  r  s               r  cancel_uta_orderszbitget.cancel_uta_orders  s    >#DG.Z$Z[[[V$$"AA&&QQVq#c((## 	& 	&Aq6L' ,' E
 u%%%%88EE ~~h33  v...r  r  c                    |t          | j        dz             |                                  |                     |          }d}|                     |ddd          \  }}|r|                     |||          S d}|                     d|          \  }}|                     |dd          }|                     |ddg          }g }t          dt          |                    D ]#}	||	         }
d	|
i}|                    |           $d
|d         i}|d         r|||d<   n||d<   d}|d         r|Z|dk    r*|                     |                     ||                    }n|                     |                     ||                    }n|                     |                     ||                    }nud}|                     ||          \  }}||d<   |r*|                     |                     ||                    }n)|                     |                     ||                    }|                     |di           }|                     |dg           }|                     ||          S )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  r0  r  r7  r8  r9  0privateMarginPostV2MarginCrossedBatchCancelOrderr;  1privateMarginPostV2MarginIsolatedBatchCancelOrder*privateSpotPostV2SpotTradeBatchCancelOrderr  r  )privateMixPostV2MixOrderBatchCancelOrdersr  r6  r  )r  r  r  r  r  r   r  r  r  rS  r  r  r  r  r  r  r|  s                    r  cancel_orderszbitget.cancel_orders  s   & >#DG.Z$Z[[[V$$33FNESXYYV 	?))#vv>>>
!??PVWW
F##FFI>>6FI#677q#c((## 	( 	(Aq6L<G w''''fTl
 &> 	1z1#.GK  %0GM"&> 	h%((#TTUYU`U`ahjpUqUqrrHH#UUVZVaVabikqVrVrssHHJJ4;;W^`fKgKghhK"&"E"Eff"U"UK%0GM" hGGT[]cHdHdeeII$++V]_eJfJfgg" x44mR88  000r  c           	         |t          | j        dz             |                                  |                     |          }d}|                     d|          \  }}d}|                     ||          \  }}d|d         i}|                     |dd          }|                     |ddg          }d}d}	|                     |ddd	          \  }	}|	r:|d
k    r|d}||d<   | 	                    | 
                    ||                    }na|d         r|t          | j        dz             |r5d|d         gi}
|                     | 
                    |
|                    }n)|                     | 
                    ||                    }|                     |d          }|                     |d          }|                     |d          }|                     ||                     |ddd          ||                     |          d          gS ||d<   |r*|                     | 
                    ||                    }n)|                     | 
                    ||                    }|                     |d          }|                     |g d          }|                     |dd          }d}|||                     ||          }n|}|                     |          S )a  
        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  )r4  r  r  r  r  )
resultListr  r?  r  r  )r/   rE   r  r  r  r  safe_bool_2r  r  &privateUtaPostV3TradeCancelSymbolOrderr;  r7   .privateSpotPostV2SpotTradeBatchCancelPlanOrder+privateSpotPostV2SpotTradeCancelSymbolOrderr  r5  rC  r  r  rG  r  r  safe_list_nsafe_list_2rB  r  )r  r  r  r  r  r  r  r  r  r   stopRequestr  responseDatar\  r  r  r  responseLists                     r  cancel_all_orderszbitget.cancel_all_orders  sS   " >#DG.]$]^^^V$$
!??@QSYZZ
F"AA&&QQVfTl
 ""669==6FI#67733F<MuV[\\V :	hf$$)"*K"-GJBB4;;wX^C_C_``HH  F^ %	h%"47  .F  $F  G  G  G n$vd|n)K  $RRSWS^S^_jlrSsSsttHH#OOPTP[P[\cekPlPlmmH !--hFF	#~~h??++L(CCOO ("&"2"28T4"P"P%.$(LL$;$;	% %    &1GM" hGGT[]cHdHdeeII$++V]_eJfJfgg ~~h//%%d,Q,Q,QRR
&&tYFF")@,,ZEELL%L  ...r  c                    |t          | j        dz             |                                  |                     |          }i }|                     |dd          }||                     |dg          }||d<   n||d<   d}d}|                     |ddd          \  }}|r*|                     |                     ||                    }n|d	         r*| 	                    |                     ||                    }n|d
         s|d         rU|d         |d<   d}	| 
                    ||          \  }	}|	|d<   |                     |                     ||                    }n#t          | j        dz   |d         z   dz             |s)t          |t                    rt          j        |          }|                     |d          }
|
+t          |
t$                    s|                     |
|          S |                     |dg           }t+          |          }|dk    r3t-          | j        dz   |z   dz   |                     |          z             |                     |di           }|                     ||          S )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  rr  r  r   z& fetchOrder() could not find order id z in )r/   rE   r  r  r  r  r  privateUtaGetV3TradeOrderInfor;  "privateSpotGetV2SpotTradeOrderInfor  privateMixGetV2MixOrderDetailr7   
isinstancerK  r  r  r5  r?  r(  r6  r8  r6   )r  rE   r  r  r  r  r  r  r   r  r  dataListdataListLengthfirsts                 r  fetch_orderzbitget.fetch_order  s    >#DG.X$XYYYV$$
 **6?KPP$YYv'899F#0GK  !#GI33FL%QVWWV 	i99$++gv:V:VWWHHF^ 		i>>t{{7TZ?[?[\\HHF^ 	ivh/ 	i &tGHK"&"E"Eff"U"UK%0GM"99$++gv:V:VWWHHtw)JJVTZ^[^gghhh`  	,
8S11 	,z(++H~~h//dD)) 6''f555>>(FB77XQ*R RUW WZ` `cgclclmucvcv vwwwxB//v...r  c           	      (
   |                                   d}d}i }d}|                     d|          \  }}d}	|                     |ddd          \  }	}|c|                     |          }|d         |d<   |                     | j        ddd          }
d	|v r|d	         n|
}|                     |d	|          }n4|                     | j        ddd          }
|                     |d	|
          }d}|                     |dd
          \  }}|r7d}d}|	rd}d}n|dk    r|d}d}nd}d}|                     d||||||          S d}|                     |d          }| 	                    |dd          }|                     |d          du}|p|}| 
                    d||          \  }}|||d<   |||d<   |	sB|dk    s|dk    s|4|                     |dd          }|                     |d          }|||d<   d}|                     ||          \  }}|                     |g d          }|	rg|dk    r|d}||d<   |r+|                     |                     ||                    }n|                     |                     ||                    }n|dk    r|||                                 dz
  }||d<   |dk    r+|                     |                     ||                    }nE|dk    r)|                     |                     ||                    }n|r*|                     |                     ||                    }n|                     |                     ||                    }n||d <   |rF|                     |dd!          }||d<   |                     |                     ||                    }nq|rF|                     |dd"          }||d<   |                     |                     ||                    }n)|                     |                     ||                    }|                     |d#          }|	rKd}|r|                     |d#g           }n|                     |d$g           }|                     ||||          S |dk    r4||r/|                     |d%g           }|                     ||||          S n/|                     |d&g           }|                     ||||          S |                     ||||          S )'ap  
        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  rd  r  r  r  rT   rU   r  r  )r  r  r  r  r  r  r  r  r  r  rc  re  r  r?  r  entrustedList)r  r  r  r  r  r  rC  r  r>  r  r  r  r  *privateUtaGetV3TradeUnfilledStrategyOrdersr;  "privateUtaGetV3TradeUnfilledOrdersr  *privateMarginGetV2MarginIsolatedOpenOrders)privateMarginGetV2MarginCrossedOpenOrders)privateSpotGetV2SpotTradeCurrentPlanOrder'privateSpotGetV2SpotTradeUnfilledOrders(privateMixGetV2MixOrderOrdersPlanPending$privateMixGetV2MixOrderOrdersPendingr  r6  r  )r  r  r  r  r  r  r  r  r  r   r  rD  r  cursorReceived
cursorSentr  r  r  planTypeDefined	isTriggerr  r  rd  r  r[  r  s                             r  fetch_open_orderszbitget.fetch_open_orders.  s   2 	
!??@QSYZZ
F33F<MuV[\\V[[((F &tGH,,T\;Lm]cddK,2f,<,<;J##FFJ??DD,,T\;Lm]cddK##FFK@@D88ART^__& 	A!NJ 	*!)%

)%,N!-J!()
334EvuV[]cesu  A  A  A>>&*55""669==**6:>>dJ/	229gvNN#(GK $GG 	5TX-=-=:CY ..v{OTTMYYv77F('4$"AA&&QQV6#J#J#JKK "	cv~~)"*K"-GJ aJJ4;;W^`fKgKghhBB4;;wX^C_C_``V^^%= --//*<E+0GK(++#NNt{{[bdjOkOkllHH7**#MMdkkZaciNjNjkkH j#MMdkkZaciNjNjkkHH#KKDKKX_agLhLhiiHH%0GM" 	c++FJMM&.
#HHU\^dIeIeff c++FJNN&.
#HHU\^dIeIeffDDT[[QXZ`EaEabbz x00 	CF :&"==fb99$$VVUEBBBV^^&7&!^^D+rBB
((VUEJJJ ' ^^D/2>>F$$VVUEBBB  vue<<<r  c                     |                                   |                     ||||          }|                     |dd          S )a  
        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_orderszbitget.fetch_closed_orders  sE    0 	66vueVTT~~fh999r  c                     |                                   |                     ||||          }|                     |dd          S )a  
        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_orderszbitget.fetch_canceled_orders  sE    0 	66vueVTT~~fh
;;;r  c           	      L	   d}|                      |ddd          \  }}|r|                     ||||          S |                                  d}i }| |                     |          }|d         |d<   d}|                     d||          \  }}d}	|                     d|          \  }	}d}
|                      |dd          \  }
}|
r*d}|dk    r|	d	}nd
}|                     d|||||d          S d}|                     |d          }|                     |dd          }| 	                    |g d          }| 
                    d||          \  }}|||d<   |||d<   |dk    s|dk    s|	4|                     |dd          }| 	                    |d          }|||d<   |                                 }|dk    r"|	n|
|dz
  }||d<   |	dk    r+|                     |                     ||                    }n|	dk    r)|                     |                     ||                    }n|r|t!          | j        dz             |                     |ddg          }| 	                    |dg          }|
|dz
  }||d<   |||d<   |                     |                     ||                    }n|                     |                     ||                    }nd}|                     ||          \  }}||d<   |                     |d          du}|rF|                     |dd          }||d<   |                     |                     ||                    }ns|s|rF|                     |dd          }||d<   |                     |                     ||                    }n)|                     |                     ||                    }|                     |d i           }|dk    r2|	|r-|                     |                     |d!g           |||          S n-|                     |                     |d"g           |||          S t7          |t8                    rt;          j        |          }|                     |d g           }|                     ||||          S )#a  

        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  rd  rc  re  r  r  r  ) r  $fetch_uta_canceled_and_closed_ordersr  r  rP  r  r  r>  r  r  r  r  r  -privateMarginGetV2MarginIsolatedHistoryOrdersr;  ,privateMarginGetV2MarginCrossedHistoryOrdersr/   rE   ri  )privateSpotGetV2SpotTradeHistoryPlanOrder&privateSpotGetV2SpotTradeHistoryOrdersr  rC  (privateMixGetV2MixOrderOrdersPlanHistory$privateMixGetV2MixOrderOrdersHistoryr  r  r  rK  r  r  r6  )r  r  r  r  r  r   r  r  rD  r  r  r  r  r  r  r  r  r  r  r  rd  r  r|  s                          r  r  z'bitget.fetch_canceled_and_closed_orders  s   4 33F<Z\achiiV 	[<<VUESYZZZ[[((F &tGH
!??@^`fhnoo
F
!??@^`fgg
F88A_akll& 	P!NV##)%,N!(334RTZ\achjp  sA  CO  P  P  P>>&*55""669==6#B#B#BCC229gvNN#(GK $GG&  jH&<&<*BX ..v{OTTMYYv77F('4$!!%=*,E+0GK(++#QQRVR]R]^egmRnRnooHH7**#PPQUQ\Q\]dflQmQmnnH e>+DG6r,rsss--fy'6JKK6G955=*,E+0GK(?),GI&II$++V]_eJfJfggFFt{{SZ\bGcGcddK"&"E"Eff"U"UK%0GM""..vzBB$NO 	c++FJMM&.
#HHU\^dIeIeff cO c++FJNN&.
#HHU\^dIeIeffDDT[[QXZ`EaEabbf x44&7&(({B)O)OQWY^`efff ' $$T__T?B%O%OQWY^`efffh$$ 	,z(++H&"55  >>>r  c           	      >   |                                   d }||                     |          }d }|                     ||          \  }}|dk    rd }|                     d|          \  }}|d}d|i}d}	|                     |dd          \  }	}|	r|                     d||||dd          S |                     d||          \  }}|||d	<   |||d
<   d }
|                     |dd          }|                     |ddg          }|r*| 	                    | 
                    ||                    }
n)|                     | 
                    ||                    }
|                     |
di           }|                     |dg           }|                     ||||          S )Nr  rw   r  r  Fr  r  r  r  r  r  r  r  r?  )r  r  r  r  r  r  r  r  r  )privateUtaGetV3TradeHistoryStrategyOrdersr;  !privateUtaGetV3TradeHistoryOrdersr5  r6  r  )r  r  r  r  r  r  r  r  r  r  r  r  r  r|  s                 r  r  z+bitget.fetch_uta_canceled_and_closed_orders  s   [[((F"AA&&QQV&  J!%!C!CDbdj!k!kJ%&
 88A_akll& 	F334RTZ\achjprz  }E  F  F  F229gvNN#(GK $GG""669==6FI#677 	\EEdkkRY[aFbFbccHH==dkk'SY>Z>Z[[Hh ~~h33fb11  >>>r  c           	         |                                   |                     |d          }|                     |d          }d}||                     |          }d}|                     d||          \  }}d}|                     |dd          \  }}|r%d}	|dk    rd}	|                     d|||||	d          S d}
i }| |                     |          }
|
d	         |d
<   |                     d||          \  }}|||d<   |||d<   d}|dk    r*| 	                    | 
                    ||                    }nV||d	         |d<   d}|                     ||          \  }}||d<   |                     | 
                    ||                    }|                     |d          }|dk    s|dk    r/|                     |dg           }|                     ||
||          S |                     ||
||          S )a  
        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-entry-structure>`
        r  Nr   Fr  rR   r  r  rE   r  r  r  r  r  r  rT   rU   bills)r  rC  r  r  rP  r  r  r  r   privateSpotGetV2SpotAccountBillsr;  r  privateMixGetV2MixAccountBillr  parse_ledger)r  r  r  r  r  r  r  rD  r  r  r  r  r  r  r  r  s                   r  fetch_ledgerzbitget.fetch_ledger{  sO   " 	!!&(3368,,[[((F
!??vW]^^
F88PZ[[& 	!NV##!(33M65RWY_aoq}~~~}}T**H&tnGFO229gvNN#(GK $GG<<T[[RX=Y=YZZHH!$*4L!K"&"E"Eff"U"UK%0GM"99$++gv:V:VWWHZ x00&  jH&<&<OOD'266E$$UHeUCCC  x>>>r  r  c                    |                      |d          }|                     ||          }|                     ||          }|                     |d          }|                     |d          }|                     |dd          }|                     |dd          }|                     t          j	        |                    }	d}
|
                    d	          d
k    rd}
|                     ||                      |d          ||                     |          |
d d d |                     |                      |d                    ||	d |d ||dd|          S )Nr  r  r  r   r  r  r  inr	  r   outbillIdr  r  )r4  rE   r  r  	directionr  referenceIdreferenceAccountr  r  r  beforeafterr  r  )rC  rD  safe_currencyr  rL  rN  r  r  r@   r  findsafe_ledger_entryrG  parse_ledger_type)r  r  r  r  r  r  r  r  	amountRawr  r  s              r  parse_ledger_entryzbitget.parse_ledger_entry  su   8 %%dF33
&&z8<<%%j(;;%%dG44	  y11  vu55&&tVX>>	""7#5i#@#@AA	>>#!##I%%""422"Y//" $**4+;+;D.+Q+QRR  '
 '
& '  	r  c                    i ddddddddddddddd	dd
dddddddddddddddddi ddddddddddddddddddd dd!dd"dd#d$d%d$d&d'd(d'd)d'ddd*d+ddd,}|                      |||          S )-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_longrV  
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  r  z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 tT222r  c           	          d}|                      |ddd          \  }}|s|t          | j        dz             |                                  |                     |          }i }|                     d||          \  }}|||d<   |||d<   d}d}	|                      |dd	          \  }}|                     d|          \  }	}|r9d}
d}|rd
}
d
}n|d         r|	d}
d}nd}
d}|                     d|||||
|          S d}|r+|                     | 	                    ||                    }n|d         |d<   |d         r|	||| 
                                dz
  |d<   |	dk    r*|                     | 	                    ||                    }n|	dk    r)|                     | 	                    ||                    }ns|                     | 	                    ||                    }nId}|                     ||          \  }}||d<   |                     | 	                    ||                    }|                     |d          }|r/|                     |dg           }|                     ||||          S |d         s|d         r/|                     |dg           }|                     ||||          S |	/|                     |dg           }|                     ||||          S |                     ||||          S )a  
        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  r?  rT   rU   fillListfills)r  r/   rE   r  r  r  r  r  privateUtaGetV3TradeFillsr;  r  %privateMarginGetV2MarginIsolatedFills$privateMarginGetV2MarginCrossedFillsprivateSpotGetV2SpotTradeFillsr  privateMixGetV2MixOrderFillsr  r6  rv  )r  r  r  r  r  r   r  r  r  r  r  r  r  r  r  rJ  s                   r  fetch_my_tradeszbitget.fetch_my_tradesJ  s   & 33FOUTYZZV 	]#DG.[$[\\\V$$229gvNN#(GK $GG
88R\]]&!??QWXX
F 	!NJ 	*!)%

 *)%,N!-J!()
33OVUTY[acqs}~~~ 	[55dkk'66R6RSSHH &tGHf~ [)}/3/@/@/B/BZ/O,!Z//#'#M#MdkkZaciNjNj#k#k#w..#'#L#LT[[Y`bhMiMi#j#j#BB4;;wX^C_C_``HH"&*&I&I&RX&Y&Y#V)4&<<T[[RX=Y=YZZH x00 	BNN444E$$UFE5AAAVn 	B!1 	BNN4R88E$$UFE5AAA#NN4"55E$$UFE5AAA  vue<<<r  c                    |                                   |                     |          }d}|                     ||          \  }}d|d         i}d}d}d}|                     |ddd          \  }}|r]||d<   |                     |                     ||                    }|                     |di           }	|                     |	d	g           }nP|d
         |d<   ||d<   |                     |                     ||                    }|                     |dg           }|                     |di           }
| 	                    |
|          S )aD  
        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  r?  r  r  r  r   )
r  r  r  r  &privateUtaGetV3PositionCurrentPositionr;  r5  r6  (privateMixGetV2MixPositionSinglePositionparse_position)r  r  r  r  r  r  r  r   r[  r  r  s              r  fetch_positionzbitget.fetch_position  sg    	V$$"AA&&QQVfTl
 33FOUTYZZV M	:"-GJBB4;;wX^C_C_``HN >>(FB77D^^D&"55FF$*:$6GL!%0GM"DDT[[QXZ`EaEabbH> ^^Hfb99Fvq"--""5&111r  c           	         |                                   d}|                     |dd          \  }}|r|                     dddd|dd          S d}|                     |dd          }|rd}n|                     |dd	d
          \  }}d}|-|                     |d          }||                     |          }d}|                     ||          \  }}i }	d}
d}d}|                     |ddd          \  }}|r/||	d<   |                     |                     |	|                    }
n|d
k    r|                     |dd          }|	|d         }nI|dk    rd}n@|dk    rd}n7|dk    rd}n.|dk    rd}n%|dk    s|dk    r|t          | j
        dz             ||	d<   ||	d<   |                     |                     |	|                    }
n=d}||d         |	d<   ||	d<   |                     |                     |	|                    }
g }|s|r/|                     |
di           }|                     |d g           }n|                     |
dg           }g }t          dt!          |                    D ]1}|                    |                     ||         |                     2|                     |          }|                     |d|d          S )!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  r?  )r  r  r  r>  rC  r  r  rR  r;  r/   rE   r  rW  r5  r6  r7  r8  r9  rT  market_symbolsfilter_by_array_positions)r  rN  r  r  r  r  r  r  r  r  r  	isHistoryr   r  positionr  r[  rS  s                     r  fetch_positionszbitget.fetch_positions  s   $ 	88AQS]^^& 	w334DdDRVX^`giuvvv!^^F4H%PP 	H@FF!::6CSU]  `G  H  HNFF$$Wa00E U++"AA&&QQV	33F<LeUZ[[V 	d"-GJBB4;;wX^C_C_``HH>>>))&,GGJ!#J/

..#

..#

//$

//$

00k^6S6S%+DG  7G  -G  H  H  H$.GL!%0GM"AA$++gW]B^B^__HHI!$*4L!%0GM"EEdkkRY[aFbFbccHL  	<) 	<>>(FB77D~~dFB77HH~~h;;Hq#h--(( 	D 	DAMM$--hqk6BBCCCC%%g..--fhOOOr  r[  c                 
   |                      |d          }|                     ||d d          }|d         }|                     |g d          }|                      |d          }d }d }|                     |dd          }	|                     |dd          }
|d	k    rt	          j        |
|	          }n
|d
k    rd}|
}|                     |dd          }d }|dk    rd}n|dk    rd}|                     |dd          }|                      |d          }|                     |d          }|                     |          }|                     |dd          }|                     |g d          }|                      |d          }t	          j	        ||          }|t	          j
        ||          }|                     t	          j
        ||                    }||                     |d          }|                      |d          }t	          j	        ||          }t	          j
        ||          }|                     |                     |                      |d                              }d}d}||d	k    rt	          j        |d          rt	          j
        |
|          }|}|d k    r(t	          j        |          }t	          j        |          }t	          j        d!|          }t	          j        ||          }|d"k    rt	          j	        ||          }nt	          j	        ||          }|                     t	          j
        ||                    }t	          j	        ||          } t	          j        t	          j	        ||          |           }!t	          j	        t	          j
        |	|d#          d$          }"|                     i d%|d&|                     |d'd(          d|d)|                     |          d|d|d*|                     |          d+|                     |	          d,|                     |g d-          d.|                     |"          d/|d|d|                     |          d0|                     |d1d2          d3|d4|d5||                     |          |                     |d6d7          |                     |!          |                     |          |                     |          |                     |          |                     |          |                     |          |                     |d8d9          d d d:          S );Nr  r  r  r  unrealizedPLunrealisedPnl
marginSizepositionBalancer  rm  r  rZ  holdModer  Tone_way_modeFrj  r  r(  r,  r  openTotalPos)openPriceAvgopenAvgPriceavgPricer  closeTotalPosr  liquidationPricer   z0.9994rv  rM  r   rL  r   r  r4  rE   r  
positionIdnotional
entryPriceunrealizedPnlrealizedPnl)pnlcurRealisedPnlcumRealisedPnlr9  	contractsr  closeAvgPriceclosePriceAvgr`  r  r  utimer  marginRatior  )r  r  maintenanceMarginmaintenanceMarginPercentage
collateralinitialMargininitialMarginPercentager(  rv  r  r  )rC  r  ri  r  r@   r  r  rs  rC  rA  
string_divr  rL  	omit_zero	string_gtrj  r  safe_positionr  rN  rG  r  )#r  r[  r  r\  r  r  r  ry  rz  rm  rawCollateralrb  r  r`  r(  contractSizeNumberr,  
baseAmountrl  rx  openNotionalrr  r  rk  r{  ri  calcTakerFeeRatecalcTakerFeeMultsignedMargin	signedMmpmmrMinusOne	numerator
feeToCloserw  r9  s#                                      r  rT  zbitget.parse_position<  s   D ##Hh77!!(FD*EE!''2S2S2STT	%%h==

**8^_UU**8\CTUU## +M=IIJJ9$$ J)M%%h	:FF|##FF''F!!(J	BB##Hj99!__V^DD,,-?@@'''>JJ
''2^2^2^__
&*&6&6xAQ&R&R#)*jAA #.|XFFM%%g&8\&R&RSS	((?CCI$$X{;;	%j)<<")"4]H"M"M,,T^^D<L<LXWi<j<j-k-kll##$:+C+CIZ[egjIkIk+C"-mZHHL3Iw&1,??#.y99	!,S)<<K*:|DDIv~~%0>NOO#.y:JKK	#001CI{1[1[\\'2BCC
#.w/AB]_g/h/hjtuu'(:=-YZ([([]bcc
!! #
H#
$$$Xy,GG#
 f#
 ))(33	#

 *#
  0#
 $++J77#
 T..}==#
 4--h8c8c8cdd#
 $++J77#
 #
 .#
 **955#
 ++HoWW#
 D#
  f!#
" ##
$ Y//#'#6#6x-#X#X!%!2!23D!E!E+/+<+<=X+Y+Y++J77!..}=='+'8'89P'Q'Q))(33--huMM!#9#
 #
 #
   	r  c           
         |t          | j        dz             |                                  |                     |          }d|d         i}d}d}d}	d}
|                     ||          \  }}|                     |ddd          \  }}|rd|||d<   ||d	<   |                     |                     ||                    }	|                     |	d
i           }| 	                    |dg           }
nd}|                     |dd          \  }}|r| 
                    d||||dd          S |||d<   ||d<   |                     |                     ||                    }	| 	                    |	d
g           }
g }t          dt          |
                    D ]}|
|         }|                     |d          }|                     ||          }|                     |dd          }|                    |||                     |d          ||                     |          d           |                     |d          }|                     ||d         ||          S )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)r4  r  r  r  r  r  )r/   rE   r  r  r  r  #publicUtaGetV3MarketHistoryFundRater;  r5  r6   fetch_paginated_call_incremental&publicMixGetV2MixMarketHistoryFundRater7  r8  rC  r  r  r9  rL  rG  sort_byfilter_by_symbol_since_limit)r  r  r  r  r  r  r  r  r   r  r[  r  r  ratesrS  r  r\  symbolInnerr  sorteds                       r  fetch_funding_rate_historyz!bitget.fetch_funding_rate_history  s    >#DG.e$efffV$$fTl
 "AA&&QQV33F<UW\^cddV .	: #( "-GJ??GU[@\@\]]H" >>(FB77D^^D,;;FFH#<<VE^`jkkHf E<<=VX^`eglntv~  AD  E  E  E &+
#%0GM"BB4;;wX^C_C_``H ^^Hfb99Fq#f++&& 	 	A1IE''x88H**8V<<K++E=BXYYILL%#//}EE& LL33      e[11009I5RWXXXr  c                    |                                   |                     |          }|d         st          | j        dz             d}|                     ||          \  }}d|d         i}d}d}|                     |ddd          \  }}|r*|                     |                     ||                    }n||d	<   d}|                     |dd
d          \  }}|dk    r*|                     |                     ||                    }n/|dk    r)| 	                    |                     ||                    }| 
                    |dg           }	|                     |	d         |          S )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  r6  parse_funding_rate)
r  r  r  r  r  r  r   r  r  r  s
             r  fetch_funding_ratezbitget.fetch_funding_rateo  s    	V$$f~ 	ZDG&XXYYY"AA&&QQVfTl
 33F<NPUW\]]V +	a??GU[@\@\]]HH& &1GM"F!::6CUW_  bJ  K  KNFFAAAFFt{{SZ\bGcGcdd$ ???BB4;;wX^C_C_`` ~~h33&&tAw777r  c                 L   |                                   d}|+|                     |d          }|                     |          }i }d}|                     ||          \  }}d}|                     |dd|          \  }}d}||d<   |dk    r*|                     |                     ||                    }n/|dk    r)|                     |                     ||                    }|                     |          }| 	                    |dg           }	| 
                    |	|          S )	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   rQ  r   r  r  r  r  )r  r  r  r  r  rQ  r;  r  rX  r6  parse_funding_rates)
r  rN  r  r  r  r  r  r  r  r  s
             r  fetch_funding_rateszbitget.fetch_funding_rates  s>    	__Wa00F[[((F"AA&&QQV166v?RT\^dee!,555B ::4;;wPV;W;WXXHH???$ BB4;;wX^C_C_``H%%g..~~h33''g666r  c                     |                                   |                     ddi|          }|                     ||          S )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  rN  r  s      r  fetch_funding_intervalszbitget.fetch_funding_intervals   sF     	h(PQSYZZ''888r  c                 6   |                      |d          }|                     ||d d          }|                     |dd          }|                     |dd          }|                     |d          }|                     |d          }|                     |d	          }	d }
||d
z   }
i d|d|d|d	|	dd dd d|d|                     |          d|                     |d          d|d|                     |          dd dd dd dd dd dd d|
iS )Nr  rT   nextFundingTime
nextUpdate
ratePeriodfundingRateIntervalr  r  r?  hr4  interestRateestimatedSettlePricer  r  r  fundingTimestampfundingDatetimenextFundingRatenextFundingTimestampnextFundingDatetimepreviousFundingRatepreviousFundingTimestamppreviousFundingDatetimer  )rC  r  r  r  r  rL  rG  )r  r  r  r\  r  r  r  r  r  r?  intervalStrings              r  r  zbitget.parse_funding_rate'   s   r ##Hh77!!(FD&AA..x9JLYY%%h>STT%%h55	$$X{;;	%%h==
%^N
H
f
 
 *	

 D
 #D
 
 Y//
 4++HmDD
  0
 t||,<==
 t
 #D
 "4
 "4
  '!
" &t#
$ %
 
 	
r  c           	         |                                   |t          | j        dz             d}|                     |ddd          \  }}d}|                     |dd          \  }}|r8|r|                     d||||dd          S |                     d||||dd	          S |                     |          }|d
         st          | j        dz             d}|                     ||          \  }}i }	|                     d|	|          \  }	}|||	d<   |||	d<   d}
|r:|d         |	d<   ||	d<   | 	                    | 
                    |	|                    }
nI|d         |	d<   |d         |	d<   d|	d<   ||	d<   |                     | 
                    |	|                    }
|                     |
di           }|                     |ddg           }|r|                     |dddgd          }|                     ||||          S )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 argumentr   r   Fr  r  r  r  rT   z3 fetchFundingHistory() supports swap contracts onlyr  r  r  r  r  r  rE   r  r  r:  r  r  r  r  r?  r   CONTRACT_MAIN_SETTLE_FEE_USER_IN!CONTRACT_MAIN_SETTLE_FEE_USER_OUT)r  r/   rE   r  r  r  r1   r  r  &privateUtaGetV3AccountFinancialRecordsr;  r  r  r  filter_by_arrayparse_funding_histories)r  r  r  r  r  r   r  r  r  r  r  r  r  s                r  fetch_funding_historyzbitget.fetch_funding_history   s    	>#DG.a$abbb33F<QSXZ_``V88AVXbcc& 	@ A778MvW\^cekmuw  A  A  A334I6SXZ_agipr~V$$f~ 	]DG&[[\\\"AA&&QQV229gvNN#(GK $GG  	X$Z0GFO"-GJBB4;;wX^C_C_``HH2 !'tGH$*:$6GL!&;GN#%0GM"99$++gv:V:VWWH. x44  w;; 	J((9[  ^A  9B  DI  J  JE++E65%HHHr  c                 f   |                      |d          }|                      |d          }|                     |dd          }||                     ||d d          ||                     |          |                     |          |                     |d          |                     |dd          d	S )
Nr  r  r  r  rT   r  r  rE   )r4  r  r  r  r  r  rE   )rC  r  r  rG  rD  rL  r  )r  r  r  r\  r  r  s         r  parse_funding_historyzbitget.parse_funding_history   s    2 ##Hh77%%h77
'''4@@	&&xvFF"Y//++J77&&x::$$Xx>>
 
 	
r  c                    g }t          dt          |                    D ]3}||         }|                    |                     ||                     4|                     |d          }d }	||d         }	|                     ||	||          S )Nr   r  r  )r7  r8  r9  r  r  r  )
r  rr  r  r  r  r[  rS  r  r  r  s
             r  r  zbitget.parse_funding_histories!  s    q#i..)) 	H 	HA |H MM$44XvFFGGGGfk22H%F00NNNr  c                    |                                   |                     |d          }|                     |          }d }|                     ||          \  }}|d         |d         |                     ||          ||d}|                     |d          }|                     |                     ||                    }	|                     |                     |	|          | 	                    |          |d          S )Nrj  rE   r  )r  r  r  rj  r  )r  r  )
r  rC  r  r  rN  r  #privateMixPostV2MixAccountSetMarginr;  parse_margin_modificationr  )
r  r  r  r  r  rj  r  r  r  r  s
             r  modify_margin_helperzbitget.modify_margin_helper!  s   ##FJ77V$$"AA&&QQVTl ,..vv>> &
 
 6:..;;DKKQW<X<XYY {{499(FKK''//N
 N
   	r  r  c                 t    |                      |d          }|dk    rdnd}||d         d dd d |d         |d d d
S )	Nr  00000r  r  r  r  r  )
r4  r  r  r  r  r  r  r  r  r  r  )r  r  r  	errorCoder  s        r  r  z bitget.parse_margin_modification3!  sc     $$T622	#w..XX&$8$
 
 	
r  c                     |dk    rt          | j        dz             |                     |d          }|t          | j        dz             |                     ||d|          S )a  
        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=margin-structure>`
        r   z9 reduceMargin() amount parameter must be a negative valuerj  NzC reduceMargin() requires a holdSide parameter, either long or shortrJ  )r0   rE   rC  r/   r  r  r  r  r  rj  s        r  r=  zbitget.reduce_marginM!  sn     A::TW'bbccc##FJ77#DG.s$sttt((6JJJr  c                     |                      |d          }|t          | j        dz             |                     ||d|          S )a|  
        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=margin-structure>`
        rj  Nz@ addMargin() requires a holdSide parameter, either long or shortadd)rC  r/   rE   r  r  s        r  
add_marginzbitget.add_margin_!  sO     ##FJ77#DG.p$pqqq((GGGr  c                 Z   |                                   |                     |          }d}|                     ||          \  }}|d         |d         |d}|                     |                     ||                    }|                     |di           }|                     ||          S )ae  
        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;  r5  parse_leverager  r  r  r  r  r  r  r  s           r  fetch_leveragezbitget.fetch_leverageo!  s     	V$$"AA&&QQVTl ,&
 

 88Wf9U9UVV: ~~h33""4000r  r(  c                     |                      |d          dk    }|rdnd}|rdnd}||d         |rdnd|                     ||          |                     ||          d	S )
Nr  rm  crossedMarginLeverageisolatedLongLeverisolatedShortLeverr  r  r  )r4  r  r  longLeverageshortLeverage)rC  r  )r  r(  r  isCrossMarginMode
longLevKeyshortLevKeys         r  r  zbitget.parse_leverage!  s     ,,X|DD	Q0AZ,,GZ
1B\--H\X&%6F''J --h
CC!..xEE
 
 	
r  c                 n   |t          | j        dz             |                                  |                     |          }d}|                     ||          \  }}|d         |                     |          d}d}d}|                     |ddd          \  }}|r_|dk    rd}	|                     d	|          \  }	}|	d
}|d         |d<   ||d<   |                     | 	                    ||                    }n9|d         |d<   ||d<   | 
                    | 	                    ||                    }|S )a  
        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  rs  r  r  "privateUtaPostV3AccountSetLeverager;  %privateMixPostV2MixAccountSetLeverage)
r  r(  r  r  r  r  r  r   r  r  s
             r  set_leveragezbitget.set_leverage!  sn    >#DG.Y$YZZZV$$"AA&&QQVTl--h77
 
 33FM5RWXXV 	`f$$!
%)%G%GW]%^%^"
F)"*K$Z0GFO"-GJ>>t{{7TZ?[?[\\HH %+:$6GL!%0GM"AA$++gW]B^B^__H  r  r  c                    |t          | j        dz             |                                }|dk    rd}|dk    r|dk    rt          | j        dz             |                                  |                     |          }d}|                     ||          \  }}|d         |d         ||d	}|                     |                     ||                    }|S )
at  
        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  rm  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_modezbitget.set_margin_mode!  s     >#DG.[$[\\\%%''
  "J*$$:+B+B#DG.u$uvvvV$$"AA&&QQVTl ,$&	
 
 ??GU[@\@\]] r  r  c                    |                                   |rdnd}i }d}||                     |          }d}d}d}	|                     ||          \  }}|                     |ddd          \  }}|r/||d<   |                     |                     ||                    }	n3||d<   ||d	<   |                     |                     ||                    }	|	S )
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  rc  Nr   r   Frb  rZ  r  )r  r  r  r  "privateUtaPostV3AccountSetHoldModer;  )privateMixPostV2MixAccountSetPositionMode)
r  r  r  r  rZ  r  r  r  r   r  s
             r  set_position_modezbitget.set_position_mode"  s    	"(<,,n[[((F"AA&&QQV33F<MuV[\\V 	d")GJ>>t{{7TZ?[?[\\HH ")GI%0GM"EEdkkRY[aFbFbccH r  c                 2   |                                   |                     |          }|d         st          | j        dz             d}|                     ||          \  }}d|d         i}d}d}|                     |ddd          \  }}|r/||d	<   |                     |                     ||                    }n.||d
<   |                     |                     ||                    }| 	                    |di           }| 
                    ||          S )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;  #publicMixGetV2MixMarketOpenInterestr5  parse_open_interest)	r  r  r  r  r  r  r   r  r  s	            r  fetch_open_interestzbitget.fetch_open_interestQ"  s8    	V$$j! 	^TW'\\]]]"AA&&QQVfTl
 33F<OQVX]^^V 	^"-GJ<<T[[RX=Y=YZZHH$ &1GM"??GU[@\@\]]H" ~~h33''f555r  c           	      X   |                      |ddg           }|                     |d          }|                     |d         d          }|                     |                     ||d d          |                     |d         dd          d ||                     |          |d	|          S )
NopenInterestListr?  r  r   r  r  r  openInterest)r  openInterestAmountopenInterestValuer  r  r4  )r  r  rC  safe_open_interestr  rN  rG  )r  r  r  r  r  r\  s         r  r  zbitget.parse_open_interest"  s    4 *<fbII%%h55	##DGX66&&&&xzJJ"&"4"4T!Wfn"U"U!%"Y//(
 (
   	r  c                    |t          | j        dz             |                                  d}|                     dd|          \  }}|                     |d|          }|                     |d          }|                     | j        di           }|                     ||          }|                     |          }|d         |d}	|||	d<   |||	d	<   | 	                    d
|	|          \  }	}| 
                    |                     |	|                    }
|                     |
dg           }|                     ||||          S )a  
        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  rP  rC  r  r  r  r  r  *privateSpotGetV2SpotAccountTransferRecordsr;  r6  parse_transfers)r  r  r  r  r  r  r  r  r  r  r  r  s               r  fetch_transferszbitget.fetch_transfers"  sa    <#DG.Z$Z[[[99:JDRXYYf&&v}dCC6=117GLL<<==&&TN
 
 #(GK $GG229gvNNBB4;;wX^C_C_``, ~~h33##D(E5AAAr  r  	toAccountc                 |   |                                   |                     |          }|                     | j        di           }|                     ||          }|                     ||          }	||	||d         d}
|                     |d          }|                     |d          }d}| |                     |          }|d         |
d<   |                     |                     |
|                    }|                     |di           }| 	                    |d          |d<   | 
                    ||          S )	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   )r  toTyper  r  r  Nr  r  r  )r  r  r  r  rC  r  r  #privateSpotPostV2SpotWalletTransferr;  r  parse_transfer)r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  s                  r  r   zbitget.transfer"  sA    	==&&7GLL##NK@@!!.)<< TN	
 
 !!&(3368,,[[((F &tGH;;DKKQW<X<XYY x44&&x??T
""4222r  r   c                 N   |                      |d          }|                     |d          }|                     |d          }|                     |d          }|                     | j        di           }|                     |||          }|                     |d          }	|                     ||	|	          }
||                     |d          ||                     |          |                     ||          |                     |d          ||
|                     |          d		S )
Nr  r  r  r  r  r  
transferIdr  )	r4  rE   r  r  r  r  r  r  r  )	r  rl  rC  r  r  rG  rD  rL  parse_transfer_status)r  r   r  r  r  r  fromAccountRawr  r  toAccountRawr  s              r  r  zbitget.parse_transfer!#  s&   2 %%h55	''(;;%%h77
))(J??t|^RHH&&|^^TT''(;;$$\<NN	""8\::"Y////
HEE&&x88&"0088

 

 
	
r  c                 8    ddi}|                      |||          S )N
successfulr  r  r  s      r  r  zbitget.parse_transfer_statusN#  s(    $
 &&999r  c                    |                      |dg           }t          |          }|d d dd d di d}t          d|          D ]}||         }|                     |d          }|                     |d          }	|                     ||	          }
d d d|                     |d          ddd	|d
         |
<   |dk    r*|                     |d          |d         d<   d|d         d<   |S )Nr  )r  r9  )r4  r   r  r  r   r  r  r  F)r  r   r  r   r   r  r9  )r  r8  r7  rC  r  rL  )r  r  r  r  r  r[  rS  r  r  ro  r  s              r  parse_deposit_withdraw_feez!bitget.parse_deposit_withdraw_feeT#  s;   . h336{{" 
 "  
 
 q,'' 	9 	9A1IE((88I++Hf==L11)\JJK#'t<<$($4$4UM$J$JZ_``/ /F:{+ q  ,0,<,<UM,R,Rz"5)38z"<0r  codesc                     |                                   |                     |          }|                     |dg           }|                     ||d          S )ae  
        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  r6  parse_deposit_withdraw_fees)r  r  r  r  r  s        r  fetch_deposit_withdraw_feesz"bitget.fetch_deposit_withdraw_fees#  sX     	66v>>< ~~h33//eVDDDr  c                 >   |                                   |                     |          }|d         |                     ||          d}|                     |                     ||                    }|                     |di           }|                     ||          S )a  
        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_marginzbitget.borrow_cross_margin#  s     	==&&TN 66tVDD
 
 EEdkkRY[aFbFbcc x44%%dH555r  c                 x   |                                   |                     |          }|                     |          }|d         |                     ||          |d         d}|                     |                     ||                    }|                     |di           }	|                     |	||          S )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  r
  r  r  )r  r  r  r  .privateMarginPostV2MarginIsolatedAccountBorrowr;  r  r  
r  r  r  r  r  r  r  r  r  r  s
             r  borrow_isolated_marginzbitget.borrow_isolated_margin#  s     	==&&V$$TN 66tVDDTl
 

 FFt{{SZ\bGcGcdd x44%%dHf===r  c                 x   |                                   |                     |          }|                     |          }|d         |                     ||          |d         d}|                     |                     ||                    }|                     |di           }	|                     |	||          S )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  r  r  s
             r  repay_isolated_marginzbitget.repay_isolated_margin#  s     	==&&V$$TN55dFCCTl
 

 EEdkkRY[aFbFbcc x44%%dHf===r  c                 >   |                                   |                     |          }|d         |                     ||          d}|                     |                     ||                    }|                     |di           }|                     ||          S )a  
        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  r  r  )r  r  r  ,privateMarginPostV2MarginCrossedAccountRepayr;  r  r  r  s           r  repay_cross_marginzbitget.repay_cross_margin$  s     	==&&TN55dFCC
 
 DDT[[QXZ`EaEabb x44%%dH555r  c                 "   |                      |d          }|                      |d          }d }||                     ||d d          }|                     |dd          |                     ||          |                     |dd          |d d |dS )	Nr  r  rR   loanIdrepayIdr
  r  )rE   r  r  r  r  r  r4  )rC  r  r  rD  rN  )r  r4  r  r  r  r\  r  s          r  r  zbitget.parse_margin_loanA$  s    L %%dF33
##D(33%%hfEEF$$T8Y??//
HEE((~}MM
 
 	
r  c           	         |                                   d}|                     |dd          \  }}|r|                     d||||dd          S d}||                     |          }d}|                     d||          \  }}|dk    rt          | j        dz             i }|                     d	||          \  }}|||d
<   n|                                 dz
  |d
<   |||d<   d}	d}
| 	                    d|d          \  }
}|
dk    rN|t          | j        dz             |d         |d<   |                     |                     ||                    }	n/|
dk    r)|                     |                     ||                    }	|                     |	di           }|                     |dg           }|                     ||||          S )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  rP  r7   rE   r  r  r  r/   2privateMarginGetV2MarginIsolatedLiquidationHistoryr;  1privateMarginGetV2MarginCrossedLiquidationHistoryr  r6  parse_liquidations)r  r  r  r  r  r  r  r  r  r  r  r  liquidationss                r  fetch_my_liquidationszbitget.fetch_my_liquidationsv$  s     	88AVXbcc& 	@334I6SXZ_agipr~[[((F99:OQWY_``f6>>tw)ccddd229gvNN#(GK  #'#4#4#6#6#CGK $GG
!??@UW]_fgg
F##~'2e(efff &tGHNNt{{[bdjOkOkllHH7""MMdkkZaciNjNjkkHj x44~~dL"==&&|VUEJJJr  c                    |                      |d          }|                     |d          }|                     |dd          }|                      |d          }t          j        ||          }|                     ||                     ||          d d d d |                     |          ||                     |          d	          S )Nr  
liqEndTimeLiqFeeliqFee	totalDebt)	r4  r  rr  r,  r  	baseValue
quoteValuer  r  )	rC  r  r  r@   r  safe_liquidationr  r  rG  )r  liquidationr  r\  r  liquidationFeer'  quoteValueStrings           r  parse_liquidationzbitget.parse_liquidation$  s    > ##K::%%k<@@	++K8LL$$[+>>	"-niHH$$&&x88 ++,<=="Y//
&
 
&
 
 
 
	r  c                 x   |                                   |                     |          }d|d         i}|                     |                     ||                    }|                     |d          }|                     |dg           }|                     |di           }||d<   |                     ||          S )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_ratez!bitget.fetch_isolated_borrow_rate%  s     	V$$fTl
 LLT[[Y`bhMiMijjT %%h>>	x44a,,&k..uf===r  r4  c           
         |                      |d          }|                     ||d d          }|                      |d          }|                      |d          }|                     |d          }||                     |          |                     |d          |                     |          |                     |d          d||                     |          |d		S )
Nr  rR   r  r  r  baseDailyInterestRatequoteDailyInterestRater  )	r  r  baseRater  	quoteRateperiodr  r  r4  )rC  r  r  rD  rL  rG  )r  r4  r  r\  r  r  r  r  s           r  r1  z!bitget.parse_isolated_borrow_rateK%  s    F ##D(33!!(FD&AA!!$
33""455%%dK88	++F33((/FGG,,W55))$0HII"Y//

 

 
	
r  c                 @   |                                   |                     |          }d|d         i}d}d}d}|                     |ddd          \  }}|rA|                     |                     ||                    }|                     |di           }nW|                     |                     ||                    }|                     |dg           }|                     |di           }|                     |d	          }	|	|d
<   | 	                    ||          S )ab  
        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;  r5  3privateMarginGetV2MarginCrossedInterestRateAndLimitr  r  parse_borrow_rate)
r  r  r  r  r  r   r  r[  r  r  s
             r  fetch_cross_borrow_ratezbitget.fetch_cross_borrow_rate%  s2    	==&&HTN
 33F<RTY[`aaV ,	2;;DKKQW<X<XYYH ^^Hfb99FFOOPTP[P[\cekPlPlmmH6 ??8VR88D__T1b11F%%h>>	'{%%fh777r  c                     |                      |d          }|                     |d          }|                     ||          |                     |dd          d||                     |          |dS )Nr  r  dailyInterestRatedailyInterestr  )r  rater8  r  r  r4  )rC  r  rD  rN  rG  )r  r4  r  r  r  s        r  r<  zbitget.parse_borrow_rate%  s~    < %%dF33
%%dK88	//
HEE&&t-@/RR"Y//
 
 	
r  c           	      f   |                                   d}|                     |dd          \  }}|r|                     d||||dd          S d}||                     |          }i }d}	| |                     |          }	|	d         |d<   |||d	<   n|                                 d
z
  |d	<   |||d<   d}
d}|                     d|d          \  }}|dk    rN|t          | j        dz             |d         |d<   | 	                    | 
                    ||                    }
n/|dk    r)|                     | 
                    ||                    }
|                     |
di           }|                     |dg           }|                     ||          }|                     ||||          S )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_interestzbitget.fetch_borrow_interest%  s    	88AVXbcc& 	@334I6SXZ_agipr~[[((F}}T**H&tnGFO#(GK  #'#4#4#6#6#CGK $GG
!??@UW]_fgg
F##~'2e(efff &tGHKKDKKX_agLhLhiiHH7""JJ4;;W^`fKgKghhHf x44t\266..tV<<228T5%PPPr  c                    |                      |d          }|                     ||          }|dnd}|                     |d          }||                      |d          |                     |                      |d                    |                     |d          |                     |d          d |||                     |          d	S )	Nr  r  r  r  interestCoininterestAmountr?  )	r4  r  r  r  r  amountBorrowedr  r  r  )rC  r  r  rD  rL  rG  )r  r4  r  r\  r  r  s         r  parse_borrow_interestzbitget.parse_borrow_interestQ&  s    : ##D(33!!(F33$,$8ZZw
%%dG44	&&vx88//0@0@~0V0VWW((/?@@ ,,T3FGG"$"Y//

 

 
	
r  c                 L   |                                   |                     |          }d|d         i}d}d}d}|                     ||          \  }}|                     |ddd          \  }}|r6|||d<   ||d<   |                     |                     ||                    }n5|||d	<   ||d
<   |                     |                     ||                    }|                     |di           }	|                     |	ddg           }
| 	                    |
d         |          S )al  
        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  rj  r  r  r  r?  r   )
r  r  r  r  #privateUtaPostV3TradeClosePositionsr;  &privateMixPostV2MixOrderClosePositionsr  r  r(  )r  r  r`  r  r  r  r  r   r  r  rg  s              r  close_positionzbitget.close_position~&  sO    	V$$fTl
 "AA&&QQV33FOUTYZZV 	a%)	""-GJ??GU[@\@\]]HH" &*
#%0GM"BB4;;wX^C_C_``H$ x44  }fbAAa&111r  c                    |                                   i }d}d}d}|                     d|          \  }}|                     |ddd          \  }}|r/||d<   |                     |                     ||                    }n.||d<   |                     |                     ||                    }|                     |di           }|                     |dd	g           }|                     |d|          S )
a  
        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  r?  )	r  r  r  rO  r;  rP  r  r  parse_positions)r  r  r  r  r   r  r  r  s           r  close_all_positionszbitget.close_all_positions&  s    	"AA$OOV33F<OQVX]^^V 	a"-GJ??GU[@\@\]]HH" &1GM"BB4;;wX^C_C_``H$ x44$$T=&"EE	##ItV<<<r  c                 Z   |                                   |                     |          }d}|                     ||          \  }}|d         |d         |d}|                     |                     ||                    }|                     |di           }|                     ||          S )a  
        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;  r5  parse_margin_moder  s           r  fetch_margin_modezbitget.fetch_margin_mode '  s     	V$$"AA&&QQVTl ,&
 

 88Wf9U9UVV: ~~h33%%dF333r  c                 Z    |                      |d          }|dk    rdn|}||d         |dS )Nr  rm  r  r  )r4  r  r  r  )r  r  r  
marginTypes       r  rV  zbitget.parse_margin_mode3'  sG    %%j,??
!+y!8!8WWz
X&$
 
 	
r  c                    |                                   i }d}d}d}d}	|;t          |          }
|
dk    r&|                     |d                   }|d         |d<   |||d<   |||d<   |                     d||          \  }}|                     ||          \  }}|                     |dd	d
          \  }}|r/||d<   |                     |                     ||                    }	n)|                     |                     ||                    }	| 	                    |	di           }| 
                    |dg           }|                     |||          }|                     |||          S )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  r?  )r  r8  r  r  r  r  &privateUtaGetV3PositionHistoryPositionr;  rW  r5  r6  rS  filter_by_since_limit)r  rN  r  r  r  r  r  r  r   r  rT  r  r  	positionss                 r  fetch_positions_historyzbitget.fetch_positions_history<'  s     	LLMq  WQZ00$*4L!#(GK $GG229gvNN"AA&&QQV33F<SUZ\abbV $	d"-GJBB4;;wX^C_C_``HHD EEdkkRY[aFbFbccH< ~~h33~~dFB77((wGG	)))UEBBBr  fromCodetoCodec                    |                                   |||                     |          d}|                     |                     ||                    }|                     |di           }|                     |d|          }|                     |          }	|                     |d|          }
|                     |
          }|                     ||	|          S )aA  
        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  rb  rc  )r  rs  %privateConvertGetV2ConvertQuotedPricer;  r5  rC  r  parse_conversion)r  r_  r`  r  r  r  r  r  fromCurrencyIdfromCurrencytoCurrencyId
toCurrencys               r  fetch_convert_quotezbitget.fetch_convert_quote'  s     	  11&99
 

 ==dkk'SY>Z>Z[[" ~~h33))$
HEE}}^44''h??]]<00
$$T<DDDr  c                 X   |                                   |                     |dd          }|t          | j        dz             |                     |dd          }|t          | j        dz             |                     |ddg          }||||                     |          ||d}|                     |                     ||                    }	|                     |	d	i           }
| 	                    |
d
|          }| 
                    |          }|                     |
d|          S )aE  
        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)traceIdrb  rc  rd  ro  rm  r  rc  )r  r  r/   rE   r  rs   privateConvertPostV2ConvertTrader;  r5  rC  r  rf  )r  rE   r_  r`  r  r  r  rn  r  r  r  ri  rj  s                r  create_convert_tradezbitget.create_convert_trade'  s9    	""67K@@=#DG.`$`aaa%%fj,GG#DG.c$cddd6GZ#899  11&99"
 
 88Wf9U9UVV ~~h33''h??]]<00
$$T4<<<r  c                    |                                   i }d}|                                 }|||d<   n||z
  |d<   |                     |dd          }|||d<   n||d<   |||d<   |                     |d          }|                     |                     ||                    }	|                     |	di           }
|                     |
dg           }|                     ||d	d
||          S )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  Nr  r  r  r  r  r  rb  rc  )	r  r  r  r  'privateConvertGetV2ConvertConvertRecordr;  r5  r6  parse_conversions)r  r  r  r  r  r  r  r  r  r  r  r  s               r  fetch_convert_trade_historyz"bitget.fetch_convert_trade_history(  s    	!!#(GK  #&=GK $$VY@@!(GI!$GI$GG67++??GU[@\@\]]. ~~h33>>$
B77%%hj(ESXYYYr  
conversionrh  rj  c                    |                      |d          }|                     |d          }|                     ||          }|                     |d          }|                     ||          }|||                     |          |                     |dd          ||                     |d          ||                     |d          |                     |d          |                     |d	          d

S )Nr  rb  rc  rE   rp  rd  ro  rm  r  )
r4  r  r  rE   rh  
fromAmountrj  rn  r  r  )r  rC  rD  rG  r  rL  )	r  rw  rh  rj  r  rb  r_  tor`  s	            r  rf  zbitget.parse_conversion8(  s    H %%j$77	##J
;;**8\BBj(33((Z88"Y//$$ZyAA$**:~FF ((\BB%%j+>>##J66
 
 	
r  c                    |                                   |                     |          }i }|                     |dg           }t          dt	          |                    D ]}||         }|                     |d          }|                     |          }|||ddddd|                     |d          dd|                     |d          |                     |d          dddddddd	dd
||<   |S )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  $privateConvertGetV2ConvertCurrenciesr6  r7  r8  rC  rD  rL  )	r  r  r  r[  r  rS  r  rE   r  s	            r  fetch_convert_currencieszbitget.fetch_convert_currenciesn(  sD    	<<VDD  ~~h33q#d))$$ 	 	AGE!!%00B**2..D  ,,UK@@!  $//{CC#//{CC 
  $#! !
  $#      5 F4LL8 r  c                    |                                   |                     |          }d}|                     ||          \  }}d|d         i}d}d}|                     |ddd          \  }}|r*|                     |                     ||                    }n.||d<   |                     |                     ||                    }|                     |dg           }|                     |d	i           }	| 	                    |	|          S )
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  r6  r5  r  )
r  r  r  r  r  r  r  r   r  r  s
             r  fetch_funding_intervalzbitget.fetch_funding_interval(  s    	V$$"AA&&QQVfTl
 33F<RTY[`aaV 	]??GU[@\@\]]HH& &1GM">>t{{7TZ?[?[\\H ~~h33tQ++&&uf555r  c                    |                                   |                     |          }d|d         i}|||d<   d}|d         s|d         r*|                     |                     ||                    }n)|                     |                     ||                    }|                     |dg           }	|                     |	|          S )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   Nr8  rT   rU   r  )r  r  'publicMixGetV2MixMarketAccountLongShortr;  +publicMarginGetV2MarginMarketLongShortRatior6  parse_long_short_ratio_history)
r  r  r  r  r  r  r  r  r  r  s
             r  fetch_long_short_ratio_historyz%bitget.fetch_long_short_ratio_history(  s     	V$$fTl
   )GH&> 	fVH- 	fCCDKKPWY_D`D`aaHH" GGT[]cHdHdeeH ~~h33224@@@r  c           
          |                      |d          }|                     |d          }||                     ||d d          ||                     |          d |                     |dd          dS )Nr  r  r  longShortRatiolongShortAccountRatio)r4  r  r  r  r  r  )rC  r@  r  rG  rN  )r  r4  r  r\  r  s        r  parse_long_short_ratiozbitget.parse_long_short_ratio#)  s    ##D(33//d;;	&&xzJJ"Y//"007GI`aa
 
 	
r  reasonurlr  headersbodyc
                    |sd S |                      |dd          }
| j        dz   |z   }|
d uo|
dk    o|
dk    }|rD|                     | j        d         |
|           |                     | j        d         |
|           |                      |dd	          }|d uo|d
k    }|r"|                     | j        d         ||           |s|rt          |          d S )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_errorszbitget.handle_errors/)  s    	46 $$Xy%@@7S=4'#4/_gm_'U^J^ 	^001I7T\]]]001I7T\]]]&&xDD	%T1M	W8L 	`001I9V^___ 	* 	*)))tr  c                 F    |                                  | j        d         z
  S )Nr  )r  r  )r  s    r  noncezbitget.nonceZ)  s!      ""T\2B%CCCr  GETc                    |d         dk    }|d         }d}	d|                      ||          z   }
|	|
z   }|                     | j        d         |                   |z   }|                     ||                     |                    }|sW|dk    rQt          |                                          }t          |          }|dk    r|dz   |                     |          z   }|rI| 	                                 t          |                                           }||z   |z   }|d	k    r|                     |          }||z  }nf|rdd|                     |                     |                    z   }|                    d
          dk    r|                    d
d          }||z  }||z  }|                     |                     |          |                     | j                  t&          j        d          }|                     | j        d          }| j        ||| j        |d}|d	k    rd|d<   |                     | j        ddd          }|r=|dk    r7|dk    r1|i }|                     |d          }|dk    r|dk    r|dk    rd|d<   ||||dS )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_paramsr?  rA  r8  	urlencodecheck_required_credentialsrK  r  r  keysortr  replacehmacencoder   hashlibsha256rC  r  r   r   r  )r  pathr   r  r  r  r  signedendpointpathPartr  payloadr  queryrA  
keysLengthr  auth
queryInner	signaturer   r  r  s                          r  signzbitget.sign])  s   Q9$q6++D&999W$##DIe$4X$>??'I		&$"5"5d";";<< 	86U??

%%DTJA~~Ci$.."7"77 	=++---DJJLL))Iv%/Dyy(( '!$t~~dll66J6J'K'K!KJ!u--22%/%7%7s%C%C
:%CJ&D		$++d"3"3T[[5M5Mw~_ghhI%%dlH==F"k($-%)]&, G *<'&&t|]IuUU 	,D$4444C`;`;`**6=AAK..[O5S5SZeixZxZx(+%fdwOOOr  )N)NNN)NN)__name__
__module____qualname__r   r  boolr  r  r  r   r  r*   r   r  r  r  r
   r  rK  r   r  r  r   r(   r  floatr   r  dictr   r  r  r   r  r  r   r  r!   rE  rJ  rM  r    r"   rU  r%   rp  r}  r&   r  r'   r  r  r?  r  r  r   r  r  r  r  r   r(  r+  r   r   r   r*  r1  r4  r   r  r  r  r  r  r  r  r  r  r  r  r  r  r   r  r  r  rP  rU  r   r\  rT  r  r#   r  r$   r  r  r  r   r  r  r  r   r  r  r=  r  r   r  r  intr  r  r  r  r  r)   r  r   r  r  r  r  r  r  r  r  r  r   r"  r.  r   r2  r1  r	   r=  r<  r   rH  rM  rQ  rT  r   rW  rV  r^  r   rk  rr  rv  rf  r  r  r   r  r  r  r  r  __classcell__)r  s   @r  rB   rB   $   s"       k# k k k k k kZ9. . . . .'4 ' ' ' ' 59 %% %% %% %%N !# 5 5s 5 5 5 5. $& 6 6$v, 6 6 6 6,ptF| p p p pdl4< l l l l\ ') u uZ u u u un ?A ~@ ~@# ~@T,EW ~@ ~@ ~@ ~@@E E E$|J\ E E E EN *.Dt\^ :L :L3 :Lc :L :Lcghsct :L :L :L :Lx KOWY 7 7S 7% 7# 7C 7^i 7 7 7 7r -1tRV_a >P >Pc >P >PC >Pfjkvfw >P >P >P >P@K
 K
T K
X K
Q\ K
 K
 K
 K
Z:s : : : : 79 #: #:# #:^ #: #: #: #:J
 
h 
R` 
 
 
 
0 :>b ?Z ?Zs ?Z3 ?ZY ?Z ?Z ?Z ?ZBM M4 M M6 M M M M^ 02 [2 [23 [2f [2 [2 [2 [2z 46 2 2s 2& 2 2 2 24 04B a1 a1W a17 a1 a1 a1 a1FU U Uv U U U U Un 6:UW A= A=3 A=s A=# A=\`af\g A= A= A= A=F 57 &4 &4 &4;N &4 &4 &4 &4P )+ q q{ q q q qf	
 	
f 	
 	
 	
 	

 
 
4 
 
 
 
. 9=4^bkm bH bH# bH# bHS bHX[ bHrvw{r| bH bH bH bHH $& d( d(( d( d( d( d(L)H ) ) ) )2I) I) I) I) I)V: : : : :*H H Hv H H H H HT
 RT ` ` `5 ` ` ` `, gksu b. b.3 b.i b.y b.RW b.`c b. b. b. b.H sw  @B b, b,s b,) b,9 b,^c b,lo b, b, b, b,H os{} n, n,3 n,i n,y n,Z_ n,hk n, n, n, n,` DF ,/ ,/\(: ,/ ,/ ,/ ,/\ @B _/ _/D$6 _/ _/ _/ _/B `drv  @B ~. ~.S ~.# ~.Y ~.i ~.Y\ ~.lo ~. ~. ~. ~.@ 37r U/ U/s U/C U/ U/ U/ U/n 48 / /S / / / /B ;?r P1 P1c P1C P1 P1 P1 P1d /32 r/ r/ r/ r/ r/ r/h 26b e/ e/c e/3 e/ e/ e/ e/R /3TXac z= z= z=3 z=c z=hlmrhs z= z= z= z=x 154VZce : :# :S :PS :jnotju : : : :8 37TX\eg < <C <s <RU < < < <8 >BPTcgpr a? a?s a?# a?]` a? a? a? a?F	 BFTXgktv t? t?3 t?c t?ad t? t? t? t?l (,$TZ\ d? d? d?C d?s d?aefqar d? d? d? d?L: :t :x :; : : : :x+3 +3 +3Z -1tRV_a R= R=c R= R=C R=fjkpfq R= R= R= R=h 24 f2 f2S f2 f2 f2 f2P 26b tP tPw tPT(^ tP tP tP tPlV Vt VV V V V Vp 8<$]ajl YY YY YYC YYWZ YY YY YY YYv 68 U8 U8 U8K U8 U8 U8 U8n 6:" P7 P77 P7 P7 P7 P7 P7d :>b 9 9w 9\ 9 9 9 9V
 V
6 V
[ V
 V
 V
 V
p 37TX\eg `I `IC `Is `IRU `Ilpq  mA `I `I `I `ID$
 $
f $
 $
 $
 $
LO OS OX[ Ogklzg{ O O O O  FH  3 L^    8
 
d 
F 
N` 
 
 
 
4 @B K KC K KFX K K K K$ =? H H He HCU H H H H  24 11 11S 11 11 11 11 11f

 

t 

V 

x 

 

 

 

 9=R @ @S @# @ @ @ @D >B" + +# +s + + + +Z =A 2 2 2c 2 2 2 2h 79 ?6 ?6# ?6 ?6 ?6 ?6B$ $F $ $ $ $L +/TPT]_ 7B 7BC 7Bs 7B# 7Bdhivdw 7B 7B 7B 7Br [] .3 .3S .3% .3c .3c .3an .3 .3 .3 .3`+
 +
t +
x +
= +
 +
 +
 +
Z:C :C : : : :1 1 1 1 1 1f <@ *E *E *E *E *E *EX DF 6 6 6U 6 6 6 6B TV #> #>S #> #>U #> #> #> #>J LN $> $>C $>s $> $> $> $>L <>  6  6s  6  6  6  6D3
 3
 3
 3
 3
 3
 3
j 37TX\eg dK dKC dKs dKRU dKlpq|l} dK dK dK dKL. .V . . . .` >@ => => =>DV => => => =>~2
 2
t 2
V 2
Oa 2
 2
 2
 2
h 9; D8 D8C D8 D8 D8 D8 D8L'
 '
 '
 '
 '
 '
R 15DW[jnwy aQ aQ# aQc aQQT aQdg aQ  C  DR  S aQ aQ aQ aQF+
 +
$ +
 +
. +
 +
 +
 +
Z =A C2 C2S C2	 C2PU C2 C2 C2 C2J *, ;= ;=X ;= ;= ;= ;=z 57 14 14 14: 14 14 14 14f
 
D 
* 
 
 
 
 :>D_cln gC gCw gCc gCY\ gCsw  yA  tB gC gC gC gCR MQY[ (E (EC (E (Ec (E`j (E (E (E (ET W[ce 0= 0=s 0=c 0=3 0=PS 0=jt 0= 0= 0= 0=d 7;\`ik 5Z 5Z 5Z3 5ZVY 5Zptu  qA 5Z 5Z 5Z 5Zn4
 4
4 4
x 4
\d 4
pz 4
 4
 4
 4
l /1 < <Z < < < <| :< <6 <6S <6 <6 <6 <6 <6| <@RVeix|  FH 7A 7AS 7AC 7A_b 7Aru 7A  MQ  R`  Ma 7A 7A 7A 7Ar

 

4 

 

> 

 

 

 

)# )s ) )c )TX )`c ) ) ) )VD D D  b$T /P /P /P /P /P /P /P /Pr  rB   )Hccxt.base.exchanger   ccxt.abstract.bitgetr   r  r  ccxt.base.typesr   r   r   r   r	   r
   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r    r!   r"   r#   r$   r%   r&   r'   r(   r)   typingr*   ccxt.base.errorsr+   r,   r-   r.   r/   r0   r1   r2   r3   r4   r5   r6   r7   r8   r9   r:   r;   r<   r=   r>   ccxt.base.decimal_to_precisionr?   ccxt.base.preciser@   rB    r  r  <module>r     s   ( ' ' ' ' ' , , , , , ,   T  T  T  T  T  T  T  T  T  T  T  T  T  T  T  T  T  T  T  T  T  T  T  T  T  T  T  T  T  T  T  T  T  T  T  T  T  T  T  T  T  T  T  T  T  T  T  T  T  T  T  T  T  T  T  T  T  T  T  T  T  T  T  T  T  T  T  T  T  T  T  T  T  T  T  T  T  T       * * * * * * 0 0 0 0 0 0 - - - - - - - - - - - - . . . . . . ' ' ' ' ' ' & & & & & & / / / / / / . . . . . . + + + + + + ) ) ) ) ) ) * * * * * * ) ) ) ) ) ) + + + + + + . . . . . . 1 1 1 1 1 1 * * * * * * ) ) ) ) ) ) + + + + + + * * * * * * 4 4 4 4 4 4 % % % % % %heP heP heP heP hePX{ heP heP heP heP hePr  