更新环境配置示例,添加 GRVT 相关的 API 凭证和选项,增强文档以支持新的交易所适配器,确保用户能够正确配置和使用 GRVT 交易功能。

This commit is contained in:
discountry
2025-09-27 16:12:20 +08:00
parent 64640f4494
commit dde7ab71a9
60 changed files with 16126 additions and 527 deletions
+29
View File
@@ -0,0 +1,29 @@
import type { ExchangeAdapter } from "./adapter";
import { AsterExchangeAdapter, type AsterCredentials } from "./aster-adapter";
import { GrvtExchangeAdapter, type GrvtCredentials } from "./grvt/adapter";
export interface ExchangeFactoryOptions {
symbol: string;
exchange?: string;
aster?: AsterCredentials;
grvt?: GrvtCredentials;
}
export type SupportedExchangeId = "aster" | "grvt";
export function resolveExchangeId(value?: string | null): SupportedExchangeId {
const fallback = (value ?? process.env.EXCHANGE ?? process.env.TRADE_EXCHANGE ?? "aster")
.toString()
.trim()
.toLowerCase();
if (fallback === "grvt") return "grvt";
return "aster";
}
export function createExchangeAdapter(options: ExchangeFactoryOptions): ExchangeAdapter {
const id = resolveExchangeId(options.exchange);
if (id === "grvt") {
return new GrvtExchangeAdapter({ ...options.grvt, symbol: options.symbol });
}
return new AsterExchangeAdapter({ ...options.aster, symbol: options.symbol });
}