AI4Finance-Foundation / FinRL

FinRL: Financial Reinforcement Learning. 🔥
https://ai4finance.org
MIT License
9.72k stars 2.36k forks source link

processor_alpaca.py: function: def fetch_latest_data() can be limited to downloading 1 data point? #766

Open marcipops opened 1 year ago

marcipops commented 1 year ago

Currently extending the paper trading with a new data processor so as to integrate with my broker ig.com

They only support downloading a maximum of 10K data points per week (across all stocks), so extremely limited.

I am experimenting downloading data from Yahoo Finance, for training, testing and also fetching the latest data for the state as part of trading ops.

In processor_alpaca.py there's a function:

def fetch_latest_data(
    self, ticker_list, time_interval, tech_indicator_list, limit=100
) -> pd.DataFrame:

I notice it only uses the latest price even though it downloads 100.

    latest_price = price_array[-1]
    latest_tech = tech_array[-1]

It looks like this function will still work properly if I set the limit to 1 - please would you confirm?

If this is the case why download 100 anyway?

Many thanks

Athe-kunal commented 1 year ago

No, I think you should download 100. The last 100 days would help you to calculate the technical indicators. So in the fetch_data function, the latest technical indicators are also returned, so for its calculation, you need the historical data. However, you can download with a smaller limit, as the indicators are calculated at max for the past 24 days (like for MACD).

marcipops commented 1 year ago

@Athe-kunal thank you for your guidance.

I am looking to trade at 1min time interval, but don't see a way to download the last 100 in yf.download()?