14 changed files with 285 additions and 39 deletions
@ -0,0 +1,26 @@ |
|||||
|
using Binance.TradeRobot.Business.Business; |
||||
|
using Binance.TradeRobot.Model.Dto; |
||||
|
using Microsoft.AspNetCore.Mvc; |
||||
|
|
||||
|
namespace Binance.TradeRobot.API.Controllers |
||||
|
{ |
||||
|
public class SingalController : BaseApiController |
||||
|
{ |
||||
|
private SingalBusiness singalBusiness; |
||||
|
|
||||
|
public SingalController(SingalBusiness singalBusiness) |
||||
|
{ |
||||
|
this.singalBusiness = singalBusiness; |
||||
|
} |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// D21杠杆/合约信号接口
|
||||
|
/// </summary>
|
||||
|
/// <param name="d21SingalRequest"></param>
|
||||
|
[HttpPost] |
||||
|
public void D21Singnal([FromBody] D21SingalRequest d21SingalRequest) |
||||
|
{ |
||||
|
singalBusiness.D21Singnal(d21SingalRequest); |
||||
|
} |
||||
|
} |
||||
|
} |
@ -0,0 +1,48 @@ |
|||||
|
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.Linq; |
||||
|
using Yitter.IdGenerator; |
||||
|
|
||||
|
namespace Binance.TradeRobot.Business.Business |
||||
|
{ |
||||
|
[BatchRegistration(ServiceLifetime.Singleton, RegistrationType.Self)] |
||||
|
public class SingalBusiness : BaseBusiness |
||||
|
{ |
||||
|
private RobotBusiness robotBusiness; |
||||
|
|
||||
|
public SingalBusiness(IFreeSql fsql, |
||||
|
NLogManager logManager, |
||||
|
IIdGenerator idGenerator, |
||||
|
IMemoryCache memoryCache, |
||||
|
RobotBusiness robotBusiness) : base(fsql, logManager, idGenerator, memoryCache) |
||||
|
{ |
||||
|
this.robotBusiness = robotBusiness; |
||||
|
} |
||||
|
|
||||
|
public void D21Singnal(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(); |
||||
|
switch (d21SingalRequest.SingalType) |
||||
|
{ |
||||
|
case Enums.SingalType.小趋势看空: |
||||
|
case Enums.SingalType.小趋势看多: |
||||
|
|
||||
|
break; |
||||
|
case Enums.SingalType.多交叉: |
||||
|
|
||||
|
break; |
||||
|
case Enums.SingalType.空交叉: |
||||
|
|
||||
|
break; |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
} |
@ -0,0 +1,41 @@ |
|||||
|
using Binance.TradeRobot.Model.Base; |
||||
|
|
||||
|
namespace Binance.TradeRobot.Model.Dto |
||||
|
{ |
||||
|
public class BaseSingalRequest |
||||
|
{ |
||||
|
public Enums.SingalType SingalType { get; set; } |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 交易对
|
||||
|
/// </summary>
|
||||
|
public string Symbol { get; set; } |
||||
|
|
||||
|
public Enums.SignalPeriod KLinePeriodic { get; set; } |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 备注
|
||||
|
/// </summary>
|
||||
|
public string Remark { get; set; } |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 最高价
|
||||
|
/// </summary>
|
||||
|
public decimal HighestPrice { get; set; } |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 最低价
|
||||
|
/// </summary>
|
||||
|
public decimal LowestPrice { get; set; } |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 开盘价
|
||||
|
/// </summary>
|
||||
|
public decimal OpenPrice { get; set; } |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 收盘价
|
||||
|
/// </summary>
|
||||
|
public decimal ClosePrice { get; set; } |
||||
|
} |
||||
|
} |
@ -0,0 +1,7 @@ |
|||||
|
namespace Binance.TradeRobot.Model.Dto |
||||
|
{ |
||||
|
public class D21SingalRequest : BaseSingalRequest |
||||
|
{ |
||||
|
|
||||
|
} |
||||
|
} |
Loading…
Reference in new issue