
    !:h/;                       d dl mZ d dlmZ d dlmZmZmZmZm	Z	m
Z
mZmZmZmZmZmZmZmZmZmZmZ d dlmZ d dlmZ d dlmZ d dlmZ d dlmZ d d	lmZ d d
lmZ d dlmZ d dlm Z  d dlm!Z! d dl"m#Z# d dl$m%Z%  G d dee      Z&y)    )Exchange)ImplicitAPI)AnyBalancesCurrencyDepositAddressIntMarketNumOrder	OrderBook	OrderSide	OrderTypeStrStringsTickerTickersTradeTransaction)List)ExchangeError)PermissionDenied)ArgumentsRequired)
BadRequest)	BadSymbol)InsufficientFunds)InvalidOrder)NotSupported)RateLimitExceeded)	TICK_SIZE)Precisec                       e Zd Zdef fdZi fdefdZi fdee   fdZ	defdZ
ddi fdeded	edee   fd
Zdi fded	edefdZdddi fdeded	edee   fdZdGdedefdZi fdedefdZdi fdedefdZd Zi fdededefdZi fdedefdZi fd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!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#Z(ddi fdedededededefd$Z)dGd%e*dede%fd&Z+d'e!fd(Z,d)e!fd*Z-dddi fde!ded	efd+Z.dGd,e*dedefd-Z/i fd.ede0fd/Z1dGd0e2de0fd1Z3di fd.eded2ede4fd3Z5d4 Z6dddi fd.e!ded	edee4   fd5Z7dddi fd.e!ded	edee4   fd6Z8dddi fd.e!ded	edee4   fd7Z9dGd8e*d0e2de4fd9Z:d'e!fd:Z;d; Z<i fde=fd<Z>de=fd=Z?d>d?i ddfd@Z@d.eAdAedBedCedDe*dEefdFZB xZCS )Halpacareturnc                 T	   | j                  t        t        |          i ddddddg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d0dd1dd2dd3dd4dd5dd6dd7dd8dd9dd:dd;dd<di d=dd>dd?dd@ddAddBddCddDddEddFddGddHddIddJddKddLddMdi dNddOddPddQddRddSddTddUddVddWddXddYddZdd[dd\dd]dd^di d_dd`ddaddbddcdddddeddfddgddhddiddjddkddlddmddnddodi dpddqddrddsddtdduddvddwddxddyddzdd{dd|dd}dd~ddddddddddddddd	di dg dg dg dddgg ddidg didg diddddddddddddddddddddt        dddddddd| j                  d      | j                  d      | j                  d      | j                  d      g| j                  d      | j                  d      g| j                  d      | j                  d      g| j                  d      | j                  d      g| j                  d      | j                  d      g| j                  d      | j                  d      g| j                  d      | j                  d      g| j                  d      | j                  d      gg| j                  d      | j                  d      g| j                  d      | j                  d      g| j                  d      | j                  d      g| j                  d      | j                  d      g| j                  d      | j                  d      g| j                  d      | j                  d      g| j                  d      | j                  d      g| j                  d      | j                  d      ggddidddiddg ddddÜdd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ddddd˜ddddd̜ddddddΜddddddddϜdddd dddddМddidӜ	d d dԜd d dԜd՜dt        t        t        t        t        t        dלt        t        d؜dٜ      S )Nidr#   nameAlpaca	countriesUS	rateLimitiM  hostnamezalpaca.marketsproTurlszOhttps://github.com/user-attachments/assets/e9476df8-a450-4c3e-ab9a-1a7794219e1bzhttps://alpaca.marketszhttps://broker-api.{hostname}zhttps://api.{hostname}zhttps://data.{hostname})brokertradermarketz%https://broker-api.sandbox.{hostname}zhttps://paper-api.{hostname}zhttps://alpaca.markets/docs/z,https://docs.alpaca.markets/docs/crypto-fees)logowwwapitestdocfeeshasCORSFspotmarginswapfutureoption	addMarginborrowCrossMarginborrowIsolatedMarginborrowMargincancelAllOrderscancelOrdercloseAllPositionsclosePositioncreateMarketBuyOrdercreateMarketBuyOrderWithCostcreateMarketOrderWithCostcreateOrder$createOrderWithTakeProfitAndStopLoss&createOrderWithTakeProfitAndStopLossWscreateReduceOnlyOrdercreateStopOrdercreateTriggerOrder	editOrderfetchBalancefetchBidsAsksfetchBorrowInterestfetchBorrowRatefetchBorrowRateHistoriesfetchBorrowRateHistoryfetchBorrowRatesfetchBorrowRatesPerSymbolfetchClosedOrdersfetchCrossBorrowRatefetchCrossBorrowRatesfetchCurrenciesfetchDepositAddressfetchDepositAddressesByNetworkfetchDepositsfetchDepositsWithdrawalsfetchFundingHistoryfetchFundingIntervalfetchFundingIntervalsfetchFundingRatefetchFundingRateHistoryfetchFundingRatesfetchGreeksfetchIndexOHLCVfetchIsolatedBorrowRatefetchIsolatedBorrowRatesfetchIsolatedPositionsfetchL1OrderBookfetchL2OrderBookfetchLeveragefetchLeveragesfetchLeverageTiersfetchLiquidationsfetchLongShortRatiofetchLongShortRatioHistoryfetchMarginAdjustmentHistoryfetchMarginModefetchMarginModesfetchMarketLeverageTiersfetchMarketsfetchMarkOHLCVfetchMarkPricesfetchMyLiquidationsfetchMySettlementHistoryfetchMyTrades
fetchOHLCVfetchOpenInterestfetchOpenInterestHistoryfetchOpenInterestsfetchOpenOrderfetchOpenOrdersfetchOptionfetchOptionChain
fetchOrderfetchOrderBookfetchOrdersfetchPositionfetchPositionHistoryfetchPositionModefetchPositionsfetchPositionsForSymbolfetchPositionsHistoryfetchPositionsRiskfetchPremiumIndexOHLCVfetchSettlementHistoryfetchStatusfetchTickerfetchTickers	fetchTimefetchTradesfetchTradingFeefetchTradingFeesfetchTransactionFeesfetchTransactionsfetchTransfersfetchVolatilityHistoryfetchWithdrawalsreduceMargin)	repayCrossMarginrepayIsolatedMarginsandboxsetLeverage	setMarginsetMarginModesetPositionModetransferwithdrawr4   private)z
v2/account	v2/ordersv2/orders/{order_id}v2/positions!v2/positions/{symbol_or_asset_id}zv2/account/portfolio/historyv2/watchlistsv2/watchlists/{watchlist_id}v2/watchlists:by_namev2/account/configurationszv2/account/activitiesz%v2/account/activities/{activity_type}zv2/calendarzv2/clockz	v2/assetszv2/assets/{symbol_or_asset_id}z'v2/corporate_actions/announcements/{id}z"v2/corporate_actions/announcementsz
v2/walletsv2/wallets/transfers)r   r   r   r   r   )r   r   r   r   r   )r   r   r   r   r   r   z%v2/watchlists/{watchlist_id}/{symbol})getpostputpatchdeleter   )zv1beta3/crypto/{loc}/barsz v1beta3/crypto/{loc}/latest/barsz&v1beta3/crypto/{loc}/latest/orderbooksz"v1beta3/crypto/{loc}/latest/quotesz"v1beta3/crypto/{loc}/latest/tradeszv1beta3/crypto/{loc}/quoteszv1beta3/crypto/{loc}/snapshotszv1beta3/crypto/{loc}/trades)zv1beta1/corporate-actionszv1beta1/forex/latest/rateszv1beta1/forex/rateszv1beta1/logos/{symbol}zv1beta1/newsz$v1beta1/screener/stocks/most-activesz%v1beta1/screener/{market_type}/moverszv2/stocks/auctionszv2/stocks/barszv2/stocks/bars/latestz$v2/stocks/meta/conditions/{ticktype}zv2/stocks/meta/exchangeszv2/stocks/quoteszv2/stocks/quotes/latestzv2/stocks/snapshotszv2/stocks/tradeszv2/stocks/trades/latestzv2/stocks/{symbol}/auctionszv2/stocks/{symbol}/barszv2/stocks/{symbol}/bars/latestzv2/stocks/{symbol}/quotesz v2/stocks/{symbol}/quotes/latestzv2/stocks/{symbol}/snapshotzv2/stocks/{symbol}/tradesz v2/stocks/{symbol}/trades/latest)publicr   
timeframes1min3min5min15min30min1H2H4H6H8H12H1D3D1W1M)1m3m5m15m30m1h2h4h6h8h12h1d3d1wr   precisionModerequiredCredentials)apiKeysecretr7   tradingz0.0015z0.00250100000z0.0022500000z0.00201000000z0.00181000000025000000z0.001350000000z0.0012	100000000z0.001z0.0008z0.0005z0.0002z0.00)takermaker)	tierBased
percentager   r   tiersheaderszAPCA-PARTNER-IDccxtoptionsCBSE)r   FTXGNSSERSXgtcz	ccxt_{id})defaultExchange	exchangesdefaultTimeInForceclientOrderIdfeatures)lastmarkindex)triggerPriceTypeprice)IOCFOKPOGTD)
marginModetriggerPricer   triggerDirectionstopLossPricetakeProfitPriceattachedStopLossTakeProfittimeInForcehedgedtrailingleveragemarketBuyRequiresPricemarketBuyByCostselfTradePreventionicebergd   i )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    )	r   rJ   createOrdersr}   r   r   r   rY   r~   )linearinverse)r:   r<   r=   
exceptions)z
forbidden.4041000040010001401100004031000042910000)zInvalid format for parameterzInvalid symbol)exactbroad)deep_extendsuperr#   describer    parse_numberr   r   r   r   r   r   )self	__class__s    E/var/www/html/turnos/venv/lib/python3.12/site-packages/ccxt/alpaca.pyr!  zalpaca.describe   sC   fd < > RA
(RA
HRA
 $RA
 RA
 (RA
 4RA
 i/=67 F<7
 6FRA
4  ppp %p 	p
 %p %p Up $Up 'p p "4p tp $Up  p 'p  /!p" ,T#p$ t%p& 7'p( 9%)p* (+p, "4-p. %d/p0 T1p2 3p4  5p6 &u7p8 "59p: +E;p< )%=p> #E?p@ ,UApB $TCpD 'EpF (GpH "5IpJ &tKpL 1%MpN  OpP +DQpR &uSpT 'UpV (WpX #EYpZ *5[p\ $U]p^ u_p` "5apb *5cpd +Eepf )%gph #Dipj #Ekpl  mpn !%opp %eqpr $Uspt &uupv -ewpx /ypz "5{p| #E}p~ +Ep@ ApB !%CpD "5EpF &uGpH +EIpJ  KpL dMpN $UOpP +EQpR %eSpT !%UpV "4WpX uYpZ #E[p\ d]p^ !$_p` tapb  cpd 'epf $Ugph !%ipj *5kpl (mpn %eopp )%qpr )%spt uupv twpx ypz T{p| t}p~ "5p@ #EApB 'CpD $UEpF !%GpH )%IpJ #DKpL MpN %*',$"!&#(! _p5RA
V   ,!  37"#O0 2j  	     *maWRA
Z [RA
| Y}RA
~ "$RA
F !%"&!..x8!..x8 "..s3T5F5Fx5PQ!..x8$:K:KH:UV!..x8$:K:KH:UV!..y94;L;LX;VW!..z:D<M<Mh<WX!..z:D<M<Mh<WX!..z:D<M<Mh<WX!..{;T=N=Nw=WX	" "..s3T5F5Fx5PQ!..x8$:K:KH:UV!..x8$:K:KG:TU!..y94;L;LX;VW!..z:D<M<Mh<WX!..z:D<M<Mh<WX!..z:D<M<Mh<WX!..{;T=N=Nv=VW	"GRA
B	 !6C	RA
H	 #) ',!,
I	RA
^	 #&+(,,0,1).+0 )-(,)-1
 &*7 $(#'"&#(	( #($($)27+0/4#(7$: %)&+!$$*%+*/& ',#($)*/	# ',!$#($)*/( ',!$$*%+#($)*/$ ',!$$*,0%+#($)*/	*  #OJX ##
 ##aT_	RA
H "2 , * 0 1 1 5?&/IRA
 R R	    c                     | j                  |      }| j                  |d      }|dd }t        |      dz
  }t        |      dz
  }||| }| j                  |      | j	                  |      dz  dz  z
  }|S )a  
        fetches the current integer timestamp in milliseconds from the exchange server
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns int: the current integer timestamp in milliseconds from the exchange server
        	timestampr            i  r  )traderPrivateGetV2Clocksafe_stringlen	parse8601parse_to_numeric)	r#  paramsresponser(  	localTimejetlagStrStartjetlagStrEndjetlagisos	            r%  
