public override void GetQuotesEx(string ticker, ref QuotationArray quotes) { if (firstGetQuotesExCall) { periodicity = quotes.Periodicity; firstGetQuotesExCall = false; } try { var tickerData = tickers.RegisterTicker(ticker); if (tickerData.QuoteDataStatus == QuoteDataStatus.Offline) { tickerData.MarkTickerForGetQuotes(periodicity); return; } if (tickerData.QuoteDataStatus != QuoteDataStatus.Online) { return; } lock (tickerData) { quotes.Merge(tickerData.Quotes); } } catch (Exception ex) { LogAndMessage.LogAndQueue(MessageType.Error, "Failed to subscribe to quote update: " + ex); } }
public void GetQuotesEx(string ticker, ref QuotationArray quotes) { // save database periodicity at the very first call if (!firstGetQuotesExCall) { periodicity = quotes.Periodicity; firstGetQuotesExCall = true; } try { TickerData tickerData = tickers.GetTickerData(ticker); // if ticker is not yet known (first time to use in charts and no RT window use) if (tickerData == null) { tickerData = tickers.RegisterTicker(ticker); } if (tickerData.QuoteDataStatus == QuoteDataStatus.Offline) { // mark it for periodic Quotation data update tickerData.MarkTickerForGetQuotes(periodicity); // we do not want to run data refresh on AB's thread... // we also want async processing of historical data download... if (connected) { EnqueueTickerForRefresh(ticker); } } lock (tickerData) { // merge downloaded data to AB's quotation array quotes.Merge(tickerData.Quotes); // save last download time tickerData.LastDownloaded = tickerData.LastProcessed; } } catch (Exception ex) { LogAndMessage.LogAndAdd(MessageType.Error, "Failed to subscribe to quote update: " + ex); } }
public override void GetQuotesEx(string ticker, ref QuotationArray quotes) { // if first call)); if (firstGetQuotesExCall) { firstGetQuotesExCall = false; // save database periodicity Periodicity = quotes.Periodicity; } if (controller == null) { return; } controller.GetQuotesEx(ticker, ref quotes); return; }
public static void WriteToFile(string ticker, ref QuotationArray quotes) { string fileName = ticker + "_" + DateTime.Now.ToLongTimeString(); // create a filename from ticker char[] invalidChars = Path.GetInvalidFileNameChars(); for (int i = 0; i < invalidChars.Length; i++) { fileName = fileName.Replace(invalidChars[i], '_'); } fileName = fileName + ".csv"; string filePath = Path.Combine(Environment.CurrentDirectory, fileName); StreamWriter sw = new StreamWriter(filePath, false, Encoding.ASCII); for (int i = 0; i < quotes.Count; i++) { Quotation q = quotes[i]; string line = ((DateTime)q.DateTime).ToShortDateString() + " " + ((DateTime)q.DateTime).ToLongTimeString() + " " + (q.DateTime.IsEod ? "EOD" : "INTRA") + "," + q.Open + "," + q.High + "," + q.Low + "," + q.Price + "," + q.Volume; sw.WriteLine(line); } sw.Close(); return; }
public override void GetQuotesEx(string ticker, ref QuotationArray quotes) { database.GetQuotesEx(ticker, ref quotes); }