Receive as a parameter the instrument in the rule function #808
Unanswered
diegolovison
asked this question in
Q&A
Replies: 3 comments 4 replies
-
How about modify the code to. I could fill the PR list_of_data_for_call = self._get_data_from_system(system, instrument_code)
result = self._call_with_data(list_of_data_for_call, instrument_code)
# Check for all zeros
result = replace_all_zeros_with_nan(result) def _call_with_data(self, list_of_data_for_call: list, instrument_code: str) -> pd.Series:
other_args = self.other_args
other_args['__instrument_code'] = instrument_code
result = self.function(*list_of_data_for_call, **other_args)
return result |
Beta Was this translation helpful? Give feedback.
0 replies
-
This shouldn't be neccessary. I don't understand the use case why you would want to do that? The whole poiint is the system prepares the data for a specific rule, and passes it to the forecasting function. |
Beta Was this translation helpful? Give feedback.
1 reply
-
You should create a new method in raw data that pulls in your external
stuff.
…On Fri, 21 Oct 2022, 23:43 Diego Lovison, ***@***.***> wrote:
The "my_rule" method returns the raw_forecast based on price. In my case,
to generate the raw_forecast, I am using an external system. Without
knowing the instrument, I am not able to request a raw_forecast.
Example:
def my_rule(self, price):
instrument_code = ....
signals = pd.Series(dtype='float64', index=price.index)
for index in price.index:
signal_date = index.replace(day=1)
if signal_date in self.signals.index:
signals.loc[index] = self.signals[instrument_code][signal_date]
return signals
my_rule = TradingRule(self.my_rule)
my_rules = Rules(dict(my_rule=my_rule))
fcs = ForecastScaleCap()
my_config = Config()
accounts = Account()
position_size = PositionSizing()
raw_data = RawData()
portfolio = Portfolios()
combiner = ForecastCombine()
my_system = System([fcs, my_rules, combiner, raw_data, portfolio, position_size, accounts], self.data, my_config)
[image: Capturar]
<https://user-images.githubusercontent.com/687311/197298924-4b61a058-cc42-43f5-9817-0a3955a7eb3e.PNG>
—
Reply to this email directly, view it on GitHub
<#808 (reply in thread)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ADCLPEULO7PIQD5VRYOOVSDWEMMCDANCNFSM6AAAAAARKUEA2U>
.
You are receiving this because you commented.Message ID:
***@***.***
com>
|
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I would like to receive the instrument into the
rule
function.Is it possible?
Beta Was this translation helpful? Give feedback.
All reactions