<p><div><div><div><div data-width="100" data-show-faces="false" data-send="true" data-layout="button_count" data-height="21" data-href="https://www.r-bloggers.com/visualizing-the-daily-variability-of-bitcoin-with-quandl-and-highcharts/"></div></div><div><a data-url="https://www.r-bloggers.com/visualizing-the-daily-variability-of-bitcoin-with-quandl-and-highcharts/" data-counturl="https://www.r-bloggers.com/visualizing-the-daily-variability-of-bitcoin-with-quandl-and-highcharts/" data-count="horizontal" data-text="Visualizing the Daily Variability of Bitcoin with Quandl and Highcharts" class="twitter-share-button" data-via="rbloggers" href="https://twitter.com/share"></a></div><div></div></div><div></div></div>
<div>
(This article was first published on <strong><a href="https://fronkonstin.com/2016/10/04/visualizing-the-daily-variability-of-bitcoin-with-quandl-and-highcharts/"> R – Fronkonstin</a></strong>, and kindly contributed to <a rel="nofollow" href="https://www.r-bloggers.com/">R-bloggers)</a> </div>
<div class="twitter-share"><a target="_blank" class="twitter-share-button" href="https://twitter.com/intent/tweet?url=https%3A%2F%2Ffronkonstin.com%2F2016%2F10%2F04%2Fvisualizing-the-daily-variability-of-bitcoin-with-quandl-and-highcharts%2F&via=aschinchon">Tweet</a></div>
<blockquote><p>Lay your dreams, little darling, in a flower bed; let that sunshine in your hair (Where the skies are blue, The Lumineers)</p>
</blockquote>
<p>I discovered <a target="_blank" href="http://www.highcharts.com/blog/209-the-art-of-the-chart-weather-radials">this nice visualization</a> some days ago. The author is also the creator of <a target="_blank" href="http://jkunst.com/highcharter/">Highcharter</a>, an incredible <a target="_blank" href="https://cran.r-project.org/">R</a> wrapper for Highcharts javascript libray and its modules. I am a big fan of him.</p>
<p>Inspired by his radial plot, I did a visualization of the daily evolution of Daily Bitcoin exchange rate (BTC vs. EUR) on Localbtc. Data is sourced from <a target="_blank" href="http://www.bitcoincharts.com/">here</a> and I used Quandl to obtain the data frame. Quandl is a marketplace for financial and economic data delivered in modern formats for today’s analysts. There is a package called <code>Quandl</code> to interact directly with the Quandl API to download data in a number of formats usable in R. You only need to locate the data you want in the <a target="_blank" href="https://www.quandl.com/">Quandl site</a>. In my case data are <a target="_blank" href="https://www.quandl.com/data/BCHARTS/LOCALBTCEUR-Bitcoin-Markets-localbtcEUR">here</a>.</p>
<p>After loading data, I do the folowing steps:</p>
<ul>
<li>Filtering data to obtain last 12 complete months</li>
<li>Create a new variable with the difference between closing and opening price of Bitcoin (in Euros)</li>
<li>Create a color variable to distinguish between positive and negative differences</li>
<li>Create the graph using Fivethirtyeight theme for highcharts</li>
</ul>
<p>This is the result:</p>
<p><br>
<iframe height="500" width="100%" src="https://fronkonstin.com/wp-content/uploads/2016/10/bitcoin.html"></iframe><br>
<br>
Apart of its appealing, I think is a good way to to have a quick overview of the evolution of a stock price. This is the code to do the experiment:</p>
<pre>
library(Quandl)
library(dplyr)
library(highcharter)
library(lubridate)
bitcoin=Quandl(&quot;BCHARTS/LOCALBTCEUR&quot;)
bitcoin %>% 
  arrange(Date) %>% 
  mutate(tmstmp = datetime_to_timestamp(Date)) -> bitcoin
last_date=max(bitcoin$Date)
if (day(last_date+1)==1) date_to=last_date else 
  date_to=ymd(paste(year(last_date), month(last_date),1, sep=&quot;-&quot;))-1
date_from=ymd(paste(year(date_to)-1, month(date_to)+1,1, sep=&quot;-&quot;))
bitcoin %>% filter(Date>=date_from, Date&lt;=date_to) -> bitcoin
var_bitcoin &lt;- bitcoin %>% 
  mutate(Variation = Close - Open,
         color = ifelse(Variation>=0, &quot;green&quot;, &quot;red&quot;),
         y = Variation) %>% 
  select(x = tmstmp,
         y,
         variation = Variation,
         name = Date,
         color,
         open = Open,
         close = Close) %>% 
  list.parse3()
