@finatic/client 0.0.132 → 0.0.134
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 -4
- package/dist/index.d.ts +471 -735
- package/dist/index.js +862 -756
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +863 -754
- 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 -18
- 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
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,81 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* Pagination-related types and classes
|
|
3
|
+
*/
|
|
4
|
+
interface ApiPaginationInfo {
|
|
5
|
+
has_more: boolean;
|
|
6
|
+
next_offset: number;
|
|
7
|
+
current_offset: number;
|
|
8
|
+
limit: number;
|
|
9
|
+
}
|
|
10
|
+
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
|
+
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
|
+
}
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Core API types
|
|
37
|
+
*/
|
|
38
|
+
|
|
39
|
+
interface ApiConfig {
|
|
40
|
+
baseUrl: string;
|
|
41
|
+
apiKey?: string;
|
|
42
|
+
sandbox?: boolean;
|
|
43
|
+
}
|
|
44
|
+
interface ApiResponse<T> {
|
|
45
|
+
success: boolean;
|
|
46
|
+
response_data: T;
|
|
47
|
+
message: string;
|
|
48
|
+
status_code: number;
|
|
49
|
+
pagination?: ApiPaginationInfo;
|
|
50
|
+
}
|
|
51
|
+
interface RequestHeaders {
|
|
52
|
+
'Content-Type': string;
|
|
53
|
+
'X-API-Key'?: string;
|
|
54
|
+
Authorization?: string;
|
|
55
|
+
'X-CSRF-Token'?: string;
|
|
56
|
+
token?: string;
|
|
57
|
+
'User-Agent'?: string;
|
|
58
|
+
'X-Device-Info'?: string;
|
|
59
|
+
'X-Request-ID'?: string;
|
|
60
|
+
'X-Request-Timestamp'?: string;
|
|
61
|
+
'X-Request-Signature'?: string;
|
|
62
|
+
[key: string]: string | undefined;
|
|
63
|
+
}
|
|
64
|
+
interface PortalResponse {
|
|
65
|
+
portalUrl: string;
|
|
66
|
+
token: string;
|
|
67
|
+
expiresIn: number;
|
|
68
|
+
}
|
|
69
|
+
interface PortalUrlResponse {
|
|
70
|
+
success: boolean;
|
|
71
|
+
message: string;
|
|
72
|
+
data: {
|
|
73
|
+
portal_url: string;
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* Authentication-related types
|
|
3
79
|
*/
|
|
4
80
|
interface SessionInitResponse {
|
|
5
81
|
success: boolean;
|
|
@@ -36,13 +112,6 @@ interface OtpVerifyResponse {
|
|
|
36
112
|
token_type: 'Bearer';
|
|
37
113
|
};
|
|
38
114
|
}
|
|
39
|
-
interface PortalUrlResponse {
|
|
40
|
-
success: boolean;
|
|
41
|
-
message: string;
|
|
42
|
-
data: {
|
|
43
|
-
portal_url: string;
|
|
44
|
-
};
|
|
45
|
-
}
|
|
46
115
|
interface UserToken {
|
|
47
116
|
accessToken: string;
|
|
48
117
|
refreshToken: string;
|
|
@@ -51,23 +120,57 @@ interface UserToken {
|
|
|
51
120
|
tokenType: string;
|
|
52
121
|
scope: string;
|
|
53
122
|
}
|
|
54
|
-
interface
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
123
|
+
interface SessionValidationResponse {
|
|
124
|
+
valid: boolean;
|
|
125
|
+
company_id: string;
|
|
126
|
+
status: string;
|
|
58
127
|
}
|
|
59
|
-
interface
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
128
|
+
interface SessionAuthenticateResponse {
|
|
129
|
+
success: boolean;
|
|
130
|
+
message: string;
|
|
131
|
+
data: {
|
|
132
|
+
access_token: string;
|
|
133
|
+
refresh_token: string;
|
|
134
|
+
};
|
|
135
|
+
}
|
|
136
|
+
interface RefreshTokenRequest {
|
|
137
|
+
refresh_token: string;
|
|
138
|
+
}
|
|
139
|
+
interface RefreshTokenResponse {
|
|
140
|
+
success: boolean;
|
|
141
|
+
response_data: {
|
|
142
|
+
access_token: string;
|
|
143
|
+
refresh_token: string;
|
|
144
|
+
expires_at: string;
|
|
145
|
+
company_id: string;
|
|
146
|
+
company_name: string;
|
|
147
|
+
email_verified: boolean;
|
|
148
|
+
};
|
|
149
|
+
message: string;
|
|
150
|
+
}
|
|
151
|
+
interface TokenInfo {
|
|
152
|
+
accessToken: string;
|
|
153
|
+
refreshToken: string;
|
|
154
|
+
expiresAt: string;
|
|
155
|
+
userId?: string;
|
|
156
|
+
}
|
|
157
|
+
interface SessionResponse {
|
|
158
|
+
data: {
|
|
159
|
+
session_id: string;
|
|
160
|
+
state: SessionState;
|
|
161
|
+
device_info?: Record<string, string>;
|
|
162
|
+
company_id?: string;
|
|
163
|
+
status?: string;
|
|
164
|
+
expires_at?: string;
|
|
165
|
+
user_id?: string | null;
|
|
166
|
+
auto_login?: boolean;
|
|
167
|
+
access_token?: string;
|
|
168
|
+
refresh_token?: string;
|
|
169
|
+
expires_in?: number;
|
|
170
|
+
token_type?: string;
|
|
171
|
+
scope?: string;
|
|
172
|
+
};
|
|
173
|
+
message: string;
|
|
71
174
|
}
|
|
72
175
|
declare enum SessionState {
|
|
73
176
|
PENDING = "PENDING",
|
|
@@ -77,25 +180,15 @@ declare enum SessionState {
|
|
|
77
180
|
EXPIRED = "EXPIRED"
|
|
78
181
|
}
|
|
79
182
|
type SessionStatus = SessionState;
|
|
80
|
-
interface
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
}
|
|
85
|
-
interface Order {
|
|
86
|
-
symbol: string;
|
|
87
|
-
side: 'buy' | 'sell';
|
|
88
|
-
quantity: number;
|
|
89
|
-
type_: 'market' | 'limit' | 'stop' | 'stop_limit';
|
|
90
|
-
price?: number;
|
|
91
|
-
stopPrice?: number;
|
|
92
|
-
timeInForce: 'day' | 'gtc' | 'opg' | 'cls' | 'ioc' | 'fok';
|
|
93
|
-
}
|
|
94
|
-
interface OptionsOrder extends Order {
|
|
95
|
-
optionType: 'call' | 'put';
|
|
96
|
-
strikePrice: number;
|
|
97
|
-
expirationDate: string;
|
|
183
|
+
interface DeviceInfo$1 {
|
|
184
|
+
ip_address: string;
|
|
185
|
+
user_agent: string;
|
|
186
|
+
fingerprint: string;
|
|
98
187
|
}
|
|
188
|
+
|
|
189
|
+
/**
|
|
190
|
+
* Broker-related types
|
|
191
|
+
*/
|
|
99
192
|
interface BrokerAccount {
|
|
100
193
|
id: string;
|
|
101
194
|
user_broker_connection_id: string;
|
|
@@ -159,115 +252,6 @@ interface BrokerDataOptions {
|
|
|
159
252
|
account_id?: string;
|
|
160
253
|
symbol?: string;
|
|
161
254
|
}
|
|
162
|
-
interface PortfolioSnapshot {
|
|
163
|
-
timestamp: string;
|
|
164
|
-
totalValue: number;
|
|
165
|
-
cash: number;
|
|
166
|
-
equity: number;
|
|
167
|
-
positions: {
|
|
168
|
-
symbol: string;
|
|
169
|
-
quantity: number;
|
|
170
|
-
averagePrice: number;
|
|
171
|
-
currentPrice: number;
|
|
172
|
-
marketValue: number;
|
|
173
|
-
unrealizedPnL: number;
|
|
174
|
-
}[];
|
|
175
|
-
}
|
|
176
|
-
interface PerformanceMetrics {
|
|
177
|
-
totalReturn: number;
|
|
178
|
-
dailyReturn: number;
|
|
179
|
-
weeklyReturn: number;
|
|
180
|
-
monthlyReturn: number;
|
|
181
|
-
yearlyReturn: number;
|
|
182
|
-
maxDrawdown: number;
|
|
183
|
-
sharpeRatio: number;
|
|
184
|
-
beta: number;
|
|
185
|
-
alpha: number;
|
|
186
|
-
}
|
|
187
|
-
interface Holding {
|
|
188
|
-
symbol: string;
|
|
189
|
-
quantity: number;
|
|
190
|
-
averagePrice: number;
|
|
191
|
-
currentPrice: number;
|
|
192
|
-
marketValue: number;
|
|
193
|
-
unrealizedPnL: number;
|
|
194
|
-
realizedPnL: number;
|
|
195
|
-
costBasis: number;
|
|
196
|
-
currency: string;
|
|
197
|
-
}
|
|
198
|
-
interface Portfolio {
|
|
199
|
-
id: string;
|
|
200
|
-
name: string;
|
|
201
|
-
type: string;
|
|
202
|
-
status: string;
|
|
203
|
-
cash: number;
|
|
204
|
-
buyingPower: number;
|
|
205
|
-
equity: number;
|
|
206
|
-
longMarketValue: number;
|
|
207
|
-
shortMarketValue: number;
|
|
208
|
-
initialMargin: number;
|
|
209
|
-
maintenanceMargin: number;
|
|
210
|
-
lastEquity: number;
|
|
211
|
-
positions: Holding[];
|
|
212
|
-
performance: PerformanceMetrics;
|
|
213
|
-
}
|
|
214
|
-
interface PortalResponse {
|
|
215
|
-
portalUrl: string;
|
|
216
|
-
token: string;
|
|
217
|
-
expiresIn: number;
|
|
218
|
-
}
|
|
219
|
-
interface SessionValidationResponse {
|
|
220
|
-
valid: boolean;
|
|
221
|
-
company_id: string;
|
|
222
|
-
status: string;
|
|
223
|
-
}
|
|
224
|
-
interface SessionAuthenticateResponse {
|
|
225
|
-
success: boolean;
|
|
226
|
-
message: string;
|
|
227
|
-
data: {
|
|
228
|
-
access_token: string;
|
|
229
|
-
refresh_token: string;
|
|
230
|
-
};
|
|
231
|
-
}
|
|
232
|
-
interface RefreshTokenRequest {
|
|
233
|
-
refresh_token: string;
|
|
234
|
-
}
|
|
235
|
-
interface RefreshTokenResponse {
|
|
236
|
-
success: boolean;
|
|
237
|
-
response_data: {
|
|
238
|
-
access_token: string;
|
|
239
|
-
refresh_token: string;
|
|
240
|
-
expires_at: string;
|
|
241
|
-
company_id: string;
|
|
242
|
-
company_name: string;
|
|
243
|
-
email_verified: boolean;
|
|
244
|
-
};
|
|
245
|
-
message: string;
|
|
246
|
-
}
|
|
247
|
-
interface TokenInfo {
|
|
248
|
-
accessToken: string;
|
|
249
|
-
refreshToken: string;
|
|
250
|
-
expiresAt: string;
|
|
251
|
-
userId?: string;
|
|
252
|
-
}
|
|
253
|
-
interface SessionResponse {
|
|
254
|
-
data: {
|
|
255
|
-
session_id: string;
|
|
256
|
-
state: SessionState;
|
|
257
|
-
device_info?: Record<string, string>;
|
|
258
|
-
company_id?: string;
|
|
259
|
-
status?: string;
|
|
260
|
-
expires_at?: string;
|
|
261
|
-
user_id?: string | null;
|
|
262
|
-
auto_login?: boolean;
|
|
263
|
-
access_token?: string;
|
|
264
|
-
refresh_token?: string;
|
|
265
|
-
expires_in?: number;
|
|
266
|
-
token_type?: string;
|
|
267
|
-
scope?: string;
|
|
268
|
-
};
|
|
269
|
-
message: string;
|
|
270
|
-
}
|
|
271
255
|
interface BrokerInfo {
|
|
272
256
|
id: string;
|
|
273
257
|
name: string;
|
|
@@ -279,20 +263,16 @@ interface BrokerInfo {
|
|
|
279
263
|
logo_path: string;
|
|
280
264
|
is_active: boolean;
|
|
281
265
|
}
|
|
282
|
-
interface DeviceInfo$1 {
|
|
283
|
-
ip_address: string;
|
|
284
|
-
user_agent: string;
|
|
285
|
-
fingerprint: string;
|
|
286
|
-
}
|
|
287
266
|
interface BrokerOrderParams {
|
|
288
267
|
broker: 'robinhood' | 'tasty_trade' | 'ninja_trader';
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
268
|
+
order_id?: string;
|
|
269
|
+
orderType: 'Market' | 'Limit' | 'Stop' | 'StopLimit';
|
|
270
|
+
assetType: 'Stock' | 'Option' | 'Crypto' | 'Future';
|
|
292
271
|
action: 'Buy' | 'Sell';
|
|
293
|
-
orderType: 'Market' | 'Limit' | 'Stop' | 'TrailingStop';
|
|
294
|
-
assetType: 'Stock' | 'Option' | 'Crypto' | 'Futures';
|
|
295
272
|
timeInForce: 'day' | 'gtc' | 'gtd' | 'ioc' | 'fok';
|
|
273
|
+
accountNumber: string | number;
|
|
274
|
+
symbol: string;
|
|
275
|
+
orderQty: number;
|
|
296
276
|
price?: number;
|
|
297
277
|
stopPrice?: number;
|
|
298
278
|
}
|
|
@@ -320,32 +300,6 @@ interface BrokerExtras {
|
|
|
320
300
|
valueEffect?: 'Debit' | 'Credit';
|
|
321
301
|
};
|
|
322
302
|
}
|
|
323
|
-
interface CryptoOrderOptions {
|
|
324
|
-
quantity?: number;
|
|
325
|
-
notional?: number;
|
|
326
|
-
}
|
|
327
|
-
interface OptionsOrderOptions {
|
|
328
|
-
strikePrice: number;
|
|
329
|
-
expirationDate: string;
|
|
330
|
-
optionType: 'call' | 'put';
|
|
331
|
-
contractSize?: number;
|
|
332
|
-
}
|
|
333
|
-
interface OrderResponse {
|
|
334
|
-
success: boolean;
|
|
335
|
-
response_data: {
|
|
336
|
-
orderId: string;
|
|
337
|
-
status: string;
|
|
338
|
-
broker?: string;
|
|
339
|
-
accountNumber?: string;
|
|
340
|
-
};
|
|
341
|
-
message: string;
|
|
342
|
-
status_code: number;
|
|
343
|
-
}
|
|
344
|
-
interface TradingContext {
|
|
345
|
-
broker?: string;
|
|
346
|
-
accountNumber?: string;
|
|
347
|
-
accountId?: string;
|
|
348
|
-
}
|
|
349
303
|
interface BrokerConnection {
|
|
350
304
|
id: string;
|
|
351
305
|
broker_id: string;
|
|
@@ -364,44 +318,6 @@ interface BrokerConnection {
|
|
|
364
318
|
};
|
|
365
319
|
needs_reauth: boolean;
|
|
366
320
|
}
|
|
367
|
-
interface OrdersFilter {
|
|
368
|
-
broker_id?: string;
|
|
369
|
-
connection_id?: string;
|
|
370
|
-
account_id?: string;
|
|
371
|
-
symbol?: string;
|
|
372
|
-
status?: 'filled' | 'pending' | 'cancelled' | 'rejected' | 'partially_filled';
|
|
373
|
-
side?: 'buy' | 'sell';
|
|
374
|
-
asset_type?: 'stock' | 'option' | 'crypto' | 'future';
|
|
375
|
-
limit?: number;
|
|
376
|
-
offset?: number;
|
|
377
|
-
created_after?: string;
|
|
378
|
-
created_before?: string;
|
|
379
|
-
with_metadata?: boolean;
|
|
380
|
-
}
|
|
381
|
-
interface PositionsFilter {
|
|
382
|
-
broker_id?: string;
|
|
383
|
-
connection_id?: string;
|
|
384
|
-
account_id?: string;
|
|
385
|
-
symbol?: string;
|
|
386
|
-
side?: 'long' | 'short';
|
|
387
|
-
asset_type?: 'stock' | 'option' | 'crypto' | 'future';
|
|
388
|
-
position_status?: 'open' | 'closed';
|
|
389
|
-
limit?: number;
|
|
390
|
-
offset?: number;
|
|
391
|
-
updated_after?: string;
|
|
392
|
-
updated_before?: string;
|
|
393
|
-
with_metadata?: boolean;
|
|
394
|
-
}
|
|
395
|
-
interface AccountsFilter {
|
|
396
|
-
broker_id?: string;
|
|
397
|
-
connection_id?: string;
|
|
398
|
-
account_type?: 'margin' | 'cash' | 'crypto_wallet' | 'live' | 'sim';
|
|
399
|
-
status?: 'active' | 'inactive';
|
|
400
|
-
currency?: string;
|
|
401
|
-
limit?: number;
|
|
402
|
-
offset?: number;
|
|
403
|
-
with_metadata?: boolean;
|
|
404
|
-
}
|
|
405
321
|
interface BrokerDataOrder {
|
|
406
322
|
id: string;
|
|
407
323
|
broker_id: string;
|
|
@@ -461,6 +377,44 @@ interface BrokerDataAccount {
|
|
|
461
377
|
last_synced_at: string;
|
|
462
378
|
metadata?: Record<string, any>;
|
|
463
379
|
}
|
|
380
|
+
interface OrdersFilter {
|
|
381
|
+
broker_id?: string;
|
|
382
|
+
connection_id?: string;
|
|
383
|
+
account_id?: string;
|
|
384
|
+
symbol?: string;
|
|
385
|
+
status?: 'filled' | 'pending' | 'cancelled' | 'rejected' | 'partially_filled';
|
|
386
|
+
side?: 'buy' | 'sell';
|
|
387
|
+
asset_type?: 'stock' | 'option' | 'crypto' | 'future';
|
|
388
|
+
limit?: number;
|
|
389
|
+
offset?: number;
|
|
390
|
+
created_after?: string;
|
|
391
|
+
created_before?: string;
|
|
392
|
+
with_metadata?: boolean;
|
|
393
|
+
}
|
|
394
|
+
interface PositionsFilter {
|
|
395
|
+
broker_id?: string;
|
|
396
|
+
connection_id?: string;
|
|
397
|
+
account_id?: string;
|
|
398
|
+
symbol?: string;
|
|
399
|
+
side?: 'long' | 'short';
|
|
400
|
+
asset_type?: 'stock' | 'option' | 'crypto' | 'future';
|
|
401
|
+
position_status?: 'open' | 'closed';
|
|
402
|
+
limit?: number;
|
|
403
|
+
offset?: number;
|
|
404
|
+
updated_after?: string;
|
|
405
|
+
updated_before?: string;
|
|
406
|
+
with_metadata?: boolean;
|
|
407
|
+
}
|
|
408
|
+
interface AccountsFilter {
|
|
409
|
+
broker_id?: string;
|
|
410
|
+
connection_id?: string;
|
|
411
|
+
account_type?: 'margin' | 'cash' | 'crypto_wallet' | 'live' | 'sim';
|
|
412
|
+
status?: 'active' | 'inactive';
|
|
413
|
+
currency?: string;
|
|
414
|
+
limit?: number;
|
|
415
|
+
offset?: number;
|
|
416
|
+
with_metadata?: boolean;
|
|
417
|
+
}
|
|
464
418
|
interface FilteredOrdersResponse {
|
|
465
419
|
orders: BrokerDataOrder[];
|
|
466
420
|
total: number;
|
|
@@ -479,7 +433,117 @@ interface FilteredAccountsResponse {
|
|
|
479
433
|
limit: number;
|
|
480
434
|
offset: number;
|
|
481
435
|
}
|
|
436
|
+
interface DisconnectCompanyResponse {
|
|
437
|
+
success: boolean;
|
|
438
|
+
response_data: {
|
|
439
|
+
connection_id: string;
|
|
440
|
+
action: 'company_access_removed' | 'connection_deleted';
|
|
441
|
+
remaining_companies?: number;
|
|
442
|
+
message: string;
|
|
443
|
+
};
|
|
444
|
+
message: string;
|
|
445
|
+
status_code: number;
|
|
446
|
+
}
|
|
447
|
+
|
|
448
|
+
/**
|
|
449
|
+
* Order-related types
|
|
450
|
+
*/
|
|
451
|
+
interface Order {
|
|
452
|
+
symbol: string;
|
|
453
|
+
side: 'buy' | 'sell';
|
|
454
|
+
quantity: number;
|
|
455
|
+
type_: 'market' | 'limit' | 'stop' | 'stop_limit';
|
|
456
|
+
price?: number;
|
|
457
|
+
stopPrice?: number;
|
|
458
|
+
timeInForce: 'day' | 'gtc' | 'opg' | 'cls' | 'ioc' | 'fok';
|
|
459
|
+
}
|
|
460
|
+
interface OptionsOrder extends Order {
|
|
461
|
+
optionType: 'call' | 'put';
|
|
462
|
+
strikePrice: number;
|
|
463
|
+
expirationDate: string;
|
|
464
|
+
}
|
|
465
|
+
interface CryptoOrderOptions {
|
|
466
|
+
quantity?: number;
|
|
467
|
+
notional?: number;
|
|
468
|
+
}
|
|
469
|
+
interface OptionsOrderOptions {
|
|
470
|
+
strikePrice: number;
|
|
471
|
+
expirationDate: string;
|
|
472
|
+
optionType: 'call' | 'put';
|
|
473
|
+
contractSize?: number;
|
|
474
|
+
}
|
|
475
|
+
interface OrderResponse {
|
|
476
|
+
success: boolean;
|
|
477
|
+
response_data: any;
|
|
478
|
+
message: string;
|
|
479
|
+
status_code: number;
|
|
480
|
+
category?: string;
|
|
481
|
+
}
|
|
482
|
+
interface TradingContext {
|
|
483
|
+
broker?: string;
|
|
484
|
+
accountNumber?: string;
|
|
485
|
+
accountId?: string;
|
|
486
|
+
}
|
|
487
|
+
|
|
488
|
+
/**
|
|
489
|
+
* Portfolio-related types
|
|
490
|
+
*/
|
|
491
|
+
interface PortfolioSnapshot {
|
|
492
|
+
timestamp: string;
|
|
493
|
+
totalValue: number;
|
|
494
|
+
cash: number;
|
|
495
|
+
equity: number;
|
|
496
|
+
positions: {
|
|
497
|
+
symbol: string;
|
|
498
|
+
quantity: number;
|
|
499
|
+
averagePrice: number;
|
|
500
|
+
currentPrice: number;
|
|
501
|
+
marketValue: number;
|
|
502
|
+
unrealizedPnL: number;
|
|
503
|
+
}[];
|
|
504
|
+
}
|
|
505
|
+
interface PerformanceMetrics {
|
|
506
|
+
totalReturn: number;
|
|
507
|
+
dailyReturn: number;
|
|
508
|
+
weeklyReturn: number;
|
|
509
|
+
monthlyReturn: number;
|
|
510
|
+
yearlyReturn: number;
|
|
511
|
+
maxDrawdown: number;
|
|
512
|
+
sharpeRatio: number;
|
|
513
|
+
beta: number;
|
|
514
|
+
alpha: number;
|
|
515
|
+
}
|
|
516
|
+
interface Holding {
|
|
517
|
+
symbol: string;
|
|
518
|
+
quantity: number;
|
|
519
|
+
averagePrice: number;
|
|
520
|
+
currentPrice: number;
|
|
521
|
+
marketValue: number;
|
|
522
|
+
unrealizedPnL: number;
|
|
523
|
+
realizedPnL: number;
|
|
524
|
+
costBasis: number;
|
|
525
|
+
currency: string;
|
|
526
|
+
}
|
|
527
|
+
interface Portfolio {
|
|
528
|
+
id: string;
|
|
529
|
+
name: string;
|
|
530
|
+
type: string;
|
|
531
|
+
status: string;
|
|
532
|
+
cash: number;
|
|
533
|
+
buyingPower: number;
|
|
534
|
+
equity: number;
|
|
535
|
+
longMarketValue: number;
|
|
536
|
+
shortMarketValue: number;
|
|
537
|
+
initialMargin: number;
|
|
538
|
+
maintenanceMargin: number;
|
|
539
|
+
lastEquity: number;
|
|
540
|
+
positions: Holding[];
|
|
541
|
+
performance: PerformanceMetrics;
|
|
542
|
+
}
|
|
482
543
|
|
|
544
|
+
/**
|
|
545
|
+
* Theme-related types
|
|
546
|
+
*/
|
|
483
547
|
interface Theme {
|
|
484
548
|
mode: 'light' | 'dark';
|
|
485
549
|
primaryColor: string;
|
|
@@ -582,16 +646,6 @@ interface Theme {
|
|
|
582
646
|
};
|
|
583
647
|
}
|
|
584
648
|
|
|
585
|
-
interface SDKConfig {
|
|
586
|
-
token: string;
|
|
587
|
-
theme?: Theme;
|
|
588
|
-
sandbox?: boolean;
|
|
589
|
-
}
|
|
590
|
-
interface PortalConfig$1 {
|
|
591
|
-
companyId: string;
|
|
592
|
-
theme?: Theme;
|
|
593
|
-
}
|
|
594
|
-
|
|
595
649
|
interface PortalConfig {
|
|
596
650
|
width?: string;
|
|
597
651
|
height?: string;
|
|
@@ -715,110 +769,32 @@ interface PortalOptions {
|
|
|
715
769
|
onEvent?: (type: string, data: any) => void;
|
|
716
770
|
/** Optional theme configuration for the portal */
|
|
717
771
|
theme?: PortalTheme;
|
|
772
|
+
/** Optional list of broker names to filter by (only these brokers will be shown) */
|
|
773
|
+
brokers?: string[];
|
|
718
774
|
}
|
|
719
775
|
|
|
720
776
|
/**
|
|
721
|
-
* Error
|
|
777
|
+
* Error response types matching API documentation
|
|
722
778
|
*/
|
|
723
|
-
interface
|
|
724
|
-
|
|
779
|
+
interface TradeAccessDeniedError {
|
|
780
|
+
success: false;
|
|
781
|
+
response_data: null;
|
|
725
782
|
message: string;
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
interface ApiError$1 extends BaseError$1 {
|
|
729
|
-
status: number;
|
|
730
|
-
headers?: Record<string, string>;
|
|
731
|
-
}
|
|
732
|
-
interface SessionError extends BaseError$1 {
|
|
733
|
-
sessionId?: string;
|
|
734
|
-
status?: string;
|
|
735
|
-
}
|
|
736
|
-
interface AuthenticationError extends BaseError$1 {
|
|
737
|
-
userId?: string;
|
|
738
|
-
tokenType?: string;
|
|
739
|
-
}
|
|
740
|
-
interface AuthorizationError extends BaseError$1 {
|
|
741
|
-
resource?: string;
|
|
742
|
-
permission?: string;
|
|
743
|
-
}
|
|
744
|
-
interface RateLimitError extends BaseError$1 {
|
|
745
|
-
retryAfter?: number;
|
|
746
|
-
limit?: number;
|
|
747
|
-
remaining?: number;
|
|
748
|
-
}
|
|
749
|
-
interface TokenError extends BaseError$1 {
|
|
750
|
-
tokenType?: string;
|
|
751
|
-
expiresAt?: string;
|
|
752
|
-
}
|
|
753
|
-
interface ValidationError extends BaseError$1 {
|
|
754
|
-
field?: string;
|
|
755
|
-
value?: any;
|
|
756
|
-
constraints?: string[];
|
|
757
|
-
}
|
|
758
|
-
interface NetworkError extends BaseError$1 {
|
|
759
|
-
url?: string;
|
|
760
|
-
method?: string;
|
|
761
|
-
status?: number;
|
|
762
|
-
}
|
|
763
|
-
interface SecurityError extends BaseError$1 {
|
|
764
|
-
securityContext?: Record<string, any>;
|
|
765
|
-
validationResult?: Record<string, any>;
|
|
766
|
-
}
|
|
767
|
-
|
|
768
|
-
interface ApiPaginationInfo {
|
|
769
|
-
has_more: boolean;
|
|
770
|
-
next_offset: number;
|
|
771
|
-
current_offset: number;
|
|
772
|
-
limit: number;
|
|
783
|
+
status_code: 403;
|
|
784
|
+
category: 'TRADE_ACCESS_DENIED';
|
|
773
785
|
}
|
|
774
|
-
interface
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
hasNext: boolean;
|
|
781
|
-
hasPrevious: boolean;
|
|
786
|
+
interface OrderNotFoundError {
|
|
787
|
+
success: false;
|
|
788
|
+
response_data: null;
|
|
789
|
+
message: string;
|
|
790
|
+
status_code: 404;
|
|
791
|
+
category: 'ORDER_NOT_FOUND';
|
|
782
792
|
}
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
get hasNext(): boolean;
|
|
789
|
-
get hasPrevious(): boolean;
|
|
790
|
-
get currentPage(): number;
|
|
791
|
-
/**
|
|
792
|
-
* Navigate to the next page
|
|
793
|
-
* @returns Promise<PaginatedResult<T> | null> - Next page result or null if no next page
|
|
794
|
-
*/
|
|
795
|
-
nextPage(): Promise<PaginatedResult<T> | null>;
|
|
796
|
-
/**
|
|
797
|
-
* Navigate to the previous page
|
|
798
|
-
* @returns Promise<PaginatedResult<T> | null> - Previous page result or null if no previous page
|
|
799
|
-
*/
|
|
800
|
-
previousPage(): Promise<PaginatedResult<T> | null>;
|
|
801
|
-
/**
|
|
802
|
-
* Navigate to a specific page
|
|
803
|
-
* @param pageNumber - The page number to navigate to (1-based)
|
|
804
|
-
* @returns Promise<PaginatedResult<T> | null> - Page result or null if page doesn't exist
|
|
805
|
-
*/
|
|
806
|
-
goToPage(pageNumber: number): Promise<PaginatedResult<T> | null>;
|
|
807
|
-
/**
|
|
808
|
-
* Get the first page
|
|
809
|
-
* @returns Promise<PaginatedResult<T> | null> - First page result or null if error
|
|
810
|
-
*/
|
|
811
|
-
firstPage(): Promise<PaginatedResult<T> | null>;
|
|
812
|
-
/**
|
|
813
|
-
* Get the last page (this is a best effort - we don't know the total count)
|
|
814
|
-
* @returns Promise<PaginatedResult<T> | null> - Last page result or null if error
|
|
815
|
-
*/
|
|
816
|
-
lastPage(): Promise<PaginatedResult<T> | null>;
|
|
817
|
-
/**
|
|
818
|
-
* Get pagination info as a string
|
|
819
|
-
* @returns string - Human readable pagination info
|
|
820
|
-
*/
|
|
821
|
-
getPaginationInfo(): string;
|
|
793
|
+
interface ValidationError {
|
|
794
|
+
success: false;
|
|
795
|
+
response_data: null;
|
|
796
|
+
message: string;
|
|
797
|
+
status_code: 400;
|
|
822
798
|
}
|
|
823
799
|
|
|
824
800
|
declare class BaseError extends Error {
|
|
@@ -830,6 +806,27 @@ declare class ApiError extends BaseError {
|
|
|
830
806
|
readonly details?: Record<string, any> | undefined;
|
|
831
807
|
constructor(status: number, message: string, details?: Record<string, any> | undefined);
|
|
832
808
|
}
|
|
809
|
+
declare class SessionError extends ApiError {
|
|
810
|
+
constructor(message: string, details?: Record<string, any>);
|
|
811
|
+
}
|
|
812
|
+
declare class AuthenticationError extends ApiError {
|
|
813
|
+
constructor(message: string, details?: Record<string, any>);
|
|
814
|
+
}
|
|
815
|
+
declare class AuthorizationError extends ApiError {
|
|
816
|
+
constructor(message: string, details?: Record<string, any>);
|
|
817
|
+
}
|
|
818
|
+
declare class RateLimitError extends ApiError {
|
|
819
|
+
constructor(message: string, details?: Record<string, any>);
|
|
820
|
+
}
|
|
821
|
+
declare class TokenError extends BaseError {
|
|
822
|
+
constructor(message: string);
|
|
823
|
+
}
|
|
824
|
+
declare class NetworkError extends BaseError {
|
|
825
|
+
constructor(message: string);
|
|
826
|
+
}
|
|
827
|
+
declare class SecurityError extends BaseError {
|
|
828
|
+
constructor(message: string);
|
|
829
|
+
}
|
|
833
830
|
declare class CompanyAccessError extends ApiError {
|
|
834
831
|
constructor(message: string, details?: Record<string, any>);
|
|
835
832
|
}
|
|
@@ -840,7 +837,7 @@ declare class OrderValidationError extends ApiError {
|
|
|
840
837
|
constructor(message: string, details?: Record<string, any>);
|
|
841
838
|
}
|
|
842
839
|
|
|
843
|
-
declare class ApiClient
|
|
840
|
+
declare class ApiClient {
|
|
844
841
|
private readonly baseUrl;
|
|
845
842
|
protected readonly deviceInfo?: DeviceInfo$1;
|
|
846
843
|
protected currentSessionState: SessionState | null;
|
|
@@ -922,95 +919,63 @@ declare class ApiClient$1 {
|
|
|
922
919
|
getPortalUrl(sessionId: string): Promise<PortalUrlResponse>;
|
|
923
920
|
validatePortalSession(sessionId: string, signature: string): Promise<SessionValidationResponse>;
|
|
924
921
|
completePortalSession(sessionId: string): Promise<PortalUrlResponse>;
|
|
925
|
-
getHoldings(
|
|
926
|
-
data: Holding[];
|
|
927
|
-
}>;
|
|
928
|
-
getOrders(accessToken: string): Promise<{
|
|
929
|
-
data: Order[];
|
|
930
|
-
}>;
|
|
931
|
-
getPortfolio(accessToken: string): Promise<{
|
|
932
|
-
data: Portfolio;
|
|
933
|
-
}>;
|
|
934
|
-
placeOrder(accessToken: string, order: Order): Promise<void>;
|
|
935
|
-
getHoldingsAuto(): Promise<{
|
|
922
|
+
getHoldings(): Promise<{
|
|
936
923
|
data: Holding[];
|
|
937
924
|
}>;
|
|
938
|
-
|
|
925
|
+
getOrders(): Promise<{
|
|
939
926
|
data: Order[];
|
|
940
927
|
}>;
|
|
941
|
-
|
|
928
|
+
getPortfolio(): Promise<{
|
|
942
929
|
data: Portfolio;
|
|
943
930
|
}>;
|
|
944
|
-
|
|
945
|
-
placeBrokerOrder(accessToken: string, params: Partial<BrokerOrderParams> & {
|
|
931
|
+
placeBrokerOrder(params: Partial<BrokerOrderParams> & {
|
|
946
932
|
symbol: string;
|
|
947
933
|
orderQty: number;
|
|
948
934
|
action: 'Buy' | 'Sell';
|
|
949
|
-
orderType: 'Market' | 'Limit' | 'Stop' | '
|
|
950
|
-
assetType: 'Stock' | 'Option' | 'Crypto' | '
|
|
951
|
-
}, extras?: BrokerExtras): Promise<OrderResponse>;
|
|
952
|
-
cancelBrokerOrder(orderId: string, broker?: 'robinhood' | 'tasty_trade' | 'ninja_trader', extras?: any): Promise<OrderResponse>;
|
|
953
|
-
modifyBrokerOrder(orderId: string, params: Partial<BrokerOrderParams>, broker?: 'robinhood' | 'tasty_trade' | 'ninja_trader', extras?: any): Promise<OrderResponse>;
|
|
935
|
+
orderType: 'Market' | 'Limit' | 'Stop' | 'StopLimit';
|
|
936
|
+
assetType: 'Stock' | 'Option' | 'Crypto' | 'Future';
|
|
937
|
+
}, extras?: BrokerExtras, connection_id?: string): Promise<OrderResponse>;
|
|
938
|
+
cancelBrokerOrder(orderId: string, broker?: 'robinhood' | 'tasty_trade' | 'ninja_trader', extras?: any, connection_id?: string): Promise<OrderResponse>;
|
|
939
|
+
modifyBrokerOrder(orderId: string, params: Partial<BrokerOrderParams>, broker?: 'robinhood' | 'tasty_trade' | 'ninja_trader', extras?: any, connection_id?: string): Promise<OrderResponse>;
|
|
954
940
|
setBroker(broker: 'robinhood' | 'tasty_trade' | 'ninja_trader'): void;
|
|
955
941
|
setAccount(accountNumber: string, accountId?: string): void;
|
|
956
942
|
getTradingContext(): TradingContext;
|
|
957
943
|
clearTradingContext(): void;
|
|
958
|
-
placeStockMarketOrder(
|
|
959
|
-
placeStockLimitOrder(
|
|
960
|
-
placeStockStopOrder(
|
|
961
|
-
placeCryptoMarketOrder(
|
|
962
|
-
placeCryptoLimitOrder(
|
|
963
|
-
placeOptionsMarketOrder(
|
|
964
|
-
placeOptionsLimitOrder(
|
|
965
|
-
placeFuturesMarketOrder(
|
|
966
|
-
placeFuturesLimitOrder(
|
|
944
|
+
placeStockMarketOrder(symbol: string, orderQty: number, action: 'Buy' | 'Sell', broker?: 'robinhood' | 'tasty_trade' | 'ninja_trader', accountNumber?: string, extras?: BrokerExtras, connection_id?: string): Promise<OrderResponse>;
|
|
945
|
+
placeStockLimitOrder(symbol: string, orderQty: number, action: 'Buy' | 'Sell', price: number, timeInForce?: 'day' | 'gtc', broker?: 'robinhood' | 'tasty_trade' | 'ninja_trader', accountNumber?: string, extras?: BrokerExtras, connection_id?: string): Promise<OrderResponse>;
|
|
946
|
+
placeStockStopOrder(symbol: string, orderQty: number, action: 'Buy' | 'Sell', stopPrice: number, timeInForce?: 'day' | 'gtc', broker?: 'robinhood' | 'tasty_trade' | 'ninja_trader', accountNumber?: string, extras?: BrokerExtras, connection_id?: string): Promise<OrderResponse>;
|
|
947
|
+
placeCryptoMarketOrder(symbol: string, orderQty: number, action: 'Buy' | 'Sell', options?: CryptoOrderOptions, broker?: 'robinhood' | 'tasty_trade' | 'ninja_trader', accountNumber?: string, extras?: BrokerExtras): Promise<OrderResponse>;
|
|
948
|
+
placeCryptoLimitOrder(symbol: string, orderQty: number, action: 'Buy' | 'Sell', price: number, timeInForce?: 'day' | 'gtc', options?: CryptoOrderOptions, broker?: 'robinhood' | 'tasty_trade' | 'ninja_trader', accountNumber?: string, extras?: BrokerExtras): Promise<OrderResponse>;
|
|
949
|
+
placeOptionsMarketOrder(symbol: string, orderQty: number, action: 'Buy' | 'Sell', options: OptionsOrderOptions, broker?: 'robinhood' | 'tasty_trade' | 'ninja_trader', accountNumber?: string, extras?: BrokerExtras): Promise<OrderResponse>;
|
|
950
|
+
placeOptionsLimitOrder(symbol: string, orderQty: number, action: 'Buy' | 'Sell', price: number, options: OptionsOrderOptions, timeInForce?: 'day' | 'gtc', broker?: 'robinhood' | 'tasty_trade' | 'ninja_trader', accountNumber?: string, extras?: BrokerExtras): Promise<OrderResponse>;
|
|
951
|
+
placeFuturesMarketOrder(symbol: string, orderQty: number, action: 'Buy' | 'Sell', broker?: 'robinhood' | 'tasty_trade' | 'ninja_trader', accountNumber?: string, extras?: BrokerExtras): Promise<OrderResponse>;
|
|
952
|
+
placeFuturesLimitOrder(symbol: string, orderQty: number, action: 'Buy' | 'Sell', price: number, timeInForce?: 'day' | 'gtc', broker?: 'robinhood' | 'tasty_trade' | 'ninja_trader', accountNumber?: string, extras?: BrokerExtras): Promise<OrderResponse>;
|
|
967
953
|
private buildOrderRequestBody;
|
|
968
954
|
private buildModifyRequestBody;
|
|
969
955
|
private applyBrokerDefaults;
|
|
970
|
-
revokeToken(
|
|
956
|
+
revokeToken(): Promise<void>;
|
|
971
957
|
getUserToken(userId: string): Promise<UserToken>;
|
|
958
|
+
/**
|
|
959
|
+
* Get the current session state
|
|
960
|
+
*/
|
|
972
961
|
getCurrentSessionState(): SessionState | null;
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
warnings: null;
|
|
987
|
-
errors: null;
|
|
988
|
-
}>;
|
|
989
|
-
getBrokerOrders(accessToken: string, options?: BrokerDataOptions): Promise<{
|
|
990
|
-
_id: string;
|
|
991
|
-
response_data: BrokerOrder[];
|
|
992
|
-
message: string;
|
|
993
|
-
status_code: number;
|
|
994
|
-
warnings: null;
|
|
995
|
-
errors: null;
|
|
996
|
-
}>;
|
|
997
|
-
getBrokerPositions(accessToken: string, options?: BrokerDataOptions): Promise<{
|
|
998
|
-
_id: string;
|
|
999
|
-
response_data: BrokerPosition[];
|
|
1000
|
-
message: string;
|
|
1001
|
-
status_code: number;
|
|
1002
|
-
warnings: null;
|
|
1003
|
-
errors: null;
|
|
1004
|
-
}>;
|
|
1005
|
-
getBrokerConnections(accessToken: string): Promise<{
|
|
1006
|
-
_id: string;
|
|
1007
|
-
response_data: BrokerConnection[];
|
|
962
|
+
/**
|
|
963
|
+
* Refresh the current session to extend its lifetime
|
|
964
|
+
*/
|
|
965
|
+
refreshSession(): Promise<{
|
|
966
|
+
success: boolean;
|
|
967
|
+
response_data: {
|
|
968
|
+
session_id: string;
|
|
969
|
+
company_id: string;
|
|
970
|
+
status: string;
|
|
971
|
+
expires_at: string;
|
|
972
|
+
user_id: string;
|
|
973
|
+
auto_login: boolean;
|
|
974
|
+
};
|
|
1008
975
|
message: string;
|
|
1009
976
|
status_code: number;
|
|
1010
|
-
warnings: null;
|
|
1011
|
-
errors: null;
|
|
1012
977
|
}>;
|
|
1013
|
-
|
|
978
|
+
getBrokerList(): Promise<{
|
|
1014
979
|
_id: string;
|
|
1015
980
|
response_data: BrokerInfo[];
|
|
1016
981
|
message: string;
|
|
@@ -1018,7 +983,7 @@ declare class ApiClient$1 {
|
|
|
1018
983
|
warnings: null;
|
|
1019
984
|
errors: null;
|
|
1020
985
|
}>;
|
|
1021
|
-
|
|
986
|
+
getBrokerAccounts(options?: BrokerDataOptions): Promise<{
|
|
1022
987
|
_id: string;
|
|
1023
988
|
response_data: BrokerAccount[];
|
|
1024
989
|
message: string;
|
|
@@ -1026,7 +991,7 @@ declare class ApiClient$1 {
|
|
|
1026
991
|
warnings: null;
|
|
1027
992
|
errors: null;
|
|
1028
993
|
}>;
|
|
1029
|
-
|
|
994
|
+
getBrokerOrders(options?: BrokerDataOptions): Promise<{
|
|
1030
995
|
_id: string;
|
|
1031
996
|
response_data: BrokerOrder[];
|
|
1032
997
|
message: string;
|
|
@@ -1034,7 +999,7 @@ declare class ApiClient$1 {
|
|
|
1034
999
|
warnings: null;
|
|
1035
1000
|
errors: null;
|
|
1036
1001
|
}>;
|
|
1037
|
-
|
|
1002
|
+
getBrokerPositions(options?: BrokerDataOptions): Promise<{
|
|
1038
1003
|
_id: string;
|
|
1039
1004
|
response_data: BrokerPosition[];
|
|
1040
1005
|
message: string;
|
|
@@ -1042,7 +1007,7 @@ declare class ApiClient$1 {
|
|
|
1042
1007
|
warnings: null;
|
|
1043
1008
|
errors: null;
|
|
1044
1009
|
}>;
|
|
1045
|
-
|
|
1010
|
+
getBrokerConnections(): Promise<{
|
|
1046
1011
|
_id: string;
|
|
1047
1012
|
response_data: BrokerConnection[];
|
|
1048
1013
|
message: string;
|
|
@@ -1050,16 +1015,6 @@ declare class ApiClient$1 {
|
|
|
1050
1015
|
warnings: null;
|
|
1051
1016
|
errors: null;
|
|
1052
1017
|
}>;
|
|
1053
|
-
placeBrokerOrderAuto(params: Partial<BrokerOrderParams> & {
|
|
1054
|
-
symbol: string;
|
|
1055
|
-
orderQty: number;
|
|
1056
|
-
action: 'Buy' | 'Sell';
|
|
1057
|
-
orderType: 'Market' | 'Limit' | 'Stop' | 'TrailingStop';
|
|
1058
|
-
assetType: 'Stock' | 'Option' | 'Crypto' | 'Futures';
|
|
1059
|
-
}, extras?: BrokerExtras): Promise<OrderResponse>;
|
|
1060
|
-
placeStockMarketOrderAuto(symbol: string, orderQty: number, action: 'Buy' | 'Sell', broker?: 'robinhood' | 'tasty_trade' | 'ninja_trader', accountNumber?: string, extras?: BrokerExtras): Promise<OrderResponse>;
|
|
1061
|
-
placeStockLimitOrderAuto(symbol: string, orderQty: number, action: 'Buy' | 'Sell', price: number, timeInForce?: 'day' | 'gtc', broker?: 'robinhood' | 'tasty_trade' | 'ninja_trader', accountNumber?: string, extras?: BrokerExtras): Promise<OrderResponse>;
|
|
1062
|
-
placeStockStopOrderAuto(symbol: string, orderQty: number, action: 'Buy' | 'Sell', stopPrice: number, timeInForce?: 'day' | 'gtc', broker?: 'robinhood' | 'tasty_trade' | 'ninja_trader', accountNumber?: string, extras?: BrokerExtras): Promise<OrderResponse>;
|
|
1063
1018
|
getBrokerOrdersPage(page?: number, perPage?: number, filters?: OrdersFilter): Promise<PaginatedResult<BrokerOrder[]>>;
|
|
1064
1019
|
getBrokerAccountsPage(page?: number, perPage?: number, filters?: AccountsFilter): Promise<PaginatedResult<BrokerAccount[]>>;
|
|
1065
1020
|
getBrokerPositionsPage(page?: number, perPage?: number, filters?: PositionsFilter): Promise<PaginatedResult<BrokerPosition[]>>;
|
|
@@ -1069,6 +1024,12 @@ declare class ApiClient$1 {
|
|
|
1069
1024
|
* @returns false for real API client
|
|
1070
1025
|
*/
|
|
1071
1026
|
isMockClient(): boolean;
|
|
1027
|
+
/**
|
|
1028
|
+
* Disconnect a company from a broker connection
|
|
1029
|
+
* @param connectionId - The connection ID to disconnect
|
|
1030
|
+
* @returns Promise with disconnect response
|
|
1031
|
+
*/
|
|
1032
|
+
disconnectCompany(connectionId: string): Promise<DisconnectCompanyResponse>;
|
|
1072
1033
|
}
|
|
1073
1034
|
|
|
1074
1035
|
type EventCallback = (...args: any[]) => void;
|
|
@@ -1102,13 +1063,13 @@ declare class FinaticConnect extends EventEmitter {
|
|
|
1102
1063
|
private readonly BROKER_LIST_CACHE_DURATION;
|
|
1103
1064
|
private readonly deviceInfo?;
|
|
1104
1065
|
private currentSessionState;
|
|
1066
|
+
private sessionKeepAliveInterval;
|
|
1067
|
+
private readonly SESSION_KEEP_ALIVE_INTERVAL;
|
|
1068
|
+
private readonly SESSION_VALIDATION_TIMEOUT;
|
|
1069
|
+
private readonly SESSION_REFRESH_BUFFER_HOURS;
|
|
1070
|
+
private sessionStartTime;
|
|
1105
1071
|
constructor(options: FinaticConnectOptions, deviceInfo?: DeviceInfo);
|
|
1106
1072
|
private handleTokens;
|
|
1107
|
-
/**
|
|
1108
|
-
* Check if the user is authenticated
|
|
1109
|
-
* @returns True if the user has a valid access token
|
|
1110
|
-
*/
|
|
1111
|
-
isAuthenticated(): boolean;
|
|
1112
1073
|
/**
|
|
1113
1074
|
* Check if the user is fully authenticated (has userId, access token, and refresh token)
|
|
1114
1075
|
* @returns True if the user is fully authenticated and ready for API calls
|
|
@@ -1198,27 +1159,34 @@ declare class FinaticConnect extends EventEmitter {
|
|
|
1198
1159
|
timeInForce: 'day' | 'gtc' | 'gtd' | 'ioc' | 'fok';
|
|
1199
1160
|
broker?: 'robinhood' | 'tasty_trade' | 'ninja_trader';
|
|
1200
1161
|
accountNumber?: string;
|
|
1201
|
-
assetType?: 'Stock' | 'Option' | 'Crypto' | '
|
|
1162
|
+
assetType?: 'Stock' | 'Option' | 'Crypto' | 'Future';
|
|
1163
|
+
order_id?: string;
|
|
1164
|
+
connection_id?: string;
|
|
1202
1165
|
}): Promise<OrderResponse>;
|
|
1203
1166
|
/**
|
|
1204
1167
|
* Cancel a broker order
|
|
1205
1168
|
* @param orderId - The order ID to cancel
|
|
1206
1169
|
* @param broker - Optional broker override
|
|
1170
|
+
* @param connection_id - Optional connection ID for testing bypass
|
|
1207
1171
|
*/
|
|
1208
|
-
cancelOrder(orderId: string, broker?: 'robinhood' | 'tasty_trade' | 'ninja_trader'): Promise<OrderResponse>;
|
|
1172
|
+
cancelOrder(orderId: string, broker?: 'robinhood' | 'tasty_trade' | 'ninja_trader', connection_id?: string): Promise<OrderResponse>;
|
|
1209
1173
|
/**
|
|
1210
1174
|
* Modify a broker order
|
|
1211
1175
|
* @param orderId - The order ID to modify
|
|
1212
1176
|
* @param modifications - The modifications to apply
|
|
1213
1177
|
* @param broker - Optional broker override
|
|
1178
|
+
* @param connection_id - Optional connection ID for testing bypass
|
|
1214
1179
|
*/
|
|
1215
1180
|
modifyOrder(orderId: string, modifications: Partial<{
|
|
1216
|
-
symbol
|
|
1217
|
-
quantity
|
|
1218
|
-
price
|
|
1219
|
-
stopPrice
|
|
1220
|
-
timeInForce
|
|
1221
|
-
|
|
1181
|
+
symbol?: string;
|
|
1182
|
+
quantity?: number;
|
|
1183
|
+
price?: number;
|
|
1184
|
+
stopPrice?: number;
|
|
1185
|
+
timeInForce?: 'day' | 'gtc' | 'gtd' | 'ioc' | 'fok';
|
|
1186
|
+
orderType?: 'Market' | 'Limit' | 'Stop' | 'StopLimit';
|
|
1187
|
+
side?: 'Buy' | 'Sell';
|
|
1188
|
+
order_id?: string;
|
|
1189
|
+
}>, broker?: 'robinhood' | 'tasty_trade' | 'ninja_trader', connection_id?: string): Promise<OrderResponse>;
|
|
1222
1190
|
/**
|
|
1223
1191
|
* Set the broker context for trading
|
|
1224
1192
|
* @param broker - The broker to use for trading
|
|
@@ -1368,15 +1336,36 @@ declare class FinaticConnect extends EventEmitter {
|
|
|
1368
1336
|
*/
|
|
1369
1337
|
getAllAccounts(filter?: AccountsFilter): Promise<BrokerDataAccount[]>;
|
|
1370
1338
|
/**
|
|
1371
|
-
* Register
|
|
1339
|
+
* Register session management (but don't auto-cleanup for 24-hour sessions)
|
|
1372
1340
|
*/
|
|
1373
1341
|
private registerSessionCleanup;
|
|
1342
|
+
/**
|
|
1343
|
+
* Start the session keep-alive mechanism
|
|
1344
|
+
*/
|
|
1345
|
+
private startSessionKeepAlive;
|
|
1346
|
+
/**
|
|
1347
|
+
* Stop the session keep-alive mechanism
|
|
1348
|
+
*/
|
|
1349
|
+
private stopSessionKeepAlive;
|
|
1350
|
+
/**
|
|
1351
|
+
* Validate session for keep-alive purposes and handle automatic refresh
|
|
1352
|
+
*/
|
|
1353
|
+
private validateSessionKeepAlive;
|
|
1354
|
+
/**
|
|
1355
|
+
* Check if the session should be refreshed (after 16 hours)
|
|
1356
|
+
*/
|
|
1357
|
+
private shouldRefreshSession;
|
|
1358
|
+
/**
|
|
1359
|
+
* Automatically refresh the session to extend its lifetime
|
|
1360
|
+
*/
|
|
1361
|
+
private refreshSessionAutomatically;
|
|
1374
1362
|
/**
|
|
1375
1363
|
* Handle session cleanup when page is unloading
|
|
1376
1364
|
*/
|
|
1377
1365
|
private handleSessionCleanup;
|
|
1378
1366
|
/**
|
|
1379
1367
|
* Handle visibility change (mobile browsers)
|
|
1368
|
+
* Note: We don't complete sessions on visibility change for 24-hour sessions
|
|
1380
1369
|
*/
|
|
1381
1370
|
private handleVisibilityChange;
|
|
1382
1371
|
/**
|
|
@@ -1384,218 +1373,13 @@ declare class FinaticConnect extends EventEmitter {
|
|
|
1384
1373
|
* @param sessionId - The session ID to complete
|
|
1385
1374
|
*/
|
|
1386
1375
|
private completeSession;
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
private isSandbox;
|
|
1395
|
-
constructor(config: ApiConfig);
|
|
1396
|
-
private getBaseUrl;
|
|
1397
|
-
private request;
|
|
1398
|
-
getPortalContent(): Promise<ApiResponse<{
|
|
1399
|
-
content: string;
|
|
1400
|
-
}>>;
|
|
1401
|
-
getInitToken(): Promise<ApiResponse<{
|
|
1402
|
-
token: string;
|
|
1403
|
-
}>>;
|
|
1404
|
-
login(otp: string): Promise<ApiResponse<{
|
|
1405
|
-
success: boolean;
|
|
1406
|
-
}>>;
|
|
1407
|
-
verifyOTP(otp: string): Promise<ApiResponse<{
|
|
1408
|
-
userId: string;
|
|
1409
|
-
connectionIds: string[];
|
|
1410
|
-
}>>;
|
|
1411
|
-
getUserProfile(): Promise<ApiResponse<{
|
|
1412
|
-
profile: any;
|
|
1413
|
-
brokers: any[];
|
|
1414
|
-
}>>;
|
|
1415
|
-
getConnectionComplete(): Promise<ApiResponse<{
|
|
1416
|
-
userId: string;
|
|
1417
|
-
connectionIds: string[];
|
|
1418
|
-
}>>;
|
|
1419
|
-
getUserToken(userId: string): Promise<ApiResponse<{
|
|
1420
|
-
accessToken: string;
|
|
1421
|
-
refreshToken: string;
|
|
1422
|
-
}>>;
|
|
1423
|
-
refreshAccessToken(): Promise<ApiResponse<{
|
|
1424
|
-
accessToken: string;
|
|
1425
|
-
refreshToken: string;
|
|
1426
|
-
}>>;
|
|
1427
|
-
revokeTokens(): Promise<ApiResponse<{
|
|
1428
|
-
success: boolean;
|
|
1429
|
-
}>>;
|
|
1430
|
-
connectBroker(brokerId: string): Promise<ApiResponse<{
|
|
1431
|
-
success: boolean;
|
|
1432
|
-
}>>;
|
|
1433
|
-
disconnectBroker(brokerId: string): Promise<ApiResponse<{
|
|
1434
|
-
success: boolean;
|
|
1435
|
-
}>>;
|
|
1436
|
-
getBrokerAccounts(): Promise<ApiResponse<{
|
|
1437
|
-
accounts: any[];
|
|
1438
|
-
}>>;
|
|
1439
|
-
getConnections(): Promise<ApiResponse<{
|
|
1440
|
-
connections: any[];
|
|
1441
|
-
}>>;
|
|
1442
|
-
getConnectionDetails(connectionId: string): Promise<ApiResponse<{
|
|
1443
|
-
connection: any;
|
|
1444
|
-
}>>;
|
|
1445
|
-
getAccounts(filter?: AccountsFilter): Promise<ApiResponse<{
|
|
1446
|
-
accounts: any[];
|
|
1447
|
-
}>>;
|
|
1448
|
-
getHoldings(): Promise<ApiResponse<{
|
|
1449
|
-
holdings: any[];
|
|
1450
|
-
}>>;
|
|
1451
|
-
getBalances(): Promise<ApiResponse<{
|
|
1452
|
-
balances: any;
|
|
1453
|
-
}>>;
|
|
1454
|
-
getTransactions(): Promise<ApiResponse<{
|
|
1455
|
-
transactions: any[];
|
|
1456
|
-
}>>;
|
|
1457
|
-
getPerformance(): Promise<ApiResponse<{
|
|
1458
|
-
performance: any;
|
|
1459
|
-
}>>;
|
|
1460
|
-
getOrders(filter?: OrdersFilter): Promise<ApiResponse<{
|
|
1461
|
-
orders: any[];
|
|
1462
|
-
}>>;
|
|
1463
|
-
getTrades(): Promise<ApiResponse<{
|
|
1464
|
-
trades: any[];
|
|
1465
|
-
}>>;
|
|
1466
|
-
placeOrder(order: any): Promise<ApiResponse<{
|
|
1467
|
-
orderId: string;
|
|
1468
|
-
}>>;
|
|
1469
|
-
cancelOrder(orderId: string): Promise<ApiResponse<{
|
|
1470
|
-
success: boolean;
|
|
1471
|
-
}>>;
|
|
1472
|
-
getOrderStatus(orderId: string): Promise<ApiResponse<{
|
|
1473
|
-
status: string;
|
|
1474
|
-
}>>;
|
|
1475
|
-
getOptionsChain(symbol: string): Promise<ApiResponse<{
|
|
1476
|
-
chain: any[];
|
|
1477
|
-
}>>;
|
|
1478
|
-
getOptionQuote(symbol: string, strike: number, expiry: string): Promise<ApiResponse<{
|
|
1479
|
-
quote: any;
|
|
1480
|
-
}>>;
|
|
1481
|
-
placeOptionsOrder(order: any): Promise<ApiResponse<{
|
|
1482
|
-
orderId: string;
|
|
1483
|
-
}>>;
|
|
1484
|
-
getDailyHistory(): Promise<ApiResponse<{
|
|
1485
|
-
history: any[];
|
|
1486
|
-
}>>;
|
|
1487
|
-
getWeeklySnapshots(): Promise<ApiResponse<{
|
|
1488
|
-
snapshots: any[];
|
|
1489
|
-
}>>;
|
|
1490
|
-
getPortfolioDeltas(): Promise<ApiResponse<{
|
|
1491
|
-
deltas: any[];
|
|
1492
|
-
}>>;
|
|
1493
|
-
getUserLogs(userId: string): Promise<ApiResponse<{
|
|
1494
|
-
logs: any[];
|
|
1495
|
-
}>>;
|
|
1496
|
-
getBrokerOrders(filter?: OrdersFilter): Promise<ApiResponse<FilteredOrdersResponse>>;
|
|
1497
|
-
getBrokerPositions(filter?: PositionsFilter): Promise<ApiResponse<FilteredPositionsResponse>>;
|
|
1498
|
-
getBrokerDataAccounts(filter?: AccountsFilter): Promise<ApiResponse<FilteredAccountsResponse>>;
|
|
1499
|
-
testWebhook(): Promise<ApiResponse<{
|
|
1500
|
-
success: boolean;
|
|
1501
|
-
}>>;
|
|
1502
|
-
private buildQueryParams;
|
|
1503
|
-
getBrokerOrdersPage(page?: number, perPage?: number, filters?: OrdersFilter): Promise<PaginatedResult<any[]>>;
|
|
1504
|
-
getBrokerAccountsPage(page?: number, perPage?: number, filters?: AccountsFilter): Promise<PaginatedResult<any[]>>;
|
|
1505
|
-
getBrokerPositionsPage(page?: number, perPage?: number, filters?: PositionsFilter): Promise<PaginatedResult<any[]>>;
|
|
1506
|
-
getNextPage<T>(previousResult: PaginatedResult<T>, fetchFunction: (offset: number, limit: number) => Promise<PaginatedResult<T>>): Promise<PaginatedResult<T> | null>;
|
|
1507
|
-
}
|
|
1508
|
-
|
|
1509
|
-
interface ITradingService {
|
|
1510
|
-
getAccounts(filter?: AccountsFilter): Promise<BrokerDataAccount[]>;
|
|
1511
|
-
getOrders(filter?: OrdersFilter): Promise<BrokerDataOrder[]>;
|
|
1512
|
-
getPositions(filter?: PositionsFilter): Promise<BrokerDataPosition[]>;
|
|
1513
|
-
placeOrder(order: Order): Promise<string>;
|
|
1514
|
-
cancelOrder(orderId: string): Promise<boolean>;
|
|
1515
|
-
placeOptionsOrder(order: OptionsOrder): Promise<string>;
|
|
1516
|
-
getAccountsPage(page?: number, perPage?: number, filter?: AccountsFilter): Promise<PaginatedResult<BrokerDataAccount[]>>;
|
|
1517
|
-
getOrdersPage(page?: number, perPage?: number, filter?: OrdersFilter): Promise<PaginatedResult<BrokerDataOrder[]>>;
|
|
1518
|
-
getPositionsPage(page?: number, perPage?: number, filter?: PositionsFilter): Promise<PaginatedResult<BrokerDataPosition[]>>;
|
|
1519
|
-
getNextAccountsPage(previousResult: PaginatedResult<BrokerDataAccount[]>): Promise<PaginatedResult<BrokerDataAccount[]> | null>;
|
|
1520
|
-
getNextOrdersPage(previousResult: PaginatedResult<BrokerDataOrder[]>): Promise<PaginatedResult<BrokerDataOrder[]> | null>;
|
|
1521
|
-
getNextPositionsPage(previousResult: PaginatedResult<BrokerDataPosition[]>): Promise<PaginatedResult<BrokerDataPosition[]> | null>;
|
|
1522
|
-
getAllAccounts(filter?: AccountsFilter): Promise<BrokerDataAccount[]>;
|
|
1523
|
-
getAllOrders(filter?: OrdersFilter): Promise<BrokerDataOrder[]>;
|
|
1524
|
-
getAllPositions(filter?: PositionsFilter): Promise<BrokerDataPosition[]>;
|
|
1525
|
-
getOpenPositions(): Promise<BrokerDataPosition[]>;
|
|
1526
|
-
getFilledOrders(): Promise<BrokerDataOrder[]>;
|
|
1527
|
-
getPendingOrders(): Promise<BrokerDataOrder[]>;
|
|
1528
|
-
getActiveAccounts(): Promise<BrokerDataAccount[]>;
|
|
1529
|
-
getOrdersBySymbol(symbol: string): Promise<BrokerDataOrder[]>;
|
|
1530
|
-
getPositionsBySymbol(symbol: string): Promise<BrokerDataPosition[]>;
|
|
1531
|
-
getOrdersByBroker(brokerId: string): Promise<BrokerDataOrder[]>;
|
|
1532
|
-
getPositionsByBroker(brokerId: string): Promise<BrokerDataPosition[]>;
|
|
1533
|
-
}
|
|
1534
|
-
declare class CoreTradingService implements ITradingService {
|
|
1535
|
-
private apiClient;
|
|
1536
|
-
constructor(apiClient: ApiClient);
|
|
1537
|
-
getAccounts(filter?: AccountsFilter): Promise<BrokerDataAccount[]>;
|
|
1538
|
-
getOrders(filter?: OrdersFilter): Promise<BrokerDataOrder[]>;
|
|
1539
|
-
getPositions(filter?: PositionsFilter): Promise<BrokerDataPosition[]>;
|
|
1540
|
-
placeOrder(order: Order): Promise<string>;
|
|
1541
|
-
cancelOrder(orderId: string): Promise<boolean>;
|
|
1542
|
-
placeOptionsOrder(order: OptionsOrder): Promise<string>;
|
|
1543
|
-
getAccountsPage(page?: number, perPage?: number, filter?: AccountsFilter): Promise<PaginatedResult<BrokerDataAccount[]>>;
|
|
1544
|
-
getOrdersPage(page?: number, perPage?: number, filter?: OrdersFilter): Promise<PaginatedResult<BrokerDataOrder[]>>;
|
|
1545
|
-
getPositionsPage(page?: number, perPage?: number, filter?: PositionsFilter): Promise<PaginatedResult<BrokerDataPosition[]>>;
|
|
1546
|
-
getNextAccountsPage(previousResult: PaginatedResult<BrokerDataAccount[]>): Promise<PaginatedResult<BrokerDataAccount[]> | null>;
|
|
1547
|
-
getNextOrdersPage(previousResult: PaginatedResult<BrokerDataOrder[]>): Promise<PaginatedResult<BrokerDataOrder[]> | null>;
|
|
1548
|
-
getNextPositionsPage(previousResult: PaginatedResult<BrokerDataPosition[]>): Promise<PaginatedResult<BrokerDataPosition[]> | null>;
|
|
1549
|
-
getAllAccounts(filter?: AccountsFilter): Promise<BrokerDataAccount[]>;
|
|
1550
|
-
getAllOrders(filter?: OrdersFilter): Promise<BrokerDataOrder[]>;
|
|
1551
|
-
getAllPositions(filter?: PositionsFilter): Promise<BrokerDataPosition[]>;
|
|
1552
|
-
getOpenPositions(): Promise<BrokerDataPosition[]>;
|
|
1553
|
-
getFilledOrders(): Promise<BrokerDataOrder[]>;
|
|
1554
|
-
getPendingOrders(): Promise<BrokerDataOrder[]>;
|
|
1555
|
-
getActiveAccounts(): Promise<BrokerDataAccount[]>;
|
|
1556
|
-
getOrdersBySymbol(symbol: string): Promise<BrokerDataOrder[]>;
|
|
1557
|
-
getPositionsBySymbol(symbol: string): Promise<BrokerDataPosition[]>;
|
|
1558
|
-
getOrdersByBroker(brokerId: string): Promise<BrokerDataOrder[]>;
|
|
1559
|
-
getPositionsByBroker(brokerId: string): Promise<BrokerDataPosition[]>;
|
|
1560
|
-
}
|
|
1561
|
-
|
|
1562
|
-
interface IAnalyticsService {
|
|
1563
|
-
getPerformance(): Promise<PerformanceMetrics>;
|
|
1564
|
-
getDailyHistory(): Promise<any[]>;
|
|
1565
|
-
getWeeklySnapshots(): Promise<PortfolioSnapshot[]>;
|
|
1566
|
-
getPortfolioDeltas(): Promise<any[]>;
|
|
1567
|
-
getUserLogs(userId: string): Promise<any[]>;
|
|
1568
|
-
}
|
|
1569
|
-
declare class CoreAnalyticsService implements IAnalyticsService {
|
|
1570
|
-
private apiClient;
|
|
1571
|
-
constructor(apiClient: ApiClient);
|
|
1572
|
-
getPerformance(): Promise<PerformanceMetrics>;
|
|
1573
|
-
getDailyHistory(): Promise<any[]>;
|
|
1574
|
-
getWeeklySnapshots(): Promise<PortfolioSnapshot[]>;
|
|
1575
|
-
getPortfolioDeltas(): Promise<any[]>;
|
|
1576
|
-
getUserLogs(userId: string): Promise<any[]>;
|
|
1577
|
-
}
|
|
1578
|
-
|
|
1579
|
-
interface IPortalService {
|
|
1580
|
-
createPortal(config: PortalConfig): Promise<void>;
|
|
1581
|
-
closePortal(): Promise<void>;
|
|
1582
|
-
updateTheme(theme: Theme): Promise<void>;
|
|
1583
|
-
getBrokerAccounts(): Promise<any[]>;
|
|
1584
|
-
linkBrokerAccount(brokerId: string): Promise<void>;
|
|
1585
|
-
unlinkBrokerAccount(brokerId: string): Promise<void>;
|
|
1586
|
-
}
|
|
1587
|
-
declare class CorePortalService implements IPortalService {
|
|
1588
|
-
private apiClient;
|
|
1589
|
-
private iframe;
|
|
1590
|
-
constructor(apiClient: ApiClient);
|
|
1591
|
-
createPortal(config: PortalConfig): Promise<void>;
|
|
1592
|
-
closePortal(): Promise<void>;
|
|
1593
|
-
updateTheme(theme: Theme): Promise<void>;
|
|
1594
|
-
getBrokerAccounts(): Promise<any[]>;
|
|
1595
|
-
linkBrokerAccount(brokerId: string): Promise<void>;
|
|
1596
|
-
unlinkBrokerAccount(brokerId: string): Promise<void>;
|
|
1597
|
-
private positionIframe;
|
|
1598
|
-
private styleIframe;
|
|
1376
|
+
/**
|
|
1377
|
+
* Disconnect a company from a broker connection
|
|
1378
|
+
* @param connectionId - The connection ID to disconnect
|
|
1379
|
+
* @returns Promise with disconnect response
|
|
1380
|
+
* @throws AuthenticationError if user is not authenticated
|
|
1381
|
+
*/
|
|
1382
|
+
disconnectCompany(connectionId: string): Promise<DisconnectCompanyResponse>;
|
|
1599
1383
|
}
|
|
1600
1384
|
|
|
1601
1385
|
/**
|
|
@@ -1727,9 +1511,9 @@ declare class MockDataProvider {
|
|
|
1727
1511
|
data: BrokerDataPosition[];
|
|
1728
1512
|
}>;
|
|
1729
1513
|
mockGetBrokerDataAccounts(filter?: AccountsFilter): Promise<{
|
|
1730
|
-
data:
|
|
1514
|
+
data: BrokerAccount[];
|
|
1731
1515
|
}>;
|
|
1732
|
-
mockPlaceOrder(order:
|
|
1516
|
+
mockPlaceOrder(order: BrokerOrderParams): Promise<OrderResponse>;
|
|
1733
1517
|
/**
|
|
1734
1518
|
* Get stored session data
|
|
1735
1519
|
*/
|
|
@@ -1764,6 +1548,12 @@ declare class MockDataProvider {
|
|
|
1764
1548
|
* Generate mock accounts with diverse data
|
|
1765
1549
|
*/
|
|
1766
1550
|
private generateMockAccounts;
|
|
1551
|
+
/**
|
|
1552
|
+
* Mock disconnect company method
|
|
1553
|
+
* @param connectionId - The connection ID to disconnect
|
|
1554
|
+
* @returns Promise with mock disconnect response
|
|
1555
|
+
*/
|
|
1556
|
+
mockDisconnectCompany(connectionId: string): Promise<DisconnectCompanyResponse>;
|
|
1767
1557
|
}
|
|
1768
1558
|
|
|
1769
1559
|
/**
|
|
@@ -1835,52 +1625,42 @@ declare class MockApiClient {
|
|
|
1835
1625
|
getPortalUrl(sessionId: string): Promise<PortalUrlResponse>;
|
|
1836
1626
|
validatePortalSession(sessionId: string, signature: string): Promise<SessionValidationResponse>;
|
|
1837
1627
|
completePortalSession(sessionId: string): Promise<PortalUrlResponse>;
|
|
1838
|
-
getHoldings(
|
|
1839
|
-
data: Holding[];
|
|
1840
|
-
}>;
|
|
1841
|
-
getOrders(accessToken: string, filter?: OrdersFilter): Promise<{
|
|
1842
|
-
data: Order[];
|
|
1843
|
-
}>;
|
|
1844
|
-
getPortfolio(accessToken: string): Promise<{
|
|
1845
|
-
data: Portfolio;
|
|
1846
|
-
}>;
|
|
1847
|
-
placeOrder(accessToken: string, order: Order): Promise<void>;
|
|
1848
|
-
getHoldingsAuto(): Promise<{
|
|
1628
|
+
getHoldings(filter?: OrdersFilter): Promise<{
|
|
1849
1629
|
data: Holding[];
|
|
1850
1630
|
}>;
|
|
1851
|
-
|
|
1631
|
+
getOrders(filter?: OrdersFilter): Promise<{
|
|
1852
1632
|
data: Order[];
|
|
1853
1633
|
}>;
|
|
1854
|
-
|
|
1634
|
+
getPortfolio(): Promise<{
|
|
1855
1635
|
data: Portfolio;
|
|
1856
1636
|
}>;
|
|
1857
|
-
|
|
1858
|
-
placeBrokerOrder(
|
|
1637
|
+
placeOrder(order: BrokerOrderParams): Promise<void>;
|
|
1638
|
+
placeBrokerOrder(params: Partial<BrokerOrderParams> & {
|
|
1859
1639
|
symbol: string;
|
|
1860
1640
|
orderQty: number;
|
|
1861
1641
|
action: 'Buy' | 'Sell';
|
|
1862
|
-
orderType: 'Market' | 'Limit' | 'Stop' | '
|
|
1863
|
-
assetType: 'Stock' | 'Option' | 'Crypto' | '
|
|
1864
|
-
}, extras?: BrokerExtras): Promise<OrderResponse>;
|
|
1865
|
-
cancelBrokerOrder(orderId: string, broker?: 'robinhood' | 'tasty_trade' | 'ninja_trader', extras?: any): Promise<OrderResponse>;
|
|
1866
|
-
modifyBrokerOrder(orderId: string, params: Partial<BrokerOrderParams>, broker?: 'robinhood' | 'tasty_trade' | 'ninja_trader', extras?: any): Promise<OrderResponse>;
|
|
1642
|
+
orderType: 'Market' | 'Limit' | 'Stop' | 'StopLimit';
|
|
1643
|
+
assetType: 'Stock' | 'Option' | 'Crypto' | 'Future';
|
|
1644
|
+
}, extras?: BrokerExtras, connection_id?: string): Promise<OrderResponse>;
|
|
1645
|
+
cancelBrokerOrder(orderId: string, broker?: 'robinhood' | 'tasty_trade' | 'ninja_trader', extras?: any, connection_id?: string): Promise<OrderResponse>;
|
|
1646
|
+
modifyBrokerOrder(orderId: string, params: Partial<BrokerOrderParams>, broker?: 'robinhood' | 'tasty_trade' | 'ninja_trader', extras?: any, connection_id?: string): Promise<OrderResponse>;
|
|
1867
1647
|
setBroker(broker: 'robinhood' | 'tasty_trade' | 'ninja_trader'): void;
|
|
1868
1648
|
setAccount(accountNumber: string, accountId?: string): void;
|
|
1869
1649
|
getTradingContext(): TradingContext;
|
|
1870
1650
|
clearTradingContext(): void;
|
|
1871
|
-
placeStockMarketOrder(
|
|
1872
|
-
placeStockLimitOrder(
|
|
1873
|
-
placeStockStopOrder(
|
|
1874
|
-
placeCryptoMarketOrder(
|
|
1875
|
-
placeCryptoLimitOrder(
|
|
1876
|
-
placeOptionsMarketOrder(
|
|
1877
|
-
placeOptionsLimitOrder(
|
|
1878
|
-
placeFuturesMarketOrder(
|
|
1879
|
-
placeFuturesLimitOrder(
|
|
1651
|
+
placeStockMarketOrder(symbol: string, orderQty: number, action: 'Buy' | 'Sell', broker?: 'robinhood' | 'tasty_trade' | 'ninja_trader', accountNumber?: string, extras?: BrokerExtras): Promise<OrderResponse>;
|
|
1652
|
+
placeStockLimitOrder(symbol: string, orderQty: number, action: 'Buy' | 'Sell', price: number, timeInForce?: 'day' | 'gtc', broker?: 'robinhood' | 'tasty_trade' | 'ninja_trader', accountNumber?: string, extras?: BrokerExtras): Promise<OrderResponse>;
|
|
1653
|
+
placeStockStopOrder(symbol: string, orderQty: number, action: 'Buy' | 'Sell', stopPrice: number, timeInForce?: 'day' | 'gtc', broker?: 'robinhood' | 'tasty_trade' | 'ninja_trader', accountNumber?: string, extras?: BrokerExtras): Promise<OrderResponse>;
|
|
1654
|
+
placeCryptoMarketOrder(symbol: string, orderQty: number, action: 'Buy' | 'Sell', options?: CryptoOrderOptions, broker?: 'robinhood' | 'tasty_trade' | 'ninja_trader', accountNumber?: string, extras?: BrokerExtras): Promise<OrderResponse>;
|
|
1655
|
+
placeCryptoLimitOrder(symbol: string, orderQty: number, action: 'Buy' | 'Sell', price: number, timeInForce?: 'day' | 'gtc', options?: CryptoOrderOptions, broker?: 'robinhood' | 'tasty_trade' | 'ninja_trader', accountNumber?: string, extras?: BrokerExtras): Promise<OrderResponse>;
|
|
1656
|
+
placeOptionsMarketOrder(symbol: string, orderQty: number, action: 'Buy' | 'Sell', options: OptionsOrderOptions, broker?: 'robinhood' | 'tasty_trade' | 'ninja_trader', accountNumber?: string, extras?: BrokerExtras): Promise<OrderResponse>;
|
|
1657
|
+
placeOptionsLimitOrder(symbol: string, orderQty: number, action: 'Buy' | 'Sell', price: number, options: OptionsOrderOptions, timeInForce?: 'day' | 'gtc', broker?: 'robinhood' | 'tasty_trade' | 'ninja_trader', accountNumber?: string, extras?: BrokerExtras): Promise<OrderResponse>;
|
|
1658
|
+
placeFuturesMarketOrder(symbol: string, orderQty: number, action: 'Buy' | 'Sell', broker?: 'robinhood' | 'tasty_trade' | 'ninja_trader', accountNumber?: string, extras?: BrokerExtras): Promise<OrderResponse>;
|
|
1659
|
+
placeFuturesLimitOrder(symbol: string, orderQty: number, action: 'Buy' | 'Sell', price: number, timeInForce?: 'day' | 'gtc', broker?: 'robinhood' | 'tasty_trade' | 'ninja_trader', accountNumber?: string, extras?: BrokerExtras): Promise<OrderResponse>;
|
|
1880
1660
|
revokeToken(accessToken: string): Promise<void>;
|
|
1881
1661
|
getUserToken(userId: string): Promise<UserToken>;
|
|
1882
1662
|
getCurrentSessionState(): SessionState | null;
|
|
1883
|
-
getBrokerList(
|
|
1663
|
+
getBrokerList(): Promise<{
|
|
1884
1664
|
_id: string;
|
|
1885
1665
|
response_data: BrokerInfo[];
|
|
1886
1666
|
message: string;
|
|
@@ -1888,7 +1668,7 @@ declare class MockApiClient {
|
|
|
1888
1668
|
warnings: null;
|
|
1889
1669
|
errors: null;
|
|
1890
1670
|
}>;
|
|
1891
|
-
getBrokerAccounts(
|
|
1671
|
+
getBrokerAccounts(options?: BrokerDataOptions): Promise<{
|
|
1892
1672
|
_id: string;
|
|
1893
1673
|
response_data: BrokerAccount[];
|
|
1894
1674
|
message: string;
|
|
@@ -1896,7 +1676,7 @@ declare class MockApiClient {
|
|
|
1896
1676
|
warnings: null;
|
|
1897
1677
|
errors: null;
|
|
1898
1678
|
}>;
|
|
1899
|
-
getBrokerOrders(
|
|
1679
|
+
getBrokerOrders(options?: BrokerDataOptions): Promise<{
|
|
1900
1680
|
_id: string;
|
|
1901
1681
|
response_data: BrokerOrder[];
|
|
1902
1682
|
message: string;
|
|
@@ -1904,7 +1684,7 @@ declare class MockApiClient {
|
|
|
1904
1684
|
warnings: null;
|
|
1905
1685
|
errors: null;
|
|
1906
1686
|
}>;
|
|
1907
|
-
getBrokerPositions(
|
|
1687
|
+
getBrokerPositions(options?: BrokerDataOptions): Promise<{
|
|
1908
1688
|
_id: string;
|
|
1909
1689
|
response_data: BrokerPosition[];
|
|
1910
1690
|
message: string;
|
|
@@ -1919,52 +1699,12 @@ declare class MockApiClient {
|
|
|
1919
1699
|
data: BrokerDataPosition[];
|
|
1920
1700
|
}>;
|
|
1921
1701
|
getBrokerDataAccountsWithFilter(filter?: AccountsFilter): Promise<{
|
|
1922
|
-
data:
|
|
1923
|
-
}>;
|
|
1924
|
-
getBrokerOrdersPage(page?: number, perPage?: number, filters?: OrdersFilter): Promise<PaginatedResult<any[]>>;
|
|
1925
|
-
getBrokerAccountsPage(page?: number, perPage?: number, filters?: AccountsFilter): Promise<PaginatedResult<any[]>>;
|
|
1926
|
-
getBrokerPositionsPage(page?: number, perPage?: number, filters?: PositionsFilter): Promise<PaginatedResult<any[]>>;
|
|
1927
|
-
getBrokerConnections(accessToken: string): Promise<{
|
|
1928
|
-
_id: string;
|
|
1929
|
-
response_data: BrokerConnection[];
|
|
1930
|
-
message: string;
|
|
1931
|
-
status_code: number;
|
|
1932
|
-
warnings: null;
|
|
1933
|
-
errors: null;
|
|
1934
|
-
}>;
|
|
1935
|
-
getBrokerListAuto(): Promise<{
|
|
1936
|
-
_id: string;
|
|
1937
|
-
response_data: BrokerInfo[];
|
|
1938
|
-
message: string;
|
|
1939
|
-
status_code: number;
|
|
1940
|
-
warnings: null;
|
|
1941
|
-
errors: null;
|
|
1942
|
-
}>;
|
|
1943
|
-
getBrokerAccountsAuto(options?: BrokerDataOptions): Promise<{
|
|
1944
|
-
_id: string;
|
|
1945
|
-
response_data: BrokerAccount[];
|
|
1946
|
-
message: string;
|
|
1947
|
-
status_code: number;
|
|
1948
|
-
warnings: null;
|
|
1949
|
-
errors: null;
|
|
1950
|
-
}>;
|
|
1951
|
-
getBrokerOrdersAuto(options?: BrokerDataOptions): Promise<{
|
|
1952
|
-
_id: string;
|
|
1953
|
-
response_data: BrokerOrder[];
|
|
1954
|
-
message: string;
|
|
1955
|
-
status_code: number;
|
|
1956
|
-
warnings: null;
|
|
1957
|
-
errors: null;
|
|
1958
|
-
}>;
|
|
1959
|
-
getBrokerPositionsAuto(options?: BrokerDataOptions): Promise<{
|
|
1960
|
-
_id: string;
|
|
1961
|
-
response_data: BrokerPosition[];
|
|
1962
|
-
message: string;
|
|
1963
|
-
status_code: number;
|
|
1964
|
-
warnings: null;
|
|
1965
|
-
errors: null;
|
|
1702
|
+
data: BrokerAccount[];
|
|
1966
1703
|
}>;
|
|
1967
|
-
|
|
1704
|
+
getBrokerOrdersPage(page?: number, perPage?: number, filters?: OrdersFilter): Promise<PaginatedResult<BrokerDataOrder[]>>;
|
|
1705
|
+
getBrokerAccountsPage(page?: number, perPage?: number, filters?: AccountsFilter): Promise<PaginatedResult<BrokerAccount[]>>;
|
|
1706
|
+
getBrokerPositionsPage(page?: number, perPage?: number, filters?: PositionsFilter): Promise<PaginatedResult<BrokerDataPosition[]>>;
|
|
1707
|
+
getBrokerConnections(): Promise<{
|
|
1968
1708
|
_id: string;
|
|
1969
1709
|
response_data: BrokerConnection[];
|
|
1970
1710
|
message: string;
|
|
@@ -1972,16 +1712,12 @@ declare class MockApiClient {
|
|
|
1972
1712
|
warnings: null;
|
|
1973
1713
|
errors: null;
|
|
1974
1714
|
}>;
|
|
1975
|
-
|
|
1976
|
-
|
|
1977
|
-
|
|
1978
|
-
|
|
1979
|
-
|
|
1980
|
-
|
|
1981
|
-
}, extras?: BrokerExtras): Promise<OrderResponse>;
|
|
1982
|
-
placeStockMarketOrderAuto(symbol: string, orderQty: number, action: 'Buy' | 'Sell', broker?: 'robinhood' | 'tasty_trade' | 'ninja_trader', accountNumber?: string, extras?: BrokerExtras): Promise<OrderResponse>;
|
|
1983
|
-
placeStockLimitOrderAuto(symbol: string, orderQty: number, action: 'Buy' | 'Sell', price: number, timeInForce?: 'day' | 'gtc', broker?: 'robinhood' | 'tasty_trade' | 'ninja_trader', accountNumber?: string, extras?: BrokerExtras): Promise<OrderResponse>;
|
|
1984
|
-
placeStockStopOrderAuto(symbol: string, orderQty: number, action: 'Buy' | 'Sell', stopPrice: number, timeInForce?: 'day' | 'gtc', broker?: 'robinhood' | 'tasty_trade' | 'ninja_trader', accountNumber?: string, extras?: BrokerExtras): Promise<OrderResponse>;
|
|
1715
|
+
/**
|
|
1716
|
+
* Mock disconnect company method
|
|
1717
|
+
* @param connectionId - The connection ID to disconnect
|
|
1718
|
+
* @returns Promise with mock disconnect response
|
|
1719
|
+
*/
|
|
1720
|
+
disconnectCompany(connectionId: string): Promise<DisconnectCompanyResponse>;
|
|
1985
1721
|
getMockDataProvider(): MockDataProvider;
|
|
1986
1722
|
clearMockData(): void;
|
|
1987
1723
|
/**
|
|
@@ -2002,7 +1738,7 @@ declare class MockFactory {
|
|
|
2002
1738
|
* @param mockConfig - Optional mock configuration (only used if mocks are enabled)
|
|
2003
1739
|
* @returns ApiClient or MockApiClient instance
|
|
2004
1740
|
*/
|
|
2005
|
-
static createApiClient(baseUrl: string, deviceInfo?: DeviceInfo$1, mockConfig?: MockConfig): ApiClient
|
|
1741
|
+
static createApiClient(baseUrl: string, deviceInfo?: DeviceInfo$1, mockConfig?: MockConfig): ApiClient | MockApiClient;
|
|
2006
1742
|
/**
|
|
2007
1743
|
* Force create a mock API client regardless of environment settings
|
|
2008
1744
|
* @param baseUrl - The base URL for the API
|
|
@@ -2017,7 +1753,7 @@ declare class MockFactory {
|
|
|
2017
1753
|
* @param deviceInfo - Optional device information
|
|
2018
1754
|
* @returns ApiClient instance
|
|
2019
1755
|
*/
|
|
2020
|
-
static createRealApiClient(baseUrl: string, deviceInfo?: DeviceInfo$1): ApiClient
|
|
1756
|
+
static createRealApiClient(baseUrl: string, deviceInfo?: DeviceInfo$1): ApiClient;
|
|
2021
1757
|
/**
|
|
2022
1758
|
* Check if mocks are currently enabled
|
|
2023
1759
|
* @returns boolean indicating if mocks are enabled
|
|
@@ -2033,5 +1769,5 @@ declare class MockFactory {
|
|
|
2033
1769
|
};
|
|
2034
1770
|
}
|
|
2035
1771
|
|
|
2036
|
-
export { ApiClient
|
|
2037
|
-
export type { AccountsFilter, ApiConfig,
|
|
1772
|
+
export { ApiClient, ApiError, AuthenticationError, AuthorizationError, BaseError, CompanyAccessError, EventEmitter, FinaticConnect, MockFactory, NetworkError, OrderError, OrderValidationError, PaginatedResult, RateLimitError, SecurityError, SessionError, TokenError, appendThemeToURL, createCustomThemeFromPreset, generatePortalThemeURL, getThemePreset, portalThemePresets, validateCustomTheme };
|
|
1773
|
+
export type { AccountsFilter, ApiConfig, ApiResponse, BrokerAccount, BrokerConnection, BrokerDataAccount, BrokerDataOptions, BrokerDataOrder, BrokerDataPosition, BrokerExtras, BrokerInfo, BrokerOrder, BrokerOrderParams, BrokerPosition, CryptoOrderOptions, DeviceInfo$1 as DeviceInfo, FilteredAccountsResponse, FilteredOrdersResponse, FilteredPositionsResponse, FinaticConnectOptions, FinaticUserToken, Holding, OptionsOrder, OptionsOrderOptions, Order, OrderNotFoundError, OrderResponse, OrdersFilter, OtpRequestResponse, OtpVerifyResponse, PerformanceMetrics, PortalMessage, PortalProps, PortalResponse, PortalTheme, PortalThemeConfig, PortalThemePreset, PortalUrlResponse, Portfolio, PortfolioSnapshot, PositionsFilter, RefreshTokenRequest, RefreshTokenResponse, RequestHeaders, SessionAuthenticateResponse, SessionInitResponse, SessionResponse, SessionStartResponse, SessionStatus, SessionValidationResponse, TokenInfo, TradeAccessDeniedError, TradingContext, UserToken, ValidationError };
|