fetch_timezalpaca.fetch_time  s     //7 $$X{;	aO	Y!+9~)>,7nnY'$*?*?*G$*NQU*UU
r&  c                 p    ddd}| j                  | j                  ||            }| j                  |      S )a  
        retrieves data on all markets for alpaca

        https://docs.alpaca.markets/reference/get-v2-assets

        :param dict [params]: extra parameters specific to the exchange api endpoint
        :returns dict[]: an array of objects representing market data
        cryptoactive)asset_classstatus)traderPrivateGetV2Assetsextendparse_markets)r#  r1  requestassetss       r%  fetch_marketszalpaca.fetch_markets  sA     $
 ..t{{7F/KL. !!&))r&  c                 `   | j                  |d      }|j                  d      }| j                  |d      }| j                  |d      }| j                  |d      }| j                  |      }| j                  |      }||dk(  rd}|dz   |z   }	| j                  |d      }
|
d	k(  }| j                  |d
      }| j                  |d      }| j                  |d      }i d|d|	d|d|dd d|d|dd dddddd ddddddd	|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symbol/classr      	us_equityUSDr=  r;  min_order_sizemin_trade_incrementprice_incrementr&   basequotesettlebaseIdquoteIdsettleIdtyper:   Tr;   r<   Fr=   r>   contractr  )amountr   )minmax)r  rV  r   cost)
r  contractSizeexpiryexpiryDatetimestrike
optionType	precisionlimitscreatedinfo)r-  splitsafe_currency_codesafe_number)r#  assetmarketIdparts
assetClassrQ  rR  rN  rO  rE  r=  r;  	minAmountrV  r   s                  r%  parse_marketzalpaca.parse_market  s(   * ##E84s#%%eW5
!!%+""5!,&&v.''0 =Z;6Ee#!!%2H$$$U,<=	!!%)>?  (9:0
(0
f0
 D0
 U	0

 d0
 f0
 w0
 0
 F0
 D0
 d0
 E0
 e0
 e0
 f0
  !0
" d#0
$  "   
 %
  
  $ _0
 0	
r&  NrE  sincer  c                    | j                          | j                  |      }|d   }| j                  |dd      }| j                  |dd      }||d}	| j                  |ddg      }d}
|dk(  re|| j	                  |      |	d<   |||	d	<   | j                  | j                  |	|            }| j                  |d
i       }| j                  ||g       }
nn|dk(  rK| j                  | j                  |	|            }| j                  |d
i       }| j                  ||i       }
|
g}
nt        | j                  dz   |z   dz         | j                  |
|||      S )a  
        get the list of most recent trades for a particular symbol

        https://docs.alpaca.markets/reference/cryptotrades
        https://docs.alpaca.markets/reference/cryptolatesttrades

        :param str symbol: unified symbol of the market to fetch trades for
        :param int [since]: timestamp in ms of the earliest trade to fetch
        :param int [limit]: the maximum amount of trades to fetch
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :param str [params.loc]: crypto location, default: us
        :param str [params.method]: method, default: marketPublicGetV1beta3CryptoLocTrades
        :returns Trade[]: a list of `trade structures <https://docs.ccxt.com/#/?id=public-trades>`
        r&   locusmethod%marketPublicGetV1beta3CryptoLocTradessymbolsrn  Nstartr  trades+marketPublicGetV1beta3CryptoLocLatestTradesz  fetchTrades() does not support ze, marketPublicGetV1beta3CryptoLocTrades and marketPublicGetV1beta3CryptoLocLatestTrades are supported)load_marketsr1   r-  omitiso8601rq  r?  	safe_dict	safe_listrv  r   r&   parse_trades)r#  rE  rl  r  r1  r1   rg  rn  rp  rA  symbolTradesr2  ru  s                r%  fetch_tradeszalpaca.fetch_tradesC  s    	V$$<vud3!!&(4[\
 6E8#45<< #'<<#6  #( AA$++gW]B^_H" ^^Hh;F>>&(B?LDDGGT[]cHdeH ^^Hh;F>>&(B?L(>Ltww)KKfT  X     @  @  vueDDr&  c           	         | j                          | j                  |      }|d   }| j                  |dd      }||d}| j                  | j	                  ||            }| j                  |di       }	| j                  |	|i       }
