Traders
Traders use the SDK component AccountTrade to post orders.
AccountTrade ⇐ WriteAccessHandler
WriteAccessHandler
Functions to create, submit and cancel orders on the exchange. This class requires a private key and executes smart-contract interactions that require gas-payments.
Kind: global class
Extends: WriteAccessHandler
AccountTrade ⇐
WriteAccessHandler
new AccountTrade(config, signer)
.cancelOrder(symbol, orderId) ⇒
ContractTransaction
.order(order) ⇒
ContractTransaction
.queryExchangeFee(poolSymbolName, [brokerAddr]) ⇒
.getCurrentTraderVolume(poolSymbolName) ⇒
number
.getOrderIds(symbol) ⇒
Array.<string>
.addCollateral(symbol, amount)
.removeCollateral(symbol, amount)
new AccountTrade(config, signer)
Constructor
Param | Type | Description |
---|---|---|
config |
| Configuration object, see PerpetualDataHandler. readSDKConfig. |
signer |
| Private key or ethers Signer of the account |
Example
accountTrade.cancelOrder(symbol, orderId) ⇒ ContractTransaction
ContractTransaction
Cancels an existing order on the exchange.
Kind: instance method of AccountTrade
Returns: ContractTransaction
-
Contract Transaction (containing events).
Param | Type | Description |
---|---|---|
symbol |
| Symbol of the form ETH-USD-MATIC. |
orderId |
| ID of the order to be cancelled. |
Example
accountTrade.order(order) ⇒ ContractTransaction
ContractTransaction
Submits an order to the exchange.
Kind: instance method of AccountTrade
Returns: ContractTransaction
-
Contract Transaction (containing events).
Param | Type | Description |
---|---|---|
order |
| Order structure. As a minimum the structure needs to specify symbol, side, type and quantity. |
Example
accountTrade.queryExchangeFee(poolSymbolName, [brokerAddr]) ⇒
Fee charged by the exchange for trading any perpetual on a given pool. It accounts for the current trader's fee tier (based on the trader's D8X balance and trading volume). If trading with a broker, it also accounts for the selected broker's fee tier. Note that this result only includes exchange fees, additional broker fees are not included.
Kind: instance method of AccountTrade
Returns:
Exchange fee, in decimals (i.e. 0.1% is 0.001).
Param | Type | Description |
---|---|---|
poolSymbolName |
| Pool symbol name (e.g. MATIC, USDC, etc). |
[brokerAddr] |
| Optional address of a broker this trader may use to trade under. |
Example
accountTrade.getCurrentTraderVolume(poolSymbolName) ⇒ number
number
Exponentially weighted EMA of the total USD trading volume of all trades performed by this trader. The weights are chosen so that in average this coincides with the 30 day volume.
Kind: instance method of AccountTrade
Returns: number
-
Current trading volume for this trader, in USD.
Param | Type | Description |
---|---|---|
poolSymbolName |
| Pool symbol name (e.g. MATIC, USDC, etc). |
Example
accountTrade.getOrderIds(symbol) ⇒ Array.<string>
Array.<string>
Kind: instance method of AccountTrade
Returns: Array.<string>
-
Array of Ids for all the orders currently open by this trader.
Param | Description |
---|---|
symbol | Symbol of the form ETH-USD-MATIC. |
Example
accountTrade.addCollateral(symbol, amount)
Kind: instance method of AccountTrade
Param | Type | Description |
---|---|---|
symbol |
| Symbol of the form ETH-USD-MATIC. |
amount |
| How much collateral to add, in units of collateral currency, e.g. MATIC |
Example
accountTrade.removeCollateral(symbol, amount)
Kind: instance method of AccountTrade
Param | Type | Description |
---|---|---|
symbol |
| Symbol of the form ETH-USD-MATIC. |
amount |
| How much collateral to remove, in units of collateral currency, e.g. MATIC |
Example