Add average SLTP
This commit is contained in:
@@ -5,12 +5,12 @@ public class BacktestScorer
|
||||
// Updated weights without ProfitEfficiency
|
||||
private static readonly Dictionary<string, double> Weights = new Dictionary<string, double>
|
||||
{
|
||||
{ "GrowthPercentage", 0.30 }, // Increased weight for profitability
|
||||
{ "GrowthPercentage", 0.28 },
|
||||
{ "SharpeRatio", 0.18 },
|
||||
{ "MaxDrawdownPc", 0.15 },
|
||||
{ "HodlComparison", 0.15 },
|
||||
{ "WinRate", 0.10 },
|
||||
{ "ProfitabilityBonus", 0.07 }, // New direct profitability component
|
||||
{ "HodlComparison", 0.05 },
|
||||
{ "WinRate", 0.18 },
|
||||
{ "ProfitabilityBonus", 0.11 },
|
||||
{ "TradeCount", 0.03 },
|
||||
{ "RecoveryTime", 0.02 }
|
||||
};
|
||||
|
||||
@@ -14,13 +14,17 @@ import type {
|
||||
} from '../../../generated/ManagingApi'
|
||||
import { BacktestClient, BotClient } from '../../../generated/ManagingApi'
|
||||
import type { IBacktestCards } from '../../../global/type'
|
||||
import { Toast, SelectColumnFilter, Table } from '../../mollecules'
|
||||
import { Toast, SelectColumnFilter, Table, CardText } from '../../mollecules'
|
||||
|
||||
import BacktestRowDetails from './backtestRowDetails'
|
||||
|
||||
const BacktestTable: React.FC<IBacktestCards> = ({ list, isFetching }) => {
|
||||
const [rows, setRows] = useState<Backtest[]>([])
|
||||
const { apiUrl } = useApiUrlStore()
|
||||
const [optimizedMoneyManagement, setOptimizedMoneyManagement] = useState({
|
||||
stopLoss: 0,
|
||||
takeProfit: 0,
|
||||
})
|
||||
|
||||
async function runBot(backtest: Backtest, isForWatchOnly: boolean) {
|
||||
const t = new Toast('Bot is starting')
|
||||
@@ -260,7 +264,29 @@ const BacktestTable: React.FC<IBacktestCards> = ({ list, isFetching }) => {
|
||||
)
|
||||
|
||||
useEffect(() => {
|
||||
setRows(list)
|
||||
setRows(list!)
|
||||
|
||||
if (list!.length > 0) {
|
||||
// const optimized = list![0].optimizedMoneyManagement
|
||||
// setOptimizedMoneyManagement({
|
||||
// stopLoss: optimized.stopLoss,
|
||||
// takeProfit: optimized.takeProfit,
|
||||
// })
|
||||
|
||||
// Get average optimized money management for every backtest
|
||||
const optimized = list!.map((b) => b.optimizedMoneyManagement)
|
||||
const stopLoss = optimized.reduce((acc, curr) => acc + curr.stopLoss, 0)
|
||||
const takeProfit = optimized.reduce(
|
||||
(acc, curr) => acc + curr.takeProfit,
|
||||
0
|
||||
)
|
||||
|
||||
setOptimizedMoneyManagement({
|
||||
stopLoss: stopLoss / optimized.length,
|
||||
takeProfit: takeProfit / optimized.length,
|
||||
})
|
||||
}
|
||||
|
||||
}, [list])
|
||||
|
||||
const renderRowSubComponent = React.useCallback(
|
||||
@@ -289,6 +315,15 @@ const BacktestTable: React.FC<IBacktestCards> = ({ list, isFetching }) => {
|
||||
{isFetching ? (
|
||||
<progress className="progress progress-primary w-56"></progress>
|
||||
) : (<>
|
||||
<div className='w-full'>
|
||||
<CardText
|
||||
title="Average Optimized Money Management"
|
||||
content={
|
||||
"SL: " +optimizedMoneyManagement.stopLoss.toFixed(2) + "% | TP: " + optimizedMoneyManagement.takeProfit.toFixed(2) + "% " +
|
||||
"| R/R: " + (optimizedMoneyManagement.takeProfit / optimizedMoneyManagement.stopLoss).toFixed(2)
|
||||
}
|
||||
></CardText>
|
||||
</div>
|
||||
<Table
|
||||
columns={columns}
|
||||
data={rows}
|
||||
|
||||
Reference in New Issue
Block a user