using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace YLErp.DBModels
{
///
/// 日终价格基础表
///
public class EodPriceBase : DBModelWithOperator
{
public static string 人工 = "人工";
public static string 系统 = "系统";
///
/// 合约代码
///
[DisplayName("合约代码")]
public virtual string UnderlyingCode { set; get; }
///
/// 估值日期
///
[DisplayName("估值日期")]
public DateTime ValueDate { set; get; }
///
/// 收盘价
///
[DisplayName("收盘价")]
public double ClosePrice { set; get; }
///
/// 结算价
///
[DisplayName("结算价")]
public virtual double SettlePrice { set; get; }
///
/// 参考价
///
[DisplayName("参考价")]
public virtual double? ReferencePrice { set; get; }
///
/// 最高价
///
[DisplayName("最高价")]
public virtual double? HighPrice { set; get; }
///
/// 最低价
///
[DisplayName("最低价")]
public virtual double? LowPrice { set; get; }
///
/// 数据来源
///
[DisplayName("数据来源")]
public virtual string DataSource { set; get; }
///
/// 源数据时间
///
[DisplayName("源数据时间")]
public string SourceTime { set; get; }
///
///
///
public double GetPrice(SettlementTypeEnum type)
{
switch (type)
{
default:
case SettlementTypeEnum.ClosePrice:
return ClosePrice;
case SettlementTypeEnum.ReferencePrice:
return ReferencePrice ?? ClosePrice;
case SettlementTypeEnum.SettlePrice:
return SettlePrice;
}
}
public override string ToString()
{
return $"{ValueDate:yyyy-MM-dd}--{UnderlyingCode}--{ClosePrice}";
}
}
///
/// 期货日终价格表
///
[Table("eod_commodity_future_price")]
public class eod_commodity_future_price : EodPriceBase
{
[DisplayName("标的信息")]
public int? UnderlyingId { get; set; }
[Column("FutureContractId"), Required]
public override string UnderlyingCode { get; set; }
public eod_commodity_future_price Clone()
{
return (eod_commodity_future_price)MemberwiseClone();
}
}
///
/// 股票日终价格表
///
[Table("eod_stock_price")]
public class eod_stock_price : EodPriceBase
{
///
/// 标的状态:正常 停牌 退市
///
[Column("UnderlyingStatus")]
[DisplayName("运行状态")]
public string UnderlyingStatus { get; set; }
[Column("StockId")]
public override string UnderlyingCode { get; set; }
[NotMapped]
public override double SettlePrice => 0;
public eod_stock_price Clone()
{
return (eod_stock_price)MemberwiseClone();
}
}
}