
    ei<                       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&dS )    )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dee         f
dZdId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)dId&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.dId-e*dedefd.Z/i fd/ede0fd0Z1dId1e2de0fd2Z3di fd/eded3ed4e!de4f
d5Z5d6 Z6dddi fd/e!ded	edee4         fd7Z7dddi fd/e!ded	edee4         fd8Z8dddi fd/e!ded	edee4         fd9Z9dId:e*d1e2de4fd;Z:d(e!fd<Z;d= Z<i fde=fd>Z>de=fd?Z?d@dAi ddfdBZ@d/eAdCedDedEedFe*dGefdHZB xZCS )Jalpacareturnc                 
   |                      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|                     d          |                     d          |                     d          |                     d          g|                     d          |                     d          g|                     d          |                     d          g|                     d          |                     d          g|                     d          |                     d          g|                     d          |                     d          g|                     d          |                     d          g|                     d          |                     d          gg|                     d          |                     d          g|                     d          |                     d          g|                     d          |                     d          g|                     d          |                     d          g|                     d          |                     d          g|                     d          |                     d          g|                     d          |                     d          g|                     d          |                     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    W/var/www/html/volatility/venv/lib/python3.11/site-packages/ccxt/async_support/alpaca.pyr!  zalpaca.describe   s   fd 3 3 < < > > 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 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 p 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 p 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 p 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 p 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 pN %*',$"!&#(! _p p p5RA
V       ,! ! !      37"# # #O0  0 2j  	  	  	         * *ma aWRA
Z  [RA
| Y}RA
~ "$ $RA
F !%"&!..x88!..x88 "..s33T5F5Fx5P5PQ!..x88$:K:KH:U:UV!..x88$:K:KH:U:UV!..y994;L;LX;V;VW!..z::D<M<Mh<W<WX!..z::D<M<Mh<W<WX!..z::D<M<Mh<W<WX!..{;;T=N=Nw=W=WX	" "..s33T5F5Fx5P5PQ!..x88$:K:KH:U:UV!..x88$:K:KG:T:TU!..y994;L;LX;V;VW!..z::D<M<Mh<W<WX!..z::D<M<Mh<W<WX!..z::D<M<Mh<W<WX!..{;;T=N=Nv=V=VW	"  GRA
B	 !6C	RA
H	 #)   ',!,
 
I	RA
^	 #&+(,,0,1).+0 )-(,)-1 1
 &*7 7 $(#'"&#(	( ( #($($)27+0/4#(7$ $: %)&+!$$*%+*/& & ',#($)*/	# # ',!$#($)*/( ( ',!$$*%+#($)*/$ $ ',!$$*,0%+#($)*/	* 	*  #OJ JX ## 
 ## aT T_	RA
H "2 , * 0 1 1  5?&/  IRA
 R R R	    c                 >  K   |                      |           d{V }|                     |d          }|dd         }t          |          dz
  }t          |          dz
  }|||         }|                     |          |                     |          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
        N	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       55f======== $$X{;;	adO	Y!+9~~)>,67nnY''$*?*?*G*G$*NQU*UU
r&  c                    K   ddd}|                      |                     ||                     d{V }|                     |          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statusN)traderPrivateGetV2Assetsextendparse_markets)r#  r1  requestassetss       r%  fetch_marketszalpaca.fetch_markets  se       $
 
 44T[[&5Q5QRRRRRRRR. !!&)))r&  c                    |                      |d          }|                    d          }|                      |d          }|                      |d          }|                      |d          }|                     |          }|                     |          }||dk    rd}|dz   |z   }	|                      |d          }
|
d	k    }|                     |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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  st   * ##E844s##%%eW55
!!%++""5!,,&&v..''00 =Z;66Ee#!!%2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
 0
 0	
r&  NrE  sincer  c                 P  K   |                                   d{V  |                     |          }|d         }|                     |dd          }|                     |dd          }||d}	|                     |ddg          }d}
|dk    r||                     |          |	d<   |||	d	<   |                     |                     |	|                     d{V }|                     |d
i           }|                     ||g           }
n|dk    ra| 	                    |                     |	|                     d{V }|                     |d
i           }|                     ||i           }
|
g}
nt          | j        dz   |z   dz             |                     |
|||          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>`
        Nr&   locusmethod%marketPublicGetV1beta3CryptoLocTradessymbolsrn  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3!!&(4[\\
 
 6E8#455<<< #'<<#6#6  #( !GGT[]cHdHdeeeeeeeeH" ^^Hh;;F>>&(B??LLDDD!MMdkkZaciNjNjkkkkkkkkH ^^Hh;;F>>&(B??L(>LLtw)KKfT  X     @  @  @  vueDDDr&  c           	        K   |                                   d{V  |                     |          }|d         }|                     |dd          }||d}|                     |                     ||                     d{V }|                     |di           }	|                     |	|i           }
|                     |                     |
d                    }|                     |
|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
        Nr&   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3
 
 MMdkkZaciNjNjkkkkkkkkL ^^HlB??
~~j"b99NN4#3#3L##F#FGG	$$\6(3CYPSUXZ]_bcccr&  r   	timeframec                   K   |                                   d{V  |                     |          }|d         }|                     |dd          }|                     |dd          }	||d}
|                     |ddg          }d}|	dk    r|||
d<   ||                     |          |
d	<   |                     | j        ||          |
d
<   |                     |                     |
|                     d{V }|                     |di           }| 	                    ||g           }n|	dk    ra| 
                    |                     |
|                     d{V }|                     |di           }|                     ||i           }|g}nt          | j        dz   |	z   dz             |                     |||||          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
        Nr&   rn  ro  rp  #marketPublicGetV1beta3CryptoLocBarsrr  r  rt  r  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3!!&(4YZZ
 
 6E8#455::: #(  #'==#7#7 #'#3#3DOYPY#Z#ZGK !EEdkkRY[aFbFbccccccccH< >>(FB77D^^D(B77FFBBB!KKDKKX_agLhLhiiiiiiiiH" >>(FB77D^^D(B77FXFFtw)JJVS  Wz   z  {  {  {  E5IIIr&  r1   c           	      0   |                      |d          }|                     |          }||                     |d          |                     |d          |                     |d          |                     |d          |                     |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                    K   |                                   d{V  |                     |          }|                     |g|           d{V }|                     ||          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>`
        N)rw  rE  fetch_tickersrz  )r#  rE  r1  tickerss       r%  fetch_tickerzalpaca.fetch_ticker<  sz       !!!!!!!!!V$$**F8V<<<<<<<<~~gv...r&  rs  c           
        K   |t          | j        dz             |                                  d{V  |                     |          }|                     |dd          }|                     |          }d                    |          |d}|                     |d          }|                     | 	                    ||                     d{V }g }| 
                    |di           }t          |                                          }	t          dt          |	                    D ])}
|	|
         }|                     |          }| 
                    ||          }| 
                    |d	i           }| 
                    |d
