Built-in Functions
Structures
Built-in Variables and Constants
Conventions
Exchanges
Poloniex
Spot trading on Poloniex (API address https://api.poloniex.com, v3 API); orders are placed in the SPOT account (accountType is SPOT). It uses REST only, with no market-data or order push. Private endpoints are signed with a Poloniex API key (Access Key and Secret Key). Conditional orders use Poloniex smart orders (/smartorders) and support stop-loss only.
Names and Configuration
exchange.GetName(): Poloniex (Spot).
| Field | Required |
|---|---|
| Access Key | Yes |
| Secret Key | Yes |
Trading Pairs and Contract Codes
Pair examples: BTC_USDT, ETH_USDT
Trading pairs are written BASE_QUOTE, the same form as the Poloniex native code.
Exchange-specific IO Commands
| Command | Arguments | Description | Returns |
|---|---|---|---|
accountId | string | Set the ID of the spot account that exchange.GetAccount reads; once set, only this spot account is read and an error is reported if it is not found; pass an empty string to restore the default (the first spot account). It does not affect exchange.GetAssets, which always sums all spot accounts. | A null value. |
For the common commands api, base and currency see exchange.IO.
Common Usage
List the spot accounts and choose the one exchange.GetAccount() reads
javascript
function main() {
// The exchange's account list; each item has accountId, accountType (such as SPOT)
// and accountState
var accounts = exchange.IO("api", "GET", "/accounts")
Log(accounts)
// From now on exchange.GetAccount() reads only this spot account (an error if not found)
exchange.IO("accountId", accounts[0].accountId)
Log(exchange.GetAccount())
// An empty string restores the default (the first spot account)
exchange.IO("accountId", "")
}
Function Support
Not supported (the call fails with an error and returns null): exchange.ModifyConditionOrder.
Served through a fallback:
exchange.GetRecords: Native periods are 1m, 5m, 10m, 15m, 30m, 1h, 2h, 4h, 6h, 12h, 1d, 3d, 1w, 1M; other periods are synthesized by the docker.
Notes
- The amount of a market buy order is the quote currency to spend (placed as Poloniex's
amount); a market sell order uses the base-currency quantity. - Limit orders support IOC, FOK and maker-only (
postOnly). exchange.ModifyOrder()uses Poloniex's replace endpoint: the exchange cancels the original order and places a new one, and the new order ID is returned; use the new ID from then on. A price or amount that is not positive is left unchanged. The amended amount is always the base-currency quantity (Poloniex'squantity), including when only the amount of a buy order is changed.- Spot conditional orders support stop-loss only (
ORDER_CONDITION_TYPE_SL): a buy triggers when the price rises to the trigger price, a sell when it falls to the trigger price. Take-profit (ORDER_CONDITION_TYPE_TP) and OCO conditional orders return an error and no order is placed. Without an order price they execute at market once triggered. The amount of a conditional order is always the base-currency quantity, for both buys and sells. - Conditional orders and normal orders have separate order IDs: a conditional order can only be canceled with
exchange.CancelConditionOrder. The normal order created when a conditional order triggers appears inexchange.GetOrders(), whileexchange.GetConditionOrders()lists only untriggered conditional orders. exchange.GetAccount()reads one SPOT account: the one set withexchange.IO("accountId", id), or the first SPOT account when none is set;exchange.GetAssets()sums the assets of all SPOT accounts.