Iceberg allows you to place a large order on the market while ensuring only a small part of it is ever filled at once. By enabling the 'Excess As Hidden' option, it is possible to offer up the remainder as a hidden order, allowing for minimal market disruption when executing large trades.
- Source:
Example
await host.startAO('bfx-iceberg', {
symbol: 'tBTCUSD',
price: 21000,
amount: -0.5,
sliceAmount: -0.1,
excessAsHidden: true,
orderType: 'LIMIT',
submitDelay: 150,
cancelDelay: 150,
_margin: false,
})
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
symbol |
string | symbol to trade on |
|
amount |
number | total order amount |
|
sliceAmount |
number | iceberg slice order amount |
|
sliceAmountPerc |
number |
<optional> |
optional, slice amount as % of total amount |
excessAsHidden |
boolean | whether to submit remainder as a hidden order |
|
orderType |
string | LIMIT or MARKET |
|
submitDelay |
number |
<optional> |
in ms, default 1500 |
cancelDelay |
number |
<optional> |
in ms, default 5000 |
_margin |
boolean |
<optional> |
if false, prefixes order type with EXCHANGE |
Members
(static) generateOrders
Returns an order set for the provided Iceberg instance, including a slice order and the remaining amount as a hidden order if configured.
Methods
(static) declareEvents(instance, host)
- Source:
Declares internal self:submit_orders
event 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) genOrderLabel(state) → {string}
- Source:
Generates a label for an Iceberg 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) genOrderLabel(state) → {string}
Generates a label for an MACrossver 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 Iceberg 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 Iceberg, with a field for each parameter.
Part of the meta
handler section.
Returns:
uiDef
- Type
- AOUIDefinition
(static) initState(args) → {object}
- Source:
Creates an initial state object for an Iceberg 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) onLifeStart(instance) → {Promise}
Parameters:
Name | Type | Description |
---|---|---|
instance |
AOInstance | AO instance |
Fires:
Listens to Events:
Returns:
p - resolves on completion
- Type
- Promise
(async, static) onLifeStop(instance)
- Source:
Cancels any pending order submits prior to teardown
Parameters:
Name | Type | Description |
---|---|---|
instance |
AOInstance | AO instance |
Listens to Events:
(async, static) onOrdersOrderCancel(instance, order) → {Promise}
Called 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) onOrdersOrderFill(instance, order) → {Promise}
Called when an order is filled. Cancels any remaining open orders (slice or excess), updates the remaining amount on the instance state, and submits the next order set.
Parameters:
Name | Type | Description |
---|---|---|
instance |
AOInstance | AO instance |
order |
object | order that filled |
Listens to Events:
Returns:
p - resolves on completion
- Type
- Promise
(async, static) onSelfSubmitOrders(instance) → {Promise}
- Source:
- See:
-
- module:Iceberg~generateOrders
Submits the next slice order, and remaining amount as a hidden order if configured.
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 Iceberg 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:Iceberg~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 Icberg 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
Events
event:selfSubmitOrders
- Source:
Triggers order submit for both the slice and remainder if configured.