
    iƎ                         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 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	IndexTypeIntMarketNumOrder	OrderBook	OrderSide	OrderTypeStrStringsTickerTickersTradeTransaction)List)ExchangeError)AuthenticationError)InsufficientFunds)InvalidOrder)DDoSProtection)	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	fdZ
i fdedefd	Zd6d
edefdZdi fdededefdZd7dededefdZd6d
edefdZ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dee         fdZdddi fdedededee         fdZd6dedefdZd Zd6d
edefdZdddi fdedededee         fd Z de!fd!Z"i fde!fd"Z#d# Z$d6d
ede%fd$Z&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,di fd*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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fd0Z1d1 Z2d2d3i ddfd4Z3d5 Z4 xZ5S )8btcalphac                    |                      t          t          |                                           dddgdi dd dddd	d
d	dd	dd	dd	dddd	dd	dd	dddd	dd	dd	dd	ddi dd	dd	dddd	dd	dd	dd	dd	d d	d!dd"d	d#d	d$d	d%d	d&d	d'd	d(d	i d)dd*d	d+d	d,dd-d	d.dd/dd0d	d1dd2dd3dd4dd5d	d6d	d7d	d8d	d9d	dddd	d	d	d	d	dd	d	d	d	d	d	d:d;d<d=d>d?d@dAdBdCdDidEdFdGdHdIdJg dKig dLdMdNgdOdP|                     dQ          |                     dQ          dRdSi idTdUdVit
          i dWt          idXdY          S )ZNr   z	BTC-AlphaUSv1CORSspotTmarginFswapfutureoption	addMargincancelOrdercloseAllPositionsclosePositioncreateDepositAddresscreateOrdercreateReduceOnlyOrdercreateStopLimitOrdercreateStopMarketOrdercreateStopOrderfetchBalancefetchBorrowRateHistoriesfetchBorrowRateHistoryfetchClosedOrdersfetchCrossBorrowRatefetchCrossBorrowRatesfetchDepositfetchDepositAddressfetchDepositAddressesfetchDepositAddressesByNetworkfetchDepositsfetchFundingHistoryfetchFundingRatefetchFundingRateHistoryfetchFundingRatesfetchIndexOHLCVfetchIsolatedBorrowRatefetchIsolatedBorrowRatesfetchL2OrderBookfetchLeveragefetchMarginModefetchMarketsfetchMarkOHLCVfetchMyTrades
fetchOHLCVfetchOpenInterestHistoryfetchOpenOrders
fetchOrderfetchOrderBookfetchOrdersfetchPositionfetchPositionModefetchPositionsfetchPositionsRiskfetchPremiumIndexOHLCV)fetchTickerfetchTickersfetchTradesfetchTradingFeefetchTradingFeesfetchTransferfetchTransfersfetchWithdrawalfetchWithdrawalsreduceMarginsetLeveragesetMarginModesetPositionModetransferwithdraw5153060240D)5m15m30m1h4h1dzchttps://user-images.githubusercontent.com/1294454/42625213-dabaa5da-85cf-11e8-8f99-aa8f8f7699f0.jpgrestzhttps://btc-alpha.com/apizhttps://btc-alpha.comz$https://btc-alpha.github.io/api-docszhttps://btc-alpha.com/fees/zhttps://btc-alpha.com/?r=123788)logoapiwwwdocfeesreferralget)zcurrencies/zpairs/zorderbook/{pair_name}z
exchanges/charts/{pair}/{type}/chart/zticker/)zwallets/zorders/own/zorder/{id}/zexchanges/own/z	deposits/z
withdraws/zorder/zorder-cancel/)rw   post)publicprivatez0.002)makertakerrc   )tradingfundingCBCCashberyzOut of balance)exactbroad)idname	countriesversionhas
timeframesurlsrr   ru   commonCurrenciesprecisionMode
exceptions)deep_extendsuperr   describeparse_numberr   r   )self	__class__s    S/var/www/html/crypto-bot/backend/venv/lib/python3.11/site-packages/ccxt/btcalpha.pyr   zbtcalpha.describe   sm   h 5 5 > > @ @CCC %C 	C
 %C %C UC tC $UC  C 'C tC (C 'C (C  "5!C" #C C$ +E%C& )%'C( $T)C* '+C, (-C. /C0 &u1C2 (3C4 1%5C6  7C8 &u9C: #E;C< *5=C> $U?C@ "5ACB *5CCD +EEC C CF #DGCH  ICJ "5KCL MCN !%OCP  QCR dSCT +EUCV "4WCX dYCZ !$[C\ t]C^  _C` $UaCb !%cCd %eeCf )%gC Ch  $ $##($)!&"'#($( %$!&#(!!EC C CJ   ~7 /=5=	 	    	   !'  8 "..w77!..w77 
   z! '$&7 EHC
 HC
 H H H	    returnc                 V    |                      |          }|                     |          S )a  
        retrieves data on all markets for btcalpha
        :see: https://btc-alpha.github.io/api-docs/#list-all-currencies
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict[]: an array of objects representing market data
        )publicGetPairsparse_marketsr   paramsresponses      r   fetch_marketszbtcalpha.fetch_markets   s-     &&v..  !!(+++r   c                    |                      |d          }|                      |d          }|                      |d          }|                     |          }|                     |          }|                      |d          }|                     |          }|                      |d          }	i d|d|dz   |z   d	|d
