33 lines
980 B
C#
33 lines
980 B
C#
using KLHZ.Trader.Core.Exchange.Interfaces;
|
|
using KLHZ.Trader.Core.Exchange.Models.AssetsAccounting;
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
using Microsoft.Extensions.Hosting;
|
|
|
|
namespace KLHZ.Trader.Core.Exchange.Services
|
|
{
|
|
public class PortfolioDataProvider : IHostedService
|
|
{
|
|
private readonly IServiceProvider _services;
|
|
public PortfolioDataProvider(IServiceProvider services)
|
|
{
|
|
_services = services;
|
|
|
|
|
|
|
|
}
|
|
|
|
public async Task StartAsync(CancellationToken cancellationToken)
|
|
{
|
|
var acc = _services.GetKeyedService<IManagedAccount>(1);
|
|
await acc.Init("2274189208");
|
|
await acc.OpenPosition("FUTIMOEXF000", PositionType.Short, 2.5m, 4m);
|
|
await acc.ClosePosition("FUTIMOEXF000");
|
|
}
|
|
|
|
public Task StopAsync(CancellationToken cancellationToken)
|
|
{
|
|
return Task.CompletedTask;
|
|
}
|
|
}
|
|
}
|