using System.Collections.Generic;
using System.Windows.Documents;
using Muchinfo.MTPClient.Data.Enums;
using Muchinfo.MTPClient.Data.Helper;
using System;
namespace Muchinfo.MTPClient.Data.Model.Account
{
public class HoldingSummaryNew : OrderBase
{
[PropertyDisc("AccountID")]
public ulong AccountId
{
get;
set;
}
///
/// 期初持仓数量
///
private decimal _positionQty;
///
/// 期初持仓数量
/// Changes to that property's value raise the PropertyChanged event.
///
[PropertyDisc("PositionQty")]
public decimal PositionQty
{
get { return _positionQty; }
set { Set(() => PositionQty, ref _positionQty, value); }
}
///
/// 期初持仓总金额
///
private decimal _holderAmount;
///
/// 期初持仓总金额
///
[PropertyDisc("HolderAmount")]
public decimal HolderAmount
{
get{ return _holderAmount; }
set { Set(() => HolderAmount, ref _holderAmount, value); }
}
///
/// 当前持仓数量
///
private decimal _curPositionQty;
///
/// 当前持仓数量
/// Changes to that property's value raise the PropertyChanged event.
///
[PropertyDisc("CurPositionQty")]
public decimal CurPositionQty
{
get { return _curPositionQty; }
set
{
Set(() => CurPositionQty, ref _curPositionQty, value);
RaisePropertyChanged(() => AvailQty);
}
}
private decimal _availQty;
public decimal AvailQty
{
get
{
_availQty=_curPositionQty - _frozenQty - _otherFrozenQty;
return _availQty;
}
set { Set(() => AvailQty, ref _availQty, value); }
}
///
/// 当前持仓总金额
///
private decimal _curHolderAmount;
///
/// 当前持仓总金额
/// Changes to that property's value raise the PropertyChanged event.
///
[PropertyDisc("CurHolderAmount")]
public decimal CurHolderAmount
{
get { return _curHolderAmount; }
set
{
Set(() => CurHolderAmount, ref _curHolderAmount, value);
RaisePropertyChanged(() => GoodsPaymentDisplay);
RaisePropertyChanged(() => ProfitPercen);
}
}
///
/// 持仓冻结数量
///
private decimal _frozenQty;
///
/// 持仓冻结数量
/// Changes to that property's value raise the PropertyChanged event.
///
[PropertyDisc("FrozenQty")]
public decimal FrozenQty
{
get { return _frozenQty; }
set
{
Set(() => FrozenQty, ref _frozenQty, value);
RaisePropertyChanged(() => AvailQty);
}
}
///
/// 其他冻结数量
///
private decimal _otherFrozenQty;
///
/// 其他冻结数量
///
[PropertyDisc("OtherFrozenQty")]
public decimal OtherFrozenQty
{
get { return _otherFrozenQty; }
set
{
Set(() => OtherFrozenQty, ref _otherFrozenQty, value);
RaisePropertyChanged(() => AvailQty);
}
}
private decimal _openReqQty;
[PropertyDisc("OpenReqQty")]
public decimal OpenReqQty
{
get { return _openReqQty; }
set { Set(() => OpenReqQty, ref _openReqQty, value); }
}
private decimal _openTotalQty;
[PropertyDisc("OpenTotalQty")]
public decimal OpenTotalQty
{
get { return _openTotalQty; }
set { Set(() => OpenTotalQty, ref _openTotalQty, value); }
}
private decimal _closeTotalQty;
[PropertyDisc("CloseTotalQty")]
public decimal CloseTotalQty
{
get { return _closeTotalQty; }
set { Set(() => CloseTotalQty, ref _closeTotalQty, value); }
}
///
/// 持仓均价
///
private decimal _holdingAVGPrice;
///
/// 获取或设置 持仓均价
/// Changes to that property's value raise the PropertyChanged event.
///
public decimal HoldingAVGPrice
{
get { return _holdingAVGPrice; }
set
{
Set(() => HoldingAVGPrice, ref _holdingAVGPrice, value);
RaisePropertyChanged(() => DisplayHoldingAVGPrice);
}
}
///
/// 显示持仓均价
///
public string DisplayHoldingAVGPrice
{
get
{
if (HoldingAVGPrice > 0)
{
return HoldingAVGPrice.ToString(PriceExpFormat);
}
else
{
return "-";
}
}
}
[PropertyDisc("AgreeUnit")]
public decimal AgreeUnit { get; set; }
///
/// 交割标志
///
[PropertyDisc("DeliveryFlag")]
public eDeliveryFlag DeliveryFlag
{
get;
set;
}
public string StrOpenDirection
{
get
{
return Direction.Discription();
}
}
///
/// 最新价
///
private decimal _latestPrice;
///
/// 获取或设置 最新价
/// Changes to that property's value raise the PropertyChanged event.
///
public decimal LatestPrice
{
get
{
return _latestPrice;
}
set
{
Set(() => LatestPrice, ref _latestPrice, value);
RaisePropertyChanged(() => DisplayLatestPrice);
RaisePropertyChanged(() => MarketValue);
}
}
///
/// 显示最新价
///
public string DisplayLatestPrice
{
get
{
if (LatestPrice > 0)
{
return LatestPrice.ToString(PriceFormat);
}
else
{
return "-";
}
}
}
public string GoodsPaymentDisplay
{
get
{
if (CurHolderAmount != 0)
{
return CurHolderAmount.ToString("f2");
}
else
{
return "-";
}
}
}
private decimal _marketValue;
///
/// 市值=最新价*持有总量*合约单位;
///
public decimal MarketValue
{
get { return _marketValue; }
set
{
Set(() => MarketValue, ref _marketValue, value);
RaisePropertyChanged(() => MarketValueDisplay);
RaisePropertyChanged(() => ProfitPercen);
}
}
public string MarketValueDisplay
{
get
{
if (MarketValue != 0)
{
return MarketValue.ToString("f2");
}
else
{
return "-";
}
}
}
///
/// 浮动盈亏
///
private decimal _pLFloat;
///
/// 获取或设置 浮动盈亏
/// Changes to that property's value raise the PropertyChanged event.
///
public decimal PLFloat
{
get
{
return _pLFloat;
}
set
{
Set(() => PLFloat, ref _pLFloat, value);
RaisePropertyChanged(() => DisplayPLFloat);
RaisePropertyChanged(() => SumFloatPL);
}
}
///
/// 显示 浮动盈亏
///
public string DisplayPLFloat
{
get
{
if (PLFloat != decimal.Zero)
{
return PLFloat.ToString(PriceExpFormat);
}
else
{
return "-";
}
}
}
///
/// 盈亏比例=(市值—货款)/ 货款 * 100% ;
///
public string ProfitPercen
{
get
{
if (CurHolderAmount != 0 && MarketValue != 0)
{
return ((MarketValue - CurHolderAmount) / CurHolderAmount).ToString("P2");
}
else
{
return "-";
}
}
}
private decimal _sumFloatPL;
///
/// 盈亏汇总
///
public decimal SumFloatPL
{
get { return _sumFloatPL; }
set { Set(() => SumFloatPL, ref _sumFloatPL, value); }
}
///
/// 是否可平仓
///
public bool IsCanClose
{
get
{
return AvailQty > 0;
}
}
public bool IsShowDelivery
{
get
{
return DeliveryFlag == eDeliveryFlag.DELIVERYFLAG_YES && Direction == Direction.Bid;
}
}
}
}