
    E#if                       S SK Jr  S SKJr  S SKrS SKrS SKJrJrJ	r	J
r
JrJrJrJrJrJrJrJrJrJrJrJrJrJrJrJrJrJrJrJrJrJ r J!r!J"r"J#r#J$r$J%r%J&r&J'r'J(r(J)r)J*r*J+r+J,r,J-r-J.r.  S SK/J0r0  S SK1J2r2  S SK1J3r3  S SK1J4r4  S S	K1J5r5  S S
K1J6r6  S SK1J7r7  S SK1J8r8  S SK1J9r9  S SK1J:r:  S SK1J;r;  S SK1J<r<  S SK1J=r=  S SK1J>r>  S SK1J?r?  S SK1J@r@  S SK1JArA  S SK1JBrB  S SKCJDrD  S SKEJFrF   " S S\\5      rGg)    )Exchange)ImplicitAPIN)(AnyBalancesBorrowInterest
ConversionCrossBorrowRate
CurrenciesCurrencyDepositAddressFundingHistoryGreeksIntLedgerEntryLeverageLeverageTierLeverageTiersLiquidationLongShortRatioMarketNumOptionOptionChainOrder	OrderBookOrderRequestCancellationRequest	OrderSide	OrderTypePositionStrStringsTickerTickersFundingRateFundingRatesTradeTradingFeeInterfaceTradingFeesTransactionMarketInterfaceTransferEntry)List)ExchangeError)AuthenticationError)PermissionDenied)AccountSuspended)ArgumentsRequired)
BadRequest)	BadSymbol)NoChange)MarginModeAlreadySet)ManualInteractionNeeded)InsufficientFunds)InvalidOrder)OrderNotFound)NotSupported)RateLimitExceeded)InvalidNonce)RequestTimeout)	TICK_SIZE)Precisec                     ^  \ rS rSrS\4U 4S jjrS\4S jrS rS r	0 4S jr
0 4S	 jrS
\4S jrSS\S\S\S\S\4
U 4S jjjr0 4S jrS
\S\4S jrS
\S\4S jrS
\S\4S jr0 4S\4S jjr0 4S\4S jjr0 4S\\   4S jjrS\\   4S jrS\\   4S jrS\\   4S jrSS\ S\S\!4S  jjr"0 4S
\S\!4S! jjr#S0 4S"\$S\%4S# jjr&S0 4S"\$S\%4S$ jjr'SS\S\(4S% jjr)S&SS0 4S
\S'\S(\S)\S\\(   4
S* jjr*SS\S\+4S+ jjr,S0 4S"\$S\-4S, jjr.SSS0 4S
\S(\S)\4S- jjr/SS.\ S\S\04S/ jjr1SS0 4S
\S(\S)\S\\0   4S0 jjr2S0 4S
\S)\S\34S1 jjr4S\54S2 jr60 4S\54S3 jjr7S4\4S5 jr8S6\4S7 jr9SS8\ S\S\:4S9 jjr;0 4S
\S\S\:4S: jjr<0 4S
\S\S\:4S; jjr=S0 4S
\S<\>S=\?S\S\@S\:4S> jjrAS0 S?4S
\S<\>S=\?S\S\@4
S@ jjrB0 4SA\\C   S\\:   4SB jjrDSS0 4SC\S
\S<\>S=\?S\@S\@4SD jjrESS0 4SC\S
\S<\>S=\?S\@S\@S\:4SE jjrF0 4SA\\C   S\\:   4SF jjrGS0 4SC\S
\4SG jjrHS0 4SC\S
\S\:4SH jjrIS0 4SI\\   S
\S\\:   4SJ jjrJ0 4SK\4SL jjrK0 4SA\\L   4SM jjrMS0 4S
\4SN jjrNS0 4SC\S
\S\:4SO jjrOS0 4SC\S
\S\:4SP jjrPSSS0 4S
\S(\S)\S\\:   4SQ jjrQSSS0 4S
\S(\S)\S\\:   4SR jjrRS0 4SC\S
\S\:4SS jjrSS0 4SC\S
\S\:4ST jjrTSSS0 4S
\S(\S)\S\\:   4SU jjrUSSS0 4S
\S(\S)\S\\:   4SV jjrVSSS0 4S
\S(\S)\S\\:   4SW jjrWSSS0 4S
\S(\S)\S\\:   4SX jjrXSSS0 4SC\S
\S(\S)\S\\0   4
SY jjrYSSS0 4S
\S(\S)\S\\0   4SZ jjrZSS[\[S\\4S\ jjr]0 4S]\S\\\   4S^ jjr^0 4S]\S\\4S_ jjr_SSS0 4S]\S(\S)\S\\`   4S` jjraSSS0 4S]\S(\S)\S\\`   4Sa jjrbS4\4Sb jrcSSc\ S[\[S\`4Sd jjrdSSS0 4S]\S(\S)\S\\e   4Se jjrfSSf\ S[\[S\e4Sg jjrgSh rhS0 4S]\S\Si\Sj\S\`4
Sk jjri0 4S
\S\j4Sl jjrkS0 4S"\$S\\j   4Sm jjrlSSn\ S\S\j4So jjrm0 4S
\S\n4Sp jjroSSq\ S\S\n4Sr jjrpS0 4Ss\S
\4St jjrqS0 4Sq\rS
\4Su jjrsS0 4Sv\S
\4Sw jjrtSxSS0 4S
\S(\S)\4Sy jjru0 4S
\4Sz jjrvSxSS0 4S
\S(\S)\4S{ jjrwSS\4S| jjrx0 4S]\S\y4S} jjrzSS[\[4S~ jjr{SSSS0 4S]\S
\S(\S)\S\\|   4
S jjr}SS0 4S]\S(\S)\4S jjr~SS\ S\S\|4S jjr0 4S]\S\S\S\S\4
S jjrSSS0 4S]\S(\S)\S\\   4S jjr0 4S]\S\4S jjr0 4S]\4S jjrSS[\[S\ 4S jjrS4\S\4S jrSS\ S[\[S\4S jjr0 4S
\S\\   4S jjr0 4S
\S\\   4S jjrSS\ S\S\4S jjr0 4S
\S\4S jjr0 4S\4S jjrSS[\[S\4S jjrS0 4S\$4S jjrSSS0 4S
\S(\S)\4S jjrSSS0 4S
\S(\S)\4S jjrS rS r0 4S]\4S jjrS r0 4S
\S\4S jjrS0 4S"\$S\\   4S jjrSS\ S\S\4S jjrSSS0 4S
\S(\S)\S\\   4S jjrSS\S\4S jjrS0 4S
\4S jjrS0 4S"\$S\4S jjrSS"\$S\4S jjrSS\S\\   4S jjrSSS0 4S
\S(\S)\S\\   4S jjrSS\S\4S jjr0 4S
\S\4S jjr0 4S]\S\4S jjrSS\ S[\[S\S\4S jjrSSS0 4S"\$S(\S)\S\\j   4S jjr0 4S\4S jjrS0 4S\S\S\@S\4S jjrS0 4SC\S\S\S\@S\4
S jjrS0 4SC\S]\S\4S jjrSSS0 4S]\S(\S)\S\\   4S jjrSS\ S\[S\[S\4S jjrSSSS0 4S
\S'\S(\S)\S\\   4
S jjrSS\ S\S\4S jjrSS0 SS4S jrS\rS\S\S\S\ S\4S jrSrU =r$ )bybit!   returnc                 .  > U R                  [        [        U ]  5       0 SS_SS_SS/_SS_S	S _S
S_SS_SS_SS_S0 SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_S S_S!S_S"S_S#S_0 S$S_S%S_S&S_S'S_S(S_S)S_S*S_S+S_S,S_S-S_S.S_S/S_S0S_S1S_S2S_S3S_S4S5_E0 S6S_S7S_S8S_S9S_S:S_S;S_S<S_S=S_S>S_S?S_S@S_SAS_SBS_SCS_SDS_SES_SFS_E0 SGS_SHS_SIS5_SJS_SKS_SLS5_SMS_SNS_SOS_SPS_SQS_SRS_SSS_STS_SUS_SVS_SWS_E0 SXS_SYS_SZS_S[S_S\S_S]S_S^S_S_S_S`S_SaS_SbS_ScS_SdS_SeS_SfS_SgS_ShS_E0 SiS_SjS_SkS5_SlS_SmS_SnS_SoS_SpS_SqS_SrS_SsS_StS_SuS_SvS_SwS_SxS_SyS_ESSSSSSSSSz.E_S{S|S}S~SSSSSSSSSSS._SSSSSSS.SSSSSSS.SSSSSS.S/ SQSSS._SS0 SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_0 SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_E0 SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_ESSSSS.E00 SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_0 SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_E0 SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_GS S_GSS_GSS_GSS_GSS_E0 GSS_GSS_GSGS_GS	S_GS
S_GSS_GSS_GSS_GSS_GSS_GSS_GSS_GSS_GSS_GSS_GSS_GSS_E0 GSS_GSS_GSS_GSS_GSS_GSS_GSS_GSS_GSS_GS S_GS!S_GS"S_GS#S_GS$GS%_GS&GS%_GS'GS%_GS(S_E0 GS)S_GS*S_GS+S_GS,S_GS-S_GS.S_GS/S_GS0S_GS1S_GS2S_GS3S_GS4S_GS5S_GS6S_GS7S_GS8GS9_GS:S_E0 GS;S_GS<S_GS=S_GS>S_GS?S_GS@S_GSAS_GSBS_GSCS_GSDS_GSES_GSFS_GSGS_GSHS_GSIS_GSJS_GSKS_E0 GSLS_GSMS_GSNS_GSOS_GSPS_GSQS_GSRS_GSSS_GSTS_GSUS_GSVS_GSWS_GSXS_GSYS_GSZS_GS[S_GS\S_ESSSSSSSSSSSGS].E0 SS_GS^S_GS_S_GS`S_GSaS_GSbS_GScS_GSdS_GSeGSf_GSgGSh_GSiS_GSjGSf_GSkGSf_GSlS_GSmS_GSnS_GSoS_0 GSpS_GSqS_GSrS_GSsS_GStS_GSuS_GSvS_GSwS_GSxS_GSyS_GSzS_GS{S_GS|S_GS}S_GS~S_GSS_GSS_E0 GSS_GSS_GSS_GSS_GSS_GSS_GSS_GSS_GSS_GSS_GSS_GSS_GSS_GSS_GSS_GSS_GSS_E0 GSS_GSS_GSS_GSS_GSS_GSS_GSS_GSS_GSS_GSS_GSS_GSS_GSS_GSS_GSS_GSS_GSS_E0 GSS_GSS_GSS_GSS_GSS_GSS_GSS_GSS_GSS_GSS_GSS_GSS_GSS_GSS_GSS_GSS_GSS_E0 GSS_GSGSf_GSS_GSS_GSS_GSS_GSS_GSS_GSS_GSS_GSS_GSS_GSS_GSS_GSS_GSS_GSS_E0 GSS_GSS_GSS_GSS_GSS_GSS_GSS_GSS_GSS_GSS_GSS_GSS_GSS_GSS_GSS_GSS_GSS_EGS.GS._GSGS[        0_GS0 GS[
        _GS[
        _GS[
        _GS[
        _GS[        _GS[        _GS[        _GS[        _GS[
        _GS[
        _GS[
        _GS[        _GS[
        _GS[
        _GS[        _GS[        _GS[        _0 GS[        _GS[        _GS[        _GS[        _GS[        _GS[        _GS[
        _GS[        _GS[
        _GS[        _GS[        _GS[        _GS[        _GS[        _GS[        _GS[        _GS[
        _E0 GS[
        _GS[        _GS[        _GS [        _GS[        _GS[        _GS[        _GS[        _GS[        _GS[        _GS[        _GS[        _GS	[        _GS
[
        _GS[        _GS[
        _GS[        _E0 GS[        _GS[
        _GS[        _GS[        _GS[        _GS[        _GS[        _GS[
        _GS[        _GS[        _GS[        _GS[
        _GS[
        _GS[        _GS[        _GS[        _GS[        _E0 GS[        _GS [        _GS![        _GS"[        _GS#[        _GS$[        _GS%[        _GS&[        _GS'[        _GS([
        _GS)[        _GS*[        _GS+[
        _GS,[
        _GS-[
        _GS.[
        _GS/[
        _E0 GS0[        _GS1[        _GS2[        _GS3[        _GS4[        _GS5[        _GS6[        _GS7[        _GS8[        _GS9[
        _GS:[
        _GS;[
        _GS<[        _GS=[        _GS>[        _GS?[        _GS@[        _E0 GSA[        _GSB[        _GSC[        _GSD[        _GSE[        _GSF[        _GSG[        _GSH[        _GSI[        _GSJ[        _GSK[        _GSL[        _GSM[        _GSN[        _GSO[        _GSP[        _GSQ[
        _E0 GSR[
        _GSS[
        _GST[
        _GSU[        _GSV[
        _GSW[        _GSX[
        _GSY[
        _GSZ[
        _GS[[        _GS\[
        _GS][
        _GS^[
        _GS_[        _GS`[        _GSa[         _GSb[         _E0 GSc[
        _GSd[        _GSe[        _GSf[        _GSg[
        _GSh[
        _GSi[
        _GSj[        _GSk[        _GSl[        _GSm[        _GSn[
        _GSo[
        _GSp[
        _GSq[        _GSr[        _GSs[        _E0 GSt[        _GSu[        _GSv[        _GSw[        _GSx[        _GSy[        _GSz[        _GS{[        _GS|[        _GS}[        _GS~[        _GS[
        _GS[        _GS[        _GS[        _GS[        _GS[
        _E0 GS[        _GS[        _GS[        _GS[        _GS[        _GS[
        _GS[
        _GS[
        _GS[
        _GS[        _GS[
        _GS[        _GS[
        _GS[        _GS[        _GS[        _GS[        _E0 GS[
        _GS[        _GS[
        _GS[
        _GS[        _GS[        _GS[        _GS[
        _GS[        _GS[        _GS[
        _GS[
        _GS[
        _GS[
        _GS[        _GS[        _GS[        _E0 GS[        _GS[        _GS[        _GS[        _GS[        _GS[        _GS[        _GS[
        _GS[
        _GS[
        _GS[        _GS[        _GS[        _GS[        _GS[        _GS[        _GS[        _E0 GS[        _GS[        _GS[        _GS["        _GS[        _GS[        _GS[        _GS[        _GS[        _GS[        _GS[        _GS[
        _GS[
        _GS[
        _GS[
        _GS[        _GS[        _E0 GS[        _GS[        _GS[        _GS[
        _GS[        _GS[        _GS[        _GS[        _GS[        _GS[        _GS[        _GS[        _GS[        _GS[        _GS[        _GS[        _GS[        _E0 GS[        _GS[        _GS[        _GS[        _GS[        _GS[        _GS[        _GS[        _GS[        _GS[        _GS[        _GS[        _GS[        _GS[        _GS[        _GS[        _GS[        _E0 GS[        _GS[        _GS[        _GS[        _GS[        _GS[        _GS[        _GS[        _GS[        _GS[        _GS[        _GS[        _GS[
        _GS[        _GS[        _GS[        _GS[        _E0 GS[        _GS[        _GS[        _GS[        _GS [$        _GS[        _GS[        _GS[        _GS[        _GS[        _GS[        _GS[        _GS[        _GS	[        _GS
[        _GS[        _GS[        _E0 GS[        _GS[        _GS[        _GS[        _GS[        _GS[        _GS[
        _GS[
        _GS[
        _GS[
        _GS[
        _GS[
        _GS[
        _GS[
        _GS[
        _GS[
        _GS[
        _E0 GS[
        _GS[
        _GS [        _GS![
        _GS"[
        _GS#[
        _GS$[
        _GS%[
        _GS&[
        _GS'[
        _GS([
        _GS)[
        _GS*[
        _GS+[
        _GS,[
        _GS-[
        _GS.[
        _E0 GS/[
        _GS0[
        _GS1[
        _GS2[        _GS3[        _GS4[        _GS5[
        _GS6[
        _GS7[
        _GS8[
        _GS9[
        _GS:[        _GS;[        _GS<[        _GS=[        _GS>[
        _GS?[        _E0 GS@[        _GSA[        _GSB[        _GSC[        _GSD[        _GSE[        _GSF[        _GSG[        _GSH[        _GSI[        _GSJ[        _GSK[        _GSL[        _GSM[        _GSN[        _GSO[        _GSP[        _E0 GSQ[        _GSR[        _GSS[
        _GST[
        _GSU[
        _GSV[
        _GSW[
        _GSX[
        _GSY[
        _GSZ[        _GS[[        _GS\[        _GS][        _GS^[        _GS_[        _GS`[        _GSa[        _E0 GSb[        _GSc[        _GSd[        _GSe[        _GSf[        _GSg[        _GSh[        _GSi[        _GSj[        _GSk[        _GSl[        _GSm[        _GSn[        _GSo[        _GSp[        _GSq[        _GSr[        _E0 GSs[        _GSt[        _GSu[        _GSv[        _GSw[        _GSx[        _GSy[        _GSz[        _GS{[        _GS|[        _GS}[        _GS~[        _GS[        _GS[        _GS[        _GS[        _GS[        _E0 GS[        _GS[        _GS[        _GS[        _GS[        _GS[        _GS[        _GS[        _GS[        _GS[        _GS[        _GS[
        _GS[
        _GS[        _GS[        _GS[
        _GS[
        _EGS[        0E[&        ["        [        [        [        [        [        GS.GS._GS[(        _GS0 GSS_GSS_SZGS/ GSQ0_GSS _GSS _GSS _GSS_GSS_GSS_GSGS_GSGS_GSGS_GSGS_GSGS_GSS_GSS_GSS_GSGSGSGSGSGSGSGSGSGSGSGS.
SSGSSGSGSGSGS.0 GSGS_GSGS_GSGS_GSGS_GSGS_GSGS_GSGS_GSGS_GSGS_GSGS_GSGS_GSGS_GSGS_GSGS_GSGS_GSGS_GSGS_0 GSGS_GSGS_GSGS_GSGS_GSGS_GSGS_GSGS_GSGS_GSGS_GSGS_GSGS_GSGS_GSGS_GSGS_GSGS_GSGS_GSGS_E0 GSGS_GSGS_GSGS_GSGS_GSGS_GSGS_GSGS_GSGS_GSGS_GSGS_GSGS_GSGS_GSGS_GSGS_GSGS_GSGS_GSGS_E0 GSGS_GSGS_GSGS_GS GS _GSGS_GSGS_GSGS_GSGS_GSGS_GSGS_GSGS_GS	GS	_GS
GS
_GSGS_GSGS_GSGS_GSGS_EGSGSGSGSGSGS.GSGSGS0GSGSGSGSGSGSGS.SGS.	E_SSSSSSGS.SSSSSSGS.SGS.SSSSGS.SSSSSSSGS.GSS0SGSGSGSSGS .SSSSGS!.SSSSSGS".S SSGSSGSSSSGS#.GS$GS%0GSS0GS&.
GS'GS(S0S SS SGS.SGS).GS*.GS+GS'0GS+GS'0GS,.GS+GS'0GS+GS'0GS,.GS-.SSSGS.GS/GS0.SS0 0 GS1.GS2.GS3.E5      $ (4  NidrB   nameBybit	countriesVGversionv5	userAgent	rateLimit   hostnamez	bybit.comproT	certifiedhasCORSspotmarginswapfutureoptionborrowCrossMargincancelAllOrderscancelAllOrdersAftercancelOrdercancelOrderscancelOrdersForSymbolscloseAllPositionsFclosePositioncreateConvertTradecreateMarketBuyOrderWithCostcreateMarketSellOrderWithCostcreateOrdercreateOrders$createOrderWithTakeProfitAndStopLosscreatePostOnlyOrdercreateReduceOnlyOrdercreateStopLimitOrdercreateStopLossOrdercreateStopMarketOrdercreateStopOrdercreateTakeProfitOrdercreateTrailingAmountOrdercreateTriggerOrder	editOrder
editOrdersfetchAllGreeksfetchBalancefetchBidsAsksemulatedfetchBorrowInterestfetchBorrowRateHistoriesfetchBorrowRateHistoryfetchCanceledAndClosedOrdersfetchCanceledOrdersfetchClosedOrderfetchClosedOrdersfetchConvertCurrenciesfetchConvertQuotefetchConvertTradefetchConvertTradeHistoryfetchCrossBorrowRatefetchCrossBorrowRatesfetchCurrenciesfetchDepositfetchDepositAddressfetchDepositAddressesfetchDepositAddressesByNetworkfetchDepositsfetchDepositWithdrawFeefetchDepositWithdrawFeesfetchFundingHistoryfetchFundingRatefetchFundingRateHistoryfetchFundingRatesfetchGreeksfetchIndexOHLCVfetchIsolatedBorrowRatefetchIsolatedBorrowRatesfetchLedgerfetchLeveragefetchLeverageTiersfetchLongShortRatiofetchLongShortRatioHistoryfetchMarginAdjustmentHistoryfetchMarketLeverageTiersfetchMarketsfetchMarkOHLCVfetchMyLiquidationsfetchMySettlementHistoryfetchMyTrades
fetchOHLCVfetchOpenInterestfetchOpenInterestHistoryfetchOpenOrderfetchOpenOrdersfetchOptionfetchOptionChain
fetchOrderfetchOrderBookfetchOrdersfetchOrderTradesfetchPositionfetchPositionHistoryfetchPositionsfetchPositionsHistoryfetchPremiumIndexOHLCVfetchSettlementHistoryfetchTickerfetchTickers	fetchTimefetchTradesfetchTradingFeefetchTradingFeesfetchTransactionsfetchTransfersfetchUnderlyingAssetsfetchVolatilityHistory)fetchWithdrawalsrepayCrossMarginsandboxsetLeveragesetMarginModesetPositionModetransferwithdraw
timeframes135153060120240360720DWM)1m3m5m15m30m1h2h4h6h12h1d1w1Murlszhttps://api-testnet.{hostname})rU   futuresv2publicprivatezOhttps://github.com/user-attachments/assets/97a5d0b3-de10-423d-90e1-6620960025edzhttps://api.{hostname}zhttps://api-demo.{hostname}zhttps://www.bybit.com)z.https://bybit-exchange.github.io/docs/inverse/z-https://bybit-exchange.github.io/docs/linear/z!https://github.com/bybit-exchangez5https://help.bybit.com/hc/en-us/articles/360039261154z(https://www.bybit.com/invite?ref=XDK12WP)testlogoapidemotradingwwwdocfeesreferralr   getzspot/v3/public/symbols   zspot/v3/public/quote/depthz!spot/v3/public/quote/depth/mergedzspot/v3/public/quote/tradeszspot/v3/public/quote/klinez spot/v3/public/quote/ticker/24hrz!spot/v3/public/quote/ticker/pricez&spot/v3/public/quote/ticker/bookTickerzspot/v3/public/server-timezspot/v3/public/infosz#spot/v3/public/margin-product-infosz#spot/v3/public/margin-ensure-tokenszv3/public/timez*contract/v3/public/copytrading/symbol/listz#derivatives/v3/public/order-book/L2zderivatives/v3/public/klinezderivatives/v3/public/tickersz&derivatives/v3/public/instruments-infoz&derivatives/v3/public/mark-price-klinez'derivatives/v3/public/index-price-klinez2derivatives/v3/public/funding/history-funding-ratez%derivatives/v3/public/risk-limit/listz$derivatives/v3/public/delivery-pricez"derivatives/v3/public/recent-tradez#derivatives/v3/public/open-interestzderivatives/v3/public/insurancezv5/announcements/index   zv5/market/timezv5/market/klinezv5/market/mark-price-klinezv5/market/index-price-klinez#v5/market/premium-index-price-klinezv5/market/instruments-infozv5/market/orderbookzv5/market/tickerszv5/market/funding/historyzv5/market/recent-tradezv5/market/open-interestzv5/market/historical-volatilityzv5/market/insurancezv5/market/risk-limitzv5/market/delivery-pricezv5/market/account-ratiozv5/spot-lever-token/infozv5/spot-lever-token/referencezv5/spot-margin-trade/datazv5/spot-margin-trade/collateralzv5/spot-cross-margin-trade/dataz'v5/spot-cross-margin-trade/pledge-tokenz'v5/spot-cross-margin-trade/borrow-tokenzv5/crypto-loan/collateral-data)zv5/crypto-loan/loanable-datav5/ins-loan/product-infos!v5/ins-loan/ensure-tokens-convertv5/earn/productzv2/private/wallet/fund/records   zspot/v3/private/orderg      @zspot/v3/private/open-orderszspot/v3/private/history-orderszspot/v3/private/my-tradeszspot/v3/private/accountzspot/v3/private/referencezspot/v3/private/recordz#spot/v3/private/cross-margin-orders
   z$spot/v3/private/cross-margin-accountz&spot/v3/private/cross-margin-loan-infoz*spot/v3/private/cross-margin-repay-historyz!spot/v3/private/margin-loan-infosz#spot/v3/private/margin-repaid-infoszspot/v3/private/margin-ltvz3asset/v3/private/transfer/inter-transfer/list/query2   z/asset/v3/private/transfer/sub-member/list/queryz8asset/v3/private/transfer/sub-member-transfer/list/queryz7asset/v3/private/transfer/universal-transfer/list/queryz asset/v3/private/coin-info/queryz&asset/v3/private/deposit/address/queryz*contract/v3/private/copytrading/order/list   z-contract/v3/private/copytrading/position/list(   z.contract/v3/private/copytrading/wallet/balancez'contract/v3/private/position/limit-infoz)contract/v3/private/order/unfilled-orderszcontract/v3/private/order/listz!contract/v3/private/position/listz"contract/v3/private/execution/listz'contract/v3/private/position/closed-pnlz*contract/v3/private/account/wallet/balancez$contract/v3/private/account/fee-ratez/contract/v3/private/account/wallet/fund-recordsz(unified/v3/private/order/unfilled-orderszunified/v3/private/order/listz unified/v3/private/position/listz!unified/v3/private/execution/listz"unified/v3/private/delivery-recordz$unified/v3/private/settlement-recordz)unified/v3/private/account/wallet/balancez*unified/v3/private/account/transaction-logz)unified/v3/private/account/borrow-historyz&unified/v3/private/account/borrow-ratezunified/v3/private/account/infoz!user/v3/private/frozen-sub-memberz!user/v3/private/query-sub-memberszuser/v3/private/query-apizuser/v3/private/get-member-typez2asset/v3/private/transfer/transfer-coin/list/queryz4asset/v3/private/transfer/account-coin/balance/queryz5asset/v3/private/transfer/account-coins/balance/queryz*asset/v3/private/transfer/asset-info/queryz2asset/v3/public/deposit/allowed-deposit-list/queryg(\?z%asset/v3/private/deposit/record/queryz&asset/v3/private/withdraw/record/queryzv5/order/realtimezv5/order/historyzv5/order/spot-borrow-checkzv5/position/listzv5/execution/listzv5/position/closed-pnlzv5/position/move-historyzv5/pre-upgrade/order/historyzv5/pre-upgrade/execution/listz"v5/pre-upgrade/position/closed-pnlz&v5/pre-upgrade/account/transaction-logz$v5/pre-upgrade/asset/delivery-recordz&v5/pre-upgrade/asset/settlement-recordzv5/account/wallet-balancezv5/account/borrow-historyzv5/account/instruments-infozv5/account/collateral-infozv5/asset/coin-greekszv5/account/fee-ratezv5/account/infozv5/account/transaction-logz#v5/account/contract-transaction-logzv5/account/smp-groupzv5/account/mmp-statezv5/account/withdrawalz!v5/asset/exchange/query-coin-listg      ?z&v5/asset/exchange/convert-result-queryz'v5/asset/exchange/query-convert-historyzv5/asset/exchange/order-recordzv5/asset/delivery-recordzv5/asset/settlement-recordz"v5/asset/transfer/query-asset-infoz-v5/asset/transfer/query-account-coins-balancez,v5/asset/transfer/query-account-coin-balancez*v5/asset/transfer/query-transfer-coin-listz+v5/asset/transfer/query-inter-transfer-listz'v5/asset/transfer/query-sub-member-listz/v5/asset/transfer/query-universal-transfer-listz#v5/asset/deposit/query-allowed-listzv5/asset/deposit/query-recordz(v5/asset/deposit/query-sub-member-recordz&v5/asset/deposit/query-internal-recordzv5/asset/deposit/query-addressz)v5/asset/deposit/query-sub-member-addresszv5/asset/coin/query-info   zv5/asset/withdraw/query-addresszv5/asset/withdraw/query-recordz%v5/asset/withdraw/withdrawable-amountzv5/asset/withdraw/vasp/listzv5/user/query-sub-memberszv5/user/query-apizv5/user/sub-apikeyszv5/user/get-member-typezv5/user/aff-customer-infozv5/user/del-submemberzv5/user/submemberszv5/affiliate/aff-user-listz v5/spot-lever-token/order-recordz*v5/spot-margin-trade/interest-rate-historyzv5/spot-margin-trade/statez#v5/spot-margin-trade/max-borrowablez#v5/spot-margin-trade/position-tierszv5/spot-margin-trade/coinstatez/v5/spot-margin-trade/repayment-available-amountz$v5/spot-cross-margin-trade/loan-infoz"v5/spot-cross-margin-trade/accountz!v5/spot-cross-margin-trade/ordersz(v5/spot-cross-margin-trade/repay-historyz1v5/crypto-loan/borrowable-collateralisable-numberzv5/crypto-loan/ongoing-ordersz v5/crypto-loan/repayment-historyzv5/crypto-loan/borrow-historyz$v5/crypto-loan/max-collateral-amountz!v5/crypto-loan/adjustment-historyr   r   zv5/ins-loan/loan-orderzv5/ins-loan/repaid-historyzv5/ins-loan/ltv-convertzv5/lending/info)zv5/lending/history-orderzv5/lending/accountzv5/broker/earning-recordzv5/broker/earnings-infozv5/broker/account-infoz/v5/broker/asset/query-sub-member-deposit-recordr   zv5/earn/orderzv5/earn/positionzv5/earn/yieldzv5/earn/hourly-yieldzspot/v3/private/cancel-orderzspot/v3/private/cancel-ordersz$spot/v3/private/cancel-orders-by-idszspot/v3/private/purchasezspot/v3/private/redeemz!spot/v3/private/cross-margin-loanz"spot/v3/private/cross-margin-repayz(asset/v3/private/transfer/inter-transfer   z asset/v3/private/withdraw/createi,  z asset/v3/private/withdraw/cancelz-asset/v3/private/transfer/sub-member-transferz2asset/v3/private/transfer/transfer-sub-member-savez,asset/v3/private/transfer/universal-transferz!user/v3/private/create-sub-memberzuser/v3/private/create-sub-apizuser/v3/private/update-apizuser/v3/private/delete-apizuser/v3/private/update-sub-apizuser/v3/private/delete-sub-apiz,contract/v3/private/copytrading/order/createz,contract/v3/private/copytrading/order/cancelz+contract/v3/private/copytrading/order/closez.contract/v3/private/copytrading/position/closez5contract/v3/private/copytrading/position/set-leveragez/contract/v3/private/copytrading/wallet/transferz2contract/v3/private/copytrading/order/trading-stopz contract/v3/private/order/createz contract/v3/private/order/cancelz$contract/v3/private/order/cancel-allz!contract/v3/private/order/replacez0contract/v3/private/position/set-auto-add-marginz,contract/v3/private/position/switch-isolatedz(contract/v3/private/position/switch-modez-contract/v3/private/position/switch-tpsl-modez)contract/v3/private/position/set-leveragez)contract/v3/private/position/trading-stopz+contract/v3/private/position/set-risk-limitz)contract/v3/private/account/setMarginModezunified/v3/private/order/createz unified/v3/private/order/replacezunified/v3/private/order/cancelz%unified/v3/private/order/create-batchz&unified/v3/private/order/replace-batchz%unified/v3/private/order/cancel-batchz#unified/v3/private/order/cancel-allz(unified/v3/private/position/set-leveragez,unified/v3/private/position/tpsl/switch-modez*unified/v3/private/position/set-risk-limitz(unified/v3/private/position/trading-stopz2unified/v3/private/account/upgrade-unified-accountz(unified/v3/private/account/setMarginModez*fht/compliance/tax/v3/private/registertimez$fht/compliance/tax/v3/private/createz$fht/compliance/tax/v3/private/statusz!fht/compliance/tax/v3/private/urlzv5/order/createzv5/order/amendzv5/order/cancelzv5/order/cancel-allzv5/order/create-batchzv5/order/amend-batchzv5/order/cancel-batchz v5/order/disconnected-cancel-allzv5/position/set-leveragezv5/position/switch-isolatedzv5/position/set-tpsl-modezv5/position/switch-modezv5/position/set-risk-limitzv5/position/trading-stopzv5/position/set-auto-add-marginzv5/position/add-marginzv5/position/move-positionszv5/position/confirm-pending-mmrzv5/account/upgrade-to-utazv5/account/quick-repaymentzv5/account/set-margin-modezv5/account/set-hedging-modezv5/account/mmp-modifyzv5/account/mmp-resetzv5/account/borrowzv5/account/repayzv5/account/no-convert-repayzv5/asset/exchange/quote-applyz!v5/asset/exchange/convert-executez v5/asset/transfer/inter-transferz*v5/asset/transfer/save-transfer-sub-memberz$v5/asset/transfer/universal-transferz#v5/asset/deposit/deposit-to-accountzv5/asset/withdraw/createzv5/asset/withdraw/cancelzv5/user/create-sub-memberzv5/user/create-sub-apizv5/user/frozen-sub-memberzv5/user/update-apizv5/user/update-sub-apizv5/user/delete-apizv5/user/delete-sub-apizv5/spot-lever-token/purchasezv5/spot-lever-token/redeemz v5/spot-margin-trade/switch-modez!v5/spot-margin-trade/set-leveragezv5/spot-cross-margin-trade/loanz v5/spot-cross-margin-trade/repayz!v5/spot-cross-margin-trade/switchzv5/crypto-loan/borrowzv5/crypto-loan/repayzv5/crypto-loan/adjust-ltvzv5/ins-loan/association-uidzv5/lending/purchasezv5/lending/redeemzv5/lending/redeem-cancelz v5/account/set-collateral-switchz&v5/account/set-collateral-switch-batchzv5/account/demo-apply-moneyzv5/broker/award/infoz v5/broker/award/distribute-awardz#v5/broker/award/distribution-recordzv5/earn/place-order)r   post)r   r   httpExceptions403
exceptionsz-10009z-1004z-1021z-1103z-1140z-1197z-2013z-2015z-6017z-6025z-60295004700110001100021000310004100051000610007100081000910010100141001610017100181002010024100271002810029121371220112141100028110001110003110004110005110006110007110008110009110010110011110012110013110014110015110016110017110018110019110020110021110022110023110024110025110026110027110028110029110030110031110032110033110034110035110036110037110038110039110040110041110042110043110044110045110046110047110048110049110050110051110052110053110054110055110056110057110058110059110060110061110062110063110064110065110066110067110068110069110070110071110072110073110092110093110094130006130021130074131001131084131200131201131202131203131204131205131206131207131208131209131210131211131212131213131214131215131216131217131231131232131002131003131004131085131086131088131089131090131091131092131093131094131095131096131097131098131099140001140003140004140005140006140007140008140009140010140011140012140013140014140015140016140017140018140019140020140021140022140023140024140025140026140027140028140029140030140031140032140033140034140035140036140037140038140039140040140041140042140043140044140045140046140047140048140049140050140051140052140053140054140055140056140057140058140059140060140061140062140063140064140065140066140067140068140069140070170001170005170007170010170011170019170031170032170033170034170035170036170037170105170115170116170117170121170124170130170131170132170133170134170135170136170137170139170140170141170142170143170144170145170146170147170148170149170150170151170157170159170190170191170192170193170194170195170196170197170198170199170200170201170202170203170204170206170210170213170217170218170221170222170223170224170226170227170228170229170234170241175000175001175002175003175004175005175006175007175008175009175010175012175013175014175015175016175017175027176002176004176003176006176005176008176007176010176009176012176011176014176013176015176016176017176018176019176020176021176022176023176024176025176026176027176028176029176030176031176034176035176036176037176038176039176040181000181001181002181003181004182000181017200012000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232003120070200712008430001300033000430005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3004130042300433004430045300493005030051300523005430057300633006730068300743007530078330043402634036350153400993400045310011631001983200300)zNot supported symbolszRequest timeoutzunknown orderInfozinvalid api_keyoc_diffnew_oczopenapi sign params error!)exactbroadprecisionModeoptionsusePrivateInstrumentsInfoenableDemoTradingtypesrU   linearinverserY   enableUnifiedMarginenableUnifiedAccountunifiedMarginStatus!createMarketBuyOrderRequiresPricecreateUnifiedMarginAccountdefaultTypedefaultSubTyper  defaultSettleUSDTcodeBTC
recvWindowi  timeDifferencer   adjustForTimeDifferenceloadAllOptionsloadExpiredOptionsCCXTSPOTCONTRACTOPTION
INVESTMENTUNIFIEDFUND)
rU   rV   rX   rW   rY   
investmentunifiedfundingfundcontractr  r  r  r  )r  MARGINr  r  r  r  r  ERC20ETHTRC20TRXBEP20BSCSOLACAADAALGOAPTAPTOSARARBONEARBIAVAXCCAVAXAVAXXXAVAXATOMBCHBEP2BNBCHZDCRDGBDOGEDOTEGLDEOSETCETHFETHWFILSTEPFITFIFLOWFTMGLMRHBARHNTICPICXKDAKLAYKMAKSMLTCMATICMINAMOVRNEARNEMOASYSOASOASISROSEOMNIONEOPTIMISMOPPOKTQTUMRVNSCSCRTSTXTHETATONWAVESWAXWAXPXDCXECXLMXRPXTZXYMZENZILZKSYNC)r  r  r  r  SPL5min15min30minr   r   r   )r   r   r   r   r   r   )	brokerIdaccountsByTypeaccountsByIdnetworksnetworksByIddefaultNetworkdefaultNetworks	intervals!useMarkPriceForPositionCollateral)lastmarkindex)triggerPriceTypeprice)IOCFOKPOGTD)
marginModetriggerPricer6  triggerDirectionstopLossPricetakeProfitPriceattachedStopLossTakeProfittimeInForcehedgedselfTradePreventiontrailingicebergleveragemarketBuyRequiresPricemarketBuyByCostmaxd   i     )r<  limitdaysBack	untilDayssymbolRequired)r<  triggerrE  rP  )r<  rM  rQ  rE  rP  )r<  rM  rN  daysBackCanceledrO  rQ  rE  rP  rM    )
r   re   rf   r   r   r   r   r}   r   rr   defaultr   )r6  r>  rA  rH  )extendsr   re   rU  )r  r  )rT  rU   rW   rX   g~jtH?g-C6?)feeSide	tierBased
percentagetakermaker)rW  rX  r   deposit)tradingr  )featuresr   )deep_extendsuperrB   describer<   r3   r9   r/   r.   r=   r0   r1   r:   r8   r5   r6   r;   r>   r7   r4   r?   )self	__class__s    R/home/james-whalen/.local/lib/python3.13/site-packages/ccxt/async_support/bybit.pyr`  bybit.describe#   s:   eT ; = A@
'A@
GA@
 $A@
 t	A@

 A@
 A@
 A@
 4A@
 A@
  ooo $o 	o
 $o $o $To "4o 'o to o )$o $Uo  o %do  /!o" 0#o$ t%o& 'o( 7)o* &t+o, (-o. '/o0 &t1o2 (3o4 "45o6 (7o8 ,T9o: %d;o< T=o> d?o@ !$AoB CoD  EoF &uGoH +EIoJ )%KoL /MoN &tOoP #DQoR $TSoT )$UoV $TWoX $TYoZ +D[o\ ']o^ (_o` "4aob cod &teof (goh 1$ioj  kol *:mon +Doop &tqor #Jsot *4uov $Twox tyoz "4{o| *5}o~ +Eo@ tAoB  CoD %dEoF &uGoH -dIoJ /KoL +DMoN OoP !$QoR &tSoT +DUoV  WoX dYoZ $T[o\ +D]o^ !$_o` "4aob tcod #Deof dgoh !$ioj ukol #Dmon  oop '
qor !$sot (uov )$wox )$yoz t{o| }o~ To@ tAoB "4CoD #DEoF $UGoH !$IoJ (KoL )$MoN %)$(#!%#'  ]oA@
t uA@
R <?:>? j47267 :<7;<  /
 PF=SA@
R  B0!B 5aB <Q	B
 6qB 5aB ;AB <QB A!B 5aB /B >qB >qB )!B  Ea!B$ >q%B& 6q'B( 8)B* A!+B, A!-B. B1/B0 Ma1B2 @3B4 ?5B6 =a7B8 >q9B: :1;B> 1!?BB )!CBD *1EBF 5aGBH 6qIBJ >qKBL 5aMBN .qOBP ,QQBR 4QSBT 1!UBV 21WBX :1YBZ .q[B\ /]B^ 3A_B` 21aBd 3AeBf 8gBj 4QkBl :1mBn :1oBp B1qBr B1sBv 9!wBx 9:56=>+,CBDLg4ag 9"g
 0g 6sg 9#g 4Sg 23g 4Sg 1#g >rg ?g A"g Ebg  <R!g" >r#g$ 5b%g( Nr)g* J2+g, STV-g. RSU/g0 ;B1g2 A"3g4 Eb5g6 H7g8 I"9g: B2;g< DQ=g> 9!?g@ <QAgB =aCgD B1EgF EaGgH ?IgJ J1KgN CAOgP 8QgR ;ASgT <QUgV =aWgX ?YgZ DQ[g\ Ea]g^ DQ_g` A!agb :1cgd <Regf <Qggh 4Qigj :1kgl Mbmgn OPRogp PQSqgr Ebsgt Mdugv @wgx A"yg~ ,Qg@ +AAgB 5aCgF +AGgH ,QIgJ 1!KgL 3AMgP 7QgR 8SgT =aUgV A!WgX ?YgZ A![g^ 4Q_g` 4Qagb 6qcgd 5aegf /ggh .rigj *1kgl 5amgn >qogp /qgr /sgt 0ugx <Sygz A#{g| B3}g~ 9!g@ 3AAgB 5aCgD =bEgF HGgH GIgJ EbKgL FrMgN B2OgP J2QgR >qSgT 8UgV CBWgX A!YgZ 9"[g\ DR]g^ 3B_g` :2agb 9"cgd @egf 6qggj 4Qkgl ,Qmgn .qogp 21qgr 4Qsgt 0ugv -awgz 5a{g~ ;AgB EaCgD 5aEgF >qGgH >qIgJ 9!KgL J1MgN ?OgP =aQgR <QSgT CAUgX LQYgZ 8[g\ ;A]g^ 8_g` ?agb <Qcgf 4Qggh <Qigj 1!kgl 5amgn 21ogr *1sgt 56./453423KM+,)*,-)*01MgPK/K 7K 8	K
 ?K 3CK 1#K <RK =bK CCK ;CK ;BK HK McK  G!K" <R#K$ 9"%K& 5b'K( 5b)K* 9"+K, 9"-K0 G1K2 G3K4 Fr5K6 I"7K8 PQS9K: J2;K< Mc=K> ;A?K@ ;AAKB ?CKD <QEKF KAGKH GIKJ CAKKL HMKN DQOKP DQQKR FqSKT DQUKX :2YKZ ;B[K\ :2]K^ @_K` A"aKb @cKd >reKf CCgKh GiKj EckKl CCmKn McoKp CCqKt EbuKv ?wKx ?yKz <R{K@ *3AKB )!CKD *3EKF .rGKH 0IKJ /KKL 0MKN ;AOKR 3ASKT 6qUKV 4QWKX 21YKZ 5a[K\ 3A]K^ :1_K` 1!aKb 5acKd :1eKh 4QiKj 5akKl 5amKn 6qoKp 0qKr /sKt ,QuKv +AwKx 6qyK| 8}K~ <QK@ ;BAKB EcCKD ?EKF >qGKH 3BIKJ 3BKKN 4ROKP 1"QKR 4RSKT -bUKV 1"WKX -bYKZ 1"[K^ 7_K` 5caKd ;AeKf <QgKh :3iKj ;CkKl <SmKp 0qKr /sKt 4QuKx 6qyK| .q}K~ ,QK@ 3AAKB ;ACKD A!EKH 6qIKL /MKN ;AOKP >qQKT .qUKSuM|SA@
L (MA@
R }j}Z} Z} Z	}
 \} \} \} 0} Z} Z} Z} M} J} Z} \}  0!}" 0#}$ -%}& .'}( 0)}* -+}, 0-}. -/}0 Z1}2 ]3}4 Z5}6 .7}8 -9}: -;}< -=}> -?}@ -A}B \C}D ZE}F ZG}H .I}J mK}L lM}N /O}P lQ}R /S}T /U}V lW}X lY}Z l[}\ l]}^ /_}` ja}b /c}d je}f lg}h li}j jk}l lm}n lo}p lq}r ls}t lu}v jw}x hy}z 2{}| h}}~ j}@ jA}B lC}D lE}F lG}H lI}J lK}L lM}N lO}P lQ}R lS}T lU}V lW}X lY}Z l[}\ j]}^ /_}` /a}b jc}d je}f jg}h ji}j jk}l /m}n /o}p /q}r ls}t lu}v lw}x ly}z l{}| l}}~ j}@ jA}B jC}D mE}F lG}H .I}J mK}L .M}N .O}P .Q}R lS}T mU}V lW}X mY}Z l[}\ l]}^ l_}` la}b /c}d le}f /g}h mi}j mk}l mm}n jo}p jq}r js}t ju}v mw}x jy}z m{}| j}}~ j}@ jA}B /C}D jE}F jG}H jI}J mK}L mM}N lO}P lQ}R jS}T mU}V 1W}X /Y}Z j[}\ j]}^ j_}` ma}b mc}d me}f mg}h ji}j jk}l jm}n mo}p mq}r ms}t mu}v lw}x /y}z l{}| /}}~ /}@ lA}B lC}D lE}F lG}H /I}J jK}L /M}N lO}P lQ}R lS}T jU}V lW}X lY}Z l[}\ l]}^ l_}` ja}b jc}d je}f jg}h li}j jk}l lm}n jo}p lq}r ls}t lu}v lw}x jy}z l{}| j}}~ j}@ lA}B lC}D lE}F jG}H /I}J /K}L jM}N jO}P jQ}R jS}T lU}V /W}X /Y}Z /[}\ l]}^ l_}` la}b lc}d le}f lg}h ji}j jk}l jm}n mo}p lq}r .s}t mu}v .w}x .y}z .{}| l}}~ m}@ lA}B nC}D lE}F lG}H lI}J mK}L mM}N /O}P /Q}R jS}T jU}V jW}X jY}Z l[}\ l]}^ l_}` la}b lc}d je}f /g}h li}j lk}l lm}n lo}p lq}r ls}t lu}v lw}x ly}z l{}| l}}~ l}@ lA}B lC}D lE}F lG}H mI}J mK}L lM}N lO}P lQ}R lS}T lU}V lW}X lY}Z l[}\ l]}^ l_}` la}b lc}d le}f lg}h .i}j lk}l lm}n lo}p lq}r ls}t mu}v lw}x ly}z j{}| /}}~ /}@	 .A	}B	 /C	}D	 mE	}F	 lG	}H	 lI	}J	 mK	}L	 5M	}N	 lO	}P	 lQ	}R	 lS	}T	 /U	}V	 lW	}X	 lY	}Z	 /[	}\	 l]	}^	 l_	}`	 la	}b	 .c	}d	 le	}f	 lg	}h	 li	}j	 lk	}l	 lm	}n	 lo	}p	 mq	}r	 js	}t	 ju	}v	 jw	}x	 jy	}z	 j{	}|	 j}	}~	 j	}@
 jA
}B
 jC
}D
 jE
}F
 jG
}H
 jI
}J
 jK
}L
 /M
}N
 jO
}P
 jQ
}R
 jS
}T
 jU
}V
 jW
}X
 jY
}Z
 j[
}\
 j]
}^
 j_
}`
 ja
}b
 jc
}d
 je
}f
 jg
}h
 ji
}j
 jk
}l
 jm
}n
 jo
}p
 .q
}r
 .s
}t
 .u
}v
 jw
}x
 jy
}z
 j{
}|
 j}
}~
 j
}@ lA}B lC}D lE}F lG}H jI}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 Zw}x Zy}z Z{}| 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 \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}h 0i}j ]k}l Zm}n Zo}p mq}r }s}t zu}v zw}x 0y}~ .7'5)6':0/2E	INSA@
p YqA@
r  K+UK#UK D!K &tK 'K &tK 4UK -eK vK !(K  K K hK  !!!K" *5#K$ !%%K& %e'K( #"$(&&".(%" *# #$ *&".("!LULUL UL 5	L
 5L 5L FL 7L $L fL WL WL FL 5L EL  5!L" 5#L$ 5%L& F'L( 5)L* F+L, 5-L. 5/L0 F1L2 F3L4 55L6 G7L8 F9L: 5;L< F=L> F?L@ 5ALB 5CLD 5ELF 5GLH FILJ 5KLL 5MLN 5OLT WULV FWLX FYLZ F[L\ 5]L^ U_L` VaLb FcLd 5eLf gLh FiLj FkLl 5mLn $oLp FqLr 5sLt WuLv 5wLx WyLz 6{L| 5}L~ 5L@ 5ALB 5CLD 5ELF 5GLH 5ILJ 5KLL hML\ #""" ! #*G$ !"" 6;UKsA@
N$  $&+(,$($(%)-
 -1)-+/ )-(,)-1
 &*7 $(#'"&#(	( #'/3$(#($)27+/? $D r% ',!$$+%&*/& ',#'$)*.	# ',!##'$)*/( $(&+!#$+,-%&#'$)*/	*  # r#QKZ  )!4( -1,104%)7 37$" "9 "9 	 "9 "9 	Il^  %!%"&$# "'"' "!	e'A@
 A A	    enablec                    U R                   (       a  [        U R                  S-   5      eU(       a9  U R                  S   U R                  S'   U R                  S   U R                  S'   ONSU R                  ;   a>  U R                  S   U R                  S'   U R	                  U R                  S5      nX l        XR
                  S'   g)z
enables or disables demo trading mode

https://bybit-exchange.github.io/docs/v5/demo

:param boolean [enable]: True if demo trading should be enabled, False otherwise
z5 demo trading does not support in sandbox environmentr   apiBackupDemoTradingr   r  N)isSandboxModeEnabledr;   rF   r   omitr  )ra  rf  newUrlss      rc  enable_demo_tradingbybit.enable_demo_trading'  s     $$tww)``aa04		%0@DII,-#yy7DIIe#tyy0#yy)?@DIIeii		+ABGI,2()re  c                 B    U R                  5       U R                  S   -
  $ )Nr  )millisecondsr  )ra  s    rc  noncebybit.nonce;  s       "T\\2B%CCCre  c                     U R                  US0 5      nU R                  U/ SQ/ 5      nU R                  USS5      n[        U5      nUb  US:  a  US   nXFS'   XcS'   U$ )Nresult)listrowsdatadataListnextPageCursorcursorr   )	safe_dictsafe_list_nsafe_string_2len)ra  responsers  rv  paginationCursor
dataLengthfirsts          rc  add_pagination_cursor_to_result%bybit.add_pagination_cursor_to_result>  sr    (B7(LbQ--f6FQY
(zA~GE&6"#Gre  c                 (  #    U R                  U R                  S5      nU R                  U R                  S5      nUb  UGc0  U R                  S   (       aK  SU R                  S'   SU R                  S'   SU R                  S'   U R                  S   U R                  S   /$ U R                  U5      U R                  U5      /n[        R
                  " U6 I Sh  vN nUS	   nUS
   nU R                  US0 5      nU R                  US0 5      n	U R                  US5      S
:H  U R                  S'   U R                  US5      S
:H  U R                  S'   U R                  U	SS5      U R                  S'   U R                  S   U R                  S   /$  N7f)aw  

https://bybit-exchange.github.io/docs/v5/user/apikey-info#http-request
https://bybit-exchange.github.io/docs/v5/account/account-info

returns [enableUnifiedMargin, enableUnifiedAccount] so the user can check if unified account is enabled
:param dict [params]: extra parameters specific to the exchange API endpoint
:returns any: [enableUnifiedMargin, enableUnifiedAccount]
r  r  Nr  FT   r  r   r   rs  r  uta)	safe_boolr  privateGetV5UserQueryApiprivateGetV5AccountInfoasynciogatherrz  safe_integer)
ra  paramsr  r  rawPromisespromisesr~  accountInfors  accountResults
             rc  is_unified_enabledbybit.is_unified_enabledI  s     #nnT\\;PQ#~~dll<RS&*>*F||/0 7<237;346723%:;T\\J`=abb88@$B^B^_eBfgK$^^[99H{H"1+Kp ^^Hh;F NN;"EM262C2CFI2VZ[2[DLL./373D3DVU3SWX3XDLL/0262C2CMShjk2lDLL./23T\\BX5YZZ :s   CFFB7Fc                 @   #    U R                  U5      I Sh  vN $  N7f)z
upgrades the account to unified trade account *warning* self is irreversible

https://bybit-exchange.github.io/docs/v5/account/upgrade-unified-account

:param dict [params]: extra parameters specific to the exchange API endpoint
:returns any: nothing
N) privatePostV5AccountUpgradeToUta)ra  r  s     rc  upgrade_unified_trade_account#bybit.upgrade_unified_trade_account  s      ::6BBBB   symbolc                    S nS nUR                  S5      nUR                  S5      nS nS nUR                  S5      S:  a^  U R                  US5      nU R                  US5      nU R                  US5      nUR                  S5      n	U R                  U	S5      n
U
nU
nORU R                  US5      nU R                  U R                  US5      5      nUR	                  S5      (       a  SnSnOS	nS	nU R                  US
5      nU R                  US5      nU R                  U5      nU R                  U5      nS nS nUS:X  a#  U R                  S5      nU R                  S5      nOQUS:X  a#  U R                  S5      nU R                  S5      nO(US:X  a"  U R                  S5      nU R                  S5      n0 SUS-   U R                  U5      -   S-   U-   S-   U-   _SUS-   U-   S-   U-   S-   U-   S-   U-   S-   U-   _SU_SU_SU_SU_SU_SU_SS_SS_SS _S S _S!S_S"S_S#S_SS$_S%S_S$U R                  S5      UUUS&:X  a  S'OS(U R                  U5      UUS).S S S*.S S S*.S S S*.S+.S S,.	E$ )-N-/r   r   :z-USDTr  USDC      r  z0.01r   r  z0.1r  r   rF   r  basequotesettlebaseIdquoteIdsettleIdactiveFtyperY   r  r  rU   rW   rX   TrV   Ccallputamountr7  minrJ  )r  r7  cost)	r  contractSizeexpiryexpiryDatetime
optionTypestrike	precisionlimitsinfo)	splitfindsafe_stringconvert_market_id_expire_dateendswithconvert_expire_date	parse8601parse_number%convert_expire_date_to_market_id_date)ra  r  r  r  optionParts
symbolBaser  r  symbolQuoteAndSettle
splitQuotequoteAndSettler  r  datetime	timestampamountPrecisionpricePrecisions                    rc  create_expired_option_market"bybit.create_expired_option_market  s`   ll3'\\#&
;;sb ##J2D%%k15F#'#3#3J#B -33C8J!--j!<N"E#F##K3D778H8HVW8XYFw''!!+q1%%k15
++F3NN8,	5="//7O!..s3NU]"//6O!..u5NU]"//4O!..v6N+
$*tII&QQTWWZ``cffiss+
dSj5(3.7#=FLvUX[[^hh+
 D+
 U	+

 f+
 d+
 u+
 +
 e+
 H+
 d+
 t+
 E+
 E+
 e+
  d!+
" e#+
$  --c2&%/3%6&U''/)'  
  
   U+
 +	
re  NmarketIdmarket	delimiter
marketTypec                    > US L=(       a/    UR                  S5      S:  =(       d    UR                  S5      S:  nU(       a   XR                  ;  a  U R                  U5      $ [        [        U ]  XX45      $ )Nz-Cr  z-P)r  markets_by_idr  r_  rB   safe_market)ra  r  r  r  r  isOptionrb  s         rc  r  bybit.safe_market  sh    D(hd0Cb0H/ghmm\`NadfNfX););;44X>>UD-h	VVre  c                 ~    S nU R                  XU5      u  pCS nU R                  XU5      u  pSUS:X  d  US:X  a  XC/$ XS/$ )NrY   rU   )handle_market_type_and_paramshandle_sub_type_and_params)ra  methodr  r  r  subTypes         rc  get_bybit_typebybit.get_bybit_type
  sS    99&&Q99&&Q8tv~>!  re  r  c                     U R                  U5      nUS   S   S L nU R                  U5      nU(       d  US:w  a  U R                  X5      $ U$ )Nr  r  0)r  number_to_stringamount_to_precision)ra  r  r  r  emptyPrecisionAmountamountStrings         rc  
get_amountbybit.get_amount  sX     V$ &{ 3H = E,,V4#)<++F;;re  r7  c                 v    Uc  U$ U R                  U5      nUS   S   S L nU(       d  U R                  X5      $ U$ Nr  r7  )r  price_to_precision)ra  r  r7  r  emptyPrecisionPrices        rc  	get_pricebybit.get_price  sH    =LV$%k27;tC"**699re  r  c                 l    U R                  U5      nUS   S   S L nU(       d  U R                  X5      $ U$ r  )r  cost_to_precision)ra  r  r  r  r  s        rc  get_costbybit.get_cost&  s>    V$%k27;tC"))&77re  c                 d   #    U R                  U5      I Sh  vN nU R                  US5      $  N7f)a)  
fetches the current integer timestamp in milliseconds from the exchange server

https://bybit-exchange.github.io/docs/v5/market/time

:param dict [params]: extra parameters specific to the exchange API endpoint
:returns int: the current integer timestamp in milliseconds from the exchange server
Ntime)publicGetV5MarketTimer  )ra  r  r~  s      rc  
fetch_timebybit.fetch_time-  s4      33F;;   622 <s   0.0c                   #    U R                  S5      (       d  0 $ U R                  S   (       a  0 $ U R                  U5      I Sh  vN nU R                  US0 5      nU R	                  US/ 5      n0 n[        S[        U5      5       GH^  nXF   nU R                  US5      nU R                  U5      n	U R                  US5      n
U R	                  US	/ 5      n0 n[        S[        U5      5       H  nX   nU R                  US
5      nU R                  U5      nUUUSU R                  US5      S:H  U R                  US5      S:H  U R                  US5      U R                  U R                  U R                  US5      5      5      U R                  US5      SS.U R                  US5      SS.S.S.	UU'   M     U R                  UU	UU
SSSSSSSS.SSS.SSS.S.USS.5      XY'   GMa     U$  GN7f)z
fetches all available currencies on an exchange

https://bybit-exchange.github.io/docs/v5/asset/coin-info

:param dict [params]: extra parameters specific to the exchange API endpoint
:returns dict: an associative dictionary of currencies
Fr  Nrs  ru  r   coinrG   chainschainchainDepositr   chainWithdrawwithdrawFeeminAccuracywithdrawMinr  
depositMin)r   r[  )	r  rF   networkr  r[  r   feer  r  r  r   r[  crypto)r  r  rF   rG   r  r[  r   r   r  r  r-  r  )check_required_credentialsr  privateGetV5AssetCoinQueryInforz  	safe_listranger}  r  safe_currency_codenetwork_id_to_coder  safe_numberr  parse_precisionsafe_currency_structure)ra  r  r~  rv  ru  rs  icurrency
currencyIdr  rG   r  r-  jr  	networkIdnetworkCodes                    rc  fetch_currenciesbybit.fetch_currenciesE  s<     ..u55I<<+,I<<VDD> ~~h"5~~dFB/q#d)$AwH))(F;J**:6D##Hf5D^^Hh;FH1c&k*	 ,,UG<	"55i@!#*"#00G1L $ 1 1% IQ N++E=A!%!2!243G3GHXHXY^`mHn3o!p $(#3#3E=#I#'%
 $(#3#3E<#H#'$	)%	 +0  77   !  $#
  $#!
  $#  % 39 FL? %t y Es   AG/G,F'G/c                 4  #    U R                   S   (       a  U R                  5       I Sh  vN   / nSn/ SQnU R                  U R                   S5      nUb  U R                  USU5      nOU R                  U R                   SU5      n[	        S[        U5      5       GH  nX6   nUS:X  a"  UR                  U R                  U5      5        M0  US:X  a$  UR                  U R                  S	S05      5        MZ  US
:X  a$  UR                  U R                  S	S
05      5        M  US:X  ah  UR                  U R                  SS05      5        UR                  U R                  SS05      5        UR                  U R                  SS05      5        M  [        U R                  S-   U-   S-   5      e   [        R                  " U6 I Sh  vN nU R                  US/ 5      n	U R                  US/ 5      n
U R                  US/ 5      nU R                  US/ 5      nU R                  US/ 5      nU R                  US/ 5      nU R                  X5      nU R                  X5      nU R                  UU5      nU R                  UU5      nU R                  U	U5      $  GNi N7f)z
retrieves data on all markets for bybit

https://bybit-exchange.github.io/docs/v5/market/instrument

:param dict [params]: extra parameters specific to the exchange API endpoint
:returns dict[]: an array of objects representing market data
r  Nr  r   r  r   rU   r  categoryr  rY   baseCoinr  r  r  z+ fetchMarkets() self.options fetchMarkets "z " is not a supported market typer   r  r     r   )r  load_time_differencerz  r  r  r}  appendfetch_spot_marketsfetch_future_marketsfetch_option_marketsr.   rF   r  r  array_concat)ra  r  promisesUnresolvedr  defaultTypesfetchMarketsOptionsr  r  r  spotMarketslinearMarketsinverseMarketsbtcOptionMarketsethOptionMarketssolOptionMarketsfutureMarketsoptionMarketsderivativeMarketss                     rc  fetch_marketsbybit.fetch_markets  s     <<12++--->"nnT\\>J*NN#6NE NN4<<NEq#e*%AJV#"))$*A*A&*IJx'"))$*C*CZQYDZ*[\y("))$*C*CZQZD[*\]x'"))$*C*CZQVDW*XY"))$*C*CZQVDW*XY"))$*C*CZQVDW*XY#DGG.[$[^h$h  lN  %N  O  O & !);<<nnXq"5xB7!R8>>(Ar:>>(Ar:>>(Ar:))-H))*:M))-9IJ --m]K  .?@@G .0 =s#   (JJFJJCJJc                 >  #    SS0nU R                  U R                  SS5      nS nU(       a)  U R                  U R                  X!5      5      I S h  vN nO(U R	                  U R                  X!5      5      I S h  vN nU R                  US0 5      nU R                  US/ 5      n/ nU R                  S5      nU R                  S5      n	[        S[        U5      5       GH  n
Xj   nU R                  US	5      nU R                  US
5      nU R                  US5      nU R                  U5      nU R                  U5      nUS-   U-   nU R                  US5      nUS:H  nU R                  US5      nU R                  US5      nU R                  US5      nU R                  USS5      nUS:g  nUR                  U R                  0 SU_S	U_SU_SU_SS _SU_SU_SS _SS_SS_SU_SS_SS_S S_S!U_S"S_S#S _S UU	S S S S S U R                  US$5      U R                  US%U5      S&.U R                  S'5      S S(.U R                  US)5      U R                  US*5      S(.S S S(.U R                  US+5      U R                  US,5      S(.S-.S US..E5      5        GM     U$  GNG GN!7f)/Nr  rU   r  Frs  rt  z0.001r   r  r  	quoteCoinr  statusTradinglotSizeFilterpriceFilterquotePrecisionmarginTradingnonerF   r  r  r  r  r  r  r  TrV   rW   rX   rY   r  r  r  basePrecisiontickSizer  r   r  minOrderQtymaxOrderQtyminOrderAmtmaxOrderAmtrG  r  r7  r  r  rY  rZ  r  r  r  r  r  r  r  createdr  )r  r  !privateGetV5MarketInstrumentsInfoextend publicGetV5MarketInstrumentsInforz  r  r  r  r}  r  r  r	  r  safe_market_structure)ra  r  requestr  r~  responseResultmarketsrs  takerFeemakerFeer  r  rF   r  r  r  r  r  r.  r  r0  r1  r2  r3  allowsMargins                            rc  r  bybit.fetch_spot_markets  se    
 %)NN4<<A\^c$d!$!CCDKKPWD`aaH!BB4;;wC_``HB (B?..<$$W-$$W-q#g,'AZF!!&(3B%%fj9F&&v{;G**62D++G4ECZ%'F%%fh7F	)F NN6?CM..?K!--m=MNN ,,V_fMM(F2LMM$44 26b26&26 26 	26
 $26 &26 726 D26 26 26 ,26 26 %26 %26 &26  E!26" $#26$  !! $"&""..}oN!--k:~V  $005#!
  $//}M#//}M
  $#
  $//}M#//}M$  c26 2 2 (D U b`s%   AJJ(J9J:HJJc                 
  #    U R                  U5      nSUS'   / nU R                  U R                  SS5      nS nU(       a  U R                  U5      I S h  vN nOuU R	                  U5      U R	                  U R                  USS05      5      /n[
        R                  " U6 I S h  vN nU R                  US0 5      nU R                  US0 5      nU R                  US	0 5      nU R                  US
/ 5      nU R                  US5      n	U	b  U	b  XS'   S n
U(       a  U R                  U5      I S h  vN n
OU R	                  U5      I S h  vN n
U R                  U
S	0 5      nU R                  US
/ 5      n[        U5      nUS:X  a  O(U R                  X5      nU R                  US5      n	U	b  M  U R                  US	0 5      nU R                  US
/ 5      nU R                  X5      n/ nU R                  US5      n[        S[        U5      5       GHF  nUU   nUc  U R                  US5      nUS:H  nUS:H  nU R                  US5      nUS:H  nUS:H  nUS:H  nUS:H  nU R                  US5      nU R                  US5      nU R                  US5      nU(       a  UOUnU R                  USU5      nU R                  U5      n U R                  U5      n!S n"U(       a	  US:X  a  Sn"OU R                  U5      n"U S-   U!-   n#U R                  US0 5      n$U R                  US0 5      n%U R                  US0 5      n&U R                  US5      n'U=(       d    Un(U=(       d    Un)S n*U((       a  Sn*O	U)(       a  S n*S n+U((       d/  U R                  U R                  US!5      5      n+U+b  [        U+5      n+U R!                  U+5      n,U#S"-   U"-   n#U+b  U#S#-   U R#                  U+5      -   n#U(       a  U R%                  U$S$S%5      OU R'                  S&5      n-UR)                  U R+                  0 S'U_SU#_S(U _S)U!_S*U"_S+U_S,U_S-U_S.U*_S/S_S0S _SU(_S U)_S1S_S2U'S3:H  _S4S5_SU_UU R-                  US6U R'                  S75      5      U R-                  US8U R'                  S95      5      U-U+U,S S U R-                  U$S:5      U R-                  U%S;5      S<.U R-                  U&S=5      U R-                  U&S>5      S?.U R%                  U$S$S%5      U R%                  U$S@SA5      S?.U R-                  U%SB5      U R-                  U%SC5      S?.S S S?.SD.U R/                  USE5      USF.E5      5        GMI     U$  GN GN GN2 GN7f)GNrS  rM  r  Fr.  	PreLaunchr   r   rs  rt  rx  ry  r  r  r  contractTypeInverseFuturesLinearFuturesLinearPerpetualInversePerpetualr  r  r-  
settleCoinUSDr  r  r0  r1  leverageFilterrW   rX   deliveryTimer  r  minTradingQtyr7  r   rF   r  r  r  r  r  r  r  rU   rV   rY   r  r/  r  TrE  0.0006rF  0.0001qtyStepr6  r  minLeveragemaxLeverager  maxTradingQtyr8  minPricemaxPricer;  
launchTimer<  )r?  r  r  r>  r@  r  r  rz  r  r  r}  r  r  r  	omit_zerointiso8601yymmddsafe_number_2r  r  rA  r	  r  ).ra  r  preLaunchMarketsr  r~  linearPromisesr  rv  rD  r  responseInnerdataNew
rawMarketsrawMarketsLengthpreLaunchDatapreLaunchMarketsListrs  r  r  r  r  r  rK  inverseFutureslinearFutureslinearPerpetualinversePerpetualrF   r  r  defaultSettledIdr  r  r  r  r  r0  r1  rG  r.  rW   rX   r  r  r  r  s.                                                 rc  r  bybit.fetch_future_marketsR  sU    V$w$(NN4<<A\^c$d!$!CCFKKH 55f=55dkk&8U`Ja6bcN %^^^<<H~~h26H#~~h2>~~h"5..vr2++D2BC'".#3x &*,*.*P*PQW*X$XM*.*O*OPV*W$WM.."E!^^GVR@
#&z? #q(++J@#'#3#3G=M#N  #.t '72F#~~mVRH##GB##D*5q#g,'AQZF++FJ?(*F9,G++FNCL*.>>N)_<M+/@@O ,0B B!!&(3B%%fj9F&&v{;G*0wf''>NOH**62D++G4EFH$500:CZ%'F NN6?BGM..CK~~f.>CH%%fh7F"6&6D#4}FDF(8(8(PQ% [F!\\&1Nc\F*F!#F(;;`g4--m_m\mqm~m~  @C  nDLMM$44 26b26&26 26 	26
 &26 &26 726 H26 26 26 $26 26 &26 %26 6Y.26  D!26" &#26$ #))&*d>O>OPX>YZ))&*d>O>OPX>YZ , "0""..}iH!--k:F  $//-H#//-H!
  $11-R_`#11-R_`
  $//ZH#//ZH
  $#$  ,,V\Bc26 2 2] (B [ L = %Y$WsR   AU'UAU'%U&B	U'/U!0U'	U$
A"U'.N.U'U'!U'$U'c                 &	  #    SS0nU R                  U R                  SS5      nS nU(       a)  U R                  U R                  X!5      5      I S h  vN nO(U R	                  U R                  X!5      5      I S h  vN nU R                  US0 5      nU R                  US/ 5      nU R                  S   (       a  SUS	'   U R                  US
5      nUb  Ub  XrS'   S nU(       a)  U R                  U R                  X!5      5      I S h  vN nO(U R	                  U R                  X!5      5      I S h  vN nU R                  US0 5      n	U R                  U	S/ 5      n
[        U
5      nUS:X  a  O(U R                  X5      nU R                  U	S
5      nUb  M  / n[        S[        U5      5       GH  nXm   nU R                  US5      nU R                  US5      nU R                  US5      nU R                  US5      nU R                  U5      nU R                  U5      nU R                  U5      nU R                  US0 5      nU R                  US0 5      nU R                  US5      nU R                  US5      nUR                  S5      nU R                  US5      nU R                  US5      nUS:H  nUU:H  nU(       d+  U R                  S   (       d  U R                  S   (       d  GM>  UR                  U R                  0 SU_SUS-   U-   S-   U-   S-   U R!                  U5      -   S-   U-   S-   U-   _SU_SU_SU_S U_S!U_S"U_S#S_S$S _S%S_S&S_S'S_S(S_SS)_S*U_S+S)_U(       + UU R#                  US,U R%                  S-5      5      U R#                  US.U R%                  S/5      5      U R%                  S05      UU R'                  U5      U R%                  U5      U R)                  US15      U R#                  US25      U R#                  US35      S4.S S S5.U R#                  US65      U R#                  US75      S5.U R#                  US85      U R#                  US95      S5.S S S5.S:.U R                  US;5      US<.E5      5        GM     U$  GN5 GN GN GN`7f)=Nr  rY   r  Frs  rt  r  rS  rM  rx  ry  r   r  r  r-  rP  r0  r1  r.  rS  r  r  r  r/  r  rF   r  r  r  r  r  r  r  r  r  r  rU   rV   rW   rX   Tr  r  rE  rU  rF  rV  r   optionsTyperW  r6  r  r  r7  r8  r[  r\  r;  r]  )r  r  rY  rZ  r  r  r  r  r  r  r  r=  r  )r  r  r>  r?  r@  rz  r  r  r}  r  r  r  r  r  r  rA  ra  r	  r  r`  safe_string_lower)ra  r  rB  r  r~  rv  rD  r  re  rf  rg  rh  rs  r  r  rF   r  r  r  r  r  r  r0  r1  r.  r  splitIdr  optionLetterisActive	isInverses                                  rc  r  bybit.fetch_option_markets  s1    
 %)NN4<<A\^c$d!$!CCDKKPWD`aaH!BB4;;wC_``H~~h"5..vr2<<()#GG#//6FG+&2(8H%*.M0.2.T.TUYU`U`ahUq.r(r.2.S.STXT_T_`gTp.q(q"nn]HbIG!%!DJ'*:$'1,"//
DG'+'7'7AQ'R$ '2b q#g,'AZF!!&(3B%%fj9F&&v{;G''=H**62D++G4E,,X6F NN6?BGM..CK%%fh7F&&v~>FhhsmG%%gq1F++GQ7L)+HIDLL)9:Ma@b@bd88 3:"3:dSj5036?#ETZH[[^aadjjmpps3: D3: U	3:
 f3: f3: w3: 3: H3: t3: E3: e3: E3: e3: d3:  h!3:" #3:$ #,m(!--fj$BSBST\B]^!--fj$BSBST\B]^$($5$5c$:$&*ll6&:"//7"&"8"8"O"&"2"2=)"L!%!1!1+z!J" $(#'%
 $(#3#3M=#Q#'#3#3M=#Q#
 $(#3#3K#L#'#3#3K#L"
 $(#'!$  $00F"e3: 3 3' (N E b` )s(qsX   ARR(R9R:BRR(R.R/A"RER(FRRRRtickerc           
         U R                  US5      S L nU R                  US5      nU R                  US5      nU(       a  SOSnU R                  XRS U5      nU R                  XRS U5      nU R                  US5      nU R                  US5      n	U R                  US5      n
[        R
                  " U
S	5      n
U R                  US
5      nU R                  US5      nU R                  US5      nU R                  US5      nU R                  US5      nU R                  US5      nU R                  0 SU_SU_SU R                  U5      _SU_SU_SU_SU R                  USS5      _SU_SU R                  USS5      _SS _SU	_SU_SU_S S _S!S _S"U
_S#S _UUU R                  US$5      U R                  US%5      US&.EU5      $ )'NopenInterestValuer  r  rU   r  	lastPriceprevPrice24hprice24hPcnt100turnover24h	volume24h	bid1Price	ask1PricehighPrice24hlowPrice24hr  r  highlowbid	bidVolumebidSizebid1Sizeask	askVolumeaskSizeask1Sizevwapopencloser3  previousClosechangerX  average	markPrice
indexPrice)
baseVolumequoteVolumer  r  r  )	r  r  r  safe_symbolr@   
string_mulsafe_tickerr`  r|  )ra  ry  r  isSpotr  r  r  r  r3  r  rX  r  r  r  r  r  r  s                    rc  parse_tickerbybit.parse_ticker  sb   \ !!&*=>$F%%ff5	##FH5vZ!!(D$?!!(D$?47%%fn=
''
E:
&&v}=%%fk:
v{3v{37v}5 !
f!
!
 Y/!
 D	!

 3!
 3!
 ++FIzJ!
 3!
 ++FIzJ!
 D!
 D!
 T!
 D!
 T!
 d!
  *!!
" t#!
$ %&))&+>**6<@-!
. / 	re  c                   #    Uc  [        U R                  S-   5      eU R                  5       I Sh  vN   U R                  U5      nSUS   0nSnU R	                  SX25      u  pRXTS'   U R                  U R                  XB5      5      I Sh  vN nU R                  US0 5      nU R                  US/ 5      nU R                  US	5      n	U R                  X5      $  N NO7f)
a  
fetches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market

https://bybit-exchange.github.io/docs/v5/market/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
:returns dict: a `ticker structure <https://docs.ccxt.com/#/?id=ticker-structure>`
Nz) fetchTicker() requires a symbol argumentr  rF   r   r  rs  rt  r   )
r2   rF   load_marketsr  r  publicGetV5MarketTickersr?  rz  r  r  )
ra  r  r  r  rB  r  r~  rs  tickers	rawTickers
             rc  fetch_tickerbybit.fetch_ticker
	  s      >#DGG.Y$YZZ!!!V$fTl

 ..}fM&
66t{{77STTN (B7..4NN7A.	  33i 	" Us#   /CCACCACCsymbolsc                   #    U R                  5       I Sh  vN   U R                  U/ SQ5      nSnSnUGb  / nU R                  SSU5      nUS   nSn[        S[	        U5      5       H  n	X   n
U
R                  S5      S:H  nU(       a  U R                  U
SSU5      nOU R                  U
5      nUc  US   nO!US   U:w  a  [        U R                  S-   5      eUS	   (       a?  Ub   X4S
   :w  a  [        U R                  S-   5      eUc  US
   nU R                  USS/5      nUR                  US   5        M     0 nSnU R                  SXB5      u  pXS'   US	:X  a  S	US'   Uc  SnX<S'   U R                  U R                  X5      5      I Sh  vN nU R                  US0 5      nU R!                  US/ 5      nU R#                  UU5      $  GN N?7f)ac  
fetches price tickers for multiple markets, statistical information calculated over the past 24 hours for each market

https://bybit-exchange.github.io/docs/v5/market/tickers

:param str[] symbols: unified symbols of the markets to fetch the ticker for, all market tickers are returned if not assigned
:param dict [params]: extra parameters specific to the exchange API endpoint
:param str [params.subType]: *contract only* 'linear', 'inverse'
:param str [params.baseCoin]: *option only* base coin, default is 'BTC'
:returns dict: an array of `ticker structures <https://docs.ccxt.com/#/?id=ticker-structure>`
N)r  r  r  r   r   r  r  r  z@ fetchTickers can only accept a list of symbols of the same typerY   r  z fetchTickers the base currency must be the same for all symbols, self endpoint only supports one base currency at a time. Read more about it here: https://bybit-exchange.github.io/docs/v5/market/tickersr  r  r  r  r  r  rs  rt  )r  safe_string_nr  r  r}  r  r  r  r3   rF   rj  r  r  r  r?  rz  r  parse_tickers)ra  r  r  r  r  parsedSymbolsmarketTypeInfor  currentTyper  r  isExchangeSpecificSymbolrB  r  r~  rs  
tickerLists                    rc  fetch_tickersbybit.fetch_tickersL	  s     !!!!!&*JKM!??PTV\]N(+KK1c'l+  -3KK,<,B(+!--fdD+NF![[0F&"(.KF^{2$TWW/q%qrr(#'D6N,B(  4A  *A  B  B|%f~!YYv
/CDF$$VH%56' ,(

 ..~vN&
x"*GJ|"&J66t{{77STTN (B7^^FFB7
!!*m<<i 	"V Us"   GGE7GG=GGc                 @   #    U R                  X5      I Sh  vN $  N7f)a4  
fetches the bid and ask price and volume for multiple markets

https://bybit-exchange.github.io/docs/v5/market/tickers

:param str[]|None symbols: unified symbols of the markets to fetch the bids and asks for, all markets are returned if not assigned
:param dict [params]: extra parameters specific to the exchange API endpoint
:param str [params.subType]: *contract only* 'linear', 'inverse'
:param str [params.baseCoin]: *option only* base coin, default is 'BTC'
:returns dict: a dictionary of `ticker structures <https://docs.ccxt.com/#/?id=ticker-structure>`
N)r  )ra  r  r  s      rc  fetch_bids_asksbybit.fetch_bids_asks	  s      ''8888r  c           	          US   (       a  SOSnU R                  US5      U R                  US5      U R                  US5      U R                  US5      U R                  US5      U R                  X5      /$ )	Nr  r  r   r   r   r  r  r  )r  r	  )ra  ohlcvr  volumeIndexs       rc  parse_ohlcvbybit.parse_ohlcv	  sz     #9-aAeQ'UA&UA&UA&UA&U0
 	
re  r   	timeframesincerM  c           	        #    Uc  [        U R                  S-   5      eU R                  5       I Sh  vN   SnU R                  USS5      u  peU(       a  U R	                  SXXBUS5      I Sh  vN $ U R                  U5      nSUS   0nUc  S	nUb  X8S
'   Ub  XHS'   U R                  SX5      u  pU R                  U R                  X"5      US'   Sn	US   (       a/  SUS'   U R                  U R                  X5      5      I Sh  vN n	GOU R                  US5      n
U R                  US5      nUS   (       a  SUS'   O(US   (       a  SUS'   O[        U R                  S-   5      eU
S:X  a)  U R                  U R                  X5      5      I Sh  vN n	OU
S:X  a)  U R                  U R                  X5      5      I Sh  vN n	OWU
S:X  a)  U R                  U R                  X5      5      I Sh  vN n	O(U R                  U R                  X5      5      I Sh  vN n	U R!                  U	S0 5      nU R#                  US/ 5      nU R%                  XX#U5      $  GN# GN GNW N N Ns NL7f)a3  
fetches historical candlestick data containing the open, high, low, and close price, and the volume of a market

https://bybit-exchange.github.io/docs/v5/market/kline
https://bybit-exchange.github.io/docs/v5/market/mark-kline
https://bybit-exchange.github.io/docs/v5/market/index-kline
https://bybit-exchange.github.io/docs/v5/market/preimum-index-kline

: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 int [params.until]: the latest time in ms to fetch orders for
:param boolean [params.paginate]: default False, when True will automatically paginate by calling self endpoint multiple times. See in the docs all the [availble parameters](https://github.com/ccxt/ccxt/wiki/Manual#pagination-params)
:returns int[][]: A list of candles ordered, open, high, low, close, volume
Nz( fetchOHLCV() requires a symbol argumentFr   paginaterS  r  rF      startrM  endintervalrU   r  r7  r  r  z1 fetchOHLCV() is not supported for option marketsr4  r5  premiumIndexrs  rt  )r2   rF   r  handle_option_and_params"fetch_paginated_call_deterministicr  handle_until_optionr  r   publicGetV5MarketKliner?  rj  r;   publicGetV5MarketMarkPriceKline publicGetV5MarketIndexPriceKline'publicGetV5MarketPremiumIndexPriceKlinerz  r  parse_ohlcvs)ra  r  r  r  rM  r  r  r  rB  r~  r7  rs  ohlcvss                rc  fetch_ohlcvbybit.fetch_ohlcv	  sZ    $ >#DGG.X$XYY!!!88zZ@@v^cpvx|}}}V$fTl
 =E$G$G225'J"..t	U
&>"(GJ!88W9UVVH$$VW5EYYvw/Fh&.
#	"&/
#"477-`#`aa!%!E!EdkkRYFb!cc'!!%!F!Ft{{SZGc!dd.(!%!M!MdkkZaNj!kk!%!<!<T[[=Y!ZZT (B73  5IIc 	" ~  W ddkZs}   /I%I:I%,I-BI%IBI%I.I%>I?.I%-I!.(I%I#>I%I%I%I%I%!I%#I%c                    U R                  US5      nU R                  US5      nU R                  US5      nU R                  XBS S5      nU R	                  US5      nU R                  US5      nU R	                  US5      nU R	                  US5      n	U R                  U R                  XBS S5      S5      n
U R                  U
S	5      nS nUb"  U R                  US
-  5      n[        U5      S-   n0 SU_SU_SU_SU	_SS _SS _SU_SU R                  U5      _SU_SU_SU R                  U5      _SS _SS _SS _SS _SS _SS _SU0E$ )Nr  r  rW   fundingRatenextFundingTimer  r  r  fundingInterval<   hinterestRateestimatedSettlePricer  fundingTimestampfundingDatetimenextFundingRatenextFundingTimestampnextFundingDatetimepreviousFundingRatepreviousFundingTimestamppreviousFundingDatetimer  )
r  rj  r  r  r	  rz  r  parse_to_intstrr`  )ra  ry  r  r  r  r  r  r  r  r  r  r  intervalStringr  s                 rc  parse_funding_ratebybit.parse_funding_rate9
  s   4 %%fk:	6;/##FH5!!(D&A&&v}=,,V5FG$$V[9	%%fl;
~~d..xvNPVW++D2CD&((2)=>H ]S0N
F
f
 
 *	

 D
 #D
 
 Y/
 ;
  0
 t||,<=
 t
 #D
 "4
 "4
  '!
" &t#
$ %
 	
re  c                   #    U R                  5       I Sh  vN   Sn0 nUb>  U R                  U5      nU R                  US   5      n[        U5      nUS:X  a  US   US'   SnU R	                  SX25      u  pbUS:w  a  [        U R                  S-   U-   S	-   5      eSnU R                  SX2S
5      u  prXtS'   U R                  U R                  XB5      5      I Sh  vN nU R                  US0 5      n	U R                  U	S/ 5      n
U R                  US5      n[        S[        U
5      5       H
  nXU   S'   M     U R                  X5      $  GN3 Ns7f)a  
fetches funding rates for multiple markets

https://bybit-exchange.github.io/docs/v5/market/tickers

:param str[] symbols: unified symbols of the markets to fetch the funding rates for, all market funding rates are returned if not assigned
:param dict [params]: extra parameters specific to the exchange API endpoint
:returns dict[]: a list of `funding rate structures <https://docs.ccxt.com/#/?id=funding-rate-structure>`
Nr   r   rF   r  r   rW   z& fetchFundingRates() does not support z marketsr  r  rs  rt  r  r  )r  market_symbolsr  r}  r  r;   rF   r  r  r?  rz  r  r  r  parse_funding_rates)ra  r  r  r  rB  symbolsLengthr  r  r~  rv  r  r  r  s                rc  fetch_funding_ratesbybit.fetch_funding_ratesv
  se     !!!))'2G[[,FLM!$*4L!99:Mv^6>tww)QQTXX[eeffG"==>QSYcklOG")J66t{{77STTJ ~~h"5^^D&"5
%%h7	q#j/*A)2qM+& +''
<<w 	"" Us#   EE	CEEA1EEc           
      l  #    Uc  [        U R                  S-   5      eU R                  5       I Sh  vN   SnU R                  USS5      u  pTU(       a  U R	                  SXUSUS5      I Sh  vN $ Uc  SnSU0nU R                  U5      nUS	   nUS
   US	'   SnU R                  SXt5      u  pUS:X  d  US:X  a  [        U R                  S-   5      eXS'   Ub  X&S'   U R                  US5      n	U R                  USU	5      n
U R                  USS/5      nU
b  XS'   OUb  SnX#U-  -   US'   U R                  U R                  Xd5      5      I Sh  vN n/ nU R                  US5      nU R                  US5      n[        S[        U5      5       Hr  nUU   nU R                  US5      nUR!                  UU R#                  U R%                  US	5      SSS5      U R'                  US5      UU R)                  U5      S.5        Mt     U R+                  US5      nU R-                  UXU5      $  GN GN N7f)a  
fetches historical funding rate prices

https://bybit-exchange.github.io/docs/v5/market/history-fund-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 <https://docs.ccxt.com/#/?id=funding-rate-history-structure>` to fetch
:param dict [params]: extra parameters specific to the exchange API endpoint
:param int [params.until]: timestamp in ms of the latest funding rate
:param boolean [params.paginate]: default False, when True will automatically paginate by calling self endpoint multiple times. See in the docs all the [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 argumentFr   r  8hr  rM  r  rF   rU   rY   zA fetchFundingRateHistory() only support linear and inverse marketr  	startTimeuntilendTimei trs  rt  r   fundingRateTimestamprW   r  )r  r  r  r  r  r  )r2   rF   r  r  r  r  r  r;   r  rj  publicGetV5MarketFundingHistoryr?  rz  r  r  r}  r  r  r  r	  r`  sort_byfilter_by_symbol_since_limit)ra  r  r  rM  r  r  rB  r  r  r  r  r  r~  ratesrs  
resultListr  entryr  sorteds                       rc  fetch_funding_rate_history bybit.fetch_funding_rate_history
  s     >#DGG.e$eff!!!88AZ\fg@@AZ\bkprvx~  AD  E  E  E=E U
 V$!"4L**+DfU6>TX-tww)llmm"
#(K !!&'2##FIu=6Iw#78!(I "4%*_-D%D	"==dkk'>Z[[& (3^^FF3
q#j/*AqME))%1GHILL**4+;+;E8+LdTXZ`a#//}E& LL3  + e[100NNG 	" E< \s5   /H4H,;H4-H/.C#H4H2CH4/H42H4tradec                    U R                  U/ SQ5      nU R                  US5      nSU;   a  SOSnU R                  US5      nUb
  US:X  a  SOSnUb  US   nU R                  XBS U5      nUS   nU R                  U/ SQ5      nU R                  U/ S	Q5      n	U R                  US
5      n
U R                  U/ SQ5      nU R	                  US5      nUc   U R                  US5      nUb  U(       a  SOSnU R                  US5      nS nUb  U(       a  SOSnODU R                  US5      nUS:X  a  S nUb'  US:X  d  US:X  a  UR                  5       nO
US:X  a  SOSnU R	                  US5      nUS:X  a  S nU R                  US5      nS nUb  U R                  US5      nS nUS   (       a@  [        R                  " US5      (       a  US:X  a  US   nO,US   nO&US:X  a  US   nOUS   nOUS   (       a  US   OUS    nUU R                  US!U5      US".nU R                  UUUU R                  U5      UU R                  US#5      UUUU	UU
US$.U5      $ )%N)execIdrF   tradeIdr  
createTyper  rU   r  r  )execQtyorderQtysize)	execPrice
orderPricer7  	execValue)r  execTime	tradeTimesideisBuyerbuysellisMakerrZ  rY  lastLiquidityIndUNKNOWNTAKERMAKERAddedLiquidity	orderTypeunknownexecFeefeeRater  r  r  r  r  feeCoin)r  r  rateorderId)rF   r  r  r  r  orderr  r  takerOrMakerr7  r  r  r   )r  r  r  safe_integer_nrs  r  r  lowerr@   	string_gt
safe_trader`  )ra  r  r  rF   r  r  r  r  r  priceString
costStringr  r  r  r	  r  r
  r  feeCostStringr   feeRateStringfeeCurrencyCodes                         rc  parse_tradebybit.parse_trade  s   h 'BC##E84$0E$9Z
##E:6$,$6ZJJ!!(D*E!))%1PQ((0TU%%e[9
''/PQ	%%eV4<''y9G" 'uV..	2&-77L#//7IJ9,#' +$/5E5P#3#9#9#;L/?CS/S7ZaL**5+>		!I((	:$ ,,UI>M"Of~$$]C88u}*0.*0/u}*0/*0.4:94E&.6RZK[% ,,UIO%C
 "Y/%%eY7( " 
  	re  c                   #    Uc  [        U R                  S-   5      eU R                  5       I Sh  vN   U R                  U5      nSUS   0nUb  X6S'   SnU R	                  SXT5      u  ptXvS'   U R                  U R                  Xd5      5      I Sh  vN nU R                  US0 5      n	U R                  U	S	/ 5      n
U R                  XX#5      $  N N>7f)
ai  
get the list of most recent trades for a particular symbol

https://bybit-exchange.github.io/docs/v5/market/recent-trade

: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 str [params.type]: market type, ['swap', 'option', 'spot']
:param str [params.subType]: market subType, ['linear', 'inverse']
:returns Trade[]: a list of `trade structures <https://docs.ccxt.com/#/?id=public-trades>`
Nz) fetchTrades() requires a symbol argumentr  rF   rM  r   r  rs  rt  )
r2   rF   r  r  r  publicGetV5MarketRecentTrader?  rz  r  parse_trades)ra  r  r  rM  r  r  rB  r  r~  rs  tradess              rc  fetch_tradesbybit.fetch_trades  s      >#DGG.Y$YZZ!!!V$fTl

   %G**=&I"
::4;;w;WXX. (B73  >>O 	" Ys"   /CCA CC=CCc                   #    Uc  [        U R                  S-   5      eU R                  5       I Sh  vN   U R                  U5      nSUS   0nSnUS   (       a  SnSUS'   O/US	   (       a  S	US'   OUS
   (       a  S
US'   OUS   (       a  SUS'   Ub  UOUUS'   U R	                  U R                  XS5      5      I Sh  vN nU R                  US0 5      nU R                  US5      n	U R                  XU	SS5      $  N N?7f)a  
fetches information on open orders with bid(buy) and ask(sell) prices, volumes and other data

https://bybit-exchange.github.io/docs/v5/market/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
:returns dict: A dictionary of `order book structures <https://docs.ccxt.com/#/?id=order-book-structure>` indexed by market symbols
Nz, fetchOrderBook() requires a symbol argumentr  rF   r   rU   r   r  rY   r  r  rM  rs  tsba)	r2   rF   r  r  publicGetV5MarketOrderbookr?  rz  r  parse_order_book)
ra  r  rM  r  r  rB  defaultLimitr~  rs  r  s
             rc  fetch_order_bookbybit.fetch_order_book)  s     >#DGG.\$\]]!!!V$fTl
 &>L"(GJh&.
#!&.
#	"&/
#%*%65\88W9UVV4 (B7%%fd3	$$VYSIIc 	"* Ws"   /D C<BD >C>?>D >D c                    U R                  US5      nUUU R                  U5      S.nU R                  US0 5      nU R                  U/ SQ5      nUcB  SnU R	                  5       nU R                  US5      US'   U R                  US5      US	'   XsU'   GOS[        S
[        U5      5       GH9  nXX   n	U R                  U	S5      n
U
S:X  d  U
S:X  d  U
S:X  GaN  U R                  U	S5      n[        S
[        U5      5       GH  nU R	                  5       nX   nU R                  US5      nU R                  US5      nUb  Ub  [        R                  " X5      US'   U R                  US5      US	'   U R                  USS5      nUb  UUS'   OlU R                  USS5      nU R                  USS5      nU R                  USS5      n[        R                  " UU5      n[        R                  " UU5      nUUS'   U R                  US5      nU R                  U5      nXsU'   GM"     GM{  U R	                  5       nU R                  U	S5      nU R                  U	S5      nUb  Ub  [        R                  " X5      US'   U R                  U	S	S5      US	'   U R                  U	/ SQ5      US'   U R                  U	S5      US'   U R                  U	/ SQ5      nU R                  U5      nXsU'   GM<     U R                  U5      $ )Nr  )r  r  r  rs  )loanAccountListrt  balancer  availableBalancefreewalletBalancetotalr   accountTyper  r  r  r  borrowAmountaccruedInterestdebtavailableToWithdrawlockedr  totalPositionIMtotalOrderIMusedloaninterest)r6  availableBalanceWithoutConvertr5  transferBalance)tokenIdr  currencyCoin)r  r`  rz  r{  accountr  r  r}  r  r@   
string_addr|  r  r  safe_balance)ra  r~  r  rs  rC  currencyListr  rH  r  r  r9  coinsr  	coinEntryrB  rC  r6  r>  totalPositionImtotalOrderIm	totalUsedr  s                         rc  parse_balancebybit.parse_balancei  s   N %%h7	"Y/

 (B?''8^_DllnG"..~?QRGFO#//PGG"4L1c,/0$"..umD)+{j/HK[aLa NN5&9E"1c%j1"&,,.$)H	#//	>J#'#3#3I?P#Q ,83G.5.@.@.PGFO+/+;+;I+W(#11)=RTZ[+.2GFO%)%5%5i3%OF.2.>.>yJ[]`.aO+/+;+;I~WZ+[L(/(:(:6?(SI(/(:(:9l(SI.7GFO%)%5%5i%H
#66zB'.t+ 2. #llnG++E6:D#//zBH(x/C*1*<*<T*L'+'9'9%/'ZGG$&*&8&8  AR  'SGFO&*&6&6uh&GGFO!%!3!3E;^!_J22:>D#*4LM 1N   ((re  c                   #    U R                  5       I Sh  vN   0 nU R                  5       I Sh  vN u  p4U=(       d    UnSnU R                  SSU5      u  paSnU R                  SSU5      u  pqUS:X  d  US:X  a  UnUb  UR	                  5       OSnUS:H  n	US:H  n
US:H  nUS:H  =(       d    US	:H  nU(       a3  U R                  U R                  S
S5      nUS:  a  U(       a  SnOSnOSnOU
(       d  U(       a  SnU R                  U R                  S0 5      nU R                  XU5      nSnU R                  SU5      u  nnSnU	(       a,  Ub)  U R                  U R                  X!5      5      I Sh  vN nOaU(       a.  SUS'   U R                  U R                  X!5      5      I Sh  vN nO,XS'   U R                  U R                  X!5      5      I Sh  vN nU R                  U5      $  GN GN N} NJ N7f)a
  
query for balance and get the amount of funds available for trading or funds locked in orders

https://bybit-exchange.github.io/docs/v5/spot-margin-normal/account-info
https://bybit-exchange.github.io/docs/v5/asset/all-balance
https://bybit-exchange.github.io/docs/v5/account/wallet-balance

:param dict [params]: extra parameters specific to the exchange API endpoint
:param str [params.type]: wallet type, ['spot', 'swap', 'funding']
:returns dict: a `balance structure <https://docs.ccxt.com/#/?id=balance-structure>`
Nrt   rW   rX   rU   r  r  r  r  r  r  r   r  r  r+  r  r9  )r  r  r  r  r  r  r  rz  safe_string_upperhandle_margin_mode_and_params'privateGetV5SpotCrossMarginTradeAccountr?  1privateGetV5AssetTransferQueryAccountCoinsBalance privateGetV5AccountWalletBalancerQ  )ra  r  rB  r  r  isUnifiedAccountr  r  lowercaseRawTyper  isLinearrw  	isFundingr  accountTypesunifiedTyper<  r~  s                     rc  fetch_balancebybit.fetch_balance	  s     !!!:>:Q:Q:S4S1/G3G99.$PVW99.$PVWFN 0D,0,<4::<4&.H$Y&	%/S5E5R	"&"3"3DLLBWYZ"["Q&%D$D 9!~~dll4DbI,,\F
!??PVW
Fz-!II$++V]JfggH &,GM"!SSTXT_T_`gTpqqH%0M"!BB4;;wC_``HN !!(++e 	"4SB h
 r asV   G6G*G6G-EG62G034G6'G2(,G6G4G6-G60G62G64G6r.  c                     0 SS_SS_SS_SS_SS_S	S_S
S_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SSSS.EnU R                  X!U5      $ )NNEWr  PARTIALLY_FILLEDFILLEDclosedCANCELEDcanceledPENDING_CANCELPENDING_NEWREJECTEDrejectedPARTIALLY_FILLED_CANCELLEDCreatedNewRejectedPartiallyFilledPartiallyFilledCanceledFilledPendingCancel	CancelledUntriggered)Deactivated	TriggeredActiver  ra  r.  statusess      rc  parse_order_statusbybit.parse_order_status  s    
6
 
 h	

 

 f
 6
 

 )(
 v
 6
 

 v
 &x
  h!
" V#
$ %
( 6)
* &/
2 &99re  rB  c                 4    SSSSS.nU R                  X!U5      $ )NGTCr8  r9  r:  )GoodTillCancelImmediateOrCancel
FillOrKillPostOnlyry  )ra  rB  timeInForcess      rc  parse_time_in_forcebybit.parse_time_in_force  s*    #!&	
 ;GGre  r  c                    U R                  US5      nUb{  US:w  au  U R                  US5      nUS:X  a  SOSnU R                  USU R                  US5      U R                  US5      U R                  U R                  US	5      S S U5      S
.5      $ U R                  US	5      nSU;   nS nUb  US   nOU(       a  SOSnU R                  XbS U5      nUS	   n	U R	                  USS5      n
U R                  USS5      nU R                  US5      nU R                  US5      nU R                  US5      nS nS nUS:X  a%  U R                  US5      nU R                  US5      nOU R                  US5      nU R                  US5      nU R                  US5      nU R	                  USS5      nU R                  US5      nU R                  U5      nU R                  US5      nS nU R                  US0 5      n[        UR                  5       5      nU R                  US5      nUb  U R                  UU5      US.nU R                  US5      nUb  [        U5      S:  a  S nU R                  U R                  US5      5      nU R                  US 5      nU R                  U5      nU R                  U R                  US!5      5      nU R                  US"5      n U R                  U R                  US#5      5      n!U R                  U R                  US$5      5      n"U R                  US%5      n#U#S&:H  n$US L=(       a    U n%U"c%  U%(       a  U$(       a  US':X  a  Un"U$(       d  US(:X  a  Un"U!c%  U%(       a  U$(       a  US(:X  a  Un!U$(       d  US':X  a  Un!U R                  0 S)U_S*U_S+U_S,U
_S-U R                  U
5      _S.U_S/U_S	U	_SU_S U_S0S _S"U R                  US"5      _SU_SU_S!U_S1U!_S2U"_UUUUUUUS S3.EU5      $ )4Nr  r  r  rU   r  rk  r  orderLinkIdr  )r  r.  rF   clientOrderIdr  tpslModer  createdTime	createdAt
marketUnitr  r  r7  qtycumExecValue
cumExecQty	leavesQtyupdatedTime	updatedAtorderStatusr  cumFeeDetailr   r  r  r   avgPricerB  r=  
reduceOnly
takeProfitstopLossr>  r   r  r  r  rF   r  r  r  lastTradeTimestamplastUpdateTimestamppostOnlyr@  r?  )r  r  r  filled	remainingr.  r   r&  )r  
safe_orderr  r  safe_integer_2rs  r|  rz  rt  keysr	  r}  r^  r  r  r`  )&ra  r  r  r  r  inferredMarketTyper  
isContractr  r  r  r  rF   r  r7  r  r  r  r  r  	rawStatusr.  r  r   r  feeCoins	feeCoinIdr  r  rawTimeInForcerB  r=  r  r@  r?  r>  isAscendingisStopOrderType2s&                                         rc  parse_orderbybit.parse_order  s   L v.s{++E:>08F0BV"!(**5)<%)%5%5e]%K"..t/?/?x/PRVX\^pq(   ##E84 E)

J'1vJ!!(D*E!''}kJ	%%e\:F
eY/%%e[9  0#%%eU3F##E>:D##E>:D!!%6$$UK8	!00{S$$UM:	((3%%eV4~~e^R@))+,$$Xq1	 ((yA%C ((>%C,>,B M>>$"2"25*"EF))%?..~>~~d&6&6un&MN^^E<8
..)9)9%)NOt'7'7z'JK++E3EF'3.(4D*!'7 ,DFN ,#)9".DEM".  
E 
" 
 ] 
 	 

 Y/ 
 !"4 
 "#5 
 f 
 D 
 ; 
  
 $..= 
 D 
 U 
 L 
  ! 
" ]# 
$ "3 
4 5 	re  c                 
  #    U R                  5       I Sh  vN   U R                  U5      nUS   (       d  [        U R                  S-   5      eSU0nU R	                  USSSSU R                  XS5      5      I Sh  vN $  Nh N7f)a  
create a market buy order by providing the symbol and cost

https://bybit-exchange.github.io/docs/v5/order/create-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>`
NrU   z9 createMarketBuyOrderWithCost() supports spot orders onlyr  r  r  r  )r  r  r;   rF   create_orderr?  )ra  r  r  r  r  reqs         rc  !create_market_buy_order_with_cost'bybit.create_market_buy_order_with_cost  s      !!!V$f~tww)ddeeD
 &&vxD$++VYJbccc 	" ds"   BA?A#B:B;BBc                   #    U R                  5       I Sh  vN   U R                  5       I Sh  vN nUS   nU(       d  [        U R                  S-   5      eU R	                  U5      nUS   (       d  [        U R                  S-   5      eSU0nU R                  USSS	SU R                  Xs5      5      I Sh  vN $  N N N7f)
a  
create a market sell order by providing the symbol and cost

https://bybit-exchange.github.io/docs/v5/order/create-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>`
Nr   z; createMarketSellOrderWithCost() supports UTA accounts onlyrU   z: createMarketSellOrderWithCost() supports spot orders onlyr  r  r  r  )r  r  r;   rF   r  r  r?  )ra  r  r  r  r  r  r  r  s           rc  "create_market_sell_order_with_cost(bybit.create_market_sell_order_with_cost  s      !!!--//$Qx#tww)ffggV$f~tww)eeffD
 &&vxT4;;WZKcddd 	"/ es2   CB;CB=BC6B?7C=C?Cr  r  c           	        #    U R                  5       I Sh  vN   U R                  U5      nU R                  5       I Sh  vN nUS   n	U R                  USS5      n
U R	                  US5      nU R	                  US5      nU
SLnUSLnUSLnU R                  XX4XVU	5      nSnU(       d  U(       d  U(       a  US   (       d  SnOS	nSnU R                  US
SU5      u  nnSnUS:X  a  U R                  U5      I Sh  vN nOU R                  U5      I Sh  vN nU R                  US0 5      nU R                  UU5      $  GN) GN NI N17f)a;	  
create a trade order

https://bybit-exchange.github.io/docs/v5/order/create-order
https://bybit-exchange.github.io/docs/v5/position/trading-stop

:param str symbol: unified symbol of the market to create an order in
:param str type: 'market' or 'limit'
:param str side: 'buy' or 'sell'
:param float amount: how much of currency you want to trade in units of base currency
:param float [price]: the price at which the order is to be fulfilled, in units of the quote currency, ignored in market orders
:param dict [params]: extra parameters specific to the exchange API endpoint
:param str [params.timeInForce]: "GTC", "IOC", "FOK"
:param bool [params.postOnly]: True or False whether the order is post-only
:param bool [params.reduceOnly]: True or False whether the order is reduce-only
:param str [params.positionIdx]: *contracts only* 0 for one-way mode, 1 buy side of hedged mode, 2 sell side of hedged mode
:param bool [params.hedged]: *contracts only* True for hedged mode, False for one way mode, default is False
:param int [params.isLeverage]: *unified spot only* False then spot trading True then margin trading
:param str [params.tpslMode]: *contract only* 'Full' or 'Partial'
:param str [params.mmp]: *option only* market maker protection
:param str [params.triggerDirection]: *contract only* the direction for trigger orders, 'ascending' or 'descending'
:param float [params.triggerPrice]: The price at which a trigger order is triggered at
:param float [params.stopLossPrice]: The price at which a stop loss order is triggered at
:param float [params.takeProfitPrice]: 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
:param float [params.takeProfit.triggerPrice]: 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
:param float [params.stopLoss.triggerPrice]: stop loss trigger price
:param str [params.trailingAmount]: the quote amount to trail away from the current market price
:param str [params.trailingTriggerPrice]: the price to trigger a trailing order, default uses the price argument
:returns dict: an `order structure <https://docs.ccxt.com/#/?id=order-structure>`
Nr   trailingAmounttrailingStopr?  r@  rU    privatePostV5PositionTradingStopprivatePostV5OrderCreatere   r  rs  )r  r  r  r|  r  create_order_requestr  r  r  rz  r  )ra  r  r  r  r  r7  r  r  partsr  r  r?  r@  isTrailingAmountOrder
isStopLossisTakeProfitorderRequestdefaultMethodr  r~  r  s                        rc  r  bybit.create_order  s]    B !!!V$--//$Qx++F4DnU((A**63DE .d :"$.
&d200tU\pq!Z<PV>M6M66v}hXef77!BB<PPH!::<HHH x26v..I 	"/$ QHsE   E	D?(E	E B;E	;E<E	E*E	E	E	E	Tc                    U R                  U5      nUS   nUR                  5       n	Uc  U	S:X  a  [        U R                  S-   5      eSUS   0n
U R	                  USS5      nU R	                  US5      nU R                  USS	5      nU R                  US
5      nU R                  US5      nU R                  US5      nU R                  US5      nU R                  USSU R                  U5      5      nU R                  USS5      nUS LnUS LnUS LnUS LnUS LnUS LnU	S:H  nU	S:H  nUS:H  nS nU(       d  U(       d  U(       a  US   (       d  SnOSnS nU R                  USSU5      u  nnUS:H  nU R                  X5      n Ub   U R                  XR                  U5      5      OS n!U(       d  U(       Ga   U(       d  U(       d  U(       d
  US   (       a  [        U R                  S-   5      eU(       d  U(       a  U R                  USS5      n"U"S:H  n#U"S:H  n$U(       a  U#(       a  [        U R                  S-   5      eU"U
S'   U(       a3  U R                  X5      U
S'   U$(       a  U U
S'   U(       a
  SU
S '   U!U
S!'   GO(U(       a1  U R                  X5      U
S'   U$(       a  U U
S"'   U(       a
  SU
S#'   U!U
S$'   OU R                  U5      U
S%'   U R                  U	5      U
S&'   U R                  US'5      n%S n&U R!                  UU%S(:H  U5      u  n&nU&(       a  S)U
S''   O#U%S*:X  a  S+U
S''   OU%S,:X  a  S-U
S''   OU%S.:X  a  S/U
S''   US   (       a  Ub  S0U
S1'   OU(       d  U(       a  S2U
S1'   U R                  US35      n'U'b  U'U
S4'   OUS5   (       a  U R#                  5       U
S4'   U(       a  U!U
S6'   S n(U R%                  S7X5      u  n(nU(U
S8'   U R                  US95      n)U R'                  US95      nU	S:H  =(       a    US:H  =(       a    US L=(       d    U)S Ln*U	S:H  n+US   (       ad  U+(       a]  U(       aV  U*(       dO  U)c  Ub=  S:U
S;'   S n,U)b  U)n,O[(        R*                  " U U!5      n-U-n,U R-                  UU,5      U
S<'   GOS=U
S;'   U U
S<'   GOUS   (       a  U+(       a  US:X  a  S>n.U R                  USS?5      u  n.nU.(       aa  Uc  U)c  [        U R                  S@-   5      e[(        R*                  " U R                  U5      U!5      n-U)b  U)OU-n/U R-                  UU/5      U
S<'   OnU)b$  U R-                  XR                  U)5      5      U
S<'   OGUb+  U R-                  U[(        R*                  " U U!5      5      U
S<'   OU U
S<'   OU(       d  U(       d  U U
S<'   U(       a  Ub  U R                  UU5      U
S'   UU
S'   GOU(       a  U(       d  U R                  USA5      n0U R'                  U/ SBQ5      nUS   (       a  U0b  [/        U R                  SC-   5      eOFU0c  [        U R                  SD-   5      eU0SE:H  =(       d    U0SF:H  =(       d    U0SG:H  n1U1(       a  SHOSIU
SA'   U R                  X5      U
S'   O]U(       d  U(       aO  U(       dH  U(       a  U(       a  SHOSIU
SA'   OU(       a  SIOSHU
SA'   U(       a  UOUnU R                  X5      U
S'   S>U
S'   U(       d  U(       GaB  U(       Gd:  U(       a  U R                  USS	U5      n2U R                  UU25      U
S'   U R                  US65      n3U3b   SU
S'   SU
S '   U R                  UU35      U
S!'   OUS   (       a  SJU
S '   US   (       a  U+(       a  [        U R                  SK-   5      eU(       a  U R                  USS	U5      n4U R                  UU45      U
S'   U R                  US65      n5U5b   SU
S'   SU
S#'   U R                  UU55      U
S$'   OUS   (       a  SJU
S#'   US   (       a  U+(       a  [        U R                  SL-   5      eUS   (       d7  U(       a0  U(       a  U R'                  US5      nUS:X  a  SMOSnUS:X  a  SHOSIU
SN'   U R'                  U/ SOQ5      nU R1                  X5      $ )PNr  rM  z7 createOrder requires a price argument for limit ordersrF   rC  Fr  r=  	stopPricer?  r@  r  r  trailingTriggerPriceactivePricer  r  r  r  rU   r  r  re   r  zf the API endpoint used only supports contract trailingAmount, stopLossPrice and takeProfitPrice ordersr  PartialFullz< tpsl orders with "full" tpslMode only support "market" typeslSizeLimitslOrderTypeslLimitPricetpSizetpOrderTypetpLimitPricer  r  rB  postonlyr  gtcr  fokr9  iocr8  	StopOrderorderFilter	tpslOrderr  r  rY   r7  createOrderRequestr  r  r-  r  r  r  Tr  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=  r  r>  zU createOrder() : trigger order does not support triggerDirection for spot markets yetz stop/trigger orders require a triggerDirection parameter, either "ascending" or "descending" to determine the direction of the trigger.	ascendingabover   r   r  r   zI createOrder(): attached stopLoss is not supported for spot market orderszK createOrder(): attached takeProfit is not supported for spot market ordersr  positionIdx)r  rB  r?  r@  r  r  r=  r  r  r  r  rC  r  )r  r  r2   rF   r  safe_value_2
safe_valuer|  r  r  r  r  r9   r  
capitalizers  handle_post_onlyuuid16r  rj  r@   r  r  r;   r?  )6ra  r  r  r  r  r7  r  isUTAr  lowerCaseTyperB  rC  r  r=  stopLossTriggerPricetakeProfitTriggerPricer  r  r  r  r  isTriggerOrderisStopLossTriggerOrderisTakeProfitTriggerOrderr  r  isMarketisLimitisBuyr  r  isAlternativeEndpointr  r  r  
isFullTpslisPartialTpslrB  r  r  r  r  isMarketBuyAndCostInferableisMarketOrder	orderCostquoteAmountr  costRequestr>  
isAsendingslTriggerPricer  tpTriggerPricer  s6                                                         rc  r  bybit.create_order_request  s   V$!

M 8#DGG.g$ghhfTl
2 %8^^FL9
((M#vG!%9J!K??6:6__V\:
#11&:PR_aeavavw|a}~++F4DnU .d :%T1!5T!A#9#E T)
!- H,7*!%;?Waghnao>M6M66v}hXef &*L Lv6OTO`dnnV-B-B5-IJgk $9\^vf~"477  .V  $V  W  W%)A++FJ	J%/
 (I 5z&tww1o'opp&.
#)*...*VGJ'$,8)18.2=/-,0NN6,ZGL)$,8)18.2=/"ood3GFO#'??=#AGK 00GKH#44X{j?XZ`aHf)3&%).&%).&%).&f~+-8GM*+/G-8GM* ,,V_EM()6&!)-&#. ../CVT&&
/66*'4'@  'Ftu}  'F\aim\m  \Esw  @D  tD#%1&>m>Y e&7(3% 	# $I")"4"4\;"OK +I!%vy!A(2%!-F^45= 15-8<8U8UV\^k  nQ  9R5-v0M&tww  2m  (m  n  n")"4"4T5J5J65RT_"`K+/+;$+K%)]]6;%GGEN#%)]]6;P;PQU;V%WGEN&%)]]67;M;Ml\g;h%iGEN%1GEN(1F!- #/)-@T)U&&4GN#$9#//8JKYYv'XYFf~#/&tww  2I  (I  J  J 0 $++DGG  7A  -A  B  B/;>}DTX_D_}euy|e|
3=a1*+&*nnV&JGN#$(@J_3Iaq*+3Iaq*+3I/OeL&*nnV&JGN#$(GL!,0E!%!2!28^[Zb!c&*nnV^&L
##xA+*3GJ'-4GM*.2nnV\.RGN+ f~19.&>m&tww1|'|}}!%!2!2:~{\f!g(,v~(N%#z7C+*3GJ'-4GM*.2nnV\.RGN+ f~19.&>m&tww1~'~f~&6<8"&%-ve+/5=QqGM"6  $k  l{{7++re  ordersc           
        #    U R                  5       I Sh  vN   U R                  5       I Sh  vN nUS   n/ n/ n[        S[        U5      5       H  nX   nU R	                  US5      n	UR                  U	5        U R	                  US5      n
U R	                  US5      nU R                  US5      nU R                  US5      nU R                  US	0 5      nU R                  XXXU5      nUS
	 UR                  U5        M     U R                  USSSS5      nU R                  US   5      nU R                  U R                  SS5      nSnU R                  SUU5      u  nnUS:X  a  US:  a  [        U R                  S-   5      eUUS.nU R!                  U R#                  UU5      5      I Sh  vN nU R                  US0 5      nU R%                  US/ 5      nU R                  US0 5      nU R%                  US/ 5      n[        S[        U5      5       H:  nUU   nU R                  US5      nUS:w  d  M"  U R#                  UU   U5      UU'   M<     U R'                  U5      $  GNL GN7 N7f)a  
create a list of trade orders

https://bybit-exchange.github.io/docs/v5/order/batch-place

:param Array orders: list of orders to create, each object should contain the parameters required by createOrder, namely symbol, type, side, amount, price and params
:param dict [params]: extra parameters specific to the exchange API endpoint
:returns dict: an `order structure <https://docs.ccxt.com/#/?id=order-structure>`
Nr   r   r  r  r  r  r7  r  r  FTr  r  rf   r  r   zB createOrders does not allow inverse orders for non UTA2.0 accountr  rB  rs  rt  
retExtInfor  )r  r  r  r}  r  r  r  rz  r  r  r  r  r  r  r;   rF   privatePostV5OrderCreateBatchr?  r  parse_orders)ra  r  r  accountsisUtaordersRequestsorderSymbolsr  rawOrderr  r  r  r  r7  orderParamsr  r  r  r  r  rB  r~  rs  rv  retInfocodesr  retCodes                               rc  create_ordersbybit.create_orders  so     !!!0022q#f+&AyH''(;H)##Hf5D##Hf5D__Xx8FOOHg6E..8R@K44XTSXglmLZ(!!,/ ' %%lD%tLWQZ("//>SUVW..~vvN&	!(;a(?tww)mmnn %
 ;;DKKQW<XYY(B7~~ffb1..<<w3q#e*%A8D''f5G!|++d1gt4Q	 &T   &&Y 	"26 Zs9   I*I"I*I%E>I*-I(.BI*5.I*%I*(I*rF   c                     U R                  U5      nUS   US.n	S n
U R                  SX5      u  pXS'   Ub  U R                  X%5      U	S'   Ub#  U R                  X R	                  U5      5      U	S'   U R                  USS5      nU R                  US	5      nU R                  US
5      nU R                  US5      nU R                  US5      nUS LnUS LnUS LnUS LnU(       d  U(       a  U(       a  UOUnUb6  US:X  a  UOU R                  X+5      nUU	S'   U R                  USS5      nUU	S'   U(       d  U(       a  U(       aK  U R                  USSU5      nUS:X  a  UOU R                  UU5      nUU	S'   U R                  USS5      nUU	S'   U(       aK  U R                  USSU5      nUS:X  a  UOU R                  UU5      nUU	S'   U R                  USS5      nUU	S'   U R                  US5      nUb  UU	S'   U R                  U/ SQ5      nU	$ )NrF   r  r  editOrderRequestr  r  r7  r=  r  r?  r@  r  r  r  	triggerBy	LastPriceslTriggerBytpTriggerByr  r  )r  r?  r@  r=  r  r  r  )	r  r  r  r  r  r|  r  r  rj  )ra  rF   r  r  r  r  r7  r  r  rB  r  r=  r  r  r  r  r  r  r  r  triggerPriceRequestr	  r  stopLossRequestr  r  takeProfitRequestr  r  s                                rc  edit_order_requestbybit.edit_order_requestB  sd   V$Tl
 ../A6R&
!__V<GEN#~~f6K6KE6RSGG))&.+N#//H!%!1!1&:K!L??6:6__V\:
!5T!A#9#E T)
!-!%=3I/OeL#3?33F,T^^\bMq&9GN#((kJI#,GK !%!3!3Hnk[c!d5Cs5J.QUQ_Q_`fhvQw&5
#"..v}kR)4&!%!3!3JP[]g!h7E7LNSWSaSabhjxSy!(9%"..v}kR)4&((A$%2GM"6  $P  Qre  c           	      ^  #    U R                  5       I Sh  vN   Uc  [        U R                  S-   5      eU R                  XX4XVU5      nU R	                  U R                  X5      5      I Sh  vN n	U R                  U	S0 5      n
U R                  U	U R                  U
S5      S.5      $  N N=7f)ak  
edit a trade order

https://bybit-exchange.github.io/docs/v5/order/amend-order
https://bybit-exchange.github.io/docs/derivatives/unified/replace-order
https://bybit-exchange.github.io/docs/api-explorer/derivatives/trade/contract/replace-order

:param str id: cancel order id
:param str symbol: unified symbol of the market to create an order in
:param str type: 'market' or 'limit'
:param str side: 'buy' or 'sell'
:param float amount: how much of currency you want to trade in units of base currency
:param float price: the price at which the order is to be fulfilled, in units of the quote currency, ignored in market orders
:param dict [params]: extra parameters specific to the exchange API endpoint
:param float [params.triggerPrice]: The price that a trigger order is triggered at
:param float [params.stopLossPrice]: The price that a stop loss order is triggered at
:param float [params.takeProfitPrice]: The price that a take profit order is triggered at
:param dict [params.takeProfit]: *takeProfit object in params* containing the triggerPrice that the attached take profit order will be triggered
:param float [params.takeProfit.triggerPrice]: take profit trigger price
:param dict [params.stopLoss]: *stopLoss object in params* containing the triggerPrice that the attached stop loss order will be triggered
:param float [params.stopLoss.triggerPrice]: stop loss trigger price
:param str [params.triggerBy]: 'IndexPrice', 'MarkPrice' or 'LastPrice', default is 'LastPrice', required if no initial value for triggerPrice
:param str [params.slTriggerBy]: 'IndexPrice', 'MarkPrice' or 'LastPrice', default is 'LastPrice', required if no initial value for stopLoss
:param str [params.tpTriggerby]: 'IndexPrice', 'MarkPrice' or 'LastPrice', default is 'LastPrice', required if no initial value for takeProfit
:returns dict: an `order structure <https://docs.ccxt.com/#/?id=order-structure>`
Nz' editOrder() requires a symbol argumentrs  r  )r  rF   )	r  r2   rF   r  privatePostV5OrderAmendr?  rz  r  r  )ra  rF   r  r  r  r  r7  r  rB  r~  rs  s              rc  
edit_orderbybit.edit_order{  s     6 !!!>#DGG.W$WXX))"d&QWX55dkk'6RSS (B7""695 
  	% 	" Ts"   B-B)AB--B+.<B-+B-c           
        #    U R                  5       I Sh  vN   / n/ n[        S[        U5      5       H  nX   nU R                  US5      nUR	                  U5        U R                  US5      nU R                  US5      n	U R                  US5      n
U R                  US5      nU R                  US5      nU R                  US	0 5      nU R                  XXXU5      nUS
	 UR	                  U5        M     U R                  USSSS5      nU R                  US   5      nU R                  U R                  SS5      nSnU R                  SX5      u  nnUS:X  a  US:  a  [        U R                  S-   5      eUUS.nU R                  U R!                  UU5      5      I Sh  vN nU R                  US0 5      nU R#                  US/ 5      nU R                  US0 5      nU R#                  US/ 5      n[        S[        U5      5       H:  nUU   nU R                  US5      nUS:w  d  M"  U R!                  UU   U5      UU'   M<     U R%                  U5      $  GN@ N7f)a  
edit a list of trade orders

https://bybit-exchange.github.io/docs/v5/order/batch-amend

:param Array orders: list of orders to create, each object should contain the parameters required by createOrder, namely symbol, type, side, amount, price and params
:param dict [params]: extra parameters specific to the exchange API endpoint
:returns dict: an `order structure <https://docs.ccxt.com/#/?id=order-structure>`
Nr   r  rF   r  r  r  r7  r  r  FTr  r  rr   r  r   z@ editOrders does not allow inverse orders for non UTA2.0 accountr  rs  rt  r  r  )r  r  r}  r  r  r  rz  r  r  r  r  r  r  r;   rF   privatePostV5OrderAmendBatchr?  r  r  )ra  r  r  r  r  r  r  r  rF   r  r  r  r7  r   r  r  r  r  rB  r~  rs  rv  r  r  r  r  s                             rc  edit_ordersbybit.edit_orders  sa     !!!q#f+&AyH%%h9F'!!(D1B##Hf5D##Hf5D__Xx8FOOHg6E..8R@K222t6ZefLZ(!!,/ ' **<udDQ\!_-"//>SUVW..|VL&	!(;a(?tww)kkll %
 ::4;;wPV;WXX(B7~~ffb1..<<w3q#e*%A8D''f5G!|++d1gt4Q	 &P   &&S 	"6 Ys)   IIF
I!I"BI).IIc                    U R                  U5      nSUS   0nUS   (       a6  U R                  USSS5      nU R                  USS/5      nU(       a  SOSUS	'   Ub  XS
'   S nU R                  SXC5      u  psXuS'   U R	                  XS5      $ )Nr  rF   rU   stoprQ  Fr  r   r  r  cancelOrderRequestr  )r  safe_bool_2rj  r  r?  )ra  rF   r  r  r  rB  	isTriggerr  s           rc  cancel_order_requestbybit.cancel_order_request  s    V$fTl
 &>((EJIYYv	':;F4=[7GM">!#I../CVT&
{{7++re  c                 8  #    Uc  [        U R                  S-   5      eU R                  5       I Sh  vN   U R                  U5      nU R	                  XU5      nU R                  U5      I Sh  vN nU R                  US0 5      nU R                  Xt5      $  Nd N*7f)a'  
cancels an open order

https://bybit-exchange.github.io/docs/v5/order/cancel-order

:param str id: order id
:param str symbol: unified symbol of the market the order was made in
:param dict [params]: extra parameters specific to the exchange API endpoint
:param boolean [params.trigger]: *spot only* whether the order is a trigger order
:param boolean [params.stop]: alias for trigger
:param str [params.orderFilter]: *spot only* 'Order' or 'StopOrder' or 'tpslOrder'
:returns dict: An `order structure <https://docs.ccxt.com/#/?id=order-structure>`
Nz) cancelOrder() requires a symbol argumentrs  )r2   rF   r  r  r  privatePostV5OrderCancelrz  r  )ra  rF   r  r  r  requestExtendedr~  rs  s           rc  cancel_orderbybit.cancel_order  s      >#DGG.Y$YZZ!!!V$33BG66GG (B7//# 	" Hs!   /BB;B-B.)BBidsc                   #    Uc  [        U R                  S-   5      eU R                  5       I Sh  vN   U R                  U5      nU R	                  5       I Sh  vN nUS   nU(       d  [        U R                  S-   5      eSnU R                  SXC5      u  psUS:X  a  [        U R                  S-   5      e/ nU R                  USS	/ 5      n	U R                  USS	/5      n[        S
[        U	5      5       H)  n
UR                  US   U R                  X5      S.5        M+     [        S
[        U5      5       H)  n
UR                  US   U R                  X5      S.5        M+     UUS.nU R                  U R                  X5      5      I Sh  vN nU R                  US0 5      nU R!                  US/ 5      nU R#                  X5      $  GN GNr NA7f)a  
cancel multiple orders

https://bybit-exchange.github.io/docs/v5/order/batch-cancel

:param str[] ids: order ids
: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.clientOrderIds]: client order ids
:returns dict: an list of `order structures <https://docs.ccxt.com/#/?id=order-structure>`
Nz* cancelOrders() requires a symbol argumentr   z* cancelOrders() supports UTA accounts onlyr^   r  z+ cancelOrders does not allow inverse ordersclientOrderIds
clientOidsr   rF   )r  r  r  r  rs  rt  )r2   rF   r  r  r  r;   r  safe_list_2rj  r  r}  r  r  privatePostV5OrderCancelBatchr?  rz  r  r  )ra  r&  r  r  r  r  r  r  r  r(  r  rB  r~  rs  rows                  rc  cancel_ordersbybit.cancel_orders:  s     >#DGG.Z$Z[[!!!V$--//$Qx#tww)UUVV..~vNy tww)VVWW))&2BLRTU6$4l#CDq#n-.A!! ,#//B#  /
 q#c(#A!! ,++C3#  $ !%
 ;;DKK<XYYH (B7nnVVR0  --C 	"/2 Zs4   /GG	(GGD2GG<GGGtimeoutc                 *  #    U R                  5       I Sh  vN   SU R                  US-  5      0nSnU R                  SSUS5      u  pBSSSS	.nU R                  XTU5      nXcS
'   U R	                  U R                  X25      5      I Sh  vN nU$  Nx N7f)a\  
dead man's switch, cancel all orders after the given timeout

https://bybit-exchange.github.io/docs/v5/order/dcp

:param number timeout: time in milliseconds
:param dict [params]: extra parameters specific to the exchange API endpoint
:param str [params.product]: OPTIONS, DERIVATIVES, SPOT, default is 'DERIVATIVES'
:returns dict: the api result
N
timeWindowrS  r\   rW   r  DERIVATIVESOPTIONS)rU   rW   rY   product)r  r  r  r  'privatePostV5OrderDisconnectedCancelAllr?  )ra  r/  r  rB  r  
productMapr4  r~  s           rc  cancel_all_orders_afterbybit.cancel_all_orders_after  s      !!!$++GdN;
 99:PRVX^`fg!


 "":T:$	EEdkkRYFbcc ) 	" ds"   BBA1BB	BBc                 f  #    U R                  5       I Sh  vN   U R                  5       I Sh  vN nUS   nU(       d  [        U R                  S-   5      e/ nSn[	        S[        U5      5       H  nX   nU R                  US5      n	U R                  U	5      n
SnU R                  SX5      u  pUS:X  a  [        U R                  S-   5      eUb  Xk:w  a  [        U R                  S	-   5      eUnU R                  US
5      nU R                  US5      nSnUb  SnSU
S
   0nUS:X  a  UOUX'   UR                  U5        M     UUS.nU R                  U R                  UU5      5      I Sh  vN nU R                  US0 5      nU R                  US/ 5      nU R                  US5      $  GN GN~ NB7f)a  
cancel multiple orders for multiple symbols

https://bybit-exchange.github.io/docs/v5/order/batch-cancel

:param CancellationRequest[] orders: list of order ids with symbol, example [{"id": "a", "symbol": "BTC/USDT"}, {"id": "b", "symbol": "ETH/USDT"}]
:param dict [params]: extra parameters specific to the exchange API endpoint
:returns dict: an list of `order structures <https://docs.ccxt.com/#/?id=order-structure>`
Nr   z4 cancelOrdersForSymbols() supports UTA accounts onlyr   r  r^   r  z5 cancelOrdersForSymbols does not allow inverse ordersz_ cancelOrdersForSymbols requires all orders to be of the same category(linear, spot or option))rF   r  r  r  r  rs  rt  )r  r  r;   rF   r  r}  r  r  r  r.   r  r+  r?  rz  r  r  )ra  r  r  r  r  r  r  r  r  r  r  currentCategoryrF   r  idKey	orderItemrB  r~  rs  r,  s                       rc  cancel_orders_for_symbolsbybit.cancel_orders_for_symbols  s     !!!--//$Qx#tww)__``q#f+&AIE%%eX6F[[(F"O&*&9&9.&&Y#O)+"477-d#dee$8+F#DGG  /P  %P  Q  Q&H!!%.B ,,UODME(%&,I ',y&8r}I!!),) ', !%
 ;;DKKQW<XYYH (B7nnVVR0  d++M 	"/> Zs2   F1F)F1F,D=F1,F/-=F1,F1/F1c                   #    U R                  5       I Sh  vN   U R                  5       I Sh  vN u  p4U=(       d    UnSn0 nUb  U R                  U5      nUS   US'   SnU R                  SXb5      u  pXS'   US:X  a%  U(       d  [	        U R
                  S-   U-   S-   5      eUS	:X  d  US
:X  aK  U R                  US5      n	Uc6  U	c3  U R                  U R                  SS5      n
U R                  USU
5      US'   U R                  USSS5      nU R                  USS/5      nU(       a  SUS'   U R                  U R                  Xr5      5      I Sh  vN nU R                  US0 5      nU R                  US5      n[        U[        5      (       d  U R!                  SU05      /$ U R#                  X5      $  GN GN Ni7f)a  
cancel all open orders

https://bybit-exchange.github.io/docs/v5/order/cancel-all

:param str symbol: unified market symbol, only orders in the market of self symbol are cancelled when symbol is not None
:param dict [params]: extra parameters specific to the exchange API endpoint
:param boolean [params.trigger]: True if trigger order
:param boolean [params.stop]: alias for trigger
:param str [params.type]: market type, ['swap', 'option', 'spot']
:param str [params.subType]: market subType, ['linear', 'inverse']
:param str [params.baseCoin]: Base coin. Supports linear, inverse & option
:param str [params.settleCoin]: Settle coin. Supports linear, inverse & option
:returns dict[]: a list of `order structures <https://docs.ccxt.com/#/?id=order-structure>`
NrF   r  r[   r  rY   z. cancelAllOrders() Normal Account not support z marketr  r  r  r  r  rP  r  rQ  Fr  r  rs  rt  r  )r  r  r  r  r;   rF   r  r  r  rj  privatePostV5OrderCancelAllr?  rz  r  
isinstancert  r  r  )ra  r  r  r  r  rY  r  rB  r  r  r  r  r~  rs  r  s                  rc  cancel_all_ordersbybit.cancel_all_orders  s      !!!:>:Q:Q:S4S1/G3G[[(F &tGH**+<fM"
H&6tww)YY\``cllmmH$)"3''
;H~("2 $ 0 0PV W(,(8(8}(]%$$VVYF	6FI#67%0GM"99$++g:VWW: (B7/&$''OOVX$6788  00o 	"4S* Xs3   F?F7F?F:D$F?F=A$F?:F?=F?c           	      8  #    Uc  [        U R                  S-   5      eU R                  5       I Sh  vN   U R                  U5      nUS   (       a  [	        U R                  S-   5      eSU0nU R                  USSU R                  XS5      5      I Sh  vN n[        U5      nUS:X  a=  U R                  USS/S	5      nU(       a  S
OSn	[        S[        U5      -   S-   U	-   5      eUS:  a  [        U R                  S-   5      eU R                  US5      $  N N7f)a  
fetches information on an order made by the user *classic accounts only*

https://bybit-exchange.github.io/docs/v5/order/order-list

: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
:returns dict: An `order structure <https://docs.ccxt.com/#/?id=order-structure>`
Nz( fetchOrder() requires a symbol argumentrU   z/ fetchOrder() is not supported for spot marketsr  r   rQ  r  F c If you are trying to fetch SL/TP conditional order, you might try setting params["trigger"] = TrueOrder  was not found.r    returned more than one order)r2   rF   r  r  r;   fetch_ordersr?  r}  safe_bool_nr:   r  r9   r  )
ra  rF   r  r  r  rB  rs  lengthr  extras
             rc  fetch_order_classicbybit.fetch_order_classicG  s     >#DGG.X$XYY!!!V$&>tww)ZZ[[r
 ((tT[[=YZZVQ;(()V1DeLI#B  *OE3r7 25F F NOOA:tww)HHIIvq)) 	" [s#   /DDA!DDBDDc                 D  #    U R                  5       I Sh  vN   U R                  5       I Sh  vN u  pEU=(       d    UnU(       d  U R                  XU5      I Sh  vN $ SnU R                  USS5      u  psU(       d  [	        U R
                  S-   5      eU R                  U5      nSn	U R                  SX5      u  pUS   UU	S.n
SnU R                  USS	S5      u  pU(       a  S
U
S'   U R                  U R                  X5      5      I Sh  vN nU R                  US0 5      nU R                  US/ 5      n[        U5      S:X  a(  U(       a  SOSn[        S[        U5      -   S-   U-   5      eU R                  US0 5      nU R!                  UU5      $  GN GNj GN? N7f)a3  
classic accounts only/ spot not supported*  fetches information on an order made by the user *classic accounts only*

        https://bybit-exchange.github.io/docs/v5/order/order-list

        :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 dict [params.acknowledged]: to suppress the warning, set to True
        :returns dict: An `order structure <https://docs.ccxt.com/#/?id=order-structure>`
        NFr   acknowledgedz fetchOrder() can only access an order if it is in last 500 orders(of any status) for your account. Set params["acknowledged"] = True to hide self warning. Alternatively, we suggest to use fetchOpenOrder or fetchClosedOrderrF   )r  r  r  rQ  r  r  r  rs  rt  r   rE  rF  rG  rH  )r  r  rN  r  r2   rF   r  r  handle_param_bool_2privateGetV5OrderRealtimer?  rz  r  r}  r:   r  r  )ra  rF   r  r  r  r  rY  acknowledger  r  rB  r  r~  rs  	innerListrM  r  s                    rc  fetch_orderbybit.fetch_ordere  s     !!!:>:Q:Q:S4S1/G3G11"fEEE";;FLR`a#DGG  /P  %P  Q  QV$
!00vN
Tl"

 	 44VYPUV	%0GM"77G8TUUd (B7NN6626	y>Q#B  *OE3r7 25F F NOOy!R0v..[ 	"4S F" VsE   F FF F-F FB1F FBF F F F c                    #    U R                  5       I S h  vN n U R                  US5      nU(       a  [        U R                  S-   5      eU R	                  XX45      I S h  vN $  NP N7f)Nr   z fetchOrders() is not supported after the 5/02 update for UTA accounts, please use fetchOpenOrders, fetchClosedOrders or fetchCanceledOrders)r  r  r;   rF   fetch_orders_classic)ra  r  r  rM  r  resr  s          rc  rJ  bybit.fetch_orders  ss     ++--	   $~~c15tww  *x   x  y  y..veLLL) .( Ms"   A+A'AA+"A)#A+)A+c                   #    U R                  5       I Sh  vN   SnU R                  USS5      u  pTU(       a  U R                  SXX4SSSS5	      I Sh  vN $ 0 nSnUb  U R                  U5      nUS   US	'   SnU R	                  SXt5      u  pUS
:X  a  [        U R                  S-   5      eXS'   U R                  USS/S5      n	U R                  USS/5      nU	(       a  SUS'   Ub  X6S'   Ub  X&S'   U R                  US5      n
U R                  USU
5      nU R                  USS/5      nUb  XS'   U R                  U R                  Xd5      5      I Sh  vN nU R                  U5      nU R                  XX#5      $  GNh GN. N-7f)al  
fetches information on multiple orders made by the user *classic accounts only*

https://bybit-exchange.github.io/docs/v5/order/order-list

:param str symbol: unified market symbol of the market orders were made in
:param int [since]: the earliest time in ms to fetch orders for
:param int [limit]: the maximum number of order structures to retrieve
:param dict [params]: extra parameters specific to the exchange API endpoint
:param boolean [params.trigger]: True if trigger order
:param boolean [params.stop]: alias for trigger
:param str [params.type]: market type, ['swap', 'option', 'spot']
:param str [params.subType]: market subType, ['linear', 'inverse']
:param str [params.orderFilter]: 'Order' or 'StopOrder' or 'tpslOrder'
:param int [params.until]: the latest time in ms to fetch entries for
:param boolean [params.paginate]: default False, when True will automatically paginate by calling self endpoint multiple times. See in the docs all the [availble parameters](https://github.com/ccxt/ccxt/wiki/Manual#pagination-params)
:returns Order[]: a list of `order structures <https://docs.ccxt.com/#/?id=order-structure>`
NFr   r  rx  ry  r   rF   r  rU   z0 fetchOrders() is not supported for spot marketsr  rQ  r  r  r  rM  r  r  r  )r  r  fetch_paginated_call_cursorr  r  r;   rF   rK  rj  r  privateGetV5OrderHistoryr?  r  r  ra  r  r  rM  r  r  rB  r  r  r  r  r  r~  rv  s                 rc  rY  bybit.fetch_orders_classic  s    & !!!88PZ[99-X]gw  zB  DH  JL  M  M  M[[(F &tGH**=&I6>tww)[[\\"
$$Vi-@%H	6Iv#67%0GM"$G#(K !!&'2##FIu=6Iw#78!(I66t{{77STTf 33H=  u<<a 	" M0 Us4   FE><FFDFF(FFFc           	        #    U R                  5       I Sh  vN   SU0nU R                  USSU R                  XC5      5      I Sh  vN n[        U5      nUS:X  a=  U R	                  USS/S5      nU(       a  SOSn[        S	[        U5      -   S
-   U-   5      eUS:  a  [        U R                  S-   5      eU R                  US5      $  N N7f)a  
fetches information on a closed order made by the user

https://bybit-exchange.github.io/docs/v5/order/order-list

:param str id: order id
:param str [symbol]: unified symbol of the market the order was made in
:param dict [params]: extra parameters specific to the exchange API endpoint
:param boolean [params.trigger]: set to True for fetching a closed trigger order
:param boolean [params.stop]: alias for trigger
:param str [params.type]: market type, ['swap', 'option', 'spot']
:param str [params.subType]: market subType, ['linear', 'inverse']
:param str [params.orderFilter]: 'Order' or 'StopOrder' or 'tpslOrder'
:returns dict: an `order structure <https://docs.ccxt.com/#/?id=order-structure>`
Nr  r   rQ  r  FrE  rF  rG  rH  r   rI  )
r  fetch_closed_ordersr?  r}  rK  r:   r  r9   rF   r  	ra  rF   r  r  rB  rs  rL  r  rM  s	            rc  fetch_closed_orderbybit.fetch_closed_order<  s       !!!r
 //dDKKPWD`aaVQ;(()V1DeLI#B  *OE3r7 25F F NOOA:tww)HHIIvq)) 	" b"   CC.CC
BC
Cc           	        #    U R                  5       I Sh  vN   SU0nU R                  USSU R                  XC5      5      I Sh  vN n[        U5      nUS:X  a=  U R	                  USS/S5      nU(       a  SOSn[        S	[        U5      -   S
-   U-   5      eUS:  a  [        U R                  S-   5      eU R                  US5      $  N N7f)aX  
fetches information on an open order made by the user

https://bybit-exchange.github.io/docs/v5/order/open-order

:param str id: order id
:param str [symbol]: unified symbol of the market the order was made in
:param dict [params]: extra parameters specific to the exchange API endpoint
:param boolean [params.trigger]: set to True for fetching an open trigger order
:param boolean [params.stop]: alias for trigger
:param str [params.type]: market type, ['swap', 'option', 'spot']
:param str [params.subType]: market subType, ['linear', 'inverse']
:param str [params.baseCoin]: Base coin. Supports linear, inverse & option
:param str [params.settleCoin]: Settle coin. Supports linear, inverse & option
:param str [params.orderFilter]: 'Order' or 'StopOrder' or 'tpslOrder'
:returns dict: an `order structure <https://docs.ccxt.com/#/?id=order-structure>`
Nr  r   rQ  r  FrE  rF  rG  rH  r   rI  )
r  fetch_open_ordersr?  r}  rK  r:   r  r9   rF   r  rc  s	            rc  fetch_open_orderbybit.fetch_open_orderZ  s     $ !!!r
 --fdD$++gB^__VQ;(()V1DeLI#B  *OE3r7 25F F NOOA:tww)HHIIvq)) 	" `rf  c                   #    U R                  5       I Sh  vN   SnU R                  USS5      u  pTU(       a  U R                  SXX4SSSS5	      I Sh  vN $ 0 nSnUb  U R                  U5      nUS   US	'   SnU R	                  SXt5      u  pXS
'   U R                  USS/S5      n	U R                  USS/5      nU	(       a  SUS'   Ub  X6S'   Ub  X&S'   U R                  US5      n
U R                  USU
5      nU R                  USS/5      nUb  XS'   U R                  U R                  Xd5      5      I Sh  vN nU R                  U5      nU R                  XX#5      $  GNJ GN N-7f)a}  
fetches information on multiple canceled and closed orders made by the user

https://bybit-exchange.github.io/docs/v5/order/order-list

:param str [symbol]: unified market symbol of the market orders were made in
:param int [since]: the earliest time in ms to fetch orders for
:param int [limit]: the maximum number of order structures to retrieve
:param dict [params]: extra parameters specific to the exchange API endpoint
:param boolean [params.trigger]: set to True for fetching trigger orders
:param boolean [params.stop]: alias for trigger
:param str [params.type]: market type, ['swap', 'option', 'spot']
:param str [params.subType]: market subType, ['linear', 'inverse']
:param str [params.orderFilter]: 'Order' or 'StopOrder' or 'tpslOrder'
:param int [params.until]: the latest time in ms to fetch entries for
:param boolean [params.paginate]: default False, when True will automatically paginate by calling self endpoint multiple times. See in the docs all the [available parameters](https://github.com/ccxt/ccxt/wiki/Manual#pagination-params)
:returns Order[]: a list of `order structures <https://docs.ccxt.com/#/?id=order-structure>`
NFrz   r  rx  ry  r   rF   r  r  rQ  r  r  r  rM  r  r  r  )r  r  r]  r  r  rK  rj  r  r^  r?  r  r  r_  s                 rc   fetch_canceled_and_closed_orders&bybit.fetch_canceled_and_closed_ordersz  s    & !!!88A_akl99:XZ`in  yI  KS  UY  []  ^  ^  ^[[(F &tGH**+I6Z"
$$Vi-@%H	6Iv#67%0GM"$G#(K !!&'2##FIu=6Iw#78!(I66t{{77STTB 33H=  u<<y 	" ^, Us4   E(E <E(E#C$E(8E&9(E(#E(&E(c           	         #    U R                  5       I Sh  vN   SS0nU R                  XX0R                  XT5      5      I Sh  vN $  N1 N7f)aw  
fetches information on multiple closed orders made by the user

https://bybit-exchange.github.io/docs/v5/order/order-list

:param str [symbol]: unified market symbol of the market orders were made in
:param int [since]: the earliest time in ms to fetch orders for
:param int [limit]: the maximum number of order structures to retrieve
:param dict [params]: extra parameters specific to the exchange API endpoint
:param boolean [params.trigger]: set to True for fetching closed trigger orders
:param boolean [params.stop]: alias for trigger
:param str [params.type]: market type, ['swap', 'option', 'spot']
:param str [params.subType]: market subType, ['linear', 'inverse']
:param str [params.orderFilter]: 'Order' or 'StopOrder' or 'tpslOrder'
:param int [params.until]: the latest time in ms to fetch entries for
:param boolean [params.paginate]: default False, when True will automatically paginate by calling self endpoint multiple times. See in the docs all the [available parameters](https://github.com/ccxt/ccxt/wiki/Manual#pagination-params)
:returns Order[]: a list of `order structures <https://docs.ccxt.com/#/?id=order-structure>`
Nr  rr  r  rl  r?  ra  r  r  rM  r  rB  s         rc  rb  bybit.fetch_closed_orders  sT     & !!!8
 ::6%Q\Q\]dQmnnn	 	" o!   AA,AA
A
Ac           	         #    U R                  5       I Sh  vN   SS0nU R                  XX0R                  XT5      5      I Sh  vN $  N1 N7f)ae  
fetches information on multiple canceled orders made by the user

https://bybit-exchange.github.io/docs/v5/order/order-list

:param str [symbol]: unified market symbol of the market orders were made in
:param int [since]: timestamp in ms of the earliest order, default is None
:param int [limit]: max number of orders to return, default is None
:param dict [params]: extra parameters specific to the exchange API endpoint
:param boolean [params.trigger]: True if trigger order
:param boolean [params.stop]: alias for trigger
:param str [params.type]: market type, ['swap', 'option', 'spot']
:param str [params.subType]: market subType, ['linear', 'inverse']
:param str [params.orderFilter]: 'Order' or 'StopOrder' or 'tpslOrder'
:param int [params.until]: the latest time in ms to fetch entries for
:param boolean [params.paginate]: default False, when True will automatically paginate by calling self endpoint multiple times. See in the docs all the [available parameters](https://github.com/ccxt/ccxt/wiki/Manual#pagination-params)
:returns dict: a list of `order structures <https://docs.ccxt.com/#/?id=order-structure>`
Nr  rt  ro  rp  s         rc  fetch_canceled_ordersbybit.fetch_canceled_orders  sT     & !!!;
 ::6%Q\Q\]dQmnnn	 	" orr  c                   #    U R                  5       I Sh  vN   SnU R                  USS5      u  pTU(       a  U R                  SXX4SSSS5	      I Sh  vN $ 0 nSnUb  U R                  U5      nUS   US	'   SnU R	                  SXt5      u  pUS
:X  d  US:X  aL  U R                  US5      n	Uc7  U	c4  U R                  U R                  SS5      n
U R                  USU
5      nXS'   XS'   U R                  USSS5      nU R                  USS/5      nU(       a  SUS'   Ub  X6S'   U R                  U R                  Xd5      5      I Sh  vN nU R                  U5      nU R                  XX#5      $  GNZ GN  N-7f)a  
fetch all unfilled currently open orders

https://bybit-exchange.github.io/docs/v5/order/open-order

:param str symbol: unified market symbol
:param int [since]: the earliest time in ms to fetch open orders for
:param int [limit]: the maximum number of open orders structures to retrieve
:param dict [params]: extra parameters specific to the exchange API endpoint
:param boolean [params.trigger]: set to True for fetching open trigger orders
:param boolean [params.stop]: alias for trigger
:param str [params.type]: market type, ['swap', 'option', 'spot']
:param str [params.subType]: market subType, ['linear', 'inverse']
:param str [params.baseCoin]: Base coin. Supports linear, inverse & option
:param str [params.settleCoin]: Settle coin. Supports linear, inverse & option
:param str [params.orderFilter]: 'Order' or 'StopOrder' or 'tpslOrder'
: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 Order[]: a list of `order structures <https://docs.ccxt.com/#/?id=order-structure>`
NFr   r  rx  ry  r   rF   r  r  r  r  r  r  rP  r  r  rQ  r  r  rM  )r  r  r]  r  r  r  r  r  rj  rS  r?  r  r  )ra  r  r  rM  r  r  rB  r  r  r  r  rP  r  r~  rv  s                  rc  rh  bybit.fetch_open_orders  s    ( !!!88ART^_99:KV\ak{  ~F  HL  NP  Q  Q  Q[[(F &tGH**+<fM8ty0''
;H~("2 $ 0 0PV W!--flMR
(2%"
$$VVYF	6FI#67%0GM"$G77G8TUUB 33H=  u<<w 	" Q* Vs4   E8E0<E8E3C4E8E6	(E83E86E8c           	         #    0 nU R                  USS5      nUb  XvS'   OXS'   U R                  USS/5      nU R                  X#X@R                  Xe5      5      I Sh  vN $  N7f)a  
fetch all the trades made from a single order

https://bybit-exchange.github.io/docs/v5/position/execution

:param str id: order id
:param str symbol: unified market symbol
:param int [since]: the earliest time in ms to fetch trades for
:param int [limit]: the maximum number of trades to retrieve
:param dict [params]: extra parameters specific to the exchange API endpoint
:returns dict[]: a list of `trade structures <https://docs.ccxt.com/#/?id=trade-structure>`
r  r  Nr  )r|  rj  fetch_my_tradesr?  )ra  rF   r  r  rM  r  rB  r  s           rc  fetch_order_tradesbybit.fetch_order_trades  sm      **6?MR$%2M"!#I6O]#CD))&G@\]]]]s   AA#A!A#c                   #    U R                  5       I Sh  vN   SnU R                  USS5      u  pTU(       a  U R                  SXX4SSSS5	      I Sh  vN $ SS	0nSnUb  U R                  U5      nUS
   US'   SnU R	                  SXt5      u  pXS'   Ub  X6S'   Ub  X&S'   U R                  SXd5      u  pdU R                  U R                  Xd5      5      I Sh  vN n	U R                  U	5      n
U R                  XX#5      $  N N N+7f)a8  
fetch all trades made by the user

https://bybit-exchange.github.io/docs/api-explorer/v5/position/execution

: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 str [params.type]: market type, ['swap', 'option', 'spot']
:param str [params.subType]: market subType, ['linear', 'inverse']
: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 Trade[]: a list of `trade structures <https://docs.ccxt.com/#/?id=trade-structure>`
NFr   r  rx  ry  rK  execTyper'   rF   r  r  rM  r  r  )
r  r  r]  r  r  r  privateGetV5ExecutionListr?  r  r%  )ra  r  r  rM  r  r  rB  r  r  r~  r&  s              rc  ry  bybit.fetch_my_trades  sM     !!!88R\]99/6Z_iy  |D  FJ  LO  P  P  P
 [[(F &tGH**?FK"
$G#(K 229gN77G8TUUR 55h?  >>} 	" P  V4   DD<DDBDD(DDDr  c                     U R                  US5      nU R                  US5      nU R                  US5      nU R                  U5        UUU R                  U R                  US5      U5      UUS.$ )NaddressDeposit
tagDepositr  r  )r  r  r  addresstag)r  check_addressr  )ra  depositAddressr  r  r  r  s         rc  parse_deposit_addressbybit.parse_deposit_address  s~     "">3CD~|<&17#"..t/?/?PW/XZ^_
 	
re  r  c                   #    U R                  5       I Sh  vN   U R                  U5      nSUS   0nSnU R                  U5      u  pRUb  U R                  XQ5      US'   U R	                  U R                  XB5      5      I Sh  vN nU R                  US0 5      nU R                  US/ 5      nU R                  US5      n	U R                  U	5      nU R                  XS   /SS	US   05      n
U R                  U
S
5      $  N N}7f)a  
fetch a dictionary of addresses for a currency, indexed by network

https://bybit-exchange.github.io/docs/v5/asset/master-deposit-addr

:param str code: unified currency code of the currency for the deposit address
:param dict [params]: extra parameters specific to the exchange API endpoint
:returns dict: a dictionary of `address structures <https://docs.ccxt.com/#/?id=address-structure>` indexed by the network
Nr  rF   	chainTypers  r  r  Fr  r  )r  r  handle_network_code_and_paramsnetwork_code_to_id$privateGetV5AssetDepositQueryAddressr?  rz  r  r  parse_deposit_addressesindex_by)ra  r  r  r  rB  r  r~  rs  r  r  parseds              rc  "fetch_deposit_addresses_by_network(bybit.fetch_deposit_addresses_by_network  s     !!!==&HTN
 "AA&I"#'#:#:;#MGK BB4;;wC_``( (B7"5/==&--f7G6H%(R
  }}VY//I 	" as#   DC>A+DD A<D Dc                    #    U R                  5       I Sh  vN   U R                  U5      nU R                  U5      u  pEU R                  X5      I Sh  vN nU R	                  US   XF5      nXg   $  NZ N7f)aV  
fetch the deposit address for a currency associated with self account

https://bybit-exchange.github.io/docs/v5/asset/master-deposit-addr

: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  )r  r  r  r  )select_network_code_from_unified_networks)ra  r  r  r  r  paramsOmitedindexedAddressesselectedNetworkCodes           rc  fetch_deposit_addressbybit.fetch_deposit_address8  s|      !!!==&$($G$G$O!!%!H!H!\\"LLXV\M]_j}44 	" ]s!   A5A1<A5A3A53A5c                   #    U R                  5       I Sh  vN   SnU R                  USS5      u  pTU(       a  U R                  SXX4SSSS5	      I Sh  vN $ 0 nSnUb  U R                  U5      nUS   US	'   Ub  X&S
'   Ub  X6S'   U R	                  SXd5      u  pdU R                  U R                  Xd5      5      I Sh  vN nU R                  U5      n	U R                  XX#5      $  N N N+7f)a  
       fetch all deposits made to an account

       https://bybit-exchange.github.io/docs/v5/asset/deposit-record

       :param str code: unified currency code
       :param int [since]: the earliest time in ms to fetch deposits for, default = 30 days before the current time
       :param int [limit]: the maximum number of deposits structures to retrieve, default = 50, max = 50
       :param dict [params]: extra parameters specific to the exchange API endpoint
       :param int [params.until]: the latest time in ms to fetch deposits for, default = 30 days after since
EXCHANGE SPECIFIC PARAMETERS
       :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)
       :param str [params.cursor]: used for pagination
       :returns dict[]: a list of `transaction structures <https://docs.ccxt.com/#/?id=transaction-structure>`
       NFr   r  rx  ry  r   rF   r  r  rM  r  )	r  r  r]  r  r  #privateGetV5AssetDepositQueryRecordr?  r  parse_transactions
ra  r  r  rM  r  r  rB  r  r~  rv  s
             rc  fetch_depositsbybit.fetch_depositsI  s%      !!!88R\]99/4X]gw  zB  DH  JL  M  M  M

 }}T*H&tnGFO#(K $G229gNAA$++gB^__8 33H=&&tuDDa 	" M `4   C+C%<C+C'A)C+=C)>(C+'C+)C+c                   #    U R                  5       I Sh  vN   SnU R                  USS5      u  pTU(       a  U R                  SXX4SSSS5	      I Sh  vN $ 0 nSnUb  U R                  U5      nUS   US	'   Ub  X&S
'   Ub  X6S'   U R	                  SXd5      u  pdU R                  U R                  Xd5      5      I Sh  vN nU R                  U5      n	U R                  XX#5      $  N N N+7f)a  
fetch all withdrawals made from an account

https://bybit-exchange.github.io/docs/v5/asset/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]: the latest time in ms to fetch entries for
:param boolean [params.paginate]: default False, when True will automatically paginate by calling self endpoint multiple times. See in the docs all the [availble parameters](https://github.com/ccxt/ccxt/wiki/Manual#pagination-params)
:returns dict[]: a list of `transaction structures <https://docs.ccxt.com/#/?id=transaction-structure>`
NFr   r  rx  ry  r   rF   r  r  rM  r  )	r  r  r]  r  r  $privateGetV5AssetWithdrawQueryRecordr?  r  r  r  s
             rc  fetch_withdrawalsbybit.fetch_withdrawals  s(     !!!88ASU_`99:Ld[`jz  }E  GK  MO  P  P  P

 }}T*H&tnGFO#(K $G229gNBB4;;wC_``T 33H=&&tuDD} 	" P ar  c                 D    SSSSSSSSSSSSS	.nU R                  X!U5      $ )
Nr  pending
processingokfailrg  rk  failed)r  r   2r   4SecurityCheckPendingsuccessCancelByUserRejectFailBlockchainConfirmedry  rz  s      rc  parse_transaction_statusbybit.parse_transaction_status  sD     & & #'
  &99re  transactionc                    U R                  US5      nU R                  X25      nU R                  USS5      nU R                  US5      nU R	                  U R                  US5      5      nU R                  USS5      nSU;   a  SOS	n	S n
Ub  UUS
.n
U R                  US5      n0 SU_SU R                  USS5      _SU R                  US5      _SU_SU R                  U5      _SU R                  U R                  US5      5      _SS _SU_SS _SU R                  US5      _SS _SS _SU	_SU R                  US5      _SU_SU_SU_U
S S S.E$ ) Nr  
createTime	successAt
updateTimer.  
depositFeer  r[  
withdrawalr  	toAddressr  rF   
withdrawIdtxidtxIDr  r  r  r  r  	addressToaddressFromr  tagTotagFromr  r  r  updated)r   internalcomment)
r  r  r  r  r  rb  r|  r`  r  r	  )ra  r  r  r  r  r  r  r.  feeCostr  r   r  s               rc  parse_transactionbybit.parse_transaction  s   R %%k6:
&&z<''\;O	##K>..t/?/?X/VW$$[,N)[8y| C $$[+>	
K
$$$[$E
 D$$[&9
 	

 Y/
 t..t/?/?W/UV
 t
 
 4
 4##K7
 T
 t
 D
 d&&{H=
 
  f!
" w#
$ )
 	
re  c                 z  #    U R                  5       I Sh  vN   SnU R                  USS5      u  pTU(       a  U R                  SXX4SSSS5	      I Sh  vN $ 0 nU R                  5       I Sh  vN nSnSn	US	   (       a
  S
n	Ub  X&S'   OUb  U R	                  U5      US'   Ub  U R                  U5      nUS   Xi'   Ub  X6S'   Sn
U R                  SSU5      u  pSnUS	   (       a{  U R                  U R                  SS5      nU
S:X  a/  US:  a)  U R                  U R                  Xd5      5      I Sh  vN nOQU R                  U R                  Xd5      5      I Sh  vN nO(U R                  U R                  Xd5      5      I Sh  vN nU R                  U5      nU R                  XX#5      $  GN GN\ GNE N N[ N47f)a  
fetch the history of changes, actions done by the user or operations that altered the balance of the user

https://bybit-exchange.github.io/docs/v5/account/transaction-log
https://bybit-exchange.github.io/docs/v5/account/contract-transaction-log

: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 boolean [params.paginate]: default False, when True will automatically paginate by calling self endpoint multiple times. See in the docs all the [available parameters](https://github.com/ccxt/ccxt/wiki/Manual#pagination-params)
:param str [params.subType]: if inverse will use v5/account/contract-transaction-log
:returns dict: a `ledger structure <https://docs.ccxt.com/#/?id=ledger>`
NFr   r  rx  ry  r   r  r   r  r  
start_daterF   rM  r  r   r  )r  r  r]  r  yyyymmddr  r  r  r  )privateGetV5AccountContractTransactionLogr?  !privateGetV5AccountTransactionLogr  parse_ledger)ra  r  r  rM  r  r  rB  enableUnifiedr  currencyKeyr  r~  r  rv  s                 rc  fetch_ledgerbybit.fetch_ledger:  s     !!!88PZ[99-V[euw  BF  HJ  K  K  K
& #5577$K ',$ (,e(<%}}T*H#+D>G $G99-vV"&"3"3DLLBWYZ"[)#)<q)@!%!O!OPTP[P[\cPl!mm!%!G!GT[Hd!ee!KKDKKX_LhiiHP 33H=  >>u 	" K( 8* neisj   F;F,<F;F/F;-F2.CF;2F53(F;F7(F;F9(F;/F;2F;5F;7F;9F;itemc                    U R                  USS5      nU R                  X25      nU R                  X25      nU R                  USS5      nU R                  USS5      n[        R                  " US5      (       a  SOS	nS nS n	S n
Ub|  Uby  US:X  a  UO[        R
                  " U5      nU R                  [        R                  " Xk5      5      nU R                  U5      n	U R                  [        R                  " U5      5      n
U R                  U R                  US
5      5      nUc  U R                  US5      nU R                  UU R                  US5      UU R                  US5      U R                  US5      S U R                  U R                  US5      5      UU
UU R                  U5      UU	SUU R                  US5      S.S.U5      $ )Nr  r  r  r  wallet_balancecashBalancer  outin	exec_timetransactionTimerF   	wallet_idtx_idr  r  r   )r  r  )r  rF   	directionrH  referenceIdreferenceAccountr  r  r  r  r  beforeafterr.  r   )r|  r  safe_currencyr@   	string_lt
string_negparse_to_numericrI  
string_absr  r  r  safe_ledger_entryparse_ledger_entry_typer`  r	  )ra  r  r  r  r  r  afterStringr  r  r  r  
differencer  s                rc  parse_ledger_entrybybit.parse_ledger_entry  s   J ''fjA
&&z<%%j;))$(C((/?O$..|SAAEt	"|'?*3u*<7CUCUVbCcJ**7+=+=k+VWF))+6E**7+=+=l+KLFNN4#3#3D+#FG	))$0ABI%%""4."''k:++D': $001A1A$1OP"Y/ ((u5'
& ' 	re  c                     0 SS_SS_SS_SS_SS	_S
S_SS_SS_SS_SS_SS_SS_SS_SS_SS
_SS	_SS_SSS.EnU R                  X!U5      $ )NDepositr  WithdrawRealisedPNLr  
Commissionr   RefundcashbackPrizeprizeExchangeOrderWithdrawExchangeOrderDepositTRANSFER_INTRANSFER_OUTTRADE
SETTLEMENTDELIVERYLIQUIDATIONBONUS
FEE_REFUNDINTEREST)CURRENCY_BUYCURRENCY_SELLry  )ra  r  r  s      rc  r  bybit.parse_ledger_entry_type0  s    
}

 7
 %	

 j
 W
 $]
 #M
 =
 M
 W
 '
 
 7
  W!
" *#
$ %
& $$)
, T22re  r  r  c                   #    U R                  XE5      u  pESnU R                  5       I Sh  vN nUS   nU R                  USS5      u  peUc  U(       a  SOSnU R                  5       I Sh  vN   U R	                  U5        U R                  U5      n	U	S   U R                  U5      UU R                  5       US.n
Ub  XJS	'   U R                  U5      u  pU R                  U5      nUb  UR                  5       U
S
'   U R                  U R                  X5      5      I Sh  vN nU R                  US0 5      nU R                  X5      $  GN N N-7f)a  
make a withdrawal

https://bybit-exchange.github.io/docs/v5/asset/withdraw

:param str code: unified currency code
:param float amount: the amount to withdraw
:param str address: the address to withdraw to
:param str tag:
:param dict [params]: extra parameters specific to the exchange API endpoint
:param str [params.accountType]: 'UTA', 'FUND', 'FUND,UTA', and 'SPOT(for classic accounts only)
:returns dict: a `transaction structure <https://docs.ccxt.com/#/?id=transaction-structure>`
Nr   r   r9  UTAr  rF   )r  r  r  r  r9  r  r  rs  )handle_withdraw_tag_and_paramsr  r  r  r  r  r  ro  r  r  upper privatePostV5AssetWithdrawCreater?  rz  r  )ra  r  r  r  r  r  r9  r  r  r  rB  r  queryr  r~  rs  s                   rc  r   bybit.withdrawI  sU     99#F0022";;FJP]^#(%fK!!!7#==&TN++F3**,&
 ? EN!@@H++K8	 (0GG>>t{{7?Z[[ (B7%%f77E 3
 	"  \s4   )EE?E+E
,B2EE)E
EEc                   #    Uc  [        U R                  S-   5      eU R                  5       I Sh  vN   U R                  U5      nSUS   0nSnSnU R	                  SX25      u  pbXdS'   U R                  U R                  XB5      5      I Sh  vN nU R                  US0 5      nU R                  USS	/ 5      nU R                  US
5      n	U R                  US0 5      n
U R                  X5      nXS'   U R                  U	5      US'   U$  N N}7f)am  
fetch data on a single open contract trade position

https://bybit-exchange.github.io/docs/v5/position

:param str symbol: unified market symbol of the market the position is held in, default is None
:param dict [params]: extra parameters specific to the exchange API endpoint
:returns dict: a `position structure <https://docs.ccxt.com/#/?id=position-structure>`
Nz+ fetchPosition() requires a symbol argumentr  rF   r   r  rs  rt  rw  r  r   r  r  )r2   rF   r  r  r  privateGetV5PositionListr?  rz  r*  r  parse_positionr`  )ra  r  r  r  rB  r~  r  rs  	positionsr  r  positions               rc  fetch_positionbybit.fetch_position}  s      >#DGG.[$[\\!!!V$fTl
 **?FK"
66t{{77STTR (B7$$VVZD	%%h7	y!R0&&u5 )#||I6s 	" Us#   /DD	ADDA<DDc                   #    U R                  5       I Sh  vN   SnU R                  USS5      u  p2U(       a!  U R                  SUSSUSSSS5	      I Sh  vN $ SnUb[  [        U[        5      (       aF  [        U5      nUS:  a  [        U R                  S	-   5      eUS:X  a  US
   nU R                  U5      nOUb  UnU R                  U5      /n0 nSnUb  U R                  U5      nUS   nUS   US'   SnU R                  SXr5      u  pUS:X  d  US:X  a^  U R                  US5      n	US:X  a;  Uc7  U	c4  U R                  U R                  SS5      n
U R                  USU
5      nXS'   OUc  U	c  SUS'   U R                  US5      c  SUS'   U R                  US/5      nXS'   U R!                  U R#                  Xb5      5      I Sh  vN nU R%                  U5      n/ n['        S
[        U5      5       HE  nX   nSU;   a  SU;   a  U R)                  US5      nUR+                  U R-                  U5      5        MG     U R/                  USUS5      $  GN< GN  N7f)a  
fetch all open positions

https://bybit-exchange.github.io/docs/v5/position

:param str[] symbols: list of unified market symbols
:param dict [params]: extra parameters specific to the exchange API endpoint
:param str [params.type]: market type, ['swap', 'option', 'spot']
:param str [params.subType]: market subType, ['linear', 'inverse']
:param str [params.baseCoin]: Base coin. Supports linear, inverse & option
:param str [params.settleCoin]: Settle coin. Supports linear, inverse & option
:param boolean [params.paginate]: default False, when True will automatically paginate by calling self endpoint multiple times
:returns dict[]: a list of `position structure <https://docs.ccxt.com/#/?id=position-structure>`
NFr   r  rx  ry  r  r   zD fetchPositions() does not accept an array with more than one symbolr   r  rF   r  r  r  r  r  rP  r  rM  r  rv  is_valid)r  r  r]  rA  rt  r}  r2   rF   r  r  r  r  r  r  r  rj  r  r?  r  r  rz  r  r  filter_by_array_positions)ra  r  r  r  r  r  rB  r  r  r  r  rP  r~  r  resultsr  rawPositions                    rc  fetch_positionsbybit.fetch_positions  s     !!!88AQS]^99:JGUY[_agiy  |D  FJ  LO  P  P  PZ%>%>LMq '2x(xyy!# ))'2G F{{6*+G[[(FH%F &tGH**+;VL8ty0''
;Hx>h&6$($4$4T\\?TZ$[M!%!1!1&,!VJ,6L) >h&6*3GJ'VW-5"GG6F8,"
66t{{77STTH 88B	q#i.)A#,K+%J+,E"nn[&ANN4..{;< * --gx%PPg 	" PF Us5   II>IIE2II	B
IIIr  c                    U R                  US5      nUS LnU R                  US5      nU R                  XRS S5      n[        R                  " U R	                  USS5      5      nU R                  US5      nUb&  US:X  a  U(       a  SOS	nOUS
:X  a  U(       a  S	OSnOS nU R	                  USS5      nU R                  U R                  US5      5      n	U R	                  USS5      n
U R                  US5      nU R                  USS/5      nU R                  U R                  US5      5      nUc  U R                  U/ SQ5      nU R                  USS5      nS nU R                  S   (       a  U R                  S   (       a  US   (       a  U(       d
  US:X  a  SOSnU R                  US5      nU R                  U R                  U/ SQ5      5      nU R                  US5      nU R                  U R                  US5      5      nU R                  US 5      nUGb  US!   S":X  a  U R                  U R                  S#S$5      (       a  UOUn[        R                  " [        R                  " UU5      5      n[        R                  " [        R                  " [        R                  " UU5      U5      U	5      nGO1U R                  US%5      nUS&   (       au  [        R                  " [        R                  " UU5      5      n[        R                  " UU5      nUb/  U
c,  [        R                  " [        R                  " UU5      U5      n
O[        R                  " [        R                  " UU5      5      n[        R                  " UU5      n[        R                  " [        R                  " UU5      U5      nUb/  U
c,  [        R                  " U[        R                  " UU5      5      n
[        R                  " X5      n[        R                  " UUS'5      nU R                  US(5      nUS L=(       a    US):g  nU R!                  0 S*U_S+S _SUS   _S,U_S-U R#                  U5      _S.U_S/U R%                  U
5      _S0U R%                  [        R                  " X5      5      _S1U R%                  U5      _S2U R%                  U5      _S3U R%                  U5      _S4U R%                  U5      _S U R%                  U5      _S5U R%                  U	5      _S6U R'                  US75      _S8U R%                  U5      _S9U R'                  US95      _U R%                  U5      U R%                  U5      U R%                  U5      U R'                  US:5      U R%                  U5      UUS U R)                  US;S<5      U R)                  US=S>5      US?.E5      $ )@N
closedSizer  r  r  r  r  BuyshortlongSellpositionValuecumExitValueunrealisedPnl
positionIMcumEntryValue
positionMMr  r  
updated_at)r  r  r  	tradeModer   r  r  r   isolatedcrosspositionBalance)
entryPricer  avgEntryPricer  liqPricerG  r  r  r2  F	bustPricer  r  r  r  r  rF   r  r  r  initialMargininitialMarginPercentagemaintenanceMarginmaintenanceMarginPercentager-  notionalunrealizedPnlrealizedPnl	closedPnl	contractsr  avgExitPrice	stop_lossr  take_profitr  )marginRatioliquidationPricer  r|  
collateralr<  r  rX  r?  r@  rC  )r  r  r@   r  r|  r^  r  r  r  r  r  r  
string_subrI  r  
string_divsafe_positionr`  r  r	  rb  )ra  r  r  r  	isHistoryr  r  r  r5  r$  initialMarginStringmaintenanceMarginStringr  r  r)  r<  collateralStringr-  r  r>  rG  r7  r  r0   maintenanceMarginPriceDifferencemultiplyr4  r=  r  rC  s                                 rc  r  bybit.parse_position(  s   P %%h=
t+	##Hh7!!(D*E!!$"4"4Xvu"MN&1u}"+w!*v%%hPt'7'7/'RS"00<Y"&"2"28\"J''=+2NO	"nnT-=-=h-UV&"&"5"5h@k"l%%hQ?	
34$,,G]:^cijsct,5NZ
++H6GH^^D$6$6xAl$mn
$$X{;	>>$*:*:8Z*PQ##Hj9'h6)%)^^DLLBegl%m%m	s}$//0B0B5JZ0[\
#*#5#5g6H6HI[I[\fhlIm  pG  7H  JW  $X  ,,X{C	(#
 8?7I7I'J\J\]moxJy7z4.5.@.@Aacg.h+".5H5P.5.@.@ASASTXZdAego.p+ ")!3!3G4F4FyRb4c!dJ&11)=MNH.5.@.@ASASTXZdAego.p+".5H5P.5.@.@wGYGYZdfnGo.p+&-&8&89P&[#(()@BRTUV&&x?T)Cs0B!! #
H#
$#
 fX&#
 	#

 Y/#
 "#6#
 T../BC#
 &t'8'89K9KL_9j'k#
  !2!23J!K#
 *4+<+<=X+Y#
 $++J7#
 ))(3#
 ))(3#
 T..}=#
 4++HkB#
  **40!#
" D,,V^D##
$  ,,[9 $ 1 12B C**95))(NC++,<=$!//+zR#11(M<X9#
  	re  c                    #    U R                  5       I Sh  vN   U R                  U5      nU R                  X5      I Sh  vN nU R                  XC5      $  N? N7f)a&  
fetch the set leverage for a market

https://bybit-exchange.github.io/docs/v5/position

: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>`
N)r  r  r  parse_leverage)ra  r  r  r  r  s        rc  fetch_leveragebybit.fetch_leverage  sS      !!!V$,,V<<""844 	"<s!   AA)A AAArG  c                     U R                  US5      nU R                  US5      nUU R                  X25      U R                  US5      UUS.$ )Nr  rG  r<  )r  r  r<  longLeverageshortLeverage)r  r  r  rs  )ra  rG  r  r  leverageValues        rc  rK  bybit.parse_leverage  sW    ##Hh7))(J?&&x800<H)*
 	
re  r<  c                   #    U R                  5       I Sh  vN   U R                  5       I Sh  vN u  pEU=(       d    UnSnSnU(       aa  US:X  a  SnO*US:X  a  SnO!US:X  a  SnO[        U R                  S-   5      eS	U0n	U R	                  U R                  X5      5      I Sh  vN nU$ Uc  [        U R                  S
-   5      eU R                  U5      nUS   S:H  n
U
(       aX  US:X  a  SnO!US:X  a  SnO[        U R                  S-   5      eS	U0n	U R	                  U R                  X5      5      I Sh  vN nU$ SnU R                  SXs5      u  pSnUS:X  a  SnO!US:X  a  SnO[        U R                  S-   5      eSnSnU R                  US5      nUcc  U R                  USS5      nU R                  USS5      nUc  Uc  [        U R                  S-   5      eUc  UnUc  UnU R                  U/ SQ5      nOUnUnU R                  US5      nUUS   UUUS.n	U R                  U R                  X5      5      I Sh  vN nU$  GN2 GN GN GN N7f)ae  
set margin mode(account) or trade mode(symbol)

https://bybit-exchange.github.io/docs/v5/account/set-margin-mode
https://bybit-exchange.github.io/docs/v5/position/cross-isolate

:param str marginMode: account mode must be either [isolated, cross, portfolio], trade mode must be either [isolated, cross]
:param str symbol: unified market symbol of the market the position is held in, default is None
:param dict [params]: extra parameters specific to the exchange API endpoint
:param str [params.leverage]: the rate of leverage, is required if setting trade mode(symbol)
:returns dict: response from the exchange
Nr*  ISOLATED_MARGINr+  REGULAR_MARGIN	portfolioPORTFOLIO_MARGINzG setMarginMode() marginMode must be either [isolated, cross, portfolio]r   zD setMarginMode() requires a symbol parameter for non unified accountr  r  zM setMarginMode() for usdc market marginMode must be either [cross, portfolio]r   r   r   zH setMarginMode() with symbol marginMode must be either [isolated, cross]rG  sell_leveragesellLeveragebuy_leveragebuyLeveragez[ setMarginMode() requires a leverage parameter or sell_leverage and buy_leverage parameters)rZ  rX  rY  r[  rF   )r  r  r)  r[  rY  )r  r  r;   rF   !privatePostV5AccountSetMarginModer?  r2   r  r  r  r|  rj  #privatePostV5PositionSwitchIsolated)ra  r<  r  r  r  r  rY  r  r~  rB  isUsdcSettledr  r)  rY  r[  rG  s                   rc  set_margin_modebybit.set_margin_mode*  s     !!!:>:Q:Q:S4S1/G3GZ'.
w&-
{*/
"477-v#vwwG "CCDKKPWD`aaHh e ~'2x(xyy[[(F"8,6M(!1J;.!3J&tww  2A  (A  B  B#Z! "&!G!GT[Hd!eeH E #223DfU 	( !I:- !I&tww1{'{||#"++FJ?##'#5#5fo~#^L"&"4"4V^]"[K#+0C/  ;X  1X  Y  Y"*&2#+'2!YYv/opF#+L"*K!YYvz:F $$Tl!*#.$0! "&!I!I$++V]Jf!ggK 	"4S  b  fF hsX   IIIIA6I%I&BI8I9DIIIIIIIc                   #    Uc  [        U R                  S-   5      eU R                  5       I Sh  vN   U R                  U5      nU R	                  U5      nUS   UUS.nXVS'   XVS'   US   (       a  SUS'   O(US	   (       a  S	US'   O[        U R                  S
-   5      eU R                  U R                  Xc5      5      I Sh  vN nU$  N N7f)a  
set the level of leverage for a market

https://bybit-exchange.github.io/docs/v5/position/leverage

:param float leverage: the rate of leverage
:param str symbol: unified market symbol
:param dict [params]: extra parameters specific to the exchange API endpoint
:param str [params.buyLeverage]: leverage for buy side
:param str [params.sellLeverage]: leverage for sell side
:returns dict: response from the exchange
Nz) setLeverage() requires a symbol argumentrF   )r  r[  rY  r[  rY  r  r  r  z5 setLeverage() only support linear and inverse market)r2   rF   r  r  r  r;    privatePostV5PositionSetLeverager?  )ra  rG  r  r  r  leverageStringrB  r~  s           rc  set_leveragebybit.set_leverage~  s      >#DGG.Y$YZZ!!!V$
 ..x8Tl)*

 "0"0("*GJI"+GJtww)``aa>>t{{7?[\\+ 	"( ]s"   /CCBCCCCrC  c                   #    U R                  5       I Sh  vN   SnUb  U R                  U5      nSnU(       a  SnOSnSU0nUc  SUS'   OUS   US'   Ub  US	   (       a  S	OS
US'   OSnU R                  SXC5      u  psXvS'   U R                  US5      nU R	                  U R                  Xc5      5      I Sh  vN nU$  N N7f)a7  
set hedged to True or False for a market

https://bybit-exchange.github.io/docs/v5/position/position-mode

:param bool hedged:
:param str symbol: used for unified account with inverse market
:param dict [params]: extra parameters specific to the exchange API endpoint
:returns dict: response from the exchange
Nr  r   moder  r  rF   r  r  r  r  r   r  )r  r  r  rj  privatePostV5PositionSwitchModer?  )	ra  rC  r  r  r  rg  rB  r  r~  s	            rc  set_position_modebybit.set_position_mode  s      !!![[(FDDD
 >$GFO &tGH.4X.>(IGJD../@&QLD"&J66*==dkk'>Z[[ C 	". \s"   CB?B!C8C9CCr   c                   #    U R                  5       I S h  vN   U R                  U5      nUS   (       a  SOSnU R                  USU5      nU R                  U R                  S5      n	U R                  X5      n
U
c  [        U R                  S-   U-   S-   5      eUS   U
US.nUb  X;S	'   U R                  US
5      nU R                  US
/5      nUb  XS'   Ub  XKS'   U R                  U R                  X5      5      I S h  vN nU R                  US0 5      nU R                  U5      nU R                  US5      nU R                  UUS S5      nU R                  XX45      $  GNL Nc7f)Nr  r  r  r1  z+ fetchOpenInterestHistory() cannot use the 
 timeframerF   r  intervalTimer  r  r  r  rM  rs  r  r  )r  r  r  rz  r  r3   rF   r  rj  publicGetV5MarketOpenInterestr?  r  r  parse_open_interests_history)ra  r  r  r  rM  r  r  r  r  r1  r  rB  r  r~  rs  rv  rF   s                    rc  'fetch_derivatives_open_interest_history-bybit.fetch_derivatives_open_interest_history  s}    !!!V$$X.(I##FJ@NN4<<=	##I9TWW'TTW``cooppTl$ 

 #(K !!&'26G9-!&I$G;;DKK<XYY0 (B733H=fh/!!"fdJ?00uLLc 	"* Zs#   E'E"C*E'E%A!E'%E'c                   #    U R                  5       I Sh  vN   U R                  U5      nUS   (       d  [        U R                  S-   5      eU R	                  USS5      nU R                  U R                  S5      nU R	                  XT5      nUc  [        U R                  S-   U-   S-   5      eUS	   (       a  S	OS
nU R	                  USU5      nUS   UUS.n	U R                  U R                  X5      5      I Sh  vN n
U R                  U
S0 5      nU R	                  US5      nU R                  XSS5      nU R                  U
5      nU R                  US   U5      $  GNI Ne7f)a  
Retrieves the open interest of a derivative trading pair

https://bybit-exchange.github.io/docs/v5/market/open-interest

:param str symbol: Unified CCXT market symbol
:param dict [params]: exchange specific parameters
:param str [params.interval]: 5m, 15m, 30m, 1h, 4h, 1d
:param str [params.category]: "linear" or "inverse"
:returns dict} an open interest structure{@link https://docs.ccxt.com/#/?id=open-interest-structure:
Nr  z3 fetchOpenInterest() supports contract markets onlyr  r   r1  z$ fetchOpenInterest() cannot use the rl  r  r  r  rF   rm  rs  r  r   )r  r  r3   rF   r  rz  r  ro  r?  r  r  parse_open_interest)ra  r  r  r  r  r1  r  r  r  rB  r~  rs  rF   rv  s                 rc  fetch_open_interestbybit.fetch_open_interest  sd     !!!V$j!TWW'\\]]$$VZ>	NN4<<=	##I9TWW'MMPYY\hhii$X.(I##FJ@Tl$ 

 ;;DKK<XYY0 (B7fh/!!"dJ?33H=''Q88Y 	"  Zs#   E$EC%E$<E"=A#E$"E$c                   #    US:X  a  [        U R                  S-   5      eU R                  5       I Sh  vN   U R                  US5      nU(       a5  U R	                  US5      nX%S'   U R                  SXXESSSS	5	      I Sh  vN $ U R                  U5      nUS
   (       d
  US   (       a  [        U R                  S-   U-   5      eSUS   0nUb  XHS'   U R                  XX4U5      I Sh  vN $  N No N7f)a  
Gets the total amount of unsettled contracts. In other words, the total number of contracts held in open positions

https://bybit-exchange.github.io/docs/v5/market/open-interest

:param str symbol: Unified market symbol
:param str timeframe: "5m", 15m, 30m, 1h, 4h, 1d
:param int [since]: Not used by Bybit
:param int [limit]: The number of open interest structures to return. Max 200, default 50
:param dict [params]: Exchange specific parameters
: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: An array of open interest structures
r   z5 fetchOpenInterestHistory cannot use the 1m timeframeNr  r  r   rx  ry  r  rU   rY   z; fetchOpenInterestHistory() symbol does not support market r  rF   rM  )r3   rF   r  r  rj  r]  r  rq  )	ra  r  r  r  rM  r  r  r  rB  s	            rc  fetch_open_interest_history!bybit.fetch_open_interest_history@  s#     TWW'^^__!!!>>&*5YYvz2F"+;99:TV\ej  uE  GO  QU  WZ  [  [  [V$&>VH-TWW'ddgmmnnfTl
 $GAA&UZcijjj 	"
 [ ks5   2C6C0AC6C2A(C6+C4,C62C64C6c           	          U R                  US5      nU R                  USS5      nUS   (       a  UOS nUS   (       a  UOS nU R                  US   UUUU R                  U5      US.U5      $ )Nr  open_interestopenInterestr  r  r  )r  openInterestAmountr{  r  r  r  )r  rb  safe_open_interestr`  )ra  rC  r  r  r|  r  values          rc  rt  bybit.parse_open_interest`  s     %%h<	))(O^T!'!1t &y 1t&&X&"(!&"Y/(
  	re  c                 6  #    U R                  5       I Sh  vN   U R                  U5      nSUS   0nU R                  U R                  XB5      5      I Sh  vN nU R	                  US5      nU R                  US0 5      nXgS'   U R                  Xs5      $  N~ N@7f)ah  
fetch the rate of interest to borrow a currency for margin trading

https://bybit-exchange.github.io/docs/zh-TW/v5/spot-margin-normal/interest-quota

:param str code: unified currency code
:param dict [params]: extra parameters specific to the exchange API endpoint
:returns dict: a `borrow rate structure <https://docs.ccxt.com/#/?id=borrow-rate-structure>`
Nr  rF   r  rs  r  )r  r  (privateGetV5SpotCrossMarginTradeLoanInfor?  r  rz  parse_borrow_rate)ra  r  r  r  rB  r~  r  rv  s           rc  fetch_cross_borrow_ratebybit.fetch_cross_borrow_rateu  s      !!!==&HTN
 FFt{{SZGcdd %%h7	~~h"5%[%%d55/ 	"
 es!   BB?BB?BBc                     U R                  US5      nU R                  USS5      nU R                  US5      nUb  SOSnU R                  XB5      U R                  USU5      UUU R	                  U5      US.$ )	Nr  r  r  hourlyBorrowRatei6 i \&r  )r  r  periodr  r  r  )r  r|  r	  r  r`  )ra  r  r  r  r  r  r  s          rc  r  bybit.parse_borrow_rate  s    $ %%dK8	''fjA
++D2DE-9//
E$$T>;KL"Y/
 	
re  c                 *  #    U R                  5       I Sh  vN   0 nU R                  U R                  Xe5      5      I Sh  vN nU R                  US0 5      nU R	                  US/ 5      n	U R                  U	S5      n
U R                  XX45      $  Nx NP7f)af  
fetch the interest owed by the user for borrowing currency for margin trading

https://bybit-exchange.github.io/docs/zh-TW/v5/spot-margin-normal/account-info

:param str code: unified currency code
:param str symbol: unified market symbol when fetch interest in isolated markets
:param number [since]: the earliest time in ms to fetch borrrow interest for
:param number [limit]: the maximum number of structures to retrieve
:param dict [params]: extra parameters specific to the exchange API endpoint
:returns dict[]: a list of `borrow interest structures <https://docs.ccxt.com/#/?id=borrow-interest-structure>`
Nrs  r3  )r  rV  r?  rz  r  parse_borrow_interestsfilter_by_currency_since_limit)ra  r  r  r  rM  r  rB  r~  rv  ru  rC  s              rc  fetch_borrow_interestbybit.fetch_borrow_interest  s      !!!EEdkkRYFbcc4 ~~h"5~~d$5r:..tT:2285PP? 	"cs"   BB)B BABBc                   #    U R                  5       I Sh  vN   U R                  U5      nSUS   0nUc  U R                  5       S-
  nX&S'   U R                  USS5      nU R	                  US/5      nUc  US-   nXvS'   U R                  U R                  Xd5      5      I Sh  vN nU R                  US5      n	U R                  U	S	/ 5      n
U R                  XX#5      $  N N=7f)
a  
retrieves a history of a currencies borrow interest rate at specific time slots

https://bybit-exchange.github.io/docs/v5/spot-margin-uta/historical-interest

:param str code: unified currency code
:param int [since]: timestamp for the earliest borrow rate
:param int [limit]: the maximum number of `borrow rate structures <https://docs.ccxt.com/#/?id=borrow-rate-structure>` to retrieve
:param dict [params]: extra parameters specific to the exchange API endpoint
:param int [params.until]: the latest time in ms to fetch entries for
:returns dict[]: an array of `borrow rate structures <https://docs.ccxt.com/#/?id=borrow-rate-structure>`
Nr  rF   l    H4 r  r  r  rs  rt  )
r  r  ro  r  rj  .privateGetV5SpotMarginTradeInterestRateHistoryr?  rz  r  parse_borrow_rate_history)ra  r  r  rM  r  r  rB  r  r~  rv  ru  s              rc  fetch_borrow_rate_historybybit.fetch_borrow_rate_history  s      !!!==&
 =%%'-7E$%%fgyA6G9-?m+G$	LLT[[Y`Mijj& ~~h1~~dFB/--d%GGE 	" ks"   C"CBC""C #<C" C"r  c           
          US U R                  U R                  US5      5      U R                  US5      S U R                  US5      SS S S.	$ )NrF  rC  rB  r+  )	r  r  r  rC  r  amountBorrowedr<  r  r  )r  r  r	  )ra  r  r  s      rc  parse_borrow_interestbybit.parse_borrow_interest  s[     //0@0@y0QR((z: "..tV<!

 
	
re  fromAccount	toAccountc           
        #    U R                  5       I Sh  vN   U R                  USU R                  5       5      nU R                  U R                  S0 5      nU R                  XsU5      nU R                  XtU5      n	U R                  U5      n
U R                  X5      nUUU	U
S   US.nU R                  U R                  X5      5      I Sh  vN nU R                  US5      nU R                  US0 5      nU R                  USS	/5      nU R                  U5      nU R                  U R                  X5      UU R                  U5      U R                  U5      UUUS
.5      $  GNL N7f)a$  
transfer currency internally between wallets on the same account

https://bybit-exchange.github.io/docs/v5/asset/create-inter-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.transferId]: UUID, which is unique across the platform
:returns dict: a `transfer structure <https://docs.ccxt.com/#/?id=transfer-structure>`
N
transferIdr+  rF   )r  fromAccountTypetoAccountTyper  r  r  rs  r  retMsg)r  r  r  r  r  r.  )r  r  uuidrz  r  r  currency_to_precision'privatePostV5AssetTransferInterTransferr?  r  r  parse_transfer_statusparse_transferr`  r  )ra  r  r  r  r  r  r  r]  fromIdtoIdr  amountToPrecisionrB  r~  r  r   	statusRawr.  s                     rc  r   bybit.transfer-  si     !!!%%flDIIKH
~~dll4DbI!!,[IC==& 66tD$%!TN'
 EEdkkRYFbcc %%h7	>>(Hb9&&x)X1FG	++I6{{4..xB"Y/''(9:&"E
  	= 	" ds#   E'E"B6E'E%BE'%E'c                   #    U R                  5       I Sh  vN   SnU R                  USS5      u  pTU(       a  U R                  SXX4SSSS5	      I Sh  vN $ Sn0 nUb  U R                  U5      nUS   US	'   Ub  X'S
'   Ub  X7S'   U R	                  SXt5      u  ptU R                  U R                  Xt5      5      I Sh  vN nU R                  U5      n	U R                  XX#5      $  N N N+7f)a.  
fetch a history of internal transfers made on an account

https://bybit-exchange.github.io/docs/v5/asset/inter-transfer-list

: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 transfer 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
: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 `transfer structures <https://docs.ccxt.com/#/?id=transfer-structure>`
NFr   r  rx  ry  r   rF   r  r  rM  r  )	r  r  r]  r  r  /privateGetV5AssetTransferQueryInterTransferListr?  r  parse_transfers)
ra  r  r  rM  r  r  r  rB  r~  rv  s
             rc  fetch_transfersbybit.fetch_transfersb  s&     !!!88AQS]^99:JDY^hx  {C  EI  KM  N  N  N))$/H&tnGFO#(K $G229gNMMdkkZaNjkk. 33H=##DEAAO 	" N lr  c                 *  #    U R                  5       I Sh  vN   U R                  U5      nUS   U R                  X5      S.nU R                  U R	                  XS5      5      I Sh  vN nU R                  US0 5      nU R                  Xt5      $  Nx N*7f)ao  
create a loan to borrow margin

https://bybit-exchange.github.io/docs/v5/account/borrow

:param str code: unified currency code of the currency to borrow
:param float amount: the amount to borrow
:param dict [params]: extra parameters specific to the exchange API endpoint
:returns dict: a `margin loan structure <https://docs.ccxt.com/#/?id=margin-loan-structure>`
NrF   r  r  rs  )r  r  r  privatePostV5AccountBorrowr?  rz  parse_margin_loan)ra  r  r  r  r  rB  r~  rs  s           rc  borrow_cross_marginbybit.borrow_cross_margin  s      !!!==&TN00>
 88W9UVV (B7%%f77) 	" Ws"   BBAB&B')BBc                 R  #    U R                  5       I Sh  vN   U R                  U5      nUS   U R                  U5      S.nU R                  U R	                  XS5      5      I Sh  vN nU R                  US0 5      nU R                  Xt5      nU R	                  USU05      $  N N>7f)a{  
repay borrowed margin and interest

https://bybit-exchange.github.io/docs/v5/account/no-convert-repay

:param str code: unified currency code of the currency to repay
:param float amount: the amount to repay
:param dict [params]: extra parameters specific to the exchange API endpoint
:returns dict: a `margin loan structure <https://docs.ccxt.com/#/?id=margin-loan-structure>`
NrF   r  rs  r  )r  r  r  "privatePostV5AccountNoConvertRepayr?  rz  r  )	ra  r  r  r  r  rB  r~  rs  r  s	            rc  repay_cross_marginbybit.repay_cross_margin  s      !!!==&TN++F3
 @@WA]^^ (B7,,V>{{;f)
  	) 	" _s"   B'B#AB'&B%'=B'%B'c                 x    U R                  US5      nS U R                  X25      U R                  US5      S S S US.$ )Nr  r  )rF   r  r  r  r  r  r  )r  r  )ra  r  r  r  s       rc  r  bybit.parse_margin_loan  sM     %%dF3
//
E&&tX6
 	
re  c                 2    SSSS.nU R                  X!U5      $ )Nr  )r  OKSUCCESSry  rz  s      rc  r  bybit.parse_transfer_status  s'    

 &99re  r   c                    U R                  US5      nU R                  US5      nU R                  US5      nU R                  US5      nU R                  U R                  S0 5      nU R                  XuU5      nU R                  XvU5      n	UU R                  US5      UU R	                  U5      U R                  X25      U R                  US5      UU	U R                  U R                  US5      5      S	.	$ )
Nr  r  r  r  r,  r  r  r.  )	r  rF   r  r  r  r  r  r  r.  )r  r  rz  r  r`  r  r	  r  )
ra  r   r  r  r  fromAccountIdtoAccountId
accountIdsr  r  s
             rc  r  bybit.parse_transfer  s    ( %%h7
%%h<	((3DE&&xA^^DLL."E
&&z-P$$ZkJ	""8\:"Y///
E&&x:&"001A1A(H1UV

 
	
re  c                 j  #    U R                  5       I S h  vN   U R                  U5      nSUS   0nUS   (       a  SUS'   OUS   (       a  SUS'   U R                  U R                  XB5      5      I S h  vN nU R	                  US5      nU R                  US5      nU R                  Xs5      $  N N;7f)Nr  rF   r  r  r  rs  rt  )r  r  publicGetV5MarketRiskLimitr?  rz  r  parse_market_leverage_tiers)ra  r  r  r  rB  r~  rs  tierss           rc  'fetch_derivatives_market_leverage_tiers-bybit.fetch_derivatives_market_leverage_tiers&  s     !!!V$fTl
 ("*GJI"+GJ88W9UVV0 (3vv.//>>G 	" Ws"   B3B/AB35B16:B31B3c                   #    U R                  5       I Sh  vN   0 nSnU R                  U5      nUS   (       d
  US   (       a  [        U R                  S-   U-   5      eUS   US'   U R	                  X5      I Sh  vN $  Ni N7f)a  
retrieve information on the maximum leverage, and maintenance margin for trades of varying trade sizes for a single market

https://bybit-exchange.github.io/docs/v5/market/risk-limit

:param str symbol: unified market symbol
:param dict [params]: extra parameters specific to the exchange API endpoint
:returns dict: a `leverage tiers structure <https://docs.ccxt.com/#/?id=leverage-tiers-structure>`
NrU   rY   z; fetchMarketLeverageTiers() symbol does not support market rF   r  )r  r  r3   rF   r  )ra  r  r  rB  r  s        rc  fetch_market_leverage_tiers!bybit.fetch_market_leverage_tiersL  s      !!!V$&>VH-TWW'ddgmmnn"4LAA&QQQ 	" Rs"   BB A$B;B<BBr   c                     U R                  US5      nUb  US   OSnU R                  X2S U5      nUUU R                  US5      U R                  US5      S S S.$ )Nr  r  r  makerFeeRatetakerFeeRate)r  r  rZ  rY  rX  rW  r  r  r	  )ra  r   r  r  r  r  s         rc  parse_trading_feebybit.parse_trading_fee_  sp     ##C2)/);fVn*!!(D+F%%c>:%%c>:
 	
re  c                   #    U R                  5       I Sh  vN   U R                  U5      nSUS   0nSnU R                  SX25      u  pRXTS'   U R                  U R	                  XB5      5      I Sh  vN nU R                  US0 5      nU R                  US/ 5      nU R                  US0 5      n	U R                  X5      $  N NP7f)	a$  
fetch the trading fees for a market

https://bybit-exchange.github.io/docs/v5/account/fee-rate

:param str symbol: unified market symbol
:param dict [params]: extra parameters specific to the exchange API endpoint
:returns dict: a `fee structure <https://docs.ccxt.com/#/?id=fee-structure>`
Nr  rF   r   r  rs  rt  r   )r  r  r  privateGetV5AccountFeeRater?  rz  r  r  )
ra  r  r  r  rB  r  r~  rs  r   r  s
             rc  fetch_trading_feebybit.fetch_trading_fees  s      !!!V$fTl
 ../@&Q&
88W9UVV$ (B7~~ffb1tQ+%%e44; 	" Ws#   CB?AC0C1ACCc                   #    U R                  5       I Sh  vN   SnU R                  USSS5      u  p!US:X  a  [        U R                  S-   5      eU R	                  U5      I Sh  vN nU R                  US0 5      nU R                  US/ 5      n0 n[        S	[        U5      5       H  nU R                  XF   5      nUS
   nXuU'   M!     U$  N Nh7f)an  
fetch the trading fees for multiple markets

https://bybit-exchange.github.io/docs/v5/account/fee-rate

:param dict [params]: extra parameters specific to the exchange API endpoint
:param str [params.type]: market type, ['swap', 'option', 'spot']
:returns dict: a dictionary of `fee structures <https://docs.ccxt.com/#/?id=fee-structure>` indexed by market symbols
Nr   r  rX   rU   z4 fetchTradingFees() is not supported for spot marketrs  rt  r   r  )
r  r  r;   rF   r  rz  r  r  r}  r  )	ra  r  r  r~  r   rs  r  r   r  s	            rc  fetch_trading_feesbybit.fetch_trading_fees  s      !!!44V=OQWYab6>tww)__``88@@$ ~~h"5~~dFB/q#d)$A((1C]F 6N % = 	"
 As#   CCAC%C&A'CCc                    U R                  US/ 5      n[        U5      nUS S S.S S S.0 S.nUS:w  a  [        SU5       H  nX6   nU R                  US5      nU R                  US5      n	U R	                  X5      n
S S S.U R                  US5      SS.S	.US
   U
'   US:X  d  Me  U R                  US5      US   S'   SUS   S'   M     U$ )Nr  )r   rX  )r  r   r[  r-  r   r  r  r  F)r[  r   r-  r   r   r   rX  )r  r}  r  r  r  r	  )ra  r   r  r  chainsLengthrs  r  r  r  currencyCoder  s              rc  parse_deposit_withdraw_fee bybit.parse_deposit_withdraw_fee  s   * Xr26{"
 " 
 11l+	 ,,UG<	#//&A"55iN'+4@(,(8(8(N^c d3z";/  1$040@0@0VF:&u-7<F:&|4 , re  r  c                   #    U R                  5         U R                  5       I Sh  vN   U R                  U5      I Sh  vN nU R                  US0 5      nU R	                  US/ 5      nU R                  XQS5      $  NU N>7f)a2  
fetch deposit and withdraw fees

https://bybit-exchange.github.io/docs/v5/asset/coin-info

:param str[] 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>`
Nrs  ru  r  )r  r  r  rz  r  parse_deposit_withdraw_fees)ra  r  r  r~  rv  ru  s         rc  fetch_deposit_withdraw_fees!bybit.fetch_deposit_withdraw_fees  sz      	'')!!!<<VDD> ~~h"5~~dFB///VDDE 	"Ds    $B A<B A> =B >B c                   #    U R                  5       I Sh  vN   0 nSnUb  U R                  U5      nUS   US'   SnU R                  SXd5      u  ptUS:X  a  [        U R                  S-   5      eXuS'   Ub  X5S'   U R                  U R                  XT5      5      I Sh  vN nU R                  US	0 5      n	U R                  U	S
/ 5      n
U R                  X5      nU R                  US5      nU R                  XS   X#5      $  N Nd7f)a  
fetches historical settlement records

https://bybit-exchange.github.io/docs/v5/market/delivery-price

:param str symbol: unified market symbol of the settlement history
:param int [since]: timestamp in ms
:param int [limit]: number of records
:param dict [params]: exchange specific params
:param str [params.type]: market type, ['swap', 'option', 'spot']
:param str [params.subType]: market subType, ['linear', 'inverse']
:returns dict[]: a list of [settlement history objects]
NrF   r  r   rU   z: fetchSettlementHistory() is not supported for spot marketr  rM  rs  rt  r  )r  r  r  r;   rF   publicGetV5MarketDeliveryPricer?  rz  r  parse_settlementsr  r  ra  r  r  rM  r  rB  r  r  r~  rs  rv  settlementsr  s                rc  fetch_settlement_historybybit.fetch_settlement_history'  s     !!![[(F &tGH**+CVT6>tww)eeff"
$G<<T[[=YZZ( (B7~~ffb1,,T:k;7009I5XXK 	" [#   DD BDDA#DDc                   #    U R                  5       I Sh  vN   0 nSnUb  U R                  U5      nUS   US'   SnU R                  SXd5      u  ptUS:X  a  [        U R                  S-   5      eXuS'   Ub  X5S'   U R                  U R                  XT5      5      I Sh  vN nU R                  US	0 5      n	U R                  U	S
/ 5      n
U R                  X5      nU R                  US5      nU R                  XS   X#5      $  N Nd7f)a  
fetches historical settlement records of the user

https://bybit-exchange.github.io/docs/v5/asset/delivery

:param str symbol: unified market symbol of the settlement history
:param int [since]: timestamp in ms
:param int [limit]: number of records
:param dict [params]: exchange specific params
:param str [params.type]: market type, ['swap', 'option', 'spot']
:param str [params.subType]: market subType, ['linear', 'inverse']
:returns dict[]: a list of [settlement history objects]
NrF   r  r   rU   z< fetchMySettlementHistory() is not supported for spot marketr  rM  rs  rt  r  )r  r  r  r;   rF   privateGetV5AssetDeliveryRecordr?  rz  r  r  r  r  r  s                rc  fetch_my_settlement_history!bybit.fetch_my_settlement_history\  s     !!![[(F &tGH**+EvV6>tww)gghh"
$G==dkk'>Z[[2 (B7~~ffb1,,T:k;7009I5XXU 	" \r  c                     U R                  US5      nU R                  US5      nUU R                  XB5      U R                  US5      UU R	                  U5      S.$ )NrS  r  deliveryPrice)r  r  r7  r  r  )r  r  r  r	  r`  )ra  
settlementr  r  r  s        rc  parse_settlementbybit.parse_settlement  sb    . %%j.A	##J9&&x8%%j/B"Y/
 	
re  c                     / n[        S[        U5      5       H&  nUR                  U R                  X   U5      5        M(     U$ )Nr   )r  r}  r  r  )ra  r  r  rs  r  s        rc  r  bybit.parse_settlements  s?    6 q#k*+AMM$//GH ,re  c                   #    U R                  5       I Sh  vN   U R                  U5      nSUS   S.nU R                  U R                  XB5      5      I Sh  vN nU R	                  US/ 5      nU R                  U5      $  Ni N*7f)a  
fetch the historical volatility of an option market based on an underlying asset

https://bybit-exchange.github.io/docs/v5/market/iv

:param str code: unified currency code
:param dict [params]: extra parameters specific to the exchange API endpoint
:param int [params.period]: the period in days to fetch the volatility for: 7,14,21,30,60,90,180,270
:returns dict[]: a list of `volatility history objects <https://docs.ccxt.com/#/?id=volatility-structure>`
NrY   rF   r  r  rs  )r  r  %publicGetV5MarketHistoricalVolatilityr?  r  parse_volatility_history)ra  r  r  r  rB  r~  
volatilitys          rc  fetch_volatility_historybybit.fetch_volatility_history  s      !!!==&  
 CCDKKPWD`aa ^^Hh;
,,Z88- 	" bs"   BB A BB)BBc           
          / n[        S[        U5      5       HN  nX   nU R                  US5      nUR                  UUU R	                  U5      U R                  US5      S.5        MP     U$ )Nr   r  r  )r  r  r  r  )r  r}  r  r  r`  r	  )ra  r  rs  r  r  r  s         rc  r  bybit.parse_volatility_history  sq     q#j/*AME))%8IMM"& LL3"..ug>	  + re  c                   #    U R                  5       I Sh  vN   U R                  U5      nUS   SS.nU R                  U R                  XB5      5      I Sh  vN nU R	                  US5      nU R                  US0 5      nU R                  US/ 5      nU R                  US   U5      n	U R                  U	UU R                  U5      S	.5      $  N Nw7f)
a  
fetches an option contracts greeks, financial metrics used to measure the factors that affect the price of an options contract

https://bybit-exchange.github.io/docs/api-explorer/v5/market/tickers

:param str symbol: unified symbol of the market to fetch greeks for
:param dict [params]: extra parameters specific to the exchange API endpoint
:returns dict: a `greeks structure <https://docs.ccxt.com/#/?id=greeks-structure>`
NrF   rY   )r  r  r  rs  rt  r   )r  r  )	r  r  r  r?  r  rz  r  parse_greeksr`  )
ra  r  r  r  rB  r~  r  rs  rv  greekss
             rc  fetch_greeksbybit.fetch_greeks  s      !!!V$Tl 
 66t{{77STTR %%h7	(B7~~ffb1""47F3{{6"Y/$
  	g 	" Us#   CCA CCA6CCc                   #    U R                  5       I Sh  vN   U R                  USSSS5      nU R                  USS5      nSUS.nSnUb-  [        U5      nUS:X  a  U R	                  US   5      nUS	   US
'   U R                  U R                  XB5      5      I Sh  vN nU R                  US0 5      nU R                  US/ 5      n	U R                  X5      $  N N=7f)a&  
fetches all option contracts greeks, financial metrics used to measure the factors that affect the price of an options contract

https://bybit-exchange.github.io/docs/api-explorer/v5/market/tickers

:param str[] [symbols]: unified symbols of the markets to fetch greeks for, all markets are returned if not assigned
:param dict [params]: extra parameters specific to the exchange API endpoint
:param str [params.baseCoin]: the baseCoin of the symbol, default is BTC
:returns dict: a `greeks structure <https://docs.ccxt.com/#/?id=greeks-structure>`
NTr  r  rY   r  r   r   rF   r  rs  rt  )
r  r  r  r}  r  r  r?  rz  r  parse_all_greeks)
ra  r  r  r  rB  r  r  r~  rs  rv  s
             rc  fetch_all_greeksbybit.fetch_all_greeksP  s      !!!%%gtT4F##FJ>  
 LM!WQZ0$*4L!66t{{77STTR (B7~~ffb1$$T33q 	" Us"   CCBCC<CCr   c                 |   U R                  US5      nU R                  X25      n0 SU_SS _SS _SU R                  US5      _SU R                  US5      _SU R                  US5      _SU R                  US5      _SS _S	U R                  US
5      _SU R                  US5      _SU R                  US5      _SU R                  US5      _SU R                  US5      _SU R                  US5      _SU R                  US5      _SU R                  US5      _SU R                  US5      _U R                  US5      US.E$ )Nr  r  r  deltagammathetavegarhor  r  r  r  bidImpliedVolatilitybid1IvaskImpliedVolatilityask1IvmarkImpliedVolatilitymarkIvbidPricer  askPricer  r  r|  underlyingPrice)r  r  r  )ra  r   r  r  r  s        rc  r  bybit.parse_greeks  s   < ##FH5!!(3
f

 
 T%%fg6	

 T%%fg6
 T%%fg6
 D$$VV4
 4
 t''
;
 t''
;
 #D$4$4VX$F
 #D$4$4VX$F
 $T%5%5fh%G
 ((=
 ((=
  ))&+>!
" ))&+>#
$  $//8IJ'
 	
re  c                   #    U R                  5       I Sh  vN   SnU R                  USS5      u  pTU(       a  U R                  SXX4SSSS5	      I Sh  vN $ SS	0nSnUb  U R                  U5      nUS
   US'   SnU R	                  SXt5      u  pXS'   Ub  X6S'   Ub  X&S'   U R                  SXd5      u  pdU R                  U R                  Xd5      5      I Sh  vN n	U R                  U	5      n
U R                  XX#5      $  N N N+7f)aa  
retrieves the users liquidated positions

https://bybit-exchange.github.io/docs/api-explorer/v5/position/execution

: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 exchange API endpoint
:param str [params.type]: market type, ['swap', 'option', 'spot']
:param str [params.subType]: market subType, ['linear', 'inverse']
:param boolean [params.paginate]: default False, when True will automatically paginate by calling self endpoint multiple times. See in the docs all the [available parameters](https://github.com/ccxt/ccxt/wiki/Manual#pagination-params)
:returns dict: an array of `liquidation structures <https://docs.ccxt.com/#/?id=liquidation-structure>`
NFr   r  rx  ry  rK  r}  	BustTraderF   r  r  rM  r  r  )
r  r  r]  r  r  r  r~  r?  r  parse_liquidations)ra  r  r  rM  r  r  rB  r  r  r~  liquidationss              rc  fetch_my_liquidationsbybit.fetch_my_liquidations  sQ     !!!88AVXbc99:OQW`eo  BJ  LP  RU  V  V  V
 [[(F &tGH**+@&Q"
$G#(K 229gN77G8TUUR ;;HE&&|UJJ} 	" V  Vr  c                    U R                  US5      nU R                  US5      nU R                  US5      nU R                  US5      nU R                  US5      n[        R                  " XV5      n[        R                  " X5      n	U R	                  UU R                  X2S S5      U R                  U5      U R                  U5      U R                  U5      U R                  U5      U R                  U	5      UU R                  U5      S.	5      $ )Nr  r  r  r  r   r  )	r  r  r9  r  r7  	baseValue
quoteValuer  r  )r  r  r@   r  safe_liquidationr  r  r`  )
ra  liquidationr  r  r  contractsStringcontractSizeStringr  baseValueStringquoteValueStrings
             rc  parse_liquidationbybit.parse_liquidation  s   : ##K:%%k:>	**;	B!--fnE&&{K@!,,_Q"--oK$$&&xzJ**?; --.@A&&{3**?;++,<="Y/
&
 
 
	re  c                 <  #    U R                  5       I S h  vN   S nUb  U R                  U5      nSnU R                  USS5      u  pBU(       a!  U R                  SUS S USSS S5	      I S h  vN $ S nU R	                  SX2S5      u  pRSU0nU R                  U R                  Xb5      5      I S h  vN nU R                  U5      nU R                  US	5      n	[        U5      n
U
S
-
  nU R                  X5      nU R                  U	S5      nSU0US'   XU'   U$  N N Nk7f)NFgetLeverageTiersPaginatedr  rx  ry  rK  r  r  r   r   r  )r  r  r  r]  r  r  r?  r  rz  r}  r  )ra  r  r  r  r  r  rB  r~  rs  r  r8  	lastIndexr3  cursorValues                 rc  get_leverage_tiers_paginated"bybit.get_leverage_tiers_paginatedJ  sb    !!![[(F88A\^hi99:UW]_ceikq  tD  FN  PT  VY  Z  Z  Z99:UW]gop
 88W9UVV55h?vq)FAI	~~f0&&u.>?k
V !y1 	" Z Ws6   DDAD+D,AD.D/A(DDDc                 d  #    U R                  5       I Sh  vN   SnSnUb;  U R                  US   5      nUS   (       a  [        U R                  S-   5      eUS   nU R	                  X@R                  SSS.U5      5      I Sh  vN nU R                  U5      nU R                  XQS5      $  N N)7f)	a  
retrieve information on the maximum leverage, for different trade sizes

https://bybit-exchange.github.io/docs/v5/market/risk-limit

:param str[] [symbols]: a list of unified market symbols
:param dict [params]: extra parameters specific to the exchange API endpoint
:param str [params.subType]: market subType, ['linear', 'inverse'], default is 'linear'
: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 dictionary of `leverage tiers structures <https://docs.ccxt.com/#/?id=leverage-tiers-structure>`, indexed by market symbols
Nr   rU   z6 fetchLeverageTiers() is not supported for spot marketr  Tr   )r  paginationCalls)r  r  r;   rF   r,  r?  r  parse_leverage_tiers)ra  r  r  r  r  rv  s         rc  fetch_leverage_tiersbybit.fetch_leverage_tierse  s      !!![[,Ff~"477-e#effH%F66v{{X\qsKtv|?}~~%%g.((AA 	" s"   B0B,A-B0B.(B0.B0c                    0 nU R                  U5      nU R                  XUS5      nU R                  Xc5      n[        UR	                  5       5      n[        S[        U5      5       H  n	X   n
Xz   n[        S[        U5      5       H  nU R                  X   S5      nXU   S'   M      U R                  U
S S S5      nUS   nU R                  U R                  US5      U5      XO'   M     U$ )NFr   rF   r  r  )
market_idsfilter_by_arraygroup_byrt  r  r  r}  r  r  r  r  )ra  r~  r  marketIdKeyr  	marketIdsfilteredResultsgroupedr  r  r  r  r  rF   r  r  s                   rc  r0  bybit.parse_leverage_tiers}  s     OOG,	..xiQVW--=GLLN#q#d)$AwH%E1c%j)&&ux6!#a * %%hdJGFH%F <<T\\%QU=VX^_EM % re  c                    / n[        S[        U5      5       H  nX   nU R                  US5      nU R                  U5      nU R	                  S5      nUS:w  a  U R                  XS-
     S5      nUR                  U R                  US5      U R                  Xb5      US   UU R                  US5      U R                  US5      U R                  US	5      US
.5        M     U$ )Nr   r  r  r   riskLimitValuerF   r  r3  rY  )tierr  r  minNotionalmaxNotionalmaintenanceMarginRaterY  r  )	r  r}  r  r  r  r	  r  r  r  )ra  r  r  r  r  r>  r  r?  s           rc  r  !bybit.parse_market_leverage_tiers  s     q#d)$A7D''h7H%%h/F++C0KAv"..tE{<LMLL))$5**8<"8,*#//6FG)-)9)9$@S)T#//mD	 	 %" re  c                 4  #    U R                  5       I Sh  vN   SnU R                  USS5      u  pTU(       a  U R                  SXX4SSSS5	      I Sh  vN $ SS	0nSnUb  U R                  U5      nUS
   US'   SnU R	                  SXt5      u  pXS'   Ub  US
   US'   Ub  X&S'   Ub  X6S'   OSUS'   U R                  SXd5      u  pdU R                  U R                  Xd5      5      I Sh  vN n	U R                  U	5      n
U R                  XX#5      $  N N N+7f)a  
fetch the history of funding payments paid and received on self account

https://bybit-exchange.github.io/docs/api-explorer/v5/position/execution

:param str [symbol]: unified market symbol
:param int [since]: the earliest time in ms to fetch funding history for
:param int [limit]: the maximum number of funding history structures to retrieve
:param dict [params]: extra parameters specific to the exchange API endpoint
:param 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 `funding history structure <https://docs.ccxt.com/#/?id=funding-history-structure>`
NFr   r  rx  ry  rK  r}  FundingrF   r  r  r  r  r  )
r  r  r]  r  r  r  r~  r?  r  parse_incomes)ra  r  r  rM  r  r  rB  r  r  r~  fundingss              rc  fetch_funding_historybybit.fetch_funding_history  si     !!!88AVXbc99:OQW`eo  BJ  LP  RU  V  V  V	
 [[(F &tGH**+@&Q"
 &tGH#(K #FO!GFO229gN77G8TUU77A!!(EAA5 	" V( Vs4   DD<DDBD*D+(DDDc                 H   U R                  US5      nU R                  X2S S5      nSnUS   (       a  US   nU R                  US5      nUU R                  X2SS5      UUU R	                  U5      U R                  US	5      U R                  US
5      U R                  US5      S.$ )Nr  r  r  r  r  r  r  rW   r  r  r  )r  r  r  r  r  rF   r  r  )r  r  r  r  r`  r	  )ra  incomer  r  r  r  s         rc  parse_incomebybit.parse_income  s    F ##FH5!!(D*E)'?D%%fj9	&&xfE"Y/""684&&vy9$$VY7	
 		
re  c                 \  #    U R                  5       I Sh  vN   U R                  U5      nSUS   S.nU R                  U R                  XB5      5      I Sh  vN nU R	                  US0 5      nU R                  US/ 5      nU R	                  US0 5      nU R                  USU5      $  N NR7f)aO  
fetches option data that is commonly found in an option chain

https://bybit-exchange.github.io/docs/v5/market/tickers

:param str symbol: unified market symbol
:param dict [params]: extra parameters specific to the exchange API endpoint
:returns dict: an `option chain structure <https://docs.ccxt.com/#/?id=option-chain-structure>`
NrY   rF   )r  r  rs  rt  r   )r  r  r  r?  rz  r  parse_option)	ra  r  r  r  rB  r~  rs  r  r  s	            rc  fetch_optionbybit.fetch_option   s      !!!V$ Tl
 66t{{77STTR (B7^^FFB7
z1b1  f55e 	" Us#   B,B(A B,B*AB,*B,c                 6  #    U R                  5       I Sh  vN   U R                  U5      nSUS   S.nU R                  U R                  XB5      5      I Sh  vN nU R	                  US0 5      nU R                  US/ 5      nU R                  USS5      $  N~ N?7f)a{  
fetches data for an underlying asset that is commonly found in an option chain

https://bybit-exchange.github.io/docs/v5/market/tickers

:param str code: base currency to fetch an option chain for
:param dict [params]: extra parameters specific to the exchange API endpoint
:returns dict: a list of `option chain structures <https://docs.ccxt.com/#/?id=option-chain-structure>`
NrY   rF   r  rs  rt  r  )r  r  r  r?  rz  r  parse_option_chain)ra  r  r  r  rB  r~  rs  r  s           rc  fetch_option_chainbybit.fetch_option_chainX   s      !!!==&  
 66t{{77STTR (B7^^FFB7
&&z4BBc 	" Us"   BBA BB>BBr  c                    U R                  US5      nU R                  XC5      n0 SU_SS _SUS   _SS _SS _SU R                  US5      _SU R                  US5      _S	U R                  US
5      _SU R                  US5      _SS _SU R                  US5      _SU R                  US5      _SU R                  US5      _SU R                  US5      _SS _SU R                  US5      _SS _$ )Nr  r  r  r  r  impliedVolatilityr  r|  r  r  r  r  midPricer  r|  r  r  	change24hrX  r  totalVolumer  )r  r  r	  )ra  r  r  r  r  s        rc  rN  bybit.parse_option   ss   < ##E84!!(3
E

 fX&
 	

 
  !1!1%!B
 D,,UNC
 ((<
 ((<
 
 ))%=
 ))%=
 t//7HI
 d&&uk:
 $
  $**5-@!
" 4#
 	
re  c                 F  #    U R                  5       I Sh  vN   SnSnSnUb%  [        U5      nUS:  a  U R                  US   5      nU R                  US5      nU R	                  SXTS5      u  pdU R                  US5      nSU0n	Ub  US:X  a  US   U	S	'   Ub  X)S
'   Ub  X9S'   Ub  XS'   U R                  U R                  X5      5      I Sh  vN n
U R                  U
S5      nU R                  US5      nU R                  XU5      nU R                  XU5      $  GN NO7f)a  
fetches historical positions

https://bybit-exchange.github.io/docs/v5/position/close-pnl

:param str[] symbols: a list of unified market symbols
:param int [since]: timestamp in ms of the earliest position to fetch, params["until"] - since <= 7 days
:param int [limit]: the maximum amount of records to fetch, default=50, 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, params["until"] - since <= 7 days
:param str [params.subType]: 'linear' or 'inverse'
:returns dict[]: a list of `position structures <https://docs.ccxt.com/#/?id=position-structure>`
Nr   r  r   r  r  r   rF   r  r  rM  r  rs  rt  )r  r}  r  r  r  rj  privateGetV5PositionClosedPnlr?  rz  r  parse_positionsfilter_by_since_limit)ra  r  r  rM  r  r  r  r  r  rB  r~  rs  rawPositionsr  s                 rc  fetch_positions_historybybit.fetch_positions_history   sO     !!!LMq WQZ0!!&'299:QSYckl67+
 mq&8 &tGH#(K $G!&I;;DKK<XYYD (3~~ff5((G	)))EBBw 	", Zs#   D!DB8D!DAD!D!c                 V  #    U R                  5       I Sh  vN   SnU R                  5       I Sh  vN u  p4U=(       d    UnU(       a  SOSnU R                  USSU5      u  p!SU0nU R                  U R	                  Xq5      5      I Sh  vN n0 n	U R                  US0 5      n
U R                  U
S/ 5      n[        S[        U5      5       H  nX   nU R                  US	5      nU R                  US
5      nU R                  US5      nU=(       d    UnU R                  U5      nUUUSU R                  US5      U R                  US5      U(       + SU R                  US5      SSU R                  US5      U R                  US5      S.SSS.SSS.S.SS.U	U'   M     U	$  GN GNs GN7f)a  
fetches all available currencies that can be converted

https://bybit-exchange.github.io/docs/v5/asset/convert/convert-coin-list

:param dict [params]: extra parameters specific to the exchange API endpoint
:param str [params.accountType]: eb_convert_uta, eb_convert_spot, eb_convert_funding, eb_convert_inverse, or eb_convert_contract
:returns dict: an associative dictionary of currencies
Neb_convert_utaeb_convert_spotr~   r9  rs  rL  r   r  disableFrom	disableTocoinTypefullNamer4  singleFromMinLimitsingleFromMaxLimitr  r  )r  rF   r  r-  r  rG   r  r[  r   r   r  r  r=  )r  r  r  &privateGetV5AssetExchangeQueryCoinListr?  rz  r  r  r}  r  r  r  r	  )ra  r  r9  r  r  rY  accountTypeDefaultrB  r~  rs  rv  rL  r  r  rF   re  rf  inactiver  s                      rc  fetch_convert_currenciesbybit.fetch_convert_currencies!  s     !!!:>:Q:Q:S4S1/G3G1A-GX";;FD\^km  A;
 DDT[[QXEabbD ~~h"5tWb1q#e*%AHE!!%0B..>Kuk:I#0yH**2.D ((
;((
;&, ,,UI>!  $//7KL#//7KL
  $#!
  $#   5F4L &F c 	"4S cs3   F)F F)F#AF)
F&DF)#F)&F)fromCodetoCodec                 .  #    U R                  5       I Sh  vN   SnU R                  5       I Sh  vN u  pgU=(       d    UnU(       a  SOSn	U R                  USSU	5      u  pTUUU R                  U5      UUS.n
U R	                  U R                  X5      5      I Sh  vN nU R                  US0 5      nU R                  USU5      nU R                  U5      nU R                  US	U5      nU R                  U5      nU R                  XU5      $  N N Nu7f)
a  
fetch a quote for converting from one currency to another

https://bybit-exchange.github.io/docs/v5/asset/convert/apply-quote

: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.accountType]: eb_convert_uta, eb_convert_spot, eb_convert_funding, eb_convert_inverse, or eb_convert_contract
:returns dict: a `conversion structure <https://docs.ccxt.com/#/?id=conversion-structure>`
Nrc  rd  r   r9  )fromCointoCoinrequestAmountrequestCoinr9  rs  rs  rt  )
r  r  r  r  $privatePostV5AssetExchangeQuoteApplyr?  rz  r  r  parse_conversion)ra  rp  rq  r  r  r9  r  r  rY  rl  rB  r~  rv  fromCurrencyIdfromCurrencytoCurrencyId
toCurrencys                    rc  fetch_convert_quotebybit.fetch_convert_quoteq!  s      !!!:>:Q:Q:S4S1/G3G1A-GX";;FDWYfhz{ !226:#&
 BB4;;wC_``* ~~h"5))$
HE}}^4''h?]]<0
$$TDDO 	"4S as3   DDDDA,DDA2DDDc                    #    U R                  5       I Sh  vN   SU0nU R                  U R                  Xe5      5      I Sh  vN nU R                  US0 5      nU R	                  U5      $  NT N*7f)a+  
convert from one currency to another

https://bybit-exchange.github.io/docs/v5/asset/convert/confirm-quote

:param str id: the id of the trade that you want to make
:param str fromCode: the currency that you want to sell and convert from
:param str toCode: the currency that you want to buy and convert into
:param float amount: how much you want to trade in units of the from currency
:param dict [params]: extra parameters specific to the exchange API endpoint
:returns dict: a `conversion structure <https://docs.ccxt.com/#/?id=conversion-structure>`
N	quoteTxIdrs  )r  (privatePostV5AssetExchangeConvertExecuter?  rz  rx  )	ra  rF   rp  rq  r  r  rB  r~  rv  s	            rc  create_convert_tradebybit.create_convert_trade!  st      !!!
 FFt{{SZGcdd ~~h"5$$T**% 	" es!   A/A++A/A-)A/-A/c                 B  #    U R                  5       I Sh  vN   SnU R                  5       I Sh  vN u  pVU=(       d    UnU(       a  SOSnU R                  USSU5      u  pCUUS.n	U R                  U R	                  X5      5      I Sh  vN n
U R                  U
S0 5      nU R                  US0 5      nU R                  US5      nU R                  US	5      nSnSnUb  U R                  U5      nUb  U R                  U5      nU R                  XU5      $  GN N N7f)
a  
fetch the data for a conversion trade

https://bybit-exchange.github.io/docs/v5/asset/convert/get-convert-result

:param str id: the id of the trade that you want to fetch
:param str [code]: the unified currency code of the conversion trade
:param dict [params]: extra parameters specific to the exchange API endpoint
:param str [params.accountType]: eb_convert_uta, eb_convert_spot, eb_convert_funding, eb_convert_inverse, or eb_convert_contract
:returns dict: a `conversion structure <https://docs.ccxt.com/#/?id=conversion-structure>`
Nrc  rd  r   r9  )r  r9  rs  rs  rt  )	r  r  r  +privateGetV5AssetExchangeConvertResultQueryr?  rz  r  r  rx  )ra  rF   r  r  r9  r  r  rY  rl  rB  r~  rv  rs  ry  r{  rz  r|  s                    rc  fetch_convert_tradebybit.fetch_convert_trade!  s1     !!!:>:Q:Q:S4S1/G3G1A-GX";;FDWYfhz{&
 II$++V]Jfgg4 ~~h"5h3))&*=''9
%==8L#|4J$$V:FF] 	"4S hs3   DDDDADDBDDDc                   #    U R                  5       I Sh  vN   0 nUb  X5S'   U R                  U R                  XT5      5      I Sh  vN nU R                  US0 5      nU R	                  US/ 5      nU R                  XSSX#5      $  No N@7f)am  
fetch the users history of conversion trades

https://bybit-exchange.github.io/docs/v5/asset/convert/get-convert-history

:param str [code]: the unified currency code
:param int [since]: the earliest time in ms to fetch conversions for
:param int [limit]: the maximum number of conversion structures to retrieve
:param dict [params]: extra parameters specific to the exchange API endpoint
:param str [params.accountType]: eb_convert_uta, eb_convert_spot, eb_convert_funding, eb_convert_inverse, or eb_convert_contract
:returns dict[]: a list of `conversion structures <https://docs.ccxt.com/#/?id=conversion-structure>`
NrM  rs  rt  rs  rt  )r  ,privateGetV5AssetExchangeQueryConvertHistoryr?  rz  r  parse_conversions)	ra  r  r  rM  r  rB  r~  rv  rw  s	            rc  fetch_convert_trade_history!bybit.fetch_convert_trade_history"  s      !!!$GJJ4;;W^Kghh8 ~~h"5>>$3%%hj(EYYE 	" is!   B
B0B
B?B
B

conversionrz  r|  c                 N   U R                  USS5      nU R                  US5      nU R                  XR5      nU R                  US5      nU R                  Xs5      nUUU R                  U5      U R	                  USS5      UU R                  US5      UU R                  US5      S S S	.
$ )
NexpiredTimer  rs  rt  r  exchangeTxId
fromAmounttoAmount)
r  r  r  rF   rz  r  r|  r  r7  r   )r  r  r  r`  r|  r	  )	ra  r  rz  r|  r  rs  rp  torq  s	            rc  rx  bybit.parse_conversion5"  s    T ''
M;O	##J
;**8Bj(3((8"Y/$$ZnM$**:|D ((Z@
 	
re  c                   #    U R                  5       I Sh  vN   U R                  U5      nSnU R                  SXe5      u  puUS:X  d  US:X  a  [        U R                  S-   5      eUc  SnUS   UUS.nUb  XHS	'   U R                  U R                  X5      5      I Sh  vN n	U R                  U	S
0 5      n
U R                  U
S/ 5      nU R                  X5      $  N N=7f)ap  
fetches the long short ratio history for a unified market symbol

https://bybit-exchange.github.io/docs/v5/market/long-short-ratio

:param str symbol: unified symbol of the market to fetch the long short ratio for
:param str [timeframe]: the period for the ratio, default is 24 hours
:param int [since]: the earliest time in ms to fetch ratios for
:param int [limit]: the maximum number of long short ratio structures to retrieve
:param dict [params]: extra parameters specific to the exchange API endpoint
:returns dict[]: an array of `long short ratio structures <https://docs.ccxt.com/#/?id=long-short-ratio-structure>`
Nr   rU   rY   zE fetchLongShortRatioHistory() only support linear and inverse marketsr   rF   )r  r  r  rM  rs  rt  )
r  r  r  r;   rF   publicGetV5MarketAccountRatior?  rz  r  parse_long_short_ratio_history)ra  r  r  r  rM  r  r  r  rB  r~  rs  rv  s               rc  fetch_long_short_ratio_history$bybit.fetch_long_short_ratio_historyq"  s      !!!V$**+GX6>TX-tww)ppqqITl

 $G;;DKK<XYY& (B7~~ffb1224@@I 	" Zs"   CCBCC<CCc                 *   U R                  US5      nU R                  US5      nU R                  US5      nU R                  US5      nUU R                  X2S S5      UU R                  U5      S U R	                  [
        R                  " XV5      5      S.$ )Nr  r  buyRatio	sellRatior  )r  r  r  r  r  longShortRatio)r  safe_integer_omit_zeror  r`  r  r@   rA  )ra  r  r  r  r  
longStringshortStrings          rc  parse_long_short_ratiobybit.parse_long_short_ratio"  s     ##D(3//kB	%%dJ7
&&t[9&&xzJ"Y/"33G4F4Fz4_`
 	
re  r   GETc                    U R                  U R                  S   U   5      S-   U-   nUS:X  a   U(       a  USU R                  U5      -   -  nGOUS:X  Ga  U R                  5         UR	                  S5      S:  nUR	                  S5      S:  n	UR	                  S	5      S:  n
UR	                  S
5      S:  n[        U R                  5       5      nU(       a  U(       a  U R                  U5      nOSnXR                  -   U-   nU R                  U R                  U5      U R                  U R                  5      [        R                  S5      nSU R                  UUS.nGOU	(       d  U
(       d  U(       GaH  SU R                  U[        U R                  S   5      S.nU	(       d  U
(       a  SUS'   U R                  0 U5      nU R                  U5      n[        U5      U R                  -   [        U R                  S   5      -   nS nUS:X  a  U R                  U5      nUU-   nOUU-   nUSU-   -  nS nU R                  R	                  S5      S:  a  U R!                  UU R                  S5      nOIU R                  U R                  U5      U R                  U R                  5      [        R                  5      nXS'   GOYU R                  UU R                  U R                  S   US.5      nU R#                  U5      nU R                  US5      nS nU R                  R	                  S5      S:  a  U R!                  UU R                  S5      nOIU R                  U R                  U5      U R                  U R                  5      [        R                  5      nUS:X  a[  UR	                  S5      S:  nU R                  USU05      nU(       a  U R%                  U5      nSS0nO6U R                  U5      nSS0nO USU R                  US5      -   -  nUSU-   -  nUS:X  a$  U R'                  U R                  S5      nUb  UUS '   XsXeS!.$ )"Nr   r  r   ?r   openapir   z
unified/v3zcontract/v3rL   z{}hexzapplication/json)Content-TypeX-BAPI-API-KEYX-BAPI-TIMESTAMPX-BAPI-SIGNr  )r  r  r  zX-BAPI-RECV-WINDOWr  zX-BAPI-SIGN-TYPEPOSTzPRIVATE KEYr  sha256r  )api_keyrecv_windowr  TrU   signr  z!application/x-www-form-urlencodedz&sign=r*  Referer)urlr  bodyheaders)implode_hostnamer   	rawencoder  r  r  rp  jsonapiKeyhmacencodesecrethashlibr  r  r?  rsakeysort	urlencoder  )ra  pathr   r  r  r  r  r  	isOpenapiisV3UnifiedMarginisV3ContractisV5UnifiedAccountr  payload	signaturer  queryEncoded	auth_baseauthFullsortedQueryauthr  extendedQueryr*  s                           rc  r  
bybit.sign"  s   ##DIIe$4S$9:S@4G(?sT^^F333I++-+q0I # 6! ;88M2a7L!$$1!4DJJL)I99V,D  D#kk1D8 IIdkk'&:DKK<TV]VdVdfkl	$6&*kk(1#,	 #l6H$6&*kk(1*-dll<.H*I	 %25G./B/#~~e4	NT[[83t||L?Y;ZZ	V#99U+D(4/H(<7H3--C 	;;##M2R7 $4;; II $		$++h*?T[[AY[b[i[i jI)2&F#{{#'<<#=!*- 
 #ll51~~k48 	;;##M2R7 $t{{H EI $		$++d*;T[[=UW^WeWe fIV# XXf-2F$(KK	8 %M #~~m<*,O#  $yy7*,># 3T!BBBC8i//CV''jAH#%-	"dOOre  httpCodereasonr  r  r  r  c
                    U(       d  g U R                  USS5      n
U
S:w  a  U
S:X  a  g S nU
S:X  a(  UR                  S5      S:  a  U R                  S-   U-   nOU R                  S	-   U-   nUR                  S
5      S:  a  US-   nU R                  U R                  S   Xk5        U R                  U R                  S   X5        [        U5      eg )Nret_coder  r  30084r  r  r   z private api uses /user/v3/private/query-api to check if you have a unified account. The API key of user id must own one of permissions: "Account Transfer", "Subaccount Transfer", "Withdrawal"  z7Withdraw address chain or destination tag are not equalr  z:; You might also need to ensure the address is whitelistedr  r  )r|  r  rF   throw_broadly_matched_exceptionr   throw_exactly_matched_exceptionr.   )ra  r  r  r  r  r  r  r~  requestHeadersrequestBody	errorCodefeedbacks               rc  handle_errorsbybit.handle_errors#  s    & &&xYG	G# HG#(9A(=77  &i  i  lp  p77S=4/yyRSVXX#&bb001I4Z001I9_))re  )r   )NNNN)N)NN)__name__
__module____qualname____firstlineno__r   r`  boolrl  rp  r  r  r  r  r  r!   r   r+   r  r  floatr  r  r  r   r  r
   r  r-   r*  r  r  r  dictr#   r  r  r"   r$   r  r  rt  r  r  r%   r  r&   r  r  r'   r!  r'  r   r0  r   rQ  r_  r|  r  r   r  r  r  r   r   r   r  r  r   r  r  r  r  r  r$  r-  r7  r   r=  rB  rN  rV  rJ  rY  rd  ri  rl  rb  rt  rh  rz  ry  r   r   r  r  r  r*   r  r  r  r  r   r  r  r  r   r    r  r  r  r   rL  rK  r_  r_  rd  ri  rq  ru  rx  rt  r	   r  r  r   r  r  r  r,   r   r  r  r  r  r  r  r   r  r  r(   r  r  r)   r  r  r  r  r  r  r  r  r  r   r  r  r  r   r  r&  r,  r   r1  r0  r  r   rG  objectrK  r   rO  r   rS  rN  r`  rn  r   r}  r  r  r  rx  r   r  r  r  r  __static_attributes____classcell__)rb  s   @rc  rB   rB   !   s   B# BH(3$ 3(D	 /1 W[r :< 	CT
3 T
lWC W WRU Wjm W  zI W W 57 ! e  C s #  ') 3S 30 -/ i: iV *, -AV -A^q$v, qftDL tlIDL IVu4 u u6 un 68 @4 @4F @4D 6:" `=7 `= `=D 8<B 9W 97 9
 
4 
, ?CQUdhqs eJ eJ eJ3 eJ^a eJx|  ~B  yC eJN;
 ;
; ;
z <@ E= E=| E=N >BPTcgpr SOs SO# SO]` SOj\ \v \ \| <@d[] 7? 7?S 7? 7?bfglbm 7?r @DB >JS >J >JS\ >J@^) ^)@ *, ^, ^,@: :8Hs HM Mv M M^ XZ dc d d^c d( Y[ es e% e_d e0 mqy{ E/ E/I E/Y E/X] E/fi E/  AF E/N os{}  FJ X,3 X,i X,y X,Z_ X,hk X,t FH V'$|*< V'DQVK V'p hlz~  HJ 7S 7# 7Y 7i 7ad 7tw 7r fjx|  FH 03 0 09 0I 0_b 0ru 0  MR 0d DF S'\(: S'$u+ S'j ;?r ,s ,C ,* 9=R !0S !0# !0E !0F AER O.tCy O.# O.TXY^T_ O.b BD S B Y[ P,d;N6O P,d 59 G1c G1R @DB *C * *SX *< 8<B Y/C Y/ Y/5 Y/v 04$UYbd M MC Ms Mimnsit M. 8<$]ajl c= c=C c=WZ c=quv{q| c=J ?C2 *3 * *RW *< =A * *c *PU *@ DHVZimvx o=S o=PS o=cf o=  ~B  CH  ~I o=b 7;\`ik o o3 oVY optuzp{ o2 9=4^bkm o# oS oX[ orvw|r} o2 59tZ^gi o=c o= o=TW o=nrsxny o=b ?CQUdhqs ^3 ^ ^3 ^^a ^x|  ~C  yD ^, 37TX\eg M?C M?s M?RU M?lpqvlw M?^
h 
R` 
* JL .0S .0PTUcPd .0` =? 5 5> 5" 04$UYbd @E @EC @Es @Eimnyiz @ED 37TX\eg LEC LEs LERU LElpq|l} LE\:s :&L
T L
X L
Q\ L
\ .2SW`b i?s i?# i?S i?gklwgx i?VIt Ix I; IV32 QU]_ 283 28 28 28# 28do 28h 8: E3 Eh EN 8<B bQW bQ4PX> bQHft fV fx fP 8: 53 5h 5	
t 	
V 	
x 	
 DHPR R RS Rh ?C2 $3 $ $L CGr ,d ,C ,\ TXfjy}  GI 2MC 2M`c 2Msv 2Mh =? 89 89t HLZ^mqz| k kTW kgj k@F * ?A !6# !6_ !6F
 
> 7;$]apt} ,Q ,QC ,QWZ ,Qjm ,Q  EI  JX  EY ,Q\ GKY]fh /HC /H /HSV /Hb
$ 
 
. 
. ac 33 3 3C 3TW 3gt 3j 154VZce 5B# 5BS 5BPS 5Bjno|j} 5Bn JL 8c 85 8B BD !S !F
 
D 
4:C :C :%
t %
x %
= %
N QS $?C $?W[\hWi $?L EG R R4P\K] R&
T 
6 
EX 
( ;= '5c '5AT '5R /1 ([ (T0 0C 0d BFb -Ew -E^ <@daenp 3YS 3Y 3Y[^ 3Yj ?CQUdhqs 8Y 8Y3 8Y^a 8Yt
B@ @B !93 !9F( 68 @ @F @D 9=R C4g C4DQWL C4J4
4 4
 4
6 4
l 9=4^bkm MK# MKS MKX[ MKrv  xC  sD MK^.V .{ .` @DB  6 =A B' BP] B0g [h <   $|J\  D 9=4^bkm 'B# 'BS 'BX[ 'Brv  xF  sG 'BR2
6 2
V 2
h 68 <6 <6F <6| :< ;CS ;C ;Cz2
$ 2
( 2
6 2
]c 2
h @DRVeirt ICW ICC IC_b ICy}  G  zH ICV 57 [: [z SW_a 4E# 4Es 4EC 4Efp 4El ]aik +S +C + +VY +pz +B >B" :GC :Gs :GQ[ :Gx =Atbfoq /Zc /Z /Z\_ /Zvz  |F  wG /Zb:
4 :
x :
\d :
pz :
x BFX\ko  C  LN 1A3 1ARU 1Aeh 1Ax{ 1A  SW  Xf  Sg 1Af
4 
 
> 
, &eBSW WPr(c (3 (S (# (X\ (dg ( (re  rB   )H ccxt.async_support.base.exchanger   ccxt.abstract.bybitr   r  r  ccxt.base.typesr   r   r   r   r	   r
   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r    r!   r"   r#   r$   r%   r&   r'   r(   r)   r*   r+   r,   typingr-   ccxt.base.errorsr.   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    re  rc  <module>r     s    6 +   r  r  r  r  r  r  r  r  r  r  r  * 0 - - . ' & % 1 4 . ) * ) . ) + 4 %ZLHk ZLre  