tradestation-client 1.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/.env.example +2 -0
- package/.prettierrc +4 -0
- package/authMiddleware.ts +235 -0
- package/cli.ts +13 -0
- package/client.d.ts +8115 -0
- package/config.ts +2 -0
- package/downloadOpenAPI.ts +31 -0
- package/openapi.json +12928 -0
- package/package.json +26 -0
- package/spike.ts +30 -0
- package/tradestation-client.ts +15 -0
- package/tsconfig.json +8 -0
package/package.json
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "tradestation-client",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "A Node.js client for the TradeStation API with OAuth2 authentication and OpenAPI integration.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"bin": "cli.ts",
|
|
7
|
+
"scripts": {
|
|
8
|
+
"test:ts": "tsc --noEmit",
|
|
9
|
+
"download-openapi": "node ./downloadOpenAPI.ts",
|
|
10
|
+
"generate-client": "openapi-typescript ./openapi.json --output client.d.ts"
|
|
11
|
+
},
|
|
12
|
+
"keywords": [],
|
|
13
|
+
"author": "",
|
|
14
|
+
"dependencies": {
|
|
15
|
+
"commander": "^14.0.2",
|
|
16
|
+
"fastify": "^5.6.2",
|
|
17
|
+
"open": "^11.0.0",
|
|
18
|
+
"openapi-fetch": "^0.15.0"
|
|
19
|
+
},
|
|
20
|
+
"devDependencies": {
|
|
21
|
+
"@types/node": "^25.0.3",
|
|
22
|
+
"openapi-typescript": "^7.10.1",
|
|
23
|
+
"playwright-core": "^1.57.0",
|
|
24
|
+
"typescript": "^5.9.3"
|
|
25
|
+
}
|
|
26
|
+
}
|
package/spike.ts
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import process from 'node:process'
|
|
2
|
+
|
|
3
|
+
process.loadEnvFile()
|
|
4
|
+
|
|
5
|
+
import { createTradeStationClient } from './tradestation-client.ts'
|
|
6
|
+
|
|
7
|
+
const tradestationClient = createTradeStationClient(
|
|
8
|
+
process.env.CLIENT_ID!,
|
|
9
|
+
process.env.CLIENT_SECRET!
|
|
10
|
+
)
|
|
11
|
+
|
|
12
|
+
const { data } = await tradestationClient.GET(
|
|
13
|
+
'/v3/marketdata/stream/barcharts/{symbol}',
|
|
14
|
+
{
|
|
15
|
+
params: {
|
|
16
|
+
path: { symbol: 'SPY' },
|
|
17
|
+
query: {
|
|
18
|
+
interval: '1',
|
|
19
|
+
unit: 'minute',
|
|
20
|
+
barsback: '2',
|
|
21
|
+
sessiontemplate: 'USEQ24Hour',
|
|
22
|
+
},
|
|
23
|
+
},
|
|
24
|
+
parseAs: 'stream',
|
|
25
|
+
}
|
|
26
|
+
)
|
|
27
|
+
|
|
28
|
+
for await (const chunk of data) {
|
|
29
|
+
console.log(new TextDecoder().decode(chunk))
|
|
30
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import createClient from 'openapi-fetch'
|
|
2
|
+
|
|
3
|
+
import type { paths } from './client.d.ts'
|
|
4
|
+
import { createAuthMiddleware } from './authMiddleware.ts'
|
|
5
|
+
|
|
6
|
+
export function createTradeStationClient(
|
|
7
|
+
clientId: string,
|
|
8
|
+
clientSecret: string
|
|
9
|
+
) {
|
|
10
|
+
const client = createClient<paths>({
|
|
11
|
+
baseUrl: 'https://api.tradestation.com',
|
|
12
|
+
})
|
|
13
|
+
client.use(createAuthMiddleware(clientId, clientSecret))
|
|
14
|
+
return client
|
|
15
|
+
}
|