示例#1
0
        public ApiResult <BittrexPrice> Ticker(string market)
        {
            using (ApiClient = new BittrexClient())
            {
                BittrexApiResult <BittrexPrice> ticker = ApiClient.GetTicker(market);

                return(Return(ticker));
            }
        }
示例#2
0
        public static void AddCancelOrderCommand(this CommandLineApplication app)
        {
            app.Command("cancel-order", cmd =>
            {
                cmd.Description = "Get current open orders for your account.";
                cmd.HelpOption("-?|-h|--help");

                var orderArgument = cmd.Argument("[order]", "Order Id");

                cmd.OnExecute(async() =>
                {
                    Bittrex.Net.BittrexDefaults.SetDefaultApiCredentials(Program.ApiKey.Value(), Program.ApiSecret.Value());
                    var inputOrderUuid = orderArgument.Value ?? "INVALID";
                    if (!Guid.TryParse(inputOrderUuid, out var orderUuid))
                    {
                        Console.WriteLine($"{inputOrderUuid} can't be parsed as Guid.");
                        return(-1);
                    }

                    Console.WriteLine($"Getting order {orderUuid}");
                    var client = new BittrexClient();
                    var order  = await client.GetOrderAsync(orderUuid);

                    if (!order.Success)
                    {
                        Console.WriteLine("Something happend while trying to get the order ...");
                        Console.WriteLine(order.Error.ErrorMessage);
                        return(-1);
                    }

                    var currentOrder = order.Result;
                    Console.WriteLine($"Canceling order {orderUuid}...");
                    var cancelOrder = await client.CancelOrderAsync(orderUuid);

                    if (!cancelOrder.Success)
                    {
                        Console.WriteLine("Something happend while trying to cancel the order ...");
                        Console.WriteLine(cancelOrder.Error.ErrorMessage);
                        return(-1);
                    }

                    Console.WriteLine("Order cancelled ...");

                    var orders = await client.GetOpenOrdersAsync();
                    if (!orders.Success)
                    {
                        Console.WriteLine("Something happend while trying to get the orders ...");
                        Console.WriteLine(orders.Error.ErrorMessage);
                        return(-1);
                    }
                    orders.Result.PrintOrders();

                    return(0);
                });
            });
        }
示例#3
0
 /// <summary>
 ///  交易所賣出
 /// </summary>
 /// <param name="highestBid">(賣價)最高資訊</param>
 /// <param name="MinQuantity">數量</param>
 /// <returns></returns>
 internal ExchangeApiData PlaceOrderBid(ExchangeData highestBid, decimal MinQuantity)
 {
     using (var client = new BittrexClient(highestBid.APIKey, highestBid.Secret))
     {
         var placedOrder = client.PlaceOrder(OrderType.Sell, highestBid.ExchangeType, MinQuantity, highestBid.Ask);
         return(new ExchangeApiData {
             Stace = placedOrder.Success, Msg = placedOrder.Error.ErrorMessage
         });
     }
 }
示例#4
0
        static async Task BittrexWriteSymbolsCsv(BittrexClient exch)
        {
            string exchName   = "BITTREX";
            var    resSymbols = await exch.GetSymbolsAsync();

            var symbols = resSymbols.Data;

            Console.WriteLine($"[{exchName}]   {symbols.Count()} symbols");
            WriteObjectsToCsv(symbols, SymbolFilepath(exchName));
        }
示例#5
0
 /// <summary>
 /// 交易所買進
 /// </summary>
 /// <param name="lowestAsk">(買價)最低資訊</param>
 /// <param name="MinQuantity">數量</param>
 /// <returns></returns>
 internal ExchangeApiData PlaceOrderAsk(ExchangeData lowestAsk, decimal MinQuantity)
 {
     using (var client = new BittrexClient(lowestAsk.APIKey, lowestAsk.Secret))
     {
         var placedOrder = client.PlaceOrder(OrderType.Buy, lowestAsk.ExchangeType, MinQuantity, lowestAsk.Ask);
         return(new ExchangeApiData {
             Stace = placedOrder.Success, Msg = placedOrder.Error.ErrorMessage
         });
     }
 }
示例#6
0
        static async Task GetMarketHistory(BittrexClient client)
        {
            var result = await client.GetMarketHistory("BTC-ADA")
                         .ConfigureAwait(false);

            foreach (var item in result.Result)
            {
                await Console.Out.WriteLineAsync($"Id: {item.Id}, TimeStamp: {item.TimeStamp.ToString()}, Quantity: {item.Quantity}, Price: {item.Price}, Total: {item.Total}, Fill type: {item.FillType}")
                .ConfigureAwait(false);
            }
        }
