Back

Live Trading for the Same Instrument Using Multiple Algorithms

Dear All, I have some questions about going live with multiple algos.
Basically I would just trade three ETFs using multiple algorithms. The algos are based on different time scale (min bar vs hourly bar) and different ideas (mean reversion vs trend following) so I diversify across algos although focusing on a few ETFs. So far I have different projects for different algos and I have tried to deploy them using my IB paper trading account. And here are my detailed questions:

1. Is that true that if I add one more algo I will need to pay $10 extra for the VPS? I am OK with the pricing but just want to be sure about it.
2. When switched to real IB account can I still deploy multiple algos for the same account trading the same symbols? Will IB allow that and how about the actual position in the account? Say, if I have two projects to deploy, I am thinking about simply use SetHoldings("SPY", 0.5) instead of 100%. I am thinking if the two projects are running truly independently, each algo will only use ~50% of the capital. I am not sure if the lean engine would detect the total holdings in your IB account and the SetHoldings() method would not fire if another algo has already established a 50% position.
3. Following question #2. If the multiple algos on the same IB account is an issue, I am thinking about a remedy of opening multiple IB and tradier accounts so each algo is only deployed on one account. With a single quantconnect account can I deploy different algos to different brokerage account? And what is the availability to short some popular ETFs like SPY, QQQ and SVXY in tradier. I know I can use the inverse ETFs to achieve similar effects of short but I am a little bit "lazy" to change the c# code to use inverse ETFs instead of direct short.

Thank you all for your help. May the profit be with you:-)
Update Backtest








