mirror of
https://github.com/NoFxAiOS/nofx.git
synced 2026-07-17 01:14:40 +08:00
Feature: Add position details to Trade History
Add missing fields to TradeOutcome: - Quantity: Position size - Leverage: Leverage multiplier - PositionValue: Total position value (quantity × openPrice) - MarginUsed: Margin required (positionValue / leverage) This provides complete trade information for analysis and display. Co-Authored-By: tinkle-community <tinklefund@gmail.com>
This commit is contained in:
@@ -271,10 +271,14 @@ type Statistics struct {
|
|||||||
type TradeOutcome struct {
|
type TradeOutcome struct {
|
||||||
Symbol string `json:"symbol"` // 币种
|
Symbol string `json:"symbol"` // 币种
|
||||||
Side string `json:"side"` // long/short
|
Side string `json:"side"` // long/short
|
||||||
|
Quantity float64 `json:"quantity"` // 仓位数量
|
||||||
|
Leverage int `json:"leverage"` // 杠杆倍数
|
||||||
OpenPrice float64 `json:"open_price"` // 开仓价
|
OpenPrice float64 `json:"open_price"` // 开仓价
|
||||||
ClosePrice float64 `json:"close_price"` // 平仓价
|
ClosePrice float64 `json:"close_price"` // 平仓价
|
||||||
|
PositionValue float64 `json:"position_value"` // 仓位价值(quantity × openPrice)
|
||||||
|
MarginUsed float64 `json:"margin_used"` // 保证金使用(positionValue / leverage)
|
||||||
PnL float64 `json:"pn_l"` // 盈亏(USDT)
|
PnL float64 `json:"pn_l"` // 盈亏(USDT)
|
||||||
PnLPct float64 `json:"pn_l_pct"` // 盈亏百分比
|
PnLPct float64 `json:"pn_l_pct"` // 盈亏百分比(相对保证金)
|
||||||
Duration string `json:"duration"` // 持仓时长
|
Duration string `json:"duration"` // 持仓时长
|
||||||
OpenTime time.Time `json:"open_time"` // 开仓时间
|
OpenTime time.Time `json:"open_time"` // 开仓时间
|
||||||
CloseTime time.Time `json:"close_time"` // 平仓时间
|
CloseTime time.Time `json:"close_time"` // 平仓时间
|
||||||
@@ -426,8 +430,12 @@ func (l *DecisionLogger) AnalyzePerformance(lookbackCycles int) (*PerformanceAna
|
|||||||
outcome := TradeOutcome{
|
outcome := TradeOutcome{
|
||||||
Symbol: symbol,
|
Symbol: symbol,
|
||||||
Side: side,
|
Side: side,
|
||||||
|
Quantity: quantity,
|
||||||
|
Leverage: leverage,
|
||||||
OpenPrice: openPrice,
|
OpenPrice: openPrice,
|
||||||
ClosePrice: action.Price,
|
ClosePrice: action.Price,
|
||||||
|
PositionValue: positionValue,
|
||||||
|
MarginUsed: marginUsed,
|
||||||
PnL: pnl,
|
PnL: pnl,
|
||||||
PnLPct: pnlPct,
|
PnLPct: pnlPct,
|
||||||
Duration: action.Timestamp.Sub(openTime).String(),
|
Duration: action.Timestamp.Sub(openTime).String(),
|
||||||
|
|||||||
Reference in New Issue
Block a user