
    ir                    (   d dl mZ d dlmZ d dlZd dlmZmZmZm	Z	m
Z
mZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZ d dlmZ d dlmZ d dlm Z  d dlm!Z! d d	lm"Z" d d
lm#Z# d dlm$Z$ d dlm%Z% d dlm&Z& d dl'm(Z( d dl)m*Z*  G d dee          Z+dS )    )Exchange)ImplicitAPIN)BalancesCurrencyIntLeverage	Leverages
MarginModeMarketNumOrder	OrderBookOrderRequest	OrderSide	OrderTypePositionStrStringsTickerTickersTradeTradingFeeInterfaceTransactionTransferEntry)List)ExchangeError)AuthenticationError)ArgumentsRequired)
BadRequest)InsufficientFunds)InvalidOrder)RateLimitExceeded)ExchangeNotAvailable)	TICK_SIZE)Precisec                       e Zd Z fdZi fdee         fdZdefdZdi fdede	de
fdZdJd	edefd
Zi fdedefdZdi fdedefdZdJd	edefdZddi fdede	de	dee         fdZdJd	edefdZdddi fdede	de	dee         fdZdddi fdede	de	fdZdJd	efdZi fdefdZd Zd Zd ZdJd	edefdZ i fde!fdZ"di fdede#de$de%de&f
d Z'd! Z(dJd	ede)fd"Z*di fdede#de$de%de&de)fd#Z+ddi fdede#de$de&de&f
d$Z,di fd%edefd&Z-i fd'ee.         dee)         fd(Z/dddi fdede	de	dee)         fd)Z0dddi fdede	de	dee         fd*Z1dddi fd+ede	de	dee2         fd,Z3dddi fd+ede	de	dee2         fd-Z4dddi fd+ede	de	fd.Z5dJd/e6de2fd0Z7d1 Z8d2 Z9dJd/e6fd3Z:d4 Z;di fdefd5Z<i fd+ede%d6ed7ede=f
d8Z>dJd/e6fd9Z?i fdede@fd:ZAdi fdee         dee@         fd;ZBdJd	efd<ZCdi fdee         deDfd=ZEi fdedeFfd>ZGdJdeFfd?ZHdi fd@e	defdAZIdi fdede$de)fdBZJdddi fdede	de	dee)         fdCZKi fdedeLfdDZMdJdeLfdEZNdF ZOdGdHi ddfdIZP xZQS )Kblofinc                    |                      t          t          |                                           i ddddddgddd	d
di dd ddddddddddddddddddddddddddddddddi ddd dd!dd"dd#dd$dd%dd&dd'dd(dd)dd*dd+d d,dd-dd.dd/di d0dd1dd2dd3dd4dd5dd6dd7dd8dd9dd:dd;d<d=dd>dd?dd@ddAdi dBddCddDddEddFddGddHd dIddJddKddLddMddNddOddPddQddRdi dSddTddUddVd dWddXddYddZdd[dd\dd]d d^dd_dd`ddaddbddcdi ddddeddfddgddhddiddjddkddlddmddnddoddpddqddrddsddtddddddddddddu
dvdwdxdydzd{d|d}d~dddddddddddddidddddddddddddddddiddddddddddddddddddddddddd	dddd|                     d          |                     d          diddddddi dt
          dt          dt          dt
          dt
          dt
          dt          dt
          dt
          dt
          dt
          dt
          dt          dt          dt          dt          dt          i dt          dt          dt          dt          dt          dt          dt          dt          dt          dt          dt          dt          dt          dt          dt          dt          dt          t          t          t          t
          t
          t
          t          t          dÜt          t          dĜdŜddt          idt          di ddʓdddd͜dddiddddѓddddd՜ddddddٜdUdvdyd|dddyd|dddۜidSddid_ddidddddOdgdddGddidWddidddiddiddid d ddddddd          S )Nidr'   nameBloFin	countriesUSversionv1	rateLimitd   hasCORSspotFmarginswapTfutureoption	addMarginborrowMargincancelAllOrderscancelOrdercancelOrderscloseAllPositionsclosePositioncreateDepositAddresscreateMarketBuyOrderWithCostcreateMarketSellOrderWithCostcreateOrdercreateOrders$createOrderWithTakeProfitAndStopLosscreatePostOnlyOrdercreateReduceOnlyOrdercreateStopLimitOrdercreateStopLossOrdercreateStopMarketOrdercreateStopOrdercreateTakeProfitOrder	editOrderfetchAccountsfetchBalancefetchBidsAsksfetchBorrowInterestfetchBorrowRateHistoriesfetchBorrowRateHistoryfetchCanceledOrdersfetchClosedOrderfetchClosedOrdersfetchCrossBorrowRatefetchCrossBorrowRatesfetchCurrenciesfetchDepositfetchDepositAddressfetchDepositAddressesfetchDepositAddressesByNetworkfetchDepositsfetchDepositsWithdrawalsfetchDepositWithdrawFeeemulatedfetchDepositWithdrawFeesfetchFundingHistoryfetchFundingRatefetchFundingRateHistoryfetchFundingRatesfetchGreeksfetchIndexOHLCVfetchIsolatedBorrowRatefetchIsolatedBorrowRatesfetchL3OrderBookfetchLedgerfetchLedgerEntryfetchLeveragefetchLeveragesfetchLeverageTiersfetchMarginModefetchMarginModesfetchMarketLeverageTiersfetchMarketsfetchMarkOHLCVfetchMySettlementHistoryfetchMyTrades
