Check direction of the position before updating the broker position
This commit is contained in:
@@ -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;
|
||||||
|
|
||||||
|
|||||||
@@ -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");
|
||||||
|
|||||||
Reference in New Issue
Block a user