Back

Seeing more details on trade logs

Hi guys,

I can view trade log, but only has half a dozen fields.

I'd like to see;  

date/time order created + date/time order filled

 fill price, fill-time

exit time, exit price + exit tag (I can only see entry tag)

I've been trying to find Python documetation on this.. I found some C# code, using smething like 'resultsBacktestObject' but having difficulty figuring out how to do in Python. Please could anyone give an example?

Update Backtest








Hi guys, does anyone know how to find this info, or a good Python link to it? Thank-you

0

We can get the information on closed trades from the TraderBuilder object:

def OnEndOfAlgorithm(self):
for trade in self.TradeBuilder.ClosedTrades:
self.Log("Symbol: {0} Quantity: {1} EntryTime: {2} EntryPrice: {3} ExitTime: {4} ExitPrice: {5}, ProfitLoss: {6}, TotalFees: {7}, MAE: {8}, MFE: {9}, Duration: {10}, EndTradeDrawdown: {11}"
.format(
trade.Symbol,
trade.Quantity,
trade.EntryTime,
trade.EntryPrice,
trade.ExitTime, trade.ExitPrice,
trade.ProfitLoss,
trade.TotalFees,
trade.MAE,
trade.MFE,
trade.Duration,
trade.EndTradeDrawdown))

 

0

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.


Your quick reply is greatly appreciated. I've been playing with this but not able to get OnEndOfAlgorithm to be called.. at least the Log isn't displaying anything. Will experiment with code more and try and fix. Thanks for pointer

0

Hi Alex, Unfortuantely I've tried several differnt examples and OnEndOfAlgorithm is not getting called. I see no Log output anyway. I tried adding not just to my code but included in QC Python moving average code, and still it doesn't get called. Anything I'm doing wrong? Thanks

0

Please checkout the working example:

0

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.


Hi Alex, again thank-you for your dedication in repling to my queries.

I was surprised to see your code worked and couldn't understand why mine didn't.

Infact I still don't understand why my code doesn't do what's expacted. All I did was link your MA crossover code with the OnEndOfAlgorithm code about.. nothing shows in log.  Is there something I have missed? Thanks

My code attached

0


There is an indentation bug in your code: a extra indent across the whole OnEndOfAlgorithm method.

0

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.


opps. Great thank-you, tested it and it works fine now. Appreciated

0

Update Backtest





0

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.


Loading...

This discussion is closed