public override int FillCandles(int n, string d = "") { int _ccnt = 0; _dohlcv = new DataTable(); _ccnt = _dbc_wr.FillRows(_period, _tname, n, ref _dohlcv); if (_ccnt == 0) { goto my_exit; } try { DataRow dr = _dohlcv.Rows[_ccnt - 1]; _last = new StockOHLCV(Convert.ToString(dr["DateTime"]), Convert.ToDouble(dr["Open"]), Convert.ToDouble(dr["High"]), Convert.ToDouble(dr["Low"]), Convert.ToDouble(dr["Close"]), Convert.ToDouble(dr["Volume"])); } catch (IndexOutOfRangeException ex) { Console.WriteLine("Exception at QuandlChart.FillCandles()\r\n" + ex.Message); } my_exit: return(_ccnt); }
public virtual int FillCandles(int n, string d = "") { if (_dohlcv == null) { throw new InvalidOperationException("Candles nothing"); } if (n < 1) { throw new ArgumentException(); } if (d != string.Empty) { DataRow _dr; _dohlcv = _dohlcv.Select("DateTime < '" + d + "'", string.Empty).CopyToDataTable(); _dr = _dohlcv.Rows[_dohlcv.Rows.Count - 1]; _last = new StockOHLCV((string)_dr["DateTime"], Convert.ToDouble(_dr["Open"]), Convert.ToDouble(_dr["High"]), Convert.ToDouble(_dr["Low"]), Convert.ToDouble(_dr["Close"]), Convert.ToDouble(_dr["Volume"])); } while (_dohlcv.Rows.Count > n) { _dohlcv.Rows[0].Delete(); } return(_dohlcv.Rows.Count); }
public StockOHLCV CheckTable(int p, string s, out string sn) { StockOHLCV lastC = default(StockOHLCV); sn = TableName(p, s); if (Exists(sn)) { lastC = LastRow(sn); } else { CreateTable(sn); } return(lastC); }
protected override StockOHLCV LastRow(string cname) { StockOHLCV lastC = default(StockOHLCV); string sql = "select * from " + cname + " where DateTime = (select MAX(DateTime) from " + cname + ")"; MySqlCommand mycommand = new MySqlCommand(sql, (MySqlConnection)conn); try { lastC = new StockOHLCV(Convert.ToString(mycommand.ExecuteScalar()), 0, 0, 0, 0, 0); } catch (Exception ex) { Console.WriteLine("Exception at MySqlWrapper.LastItem()\r\n" + ex.Message); } return(lastC); }
protected override StockOHLCV LastRow(string cname) { StockOHLCV lastC = default(StockOHLCV); string sql = "select * from " + cname + " where rowid = (select MAX(rowid) from " + cname + ")"; SQLiteCommand mycommand = new SQLiteCommand((SQLiteConnection)conn); mycommand.CommandText = sql; try { lastC = new StockOHLCV(Convert.ToString(mycommand.ExecuteScalar()), 0, 0, 0, 0, 0); } catch (Exception ex) { Console.WriteLine("Exception at SQLiteWrapper.LastItem()\r\n" + ex.Message); } return(lastC); }