Hey Everybody,
We're excited to give the community the fifth and final demonstration algorithm of how to use one of the 5 ETF universes in the competition: Precious Metals ETFs.
This algorithm provides a rough template of how this universe can be used in a submission and also implements some of the backtest requirements (5-year minimum, $1m starting cash minimum, and using the Alpha Streams brokerage model).
Some factors that tend to affect energy markets that you can consider when writing an algorithm:
- Major news announcements: trade-war news, major geopolitical events, etc.
- Market volatility
- Major Forex movements
- US Treasury information: bond prices, yield curve inversions, etc.
- Analyst sentiment
P.S. -- Keep an eye out for new data sources regarding macro-economic updates, trade-war news, US Treasury data, and analyst sentiment to inform your trading signals!
Jack Simonson
Here is the C# version of the demonstration algorithm using the Precious Metals ETF universe!
Jack Simonson
For those of you who enjoy using the Classic algorithms and don't want to use the Framework algorithms, we've attached a template here that you can clone and use to start coding!
Jack Simonson
Here's the C# version!
Dr. Roland Preiss
The competition and the examples are using the brokerage model BrokerageName.AlphaStreams. Where can I find detailed information (source code / documentation) about the fee model which is used within this brokerage model? I would assume that a good strategy should be aware of the fee model to optimize for a good result after fees are applied.
Jared Broad
Thanks Roland you're 100% correct. I've whipped this up for you this morning.
https://www.quantconnect.com/docs/alpha-streams/alpha-fee-modelsThe 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.
Dr. Roland Preiss
Thx for the swift reply :)
Jeff Ward
This is a great starter, but I think it would help out a lot to understand what the metrics mean and how to interpret them. For instance, I can make an alpha with Market Insight +$7,200, but the total return is -67%. Is this good? I assume the return is because the back test traded it in a bad way, but the insights themselves were good. Also what is Fitness and the other indicators like Active Strategy? What do people look for that indicate you have a decent alpha? Things like sharpe ratio make no sense because you are just emitting insights, not actually trading or allocating risk.
Jared Broad
Hi Jeff; I completely agree that Sharpe Ratio makes no sense with a pure alpha signal. It is a hard task to balance something universally understandable with something which perfectly measures what institutions are looking for. Combined with that - each institution is looking for totally different things! We consulted industry-leading quants (former quant head of $10B+ fund) in this process to find a good hybrid - eventually settling on the PSR (coming soon).
We documented our research process and solicited community feedback which you can review in the forums(1, 2, 3). The short answer is -- we'll measure everything and it'll be up to the funds to decide what KPI is important to them.
For the purposes of this competition, this institution is looking for the metrics provided in the competition rules. This is a rare "behind the curtains" view which we're hoping will give the community a focused target. The competition is looking for daily trading signals (to establish statistical significance) with a 5 year backtest (sufficient market types). The universes provided are to focus on assets not correlated to the US markets - so alphas built of them are unlikely to be correlated.
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.
Jeff Ward
Thanks! That's really helpful. Not to sidetrack the discussion too much, but another helpful feature would be to add an IsBearish flag to the symbol (I know this would probably take a lot of backend work). If you are trying to go long an energy product, for instance, on a news report, but your universe of energy ETFs also contains bearish ones, the code can get a bit complicated trying to sort out which thing does what. If the universe is fixed ahead of time, it might be ok, but not if institutions are allowed to add and subtract equites whenever they want. It took a little debugging before I realized what was going on in my code.
Jared Broad
short ETF's in the universe!
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.
Troy B
Would Jack or someone else be willing to post the full Python code for the above algorithm in Classic format? I'm still learning Python and am not getting this to work in Classic form.
Thanks,
Troy
Alexandre Catarino
Hi Troy B ,
I have attached a full Classic Algorithm example.
In this case, the logic from OnSecuritiesChanged is moved to Initialize:
tickers = ["GLD", "IAU", "SLV", "GDX", "AGQ", "GDXJ", "PPLT", "NUGT", "DUST", "USLV", "UGLD", "JNUG", "JDST"] for ticker in tickers: self.AddEquity(ticker, Resolution.Hour) self.universe = { } history = self.History(tickers, 30, Resolution.Hour) for symbol in self.Securities.Keys: self.universe[symbol] = AssetData(symbol, history.loc[str(symbol.ID)])
We can also remove the optional framework model and place the orders directly using SetHoldings:
def ScheduleDemo(self): insights = [] for symbol, assetData in self.universe.items(): price = self.ActiveSecurities[symbol].Price if assetData.is_ready() and assetData.deviating(price): # Demonstration: Ensure to emit Insights to clearly signal intent to fund. insights.append(Insight.Price(symbol, timedelta(3), InsightDirection.Up)) for insight in insights: self.SetHoldings(insight.Symbol, 1/len(insights)) self.EmitInsights(insights)
Troy B
Thanks Alexandre! This is very helpful.
Troy
Jack Simonson
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!