Back

Contract size and margin data for Futures

Hi,

searching the documentation and forum I found some posts from 2016 that the margin and contract size data of Futures are missing. I made an algorithm trading multiple futures and really Silver is traded as $15.78 USD, which is totally not correct.

Is there some workaround? Or should I calculate the margin requirements and tick size myself?

How?

BTW building the algorithm including consolidators was definitely not easy. Otherwise great job! I really like Quantconnect.

Thanks,
John

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.


Hi John,

Contract size information is not an attribute of the contracts in LEAN, but you can find information about contract sizes from the CME. For instance, our Silver futures contracts are COMEX Silver futures and therefore are for 5,000 troy oz. each. The contract symbols, which you can find here, will tell you what type of future it is (i.e., SI for silver Comex 5000oz futures versus SIL for 1000oz futures) and the size data can be found from the CME this way. Likewise, tick size is not an attribute of a contract or futures chain, but the tick size of COMEX Silver futures is $0.005/troy oz., which is $25/contract (found here). We don't have margin requirements as an attribute either, but they are taken into account by the algorithm.

To address your concern about the price, it depends on the contract you are examining. Depending on the specific contract, silver futures are settling today for anywhere between $14.86-$16.83. If you could attach a backtest or provide some of your code, this would help us better understand what you are trying to accomplish and address the source of any issues you are having.

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 Jack Simonson and thanks for the message. I am familiar with the contracts and CME contract specifications.

I was wrong, I just checked the Algo lab and the profit is calculated properly, meaning the trade

Date Time Symbol Type Price Quantity Operation Status Tag
2018-12-27 00:00:00 SI27Z18 Market $15.01 USD 1 Buy Filled
2018-12-28 17:00:00 SI27Z18 Market $15.17 USD -1 Sell Filled

was calculated properly like SI 15.17 - SI 15.01 = 0.16 * $5000 = $800 profit. I initially thought the result just took $0.16 as a profit, not taking the contract value into consideration.

But is the margin also taken into account? I mean IB says $3,354 intraday initial margin, so this margin should be deducted from my backtest account balance. But I did not find any such info in the Quantconnect data.

Can I simulate the margin? I.e. with Reallity modelling and Buying power models?

I admit I am not that into Python, but I see 

class IBuyingPowerModel:
self.GetReservedBuyingPowerForPosition(security):
return decimal
self.GetBuyingPower(portfolio, security, direction):
return decimal

but there are not Setter methods...? Does it work? Can you please post some example?

0

Hi John,

Here is the source file of BuyingPowerModel. You could find all the constructor overloads and methods in it. Here is an example:

si = self.AddFuture("SI").Symbol
# Default - no leverage (1x)
self.Securities[si].MarginModel = BuyingPowerModel()

# Overload 1: BuyingPowerModel(
# decimal initialMarginRequirement,
# decimal maintenanceMarginRequirement,
# decimal requiredFreeBuyingPowerPercent)
self.Securities[si].MarginModel = BuyingPowerModel(a,b,c)

# OverLoad 2: BuyingPowerModel(
# decimal leverage,
# decimal requiredFreeBuyingPowerPercent)
self.Securities[si].MarginModel = BuyingPowerModel(a,b)

You could find more information about Buying Power Models here. Hope it helps!

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