Exemplo n.º 1
0
        /// <summary>
        /// Get all data for selected symbol in selected date
        /// </summary>
        /// <param name="symbol"></param>
        /// <param name="date"></param>
        /// <returns></returns>
        public static List<TickDataModel> GetTickData(string symbol, DateTime date)
        {
            var contractModelList = new List<TickDataModel>();
            var dateFrom = Convert.ToDateTime(date).ToString("yyyy/MM/dd HH:mm:ss", CultureInfo.InvariantCulture);
            var dateTo = Convert.ToDateTime(date.AddDays(1).Date).ToString("yyyy/MM/dd HH:mm:ss", CultureInfo.InvariantCulture);

            var sql = "SELECT * FROM " + GetTableNameFromContract(symbol) + " WHERE Time BETWEEN '" + dateFrom + "' AND '" + dateTo + "'";
            var reader = GetReader(sql);
            if (reader != null)
            {
                while (reader.Read())
                {
                    var cm = new TickDataModel { Date = reader.GetDateTime(1), Price = reader.GetDouble(2) };

                    contractModelList.Add(cm);
                }

                reader.Close();
            }
            return contractModelList;
        }
Exemplo n.º 2
0
        /// <summary>
        /// With this function you can get all data 
        /// of contract
        /// </summary>
        /// <param name="contractName"></param>
        /// <returns></returns>
        public static List<TickDataModel> GetContractData(string contractName)
        {
            var contractModelList = new List<TickDataModel>();

            var sql = "SELECT * FROM " + GetTableNameFromContract(contractName);
            var reader = GetReader(sql);
            if (reader != null)
            {
                while (reader.Read())
                {
                    var cm = new TickDataModel { Date = reader.GetDateTime(1), Price = reader.GetDouble(2) };

                    contractModelList.Add(cm);
                }

                reader.Close();
            }

            return contractModelList;
        }