mirror of
https://github.com/discountry/ritmex-bot.git
synced 2026-09-09 16:28:06 +00:00
* add docs * 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. * Enhance README with detailed Binance exchange configuration - Added comprehensive instructions for setting up Binance as an exchange option. - Included environment variable specifications for API keys, market types, and trading symbols. - Provided examples for both perpetual and spot trading strategies. - Clarified the use of WebSocket and REST for the Binance adapter. * Enhance exchange support and testing framework - Added a new test suite for exchange contracts to ensure consistency and functionality across supported exchanges. - Refactored exchange ID handling to utilize a centralized list of supported exchanges, improving maintainability. - Updated CLI argument parsing and help documentation to reflect the new exchange structure. - Introduced utility functions for validating supported exchanges and their display names. - Enhanced the BasisApp and strategy runner to leverage the new exchange validation logic. - Added a new test command for running exchange-related tests. * Refactor exchange contract tests and update CLI commands - Removed the trailing supported exchanges set and simplified the logic for trailing stop support in the exchange contract tests. - Updated the test command for exchange contracts to exclude unnecessary tests, streamlining the testing process. - Enhanced test descriptions for clarity and improved understanding of the functionality being tested.
60 lines
1.7 KiB
TypeScript
60 lines
1.7 KiB
TypeScript
import { afterEach, beforeEach, describe, expect, it } from "vitest";
|
|
import { resolveSymbolFromEnv } from "../src/config";
|
|
|
|
const ORIGINAL_ENV = { ...process.env };
|
|
|
|
beforeEach(() => {
|
|
process.env = { ...ORIGINAL_ENV };
|
|
});
|
|
|
|
afterEach(() => {
|
|
process.env = { ...ORIGINAL_ENV };
|
|
});
|
|
|
|
describe("resolveSymbolFromEnv", () => {
|
|
it("prefers exchange-specific symbol when available", () => {
|
|
process.env.EXCHANGE = "backpack";
|
|
process.env.BACKPACK_SYMBOL = "ETHUSDC";
|
|
process.env.TRADE_SYMBOL = "BTCUSDT";
|
|
|
|
expect(resolveSymbolFromEnv()).toBe("ETHUSDC");
|
|
});
|
|
|
|
it("falls back to TRADE_SYMBOL when exchange symbol is missing", () => {
|
|
process.env.EXCHANGE = "paradex";
|
|
process.env.TRADE_SYMBOL = "ETH/USDC";
|
|
delete process.env.PARADEX_SYMBOL;
|
|
|
|
expect(resolveSymbolFromEnv()).toBe("ETH/USDC");
|
|
});
|
|
|
|
it("uses exchange-specific fallback when no env is defined", () => {
|
|
process.env.EXCHANGE = "paradex";
|
|
delete process.env.PARADEX_SYMBOL;
|
|
delete process.env.TRADE_SYMBOL;
|
|
|
|
expect(resolveSymbolFromEnv()).toBe("BTC/USDC");
|
|
});
|
|
|
|
it("supports resolving symbol for an explicit exchange id", () => {
|
|
delete process.env.EXCHANGE;
|
|
process.env.GRVT_SYMBOL = "ETHUSDT";
|
|
|
|
expect(resolveSymbolFromEnv("grvt")).toBe("ETHUSDT");
|
|
});
|
|
|
|
it("supports standx symbol defaults when explicit exchange id is provided", () => {
|
|
delete process.env.EXCHANGE;
|
|
process.env.STANDX_SYMBOL = "ETH-USD";
|
|
|
|
expect(resolveSymbolFromEnv("standx")).toBe("ETH-USD");
|
|
});
|
|
|
|
it("supports binance symbol defaults when explicit exchange id is provided", () => {
|
|
delete process.env.EXCHANGE;
|
|
process.env.BINANCE_SYMBOL = "ETHUSDT";
|
|
|
|
expect(resolveSymbolFromEnv("binance")).toBe("ETHUSDT");
|
|
});
|
|
});
|