Cryptocurrency | Perpetual Contract | Phemex

This document outlines the appropriate format that the traders must follow while writing the webhook payload for setting up the following types of perpetual contract market orders to be executed into Phemex.

Let’s get started 🚀

Market Order

The traders can write the webhook payload for setting up Market orders using these three payload fields:

  • Symbol
  • Action
  • Quantity

Symbol

The ticker symbol of the asset. Phemex provides three distinct types of perpetual contracts, namely USDⓢ-M, COIN-M, and USD-M.

I. If you choose the USDⓢ-M perpetual contract, this particular contract uses USDT as the margin. As a result, the ticker symbol for this contract takes the form of something like this:

  • BTCUSDT: BTCUSDT is a BTCUSDT perpetual contract priced on the .BTC Index. Each contract is worth 1 BTC of USDT. Funding is paid and received every 8 hours.
  • ETHUSDT: ETHUSDT is an ETHUSDT perpetual contract priced on the .ETH Index. Each contract is worth 1 ETH of USDT. Funding is paid and received every 8 hours.

II. If you choose the COIN-M perpetual contract, this specific contract uses COIN as the collateral.  As a result, the ticker symbol for this contract takes the form of something like this:

  • BTCUSD: BTCUSD is a BTCUSD perpetual contract priced on the .BTC Index. Each contract is worth 1 USD of BTC. Funding is paid and received every 8 hours.
  • ETHUSD: ETHUSD is an ETHUSD perpetual contract priced on the .ETH Index. Each contract is worth 1 USD of ETH. Funding is paid and received every 8 hours.

III. If you choose the USD-M perpetual contract then, this particular contract uses USD as the margin. As a result, the ticker symbol for this contract takes the form of something like this:

  • BTCUSD: BTCUSD is a BTCUSD perpetual contract priced on the .BTC Index. Each contract is worth 0.001 BTC of USD. Funding is paid and received every 8 hours.
  • ETHUSD: ETHUSD is an ETHUSD perpetual contract priced on the .ETH Index. Each contract is worth 0.005 ETH of USD. Funding is paid and received every 8 hours.

Action

The signal action indicates the type of trade to be triggered. The action can be any of the following:

  • Buy: Triggers an action to buy the asset.
  • Sell: Triggers an action to sell the asset.

Quantity

The number of assets to be traded. If omitted, the quantity will be dynamically calculated or defaulted to 1.

Note: You can also use the JSON field- quantity_type

This is an optional field indicating the type of quantity being specified. We have three options - fixed, cash, and percent_of_equity.

Fixed (Default): The trade quantity will be set as a fixed quantity, such as “100” shares or “10” shares.

{
 "quantity": 100,
 "quantity_type": "fixed"
}

Cash: The trade quantity is represented by the available cash amount. For instance, if the quantity_type is set to "cash", and the trader specifies a value of 100, it means they are trading 100 units of the currency value, such as 100 USD or 100 GBP, depending on the currency locale of the trader.

{
 "quantity": 100,
 "quantity_type": "cash"
}

Percent_of_equity: The quantity is calculated as a percentage of the total equity (account balance, not including unrealized p/l). For instance, if the total equity is $50,000 and the quantity_type is set to “percent_of_equity” with the value of “2” then the trade quantity would be $50,000*0.02 = $1000.

{
  "quantity": 2,
  "quantity_type": "percent_of_equity"
}

EXAMPLE

I. Buy

{
  "symbol": "BTCUSDT",
  "action": "buy",
  "quantity": 123
}

II. Sell

{
  "symbol": "BTCUSDT",
  "action": "sell",
  "quantity": 123
}

Limit Order

The traders can write the webhook payload for setting up Limit orders using these four payload fields:

  • Symbol
  • Action
  • Quantity
  • Limit_price

Symbol

The ticker symbol of the asset. Phemex provides three distinct types of perpetual contracts, namely USDⓢ-M, COIN-M, and USD-M.

I. If you choose the USDⓢ-M perpetual contract, this particular contract uses USDT as the margin. As a result, the ticker symbol for this contract takes the form of something like this:

  • BTCUSDT: BTCUSDT is a BTCUSDT perpetual contract priced on the .BTC Index. Each contract is worth 1 BTC of USDT. Funding is paid and received every 8 hours.
  • ETHUSDT: ETHUSDT is an ETHUSDT perpetual contract priced on the .ETH Index. Each contract is worth 1 ETH of USDT. Funding is paid and received every 8 hours.

II. If you choose the COIN-M perpetual contract, this specific contract uses COIN as the collateral.  As a result, the ticker symbol for this contract takes the form of something like this:

  • BTCUSD: BTCUSD is a BTCUSD perpetual contract priced on the .BTC Index. Each contract is worth 1 USD of BTC. Funding is paid and received every 8 hours.
  • ETHUSD: ETHUSD is an ETHUSD perpetual contract priced on the .ETH Index. Each contract is worth 1 USD of ETH. Funding is paid and received every 8 hours.

