korea-crypto-exchange
Version:
한국의 주요 암호화폐 거래소(업비트, 빗썸) API를 쉽게 구현할 수 있도록 도와주는 TypeScript 라이브러리
36 lines (35 loc) • 1.22 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.ExchangeSelector = void 0;
const types_1 = require("../core/types");
const upbit_1 = require("../strategies/upbit");
class ExchangeSelector {
constructor(config) {
this.config = config;
}
getServerUrl(type) {
switch (type) {
case types_1.ExchangeType.UPBIT:
return 'https://api.upbit.com';
case types_1.ExchangeType.BITHUMB:
return 'https://api.bithumb.com';
default:
throw new Error(`Unsupported exchange type: ${type}`);
}
}
select() {
const serverUrl = this.getServerUrl(this.config.type);
switch (this.config.type) {
case types_1.ExchangeType.UPBIT:
return new upbit_1.UpbitStrategy({
...this.config,
serverUrl
});
case types_1.ExchangeType.BITHUMB:
throw new Error('Bithumb exchange is not implemented yet');
default:
throw new Error(`Unsupported exchange type: ${this.config.type}`);
}
}
}
exports.ExchangeSelector = ExchangeSelector;