GMX v2 - Trading (#7)

* Move PrivateKeys.cs

* Update gitignore

* Update gitignore

* updt

* Extract GmxServiceTests.cs

* Refact

* update todo

* Update code

* Fix hashdata

* Replace static token hashed datas

* Set allowance

* Add get orders

* Add get orders tests

* Add ignore

* add close orders

* revert

* Add get gas limit

* Start increasePosition. Todo: Finish GetExecutionFee and estimateGas

* little refact

* Update gitignore

* Fix namespaces and clean repo

* Add tests samples

* Add execution fee

* Add increase position

* Handle backtest on the frontend

* Add tests

* Update increase

* Test increase

* fix increase

* Fix size

* Start get position

* Update get positions

* Fix get position

* Update rpc and trade mappers

* Finish close position

* Fix leverage
This commit is contained in:
Oda
2025-01-30 23:06:22 +07:00
committed by GitHub
parent ecaa89c67b
commit 65bdb8e34f
156 changed files with 11253 additions and 4073 deletions

View File

@@ -1,5 +1,4 @@
using Managing.Application.Strategies;
using Managing.Domain.Strategies;
using Managing.Domain.Strategies;
using static Managing.Common.Enums;
namespace Managing.Domain.Scenarios;
@@ -14,16 +13,25 @@ public static class ScenarioHelpers
IStrategy result = strategy.Type switch
{
StrategyType.StDev => new StDevContext(strategy.Name, strategy.Timeframe, strategy.Period.Value),
StrategyType.RsiDivergence => new RSIDivergenceStrategy(strategy.Name, strategy.Timeframe, strategy.Period.Value),
StrategyType.RsiDivergenceConfirm => new RSIDivergenceConfirmStrategy(strategy.Name, strategy.Timeframe, strategy.Period.Value),
StrategyType.MacdCross => new MACDCrossStrategy(strategy.Name, strategy.Timeframe, strategy.FastPeriods.Value, strategy.SlowPeriods.Value, strategy.SignalPeriods.Value),
StrategyType.RsiDivergence => new RSIDivergenceStrategy(strategy.Name, strategy.Timeframe,
strategy.Period.Value),
StrategyType.RsiDivergenceConfirm => new RSIDivergenceConfirmStrategy(strategy.Name, strategy.Timeframe,
strategy.Period.Value),
StrategyType.MacdCross => new MACDCrossStrategy(strategy.Name, strategy.Timeframe,
strategy.FastPeriods.Value, strategy.SlowPeriods.Value, strategy.SignalPeriods.Value),
StrategyType.EmaCross => new EmaCrossStrategy(strategy.Name, strategy.Timeframe, strategy.Period.Value),
StrategyType.ThreeWhiteSoldiers => new ThreeWhiteSoldiersStrategy(strategy.Name, strategy.Timeframe, strategy.Period.Value),
StrategyType.SuperTrend => new SuperTrendStrategy(strategy.Name, strategy.Timeframe, strategy.Period.Value, strategy.Multiplier.Value),
StrategyType.ChandelierExit => new ChandelierExitStrategy(strategy.Name, strategy.Timeframe, strategy.Period.Value, strategy.Multiplier.Value),
StrategyType.ThreeWhiteSoldiers => new ThreeWhiteSoldiersStrategy(strategy.Name, strategy.Timeframe,
strategy.Period.Value),
StrategyType.SuperTrend => new SuperTrendStrategy(strategy.Name, strategy.Timeframe,
strategy.Period.Value, strategy.Multiplier.Value),
StrategyType.ChandelierExit => new ChandelierExitStrategy(strategy.Name, strategy.Timeframe,
strategy.Period.Value, strategy.Multiplier.Value),
StrategyType.EmaTrend => new EmaTrendStrategy(strategy.Name, strategy.Timeframe, strategy.Period.Value),
StrategyType.StochRsiTrend => new StochRsiTrendStrategy(strategy.Name, strategy.Timeframe, strategy.Period.Value, strategy.StochPeriods.Value, strategy.SignalPeriods.Value, strategy.SmoothPeriods.Value),
StrategyType.Stc => new STCStrategy(strategy.Name, strategy.Timeframe, strategy.CyclePeriods.Value, strategy.FastPeriods.Value, strategy.SlowPeriods.Value),
StrategyType.StochRsiTrend => new StochRsiTrendStrategy(strategy.Name, strategy.Timeframe,
strategy.Period.Value, strategy.StochPeriods.Value, strategy.SignalPeriods.Value,
strategy.SmoothPeriods.Value),
StrategyType.Stc => new STCStrategy(strategy.Name, strategy.Timeframe, strategy.CyclePeriods.Value,
strategy.FastPeriods.Value, strategy.SlowPeriods.Value),
_ => throw new NotImplementedException(),
};
@@ -63,11 +71,13 @@ public static class ScenarioHelpers
{
strategy.Period = period.Value;
}
break;
case StrategyType.MacdCross:
if (!fastPeriods.HasValue || !slowPeriods.HasValue || !signalPeriods.HasValue)
{
throw new Exception($"Missing fastPeriods or slowPeriods or signalPeriods, for {strategy.Type} strategy type");
throw new Exception(
$"Missing fastPeriods or slowPeriods or signalPeriods, for {strategy.Type} strategy type");
}
else
{
@@ -75,6 +85,7 @@ public static class ScenarioHelpers
strategy.SlowPeriods = slowPeriods;
strategy.SignalPeriods = signalPeriods;
}
break;
break;
case StrategyType.ThreeWhiteSoldiers:
@@ -90,6 +101,7 @@ public static class ScenarioHelpers
strategy.Period = period;
strategy.Multiplier = multiplier;
}
break;
case StrategyType.StochRsiTrend:
if (!period.HasValue
@@ -97,7 +109,8 @@ public static class ScenarioHelpers
|| !signalPeriods.HasValue
|| !smoothPeriods.HasValue)
{
throw new Exception($"Missing period, stochPeriods, signalPeriods, smoothPeriods for {strategy.Type} strategy type");
throw new Exception(
$"Missing period, stochPeriods, signalPeriods, smoothPeriods for {strategy.Type} strategy type");
}
else
{
@@ -106,11 +119,13 @@ public static class ScenarioHelpers
strategy.SignalPeriods = signalPeriods;
strategy.SmoothPeriods = smoothPeriods;
}
break;
case StrategyType.Stc:
if (!fastPeriods.HasValue || !slowPeriods.HasValue || !cyclePeriods.HasValue)
{
throw new Exception($"Missing fastPeriods or slowPeriods or cyclePeriods, for {strategy.Type} strategy type");
throw new Exception(
$"Missing fastPeriods or slowPeriods or cyclePeriods, for {strategy.Type} strategy type");
}
else
{
@@ -118,6 +133,7 @@ public static class ScenarioHelpers
strategy.SlowPeriods = slowPeriods;
strategy.CyclePeriods = cyclePeriods;
}
break;
default:
break;
@@ -145,4 +161,4 @@ public static class ScenarioHelpers
_ => throw new NotImplementedException(),
};
}
}
}