Skip to content

Commit a2deb9a

Browse files
committed
Change Quote interface to MarketQuote, to match other RTC payload names like MarketTrade and MarketDepth.
1 parent 91ab466 commit a2deb9a

5 files changed

Lines changed: 59 additions & 42 deletions

File tree

src/index.ts

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,14 @@
11
// Main client
2-
export { TopstepXClient } from './client';
2+
export { TopstepXClient } from "./client";
33

44
// Auth
5-
export { AuthService } from './auth';
6-
export type { AuthConfig, LoginRequest, LoginResponse, ValidateResponse } from './auth';
5+
export { AuthService } from "./auth";
6+
export type {
7+
AuthConfig,
8+
LoginRequest,
9+
LoginResponse,
10+
ValidateResponse,
11+
} from "./auth";
712

813
// REST APIs
914
export {
@@ -14,7 +19,7 @@ export {
1419
TradeApi,
1520
ContractApi,
1621
HistoryApi,
17-
} from './rest';
22+
} from "./rest";
1823

1924
export type {
2025
HttpClientConfig,
@@ -55,15 +60,15 @@ export type {
5560
Bar,
5661
RetrieveBarsRequest,
5762
RetrieveBarsResponse,
58-
} from './rest';
63+
} from "./rest";
5964

6065
// Realtime
61-
export { ConnectionManager, MarketHub, UserHub } from './realtime';
66+
export { ConnectionManager, MarketHub, UserHub } from "./realtime";
6267

6368
export type {
6469
ConnectionManagerConfig,
6570
// Market hub types
66-
Quote,
71+
MarketQuote,
6772
MarketTrade,
6873
MarketDepth,
6974
MarketEvent,
@@ -74,7 +79,7 @@ export type {
7479
TradeUpdate,
7580
AccountUpdate,
7681
UserHubEvents,
77-
} from './realtime';
82+
} from "./realtime";
7883

7984
// Types & Enums
8085
export {
@@ -84,17 +89,21 @@ export {
8489
BarUnit,
8590
PositionType,
8691
TradeType,
87-
} from './types';
92+
} from "./types";
8893

89-
export type { ApiResponse, TopstepXClientConfig, TopstepXClientEvents } from './types';
94+
export type {
95+
ApiResponse,
96+
TopstepXClientConfig,
97+
TopstepXClientEvents,
98+
} from "./types";
9099

91100
// Errors
92101
export {
93102
TopstepXError,
94103
AuthenticationError,
95104
ApiError,
96105
ConnectionError,
97-
} from './errors';
106+
} from "./errors";
98107

99108
// Utilities
100-
export { TypedEventEmitter } from './utils';
109+
export { TypedEventEmitter } from "./utils";

src/realtime/index.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
1-
export { ConnectionManager } from './connection-manager';
2-
export type { ConnectionManagerConfig } from './connection-manager';
1+
export { ConnectionManager } from "./connection-manager";
2+
export type { ConnectionManagerConfig } from "./connection-manager";
33

4-
export { MarketHub } from './market';
4+
export { MarketHub } from "./market";
55
export type {
6-
Quote,
6+
MarketQuote,
77
MarketTrade,
88
MarketDepth,
99
MarketEvent,
1010
MarketHubEvents,
11-
} from './market';
11+
} from "./market";
1212

13-
export { UserHub } from './user';
13+
export { UserHub } from "./user";
1414
export type {
1515
OrderUpdate,
1616
PositionUpdate,
1717
TradeUpdate,
1818
AccountUpdate,
1919
UserHubEvents,
20-
} from './user';
20+
} from "./user";

src/realtime/market/index.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
export { MarketHub } from './market-hub';
1+
export { MarketHub } from "./market-hub";
22
export type {
3-
Quote,
3+
MarketQuote,
44
MarketTrade,
55
MarketDepth,
66
MarketEvent,
77
MarketHubEvents,
8-
} from './types';
8+
} from "./types";

src/realtime/market/market-hub.ts

Lines changed: 26 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
1-
import type { ConnectionManager } from '../connection-manager';
2-
import { TypedEventEmitter } from '../../utils/event-emitter';
3-
import type { Quote, MarketTrade, MarketDepth, MarketHubEvents } from './types';
1+
import type { ConnectionManager } from "../connection-manager";
2+
import { TypedEventEmitter } from "../../utils/event-emitter";
3+
import type {
4+
MarketQuote,
5+
MarketTrade,
6+
MarketDepth,
7+
MarketHubEvents,
8+
} from "./types";
49

