Ejemplo n.º 1
0
        public void BitcoinChartsMtgoxBTCUSD_GetTrades()
        {
            try
            {
                var source = new DataProvider.Sources.CBitcoinChartsMtgoxBtcusd();
                var from   = DateTime.Now.AddDays(-1);
                var res    = source.GetTrades(from);

                Assert.False(res.Any(o => o.Date < from), "date sbagliate");
                Assert.False(res.Count() == 0, "nessun dato");
            }
            catch (Exception ex)
            {
                Assert.Fail("lettura fallita, error: " + ex.Message, ex);
            }
        }
Ejemplo n.º 2
0
        // }


        public bool Init(CMarket market)
        {
            //http://api.bitcoincharts.com/v1/trades.csv?symbol=mtgoxUSD

            /*
             * occorre un ciclo while che esamina bitcoincharts e cerca di estrarre i dati
             */

            CUtility.Log("reading candles");
            var candleWidth  = market.CandleMaker.CandleWidth;
            var candleLength = market.CandleMaker.QueueLength();

            var duration = candleWidth * candleLength;
            var from     = DateTime.Now.ToUniversalTime().AddSeconds(-duration);
            var to       = DateTime.Now.ToUniversalTime();
            var source   = new DataProvider.Sources.CBitcoinChartsMtgoxBtcusd();
            var res      = source.GetTrades(from, to);

            CUtility.Log("creating candles");
            foreach (Trade trade in res)
            {
                try
                {
                    var date   = trade.Date;
                    var value  = trade.Price;
                    var amount = trade.Amount;
                    market.CandleMaker.CandleBuilder(date, value, amount);
                    //CUtility.Log(string.Format("Candle {0} {1} ",date.ToString(CultureInfo.InvariantCulture),value.ToString(CultureInfo.InvariantCulture)));
                }
                catch (Exception ex)
                {
                    CUtility.Log(ex.Message);
                    //throw;
                }
            }
            CUtility.Log("start trading");
            //throw new NotImplementedException();
            return(true);
        }