mirror of
https://github.com/wassname/catalyst.git
synced 2026-09-12 12:12:04 +08:00
tests are passing for independent commission model
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
from unittest2 import TestCase
|
||||
from collections import defaultdict
|
||||
|
||||
import zipline.utils.simfactory as simfactory
|
||||
from zipline.test_algorithms import ExceptionAlgorithm, DivByZeroAlgorithm, \
|
||||
InitializeTimeoutAlgorithm, TooMuchProcessingAlgorithm
|
||||
from zipline.finance.slippage import FixedSlippage
|
||||
@@ -9,6 +10,7 @@ from zipline.lines import SimulatedTrading
|
||||
from zipline.gens.transform import StatefulTransform
|
||||
from zipline.utils.timeout import TimeoutException
|
||||
|
||||
|
||||
from zipline.utils.test_utils import (
|
||||
drain_zipline,
|
||||
setup_logger,
|
||||
@@ -37,7 +39,7 @@ class ExceptionTestCase(TestCase):
|
||||
|
||||
def test_datasource_exception(self):
|
||||
self.zipline_test_config['trade_source'] = ExceptionSource()
|
||||
zipline = SimulatedTrading.create_test_zipline(
|
||||
zipline = simfactory.create_test_zipline(
|
||||
**self.zipline_test_config
|
||||
)
|
||||
|
||||
@@ -54,7 +56,7 @@ class ExceptionTestCase(TestCase):
|
||||
exc_tnfm = StatefulTransform(ExceptionTransform)
|
||||
self.zipline_test_config['transforms'] = [exc_tnfm]
|
||||
|
||||
zipline = SimulatedTrading.create_test_zipline(
|
||||
zipline = simfactory.create_test_zipline(
|
||||
**self.zipline_test_config
|
||||
)
|
||||
|
||||
@@ -72,7 +74,7 @@ class ExceptionTestCase(TestCase):
|
||||
self.zipline_test_config['sid']
|
||||
)
|
||||
|
||||
zipline = SimulatedTrading.create_test_zipline(
|
||||
zipline = simfactory.create_test_zipline(
|
||||
**self.zipline_test_config
|
||||
)
|
||||
|
||||
@@ -90,7 +92,7 @@ class ExceptionTestCase(TestCase):
|
||||
self.zipline_test_config['sid']
|
||||
)
|
||||
|
||||
zipline = SimulatedTrading.create_test_zipline(
|
||||
zipline = simfactory.create_test_zipline(
|
||||
**self.zipline_test_config
|
||||
)
|
||||
|
||||
@@ -108,7 +110,7 @@ class ExceptionTestCase(TestCase):
|
||||
self.zipline_test_config['sid']
|
||||
)
|
||||
|
||||
zipline = SimulatedTrading.create_test_zipline(
|
||||
zipline = simfactory.create_test_zipline(
|
||||
**self.zipline_test_config
|
||||
)
|
||||
|
||||
@@ -125,7 +127,7 @@ class ExceptionTestCase(TestCase):
|
||||
self.zipline_test_config['sid']
|
||||
)
|
||||
|
||||
zipline = SimulatedTrading.create_test_zipline(
|
||||
zipline = simfactory.create_test_zipline(
|
||||
**self.zipline_test_config
|
||||
)
|
||||
|
||||
@@ -140,7 +142,7 @@ class ExceptionTestCase(TestCase):
|
||||
TooMuchProcessingAlgorithm(
|
||||
self.zipline_test_config['sid']
|
||||
)
|
||||
zipline = SimulatedTrading.create_test_zipline(
|
||||
zipline = simfactory.create_test_zipline(
|
||||
**self.zipline_test_config
|
||||
)
|
||||
|
||||
|
||||
@@ -10,6 +10,7 @@ from collections import defaultdict
|
||||
from nose.tools import timed
|
||||
|
||||
import zipline.utils.factory as factory
|
||||
import zipline.utils.simfactory as simfactory
|
||||
|
||||
from zipline.finance.trading import TradingEnvironment
|
||||
from zipline.lines import SimulatedTrading
|
||||
@@ -111,7 +112,7 @@ class FinanceTestCase(TestCase):
|
||||
#provide enough trades to ensure all orders are filled.
|
||||
self.zipline_test_config['order_count'] = 100
|
||||
self.zipline_test_config['trade_count'] = 200
|
||||
zipline = SimulatedTrading.create_test_zipline(**self.zipline_test_config)
|
||||
zipline = simfactory.create_test_zipline(**self.zipline_test_config)
|
||||
assert_single_position(self, zipline)
|
||||
|
||||
# TODO: write tests for short sales
|
||||
|
||||
@@ -307,6 +307,21 @@ class BatchTransformTestCase(TestCase):
|
||||
self.assertTrue(np.all(test_history[3].values.flatten() == range(4, 10)))
|
||||
self.assertTrue(np.all(test_history[4].values.flatten() == range(6, 14)))
|
||||
|
||||
np.testing.assert_array_equal(
|
||||
range(4, 10),
|
||||
test_history[2].values.flatten()
|
||||
)
|
||||
|
||||
np.testing.assert_array_equal(
|
||||
range(4, 10),
|
||||
test_history[3].values.flatten()
|
||||
)
|
||||
|
||||
np.testing.assert_array_equal(
|
||||
range(6, 14),
|
||||
test_history[4].values.flatten()
|
||||
)
|
||||
|
||||
def test_passing_of_args(self):
|
||||
algo = BatchTransformAlgorithm([0, 1], 1, kwarg='str')
|
||||
self.assertEqual(algo.args, (1,))
|
||||
|
||||
Reference in New Issue
Block a user