mirror of
https://github.com/wassname/catalyst.git
synced 2026-10-02 12:10:23 +08:00
Fixed floating-point error in volume share slippage model
This commit is contained in:
1 parent
149309d4af
commit
1b2f6739e9
1 file changed
+9
-1
@@ -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