예제 #1
0
        public void GetTotalBalances()
        {
            ItBit    itbit    = new ItBit();
            Anx      anx      = new Anx();
            Bitstamp bitstamp = new Bitstamp();
            Kraken   kraken   = new Kraken();
            //Btce btce = new Btce();
            Bitfinex bitfinex = new Bitfinex();

            itbit.UpdateBalances();
            anx.UpdateBalances();
            bitstamp.UpdateBalances();
            bitfinex.UpdateBalances();

            //TODO: Fix these! Should be calls to UpdateTotalBalances!
            kraken.UpdateBalances();
            //btce.UpdateBalances();

            Decimal itBitBtcAmount      = itbit.TotalBtc;
            Decimal itBitFiatAmount     = itbit.TotalFiat;
            Decimal anxBtcAmount        = anx.TotalBtc;
            Decimal anxFiatAmount       = anx.TotalFiat;
            Decimal bitstampBtcAmount   = bitstamp.TotalBtc;
            Decimal bitstampFiatoAmount = bitstamp.TotalFiat;
            Decimal bitfinexBtcAmount   = bitfinex.TotalBtc;
            Decimal bitfinexFiatAmount  = bitfinex.TotalFiat;

            //TODO Fix these! They should be the total amounts!
            Decimal krakenBtcAmount = kraken.AvailableBtc;
            Decimal krakenEurAmount = kraken.AvailableFiat;
            //Decimal btceBtcAmount = btce.AvailableBtc;
            //Decimal btceEuroAmount = btce.AvailableFiat;
        }
예제 #2
0
        public void BitfinexGetAllOpenOrdersTest()
        {
            Bitfinex bitfinex = new Bitfinex();

            //If there is any problem connecting to the exchange, this will throw an error.
            List <Dictionary <string, dynamic> > openOrderList = bitfinex.GetAllOpenOrders();
        }
        public ActionResult CurrencyDetail(int symbol)
        {
            var response = MCAPI.Get <JObject>("ticker/" + symbol);
            var tickers  = MCAPI.GetSysmbolData(response);

            if (symbol == 1)
            {
                var response_trade = Bitfinex.GetTicklers("candles/trade:1M:tBTCUSD/hist");
                JsonSerializerSettings _jsonSetting = new JsonSerializerSettings()
                {
                    NullValueHandling = NullValueHandling.Ignore
                };
                ViewBag.DataPoints          = JsonConvert.SerializeObject(response_trade.ListChartParameters.ToList(), _jsonSetting);
                tickers.ListChartParameters = response_trade.ListChartParameters;
            }
            else if (symbol == 1027)
            {
                var response_trade = Bitfinex.GetTicklers("candles/trade:1M:tETHUSD/hist");
                JsonSerializerSettings _jsonSetting = new JsonSerializerSettings()
                {
                    NullValueHandling = NullValueHandling.Ignore
                };
                ViewBag.DataPoints          = JsonConvert.SerializeObject(response_trade.ListChartParameters.ToList(), _jsonSetting);
                tickers.ListChartParameters = response_trade.ListChartParameters;
            }

            return(View(tickers));
        }
예제 #4
0
        public void BitfinexBalanceUpdateTest()
        {
            Bitfinex bitfinex = new Bitfinex();

            //If there is any problem connecting to the exchange, this will throw an error.
            bitfinex.UpdateBalances();
        }
예제 #5
0
        public Client(Bitfinex ex, ISymbolFactory symbolFactory)
        {
            Exchange = ex;

            SymbolFactory = symbolFactory;

            RateLimiter = new BitfinexRateLimiter();
        }
예제 #6
0
        public void BitfinexGetTradeFeeTest()
        {
            Bitfinex bitfinex = new Bitfinex();

            bitfinex.SetTradeFee();

            Assert.IsTrue(bitfinex.TradeFee > 0);
        }
예제 #7
0
        public void BitfinexUpdateOrderBookTest()
        {
            Bitfinex bitfinex = new Bitfinex();

            //If there is any problem connecting to the exchange, this will throw an error.
            bitfinex.UpdateOrderBook(1);

            //This assumes that the exchange has at least 1 order on each side. Technically this can give a false negative, but it's unlikely.
            Assert.IsTrue(bitfinex.OrderBook.Asks.Count == 1);
            Assert.IsTrue(bitfinex.OrderBook.Bids.Count == 1);
        }
