Commit Graph

82 Commits

Author SHA1 Message Date
0428775abf Excellent! Everything builds successfully. Let me create a summary of all the changes:
## Summary of Changes

I've successfully moved the `GetBacktestStats` endpoint to the `DataController` and removed JWT authentication. Here's what was done:

### 1. **Moved GetBacktestStats Endpoint to DataController** 
- **File**: `src/Managing.Api/Controllers/DataController.cs:1064`
- **Endpoint**: `GET /Data/GetBacktestStats/{id}`
- **Authentication**: None required (DataController has `[AllowAnonymous]`)
- Returns only statistical information without positions, signals, or candles

### 2. **Added IBacktester Dependency to DataController** 
- **File**: `src/Managing.Api/Controllers/DataController.cs:45,87`
- Added `IBacktester` field and constructor parameter
- Allows DataController to retrieve backtest information

### 3. **Created New Repository Method** 
- **Interface**: `src/Managing.Application.Abstractions/Repositories/IBacktestRepository.cs:41`
- **Implementation**: `src/Managing.Infrastructure.Database/PostgreSql/PostgreSqlBacktestRepository.cs:301`
- Added `GetBacktestByIdAsync(string id)` - retrieves backtest without user filtering

### 4. **Created New Service Method** 
- **Interface**: `src/Managing.Application.Abstractions/Services/IBacktester.cs:67`
- **Implementation**: `src/Managing.Application/Backtests/Backtester.cs:221`
- Added `GetBacktestByIdAsync(string id)` in IBacktester service

### 5. **Removed Duplicate Endpoint from BacktestController** 
- **File**: `src/Managing.Api/Controllers/BacktestController.cs`
- Removed the `/Backtest/{id}/stats` endpoint to avoid duplication

### 6. **Regenerated Frontend API Client** 
- Successfully ran `dotnet build` in `src/Managing.Nswag`
- The new endpoint is now available in `ManagingApi.ts`

## API Endpoint Details

**Endpoint**: `GET /Data/GetBacktestStats/{id}`

**Authentication**: None (AllowAnonymous)

**Response Format**:
```json
{
  "id": "string",
  "name": "string",
  "ticker": "BTC",
  "timeframe": "15m",
  "tradingType": "Futures",
  "startDate": "2024-01-01T00:00:00Z",
  "endDate": "2024-12-31T23:59:59Z",
  "initialBalance": 1000,
  "finalPnl": 150.50,
  "netPnl": 145.25,
  "growthPercentage": 14.5,
  "hodlPercentage": 12.3,
  "winRate": 65,
  "sharpeRatio": 1.8,
  "maxDrawdown": -5.2,
  "maxDrawdownRecoveryTime": "2.00:00:00",
  "fees": 5.25,
  "score": 85.5,
  "scoreMessage": "Good performance",
  "positionCount": 150
}
```

