do you know any C#?
i started with the tutorials in the QC University.
when you create a new project, the basic template has comments that tell you where to put each part of your code
the comments lines begin with // and are grayed out. this means the compiler (machine) does not read these lines of code and they are there to be read by the programmers (human)
hope this helps!
0
Yoni,
Would be happy to help. If your rules are relatively simple, I might be able to draft it up quickly for you.
Else, C# (especially within the context of QuantConnect) is really easy to learn and we can answer questions as you have them on this forum.
-Stephen
0
That would be amazing!
However, I just realized it's a little more complicated than I thought. Haha sorry I didn't even realize!
Might as well give it a shot and explain the strategy:
Theres an X and y axis.
On the X axis is ROIC from 1% all the way up to 150%
On the Y axis is are values for "Enterprise Value/ (divided by) Invested Capital" going from 0 up to 30
The line running through this chart has the following equation:
15.998x2 (squared) + 1.548x + 1.376.
If a company is over the line it is overvalued, under the line and its undervalued.
I've been using this strategy for a while and it has beaten the market week after week, I just want to see how it would have fared during the 2008 market crash.
I have an excel spreadsheet that has the graph and all values on it if that helps.
Anyway, thanks for listening! If there's anything you think you can do with this, it might be really helpful.
0
Interesting strategy. How did you get it?
I think people can code this up pretty quickly. I'm a bit busy at the moment otherwise I would have loved to try it out for you. Maybe I have some time next month to program it.
0
Yeah I agree with JPB, this should be relatively easy to draft. What are your entry/exit rules? Do you re-evaluate portfolios once a month, etc.? Are you singularly focused on a single company or do you rotate through a universe of assets?
Very simple strategy though, and you do have that simplicity working for you. Debugging algorithms with complex rules tends to become quite painful, as you can never know if any discrepancies are stemming from algorithmic problems or if the rules are working against you. :-)
One thing to note: ROIC, Enterprise Value, and Invested Capital are classified as 'fundamental data'. Currently QuantConnect supports only technical indicators, although they leave open some slots to allow for consumption of custom data that you own.
TimCo had an excellent post that got bumped recently that showcased consumption of Custom Data, where he uses Cyclically Adjusted Price-to-Earnings ratio. So we know it can be done. Might need to download some data from Quandl first though.
His post for reference: https://www.quantconnect.com/forum/discussion/418/bubble-algorithm-using-cape-ratio-macd-and-rsi
That said, Jared also mentiond recently that fundamentals are coming online and will be supported by QC in a few months.
0
Wow, love the support in here. To answer your questions
1. I re-evaluate portfolios every month to make sure that nothing has changed with a company's ROIC - EV/IC relationship. Should the company drift too close to the line, I sell and purchase another. I should note that in 9 months I sold only once with a portfolio of 8 companies.
2. I developed this model alongside a few other people working as an analyst for a firm in Florida.
It's too bad only technical indicators are supported, I feel like I'm on to a pretty good strategy here.
A few caveats I should mention.
-The strategy has beaten the market consistently in the last 9 months but we have had bull markets in certain sectors because of QE here and abroad.
- So far I have not (do not know how) to backtest the strategy during a market crash like in 2008.
- I suspect there will be a market crash (in Europe at least) this year led by the collapse of Deutsche Bank and it is difficult to tell what effect that will have on US equities. Thus I have no idea how my strategy will fare.
Hopefully it proves useful to someone!
0
Yoni,
Great feedback, thanks. This is the code I've thrown together so far. Three points:
1.) I use a strange way of organizing things; so I hope I don't offend anybody here who is a stickler for code semantics :-P
2.) I still need to put in the buy and sell code at the bottom of the main class (i.e. sell all losers during evaluation period and then buy all winners using input weightings)
3.) If you attempt to run this, you'll get several errors saying there are no such objects as "ROIC, Enterprise Value, or Invested Capital". This is because, as I mentioned previously, we don't have fundamentals data incorporated into the master Lean Engine yet. So these are just placeholders for now. If you have a good source for this data that goes back several years, we can try to read it in as custom data to backtest it while we wait for the Morningstar integration. Though we might need someone much smarter than me (which is pretty much everyone else on this forum) to do that :-P
It's good that you mention 30 day evaluation period, as that is what I've assumed in this model. :-)
Will work more on it when I get the chance (next day or so). Interesting algo!
-Stephen
0
Hmm. It seems I can't post any code unless I have a successful backtest. I'll try to put in junk placeholders a bit later and run a backtest so you can see the code.
0
Ok, I think I've got it now. :-)
Attached is the project. Viewing the code from the forum might mess some of the formatting, so it might be best to just Clone it and view it in your Backtester IDE.
The points I made above still apply: for ROIC, Enterprise Value, and Invested Capital, we don't have any way of gleaning these as objects while QC is still integrating Morningstar. So for the purposes of getting a backtest up and running (so I could post it on the forum), I just commented those objects out and replaced them with dummy "doubles" set to zero.
Feel free to take a look around the code. I've created two classes. The first (Main.cs) contains the user-editable variables (the tickers you want to analyze and their weightings in your portfolio with respect to each other, etc.) the initializer method which is called only ONCE at the beginning of code boot-up. Then the OnData method, which is called every time a tick bar is sent (I believe every second). The code assumes a check every 30 days to re-evaluate your portfolio and run through a series of methods that contain your "rules": a recalculation of each security's value with respect to the polynomial you mentioned (and by extension whether or not it is "above or below the line"). Then some methods to classify each security as a "winner" or "loser" and finally to sell all of your losers and buy all of your winners in proportion to their weight with respect to each other.
The second class (SecurityObject.cs) just contains all the data for each security, and also contains the method that evaluates the security's value with respect to the polynomial.
Hope this makes sense :-)
When we get actual fundamentals data, we should be able to exercise this quickly by commenting out all of the areas I've designated "DEACTIVATE THESE" and uncommenting out all of the areas I've designated "ACTIVATE THESE".
0
Wow, this is truly incredible, I don't even know what to say.
I'm gonna play with this thing for hours, thank you so much.
Its promising that the stocks I picked out using this model actually survived the market relatively well today!
If this thing really turns into something useful, I'll make sure to keep you guys updated.
Thanks again, I had no idea Quantconnect was full of so many helpful people.
0
You're quite welcome! Many thanks for the compliments :-)
Fair disclaimer, I'm somewhat new here, so it might be good for somebody to double check my work. That said, I'm keeping an eye out for that fundamental data for other algorithms I'm developing. When it's integrated into QC I'll dust off this algorithm and finish it off for you and backtest it, to make sure I didn't inadvertently lead you down a wrong path or something.
Glad to hear your strategy works well even in this climate! If you don't mind me asking, how did you end up arriving at those polynomial constants? I'm finding that I'm pretty good at coding, but my ability to hypothesize an underlying model still needs some work. I'm trying to learn as much as I can from others who have arrived at a good solution :-)
0
Hi Stephen,
Thanks for the excellent input and work. I am getting an error: "Insufficient Buying Power to Complete order."
Why is that hapenning?
0
Hey Mauro,
Would you mind sharing the project code?
If you're using the code I gave to Yoni, do realize that it is simply a framework. I've commented out several areas where fundamentals data is supposed to be plugged in, and replaced them with dummy variables (zeros). I'd be surprised if it functioned at all in the state that I presented it :-P
0
Hi Stephen, thanks for the answer. I used the code you posted. I backtested it as is (googl, aapl, nflx, amazn) and it delivered amazing results 2008 on. I am not sure if it would work live, but it surely delivers.
0
Mauro,
Thanks for the compliment! However (and this is important) you should know that, as-is, the code has no data to operate from, and so it will likely attempt to invest in all four of the stocks above right when you start it. Since it can't currently consume fundamental data (it doesn't exist yet at QuantConnect, but they're working on it), my code will NOT be smart enough to divest from those stocks if they perform badly.
To put it another way, the code is crippled: so it will most certainly not perform the same when deployed live. We need to wait for fundamental data to arrive.
Please understand that, since those four stocks performed very well from 2008 to 2016, it just so happens that you're getting good results.
0
Loading...