Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MAINT: fix error messages for set_(commission|slippage) #923

Merged
merged 1 commit into from Dec 22, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 4 additions & 4 deletions zipline/algorithm.py
Expand Up @@ -39,11 +39,11 @@
HistoryInInitialize,
NoSuchPipeline,
OrderDuringInitialize,
OverrideCommissionPostInit,
OverrideSlippagePostInit,
PipelineOutputDuringInitialize,
RegisterAccountControlPostInit,
RegisterTradingControlPostInit,
SetCommissionPostInit,
SetSlippagePostInit,
UnsupportedCommissionModel,
UnsupportedDatetimeFormat,
UnsupportedOrderParameters,
Expand Down Expand Up @@ -1072,7 +1072,7 @@ def set_slippage(self, slippage):
if not isinstance(slippage, SlippageModel):
raise UnsupportedSlippageModel()
if self.initialized:
raise OverrideSlippagePostInit()
raise SetSlippagePostInit()
self.slippage = slippage

@api_method
Expand All @@ -1081,7 +1081,7 @@ def set_commission(self, commission):
raise UnsupportedCommissionModel()

if self.initialized:
raise OverrideCommissionPostInit()
raise SetCommissionPostInit()
self.commission = commission

@api_method
Expand Down
22 changes: 11 additions & 11 deletions zipline/errors.py
Expand Up @@ -41,22 +41,22 @@ class WrongDataForTransform(ZiplineError):

class UnsupportedSlippageModel(ZiplineError):
"""
Raised if a user script calls the override_slippage magic
Raised if a user script calls the set_slippage magic
with a slipage object that isn't a VolumeShareSlippage or
FixedSlipapge
"""
msg = """
You attempted to override slippage with an unsupported class. \
You attempted to set slippage with an unsupported class. \
Please use VolumeShareSlippage or FixedSlippage.
""".strip()


class OverrideSlippagePostInit(ZiplineError):
# Raised if a users script calls override_slippage magic
class SetSlippagePostInit(ZiplineError):
# Raised if a users script calls set_slippage magic
# after the initialize method has returned.
msg = """
You attempted to override slippage outside of `initialize`. \
You may only call override_slippage in your initialize method.
You attempted to set slippage outside of `initialize`. \
You may only call 'set_slippage' in your initialize method.
""".strip()


Expand All @@ -80,24 +80,24 @@ class RegisterAccountControlPostInit(ZiplineError):

class UnsupportedCommissionModel(ZiplineError):
"""
Raised if a user script calls the override_commission magic
Raised if a user script calls the set_commission magic
with a commission object that isn't a PerShare, PerTrade or
PerDollar commission
"""
msg = """
You attempted to override commission with an unsupported class. \
You attempted to set commission with an unsupported class. \
Please use PerShare or PerTrade.
""".strip()


class OverrideCommissionPostInit(ZiplineError):
class SetCommissionPostInit(ZiplineError):
"""
Raised if a users script calls override_commission magic
Raised if a users script calls set_commission magic
after the initialize method has returned.
"""
msg = """
You attempted to override commission outside of `initialize`. \
You may only call override_commission in your initialize method.
You may only call 'set_commission' in your initialize method.
""".strip()


Expand Down