
    E#is)                       S SK Jr  S SKJ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  S SKJr  S SKJr  S SKJr  S SKJr  S S	KJr  S S
KJr  S SKJ r   S SKJ!r!  S SK"J#r#  S SK$J%r%   " S S\\5      r&g)    )Exchange)ImplicitAPIN)AnyBalancesCurrencyDepositAddressIntLedgerEntryMarketNumOrder	OrderBook	OrderSide	OrderTypeStrStringsTickerTradeTradingFeesTransaction)List)ExchangeError)AuthenticationError)ArgumentsRequired)
BadRequest)OrderNotFound)NotSupported)InvalidNonce)	TICK_SIZE)Precisec                     ^  \ rS rSrS\4U 4S jjrSSS0 4S\S\S\S\\	   4S jjr
S	 rSJS
\S\S\	4S jjr0 4S\\   4S jjrS\4S jr0 4S\4S jjrS0 4S\S\S\4S jjrSJS\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\S\\   4
S jjrSJS\S\4S jjrSJS\S\S\4S jjrSS0 4S\S\S\S\\   4S jjr0 4S\ 4S jjr!SSS0 4S\S\S\4S jjr"S0 4S\S \#S!\$S"\%S#\&4
S$ jjr'S0 4S%\S\4S& jjr(S0 4S'\\   S\S\\)   4S( jjr*S0 4S\S\\)   4S) jjr+S*\4S+ jr,SJS,\S\S\)4S- jjr-SSS0 4S\S\S\S\\)   4S. jjr.S0 4S%\S\4S/ jjr/SSS0 4S%\S\S\S\4S0 jjr0S0 4S%\S\4S1 jjr1SSS0 4S\S\S\S\\2   4S2 jjr30 4S\S\44S3 jjr5S0 4S4\64S5 jjr7S0 4S4\64S6 jjr8SKS7 jr9S0 4S\S"\%S8\S9\S\24
S: jjr:SJS;\S\S\24S< jjr;S*\4S= jr<S> r=S?S@0 SS4SA jr>SB\?SC\SD\SE\SF\SG\4SH jr@SIrAU =rB$ )Lbitso   returnc                   > U R                  [        [        U ]  5       SSS/SS0 SS _SS_S	S
_SS
_SS
_SS
_SS
_SS
_SS
_SS
_SS_SS_SS_SS
_SS
_SS
_SS_0 SS
_SS
_SS
_SS
_SS_SS
_SS
_S S
_S!S
_S"S
_S#S
_S$S
_S%S
_S&S
_S'S_S(S_S)S
_E0 S*S
_S+S_S,S
_S-S._S/S_S0S
_S1S
_S2S
_S3S
_S4S
_S5S
_S6S
_S7S
_S8S
_S9S
_S:S
_S;S_E0 S<S
_S=S
_S>S
_S?S
_S@S
_SAS
_SBS
_SCS
_SDS
_SES
_SFS_SGS
_SHS
_SIS
_SJS
_SKS_SLS_E0 SMS
_SNS
_SOS
_SPS_SQS
_SRS
_SSS_STS_SUS_SVS
_SWS
_SXS
_SYS
_SZS
_S[S
_S\S
_S]S
_E0 S^S
_S_S_S`S
_SaS
_SbS_ScS
_SdS_SeS
_SfS_SgS
_ShS
_SiS
_SjS
_SkS
_SlS
_SmS
_SnS
_ES
S
S
S
SSo.ESpSqSr0SqSs0StSuSvSwSx.[        SySzSzS{.S|S}S~SSS.S.SSSSSSSSSS.	S/ SQ0/ SQ/ SQ/ SQ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
SS S SS.S
S
S
SS.S
SS
S
SS.S S SS0S.	S S S.S S S.S.[
        [        [        S.S.5      $ )Nr"   BitsoMXi  v3CORSspotTmarginFswapfutureoption	addMarginborrowCrossMarginborrowIsolatedMarginborrowMargincancelAllOrderscancelOrdercancelOrderscloseAllPositionsclosePositioncreateDepositAddresscreateOrder$createOrderWithTakeProfitAndStopLoss&createOrderWithTakeProfitAndStopLossWscreateReduceOnlyOrderfetchAccountsfetchBalancefetchBorrowInterestfetchBorrowRatefetchBorrowRateHistoriesfetchBorrowRateHistoryfetchBorrowRatesfetchBorrowRatesPerSymbolfetchCrossBorrowRatefetchCrossBorrowRatesfetchCurrenciesfetchDepositfetchDepositAddressfetchDepositAddressesfetchDepositAddressesByNetworkfetchDepositsfetchDepositsWithdrawalsfetchDepositWithdrawFeeemulatedfetchDepositWithdrawFeesfetchFundingHistoryfetchFundingIntervalfetchFundingIntervalsfetchFundingRatefetchFundingRateHistoryfetchFundingRatesfetchGreeksfetchIndexOHLCVfetchIsolatedBorrowRatefetchIsolatedBorrowRatesfetchIsolatedPositionsfetchLedgerfetchLeveragefetchLeveragesfetchLeverageTiersfetchLiquidationsfetchLongShortRatiofetchLongShortRatioHistoryfetchMarginAdjustmentHistoryfetchMarginModefetchMarginModesfetchMarketLeverageTiersfetchMarketsfetchMarkOHLCVfetchMarkPricesfetchMyLiquidationsfetchMySettlementHistoryfetchMyTrades
fetchOHLCVfetchOpenInterestfetchOpenInterestHistoryfetchOpenInterestsfetchOpenOrdersfetchOptionfetchOptionChain
fetchOrderfetchOrderBookfetchOrderTradesfetchPositionfetchPositionHistoryfetchPositionModefetchPositionsfetchPositionsForSymbolfetchPositionsHistoryfetchPositionsRiskfetchPremiumIndexOHLCVfetchSettlementHistoryfetchTickerfetchTickers	fetchTimefetchTradesfetchTradingFeefetchTradingFeesfetchTransactionFeefetchTransactionFeesfetchTransactionsfetchTransferfetchTransfersfetchVolatilityHistoryreduceMarginrepayCrossMarginrepayIsolatedMarginsetLeverage)	setMarginsetMarginModesetPositionModetransferwithdrawzOhttps://github.com/user-attachments/assets/178c8e56-9054-4107-b192-5e5053d4f975restzhttps://bitso.com/apizhttps://stage.bitso.com/apizhttps://bitso.comzhttps://bitso.com/api_infozhttps://bitso.com/feeszhttps://bitso.com/?ref=itej)logoapitestwwwdocfeesreferralgư>g{Gz?)XRPMXNTUSDg:0yE>trxerc20bscbep2)TRC20ERC20BEP20BEP2)	precisiondefaultPrecisionnetworks6030090018003600144004320086400604800)	1m5m15m30m1h4h12h1d1wget)available_booksticker
order_booktradesohlc)account_statusbalancer   fundingszfundings/{fid}funding_destinationkyc_documentsledgerzledger/tradeszledger/feeszledger/fundingszledger/withdrawalsmx_bank_codesopen_orderszorder_trades/{oid}orders/{oid}user_tradeszuser_trades/{tid}zwithdrawals/zwithdrawals/{wid})bitcoin_withdrawaldebit_card_withdrawalether_withdrawalordersphone_numberphone_verificationphone_withdrawalspei_withdrawalripple_withdrawalbcash_withdrawallitecoin_withdrawal)r   r   z
orders/all)r   postdelete)publicprivate)IOCFOKPOGTD)
marginModetriggerPricetriggerPriceTypetriggerDirectionstopLossPricetakeProfitPriceattachedStopLossTakeProfittimeInForcehedgedtrailingleveragemarketBuyRequiresPricemarketBuyByCostselfTradePreventionicebergd   )r   limitdaysBack	untilDayssymbolRequired)r   triggerr   r   i  )r   r   r   r   r   r   i,  )	sandboxr9   createOrdersrl   rt   rq   fetchOrdersfetchClosedOrdersrm   )linearinverse)r*   r,   r-   )02011040304)idname	countries	rateLimitversionhasurlsprecisionModeoptions
timeframesr   features
exceptions)deep_extendsuperr"   describer   r   r   r   )self	__class__s    R/home/james-whalen/.local/lib/python3.13/site-packages/ccxt/async_support/bitso.pyr  bitso.describe   s   eT ; =lll %l 	l
 %l %l Ul $Ul 'l l "4l tl l $Ul  l  '!l" t#l$ 7%l& 9%'l( ()l*  +l, -l. &u/l0 "51l2 +E3l4 )%5l6 #E7l8 ,U9l: ';l< (=l> "5?l@ AlB &tClD (ElF 1%GlH  IlJ +EKlL *:MlN +DOlP &uQlR 'SlT (UlV #EWlX *5YlZ $U[l\ u]l^ "5_l` *5alb +Ecld )%elf tglh  ilj !%kll %emln $Uolp &uqlr -eslt /ulv "5wlx #Eylz +E{l| }l~ !%l@ "5AlB &uClD +EElF  GlH dIlJ $UKlL +EMlN %eOlP "4QlR uSlT #EUlV dWlX !$YlZ #D[l\  ]l^ '_l` $Ualb !%cld *5elf (glh %eilj )%kll )%mln tolp qlr Uslt tulv "5wlx #Dylz &u{l| '}l~ $Ul@  AlB !%ClD )%ElF GlH #EIlJ &uKlL uMlN #!&#(! Wl\ j3 9 +309 ' $ 
 %/"$""	 
  ,I)4n  %&+(,,0,0).+06: $(#'"&#(	( #($)$)27+0/4#(+$. %)&+!$$(%)*.& ',#($)*.	# ',!$#($)*.( $()-#a3j ##
 ##s=~ ,#"[R@
 R R	    Ncodesincer   c                    #    0 nUb  X5S'   U R                  U R                  XT5      5      I Sh  vN nU R                  US/ 5      nU R                  U5      nU R	                  XxX#5      $  N:7f)a  
fetch the history of changes, actions done by the user or operations that altered the balance of the user
: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
:returns dict: a `ledger structure <https://docs.ccxt.com/#/?id=ledger>`
Nr   payload)privateGetLedgerextend
safe_valuesafe_currencyparse_ledger)	r  r  r  r   paramsrequestresponser  currencys	            r  fetch_ledgerbitso.fetch_ledger-  ss      $G..t{{7/KLL0 //(Ir:%%d+  EAA5 Ms   -A,A*;A,c                 4    SSSSS.nU R                  X!U5      $ )Ntransactiontradefee)funding
withdrawalr#  r$  safe_string)r  typetypess      r  parse_ledger_entry_typebitso.parse_ledger_entry_typeU  s*    $'	
 T22r  itemr  c                    U R                  US5      nU R                  U5      nU R                  US/ 5      nU R                  US0 5      nS nS nU R                  US5      n	U R                  US5      n
U R                  X5      nU R	                  X5      nU R                  US0 5      nU R                  USS5      nUc  U R                  US	5      nUS
:X  a  SnO5US:X  a  SnO,US:X  a  S nO#US:X  a  Sn[        R                  " U	5      nUUS.nU R                  U R                  US5      5      nU R                  UU R                  US5      US US UUU	UU R                  U5      S S SUS.U5      $ )N	operationbalance_updatesr   amountr  detailsfidwidtidr%  inr&  outr#  r$  costr  
created_ateidok)infor   	directionaccountreferenceIdreferenceAccountr)  r  r1  	timestampdatetimebeforeafterstatusr$  )r(  r+  r  safe_currency_coder  safe_string_2r    
string_abs	parse8601safe_ledger_entryiso8601)r  r-  r  r/  r)  balanceUpdatesfirstBalancer>  r$  r1  
currencyIdr  r2  r@  r9  rB  s                   r  parse_ledger_entrybitso.parse_ledger_entry^  s   n $$T;7	++I6/@"E~q"=	!!,9%%lJ?
&&z<%%j;//$	26((%?**7E:K	!I,&I'!I%I%%f-D$C NN4#3#3D,#GH	%%""4/"& $"Y/'
  ! 	r  c                   #    U R                  U5      I Sh  vN nU R                  US/ 5      n/ n[        S[        U5      5       GH   nX5   nU R	                  US5      nUR                  S5      u  pUR                  5       n
