{"id":263,"date":"2020-11-29T16:19:45","date_gmt":"2020-11-29T16:19:45","guid":{"rendered":"http:\/\/burmistrov-srv.xyz\/blog\/?p=263"},"modified":"2020-11-29T16:19:45","modified_gmt":"2020-11-29T16:19:45","slug":"market-data-in-r","status":"publish","type":"post","link":"https:\/\/burmistrov.xyz\/blog\/?p=263","title":{"rendered":"Data Science and Market"},"content":{"rendered":"\n<p>I finished another course by HarvardX on EdX. The second course was about data visualization and has two parts. The first part is about general rules for data visualization (like avoid pie charts and use the same axes for data comparison etc.). The second part is about ggplot2 package in R. I should say it&#8217;s rather a powerful and flexible tool. I have experience writing VBA scripts for excel plots and definitely, ggplot2 is way too easier and faster.<\/p>\n\n\n\n<!--more-->\n\n\n\n<p>As I did before, I applied for financial support and got a 90% discount. So I was able to get a certificate for a reasonable price <\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"626\" src=\"https:\/\/burmistrov.xyz\/blog\/wp-content\/uploads\/2020\/11\/DS_Vis-1024x626.jpg\" alt=\"\" class=\"wp-image-264\" srcset=\"https:\/\/burmistrov.xyz\/blog\/wp-content\/uploads\/2020\/11\/DS_Vis-1024x626.jpg 1024w, https:\/\/burmistrov.xyz\/blog\/wp-content\/uploads\/2020\/11\/DS_Vis-300x183.jpg 300w, https:\/\/burmistrov.xyz\/blog\/wp-content\/uploads\/2020\/11\/DS_Vis-768x469.jpg 768w, https:\/\/burmistrov.xyz\/blog\/wp-content\/uploads\/2020\/11\/DS_Vis.jpg 1172w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>After completing of course I decided to apply new knowledge to our reality and made a plot of Sberbank stock price for the last 60 days. I took data from the Moscow exchange server using their API and then constructed from JSON file a data frame with dates and closed prices. Here is the code<\/p>\n\n\n\n<pre class=\"wp-block-syntaxhighlighter-code\">library(jsonlite)\njson_file=\"http:\/\/iss.moex.com\/iss\/history\/engines\/stock\/markets\/shares\/boards\/tqbr\/securities\/sber.json?from=2020-09-29\"\njsonData&lt;-fromJSON(json_file)\nhead(jsonData)\ndate_col&lt;-as.Date(jsonData$history$data[,2], format='%Y-%m-%d')\ndata_col&lt;-as.numeric(jsonData$history$data[,12])\n\ndf&lt;-data.frame(date=date_col,cl_price=data_col)\n\nhead(df)\nstr(df)\n\ndf %>% ggplot(aes(x=date, y = cl_price)) +  geom_line(colour=\"red\", size = 2, alpha=0.8) +\nxlab(\"Date\") +\nylab(\"Close price, RUB\") +\nggtitle(\"Sberbank Price History\") <\/pre>\n\n\n\n<p>And as a result, I got a good-looking plot created with five lines in two minutes.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"785\" height=\"538\" src=\"https:\/\/burmistrov.xyz\/blog\/wp-content\/uploads\/2020\/11\/Rplot01.jpeg\" alt=\"\" class=\"wp-image-265\" srcset=\"https:\/\/burmistrov.xyz\/blog\/wp-content\/uploads\/2020\/11\/Rplot01.jpeg 785w, https:\/\/burmistrov.xyz\/blog\/wp-content\/uploads\/2020\/11\/Rplot01-300x206.jpeg 300w, https:\/\/burmistrov.xyz\/blog\/wp-content\/uploads\/2020\/11\/Rplot01-768x526.jpeg 768w\" sizes=\"auto, (max-width: 785px) 100vw, 785px\" \/><\/figure>\n\n\n\n<p>I should say that the second course was more utilized, and most of the time was dedicated to practical issues. But as before, there were a lot of examples based on real data sets. So I very satisfied with this specialization so far. <\/p>\n","protected":false},"excerpt":{"rendered":"<p>I finished another course by HarvardX on EdX. The second course was about data visualization and has two parts. The first part is about general rules for data visualization (like avoid pie charts and use the same axes for data comparison etc.). The second part is about ggplot2 package in R. I should say it&#8217;s [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":266,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5,6,9],"tags":[58,60,61,67,112],"class_list":["post-263","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-data-science","category-education","category-experience","tag-data-science","tag-education","tag-edx","tag-experience","tag-money"],"_links":{"self":[{"href":"https:\/\/burmistrov.xyz\/blog\/index.php?rest_route=\/wp\/v2\/posts\/263","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/burmistrov.xyz\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/burmistrov.xyz\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/burmistrov.xyz\/blog\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/burmistrov.xyz\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=263"}],"version-history":[{"count":0,"href":"https:\/\/burmistrov.xyz\/blog\/index.php?rest_route=\/wp\/v2\/posts\/263\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/burmistrov.xyz\/blog\/index.php?rest_route=\/wp\/v2\/media\/266"}],"wp:attachment":[{"href":"https:\/\/burmistrov.xyz\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=263"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/burmistrov.xyz\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=263"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/burmistrov.xyz\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=263"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}