From 784bb3673b6a3a1697d535b6486e664f151ad087 Mon Sep 17 00:00:00 2001 From: Eddie Hebert Date: Wed, 22 Aug 2012 09:51:29 -0400 Subject: [PATCH 1/6] Removes unused dev folder. - cli.py: Only contains a TODO: statement - topos.py: Appears to be a utility for debugging zeromq topologies. Which is unneeded in the current zeromq-less architecture. --- dev/cli.py | 1 - dev/topos.py | 189 --------------------------------------------------- 2 files changed, 190 deletions(-) delete mode 100644 dev/cli.py delete mode 100644 dev/topos.py diff --git a/dev/cli.py b/dev/cli.py deleted file mode 100644 index 3fd8a4b3..00000000 --- a/dev/cli.py +++ /dev/null @@ -1 +0,0 @@ -# TODO: move qexec console here diff --git a/dev/topos.py b/dev/topos.py deleted file mode 100644 index 23e37ff7..00000000 --- a/dev/topos.py +++ /dev/null @@ -1,189 +0,0 @@ -import uuid -import copy -import atexit -import pickle - -from datetime import datetime -from collections import defaultdict - -from UserDict import DictMixin - -class Snapshot(object, DictMixin): - """ - A snapshot in time of a history container. - """ - - def __init__(self, state, version, ts): - self.version = version - self.timestamp = ts - self._state = state - - def keys(self): - return self._state.keys() - - def values(self): - return self._state.values() - - def items(self): - return self._state.items() - - def __getitem__(self, key): - return self._state.__getitem__(key) - - def has_key(self, key): - return self._state.has_key(key) - - def copy(self): - return copy.copy(self._state) - -class History(object, DictMixin): - """ - A duck-typed dictionary that tracks its time evolution. - - Worth noting this not a particuarly high-performance - data structure due to the copious amount of copying going on. - """ - - def __init__(self, default=None): - if default: - initial = defaultdict(default) - else: - initial = {} - - self.version = 0 - self.changeset = [('CREATE', None)] - self.current = Snapshot(initial, version=self.version, ts=datetime.now()) - self._history = [self.current] - - def items(self, version=-1): - return self._history[version].items() - - def keys(self, version=-1): - return self._history[version].keys() - - def rollback(self, version): - pass - - def event(self, tup): - self.changeset.append(tup) - - def __getitem__(self, key, version=-1): - return self._history[version].__getitem__(key) - - def __setitem__(self, key, val): - if self.current.has_key(key): - self.changeset.append(('CHANGE', key)) - else: - self.changeset.append(('ADD', key)) - - state = self.current.copy() - state[key] = val - - self.version += 1 - self.current = Snapshot(state, self.version, datetime.now()) - self._history.append(self.current) - - def __delitem__(self, key): - self.changeset.append(('REMOVE', key)) - - state = self.current.copy() - del state[key] - - self.version += 1 - self.current = Snapshot(state, self.version, datetime.now()) - self._history.append(self.current) - - def history(self): - for change in self.changeset: - print change - - def __repr__(self): - return ':'.join(['historical', self.current._state.__repr__()]) - -SocketHistory = History() -ContextHistory = History() - -def patch_zmq(_zmq=None): - """ - Monkey patch zeromq to allow for socket tracking. - """ - if _zmq: - zmq = _zmq - else: - import zmq - - _Context = zmq.Context - _Socket = zmq.Socket - - class TrackedSocket(zmq.Socket): - - def __init__(self, context, socket_type): - self.context = context - self.uuid = str(uuid.uuid4()) - SocketHistory[self.uuid] = self - _Socket.__init__(self, context, socket_type) - - def connect(self, address): - SocketHistory.event(('CONNECT', self.uuid, address)) - _Socket.connect(self, address) - - def bind(self, address): - SocketHistory.event(('BIND', self.uuid, address)) - _Socket.bind(self, address) - - def close(self, *args, **kwargs): - del SocketHistory[self.uuid] - _Socket.close(self, *args, **kwargs) - - def setsockopt(self, option, optval): - if option == zmq.IDENTITY: - old = SocketHistory[self.uuid] - SocketHistory[optval] = old - del SocketHistory[self.uuid] - self.uuid = optval - - _Socket.setsockopt(self, option, optval) - - class TrackedContext(zmq.Context): - - def __init__(self, *args, **kwargs): - self.sockets = {} - _Context.__init__(self, *args, **kwargs) - self.uuid = str(uuid.uuid4()) - ContextHistory[self.uuid] = self - - def socket(self, socket_type): - sock = TrackedSocket(self, socket_type) - ContextHistory.event(('EMBED', self.uuid, sock.uuid)) - self.sockets[sock.uuid] = sock - return sock - - def name(self, name): - """ - Name the context. Is a superset of the vanilla pyzmq - API. - """ - old = ContextHistory[self.context.uuid] - ContextHistory[name] = old - del ContextHistory[self.context.uuid] - self.uuid = name - - def term(self, *args, **kwargs): - for uid, sock in self.sockets.iteritems(): - if not sock.closed: - del SocketHistory[sock.uuid] - del ContextHistory[self.uuid] - _Context.term(self, *args, **kwargs) - - def destroy(self, *args, **kwargs): - ContextHistory.event(('DESTROY', self.uuid)) - _Context.destroy(self, *args, **kwargs) - - zmq.Context = TrackedContext - zmq.Socket = TrackedSocket - return TrackedContext, TrackedSocket - -def track_to_file(f): - def write_track(): - pickle.dump(SocketHistory.changeset, file(f, 'wb+')) - atexit.register(write_track) From bf1247e00935a7c85fa05b77874d4c8787892c6a Mon Sep 17 00:00:00 2001 From: Eddie Hebert Date: Wed, 22 Aug 2012 12:57:29 -0400 Subject: [PATCH 2/6] Removes unused imports. --- zipline/lines.py | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/zipline/lines.py b/zipline/lines.py index d31c47d6..4e5f2cfb 100644 --- a/zipline/lines.py +++ b/zipline/lines.py @@ -68,16 +68,15 @@ from setproctitle import setproctitle from zipline.test_algorithms import TestAlgorithm from zipline.finance.trading import SIMULATION_STYLE -from zipline.utils.log_utils import ZeroMQLogHandler, stdout_only_pipe +from zipline.utils.log_utils import ZeroMQLogHandler from zipline.utils import factory -from zipline.test_algorithms import TestAlgorithm - -from zipline.gens.composites import \ - date_sorted_sources, merged_transforms, sequential_transforms -from zipline.gens.transform import Passthrough, StatefulTransform +from zipline.gens.composites import ( + date_sorted_sources, + sequential_transforms +) from zipline.gens.tradesimulation import TradeSimulationClient as tsc -from logbook import Logger, NestedSetup, Processor +from logbook import Logger import zipline.protocol as zp From 90cf794952a5093c78f9ef21f37797c10a503139 Mon Sep 17 00:00:00 2001 From: fawce Date: Wed, 22 Aug 2012 16:33:52 -0400 Subject: [PATCH 3/6] added statsmodels and moved pandas forward --- etc/requirements_sci.txt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/etc/requirements_sci.txt b/etc/requirements_sci.txt index b74b3e57..5128eb20 100644 --- a/etc/requirements_sci.txt +++ b/etc/requirements_sci.txt @@ -4,7 +4,7 @@ python-dateutil==1.5 # Core scientific python numpy>=1.6.1 -pandas>=0.7.0rc1 +pandas=0.8.0 scipy>=0.10.0 matplotlib==1.1.0 @@ -12,8 +12,8 @@ matplotlib==1.1.0 numexpr==2.0.1 Cython==0.15.1 -#tables>=2.3.1 -#scikits.statsmodels>=0.3.1 +statsmodels==0.5.0 +patsy==0.1.0 # ZeroMQ pyzmq==2.1.11 From e6be7d49f21f2d2d07e8bc1fbaaf5d0c476869bd Mon Sep 17 00:00:00 2001 From: fawce Date: Wed, 22 Aug 2012 17:03:28 -0400 Subject: [PATCH 4/6] updated sci requirements to include statsmodels and latest pandas --- etc/requirements_sci.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/etc/requirements_sci.txt b/etc/requirements_sci.txt index 5128eb20..3c72a01d 100644 --- a/etc/requirements_sci.txt +++ b/etc/requirements_sci.txt @@ -15,5 +15,6 @@ Cython==0.15.1 statsmodels==0.5.0 patsy==0.1.0 + # ZeroMQ pyzmq==2.1.11 From 25c33b70c77bc45f0e5be4f190af17f53d0dd4a7 Mon Sep 17 00:00:00 2001 From: fawce Date: Wed, 22 Aug 2012 17:21:32 -0400 Subject: [PATCH 5/6] fixed pandas version specifier, reversed order of patsy --- etc/requirements_sci.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/etc/requirements_sci.txt b/etc/requirements_sci.txt index 3c72a01d..e9ab5111 100644 --- a/etc/requirements_sci.txt +++ b/etc/requirements_sci.txt @@ -4,7 +4,7 @@ python-dateutil==1.5 # Core scientific python numpy>=1.6.1 -pandas=0.8.0 +pandas==0.8.0 scipy>=0.10.0 matplotlib==1.1.0 @@ -12,8 +12,8 @@ matplotlib==1.1.0 numexpr==2.0.1 Cython==0.15.1 -statsmodels==0.5.0 patsy==0.1.0 +statsmodels==0.5.0 # ZeroMQ From 88c31e7a60a716f288a2a1c1875b24c9c16702b7 Mon Sep 17 00:00:00 2001 From: fawce Date: Wed, 22 Aug 2012 19:28:16 -0400 Subject: [PATCH 6/6] pip freeze reports statsmodels==0.5.0 ... actual version? 0.5.0-tutorial-beta --- etc/requirements_sci.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/etc/requirements_sci.txt b/etc/requirements_sci.txt index e9ab5111..a0104713 100644 --- a/etc/requirements_sci.txt +++ b/etc/requirements_sci.txt @@ -13,7 +13,7 @@ matplotlib==1.1.0 numexpr==2.0.1 Cython==0.15.1 patsy==0.1.0 -statsmodels==0.5.0 +statsmodels==0.5.0-tutorial-beta # ZeroMQ