Skip to content

Instantly share code, notes, and snippets.

@dat-boris
dat-boris / gist:5515726
Created May 4, 2013 01:56
Data frequency analysis script
#!/usr/bin/python
"""
Input:
[visitor, element, t]
Output:
[element, count(visitor)].sort(lambda a,b: b[1]-a[1])
"""
@dat-boris
dat-boris / gist:5564369
Created May 12, 2013 17:49
Base line bootstrap css template that have no dependency
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Bootstrap, from Twitter</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="">
<meta name="author" content="">
@dat-boris
dat-boris / py_trace.d
Created December 31, 2013 00:41
Python dtrace script for tracing function call
#!/usr/sbin/dtrace -Zs
python$target:::function-entry
{
trace(copyinstr(arg1));
}
import boto
import boto.s3
import os.path
import sys
# Fill these in - you get them when you sign up for S3
AWS_ACCESS_KEY_ID = ''
AWS_ACCESS_KEY_SECRET = ''
# Fill in info on data to upload
@dat-boris
dat-boris / pipeline.py
Created November 20, 2016 03:36
`pipeline_line` output replacement
# see
# * https://www.quantopian.com/research/notebooks/201610-Female-CEO/1106-Alpha-confirmation.ipynb
# * https://www.quantopian.com/posts/running-pipeline-backtest-in-reserach
last_pipeline_index = None
pipeline_data = None
def get_new_data(t, pipeline_name):
start_date = t
@dat-boris
dat-boris / pipeline_data.py
Last active November 24, 2016 09:53
Pipeline abstraction class for handling quantopian pipeline data
# https://www.quantopian.com/posts/help-with-custom-factor
class SidInList(CustomFilter):
inputs = []
window_length = 1
params = ('sid_list',)
def compute(self, today, assets, out, sid_list):
assert len(sid_list) > 0
out[:] = np.in1d(assets, sid_list)
@dat-boris
dat-boris / classifier.py
Created November 24, 2016 22:54
Wrapper class I use for simple decision tree exploration
class Classifier():
def __init__(self,
df, depth=3,
source_cols=input_columns, target='delta_90',
use_classification=False):
"""
Given the model, let's train
:return: Classified model
"""
@dat-boris
dat-boris / pairs.py
Last active February 28, 2017 05:18
Quantopian tool for researching pair trading algorithm
"""
A simple tool for researching Pairs based on:
https://www.quantopian.com/clone_notebook?id=57ed7c41144f8837290000da
"""
from datetime import date, timedelta
import matplotlib.pyplot as plt
from statsmodels.tsa.stattools import coint
from zipline import TradingAlgorithm
@dat-boris
dat-boris / recorder.py
Last active November 28, 2016 03:30
Simple quantopian polyfill to allow recording metrics into dataframe
from zipline.api import (
schedule_function, date_rules, time_rules, sid, symbol,
set_slippage, slippage, set_commission, commission,
get_datetime, order_target_percent,
# record, # Replaced below
attach_pipeline,
order_target, get_open_orders, history
)
@dat-boris
dat-boris / debug_flink_aws.scala
Created December 14, 2016 09:39
Some notes on our process on debugging Flink AWS parameter name