Add synthApi (#27)
* Add synthApi * Put confidence for Synth proba * Update the code * Update readme * Fix bootstraping * fix github build * Update the endpoints for scenario * Add scenario and update backtest modal * Update bot modal * Update interfaces for synth * add synth to backtest * Add Kelly criterion and better signal * Update signal confidence * update doc * save leaderboard and prediction * Update nswag to generate ApiClient in the correct path * Unify the trading modal * Save miner and prediction * Update messaging and block new signal until position not close when flipping off * Rename strategies to indicators * Update doc * Update chart + add signal name * Fix signal direction * Update docker webui * remove crypto npm * Clean
This commit is contained in:
@@ -45,7 +45,7 @@ namespace Managing.Application.ManageBot
|
||||
return _botRepository.GetBots().FirstOrDefault(b => b.Identifier == identifier);
|
||||
}
|
||||
|
||||
public void SaveOrUpdateBotBackup(User user, string identifier, BotType botType, BotStatus status, string data)
|
||||
public void SaveOrUpdateBotBackup(User user, string identifier, BotStatus status, string data)
|
||||
{
|
||||
var backup = GetBotBackup(identifier);
|
||||
|
||||
@@ -62,7 +62,6 @@ namespace Managing.Application.ManageBot
|
||||
LastStatus = status,
|
||||
User = user,
|
||||
Identifier = identifier,
|
||||
BotType = botType,
|
||||
Data = data
|
||||
};
|
||||
|
||||
@@ -118,40 +117,29 @@ namespace Managing.Application.ManageBot
|
||||
object bot = null;
|
||||
Task botTask = null;
|
||||
|
||||
switch (backupBot.BotType)
|
||||
var scalpingBotData = JsonConvert.DeserializeObject<TradingBotBackup>(backupBot.Data);
|
||||
|
||||
// Get the config directly from the backup
|
||||
var scalpingConfig = scalpingBotData.Config;
|
||||
|
||||
// Ensure the money management is properly loaded from database if needed
|
||||
if (scalpingConfig.MoneyManagement != null &&
|
||||
!string.IsNullOrEmpty(scalpingConfig.MoneyManagement.Name))
|
||||
{
|
||||
case BotType.ScalpingBot:
|
||||
case BotType.FlippingBot:
|
||||
var scalpingBotData = JsonConvert.DeserializeObject<TradingBotBackup>(backupBot.Data);
|
||||
var scalpingMoneyManagement =
|
||||
_moneyManagementService.GetMoneyMangement(scalpingBotData.MoneyManagement.Name).Result;
|
||||
|
||||
// Create config from backup data
|
||||
var scalpingConfig = new TradingBotConfig
|
||||
{
|
||||
AccountName = scalpingBotData.AccountName,
|
||||
MoneyManagement = scalpingMoneyManagement,
|
||||
Ticker = scalpingBotData.Ticker,
|
||||
ScenarioName = scalpingBotData.ScenarioName,
|
||||
Timeframe = scalpingBotData.Timeframe,
|
||||
IsForWatchingOnly = scalpingBotData.IsForWatchingOnly,
|
||||
BotTradingBalance = scalpingBotData.BotTradingBalance,
|
||||
BotType = scalpingBotData.BotType,
|
||||
Name = scalpingBotData.Name,
|
||||
CooldownPeriod = scalpingBotData.CooldownPeriod,
|
||||
MaxLossStreak = scalpingBotData.MaxLossStreak,
|
||||
MaxPositionTimeHours = scalpingBotData.MaxPositionTimeHours == 0m ? null : scalpingBotData.MaxPositionTimeHours,
|
||||
FlipOnlyWhenInProfit = scalpingBotData.FlipOnlyWhenInProfit,
|
||||
IsForBacktest = false,
|
||||
FlipPosition = false,
|
||||
CloseEarlyWhenProfitable = scalpingBotData.CloseEarlyWhenProfitable
|
||||
};
|
||||
|
||||
bot = CreateTradingBot(scalpingConfig);
|
||||
botTask = Task.Run(() => InitBot((ITradingBot)bot, backupBot));
|
||||
break;
|
||||
var moneyManagement = _moneyManagementService
|
||||
.GetMoneyMangement(scalpingConfig.MoneyManagement.Name).Result;
|
||||
if (moneyManagement != null)
|
||||
{
|
||||
scalpingConfig.MoneyManagement = moneyManagement;
|
||||
}
|
||||
}
|
||||
|
||||
// Ensure critical properties are set correctly for restored bots
|
||||
scalpingConfig.IsForBacktest = false;
|
||||
|
||||
bot = CreateTradingBot(scalpingConfig);
|
||||
botTask = Task.Run(() => InitBot((ITradingBot)bot, backupBot));
|
||||
|
||||
if (bot != null && botTask != null)
|
||||
{
|
||||
var botWrapper = new BotTaskWrapper(botTask, bot.GetType(), bot);
|
||||
@@ -258,14 +246,14 @@ namespace Managing.Application.ManageBot
|
||||
|
||||
// Update the bot configuration first
|
||||
var updateResult = await tradingBot.UpdateConfiguration(newConfig, allowNameChange: true);
|
||||
|
||||
|
||||
if (updateResult)
|
||||
{
|
||||
// Update the dictionary key
|
||||
if (_botTasks.TryRemove(identifier, out var removedWrapper))
|
||||
{
|
||||
_botTasks.TryAdd(newConfig.Name, removedWrapper);
|
||||
|
||||
|
||||
// Update the backup with the new identifier
|
||||
if (!newConfig.IsForBacktest)
|
||||
{
|
||||
@@ -275,7 +263,7 @@ namespace Managing.Application.ManageBot
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return updateResult;
|
||||
}
|
||||
else
|
||||
@@ -288,7 +276,6 @@ namespace Managing.Application.ManageBot
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public ITradingBot CreateTradingBot(TradingBotConfig config)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user