III. If you choose the USD-M perpetual contract then, this particular contract uses USD as the margin. As a result, the ticker symbol for this contract takes the form of something like this:

  • BTCUSD: BTCUSD is a BTCUSD perpetual contract priced on the .BTC Index. Each contract is worth 0.001 BTC of USD. Funding is paid and received every 8 hours.
  • ETHUSD: ETHUSD is an ETHUSD perpetual contract priced on the .ETH Index. Each contract is worth 0.005 ETH of USD. Funding is paid and received every 8 hours.

Action

The signal action indicates the type of trade to be triggered. The action can be any of the following:

  • Buy: Triggers an action to buy the asset.
  • Sell: Triggers an action to sell the asset.

Quantity

The number of assets to be traded. If omitted, the quantity will be dynamically calculated or defaulted to 1.

Note: You can also use the JSON field- quantity_type

This is an optional field indicating the type of quantity being specified. We have three options - fixed, cash, and percent_of_equity.

Fixed (Default): The trade quantity will be set as a fixed quantity, such as “100” shares or “10” shares.

{
 "quantity": 100,
 "quantity_type": "fixed"
}

Cash: The trade quantity is represented by the available cash amount. For instance, if the quantity_type is set to "cash", and the trader specifies a value of 100, it means they are trading 100 units of the currency value, such as 100 USD or 100 GBP, depending on the currency locale of the trader.

{
 "quantity": 100,
 "quantity_type": "cash"
}

Percent_of_equity: The quantity is calculated as a percentage of the total equity (account balance, not including unrealized p/l). For instance, if the total equity is $50,000 and the quantity_type is set to “percent_of_equity” with the value of “2” then the trade quantity would be $50,000*0.02 = $1000.

{
  "quantity": 2,
  "quantity_type": "percent_of_equity"
}

Limit_price

An optional field specifying the execution price for a “buy” or  “sell” trade. If you specify the limit price the trade will be executed at the specified limit price. Or If you choose not to specify a limit price, the trade will be executed at the current market price.

EXAMPLE

I. Buy

{
  "symbol": "BTCUSDT",
  "action": "buy",
  "quantity": 123,
   "limit_price": 123.98
}

II. Sell

{
  "symbol": "BTCUSDT",
  "action": "sell",
  "quantity": 123,
   "limit_price": 123.98
}

Stop Order

The traders can write the webhook payload for setting up Stop orders using these four payload fields:

  • Symbol
  • Action
  • Quantity
  • Stop_price

Symbol

The ticker symbol of the asset. Phemex provides three distinct types of perpetual contracts, namely USDⓢ-M, COIN-M, and USD-M.

I. If you choose the USDⓢ-M perpetual contract, this particular contract uses USDT as the margin. As a result, the ticker symbol for this contract takes the form of something like this:

  • BTCUSDT: BTCUSDT is a BTCUSDT perpetual contract priced on the .BTC Index. Each contract is worth 1 BTC of USDT. Funding is paid and received every 8 hours.
  • ETHUSDT: ETHUSDT is an ETHUSDT perpetual contract priced on the .ETH Index. Each contract is worth 1 ETH of USDT. Funding is paid and received every 8 hours.

II. If you choose the COIN-M perpetual contract, this specific contract uses COIN as the collateral.  As a result, the ticker symbol for this contract takes the form of something like this:

  • BTCUSD: BTCUSD is a BTCUSD perpetual contract priced on the .BTC Index. Each contract is worth 1 USD of BTC. Funding is paid and received every 8 hours.
  • ETHUSD: ETHUSD is an ETHUSD perpetual contract priced on the .ETH Index. Each contract is worth 1 USD of ETH. Funding is paid and received every 8 hours.

III. If you choose the USD-M perpetual contract then, this particular contract uses USD as the margin. As a result, the ticker symbol for this contract takes the form of something like this:

  • BTCUSD: BTCUSD is a BTCUSD perpetual contract priced on the .BTC Index. Each contract is worth 0.001 BTC of USD. Funding is paid and received every 8 hours.
  • ETHUSD: ETHUSD is an ETHUSD perpetual contract priced on the .ETH Index. Each contract is worth 0.005 ETH of USD. Funding is paid and received every 8 hours.

Action

The signal action indicates the type of trade to be triggered. The action can be any of the following:

  • Buy: Triggers an action to buy the asset.
  • Sell: Triggers an action to sell the asset.

Quantity

The number of assets to be traded. If omitted, the quantity will be dynamically calculated or defaulted to 1.

Note: You can also use the JSON field- quantity_type

This is an optional field indicating the type of quantity being specified. We have three options - fixed, cash, and percent_of_equity.

Fixed (Default): The trade quantity will be set as a fixed quantity, such as “100” shares or “10” shares.

{
 "quantity": 100,
 "quantity_type": "fixed"
}

Cash: The trade quantity is represented by the available cash amount. For instance, if the quantity_type is set to "cash", and the trader specifies a value of 100, it means they are trading 100 units of the currency value, such as 100 USD or 100 GBP, depending on the currency locale of the trader.