|dd d|d|dd dddddddddddddddddd d d d d d d |                     |                     |                      |d                              |                     |                     |                    dd d d|                     |	          |                     |d          d|                     |          d d|                     t          j        ||	                    d ddd |d
S ) Nr   	currency1	currency2price_precisionminimum_order_sizer   symbol/basequotesettlebaseIdquoteIdsettleIdtyper#   Tr$   Fr%   r&   r'   activecontractlinearamount_precision)amountprice)minmaxmaximum_order_size)leverager   r   cost)
inversecontractSizeexpiryexpiryDatetimestrike
optionType	precisionlimitscreatedinfo)safe_stringsafe_currency_codeparse_precisionr   safe_numberr   
string_mul)
r   marketr   r   r   r   r   pricePrecision
priceLimitamountLimits
             r   parse_marketzbtcalpha.parse_market   s   ff--!!&+66""6;77&&v..''00))&2CDD)).99
&&v/CDD0
"0
dSj5(0
 D0
 U	0

 d0
 f0
 w0
 0
 F0
 D0
 e0
 E0
 e0
 e0
 d0
  !0
" d#0
$  "++D,@,@AQAQRXZlAmAm,n,noo**4+?+?+Q+QRR    
  ,,[99++F4HII 
  ,,Z88 
  ,,W-?
K-X-XYY  $ _0
 0
 0
 0	
r   Nsymbolsc                     |                                   |                     |          }|                     ||          S )a  
        :see: https://btc-alpha.github.io/api-docs/#tickers
        fetches price tickers for multiple markets, statistical information calculated over the past 24 hours for each market
        :param str[]|None symbols: unified symbols of the markets to fetch the ticker for, all market tickers are returned if not assigned
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: a dictionary of `ticker structures <https://docs.ccxt.com/#/?id=ticker-structure>`
        )load_marketspublicGetTickerparse_tickers)r   r   r   r   s       r   fetch_tickerszbtcalpha.fetch_tickers   sA     	''//" !!(G444r   r   c                     |                                   |                     |          }d|d         i}|                     |                     ||                    }|                     ||          S )a  
        :see: https://btc-alpha.github.io/api-docs/#tickers
        fetches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market
        :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>`
        pairr   )r   r   r   extendparse_ticker)r   r   r   r   requestr   s         r   fetch_tickerzbtcalpha.fetch_ticker  sr     	V$$F4L
 ''GV(D(DEE   6222r   r   c           	         |                      |d          }t          t          j        |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|          S )N	timestamp1000000r   _lastr   r   datetimehighlowbidbuy	bidVolumeasksell	askVolumevwapopenclosepreviousClosechangediff
percentagevol)average
baseVolumequoteVolume)r   intr   r   safe_marketsafe_tickeriso8601)r   tickerr   timestampStrr   marketIdr   s          r   r   zbtcalpha.parse_ticker.  s    ''<<*<CCDD	##FF33!!(FC88// !
F!
fX&!
 !
 Y//	!

 D$$VV44!
 4##FE22!
 4##FE22!
 !
 4##FF33!
 !
 D!
 D!
 T!
 D!
 T!
  d&&vv66!!
" $#!
$ ++FE::)!
 !
 !
* +  	r   limitc           	         |                                   |                     |          }d|d         i}|r
||d<   ||d<   |                     |                     ||                    }|                     ||d         dddd	d
          S )a5  
        :see: https://btc-alpha.github.io/api-docs/#get-orderbook
        fetches information on open orders with bid(buy) and ask(sell) prices, volumes and other data
        :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
        	pair_namer   
limit_sell	limit_buyr   Nr   r   r   r   )r   r   publicGetOrderbookPairNamer   parse_order_book)r   r   r   r   r   r   r   s          r   fetch_order_bookzbtcalpha.fetch_order_bookX  s     	V$$
  	)$)GL!#(GK 224;;w3O3OPP$$Xvh/?ufV]_ghhhr   r         priceKey	amountKeycountOrIdKeyc                     g }t          dt          |                    D ]6}||         }|r*|                    |                     |||                     7|S )Nr   )rangelenappendparse_bid_ask)r   bidasksr  r  r  resultibidasks           r   parse_bids_askszbtcalpha.parse_bids_asksl  sd    q#g,,'' 	O 	OAQZF Od009MMNNNr   c                    |                      |d          }|                     ||d          }|                      |d          }|                     t          j        |d                    }|                      |d          }|                      |d          }|                      |d          }|                     |dd	          }	|                     ||||                     |          |d
         |d|	d ||d d d|          S )Nr   r   r   r   r   r   r   my_sider   r   r   )r   r   r   r   r   orderr   sidetakerOrMakerr   r   r   fee)r   r   parse_to_intr   r   safe_string_2
safe_trader   )
r   trader   r   timestampRawr   priceStringamountStringr   r  s
             r   parse_tradezbtcalpha.parse_tradet  s   2 ##E622!!(FC88''{;;%%g&8y&Q&QRR	&&ug66''x88eT**!!%F;;"Y//X&  " 
  
   	r   sincec                    |                                   d}i }| |                     |          }|d         |d<   |||d<   |                     |                     ||                    }|                     ||||          S )a$  
        get the list of most recent trades for a particular symbol
        :see: https://btc-alpha.github.io/api-docs/#list-all-exchanges
        :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>`
        Nr   r   r   )r   r   publicGetExchangesr   parse_trades)r   r   r  r   r   r   r   tradess           r   fetch_tradeszbtcalpha.fetch_trades  s     	[[((F$TlGFO$GG((Wf)E)EFF  >>>r   codec                     |                                   d}||                     |          }|                     |          }|                     ||||ddi          S )a  
        fetch all deposits made to an account
        :see: https://btc-alpha.github.io/api-docs/#list-own-deposits
        :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   deposit)r   currencyprivateGetDepositsparse_transactions)r   r"  r  r   r   r%  r   s          r   fetch_depositszbtcalpha.fetch_deposits  si     	}}T**H**622 &&x5%&R[I\]]]r   c                     |                                   d}i }| |                     |          }|d         |d<   |                     |                     ||                    }|                     ||||ddi          S )a  
        fetch all withdrawals made from an account
        :see: https://btc-alpha.github.io/api-docs/#list-own-made-withdraws
        :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
        :returns dict[]: a list of `transaction structures <https://docs.ccxt.com/#/?id=transaction-structure>`
        Nr   currency_idr   