U	R                  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                  [        R                  " US
5      5      nU R                  [        R                  " US
5      5      nU R                  US/ 5      nUUSSS.n/ n/ n[        S[        U5      5       Hv  nUU   nU R                  US5      nU R                  US5      nU R                  US	5      nUR                  UU/5        UR                  UU/5        US:X  d  Ml  UUS'   UUS	'   Mx     UUS.nUUS'   U R                  U R                  S   XR                  S   5      nUR                  U R                  0 SU_SU
S-   U-   _SU
_SU_SS_SU_SU	_SS_SS_SS_SS_S S_S!S_S"S_S#S_S$S_S%S_SUUSSSSSU R                  U R                  S   XR                  S   5      U R                  US&U5      S'.S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-5      U R                  US.5      S(.S/.SUS0.EU5      5        GM     U$  GN67f)1z
retrieves data on all markets for bitso

https://docs.bitso.com/bitso-api/docs/list-available-books

:param dict [params]: extra parameters specific to the exchange API endpoint
:returns dict[]: an array of objects representing market data
Nr  r   book_r   	flat_ratetakermaker100	structureT)rV  rW  
percentage	tierBasedvolume)rV  rW  tiersr   r   r   symbol/basequotesettlebaseIdquoteIdsettleIdr)  r*   r+   Fr,   r-   r.   activecontractr   	tick_size)r1  price)minmaxminimum_amountmaximum_amountminimum_pricemaximum_priceminimum_valuemaximum_value)r   r1  ri  r9  )r   rV  rW  contractSizeexpiryexpiryDatetimestrike
optionTyper   limitscreatedr=  )publicGetAvailableBooksr  rangelenr(  splitupperrG  parse_numberr    
string_divsafe_numberappendr  r  )r  r  r  marketsresultimarketr   rc  rd  r`  ra  r   flatRatetakerStringmakerStringrV  rW  feeTiersr$  	takerFees	makerFeesjtierr\  takerFeemakerFeer]  defaultPricePrecisions                                r  fetch_marketsbitso.fetch_markets  s!     55f==B //(Ir:q#g,'AZF!!&&1B hhsmOF<<>DMMOE**40D++E2E??6626Dt["=H**8W=K**8W=K%%g&8&8e&LME%%g&8&8e&LMEt["=H"!	C II1c(m,{))$9++D':++D':  &(!34  &(!346#+CL#+CL - #"E !CL$($4$4T\\+5NPUWcWcdvWw$x!MM$++ 2'b2'$*u,2' 2' 	2'
 $2' &2' 72' D2' 2' 2' %2' 2' %2' %2' $2'  E!2'" $#2'$   $"&""..t||K/H$P\P\]oPpq!--fkCXY  $#!
  $//8HI#//8HI
  $//H#//H
  $//H#//H$  c2'd e2 2Q (v } >s   MMGM*E$Mc                    U R                  US0 5      nU R                  US/ 5      nUS S S.n[        S[        U5      5       H}  nX5   nU R                  US5      nU R	                  U5      nU R                  5       n	U R                  US5      U	S'   U R                  US5      U	S	'   U R                  US
5      U	S
'   XU'   M     U R                  U5      $ )Nr  balances)r=  rB  rC  r   r  	availablefreelockedusedtotal)r  rz  r{  r(  rG  r?  safe_balance)
r  r  r  r  r  r  r   rO  r  r?  s
             r  parse_balancebitso.parse_balanceL  s    //(Ir:??7J;

 q#h-(AkG))':>J**:6DllnG"..wDGFO"..wAGFO#//AGG"4L )   ((r  c                    #    U R                  5       I Sh  vN   U R                  U5      I Sh  vN nU R                  U5      $  N. N7f)a=  
query for balance and get the amount of funds available for trading or funds locked in orders

https://docs.bitso.com/bitso-api/docs/get-account-balance

:param dict [params]: extra parameters specific to the exchange API endpoint
:returns dict: a `balance structure <https://docs.ccxt.com/#/?id=balance-structure>`
N)load_marketsprivateGetBalancer  )r  r  r  s      r  fetch_balancebitso.fetch_balance_  sG      !!!//774 !!(++7 	"7s   A	AA	AA	A	r^  c           	      Z  #    U R                  5       I Sh  vN   U R                  U5      nSUS   0nU R                  U R                  XS5      5      I Sh  vN nU R	                  US5      nU R                  U R                  US5      5      nU R                  XtS   USSS	S
5      $  N NR7f)a  
fetches information on open orders with bid(buy) and ask(sell) prices, volumes and other data

