Back

Portfolio running multiple algos

Hi All,

Many systems run multiple algorithms simultaneously to smooth the PL curve.
Do you plan to implement something similar in QC in a feasible time?

E.g.: one way would be to create "portfolio" and chose already created algorithms and basically merge their results
thus creating the final result.

Currently we can achieve it by implementing it ourselves, but if we have multi-algorithm portfolio, we can just "point and choose"
already created algos and see how they work combined.

Thanks
Nik
Update Backtest






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.



Cool idea @Nik, we have had requests for a Lean order management system for combining the outputs of algorithms so it is on our radar. The orders generated would be merged and offset against each other before sending them through for execution.

Do you think each algorithm should have a fixed cash allocation? & if not, how could algorithm state be managed with a dynamic portfolio?
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.


As a first stage, generally speaking you can run all specified algos in different threads - wait until they finished, convert their outputs to e.g. daily arrays of money and add these arrays. So, each algo operates on its initial capital and does not know other algos. Algos do not borrow money from each other.
As a next step you can perhaps add some sort of rebalancing (weekly/monthly), between them - e.g. if an algos capital exceeds or is less than certain percent, then move capital between them.

You can keep their starting cash as it is, so total starting capital of the portfolio would be the lump sum of all.
Since we are concerned with the results only - you can "normalize" algos outputs (let's say make all outputs daily) and then sum up these arrays. For those algos which dont have data for particular date, just keep the last capital, or if it has not started the initial capital.
0

Cool idea to re-balance capital after a period! But perhaps to keep everything identical in live and backtesting we can make a parent algorithm runner which can run multiple strategies in parallel?
Re-balancing cash is great if the algorithm holds cash, but what about if it has existing holdings?

Perhaps there could be a "Release Capital" method to pass capital back into the communal pool/runner for redistribution :)
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.


The moment all algorithms finished, you have all the information - every purchase, securities hold, cash, total capital and etc. for every day. Then you can go back and do rebalancing, day by day, where you can sell shares or purchase shares.
For example -you want to rebalance and sell from an algo certain number of shares on a particular day. You would remove the amount from all future days of the algo and recalculate its holdings and etc. Then these shares will be converted to cash and you would buy to adjust another algo from this day.

But above will work only for back testing, not for "live". If you want to go live, I agree with you that the main algo will have to run at the end of each bar and recalculate and make decisions to rebalance. The main algo may have different criteria for rebalancing: e.g. if an algo holds several holdings, just sell the losers (or winners) and with the cash buy/add some winners/losers of another algo which capital is below the threshold.

The same idea is applicable within an algorithm: buy holdings which went down of their target percentage and sell holdings who are above (automatically), since we can implement this by ourselves now :)

My vote would be to implement first the idea of "portfolio" of algos :)
0

I like the idea of having a runner algorithm who could manage resources and have child algorithms. This could lead to some very interesting set ups. I would also expect the root algorithm to handle collating orders to reduce thrash/transaction fees
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.


I like idea of having a top level algorithm to manage resources and allocate capital. Given a system with edge, it is often the capital allocation / sizing that has the biggest impact on long-term profitability. Is the University Tutorial "Strategy Example: Complete Algorithm Framework" a step in this direction?

My goal is to be able to implement a fixed fraction sizing approach (a la Kelly Criterion, Ralph Vince) that will dynamically adjust cash allocated to a given system / algo based on its performance. Would want to measure correlation between different systems to gauge risk, and especially to gauge if uncorrelated results become correlated in certain market environments. This would be extremely useful in backtesting, as well.
1

"re-balance capital after a period"

This would be fairly important for when Futures are supported, as the margin accounts are updated at the end-of-day with the gains/losses credited/debited from the account.

This end-of-day update to account balances will affect position sizing decisions.
0

Hey Jared,

Another question along the same line.
I am trying to implement 2 algorithms trading simultaneously and they may be short/long of the same security:

First algo goes short and sells 50 % worth of capital: Setholdings("MSFT", -0.5)
While it is still short, few days later, the second algo buys 50 % worth of capital: Setholdings("MSFT", 0.5)
The end result will be that in the Portfolio all "MSFT" shares will be gone.

Later on when the algos close their position, since the executions are reverse, the result will be 0 shares again.

Is this correct?

Also, when
Thanks
Nik
0

Hey Jared,

I am going back to multiple algorithms running (runner algorithm having children), since I have more feedback to share.

Recently I have been doing some live testing on IB paper account.
IB allows only one connection per time, so I either test algo1 or algo2, but can't do them together, which in turns shorten the amount of possible live testing.

It seems that for people who do live "paper" trading (and real trading), having ability to incorporate multiple algorithms in one running instance would be really beneficial.

Not sure if you share my opinion and how many people will benefit it, but we can revive the topic and see if this is important for many or not.

Thanks
Nik
0

Thank you @Nik, a portfolio approach for algorithms is definitely on our todo list! If you're keep to make it happen we could definitely use a hand! You could make an algorithm manager which handles the child algorithms, and allocates their cash on Initialize, and pipes required data. Eventually we could update the algorithm manager to rebalance capital.
class QCAlgorithmManager : QCAlgorithm {
public List Children;

private QCAlgorithm Child-John {};
private QCAlgorithm Child-Jane {};
private QCAlgorithm Child-Bob {};
}


We'll need to make a change to the Loader to select the QCAlgorithmManager if there are multiple QCAlgorithm types in the DLL.

The example you explained above (long/short MSFT) is how we model the portfolio. This doesn't really support going long and short simultaneously as you've pointed out.

As we get deeper into FX we've found some brokerages model trades as individual tickets - and you can go long and short on separate trades as you like. We don't support this style of portfolio accounting yet but its also on our todo list :)
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.


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