All changes have been tested and the project builds successfully!
2026-01-09 19:18:52 +07:00
07fb67c535 Enhance DataController to support status filtering in GetStrategiesPaginated method
- Added an optional status parameter to the GetStrategiesPaginated method, defaulting to Running if not provided.
- Updated the bot retrieval logic to apply the status filter directly, simplifying the filtering process and ensuring accurate bot status management.
2026-01-09 03:54:20 +07:00
8d4be59d10 Update ProfitAndLoss calculation in BotController and DataController to use NetPnL
- Changed the ProfitAndLoss property assignment from item.Pnl to item.NetPnL in both BotController and DataController, ensuring consistency in profit and loss reporting across the application.
2026-01-08 07:01:49 +07:00
a227c72e1f Enhance trading bot functionality and LLM system message clarity
- Added BotTradingBalance property to UserStrategyDetailsViewModel for better tracking of bot allocations.
- Updated DataController to include BotTradingBalance in the response model.
- Improved LlmController by refining the system message to ensure LLM understands its response capabilities and tool usage.
- Introduced new MCP tools for running and analyzing bundle backtests, enhancing backtesting capabilities for users.
- Implemented security measures in BotTools to ensure users can only access their own bots, improving data privacy.
2026-01-04 23:26:59 +07:00
18373b657a Add min and max balance filters to bot management
- Introduced optional parameters for minimum and maximum BotTradingBalance in BotController, DataController, and related services.
- Updated interfaces and repository methods to support filtering by BotTradingBalance.
- Enhanced TradingBotResponse and BotEntity models to include BotTradingBalance property.
- Adjusted database schema to accommodate new BotTradingBalance field.
- Ensured proper mapping and handling of BotTradingBalance in PostgreSQL repository and mappers.
2026-01-01 21:32:05 +07:00
bcb00b9a86 Refactor pagination sorting parameters across multiple controllers and services to use the new SortDirection enum; update related API models and TypeScript definitions for consistency. Fix minor documentation and naming inconsistencies in the Bot and Data controllers. 2025-12-14 20:23:26 +07:00
c4e444347c Fix bot update with the tradingtype 2025-12-13 14:46:30 +07:00
Oda
9d536ea49e Refactoring TradingBotBase.cs + clean architecture (#38)
* Refactoring TradingBotBase.cs + clean architecture

* Fix basic tests

* Fix tests

* Fix workers

* Fix open positions

* Fix closing position stucking the grain

* Fix comments

* Refactor candle handling to use IReadOnlyList for chronological order preservation across various components
2025-12-01 19:32:06 +07:00
4b5c1c5ce0 Fix graph 2025-11-25 11:03:52 +07:00
2a354bd7d2 Implement profitable bots filtering in BotController and DataController
- Added IConfiguration dependency to BotController for accessing environment variables.
- Updated GetBotsPaginatedAsync method in BotService and IBotService to include a flag for filtering profitable bots.
- Modified DataController to utilize the new filtering option for agent summaries and bot retrieval.
- Enhanced PostgreSqlBotRepository to apply filtering based on profitability when querying bots.
2025-11-22 14:02:29 +07:00
e69dd43ace Enhance DataController and BotService with new configuration and bot name checks
- Added IConfiguration dependency to DataController for environment variable access.
- Updated GetPaginatedAgentSummariesCommand to include a flag for filtering profitable agents.
- Implemented HasUserBotWithNameAsync method in IBotService and BotService to check for existing bots by name.
- Modified StartBotCommandHandler and StartCopyTradingCommandHandler to prevent duplicate bot names during strategy creation.
2025-11-22 13:34:26 +07:00
53f81302ba Return last 24 volume for strategies 2025-11-21 17:02:18 +07:00
1bec83a2ec Add MasterAgentName to UserStrategyDetailsViewModel and DataController
- Updated UserStrategyDetailsViewModel to include MasterAgentName property, which represents the agent name of the master bot's owner for copy trading bots.
- Modified DataController to populate the MasterAgentName field when returning strategy details.
2025-11-21 14:28:19 +07:00
ff2df2d9ac Add MasterBotUserId and MasterAgentName for copy trading support
- Introduced MasterBotUserId and MasterAgentName properties to facilitate copy trading functionality.
- Updated relevant models, controllers, and database entities to accommodate these new properties.
- Enhanced validation logic in StartCopyTradingCommandHandler to ensure proper ownership checks for master strategies.
2025-11-20 00:33:31 +07:00
3b176c290c Update precalculated indicators values 2025-11-12 23:26:12 +07:00
51a227e27e Improve perf for backtests 2025-11-10 02:15:43 +07:00
d144ae73ca Add name to ticker list 2025-10-20 16:26:01 +07:00
82f8057ed1 Fix loss and win count for GetUserStrategy 2025-10-10 17:37:32 +07:00
3128e3e9d9 Add cache for position 2025-10-10 02:48:50 +07:00
f30cc7dc47 Fix get tickers 2025-10-07 02:34:42 +07:00
f43117e6c6 Add strategies paginated 2025-10-07 01:21:25 +07:00
746308bc4f Remove get best agent 2025-10-06 18:31:29 +07:00
dab4807334 Fix Runtime 2025-10-06 00:55:18 +07:00
f67ee330b3 Fix Runtime by adding TotalRuntimeInSeconds 2025-10-05 20:51:46 +07:00
faec7e2e5a Fix win and loses count 2025-10-05 03:21:59 +07:00
7c13ad5f06 Update Agent balance tracking 2025-10-03 15:30:39 +07:00
58b07a1a13 Add netPnl in db for position 2025-10-03 03:11:17 +07:00
06850b57c4 Add BacktestCount 2025-10-01 13:01:03 +07:00
5953b96a38 Fix fetch userStrategies 2025-09-29 00:59:29 +07:00
e2d7e75247 Remove endpoint update generatedClient 2025-09-29 00:55:59 +07:00
f041c1e8e8 Add net Pnl in db 2025-09-28 22:18:58 +07:00
16a56bd26c Add agent fees 2025-09-28 20:57:42 +07:00
2d403da28f Update naming and remove used calls 2025-09-28 15:59:11 +07:00
147186724e Rename a bit for more clarity 2025-09-28 14:18:56 +07:00
8b0970fc7b Fix get UserStrategies 2025-09-26 12:48:29 +07:00
c297429b18 Fix bot TOP 3 2025-09-25 11:08:28 +07:00
d2a4bd4426 Fix dailySnapshot for platformsummary 2025-09-24 12:21:56 +07:00
9bdfb989c1 Fix ROI 2025-09-24 01:19:10 +07:00
2e953ddf77 Add AgentBalance to UserStrategies endpoint 2025-09-17 15:15:26 +07:00
Oda
56b4f14eb3 Price reminder and init approval
* Start price reminder grain

* Add config and init grain at startup

* Save init wallet when already init
2025-09-13 02:29:14 +07:00
cb6778d9a0 Add ticker to the UserStrategies list and set debit credit to 1 for backtest 2025-09-10 20:41:36 +07:00
82fa0d20d2 Add more errors 2025-08-20 00:14:26 +07:00
137444a045 Add best agent by pnl 2025-08-15 22:35:29 +07:00
cd93dede4e Add agentbalance 2025-08-15 19:35:01 +07:00
8eefab4597 Fix concurrent on userStrategies 2025-08-15 08:56:32 +07:00
b4a4656b3b Update the position count and initiator 2025-08-15 08:47:48 +07:00
0a4a4e1398 Update plateform summary 2025-08-15 06:54:09 +07:00
4a45d6c970 Add platform grain 2025-08-14 19:44:33 +07:00
345d76e06f Update plateform summary 2025-08-14 18:59:37 +07:00
6a2e4e81b1 Update status to match UI 2025-08-14 18:08:31 +07:00