https://docs.bitso.com/bitso-api/docs/list-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
NrS  r   r  
updated_atr^  bidsasksri  r1  )r  r  publicGetOrderBookr  r  rJ  r(  parse_order_book)	r  r^  r   r  r  r  r  	orderbookrB  s	            r  fetch_order_bookbitso.fetch_order_book  s      !!!V$F4L
 00W1MNNOOHi8	NN4#3#3I|#LM	$$Yx0@)VU[]dfnoo 	"
 Os"   B+B'?B+B)AB+)B+r   r  c                 4   U R                  S U5      nU R                  U R                  US5      5      nU R                  US5      nU R                  US5      n[        R                  " Xe5      nU R                  US5      nU R                  0 SU_SU_SU R                  U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 _SU_SS _SU_SU_SS _SS _SS _SS _UUUS.EU5      $ )Nr:  vwapr\  lastr^  rB  rC  highlowbid	bidVolumeask	askVolumeopenclosepreviousClosechangerZ  average)
baseVolumequoteVolumer=  )safe_symbolrJ  r(  r    
string_mulsafe_tickerrL  )	r  r   r  r^  rB  r  r  r  r  s	            r  parse_tickerbitso.parse_ticker  s    !!$/NN4#3#3FL#IJ	/%%fh7
((:/ !
f!
!
 Y/!
 D$$VV4	!

 4##FE2!
 4##FE2!
 !
 4##FE2!
 !
 D!
 D!
 T!
 D!
 T!
 d!
  $!!
" t#!
$ %&)!
* + 	r  c                   #    U R                  5       I Sh  vN   U R                  U5      nSUS   0nU R                  U R                  XB5      5      I Sh  vN nU R	                  US5      nU R                  Xc5      $  Ng N)7f)a  
fetches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market

https://docs.bitso.com/bitso-api/docs/ticker

: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>`
NrS  r   r  )r  r  publicGetTickerr  r  r  )r  r^  r  r  r  r  r   s          r  fetch_tickerbitso.fetch_ticker  s      !!!V$F4L
 --dkk'.JKK95$   001 	"
 Ls!   BA>?BB (B Br   	timeframec                   #    U R                  5       I Sh  vN   U R                  U5      nUS   U R                  U R                  X"5      S.nUb3  X7S'   Ub+  U R	                  U5      nU R                  X8U-  S-  5      US'   O3Ub0  U R                  5       n	XS'   XR	                  U5      S-  U-  -
  US'   U R                  U R                  Xu5      5      I Sh  vN n
U R                  U
S/ 5      nU R                  XX#U5      $  N N,7f)a  
fetches historical candlestick data containing the open, high, low, and close price, and the volume of a market
: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
:returns int[][]: A list of candles ordered, open, high, low, close, volume
Nr   )rS  time_bucketstarti  endr  )r  r  r(  r  parse_timeframesummillisecondspublicGetOhlcr  	safe_listparse_ohlcvs)r  r^  r  r  r   r  r  r  durationnowr  r  s               r  fetch_ohlcvbitso.fetch_ohlcv  s     !!!V$4L++DOOYR
 $G //	:!%%E1AD1H!I##%C EN"%9%9)%Dt%Ke%SSGG++DKK,HII( ..9b9  )EJJI 	" Js"   D	DCD	D+D	D	c           	          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                  US5      /$ )Nbucket_start_time
first_ratemax_ratemin_rate	last_rater\  )safe_integerr  )r  ohlcvr  s      r  parse_ohlcvbitso.parse_ohlcv  so      e%89UL1UJ/UJ/UK0UH-
 	
r  r#  c                     U R                  U R                  US5      5      nU R                  US5      nU R                  XBS5      nU R                  US5      nU R                  US5      nS nUb  Xg:X  a  SnOSnOUS:X  a  S	nOSnU R                  US
S5      n	U	b  [        R
                  " U	5      n	S n
U R                  US5      nUb(  U R                  US5      nU R                  U5      nUUS.n
U R                  US5      nUb  [        R
                  " U5      nU R                  US5      nU R                  US5      nU R                  US5      nU R                  UUUU R                  U5      UUS UUUU	UU
S.U5      $ )Nr:  rS  rT  side
maker_siderW  rV  buysellr1  majorfees_amountfees_currencyr8  minorri  oidr5  )r   r=  rB  rC  r^  orderr)  r  takerOrMakerri  r1  r9  r$  )	rJ  r(  r  rH  r    rI  rG  
safe_traderL  )r  r#  r  rB  marketIdr^  r  	makerSider  r1  r$  feeCostfeeCurrencyIdfeeCurrencyr9  ri  orderIdr   s                     r  parse_tradebitso.parse_trade2  s   b NN4#3#3E<#HI	##E62!!(C8v.$$UL9	 &&E!##E8W=''/F""5-8 ,,UODM11-@K'C w/%%d+D  0""5%0eU+"Y/( 
  	r  c                    #    U R                  5       I Sh  vN   U R                  U5      nSUS   0nU R                  U R                  Xd5      5      I Sh  vN nU R	                  US   XRU5      $  NZ N7f)a  
get the list of most recent trades for a particular symbol

https://docs.bitso.com/bitso-api/docs/list-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
:returns Trade[]: a list of `trade structures <https://docs.ccxt.com/#/?id=public-trades>`
NrS  r   r  )r  r  publicGetTradesr  parse_trades)r  r^  r  r   r  r  r  r  s           r  fetch_tradesbitso.fetch_trades  sz      !!!V$F4L
 --dkk'.JKK  )!4fUKK 	"
 Ls!   A5A1?A5A3A53A5c                   #    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0 n[        S[	        U5      5       HW  nXF   nU R                  US5      nU R                  USS5      n	UU	U R                  US5      U R                  US5      S	S	S