i           }| 
                    |di           }| 
                    |di           }|                     |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|          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  s      ?#DG.[$[\\\!!!!!!!!!%%g..vud33oog&&xx}}
 
 65))FFt{{SZ\bGcGcddddddddj NN8["==	))**	q#i..)) 	# 	#A |H%%h//FNN9h77E~~eZ<<H>>%DDL..rBBK..rBBK''S99H%% ''&*' T^^H55' H	'
 ((377' t''#66' t''T::' T--k4@@' t''T::' T--k4@@' ((488' ((377' ))(C88' ((c::'  !1!1,!D!D'  $!'" d#'$  "..x==#//#>>)' ' '* + F, NN6""""##GXw???r&  c                    |                      | j        d          }|                                 }|                    d          }d                    |          }|                     |d|i          }|                      |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  s}    "..t|_MMyy{{

3GGENN	--.AD)CTUU((/RRr&  siderY  c                    K   |                                   d{V  d|i}|                     |d|dd|                     ||                     d{V 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>`
        NrY  r1   r   rw  create_orderr?  )r#  rE  r  rY  r1  reqs         r%  create_market_order_with_costz$alpaca.create_market_order_with_cost  sz       !!!!!!!!!D
 &&vxq$TWY_H`H`aaaaaaaaar&  c                    K   |                                   d{V  d|i}|                     |dddd|                     ||                     d{V 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>`
        NrY  r1   buyr   r  r#  rE  rY  r1  r  s        r%  !create_market_buy_order_with_costz(alpaca.create_market_buy_order_with_cost  sz       !!!!!!!!!D
 &&vx4UXZ`IaIabbbbbbbbbr&  c                    K   |                                   d{V  d|i}|                     |dd|d|                     ||                     d{V 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>`
        NrY  r1   sellr  r  s        r%  "create_market_sell_order_with_costz)alpaca.create_market_sell_order_with_cost  sz       !!!!!!!!!D
 &&vxtT[[Y\^dMeMefffffffffr&  rT  rV  r   c                 
  K   |                                   d{V  |                     |          }|d         }|||d}	|                     |ddg          }
|
W|                    d          dk    rd}nt	          | j        d	z   |z   d
z             |                     ||
          |	d<   ||	d<   |                    d          dk    r|                     ||          |	d<   |                     |d          }|0|                     |d          }| 	                    ||          |	d<   n| 
                    ||          |	d<   |                     | j        d          }|                     |d|          |	d<   |                     |ddg          }|                     |          |	d<   |                     |dg          }|                     |                     |	|                     d{V }|                     ||          S )ar  
        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>`
        Nr&   )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  sL       !!!!!!!!!V$$D\
 

 ))&><2PQQ#yy!!Q&&&"47-_#_bf#f  jY  $Y  Z  Z  Z$($;$;FL$Q$QGL!%GFO99W""%)%<%<VU%K%KGM"//YYvv..F"&"8"8"F"FGJ!55ffEEGEN%%dl4HII
#'#3#3FM:#V#V 6M>#BCC%)%B%B6%J%J!"6O#45544T[[&5Q5QRRRRRRRRJ v...r&  r&   c                    K   d|i}|                      |                     ||                     d{V }|                     |          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_idN)"traderPrivateDeleteV2OrdersOrderIdr?  r  )r#  r&   rE  r1  rA  r2  s         r%  cancel_orderzalpaca.cancel_orderN  s`       
 @@WV\A]A]^^^^^^^^ )))r&  c                    K   |                                   d{V  |                     |           d{V }t          |t                    r|                     |d          S |                     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       !!!!!!!!!99&AAAAAAAAh%% 	$$Xt444 H!   r&  c                 "  K   |                                   d{V  d|i}|                     |                     ||                     d{V }|                     |d          }|                     |          }|                     ||          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>`
        Nr  rE  )rw  traderPrivateGetV2OrdersOrderIdr?  r-  r  r  )r#  r&   rE  r1  rA  r  rg  r1   s           r%  fetch_orderzalpaca.fetch_orderz  s       !!!!!!!!!
 ::4;;wPV;W;WXXXXXXXX##E844!!(++v...r&  c                   K   |                                   d{V  ddi}d}| |                     |          }|d         |d<   |                     |d          }|.|                     |d          }|                     |          |d<   ||                     |          |d<   |||d	<   |                     |                     ||                     d{V }|                     ||||          S )
au  
        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>`
        Nr=  allr&   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2YYvw//F!%e!4!4GI#||E22GG$GG66t{{7F7S7STTTTTTTTR   65%@@@r&  c           	      r   K   ddi}|                      ||||                     ||                     d{V S )af  
        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  Nr  r?  r#  rE  rl  r  r1  rA  s         r%  fetch_open_orderszalpaca.fetch_open_orders  sQ       f
 &&vueT[[RX=Y=YZZZZZZZZZr&  c           	      r   K   ddi}|                      ||||                     ||                     d{V 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=  closedNr
  r  s         r%  fetch_closed_orderszalpaca.fetch_closed_orders  sQ       h
 &&vueT[[RX=Y=YZZZZZZZZZr&  c                   K   |                                   d{V  d|i}d}	||                     |          }	||                     ||          |d<   |                     |ddg          }
|
/|                     ||
          |d<   |                     |d          }||                     ||          |d<   d}|                     |ddd	          \  }}|||d
<   |                     |          |d<   |                     |dg          }|                     | 	                    ||                     d{V }| 
                    ||	          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>`
        Nr  r  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EEGEN))&><2PQQ#$($;$;FL$Q$QGL!YYv~66F%)%<%<VU%K%KGM""==fkS`bvwwV"'2GO$%)%B%B6%J%J!"6O#455??GU[@\@\]]]]]]]]&111r&  r  c           
         |                      |d          }|                     ||          }|d         }|                      |d          }|                     |          }|                      |d          }d }||dd}|                      |d          }	|	|	                    d          dk    r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 |          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$  s   N ##E844!!(F33!''x88((66##E<88 ! C $$UL99	 ~~g&&!++#	##E>::NN8,,	  
