Members
(static) genPingPongTable
Generates a mapping between ping
and pong
prices as configured in the
execution parameters.
Methods
(static) genOrderLabel(state) → {string}
- Source:
Generates a label for a PingPong instance for rendering in an UI.
Part of the meta
handler section.
Parameters:
Name | Type | Description | ||||||
---|---|---|---|---|---|---|---|---|
state |
object | source instance state Properties
|
Returns:
label
- Type
- string
(static) genPreview(args) → {Array.<object>}
- Source:
Generates an array of preview orders which show what could be expected if an instance of PingPong was executed with the specified parameters.
Part of the meta
handler section.
Parameters:
Name | Type | Description |
---|---|---|
args |
object | instance parameters |
Returns:
previewOrders
- Type
- Array.<object>
(static) getUIDef() → {AOUIDefinition}
- Source:
Returns the UI layout definition for PingPong, with a field for each parameter.
Part of the meta
handler section.
Returns:
uiDef
- Type
- AOUIDefinition
(static) initState(args) → {object}
- Source:
- See:
-
- module:PingPong~genPingPongTable
Creates an initial state object for PingPong instance to begin executing with. Generates the ping-pong table price mapping.
Part of the meta
handler section.
Parameters:
Name | Type | Description |
---|---|---|
args |
object | instance execution parameters |
Returns:
initialState
- Type
- object
(async, static) onLifeStart(instance) → {Promise}
- Source:
Generates and submits initial ping
orders, along with any pongs
that
need to be submitted due to the loaded execution state.
Parameters:
Name | Type | Description |
---|---|---|
instance |
AOInstance | AO instance |
Listens to Events:
Returns:
p - resolves on completion
- Type
- Promise
(async, static) onLifeStop(instance) → {Promise}
- Source:
Cancels all open orders prior to teardown.
Parameters:
Name | Type | Description |
---|---|---|
instance |
AOInstance | AO instance |
Listens to Events:
Returns:
p - resolves on completion
- Type
- Promise
(async, static) onOrdersOrderCancel(instance, order) → {Promise}
Triggered when an atomic order cancellation is detected, and cancels any
open orders before emitting an exec:stop
event to trigger teardown.
Parameters:
Name | Type | Description |
---|---|---|
instance |
AOInstance | AO instance |
order |
object | the order that was cancelled |
Listens to Events:
Returns:
p - resolves on completion
- Type
- Promise
(async, static) onOrdersOrderFill(instance, order) → {Promise}
Triggered on atomic order fill. If it was a ping
, the associated pong
is submitted. Otherwise it if was a pong
and the instance was configured
as endless
, the associated ping
is submitted. If not endless
, nothing
is done.
Parameters:
Name | Type | Description |
---|---|---|
instance |
AOInstance | AO instance |
order |
object | the order that filled |
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 a PingPong 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:
- See:
Creates a POJO from an instance's state which can be stored as JSON in a
database, and later loaded with the corresponding
module:PingPong~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:
- See:
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 PingPong order.
Part of the meta
handler section.
Parameters:
Name | Type | Description | ||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
args |
object | incoming parameters Properties
|
Returns:
error - null if parameters are valid, otherwise a description of which parameter is invalid.
- Type
- string