@imbingox/acex 0.1.0-beta.1 → 0.1.0-beta.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,8 @@
1
+ import type BigNumber from "bignumber.js";
1
2
  import type { PositionSide } from "./account.ts";
2
3
  import type {
3
4
  Exchange,
5
+ PrivateRuntimeReason,
4
6
  PrivateRuntimeStatus,
5
7
  SubscriptionActivity,
6
8
  } from "./shared.ts";
@@ -14,12 +16,7 @@ export interface OrderDataStatus {
14
16
  lastReceivedAt?: number;
15
17
  lastReadyAt?: number;
16
18
  inactiveSince?: number;
17
- reason?:
18
- | "credentials_missing"
19
- | "auth_failed"
20
- | "ws_disconnected"
21
- | "heartbeat_timeout"
22
- | "reconciling";
19
+ reason?: PrivateRuntimeReason;
23
20
  }
24
21
 
25
22
  export interface OrderStatusChangedEvent {
@@ -40,6 +37,8 @@ export type OrderStatus =
40
37
  | "rejected"
41
38
  | "expired";
42
39
 
40
+ export type CreateOrderType = "limit" | "market";
41
+
43
42
  export interface SubscribeOrdersInput {
44
43
  accountId: string;
45
44
  }
@@ -54,6 +53,39 @@ export interface GetOrderInput {
54
53
  clientOrderId?: string;
55
54
  }
56
55
 
56
+ interface CreateOrderInputBase {
57
+ accountId: string;
58
+ symbol: string;
59
+ side: OrderSide;
60
+ amount: string;
61
+ clientOrderId?: string;
62
+ reduceOnly?: boolean;
63
+ positionSide?: PositionSide;
64
+ }
65
+
66
+ export interface CreateLimitOrderInput extends CreateOrderInputBase {
67
+ type: "limit";
68
+ price: string;
69
+ }
70
+
71
+ export interface CreateMarketOrderInput extends CreateOrderInputBase {
72
+ type: "market";
73
+ }
74
+
75
+ export type CreateOrderInput = CreateLimitOrderInput | CreateMarketOrderInput;
76
+
77
+ export interface CancelOrderInput {
78
+ accountId: string;
79
+ symbol: string;
80
+ orderId?: string;
81
+ clientOrderId?: string;
82
+ }
83
+
84
+ export interface CancelAllOrdersInput {
85
+ accountId: string;
86
+ symbol: string;
87
+ }
88
+
57
89
  export interface OrderEventFilter {
58
90
  accountId?: string;
59
91
  exchange?: Exchange;
@@ -69,14 +101,14 @@ export interface OrderSnapshot {
69
101
  side: OrderSide;
70
102
  type: string;
71
103
  status: OrderStatus;
72
- price?: string;
73
- triggerPrice?: string;
74
- amount: string;
75
- filled: string;
76
- remaining?: string;
104
+ price?: BigNumber;
105
+ triggerPrice?: BigNumber;
106
+ amount: BigNumber;
107
+ filled: BigNumber;
108
+ remaining?: BigNumber;
77
109
  reduceOnly?: boolean;
78
110
  positionSide?: PositionSide;
79
- avgFillPrice?: string;
111
+ avgFillPrice?: BigNumber;
80
112
  exchangeTs?: number;
81
113
  receivedAt: number;
82
114
  updatedAt: number;
@@ -135,6 +167,9 @@ export interface OrderManager {
135
167
 
136
168
  subscribeOrders(input: SubscribeOrdersInput): Promise<void>;
137
169
  unsubscribeOrders(input: UnsubscribeOrdersInput): Promise<void>;
170
+ createOrder(input: CreateOrderInput): Promise<OrderSnapshot>;
171
+ cancelOrder(input: CancelOrderInput): Promise<OrderSnapshot>;
172
+ cancelAllOrders(input: CancelAllOrdersInput): Promise<OrderSnapshot[]>;
138
173
 
139
174
  getOrder(input: GetOrderInput): OrderSnapshot | undefined;
140
175
  getOpenOrders(accountId: string, symbol?: string): OrderSnapshot[];
@@ -25,11 +25,19 @@ export interface MarketRuntimeOptions {
25
25
  l1ReconnectMaxDelayMs?: number;
26
26
  }
27
27
 
28
+ export interface AccountRuntimeOptions {
29
+ streamOpenTimeoutMs?: number;
30
+ streamReconnectDelayMs?: number;
31
+ streamReconnectMaxDelayMs?: number;
32
+ listenKeyKeepAliveMs?: number;
33
+ }
34
+
28
35
  export interface CreateClientOptions {
29
36
  sandbox?: boolean;
30
37
  logger?: Logger;
31
38
  logLevel?: LogLevel;
32
39
  market?: MarketRuntimeOptions;
40
+ account?: AccountRuntimeOptions;
33
41
  }
34
42
 
35
43
  export interface AccountCredentials {
@@ -76,3 +84,10 @@ export type PrivateRuntimeStatus =
76
84
  | "reconnecting"
77
85
  | "reconciling"
78
86
  | "stopped";
87
+
88
+ export type PrivateRuntimeReason =
89
+ | "credentials_missing"
90
+ | "auth_failed"
91
+ | "ws_disconnected"
92
+ | "heartbeat_timeout"
93
+ | "reconciling";