Back

Optimising our Trading Bot - Trading Bot in Python #7/#8

Hey everyone,

I've attached the backtest and algo for the two latest episodes of the python trading bot series. You can find #7 here and #8 here.

In these two episodes we develop an optimiser class using the CVXPY optimisation package, implement it into our trading bot and then evaluate the backtest with some extra charts.

Hope you enjoy it!

Ollie

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.


Well done! Thanks.

0

Have you tried using skylight? Do you know how to synch pycharm with quantconnect cloud? How?

0

Hi Dave,

Syncing local QC project files with our cloud servers using Skylight is straightforward. Watch our latest YouTube video for a quick demonstration. For more information on Skylight, checkout our recent blog post about it: A New Era For Desktop Algorithmic Trading.

Best,
Derek Melchin

1

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.


Thanks for this wonderful series, Ollie. I am trying to understand certain things

In the SelectFine method, the secrities list from the main algo gets set to the selected universe and the method also returns the universe. does the returned universe have any function?

def SelectFine(self, fine):
universe = self.FilterFactor(self.FilterFinancials(fine))
# self.algorithm.Log(f"Universe consists of {len(universe)} securities")
self.algorithm.securities = universe
return [f.Symbol for f in universe]

 

0

Hey Mohamed,

The return universe is the set of securities whose data we are subscribed to. The data for those securities can be accessed in the AlphaModel within the Update method.

class MyAlpha(AlphaModel):

def Update(self, algorithm, data):
insights = []
for symbol in data.Keys:
# create insights
return insights

The algorithm Ollie created doesn't use this feature, however, a set of symbols, a empty array or Universe.Unchanged must be returned during universe selection, otherwise the algorithm will throw an error.Learn more in the documentation on Universe Selection and Alpha Creation.

Best
Rahul

1

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.


Thanks Rahul! Appreciate it!

0

Hey Ollie, 

I just cloned this and ran a backtest and for some reason in Nov 2008 I am getting it drop down to 0 dollars....its taking a big short in something I think. Anyway not sure if I am doing something wrong, I dont think I changed anything when I cloned your code above. Does this happen to you now?

0

Hi Jason,

I was able to backtest the strategy over November 2008 without experiencing the same issue. See the attached backtest for reference. I'd recommend cloning the original code files again to fix the issue.

Best,
Derek Melchin

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.


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