Daman Markets API Reference
Programmatic GraphQL access to the Daman Markets: 29 operations across 1 module covering derivatives trading.
Get a Bearer Token
Exchange your API key + secret for a JWT via service_signin, then pass it as Authorization: Bearer <token> on every request and to enable the Try It action below. Create an API key in your Daman Markets account settings. It returns an api_key_id and api_key_secret. Tokens are short-lived; sign in again to refresh.
Introduction
The Daman Markets API is a GraphQL API. All requests are sent as POST to the /graphql endpoint with a JSON body containing query and variables, and an Authorization: Bearer <token> header.
Authentication
Programmatic access uses an API key + secret exchanged for a short-lived JWT.
- Create an API key in your Daman Markets account settings. It returns
api_key_idandapi_key_secret(the secret is shown only once). - Exchange the key for a JWT:
service_signin(service_api_key, service_api_secret)→{ jwt, expires_at }. - Send
Authorization: Bearer <jwt>on every request. If the key hashmac_requiredenabled, also HMAC-sign each request with the secret.
Endpoints
Daman Markets exposes 2 GraphQL services on production. The core gateway is used only to exchange your API key for a bearer token; every documented operation runs on the other service. Every operation below states the endpoint it belongs to, and its Try It runner is already pointed at the right one:
https://vakotrade-damanx.cryptosrvc.com/graphql sign-in only
https://margin-trading-service-damanx.cryptosrvc.com/graphql Derivatives
Request shape
POST /graphql HTTP/1.1
Authorization: Bearer <token>
Content-Type: application/json
{
"query": "query { instruments { instrument_id name } }",
"variables": {}
}
Errors
GraphQL errors are returned in the errors array of the response body with HTTP status 200. Network and auth errors return non-200 statuses.
Permissions
Each operation is gated by a permission scope on the API key. A token only succeeds on operations the key's permissions grant.
Derivatives
29 operations across 6 areas · service: https://margin-trading-service-damanx.cryptosrvc.com/graphql
History
2 ops
query margin_funding_fees Margin Funding Fees
Inputs
| Name | Type | Required |
|---|---|---|
sort |
SortInput |
optional |
pager |
PagerInput |
optional |
dateRange |
DateRangeInput |
optional |
margin_position_id |
String |
optional |
wallet_id |
String |
optional |
Response
| Field | Sub-fields |
|---|---|
amount |
scalar |
updated_at_iso |
scalar |
margin_position_id |
scalar |
position_size |
scalar |
rate |
scalar |
currency_id |
scalar |
rate_type |
scalar |
GraphQL Operation
query margin_funding_fees($sort: SortInput, $pager: PagerInput, $dateRange: DateRangeInput, $margin_position_id: String, $wallet_id: String) {
margin_funding_fees(sort: $sort, pager: $pager, dateRange: $dateRange, margin_position_id: $margin_position_id, wallet_id: $wallet_id) {
amount
updated_at_iso
margin_position_id
position_size
rate
currency_id
rate_type
}
}
Code Examples
curl -X POST 'https://margin-trading-service-damanx.cryptosrvc.com/graphql' \
-H 'Authorization: Bearer YOUR_TOKEN' \
-H 'Content-Type: application/json' \
-d '{"query":"query margin_funding_fees($sort: SortInput, $pager: PagerInput, $dateRange: DateRangeInput, $margin_position_id: String, $wallet_id: String) { margin_funding_fees(sort: $sort, pager: $pager, dateRange: $dateRange, margin_position_id: $margin_position_id, wallet_id: $wallet_id) { amount updated_at_iso margin_position_id position_size rate currency_id rate_type } }","variables":{}}'
import requests
url = "https://margin-trading-service-damanx.cryptosrvc.com/graphql"
headers = {
"Authorization": "Bearer YOUR_TOKEN",
"Content-Type": "application/json",
}
payload = {
"query": """query margin_funding_fees($sort: SortInput, $pager: PagerInput, $dateRange: DateRangeInput, $margin_position_id: String, $wallet_id: String) { margin_funding_fees(sort: $sort, pager: $pager, dateRange: $dateRange, margin_position_id: $margin_position_id, wallet_id: $wallet_id) { amount updated_at_iso margin_position_id position_size rate currency_id rate_type } }""",
"variables": {},
}
response = requests.post(url, json=payload, headers=headers)
print(response.json())
const response = await fetch("https://margin-trading-service-damanx.cryptosrvc.com/graphql", {
method: "POST",
headers: {
"Authorization": `Bearer ${YOUR_TOKEN}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
query: `query margin_funding_fees($sort: SortInput, $pager: PagerInput, $dateRange: DateRangeInput, $margin_position_id: String, $wallet_id: String) { margin_funding_fees(sort: $sort, pager: $pager, dateRange: $dateRange, margin_position_id: $margin_position_id, wallet_id: $wallet_id) { amount updated_at_iso margin_position_id position_size rate currency_id rate_type } }`,
variables: {},
}),
});
const data = await response.json();
console.log(data);Try It
query margin_funding_rates_history Margin Funding Rates History
Inputs
| Name | Type | Required |
|---|---|---|
margin_instrument_strategy_id |
String |
optional |
pager |
PagerInput |
optional |
dateRange |
DateRangeInput |
optional |
Response
| Field | Sub-fields |
|---|---|
updated_at_iso |
scalar |
short_funding_rate |
scalar |
long_funding_rate |
scalar |
margin_instrument_id |
scalar |
GraphQL Operation
query margin_funding_rates_history($margin_instrument_strategy_id: String, $pager: PagerInput, $dateRange: DateRangeInput) {
margin_funding_rates_history(margin_instrument_strategy_id: $margin_instrument_strategy_id, pager: $pager, dateRange: $dateRange) {
updated_at_iso
short_funding_rate
long_funding_rate
margin_instrument_id
}
}
Code Examples
curl -X POST 'https://margin-trading-service-damanx.cryptosrvc.com/graphql' \
-H 'Authorization: Bearer YOUR_TOKEN' \
-H 'Content-Type: application/json' \
-d '{"query":"query margin_funding_rates_history($margin_instrument_strategy_id: String, $pager: PagerInput, $dateRange: DateRangeInput) { margin_funding_rates_history(margin_instrument_strategy_id: $margin_instrument_strategy_id, pager: $pager, dateRange: $dateRange) { updated_at_iso short_funding_rate long_funding_rate margin_instrument_id } }","variables":{}}'
import requests
url = "https://margin-trading-service-damanx.cryptosrvc.com/graphql"
headers = {
"Authorization": "Bearer YOUR_TOKEN",
"Content-Type": "application/json",
}
payload = {
"query": """query margin_funding_rates_history($margin_instrument_strategy_id: String, $pager: PagerInput, $dateRange: DateRangeInput) { margin_funding_rates_history(margin_instrument_strategy_id: $margin_instrument_strategy_id, pager: $pager, dateRange: $dateRange) { updated_at_iso short_funding_rate long_funding_rate margin_instrument_id } }""",
"variables": {},
}
response = requests.post(url, json=payload, headers=headers)
print(response.json())
const response = await fetch("https://margin-trading-service-damanx.cryptosrvc.com/graphql", {
method: "POST",
headers: {
"Authorization": `Bearer ${YOUR_TOKEN}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
query: `query margin_funding_rates_history($margin_instrument_strategy_id: String, $pager: PagerInput, $dateRange: DateRangeInput) { margin_funding_rates_history(margin_instrument_strategy_id: $margin_instrument_strategy_id, pager: $pager, dateRange: $dateRange) { updated_at_iso short_funding_rate long_funding_rate margin_instrument_id } }`,
variables: {},
}),
});
const data = await response.json();
console.log(data);Try It
Instruments
6 ops
query derivatives_enabled Derivatives Enabled
Inputs
Response
GraphQL Operation
query derivatives_enabled {
derivatives_enabled
}
Code Examples
curl -X POST 'https://margin-trading-service-damanx.cryptosrvc.com/graphql' \
-H 'Authorization: Bearer YOUR_TOKEN' \
-H 'Content-Type: application/json' \
-d '{"query":"query derivatives_enabled { derivatives_enabled }","variables":{}}'
import requests
url = "https://margin-trading-service-damanx.cryptosrvc.com/graphql"
headers = {
"Authorization": "Bearer YOUR_TOKEN",
"Content-Type": "application/json",
}
payload = {
"query": """query derivatives_enabled { derivatives_enabled }""",
"variables": {},
}
response = requests.post(url, json=payload, headers=headers)
print(response.json())
const response = await fetch("https://margin-trading-service-damanx.cryptosrvc.com/graphql", {
method: "POST",
headers: {
"Authorization": `Bearer ${YOUR_TOKEN}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
query: `query derivatives_enabled { derivatives_enabled }`,
variables: {},
}),
});
const data = await response.json();
console.log(data);Try It
This operation takes no inputs.
query margin_currencies Margin Currencies
Inputs
| Name | Type | Required |
|---|---|---|
is_active |
ToggleSwitch |
required |
pager |
PagerInput |
optional |
Response
| Field | Sub-fields |
|---|---|
currency_id |
scalar |
precision |
scalar |
GraphQL Operation
query margin_currencies($is_active: ToggleSwitch!, $pager: PagerInput) {
margin_currencies(is_active: $is_active, pager: $pager) {
currency_id
precision
}
}
Code Examples
curl -X POST 'https://margin-trading-service-damanx.cryptosrvc.com/graphql' \
-H 'Authorization: Bearer YOUR_TOKEN' \
-H 'Content-Type: application/json' \
-d '{"query":"query margin_currencies($is_active: ToggleSwitch!, $pager: PagerInput) { margin_currencies(is_active: $is_active, pager: $pager) { currency_id precision } }","variables":{}}'
import requests
url = "https://margin-trading-service-damanx.cryptosrvc.com/graphql"
headers = {
"Authorization": "Bearer YOUR_TOKEN",
"Content-Type": "application/json",
}
payload = {
"query": """query margin_currencies($is_active: ToggleSwitch!, $pager: PagerInput) { margin_currencies(is_active: $is_active, pager: $pager) { currency_id precision } }""",
"variables": {},
}
response = requests.post(url, json=payload, headers=headers)
print(response.json())
const response = await fetch("https://margin-trading-service-damanx.cryptosrvc.com/graphql", {
method: "POST",
headers: {
"Authorization": `Bearer ${YOUR_TOKEN}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
query: `query margin_currencies($is_active: ToggleSwitch!, $pager: PagerInput) { margin_currencies(is_active: $is_active, pager: $pager) { currency_id precision } }`,
variables: {},
}),
});
const data = await response.json();
console.log(data);Try It
subscription margin_instrument_price_bar Margin Instrument Price Bar
Inputs
| Name | Type | Required |
|---|---|---|
instrument_id |
String |
required |
periodicity |
MarginInstrumentHistoryPeriodicity |
required |
Response
| Field | Sub-fields |
|---|---|
margin_instrument_id |
scalar |
high |
scalar |
low |
scalar |
updated_at |
scalar |
updated_at_iso |
scalar |
close |
scalar |
open |
scalar |
GraphQL Operation
subscription margin_instrument_price_bar($instrument_id: String!, $periodicity: MarginInstrumentHistoryPeriodicity!) {
margin_instrument_price_bar(instrument_id: $instrument_id, periodicity: $periodicity) {
margin_instrument_id
high
low
updated_at
updated_at_iso
close
open
}
}
Code Examples
curl -X POST 'https://margin-trading-service-damanx.cryptosrvc.com/graphql' \
-H 'Authorization: Bearer YOUR_TOKEN' \
-H 'Content-Type: application/json' \
-d '{"query":"subscription margin_instrument_price_bar($instrument_id: String!, $periodicity: MarginInstrumentHistoryPeriodicity!) { margin_instrument_price_bar(instrument_id: $instrument_id, periodicity: $periodicity) { margin_instrument_id high low updated_at updated_at_iso close open } }","variables":{}}'
import requests
url = "https://margin-trading-service-damanx.cryptosrvc.com/graphql"
headers = {
"Authorization": "Bearer YOUR_TOKEN",
"Content-Type": "application/json",
}
payload = {
"query": """subscription margin_instrument_price_bar($instrument_id: String!, $periodicity: MarginInstrumentHistoryPeriodicity!) { margin_instrument_price_bar(instrument_id: $instrument_id, periodicity: $periodicity) { margin_instrument_id high low updated_at updated_at_iso close open } }""",
"variables": {},
}
response = requests.post(url, json=payload, headers=headers)
print(response.json())
const response = await fetch("https://margin-trading-service-damanx.cryptosrvc.com/graphql", {
method: "POST",
headers: {
"Authorization": `Bearer ${YOUR_TOKEN}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
query: `subscription margin_instrument_price_bar($instrument_id: String!, $periodicity: MarginInstrumentHistoryPeriodicity!) { margin_instrument_price_bar(instrument_id: $instrument_id, periodicity: $periodicity) { margin_instrument_id high low updated_at updated_at_iso close open } }`,
variables: {},
}),
});
const data = await response.json();
console.log(data);Try It
Subscriptions are delivered over WebSocket (wss://). Use a GraphQL-WS client rather than this HTTP runner.
query margin_instrument_price_bars Margin Instrument Price Bars
Inputs
| Name | Type | Required |
|---|---|---|
instrument_id |
String |
required |
limit |
String |
optional |
date_range |
DateRangeInput |
optional |
periodicity |
MarginInstrumentHistoryPeriodicity |
optional |
Response
| Field | Sub-fields |
|---|---|
margin_instrument_id |
scalar |
high |
scalar |
low |
scalar |
updated_at |
scalar |
updated_at_iso |
scalar |
close |
scalar |
open |
scalar |
GraphQL Operation
query margin_instrument_price_bars($instrument_id: String!, $limit: String, $date_range: DateRangeInput, $periodicity: MarginInstrumentHistoryPeriodicity) {
margin_instrument_price_bars(instrument_id: $instrument_id, limit: $limit, date_range: $date_range, periodicity: $periodicity) {
margin_instrument_id
high
low
updated_at
updated_at_iso
close
open
}
}
Code Examples
curl -X POST 'https://margin-trading-service-damanx.cryptosrvc.com/graphql' \
-H 'Authorization: Bearer YOUR_TOKEN' \
-H 'Content-Type: application/json' \
-d '{"query":"query margin_instrument_price_bars($instrument_id: String!, $limit: String, $date_range: DateRangeInput, $periodicity: MarginInstrumentHistoryPeriodicity) { margin_instrument_price_bars(instrument_id: $instrument_id, limit: $limit, date_range: $date_range, periodicity: $periodicity) { margin_instrument_id high low updated_at updated_at_iso close open } }","variables":{}}'
import requests
url = "https://margin-trading-service-damanx.cryptosrvc.com/graphql"
headers = {
"Authorization": "Bearer YOUR_TOKEN",
"Content-Type": "application/json",
}
payload = {
"query": """query margin_instrument_price_bars($instrument_id: String!, $limit: String, $date_range: DateRangeInput, $periodicity: MarginInstrumentHistoryPeriodicity) { margin_instrument_price_bars(instrument_id: $instrument_id, limit: $limit, date_range: $date_range, periodicity: $periodicity) { margin_instrument_id high low updated_at updated_at_iso close open } }""",
"variables": {},
}
response = requests.post(url, json=payload, headers=headers)
print(response.json())
const response = await fetch("https://margin-trading-service-damanx.cryptosrvc.com/graphql", {
method: "POST",
headers: {
"Authorization": `Bearer ${YOUR_TOKEN}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
query: `query margin_instrument_price_bars($instrument_id: String!, $limit: String, $date_range: DateRangeInput, $periodicity: MarginInstrumentHistoryPeriodicity) { margin_instrument_price_bars(instrument_id: $instrument_id, limit: $limit, date_range: $date_range, periodicity: $periodicity) { margin_instrument_id high low updated_at updated_at_iso close open } }`,
variables: {},
}),
});
const data = await response.json();
console.log(data);Try It
query margin_instruments Margin Instruments
Inputs
| Name | Type | Required |
|---|---|---|
is_active |
ToggleSwitch |
required |
pager |
PagerInput |
optional |
search |
String |
optional |
Response
| Field | Sub-fields |
|---|---|
margin_instrument_id |
scalar |
name |
scalar |
base_currency_id |
scalar |
quote_currency_id |
scalar |
min_leverage |
scalar |
max_leverage |
scalar |
min_quantity |
scalar |
max_quantity |
scalar |
long_funding_rate |
scalar |
short_funding_rate |
scalar |
price_24h_change |
scalar |
price_decimals |
scalar |
quantity_decimals |
scalar |
price_24h_low |
scalar |
price_24h_high |
scalar |
is_trading_on |
scalar |
market_status |
scalar |
margin_instrument_strategy_is_active |
scalar |
margin_instrument_strategy_id |
scalar |
class |
scalar |
lot_size |
scalar |
step_size |
scalar |
cross_quote_price |
scalar |
close_only |
scalar |
base_currency |
currency_id, precision, is_active |
quote_currency |
currency_id, precision, is_active |
price |
margin_instrument_id, ask, bid, updated_at |
funding_data |
rate_type, next_funding_date, long_funding_rate, short_funding_rate, multiplier, period |
meta |
scalar |
market_hours |
custom_periods, general_rules, holidays |
funding_rates_history |
long_funding_rate, short_funding_rate, updated_at |
GraphQL Operation
query margin_instruments($is_active: ToggleSwitch!, $pager: PagerInput, $search: String) {
margin_instruments(is_active: $is_active, pager: $pager, search: $search) {
margin_instrument_id
name
base_currency_id
quote_currency_id
min_leverage
max_leverage
min_quantity
max_quantity
long_funding_rate
short_funding_rate
price_24h_change
price_decimals
quantity_decimals
price_24h_low
price_24h_high
is_trading_on
market_status
margin_instrument_strategy_is_active
margin_instrument_strategy_id
class
lot_size
step_size
cross_quote_price
close_only
base_currency {
currency_id
precision
is_active
}
quote_currency {
currency_id
precision
is_active
}
price {
margin_instrument_id
ask
bid
updated_at
}
funding_data {
rate_type
next_funding_date
long_funding_rate
short_funding_rate
multiplier
period
}
meta
market_hours {
custom_periods {
end_time
name
start_time
}
general_rules {
days
end_time
is_active
start_time
}
holidays {
end_time
name
start_time
}
}
funding_rates_history {
long_funding_rate
short_funding_rate
updated_at
}
}
}
Code Examples
curl -X POST 'https://margin-trading-service-damanx.cryptosrvc.com/graphql' \
-H 'Authorization: Bearer YOUR_TOKEN' \
-H 'Content-Type: application/json' \
-d '{"query":"query margin_instruments($is_active: ToggleSwitch!, $pager: PagerInput, $search: String) { margin_instruments(is_active: $is_active, pager: $pager, search: $search) { margin_instrument_id name base_currency_id quote_currency_id min_leverage max_leverage min_quantity max_quantity long_funding_rate short_funding_rate price_24h_change price_decimals quantity_decimals price_24h_low price_24h_high is_trading_on market_status margin_instrument_strategy_is_active margin_instrument_strategy_id class lot_size step_size cross_quote_price close_only base_currency { currency_id precision is_active } quote_currency { currency_id precision is_active } price { margin_instrument_id ask bid updated_at } funding_data { rate_type next_funding_date long_funding_rate short_funding_rate multiplier period } meta market_hours { custom_periods { end_time name start_time } general_rules { days end_time is_active start_time } holidays { end_time name start_time } } funding_rates_history { long_funding_rate short_funding_rate updated_at } } }","variables":{}}'
import requests
url = "https://margin-trading-service-damanx.cryptosrvc.com/graphql"
headers = {
"Authorization": "Bearer YOUR_TOKEN",
"Content-Type": "application/json",
}
payload = {
"query": """query margin_instruments($is_active: ToggleSwitch!, $pager: PagerInput, $search: String) { margin_instruments(is_active: $is_active, pager: $pager, search: $search) { margin_instrument_id name base_currency_id quote_currency_id min_leverage max_leverage min_quantity max_quantity long_funding_rate short_funding_rate price_24h_change price_decimals quantity_decimals price_24h_low price_24h_high is_trading_on market_status margin_instrument_strategy_is_active margin_instrument_strategy_id class lot_size step_size cross_quote_price close_only base_currency { currency_id precision is_active } quote_currency { currency_id precision is_active } price { margin_instrument_id ask bid updated_at } funding_data { rate_type next_funding_date long_funding_rate short_funding_rate multiplier period } meta market_hours { custom_periods { end_time name start_time } general_rules { days end_time is_active start_time } holidays { end_time name start_time } } funding_rates_history { long_funding_rate short_funding_rate updated_at } } }""",
"variables": {},
}
response = requests.post(url, json=payload, headers=headers)
print(response.json())
const response = await fetch("https://margin-trading-service-damanx.cryptosrvc.com/graphql", {
method: "POST",
headers: {
"Authorization": `Bearer ${YOUR_TOKEN}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
query: `query margin_instruments($is_active: ToggleSwitch!, $pager: PagerInput, $search: String) { margin_instruments(is_active: $is_active, pager: $pager, search: $search) { margin_instrument_id name base_currency_id quote_currency_id min_leverage max_leverage min_quantity max_quantity long_funding_rate short_funding_rate price_24h_change price_decimals quantity_decimals price_24h_low price_24h_high is_trading_on market_status margin_instrument_strategy_is_active margin_instrument_strategy_id class lot_size step_size cross_quote_price close_only base_currency { currency_id precision is_active } quote_currency { currency_id precision is_active } price { margin_instrument_id ask bid updated_at } funding_data { rate_type next_funding_date long_funding_rate short_funding_rate multiplier period } meta market_hours { custom_periods { end_time name start_time } general_rules { days end_time is_active start_time } holidays { end_time name start_time } } funding_rates_history { long_funding_rate short_funding_rate updated_at } } }`,
variables: {},
}),
});
const data = await response.json();
console.log(data);Try It
query margin_trading_config Margin Trading Config
Inputs
Response
| Field | Sub-fields |
|---|---|
margin_currency |
scalar |
margin_call_level |
scalar |
liquidation_level |
scalar |
add_limit_orders_when_market_closed |
scalar |
GraphQL Operation
query margin_trading_config {
margin_trading_config {
margin_currency
margin_call_level
liquidation_level
add_limit_orders_when_market_closed
}
}
Code Examples
curl -X POST 'https://margin-trading-service-damanx.cryptosrvc.com/graphql' \
-H 'Authorization: Bearer YOUR_TOKEN' \
-H 'Content-Type: application/json' \
-d '{"query":"query margin_trading_config { margin_trading_config { margin_currency margin_call_level liquidation_level add_limit_orders_when_market_closed } }","variables":{}}'
import requests
url = "https://margin-trading-service-damanx.cryptosrvc.com/graphql"
headers = {
"Authorization": "Bearer YOUR_TOKEN",
"Content-Type": "application/json",
}
payload = {
"query": """query margin_trading_config { margin_trading_config { margin_currency margin_call_level liquidation_level add_limit_orders_when_market_closed } }""",
"variables": {},
}
response = requests.post(url, json=payload, headers=headers)
print(response.json())
const response = await fetch("https://margin-trading-service-damanx.cryptosrvc.com/graphql", {
method: "POST",
headers: {
"Authorization": `Bearer ${YOUR_TOKEN}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
query: `query margin_trading_config { margin_trading_config { margin_currency margin_call_level liquidation_level add_limit_orders_when_market_closed } }`,
variables: {},
}),
});
const data = await response.json();
console.log(data);Try It
This operation takes no inputs.
Orders
3 ops
query closed_margin_orders Closed Margin Orders
Inputs
| Name | Type | Required |
|---|---|---|
search |
String |
optional |
pager |
PagerInput |
optional |
sort |
SortInput |
optional |
user_id |
String |
optional |
dateRange |
DateRangeInput |
optional |
side |
MarginPositionSide |
optional |
status |
MarginOrderStatus |
optional |
time_in_force |
MarginOrderTimeInForce |
optional |
type |
MarginOrderType |
optional |
instrument_id |
String |
optional |
instruments_ids |
[String!] |
optional |
wallet_id |
String |
optional |
Response
| Field | Sub-fields |
|---|---|
value |
scalar |
margin_order_id |
scalar |
margin_position_id |
scalar |
user_id |
scalar |
instrument_id |
scalar |
side |
scalar |
type |
scalar |
status |
scalar |
leverage |
scalar |
quantity |
scalar |
price |
scalar |
limit_price |
scalar |
message |
scalar |
created_at_timestamp |
scalar |
stop_loss |
scalar |
take_profit |
scalar |
ask |
scalar |
bid |
scalar |
executed_quantity |
scalar |
fee_amount |
scalar |
time_in_force |
scalar |
expires_at_iso |
scalar |
updated_at_iso |
scalar |
cross_quote_price |
scalar |
wallet_id |
scalar |
margin_instrument |
base_currency_id, quote_currency_id, name, price_decimals, quantity_decimals, min_leverage, max_leverage, min_quantity, max_quantity, cross_quote_price, close_only, quote_currency, base_currency, price, margin_instrument_strategy_is_active, lot_size, step_size, class, margin_instrument_id, is_trading_on, market_status |
GraphQL Operation
query closed_margin_orders($search: String, $pager: PagerInput, $sort: SortInput, $user_id: String, $dateRange: DateRangeInput, $side: MarginPositionSide, $status: MarginOrderStatus, $time_in_force: MarginOrderTimeInForce, $type: MarginOrderType, $instrument_id: String, $instruments_ids: [String!], $wallet_id: String) {
closed_margin_orders(search: $search, pager: $pager, sort: $sort, user_id: $user_id, dateRange: $dateRange, side: $side, status: $status, time_in_force: $time_in_force, type: $type, instrument_id: $instrument_id, instruments_ids: $instruments_ids, wallet_id: $wallet_id) {
value
margin_order_id
margin_position_id
user_id
instrument_id
side
type
status
leverage
quantity
price
limit_price
message
created_at_timestamp
stop_loss
take_profit
ask
bid
executed_quantity
fee_amount
time_in_force
expires_at_iso
updated_at_iso
cross_quote_price
wallet_id
margin_instrument {
base_currency_id
quote_currency_id
name
price_decimals
quantity_decimals
min_leverage
max_leverage
min_quantity
max_quantity
cross_quote_price
close_only
quote_currency {
precision
}
base_currency {
precision
}
price {
ask
bid
}
margin_instrument_strategy_is_active
lot_size
step_size
class
margin_instrument_id
is_trading_on
market_status
}
}
}
Code Examples
curl -X POST 'https://margin-trading-service-damanx.cryptosrvc.com/graphql' \
-H 'Authorization: Bearer YOUR_TOKEN' \
-H 'Content-Type: application/json' \
-d '{"query":"query closed_margin_orders($search: String, $pager: PagerInput, $sort: SortInput, $user_id: String, $dateRange: DateRangeInput, $side: MarginPositionSide, $status: MarginOrderStatus, $time_in_force: MarginOrderTimeInForce, $type: MarginOrderType, $instrument_id: String, $instruments_ids: [String!], $wallet_id: String) { closed_margin_orders(search: $search, pager: $pager, sort: $sort, user_id: $user_id, dateRange: $dateRange, side: $side, status: $status, time_in_force: $time_in_force, type: $type, instrument_id: $instrument_id, instruments_ids: $instruments_ids, wallet_id: $wallet_id) { value margin_order_id margin_position_id user_id instrument_id side type status leverage quantity price limit_price message created_at_timestamp stop_loss take_profit ask bid executed_quantity fee_amount time_in_force expires_at_iso updated_at_iso cross_quote_price wallet_id margin_instrument { base_currency_id quote_currency_id name price_decimals quantity_decimals min_leverage max_leverage min_quantity max_quantity cross_quote_price close_only quote_currency { precision } base_currency { precision } price { ask bid } margin_instrument_strategy_is_active lot_size step_size class margin_instrument_id is_trading_on market_status } } }","variables":{}}'
import requests
url = "https://margin-trading-service-damanx.cryptosrvc.com/graphql"
headers = {
"Authorization": "Bearer YOUR_TOKEN",
"Content-Type": "application/json",
}
payload = {
"query": """query closed_margin_orders($search: String, $pager: PagerInput, $sort: SortInput, $user_id: String, $dateRange: DateRangeInput, $side: MarginPositionSide, $status: MarginOrderStatus, $time_in_force: MarginOrderTimeInForce, $type: MarginOrderType, $instrument_id: String, $instruments_ids: [String!], $wallet_id: String) { closed_margin_orders(search: $search, pager: $pager, sort: $sort, user_id: $user_id, dateRange: $dateRange, side: $side, status: $status, time_in_force: $time_in_force, type: $type, instrument_id: $instrument_id, instruments_ids: $instruments_ids, wallet_id: $wallet_id) { value margin_order_id margin_position_id user_id instrument_id side type status leverage quantity price limit_price message created_at_timestamp stop_loss take_profit ask bid executed_quantity fee_amount time_in_force expires_at_iso updated_at_iso cross_quote_price wallet_id margin_instrument { base_currency_id quote_currency_id name price_decimals quantity_decimals min_leverage max_leverage min_quantity max_quantity cross_quote_price close_only quote_currency { precision } base_currency { precision } price { ask bid } margin_instrument_strategy_is_active lot_size step_size class margin_instrument_id is_trading_on market_status } } }""",
"variables": {},
}
response = requests.post(url, json=payload, headers=headers)
print(response.json())
const response = await fetch("https://margin-trading-service-damanx.cryptosrvc.com/graphql", {
method: "POST",
headers: {
"Authorization": `Bearer ${YOUR_TOKEN}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
query: `query closed_margin_orders($search: String, $pager: PagerInput, $sort: SortInput, $user_id: String, $dateRange: DateRangeInput, $side: MarginPositionSide, $status: MarginOrderStatus, $time_in_force: MarginOrderTimeInForce, $type: MarginOrderType, $instrument_id: String, $instruments_ids: [String!], $wallet_id: String) { closed_margin_orders(search: $search, pager: $pager, sort: $sort, user_id: $user_id, dateRange: $dateRange, side: $side, status: $status, time_in_force: $time_in_force, type: $type, instrument_id: $instrument_id, instruments_ids: $instruments_ids, wallet_id: $wallet_id) { value margin_order_id margin_position_id user_id instrument_id side type status leverage quantity price limit_price message created_at_timestamp stop_loss take_profit ask bid executed_quantity fee_amount time_in_force expires_at_iso updated_at_iso cross_quote_price wallet_id margin_instrument { base_currency_id quote_currency_id name price_decimals quantity_decimals min_leverage max_leverage min_quantity max_quantity cross_quote_price close_only quote_currency { precision } base_currency { precision } price { ask bid } margin_instrument_strategy_is_active lot_size step_size class margin_instrument_id is_trading_on market_status } } }`,
variables: {},
}),
});
const data = await response.json();
console.log(data);Try It
subscription margin_order_update Margin Order Update
Inputs
| Name | Type | Required |
|---|---|---|
wallet_id |
String |
optional |
Response
| Field | Sub-fields |
|---|---|
margin_order_id |
scalar |
margin_position_id |
scalar |
user_id |
scalar |
instrument_id |
scalar |
side |
scalar |
type |
scalar |
status |
scalar |
leverage |
scalar |
quantity |
scalar |
price |
scalar |
limit_price |
scalar |
message |
scalar |
created_at_timestamp |
scalar |
stop_loss |
scalar |
take_profit |
scalar |
ask |
scalar |
bid |
scalar |
executed_quantity |
scalar |
fee_amount |
scalar |
time_in_force |
scalar |
expires_at_iso |
scalar |
updated_at_iso |
scalar |
cross_quote_price |
scalar |
wallet_id |
scalar |
margin_instrument |
base_currency_id, quote_currency_id, name, price_decimals, quantity_decimals, min_leverage, max_leverage, min_quantity, max_quantity, cross_quote_price, close_only, quote_currency, base_currency, price, margin_instrument_strategy_is_active, lot_size, step_size, class, margin_instrument_id, is_trading_on, market_status |
GraphQL Operation
subscription margin_order_update($wallet_id: String) {
margin_order_update(wallet_id: $wallet_id) {
margin_order_id
margin_position_id
user_id
instrument_id
side
type
status
leverage
quantity
price
limit_price
message
created_at_timestamp
stop_loss
take_profit
ask
bid
executed_quantity
fee_amount
time_in_force
expires_at_iso
updated_at_iso
cross_quote_price
wallet_id
margin_instrument {
base_currency_id
quote_currency_id
name
price_decimals
quantity_decimals
min_leverage
max_leverage
min_quantity
max_quantity
cross_quote_price
close_only
quote_currency {
precision
}
base_currency {
precision
}
price {
ask
bid
}
margin_instrument_strategy_is_active
lot_size
step_size
class
margin_instrument_id
is_trading_on
market_status
}
}
}
Code Examples
curl -X POST 'https://margin-trading-service-damanx.cryptosrvc.com/graphql' \
-H 'Authorization: Bearer YOUR_TOKEN' \
-H 'Content-Type: application/json' \
-d '{"query":"subscription margin_order_update($wallet_id: String) { margin_order_update(wallet_id: $wallet_id) { margin_order_id margin_position_id user_id instrument_id side type status leverage quantity price limit_price message created_at_timestamp stop_loss take_profit ask bid executed_quantity fee_amount time_in_force expires_at_iso updated_at_iso cross_quote_price wallet_id margin_instrument { base_currency_id quote_currency_id name price_decimals quantity_decimals min_leverage max_leverage min_quantity max_quantity cross_quote_price close_only quote_currency { precision } base_currency { precision } price { ask bid } margin_instrument_strategy_is_active lot_size step_size class margin_instrument_id is_trading_on market_status } } }","variables":{}}'
import requests
url = "https://margin-trading-service-damanx.cryptosrvc.com/graphql"
headers = {
"Authorization": "Bearer YOUR_TOKEN",
"Content-Type": "application/json",
}
payload = {
"query": """subscription margin_order_update($wallet_id: String) { margin_order_update(wallet_id: $wallet_id) { margin_order_id margin_position_id user_id instrument_id side type status leverage quantity price limit_price message created_at_timestamp stop_loss take_profit ask bid executed_quantity fee_amount time_in_force expires_at_iso updated_at_iso cross_quote_price wallet_id margin_instrument { base_currency_id quote_currency_id name price_decimals quantity_decimals min_leverage max_leverage min_quantity max_quantity cross_quote_price close_only quote_currency { precision } base_currency { precision } price { ask bid } margin_instrument_strategy_is_active lot_size step_size class margin_instrument_id is_trading_on market_status } } }""",
"variables": {},
}
response = requests.post(url, json=payload, headers=headers)
print(response.json())
const response = await fetch("https://margin-trading-service-damanx.cryptosrvc.com/graphql", {
method: "POST",
headers: {
"Authorization": `Bearer ${YOUR_TOKEN}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
query: `subscription margin_order_update($wallet_id: String) { margin_order_update(wallet_id: $wallet_id) { margin_order_id margin_position_id user_id instrument_id side type status leverage quantity price limit_price message created_at_timestamp stop_loss take_profit ask bid executed_quantity fee_amount time_in_force expires_at_iso updated_at_iso cross_quote_price wallet_id margin_instrument { base_currency_id quote_currency_id name price_decimals quantity_decimals min_leverage max_leverage min_quantity max_quantity cross_quote_price close_only quote_currency { precision } base_currency { precision } price { ask bid } margin_instrument_strategy_is_active lot_size step_size class margin_instrument_id is_trading_on market_status } } }`,
variables: {},
}),
});
const data = await response.json();
console.log(data);Try It
Subscriptions are delivered over WebSocket (wss://). Use a GraphQL-WS client rather than this HTTP runner.
query open_margin_orders Open Margin Orders
Inputs
| Name | Type | Required |
|---|---|---|
search |
String |
optional |
pager |
PagerInput |
optional |
sort |
SortInput |
optional |
user_id |
String |
optional |
dateRange |
DateRangeInput |
optional |
side |
MarginPositionSide |
optional |
status |
MarginOrderStatus |
optional |
time_in_force |
MarginOrderTimeInForce |
optional |
type |
MarginOrderType |
optional |
instrument_id |
String |
optional |
instruments_ids |
[String!] |
optional |
wallet_id |
String |
optional |
Response
| Field | Sub-fields |
|---|---|
margin_order_id |
scalar |
margin_position_id |
scalar |
user_id |
scalar |
instrument_id |
scalar |
side |
scalar |
type |
scalar |
status |
scalar |
leverage |
scalar |
quantity |
scalar |
price |
scalar |
limit_price |
scalar |
message |
scalar |
created_at_timestamp |
scalar |
stop_loss |
scalar |
take_profit |
scalar |
ask |
scalar |
bid |
scalar |
executed_quantity |
scalar |
fee_amount |
scalar |
time_in_force |
scalar |
expires_at_iso |
scalar |
updated_at_iso |
scalar |
cross_quote_price |
scalar |
wallet_id |
scalar |
margin_instrument |
base_currency_id, quote_currency_id, name, price_decimals, quantity_decimals, min_leverage, max_leverage, min_quantity, max_quantity, cross_quote_price, close_only, quote_currency, base_currency, price, margin_instrument_strategy_is_active, lot_size, step_size, class, margin_instrument_id, is_trading_on, market_status |
GraphQL Operation
query open_margin_orders($search: String, $pager: PagerInput, $sort: SortInput, $user_id: String, $dateRange: DateRangeInput, $side: MarginPositionSide, $status: MarginOrderStatus, $time_in_force: MarginOrderTimeInForce, $type: MarginOrderType, $instrument_id: String, $instruments_ids: [String!], $wallet_id: String) {
open_margin_orders(search: $search, pager: $pager, sort: $sort, user_id: $user_id, dateRange: $dateRange, side: $side, status: $status, time_in_force: $time_in_force, type: $type, instrument_id: $instrument_id, instruments_ids: $instruments_ids, wallet_id: $wallet_id) {
margin_order_id
margin_position_id
user_id
instrument_id
side
type
status
leverage
quantity
price
limit_price
message
created_at_timestamp
stop_loss
take_profit
ask
bid
executed_quantity
fee_amount
time_in_force
expires_at_iso
updated_at_iso
cross_quote_price
wallet_id
margin_instrument {
base_currency_id
quote_currency_id
name
price_decimals
quantity_decimals
min_leverage
max_leverage
min_quantity
max_quantity
cross_quote_price
close_only
quote_currency {
precision
}
base_currency {
precision
}
price {
ask
bid
}
margin_instrument_strategy_is_active
lot_size
step_size
class
margin_instrument_id
is_trading_on
market_status
}
}
}
Code Examples
curl -X POST 'https://margin-trading-service-damanx.cryptosrvc.com/graphql' \
-H 'Authorization: Bearer YOUR_TOKEN' \
-H 'Content-Type: application/json' \
-d '{"query":"query open_margin_orders($search: String, $pager: PagerInput, $sort: SortInput, $user_id: String, $dateRange: DateRangeInput, $side: MarginPositionSide, $status: MarginOrderStatus, $time_in_force: MarginOrderTimeInForce, $type: MarginOrderType, $instrument_id: String, $instruments_ids: [String!], $wallet_id: String) { open_margin_orders(search: $search, pager: $pager, sort: $sort, user_id: $user_id, dateRange: $dateRange, side: $side, status: $status, time_in_force: $time_in_force, type: $type, instrument_id: $instrument_id, instruments_ids: $instruments_ids, wallet_id: $wallet_id) { margin_order_id margin_position_id user_id instrument_id side type status leverage quantity price limit_price message created_at_timestamp stop_loss take_profit ask bid executed_quantity fee_amount time_in_force expires_at_iso updated_at_iso cross_quote_price wallet_id margin_instrument { base_currency_id quote_currency_id name price_decimals quantity_decimals min_leverage max_leverage min_quantity max_quantity cross_quote_price close_only quote_currency { precision } base_currency { precision } price { ask bid } margin_instrument_strategy_is_active lot_size step_size class margin_instrument_id is_trading_on market_status } } }","variables":{}}'
import requests
url = "https://margin-trading-service-damanx.cryptosrvc.com/graphql"
headers = {
"Authorization": "Bearer YOUR_TOKEN",
"Content-Type": "application/json",
}
payload = {
"query": """query open_margin_orders($search: String, $pager: PagerInput, $sort: SortInput, $user_id: String, $dateRange: DateRangeInput, $side: MarginPositionSide, $status: MarginOrderStatus, $time_in_force: MarginOrderTimeInForce, $type: MarginOrderType, $instrument_id: String, $instruments_ids: [String!], $wallet_id: String) { open_margin_orders(search: $search, pager: $pager, sort: $sort, user_id: $user_id, dateRange: $dateRange, side: $side, status: $status, time_in_force: $time_in_force, type: $type, instrument_id: $instrument_id, instruments_ids: $instruments_ids, wallet_id: $wallet_id) { margin_order_id margin_position_id user_id instrument_id side type status leverage quantity price limit_price message created_at_timestamp stop_loss take_profit ask bid executed_quantity fee_amount time_in_force expires_at_iso updated_at_iso cross_quote_price wallet_id margin_instrument { base_currency_id quote_currency_id name price_decimals quantity_decimals min_leverage max_leverage min_quantity max_quantity cross_quote_price close_only quote_currency { precision } base_currency { precision } price { ask bid } margin_instrument_strategy_is_active lot_size step_size class margin_instrument_id is_trading_on market_status } } }""",
"variables": {},
}
response = requests.post(url, json=payload, headers=headers)
print(response.json())
const response = await fetch("https://margin-trading-service-damanx.cryptosrvc.com/graphql", {
method: "POST",
headers: {
"Authorization": `Bearer ${YOUR_TOKEN}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
query: `query open_margin_orders($search: String, $pager: PagerInput, $sort: SortInput, $user_id: String, $dateRange: DateRangeInput, $side: MarginPositionSide, $status: MarginOrderStatus, $time_in_force: MarginOrderTimeInForce, $type: MarginOrderType, $instrument_id: String, $instruments_ids: [String!], $wallet_id: String) { open_margin_orders(search: $search, pager: $pager, sort: $sort, user_id: $user_id, dateRange: $dateRange, side: $side, status: $status, time_in_force: $time_in_force, type: $type, instrument_id: $instrument_id, instruments_ids: $instruments_ids, wallet_id: $wallet_id) { margin_order_id margin_position_id user_id instrument_id side type status leverage quantity price limit_price message created_at_timestamp stop_loss take_profit ask bid executed_quantity fee_amount time_in_force expires_at_iso updated_at_iso cross_quote_price wallet_id margin_instrument { base_currency_id quote_currency_id name price_decimals quantity_decimals min_leverage max_leverage min_quantity max_quantity cross_quote_price close_only quote_currency { precision } base_currency { precision } price { ask bid } margin_instrument_strategy_is_active lot_size step_size class margin_instrument_id is_trading_on market_status } } }`,
variables: {},
}),
});
const data = await response.json();
console.log(data);Try It
Performance
4 ops
query user_closed_orders_stats User Closed Orders Stats
Inputs
| Name | Type | Required |
|---|---|---|
user_id |
String |
optional |
instrument_ids |
[String!] |
optional |
date_range |
DateRangeInput |
optional |
wallet_id |
String |
optional |
Response
| Field | Sub-fields |
|---|---|
long_count |
scalar |
short_count |
scalar |
avg_long_order_size |
scalar |
avg_short_order_size |
scalar |
short_volume |
scalar |
long_volume |
scalar |
avg_order_size |
scalar |
trading_fees |
scalar |
GraphQL Operation
query user_closed_orders_stats($user_id: String, $instrument_ids: [String!], $date_range: DateRangeInput, $wallet_id: String) {
user_closed_orders_stats(user_id: $user_id, instrument_ids: $instrument_ids, date_range: $date_range, wallet_id: $wallet_id) {
long_count
short_count
avg_long_order_size
avg_short_order_size
short_volume
long_volume
avg_order_size
trading_fees
}
}
Code Examples
curl -X POST 'https://margin-trading-service-damanx.cryptosrvc.com/graphql' \
-H 'Authorization: Bearer YOUR_TOKEN' \
-H 'Content-Type: application/json' \
-d '{"query":"query user_closed_orders_stats($user_id: String, $instrument_ids: [String!], $date_range: DateRangeInput, $wallet_id: String) { user_closed_orders_stats(user_id: $user_id, instrument_ids: $instrument_ids, date_range: $date_range, wallet_id: $wallet_id) { long_count short_count avg_long_order_size avg_short_order_size short_volume long_volume avg_order_size trading_fees } }","variables":{}}'
import requests
url = "https://margin-trading-service-damanx.cryptosrvc.com/graphql"
headers = {
"Authorization": "Bearer YOUR_TOKEN",
"Content-Type": "application/json",
}
payload = {
"query": """query user_closed_orders_stats($user_id: String, $instrument_ids: [String!], $date_range: DateRangeInput, $wallet_id: String) { user_closed_orders_stats(user_id: $user_id, instrument_ids: $instrument_ids, date_range: $date_range, wallet_id: $wallet_id) { long_count short_count avg_long_order_size avg_short_order_size short_volume long_volume avg_order_size trading_fees } }""",
"variables": {},
}
response = requests.post(url, json=payload, headers=headers)
print(response.json())
const response = await fetch("https://margin-trading-service-damanx.cryptosrvc.com/graphql", {
method: "POST",
headers: {
"Authorization": `Bearer ${YOUR_TOKEN}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
query: `query user_closed_orders_stats($user_id: String, $instrument_ids: [String!], $date_range: DateRangeInput, $wallet_id: String) { user_closed_orders_stats(user_id: $user_id, instrument_ids: $instrument_ids, date_range: $date_range, wallet_id: $wallet_id) { long_count short_count avg_long_order_size avg_short_order_size short_volume long_volume avg_order_size trading_fees } }`,
variables: {},
}),
});
const data = await response.json();
console.log(data);Try It
query user_closed_positions_stats User Closed Positions Stats
Inputs
| Name | Type | Required |
|---|---|---|
user_id |
String |
optional |
instrument_ids |
[String!] |
optional |
date_range |
DateRangeInput |
optional |
wallet_id |
String |
optional |
Response
| Field | Sub-fields |
|---|---|
long_positions |
wins_count, loss_count, win_rate, avg_position_duration, total_pnl, pnl_ranking, spread_pnl, funding_fees |
short_positions |
wins_count, loss_count, win_rate, avg_position_duration, total_pnl, pnl_ranking, spread_pnl, funding_fees |
all_positions |
wins_count, loss_count, win_rate, avg_position_duration, total_pnl, pnl_ranking, spread_pnl, funding_fees |
GraphQL Operation
query user_closed_positions_stats($user_id: String, $instrument_ids: [String!], $date_range: DateRangeInput, $wallet_id: String) {
user_closed_positions_stats(user_id: $user_id, instrument_ids: $instrument_ids, date_range: $date_range, wallet_id: $wallet_id) {
long_positions {
wins_count
loss_count
win_rate
avg_position_duration
total_pnl
pnl_ranking
spread_pnl
funding_fees
}
short_positions {
wins_count
loss_count
win_rate
avg_position_duration
total_pnl
pnl_ranking
spread_pnl
funding_fees
}
all_positions {
wins_count
loss_count
win_rate
avg_position_duration
total_pnl
pnl_ranking
spread_pnl
funding_fees
}
}
}
Code Examples
curl -X POST 'https://margin-trading-service-damanx.cryptosrvc.com/graphql' \
-H 'Authorization: Bearer YOUR_TOKEN' \
-H 'Content-Type: application/json' \
-d '{"query":"query user_closed_positions_stats($user_id: String, $instrument_ids: [String!], $date_range: DateRangeInput, $wallet_id: String) { user_closed_positions_stats(user_id: $user_id, instrument_ids: $instrument_ids, date_range: $date_range, wallet_id: $wallet_id) { long_positions { wins_count loss_count win_rate avg_position_duration total_pnl pnl_ranking spread_pnl funding_fees } short_positions { wins_count loss_count win_rate avg_position_duration total_pnl pnl_ranking spread_pnl funding_fees } all_positions { wins_count loss_count win_rate avg_position_duration total_pnl pnl_ranking spread_pnl funding_fees } } }","variables":{}}'
import requests
url = "https://margin-trading-service-damanx.cryptosrvc.com/graphql"
headers = {
"Authorization": "Bearer YOUR_TOKEN",
"Content-Type": "application/json",
}
payload = {
"query": """query user_closed_positions_stats($user_id: String, $instrument_ids: [String!], $date_range: DateRangeInput, $wallet_id: String) { user_closed_positions_stats(user_id: $user_id, instrument_ids: $instrument_ids, date_range: $date_range, wallet_id: $wallet_id) { long_positions { wins_count loss_count win_rate avg_position_duration total_pnl pnl_ranking spread_pnl funding_fees } short_positions { wins_count loss_count win_rate avg_position_duration total_pnl pnl_ranking spread_pnl funding_fees } all_positions { wins_count loss_count win_rate avg_position_duration total_pnl pnl_ranking spread_pnl funding_fees } } }""",
"variables": {},
}
response = requests.post(url, json=payload, headers=headers)
print(response.json())
const response = await fetch("https://margin-trading-service-damanx.cryptosrvc.com/graphql", {
method: "POST",
headers: {
"Authorization": `Bearer ${YOUR_TOKEN}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
query: `query user_closed_positions_stats($user_id: String, $instrument_ids: [String!], $date_range: DateRangeInput, $wallet_id: String) { user_closed_positions_stats(user_id: $user_id, instrument_ids: $instrument_ids, date_range: $date_range, wallet_id: $wallet_id) { long_positions { wins_count loss_count win_rate avg_position_duration total_pnl pnl_ranking spread_pnl funding_fees } short_positions { wins_count loss_count win_rate avg_position_duration total_pnl pnl_ranking spread_pnl funding_fees } all_positions { wins_count loss_count win_rate avg_position_duration total_pnl pnl_ranking spread_pnl funding_fees } } }`,
variables: {},
}),
});
const data = await response.json();
console.log(data);Try It
query user_pnl_ranking User Pnl Ranking
Inputs
| Name | Type | Required |
|---|---|---|
user_id |
String |
optional |
instrument_ids |
[String!] |
optional |
date_range |
DateRangeInput |
optional |
sort |
SortDirection |
optional |
wallet_id |
String |
optional |
Response
| Field | Sub-fields |
|---|---|
instrument_id |
scalar |
pnl |
scalar |
GraphQL Operation
query user_pnl_ranking($user_id: String, $instrument_ids: [String!], $date_range: DateRangeInput, $sort: SortDirection, $wallet_id: String) {
user_pnl_ranking(user_id: $user_id, instrument_ids: $instrument_ids, date_range: $date_range, sort: $sort, wallet_id: $wallet_id) {
instrument_id
pnl
}
}
Code Examples
curl -X POST 'https://margin-trading-service-damanx.cryptosrvc.com/graphql' \
-H 'Authorization: Bearer YOUR_TOKEN' \
-H 'Content-Type: application/json' \
-d '{"query":"query user_pnl_ranking($user_id: String, $instrument_ids: [String!], $date_range: DateRangeInput, $sort: SortDirection, $wallet_id: String) { user_pnl_ranking(user_id: $user_id, instrument_ids: $instrument_ids, date_range: $date_range, sort: $sort, wallet_id: $wallet_id) { instrument_id pnl } }","variables":{}}'
import requests
url = "https://margin-trading-service-damanx.cryptosrvc.com/graphql"
headers = {
"Authorization": "Bearer YOUR_TOKEN",
"Content-Type": "application/json",
}
payload = {
"query": """query user_pnl_ranking($user_id: String, $instrument_ids: [String!], $date_range: DateRangeInput, $sort: SortDirection, $wallet_id: String) { user_pnl_ranking(user_id: $user_id, instrument_ids: $instrument_ids, date_range: $date_range, sort: $sort, wallet_id: $wallet_id) { instrument_id pnl } }""",
"variables": {},
}
response = requests.post(url, json=payload, headers=headers)
print(response.json())
const response = await fetch("https://margin-trading-service-damanx.cryptosrvc.com/graphql", {
method: "POST",
headers: {
"Authorization": `Bearer ${YOUR_TOKEN}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
query: `query user_pnl_ranking($user_id: String, $instrument_ids: [String!], $date_range: DateRangeInput, $sort: SortDirection, $wallet_id: String) { user_pnl_ranking(user_id: $user_id, instrument_ids: $instrument_ids, date_range: $date_range, sort: $sort, wallet_id: $wallet_id) { instrument_id pnl } }`,
variables: {},
}),
});
const data = await response.json();
console.log(data);Try It
query user_trading_performace User Trading Performace
Inputs
| Name | Type | Required |
|---|---|---|
user_id |
String |
optional |
instrument_ids |
[String!] |
optional |
date_range |
DateRangeInput |
optional |
limit |
Int |
optional |
periodicity |
UserTradingPerformancePeriodicity |
optional |
wallet_id |
String |
optional |
Response
| Field | Sub-fields |
|---|---|
date |
scalar |
pnl |
scalar |
GraphQL Operation
query user_trading_performace($user_id: String, $instrument_ids: [String!], $date_range: DateRangeInput, $limit: Int, $periodicity: UserTradingPerformancePeriodicity, $wallet_id: String) {
user_trading_performace(user_id: $user_id, instrument_ids: $instrument_ids, date_range: $date_range, limit: $limit, periodicity: $periodicity, wallet_id: $wallet_id) {
date
pnl
}
}
Code Examples
curl -X POST 'https://margin-trading-service-damanx.cryptosrvc.com/graphql' \
-H 'Authorization: Bearer YOUR_TOKEN' \
-H 'Content-Type: application/json' \
-d '{"query":"query user_trading_performace($user_id: String, $instrument_ids: [String!], $date_range: DateRangeInput, $limit: Int, $periodicity: UserTradingPerformancePeriodicity, $wallet_id: String) { user_trading_performace(user_id: $user_id, instrument_ids: $instrument_ids, date_range: $date_range, limit: $limit, periodicity: $periodicity, wallet_id: $wallet_id) { date pnl } }","variables":{}}'
import requests
url = "https://margin-trading-service-damanx.cryptosrvc.com/graphql"
headers = {
"Authorization": "Bearer YOUR_TOKEN",
"Content-Type": "application/json",
}
payload = {
"query": """query user_trading_performace($user_id: String, $instrument_ids: [String!], $date_range: DateRangeInput, $limit: Int, $periodicity: UserTradingPerformancePeriodicity, $wallet_id: String) { user_trading_performace(user_id: $user_id, instrument_ids: $instrument_ids, date_range: $date_range, limit: $limit, periodicity: $periodicity, wallet_id: $wallet_id) { date pnl } }""",
"variables": {},
}
response = requests.post(url, json=payload, headers=headers)
print(response.json())
const response = await fetch("https://margin-trading-service-damanx.cryptosrvc.com/graphql", {
method: "POST",
headers: {
"Authorization": `Bearer ${YOUR_TOKEN}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
query: `query user_trading_performace($user_id: String, $instrument_ids: [String!], $date_range: DateRangeInput, $limit: Int, $periodicity: UserTradingPerformancePeriodicity, $wallet_id: String) { user_trading_performace(user_id: $user_id, instrument_ids: $instrument_ids, date_range: $date_range, limit: $limit, periodicity: $periodicity, wallet_id: $wallet_id) { date pnl } }`,
variables: {},
}),
});
const data = await response.json();
console.log(data);Try It
Positions
5 ops
query closed_margin_positions Closed Margin Positions
Inputs
| Name | Type | Required |
|---|---|---|
search |
String |
optional |
pager |
PagerInput |
optional |
sort |
SortInput |
optional |
user_id |
String |
optional |
dateRange |
DateRangeInput |
optional |
side |
MarginPositionSide |
optional |
instrument_id |
String |
optional |
instruments_ids |
[String!] |
optional |
wallet_id |
String |
optional |
Response
| Field | Sub-fields |
|---|---|
margin_position_id |
scalar |
instrument_id |
scalar |
user_id |
scalar |
side |
scalar |
leverage |
scalar |
amount |
scalar |
value |
scalar |
funding_fee_amount |
scalar |
entry_price |
scalar |
start_price_ts |
scalar |
end_price_ts |
scalar |
start_ask_price |
scalar |
duration |
scalar |
end_ask_price |
scalar |
pnl |
scalar |
stop_loss |
scalar |
take_profit |
scalar |
start_ts_timestamp |
scalar |
close_reason |
scalar |
updated_at_iso |
scalar |
start_bid_price |
scalar |
end_bid_price |
scalar |
close_reason_code |
scalar |
margin |
scalar |
total_pnl |
scalar |
cross_quote_price |
scalar |
exit_price |
scalar |
wallet_id |
scalar |
margin_currency_id |
scalar |
end_ts_iso |
scalar |
margin_instrument |
base_currency_id, quote_currency_id, name, price_decimals, quantity_decimals, min_quantity, min_leverage, max_leverage, is_trading_on, class, margin_instrument_id, market_status, cross_quote_price, close_only, quote_currency, base_currency, price, margin_instrument_strategy_is_active, lot_size, step_size |
GraphQL Operation
query closed_margin_positions($search: String, $pager: PagerInput, $sort: SortInput, $user_id: String, $dateRange: DateRangeInput, $side: MarginPositionSide, $instrument_id: String, $instruments_ids: [String!], $wallet_id: String) {
closed_margin_positions(search: $search, pager: $pager, sort: $sort, user_id: $user_id, dateRange: $dateRange, side: $side, instrument_id: $instrument_id, instruments_ids: $instruments_ids, wallet_id: $wallet_id) {
margin_position_id
instrument_id
user_id
side
leverage
amount
value
funding_fee_amount
entry_price
start_price_ts
end_price_ts
start_ask_price
duration
end_ask_price
pnl
stop_loss
take_profit
start_ts_timestamp
close_reason
updated_at_iso
start_bid_price
end_bid_price
close_reason_code
margin
total_pnl
cross_quote_price
exit_price
wallet_id
margin_currency_id
end_ts_iso
margin_instrument {
base_currency_id
quote_currency_id
name
price_decimals
quantity_decimals
min_quantity
min_leverage
max_leverage
is_trading_on
class
margin_instrument_id
market_status
cross_quote_price
close_only
quote_currency {
precision
}
base_currency {
precision
}
price {
ask
bid
}
margin_instrument_strategy_is_active
lot_size
step_size
}
}
}
Code Examples
curl -X POST 'https://margin-trading-service-damanx.cryptosrvc.com/graphql' \
-H 'Authorization: Bearer YOUR_TOKEN' \
-H 'Content-Type: application/json' \
-d '{"query":"query closed_margin_positions($search: String, $pager: PagerInput, $sort: SortInput, $user_id: String, $dateRange: DateRangeInput, $side: MarginPositionSide, $instrument_id: String, $instruments_ids: [String!], $wallet_id: String) { closed_margin_positions(search: $search, pager: $pager, sort: $sort, user_id: $user_id, dateRange: $dateRange, side: $side, instrument_id: $instrument_id, instruments_ids: $instruments_ids, wallet_id: $wallet_id) { margin_position_id instrument_id user_id side leverage amount value funding_fee_amount entry_price start_price_ts end_price_ts start_ask_price duration end_ask_price pnl stop_loss take_profit start_ts_timestamp close_reason updated_at_iso start_bid_price end_bid_price close_reason_code margin total_pnl cross_quote_price exit_price wallet_id margin_currency_id end_ts_iso margin_instrument { base_currency_id quote_currency_id name price_decimals quantity_decimals min_quantity min_leverage max_leverage is_trading_on class margin_instrument_id market_status cross_quote_price close_only quote_currency { precision } base_currency { precision } price { ask bid } margin_instrument_strategy_is_active lot_size step_size } } }","variables":{}}'
import requests
url = "https://margin-trading-service-damanx.cryptosrvc.com/graphql"
headers = {
"Authorization": "Bearer YOUR_TOKEN",
"Content-Type": "application/json",
}
payload = {
"query": """query closed_margin_positions($search: String, $pager: PagerInput, $sort: SortInput, $user_id: String, $dateRange: DateRangeInput, $side: MarginPositionSide, $instrument_id: String, $instruments_ids: [String!], $wallet_id: String) { closed_margin_positions(search: $search, pager: $pager, sort: $sort, user_id: $user_id, dateRange: $dateRange, side: $side, instrument_id: $instrument_id, instruments_ids: $instruments_ids, wallet_id: $wallet_id) { margin_position_id instrument_id user_id side leverage amount value funding_fee_amount entry_price start_price_ts end_price_ts start_ask_price duration end_ask_price pnl stop_loss take_profit start_ts_timestamp close_reason updated_at_iso start_bid_price end_bid_price close_reason_code margin total_pnl cross_quote_price exit_price wallet_id margin_currency_id end_ts_iso margin_instrument { base_currency_id quote_currency_id name price_decimals quantity_decimals min_quantity min_leverage max_leverage is_trading_on class margin_instrument_id market_status cross_quote_price close_only quote_currency { precision } base_currency { precision } price { ask bid } margin_instrument_strategy_is_active lot_size step_size } } }""",
"variables": {},
}
response = requests.post(url, json=payload, headers=headers)
print(response.json())
const response = await fetch("https://margin-trading-service-damanx.cryptosrvc.com/graphql", {
method: "POST",
headers: {
"Authorization": `Bearer ${YOUR_TOKEN}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
query: `query closed_margin_positions($search: String, $pager: PagerInput, $sort: SortInput, $user_id: String, $dateRange: DateRangeInput, $side: MarginPositionSide, $instrument_id: String, $instruments_ids: [String!], $wallet_id: String) { closed_margin_positions(search: $search, pager: $pager, sort: $sort, user_id: $user_id, dateRange: $dateRange, side: $side, instrument_id: $instrument_id, instruments_ids: $instruments_ids, wallet_id: $wallet_id) { margin_position_id instrument_id user_id side leverage amount value funding_fee_amount entry_price start_price_ts end_price_ts start_ask_price duration end_ask_price pnl stop_loss take_profit start_ts_timestamp close_reason updated_at_iso start_bid_price end_bid_price close_reason_code margin total_pnl cross_quote_price exit_price wallet_id margin_currency_id end_ts_iso margin_instrument { base_currency_id quote_currency_id name price_decimals quantity_decimals min_quantity min_leverage max_leverage is_trading_on class margin_instrument_id market_status cross_quote_price close_only quote_currency { precision } base_currency { precision } price { ask bid } margin_instrument_strategy_is_active lot_size step_size } } }`,
variables: {},
}),
});
const data = await response.json();
console.log(data);Try It
subscription margin_orderbook Margin Orderbook
Inputs
| Name | Type | Required |
|---|---|---|
instrument_id |
String |
required |
Response
| Field | Sub-fields |
|---|---|
instrument_id |
scalar |
buy |
quantity, price |
sell |
quantity, price |
GraphQL Operation
subscription margin_orderbook($instrument_id: String!) {
margin_orderbook(instrument_id: $instrument_id) {
instrument_id
buy {
quantity
price
}
sell {
quantity
price
}
}
}
Code Examples
curl -X POST 'https://margin-trading-service-damanx.cryptosrvc.com/graphql' \
-H 'Authorization: Bearer YOUR_TOKEN' \
-H 'Content-Type: application/json' \
-d '{"query":"subscription margin_orderbook($instrument_id: String!) { margin_orderbook(instrument_id: $instrument_id) { instrument_id buy { quantity price } sell { quantity price } } }","variables":{}}'
import requests
url = "https://margin-trading-service-damanx.cryptosrvc.com/graphql"
headers = {
"Authorization": "Bearer YOUR_TOKEN",
"Content-Type": "application/json",
}
payload = {
"query": """subscription margin_orderbook($instrument_id: String!) { margin_orderbook(instrument_id: $instrument_id) { instrument_id buy { quantity price } sell { quantity price } } }""",
"variables": {},
}
response = requests.post(url, json=payload, headers=headers)
print(response.json())
const response = await fetch("https://margin-trading-service-damanx.cryptosrvc.com/graphql", {
method: "POST",
headers: {
"Authorization": `Bearer ${YOUR_TOKEN}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
query: `subscription margin_orderbook($instrument_id: String!) { margin_orderbook(instrument_id: $instrument_id) { instrument_id buy { quantity price } sell { quantity price } } }`,
variables: {},
}),
});
const data = await response.json();
console.log(data);Try It
Subscriptions are delivered over WebSocket (wss://). Use a GraphQL-WS client rather than this HTTP runner.
subscription open_margin_position_update Open Margin Position Update
Inputs
| Name | Type | Required |
|---|---|---|
wallet_id |
String |
optional |
Response
| Field | Sub-fields |
|---|---|
margin_position_id |
scalar |
instrument_id |
scalar |
user_id |
scalar |
side |
scalar |
leverage |
scalar |
amount |
scalar |
value |
scalar |
funding_fee_amount |
scalar |
entry_price |
scalar |
start_price_ts |
scalar |
end_price_ts |
scalar |
start_ask_price |
scalar |
duration |
scalar |
end_ask_price |
scalar |
pnl |
scalar |
stop_loss |
scalar |
take_profit |
scalar |
start_ts_timestamp |
scalar |
close_reason |
scalar |
updated_at_iso |
scalar |
start_bid_price |
scalar |
end_bid_price |
scalar |
close_reason_code |
scalar |
margin |
scalar |
total_pnl |
scalar |
cross_quote_price |
scalar |
exit_price |
scalar |
wallet_id |
scalar |
margin_currency_id |
scalar |
end_ts_iso |
scalar |
margin_instrument |
base_currency_id, quote_currency_id, name, price_decimals, quantity_decimals, min_quantity, min_leverage, max_leverage, is_trading_on, class, margin_instrument_id, market_status, cross_quote_price, close_only, quote_currency, base_currency, price, margin_instrument_strategy_is_active, lot_size, step_size |
GraphQL Operation
subscription open_margin_position_update($wallet_id: String) {
open_margin_position_update(wallet_id: $wallet_id) {
margin_position_id
instrument_id
user_id
side
leverage
amount
value
funding_fee_amount
entry_price
start_price_ts
end_price_ts
start_ask_price
duration
end_ask_price
pnl
stop_loss
take_profit
start_ts_timestamp
close_reason
updated_at_iso
start_bid_price
end_bid_price
close_reason_code
margin
total_pnl
cross_quote_price
exit_price
wallet_id
margin_currency_id
end_ts_iso
margin_instrument {
base_currency_id
quote_currency_id
name
price_decimals
quantity_decimals
min_quantity
min_leverage
max_leverage
is_trading_on
class
margin_instrument_id
market_status
cross_quote_price
close_only
quote_currency {
precision
}
base_currency {
precision
}
price {
ask
bid
}
margin_instrument_strategy_is_active
lot_size
step_size
}
}
}
Code Examples
curl -X POST 'https://margin-trading-service-damanx.cryptosrvc.com/graphql' \
-H 'Authorization: Bearer YOUR_TOKEN' \
-H 'Content-Type: application/json' \
-d '{"query":"subscription open_margin_position_update($wallet_id: String) { open_margin_position_update(wallet_id: $wallet_id) { margin_position_id instrument_id user_id side leverage amount value funding_fee_amount entry_price start_price_ts end_price_ts start_ask_price duration end_ask_price pnl stop_loss take_profit start_ts_timestamp close_reason updated_at_iso start_bid_price end_bid_price close_reason_code margin total_pnl cross_quote_price exit_price wallet_id margin_currency_id end_ts_iso margin_instrument { base_currency_id quote_currency_id name price_decimals quantity_decimals min_quantity min_leverage max_leverage is_trading_on class margin_instrument_id market_status cross_quote_price close_only quote_currency { precision } base_currency { precision } price { ask bid } margin_instrument_strategy_is_active lot_size step_size } } }","variables":{}}'
import requests
url = "https://margin-trading-service-damanx.cryptosrvc.com/graphql"
headers = {
"Authorization": "Bearer YOUR_TOKEN",
"Content-Type": "application/json",
}
payload = {
"query": """subscription open_margin_position_update($wallet_id: String) { open_margin_position_update(wallet_id: $wallet_id) { margin_position_id instrument_id user_id side leverage amount value funding_fee_amount entry_price start_price_ts end_price_ts start_ask_price duration end_ask_price pnl stop_loss take_profit start_ts_timestamp close_reason updated_at_iso start_bid_price end_bid_price close_reason_code margin total_pnl cross_quote_price exit_price wallet_id margin_currency_id end_ts_iso margin_instrument { base_currency_id quote_currency_id name price_decimals quantity_decimals min_quantity min_leverage max_leverage is_trading_on class margin_instrument_id market_status cross_quote_price close_only quote_currency { precision } base_currency { precision } price { ask bid } margin_instrument_strategy_is_active lot_size step_size } } }""",
"variables": {},
}
response = requests.post(url, json=payload, headers=headers)
print(response.json())
const response = await fetch("https://margin-trading-service-damanx.cryptosrvc.com/graphql", {
method: "POST",
headers: {
"Authorization": `Bearer ${YOUR_TOKEN}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
query: `subscription open_margin_position_update($wallet_id: String) { open_margin_position_update(wallet_id: $wallet_id) { margin_position_id instrument_id user_id side leverage amount value funding_fee_amount entry_price start_price_ts end_price_ts start_ask_price duration end_ask_price pnl stop_loss take_profit start_ts_timestamp close_reason updated_at_iso start_bid_price end_bid_price close_reason_code margin total_pnl cross_quote_price exit_price wallet_id margin_currency_id end_ts_iso margin_instrument { base_currency_id quote_currency_id name price_decimals quantity_decimals min_quantity min_leverage max_leverage is_trading_on class margin_instrument_id market_status cross_quote_price close_only quote_currency { precision } base_currency { precision } price { ask bid } margin_instrument_strategy_is_active lot_size step_size } } }`,
variables: {},
}),
});
const data = await response.json();
console.log(data);Try It
Subscriptions are delivered over WebSocket (wss://). Use a GraphQL-WS client rather than this HTTP runner.
query open_margin_positions Open Margin Positions
Inputs
| Name | Type | Required |
|---|---|---|
search |
String |
optional |
pager |
PagerInput |
optional |
sort |
SortInput |
optional |
user_id |
String |
optional |
dateRange |
DateRangeInput |
optional |
side |
MarginPositionSide |
optional |
instrument_id |
String |
optional |
instruments_ids |
[String!] |
optional |
wallet_id |
String |
optional |
Response
| Field | Sub-fields |
|---|---|
margin_position_id |
scalar |
instrument_id |
scalar |
user_id |
scalar |
side |
scalar |
leverage |
scalar |
amount |
scalar |
value |
scalar |
funding_fee_amount |
scalar |
entry_price |
scalar |
start_price_ts |
scalar |
end_price_ts |
scalar |
start_ask_price |
scalar |
duration |
scalar |
end_ask_price |
scalar |
pnl |
scalar |
stop_loss |
scalar |
take_profit |
scalar |
start_ts_timestamp |
scalar |
close_reason |
scalar |
updated_at_iso |
scalar |
start_bid_price |
scalar |
end_bid_price |
scalar |
close_reason_code |
scalar |
margin |
scalar |
total_pnl |
scalar |
cross_quote_price |
scalar |
exit_price |
scalar |
wallet_id |
scalar |
margin_currency_id |
scalar |
margin_instrument |
base_currency_id, quote_currency_id, name, price_decimals, quantity_decimals, min_quantity, min_leverage, max_leverage, is_trading_on, class, margin_instrument_id, market_status, cross_quote_price, close_only, quote_currency, base_currency, price, margin_instrument_strategy_is_active, lot_size, step_size |
GraphQL Operation
query open_margin_positions($search: String, $pager: PagerInput, $sort: SortInput, $user_id: String, $dateRange: DateRangeInput, $side: MarginPositionSide, $instrument_id: String, $instruments_ids: [String!], $wallet_id: String) {
open_margin_positions(search: $search, pager: $pager, sort: $sort, user_id: $user_id, dateRange: $dateRange, side: $side, instrument_id: $instrument_id, instruments_ids: $instruments_ids, wallet_id: $wallet_id) {
margin_position_id
instrument_id
user_id
side
leverage
amount
value
funding_fee_amount
entry_price
start_price_ts
end_price_ts
start_ask_price
duration
end_ask_price
pnl
stop_loss
take_profit
start_ts_timestamp
close_reason
updated_at_iso
start_bid_price
end_bid_price
close_reason_code
margin
total_pnl
cross_quote_price
exit_price
wallet_id
margin_currency_id
margin_instrument {
base_currency_id
quote_currency_id
name
price_decimals
quantity_decimals
min_quantity
min_leverage
max_leverage
is_trading_on
class
margin_instrument_id
market_status
cross_quote_price
close_only
quote_currency {
precision
}
base_currency {
precision
}
price {
ask
bid
}
margin_instrument_strategy_is_active
lot_size
step_size
}
}
}
Code Examples
curl -X POST 'https://margin-trading-service-damanx.cryptosrvc.com/graphql' \
-H 'Authorization: Bearer YOUR_TOKEN' \
-H 'Content-Type: application/json' \
-d '{"query":"query open_margin_positions($search: String, $pager: PagerInput, $sort: SortInput, $user_id: String, $dateRange: DateRangeInput, $side: MarginPositionSide, $instrument_id: String, $instruments_ids: [String!], $wallet_id: String) { open_margin_positions(search: $search, pager: $pager, sort: $sort, user_id: $user_id, dateRange: $dateRange, side: $side, instrument_id: $instrument_id, instruments_ids: $instruments_ids, wallet_id: $wallet_id) { margin_position_id instrument_id user_id side leverage amount value funding_fee_amount entry_price start_price_ts end_price_ts start_ask_price duration end_ask_price pnl stop_loss take_profit start_ts_timestamp close_reason updated_at_iso start_bid_price end_bid_price close_reason_code margin total_pnl cross_quote_price exit_price wallet_id margin_currency_id margin_instrument { base_currency_id quote_currency_id name price_decimals quantity_decimals min_quantity min_leverage max_leverage is_trading_on class margin_instrument_id market_status cross_quote_price close_only quote_currency { precision } base_currency { precision } price { ask bid } margin_instrument_strategy_is_active lot_size step_size } } }","variables":{}}'
import requests
url = "https://margin-trading-service-damanx.cryptosrvc.com/graphql"
headers = {
"Authorization": "Bearer YOUR_TOKEN",
"Content-Type": "application/json",
}
payload = {
"query": """query open_margin_positions($search: String, $pager: PagerInput, $sort: SortInput, $user_id: String, $dateRange: DateRangeInput, $side: MarginPositionSide, $instrument_id: String, $instruments_ids: [String!], $wallet_id: String) { open_margin_positions(search: $search, pager: $pager, sort: $sort, user_id: $user_id, dateRange: $dateRange, side: $side, instrument_id: $instrument_id, instruments_ids: $instruments_ids, wallet_id: $wallet_id) { margin_position_id instrument_id user_id side leverage amount value funding_fee_amount entry_price start_price_ts end_price_ts start_ask_price duration end_ask_price pnl stop_loss take_profit start_ts_timestamp close_reason updated_at_iso start_bid_price end_bid_price close_reason_code margin total_pnl cross_quote_price exit_price wallet_id margin_currency_id margin_instrument { base_currency_id quote_currency_id name price_decimals quantity_decimals min_quantity min_leverage max_leverage is_trading_on class margin_instrument_id market_status cross_quote_price close_only quote_currency { precision } base_currency { precision } price { ask bid } margin_instrument_strategy_is_active lot_size step_size } } }""",
"variables": {},
}
response = requests.post(url, json=payload, headers=headers)
print(response.json())
const response = await fetch("https://margin-trading-service-damanx.cryptosrvc.com/graphql", {
method: "POST",
headers: {
"Authorization": `Bearer ${YOUR_TOKEN}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
query: `query open_margin_positions($search: String, $pager: PagerInput, $sort: SortInput, $user_id: String, $dateRange: DateRangeInput, $side: MarginPositionSide, $instrument_id: String, $instruments_ids: [String!], $wallet_id: String) { open_margin_positions(search: $search, pager: $pager, sort: $sort, user_id: $user_id, dateRange: $dateRange, side: $side, instrument_id: $instrument_id, instruments_ids: $instruments_ids, wallet_id: $wallet_id) { margin_position_id instrument_id user_id side leverage amount value funding_fee_amount entry_price start_price_ts end_price_ts start_ask_price duration end_ask_price pnl stop_loss take_profit start_ts_timestamp close_reason updated_at_iso start_bid_price end_bid_price close_reason_code margin total_pnl cross_quote_price exit_price wallet_id margin_currency_id margin_instrument { base_currency_id quote_currency_id name price_decimals quantity_decimals min_quantity min_leverage max_leverage is_trading_on class margin_instrument_id market_status cross_quote_price close_only quote_currency { precision } base_currency { precision } price { ask bid } margin_instrument_strategy_is_active lot_size step_size } } }`,
variables: {},
}),
});
const data = await response.json();
console.log(data);Try It
subscription user_balance_position User Balance Position
Inputs
| Name | Type | Required |
|---|---|---|
wallet_id |
String |
optional |
Response
| Field | Sub-fields |
|---|---|
free_balance |
scalar |
equity |
scalar |
margin_call_left_margin |
scalar |
currently_used_margin |
scalar |
pnl |
scalar |
total_pnl |
scalar |
margin_ratio_percentage |
scalar |
risk_level |
scalar |
liquidation_left_margin |
scalar |
unsettled_balance |
scalar |
GraphQL Operation
subscription user_balance_position($wallet_id: String) {
user_balance_position(wallet_id: $wallet_id) {
free_balance
equity
margin_call_left_margin
currently_used_margin
pnl
total_pnl
margin_ratio_percentage
risk_level
liquidation_left_margin
unsettled_balance
}
}
Code Examples
curl -X POST 'https://margin-trading-service-damanx.cryptosrvc.com/graphql' \
-H 'Authorization: Bearer YOUR_TOKEN' \
-H 'Content-Type: application/json' \
-d '{"query":"subscription user_balance_position($wallet_id: String) { user_balance_position(wallet_id: $wallet_id) { free_balance equity margin_call_left_margin currently_used_margin pnl total_pnl margin_ratio_percentage risk_level liquidation_left_margin unsettled_balance } }","variables":{}}'
import requests
url = "https://margin-trading-service-damanx.cryptosrvc.com/graphql"
headers = {
"Authorization": "Bearer YOUR_TOKEN",
"Content-Type": "application/json",
}
payload = {
"query": """subscription user_balance_position($wallet_id: String) { user_balance_position(wallet_id: $wallet_id) { free_balance equity margin_call_left_margin currently_used_margin pnl total_pnl margin_ratio_percentage risk_level liquidation_left_margin unsettled_balance } }""",
"variables": {},
}
response = requests.post(url, json=payload, headers=headers)
print(response.json())
const response = await fetch("https://margin-trading-service-damanx.cryptosrvc.com/graphql", {
method: "POST",
headers: {
"Authorization": `Bearer ${YOUR_TOKEN}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
query: `subscription user_balance_position($wallet_id: String) { user_balance_position(wallet_id: $wallet_id) { free_balance equity margin_call_left_margin currently_used_margin pnl total_pnl margin_ratio_percentage risk_level liquidation_left_margin unsettled_balance } }`,
variables: {},
}),
});
const data = await response.json();
console.log(data);Try It
Subscriptions are delivered over WebSocket (wss://). Use a GraphQL-WS client rather than this HTTP runner.
Trade
9 ops
mutation cancel_all_margin_orders Cancel All Margin Orders
Inputs
| Name | Type | Required |
|---|---|---|
wallet_id |
String |
optional |
Response
GraphQL Operation
mutation cancel_all_margin_orders($wallet_id: String) {
cancel_all_margin_orders(wallet_id: $wallet_id)
}
Code Examples
curl -X POST 'https://margin-trading-service-damanx.cryptosrvc.com/graphql' \
-H 'Authorization: Bearer YOUR_TOKEN' \
-H 'Content-Type: application/json' \
-d '{"query":"mutation cancel_all_margin_orders($wallet_id: String) { cancel_all_margin_orders(wallet_id: $wallet_id) }","variables":{}}'
import requests
url = "https://margin-trading-service-damanx.cryptosrvc.com/graphql"
headers = {
"Authorization": "Bearer YOUR_TOKEN",
"Content-Type": "application/json",
}
payload = {
"query": """mutation cancel_all_margin_orders($wallet_id: String) { cancel_all_margin_orders(wallet_id: $wallet_id) }""",
"variables": {},
}
response = requests.post(url, json=payload, headers=headers)
print(response.json())
const response = await fetch("https://margin-trading-service-damanx.cryptosrvc.com/graphql", {
method: "POST",
headers: {
"Authorization": `Bearer ${YOUR_TOKEN}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
query: `mutation cancel_all_margin_orders($wallet_id: String) { cancel_all_margin_orders(wallet_id: $wallet_id) }`,
variables: {},
}),
});
const data = await response.json();
console.log(data);Try It
mutation cancel_margin_order Cancel Margin Order
Inputs
| Name | Type | Required |
|---|---|---|
margin_order_id |
String |
required |
Response
GraphQL Operation
mutation cancel_margin_order($margin_order_id: String!) {
cancel_margin_order(margin_order_id: $margin_order_id)
}
Code Examples
curl -X POST 'https://margin-trading-service-damanx.cryptosrvc.com/graphql' \
-H 'Authorization: Bearer YOUR_TOKEN' \
-H 'Content-Type: application/json' \
-d '{"query":"mutation cancel_margin_order($margin_order_id: String!) { cancel_margin_order(margin_order_id: $margin_order_id) }","variables":{}}'
import requests
url = "https://margin-trading-service-damanx.cryptosrvc.com/graphql"
headers = {
"Authorization": "Bearer YOUR_TOKEN",
"Content-Type": "application/json",
}
payload = {
"query": """mutation cancel_margin_order($margin_order_id: String!) { cancel_margin_order(margin_order_id: $margin_order_id) }""",
"variables": {},
}
response = requests.post(url, json=payload, headers=headers)
print(response.json())
const response = await fetch("https://margin-trading-service-damanx.cryptosrvc.com/graphql", {
method: "POST",
headers: {
"Authorization": `Bearer ${YOUR_TOKEN}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
query: `mutation cancel_margin_order($margin_order_id: String!) { cancel_margin_order(margin_order_id: $margin_order_id) }`,
variables: {},
}),
});
const data = await response.json();
console.log(data);Try It
mutation close_all_margin_positions Close All Margin Positions
Inputs
| Name | Type | Required |
|---|---|---|
wallet_id |
String |
required |
Response
GraphQL Operation
mutation close_all_margin_positions($wallet_id: String!) {
close_all_margin_positions(wallet_id: $wallet_id)
}
Code Examples
curl -X POST 'https://margin-trading-service-damanx.cryptosrvc.com/graphql' \
-H 'Authorization: Bearer YOUR_TOKEN' \
-H 'Content-Type: application/json' \
-d '{"query":"mutation close_all_margin_positions($wallet_id: String!) { close_all_margin_positions(wallet_id: $wallet_id) }","variables":{}}'
import requests
url = "https://margin-trading-service-damanx.cryptosrvc.com/graphql"
headers = {
"Authorization": "Bearer YOUR_TOKEN",
"Content-Type": "application/json",
}
payload = {
"query": """mutation close_all_margin_positions($wallet_id: String!) { close_all_margin_positions(wallet_id: $wallet_id) }""",
"variables": {},
}
response = requests.post(url, json=payload, headers=headers)
print(response.json())
const response = await fetch("https://margin-trading-service-damanx.cryptosrvc.com/graphql", {
method: "POST",
headers: {
"Authorization": `Bearer ${YOUR_TOKEN}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
query: `mutation close_all_margin_positions($wallet_id: String!) { close_all_margin_positions(wallet_id: $wallet_id) }`,
variables: {},
}),
});
const data = await response.json();
console.log(data);Try It
mutation close_margin_position Close Margin Position
Inputs
| Name | Type | Required |
|---|---|---|
margin_position_id |
String |
required |
percentage |
Percentage |
optional |
amount |
Float |
optional |
wallet_id |
String |
required |
Response
GraphQL Operation
mutation close_margin_position($margin_position_id: String!, $percentage: Percentage, $amount: Float, $wallet_id: String!) {
close_margin_position(margin_position_id: $margin_position_id, percentage: $percentage, amount: $amount, wallet_id: $wallet_id)
}
Code Examples
curl -X POST 'https://margin-trading-service-damanx.cryptosrvc.com/graphql' \
-H 'Authorization: Bearer YOUR_TOKEN' \
-H 'Content-Type: application/json' \
-d '{"query":"mutation close_margin_position($margin_position_id: String!, $percentage: Percentage, $amount: Float, $wallet_id: String!) { close_margin_position(margin_position_id: $margin_position_id, percentage: $percentage, amount: $amount, wallet_id: $wallet_id) }","variables":{}}'
import requests
url = "https://margin-trading-service-damanx.cryptosrvc.com/graphql"
headers = {
"Authorization": "Bearer YOUR_TOKEN",
"Content-Type": "application/json",
}
payload = {
"query": """mutation close_margin_position($margin_position_id: String!, $percentage: Percentage, $amount: Float, $wallet_id: String!) { close_margin_position(margin_position_id: $margin_position_id, percentage: $percentage, amount: $amount, wallet_id: $wallet_id) }""",
"variables": {},
}
response = requests.post(url, json=payload, headers=headers)
print(response.json())
const response = await fetch("https://margin-trading-service-damanx.cryptosrvc.com/graphql", {
method: "POST",
headers: {
"Authorization": `Bearer ${YOUR_TOKEN}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
query: `mutation close_margin_position($margin_position_id: String!, $percentage: Percentage, $amount: Float, $wallet_id: String!) { close_margin_position(margin_position_id: $margin_position_id, percentage: $percentage, amount: $amount, wallet_id: $wallet_id) }`,
variables: {},
}),
});
const data = await response.json();
console.log(data);Try It
mutation create_margin_order Create Margin Order
Inputs
| Name | Type | Required |
|---|---|---|
quantity |
Float |
required |
instrument_id |
String |
required |
leverage |
Int |
required |
side |
MarginPositionSide |
required |
type |
MarginOrderType |
required |
price |
Float |
optional |
stop_loss |
Float |
optional |
take_profit |
Float |
optional |
expires_at |
String |
optional |
all_in |
ToggleSwitch |
optional |
wallet_id |
String |
optional |
time_in_force |
MarginOrderTimeInForce |
required |
Response
| Field | Sub-fields |
|---|---|
margin_order_id |
scalar |
GraphQL Operation
mutation create_margin_order($quantity: Float!, $instrument_id: String!, $leverage: Int!, $side: MarginPositionSide!, $type: MarginOrderType!, $price: Float, $stop_loss: Float, $take_profit: Float, $expires_at: String, $all_in: ToggleSwitch, $wallet_id: String, $time_in_force: MarginOrderTimeInForce!) {
create_margin_order(quantity: $quantity, instrument_id: $instrument_id, leverage: $leverage, side: $side, type: $type, price: $price, stop_loss: $stop_loss, take_profit: $take_profit, expires_at: $expires_at, all_in: $all_in, wallet_id: $wallet_id, time_in_force: $time_in_force) {
margin_order_id
}
}
Code Examples
curl -X POST 'https://margin-trading-service-damanx.cryptosrvc.com/graphql' \
-H 'Authorization: Bearer YOUR_TOKEN' \
-H 'Content-Type: application/json' \
-d '{"query":"mutation create_margin_order($quantity: Float!, $instrument_id: String!, $leverage: Int!, $side: MarginPositionSide!, $type: MarginOrderType!, $price: Float, $stop_loss: Float, $take_profit: Float, $expires_at: String, $all_in: ToggleSwitch, $wallet_id: String, $time_in_force: MarginOrderTimeInForce!) { create_margin_order(quantity: $quantity, instrument_id: $instrument_id, leverage: $leverage, side: $side, type: $type, price: $price, stop_loss: $stop_loss, take_profit: $take_profit, expires_at: $expires_at, all_in: $all_in, wallet_id: $wallet_id, time_in_force: $time_in_force) { margin_order_id } }","variables":{}}'
import requests
url = "https://margin-trading-service-damanx.cryptosrvc.com/graphql"
headers = {
"Authorization": "Bearer YOUR_TOKEN",
"Content-Type": "application/json",
}
payload = {
"query": """mutation create_margin_order($quantity: Float!, $instrument_id: String!, $leverage: Int!, $side: MarginPositionSide!, $type: MarginOrderType!, $price: Float, $stop_loss: Float, $take_profit: Float, $expires_at: String, $all_in: ToggleSwitch, $wallet_id: String, $time_in_force: MarginOrderTimeInForce!) { create_margin_order(quantity: $quantity, instrument_id: $instrument_id, leverage: $leverage, side: $side, type: $type, price: $price, stop_loss: $stop_loss, take_profit: $take_profit, expires_at: $expires_at, all_in: $all_in, wallet_id: $wallet_id, time_in_force: $time_in_force) { margin_order_id } }""",
"variables": {},
}
response = requests.post(url, json=payload, headers=headers)
print(response.json())
const response = await fetch("https://margin-trading-service-damanx.cryptosrvc.com/graphql", {
method: "POST",
headers: {
"Authorization": `Bearer ${YOUR_TOKEN}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
query: `mutation create_margin_order($quantity: Float!, $instrument_id: String!, $leverage: Int!, $side: MarginPositionSide!, $type: MarginOrderType!, $price: Float, $stop_loss: Float, $take_profit: Float, $expires_at: String, $all_in: ToggleSwitch, $wallet_id: String, $time_in_force: MarginOrderTimeInForce!) { create_margin_order(quantity: $quantity, instrument_id: $instrument_id, leverage: $leverage, side: $side, type: $type, price: $price, stop_loss: $stop_loss, take_profit: $take_profit, expires_at: $expires_at, all_in: $all_in, wallet_id: $wallet_id, time_in_force: $time_in_force) { margin_order_id } }`,
variables: {},
}),
});
const data = await response.json();
console.log(data);Try It
mutation edit_margin_order Edit Margin Order
Inputs
| Name | Type | Required |
|---|---|---|
margin_order_id |
String |
required |
leverage |
Int |
required |
quantity |
Float |
required |
price |
Float |
optional |
stop_loss |
Float |
optional |
take_profit |
Float |
optional |
expires_at |
String |
optional |
Response
GraphQL Operation
mutation edit_margin_order($margin_order_id: String!, $leverage: Int!, $quantity: Float!, $price: Float, $stop_loss: Float, $take_profit: Float, $expires_at: String) {
edit_margin_order(margin_order_id: $margin_order_id, leverage: $leverage, quantity: $quantity, price: $price, stop_loss: $stop_loss, take_profit: $take_profit, expires_at: $expires_at)
}
Code Examples
curl -X POST 'https://margin-trading-service-damanx.cryptosrvc.com/graphql' \
-H 'Authorization: Bearer YOUR_TOKEN' \
-H 'Content-Type: application/json' \
-d '{"query":"mutation edit_margin_order($margin_order_id: String!, $leverage: Int!, $quantity: Float!, $price: Float, $stop_loss: Float, $take_profit: Float, $expires_at: String) { edit_margin_order(margin_order_id: $margin_order_id, leverage: $leverage, quantity: $quantity, price: $price, stop_loss: $stop_loss, take_profit: $take_profit, expires_at: $expires_at) }","variables":{}}'
import requests
url = "https://margin-trading-service-damanx.cryptosrvc.com/graphql"
headers = {
"Authorization": "Bearer YOUR_TOKEN",
"Content-Type": "application/json",
}
payload = {
"query": """mutation edit_margin_order($margin_order_id: String!, $leverage: Int!, $quantity: Float!, $price: Float, $stop_loss: Float, $take_profit: Float, $expires_at: String) { edit_margin_order(margin_order_id: $margin_order_id, leverage: $leverage, quantity: $quantity, price: $price, stop_loss: $stop_loss, take_profit: $take_profit, expires_at: $expires_at) }""",
"variables": {},
}
response = requests.post(url, json=payload, headers=headers)
print(response.json())
const response = await fetch("https://margin-trading-service-damanx.cryptosrvc.com/graphql", {
method: "POST",
headers: {
"Authorization": `Bearer ${YOUR_TOKEN}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
query: `mutation edit_margin_order($margin_order_id: String!, $leverage: Int!, $quantity: Float!, $price: Float, $stop_loss: Float, $take_profit: Float, $expires_at: String) { edit_margin_order(margin_order_id: $margin_order_id, leverage: $leverage, quantity: $quantity, price: $price, stop_loss: $stop_loss, take_profit: $take_profit, expires_at: $expires_at) }`,
variables: {},
}),
});
const data = await response.json();
console.log(data);Try It
query estimate_margin_user_position Estimate Margin User Position
Inputs
| Name | Type | Required |
|---|---|---|
instrument_id |
String |
required |
quantity |
Float |
required |
leverage |
Int |
required |
side |
MarginPositionSide |
required |
limit_price |
Float |
optional |
use_cached_price |
ToggleSwitch |
optional |
wallet_id |
String |
optional |
Response
| Field | Sub-fields |
|---|---|
order_required_margin |
scalar |
fee |
scalar |
order_available_margin |
scalar |
order_value |
scalar |
max_position_size_base |
scalar |
min_position_size_base |
scalar |
fees_breakdown |
fee, value, source |
free_balance |
scalar |
pnl |
scalar |
equity |
scalar |
total_pnl |
scalar |
GraphQL Operation
query estimate_margin_user_position($instrument_id: String!, $quantity: Float!, $leverage: Int!, $side: MarginPositionSide!, $limit_price: Float, $use_cached_price: ToggleSwitch, $wallet_id: String) {
estimate_margin_user_position(instrument_id: $instrument_id, quantity: $quantity, leverage: $leverage, side: $side, limit_price: $limit_price, use_cached_price: $use_cached_price, wallet_id: $wallet_id) {
order_required_margin
fee
order_available_margin
order_value
max_position_size_base
min_position_size_base
fees_breakdown {
fee
value
source
}
free_balance
pnl
equity
total_pnl
}
}
Code Examples
curl -X POST 'https://margin-trading-service-damanx.cryptosrvc.com/graphql' \
-H 'Authorization: Bearer YOUR_TOKEN' \
-H 'Content-Type: application/json' \
-d '{"query":"query estimate_margin_user_position($instrument_id: String!, $quantity: Float!, $leverage: Int!, $side: MarginPositionSide!, $limit_price: Float, $use_cached_price: ToggleSwitch, $wallet_id: String) { estimate_margin_user_position(instrument_id: $instrument_id, quantity: $quantity, leverage: $leverage, side: $side, limit_price: $limit_price, use_cached_price: $use_cached_price, wallet_id: $wallet_id) { order_required_margin fee order_available_margin order_value max_position_size_base min_position_size_base fees_breakdown { fee value source } free_balance pnl equity total_pnl } }","variables":{}}'
import requests
url = "https://margin-trading-service-damanx.cryptosrvc.com/graphql"
headers = {
"Authorization": "Bearer YOUR_TOKEN",
"Content-Type": "application/json",
}
payload = {
"query": """query estimate_margin_user_position($instrument_id: String!, $quantity: Float!, $leverage: Int!, $side: MarginPositionSide!, $limit_price: Float, $use_cached_price: ToggleSwitch, $wallet_id: String) { estimate_margin_user_position(instrument_id: $instrument_id, quantity: $quantity, leverage: $leverage, side: $side, limit_price: $limit_price, use_cached_price: $use_cached_price, wallet_id: $wallet_id) { order_required_margin fee order_available_margin order_value max_position_size_base min_position_size_base fees_breakdown { fee value source } free_balance pnl equity total_pnl } }""",
"variables": {},
}
response = requests.post(url, json=payload, headers=headers)
print(response.json())
const response = await fetch("https://margin-trading-service-damanx.cryptosrvc.com/graphql", {
method: "POST",
headers: {
"Authorization": `Bearer ${YOUR_TOKEN}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
query: `query estimate_margin_user_position($instrument_id: String!, $quantity: Float!, $leverage: Int!, $side: MarginPositionSide!, $limit_price: Float, $use_cached_price: ToggleSwitch, $wallet_id: String) { estimate_margin_user_position(instrument_id: $instrument_id, quantity: $quantity, leverage: $leverage, side: $side, limit_price: $limit_price, use_cached_price: $use_cached_price, wallet_id: $wallet_id) { order_required_margin fee order_available_margin order_value max_position_size_base min_position_size_base fees_breakdown { fee value source } free_balance pnl equity total_pnl } }`,
variables: {},
}),
});
const data = await response.json();
console.log(data);Try It
subscription margin_user_update Margin User Update
Inputs
| Name | Type | Required |
|---|---|---|
wallet_id |
String |
optional |
Response
| Field | Sub-fields |
|---|---|
notification |
title, body, trigger |
GraphQL Operation
subscription margin_user_update($wallet_id: String) {
margin_user_update(wallet_id: $wallet_id) {
notification {
title
body
trigger
}
}
}
Code Examples
curl -X POST 'https://margin-trading-service-damanx.cryptosrvc.com/graphql' \
-H 'Authorization: Bearer YOUR_TOKEN' \
-H 'Content-Type: application/json' \
-d '{"query":"subscription margin_user_update($wallet_id: String) { margin_user_update(wallet_id: $wallet_id) { notification { title body trigger } } }","variables":{}}'
import requests
url = "https://margin-trading-service-damanx.cryptosrvc.com/graphql"
headers = {
"Authorization": "Bearer YOUR_TOKEN",
"Content-Type": "application/json",
}
payload = {
"query": """subscription margin_user_update($wallet_id: String) { margin_user_update(wallet_id: $wallet_id) { notification { title body trigger } } }""",
"variables": {},
}
response = requests.post(url, json=payload, headers=headers)
print(response.json())
const response = await fetch("https://margin-trading-service-damanx.cryptosrvc.com/graphql", {
method: "POST",
headers: {
"Authorization": `Bearer ${YOUR_TOKEN}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
query: `subscription margin_user_update($wallet_id: String) { margin_user_update(wallet_id: $wallet_id) { notification { title body trigger } } }`,
variables: {},
}),
});
const data = await response.json();
console.log(data);Try It
Subscriptions are delivered over WebSocket (wss://). Use a GraphQL-WS client rather than this HTTP runner.
mutation update_open_margin_position Update Open Margin Position
Inputs
| Name | Type | Required |
|---|---|---|
margin_position_id |
String |
required |
leverage |
Int |
required |
stop_loss |
Float |
optional |
take_profit |
Float |
optional |
Response
| Field | Sub-fields |
|---|---|
margin_position_id |
scalar |
instrument_id |
scalar |
user_id |
scalar |
side |
scalar |
leverage |
scalar |
amount |
scalar |
value |
scalar |
funding_fee_amount |
scalar |
entry_price |
scalar |
start_price_ts |
scalar |
end_price_ts |
scalar |
start_ask_price |
scalar |
duration |
scalar |
end_ask_price |
scalar |
pnl |
scalar |
stop_loss |
scalar |
take_profit |
scalar |
start_ts_timestamp |
scalar |
close_reason |
scalar |
updated_at_iso |
scalar |
start_bid_price |
scalar |
end_bid_price |
scalar |
close_reason_code |
scalar |
margin |
scalar |
total_pnl |
scalar |
cross_quote_price |
scalar |
exit_price |
scalar |
wallet_id |
scalar |
margin_currency_id |
scalar |
margin_instrument |
base_currency_id, quote_currency_id, name, price_decimals, quantity_decimals, min_quantity, min_leverage, max_leverage, is_trading_on, class, margin_instrument_id, market_status, cross_quote_price, close_only, quote_currency, base_currency, price, margin_instrument_strategy_is_active, lot_size, step_size |
GraphQL Operation
mutation update_open_margin_position($margin_position_id: String!, $leverage: Int!, $stop_loss: Float, $take_profit: Float) {
update_open_margin_position(margin_position_id: $margin_position_id, leverage: $leverage, stop_loss: $stop_loss, take_profit: $take_profit) {
margin_position_id
instrument_id
user_id
side
leverage
amount
value
funding_fee_amount
entry_price
start_price_ts
end_price_ts
start_ask_price
duration
end_ask_price
pnl
stop_loss
take_profit
start_ts_timestamp
close_reason
updated_at_iso
start_bid_price
end_bid_price
close_reason_code
margin
total_pnl
cross_quote_price
exit_price
wallet_id
margin_currency_id
margin_instrument {
base_currency_id
quote_currency_id
name
price_decimals
quantity_decimals
min_quantity
min_leverage
max_leverage
is_trading_on
class
margin_instrument_id
market_status
cross_quote_price
close_only
quote_currency {
precision
}
base_currency {
precision
}
price {
ask
bid
}
margin_instrument_strategy_is_active
lot_size
step_size
}
}
}
Code Examples
curl -X POST 'https://margin-trading-service-damanx.cryptosrvc.com/graphql' \
-H 'Authorization: Bearer YOUR_TOKEN' \
-H 'Content-Type: application/json' \
-d '{"query":"mutation update_open_margin_position($margin_position_id: String!, $leverage: Int!, $stop_loss: Float, $take_profit: Float) { update_open_margin_position(margin_position_id: $margin_position_id, leverage: $leverage, stop_loss: $stop_loss, take_profit: $take_profit) { margin_position_id instrument_id user_id side leverage amount value funding_fee_amount entry_price start_price_ts end_price_ts start_ask_price duration end_ask_price pnl stop_loss take_profit start_ts_timestamp close_reason updated_at_iso start_bid_price end_bid_price close_reason_code margin total_pnl cross_quote_price exit_price wallet_id margin_currency_id margin_instrument { base_currency_id quote_currency_id name price_decimals quantity_decimals min_quantity min_leverage max_leverage is_trading_on class margin_instrument_id market_status cross_quote_price close_only quote_currency { precision } base_currency { precision } price { ask bid } margin_instrument_strategy_is_active lot_size step_size } } }","variables":{}}'
import requests
url = "https://margin-trading-service-damanx.cryptosrvc.com/graphql"
headers = {
"Authorization": "Bearer YOUR_TOKEN",
"Content-Type": "application/json",
}
payload = {
"query": """mutation update_open_margin_position($margin_position_id: String!, $leverage: Int!, $stop_loss: Float, $take_profit: Float) { update_open_margin_position(margin_position_id: $margin_position_id, leverage: $leverage, stop_loss: $stop_loss, take_profit: $take_profit) { margin_position_id instrument_id user_id side leverage amount value funding_fee_amount entry_price start_price_ts end_price_ts start_ask_price duration end_ask_price pnl stop_loss take_profit start_ts_timestamp close_reason updated_at_iso start_bid_price end_bid_price close_reason_code margin total_pnl cross_quote_price exit_price wallet_id margin_currency_id margin_instrument { base_currency_id quote_currency_id name price_decimals quantity_decimals min_quantity min_leverage max_leverage is_trading_on class margin_instrument_id market_status cross_quote_price close_only quote_currency { precision } base_currency { precision } price { ask bid } margin_instrument_strategy_is_active lot_size step_size } } }""",
"variables": {},
}
response = requests.post(url, json=payload, headers=headers)
print(response.json())
const response = await fetch("https://margin-trading-service-damanx.cryptosrvc.com/graphql", {
method: "POST",
headers: {
"Authorization": `Bearer ${YOUR_TOKEN}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
query: `mutation update_open_margin_position($margin_position_id: String!, $leverage: Int!, $stop_loss: Float, $take_profit: Float) { update_open_margin_position(margin_position_id: $margin_position_id, leverage: $leverage, stop_loss: $stop_loss, take_profit: $take_profit) { margin_position_id instrument_id user_id side leverage amount value funding_fee_amount entry_price start_price_ts end_price_ts start_ask_price duration end_ask_price pnl stop_loss take_profit start_ts_timestamp close_reason updated_at_iso start_bid_price end_bid_price close_reason_code margin total_pnl cross_quote_price exit_price wallet_id margin_currency_id margin_instrument { base_currency_id quote_currency_id name price_decimals quantity_decimals min_quantity min_leverage max_leverage is_trading_on class margin_instrument_id market_status cross_quote_price close_only quote_currency { precision } base_currency { precision } price { ask bid } margin_instrument_strategy_is_active lot_size step_size } } }`,
variables: {},
}),
});
const data = await response.json();
console.log(data);