@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
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,6 +1063,11 @@ 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
1073
|
/**
|
|
@@ -1193,27 +1159,34 @@ declare class FinaticConnect extends EventEmitter {
|
|
|
1193
1159
|
timeInForce: 'day' | 'gtc' | 'gtd' | 'ioc' | 'fok';
|
|
1194
1160
|
broker?: 'robinhood' | 'tasty_trade' | 'ninja_trader';
|
|
1195
1161
|
accountNumber?: string;
|
|
1196
|
-
assetType?: 'Stock' | 'Option' | 'Crypto' | '
|
|
1162
|
+
assetType?: 'Stock' | 'Option' | 'Crypto' | 'Future';
|
|
1163
|
+
order_id?: string;
|
|
1164
|
+
connection_id?: string;
|
|
1197
1165
|
}): Promise<OrderResponse>;
|
|
1198
1166
|
/**
|
|
1199
1167
|
* Cancel a broker order
|
|
1200
1168
|
* @param orderId - The order ID to cancel
|
|
1201
1169
|
* @param broker - Optional broker override
|
|
1170
|
+
* @param connection_id - Optional connection ID for testing bypass
|
|
1202
1171
|
*/
|
|
1203
|
-
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>;
|
|
1204
1173
|
/**
|
|
1205
1174
|
* Modify a broker order
|
|
1206
1175
|
* @param orderId - The order ID to modify
|
|
1207
1176
|
* @param modifications - The modifications to apply
|
|
1208
1177
|
* @param broker - Optional broker override
|
|
1178
|
+
* @param connection_id - Optional connection ID for testing bypass
|
|
1209
1179
|
*/
|
|
1210
1180
|
modifyOrder(orderId: string, modifications: Partial<{
|
|
1211
|
-
symbol
|
|
1212
|
-
quantity
|
|
1213
|
-
price
|
|
1214
|
-
stopPrice
|
|
1215
|
-
timeInForce
|
|
1216
|
-
|
|
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>;
|
|
1217
1190
|
/**
|
|
1218
1191
|
* Set the broker context for trading
|
|
1219
1192
|
* @param broker - The broker to use for trading
|
|
@@ -1363,15 +1336,36 @@ declare class FinaticConnect extends EventEmitter {
|
|
|
1363
1336
|
*/
|
|
1364
1337
|
getAllAccounts(filter?: AccountsFilter): Promise<BrokerDataAccount[]>;
|
|
1365
1338
|
/**
|
|
1366
|
-
* Register
|
|
1339
|
+
* Register session management (but don't auto-cleanup for 24-hour sessions)
|
|
1367
1340
|
*/
|
|
1368
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;
|
|
1369
1362
|
/**
|
|
1370
1363
|
* Handle session cleanup when page is unloading
|
|
1371
1364
|
*/
|
|
1372
1365
|
private handleSessionCleanup;
|
|
1373
1366
|
/**
|
|
1374
1367
|
* Handle visibility change (mobile browsers)
|
|
1368
|
+
* Note: We don't complete sessions on visibility change for 24-hour sessions
|
|
1375
1369
|
*/
|
|
1376
1370
|
private handleVisibilityChange;
|
|
1377
1371
|
/**
|
|
@@ -1379,218 +1373,13 @@ declare class FinaticConnect extends EventEmitter {
|
|
|
1379
1373
|
* @param sessionId - The session ID to complete
|
|
1380
1374
|
*/
|
|
1381
1375
|
private completeSession;
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
private isSandbox;
|
|
1390
|
-
constructor(config: ApiConfig);
|
|
1391
|
-
private getBaseUrl;
|
|
1392
|
-
private request;
|
|
1393
|
-
getPortalContent(): Promise<ApiResponse<{
|
|
1394
|
-
content: string;
|
|
1395
|
-
}>>;
|
|
1396
|
-
getInitToken(): Promise<ApiResponse<{
|
|
1397
|
-
token: string;
|
|
1398
|
-
}>>;
|
|
1399
|
-
login(otp: string): Promise<ApiResponse<{
|
|
1400
|
-
success: boolean;
|
|
1401
|
-
}>>;
|
|
1402
|
-
verifyOTP(otp: string): Promise<ApiResponse<{
|
|
1403
|
-
userId: string;
|
|
1404
|
-
connectionIds: string[];
|
|
1405
|
-
}>>;
|
|
1406
|
-
getUserProfile(): Promise<ApiResponse<{
|
|
1407
|
-
profile: any;
|
|
1408
|
-
brokers: any[];
|
|
1409
|
-
}>>;
|
|
1410
|
-
getConnectionComplete(): Promise<ApiResponse<{
|
|
1411
|
-
userId: string;
|
|
1412
|
-
connectionIds: string[];
|
|
1413
|
-
}>>;
|
|
1414
|
-
getUserToken(userId: string): Promise<ApiResponse<{
|
|
1415
|
-
accessToken: string;
|
|
1416
|
-
refreshToken: string;
|
|
1417
|
-
}>>;
|
|
1418
|
-
refreshAccessToken(): Promise<ApiResponse<{
|
|
1419
|
-
accessToken: string;
|
|
1420
|
-
refreshToken: string;
|
|
1421
|
-
}>>;
|
|
1422
|
-
revokeTokens(): Promise<ApiResponse<{
|
|
1423
|
-
success: boolean;
|
|
1424
|
-
}>>;
|
|
1425
|
-
connectBroker(brokerId: string): Promise<ApiResponse<{
|
|
1426
|
-
success: boolean;
|
|
1427
|
-
}>>;
|
|
1428
|
-
disconnectBroker(brokerId: string): Promise<ApiResponse<{
|
|
1429
|
-
success: boolean;
|
|
1430
|
-
}>>;
|
|
1431
|
-
getBrokerAccounts(): Promise<ApiResponse<{
|
|
1432
|
-
accounts: any[];
|
|
1433
|
-
}>>;
|
|
1434
|
-
getConnections(): Promise<ApiResponse<{
|
|
1435
|
-
connections: any[];
|
|
1436
|
-
}>>;
|
|
1437
|
-
getConnectionDetails(connectionId: string): Promise<ApiResponse<{
|
|
1438
|
-
connection: any;
|
|
1439
|
-
}>>;
|
|
1440
|
-
getAccounts(filter?: AccountsFilter): Promise<ApiResponse<{
|
|
1441
|
-
accounts: any[];
|
|
1442
|
-
}>>;
|
|
1443
|
-
getHoldings(): Promise<ApiResponse<{
|
|
1444
|
-
holdings: any[];
|
|
1445
|
-
}>>;
|
|
1446
|
-
getBalances(): Promise<ApiResponse<{
|
|
1447
|
-
balances: any;
|
|
1448
|
-
}>>;
|
|
1449
|
-
getTransactions(): Promise<ApiResponse<{
|
|
1450
|
-
transactions: any[];
|
|
1451
|
-
}>>;
|
|
1452
|
-
getPerformance(): Promise<ApiResponse<{
|
|
1453
|
-
performance: any;
|
|
1454
|
-
}>>;
|
|
1455
|
-
getOrders(filter?: OrdersFilter): Promise<ApiResponse<{
|
|
1456
|
-
orders: any[];
|
|
1457
|
-
}>>;
|
|
1458
|
-
getTrades(): Promise<ApiResponse<{
|
|
1459
|
-
trades: any[];
|
|
1460
|
-
}>>;
|
|
1461
|
-
placeOrder(order: any): Promise<ApiResponse<{
|
|
1462
|
-
orderId: string;
|
|
1463
|
-
}>>;
|
|
1464
|
-
cancelOrder(orderId: string): Promise<ApiResponse<{
|
|
1465
|
-
success: boolean;
|
|
1466
|
-
}>>;
|
|
1467
|
-
getOrderStatus(orderId: string): Promise<ApiResponse<{
|
|
1468
|
-
status: string;
|
|
1469
|
-
}>>;
|
|
1470
|
-
getOptionsChain(symbol: string): Promise<ApiResponse<{
|
|
1471
|
-
chain: any[];
|
|
1472
|
-
}>>;
|
|
1473
|
-
getOptionQuote(symbol: string, strike: number, expiry: string): Promise<ApiResponse<{
|
|
1474
|
-
quote: any;
|
|
1475
|
-
}>>;
|
|
1476
|
-
placeOptionsOrder(order: any): Promise<ApiResponse<{
|
|
1477
|
-
orderId: string;
|
|
1478
|
-
}>>;
|
|
1479
|
-
getDailyHistory(): Promise<ApiResponse<{
|
|
1480
|
-
history: any[];
|
|
1481
|
-
}>>;
|
|
1482
|
-
getWeeklySnapshots(): Promise<ApiResponse<{
|
|
1483
|
-
snapshots: any[];
|
|
1484
|
-
}>>;
|
|
1485
|
-
getPortfolioDeltas(): Promise<ApiResponse<{
|
|
1486
|
-
deltas: any[];
|
|
1487
|
-
}>>;
|
|
1488
|
-
getUserLogs(userId: string): Promise<ApiResponse<{
|
|
1489
|
-
logs: any[];
|
|
1490
|
-
}>>;
|
|
1491
|
-
getBrokerOrders(filter?: OrdersFilter): Promise<ApiResponse<FilteredOrdersResponse>>;
|
|
1492
|
-
getBrokerPositions(filter?: PositionsFilter): Promise<ApiResponse<FilteredPositionsResponse>>;
|
|
1493
|
-
getBrokerDataAccounts(filter?: AccountsFilter): Promise<ApiResponse<FilteredAccountsResponse>>;
|
|
1494
|
-
testWebhook(): Promise<ApiResponse<{
|
|
1495
|
-
success: boolean;
|
|
1496
|
-
}>>;
|
|
1497
|
-
private buildQueryParams;
|
|
1498
|
-
getBrokerOrdersPage(page?: number, perPage?: number, filters?: OrdersFilter): Promise<PaginatedResult<any[]>>;
|
|
1499
|
-
getBrokerAccountsPage(page?: number, perPage?: number, filters?: AccountsFilter): Promise<PaginatedResult<any[]>>;
|
|
1500
|
-
getBrokerPositionsPage(page?: number, perPage?: number, filters?: PositionsFilter): Promise<PaginatedResult<any[]>>;
|
|
1501
|
-
getNextPage<T>(previousResult: PaginatedResult<T>, fetchFunction: (offset: number, limit: number) => Promise<PaginatedResult<T>>): Promise<PaginatedResult<T> | null>;
|
|
1502
|
-
}
|
|
1503
|
-
|
|
1504
|
-
interface ITradingService {
|
|
1505
|
-
getAccounts(filter?: AccountsFilter): Promise<BrokerDataAccount[]>;
|
|
1506
|
-
getOrders(filter?: OrdersFilter): Promise<BrokerDataOrder[]>;
|
|
1507
|
-
getPositions(filter?: PositionsFilter): Promise<BrokerDataPosition[]>;
|
|
1508
|
-
placeOrder(order: Order): Promise<string>;
|
|
1509
|
-
cancelOrder(orderId: string): Promise<boolean>;
|
|
1510
|
-
placeOptionsOrder(order: OptionsOrder): Promise<string>;
|
|
1511
|
-
getAccountsPage(page?: number, perPage?: number, filter?: AccountsFilter): Promise<PaginatedResult<BrokerDataAccount[]>>;
|
|
1512
|
-
getOrdersPage(page?: number, perPage?: number, filter?: OrdersFilter): Promise<PaginatedResult<BrokerDataOrder[]>>;
|
|
1513
|
-
getPositionsPage(page?: number, perPage?: number, filter?: PositionsFilter): Promise<PaginatedResult<BrokerDataPosition[]>>;
|
|
1514
|
-
getNextAccountsPage(previousResult: PaginatedResult<BrokerDataAccount[]>): Promise<PaginatedResult<BrokerDataAccount[]> | null>;
|
|
1515
|
-
getNextOrdersPage(previousResult: PaginatedResult<BrokerDataOrder[]>): Promise<PaginatedResult<BrokerDataOrder[]> | null>;
|
|
1516
|
-
getNextPositionsPage(previousResult: PaginatedResult<BrokerDataPosition[]>): Promise<PaginatedResult<BrokerDataPosition[]> | null>;
|
|
1517
|
-
getAllAccounts(filter?: AccountsFilter): Promise<BrokerDataAccount[]>;
|
|
1518
|
-
getAllOrders(filter?: OrdersFilter): Promise<BrokerDataOrder[]>;
|
|
1519
|
-
getAllPositions(filter?: PositionsFilter): Promise<BrokerDataPosition[]>;
|
|
1520
|
-
getOpenPositions(): Promise<BrokerDataPosition[]>;
|
|
1521
|
-
getFilledOrders(): Promise<BrokerDataOrder[]>;
|
|
1522
|
-
getPendingOrders(): Promise<BrokerDataOrder[]>;
|
|
1523
|
-
getActiveAccounts(): Promise<BrokerDataAccount[]>;
|
|
1524
|
-
getOrdersBySymbol(symbol: string): Promise<BrokerDataOrder[]>;
|
|
1525
|
-
getPositionsBySymbol(symbol: string): Promise<BrokerDataPosition[]>;
|
|
1526
|
-
getOrdersByBroker(brokerId: string): Promise<BrokerDataOrder[]>;
|
|
1527
|
-
getPositionsByBroker(brokerId: string): Promise<BrokerDataPosition[]>;
|
|
1528
|
-
}
|
|
1529
|
-
declare class CoreTradingService implements ITradingService {
|
|
1530
|
-
private apiClient;
|
|
1531
|
-
constructor(apiClient: ApiClient);
|
|
1532
|
-
getAccounts(filter?: AccountsFilter): Promise<BrokerDataAccount[]>;
|
|
1533
|
-
getOrders(filter?: OrdersFilter): Promise<BrokerDataOrder[]>;
|
|
1534
|
-
getPositions(filter?: PositionsFilter): Promise<BrokerDataPosition[]>;
|
|
1535
|
-
placeOrder(order: Order): Promise<string>;
|
|
1536
|
-
cancelOrder(orderId: string): Promise<boolean>;
|
|
1537
|
-
placeOptionsOrder(order: OptionsOrder): Promise<string>;
|
|
1538
|
-
getAccountsPage(page?: number, perPage?: number, filter?: AccountsFilter): Promise<PaginatedResult<BrokerDataAccount[]>>;
|
|
1539
|
-
getOrdersPage(page?: number, perPage?: number, filter?: OrdersFilter): Promise<PaginatedResult<BrokerDataOrder[]>>;
|
|
1540
|
-
getPositionsPage(page?: number, perPage?: number, filter?: PositionsFilter): Promise<PaginatedResult<BrokerDataPosition[]>>;
|
|
1541
|
-
getNextAccountsPage(previousResult: PaginatedResult<BrokerDataAccount[]>): Promise<PaginatedResult<BrokerDataAccount[]> | null>;
|
|
1542
|
-
getNextOrdersPage(previousResult: PaginatedResult<BrokerDataOrder[]>): Promise<PaginatedResult<BrokerDataOrder[]> | null>;
|
|
1543
|
-
getNextPositionsPage(previousResult: PaginatedResult<BrokerDataPosition[]>): Promise<PaginatedResult<BrokerDataPosition[]> | null>;
|
|
1544
|
-
getAllAccounts(filter?: AccountsFilter): Promise<BrokerDataAccount[]>;
|
|
1545
|
-
getAllOrders(filter?: OrdersFilter): Promise<BrokerDataOrder[]>;
|
|
1546
|
-
getAllPositions(filter?: PositionsFilter): Promise<BrokerDataPosition[]>;
|
|
1547
|
-
getOpenPositions(): Promise<BrokerDataPosition[]>;
|
|
1548
|
-
getFilledOrders(): Promise<BrokerDataOrder[]>;
|
|
1549
|
-
getPendingOrders(): Promise<BrokerDataOrder[]>;
|
|
1550
|
-
getActiveAccounts(): Promise<BrokerDataAccount[]>;
|
|
1551
|
-
getOrdersBySymbol(symbol: string): Promise<BrokerDataOrder[]>;
|
|
1552
|
-
getPositionsBySymbol(symbol: string): Promise<BrokerDataPosition[]>;
|
|
1553
|
-
getOrdersByBroker(brokerId: string): Promise<BrokerDataOrder[]>;
|
|
1554
|
-
getPositionsByBroker(brokerId: string): Promise<BrokerDataPosition[]>;
|
|
1555
|
-
}
|
|
1556
|
-
|
|
1557
|
-
interface IAnalyticsService {
|
|
1558
|
-
getPerformance(): Promise<PerformanceMetrics>;
|
|
1559
|
-
getDailyHistory(): Promise<any[]>;
|
|
1560
|
-
getWeeklySnapshots(): Promise<PortfolioSnapshot[]>;
|
|
1561
|
-
getPortfolioDeltas(): Promise<any[]>;
|
|
1562
|
-
getUserLogs(userId: string): Promise<any[]>;
|
|
1563
|
-
}
|
|
1564
|
-
declare class CoreAnalyticsService implements IAnalyticsService {
|
|
1565
|
-
private apiClient;
|
|
1566
|
-
constructor(apiClient: ApiClient);
|
|
1567
|
-
getPerformance(): Promise<PerformanceMetrics>;
|
|
1568
|
-
getDailyHistory(): Promise<any[]>;
|
|
1569
|
-
getWeeklySnapshots(): Promise<PortfolioSnapshot[]>;
|
|
1570
|
-
getPortfolioDeltas(): Promise<any[]>;
|
|
1571
|
-
getUserLogs(userId: string): Promise<any[]>;
|
|
1572
|
-
}
|
|
1573
|
-
|
|
1574
|
-
interface IPortalService {
|
|
1575
|
-
createPortal(config: PortalConfig): Promise<void>;
|
|
1576
|
-
closePortal(): Promise<void>;
|
|
1577
|
-
updateTheme(theme: Theme): Promise<void>;
|
|
1578
|
-
getBrokerAccounts(): Promise<any[]>;
|
|
1579
|
-
linkBrokerAccount(brokerId: string): Promise<void>;
|
|
1580
|
-
unlinkBrokerAccount(brokerId: string): Promise<void>;
|
|
1581
|
-
}
|
|
1582
|
-
declare class CorePortalService implements IPortalService {
|
|
1583
|
-
private apiClient;
|
|
1584
|
-
private iframe;
|
|
1585
|
-
constructor(apiClient: ApiClient);
|
|
1586
|
-
createPortal(config: PortalConfig): Promise<void>;
|
|
1587
|
-
closePortal(): Promise<void>;
|
|
1588
|
-
updateTheme(theme: Theme): Promise<void>;
|
|
1589
|
-
getBrokerAccounts(): Promise<any[]>;
|
|
1590
|
-
linkBrokerAccount(brokerId: string): Promise<void>;
|
|
1591
|
-
unlinkBrokerAccount(brokerId: string): Promise<void>;
|
|
1592
|
-
private positionIframe;
|
|
1593
|
-
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>;
|
|
1594
1383
|
}
|
|
1595
1384
|
|
|
1596
1385
|
/**
|
|
@@ -1722,9 +1511,9 @@ declare class MockDataProvider {
|
|
|
1722
1511
|
data: BrokerDataPosition[];
|
|
1723
1512
|
}>;
|
|
1724
1513
|
mockGetBrokerDataAccounts(filter?: AccountsFilter): Promise<{
|
|
1725
|
-
data:
|
|
1514
|
+
data: BrokerAccount[];
|
|
1726
1515
|
}>;
|
|
1727
|
-
mockPlaceOrder(order:
|
|
1516
|
+
mockPlaceOrder(order: BrokerOrderParams): Promise<OrderResponse>;
|
|
1728
1517
|
/**
|
|
1729
1518
|
* Get stored session data
|
|
1730
1519
|
*/
|
|
@@ -1759,6 +1548,12 @@ declare class MockDataProvider {
|
|
|
1759
1548
|
* Generate mock accounts with diverse data
|
|
1760
1549
|
*/
|
|
1761
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>;
|
|
1762
1557
|
}
|
|
1763
1558
|
|
|
1764
1559
|
/**
|
|
@@ -1830,52 +1625,42 @@ declare class MockApiClient {
|
|
|
1830
1625
|
getPortalUrl(sessionId: string): Promise<PortalUrlResponse>;
|
|
1831
1626
|
validatePortalSession(sessionId: string, signature: string): Promise<SessionValidationResponse>;
|
|
1832
1627
|
completePortalSession(sessionId: string): Promise<PortalUrlResponse>;
|
|
1833
|
-
getHoldings(
|
|
1834
|
-
data: Holding[];
|
|
1835
|
-
}>;
|
|
1836
|
-
getOrders(accessToken: string, filter?: OrdersFilter): Promise<{
|
|
1837
|
-
data: Order[];
|
|
1838
|
-
}>;
|
|
1839
|
-
getPortfolio(accessToken: string): Promise<{
|
|
1840
|
-
data: Portfolio;
|
|
1841
|
-
}>;
|
|
1842
|
-
placeOrder(accessToken: string, order: Order): Promise<void>;
|
|
1843
|
-
getHoldingsAuto(): Promise<{
|
|
1628
|
+
getHoldings(filter?: OrdersFilter): Promise<{
|
|
1844
1629
|
data: Holding[];
|
|
1845
1630
|
}>;
|
|
1846
|
-
|
|
1631
|
+
getOrders(filter?: OrdersFilter): Promise<{
|
|
1847
1632
|
data: Order[];
|
|
1848
1633
|
}>;
|
|
1849
|
-
|
|
1634
|
+
getPortfolio(): Promise<{
|
|
1850
1635
|
data: Portfolio;
|
|
1851
1636
|
}>;
|
|
1852
|
-
|
|
1853
|
-
placeBrokerOrder(
|
|
1637
|
+
placeOrder(order: BrokerOrderParams): Promise<void>;
|
|
1638
|
+
placeBrokerOrder(params: Partial<BrokerOrderParams> & {
|
|
1854
1639
|
symbol: string;
|
|
1855
1640
|
orderQty: number;
|
|
1856
1641
|
action: 'Buy' | 'Sell';
|
|
1857
|
-
orderType: 'Market' | 'Limit' | 'Stop' | '
|
|
1858
|
-
assetType: 'Stock' | 'Option' | 'Crypto' | '
|
|
1859
|
-
}, extras?: BrokerExtras): Promise<OrderResponse>;
|
|
1860
|
-
cancelBrokerOrder(orderId: string, broker?: 'robinhood' | 'tasty_trade' | 'ninja_trader', extras?: any): Promise<OrderResponse>;
|
|
1861
|
-
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>;
|
|
1862
1647
|
setBroker(broker: 'robinhood' | 'tasty_trade' | 'ninja_trader'): void;
|
|
1863
1648
|
setAccount(accountNumber: string, accountId?: string): void;
|
|
1864
1649
|
getTradingContext(): TradingContext;
|
|
1865
1650
|
clearTradingContext(): void;
|
|
1866
|
-
placeStockMarketOrder(
|
|
1867
|
-
placeStockLimitOrder(
|
|
1868
|
-
placeStockStopOrder(
|
|
1869
|
-
placeCryptoMarketOrder(
|
|
1870
|
-
placeCryptoLimitOrder(
|
|
1871
|
-
placeOptionsMarketOrder(
|
|
1872
|
-
placeOptionsLimitOrder(
|
|
1873
|
-
placeFuturesMarketOrder(
|
|
1874
|
-
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>;
|
|
1875
1660
|
revokeToken(accessToken: string): Promise<void>;
|
|
1876
1661
|
getUserToken(userId: string): Promise<UserToken>;
|
|
1877
1662
|
getCurrentSessionState(): SessionState | null;
|
|
1878
|
-
getBrokerList(
|
|
1663
|
+
getBrokerList(): Promise<{
|
|
1879
1664
|
_id: string;
|
|
1880
1665
|
response_data: BrokerInfo[];
|
|
1881
1666
|
message: string;
|
|
@@ -1883,7 +1668,7 @@ declare class MockApiClient {
|
|
|
1883
1668
|
warnings: null;
|
|
1884
1669
|
errors: null;
|
|
1885
1670
|
}>;
|
|
1886
|
-
getBrokerAccounts(
|
|
1671
|
+
getBrokerAccounts(options?: BrokerDataOptions): Promise<{
|
|
1887
1672
|
_id: string;
|
|
1888
1673
|
response_data: BrokerAccount[];
|
|
1889
1674
|
message: string;
|
|
@@ -1891,7 +1676,7 @@ declare class MockApiClient {
|
|
|
1891
1676
|
warnings: null;
|
|
1892
1677
|
errors: null;
|
|
1893
1678
|
}>;
|
|
1894
|
-
getBrokerOrders(
|
|
1679
|
+
getBrokerOrders(options?: BrokerDataOptions): Promise<{
|
|
1895
1680
|
_id: string;
|
|
1896
1681
|
response_data: BrokerOrder[];
|
|
1897
1682
|
message: string;
|
|
@@ -1899,7 +1684,7 @@ declare class MockApiClient {
|
|
|
1899
1684
|
warnings: null;
|
|
1900
1685
|
errors: null;
|
|
1901
1686
|
}>;
|
|
1902
|
-
getBrokerPositions(
|
|
1687
|
+
getBrokerPositions(options?: BrokerDataOptions): Promise<{
|
|
1903
1688
|
_id: string;
|
|
1904
1689
|
response_data: BrokerPosition[];
|
|
1905
1690
|
message: string;
|
|
@@ -1914,52 +1699,12 @@ declare class MockApiClient {
|
|
|
1914
1699
|
data: BrokerDataPosition[];
|
|
1915
1700
|
}>;
|
|
1916
1701
|
getBrokerDataAccountsWithFilter(filter?: AccountsFilter): Promise<{
|
|
1917
|
-
data:
|
|
1918
|
-
}>;
|
|
1919
|
-
getBrokerOrdersPage(page?: number, perPage?: number, filters?: OrdersFilter): Promise<PaginatedResult<any[]>>;
|
|
1920
|
-
getBrokerAccountsPage(page?: number, perPage?: number, filters?: AccountsFilter): Promise<PaginatedResult<any[]>>;
|
|
1921
|
-
getBrokerPositionsPage(page?: number, perPage?: number, filters?: PositionsFilter): Promise<PaginatedResult<any[]>>;
|
|
1922
|
-
getBrokerConnections(accessToken: string): Promise<{
|
|
1923
|
-
_id: string;
|
|
1924
|
-
response_data: BrokerConnection[];
|
|
1925
|
-
message: string;
|
|
1926
|
-
status_code: number;
|
|
1927
|
-
warnings: null;
|
|
1928
|
-
errors: null;
|
|
1929
|
-
}>;
|
|
1930
|
-
getBrokerListAuto(): Promise<{
|
|
1931
|
-
_id: string;
|
|
1932
|
-
response_data: BrokerInfo[];
|
|
1933
|
-
message: string;
|
|
1934
|
-
status_code: number;
|
|
1935
|
-
warnings: null;
|
|
1936
|
-
errors: null;
|
|
1937
|
-
}>;
|
|
1938
|
-
getBrokerAccountsAuto(options?: BrokerDataOptions): Promise<{
|
|
1939
|
-
_id: string;
|
|
1940
|
-
response_data: BrokerAccount[];
|
|
1941
|
-
message: string;
|
|
1942
|
-
status_code: number;
|
|
1943
|
-
warnings: null;
|
|
1944
|
-
errors: null;
|
|
1945
|
-
}>;
|
|
1946
|
-
getBrokerOrdersAuto(options?: BrokerDataOptions): Promise<{
|
|
1947
|
-
_id: string;
|
|
1948
|
-
response_data: BrokerOrder[];
|
|
1949
|
-
message: string;
|
|
1950
|
-
status_code: number;
|
|
1951
|
-
warnings: null;
|
|
1952
|
-
errors: null;
|
|
1953
|
-
}>;
|
|
1954
|
-
getBrokerPositionsAuto(options?: BrokerDataOptions): Promise<{
|
|
1955
|
-
_id: string;
|
|
1956
|
-
response_data: BrokerPosition[];
|
|
1957
|
-
message: string;
|
|
1958
|
-
status_code: number;
|
|
1959
|
-
warnings: null;
|
|
1960
|
-
errors: null;
|
|
1702
|
+
data: BrokerAccount[];
|
|
1961
1703
|
}>;
|
|
1962
|
-
|
|
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<{
|
|
1963
1708
|
_id: string;
|
|
1964
1709
|
response_data: BrokerConnection[];
|
|
1965
1710
|
message: string;
|
|
@@ -1967,16 +1712,12 @@ declare class MockApiClient {
|
|
|
1967
1712
|
warnings: null;
|
|
1968
1713
|
errors: null;
|
|
1969
1714
|
}>;
|
|
1970
|
-
|
|
1971
|
-
|
|
1972
|
-
|
|
1973
|
-
|
|
1974
|
-
|
|
1975
|
-
|
|
1976
|
-
}, extras?: BrokerExtras): Promise<OrderResponse>;
|
|
1977
|
-
placeStockMarketOrderAuto(symbol: string, orderQty: number, action: 'Buy' | 'Sell', broker?: 'robinhood' | 'tasty_trade' | 'ninja_trader', accountNumber?: string, extras?: BrokerExtras): Promise<OrderResponse>;
|
|
1978
|
-
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>;
|
|
1979
|
-
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>;
|
|
1980
1721
|
getMockDataProvider(): MockDataProvider;
|
|
1981
1722
|
clearMockData(): void;
|
|
1982
1723
|
/**
|
|
@@ -1997,7 +1738,7 @@ declare class MockFactory {
|
|
|
1997
1738
|
* @param mockConfig - Optional mock configuration (only used if mocks are enabled)
|
|
1998
1739
|
* @returns ApiClient or MockApiClient instance
|
|
1999
1740
|
*/
|
|
2000
|
-
static createApiClient(baseUrl: string, deviceInfo?: DeviceInfo$1, mockConfig?: MockConfig): ApiClient
|
|
1741
|
+
static createApiClient(baseUrl: string, deviceInfo?: DeviceInfo$1, mockConfig?: MockConfig): ApiClient | MockApiClient;
|
|
2001
1742
|
/**
|
|
2002
1743
|
* Force create a mock API client regardless of environment settings
|
|
2003
1744
|
* @param baseUrl - The base URL for the API
|
|
@@ -2012,7 +1753,7 @@ declare class MockFactory {
|
|
|
2012
1753
|
* @param deviceInfo - Optional device information
|
|
2013
1754
|
* @returns ApiClient instance
|
|
2014
1755
|
*/
|
|
2015
|
-
static createRealApiClient(baseUrl: string, deviceInfo?: DeviceInfo$1): ApiClient
|
|
1756
|
+
static createRealApiClient(baseUrl: string, deviceInfo?: DeviceInfo$1): ApiClient;
|
|
2016
1757
|
/**
|
|
2017
1758
|
* Check if mocks are currently enabled
|
|
2018
1759
|
* @returns boolean indicating if mocks are enabled
|
|
@@ -2028,5 +1769,5 @@ declare class MockFactory {
|
|
|
2028
1769
|
};
|
|
2029
1770
|
}
|
|
2030
1771
|
|
|
2031
|
-
export { ApiClient
|
|
2032
|
-
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 };
|