@chirag1702/algox-delta-exchange-plugin
v1.0.0
Published
Delta Exchange India broker plugin for AlgoX Trading Framework
Maintainers
Readme
AlgoX Delta Exchange India Broker Plugin
A broker plugin for Delta Exchange India that integrates with the AlgoX Trading Framework, enabling algorithmic trading strategies to connect and trade on the Delta Exchange platform.
Features
- REST API Integration: Full support for order management, positions, and account information
- WebSocket Streaming: Real-time market data (tickers, candles, orderbook)
- Option Chain Support: Snapshot + live option chain updates via
optionChainevents - Options Trading: Place/modify/cancel option orders using option
tradingSymbol - Private Channels: Order and position updates via authenticated WebSocket
- Automatic Reconnection: Built-in reconnection logic with exponential backoff
- TypeScript Support: Full TypeScript definitions included
Installation
npm install @chirag1702/algox @chirag1702/algox-delta-exchange-pluginThe plugin expects @chirag1702/algox to be installed alongside it as a peer dependency.
Quick Start
import { DeltaExchangePlugin, BrokerCredentials } from '@chirag1702/algox-delta-exchange-plugin';
// Create plugin instance
const deltaPlugin = new DeltaExchangePlugin({
testnet: true, // Use testnet for testing
debug: true // Enable debug logging
});
// Connect with credentials
await deltaPlugin.connect({
apiKey: 'your-api-key',
apiSecret: 'your-api-secret'
});
// Subscribe to market data
await deltaPlugin.subscribeTicks([{
symbol: 'BTCUSD',
exchange: 'DELTA',
instrumentType: 'CRYPTO',
tradingSymbol: 'BTCUSD',
lotSize: 1,
tickSize: 0.5
}]);
// Listen for ticks
deltaPlugin.on('tick', (tick) => {
console.log('Tick received:', tick.ltp);
});
// Place an order
const orderResponse = await deltaPlugin.placeOrder({
instrument: {
symbol: 'BTCUSD',
exchange: 'DELTA',
instrumentType: 'CRYPTO',
tradingSymbol: 'BTCUSD',
lotSize: 1,
tickSize: 0.5
},
orderType: 'LIMIT',
transactionType: 'BUY',
quantity: 10,
price: 50000,
productType: 'MARGIN',
validity: 'GTC'
});
console.log('Order placed:', orderResponse);Configuration
DeltaConfig
| Parameter | Type | Default | Description |
|-----------|------|---------|-------------|
| testnet | boolean | false | Use testnet environment |
| apiKey | string | '' | API key for authentication |
| apiSecret | string | '' | API secret for signature generation |
| timeout | number | 10000 | Request timeout in milliseconds |
| debug | boolean | false | Enable debug logging |
BrokerCredentials
interface BrokerCredentials {
apiKey: string;
apiSecret: string;
// Optional:
clientId?: string;
userId?: string;
}API Reference
Connection Management
connect(credentials: BrokerCredentials): Promise
Connects to Delta Exchange API using the provided credentials.
disconnect(): Promise
Disconnects from Delta Exchange API and cleans up resources.
isConnected(): boolean
Returns true if currently connected.
Data Subscriptions
subscribeTicks(instruments: Instrument[]): Promise
Subscribe to real-time tick data for specified instruments.
subscribeCandles(instruments: Instrument[], timeframes: Timeframe[]): Promise
Subscribe to candlestick data for specified instruments and timeframes.
subscribeOptionChain(symbol: string): Promise
Subscribe to option chain updates.
Input formats:
UNDERLYING|DD-MM-YYYY(recommended)UNDERLYING(nearest live/upcoming expiry auto-selected)
unsubscribe(instruments: Instrument[]): Promise
Unsubscribe from data for specified instruments.
Order Management
placeOrder(order: OrderRequest): Promise
Place a new order.
modifyOrder(orderId: string, modifications: OrderModification): Promise
Modify an existing order.
cancelOrder(orderId: string): Promise
Cancel an order.
getOrderStatus(orderId: string): Promise
Get current order status.
getOrders(): Promise<Order[]>
Get all open orders.
Position Management
getPositions(): Promise<Position[]>
Get all open positions.
getPosition(instrument: Instrument): Promise<Position | null>
Get position for a specific instrument.
Account Information
getAccountInfo(): Promise
Get account information including balances.
getMargins(): Promise
Get margin details.
Historical Data
getHistoricalCandles(instrument, timeframe, from, to): Promise<Candle[]>
Fetch historical candle data.
Event Handling
on(event: BrokerEvent, handler: EventHandler): void
Register event handler.
off(event: BrokerEvent, handler: EventHandler): void
Unregister event handler.
Events
| Event | Description |
|-------|-------------|
| tick | Real-time tick data |
| candle | Candlestick data updates |
| orderUpdate | Order status changes |
| positionUpdate | Position changes |
| optionChain | Option chain snapshot/incremental updates |
| connected | Connection established |
| disconnected | Connection lost |
| reconnected | Successfully reconnected |
| error | Error occurred |
Supported Instruments
Delta Exchange India supports:
Crypto perpetual futures
Crypto options (call/put contracts)
BTCUSD (Bitcoin)
ETHUSD (Ethereum)
SOLUSD (Solana)
XRPUSD (Ripple)
ADAUSD (Cardano)
And more...
Error Handling
try {
await deltaPlugin.placeOrder(order);
} catch (error) {
if (error.message.includes('Insufficient margin')) {
console.log('Not enough margin for this order');
} else if (error.message.includes('Invalid API key')) {
console.log('Check your API credentials');
}
}Testing
# Install dependencies
npm install
# Run tests
npm test
# Build
npm run build
# Lint
npm run lintDelta Exchange API Documentation
For detailed API documentation, visit:
Integration with AlgoX Framework
This plugin implements the IBrokerPlugin interface, making it fully compatible with the AlgoX Trading Framework:
import { StrategyEngine, BrokerAdapter } from '@chirag1702/algox';
import { DeltaExchangePlugin } from '@chirag1702/algox-delta-exchange-plugin';
const brokerAdapter = new BrokerAdapter();
const deltaPlugin = new DeltaExchangePlugin({ testnet: true });
brokerAdapter.registerPlugin('delta', deltaPlugin);
// Connect all registered plugins
await brokerAdapter.connectAll();Contributing
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
License
This project is licensed under the MIT License - see the LICENSE file for details.
Support
For issues and feature requests, please open an issue on GitHub.
