mirror of
https://github.com/discountry/ritmex-bot.git
synced 2026-09-09 08:18:07 +00:00
更新策略工具测试,添加 markPrice 字段以确保返回的默认位置和提取位置包含最新信息。
This commit is contained in:
@@ -34,17 +34,17 @@ const mockKlines = (values: number[]): AsterKline[] =>
|
||||
|
||||
describe("strategy utils", () => {
|
||||
it("returns default position when snapshot missing", () => {
|
||||
expect(getPosition(null, "BTCUSDT")).toEqual({ positionAmt: 0, entryPrice: 0, unrealizedProfit: 0 });
|
||||
expect(getPosition(null, "BTCUSDT")).toEqual({ positionAmt: 0, entryPrice: 0, unrealizedProfit: 0, markPrice: null });
|
||||
});
|
||||
|
||||
it("extracts position for symbol", () => {
|
||||
const snapshot = mockSnapshot([{ symbol: "BTCUSDT", amt: 1, entry: 100, pnl: 5 }]);
|
||||
expect(getPosition(snapshot, "BTCUSDT")).toEqual({ positionAmt: 1, entryPrice: 100, unrealizedProfit: 5 });
|
||||
expect(getPosition(snapshot, "BTCUSDT")).toEqual({ positionAmt: 1, entryPrice: 100, unrealizedProfit: 5, markPrice: null });
|
||||
});
|
||||
|
||||
it("returns zero position when symbol not found", () => {
|
||||
const snapshot = mockSnapshot([{ symbol: "ETHUSDT", amt: 2, entry: 200, pnl: 10 }]);
|
||||
expect(getPosition(snapshot, "BTCUSDT")).toEqual({ positionAmt: 0, entryPrice: 0, unrealizedProfit: 0 });
|
||||
expect(getPosition(snapshot, "BTCUSDT")).toEqual({ positionAmt: 0, entryPrice: 0, unrealizedProfit: 0, markPrice: null });
|
||||
});
|
||||
|
||||
it("returns null when not enough klines", () => {
|
||||
|
||||
Reference in New Issue
Block a user