What is JT-Trader?
JT-Trader is an open-source platform designed to automate cryptocurrency trading. At its core lies JT-Lib, a library that powers the development, testing, and deployment of trading strategies on real exchanges.
In practice, JT-Trader is a full-featured tool for algorithmic trading:
Developers can build their own strategies in TypeScript.
Traders can use ready-made bots via a user-friendly web interface.
The built-in strategy tester allows you to check whether your algorithm is viable before going live.
How Trading Bots Are Created
Bot development in JT-Trader revolves around the Script class, which extends BaseScript. This class defines all the key lifecycle methods: initialization, data processing, order management, and shutdown.
Bot parameters are defined in static definedArgs. These may include:
position size;
stop-loss and take-profit levels;
indicator periods;
trading pairs, etc.
This approach makes it possible to adjust settings directly from the interface without rewriting code.
Before running a bot in real trading, every strategy can (and should) be backtested — a crucial step for finding effective parameters and avoiding costly mistakes.
Bot Lifecycle
Every trading script in JT-Trader follows a clear lifecycle:
onInit() — load parameters, connect indicators, initialize orders.
onTick() — process live market data and make decisions.
onOrderChange() — react to order executions and status changes.
onStop() — safely shut down and release resources.
Example: A Simple RSI Strategy
Below is a code snippet showing a trading bot based on the RSI indicator, with automatic stop-loss and take-profit handling:
class Script extends BaseScript {
static definedArgs = [ // User-defined strategy parameters
{ key: 'symbols', defaultValue: 'BTC/USDT:USDT' }, // Trading pair
{ key: 'sizeUsd', defaultValue: 100 }, // Position size in USD
{ key: 'slPercent', defaultValue: 2 }, // Stop-loss percentage
{ key: 'tpPercent', defaultValue: 4 } // Take-profit percentage
];
private basket: OrdersBasket; // Order manager
private rsi: RelativeStrengthIndex; // RSI indicator
private sizeUsd: number;
private slPercent: number;
private tpPercent: number;
async onInit() { // Initialization at startup
this.sizeUsd = getArgNumber('sizeUsd', 100); // Load parameters
this.slPercent = getArgNumber('slPercent', 2);
this.tpPercent = getArgNumber('tpPercent', 4);
this.basket = new OrdersBasket({ // Create order manager
symbol: this.symbols[0],
connectionName: this.connectionName
});
await this.basket.init();
this.rsi = await globals.indicators.rsi(this.symbols[0], '1h', 14); // Initialize RSI
}
private async signal(): Promise<number> { // Trading signal logic
const longPosition = await this.basket.getPositionBySide('long');
if (longPosition.contracts !== 0) return 0; // If there’s already a position – don’t trade
const rsiValue = this.rsi.getValue();
if (rsiValue < 30) return 1; // RSI < 30 → buy signal
if (rsiValue > 70) return -1; // RSI > 70 → sell signal
return 0; // No signal
}
async onTick() { // Called on each price tick
const currentPrice = close(); // Current closing price
const signalValue = await this.signal();
if (signalValue === 1) { // Buy signal
const contracts = this.basket.getContractsAmount(this.sizeUsd, currentPrice); // Convert USD to contracts
const stopLoss = currentPrice * (1 - this.slPercent / 100); // Stop-loss price
const takeProfit = currentPrice * (1 + this.tpPercent / 100); // Take-profit price
await this.basket.buyMarket(contracts, takeProfit, stopLoss); // Buy with automatic stops
}
if (signalValue === -1) { // Sell signal
const longPosition = await this.basket.getPositionBySide('long');
if (longPosition.contracts > 0) { // If there’s an open long position
const contracts = longPosition.contracts;
const stopLoss = currentPrice * (1 + this.slPercent / 100); // Stop-loss for short
const takeProfit = currentPrice * (1 - this.tpPercent / 100); // Take-profit for short
await this.basket.sellMarket(contracts, takeProfit, stopLoss); // Sell with automatic stops
}
}
}
async onOrderChange(order: Order) { // Handle order status changes
if (order.status === 'closed') { // If the order has been executed
log('Script', 'Order executed', { orderId: order.id, side: order.side }, true); // Log the event
}
}
async onStop() { // Cleanup on shutdown
await this.basket.cancelAllOrders(); // Cancel all active orders
}
}
Strategy Testing
One of JT-Trader’s biggest strengths is its built-in strategy tester. It allows you to simulate trading strategies on historical data while accounting for commissions, spreads, and slippage.
You can configure:
the testing period,
initial balance,
trading pairs,
timeframes.
The tester outputs:
equity curve charts,
maximum drawdown,
Sharpe ratio,
trade statistics.
A standout feature is parameter optimization — JT-Trader can iterate through thousands of parameter combinations to find the most profitable ones.
Running Bots in Real Time
For live trading, JT-Trader uses the Runtime section of the web interface. Users simply select a strategy file, exchange connection, and trading pairs.
Once launched, the bot streams data via WebSocket, processes every tick, and places orders based on the strategy’s logic.
Key features include:
adjusting parameters on the fly (without restarting),
detailed statistics available in the interface,
utomatic recovery after errors or crashes.
Monitoring and Debugging
JT-Trader comes with a comprehensive logging and reporting system:
all bot actions are logged,
logs can be filtered by type and severity,
Telegram alerts are available for critical issues or trade events.
For developers, there’s also a real-time debug system to inspect indicators, positions, and variables directly while the bot is running. This makes debugging and optimization much more efficient.
Conclusion
JT-Trader is a flexible and open platform for algorithmic crypto trading that combines:
a straightforward strategy development process,
built-in backtesting,
safe 24/7 execution of trading bots,
advanced monitoring and debugging tools.
It’s equally valuable for seasoned algo-traders and beginners taking their first steps in trading automation.
Top comments (0)