예제 #1
0
        public void ApplyStrategySettings(StrategySetting settings)
        {
            this.StrategySetting.CopyFrom(settings);
            _accountVm.Host.PortfApplyStrategySettings(this.Id, StrategySetting.GetEntity());

            _accountVm.PublishChanged();
        }
예제 #2
0
 private void OnShortOpen()
 {
     if (StrategySetting is ManualStrategySetting)
     {
         ((ManualStrategySetting)StrategySetting).Direction = PTEntity.PosiDirectionType.SHORT;
         _accountVm.Host.PortfApplyStrategySettings(this.Id, StrategySetting.GetEntity());
         OnOpenPosition();
         NotifyManualOpenDirectionChange();
     }
 }
예제 #3
0
        public PTEntity.PortfolioItem GetEntity()
        {
            PTEntity.PortfolioItem portfolioItem = new PTEntity.PortfolioItem();
            portfolioItem.ID              = Id;
            portfolioItem.Quantity        = Quantity;
            portfolioItem.MaxOpenPerStart = MaxOpenPerStart;
            portfolioItem.MaxCancel       = MaxCancel;
            portfolioItem.TotalOpenLimit  = TotalOpenLimit;
            portfolioItem.HedgeFlag       = HedgeFlag;

            foreach (var legVm in _legs)
            {
                PTEntity.LegItem leg = new PTEntity.LegItem();
                leg.Symbol         = legVm.Symbol;
                leg.Side           = (PTEntity.PosiDirectionType)legVm.Side;
                leg.Ratio          = legVm.Ratio;
                leg.IsPreferred    = legVm.IsPreferred;
                leg.MinPriceChange = legVm.MinPriceChange;
                portfolioItem.Legs.Add(leg);
            }

            if (!string.IsNullOrEmpty(_endTimePointsExpr))
            {
                string[] tps = _endTimePointsExpr.Split(',');
                foreach (string s in tps)
                {
                    if (!string.IsNullOrWhiteSpace(s))
                    {
                        portfolioItem.EndTimePoints.Add(s.Trim());
                    }
                }
            }

            portfolioItem.Strategy = StrategySetting.GetEntity();

            return(portfolioItem);
        }