Update healthcheck and display pnl on trades
This commit is contained in:
@@ -3,19 +3,19 @@ using Managing.ABI.GmxV2.SyntheticsReader.ContractDefinition;
|
||||
using Managing.Common;
|
||||
using Managing.Core;
|
||||
using Managing.Domain.Candles;
|
||||
using Managing.Domain.MoneyManagements;
|
||||
using Managing.Domain.Trades;
|
||||
using Managing.Domain.Users;
|
||||
using Managing.Infrastructure.Evm.Models.Gmx.v2;
|
||||
using Managing.Infrastructure.Evm.Models.Proxy;
|
||||
using Nethereum.Web3;
|
||||
using Managing.Domain.MoneyManagements;
|
||||
using Managing.Domain.Users;
|
||||
using static Managing.Common.Enums;
|
||||
|
||||
namespace Managing.Infrastructure.Evm.Services.Gmx;
|
||||
|
||||
internal static class GmxV2Mappers
|
||||
{
|
||||
public static Trade Map(GmxV2Position position, Enums.Ticker ticker)
|
||||
public static Trade Map(GmxV2Position position, Ticker ticker)
|
||||
{
|
||||
var entryPrice = GmxV2Helpers.GetEntryPrice(position.SizeInUsd, position.SizeInTokens,
|
||||
position.TokenData.Decimals);
|
||||
@@ -24,9 +24,9 @@ internal static class GmxV2Mappers
|
||||
var collateralLeverage = CalculateCollateralAndLeverage(position.SizeInUsd, position.CollateralAmount);
|
||||
var trade = new Trade(
|
||||
DateHelpers.GetFromUnixTimestamp((int)position.IncreasedAtTime),
|
||||
position.IsLong ? Enums.TradeDirection.Long : Enums.TradeDirection.Short,
|
||||
Enums.TradeStatus.Filled,
|
||||
Enums.TradeType.Limit,
|
||||
position.IsLong ? TradeDirection.Long : TradeDirection.Short,
|
||||
TradeStatus.Filled,
|
||||
TradeType.Limit,
|
||||
ticker,
|
||||
collateralLeverage.collateral / parsedEntryPrice,
|
||||
parsedEntryPrice,
|
||||
@@ -56,8 +56,8 @@ internal static class GmxV2Mappers
|
||||
|
||||
var trade = new Trade(
|
||||
order.Date,
|
||||
order.IsLong ? Enums.TradeDirection.Long : Enums.TradeDirection.Short,
|
||||
Enums.TradeStatus.PendingOpen,
|
||||
order.IsLong ? TradeDirection.Long : TradeDirection.Short,
|
||||
TradeStatus.PendingOpen,
|
||||
GmxV2Helpers.GetTradeType(order.OrderType),
|
||||
ticker,
|
||||
Convert.ToDecimal(quantity),
|
||||
@@ -111,7 +111,7 @@ internal static class GmxV2Mappers
|
||||
}).ToList();
|
||||
}
|
||||
|
||||
public static Candle Map(List<double> marketPrices, Enums.Ticker ticker, Enums.Timeframe timeframe, int timeBetween)
|
||||
public static Candle Map(List<double> marketPrices, Ticker ticker, Timeframe timeframe, int timeBetween)
|
||||
{
|
||||
return new Candle()
|
||||
{
|
||||
@@ -121,20 +121,20 @@ internal static class GmxV2Mappers
|
||||
High = Convert.ToDecimal(marketPrices[2]),
|
||||
Low = Convert.ToDecimal(marketPrices[3]),
|
||||
Close = Convert.ToDecimal(marketPrices[4]),
|
||||
Exchange = Enums.TradingExchanges.Evm,
|
||||
Exchange = TradingExchanges.Evm,
|
||||
Ticker = ticker.ToString(),
|
||||
Timeframe = timeframe
|
||||
};
|
||||
}
|
||||
|
||||
public static List<Enums.Ticker> Map(GmxV2TokenList tokenList)
|
||||
public static List<Ticker> Map(GmxV2TokenList tokenList)
|
||||
{
|
||||
var tokens = new List<Enums.Ticker>();
|
||||
var tokens = new List<Ticker>();
|
||||
foreach (var t in tokenList.Tokens)
|
||||
{
|
||||
try
|
||||
{
|
||||
var ticker = MiscExtensions.ParseEnum<Enums.Ticker>(t.Symbol);
|
||||
var ticker = MiscExtensions.ParseEnum<Ticker>(t.Symbol);
|
||||
tokens.Add(ticker);
|
||||
}
|
||||
catch (Exception e)
|
||||
@@ -187,7 +187,7 @@ internal static class GmxV2Mappers
|
||||
|
||||
position.ProfitAndLoss = new ProfitAndLoss()
|
||||
{
|
||||
Net = (decimal)gmxPosition.Pnl
|
||||
Realized = (decimal)gmxPosition.Pnl
|
||||
};
|
||||
|
||||
position.Status = MiscExtensions.ParseEnum<PositionStatus>(gmxPosition.Status);
|
||||
|
||||
Reference in New Issue
Block a user