-
Notifications
You must be signed in to change notification settings - Fork 189
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fixed bugs in pandas_data and data.py which didnt correctly handle long lengths in get_historical_prices #661
Closed
Closed
Changes from 6 commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
43a833c
fix for bug in data.py for polygon data
brettelliot 8835f18
Merge branch 'dev' into fix-polygon-get-historical-prices
brettelliot f05b327
Make test deterministic
brettelliot 7525392
Added deterministic tests for thanksgiving dates.
brettelliot 36bbf9e
make sure tests that require polygon subs are properly skipped
brettelliot deea225
Fixed bug in get_start_datetime_and_ts_unit; wasn't getting enough pa…
brettelliot e4ea8a1
Merge branch 'dev' into fix-polygon-get-historical-prices
brettelliot 1a230d0
set the startdate far back enough to get N bars but not too far back
brettelliot e6393f6
Fix one of the polygon tests in test_polygon
brettelliot b4cf8e1
Merge branch 'dev' into fix-polygon-get-historical-prices
brettelliot 99b064b
Change warning to debug message
brettelliot 4e3f0fd
Merge branch 'dev' into fix-polygon-get-historical-prices
brettelliot 1f73603
Merge branch 'dev' into fix-polygon-get-historical-prices
brettelliot 354e004
fix division by zero bug when shorting
brettelliot 86a6f78
better tests for figuring out the get_historical_prices problem
brettelliot 568f877
tests for backtest broker getting data in the future; fix for yahoo d…
brettelliot 03db9c1
Fixed bug so that covering short positions works in drift rebalancer.
brettelliot 2bfe2c9
Merge branch 'dev' into fix-polygon-get-historical-prices
brettelliot 29bb725
remove warning that wasn't true. If the drift is 1.0 or -1.0 we will …
brettelliot File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -412,8 +412,11 @@ def get_start_datetime_and_ts_unit(self, length, timestep, start_dt=None, start_ | |
# Convert timestep string to timedelta and get start datetime | ||
td, ts_unit = self.convert_timestep_str_to_timedelta(timestep) | ||
|
||
# Multiply td by length to get the end datetime | ||
td *= length | ||
if ts_unit == "day": | ||
# Multiply td * length * 1.5 to get the end datetime with overflow + 3 days for long weekends | ||
td = (td * length * 1.5) + timedelta(days=3) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 1.5 multiplier can be large if someone is running a large backtest of like 2 years. How about instead using a round weeks check? weeks_requested = td // 5 # Full trading week is 5 days
extra_padding_days = weeks_requested * 3 # to account for 3day weekends
td += extra_padding_days |
||
else: | ||
td *= length | ||
|
||
if start_dt is not None: | ||
start_datetime = start_dt - td | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Inflexible Date Buffer for Market Closures
Tell me more
What is the issue?
The hardcoded overflow factor of 1.5 and additional 3 days buffer may not be sufficient for all scenarios, particularly during periods with multiple holidays or market closures.
Why this matters
During periods with multiple holidays (e.g., Christmas to New Year's) or unexpected market closures, the calculation could still result in insufficient data being retrieved, causing potential data gaps or incorrect analysis.