mirror of
https://github.com/discountry/ritmex-bot.git
synced 2026-09-11 01:08:07 +00:00
Enhance CLI command mode for ritmex-bot
- Introduced a new command mode for `ritmex-bot`, allowing agent-friendly structured trading operations without entering the Ink interactive menu. - Updated `package.json` to include versioning and set the project as public with a new CLI entry point. - Enhanced documentation in both English and Chinese to provide comprehensive usage instructions for the new command mode. - Added a new executable script for `ritmex-bot` to facilitate command execution. - Improved error handling and command parsing for better user experience and clarity in command execution.
This commit is contained in:
@@ -0,0 +1,55 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { DryRunExchangeAdapter } from "../src/exchanges/dry-run-adapter";
|
||||
import type { ExchangeAdapter } from "../src/exchanges/adapter";
|
||||
import type {
|
||||
AsterAccountSnapshot,
|
||||
AsterDepth,
|
||||
AsterKline,
|
||||
AsterOrder,
|
||||
AsterTicker,
|
||||
CreateOrderParams,
|
||||
} from "../src/exchanges/types";
|
||||
|
||||
class BaseAdapter implements ExchangeAdapter {
|
||||
readonly id = "aster";
|
||||
createCalls = 0;
|
||||
|
||||
supportsTrailingStops(): boolean {
|
||||
return true;
|
||||
}
|
||||
|
||||
watchAccount(_cb: (snapshot: AsterAccountSnapshot) => void): void {}
|
||||
watchOrders(_cb: (orders: AsterOrder[]) => void): void {}
|
||||
watchDepth(_symbol: string, _cb: (depth: AsterDepth) => void): void {}
|
||||
watchTicker(_symbol: string, _cb: (ticker: AsterTicker) => void): void {}
|
||||
watchKlines(_symbol: string, _interval: string, _cb: (klines: AsterKline[]) => void): void {}
|
||||
|
||||
async createOrder(_params: CreateOrderParams): Promise<AsterOrder> {
|
||||
this.createCalls += 1;
|
||||
throw new Error("should not be called in dry-run");
|
||||
}
|
||||
|
||||
async cancelOrder(): Promise<void> {}
|
||||
async cancelOrders(): Promise<void> {}
|
||||
async cancelAllOrders(): Promise<void> {}
|
||||
}
|
||||
|
||||
describe("DryRunExchangeAdapter", () => {
|
||||
it("simulates create order and records actions", async () => {
|
||||
const base = new BaseAdapter();
|
||||
const dry = new DryRunExchangeAdapter(base);
|
||||
|
||||
const order = await dry.createOrder({
|
||||
symbol: "BTCUSDT",
|
||||
side: "BUY",
|
||||
type: "LIMIT",
|
||||
quantity: 0.01,
|
||||
price: 100000,
|
||||
});
|
||||
|
||||
expect(base.createCalls).toBe(0);
|
||||
expect(order.orderId).toMatch(/^dry-run-/);
|
||||
expect(dry.actions.length).toBe(1);
|
||||
expect(dry.actions[0]?.method).toBe("createOrder");
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user