Indenting
This commit is contained in:
@@ -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,334 @@ 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
|
* @deprecated use getTrades() instead
|
||||||
*/
|
*/
|
||||||
getPublicTradingRecords(params: {
|
getPublicTradingRecords(params: {
|
||||||
symbol: string;
|
symbol: string;
|
||||||
from?: number;
|
from?: number;
|
||||||
limit?: number;
|
limit?: number;
|
||||||
}): GenericAPIResponse {
|
}): GenericAPIResponse {
|
||||||
return this.getTrades(params);
|
return this.getTrades(params);
|
||||||
}
|
}
|
||||||
|
|
||||||
getTrades(params: {
|
getTrades(params: {
|
||||||
symbol: string;
|
symbol: string;
|
||||||
//from?: number;
|
//from?: number;
|
||||||
limit?: number;
|
limit?: number;
|
||||||
}): GenericAPIResponse {
|
}): GenericAPIResponse {
|
||||||
return this.requestWrapper.get('public/linear/recent-trading-records', params);
|
return this.requestWrapper.get('public/linear/recent-trading-records', params);
|
||||||
}
|
}
|
||||||
|
|
||||||
getLastFundingRate(params: {
|
getLastFundingRate(params: {
|
||||||
symbol: string;
|
symbol: string;
|
||||||
}): GenericAPIResponse {
|
}): GenericAPIResponse {
|
||||||
return this.requestWrapper.get('public/linear/funding/prev-funding-rate', params);
|
return this.requestWrapper.get('public/linear/funding/prev-funding-rate', params);
|
||||||
}
|
}
|
||||||
|
|
||||||
getMarkPriceKline(params: {
|
getMarkPriceKline(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/mark-price-kline', params);
|
return this.requestWrapper.get('public/linear/mark-price-kline', params);
|
||||||
}
|
}
|
||||||
|
|
||||||
getIndexPriceKline(params: {
|
getIndexPriceKline(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/index-price-kline', params);
|
return this.requestWrapper.get('public/linear/index-price-kline', params);
|
||||||
}
|
}
|
||||||
|
|
||||||
getPremiumIndexKline(params: {
|
getPremiumIndexKline(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/premium-index-kline', params);
|
return this.requestWrapper.get('public/linear/premium-index-kline', params);
|
||||||
}
|
}
|
||||||
|
|
||||||
//-----------Account Data Endpoints------------>
|
//-----------Account Data Endpoints------------>
|
||||||
|
|
||||||
//Active Orders
|
//Active Orders
|
||||||
|
|
||||||
placeActiveOrder(orderRequest: {
|
placeActiveOrder(orderRequest: {
|
||||||
side: string;
|
side: string;
|
||||||
symbol: string;
|
symbol: string;
|
||||||
order_type: string;
|
order_type: string;
|
||||||
qty: number;
|
qty: number;
|
||||||
price?: number;
|
price?: number;
|
||||||
time_in_force: string;
|
time_in_force: string;
|
||||||
take_profit?: number;
|
take_profit?: number;
|
||||||
stop_loss?: number;
|
stop_loss?: number;
|
||||||
tp_trigger_by?: string;
|
tp_trigger_by?: string;
|
||||||
sl_trigger_by?: string;
|
sl_trigger_by?: string;
|
||||||
reduce_only?: boolean;
|
reduce_only?: boolean;
|
||||||
close_on_trigger?: boolean;
|
close_on_trigger?: boolean;
|
||||||
order_link_id?: string;
|
order_link_id?: string;
|
||||||
}): GenericAPIResponse {
|
}): GenericAPIResponse {
|
||||||
return this.requestWrapper.post('private/linear/order/create', orderRequest);
|
return this.requestWrapper.post('private/linear/order/create', orderRequest);
|
||||||
}
|
}
|
||||||
|
|
||||||
getActiveOrderList(params: {
|
getActiveOrderList(params: {
|
||||||
order_id?: string;
|
order_id?: string;
|
||||||
order_link_id?: string;
|
order_link_id?: string;
|
||||||
symbol: string;
|
symbol: string;
|
||||||
order?: string;
|
order?: string;
|
||||||
page?: number;
|
page?: number;
|
||||||
limit?: number;
|
limit?: number;
|
||||||
order_status?: string;
|
order_status?: string;
|
||||||
|
|
||||||
}): GenericAPIResponse {
|
}): GenericAPIResponse {
|
||||||
return this.requestWrapper.get('private/linear/order/list', params);
|
return this.requestWrapper.get('private/linear/order/list', params);
|
||||||
}
|
}
|
||||||
|
|
||||||
cancelActiveOrder(params: {
|
cancelActiveOrder(params: {
|
||||||
symbol: string;
|
symbol: string;
|
||||||
order_id?: string;
|
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/order/cancel', params);
|
||||||
}
|
}
|
||||||
|
|
||||||
cancelAllActiveOrders(params: {
|
cancelAllActiveOrders(params: {
|
||||||
symbol: string;
|
symbol: string;
|
||||||
}): GenericAPIResponse {
|
}): GenericAPIResponse {
|
||||||
return this.requestWrapper.post('private/linear/order/cancel-all', params);
|
return this.requestWrapper.post('private/linear/order/cancel-all', params);
|
||||||
}
|
}
|
||||||
|
|
||||||
replaceActiveOrder(params: {
|
replaceActiveOrder(params: {
|
||||||
order_id?: string;
|
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;
|
take_profit?: number;
|
||||||
stop_loss?: number;
|
stop_loss?: number;
|
||||||
tp_trigger_by?: string;
|
tp_trigger_by?: string;
|
||||||
sl_trigger_by?: string;
|
sl_trigger_by?: string;
|
||||||
}): GenericAPIResponse {
|
}): GenericAPIResponse {
|
||||||
return this.requestWrapper.post('private/linear/order/replace', params);
|
return this.requestWrapper.post('private/linear/order/replace', params);
|
||||||
}
|
}
|
||||||
|
|
||||||
queryActiveOrder(params: {
|
queryActiveOrder(params: {
|
||||||
order_id?: string;
|
order_id?: string;
|
||||||
order_link_id?: string;
|
order_link_id?: string;
|
||||||
symbol: string;
|
symbol: string;
|
||||||
}): GenericAPIResponse {
|
}): GenericAPIResponse {
|
||||||
return this.requestWrapper.get('private/linear/order/search', params);
|
return this.requestWrapper.get('private/linear/order/search', params);
|
||||||
}
|
}
|
||||||
|
|
||||||
//Conditional Orders
|
//Conditional Orders
|
||||||
|
|
||||||
placeConditionalOrder(params: {
|
placeConditionalOrder(params: {
|
||||||
side: string;
|
side: string;
|
||||||
symbol: string;
|
symbol: string;
|
||||||
order_type: string;
|
order_type: string;
|
||||||
qty: number;
|
qty: number;
|
||||||
price?: number;
|
price?: number;
|
||||||
base_price: number;
|
base_price: number;
|
||||||
stop_px: number;
|
stop_px: number;
|
||||||
time_in_force: string;
|
time_in_force: string;
|
||||||
trigger_by?: string;
|
trigger_by?: string;
|
||||||
close_on_trigger?: boolean;
|
close_on_trigger?: boolean;
|
||||||
order_link_id?: string;
|
order_link_id?: string;
|
||||||
reduce_only: boolean;
|
reduce_only: boolean;
|
||||||
take_profit?: number;
|
take_profit?: number;
|
||||||
stop_loss?: number;
|
stop_loss?: number;
|
||||||
tp_trigger_by?: string;
|
tp_trigger_by?: string;
|
||||||
sl_trigger_by?: string;
|
sl_trigger_by?: string;
|
||||||
}): GenericAPIResponse {
|
}): GenericAPIResponse {
|
||||||
return this.requestWrapper.post('private/linear/stop-order/create', params);
|
return this.requestWrapper.post('private/linear/stop-order/create', params);
|
||||||
}
|
}
|
||||||
|
|
||||||
getConditionalOrder(params: {
|
getConditionalOrder(params: {
|
||||||
stop_order_id?: string;
|
stop_order_id?: string;
|
||||||
order_link_id?: string;
|
order_link_id?: string;
|
||||||
symbol: string;
|
symbol: string;
|
||||||
stop_order_status?: string;
|
stop_order_status?: string;
|
||||||
order?: string;
|
order?: string;
|
||||||
page?: number;
|
page?: number;
|
||||||
limit?: number;
|
limit?: number;
|
||||||
}): GenericAPIResponse {
|
}): GenericAPIResponse {
|
||||||
return this.requestWrapper.get('private/linear/stop-order/list', params);
|
return this.requestWrapper.get('private/linear/stop-order/list', params);
|
||||||
}
|
}
|
||||||
|
|
||||||
cancelConditionalOrder(params: {
|
cancelConditionalOrder(params: {
|
||||||
symbol: string;
|
symbol: string;
|
||||||
stop_order_id?: string;
|
stop_order_id?: string;
|
||||||
order_link_id?: string;
|
order_link_id?: string;
|
||||||
}): GenericAPIResponse {
|
}): GenericAPIResponse {
|
||||||
return this.requestWrapper.post('private/linear/stop-order/cancel', params);
|
return this.requestWrapper.post('private/linear/stop-order/cancel', params);
|
||||||
}
|
}
|
||||||
|
|
||||||
cancelAllConditionalOrders(params: {
|
cancelAllConditionalOrders(params: {
|
||||||
symbol: string;
|
symbol: string;
|
||||||
}): GenericAPIResponse {
|
}): GenericAPIResponse {
|
||||||
return this.requestWrapper.post('private/linear/stop-order/cancel-all', params);
|
return this.requestWrapper.post('private/linear/stop-order/cancel-all', params);
|
||||||
}
|
}
|
||||||
|
|
||||||
replaceConditionalOrder(params: {
|
replaceConditionalOrder(params: {
|
||||||
stop_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;
|
||||||
p_r_trigger_price?: number;
|
p_r_trigger_price?: number;
|
||||||
take_profit?: number;
|
take_profit?: number;
|
||||||
stop_loss?: number;
|
stop_loss?: number;
|
||||||
tp_trigger_by?: string;
|
tp_trigger_by?: string;
|
||||||
sl_trigger_by?: string;
|
sl_trigger_by?: string;
|
||||||
}): GenericAPIResponse {
|
}): GenericAPIResponse {
|
||||||
return this.requestWrapper.post('private/linear/stop-order/replace', params);
|
return this.requestWrapper.post('private/linear/stop-order/replace', params);
|
||||||
}
|
}
|
||||||
|
|
||||||
queryConditionalOrder(params: {
|
queryConditionalOrder(params: {
|
||||||
symbol: string;
|
symbol: string;
|
||||||
stop_order_id?: string;
|
stop_order_id?: string;
|
||||||
order_link_id?: string;
|
order_link_id?: string;
|
||||||
}): GenericAPIResponse {
|
}): GenericAPIResponse {
|
||||||
return this.requestWrapper.get('private/linear/stop-order/search', params);
|
return this.requestWrapper.get('private/linear/stop-order/search', params);
|
||||||
}
|
}
|
||||||
|
|
||||||
//Position
|
//Position
|
||||||
|
|
||||||
getPosition(params?: {
|
getPosition(params?: {
|
||||||
symbol?: string;
|
symbol?: string;
|
||||||
}): GenericAPIResponse {
|
}): GenericAPIResponse {
|
||||||
return this.requestWrapper.get('private/linear/position/list', params);
|
return this.requestWrapper.get('private/linear/position/list', params);
|
||||||
}
|
}
|
||||||
|
|
||||||
setAutoAddMargin(params?: {
|
setAutoAddMargin(params?: {
|
||||||
symbol: string;
|
symbol: string;
|
||||||
side: string;
|
side: string;
|
||||||
auto_add_margin: boolean;
|
auto_add_margin: boolean;
|
||||||
}): GenericAPIResponse {
|
}): GenericAPIResponse {
|
||||||
return this.requestWrapper.post('private/linear/position/set-auto-add-margin', params);
|
return this.requestWrapper.post('private/linear/position/set-auto-add-margin', params);
|
||||||
}
|
}
|
||||||
|
|
||||||
setMarginSwitch(params?: {
|
setMarginSwitch(params?: {
|
||||||
symbol: string;
|
symbol: string;
|
||||||
is_isolated: boolean;
|
is_isolated: boolean;
|
||||||
buy_leverage: number;
|
buy_leverage: number;
|
||||||
sell_leverage: number;
|
sell_leverage: number;
|
||||||
}): GenericAPIResponse {
|
}): GenericAPIResponse {
|
||||||
return this.requestWrapper.post('private/linear/position/switch-isolated', params);
|
return this.requestWrapper.post('private/linear/position/switch-isolated', params);
|
||||||
}
|
}
|
||||||
|
|
||||||
setSwitchMode(params?: {
|
setSwitchMode(params?: {
|
||||||
symbol: string;
|
symbol: string;
|
||||||
tp_sl_mode: string;
|
tp_sl_mode: string;
|
||||||
}): GenericAPIResponse {
|
}): GenericAPIResponse {
|
||||||
return this.requestWrapper.post('private/linear/tpsl/switch-mode', params);
|
return this.requestWrapper.post('private/linear/tpsl/switch-mode', params);
|
||||||
}
|
}
|
||||||
|
|
||||||
setAddReduceMargin(params?: {
|
setAddReduceMargin(params?: {
|
||||||
symbol: string;
|
symbol: string;
|
||||||
side: string;
|
side: string;
|
||||||
margin: number;
|
margin: number;
|
||||||
}): GenericAPIResponse {
|
}): GenericAPIResponse {
|
||||||
return this.requestWrapper.post('private/linear/position/add-margin', params);
|
return this.requestWrapper.post('private/linear/position/add-margin', params);
|
||||||
}
|
}
|
||||||
|
|
||||||
setUserLeverage(params: {
|
setUserLeverage(params: {
|
||||||
symbol: string;
|
symbol: string;
|
||||||
buy_leverage: number;
|
buy_leverage: number;
|
||||||
sell_leverage: number;
|
sell_leverage: number;
|
||||||
}): GenericAPIResponse {
|
}): GenericAPIResponse {
|
||||||
return this.requestWrapper.post('private/linear/position/set-leverage', params);
|
return this.requestWrapper.post('private/linear/position/set-leverage', params);
|
||||||
}
|
}
|
||||||
|
|
||||||
setTradingStop(params: {
|
setTradingStop(params: {
|
||||||
symbol: string;
|
symbol: string;
|
||||||
side: string;
|
side: string;
|
||||||
take_profit?: number;
|
take_profit?: number;
|
||||||
stop_loss?: number;
|
stop_loss?: number;
|
||||||
trailing_stop?: number;
|
trailing_stop?: number;
|
||||||
tp_trigger_by?: string;
|
tp_trigger_by?: string;
|
||||||
sl_trigger_by?: string;
|
sl_trigger_by?: string;
|
||||||
sl_size?: number;
|
sl_size?: number;
|
||||||
tp_size?: number;
|
tp_size?: number;
|
||||||
}): GenericAPIResponse {
|
}): GenericAPIResponse {
|
||||||
return this.requestWrapper.post('private/linear/position/trading-stop', params);
|
return this.requestWrapper.post('private/linear/position/trading-stop', params);
|
||||||
}
|
}
|
||||||
|
|
||||||
getTradeRecords(params: {
|
getTradeRecords(params: {
|
||||||
symbol: string;
|
symbol: string;
|
||||||
start_time?: number;
|
start_time?: number;
|
||||||
end_time?: number;
|
end_time?: number;
|
||||||
exec_type?: string;
|
exec_type?: string;
|
||||||
page?: number;
|
page?: number;
|
||||||
limit?: number;
|
limit?: number;
|
||||||
}): GenericAPIResponse {
|
}): GenericAPIResponse {
|
||||||
return this.requestWrapper.get('private/linear/trade/execution/list', params);
|
return this.requestWrapper.get('private/linear/trade/execution/list', params);
|
||||||
}
|
}
|
||||||
|
|
||||||
getClosedPnl(params: {
|
getClosedPnl(params: {
|
||||||
symbol: string;
|
symbol: string;
|
||||||
start_time?: number;
|
start_time?: number;
|
||||||
end_time?: number;
|
end_time?: number;
|
||||||
exec_type?: string;
|
exec_type?: string;
|
||||||
page?: number;
|
page?: number;
|
||||||
limit?: number;
|
limit?: number;
|
||||||
}): GenericAPIResponse {
|
}): GenericAPIResponse {
|
||||||
return this.requestWrapper.get('private/linear/tpsl/switch-mode', params);
|
return this.requestWrapper.get('private/linear/tpsl/switch-mode', params);
|
||||||
}
|
}
|
||||||
|
|
||||||
//Risk Limit
|
//Risk Limit
|
||||||
|
|
||||||
getRiskLimitList(params: {
|
getRiskLimitList(params: {
|
||||||
symbol: string;
|
symbol: string;
|
||||||
}): GenericAPIResponse {
|
}): GenericAPIResponse {
|
||||||
return this.requestWrapper.get('public/linear/risk-limit');
|
return this.requestWrapper.get('public/linear/risk-limit');
|
||||||
}
|
}
|
||||||
|
|
||||||
//Funding
|
//Funding
|
||||||
|
|
||||||
getPredictedFundingFee(params: {
|
getPredictedFundingFee(params: {
|
||||||
symbol: string;
|
symbol: string;
|
||||||
}): GenericAPIResponse {
|
}): GenericAPIResponse {
|
||||||
return this.requestWrapper.get('private/linear/funding/predicted-funding');
|
return this.requestWrapper.get('private/linear/funding/predicted-funding');
|
||||||
}
|
}
|
||||||
|
|
||||||
getLastFundingFee(params: {
|
getLastFundingFee(params: {
|
||||||
symbol: string;
|
symbol: string;
|
||||||
}): GenericAPIResponse {
|
}): GenericAPIResponse {
|
||||||
return this.requestWrapper.get('private/linear/funding/prev-funding');
|
return this.requestWrapper.get('private/linear/funding/prev-funding');
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user