using System; using System.Collections.Generic; using System.Linq; using System.Text; //---------------------------------------------------------------- //Module Name: $safeprojectname$ //Purpose: //CopyRight: Muchinfo //History: //---------------------------------------------------------------- //DateTime 2016/7/27 20:28:55 //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; namespace Muchinfo.MTPClient.Trade.ViewModels { public class MixPayTradeViewModel:MixTradeViewModel { public MixPayTradeViewModel(QuoteGoods goods, Direction direction) : base(goods, direction) { OpenCloseMode = OpenCloseMode.BUILDTYPE_OPEN; } public MixPayTradeViewModel(QuoteGoods goods, OrderBase orderBase) : base(goods, orderBase) { } public override bool IsSellEnable { get { var holdingOrders = UserManager.GetCacheOrders(); if (holdingOrders == null || !holdingOrders.Any()) { return false; } //全款划扣商品-》只有买入方向的平仓单 return holdingOrders.Where((item) => item.GoodsId == _currentGoods.GoodsId && item.Direction == Direction.Bid).ToList().Any(); } } /// /// 按单、寸头是否可见 /// public override bool IsCloseTypeVsb { get { //卖方向的时候可见 return Direction == Direction.Ask; } } 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.MixMarketEntrustOrder(entrustOrder, successAction, errorAction); } protected override void SetMinMaxQtyVaule() { if (this.Direction == Direction.Bid) { SetOpenQty(); //设置建仓最大最小数量 } else { SetCloseQty();//设置平仓最大最小数量 } } } }