GetHistoryDay(数据库)
定义
public virtual List<Stock_price_history> GetHistoryDay(DateTime beginTime, DateTime endTime)
描述
获取所有股票历史日数据(时间间隔不大时可用)
参数
参数名 |
类型 |
描述 |
beginTime |
DateTime |
开始时间 |
endTime |
DateTime |
结束时间 |
返回值
返回值 |
类型 |
描述 |
result |
List<Stock_price_history> |
股票历史记录表 日表 |
示例
public override void OnData(Slice slice)
{
//每日9.35取得当天需要的数据
if (Time.Hour == 9 && Time.Minute == 35)
{
Print($"每日9点35分获取当天数据 {Time}");
var yesterday = GetCalendarDateTime(Time, false).Result;//上个交易日
var theDayBefore = GetCalendarDateTime(GetCalendarDateTime(Time, false).Result, false).Result;//上上个交易日
//取到所有股票的上个交易日和上上个交易日的日数据
List<Stock_price_history> theDayBeforeHistoryList = GetHistoryDay(theDayBefore, yesterday);
SymbolPool.ForEach(x =>
{
SymbloAvg symbloAvg = symbloAvgs.Find(y => y.code == x.Value);
//上一个交易日的历史数据
var yesterdayHistory = theDayBeforeHistoryList.FirstOrDefault(y => y.Date == yesterday.Date && y.Code == x.Value);
//上上个交易日的历史数据
var theDayBeforeHistory = theDayBeforeHistoryList.FirstOrDefault(y => y.Date == theDayBefore.Date && y.Code == x.Value);
});
}
}