.XY'   MY     U$  N N7f)a"  
fetch the trading fees for multiple markets

https://docs.bitso.com/bitso-api/docs/list-fees

:param dict [params]: extra parameters specific to the exchange API endpoint
:returns dict: a dictionary of `fee structures <https://docs.ccxt.com/#/?id=fee-structure>` indexed by market symbols
Nr  r   r   rS  rT  maker_fee_decimaltaker_fee_decimalT)r=  r^  rW  rV  rZ  r[  )r  privateGetFeesr  rz  r{  r(  r  r  )
r  r  r  r  r   r  r  r$  r  r^  s
             r  fetch_trading_feesbitso.fetch_trading_fees  s      !!!,,V44X //(Ir:w3q#d)$A'C''V4H%%hc:F ))#/BC))#/BC"!FN	 % y 	"4s    CCCCBCC   c                   #    U R                  5       I Sh  vN   U R                  U5      nSU;   nUb  U(       d  [        U R                  S-   5      eU(       a   U R	                  US[        US   5      05      nUS   US.nU R                  U R	                  Xt5      5      I Sh  vN nU R                  US   XRU5      $  N N7f)a  
fetch all trades made by the user

https://docs.bitso.com/bitso-api/docs/user-trades

: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
:returns Trade[]: a list of `trade structures <https://docs.ccxt.com/#/?id=trade-structure>`
Nmarkerz fetchMyTrades() does not support fetching trades starting from a timestamp with the `since` argument, use the `marker` extra param to filter starting from an integer trade idr   rS  r   r  )r  r  r   r   r  intprivateGetUserTradesr  )	r  r^  r  r   r  r  markerInParamsr  r  s	            r  fetch_my_tradesbitso.fetch_my_trades  s      !!!V$ #f, ~  +\  !\  ]  ][[#fX./* F 4L
 224;;w3OPP  )!4fUKK- 	"* Qs"   CC BC%C&CCr)  r  r1  ri  c                 ~  #    U R                  5       I Sh  vN   U R                  U5      nUS   UUU R                  US   U5      S.nUS:X  a  U R                  US   U5      US'   U R	                  U R                  X5      5      I Sh  vN n	U R                  U	S   S5      n
