MACrossover

Members

(static) generateOrder

Source:

Generates the atomic order as configured in the execution parameters

Methods

(async, static) declareChannels(instance, host)

Source:

Declares necessary candle data channels for updating indicators and eventually triggering atomic order execution.

Part of the meta handler section.

Parameters:
Name Type Description
instance AOInstance

AO instance state

host AOHost

algo host instance for declaring channel requirements

(static) declareEvents(instance, host)

Source:
See:

Declares the internal self:submit_order handler to the host for event routing.

Part of the meta handler section.

Parameters:
Name Type Description
instance AOInstance

AO instance state

host AOHost

algo host instance for event mapping

(static) genPreview(args) → {Array.<object>}

Source:

Stub to conform to the algo order schema.

Part of the meta handler section.

Parameters:
Name Type Description
args object

instance arguments

Returns:

preview

Type
Array.<object>

(static) initState(args) → {object}

Source:

Creates an initial state object for an MACrossover instance to begin executing with.

Part of the meta handler section.

Parameters:
Name Type Description
args object

instance execution parameters

Returns:

initialState

Type
object

(async, static) onDataManagedCandles(instance, candles, meta) → {Promise}

Source:

If the instance has internal indicators, they are either seeded with the initial candle dataset or updated with new candles as they arrive. The candle dataset is saved on the instance state for order generation.

Indicator values are calculated, and if they have crossed the configured atomic order is submitted, and the 'exec:stop' event is emitted to stop execution and trigger teardown.

Parameters:
Name Type Description
instance AOInstance

AO instance

candles Array.<object>

incoming candles

meta EventMetaInformation

source channel information

Listens to Events:
Returns:

p - resolves on completion

Type
Promise

(async, static) onLifeStop(instance) → {Promise}

Source:

Stub to conform to the algo order schema.

Parameters:
Name Type Description
instance AOInstance

AO instance

Listens to Events:
Returns:

p - resolves on completion

Type
Promise

(async, static) onOrdersOrderCancel(instance, order) → {Promise}

Source:

Triggered when an atomic order cancellation is detected, cancels any open orders and emits the 'exec:stop' event.

Parameters:
Name Type Description
instance AOInstance

AO instance

order object

order that was cancelled

Listens to Events:
Returns:

p - resolves on completion

Type
Promise

(async, static) onSelfSubmitOrder(instance) → {Promise}

Source:

Generates and submits the configured order.

Parameters:
Name Type Description
instance AOInstance

AO instance

Listens to Events:
Returns:

p - resolves on completion

Type
Promise

(static) processParams(data) → {object}

Source:

Converts a raw parameters Object received from an UI into a parameters Object which can be used by an MACrossover instance for execution.

Part of the meta handler section.

Parameters:
Name Type Description
data object

raw parameters from an UI

Returns:

parameters - ready to be passed to a fresh instance

Type
object

(static) serialize(state) → {object}

Source:

Creates a POJO from an instance's state which can be stored as JSON in a database, and later loaded with the corresponding module:MACrossover~unserialize method.

Part of the meta handler section.

Parameters:
Name Type Description
state object

instance state to be serialized

Returns:

pojo - DB-ready plain JS object

Type
object

(static) unserialize(loadedState) → {object}

Source:

Converts a loaded POJO into a state object ready for live execution.

Part of the meta handler section.

Parameters:
Name Type Description
loadedState object

data from a DB

Returns:

instanceState - ready for execution

Type
object

(static) validateParams(args) → {string}

Source:

Verifies that a parameters Object is valid, and all parameters are within the configured boundaries for a valid MACrossover order.

Part of the meta handler section.

Parameters:
Name Type Description
args object

incoming parameters

Properties
Name Type Attributes Description
orderType string

LIMIT or MARKET

orderPrice number

price for order if orderType is LIMIT

amount number

total order amount

shortType string

MA or EMA

shortEMATF string <optional>

candle time frame for short EMA signal

shortEMAPeriod number <optional>

cadnel period for short EMA signal

shortEMAPrice string <optional>

candle price key for short EMA signal

shortMATF string <optional>

candle time frame for short MA signal

shortMAPeriod number <optional>

cadnel period for short MA signal

shortMAPrice string <optional>

candle price key for short MA signal

longType string

MA or EMA

longEMATF string <optional>

candle time frame for long EMA signal

longEMAPeriod number <optional>

cadnel period for long EMA signal

longEMAPrice string <optional>

candle price key for long EMA signal

longMATF string <optional>

candle time frame for long MA signal

longMAPeriod number <optional>

cadnel period for long MA signal

longMAPrice string <optional>

candle price key for long MA signal

Returns:

error - null if parameters are valid, otherwise a description of which parameter is invalid.

Type
string

Events

selfSubmitOrder

Source:

Triggers atomic order creation and teardown

Listeners of This Event: