public bool ReadURLString(string k, out string fstr)
        {
            string p = _home + System.IO.Path.DirectorySeparatorChar + Properties.Settings.Default.urls_ini;

            fstr = WnFElliottBrowser.ReadURLString(p, k);
            return(fstr != string.Empty);
        }
Beispiel #2
0
        private void toolStripBtnAbout_Click(object sender, EventArgs e)
        {
            Form f = WnFElliottBrowser.GetForm(_factory, ModeOfInfo.Product);

            f.Show();
            f.Location = new Point(this.Location.X + SystemInformation.ToolWindowCaptionHeight, this.Location.Y + SystemInformation.ToolWindowCaptionHeight);
        }
Beispiel #3
0
        public static Form GetForm(IWnFOpenAPI factory, ModeOfInfo m = ModeOfInfo.Product, int ic = -1)
        {
            Form        f = new Form();
            UserControl c = default(UserControl);

            if (m == ModeOfInfo.Product)
            {
                f.Text = Properties.Settings.Default.tm + " Information";
                c      = new CProductInfo();
            }
            else if (m == ModeOfInfo.IniEdit)
            {
                f.Text = Properties.Settings.Default.tm + " Settings for " + factory.ProviderName();
                c      = new CIniEdit(ic, (ic != -1) ? WnFElliottBrowser.APIIniPath(QuandlAPI._PROVIDER, (IniCategory)ic) : null);
            }
            else
            {
                throw new NotImplementedException();
            }

            f.Size = new System.Drawing.Size(900, 500);
            f.Icon = Properties.Resources.tr5_10;
            c.Dock = DockStyle.Fill;
            f.Controls.Add(c);
            f.TopMost = true;
            return(f);
        }
Beispiel #4
0
        private void toolStripSplitAPI_ButtonClick(object sender, EventArgs e)
        {
            WnFCandles ch;
            int        err = -1;

            if (toolStripSplitAPI.Text == "Data Provider")
            {
                if (Convert.ToString(toolStripSplitAPI.Tag) == QuandlAPI._PROVIDER)
                {
                    WnFElliottBrowser.Factory            = _factory = (IWnFOpenAPI)(new QuandlAPI());
                    ((QuandlAPI)_factory).SymbolsUpdate += Trade5ElliottBrowser_SymbolsUpdate;
                }
                else
                {
                    throw new NotImplementedException();
                }

                if (_factory.Check(out err, out ch))
                {
                    toolStripSLblOnOff.Image  = Properties.Resources.ArrowGreen;
                    toolStripSLblOnOff.Text   = _factory.ProviderName();
                    toolStripSLblMessage.Text = "Checking API settings OK";
                    MessageBox.Show(toolStripSLblMessage.Text, Properties.Settings.Default.tm, MessageBoxButtons.OK);

                    toolStripSplitAPI.Text = quandlToolStripMenuItem.Text;
                    InitPeriodButtons();
                    SelectSymbol(ch.Symbol, CommodityType.None, ch);
                }
                else
                {
                    MessageBox.Show("Error checking API settings: " + ((APIError)err).ToString(), Properties.Settings.Default.tm, MessageBoxButtons.OK);

                    if (err == (int)APIError.APIKeyFile || err == (int)APIError.APIKeyLength)
                    {
                        if (err == (int)APIError.APIKeyFile)
                        {
                            WnFElliottBrowser.CreateAPIKeysIni(QuandlAPI._PROVIDER);
                        }

                        Form f = WnFElliottBrowser.GetForm(_factory, ModeOfInfo.IniEdit, (int)IniCategory.APIKeys);
                        f.Show();
                        f.Location = new Point(this.Location.X + SystemInformation.ToolWindowCaptionHeight, this.Location.Y + SystemInformation.ToolWindowCaptionHeight);
                    }
                    else if (err == (int)APIError.APIUrlFormat || err == (int)APIError.APIResponseErr)
                    {
                        Form f = WnFElliottBrowser.GetForm(_factory, ModeOfInfo.IniEdit, (int)IniCategory.URLs);
                        f.Show();
                        f.Location = new Point(this.Location.X + SystemInformation.ToolWindowCaptionHeight, this.Location.Y + SystemInformation.ToolWindowCaptionHeight);
                    }
                }
            }
            else
            {
            }
        }
        public QuandlError GetCandlesDic(string fstr, string end_date, out Dictionary <string, double[]> dic, int n = int.MinValue)
        {
            QuandlError       err    = default(QuandlError);
            QuandlDataWrapper result = default(QuandlDataWrapper);
            string            req_url;
            int ccnt = 0, rcnt = 0;

            dic = new Dictionary <string, double[]>();

            if (n != int.MinValue)
            {
                n = Math.Max(n, _MAX_JSON); fstr += "&rows=" + n;
            }
            else
            {
                n = int.MaxValue;
            }

            req_url = string.Format(fstr, end_date);

            do
            {
                try
                {
                    result = (QuandlDataWrapper)WnFElliottBrowser.GetJSONObjects(req_url, typeof(QuandlDataWrapper));
                }
                catch (WebException ex)
                {
                    int status = (int)((HttpWebResponse)ex.Response).StatusCode;
                    err = GetQuandlError(ex);
                    Console.WriteLine("Exception at QuandlAPI.GetCandlesDic() GetJSONObjects returned {0} after {1} candles.", status, dic.Count);
                    if (dic.Count > 0)
                    {
                        dic.Clear();
                    }
                    break;
                }

                rcnt += 1;
                ccnt  = result.dataset_data.data.Length;
                foreach (TimeSeries l in result.dataset_data.data)
                {
                    end_date      = l.Date;
                    dic[end_date] = l.Values;
                }

                req_url = string.Format(fstr, end_date);
            } while (ccnt >= n);

            result = null;
            return(err);
        }
 public Dictionary <int, string> LoadAPIKeys(out string _p)
 {
     _p = _home + System.IO.Path.DirectorySeparatorChar + Properties.Settings.Default.keys_ini;
     if (!File.Exists(_p))
     {
         _p = string.Empty;
         return(null);
     }
     else
     {
         return(WnFElliottBrowser.LoadAPIKeys(_p));
     }
 }
