You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
58 lines
2.3 KiB
58 lines
2.3 KiB
using Binance.TradeRobot.Common.DI;
|
|
using Binance.TradeRobot.Model.Base;
|
|
using Binance.TradeRobot.Model.Dto;
|
|
using Microsoft.Extensions.Caching.Memory;
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Threading.Tasks;
|
|
using Yitter.IdGenerator;
|
|
|
|
namespace Binance.TradeRobot.Business.Business
|
|
{
|
|
[BatchRegistration(ServiceLifetime.Singleton, RegistrationType.Self)]
|
|
public class SingalBusiness : BaseBusiness
|
|
{
|
|
private RobotBusiness robotBusiness;
|
|
private IEnumerable<ITradeBusiness> tradeBusinessList;
|
|
|
|
public SingalBusiness(IFreeSql fsql,
|
|
NLogManager logManager,
|
|
IIdGenerator idGenerator,
|
|
IMemoryCache memoryCache,
|
|
RobotBusiness robotBusiness,
|
|
IEnumerable<ITradeBusiness> tradeBusinessList) : base(fsql, logManager, idGenerator, memoryCache)
|
|
{
|
|
this.robotBusiness = robotBusiness;
|
|
this.tradeBusinessList = tradeBusinessList;
|
|
}
|
|
|
|
public void D21Singal(D21SingalRequest d21SingalRequest)
|
|
{
|
|
//logManager.GetLogger("D21").Info(JsonConvert.SerializeObject(d21SingalRequest));
|
|
var robotList = robotBusiness.GetD21PolicyRobotList(Enums.RobotState.Runing, d21SingalRequest.KLinePeriodic, d21SingalRequest.Symbol, false, true);
|
|
if (robotList == null || robotList.Count() == 0)
|
|
throw new BusinessException("未找到符合条件的机器人");
|
|
|
|
//var robot = robotList.FirstOrDefault();
|
|
var d21TradeBusiness = tradeBusinessList.FirstOrDefault(t => t.TradePolicy == Enums.TradePolicy.D21);
|
|
|
|
foreach (var robot in robotList)
|
|
{
|
|
switch (d21SingalRequest.SingalType)
|
|
{
|
|
case Enums.SingalType.小趋势看空:
|
|
case Enums.SingalType.小趋势看多:
|
|
Task.Factory.StartNew(() => d21TradeBusiness.TrendChanged(d21SingalRequest, robot));
|
|
break;
|
|
case Enums.SingalType.多交叉:
|
|
|
|
break;
|
|
case Enums.SingalType.空交叉:
|
|
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|