tradestation-client 1.0.14 → 1.0.15
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/.prettierrc +3 -2
- package/authMiddleware.ts +13 -5
- package/cli.ts +15 -9
- package/commands/auth.ts +13 -0
- package/commands/barsCommand.ts +83 -0
- package/dist/authMiddleware.d.ts +3 -0
- package/dist/authMiddleware.d.ts.map +1 -1
- package/dist/authMiddleware.js +7 -5
- package/dist/authMiddleware.js.map +1 -1
- package/dist/cli.js +11 -7
- package/dist/cli.js.map +1 -1
- package/dist/commands/auth.d.ts +3 -0
- package/dist/commands/auth.d.ts.map +1 -0
- package/dist/commands/auth.js +12 -0
- package/dist/commands/auth.js.map +1 -0
- package/dist/commands/barsCommand.d.ts +3 -0
- package/dist/commands/barsCommand.d.ts.map +1 -0
- package/dist/commands/barsCommand.js +59 -0
- package/dist/commands/barsCommand.js.map +1 -0
- package/dist/tradestation-client.d.ts +1 -1
- package/dist/tradestation-client.d.ts.map +1 -1
- package/package.json +6 -3
- package/tradestation-client.ts +1 -1
- package/tsconfig.json +42 -44
- /package/{client.d.ts → generated/tradestation-api.d.ts} +0 -0
package/.prettierrc
CHANGED
package/authMiddleware.ts
CHANGED
|
@@ -18,6 +18,8 @@ type AuthResponse = {
|
|
|
18
18
|
|
|
19
19
|
type AuthData = AuthResponse & {
|
|
20
20
|
timestamp: number // Unix timestamp in milliseconds when token was obtained
|
|
21
|
+
client_id: string
|
|
22
|
+
client_secret: string
|
|
21
23
|
}
|
|
22
24
|
|
|
23
25
|
const authFilePath = join(process.cwd(), 'tradestation-auth.json')
|
|
@@ -26,7 +28,7 @@ function generateRandomState(): string {
|
|
|
26
28
|
return randomBytes(32).toString('base64url')
|
|
27
29
|
}
|
|
28
30
|
|
|
29
|
-
async function tryLoadAuth(): Promise<AuthData | null> {
|
|
31
|
+
export async function tryLoadAuth(): Promise<AuthData | null> {
|
|
30
32
|
try {
|
|
31
33
|
const data = await readFile(authFilePath, 'utf-8')
|
|
32
34
|
return JSON.parse(data)
|
|
@@ -35,10 +37,16 @@ async function tryLoadAuth(): Promise<AuthData | null> {
|
|
|
35
37
|
}
|
|
36
38
|
}
|
|
37
39
|
|
|
38
|
-
async function saveAuth(
|
|
40
|
+
async function saveAuth(
|
|
41
|
+
authResponse: AuthResponse,
|
|
42
|
+
clientId: string,
|
|
43
|
+
clientSecret: string
|
|
44
|
+
): Promise<AuthData> {
|
|
39
45
|
const authData: AuthData = {
|
|
40
46
|
...authResponse,
|
|
41
47
|
timestamp: Date.now(),
|
|
48
|
+
client_id: clientId,
|
|
49
|
+
client_secret: clientSecret,
|
|
42
50
|
}
|
|
43
51
|
|
|
44
52
|
await writeFile(authFilePath, JSON.stringify(authData, null, 2), 'utf-8')
|
|
@@ -76,7 +84,7 @@ async function requestAccessToken(
|
|
|
76
84
|
if (!authRes.ok) {
|
|
77
85
|
throw new Error(`Failed to obtain access token: ${authResponse}`)
|
|
78
86
|
}
|
|
79
|
-
return saveAuth(authResponse)
|
|
87
|
+
return saveAuth(authResponse, clientId, clientSecret)
|
|
80
88
|
}
|
|
81
89
|
|
|
82
90
|
async function refreshAccessToken(
|
|
@@ -109,7 +117,7 @@ async function refreshAccessToken(
|
|
|
109
117
|
authResponse.refresh_token = refreshToken
|
|
110
118
|
}
|
|
111
119
|
|
|
112
|
-
return saveAuth(authResponse)
|
|
120
|
+
return saveAuth(authResponse, clientId, clientSecret)
|
|
113
121
|
}
|
|
114
122
|
|
|
115
123
|
async function authenticateWithOAuth2(
|
|
@@ -147,7 +155,7 @@ async function authenticateWithOAuth2(
|
|
|
147
155
|
})
|
|
148
156
|
})
|
|
149
157
|
|
|
150
|
-
await app.listen({ port: redirectPort })
|
|
158
|
+
await app.listen({ port: redirectPort, host: 'localhost' })
|
|
151
159
|
|
|
152
160
|
console.log('Opening browser for authentication...')
|
|
153
161
|
|
package/cli.ts
CHANGED
|
@@ -1,13 +1,19 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { program } from 'commander'
|
|
3
|
-
import {
|
|
2
|
+
import { program, Option, Command } from 'commander'
|
|
3
|
+
import { TradeStationClient } from 'tradestation-api-ts'
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
program.parse()
|
|
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'
|
|
10
9
|
|
|
11
|
-
|
|
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)
|
|
12
18
|
|
|
13
|
-
|
|
19
|
+
await program.parseAsync()
|
package/commands/auth.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
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
|
+
})
|
|
@@ -0,0 +1,83 @@
|
|
|
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.')
|
|
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(units[0]))
|
|
26
|
+
.option('--barsBack <barsBack>', 'Number of bars to retrieve', parseInt, 10)
|
|
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
|
+
.addOption(new Option('--clientId <clientId>', 'TradeStation Client ID'))
|
|
33
|
+
.addOption(new Option('--clientSecret <clientSecret>', 'TradeStation Client Secret'))
|
|
34
|
+
.addOption(new Option('--refreshToken <refreshToken>', 'TradeStation Refresh Token'))
|
|
35
|
+
.action(async function (
|
|
36
|
+
symbol: string,
|
|
37
|
+
options: {
|
|
38
|
+
interval: string
|
|
39
|
+
unit: BarUnit
|
|
40
|
+
barsBack: number
|
|
41
|
+
firstDate: string
|
|
42
|
+
lastDate: string
|
|
43
|
+
sessionTemplate: SessionTemplate
|
|
44
|
+
clientId?: string
|
|
45
|
+
clientSecret?: string
|
|
46
|
+
refreshToken?: string
|
|
47
|
+
}
|
|
48
|
+
) {
|
|
49
|
+
const environment = this.optsWithGlobals().environment as 'Live' | 'Simulation'
|
|
50
|
+
|
|
51
|
+
let client: TradeStationClient
|
|
52
|
+
|
|
53
|
+
if (options.clientId && options.clientSecret && options.refreshToken) {
|
|
54
|
+
client = new TradeStationClient({
|
|
55
|
+
clientId: options.clientId,
|
|
56
|
+
clientSecret: options.clientSecret,
|
|
57
|
+
refresh_token: options.refreshToken,
|
|
58
|
+
environment,
|
|
59
|
+
})
|
|
60
|
+
} else {
|
|
61
|
+
const authData = await authenticateOrFail()
|
|
62
|
+
client = new TradeStationClient({
|
|
63
|
+
clientId: authData.client_id,
|
|
64
|
+
clientSecret: authData.client_secret,
|
|
65
|
+
refresh_token: authData.refresh_token,
|
|
66
|
+
environment,
|
|
67
|
+
})
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
console.log(`Downloading market data for symbol: ${symbol}`)
|
|
71
|
+
|
|
72
|
+
const bars = await client.marketData.getBarHistory(symbol, {
|
|
73
|
+
interval: options.interval,
|
|
74
|
+
unit: options.unit,
|
|
75
|
+
firstdate: options.firstDate,
|
|
76
|
+
lastdate: options.lastDate,
|
|
77
|
+
barsback: options.barsBack,
|
|
78
|
+
sessiontemplate: options.sessionTemplate,
|
|
79
|
+
})
|
|
80
|
+
|
|
81
|
+
await fsp.writeFile(`${symbol}_bars.json`, JSON.stringify(bars.Bars, null, 2))
|
|
82
|
+
console.log(`Saved ${bars.Bars.length} bars to ${symbol}_bars.json`)
|
|
83
|
+
})
|
package/dist/authMiddleware.d.ts
CHANGED
|
@@ -9,7 +9,10 @@ type AuthResponse = {
|
|
|
9
9
|
};
|
|
10
10
|
type AuthData = AuthResponse & {
|
|
11
11
|
timestamp: number;
|
|
12
|
+
client_id: string;
|
|
13
|
+
client_secret: string;
|
|
12
14
|
};
|
|
15
|
+
export declare function tryLoadAuth(): Promise<AuthData | null>;
|
|
13
16
|
export declare function authenticate(clientId: string, clientSecret: string): Promise<AuthData>;
|
|
14
17
|
export declare function createAuthMiddleware(clientId: string, clientSecret: string): Middleware;
|
|
15
18
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"authMiddleware.d.ts","sourceRoot":"","sources":["../authMiddleware.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,eAAe,CAAA;AAM/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;
|
|
1
|
+
{"version":3,"file":"authMiddleware.d.ts","sourceRoot":"","sources":["../authMiddleware.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,eAAe,CAAA;AAM/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;AAgJD,wBAAsB,YAAY,CAChC,QAAQ,EAAE,MAAM,EAChB,YAAY,EAAE,MAAM,GACnB,OAAO,CAAC,QAAQ,CAAC,CAkBnB;AAED,wBAAgB,oBAAoB,CAClC,QAAQ,EAAE,MAAM,EAChB,YAAY,EAAE,MAAM,GACnB,UAAU,CAmCZ"}
|
package/dist/authMiddleware.js
CHANGED
|
@@ -8,7 +8,7 @@ const authFilePath = join(process.cwd(), 'tradestation-auth.json');
|
|
|
8
8
|
function generateRandomState() {
|
|
9
9
|
return randomBytes(32).toString('base64url');
|
|
10
10
|
}
|
|
11
|
-
async function tryLoadAuth() {
|
|
11
|
+
export async function tryLoadAuth() {
|
|
12
12
|
try {
|
|
13
13
|
const data = await readFile(authFilePath, 'utf-8');
|
|
14
14
|
return JSON.parse(data);
|
|
@@ -17,10 +17,12 @@ async function tryLoadAuth() {
|
|
|
17
17
|
return null;
|
|
18
18
|
}
|
|
19
19
|
}
|
|
20
|
-
async function saveAuth(authResponse) {
|
|
20
|
+
async function saveAuth(authResponse, clientId, clientSecret) {
|
|
21
21
|
const authData = {
|
|
22
22
|
...authResponse,
|
|
23
23
|
timestamp: Date.now(),
|
|
24
|
+
client_id: clientId,
|
|
25
|
+
client_secret: clientSecret,
|
|
24
26
|
};
|
|
25
27
|
await writeFile(authFilePath, JSON.stringify(authData, null, 2), 'utf-8');
|
|
26
28
|
return authData;
|
|
@@ -49,7 +51,7 @@ async function requestAccessToken(code, clientId, clientSecret) {
|
|
|
49
51
|
if (!authRes.ok) {
|
|
50
52
|
throw new Error(`Failed to obtain access token: ${authResponse}`);
|
|
51
53
|
}
|
|
52
|
-
return saveAuth(authResponse);
|
|
54
|
+
return saveAuth(authResponse, clientId, clientSecret);
|
|
53
55
|
}
|
|
54
56
|
async function refreshAccessToken(refreshToken, clientId, clientSecret) {
|
|
55
57
|
const authRes = await fetch('https://signin.tradestation.com/oauth/token', {
|
|
@@ -73,7 +75,7 @@ async function refreshAccessToken(refreshToken, clientId, clientSecret) {
|
|
|
73
75
|
if (!authResponse.refresh_token) {
|
|
74
76
|
authResponse.refresh_token = refreshToken;
|
|
75
77
|
}
|
|
76
|
-
return saveAuth(authResponse);
|
|
78
|
+
return saveAuth(authResponse, clientId, clientSecret);
|
|
77
79
|
}
|
|
78
80
|
async function authenticateWithOAuth2(clientId, clientSecret) {
|
|
79
81
|
const app = fastify();
|
|
@@ -97,7 +99,7 @@ async function authenticateWithOAuth2(clientId, clientSecret) {
|
|
|
97
99
|
return 'Authorization successful! You can close this tab.';
|
|
98
100
|
});
|
|
99
101
|
});
|
|
100
|
-
await app.listen({ port: redirectPort });
|
|
102
|
+
await app.listen({ port: redirectPort, host: 'localhost' });
|
|
101
103
|
console.log('Opening browser for authentication...');
|
|
102
104
|
await openAuthUrl(state, clientId);
|
|
103
105
|
return authPromise;
|
|
@@ -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,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAA;AACtD,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAEhC,OAAO,OAAO,MAAM,SAAS,CAAA;AAC7B,OAAO,IAAI,MAAM,MAAM,CAAA;AAEvB,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,aAAa,CAAA;
|
|
1
|
+
{"version":3,"file":"authMiddleware.js","sourceRoot":"","sources":["../authMiddleware.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAA;AACzC,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAA;AACtD,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAEhC,OAAO,OAAO,MAAM,SAAS,CAAA;AAC7B,OAAO,IAA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AC,CAAA;IACpE,CAAC;IAED,OAAO,sBAAsB,CAAC,QAAQ,EAAE,YAAY,CAAC,CAAA;AACvD,CAAC;AAED,MAAM,UAAU,oBAAoB,CAClC,QAAgB,EAChB,YAAoB;IAEpB,OAAO;QACL,KAAK,CAAC,SAAS,CAAC,EAAE,OAAO,EAAE;YACzB,MAAM,IAAI,GAAG,MAAM,YAAY,CAAC,QAAQ,EAAE,YAAY,CAAC,CAAA;YAEvD,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,eAAe,EAAE,UAAU,IAAI,CAAC,YAAY,EAAE,CAAC,CAAA;YACnE,OAAO,OAAO,CAAA;QAChB,CAAC;QACD,KAAK,CAAC,UAAU,CAAC,EAAE,QAAQ,EAAE,OAAO,EAAE;YACpC,IAAI,QAAQ,CAAC,MAAM,KAAK,GAAG,EAAE,CAAC;gBAC5B,OAAO,CAAC,IAAI,CACV,4CAA4C,OAAO,CAAC,GAAG,2CAA2C,CACnG,CAAA;gBAED,IAAI,IAAI,GAAG,MAAM,WAAW,EAAE,CAAA;gBAC9B,IAAI,CAAC,IAAI,EAAE,CAAC;oBACV,MAAM,IAAI,KAAK,CAAC,oDAAoD,CAAC,CAAA;gBACvE,CAAC;gBAED,IAAI,GAAG,MAAM,kBAAkB,CAC7B,IAAI,CAAC,aAAa,EAClB,QAAQ,EACR,YAAY,CACb,CAAA;gBAED,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"}
|
package/dist/cli.js
CHANGED
|
@@ -1,10 +1,14 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { program } from 'commander';
|
|
3
|
-
import {
|
|
2
|
+
import { program, Option, Command } from 'commander';
|
|
3
|
+
import { TradeStationClient } from 'tradestation-api-ts';
|
|
4
|
+
import { authenticate, tryLoadAuth } from './authMiddleware.js';
|
|
5
|
+
import { authCommand } from './commands/auth.js';
|
|
6
|
+
import { barsCommand } from './commands/barsCommand.js';
|
|
4
7
|
program
|
|
5
|
-
.
|
|
6
|
-
.
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
8
|
+
.addOption(new Option('--environment <environment>', 'TradeStation environment')
|
|
9
|
+
.choices(['Live', 'Simulation'])
|
|
10
|
+
.default('Simulation'))
|
|
11
|
+
.addCommand(authCommand, { isDefault: true })
|
|
12
|
+
.addCommand(barsCommand);
|
|
13
|
+
await program.parseAsync();
|
|
10
14
|
//# sourceMappingURL=cli.js.map
|
package/dist/cli.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../cli.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;
|
|
1
|
+
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../cli.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AACpD,OAAO,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAA;AAExD,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAA;AAE/D,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAA;AAChD,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAA;AAEvD,OAAO;KACJ,SAAS,CACR,IAAI,MAAM,CAAC,6BAA6B,EAAE,0BAA0B,CAAC;KAClE,OAAO,CAAC,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC;KAC/B,OAAO,CAAC,YAAY,CAAC,CACzB;KACA,UAAU,CAAC,WAAW,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC;KAC5C,UAAU,CAAC,WAAW,CAAC,CAAA;AAE1B,MAAM,OAAO,CAAC,UAAU,EAAE,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../../commands/auth.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAInC,eAAO,MAAM,WAAW,SAQpB,CAAA"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Command } from 'commander';
|
|
2
|
+
import { authenticate } from '../authMiddleware.js';
|
|
3
|
+
export const authCommand = new Command('auth')
|
|
4
|
+
.description('Authenticate with TradeStation API')
|
|
5
|
+
.requiredOption('--clientId <clientId>', 'TradeStation Client ID')
|
|
6
|
+
.requiredOption('--clientSecret <clientSecret>', 'TradeStation Client Secret')
|
|
7
|
+
.action(async (options) => {
|
|
8
|
+
console.log('Authenticating with TradeStation API...', options);
|
|
9
|
+
await authenticate(options.clientId, options.clientSecret);
|
|
10
|
+
console.log('Authentication successful!');
|
|
11
|
+
});
|
|
12
|
+
//# sourceMappingURL=auth.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth.js","sourceRoot":"","sources":["../../commands/auth.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAEnC,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAA;AAEnD,MAAM,CAAC,MAAM,WAAW,GAAG,IAAI,OAAO,CAAC,MAAM,CAAC;KAC3C,WAAW,CAAC,oCAAoC,CAAC;KACjD,cAAc,CAAC,uBAAuB,EAAE,wBAAwB,CAAC;KACjE,cAAc,CAAC,+BAA+B,EAAE,4BAA4B,CAAC;KAC7E,MAAM,CAAC,KAAK,EAAE,OAAmD,EAAE,EAAE;IACpE,OAAO,CAAC,GAAG,CAAC,yCAAyC,EAAE,OAAO,CAAC,CAAA;IAC/D,MAAM,YAAY,CAAC,OAAO,CAAC,QAAQ,EAAE,OAAO,CAAC,YAAY,CAAC,CAAA;IAC1D,OAAO,CAAC,GAAG,CAAC,4BAA4B,CAAC,CAAA;AAC3C,CAAC,CAAC,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"barsCommand.d.ts","sourceRoot":"","sources":["../../commands/barsCommand.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAU,MAAM,WAAW,CAAA;AAoB3C,eAAO,MAAM,WAAW,SA8DpB,CAAA"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { Command, Option } from 'commander';
|
|
2
|
+
import { TradeStationClient } from 'tradestation-api-ts';
|
|
3
|
+
import fsp from 'fs/promises';
|
|
4
|
+
import { tryLoadAuth } from '../authMiddleware.js';
|
|
5
|
+
const sessions = ['Default', 'USEQPre', 'USEQPost', 'USEQPreAndPost', 'USEQ24Hour'];
|
|
6
|
+
const units = ['Minute', 'Hour', 'Daily', 'Weekly', 'Monthly'];
|
|
7
|
+
async function authenticateOrFail() {
|
|
8
|
+
const authData = await tryLoadAuth();
|
|
9
|
+
if (!authData) {
|
|
10
|
+
console.error('No authentication data found. Please run the auth command first.');
|
|
11
|
+
process.exit(1);
|
|
12
|
+
}
|
|
13
|
+
return authData;
|
|
14
|
+
}
|
|
15
|
+
export const barsCommand = new Command('bars')
|
|
16
|
+
.description('Download market data bars from TradeStation API')
|
|
17
|
+
.argument('<symbol>', 'Market symbol to download data for')
|
|
18
|
+
.option('--interval <interval>', 'Bar interval (e.g., 1, 5, 1440, ...)', '1')
|
|
19
|
+
.addOption(new Option('--unit <unit>', 'Bar unit').choices(units).default(units[0]))
|
|
20
|
+
.option('--barsBack <barsBack>', 'Number of bars to retrieve', parseInt, 10)
|
|
21
|
+
.option('--firstDate <firstDate>', 'First date for bar data (YYYY-MM-DD)')
|
|
22
|
+
.option('--lastDate <lastDate>', 'Last date for bar data (YYYY-MM-DD)')
|
|
23
|
+
.addOption(new Option('--sessionTemplate <sessionTemplate>', 'Session template to use.').choices(sessions).default(sessions[0]))
|
|
24
|
+
.addOption(new Option('--clientId <clientId>', 'TradeStation Client ID'))
|
|
25
|
+
.addOption(new Option('--clientSecret <clientSecret>', 'TradeStation Client Secret'))
|
|
26
|
+
.addOption(new Option('--refreshToken <refreshToken>', 'TradeStation Refresh Token'))
|
|
27
|
+
.action(async function (symbol, options) {
|
|
28
|
+
const environment = this.optsWithGlobals().environment;
|
|
29
|
+
let client;
|
|
30
|
+
if (options.clientId && options.clientSecret && options.refreshToken) {
|
|
31
|
+
client = new TradeStationClient({
|
|
32
|
+
clientId: options.clientId,
|
|
33
|
+
clientSecret: options.clientSecret,
|
|
34
|
+
refresh_token: options.refreshToken,
|
|
35
|
+
environment,
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
else {
|
|
39
|
+
const authData = await authenticateOrFail();
|
|
40
|
+
client = new TradeStationClient({
|
|
41
|
+
clientId: authData.client_id,
|
|
42
|
+
clientSecret: authData.client_secret,
|
|
43
|
+
refresh_token: authData.refresh_token,
|
|
44
|
+
environment,
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
console.log(`Downloading market data for symbol: ${symbol}`);
|
|
48
|
+
const bars = await client.marketData.getBarHistory(symbol, {
|
|
49
|
+
interval: options.interval,
|
|
50
|
+
unit: options.unit,
|
|
51
|
+
firstdate: options.firstDate,
|
|
52
|
+
lastdate: options.lastDate,
|
|
53
|
+
barsback: options.barsBack,
|
|
54
|
+
sessiontemplate: options.sessionTemplate,
|
|
55
|
+
});
|
|
56
|
+
await fsp.writeFile(`${symbol}_bars.json`, JSON.stringify(bars.Bars, null, 2));
|
|
57
|
+
console.log(`Saved ${bars.Bars.length} bars to ${symbol}_bars.json`);
|
|
58
|
+
});
|
|
59
|
+
//# sourceMappingURL=barsCommand.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"barsCommand.js","sourceRoot":"","sources":["../../commands/barsCommand.ts"],"names":[],"mappings":"AA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O,CAAC,SAAS;QAC5B,QAAQ,EAAE,OAAO,CAAC,QAAQ;QAC1B,QAAQ,EAAE,OAAO,CAAC,QAAQ;QAC1B,eAAe,EAAE,OAAO,CAAC,eAAe;KACzC,CAAC,CAAA;IAEF,MAAM,GAAG,CAAC,SAAS,CAAC,GAAG,MAAM,YAAY,EAAE,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAA;IAC9E,OAAO,CAAC,GAAG,CAAC,SAAS,IAAI,CAAC,IAAI,CAAC,MAAM,YAAY,MAAM,YAAY,CAAC,CAAA;AACtE,CAAC,CAAC,CAAA"}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import type { paths } from './
|
|
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
3
|
//# sourceMappingURL=tradestation-client.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tradestation-client.d.ts","sourceRoot":"","sources":["../tradestation-client.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,
|
|
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"}
|
package/package.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tradestation-client",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.15",
|
|
4
4
|
"description": "A Node.js client for the TradeStation API with OAuth2 authentication and OpenAPI integration.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": "./dist/cli.js",
|
|
7
7
|
"scripts": {
|
|
8
8
|
"test:ts": "tsc --noEmit",
|
|
9
9
|
"download-openapi": "node ./downloadOpenAPI.ts",
|
|
10
|
-
"generate-client": "openapi-typescript ./openapi.json --output
|
|
10
|
+
"generate-client": "openapi-typescript ./openapi.json --output generated/tradestation-api.d.ts",
|
|
11
11
|
"build": "npm run download-openapi && npm run generate-client && tsc",
|
|
12
12
|
"prepublishOnly": "npm run build"
|
|
13
13
|
},
|
|
@@ -16,8 +16,11 @@
|
|
|
16
16
|
"dependencies": {
|
|
17
17
|
"commander": "^14.0.2",
|
|
18
18
|
"fastify": "^5.6.2",
|
|
19
|
+
"install": "^0.13.0",
|
|
20
|
+
"npm": "^11.7.0",
|
|
19
21
|
"open": "^11.0.0",
|
|
20
|
-
"openapi-fetch": "^0.15.0"
|
|
22
|
+
"openapi-fetch": "^0.15.0",
|
|
23
|
+
"tradestation-api-ts": "^1.2.1"
|
|
21
24
|
},
|
|
22
25
|
"devDependencies": {
|
|
23
26
|
"@types/node": "^25.0.3",
|
package/tradestation-client.ts
CHANGED
package/tsconfig.json
CHANGED
|
@@ -1,44 +1,42 @@
|
|
|
1
|
-
{
|
|
2
|
-
// Visit https://aka.ms/tsconfig to read more about this file
|
|
3
|
-
"compilerOptions": {
|
|
4
|
-
// File Layout
|
|
5
|
-
"rootDir": ".",
|
|
6
|
-
"outDir": "./dist",
|
|
7
|
-
|
|
8
|
-
// Environment Settings
|
|
9
|
-
// See also https://aka.ms/tsconfig/module
|
|
10
|
-
"module": "nodenext",
|
|
11
|
-
"target": "esnext",
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
//
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
"
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
//
|
|
28
|
-
// "
|
|
29
|
-
// "
|
|
30
|
-
// "
|
|
31
|
-
// "
|
|
32
|
-
|
|
33
|
-
//
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
"
|
|
37
|
-
"
|
|
38
|
-
"
|
|
39
|
-
"
|
|
40
|
-
"
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
}
|
|
44
|
-
}
|
|
1
|
+
{
|
|
2
|
+
// Visit https://aka.ms/tsconfig to read more about this file
|
|
3
|
+
"compilerOptions": {
|
|
4
|
+
// File Layout
|
|
5
|
+
"rootDir": ".",
|
|
6
|
+
"outDir": "./dist",
|
|
7
|
+
|
|
8
|
+
// Environment Settings
|
|
9
|
+
// See also https://aka.ms/tsconfig/module
|
|
10
|
+
"module": "nodenext",
|
|
11
|
+
"target": "esnext",
|
|
12
|
+
// For nodejs:
|
|
13
|
+
"lib": ["esnext"],
|
|
14
|
+
"types": ["node"],
|
|
15
|
+
|
|
16
|
+
// Other Outputs
|
|
17
|
+
"sourceMap": true,
|
|
18
|
+
"declaration": true,
|
|
19
|
+
"declarationMap": true,
|
|
20
|
+
|
|
21
|
+
// Stricter Typechecking Options
|
|
22
|
+
"noUncheckedIndexedAccess": true,
|
|
23
|
+
"exactOptionalPropertyTypes": true,
|
|
24
|
+
|
|
25
|
+
// Style Options
|
|
26
|
+
// "noImplicitReturns": true,
|
|
27
|
+
// "noImplicitOverride": true,
|
|
28
|
+
// "noUnusedLocals": true,
|
|
29
|
+
// "noUnusedParameters": true,
|
|
30
|
+
// "noFallthroughCasesInSwitch": true,
|
|
31
|
+
// "noPropertyAccessFromIndexSignature": true,
|
|
32
|
+
|
|
33
|
+
// Recommended Options
|
|
34
|
+
"strict": true,
|
|
35
|
+
"jsx": "react-jsx",
|
|
36
|
+
"verbatimModuleSyntax": true,
|
|
37
|
+
"isolatedModules": true,
|
|
38
|
+
"noUncheckedSideEffectImports": true,
|
|
39
|
+
"moduleDetection": "force",
|
|
40
|
+
"skipLibCheck": true
|
|
41
|
+
}
|
|
42
|
+
}
|
|
File without changes
|