Example #1
0
        public override HuobiMarketSummary GetMarketSummary(HuobiMarket market)
        {
            Depth            btcusdDepth = BtceApi.GetDepth(BtcePair.btc_usd);
            Ticker           ticker      = BtceApi.GetTicker(BtcePair.btc_usd);
            List <TradeInfo> trades      = BtceApi.GetTrades(BtcePair.btc_usd);

            return(new HuobiMarketSummary
            {
                buys = btcusdDepth.Asks.Select(a => new HuobiDepthItem {
                    amount = a.Amount, price = a.Price
                }).ToArray(),
                sells = btcusdDepth.Bids.Select(a => new HuobiDepthItem {
                    amount = a.Amount, price = a.Price
                }).ToArray(),
                trades = trades.Select(a => new HuobiTransaction
                {
                    amount = a.Amount,
                    price = a.Price,
                    time = a.Date.ToString(),
                    type = a.Type.ToString(),
                }).ToArray(),

                p_low = ticker.Low,
                amount = ticker.Volume,
                p_high = ticker.High,
            });
        }
Example #2
0
        private static void Main()
        {
            //var depth3 = BtceApiV3.GetDepth(new[] { BtcePair.BTCUSD });
            //var ticker3 = BtceApiV3.GetTicker(new[] { BtcePair.BTCUSD });
            //var trades3 = BtceApiV3.GetTrades(new[] { BtcePair.BTCUSD });
            //Ticker ticker = BtceApi.GetTicker(BtcePair.btc_usd);
            //var trades = BtceApi.GetTrades(BtcePair.BTCUSD);
            //var btcusdDepth = BtceApi.GetDepth(BtcePair.BTCUSD);
            //var fee = BtceApi.GetFee(BtcePair.BTCUSD);

            var btceApi = new BtceApi("KR3Y5845-RJ9P21RY-C8AFMBDV-DLTSDRBM-GKN022V9", "79b2562155534c1842b85725358fc8ac3adbc7ef0952c0e9a772ced1f0a93369");
            var info = btceApi.GetInfo();
            Console.WriteLine(info.Funds.Ltc);
            //var transHistory = btceApi.GetTransHistory();
            //var tradeHistory = btceApi.GetTradeHistory(count: 20);
            //var orderList = btceApi.GetOrderList();
            //var tradeAnswer = btceApi.Trade(BtcePair.BTCUSD, TradeType.Sell, 20, 0.1m);
            //var cancelAnswer = btceApi.CancelOrder(tradeAnswer.OrderId);

            var activerOrderList = btceApi.GetActiveOrderList();

            Console.WriteLine(">>");
            foreach (var order in activerOrderList.@return)
            {
                Console.WriteLine(order.Key);
                Console.WriteLine(order.Value.Amount);
                Console.WriteLine(order.Value.Pair);
                Console.WriteLine(order.Value.Rate);
                Console.WriteLine(order.Value.Status);
                Console.WriteLine(order.Value.Timestamp_Created);
                Console.WriteLine(order.Value.Type);
            }
            Console.WriteLine("<<");
        }
Example #3
0
        public string UpdateBalance()
        {
            _btceApi = new BtceApi(LoginPage.Key, LoginPage.Secret);

            var userInfo = _btceApi.GetInfo();
            return userInfo.Funds.Ltc.ToString(_culture) + "LTC";
        }
Example #4
0
        static void Main(string[] args)
        {
            var depth3 = BtceApiV3.GetDepth(new BtcePair[] { BtcePair.btc_usd });
            var ticker3 = BtceApiV3.GetTicker(new BtcePair[] { BtcePair.btc_usd });
            var trades3 = BtceApiV3.GetTrades(new BtcePair[] { BtcePair.btc_usd });
            var ticker = BtceApi.GetTicker(BtcePair.btc_usd);
            var trades = BtceApi.GetTrades(BtcePair.btc_usd);
            var btcusdDepth = BtceApi.GetDepth(BtcePair.usd_rur);
            var fee = BtceApi.GetFee(BtcePair.usd_rur);

            if (apiTick == 1)
            {
                apiKey = "3CDPFMIW-XQM8SQ9S-DKT32FZ1-0VOGI1YW-YQELC1Z7";
                apiSecret = "598c09236ca49e737b68c252e413d035d3a1c64a39f0c19078ede95ccf218a8b";
            }
            else if (apiTick == 2)
            {
                apiKey = "EJXDS1KQ-KIHF2XBQ-Z1B7U8P6-JXL7LTQP-P4ATQ3FC";
                apiSecret = "35ae42ffa6942a06724d03b4324a6ce628e8958f4e4bd173803863cc72718bed";
            }
            else if (apiTick == 3)
            {
                apiTick = 1;
            }

            var btceApi = new BtceApi(apiKey, apiSecret);
            var info = btceApi.GetInfo();
            var transHistory = btceApi.GetTransHistory();
            var tradeHistory = btceApi.GetTradeHistory(count: 20);
            var orderList = btceApi.GetOrderList();
            var tradeAnswer = btceApi.Trade(BtcePair.btc_usd, TradeType.Sell, 20, 0.1m);
            var cancelAnswer = btceApi.CancelOrder(tradeAnswer.OrderId);

            refreshStack.Push(refresh(btceApi, 0));
        }
