Latest Threat ResearchGlassWorm Loader Hits Open VSX via Developer Account Compromise.Details
Socket
Book a DemoInstallSign in
Socket

tda-wsjson-client

Package Overview
Dependencies
Maintainers
1
Versions
29
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

tda-wsjson-client

WebSocket client for the TD Ameritrade wsjson API

latest
npmnpm
Version
0.10.2
Version published
Weekly downloads
34
161.54%
Maintainers
1
Weekly downloads
 
Created
Source

TD Ameritrade WsJson API client

This is a node and browser API client for the (undocumented) TD Ameritrade WebSocket API.

🚧 Work in progress 🚧

Prerequisites

  • Node 16+

Create a .env file and set your TD Ameritrade oauth access token:

CLIENT_ID=your-client-id
ACCESS_TOKEN=your-access-token
REFRESH_TOKEN=your-refresh-token
TOKEN_EXPIRES_AT=your-token-expires-at

Building for Node

yarn install
yarn build

Running the example app

cd example
yarn install
yarn link tda-wsjson-client
yarn start

Supported APIs

  • ✅ Authentication via access token
  • ✅ Quotes
  • ✅ Price History (chart)
  • ✅ Account positions
  • ✅ Place & submit order
  • ✅ Cancel order
  • ✅ User properties
  • ✅ Create alert
  • ✅ Cancel alert
  • ✅ Instrument search
  • ✅ Option chains
  • ✅ Alert lookup
  • ✅ Option chain details
  • ✅ Option chain quotes
  • ✅ Option quotes
  • ✅ Order events
  • ✅ Market depth
  • ✅ Get watchlist

Not yet implemented

  • ❌ Instrument order events
  • ❌ Alert subscription
  • ❌ And many more 😀

Usage

import WsJsonClient from "tda-wsjson-client/wsJsonClient";

const client = new WsJsonClient();
await client.authenticate(accessToken);
console.log(loginResponse);
const chartRequest = {
  symbol: "UBER",
  timeAggregation: "DAY",
  range: "YEAR2",
  includeExtendedHours: true,
};
for await (const event of client.chart(chartRequest)) {
  console.log(event);
}

For more sample usage check out https://github.com/felipecsl/tda-wsjson-client/blob/master/src/testApp.ts and https://github.com/felipecsl/tda-wsjson-client/blob/master/example/src/App.tsx

Running tests

yarn test

License

MIT

FAQs

Package last updated on 12 Dec 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts