Include options unrealized PnL in OKX instance header realtime PnL total.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -1046,6 +1046,26 @@ function sumOrdersFloatPnl(orders){
|
||||
});
|
||||
return found ? total : null;
|
||||
}
|
||||
function combineRealtimeFloatPnl(perpTotal, optionsTotal){
|
||||
let total = 0, found = false;
|
||||
[perpTotal, optionsTotal].forEach(v=>{
|
||||
if(v != null && !Number.isNaN(Number(v))){
|
||||
total += Number(v);
|
||||
found = true;
|
||||
}
|
||||
});
|
||||
return found ? total : null;
|
||||
}
|
||||
function paintRealtimePnlFromSnapshot(data){
|
||||
if(!data) return;
|
||||
const perp = data.order_prices && data.order_prices.length
|
||||
? sumOrdersFloatPnl(data.order_prices)
|
||||
: null;
|
||||
const combined = combineRealtimeFloatPnl(perp, data.options_unrealized_pnl);
|
||||
if(combined !== null || perp !== null || data.options_unrealized_pnl != null){
|
||||
paintRealtimePnl(combined);
|
||||
}
|
||||
}
|
||||
|
||||
function formatOptionsFundingLabel(usdc, usdt) {
|
||||
const parts = [];
|
||||
@@ -1319,7 +1339,9 @@ function refreshPriceSnapshotConditional(){
|
||||
tickOrderHoldDurations();
|
||||
}
|
||||
if(data.order_prices && data.order_prices.length){
|
||||
paintRealtimePnl(sumOrdersFloatPnl(data.order_prices));
|
||||
paintRealtimePnlFromSnapshot(data);
|
||||
} else if (typeof data.options_unrealized_pnl !== "undefined") {
|
||||
paintRealtimePnlFromSnapshot(data);
|
||||
}
|
||||
}).catch(()=>{});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user