U R                  U	U
S	.U5      $  N N07f)
aN  
create a trade order

https://docs.bitso.com/bitso-api/docs/place-an-order

:param str symbol: unified symbol of the market to create an order in
:param str type: 'market' or 'limit'
:param str side: 'buy' or 'sell'
:param float amount: how much 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
:returns dict: an `order structure <https://docs.ccxt.com/#/?id=order-structure>`
Nr   r^  )rS  r  r)  r  r   ri  r  r  r=  r   )r  r  amount_to_precisionprice_to_precisionprivatePostOrdersr  r(  
safe_order)r  r^  r)  r  r1  ri  r  r  r  r  r   s              r  create_orderbitso.create_order  s      !!!V$4L--fX.>G	
 7?#66vh7GOGG//G0LMMhy159 
  	 	" Ns"   B=B9A3B=
B;/B=;B=r   c                   #    U R                  5       I Sh  vN   SU0nU R                  U R                  XC5      5      I Sh  vN nU R                  US/ 5      nU R	                  US5      nU R                  UUS.5      $  Ni N?7f)a9  
cancels an open order

https://docs.bitso.com/bitso-api/docs/cancel-an-order

:param str id: order id
:param str symbol: not used by bitso cancelOrder()
: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  privateDeleteOrdersOidr  r  r(  r  )r  r   r^  r  r  r  r  r  s           r  cancel_orderbitso.cancel_order3  s      !!!2
 44T[[5QRR ..9b9""7A. 
  	 	" Ss!   BB +BB>BBidsc                   #    [        U[        5      (       d  [        U R                  S-   5      eSnUb  U R	                  U5      nSR                  U5      nSU0nU R                  U R                  Xc5      5      I Sh  vN nU R                  US/ 5      n/ n	[        S[        U5      5       H'  n
X   nU	R                  U R                  X5      5        M)     U	$  N[7f)a=  
cancel multiple orders

https://docs.bitso.com/bitso-api/docs/cancel-an-order

:param str[] ids: order ids
:param str symbol: unified market symbol
: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>`
z/ cancelOrders() ids argument should be an arrayN,oidsr  r   )
isinstancelistr   r   r  joinprivateDeleteOrdersr  r  rz  r{  r  parse_order)r  r  r^  r  r  r  r  r  r  r   r  r   s               r  cancel_ordersbitso.cancel_ordersP  s      #t$$#DGG._$_``[[(Fxx}D
 11$++g2NOO //(Ir:q#g,'ABMM$**267 (  Ps   A<C>C?ACc                 $  #    Ub  [        U R                  S-   5      eU R                  U5      I Sh  vN nU R                  US/ 5      n/ n[	        S[        U5      5       H'  nU R                  XF   5      nUR                  U5        M)     U$  N[7f)aP  
cancel all open orders

https://docs.bitso.com/bitso-api/docs/cancel-an-order

:param None symbol: bitso does not support canceling orders for only a specific market
:param dict [params]: extra parameters specific to the exchange API endpoint
:returns dict[]: a list of `order structures <https://docs.ccxt.com/#/?id=order-structure>`
NzX cancelAllOrders() deletes all orders for user, it does not support filtering by symbol.r  r   )r   r   privateDeleteOrdersAllr  rz  r{  r  r  )r  r^  r  r  r  canceledOrdersr  r  s           r  cancel_all_ordersbitso.cancel_all_ordersr  s      tww  *D   D  E  E44V<< //(Ir:q#g,'A$$WZ0E!!%( (  =s   0BBABrF  c                 4    SSSSS.nU R                  X!U5      $ )Nr  closed)zpartial-fillzpartially filledqueued	completedr'  r  rF  statusess      r  parse_order_statusbitso.parse_order_status  s*    " &!	
 &99r  r  c                    S n[        U[        5      (       a  UnOU R                  US5      nU R                  US5      nU R                  U R                  US5      5      nU R                  US5      nU R	                  XbS5      nU R                  US5      nU R                  U R                  US5      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_SU	_SU R                  U	5      _SS _SU_SU_SS _SS _SU_SU
_SS _SU_SS _SU_SS _US S S S.EU5      $ )Nr  r  rF  rS  rT  r)  r:  ri  original_amountunfilled_amount	client_idr=  r   clientOrderIdrB  rC  lastTradeTimestampr^  r   postOnlyr   r1  r9  	remainingfilled)rF  r$  r  r   )r  strr(  r(  r  rJ  r  rL  )r  r  r  r   r  rF  r  r^  	orderTyperB  ri  r1  r1  r.  s                 r  r  bitso.parse_order  s    eS!!B!!%/Bv.(()9)9%)JK##E62!!(C8$$UF3	NN4#3#3E<#HI	  0!!%):;$$U,=>	((<  
E 
" 
 ] 
 	 

 Y/ 
 !$ 
 f 
 I 
 4 
  
 D 
 U 
 D 
 f 
 D 
  ! 
