@robomotic said in idea:
Hello, the commands will be pause/resume trading whereby the strategy will keep resampling the live data but if it receives a pause command it will not place any trading orders (to the broker), once it receives a resume command it will keep placing orders as before.
Isn't that handled just by having a bool in your code which decides if an order will be sent to the broker or not?
@robomotic said in idea:
Hmm what if we have support for a message broker like RabbitMQ whose queue will act as an additional "command" data source and add a method to Strategy called notify_status()
Same as above. Upon entering next you can pull a command, message, value (you name it) from anything and be the source for the bool above which decides if an order is a trading signal will send an order to the broker or not.
A very generic approach is to pass a callable to the strategy, to fully isolate even your code from the actual details.
class Strategy(bt.Strategy):
params = (
... # other params here
('msgpull', None),
)
def next(self):
cantrade = True
if self.p.msgpull is not None:
cantrade = self.p.msgpull() # or self.p.msgpull(self) to grant full strategy access to the callable
.... # some other things
if mybuysignal and cantrade:
self.buy()