예제 #8
0
        static void Main(string[] args)
        {
            Bitfinex b = new Bitfinex();

            b.MinVolConsider = 10000;
            //Console.WriteLine(b.GetMoedas()[0]);
            //b.getTicker(b.GetMoedas()[4]);
            b.consultaVolume("ZECBTC", Exchange.Periodos.Dia);


            Console.ReadLine();
        }
        public ActionResult _ChartTable(int sym, string selectedval)
        {
            var response       = MCAPI.Get <JObject>("ticker/" + 1);
            var symbol         = "";
            var tickers        = MCAPI.GetSysmbolData(response);
            var response_trade = new Ticklers();

            if (sym == 1)
            {
                symbol = "tBTCUSD";
            }
            else if (sym == 2)
            {
                symbol = "tETHUSD";
            }

            if (selectedval == "1Min")
            {
                response_trade = Bitfinex.GetTicklers("candles/trade:" + 1 + "m:" + symbol + "/hist");
            }

            else if (selectedval == "1Hour")
            {
                response_trade = Bitfinex.GetTicklers("candles/trade:" + 1 + "h:" + symbol + "/hist");
            }
            else if (selectedval == "1Day")
            {
                response_trade = Bitfinex.GetTicklers("candles/trade:" + 1 + "D:" + symbol + "/hist");
            }
            else if (selectedval == "7Days")
            {
                response_trade = Bitfinex.GetTicklers("candles/trade:" + 7 + "D:" + symbol + "/hist");
            }
            else if (selectedval == "14Days")
            {
                response_trade = Bitfinex.GetTicklers("candles/trade:" + 14 + "D:" + symbol + "/hist");
            }
            else if (selectedval == "1Month")
            {
                response_trade = Bitfinex.GetTicklers("candles/trade:" + 1 + "M:" + symbol + "/hist");
            }
            JsonSerializerSettings _jsonSetting = new JsonSerializerSettings()
            {
                NullValueHandling = NullValueHandling.Ignore
            };

            ViewBag.DataPoints = JsonConvert.SerializeObject(response_trade.ListChartParameters.ToList(), _jsonSetting);
            return(PartialView(tickers));
        }
        public ActionResult _HistoricalTable(string drpdownval, int sym = 1)
        {
            var response       = MCAPI.Get <JObject>("ticker/" + 1);
            var symbol         = "";
            var tickers        = MCAPI.GetSysmbolData(response);
            var response_trade = new Ticklers();

            if (sym == 1)
            {
                symbol = "tBTCUSD";
            }
            else if (sym == 2)
            {
                symbol = "tETHUSD";
            }


            if (drpdownval == "1 Min")
            {
                response_trade = Bitfinex.GetTicklers("candles/trade:" + 1 + "m:" + symbol + "/hist");
            }

            else if (drpdownval == "1 Hour")
            {
                response_trade = Bitfinex.GetTicklers("candles/trade:" + 1 + "h:" + symbol + "/hist");
            }

            else if (drpdownval == "30 Days")
            {
                response_trade = Bitfinex.GetTicklers("candles/trade:" + 1 + "M:" + symbol + "/hist");
            }
            else if (drpdownval == "7 Days")
            {
                response_trade = Bitfinex.GetTicklers("candles/trade:" + 7 + "D:" + symbol + "/hist");
            }
            else if (drpdownval == "1 Day")
            {
                response_trade = Bitfinex.GetTicklers("candles/trade:" + 1 + "D:" + symbol + "/hist");
            }
            else if (drpdownval == "14 Days")
            {
                response_trade = Bitfinex.GetTicklers("candles/trade:" + 14 + "D:" + symbol + "/hist");
            }

            tickers.ListChartParameters = response_trade.ListChartParameters;
            return(PartialView(tickers));
        }
        private async void UpdatePrice()
        {
            Status      = "Fetching Bitcoin Price...";
            Errors      = string.Empty;
            IsReceiving = true;

            PriceApi api = null;

            switch (Settings.SelectedPriceApi)
            {
            case PriceServiceNames.Bitfinex:
                api = new Bitfinex();
                break;

            case PriceServiceNames.Btce:
                api = new Btce();
                break;

            case PriceServiceNames.Coindesk:
                api = new Coindesk();
                break;

            default:
                api = new Bitfinex();
                break;
            }

            Response <decimal> resp = await api.UpdatePriceAsync();

            if (resp.Errors.Any())
            {
                Errors = resp.Errors.GetErrors();
                Status = "Encountered an error!";
            }
            else
            {
                Settings.BitcoinPriceInUSD = resp.Result;
                RaisePropertyChanged("BitcoinPrice");
                Status = "Price Update Success!";
            }

            IsReceiving = false;
        }