Beispiel #7
0
        public trade5ElliottBrowser()
        {
            InitializeComponent();

            if (!WnFElliottBrowser.LoadIni())
            {
                throw new Exception("Error loading application configuration file");
            }

            symbolsOn = new Dictionary <string, Dictionary <CandlePeriod, WnFCandles> >();
            chartsDic = new Dictionary <string, Dictionary <CandlePeriod, CChartPanel> >();
            periodDic = new Dictionary <CandlePeriod, bool>();

            czoom = Properties.Settings.Default.czoom;
            if (czoom == 0)
            {
                czoom = 144;
                Properties.Settings.Default.czoom = czoom;
            }
            toolStripTBZoom.Text = czoom.ToString();
        }
        public QuandlError GetCandlesTable(string fstr, string end_date, out DataTable dic, string tname = "")
        {
            QuandlError       err = default(QuandlError);
            QuandlDataWrapper result = default(QuandlDataWrapper);
            DataRow           r = default(DataRow);
            string            req_url = string.Format(fstr, end_date);
            int ccnt = 0, rcnt = 0;

            dic = _candles_table(tname);

            try
            {
                result = (QuandlDataWrapper)WnFElliottBrowser.GetJSONObjects(req_url, typeof(QuandlDataWrapper));
            }
            catch (WebException ex)
            {
                int status = (int)((HttpWebResponse)ex.Response).StatusCode;
                err = GetQuandlError(ex);
                Console.WriteLine("Exception at QuandlAPI.GetCandlesTable() GetJSONObjects returned {0}", status);
            }

            rcnt += 1;
            ccnt  = result.dataset_data.data.Length;
            for (int i = result.dataset_data.data.Length - 1; i >= 0; i--)
            {
                TimeSeries v = result.dataset_data.data[i];
                r             = dic.NewRow();
                r["DateTime"] = v.Date.Replace("-", "/");
                r["Open"]     = v.Values[0];
                r["High"]     = v.Values[1];
                r["Low"]      = v.Values[2];
                r["Close"]    = v.Values[3];
                r["Volume"]   = v.Values[4];
                dic.Rows.Add(r);
            }

            result = null;
            return(err);
        }