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.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains 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
{ | |
"metadata": { | |
"name": "Coffee_Cooling" | |
}, | |
"nbformat": 3, | |
"nbformat_minor": 0, | |
"worksheets": [ | |
{ | |
"cells": [ | |
{ |
This file contains 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
{ | |
"metadata": { | |
"name": "Simple_ODEs_Conservation" | |
}, | |
"nbformat": 3, | |
"nbformat_minor": 0, | |
"worksheets": [ | |
{ | |
"cells": [ | |
{ |
This file contains 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
// Import Federal Election campaign contribution data into Neo4j | |
// /path/to/neo4j/bin/neo4j-shell < FEC-2015.cql | |
//first let us create indexes! | |
CREATE INDEX ON :Candidate(fullName); | |
CREATE INDEX ON :Candidate(lastName); | |
CREATE INDEX ON :Candidate(candidateID); | |
CREATE INDEX ON :Contributor(fullName); | |
CREATE INDEX ON :Contributor(occupation); |
This file contains 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
MATCH n | |
OPTIONAL MATCH n-[r]->() | |
DELETE n,r; | |
LOAD CSV FROM 'https://dl.dropboxusercontent.com/u/67572426/persons.csv' AS line | |
MERGE (p:Person:Entity {name: line[0]}); | |
LOAD CSV FROM 'https://dl.dropboxusercontent.com/u/67572426/orgs.csv' AS line | |
MERGE (o:Org:Dept:Entity {name: line[0]}); |
This file contains 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
// Create schema constraints | |
CREATE CONSTRAINT ON (c:FECCommittee) ASSERT c.committee_id IS UNIQUE; | |
CREATE CONSTRAINT ON (t:Treasurer) ASSERT t.name IS UNIQUE; | |
CREATE CONSTRAINT ON (c:Contributor) ASSERT c.name IS UNIQUE; | |
CREATE CONSTRAINT ON (o:Occupation) ASSERT o.name IS UNIQUE; | |
CREATE CONSTRAINT ON (e:Employer) ASSERT e.name IS UNIQUE; | |
CREATE CONSTRAINT ON (c:City) ASSERT c.name IS UNIQUE; | |
// FEC Committees | |
USING PERIODIC COMMIT |
This file contains 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
// data available here: https://data.police.uk/data/ | |
// Load data for City of London 2015. Change URL for other data downloaded from https://data.police.uk/data/ | |
LOAD CSV WITH HEADERS FROM "https://dl.dropboxusercontent.com/u/67572426/london_graph_hack/2015-01-city-of-london-street.csv" AS row | |
WITH row WHERE row.Location IS NOT NULL AND row.Latitude IS NOT NULL AND row.Longitude IS NOT NULL AND row.Month IS NOT NULL AND row.`Falls within` IS NOT NULL AND row.`Reported by` IS NOT NULL AND row.`Crime type` IS NOT NULL AND row.`Crime ID` IS NOT NULL | |
MERGE (location:Location {name: row.Location}) | |
MERGE (point:Point {lat: row.Latitude, lon: row.Longitude}) | |
MERGE (month:Month {name: row.Month}) | |
MERGE (juris:Jurisdiction {name: row.`Falls within`}) | |
MERGE (report:Reporter {name: row.`Reported by`}) |
This file contains 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
// Load airports from Openflights.org dataset | |
CREATE CONSTRAINT ON (c:Country) ASSERT c.name IS UNIQUE; | |
CREATE CONSTRAINT ON (c:City) ASSERT c.name IS UNIQUE; | |
CREATE CONSTRAINT ON (a:Airport) ASSERT a.id IS UNIQUE; | |
LOAD CSV FROM "https://raw.githubusercontent.com/jpatokal/openflights/master/data/airports.dat" AS row | |
WITH toInt(row[0]) AS id, | |
row[1] AS name, | |
row[2] AS city, |
This file contains 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
CREATE CONSTRAINT ON (u:User) ASSERT u.eid IS UNIQUE; | |
CREATE CONSTRAINT ON (f:Folder) ASSERT f.name IS UNIQUE; | |
CREATE CONSTRAINT ON (m:Message) ASSERT m.mid IS UNIQUE; | |
CREATE INDEX ON :User(email); | |
LOAD CSV WITH HEADERS FROM "file:///employeelist.csv" AS row | |
MERGE (u:User {eid: row.eid}) | |
SET u.firstName = row.firstName, | |
u.lastName = row.lastName, | |
u.email = row.Email_id; |
OlderNewer