예제 #1
0
        public void GetAllData2(IEXData.HistoryType ht, int num)
        {
            List <Trading.SymbolData> symbols = Trading.IEXData.DownloadSymbolList();

            int cnt = symbols.Count;

            if (num > 0)
            {
                cnt = num;
            }
            List <Task> tasks = new List <Task>();
            int         total = symbols.Count;

            foreach (var sym in symbols)
            {
                var t = new Task(() => ProcessSymbol(total, sym, ht));
                tasks.Add(t);
                if (tasks.Count == cnt)
                {
                    break;
                }
            }
            sw = new System.Diagnostics.Stopwatch();
            sw.Start();
            StartAndWaitAllThrottled(tasks, 6, 20000000);
        }
예제 #2
0
        public void ProcessSymbol(int total, SymbolData symData, IEXData.HistoryType ht)
        {
            Trading.Company c = Trading.IEXData.DownloadSymbol(symData.symbol, ht, symData);
            if (c.Id != -1)
            {
                this.AddSymbol(c);
            }

            current++;
            int      left   = total - current;
            double   avgSec = sw.Elapsed.TotalSeconds / current;
            TimeSpan ts     = new TimeSpan(0, 0, (int)(avgSec * left));

            Debug.Nlog(current.ToString() + "/" + total.ToString() + "\t" + symData.symbol + ", " + ts.ToString() + " left");
        }
예제 #3
0
        public void GetAllData(IEXData.HistoryType ht, int num)
        {
            List <Trading.SymbolData> symbols = Trading.IEXData.DownloadSymbolList();

            int cnt = symbols.Count;

            if (num > 0)
            {
                cnt = num;
            }

            current = 0;
            for (int i = 0; i < cnt; i++)
            {
                Trading.SymbolData symData = symbols[i];
                Debug.Nlog((i + 1).ToString() + "/" + symbols.Count.ToString() + "\t" + symData.symbol);
                Trading.Company c = Trading.IEXData.DownloadSymbol(symData.symbol, ht);
                if (c.Id != -1)
                {
                    this.AddSymbol(c);
                }
            }
        }