public entity.PortfolioItem GetEntity() { entity.PortfolioItem portfolioItem = new entity.PortfolioItem(); portfolioItem.ID = Id; portfolioItem.AutoOpen = AutoOpen; portfolioItem.AutoStopGain = AutoStopGain; portfolioItem.AutoStopLoss = AutoStopLoss; portfolioItem.AutoTrack = AutoTracking; portfolioItem.EnablePrefer = EnablePrefer; portfolioItem.Quantity = Quantity; portfolioItem.MaxPosition = MaxPosition; portfolioItem.OpenTimes = OpenTimes; portfolioItem.CloseTimes = 0; portfolioItem.CurrentPosition = Position; portfolioItem.AvgCost = AvgCost; foreach (var legVm in _legs) { entity.LegItem leg = new entity.LegItem(); leg.Symbol = legVm.Symbol; leg.Side = legVm.Side; leg.Ratio = legVm.Ratio; leg.IsPreferred = legVm.IsPreferred; portfolioItem.Legs.Add(leg); } portfolioItem.StrategyName = StrategySetting.Name; portfolioItem.StrategyData = StrategySetting.Serialize(); return(portfolioItem); }
private void btnAddPortf_Click(object sender, RoutedEventArgs e) { portfolioItem = new entity.PortfolioItem(); portfolioItem.ID = Guid.NewGuid().ToString(); portfolioItem.Diff = 2; portfolioItem.Quantity = 1; entity.LegItem leg1 = new entity.LegItem(); leg1.Symbol = "cu1212"; leg1.Side = entity.PosiDirectionType.LONG; leg1.Ratio = 1; portfolioItem.Legs.Add(leg1); entity.LegItem leg2 = new entity.LegItem(); leg2.Symbol = "cu1301"; leg2.Side = entity.PosiDirectionType.SHORT; leg2.Ratio = 1; portfolioItem.Legs.Add(leg2); _client.AddPortf(portfolioItem); }