Skip to content

Instantly share code, notes, and snippets.

View laholmes's full-sized avatar

Laurence Holmes laholmes

View GitHub Profile
@laholmes
laholmes / fib.py
Last active November 12, 2017 10:55
def fibonacci(n):
x = 0
y = 1
for i in range(n):
print x
t = y
y = x + y
x = t
def fibonacci(n):
@laholmes
laholmes / Dockerfile
Created October 8, 2017 12:21 — forked from yefim/Dockerrun.aws.json
Build a Docker image, push it to AWS EC2 Container Registry, then deploy it to AWS Elastic Beanstalk
# Example Dockerfile
FROM hello-world
s3_lib_path = os.getenv('S3_LIB_PATH', None)
if s3_lib_path is not None and len(s3_lib_path) > 0:
log.info('[S3 patch] S3_LIB_PATH is defined. Will patch deployment from S3.')
log.info('[S3 patch] S3_LIB_PATH is [{}]'.format(s3_lib_path))
import boto3
import botocore
bucket, key = s3_lib_path.split('/', 1)
patch_dir = '/tmp/extensions'
patch_file_target = os.path.join(patch_dir, '.s3_patch.zip')
@laholmes
laholmes / cointegration.R
Created December 19, 2016 15:16
cointegration test + cross hedging
library('zoo')
library('urca')
prices <- read.zoo('./priceData.csv', sep=',', FUN = as.yearmon, format='%Y-%m', header=TRUE)
# taking into account short term behaviour, derive the minimum variance hedge by fitting
# a linear model that explains changes in B prices by changes in A prices
# beta coefficient of the regression is the optimal hedge ratio
# intercept is zero as no cash holdings