Beispiel #1
0
        public void GetBalance_ShouldNotThrowException()
        {
            var         bittrex = new Bittrex(DefaultApiKey, DefaultApiSecret);
            Func <Task> action  = async() => { var _ = await bittrex.GetBalance(DefaultCurrency); };

            action.ShouldNotThrow();
        }
Beispiel #2
0
        public void BuyLimit_ShouldUnauthorizedThrowException_IfNoApiKeyIsGiven()
        {
            var         bittrex = new Bittrex();
            Func <Task> action  = async() => { var _ = await bittrex.BuyLimit(DefaultMarketName, 1, 1); };

            action.ShouldThrow <UnauthorizedException>();
        }
Beispiel #3
0
 public BittrexStock()
 {
     if (bittrex == null)
     {
         bittrex = new Bittrex();
     }
 }
        public void GetTickerv2_ShouldNotThrowException()
        {
            var         bittrex = new Bittrex();
            Func <Task> action  = async() => { var _ = await bittrex.GetTicker(DefaultMarketName, tickInterval, timeStamp); };

            action.ShouldNotThrow();
        }
Beispiel #5
0
        public BittrexBridge(string apiKey, string apiSecret)
        {
            apiKeyStore      = apiKey;
            ActiveOrders     = new List <BittrexSharp.Domain.OpenOrder>();
            OnHoldOrders     = new List <BittrexSharp.Domain.OpenOrder>();
            cancelling       = new List <string>();
            fFailedConection = fConnected = false;

            account = new Bittrex(apiKey, apiSecret); //TODO: Modify library so it uses securestring when handling apiSecret
            //TODO: Maybe change this task so it can use the "testConnection" method
            Task.Run(async() =>
            {
                var response = await account.GetBalances();

                if (!fFailedConection)
                {
                    fFailedConection = !response.Success;
                }

                if (fFailedConection)
                {
                    return;
                }

                fConnected = true;
            });
        }
Beispiel #6
0
        public void BuyLimit_ShouldNotThrowException()
        {
            var         bittrex = new Bittrex(DefaultApiKey, DefaultApiSecret);
            Func <Task> action  = async() => { var _ = await bittrex.BuyLimit(DefaultMarketName, 1, 1); };

            action.ShouldNotThrow();
        }
Beispiel #7
0
        public void GetOrderBook_ShouldNotThrowException()
        {
            var         bittrex = new Bittrex();
            Func <Task> action  = async() => { var _ = await bittrex.GetOrderBook(DefaultMarketName, OrderType.Both, 1); };

            action.ShouldNotThrow();
        }
Beispiel #8
0
        public void GetDepositAddress_ShouldUnauthorizedThrowException_IfNoApiKeyIsGiven()
        {
            var         bittrex = new Bittrex();
            Func <Task> action  = async() => { var _ = await bittrex.GetDepositAddress(DefaultCurrency); };

            action.ShouldThrow <UnauthorizedException>();
        }
Beispiel #9
0
        public void Withdraw_ShouldUnauthorizedThrowException_IfNoApiKeyIsGiven()
        {
            var         bittrex = new Bittrex();
            Func <Task> action  = async() => { var _ = await bittrex.Withdraw(DefaultCurrency, 0, DefaultTargetAddress); };

            action.ShouldThrow <UnauthorizedException>();
        }
Beispiel #10
0
        public void GetDepositHistory_ShouldNotThrowException()
        {
            var         bittrex = new Bittrex(DefaultApiKey, DefaultApiSecret);
            Func <Task> action  = async() => { var _ = await bittrex.GetDepositHistory(); };

            action.ShouldNotThrow();
        }
Beispiel #11
0
        public void Withdraw_ShouldNotThrowException()
        {
            var         bittrex = new Bittrex(DefaultApiKey, DefaultApiSecret);
            Func <Task> action  = async() => { var _ = await bittrex.Withdraw(DefaultCurrency, 0, DefaultTargetAddress); };

            action.ShouldNotThrow();
        }