| j                  | j                  |
d            }| j                  |
|d   |dd	d
d      S )a  
        fetches information on open orders with bid(buy) and ask(sell) prices, volumes and other data

        https://docs.alpaca.markets/reference/cryptolatestorderbooks

        :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
        :param str [params.loc]: crypto location, default: us
        :returns dict: A dictionary of `order book structures <https://github.com/ccxt/ccxt/wiki/Manual#order-book-structure>` indexed by market symbols
        r&   rn  ro  rr  
orderbookstrE  baps)rw  r1   r-  /marketPublicGetV1beta3CryptoLocLatestOrderbooksr?  rz  r/  parse_order_book)r#  rE  r  r1  r1   r&   rn  rA  r2  r  rawOrderbookr(  s               r%  fetch_order_bookzalpaca.fetch_order_book  s     	V$D\vud3
 GGT[]cHdeL ^^HlB?
~~j"b9NN4#3#3L##FG	$$\6(3CYPSUXZ]_bccr&  r   c                    | j                          | j                  |      }|d   }| j                  |dd      }| j                  |dd      }	||d}
| j                  |ddg      }d}|	dk(  r|||
d<   || j	                  |      |
d	<   | j                  | j
                  ||      |
d
<   | j                  | j                  |
|            }| j                  |di       }| j                  ||g       }nn|	dk(  rK| j                  | j                  |
|            }| j                  |di       }| j                  ||i       }|g}nt        | j                  dz   |	z   dz         | j                  |||||      S )a_  
        fetches historical candlestick data containing the open, high, low, and close price, and the volume of a market

        https://docs.alpaca.markets/reference/cryptobars
        https://docs.alpaca.markets/reference/cryptolatestbars

        :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 alpha api endpoint
        :param str [params.loc]: crypto location, default: us
        :param str [params.method]: method, default: marketPublicGetV1beta3CryptoLocBars
        :returns int[][]: A list of candles ordered, open, high, low, close, volume
        r&   rn  ro  rp  #marketPublicGetV1beta3CryptoLocBarsrr  Nr  rt  	timeframebars)marketPublicGetV1beta3CryptoLocLatestBarsz fetchOHLCV() does not support za, marketPublicGetV1beta3CryptoLocBars and marketPublicGetV1beta3CryptoLocLatestBars are supported)rw  r1   r-  rx  yyyymmddr   r  r?  rz  r{  r  r   r&   parse_ohlcvs)r#  rE  r  rl  r  r1  r1   rg  rn  rp  rA  ohlcvsr2  r  s                 r%  fetch_ohlcvzalpaca.fetch_ohlcv  s     	V$$<vud3!!&(4YZ
 6E8#45:: #(  #'==#7 #'#3#3DOOYPY#ZGK ??GU[@\]H< >>(FB7D^^D(B7FBBEEdkkRY[aFbcH" >>(FB7D^^D(B7FXFtww)JJVS  Wz   z  {  {  E5IIr&  r1   c           	          | j                  |d      }| j                  |      }|| j                  |d      | j                  |d      | j                  |d      | j                  |d      | j                  |d      gS )Nr  ohlcv)r-  r/  re  )r#  ohlcvr1   datetimer(  s        r%  parse_ohlcvzalpaca.parse_ohlcv$  s     ##E3/NN8,	UC(UC(UC(UC(UC(
 	
