remove silly logger from ws by default. Expand spot and linear types

This commit is contained in:
tiagosiebler
2022-08-18 17:04:53 +01:00
parent ae56067c94
commit 2d0366a708
15 changed files with 174 additions and 31 deletions

4
src/types/index.ts Normal file
View File

@@ -0,0 +1,4 @@
export * from './response';
export * from './request';
export * from './shared';
export * from './spot';

View File

@@ -0,0 +1 @@
export * from './usdt-perp';

View File

@@ -0,0 +1,27 @@
import { LinearPositionIdx } from '../../constants/enum';
import { OrderSide } from '../shared';
export type LinearOrderType = 'Limit' | 'Market';
export type LinearTimeInForce =
| 'GoodTillCancel'
| 'ImmediateOrCancel'
| 'FillOrKill'
| 'PostOnly';
export interface NewLinearOrder {
side: OrderSide;
symbol: string;
order_type: LinearOrderType;
qty: number;
price?: number;
time_in_force: LinearTimeInForce;
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;
position_idx?: LinearPositionIdx;
}

View File

@@ -0,0 +1,3 @@
export * from './shared';
export * from './spot';
export * from './usdt-perp';

View File

@@ -0,0 +1,19 @@
export interface SymbolWalletBalance {
equity: number;
available_balance: number;
used_margin: number;
order_margin: number;
position_margin: number;
occ_closing_fee: number;
occ_funding_fee: number;
wallet_balance: number;
realised_pnl: number;
unrealised_pnl: number;
cum_realised_pnl: number;
given_cash: number;
service_cash: number;
}
export interface WalletBalances {
[symbol: string]: SymbolWalletBalance | undefined;
}

View File

@@ -0,0 +1,17 @@
export interface SpotBalances {
balances: SpotBalance[];
}
export interface SpotBalance {
coin: string;
coinId: string;
coinName: string;
total: string;
free: string;
locked: string;
}
export interface SpotLastPrice {
symbol: string;
price: string;
}

View File

@@ -0,0 +1,58 @@
export interface PerpPosition {
user_id: number;
symbol: string;
side: string;
size: number;
position_value: number;
entry_price: number;
liq_price: number;
bust_price: number;
leverage: number;
auto_add_margin: number;
is_isolated: boolean;
position_margin: number;
occ_closing_fee: number;
realised_pnl: number;
cum_realised_pnl: number;
free_qty: number;
tp_sl_mode: string;
unrealised_pnl: number;
deleverage_indicator: number;
risk_id: number;
stop_loss: number;
take_profit: number;
trailing_stop: number;
position_idx: number;
mode: string;
}
export interface PerpPositionRoot {
data: PerpPosition;
is_valid: boolean;
}
export interface LinearOrder {
order_id: string;
user_id: number;
symbol: string;
side: string;
order_type: string;
price: number;
qty: number;
time_in_force: string;
order_status: string;
last_exec_price: number;
cum_exec_qty: number;
cum_exec_value: number;
cum_exec_fee: number;
reduce_only: boolean;
close_on_trigger: boolean;
order_link_id: string;
created_time: string;
updated_time: string;
take_profit: number;
stop_loss: number;
tp_trigger_by: string;
sl_trigger_by: string;
position_idx: number;
}

View File

@@ -1,3 +1,7 @@
export type numberInString = string;
export type OrderSide = 'Buy' | 'Sell';
export type KlineInterval =
| '1m'
| '3m'
@@ -13,8 +17,6 @@ export type KlineInterval =
| '1w'
| '1M';
export type numberInString = string;
export interface APIResponse<T> {
ret_code: number;
ret_msg: 'OK' | string;

View File

@@ -1,6 +1,5 @@
import { numberInString } from './shared';
import { numberInString, OrderSide } from './shared';
export type OrderSide = 'Buy' | 'Sell';
export type OrderTypeSpot = 'LIMIT' | 'MARKET' | 'LIMIT_MAKER';
export type OrderTimeInForce = 'GTC' | 'FOK' | 'IOC';