mirror of
https://github.com/wassname/catalyst.git
synced 2026-07-12 05:26:59 +08:00
Dummy.
This commit is contained in:
@@ -57,7 +57,7 @@ class TestUpDown(TestCase):
|
||||
base_price = self.zipline_test_config['base_price']
|
||||
amplitude = self.zipline_test_config['amplitude']
|
||||
|
||||
prices = np.array([event.price for event in config['trade_source'].event_list])
|
||||
prices = config['trade_source'][0].values
|
||||
max_price_idx = np.where(prices==prices.max())[0]
|
||||
min_price_idx = np.where(prices==prices.min())[0]
|
||||
self.assertTrue(np.all(max_price_idx % 2 == 1),
|
||||
@@ -73,7 +73,7 @@ class TestUpDown(TestCase):
|
||||
"Minimum price does not equal expected maximum price."
|
||||
)
|
||||
|
||||
zipline.simulate(blocking=True)
|
||||
zipline.run(config['trade_source'])
|
||||
|
||||
algo = config['algorithm']
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ from zipline.protocol import DATASOURCE_TYPE
|
||||
from zipline import ndict
|
||||
from zipline.utils.factory import create_trading_environment
|
||||
from zipline.gens.transform import StatefulTransform
|
||||
from zipline.lines import SimulatedTrading
|
||||
from zipline.lines import SimulatedTradingLite
|
||||
|
||||
class BuySellAlgorithm(object):
|
||||
"""Algorithm that buys and sells alternatingly. The amount for
|
||||
@@ -46,6 +46,9 @@ class BuySellAlgorithm(object):
|
||||
def set_portfolio(self, portfolio):
|
||||
self.portfolio = portfolio
|
||||
|
||||
def set_logger(self, logger):
|
||||
self.logger = logger
|
||||
|
||||
def handle_data(self, frame):
|
||||
order_size = self.buy_or_sell * (self.amount - (self.offset**2))
|
||||
self.order(self.sid, order_size)
|
||||
@@ -83,21 +86,15 @@ class TradingAlgorithm(object):
|
||||
|
||||
transforms.append(sf)
|
||||
|
||||
results_socket_uri = None
|
||||
context = None
|
||||
sim_id = None
|
||||
|
||||
style = SIMULATION_STYLE.FIXED_SLIPPAGE
|
||||
|
||||
self.simulated_trading = SimulatedTrading(
|
||||
self.simulated_trading = SimulatedTradingLite(
|
||||
[self.source],
|
||||
transforms,
|
||||
self,
|
||||
environment,
|
||||
style,
|
||||
results_socket_uri,
|
||||
context,
|
||||
sim_id)
|
||||
|
||||
style)
|
||||
#self.simulated_trading.trading_client.performance_tracker.compute_risk_metrics = compute_risk_metrics
|
||||
|
||||
|
||||
@@ -122,7 +119,7 @@ class TradingAlgorithm(object):
|
||||
self._setup(compute_risk_metrics=compute_risk_metrics)
|
||||
|
||||
# drain simulated_trading
|
||||
perfs = [perf for perf in self.simulated_trading]
|
||||
perfs = list(self.simulated_trading)
|
||||
|
||||
daily_stats = self._create_daily_stats(perfs)
|
||||
return daily_stats
|
||||
|
||||
Reference in New Issue
Block a user