Add volumes and fix missing signal
This commit is contained in:
@@ -81,6 +81,45 @@ const BacktestRowDetails: React.FC<IBacktestRowDetailsProps> = ({
|
||||
return averageHours.toFixed(2);
|
||||
};
|
||||
|
||||
// Calculate total volume traded with leverage
|
||||
const getTotalVolumeTraded = () => {
|
||||
let totalVolume = 0;
|
||||
|
||||
positions.forEach((position) => {
|
||||
// Calculate volume for open trade
|
||||
const openLeverage = position.open.leverage || 1;
|
||||
const openVolume = position.open.quantity * position.open.price * openLeverage;
|
||||
totalVolume += openVolume;
|
||||
|
||||
// Calculate volume for close trade (stopLoss or takeProfit based on realized P&L)
|
||||
if (position.profitAndLoss?.realized != null) {
|
||||
let closeTrade;
|
||||
if (position.profitAndLoss.realized > 0) {
|
||||
// Profitable close = Take Profit
|
||||
closeTrade = position.takeProfit1;
|
||||
} else {
|
||||
// Loss or breakeven close = Stop Loss
|
||||
closeTrade = position.stopLoss;
|
||||
}
|
||||
|
||||
if (closeTrade) {
|
||||
const closeLeverage = closeTrade.leverage || 1;
|
||||
const closeVolume = closeTrade.quantity * closeTrade.price * closeLeverage;
|
||||
totalVolume += closeVolume;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
return totalVolume;
|
||||
};
|
||||
|
||||
// Calculate estimated UI fee (0.02% of total volume)
|
||||
const getEstimatedUIFee = () => {
|
||||
const totalVolume = getTotalVolumeTraded();
|
||||
const uiFeePercentage = 0.0002; // 0.02%
|
||||
return totalVolume * uiFeePercentage;
|
||||
};
|
||||
|
||||
return (
|
||||
<>
|
||||
<div className="grid grid-flow-row">
|
||||
@@ -146,6 +185,20 @@ const BacktestRowDetails: React.FC<IBacktestRowDetailsProps> = ({
|
||||
title="Avg Open Time (Losing)"
|
||||
content={getAverageOpenTimeLosing() + " hours"}
|
||||
></CardText>
|
||||
<CardText
|
||||
title="Volume Traded"
|
||||
content={"$" + getTotalVolumeTraded().toLocaleString('en-US', {
|
||||
minimumFractionDigits: 2,
|
||||
maximumFractionDigits: 2
|
||||
})}
|
||||
></CardText>
|
||||
<CardText
|
||||
title="Estimated UI Fee"
|
||||
content={"$" + getEstimatedUIFee().toLocaleString('en-US', {
|
||||
minimumFractionDigits: 2,
|
||||
maximumFractionDigits: 2
|
||||
})}
|
||||
></CardText>
|
||||
</div>
|
||||
<div>
|
||||
<figure>
|
||||
|
||||
Reference in New Issue
Block a user