mirror of
https://github.com/wassname/catalyst.git
synced 2026-08-14 12:10:24 +08:00
Revert "Merge pull request #1340 from quantopian/by-daily-i-mean-minutely"
This reverts commitf4456719b0, reversing changes made to4be07e4628.
This commit is contained in:
@@ -26,7 +26,6 @@ from pandas import (
|
||||
Series,
|
||||
Timestamp,
|
||||
)
|
||||
from pandas.tseries.tools import normalize_date
|
||||
from six import iteritems, itervalues
|
||||
|
||||
from zipline.algorithm import TradingAlgorithm
|
||||
@@ -513,7 +512,7 @@ class PipelineAlgorithmTestCase(WithBcolzEquityDailyBarReaderFromCSVs,
|
||||
attach_pipeline(pipeline, 'test')
|
||||
|
||||
def handle_data(context, data):
|
||||
today = normalize_date(get_datetime())
|
||||
today = get_datetime()
|
||||
results = pipeline_output('test')
|
||||
expect_over_300 = {
|
||||
AAPL: today < self.AAPL_split_date,
|
||||
|
||||
+7
-21
@@ -3731,18 +3731,12 @@ class TestEquityAutoClose(WithTmpDir, WithTradingCalendar, ZiplineTestCase):
|
||||
transactions = output['transactions']
|
||||
initial_fills = transactions.iloc[1]
|
||||
self.assertEqual(len(initial_fills), len(assets))
|
||||
|
||||
last_minute_of_session = \
|
||||
self.trading_calendar.open_and_close_for_session(
|
||||
self.test_days[1]
|
||||
)[1]
|
||||
|
||||
for sid, txn in zip(sids, initial_fills):
|
||||
self.assertDictContainsSubset(
|
||||
{
|
||||
'amount': order_size,
|
||||
'commission': None,
|
||||
'dt': last_minute_of_session,
|
||||
'dt': self.test_days[1],
|
||||
'price': initial_fill_prices[sid],
|
||||
'sid': sid,
|
||||
},
|
||||
@@ -3809,17 +3803,15 @@ class TestEquityAutoClose(WithTmpDir, WithTradingCalendar, ZiplineTestCase):
|
||||
context.portfolio.cash == context.portfolio.starting_cash
|
||||
)
|
||||
|
||||
today_session = self.trading_calendar.minute_to_session_label(
|
||||
context.get_datetime()
|
||||
)
|
||||
now = context.get_datetime()
|
||||
|
||||
if today_session == first_asset_end_date:
|
||||
if now == first_asset_end_date:
|
||||
# Equity 0 will no longer exist tomorrow, so this order will
|
||||
# never be filled.
|
||||
assert len(context.get_open_orders()) == 0
|
||||
context.order(context.sid(0), 10)
|
||||
assert len(context.get_open_orders()) == 1
|
||||
elif today_session == first_asset_auto_close_date:
|
||||
elif now == first_asset_auto_close_date:
|
||||
assert len(context.get_open_orders()) == 0
|
||||
|
||||
algo = TradingAlgorithm(
|
||||
@@ -3837,18 +3829,12 @@ class TestEquityAutoClose(WithTmpDir, WithTradingCalendar, ZiplineTestCase):
|
||||
|
||||
original_open_orders = orders_for_date(first_asset_end_date)
|
||||
assert len(original_open_orders) == 1
|
||||
|
||||
last_close_for_asset = \
|
||||
algo.trading_calendar.open_and_close_for_session(
|
||||
first_asset_end_date
|
||||
)[1]
|
||||
|
||||
self.assertDictContainsSubset(
|
||||
{
|
||||
'amount': 10,
|
||||
'commission': 0,
|
||||
'created': last_close_for_asset,
|
||||
'dt': last_close_for_asset,
|
||||
'created': first_asset_end_date,
|
||||
'dt': first_asset_end_date,
|
||||
'sid': assets[0],
|
||||
'status': ORDER_STATUS.OPEN,
|
||||
'filled': 0,
|
||||
@@ -3862,7 +3848,7 @@ class TestEquityAutoClose(WithTmpDir, WithTradingCalendar, ZiplineTestCase):
|
||||
{
|
||||
'amount': 10,
|
||||
'commission': 0,
|
||||
'created': last_close_for_asset,
|
||||
'created': first_asset_end_date,
|
||||
'dt': first_asset_auto_close_date,
|
||||
'sid': assets[0],
|
||||
'status': ORDER_STATUS.CANCELLED,
|
||||
|
||||
@@ -417,7 +417,6 @@ def handle_data(context, data):
|
||||
|
||||
algocode = """
|
||||
from pandas import Timestamp
|
||||
from pandas.tseries.tools import normalize_date
|
||||
from zipline.api import fetch_csv, record, sid, get_datetime
|
||||
|
||||
def initialize(context):
|
||||
@@ -433,7 +432,7 @@ def initialize(context):
|
||||
context.bar_count = 0
|
||||
|
||||
def handle_data(context, data):
|
||||
expected = context.expected_sids[normalize_date(get_datetime())]
|
||||
expected = context.expected_sids[get_datetime()]
|
||||
actual = data.fetcher_assets
|
||||
for stk in expected:
|
||||
if stk not in actual:
|
||||
|
||||
Reference in New Issue
Block a user