/// <summary> /// Execute query /// </summary> /// <param name="exchange">Security exchange</param> public static List <Spark.Event> Execute(string exchange) { //Connect to Spark API if required ApiControl.Instance.Connect(); //Get exchange reference Spark.Exchange exchangeRef; List <Spark.Event> result = null; if (ApiFunctions.GetSparkExchange(exchange, out exchangeRef)) { //Wait to allow Spark API to prepare for large download (it will only return a small number of events without this) System.Threading.Thread.Sleep(1000); //Request stock events result = new List <Spark.Event>(); Spark.Event sparkEvent = new Spark.Event(); //Execute query using current day request method if (Spark.GetAllExchangeEvents(ref exchangeRef, ref sparkEvent)) { while (Spark.GetNextExchangeEvent(ref exchangeRef, ref sparkEvent, 1000)) { result.Add(sparkEvent); } } Spark.ReleaseCurrentEvents(); } return(result); }
/// <summary> /// Initiate data feed /// </summary> public override void Execute() { //Connect to Spark API if required ApiControl.Instance.Connect(); //Get instance to exchange Spark.Exchange exchangeRef; if (ApiFunctions.GetSparkExchange(Exchange, out exchangeRef)) { //Request all events for current day Spark.Event sparkEvent = new Spark.Event(); if (Spark.GetAllExchangeEvents(ref exchangeRef, ref sparkEvent)) { while (Spark.GetNextExchangeEvent(ref exchangeRef, ref sparkEvent, -1)) //Specifying -1 timeout will keep it waiting until end of day { RaiseEvent(new EventFeedArgs(sparkEvent, Spark.TimeToDateTime(sparkEvent.Time))); } } //Release memory at end of day Spark.ReleaseCurrentEvents(); } }