Expand types, add type guards, flesh out futures position example

This commit is contained in:
Tiago Siebler
2022-11-22 12:32:26 +00:00
parent b3c4c43f63
commit 99a24e6982
9 changed files with 276 additions and 10 deletions

View File

@@ -17,6 +17,8 @@ import {
NewFuturesPlanStopOrder,
FuturesAccount,
FuturesSymbolRule,
FuturesMarginMode,
FuturesPosition,
} from './types';
import { REST_CLIENT_TYPE_ENUM } from './util';
import BaseRestClient from './util/BaseRestClient';
@@ -198,7 +200,7 @@ export class FuturesClient extends BaseRestClient {
setMarginMode(
symbol: string,
marginCoin: string,
marginMode: 'fixed' | 'crossed'
marginMode: FuturesMarginMode
): Promise<APIResponse<any>> {
return this.postPrivate('/api/mix/v1/account/setMarginMode', {
symbol,
@@ -208,7 +210,10 @@ export class FuturesClient extends BaseRestClient {
}
/** Get Symbol Position */
getPosition(symbol: string, marginCoin?: string): Promise<APIResponse<any>> {
getPosition(
symbol: string,
marginCoin?: string
): Promise<APIResponse<FuturesPosition[]>> {
return this.getPrivate('/api/mix/v1/position/singlePosition', {
symbol,
marginCoin,
@@ -219,7 +224,7 @@ export class FuturesClient extends BaseRestClient {
getPositions(
productType: FuturesProductType,
marginCoin?: string
): Promise<APIResponse<any>> {
): Promise<APIResponse<FuturesPosition[]>> {
return this.getPrivate('/api/mix/v1/position/allPosition', {
productType,
marginCoin,