diff --git a/src/Managing.Application/Bots/TradingBot.cs b/src/Managing.Application/Bots/TradingBot.cs index 8dd4d85..7d9983b 100644 --- a/src/Managing.Application/Bots/TradingBot.cs +++ b/src/Managing.Application/Bots/TradingBot.cs @@ -510,12 +510,14 @@ public class TradingBot : Bot, ITradingBot var position = await new OpenPositionCommandHandler(ExchangeService, AccountService, TradingService) .Handle(command); + if (position != null) { + position.SignalIdentifier = signal.Identifier; + Positions.Add(position); + if (position.Open.Status != TradeStatus.Cancelled) { - position.SignalIdentifier = signal.Identifier; - Positions.Add(position); SetSignalStatus(signal.Identifier, SignalStatus.PositionOpen); if (!IsForBacktest) @@ -534,8 +536,11 @@ public class TradingBot : Bot, ITradingBot } catch (Exception ex) { + // Keep signal open for debug purpose + //SetSignalStatus(signal.Identifier, SignalStatus.Expired); SetSignalStatus(signal.Identifier, SignalStatus.Expired); - await LogWarning($"Cannot open trade : {ex.Message}"); + + await LogWarning($"Cannot open trade : {ex.Message}, stackTrace : {ex.StackTrace}"); } } } diff --git a/src/Managing.Application/Trading/OpenPositionCommandHandler.cs b/src/Managing.Application/Trading/OpenPositionCommandHandler.cs index 3a91ad8..df3f625 100644 --- a/src/Managing.Application/Trading/OpenPositionCommandHandler.cs +++ b/src/Managing.Application/Trading/OpenPositionCommandHandler.cs @@ -42,11 +42,7 @@ namespace Managing.Application.Trading ? request.Price.Value : exchangeService.GetPrice(account, request.Ticker, DateTime.Now); var quantity = balanceAtRisk / price; - var fee = request.IsForPaperTrading - ? request.Fee.GetValueOrDefault() - : tradingService.GetFee(account, request.IsForPaperTrading); - - var expectedStatus = GetExpectedStatus(request); + // var expectedStatus = GetExpectedStatus(request); // position.Open = TradingPolicies.OpenPosition(expectedStatus).Execute(async () => { }); var openPrice = request.IsForPaperTrading || request.Price.HasValue @@ -70,7 +66,7 @@ namespace Managing.Application.Trading stopLossPrice: stopLossPrice, // Pass determined SL price takeProfitPrice: takeProfitPrice); // Pass determined TP price - trade.Fee = TradingHelpers.GetFeeAmount(fee, openPrice * quantity, account.Exchange); + //trade.Fee = TradingHelpers.GetFeeAmount(fee, openPrice * quantity, account.Exchange); position.Open = trade; var closeDirection = request.Direction == TradeDirection.Long @@ -88,8 +84,8 @@ namespace Managing.Application.Trading request.Date, TradeStatus.Requested); - position.StopLoss.Fee = TradingHelpers.GetFeeAmount(fee, - position.StopLoss.Price * position.StopLoss.Quantity, account.Exchange); + // position.StopLoss.Fee = TradingHelpers.GetFeeAmount(fee, + // position.StopLoss.Price * position.StopLoss.Quantity, account.Exchange); // Take profit - Use the determined price position.TakeProfit1 = exchangeService.BuildEmptyTrade( diff --git a/src/Managing.Infrastructure.Web3/Services/Web3ProxyService.cs b/src/Managing.Infrastructure.Web3/Services/Web3ProxyService.cs index 35c40af..9d9e8af 100644 --- a/src/Managing.Infrastructure.Web3/Services/Web3ProxyService.cs +++ b/src/Managing.Infrastructure.Web3/Services/Web3ProxyService.cs @@ -92,7 +92,7 @@ namespace Managing.Infrastructure.Evm.Services endpoint = $"/{endpoint}"; } - var url = $"{_settings.BaseUrl}gmx{endpoint}"; + var url = $"{_settings.BaseUrl}/api/gmx{endpoint}"; try { diff --git a/src/Managing.Web3Proxy/package-lock.json b/src/Managing.Web3Proxy/package-lock.json index a7237ee..5465cff 100644 --- a/src/Managing.Web3Proxy/package-lock.json +++ b/src/Managing.Web3Proxy/package-lock.json @@ -4340,7 +4340,7 @@ }, "node_modules/get-tsconfig": { "version": "4.10.0", - "devOptional": true, + "dev": true, "license": "MIT", "dependencies": { "resolve-pkg-maps": "^1.0.0" @@ -6598,7 +6598,7 @@ }, "node_modules/resolve-pkg-maps": { "version": "1.0.0", - "devOptional": true, + "dev": true, "license": "MIT", "funding": { "url": "https://github.com/privatenumber/resolve-pkg-maps?sponsor=1" @@ -7526,7 +7526,7 @@ }, "node_modules/tsx": { "version": "4.19.3", - "devOptional": true, + "dev": true, "license": "MIT", "dependencies": { "esbuild": "~0.25.0", @@ -7646,7 +7646,7 @@ }, "node_modules/typescript": { "version": "5.8.2", - "devOptional": true, + "dev": true, "license": "Apache-2.0", "bin": { "tsc": "bin/tsc",