fix signal and get position during closing

This commit is contained in:
2025-05-14 14:48:01 +07:00
parent 15190a0516
commit 456867c352
3 changed files with 420 additions and 419 deletions

View File

@@ -1,4 +1,5 @@
using System.ComponentModel.DataAnnotations;
using System.Globalization;
using Managing.Core;
using Managing.Domain.Candles;
using Managing.Domain.Users;
@@ -34,7 +35,7 @@ namespace Managing.Domain.Strategies
StrategyType = strategyType;
User = user;
Identifier = $"{StrategyType}-{direction}-{ticker}-{candle?.Close}-{date:yyyyMMdd-HHmmss}";
Identifier = $"{StrategyType}-{direction}-{ticker}-{candle?.Close.ToString(CultureInfo.InvariantCulture)}-{date:yyyyMMdd-HHmmss}";
SignalType = signalType;
}

View File

@@ -660,7 +660,9 @@ public class EvmManager : IEvmManager
{
account = account.Key,
ticker = ticker.ToString(),
direction = direction.ToString(),
direction = direction == TradeDirection.Long
? TradeDirection.Short.ToString()
: TradeDirection.Long.ToString(),
});
trade = new Trade(
DateTime.UtcNow,

View File

@@ -157,9 +157,7 @@ export async function increaseOrderHelper(
externalSwapQuote: undefined,
});
const createSltpEntries: SidecarSlTpOrderEntryValid[] = [
]
const createSltpEntries: SidecarSlTpOrderEntryValid[] = []
let stopLossDecreaseAmounts: DecreasePositionAmounts | undefined;
if (params.stopLossPrice) {
@@ -183,8 +181,8 @@ export async function increaseOrderHelper(
indexPrice: params.stopLossPrice,
collateralPrice: 0n,
acceptablePrice: params.isLong ? 2n ** 256n - 1n : 0n,
acceptablePriceDeltaBps: acceptablePriceInfo.acceptablePriceDeltaBps,
recommendedAcceptablePriceDeltaBps: 0n,
acceptablePriceDeltaBps: acceptablePriceInfo.acceptablePriceDeltaBps + 50n,
recommendedAcceptablePriceDeltaBps: 50n,
estimatedPnl: 0n,
estimatedPnlPercentage: 0n,
realizedPnl: 0n,
@@ -257,8 +255,8 @@ export async function increaseOrderHelper(
indexPrice: params.takeProfitPrice, // Keep original trigger price for indexPrice
collateralPrice: 0n, // Consider if this needs calculation
acceptablePrice: acceptablePriceInfo.acceptablePrice,
acceptablePriceDeltaBps: acceptablePriceInfo.acceptablePriceDeltaBps,
recommendedAcceptablePriceDeltaBps: 0n,
acceptablePriceDeltaBps: acceptablePriceInfo.acceptablePriceDeltaBps + 50n, // Add 0.5% buffer to acceptable price impact
recommendedAcceptablePriceDeltaBps: 50n, // Set recommended buffer to 0.5%
estimatedPnl: 0n,
estimatedPnlPercentage: 0n,
realizedPnl: 0n,