Example #5
0
        public override BcwTicker GetTicker(BcwMarket market)
        {
            Ticker ticker = BtceApi.GetTicker(BtcePair.btc_usd);

            return(new BcwTicker
            {
                date = ticker.ServerTime,
                last = ticker.Last,
            });
        }
Example #6
0
 static object refresh(BtceApi btceApi, int counter)
 {
     //Multi threading fix for stack overflow errors/api key timeout.
     counter += 1;
     if (counter > 10)
     {
         refreshStack.Clear();
         counter = 0;
     }
     apiTick = BtceApi.apiTick;
     refreshStack.Push(refresh(btceApi, counter));
     return counter;
 }
Example #7
0
		static void Main(string[] args) {
			var ticker = BtceApi.GetTicker(BtcePair.btc_usd);
			var trades = BtceApi.GetTrades(BtcePair.btc_usd);
			var btcusdDepth = BtceApi.GetDepth(BtcePair.usd_rur);
			var fee = BtceApi.GetFee(BtcePair.usd_rur);

			var btceApi = new BtceApi("API_KEY", "API_SECRET");
			var info = btceApi.GetInfo();
			var transHistory = btceApi.GetTransHistory();
			var tradeHistory = btceApi.GetTradeHistory(count: 20);
			var orderList = btceApi.GetOrderList();
			var tradeAnswer = btceApi.Trade(BtcePair.btc_usd, TradeType.Sell, 20, 0.1m);
			var cancelAnswer = btceApi.CancelOrder(tradeAnswer.OrderId);
		}
Example #8
0
        public override List <BcwTrade> GetPublicTrades(BcwMarket market, long sinceTid = -1)
        {
            List <TradeInfo> trades = BtceApi.GetTrades(BtcePair.btc_usd);

            return(trades.Select(e => new BcwTrade
            {
                amount = e.Amount,
                date = UnixTime.GetFromDateTime(e.Date),
                price = e.Price,
                tid = e.Tid,
                trade_type = e.Type == TradeInfoType.Ask
                    ? BcwOrderType.ask
                    : BcwOrderType.bid
            }).ToList());
        }
Example #9
0
        static void Main(string[] args)
        {
            var ticker = BtceApi.GetTicker(BtcePair.BtcUsd);
            var trades = BtceApi.GetTrades(BtcePair.BtcUsd);
            var btcusdDepth = BtceApi.GetDepth(BtcePair.UsdRur);
            var fee = BtceApi.GetFee(BtcePair.UsdRur);

            var btceApi = new BtceApi("YOUR-API-KEY", "your_secret_key");
            var info = btceApi.GetInfo();
            var transHistory = btceApi.GetTransHistory();
            var tradeHistory = btceApi.GetTradeHistory(count: 20);
            var orderList = btceApi.GetOrderList();
            var tradeAnswer = btceApi.Trade(BtcePair.BtcUsd, TradeType.Sell, 20, 0.1m);
            var cancelAnswer = btceApi.CancelOrder(tradeAnswer.OrderId);
        }
Example #10
0
 /// <summary>
 ///     Clean up
 /// </summary>
 /// <param name="disposing"></param>
 protected virtual void Dispose(bool disposing)
 {
     // make thread safe
     lock (_disposeLock)
     {
         // conform to reference example: http://msdn.microsoft.com/en-us/library/fs2xkftw.aspx
         if (!_disposed)
         {
             if (disposing)
             {
                 // null check
                 if (_apiv2 != null)
                 {
                     // invoke disposing
                     _apiv2.Dispose();
                     _apiv2 = null; // null just to br safe
                 }
                 _disposed = true;
             }
         }
     }
 }
Example #11
0
 /// <summary>
 ///     Constructor.
 /// </summary>
 /// <param name="key">The account key.</param>
 /// <param name="secret">The account secret.</param>
 /// <param name="exchangeHost">The exchange host (default: "https://btc-e.com/";).</param>
 public BtceApiClientV3(string key, string secret, string exchangeHost = null)
 {
     _apiv2 = new BtceApi(key, secret, exchangeHost);
 }
