import { config } from '../config/index.js';
import { AlpacaConnector } from './alpaca.js';
import { CCXTConnector } from './ccxt.js';
import { IExchangeConnector } from './types.js';

export class ConnectorFactory {
    static getConnector(): IExchangeConnector {
        return this.getCustomConnector(config.PROVIDER);
    }

    static getCustomConnector(provider: string, apiKey?: string, apiSecret?: string): IExchangeConnector {
        switch (provider.toLowerCase()) {
            case 'alpaca':
                return new AlpacaConnector(apiKey, apiSecret);
            case 'ccxt':
                return new CCXTConnector(apiKey, apiSecret);
            default:
                throw new Error(`Provider ${provider} is not supported. Use 'alpaca' or 'ccxt'.`);
        }
    }
}