r&  c                     | j                          | j                  |      }| j                  |g|      }| j                  ||      S )a  
        fetches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market

        https://docs.alpaca.markets/reference/cryptosnapshots-1

        :param str symbol: unified symbol of the market to fetch the ticker for
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :param str [params.loc]: crypto location, default: us
        :returns dict: a `ticker structure <https://docs.ccxt.com/#/?id=ticker-structure>`
        )rw  rE  fetch_tickersrz  )r#  rE  r1  tickerss       r%  fetch_tickerzalpaca.fetch_ticker<  sC     	V$$$fXv6~~gv..r&  rs  c           
         |t        | j                  dz         | j                          | j                  |      }| j	                  |dd      }| j                  |      }dj                  |      |d}| j                  |d      }| j                  | j                  ||            }g }| j                  |di       }t        |j                               }	t        dt        |	            D ]  }
|	|
   }| j                  |      }| j                  ||      }| j                  |d	i       }| j                  |d
i       }| j                  |di       }| j                  |di       }| j	                  |d      }| j!                  i d|d|d   d| j#                  |      d|d| j	                  |d      d| j	                  |d      d| j	                  |d      d| j	                  |d      d| j	                  |d      d| j	                  |d      d| j	                  |d      d | j	                  |d!      d"| j	                  |d#      d$| j	                  |d%      d&| j	                  |d#      d'dd(dd| j	                  |d)      | j	                  |d*      d+|      }|j%                  |        | j'                  |d|      S ),a  
        fetches price tickers for multiple markets, statistical information calculated over the past 24 hours for each market

        https://docs.alpaca.markets/reference/cryptosnapshots-1

        :param str[] symbols: unified symbols of the markets to fetch tickers for
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :param str [params.loc]: crypto location, default: us
        :returns dict: a dictionary of `ticker structures <https://docs.ccxt.com/#/?id=ticker-structure>`
        Nz+ fetchTickers() requires a symbols argumentrn  ro  ,rr  	snapshotsr   dailyBarprevDailyBarlatestQuotelatestTrader  rb  rE  r(  r  highr  lowr  bidbp	bidVolumebsaskap	askVolumeasvwapvwopenr  closer  r   r  previousClosechanger   r  n)average
