From 54547bfd28f4c8d8d2cbce11dcb9af76b900c12d Mon Sep 17 00:00:00 2001 From: konard Date: Thu, 11 Sep 2025 10:14:33 +0300 Subject: [PATCH 1/3] Initial commit with task details for issue #245 Adding CLAUDE.md with task information for AI processing. This file will be removed when the task is complete. Issue: https://github.com/linksplatform/Bot/issues/245 --- CLAUDE.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 CLAUDE.md diff --git a/CLAUDE.md b/CLAUDE.md new file mode 100644 index 00000000..a385a7bc --- /dev/null +++ b/CLAUDE.md @@ -0,0 +1,5 @@ +Issue to solve: https://github.com/linksplatform/Bot/issues/245 +Your prepared branch: issue-245-4d69fcab +Your prepared working directory: /tmp/gh-issue-solver-1757574869564 + +Proceed. \ No newline at end of file From 8750f6602d70286e189934dca9dfd0bb0f133ff1 Mon Sep 17 00:00:00 2001 From: konard Date: Thu, 11 Sep 2025 10:14:51 +0300 Subject: [PATCH 2/3] Remove CLAUDE.md - PR created successfully --- CLAUDE.md | 5 ----- 1 file changed, 5 deletions(-) delete mode 100644 CLAUDE.md diff --git a/CLAUDE.md b/CLAUDE.md deleted file mode 100644 index a385a7bc..00000000 --- a/CLAUDE.md +++ /dev/null @@ -1,5 +0,0 @@ -Issue to solve: https://github.com/linksplatform/Bot/issues/245 -Your prepared branch: issue-245-4d69fcab -Your prepared working directory: /tmp/gh-issue-solver-1757574869564 - -Proceed. \ No newline at end of file From 6e38695bdb28e7bcf9cd897d4eaa32c10804f338 Mon Sep 17 00:00:00 2001 From: konard Date: Thu, 11 Sep 2025 10:31:28 +0300 Subject: [PATCH 3/3] Remove LoadOperationsFrom config setting and implement automatic calculation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The LoadOperationsFrom setting has been removed from configuration files and is now calculated automatically. The system uses the maximum of either the account open date or 30 days ago as the starting point for loading operations, preventing the need for manual updates that could cause errors. Changes: - Made LoadOperationsFrom nullable in TradingSettings - Removed LoadOperationsFrom from both appsettings files - Implemented automatic calculation logic in TradingService constructor - Updated README.md to remove documentation for the removed setting - Added informative logging for both configured and calculated values 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude --- csharp/TraderBot/README.md | 1 - csharp/TraderBot/TradingService.cs | 20 +++++++++++++++++--- csharp/TraderBot/TradingSettings.cs | 2 +- csharp/TraderBot/appsettings.TMON.json | 3 +-- csharp/TraderBot/appsettings.TRUR.json | 3 +-- 5 files changed, 20 insertions(+), 9 deletions(-) diff --git a/csharp/TraderBot/README.md b/csharp/TraderBot/README.md index 352b8b97..138fea35 100644 --- a/csharp/TraderBot/README.md +++ b/csharp/TraderBot/README.md @@ -78,7 +78,6 @@ Configuration is located in `appsettings.json` file. | `TradingSettings`/`MinimumMarketOrderSizeToSell` | Minimum size of the market order to sell. The price will be not acceptable unless there is that much lots on the market at this price. | | `TradingSettings`/`EarlySellOwnedLotsDelta` | A constant component of the minimum number of lots that the market order placed at the buy price should have in order to trigger the immediate sell order. Complete formula: (`TradingSettings`/`EarlySellOwnedLotsDelta` + `TradingSettings`/`EarlySellOwnedLotsMultiplier` * `Lots requested to sell`). | | `TradingSettings`/`EarlySellOwnedLotsMultiplier` | A multiplier of lots requested to sell. A component of the minimum number of lots that the market order placed at the buy price should have in order to trigger the immediate sell order. Complete formula: (`TradingSettings`/`EarlySellOwnedLotsDelta` + `TradingSettings`/`EarlySellOwnedLotsMultiplier` * `Lots requested to sell`). | -| `TradingSettings`/`LoadOperationsFrom` | Minimum data and time to load operations from. | ## Current default trading time-frame diff --git a/csharp/TraderBot/TradingService.cs b/csharp/TraderBot/TradingService.cs index 0302809b..1dad0292 100644 --- a/csharp/TraderBot/TradingService.cs +++ b/csharp/TraderBot/TradingService.cs @@ -62,8 +62,6 @@ public TradingService(ILogger logger, InvestApiClient investApi, Logger.LogInformation($"MaximumTimeToBuy: {MaximumTimeToBuy}"); Logger.LogInformation($"EarlySellOwnedLotsDelta: {settings.EarlySellOwnedLotsDelta}"); Logger.LogInformation($"EarlySellOwnedLotsMultiplier: {settings.EarlySellOwnedLotsMultiplier}"); - Logger.LogInformation($"LoadOperationsFrom: {settings.LoadOperationsFrom}"); - var currentTime = DateTime.UtcNow.TimeOfDay; Logger.LogInformation($"Current time: {currentTime}"); @@ -111,7 +109,23 @@ public TradingService(ILogger logger, InvestApiClient investApi, ActiveSellOrders = new ConcurrentDictionary(); LotsSets = new ConcurrentDictionary(); ActiveSellOrderSourcePrice = new ConcurrentDictionary(); - LastOperationsCheckpoint = settings.LoadOperationsFrom; + + // Calculate LoadOperationsFrom automatically if not provided + DateTime calculatedLoadOperationsFrom; + if (settings.LoadOperationsFrom.HasValue) + { + calculatedLoadOperationsFrom = settings.LoadOperationsFrom.Value; + Logger.LogInformation($"LoadOperationsFrom (from config): {calculatedLoadOperationsFrom}"); + } + else + { + // Use account open date or 30 days ago, whichever is more recent + DateTime accountOpenDate = DateTime.SpecifyKind(CurrentAccount.OpenedDate.ToDateTime(), DateTimeKind.Utc); + DateTime thirtyDaysAgo = DateTime.UtcNow.AddDays(-30); + calculatedLoadOperationsFrom = new[] { accountOpenDate, thirtyDaysAgo }.Max(); + Logger.LogInformation($"LoadOperationsFrom (calculated automatically): {calculatedLoadOperationsFrom}"); + } + LastOperationsCheckpoint = calculatedLoadOperationsFrom; } protected async Task ReceiveTrades(CancellationToken cancellationToken) diff --git a/csharp/TraderBot/TradingSettings.cs b/csharp/TraderBot/TradingSettings.cs index 884a25df..624cdda0 100644 --- a/csharp/TraderBot/TradingSettings.cs +++ b/csharp/TraderBot/TradingSettings.cs @@ -16,5 +16,5 @@ public class TradingSettings public string? MaximumTimeToBuy { get; set; } public long EarlySellOwnedLotsDelta { get; set; } public decimal EarlySellOwnedLotsMultiplier { get; set; } - public DateTime LoadOperationsFrom { get; set; } + public DateTime? LoadOperationsFrom { get; set; } } \ No newline at end of file diff --git a/csharp/TraderBot/appsettings.TMON.json b/csharp/TraderBot/appsettings.TMON.json index c7b66d7a..5ada1dae 100644 --- a/csharp/TraderBot/appsettings.TMON.json +++ b/csharp/TraderBot/appsettings.TMON.json @@ -23,7 +23,6 @@ "MinimumTimeToBuy": "00:00:01", "MaximumTimeToBuy": "23:59:59", "EarlySellOwnedLotsDelta": 300000, - "EarlySellOwnedLotsMultiplier": 0, - "LoadOperationsFrom": "2025-03-01T00:00:01.3389860Z" + "EarlySellOwnedLotsMultiplier": 0 } } diff --git a/csharp/TraderBot/appsettings.TRUR.json b/csharp/TraderBot/appsettings.TRUR.json index 1dc848e6..e71c06c9 100644 --- a/csharp/TraderBot/appsettings.TRUR.json +++ b/csharp/TraderBot/appsettings.TRUR.json @@ -23,7 +23,6 @@ "MinimumTimeToBuy": "09:00:00", "MaximumTimeToBuy": "14:45:00", "EarlySellOwnedLotsDelta": 300000, - "EarlySellOwnedLotsMultiplier": 0, - "LoadOperationsFrom": "2025-03-01T00:00:01.3389860Z" + "EarlySellOwnedLotsMultiplier": 0 } }