Moved cycle import out of function.

This commit is contained in:
Thomas Wiecki
2012-05-28 12:02:11 -04:00
parent 6523ff6c9b
commit 1c91c7287b
2 changed files with 3 additions and 4 deletions
+2 -3
View File
@@ -110,7 +110,7 @@ class TestUpDown(TestCase):
def test_concavity_of_returns(self):
"""verify concave relationship between of free parameter and
"""verify concave relationship between free parameter and
returns in certain region around the max. Moreover,
establishes that the max returns is at the correct value
(i.e. 0).
@@ -169,7 +169,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
@@ -200,7 +200,6 @@ class TestUpDown(TestCase):
self.zipline_test_config['environment'] = trading_environment
zipline = SimulatedTrading.create_test_zipline(**self.zipline_test_config)
zipline.simulate(blocking=True)
zipline.shutdown()
#function is getting minimized, so have to return negative cum returns.
return -zipline.get_cumulative_performance()['returns']
+1 -1
View File
@@ -12,9 +12,9 @@ from zipline.finance.sources import SpecificEquityTrades
from zipline.optimize.algorithms import BuySellAlgorithm
from zipline.lines import SimulatedTrading
from copy import deepcopy
from itertools import cycle
def create_updown_trade_source(sid, trade_count, trading_environment, start_price, amplitude):
from itertools import cycle
volume = 1000
events = []
price = start_price-amplitude/2.