" d# 
$ + 
, - 	r  c                   #    U R                  5       I Sh  vN   U R                  U5      nSU;   nUb  U(       d  [        U R                  S-   5      eU(       a   U R	                  US[        US   5      05      nUS   US.nU R                  U R	                  Xt5      5      I Sh  vN nU R                  US   XRU5      n	U	$  N N7f)a  
fetch all unfilled currently open orders

https://docs.bitso.com/bitso-api/docs/list-open-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
:returns Order[]: a list of `order structures <https://docs.ccxt.com/#/?id=order-structure>`
Nr  z fetchOpenOrders() does not support fetching orders starting from a timestamp with the `since` argument, use the `marker` extra param to filter starting from an integer trade idr   r   r  )r  r  r   r   r  r  privateGetOpenOrdersparse_orders)
r  r^  r  r   r  r  r  r  r  r   s
             r  fetch_open_ordersbitso.fetch_open_orders  s      !!!V$ #f, ~  +^  !^  _  _[[#fX./* F 4L
 224;;w3OPP""8I#6uM/ 	"* Qs"   CCBC%C&CCc                 R  #    U R                  5       I Sh  vN   U R                  SU05      I Sh  vN nU R                  US5      n[        U[        5      (       a(  [        US   5      nUS:X  a  U R                  US   5      $ [        U R                  S-   U-   S-   5      e N Ns7f)aT  
fetches information on an order made by the user

https://docs.bitso.com/bitso-api/docs/look-up-orders

:param str id: the order id
:param str symbol: not used by bitso fetchOrder
: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   z: The order z not found.)	r  privateGetOrdersOidr  r  r  r{  r  r   r   )r  r   r^  r  r  r  	numOrderss          r  fetch_orderbitso.fetch_order  s      !!!1123
   //(I6gt$$HY/0IA~''
33DGGn4r9MIJJ 	"s    B'B#B'B%A2B'%B'c                    #    U R                  5       I Sh  vN   U R                  U5      nSU0nU R                  U R                  Xu5      5      I Sh  vN nU R	                  US   U5      $  NV N7f)a  
fetch all the trades made from a single order

https://docs.bitso.com/bitso-api/docs/list-user-trades

: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>`
Nr  r  )r  r  privateGetOrderTradesOidr  r  )	r  r   r^  r  r   r  r  r  r  s	            r  fetch_order_tradesbitso.fetch_order_trades  st      !!!V$2
 66t{{77STT  )!4f== 	"
 Us!   A1A-<A1A/A1/A1c                   #    U R                  5       I Sh  vN   SU0nU R                  U R                  XC5      5      I Sh  vN nU R                  US/ 5      nU R	                  US0 5      nU R                  U5      $  Ng N=7f)a  
fetch information on a deposit

https://docs.bitso.com/bitso-payouts-funding/docs/fundings

:param str id: deposit id
:param str code: bitso does not support filtering by currency code and will ignore self argument
:param dict [params]: extra parameters specific to the exchange API endpoint
:returns dict: a `transaction structure <https://docs.ccxt.com/#/?id=transaction-structure>`
Nr3  r  r   )r  privateGetFundingsFidr  r  	safe_dictparse_transaction)r  r   r  r  r  r  transactionsfirsts           r  fetch_depositbitso.fetch_deposit  s      !!!2
 33DKK4PQQ0 xB?|Q3%%e,,= 	" Rs!   BA>+BB <B Bc                    #    U R                  5       I Sh  vN   SnUb  U R                  U5      nU R                  U5      I Sh  vN nU R                  US/ 5      nU R	                  XuX#U5      $  NY N,7f)a  
fetch all deposits made to an account

https://docs.bitso.com/bitso-payouts-funding/docs/fundings