withdrawal)r   r%  privateGetWithdrawsr   r'  )r   r"  r  r   r   r%  r   r   s           r   fetch_withdrawalszbtcalpha.fetch_withdrawals  s     	}}T**H%-d^GM"++DKK,H,HII &&x5%&R^I_```r   r%  c                    |                      |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S )Nr   r%  statusr   r   r   networkaddress	addressToaddressFromtagtagTotagFromr   txidr   comment)internalr  updated)safe_timestampr   r   r   r   parse_transaction_status)r   transactionr%  r   
currencyIdstatusIds         r   parse_transactionzbtcalpha.parse_transaction  sy   & ''[AA	%%k:>>
##K::
$"";55
K
 
 Y//	

 t
 t
 
 4
 4
 T
 t
 //
HEE
 d&&{H==
 D
 D
  d33H==!
" t#
$ )
 
 
 	
r   c                 @    dddddd}|                      |||          S )Npendingokfailedcanceled)1020rf   4050r   r   r/  statusess      r   r<  z!btcalpha.parse_transaction_status   s7    
 
 &&999r   c           	         |                      |d          |                     |d          |                     |d          |                     |d          |                     |d          |                     |d          gS )Ntimer   r   r   r   volume)r;  r   )r   ohlcvr   s      r   parse_ohlcvzbtcalpha.parse_ohlcv*  s     v..UF++UF++UE**UG,,UH--
 	
