Hi all,
In a simple buy low sell high equity algo, I am trying to log profit/loss for every sell order. I assumed it would be simple but am having a hard time.
I have tried "self.Log(self.Portfolio["SPY"].LastTradeProfit)" placed right under Set.Holdings code below and also have tried "self.Log(self.Securities["SPY"].Price-self.Portfolio["SPY"].AveragePrice)."
if self.Securities["SPY"].Price > self.Portfolio["SPY"].AveragePrice:
self.SetHoldings("SPY", 0.0, False, "TAKE PROFIT")
The log posts the wrong value and also posts it every minute instead of just when the sell order executes. I can't seem to solve both of those issues. The algo runs on minute intervals and is coded in python. Any help would be appreciated. Thank you.
To unlock posting to the community forums please complete at least 30% of Boot Camp.
You can continue your Boot Camp training progress from the terminal. We hope to see you in the community soon!