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,6 +1,7 @@
using Managing.Application.Abstractions;
using Managing.Application.Abstractions.Services;
using Managing.Application.Workflows.Flows.Feeds;
using Managing.Application.Workflows.Flows.Strategies;
using Managing.Application.Workflows.Flows.Trading;
using Managing.Domain.Workflows;
using Managing.Domain.Workflows.Synthetics;
@@ -15,7 +16,8 @@ public class FlowFactory : IFlowFactory
private readonly ITradingService _tradingService;
private readonly IAccountService _accountService;
public FlowFactory(IExchangeService exchangeService, ICacheService cacheService, ITradingService tradingService, IAccountService accountService)
public FlowFactory(IExchangeService exchangeService, ICacheService cacheService, ITradingService tradingService,
IAccountService accountService)
{
_exchangeService = exchangeService;
_cacheService = cacheService;
@@ -29,16 +31,18 @@ public class FlowFactory : IFlowFactory
{
FlowType.FeedTicker => new FeedTicker(_exchangeService),
FlowType.RsiDivergence => new RsiDiv(),
FlowType.OpenPosition => new OpenPosition(_exchangeService, _cacheService, _accountService, _tradingService),
FlowType.OpenPosition => new OpenPosition(_exchangeService, _cacheService, _accountService,
_tradingService),
_ => throw new NotImplementedException(),
};
flow.Children = new List<IFlow>();
flow.Parameters = new List<FlowParameter>();
foreach (var parameter in request.Parameters)
foreach (var parameter in request.Parameters)
{
if (!flow.Parameters.Any(p => p.Name == parameter.Name)) {
if (!flow.Parameters.Any(p => p.Name == parameter.Name))
{
flow.Parameters.Add(new FlowParameter
{
Name = parameter.Name,
@@ -46,6 +50,7 @@ public class FlowFactory : IFlowFactory
});
}
}
return flow;
}
}
}

View File

@@ -4,7 +4,7 @@ using Managing.Domain.Workflows;
using Newtonsoft.Json;
using static Managing.Common.Enums;
namespace Managing.Application.Workflows.Flows.Feeds;
namespace Managing.Application.Workflows.Flows.Strategies;
public class RsiDiv : FlowBase
{
@@ -36,7 +36,7 @@ public class RsiDiv : FlowBase
Output = JsonConvert.SerializeObject(strategy.Signals);
if(Children != null && Children.Count > 0)
if (Children != null && Children.Count > 0)
{
foreach (var child in Children)
{
@@ -62,4 +62,4 @@ public class RsiDivParameters
{
public int Period { get; set; }
public Timeframe Timeframe { get; set; }
}
}

View File

@@ -2,6 +2,7 @@
using Managing.Application.Abstractions.Repositories;
using Managing.Application.Abstractions.Services;
using Managing.Application.Workflows.Flows.Feeds;
using Managing.Application.Workflows.Flows.Strategies;
using Managing.Application.Workflows.Flows.Trading;
using Managing.Domain.Workflows;
using Managing.Domain.Workflows.Synthetics;
@@ -14,7 +15,7 @@ public class WorkflowService : IWorkflowService
private readonly IExchangeService _exchangeService;
private readonly IFlowFactory _flowFactory;
private readonly ICacheService _cacheService;
private readonly ITradingService _tradingService;
private readonly ITradingService _tradingService;
private readonly IAccountService _accountService;
public WorkflowService(
@@ -50,10 +51,9 @@ public class WorkflowService : IWorkflowService
}
catch (Exception ex)
{
throw;
}
return Map(workflowRequest);
}
@@ -122,5 +122,4 @@ public class WorkflowService : IWorkflowService
return Task.FromResult(availableFlows.AsEnumerable());
}
}
}