backtrader2 / backtrader

Python Backtesting library for trading strategies
https://www.backtrader.com
GNU General Public License v3.0
221 stars 52 forks source link

YahooDinanceData fromdate, todate fix #70

Closed happydasch closed 2 years ago

happydasch commented 2 years ago

YahooDinanceData fromdate, todate fix

both params are needed in request. added default values if dates not provided, fixed also wrong todate check

neilsmurphy commented 2 years ago

Are we saying that the user should be able to call the data for a backtest without any dates? Would it be preferable to make the user input dates?

happydasch commented 2 years ago

I tried to keep it close to other feeds which work without a fromdate but was also unsure about that. Usually what happens without fromdate is fetching latest data.

neilsmurphy commented 2 years ago

I like this and there was an error in the original code as well. I think this line can be simplified:

else:
    # use a date far away for fromdate if not provided
    period1 = (date(1980, 1, 1) - posix).total_seconds()

to

period1 = 0

No point calculating the integer difference to 1980. Just go back to posix, which when subtracting itself, would be zero.

happydasch commented 2 years ago

i will squash the commits but am having a problem with some data files.

happydasch commented 2 years ago

I created a new pull request with just the files needed to be committed and closed this one. I have some issues with two data files being shown as modified when doing a clean git check out.