Calling self.getsizing() and getting results for self.isbuy() vs. not
I've been attempting to accomplish scaled in order sizing somewhat outside of the sizer by using
My sizer has a different result for
if isbuyvs. not.
How can I call that logic outside of the sizer with
This topic somehow got down the ladder without being considered. Let's get down the right ladder which is getting to the core of the question.
order_target_sizeis meant to go to a target, not to execute an order for a specific given size
Sizerinstances are meant to calculate the size of an order.
One can of course access the
brokerattributes and implement a targeting sizer.
Unlike some other concepts in the
Sizerinstances don't automatically try to locate the surrounding environment (i.e.: finding out where it is being instantiated and therefore in which
Strategyinstance it is being created)
If the question is being rightly understood, this is an advantage in this situation. Accessing the logic could be done like this:
Create the desired
Sizermanually in the strategy in which is going to be executed (and keep a reference to it, of course)
Manually set the
brokerattribute of the sizer:
thesizer.broker = self.broker
Accessing the logic would be done by means of calling:
thesizer.getsizing(self, data, isbuy) # where isbuy is a boolean with `True` for long and `False` for short