-
Notifications
You must be signed in to change notification settings - Fork 5.9k
Fix errors when SignalRecord is not called before SigAna/PortAna #345
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
Merged
Merged
Changes from 3 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
9f57681
Fix errors when SignalRecord is not called before SigAna/PortAna
6559d44
Add tests for SigAnaRecord
b0fd0d2
Add tests for SigAnaRecord
4cb74d7
add error type for record_temp
d4aa681
Add MSERecord in contrib.workflow
88b0871
Add RMSE for contrib.workflow.record_temp and unit tests
872ddc6
Fix black error
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 hidden or 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 |
|---|---|---|
|
|
@@ -110,7 +110,7 @@ class SignalRecord(RecordTemp): | |
| This is the Signal Record class that generates the signal prediction. This class inherits the ``RecordTemp`` class. | ||
| """ | ||
|
|
||
| def __init__(self, model=None, dataset=None, recorder=None, **kwargs): | ||
| def __init__(self, model=None, dataset=None, recorder=None): | ||
| super().__init__(recorder=recorder) | ||
| self.model = model | ||
| self.dataset = dataset | ||
|
|
@@ -164,13 +164,15 @@ class SigAnaRecord(SignalRecord): | |
| artifact_path = "sig_analysis" | ||
|
|
||
| def __init__(self, recorder, ana_long_short=False, ann_scaler=252, **kwargs): | ||
| super().__init__(recorder=recorder, **kwargs) | ||
| self.ana_long_short = ana_long_short | ||
| self.ann_scaler = ann_scaler | ||
| super().__init__(recorder=recorder, **kwargs) | ||
| # The name must be unique. Otherwise it will be overridden | ||
|
|
||
| def generate(self): | ||
| self.check(parent=True) | ||
| def generate(self, **kwargs): | ||
| try: | ||
| self.check(parent=True) | ||
| except: | ||
| super().generate() | ||
|
|
||
| pred = self.load("pred.pkl") | ||
| label = self.load("label.pkl") | ||
|
|
@@ -228,18 +230,21 @@ def __init__(self, recorder, config, **kwargs): | |
| config["backtest"] : dict | ||
| define the backtest kwargs. | ||
| """ | ||
| super().__init__(recorder=recorder) | ||
| super().__init__(recorder=recorder, **kwargs) | ||
|
|
||
| self.strategy_config = config["strategy"] | ||
| self.backtest_config = config["backtest"] | ||
| self.strategy = init_instance_by_config(self.strategy_config, accept_types=BaseStrategy) | ||
|
|
||
| def generate(self, **kwargs): | ||
| # check previously stored prediction results | ||
| self.check(parent=True) # "Make sure the parent process is completed and store the data properly." | ||
| try: | ||
| self.check(parent=True) # "Make sure the parent process is completed and store the data properly." | ||
| except: | ||
|
||
| super().generate() | ||
|
|
||
| # custom strategy and get backtest | ||
| pred_score = super().load() | ||
| pred_score = super().load("pred.pkl") | ||
| report_dict = normal_backtest(pred_score, strategy=self.strategy, **self.backtest_config) | ||
| report_normal = report_dict.get("report_df") | ||
| positions_normal = report_dict.get("positions") | ||
|
|
||
This file contains hidden or 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
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.
Please specify the specific error type to avoid unexpected outcomes.
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.
Got it, added :)