@finatic/client 0.0.140 → 0.0.141
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 +72 -0
- package/dist/index.d.ts +218 -1
- package/dist/index.js +212 -0
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +212 -0
- package/dist/index.mjs.map +1 -1
- package/dist/types/core/client/ApiClient.d.ts +69 -1
- package/dist/types/core/client/FinaticConnect.d.ts +33 -0
- package/dist/types/index.d.ts +1 -1
- package/dist/types/types/api/broker.d.ts +116 -0
- package/package.json +1 -1
- package/src/core/client/ApiClient.ts +257 -0
- package/src/core/client/FinaticConnect.ts +81 -0
- package/src/index.ts +12 -0
- package/src/types/api/broker.ts +131 -0
package/README.md
CHANGED
|
@@ -356,6 +356,73 @@ if (ordersPage.hasPrevious) {
|
|
|
356
356
|
// No manual session management required
|
|
357
357
|
```
|
|
358
358
|
|
|
359
|
+
## Order and Position Detail Data
|
|
360
|
+
|
|
361
|
+
### Getting Order Fills
|
|
362
|
+
|
|
363
|
+
Order fills represent individual execution fills for an order:
|
|
364
|
+
|
|
365
|
+
```typescript
|
|
366
|
+
// Get fills for a specific order
|
|
367
|
+
const fills = await finatic.getOrderFills('order-123', {
|
|
368
|
+
connection_id: 'connection-456',
|
|
369
|
+
limit: 50,
|
|
370
|
+
offset: 0,
|
|
371
|
+
});
|
|
372
|
+
```
|
|
373
|
+
|
|
374
|
+
### Getting Order Events
|
|
375
|
+
|
|
376
|
+
Order events represent lifecycle events for an order:
|
|
377
|
+
|
|
378
|
+
```typescript
|
|
379
|
+
// Get events for a specific order
|
|
380
|
+
const events = await finatic.getOrderEvents('order-123', {
|
|
381
|
+
connection_id: 'connection-456',
|
|
382
|
+
limit: 100,
|
|
383
|
+
});
|
|
384
|
+
```
|
|
385
|
+
|
|
386
|
+
### Getting Order Groups
|
|
387
|
+
|
|
388
|
+
Order groups contain multiple related orders:
|
|
389
|
+
|
|
390
|
+
```typescript
|
|
391
|
+
// Get order groups with filters
|
|
392
|
+
const groups = await finatic.getOrderGroups({
|
|
393
|
+
broker_id: 'robinhood',
|
|
394
|
+
connection_id: 'connection-456',
|
|
395
|
+
created_after: '2024-01-01T00:00:00Z',
|
|
396
|
+
limit: 50,
|
|
397
|
+
});
|
|
398
|
+
```
|
|
399
|
+
|
|
400
|
+
### Getting Position Lots (Tax Lots)
|
|
401
|
+
|
|
402
|
+
Position lots are used for tax reporting and track when positions were opened/closed:
|
|
403
|
+
|
|
404
|
+
```typescript
|
|
405
|
+
// Get position lots for tax reporting
|
|
406
|
+
const lots = await finatic.getPositionLots({
|
|
407
|
+
broker_id: 'robinhood',
|
|
408
|
+
account_id: '123456789',
|
|
409
|
+
symbol: 'AAPL',
|
|
410
|
+
limit: 100,
|
|
411
|
+
});
|
|
412
|
+
```
|
|
413
|
+
|
|
414
|
+
### Getting Position Lot Fills
|
|
415
|
+
|
|
416
|
+
Position lot fills show the execution details for each lot:
|
|
417
|
+
|
|
418
|
+
```typescript
|
|
419
|
+
// Get fills for a specific position lot
|
|
420
|
+
const lotFills = await finatic.getPositionLotFills('lot-123', {
|
|
421
|
+
connection_id: 'connection-456',
|
|
422
|
+
limit: 50,
|
|
423
|
+
});
|
|
424
|
+
```
|
|
425
|
+
|
|
359
426
|
## Type Definitions
|
|
360
427
|
|
|
361
428
|
The SDK includes comprehensive TypeScript definitions for all data structures:
|
|
@@ -368,6 +435,11 @@ The SDK includes comprehensive TypeScript definitions for all data structures:
|
|
|
368
435
|
- `BrokerConnection`: Connection information
|
|
369
436
|
- `OrderResponse`: Order operation responses
|
|
370
437
|
- `PaginatedResult`: Paginated data responses
|
|
438
|
+
- `OrderFill`: Order fill information
|
|
439
|
+
- `OrderEvent`: Order event information
|
|
440
|
+
- `OrderGroup`: Order group information
|
|
441
|
+
- `PositionLot`: Position lot (tax lot) information
|
|
442
|
+
- `PositionLotFill`: Position lot fill information
|
|
371
443
|
|
|
372
444
|
## Error Types
|
|
373
445
|
|
package/dist/index.d.ts
CHANGED
|
@@ -473,6 +473,122 @@ interface DisconnectCompanyResponse {
|
|
|
473
473
|
message: string;
|
|
474
474
|
status_code: number;
|
|
475
475
|
}
|
|
476
|
+
interface OrderFill {
|
|
477
|
+
id: string;
|
|
478
|
+
order_id: string;
|
|
479
|
+
leg_id: string | null;
|
|
480
|
+
price: number;
|
|
481
|
+
quantity: number;
|
|
482
|
+
executed_at: string;
|
|
483
|
+
execution_id: string | null;
|
|
484
|
+
trade_id: string | null;
|
|
485
|
+
venue: string | null;
|
|
486
|
+
commission_fee: number | null;
|
|
487
|
+
created_at: string;
|
|
488
|
+
updated_at: string;
|
|
489
|
+
}
|
|
490
|
+
interface OrderEvent {
|
|
491
|
+
id: string;
|
|
492
|
+
order_id: string;
|
|
493
|
+
order_group_id: string | null;
|
|
494
|
+
event_type: string | null;
|
|
495
|
+
event_time: string;
|
|
496
|
+
event_id: string | null;
|
|
497
|
+
order_status: string | null;
|
|
498
|
+
inferred: boolean;
|
|
499
|
+
confidence: number | null;
|
|
500
|
+
reason_code: string | null;
|
|
501
|
+
recorded_at: string | null;
|
|
502
|
+
}
|
|
503
|
+
interface OrderLeg {
|
|
504
|
+
id: string;
|
|
505
|
+
order_id: string;
|
|
506
|
+
leg_index: number;
|
|
507
|
+
asset_type: string;
|
|
508
|
+
broker_provided_symbol: string | null;
|
|
509
|
+
quantity: number;
|
|
510
|
+
filled_quantity: number | null;
|
|
511
|
+
avg_fill_price: number | null;
|
|
512
|
+
created_at: string | null;
|
|
513
|
+
updated_at: string | null;
|
|
514
|
+
}
|
|
515
|
+
interface OrderGroupOrder extends BrokerDataOrder {
|
|
516
|
+
legs: OrderLeg[];
|
|
517
|
+
}
|
|
518
|
+
interface OrderGroup {
|
|
519
|
+
id: string;
|
|
520
|
+
user_broker_connection_id: string | null;
|
|
521
|
+
created_at: string;
|
|
522
|
+
updated_at: string;
|
|
523
|
+
orders: OrderGroupOrder[];
|
|
524
|
+
}
|
|
525
|
+
interface PositionLot {
|
|
526
|
+
id: string;
|
|
527
|
+
position_id: string | null;
|
|
528
|
+
user_broker_connection_id: string;
|
|
529
|
+
broker_provided_account_id: string;
|
|
530
|
+
instrument_key: string;
|
|
531
|
+
asset_type: string | null;
|
|
532
|
+
side: 'long' | 'short' | null;
|
|
533
|
+
open_quantity: number;
|
|
534
|
+
closed_quantity: number;
|
|
535
|
+
remaining_quantity: number;
|
|
536
|
+
open_price: number;
|
|
537
|
+
close_price_avg: number | null;
|
|
538
|
+
cost_basis: number;
|
|
539
|
+
cost_basis_w_commission: number;
|
|
540
|
+
realized_pl: number;
|
|
541
|
+
realized_pl_w_commission: number;
|
|
542
|
+
lot_opened_at: string;
|
|
543
|
+
lot_closed_at: string | null;
|
|
544
|
+
position_group_id: string | null;
|
|
545
|
+
created_at: string;
|
|
546
|
+
updated_at: string;
|
|
547
|
+
position_lot_fills?: PositionLotFill[];
|
|
548
|
+
}
|
|
549
|
+
interface PositionLotFill {
|
|
550
|
+
id: string;
|
|
551
|
+
lot_id: string;
|
|
552
|
+
order_fill_id: string;
|
|
553
|
+
fill_price: number;
|
|
554
|
+
fill_quantity: number;
|
|
555
|
+
executed_at: string;
|
|
556
|
+
commission_share: number | null;
|
|
557
|
+
created_at: string;
|
|
558
|
+
updated_at: string;
|
|
559
|
+
}
|
|
560
|
+
interface OrderFillsFilter {
|
|
561
|
+
connection_id?: string;
|
|
562
|
+
limit?: number;
|
|
563
|
+
offset?: number;
|
|
564
|
+
}
|
|
565
|
+
interface OrderEventsFilter {
|
|
566
|
+
connection_id?: string;
|
|
567
|
+
limit?: number;
|
|
568
|
+
offset?: number;
|
|
569
|
+
}
|
|
570
|
+
interface OrderGroupsFilter {
|
|
571
|
+
broker_id?: string;
|
|
572
|
+
connection_id?: string;
|
|
573
|
+
limit?: number;
|
|
574
|
+
offset?: number;
|
|
575
|
+
created_after?: string;
|
|
576
|
+
created_before?: string;
|
|
577
|
+
}
|
|
578
|
+
interface PositionLotsFilter {
|
|
579
|
+
broker_id?: string;
|
|
580
|
+
connection_id?: string;
|
|
581
|
+
account_id?: string;
|
|
582
|
+
symbol?: string;
|
|
583
|
+
position_id?: string;
|
|
584
|
+
limit?: number;
|
|
585
|
+
offset?: number;
|
|
586
|
+
}
|
|
587
|
+
interface PositionLotFillsFilter {
|
|
588
|
+
connection_id?: string;
|
|
589
|
+
limit?: number;
|
|
590
|
+
offset?: number;
|
|
591
|
+
}
|
|
476
592
|
|
|
477
593
|
/**
|
|
478
594
|
* Order-related types
|
|
@@ -1192,6 +1308,74 @@ declare class ApiClient {
|
|
|
1192
1308
|
* @returns Promise with disconnect response
|
|
1193
1309
|
*/
|
|
1194
1310
|
disconnectCompany(connectionId: string): Promise<DisconnectCompanyResponse>;
|
|
1311
|
+
/**
|
|
1312
|
+
* Get order fills for a specific order
|
|
1313
|
+
* @param orderId - The order ID
|
|
1314
|
+
* @param filter - Optional filter parameters
|
|
1315
|
+
* @returns Promise with order fills response
|
|
1316
|
+
*/
|
|
1317
|
+
getOrderFills(orderId: string, filter?: OrderFillsFilter): Promise<{
|
|
1318
|
+
_id: string;
|
|
1319
|
+
response_data: OrderFill[];
|
|
1320
|
+
message: string;
|
|
1321
|
+
status_code: number;
|
|
1322
|
+
warnings: null;
|
|
1323
|
+
errors: null;
|
|
1324
|
+
}>;
|
|
1325
|
+
/**
|
|
1326
|
+
* Get order events for a specific order
|
|
1327
|
+
* @param orderId - The order ID
|
|
1328
|
+
* @param filter - Optional filter parameters
|
|
1329
|
+
* @returns Promise with order events response
|
|
1330
|
+
*/
|
|
1331
|
+
getOrderEvents(orderId: string, filter?: OrderEventsFilter): Promise<{
|
|
1332
|
+
_id: string;
|
|
1333
|
+
response_data: OrderEvent[];
|
|
1334
|
+
message: string;
|
|
1335
|
+
status_code: number;
|
|
1336
|
+
warnings: null;
|
|
1337
|
+
errors: null;
|
|
1338
|
+
}>;
|
|
1339
|
+
/**
|
|
1340
|
+
* Get order groups
|
|
1341
|
+
* @param filter - Optional filter parameters
|
|
1342
|
+
* @returns Promise with order groups response
|
|
1343
|
+
*/
|
|
1344
|
+
getOrderGroups(filter?: OrderGroupsFilter): Promise<{
|
|
1345
|
+
_id: string;
|
|
1346
|
+
response_data: OrderGroup[];
|
|
1347
|
+
message: string;
|
|
1348
|
+
status_code: number;
|
|
1349
|
+
warnings: null;
|
|
1350
|
+
errors: null;
|
|
1351
|
+
}>;
|
|
1352
|
+
/**
|
|
1353
|
+
* Get position lots (tax lots for positions)
|
|
1354
|
+
* @param filter - Optional filter parameters
|
|
1355
|
+
* @returns Promise with position lots response
|
|
1356
|
+
*/
|
|
1357
|
+
getPositionLots(filter?: PositionLotsFilter): Promise<{
|
|
1358
|
+
_id: string;
|
|
1359
|
+
response_data: PositionLot[];
|
|
1360
|
+
message: string;
|
|
1361
|
+
status_code: number;
|
|
1362
|
+
warnings: null;
|
|
1363
|
+
errors: null;
|
|
1364
|
+
}>;
|
|
1365
|
+
/**
|
|
1366
|
+
* Get position lot fills for a specific lot
|
|
1367
|
+
* @param lotId - The position lot ID
|
|
1368
|
+
* @param filter - Optional filter parameters
|
|
1369
|
+
* @returns Promise with position lot fills response
|
|
1370
|
+
*/
|
|
1371
|
+
getPositionLotFills(lotId: string, filter?: PositionLotFillsFilter): Promise<{
|
|
1372
|
+
_id: string;
|
|
1373
|
+
response_data: PositionLotFill[];
|
|
1374
|
+
message: string;
|
|
1375
|
+
status_code: number;
|
|
1376
|
+
warnings: null;
|
|
1377
|
+
errors: null;
|
|
1378
|
+
}>;
|
|
1195
1379
|
}
|
|
1196
1380
|
|
|
1197
1381
|
type EventCallback = (...args: any[]) => void;
|
|
@@ -1496,6 +1680,39 @@ declare class FinaticConnect extends EventEmitter {
|
|
|
1496
1680
|
* @throws AuthenticationError if user is not authenticated
|
|
1497
1681
|
*/
|
|
1498
1682
|
disconnectCompany(connectionId: string): Promise<DisconnectCompanyResponse>;
|
|
1683
|
+
/**
|
|
1684
|
+
* Get order fills for a specific order
|
|
1685
|
+
* @param orderId - The order ID
|
|
1686
|
+
* @param filter - Optional filter parameters
|
|
1687
|
+
* @returns Promise with order fills response
|
|
1688
|
+
*/
|
|
1689
|
+
getOrderFills(orderId: string, filter?: OrderFillsFilter): Promise<OrderFill[]>;
|
|
1690
|
+
/**
|
|
1691
|
+
* Get order events for a specific order
|
|
1692
|
+
* @param orderId - The order ID
|
|
1693
|
+
* @param filter - Optional filter parameters
|
|
1694
|
+
* @returns Promise with order events response
|
|
1695
|
+
*/
|
|
1696
|
+
getOrderEvents(orderId: string, filter?: OrderEventsFilter): Promise<OrderEvent[]>;
|
|
1697
|
+
/**
|
|
1698
|
+
* Get order groups
|
|
1699
|
+
* @param filter - Optional filter parameters
|
|
1700
|
+
* @returns Promise with order groups response
|
|
1701
|
+
*/
|
|
1702
|
+
getOrderGroups(filter?: OrderGroupsFilter): Promise<OrderGroup[]>;
|
|
1703
|
+
/**
|
|
1704
|
+
* Get position lots (tax lots for positions)
|
|
1705
|
+
* @param filter - Optional filter parameters
|
|
1706
|
+
* @returns Promise with position lots response
|
|
1707
|
+
*/
|
|
1708
|
+
getPositionLots(filter?: PositionLotsFilter): Promise<PositionLot[]>;
|
|
1709
|
+
/**
|
|
1710
|
+
* Get position lot fills for a specific lot
|
|
1711
|
+
* @param lotId - The position lot ID
|
|
1712
|
+
* @param filter - Optional filter parameters
|
|
1713
|
+
* @returns Promise with position lot fills response
|
|
1714
|
+
*/
|
|
1715
|
+
getPositionLotFills(lotId: string, filter?: PositionLotFillsFilter): Promise<PositionLotFill[]>;
|
|
1499
1716
|
}
|
|
1500
1717
|
|
|
1501
1718
|
/**
|
|
@@ -1535,4 +1752,4 @@ declare function createCustomThemeFromPreset(preset: string, modifications: Part
|
|
|
1535
1752
|
declare const portalThemePresets: Record<string, PortalThemeConfig>;
|
|
1536
1753
|
|
|
1537
1754
|
export { ApiClient, ApiError, AuthenticationError, AuthorizationError, BaseError, CompanyAccessError, EventEmitter, FinaticConnect, NetworkError, OrderError, OrderValidationError, PaginatedResult, RateLimitError, SecurityError, SessionError, TokenError, TradingNotEnabledError, appendThemeToURL, createCustomThemeFromPreset, generatePortalThemeURL, getThemePreset, portalThemePresets, validateCustomTheme };
|
|
1538
|
-
export type { AccountsFilter, ApiConfig, ApiResponse, BalancesFilter, BrokerAccount, BrokerBalance, BrokerConnection, BrokerDataAccount, BrokerDataOptions, BrokerDataOrder, BrokerDataPosition, BrokerExtras$1 as BrokerExtras, BrokerInfo, BrokerOrder, BrokerOrderParams, BrokerPosition, CryptoOrderOptions, DeviceInfo$1 as DeviceInfo, FilteredAccountsResponse, FilteredBalancesResponse, 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, SessionStatus, SessionValidationResponse, TokenInfo, TradeAccessDeniedError, TradingContext, UserToken, ValidationError };
|
|
1755
|
+
export type { AccountsFilter, ApiConfig, ApiResponse, BalancesFilter, BrokerAccount, BrokerBalance, BrokerConnection, BrokerDataAccount, BrokerDataOptions, BrokerDataOrder, BrokerDataPosition, BrokerExtras$1 as BrokerExtras, BrokerInfo, BrokerOrder, BrokerOrderParams, BrokerPosition, CryptoOrderOptions, DeviceInfo$1 as DeviceInfo, FilteredAccountsResponse, FilteredBalancesResponse, FilteredOrdersResponse, FilteredPositionsResponse, FinaticConnectOptions, FinaticUserToken, Holding, OptionsOrder, OptionsOrderOptions, Order, OrderEvent, OrderEventsFilter, OrderFill, OrderFillsFilter, OrderGroup, OrderGroupOrder, OrderGroupsFilter, OrderLeg, OrderNotFoundError, OrderResponse, OrdersFilter, OtpRequestResponse, OtpVerifyResponse, PerformanceMetrics, PortalMessage, PortalProps, PortalResponse, PortalTheme, PortalThemeConfig, PortalThemePreset, PortalUrlResponse, Portfolio, PortfolioSnapshot, PositionLot, PositionLotFill, PositionLotFillsFilter, PositionLotsFilter, PositionsFilter, RefreshTokenRequest, RefreshTokenResponse, RequestHeaders, SessionAuthenticateResponse, SessionInitResponse, SessionResponse, SessionStatus, SessionValidationResponse, TokenInfo, TradeAccessDeniedError, TradingContext, UserToken, ValidationError };
|
package/dist/index.js
CHANGED
|
@@ -1411,6 +1411,155 @@ class ApiClient {
|
|
|
1411
1411
|
},
|
|
1412
1412
|
});
|
|
1413
1413
|
}
|
|
1414
|
+
/**
|
|
1415
|
+
* Get order fills for a specific order
|
|
1416
|
+
* @param orderId - The order ID
|
|
1417
|
+
* @param filter - Optional filter parameters
|
|
1418
|
+
* @returns Promise with order fills response
|
|
1419
|
+
*/
|
|
1420
|
+
async getOrderFills(orderId, filter) {
|
|
1421
|
+
const accessToken = await this.getValidAccessToken();
|
|
1422
|
+
const params = {};
|
|
1423
|
+
if (filter?.connection_id) {
|
|
1424
|
+
params.connection_id = filter.connection_id;
|
|
1425
|
+
}
|
|
1426
|
+
if (filter?.limit) {
|
|
1427
|
+
params.limit = filter.limit.toString();
|
|
1428
|
+
}
|
|
1429
|
+
if (filter?.offset) {
|
|
1430
|
+
params.offset = filter.offset.toString();
|
|
1431
|
+
}
|
|
1432
|
+
return this.request(`/brokers/data/orders/${orderId}/fills`, {
|
|
1433
|
+
method: 'GET',
|
|
1434
|
+
headers: {
|
|
1435
|
+
Authorization: `Bearer ${accessToken}`,
|
|
1436
|
+
},
|
|
1437
|
+
params,
|
|
1438
|
+
});
|
|
1439
|
+
}
|
|
1440
|
+
/**
|
|
1441
|
+
* Get order events for a specific order
|
|
1442
|
+
* @param orderId - The order ID
|
|
1443
|
+
* @param filter - Optional filter parameters
|
|
1444
|
+
* @returns Promise with order events response
|
|
1445
|
+
*/
|
|
1446
|
+
async getOrderEvents(orderId, filter) {
|
|
1447
|
+
const accessToken = await this.getValidAccessToken();
|
|
1448
|
+
const params = {};
|
|
1449
|
+
if (filter?.connection_id) {
|
|
1450
|
+
params.connection_id = filter.connection_id;
|
|
1451
|
+
}
|
|
1452
|
+
if (filter?.limit) {
|
|
1453
|
+
params.limit = filter.limit.toString();
|
|
1454
|
+
}
|
|
1455
|
+
if (filter?.offset) {
|
|
1456
|
+
params.offset = filter.offset.toString();
|
|
1457
|
+
}
|
|
1458
|
+
return this.request(`/brokers/data/orders/${orderId}/events`, {
|
|
1459
|
+
method: 'GET',
|
|
1460
|
+
headers: {
|
|
1461
|
+
Authorization: `Bearer ${accessToken}`,
|
|
1462
|
+
},
|
|
1463
|
+
params,
|
|
1464
|
+
});
|
|
1465
|
+
}
|
|
1466
|
+
/**
|
|
1467
|
+
* Get order groups
|
|
1468
|
+
* @param filter - Optional filter parameters
|
|
1469
|
+
* @returns Promise with order groups response
|
|
1470
|
+
*/
|
|
1471
|
+
async getOrderGroups(filter) {
|
|
1472
|
+
const accessToken = await this.getValidAccessToken();
|
|
1473
|
+
const params = {};
|
|
1474
|
+
if (filter?.broker_id) {
|
|
1475
|
+
params.broker_id = filter.broker_id;
|
|
1476
|
+
}
|
|
1477
|
+
if (filter?.connection_id) {
|
|
1478
|
+
params.connection_id = filter.connection_id;
|
|
1479
|
+
}
|
|
1480
|
+
if (filter?.limit) {
|
|
1481
|
+
params.limit = filter.limit.toString();
|
|
1482
|
+
}
|
|
1483
|
+
if (filter?.offset) {
|
|
1484
|
+
params.offset = filter.offset.toString();
|
|
1485
|
+
}
|
|
1486
|
+
if (filter?.created_after) {
|
|
1487
|
+
params.created_after = filter.created_after;
|
|
1488
|
+
}
|
|
1489
|
+
if (filter?.created_before) {
|
|
1490
|
+
params.created_before = filter.created_before;
|
|
1491
|
+
}
|
|
1492
|
+
return this.request('/brokers/data/orders/groups', {
|
|
1493
|
+
method: 'GET',
|
|
1494
|
+
headers: {
|
|
1495
|
+
Authorization: `Bearer ${accessToken}`,
|
|
1496
|
+
},
|
|
1497
|
+
params,
|
|
1498
|
+
});
|
|
1499
|
+
}
|
|
1500
|
+
/**
|
|
1501
|
+
* Get position lots (tax lots for positions)
|
|
1502
|
+
* @param filter - Optional filter parameters
|
|
1503
|
+
* @returns Promise with position lots response
|
|
1504
|
+
*/
|
|
1505
|
+
async getPositionLots(filter) {
|
|
1506
|
+
const accessToken = await this.getValidAccessToken();
|
|
1507
|
+
const params = {};
|
|
1508
|
+
if (filter?.broker_id) {
|
|
1509
|
+
params.broker_id = filter.broker_id;
|
|
1510
|
+
}
|
|
1511
|
+
if (filter?.connection_id) {
|
|
1512
|
+
params.connection_id = filter.connection_id;
|
|
1513
|
+
}
|
|
1514
|
+
if (filter?.account_id) {
|
|
1515
|
+
params.account_id = filter.account_id;
|
|
1516
|
+
}
|
|
1517
|
+
if (filter?.symbol) {
|
|
1518
|
+
params.symbol = filter.symbol;
|
|
1519
|
+
}
|
|
1520
|
+
if (filter?.position_id) {
|
|
1521
|
+
params.position_id = filter.position_id;
|
|
1522
|
+
}
|
|
1523
|
+
if (filter?.limit) {
|
|
1524
|
+
params.limit = filter.limit.toString();
|
|
1525
|
+
}
|
|
1526
|
+
if (filter?.offset) {
|
|
1527
|
+
params.offset = filter.offset.toString();
|
|
1528
|
+
}
|
|
1529
|
+
return this.request('/brokers/data/positions/lots', {
|
|
1530
|
+
method: 'GET',
|
|
1531
|
+
headers: {
|
|
1532
|
+
Authorization: `Bearer ${accessToken}`,
|
|
1533
|
+
},
|
|
1534
|
+
params,
|
|
1535
|
+
});
|
|
1536
|
+
}
|
|
1537
|
+
/**
|
|
1538
|
+
* Get position lot fills for a specific lot
|
|
1539
|
+
* @param lotId - The position lot ID
|
|
1540
|
+
* @param filter - Optional filter parameters
|
|
1541
|
+
* @returns Promise with position lot fills response
|
|
1542
|
+
*/
|
|
1543
|
+
async getPositionLotFills(lotId, filter) {
|
|
1544
|
+
const accessToken = await this.getValidAccessToken();
|
|
1545
|
+
const params = {};
|
|
1546
|
+
if (filter?.connection_id) {
|
|
1547
|
+
params.connection_id = filter.connection_id;
|
|
1548
|
+
}
|
|
1549
|
+
if (filter?.limit) {
|
|
1550
|
+
params.limit = filter.limit.toString();
|
|
1551
|
+
}
|
|
1552
|
+
if (filter?.offset) {
|
|
1553
|
+
params.offset = filter.offset.toString();
|
|
1554
|
+
}
|
|
1555
|
+
return this.request(`/brokers/data/positions/lots/${lotId}/fills`, {
|
|
1556
|
+
method: 'GET',
|
|
1557
|
+
headers: {
|
|
1558
|
+
Authorization: `Bearer ${accessToken}`,
|
|
1559
|
+
},
|
|
1560
|
+
params,
|
|
1561
|
+
});
|
|
1562
|
+
}
|
|
1414
1563
|
}
|
|
1415
1564
|
|
|
1416
1565
|
class EventEmitter {
|
|
@@ -5885,6 +6034,69 @@ class FinaticConnect extends EventEmitter {
|
|
|
5885
6034
|
}
|
|
5886
6035
|
return this.apiClient.disconnectCompany(connectionId);
|
|
5887
6036
|
}
|
|
6037
|
+
/**
|
|
6038
|
+
* Get order fills for a specific order
|
|
6039
|
+
* @param orderId - The order ID
|
|
6040
|
+
* @param filter - Optional filter parameters
|
|
6041
|
+
* @returns Promise with order fills response
|
|
6042
|
+
*/
|
|
6043
|
+
async getOrderFills(orderId, filter) {
|
|
6044
|
+
if (!(await this.isAuthenticated())) {
|
|
6045
|
+
throw new AuthenticationError('User is not authenticated');
|
|
6046
|
+
}
|
|
6047
|
+
const response = await this.apiClient.getOrderFills(orderId, filter);
|
|
6048
|
+
return response.response_data;
|
|
6049
|
+
}
|
|
6050
|
+
/**
|
|
6051
|
+
* Get order events for a specific order
|
|
6052
|
+
* @param orderId - The order ID
|
|
6053
|
+
* @param filter - Optional filter parameters
|
|
6054
|
+
* @returns Promise with order events response
|
|
6055
|
+
*/
|
|
6056
|
+
async getOrderEvents(orderId, filter) {
|
|
6057
|
+
if (!(await this.isAuthenticated())) {
|
|
6058
|
+
throw new AuthenticationError('User is not authenticated');
|
|
6059
|
+
}
|
|
6060
|
+
const response = await this.apiClient.getOrderEvents(orderId, filter);
|
|
6061
|
+
return response.response_data;
|
|
6062
|
+
}
|
|
6063
|
+
/**
|
|
6064
|
+
* Get order groups
|
|
6065
|
+
* @param filter - Optional filter parameters
|
|
6066
|
+
* @returns Promise with order groups response
|
|
6067
|
+
*/
|
|
6068
|
+
async getOrderGroups(filter) {
|
|
6069
|
+
if (!(await this.isAuthenticated())) {
|
|
6070
|
+
throw new AuthenticationError('User is not authenticated');
|
|
6071
|
+
}
|
|
6072
|
+
const response = await this.apiClient.getOrderGroups(filter);
|
|
6073
|
+
return response.response_data;
|
|
6074
|
+
}
|
|
6075
|
+
/**
|
|
6076
|
+
* Get position lots (tax lots for positions)
|
|
6077
|
+
* @param filter - Optional filter parameters
|
|
6078
|
+
* @returns Promise with position lots response
|
|
6079
|
+
*/
|
|
6080
|
+
async getPositionLots(filter) {
|
|
6081
|
+
if (!(await this.isAuthenticated())) {
|
|
6082
|
+
throw new AuthenticationError('User is not authenticated');
|
|
6083
|
+
}
|
|
6084
|
+
const response = await this.apiClient.getPositionLots(filter);
|
|
6085
|
+
return response.response_data;
|
|
6086
|
+
}
|
|
6087
|
+
/**
|
|
6088
|
+
* Get position lot fills for a specific lot
|
|
6089
|
+
* @param lotId - The position lot ID
|
|
6090
|
+
* @param filter - Optional filter parameters
|
|
6091
|
+
* @returns Promise with position lot fills response
|
|
6092
|
+
*/
|
|
6093
|
+
async getPositionLotFills(lotId, filter) {
|
|
6094
|
+
if (!(await this.isAuthenticated())) {
|
|
6095
|
+
throw new AuthenticationError('User is not authenticated');
|
|
6096
|
+
}
|
|
6097
|
+
const response = await this.apiClient.getPositionLotFills(lotId, filter);
|
|
6098
|
+
return response.response_data;
|
|
6099
|
+
}
|
|
5888
6100
|
}
|
|
5889
6101
|
FinaticConnect.instance = null;
|
|
5890
6102
|
|