예제 #12
0
        public void BitfinexBuySellQueryDeleteTest()
        {
            Bitfinex bitfinex = new Bitfinex();
            string   buyOrderId;
            string   sellorderId;

            //First, insert a buy and sell order. If there are any errors with either of these operations,
            //an exception will be thrown.

            //Buy at a really low price to the order doesn't actually get executed.
            buyOrderId = bitfinex.Buy(bitfinex.MinimumBitcoinOrderAmount, 10m);

            //Sell at a really high price so the order doesn't actually get executed.
            sellorderId = bitfinex.Sell(bitfinex.MinimumBitcoinOrderAmount, 9999m);

            //Both orders should still be open
            Assert.IsFalse(bitfinex.IsOrderFulfilled(buyOrderId));
            Assert.IsFalse(bitfinex.IsOrderFulfilled(sellorderId));

            //Now delete both orders. If there are any errors with either of these operations,
            //an exception will be thrown.
            bitfinex.DeleteOrder(buyOrderId);
            bitfinex.DeleteOrder(sellorderId);
        }
예제 #13
0
        public Client(Bitfinex ex, ISymbolFactory symbolFactory)
        {
            Exchange = ex;

            SymbolFactory = symbolFactory;
        }
예제 #14
0
        public async Task <ITickers> GetTicker([FromBody] CompositeStockExchangeObject compositeStockExchangeObject)
        {
            decimal exchangeRate = compositeStockExchangeObject.ExchangeRate;

            Common.StockExchange.Types.StockExchange selectedStockExchange = compositeStockExchangeObject.StockExchange;
            string selectedPairs = compositeStockExchangeObject.SelectedPairs;

            IStockExchanges stockExchanges;

            switch (selectedStockExchange)
            {
            case Common.StockExchange.Types.StockExchange.Binance:
                stockExchanges = new Binance();
                return(await stockExchanges.GetTickers(selectedPairs, exchangeRate));

            case Common.StockExchange.Types.StockExchange.Bitfinex:
                stockExchanges = new Bitfinex();
                return(await stockExchanges.GetTickers(selectedPairs, exchangeRate));

            case Common.StockExchange.Types.StockExchange.Bitmex:
                stockExchanges = new Bitmex();
                return(await stockExchanges.GetTickers(selectedPairs, exchangeRate));

            case Common.StockExchange.Types.StockExchange.Bitstamp:
                stockExchanges = new Bitstamp();
                return(await stockExchanges.GetTickers(selectedPairs, exchangeRate));

            case Common.StockExchange.Types.StockExchange.Bittrex:
                stockExchanges = new Bittrex();
                return(await stockExchanges.GetTickers(selectedPairs, exchangeRate));

            case Common.StockExchange.Types.StockExchange.Cex:
                stockExchanges = new Cex();
                return(await stockExchanges.GetTickers(selectedPairs, exchangeRate));

            case Common.StockExchange.Types.StockExchange.Exmo:
                stockExchanges = new Exmo();
                return(await stockExchanges.GetTickers(selectedPairs, exchangeRate));

            case Common.StockExchange.Types.StockExchange.Gdax:
                stockExchanges = new Gdax();
                return(await stockExchanges.GetTickers(selectedPairs, exchangeRate));

            case Common.StockExchange.Types.StockExchange.Gemini:
                stockExchanges = new Gemini();
                return(await stockExchanges.GetTickers(selectedPairs, exchangeRate));

            case Common.StockExchange.Types.StockExchange.Kraken:
                stockExchanges = new Kraken();
                return(await stockExchanges.GetTickers(selectedPairs, exchangeRate));

            case Common.StockExchange.Types.StockExchange.Poloniex:
                stockExchanges = new Poloniex();
                return(await stockExchanges.GetTickers(selectedPairs, exchangeRate));

            case Common.StockExchange.Types.StockExchange.QuadrigaCx:
                stockExchanges = new QuadrigaCx();
                return(await stockExchanges.GetTickers(selectedPairs, exchangeRate));

            default:
                throw new NullStockExchangeException("Invalid StockExchange Selection");
            }
        }
