private void CheckForNewSessions(string stTime) { //TODO from global variable, from config //int mscOffset = -2; DateTime dt = CASTSConv.ASTSTimeToDateTime(stTime); DateTime dtBegin = GetSessionStartNormalTime(); DateTime dtEnd = GetSessionEndNormalTime(); int tolMs = 2000; if (CUtilTime.IsEqual(dt, dtBegin, tolMs)) { _currSession = new CDBSession { DtBegin = dtBegin, DtEnd = dtEnd, stock_exchange_id = _client.StockExchId }; _lstSessions.Add(_currSession); } CUtil.TaskStart(InsertUnsavedSessions); }
public void GenerateNextSession() { if (_bProduction) //use on real server { _currDBSession = new CDBSession { //2018-04-22 DtBegin = _currDBSession.DtBegin.Date.AddDays(1).AddHours(_sessionBeginHours).AddMinutes(_sessionBeginMinutes), DtEnd = _currDBSession.DtEnd.Date.AddDays(1).AddHours(_sessonEndHours).AddMinutes(_sessionEndMinutes), stock_exchange_id = _client.StockExchId, StockExchangedSessionId = GenSessionId() }; } else //use for debugging { _currDBSession = new CDBSession { DtBegin = _currDBSession.DtEnd.AddMinutes(4), DtEnd = _currDBSession.DtEnd.AddMinutes(10), stock_exchange_id = _client.StockExchId, StockExchangedSessionId = GenSessionId() }; } _client.DBCommunicator.InsertUnsavedSessionCrypto(_currDBSession); }
/// <summary> /// 1)Inserts unstored sessions. /// 2)Check session for completion. If session is completed /// updates session's status /// 3)Process Automatic clearing /// 4)Send reports /// /// /// Call when: /// 1)Session become online for P2( assume at start) /// 2)When session ended (expired). Assume after day session /// (and whole session) ended /// /// Call from: /// 1) Plaza2Connector.SessionBox.OnSessionExpired /// 2) Plaza2Connector.IsSessionOnline /// 3) CBaseDealingServer.Process /// </summary> public void TaskCheckUnsavedSessionsAndClearing() { Log("TaskCheckUnsavedSessionsAndClearing entry"); _client.WaitDataLoadedFromDB(); _client.WaitServerTimeAvailable(); Log("Step 1 insert unstored sessions"); InsertUnsavedSessions(); Log("Step 2 Get stored sessions and check if sessions completed. If completed update it"); //Gen list of "Not completed sessions" var notCompletedSess = _client.DBCommunicator.GetUnCompletedSessions(_client.StockExchId); int tol = 1000; List <int> needSetCompletedSession = new List <int>(); //if session already ended (check it using server time) do add to //"needSetCompletedSession" list notCompletedSess.ForEach(a => { CDBSession dbSess = new CDBSession(); _client.FillDBClassField(a, dbSess); if (dbSess.IsCompleted == 0) { if (_client.ServerTime > dbSess.DtEnd.AddMilliseconds(-tol)) { needSetCompletedSession.Add(dbSess.StockExchangedSessionId); } } } ); //... set that session completed if (needSetCompletedSession.Count != 0) { _client.DBCommunicator.SetCompletedSessions(needSetCompletedSession); } _client.ClearingProcessor.ProcessAutomaticClearing(); _client.IsAutomaticClearingProcessed = true; //2018-06-14 - after clearing - do force update TradeManagers //to load new data _client.TriggerRecalcAllBots(EnmBotEventCode.OnForceUpdTotalVM, null); _client.TriggerRecalcAllBots(EnmBotEventCode.OnForceUpdTrdMgr, null); _client.SendReports(); Log("TaskCheckUnsavedSessionsAndClearing exit"); }
public void GenerateFirstSession() { _currDBSession = new CDBSession { DtBegin = DateTime.Now.Date.AddHours(_sessionBeginHours).AddMinutes(_sessionBeginMinutes), DtEnd = DateTime.Now.Date.AddHours(_sessonEndHours).AddMinutes(_sessionEndMinutes), stock_exchange_id = _client.StockExchId, StockExchangedSessionId = GenSessionId() }; _client.GUIBox.UpdateSessionString(_currDBSession.DtBegin, _currDBSession.DtEnd); //Insert new session to DB. //If session already in DB it will not insert (as implemented in method). _client.DBCommunicator.InsertUnsavedSessionCrypto(_currDBSession); //DateTime dt = _client.ServerTime; //if (dt.) }