public Response PriceCheck(Request request, ILambdaContext context) { var message = new StringBuilder(); context.Logger.LogLine($"{context.FunctionName} execution started"); context.Logger.LogLine(context.LogGroupName); context.Logger.LogLine(context.LogStreamName); var coins = AppConfig.Instance.GetParameter("CoinsToWatch").Split(','); var priceList = new Dictionary <string, double>(); foreach (var c in coins) { priceList.Add(c, CryptoCompare.GetCurrentCryptoPrice(c)); } message.AppendLine("```"); message.AppendLine("=== Crypto-PriceWatch ==="); foreach (var p in priceList) { message.AppendLine($"{p.Key} : {p.Value}"); } message.AppendLine("========================="); message.AppendLine("```"); SlackHookHelper.SendSlackNotification(message.ToString()); return(new Response { Message = message.ToString() }); }
public async Task HandlerAsync(FastSell command) { await _transactionService.FastSellTransactionAsync(command.FromCurrency, command.Amount, command.UserId); var price = await CryptoCompare.GetCryptoPriceInUsd(command.FromCurrency); await _historyService.AddAsync(OperationType.Sell, command.FromCurrency, command.Amount, price, command.UserId); }
public void WhenIMakeACallForPricingForEthInUSD_ThenIShouldGetBackPricing() { var testClass = new CryptoCompare(); var response = testClass.GetGetPrice("ETH", "USD"); Assert.NotNull(response); Assert.NotNull(response.Data); Assert.NotNull(response.Data.First().Price); }
public void WhenIMakeCallToGetTheCoinList_ThenIshouldBeSuccessful() { var testClass = new CryptoCompare(); var response = testClass.GetCoinList(); Assert.NotNull(response.Data.BTC); Assert.NotNull(response.Data.DSH); Assert.NotNull(response.Data.ETH); Assert.NotNull(response.Data.LTC); Assert.NotNull(response.Data.ZEC); }
public async void HistoHourOnline() { var cc = new CryptoCompare(new Maybe <IDownloadData>()); var res = await cc.HistoHour("ETH", "BTC", emptyStringMaybe, emptyIntMaybe, emptyIntMaybe, emptyIntMaybe); Assert.Equal("Success", res.Response); Assert.NotEmpty(res.Data); }
private async void Page_Loaded(object sender, RoutedEventArgs e) { vm.Categories = await CryptoCompare.GetNewsCategories(); _acv = new AdvancedCollectionView(vm.Categories, false); _acv.SortDescriptions.Add(new SortDescription(nameof(NewsCategories.categoryName), SortDirection.Ascending)); _ttb = CategoriesTokenBox; _acv.Filter = item => !_ttb.Items.Contains(item) && (item as NewsCategories).categoryName.Contains(_ttb.Text, StringComparison.CurrentCultureIgnoreCase); _ttb.SuggestedItemsSource = _acv; await UpdatePage(); }
private static void PrintRatesBtc() { var cryptoCurrencies = new CryptoCompare(); var coinList = cryptoCurrencies.GetCoinList(); var pricing = new List <string> { $"{DateTime.Now}", $"{coinList.Data.BTC.Name} : {cryptoCurrencies.GetGetPrice(coinList.Data.BTC.Name, Constants.Btc).Data.First().Price}", $"{coinList.Data.DSH.Name} : {cryptoCurrencies.GetGetPrice(coinList.Data.DSH.Name, Constants.Btc).Data.First().Price}", $"{coinList.Data.ETH.Name} : {cryptoCurrencies.GetGetPrice(coinList.Data.ETH.Name, Constants.Btc).Data.First().Price}", $"{coinList.Data.LTC.Name} : {cryptoCurrencies.GetGetPrice(coinList.Data.LTC.Name, Constants.Btc).Data.First().Price}", $"{coinList.Data.ZEC.Name} : {cryptoCurrencies.GetGetPrice(coinList.Data.ZEC.Name, Constants.Btc).Data.First().Price}" }; WriteToFile(pricing, "pricingBtc.txt"); }
public async void HistoHourWithParametersOnline() { var cc = new CryptoCompare(new Maybe <IDownloadData>()); var res = await cc.HistoHour( "ETH", "BTC", new Maybe <string>("Kraken"), new Maybe <int>(2), new Maybe <int>(10), emptyIntMaybe); Assert.Equal("Success", res.Response); Assert.NotEmpty(res.Data); Assert.True(res.Aggregated); }
public IActionResult Index() { try { var results = new CryptoCompare().GetInvestments(_settings.Value); return(View(new IndexViewModel(results))); } catch (Exception ex) { while (ex.InnerException != null) { ex = ex.InnerException; } return(View("Error", new ErrorViewModel(ex))); } }
public async Task FastSellTransactionAsync(string fromCurrnecy, decimal amount, Guid userId) { var wallet = await _walletRepository.GetByUserIdAsync(userId); var price = await CryptoCompare.GetCryptoPriceInUsd(fromCurrnecy); var fromWallet = wallet.Where(x => x.Currency == fromCurrnecy && (x.AmountOfMoney - amount) >= 0).SingleOrDefault(); var toWallet = wallet.Where(x => x.Currency == "USD").SingleOrDefault(); if (fromWallet == null || toWallet == null) { throw new Exception("Wallet is not exists"); } fromWallet.SetAmountOfMoney(fromWallet.AmountOfMoney - amount); toWallet.SetAmountOfMoney(toWallet.AmountOfMoney + amount * price); await _walletRepository.UpdateAsync(fromWallet); await _walletRepository.UpdateAsync(toWallet); }
private void TwEX_FormEditor_Load(object sender, EventArgs e) { if (System.Deployment.Application.ApplicationDeployment.IsNetworkDeployed) { System.Deployment.Application.ApplicationDeployment cd = System.Deployment.Application.ApplicationDeployment.CurrentDeployment; string publishVersion = cd.CurrentVersion.ToString(); Text = "TwEX Trader : Short Armed Trading Tools Version " + publishVersion; } else { Text = "TwEX Trader : Short Armed Trading Tools"; } FormPreference preference = FormPreferences.FirstOrDefault(item => item.Name == Name); if (preference != null) { //LogManager.AddLogMessage(Name, "toolStripButton_Form_Click", "FOUND : " + preference.Name + " | " + preference.Font.FontFamily + " | " + preference.Size + " | " + preference.Location); SetBounds(preference.Location.X, preference.Location.Y, preference.Size.Width, preference.Size.Height); Font = new Font(preference.Font.FontFamily, preference.Font.Size, preference.Font.Style); } else { //LogManager.AddLogMessage(Name, "toolStripButton_Form_Click", "NOT FOUND ADDING : " + form.Name + " | " + form.Location); UpdateFormPreferences(this, true); } LocationChanged += delegate { UpdateFormPreferences(this, true); }; SizeChanged += delegate { UpdateFormPreferences(this, true); }; FontChanged += delegate { UpdateFormPreferences(this, true); }; FormClosing += delegate { UpdateFormPreferences(this, false); }; ContentManager.Initialize(); Task.Factory.StartNew(() => CryptoCompare.Initialize()); //LogManager.AddLogMessage(Name, "TwEX_FormEditor_Load", "Load Complete", LogManager.LogMessageType.LOG); }
public async Task UpdatePage() { NewsAdaptiveGridView.IsItemClickEnabled = false; var news = await CryptoCompare.GetNews(vm.Filters); if (news.Count != 0) { // Filter out websites that crash the WebView: news = news.FindAll(x => !x.url.Contains("ambcrypto")); vm.News = news; NewsAdaptiveGridView.IsItemClickEnabled = true; } else { vm.News = new List <NewsData>() { new NewsData() { title = "Error getting the news..." } } }; }
public CryptoCompareTests() { reader = new Maybe <IDownloadData>(new LocalDownloader("CryptoCompareData")); cc = new CryptoCompare(reader); }