-
Notifications
You must be signed in to change notification settings - Fork 19
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
Dynamically load strategies #167
Conversation
Multiple strategies can be included in a single file, therefore, one hash may be mapped to more than one names.
This is for passing parameters to the dynamically loaded strategies without needing to change the service's implementation.
145ea9d
to
e372fd7
Compare
if STRATEGY_RUN_METHOD in globals(): | ||
del globals()[STRATEGY_RUN_METHOD] | ||
exec(self.strategy_exec, globals()) # pylint: disable=W0122 # nosec | ||
method = globals().get(STRATEGY_RUN_METHOD, None) | ||
if method is None: | ||
self.context.logger.error( | ||
f"No {STRATEGY_RUN_METHOD!r} method was found in {self.params.trading_strategy} strategy's executable." | ||
) | ||
return {BET_AMOUNT_FIELD: 0} | ||
return method(*args, **kwargs) |
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.
So basically the assumption here is that the strategy doesnt block. I guess its fine for now, although maybe it makes sense to run this on a separate thread/process to not block the agent.
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.
Opened #169.
return | ||
for strategy, file_hash in self.shared_state.strategy_to_filehash.items(): | ||
self.context.logger.info(f"Fetching {strategy} strategy...") | ||
ipfs_msg, message = self._build_ipfs_get_file_req(file_hash) |
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.
why do this? this class has access to the IPFS helper methods, you can use generators for it and avoid having callbacks?
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.
Yeah this is an overkill, not sure why I chose this path.
I opened #170 as this works for now.
IpfsHandler = BaseIpfsHandler | ||
|
||
|
||
class IpfsHandler(AbstractResponseHandler): |
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.
you could just use the default IPFS handler, no?
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.
Correct. Will be addressed in #170.
@@ -1,25 +0,0 @@ | |||
# -*- coding: utf-8 -*- | |||
# ------------------------------------------------------------------------------ | |||
# |
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.
Would be good to keep that and add at least one test so we can later build on it. Rather than deleting it now and adding it back in 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.
Done in 7225bc3.
Add a max bet parameter for the bankroll's adjustment
73567ce
to
3f07634
Compare
No description provided.