mirror of
https://github.com/wassname/catalyst.git
synced 2026-07-04 12:46:12 +08:00
Fixed floating-point error in volume share slippage model
This commit is contained in:
@@ -108,7 +108,15 @@ class VolumeShareSlippage(object):
|
||||
|
||||
volume_share = min(direction * (desired_order) / event.volume,
|
||||
self.volume_limit)
|
||||
simulated_amount = int(volume_share * event.volume * direction)
|
||||
|
||||
if volume_share == self.volume_limit:
|
||||
simulated_amount = \
|
||||
int(self.volume_limit * event.volume * direction)
|
||||
else:
|
||||
# we can fill the entire desired order
|
||||
# let's not deal with floating-point errors
|
||||
simulated_amount = desired_order
|
||||
|
||||
simulated_impact = (volume_share) ** 2 \
|
||||
* self.price_impact * direction * event.price
|
||||
|
||||
|
||||
Reference in New Issue
Block a user