Ejemplo n.º 1
0
        /// <summary>
        /// Executes a run of processing the stock data
        /// </summary>
        /// <param name="session">The session configuration</param>
        public static void Run(StockSession session)
        {
            // Set up the derived data sink
            var sourceData = session.SourceFile.GetSegments <StockDataSource>();
            var sinkData   = StockDataSetDerived <StockDataSink, StockDataSource> .Derive(sourceData, session.SinkFile, (data, idx) =>
            {
                var point = new StockDataSink();
                point.Update(data, idx);
                return(point);
            });

            session.SinkFile.SetSegments(sinkData);

            // Find when a stock increases by a certain amount
            PriceMonitor priceMonitor = new PriceMonitor(0.025);

            priceMonitor.MonitorDecrease = false;
            sinkData["AA"][0].Load();
            priceMonitor.Monitor("AA", sinkData["AA"][0][0].Price, (string stock, float startPrice, float endPrice, DateTime time) =>
            {
                System.Windows.Forms.MessageBox.Show(string.Format("{0} {1:C}->{2:C} @ {3}", stock, startPrice, endPrice, time));
                return(true);
            });

            // Load the first set of data
            foreach (var pair in sinkData)
            {
                foreach (var set in pair.Value)
                {
                    set.Load();
                    priceMonitor.Process(set, 0);
                }
            }
        }
Ejemplo n.º 2
0
 public ProcessingTarget(string symbol, DateTime referenceTime, StockDataSink reference)
 {
     this.Symbol           = symbol;
     this.ReferenceTime    = referenceTime;
     this.Reference        = reference;
     this.ProcessedSetIdx  = 0;
     this.ProcessedDataIdx = 0;
     this.ProcessedLiveIdx = 0;
 }
Ejemplo n.º 3
0
 public ProcessingTarget(string symbol)
 {
     this.Symbol           = symbol;
     this.ReferenceTime    = DateTime.Now;
     this.Reference        = new StockDataSink();
     this.ProcessedSetIdx  = 0;
     this.ProcessedDataIdx = 0;
     this.ProcessedLiveIdx = 0;
 }
Ejemplo n.º 4
0
        /// <summary>
        /// Pulls the processed stock data, and puts it into a format that can be fed into the ML model
        /// </summary>
        /// <param name="src">The processed stock data</param>
        /// <param name="dst">The array the features should be placed in</param>
        /// <param name="labels">The array the expected outputs should be placed in</param>
        /// <param name="dstIdx">Update the current postion within the arrays</param>
        /// <param name="numFeatures">Output the number of features</param>
        /// <param name="numLabels">Output the number of data labels</param>
        public static void PopulateData(StockDataSet <StockDataSink> src, float[,] dst, int[,] labels, ref int dstIdx, out int numFeatures, out int numLabels)
        {
            numFeatures = 0;
            numLabels   = 0;
            for (int srcIdx = 0; (srcIdx < src.Count) && (dstIdx < dst.GetLength(0)); srcIdx++, dstIdx++)
            {
                // Output features for the data point
                numFeatures = 0;

                StockDataSink s = src[srcIdx];
                dst[dstIdx, numFeatures++] = s.Average10Min;

                // Output the labels for the data point - the thing you are trying to predict
                numLabels = 0;

                labels[dstIdx, numLabels++] = ((s.Price > s.Average10Min) ? 1 : 0);
            }
        }