using System; using System.Collections.Generic; using System.Linq; using System.Text; //---------------------------------------------------------------- //Module Name: $safeprojectname$ //Purpose: //CopyRight: Muchinfo //History: //---------------------------------------------------------------- //DateTime 2016/7/27 20:20:33 //Author //Description Create //---------------------------------------------------------------- using Muchinfo.MTPClient.Data; using Muchinfo.MTPClient.Data.Enums; using Muchinfo.MTPClient.Data.Model; using Muchinfo.MTPClient.Data.Model.Account; using Muchinfo.MTPClient.Infrastructure.Utilities; using Muchinfo.MTPClient.Infrastructure.Cache; namespace Muchinfo.MTPClient.Trade.ViewModels { /// /// 竞价商品-所有权/全额商品 /// /// 所有权不能建空,只能买(建),卖(平)-》有头寸 /// 挂开买 ● /// 挂开卖 × /// 挂平买 × /// 挂平卖 ● /// 摘开买 ● /// 摘开卖 × /// 摘平买 × /// 摘平卖 ● /// /// public class BidPayTradeViewModel : BidTradeViewModel { #region "=========私有成员/Private Data Members" //To declare private service data #endregion "Private Data Members" #region "=========构造函数/Constructor/Initialization" public BidPayTradeViewModel(QuoteGoods goods, Direction direction) : base(goods, direction) { SetDefaultBinding(direction); } public BidPayTradeViewModel(QuoteGoods goods, OrderBase orderBase) : base(goods, orderBase) { } #endregion "Constructor/Initialization" #region "=========接口重写/Interface implementation Or override" /// /// 是否显示最大可下单数量=》只有卖平仓的时候显示 /// public override bool IsLotMaxVsb { get { if (Direction == Direction.Ask && OpenCloseMode == OpenCloseMode.BUILDTYPE_CLOSE) { return true; } return false; } } /// /// 设置默认绑定值 /// /// private void SetDefaultBinding(Direction direction) { if (direction == Direction.Ask) { OpenCloseMode = OpenCloseMode.BUILDTYPE_CLOSE; } else { OpenCloseMode = OpenCloseMode.BUILDTYPE_OPEN; } } /// /// 是否可平仓 /// public override bool IsCloseEnable { get { if (OpenCloseMode == OpenCloseMode.BUILDTYPE_OPEN) { return false; } else { return true; } } } /// /// 所有权商品,买建卖平显示 /// protected override void SetSellCloseBuyOpen() { if (Direction == Direction.Bid) { OpenCloseMode = OpenCloseMode.BUILDTYPE_OPEN; } else { OpenCloseMode = OpenCloseMode.BUILDTYPE_CLOSE; } } /// /// 是否可以选择建仓 /// public override bool IsEnableSelectOpenMode { get { if (OpenCloseMode == OpenCloseMode.BUILDTYPE_OPEN) { return true; } else { return false; } } } /// /// 设置默认价格模式[读取数据库配置--设置] /// protected override void setDefaultPriceMode() { PriceMode = ePriceMode.PRICEMODE_LIMIT;//【客户需求】若商品为竞价模式,则默认成交的价格类型为“限价” if (ApplicationParameter.BidTradeDefaultPriceMode == 0) { PriceMode = ePriceMode.PRICEMODE_MARKET; } } public override bool IsSellEnable { get { //return CacheManager.GetGoodsPositionAvailableQty(Direction.Bid,_currentGoods.GoodsId,eTradeMode.Full_Transfer)>0; return true; } } /// /// 按单、寸头是否可见 /// public override bool IsCloseTypeVsb { get { //卖方向的时候可见 return false;//Direction == Direction.Ask; } } protected override void SetMinMaxQtyVaule() { if (this.Direction == Direction.Bid) { SetOpenQty(); } else { SetCloseQty(); } } public override void PostOrder(Action successAction, Action errorAction) { var entrustOrder = BuildEntrustOrder(); entrustOrder.BuildType = Direction == Direction.Ask ? OpenCloseMode.BUILDTYPE_CLOSE : OpenCloseMode.BUILDTYPE_OPEN; ////按单平 if (Direction == Direction.Ask && GoodsOrderMode == GoodsOrderMode.Order) { //entrustOrder.RelationTicket = SelectOrder == null ? 0 : SelectOrder.OrderID; } //_orderService.BidMarketEntrustOrder(entrustOrder, successAction, errorAction); _orderService.MakeMarketEntrustOrder(entrustOrder, successAction, errorAction); } #endregion "Interface implementation Or override" #region "=========公共属性/Public Properties To Get/Set " //To do Get/Set #endregion "Public Properties To Get/Set " #region "=========公共命令/Public Commands" //To to some Commands #endregion "Public Commands" #region "=========私有方法/Private Methods" //To to something #endregion "Private Methods" #region "=========其它方法/Other Methods" //To to something #endregion "Other Methods" } }