r   rj   c                 j   |                                   |                     |          }|d         |                     | j        ||          d}|||d<   ||                     |dz            |d<   |                     |                     ||                    }|                     |||||          S )a  
        fetches historical candlestick data containing the open, high, low, and close price, and the volume of a market
        :see: https://btc-alpha.github.io/api-docs/#charts
        :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
        r   )r   r   Nr   i  r  )r   r   r   r   r  publicGetChartsPairTypeChartr   parse_ohlcvs)	r   r   	timeframer  r   r   r   r   r   s	            r   fetch_ohlcvzbtcalpha.fetch_ohlcv>  s     	V$$4L$$T_iKK
 
 $GG#00>>GG44T[[&5Q5QRR   69eUKKKr   c                 p   d|i}t          dt          |                    D ]}||         }|                     |d          }|                     |          }|                                 }|                     |d          |d<   |                     |d          |d<   |||<   |                     |          S )Nr   r   r%  reserveusedbalancetotal)r  r  r   r   accountsafe_balance)r   r   r
  r  rZ  r>  r"  r\  s           r   parse_balancezbtcalpha.parse_balance]  s    (#q#h--(( 	# 	#AqkG))':>>J**:66DllnnG"..w	BBGFO#//CCGG"F4LL  (((r   c                 ~    |                                   |                     |          }|                     |          S )af  
        query for balance and get the amount of funds available for trading or funds locked in orders
        :see: https://btc-alpha.github.io/api-docs/#list-own-wallets
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: a `balance structure <https://docs.ccxt.com/#/?id=balance-structure>`
        )r   privateGetWalletsr^  r   s      r   fetch_balancezbtcalpha.fetch_balancei  s=     	))&11!!(+++r   c                 <    dddd}|                      |||          S )Nr   rE  closed)123rJ  rK  s      r   parse_order_statuszbtcalpha.parse_order_statust  s1    
 

 &&999r   c           	      N   |                      |d          }|                     ||d          }|d         }|                     |dd          }d }|r|                     |d          }n|                     |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|          S )Nr   r   r   successFdater   r   amount_filledamount_originalr/  oidr   r   r  r   clientOrderIdr   r   r   timeInForcepostOnlyr  	stopPricetriggerPricer   filled	remaining)r   r  r   lastTradeTimestampr   )
r   r   	safe_boolr;  safe_integerrg  r  
safe_value
safe_orderr   )r   r  r   r   r   ri  r   r   rt  rs  r   r/  r   r   r  s                  r   parse_orderzbtcalpha.parse_order|  sU   : ##E622!!(FC88!..	599	 	9++E6::II))%88I  00$$UH55	!!%99!!%):;;(()9)9%)J)JKKud3311!!%F;;  
" 
T 
 Y// 
 	 

 f 
 f 
 G 
 4 
  
 D 
 U 
  
 D 
 D 
 f 
  f! 
