From 56a993bfc6a7f547558e5ad0b89f36fed43df8a9 Mon Sep 17 00:00:00 2001 From: Richard Frank Date: Fri, 5 May 2017 09:47:56 -0400 Subject: [PATCH] BUG: Fixed abstractness of MarketImpactBase --- tests/finance/test_slippage.py | 3 +-- zipline/finance/slippage.py | 20 ++++++++++---------- 2 files changed, 11 insertions(+), 12 deletions(-) diff --git a/tests/finance/test_slippage.py b/tests/finance/test_slippage.py index 1a9280f1..e8812ec2 100644 --- a/tests/finance/test_slippage.py +++ b/tests/finance/test_slippage.py @@ -32,7 +32,6 @@ from zipline.finance.asset_restrictions import NoRestrictions from zipline.finance.order import Order from zipline.finance.slippage import ( fill_price_worse_than_limit_price, - MarketImpactBase, NO_DATA_VOLATILITY_SLIPPAGE_IMPACT, VolatilityVolumeShare, VolumeShareSlippage, @@ -875,7 +874,7 @@ class MarketImpactTestCase(WithCreateBarData, ZiplineTestCase): data = self.create_bardata(simulation_dt_func=lambda: minute) asset = self.asset_finder.retrieve_asset(1) - mean_volume, volatility = MarketImpactBase()._get_window_data( + mean_volume, volatility = VolatilityVolumeShare(0.0)._get_window_data( data, asset, window_length=20, ) diff --git a/zipline/finance/slippage.py b/zipline/finance/slippage.py index 983f30ab..208e1db3 100644 --- a/zipline/finance/slippage.py +++ b/zipline/finance/slippage.py @@ -291,7 +291,7 @@ class FixedSlippage(SlippageModel): ) -class MarketImpactBase(object): +class MarketImpactBase(SlippageModel): """ Base class for slippage models which compute a simulated price impact according to a history lookback. @@ -318,13 +318,13 @@ class MarketImpactBase(object): raise NotImplementedError('get_txn_volume') @abstractmethod - def simulated_impact(self, - order, - current_price, - current_volume, - txn_volume, - mean_volume, - volatility): + def get_simulated_impact(self, + order, + current_price, + current_volume, + txn_volume, + mean_volume, + volatility): """ Calculate simulated price impact. @@ -341,7 +341,7 @@ class MarketImpactBase(object): ------ int : impact on the current price. """ - raise NotImplementedError('simulated_impact') + raise NotImplementedError('get_simulated_impact') def process_order(self, data, order): if order.open_amount == 0: @@ -430,7 +430,7 @@ class MarketImpactBase(object): return values['volume'], values['close'] -class VolatilityVolumeShare(MarketImpactBase, FutureSlippageModel): +class VolatilityVolumeShare(MarketImpactBase): """ Model slippage for futures contracts according to the following formula: