Check direction of the position before updating the broker position

This commit is contained in:
2025-10-24 02:41:40 +07:00
parent 4489c57f55
commit 554cac7d89
2 changed files with 5 additions and 3 deletions

View File

@@ -402,7 +402,8 @@ public class TradingBotBase : ITradingBot
if (!Config.IsForBacktest) if (!Config.IsForBacktest)
{ {
var brokerPosition = brokerPositions.FirstOrDefault(p => p.Ticker == Config.Ticker); var brokerPosition = brokerPositions.FirstOrDefault(p =>
p.Ticker == Config.Ticker && p.OriginDirection == positionForSignal.OriginDirection);
if (brokerPosition != null) if (brokerPosition != null)
{ {
var previousPositionStatus = internalPosition.Status; var previousPositionStatus = internalPosition.Status;
@@ -1164,7 +1165,7 @@ public class TradingBotBase : ITradingBot
} }
await LogInformation( await LogInformation(
$"🔧 Closing Trade\nTicker: `{Config.Ticker}`\nPrice: `${lastPrice}`\n📋 Type: `{tradeToClose.TradeType}`\n📊 Quantity: `{tradeToClose.Quantity:F5}`"); $"🔧 Closing {position.OriginDirection} Trade\nTicker: `{Config.Ticker}`\nPrice: `${lastPrice}`\n📋 Type: `{tradeToClose.TradeType}`\n📊 Quantity: `{tradeToClose.Quantity:F5}`");
decimal quantity = 0; decimal quantity = 0;

View File

@@ -56,9 +56,10 @@ public class UserService : IUserService
if (!_authorizedAddresses.Any(a => string.Equals(a, recoveredAddress, StringComparison.OrdinalIgnoreCase))) if (!_authorizedAddresses.Any(a => string.Equals(a, recoveredAddress, StringComparison.OrdinalIgnoreCase)))
{ {
throw new Exception($"Address {recoveredAddress} not authorized"); throw new Exception($"Address {recoveredAddress} not authorized. Please wait for team approval.");
} }
if (recoveredAddress == null || !recoveredAddress.Equals(address)) if (recoveredAddress == null || !recoveredAddress.Equals(address))
{ {
throw new Exception($"Address {recoveredAddress} not corresponding"); throw new Exception($"Address {recoveredAddress} not corresponding");