| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687 |
- 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;
- /// <summary>
- /// 限价单
- /// </summary>
- public class OrderDetail : OrderBase
- {
- #region Fields
- /// <summary>
- /// 有效期
- /// </summary>
- private DateTime _expirationDate;
- /// <summary>
- /// 商品
- /// </summary>
- private string _goods;
- /// <summary>
- /// 限价
- /// </summary>
- private decimal _limit;
- /// <summary>
- /// 订单号
- /// </summary>
- private long _orderNumber;
- /// <summary>
- /// 止损价
- /// </summary>
- private decimal _stopLoss;
- /// <summary>
- ///止盈价
- /// </summary>
- private decimal _stopProfit;
- //手续费
- private decimal _charge;
- private eChannelOrderStatus _status;
- /// <summary>
- /// 委托价格
- /// </summary>
- private decimal _entrustPrice;
- /// <summary>
- /// 市场名称
- /// </summary>
- private string _marketName;
- #endregion Fields
- #region Properties
- /// <summary>
- /// 委托来源
- /// </summary>
- /// <value>The channelordersrc.</value>
- [PropertyDisc("ChannelOrderSrc")]
- public eChannelOrderSrc ChannelOrderSrc { get; set; }
- /// <summary>
- /// 资金账户Id
- /// </summary>
- [PropertyDisc("AccountID")]
- public ulong AccountId { get; set; }
- /// <summary>
- /// 委托时间
- /// </summary>
- [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 "-";
- }
- }
- }
- /// <summary>
- /// 建平
- /// </summary>
- [PropertyDisc("ChannelBuildType")]
- public eChannelBuildType BuildType { get; set; }
- public string BuildTypeDisplay
- {
- get { return BuildType.Discription(); }
- }
- ///// <summary>
- ///// 对冲标志
- ///// </summary>
- //[PropertyDisc("HedgeFlag")]
- //public eHedgeFlag HedgeFlag { get; set; }
- /// <summary>
- /// 委托价格
- /// </summary>
- [PropertyDisc("OrderPrice")]
- public decimal EntrustPrice
- {
- get { return _entrustPrice; }
- set { Set(() => EntrustPrice, ref _entrustPrice, value); }
- }
- /// <summary>
- /// 委托数量
- /// </summary>
- public decimal EntrustQty { get { return OpenOrderQty + CloseOrderQty; } }
- [PropertyDisc("OpenOrderQty")]
- public decimal OpenOrderQty { get; set; }
- [PropertyDisc("CloseOrderQty")]
- public decimal CloseOrderQty { get; set; }
- /// <summary>
- /// 成交数量
- /// </summary>
- public decimal TradeQty { get { return OpenTradeQty + CloseTradeQty; } }
- [PropertyDisc("OpenTradeQty")]
- public decimal OpenTradeQty { get; set; }
- [PropertyDisc("CloseTradeQty")]
- public decimal CloseTradeQty { get; set; }
- /// <summary>
- /// 显示状态
- /// </summary>
- public string DisplayStatus
- {
- get
- {
- return Status.Discription();
- }
- }
- /// <summary>
- /// 委托单号
- /// </summary>
- [PropertyDisc("OrderID")]
- public long OrderID { get; set; }
- /// <summary>
- /// 订单所属交易类型
- /// </summary>
- [PropertyDisc("MarketType")]
- public eTradeMode MarketType { get; set; }
- /// <summary>
- /// 资金模式
- /// </summary>
- [PropertyDisc("Moneymode")]
- public eMoneyMode Moneymode { get; set; }
- /// <summary>
- /// 时间校验类型
- /// </summary>
- [PropertyDisc("ValidType")]
- public ExpirationType VailType
- {
- get;
- set;
- }
- /// <summary>
- /// 获取或设置有效期
- /// Changes to that property's value raise the PropertyChanged event.
- /// </summary>
- [PropertyDisc("ValidTime")]
- public DateTime ExpirationDate
- {
- get { return _expirationDate; }
- set { Set(() => ExpirationDate, ref _expirationDate, value); }
- }
- /// <summary>
- /// 获取或设置 止损价
- /// Changes to that property's value raise the PropertyChanged event.
- /// </summary>
- [PropertyDisc("SlPrice")]
- public decimal StopLoss
- {
- get { return _stopLoss; }
- set { Set(() => StopLoss, ref _stopLoss, value); }
- }
- /// <summary>
- /// 显示格式化止损价
- /// </summary>
- public string DisplayStopLoss
- {
- get
- {
- if (StopLoss == 0) { return "-"; }
- return StopLoss.ToString();
- }
- }
- /// <summary>
- /// 获取或设置止盈价
- /// Changes to that property's value raise the PropertyChanged event.
- /// </summary>
- [PropertyDisc("SpPrice")]
- public decimal StopProfit
- {
- get { return _stopProfit; }
- set { Set(() => StopProfit, ref _stopProfit, value); }
- }
- /// <summary>
- /// 显示格式化止盈价
- /// </summary>
- public string DisplayStopProfit
- {
- get
- {
- if (StopProfit == 0) { return "-"; }
- return StopProfit.ToString();
- }
- }
- /// <summary>
- /// 状态
- /// </summary>
- [PropertyDisc("ChannelInnerOrderStatus")]
- public eChannelOrderStatus Status
- {
- get { return _status; }
- set { Set(() => Status, ref _status, value); }
- }
- ///// <summary>
- ///// 订单类型描述
- ///// </summary>
- //public string DisplayOrderType
- //{
- // get { return BuildType.Discription(); }
- //}
- public string StrVailType
- {
- get { return VailType.Discription(); }
- }
- /// <summary>
- /// 历史状态
- /// </summary>
- public string DisplayHistoryStatus
- {
- get
- {
- return Status.Discription();
- }
- }
- /// <summary>
- /// 关联委托单号
- /// </summary>
- 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;
- /// <summary>
- /// 可撤数量
- /// </summary>
- public decimal CanCancelQty
- {
- get { return _canCancelQty; }
- set { Set(() => CanCancelQty, ref _canCancelQty, value); }
- }
- private decimal _canceledQty;
- /// <summary>
- /// 已撤数量
- /// </summary>
- [PropertyDisc("CancelQty")]
- public decimal CanceledQty
- {
- get { return _canceledQty; }
- set { Set(() => CanceledQty, ref _canceledQty, value); }
- }
-
- private decimal _completeQty; //UnTradeQty
- /// <summary>
- /// 成交数量
- /// </summary>
- [PropertyDisc("TradeQty")]
- public decimal CompleteQty
- {
- get { return _completeQty; }
- set { Set(() => CompleteQty, ref _completeQty, value); }
- }
- /// <summary>
- /// 公开发售数量
- /// </summary>
- [PropertyDisc("PublicIssueTradeQty")]
- public decimal PublicIssueTradeQty { get; set; }
- /// <summary>
- /// 优先成交数量
- /// </summary>
- [PropertyDisc("PreTradeQty")]
- public decimal PreTradeQty { get; set; }
- /// <summary>
- /// 未成交数量
- /// </summary>
- public decimal UnTradeQty
- {
- get
- {
- return EntrustQty - CompleteQty - CanceledQty;
- }
- }
- /// <summary>
- /// 冻结保证金
- /// </summary>
- private decimal _freezeMargin;
- /// <summary>
- /// 冻结保证金
- /// </summary>
- [PropertyDisc("FrozenMargin")]
- public decimal FreezeMargin
- {
- get
- {
- return _freezeMargin;
- }
- set
- {
- Set(() => FreezeMargin, ref _freezeMargin, value);
- }
- }
- /// <summary>
- /// 冻结保证金[固定保留两位小数]
- /// </summary>
- public string FreezeMarginDisplay
- {
- get
- {
- return FreezeMargin.ToString("f2");
- }
- }
- private eOrderOperateType _operateType;
- /// <summary>
- /// 操作类型
- /// </summary>
- [PropertyDisc("OperateType")]
- public eOrderOperateType OperateType
- {
- get { return _operateType; }
- set { _operateType = value; }
- }
- /// <summary>
- /// 所属机构
- /// </summary>
- [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;
- }
- }
- }
- /// <summary>
- /// 显示格式化
- /// </summary>
- 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;
- /// <summary>
- /// 价格类型
- /// </summary>
- [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();
- }
- }
- /// <summary>
- /// 显示历史委托价格
- /// </summary>
- public string DisplayHistoryEntrustPrice
- {
- get
- {
- return EntrustPrice.ToString(PriceExpFormat);
- }
- }
- /// <summary>
- /// 市场名称
- /// </summary>
- public string MarketName
- {
- get { return _marketName; }
- set { Set(() => MarketName, ref _marketName, value); }
- }
- private uint _marketID;
- /// <summary>
- /// 市场ID
- /// </summary>
- [PropertyDisc("MarketID")]
- public uint MarketID
- {
- get { return _marketID; }
- set { Set(() => MarketID, ref _marketID, value); }
- }
- /// <summary>
- /// 委托交易日
- /// </summary>
- [PropertyDisc("TradeDate")]
- public DateTime EntrustTradeDate { get; set; }
- /// <summary>
- /// 有效时间
- /// </summary>
- [PropertyDisc("ValidTime")]
- public string ValidTime { get; set; }
- /// <summary>
- /// 平仓模式
- /// </summary>
- [PropertyDisc("CloseMode")]
- public TradeCloseMode TradeCloseMode { get; set; }
- /// <summary>
- /// 发售成交数量
- /// </summary>
- [PropertyDisc("IMTradeqty")]
- public long IMTradeqty { get; set; }
- private string _retDesc;
- /// <summary>
- /// 描述--委托单的描述
- /// </summary>
- [PropertyDisc("RetDesc")]
- public string RetDesc
- {
- get
- {
- return _retDesc ?? "--";
- }
- set { Set(() => RetDesc, ref _retDesc, value); }
- }
- /// <summary>
- /// 订单取消
- /// </summary>
- public decimal IMCanceledQty
- {
- get
- {
- if (Status == eChannelOrderStatus.ORDERSTATUS_CANCELED)
- {
- return CanceledQty;
- }
- return 0;
- }
- }
- /// <summary>
- /// 未成交状态集合(1,2)
- /// </summary>
- public string UnTradeStatus { get; set; }
- /// <summary>
- /// 是否可撤单
- /// </summary>
- public bool IsCancel
- {
- get
- {
- //委托状态 - 3:委托成功 7:部分成交 且委托来源不为交易服务的 可撤单
- return ((Status == eChannelOrderStatus.ORDERSTATUS_SUCCEED || Status == eChannelOrderStatus.ORDERSTATUS_REQUEST) && ChannelOrderSrc != eChannelOrderSrc.CHANNELORDERSRC_TRADE);
- }
- }
- private DateTime _cancelTime;
- /// <summary>
- /// hedge_innerOrderCancel表中的ActionTime字段表示撤单时间
- /// </summary>
- [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
- }
- }
|