interface SubmitOrderCommand {
symbol: string; // Trading symbol (e.g., 'ETH')
side: 'buy' | 'sell'; // Order side
orderType: 'market' | 'limit' | 'stop' | 'stop_limit';
size?: number; // Order size
price?: number; // Limit price (required for limit orders)
stopPrice?: number; // Stop price (required for stop orders)
reduceOnly?: boolean; // Reduce-only flag
postOnly?: boolean; // Post-only flag
tpsl?: { // Take profit / Stop loss
tpPrice?: number | null; // Take profit price
tpGainPercent?: number | null; // TP as percentage gain
slPrice?: number | null; // Stop loss price
slLossPercent?: number | null; // SL as percentage loss
};
tif?: 'Gtc' | 'Ioc' | 'Alo'; // Time in force
}
// Market order
const response = await client.placeOrder({
symbol: 'ETH',
side: 'buy',
orderType: 'market',
size: 0.1
});
// Limit order with TP/SL
const response = await client.placeOrder({
symbol: 'ETH',
side: 'buy',
orderType: 'limit',
price: 2500,
size: 0.1,
tpsl: {
tpPrice: 3000, // Take profit at $3000
slPrice: 2400 // Stop loss at $2400
}
});
// Get all positions
const positions = await client.getPositions();
// Get positions for specific symbol
const ethPositions = await client.getPositions('ETH');
if (positions.success && positions.data) {
positions.data.positions.forEach(pos => {
console.log(`${pos.symbol}: ${pos.size} units, PnL: $${pos.unrealizedPnl}`);
});
}