
    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    U/home/james-whalen/.local/lib/python3.13/site-packages/ccxt/async_support/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                 b   #    U R                  U5      I Sh  vN nU R                  U5      $  N7f)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
N)publicGetPairsparse_marketsr   paramsresponses      r   fetch_marketsbtcalpha.fetch_markets  s2      ,,V44  !!(++! 5s   /-/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                    #    U R                  5       I Sh  vN   U R                  U5      I Sh  vN nU R                  X15      $  N. N7f)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>`
N)load_marketspublicGetTickerparse_tickers)r   r  r   r   s       r   fetch_tickersbtcalpha.fetch_tickersj  sG      !!!--f55" !!(44% 	"5   A	AA	AA	A	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	                  XS5      $  NU N7f)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>`
Npairr   )r  r   r  extendparse_ticker)r   r   r   r   requestr   s         r   fetch_tickerbtcalpha.fetch_ticker  ss      !!!V$F4L
 --dkk'.JKK   22' 	"
 Ls!   A0A,?A0A.A0.A0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       I Sh  vN   U R                  U5      nSUS   0nU(       a  X%S'   X%S'   U R                  U R                  XS5      5      I Sh  vN nU R	                  XdS   SSSS	S
5      $  Nl N7f)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
N	pair_namer   
limit_sell	limit_buyr   r*  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 88W9UVV$$Xh/?ufV]_ghh 	" Ws"   BBAB%B&BB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   bidasksrI  rJ  rK  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   rW  r   r?  timestampRawr"  priceStringamountStringr   r[  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       I Sh  vN   Sn0 nUb  U R                  U5      nUS   US'   Ub  X6S'   U R                  U R                  Xd5      5      I Sh  vN nU R	                  XuX#5      $  Ne N7f)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   rf  r   r   r   r  tradess           r   fetch_tradesbtcalpha.fetch_trades   s      !!![[(F$TlGFO$G..t{{7/KLL  >> 	" M"   B A<AB %A>&B >B codec                    #    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                  XeX#SS05      $  NH N7f)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   rn  rf  r   r   rq  r   s          r   fetch_depositsbtcalpha.fetch_deposits7  sl      !!!}}T*H0088 &&x5&R[I\]] 	" 9s!   A#A.A#A!A#!A#c                    #    U R                  5       I Sh  vN   Sn0 nUb  U R                  U5      nUS   US'   U R                  U R                  Xd5      5      I Sh  vN nU R	                  XuX#SS05      $  Na N7f)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  rq  privateGetWithdrawsr  rs  )r   rn  rf  r   r   rq  r  r   s           r   fetch_withdrawalsbtcalpha.fetch_withdrawalsT  s      !!!}}T*H%-d^GM"11$++g2NOO &&x5&R^I_``% 	" Ps"   A<A8AA<A:A<:A<transactionrq  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"  rq  statusr   r  r&  networkaddress	addressToaddressFromtagtagTotagFromr   txidr   comment)internalr]  updated)safe_timestampr  r=  r  r
  parse_transaction_status)r   r|  rq  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timer0  r'  r(  r1  volume)r  r
  )r   ohlcvr   s      r   parse_ohlcvbtcalpha.parse_ohlcv  sn     v.UF+UF+UE*UG,UH-
 	
r   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b  XGS'   Ub  U R	                  US-  5      US'   U R                  U R                  Xu5      5      I Sh  vN 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

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
Nr   )r  r   r   i  rf  )r  r   r  r   r^  publicGetChartsPairTypeChartr  parse_ohlcvs)	r   r   r  rf  r   r   r   r  r   s	            r   fetch_ohlcvbtcalpha.fetch_ohlcv  s      !!!V$4L$$T__iK
 $G#00>GG::4;;w;WXX   9UKK% 	" Ys"   B.B*A;B.B,B.,B.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   rq  reserveusedbalancetotal)rM  rN  r  r  accountsafe_balance)r   r   rR  rS  r  r  rn  r  s           r   parse_balancebtcalpha.parse_balance  s    )q#h-(AkG))':>J**:6DllnG"..w	BGFO#//CGG"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://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>`
N)r  privateGetWalletsr  r   s      r   fetch_balancebtcalpha.fetch_balance  sE      !!!//77!!(++ 	"7r  c                 2    SSSS.nU R                  X!U5      $ )Nr0  r  closed)123r  r  s      r   parse_order_statusbtcalpha.parse_order_status  s'    

 &99r   rZ  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   rZ  rj  rY  r   r   clientOrderIdr&  r"  r   r   postOnlyr[  r   r   filled	remaining)r]  r  lastTradeTimestampr7  )r  r;  	safe_boolr  safe_integerr  safe_string_n