baseVolumequoteVolume)r   r&   rw  market_symbolsr-  
market_idsjoinrx  (marketPublicGetV1beta3CryptoLocSnapshotsr?  rz  listkeysranger.  safe_marketsafe_tickerr/  appendfilter_by_array)r#  rs  r1  rn  idsrA  r2  resultsr  	marketIdsirg  r1   entryr  r  r  r  r  tickers                       r%  r  zalpaca.fetch_tickersL  s6    ?#DGG.[$[\\%%g.vud3oog&xx}
 65)@@WV\A]^j NN8["=	)*	q#i.) 	#A |H%%h/FNN9h7E~~eZ<H>>%DL..rBK..rBK''S9H%% ''&*' T^^H5' H	'
 ((37' t''#6' t''T:' T--k4@' t''T:' T--k4@' ((48' ((37' ))(C8' ((c:'  !1!1,!D'  $!'" d#'$  "..x=#//#>)'* +F, NN6"?	#@ ##GXw??r&  c                     | j                  | j                  d      }| j                         }|j                  d      }dj	                  |      }| j                  |d|i      }| j                  |d|      }|S )Nr   - r&   )r-  r   uuidrc  r  implode_params)r#  r1  clientOrderIdprefixr  rh  	random_iddefaultClientIdr   s           r%  generate_client_order_idzalpaca.generate_client_order_id  sp    "..t||_Myy{

3GGEN	--.AD)CTU((/Rr&  siderY  c                 v    | j                          d|i}| j                  |d|dd| j                  ||            S )a  
        create a market order by providing the symbol, side and cost

        https://docs.alpaca.markets/reference/postorder

        :param str symbol: unified symbol of the market to create an order in
        :param str side: 'buy' or 'sell'
        :param float cost: how much you want to trade in units of the quote currency
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: an `order structure <https://docs.ccxt.com/#/?id=order-structure>`
        rY  r1   r   Nrw  create_orderr?  )r#  rE  r  rY  r1  reqs         r%  create_market_order_with_costz$alpaca.create_market_order_with_cost  sE     	D
   4D$++cSYBZ[[r&  c                 v    | j                          d|i}| j                  |dddd| j                  ||            S )a  
        create a market buy order by providing the symbol and cost

        https://docs.alpaca.markets/reference/postorder

        :param str symbol: unified symbol of the market to create an order in
        :param float cost: how much you want to trade in units of the quote currency
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: an `order structure <https://docs.ccxt.com/#/?id=order-structure>`
        rY  r1   buyr   Nr  r#  rE  rY  r1  r  s        r%  !create_market_buy_order_with_costz(alpaca.create_market_buy_order_with_cost  sE     	D
   5!T4;;sTZC[\\r&  c                 v    | j                          d|i}| j                  |dd|d| j                  ||            S )a  
        create a market sell order by providing the symbol and cost

        https://docs.alpaca.markets/reference/postorder

        :param str symbol: unified symbol of the market to create an order in
        :param float cost: how much you want to trade in units of the quote currency
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: an `order structure <https://docs.ccxt.com/#/?id=order-structure>`
        rY  r1   sellNr  r  s        r%  "create_market_sell_order_with_costz)alpaca.create_market_sell_order_with_cost  sF     	D
   64t{{SVX^G_``r&  rT  rV  r   c                 X   | j                          | j                  |      }|d   }|||d}	| j                  |ddg      }
|
O|j                  d      dk\  rd}nt	        | j
                  dz   |z   d	z         | j                  ||
      |	d<   ||	d
<   |j                  d      dk\  r| j                  ||      |	d<   | j                  |d      }|(| j                  |d      }| j                  ||      |	d<   n| j                  ||      |	d<   | j                  | j                  d      }| j                  |d|      |	d<   | j                  |ddg      }| j                  |      |	d<   | j                  |dg      }| j                  | j                  |	|            }| j                  ||      S )at  
        create a trade order

        https://docs.alpaca.markets/reference/postorder

        :param str symbol: unified symbol of the market to create an order in
        :param str type: 'market', 'limit' or 'stop_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
        :param float [params.triggerPrice]: The price at which a trigger order is triggered at
        :param float [params.cost]: *market orders only* the cost of the order in units of the quote currency
        :returns dict: an `order structure <https://docs.ccxt.com/#/?id=order-structure>`
        r&   )rE  r  rT  r   
stop_pricer  r   
stop_limitz0 createOrder() does not support stop orders for z- orders, only stop_limit orders are supportedrT  limit_pricerY  notionalqtyr   r  time_in_forceclient_order_idr   )rw  r1   safe_string_nfindr   r&   price_to_precisionr-  rx  cost_to_precisionamount_to_precisionr   r  traderPrivatePostV2Ordersr?  parse_order)r#  rE  rT  r  rV  r   r1  r1   r&   rA  r   newTyperY  
defaultTIForders                  r%  r  zalpaca.create_order  s     	V$D\

 ))&><2PQ#yy!Q&&"477-_#_bf#f  jY  $Y  Z  Z$($;$;FL$QGL!%GFO99W"%)%<%<VU%KGM"/YYvv.F"&"8"8"FGJ!55ffEGEN%%dll4HI
#'#3#3FM:#V 6M>#BC%)%B%B6%J!"6O#45..t{{7F/KLJ v..r&  r&   c                 n    d|i}| j                  | j                  ||            }| j                  |      S )a  
        cancels an open order

        https://docs.alpaca.markets/reference/deleteorderbyorderid

        :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>`
        order_id)"traderPrivateDeleteV2OrdersOrderIdr?  r  )r#  r&   rE  r1  rA  r2  s         r%  cancel_orderzalpaca.cancel_orderN  sA     
 ::4;;wPV;WX ))r&  c                     | j                          | j                  |      }t        |t              r| j	                  |d      S | j                  d|i      gS )a  
        cancel all open orders in a market

        https://docs.alpaca.markets/reference/deleteallorders

        :param str symbol: alpaca cancelAllOrders cannot setting symbol, it will cancel all open orders
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict[]: a list of `order structures <https://docs.ccxt.com/#/?id=order-structure>`
        Nrb  )rw  traderPrivateDeleteV2Orders
