using Muchinfo.MTPClient.Data.Enums;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Muchinfo.MTPClient.Data.Helper;
namespace Muchinfo.MTPClient.Data.Model.Account
{
///
/// 止盈止损单对象
///
public class SPSLOrderModel
{
#region 查询返回字段
[PropertyDisc("OrderId")]
public ulong OrderId { get; set; }
[PropertyDisc("AccountId")]
public long AccountId { get; set; }
[PropertyDisc("LoginId")]
public long LoginId { get; set; }
[PropertyDisc("GoodsId")]
public uint GoodsId { get; set; }
[PropertyDisc("MarketId")]
public uint MarketId { get; set; }
[PropertyDisc("OrderQty")]
public decimal OrderQty { get; set; }
[PropertyDisc("ValidType")]
public ExpirationType ValidType { get; set; }
[PropertyDisc("SPSLType")]
public SPSLOrderType SPSLType { get; set; }
[PropertyDisc("PriceType")]
public ChannelPriceMode PriceType { get; set; }
[PropertyDisc("TriggerType")]
public SPSLTriggerType TriggerType { get; set; }
[PropertyDisc("OrderSrc")]
public eOrderSrc OrderSrc { get; set; }
[PropertyDisc("BuyOrSell")]
public Direction BuyOrSell { get; set; }
[PropertyDisc("SPPrice")]
public decimal SPPrice { get; set; }
[PropertyDisc("SLPrice")]
public decimal SLPrice { get; set; }
[PropertyDisc("Status")]
public SPSLOrderStatus Status { get; set; }
[PropertyDisc("CreateTime")]
public DateTime CreateTime { get; set; }
[PropertyDisc("UpdateTime")]
public DateTime UpdateTime { get; set; }
#endregion
///
/// 单据商品
///
public QuoteGoods QuoteGoods { get; set; }
///
/// Gets the goods code.
///
/// The goods code.
public string GoodsCode
{
get { return QuoteGoods == null ? string.Empty : QuoteGoods.GoodsCode; }
}
///
/// Gets the name of the goods.
///
/// The name of the goods.
public string GoodsName
{
get { return QuoteGoods == null ? string.Empty : QuoteGoods.Name; }
}
///
/// Gets the direction display.
///
/// The direction display.
public string DirectionDisplay
{
// 止损止盈单显示的是持仓方向 <- 下止损止盈单时方向使用的已经是持仓方向,这里不用再取反
get
{
//var buyOrSell = BuyOrSell == Direction.Ask ? Direction.Bid : Direction.Ask;
return BuyOrSell.Discription();
}
}
///
/// Gets the SPSL type display.
///
/// The SPSL type display.
public string SPSLTypeDisplay
{
get
{
switch (SPSLType)
{
case SPSLOrderType.SPOrder:
return "止盈";
case SPSLOrderType.SLOrder:
return "止损";
case SPSLOrderType.Cancel:
return "撤单";
case SPSLOrderType.SPSL:
return "止盈止损";
default:
return SPSLType.Discription("spsltype");
}
//更新协议后使用
return SPSLType.Discription("spsltype");
}
}
///
/// Gets the trigger type display.
///
/// The trigger type display.
public string TriggerTypeDisplay
{
get { return TriggerType.Discription("triggertype"); }
}
///
/// Gets the trigger type display.
///
/// The trigger type display.
public string PriceDisplay
{
get
{
var spPrice = SPPrice > 0 ? SPPrice.ToString(PriceExpFormat) : "-";
var slPrice = SLPrice > 0 ? SLPrice.ToString(PriceExpFormat) : "-";
return spPrice + "/" + slPrice;
}
}
///
/// Gets the price type display.
///
/// The price type display.
public string PriceTypeDisplay
{
get { return PriceType.Discription("pricetype"); }
}
///
/// Gets the status display.
///
/// The status display.
public string StatusDisplay
{
get { return Status.Discription("spslstatus"); }
}
///
/// Gets the valid type display.
///
/// The valid type display.
public string ValidTypeDisplay
{
get { return ValidType.Discription(); }
}
///
/// Gets the create time display.
///
/// The create time display.
public string CreateTimeDisplay
{
get { return CreateTime.ToString("yyyy-MM-dd HH:mm:ss"); }
}
///
/// Gets a value indicating whether this instance is cancel.
///
/// true if this instance is cancel; otherwise, false.
public bool IsCancel
{
//OrderSrc = 5:交易服务下的止盈止损单的不能撤单
get { return Status == SPSLOrderStatus.NotTrigger && OrderSrc != eOrderSrc.ORDERSRC_TRADE; }
}
///
/// Gets the price exp format.
///
/// The price exp format.
public string PriceExpFormat
{
get
{
if (this.QuoteGoods == null || this.QuoteGoods.GoodsParameters == null)
{
// return "F0";
//}
//if (this.QuoteGoods.GoodsParameters.HqExchFigures < 3)
//{
return "F2";
}
else
{
return QuoteGoods.FormatPrice;
}
}
}
}
}