x &lt;- c(&quot;Open&quot;, &quot;Close&quot;, &quot;Variation&quot;)
y &lt;- sprintf(&quot;{point.%s}&quot;, tolower(x))
tltip &lt;- tooltip_table(x, y)
hc &lt;- highchart() %>% 
  hc_title(text = &quot;Bitcoin Exchange Rate (BTC vs. EUR)&quot;) %>% 
  hc_subtitle(text = &quot;Daily Variation on Localbtc. Last 12 months&quot;)%>% 
  hc_chart(
    type = &quot;column&quot;,
    polar = TRUE) %>%
  hc_plotOptions(
    series = list(
      stacking = &quot;normal&quot;,
      showInLegend = FALSE)) %>% 
  hc_xAxis(
    gridLineWidth = 0.5,
    type = &quot;datetime&quot;,
    tickInterval = 30 * 24 * 3600 * 1000,
    labels = list(format = &quot;{value: %b}&quot;)) %>% 
  hc_yAxis(showFirstLabel = FALSE) %>% 
  hc_add_series(data = var_bitcoin) %>% 
  hc_add_theme(hc_theme_538()) %>% 
  hc_tooltip(useHTML = TRUE,
    headerFormat = as.character(tags$small(&quot;{point.x:%d %B, %Y}&quot;)),
    pointFormat = tltip)
hc
</pre>
<p><div><div><div><div data-width="55" data-show-faces="false" data-send="true" data-layout="box_count" data-height="62" data-href="https://www.r-bloggers.com/visualizing-the-daily-variability-of-bitcoin-with-quandl-and-highcharts/"></div></div><div><a data-url="https://www.r-bloggers.com/visualizing-the-daily-variability-of-bitcoin-with-quandl-and-highcharts/" data-counturl="https://www.r-bloggers.com/visualizing-the-daily-variability-of-bitcoin-with-quandl-and-highcharts/" data-count="vertical" data-text="Visualizing the Daily Variability of Bitcoin with Quandl and Highcharts" class="twitter-share-button" data-via="rbloggers" href="https://twitter.com/share"></a></div><div></div></div><div></div></div>
<div>
<div>To <strong>leave a comment</strong> for the author, please follow the link and comment on their blog: <strong><a href="https://fronkonstin.com/2016/10/04/visualizing-the-daily-variability-of-bitcoin-with-quandl-and-highcharts/"> R – Fronkonstin</a></strong>.</div>
<hr>
<a rel="nofollow" href="https://www.r-bloggers.com/">R-bloggers.com</a> offers <strong><a rel="nofollow" href="https://feedburner.google.com/fb/a/mailverify?uri=RBloggers">daily e-mail updates</a></strong> about <a title="The R Project for Statistical Computing" rel="nofollow" href="https://www.r-project.org/">R</a> news and <a title="R tutorials" rel="nofollow" href="https://www.r-bloggers.com/?s=tutorial">tutorials</a> on topics such as: <a title="Data science" rel="nofollow" href="https://www.r-bloggers.com/?s=data%20science">Data science</a>, <a title="Big Data" rel="nofollow" href="https://www.r-bloggers.com/?s=Big%20Data">Big Data, <a title="R jobs" rel="nofollow" href="https://www.r-users.com/">R jobs</a>, visualization (<a title="ggplot and ggplot2 tutorials" rel="nofollow" href="https://www.r-bloggers.com/?s=ggplot2">ggplot2</a>, <a title="Boxplots using lattice and ggplot2 tutorials" rel="nofollow" href="https://www.r-bloggers.com/?s=boxplot">Boxplots</a>, <a title="Maps and gis" rel="nofollow" href="https://www.r-bloggers.com/?s=map">maps</a>, <a title="Animation in R" rel="nofollow" href="https://www.r-bloggers.com/?s=animation">animation</a>), programming (<a title="RStudio IDE for R" rel="nofollow" href="https://www.r-bloggers.com/?s=RStudio">RStudio</a>, <a title="Sweave and literate programming" rel="nofollow" href="https://www.r-bloggers.com/?s=sweave">Sweave</a>, <a title="LaTeX in R" rel="nofollow" href="https://www.r-bloggers.com/?s=LaTeX">LaTeX</a>, <a title="SQL and databases" rel="nofollow" href="https://www.r-bloggers.com/?s=SQL">SQL</a>, <a title="Eclipse IDE for R" rel="nofollow" href="https://www.r-bloggers.com/?s=eclipse">Eclipse</a>, <a title="git and github, Version Control System" rel="nofollow" href="https://www.r-bloggers.com/?s=git">git</a>, <a title="Large data in R using Hadoop" rel="nofollow" href="https://www.r-bloggers.com/?s=hadoop">hadoop</a>, <a title="Web Scraping of google, facebook, yahoo, twitter and more using R" rel="nofollow" href="https://www.r-bloggers.com/?s=Web+Scraping">Web Scraping</a>) statistics (<a title="Regressions and ANOVA analysis tutorials" rel="nofollow" href="https://www.r-bloggers.com/?s=regression">regression</a>, <a title="principal component analysis tutorial" rel="nofollow" href="https://www.r-bloggers.com/?s=PCA">PCA</a>, <a title="Time series" rel="nofollow" href="https://www.r-bloggers.com/?s=time+series">time series</a>, <a title="finance trading" rel="nofollow" href="https://www.r-bloggers.com/?s=trading">trading</a>) and more...
<img height="1" alt="" width="1" src="http://feeds.feedburner.com/~r/RBloggers/~4/2_KTBAP2iZ0"></a></div>