Skip to content

Instantly share code, notes, and snippets.

View fawce's full-sized avatar
💭
former software engineer

fawce fawce

💭
former software engineer
View GitHub Profile
@fawce
fawce / fetcher2dot0.md
Last active April 21, 2017 23:03
Draft documentation for Quantopian fetcher 2.0

Fetcher 2.0

Fetcher - Load any CSV file

Quantopian provides a 11-year history of US equity market data in minute and daily bars. The US market data provides a backbone for financial analysis, but some of the most promising areas of research are finding signals in non-market data. Fetcher provides your algorithm with access to external time series data. Any time series that can be retrieved as a csv file via http or https can be incorporated into a Quantopian algorithm.

Fetcher lets you load csv files over http. To use it, invoke fetch_csv(url) in your initialize method. fetch_csv will retrieve the text of the csv file using the (wonderful) requests module. The csv is parsed into a pandas dataframe using pandas.io.parsers.read_csv. You may then specify your own methods to modify the entire dataframe prior to the start of the simulation. During simulation, the rows of the csv/dataframe are streamed to your algorithm's handle_data method as additional properties of the data parameter.

Best of all, your F

Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
#!/usr/bin/perl
################
use strict;
use warnings;
use CGI ':standard';
use CGI::Carp 'fatalsToBrowser';
use Data::Dumper;
@fawce
fawce / csvds.py
Created November 12, 2012 01:15
Rough draft, CSV data source for zipline
"""
Generator-style DataSource that loads from CSV.
"""
import pytz
import csv
import mmap
import os.path
@fawce
fawce / install-ruby-debug-ubuntu-ruby-1.9.3
Created February 3, 2012 03:19 — forked from boriscy/install-ruby-debug-ubuntu-ruby-1.9.3
install for ruby-debug in ruby-1.9.3 and ubuntu
#!/bin/bash
##########IMPORTANT###########################################################################
# This script requires rvm: http://beginrescueend.com/
# Before running this script you must install rvm. This script will install ruby 1.9.3-p0 if it
# is not already. Ruby can take 10 minutes to compile.
# Load RVM into a shell session *as a function*
if [[ -s "$HOME/.rvm/scripts/rvm" ]] ; then
# First try to load from a user install
@fawce
fawce / generic_algo.py
Created January 8, 2012 14:15
Simple Object Model for Quantopian Algorithm
class SecurityState():
"""An example class to track persistent state for a
specific security. This trivial example just tracks the max
price for the security, as well as shares ordered.
Modify this class to track individual securities."""
def __init__(self, tick):
self.sid = tick.sid
self.max_price = tick.price
@fawce
fawce / quantopian_tutorial.py
Created January 8, 2012 14:07
Example Algorithm for Quantopian - VWAP
vwapMap = {}
class DailyVWAP:
"""A class that tracks the volume weighted average price
based on tick updates."""
def __init__(self, sid, period_length):
self.sid = sid
self.ticks = []
self.value = 0.0
self.period_length = period_length