fetchOHLCVfetchOpenInterestfetchOpenInterestHistoryfetchOpenOrderfetchOpenOrders
fetchOrderfetchOrderBookfetchOrderBooksfetchOrdersfetchOrderTradesfetchPermissionsfetchPositionfetchPositionsfetchPositionsForSymbolfetchPositionsRiskfetchPremiumIndexOHLCVfetchSettlementHistoryfetchStatusfetchTickerfetchTickers	fetchTimefetchTradesfetchTradingFeefetchTradingFeesfetchTradingLimitsfetchTransactionFeefetchTransactionFeesfetchTransactionsfetchTransferfetchTransfersfetchUnderlyingAssetsfetchVolatilityHistoryfetchWithdrawalfetchWithdrawals)
fetchWithdrawalWhitelistreduceMarginrepayCrossMarginsetLeverage	setMarginsetMarginModesetPositionModesignIntransferwithdraw
timeframes1m3m5m15m30m1H2H4H6H12H1D1W1M3M)r   r   r   r   r   1h2h4h6h12h1d1wr   r   hostnamezwww.blofin.comurlszQhttps://github.com/ccxt/ccxt/assets/43336371/255a7b29-341f-4d20-8342-fbfae4932807restzhttps://openapi.blofin.comz0https://blofin.com/register?referral_code=jBd8U1g?)urldiscountzhttps://www.blofin.comzhttps://blofin.com/docs)logoapireferralwwwdocr   get   )zmarket/instrumentszmarket/tickerszmarket/bookszmarket/tradeszmarket/candleszmarket/mark-pricezmarket/funding-ratezmarket/funding-rate-history)zasset/balancesztrade/orders-pendingztrade/fills-historyzasset/deposit-historyzasset/withdrawal-historyzasset/billszaccount/balancezaccount/positionszaccount/leverage-infozaccount/margin-modezaccount/batch-leverage-infoztrade/orders-tpsl-pendingztrade/orders-historyztrade/orders-tpsl-history)	ztrade/orderztrade/cancel-orderzaccount/set-leverageztrade/batch-ordersztrade/order-tpslztrade/cancel-batch-ordersztrade/cancel-tpslztrade/close-positionzasset/transfer)r   post)publicprivatefeesz0.00060z0.00020)takermakerrequiredCredentials)apiKeysecretpassword
exceptions400401500404405406429152001152002152003152004152005152006152007152008152009150003150004542102002102005102014102015102022102037102038102039102040102047102048102049102050102051102052)102053102054102055102064102065102068103013z1Order failed. Insufficient USDT margin in account)zInternal Server Errorzserver error)exactbroadhttpExceptionsprecisionModeoptionsbrokerIdec6dd3a7dd982d0baccountsByTypefutures)r6   r7   accountsByIdsandboxModedefaultNetworkERC20defaultNetworksBTCTRC20)ETHr  USDTnetworksBitcoinBSC)r  BEP20r  r	  8H)r   r   8hr   5Mr   r  r   timezoneUTCmethodprivateGetAccountPositionsprivatePostTradeOrder!createMarketBuyOrderRequiresPricedefaultTypeprivateGetAssetBillsprivateGetTradeOrdersPending!privatePostTradeCancelBatchOrdersprivateGetTradeOrdersHistory)r   pwdSPOTSWAP)r4   r6   r  r   )rT   rV   r   exchangeType)deep_extendsuperr'   describeparse_numberr   r   r   r"   r!   r    r#   r$   )self	__class__s    _/var/www/html/crypto-bot/backend/venv/lib/python3.11/site-packages/ccxt/async_support/blofin.pyr$  zblofin.describe   sq   fd 3 3 < < > > JA
(JA
HJA
 $JA
 t	JA

 JA
  qqq %q 	q
 %q %q Uq q "5q tq q $Uq  q 'q /q  0!q" t#q q$ %q& 7'q( &u)q* (+q, '-q. &t/q0 (1q2 "53q4 (5q6 U7q8  9q: ;q<  =q> &u?q@ +EAqB )%CqD &uEq q qF #EGqH $UIqJ 'KqL (MqN "5OqP QqR &uSqT (UqV 1%WqX  YqZ +E[q\ *:]q^ +E_q` &taqb #Dcqd *4eqf $Ugq q qh uiqj "5kql *5mqn +Eoqp #Eqqr tsqt #Duqv  wqx !$yqz %e{q| "4}q~ #Eq@ +EAqB CqD !%EqF +EGqH  Iq q qJ dKqL $UMqN +EOqP !$QqR "4SqT dUqV !$WqX "5YqZ u[q\ #D]q^ #D_q`  aqb !$cqd *5eqf %egqh )%iqj )%kq q ql umqn toqp qqr Usqt tuqv "5wqx #Eyqz %e{q| &u}q~ 'q@ $UAqB  CqD !%EqF (GqH )%IqJ "5KqL #DMq qN -2 %$)#"!&#( !aq q qJA
p  qJA
P (QJA
R k8 N $  00 SJA
j ./*+())**+-./078	 	 +,01/01245'(+,-.12/078560156 " ()./01./,-56-.01*+
 
# * *kJA
@ !..y99!..y99 AJA
L " $ $MJA
V +:+.+ =+ :	+
 :+ :+ ,+ j+ j+ j+ j+ j+ l+ l+ l+  l!+" l#+ +$ l%+& <'+( l)+* l++, l-+. l/+0 l1+2 l3+4 l5+6 l7+8 l9+: l;+< l=+> l?+@ lA+B lC+D lE+ +F +**(((+IZU+ + +Z .B$8 [1 1WJA
z +{JA
@ YAJA
B  H.H %'# #H v!H uH !'H "" #$ $H  $"$$	 !H, + """"""""	# 	#--HD EHL !:#MHR 6SHT 4UUHV WHX vYHZ 4 [H` "<$aHf A!gHn <( <& !%	  #"""	! !EH H HCJA
 J J J	    returnc                    K   |                      |           d{V }|                     |dg           }|                     |          S )a  
        retrieves data on all markets for blofin
        :see: https://blofin.com/docs#get-instruments
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict[]: an array of objects representing market data
        Ndata)publicGetMarketInstruments	safe_listparse_markets)r&  paramsresponser,  s       r(  fetch_marketszblofin.fetch_marketsf  sV       88@@@@@@@@~~h33!!$'''r)  c                 H   |                      |d          }|                     |d          }|dk    }|dk    }|dk    }|dk    }|p|}|                      |d          }	|                      |d          }
|                      |d          }|                     |          }|                     |	          }|                     |
          }|d	z   |z   }|r|d
z   |z   }d }d }d }|                      |d          }|                     | j        |di           }|                     |d          }|                     |d          }|                      |dd          }t          j        |d          }|                      |d          dk    }|                     i d|d|d|d|d|	d|
d|d|d|d|d|d|ot          j	        |d          d|d|d|d|d|||r|
|k    nd |r|	|k    nd |r|                     |d          nd ||||| 
                    |d           |                     |d!          |                     |          d"|                     d          |                     |          d#|                     |d$          d d#d d d#d d d#d%|d&          S )'NinstIdinstTyper4   r7   r6   r8   baseCurrencyquoteCurrency/:tickSizetradingr   r   maxLeverage1001stateliver)   symbolbasequotebaseIdquoteIdsettlesettleIdtyper5   activecontractValuelistTimelotSize)amountprice)minmaxminSize)leveragerM  rN  cost)contractlinearinversecontractSizeexpiryexpiryDatetimestrike
optionTypecreated	precisionlimitsinfo)safe_stringsafe_string_lowersafe_currency_codesafe_dict_2r   safe_numberr%   
string_maxsafe_market_structure	string_gtsafe_integerr%  )r&  marketr)   rH  r4   r7   r6   r8   rT  rD  rE  rG  rF  rB  rC  rA  rX  strikePricer[  r:  r   r   r   r<  isActives                            r(  parse_marketzblofin.parse_marketq  s   fh//%%fj99("(">6!!&.99""6?;;##FO<<((22&&v..''00e# 	+c\F*F
##FJ77	4B??  w//  w//&&v}eDD(c::$$VW55?)) 2+
"2+
f2+
 D2+
 U	2+

 f2+
 w2+
 f2+
 2+
 D2+
 D2+
 f2+
 dD 1+s C C2+
 D2+
 f2+
 h2+
  U!2+
" U#2+
$ !/7Aw(**T/7A(**TIQ[D,,V_EEEW[$!$((<<**69==**844   ,,S11,,[99 
  ++FI>> 
   
    $ c2+
 2+
 2+
 2 2 2	r)  NrA  limitc                   K   |                                   d{V  |                     |          }d|d         i}|dn|}|||d<   |                     |                     ||                     d{V }|                     |dg           }|                     |di           }|                     |d          }	|                     |||	          S )	a(  
        fetches information on open orders with bid(buy) and ask(sell) prices, volumes and other data
        :see: https://blofin.com/docs#get-order-book
        :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
        Nr4  r)   2   sizer,  r   ts)load_marketsri  publicGetMarketBooksextendr.  	safe_dictrh  parse_order_book)
r&  rA  rm  r0  ri  requestr1  r,  first	timestamps
             r(  fetch_order_bookzblofin.fetch_order_book  s       !!!!!!!!!V$$fTl
 }5#GFO224;;w3O3OPPPPPPPP, ~~h33tQ++%%eT22	$$UFI>>>r)  ri  c                 :   |                      |d          }|                     |d          }|                     ||d          }|d         }|                     |d          }|                     |d          }|                     |dd          }|r|                     |d	          nd }	|                     |d
          }
|                     |d          }|                     |d          }|                     i d|d|d|                     |          d|d|d|                     |d          d|                     |d          d|                     |d          d|                     |d          dd d|d|d|dd dd dd dd |
|	|d |          S )!Nrq  r4  -rA  lastopen24hr4   FvolCurrency24hvol24hhigh24hlow24hry  datetimehighlowbidbidPrice	bidVolumebidSizeaskaskPrice	askVolumeaskSizevwapopenclosepreviousClosechange
percentageaverage)
baseVolumequoteVolumer_  )rh  r`  safe_market	safe_boolsafe_tickeriso8601)r&  tickerri  ry  marketIdrA  r}  r  r4   r  r  r  r  s                r(  parse_tickerzblofin.parse_ticker  s;   %%fd33	##FH55!!(FC88!//	22~~ffe44DHRd&&v/?@@@d%%fh77
	22vx00 !
f!
!
 Y//!
 D	!

 3!
 4##FJ77!
 ))&)<<!
 4##FJ77!
 ))&)<<!
 D!
 D!
 T!
 D!
 T!
 d!
  $!!
" t#!
$ %&)!
 !
 !
* +  	r)  c                 ^  K   |                                   d{V  |                     |          }d|d         i}|                     |                     ||                     d{V }|                     |dg           }|                     |di           }|                     ||          S )a  
        fetches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market
        :see: https://blofin.com/docs#get-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>`
        Nr4  r)   r,  r   )rr  ri  publicGetMarketTickersrt  r.  ru  r  )r&  rA  r0  ri  rw  r1  r,  rx  s           r(  fetch_tickerzblofin.fetch_ticker  s       !!!!!!!!!V$$fTl
 44T[[&5Q5QRRRRRRRR~~h33tQ++  ///r)  symbolsc                    K   |                                   d{V  |                     |          }|                     |           d{V }|                     |dg           }|                     ||          S )a   
        fetches price tickers for multiple markets, statistical information calculated over the past 24 hours for each market
        :see: https://blofin.com/docs#get-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
        :returns dict: a dictionary of `ticker structures <https://docs.ccxt.com/#/?id=ticker-structure>`
        Nr,  )rr  market_symbolsr  r.  parse_tickers)r&  r  r0  r1  tickerss        r(  fetch_tickerszblofin.fetch_tickers!  s       !!!!!!!!!%%g..44V<<<<<<<<..6266!!'7333r)  c                 0   |                      |d          }|                      |d          }|                     ||d          }|d         }|                     |d          }|                     |dd          }|                     |dd	          }|                      |d
          }	|                      |d          }
|                      |d          }d }|||d         d}|                     |||                     |          |||
d d |	||d |d|          S )NtradeIdr4  r|  rA  rq  rN  	fillPricerp  fillSizesideorderIdfeerF  rS  currency)r_  ry  r  rA  r)   orderrH  takerOrMakerr  rN  rM  rS  r  )r`  r  rh  safe_string_2
safe_trader  )r&  traderi  r)   r  rA  ry  rN  rM  r  r  feeCostr  s                r(  parse_tradezblofin.parse_trade/  sM   4 eY//##E844!!(FC88!%%eT22	""5';??##E6:>>v..""5)44""5%00"8, C "Y//  
  
   	r)  sincec                   K   |                                   d{V  d}|                     |dd          \  }}|r#|                     d||||dddd	  	         d{V S |                     |          }d|d	         i}d}|||d
<   d}	|                     |ddd          \  }	}|	dk    r/|                     |                     ||                     d{V }|                     |dg           }
|                     |
|||          S )a  
        get the list of most recent trades for a particular symbol
        :see: https://blofin.com/docs#get-trades
        :param str symbol: unified symbol of the market to fetch trades for
        :param int [since]: timestamp in ms of the earliest trade to fetch
        :param int [limit]: the maximum amount of trades to fetch
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :param boolean [params.paginate]: *only applies to publicGetMarketHistoryTrades* default False, when True will automatically paginate by calling self endpoint multiple times
        :returns Trade[]: a list of `trade structures <https://docs.ccxt.com/#/?id=public-trades>`
        NFr   paginater  afterr1   r4  r)   rm  r  publicGetMarketTradesr,  )rr  handle_option_and_paramsfetch_paginated_call_cursorri  r  rt  r.  parse_trades)r&  rA  r  rm  r0  r  ri  rw  r1  r  r,  s              r(  fetch_tradeszblofin.fetch_tradesi  s|      !!!!!!!!!88PZ[[& 	F99-QVX]_egpry{  BE  F  F  F  F  F  F  F  F  FV$$fTl
 $GG66v}hXopp,,,!77GV8T8TUUUUUUUUH~~h33  vue<<<r)  c           	         |                      |d          |                     |d          |                     |d          |                     |d          |                     |d          |                     |d          gS )Nr   r               )rh  rd  )r&  ohlcvri  s      r(  parse_ohlcvzblofin.parse_ohlcv  s     eQ''UA&&UA&&UA&&UA&&UA&&
 	
r)  r   c           	      ^  K   |                                   d{V  |                     |          }d}|                     |dd          \  }}|r!|                     d|||||d           d{V S |d}|d         |                     | j        ||          |d}|                     |d          }	|	|	|d	<   |                     |d          }d}
|                     | 	                    ||                     d{V }
| 
                    |
d
g           }|                     |||||          S )a  
        fetches historical candlestick data containing the open, high, low, and close price, and the volume of a market
        :see: https://blofin.com/docs#get-candlesticks
        :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]: timestamp in ms of the latest candle to fetch
        :param boolean [params.paginate]: default False, when True will automatically paginate by calling self endpoint multiple times. See in the docs all the [availble parameters](https://github.com/ccxt/ccxt/wiki/Manual#pagination-params)
        :returns int[][]: A list of candles ordered, open, high, low, close, volume
        NFrx   r  r1   r)   )r4  barrm  untilr  r,  )rr  ri  r  "fetch_paginated_call_deterministicr`  r   rh  omitpublicGetMarketCandlesrt  r.  parse_ohlcvs)r&  rA  	timeframer  rm  r0  ri  r  rw  r  r1  r,  s               r(  fetch_ohlcvzblofin.fetch_ohlcv  sx      !!!!!!!!!V$$88zZZ& 	}@@vW\^cenpvx{|||||||||=ETl##DOY	JJ
 

 !!&'22$GGYYvw//F44T[[&5Q5QRRRRRRRR~~h33  vy%GGGr)  c           
      h  K   |t          | j        dz             |                                  d{V  d}|                     |dd          \  }}|r |                     d|||d|           d{V S |                     |          }d|d         i}|t          |d	z
  d
          |d<   |||d<   |                     |                     ||                     d{V }g }	| 	                    |dg           }
t          d
t          |
                    D ]h}|
|         }|                     |d          }|	                    ||d         |                     |d          ||                     |          d           i|                     |	d          }|                     ||d         ||          S )az  
        fetches historical funding rate prices
        :see: https://blofin.com/docs#get-funding-rate-history
        :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 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 argumentFre   r  r  r4  r)   r   r   beforerm  r,  fundingTimerA  fundingRate)r_  rA  r  ry  r  ry  )r   r)   rr  r  r  ri  rP  !publicGetMarketFundingRateHistoryrt  r.  rangelenrh  appendrd  r  sort_byfilter_by_symbol_since_limit)r&  rA  r  rm  r0  r  ri  rw  r1  ratesr,  iratery  sorteds                  r(  fetch_funding_rate_historyz!blofin.fetch_funding_rate_history  s      >#DG.e$efff!!!!!!!!!88AZ\fgg& 	@@@AZ\bdikprvx~V$$fTl
  #EAIq 1 1GH$GG??GU[@\@\]]]]]]]]~~h33q#d))$$ 		 		A7D))$>>ILL *#//mDD& LL33      e[11009I5RWXXXr)  c                    |                      |d          }|                     |d          }|                     ||          }|                     |d          }|                      |d          }i d|d|dd dd d	|                     d
          dd dd dd d|                     |d          d|d|                     |          d|d|d|                     |          dd dd dd S )NnextFundingTimer4  nextFundingRater  r_  rA  	markPrice
indexPriceinterestRate0estimatedSettlePricery  r  r  fundingTimestampfundingDatetimenextFundingTimestampnextFundingDatetimepreviousFundingRatepreviousFundingTimestamppreviousFundingDatetime)rh  r`  safe_symbolrd  r%  r  )r&  rT  ri  nextFundingRateTimestampr  rA  r  r  s           r(  parse_funding_ratezblofin.parse_funding_rate  sz    $(#4#4X?P#Q#Q ##Hh77!!(F33**85FGG''-@@
H
f
 
 $	

 D--c22
 #D
 
 
 4++HmDD
 
 t||K88
 
 #$<
 "4<<0H#I#I
 "4
  '!
" &t#
 	
r)  c                   K   |                                   d{V  |                     |          }|d         st          | j        dz             d|d         i}|                     |                     ||                     d{V }|                     |dg           }|                     |di           }|                     ||          S )aT  
        fetch the current funding rate
        :see: https://blofin.com/docs#get-funding-rate
        :param str symbol: unified market symbol
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: a `funding rate structure <https://docs.ccxt.com/#/?id=funding-rate-structure>`
        Nr6   z2 fetchFundingRate() is only valid for swap marketsr4  r)   r,  r   )	rr  ri  r   r)   publicGetMarketFundingRatert  r.  ru  r  )r&  rA  r0  ri  rw  r1  r,  entrys           r(  fetch_funding_ratezblofin.fetch_funding_rate  s       !!!!!!!!!V$$f~ 	`*^ ^___fTl
 88Wf9U9UVVVVVVVV" ~~h33tQ++&&uf555r)  c                 Z    |r|                      |          S |                     |          S N)parse_funding_balanceparse_trading_balance)r&  rH  r1  s      r(  parse_balance_by_typezblofin.parse_balance_by_type6  s2     	8--h777--h777r)  c                    d|i}|                      |di           }|                     |d          }|                     |dg           }t          dt	          |                    D ]}||         }|                     |d          }|                     |          }	|                                 }
|                     |d          }|                     |d          }||3|                     |d	          |
d
<   |                     |d          |
d<   n
||
d<   ||
d
<   |
||	<   ||d<   |                     |          |d<   | 	                    |          S )Nr_  r,  rq  detailsr   r  equity	availableavailableEquityfreefrozenusedtotalry  r  )
ru  rh  r.  r  r  r`  rb  accountr  safe_balance)r&  r1  resultr,  ry  r  r  balance
currencyIdcoder  eqavailEqs                r(  r  zblofin.parse_trading_balance<  sd   8 (#~~h33%%dD11	..y"55q#g,,'' 	# 	#AajG))':>>J**:66DllnnG!!'844B&&w<<G
"&"2"27<M"N"N"&"2"27H"E"E#% ")"F4LL'{!\\)44z  (((r)  c                    d|i}|                      |dg           }t          dt          |                    D ]}||         }|                     |d          }|                     |          }|                                 }|                     |d          |d<   |                     |d          |d<   |                     |d	          |d
<   |||<   |                     |          S )Nr_  r,  r   r  r  r  r  r  r   r  )r.  r  r  r`  rb  r  r  )	r&  r1  r  r,  r  r  r  r  r  s	            r(  r  zblofin.parse_funding_balanceo  s      (#~~h33q#d))$$ 		# 		#A1gG))':>>J**:66DllnnG#//CCGG"..wDDGFO"..wAAGFO"F4LL  (((r)  c                 $   ||                      d |          |                     t          j        |                     |dd                              |                     t          j        |                     |dd                              d d dS )Nr   makerUr   takerU)r_  rA  r   r   r  	tierBased)r  r%  r%   
string_negr  )r&  r  ri  s      r(  parse_trading_feezblofin.parse_trading_fee  s    &&tV44&&w'9$:L:LSRY[c:d:d'e'eff&&w'9$:L:LSRY[c:d:d'e'eff
 
 	
r)  c                   K   |                                   d{V  |                     |dd          }|                     |ddg          }i }d}|h|                     | j        di           }|                     |||          }||d<   |                     |                     ||                     d{V }n/|                     |                     ||                     d{V }| 	                    ||          S )a'  
        query for balance and get the amount of funds available for trading or funds locked in orders
        :see: https://blofin.com/docs#get-balance
        :see: https://blofin.com/docs#get-futures-account-balance
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :param str [params.accountType]: the type of account to fetch the balance for, either 'funding' or 'futures'  or 'copy_trading' or 'earn'
        :returns dict: a `balance structure <https://docs.ccxt.com/#/?id=balance-structure>`
        NaccountTyperH  r  )
rr  r  r  ru  r   r`  privateGetAssetBalancesrt  privateGetAccountBalancer  )r&  r0  r  rw  r1  r   parsedAccountTypes          r(  fetch_balancezblofin.fetch_balance  s&      !!!!!!!!!((GG6M6#:;;
"nnT\3CRHHG $ 0 0+{ S S%6GM"!99$++gv:V:VWWWWWWWWHH!::4;;wPV;W;WXXXXXXXXH))+x@@@r)  rH  r  rM  rN  c           	      V   |                      |          }|d         |||                     ||          |                     | j        dd          d}d }	|                     d|d          \  }	}|	|d<   |                     |dd	          }
|d
k    }|                     |dg          }|
dk    p|dk    }|o|}|s|rd
|d<   n|                     ||          |d<   d}|                     ||dk    |          \  }}|rd|d<   |                     |d          }|                     |d          }|                     |ddg          }|d u}|d u}|s|r|r`| 	                    |dd          }|                     ||          |d<   |                     |dd          }|                     ||          |d<   |r`| 	                    |dd          }|                     ||          |d<   |                     |dd          }|                     ||          |d<   | 
                    ||          S )Nr)   r   r   )r4  r  	orderTyperp  r   rC   cross
marginModetimeInForceGTCri  IOCiocr  rN  F	post_onlyrH  stopLoss
takeProfittriggerPrice	stopPriceslTriggerPrice-1slOrderPricetpTriggerPricetpOrderPrice)ri  amount_to_precisionr`  r   handle_margin_mode_and_paramsr  price_to_precisionhandle_post_onlyru  r  rt  )r&  rA  rH  r  rM  rN  r0  ri  rw  r  r  isMarketOrderr  	marketIOCpostOnlyr!  r"  
isStopLossisTakeProfitr%  r'  r(  tpPrices                          r(  create_order_requestzblofin.create_order_request  s   V$$Tl,,VV<<((zCUVV
 
 
!??vW^__
F *&&v}eDD(6M?33e#7"*s	 	FI 	F#+GK  #66vuEEGG00@SU[\\& 	*)GFO>>&*55^^FL99
6J#=>>T)
!- 
	S 
	S X!%!3!3Hnk!Z!Z,0,C,CFN,[,[()#//'4HH*.*A*A&,*W*W' S!%!3!3JP[!\!\,0,C,CFN,[,[()**:wEE*.*A*A&'*R*R'{{7F+++r)  c                 B    ddddddd}|                      |||          S )Ncanceledr  closed)r6  order_failedr@  partially_filledfilled	effectiver`  r&  statusstatusess      r(  parse_order_statuszblofin.parse_order_status  s:    "& &!
 
 &&999r)  c                    |                      |dd          }|                     |d          }|                     |d          }|                     |d          }|                     |d          }|                     |d          }d }	d }
|dk    rd	}	d
}n|dk    rd}
d
}n
|dk    rd}
d
}|                     |d          }|                     ||          }|                     ||d          }|                     |d          }|                      |dd          }|                     |d          }|                     |                     |d                    }|                     |d          }|                     |d          }|                     |dd          }|                     |d          }t          j        ||          }d }|*t          j        ||          }t          j        ||          }d }|Xt          j	        |          }|                     |dd          }| 
                    |          }|                     |          |d}|                     |d          }|t          |          dk     rd }|                     |d           }|                     |d!          }|                     |d"          }|                     |d#          }|                     |d$          } | d%k    }!|                     i d&|d'|d|d(|d)|                     |          d*|d+|d,|d-|d.|
d/|	d|d|d0|d1|d2|d3|||||d ||d |!d4	|          S )5NtpslIdr  
createTime
updateTimefillTimer  r  r   Trm  fokFOKr  r  r4  r|  
filledSizepxrN  averagePricer?  r  rp  rR  r>  rW  feeCcyr  r  clientOrderIdr   r%  r'  r(  r)  
reduceOnlytruer_  r)   ry  r  lastTradeTimestamplastUpdateTimestamprA  rH  r  r0  stopLossTriggerPricetakeProfitTriggerPricestopLossPricetakeProfitPrice)	r  rS  rM  r:  	remainingr>  r  tradesrM  )r  rh  r`  r  r  r@  r%   
string_mul
string_div
string_absrb  r%  r  rd  
safe_orderr  )"r&  r  ri  r)   ry  rP  rO  r  rH  r0  r  r  rA  r:  rN  r  r>  feeCostStringrM  rR  rW  
baseAmountrS  r  feeCostSignedfeeCurrencyIdfeeCurrencyCoderL  rQ  rS  rR  rT  reduceOnlyRawrM  s"                                     r(  parse_orderzblofin.parse_order  s?   > x;;%%e\::	"//|DD!..ujAAv..{33;HDDU]]KDDU]]KD##E844!!(F33!!(FC88!!%66""5$88""5.99(()9)9%)I)IJJ((66!!%00##E:s;;''??'f==
%gz::D%dH55D$#.}==M ,,UHfEEM"55mDDO))-88+ C ((@@%C,>,>,B,B M#//7GHH((??!%!1!1%9I!J!J**5.AA((==#v-
  
E 
" 
 ] 
 	 

 Y// 
 !"4 
 "#6 
 f 
 D 
 ; 
  
 D 
 U 
 #$8 
 %&< 
  ]! 
" # 
$ $5 
  
  
6 7  	r)  c                   K   |                                   d{V  |                     |          }|                     |dd          }|                     |d          }d}	|                     |ddd          \  }	}|                     |d          du}
|                     |d          du}|
p|}d}|s|	d	k    s|r6|                     ||||||          }|                     |           d{V }n5|                     ||||||          }| 	                    |           d{V }| 
                    |d
g           }|                     |d          }|                     ||          }||d<   ||d<   |S )aP  
        create a trade order
        :see: https://blofin.com/docs#place-order
        :see: https://blofin.com/docs#place-tpsl-order
        :param str symbol: unified symbol of the market to create an order in
        :param str type: 'market' or 'limit' or 'post_only' or 'ioc' or 'fok'
        :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 fullfilled, in units of the quote currency, ignored in market orders
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :param bool [params.reduceOnly]: a mark to reduce the position size for margin, swap and future orders
        :param bool [params.postOnly]: True to place a post only order
        :param str [params.marginMode]: 'cross' or 'isolated', default is 'cross'
        :param float [params.stopLossPrice]: stop loss trigger price(will use privatePostTradeOrderTpsl)
        :param float [params.takeProfitPrice]: take profit trigger price(will use privatePostTradeOrderTpsl)
        :param str [param.positionSide]: *stopLossPrice/takeProfitPrice orders only* 'long' or 'short' or 'net' default is 'net'
        :param str [params.clientOrderId]: a unique id for the order
        :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 float [params.takeProfit.price]: take profit order price(if not provided the order will be a market order)
        :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 float [params.stopLoss.price]: stop loss order price(if not provided the order will be a market order)
        :returns dict: an `order structure <https://docs.ccxt.com/#/?id=order-structure>`
        NtpslFrC   r  r  rS  rT  privatePostTradeOrderTpslr,  r   rH  r  )rr  ri  r  r  r  r`  create_tpsl_order_requestrd  r4  r  r.  ru  ra  )r&  rA  rH  r  rM  rN  r0  ri  rc  r  isStopLossPriceDefinedisTakeProfitPriceDefinedisType2Orderr1  tpslRequestrw  r,  rx  r  s                      r(  create_orderzblofin.create_orderV  s     4 !!!!!!!!!V$$~~ffe4466**66v}hXopp!%!1!1&/!J!JRV!V#'#3#3F<M#N#NVZ#Z .J2J 	AF999l988tVUZ\bccK!;;KHHHHHHHHHH//dFESYZZG!77@@@@@@@@H~~h33tQ''  //ffr)  c                    |                      |          }|                     |dd          }|d         |||                     | j        dd          d}	||                     ||          |	d<   |                     |dd	          }
|
d	k    r|
d
k    rt	          | j        dz             |                     |d          }|                     |d          }|?|                     ||          |	d<   |dk    rd|	d<   nZ|                     ||          |	d<   n@|>|                     ||          |	d<   |dk    rd|	d<   n|                     ||          |	d<   |
|	d<   |                     |ddg          }|                     |	|          S )NpositionSidenetr)   r   r   )r4  r  rl  r   rp  r  r  isolatedzX createTpslOrder() requires a marginMode parameter that must be either cross or isolatedrS  rT  r%  ri  r&  r'  r(  r)  )	ri  r`  r   r*  r   r)   r,  r  rt  )r&  rA  rH  r  rM  rN  r0  ri  rl  rw  r  rS  rT  s                r(  re  z blofin.create_tpsl_order_request  s   V$$''FFTl(((zCUVV	
 
 "66vvFFGFO%%flGDD
  Z:%=%=TW  (B  B  C  C  C((AA**63DEE$(,(?(?(V(VG$%x*.''*.*A*A&%*P*P''((,(?(?(X(XG$%x*.''*.*A*A&%*P*P' *6O5F#GHH{{7F+++r)  r)   c                   K   |t          | j        dz             |                                  d{V  |                     |          }d|d         i}|                     |g dd          }|                     |d          }|||d<   n'|st          |          |d<   nt          |          |d	<   |                     |g d
          }|r6|                     |g||           d{V }	| 	                    |	d          }
|
S | 
                    |                     ||                     d{V }|                     |dg           }| 	                    |d          }|                     ||          S )a  
        cancels an open order
        :see: https://blofin.com/docs#cancel-order
        :see: https://blofin.com/docs#cancel-tpsl-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]: True if cancelling a trigger/conditional order/tp sl orders
        :returns dict: An `order structure <https://docs.ccxt.com/#/?id=order-structure>`
        Nz) cancelOrder() requires a symbol argumentr4  r)   stoptriggerrc  FrL  r  rB  )r  rL  rq  rr  rc  r   r,  )r   r)   rr  ri  safe_bool_nr`  strr  cancel_ordersru  privatePostTradeCancelOrderrt  r.  ra  )r&  r)   rA  r0  ri  rw  	isTriggerrL  querytpslResponserx  r1  r,  r  s                 r(  cancel_orderzblofin.cancel_order  s      >#DG.Y$YZZZ!!!!!!!!!V$$fTl
 $$V-H-H-H%PP	((AA$'4GO$$ ,%(WW	""$'GG!		&"Y"Y"YZZ 	!%!3!3RD&&!I!IIIIIIILNN<33EL99$++gu:U:UVVVVVVVV~~h33tQ''v...r)  ordersc           	        K   |                                   d{V  g }t          dt          |                    D ]}||         }|                     |d          }|                     |d          }|                     |d          }|                     |d          }	|                     |d          }
|                     |di           }|                     ||          }|                     ||||	|
|          }|                    |           | 	                    |           d{V }| 
                    |d	g           }|                     |          S )
as  
        create a list of trade orders
        :see: https://blofin.com/docs#place-multiple-orders
        :param Array orders: list of orders to create, each object should contain the parameters required by createOrder, namely symbol, type, side, amount, price and params
        :returns dict: an `order structure <https://docs.ccxt.com/#/?id=order-structure>`
        Nr   rA  rH  r  rM  rN  r0  r,  )rr  r  r  r`  
safe_valueru  rt  r4  r  privatePostTradeBatchOrdersr.  parse_orders)r&  r{  r0  ordersRequestsr  rawOrderr  rH  r  rM  rN  orderParamsextendedParamsorderRequestr1  r,  s                   r(  create_orderszblofin.create_orders  sj      !!!!!!!!!q#f++&& 
	0 
	0AayH''(;;H##Hf55D##Hf55D__Xx88FOOHg66E..8R@@K![[f==N44XtT6SXZhiiL!!,////99.IIIIIIII~~h33  &&&r)  c                   K   |                                   d{V  d}|                     |dd          \  }}|r|                     d||||           d{V S i }d}| |                     |          }|d         |d<   |||d<   |                     |g dd          }d}	|                     |dd	d
          \  }	}|                     |g d          }
d}|s|	dk    r0|                     |                     ||
                     d{V }n/|                     |                     ||
                     d{V }| 	                    |dg           }| 
                    ||||          S )ay  
        Fetch orders that are still open
        :see: https://blofin.com/docs#get-active-orders
        :see: https://blofin.com/docs#get-active-tpsl-orders
        :param str symbol: unified market symbol
        :param int [since]: the earliest time in ms to fetch open orders for
        :param int [limit]: the maximum number of  open orders structures to retrieve
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :param bool [params.stop]: True if fetching trigger or conditional orders
        :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  r)   r4  rm  rq  rr  rc  TPSLr  r  r  rq  rr  rc  r   privateGetTradeOrdersTpslPendingr,  )rr  r  fetch_paginated_call_dynamicri  rs  r  r  rt  r  r.  r  r&  rA  r  rm  r0  r  rw  ri  isStopr  rx  r1  r,  s                r(  fetch_open_orderszblofin.fetch_open_orders  s      !!!!!!!!!88ART^__& 	l::;LfV[]bdjkkkkkkkkk
[[((F &tGH$GG!!&*M*M*MuUU66v?PRZ\z{{		&"O"O"OPP 	\f BBB!BB4;;wX]C^C^________HH!>>t{{7TY?Z?Z[[[[[[[[H~~h33  vue<<<r)  c                   K   |                                   d{V  d}|                     |dd          \  }}|r|                     d||||           d{V S i }d}| |                     |          }|d         |d<   |                     d||          \  }}|||d<   |                     |                     ||                     d{V }|                     |d	g           }	|                     |	|||          S )
a=  
        fetch all trades made by the user
        :see: https://blofin.com/docs#get-trade-history
        :param str symbol: unified market symbol
        :param int [since]: the earliest time in ms to fetch trades for
        :param int [limit]: the maximum number of trades structures to retrieve
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :param int [params.until]: Timestamp in ms of the latest time to retrieve trades 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 Trade[]: a list of `trade structures <https://docs.ccxt.com/#/?id=trade-structure>`
        NFrw   r  r)   r4  endrm  r,  )	rr  r  r  ri  handle_until_optionprivateGetTradeFillsHistoryrt  r.  r  )
r&  rA  r  rm  r0  r  rw  ri  r1  r,  s
             r(  fetch_my_tradeszblofin.fetch_my_trades
  sF      !!!!!!!!!88R\]]& 	j::?FTY[`bhiiiiiiiii
[[((F &tGH225'6JJ$GG99$++gv:V:VWWWWWWWW~~h33  vue<<<r)  r  c                 0  K   |                                   d{V  d}|                     |dd          \  }}|r|                     d||||           d{V S i }d}| |                     |          }|d         |d<   |t	          |dz
  d          |d	<   |||d
<   |                     d||          \  }}|                     |                     ||                     d{V }|                     |dg           }	| 	                    |	||||          S )aB  
        fetch all deposits made to an account
        :see: https://blofin.com/docs#get-deposite-history
        :param str code: unified currency code
        :param int [since]: the earliest time in ms to fetch deposits for
        :param int [limit]: the maximum number of deposits structures to retrieve
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :param 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  r)   r  r   r   r  rm  r  r,  )
rr  r  r  r  rP  r  privateGetAssetDepositHistoryrt  r.  parse_transactions
r&  r  r  rm  r0  r  rw  r  r1  r,  s
             r(  fetch_depositszblofin.fetch_deposits(  sg      !!!!!!!!!88R\]]& 	h::?DRWY^`fggggggggg
}}T**H"*4.GJ #EAIq 1 1GH$GG227GVLL;;DKKQW<X<XYYYYYYYY~~h33&&tXueVLLLr)  c                 0  K   |                                   d{V  d}|                     |dd          \  }}|r|                     d||||           d{V S i }d}| |                     |          }|d         |d<   |t	          |dz
  d          |d	<   |||d
<   |                     d||          \  }}|                     |                     ||                     d{V }|                     |dg           }	| 	                    |	||||          S )aM  
        fetch all withdrawals made from an account
        :see: https://blofin.com/docs#get-withdraw-history
        :param str code: unified currency code
        :param int [since]: the earliest time in ms to fetch withdrawals for
        :param int [limit]: the maximum number of withdrawals structures to retrieve
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :param 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  r)   r  r   r   r  rm  r  r,  )
rr  r  r  r  rP  r   privateGetAssetWithdrawalHistoryrt  r.  r  r  s
             r(  fetch_withdrawalszblofin.fetch_withdrawalsH  si      !!!!!!!!!88ASU_``& 	k::;MtUZ\acijjjjjjjjj
}}T**H"*4.GJ #EAIq 1 1GH$GG227GVLL>>t{{7TZ?[?[\\\\\\\\~~h33&&tXueVLLLr)  c                   K   |                                   d{V  d}|                     |dd          \  }}|r|                     d||||           d{V S i }|||d<   d}| |                     |          }|d         |d<   |                     d||          \  }}d}|                     |                     ||                     d{V }|                     |d	g           }	|                     |	|||          S )
a  
        fetch the history of changes, actions done by the user or operations that altered balance of the user
        :see: https://blofin.com/docs#get-funds-transfer-history
        :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 entrys to return, default is None
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :param str [params.marginMode]: 'cross' or 'isolated'
        :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 `ledger structure <https://docs.ccxt.com/#/?id=ledger-structure>`
        NFrl   r  rm  r)   r  r  r,  )	rr  r  r  r  r  r  rt  r.  parse_ledgerr  s
             r(  fetch_ledgerzblofin.fetch_ledgerh  sK      !!!!!!!!!88PZ[[& 	f::=$PUW\^deeeeeeeee
$GG}}T**H"*4.GJ225'6JJ224;;w3O3OPPPPPPPP~~h33  x>>>r)  r  c                 $   d }d }|                      |d          }|                      |d          }|                      |d          }|}|                      |d          }	|d}|}n|}d}|                      |d          }
|                     |
          }|                     |d          }|                     |                      |d	                    }|                      |d
          }|                     |d          }|                      |d          }|                     |          }|                     |d          }i d|d|d|d|dd dd d|d|dd d|	d|	d|d|dd d|d|d|                     |          d d ||ddS )N
withdrawId	depositIdaddresstag
withdrawaldepositr  rM  r?  txIdrq  feeCurrencyr  r_  r)   networkaddressFrom	addressTotagFromtagTor>  rH  updatedtxidry  r  )r  rS  )internalcommentr  )r`  rb  rd  parse_transaction_statusrh  r  )r&  transactionr  rH  r)   withdrawalIdr  r  r  r  r  r  rM  r>  r  ry  r^  feeCoder  s                      r(  parse_transactionzblofin.parse_transaction  sP   H ''\BB$$[+>>	$$[)<<	  e44#DBBBD%%k:>>
&&z22!!+x88..t/?/?W/U/UVVV44%%k488	((mDD))-88"";66
K
"
 
 f	

 t
 4
 
 w
 t
 U
 5
 f
 D
 t
 D
  !
" Y//#
$ # )
 
 
 	
r)  c                 >    ddddd}|                      |||          S )Npendingokfailed)r  r>  23r<  r=  s      r(  r  zblofin.parse_transaction_status  s4    	
 
 &&999r)  c                 L    dddddddddddd}|                      |||          S )Nr   r  rebater  )r>  r  r  4567891011r<  )r&  rH  typess      r(  parse_ledger_entry_typezblofin.parse_ledger_entry_type  sI    
 
 tT222r)  c                     |                      |d          }|                      |d          }|                      |d          }|                      |d          }|                     |                      |d                    }|                     |                      |d          |          }|                      |d          }	|                     |	          }
|                     |d          }d	}||||                     |          |||||
||d
S )N
transferIdclientIdfromAccount	toAccountrH  r  rM  rq  r  )r)   r_  ry  r  r  r  rH  r  rM  r  r>  )r`  r  rb  r%  rh  r  )r&  itemr  r)   referenceIdr  r  rH  r  amountStringrM  ry  r>  s                r(  parse_ledger_entryzblofin.parse_ledger_entry  s   dL11&&tZ88&&t];;$$T;77	++D,<,<T6,J,JKK&&t'7'7j'I'I8TT''h77""<00%%dD11	"Y//&"#
 
 	
r)  c                 Z    t          |t                    r|                    d          S |S )zq
         * @ignore
        :param string[]|str ids: order ids
        :returns str[]: list of order ids
        ,)
isinstancert  split)r&  idss     r(  	parse_idszblofin.parse_ids  s+     c3 	99S>>!Jr)  c                   K   |t          | j        dz             |                                  d{V  |                     |          }g }|                     | j        di           }|                     |dd          }|                     |d|          }|                     |                     |d                    }	|                     |                     |d                    }
| 	                    |g d          }|rd	}|	|                     |          }|
Dt          d
t          |
                    D ]&}|                    |
|         |d         d           't          d
t          |                    D ]M}|r%|                    ||         |d         d           )|                    ||         |d         d           NnDt          d
t          |	                    D ]&}|                    |d         |	|         d           'd}|d	k    r|                     |           d{V }n|                     |           d{V }|                     |dg           }|                     ||dd|          S )a  
        cancel multiple orders
        :see: https://blofin.com/docs#cancel-multiple-orders
        :param str[] ids: order ids
        :param str symbol: unified market symbol
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :param boolean [params.trigger]: whether the order is a stop/trigger order
        :returns dict: an list of `order structures <https://docs.ccxt.com/#/?id=order-structure>`
        Nz* cancelOrders() requires a symbol argumentr=   r  r  rL  rB  rp  privatePostTradeCancelTpslr   r)   )rB  r4  )r  r4  )r4  rL  r,  )r   r)   rr  ri  ru  r   r`  r  r}  rs  r  r  r  r  r  r.  r  )r&  r  rA  r0  ri  rw  r   defaultMethodr  clientOrderIdstpslIdsrq  r  r1  
ordersDatas                  r(  ru  zblofin.cancel_orders  s      >#DG.Z$Z[[[!!!!!!!!!V$$..~rBB(((<_``!!&(MBB(P(PQQ..!B!BCC(C(C(CDD 	21F!..%%C"q#g,,//  ANN")!*"(,$ $     1c#hh'' 
 
 	NN"%a&"(,$ $    
 NN#&q6"(,$ $    
 1c.1122  $Tl%3A%6        111!<<WEEEEEEEEHH!CCGLLLLLLLLH^^Hfb99
  VT4HHHr)  r  r  c                   K   |                                   d{V  |                     |          }|                     | j        di           }|                     |||          }|                     |||          }	|d         |                     ||          ||	d}
|                     |                     |
|                     d{V }|                     |di           }|                     ||          S )aN  
        transfer currency internally between wallets on the same account
        :see: https://blofin.com/docs#funds-transfer
        :param str code: unified currency code
        :param float amount: amount to transfer
        :param str fromAccount: account to transfer from(funding, swap, copy_trading, earn)
        :param str toAccount: account to transfer to(funding, swap, copy_trading, earn)
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: a `transfer structure <https://docs.ccxt.com/#/?id=transfer-structure>`
        Nr  r)   )r  rM  r  r  r,  )	rr  r  ru  r   r`  currency_to_precisionprivatePostAssetTransferrt  parse_transfer)r&  r  rM  r  r  r0  r  r  fromIdtoIdrw  r1  r,  s                r(  r   zblofin.transferR  s      !!!!!!!!!==&&6FKK!!.+{KK	9EE 00v>>!	
 
 66t{{7F7S7STTTTTTTT~~h33""4222r)  c           
      F    |                      |d          }||d d d d d d d d	S )Nr  )	r_  r)   ry  r  r  rM  r  r  r>  r<  )r&  r   r  r)   s       r(  r  zblofin.parse_transferl  sA    h55

 

 
	
r)  c                 d  K   |                                   d{V  |                     |          }d|d         i}|                     |                     ||                     d{V }|                     |dg           }|                     |d          }|dS |                     ||          S )a  
        fetch data on a single open contract trade position
        :see: https://blofin.com/docs#get-positions
        :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.instType]: MARGIN, SWAP, FUTURES, OPTION
        :returns dict: a `position structure <https://docs.ccxt.com/#/?id=position-structure>`
        Nr4  r)   r,  r   )rr  ri  r  rt  r.  ru  parse_position)r&  rA  r0  ri  rw  r1  r,  positions           r(  fetch_positionzblofin.fetch_positionz  s       !!!!!!!!!V$$fTl
 88Wf9U9UVVVVVVVV~~h33>>$**4""8V444r)  c                 "  K   |                                   d{V  |                     |          }|                     |           d{V }|                     |dg           }|                     |          }|                     |d|d          S )a  
        fetch data on a single open contract trade position
        :see: https://blofin.com/docs#get-positions
        :param str[] [symbols]: list of unified market symbols
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :param str [params.instType]: MARGIN, SWAP, FUTURES, OPTION
        :returns dict: a `position structure <https://docs.ccxt.com/#/?id=position-structure>`
        Nr,  rA  F)rr  r  r  r.  parse_positionsfilter_by_array_positions)r&  r  r0  r1  r,  r  s         r(  fetch_positionszblofin.fetch_positions  s       !!!!!!!!!%%g..88@@@@@@@@~~h33%%d++--fhOOOr)  c                    |                      |d          }|                     ||          }|d         }|                      |d          }t          j        |          }|                      |d          }|dk    }|                     |          }	|8|dk    r2t          j        |d          rd}nt          j        |d          rd}nd }|                     |d	          }
|                     |
          }|                      |d
          }|                      |d          }|d         r(t          j	        t          j
        ||          |          }|                     |          }|                      |d          }d }|                      |d          }|                      |d          }|                      |d          }d }d }|dk    r,|                      |d          }t          j        ||          }n1|dk    r+t          j	        d|          }|                      |d          }|                      |d          }|                     |          }t          j	        ||          }|*|                     t          j	        ||d                    }n|t          j
        ||          }d}|                     t          j	        t          j        ||          dd                    }|                     |d          }|                      |d          }|                     t          j
        |d                    }|                     |d          }|                     t          j	        ||d                    }|                     i d|dd d|d|d|d|d |                     |          d|                     |          d!|d"|	d	|
d
|                     |          d#d d$|d%|d&|d'|                     |          d |||                     |          |                     |          |                     |          |                     |          |d d d(
          S ))Nr4  rA  	positionsrl  rm  r  longshortrW  r  notionalUsdrV  r  rJ  unrealizedPnlrR  r  initialMarginrn  r>  r5   maintenanceMarginr  z0.00005liquidationPriceunrealizedPnlRatior=  rD  r_  r)   notional
entryPricer  	contracts	lastPricer  hedgedry  r  )
rP  r  maintenanceMarginPercentage
collateralr  initialMarginPercentagerR  marginRatiorS  rT  )r`  r  r%   rY  r%  rg  	string_ltrd  number_to_stringrX  rW  
string_addrh  safe_positionr  ) r&  r  ri  r  rA  poscontractsAbsr  r  r  rW  contractSizeStringmarkPriceStringnotionalStringr  r  initialMarginStringentryPriceStringunrealizedPnlStringleverageStringr  collateralStringmaintenanceMarginStringr  !maintenanceMarginPercentageStringrounderr  r  percentageStringr  ry  r  s                                    r(  r  zblofin.parse_position  s5   ##Hh77!!(F33!x55)#...99%%l33	?u}}$S#..  !DD&sC00  "DDD''??!22<@@**8[AA))(MBB) 	w$/0B<Qc0d0dfuvvN$$^44%%h==
"++HnEE"..xII))(J??"&  "&"2"28_"M"M&12EGZ[[:%%&-&8n&M&M##//(CC"&"2"28=P"Q"Q --.EFF,3,>?VXf,g,g)"*&*&7&78JK^`npq8r8r&s&s## (")"45Ln"]"]&*&7&78J7K]^  BI  LJ  LJ  LO  QR  9S  9S  'T  'T#++H6HII++H6JKK&&w'9:JE'R'RSS
%%h==	''(:;RTdfg(h(hii!! #
H#
$#
 f#
 	#

 *#
  0#
 $++,<==#
 T../BCC#
 *#
 #
 L#
 **?;;#
 #
 D#
 f#
  !#
" Y//##
$ $(!2+F++,<==!../BCC'+'8'89P'Q'Q)).99&!#7#
 #
 #
   	r)  c                   K   |                                   d{V  |t          | j        dz             d}|                     d|          \  }}||                     |dd          }|dk    r|dk    rt          | j        dz             |                     |          }d}t          d	t          |                    D ]?}||         }| 	                    |          }|d	k    r|d
z   |d         z   }4||d         z   }@||d}| 
                    |                     ||                     d{V }	|                     |	dg           }
|                     |
|d          S )a  
        fetch the set leverage for all contract markets
        :see: https://docs.blofin.com/index.html#get-multiple-leverage
        :param str[] symbols: a list of unified market symbols, required on blofin
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :param str [params.marginMode]: 'cross' or 'isolated'
        :returns dict: a list of `leverage structures <https://docs.ccxt.com/#/?id=leverage-structure>`
        Nz- fetchLeverages() requires a symbols argumentro   r  r  rn  zW fetchLeverages() requires a marginMode parameter that must be either cross or isolated r   r  r)   r4  r  r,  r4  )rr  r   r)   r+  r`  r   r  r  r  ri  "privateGetAccountBatchLeverageInfort  r.  parse_leverages)r&  r  r0  r  instIdsr  r  entryMarketrw  r1  	leveragess              r(  fetch_leverageszblofin.fetch_leverages  s      !!!!!!!!!?#DG.]$]^^^
!??@PRXYY
F))&,HHJ'!!
j(@(@TW  (A  A  B  B  B%%g..q#g,,'' 	6 	6AAJE++e,,K1uu!C-+d*;;!K$55$
 
 @@WV\A]A]^^^^^^^^ NN8VR88	##IwAAAr)  c                   K   |                                   d{V  d}|                     d|          \  }}||                     |dd          }|dk    r|dk    rt          | j        dz             |                     |          }|d         |d}|                     |                     ||                     d{V }|                     |d	i           }| 	                    ||          S )
a  
        fetch the set leverage for a market
        :see: https://docs.blofin.com/index.html#get-leverage
        :param str symbol: unified market symbol
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :param str [params.marginMode]: 'cross' or 'isolated'
        :returns dict: a `leverage structure <https://docs.ccxt.com/#/?id=leverage-structure>`
        Nrn   r  r  rn  zV fetchLeverage() requires a marginMode parameter that must be either cross or isolatedr)   r  r,  )
rr  r+  r`  r   r)   ri  privateGetAccountLeverageInfort  ru  parse_leverage)r&  rA  r0  r  ri  rw  r1  r,  s           r(  fetch_leveragezblofin.fetch_leverage   s'      !!!!!!!!!
!??QWXX
F))&,HHJ'!!
j(@(@TW'  A  A  AV$$Tl$
 
 ;;DKKQW<X<XYYYYYYYY ~~h33""4000r)  c                     |                      |d          }|                     |d          }||                     ||          |                     |d          ||dS )Nr4  rR  r  )r_  rA  r  longLeverageshortLeverage)r`  rh  r  ra  )r&  rR  ri  r  leverageValues        r(  r  zblofin.parse_leverageD  sj    ##Hh77))(J??&&x8800<HH)*
 
 	
r)  rR  c                   K   |t          | j        dz             |dk     s|dk    rt          | j        dz             |                                  d{V  |                     |          }d}|                     d|d          \  }}|dk    r|dk    rt          | j        d	z             |||d
         d}|                     |                     ||                     d{V }|S )a  
        set the level of leverage for a market
        :see: https://blofin.com/docs#set-leverage
        :param int leverage: the rate of leverage
        :param str symbol: unified market symbol
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :param str [params.marginMode]: 'cross' or 'isolated'
        :returns dict: response from the exchange
        Nz) setLeverage() requires a symbol argumentr   }   z3 setLeverage() leverage should be between 1 and 125r   r  rn  zT setLeverage() requires a marginMode parameter that must be either cross or isolatedr)   )rR  r  r4  )r   r)   r   rr  ri  r+  privatePostAccountSetLeveragert  )r&  rR  rA  r0  ri  r  rw  r1  s           r(  set_leveragezblofin.set_leverageO  s"      >#DG.Y$YZZZ qLLhnnTW'\\]]]!!!!!!!!!V$$
!??vW^__
F'!!
j(@(@TW'}}~~~ $Tl
 

 ;;DKKQW<X<XYYYYYYYYr)  c                 v  K   |                                   d{V  |                     |          }|                     |d          }d}|                     d|d          \  }}|d         |d}|||d<   |                     |                     ||                     d{V }|                     |d          S )aA  
        closes open positions for a market
        :see: https://blofin.com/docs#close-positions
        :param str symbol: Unified CCXT market symbol
        :param str [side]: 'buy' or 'sell', leave in net mode
        :param dict [params]: extra parameters specific to the blofin api endpoint
        :param str [params.clientOrderId]: a unique identifier for the order
        :param str [params.marginMode]: 'cross' or 'isolated', default is 'cross
        :param str [params.code]: *required in the case of closing cross MARGIN position for Single-currency margin* margin currency
         *
         * EXCHANGE SPECIFIC PARAMETERS
        :param boolean [params.autoCxl]: whether any pending orders for closing out needs to be automatically canceled when close position via a market order. False or True, the default is False
        :param str [params.tag]: order tag a combination of case-sensitive alphanumerics, all numbers, or all letters of up to 16 characters
        :returns dict[]: `A list of position structures <https://docs.ccxt.com/#/?id=position-structure>`
        NrL  r?   r  r)   r  r,  )rr  ri  r`  r+  privatePostTradeClosePositionrt  ru  )	r&  rA  r  r0  ri  rL  r  rw  r1  s	            r(  close_positionzblofin.close_positionm  s        !!!!!!!!!V$$((AA
!??QWY`aa
FTl$
 
 $'4GO$;;DKKQW<X<XYYYYYYYY~~h///r)  c                   K   |                                   d{V  d}|                     |dd          \  }}|r|                     d||||           d{V S i }d}| |                     |          }|d         |d<   |||d<   |||d<   |                     |g d	d          }d}	|                     |d
dd          \  }	}|                     |g d          }
d}|s|	dk    r0|                     |                     ||
                     d{V }n/|                     |                     ||
                     d{V }| 	                    |dg           }| 
                    ||||          S )a  
        fetches information on multiple closed orders made by the user
        :see: https://blofin.com/docs#get-order-history
        :see: https://blofin.com/docs#get-tpsl-order-history
        :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  orde structures to retrieve
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :param bool [params.stop]: True if fetching trigger or conditional orders
        :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>`
        NFrV   r  r)   r4  rm  beginr  r|   r  r  r   privateGetTradeOrdersTpslHistoryr,  )rr  r  r  ri  rs  r  r+  rt  r  r.  r  r  s                r(  fetch_closed_orderszblofin.fetch_closed_orders  s      !!!!!!!!!88ATV`aa& 	n::;NPVX]_dflmmmmmmmmm
[[((F &tGH$GG$GG!!&*M*M*MuUU66v?PRZ\z{{		&"O"O"OPP 	\"DDD!BB4;;wX]C^C^________HH!>>t{{7TY?Z?Z[[[[[[[[H~~h33  vue<<<r)  c                    K   |                                   d{V  |                     |          }|                     |           d{V }|                     |di           }|                     ||          S )a  
        fetches the margin mode of a trading pair
        :see: https://docs.blofin.com/index.html#get-margin-mode
        :param str symbol: unified symbol of the market to fetch the margin mode for
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: a `margin mode structure <https://docs.ccxt.com/#/?id=margin-mode-structure>`
        Nr,  )rr  ri  privateGetAccountMarginModeru  parse_margin_mode)r&  rA  r0  ri  r1  r,  s         r(  fetch_margin_modezblofin.fetch_margin_mode  s       !!!!!!!!!V$$99&AAAAAAAA ~~h33%%dF333r)  c                 B    ||d         |                      |d          dS )NrA  r  )r_  rA  r  r<  )r&  r  ri  s      r(  r/  zblofin.parse_margin_mode  s/    X&**:|DD
 
 	
r)  c
                    |d S |                      |d          }
|                      |d          }| j        dz   |z   }|
{|
dk    ru|                     | j        d         ||           |                     | j        d         |
|           |                     | j        d         ||           t          |          |                     |d          }|                     |d          }|                      |d          }|                      |d          }|l|dk    rf|                     | j        d         ||           |                     | j        d         ||           |                     | j        d         ||           d S )	Nr  msg r  r   r   r,  r   )r`  r)   throw_exactly_matched_exceptionr   throw_broadly_matched_exceptionr   r.  ru  )r&  httpCodereasonr   r  headersbodyr1  requestHeadersrequestBodyr  messagefeedbackr,  rx  	insideMsg
insideCodes                    r(  handle_errorszblofin.handle_errors  s   4 &11""8U337S=4'001I7T\]]]001I4QYZZZ001I7T\]]]))) ~~h//tQ''$$UE22	%%eV44
!jC&7&7001I:W_```001I9V^___001I9V^___tr)  r   GETc                    d| j         z   dz   |                     ||          z   }|                     ||                     |                    }|                     | j        d         d                   |z   }	|dk    r2|                     |          s|	d|                     |          z   z  }	n0|dk    r)|                                  t          | 
                                          }
| j        | j        |
|
d}d	}|d
k    r8|                     |          s"d|                     |          z   }|	|z  }	||z  }n1|                     |          s|                     |          }|}d|d<   ||z   |
z   |
z   |z   }|                     |                     |                     |          |                     | j                  t$          j                            }||d<   |	|||dS )Nz/api/r8  r   r   r   ?r   )z
ACCESS-KEYzACCESS-PASSPHRASEzACCESS-TIMESTAMPzACCESS-NONCEr  rB  zapplication/jsonzContent-TypezACCESS-SIGN)r   r  r:  r9  )r.   implode_paramsr  extract_paramsimplode_hostnamer   is_empty	urlencodecheck_required_credentialsrt  millisecondsr   r   jsonstring_to_base64hmacencoder   hashlibsha256)r&  pathr   r  r0  r9  r:  rw  rx  r   ry  	sign_bodyurlencodedQueryauth	signatures                  r(  signzblofin.sign  s   DL(3.1D1DT61R1RR		&$"5"5d";";<<##DIe$4V$<==G(??=='' 3sT^^E2222I++---D--//00I"k%)]$- )	 G I}}U++ /&)DNN5,A,A&AO?*C.G}}U++ %99U++D $I*<'V#i/);iGD--diiD8I8I4;;W[WbKcKceles.t.tuuI%.GM"fdwOOOr)  r  )R__name__
__module____qualname__r$  r   r   r2  rl  rt  r   r   rz  r   r  r  r   r   r  r   r  r  listr  r  r   r  r  r  r  r  r  r   r  r   r  r   r   floatr   r4  r@  r   ra  rj  re  rz  r   r  r  r  r   r  r  r  r   r  r  r  r  r  ru  r   r   r  r   r  r  r  r	   r  r   r  r  r%  r(  r,  r
   r0  r/  rA  rW  __classcell__)r'  s   @r(  r'   r'      s	       K K K K KZ
 *, 	( 	(V 	( 	( 	( 	(Mf M M M M^ @DB *? *?S *? *?S\ *? *? *? *?X! !6 !V ! ! ! !F 68 0 0 0F 0 0 0 0$ 6:" 4 47 4 4 4 4 48 8 85 8 8 8 8t <@d[] = = =S = =bfglbm = = = =<
 
 
4 
 
 
 
. 8<$]ajl !H !H !HC !HWZ !Hquvzq{ !H !H !H !HF >BPTcgpr (Y (Ys (Y# (Y]` (Y (Y (Y (YT%
 %
6 %
 %
 %
 %
N <> "6 "6s "6 "6 "6 "6H8 8 81) 1) 1)f) ) )<	
 	
V 	
?R 	
 	
 	
 	
 *, A A A A A A0 os{} ), ),3 ),i ),y ),Z_ ),hk ), ), ), ),V	: 	: 	:n n n5 n n n n` mqy{ / / /I /Y /X] /fi /  AF / / / /b fjx|  FH , , ,9 ,I ,_b ,ru , , , ,@ 9=R #/ #/S #/# #/ #/ #/ #/J FH ' '$|*< 'DQVK ' ' ' '0 59tZ^gi $= $=c $= $=TW $=nrsxny $= $= $= $=L 37TX\eg = =C =s =RU =lpqvlw = = = =< 04$UYbd M M MC Ms Mimnyiz M M M M@ 37TX\eg M MC Ms MRU Mlpq|l} M M M M@ .2SW`b ? ?s ?# ?S ? ? ? ?@R
 R
x R
; R
 R
 R
 R
h: : :3 3 3 
 
 
 
 
 
2	 	 	 6:" 7I 7Is 7I 7I 7I 7Ir ac 3 33 3 3C 3TW 3gt 3 3 3 34
 
 
 
 
 
 8: 5 53 5h 5 5 5 5* :>b P PT#Y PTRZ^ P P P P O Ov O O O Ob :>b .B .BT#Y .BY .B .B .B .B` 8: "1 "13 "1h "1 "1 "1 "1H	
 	
x 	
 	
 	
 	
 ?C2  3     < CGr 0 03 0i 0V[ 0 0 0 0< 7;\`ik &= &= &=3 &=VY &=ptuzp{ &= &= &= &=P ;= 4 4c 4 4 4 4 4.
 
J 
 
 
 
  @ &eBSW P P P P P P P Pr)  r'   ), ccxt.async_support.base.exchanger   ccxt.abstract.blofinr   rP  ccxt.base.typesr   r   r   r   r	   r
   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   typingr   ccxt.base.errorsr   r   r   r   r    r!   r"   r#   ccxt.base.decimal_to_precisionr$   ccxt.base.preciser%   r'    r)  r(  <module>rf     sd   6 5 5 5 5 5 , , , , , ,  y  y  y  y  y  y  y  y  y  y  y  y  y  y  y  y  y  y  y  y  y  y  y  y  y  y  y  y  y  y  y  y  y  y  y  y  y  y  y  y  y  y  y  y  y  y  y  y       * * * * * * 0 0 0 0 0 0 . . . . . . ' ' ' ' ' ' . . . . . . ) ) ) ) ) ) . . . . . . 1 1 1 1 1 1 4 4 4 4 4 4 % % % % % %yP yP yP yP yPX{ yP yP yP yP yPr)  