510
export class MarketHub extends TypedEventEmitter<MarketHubEvents> {
611
private subscribedQuotes = new Set<string>();
@@ -14,22 +19,25 @@ export class MarketHub extends TypedEventEmitter<MarketHubEvents> {
1419

1520
private setupEventHandlers(): void {
1621
this.connectionManager.onMarketConnection((connection) => {
17-
connection.on('GatewayQuote', (contractId: string, data: Quote[]) => {
18-
this.emit('quote', { contractId, data });
19-
});
22+
connection.on(
23+
"GatewayQuote",
24+
(contractId: string, data: MarketQuote[]) => {
25+
this.emit("quote", { contractId, data });
26+
},
27+
);
2028

2129
connection.on(
22-
'GatewayTrade',
30+
"GatewayTrade",
2331
(contractId: string, data: MarketTrade[]) => {
24-
this.emit('trade', { contractId, data });
25-
}
32+
this.emit("trade", { contractId, data });
33+
},
2634
);
2735

2836
connection.on(
29-
'GatewayDepth',
37+
"GatewayDepth",
3038
(contractId: string, data: MarketDepth[]) => {
31-
this.emit('depth', { contractId, data });
32-
}
39+
this.emit("depth", { contractId, data });
40+
},
3341
);
3442
});
3543
}
@@ -53,42 +61,42 @@ export class MarketHub extends TypedEventEmitter<MarketHubEvents> {
5361
async subscribeQuotes(contractId: string): Promise<void> {
5462
if (this.subscribedQuotes.has(contractId)) return;
5563
const connection = this.connectionManager.marketConnection;
56-
await connection.invoke('SubscribeContractQuotes', contractId);
64+
await connection.invoke("SubscribeContractQuotes", contractId);
5765
this.subscribedQuotes.add(contractId);
5866
}
5967

6068
async unsubscribeQuotes(contractId: string): Promise<void> {
6169
if (!this.subscribedQuotes.has(contractId)) return;
6270
const connection = this.connectionManager.marketConnection;
63-
await connection.invoke('UnsubscribeContractQuotes', contractId);
71+
await connection.invoke("UnsubscribeContractQuotes", contractId);
6472
this.subscribedQuotes.delete(contractId);
6573
}
6674

6775
async subscribeTrades(contractId: string): Promise<void> {
6876
if (this.subscribedTrades.has(contractId)) return;
6977
const connection = this.connectionManager.marketConnection;
70-
await connection.invoke('SubscribeContractTrades', contractId);
78+
await connection.invoke("SubscribeContractTrades", contractId);
7179
this.subscribedTrades.add(contractId);
7280
}
7381

7482
async unsubscribeTrades(contractId: string): Promise<void> {
7583
if (!this.subscribedTrades.has(contractId)) return;
7684
const connection = this.connectionManager.marketConnection;
77-
await connection.invoke('UnsubscribeContractTrades', contractId);
85+
await connection.invoke("UnsubscribeContractTrades", contractId);
7886
this.subscribedTrades.delete(contractId);
7987
}
8088

8189
async subscribeDepth(contractId: string): Promise<void> {
8290
if (this.subscribedDepth.has(contractId)) return;
8391
const connection = this.connectionManager.marketConnection;
84-
await connection.invoke('SubscribeContractMarketDepth', contractId);
92+
await connection.invoke("SubscribeContractMarketDepth", contractId);
8593
this.subscribedDepth.add(contractId);
8694
}
8795

8896
async unsubscribeDepth(contractId: string): Promise<void> {
8997
if (!this.subscribedDepth.has(contractId)) return;
9098
const connection = this.connectionManager.marketConnection;
91-
await connection.invoke('UnsubscribeContractMarketDepth', contractId);
99+
await connection.invoke("UnsubscribeContractMarketDepth", contractId);
92100
this.subscribedDepth.delete(contractId);
93101
}
94102
}

src/realtime/market/types.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
export interface Quote {
1+
export interface MarketQuote {
22
symbol: string;
33
lastPrice: number;
44
bestBid: number;
@@ -33,7 +33,7 @@ export interface MarketEvent<T> {
3333

3434
export interface MarketHubEvents {
3535
[key: string]: unknown;
36-
quote: MarketEvent<Quote>;
36+
quote: MarketEvent<MarketQuote>;
3737
trade: MarketEvent<MarketTrade>;
3838
depth: MarketEvent<MarketDepth>;
3939
}

0 commit comments

Comments
 (0)