Add support for a new cryptocurrency exchange to the dashboard
Add integration for a new cryptocurrency exchange to enable position monitoring.
Add support for the exchange specified in $ARGUMENTS. If no exchange is specified, ask the user which exchange to add.
Research the Exchange
Update Type Definitions
Add the exchange to relevant types in src/types/index.ts:
exchange field to include the new exchange nameCreate Exchange Service
Create src/services/exchanges/{exchange-name}.ts:
import { Position } from '../../types';
export interface {ExchangeName}Config {
apiKey: string;
apiSecret: string;
testnet: boolean;
}
export class {ExchangeName}Service {
constructor(config: {ExchangeName}Config) {}
async getPositions(): Promise<Position[]> {}
async getAccountBalance(): Promise<number> {}
}
Add Environment Variables
Update .env.example:
# {Exchange Name}
{EXCHANGE}_API_KEY=
{EXCHANGE}_API_SECRET=
{EXCHANGE}_TESTNET=true
Update Mock Data
Add the exchange to src/services/mockData.ts:
const exchanges = ['Binance', 'Bybit', 'OKX', '{NewExchange}'];
Documentation
Add exchange-specific notes to README.md:
Test Integration
Create a test file or add test cases:
For adding Kraken exchange:
// src/services/exchanges/kraken.ts
import { Position } from '../../types';
export interface KrakenConfig {
apiKey: string;
apiSecret: string;
}
export class KrakenService {
private baseUrl = 'https://api.kraken.com';
constructor(private config: KrakenConfig) {}
async getPositions(): Promise<Position[]> {
// Implementation
const response = await fetch(`${this.baseUrl}/0/private/OpenPositions`, {
method: 'POST',
headers: this.getHeaders(),
});
const data = await response.json();
return this.parsePositions(data);
}
private parsePositions(data: any): Position[] {
// Parse Kraken API response to Position[]
}
private getHeaders() {
// Generate authentication headers
}
}