Skip to content

Instantly share code, notes, and snippets.

############################################################
## Using Genetic Algorithms in Quantitative Trading
##
## thertrader@gmail.com - Mar 2014
############################################################
library(PerformanceAnalytics)
library(rgenoud)
library(quantmod)
library(TTR)
@sglyon
sglyon / knitr.mk
Created March 15, 2014 23:59 — forked from halpo/knitr.mk
################################################################################
# Copyright 2011
# Andrew Redd
# 11/23/2011
#
# Description of File:
# Makefile for knitr compiling
#
################################################################################
all:pdf # default rule DO NOT EDIT
package main
import "code.google.com/p/go-tour/pic"
func Pic(dx, dy int) [][]uint8 {
a := make([][]uint8, dy)
// allocate inner dimension
for i:=0; i < dy; i++ {
a[i] = make([]uint8, dx)
@sglyon
sglyon / discretize.jl
Last active August 29, 2015 14:00
Violante HW 3 Code
"""
Various routines to discretize AR(1) processes
@author : Spencer Lyon <spencer.lyon@nyu.edu>
@date : 2014-04-10 23:55:05
"""
norm_cdf{T <: Real}(x::Union(T, Array{T})) = 0.5 * erfc(-x/sqrt(2))
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
class AssetPrices(object):
"""
docstring
"""
def __init__(self, beta, P, s, gamma):
self.beta, self.gamma = beta, gamma
self.P, self.s = P, s
self.n = self.P.shape[0]
@property
#!/usr/bin/env python
"""
simple example script for running notebooks and reporting exceptions.
Usage: `checkipnb.py foo.ipynb [bar.ipynb [...]]`
Each cell is submitted to the kernel, and checked for errors.
"""
import os,sys,time
@sglyon
sglyon / README.md
Created August 5, 2014 23:50
jinja2 templates for website

The template is called example.tmpl and it contains the lecture source as well as defines various blocks.

Each of the blocks has a default argument that is simply the content that is found in the current python only version of the site.

The cool thing is how we can use this system to easily generate lecture files for both languages, by only having to define the blocks for julia. This happens in example_jl.tmpl.

Notice I don't do anything beyond filling in the blocks here. i.e. there is no actual exposition here -- just replacing the default block parameters with their julia equivalent.

The python script run_example.py shows how we could load the template and evaluate it. If you have python run the file it will print out the python and julia versions of the file for you.

@sglyon
sglyon / hw2_plotting.jl
Last active August 29, 2015 14:08
hw2 for cogley's course
# load in the model and associated tools
require("../nk_model.jl")
require("../nk_model_tools.jl")
# load packages we use
import Gadfly
import PyPlot
using Distributions
using DataFrames
@sglyon
sglyon / README.md
Last active August 29, 2015 14:12
cs2014

Code/data for cs2014

To actually run this code you need to get my gibbs branch of MCMC.jl:

Pkg.clone("git@github.com:spencerlyon2/MCMC.jl.git")
Pkg.checkout("MCMC", "gibbs")

You will also need a special version of the StateSpace.jl package: