//[TestMethod] public void test_deals() { FinancialInstrument instr = controller.get_instrument("SPFB_LKOH_140101_140331.txt"); TradingStrategy strategy = controller.get_strategy("Test5").Originator; ForecastingModule forecastingModule = new ForecastingModule(strategy, instr); ForecastResult result = forecastingModule.run(); int numDeal = 5; TypeDeal expType = TypeDeal.Sell; DateTime expDateOpen = new DateTime(14, 2, 12, 12, 35, 0); DateTime expDateClose = new DateTime(14, 2, 12, 12, 36, 0); double expOpenPrice = 20430, expClosePrice = 20438; TradeDeal tradeDeal = result.get_deal(numDeal); double actOpenPrice = tradeDeal.OpeningPrice; double actClosePrice = tradeDeal.ClosingPrice; Assert.AreEqual( true, tradeDeal.Opening == false && tradeDeal.Type == expType && actOpenPrice == expOpenPrice //&& tradeDeal.DateTimeOpen.Equals(expDateOpen) //&& tradeDeal.DateTimeClose == expDateClose && actClosePrice == expClosePrice ); }
private void SearchFile(string fileName) { try { var assembly = Assembly.LoadFrom(fileName); AssemblyDeal?.Invoke(assembly); //非IL程序集不能读取 Type[] types = assembly.GetTypes(); foreach (var type in types) { TypeDeal?.Invoke(type); } } catch (BadImageFormatException) { //throw; } }
public void test_run() { FinancialInstrument instr = controller.get_instrument("SPFB.Si_090101_091231.txt"); TradingStrategy strategy = controller.get_strategy("Test5").Originator; strategy.subscribe_analyzer(new AnalyzerDirection()); ForecastingModule forecastingModule = new ForecastingModule(strategy, instr); ForecastResult result = forecastingModule.run(); //result.print(); double profitExepted = -3419; int numDeal = 5; TypeDeal expType = TypeDeal.Buy; DateTime expDateOpen = new DateTime(2009, 5, 13, 10, 49, 0); DateTime expDateClose = new DateTime(2009, 5, 13, 10, 53, 0); double expOpenPrice = 32110, expClosePrice = 32094; TradeDeal tradeDeal = result.get_deal(numDeal); double actOpenPrice = tradeDeal.OpeningPrice; double actClosePrice = tradeDeal.ClosingPrice; DateTime actDateTimeOpen = tradeDeal.DateTimeOpen; DateTime actDateTimeClose = tradeDeal.DateTimeClose; Assert.AreEqual(true, profitExepted == result.CurProfit && tradeDeal.Opening == false && tradeDeal.Type == expType && actOpenPrice == expOpenPrice && actClosePrice == expClosePrice && actDateTimeOpen == expDateOpen && actDateTimeClose == expDateClose); }
protected override void Seed(HotDealsContext context) { var demoCategory1 = new Category() { Label = "Services" }; var demoCategory2 = new Category() { Label = "Mode" }; var demoCategory3 = new Category() { Label = "Maison" }; var demoSubCategory1 = new SubCategory() { Label = "Voyages" }; var demoSubCategory2 = new SubCategory() { Label = "Presse" }; var demoSubCategory3 = new SubCategory() { Label = "Informatique" }; var demoSubCategory4 = new SubCategory() { Label = "Others" }; demoCategory1.SubCategories = new List <SubCategory>(); demoCategory1.SubCategories.Add(demoSubCategory1); demoCategory2.SubCategories = new List <SubCategory>(); demoCategory2.SubCategories.Add(demoSubCategory2); demoCategory2.SubCategories.Add(demoSubCategory3); demoCategory3.SubCategories = new List <SubCategory>(); demoCategory3.SubCategories.Add(demoSubCategory4); var categories = new List <Category>(); categories.Add(demoCategory1); categories.Add(demoCategory2); categories.Add(demoCategory3); categories.ForEach(cat => context.Categories.Add(cat)); var subCategories = new List <SubCategory>(); subCategories.Add(demoSubCategory1); subCategories.Add(demoSubCategory2); subCategories.Add(demoSubCategory3); subCategories.ForEach(cat => context.SubCategories.Add(cat)); #region typedeal var demoTypeDeal1 = new TypeDeal() { Value = 3, Label = "Free" }; var demoTypeDeal2 = new TypeDeal() { Value = 1, Label = "Bon plan" }; var demoTypeDeal3 = new TypeDeal() { Value = 2, Label = "Code promo" }; var typeDeals = new List <TypeDeal>(); typeDeals.Add(demoTypeDeal1); typeDeals.Add(demoTypeDeal2); typeDeals.Add(demoTypeDeal3); typeDeals.ForEach(type => context.TypeDeals.Add(type)); #endregion var demoDeal1 = new Deal() { Title = "Demo 1", Degree = 100, Description = "Third party compilation tools may work with Bootstrap, but they are not supported by our core team", Price = 100, OldPrice = 80, IsOnline = 1, Category = demoCategory1, SubCategory = demoSubCategory1, TypeDeal = demoTypeDeal1, StartDate = new DateTime(2015, 7, 15), EndDate = new DateTime(2015, 12, 31), CreationDate = new DateTime(2015, 12, 31) }; var demoDeal2 = new Deal() { Title = "Demo 2", Degree = 80, Description = "Third party compilation tools may work with Bootstrap, but they are not supported by our core team", Price = 100, OldPrice = 80, IsOnline = 1, Category = demoCategory2, SubCategory = demoSubCategory2, TypeDeal = demoTypeDeal2, StartDate = new DateTime(2015, 7, 15), EndDate = new DateTime(2015, 12, 31), CreationDate = new DateTime(2015, 12, 31) }; var user1 = new UserInfo() { FirstName = "Hong Quan", LastName = "HO" }; user1.Deals = new List <Deal>(); user1.Comments = new List <Comment>(); var comment1 = new Comment() { DatePost = new DateTime(2016, 07, 08), Content = "This deal is good" }; user1.Comments.Add(comment1); var demoDeal3 = new Deal() { Title = "Demo title", Degree = 50, Description = "Third party compilation tools may work with Bootstrap, but they are not supported by our core team", Price = 100, OldPrice = 80, IsOnline = 1, Category = demoCategory2, SubCategory = demoSubCategory3, TypeDeal = demoTypeDeal3, StartDate = new DateTime(2015, 7, 15), EndDate = new DateTime(2015, 12, 31), CreationDate = new DateTime(2015, 12, 31) }; demoDeal3.Comments = new List <Comment>(); demoDeal3.Comments.Add(comment1); user1.Deals.Add(demoDeal3); context.UserInfos.Add(user1); context.Comments.Add(comment1); context.Deals.Add(demoDeal1); context.Deals.Add(demoDeal2); context.Deals.Add(demoDeal3); context.SaveChanges(); base.Seed(context); }