Skip to content

Instantly share code, notes, and snippets.

View capm's full-sized avatar

Christian Portocarrero capm

View GitHub Profile
@psychemedia
psychemedia / gplus_espTest.py
Created June 20, 2012 10:23
ESP for Google+
# ABOUT:
# A script that grabs a list of the friends or followers of a user on Google+,
# grabs a sample of their friends, and generates the resulting social graph
# USAGE:
# Requirements: networkx (see DEPENDENCIES)
# Configuration: see CONFIGURATION
# Output: files will be save to the reports directory
# To run the script:
# 1) Download this file to a new directory somewhere as eg gplusESPnet.py
@timelyportfolio
timelyportfolio / obviousness of reits.r
Created September 20, 2012 20:20
obviousness of reits
#obviousness of reits?
#get NAREIT data
#I like NAREIT since I get back to 1971
#much easier though to get Wilshire REIT from FRED
#also it is daily instead of monthly
#getSymbols("WILLREITIND",src="FRED") will do this
require(gdata)
reitURL <- "http://returns.reit.com/returns/MonthlyHistoricalReturns.xls"
reitExcel <- read.xls(reitURL,sheet="Index Data",pattern="All REITs",stringsAsFactors=FALSE)
@dsparks
dsparks / advent_XML.R
Created November 30, 2012 16:31
XML package example
doInstall <- TRUE
toInstall <- c("XML")
if(doInstall){install.packages(toInstall, repos = "http://cran.us.r-project.org")}
lapply(toInstall, library, character.only = TRUE)
myURL <- "http://en.wikipedia.org/wiki/United_States_presidential_election,_2012"
allTables <- readHTMLTable(myURL)
str(allTables) # Look at the allTables object to find the specific table we want
stateTable <- allTables[[14]] # We want the 14th table in the list (maybe 13th?)
@dsparks
dsparks / advent_zoo.R
Created November 30, 2012 16:54
Rolling means with zoo
doInstall <- TRUE
toInstall <- c("zoo")
if(doInstall){install.packages(toInstall, repos = "http://cran.us.r-project.org")}
lapply(toInstall, library, character.only = TRUE)
ftseIndex <- EuStockMarkets[, 4]
plot(ftseIndex, col = "GRAY")
# Calculate 10-day rolling mean, quickly:
smoothIndex <- rollmean(x = ftseIndex, # original series
@capm
capm / advent_zoo.R
Created December 8, 2012 19:16 — forked from dsparks/advent_zoo.R
Rolling means with zoo
doInstall <- TRUE
toInstall <- c("zoo")
if(doInstall){install.packages(toInstall, repos = "http://cran.us.r-project.org")}
lapply(toInstall, library, character.only = TRUE)
ftseIndex <- EuStockMarkets[, 4]
plot(ftseIndex, col = "GRAY")
# Calculate 10-day rolling mean, quickly:
smoothIndex <- rollmean(x = ftseIndex, # original series
@pssguy
pssguy / global.R
Last active January 21, 2018 01:25
Motion Chart of Premier League Positions by game for past 20+ seasons. Shiny app using googleVis package The data is not currently provided but to-date charts can be viewed at glimmer.rstudio.com/pssguy/eplTableMotion/
# load requisite libraries
library(shiny)
library(googleVis)
# load raw data (NB not provided)
tableByGame <- read.csv("../tableByGame.csv",stringsAsFactors=FALSE)
# to create chart need to repeat one column and get negative of league position as hack
tableByGame$game <- tableByGame$seasonGame
tableByGame$lgPos <- -tableByGame$lgPos
@thertrader
thertrader / performanceReportREADME.txt
Last active December 7, 2021 05:19
Trading Strategies Performance Report with R and Knitr
###############################################################################
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
@thertrader
thertrader / geneticAlgorithms
Created March 12, 2014 15:39
Using Genetic Algorithms in Quantitative Trading
############################################################
## Using Genetic Algorithms in Quantitative Trading
##
## thertrader@gmail.com - Mar 2014
############################################################
library(PerformanceAnalytics)
library(rgenoud)
library(quantmod)
library(TTR)
@aniversarioperu
aniversarioperu / descarga_hojas_de_vida.py
Last active August 29, 2015 14:04
script para descargar las hojas de vida de candidatos a las Elecciones Regionales y Municipales 2014 del servidor del JNE
#-*- coding: utf-8 -*-
import codecs
import time
import json
import re
import sys
from selenium import webdriver
@mwaskom
mwaskom / seaborn_dark_background.ipynb
Created December 3, 2015 19:49
Use seaborn with a dark background, if you like that sort of thing.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.