$""5$// 
T--e5FGG 
  
 	 

 !$ 
 f 
 f 
 I 
 433D4D4DUO4\4\]] 
  
 D$$UF33 
 T%%e];; 
 D,,ULAA 
 D 
 t''/ABB 
  d&&ue44! 
" d&&ul;;# 
$ + 
  
  
, -  	r&  r=  c                 B    ddddddd}|                      |||          S )Nr  r  )pending_newacceptednewpartially_filled	activatedr  r-  r#  r=  statusess      r%  r!  zalpaca.parse_order_statusv  s:    ! &
 
 &&999r&  r  c                 8    ddi}|                      |||          S )NdayDayr,  )r#  r  timeInForcess      r%  r"  zalpaca.parse_time_in_force  s(    5
 k;GGGr&  c                   K   |                                   d{V  d}ddi}||                     |          }|                     |d          }|.|                     |d          }|                     |          |d<   ||                     |          |d<   |||d<   |                     d||          \  }}|                     |                     ||                     d{V }|                     ||||          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  s2      !!!!!!!!!V
 [[((F!!&'22YYvw//F#||E22GG#||E22GG#(GK 227GVLLMMdkkZaciNjNjkkkkkkkk(   65%@@@r&  tradec                 J   |                      |dd          }|                     ||          }|                      |dd          }|                     |          }|                     |d          }|                     |d          }|dk    rd}n|dk    rd	}|                      |d
d          }	|                      |dd          }
|                     ||                      |dd          ||                     |          ||                     |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  sM   > %%eS(;;!!(F33%%eS2DEENN8,,	%%eU33
v..DD3D((W==))%e<<$$UC66"Y//%%eZ88# " 
  
   	r&  codec                   K   |                                   d{V  |                     |          }d|d         i}|                     |                     ||                     d{V }|                     ||          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>`
        Nrf  r&   )rw  r  traderPrivateGetV2Walletsr?  parse_deposit_address)r#  rH  r1  r  rA  r2  s         r%  fetch_deposit_addresszalpaca.fetch_deposit_address  s       !!!!!!!!!==&&Xd^
 77GV8T8TUUUUUUUU ))(H===r&  r  c                 R    d }||d         }||d |                      |d          d dS )Nr&   address)rb  r  networkrN  tagr,  )r#  depositAddressr  parsedCurrencys       r%  rK  zalpaca.parse_deposit_address  sF     %d^N"&''	BB
 
 	
r&  rN  rP  c                   K   |                      ||          \  }}|                     |           |                                  d{V  |                     |          }|r|dz   |z   }|d         ||                     |          d}|                     |                     ||                     d{V }|                     ||          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>`
        N: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FV7###!!!!!!!!!==&& 	*mc)Gd^++F33
 

 AA$++gW]B^B^________$ %%h999r&  c                   K   |                                   d {V  d }||                     |          }|                     |           d {V }g }t          dt	          |                    D ]W}	||	         }
