List <Order> GetOrderList(IPortfolio portfolio) { var ol = new List <Order>(); if (CurrentPortfolio == null) { CurrentPortfolio = portfolio; } if (portfolio.LastMarketDataTime <= CurrentPortfolio.LastMarketDataTime) { return(ol); } RefreshPortfolio(portfolio); RefreshTarget(); if (Target.CurrentPrice == 0) { return(ol); } LogInfo("Target Info:" + CommonProc.ConvertObjectToString(Target)); LogInfo("Portfolio Info:" + CommonProc.ConvertObjectToString(portfolio)); if (Math.Abs(Target.AbsDistance) > Target.TargetThreshold) { var dn = (GetTotleValue().Number *Target.TargetWeight) / Target.CurrentPrice - Target.Shares; //var dn = (GetTotleValue() * (v.CurrentWeight + v.TargetThreshold) - v.CurrentValue) / (1 - v.CurrentWeight - v.TargetThreshold) / v.CurrentPrice; int n = Convert.ToInt32(dn); if (n != 0) { ol.Add(new Order() { OrderTime = CurrentPortfolio.LastMarketDataTime, Currency = Target.CurrentCurrency, TargetPortfolioName = Target.TargetPortfolioName, Instrument = new Instrument() { Ticker = Target.TargetTicker }, Shares = n, OrderDirection = OrderType.Buy, Price = Target.CurrentPrice, Mode = OrderMode.OrderLong }); } } return(ol); }
public virtual string GetStatus() { return(CommonProc.ConvertObjectToString(this)); }
public override string GetSerialParameter() { TradeAlgorithmSerialString = CommonProc.ConvertObjectToString(TradeAlgorithmList); return(base.GetSerialParameter()); }
public void Save() { var s = CommonProc.ConvertObjectToString(this); CommonProc.SaveStringToFile(s); }