Fix backtest delete and save
This commit is contained in:
@@ -47,11 +47,11 @@ public class BacktestRepository : IBacktestRepository
|
||||
|
||||
public void DeleteBacktestByIdForUser(User user, string id)
|
||||
{
|
||||
var backtest = _backtestRepository.FindById(id);
|
||||
var backtest = _backtestRepository.FindOne(b => b.Identifier == id);
|
||||
|
||||
if (backtest != null && backtest.User != null && backtest.User.Name == user.Name)
|
||||
{
|
||||
_backtestRepository.DeleteById(id);
|
||||
_backtestRepository.DeleteById(backtest.Id.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -22,5 +22,6 @@ namespace Managing.Infrastructure.Databases.MongoDb.Collections
|
||||
public UserDto User { get; set; }
|
||||
public PerformanceMetrics Statistics { get; set; }
|
||||
public double Score { get; set; }
|
||||
public string Identifier { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -14,7 +14,6 @@ using Managing.Domain.Users;
|
||||
using Managing.Domain.Workers;
|
||||
using Managing.Domain.Workflows.Synthetics;
|
||||
using Managing.Infrastructure.Databases.MongoDb.Collections;
|
||||
using MongoDB.Bson;
|
||||
using static Managing.Common.Enums;
|
||||
|
||||
namespace Managing.Infrastructure.Databases.MongoDb;
|
||||
@@ -145,7 +144,7 @@ public static class MongoMappers
|
||||
WinRate = b.WinRate,
|
||||
GrowthPercentage = b.GrowthPercentage,
|
||||
HodlPercentage = b.HodlPercentage,
|
||||
Id = b.Id.ToString(),
|
||||
Id = b.Identifier,
|
||||
OptimizedMoneyManagement = Map(b.OptimizedMoneyManagement),
|
||||
User = Map(b.User),
|
||||
Statistics = b.Statistics,
|
||||
@@ -164,7 +163,7 @@ public static class MongoMappers
|
||||
|
||||
return new BacktestDto
|
||||
{
|
||||
Id = (!string.IsNullOrEmpty(result.Id)) ? ObjectId.Parse(result.Id) : ObjectId.GenerateNewId(),
|
||||
Identifier = result.Id,
|
||||
FinalPnl = result.FinalPnl,
|
||||
WinRate = result.WinRate,
|
||||
GrowthPercentage = result.GrowthPercentage,
|
||||
|
||||
@@ -636,7 +636,7 @@ const UnifiedTradingModal: React.FC<UnifiedTradingModalProps> = ({
|
||||
scenarioName: customScenario ? undefined : form.scenarioName,
|
||||
timeframe: form.timeframe,
|
||||
isForWatchingOnly: form.isForWatchingOnly || false,
|
||||
flipPosition: false, // Default to false since we're only using isForWatchingOnly checkbox
|
||||
flipPosition: form.flipPosition || false,
|
||||
cooldownPeriod: form.cooldownPeriod,
|
||||
maxLossStreak: form.maxLossStreak,
|
||||
maxPositionTimeHours: form.maxPositionTimeHours,
|
||||
@@ -700,7 +700,7 @@ const UnifiedTradingModal: React.FC<UnifiedTradingModalProps> = ({
|
||||
useForDynamicStopLoss: form.useForDynamicStopLoss ?? true,
|
||||
moneyManagementName: showCustomMoneyManagement ? undefined : selectedMoneyManagement,
|
||||
moneyManagement: customMoneyManagement,
|
||||
flipPosition: form.isForWatchingOnly ?? false,
|
||||
flipPosition: form.flipPosition || false,
|
||||
};
|
||||
|
||||
const request: RunBacktestRequest = {
|
||||
@@ -1129,6 +1129,25 @@ const UnifiedTradingModal: React.FC<UnifiedTradingModalProps> = ({
|
||||
</div>
|
||||
|
||||
{/* Trading Options */}
|
||||
<FormInput
|
||||
label={
|
||||
<div className="flex items-center gap-2">
|
||||
Enable Position Flipping
|
||||
<div className="tooltip tooltip-top" data-tip="Allow the bot to flip between long and short positions based on signals. More aggressive trading strategy">
|
||||
<span className="badge badge-info badge-xs">i</span>
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
htmlFor="flipPosition"
|
||||
>
|
||||
<input
|
||||
type="checkbox"
|
||||
className="toggle toggle-primary"
|
||||
{...register('flipPosition')}
|
||||
/>
|
||||
</FormInput>
|
||||
|
||||
|
||||
<div className="grid grid-cols-1 md:grid-cols-2 gap-4">
|
||||
<FormInput
|
||||
label={
|
||||
@@ -1167,27 +1186,7 @@ const UnifiedTradingModal: React.FC<UnifiedTradingModalProps> = ({
|
||||
</FormInput>
|
||||
</div>
|
||||
|
||||
{/* Position Flipping (bot modes only) */}
|
||||
{mode !== 'backtest' && (
|
||||
<FormInput
|
||||
label={
|
||||
<div className="flex items-center gap-2">
|
||||
Enable Position Flipping
|
||||
<div className="tooltip tooltip-top" data-tip="Allow the bot to flip between long and short positions based on signals. More aggressive trading strategy">
|
||||
<span className="badge badge-info badge-xs">i</span>
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
htmlFor="flipPosition"
|
||||
>
|
||||
<input
|
||||
type="checkbox"
|
||||
className="toggle toggle-primary"
|
||||
{...register('flipPosition')}
|
||||
/>
|
||||
</FormInput>
|
||||
)}
|
||||
|
||||
|
||||
{/* Save Option (backtest mode only) */}
|
||||
{mode === 'backtest' && (
|
||||
<FormInput
|
||||
|
||||
Reference in New Issue
Block a user