-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
add_baostock_collector #1641
Merged
Merged
add_baostock_collector #1641
Changes from 1 commit
Commits
Show all changes
25 commits
Select commit
Hold shift + click to select a range
41a4bc1
add_baostock_collector
SunsetWolf b17afdf
modify_comments
SunsetWolf b02d789
fix_pylint_error
SunsetWolf 4574d05
solve_duplication_methods
SunsetWolf ab3e6d3
modified the logic of update_data_to_bin
SunsetWolf 065479e
modified the logic of update_data_to_bin
SunsetWolf bbf47df
optimize code
SunsetWolf 0401298
optimize pylint issue
SunsetWolf bd678fc
fix pylint error
SunsetWolf 48de114
changes suggested by the review
SunsetWolf bc5fe98
fix CI faild
SunsetWolf df94d6c
fix CI faild
SunsetWolf e87a54f
fix issue 1121
SunsetWolf b168a39
format with black
SunsetWolf 530bd08
optimize code logic
SunsetWolf 6633605
optimize code logic
SunsetWolf 0fdcb97
fix error code
SunsetWolf fe8c4bc
drop warning during code runs
SunsetWolf efd43c1
optimize code
SunsetWolf 3b70cf5
format with black
SunsetWolf 3af3cae
fix bug
SunsetWolf 34e9553
format with black
SunsetWolf 0dba040
optimize code
SunsetWolf 6a95c86
optimize code
SunsetWolf e95cecb
add comments
SunsetWolf 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
Prev
Previous commit
add comments
- Loading branch information
commit e95cecb7cea16b86e9ab82242e8f8b8e993e0fa3
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 |
---|---|---|
|
@@ -647,6 +647,21 @@ def calc_adjusted_price( | |
consistent_1d: bool = True, | ||
calc_paused: bool = True, | ||
) -> pd.DataFrame: | ||
"""calc adjusted price | ||
This method does 4 things. | ||
1. Adds the `paused` field. | ||
- The added paused field comes from the paused field of the 1d data. | ||
2. Aligns the time of the 1d data. | ||
3. The data is reweighted. | ||
- The reweighting method: | ||
- volume / factor | ||
- open * factor | ||
- high * factor | ||
- low * factor | ||
- close * factor | ||
4. Called `calc_paused_num` method to add the `paused_num` field. | ||
- The `paused_num` is the number of consecutive days of trading suspension. | ||
""" | ||
# TODO: using daily data factor | ||
if df.empty: | ||
return df | ||
|
@@ -714,6 +729,10 @@ def _calc_factor(df_1d: pd.DataFrame): | |
|
||
|
||
def calc_paused_num(df: pd.DataFrame, _date_field_name, _symbol_field_name): | ||
"""calc paused num | ||
This method adds the paused_num field | ||
- The `paused_num` is the number of consecutive days of trading suspension. | ||
""" | ||
_symbol = df.iloc[0][_symbol_field_name] | ||
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. More document for this function |
||
df = df.copy() | ||
df["_tmp_date"] = df[_date_field_name].apply(lambda x: pd.Timestamp(x).date()) | ||
|
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.
More document for this function