Back

How to add multiple symbols to OnData(TradeBars)?

For example, if I need to do simple thing, add symbolA.Close to symbolB.Close or trade *both* via OnData. Maybe I'm missing something, haha :)
Update Backtest








No worries :) It defaults to sending in all symbols - but sometimes where there is no data available to fill forward ( at the start of a backtest ), or there is no stock data for that date it will be empty.

I use the following trick to ensure there's always data:
//Update the global "_bars" object
private void UpdateBars(TradeBars data)
{
foreach (var bar in data.Values)
{
if (!_bars.ContainsKey(bar.Symbol)) {
_bars.Add(bar.Symbol, bar);
}
_bars[bar.Symbol] = bar;
}
}
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.


Elegant, thank you, Jared :) Is there a way to use both Equity and Forex on the same bars?
0

Yes absolutely! See the updated QC University algorithm - "Check There Is Always Data" - it now includes Forex symbols.

Potentially we could build this into the engine: when all the symbols requested are fill-forward> wait for all symbols to have data before generating first event.
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.


Great, big thanks. Would be useful for all intermarket strategies.
0

Unfortunate side effect would be if you wanted IBM and Facebook from 2009 to Present, it wouldn't start the backtest until 2012 when FB went public :)
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.


BTW, noticed algorithm ranking? On which parameters it's based?
0

We're still tweaking it but its a combination of sharpe ratio, drawdown and annual return. We want to penalize strategies with high drawdown:

[tex]
Score = (SharpeRatio + \frac{1}{Drawdown} + Annual Compounding Return) * (1-Drawdown)
[/tex]

Your rank is out of a subset of QC's backtests which are more than 1 year long, have valid statistics and were generated in the last few months. Ideally we don't want old, short backtest results skewing the distribution.
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.


Wow, just interesting what's used in the top 10% as one of mne's with Sharpe of 3.2, return 75% and DD of 11 is only 2,000 (on top 27%). Can't believe those strategies are real :) I'd suggest maybe making (Sharpe*CAGR)*(1-DD) or (Sharpe*CAGR)*(1/DD) as adding isn't right here I think.
0

Cool we'll try that formula. We used adding because the three factors are scaled to 100: its actually sharpe * 17 to make the top sharpes return 100+. CAGR and Drawdown are whole numbers as well so they are scaled to more or less 100 (few strategies have more than 100% CAGR).
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.


Accidentally got into top:

Your algorithm is ranked #806, and is in the top 8% of the community.

With Sharpe 0.15, drawdown 0.13 and yearly return return 0.096, yep, that needs to be tweaked :)
0

hehe thats not too good. What period was the 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.


Daily.
0

Jared ;

It seems like DD is having too large of an effect on the ranking.

I happened to be testing an older algo; the CSV xactions replay algo (using a spreadsheet with rows of xactions). Modifying the starting capital but keeping the individual xaction amounts intact I found that even though the Sharpe Ratio were quite decent, CAGR had minimal impact but DD overrode the ranking:

Increasing the capital from 1 to 20 million made my algo shoot to the top -1% (minus?)
"Your algorithm is ranked #124, and is in the top -1% of the community."
Drawdown 0.1%, CAGR 1.616%, Sharpe Ratio 5.539
www.quantconnect.com/terminal/results/5dd700a2544d9af33ffdb230c1f46b66

However, if I reduce the capital to 500,000, keeping everything else intact...
"Your algorithm is ranked #1,456, and is in the top 22% of the community."
Drawdown 2.7%, CAGR 79.334%, Sharpe Ratio 5.59
www.quantconnect.com/terminal/results/8a045c8719c22148736533eaa07b78c1

It seems to me these rankings should be reversed, or at least the first one should be much lower.

Maybe adding the weighted scores for each result type would give a better ranking. For example, DD above 5% would have a very low score, while the score differences between 4 and 1% would be small (i.e.: 4 - 9). Below 1% the score would be maximized (i.e.: 10). Similarly for Sharpe and CAGR. Essentially an exponential formula for each score (maybe based out of 100 rather than 10 to give it more range). Basically penalize the undesirable ranges, while preventing an out-of-range positive indicator to skew the ranking.

I'm sure others have more experience doing this type of scoring and can provide other ideas to make the rankings more robust and valuable.

As an aside, I limited the algos to use the first 635 xactions from 11/21/2012 to 3/20/2013, using 250 symbols. The XLS file contains 1531 xactions ending 11/19/2013 with 499 symbols, but it was running out of memory around 3/21. Stopping on 3/20 they ran cleanly. Either way the end results were essentially identical. Can we increase the memory beyond 1024MB?

Keep up the great work you and your team are doing. It's fantastic to see how far you have taken this platform in the past 18 months. Looking forward to the next 6 months!

Marc.
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