: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
:returns dict[]: a list of `transaction structures <https://docs.ccxt.com/#/?id=transaction-structure>`
Nr  )r  r  privateGetFundingsr  parse_transactions)r  r  r  r   r  r  r  rI  s           r  fetch_depositsbitso.fetch_deposits=  sx      !!!}}T*H00880 ~~h	2>&&|uVTT; 	" 9s!   A4A0.A4A2+A42A4c                   #    U R                  5       I Sh  vN   U R                  U5      nSUS   0nU R                  U R                  XB5      5      I Sh  vN nU R	                  US   S5      nSnUR                  S5      S:  a5  UR                  S5      nU R	                  US5      nU R	                  US5      nU R                  U5        UUSUUS	.$  N N7f)
a  
fetch the deposit address for a currency associated with self account
: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>`
Nfund_currencyr   r  account_identifierz?dt=r   r<  )r=  r  networkaddresstag)r  r  privateGetFundingDestinationr  r(  findr|  check_address)	r  r  r  r  r  r  rV  rW  partss	            r  fetch_deposit_addressbitso.fetch_deposit_addressh  s      !!!==&Xd^
 ::4;;w;WXX""8I#68LM<<1$MM&)E&&ua0G""5!,C7#
 	
 	"
 Ys"   CC?CCA?CCcodesc                 N  #    U R                  5       I Sh  vN   U R                  U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Xg   nU R                  US5      n	U R                  U	5      n
Ub  U R                  X5      (       d  ME  U R                  US5      SUSS.S.XJ'   Mb     U R                  US	/ 5      n[        UR                  5       5      n[        S[	        U5      5       H  nX   n	U R                  U	5      n
Ub  U R                  X5      (       d  M3  U R                  XJ   S
5      U R                  X5      U R                  XJ   S   S
5      U R                  X5      S.S.XJ'   M     U$  GN GNs7f)ar  
@deprecated
       please use fetchDepositWithdrawFees instead

       https://docs.bitso.com/bitso-api/docs/list-fees

       :param str[]|None codes: list of unified currency codes
       :param dict [params]: extra parameters specific to the exchange API endpoint
       :returns dict[]: a list of `fee structures <https://docs.ccxt.com/#/?id=fee-structure>`
       Nr  deposit_feesr   r  r$  )depositr   )ra  r   r=  withdrawal_feesra  r=  )r  r  r  rz  r{  r(  rG  in_arrayr  r  keys)r  r^  r  r  r  r  depositFeesr  
depositFeerO  r  withdrawalFeescurrencyIdss                r  fetch_transaction_feesbitso.fetch_transaction_fees  s     !!!,,V44X //(Ir:oog~rBq#k*+A$J))*jAJ**:6D!4==+E+E++J> ) $FL , 2CRH>..01q#k*+A$J**:6D!4==+E+E??6<C ,,^H#v|F/CYO $ 0 0 LFL , [ 	"4s    F%FF%F"E0F%"F%c                    #    U R                  5       I Sh  vN   U R                  U5      I Sh  vN nU R                  US/ 5      nU R                  XA5      $  NA N*7f)a0  
fetch deposit and withdraw fees

https://docs.bitso.com/bitso-api/docs/list-fees

:param str[]|None codes: list of unified currency codes
:param dict [params]: extra parameters specific to the exchange API endpoint
:returns dict[]: a list of `fee structures <https://docs.ccxt.com/#/?id=fee-structure>`
Nr  )r  r  r  parse_deposit_withdraw_fees)r  r^  r  r  r  s        r  fetch_deposit_withdraw_fees!bitso.fetch_deposit_withdraw_fees  s[      !!!,,V44X ..9b9//??] 	"4s   AAAA)AAc                    0 nU R                  US/ 5      nU R                  US/ 5      n[        S[        U5      5       Hh  nXW   nU R                  US5      n	U R	                  U	5      n
Ub  X;   d  M4  U R                  US5      U R                  US5      (       + S.S S S.0 US.XJ'   Mj     [        UR                  5       5      n[        S[        U5      5       Hp  nX   n	U R	                  U	5      n
Ub  X;   d  M"  U R                  Xi   5      nU R                  XJ5      nUc  U R                  0 5      XJ'   XU
   S	   S'   XU
   S
   U
'   Mr     U$ )Nr`  rb  r   r  r$  is_fixed)r$  rZ  )ra  r   r   r=  r   r=  )
r  rz  r{  r(  rG  r  r  rd  r~  deposit_withdraw_fee)r  r  r^  currencyIdKeyr  depositResponsewithdrawalResponser  entryrO  r  withdrawalKeyswithdrawFeeresultValues                 r  rl  !bitso.parse_deposit_withdraw_fees  so   R //(NBG!__X7H"Mq#o./A#&E))%<J**:6D4=  $//u=*.//%*L&L 
  $&*! !#!  0" 05578q#n-.A'*J**:6D4="//0B0NO"oof;&#'#<#<R#@FL2=tZ(/-8tV$T* / r  rV  rW  c                   #    U R                  XE5      u  pEU R                  U5        U R                  5       I Sh  vN   SSSSSS.nU R                  U5      nX;   a  Xa   OSnUc  [	        U R
                  S-   U-   5      eUUUS	.n	S
U-   S-   n
[        X
5      " U R                  X5      5      I Sh  vN nU R                  US/ 5      nU R                  US5      nU R                  X5      $  N N<7f)aO  
make a withdrawal
:param str code: unified currency code
:param float amount: the amount to withdraw
:param str address: the address to withdraw to
:param str tag:
:param dict [params]: extra parameters specific to the exchange API endpoint
:returns dict: a `transaction structure <https://docs.ccxt.com/#/?id=transaction-structure>`
NBitcoinEtherRippleBcashLitecoin)BTCETHr   BCHLTCz not valid withdraw coin: )r1  rV  destination_tagprivatePost
Withdrawalr  r   )handle_withdraw_tag_and_paramsrZ  r  r  r   r   getattrr  r  rG  rH  )r  r  r1  rV  rW  r  methodsr  methodr  classMethodr  r  rJ  s                 r  r   bitso.withdrawb  s     99#F7#!!!
 ==&#'?>*F F MNN"

 $f,|; 3DKK4PQQ( //(Ir:w*%%e66Q 	"$ Rs"   8C1C-A7C12C/3;C1/C1r"  c                    U R                  USS5      nU R                  X25      nU R                  US0 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5      nU R                  US	5      n	U R                  US
5      n
U R	                  U5      nUb  UR                  5       OS n0 SU R                  US
S5      _SU R                  US5      _SU R                  U5      _SU_SU_SU_SUb  UOU_SU_SU R                  US5      _SU
c  SOS_SU R                  X25      _S	U R                  U	5      _SS _SS _SS _SS _SS _S S US.E$ )Nr  assetr2  r:  withdrawal_addressreceiving_addressrU  r  rF  r4  r   r3  txidtx_hashrB  rC  addressFromrV  	addressTor1  r)  ra  r&  updatedtagFromrW  tagTocomment)internalr$  r=  )
rH  r  r  r(  network_id_to_coder}  rJ  r  rG  parse_transaction_status)r  r"  r  rO  r2  rC  withdrawalAddressreceivingAddress	networkIdrF  
withdrawIdnetworkCodenetworkCodeUppers                r  rH  bitso.parse_transaction  s   J ''ZI
%%j;//+y"=##K> ,,W6JK++G5HI&&{IxH	!!+x8%%k59
--i83>3J;,,.QU
$$$[%?
D$$Wi8
 1
 	

 '
 +
 ->-J(Qa
 *
 d&&{H=
 *"4I<
 //
E
 d33F;
 t
 t
 4
  T!
" t#
$ )
 	
r  c                 4    SSSSS.nU R                  X!U5      $ )Npendingr<  failed)r  in_progresscompleter  r'  r&  s      r  r  bitso.parse_transaction_status  s*     $	
 &99r  c                 "    U R                  5       $ N)r  )r  s    r  noncebitso.nonce  s      ""r  r   GETc                    SU R                   -   S-   U R                  X5      -   nU R                  X@R                  U5      5      nUS:X  d  US:X  a  U(       a  USU R	                  U5      -   -  nU R
                  S   S   U-   n	US:X  a  U R                  5         [        U R                  5       5      n
SU-   nS	R                  XU/5      nUS:w  a"  US:w  a  U(       a  U R                  U5      nX-  nU R                  U R                  U5      U R                  U R                  5      [        R                  5      nU R                   S
-   U
-   S
-   U-   nSSU-   0nXXeS.$ )Nr_  r  DELETE?r   r   r   z/api :AuthorizationzBitso )urlr  bodyheaders)r  implode_paramsomitextract_params	urlencoder  check_required_credentialsr3  r  r  jsonhmacencodesecrethashlibsha256apiKey)r  pathr   r  r  r  r  endpointqueryr  r  r  	signatureauths                 r  sign
bitso.sign  sO   %+d.A.A$.OO		&"5"5d";<U?f0C$.."777iiv&1)++-

