Esempio n. 1
0
        public void InsertHistory(string collectionName, int period, string json)
        {
            IHistory h;

            switch (period)
            {
            case 60:
                h = new TradeHistory60();
                break;

            case 30:
                h = new TradeHistory30();
                break;

            case 15:
                h = new TradeHistory15();
                break;

            case 5:
                h = new TradeHistory5();
                break;

            case 10:
                h = new TradeHistory10();
                break;

            default:
                h = new TradeHistoryDaily();
                break;
            }

            h.InsertHistory(collectionName, json);
        }
Esempio n. 2
0
        public ConcurrentBag <List <Candle> > GetHistoryFromFile(ProgressDelegate progress, int period, DateTime fromDate, DateTime toDate)
        {
            IHistory h;
            int      num;
            Dictionary <string, string>    source           = ZerodhaOperations.LoadInstruments();
            ConcurrentBag <List <Candle> > resultCollection = new ConcurrentBag <List <Candle> >();
            int num2 = period;

            if (num2 > 10)
            {
                if (num2 == 15)
                {
                    h = new TradeHistory15();
                    goto TR_0000;
                }
                else if (num2 == 30)
                {
                    h = new TradeHistory30();
                    goto TR_0000;
                }
                else if (num2 == 60)
                {
                    h = new TradeHistory60();
                    goto TR_0000;
                }
            }
            else if (num2 == 5)
            {
                h = new TradeHistory5();
                goto TR_0000;
            }
            else if (num2 == 10)
            {
                h = new TradeHistory10();
                goto TR_0000;
            }
            else if (num2 == 100)
            {
                h = new TradeHistoryDaily();
                goto TR_0000;
            }
            {
                h = new TradeHistoryDaily();
            }
TR_0000:
            num = Environment.ProcessorCount;
            ParallelOptions parallelOptions = new ParallelOptions();

            parallelOptions.MaxDegreeOfParallelism = num;
            Parallel.ForEach <KeyValuePair <string, string> >(source, parallelOptions, delegate(KeyValuePair <string, string> i)
            {
                resultCollection.Add(h.GetHistoryFromFile(h.folderName, i.Value, fromDate.AddDays(-30), toDate));
                if (progress != null)
                {
                    progress($"Loading Data ... {i.Value}");
                }
            });
            return(resultCollection);
        }
Esempio n. 3
0
        public ConcurrentBag <ConcurrentBag <Candle> > GetHistory(ProgressDelegate progress, int period, DateTime fromDate, DateTime toDate)
        {
            Dictionary <string, string>             instrumnets      = ZerodhaOperations.LoadInstruments();
            ConcurrentBag <ConcurrentBag <Candle> > resultCollection = new ConcurrentBag <ConcurrentBag <Candle> >();
            IHistory h;

            switch (period)
            {
            case 60:
                h = new TradeHistory60();
                break;

            case 30:
                h = new TradeHistory30();
                break;

            case 15:
                h = new TradeHistory15();
                break;

            case 5:
                h = new TradeHistory5();
                break;

            case 10:
                h = new TradeHistory10();
                break;

            default:
                h = new TradeHistoryDaily();
                break;
            }

            int cores = Environment.ProcessorCount;

            Parallel.ForEach(instrumnets, new ParallelOptions {
                MaxDegreeOfParallelism = cores
            }, (i) =>
            {
                resultCollection.Add(h.GetHistory(i.Key, i.Value, fromDate, toDate));
                progress(string.Format("Loading Data ... {0}", i.Value));
            });

            return(resultCollection);
        }
Esempio n. 4
0
        public ConcurrentBag <ConcurrentBag <Candle> > GetHistory(string InstrumentToken, int period, DateTime fromDate, DateTime toDate)
        {
            IHistory history;
            ConcurrentBag <ConcurrentBag <Candle> > bag = new ConcurrentBag <ConcurrentBag <Candle> >();
            int num = period;

            if (num > 10)
            {
                if (num == 15)
                {
                    history = new TradeHistory15();
                    goto TR_0000;
                }
                else if (num == 30)
                {
                    history = new TradeHistory30();
                    goto TR_0000;
                }
                else if (num == 60)
                {
                    history = new TradeHistory60();
                    goto TR_0000;
                }
            }
            else if (num == 5)
            {
                history = new TradeHistory5();
                goto TR_0000;
            }
            else if (num == 10)
            {
                history = new TradeHistory10();
                goto TR_0000;
            }
            history = new TradeHistoryDaily();
TR_0000:
            bag.Add(history.GetHistory(InstrumentToken, string.Empty, fromDate, toDate));
            return(bag);
        }
Esempio n. 5
0
        public void InsertHistory(string collectionName, int period, string json)
        {
            IHistory history;
            int      num = period;

            if (num > 10)
            {
                if (num == 15)
                {
                    history = new TradeHistory15();
                    goto TR_0000;
                }
                else if (num == 30)
                {
                    history = new TradeHistory30();
                    goto TR_0000;
                }
                else if (num == 60)
                {
                    history = new TradeHistory60();
                    goto TR_0000;
                }
            }
            else if (num == 5)
            {
                history = new TradeHistory5();
                goto TR_0000;
            }
            else if (num == 10)
            {
                history = new TradeHistory10();
                goto TR_0000;
            }
            history = new TradeHistoryDaily();
TR_0000:
            history.InsertHistory(collectionName, json);
        }
Esempio n. 6
0
        public ConcurrentBag <ConcurrentBag <Candle> > GetHistory(string InstrumentToken, int period, DateTime fromDate, DateTime toDate)
        {
            //Dictionary<string, string> instrumnets = ZerodhaOperations.LoadInstruments();
            ConcurrentBag <ConcurrentBag <Candle> > resultCollection = new ConcurrentBag <ConcurrentBag <Candle> >();
            IHistory h;

            switch (period)
            {
            case 60:
                h = new TradeHistory60();
                break;

            case 30:
                h = new TradeHistory30();
                break;

            case 15:
                h = new TradeHistory15();
                break;

            case 5:
                h = new TradeHistory5();
                break;

            case 10:
                h = new TradeHistory10();
                break;

            default:
                h = new TradeHistoryDaily();
                break;
            }

            resultCollection.Add(h.GetHistory(InstrumentToken, string.Empty, fromDate, toDate));
            return(resultCollection);
        }