Trade Smarter with Automation

OptionRange

Used to maintain a range of options by delta or theta.

Usage

Call $data.optionrange with options to select the desired symbol, greek, range, option series, etc:

var query = {
    symbol: 'AAPL',
    type: 'call',
    expiration: 'next friday',
    greek: 'delta',   // <-- tied to delta
    range: [.2, .4]   // <-- the range to maintain
};

$data.optionrange(query).then(function(range){
    // API functions
    var a = range.nearest(.3);  // nearest to .3
    var b = range.gt(.3);       // greater than
    var c = range.gte(.3);      // greater than / equal to
    var d = range.lt(.3);       // less than
    var e = range.lte(.3);      // less than / equal to

    var calls = range.items;     // array of security objects

    range.forEach(function(call){
        // do something with each call
    });
});

Maintaining the correct options

In order to minimize the number of data requests, the Security objects loaded into items will be a slighter larger range than the requested range. The OptionRange will monitor the options it holds and if at any point it no longer contains the entire requested range, it will automatically reload the correct options. While it is loading, the bot's status will be "loading" and no events will fire.


API

Properties

  • Number

    The number of days until expiration for the options.

  • Number

    The requested range's ending greek value, e.g. .45.

  • Date

    The expiration date of the options.

  • String

    The greek the range is tracking (delta or theta).

  • Number

    The highest greek value of any option in items.

  • Array

    Array of Security objects for all options the range has loaded (includes options outside the requested range).

  • Number

    The number of options in items.

  • Number

    The lowest greek value of any option in items.

  • Number

    The requested range's starting greek value, e.g. .15.

  • String

    The underlying symbol for the options.

  • Security

    A Security object for the underlying.

Functions

forEach(fn)

Calls the supplied function, fn, with each option in items.

Arguments
  • Function

    A function to call. Passed (item, index).

Usage
$yourRange.forEach(function(option){
    // do something smart
});

gt(value)

Returns the first option with greek value greater than value.

Arguments
  • Number

    a greek value as a decimal number, e.g. .25.

Usage
var option = $range.gt(.3);
console.log(option.strike);

gte(value)

Returns the first option with greek value greater than or equal to value.

Arguments
  • Number

    a greek value as a decimal number, e.g. .25.

Usage
var option = $range.gte(.3);
console.log(option.strike);

lt(value)

Returns the first option with greek value less than value.

Arguments
  • Number

    a greek value as a decimal number, e.g. .25.

Usage
var option = $range.gte(.3);
console.log(option.strike);

lte(value)

Returns the first option with greek value less than or equal to value.

Arguments
  • Number

    a greek value as a decimal number, e.g. .25.

Usage
var option = $range.gte(.3);
console.log(option.strike);

nearest(value)

Returns the option with greek value nearest to value.

Arguments
  • Number

    a greek value as a decimal number, e.g. .25.

Usage
var option = $range.nearest(.3);
console.log(option.strike);