%E(Hgguh78G6X#599U+DOG		$++g"6DKK8PRYR`R`aI;;$u,s2Y>DDG dOOr  httpCodereasonr  r  r  r  c
                    Uc  g SU;   a  U R                  USS5      n
[        U
[        5      (       a  U
S:X  d  U
S:X  a  Sn
OSn
U
(       dz  U R                  S-   U R	                  U5      -   nU R                  US5      nUc  [        U5      eU R                  US5      nU R                  U R                  X5        [        U5      eg )	NsuccessFtrue1T errorr  )
	safe_boolr  r3  r   r  r  r   r(  throw_exactly_matched_exceptionr	  )r  r  r  r  r  r  r  r  requestHeadersrequestBodyr  feedbackr  r  s                 r  handle_errorsbitso.handle_errors  s      nnXy%@G'3''v%7c>"G#G77S=499X+>>':='11''v644T__dU#H--r   r  )NN)C__name__
__module____qualname____firstlineno__r   r  r   r	   r   r
   r  r+  dictr   rP  r   r  r   r  r  r3  r   r  r   r  r  r  r  r  r   r  r  r   r  r  r   r   floatr   r  r  r   r  r   r(  r  r9  r?  rC  rK  r   rP  r   r\  r   ri  rm  rl  r   rH  r  r  r  r  r  __static_attributes____classcell__)r  s   @r  r"   r"      s   S# Sj .2SW`b &Bs &B# &BS &Bgklwgx &BP3ct cx c; cJ *, GV GR) )& *, $, $,L @DB pS p pS\ p**4 * *6 *X 68 "1 "1F "1H ?CQUdhqs .K .K .K3 .K^a .Kx|  ~B  yC .K`
 
4 
0a av a aF <@d[] L LS L Lbfglbm L( /1 E[ EN 37TXZce "LC "Ls "LRU "LH mqy{  I Y X] fi > 9=R S # : AER  tCy  #  TXY^T_  D 59 c U 4: :+ +v + +Z 59tZ\eg #c # #TW #lpqvlw #J 8<B KC K K, ?CQUdhqs >3 > >3 >^a >* 8<B )-c )- )-V 04$UYbd )U )UC )Us )Uimnyiz )UV =? 
 
> 
8 =A X' Xt BFb 8@w 8@tHT QU]_ 473 47 47 47# 47do 47lE
T E
X E
Q\ E
N:s :# &eBSW P0c 3 S # X\ dg  r  r"   )' ccxt.async_support.base.exchanger   ccxt.abstract.bitsor   r  ccxt.base.typesr   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   ccxt.base.decimal_to_precisionr   ccxt.base.preciser    r"   r  r  r  <module>r     s\    6 +  B  B  B  B  B  * 0 . ' * ) ) 4 %BHk Br  