Beispiel #12
0
        public void GetOpenOrders_ShouldNotThrowException()
        {
            var         bittrex = new Bittrex(DefaultApiKey, DefaultApiSecret);
            Func <Task> action  = async() => { var _ = await bittrex.GetOpenOrders(); };

            action.ShouldNotThrow();
        }
Beispiel #13
0
        public void GetDepositHistory_ShouldUnauthorizedThrowException_IfNoApiKeyIsGiven()
        {
            var         bittrex = new Bittrex();
            Func <Task> action  = async() => { var _ = await bittrex.GetDepositHistory(); };

            action.ShouldThrow <UnauthorizedException>();
        }
Beispiel #14
0
        public void GetSupportedCurrencies_ShouldNotThrowException()
        {
            var         bittrex = new Bittrex();
            Func <Task> action  = async() => { var _ = await bittrex.GetSupportedCurrencies(); };

            action.ShouldNotThrow();
        }
Beispiel #15
0
        public void GetMarketSummaries_ShouldNotThrowException()
        {
            var         bittrex = new Bittrex();
            Func <Task> action  = async() => { var _ = await bittrex.GetMarketSummaries(); };

            action.ShouldNotThrow();
        }
Beispiel #16
0
        public void GetMarketHistory_ShouldNotThrowException()
        {
            var         bittrex = new Bittrex();
            Func <Task> action  = async() => { var _ = await bittrex.GetMarketHistory(DefaultMarketName); };

            action.ShouldNotThrow();
        }
Beispiel #17
0
        public void GetOrder_ShouldNotThrowException()
        {
            var         orderId = Guid.NewGuid().ToString();
            var         bittrex = new Bittrex(DefaultApiKey, DefaultApiSecret);
            Func <Task> action  = async() => { var _ = await bittrex.GetOrder(orderId); };

            action.ShouldNotThrow();
        }
Beispiel #18
0
        public void GetOrder_ShouldUnauthorizedThrowException_IfNoApiKeyIsGiven()
        {
            var         orderId = Guid.NewGuid().ToString();
            var         bittrex = new Bittrex();
            Func <Task> action  = async() => { var _ = await bittrex.GetOrder(orderId); };

            action.ShouldThrow <UnauthorizedException>();
        }
Beispiel #19
0
        public static async Task <bool> testConnection(string apiKey, string apiSecret)
        {
            Bittrex TempAccount = new Bittrex(apiKey, apiSecret);
            var     response    = await TempAccount.GetBalances();

            TempAccount = null;
            return(response.Success);
        }
Beispiel #20
0
        private async Task <ResponseWrapper <IEnumerable <MarketSummary> > > GetMarketSummaries()
        {
            Bittrex bittrex = new Bittrex();
            var     uri     = BaseUrl + "public/getmarketsummaries";
            var     marketSummariesResponse = await bittrex.Request <IEnumerable <MarketSummary> >(HttpMethod.Get, uri);

            return(marketSummariesResponse);
        }
Beispiel #21
0
        public async void MarketHistoryInvalidOnline()
        {
            var r   = new Maybe <IDownloadData>();
            var b   = new Bittrex(r);
            var res = await b.GetMarketHistory("NotValid");

            Assert.Equal("INVALID_MARKET", res.Message);
        }
Beispiel #22
0
 /// <summary>
 ///     Constructor
 /// </summary>
 public My_Bittrex()
 {
     // Connection to bittrex
     this.api_key        = "<your_api_key>";
     this.api_secret     = "<your_api_secret>";
     this.my_bittrex     = new Bittrex(this.api_key, this.api_secret);
     this.my_balances    = new Dictionary <string, double>();
     this.portfolio_size = this.my_balances.Count;
 }
Beispiel #23
0
        public async void OrderbookBothOnline()
        {
            var r   = new Maybe <IDownloadData>();
            var b   = new Bittrex(r);
            var res = await b.GetOrderbook("BTC-LTC", "both");

            Assert.NotEmpty(res.Result.buy);
            Assert.NotEmpty(res.Result.sell);
        }
