Trade Smarter with Automation

Securities

Overview

A security is a financial instrument that represents an ownership position in a publicly-traded corporation or fund (equity), a portfolio of multiple securities that represents a particular market or a portion of it (index) or rights to ownership as represented by an option.

In Alta5, a security is represented by a Security object. A Security object has properties that contain the current market data for that security and methods used to perform actions with that security.

Ready State

When a Security object is created, there are several things that happen automatically: a current quote for the underlying security is requested and the Security object is subscribed for real-time market updates. When these operations complete, the Security is ready and can be used by a strategy.

Properties on a Security object, such as the bid or last, are streamed from the market in real-time and will always be the latest up-to-date value automatically.

Before a strategy can start using the Security object, it must wait for the Security to be initialized and ready. Since strategies cannot contain asynchronous code, that process is handled by a worker. One of the methods below in Using Securities is generally used to initialize the Security and wait for it to be ready.

Using Securities

Security Parameter

The easiest and most common way to get a reference to a Security is to use a security parameter. Using a security parameter, the security will be available in your strategy as data.id.

Example


params: [{
    id: 'stock',
    type: 'security'
}],

onSeek: function(target, data){
    // get security object by it's id
    var st = data.stock;
    // it is ready and always updated
    var bid = st.bid;
}

Security Worker

To get a reference to a Security that isn't configurable with a parameter, you could use a security worker. The security will be available in your strategy as data.id. A security worker's ready state is bound to the ready state of the Security it initializes, ensuring traders using the strategy will wait before calling onSeek or onManage.

Example


workers: [{
    id: 'spx',
    type: 'security',
    symbol: 'SPX'
}],

onSeek: function(target, data){
    // get security object
    var spx = data.spx;
}

Options

Options are initialized using an Option Chain worker. For more information, see the Option Chains guide.

Security API

Properties labeled real-time are always up-to-date with the latest market value.

All Securities

Properties

ask
Number
The current ask for the security.
askSize
Number
The quantity being offered at the ask price for the security.
bid
Number
The current bid for the security.
bidSize
Number
The current bid quantity for the security.
change
Number
The difference between the last close price and the last trade price today.
changePct
Number
The difference between the last close price and the last trade price today as a decimal percentage.
close
Number
The daily close for the security.
description
String
The display name for the security.
exchange
String
The code for the exchange on which the security is traded.
high
Number
The daily high for the security.
last
Number
The last trade price for the security.
low
Number
The daily low for the security.
open
Number
The daily open for the security.
mark
Number
A calculated mid price for the security half way between the bid and ask price.
size
Number
The quantity of the last trade for the security.
symbol
String
The symbol for the security.
volume
Number
The daily volume for the security.

Equity and Index

In addition to the properties below, Equity and Index securities have the properties listed above in All Securities.

Properties

annualVolatility
Number
Annual volatility for this security as a decimal. Calculated as this.sd30 * √252.
sd
Number
The standard deviation of the price of this security over a period of 30 days.
sdN
Number
The standard deviation of the price of this security over a period of the last N days. 5, 10, 15, 30, 90

var sd = this.target.sd90;

Methods

down
Number pct
Calculates the price pct below the last trade price. pctNumber The decimal percentage above the current price. Number The calculated price.

onSeek: function(target, data){
    // get the price 3% below the last trade price
    var alarm = target.down(.03);
}
getSD
Number days, Number multiplier
Gets the standard deviation for this security for a specific time period, optionally adjusted by a multiplier. daysNumber The number of days of prices to use to calculate standard deviation. 5, 10, 15, 30, 90 30 multiplierNumber The number to multiply the standard deviation by to adjust it. 1 Number The standard deviation as a decimal value.

onSeek: function(target, data){
    // get custom param values
    var days = this.get('sdDays'),
        sdx = this.get('sdMultiplier');

    var sd = target.getSD(days, sdx);

    // do something with the value
}
probability
Number strike, Number days
Calculates the probability that the price of the security will be above strike in the passed days, using Monte Carlo simulation. strikeNumber The price to be above. daysNumber The number of days. Number The probability as a decimal percentage.
up
Number pct
Calculates the price pct above the last trade price. pctNumber The decimal percentage above the current price. Number The calculated price.

onSeek: function(target, data){
    // get the price 3% above the last trade price
    var alarm = target.up(.03);
}

Option

In addition to the properties below, an Option security has the properties listed above in All Securities.

Properties

breakeven
Number
The breakeven price for this option.
days
Number
The number of days until expiration.
delta
Number
The delta greek for this option.
expiration
Date
The expiration date for this option.
expired
Boolean
True if this option is expired.
gamma
Number
The gamma greek for this option.
impliedVolatility
Number
The implied volatility value for this option. Also aliased as iv.
interest
Number
Total open interest for this option.
intrinsicValue
Number
For call options, this is the difference between the underlying stock's price and the strike price. For put options, it is the difference between the strike price and the underlying stock's price.
isCall
Boolean
True if this is a call option.
isPut
Boolean
True if this is a put option.
itm
Boolean
True if this option is in the money.
iv
Boolean
Alias for impliedVolatility.
mdays
Number
The number of days until expiration, adjusted to only including trading days in the final week. If an option with 10 days until expiration expires on Saturday and the preceding Friday is a holiday, the days value would be adjusted 2 days and mdays would be 8.
moneyGap
Number
The distance between the underlying stock's price and the strike price. A negative number means the option is in the money.
rho
Number
The rho greek for this option.
strike
Number
The strike price for this option.
theta
Number
The theta greek for this option.
timeValue
Number
The portion of an option's premium that is attributable to the amount of time remaining until the expiration of the option contract.
type
String
Either Option.CALL or Option.PUT.
underlying
Security
A Security object for the underlying security.
vega
Number
The vega greek for this option.

Methods

isAtm
Number range, Boolean useMark
Calculates if the underlying stock's price is within range of the current price (ATM). rangeNumber The range above or below the strike price that the underlying price should be to be considered ATM (in cents). 0.25 useMarkBoolean True to use the mark price of the underlying. false Boolean True if the option is at the money.