Merge branch 'master' of github.com:peepopoggers/bybit-api into masterp
This commit is contained in:
@@ -33,7 +33,11 @@ export class InverseClient extends SharedEndpoints {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
//------------Market Data Endpoints------------>
|
/**
|
||||||
|
*
|
||||||
|
* Market Data Endpoints
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
getKline(params: {
|
getKline(params: {
|
||||||
symbol: string;
|
symbol: string;
|
||||||
@@ -112,7 +116,15 @@ export class InverseClient extends SharedEndpoints {
|
|||||||
return this.requestWrapper.get('v2/public/premium-index-kline', params);
|
return this.requestWrapper.get('v2/public/premium-index-kline', params);
|
||||||
}
|
}
|
||||||
|
|
||||||
//-----------Account Data Endpoints------------>
|
/**
|
||||||
|
*
|
||||||
|
* Account Data Endpoints
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Active orders
|
||||||
|
*/
|
||||||
|
|
||||||
placeActiveOrder(orderRequest: {
|
placeActiveOrder(orderRequest: {
|
||||||
side: string;
|
side: string;
|
||||||
@@ -171,6 +183,10 @@ export class InverseClient extends SharedEndpoints {
|
|||||||
}): GenericAPIResponse {
|
}): GenericAPIResponse {
|
||||||
return this.requestWrapper.get('v2/private/order', params);
|
return this.requestWrapper.get('v2/private/order', params);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Conditional orders
|
||||||
|
*/
|
||||||
|
|
||||||
placeConditionalOrder(params: {
|
placeConditionalOrder(params: {
|
||||||
side: string;
|
side: string;
|
||||||
@@ -230,6 +246,10 @@ export class InverseClient extends SharedEndpoints {
|
|||||||
}): GenericAPIResponse {
|
}): GenericAPIResponse {
|
||||||
return this.requestWrapper.get('v2/private/stop-order', params);
|
return this.requestWrapper.get('v2/private/stop-order', params);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Position
|
||||||
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @deprecated use getPosition() instead
|
* @deprecated use getPosition() instead
|
||||||
@@ -305,6 +325,10 @@ export class InverseClient extends SharedEndpoints {
|
|||||||
return this.requestWrapper.get('v2/private/trade/closed-pnl/list', params);
|
return this.requestWrapper.get('v2/private/trade/closed-pnl/list', params);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Risk Limit
|
||||||
|
*/
|
||||||
|
|
||||||
getRiskLimitList(): GenericAPIResponse {
|
getRiskLimitList(): GenericAPIResponse {
|
||||||
return this.requestWrapper.get('open-api/wallet/risk-limit/list');
|
return this.requestWrapper.get('open-api/wallet/risk-limit/list');
|
||||||
}
|
}
|
||||||
@@ -315,6 +339,10 @@ export class InverseClient extends SharedEndpoints {
|
|||||||
}): GenericAPIResponse {
|
}): GenericAPIResponse {
|
||||||
return this.requestWrapper.post('open-api/wallet/risk-limit', params);
|
return this.requestWrapper.post('open-api/wallet/risk-limit', params);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Funding
|
||||||
|
*/
|
||||||
|
|
||||||
getLastFundingRate(params: {
|
getLastFundingRate(params: {
|
||||||
symbol: string;
|
symbol: string;
|
||||||
@@ -333,6 +361,10 @@ export class InverseClient extends SharedEndpoints {
|
|||||||
}): GenericAPIResponse {
|
}): GenericAPIResponse {
|
||||||
return this.requestWrapper.get('v2/private/funding/predicted-funding', params);
|
return this.requestWrapper.get('v2/private/funding/predicted-funding', params);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* LCP Info
|
||||||
|
*/
|
||||||
|
|
||||||
getLcpInfo(params: {
|
getLcpInfo(params: {
|
||||||
symbol: string;
|
symbol: string;
|
||||||
|
|||||||
@@ -4,9 +4,9 @@ import RequestWrapper from './util/requestWrapper';
|
|||||||
import SharedEndpoints from './shared-endpoints';
|
import SharedEndpoints from './shared-endpoints';
|
||||||
|
|
||||||
export class LinearClient extends SharedEndpoints {
|
export class LinearClient extends SharedEndpoints {
|
||||||
protected requestWrapper: RequestWrapper;
|
protected requestWrapper: RequestWrapper;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @public Creates an instance of the inverse REST API client.
|
* @public Creates an instance of the inverse REST API client.
|
||||||
*
|
*
|
||||||
* @param {string} key - your API key
|
* @param {string} key - your API key
|
||||||
@@ -16,334 +16,352 @@ export class LinearClient extends SharedEndpoints {
|
|||||||
* @param {AxiosRequestConfig} [requestOptions={}] HTTP networking options for axios
|
* @param {AxiosRequestConfig} [requestOptions={}] HTTP networking options for axios
|
||||||
*/
|
*/
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
key?: string | undefined,
|
key?: string | undefined,
|
||||||
secret?: string | undefined,
|
secret?: string | undefined,
|
||||||
livenet?: boolean,
|
livenet?: boolean,
|
||||||
restInverseOptions:RestClientInverseOptions = {}, // TODO: Rename this type to be more general.
|
restInverseOptions:RestClientInverseOptions = {}, // TODO: Rename this type to be more general.
|
||||||
requestOptions: AxiosRequestConfig = {}
|
requestOptions: AxiosRequestConfig = {}
|
||||||
) {
|
) {
|
||||||
super()
|
super()
|
||||||
this.requestWrapper = new RequestWrapper(
|
this.requestWrapper = new RequestWrapper(
|
||||||
key,
|
key,
|
||||||
secret,
|
secret,
|
||||||
getBaseRESTInverseUrl(livenet),
|
getBaseRESTInverseUrl(livenet),
|
||||||
restInverseOptions,
|
restInverseOptions,
|
||||||
requestOptions
|
requestOptions
|
||||||
);
|
);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
//------------Market Data Endpoints------------>
|
/**
|
||||||
|
*
|
||||||
|
* Market Data Endpoints
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
getKline(params: {
|
getKline(params: {
|
||||||
symbol: string;
|
symbol: string;
|
||||||
interval: string;
|
interval: string;
|
||||||
from: number;
|
from: number;
|
||||||
limit?: number;
|
limit?: number;
|
||||||
}): GenericAPIResponse {
|
}): GenericAPIResponse {
|
||||||
return this.requestWrapper.get('/public/linear/kline', params);
|
return this.requestWrapper.get('/public/linear/kline', params);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated use getTrades() instead
|
||||||
|
*/
|
||||||
|
getPublicTradingRecords(params: {
|
||||||
|
symbol: string;
|
||||||
|
from?: number;
|
||||||
|
limit?: number;
|
||||||
|
}): GenericAPIResponse {
|
||||||
|
return this.getTrades(params);
|
||||||
|
}
|
||||||
|
|
||||||
|
getTrades(params: {
|
||||||
|
symbol: string;
|
||||||
|
//from?: number;
|
||||||
|
limit?: number;
|
||||||
|
}): GenericAPIResponse {
|
||||||
|
return this.requestWrapper.get('public/linear/recent-trading-records', params);
|
||||||
|
}
|
||||||
|
|
||||||
|
getLastFundingRate(params: {
|
||||||
|
symbol: string;
|
||||||
|
}): GenericAPIResponse {
|
||||||
|
return this.requestWrapper.get('public/linear/funding/prev-funding-rate', params);
|
||||||
|
}
|
||||||
|
|
||||||
|
getMarkPriceKline(params: {
|
||||||
|
symbol: string;
|
||||||
|
interval: string;
|
||||||
|
from: number;
|
||||||
|
limit?: number;
|
||||||
|
}): GenericAPIResponse {
|
||||||
|
return this.requestWrapper.get('public/linear/mark-price-kline', params);
|
||||||
|
}
|
||||||
|
|
||||||
|
getIndexPriceKline(params: {
|
||||||
|
symbol: string;
|
||||||
|
interval: string;
|
||||||
|
from: number;
|
||||||
|
limit?: number;
|
||||||
|
}): GenericAPIResponse {
|
||||||
|
return this.requestWrapper.get('public/linear/index-price-kline', params);
|
||||||
|
}
|
||||||
|
|
||||||
|
getPremiumIndexKline(params: {
|
||||||
|
symbol: string;
|
||||||
|
interval: string;
|
||||||
|
from: number;
|
||||||
|
limit?: number;
|
||||||
|
}): GenericAPIResponse {
|
||||||
|
return this.requestWrapper.get('public/linear/premium-index-kline', params);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* Account Data Endpoints
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @deprecated use getTrades() instead
|
* Active orders
|
||||||
*/
|
*/
|
||||||
getPublicTradingRecords(params: {
|
|
||||||
symbol: string;
|
|
||||||
from?: number;
|
|
||||||
limit?: number;
|
|
||||||
}): GenericAPIResponse {
|
|
||||||
return this.getTrades(params);
|
|
||||||
}
|
|
||||||
|
|
||||||
getTrades(params: {
|
placeActiveOrder(params: {
|
||||||
symbol: string;
|
side: string;
|
||||||
//from?: number;
|
symbol: string;
|
||||||
limit?: number;
|
order_type: string;
|
||||||
}): GenericAPIResponse {
|
qty: number;
|
||||||
return this.requestWrapper.get('public/linear/recent-trading-records', params);
|
price?: number;
|
||||||
}
|
time_in_force: string;
|
||||||
|
take_profit?: number;
|
||||||
|
stop_loss?: number;
|
||||||
|
tp_trigger_by?: string;
|
||||||
|
sl_trigger_by?: string;
|
||||||
|
reduce_only?: boolean;
|
||||||
|
close_on_trigger?: boolean;
|
||||||
|
order_link_id?: string;
|
||||||
|
}): GenericAPIResponse {
|
||||||
|
return this.requestWrapper.post('private/linear/order/create', params);
|
||||||
|
}
|
||||||
|
|
||||||
getLastFundingRate(params: {
|
getActiveOrderList(params: {
|
||||||
symbol: string;
|
order_id?: string;
|
||||||
}): GenericAPIResponse {
|
order_link_id?: string;
|
||||||
return this.requestWrapper.get('public/linear/funding/prev-funding-rate', params);
|
symbol: string;
|
||||||
}
|
order?: string;
|
||||||
|
page?: number;
|
||||||
|
limit?: number;
|
||||||
|
order_status?: string;
|
||||||
|
|
||||||
getMarkPriceKline(params: {
|
}): GenericAPIResponse {
|
||||||
symbol: string;
|
return this.requestWrapper.get('private/linear/order/list', params);
|
||||||
interval: string;
|
}
|
||||||
from: number;
|
|
||||||
limit?: number;
|
|
||||||
}): GenericAPIResponse {
|
|
||||||
return this.requestWrapper.get('public/linear/mark-price-kline', params);
|
|
||||||
}
|
|
||||||
|
|
||||||
getIndexPriceKline(params: {
|
cancelActiveOrder(params: {
|
||||||
symbol: string;
|
symbol: string;
|
||||||
interval: string;
|
order_id?: string;
|
||||||
from: number;
|
order_link_id?: string;
|
||||||
limit?: number;
|
}): GenericAPIResponse {
|
||||||
}): GenericAPIResponse {
|
return this.requestWrapper.post('private/linear/order/cancel', params);
|
||||||
return this.requestWrapper.get('public/linear/index-price-kline', params);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
getPremiumIndexKline(params: {
|
cancelAllActiveOrders(params: {
|
||||||
symbol: string;
|
symbol: string;
|
||||||
interval: string;
|
}): GenericAPIResponse {
|
||||||
from: number;
|
return this.requestWrapper.post('private/linear/order/cancel-all', params);
|
||||||
limit?: number;
|
}
|
||||||
}): GenericAPIResponse {
|
|
||||||
return this.requestWrapper.get('public/linear/premium-index-kline', params);
|
|
||||||
}
|
|
||||||
|
|
||||||
//------------Account Data Endpoints------------>
|
replaceActiveOrder(params: {
|
||||||
|
order_id?: string;
|
||||||
|
order_link_id?: string;
|
||||||
|
symbol: string;
|
||||||
|
p_r_qty?: number;
|
||||||
|
p_r_price?: number;
|
||||||
|
take_profit?: number;
|
||||||
|
stop_loss?: number;
|
||||||
|
tp_trigger_by?: string;
|
||||||
|
sl_trigger_by?: string;
|
||||||
|
}): GenericAPIResponse {
|
||||||
|
return this.requestWrapper.post('private/linear/order/replace', params);
|
||||||
|
}
|
||||||
|
|
||||||
//Active Orders
|
queryActiveOrder(params: {
|
||||||
|
order_id?: string;
|
||||||
|
order_link_id?: string;
|
||||||
|
symbol: string;
|
||||||
|
}): GenericAPIResponse {
|
||||||
|
return this.requestWrapper.get('private/linear/order/search', params);
|
||||||
|
}
|
||||||
|
|
||||||
placeActiveOrder(params: {
|
/**
|
||||||
side: string;
|
* Conditional orders
|
||||||
symbol: string;
|
*/
|
||||||
order_type: string;
|
|
||||||
qty: number;
|
|
||||||
price?: number;
|
|
||||||
time_in_force: string;
|
|
||||||
take_profit?: number;
|
|
||||||
stop_loss?: number;
|
|
||||||
tp_trigger_by?: string;
|
|
||||||
sl_trigger_by?: string;
|
|
||||||
reduce_only?: boolean;
|
|
||||||
close_on_trigger?: boolean;
|
|
||||||
order_link_id?: string;
|
|
||||||
}): GenericAPIResponse {
|
|
||||||
return this.requestWrapper.post('private/linear/order/create', params);
|
|
||||||
}
|
|
||||||
|
|
||||||
getActiveOrderList(params: {
|
placeConditionalOrder(params: {
|
||||||
order_id?: string;
|
side: string;
|
||||||
order_link_id?: string;
|
symbol: string;
|
||||||
symbol: string;
|
order_type: string;
|
||||||
order?: string;
|
qty: number;
|
||||||
page?: number;
|
price?: number;
|
||||||
limit?: number;
|
base_price: number;
|
||||||
order_status?: string;
|
stop_px: number;
|
||||||
|
time_in_force: string;
|
||||||
|
trigger_by?: string;
|
||||||
|
close_on_trigger?: boolean;
|
||||||
|
order_link_id?: string;
|
||||||
|
reduce_only: boolean;
|
||||||
|
take_profit?: number;
|
||||||
|
stop_loss?: number;
|
||||||
|
tp_trigger_by?: string;
|
||||||
|
sl_trigger_by?: string;
|
||||||
|
}): GenericAPIResponse {
|
||||||
|
return this.requestWrapper.post('private/linear/stop-order/create', params);
|
||||||
|
}
|
||||||
|
|
||||||
}): GenericAPIResponse {
|
getConditionalOrder(params: {
|
||||||
return this.requestWrapper.get('private/linear/order/list', params);
|
stop_order_id?: string;
|
||||||
}
|
order_link_id?: string;
|
||||||
|
symbol: string;
|
||||||
|
stop_order_status?: string;
|
||||||
|
order?: string;
|
||||||
|
page?: number;
|
||||||
|
limit?: number;
|
||||||
|
}): GenericAPIResponse {
|
||||||
|
return this.requestWrapper.get('private/linear/stop-order/list', params);
|
||||||
|
}
|
||||||
|
|
||||||
cancelActiveOrder(params: {
|
cancelConditionalOrder(params: {
|
||||||
symbol: string;
|
symbol: string;
|
||||||
order_id?: string;
|
stop_order_id?: string;
|
||||||
order_link_id?: string;
|
order_link_id?: string;
|
||||||
}): GenericAPIResponse {
|
}): GenericAPIResponse {
|
||||||
return this.requestWrapper.post('private/linear/order/cancel', params);
|
return this.requestWrapper.post('private/linear/stop-order/cancel', params);
|
||||||
}
|
}
|
||||||
|
|
||||||
cancelAllActiveOrders(params: {
|
cancelAllConditionalOrders(params: {
|
||||||
symbol: string;
|
symbol: string;
|
||||||
}): GenericAPIResponse {
|
}): GenericAPIResponse {
|
||||||
return this.requestWrapper.post('private/linear/order/cancel-all', params);
|
return this.requestWrapper.post('private/linear/stop-order/cancel-all', params);
|
||||||
}
|
}
|
||||||
|
|
||||||
replaceActiveOrder(params: {
|
replaceConditionalOrder(params: {
|
||||||
order_id?: string;
|
stop_order_id?: string;
|
||||||
order_link_id?: string;
|
order_link_id?: string;
|
||||||
symbol: string;
|
symbol: string;
|
||||||
p_r_qty?: number;
|
p_r_qty?: number;
|
||||||
p_r_price?: number;
|
p_r_price?: number;
|
||||||
take_profit?: number;
|
p_r_trigger_price?: number;
|
||||||
stop_loss?: number;
|
take_profit?: number;
|
||||||
tp_trigger_by?: string;
|
stop_loss?: number;
|
||||||
sl_trigger_by?: string;
|
tp_trigger_by?: string;
|
||||||
}): GenericAPIResponse {
|
sl_trigger_by?: string;
|
||||||
return this.requestWrapper.post('private/linear/order/replace', params);
|
}): GenericAPIResponse {
|
||||||
}
|
return this.requestWrapper.post('private/linear/stop-order/replace', params);
|
||||||
|
}
|
||||||
|
|
||||||
queryActiveOrder(params: {
|
queryConditionalOrder(params: {
|
||||||
order_id?: string;
|
symbol: string;
|
||||||
order_link_id?: string;
|
stop_order_id?: string;
|
||||||
symbol: string;
|
order_link_id?: string;
|
||||||
}): GenericAPIResponse {
|
}): GenericAPIResponse {
|
||||||
return this.requestWrapper.get('private/linear/order/search', params);
|
return this.requestWrapper.get('private/linear/stop-order/search', params);
|
||||||
}
|
}
|
||||||
|
|
||||||
//Conditional Orders
|
/**
|
||||||
|
* Position
|
||||||
|
*/
|
||||||
|
|
||||||
placeConditionalOrder(params: {
|
getPosition(params?: {
|
||||||
side: string;
|
symbol?: string;
|
||||||
symbol: string;
|
}): GenericAPIResponse {
|
||||||
order_type: string;
|
return this.requestWrapper.get('private/linear/position/list', params);
|
||||||
qty: number;
|
}
|
||||||
price?: number;
|
|
||||||
base_price: number;
|
|
||||||
stop_px: number;
|
|
||||||
time_in_force: string;
|
|
||||||
trigger_by?: string;
|
|
||||||
close_on_trigger?: boolean;
|
|
||||||
order_link_id?: string;
|
|
||||||
reduce_only: boolean;
|
|
||||||
take_profit?: number;
|
|
||||||
stop_loss?: number;
|
|
||||||
tp_trigger_by?: string;
|
|
||||||
sl_trigger_by?: string;
|
|
||||||
}): GenericAPIResponse {
|
|
||||||
return this.requestWrapper.post('private/linear/stop-order/create', params);
|
|
||||||
}
|
|
||||||
|
|
||||||
getConditionalOrder(params: {
|
setAutoAddMargin(params?: {
|
||||||
stop_order_id?: string;
|
symbol: string;
|
||||||
order_link_id?: string;
|
side: string;
|
||||||
symbol: string;
|
auto_add_margin: boolean;
|
||||||
stop_order_status?: string;
|
}): GenericAPIResponse {
|
||||||
order?: string;
|
return this.requestWrapper.post('private/linear/position/set-auto-add-margin', params);
|
||||||
page?: number;
|
}
|
||||||
limit?: number;
|
|
||||||
}): GenericAPIResponse {
|
|
||||||
return this.requestWrapper.get('private/linear/stop-order/list', params);
|
|
||||||
}
|
|
||||||
|
|
||||||
cancelConditionalOrder(params: {
|
setMarginSwitch(params?: {
|
||||||
symbol: string;
|
symbol: string;
|
||||||
stop_order_id?: string;
|
is_isolated: boolean;
|
||||||
order_link_id?: string;
|
buy_leverage: number;
|
||||||
}): GenericAPIResponse {
|
sell_leverage: number;
|
||||||
return this.requestWrapper.post('private/linear/stop-order/cancel', params);
|
}): GenericAPIResponse {
|
||||||
}
|
return this.requestWrapper.post('private/linear/position/switch-isolated', params);
|
||||||
|
}
|
||||||
|
|
||||||
cancelAllConditionalOrders(params: {
|
setSwitchMode(params?: {
|
||||||
symbol: string;
|
symbol: string;
|
||||||
}): GenericAPIResponse {
|
tp_sl_mode: string;
|
||||||
return this.requestWrapper.post('private/linear/stop-order/cancel-all', params);
|
}): GenericAPIResponse {
|
||||||
}
|
return this.requestWrapper.post('private/linear/tpsl/switch-mode', params);
|
||||||
|
}
|
||||||
|
|
||||||
replaceConditionalOrder(params: {
|
setAddReduceMargin(params?: {
|
||||||
stop_order_id?: string;
|
symbol: string;
|
||||||
order_link_id?: string;
|
side: string;
|
||||||
symbol: string;
|
margin: number;
|
||||||
p_r_qty?: number;
|
}): GenericAPIResponse {
|
||||||
p_r_price?: number;
|
return this.requestWrapper.post('private/linear/position/add-margin', params);
|
||||||
p_r_trigger_price?: number;
|
}
|
||||||
take_profit?: number;
|
|
||||||
stop_loss?: number;
|
|
||||||
tp_trigger_by?: string;
|
|
||||||
sl_trigger_by?: string;
|
|
||||||
}): GenericAPIResponse {
|
|
||||||
return this.requestWrapper.post('private/linear/stop-order/replace', params);
|
|
||||||
}
|
|
||||||
|
|
||||||
queryConditionalOrder(params: {
|
setUserLeverage(params: {
|
||||||
symbol: string;
|
symbol: string;
|
||||||
stop_order_id?: string;
|
buy_leverage: number;
|
||||||
order_link_id?: string;
|
sell_leverage: number;
|
||||||
}): GenericAPIResponse {
|
}): GenericAPIResponse {
|
||||||
return this.requestWrapper.get('private/linear/stop-order/search', params);
|
return this.requestWrapper.post('private/linear/position/set-leverage', params);
|
||||||
}
|
}
|
||||||
|
|
||||||
//Position
|
setTradingStop(params: {
|
||||||
|
symbol: string;
|
||||||
|
side: string;
|
||||||
|
take_profit?: number;
|
||||||
|
stop_loss?: number;
|
||||||
|
trailing_stop?: number;
|
||||||
|
tp_trigger_by?: string;
|
||||||
|
sl_trigger_by?: string;
|
||||||
|
sl_size?: number;
|
||||||
|
tp_size?: number;
|
||||||
|
}): GenericAPIResponse {
|
||||||
|
return this.requestWrapper.post('private/linear/position/trading-stop', params);
|
||||||
|
}
|
||||||
|
|
||||||
getPosition(params?: {
|
getTradeRecords(params: {
|
||||||
symbol?: string;
|
symbol: string;
|
||||||
}): GenericAPIResponse {
|
start_time?: number;
|
||||||
return this.requestWrapper.get('private/linear/position/list', params);
|
end_time?: number;
|
||||||
}
|
exec_type?: string;
|
||||||
|
page?: number;
|
||||||
|
limit?: number;
|
||||||
|
}): GenericAPIResponse {
|
||||||
|
return this.requestWrapper.get('private/linear/trade/execution/list', params);
|
||||||
|
}
|
||||||
|
|
||||||
setAutoAddMargin(params?: {
|
getClosedPnl(params: {
|
||||||
symbol: string;
|
symbol: string;
|
||||||
side: string;
|
start_time?: number;
|
||||||
auto_add_margin: boolean;
|
end_time?: number;
|
||||||
}): GenericAPIResponse {
|
exec_type?: string;
|
||||||
return this.requestWrapper.post('private/linear/position/set-auto-add-margin', params);
|
page?: number;
|
||||||
}
|
limit?: number;
|
||||||
|
}): GenericAPIResponse {
|
||||||
|
return this.requestWrapper.get('private/linear/tpsl/switch-mode', params);
|
||||||
|
}
|
||||||
|
|
||||||
setMarginSwitch(params?: {
|
/**
|
||||||
symbol: string;
|
* Risk Limit
|
||||||
is_isolated: boolean;
|
*/
|
||||||
buy_leverage: number;
|
|
||||||
sell_leverage: number;
|
|
||||||
}): GenericAPIResponse {
|
|
||||||
return this.requestWrapper.post('private/linear/position/switch-isolated', params);
|
|
||||||
}
|
|
||||||
|
|
||||||
setSwitchMode(params?: {
|
getRiskLimitList(params: {
|
||||||
symbol: string;
|
symbol: string;
|
||||||
tp_sl_mode: string;
|
}): GenericAPIResponse {
|
||||||
}): GenericAPIResponse {
|
return this.requestWrapper.get('public/linear/risk-limit');
|
||||||
return this.requestWrapper.post('private/linear/tpsl/switch-mode', params);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
setAddReduceMargin(params?: {
|
/**
|
||||||
symbol: string;
|
* Funding
|
||||||
side: string;
|
*/
|
||||||
margin: number;
|
|
||||||
}): GenericAPIResponse {
|
|
||||||
return this.requestWrapper.post('private/linear/position/add-margin', params);
|
|
||||||
}
|
|
||||||
|
|
||||||
setUserLeverage(params: {
|
getPredictedFundingFee(params: {
|
||||||
symbol: string;
|
symbol: string;
|
||||||
buy_leverage: number;
|
}): GenericAPIResponse {
|
||||||
sell_leverage: number;
|
return this.requestWrapper.get('private/linear/funding/predicted-funding');
|
||||||
}): GenericAPIResponse {
|
}
|
||||||
return this.requestWrapper.post('private/linear/position/set-leverage', params);
|
|
||||||
}
|
|
||||||
|
|
||||||
setTradingStop(params: {
|
getLastFundingFee(params: {
|
||||||
symbol: string;
|
symbol: string;
|
||||||
side: string;
|
}): GenericAPIResponse {
|
||||||
take_profit?: number;
|
return this.requestWrapper.get('private/linear/funding/prev-funding');
|
||||||
stop_loss?: number;
|
}
|
||||||
trailing_stop?: number;
|
|
||||||
tp_trigger_by?: string;
|
|
||||||
sl_trigger_by?: string;
|
|
||||||
sl_size?: number;
|
|
||||||
tp_size?: number;
|
|
||||||
}): GenericAPIResponse {
|
|
||||||
return this.requestWrapper.post('private/linear/position/trading-stop', params);
|
|
||||||
}
|
|
||||||
|
|
||||||
getTradeRecords(params: {
|
|
||||||
symbol: string;
|
|
||||||
start_time?: number;
|
|
||||||
end_time?: number;
|
|
||||||
exec_type?: string;
|
|
||||||
page?: number;
|
|
||||||
limit?: number;
|
|
||||||
}): GenericAPIResponse {
|
|
||||||
return this.requestWrapper.get('private/linear/trade/execution/list', params);
|
|
||||||
}
|
|
||||||
|
|
||||||
getClosedPnl(params: {
|
|
||||||
symbol: string;
|
|
||||||
start_time?: number;
|
|
||||||
end_time?: number;
|
|
||||||
exec_type?: string;
|
|
||||||
page?: number;
|
|
||||||
limit?: number;
|
|
||||||
}): GenericAPIResponse {
|
|
||||||
return this.requestWrapper.get('private/linear/tpsl/switch-mode', params);
|
|
||||||
}
|
|
||||||
|
|
||||||
//Risk Limit
|
|
||||||
|
|
||||||
getRiskLimitList(params: {
|
|
||||||
symbol: string;
|
|
||||||
}): GenericAPIResponse {
|
|
||||||
return this.requestWrapper.get('public/linear/risk-limit');
|
|
||||||
}
|
|
||||||
|
|
||||||
//Funding
|
|
||||||
|
|
||||||
getPredictedFundingFee(params: {
|
|
||||||
symbol: string;
|
|
||||||
}): GenericAPIResponse {
|
|
||||||
return this.requestWrapper.get('private/linear/funding/predicted-funding');
|
|
||||||
}
|
|
||||||
|
|
||||||
getLastFundingFee(params: {
|
|
||||||
symbol: string;
|
|
||||||
}): GenericAPIResponse {
|
|
||||||
return this.requestWrapper.get('private/linear/funding/prev-funding');
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,7 +5,11 @@ export default class SharedEndpoints {
|
|||||||
// TODO: Is there a way to say that Base has to provide this?
|
// TODO: Is there a way to say that Base has to provide this?
|
||||||
protected requestWrapper: RequestWrapper;
|
protected requestWrapper: RequestWrapper;
|
||||||
|
|
||||||
//------------Market Data Endpoints------------>
|
/**
|
||||||
|
*
|
||||||
|
* Market Data Endpoints
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
getOrderBook(params: {
|
getOrderBook(params: {
|
||||||
symbol: string;
|
symbol: string;
|
||||||
@@ -56,13 +60,21 @@ export default class SharedEndpoints {
|
|||||||
return this.requestWrapper.get('v2/public/account-ratio', params);
|
return this.requestWrapper.get('v2/public/account-ratio', params);
|
||||||
}
|
}
|
||||||
|
|
||||||
//------------Account Data Endpoints------------>
|
/**
|
||||||
|
*
|
||||||
|
* Account Data Endpoints
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
getApiKeyInfo(): GenericAPIResponse {
|
getApiKeyInfo(): GenericAPIResponse {
|
||||||
return this.requestWrapper.get('v2/private/account/api-key');
|
return this.requestWrapper.get('v2/private/account/api-key');
|
||||||
}
|
}
|
||||||
|
|
||||||
//------------Wallet Data Endpoints------------>
|
/**
|
||||||
|
*
|
||||||
|
* Wallet Data Endpoints
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
getWalletBalance(params: {
|
getWalletBalance(params: {
|
||||||
coin?: string;
|
coin?: string;
|
||||||
@@ -101,7 +113,11 @@ export default class SharedEndpoints {
|
|||||||
return this.requestWrapper.get('v2/private/wallet/withdraw/list', params);
|
return this.requestWrapper.get('v2/private/wallet/withdraw/list', params);
|
||||||
}
|
}
|
||||||
|
|
||||||
//-------------API Data Endpoints------------->
|
/**
|
||||||
|
*
|
||||||
|
* API Data Endpoints
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
getServerTime(): GenericAPIResponse {
|
getServerTime(): GenericAPIResponse {
|
||||||
return this.requestWrapper.get('v2/public/time');
|
return this.requestWrapper.get('v2/public/time');
|
||||||
@@ -111,11 +127,11 @@ export default class SharedEndpoints {
|
|||||||
return this.requestWrapper.get('v2/public/announcement');
|
return this.requestWrapper.get('v2/public/announcement');
|
||||||
}
|
}
|
||||||
|
|
||||||
async getTimeOffset(): Promise < number > {
|
async getTimeOffset(): Promise<number> {
|
||||||
const start = Date.now();
|
const start = Date.now();
|
||||||
return this.getServerTime().then(result => {
|
return this.getServerTime().then(result => {
|
||||||
const end = Date.now();
|
const end = Date.now();
|
||||||
return Math.ceil((result.time_now * 1000) - end + ((end - start) / 2));
|
return Math.ceil((result.time_now * 1000) - end + ((end - start) / 2));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user