@finatic/client 0.0.133 → 0.0.135
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.
- package/README.md +87 -0
- package/dist/index.d.ts +471 -730
- package/dist/index.js +847 -734
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +848 -732
- package/dist/index.mjs.map +1 -1
- package/dist/types/core/client/ApiClient.d.ts +206 -0
- package/dist/types/{client → core/client}/FinaticConnect.d.ts +54 -13
- package/dist/types/{portal → core/portal}/PortalUI.d.ts +1 -1
- package/dist/types/index.d.ts +6 -11
- package/dist/types/mocks/MockApiClient.d.ts +36 -90
- package/dist/types/mocks/MockDataProvider.d.ts +13 -3
- package/dist/types/mocks/MockFactory.d.ts +2 -2
- package/dist/types/{shared/themes → themes}/portalPresets.d.ts +1 -1
- package/dist/types/types/api/auth.d.ts +111 -0
- package/dist/types/types/{api.d.ts → api/broker.d.ts} +56 -284
- package/dist/types/types/api/core.d.ts +46 -0
- package/dist/types/types/api/errors.d.ts +23 -0
- package/dist/types/types/api/orders.d.ts +39 -0
- package/dist/types/types/{shared.d.ts → api/portfolio.d.ts} +26 -21
- package/dist/types/types/common/pagination.d.ts +33 -0
- package/dist/types/types/connect.d.ts +4 -2
- package/dist/types/types/index.d.ts +13 -0
- package/dist/types/types/{theme.d.ts → ui/theme.d.ts} +3 -0
- package/dist/types/utils/brokerUtils.d.ts +30 -0
- package/package.json +4 -3
- package/dist/types/client/ApiClient.d.ts +0 -234
- package/dist/types/mocks/index.d.ts +0 -5
- package/dist/types/security/ApiSecurity.d.ts +0 -24
- package/dist/types/security/RuntimeSecurity.d.ts +0 -28
- package/dist/types/security/SecurityUtils.d.ts +0 -21
- package/dist/types/security/index.d.ts +0 -2
- package/dist/types/services/AnalyticsService.d.ts +0 -18
- package/dist/types/services/ApiClient.d.ts +0 -121
- package/dist/types/services/PortalService.d.ts +0 -24
- package/dist/types/services/TradingService.d.ts +0 -55
- package/dist/types/services/api.d.ts +0 -23
- package/dist/types/services/auth.d.ts +0 -9
- package/dist/types/services/index.d.ts +0 -4
- package/dist/types/services/portfolio.d.ts +0 -10
- package/dist/types/services/trading.d.ts +0 -10
- package/dist/types/shared/index.d.ts +0 -2
- package/dist/types/shared/themes/index.d.ts +0 -2
- package/dist/types/shared/themes/presets.d.ts +0 -3
- package/dist/types/shared/themes/system.d.ts +0 -2
- package/dist/types/shared/types/index.d.ts +0 -110
- package/dist/types/types/config.d.ts +0 -12
- package/dist/types/types/errors.d.ts +0 -47
- package/dist/types/types/security.d.ts +0 -35
- package/dist/types/types.d.ts +0 -157
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Authentication-related types
|
|
3
|
+
*/
|
|
4
|
+
export interface SessionInitResponse {
|
|
5
|
+
success: boolean;
|
|
6
|
+
message: string;
|
|
7
|
+
data: {
|
|
8
|
+
one_time_token: string;
|
|
9
|
+
expires_at: string;
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
export interface SessionResponseData {
|
|
13
|
+
session_id: string;
|
|
14
|
+
company_id: string;
|
|
15
|
+
status: 'pending';
|
|
16
|
+
expires_at: string;
|
|
17
|
+
}
|
|
18
|
+
export interface SessionStartResponse {
|
|
19
|
+
data: SessionResponseData;
|
|
20
|
+
message: 'Session started successfully';
|
|
21
|
+
}
|
|
22
|
+
export interface OtpRequestResponse {
|
|
23
|
+
success: boolean;
|
|
24
|
+
message: string;
|
|
25
|
+
data: boolean;
|
|
26
|
+
}
|
|
27
|
+
export interface OtpVerifyResponse {
|
|
28
|
+
success: boolean;
|
|
29
|
+
message: string;
|
|
30
|
+
data: {
|
|
31
|
+
access_token: string;
|
|
32
|
+
refresh_token: string;
|
|
33
|
+
user_id: string;
|
|
34
|
+
expires_in: number;
|
|
35
|
+
scope: string;
|
|
36
|
+
token_type: 'Bearer';
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
export interface UserToken {
|
|
40
|
+
accessToken: string;
|
|
41
|
+
refreshToken: string;
|
|
42
|
+
expiresIn: number;
|
|
43
|
+
user_id: string;
|
|
44
|
+
tokenType: string;
|
|
45
|
+
scope: string;
|
|
46
|
+
}
|
|
47
|
+
export interface SessionValidationResponse {
|
|
48
|
+
valid: boolean;
|
|
49
|
+
company_id: string;
|
|
50
|
+
status: string;
|
|
51
|
+
}
|
|
52
|
+
export interface SessionAuthenticateResponse {
|
|
53
|
+
success: boolean;
|
|
54
|
+
message: string;
|
|
55
|
+
data: {
|
|
56
|
+
access_token: string;
|
|
57
|
+
refresh_token: string;
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
export interface RefreshTokenRequest {
|
|
61
|
+
refresh_token: string;
|
|
62
|
+
}
|
|
63
|
+
export interface RefreshTokenResponse {
|
|
64
|
+
success: boolean;
|
|
65
|
+
response_data: {
|
|
66
|
+
access_token: string;
|
|
67
|
+
refresh_token: string;
|
|
68
|
+
expires_at: string;
|
|
69
|
+
company_id: string;
|
|
70
|
+
company_name: string;
|
|
71
|
+
email_verified: boolean;
|
|
72
|
+
};
|
|
73
|
+
message: string;
|
|
74
|
+
}
|
|
75
|
+
export interface TokenInfo {
|
|
76
|
+
accessToken: string;
|
|
77
|
+
refreshToken: string;
|
|
78
|
+
expiresAt: string;
|
|
79
|
+
userId?: string;
|
|
80
|
+
}
|
|
81
|
+
export interface SessionResponse {
|
|
82
|
+
data: {
|
|
83
|
+
session_id: string;
|
|
84
|
+
state: SessionState;
|
|
85
|
+
device_info?: Record<string, string>;
|
|
86
|
+
company_id?: string;
|
|
87
|
+
status?: string;
|
|
88
|
+
expires_at?: string;
|
|
89
|
+
user_id?: string | null;
|
|
90
|
+
auto_login?: boolean;
|
|
91
|
+
access_token?: string;
|
|
92
|
+
refresh_token?: string;
|
|
93
|
+
expires_in?: number;
|
|
94
|
+
token_type?: string;
|
|
95
|
+
scope?: string;
|
|
96
|
+
};
|
|
97
|
+
message: string;
|
|
98
|
+
}
|
|
99
|
+
export declare enum SessionState {
|
|
100
|
+
PENDING = "PENDING",
|
|
101
|
+
AUTHENTICATING = "AUTHENTICATING",
|
|
102
|
+
ACTIVE = "ACTIVE",
|
|
103
|
+
COMPLETED = "COMPLETED",
|
|
104
|
+
EXPIRED = "EXPIRED"
|
|
105
|
+
}
|
|
106
|
+
export type SessionStatus = SessionState;
|
|
107
|
+
export interface DeviceInfo {
|
|
108
|
+
ip_address: string;
|
|
109
|
+
user_agent: string;
|
|
110
|
+
fingerprint: string;
|
|
111
|
+
}
|
|
@@ -1,106 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* Broker-related types
|
|
3
3
|
*/
|
|
4
|
-
export interface SessionInitResponse {
|
|
5
|
-
success: boolean;
|
|
6
|
-
message: string;
|
|
7
|
-
data: {
|
|
8
|
-
one_time_token: string;
|
|
9
|
-
expires_at: string;
|
|
10
|
-
};
|
|
11
|
-
}
|
|
12
|
-
export interface SessionResponseData {
|
|
13
|
-
session_id: string;
|
|
14
|
-
company_id: string;
|
|
15
|
-
status: 'pending';
|
|
16
|
-
expires_at: string;
|
|
17
|
-
}
|
|
18
|
-
export interface SessionStartResponse {
|
|
19
|
-
data: SessionResponseData;
|
|
20
|
-
message: 'Session started successfully';
|
|
21
|
-
}
|
|
22
|
-
export interface OtpRequestResponse {
|
|
23
|
-
success: boolean;
|
|
24
|
-
message: string;
|
|
25
|
-
data: boolean;
|
|
26
|
-
}
|
|
27
|
-
export interface OtpVerifyResponse {
|
|
28
|
-
success: boolean;
|
|
29
|
-
message: string;
|
|
30
|
-
data: {
|
|
31
|
-
access_token: string;
|
|
32
|
-
refresh_token: string;
|
|
33
|
-
user_id: string;
|
|
34
|
-
expires_in: number;
|
|
35
|
-
scope: string;
|
|
36
|
-
token_type: 'Bearer';
|
|
37
|
-
};
|
|
38
|
-
}
|
|
39
|
-
export interface PortalUrlResponse {
|
|
40
|
-
success: boolean;
|
|
41
|
-
message: string;
|
|
42
|
-
data: {
|
|
43
|
-
portal_url: string;
|
|
44
|
-
};
|
|
45
|
-
}
|
|
46
|
-
export interface UserToken {
|
|
47
|
-
accessToken: string;
|
|
48
|
-
refreshToken: string;
|
|
49
|
-
expiresIn: number;
|
|
50
|
-
user_id: string;
|
|
51
|
-
tokenType: string;
|
|
52
|
-
scope: string;
|
|
53
|
-
}
|
|
54
|
-
export interface ApiError {
|
|
55
|
-
code: string;
|
|
56
|
-
message: string;
|
|
57
|
-
details?: Record<string, any>;
|
|
58
|
-
}
|
|
59
|
-
export interface ApiConfig {
|
|
60
|
-
baseUrl: string;
|
|
61
|
-
apiKey?: string;
|
|
62
|
-
sandbox?: boolean;
|
|
63
|
-
}
|
|
64
|
-
export interface RequestHeaders {
|
|
65
|
-
'Content-Type': string;
|
|
66
|
-
'X-API-Key'?: string;
|
|
67
|
-
Authorization?: string;
|
|
68
|
-
'X-CSRF-Token'?: string;
|
|
69
|
-
token?: string;
|
|
70
|
-
'User-Agent'?: string;
|
|
71
|
-
'X-Device-Info'?: string;
|
|
72
|
-
'X-Request-ID'?: string;
|
|
73
|
-
'X-Request-Timestamp'?: string;
|
|
74
|
-
'X-Request-Signature'?: string;
|
|
75
|
-
[key: string]: string | undefined;
|
|
76
|
-
}
|
|
77
|
-
export declare enum SessionState {
|
|
78
|
-
PENDING = "PENDING",
|
|
79
|
-
AUTHENTICATING = "AUTHENTICATING",
|
|
80
|
-
ACTIVE = "ACTIVE",
|
|
81
|
-
COMPLETED = "COMPLETED",
|
|
82
|
-
EXPIRED = "EXPIRED"
|
|
83
|
-
}
|
|
84
|
-
export type SessionStatus = SessionState;
|
|
85
|
-
export interface ApiResponse<T> {
|
|
86
|
-
data: T;
|
|
87
|
-
error?: string;
|
|
88
|
-
status: number;
|
|
89
|
-
}
|
|
90
|
-
export interface Order {
|
|
91
|
-
symbol: string;
|
|
92
|
-
side: 'buy' | 'sell';
|
|
93
|
-
quantity: number;
|
|
94
|
-
type_: 'market' | 'limit' | 'stop' | 'stop_limit';
|
|
95
|
-
price?: number;
|
|
96
|
-
stopPrice?: number;
|
|
97
|
-
timeInForce: 'day' | 'gtc' | 'opg' | 'cls' | 'ioc' | 'fok';
|
|
98
|
-
}
|
|
99
|
-
export interface OptionsOrder extends Order {
|
|
100
|
-
optionType: 'call' | 'put';
|
|
101
|
-
strikePrice: number;
|
|
102
|
-
expirationDate: string;
|
|
103
|
-
}
|
|
104
4
|
export interface BrokerAccount {
|
|
105
5
|
id: string;
|
|
106
6
|
user_broker_connection_id: string;
|
|
@@ -164,115 +64,6 @@ export interface BrokerDataOptions {
|
|
|
164
64
|
account_id?: string;
|
|
165
65
|
symbol?: string;
|
|
166
66
|
}
|
|
167
|
-
export interface PortfolioSnapshot {
|
|
168
|
-
timestamp: string;
|
|
169
|
-
totalValue: number;
|
|
170
|
-
cash: number;
|
|
171
|
-
equity: number;
|
|
172
|
-
positions: {
|
|
173
|
-
symbol: string;
|
|
174
|
-
quantity: number;
|
|
175
|
-
averagePrice: number;
|
|
176
|
-
currentPrice: number;
|
|
177
|
-
marketValue: number;
|
|
178
|
-
unrealizedPnL: number;
|
|
179
|
-
}[];
|
|
180
|
-
}
|
|
181
|
-
export interface PerformanceMetrics {
|
|
182
|
-
totalReturn: number;
|
|
183
|
-
dailyReturn: number;
|
|
184
|
-
weeklyReturn: number;
|
|
185
|
-
monthlyReturn: number;
|
|
186
|
-
yearlyReturn: number;
|
|
187
|
-
maxDrawdown: number;
|
|
188
|
-
sharpeRatio: number;
|
|
189
|
-
beta: number;
|
|
190
|
-
alpha: number;
|
|
191
|
-
}
|
|
192
|
-
export interface Holding {
|
|
193
|
-
symbol: string;
|
|
194
|
-
quantity: number;
|
|
195
|
-
averagePrice: number;
|
|
196
|
-
currentPrice: number;
|
|
197
|
-
marketValue: number;
|
|
198
|
-
unrealizedPnL: number;
|
|
199
|
-
realizedPnL: number;
|
|
200
|
-
costBasis: number;
|
|
201
|
-
currency: string;
|
|
202
|
-
}
|
|
203
|
-
export interface Portfolio {
|
|
204
|
-
id: string;
|
|
205
|
-
name: string;
|
|
206
|
-
type: string;
|
|
207
|
-
status: string;
|
|
208
|
-
cash: number;
|
|
209
|
-
buyingPower: number;
|
|
210
|
-
equity: number;
|
|
211
|
-
longMarketValue: number;
|
|
212
|
-
shortMarketValue: number;
|
|
213
|
-
initialMargin: number;
|
|
214
|
-
maintenanceMargin: number;
|
|
215
|
-
lastEquity: number;
|
|
216
|
-
positions: Holding[];
|
|
217
|
-
performance: PerformanceMetrics;
|
|
218
|
-
}
|
|
219
|
-
export interface PortalResponse {
|
|
220
|
-
portalUrl: string;
|
|
221
|
-
token: string;
|
|
222
|
-
expiresIn: number;
|
|
223
|
-
}
|
|
224
|
-
export interface SessionValidationResponse {
|
|
225
|
-
valid: boolean;
|
|
226
|
-
company_id: string;
|
|
227
|
-
status: string;
|
|
228
|
-
}
|
|
229
|
-
export interface SessionAuthenticateResponse {
|
|
230
|
-
success: boolean;
|
|
231
|
-
message: string;
|
|
232
|
-
data: {
|
|
233
|
-
access_token: string;
|
|
234
|
-
refresh_token: string;
|
|
235
|
-
};
|
|
236
|
-
}
|
|
237
|
-
export interface RefreshTokenRequest {
|
|
238
|
-
refresh_token: string;
|
|
239
|
-
}
|
|
240
|
-
export interface RefreshTokenResponse {
|
|
241
|
-
success: boolean;
|
|
242
|
-
response_data: {
|
|
243
|
-
access_token: string;
|
|
244
|
-
refresh_token: string;
|
|
245
|
-
expires_at: string;
|
|
246
|
-
company_id: string;
|
|
247
|
-
company_name: string;
|
|
248
|
-
email_verified: boolean;
|
|
249
|
-
};
|
|
250
|
-
message: string;
|
|
251
|
-
}
|
|
252
|
-
export interface TokenInfo {
|
|
253
|
-
accessToken: string;
|
|
254
|
-
refreshToken: string;
|
|
255
|
-
expiresAt: string;
|
|
256
|
-
userId?: string;
|
|
257
|
-
}
|
|
258
|
-
export interface SessionResponse {
|
|
259
|
-
data: {
|
|
260
|
-
session_id: string;
|
|
261
|
-
state: SessionState;
|
|
262
|
-
device_info?: Record<string, string>;
|
|
263
|
-
company_id?: string;
|
|
264
|
-
status?: string;
|
|
265
|
-
expires_at?: string;
|
|
266
|
-
user_id?: string | null;
|
|
267
|
-
auto_login?: boolean;
|
|
268
|
-
access_token?: string;
|
|
269
|
-
refresh_token?: string;
|
|
270
|
-
expires_in?: number;
|
|
271
|
-
token_type?: string;
|
|
272
|
-
scope?: string;
|
|
273
|
-
};
|
|
274
|
-
message: string;
|
|
275
|
-
}
|
|
276
67
|
export interface BrokerInfo {
|
|
277
68
|
id: string;
|
|
278
69
|
name: string;
|
|
@@ -284,20 +75,16 @@ export interface BrokerInfo {
|
|
|
284
75
|
logo_path: string;
|
|
285
76
|
is_active: boolean;
|
|
286
77
|
}
|
|
287
|
-
export interface DeviceInfo {
|
|
288
|
-
ip_address: string;
|
|
289
|
-
user_agent: string;
|
|
290
|
-
fingerprint: string;
|
|
291
|
-
}
|
|
292
78
|
export interface BrokerOrderParams {
|
|
293
79
|
broker: 'robinhood' | 'tasty_trade' | 'ninja_trader';
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
80
|
+
order_id?: string;
|
|
81
|
+
orderType: 'Market' | 'Limit' | 'Stop' | 'StopLimit';
|
|
82
|
+
assetType: 'Stock' | 'Option' | 'Crypto' | 'Future';
|
|
297
83
|
action: 'Buy' | 'Sell';
|
|
298
|
-
orderType: 'Market' | 'Limit' | 'Stop' | 'TrailingStop';
|
|
299
|
-
assetType: 'Stock' | 'Option' | 'Crypto' | 'Futures';
|
|
300
84
|
timeInForce: 'day' | 'gtc' | 'gtd' | 'ioc' | 'fok';
|
|
85
|
+
accountNumber: string | number;
|
|
86
|
+
symbol: string;
|
|
87
|
+
orderQty: number;
|
|
301
88
|
price?: number;
|
|
302
89
|
stopPrice?: number;
|
|
303
90
|
}
|
|
@@ -325,32 +112,6 @@ export interface BrokerExtras {
|
|
|
325
112
|
valueEffect?: 'Debit' | 'Credit';
|
|
326
113
|
};
|
|
327
114
|
}
|
|
328
|
-
export interface CryptoOrderOptions {
|
|
329
|
-
quantity?: number;
|
|
330
|
-
notional?: number;
|
|
331
|
-
}
|
|
332
|
-
export interface OptionsOrderOptions {
|
|
333
|
-
strikePrice: number;
|
|
334
|
-
expirationDate: string;
|
|
335
|
-
optionType: 'call' | 'put';
|
|
336
|
-
contractSize?: number;
|
|
337
|
-
}
|
|
338
|
-
export interface OrderResponse {
|
|
339
|
-
success: boolean;
|
|
340
|
-
response_data: {
|
|
341
|
-
orderId: string;
|
|
342
|
-
status: string;
|
|
343
|
-
broker?: string;
|
|
344
|
-
accountNumber?: string;
|
|
345
|
-
};
|
|
346
|
-
message: string;
|
|
347
|
-
status_code: number;
|
|
348
|
-
}
|
|
349
|
-
export interface TradingContext {
|
|
350
|
-
broker?: string;
|
|
351
|
-
accountNumber?: string;
|
|
352
|
-
accountId?: string;
|
|
353
|
-
}
|
|
354
115
|
export interface BrokerConnection {
|
|
355
116
|
id: string;
|
|
356
117
|
broker_id: string;
|
|
@@ -369,44 +130,6 @@ export interface BrokerConnection {
|
|
|
369
130
|
};
|
|
370
131
|
needs_reauth: boolean;
|
|
371
132
|
}
|
|
372
|
-
export interface OrdersFilter {
|
|
373
|
-
broker_id?: string;
|
|
374
|
-
connection_id?: string;
|
|
375
|
-
account_id?: string;
|
|
376
|
-
symbol?: string;
|
|
377
|
-
status?: 'filled' | 'pending' | 'cancelled' | 'rejected' | 'partially_filled';
|
|
378
|
-
side?: 'buy' | 'sell';
|
|
379
|
-
asset_type?: 'stock' | 'option' | 'crypto' | 'future';
|
|
380
|
-
limit?: number;
|
|
381
|
-
offset?: number;
|
|
382
|
-
created_after?: string;
|
|
383
|
-
created_before?: string;
|
|
384
|
-
with_metadata?: boolean;
|
|
385
|
-
}
|
|
386
|
-
export interface PositionsFilter {
|
|
387
|
-
broker_id?: string;
|
|
388
|
-
connection_id?: string;
|
|
389
|
-
account_id?: string;
|
|
390
|
-
symbol?: string;
|
|
391
|
-
side?: 'long' | 'short';
|
|
392
|
-
asset_type?: 'stock' | 'option' | 'crypto' | 'future';
|
|
393
|
-
position_status?: 'open' | 'closed';
|
|
394
|
-
limit?: number;
|
|
395
|
-
offset?: number;
|
|
396
|
-
updated_after?: string;
|
|
397
|
-
updated_before?: string;
|
|
398
|
-
with_metadata?: boolean;
|
|
399
|
-
}
|
|
400
|
-
export interface AccountsFilter {
|
|
401
|
-
broker_id?: string;
|
|
402
|
-
connection_id?: string;
|
|
403
|
-
account_type?: 'margin' | 'cash' | 'crypto_wallet' | 'live' | 'sim';
|
|
404
|
-
status?: 'active' | 'inactive';
|
|
405
|
-
currency?: string;
|
|
406
|
-
limit?: number;
|
|
407
|
-
offset?: number;
|
|
408
|
-
with_metadata?: boolean;
|
|
409
|
-
}
|
|
410
133
|
export interface BrokerDataOrder {
|
|
411
134
|
id: string;
|
|
412
135
|
broker_id: string;
|
|
@@ -466,6 +189,44 @@ export interface BrokerDataAccount {
|
|
|
466
189
|
last_synced_at: string;
|
|
467
190
|
metadata?: Record<string, any>;
|
|
468
191
|
}
|
|
192
|
+
export interface OrdersFilter {
|
|
193
|
+
broker_id?: string;
|
|
194
|
+
connection_id?: string;
|
|
195
|
+
account_id?: string;
|
|
196
|
+
symbol?: string;
|
|
197
|
+
status?: 'filled' | 'pending' | 'cancelled' | 'rejected' | 'partially_filled';
|
|
198
|
+
side?: 'buy' | 'sell';
|
|
199
|
+
asset_type?: 'stock' | 'option' | 'crypto' | 'future';
|
|
200
|
+
limit?: number;
|
|
201
|
+
offset?: number;
|
|
202
|
+
created_after?: string;
|
|
203
|
+
created_before?: string;
|
|
204
|
+
with_metadata?: boolean;
|
|
205
|
+
}
|
|
206
|
+
export interface PositionsFilter {
|
|
207
|
+
broker_id?: string;
|
|
208
|
+
connection_id?: string;
|
|
209
|
+
account_id?: string;
|
|
210
|
+
symbol?: string;
|
|
211
|
+
side?: 'long' | 'short';
|
|
212
|
+
asset_type?: 'stock' | 'option' | 'crypto' | 'future';
|
|
213
|
+
position_status?: 'open' | 'closed';
|
|
214
|
+
limit?: number;
|
|
215
|
+
offset?: number;
|
|
216
|
+
updated_after?: string;
|
|
217
|
+
updated_before?: string;
|
|
218
|
+
with_metadata?: boolean;
|
|
219
|
+
}
|
|
220
|
+
export interface AccountsFilter {
|
|
221
|
+
broker_id?: string;
|
|
222
|
+
connection_id?: string;
|
|
223
|
+
account_type?: 'margin' | 'cash' | 'crypto_wallet' | 'live' | 'sim';
|
|
224
|
+
status?: 'active' | 'inactive';
|
|
225
|
+
currency?: string;
|
|
226
|
+
limit?: number;
|
|
227
|
+
offset?: number;
|
|
228
|
+
with_metadata?: boolean;
|
|
229
|
+
}
|
|
469
230
|
export interface FilteredOrdersResponse {
|
|
470
231
|
orders: BrokerDataOrder[];
|
|
471
232
|
total: number;
|
|
@@ -484,3 +245,14 @@ export interface FilteredAccountsResponse {
|
|
|
484
245
|
limit: number;
|
|
485
246
|
offset: number;
|
|
486
247
|
}
|
|
248
|
+
export interface DisconnectCompanyResponse {
|
|
249
|
+
success: boolean;
|
|
250
|
+
response_data: {
|
|
251
|
+
connection_id: string;
|
|
252
|
+
action: 'company_access_removed' | 'connection_deleted';
|
|
253
|
+
remaining_companies?: number;
|
|
254
|
+
message: string;
|
|
255
|
+
};
|
|
256
|
+
message: string;
|
|
257
|
+
status_code: number;
|
|
258
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Core API types
|
|
3
|
+
*/
|
|
4
|
+
import { ApiPaginationInfo } from '../common/pagination';
|
|
5
|
+
export interface ApiConfig {
|
|
6
|
+
baseUrl: string;
|
|
7
|
+
apiKey?: string;
|
|
8
|
+
sandbox?: boolean;
|
|
9
|
+
}
|
|
10
|
+
export interface ApiResponse<T> {
|
|
11
|
+
success: boolean;
|
|
12
|
+
response_data: T;
|
|
13
|
+
message: string;
|
|
14
|
+
status_code: number;
|
|
15
|
+
pagination?: ApiPaginationInfo;
|
|
16
|
+
}
|
|
17
|
+
export interface ApiError {
|
|
18
|
+
code: string;
|
|
19
|
+
message: string;
|
|
20
|
+
details?: Record<string, any>;
|
|
21
|
+
}
|
|
22
|
+
export interface RequestHeaders {
|
|
23
|
+
'Content-Type': string;
|
|
24
|
+
'X-API-Key'?: string;
|
|
25
|
+
Authorization?: string;
|
|
26
|
+
'X-CSRF-Token'?: string;
|
|
27
|
+
token?: string;
|
|
28
|
+
'User-Agent'?: string;
|
|
29
|
+
'X-Device-Info'?: string;
|
|
30
|
+
'X-Request-ID'?: string;
|
|
31
|
+
'X-Request-Timestamp'?: string;
|
|
32
|
+
'X-Request-Signature'?: string;
|
|
33
|
+
[key: string]: string | undefined;
|
|
34
|
+
}
|
|
35
|
+
export interface PortalResponse {
|
|
36
|
+
portalUrl: string;
|
|
37
|
+
token: string;
|
|
38
|
+
expiresIn: number;
|
|
39
|
+
}
|
|
40
|
+
export interface PortalUrlResponse {
|
|
41
|
+
success: boolean;
|
|
42
|
+
message: string;
|
|
43
|
+
data: {
|
|
44
|
+
portal_url: string;
|
|
45
|
+
};
|
|
46
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Error response types matching API documentation
|
|
3
|
+
*/
|
|
4
|
+
export interface TradeAccessDeniedError {
|
|
5
|
+
success: false;
|
|
6
|
+
response_data: null;
|
|
7
|
+
message: string;
|
|
8
|
+
status_code: 403;
|
|
9
|
+
category: 'TRADE_ACCESS_DENIED';
|
|
10
|
+
}
|
|
11
|
+
export interface OrderNotFoundError {
|
|
12
|
+
success: false;
|
|
13
|
+
response_data: null;
|
|
14
|
+
message: string;
|
|
15
|
+
status_code: 404;
|
|
16
|
+
category: 'ORDER_NOT_FOUND';
|
|
17
|
+
}
|
|
18
|
+
export interface ValidationError {
|
|
19
|
+
success: false;
|
|
20
|
+
response_data: null;
|
|
21
|
+
message: string;
|
|
22
|
+
status_code: 400;
|
|
23
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Order-related types
|
|
3
|
+
*/
|
|
4
|
+
export interface Order {
|
|
5
|
+
symbol: string;
|
|
6
|
+
side: 'buy' | 'sell';
|
|
7
|
+
quantity: number;
|
|
8
|
+
type_: 'market' | 'limit' | 'stop' | 'stop_limit';
|
|
9
|
+
price?: number;
|
|
10
|
+
stopPrice?: number;
|
|
11
|
+
timeInForce: 'day' | 'gtc' | 'opg' | 'cls' | 'ioc' | 'fok';
|
|
12
|
+
}
|
|
13
|
+
export interface OptionsOrder extends Order {
|
|
14
|
+
optionType: 'call' | 'put';
|
|
15
|
+
strikePrice: number;
|
|
16
|
+
expirationDate: string;
|
|
17
|
+
}
|
|
18
|
+
export interface CryptoOrderOptions {
|
|
19
|
+
quantity?: number;
|
|
20
|
+
notional?: number;
|
|
21
|
+
}
|
|
22
|
+
export interface OptionsOrderOptions {
|
|
23
|
+
strikePrice: number;
|
|
24
|
+
expirationDate: string;
|
|
25
|
+
optionType: 'call' | 'put';
|
|
26
|
+
contractSize?: number;
|
|
27
|
+
}
|
|
28
|
+
export interface OrderResponse {
|
|
29
|
+
success: boolean;
|
|
30
|
+
response_data: any;
|
|
31
|
+
message: string;
|
|
32
|
+
status_code: number;
|
|
33
|
+
category?: string;
|
|
34
|
+
}
|
|
35
|
+
export interface TradingContext {
|
|
36
|
+
broker?: string;
|
|
37
|
+
accountNumber?: string;
|
|
38
|
+
accountId?: string;
|
|
39
|
+
}
|
|
@@ -1,6 +1,31 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* Portfolio-related types
|
|
3
3
|
*/
|
|
4
|
+
export interface PortfolioSnapshot {
|
|
5
|
+
timestamp: string;
|
|
6
|
+
totalValue: number;
|
|
7
|
+
cash: number;
|
|
8
|
+
equity: number;
|
|
9
|
+
positions: {
|
|
10
|
+
symbol: string;
|
|
11
|
+
quantity: number;
|
|
12
|
+
averagePrice: number;
|
|
13
|
+
currentPrice: number;
|
|
14
|
+
marketValue: number;
|
|
15
|
+
unrealizedPnL: number;
|
|
16
|
+
}[];
|
|
17
|
+
}
|
|
18
|
+
export interface PerformanceMetrics {
|
|
19
|
+
totalReturn: number;
|
|
20
|
+
dailyReturn: number;
|
|
21
|
+
weeklyReturn: number;
|
|
22
|
+
monthlyReturn: number;
|
|
23
|
+
yearlyReturn: number;
|
|
24
|
+
maxDrawdown: number;
|
|
25
|
+
sharpeRatio: number;
|
|
26
|
+
beta: number;
|
|
27
|
+
alpha: number;
|
|
28
|
+
}
|
|
4
29
|
export interface Holding {
|
|
5
30
|
symbol: string;
|
|
6
31
|
quantity: number;
|
|
@@ -12,15 +37,6 @@ export interface Holding {
|
|
|
12
37
|
costBasis: number;
|
|
13
38
|
currency: string;
|
|
14
39
|
}
|
|
15
|
-
export interface Order {
|
|
16
|
-
symbol: string;
|
|
17
|
-
quantity: number;
|
|
18
|
-
side: 'buy' | 'sell';
|
|
19
|
-
type_: 'market' | 'limit' | 'stop' | 'stop_limit';
|
|
20
|
-
timeInForce: 'day' | 'gtc' | 'opg' | 'cls' | 'ioc' | 'fok';
|
|
21
|
-
price?: number;
|
|
22
|
-
stopPrice?: number;
|
|
23
|
-
}
|
|
24
40
|
export interface Portfolio {
|
|
25
41
|
id: string;
|
|
26
42
|
name: string;
|
|
@@ -37,14 +53,3 @@ export interface Portfolio {
|
|
|
37
53
|
positions: Holding[];
|
|
38
54
|
performance: PerformanceMetrics;
|
|
39
55
|
}
|
|
40
|
-
export interface PerformanceMetrics {
|
|
41
|
-
totalReturn: number;
|
|
42
|
-
dailyReturn: number;
|
|
43
|
-
weeklyReturn: number;
|
|
44
|
-
monthlyReturn: number;
|
|
45
|
-
yearlyReturn: number;
|
|
46
|
-
maxDrawdown: number;
|
|
47
|
-
sharpeRatio: number;
|
|
48
|
-
beta: number;
|
|
49
|
-
alpha: number;
|
|
50
|
-
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pagination-related types and classes
|
|
3
|
+
*/
|
|
4
|
+
export interface ApiPaginationInfo {
|
|
5
|
+
has_more: boolean;
|
|
6
|
+
next_offset: number;
|
|
7
|
+
current_offset: number;
|
|
8
|
+
limit: number;
|
|
9
|
+
}
|
|
10
|
+
export interface PaginationMetadata {
|
|
11
|
+
hasMore: boolean;
|
|
12
|
+
nextOffset: number;
|
|
13
|
+
currentOffset: number;
|
|
14
|
+
limit: number;
|
|
15
|
+
currentPage: number;
|
|
16
|
+
hasNext: boolean;
|
|
17
|
+
hasPrevious: boolean;
|
|
18
|
+
}
|
|
19
|
+
export declare class PaginatedResult<T> {
|
|
20
|
+
readonly data: T;
|
|
21
|
+
readonly metadata: PaginationMetadata;
|
|
22
|
+
private navigationCallback?;
|
|
23
|
+
constructor(data: T, paginationInfo: ApiPaginationInfo, navigationCallback?: (offset: number, limit: number) => Promise<PaginatedResult<T>>);
|
|
24
|
+
get hasNext(): boolean;
|
|
25
|
+
get hasPrevious(): boolean;
|
|
26
|
+
get currentPage(): number;
|
|
27
|
+
nextPage(): Promise<PaginatedResult<T> | null>;
|
|
28
|
+
previousPage(): Promise<PaginatedResult<T> | null>;
|
|
29
|
+
goToPage(pageNumber: number): Promise<PaginatedResult<T> | null>;
|
|
30
|
+
firstPage(): Promise<PaginatedResult<T> | null>;
|
|
31
|
+
lastPage(): Promise<PaginatedResult<T> | null>;
|
|
32
|
+
getPaginationInfo(): string;
|
|
33
|
+
}
|