You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I wanted to simulate some realistic scenarios relating to systematic investment plan, cash withdrawals, and partial reinvestment.
Presently, I am manipulating the self._broker._cash attribute to this effect.
Is there any suggested approach?
I am more concerned about the execution rather than the returns as I am using attributes inside the Strategy class to calculate customized returns.
The text was updated successfully, but these errors were encountered:
classMyStrategy(Strategy):
definit(self):
# Anything above this capital in cash would be withdrawnself._initial_capital=10000# Everything else goes heredefnext(self):
# After processing all logic# Withdraw only when there is excessif (self.equity>self._initial_capital) and (self._broker._cash>self._initial_capital):
# Withdraw cash only when all positions are closed and everything is in cashif (self.position.size==0):
withdrawal=self._broker._cash-self._initial_capitalself._broker._cash-=withdrawal
One big caveat is withdrawing cash when a position is already open.
Would post after experimenting this
I wanted to simulate some realistic scenarios relating to systematic investment plan, cash withdrawals, and partial reinvestment.
Presently, I am manipulating the
self._broker._cash
attribute to this effect.Is there any suggested approach?
I am more concerned about the execution rather than the returns as I am using attributes inside the Strategy class to calculate customized returns.
The text was updated successfully, but these errors were encountered: