Variables for futures and options
The following variables are valid after loading a
contract chain and selecting a contract.
Type and expiration date (YYYYMMDD format) of the selected contract, or 0 when no valid contract was selected.
Current ask, bid, underlying, and strike price, and trade volume or open
interest of the selected contract. 0 when no contract chain
was loaded, or no valid contract was selected,
or when the parameter is not or not yet available in
the selected contract. In historical
data, ContractAsk or ContractBid can be 0 with
illiquid or worthless contracts; such contracts should not be traded.
ContractVal includes 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.
The currently selected contract by the last contract
call. In [Trade] mode,
(string)ThisContract - the first element of the
CONTRACT struct - contains the trading class retrieved from the broker
The current option or future chain loaded by the last contractUpdate
call. A list of CONTRACT structs of the size NumContracts.
The number of contracts in the chain, up to 20000, or 0 when no
chain was loaded..
The row number of the selected contract in the historical .t8
dataset that holds the contract chain history of
the current asset in Test and Train mode; the row number of the selected
contract in the options chain (Contracts pointer)
in Trade mode. Can be used to retrieve further data belonging
to the contract from additional datasets.
The handle of the historical .t8
dataset that holds the contract chain history of the
current asset in Test and Train mode. Can be set to a specific dataset before
calling contractUpdate; otherwise it is automatically
int, asset specific.
The following variables are used to set up asset specific contract parameters:
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. If
at 0, contractUpdate will in [Trade]
mode automatically set this variable to the multiplier of the first contract
when available via broker API.
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
- strike in cents, in contract history
4 - underlying in
cents, in live contract data
8 - underlying in cents, in
16 - ask/bid in cents, in live contract
- 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.
int, asset specific
The hour in HHMM format at which contracts expire; default 1200
(UTC). Used for
contractDays. The contract will at that time on its
expiration day be removed from the open trade list, and its profit or loss will be booked
to the account. Set this to a higher value for checking contract expiration with
the contractCheck function in live trading. Note
that some exchanges have restrictions to trading or exercising contracts at
their expiration day.
DATE, global for all assets
The exchange for the contracts in live trading. Automatically set up when a contract chain is
loaded from the broker; otherwise set the exchange symbol manually through this variable.
The list of valid exchange symbols can be obtained from the broker website.
string, asset specific.
- Contract variables are not valid before a contract chain was loaded by
- Multiplier and Centage (if required)
must be set up for the current asset before loading contract chains.
► latest version online