diff --git a/README.md b/README.md
index 354145c..ffcc224 100644
--- a/README.md
+++ b/README.md
@@ -1,8 +1,9 @@
# Introduction
-Managing App is a bot management application written using C# and Typescript. First goal was to be able to run an infinite
+Managing App is a bot management application written using C# and Typescript. First goal was to be able to run an
+infinite
number of Bot without any limitations (will depend on your server capabilities only)
-It is designed to support multiples exchanges and be controlled via webUI or Discord.
+It is designed to support multiples exchanges and be controlled via webUI or Discord.
It contains bot management, backtesting, scenario management and money management..
---
@@ -10,8 +11,9 @@ It contains bot management, backtesting, scenario management and money managemen
# Roadmap
## v1 - The base
-- [x] Bot management
-- [x] Backtesting
+
+- [x] Bot management
+- [x] Backtesting
- [x] MoneyManagement
- [x] Strategies systems
- [x] WebUI
@@ -21,36 +23,46 @@ It contains bot management, backtesting, scenario management and money managemen
- [x] Workers (prices, backtests, volumes)
## v2 - The custody back
+
- [x] Web3 Authentification
- [x] Hot-wallets management
- [x] Chainlink and Subgraphs feeds
- [x] [GMX Contracts integration](https://gmx.io/)
+- [ ] GMX v2 Contracts integration
+
+### v2.1
-### v2.1
- [x] Tools : RektFees, Spotlight
-- [ ] Address tracking
+- [x] Funding Rates
- [ ] Strategies optimisation
+- [ ] Delta neutral positions
+- [ ] Address tracking
- [ ] Trading desk
- [ ] Metrics (backtests, portofolio)
- [ ] Enhance performances
- [ ] Dockerize everything
### v2.2
+
- [ ] Hedging Bot with Options [HegicOption](https://www.hegic.co/)
- [ ] Market making
## v3 - The bitcoin protocol
+
- [ ] Integrate [LNMarkets](https://lnmarkets.com/)
## v4 - The omnipotence
+
- [ ] Connect to [Blockstream Satellite](https://blockstream.com/satellite/)
# Stack
## Architecture
+

## Front-end
+
- [Vite.JS](https://vitejs.dev/)
- [Tailwindcss](https://tailwindcss.com/)
- [Daisy UI](https://daisyui.com/)
@@ -63,6 +75,7 @@ It contains bot management, backtesting, scenario management and money managemen
- [Connectkit](https://github.com/family/connectkit)
## Back-end
+
- .NET 7
- [SignalR](https://dotnet.microsoft.com/en-us/apps/aspnet/signalr)
- [Discord.Net](https://github.com/discord-net/Discord.Net)
@@ -74,36 +87,42 @@ It contains bot management, backtesting, scenario management and money managemen
---
# Features
+
## Money Management
+
- Create a defined money management for a given timeframe (StopLoss, TakeProfit, Amount to risk)
- Edit a money management configuration
- Delete a configuration
## Strategies
+
- Build a strategy
- Delete strategy
Strategies availables :
-| Strategy | Description | Recommanded values |
-| ----------- | ----------- | ----------- |
-| RsiDivergence | Trigger a signal when a divergence occurs on the period | Period : 4 for 6|
-| RsiDivergenceConfirm | First, detect a divergence and trigger a signal when the divergence is confirmed. The confirmation happen for a LONG when the price close above the candle in divergence. The loopback period is based on the period parameter. | Period : 4 for 6|
-| MACDCross | Trigger a signal when EMAs cross | FastPeriod : 12, SlowPeriods : 26, SignalPeriods : 9|
-| SuperTrend | Trigger a SHORT signal when previous candle is above the super trend and the last candle close below the super trend | Period : 10, Multiplier : 3 |
-| ChandelierExit | Trigger a SHORT signal when previous candle is above the ChandelierExit and the last candle close below the ChandelierExit | Period : 22, Multiplier : 3 |
-| EMACross | Trigger a signal when last candle cross the EMA | Period : 200 |
-| EMATrend | Return a Trend signal SHORT when last candle is below the EMA and return a Trend LONG signal when StochRSI < 20% | Period : 200 |
-| StochRsiTrend | Return a Trend signal SHORT when Stoch RSI > 80% and return a Trend LONG signal when StochRSI < 20% | Period : 22 |
-| STC | Return a signal SHORT when previous STC > 75% and current STC <= 75% | Period : 22 |
+| Strategy | Description | Recommended values |
+|----------------------|------------------------------------------------------------------------------------------------------------------------------------|---------------------------------------------------|
+| ChandelierExit | Triggers a SHORT signal when the previous candle is above the ChandelierExit, and the last candle closes below the ChandelierExit. | Period: 22, Multiplier: 3 |
+| EMACross | Triggers a signal when the last candle crosses the EMA. | Period: 200 |
+| EMATrend | Returns a Trend signal SHORT when the last candle is below the EMA, and a Trend LONG signal when StochRSI < 20%. | Period: 200 |
+| MACDCross | Triggers a signal when EMAs cross. | FastPeriod: 12, SlowPeriods: 26, SignalPeriods: 9 |
+| RSIDivergenceConfirm | First, detects a divergence and then triggers a signal when the divergence is confirmed. | Period: 4 for 6 |
+| RSIDivergence | Triggers a signal when a divergence occurs on the period. | Period: 4 for 6 |
+| STC | Returns a signal SHORT when the previous STC > 75% and the current STC <= 75%. | Period: 22 |
+| StochRsiTrend | Returns a Trend signal SHORT when Stoch RSI > 80% and a Trend LONG signal when StochRSI < 20%. | Period: 22 |
+| SuperTrend | Triggers a SHORT signal when the previous candle is above the super trend, and the last candle closes below the super trend. | Period: 10, Multiplier: 3 |
+| ThreeWhiteSoldiers | Triggers a LONG signal when the Three White Soldiers pattern is identified. | Lookback Period: 3 |
## Scenarios
+
- Build a scenario with multiple strategies
- Delete a scenario
## Backtests
The backtest system works with multiple required parameters :
+
- Exchange (Binance, Kraken, FTX)
- Ticker (ADAUSDT, BTCUSDT, etc..)
- Days : Since when did you want to start backtest. Should be a negative value
@@ -122,8 +141,8 @@ The backtest system works with multiple required parameters :
Bot types availables :
-| Type | Description |
-| ----------- | ----------- |
-| ScalpingBot | This bot will open position and wait before opening a new one |
+| Type | Description |
+|-------------|----------------------------------------------------------------------------------------|
+| ScalpingBot | This bot will open position and wait before opening a new one |
| FlippingBot | The flipping bot flipping the position only when a strategy trigger an opposite signal |
diff --git a/assets/Todo-v2.md b/assets/Todo-v2.md
index e6e2068..aba1026 100644
--- a/assets/Todo-v2.md
+++ b/assets/Todo-v2.md
@@ -1,23 +1,30 @@
-# V2
+# V2
+
## Done
+
### Adaptive mode
+
- [x] Create a risk mode 'Adaptive' to be able to not use save moneymanagement settings
-- [x] Adaptive mode will force Bot to determine SL by getting the previous highest price on the period (prevent choppy price on good entry)
+- [x] Adaptive mode will force Bot to determine SL by getting the previous highest price on the period (prevent choppy
+ price on good entry)
- [x] Create account (type, exchange, key, secret)
- [x] Update trading bot to handle one account
- [x] Remove exchange from bot. Exchange will be set on the account
- [x] Update ftxClient to not use Managingbot subaccount
-- [x] Update exchangeService to handle account
-- [x] Dynamic Ticker selection base on best volumes on the exchanges
+- [x] Update exchangeService to handle account
+- [x] Dynamic Ticker selection base on best volumes on the exchanges
- [x] Create endpoint to get the ticker list for the frontend
- [x] Create method in application to get best bid and best ask
- [x] Submit only limit with IOC
- [x] Implement Poly to have a retry policy for limit order ioc execution => Unsure position is open
-- [x] For openOrder inject a parameter to select the ioc mode. If risk is adaptive we just place the order a the price without forcing the position opening
+- [x] For openOrder inject a parameter to select the ioc mode. If risk is adaptive we just place the order a the price
+ without forcing the position opening
- [x] Integrate STC signals
-### Web3
+
+### Web3
+
- [x] Integrate wallet management from backend side
-- [x] Integrate wagmi/connectkit
+- [x] Integrate wagmi/connectkit
- [x] Sign message with connectkit
- [x] On wallet connect, check if token is not expired
- [x] User can have multiple address
@@ -25,34 +32,37 @@
- [x] Hide key/secret if evm exchange is selected
- [x] Generate pub/priv key on evm account creation and store it into mongo
- [x] Get balance for an address
-- [x] Handle multi-chain
+- [x] Handle multi-chain
- [x] Add arbitrum testnet for backend
- [x] User can withdraw found to the connected address of the user
- [x] Implement get balance with chainlink feed
- [x] Abstract subgraph management
- [x] Get price from multiple price feeds subgraph
- [x] Add to ExchangeService GetAvailableTicker()
-- [x] Add get token list method to EvmManager
+- [x] Add get token list method to EvmManager
- [x] Setup worker to save candles into db
- [x] Open trade -> CreateIncreaseOrder
- [x] Close trade -> CreateDecreasePosition
-- [x] Close all orders
+- [x] Close all orders
- [x] Create SL & TP -> CreateDecreaseOrder
-- [x] Get Fees -> Estimate Tx cost
+- [x] Get Fees -> Estimate Tx cost
- [x] Adapt GetBalance to retrieve stablecoin amount
- [x] Create worker to fetch GMX leaderboard -> LeaderboardWorker
- [x] Leaderboard will create PositionUpdate message bus to deposit a message with all information to open a trade
- [x] Create bot type CopyTrading to receive PositionUpdate bus message and open position based on criteria
- [x] CopyTrading bot will send an OpenPosition button on Discord if he's set to watchOnly
-- [x] Fix : Trim address, give name to address, decrease amount bug,
-- [x] Display best last backtests ran by backtester workers
+- [x] Fix : Trim address, give name to address, decrease amount bug,
+- [x] Display best last backtests ran by backtester workers
- [x] Refactor GetAccounts/GetAccount to handle the user
- [x] AccountType : Binance/EvmTrador/EvmWatch/EvmPersonal
-- [x] Make better abstration of the Database projects (influx, mongodb) to Remove the link between Application and Infrastructure
+- [x] Make better abstration of the Database projects (influx, mongodb) to Remove the link between Application and
+ Infrastructure
- [x] Implement strategy pattern for exchange processors
- [x] Use cache for position and signal
- [x] Don't run update Signal and manage position if no new candle
+
### Workers
+
- [x] Add Influxdb
- [x] Create workers for scrap data (per ticker, per exchange, per timeframe)
- [x] Use candle from influxdb for backtests and bots
@@ -60,11 +70,13 @@
- [x] Scrap candle only for crypto with high volume
- [x] Create a worker that run backtest and save it in db
-### Front-end
+### Front-end
+
- [x] Return list of balances with tokens/chains data
- [x] On account line click, display tokens by chain available
- [x] Call Available ticker to produce the droplist
-- [x] Display multipanes https://github.com/qwpto/lightweight-charts-panels / https://codesandbox.io/s/react-typescript-forked-mxek17?file=/src/App.tsx / https://github.com/Rassibassi/multipane_tradingview
+- [x] Display
+ multipanes https://github.com/qwpto/lightweight-charts-panels / https://codesandbox.io/s/react-typescript-forked-mxek17?file=/src/App.tsx / https://github.com/Rassibassi/multipane_tradingview
- [x] Display last open position with lines (add SL and TP)
- [x] Fix double charts problem (has been fixed by removing strict mode)
- [x] Try to pass the tailwind current theme color to the chart
@@ -76,32 +88,38 @@
- [x] Add input to specify the account balance. If not set, it will use the selected account balance
# The rest
+
## Part 1 : Adaptive trading
+
- [x] From backtests list : Determine TP and Stop loss % by getting average profit and average lost for a signal
- [x] Modify bot to use MoneyManagement object instead of using the risk associated to the signal.
-- [x] Bot object should return MoneyManagement object
-- [ ] Strategy can return a suggested trade that will give the best orders to execute
+- [x] Bot object should return MoneyManagement object
+- [ ] Strategy can return a suggested trade that will give the best orders to execute
## Part 2 : Workflows builder
+
- [x] Create a workflow type that will encapsulate a list of flows
- [x] Each flow will have parameters, inputs and outputs that will be used by the children flows
-- [ ] Flow can handle multiple parents
+- [ ] Flow can handle multiple parents
- [ ] Run Simple bot base on a workflow
- [ ] Run backtest based on a workflow
- [ ] Add flows : ClosePosition, Scenario
## Part 2 : Strategies optimisation
+
- [ ] Optimize all strategies with more data (funding rate trend, bbwp, etc..)
- [ ] Optimize entry by getting last ask price and place an order limit to match directly with it
-- [ ] Add bbwp indicator => PR example : https://github.com/DaveSkender/Stock.Indicators/pull/893/files#diff-df1cd2a99846f7328c9fc3db4d2c164380a0fa943cdcad2ece01b886cac68137
+- [ ] Add bbwp indicator => PR
+ example : https://github.com/DaveSkender/Stock.Indicators/pull/893/files#diff-df1cd2a99846f7328c9fc3db4d2c164380a0fa943cdcad2ece01b886cac68137
- [ ] Create strategies types from signal (a divergence) / trend (stoch long or short) / context (high vol/low vol)
-- [ ] Create a trend strategy on fundinrate -> long trend if negativ fr / short trend if positiv fr
+- [ ] Create a trend strategy on fundinrate -> long trend if negativ fr / short trend if positiv fr
- [ ] Add entry/exit price to signal for adaptive risk
- [ ] MACD: Open only when candle is not a big move to avoid late entry (only enter when low vol)
- [ ] Improve strategy composability by using delegate pattern
## Part 3 : Backtests automation
-- [ ] Create a worker that determine best TP and SL
+
+- [ ] Create a worker that determine best TP and SL
- [ ] Create a page 'Analyze' to show the best TP and SL for multiple backtest result
- [ ] Implement reverseSignal to close and flip the trade
- [ ] Load signal from database
@@ -114,30 +132,45 @@
_______________________________________________________________________________________________________________
-# Phase 2 - Web3
-## 1 - Wallet management
+# Phase 2 - Web3
+
+## 1 - Wallet management
+
- [ ] User can deposit token to and evm account with a QR code or clicking on button to copy the address
+- [ ] Add account abstraction to level up security
+
## 2 - [Track address](https://github.com/users/CryptoOda/projects/1/views/1?pane=issue&itemId=32158941)
+
- [ ] Create a snapshot of the account balances with BalancesWorker
- [ ] Display balance in $ evolution per token hold on the account page
+
## 3 - Settings [Link](https://github.com/users/CryptoOda/projects/1/views/1?pane=issue&itemId=32159287)
+
- [ ] Save theme into database
-- [ ] Call GET Settings/Theme to retrieve the theme used by the user
+- [ ] Call GET Settings/Theme to retrieve the theme used by the user
+
## 4 - Trading desk [Link](https://github.com/users/CryptoOda/projects/1/views/1?pane=issue&itemId=11070087)
+
- [x] Live data position hub
-- [x] Live candles
+- [x] Live candles
- [x] Open position from desk
+
## 5 - Live liquidation map
+
- [ ] Create worker to aggregate binance/okx liquidation
- [ ] Render liquidation map with a hub subscription to get live update
-- [ ] Live data signal
+- [ ] Live data signal
- [ ] Display massive liquidation on TradeChartWidget
+
## 6 - Metrics [Link](https://github.com/users/CryptoOda/projects/1/views/1?pane=issue&itemId=32159107)
+
- [ ] Create a worker that get top 5 cryptos by scenario
- [ ] Create worker to store portofolio evolution
-- [ ] Display portofolio evolution
+- [ ] Display portofolio evolution
- [ ] Create a worker to scrap funding fees over time (per ticker, per exchange)
+
## 7 - Improvement [Link](https://github.com/users/CryptoOda/projects/1/views/1?pane=issue&itemId=32159127)
+
- [ ] Handling user on every object => Use the JWT token to inject the userName
- [ ] Extract BacktestReport from tests to a Tools projects
- [ ] Factorize amount management for GMX Service
@@ -152,37 +185,56 @@ ________________________________________________________________________________
- [ ] Implement from/to tickers array pattern
- [ ] Extract all managing trade method into a TradingBox class => Create composable trading bot type easily
- [ ] Bot backup worker: Every x, get saved bots and check if still running. If not running call api to reboot bot.
-- [ ] Create worker to fetch the biggest spread between long\short funding rate and send alert when most profitable delta neutral position is found
+- [ ] Create worker to fetch the biggest spread between long\short funding rate and send alert when most profitable
+ delta neutral position is found
+
+# Front-end
-# Front-end
## Improve Account page
+
- [ ] Display total balances (only trader account) on Settings->Accounts Page
-- [ ] On Token Account details line -> Add button to withdraw money (this will open a Modal to prompt the address/amount that will receive the money)
-## Charts
+- [ ] On Token Account details line -> Add button to withdraw money (this will open a Modal to prompt the
+ address/amount that will receive the money)
+
+## Charts
+
- [ ] Add multi-timeframe options
- [ ] Display optionnal indicators on charts
- [ ] Display current selected position (when i click on a Position in the list)
+
## Trading desk
+
- [ ] WAIT - Create a button to open a hedge on option market
- [ ] Get global exposure ((total position / total balances *) 100)
- [ ] Display multiple tab to show different tickers
+
## Scenarios
+
- [x] Create a blocky-like editor to create scenarios https://google.github.io/blockly-samples/
+
## Bots
+
- [ ] Add button to display money management use by the bot
- [ ] On the modal, When simple bot selected, show only a select for the workflow
+
## Backtests
+
- [x] Display the money management used by the backtest
-## Technical front-end :
+
+## Technical front-end :
+
- [ ] Implement alias to reduce 'import' lines https://github.com/subwaytime/vite-aliases
- [ ] Make Get Accounts List as a store
- [ ] Replace all html-tag Modals (ex: BacktestPlayground.tsx)
- [ ] Refactoring Components :
-- organism : Put all the code related to the app (Trade charts etc). This folder should be delete when the project is forked
+- organism : Put all the code related to the app (Trade charts etc). This folder should be delete when the project is
+ forked
- mollecules : Put aggregate of atoms to create forms/modal/table
-- atoms : Put all basic html tag components (List, Select, Slider...)
+- atoms : Put all basic html tag components (List, Select, Slider...)
+
## Workflow
-- [x] List all workflow saved in
+
+- [x] List all workflow saved in
- [x] Use https://reactflow.dev/ to display a workflow (map flow to nodes and children to edges)
- [x] On update Nodes : https://codesandbox.io/s/dank-waterfall-8jfcf4?file=/src/App.js
- [x] Save workflow
@@ -195,7 +247,7 @@ ________________________________________________________________________________
# Technicals
-- [ ] Remove mediator
+- [ ] Remove mediator
- [ ] Check Traefik : https://www.cloudbees.com/blog/setting-up-traefik-as-a-reverse-proxy-for-asp-net-applications
- [ ] Implement IHostedService/BackgroundService to run bot in background https://www.youtube.com/watch?v=fw-n2RkzOMI
- [ ] Implement Microsoft Orleans
diff --git a/src/Managing.Api.Workers/Workers/TraderWatcher.cs b/src/Managing.Api.Workers/Workers/TraderWatcher.cs
index b9f2132..bfd851f 100644
--- a/src/Managing.Api.Workers/Workers/TraderWatcher.cs
+++ b/src/Managing.Api.Workers/Workers/TraderWatcher.cs
@@ -5,11 +5,21 @@ using static Managing.Common.Enums;
namespace Managing.Api.Workers.Workers;
+///
+/// Represents a worker that watches traders and performs actions based on trading activities.
+/// Inherits from where TWorker is .
+///
public class TraderWatcher : BaseWorker
{
private readonly ITradingService _tradingService;
private static readonly WorkerType _workerType = WorkerType.TraderWatcher;
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ /// The logger to be used by the worker.
+ /// The trading service to monitor trading activities.
+ /// The worker service to manage worker lifecycle.
public TraderWatcher(
ILogger logger,
ITradingService tradingService,
@@ -23,8 +33,12 @@ public class TraderWatcher : BaseWorker
_tradingService = tradingService;
}
+ ///
+ /// Executes the worker's task to watch traders. This method is called periodically based on the worker's configured interval.
+ ///
+ /// A token to observe while waiting for the task to complete.
protected override async Task Run(CancellationToken cancellationToken)
{
await _tradingService.WatchTrader();
}
-}
+}
\ No newline at end of file
diff --git a/src/Managing.Api/Controllers/AccountController.cs b/src/Managing.Api/Controllers/AccountController.cs
index 845355e..b961a25 100644
--- a/src/Managing.Api/Controllers/AccountController.cs
+++ b/src/Managing.Api/Controllers/AccountController.cs
@@ -5,11 +5,20 @@ using Microsoft.AspNetCore.Mvc;
namespace Managing.Api.Controllers
{
+ ///
+ /// Provides endpoints for account management operations such as creating, retrieving, and deleting accounts.
+ /// Requires authorization for access.
+ ///
[Authorize]
public class AccountController : BaseController
{
private readonly IAccountService _AccountService;
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ /// Service for account-related operations.
+ /// Service for user-related operations.
public AccountController(
IAccountService AccountService,
IUserService userService)
@@ -18,6 +27,11 @@ namespace Managing.Api.Controllers
_AccountService = AccountService;
}
+ ///
+ /// Creates a new account for the authenticated user.
+ ///
+ /// The account details to create.
+ /// The created account details.
[HttpPost]
public async Task> PostAccount(Account Account)
{
@@ -25,6 +39,10 @@ namespace Managing.Api.Controllers
return Ok(await _AccountService.CreateAccount(user, Account));
}
+ ///
+ /// Retrieves all accounts associated with the authenticated user.
+ ///
+ /// A list of accounts.
[HttpGet]
[Route("accounts")]
public async Task>> GetAccounts()
@@ -33,6 +51,10 @@ namespace Managing.Api.Controllers
return Ok(_AccountService.GetAccountsByUser(user, true));
}
+ ///
+ /// Retrieves the balances of all accounts associated with the authenticated user.
+ ///
+ /// A list of accounts with their balances.
[HttpGet]
[Route("balances")]
public async Task>> GetAccountsBalances()
@@ -41,6 +63,11 @@ namespace Managing.Api.Controllers
return Ok(_AccountService.GetAccountsBalancesByUser(user));
}
+ ///
+ /// Retrieves a specific account by name for the authenticated user.
+ ///
+ /// The name of the account to retrieve.
+ /// The account details if found.
[HttpGet]
public async Task> GetAccount(string name)
{
@@ -48,6 +75,11 @@ namespace Managing.Api.Controllers
return Ok(await _AccountService.GetAccountByUser(user, name, true, true));
}
+ ///
+ /// Deletes a specific account by name for the authenticated user.
+ ///
+ /// The name of the account to delete.
+ /// An ActionResult indicating the outcome of the operation.
[HttpDelete]
public ActionResult DeleteAccount(string name)
{
@@ -55,4 +87,4 @@ namespace Managing.Api.Controllers
return Ok(_AccountService.DeleteAccount(user, name));
}
}
-}
+}
\ No newline at end of file
diff --git a/src/Managing.Api/Controllers/BacktestController.cs b/src/Managing.Api/Controllers/BacktestController.cs
index 22558e7..8037b51 100644
--- a/src/Managing.Api/Controllers/BacktestController.cs
+++ b/src/Managing.Api/Controllers/BacktestController.cs
@@ -10,6 +10,11 @@ using static Managing.Common.Enums;
namespace Managing.Api.Controllers;
+///
+/// Controller for managing backtest operations.
+/// Provides endpoints for creating, retrieving, and deleting backtests.
+/// Requires authorization for access.
+///
[ApiController]
[Authorize]
[Route("[controller]")]
@@ -22,6 +27,14 @@ public class BacktestController : ControllerBase
private readonly IAccountService _accountService;
private readonly IMoneyManagementService _moneyManagementService;
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ /// The SignalR hub context for real-time communication.
+ /// The service for backtesting strategies.
+ /// The service for managing scenarios.
+ /// The service for account management.
+ /// The service for money management strategies.
public BacktestController(
IHubContext hubContext,
IBacktester backtester,
@@ -36,18 +49,31 @@ public class BacktestController : ControllerBase
_moneyManagementService = moneyManagementService;
}
+ ///
+ /// Retrieves all backtests.
+ ///
+ /// A list of backtests.
[HttpGet]
public ActionResult> Backtests()
{
return Ok(_backtester.GetBacktests());
}
+ ///
+ /// Deletes a specific backtest by ID.
+ ///
+ /// The ID of the backtest to delete.
+ /// An ActionResult indicating the outcome of the operation.
[HttpDelete]
public ActionResult DeleteBacktest(string id)
{
return Ok(_backtester.DeleteBacktest(id));
}
+ ///
+ /// Deletes all backtests.
+ ///
+ /// An ActionResult indicating the outcome of the operation.
[HttpDelete]
[Route("deleteAll")]
public ActionResult DeleteBacktests()
@@ -55,6 +81,21 @@ public class BacktestController : ControllerBase
return Ok(_backtester.DeleteBacktests());
}
+ ///
+ /// Runs a backtest with the specified parameters.
+ ///
+ /// The name of the account to use for the backtest.
+ /// The type of bot to use for the backtest.
+ /// The ticker symbol to backtest.
+ /// The name of the scenario to use for the backtest.
+ /// The timeframe for the backtest.
+ /// Whether to only watch the backtest without executing trades.
+ /// The number of days to backtest.
+ /// The starting balance for the backtest.
+ /// The name of the money management strategy to use.
+ /// The money management strategy details, if not using a named strategy.
+ /// Whether to save the backtest results.
+ /// The result of the backtest.
[HttpPost]
[Route("Run")]
public async Task> Run(string accountName,
@@ -124,10 +165,14 @@ public class BacktestController : ControllerBase
return Ok(backtestResult);
}
+ ///
+ /// Notifies subscribers about the backtesting results via SignalR.
+ ///
+ /// The backtest result to notify subscribers about.
private async Task NotifyBacktesingSubscriberAsync(Backtest backtesting)
{
if(backtesting != null){
await _hubContext.Clients.All.SendAsync("BacktestsSubscription", backtesting);
}
}
-}
+}
\ No newline at end of file
diff --git a/src/Managing.Api/Controllers/BotController.cs b/src/Managing.Api/Controllers/BotController.cs
index 7ef588e..a54b692 100644
--- a/src/Managing.Api/Controllers/BotController.cs
+++ b/src/Managing.Api/Controllers/BotController.cs
@@ -11,6 +11,10 @@ using static Managing.Common.Enums;
namespace Managing.Api.Controllers;
+///
+/// Controller for bot operations such as starting, stopping, deleting, and managing bots.
+/// Requires authorization for access and produces JSON responses.
+///
[ApiController]
[Authorize]
[Route("[controller]")]
@@ -22,6 +26,13 @@ public class BotController : ControllerBase
private readonly IHubContext _hubContext;
private readonly IBacktester _backtester;
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ /// Logger for logging information.
+ /// Mediator for handling commands and requests.
+ /// SignalR hub context for real-time communication.
+ /// Backtester for running backtests on bots.
public BotController(ILogger logger, IMediator mediator, IHubContext hubContext, IBacktester backtester)
{
_logger = logger;
@@ -30,6 +41,11 @@ public class BotController : ControllerBase
_backtester = backtester;
}
+ ///
+ /// Starts a bot with the specified parameters.
+ ///
+ /// The request containing bot start parameters.
+ /// A string indicating the result of the start operation.
[HttpPost]
[Route("Start")]
public async Task> Start(StartBotRequest request)
@@ -41,6 +57,12 @@ public class BotController : ControllerBase
return Ok(result);
}
+ ///
+ /// Stops a bot specified by type and name.
+ ///
+ /// The type of the bot to stop.
+ /// The name of the bot to stop.
+ /// A string indicating the result of the stop operation.
[HttpGet]
[Route("Stop")]
public async Task> Stop(BotType botType, string botName)
@@ -53,6 +75,11 @@ public class BotController : ControllerBase
return Ok(result);
}
+ ///
+ /// Deletes a bot specified by name.
+ ///
+ /// The name of the bot to delete.
+ /// A boolean indicating the result of the delete operation.
[HttpDelete]
[Route("Delete")]
public async Task> Delete(string botName)
@@ -65,6 +92,10 @@ public class BotController : ControllerBase
return Ok(result);
}
+ ///
+ /// Stops all active bots.
+ ///
+ /// A string summarizing the results of the stop operations for all bots.
[HttpGet]
[Route("StopAll")]
public async Task StopAll()
@@ -83,6 +114,12 @@ public class BotController : ControllerBase
return result;
}
+ ///
+ /// Restarts a bot specified by type and name.
+ ///
+ /// The type of the bot to restart.
+ /// The name of the bot to restart.
+ /// A string indicating the result of the restart operation.
[HttpGet]
[Route("Restart")]
public async Task> Restart(BotType botType, string botName)
@@ -95,6 +132,10 @@ public class BotController : ControllerBase
return Ok(result);
}
+ ///
+ /// Restarts all active bots.
+ ///
+ /// A string summarizing the results of the restart operations for all bots.
[HttpGet]
[Route("RestartAll")]
public async Task RestartAll()
@@ -113,6 +154,11 @@ public class BotController : ControllerBase
return result;
}
+ ///
+ /// Toggles the watching status of a bot specified by name.
+ ///
+ /// The name of the bot to toggle watching status.
+ /// A string indicating the new watching status of the bot.
[HttpGet]
[Route("ToggleIsForWatching")]
public async Task> ToggleIsForWatching(string botName)
@@ -125,12 +171,20 @@ public class BotController : ControllerBase
return Ok(result);
}
+ ///
+ /// Retrieves a list of active bots.
+ ///
+ /// A list of active trading bots.
[HttpGet]
public async Task> GetActiveBots()
{
return await GetBotList();
}
+ ///
+ /// Retrieves a list of active bots by sending a command to the mediator.
+ ///
+ /// A list of trading bots.
private async Task> GetBotList()
{
var result = await _mediator.Send(new GetActiveBotsCommand());
@@ -160,9 +214,12 @@ public class BotController : ControllerBase
return list;
}
+ ///
+ /// Notifies subscribers about the current list of bots via SignalR.
+ ///
private async Task NotifyBotSubscriberAsync()
{
var botsList = await GetBotList();
await _hubContext.Clients.All.SendAsync("BotsSubscription", botsList);
}
-}
+}
\ No newline at end of file
diff --git a/src/Managing.Api/Controllers/DataController.cs b/src/Managing.Api/Controllers/DataController.cs
index 01f0398..88a2981 100644
--- a/src/Managing.Api/Controllers/DataController.cs
+++ b/src/Managing.Api/Controllers/DataController.cs
@@ -10,6 +10,10 @@ using static Managing.Common.Enums;
namespace Managing.Api.Controllers;
+///
+/// Controller for handling data-related operations such as retrieving tickers, spotlight data, and candles.
+/// Requires authorization for access.
+///
[ApiController]
[Authorize]
[Route("[controller]")]
@@ -21,6 +25,14 @@ public class DataController : ControllerBase
private readonly IStatisticService _statisticService;
private readonly IHubContext _hubContext;
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ /// Service for interacting with exchanges.
+ /// Service for account management.
+ /// Service for caching data.
+ /// Service for statistical analysis.
+ /// SignalR hub context for real-time communication.
public DataController(
IExchangeService exchangeService,
IAccountService accountService,
@@ -35,6 +47,12 @@ public class DataController : ControllerBase
_hubContext = hubContext;
}
+ ///
+ /// Retrieves tickers for a given account and timeframe, utilizing caching to improve performance.
+ ///
+ /// The name of the account to retrieve tickers for.
+ /// The timeframe for which to retrieve tickers.
+ /// An array of tickers.
[HttpPost("GetTickers")]
public async Task> GetTickers(string accountName, Timeframe timeframe)
{
@@ -48,6 +66,10 @@ public class DataController : ControllerBase
return Ok(tickers);
}
+ ///
+ /// Retrieves the latest spotlight overview, using caching to enhance response times.
+ ///
+ /// A object containing spotlight data.
[HttpGet("Spotlight")]
public ActionResult GetSpotlight()
{
@@ -64,10 +86,17 @@ public class DataController : ControllerBase
return Ok(overview);
}
+ ///
+ /// Retrieves candle data for a given exchange, ticker, start date, and timeframe.
+ ///
+ /// The exchange to retrieve candles from.
+ /// The ticker symbol to retrieve candles for.
+ /// The start date for the candle data.
+ /// The timeframe for the candle data.
+ /// A list of objects.
[HttpGet("GetCandles")]
public async Task>> GetCandles(TradingExchanges exchange, Ticker ticker, DateTime startDate, Timeframe timeframe)
{
return Ok(await _exchangeService.GetCandlesInflux(exchange, ticker, startDate, timeframe));
}
-
-}
+}
\ No newline at end of file
diff --git a/src/Managing.Api/Controllers/MoneyManagementController.cs b/src/Managing.Api/Controllers/MoneyManagementController.cs
index 6ce38a9..0442a3d 100644
--- a/src/Managing.Api/Controllers/MoneyManagementController.cs
+++ b/src/Managing.Api/Controllers/MoneyManagementController.cs
@@ -5,6 +5,11 @@ using Microsoft.AspNetCore.Mvc;
namespace Managing.Api.Controllers;
+///
+/// Controller for managing money management strategies.
+/// Provides endpoints for creating, retrieving, updating, and deleting money management strategies.
+/// Requires authorization for access and produces JSON responses.
+///
[ApiController]
[Authorize]
[Route("[controller]")]
@@ -12,17 +17,31 @@ namespace Managing.Api.Controllers;
public class MoneyManagementController : ControllerBase
{
private readonly IMoneyManagementService _moneyManagementService;
+
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ /// The service for managing money management strategies.
public MoneyManagementController(IMoneyManagementService moneyManagementService)
{
_moneyManagementService = moneyManagementService;
}
+ ///
+ /// Creates a new money management strategy or updates an existing one.
+ ///
+ /// The money management strategy to create or update.
+ /// The created or updated money management strategy.
[HttpPost]
public async Task> PostMoneyManagement(MoneyManagement moneyManagement)
{
return Ok(await _moneyManagementService.CreateOrUpdateMoneyManagement(moneyManagement));
}
+ ///
+ /// Retrieves all money management strategies.
+ ///
+ /// A list of money management strategies.
[HttpGet]
[Route("moneymanagements")]
public ActionResult> GetMoneyManagements()
@@ -30,15 +49,25 @@ public class MoneyManagementController : ControllerBase
return Ok(_moneyManagementService.GetMoneyMangements());
}
+ ///
+ /// Retrieves a specific money management strategy by name.
+ ///
+ /// The name of the money management strategy to retrieve.
+ /// The requested money management strategy if found.
[HttpGet]
public ActionResult GetMoneyManagement(string name)
{
return Ok(_moneyManagementService.GetMoneyMangement(name));
}
+ ///
+ /// Deletes a specific money management strategy by name.
+ ///
+ /// The name of the money management strategy to delete.
+ /// An ActionResult indicating the outcome of the operation.
[HttpDelete]
public ActionResult DeleteMoneyManagement(string name)
{
return Ok(_moneyManagementService.DeleteMoneyManagement(name));
}
-}
+}
\ No newline at end of file
diff --git a/src/Managing.Api/Controllers/ScenarioController.cs b/src/Managing.Api/Controllers/ScenarioController.cs
index 2a55c9a..b2f89ed 100644
--- a/src/Managing.Api/Controllers/ScenarioController.cs
+++ b/src/Managing.Api/Controllers/ScenarioController.cs
@@ -7,6 +7,11 @@ using static Managing.Common.Enums;
namespace Managing.Api.Controllers;
+///
+/// Controller for managing scenarios and strategies within the application.
+/// Provides endpoints for creating, retrieving, and deleting scenarios and strategies.
+/// Requires authorization for access and produces JSON responses.
+///
[ApiController]
[Authorize]
[Route("[controller]")]
@@ -14,30 +19,53 @@ namespace Managing.Api.Controllers;
public class ScenarioController : ControllerBase
{
private readonly IScenarioService _scenarioService;
+
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ /// The service for managing scenarios.
public ScenarioController(IScenarioService scenarioService)
{
_scenarioService = scenarioService;
}
+ ///
+ /// Retrieves all scenarios.
+ ///
+ /// A list of scenarios.
[HttpGet]
public ActionResult> GetScenarios()
{
return Ok(_scenarioService.GetScenarios());
}
+ ///
+ /// Creates a new scenario with the specified name and strategies.
+ ///
+ /// The name of the scenario.
+ /// A list of strategy names to include in the scenario.
+ /// The created scenario.
[HttpPost]
public ActionResult CreateScenario(string name, List strategies)
{
return Ok(_scenarioService.CreateScenario(name, strategies));
}
-
+ ///
+ /// Deletes a scenario by name.
+ ///
+ /// The name of the scenario to delete.
+ /// An ActionResult indicating the outcome of the operation.
[HttpDelete]
public ActionResult DeleteScenario(string name)
{
return Ok(_scenarioService.DeleteScenario(name));
}
+ ///
+ /// Retrieves all strategies.
+ ///
+ /// A list of strategies.
[HttpGet]
[Route("strategy")]
public ActionResult> GetStrategies()
@@ -45,6 +73,21 @@ public class ScenarioController : ControllerBase
return Ok(_scenarioService.GetStrategies());
}
+ ///
+ /// Creates a new strategy with specified parameters.
+ ///
+ /// The type of the strategy.
+ /// The timeframe for the strategy.
+ /// The name of the strategy.
+ /// The period for the strategy (optional).
+ /// The fast periods for the strategy (optional).
+ /// The slow periods for the strategy (optional).
+ /// The signal periods for the strategy (optional).
+ /// The multiplier for the strategy (optional).
+ /// The stochastic periods for the strategy (optional).
+ /// The smooth periods for the strategy (optional).
+ /// The cycle periods for the strategy (optional).
+ /// The created strategy.
[HttpPost]
[Route("strategy")]
public ActionResult CreateStrategy(
@@ -74,10 +117,15 @@ public class ScenarioController : ControllerBase
cyclePeriods));
}
+ ///
+ /// Deletes a strategy by name.
+ ///
+ /// The name of the strategy to delete.
+ /// An ActionResult indicating the outcome of the operation.
[HttpDelete]
[Route("strategy")]
public ActionResult DeleteStrategy(string name)
{
return Ok(_scenarioService.DeleteStrategy(name));
}
-}
+}
\ No newline at end of file
diff --git a/src/Managing.Api/Controllers/TradingController.cs b/src/Managing.Api/Controllers/TradingController.cs
index bec3be2..730abc8 100644
--- a/src/Managing.Api/Controllers/TradingController.cs
+++ b/src/Managing.Api/Controllers/TradingController.cs
@@ -10,6 +10,10 @@ using static Managing.Common.Enums;
namespace Managing.Api.Controllers;
+///
+/// Controller for trading operations such as opening and closing positions, and retrieving trade information.
+/// Requires authorization for access.
+///
[ApiController]
[Authorize]
[Route("[controller]")]
@@ -20,9 +24,16 @@ public class TradingController : ControllerBase
private readonly ITradingService _tradingService;
private readonly IMoneyManagementService _moneyManagementService;
private readonly IMediator _mediator;
-
private readonly ILogger _logger;
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ /// Logger for logging information.
+ /// Command handler for opening trades.
+ /// Command handler for closing trades.
+ /// Service for trading operations.
+ /// Mediator for handling commands and requests.
public TradingController(
ILogger logger,
ICommandHandler openTradeCommandHandler,
@@ -37,6 +48,11 @@ public class TradingController : ControllerBase
_mediator = mediator;
}
+ ///
+ /// Retrieves a list of positions based on the initiator type.
+ ///
+ /// The initiator of the position (e.g., User, System).
+ /// A list of positions.
[HttpGet("GetPositions")]
public async Task>> GetPositions(PositionInitiator positionInitiator)
{
@@ -44,6 +60,13 @@ public class TradingController : ControllerBase
return Ok(result);
}
+ ///
+ /// Retrieves a specific trade by account name, ticker, and exchange order ID.
+ ///
+ /// The name of the account.
+ /// The ticker symbol of the trade.
+ /// The exchange order ID of the trade.
+ /// The requested trade.
[HttpGet("GetTrade")]
public async Task> GetTrade(string accountName, Ticker ticker, string exchangeOrderId)
{
@@ -51,13 +74,24 @@ public class TradingController : ControllerBase
return Ok(result);
}
+ ///
+ /// Retrieves a list of trades for a given account and ticker.
+ ///
+ /// The name of the account.
+ /// The ticker symbol of the trades.
+ /// A list of trades.
[HttpGet("GetTrades")]
- public async Task> GetTrades(string accountName, Ticker ticker, string exchangeOrderId)
+ public async Task> GetTrades(string accountName, Ticker ticker)
{
var result = await _mediator.Send(new GetTradesCommand(ticker, accountName));
return Ok(result);
}
+ ///
+ /// Closes a position identified by its unique identifier.
+ ///
+ /// The unique identifier of the position to close.
+ /// The closed position.
[HttpGet("ClosePosition")]
public async Task> ClosePosition(string identifier)
{
@@ -66,6 +100,18 @@ public class TradingController : ControllerBase
return Ok(result);
}
+ ///
+ /// Opens a new position based on the provided parameters.
+ ///
+ /// The name of the account to open the position for.
+ /// The name of the money management strategy to use.
+ /// The direction of the trade (Buy or Sell).
+ /// The ticker symbol for the trade.
+ /// The risk level for the trade.
+ /// Indicates whether the trade is for paper trading.
+ /// The money management strategy details (optional).
+ /// The opening price for the trade (optional).
+ /// The opened position.
[HttpGet("OpenPosition")]
public async Task> Trade(
string accountName,
@@ -104,4 +150,4 @@ public class TradingController : ControllerBase
var result = await _openTradeCommandHandler.Handle(command);
return Ok(result);
}
-}
+}
\ No newline at end of file
diff --git a/src/Managing.Api/Controllers/UserController.cs b/src/Managing.Api/Controllers/UserController.cs
index 0ec0c71..632269f 100644
--- a/src/Managing.Api/Controllers/UserController.cs
+++ b/src/Managing.Api/Controllers/UserController.cs
@@ -6,6 +6,9 @@ using Microsoft.AspNetCore.Mvc;
namespace Managing.Api.Controllers;
+///
+/// Provides authentication-related actions, including token creation for user authentication.
+///
[ApiController]
[Route("[controller]")]
[Produces("application/json")]
@@ -15,6 +18,12 @@ public class UserController : ControllerBase
private readonly IUserService _userService;
private readonly IJwtUtils _jwtUtils;
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ /// Configuration settings.
+ /// Service for user-related operations.
+ /// Utility for JWT token operations.
public UserController(IConfiguration config, IUserService userService, IJwtUtils jwtUtils)
{
_config = config;
@@ -22,6 +31,11 @@ public class UserController : ControllerBase
_jwtUtils = jwtUtils;
}
+ ///
+ /// Creates a JWT token for a user based on the provided login credentials.
+ ///
+ /// The login request containing user credentials.
+ /// A JWT token if authentication is successful; otherwise, an Unauthorized result.
[AllowAnonymous]
[HttpPost]
public async Task> CreateToken([FromBody] LoginRequest login)
@@ -36,4 +50,4 @@ public class UserController : ControllerBase
return Unauthorized();
}
-}
+}
\ No newline at end of file
diff --git a/src/Managing.Api/Controllers/WorkflowController.cs b/src/Managing.Api/Controllers/WorkflowController.cs
index 2e33a60..f8a3aad 100644
--- a/src/Managing.Api/Controllers/WorkflowController.cs
+++ b/src/Managing.Api/Controllers/WorkflowController.cs
@@ -7,28 +7,50 @@ using Microsoft.AspNetCore.Mvc;
namespace Managing.Api.Controllers
{
+ ///
+ /// Controller for managing workflows, including creating, retrieving, and deleting workflows.
+ /// Requires authorization for access.
+ ///
[Authorize]
public class WorkflowController : BaseController
{
private readonly IWorkflowService _workflowService;
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ /// Service for managing workflows.
+ /// Service for user-related operations.
public WorkflowController(IWorkflowService WorkflowService, IUserService userService) : base(userService)
{
_workflowService = WorkflowService;
}
+ ///
+ /// Creates a new workflow or updates an existing one based on the provided workflow request.
+ ///
+ /// The workflow request containing the details of the workflow to be created or updated.
+ /// The created or updated workflow.
[HttpPost]
public async Task> PostWorkflow([ModelBinder]SyntheticWorkflow workflowRequest)
{
return Ok(await _workflowService.InsertOrUpdateWorkflow(workflowRequest));
}
+ ///
+ /// Retrieves all workflows.
+ ///
+ /// A list of all workflows.
[HttpGet]
public ActionResult> GetWorkflows()
{
return Ok(_workflowService.GetWorkflows());
}
+ ///
+ /// Retrieves all available flows.
+ ///
+ /// A list of all available flows.
[HttpGet]
[Route("flows")]
public async Task>> GetAvailableFlows()
@@ -36,10 +58,15 @@ namespace Managing.Api.Controllers
return Ok(await _workflowService.GetAvailableFlows());
}
+ ///
+ /// Deletes a workflow by name.
+ ///
+ /// The name of the workflow to delete.
+ /// An ActionResult indicating the outcome of the operation.
[HttpDelete]
public ActionResult DeleteWorkflow(string name)
{
return Ok(_workflowService.DeleteWorkflow(name));
}
}
-}
+}
\ No newline at end of file