isinstancer  parse_orders
safe_order)r#  rE  r1  r2  s       r%  cancel_all_orderszalpaca.cancel_all_orderse  s_     	33F;h%$$Xt44 H!  r&  c                     | j                          d|i}| j                  | j                  ||            }| j                  |d      }| j	                  |      }| j                  ||      S )a  
        fetches information on an order made by the user

        https://docs.alpaca.markets/reference/getorderbyorderid

        :param str id: the 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  rE  )rw  traderPrivateGetV2OrdersOrderIdr?  r-  r  r  )r#  r&   rE  r1  rA  r  rg  r1   s           r%  fetch_orderzalpaca.fetch_orderz  sn     	
 44T[[&5QR##E84!!(+v..r&  c                 |   | j                          ddi}d}|| j                  |      }|d   |d<   | j                  |d      }|&| j                  |d      }| j	                  |      |d<   || j	                  |      |d<   |||d	<   | j                  | j                  ||            }| j                  ||||      S )
aw  
        fetches information on multiple orders made by the user

        https://docs.alpaca.markets/reference/getallorders

        :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
        :param int [params.until]: the latest time in ms to fetch orders for
        :returns Order[]: a list of `order structures <https://docs.ccxt.com/#/?id=order-structure>`
        r=  allNr&   rs  untilendTimeafterr  )rw  r1   safe_integerrx  ry  traderPrivateGetV2Ordersr?  r  )	r#  rE  rl  r  r1  rA  r1   r  r2  s	            r%  fetch_orderszalpaca.fetch_orders  s     	e
 [[(F!'GI!!&'2YYvw/F!%e!4GI#||E2GG$GG00Wf1MNR   65%@@r&  c           	      R    ddi}| j                  |||| j                  ||            S )ah  
        fetch all unfilled currently open orders

        https://docs.alpaca.markets/reference/getallorders

        :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
        :param int [params.until]: the latest time in ms to fetch orders for
        :returns Order[]: a list of `order structures <https://docs.ccxt.com/#/?id=order-structure>`
        r=  r  r  r?  r#  rE  rl  r  r1  rA  s         r%  fetch_open_orderszalpaca.fetch_open_orders  s4     f
   t{{7F7STTr&  c           	      R    ddi}| j                  |||| j                  ||            S )a~  
        fetches information on multiple closed orders made by the user

        https://docs.alpaca.markets/reference/getallorders

        :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
        :param int [params.until]: the latest time in ms to fetch orders for
        :returns Order[]: a list of `order structures <https://docs.ccxt.com/#/?id=order-structure>`
        r=  closedr
  r  s         r%  fetch_closed_orderszalpaca.fetch_closed_orders  s4     h
   t{{7F7STTr&  c                    | j                          d|i}d}	|| j                  |      }	|| j                  ||      |d<   | j                  |ddg      }
|
'| j	                  ||
      |d<   | j                  |d      }|| j	                  ||      |d<   d}| j                  |ddd	      \  }}|||d
<   | j                  |      |d<   | j                  |dg      }| j                  | j                  ||            }| j                  ||	      S )a  
        edit a trade order

        https://docs.alpaca.markets/reference/patchorderbyorderid-1

        :param str id: order id
        :param str [symbol]: unified symbol of the market to create an order in
        :param str [type]: 'market', 'limit' or 'stop_limit'
        :param str [side]: 'buy' or 'sell'
        :param float [amount]: how much of the currency you want to trade in units of the base currency
        :param float [price]: the price for the order, in units of the quote currency, ignored in market orders
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :param str [params.triggerPrice]: the price to trigger a stop order
        :param str [params.timeInForce]: for crypto trading either 'gtc' or 'ioc' can be used
        :param str [params.clientOrderId]: a unique identifier for the order, automatically generated if not sent
        :returns dict: an `order structure <https://docs.ccxt.com/#/?id=order-structure>`
        r  Nr  r   r  r  rP   r  r   r  r  r   )rw  r1   r  r  r  rx  handle_option_and_params_2r  !traderPrivatePatchV2OrdersOrderIdr?  r  )r#  r&   rE  rT  r  rV  r   r1  rA  r1   r   r  r2  s                r%  
edit_orderzalpaca.edit_order  s=   $ 	
 [[(F!55ffEGEN))&><2PQ#$($;$;FL$QGL!YYv~6F%)%<%<VU%KGM""==fkS`bvwV"'2GO$%)%B%B6%J!"6O#4599$++gv:VW&11r&  r  c           
      @   | j                  |d      }| j                  ||      }|d   }| j                  |d      }| j                  |      }| j                  |d      }d }||dd}| j                  |d      }	|	|	j                  d      dk\  rd}	| j                  |d	      }
| j	                  |
      }| j                  i d
| j                  |d
      d| j                  |d      d|d|
dd d|d|d|	d| j                  | j                  |d            dd d| j                  |d      d| j                  |d      d| j                  |d      dd d| j                  |d      d| j                  |d      d| j                  |d      d d ||d |      S )!NrE  r=  
commissionrJ  rY  currency
order_typer  r   submitted_atr&   r   r  r(  r  lastTradeTimeStamprT  r  r  postOnlyr  r   r  r   r  rY  r  filled_avg_pricerV  r  filled
filled_qty)	remainingru  feerb  )r-  r  parse_order_statusr  r/  r  parse_time_in_forcere  )r#  r  r1   rg  rE  alpacaStatusr=  feeValuer   	orderTyper  r(  s               r%  r  zalpaca.parse_order$  sG   N ##E84!!(F3!''x8((6##E<8 !C $$UL9	 ~~g&!+#	##E>:NN8,	  
$""5$/ 
T--e5FG 
  
 	 

 !$ 
 f 
 f 
 I 
 433D4D4DUO4\] 
  
 D$$UF3 
 T%%e]; 
 D,,ULA 
 D 
 t''/AB 
  d&&ue4! 
