public static DealList GetDeals(StrategyHeader strategyHeader) { if (strategyHeader == null) { return(null); } IEnumerable <Trade> Trades = TradingData.Instance.GetTrades(strategyHeader); DealList dealList = new DealList(strategyHeader); Console.WriteLine("GetDeals"); foreach (Trade item in Trades.OrderBy(i => i.DateTime)) { dealList.OnItemAdded(item); } Console.WriteLine("Количество сделок: {0}", dealList.Count); Console.WriteLine("Количество сделок P: {0}", dealList.CountP); Console.WriteLine("Количество сделок L: {0}", dealList.CountL); Console.WriteLine("Процент сделок P: {0}", dealList.CountPercentP.ToString("0.0000")); Console.WriteLine("Процент сделок L: {0}", dealList.CountPercentL.ToString("0.0000")); Console.WriteLine("Сумма PnL: {0}", dealList.Sum); Console.WriteLine("Сумма P: {0}", dealList.SumP); Console.WriteLine("Сумма L: {0}", dealList.SumL); Console.WriteLine("Средняя Сумма PnL: {0}", dealList.AverageSum.ToString("0.0000")); Console.WriteLine("Средняя Сумма P: {0}", dealList.AverageSumP.ToString("0.0000")); Console.WriteLine("Средняя Сумма L: {0}", dealList.AverageSumL.ToString("0.0000")); Console.WriteLine("Средняя Серия P: {0}", dealList.AverageSeriesP.ToString("0.0000")); Console.WriteLine("Средняя Серия L: {0}", dealList.AverageSeriesL.ToString("0.0000")); Console.WriteLine("Max Серия P: {0}", dealList.MaxSeriesP.ToString("0.0000")); Console.WriteLine("Max Серия L: {0}", dealList.MaxSeriesL.ToString("0.0000")); return(dealList); //Console.WriteLine(String.Format("BuyTrades.Sum: {0}", BuyTrades.Sum(i => i.Amount).ToString())); //Console.WriteLine(String.Format("BuyTrades1.Sum: {0}", BuyTrades1.Sum(i => i.Amount).ToString())); //Console.WriteLine(String.Format("BuyTrades.Count: {0}", BuyTrades.Count().ToString())); //Console.WriteLine(String.Format("BuyTrades1.Count: {0}", BuyTrades1.Count().ToString())); //Console.WriteLine(String.Format("SellTrades.Sum: {0}", SellTrades.Sum(i => i.Amount).ToString())); //Console.WriteLine(String.Format("SellTrades1.Sum: {0}", SellTrades1.Sum(i => i.Amount).ToString())); //Console.WriteLine(String.Format("SellTrades.Count: {0}", SellTrades.Count().ToString())); //Console.WriteLine(String.Format("SellTrades1.Count: {0}", SellTrades1.Count().ToString())); }
public void DealList_GetTradingResult_positive_for_long_test() { DateTime date = DateTime.Now; Trade open = new Trade(null, "BP12345-RF-01", "RTS-12.13_FT", 150000, 1, date); Trade close = new Trade(null, "BP12345-RF-01", "RTS-12.13_FT", 150100, -1, date.AddSeconds(10)); Assert.AreEqual(100, open.GetTradeResult(close)); dealList.OnItemAdded(open); dealList.OnItemAdded(close); Assert.AreEqual(100, dealList.Sum); open = new Trade(null, "BP12345-RF-01", "RTS-12.13_FT", 150000, 2, date); close = new Trade(null, "BP12345-RF-01", "RTS-12.13_FT", 150100, -2, date.AddSeconds(10)); dealList.OnItemAdded(open); dealList.OnItemAdded(close); Assert.AreEqual(300, dealList.Sum); }