using Muchinfo.MTPClient.Data.Enums;
using Muchinfo.MTPClient.Data.Helper;
using Muchinfo.MTPClient.Resources;
namespace Muchinfo.MTPClient.Data.Model.Account
{
using System;
///
/// 持仓明细表
///
public class HoldingOrder : OrderBase
{
#region Fields
///
/// 手续费
///
private decimal _charge;
///
/// 平仓价
///
private decimal _closePrice;
/////
///// 商品
/////
//private string _goods;
///
/// 持仓价
///
private decimal _holdingPrice;
///
/// 数量
///
private decimal _lot;
///
/// 建仓时间
///
private DateTime _openDate;
private Direction _openDirection;
///
/// 建仓价
///
private decimal _openPrice;
///
/// 订单号
///
private long _orderId;
///
/// 浮动盈亏
///
private decimal _pLFloat;
///
/// 止损价
///
private decimal _stopLoss;
///
///止盈价
///
private decimal _stopProfit;
///
/// 建仓单号
///
private int _openOrder;
///
/// 递延费
///
private decimal _interest;
///
/// 市场名称
///
private string _marketName;
#endregion Fields
#region Properties
#region Public Properties
///
/// Sets and gets 手续费
/// Changes to that property's value raise the PropertyChanged event.
///
[PropertyDisc("Charge")]
public decimal Charge
{
get { return _charge; }
set { Set(() => Charge, ref _charge, value); }
}
///
/// 冻结头寸
///
private decimal _positionFzQty;
///
/// 冻结头寸
///
[PropertyDisc("PositionFzQty")]
public decimal PositionFzQty
{
get { return _positionFzQty; }
set { Set(() => PositionFzQty, ref _positionFzQty, value); }
}
///
/// 所属机构
///
[PropertyDisc("AreaName")]
public string AreaName { get; set; }
///
/// 合约单位
///
[PropertyDisc("currentAgreeunit")]
public int currentAgreeunit { get; set; }
///
/// Sets and gets 平仓价
/// Changes to that property's value raise the PropertyChanged event.
///
public decimal ClosePrice
{
get
{
return _closePrice;
}
set
{
Set(() => ClosePrice, ref _closePrice, value);
RaisePropertyChanged(() => DisplayClosePrice);
}
}
public decimal ContrayClosePrice { get; set; }
///
/// 格式化平仓价
///
public string DisplayClosePrice
{
get
{
//if (ClosePrice > 0 && MarketType != eTradeMode.TRADEMODE_SALE)
if (ClosePrice > 0)
{
return ClosePrice.ToString(PriceFormat);
}
else
{
return "-";
}
}
}
///
/// 显示建仓日期
///
public string DisplayOpenDate
{
get
{
if (_openDate==DateTime.MinValue)
{
return "--";
}
return _openDate.ToString("yyyy-MM-dd HH:mm:ss");
}
}
private decimal _usedMargin; //占用保证金
///
/// 占用保证金
///
[PropertyDisc("UsedMargin")]
public decimal UsedMargin
{
get { return _usedMargin; }
set { Set(() => UsedMargin, ref _usedMargin, value); }
}
///
/// 占用保证金[固定保留两位]
///
public string UsedMarginDisplay
{
get
{
return UsedMargin.ToString("f2");
}
}
///
/// Sets and gets 持仓价
/// Changes to that property's value raise the PropertyChanged event.
///
[PropertyDisc("HolderPrice")]
public decimal HoldingPrice
{
get
{
return _holdingPrice;
}
set
{
Set(() => HoldingPrice, ref _holdingPrice, value);
}
}
///
/// 格式化持仓价
///
public string DisplayHoldingPrice
{
get
{
return HoldingPrice.ToString(PriceFormat);
}
}
///
/// Sets and gets 持仓 数量(包括锁仓数量).
///
///
[PropertyDisc("Qty")]
public decimal Lot
{
get { return _lot; }
set { Set(() => Lot, ref _lot, value); }
}
///
/// 建仓时间
/// Changes to that property's value raise the PropertyChanged event.
///
[PropertyDisc("OpenTime")]
public DateTime OpenDate
{
get { return _openDate; }
set { Set(() => OpenDate, ref _openDate, value); }
}
/// HoldingMargin
/// 显示建仓日期
///
public string StrOpenDirection
{
get
{
return Direction.Discription();
//switch (OpenDirection)
//{
// case Direction.Ask:
// return Client_Resource.Domain_SellOut;
// case Direction.Bid:
// return Client_Resource.Model_Buyin;
// default:
// return Client_Resource.Model_Buyin;
//}
}
}
///
/// Sets and gets 建仓价
/// Changes to that property's value raise the PropertyChanged event.
///
[PropertyDisc("OpenPrice")]
public decimal OpenPrice
{
get { return _openPrice; }
set { Set(() => OpenPrice, ref _openPrice, value); }
}
///
/// 显示委托价格
///
public string DisplayOpenPrice
{
get { return OpenPrice.ToString(PriceFormat); }
}
///
/// Sets and gets the orderNumber property.
/// Changes to that property's value raise the PropertyChanged event.
///
[PropertyDisc("OrderID")]
public long OrderID
{
get { return _orderId; }
set { Set(() => OrderID, ref _orderId, value); }
}
///
/// Sets and gets 浮动盈亏
/// Changes to that property's value raise the PropertyChanged event.
///
public decimal PLFloat
{
get { return _pLFloat; }
set { Set(() => PLFloat, ref _pLFloat, value); }
}
///
/// Sets and gets 止损价
/// 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(PriceFormat);
}
}
///
/// Sets and gets 止盈价
/// 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(PriceFormat);
}
}
private decimal _availQty;
///
/// 可用数量
///
[PropertyDisc("enableQty")]
public decimal AvailQty
{
get { return _availQty; }
set
{
Set(() => AvailQty, ref _availQty, value);
}
}
///
/// 保证金金额
///
private decimal _marginAccount;
private decimal _reckonPl;
///
/// 结算盈亏
///
[PropertyDisc("ReckonPL")]
public decimal ReckonPL
{
get { return _reckonPl; }
set { Set(() => ReckonPL, ref _reckonPl, value); }
}
public TradeAccount TradeAccount
{
get;
set;
}
///
/// 递延费
///
[PropertyDisc("Interest")]
public decimal Interest
{
get { return _interest; }
set { Set(() => Interest, ref _interest, value); }
}
///
/// 成交数数量
///
[PropertyDisc("TradeQty")]
public decimal TradeQty { get; set; }
///
/// 市场名称
///
public string MarketName
{
get { return _marketName; }
set { Set(() => MarketName, ref _marketName, value); }
}
private string _settlementMember;
///
/// 特别会员ID
///
public string SettlementMember
{
get { return _settlementMember; }
set { Set(() => SettlementMember, ref _settlementMember, value); }
}
private string _settlementMemberName;
///
/// 特别会员名字
///
public string SettlementMemberName
{
get
{
return _settlementMemberName;
}
set
{
Set(() => SettlementMemberName, ref _settlementMemberName, value);
}
}
///
/// 冻结数量
///
//[PropertyDisc("FreezeQty")]
//public decimal FrozenQty { get; set; }
///
/// 操作类型
///
public eOrderOperateType OrderOperate
{
get;
set;
}
///
/// 操作员
///
[PropertyDisc("OperatorId")]
public ulong OperatorID
{
get;
set;
}
private HoldStatus _holdStatus;
///
/// 持仓金额
///
[PropertyDisc("HolderAmount")]
public decimal HoldAmount { get; set; }
///
/// 锁仓的持仓金额
///
[PropertyDisc("lockHolderAmount")]
public decimal lockHolderAmount { get; set; }
///
/// 建仓金额
///
[PropertyDisc("TradeAmount")]
public decimal OpenAmount { get; set; }
///
/// 持仓状态
///
public HoldStatus HoldStatus
{
get { return _holdStatus; }
set { _holdStatus = value; }
}
private DateTime _tradeDate;
///
/// 交易日
///
public DateTime TradeDate
{
get { return _tradeDate; }
set { _tradeDate = value; }
}
///
/// 账号ID
///
[PropertyDisc("AccountId")]
public ulong Accountid { get; set; }
///
/// 持仓状态显示
///
public string HoldStatusDisplay
{
get
{
switch (HoldStatus)
{
case HoldStatus.NODELIVERY:
return "--";
default:
return Client_Resource.Model_DeliveryFreeze;
}
}
}
///
/// 显示到表单中操作类型
///
public string OrderOperateDisplay
{
get
{
return OperatorID == Accountid ? Client_Resource.Model_UserPlaceOrder : Client_Resource.Model_SystemPlaceOrder;
//switch (OrderOperate)
//{
// case OrderOperateType.UserOrder:
// return Client_Resource.Model_UserPlaceOrder;
// case OrderOperateType.SystemOrder:
// return Client_Resource.Model_SystemPlaceOrder;
// default:
// return Client_Resource.Model_UserPlaceOrder;
//}
}
}
///
/// 关联委托单据号(平仓委托)
///
[PropertyDisc("RelationTicket")]
public long RelationTicket { get; set; }
///
/// 订单所属交易类型
///
[PropertyDisc("MarketType")]
public eTradeMode MarketType { get; set; }
///
/// 锁仓数量
///
[PropertyDisc("LockQty")]
public decimal LockQty { get; set; }
///
/// 当前市值
///
public decimal CurrentAmount { get; set; }
private decimal _sumFloatPL;
///
/// 盈亏汇总
///
public decimal SumFloatPL
{
get { return _sumFloatPL; }
set { Set(() => SumFloatPL, ref _sumFloatPL, value); }
}
///
/// 持仓天数
///
[PropertyDisc("holderdays")]
public int HolderDays { get; set; }
///
/// /最小持仓天数
///
[PropertyDisc("MinHOLDERDAYS")]
public int MinHolderDays { get; set; }
///
/// T+N 冻结
///
[PropertyDisc("tnfreezeqty")]
public decimal tnFreezeqty { get; set; }
///
/// 是否可以平仓,T+N后可平仓
///
public bool IsCanClose
{
get
{
return HolderDays - MinHolderDays >=0; ///持仓天数超过最小持仓天数
}
}
///
/// 可平数量
///
public decimal CloseQty
{
get
{
return IsCanClose ? AvailQty : 0;
}
}
///
/// 显示商品最小持仓天数
///
public string CloseDaysDisplay
{
get
{
return string.Format(Client_Resource.Content_ShowCloseDays, MinHolderDays);
}
}
public bool IsCanButtunCloseVbs
{
get
{
//return MarketType != eTradeMode.TRADEMODE_SALE;
return true;
}
}
#region 小数位
///
/// 价格小数位
///
[PropertyDisc("decimalplace")]
public int DecimalPlace { get; set; }
public override string PriceExpFormat
{
get
{
if (DecimalPlace < 3)
{
return "F2";
}
else
{
return PriceFormat;
}
}
}
public override string PriceFormat
{
get
{
if (DecimalPlace > 0 && DecimalPlace < 20)
{
return "F" + DecimalPlace;
}
else
{
return "F2";
}
}
}
#endregion
#endregion Public Properties
#endregion Properties
#region 全额持仓字段MTP2.0
private uint _HolderQty = uint.MaxValue;
///
/// 持仓数量
///
public uint HolderQty
{
get { return _HolderQty; }
set { _HolderQty = value; }
}
private uint _limitCount = uint.MaxValue;
///
/// 受限数量
///
public uint limitCount
{
get { return _limitCount; }
set { _limitCount = value; }
}
private uint _FreezeQty = uint.MaxValue;
///
/// 冻结数量
///
public uint FreezeQty
{
get { return _FreezeQty; }
set { _FreezeQty = value; }
}
#endregion
#region 保证金持仓字段MTP2.0
private uint _BuyFrozenQty = uint.MaxValue;
///
/// 买持仓冻结
///
public uint BuyFrozenQty
{
get { return _BuyFrozenQty; }
set { _BuyFrozenQty = value; }
}
private uint _BuyOtherFrozenQty = uint.MaxValue;
///
/// 买持仓其他冻结
///
public uint BuyOtherFrozenQty
{
get { return _BuyOtherFrozenQty; }
set { _BuyOtherFrozenQty = value; }
}
private uint _SellFrozenQty = uint.MaxValue;
///
/// 卖持仓冻结
///
public uint SellFrozenQty
{
get { return _SellFrozenQty; }
set { _SellFrozenQty = value; }
}
private uint _SellOtherFrozenQty = uint.MaxValue;
///
/// 卖持仓其他冻结
///
public uint SellOtherFrozenQty
{
get { return _SellOtherFrozenQty; }
set { _SellOtherFrozenQty = value; }
}
private uint _BuyCurPositionQty = uint.MaxValue;
///
/// 买当前持仓数量
///
public uint BuyCurPositionQty
{
get { return _BuyCurPositionQty; }
set { _BuyCurPositionQty = value; }
}
private double _BuyCurHolderAmount = int.MinValue;
///
/// 买当前持仓金额
///
public double BuyCurHolderAmount
{
get { return _BuyCurHolderAmount; }
set { _BuyCurHolderAmount = value; }
}
private uint _SellCurPositionQty = uint.MaxValue;
///
/// 卖当前持仓数量
///
public uint SellCurPositionQty
{
get { return _SellCurPositionQty; }
set { _SellCurPositionQty = value; }
}
private double _SellCurHolderAmount = int.MinValue;
///
/// 卖当前持仓金额
///
public double SellCurHolderAmount
{
get { return _SellCurHolderAmount; }
set { _SellCurHolderAmount = value; }
}
#endregion
}
}