mirror of
https://github.com/discountry/ritmex-bot.git
synced 2026-09-09 16:28:06 +00:00
- AsterOrder → Order - AsterAccountSnapshot → AccountSnapshot - AsterAccountPosition → AccountPosition - AsterAccountAsset → AccountAsset - AsterDepthLevel → DepthLevel - AsterDepth → Depth - AsterTicker → Ticker - AsterKline → Kline These types are the platform-agnostic contract used by all 8 exchanges, not Aster-specific. Renamed across 63 files.
56 lines
1.6 KiB
TypeScript
56 lines
1.6 KiB
TypeScript
import { describe, expect, it } from "vitest";
|
|
import { DryRunExchangeAdapter } from "../src/exchanges/dry-run-adapter";
|
|
import type { ExchangeAdapter } from "../src/exchanges/adapter";
|
|
import type {
|
|
AccountSnapshot,
|
|
Depth,
|
|
Kline,
|
|
Order,
|
|
Ticker,
|
|
CreateOrderParams,
|
|
} from "../src/exchanges/types";
|
|
|
|
class BaseAdapter implements ExchangeAdapter {
|
|
readonly id = "aster";
|
|
createCalls = 0;
|
|
|
|
supportsTrailingStops(): boolean {
|
|
return true;
|
|
}
|
|
|
|
watchAccount(_cb: (snapshot: AccountSnapshot) => void): void {}
|
|
watchOrders(_cb: (orders: Order[]) => void): void {}
|
|
watchDepth(_symbol: string, _cb: (depth: Depth) => void): void {}
|
|
watchTicker(_symbol: string, _cb: (ticker: Ticker) => void): void {}
|
|
watchKlines(_symbol: string, _interval: string, _cb: (klines: Kline[]) => void): void {}
|
|
|
|
async createOrder(_params: CreateOrderParams): Promise<Order> {
|
|
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");
|
|
});
|
|
});
|