示例#7
0
        static async Task GetMarkets(BittrexClient client)
        {
            var result = await client.GetMarkets()
                         .ConfigureAwait(false);

            foreach (var item in result.Result)
            {
                await Console.Out.WriteLineAsync($"Market: {item.MarketName}, Base currency: {item.BaseCurrency}, Market currency: {item.MarketCurrency}")
                .ConfigureAwait(false);
            }
        }
示例#8
0
        static async Task GetCurrencies(BittrexClient client)
        {
            var result = await client.GetCurrencies()
                         .ConfigureAwait(false);

            foreach (var item in result.Result)
            {
                await Console.Out.WriteLineAsync($"Currency: {item.Currency}, Currency Long: {item.CurrencyLong}, Tx fee: {item.TxFee}")
                .ConfigureAwait(false);
            }
        }
        public BittrexClient GetBittrexClient()
        {
            var exchange  = "BITTREX";
            var apiKey    = m_creds[exchange].Key;
            var apiSecret = m_creds[exchange].Secret;
            var options   = new BittrexClientOptions();

            options.ApiCredentials = new CryptoExchange.Net.Authentication.ApiCredentials(apiKey, apiSecret);
            var client = new BittrexClient(options);

            return(client);
        }
        public void Clear()
        {
            BittrexClientOptions lClientOptions = new Bittrex.Net.Objects.BittrexClientOptions {
                ApiCredentials = null
            };
            BittrexSocketClientOptions lSocketOptions = new Bittrex.Net.Objects.BittrexSocketClientOptions {
                ApiCredentials = null
            };

            BittrexClient.SetDefaultOptions(lClientOptions);
            BittrexSocketClient.SetDefaultOptions(lSocketOptions);
            IsCredentialsSet = false;
        }
示例#11
0
        public void UpdateKeyData(ApiKeyData keyData)
        {
            if (string.IsNullOrWhiteSpace(keyData.GetRawApiKey()))
            {
                IsConfigured = false;
                return;
            }

            _apiKey = keyData;
            _client = new BittrexClient(
                _apiKey.GetRawApiKey(),
                _apiKey.GetRawApiSecret());
        }
示例#12
0
    static async Task Main()
    {
        var client = new BittrexClient("key", "secret");

        var result = await client.GetMarkets()
                     .ConfigureAwait(false);

        foreach (var market in result.Result)
        {
            await Console.Out.WriteLineAsync(market.MarketName)
            .ConfigureAwait(false);
        }
    }
示例#13
0
        private void LoadDone(object sender, EventArgs e)
        {
            socketClient = new BittrexSocketClient();
            socketClient.SubscribeToSymbolTickerUpdatesAsync("ETH-BTC", data =>
            {
                UpdateLastPrice(data.LastTradeRate);
            });

            using (var client = new BittrexClient())
            {
                var result = client.GetTicker("ETH-BTC");
                UpdateLastPrice(result.Data.LastTradeRate);
            }
        }
示例#14
0
        private async Task <BittrexPrice> GetTicker(string baseCcy, string termsCurrency)
        {
            using (var client = new BittrexClient(_config.Key, _config.Secret))
            {
                var response = await client.GetTickerAsync($"{baseCcy}-{termsCurrency}");

                if (response.Success)
                {
                    return(response.Result);
                }

                _log.LogWarning($"Bittrex returned an error {response.Error.ErrorCode} : {response.Error.ErrorMessage}");
                return(null);
            }
        }
