Esempio n. 1
0
        public bool Check(out int _err, out WnFCandles _c)
        {
            _err      = 0;
            _c        = null;
            _akeyfile = string.Empty;
            _apikeys  = LoadAPIKeys(out _akeyfile);
            _url_fstr = string.Empty;

            if (_akeyfile == string.Empty)
            {
                _err = (int)APIError.APIKeyFile;
                return(false);
            }
            else if (_apikeys.Count == 0)
            {
                _err = (int)APIError.APIKeyLength;
                return(false);
            }
            else if (!ReadURLString("Candles", out _url_fstr))
            {
                _err = (int)APIError.APIUrlFormat;
                return(false);
            }
            else
            {
                string symbol, database;
                if (!ReadURLString("DatabaseDefault", out database) || !ReadURLString("DatasetDefault", out symbol))
                {
                    _err = (int)APIError.APIUrlFormat; return(false);
                }

                _ch  = new QuandlChart((int)CandlePeriod.D, symbol, database);
                _err = _ch.GetCandles();
                if (_err < 0)
                {
                    return(false);
                }
                else if (_err > 0)
                {
                    _ch.FillCandles(_MAX_JSON);
                }

                if (_ch.DOHLCV.Rows.Count == 0)
                {
                    _err = (int)APIError.Unknown; return(false);
                }
                else
                {
                    _c = _ch;
                }
            }

            return(true);
        }
Esempio n. 2
0
        private void SelectSymbol(string symbol, CommodityType type = CommodityType.Stocks, WnFCandles ch = null)
        {
            if (symbol == symbolOnDisplay)
            {
                return;
            }

            splitContainer2.Panel2.Controls.RemoveAt(0); splitContainer2.Panel1Collapsed = true;

            if (!toolStripCBSymbol.AutoCompleteCustomSource.Contains(symbol))
            {
                chartsDic[symbol] = new Dictionary <CandlePeriod, CChartPanel>();
                if (!toolStripCBSymbol.Items.Contains(symbol))
                {
                    toolStripCBSymbol.Items.Add(symbol);
                }
                toolStripCBSymbol.AutoCompleteCustomSource.Add(symbol);
            }

            if (!symbolsOn.ContainsKey(symbol))
            {
                symbolsOn[symbol] = new Dictionary <CandlePeriod, WnFCandles>();
                if (ch != null)
                {
                    symbolsOn[symbol][(CandlePeriod)ch.Period] = ch;
                }
            }

            toolStripCBSymbol.Text = symbol;
            this.Text = Properties.Settings.Default.tm + " - " + symbolsDic[symbol];
        }