Exemplo n.º 1
0
 private void OnResourceDownloaded(object sender, DataDownloaderEventArgs args)
 {
     if (args.Resource is DiaryPost || args.Resource is DiaryDatePage || args.Resource is DiaryAccountPage)
     {
         Progress.PageDownloaded(args.DownloadedData);
     }
     else if (args.Resource is DiaryImage)
     {
         Progress.ImageDownloaded(args.DownloadedData);
     }
 }
Exemplo n.º 2
0
        static void DownloadPriceDataCompleted(object sender, DataDownloaderEventArgs e)
        {
            OpenAPIBar[] data = e.BarData.Data.OrderByDescending(x => x.OpenTime).ToArray();

            lock (priceData[e.AssetName][e.Timeframe])
            {
                for (int i = 1; i < priceData[e.AssetName][e.Timeframe].Length && i < data.Length; i++)
                {
                    OpenAPIBar oBar = data[i - 1];
                    Bar        bar  = new Bar();
                    bar.OpenTime = oBar.OpenTime;
                    bar.BidOpen  = oBar.Open;
                    bar.AskOpen  = oBar.Open;
                    bar.BidClose = oBar.Close;
                    bar.AskClose = oBar.Close;
                    bar.BidHigh  = oBar.High;
                    bar.AskHigh  = oBar.High;
                    bar.BidLow   = oBar.Low;
                    bar.AskLow   = oBar.Low;
                    bar.Volume   = oBar.Volume;
                    priceData[e.AssetName][e.Timeframe][i] = bar;
                }
            }

            //uodate the bar index so that strategies can run eg. barIndex will now be > MinBars
            barIndices[e.AssetName][e.Timeframe] = priceData[e.AssetName][e.Timeframe].Length;

            //flag that this timeframe has been downloaded
            if (!assetDetails[e.AssetName].LookbackDownloaded.ContainsKey(e.Timeframe))
            {
                assetDetails[e.AssetName].LookbackDownloaded.Add(e.Timeframe, true);
            }
            else
            {
                assetDetails[e.AssetName].LookbackDownloaded[e.Timeframe] = true;
            }

            //Now we need to send this data to Python to calculate any required data using the whole lookback period
            if (PythonBridge != null)
            {
                CalculatePythonData(PythonBridge, e.AssetName, e.Timeframe, priceData[e.AssetName][e.Timeframe].Length);
            }

            //Run the strategies after the look back price data has been downloade (if strategies attached)
            if (e.PostRunStrategies != null)
            {
                foreach (Strategy strategy in (Strategy[])e.PostRunStrategies)
                {
                    strategy.Run(e.Timeframe, e.AssetName);
                }
            }
        }