This GraphGist will begin to explore how stock option data can be modeled as a graph, some simple Cypher queries for calculating payout at expiration for an options contract and a very basic look at finding profitable options trades given a specific forecast. Please note that some of the concepts here have been simplified and are only meant as an educational overview of exploring Neo4j and graph data modeling.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| library(R6) | |
| library(shiny) | |
| ### | |
| ### Create a simple R6 class with a public dummy value | |
| ### | |
| DummyClass <- R6Class("DummyClass",lock_objects=FALSE, | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| FROM ubuntu:14.04 | |
| MAINTAINER Winston Chang "winston@rstudio.com" | |
| # ===================================================================== | |
| # R | |
| # ===================================================================== | |
| # Need this to add R repo | |
| RUN apt-get update && apt-get install -y software-properties-common |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| FROM ubuntu:14.04 | |
| MAINTAINER Winston Chang "winston@rstudio.com" | |
| # ===================================================================== | |
| # R | |
| # ===================================================================== | |
| # Need this to add R repo | |
| RUN apt-get update && apt-get install -y software-properties-common |
Most Finance portfolio management’s would be using RDBMS. But the same could be built with neo4j in a much succint manner. The analysis that can be done over it is interesting too. Consider the system has the data for x members, we can get analysis as follows:
-
How much percentage people spend money on a particular liability, say loans.
-
How much percentage does a particular asset contribute to average earnings.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| library(rgeos) | |
| data(wrld_simpl) | |
| plot(wrld_simpl, col='white', bg='grey9', border=NA) | |
| limx <- c(-6,1) | |
| limy <- c(49,60) | |
| plot(wrld_simpl, xlim=limx, ylim=limy, col='white', bg='grey9', border=NA) | |
| # Apply RDP algorithm with distance variable = 0.4 degrees |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| library(DT) | |
| library(shiny) | |
| # options(shiny.reactlog=TRUE) | |
| id <- 1:10 | |
| label <- paste0("lab","-",id) | |
| ratio <- runif(10, 1.0, 10.0) | |
| ratio <- round(ratio,0) | |
| df <- ds <- data.frame(id=id, label=label,ratio=ratio, stringsAsFactors = FALSE) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| library(shiny) | |
| shinyServer(function(input, output, session) { | |
| # The number of iterations to perform | |
| maxIter <- 50 | |
| # Track the start and elapsed time | |
| startTime <- Sys.time() | |
| output$elapsed <- renderText({ |
Once I saw R.devices function toFavicon I just had to figure out how to use it to dynamically change the favicon with a plot from R. Here is one way to accomplish it, but note the dangerous eval(parse(...)) in line 14, so be careful if you are using for nonpersonal use.
For non-shiny use, we can see it work with htmltools.
library(htmltools)
library(R.devices)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| --- | |
| title: "Changes in homicide rates" | |
| output: html_document | |
| --- | |
| I've updated the [mxmortalitydb](https://github.com/diegovalle/mxmortalitydb) package to include 2013 data. This data only packages includes all injury intent deaths (accidents, homicides, suicides and unspcified intent) that were registered in Mexico from 2004 to 2013. You can use the package to calculate changes and trends in homicide rates in the most violent metro areas or big municipios. | |
| ```{r} | |
| #if (!require('devtools')) install.packages('devtools') |