Hi There.
Is it possible to apply leverage to Quandl data. I have looked at the examples and tried various things. For example, setting the leverage on the AddData<Quandl>() method does not seem to do anything.
QUANTCONNECT COMMUNITY
Hi There.
Is it possible to apply leverage to Quandl data. I have looked at the examples and tried various things. For example, setting the leverage on the AddData<Quandl>() method does not seem to do anything.
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.
Alexandre Catarino
The default value for leverage of custom data, such as Quandl data, is 1.
In order to change it to a desirable value, we can either use a method overload with the leverage parameter:
AddData<Quandl>("YAHOO/INDEX_SPY", Resolution.Minute, false, 2m);
or we can rely on the Security.SetLeverage method:
AddData<Quandl>("YAHOO/INDEX_SPY", Resolution.Minute); security = Securities["YAHOO/INDEX_SPY"]; security.SetLeverage(2m);
In the example below, we set the leverage to 2 and use all the leverage.
Anton Esterhuyse
@Alexandre: Thank you for your very quick response.
This leads me to another question. Is it possible to set the Portfolio Margin Model? For example, when backtesting single stock futures, a broker typically requires around 15% margin on the value of the order (might be different in the USA). I have notived that orders are ignored or rejected (in the case or the Order() function) if the marginRequired (equal to total value of the transaction) is below the availible cash margin, however, in the case of single stock futures only 15% margin is actually required.
If one SSF contract is equal to 100 underlying shares, I can purchase $1m worth of share contracts with $150k cash holdings, however the order will be rejected/ignored by QuantConnect because I don't have the cash margin.
I appologise if this is a mindless question, I am new to QuantConnect and still trying to wrap my head around the inner gears of the system.
Regards
Anton
Anton Esterhuyse
Okay, I have experimented a bit and I see now that you have to call Securities["YAHOO/INDEX_SPY"].SetLeverage(100.0m) in order to allow you to use leverage when calling SetHoldings();
Alexandre Catarino
Yes, it is possible to set the security margin model. Please checkout the docs under Reality Modelling section:
// Example of setting a security to use PDT margin models: // Generally you do not need to adjust margin models Securities["AAPL"].MarginModel = new PatternDayTradingMarginModel();
In QuantConnect's default security margin model, initial and maintenance margin requirements are 1 / leverage. If stock futures have a 15% margin requirement, leverage is 1 / 0.15:
AddData<Quandl>(_quandlCode, Resolution.Minute, false, 1/.15m);
In the following example, the algorithm purshases $1m worth of shares with $150k initial cash.
Anton Esterhuyse
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.
To unlock posting to the community forums please complete at least 30% of Boot Camp.
You can continue your Boot Camp training progress from the terminal. We hope to see you in the community soon!