
    E#i                         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  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	IndexTypeIntMarketNumOrder	OrderBook	OrderSide	OrderTypeStrStringsTickerTickersTradeTransaction)List)ExchangeError)InsufficientFunds)InvalidOrder)	TICK_SIZE)Precisec                   p  ^  \ rS rSrS\4U 4S jjr0 4S\\   4S jjrS\	S\4S jr
S0 4S\S\4S	 jjr0 4S
\S\4S jjrS@S\	S\S\4S jjrS0 4S
\S\S\4S jjrSAS\S\S\4S jjrS@S\	S\S\4S jjrSS0 4S
\S\S\S\\   4S jjrSSS0 4S\S\S\S\\   4S jjrSSS0 4S\S\S\S\\   4S jjrS@S\	S\S\4S jjrS\4S jr S@S\S\!4S  jjr"S!SS0 4S
\S"\S\S\S\\!   4
S# jjr#S\$4S$ jr%0 4S\$4S% jjr&S\4S& jr'S@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
\4S0 jjr0SSS0 4S
\S\S\S\\(   4S1 jjr1SSS0 4S
\S\S\S\\(   4S2 jjr2SSS0 4S
\S\S\S\\(   4S3 jjr3SSS0 4S
\S\S\4S4 jjr4S5 r5S6S70 SS4S8 jr6S\7S9\S:\S;\S<\	S=\4S> jr8S?r9U =r:$ )Bbtcalpha   returnc                 *  > U R                  [        [        U ]  5       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	_S.S	_S/S	_S0S	_S1S	_S2S	_S3S	_S4S	_S5S	_S6S	_S7S	_S8S_S9S	_E0 S:S	_S;S	_S<S	_S=S	_S>S	_S?S	_S@S	_SAS	_SBS	_SCS_SDS	_SES	_SFS	_SGS	_SHS_SIS_SJS	_E0 SKS	_SLS	_SMS_SNS	_SOS	_SPS_SQS_SRS_SSS	_STS	_SUS	_SVS	_SWS	_SXS	_SYS	_SZS	_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S	S	S	Sm.ESnSoSpSqSrSsSt.SuSvSw0SxSySzS{S|.S}/ S~Q0/ SQSS/S.S.U R	                  S5      U R	                  S5      S.S0 0S.SS0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	SS S S	S	S	S.S	SS S S S	S	S	S.SS0S.	S S S.S S S.S.[
        0 S[        0S.S.5      $ )Nr   z	BTC-AlphaUSv1CORSspotTmarginFswapfutureoption	addMarginborrowCrossMarginborrowIsolatedMarginborrowMargincancelOrdercloseAllPositionsclosePositioncreateDepositAddresscreateOrder$createOrderWithTakeProfitAndStopLoss&createOrderWithTakeProfitAndStopLossWscreatePostOnlyOrdercreateReduceOnlyOrdercreateStopLimitOrdercreateStopMarketOrdercreateStopOrderfetchBalancefetchBorrowInterestfetchBorrowRatefetchBorrowRateHistoriesfetchBorrowRateHistoryfetchBorrowRatesfetchBorrowRatesPerSymbolfetchClosedOrdersfetchCrossBorrowRatefetchCrossBorrowRatesfetchCurrenciesfetchDepositfetchDepositAddressfetchDepositAddressesfetchDepositAddressesByNetworkfetchDepositsfetchFundingHistoryfetchFundingIntervalfetchFundingIntervalsfetchFundingRatefetchFundingRateHistoryfetchFundingRatesfetchGreeksfetchIndexOHLCVfetchIsolatedBorrowRatefetchIsolatedBorrowRatesfetchIsolatedPositionsfetchL2OrderBook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fetchOrdersfetchPositionfetchPositionHistoryfetchPositionModefetchPositionsfetchPositionsForSymbolfetchPositionsHistoryfetchPositionsRiskfetchPremiumIndexOHLCVfetchSettlementHistoryfetchTickerfetchTickersfetchTradesfetchTradingFeefetchTradingFeesfetchTransferfetchTransfersfetchVolatilityHistoryfetchWithdrawalfetchWithdrawalsreduceMarginrepayCrossMarginrepayIsolatedMarginrepayMarginsetLeverage	setMarginsetMarginMode)setPositionModetransferwithdraw5153060240D)5m15m30m1h4h1dzOhttps://github.com/user-attachments/assets/dce49f3a-61e5-4ba0-a2fe-41d192fd0e5d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/)r   post)publicprivatez0.002)makertakerr   )tradingfundingCBCCashbery)IOCFOKPOGTD)
marginModetriggerPricetriggerPriceTypetriggerDirectionstopLossPricetakeProfitPriceattachedStopLossTakeProfittimeInForcehedgedleveragemarketBuyRequiresPricemarketBuyByCostselfTradePreventiontrailingicebergd   )r   limitdaysBack	untilDayssymbolRequired)r   triggerr   r   i  )r   r   r   r   r   )r   r   r   r   r   r   r   )r   r   r   daysBackCanceledr   r   r   r   r   i  )	sandboxr1   createOrdersrd   rl   ri   rn   r@   re   )linearinverse)r$   r&   r'   zOut of balance)exactbroad)idname	countriesversionhas
timeframesurlsr   r   commonCurrenciesfeaturesprecisionMode
exceptions)deep_extendsuperr   describeparse_numberr   r   )self	__class__s    G/home/james-whalen/.local/lib/python3.13/site-packages/ccxt/btcalpha.pyr   btcalpha.describe   s   h > @jjj %j 	j
 %j %j Uj $Uj 'j j tj $Uj  j 'j tj  7!j" 9%#j$ &u%j& ('j( ')j* (+j, "5-j. /j0 &u1j2 "53j4 +E5j6 )%7j8 #E9j: ,U;j< $T=j> '?j@ (AjB "5CjD EjF &uGjH (IjJ 1%KjL  MjN &uOjP 'QjR (SjT #EUjV *5WjX $UYjZ u[j\ "5]j^ *5_j` +Eajb )%cjd #Dejf  gjh !%ijj %ekjl $Umjn &uojp -eqjr /sjt "5ujv #Ewjx +Eyjz {j| !%}j~ "5j@ &uAjB +ECjD  EjF dGjH $UIjJ +EKjL %eMjN "4OjP uQjR #ESjT dUjV !$WjX tYjZ  [j\ ']j^ $U_j` !%ajb *5cjd (ejf %egjh )%ijj )%kjl tmjn ojp tqjr "5sjt #Eujv  wjx !%yjz )%{j| "5}j~ #Dj@ AjB #ECjD &uEjF uGjH uIjJ UKjL  MjN $)!!SjX  j7 /=5=	  	 !'8 "..w7!..w7
  z!
  %&+(-,0,1).+06:#(#("'#(	( #($)27+0/4$)#()$, %)&+!$$(%)*/& ',#($)*/	# ',!%#($)*/( ',!%$(%)#($)*/$ ',!%$(,0%)#($)*/	*  #ACJ ##
 ##SM\ '$&7o}C
 } }	    c                 F    U R                  U5      nU R                  U5      $ )z
retrieves data on all markets for btcalpha

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_marketsbtcalpha.fetch_markets  s'     &&v.  !!(++r   marketc                    U R                  US5      nU R                  US5      nU R                  US5      nU R                  U5      nU R                  U5      nU R                  US5      nU R                  U5      nU R                  US5      n	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 S S S S S U R                  U R                  U R                  US5      5      5      U R                  U R                  U5      5      S.S S S.U R                  U	5      U R	                  US5      S.U R                  U5      S S.U R                  [
        R                  " X5      5      S S.S.S US.
E$ ) Nr   	currency1	currency2price_precisionminimum_order_sizer   symbol/basequotesettlebaseIdquoteIdsettleIdtyper$   Tr%   Fr&   r'   r(   activecontractr   amount_precision)amountprice)minmaxmaximum_order_size)r   r   r   cost)
r   contractSizeexpiryexpiryDatetimestrike
optionType	precisionlimitscreatedinfo)safe_stringsafe_currency_codeparse_precisionr   safe_numberr   
string_mul)
r   r   r   r   r   r   r   pricePrecision
priceLimitamountLimits
             r   parse_marketbtcalpha.parse_market/  sD   ff-!!&+6""6;7&&v.''0))&2CD)).9
&&v/C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,@,@AQAQRXZlAm,no**4+?+?+QR  
  ,,[9++F4HI
  ,,Z8
  ,,W-?-?
-XY$ _0
 0	
r   Nsymbolsc                 f    U R                  5         U R                  U5      nU R                  X15      $ )a  

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_tickersbtcalpha.fetch_tickersj  s3     	''/" !!(44r   r   c                     U R                  5         U R                  U5      nSUS   0nU R                  U R                  XB5      5      nU R	                  XS5      $ )a  

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_tickerbtcalpha.fetch_ticker  s\     	V$F4L
 ''G(DE   22r   tickerc           	      L   U R                  US5      n[        [        R                  " US5      5      nU R                  US5      nU R	                  XRS5      nU R                  US5      nU R                  0 SU_SUS   _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S _SS _SU_SU_SS _SU R                  US5      _SS _S S U R                  US5      S.EU5      $ )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   r  r   timestampStrr!  marketIdr$  s          r   r  btcalpha.parse_ticker  s    ''<**<CD	##FF3!!(C8/ !
F!
fX&!
 !
 Y/	!

 D$$VV4!
 4##FE2!
 4##FE2!
 !
 4##FF3!
 !
 D!
 D!
 T!
 D!
 T!
  d&&vv6!!
" $#!
$ ++FE:)!
* + 	r   r   c           	          U R                  5         U R                  U5      nSUS   0nU(       a  X%S'   X%S'   U R                  U R                  XS5      5      nU R	                  XdS   SSSS	S
5      $ )a  

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_bookbtcalpha.fetch_order_book  s~     	V$
 $)L!#(K 224;;w3OP$$Xh/?ufV]_ghhr   priceKey	amountKeycountOrIdKeyc                     / n[        S[        U5      5       H1  nX   nU(       d  M  UR                  U R                  XrU5      5        M3     U$ )Nr   )rangelenappendparse_bid_ask)r   bidasksrH  rI  rJ  resultibidasks           r   parse_bids_asksbtcalpha.parse_bids_asks  sH    q#g,'AZFvd009MN ( r   tradec                    U R                  US5      nU R                  X2S5      nU R                  US5      nU R                  [        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S	5      n	U R                  UUUU R                  U5      US
   USU	S UUS S S.U5      $ )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   rV  r   r>  timestampRawr!  priceStringamountStringr   rZ  s
             r   parse_tradebtcalpha.parse_trade  s    2 ##E62!!(C8''{;%%g&8&8y&QR	&&ug6''x8eT*!!%F;"Y/X&  " 
  	r   sincec                     U R                  5         Sn0 nUb  U R                  U5      nUS   US'   Ub  X6S'   U R                  U R                  Xd5      5      nU R	                  XuX#5      $ )a  
get the list of most recent trades for a particular symbol

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   re  r   r   r   r  tradess           r   fetch_tradesbtcalpha.fetch_trades   su     	[[(F$TlGFO$G((W)EF  >>r   codec                     U R                  5         SnUb  U R                  U5      nU R                  U5      nU R                  XeX#SS05      $ )a  
fetch all deposits made to an account

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   rl  re  r   r   ro  r   s          r   fetch_depositsbtcalpha.fetch_deposits7  sV     	}}T*H**62 &&x5&R[I\]]r   c                     U R                  5         Sn0 nUb  U R                  U5      nUS   US'   U R                  U R                  Xd5      5      nU R	                  XuX#SS05      $ )a  
fetch all withdrawals made from an account

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  ro  privateGetWithdrawsr  rq  )r   rl  re  r   r   ro  r  r   s           r   fetch_withdrawalsbtcalpha.fetch_withdrawalsT  sr     	}}T*H%-d^GM"++DKK,HI &&x5&R^I_``r   transactionro  c                 ~   U R                  US5      nU R                  US5      nU R                  US5      n0 SU R                  US5      _SU_SU_SU R                  U5      _SS _SS _S	S _S
S _SS _SS _SS _SU R                  XB5      _SU R	                  US5      _SS _SS _SU R                  U5      _SS _S S S S.E$ )Nr!  ro  statusr   r  r%  networkaddress	addressToaddressFromtagtagTotagFromr   txidr   comment)internalr\  updated)safe_timestampr  r<  r  r
  parse_transaction_status)r   rz  ro  r!  
currencyIdstatusIds         r   parse_transactionbtcalpha.parse_transactiont  sU   & ''[A	%%k:>
##K:
$"";5
K
 
 Y/	

 t
 t
 
 4
 4
 T
 t
 //
E
 d&&{H=
 D
 D
  d33H=!
" t#
$ )
 	
r   r|  c                 6    SSSSSS.nU R                  X!U5      $ )Npendingokfailedcanceled)1020r   4050r  r   r|  statusess      r   r  !btcalpha.parse_transaction_status  s-    
 &99r   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timer/  r&  r'  r0  volume)r  r
  )r   ohlcvr   s      r   parse_ohlcvbtcalpha.parse_ohlcv  sn     v.UF+UF+UE*UG,UH-
 	
r   r   	timeframec                 0   U R                  5         U R                  U5      nUS   U R                  U R                  X"5      S.nUb  XGS'   Ub  U R	                  US-  5      US'   U R                  U R                  Xu5      5      nU R                  XX#U5      $ )a@  
fetches historical candlestick data containing the open, high, low, and close price, and the volume of a market

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   r   i  re  )r  r   r  r   r]  publicGetChartsPairTypeChartr  parse_ohlcvs)	r   r   r  re  r   r   r   r  r   s	            r   fetch_ohlcvbtcalpha.fetch_ohlcv  s     	V$4L$$T__iK
 $G#00>GG44T[[5QR   9UKKr   c                 .   SU0n[        S[        U5      5       Hh  nX   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'   XrU'   Mj     U R                  U5      $ )Nr  r   ro  reserveusedbalancetotal)rL  rM  r  r  accountsafe_balance)r   r   rQ  rR  r  r  rl  r  s           r   parse_balancebtcalpha.parse_balance  s    )q#h-(AkG))':>J**:6DllnG"..w	BGFO#//CGG"4L )   ((r   c                 f    U R                  5         U R                  U5      nU R                  U5      $ )a:  
query for balance and get the amount of funds available for trading or funds locked in orders

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_balancebtcalpha.fetch_balance  s1     	))&1!!(++r   c                 2    SSSS.nU R                  X!U5      $ )Nr/  r  closed)123r  r  s      r   parse_order_statusbtcalpha.parse_order_status  s'    

 &99r   rY  c                    U R                  US5      nU R                  X2S5      nUS   nU R                  USS5      nS nU(       a  U R                  US5      nOU R	                  US5      nU R                  US5      nU R                  US5      nU R                  US	5      n	U R                  US
5      n
U R                  U R                  US5      5      nU R                  U/ SQ5      nU R                  US5      nU R                  USS5      nU R                  0 SU_SS _SU R                  U5      _SU_SU_SU_SS_SS _SS _SU_SU_SS _SS _SU
_SU	_SU_SU_S US S S.EU5      $ )Nr  r#  r   successFdater   r   amount_filledamount_originalr|  )oidr   rY  ri  rX  r   r   clientOrderIdr%  r!  r   r   postOnlyrZ  r   r   filled	remaining)r\  r  lastTradeTimestampr6  )r  r:  	safe_boolr  safe_integerr  safe_string_n
safe_valuer^  
safe_orderr<  )r   rY  r   r>  r   r  r!  r   r  r  r   r|  r   ri  rZ  s                  r   parse_orderbtcalpha.parse_order  s   : ##E62!!(C8!..	59	++E6:I))%8I  0$$UH5	!!%9!!%):;(()9)9%)JK'=>1!!%F;  
" 
T 
 Y/ 
 	 

 f 
 f 
 G 
 4 
  
 D 
 U 
 D 
 D 
 f 
 f 
  ! 
" f# 
$ "&+ 
, - 	r   r   rZ  r   r   c                 
   US:X  a  [        U R                  S-   5      eU R                  5         U R                  U5      nUS   UUU R	                  X5      S.nU R                  U R                  X5      5      n	U	S   (       d*  [        U R                  S-   U R                  U	5      -   5      eU R                  X5      n
[        U
S   5      n[        R                  " US5      (       a  U
S   OUnU R                  U5      U
S'   U
$ )	a@  

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 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>`
r   z! only limits orders are supportedr   )r  r   r   r   r   r   0)r   r   r  r   price_to_precisionprivatePostOrderr  jsonr  strr   	string_gtr   )r   r   r   rZ  r   r   r   r   r  r   rY  orderAmounts               r   create_orderbtcalpha.create_orderG  s     8tww)LLMMV$4L,,V;	
 ((W)EF	"tww}tyy/BBCC  2%/*$+$5$5k3$G$GxV++F3hr   r   c                 l    SU0nU R                  U R                  XC5      5      nU R                  U5      $ )aI  

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>`
rY  )privatePostOrderCancelr  r  )r   r   r   r   r  r   s         r   cancel_orderbtcalpha.cancel_orderh  s>     R
 ..t{{7/KL ))r   c                     U R                  5         SU0nU R                  U R                  XC5      5      nU R                  U5      $ )a^  

https://btc-alpha.github.io/api-docs/#retrieve-single-order

fetches information on an order made by the user
:param str id: the order id
: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  r  )r   r   r   r   r  rY  s         r   fetch_orderbtcalpha.fetch_order~  sH     	"
 &&t{{7'CD&&r   c                     U R                  5         0 nSnUb  U R                  U5      nUS   US'   Ub  X5S'   U R                  U R                  XT5      5      nU R	                  XvX#5      $ )a  

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   re  r   r   r  r   orderss           r   fetch_ordersbtcalpha.fetch_orders  su     	[[(F$TlGFO$G))$++g*FG  >>r   c           	      L    SS0nU R                  XX0R                  XT5      5      $ )a  
fetch all unfilled currently open orders

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|  r  r  r  r   r   re  r   r   r  s         r   fetch_open_ordersbtcalpha.fetch_open_orders  .     c
   {{77STTr   c           	      L    SS0nU R                  XX0R                  XT5      5      $ )a  
fetches information on multiple closed orders made by the user

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|  r  r  r  s         r   fetch_closed_ordersbtcalpha.fetch_closed_orders  r  r   c                     U R                  5         0 nUb  U R                  U5      nUS   US'   Ub  X5S'   U R                  U R                  XT5      5      nU R	                  USX#5      $ )a  
fetch all trades made by the user

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  rh  )r   r   re  r   r   r  r   ri  s           r   fetch_my_tradesbtcalpha.fetch_my_trades  sr     	[[(F$TlGFO$G,,T[[-IJ  u<<r   c                 "    U R                  5       $ N)milliseconds)r   s    r   noncebtcalpha.nonce  s      ""r   r   GETc           
         U R                  U R                  U R                  X@R                  U5      5      5      5      nU R                  S   S   S-   nUS:w  a  US-  nXR                  X5      -  nSS0nUS:X  a  [        U5      (       a  US	U-   -  nOU R                  5         U R                  n	US
:X  a  SUS'   UnX-  n	O[        U5      (       a  US	U-   -  nU R                  US'   U R                  U R                  U	5      U R                  U R                  5      [        R                  5      US'   [        U R                  5       5      US'   XXeS.$ )Nr   r   r   r   zv1/Acceptzapplication/jsonr   ?POSTz!application/x-www-form-urlencodedzContent-TypezX-KEYzX-SIGNzX-NONCE)urlmethodbodyheaders)	urlencodekeysortomitextract_paramsr   implode_paramsrM  check_required_credentialsapiKeyhmacencodesecrethashlibsha256r  r  )
r   pathr   r  r   r   r  queryr  payloads
             r   signbtcalpha.sign  sA   t||DIIf>Q>QRV>W,XYZiiv&,005LC""400/0(?5zzsU{"++-kkG*M'UsU{"#{{GG $		$++g*>DKK@XZaZhZh iGH!$TZZ\!2GIdOOr   reasonr  r  r   r  c
                     Uc  g U R                  US5      n
U
b[  U R                  S-   U-   nU R                  U R                  S   X5        U R	                  U R                  S   X5        [        U5      eg )Nerrorr  r   r   )r  r   throw_exactly_matched_exceptionr   throw_broadly_matched_exceptionr   )r   rl  r  r  r  r   r  r   requestHeadersrequestBodyr  feedbacks               r   handle_errorsbtcalpha.handle_errors  sw       73ww}t+H001I5[001I5[))r    r  )r         );__name__
__module____qualname____firstlineno__r   r   r   r
   r   dictr  r   r   r  r  r   r  r  r	   r   rF  r   rT  r   rc  rj  r   r   rr  rx  r   r  r  listr  r  r   r  r  r  r   r  r   r   floatr   r  r  r  r  r  r  r  r  r  r9  r  __static_attributes____classcell__)r   s   @r   r   r      s   ~# ~@ $& ,$v, ,69
4 9
F 9
v 04B 5W 57 5< 02 33 3f 3>(4 ( (6 (T :>b is i3 iY i, 9 hq / /v / /b 6:UW ?3 ?s ?# ?\`af\g ?. *.Dt\^ ^3 ^c ^ ^cghsct ^: -1tRV_a ac a aC afjkvfw a@+
T +
X +
Q\ +
Z:s :
 
4 
( 9=4^bkm L# L# LS LX[ Lrvw{r| LB
) 
) $& ,( ,: :D Dv D DL gksu 3 i y RW `c B 37r *s *C *, 26b 'c '3 '$ *.Dt\^ ?3 ?c ? ?cghmcn ?. /3TXac U U3 Uc Uhlmrhs U" 154VZce U# US UPS Ujnotju U" -1tRV_a =c = =C =,# &eBSW P0# s  c TX `c  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   r   typingr   ccxt.base.errorsr   r   r   ccxt.base.decimal_to_precisionr   ccxt.base.preciser   r   r  r   r   <module>r/     sP    ( .  l  l  l  l  l  * . ) 4 %tx tr   