|                     |
d          }||k    r|                    |
           <|dk    r|                    |
           X|                     |||||          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@@HHHHHHHH$ q#h--(( 	& 	&AQKE((<<ID  u%%%%u%%%&&w%OOOr&  c                 D   K   |                      d||||           d{V S )am  
        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\  Nr_  r#  rH  rl  r  r1  s        r%  fetch_deposits_withdrawalsz!alpaca.fetch_deposits_withdrawalso  s7       33FD%PVWWWWWWWWWr&  c                 D   K   |                      d||||           d{V 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>`
        INCOMINGNra  rb  s        r%  fetch_depositszalpaca.fetch_deposits}  7       33JeUTZ[[[[[[[[[r&  c                 D   K   |                      d||||           d{V 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>`
        OUTGOINGNra  rb  s        r%  fetch_withdrawalszalpaca.fetch_withdrawals  rg  r&  transactionc                    |                      |d          }|                      |d          }|                     ||          }|                      |d          }|                      |d          }t          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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  sD   $ ##K>>%%k7;;
&&z8<<V44%%k=AA
%dJ77%%h//
 

K
$"";55
 D$$[)<<
 11	

 
 t''W==
 t''\BB
 ))+|DD
 4++KHH
 4
 T
 t
 D//0@0@k0Z0Z[[
 d&&{H==
 
  d33D4D4D[RZ4[4[\\!
" t#
$ )
 
 
 	
r&  c                 <    dddd}|                      |||          S )Npendingfailedok)
PROCESSINGFAILEDCOMPLETEr,  r-  s      r%  r}  zalpaca.parse_transaction_status  s1    #
 

 &&999r&  c                 :    ddd}|                      |||          S )Ndeposit
withdrawal)re  ri  r,  )r#  rT  typess      r%  r|  zalpaca.parse_transaction_type  s.    !$
 
 tT222r&  c                    K   |                                   d{V  |                     |           d{V }|                     |          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>`
        N)rw  traderPrivateGetV2Accountparse_balance)r#  r1  r2  s      r%  fetch_balancezalpaca.fetch_balance  sh       !!!!!!!!!77????????b !!(+++r&  c                     d|i}|                                  }|                     |d          }|                     |          }|                     |d          |d<   |                     |d          |d<   |||<   |                     |          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2**8V<<++Hh??t  (((r&  r   GETc                    d|                      ||          z   }|                     | j        d         |d                            }||ni }|d         dk    r(|                                  | j        |d<   | j        |d<   |                     ||                     |                    }	|	rB|dk    s|d	k    r|d
|                     |	          z   z  }n| 	                    |	          }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:::##DIe$4SV$<==%1''q6Y++---)-G%&-1[G)*		&$"5"5d";";<< 	=%Vx%7%7C$.."7"777yy''*<'HnfdwOOOr&  reasonr  rp  r   r  c
                 t   |d S | j         dz   |z   }
|                     |d          }|"|                     | j        d         ||
           |                     |dd           }|S|                     | j        d         ||
           |                     | j        d         ||
           t          |
          d S )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    4
 7S=4'$$Xv66	001I9V^___//(It<<001I7T\]]]001I7T\]]])))tr&  )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#      s       S# S S S S S Sj ')  S    . *, $* $*V $* $* $* $*LV
V V
 V
 V
 V
p <@d[] FE FE FES FE FEbfglbm FE FE FE FEP @DB =d =dS =d =dS\ =d =d =d =d~ ?CQUdhqs XJ XJ XJ XJ3 XJ^a XJx|  ~B  yC XJ XJ XJ XJt
 
 
4 
 
 
 
0 68 / / /F / / / /  6:" n@ n@7 n@ n@ n@ n@ n@`   eg b b# bY bV[ b b b b$ XZ c cc c c c c c" Y[ g gs g% g g g g" mqy{ S/ S/ S/I S/Y S/X] S/fi S/ S/ S/ S/j 9=R * *S *# * * * *. 59  c    * 8<B / /C / / / / /( 04$UYbd FA FA FAC FAs FAimnsit FA FA FA FAP 59tZ^gi [ [c [ [TW [nrsxny [ [ [ [$ 7;\`ik [ [ [3 [VY [ptuzp{ [ [ [ [$ fjx|  FH (2 (23 (2 (29 (2I (2_b (2ru (2 (2 (2 (2TP P Pv P P P P Pd	: 	: 	: 	: 	:Hs H H H H 37TX\eg 2A 2AC 2As 2ARU 2A 2A 2A 2Ah9 9 9v 9 9 9 9 9v =? > > >> > > > >2
 
h 
R` 
 
 
 
& QU]_ *: *:3 *: *: *:# *:do *: *: *: *:XP P PB <@daenp X XS X X[^ Xuy  {F  vG X X X X 04$UYbd \ \ \C \s \imnyiz \ \ \ \ 37TX\eg \ \C \s \RU \lpq|l} \ \ \ \1
 1
T 1
X 1
Q\ 1
 1
 1
 1
f:s : : : :3 3 3 *, ;, ;, ;, ;, ;, ;,z) ) ) ) ) &eBSW P P P P$# s  c TX `c        r&  r#   N)' ccxt.async_support.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'   6 5 5 5 5 5 , , , , , , q  q  q  q  q  q  q  q  q  q  q  q  q  q  q  q  q  q  q  q  q  q  q  q  q  q  q  q  q  q  q  q  q  q  q  q  q  q       * * * * * * - - - - - - . . . . . . ' ' ' ' ' ' & & & & & & . . . . . . ) ) ) ) ) ) ) ) ) ) ) ) . . . . . . 4 4 4 4 4 4 % % % % % %m m m m mX{ m m m m mr&  