USDC request param typings
This commit is contained in:
@@ -1,3 +1,5 @@
|
|||||||
export * from './account-asset';
|
export * from './account-asset';
|
||||||
export * from './usdt-perp';
|
export * from './usdt-perp';
|
||||||
export * from './usdc-perp';
|
export * from './usdc-perp';
|
||||||
|
export * from './usdc-options';
|
||||||
|
export * from './usdc-shared';
|
||||||
|
|||||||
135
src/types/request/usdc-options.ts
Normal file
135
src/types/request/usdc-options.ts
Normal file
@@ -0,0 +1,135 @@
|
|||||||
|
import { OrderSide } from '../shared';
|
||||||
|
import { USDCOrderFilter } from './usdc-perp';
|
||||||
|
import { USDCAPICategory, USDCOrderType, USDCTimeInForce } from './usdc-shared';
|
||||||
|
|
||||||
|
export interface USDCOptionsContractInfoRequest {
|
||||||
|
symbol?: string;
|
||||||
|
status?: 'WAITING_ONLINE' | 'ONLINE' | 'DELIVERING' | 'OFFLINE';
|
||||||
|
baseCoin?: string;
|
||||||
|
direction?: string;
|
||||||
|
limit?: string;
|
||||||
|
cursor?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface USDCOptionsDeliveryPriceRequest {
|
||||||
|
symbol?: string;
|
||||||
|
baseCoin?: string;
|
||||||
|
direction?: string;
|
||||||
|
limit?: string;
|
||||||
|
cursor?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface USDCOptionsRecentTradesRequest {
|
||||||
|
category: USDCAPICategory;
|
||||||
|
symbol?: string;
|
||||||
|
baseCoin?: string;
|
||||||
|
optionType?: 'Call' | 'Put';
|
||||||
|
limit?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface USDCOptionsHistoricalVolatilityRequest {
|
||||||
|
baseCoin?: string;
|
||||||
|
period?: string;
|
||||||
|
startTime?: string;
|
||||||
|
endTime?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface USDCOptionsOrderRequest {
|
||||||
|
symbol: string;
|
||||||
|
orderType: USDCOrderType;
|
||||||
|
side: OrderSide;
|
||||||
|
orderPrice?: string;
|
||||||
|
orderQty: string;
|
||||||
|
iv?: string;
|
||||||
|
timeInForce?: USDCTimeInForce;
|
||||||
|
orderLinkId?: string;
|
||||||
|
reduceOnly?: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface USDCOptionsModifyOrderRequest {
|
||||||
|
symbol: string;
|
||||||
|
orderId?: string;
|
||||||
|
orderLinkId?: string;
|
||||||
|
orderPrice?: string;
|
||||||
|
orderQty?: string;
|
||||||
|
iv?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface USDCOptionsCancelOrderRequest {
|
||||||
|
symbol: string;
|
||||||
|
orderId?: string;
|
||||||
|
orderLinkId?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface USDCOptionsCancelAllOrdersRequest {
|
||||||
|
symbol?: string;
|
||||||
|
baseCoin?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface USDCOptionsActiveOrdersRealtimeRequest {
|
||||||
|
orderId?: string;
|
||||||
|
orderLinkId?: string;
|
||||||
|
symbol?: string;
|
||||||
|
baseCoin?: string;
|
||||||
|
direction?: string;
|
||||||
|
limit?: number;
|
||||||
|
cursor?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface USDCOptionsActiveOrdersRequest {
|
||||||
|
category: 'OPTION';
|
||||||
|
symbol?: string;
|
||||||
|
baseCoin?: string;
|
||||||
|
orderId?: string;
|
||||||
|
orderLinkId?: string;
|
||||||
|
direction?: string;
|
||||||
|
limit?: number;
|
||||||
|
cursor?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface USDCOptionsHistoricOrdersRequest {
|
||||||
|
category: 'OPTION';
|
||||||
|
symbol?: string;
|
||||||
|
baseCoin?: string;
|
||||||
|
orderId?: string;
|
||||||
|
orderLinkId?: string;
|
||||||
|
orderStatus?: string;
|
||||||
|
direction?: string;
|
||||||
|
limit?: number;
|
||||||
|
cursor?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface USDCOptionsOrderExecutionRequest {
|
||||||
|
category: 'OPTION';
|
||||||
|
symbol?: string;
|
||||||
|
baseCoin?: string;
|
||||||
|
orderId?: string;
|
||||||
|
orderLinkId?: string;
|
||||||
|
startTime?: string;
|
||||||
|
direction?: string;
|
||||||
|
limit?: number;
|
||||||
|
cursor?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface USDCOptionsDeliveryHistoryRequest {
|
||||||
|
symbol: string;
|
||||||
|
expDate?: string;
|
||||||
|
direction?: string;
|
||||||
|
limit?: string;
|
||||||
|
cursor?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface USDCOptionsPositionsInfoExpiryRequest {
|
||||||
|
expDate?: string;
|
||||||
|
direction?: string;
|
||||||
|
limit?: string;
|
||||||
|
cursor?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface USDCOptionsModifyMMPRequest {
|
||||||
|
currency: string;
|
||||||
|
windowMs: number;
|
||||||
|
frozenPeriodMs: number;
|
||||||
|
qtyLimit: string;
|
||||||
|
deltaLimit: string;
|
||||||
|
}
|
||||||
@@ -1,9 +1,5 @@
|
|||||||
export interface USDCKlineRequest {
|
import { OrderSide } from '../shared';
|
||||||
symbol: string;
|
import { USDCAPICategory, USDCOrderType, USDCTimeInForce } from './usdc-shared';
|
||||||
period: string;
|
|
||||||
startTime: number;
|
|
||||||
limit?: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface USDCOpenInterestRequest {
|
export interface USDCOpenInterestRequest {
|
||||||
symbol: string;
|
symbol: string;
|
||||||
@@ -12,8 +8,90 @@ export interface USDCOpenInterestRequest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export interface USDCLast500TradesRequest {
|
export interface USDCLast500TradesRequest {
|
||||||
category: string;
|
category: USDCAPICategory;
|
||||||
symbol?: string;
|
symbol?: string;
|
||||||
baseCoin?: string;
|
baseCoin?: string;
|
||||||
limit?: string;
|
limit?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface USDCSymbolDirectionLimit {
|
||||||
|
symbol?: string;
|
||||||
|
direction?: string;
|
||||||
|
limit?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface USDCSymbolDirectionLimitCursor {
|
||||||
|
symbol?: string;
|
||||||
|
direction?: string;
|
||||||
|
limit?: string;
|
||||||
|
cursor?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export type USDCOrderFilter = 'Order' | 'StopOrder';
|
||||||
|
|
||||||
|
export interface USDCPerpOrderRequest {
|
||||||
|
symbol: string;
|
||||||
|
orderType: USDCOrderType;
|
||||||
|
orderFilter: USDCOrderFilter;
|
||||||
|
side: OrderSide;
|
||||||
|
orderPrice?: string;
|
||||||
|
orderQty: string;
|
||||||
|
timeInForce?: USDCTimeInForce;
|
||||||
|
orderLinkId?: string;
|
||||||
|
reduceOnly?: boolean;
|
||||||
|
closeOnTrigger?: boolean;
|
||||||
|
takeProfit?: string;
|
||||||
|
stopLoss?: string;
|
||||||
|
tptriggerby?: string;
|
||||||
|
slTriggerBy?: string;
|
||||||
|
basePrice?: string;
|
||||||
|
triggerPrice?: string;
|
||||||
|
triggerBy?: string;
|
||||||
|
mmp?: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface USDCPerpModifyOrderRequest {
|
||||||
|
symbol: string;
|
||||||
|
orderFilter: USDCOrderFilter;
|
||||||
|
orderId?: string;
|
||||||
|
orderLinkId?: string;
|
||||||
|
orderPrice?: string;
|
||||||
|
orderQty?: string;
|
||||||
|
takeProfit?: string;
|
||||||
|
stopLoss?: string;
|
||||||
|
tptriggerby?: string;
|
||||||
|
slTriggerBy?: string;
|
||||||
|
triggerPrice?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface USDCPerpCancelOrderRequest {
|
||||||
|
symbol: string;
|
||||||
|
orderFilter: USDCOrderFilter;
|
||||||
|
orderId?: string;
|
||||||
|
orderLinkId?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface USDCPerpActiveOrdersRequest {
|
||||||
|
category: 'PERPETUAL';
|
||||||
|
symbol?: string;
|
||||||
|
baseCoin?: string;
|
||||||
|
orderId?: string;
|
||||||
|
orderLinkId?: string;
|
||||||
|
orderFilter?: USDCOrderFilter;
|
||||||
|
direction?: string;
|
||||||
|
limit?: number;
|
||||||
|
cursor?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface USDCPerpHistoricOrdersRequest {
|
||||||
|
category: 'PERPETUAL';
|
||||||
|
symbol?: string;
|
||||||
|
baseCoin?: string;
|
||||||
|
orderId?: string;
|
||||||
|
orderLinkId?: string;
|
||||||
|
orderStatus?: string;
|
||||||
|
orderFilter?: USDCOrderFilter;
|
||||||
|
direction?: string;
|
||||||
|
limit?: number;
|
||||||
|
cursor?: string;
|
||||||
|
}
|
||||||
|
|||||||
36
src/types/request/usdc-shared.ts
Normal file
36
src/types/request/usdc-shared.ts
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
export type USDCAPICategory = 'PERPETUAL' | 'OPTION';
|
||||||
|
|
||||||
|
export type USDCOrderType = 'Limit' | 'Market';
|
||||||
|
export type USDCTimeInForce =
|
||||||
|
| 'GoodTillCancel'
|
||||||
|
| 'ImmediateOrCancel'
|
||||||
|
| 'FillOrKill'
|
||||||
|
| 'PostOnly';
|
||||||
|
|
||||||
|
export interface USDCKlineRequest {
|
||||||
|
symbol: string;
|
||||||
|
period: string;
|
||||||
|
startTime: number;
|
||||||
|
limit?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface USDCTransactionLogRequest {
|
||||||
|
type: string;
|
||||||
|
baseCoin?: string;
|
||||||
|
startTime?: string;
|
||||||
|
endTime?: string;
|
||||||
|
direction?: string;
|
||||||
|
limit?: string;
|
||||||
|
cursor?: string;
|
||||||
|
category?: USDCAPICategory;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface USDCPositionsRequest {
|
||||||
|
category: USDCAPICategory;
|
||||||
|
symbol?: string;
|
||||||
|
baseCoin?: string;
|
||||||
|
expDate?: string;
|
||||||
|
direction?: string;
|
||||||
|
limit?: string;
|
||||||
|
cursor?: string;
|
||||||
|
}
|
||||||
@@ -1,4 +1,24 @@
|
|||||||
import { APIResponseWithTime } from './types';
|
import {
|
||||||
|
APIResponseWithTime,
|
||||||
|
USDCAPIResponse,
|
||||||
|
USDCOptionsActiveOrdersRealtimeRequest,
|
||||||
|
USDCOptionsActiveOrdersRequest,
|
||||||
|
USDCOptionsCancelAllOrdersRequest,
|
||||||
|
USDCOptionsCancelOrderRequest,
|
||||||
|
USDCOptionsContractInfoRequest,
|
||||||
|
USDCOptionsDeliveryHistoryRequest,
|
||||||
|
USDCOptionsDeliveryPriceRequest,
|
||||||
|
USDCOptionsHistoricalVolatilityRequest,
|
||||||
|
USDCOptionsHistoricOrdersRequest,
|
||||||
|
USDCOptionsModifyMMPRequest,
|
||||||
|
USDCOptionsModifyOrderRequest,
|
||||||
|
USDCOptionsOrderExecutionRequest,
|
||||||
|
USDCOptionsOrderRequest,
|
||||||
|
USDCOptionsPositionsInfoExpiryRequest,
|
||||||
|
USDCOptionsRecentTradesRequest,
|
||||||
|
USDCPositionsRequest,
|
||||||
|
USDCTransactionLogRequest,
|
||||||
|
} from './types';
|
||||||
import { REST_CLIENT_TYPE_ENUM } from './util';
|
import { REST_CLIENT_TYPE_ENUM } from './util';
|
||||||
import BaseRestClient from './util/BaseRestClient';
|
import BaseRestClient from './util/BaseRestClient';
|
||||||
|
|
||||||
@@ -22,27 +42,33 @@ export class USDCOptionsClient extends BaseRestClient {
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/** Query order book info. Each side has a depth of 25 orders. */
|
/** Query order book info. Each side has a depth of 25 orders. */
|
||||||
getOrderBook(symbol: string): Promise<APIResponseWithTime<any>> {
|
getOrderBook(symbol: string): Promise<USDCAPIResponse<any>> {
|
||||||
return this.get('/option/usdc/openapi/public/v1/order-book', { symbol });
|
return this.get('/option/usdc/openapi/public/v1/order-book', { symbol });
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Fetch trading rules (such as min/max qty). Query for all if blank. */
|
/** Fetch trading rules (such as min/max qty). Query for all if blank. */
|
||||||
getContractInfo(params?: unknown): Promise<APIResponseWithTime<any>> {
|
getContractInfo(
|
||||||
|
params?: USDCOptionsContractInfoRequest
|
||||||
|
): Promise<USDCAPIResponse<any>> {
|
||||||
return this.get('/option/usdc/openapi/public/v1/symbols', params);
|
return this.get('/option/usdc/openapi/public/v1/symbols', params);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Get a symbol price/statistics ticker */
|
/** Get a symbol price/statistics ticker */
|
||||||
getSymbolTicker(symbol: string): Promise<APIResponseWithTime<any>> {
|
getSymbolTicker(symbol: string): Promise<USDCAPIResponse<any>> {
|
||||||
return this.get('/option/usdc/openapi/public/v1/tick', { symbol });
|
return this.get('/option/usdc/openapi/public/v1/tick', { symbol });
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Get delivery information */
|
/** Get delivery information */
|
||||||
getDeliveryPrice(params?: unknown): Promise<APIResponseWithTime<any>> {
|
getDeliveryPrice(
|
||||||
|
params?: USDCOptionsDeliveryPriceRequest
|
||||||
|
): Promise<USDCAPIResponse<any>> {
|
||||||
return this.get('/option/usdc/openapi/public/v1/delivery-price', params);
|
return this.get('/option/usdc/openapi/public/v1/delivery-price', params);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Returned records are Taker Buy in default. */
|
/** Returned records are Taker Buy in default. */
|
||||||
getLastTrades(params: unknown): Promise<APIResponseWithTime<any>> {
|
getLast500Trades(
|
||||||
|
params: USDCOptionsRecentTradesRequest
|
||||||
|
): Promise<USDCAPIResponse<any>> {
|
||||||
return this.get(
|
return this.get(
|
||||||
'/option/usdc/openapi/public/v1/query-trade-latest',
|
'/option/usdc/openapi/public/v1/query-trade-latest',
|
||||||
params
|
params
|
||||||
@@ -56,7 +82,9 @@ export class USDCOptionsClient extends BaseRestClient {
|
|||||||
* It returns all data in 2 years when startTime & endTime are not passed.
|
* It returns all data in 2 years when startTime & endTime are not passed.
|
||||||
* Both startTime & endTime entered together or both are left blank
|
* Both startTime & endTime entered together or both are left blank
|
||||||
*/
|
*/
|
||||||
getHistoricalVolatility(params?: unknown): Promise<APIResponseWithTime<any>> {
|
getHistoricalVolatility(
|
||||||
|
params?: USDCOptionsHistoricalVolatilityRequest
|
||||||
|
): Promise<USDCAPIResponse<any>> {
|
||||||
return this.get(
|
return this.get(
|
||||||
'/option/usdc/openapi/public/v1/query-historical-volatility',
|
'/option/usdc/openapi/public/v1/query-historical-volatility',
|
||||||
params
|
params
|
||||||
@@ -76,7 +104,7 @@ export class USDCOptionsClient extends BaseRestClient {
|
|||||||
* The request status can be queried in real-time.
|
* The request status can be queried in real-time.
|
||||||
* The response parameters must be queried through a query or a WebSocket response.
|
* The response parameters must be queried through a query or a WebSocket response.
|
||||||
*/
|
*/
|
||||||
submitOrder(params: unknown): Promise<APIResponseWithTime<any>> {
|
submitOrder(params: USDCOptionsOrderRequest): Promise<USDCAPIResponse<any>> {
|
||||||
return this.postPrivate(
|
return this.postPrivate(
|
||||||
'/option/usdc/openapi/private/v1/place-order',
|
'/option/usdc/openapi/private/v1/place-order',
|
||||||
params
|
params
|
||||||
@@ -87,8 +115,8 @@ export class USDCOptionsClient extends BaseRestClient {
|
|||||||
* Each request supports a max. of four orders. The reduceOnly parameter should be separate and unique for each order in the request.
|
* Each request supports a max. of four orders. The reduceOnly parameter should be separate and unique for each order in the request.
|
||||||
*/
|
*/
|
||||||
batchSubmitOrders(
|
batchSubmitOrders(
|
||||||
orderRequest: unknown[]
|
orderRequest: USDCOptionsOrderRequest[]
|
||||||
): Promise<APIResponseWithTime<any>> {
|
): Promise<USDCAPIResponse<any>> {
|
||||||
return this.postPrivate(
|
return this.postPrivate(
|
||||||
'/option/usdc/openapi/private/v1/batch-place-orders',
|
'/option/usdc/openapi/private/v1/batch-place-orders',
|
||||||
{ orderRequest }
|
{ orderRequest }
|
||||||
@@ -96,7 +124,9 @@ export class USDCOptionsClient extends BaseRestClient {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** For Options, at least one of the three parameters — price, quantity or implied volatility — must be input. */
|
/** For Options, at least one of the three parameters — price, quantity or implied volatility — must be input. */
|
||||||
modifyOrder(params: unknown): Promise<APIResponseWithTime<any>> {
|
modifyOrder(
|
||||||
|
params: USDCOptionsModifyOrderRequest
|
||||||
|
): Promise<USDCAPIResponse<any>> {
|
||||||
return this.postPrivate(
|
return this.postPrivate(
|
||||||
'/option/usdc/openapi/private/v1/replace-order',
|
'/option/usdc/openapi/private/v1/replace-order',
|
||||||
params
|
params
|
||||||
@@ -105,8 +135,8 @@ export class USDCOptionsClient extends BaseRestClient {
|
|||||||
|
|
||||||
/** Each request supports a max. of four orders. The reduceOnly parameter should be separate and unique for each order in the request. */
|
/** Each request supports a max. of four orders. The reduceOnly parameter should be separate and unique for each order in the request. */
|
||||||
batchModifyOrders(
|
batchModifyOrders(
|
||||||
replaceOrderRequest: unknown[]
|
replaceOrderRequest: USDCOptionsModifyOrderRequest[]
|
||||||
): Promise<APIResponseWithTime<any>> {
|
): Promise<USDCAPIResponse<any>> {
|
||||||
return this.postPrivate(
|
return this.postPrivate(
|
||||||
'/option/usdc/openapi/private/v1/batch-replace-orders',
|
'/option/usdc/openapi/private/v1/batch-replace-orders',
|
||||||
{ replaceOrderRequest }
|
{ replaceOrderRequest }
|
||||||
@@ -114,7 +144,9 @@ export class USDCOptionsClient extends BaseRestClient {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** Cancel order */
|
/** Cancel order */
|
||||||
cancelOrder(params: unknown): Promise<APIResponseWithTime<any>> {
|
cancelOrder(
|
||||||
|
params: USDCOptionsCancelOrderRequest
|
||||||
|
): Promise<USDCAPIResponse<any>> {
|
||||||
return this.postPrivate(
|
return this.postPrivate(
|
||||||
'/option/usdc/openapi/private/v1/cancel-order',
|
'/option/usdc/openapi/private/v1/cancel-order',
|
||||||
params
|
params
|
||||||
@@ -123,8 +155,8 @@ export class USDCOptionsClient extends BaseRestClient {
|
|||||||
|
|
||||||
/** Batch cancel orders */
|
/** Batch cancel orders */
|
||||||
batchCancelOrders(
|
batchCancelOrders(
|
||||||
cancelRequest: unknown[]
|
cancelRequest: USDCOptionsCancelOrderRequest[]
|
||||||
): Promise<APIResponseWithTime<any>> {
|
): Promise<USDCAPIResponse<any>> {
|
||||||
return this.postPrivate(
|
return this.postPrivate(
|
||||||
'/option/usdc/openapi/private/v1/batch-cancel-orders',
|
'/option/usdc/openapi/private/v1/batch-cancel-orders',
|
||||||
{ cancelRequest }
|
{ cancelRequest }
|
||||||
@@ -132,7 +164,9 @@ export class USDCOptionsClient extends BaseRestClient {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** This is used to cancel all active orders. The real-time response indicates whether the request is successful, depending on retCode. */
|
/** This is used to cancel all active orders. The real-time response indicates whether the request is successful, depending on retCode. */
|
||||||
cancelActiveOrders(params?: unknown): Promise<APIResponseWithTime<any>> {
|
cancelActiveOrders(
|
||||||
|
params?: USDCOptionsCancelAllOrdersRequest
|
||||||
|
): Promise<USDCAPIResponse<any>> {
|
||||||
return this.postPrivate(
|
return this.postPrivate(
|
||||||
'/option/usdc/openapi/private/v1/cancel-all',
|
'/option/usdc/openapi/private/v1/cancel-all',
|
||||||
params
|
params
|
||||||
@@ -140,7 +174,9 @@ export class USDCOptionsClient extends BaseRestClient {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** Query Unfilled/Partially Filled Orders(real-time), up to last 7 days of partially filled/unfilled orders */
|
/** Query Unfilled/Partially Filled Orders(real-time), up to last 7 days of partially filled/unfilled orders */
|
||||||
getActiveRealtimeOrders(params?: unknown): Promise<APIResponseWithTime<any>> {
|
getActiveRealtimeOrders(
|
||||||
|
params?: USDCOptionsActiveOrdersRealtimeRequest
|
||||||
|
): Promise<USDCAPIResponse<any>> {
|
||||||
return this.getPrivate(
|
return this.getPrivate(
|
||||||
'/option/usdc/openapi/private/v1/trade/query-active-orders',
|
'/option/usdc/openapi/private/v1/trade/query-active-orders',
|
||||||
params
|
params
|
||||||
@@ -148,7 +184,9 @@ export class USDCOptionsClient extends BaseRestClient {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** Query Unfilled/Partially Filled Orders */
|
/** Query Unfilled/Partially Filled Orders */
|
||||||
getActiveOrders(params: unknown): Promise<APIResponseWithTime<any>> {
|
getActiveOrders(
|
||||||
|
params: USDCOptionsActiveOrdersRequest
|
||||||
|
): Promise<USDCAPIResponse<any>> {
|
||||||
return this.postPrivate(
|
return this.postPrivate(
|
||||||
'/option/usdc/openapi/private/v1/query-active-orders',
|
'/option/usdc/openapi/private/v1/query-active-orders',
|
||||||
params
|
params
|
||||||
@@ -156,7 +194,9 @@ export class USDCOptionsClient extends BaseRestClient {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** Query order history. The endpoint only supports up to 30 days of queried records */
|
/** Query order history. The endpoint only supports up to 30 days of queried records */
|
||||||
getHistoricOrders(params: unknown): Promise<APIResponseWithTime<any>> {
|
getHistoricOrders(
|
||||||
|
params: USDCOptionsHistoricOrdersRequest
|
||||||
|
): Promise<USDCAPIResponse<any>> {
|
||||||
return this.postPrivate(
|
return this.postPrivate(
|
||||||
'/option/usdc/openapi/private/v1/query-order-history',
|
'/option/usdc/openapi/private/v1/query-order-history',
|
||||||
params
|
params
|
||||||
@@ -164,7 +204,9 @@ export class USDCOptionsClient extends BaseRestClient {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** Query trade history. The endpoint only supports up to 30 days of queried records. An error will be returned if startTime is more than 30 days. */
|
/** Query trade history. The endpoint only supports up to 30 days of queried records. An error will be returned if startTime is more than 30 days. */
|
||||||
getOrderExecutionHistory(params: unknown): Promise<APIResponseWithTime<any>> {
|
getOrderExecutionHistory(
|
||||||
|
params: USDCOptionsOrderExecutionRequest
|
||||||
|
): Promise<USDCAPIResponse<any>> {
|
||||||
return this.postPrivate(
|
return this.postPrivate(
|
||||||
'/option/usdc/openapi/private/v1/execution-list',
|
'/option/usdc/openapi/private/v1/execution-list',
|
||||||
params
|
params
|
||||||
@@ -174,7 +216,9 @@ export class USDCOptionsClient extends BaseRestClient {
|
|||||||
/** -> Account API */
|
/** -> Account API */
|
||||||
|
|
||||||
/** The endpoint only supports up to 30 days of queried records. An error will be returned if startTime is more than 30 days. */
|
/** The endpoint only supports up to 30 days of queried records. An error will be returned if startTime is more than 30 days. */
|
||||||
getTransactionLog(params: unknown): Promise<APIResponseWithTime<any>> {
|
getTransactionLog(
|
||||||
|
params: USDCTransactionLogRequest
|
||||||
|
): Promise<USDCAPIResponse<any>> {
|
||||||
return this.postPrivate(
|
return this.postPrivate(
|
||||||
'/option/usdc/openapi/private/v1/query-transaction-log',
|
'/option/usdc/openapi/private/v1/query-transaction-log',
|
||||||
params
|
params
|
||||||
@@ -182,15 +226,14 @@ export class USDCOptionsClient extends BaseRestClient {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** Wallet info for USDC account. */
|
/** Wallet info for USDC account. */
|
||||||
getBalance(params?: unknown): Promise<APIResponseWithTime<any>> {
|
getBalance(): Promise<USDCAPIResponse<any>> {
|
||||||
return this.postPrivate(
|
return this.postPrivate(
|
||||||
'/option/usdc/openapi/private/v1/query-wallet-balance',
|
'/option/usdc/openapi/private/v1/query-wallet-balance'
|
||||||
params
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Asset Info */
|
/** Asset Info */
|
||||||
getAssetInfo(baseCoin?: string): Promise<APIResponseWithTime<any>> {
|
getAssetInfo(baseCoin?: string): Promise<USDCAPIResponse<any>> {
|
||||||
return this.postPrivate(
|
return this.postPrivate(
|
||||||
'/option/usdc/openapi/private/v1/query-asset-info',
|
'/option/usdc/openapi/private/v1/query-asset-info',
|
||||||
{ baseCoin }
|
{ baseCoin }
|
||||||
@@ -203,7 +246,7 @@ export class USDCOptionsClient extends BaseRestClient {
|
|||||||
*/
|
*/
|
||||||
setMarginMode(
|
setMarginMode(
|
||||||
newMarginMode: 'REGULAR_MARGIN' | 'PORTFOLIO_MARGIN'
|
newMarginMode: 'REGULAR_MARGIN' | 'PORTFOLIO_MARGIN'
|
||||||
): Promise<APIResponseWithTime<any>> {
|
): Promise<USDCAPIResponse<any>> {
|
||||||
return this.postPrivate(
|
return this.postPrivate(
|
||||||
'/option/usdc/private/asset/account/setMarginMode',
|
'/option/usdc/private/asset/account/setMarginMode',
|
||||||
{ setMarginMode: newMarginMode }
|
{ setMarginMode: newMarginMode }
|
||||||
@@ -211,7 +254,7 @@ export class USDCOptionsClient extends BaseRestClient {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** Query margin mode for USDC account. */
|
/** Query margin mode for USDC account. */
|
||||||
getMarginMode(): Promise<APIResponseWithTime<any>> {
|
getMarginMode(): Promise<USDCAPIResponse<any>> {
|
||||||
return this.postPrivate(
|
return this.postPrivate(
|
||||||
'/option/usdc/openapi/private/v1/query-margin-info'
|
'/option/usdc/openapi/private/v1/query-margin-info'
|
||||||
);
|
);
|
||||||
@@ -220,7 +263,7 @@ export class USDCOptionsClient extends BaseRestClient {
|
|||||||
/** -> Positions API */
|
/** -> Positions API */
|
||||||
|
|
||||||
/** Query my positions */
|
/** Query my positions */
|
||||||
getPositions(params: unknown): Promise<APIResponseWithTime<any>> {
|
getPositions(params: USDCPositionsRequest): Promise<USDCAPIResponse<any>> {
|
||||||
return this.postPrivate(
|
return this.postPrivate(
|
||||||
'/option/usdc/openapi/private/v1/query-position',
|
'/option/usdc/openapi/private/v1/query-position',
|
||||||
params
|
params
|
||||||
@@ -228,7 +271,9 @@ export class USDCOptionsClient extends BaseRestClient {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** Query Delivery History */
|
/** Query Delivery History */
|
||||||
getDeliveryHistory(params: unknown): Promise<APIResponseWithTime<any>> {
|
getDeliveryHistory(
|
||||||
|
params: USDCOptionsDeliveryHistoryRequest
|
||||||
|
): Promise<USDCAPIResponse<any>> {
|
||||||
return this.postPrivate(
|
return this.postPrivate(
|
||||||
'/option/usdc/openapi/private/v1/query-delivery-list',
|
'/option/usdc/openapi/private/v1/query-delivery-list',
|
||||||
params
|
params
|
||||||
@@ -237,8 +282,8 @@ export class USDCOptionsClient extends BaseRestClient {
|
|||||||
|
|
||||||
/** Query Positions Info Upon Expiry */
|
/** Query Positions Info Upon Expiry */
|
||||||
getPositionsInfoUponExpiry(
|
getPositionsInfoUponExpiry(
|
||||||
params?: unknown
|
params?: USDCOptionsPositionsInfoExpiryRequest
|
||||||
): Promise<APIResponseWithTime<any>> {
|
): Promise<USDCAPIResponse<any>> {
|
||||||
return this.postPrivate(
|
return this.postPrivate(
|
||||||
'/option/usdc/openapi/private/v1/query-position-exp-date',
|
'/option/usdc/openapi/private/v1/query-position-exp-date',
|
||||||
params
|
params
|
||||||
@@ -248,7 +293,9 @@ export class USDCOptionsClient extends BaseRestClient {
|
|||||||
/** -> Market Maker Protection */
|
/** -> Market Maker Protection */
|
||||||
|
|
||||||
/** modifyMMP */
|
/** modifyMMP */
|
||||||
modifyMMP(params?: unknown): Promise<APIResponseWithTime<any>> {
|
modifyMMP(
|
||||||
|
params: USDCOptionsModifyMMPRequest
|
||||||
|
): Promise<USDCAPIResponse<any>> {
|
||||||
return this.postPrivate(
|
return this.postPrivate(
|
||||||
'/option/usdc/openapi/private/v1/mmp-modify',
|
'/option/usdc/openapi/private/v1/mmp-modify',
|
||||||
params
|
params
|
||||||
@@ -256,14 +303,14 @@ export class USDCOptionsClient extends BaseRestClient {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** resetMMP */
|
/** resetMMP */
|
||||||
resetMMP(currency: string): Promise<APIResponseWithTime<any>> {
|
resetMMP(currency: string): Promise<USDCAPIResponse<any>> {
|
||||||
return this.postPrivate('/option/usdc/openapi/private/v1/mmp-reset', {
|
return this.postPrivate('/option/usdc/openapi/private/v1/mmp-reset', {
|
||||||
currency,
|
currency,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/** queryMMPState */
|
/** queryMMPState */
|
||||||
queryMMPState(baseCoin: string): Promise<APIResponseWithTime<any>> {
|
queryMMPState(baseCoin: string): Promise<USDCAPIResponse<any>> {
|
||||||
return this.postPrivate('/option/usdc/openapi/private/v1/get-mmp-state', {
|
return this.postPrivate('/option/usdc/openapi/private/v1/get-mmp-state', {
|
||||||
baseCoin,
|
baseCoin,
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -6,6 +6,16 @@ import {
|
|||||||
USDCKlineRequest,
|
USDCKlineRequest,
|
||||||
USDCLast500TradesRequest,
|
USDCLast500TradesRequest,
|
||||||
USDCOpenInterestRequest,
|
USDCOpenInterestRequest,
|
||||||
|
USDCOrderFilter,
|
||||||
|
USDCPerpActiveOrdersRequest,
|
||||||
|
USDCPerpCancelOrderRequest,
|
||||||
|
USDCPerpHistoricOrdersRequest,
|
||||||
|
USDCPerpModifyOrderRequest,
|
||||||
|
USDCPerpOrderRequest,
|
||||||
|
USDCPositionsRequest,
|
||||||
|
USDCSymbolDirectionLimit,
|
||||||
|
USDCSymbolDirectionLimitCursor,
|
||||||
|
USDCTransactionLogRequest,
|
||||||
} from './types';
|
} from './types';
|
||||||
import { REST_CLIENT_TYPE_ENUM } from './util';
|
import { REST_CLIENT_TYPE_ENUM } from './util';
|
||||||
import BaseRestClient from './util/BaseRestClient';
|
import BaseRestClient from './util/BaseRestClient';
|
||||||
@@ -34,7 +44,9 @@ export class USDCPerpetualClient extends BaseRestClient {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** Fetch trading rules (such as min/max qty). Query for all if blank. */
|
/** Fetch trading rules (such as min/max qty). Query for all if blank. */
|
||||||
getContractInfo(params?: unknown): Promise<USDCAPIResponse<any>> {
|
getContractInfo(
|
||||||
|
params?: USDCSymbolDirectionLimit
|
||||||
|
): Promise<USDCAPIResponse<any>> {
|
||||||
return this.get('/perpetual/usdc/openapi/public/v1/symbols', params);
|
return this.get('/perpetual/usdc/openapi/public/v1/symbols', params);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -108,7 +120,7 @@ export class USDCPerpetualClient extends BaseRestClient {
|
|||||||
* The request status can be queried in real-time.
|
* The request status can be queried in real-time.
|
||||||
* The response parameters must be queried through a query or a WebSocket response.
|
* The response parameters must be queried through a query or a WebSocket response.
|
||||||
*/
|
*/
|
||||||
submitOrder(params: unknown): Promise<USDCAPIResponse<any>> {
|
submitOrder(params: USDCPerpOrderRequest): Promise<USDCAPIResponse<any>> {
|
||||||
return this.postPrivate(
|
return this.postPrivate(
|
||||||
'/perpetual/usdc/openapi/private/v1/place-order',
|
'/perpetual/usdc/openapi/private/v1/place-order',
|
||||||
params
|
params
|
||||||
@@ -116,7 +128,9 @@ export class USDCPerpetualClient extends BaseRestClient {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** Active order parameters (such as quantity, price) and stop order parameters cannot be modified in one request at the same time. Please request modification separately. */
|
/** Active order parameters (such as quantity, price) and stop order parameters cannot be modified in one request at the same time. Please request modification separately. */
|
||||||
modifyOrder(params: unknown): Promise<USDCAPIResponse<any>> {
|
modifyOrder(
|
||||||
|
params: USDCPerpModifyOrderRequest
|
||||||
|
): Promise<USDCAPIResponse<any>> {
|
||||||
return this.postPrivate(
|
return this.postPrivate(
|
||||||
'/perpetual/usdc/openapi/private/v1/replace-order',
|
'/perpetual/usdc/openapi/private/v1/replace-order',
|
||||||
params
|
params
|
||||||
@@ -124,7 +138,9 @@ export class USDCPerpetualClient extends BaseRestClient {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** Cancel order */
|
/** Cancel order */
|
||||||
cancelOrder(params: unknown): Promise<USDCAPIResponse<any>> {
|
cancelOrder(
|
||||||
|
params: USDCPerpCancelOrderRequest
|
||||||
|
): Promise<USDCAPIResponse<any>> {
|
||||||
return this.postPrivate(
|
return this.postPrivate(
|
||||||
'/perpetual/usdc/openapi/private/v1/cancel-order',
|
'/perpetual/usdc/openapi/private/v1/cancel-order',
|
||||||
params
|
params
|
||||||
@@ -134,7 +150,7 @@ export class USDCPerpetualClient extends BaseRestClient {
|
|||||||
/** Cancel all active orders. The real-time response indicates whether the request is successful, depending on retCode. */
|
/** Cancel all active orders. The real-time response indicates whether the request is successful, depending on retCode. */
|
||||||
cancelActiveOrders(
|
cancelActiveOrders(
|
||||||
symbol: string,
|
symbol: string,
|
||||||
orderFilter: string
|
orderFilter: USDCOrderFilter
|
||||||
): Promise<USDCAPIResponse<any>> {
|
): Promise<USDCAPIResponse<any>> {
|
||||||
return this.postPrivate('/perpetual/usdc/openapi/private/v1/cancel-all', {
|
return this.postPrivate('/perpetual/usdc/openapi/private/v1/cancel-all', {
|
||||||
symbol,
|
symbol,
|
||||||
@@ -143,7 +159,9 @@ export class USDCPerpetualClient extends BaseRestClient {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** Query Unfilled/Partially Filled Orders */
|
/** Query Unfilled/Partially Filled Orders */
|
||||||
getActiveOrders(params: unknown): Promise<USDCAPIResponse<any>> {
|
getActiveOrders(
|
||||||
|
params: USDCPerpActiveOrdersRequest
|
||||||
|
): Promise<USDCAPIResponse<any>> {
|
||||||
return this.postPrivate(
|
return this.postPrivate(
|
||||||
'/option/usdc/openapi/private/v1/query-active-orders',
|
'/option/usdc/openapi/private/v1/query-active-orders',
|
||||||
params
|
params
|
||||||
@@ -151,7 +169,9 @@ export class USDCPerpetualClient extends BaseRestClient {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** Query order history. The endpoint only supports up to 30 days of queried records */
|
/** Query order history. The endpoint only supports up to 30 days of queried records */
|
||||||
getHistoricOrders(params: unknown): Promise<USDCAPIResponse<any>> {
|
getHistoricOrders(
|
||||||
|
params: USDCPerpHistoricOrdersRequest
|
||||||
|
): Promise<USDCAPIResponse<any>> {
|
||||||
return this.postPrivate(
|
return this.postPrivate(
|
||||||
'/option/usdc/openapi/private/v1/query-order-history',
|
'/option/usdc/openapi/private/v1/query-order-history',
|
||||||
params
|
params
|
||||||
@@ -159,7 +179,9 @@ export class USDCPerpetualClient extends BaseRestClient {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** Query trade history. The endpoint only supports up to 30 days of queried records. An error will be returned if startTime is more than 30 days. */
|
/** Query trade history. The endpoint only supports up to 30 days of queried records. An error will be returned if startTime is more than 30 days. */
|
||||||
getOrderExecutionHistory(params: unknown): Promise<USDCAPIResponse<any>> {
|
getOrderExecutionHistory(
|
||||||
|
params: USDCPerpActiveOrdersRequest
|
||||||
|
): Promise<USDCAPIResponse<any>> {
|
||||||
return this.postPrivate(
|
return this.postPrivate(
|
||||||
'/option/usdc/openapi/private/v1/execution-list',
|
'/option/usdc/openapi/private/v1/execution-list',
|
||||||
params
|
params
|
||||||
@@ -169,7 +191,9 @@ export class USDCPerpetualClient extends BaseRestClient {
|
|||||||
/** -> Account API */
|
/** -> Account API */
|
||||||
|
|
||||||
/** The endpoint only supports up to 30 days of queried records. An error will be returned if startTime is more than 30 days. */
|
/** The endpoint only supports up to 30 days of queried records. An error will be returned if startTime is more than 30 days. */
|
||||||
getTransactionLog(params: unknown): Promise<USDCAPIResponse<any>> {
|
getTransactionLog(
|
||||||
|
params: USDCTransactionLogRequest
|
||||||
|
): Promise<USDCAPIResponse<any>> {
|
||||||
return this.postPrivate(
|
return this.postPrivate(
|
||||||
'/option/usdc/openapi/private/v1/query-transaction-log',
|
'/option/usdc/openapi/private/v1/query-transaction-log',
|
||||||
params
|
params
|
||||||
@@ -177,10 +201,9 @@ export class USDCPerpetualClient extends BaseRestClient {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** Wallet info for USDC account. */
|
/** Wallet info for USDC account. */
|
||||||
getBalance(params?: unknown): Promise<USDCAPIResponse<any>> {
|
getBalance(): Promise<USDCAPIResponse<any>> {
|
||||||
return this.postPrivate(
|
return this.postPrivate(
|
||||||
'/option/usdc/openapi/private/v1/query-wallet-balance',
|
'/option/usdc/openapi/private/v1/query-wallet-balance'
|
||||||
params
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -215,7 +238,7 @@ export class USDCPerpetualClient extends BaseRestClient {
|
|||||||
/** -> Positions API */
|
/** -> Positions API */
|
||||||
|
|
||||||
/** Query my positions */
|
/** Query my positions */
|
||||||
getPositions(params: unknown): Promise<USDCAPIResponse<any>> {
|
getPositions(params: USDCPositionsRequest): Promise<USDCAPIResponse<any>> {
|
||||||
return this.postPrivate(
|
return this.postPrivate(
|
||||||
'/option/usdc/openapi/private/v1/query-position',
|
'/option/usdc/openapi/private/v1/query-position',
|
||||||
params
|
params
|
||||||
@@ -231,7 +254,9 @@ export class USDCPerpetualClient extends BaseRestClient {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** Query Settlement History */
|
/** Query Settlement History */
|
||||||
getSettlementHistory(params?: unknown): Promise<USDCAPIResponse<any>> {
|
getSettlementHistory(
|
||||||
|
params?: USDCSymbolDirectionLimitCursor
|
||||||
|
): Promise<USDCAPIResponse<any>> {
|
||||||
return this.postPrivate(
|
return this.postPrivate(
|
||||||
'/option/usdc/openapi/private/v1/session-settlement',
|
'/option/usdc/openapi/private/v1/session-settlement',
|
||||||
params
|
params
|
||||||
|
|||||||
@@ -36,8 +36,8 @@ describe('Public USDC Options REST API Endpoints', () => {
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('getLastTrades()', async () => {
|
it('getLast500Trades()', async () => {
|
||||||
expect(await api.getLastTrades({ category: 'OPTION' })).toMatchObject(
|
expect(await api.getLast500Trades({ category: 'OPTION' })).toMatchObject(
|
||||||
successUSDCResponseObject()
|
successUSDCResponseObject()
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -41,6 +41,7 @@ describe('Private Account Asset REST API Endpoints', () => {
|
|||||||
symbol,
|
symbol,
|
||||||
orderId: 'somethingFake',
|
orderId: 'somethingFake',
|
||||||
orderPrice: '20000',
|
orderPrice: '20000',
|
||||||
|
orderFilter: 'Order',
|
||||||
})
|
})
|
||||||
).toMatchObject({
|
).toMatchObject({
|
||||||
retCode: API_ERROR_CODE.ORDER_NOT_FOUND_OR_TOO_LATE,
|
retCode: API_ERROR_CODE.ORDER_NOT_FOUND_OR_TOO_LATE,
|
||||||
|
|||||||
Reference in New Issue
Block a user