GithubHelp home page GithubHelp logo

sol-eng / stockportfolio Goto Github PK

View Code? Open in Web Editor NEW
2.0 4.0 6.0 1.78 MB

Demo repository containing stock portfolio assets (Shiny, RMD, Plumber, ...)

License: Apache License 2.0

R 100.00%
demo finance rmarkdown plumber powerpoint pdf shiny stock

stockportfolio's Introduction

Stocks

These demos showcase different components of RStudio Connect. To view the final results, visit RStudio Solutions Engineering and filter by the tags: Finance > Stocks > Portfolio.

Each folder contains a piece of R content. More details on each are below. There are also two SQLite databases with sample data (./stock.db and ./portfolio.db) to make the repository and resources somewhat encapsulated from external dependencies.

Stocks Report


  • The report-stock [login] folder shows a quick summary of a specific stock ticker symbol. The R Markdown report is parameterized, making it easy to schedule different versions of the report in RStudio Connect. The report also generates an email that includes a custom subject line, embeds a plot and table in the body of the email, and attaches a summary of the data in a csv file. RStudio Connect stores the history of the report and makes it easy to compare versions of the report over time.

Stocks Portfolio


  • The etl [login] folder extends the use of RStudio Connect's job scheduler to an ETL task that updates a database. The ETL document provides a quick visualization to validate the model over time and RStudio Connect sends an email if the ETL task fails.

  • The shiny-app [login] folder has a R Markdown flexdashboard that uses shiny to allow users to explore portfolio returns based on different tolerances for risk.

  • The api [login] folder surfaces a function that computes the volatiltiy of a stock price as a RESTful API. RStudio Connect automatically scales the number of R processes based on the volume of incoming API requests. RStudio Connect also contains a record of deployments, making it easy to roll back to a prior version of the API.

  • The report-portfolio [login] folder contains a parameterized R Markdown report that can be used to do batch exploration of the same portfolio returns explored in the Shiny application above. The report generates a customized email for remote review by stakeholders and RStudio Connect stores the report history for review over time.

stockportfolio's People

Contributors

colearendt avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar  avatar

stockportfolio's Issues

Move `master` branch to `main`

The master branch of this repository will soon be renamed to main, as part of a coordinated change across several GitHub organizations (including, but not limited to: tidyverse, r-lib, tidymodels, and sol-eng). We anticipate this will happen by the end of September 2021.

That will be preceded by a release of the usethis package, which will gain some functionality around detecting and adapting to a renamed default branch. There will also be a blog post at the time of this master --> main change.

The purpose of this issue is to:

  • Help us firm up the list of targetted repositories
  • Make sure all maintainers are aware of what's coming
  • Give us an issue to close when the job is done
  • Give us a place to put advice for collaborators re: how to adapt

message id: euphoric_snowdog

Compare plotly and highcharter

Comparing candlestick plots between plotly and highcharter:

library(quantmod)
library(DT)
library(highcharter)
library(plotly)
library(blastula)
library(formattable)
library(ggplot2)
library(ggthemes)

prices <- round(getSymbols('TSLA', auto.assign = FALSE, src = 'yahoo'), 2)
close <- Cl(last(prices))
open <- Op(last(prices))

recent <- last(prices, n=90)
recent_nv <- recent[,-5]

price_data <- as.data.frame(prices)
price_data$Date <- as.Date(rownames(price_data))
d <- list(line = list(color = "#6794a7"))
i <- list(line = list(color = "#ffffff"))

price_data %>%
  plot_ly(
    x = ~Date, type = "candlestick",
    open = ~TSLA.Open, close = ~TSLA.Close,
    high = ~TSLA.High, low = ~TSLA.Low,
    decreasing = d, increasing = i
  ) %>%
  layout(
    paper_bgcolor = '#dce7ee',
    plot_bgcolor = '#dce7ee'
    )

highchart(type = "stock") %>% 
   hc_yAxis_multiples(
    list(title = list(text = NULL), height = "75%", top = "0%"),
    list(title = list(text = NULL), height = "15%", top = "80.5%", opposite = TRUE)
  ) %>%
  hc_add_series(prices, type = "candlestick", yAxis=0, name= 'TSLA') %>% 
  hc_add_series(prices[,paste0("TSLA.Volume")], name="Volume", type="column", yAxis=1) %>% 
  hc_add_theme(hc_theme_economist())

See if we can boil plotly down to get some feedback on possible improvements. Namely:

  • data is not aggregated nicely
  • easy way to specify time windows / filters
  • colorization issues... these are probably easy enough to fix
  • supplementary series, etc.
  • theming, etc.

https://plot.ly/r/candlestick-charts/

Current state:

Plotly:
image

Highcharter:
image

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.