" # 
$ "&- 
  
  
. /  	r   r   r  r   r   c                 T   |dk    rt          | j        dz             |                                  |                     |          }|d         |||                     ||          d}|                     |                     ||                    }	|	d         s-t          | j        dz   |                     |	          z             |                     |	|          }
t          |
d                   }t          j        |d          r|
d         n|}|                     |          |
d<   |
S )	a  
        :see: https://btc-alpha.github.io/api-docs/#create-order
        create a trade order
        :param str symbol: unified symbol of the market to create an order in
        :param str type: '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 fullfilled, 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>`
        r   z! only limits orders are supportedr   )r   r   r   r   ri   r   0)r   r   r   r   price_to_precisionprivatePostOrderr   jsonrz  strr   	string_gtr   )r   r   r   r  r   r   r   r   r   r   r  orderAmounts               r   create_orderzbtcalpha.create_order  s+    8tw)LLMMMV$$4L,,VU;;	
 
 ((Wf)E)EFF	" 	Dtw}tyy/B/BBCCC  622%/**$+$5k3$G$GSxV++F33hr   r   c                 `    d|i}|                      |                     ||                    }|S )a  
        :see: https://btc-alpha.github.io/api-docs/#cancel-order
        cancels an open order
        :param str id: order id
        :param str symbol: unified symbol of the market the order was made in
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: An `order structure <https://docs.ccxt.com/#/?id=order-structure>`
        r  )privatePostOrderCancelr   )r   r   r   r   r   r   s         r   cancel_orderzbtcalpha.cancel_order  s8     R
 ..t{{7F/K/KLLr   c                     |                                   d|i}|                     |                     ||                    }|                     |          S )av  
        :see: https://btc-alpha.github.io/api-docs/#retrieve-single-order
        fetches information on an order made by the user
        :param str symbol: not used by btcalpha fetchOrder
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: An `order structure <https://docs.ccxt.com/#/?id=order-structure>`
        r   )r   privateGetOrderIdr   rz  )r   r   r   r   r   r  s         r   fetch_orderzbtcalpha.fetch_order  sY     	"
 &&t{{7F'C'CDD&&&r   c                    |                                   i }d}| |                     |          }|d         |d<   |||d<   |                     |                     ||                    }|                     ||||          S )a1  
        :see: https://btc-alpha.github.io/api-docs/#list-own-orders
        fetches information on multiple orders made by the user
        :param str symbol: unified market symbol of the market orders were made in
        :param int [since]: the earliest time in ms to fetch orders for
        :param int [limit]: the maximum number of order structures to retrieve
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns Order[]: a list of `order structures <https://docs.ccxt.com/#/?id=order-structure>`
        Nr   r   r   )r   r   privateGetOrdersOwnr   parse_orders)r   r   r  r   r   r   r   orderss           r   fetch_orderszbtcalpha.fetch_orders   s     	[[((F$TlGFO$GG))$++gv*F*FGG  >>>r   c           	      b    ddi}|                      ||||                     ||                    S )a  
        fetch all unfilled currently open orders
        :see: https://btc-alpha.github.io/api-docs/#list-own-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>`
        r/  rd  r  r   r   r   r  r   r   r   s         r   fetch_open_orderszbtcalpha.fetch_open_orders  :     c
   t{{7F7S7STTTr   c           	      b    ddi}|                      ||||                     ||                    S )a8  
        fetches information on multiple closed orders made by the user
        :see: https://btc-alpha.github.io/api-docs/#list-own-orders
        :param str symbol: unified market symbol of the market orders were made in
        :param int [since]: the earliest time in ms to fetch orders for
        :param int [limit]: the maximum number of order structures to retrieve
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns Order[]: a list of `order structures <https://docs.ccxt.com/#/?id=order-structure>`
        r/  rf  r  r  s         r   fetch_closed_orderszbtcalpha.fetch_closed_orders$  r  r   c                    |                                   i }| |                     |          }|d         |d<   |||d<   |                     |                     ||                    }|                     |d||          S )a  
        fetch all trades made by the user
        :see: https://btc-alpha.github.io/api-docs/#list-own-exchanges
        :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>`
        Nr   r   r   )r   r   privateGetExchangesOwnr   r  )r   r   r  r   r   r   r   r   s           r   fetch_my_tradeszbtcalpha.fetch_my_trades3  s     	[[((F$TlGFO$GG,,T[[&-I-IJJ  ue<<<r   c                 *    |                                  S N)milliseconds)r   s    r   noncezbtcalpha.nonceG  s      """r   rz   GETc           
         |                      |                     |                     ||                     |                                        }| j        d         d         dz   }|dk    r|dz  }||                     ||          z  }ddi}|dk    rt          |          r|d	|z   z  }n|                                  | j        }	|d
k    rd|d<   |}|	|z  }	nt          |          r|d	|z   z  }| j        |d<   | 	                    | 
                    |	          | 
                    | j                  t          j                  |d<   t          |                                           |d<   ||||dS )Nrr   rp   r   rx   zv1/Acceptzapplication/jsonrz   ?POSTz!application/x-www-form-urlencodedzContent-TypezX-KEYzX-SIGNzX-NONCE)urlmethodbodyheaders)	urlencodekeysortomitextract_paramsr   implode_paramsr  check_required_credentialsapiKeyhmacencodesecrethashlibsha256r  r  )
r   pathrr   r  r   r  r  queryr  payloads
             r   signzbtcalpha.signJ  s|   t||DIIfd>Q>QRV>W>W,X,XYYZZiv&,0005LCt""4000/0(??5zz #sU{"++---kG*M'4U #sU{"#{GG $		$++g*>*>DK@X@XZaZh i iGH!$TZZ\\!2!2GIfdwOOOr   c
                 j   |d S |                      |d          }
| j        dz   |z   }|
D|                     | j        d         |
|           |                     | j        d         |
|           |dk    s|dk    rt          |          |dk    rt          |          |dk     rd S t          |          )	Nerrorr|  r   r   i  i  i  i  )r   r   throw_exactly_matched_exceptionr   throw_broadly_matched_exceptionr   r   r   )r   r"  reasonr  r  r  r  r   requestHeadersrequestBodyr  feedbacks               r   handle_errorszbtcalpha.handle_errorsb  s    4   7337S=4'001I5RZ[[[001I5RZ[[[3;;$#++%h///S[[ ***#::4H%%%r   r  )r   r   r   )6__name__
__module____qualname__r   r   r	   r   r   r   r   r   r  r   r   r   r   r   r   r   r  r   r  r!  r   r   r(  r-  r   r@  r<  listrQ  rV  r   r^  ra  rg  r   rz  r   r   floatr
   r  r  r  r  r  r  r  r  r  r  __classcell__)r   s   @r   r   r      s       I I I I IV $& , ,$v, , , , ,29
f 9
 9
 9
 9
v 04B 5 5W 57 5 5 5 58 02 3 33 3f 3 3 3 3:( (6 (V ( ( ( (T :>b i is i3 iY i i i i(  9 hq    / / /5 / / / /b 6:UW ? ?3 ?s ?# ?\`af\g ? ? ? ?* *.Dt\^ ^ ^3 ^c ^ ^cghsct ^ ^ ^ ^6 -1tRV_a a ac a aC afjkvfw a a a a<+
 +
x +
; +
 +
 +
 +
Z: : :
 
 
4 
 
 
 
( 26DW[df L L# Lc LQT Lkoptku L L L L>
) 
) 
) 
) 
) $& 	, 	,( 	, 	, 	, 	,: : :E E E5 E E E EN gksu  3 i y RW `c    > 37r  s C     26b ' 'c '3 ' ' ' ' *.Dt\^ ? ?3 ?c ? ?cghmcn ? ? ? ?* /3TXac U U U3 Uc Uhlmrhs U U U U 154VZce U U# US UPS Ujnotju U U U U -1tRV_a = =c = =C = = = =(# # # &eBSW P P P P0& & & & & & &r   r   )#ccxt.base.exchanger   ccxt.abstract.btcalphar   r  ccxt.base.typesr   r   r   r   r	   r
   r   r   r   r   r   r   r   r   r   r   typingr   ccxt.base.errorsr   r   r   r   r   ccxt.base.decimal_to_precisionr   ccxt.base.preciser   r    r   r   <module>r     s   ( ' ' ' ' ' . . . . . .  g  g  g  g  g  g  g  g  g  g  g  g  g  g  g  g  g  g  g  g  g  g  g  g  g  g  g  g  g  g  g  g  g  g  g  g       * * * * * * 0 0 0 0 0 0 . . . . . . ) ) ) ) ) ) + + + + + + 4 4 4 4 4 4 % % % % % %_& _& _& _& _&x _& _& _& _& _&r   