Closed alisalama closed 2 weeks ago
~No it's not. ~
you'll at least need fetchOHLCV (with history - otherwise we'll have to disable the exchange manually) - otherwise freqtrade will assume the exchange as not suitable.
A list of required endpoints (what ccxt MUST provide) for freqtrade to even consider the exchange is here: https://github.com/freqtrade/freqtrade/blob/f3e2dcd34205a82c1dfabdaab2aa8f4022564ef1/freqtrade/exchange/common.py#L65
You'll also need either fetchTicker or fetchL2Orderbook. Either of the 2 will work - as long as fetchTicker has bid/ask values - which also provide uptodate information (essentially the orderbook).
not having the orderbok will be a bit limiting - and i doubt alpaca really doesn't offer orderbook ... but that's a different topic
For questions about how to integrate to ccxt, please refer to ccxt. ~If they're not interested in integrating alpaca (they'll reject your PR), your endavor will end at that point anyway.~
(funnily, alpaca does seem to be somewhat in ccxt already - though with a ton of missing endpoints) - so whatever you "tried" - is most likely not going to fit it.
Thanks Matthias. Seems like got the basis to move forward, so will keep going.
OHLCV CCXT Alpaca already has fetch_ohlcv implemented. I have tested just tested the fetch_ohlcv function, works fine, can grab full history from it.(https://github.com/ccxt/ccxt/blob/be60a09df3a28b10bf8cf243cd3c940e08d08c46/python/ccxt/alpaca.py#L561C9-L561C20).
fetchTicker
You'll also need either fetchTicker or fetchL2Orderbook. Either of the 2 will work - as long as fetchTicker has bid/ask values - which also provide uptodate information (essentially the orderbook).
I have implemented fetchTicker + fetchTickers and includes bid/ask/last.
Order Book ccxt Alpaca has fetchOrderBook and fetchL1OrderBook implemented but not FetchL2Orderbook. I will do some investigation on the differences between those, and come back.
I'm fine with the integration to ccxt part, experienced programmer here so no problem. I was mainly looking for data requirement from fetchTicker(s), but looks like what I've implement will be sufficient.
Thanks, Ali
you don't necessarily need fetchTickers - it's only used for some pairlists - not necessary for basic operations
Hi Matthias, I am looking at contributing to CCXT to add Alpaca and to start building out that functionality. I note your comments here (https://github.com/freqtrade/freqtrade/issues/7953#issuecomment-1366399243) and have implemented fetchTicker & fetchTickers for Alpaca in my working copy. fetchTicker returns the below. It essentially returns last / close / bid / bid volume / ask / ask volume.
I just want to confirm that that is enough data for Freqtrade to pick up the prices. I think from https://github.com/freqtrade/freqtrade/blob/f3e2dcd34205a82c1dfabdaab2aa8f4022564ef1/freqtrade/exchange/exchange.py#L1933C2-L1948C20 it is going to use 'last' which is included so that should be ok.
From ccxt docs (https://github.com/ccxt/ccxt/wiki/Manual#ticker-structure), the fetch_ticker should return 24h weighted values, but the 24h rolling values are not available on the Alpaca api endpoints, so have had to use smaller set of values. I note quite a few other exchanges on ccxt library, including coinbase, have only the last/close/bid/ask on fetch_ticker, so I presume it's ok?
Will push ahead with the pull request to ccxt if so.
My eventual goal is to use Freqtrade for stocks through Alpaca, it's both a Crypto and Stocks api, happy to work on my own copy & unsupported, so no bother. I assume theoretically this will work, just have different symbol names. I have been using Freqtrade for crypto for over a year now, it works brilliantly well and is super robust, and I can't find anything nearly as good for stocks.
There is no fetchL2OrderBook equivalent endpoint.
Thanks, Ali