86 lines
3.3 KiB
JSON
86 lines
3.3 KiB
JSON
{
|
||
"meta": {
|
||
"schemaVersion": 1,
|
||
"source": "hand-crafted representative samples (replace/extend via tools/exportHistoricalSwapEvents.js against real DB)",
|
||
"note": "每条 record 的 inputs 是前端 calcCloseAmount 实际会收到的形态(deal/floatPosition/interestList/marginList);expected 是落库/记录值。运行时无需 DB。",
|
||
"knownDiscrepancies": "swapLongShort.js 的 SwapMarginAmount 用裸 InterestPrincipal(无符号),而 unwindSwapTrade.js 用 InterestDirection 求符号。该差异被冻结在 knownDiscrepancies 中,仅当差异量变化时才报红。"
|
||
},
|
||
"records": [
|
||
{
|
||
"id": "UNWIND_STD",
|
||
"desc": "标准平仓(unwind):含浮动盈亏 + 利息腿 + 预付金腿",
|
||
"eventType": 2,
|
||
"deal": { "CloseQty": 1000 },
|
||
"floatPosition": { "FloatPnlSum": 50000, "PositionType": 1, "PayDirection": 1, "TradingFee": 20 },
|
||
"interestList": [
|
||
{ "InterestClosePnL": 1200, "InterestDirection": 1, "InterestPrincipal": 0 }
|
||
],
|
||
"marginList": [
|
||
{ "InterestClosePnL": 300, "InterestDirection": 1, "InterestPrincipal": 50000 }
|
||
],
|
||
"expected": {
|
||
"SwapCloseAmount": 51500,
|
||
"SwapRealizedPnL": 51500,
|
||
"SwapMarginRebatePnl": 300,
|
||
"SwapMarginAmount": -50000
|
||
}
|
||
},
|
||
{
|
||
"id": "INCOME_STD",
|
||
"desc": "收益结算(income):用 CloseNotionalValue 计价,利息腿+预付金腿",
|
||
"eventType": 3,
|
||
"deal": { "CloseQty": 0, "CloseNotionalValue": 10200 },
|
||
"floatPosition": { "FloatPnlSum": 30000, "PositionType": 1, "PayDirection": 2, "TradingFee": 0 },
|
||
"interestList": [
|
||
{ "InterestClosePnL": 800, "InterestDirection": 1, "InterestPrincipal": 0 }
|
||
],
|
||
"marginList": [
|
||
{ "InterestClosePnL": 200, "InterestDirection": 2, "InterestPrincipal": 40000 }
|
||
],
|
||
"expected": {
|
||
"SwapCloseAmount": 31000,
|
||
"SwapRealizedPnL": 31000,
|
||
"SwapMarginRebatePnl": 200,
|
||
"SwapMarginAmount": 40000
|
||
}
|
||
},
|
||
{
|
||
"id": "LONGSHORT_UNWIND",
|
||
"desc": "多空组合平仓(unwindLongShort):从0起,不含浮动盈亏(FloatPnlSum=0)",
|
||
"eventType": 4,
|
||
"deal": { "CloseQty": 0 },
|
||
"floatPosition": { "FloatPnlSum": 0, "PositionType": 1, "PayDirection": 1, "TradingFee": 0 },
|
||
"interestList": [],
|
||
"marginList": [
|
||
{ "InterestClosePnL": 150, "InterestDirection": 1, "InterestPrincipal": 20000 }
|
||
],
|
||
"expected": {
|
||
"SwapCloseAmount": 150,
|
||
"SwapRealizedPnL": 150,
|
||
"SwapMarginRebatePnl": 150,
|
||
"SwapMarginAmount": -20000
|
||
}
|
||
},
|
||
{
|
||
"id": "LONGSHORT_SWAP",
|
||
"desc": "多空组合互换(swapLongShort):SwapMarginAmount 用裸 InterestPrincipal(无符号) —— 已知差异",
|
||
"eventType": 5,
|
||
"deal": { "CloseQty": 0 },
|
||
"floatPosition": { "FloatPnlSum": 0, "PositionType": 1, "PayDirection": 1, "TradingFee": 0 },
|
||
"interestList": [],
|
||
"marginList": [
|
||
{ "InterestClosePnL": 100, "InterestDirection": 1, "InterestPrincipal": 18000 }
|
||
],
|
||
"expected": {
|
||
"SwapCloseAmount": 100,
|
||
"SwapRealizedPnL": 100,
|
||
"SwapMarginRebatePnl": 100,
|
||
"SwapMarginAmount": 18000
|
||
},
|
||
"knownDiscrepancies": {
|
||
"SwapMarginAmount": 36000
|
||
}
|
||
}
|
||
]
|
||
}
|