Example #12
0
 /// <summary>
 ///     Clean up
 /// </summary>
 /// <param name="disposing"></param>
 protected virtual void Dispose(bool disposing)
 {
     // make thread safe
     lock (_disposeLock)
     {
         // conform to reference example: http://msdn.microsoft.com/en-us/library/fs2xkftw.aspx
         if (!_disposed)
         {
             if (disposing)
             {
                 // null check
                 if (_apiv2 != null)
                 {
                     // invoke disposing
                     _apiv2.Dispose();
                     _apiv2 = null; // null just to br safe
                 }
                 _disposed = true;
             }
         }
     }
 }
Example #13
0
 /// <summary>
 ///     Constructor.
 /// </summary>
 /// <param name="key">The account key.</param>
 /// <param name="secret">The account secret.</param>
 /// <param name="exchangeHost">The exchange host (default: "https://btc-e.com/";).</param>
 public BtceApiClientV3(string key, string secret, string exchangeHost = null)
 {
     _apiv2 = new BtceApi(key, secret, exchangeHost);
 }
Example #14
0
        public override DateTime GetHuobiTime()
        {
            Ticker ticker = BtceApi.GetTicker(BtcePair.btc_usd);

            return(UnixTime.ConvertToDateTime(ticker.ServerTime));
        }
Example #15
0
 public BTCeMarket(string accessKey, string secretKey, double sleepAfterCallSeconds = 1.5)
     : base(accessKey, secretKey, sleepAfterCallSeconds)
 {
     _btceApi = new BtceApi(accessKey, secretKey);
 }
 public ArbitrageManager()
 {
     _fee = 0.2m;
     _proxy = (ExchangeProxyFactory.GetProxy(ExchangesInternalCodes.Btce) as BtceWrapper).BtceProxy;
 }
 public decimal GetFee(BtcePair pair)
 {
     return(BtceApi.GetFee(pair));
 }
 public BTCeMarket(string accessKey, string secretKey, double sleepAfterCallSeconds = 1.5)
     : base(accessKey, secretKey, sleepAfterCallSeconds)
 {
     _btceApi = new BtceApi(accessKey, secretKey);
 }
Example #19
0
        private void Update(bool enabled, double period)
        {
            lock (this)
            {
                // Fetch live data from internet
                if (enabled)
                {
                    if (realtimeCandles.Count == 0)
                    {
                        UpdateStatus("Loading last 24 hours candles");
                        try
                        {
                            IList<OHLC> candles = GetCandlesFromBitcoincharts(DateTime.Now.Subtract(new TimeSpan(24, 0, 0)), period);
                            if (candles.Count == 0)
                                candles = ReadCandlesFromCSV(string.Format("realtime{0}.csv", pair.ToString()), DateTime.Now.Subtract(new TimeSpan(24, 0, 0)));

                            foreach (var candle in candles)
                                realtimeCandles.Add(candle);
                        }
                        catch (Exception)
                        {
                            UpdateStatus("Failed to get last 24 hours candles from Bitcoincharts");
                            Thread.Sleep(1000);
                        }
                    }

                    // First load history
                    if (realtimeCandles.Count > 0)
                    {
                        UpdateStatus("Fetching new data from BTC-e");
                        GetCandlesFromBtce(period);
                        SaveCandlesToCSV(realtimeCandles, string.Format("realtime{0}.csv", pair.ToString()));
                    }
                }

                try
                {
                    if (pair != BtcePair.Unknown)
                    {
                        //UpdateStatus("Updating BTC-e ticker and fees");
                        if (fee == 0m) fee = BtceApi.GetFee(pair);
                        ticker = BtceApi.GetTicker(pair);
                    }

                    if (!string.IsNullOrEmpty(key) && !string.IsNullOrEmpty(secret))
                    {
                        //UpdateStatus("Updating account informations");
                        BtceApi btceApi = new BtceApi(key, secret);
                        info = btceApi.GetInfo();
                    }
                    UpdateStatus("Ready...");
                }
                catch (Exception ex)
                {
                    UpdateStatus(string.Format("Error during Update: {0}", ex.Message));
                }

                //Depth btcusdDepth = BtceApi.GetDepth(BtcePair.btc_eur);
                //var transHistory = btceApi.GetTransHistory();
                //var tradeHistory = btceApi.GetTradeHistory(count: 20);
                //var orderList = btceApi.GetOrderList();
                //var tradeAnswer = btceApi.Trade(BtcePair.btc_eur, TradeType.Sell, 20, 0.1m);
                //var cancelAnswer = btceApi.CancelOrder(tradeAnswer.OrderId);
            }
        }