Hi, I tested a simple algo form Boot Camp and got results with all filled orders.
Is there a way to get a list of the stocks that have been profitable with this algorithm?
The only way I can see is to export orders to excel and manually sum the values. Is there a more convenient way?
Shile Wen
Hi Pavel,
The orders are available in csv in the Order tab. If it's not detailed enough, detailed information on each order is found in the results json file that can be downloaded at Overview tab.
Otherwise, this thread demonstrates how to keep track of the profits using a dictionary of RollingWindows keyed by Symbol. If you wish to track all trades, feel free to replace the RollingWindow with a standard list.
Best,
Shile Wen
P Chen
Tradebuilder is useful if you're looking to do this type of analysis after the completion of a backtest:
def OnEndOfAlgorithm(self): if not self.LiveMode: for trade in self.TradeBuilder.ClosedTrades: self.trade_to_string(trade) def trade_to_string(self, trade): return 'Symbol: {0} EntryTime: {1} EntryPrice {2} Direction: {3} Quantity: {4} ExitTime: {5} ExitPrice: {6} ProfitLoss: {7} TotalFees: {8} MAE: {9} MFE: {10} EndTradeDrawdown: {11} Return: {12}'.format( trade.Symbol, trade.EntryTime, trade.EntryPrice, trade.Direction, trade.Quantity, trade.ExitTime, trade.ExitPrice, trade.ProfitLoss, trade.TotalFees, trade.MAE, trade.MFE, trade.EndTradeDrawdown, trade.ExitPrice/trade.EntryPrice)
Â
Pavel Ananyev
The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by QuantConnect. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. QuantConnect makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances. All investments involve risk, including loss of principal. You should consult with an investment professional before making any investment decisions.
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!