public void TestAccountSave() { string code = "RB1710"; int startDate = 20170601; int endDate = 20170605; IDataForward_Code historyDataForward = ForwardDataGetter.GetHistoryDataForward_Code(code, startDate, endDate, true); historyDataForward.Forward(); IAccount account = DataCenter.Default.AccountManager.CreateAccount(100000, historyDataForward); account.AccountSetting.TradeType = AccountTradeType.MARKETPRICE; account.OnReturnOrder += Account_OnReturnOrder; account.OnReturnTrade += Account_OnReturnTrade; account.Open(code, 3099, market.OrderSide.Buy, 10); account.Open(code, 3095, market.OrderSide.Buy, 10); int index = 0; while (index < 2000) { historyDataForward.Forward(); index++; if (isOpen && historyDataForward.GetTickData().SellPrice >= 3102) { account.Close(code, 3102, market.OrderSide.Sell, 10); account.Close(code, 3105, market.OrderSide.Sell, 10); } //Console.WriteLine(historyDataForward.GetTickData()); } account.Open(code, 3105, market.OrderSide.Buy, 10); account.Open(code, 3025, market.OrderSide.Buy, 10); for (int i = 0; i < 100; i++) { historyDataForward.Forward(); } XmlElement root = GetXmlRoot(); account.Save(root); Account account2 = (Account)DataCenter.Default.AccountManager.CreateAccount(root); //Console.WriteLine(account); //Console.WriteLine(account2); Assert.AreEqual(XmlUtils.ToString(account), XmlUtils.ToString(account2)); IDataForward_Code historyDataForward2 = ForwardDataGetter.GetHistoryDataForward_Code(code, startDate, endDate, true); historyDataForward2.NavigateTo(account2.Time); account2.BindRealTimeReader(historyDataForward2); //IDataForward_Code historyDataForward2 = account2.DataForward_Code; for (int i = 0; i < 100; i++) { historyDataForward2.Forward(); } Console.WriteLine(account2); }
//[TestMethod] public void TestHistoryDataForward_Play() { string code = "RB1710"; int start = 20170601; int endDate = 20170601; IDataForward_Code realTimeReader = ForwardDataGetter.GetHistoryDataForward_Code(code, start, endDate, true); realTimeReader.OnTick += RealTimeReader_OnTick; realTimeReader.NavigateTo(20170531.210011); realTimeReader.Play(); while (realTimeReader.Time < 20170531.210015) { } realTimeReader.Pause(); }
//[TestMethod] public void TestKLineData_Play2() { string code = "RB1710"; int start = 20170601; int endDate = 20170601; IDataForward_Code klineDataForward = GetKLineDataForward(code, start, endDate); klineDataForward.OnTick += KlineDataForward_OnTick; klineDataForward.NavigateTo(20170531.210011); Console.WriteLine(klineDataForward.GetKLineData(KLinePeriod.KLinePeriod_1Minute)); klineDataForward.Play(); while (klineDataForward.Time < 20170531.210015) { } klineDataForward.Pause(); }