Skip to content

Commit

Permalink
fixed tests net of merge of dataflow.
Browse files Browse the repository at this point in the history
  • Loading branch information
fawce committed Mar 15, 2012
1 parent 930ec57 commit a35c702
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 12 deletions.
12 changes: 6 additions & 6 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
verbosity=2
detailed-errors=1

with-xcoverage=1
cover-package=zipline
cover-erase=1
cover-html=1
cover-html-dir=docs/_build/html/cover
with-xunit=1
#with-xcoverage=1
#cover-package=zipline
#cover-erase=1
#cover-html=1
#cover-html-dir=docs/_build/html/cover
#with-xunit=1


# Drop into debugger on failure
Expand Down
1 change: 0 additions & 1 deletion zipline/protocol.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,6 @@
import datetime
import pytz
import copy
import pandas
from collections import namedtuple

from protocol_utils import Enum, FrameExceptionFactory, namedict
Expand Down
6 changes: 6 additions & 0 deletions zipline/protocol_utils.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import copy
import pandas
from ctypes import Structure, c_ubyte

def Enum(*options):
Expand Down Expand Up @@ -85,3 +86,8 @@ def __eq__(self, other):

def has_attr(self, name):
return self.__dict__.has_key(name)

def as_series(self):
s = pandas.Series(self.__dict__)
s.name = self.sid
return s
5 changes: 2 additions & 3 deletions zipline/test/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,8 @@ def handle_frame(self, frame):
event = zp.namedict(data)
#place an order for 100 shares of sid:133
if self.incr < self.count:
if event.source_id != zp.FINANCE_COMPONENT.ORDER_SOURCE:
self.trading_client.order(self.sid, self.amount)
self.incr += 1
self.trading_client.order(self.sid, self.amount)
self.incr += 1
elif not self.done:
self.trading_client.signal_order_done()
self.done = True
4 changes: 4 additions & 0 deletions zipline/test/test_finance.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,8 @@ def test_orders(self):
self.trading_environment.period_start = trade_history[0].dt
self.trading_environment.period_end = trade_history[-1].dt
self.trading_environment.capital_base = 10000
self.trading_environment.frame_index = ['sid', 'volume', 'dt', \
'price', 'changed']

trading_client = TradeSimulationClient(self.trading_environment)
#client will send 10 orders for 100 shares of 133
Expand Down Expand Up @@ -291,6 +293,8 @@ def test_performance(self):
self.trading_environment.period_start = trade_history[0].dt
self.trading_environment.period_end = trade_history[-1].dt
self.trading_environment.capital_base = 10000
self.trading_environment.frame_index = ['sid', 'volume', 'dt', \
'price', 'changed']

set1 = SpecificEquityTrades("flat-133", trade_history)

Expand Down
7 changes: 5 additions & 2 deletions zipline/test/test_risk.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ class Risk(unittest.TestCase):

def setUp(self):
qutil.configure_logging()
start_date = datetime.datetime(year=2006, month=1, day=1, tzinfo=pytz.utc)
end_date = datetime.datetime(year=2006, month=12, day=31, tzinfo=pytz.utc)

self.benchmark_returns, self.treasury_curves = \
factory.load_market_data()

Expand All @@ -23,9 +26,9 @@ def setUp(self):
self.oneday = datetime.timedelta(days=1)
self.tradingday = datetime.timedelta(hours=6, minutes=30)
self.dt = datetime.datetime.utcnow()
start_date = datetime.datetime(year=2006, month=1, day=1, tzinfo=pytz.utc)

self.algo_returns_06 = factory.create_returns_from_list(RETURNS, start_date, self.trading_calendar)
end_date = datetime.datetime(year=2006, month=12, day=31, tzinfo=pytz.utc)

self.metrics_06 = risk.RiskReport(self.algo_returns_06, self.trading_calendar)

def tearDown(self):
Expand Down

0 comments on commit a35c702

Please sign in to comment.