Beispiel #24
0
        private static async Task <ResponseWrapper <IEnumerable <Market> > > GetBittrixMarketAsync()
        {
            Console.WriteLine("before");  // Step Out from here
            var apiKey    = "b6261f5e794f4c5fb0fcd8ede10eaea8";
            var apiSecret = "7c8e55b4d0b245779e4d645f7a5bc92f";
            var bittrex   = new Bittrex(apiKey, apiSecret);
            var result    = await bittrex.GetMarkets();

            Console.WriteLine("after");  // Step Out from here
            return(result);
        }
Beispiel #25
0
        public BittrexService(
            BittrexConfig config,
            DatabaseService databaseService,
            PriceService priceService,
            ILogger <BittrexService> log)
        {
            var config1 = config;

            _databaseService = databaseService;
            _priceService    = priceService;
            _log             = log;

            _exchange = new Bittrex(config1.Key, config1.Secret);
        }
Beispiel #26
0
        public void Restart()
        {
            string apiKey = AppSetings.Default.BittrexApiKey;

            if (apiKey.Length > 0)
            {
                bittrex = new Bittrex(apiKey,
                                      Security.ToInsecureString(Security.DecryptString(AppSetings.Default.BittrexApiSecret)));
            }
            else
            {
                bittrex = new Bittrex("", "");
            }
        }
Beispiel #27
0
        public BittrexService(
            BittrexConfig config,
            DatabaseService databaseService,
            GeneralConfig generalConfig,
            ILogger <BittrexService> log)
        {
            var config1 = config;

            _databaseService = databaseService;
            _generalConfig   = generalConfig;
            _log             = log;

            _exchange = new Bittrex(config1.Key, config1.Secret);
        }
Beispiel #28
0
        private static async Task <ResponseWrapper <IEnumerable <TickerV2> > > GetBittrixTickerDataAsync()
        {
            Console.WriteLine("before");  // Step Out from here
            var apiKey    = "b6261f5e794f4c5fb0fcd8ede10eaea8";
            var apiSecret = "7c8e55b4d0b245779e4d645f7a5bc92f";
            var bittrex   = new Bittrex(apiKey, apiSecret);


            string DefaultMarketName = "BTC-ETH";
            string tickInterval      = "thirtyMin";
            UInt64 timeStamp         = 1500915289433;

            var result = await bittrex.GetTicker(DefaultMarketName, tickInterval, timeStamp);

            Console.WriteLine("after");  // Step Out from here
            return(result);
        }
Beispiel #29
0
        public static async Task Main()
        {
            // Our apiKey and apiSecret variables
            const string apiKey    = "";
            const string apiSecret = "";

            // Set up the three clients: one for the operations (such as buy/sell), one to calculate the margins and one for the CoinMarketCap data
            var bittrexClient     = new Bittrex(apiKey, apiSecret);
            var calculationClient = new CalculationClient(bittrexClient);

            // Load the user config file
            var userConfig = bittrexClient.LoadConfig();

            foreach (var item in userConfig.Result)
            {
                await calculationClient.CalculateToDollar(item.CoinName, item.Amount).ConfigureAwait(false);
            }
        }
Beispiel #30
0
        public async Task <decimal> GetPrice(string baseCcy, string termsCurrency)
        {
            var apiKey    = "...";
            var apiSecret = "...";
            var bittrex   = new Bittrex(apiKey, apiSecret);

            Ticker tcik = null;

            try
            {
                tcik = await bittrex.GetTicker(baseCcy, termsCurrency);
            }
            catch (Exception ex)
            {
                // should log
            }

            if (tcik != null && tcik.Last.HasValue)
            {
                return(tcik.Last.Value);
            }

            var btcPrice = await bittrex.GetTicker("BTC", termsCurrency);

            if (btcPrice?.Last != null)
            {
                var btcBasePrice = await bittrex.GetTicker("BTC", baseCcy);

                if (btcBasePrice?.Last != null)
                {
                    return(btcPrice.Last.Value * btcBasePrice.Last.Value);
                }
                else
                {
                    var baseBtcPrice = await bittrex.GetTicker(baseCcy, "BTC");

                    if (baseBtcPrice?.Last != null)
                    {
                        return(baseBtcPrice.Last.Value * btcPrice.Last.Value);
                    }
                }
            }
            return(0);
        }