alpacahq / alpacahq/alpaca-backtrader-api
Is it possible to convert AlpacaData to pandas/numpy/CSV data?
- Lenguaje dominante
- Python
- Estrellas
- 702
- Forks
- 160
- Métricas de merge de PR
- Sin PR fusionados en 30 d
Descripción
I adapted the following code from the `README.md`:
```
import alpaca_backtrader_api
import backtrader as bt
from datetime import datetime
ALPACA_API_KEY = "..."
ALPACA_SECRET_KEY = "..."
ALPACA_PAPER = True
store = alpaca_backtrader_api.AlpacaStore(key_id = ALPACA_API_KEY,
secret_key = ALPACA_SECRET_KEY,
paper = ALPACA_PAPER)
data = store.getdata(dataname = "AAPL",
historical = True,
fromdate = datetime(2015, 1, 1),
timeframe = bt.TimeFrame.Days)
```
The resulting `data` of type `AlpacaData` works fine with cerebro, but I'm struggling to figure out how it's possible to use directly. `len(data)` returns `0`. My goal is simply to perform some general analyses like identifying local extrema to help in developing my strategy. I guess I could download the data once through `alpaca-backtrader-api` for backtesting, and then again through the Alpaca API for other analyses, but isn't there any way to just do it once to get an `AlpacaData` object (which I guess is a Backtrader data feed?), and then convert that to a numpy series, or a pandas DataFrame, or CSV?
Apologies if I'm missing something obvious. I'm new to both Backtrader and Alpaca. I wanted to first ask the Backtrader community, but unfortunately their forum is not letting me register because the CAPTCHA isn't loading.
Guía de contribución
No hay ninguna guía de contribución indexada para este repositorio
Evaluación
Este issue todavía no se ha evaluado.