mirror of
https://github.com/discountry/ritmex-bot.git
synced 2026-09-09 08:18:07 +00:00
- Replaced direct price calculations with a new method `normalizeDepthTargetPrice` to ensure valid target prices for buy and sell orders. - Updated all instances of price calculations in the MakerPointsEngine to utilize the new normalization method. - Added boundary tests for `getDepthBetweenPrices` to validate behavior when prices are exactly at the target.
38 lines
989 B
TypeScript
38 lines
989 B
TypeScript
import { describe, expect, it } from "vitest";
|
|
import { getDepthBetweenPrices } from "../src/utils/price";
|
|
import type { AsterDepth } from "../src/exchanges/types";
|
|
|
|
describe("getDepthBetweenPrices boundary", () => {
|
|
it("SELL side excludes quantity exactly at target price", () => {
|
|
const depth: AsterDepth = {
|
|
lastUpdateId: 1,
|
|
bids: [],
|
|
asks: [
|
|
["69345", "1"],
|
|
["69349", "2"],
|
|
["69350", "999"],
|
|
["69351", "3"],
|
|
],
|
|
};
|
|
|
|
const total = getDepthBetweenPrices(depth, "SELL", 69350);
|
|
expect(total).toBe(3); // 仅 69345 + 69349
|
|
});
|
|
|
|
it("BUY side excludes quantity exactly at target price", () => {
|
|
const depth: AsterDepth = {
|
|
lastUpdateId: 1,
|
|
bids: [
|
|
["69355", "1"],
|
|
["69351", "2"],
|
|
["69350", "999"],
|
|
["69349", "3"],
|
|
],
|
|
asks: [],
|
|
};
|
|
|
|
const total = getDepthBetweenPrices(depth, "BUY", 69350);
|
|
expect(total).toBe(3); // 仅 69355 + 69351
|
|
});
|
|
});
|