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:
@@ -69,12 +69,11 @@ namespace Managing.Infrastructure.Messengers.Discord
|
||||
|
||||
var moneymanagement = new MoneyManagement
|
||||
{
|
||||
BalanceAtRisk = 5,
|
||||
StopLoss = stopLoss.GetValueOrDefault(),
|
||||
TakeProfit = takeProfit.GetValueOrDefault(),
|
||||
};
|
||||
var tradeCommand = new OpenPositionRequest(accountName, moneymanagement, direction, ticker,
|
||||
PositionInitiator.User, DateTime.UtcNow, new User());
|
||||
PositionInitiator.User, DateTime.UtcNow, new User(), 100m);
|
||||
var result = await _openTradeCommandHandler.Handle(tradeCommand);
|
||||
var builder = new ComponentBuilder().WithButton("Close Position",
|
||||
$"{Constants.DiscordButtonAction.ClosePosition}|{result.Open.ExchangeOrderId}");
|
||||
|
||||
@@ -12,6 +12,7 @@ using Managing.Core;
|
||||
using Managing.Domain.MoneyManagements;
|
||||
using Managing.Domain.Statistics;
|
||||
using Managing.Domain.Trades;
|
||||
using Managing.Domain.Users;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Newtonsoft.Json;
|
||||
@@ -264,7 +265,7 @@ namespace Managing.Infrastructure.Messengers.Discord
|
||||
var tradingService = (ITradingService)_services.GetService(typeof(ITradingService));
|
||||
|
||||
// Create default user for Discord bot operations
|
||||
var defaultUser = new Domain.Users.User { Name = "DiscordBot" };
|
||||
var defaultUser = new User { Name = "DiscordBot" };
|
||||
|
||||
var tradeCommand = new OpenPositionRequest(
|
||||
accountName,
|
||||
@@ -274,7 +275,7 @@ namespace Managing.Infrastructure.Messengers.Discord
|
||||
initiator,
|
||||
DateTime.UtcNow,
|
||||
defaultUser,
|
||||
ignoreSLTP: ignoreSLTP);
|
||||
100m);
|
||||
var position = await new OpenPositionCommandHandler(exchangeService, accountService, tradingService)
|
||||
.Handle(tradeCommand);
|
||||
|
||||
@@ -416,7 +417,6 @@ namespace Managing.Infrastructure.Messengers.Discord
|
||||
new MoneyManagement
|
||||
{
|
||||
Name = "MediumRisk",
|
||||
BalanceAtRisk = 0.05m,
|
||||
Leverage = 1,
|
||||
StopLoss = 0.021m,
|
||||
TakeProfit = 0.042m,
|
||||
|
||||
Reference in New Issue
Block a user