10 changed files with 109 additions and 16 deletions
@ -0,0 +1,41 @@ |
|||
using Binance.TradeRobot.Common.DI; |
|||
using Binance.TradeRobot.Model.Base; |
|||
using Binance.TradeRobot.Model.Db; |
|||
using Binance.TradeRobot.Model.Dto; |
|||
using Binance.TradeRobot.Model.RuningInfo; |
|||
using Microsoft.Extensions.Caching.Memory; |
|||
using Microsoft.Extensions.DependencyInjection; |
|||
using System; |
|||
using Yitter.IdGenerator; |
|||
|
|||
namespace Binance.TradeRobot.Business |
|||
{ |
|||
[BatchRegistration(ServiceLifetime.Singleton, RegistrationType.Interface)] |
|||
public class D21TradeBusiness : BaseBusiness, ITradeBusiness |
|||
{ |
|||
public D21TradeBusiness(IFreeSql fsql, NLogManager logManager, IIdGenerator idGenerator, IMemoryCache memoryCache) : base(fsql, logManager, idGenerator, memoryCache) |
|||
{ |
|||
|
|||
} |
|||
|
|||
public Enums.TradePolicy TradePolicy => Enums.TradePolicy.动量趋势v21; |
|||
|
|||
public void TrendChanged<T, T1>(T singalRequest, T1 robot) where T : BaseSingalRequest where T1 : RobotResponse |
|||
{ |
|||
var executionLog = new ExecutionLog() |
|||
{ |
|||
Id = idGenerator.NewLong(), |
|||
RobotId = robot.Id, |
|||
CreateTime = DateTime.Now, |
|||
SourceSingal = singalRequest.SingalType, |
|||
Content = $"收到趋势信号【{singalRequest.SingalType}】" |
|||
}; |
|||
fsql.Insert(executionLog).ExecuteAffrows(); |
|||
var d21RuningInfo = RedisHelper.Get<D21RuningInfo>(robot.Id.ToString()); |
|||
if (d21RuningInfo == null) |
|||
d21RuningInfo = new D21RuningInfo() { RobotId = robot.Id }; |
|||
d21RuningInfo.RecentSmallTrendSingal = singalRequest.SingalType; |
|||
RedisHelper.Set(robot.Id.ToString(), d21RuningInfo); |
|||
} |
|||
} |
|||
} |
@ -0,0 +1,12 @@ |
|||
using Binance.TradeRobot.Model.Base; |
|||
using Binance.TradeRobot.Model.Dto; |
|||
|
|||
namespace Binance.TradeRobot.Business |
|||
{ |
|||
public interface ITradeBusiness |
|||
{ |
|||
Enums.TradePolicy TradePolicy { get; } |
|||
|
|||
void TrendChanged<T, T1>(T singalRequest, T1 robot) where T : BaseSingalRequest where T1 : RobotResponse; |
|||
} |
|||
} |
@ -0,0 +1,14 @@ |
|||
using Binance.TradeRobot.Model.Base; |
|||
|
|||
namespace Binance.TradeRobot.Model.RuningInfo |
|||
{ |
|||
public class D21RuningInfo |
|||
{ |
|||
public long RobotId { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 最近一次小趋势信号
|
|||
/// </summary>
|
|||
public Enums.SingalType RecentSmallTrendSingal { get; set; } |
|||
} |
|||
} |
Loading…
Reference in new issue