Beispiel #1
0
        public void Create(CoinIntervalModel model, MarketTimes mt)
        {
            if (!CheckIfTableExists(mt))
            {
                CreateTable(mt);
            }

            lock (_connection)
            {
                _connection.Open();
                using (SqlCommand command = new SqlCommand("INSERT INTO " + Market + mt.ToString() + " VALUES (@TimeStamp, @Interval, @Average, @High, @LastHigh, @LastLow, @Low)", _connection))
                {
                    command.Parameters.Add("@TimeStamp", SqlDbType.DateTime).Value = model.IntervalStamp;
                    command.Parameters.Add("@Interval", SqlDbType.Int).Value       = model.Interval;
                    command.Parameters.Add("@Average", SqlDbType.Decimal).Value    = model.Average;
                    command.Parameters.Add("@High", SqlDbType.Decimal).Value       = model.High;
                    command.Parameters.Add("@LastHigh", SqlDbType.Decimal).Value   = model.LastHigh;
                    command.Parameters.Add("@LastLow", SqlDbType.Decimal).Value    = model.LastLow;
                    command.Parameters.Add("@Low", SqlDbType.Decimal).Value        = model.Low;

                    command.ExecuteNonQuery();
                }
                _connection.Close();
            }
        }
Beispiel #2
0
        public CoinIntervalModel Build(List <CoinModel> lcm, MarketTimes mt)
        {
            var cim = new CoinIntervalModel();

            cim.IntervalStamp = DateTime.Now;
            cim.Interval      = (int)mt;
            cim.High          = GetHigh(lcm);
            cim.Low           = GetLow(lcm);
            cim.LastHigh      = lcm[lcm.Count - 1].Result.Ask;
            if (lcm[lcm.Count - 1].Result.Bid >= cim.LastLow)
            {
                cim.LastLow = lcm[lcm.Count - 1].Result.Bid;
            }
            else
            {
                cim.LastLow = cim.LastLow;
            }
            cim.Average = GetAverage(lcm);
            return(cim);
        }