using System.Linq;
using System.Runtime.Remoting.Activation;
using Muchinfo.MTPClient.Data.Enums;
using Muchinfo.MTPClient.Data.Helper;
using Muchinfo.MTPClient.Resources;
using System.Text;
namespace Muchinfo.MTPClient.Data.Model.Account
{
using System;
///
/// 限价单
///
public class OrderDetail : OrderBase
{
#region Fields
///
/// 有效期
///
private DateTime _expirationDate;
///
/// 商品
///
private string _goods;
///
/// 限价
///
private decimal _limit;
///
/// 订单号
///
private long _orderNumber;
///
/// 止损价
///
private decimal _stopLoss;
///
///止盈价
///
private decimal _stopProfit;
//手续费
private decimal _charge;
private eChannelOrderStatus _status;
///
/// 委托价格
///
private decimal _entrustPrice;
///
/// 市场名称
///
private string _marketName;
#endregion Fields
#region Properties
///
/// 委托来源
///
/// The channelordersrc.
[PropertyDisc("ChannelOrderSrc")]
public eChannelOrderSrc ChannelOrderSrc { get; set; }
///
/// 资金账户Id
///
[PropertyDisc("AccountID")]
public ulong AccountId { get; set; }
///
/// 委托时间
///
[PropertyDisc("OrderTime")]
public DateTime EntrustTime { get; set; }
public string EntrustTimeDisplay
{
get
{
if (EntrustTime != null)
{
return EntrustTime.ToString("yyyy-MM-dd HH:mm:ss");
}
else
{
return "-";
}
}
}
///
/// 建平
///
[PropertyDisc("ChannelBuildType")]
public eChannelBuildType BuildType { get; set; }
public string BuildTypeDisplay
{
get { return BuildType.Discription(); }
}
/////
///// 对冲标志
/////
//[PropertyDisc("HedgeFlag")]
//public eHedgeFlag HedgeFlag { get; set; }
///
/// 委托价格
///
[PropertyDisc("OrderPrice")]
public decimal EntrustPrice
{
get { return _entrustPrice; }
set { Set(() => EntrustPrice, ref _entrustPrice, value); }
}
///
/// 委托数量
///
public decimal EntrustQty { get { return OpenOrderQty + CloseOrderQty; } }
[PropertyDisc("OpenOrderQty")]
public decimal OpenOrderQty { get; set; }
[PropertyDisc("CloseOrderQty")]
public decimal CloseOrderQty { get; set; }
///
/// 成交数量
///
public decimal TradeQty { get { return OpenTradeQty + CloseTradeQty; } }
[PropertyDisc("OpenTradeQty")]
public decimal OpenTradeQty { get; set; }
[PropertyDisc("CloseTradeQty")]
public decimal CloseTradeQty { get; set; }
///
/// 显示状态
///
public string DisplayStatus
{
get
{
return Status.Discription();
}
}
///
/// 委托单号
///
[PropertyDisc("OrderID")]
public long OrderID { get; set; }
///
/// 订单所属交易类型
///
[PropertyDisc("MarketType")]
public eTradeMode MarketType { get; set; }
///
/// 资金模式
///
[PropertyDisc("Moneymode")]
public eMoneyMode Moneymode { get; set; }
///
/// 时间校验类型
///
[PropertyDisc("ValidType")]
public ExpirationType VailType
{
get;
set;
}
///
/// 获取或设置有效期
/// Changes to that property's value raise the PropertyChanged event.
///
[PropertyDisc("ValidTime")]
public DateTime ExpirationDate
{
get { return _expirationDate; }
set { Set(() => ExpirationDate, ref _expirationDate, value); }
}
///
/// 获取或设置 止损价
/// Changes to that property's value raise the PropertyChanged event.
///
[PropertyDisc("SlPrice")]
public decimal StopLoss
{
get { return _stopLoss; }
set { Set(() => StopLoss, ref _stopLoss, value); }
}
///
/// 显示格式化止损价
///
public string DisplayStopLoss
{
get
{
if (StopLoss == 0) { return "-"; }
return StopLoss.ToString();
}
}
///
/// 获取或设置止盈价
/// Changes to that property's value raise the PropertyChanged event.
///
[PropertyDisc("SpPrice")]
public decimal StopProfit
{
get { return _stopProfit; }
set { Set(() => StopProfit, ref _stopProfit, value); }
}
///
/// 显示格式化止盈价
///
public string DisplayStopProfit
{
get
{
if (StopProfit == 0) { return "-"; }
return StopProfit.ToString();
}
}
///
/// 状态
///
[PropertyDisc("ChannelInnerOrderStatus")]
public eChannelOrderStatus Status
{
get { return _status; }
set { Set(() => Status, ref _status, value); }
}
/////
///// 订单类型描述
/////
//public string DisplayOrderType
//{
// get { return BuildType.Discription(); }
//}
public string StrVailType
{
get { return VailType.Discription(); }
}
///
/// 历史状态
///
public string DisplayHistoryStatus
{
get
{
return Status.Discription();
}
}
///
/// 关联委托单号
///
private long _relationTicket;
[PropertyDisc("RelationTicket")]
public long RelationTicket
{
get
{
return _relationTicket;
}
set
{
Set(() => RelationTicket, ref _relationTicket, value);
}
}
public string DisplayRelationID
{
get
{
if (_relationTicket == 0)
{
return "--";
}
return _relationTicket + string.Empty;
}
}
private decimal _canCancelQty;
///
/// 可撤数量
///
public decimal CanCancelQty
{
get { return _canCancelQty; }
set { Set(() => CanCancelQty, ref _canCancelQty, value); }
}
private decimal _canceledQty;
///
/// 已撤数量
///
[PropertyDisc("CancelQty")]
public decimal CanceledQty
{
get { return _canceledQty; }
set { Set(() => CanceledQty, ref _canceledQty, value); }
}
private decimal _completeQty; //UnTradeQty
///
/// 成交数量
///
[PropertyDisc("TradeQty")]
public decimal CompleteQty
{
get { return _completeQty; }
set { Set(() => CompleteQty, ref _completeQty, value); }
}
///
/// 公开发售数量
///
[PropertyDisc("PublicIssueTradeQty")]
public decimal PublicIssueTradeQty { get; set; }
///
/// 优先成交数量
///
[PropertyDisc("PreTradeQty")]
public decimal PreTradeQty { get; set; }
///
/// 未成交数量
///
public decimal UnTradeQty
{
get
{
return EntrustQty - CompleteQty - CanceledQty;
}
}
///
/// 冻结保证金
///
private decimal _freezeMargin;
///
/// 冻结保证金
///
[PropertyDisc("FrozenMargin")]
public decimal FreezeMargin
{
get
{
return _freezeMargin;
}
set
{
Set(() => FreezeMargin, ref _freezeMargin, value);
}
}
///
/// 冻结保证金[固定保留两位小数]
///
public string FreezeMarginDisplay
{
get
{
return FreezeMargin.ToString("f2");
}
}
private eOrderOperateType _operateType;
///
/// 操作类型
///
[PropertyDisc("OperateType")]
public eOrderOperateType OperateType
{
get { return _operateType; }
set { _operateType = value; }
}
///
/// 所属机构
///
[PropertyDisc("AreaName")]
public string AreaName { get; set; }
public string EntrustPriceDisplay
{
get
{
if (ePriceMode.PRICEMODE_MARKET == PriceMode) // 市价,显示市价2个字
{
return Client_Resource.EntrustOrderFrame_Market;
}
else
{
return DisplayEntrustPrice;
}
}
}
///
/// 显示格式化
///
public string DisplayEntrustPrice
{
get
{
string result = EntrustPrice.ToString(PriceExpFormat);//服务端已做小数位处理
//if (eTradeMode.TRADEMODE_MARKETMAKE == MarketType)
//{
// switch (BuildType)
// {
// case eChannelBuildType.CHANNELBUILDTYPE_CLOSE:
// //case eBuildType.BUILDTYPE_CLOSETHENOPEN:
// result = "-";
// break;
// default:
// result = EntrustPrice.ToString(PriceFormat);
// //result = EntrustPrice.ToString(); //服务端已做小数位处理
// break;
// }
//}
//else if (eTradeMode.TRADEMODE_BIDDINGMARKETMAKE == MarketType)
//{
// result = PriceMode == ePriceMode.PRICEMODE_MARKET ? "-" : result;
//}
return result;
}
}
private ePriceMode _ePriceMode = ePriceMode.PRICEMODE_LIMIT;
///
/// 价格类型
///
[PropertyDisc("PriceMode")]
public ePriceMode PriceMode
{
get
{
return _ePriceMode;
}
set
{
_ePriceMode = value;
}
}
private eListingSelectType _eSelectType = eListingSelectType.LISTINGSELECTTYPE_DELISTING;
[PropertyDisc("ListingSelectType")]
public eListingSelectType ListingSelectType
{
get
{
return _eSelectType;
}
set
{
Set(() => ListingSelectType, ref _eSelectType, value);
RaisePropertyChanged(() => DisplayListingSelectType);
}
}
public string DisplayListingSelectType
{
get
{
return ListingSelectType.Discription();
}
}
public string DisplayOpenDirection
{
get
{
return Direction.Discription();
}
}
///
/// 显示历史委托价格
///
public string DisplayHistoryEntrustPrice
{
get
{
return EntrustPrice.ToString(PriceExpFormat);
}
}
///
/// 市场名称
///
public string MarketName
{
get { return _marketName; }
set { Set(() => MarketName, ref _marketName, value); }
}
private uint _marketID;
///
/// 市场ID
///
[PropertyDisc("MarketID")]
public uint MarketID
{
get { return _marketID; }
set { Set(() => MarketID, ref _marketID, value); }
}
///
/// 委托交易日
///
[PropertyDisc("TradeDate")]
public DateTime EntrustTradeDate { get; set; }
///
/// 有效时间
///
[PropertyDisc("ValidTime")]
public string ValidTime { get; set; }
///
/// 平仓模式
///
[PropertyDisc("CloseMode")]
public TradeCloseMode TradeCloseMode { get; set; }
///
/// 发售成交数量
///
[PropertyDisc("IMTradeqty")]
public long IMTradeqty { get; set; }
private string _retDesc;
///
/// 描述--委托单的描述
///
[PropertyDisc("RetDesc")]
public string RetDesc
{
get
{
return _retDesc ?? "--";
}
set { Set(() => RetDesc, ref _retDesc, value); }
}
///
/// 订单取消
///
public decimal IMCanceledQty
{
get
{
if (Status == eChannelOrderStatus.ORDERSTATUS_CANCELED)
{
return CanceledQty;
}
return 0;
}
}
///
/// 未成交状态集合(1,2)
///
public string UnTradeStatus { get; set; }
///
/// 是否可撤单
///
public bool IsCancel
{
get
{
//委托状态 - 3:委托成功 7:部分成交 且委托来源不为交易服务的 可撤单
return ((Status == eChannelOrderStatus.ORDERSTATUS_SUCCEED || Status == eChannelOrderStatus.ORDERSTATUS_REQUEST) && ChannelOrderSrc != eChannelOrderSrc.CHANNELORDERSRC_TRADE);
}
}
private DateTime _cancelTime;
///
/// hedge_innerOrderCancel表中的ActionTime字段表示撤单时间
///
[PropertyDisc("CancelTime")]
public DateTime CancelTime
{
get
{
return _cancelTime;
}
set
{
Set(() => CancelTime, ref _cancelTime, value);
RaisePropertyChanged(() => CancelTimeDisplay);
}
}
public string CancelTimeDisplay
{
get
{
string time = CancelTime.ToString("yyyy-MM-dd HH:mm:ss");
if (@"0001-01-01 00:00:00".Equals(time))// 数据库中没有值得时候,通用查询会返回这样的数据下来。特殊处理一下
{
return "--";
}
else
{
return time;
}
}
}
#endregion Properties
#region 常量
private readonly string c_CloseToday = Client_Resource.Domain_TodayClose;
private readonly string c_CloseHistory = Client_Resource.Domain_HistoryClose;
private readonly string c_CloseAll = Client_Resource.Domain_CloseAll;
private readonly string c_OrderMode_STD = Client_Resource.Domain_NoDeal_PendingOrder;
private readonly string c_MovingSl = Client_Resource.Domain_Stop_Trriger;
private readonly string c_Reverse = Client_Resource.Domain_BackhandOpen_AllowSpreads;
private readonly string c_StopLossProfit = Client_Resource.Domain_Stop_OnlyProfit_AllowSpreads;
#endregion
}
}