npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

@kofeinstyle/tradernet-sdk

v0.0.1-beta.8

Published

Tradernet API typescript client

Readme

Tradernet SDK

A comprehensive TypeScript/JavaScript client library for the Tradernet trading platform API.

Publish Package to npmjs npm version

Docs - https://tradernet.ua/tradernet-api

Features

  • 💼 Report Data - Data array on trades for the requested report period
  • 📝 User Cash flow - Obtaining data on the client's cash flow
  • 📊 Market Data - Real-time and historical market data (🔮 Coming Soon)
  • 💼 Portfolio - Portfolio and position tracking (🔮 Coming Soon)
  • 🔌 WebSocket - Real-time data streaming with auto-reconnection (🔮 Coming Soon)
  • 📝 TypeScript - Full TypeScript support with comprehensive types
  • 🧪 Tested - Comprehensive test suite with Jest
  • 🔄 Retry Logic - Automatic retry with exponential backoff
  • 📦 Lightweight - Zero external dependencies

Installation

npm install @kofeinstyle/tradernet-sdk

Quick Start

import { TradernetApiClient } from '@kofeinstyle/tradernet-sdk';

// Initialize client
const client = new TradernetApiClient({
  apiKey: 'testApiKey',
  apiSecret: 'testApiSecret',
});
  • Get report data

const result = await client.getBrokerReport({dateFrom: '2025-01-01', dateTo: '2025-21-31'});
console.log('Report data:', result.data);
  • Get user cash flow data

const filter = [{ field: 'type_code', operator: 'eq', value: 'dividend'}]
const result = await client.getUserCashFlows({take: 100, skip: 0, filter: filter});
console.log('Cashflow data:', result.data.cashflow);

API Methods

Reports

  • getBrokerReport(dateRange, attempt) - Getting the broker's report by date range
  • getUserCashFlows(params) - Getting the user's cash flow by filter. (Like tax, dividend, etc)

Market Data (🚧 Planned for Future Versions)

  • getTicker(symbol) - Get ticker data for a symbol
  • getTickers(symbols) - Get ticker data for multiple symbols
  • getQuote(symbol) - Get bid/ask quote data
  • getCandles(symbol, interval, limit) - Get historical candle data

Portfolio (🚧 Planned for Future Versions)

  • getPortfolio() - Get portfolio summary
  • getPositions() - Get all positions
  • getPosition(symbol) - Get position for a symbol
  • getAccountInfo() - Get account information
  • getBalance() - Get account balance

WebSocket (🚧 Planned for Future Versions)

  • connectWebSocket() - Connect to real-time data stream
  • disconnectWebSocket() - Disconnect from WebSocket
  • subscribeToTickers(symbols) - Subscribe to ticker updates
  • subscribeToQuotes(symbols) - Subscribe to quote updates
  • subscribeToOrders() - Subscribe to order updates
  • subscribeToPortfolio() - Subscribe to portfolio updates
  • unsubscribe(channels, symbols) - Unsubscribe from channels

Error Handling

All API methods return an ApiResponse object with success/error information:

const result = await client.getBrokerTrades({dateFrom: '2021-01-01', dateTo: '2021-21-31'});
if (result.success) {
  console.log('Report data:', result.data);
} else {
  console.error('Error:', result.error);
}

Configuration

TradernetConfig

  • baseUrl - API base URL (default: 'https://tradernet.com/api')
  • timeout - Request timeout in milliseconds (default: 30000)
  • retries - Number of retry attempts (default: 3)

Events (🚧 Planned for Future Versions)

The client emits the following events:

  • ticker - Real-time ticker updates
  • quote - Real-time quote updates
  • order - Order status updates
  • portfolio - Portfolio updates
  • ws_connected - WebSocket connected
  • ws_disconnected - WebSocket disconnected
  • ws_authenticated - WebSocket authenticated
  • error - Error events

WebSocketConfig (🚧 Planned for Future Versions)

  • url - WebSocket URL (default: 'wss://ws.tradernet.com')
  • reconnectInterval - Reconnection interval in ms (default: 5000)
  • maxReconnectAttempts - Max reconnection attempts (default: 10)
  • pingInterval - Ping interval in ms (default: 30000)

Development

# Install dependencies
npm install

# Run tests
npm test

# Run tests in watch mode
npm run test:watch

# Run tests with coverage
npm run test:coverage

# Build TypeScript
npm run build

# Build in watch mode
npm run build:watch

Contributing

  1. Fork the repository
  2. Create your feature branch
  3. Commit your changes
  4. Push to the branch
  5. Open a Pull Request

License

This project is licensed under the MIT License.

Support

For support, please open an issue on GitHub or contact the maintainers.


Note: This SDK is designed to work with the Tradernet trading platform. Make sure you have valid API credentials and understand the risks involved in automated trading.