public void AddRegressionJobBar(int regressionJobUd, int index, Bar bar) { datsys.RegressionJobBars.Add(new RegressionJobBar { RegressionJobId = regressionJobUd, BarIndex = index, BarMin = bar.BarMin, BarMax = bar.BarMax }); datsys.SaveChanges(); }
private static void OnRegressionJobFinished(int reference) { Console.WriteLine("Processing last day's regression job with id: {0}", currentJob.RegressionJobId); _dataManager.SetRegressionJobToFinish(currentJob.RegressionJobId); JobDataManager jobdataMgr = new JobDataManager(); foreach (BarDataStat barDataStat in m_JobStat.Bars) { DataEntity.Bar barData = new DataEntity.Bar(); barData.BarMin = (float)Convert.ToDecimal(barDataStat.Bar.Min); barData.BarMax = (float)Convert.ToDecimal(barDataStat.Bar.Max); jobdataMgr.AddRegressionJobBar(m_JobStat.JobId, barDataStat.Index, barData); } //save the tickdatas//TODO: TICK DATA SHOULD NOT BE DOUBLY STORED BUT READ FROM THE TICK DB /* jobdataMgr.AddRegressionJobTickDatas(m_JobStat.GetAllTickDatas() * .Where(x=>x.Item2.Ask>0 || x.Item2.Bid>0) * .Select(x => new DataEntity.RegressionJobTickData * { * RegressionJobId = m_JobStat.JobId, * BarIndex = x.Item1, * Ask = (float?)x.Item2.Ask, * AskQty = (float?)x.Item2.AskQty, * BidQty = (float?)x.Item2.BidQty, * Bid = (float?)x.Item2.Bid * }).ToList());*/ //add entry signals jobdataMgr.AddEntrySignals(m_JobStat.GetEntrySignals().Select(x => new DataEntity.RegressionJobTradeSignal { BarIndex = x.BarIndex, RegressionJobId = m_JobStat.JobId }).ToList()); //add trade positions jobdataMgr.AddTradeSignals(m_JobStat.GetTradeSignals().Select(x => new DataEntity.RegressionJobTradePosition { RegressionJobId = m_JobStat.JobId, BarIndex = x.BarIndex, Reference = x.Reference, Direction = x.TradePosition.Direction.ToString(), Lots = x.TradePosition.Lots, Price = (float)x.TradePosition.Price, Stop = (float)x.TradePosition.Stop, Target = (float)x.TradePosition.Target, TradePositionType = x.PositionType }).ToList()); //add equity jobdataMgr.AddEquity(m_JobStat.GetEquityStats().Select(x => new DataEntity.RegressionJobsEquity { RegressionJobId = m_JobStat.JobId, Reference = x.Reference, Pnl = (float)x.PnL }).ToList()); //wait for 30 seconds to ensure last date data is regressed //TODO: Tick data type for all published Thread.Sleep(30000); //saves the stat data in the database // var serializer=new StringSerializer(); // string serialized= serializer.Serialize(m_JobStat); // DataManager.AddRegressionJobStat(currentJob.RegressionJobId, serialized); m_RegressionEndFlagEvent.Set(); Console.WriteLine("Finished regression job with id: {0}", currentJob.RegressionJobId); Console.WriteLine("..............................................................................."); }