Back

Basket of securities

If I would like to implement a basket of securities, with the basket assigned a symbol that I can reference in my algo. What is the best way to do that? any suggestion?
Update Backtest








If you plan on manually creating the basket, you could define a dictionary such as:var baskets = new Dictionary>();
var preciousMetals = new List{"GLD", "SLV"};
baskets.Add("PM", preciousMetals);

In this way you could define multiple baskets by name (or some other key if you prefer).

What kind of operations would you like to perform against the entire basket? What are your reason for wanting to group the securities?
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.


Hi Michael,
the basket is more like a security itself. I want to have its real-time price update(the average price of the basket), i need to be able to execute the basket just like a security. this is for the purpose of if you are trading the components of an etf. or you want to define a sector of stocks that you always wanted to traded like a single security.
0

@Shuo I had a go at creating a basket but don't believe its possible sorry. We have two separate threads - the data & algorithm thread so using data in algorithm thread to create basket values would cause weird bugs.

I made an approximation, so you can get the basket value, you just can't trade directly on it. This algo uses a "BasketBuy()" to purchase the stocks individually -
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.


Hi @jared @Michael,
what if I want to extend the DataFeed and TransactionHandler in the opensource project? what is the best way to go about it? any suggestion?
0

@Shuo - Do you mean a custom DataFeed to create baskets of symbols? Working locally this is easier. You can make a custom data type and add it to your algorithm with "AddData()" which loads the data for all the symbols you want in the Basket.Reader() and returns the compiled Basket value. This isn't what the system was designed for though, and you can't trade the fictional asset..
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.


Getting this to work properly would probably require a new way to define a security whose value is dependent on other securities. If you're doing in lean locally you could define a custom type with custom readers that reads from all the required data files and builds the 'basket' item.
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.


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