Hey @Jiaqi! - If two algorithms were operating on a portfolio/cashbook at the same time it would be very difficult to make decisions and maintain state across both portfolios. Because of this we only allow 1 algorithm per brokerage. Additionally, Interactive Brokers only allows one computer to use a login at one time (you can't even login to TWS while QC is trading...)

We currently charge $10 for each additional VPS. You can use these for paper trading or trading on another brokerage.

You could trade one two brokerages (or have 2 separate accounts at 1 brokerage) to solve this problem. I'm not certain about Tradier's availability for those specific stocks though - they are very responsive so feel free to ask them: service@tradier.com
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.


@Jiaqi

I know that, during my live trading tests, that Lean does not detect the holdings in your account. If your algorithm throws an unhandled fatal exception, an algorithm will exit. It says very clearly in the message that you could still have positions outstanding. I restarted my algorithm with positions still in place, and Lean did not pick them up upon restarting. I really had to scramble to get flat before the end of day. There may be a way to ask Lean to query IB for your positions, but I have not looked for it yet. I just accepted that each algo start assumes a flat position and coded accordingly.

Rather than run two separate algos, one for trend and one for reversion, I would combine them into one algo that has two strategies. Then you can maintain state between the two much more easily. Suppose, for example, you are running JJ's Momersion indicator and want to switch between a momentum strategy and a mean reversion strategy, you could use the result of the indicator to decide with an if/else which of the two strategies you wish to be the current strategy. Pseudocode in OnData..


var trend = DetermineTrend();
var mean_reversion = DetermineMeanReversion();
if (trend)
{
... gather results from some trend following indicators.
... decide to buy or sell with a signal from your strategy
(eg. if x[0] > x[1] && x[1] < x[2] buy) // because you reached a valley
... determine number of shares (BetSize)
... execute your trade
}
if (mean_reversion)
{
... gather the results from some mean reversion indicators.
... decide to buy or sell with a signal from your strategy
... determine number of shares
... execute your trade
}
else
{
... do nothing
}


Insofar as your 50% of capital allocation method is concerned, you might what to take a look at the Kelly ratio for determining Bet Size.

A more complicated mechanism for selecting which strategy to use would be to set up a custom data type. Take a look at the BitCoin example that Michael wrote some time ago. What the custom data type does is makes a call to a uri. It then parses the result and raises a custom event with the parsed result. You tell the uri which strategy you want to employ and the uri tells your algorithm which strategy to run. I say uri, because it does not have to be a url to a web page. It can be a file in your Dropbox. I have posted some sample code in a response to an inquiry about custom data in QC forum somewhere. If you cannot find it, I can dredge it up for you.

Cheers,

Nick
0

@Nicholas - LEAN does actually query IB for position holdings before launching the algorithm and in our testing it works well. If there's a case you've seen where it didn't please touch base separately to https://www.quantconnect.com/support and we'll schedule a screen share to try debug it with you.
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.


Thank you all for the fantastic answers. They are really helpful.
0

I would like to suggest a solution, one which I would really like to discuss as I have not yet applied it to QC myself.

I come from Quantopian, they 'provided' data to the live algo. I believe QC does the same? This is what I think empowers the use of an Interactive Brokers Proprietary Trading Group: Seprate Trading Limit account structure(scroll to the bottom and click 'separate trading limit account' for info) because IB institutional accounts charge a high price for their data. Additionally, most algos have high turnover for the sake of statistical relevance, so it is easier to ignore the minimum fee applied to each account(assuming 5+ round trip trades per month).

This account structure allows me to set up 100% isolated systems with separate logins, owned by a single entity and run under a master account (you can only log into master when algos running, there is NO ability to create a second login for sub accounts in this account type like you do with personal or ira accounts). This makes running multiple algos pretty clean and also works to benefit from IB's features for accounting, taxes, etc when managing your portfolio of live strategies. Instead of applying for a brand new account, you can very quickly add new sub accounts to this type of structure in order to launch a new system. Additonaly the use of margin in trading systems makes the protection sometimes offered by a limited liability corporation(for example) worth considering.

Jared Broad does the use of this account type work with QC's rules and/or does a better known solution exist for IB customers? Does anyone have experience with live trading systems on IB Linked Accounts such as a Personal + IRA?

1

Very interesting thank you for sharing Derek.  I wasn't aware of that account structure but it makes sense. I don't see why we would limit it. We're not really aiming to maximize profits but get as many people as possible happy about LEAN and QuantConnect :)

We're chewing through bugs that Quantopian people have brought to our attention but we'll move onto features soon. Stefano has already started the research into adding master & advisor accounts.

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.


Does someone know how the pricing model for data in IB looks like for master accounts vs QC?

If you trade frequently your personal account get a maximum subscribe amount of 350 stocks for example instead of the default 50 at start. You can follow 350 stocks live. Of course some booster packs are available. Everything depends on your trading costs.

This things i have to be aware of if i am using universe selection for personal and master/advisor account.

Is that right? 

Does the advisor/master account has to buy all of that data subscription/booster packs or does QC provide live streaming data when going live? And only orders are going to be send to IB and thats it?

0

Derek,

 

Are you using this type of account now ? (Interactive Brokers Proprietary Trading Group: Seprate Trading Limit). Do you know how this compares to the master/advisor accounts in terms of pricing? I am starting to port my live trading programs from Quantopian to QC and have faced a number of challenges along the way. I'm still not sure I have a handle on the account-> algorighthm linkage and the costs that this may incur.  

My understanding is that I will need a separate $10 fee for each algo running on a live account. Each of these has a 512 MB limit on memory. Since all of my accounts are pretty much running on the same algo, I would like it if that permitted me to use x times memory limit to run against my data requirements. 

Let's say I have one algo that requires a lot of memory or cpu cycles initially (sorting through the universe of stocks, or crunching a lot of historical cycles determining a good signal), but then that same signal is useful for 20 different users all coded to the same strategy. In that case I guess I could pay for extra cpu / memory on just 1 unit, have the algo then write the results to a csv file, then have all the other algo's read from that csv file. Kind of clunky but it would probably work. 

The slicker solution - at the same hardward costs to QC - would be if they could multiply the memory/cycle limitations by the number of accounts subscribed to. So if I am paying for 10 "units" I would then be allowed 10 x 512 MB of memory on the aggregate  of them.  This would make my deployments much easier.

Obviously , my algos would have to be coded a bit differently depending on which of the two is possible.

I'm curious if any of you have similar issues and already found workarounds.

0

I think the RiA accounts/advisor accounts are still on the roadmap of QC.

Support for Multiple Accounts at Interactive Brokers

they have sure a lot to do after people jumping of the quantopian train.

your CSV file idea is quite good. You would have to run it on your windows or linux machine. Easiest and fastest way would be windows. 

BUT! if you start 20 quantconnect accounts on one machine you have to think about some minor IB problems that can occur. If one/some TWS/IB Gateway got a disconnect because of IB Server it will restart the gateway again killing all instances of the gateway or tws................5 minutes of debugging could help to solve the problem or wait till they implement the account type.

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