safe_valuer_  
safe_orderr=  )r   rZ  r   r?  r   r  r"  r   r  r  r   r~  r   rj  r[  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   r[  r   r   c                 :  #    US:X  a  [        U R                  S-   5      eU R                  5       I Sh  vN   U R                  U5      nUS   UUU R	                  X5      S.nU R                  U R                  X5      5      I Sh  vN 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
$  N N7f)
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 supportedNr   )r  r   r   r   r   r   0)r   r   r  r   price_to_precisionprivatePostOrderr  jsonr  strr   	string_gtr   )r   r   r   r[  r   r   r   r   r  r   rZ  orderAmounts               r   create_orderbtcalpha.create_orderG  s     8tww)LLMM!!!V$4L,,V;	
 ..t{{7/KLL	"tww}tyy/BBCC  2%/*$+$5$5k3$G$GxV++F3h 	" Ms#   2DDADDBDDr   c                    #    SU0nU R                  U R                  XC5      5      I Sh  vN nU R                  U5      $  N7f)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>`
rZ  N)privatePostOrderCancelr  r  )r   r   r   r   r  r   s         r   cancel_orderbtcalpha.cancel_orderh  sJ      R
 44T[[5QRR )) Ss   (AA A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5      $  NA N7f)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>`
Nr   )r  privateGetOrderIdr  r  )r   r   r   r   r  rZ  s         r   fetch_orderbtcalpha.fetch_order~  s_      !!!"
 ,,T[[-IJJ&& 	" Ks!   AA+AAAAc                   #    U R                  5       I Sh  vN   0 nSnUb  U R                  U5      nUS   US'   Ub  X5S'   U R                  U R                  XT5      5      I Sh  vN nU R	                  XvX#5      $  Ne N7f)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   rf  r   r   r  r   orderss           r   fetch_ordersbtcalpha.fetch_orders  s      !!![[(F$TlGFO$G//G0LMM  >> 	" Nrm  c           	      h   #    SS0nU R                  XX0R                  XT5      5      I Sh  vN $  N7f)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  Nr  r  r   r   rf  r   r   r  s         r   fetch_open_ordersbtcalpha.fetch_open_orders  7      c
 &&ve[[=YZZZZ   )202c           	      h   #    SS0nU R                  XX0R                  XT5      5      I Sh  vN $  N7f)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  Nr  r  s         r   fetch_closed_ordersbtcalpha.fetch_closed_orders  r  r  c                   #    U R                  5       I Sh  vN   0 nUb  U R                  U5      nUS   US'   Ub  X5S'   U R                  U R                  XT5      5      I Sh  vN nU R	                  USX#5      $  Nd N7f)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  ri  )r   r   rf  r   r   r  r   rj  s           r   fetch_my_tradesbtcalpha.fetch_my_trades  s      !!![[(F$TlGFO$G224;;w3OPP  u<< 	" Qs"   A?A;AA?#A=$A?=A?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_paramsrN  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   rn  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   rG  r   rU  r   rd  rk  r   r   rt  rz  r   r  r  listr  r  r   r  r  r  r   r  r   r   floatr   r  r  r  r  r  r  r  r  r  r:  r  __static_attributes____classcell__)r   s   @r   r   r      s   ~# ~@ *, ,V ,69
4 9
F 9
v 6:" 57 5 5< 68 3 3F 3>(4 ( (6 (T @DB iS i iS\ i, 9 hq / /v / /b <@d[] ? ?S ? ?bfglbm ?. 04$UYbd ^ ^C ^s ^imnyiz ^: 37TX\eg aC as aRU alpq|l} a@+
T +
X +
Q\ +
Z:s :
 
4 
( ?CQUdhqs L L L3 L^a Lx|  ~B  yC LB
) 
) *, , ,: :D Dv D DL mqy{  I Y X] fi B 9=R *S *# *, 8<B 'C ' '$ 04$UYbd ? ?C ?s ?imnsit ?. 59tZ^gi [c [ [TW [nrsxny [" 7;\`ik [ [3 [VY [ptuzp{ [" 37TX\eg =C =s =RU =,# &eBSW P0# s  c TX `c  r   r   )" ccxt.async_support.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>r2     sP    6 .  l  l  l  l  l  * . ) 4 %tx tr   