{
 "quantity": 100,
 "quantity_type": "cash"
}

Percent_of_equity: The quantity is calculated as a percentage of the total equity (account balance, not including unrealized p/l). For instance, if the total equity is $50,000 and the quantity_type is set to “percent_of_equity” with the value of “2” then the trade quantity would be $50,000*0.02 = $1000.

{
  "quantity": 2,
  "quantity_type": "percent_of_equity"
}

Stop_price

An optional field specifying the price level at which a stop-loss or stop-limit order should be triggered. It helps limits potential losses by automatically closing the position when the specified price is reached.

EXAMPLE

I. Buy

{
  "symbol": "BTCUSDT",
  "action": "buy",
  "quantity": 123,
   "stop_price": 123.98
}

II. Sell

{
  "symbol": "BTCUSDT",
  "action": "sell",
  "quantity": 123,
   "stop_price": 123.98
}

Stop-Limit Order

The traders can write the webhook payload for setting up Stop-Limit orders using these five payload fields:

  • Symbol
  • Action
  • Quantity
  • Limit_price
  • Stop_price

Symbol

The ticker symbol of the asset. Phemex provides three distinct types of perpetual contracts, namely USDⓢ-M, COIN-M, and USD-M.

I. If you choose the USDⓢ-M perpetual contract, this particular contract uses USDT as the margin. As a result, the ticker symbol for this contract takes the form of something like this:

  • BTCUSDT: BTCUSDT is a BTCUSDT perpetual contract priced on the .BTC Index. Each contract is worth 1 BTC of USDT. Funding is paid and received every 8 hours.
  • ETHUSDT: ETHUSDT is an ETHUSDT perpetual contract priced on the .ETH Index. Each contract is worth 1 ETH of USDT. Funding is paid and received every 8 hours.

II. If you choose the COIN-M perpetual contract, this specific contract uses COIN as the collateral.  As a result, the ticker symbol for this contract takes the form of something like this:

  • BTCUSD: BTCUSD is a BTCUSD perpetual contract priced on the .BTC Index. Each contract is worth 1 USD of BTC. Funding is paid and received every 8 hours.
  • ETHUSD: ETHUSD is an ETHUSD perpetual contract priced on the .ETH Index. Each contract is worth 1 USD of ETH. Funding is paid and received every 8 hours.

III. If you choose the USD-M perpetual contract then, this particular contract uses USD as the margin. As a result, the ticker symbol for this contract takes the form of something like this:

  • BTCUSD: BTCUSD is a BTCUSD perpetual contract priced on the .BTC Index. Each contract is worth 0.001 BTC of USD. Funding is paid and received every 8 hours.
  • ETHUSD: ETHUSD is an ETHUSD perpetual contract priced on the .ETH Index. Each contract is worth 0.005 ETH of USD. Funding is paid and received every 8 hours.

Action

The signal action indicates the type of trade to be triggered. The action can be any of the following:

  • Buy: Triggers an action to buy the asset.
  • Sell: Triggers an action to sell the asset.

Quantity

The number of assets to be traded. If omitted, the quantity will be dynamically calculated or defaulted to 1.

Note: You can also use the JSON field- quantity_type

This is an optional field indicating the type of quantity being specified. We have three options - fixed, cash, and percent_of_equity.

Fixed (Default): The trade quantity will be set as a fixed quantity, such as “100” shares or “10” shares.

{
 "quantity": 100,
 "quantity_type": "fixed"
}

Cash: The trade quantity is represented by the available cash amount. For instance, if the quantity_type is set to "cash", and the trader specifies a value of 100, it means they are trading 100 units of the currency value, such as 100 USD or 100 GBP, depending on the currency locale of the trader.

{
 "quantity": 100,
 "quantity_type": "cash"
}

Percent_of_equity: The quantity is calculated as a percentage of the total equity (account balance, not including unrealized p/l). For instance, if the total equity is $50,000 and the quantity_type is set to “percent_of_equity” with the value of “2” then the trade quantity would be $50,000*0.02 = $1000.

{
  "quantity": 2,
  "quantity_type": "percent_of_equity"
}

Limit_price

An optional field specifying the execution price for a “buy” or  “sell” trade. If you specify the limit price the trade will be executed at the specified limit price. Or If you choose not to specify a limit price, the trade will be executed at the current market price.

Stop_price

An optional field specifying the price level at which a stop-loss or stop-limit order should be triggered. It helps limits potential losses by automatically closing the position when the specified price is reached.

EXAMPLE

I. Buy

{
  "symbol": "BTCUSDT",
  "action": "buy",
  "quantity": 123,
   "limit_price": 123.98,
   "stop_price": 123.98
}

II. Sell

{
  "symbol": "BTCUSDT",
  "action": "sell",
  "quantity": 123,
   "limit_price": 123.98,
   "stop_price": 123.98
}




Contact Us

Not finding what you're looking for? Contact Us Directly