" d&&ul;# 
$ + 
, - 	r&  r=  c                 :    ddddddd}| j                  |||      S )Nr  r  )pending_newacceptednewpartially_filled	activatedr  r-  r#  r=  statusess      r%  r!  zalpaca.parse_order_statusv  s2    ! &
 &&99r&  r  c                 0    ddi}| j                  |||      S )NdayDayr,  )r#  r  timeInForcess      r%  r"  zalpaca.parse_time_in_force  s%    5
 k;GGr&  c                    | j                          d}ddi}|| j                  |      }| j                  |d      }|&| j                  |d      }| j	                  |      |d<   || j	                  |      |d<   |||d<   | j                  d||      \  }}| j                  | j                  ||            }| j                  ||||      S )a  
        fetch all trades made by the user

        https://docs.alpaca.markets/reference/getaccountactivitiesbyactivitytype-1

        :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 trade structures to retrieve
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :param int [params.until]: the latest time in ms to fetch trades for
        :param str [params.page_token]: page_token - used for paging
        :returns Trade[]: a list of `trade structures <https://docs.ccxt.com/#/?id=trade-structure>`
        Nactivity_typeFILLr  r  	page_size)	rw  r1   r  rx  ry  handle_until_option/traderPrivateGetV2AccountActivitiesActivityTyper?  r|  )	r#  rE  rl  r  r1  r1   rA  r  r2  s	            r%  fetch_my_tradeszalpaca.fetch_my_trades  s     	V
 [[(F!!&'2YYvw/F#||E2GG#||E2GG#(GK 227GVLGGT[]cHde(   65%@@r&  tradec                    | j                  |dd      }| j                  ||      }| j                  |dd      }| j                  |      }| j                  |d      }| j                  |d      }|dk(  rd}n|dk(  rd	}| j                  |d
d      }	| j                  |dd      }
| j	                  || j                  |dd      || j                  |      || j                  |d      d |d|	|
d d d|      S )NSrE  r  transaction_timetksr  Br  r  r  r   r  r  r  r&   r  r   )rb  r&   r(  r  rE  r  rT  r  takerOrMakerr   rV  rY  r   )safe_string_2safe_symbolr/  r-  
safe_tradery  )r#  r:  r1   rg  rE  r  r(  
alpacaSider  priceStringamountStrings              r%  parse_tradezalpaca.parse_trade  s   > %%eS(;!!(F3%%eS2DENN8,	%%eU3
v.D3D((W=))%e<$$UC6"Y/%%eZ8# " 
  	r&  codec                     | j                          | j                  |      }d|d   i}| j                  | j                  ||            }| j	                  ||      S )a  
        fetch the deposit address for a currency associated with self account

        https://docs.alpaca.markets/reference/listcryptofundingwallets

        :param str code: unified currency code
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: an `address structure <https://docs.ccxt.com/#/?id=address-structure>`
        rf  r&   )rw  r  traderPrivateGetV2Walletsr?  parse_deposit_address)r#  rH  r1  r  rA  r2  s         r%  fetch_deposit_addresszalpaca.fetch_deposit_address  s`     	==&Xd^
 11$++gv2NO ))(H==r&  r  c                 D    d }||d   }||d | j                  |d      d dS )Nr&   address)rb  r  networkrN  tagr,  )r#  depositAddressr  parsedCurrencys       r%  rK  zalpaca.parse_deposit_address  s>     %d^N"&''	B
 	
r&  rN  c                 :   | j                  ||      \  }}| j                  |       | j                          | j                  |      }|r|dz   |z   }|d   || j	                  |      d}| j                  | j                  ||            }| j                  ||      S )a  
        make a withdrawal

        https://docs.alpaca.markets/reference/createcryptotransferforaccount

        :param str code: unified currency code
        :param float amount: the amount to withdraw
        :param str address: the address to withdraw to
        :param str tag: a memo for the transaction
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: a `transaction structure <https://docs.ccxt.com/#/?id=transaction-structure>`
        :r&   )rf  rN  rV  )handle_withdraw_tag_and_paramscheck_addressrw  r  number_to_string#traderPrivatePostV2WalletsTransfersr?  parse_transaction)	r#  rH  rV  rN  rP  r1  r  rA  r2  s	            r%  r   zalpaca.withdraw"  s     99#vFV7#==&mc)Gd^++F3

 ;;DKKQW<XY$ %%h99r&  c                 Z   | j                          d }|| j                  |      }| j                  |      }g }t        dt	        |            D ]G  }	||	   }
| j                  |
d      }||k(  r|j                  |
       1|dk(  s7|j                  |
       I | j                  |||||      S )Nr   	directionBOTH)rw  r  "traderPrivateGetV2WalletsTransfersr  r.  r-  r  parse_transactions)r#  rT  rH  rl  r  r1  r  r2  r  r  r  r[  s               r%  fetch_transactions_helperz alpaca.fetch_transactions_helperN  s    }}T*H::6B$ q#h-( 	&AQKE((<ID u%u%	& &&w%OOr&  c                 ,    | j                  d||||      S )ao  
        fetch history of deposits and withdrawals

        https://docs.alpaca.markets/reference/listcryptofundingtransfers

        :param str [code]: unified currency code for the currency of the deposit/withdrawals, default is None
        :param int [since]: timestamp in ms of the earliest deposit/withdrawal, default is None
        :param int [limit]: max number of deposit/withdrawals to return, default is None
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: a list of `transaction structure <https://docs.ccxt.com/#/?id=transaction-structure>`
        r\  r_  r#  rH  rl  r  r1  s        r%  fetch_deposits_withdrawalsz!alpaca.fetch_deposits_withdrawalso  s     --fdE5&QQr&  c                 ,    | j                  d||||      S )a  
        fetch all deposits made to an account

        https://docs.alpaca.markets/reference/listcryptofundingtransfers

        :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 deposit 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>`
        INCOMINGra  rb  s        r%  fetch_depositszalpaca.fetch_deposits}       --j$ufUUr&  c                 ,    | j                  d||||      S )a  
        fetch all withdrawals made from an account

        https://docs.alpaca.markets/reference/listcryptofundingtransfers

        :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 withdrawal 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>`
        OUTGOINGra  rb  s        r%  fetch_withdrawalszalpaca.fetch_withdrawals  rg  r&  transactionc                    | j                  |d      }| j                  |d      }| j                  ||      }| j                  |d      }| j                  |d      }t        j                  ||      }| j	                  |      |d}	i d|d| j                  |d      d| j                  |d	      d
