BUG: Fixed abstractness of MarketImpactBase

This commit is contained in:
Richard Frank
2017-05-05 09:47:56 -04:00
parent a1d055abb1
commit 56a993bfc6
2 changed files with 11 additions and 12 deletions
+1 -2
View File
@@ -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,
)
+10 -10
View File
@@ -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: