Пример #1
0
        private void _store_candles(string fstr, string d2)
        {
            DataTable dic = default(DataTable);

            QuandlAPI.QuandlError err = default(QuandlAPI.QuandlError);
            WnF_DBType            dbt = (WnF_DBType)Properties.Settings.Default.dbms;
            string cstr;

            err = _api.GetCandlesTable(fstr, d2, out dic, _tname);
            if (err != null)
            {
                Console.WriteLine("[QuandlChart._store_candles()] GetCandlesTable failed...\r\n" + err.message);
                return;
            }

#if DEBUG
            dynamic watch = System.Diagnostics.Stopwatch.StartNew();
#endif
            cstr = string.Format(Properties.Settings.Default.dbConn, _database);
            using (WnFDbConnectionWrapper dbcw = WnFDbConnectionWrapper.GetWrapper(dbt, cstr))
                dbcw.InsertTable(dic);

#if DEBUG
            watch.Stop();
            Console.WriteLine("[QuandlChart._store_candles()] " + dic.Rows.Count + " ellapsed " + watch.ElapsedMilliseconds);
#endif
            dic = null;
        }
Пример #2
0
 public QuandlChart(int p, string dataset, string database, WnFDbConnectionWrapper _wrpper = null) : base(p, dataset)
 {
     _database = database;
     _api      = (QuandlAPI)WnFElliottBrowser.Factory;
     _set_dbconn(_wrpper);
     _init_candles();
 }
Пример #3
0
 private void _set_dbconn(WnFDbConnectionWrapper wrpper)
 {
     _dbc_wr_owner = (wrpper == null);
     if (wrpper == null)
     {
         _dbc_wr = WnFDbConnectionWrapper.GetWrapper((WnF_DBType)Properties.Settings.Default.dbms, string.Format(Properties.Settings.Default.dbConn, _database));
     }
     else
     {
         _dbc_wr = wrpper;
     }
 }
        public static WnFDbConnectionWrapper GetWrapper(WnF_DBType k, string s)
        {
            WnFDbConnectionWrapper wrpper = default(WnFDbConnectionWrapper);

            if (k == WnF_DBType.SQLCE)
            {
retry:
                wrpper = new SqlCeWrapper(k, s);
                if (!wrpper.InitConnection())
                {
                    wrpper = null; Thread.Sleep(10);
                    goto retry;
                }
            }
            else
            {
                throw new NotImplementedException();
            }

            return(wrpper);
        }
Пример #5
0
 public QuandlChart(int p, string dataset, CommodityType k, string database, WnFDbConnectionWrapper _wrpper = null) : this(p, dataset, database, _wrpper)
 {
     _ctype = k;
 }
Пример #6
0
        public void GetCandles(string s, int p, CommodityType type, ref Dictionary <CandlePeriod, WnFCandles> dic, WnFDbConnectionWrapper wrpper = null)
        {
            WnFCandles ch = new QuandlChart(p, s, "WIKI", wrpper);

            if (((QuandlChart)ch).GetCandles() > 0)
            {
                ch.FillCandles(_MAX_JSON);
            }
            dic[(CandlePeriod)p] = ch;
        }
Пример #7
0
        public WnFCandles GetCandles(string s, int p, CommodityType type = CommodityType.None, WnFDbConnectionWrapper wrpper = null)
        {
            QuandlChart ch  = new QuandlChart(p, s, "WIKI", wrpper);
            int         err = ch.GetCandles();

            if (err < 0)
            {
                ch.FillCandles(_MAX_JSON);
            }
            else if (err > 0)
            {
                ch.FillCandles(_MAX_JSON);
            }
            return(ch);
        }