示例#15
0
        static void CreateBittrexExchange(out BittrexClient exch, out BittrexSocketClient sock)
        {
            var evKeys = Environment.GetEnvironmentVariable("BITTREX_KEY", EnvironmentVariableTarget.User);
            var keys   = evKeys.Split('|');

            var clientOptions = new BittrexClientOptions();

            clientOptions.ApiCredentials = new ApiCredentials(keys[0], keys[1]);
            exch = new BittrexClient(clientOptions);
            //----------
            var socketOptions = new BittrexSocketClientOptions();

            socketOptions.ApiCredentials = clientOptions.ApiCredentials;
            sock = new BittrexSocketClient(socketOptions);
        }
 public string GetMBC_USDCoin()//Litecoin 104
 {
     try
     {
         BittrexClient bitt = new BittrexClient(bittrexbase_address, bittrexapi_key, bittrexsecert_key);
         var           a    = bitt.Getticker("USDT-LTC");//USDT-LTC
         dynamic       d    = JObject.Parse(a);
         var           a1   = d.result.Bid;
         var           last = d.result.Last;
         return(last);
     }
     catch (Exception es)
     {
         throw es;
     }
 }
 public string ETCCurrentPrice()// Etherum 105
 {
     try
     {
         BittrexClient bitt = new BittrexClient(bittrexbase_address, bittrexapi_key, bittrexsecert_key);
         var           c    = bitt.Getticker("USDT-ETC");
         dynamic       d4   = JObject.Parse(c);
         var           c3   = d4.result.Bid;
         var           etc  = d4.result.Last;
         return(etc);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
 public string LTCCurrentPrice()// Bitcoin Gold 103
 {
     try
     {
         BittrexClient bitt = new BittrexClient(bittrexbase_address, bittrexapi_key, bittrexsecert_key);
         var           c    = bitt.Getticker("USDT-LTC");
         dynamic       d3   = JObject.Parse(c);
         var           c2   = d3.result.Bid;
         var           ltc  = d3.result.Last;
         return(ltc);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
 public string DASHCurrentPrice()//bitcoinCash 102
 {
     try
     {
         BittrexClient bitt = new BittrexClient(bittrexbase_address, bittrexapi_key, bittrexsecert_key);
         var           c    = bitt.Getticker("USDT-DASH");
         dynamic       d2   = JObject.Parse(c);
         var           c1   = d2.result.Bid;
         var           dash = d2.result.Last;
         return(dash);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
 public string ETHCurrentPrice()//Etherum Classic 106
 {
     try
     {
         BittrexClient bitt = new BittrexClient(bittrexbase_address, bittrexapi_key, bittrexsecert_key);
         var           b    = bitt.Getticker("USDT-ETH");
         dynamic       d1   = JObject.Parse(b);
         var           b1   = d1.result.Bid;
         var           last = d1.result.Last;
         return(last);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
        //public BittrexExchange(KafkaProducer p)
        public BittrexExchange(string bootstrapServers, string topic)
        {
            var evKeys = Environment.GetEnvironmentVariable(ApiKeyEnvVar, EnvironmentVariableTarget.User);
            var keys = evKeys.Split('|');

            var clientOptions = new BittrexClientOptions();
            clientOptions.ApiCredentials = new ApiCredentials(keys[0], keys[1]);
            this.exch = new BittrexClient(clientOptions);
            //----------
            var socketOptions = new BittrexSocketClientOptions();
            socketOptions.ApiCredentials = clientOptions.ApiCredentials;
            this.sock = new BittrexSocketClient(socketOptions);

            //_p = p;
            _p = new KafkaProducer(bootstrapServers, topic);
        }
示例#22
0
        public void UpdateMarketSummary()
        {
            if (_apiKey == null || !IsConfigured)
            {
                return;
            }

            if (_client == null)
            {
                _client = new BittrexClient(
                    _apiKey.GetRawApiKey(),
                    _apiKey.GetRawApiSecret());
            }

            _summaries = Task.Run(() => _client.GetMarketSummaries()).Result;
        }
示例#23
0
        public async Task <bool> GetCurrencies()
        {
            using (var client = new BittrexClient())
            {
                Currencies = await client.GetCurrenciesAsync();

                if (Currencies.Success)
                {
                    AddLog("Pavyko gauti valiutų sąrašą", "", Color.Green);
                }
                else
                {
                    AddLog("Nepavyko gauti valiutų sąrašo", Currencies.Error.ErrorMessage, Color.Red);
                }
                return(Currencies.Success ? true : false);
            }
        }
示例#24
0
        public void Init()
        {
            BittrexClient.SetDefaultOptions(new BittrexClientOptions()
            {
                ApiCredentials = new ApiCredentials(_settings.Bittrex.Key, _settings.Bittrex.Secret),
                LogVerbosity   = LogVerbosity.Info,
                LogWriters     = new List <TextWriter>()
                {
                    Console.Out
                }
            });

            _httpClient   = new BittrexClient();
            _socketClient = new BittrexSocketClient();

            _placeOrderWorker.Start();
        }
示例#25
0
        static void Main(string[] args)
        {
            BittrexClient.SetDefaultOptions(new BittrexClientOptions()
            {
                ApiCredentials = new ApiCredentials("APIKEY", "APISECRET"),
                LogVerbosity   = LogVerbosity.Info,
                LogWriter      = Console.Out
            });

            using (var client = new BittrexClient())
            {
                // public
                var markets         = client.GetMarkets();
                var currencies      = client.GetCurrencies();
                var price           = client.GetTicker("BTC-ETH");
                var marketSummary   = client.GetMarketSummary("BTC-ETH");
                var marketSummaries = client.GetMarketSummaries();
                var orderbook       = client.GetOrderBook("BTC-ETH");
                var marketHistory   = client.GetMarketHistory("BTC-ETH");

                // private
                var placedOrder   = client.PlaceOrder(OrderSide.Sell, "BTC-NEO", 1, 1);
                var openOrders    = client.GetOpenOrders("BTC-NEO");
                var orderInfo     = client.GetOrder(placedOrder.Data.Uuid);
                var canceledOrder = client.CancelOrder(placedOrder.Data.Uuid);
                var orderHistory  = client.GetOrderHistory("BTC-NEO");

                var balance         = client.GetBalance("NEO");
                var balances        = client.GetBalances();
                var depositAddress  = client.GetDepositAddress("BTC");
                var withdraw        = client.Withdraw("TEST", 1, "TEST", "TEST");
                var withdrawHistory = client.GetWithdrawalHistory();
                var depositHistory  = client.GetDepositHistory();
            }

            // Websocket
            var socketClient = new BittrexSocketClient();
            var subcribtion  = socketClient.SubscribeToMarketDeltaStream("BTC-ETH", summary =>
            {
                Console.WriteLine($"BTC-ETH: {summary.Last}");
            });

            Console.ReadLine();
            socketClient.UnsubscribeFromStream(subcribtion.Data);
        }
        private void GetCurrencyRelatedData()
        {
            using (BittrexClient lClient = new BittrexClient())
            {
                CallResult <IEnumerable <BittrexCurrency> > lResponse = lClient.GetCurrenciesAsync().Result;

                if (!lResponse.Success)
                {
                    throw new Exception("Failed to retrieve balance");
                }

                foreach (BittrexCurrency lCurrency in lResponse.Data)
                {
                    FCurrencyFees[lCurrency.Symbol]          = lCurrency.TransactionFee;
                    FCurrencyConfirmations[lCurrency.Symbol] = lCurrency.MinConfirmations + 1;
                }
            }
        }
示例#27
0
        private async Task <BittrexPrice> GetTicker(string baseCcy, string termsCurrency)
        {
            using (var client = new BittrexClient(new BittrexClientOptions()
            {
                ApiCredentials = new ApiCredentials(_config.Key, _config.Secret)
            }))
            {
                var response = await client.GetTickerAsync($"{baseCcy}-{termsCurrency}");

                if (response.Success)
                {
                    return(response.Data);
                }

                _log.LogWarning($"Bittrex returned an error {response.Error.Code} : {response.Error.Message}");
                return(null);
            }
        }
示例#28
0
        private void LoadDone(object sender, EventArgs e)
        {
            socketClient = new BittrexSocketClient();
            socketClient.SubscribeToMarketSummariesUpdate(data =>
            {
                var eth = data.SingleOrDefault(d => d.MarketName == "BTC-ETH");
                if (eth != null)
                {
                    UpdateLastPrice(eth.Last);
                }
            });

            using (var client = new BittrexClient())
            {
                var result = client.GetMarketSummary("BTC-ETH");
                UpdateLastPrice(result.Data.Last);
                label2.Invoke(new Action(() => { label2.Text = "BTC-ETH Volume: " + result.Data.Volume; }));
            }
        }
        private async Task DoUpdateMarketCoins()
        {
            if (FLastMarketCoinsRetrieval == DateTime.MinValue || FLastMarketCoinsRetrieval < DateTime.UtcNow.AddHours(-12))
            {
                using (BittrexClient lClient = new BittrexClient())
                {
                    var lResponse = await lClient.GetSymbolsAsync();

                    if (!lResponse.Success)
                    {
                        throw new Exception("Failed to retrieve Markets");
                    }

                    FMarkets = lResponse.Data.ToArray();
                    FLastMarketCoinsRetrieval = DateTime.UtcNow;
                }
                FLocalCacheOfMarkets.Clear();
            }
        }
        public static void InitializeApi(string encryptedCredentialsFile, string password)
        {
            m_creds = Credentials.LoadEncryptedJson(encryptedCredentialsFile, password);
            var cred = m_creds["BITTREX"];

            m_api = new BittrexApi(cred.Key, cred.Secret);

            BittrexClientOptions options = new BittrexClientOptions();

            options.ApiCredentials = new CryptoExchange.Net.Authentication.ApiCredentials(cred.Key, cred.Secret);
            m_client = new BittrexClient(options);

            //m_api.Test();
            //PrintAllBalances();
            //Ping(new string[] { "api.binance.com" });
            //Rebalance();

            //m_api.StartUserDataStream();
        }