Variables for futures and options

ContractType

ContractExpiry

Type and expiration date (YYYYMM format) of the selected contract, or 0 when no valid contract was selected.

Type:

int, read/only

ContractAsk

ContractBid

ContractUnl

ContractStrike

ContractVol

ContractVal

Current ask, bid, underlying, and strike price, and trade volume or open interest of the selected contract. 0 when no valid contract was selected, or when the parameter is not available. In historical data, ContractAsk or ContractBid can be 0 with illiquid or worthless contracts; such contracts should not be traded. ContractVal contains the multiplier retrieved from the broker API in [Trade] mode. For retrieving the ask and bid prices, the underlying, and the volume in [Trade] mode, contractPrice must be called before.

Type:

var, read/only

ThisContract

The currently selected contract. In [Trade] mode, (string)ThisContract - the first element of the CONTRACT struct - contains the trading class retrieved from the broker API.

Contracts

The option or future chain for the current bar, asset specific, downloaded by contractUpdate. A list of CONTRACT structs of the size NumContracts.

Type:

CONTRACT*

NumContracts

The number of contracts in the chain, 0...10000.

ContractRow

The row number of the selected contract in the historical .t8 dataset in Test and Train mode, and in the options chain in Trade mode. Can be used to retrieve further data belonging to the contract from additional datasets in the backtest.

Type:

int, read/only, asset specific.

Multiplier

Number of underlying units per option / future contract, for calculating the trade volume, selecting a contract, and filtering the options chain (default 0 = download all options). Asset specific; set it after selecting the asset and before buying contracts. 

Centage

Combination of flags that determine which option or futures prices in historical data or live data are given in cents instead of dollars (default 0 = all prices in dollars). Prices are then automatically converted to dollars when loading history or retrieving data from the broker API. Centage flags can be combined by adding them up. Asset specific; to be set after selecting the asset and before buying contracts.

1 -  strike in cents, in live contract data
2 -  strike in cents, in contract history
4 -  underlying in cents, in live contract data
8 -  underlying in cents, in contract history
16 - ask/bid in cents, in live contract data
32 - ask/bid in cents, in contract history
64 - underlying prices and spreads in cents, in live and historical price data (similar to HedgeRatio = 0.01).

Example: Centage = 59 (= 32+16+8+2+1) for ask/bid always in cents, underlying history in cents but live in dollars, and strike always in cents.

Type:

int, asset specific

Exchange

The exchange for the contracts. Automatically set up when a contract chain is loaded from the broker; otherwise set it up manually through this variable.

Type:

string, asset specific.

Examples: see Options and Futures

See also:

enterLong/Short, Contract

 

► latest version online