Balance for bot (#20)

* Add bot balance

* Update amount to trade

* fix initial trading balance

* Update MM modal

* fix backtest

* stop bot if no more balance

* Add constant for minimum trading

* Add constant
This commit is contained in:
Oda
2025-04-28 16:52:42 +02:00
committed by GitHub
parent 967e8410dc
commit 204bd87e6a
39 changed files with 600 additions and 546 deletions

View File

@@ -2,6 +2,7 @@
using Managing.Application.Abstractions.Services;
using Managing.Domain.Accounts;
using Managing.Domain.MoneyManagements;
using Managing.Domain.Users;
using Managing.Infrastructure.Tests;
using Moq;
using static Managing.Common.Enums;
@@ -24,7 +25,6 @@ public class BaseTests
_moneyManagementService = new Mock<IMoneyManagementService>();
MoneyManagement = new MoneyManagement()
{
BalanceAtRisk = 1m, // 30%
Leverage = 2, // x2
Timeframe = Timeframe.FifteenMinutes,
StopLoss = 0.008m, // 0.8%
@@ -32,7 +32,7 @@ public class BaseTests
Name = "Default MM"
};
_ = _moneyManagementService.Setup(m => m.GetMoneyMangement(It.IsAny<Domain.Users.User>(), It.IsAny<string>()))
_ = _moneyManagementService.Setup(m => m.GetMoneyMangement(It.IsAny<User>(), It.IsAny<string>()))
.Returns(Task.FromResult(MoneyManagement));
_accountService.Setup(a => a.GetAccount(It.IsAny<string>(), It.IsAny<bool>(), It.IsAny<bool>()))

View File

@@ -9,7 +9,6 @@ using Managing.Core;
using Managing.Domain.Candles;
using Managing.Domain.MoneyManagements;
using Managing.Domain.Scenarios;
using MongoDB.Driver.Linq;
using Moq;
using Newtonsoft.Json;
using Xunit;
@@ -115,7 +114,6 @@ namespace Managing.Application.Tests
var moneyManagement = new MoneyManagement()
{
BalanceAtRisk = 0.05m,
Leverage = 1,
Timeframe = timeframe,
StopLoss = 0.01m,
@@ -179,7 +177,6 @@ namespace Managing.Application.Tests
{
var moneyManagement = new MoneyManagement()
{
BalanceAtRisk = 0.05m,
Leverage = 1,
Timeframe = timeframe,
StopLoss = s,
@@ -293,7 +290,6 @@ namespace Managing.Application.Tests
{
var moneyManagement = new MoneyManagement()
{
BalanceAtRisk = 0.05m,
Leverage = 1,
Timeframe = timeframe,
StopLoss = s,

File diff suppressed because one or more lines are too long

View File

@@ -12,7 +12,6 @@ namespace Managing.Application.Tests
{
_moneyManagement = new MoneyManagement()
{
BalanceAtRisk = 0.05m,
Leverage = 1,
Timeframe = Timeframe.OneDay,
StopLoss = 0.008m,