using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
//----------------------------------------------------------------
//Module Name: $safeprojectname$
//Purpose:
//CopyRight: Muchinfo
//History:
//----------------------------------------------------------------
//DateTime 2016/6/21 17:32:21
//Author
//Description Create
//----------------------------------------------------------------
using Muchinfo.MTPClient.Data.Helper;
namespace Muchinfo.MTPClient.Data.Quote
{
public class TradeDayPlan
{
// MarketTypeID 市场类型ID
//tradeday, 交易日
// opentime , 开市时间
// ReckonTime, 结算时间
// nextTradeDay, 下 一个交易日
// nextReckonTime,
// m.InReckon
///
/// 市场类型ID
///
[PropertyDisc("MarketTypeID")]
public long MarketTypeID { get; set; }
///
/// 交易日
///
[PropertyDisc("TradeDay")]
public DateTime TradeDay { get; set; }
///
/// 开市时间
///
[PropertyDisc("OpenTime")]
public string OpenTime { get; set; }
///
/// 开始周几
///
[PropertyDisc("OpenWeekDay")]
public int OpenWeekDay { get; set; }
///
/// 结算时间
///
[PropertyDisc("ReckonTime")]
public string ReckonTime { get; set; }
///
/// 结束周几
///
[PropertyDisc("CLOSEWEEKDAY")]
public int CloseWeekDay { get; set; }
///
/// 运行阶段
///
[PropertyDisc("RunStep")]
public int RunStep { get; set; }
///
/// 起始周几
///
[PropertyDisc("STARTWEEKDAY")]
public int StartWeekDay { get; set; }
///
/// 结束周几
///
[PropertyDisc("ENDWEEKDAY")]
public int EndWeekDay { get; set; }
///
/// 开始时间 HH:mm
///
[PropertyDisc("STARTTIME")]
public string Starttime { get; set; }
///
/// 结束时间 HH:mm
///
[PropertyDisc("ENDTIME")]
public string EndTime { get; set; }
///
/// 结算延时时间
///
[PropertyDisc("RECKONDELAY")]
public string ReckenDelay { get; set; }
///
/// 获取开始时间
///
///
public DateTime GetOpenTime()
{
if (this.TradeDay == DateTime.MinValue)
{
throw new Exception("traday is not valid !" + TradeDay);
}
var open = OpenWeekDay - (int)TradeDay.DayOfWeek;
var openTime = this.TradeDay.AddDays(open);
if (!DateTime.TryParse(openTime.ToString("yyyy-MM-dd ") + OpenTime, out openTime))
{
throw new Exception("openTime is not valid !:" + openTime.ToString("yyyy-MM-dd ") + OpenTime);
}
return openTime;
}
///
/// 获取结束时间
///
///
public DateTime GetReckonTime()
{
if (this.TradeDay == DateTime.MinValue)
{
throw new Exception("traday is not valid !" + TradeDay);
}
var close = CloseWeekDay - (int)TradeDay.DayOfWeek;
var closeTime = this.TradeDay.AddDays(close);
if (!DateTime.TryParse(closeTime.ToString("yyyy-MM-dd ") + ReckonTime, out closeTime))
{
throw new Exception("closeTime is not valid !:" + closeTime.ToString("yyyy-MM-dd ") + ReckonTime);
}
return closeTime;
}
///
/// 获取开始时间
///
///
public DateTime GetStartTime()
{
if (this.TradeDay == DateTime.MinValue)
{
throw new Exception("traday is not valid !" + TradeDay);
}
var start = StartWeekDay - (int)TradeDay.DayOfWeek;
var startTime = this.TradeDay.AddDays(start);
if (!DateTime.TryParse(startTime.ToString("yyyy-MM-dd ") + Starttime, out startTime))
{
throw new Exception("traday is not valid !:" + startTime.ToString("yyyy-MM-dd ") + Starttime);
}
return startTime;
}
///
/// 获取结束时间
///
///
public DateTime GetEndTime()
{
if (this.TradeDay == DateTime.MinValue)
{
throw new Exception("traday is not valid !" + TradeDay);
}
var end = EndWeekDay - (int)TradeDay.DayOfWeek;
var endTime = this.TradeDay.AddDays(end);
if (!DateTime.TryParse(endTime.ToString("yyyy-MM-dd ") + EndTime, out endTime))
{
throw new Exception("traday is not valid !:" + endTime.ToString("yyyy-MM-dd ") + EndTime);
}
return endTime;
}
}
}