mirror of
https://github.com/wassname/catalyst.git
synced 2026-07-04 21:53:45 +08:00
Refactored optimize factory. Enabled optimize unittests.
This commit is contained in:
@@ -7,7 +7,7 @@ import numpy as np
|
||||
|
||||
from zipline.core.devsimulator import AddressAllocator
|
||||
# TODO: refactor the factory to use generators
|
||||
# from zipline.optimize.factory import create_predictable_zipline
|
||||
from zipline.optimize.factory import create_predictable_zipline
|
||||
|
||||
DEFAULT_TIMEOUT = 15 # seconds
|
||||
EXTENDED_TIMEOUT = 90
|
||||
@@ -38,7 +38,7 @@ class TestUpDown(TestCase):
|
||||
def tearDown(self):
|
||||
teardown_logger(self)
|
||||
|
||||
@skip
|
||||
# @skip
|
||||
@timed(DEFAULT_TIMEOUT)
|
||||
def test_source_and_orders(self):
|
||||
"""verify that UpDownSource is having the correct
|
||||
@@ -94,7 +94,7 @@ class TestUpDown(TestCase):
|
||||
"Algorithm did not sell when price was going to increase."
|
||||
)
|
||||
|
||||
@skip
|
||||
# @skip
|
||||
def test_concavity_of_returns(self):
|
||||
"""verify concave relationship between free parameter and
|
||||
returns in certain region around the max. Moreover,
|
||||
@@ -136,7 +136,7 @@ class TestUpDown(TestCase):
|
||||
idx[0] -= 1
|
||||
idx[1] += 1
|
||||
|
||||
@skip
|
||||
# @skip
|
||||
def test_optimize(self):
|
||||
"""verify that gradient descent (Powell's method) can find
|
||||
the optimal free parameter under which the BuySellAlgorithm produces
|
||||
|
||||
@@ -9,10 +9,10 @@ from itertools import izip
|
||||
from zipline.utils.factory import create_trading_environment
|
||||
from zipline.test_algorithms import TestAlgorithm
|
||||
|
||||
from zipline.gens.composites import SourceBundle, TransformBundle, \
|
||||
date_sorted_sources, merged_transforms, sequential_transforms
|
||||
from zipline.gens.composites import date_sorted_sources, merged_transforms, sequential_transforms
|
||||
from zipline.gens.tradegens import SpecificEquityTrades
|
||||
from zipline.gens.transform import MovingAverage, Passthrough, StatefulTransform
|
||||
from zipline.gens.mavg import MovingAverage
|
||||
from zipline.gens.transform import Passthrough, StatefulTransform
|
||||
from zipline.gens.tradesimulation import TradeSimulationClient as tsc
|
||||
|
||||
import zipline.protocol as zp
|
||||
|
||||
@@ -4,12 +4,11 @@ Factory functions to prepare useful data for optimize tests.
|
||||
Author: Thomas V. Wiecki (thomas.wiecki@gmail.com), 2012
|
||||
"""
|
||||
from datetime import timedelta
|
||||
import pandas as pd
|
||||
|
||||
import zipline.protocol as zp
|
||||
|
||||
from zipline.utils.factory import get_next_trading_dt, create_trading_environment
|
||||
from zipline.finance.sources import SpecificEquityTrades
|
||||
from zipline.gens.tradegens import SpecificEquityTrades
|
||||
from zipline.optimize.algorithms import BuySellAlgorithm
|
||||
from zipline.lines import SimulatedTrading
|
||||
from zipline.finance.trading import SIMULATION_STYLE
|
||||
@@ -66,7 +65,7 @@ def create_updown_trade_source(sid, trade_count, trading_environment, base_price
|
||||
|
||||
trading_environment.period_end = cur
|
||||
|
||||
source = SpecificEquityTrades(events)
|
||||
source = SpecificEquityTrades(event_list=events)
|
||||
|
||||
return source
|
||||
|
||||
|
||||
Reference in New Issue
Block a user