public SecurityMasterRecord[] GetSecurityMasterRecords() { List <SecurityMasterRecord> securities = new List <SecurityMasterRecord>(); int i = 1; foreach (string firm in FirmPositions.Keys) { foreach (ClientPosition pos in FirmPositions[firm]) { if (!securities.Any(x => x.Symbol == pos.Symbol)) { SecurityMasterRecord security = new SecurityMasterRecord(); security.Symbol = pos.Symbol; security.CurrencyPair = "XBT-USD"; security.InstrumentId = i; security.MaturityDate = security.GetMaturityDateFromSymbol(); i++; securities.Add(security); } } } return(securities.ToArray()); }
private void EvalDailySettlementPriceWarnings(string symbol) { SecurityMasterRecord security = SecurityMasterRecords.Where(x => x.Symbol == symbol).FirstOrDefault(); if (security.AssetClass == Security._SPOT) { //WE shouldn't have this service requested for a spot currency DoLog(string.Format("WARNING2 - Daily Settlement Price requested for spot currency! : {0}", symbol), MessageType.Error); } }
private static void ProcessEvent(WebSocketMessage msg) { if (msg is ClientLoginResponse) { ClientLoginResponse loginResp = (ClientLoginResponse)msg; if (loginResp.JsonWebToken != null) { ClientLoginResponse = loginResp; } DoLog(string.Format("Client successfully logged with token {0}", loginResp.JsonWebToken)); //3- Once Logged we request the security master record. We set the request timestamp for timeout calculation SecurityMasterRecordRequestStartTime = DateTime.Now; SubscriptionTAFinished = false; RequestSecurityMasterList(); //3.1- We launch the thread that will process all the securities once everything is available Thread processSecurityMasterRecordThread = new Thread(ProcessSecurityMasterRecordThread); processSecurityMasterRecordThread.Start(); } else if (msg is SubscriptionResponse) { SubscriptionResponse subscrResp = (SubscriptionResponse)msg; if (subscrResp.Service == "TA") { SubscriptionTAFinished = true; } } else if (msg is SecurityMasterRecord) { SecurityMasterRecord security = (SecurityMasterRecord)msg; //4-Every time we get a security, if the arrival time is less than timeout time, we update the list that hold //all the securities TimeSpan elapsed = DateTime.Now - SecurityMasterRecordRequestStartTime; if (elapsed.TotalSeconds < _SECURITY_MASTER_RECORD_TIMOUT_IN_SECONDS && !SubscriptionTAFinished) { SecurityMasterRecords.Add(security); } else { //4.1- Here the security arrive after the timeout. We have to set some warning in the logs to check // if we have to recalibrate the timeout threshold if (SubscriptionTAFinished) { DoLog(string.Format("TC1-Security Master Record arrived afte subscription response succesfull received!:{0}", security.Symbol)); } else if (elapsed.TotalSeconds > _SECURITY_MASTER_RECORD_TIMOUT_IN_SECONDS) { DoLog(string.Format("TC2-Security Master Record arrived after timeout expiration!:{0}", security.Symbol)); } } } }