topstepx-api 1.0.3 → 2.0.0
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/CHANGELOG.md +145 -0
- package/MIGRATION.md +515 -0
- package/README.md +143 -38
- package/dist/index.cjs +599 -92
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.mts +346 -197
- package/dist/index.d.ts +346 -197
- package/dist/index.js +593 -85
- package/dist/index.js.map +1 -1
- package/package.json +5 -2
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,150 @@ All notable changes to this project will be documented in this file.
|
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
|
|
6
6
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
7
|
|
|
8
|
+
## [2.0.0] - 2026-02-15
|
|
9
|
+
|
|
10
|
+
### 🚨 BREAKING CHANGES
|
|
11
|
+
|
|
12
|
+
This is a major release with comprehensive refactoring of file structure, file naming conventions, and exported type/enum names. **All exported interfaces now have an `Interface` suffix and all exported enums now have an `Enum` suffix.** All users will need to update their imports. See [MIGRATION.md](./MIGRATION.md) for detailed migration instructions.
|
|
13
|
+
|
|
14
|
+
#### Renamed All Exported Interfaces and Enums
|
|
15
|
+
|
|
16
|
+
All exported interfaces and enums have been renamed to follow a consistent naming convention:
|
|
17
|
+
|
|
18
|
+
- **Enums** now end with `Enum` (e.g., `OrderType` -> `OrderTypeEnum`, `OrderSide` -> `OrderSideEnum`, `OrderStatus` -> `OrderStatusEnum`, `BarUnit` -> `BarUnitEnum`)
|
|
19
|
+
- **Domain model interfaces** now end with `Interface` (e.g., `Order` -> `OrderInterface`, `Position` -> `PositionInterface`, `Account` -> `AccountInterface`, `Trade` -> `TradeInterface`, `Contract` -> `ContractInterface`, `Bar` -> `BarInterface`)
|
|
20
|
+
- **Auth types** renamed with `Interface` suffix and more descriptive names (e.g., `AuthConfig` -> `AuthConfigInterface`, `LoginResponse` -> `AuthLoginResponseInterface`, `ValidateResponse` -> `AuthValidateResponseInterface`)
|
|
21
|
+
- **All request/response interfaces** now end with `Interface` (e.g., `PlaceOrderRequest` -> `PlaceOrderRequestInterface`, `SearchOrdersResponse` -> `SearchOrdersResponseInterface`)
|
|
22
|
+
- **Realtime types** renamed with descriptive names and `Interface` suffix (e.g., `MarketQuote` -> `RealtimeMarketQuoteEventInterface`, `MarketHubEvents` -> `RealtimeMarketEventHubInterface`, `UserHubEvents` -> `RealtimeUserEventHubInterface`)
|
|
23
|
+
|
|
24
|
+
See [MIGRATION.md](./MIGRATION.md) for a complete rename table with every old and new name.
|
|
25
|
+
|
|
26
|
+
#### File Structure Changes
|
|
27
|
+
|
|
28
|
+
- **Renamed all error files** from kebab-case to dot-notation:
|
|
29
|
+
- `api-error.ts` → `api.error.ts`
|
|
30
|
+
- `auth-error.ts` → `auth.error.ts`
|
|
31
|
+
- `base-error.ts` → `base.error.ts`
|
|
32
|
+
- `connection-error.ts` → `connection.error.ts`
|
|
33
|
+
|
|
34
|
+
- **Renamed hub files** to follow dot-notation pattern:
|
|
35
|
+
- `market-hub.ts` → `realtime.market.event.hub.ts`
|
|
36
|
+
- `user-hub.ts` → `realtime.user.event.hub.ts`
|
|
37
|
+
|
|
38
|
+
- **Removed generic `types.ts` files** and replaced with explicit interface files:
|
|
39
|
+
- `src/auth/types.ts` → Split into:
|
|
40
|
+
- `auth.config.interface.ts`
|
|
41
|
+
- `auth.validate.response.interface.ts`
|
|
42
|
+
- `login/auth.login.request.interface.ts`
|
|
43
|
+
- `login/auth.login.response.interface.ts`
|
|
44
|
+
- `src/rest/account/types.ts` → Renamed to `account.interface.ts` and split into:
|
|
45
|
+
- `search/search.accounts.request.interface.ts`
|
|
46
|
+
- `search/search.accounts.response.interface.ts`
|
|
47
|
+
- `src/rest/order/types.ts` → Renamed to `order.interface.ts` and split into:
|
|
48
|
+
- `place/request/place.order.request.interface.ts`
|
|
49
|
+
- `place/response/place.order.response.interface.ts`
|
|
50
|
+
- `cancel/request/cancel.order.request.interface.ts`
|
|
51
|
+
- `cancel/response/cancel.order.response.interface.ts`
|
|
52
|
+
- `modify/request/modify.order.request.interface.ts`
|
|
53
|
+
- `modify/response/modify.order.response.interface.ts`
|
|
54
|
+
- `search/request/search.orders.request.interface.ts`
|
|
55
|
+
- `search/response/search.orders.response.interface.ts`
|
|
56
|
+
- `search/open/request/search.open.orders.request.interface.ts`
|
|
57
|
+
- `search/open/response/search.open.orders.response.interface.ts`
|
|
58
|
+
- `src/rest/position/types.ts` → Renamed to `position.interface.ts` and split into:
|
|
59
|
+
- `close/request/close.position.request.interface.ts`
|
|
60
|
+
- `close/response/close.position.response.interface.ts`
|
|
61
|
+
- `partial/close/request/partial.close.position.request.interface.ts`
|
|
62
|
+
- `partial/close/response/partial.close.position.response.interface.ts`
|
|
63
|
+
- `search/open/request/search.open.positions.request.interface.ts`
|
|
64
|
+
- `search/open/response/search.open.positions.response.interface.ts`
|
|
65
|
+
- `src/rest/trade/types.ts` → Deleted and replaced with:
|
|
66
|
+
- `trade.interface.ts`
|
|
67
|
+
- `search/request/search.trades.request.interface.ts`
|
|
68
|
+
- `search/response/search.trades.response.interface.ts`
|
|
69
|
+
- `src/rest/history/types.ts` → Deleted and replaced with:
|
|
70
|
+
- `bar/bar.interface.ts`
|
|
71
|
+
- `bar/request/retrieve.bars.request.interface.ts`
|
|
72
|
+
- `bar/response/retrieve.bars.response.interface.ts`
|
|
73
|
+
- `src/rest/contract/types.ts` → Deleted and replaced with:
|
|
74
|
+
- `contract.interface.ts`
|
|
75
|
+
- `search/request/search.contracts.request.interface.ts`
|
|
76
|
+
- `search/response/search.contracts.response.interface.ts`
|
|
77
|
+
- `search/request/search.contract.by.id.request.interface.ts`
|
|
78
|
+
- `search/response/search.contract.by.id.request.interface.ts`
|
|
79
|
+
- `src/realtime/market/types.ts` → Deleted and replaced with:
|
|
80
|
+
- `event/realtime.market.event.interface.ts`
|
|
81
|
+
- `event/realtime.market.quote.event.interface.ts`
|
|
82
|
+
- `event/realtime.market.trade.event.interface.ts`
|
|
83
|
+
- `event/realtime.market.depth.event.interface.ts`
|
|
84
|
+
- `realtime.market.event.hub.interface.ts`
|
|
85
|
+
- `src/realtime/user/types.ts` → Deleted and replaced with:
|
|
86
|
+
- `account/realtime.user.account.update.interface.ts`
|
|
87
|
+
- `order/realtime.user.order.update.interface.ts`
|
|
88
|
+
- `position/realtime.user.position.update.interface.ts`
|
|
89
|
+
- `trade/realtime.user.trade.update.interface.ts`
|
|
90
|
+
- `realtime.user.event.hub.interface.ts`
|
|
91
|
+
|
|
92
|
+
#### New Config Interface Files
|
|
93
|
+
|
|
94
|
+
- Added `src/rest/http-client.config.interface.ts` for HTTP client configuration
|
|
95
|
+
- Added `src/realtime/connection-manager.config.interface.ts` for connection manager configuration
|
|
96
|
+
|
|
97
|
+
### ✨ Added
|
|
98
|
+
|
|
99
|
+
#### CME Contract Information System
|
|
100
|
+
|
|
101
|
+
- **New CME contract constants and utilities** (`src/rest/contract/cme/`):
|
|
102
|
+
- `CME_CONTRACTS` constant with complete contract specifications for all offered Topstep CME futures contracts
|
|
103
|
+
- `CmeContractStore` class for easy contract lookups and filtering
|
|
104
|
+
- `CmeContractInterface` with contract details including:
|
|
105
|
+
- `symbol`: Contract symbol (e.g., 'ES', 'NQ', 'CL')
|
|
106
|
+
- `name`: Full contract name
|
|
107
|
+
- `sector`: Contract sector (Equity, FX, Metals, Energy, etc.)
|
|
108
|
+
- `exchange`: Trading exchange (CME, CBOT, NYMEX, COMEX)
|
|
109
|
+
- `tickSize`: Minimum price fluctuation
|
|
110
|
+
- `tickValue`: Dollar value per tick
|
|
111
|
+
- `roundTripFees`: TopstepX round-trip commission and fees
|
|
112
|
+
- Contract sector enums: `EQUITY`, `FOREIGN_EXCHANGE`, `LIVE_STOCK`, `CROPS`, `GAS_AND_OIL`, `NOTES_AND_BONDS`, `METALS`, `CRYPTO`
|
|
113
|
+
- Exchange enums: `CME`, `CBOT`, `NYMEX`, `COMEX`
|
|
114
|
+
- Symbol enums for all supported contracts
|
|
115
|
+
|
|
116
|
+
**Example usage:**
|
|
117
|
+
|
|
118
|
+
```typescript
|
|
119
|
+
import { CME_CONTRACTS, CmeContractStore } from "topstepx-api";
|
|
120
|
+
|
|
121
|
+
const store = new CmeContractStore();
|
|
122
|
+
const esContract = store.getContractBySymbol("ES");
|
|
123
|
+
console.log(esContract?.tickSize); // 0.25
|
|
124
|
+
console.log(esContract?.tickValue); // 12.5
|
|
125
|
+
console.log(esContract?.roundTripFees); // 2.8
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
### 📖 Documentation
|
|
129
|
+
|
|
130
|
+
- Added comprehensive [MIGRATION.md](./MIGRATION.md) guide with:
|
|
131
|
+
- Detailed breaking changes documentation
|
|
132
|
+
- Step-by-step migration instructions
|
|
133
|
+
- Before/after code examples
|
|
134
|
+
- Migration impact assessment table
|
|
135
|
+
|
|
136
|
+
### ⚠️ Migration Notes
|
|
137
|
+
|
|
138
|
+
**IMPORTANT:** This is a breaking change that affects **all users**. All exported interfaces and enums have been renamed.
|
|
139
|
+
|
|
140
|
+
```typescript
|
|
141
|
+
// ❌ BREAKS in v2.0.0
|
|
142
|
+
import { TopstepXClient, OrderType } from "topstepx-api";
|
|
143
|
+
import type { Order, Position } from "topstepx-api";
|
|
144
|
+
|
|
145
|
+
// ✅ FIXED for v2.0.0
|
|
146
|
+
import { TopstepXClient, OrderTypeEnum } from "topstepx-api";
|
|
147
|
+
import type { OrderInterface, PositionInterface } from "topstepx-api";
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
**See [MIGRATION.md](./MIGRATION.md) for a complete migration guide with every rename listed.**
|
|
151
|
+
|
|
8
152
|
## [1.0.3] - 2026-01-23
|
|
9
153
|
|
|
10
154
|
### Changed
|
|
@@ -14,6 +158,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
14
158
|
## [1.0.2] - 2026-01-19
|
|
15
159
|
|
|
16
160
|
### Fixed
|
|
161
|
+
|
|
17
162
|
- Fixed account, contract, history, order, position, and trade REST API responses to include `errorMessage`, `errorCode`, and `success` fields in the root of the response payload.
|
|
18
163
|
|
|
19
164
|
## [1.0.1] - 2026-01-19
|
package/MIGRATION.md
ADDED
|
@@ -0,0 +1,515 @@
|
|
|
1
|
+
# Migration Guide: v1.x to v2.0.0
|
|
2
|
+
|
|
3
|
+
This guide helps you migrate from TopstepX-API v1.x to v2.0.0.
|
|
4
|
+
|
|
5
|
+
## Overview
|
|
6
|
+
|
|
7
|
+
Version 2.0.0 is a **MAJOR** release that refactors **internal file structure, file naming conventions, and exported type/enum names**. All exported interfaces now have an `Interface` suffix and all exported enums now have an `Enum` suffix. Internal files were reorganized from generic `types.ts` files into explicit, descriptive files.
|
|
8
|
+
|
|
9
|
+
**All users will need to update their imports** to use the new names.
|
|
10
|
+
|
|
11
|
+
## What Changed
|
|
12
|
+
|
|
13
|
+
### 1. Renamed Exports (Interfaces and Enums)
|
|
14
|
+
|
|
15
|
+
Every exported interface and enum has been renamed to follow a consistent naming convention:
|
|
16
|
+
|
|
17
|
+
- **Interfaces** now end with `Interface`
|
|
18
|
+
- **Enums** now end with `Enum`
|
|
19
|
+
|
|
20
|
+
#### Enum Renames
|
|
21
|
+
|
|
22
|
+
| v1.x | v2.0.0 |
|
|
23
|
+
|------|--------|
|
|
24
|
+
| `OrderType` | `OrderTypeEnum` |
|
|
25
|
+
| `OrderSide` | `OrderSideEnum` |
|
|
26
|
+
| `OrderStatus` | `OrderStatusEnum` |
|
|
27
|
+
| `BarUnit` | `BarUnitEnum` |
|
|
28
|
+
|
|
29
|
+
#### Domain Model Renames
|
|
30
|
+
|
|
31
|
+
| v1.x | v2.0.0 |
|
|
32
|
+
|------|--------|
|
|
33
|
+
| `Account` | `AccountInterface` |
|
|
34
|
+
| `Contract` | `ContractInterface` |
|
|
35
|
+
| `Order` | `OrderInterface` |
|
|
36
|
+
| `Position` | `PositionInterface` |
|
|
37
|
+
| `Trade` | `TradeInterface` |
|
|
38
|
+
| `Bar` | `BarInterface` |
|
|
39
|
+
|
|
40
|
+
#### Auth Type Renames
|
|
41
|
+
|
|
42
|
+
| v1.x | v2.0.0 |
|
|
43
|
+
|------|--------|
|
|
44
|
+
| `AuthConfig` | `AuthConfigInterface` |
|
|
45
|
+
| `LoginResponse` | `AuthLoginResponseInterface` |
|
|
46
|
+
| `ValidateResponse` | `AuthValidateResponseInterface` |
|
|
47
|
+
|
|
48
|
+
> **New in v2.0.0:** `AuthLoginRequestInterface` (no v1.x equivalent)
|
|
49
|
+
|
|
50
|
+
#### REST Request/Response Renames
|
|
51
|
+
|
|
52
|
+
**Account:**
|
|
53
|
+
|
|
54
|
+
| v1.x | v2.0.0 |
|
|
55
|
+
|------|--------|
|
|
56
|
+
| `SearchAccountsRequest` | `SearchAccountsRequestInterface` |
|
|
57
|
+
| `SearchAccountsResponse` | `SearchAccountsResponseInterface` |
|
|
58
|
+
|
|
59
|
+
**Order:**
|
|
60
|
+
|
|
61
|
+
| v1.x | v2.0.0 |
|
|
62
|
+
|------|--------|
|
|
63
|
+
| `PlaceOrderRequest` | `PlaceOrderRequestInterface` |
|
|
64
|
+
| `PlaceOrderResponse` | `PlaceOrderResponseInterface` |
|
|
65
|
+
| `ModifyOrderRequest` | `ModifyOrderRequestInterface` |
|
|
66
|
+
| `ModifyOrderResponse` | `ModifyOrderResponseInterface` |
|
|
67
|
+
| `CancelOrderRequest` | `CancelOrderRequestInterface` |
|
|
68
|
+
| `CancelOrderResponse` | `CancelOrderResponseInterface` |
|
|
69
|
+
| `SearchOrdersRequest` | `SearchOrdersRequestInterface` |
|
|
70
|
+
| `SearchOrdersResponse` | `SearchOrdersResponseInterface` |
|
|
71
|
+
| `SearchOpenOrdersRequest` | `SearchOpenOrdersRequestInterface` |
|
|
72
|
+
|
|
73
|
+
> **New in v2.0.0:** `SearchOpenOrdersResponseInterface` (was not exported in v1.x)
|
|
74
|
+
|
|
75
|
+
**Position:**
|
|
76
|
+
|
|
77
|
+
| v1.x | v2.0.0 |
|
|
78
|
+
|------|--------|
|
|
79
|
+
| `SearchOpenPositionsRequest` | `SearchOpenPositionsRequestInterface` |
|
|
80
|
+
| `SearchOpenPositionsResponse` | `SearchOpenPositionsResponseInterface` |
|
|
81
|
+
| `ClosePositionRequest` | `ClosePositionRequestInterface` |
|
|
82
|
+
| `ClosePositionResponse` | `ClosePositionResponseInterface` |
|
|
83
|
+
| `PartialClosePositionRequest` | `PartialClosePositionRequestInterface` |
|
|
84
|
+
| `PartialClosePositionResponse` | `PartialClosePositionResponseInterface` |
|
|
85
|
+
|
|
86
|
+
**Trade:**
|
|
87
|
+
|
|
88
|
+
| v1.x | v2.0.0 |
|
|
89
|
+
|------|--------|
|
|
90
|
+
| `SearchTradesRequest` | `SearchTradesRequestInterface` |
|
|
91
|
+
| `SearchTradesResponse` | `SearchTradesResponseInterface` |
|
|
92
|
+
|
|
93
|
+
**Contract:**
|
|
94
|
+
|
|
95
|
+
| v1.x | v2.0.0 |
|
|
96
|
+
|------|--------|
|
|
97
|
+
| `SearchContractsRequest` | `SearchContractsRequestInterface` |
|
|
98
|
+
| `SearchContractsResponse` | `SearchContractsResponseInterface` |
|
|
99
|
+
| `SearchContractByIdRequest` | `SearchContractByIdRequestInterface` |
|
|
100
|
+
| `SearchContractByIdResponse` | `SearchContractByIdResponseInterface` |
|
|
101
|
+
|
|
102
|
+
**History:**
|
|
103
|
+
|
|
104
|
+
| v1.x | v2.0.0 |
|
|
105
|
+
|------|--------|
|
|
106
|
+
| `RetrieveBarsRequest` | `RetrieveBarsRequestInterface` |
|
|
107
|
+
| `RetrieveBarsResponse` | `RetrieveBarsResponseInterface` |
|
|
108
|
+
|
|
109
|
+
#### Realtime Type Renames
|
|
110
|
+
|
|
111
|
+
| v1.x | v2.0.0 |
|
|
112
|
+
|------|--------|
|
|
113
|
+
| `MarketQuote` | `RealtimeMarketQuoteEventInterface` |
|
|
114
|
+
| `MarketTrade` | `RealtimeMarketTradeEventInterface` |
|
|
115
|
+
| `MarketDepth` | `RealtimeMarketDepthEventInterface` |
|
|
116
|
+
| `MarketHubEvents` | `RealtimeMarketEventHubInterface` |
|
|
117
|
+
| `UserHubEvents` | `RealtimeUserEventHubInterface` |
|
|
118
|
+
|
|
119
|
+
> **New in v2.0.0:** `RealtimeMarketEventInterface`, `RealtimeUserOrderUpdateInterface`, `RealtimeUserPositionUpdateInterface`, `RealtimeUserTradeUpdateInterface`, `RealtimeUserAccountUpdateInterface`, `ConnectionManagerConfigInterface`
|
|
120
|
+
|
|
121
|
+
#### Unchanged Exports
|
|
122
|
+
|
|
123
|
+
The following class and utility names did **not** change:
|
|
124
|
+
|
|
125
|
+
- `TopstepXClient`
|
|
126
|
+
- `AuthService`
|
|
127
|
+
- `HttpClient`
|
|
128
|
+
- `AccountApi`, `OrderApi`, `PositionApi`, `TradeApi`, `ContractApi`, `HistoryApi`
|
|
129
|
+
- `ConnectionManager`
|
|
130
|
+
- `RealtimeMarketEventHub`, `RealtimeUserEventHub`
|
|
131
|
+
- `TopstepXError`, `AuthenticationError`, `ApiError`, `ConnectionError`
|
|
132
|
+
- `TypedEventEmitter`
|
|
133
|
+
- `ApiResponse`, `TopstepXClientConfig`, `TopstepXClientEvents`
|
|
134
|
+
- `CME_CONTRACTS`, `CmeContractStore`
|
|
135
|
+
|
|
136
|
+
### 2. Internal File Structure Refactoring
|
|
137
|
+
|
|
138
|
+
The entire codebase was reorganized from generic `types.ts` files to explicit, descriptive interface files.
|
|
139
|
+
|
|
140
|
+
#### Example: Order Module
|
|
141
|
+
|
|
142
|
+
**v1.x File Structure:**
|
|
143
|
+
```
|
|
144
|
+
src/rest/order/
|
|
145
|
+
├── order.api.ts
|
|
146
|
+
├── types.ts # All interfaces in one file
|
|
147
|
+
└── index.ts
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
**v2.0.0 File Structure:**
|
|
151
|
+
```
|
|
152
|
+
src/rest/order/
|
|
153
|
+
├── order.api.ts
|
|
154
|
+
├── order.interface.ts # OrderInterface
|
|
155
|
+
├── place/
|
|
156
|
+
│ ├── request/place.order.request.interface.ts # PlaceOrderRequestInterface
|
|
157
|
+
│ └── response/place.order.response.interface.ts # PlaceOrderResponseInterface
|
|
158
|
+
├── cancel/
|
|
159
|
+
│ ├── request/cancel.order.request.interface.ts # CancelOrderRequestInterface
|
|
160
|
+
│ └── response/cancel.order.response.interface.ts # CancelOrderResponseInterface
|
|
161
|
+
├── modify/
|
|
162
|
+
│ ├── request/modify.order.request.interface.ts # ModifyOrderRequestInterface
|
|
163
|
+
│ └── response/modify.order.response.interface.ts # ModifyOrderResponseInterface
|
|
164
|
+
├── search/
|
|
165
|
+
│ ├── request/search.orders.request.interface.ts # SearchOrdersRequestInterface
|
|
166
|
+
│ ├── response/search.orders.response.interface.ts # SearchOrdersResponseInterface
|
|
167
|
+
│ └── open/
|
|
168
|
+
│ ├── request/search.open.orders.request.interface.ts
|
|
169
|
+
│ └── response/search.open.orders.response.interface.ts
|
|
170
|
+
└── index.ts
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
#### File Naming Convention Changes
|
|
174
|
+
|
|
175
|
+
All files now follow a consistent **dot-notation** pattern:
|
|
176
|
+
|
|
177
|
+
| Category | v1.x Pattern | v2.0.0 Pattern | Example |
|
|
178
|
+
|----------|-------------|----------------|---------|
|
|
179
|
+
| Interfaces | `types.ts` | `*.interface.ts` | `order.interface.ts` |
|
|
180
|
+
| Enums | `enums.ts` | `*.enum.ts` | `order.side.enum.ts` |
|
|
181
|
+
| Errors | `error-name.ts` | `*.error.ts` | `api.error.ts` |
|
|
182
|
+
| Hubs | `hub-name.ts` | `*.event.hub.ts` | `realtime.market.event.hub.ts` |
|
|
183
|
+
| Requests | N/A | `*.request.interface.ts` | `place.order.request.interface.ts` |
|
|
184
|
+
| Responses | N/A | `*.response.interface.ts` | `place.order.response.interface.ts` |
|
|
185
|
+
|
|
186
|
+
#### Deleted Files
|
|
187
|
+
|
|
188
|
+
All generic `types.ts` files were removed and split into explicit interface files:
|
|
189
|
+
|
|
190
|
+
- `src/types/enums.ts`
|
|
191
|
+
- `src/types/common.ts`
|
|
192
|
+
- `src/types/index.ts`
|
|
193
|
+
- `src/auth/types.ts`
|
|
194
|
+
- `src/rest/account/types.ts`
|
|
195
|
+
- `src/rest/order/types.ts`
|
|
196
|
+
- `src/rest/position/types.ts`
|
|
197
|
+
- `src/rest/trade/types.ts`
|
|
198
|
+
- `src/rest/history/types.ts`
|
|
199
|
+
- `src/rest/contract/types.ts`
|
|
200
|
+
- `src/realtime/market/types.ts`
|
|
201
|
+
- `src/realtime/user/types.ts`
|
|
202
|
+
|
|
203
|
+
### 3. Renamed Error Files
|
|
204
|
+
|
|
205
|
+
Error class files renamed from kebab-case to dot-notation:
|
|
206
|
+
|
|
207
|
+
| v1.x | v2.0.0 |
|
|
208
|
+
|------|--------|
|
|
209
|
+
| `api-error.ts` | `api.error.ts` |
|
|
210
|
+
| `auth-error.ts` | `auth.error.ts` |
|
|
211
|
+
| `base-error.ts` | `base.error.ts` |
|
|
212
|
+
| `connection-error.ts` | `connection.error.ts` |
|
|
213
|
+
|
|
214
|
+
### 4. Renamed Hub Files
|
|
215
|
+
|
|
216
|
+
| v1.x | v2.0.0 |
|
|
217
|
+
|------|--------|
|
|
218
|
+
| `market-hub.ts` | `realtime.market.event.hub.ts` |
|
|
219
|
+
| `user-hub.ts` | `realtime.user.event.hub.ts` |
|
|
220
|
+
|
|
221
|
+
### 5. Renamed Client File
|
|
222
|
+
|
|
223
|
+
| v1.x | v2.0.0 |
|
|
224
|
+
|------|--------|
|
|
225
|
+
| `client.ts` | `topstep.x.client.ts` |
|
|
226
|
+
|
|
227
|
+
## New Features in v2.0.0
|
|
228
|
+
|
|
229
|
+
### CME Contract Information
|
|
230
|
+
|
|
231
|
+
New comprehensive CME contract data with tick sizes, tick values, and fees:
|
|
232
|
+
|
|
233
|
+
```typescript
|
|
234
|
+
import {
|
|
235
|
+
CME_CONTRACTS,
|
|
236
|
+
CmeContractStore,
|
|
237
|
+
CmeContractSymbolEnum,
|
|
238
|
+
CmeContractSectorEnum,
|
|
239
|
+
} from "topstepx-api";
|
|
240
|
+
|
|
241
|
+
// Use the contract store
|
|
242
|
+
const store = new CmeContractStore();
|
|
243
|
+
|
|
244
|
+
// Get contract by symbol
|
|
245
|
+
const esContract = store.getContractBySymbol(CmeContractSymbolEnum.E_MINI_SP_500);
|
|
246
|
+
console.log(esContract?.tickSize); // 0.25
|
|
247
|
+
console.log(esContract?.tickValue); // 12.5
|
|
248
|
+
console.log(esContract?.roundTripFees); // 2.8 (TopstepX fees)
|
|
249
|
+
|
|
250
|
+
// Get all equity contracts
|
|
251
|
+
const equityContracts = store.getContractsBySector(CmeContractSectorEnum.EQUITY);
|
|
252
|
+
|
|
253
|
+
// Get all available sectors
|
|
254
|
+
const sectors = store.getSectors();
|
|
255
|
+
```
|
|
256
|
+
|
|
257
|
+
**Available contract data:**
|
|
258
|
+
- 60+ CME futures contracts (ES, NQ, CL, GC, ZN, etc.)
|
|
259
|
+
- Tick size (minimum price fluctuation)
|
|
260
|
+
- Tick value (dollar value per tick)
|
|
261
|
+
- Round-trip fees (TopstepX commissions)
|
|
262
|
+
- Contract sector and exchange information
|
|
263
|
+
|
|
264
|
+
## Migration Steps
|
|
265
|
+
|
|
266
|
+
### Step 1: Update Package Version
|
|
267
|
+
|
|
268
|
+
```bash
|
|
269
|
+
npm install topstepx-api@2.0.0
|
|
270
|
+
# or
|
|
271
|
+
yarn add topstepx-api@2.0.0
|
|
272
|
+
```
|
|
273
|
+
|
|
274
|
+
### Step 2: Update Enum Imports
|
|
275
|
+
|
|
276
|
+
```typescript
|
|
277
|
+
// v1.x
|
|
278
|
+
import { OrderType, OrderSide, OrderStatus, BarUnit } from "topstepx-api";
|
|
279
|
+
|
|
280
|
+
// v2.0.0
|
|
281
|
+
import { OrderTypeEnum, OrderSideEnum, OrderStatusEnum, BarUnitEnum } from "topstepx-api";
|
|
282
|
+
```
|
|
283
|
+
|
|
284
|
+
### Step 3: Update Interface Imports
|
|
285
|
+
|
|
286
|
+
```typescript
|
|
287
|
+
// v1.x
|
|
288
|
+
import type { Order, Position, Trade, Account, Contract, Bar } from "topstepx-api";
|
|
289
|
+
|
|
290
|
+
// v2.0.0
|
|
291
|
+
import type {
|
|
292
|
+
OrderInterface,
|
|
293
|
+
PositionInterface,
|
|
294
|
+
TradeInterface,
|
|
295
|
+
AccountInterface,
|
|
296
|
+
ContractInterface,
|
|
297
|
+
BarInterface,
|
|
298
|
+
} from "topstepx-api";
|
|
299
|
+
```
|
|
300
|
+
|
|
301
|
+
### Step 4: Update Request/Response Imports
|
|
302
|
+
|
|
303
|
+
```typescript
|
|
304
|
+
// v1.x
|
|
305
|
+
import type {
|
|
306
|
+
PlaceOrderRequest,
|
|
307
|
+
PlaceOrderResponse,
|
|
308
|
+
SearchOrdersRequest,
|
|
309
|
+
SearchOrdersResponse,
|
|
310
|
+
ClosePositionRequest,
|
|
311
|
+
ClosePositionResponse,
|
|
312
|
+
} from "topstepx-api";
|
|
313
|
+
|
|
314
|
+
// v2.0.0
|
|
315
|
+
import type {
|
|
316
|
+
PlaceOrderRequestInterface,
|
|
317
|
+
PlaceOrderResponseInterface,
|
|
318
|
+
SearchOrdersRequestInterface,
|
|
319
|
+
SearchOrdersResponseInterface,
|
|
320
|
+
ClosePositionRequestInterface,
|
|
321
|
+
ClosePositionResponseInterface,
|
|
322
|
+
} from "topstepx-api";
|
|
323
|
+
```
|
|
324
|
+
|
|
325
|
+
### Step 5: Update Auth Type Imports
|
|
326
|
+
|
|
327
|
+
```typescript
|
|
328
|
+
// v1.x
|
|
329
|
+
import type { AuthConfig, LoginResponse, ValidateResponse } from "topstepx-api";
|
|
330
|
+
|
|
331
|
+
// v2.0.0
|
|
332
|
+
import type {
|
|
333
|
+
AuthConfigInterface,
|
|
334
|
+
AuthLoginResponseInterface,
|
|
335
|
+
AuthValidateResponseInterface,
|
|
336
|
+
} from "topstepx-api";
|
|
337
|
+
```
|
|
338
|
+
|
|
339
|
+
### Step 6: Update Realtime Type Imports
|
|
340
|
+
|
|
341
|
+
```typescript
|
|
342
|
+
// v1.x
|
|
343
|
+
import type {
|
|
344
|
+
MarketQuote,
|
|
345
|
+
MarketTrade,
|
|
346
|
+
MarketDepth,
|
|
347
|
+
MarketHubEvents,
|
|
348
|
+
UserHubEvents,
|
|
349
|
+
} from "topstepx-api";
|
|
350
|
+
|
|
351
|
+
// v2.0.0
|
|
352
|
+
import type {
|
|
353
|
+
RealtimeMarketQuoteEventInterface,
|
|
354
|
+
RealtimeMarketTradeEventInterface,
|
|
355
|
+
RealtimeMarketDepthEventInterface,
|
|
356
|
+
RealtimeMarketEventHubInterface,
|
|
357
|
+
RealtimeUserEventHubInterface,
|
|
358
|
+
} from "topstepx-api";
|
|
359
|
+
```
|
|
360
|
+
|
|
361
|
+
### Step 7: Update Enum Value References in Code
|
|
362
|
+
|
|
363
|
+
Enum member names are unchanged, but the enum itself is renamed:
|
|
364
|
+
|
|
365
|
+
```typescript
|
|
366
|
+
// v1.x
|
|
367
|
+
const order = {
|
|
368
|
+
type: OrderType.Limit,
|
|
369
|
+
side: OrderSide.Buy,
|
|
370
|
+
};
|
|
371
|
+
|
|
372
|
+
if (order.status === OrderStatus.Filled) { ... }
|
|
373
|
+
|
|
374
|
+
// v2.0.0
|
|
375
|
+
const order = {
|
|
376
|
+
type: OrderTypeEnum.Limit,
|
|
377
|
+
side: OrderSideEnum.Buy,
|
|
378
|
+
};
|
|
379
|
+
|
|
380
|
+
if (order.status === OrderStatusEnum.Filled) { ... }
|
|
381
|
+
```
|
|
382
|
+
|
|
383
|
+
### Step 8: Clear TypeScript Cache
|
|
384
|
+
|
|
385
|
+
TypeScript may cache old file paths. Clear the cache:
|
|
386
|
+
|
|
387
|
+
```bash
|
|
388
|
+
# Delete TypeScript build cache
|
|
389
|
+
rm -rf node_modules/.cache
|
|
390
|
+
|
|
391
|
+
# Or restart your TypeScript server in VS Code
|
|
392
|
+
# Cmd/Ctrl + Shift + P -> "TypeScript: Restart TS Server"
|
|
393
|
+
```
|
|
394
|
+
|
|
395
|
+
### Step 9: Test Your Application
|
|
396
|
+
|
|
397
|
+
```bash
|
|
398
|
+
# Run TypeScript compiler
|
|
399
|
+
npx tsc --noEmit
|
|
400
|
+
|
|
401
|
+
# Run your tests
|
|
402
|
+
npm test
|
|
403
|
+
|
|
404
|
+
# Build your application
|
|
405
|
+
npm run build
|
|
406
|
+
```
|
|
407
|
+
|
|
408
|
+
## Quick Find/Replace Reference
|
|
409
|
+
|
|
410
|
+
For a fast migration, apply these find/replace operations across your codebase:
|
|
411
|
+
|
|
412
|
+
| Find | Replace |
|
|
413
|
+
|------|---------|
|
|
414
|
+
| `OrderType` | `OrderTypeEnum` |
|
|
415
|
+
| `OrderSide` | `OrderSideEnum` |
|
|
416
|
+
| `OrderStatus` | `OrderStatusEnum` |
|
|
417
|
+
| `BarUnit` | `BarUnitEnum` |
|
|
418
|
+
| `Account` (type only) | `AccountInterface` |
|
|
419
|
+
| `Contract` (type only) | `ContractInterface` |
|
|
420
|
+
| `Order` (type only) | `OrderInterface` |
|
|
421
|
+
| `Position` (type only) | `PositionInterface` |
|
|
422
|
+
| `Trade` (type only) | `TradeInterface` |
|
|
423
|
+
| `Bar` (type only) | `BarInterface` |
|
|
424
|
+
| `AuthConfig` | `AuthConfigInterface` |
|
|
425
|
+
| `LoginResponse` | `AuthLoginResponseInterface` |
|
|
426
|
+
| `ValidateResponse` | `AuthValidateResponseInterface` |
|
|
427
|
+
| `PlaceOrderRequest` | `PlaceOrderRequestInterface` |
|
|
428
|
+
| `PlaceOrderResponse` | `PlaceOrderResponseInterface` |
|
|
429
|
+
| `ModifyOrderRequest` | `ModifyOrderRequestInterface` |
|
|
430
|
+
| `ModifyOrderResponse` | `ModifyOrderResponseInterface` |
|
|
431
|
+
| `CancelOrderRequest` | `CancelOrderRequestInterface` |
|
|
432
|
+
| `CancelOrderResponse` | `CancelOrderResponseInterface` |
|
|
433
|
+
| `SearchOrdersRequest` | `SearchOrdersRequestInterface` |
|
|
434
|
+
| `SearchOrdersResponse` | `SearchOrdersResponseInterface` |
|
|
435
|
+
| `SearchOpenOrdersRequest` | `SearchOpenOrdersRequestInterface` |
|
|
436
|
+
| `SearchAccountsRequest` | `SearchAccountsRequestInterface` |
|
|
437
|
+
| `SearchAccountsResponse` | `SearchAccountsResponseInterface` |
|
|
438
|
+
| `SearchOpenPositionsRequest` | `SearchOpenPositionsRequestInterface` |
|
|
439
|
+
| `SearchOpenPositionsResponse` | `SearchOpenPositionsResponseInterface` |
|
|
440
|
+
| `ClosePositionRequest` | `ClosePositionRequestInterface` |
|
|
441
|
+
| `ClosePositionResponse` | `ClosePositionResponseInterface` |
|
|
442
|
+
| `PartialClosePositionRequest` | `PartialClosePositionRequestInterface` |
|
|
443
|
+
| `PartialClosePositionResponse` | `PartialClosePositionResponseInterface` |
|
|
444
|
+
| `SearchTradesRequest` | `SearchTradesRequestInterface` |
|
|
445
|
+
| `SearchTradesResponse` | `SearchTradesResponseInterface` |
|
|
446
|
+
| `SearchContractsRequest` | `SearchContractsRequestInterface` |
|
|
447
|
+
| `SearchContractsResponse` | `SearchContractsResponseInterface` |
|
|
448
|
+
| `SearchContractByIdRequest` | `SearchContractByIdRequestInterface` |
|
|
449
|
+
| `SearchContractByIdResponse` | `SearchContractByIdResponseInterface` |
|
|
450
|
+
| `RetrieveBarsRequest` | `RetrieveBarsRequestInterface` |
|
|
451
|
+
| `RetrieveBarsResponse` | `RetrieveBarsResponseInterface` |
|
|
452
|
+
| `MarketQuote` | `RealtimeMarketQuoteEventInterface` |
|
|
453
|
+
| `MarketTrade` | `RealtimeMarketTradeEventInterface` |
|
|
454
|
+
| `MarketDepth` | `RealtimeMarketDepthEventInterface` |
|
|
455
|
+
| `MarketHubEvents` | `RealtimeMarketEventHubInterface` |
|
|
456
|
+
| `UserHubEvents` | `RealtimeUserEventHubInterface` |
|
|
457
|
+
|
|
458
|
+
> **Note:** Be careful with domain model renames (`Account`, `Order`, etc.) as these are common words. Use your IDE's "rename symbol" feature or restrict find/replace to import statements and type annotations.
|
|
459
|
+
|
|
460
|
+
## Troubleshooting
|
|
461
|
+
|
|
462
|
+
### TypeScript Errors After Upgrade
|
|
463
|
+
|
|
464
|
+
**Error:** `Cannot find name 'Order'` / `Cannot find name 'OrderType'`
|
|
465
|
+
|
|
466
|
+
**Solution:** Update to the new names with `Interface` or `Enum` suffixes:
|
|
467
|
+
```typescript
|
|
468
|
+
// v1.x
|
|
469
|
+
import type { Order } from "topstepx-api";
|
|
470
|
+
import { OrderType } from "topstepx-api";
|
|
471
|
+
|
|
472
|
+
// v2.0.0
|
|
473
|
+
import type { OrderInterface } from "topstepx-api";
|
|
474
|
+
import { OrderTypeEnum } from "topstepx-api";
|
|
475
|
+
```
|
|
476
|
+
|
|
477
|
+
**Error:** `Cannot find module 'topstepx-api/dist/rest/order/types'`
|
|
478
|
+
|
|
479
|
+
**Solution:** Update imports to use the main entry point:
|
|
480
|
+
```typescript
|
|
481
|
+
import type { OrderInterface } from "topstepx-api";
|
|
482
|
+
```
|
|
483
|
+
|
|
484
|
+
### IDE Auto-Import Not Working
|
|
485
|
+
|
|
486
|
+
**Problem:** IDE suggests old type names or file paths
|
|
487
|
+
|
|
488
|
+
**Solution:**
|
|
489
|
+
1. Restart your TypeScript server (VS Code: Cmd/Ctrl + Shift + P -> "TypeScript: Restart TS Server")
|
|
490
|
+
2. Clear node_modules cache: `rm -rf node_modules/.cache`
|
|
491
|
+
3. Reload your editor
|
|
492
|
+
|
|
493
|
+
### Build Errors
|
|
494
|
+
|
|
495
|
+
**Problem:** Build fails with "Cannot find module" errors
|
|
496
|
+
|
|
497
|
+
**Solution:**
|
|
498
|
+
1. Delete `dist` and `node_modules` directories
|
|
499
|
+
2. Reinstall dependencies: `npm install`
|
|
500
|
+
3. Rebuild: `npm run build`
|
|
501
|
+
|
|
502
|
+
## Summary Table
|
|
503
|
+
|
|
504
|
+
| Change Category | Breaking? | Affected Users | Action Required |
|
|
505
|
+
|----------------|-----------|----------------|-----------------|
|
|
506
|
+
| Interface/Enum name suffixes | **Yes** | **All users** | **Rename all type/enum imports** |
|
|
507
|
+
| Internal file structure | Yes | Deep imports only | Update import paths |
|
|
508
|
+
| File naming (kebab -> dot) | Yes | Deep imports only | Update import paths |
|
|
509
|
+
| New CME contract features | No | Nobody | Optional adoption |
|
|
510
|
+
|
|
511
|
+
## Need Help?
|
|
512
|
+
|
|
513
|
+
- **Migration Issues:** Review this guide and the [CHANGELOG.md](./CHANGELOG.md)
|
|
514
|
+
- **Bug Reports:** Open an issue on [GitHub](https://github.com/nickmvincent/topstepx-api/issues)
|
|
515
|
+
- **Questions:** Check the updated [README.md](./README.md) for examples
|