예제 #15
0
        private static void PopulateExchanges(string securityJsonFilename)
        {
            m_security = new ApiSecurity(securityJsonFilename);
            foreach (var exch in m_security.ApiKeys.Keys)
            {
                var c = m_security.ApiKeys[exch];
                //Console.WriteLine("{0} '{1}' '{2}'", exch, c.ApiKey, c.ApiSecret);
            }

            ApiCredentials creds;

            /*creds = m_security.ApiKeys["B2C2"];                             // BINANCE
             * b2c2 = B2C2.Create(creds);
             * Exchanges[CryptoExch.B2C2] = b2c2;*/

            creds   = m_security.ApiKeys["BINANCE"];                        // BINANCE
            binance = Binance.Create(creds);
            Exchanges[CryptoExch.BINANCE] = binance;

            creds    = m_security.ApiKeys["BITFINEX"];                      // BITFINEX
            bitfinex = Bitfinex.Create(creds);
            Exchanges[CryptoExch.BITFINEX] = bitfinex;

            creds    = m_security.ApiKeys["BITFLYER"];                      // BITFLYER
            bitflyer = BitFlyer.Create(creds);
            Exchanges[CryptoExch.BITFLYER] = bitflyer;

            creds    = m_security.ApiKeys["BITSTAMP"];                      // BITSTAMP
            bitstamp = Bitstamp.Create(creds, "client_id");
            Exchanges[CryptoExch.BITSTAMP] = bitstamp;

            creds   = m_security.ApiKeys["BITTREX"];                        // BITTREX
            bittrex = Bittrex.Create(creds);
            Exchanges[CryptoExch.BITTREX] = bittrex;

            creds = m_security.ApiKeys["GDAX"];                             // GDAX
            gdax  = GDAX.Create(creds, "mickey+mouse");
            Exchanges[CryptoExch.GDAX] = gdax;

            creds  = m_security.ApiKeys["HITBTC"];                          // HITBTC
            hitbtc = HitBTC.Create(creds);
            Exchanges[CryptoExch.HITBTC] = hitbtc;

            creds = m_security.ApiKeys["ITBIT"];                            // ITBIT
            itbit = ItBit.Create(creds);
            Exchanges[CryptoExch.ITBIT] = itbit;

            creds  = m_security.ApiKeys["KRAKEN"];                          // KRAKEN
            kraken = Kraken.Create(creds);
            Exchanges[CryptoExch.KRAKEN] = kraken;

            creds    = m_security.ApiKeys["POLONIEX"];                      // POLONIEX
            poloniex = Poloniex.Create(creds);
            Exchanges[CryptoExch.POLONIEX] = poloniex;

            /*creds = m_security.ApiKeys["BLEUTRADE"];                        // BLEUTRADE
             * bleutrade = Bleutrade.Create(creds);
             * Exchanges[CryptoExch.BLEUTRADE] = bleutrade;
             *
             * creds = m_security.ApiKeys["BLINKTRADE"];                       // BLINKTRADE
             * blinktrade = BlinkTrade.Create(creds);
             * Exchanges[CryptoExch.BLINKTRADE] = blinktrade;*/

            gemini = Gemini.Instance;
            Exchanges[CryptoExch.GEMINI] = Gemini.Instance;

            // For each exchange, subscribe to the various events
            foreach (var exchange in Exchanges.Values)
            {
                exchange.UpdateOrderBookEvent += Exchanges_UpdateOrderBookEvent;
                exchange.UpdateOrdersEvent    += Exchanges_UpdateOrdersEvent;
                exchange.UpdateTickerEvent    += Exchanges_UpdateTickerEvent;

                /*var ws = exchange as IExchangeWebSocket;
                 * if (ws != null)
                 *  ws.StartWebSocket(null);*/
            }

            /*Exchanges[CryptoExch.VAULTORO] = Vaultoro.Instance;
             * Exchanges[CryptoExch.CHANGELLY] = Changelly.Instance;
             * Exchanges[CryptoExch.BITHUMB] = Bithumb.Instance;
             * Exchanges[CryptoExch.BITMEX] = BitMEX.Instance;
             * Exchanges[CryptoExch.BITSQUARE] = Bitsquare.Instance;
             * Exchanges[CryptoExch.BTCC] = BTCC.Instance;
             * //Exchanges[CryptoExch.BTER] = BTER.Instance;
             * Exchanges[CryptoExch.CEX] = Cex.Instance;
             * //Exchanges[CryptoExch.COINIGY] = Coinigy.Instance;
             * Exchanges[CryptoExch.COINONE] = Coinone.Instance;
             * Exchanges[CryptoExch.GATEIO] = GateIO.Instance;
             * Exchanges[CryptoExch.HUOBI] = Huobi.Instance;
             * Exchanges[CryptoExch.KORBIT] = Korbit.Instance;
             * Exchanges[CryptoExch.KUCOIN] = Kucoin.Instance;
             * Exchanges[CryptoExch.OKCOIN] = OkCoin.Instance;
             * Exchanges[CryptoExch.OKEX] = OKEx.Instance;
             * Exchanges[CryptoExch.WEX] = Wex.Instance;
             * Exchanges[CryptoExch.XCRYPTO] = XCrypto.Instance;*/
        }