tickerterm
v1.0.2
Published
Node.js library for TickerBot trading and market data
Maintainers
Readme
TickerTerm Node.js Library
⚠️ Breaking Changes (2025-10-25):
ticker.history()renamed toticker.bars()andticker.quote()removed. See CHANGELOG.md
A Node.js library that provides programmatic access to TickerBot's trading and market data APIs. This library mirrors the same API available in the TickerBot web platform for server-side applications.
Installation
npm install tickertermAuthentication
This library requires authentication via the TickerTerm CLI. You must install and authenticate with the CLI before using this library.
1. Install TickerTerm CLI
# Installation via npm (when published)
npm install -g tickerterm-cli
# Or install locally in your project
git clone <tickerterm-cli-repo>
cd cli && npm install && npm link2. Authenticate
# Login with email/password (production)
tickerterm login --email
# Login with Google OAuth (production)
tickerterm login --google
# For TickerTerm employees (staging)
tickerterm login --email --staging
tickerterm login --google --staging3. Verify Authentication
tickerterm whoamiQuick Start
import { tt, portfolio, ticker, utils, TA } from 'tickerterm';
async function example() {
try {
// Get portfolio balances
const balances = portfolio.balances();
console.log('Portfolio equity:', balances.equity);
// Get ticker price
const price = await ticker.price('AAPL');
console.log('AAPL price:', price);
// Place an order
await portfolio.order('AAPL', 'buy', 'market', { qty: 10 });
// Log something to TickerBot
await tt.log('Order placed successfully');
} catch (error) {
if (error.message.includes('Authentication required')) {
console.error('Please run "tickerterm login" first');
} else {
console.error('Error:', error.message);
}
}
}
example();API Reference
TT Module
import { tt } from 'tickerterm';
// Logging and notifications
await tt.log(message);
await tt.send_email(to, subject, body);
await tt.create_toast(message, color?);
// State management
await tt.set_state(name, value);
const value = await tt.get_state(name);
await tt.delete_state(name);
// Watchlists
await tt.set_watchlist(name, tickers);
const tickers = await tt.get_watchlist(name);
await tt.delete_watchlist(name);
// AI queries
const result = await tt.ai(returnType, prompt, data?, model?);Portfolio Module
import { portfolio } from 'tickerterm';
// Portfolio data
const balances = portfolio.balances();
const positions = await portfolio.get_positions();
const position = await portfolio.get_position('AAPL');
// Orders and trades
await portfolio.order('AAPL', 'buy', 'market', { qty: 10 });
await portfolio.close_position('AAPL');
await portfolio.cancel_all_orders();
// Account history
const orders = await portfolio.get_orders();
const transactions = await portfolio.get_transactions();Ticker Module
import { ticker } from 'tickerterm';
// Market data
const snapshot = await ticker.get('AAPL');
const price = await ticker.price('AAPL');
const bars = await ticker.bars('AAPL', '1d', { start: new Date('2024-01-01') });
// Fundamentals
const financials = await ticker.financials('AAPL');
const dividends = await ticker.dividends('AAPL');
// Chart annotations
await ticker.create_trendline('AAPL', 'support', {
price0: 150, price1: 160,
date0: '2024-01-01', date1: '2024-01-10'
});Utils Module
import { utils } from 'tickerterm';
// Market timing
const isOpen = utils.is_market_open();
const minutesUntilClose = utils.get_minutes_until_close();
const lastMarketDay = utils.get_last_market_day();Technical Analysis Module
import { TA } from 'tickerterm';
// Moving averages
const sma = TA.SMA.calculate({ values: prices, period: 20 });
const ema = TA.EMA.calculate({ values: prices, period: 20 });
// Oscillators
const rsi = TA.RSI.calculate({ values: prices, period: 14 });
const macd = TA.MACD.calculate({
values: prices,
fastPeriod: 12,
slowPeriod: 26,
signalPeriod: 9
});
// Volume indicators
const obv = TA.OBV.calculate({ close: prices, volume: volumes });Error Handling
All functions will throw errors if:
- You're not authenticated via the CLI
- Your authentication token has expired
- API requests fail
try {
const price = await ticker.price('AAPL');
} catch (error) {
if (error.message.includes('Authentication required')) {
console.error('Please run "tickerterm login" first');
} else if (error.message.includes('token has expired')) {
console.error('Please run "tickerterm login" to re-authenticate');
} else {
console.error('API error:', error.message);
}
}Development Status
🚧 This library is currently in development
All functions are implemented as boilerplate and will throw "Not yet implemented" errors. The authentication system is fully functional and will ensure you're properly logged in via the CLI.
Environment Support
- Production: Default environment for all users
- Staging: Available only for @tickerterm.com and @tickerbot.io email addresses
The library automatically uses the same environment you authenticated with via the CLI.
Requirements
- Node.js >= 14.0.0
- TickerTerm CLI installed and authenticated
License
MIT
