tradestation-client 1.1.0 → 1.1.2
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/dist/authMiddleware.d.ts.map +1 -1
- package/dist/authMiddleware.js +2 -1
- package/dist/authMiddleware.js.map +1 -1
- package/dist/{tradestation-client.d.ts → index.d.ts} +1 -1
- package/dist/index.d.ts.map +1 -0
- package/dist/{tradestation-client.js → index.js} +1 -1
- package/dist/index.js.map +1 -0
- package/dist/scripts/downloadOpenAPI.d.ts.map +1 -0
- package/dist/scripts/downloadOpenAPI.js.map +1 -0
- package/dist/spike.js +1 -1
- package/dist/spike.js.map +1 -1
- package/package.json +11 -7
- package/.env.example +0 -2
- package/.prettierrc +0 -6
- package/authMiddleware.ts +0 -243
- package/cli.ts +0 -19
- package/commands/auth.ts +0 -13
- package/commands/barsCommand.ts +0 -88
- package/config.ts +0 -2
- package/dist/config.d.ts +0 -3
- package/dist/config.d.ts.map +0 -1
- package/dist/config.js +0 -3
- package/dist/config.js.map +0 -1
- package/dist/downloadOpenAPI.d.ts.map +0 -1
- package/dist/downloadOpenAPI.js.map +0 -1
- package/dist/tradestation-client.d.ts.map +0 -1
- package/dist/tradestation-client.js.map +0 -1
- package/downloadOpenAPI.ts +0 -31
- package/generated/tradestation-api.d.ts +0 -8115
- package/openapi.json +0 -12928
- package/spike.ts +0 -30
- package/test/cli.test.ts +0 -37
- package/tradestation-client.ts +0 -15
- package/tsconfig.json +0 -42
- /package/dist/{downloadOpenAPI.d.ts → scripts/downloadOpenAPI.d.ts} +0 -0
- /package/dist/{downloadOpenAPI.js → scripts/downloadOpenAPI.js} +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"authMiddleware.d.ts","sourceRoot":"","sources":["../authMiddleware.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,eAAe,CAAA;
|
|
1
|
+
{"version":3,"file":"authMiddleware.d.ts","sourceRoot":"","sources":["../authMiddleware.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,eAAe,CAAA;AAO/C,KAAK,YAAY,GAAG;IAClB,YAAY,EAAE,MAAM,CAAA;IACpB,aAAa,EAAE,MAAM,CAAA;IACrB,QAAQ,EAAE,MAAM,CAAA;IAChB,KAAK,EAAE,MAAM,CAAA;IACb,UAAU,EAAE,MAAM,CAAA;IAClB,UAAU,EAAE,MAAM,CAAA;CACnB,CAAA;AAED,KAAK,QAAQ,GAAG,YAAY,GAAG;IAC7B,SAAS,EAAE,MAAM,CAAA;IACjB,SAAS,EAAE,MAAM,CAAA;IACjB,aAAa,EAAE,MAAM,CAAA;CACtB,CAAA;AAQD,wBAAsB,WAAW,IAAI,OAAO,CAAC,QAAQ,GAAG,IAAI,CAAC,CAO5D;AA8HD,wBAAsB,YAAY,CAAC,QAAQ,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,GAAG,OAAO,CAAC,QAAQ,CAAC,CAkB5F;AAED,wBAAgB,oBAAoB,CAAC,QAAQ,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,GAAG,UAAU,CA6BvF"}
|
package/dist/authMiddleware.js
CHANGED
|
@@ -3,7 +3,8 @@ import { readFile, writeFile } from 'node:fs/promises';
|
|
|
3
3
|
import { join } from 'node:path';
|
|
4
4
|
import fastify from 'fastify';
|
|
5
5
|
import open from 'open';
|
|
6
|
-
|
|
6
|
+
const redirectPort = 31022;
|
|
7
|
+
const redirectUri = `http://localhost:${redirectPort}`;
|
|
7
8
|
const authFilePath = join(process.cwd(), 'tradestation-auth.json');
|
|
8
9
|
function generateRandomState() {
|
|
9
10
|
return randomBytes(32).toString('base64url');
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"authMiddleware.js","sourceRoot":"","sources":["../authMiddleware.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAA;AACzC,OAAO,EAAE,QAAQ,E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,CAAC;gBAED,IAAI,GAAG,MAAM,kBAAkB,CAAC,IAAI,CAAC,aAAa,EAAE,QAAQ,EAAE,YAAY,CAAC,CAAA;gBAE3E,QAAQ,GAAG,MAAM,KAAK,CAAC,IAAI,OAAO,CAAC,OAAO,CAAC,EAAE;oBAC3C,OAAO,EAAE;wBACP,aAAa,EAAE,UAAU,IAAI,CAAC,YAAY,EAAE;qBAC7C;iBACF,CAAC,CAAA;gBAEF,OAAO,QAAQ,CAAA;YACjB,CAAC;QACH,CAAC;KACF,CAAA;AACH,CAAC"}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { paths } from './generated/tradestation-api.js';
|
|
2
2
|
export declare function createTradeStationClient(clientId: string, clientSecret: string): import("openapi-fetch").Client<paths, `${string}/${string}`>;
|
|
3
|
-
//# sourceMappingURL=
|
|
3
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,iCAAiC,CAAA;AAG5D,wBAAgB,wBAAwB,CACtC,QAAQ,EAAE,MAAM,EAChB,YAAY,EAAE,MAAM,gEAOrB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAAA,OAAO,YAAY,MAAM,eAAe,CAAA;AAGxC,OAAO,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAA;AAE1D,MAAM,UAAU,wBAAwB,CACtC,QAAgB,EAChB,YAAoB;IAEpB,MAAM,MAAM,GAAG,YAAY,CAAQ;QACjC,OAAO,EAAE,8BAA8B;KACxC,CAAC,CAAA;IACF,MAAM,CAAC,GAAG,CAAC,oBAAoB,CAAC,QAAQ,EAAE,YAAY,CAAC,CAAC,CAAA;IACxD,OAAO,MAAM,CAAA;AACf,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"downloadOpenAPI.d.ts","sourceRoot":"","sources":["../../scripts/downloadOpenAPI.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"downloadOpenAPI.js","sourceRoot":"","sources":["../../scripts/downloadOpenAPI.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAA;AACnD,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAChC,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAA;AAE1C,MAAM,OAAO,GAAG,MAAM,QAAQ,CAAC,MAAM,CAAC;IACpC,QAAQ,EAAE,IAAI;IACd,OAAO,EAAE,QAAQ;IACjB,IAAI,EAAE,CAAC,sBAAsB,CAAC;CAC/B,CAAC,CAAA;AACF,MAAM,IAAI,GAAG,MAAM,OAAO,CAAC,OAAO,EAAE,CAAA;AAEpC,MAAM,IAAI,CAAC,IAAI,CAAC,kDAAkD,CAAC,CAAA;AAEnE,MAAM,IAAI,CAAC,gBAAgB,CAAC,aAAa,CAAC,CAAA;AAE1C,MAAM,eAAe,GAAG,IAAI,CAAC,YAAY,CAAC,UAAU,CAAC,CAAA;AAErD,MAAM,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,EAAE,IAAI,EAAE,UAAU,EAAE,CAAC,CAAC,KAAK,EAAE,CAAA;AAE1D,MAAM,QAAQ,GAAG,MAAM,eAAe,CAAA;AACtC,MAAM,cAAc,GAAG,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAA;AAE5C,IAAI,cAAc,EAAE,CAAC;IACnB,MAAM,QAAQ,CAAC,cAAc,EAAE,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,cAAc,CAAC,CAAC,CAAA;IACnE,MAAM,MAAM,CAAC,cAAc,CAAC,CAAA;IAC5B,OAAO,CAAC,GAAG,CAAC,2CAA2C,CAAC,CAAA;AAC1D,CAAC;KAAM,CAAC;IACN,MAAM,IAAI,KAAK,CAAC,iBAAiB,CAAC,CAAA;AACpC,CAAC;AAED,MAAM,OAAO,CAAC,KAAK,EAAE,CAAA"}
|
package/dist/spike.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import process from 'node:process';
|
|
2
2
|
process.loadEnvFile();
|
|
3
|
-
import { createTradeStationClient } from './
|
|
3
|
+
import { createTradeStationClient } from './index.js';
|
|
4
4
|
const tradestationClient = createTradeStationClient(process.env.CLIENT_ID, process.env.CLIENT_SECRET);
|
|
5
5
|
const { data } = await tradestationClient.GET('/v3/marketdata/stream/barcharts/{symbol}', {
|
|
6
6
|
params: {
|
package/dist/spike.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"spike.js","sourceRoot":"","sources":["../spike.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,MAAM,cAAc,CAAA;AAElC,OAAO,CAAC,WAAW,EAAE,CAAA;AAErB,OAAO,EAAE,wBAAwB,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"spike.js","sourceRoot":"","sources":["../spike.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,MAAM,cAAc,CAAA;AAElC,OAAO,CAAC,WAAW,EAAE,CAAA;AAErB,OAAO,EAAE,wBAAwB,EAAE,MAAM,YAAY,CAAA;AAErD,MAAM,kBAAkB,GAAG,wBAAwB,CAAC,OAAO,CAAC,GAAG,CAAC,SAAU,EAAE,OAAO,CAAC,GAAG,CAAC,aAAc,CAAC,CAAA;AAEvG,MAAM,EAAE,IAAI,EAAE,GAAG,MAAM,kBAAkB,CAAC,GAAG,CAAC,0CAA0C,EAAE;IACxF,MAAM,EAAE;QACN,IAAI,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE;QACvB,KAAK,EAAE;YACL,QAAQ,EAAE,GAAG;YACb,IAAI,EAAE,QAAQ;YACd,QAAQ,EAAE,GAAG;YACb,eAAe,EAAE,YAAY;SAC9B;KACF;IACD,OAAO,EAAE,QAAQ;CAClB,CAAC,CAAA;AAEF,IAAI,KAAK,EAAE,MAAM,KAAK,IAAI,IAAK,EAAE,CAAC;IAChC,OAAO,CAAC,GAAG,CAAC,IAAI,WAAW,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAA;AAC9C,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,25 +1,28 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tradestation-client",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.2",
|
|
4
4
|
"description": "A Node.js client for the TradeStation API with OAuth2 authentication and OpenAPI integration.",
|
|
5
5
|
"type": "module",
|
|
6
|
+
"main": "./dist/index.js",
|
|
6
7
|
"bin": "./dist/cli.js",
|
|
8
|
+
"files": [
|
|
9
|
+
"dist"
|
|
10
|
+
],
|
|
7
11
|
"scripts": {
|
|
8
12
|
"test": "tsx --experimental-test-module-mocks --test",
|
|
9
|
-
"test:ts": "tsc --noEmit",
|
|
10
13
|
"cli": "tsx cli.ts",
|
|
11
|
-
"download-openapi": "node
|
|
12
|
-
"generate-client": "openapi-typescript
|
|
13
|
-
"build": "npm run download-openapi && npm run generate-client && tsc",
|
|
14
|
+
"download-openapi": "node scripts/downloadOpenAPI.ts",
|
|
15
|
+
"generate-client": "openapi-typescript openapi.json --output generated/tradestation-api.d.ts",
|
|
16
|
+
"build": "npm run download-openapi && npm run generate-client && rimraf dist && tsc",
|
|
14
17
|
"prepublishOnly": "npm run build"
|
|
15
18
|
},
|
|
16
19
|
"keywords": [],
|
|
17
|
-
"author": "",
|
|
20
|
+
"author": "Simone Busoli <simone.busoli@gmail.com>",
|
|
21
|
+
"repository": "github:simoneb/tradestation-client",
|
|
18
22
|
"dependencies": {
|
|
19
23
|
"commander": "^14.0.2",
|
|
20
24
|
"fastify": "^5.6.2",
|
|
21
25
|
"install": "^0.13.0",
|
|
22
|
-
"npm": "^11.7.0",
|
|
23
26
|
"open": "^11.0.0",
|
|
24
27
|
"openapi-fetch": "^0.15.0",
|
|
25
28
|
"tradestation-api-ts": "^1.2.1"
|
|
@@ -28,6 +31,7 @@
|
|
|
28
31
|
"@types/node": "^25.0.3",
|
|
29
32
|
"openapi-typescript": "^7.10.1",
|
|
30
33
|
"playwright-core": "^1.57.0",
|
|
34
|
+
"rimraf": "^6.1.2",
|
|
31
35
|
"tsx": "^4.21.0",
|
|
32
36
|
"typescript": "^5.9.3"
|
|
33
37
|
}
|
package/.env.example
DELETED
package/.prettierrc
DELETED
package/authMiddleware.ts
DELETED
|
@@ -1,243 +0,0 @@
|
|
|
1
|
-
import { randomBytes } from 'node:crypto'
|
|
2
|
-
import { readFile, writeFile } from 'node:fs/promises'
|
|
3
|
-
import { join } from 'node:path'
|
|
4
|
-
import type { Middleware } from 'openapi-fetch'
|
|
5
|
-
import fastify from 'fastify'
|
|
6
|
-
import open from 'open'
|
|
7
|
-
|
|
8
|
-
import { redirectPort, redirectUri } from './config.js'
|
|
9
|
-
|
|
10
|
-
type AuthResponse = {
|
|
11
|
-
access_token: string
|
|
12
|
-
refresh_token: string
|
|
13
|
-
id_token: string
|
|
14
|
-
scope: string
|
|
15
|
-
expires_in: number
|
|
16
|
-
token_type: string
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
type AuthData = AuthResponse & {
|
|
20
|
-
timestamp: number // Unix timestamp in milliseconds when token was obtained
|
|
21
|
-
client_id: string
|
|
22
|
-
client_secret: string
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
const authFilePath = join(process.cwd(), 'tradestation-auth.json')
|
|
26
|
-
|
|
27
|
-
function generateRandomState(): string {
|
|
28
|
-
return randomBytes(32).toString('base64url')
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
export async function tryLoadAuth(): Promise<AuthData | null> {
|
|
32
|
-
try {
|
|
33
|
-
const data = await readFile(authFilePath, 'utf-8')
|
|
34
|
-
return JSON.parse(data)
|
|
35
|
-
} catch {
|
|
36
|
-
return null
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
async function saveAuth(
|
|
41
|
-
authResponse: AuthResponse,
|
|
42
|
-
clientId: string,
|
|
43
|
-
clientSecret: string
|
|
44
|
-
): Promise<AuthData> {
|
|
45
|
-
const authData: AuthData = {
|
|
46
|
-
...authResponse,
|
|
47
|
-
timestamp: Date.now(),
|
|
48
|
-
client_id: clientId,
|
|
49
|
-
client_secret: clientSecret,
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
await writeFile(authFilePath, JSON.stringify(authData, null, 2), 'utf-8')
|
|
53
|
-
return authData
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
function isTokenValid(token: AuthData): boolean {
|
|
57
|
-
const now = Date.now()
|
|
58
|
-
const expiresAt = token.timestamp + token.expires_in * 1000
|
|
59
|
-
// Consider token expired 30 seconds before actual expiration to account for clock skew
|
|
60
|
-
return now < expiresAt - 30000
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
async function requestAccessToken(
|
|
64
|
-
code: string,
|
|
65
|
-
clientId: string,
|
|
66
|
-
clientSecret: string
|
|
67
|
-
): Promise<AuthData> {
|
|
68
|
-
const authRes = await fetch('https://signin.tradestation.com/oauth/token', {
|
|
69
|
-
method: 'POST',
|
|
70
|
-
headers: {
|
|
71
|
-
'Content-Type': 'application/x-www-form-urlencoded',
|
|
72
|
-
},
|
|
73
|
-
body: new URLSearchParams({
|
|
74
|
-
grant_type: 'authorization_code',
|
|
75
|
-
code,
|
|
76
|
-
redirect_uri: redirectUri,
|
|
77
|
-
client_id: clientId,
|
|
78
|
-
client_secret: clientSecret,
|
|
79
|
-
}),
|
|
80
|
-
})
|
|
81
|
-
|
|
82
|
-
const authResponse = (await authRes.json()) as AuthResponse
|
|
83
|
-
|
|
84
|
-
if (!authRes.ok) {
|
|
85
|
-
throw new Error(`Failed to obtain access token: ${authResponse}`)
|
|
86
|
-
}
|
|
87
|
-
return saveAuth(authResponse, clientId, clientSecret)
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
async function refreshAccessToken(
|
|
91
|
-
refreshToken: string,
|
|
92
|
-
clientId: string,
|
|
93
|
-
clientSecret: string
|
|
94
|
-
): Promise<AuthData> {
|
|
95
|
-
const authRes = await fetch('https://signin.tradestation.com/oauth/token', {
|
|
96
|
-
method: 'POST',
|
|
97
|
-
headers: {
|
|
98
|
-
'Content-Type': 'application/x-www-form-urlencoded',
|
|
99
|
-
},
|
|
100
|
-
body: new URLSearchParams({
|
|
101
|
-
grant_type: 'refresh_token',
|
|
102
|
-
client_id: clientId,
|
|
103
|
-
client_secret: clientSecret,
|
|
104
|
-
refresh_token: refreshToken,
|
|
105
|
-
}),
|
|
106
|
-
})
|
|
107
|
-
|
|
108
|
-
if (!authRes.ok) {
|
|
109
|
-
throw new Error(`Failed to refresh token: ${await authRes.text()}`)
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
const authResponse = (await authRes.json()) as AuthResponse
|
|
113
|
-
|
|
114
|
-
// Preserve the original refresh token if a new one wasn't provided
|
|
115
|
-
// (TradeStation doesn't rotate refresh tokens by default)
|
|
116
|
-
if (!authResponse.refresh_token) {
|
|
117
|
-
authResponse.refresh_token = refreshToken
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
return saveAuth(authResponse, clientId, clientSecret)
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
async function authenticateWithOAuth2(
|
|
124
|
-
clientId: string,
|
|
125
|
-
clientSecret: string
|
|
126
|
-
): Promise<AuthData> {
|
|
127
|
-
const app = fastify()
|
|
128
|
-
const state = generateRandomState()
|
|
129
|
-
|
|
130
|
-
const authPromise = new Promise<AuthData>((resolve, reject) => {
|
|
131
|
-
app.get('/', async (request, reply) => {
|
|
132
|
-
const { code, state: callbackState } = request.query as {
|
|
133
|
-
code?: string
|
|
134
|
-
state?: string
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
if (!code) {
|
|
138
|
-
reply.code(400)
|
|
139
|
-
return 'No code provided'
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
if (callbackState !== state) {
|
|
143
|
-
reply.code(401)
|
|
144
|
-
reject(new Error('State parameter mismatch - possible CSRF attack'))
|
|
145
|
-
return 'State validation failed'
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
resolve(await requestAccessToken(code, clientId, clientSecret))
|
|
149
|
-
|
|
150
|
-
setTimeout(() => {
|
|
151
|
-
app.close()
|
|
152
|
-
}, 100)
|
|
153
|
-
|
|
154
|
-
return 'Authorization successful! You can close this tab.'
|
|
155
|
-
})
|
|
156
|
-
})
|
|
157
|
-
|
|
158
|
-
await app.listen({ port: redirectPort, host: 'localhost' })
|
|
159
|
-
|
|
160
|
-
console.log('Opening browser for authentication...')
|
|
161
|
-
|
|
162
|
-
await openAuthUrl(state, clientId)
|
|
163
|
-
|
|
164
|
-
return authPromise
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
async function openAuthUrl(state: string, clientId: string) {
|
|
168
|
-
const authUrl = new URL('https://signin.tradestation.com/authorize')
|
|
169
|
-
authUrl.searchParams.append('response_type', 'code')
|
|
170
|
-
authUrl.searchParams.append(
|
|
171
|
-
'scope',
|
|
172
|
-
'openid offline_access profile MarketData ReadAccount Trade Matrix'
|
|
173
|
-
)
|
|
174
|
-
authUrl.searchParams.append('redirect_uri', redirectUri)
|
|
175
|
-
authUrl.searchParams.append('client_id', clientId)
|
|
176
|
-
authUrl.searchParams.append('state', state)
|
|
177
|
-
authUrl.searchParams.append('audience', 'https://api.tradestation.com')
|
|
178
|
-
|
|
179
|
-
await open(authUrl.toString())
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
export async function authenticate(
|
|
183
|
-
clientId: string,
|
|
184
|
-
clientSecret: string
|
|
185
|
-
): Promise<AuthData> {
|
|
186
|
-
const auth = await tryLoadAuth()
|
|
187
|
-
|
|
188
|
-
if (!auth) {
|
|
189
|
-
return authenticateWithOAuth2(clientId, clientSecret)
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
if (isTokenValid(auth)) {
|
|
193
|
-
return auth
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
try {
|
|
197
|
-
return await refreshAccessToken(auth.refresh_token, clientId, clientSecret)
|
|
198
|
-
} catch (error) {
|
|
199
|
-
console.error('Token refresh failed, starting OAuth flow:', error)
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
return authenticateWithOAuth2(clientId, clientSecret)
|
|
203
|
-
}
|
|
204
|
-
|
|
205
|
-
export function createAuthMiddleware(
|
|
206
|
-
clientId: string,
|
|
207
|
-
clientSecret: string
|
|
208
|
-
): Middleware {
|
|
209
|
-
return {
|
|
210
|
-
async onRequest({ request }) {
|
|
211
|
-
const auth = await authenticate(clientId, clientSecret)
|
|
212
|
-
|
|
213
|
-
request.headers.set('Authorization', `Bearer ${auth.access_token}`)
|
|
214
|
-
return request
|
|
215
|
-
},
|
|
216
|
-
async onResponse({ response, request }) {
|
|
217
|
-
if (response.status === 401) {
|
|
218
|
-
console.warn(
|
|
219
|
-
`Received 401 Unauthorized for request to ${request.url}. Access token may be invalid or expired.`
|
|
220
|
-
)
|
|
221
|
-
|
|
222
|
-
let auth = await tryLoadAuth()
|
|
223
|
-
if (!auth) {
|
|
224
|
-
throw new Error('No authentication data available to refresh token.')
|
|
225
|
-
}
|
|
226
|
-
|
|
227
|
-
auth = await refreshAccessToken(
|
|
228
|
-
auth.refresh_token,
|
|
229
|
-
clientId,
|
|
230
|
-
clientSecret
|
|
231
|
-
)
|
|
232
|
-
|
|
233
|
-
response = await fetch(new Request(request), {
|
|
234
|
-
headers: {
|
|
235
|
-
Authorization: `Bearer ${auth.access_token}`,
|
|
236
|
-
},
|
|
237
|
-
})
|
|
238
|
-
|
|
239
|
-
return response
|
|
240
|
-
}
|
|
241
|
-
},
|
|
242
|
-
}
|
|
243
|
-
}
|
package/cli.ts
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
import { program, Option, Command } from 'commander'
|
|
3
|
-
import { TradeStationClient } from 'tradestation-api-ts'
|
|
4
|
-
|
|
5
|
-
import { authenticate, tryLoadAuth } from './authMiddleware.js'
|
|
6
|
-
import type { BarUnit, SessionTemplate } from 'tradestation-api-ts/dist/types/marketData.js'
|
|
7
|
-
import { authCommand } from './commands/auth.js'
|
|
8
|
-
import { barsCommand } from './commands/barsCommand.js'
|
|
9
|
-
|
|
10
|
-
program
|
|
11
|
-
.addOption(
|
|
12
|
-
new Option('--environment <environment>', 'TradeStation environment')
|
|
13
|
-
.choices(['Live', 'Simulation'])
|
|
14
|
-
.default('Simulation')
|
|
15
|
-
)
|
|
16
|
-
.addCommand(authCommand, { isDefault: true })
|
|
17
|
-
.addCommand(barsCommand)
|
|
18
|
-
|
|
19
|
-
await program.parseAsync()
|
package/commands/auth.ts
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { Command } from 'commander'
|
|
2
|
-
|
|
3
|
-
import { authenticate } from '../authMiddleware.js'
|
|
4
|
-
|
|
5
|
-
export const authCommand = new Command('auth')
|
|
6
|
-
.description('Authenticate with TradeStation API')
|
|
7
|
-
.requiredOption('--clientId <clientId>', 'TradeStation Client ID')
|
|
8
|
-
.requiredOption('--clientSecret <clientSecret>', 'TradeStation Client Secret')
|
|
9
|
-
.action(async (options: { clientId: string; clientSecret: string }) => {
|
|
10
|
-
console.log('Authenticating with TradeStation API...', options)
|
|
11
|
-
await authenticate(options.clientId, options.clientSecret)
|
|
12
|
-
console.log('Authentication successful!')
|
|
13
|
-
})
|
package/commands/barsCommand.ts
DELETED
|
@@ -1,88 +0,0 @@
|
|
|
1
|
-
import { Command, Option } from 'commander'
|
|
2
|
-
import { TradeStationClient } from 'tradestation-api-ts'
|
|
3
|
-
import type { BarUnit, SessionTemplate } from 'tradestation-api-ts/dist/types/marketData.js'
|
|
4
|
-
import fsp from 'fs/promises'
|
|
5
|
-
|
|
6
|
-
import { tryLoadAuth } from '../authMiddleware.js'
|
|
7
|
-
|
|
8
|
-
const sessions = ['Default', 'USEQPre', 'USEQPost', 'USEQPreAndPost', 'USEQ24Hour']
|
|
9
|
-
|
|
10
|
-
const units = ['Minute', 'Hour', 'Daily', 'Weekly', 'Monthly']
|
|
11
|
-
|
|
12
|
-
async function authenticateOrFail() {
|
|
13
|
-
const authData = await tryLoadAuth()
|
|
14
|
-
if (!authData) {
|
|
15
|
-
console.error('No authentication data found. Please run the auth command first or provide credentials.')
|
|
16
|
-
process.exit(1)
|
|
17
|
-
}
|
|
18
|
-
return authData
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
export const barsCommand = new Command('bars')
|
|
22
|
-
.description('Download market data bars from TradeStation API')
|
|
23
|
-
.argument('<symbol>', 'Market symbol to download data for')
|
|
24
|
-
.option('--interval <interval>', 'Bar interval (e.g., 1, 5, 1440, ...)', '1')
|
|
25
|
-
.addOption(new Option('--unit <unit>', 'Bar unit').choices(units).default('Daily'))
|
|
26
|
-
.option('--barsBack <barsBack>', 'Number of bars to retrieve', parseInt)
|
|
27
|
-
.option('--firstDate <firstDate>', 'First date for bar data (YYYY-MM-DD)')
|
|
28
|
-
.option('--lastDate <lastDate>', 'Last date for bar data (YYYY-MM-DD)')
|
|
29
|
-
.addOption(
|
|
30
|
-
new Option('--sessionTemplate <sessionTemplate>', 'Session template to use.').choices(sessions).default(sessions[0])
|
|
31
|
-
)
|
|
32
|
-
// Optional authentication options
|
|
33
|
-
.addOption(new Option('--clientId <clientId>', 'TradeStation Client ID'))
|
|
34
|
-
.addOption(new Option('--clientSecret <clientSecret>', 'TradeStation Client Secret'))
|
|
35
|
-
.addOption(new Option('--refreshToken <refreshToken>', 'TradeStation Refresh Token'))
|
|
36
|
-
// Output options
|
|
37
|
-
.option('-o --output <output>', 'Output file name, defaults to <symbol>.json')
|
|
38
|
-
.action(async function (
|
|
39
|
-
symbol: string,
|
|
40
|
-
options: {
|
|
41
|
-
interval: string
|
|
42
|
-
unit: BarUnit
|
|
43
|
-
barsBack: number
|
|
44
|
-
firstDate: string
|
|
45
|
-
lastDate: string
|
|
46
|
-
sessionTemplate: SessionTemplate
|
|
47
|
-
clientId?: string
|
|
48
|
-
clientSecret?: string
|
|
49
|
-
refreshToken?: string
|
|
50
|
-
output: string
|
|
51
|
-
}
|
|
52
|
-
) {
|
|
53
|
-
const environment = this.optsWithGlobals().environment as 'Live' | 'Simulation'
|
|
54
|
-
const output = options.output || `${symbol}.json`
|
|
55
|
-
|
|
56
|
-
let client: TradeStationClient
|
|
57
|
-
|
|
58
|
-
if (options.clientId && options.clientSecret && options.refreshToken) {
|
|
59
|
-
client = new TradeStationClient({
|
|
60
|
-
clientId: options.clientId,
|
|
61
|
-
clientSecret: options.clientSecret,
|
|
62
|
-
refresh_token: options.refreshToken,
|
|
63
|
-
environment,
|
|
64
|
-
})
|
|
65
|
-
} else {
|
|
66
|
-
const authData = await authenticateOrFail()
|
|
67
|
-
client = new TradeStationClient({
|
|
68
|
-
clientId: authData.client_id,
|
|
69
|
-
clientSecret: authData.client_secret,
|
|
70
|
-
refresh_token: authData.refresh_token,
|
|
71
|
-
environment,
|
|
72
|
-
})
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
console.log(`Downloading market data for symbol: ${symbol}`)
|
|
76
|
-
|
|
77
|
-
const bars = await client.marketData.getBarHistory(symbol, {
|
|
78
|
-
interval: options.interval,
|
|
79
|
-
unit: options.unit,
|
|
80
|
-
firstdate: options.firstDate,
|
|
81
|
-
lastdate: options.lastDate,
|
|
82
|
-
barsback: options.barsBack,
|
|
83
|
-
sessiontemplate: options.sessionTemplate,
|
|
84
|
-
})
|
|
85
|
-
|
|
86
|
-
await fsp.writeFile(output, JSON.stringify(bars.Bars, null, 2))
|
|
87
|
-
console.log(`Saved ${bars.Bars.length} bars to ${output}`)
|
|
88
|
-
})
|
package/config.ts
DELETED
package/dist/config.d.ts
DELETED
package/dist/config.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../config.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,YAAY,QAAQ,CAAA;AACjC,eAAO,MAAM,WAAW,2BAAqC,CAAA"}
|
package/dist/config.js
DELETED
package/dist/config.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"config.js","sourceRoot":"","sources":["../config.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,YAAY,GAAG,KAAK,CAAA;AACjC,MAAM,CAAC,MAAM,WAAW,GAAG,oBAAoB,YAAY,EAAE,CAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"downloadOpenAPI.d.ts","sourceRoot":"","sources":["../downloadOpenAPI.ts"],"names":[],"mappings":""}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"downloadOpenAPI.js","sourceRoot":"","sources":["../downloadOpenAPI.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAA;AACnD,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAChC,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAA;AAE1C,MAAM,OAAO,GAAG,MAAM,QAAQ,CAAC,MAAM,CAAC;IACpC,QAAQ,EAAE,IAAI;IACd,OAAO,EAAE,QAAQ;IACjB,IAAI,EAAE,CAAC,sBAAsB,CAAC;CAC/B,CAAC,CAAA;AACF,MAAM,IAAI,GAAG,MAAM,OAAO,CAAC,OAAO,EAAE,CAAA;AAEpC,MAAM,IAAI,CAAC,IAAI,CAAC,kDAAkD,CAAC,CAAA;AAEnE,MAAM,IAAI,CAAC,gBAAgB,CAAC,aAAa,CAAC,CAAA;AAE1C,MAAM,eAAe,GAAG,IAAI,CAAC,YAAY,CAAC,UAAU,CAAC,CAAA;AAErD,MAAM,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,EAAE,IAAI,EAAE,UAAU,EAAE,CAAC,CAAC,KAAK,EAAE,CAAA;AAE1D,MAAM,QAAQ,GAAG,MAAM,eAAe,CAAA;AACtC,MAAM,cAAc,GAAG,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAA;AAE5C,IAAI,cAAc,EAAE,CAAC;IACnB,MAAM,QAAQ,CAAC,cAAc,EAAE,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,cAAc,CAAC,CAAC,CAAA;IACnE,MAAM,MAAM,CAAC,cAAc,CAAC,CAAA;IAC5B,OAAO,CAAC,GAAG,CAAC,2CAA2C,CAAC,CAAA;AAC1D,CAAC;KAAM,CAAC;IACN,MAAM,IAAI,KAAK,CAAC,iBAAiB,CAAC,CAAA;AACpC,CAAC;AAED,MAAM,OAAO,CAAC,KAAK,EAAE,CAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"tradestation-client.d.ts","sourceRoot":"","sources":["../tradestation-client.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,iCAAiC,CAAA;AAG5D,wBAAgB,wBAAwB,CACtC,QAAQ,EAAE,MAAM,EAChB,YAAY,EAAE,MAAM,gEAOrB"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"tradestation-client.js","sourceRoot":"","sources":["../tradestation-client.ts"],"names":[],"mappings":"AAAA,OAAO,YAAY,MAAM,eAAe,CAAA;AAGxC,OAAO,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAA;AAE1D,MAAM,UAAU,wBAAwB,CACtC,QAAgB,EAChB,YAAoB;IAEpB,MAAM,MAAM,GAAG,YAAY,CAAQ;QACjC,OAAO,EAAE,8BAA8B;KACxC,CAAC,CAAA;IACF,MAAM,CAAC,GAAG,CAAC,oBAAoB,CAAC,QAAQ,EAAE,YAAY,CAAC,CAAC,CAAA;IACxD,OAAO,MAAM,CAAA;AACf,CAAC"}
|
package/downloadOpenAPI.ts
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { copyFile, unlink } from 'node:fs/promises'
|
|
2
|
-
import { join } from 'node:path'
|
|
3
|
-
import { chromium } from 'playwright-core'
|
|
4
|
-
|
|
5
|
-
const browser = await chromium.launch({
|
|
6
|
-
headless: true,
|
|
7
|
-
channel: 'chrome',
|
|
8
|
-
args: ['--disable-extensions'],
|
|
9
|
-
})
|
|
10
|
-
const page = await browser.newPage()
|
|
11
|
-
|
|
12
|
-
await page.goto('https://api.tradestation.com/docs/specification/')
|
|
13
|
-
|
|
14
|
-
await page.waitForLoadState('networkidle')
|
|
15
|
-
|
|
16
|
-
const downloadPromise = page.waitForEvent('download')
|
|
17
|
-
|
|
18
|
-
await page.getByRole('link', { name: 'Download' }).click()
|
|
19
|
-
|
|
20
|
-
const download = await downloadPromise
|
|
21
|
-
const downloadedPath = await download.path()
|
|
22
|
-
|
|
23
|
-
if (downloadedPath) {
|
|
24
|
-
await copyFile(downloadedPath, join(process.cwd(), 'openapi.json'))
|
|
25
|
-
await unlink(downloadedPath)
|
|
26
|
-
console.log('✅ OpenAPI spec downloaded to openapi.json')
|
|
27
|
-
} else {
|
|
28
|
-
throw new Error('Download failed')
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
await browser.close()
|