Add Binance exchange support

- Updated the environment configuration to include Binance as a selectable exchange option.
- Enhanced the README documentation to reflect the addition of Binance.
- Implemented the Binance exchange adapter and integrated it into the existing exchange framework.
- Modified the basis arbitrage strategy to support Binance alongside existing exchanges.
- Added tests to ensure proper functionality and integration of Binance within the trading system.
This commit is contained in:
discountry
2026-02-27 11:21:47 +08:00
parent 227484152d
commit 4205d5dc12
18 changed files with 2143 additions and 17 deletions
+9 -1
View File
@@ -6,6 +6,7 @@ import { BackpackExchangeAdapter, type BackpackCredentials } from "./backpack/ad
import { ParadexExchangeAdapter, type ParadexCredentials } from "./paradex/adapter";
import { NadoExchangeAdapter, type NadoCredentials } from "./nado/adapter";
import { StandxExchangeAdapter, type StandxCredentials } from "./standx/adapter";
import { BinanceExchangeAdapter, type BinanceCredentials } from "./binance/adapter";
export interface ExchangeFactoryOptions {
symbol: string;
@@ -17,6 +18,7 @@ export interface ExchangeFactoryOptions {
paradex?: ParadexCredentials;
nado?: NadoCredentials;
standx?: StandxCredentials;
binance?: BinanceCredentials;
}
export type SupportedExchangeId =
@@ -26,7 +28,8 @@ export type SupportedExchangeId =
| "backpack"
| "paradex"
| "nado"
| "standx";
| "standx"
| "binance";
export function resolveExchangeId(value?: string | null): SupportedExchangeId {
const fallback = (value ?? process.env.EXCHANGE ?? process.env.TRADE_EXCHANGE ?? "aster")
@@ -39,6 +42,7 @@ export function resolveExchangeId(value?: string | null): SupportedExchangeId {
if (fallback === "paradex") return "paradex";
if (fallback === "nado") return "nado";
if (fallback === "standx") return "standx";
if (fallback === "binance" || fallback === "bnb") return "binance";
return "aster";
}
@@ -49,6 +53,7 @@ export function getExchangeDisplayName(id: SupportedExchangeId): string {
if (id === "paradex") return "Paradex";
if (id === "nado") return "Nado";
if (id === "standx") return "StandX";
if (id === "binance") return "Binance";
return "AsterDex";
}
@@ -72,5 +77,8 @@ export function createExchangeAdapter(options: ExchangeFactoryOptions): Exchange
if (id === "standx") {
return new StandxExchangeAdapter({ ...options.standx, symbol: options.symbol });
}
if (id === "binance") {
return new BinanceExchangeAdapter({ ...options.binance, symbol: options.symbol });
}
return new AsterExchangeAdapter({ ...options.aster, symbol: options.symbol });
}