mirror of
https://github.com/wassname/catalyst.git
synced 2026-07-16 11:18:11 +08:00
MAINT: Make usage of absolute`value more clear in slippage.
Instead of using copysign with a param of 1, use `abs` to make the code more clear between when slippage is using the absolute value, and when it is creating an amount that uses the order direction.
This commit is contained in:
@@ -106,7 +106,7 @@ def create_transaction(event, order, price, amount):
|
||||
# floor the amount to protect against non-whole number orders
|
||||
# TODO: Investigate whether we can add a robust check in blotter
|
||||
# and/or tradesimulation, as well.
|
||||
amount_magnitude = int(math.copysign(amount, 1))
|
||||
amount_magnitude = int(abs(amount))
|
||||
|
||||
if amount_magnitude < 1:
|
||||
raise Exception("Transaction magnitude must be at least 1.")
|
||||
@@ -155,7 +155,7 @@ class SlippageModel(object):
|
||||
|
||||
if txn:
|
||||
txns.append(txn)
|
||||
self._volume_for_bar += math.copysign(txn.amount, 1)
|
||||
self._volume_for_bar += abs(txn.amount)
|
||||
|
||||
return txns
|
||||
|
||||
|
||||
Reference in New Issue
Block a user