Indenting

This commit is contained in:
peepopoggers
2021-01-29 14:51:30 +00:00
parent 3269e457c9
commit 73f567c809

View File

@@ -4,9 +4,9 @@ import RequestWrapper from './util/requestWrapper';
import SharedEndpoints from './shared-endpoints';
export class LinearClient extends SharedEndpoints {
protected requestWrapper: RequestWrapper;
protected requestWrapper: RequestWrapper;
/**
/**
* @public Creates an instance of the inverse REST API client.
*
* @param {string} key - your API key
@@ -16,334 +16,334 @@ export class LinearClient extends SharedEndpoints {
* @param {AxiosRequestConfig} [requestOptions={}] HTTP networking options for axios
*/
constructor(
key?: string | undefined,
secret?: string | undefined,
livenet?: boolean,
restInverseOptions:RestClientInverseOptions = {}, // TODO: Rename this type to be more general.
requestOptions: AxiosRequestConfig = {}
) {
super()
this.requestWrapper = new RequestWrapper(
key,
secret,
getBaseRESTInverseUrl(livenet),
restInverseOptions,
requestOptions
);
return this;
}
constructor(
key?: string | undefined,
secret?: string | undefined,
livenet?: boolean,
restInverseOptions:RestClientInverseOptions = {}, // TODO: Rename this type to be more general.
requestOptions: AxiosRequestConfig = {}
) {
super()
this.requestWrapper = new RequestWrapper(
key,
secret,
getBaseRESTInverseUrl(livenet),
restInverseOptions,
requestOptions
);
return this;
}
//------------Market Data Endpoints------------>
//------------Market Data Endpoints------------>
getKline(params: {
symbol: string;
interval: string;
from: number;
limit?: number;
}): GenericAPIResponse {
return this.requestWrapper.get('/public/linear/kline', params);
}
getKline(params: {
symbol: string;
interval: string;
from: number;
limit?: number;
}): GenericAPIResponse {
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);
}
/**
* @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);
}
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);
}
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);
}
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);
}
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);
}
getPremiumIndexKline(params: {
symbol: string;
interval: string;
from: number;
limit?: number;
}): GenericAPIResponse {
return this.requestWrapper.get('public/linear/premium-index-kline', params);
}
//-----------Account Data Endpoints------------>
//-----------Account Data Endpoints------------>
//Active Orders
//Active Orders
placeActiveOrder(orderRequest: {
side: string;
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', orderRequest);
}
placeActiveOrder(orderRequest: {
side: string;
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', orderRequest);
}
getActiveOrderList(params: {
order_id?: string;
order_link_id?: string;
symbol: string;
order?: string;
page?: number;
limit?: number;
order_status?: string;
getActiveOrderList(params: {
order_id?: string;
order_link_id?: string;
symbol: string;
order?: string;
page?: number;
limit?: number;
order_status?: string;
}): GenericAPIResponse {
return this.requestWrapper.get('private/linear/order/list', params);
}
}): GenericAPIResponse {
return this.requestWrapper.get('private/linear/order/list', params);
}
cancelActiveOrder(params: {
symbol: string;
order_id?: string;
order_link_id?: string;
}): GenericAPIResponse {
return this.requestWrapper.post('private/linear/order/cancel', params);
}
cancelActiveOrder(params: {
symbol: string;
order_id?: string;
order_link_id?: string;
}): GenericAPIResponse {
return this.requestWrapper.post('private/linear/order/cancel', params);
}
cancelAllActiveOrders(params: {
symbol: string;
}): GenericAPIResponse {
return this.requestWrapper.post('private/linear/order/cancel-all', params);
}
cancelAllActiveOrders(params: {
symbol: string;
}): GenericAPIResponse {
return this.requestWrapper.post('private/linear/order/cancel-all', params);
}
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);
}
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);
}
queryActiveOrder(params: {
order_id?: string;
order_link_id?: string;
symbol: string;
}): GenericAPIResponse {
return this.requestWrapper.get('private/linear/order/search', params);
}
queryActiveOrder(params: {
order_id?: string;
order_link_id?: string;
symbol: string;
}): GenericAPIResponse {
return this.requestWrapper.get('private/linear/order/search', params);
}
//Conditional Orders
//Conditional Orders
placeConditionalOrder(params: {
side: string;
symbol: string;
order_type: string;
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);
}
placeConditionalOrder(params: {
side: string;
symbol: string;
order_type: string;
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: {
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);
}
getConditionalOrder(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);
}
cancelConditionalOrder(params: {
symbol: string;
stop_order_id?: string;
order_link_id?: string;
}): GenericAPIResponse {
return this.requestWrapper.post('private/linear/stop-order/cancel', params);
}
cancelConditionalOrder(params: {
symbol: string;
stop_order_id?: string;
order_link_id?: string;
}): GenericAPIResponse {
return this.requestWrapper.post('private/linear/stop-order/cancel', params);
}
cancelAllConditionalOrders(params: {
symbol: string;
}): GenericAPIResponse {
return this.requestWrapper.post('private/linear/stop-order/cancel-all', params);
}
cancelAllConditionalOrders(params: {
symbol: string;
}): GenericAPIResponse {
return this.requestWrapper.post('private/linear/stop-order/cancel-all', params);
}
replaceConditionalOrder(params: {
stop_order_id?: string;
order_link_id?: string;
symbol: string;
p_r_qty?: number;
p_r_price?: number;
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);
}
replaceConditionalOrder(params: {
stop_order_id?: string;
order_link_id?: string;
symbol: string;
p_r_qty?: number;
p_r_price?: number;
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: {
symbol: string;
stop_order_id?: string;
order_link_id?: string;
}): GenericAPIResponse {
return this.requestWrapper.get('private/linear/stop-order/search', params);
}
queryConditionalOrder(params: {
symbol: string;
stop_order_id?: string;
order_link_id?: string;
}): GenericAPIResponse {
return this.requestWrapper.get('private/linear/stop-order/search', params);
}
//Position
//Position
getPosition(params?: {
symbol?: string;
}): GenericAPIResponse {
return this.requestWrapper.get('private/linear/position/list', params);
}
getPosition(params?: {
symbol?: string;
}): GenericAPIResponse {
return this.requestWrapper.get('private/linear/position/list', params);
}
setAutoAddMargin(params?: {
symbol: string;
side: string;
auto_add_margin: boolean;
}): GenericAPIResponse {
return this.requestWrapper.post('private/linear/position/set-auto-add-margin', params);
}
setAutoAddMargin(params?: {
symbol: string;
side: string;
auto_add_margin: boolean;
}): GenericAPIResponse {
return this.requestWrapper.post('private/linear/position/set-auto-add-margin', params);
}
setMarginSwitch(params?: {
symbol: string;
is_isolated: boolean;
buy_leverage: number;
sell_leverage: number;
}): GenericAPIResponse {
return this.requestWrapper.post('private/linear/position/switch-isolated', params);
}
setMarginSwitch(params?: {
symbol: string;
is_isolated: boolean;
buy_leverage: number;
sell_leverage: number;
}): GenericAPIResponse {
return this.requestWrapper.post('private/linear/position/switch-isolated', params);
}
setSwitchMode(params?: {
symbol: string;
tp_sl_mode: string;
}): GenericAPIResponse {
return this.requestWrapper.post('private/linear/tpsl/switch-mode', params);
}
setSwitchMode(params?: {
symbol: string;
tp_sl_mode: string;
}): GenericAPIResponse {
return this.requestWrapper.post('private/linear/tpsl/switch-mode', params);
}
setAddReduceMargin(params?: {
symbol: string;
side: string;
margin: number;
}): GenericAPIResponse {
return this.requestWrapper.post('private/linear/position/add-margin', params);
}
setAddReduceMargin(params?: {
symbol: string;
side: string;
margin: number;
}): GenericAPIResponse {
return this.requestWrapper.post('private/linear/position/add-margin', params);
}
setUserLeverage(params: {
symbol: string;
buy_leverage: number;
sell_leverage: number;
}): GenericAPIResponse {
return this.requestWrapper.post('private/linear/position/set-leverage', params);
}
setUserLeverage(params: {
symbol: string;
buy_leverage: number;
sell_leverage: number;
}): GenericAPIResponse {
return this.requestWrapper.post('private/linear/position/set-leverage', params);
}
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);
}
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);
}
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);
}
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);
}
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
//Risk Limit
getRiskLimitList(params: {
symbol: string;
}): GenericAPIResponse {
return this.requestWrapper.get('public/linear/risk-limit');
}
getRiskLimitList(params: {
symbol: string;
}): GenericAPIResponse {
return this.requestWrapper.get('public/linear/risk-limit');
}
//Funding
//Funding
getPredictedFundingFee(params: {
symbol: string;
}): GenericAPIResponse {
return this.requestWrapper.get('private/linear/funding/predicted-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');
}
getLastFundingFee(params: {
symbol: string;
}): GenericAPIResponse {
return this.requestWrapper.get('private/linear/funding/prev-funding');
}
}