removed expiremental pandas code

This commit is contained in:
fawce
2012-05-10 15:13:00 -04:00
parent 81de47774f
commit add3f10b2e
3 changed files with 2 additions and 63 deletions
-32
View File
@@ -1,4 +1,3 @@
import pandas
from datetime import timedelta
from collections import defaultdict
@@ -64,36 +63,5 @@ class EventWindow(object):
# remove the expired events
slice_index = len(self.dropped_ticks)
self.ticks = self.ticks[slice_index:]
# ------------------------------
# Experimental
# ------------------------------
class EventHistory(object):
def __init__(self, daycount):
self.ticks = []
self.dropped_ticks = []
self.frame = pandas.DataFrame()
self.delta = timedelta(days=daycount)
def update(self, event):
self.ticks.append(event.__dict__)
self.last_date = event['dt']
self.first_date = self.last_date - self.delta
# determine which events are expired
self.dropped_ticks = []
for tick in self.ticks:
if tick['dt'] < self.first_date:
self.dropped_ticks.append(tick)
# remove the expired events
slice_index = len(self.dropped_ticks)
self.ticks = self.ticks[slice_index:]
self.frame = pandas.DataFrame(
self.ticks
)
self.frame.index = self.frame['dt']
+1 -30
View File
@@ -3,7 +3,7 @@ from datetime import timedelta
from collections import defaultdict
from zipline.messaging import BaseTransform
from zipline.finance.movingaverage import EventWindow, EventHistory
from zipline.finance.movingaverage import EventWindow
class VWAPTransform(BaseTransform):
@@ -59,32 +59,3 @@ class DailyVWAP:
flux += tick['volume'] * tick['price']
volume += tick['volume']
return flux, volume
# ------------------------------
# Experimental
# ------------------------------
class DailyVWAP_df(object):
def __init__(self, daycount=3):
self.history = EventHistory(daycount)
self.vwap = None
def update(self, event):
self.history.update(event)
frame = self.history.frame
window = len(frame)
value = pandas.rolling_sum(
frame['price'] * frame['volume'],
window
)
volume = pandas.rolling_sum(
frame['volume'],
window
)
vwap = value / volume
self.vwap = vwap[-1]
+1 -1
View File
@@ -4,7 +4,7 @@ from unittest2 import TestCase
import zipline.test.factory as factory
import zipline.util as qutil
from zipline.finance.vwap import DailyVWAP, VWAPTransform, DailyVWAP_df
from zipline.finance.vwap import DailyVWAP, VWAPTransform
from zipline.finance.returns import ReturnsFromPriorClose
from zipline.finance.movingaverage import MovingAverage
from zipline.lines import SimulatedTrading