Skip to content

Instantly share code, notes, and snippets.

@ssanderson
ssanderson / multiply.py
Created June 7, 2012 20:08
zmq node chain test
#Midpoint for zmq node chain test. Receives a message
#via SUB socket, then propagates that message out via
#PUB socket to sink nodes.
import zmq
context = zmq.Context()
receiver = context.socket(zmq.SUB)
receiver.connect("tcp://localhost:5555")
@ssanderson
ssanderson / queueoverview.txt
Created June 13, 2012 17:31
Qexec Queue and Server Flavors
Flavors of queues in Qexec system topology:
|| Queue type: || Receives new tasks from: || Routes tasks to: ||
--------------------------------------------------------------------------------------------------------------
|| LQueue || http PUT requests (via WSGI app) || RQueue (via ZMQ socket) ||
|| RQueue || polls an LQueue for new tasks (via ZMQ socket) || Arbiter instances (via gevent queues)||
|| MQueue || http PUT requests (via WSGI app) || Arbiter instances (via gevent queues)||
Flavors of servers:
@ssanderson
ssanderson / tsc_gen.py
Created July 31, 2012 22:16
tentative top-level design for TSC
from zipline.gens import stateful_transform
from zipline.finance.trading import TransactionSimulator
from zipline.finance.performance import PerformanceTracker
def trade_simulation_client(stream_in, algo, environment, sim_style):
#============
# Algo Setup
#============
@ssanderson
ssanderson / tsc_gen.py
Created August 1, 2012 01:36
top-level draft of trade_simulation_client generator
from zipline.gens import stateful_transform
from zipline.finance.trading import TransactionSimulator
from zipline.finance.performance import PerformanceTracker
def trade_simulation_client(stream_in, algo, environment, sim_style):
"""
Generator that takes the expected output of a merge, a user
algorithm, a trading environment, and a simulator style as
arguments. Pipes the merge stream through a TransactionSimulator
and a PerformanceTracker, which keep track of the current state of
;; Root directory for Quantopian projects.
(setq quantopian-root
(let (temp)
(setq temp (getenv "QUANTO_ROOT"))
(if temp (file-name-as-directory temp) "~/quantopian")))
;; =============
;; Package Repos
;; =============
(require 'package)
Min Variance
Staging:
real 0m24.313s
user 0m23.650s
sys 0m0.330s
real 0m23.974s
user 0m23.210s
sys 0m0.420s
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
### Loading CSV for EIDO Data since 2014
## Branch
2428414 function calls (2416047 primitive calls) in 9.570 seconds
ncalls tottime percall cumtime percall filename:lineno(function)
1 0.000 0.000 8.094 8.094 qexec/qexec/sources/requests_csv.py:384(__init__)
1 0.254 0.254 8.094 8.094 qexec/qexec/sources/requests_csv.py:269(load_df)
## Master
9529341 function calls (9517154 primitive calls) in 30.053 seconds
ncalls tottime percall cumtime percall filename:lineno(function)
# Run flake8 against any added/modified python files in the current git repo.
function check8 ()
{
errors=`git diff --relative --name-only --diff-filter AM --ignore-submodules | grep -e "\.py" | xargs flake8`
retval=$?
# xargs returns 127 if flake8 couldn't be found
if [ "$retval" = "127" ]
then
@ssanderson
ssanderson / gist:33d4eec82eb84e1e3117
Created July 18, 2014 20:15
Minimal refcycle example
import gc
import objgraph
class Foo(object):
def __init__(self):
self._gen = None
def __iter__(self):
self._gen = self.gen()