@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
|
@@ -3,7 +3,7 @@ import { BrokerInfo, BrokerAccount, BrokerOrder, BrokerPosition, BrokerBalance,
|
|
|
3
3
|
import { BrokerOrderParams, BrokerExtras } from '../../types/api/broker';
|
|
4
4
|
import { CryptoOrderOptions, OptionsOrderOptions, OrderResponse } from '../../types/api/orders';
|
|
5
5
|
import { BrokerConnection } from '../../types/api/broker';
|
|
6
|
-
import { OrdersFilter, PositionsFilter, AccountsFilter, BalancesFilter } from '../../types/api/broker';
|
|
6
|
+
import { OrdersFilter, PositionsFilter, AccountsFilter, BalancesFilter, OrderFill, OrderEvent, OrderGroup, PositionLot, PositionLotFill, OrderFillsFilter, OrderEventsFilter, OrderGroupsFilter, PositionLotsFilter, PositionLotFillsFilter } from '../../types/api/broker';
|
|
7
7
|
import { PaginatedResult } from '../../types/common/pagination';
|
|
8
8
|
import { PortalUrlResponse } from '../../types/api/core';
|
|
9
9
|
import { DeviceInfo, SessionState, SessionResponse, OtpRequestResponse, OtpVerifyResponse, SessionAuthenticateResponse, UserToken } from '../../types/api/auth';
|
|
@@ -197,4 +197,72 @@ export declare class ApiClient {
|
|
|
197
197
|
* @returns Promise with disconnect response
|
|
198
198
|
*/
|
|
199
199
|
disconnectCompany(connectionId: string): Promise<DisconnectCompanyResponse>;
|
|
200
|
+
/**
|
|
201
|
+
* Get order fills for a specific order
|
|
202
|
+
* @param orderId - The order ID
|
|
203
|
+
* @param filter - Optional filter parameters
|
|
204
|
+
* @returns Promise with order fills response
|
|
205
|
+
*/
|
|
206
|
+
getOrderFills(orderId: string, filter?: OrderFillsFilter): Promise<{
|
|
207
|
+
_id: string;
|
|
208
|
+
response_data: OrderFill[];
|
|
209
|
+
message: string;
|
|
210
|
+
status_code: number;
|
|
211
|
+
warnings: null;
|
|
212
|
+
errors: null;
|
|
213
|
+
}>;
|
|
214
|
+
/**
|
|
215
|
+
* Get order events for a specific order
|
|
216
|
+
* @param orderId - The order ID
|
|
217
|
+
* @param filter - Optional filter parameters
|
|
218
|
+
* @returns Promise with order events response
|
|
219
|
+
*/
|
|
220
|
+
getOrderEvents(orderId: string, filter?: OrderEventsFilter): Promise<{
|
|
221
|
+
_id: string;
|
|
222
|
+
response_data: OrderEvent[];
|
|
223
|
+
message: string;
|
|
224
|
+
status_code: number;
|
|
225
|
+
warnings: null;
|
|
226
|
+
errors: null;
|
|
227
|
+
}>;
|
|
228
|
+
/**
|
|
229
|
+
* Get order groups
|
|
230
|
+
* @param filter - Optional filter parameters
|
|
231
|
+
* @returns Promise with order groups response
|
|
232
|
+
*/
|
|
233
|
+
getOrderGroups(filter?: OrderGroupsFilter): Promise<{
|
|
234
|
+
_id: string;
|
|
235
|
+
response_data: OrderGroup[];
|
|
236
|
+
message: string;
|
|
237
|
+
status_code: number;
|
|
238
|
+
warnings: null;
|
|
239
|
+
errors: null;
|
|
240
|
+
}>;
|
|
241
|
+
/**
|
|
242
|
+
* Get position lots (tax lots for positions)
|
|
243
|
+
* @param filter - Optional filter parameters
|
|
244
|
+
* @returns Promise with position lots response
|
|
245
|
+
*/
|
|
246
|
+
getPositionLots(filter?: PositionLotsFilter): Promise<{
|
|
247
|
+
_id: string;
|
|
248
|
+
response_data: PositionLot[];
|
|
249
|
+
message: string;
|
|
250
|
+
status_code: number;
|
|
251
|
+
warnings: null;
|
|
252
|
+
errors: null;
|
|
253
|
+
}>;
|
|
254
|
+
/**
|
|
255
|
+
* Get position lot fills for a specific lot
|
|
256
|
+
* @param lotId - The position lot ID
|
|
257
|
+
* @param filter - Optional filter parameters
|
|
258
|
+
* @returns Promise with position lot fills response
|
|
259
|
+
*/
|
|
260
|
+
getPositionLotFills(lotId: string, filter?: PositionLotFillsFilter): Promise<{
|
|
261
|
+
_id: string;
|
|
262
|
+
response_data: PositionLotFill[];
|
|
263
|
+
message: string;
|
|
264
|
+
status_code: number;
|
|
265
|
+
warnings: null;
|
|
266
|
+
errors: null;
|
|
267
|
+
}>;
|
|
200
268
|
}
|
|
@@ -293,5 +293,38 @@ export declare class FinaticConnect extends EventEmitter {
|
|
|
293
293
|
* @throws AuthenticationError if user is not authenticated
|
|
294
294
|
*/
|
|
295
295
|
disconnectCompany(connectionId: string): Promise<DisconnectCompanyResponse>;
|
|
296
|
+
/**
|
|
297
|
+
* Get order fills for a specific order
|
|
298
|
+
* @param orderId - The order ID
|
|
299
|
+
* @param filter - Optional filter parameters
|
|
300
|
+
* @returns Promise with order fills response
|
|
301
|
+
*/
|
|
302
|
+
getOrderFills(orderId: string, filter?: import('../../types/api/broker').OrderFillsFilter): Promise<import('../../types/api/broker').OrderFill[]>;
|
|
303
|
+
/**
|
|
304
|
+
* Get order events for a specific order
|
|
305
|
+
* @param orderId - The order ID
|
|
306
|
+
* @param filter - Optional filter parameters
|
|
307
|
+
* @returns Promise with order events response
|
|
308
|
+
*/
|
|
309
|
+
getOrderEvents(orderId: string, filter?: import('../../types/api/broker').OrderEventsFilter): Promise<import('../../types/api/broker').OrderEvent[]>;
|
|
310
|
+
/**
|
|
311
|
+
* Get order groups
|
|
312
|
+
* @param filter - Optional filter parameters
|
|
313
|
+
* @returns Promise with order groups response
|
|
314
|
+
*/
|
|
315
|
+
getOrderGroups(filter?: import('../../types/api/broker').OrderGroupsFilter): Promise<import('../../types/api/broker').OrderGroup[]>;
|
|
316
|
+
/**
|
|
317
|
+
* Get position lots (tax lots for positions)
|
|
318
|
+
* @param filter - Optional filter parameters
|
|
319
|
+
* @returns Promise with position lots response
|
|
320
|
+
*/
|
|
321
|
+
getPositionLots(filter?: import('../../types/api/broker').PositionLotsFilter): Promise<import('../../types/api/broker').PositionLot[]>;
|
|
322
|
+
/**
|
|
323
|
+
* Get position lot fills for a specific lot
|
|
324
|
+
* @param lotId - The position lot ID
|
|
325
|
+
* @param filter - Optional filter parameters
|
|
326
|
+
* @returns Promise with position lot fills response
|
|
327
|
+
*/
|
|
328
|
+
getPositionLotFills(lotId: string, filter?: import('../../types/api/broker').PositionLotFillsFilter): Promise<import('../../types/api/broker').PositionLotFill[]>;
|
|
296
329
|
}
|
|
297
330
|
export {};
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export type { ApiConfig, ApiResponse, Order, OptionsOrder, BrokerAccount, PortfolioSnapshot, PerformanceMetrics, UserToken, Holding, Portfolio, PortalResponse, SessionInitResponse, SessionResponse, OtpRequestResponse, OtpVerifyResponse, PortalUrlResponse, SessionValidationResponse, SessionAuthenticateResponse, RequestHeaders, SessionStatus, BrokerOrderParams, BrokerExtras, CryptoOrderOptions, OptionsOrderOptions, OrderResponse, TradingContext, DeviceInfo, BrokerOrder, BrokerPosition, BrokerBalance, BrokerDataOptions, BrokerInfo, TokenInfo, RefreshTokenRequest, RefreshTokenResponse, AccountsFilter, OrdersFilter, PositionsFilter, BalancesFilter, BrokerDataOrder, BrokerDataPosition, BrokerDataAccount, FilteredOrdersResponse, FilteredPositionsResponse, FilteredAccountsResponse, FilteredBalancesResponse, BrokerConnection, } from './types';
|
|
1
|
+
export type { ApiConfig, ApiResponse, Order, OptionsOrder, BrokerAccount, PortfolioSnapshot, PerformanceMetrics, UserToken, Holding, Portfolio, PortalResponse, SessionInitResponse, SessionResponse, OtpRequestResponse, OtpVerifyResponse, PortalUrlResponse, SessionValidationResponse, SessionAuthenticateResponse, RequestHeaders, SessionStatus, BrokerOrderParams, BrokerExtras, CryptoOrderOptions, OptionsOrderOptions, OrderResponse, TradingContext, DeviceInfo, BrokerOrder, BrokerPosition, BrokerBalance, BrokerDataOptions, BrokerInfo, TokenInfo, RefreshTokenRequest, RefreshTokenResponse, AccountsFilter, OrdersFilter, PositionsFilter, BalancesFilter, BrokerDataOrder, BrokerDataPosition, BrokerDataAccount, FilteredOrdersResponse, FilteredPositionsResponse, FilteredAccountsResponse, FilteredBalancesResponse, BrokerConnection, OrderFill, OrderEvent, OrderLeg, OrderGroup, OrderGroupOrder, PositionLot, PositionLotFill, OrderFillsFilter, OrderEventsFilter, OrderGroupsFilter, PositionLotsFilter, PositionLotFillsFilter, } from './types';
|
|
2
2
|
export type { FinaticConnectOptions, FinaticUserToken, PortalMessage } from './types/connect';
|
|
3
3
|
export type { PortalProps, PortalTheme, PortalThemeConfig, PortalThemePreset, } from './types/portal';
|
|
4
4
|
export type { TradeAccessDeniedError, OrderNotFoundError, ValidationError, } from './types/api/errors';
|
|
@@ -303,3 +303,119 @@ export interface DisconnectCompanyResponse {
|
|
|
303
303
|
message: string;
|
|
304
304
|
status_code: number;
|
|
305
305
|
}
|
|
306
|
+
export interface OrderFill {
|
|
307
|
+
id: string;
|
|
308
|
+
order_id: string;
|
|
309
|
+
leg_id: string | null;
|
|
310
|
+
price: number;
|
|
311
|
+
quantity: number;
|
|
312
|
+
executed_at: string;
|
|
313
|
+
execution_id: string | null;
|
|
314
|
+
trade_id: string | null;
|
|
315
|
+
venue: string | null;
|
|
316
|
+
commission_fee: number | null;
|
|
317
|
+
created_at: string;
|
|
318
|
+
updated_at: string;
|
|
319
|
+
}
|
|
320
|
+
export interface OrderEvent {
|
|
321
|
+
id: string;
|
|
322
|
+
order_id: string;
|
|
323
|
+
order_group_id: string | null;
|
|
324
|
+
event_type: string | null;
|
|
325
|
+
event_time: string;
|
|
326
|
+
event_id: string | null;
|
|
327
|
+
order_status: string | null;
|
|
328
|
+
inferred: boolean;
|
|
329
|
+
confidence: number | null;
|
|
330
|
+
reason_code: string | null;
|
|
331
|
+
recorded_at: string | null;
|
|
332
|
+
}
|
|
333
|
+
export interface OrderLeg {
|
|
334
|
+
id: string;
|
|
335
|
+
order_id: string;
|
|
336
|
+
leg_index: number;
|
|
337
|
+
asset_type: string;
|
|
338
|
+
broker_provided_symbol: string | null;
|
|
339
|
+
quantity: number;
|
|
340
|
+
filled_quantity: number | null;
|
|
341
|
+
avg_fill_price: number | null;
|
|
342
|
+
created_at: string | null;
|
|
343
|
+
updated_at: string | null;
|
|
344
|
+
}
|
|
345
|
+
export interface OrderGroupOrder extends BrokerDataOrder {
|
|
346
|
+
legs: OrderLeg[];
|
|
347
|
+
}
|
|
348
|
+
export interface OrderGroup {
|
|
349
|
+
id: string;
|
|
350
|
+
user_broker_connection_id: string | null;
|
|
351
|
+
created_at: string;
|
|
352
|
+
updated_at: string;
|
|
353
|
+
orders: OrderGroupOrder[];
|
|
354
|
+
}
|
|
355
|
+
export interface PositionLot {
|
|
356
|
+
id: string;
|
|
357
|
+
position_id: string | null;
|
|
358
|
+
user_broker_connection_id: string;
|
|
359
|
+
broker_provided_account_id: string;
|
|
360
|
+
instrument_key: string;
|
|
361
|
+
asset_type: string | null;
|
|
362
|
+
side: 'long' | 'short' | null;
|
|
363
|
+
open_quantity: number;
|
|
364
|
+
closed_quantity: number;
|
|
365
|
+
remaining_quantity: number;
|
|
366
|
+
open_price: number;
|
|
367
|
+
close_price_avg: number | null;
|
|
368
|
+
cost_basis: number;
|
|
369
|
+
cost_basis_w_commission: number;
|
|
370
|
+
realized_pl: number;
|
|
371
|
+
realized_pl_w_commission: number;
|
|
372
|
+
lot_opened_at: string;
|
|
373
|
+
lot_closed_at: string | null;
|
|
374
|
+
position_group_id: string | null;
|
|
375
|
+
created_at: string;
|
|
376
|
+
updated_at: string;
|
|
377
|
+
position_lot_fills?: PositionLotFill[];
|
|
378
|
+
}
|
|
379
|
+
export interface PositionLotFill {
|
|
380
|
+
id: string;
|
|
381
|
+
lot_id: string;
|
|
382
|
+
order_fill_id: string;
|
|
383
|
+
fill_price: number;
|
|
384
|
+
fill_quantity: number;
|
|
385
|
+
executed_at: string;
|
|
386
|
+
commission_share: number | null;
|
|
387
|
+
created_at: string;
|
|
388
|
+
updated_at: string;
|
|
389
|
+
}
|
|
390
|
+
export interface OrderFillsFilter {
|
|
391
|
+
connection_id?: string;
|
|
392
|
+
limit?: number;
|
|
393
|
+
offset?: number;
|
|
394
|
+
}
|
|
395
|
+
export interface OrderEventsFilter {
|
|
396
|
+
connection_id?: string;
|
|
397
|
+
limit?: number;
|
|
398
|
+
offset?: number;
|
|
399
|
+
}
|
|
400
|
+
export interface OrderGroupsFilter {
|
|
401
|
+
broker_id?: string;
|
|
402
|
+
connection_id?: string;
|
|
403
|
+
limit?: number;
|
|
404
|
+
offset?: number;
|
|
405
|
+
created_after?: string;
|
|
406
|
+
created_before?: string;
|
|
407
|
+
}
|
|
408
|
+
export interface PositionLotsFilter {
|
|
409
|
+
broker_id?: string;
|
|
410
|
+
connection_id?: string;
|
|
411
|
+
account_id?: string;
|
|
412
|
+
symbol?: string;
|
|
413
|
+
position_id?: string;
|
|
414
|
+
limit?: number;
|
|
415
|
+
offset?: number;
|
|
416
|
+
}
|
|
417
|
+
export interface PositionLotFillsFilter {
|
|
418
|
+
connection_id?: string;
|
|
419
|
+
limit?: number;
|
|
420
|
+
offset?: number;
|
|
421
|
+
}
|
package/package.json
CHANGED
|
@@ -16,6 +16,16 @@ import {
|
|
|
16
16
|
PositionsFilter,
|
|
17
17
|
AccountsFilter,
|
|
18
18
|
BalancesFilter,
|
|
19
|
+
OrderFill,
|
|
20
|
+
OrderEvent,
|
|
21
|
+
OrderGroup,
|
|
22
|
+
PositionLot,
|
|
23
|
+
PositionLotFill,
|
|
24
|
+
OrderFillsFilter,
|
|
25
|
+
OrderEventsFilter,
|
|
26
|
+
OrderGroupsFilter,
|
|
27
|
+
PositionLotsFilter,
|
|
28
|
+
PositionLotFillsFilter,
|
|
19
29
|
} from '../../types/api/broker';
|
|
20
30
|
import { TradingContext } from '../../types/api/orders';
|
|
21
31
|
import { ApiPaginationInfo, PaginatedResult } from '../../types/common/pagination';
|
|
@@ -1718,4 +1728,251 @@ export class ApiClient {
|
|
|
1718
1728
|
},
|
|
1719
1729
|
});
|
|
1720
1730
|
}
|
|
1731
|
+
|
|
1732
|
+
/**
|
|
1733
|
+
* Get order fills for a specific order
|
|
1734
|
+
* @param orderId - The order ID
|
|
1735
|
+
* @param filter - Optional filter parameters
|
|
1736
|
+
* @returns Promise with order fills response
|
|
1737
|
+
*/
|
|
1738
|
+
async getOrderFills(
|
|
1739
|
+
orderId: string,
|
|
1740
|
+
filter?: OrderFillsFilter
|
|
1741
|
+
): Promise<{
|
|
1742
|
+
_id: string;
|
|
1743
|
+
response_data: OrderFill[];
|
|
1744
|
+
message: string;
|
|
1745
|
+
status_code: number;
|
|
1746
|
+
warnings: null;
|
|
1747
|
+
errors: null;
|
|
1748
|
+
}> {
|
|
1749
|
+
const accessToken = await this.getValidAccessToken();
|
|
1750
|
+
const params: Record<string, string> = {};
|
|
1751
|
+
|
|
1752
|
+
if (filter?.connection_id) {
|
|
1753
|
+
params.connection_id = filter.connection_id;
|
|
1754
|
+
}
|
|
1755
|
+
if (filter?.limit) {
|
|
1756
|
+
params.limit = filter.limit.toString();
|
|
1757
|
+
}
|
|
1758
|
+
if (filter?.offset) {
|
|
1759
|
+
params.offset = filter.offset.toString();
|
|
1760
|
+
}
|
|
1761
|
+
|
|
1762
|
+
return this.request<{
|
|
1763
|
+
_id: string;
|
|
1764
|
+
response_data: OrderFill[];
|
|
1765
|
+
message: string;
|
|
1766
|
+
status_code: number;
|
|
1767
|
+
warnings: null;
|
|
1768
|
+
errors: null;
|
|
1769
|
+
}>(`/brokers/data/orders/${orderId}/fills`, {
|
|
1770
|
+
method: 'GET',
|
|
1771
|
+
headers: {
|
|
1772
|
+
Authorization: `Bearer ${accessToken}`,
|
|
1773
|
+
},
|
|
1774
|
+
params,
|
|
1775
|
+
});
|
|
1776
|
+
}
|
|
1777
|
+
|
|
1778
|
+
/**
|
|
1779
|
+
* Get order events for a specific order
|
|
1780
|
+
* @param orderId - The order ID
|
|
1781
|
+
* @param filter - Optional filter parameters
|
|
1782
|
+
* @returns Promise with order events response
|
|
1783
|
+
*/
|
|
1784
|
+
async getOrderEvents(
|
|
1785
|
+
orderId: string,
|
|
1786
|
+
filter?: OrderEventsFilter
|
|
1787
|
+
): Promise<{
|
|
1788
|
+
_id: string;
|
|
1789
|
+
response_data: OrderEvent[];
|
|
1790
|
+
message: string;
|
|
1791
|
+
status_code: number;
|
|
1792
|
+
warnings: null;
|
|
1793
|
+
errors: null;
|
|
1794
|
+
}> {
|
|
1795
|
+
const accessToken = await this.getValidAccessToken();
|
|
1796
|
+
const params: Record<string, string> = {};
|
|
1797
|
+
|
|
1798
|
+
if (filter?.connection_id) {
|
|
1799
|
+
params.connection_id = filter.connection_id;
|
|
1800
|
+
}
|
|
1801
|
+
if (filter?.limit) {
|
|
1802
|
+
params.limit = filter.limit.toString();
|
|
1803
|
+
}
|
|
1804
|
+
if (filter?.offset) {
|
|
1805
|
+
params.offset = filter.offset.toString();
|
|
1806
|
+
}
|
|
1807
|
+
|
|
1808
|
+
return this.request<{
|
|
1809
|
+
_id: string;
|
|
1810
|
+
response_data: OrderEvent[];
|
|
1811
|
+
message: string;
|
|
1812
|
+
status_code: number;
|
|
1813
|
+
warnings: null;
|
|
1814
|
+
errors: null;
|
|
1815
|
+
}>(`/brokers/data/orders/${orderId}/events`, {
|
|
1816
|
+
method: 'GET',
|
|
1817
|
+
headers: {
|
|
1818
|
+
Authorization: `Bearer ${accessToken}`,
|
|
1819
|
+
},
|
|
1820
|
+
params,
|
|
1821
|
+
});
|
|
1822
|
+
}
|
|
1823
|
+
|
|
1824
|
+
/**
|
|
1825
|
+
* Get order groups
|
|
1826
|
+
* @param filter - Optional filter parameters
|
|
1827
|
+
* @returns Promise with order groups response
|
|
1828
|
+
*/
|
|
1829
|
+
async getOrderGroups(
|
|
1830
|
+
filter?: OrderGroupsFilter
|
|
1831
|
+
): Promise<{
|
|
1832
|
+
_id: string;
|
|
1833
|
+
response_data: OrderGroup[];
|
|
1834
|
+
message: string;
|
|
1835
|
+
status_code: number;
|
|
1836
|
+
warnings: null;
|
|
1837
|
+
errors: null;
|
|
1838
|
+
}> {
|
|
1839
|
+
const accessToken = await this.getValidAccessToken();
|
|
1840
|
+
const params: Record<string, string> = {};
|
|
1841
|
+
|
|
1842
|
+
if (filter?.broker_id) {
|
|
1843
|
+
params.broker_id = filter.broker_id;
|
|
1844
|
+
}
|
|
1845
|
+
if (filter?.connection_id) {
|
|
1846
|
+
params.connection_id = filter.connection_id;
|
|
1847
|
+
}
|
|
1848
|
+
if (filter?.limit) {
|
|
1849
|
+
params.limit = filter.limit.toString();
|
|
1850
|
+
}
|
|
1851
|
+
if (filter?.offset) {
|
|
1852
|
+
params.offset = filter.offset.toString();
|
|
1853
|
+
}
|
|
1854
|
+
if (filter?.created_after) {
|
|
1855
|
+
params.created_after = filter.created_after;
|
|
1856
|
+
}
|
|
1857
|
+
if (filter?.created_before) {
|
|
1858
|
+
params.created_before = filter.created_before;
|
|
1859
|
+
}
|
|
1860
|
+
|
|
1861
|
+
return this.request<{
|
|
1862
|
+
_id: string;
|
|
1863
|
+
response_data: OrderGroup[];
|
|
1864
|
+
message: string;
|
|
1865
|
+
status_code: number;
|
|
1866
|
+
warnings: null;
|
|
1867
|
+
errors: null;
|
|
1868
|
+
}>('/brokers/data/orders/groups', {
|
|
1869
|
+
method: 'GET',
|
|
1870
|
+
headers: {
|
|
1871
|
+
Authorization: `Bearer ${accessToken}`,
|
|
1872
|
+
},
|
|
1873
|
+
params,
|
|
1874
|
+
});
|
|
1875
|
+
}
|
|
1876
|
+
|
|
1877
|
+
/**
|
|
1878
|
+
* Get position lots (tax lots for positions)
|
|
1879
|
+
* @param filter - Optional filter parameters
|
|
1880
|
+
* @returns Promise with position lots response
|
|
1881
|
+
*/
|
|
1882
|
+
async getPositionLots(
|
|
1883
|
+
filter?: PositionLotsFilter
|
|
1884
|
+
): Promise<{
|
|
1885
|
+
_id: string;
|
|
1886
|
+
response_data: PositionLot[];
|
|
1887
|
+
message: string;
|
|
1888
|
+
status_code: number;
|
|
1889
|
+
warnings: null;
|
|
1890
|
+
errors: null;
|
|
1891
|
+
}> {
|
|
1892
|
+
const accessToken = await this.getValidAccessToken();
|
|
1893
|
+
const params: Record<string, string> = {};
|
|
1894
|
+
|
|
1895
|
+
if (filter?.broker_id) {
|
|
1896
|
+
params.broker_id = filter.broker_id;
|
|
1897
|
+
}
|
|
1898
|
+
if (filter?.connection_id) {
|
|
1899
|
+
params.connection_id = filter.connection_id;
|
|
1900
|
+
}
|
|
1901
|
+
if (filter?.account_id) {
|
|
1902
|
+
params.account_id = filter.account_id;
|
|
1903
|
+
}
|
|
1904
|
+
if (filter?.symbol) {
|
|
1905
|
+
params.symbol = filter.symbol;
|
|
1906
|
+
}
|
|
1907
|
+
if (filter?.position_id) {
|
|
1908
|
+
params.position_id = filter.position_id;
|
|
1909
|
+
}
|
|
1910
|
+
if (filter?.limit) {
|
|
1911
|
+
params.limit = filter.limit.toString();
|
|
1912
|
+
}
|
|
1913
|
+
if (filter?.offset) {
|
|
1914
|
+
params.offset = filter.offset.toString();
|
|
1915
|
+
}
|
|
1916
|
+
|
|
1917
|
+
return this.request<{
|
|
1918
|
+
_id: string;
|
|
1919
|
+
response_data: PositionLot[];
|
|
1920
|
+
message: string;
|
|
1921
|
+
status_code: number;
|
|
1922
|
+
warnings: null;
|
|
1923
|
+
errors: null;
|
|
1924
|
+
}>('/brokers/data/positions/lots', {
|
|
1925
|
+
method: 'GET',
|
|
1926
|
+
headers: {
|
|
1927
|
+
Authorization: `Bearer ${accessToken}`,
|
|
1928
|
+
},
|
|
1929
|
+
params,
|
|
1930
|
+
});
|
|
1931
|
+
}
|
|
1932
|
+
|
|
1933
|
+
/**
|
|
1934
|
+
* Get position lot fills for a specific lot
|
|
1935
|
+
* @param lotId - The position lot ID
|
|
1936
|
+
* @param filter - Optional filter parameters
|
|
1937
|
+
* @returns Promise with position lot fills response
|
|
1938
|
+
*/
|
|
1939
|
+
async getPositionLotFills(
|
|
1940
|
+
lotId: string,
|
|
1941
|
+
filter?: PositionLotFillsFilter
|
|
1942
|
+
): Promise<{
|
|
1943
|
+
_id: string;
|
|
1944
|
+
response_data: PositionLotFill[];
|
|
1945
|
+
message: string;
|
|
1946
|
+
status_code: number;
|
|
1947
|
+
warnings: null;
|
|
1948
|
+
errors: null;
|
|
1949
|
+
}> {
|
|
1950
|
+
const accessToken = await this.getValidAccessToken();
|
|
1951
|
+
const params: Record<string, string> = {};
|
|
1952
|
+
|
|
1953
|
+
if (filter?.connection_id) {
|
|
1954
|
+
params.connection_id = filter.connection_id;
|
|
1955
|
+
}
|
|
1956
|
+
if (filter?.limit) {
|
|
1957
|
+
params.limit = filter.limit.toString();
|
|
1958
|
+
}
|
|
1959
|
+
if (filter?.offset) {
|
|
1960
|
+
params.offset = filter.offset.toString();
|
|
1961
|
+
}
|
|
1962
|
+
|
|
1963
|
+
return this.request<{
|
|
1964
|
+
_id: string;
|
|
1965
|
+
response_data: PositionLotFill[];
|
|
1966
|
+
message: string;
|
|
1967
|
+
status_code: number;
|
|
1968
|
+
warnings: null;
|
|
1969
|
+
errors: null;
|
|
1970
|
+
}>(`/brokers/data/positions/lots/${lotId}/fills`, {
|
|
1971
|
+
method: 'GET',
|
|
1972
|
+
headers: {
|
|
1973
|
+
Authorization: `Bearer ${accessToken}`,
|
|
1974
|
+
},
|
|
1975
|
+
params,
|
|
1976
|
+
});
|
|
1977
|
+
}
|
|
1721
1978
|
}
|
|
@@ -1471,6 +1471,87 @@ export class FinaticConnect extends EventEmitter {
|
|
|
1471
1471
|
return this.apiClient.disconnectCompany(connectionId);
|
|
1472
1472
|
}
|
|
1473
1473
|
|
|
1474
|
+
/**
|
|
1475
|
+
* Get order fills for a specific order
|
|
1476
|
+
* @param orderId - The order ID
|
|
1477
|
+
* @param filter - Optional filter parameters
|
|
1478
|
+
* @returns Promise with order fills response
|
|
1479
|
+
*/
|
|
1480
|
+
public async getOrderFills(
|
|
1481
|
+
orderId: string,
|
|
1482
|
+
filter?: import('../../types/api/broker').OrderFillsFilter
|
|
1483
|
+
): Promise<import('../../types/api/broker').OrderFill[]> {
|
|
1484
|
+
if (!(await this.isAuthenticated())) {
|
|
1485
|
+
throw new AuthenticationError('User is not authenticated');
|
|
1486
|
+
}
|
|
1487
|
+
const response = await this.apiClient.getOrderFills(orderId, filter);
|
|
1488
|
+
return response.response_data;
|
|
1489
|
+
}
|
|
1490
|
+
|
|
1491
|
+
/**
|
|
1492
|
+
* Get order events for a specific order
|
|
1493
|
+
* @param orderId - The order ID
|
|
1494
|
+
* @param filter - Optional filter parameters
|
|
1495
|
+
* @returns Promise with order events response
|
|
1496
|
+
*/
|
|
1497
|
+
public async getOrderEvents(
|
|
1498
|
+
orderId: string,
|
|
1499
|
+
filter?: import('../../types/api/broker').OrderEventsFilter
|
|
1500
|
+
): Promise<import('../../types/api/broker').OrderEvent[]> {
|
|
1501
|
+
if (!(await this.isAuthenticated())) {
|
|
1502
|
+
throw new AuthenticationError('User is not authenticated');
|
|
1503
|
+
}
|
|
1504
|
+
const response = await this.apiClient.getOrderEvents(orderId, filter);
|
|
1505
|
+
return response.response_data;
|
|
1506
|
+
}
|
|
1507
|
+
|
|
1508
|
+
/**
|
|
1509
|
+
* Get order groups
|
|
1510
|
+
* @param filter - Optional filter parameters
|
|
1511
|
+
* @returns Promise with order groups response
|
|
1512
|
+
*/
|
|
1513
|
+
public async getOrderGroups(
|
|
1514
|
+
filter?: import('../../types/api/broker').OrderGroupsFilter
|
|
1515
|
+
): Promise<import('../../types/api/broker').OrderGroup[]> {
|
|
1516
|
+
if (!(await this.isAuthenticated())) {
|
|
1517
|
+
throw new AuthenticationError('User is not authenticated');
|
|
1518
|
+
}
|
|
1519
|
+
const response = await this.apiClient.getOrderGroups(filter);
|
|
1520
|
+
return response.response_data;
|
|
1521
|
+
}
|
|
1522
|
+
|
|
1523
|
+
/**
|
|
1524
|
+
* Get position lots (tax lots for positions)
|
|
1525
|
+
* @param filter - Optional filter parameters
|
|
1526
|
+
* @returns Promise with position lots response
|
|
1527
|
+
*/
|
|
1528
|
+
public async getPositionLots(
|
|
1529
|
+
filter?: import('../../types/api/broker').PositionLotsFilter
|
|
1530
|
+
): Promise<import('../../types/api/broker').PositionLot[]> {
|
|
1531
|
+
if (!(await this.isAuthenticated())) {
|
|
1532
|
+
throw new AuthenticationError('User is not authenticated');
|
|
1533
|
+
}
|
|
1534
|
+
const response = await this.apiClient.getPositionLots(filter);
|
|
1535
|
+
return response.response_data;
|
|
1536
|
+
}
|
|
1537
|
+
|
|
1538
|
+
/**
|
|
1539
|
+
* Get position lot fills for a specific lot
|
|
1540
|
+
* @param lotId - The position lot ID
|
|
1541
|
+
* @param filter - Optional filter parameters
|
|
1542
|
+
* @returns Promise with position lot fills response
|
|
1543
|
+
*/
|
|
1544
|
+
public async getPositionLotFills(
|
|
1545
|
+
lotId: string,
|
|
1546
|
+
filter?: import('../../types/api/broker').PositionLotFillsFilter
|
|
1547
|
+
): Promise<import('../../types/api/broker').PositionLotFill[]> {
|
|
1548
|
+
if (!(await this.isAuthenticated())) {
|
|
1549
|
+
throw new AuthenticationError('User is not authenticated');
|
|
1550
|
+
}
|
|
1551
|
+
const response = await this.apiClient.getPositionLotFills(lotId, filter);
|
|
1552
|
+
return response.response_data;
|
|
1553
|
+
}
|
|
1554
|
+
|
|
1474
1555
|
// Duplicate getBalances method removed - using the paginated version above
|
|
1475
1556
|
|
|
1476
1557
|
}
|
package/src/index.ts
CHANGED
|
@@ -48,6 +48,18 @@ export type {
|
|
|
48
48
|
FilteredAccountsResponse,
|
|
49
49
|
FilteredBalancesResponse,
|
|
50
50
|
BrokerConnection,
|
|
51
|
+
OrderFill,
|
|
52
|
+
OrderEvent,
|
|
53
|
+
OrderLeg,
|
|
54
|
+
OrderGroup,
|
|
55
|
+
OrderGroupOrder,
|
|
56
|
+
PositionLot,
|
|
57
|
+
PositionLotFill,
|
|
58
|
+
OrderFillsFilter,
|
|
59
|
+
OrderEventsFilter,
|
|
60
|
+
OrderGroupsFilter,
|
|
61
|
+
PositionLotsFilter,
|
|
62
|
+
PositionLotFillsFilter,
|
|
51
63
|
} from './types';
|
|
52
64
|
|
|
53
65
|
export type { FinaticConnectOptions, FinaticUserToken, PortalMessage } from './types/connect';
|