mirror of
https://github.com/discountry/ritmex-bot.git
synced 2026-09-11 09:18:08 +00:00
feat: add priceDecimals to MakerEngine and OffsetMakerEngine for improved price formatting in MakerApp and OffsetMakerApp
This commit is contained in:
@@ -41,6 +41,7 @@ export interface MakerEngineSnapshot {
|
|||||||
topBid: number | null;
|
topBid: number | null;
|
||||||
topAsk: number | null;
|
topAsk: number | null;
|
||||||
spread: number | null;
|
spread: number | null;
|
||||||
|
priceDecimals: number;
|
||||||
position: PositionSnapshot;
|
position: PositionSnapshot;
|
||||||
pnl: number;
|
pnl: number;
|
||||||
accountUnrealized: number;
|
accountUnrealized: number;
|
||||||
@@ -599,6 +600,7 @@ export class MakerEngine {
|
|||||||
topBid: topBid,
|
topBid: topBid,
|
||||||
topAsk: topAsk,
|
topAsk: topAsk,
|
||||||
spread,
|
spread,
|
||||||
|
priceDecimals: this.getPriceDecimals(),
|
||||||
position,
|
position,
|
||||||
pnl,
|
pnl,
|
||||||
accountUnrealized: this.accountUnrealized,
|
accountUnrealized: this.accountUnrealized,
|
||||||
|
|||||||
@@ -725,6 +725,7 @@ export class OffsetMakerEngine {
|
|||||||
topBid: topBid,
|
topBid: topBid,
|
||||||
topAsk: topAsk,
|
topAsk: topAsk,
|
||||||
spread,
|
spread,
|
||||||
|
priceDecimals: this.getPriceDecimals(),
|
||||||
position,
|
position,
|
||||||
pnl,
|
pnl,
|
||||||
accountUnrealized: this.accountUnrealized,
|
accountUnrealized: this.accountUnrealized,
|
||||||
|
|||||||
+6
-3
@@ -70,7 +70,10 @@ export function MakerApp({ onExit }: MakerAppProps) {
|
|||||||
|
|
||||||
const topBid = snapshot.topBid;
|
const topBid = snapshot.topBid;
|
||||||
const topAsk = snapshot.topAsk;
|
const topAsk = snapshot.topAsk;
|
||||||
const spreadDisplay = snapshot.spread != null ? `${snapshot.spread.toFixed(4)} USDT` : "-";
|
const priceDigits = snapshot.priceDecimals ?? 2;
|
||||||
|
const spreadDigits = Math.max(priceDigits + 1, 4);
|
||||||
|
const spreadDisplay =
|
||||||
|
snapshot.spread != null ? `${formatNumber(snapshot.spread, spreadDigits)} USDT` : "-";
|
||||||
const hasPosition = Math.abs(snapshot.position.positionAmt) > 1e-5;
|
const hasPosition = Math.abs(snapshot.position.positionAmt) > 1e-5;
|
||||||
const sortedOrders = [...snapshot.openOrders].sort((a, b) => (Number(b.updateTime ?? 0) - Number(a.updateTime ?? 0)) || Number(b.orderId) - Number(a.orderId));
|
const sortedOrders = [...snapshot.openOrders].sort((a, b) => (Number(b.updateTime ?? 0) - Number(a.updateTime ?? 0)) || Number(b.orderId) - Number(a.orderId));
|
||||||
const openOrderRows = sortedOrders.slice(0, 8).map((order) => ({
|
const openOrderRows = sortedOrders.slice(0, 8).map((order) => ({
|
||||||
@@ -121,7 +124,7 @@ export function MakerApp({ onExit }: MakerAppProps) {
|
|||||||
<Box flexDirection="column" marginBottom={1}>
|
<Box flexDirection="column" marginBottom={1}>
|
||||||
<Text color="cyanBright">Maker Strategy Dashboard</Text>
|
<Text color="cyanBright">Maker Strategy Dashboard</Text>
|
||||||
<Text>
|
<Text>
|
||||||
交易所: {exchangeName} | 交易对: {snapshot.symbol} | 买一价: {formatNumber(topBid, 2)} | 卖一价: {formatNumber(topAsk, 2)} | 点差: {spreadDisplay}
|
交易所: {exchangeName} | 交易对: {snapshot.symbol} | 买一价: {formatNumber(topBid, priceDigits)} | 卖一价: {formatNumber(topAsk, priceDigits)} | 点差: {spreadDisplay}
|
||||||
</Text>
|
</Text>
|
||||||
<Text color="gray">状态: {snapshot.ready ? "实时运行" : "等待市场数据"} | 按 Esc 返回策略选择</Text>
|
<Text color="gray">状态: {snapshot.ready ? "实时运行" : "等待市场数据"} | 按 Esc 返回策略选择</Text>
|
||||||
<Text>
|
<Text>
|
||||||
@@ -141,7 +144,7 @@ export function MakerApp({ onExit }: MakerAppProps) {
|
|||||||
{hasPosition ? (
|
{hasPosition ? (
|
||||||
<>
|
<>
|
||||||
<Text>
|
<Text>
|
||||||
方向: {snapshot.position.positionAmt > 0 ? "多" : "空"} | 数量: {formatNumber(Math.abs(snapshot.position.positionAmt), 4)} | 开仓价: {formatNumber(snapshot.position.entryPrice, 2)}
|
方向: {snapshot.position.positionAmt > 0 ? "多" : "空"} | 数量: {formatNumber(Math.abs(snapshot.position.positionAmt), 4)} | 开仓价: {formatNumber(snapshot.position.entryPrice, priceDigits)}
|
||||||
</Text>
|
</Text>
|
||||||
<Text>
|
<Text>
|
||||||
浮动盈亏: {formatNumber(snapshot.pnl, 4)} USDT | 账户未实现盈亏: {formatNumber(snapshot.accountUnrealized, 4)} USDT
|
浮动盈亏: {formatNumber(snapshot.pnl, 4)} USDT | 账户未实现盈亏: {formatNumber(snapshot.accountUnrealized, 4)} USDT
|
||||||
|
|||||||
@@ -70,7 +70,10 @@ export function OffsetMakerApp({ onExit }: OffsetMakerAppProps) {
|
|||||||
|
|
||||||
const topBid = snapshot.topBid;
|
const topBid = snapshot.topBid;
|
||||||
const topAsk = snapshot.topAsk;
|
const topAsk = snapshot.topAsk;
|
||||||
const spreadDisplay = snapshot.spread != null ? `${snapshot.spread.toFixed(4)} USDT` : "-";
|
const priceDigits = snapshot.priceDecimals ?? 2;
|
||||||
|
const spreadDigits = Math.max(priceDigits + 1, 4);
|
||||||
|
const spreadDisplay =
|
||||||
|
snapshot.spread != null ? `${formatNumber(snapshot.spread, spreadDigits)} USDT` : "-";
|
||||||
const hasPosition = Math.abs(snapshot.position.positionAmt) > 1e-5;
|
const hasPosition = Math.abs(snapshot.position.positionAmt) > 1e-5;
|
||||||
const sortedOrders = [...snapshot.openOrders].sort((a, b) =>
|
const sortedOrders = [...snapshot.openOrders].sort((a, b) =>
|
||||||
(Number(b.updateTime ?? 0) - Number(a.updateTime ?? 0)) || Number(b.orderId) - Number(a.orderId)
|
(Number(b.updateTime ?? 0) - Number(a.updateTime ?? 0)) || Number(b.orderId) - Number(a.orderId)
|
||||||
@@ -121,7 +124,7 @@ export function OffsetMakerApp({ onExit }: OffsetMakerAppProps) {
|
|||||||
<Box flexDirection="column" marginBottom={1}>
|
<Box flexDirection="column" marginBottom={1}>
|
||||||
<Text color="cyanBright">Offset Maker Strategy Dashboard</Text>
|
<Text color="cyanBright">Offset Maker Strategy Dashboard</Text>
|
||||||
<Text>
|
<Text>
|
||||||
交易所: {exchangeName} | 交易对: {snapshot.symbol} | 买一价: {formatNumber(topBid, 2)} | 卖一价: {formatNumber(topAsk, 2)} | 点差: {spreadDisplay}
|
交易所: {exchangeName} | 交易对: {snapshot.symbol} | 买一价: {formatNumber(topBid, priceDigits)} | 卖一价: {formatNumber(topAsk, priceDigits)} | 点差: {spreadDisplay}
|
||||||
</Text>
|
</Text>
|
||||||
<Text>
|
<Text>
|
||||||
买10档累计: {formatNumber(snapshot.buyDepthSum10, 4)} | 卖10档累计: {formatNumber(snapshot.sellDepthSum10, 4)} | 状态: {imbalanceLabel}
|
买10档累计: {formatNumber(snapshot.buyDepthSum10, 4)} | 卖10档累计: {formatNumber(snapshot.sellDepthSum10, 4)} | 状态: {imbalanceLabel}
|
||||||
@@ -138,7 +141,7 @@ export function OffsetMakerApp({ onExit }: OffsetMakerAppProps) {
|
|||||||
{hasPosition ? (
|
{hasPosition ? (
|
||||||
<>
|
<>
|
||||||
<Text>
|
<Text>
|
||||||
方向: {snapshot.position.positionAmt > 0 ? "多" : "空"} | 数量: {formatNumber(Math.abs(snapshot.position.positionAmt), 4)} | 开仓价: {formatNumber(snapshot.position.entryPrice, 2)}
|
方向: {snapshot.position.positionAmt > 0 ? "多" : "空"} | 数量: {formatNumber(Math.abs(snapshot.position.positionAmt), 4)} | 开仓价: {formatNumber(snapshot.position.entryPrice, priceDigits)}
|
||||||
</Text>
|
</Text>
|
||||||
<Text>
|
<Text>
|
||||||
浮动盈亏: {formatNumber(snapshot.pnl, 4)} USDT | 账户未实现盈亏: {formatNumber(snapshot.accountUnrealized, 4)} USDT
|
浮动盈亏: {formatNumber(snapshot.pnl, 4)} USDT | 账户未实现盈亏: {formatNumber(snapshot.accountUnrealized, 4)} USDT
|
||||||
|
|||||||
Reference in New Issue
Block a user