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.
45 lines
1.6 KiB
45 lines
1.6 KiB
3 years ago
|
using Binance.TradeRobot.Model.Base;
|
||
|
using Binance.TradeRobot.Model.Db;
|
||
|
using Binance.TradeRobot.Model.Dto;
|
||
|
using Microsoft.Extensions.Caching.Memory;
|
||
|
using System;
|
||
|
using System.Collections.Generic;
|
||
|
using System.Text;
|
||
|
using Yitter.IdGenerator;
|
||
|
|
||
|
namespace Binance.TradeRobot.Business
|
||
|
{
|
||
|
public class BaseTradeBusiness : BaseBusiness
|
||
|
{
|
||
|
|
||
|
protected DingBusiness dingBusiness { get; private set; }
|
||
|
protected GlobalContext globalContext { get; private set; }
|
||
|
|
||
|
public BaseTradeBusiness(IFreeSql fsql, NLogManager logManager, IIdGenerator idGenerator, IMemoryCache memoryCache, DingBusiness dingBusiness, GlobalContext globalContext) : base(fsql, logManager, idGenerator, memoryCache)
|
||
|
{
|
||
|
this.dingBusiness = dingBusiness;
|
||
|
this.globalContext = globalContext;
|
||
|
}
|
||
|
|
||
|
public void HandleError(Exception ex,
|
||
|
Enums.SingalType singalType,
|
||
|
List<ExecutionLog> logList,
|
||
|
RobotResponse robot,
|
||
|
string step)
|
||
|
{
|
||
|
logList.Add(new ExecutionLog()
|
||
|
{
|
||
|
Id = idGenerator.NewLong(),
|
||
|
SourceSingal = singalType,
|
||
|
RobotId = robot.Id,
|
||
|
CreateTime = DateTime.Now,
|
||
|
Content = ex.Message
|
||
|
});
|
||
|
try { fsql.Insert(logList).ExecuteAffrows(); } catch { }
|
||
|
var errorMsg = $"交易警报,{singalType},{robot.ExecuteKey},{robot.Id},{step}";
|
||
|
logManager.GetLogger(robot.ExecuteKey).Error(ex, errorMsg);
|
||
|
dingBusiness.Send($"{errorMsg} {ex.Message}");
|
||
|
}
|
||
|
}
|
||
|
}
|