| j                  |      d|d| j                  |d      d| j                  |d      d| j                  |d      d| j                  |d      dd dd dd d| j                  | j                  |d            d| j                  |d      d|d| j                  | j                  |d            dd |	d d dS )N
created_atrf  r7   network_feer  rb  r&   txidtx_hashr(  r  rO  chainrN  
to_address	addressToaddressFromfrom_addressrP  tagTotagFromrT  r[  rV  r  r=  updated)r   commentinternal)	r-  rd  r!   
string_addr"  r/  parse_transaction_typere  parse_transaction_status)
r#  rk  r  r  
currencyIdrH  r7   
networkFeetotalFeer   s
             r%  rY  zalpaca.parse_transaction  s   $ ##K>%%k7;
&&z8<V4%%k=A
%%dJ7%%h/

K
$"";5
 D$$[)<
 1	

 
 t''W=
 t''\B
 ))+|D
 4++KH
 4
 T
 t
 D//0@0@k0Z[
 d&&{H=
 
  d33D4D4D[RZ4[\!
" t#
$ )
 	
r&  c                 4    dddd}| j                  |||      S )Npendingfailedok)
PROCESSINGFAILEDCOMPLETEr,  r-  s      r%  r}  zalpaca.parse_transaction_status  s)    #

 &&99r&  c                 2    ddd}| j                  |||      S )Ndeposit
withdrawal)re  ri  r,  )r#  rT  typess      r%  r|  zalpaca.parse_transaction_type  s&    !$
 tT22r&  c                 f    | j                          | j                  |      }| j                  |      S )a^  
        query for balance and get the amount of funds available for trading or funds locked in orders

        https://docs.alpaca.markets/reference/getaccount-1

        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: a `balance structure <https://docs.ccxt.com/#/?id=balance-structure>`
        )rw  traderPrivateGetV2Accountparse_balance)r#  r1  r2  s      r%  fetch_balancezalpaca.fetch_balance  s4     	11&9b !!(++r&  c                     d|i}| j                         }| j                  |d      }| j                  |      }| j                  |d      |d<   | j                  |d      |d<   |||<   | j                  |      S )Nrb  r  cashfreeequitytotal)accountr-  rd  safe_balance)r#  r2  resultr  r~  rH  s         r%  r  zalpaca.parse_balance  s    ),,.%%h
;
&&z2**8V<++Hh?t  ((r&  r   GETc                    d| j                  ||      z   }| j                  | j                  d   |d            }||ni }|d   dk(  r.| j                          | j                  |d<   | j
                  |d<   | j                  || j                  |            }	|	r8|dk(  s|d	k(  r|d
| j                  |	      z   z  }n| j                  |	      }d|d<   ||z   }||||dS )NrF  r4   r   rH  r   zAPCA-API-KEY-IDzAPCA-API-SECRET-KEYr  DELETE?zapplication/jsonzContent-Type)urlrp  bodyr   )
r  implode_hostnamer.   check_required_credentialsr   r   rx  extract_params	urlencodejson)
r#  pathr4   rp  r1  r   r  endpointr  querys
             r%  signzalpaca.sign"  s    ,,T6::##DIIe$4SV$<=%1'q6Y++-)-G%&-1[[G)*		&$"5"5d";<%Vx%7C$.."777yy'*<'HnfdwOOr&  reasonr  rp  r   r  c
                 V   |y | j                   dz   |z   }
| j                  |d      }| | j                  | j                  d   ||
       | j	                  |dd       }|K| j                  | j                  d   ||
       | j                  | j                  d   ||
       t        |
      y )N rH  r  messager  )r&   r-  throw_exactly_matched_exceptionr  
safe_valuethrow_broadly_matched_exceptionr   )r#  rH  r  r  rp  r   r  r2  requestHeadersrequestBodyfeedback	errorCoder  s                r%  handle_errorszalpaca.handle_errors4  s    
 77S=4'$$Xv6	001I9V^_//(It<001I7T\]001I7T\]))r&  )N)D__name__
__module____qualname__r   r!  r	   r8  r   r
   rC  rk  strr   r~  r   r  r  r  r  r   r  r   r   r  r  r   floatr  r  r  r   r   r  r   r  r  r   r   r  r  r  r  dictr  r!  r"  r9  rG  r   rL  r   rK  r   r   r_  rc  rf  rj  rY  r}  r|  r   r  r  r  intr  __classcell__)r$  s   @r%  r#   r#      s8   S# Sj !# s . $& $*$v, $*LV
V V
p 6:UW FE3 FEs FE# FE\`af\g FEP :>b =ds =d3 =dY =d~ 26DW[df XJ# XJc XJQT XJkoptku XJt
 
4 
0 02 /3 /f /  04B n@W n@7 n@` _a \C \y \PU \$ RT ] ]5 ]" SU a aE a" gksu S/3 S/i S/y S/RW S/`c S/j 37r *s *C *. /32  * 26b /c /3 /( *.Dt\^ FA3 FAc FA FAcghmcn FAP /3TXac U U3 Uc Uhlmrhs U$ 154VZce U# US UPS Ujnotju U$ `drv  @B (2S (2# (2Y (2i (2Y\ (2lo (2TP Pv P Pd	: 	:Hs H -1tRV_a 2Ac 2A 2AC 2Ah9 9v 9 9v 79 ># >^ >2
h 
R` 
& DHPR *:S *:% *:# *:Wb *:XPB 6:[_hj Rs R# RUX Rost  pA R *.Dt\^ V3 Vc V Vcghsct V -1tRV_a Vc V VC Vfjkvfw V1
T 1
X 1
Q\ 1
f:s :3 $& ;,( ;,z) ) &eBSW P$# s  c TX `c r&  r#   N)'ccxt.base.exchanger   ccxt.abstract.alpacar   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   r   r   r   r   r   r   ccxt.base.decimal_to_precisionr    ccxt.base.preciser!   r#    r&  r%  <module>r     s_    ( , q  q  q  q  q  * - . ' & . ) ) . 4 %mX{ mr&  