Repository: liampauling/flumine
Pull request #315 (2020-11-04 09:14:01)

pass correct size into create replace order based on api response (th…
…anks @Jonjonjon)


Patch:
diff --git a/HISTORY.rst b/HISTORY.rst
index 7434958..e724902 100644
--- a/HISTORY.rst
+++ b/HISTORY.rst
@@ -3,20 +3,6 @@
 Release History
 ---------------
 
-1.14.4 (2020-11-04)
-+++++++++++++++++++
-
-**Improvements**
-
-- #310 typing update and bool return added on stream
-- add min_bet_validation flag to prevent control checking min size
-
-**Bug Fixes**
-
-- filters out violated orders from being used to calculate the selection exposure (@lunswor)
-- handle simulated cancel when size reduction is larger than size remaining
-- pass correct size into create replace order based on api response
-
 1.14.3 (2020-11-02)
 +++++++++++++++++++
 
diff --git a/flumine/__version__.py b/flumine/__version__.py
index 7dd489f..f60c1a1 100644
--- a/flumine/__version__.py
+++ b/flumine/__version__.py
@@ -1,6 +1,6 @@
 __title__ = "flumine"
 __description__ = "Betfair trading framework"
 __url__ = "https://github.com/liampauling/flumine"
-__version__ = "1.14.4"
+__version__ = "1.14.3"
 __author__ = "Liam Pauling"
 __license__ = "MIT"
diff --git a/flumine/execution/betfairexecution.py b/flumine/execution/betfairexecution.py
index e1416ba..f3fda72 100644
--- a/flumine/execution/betfairexecution.py
+++ b/flumine/execution/betfairexecution.py
@@ -156,6 +156,7 @@ class BetfairExecution(BaseExecution):
                         replacement_order = order.trade.create_order_replacement(
                             order,
                             instruction_report.place_instruction_reports.instruction.limit_order.price,
+                            instruction_report.place_instruction_reports.instruction.limit_order.size,
                         )
                         self._order_logger(
                             replacement_order,
diff --git a/flumine/execution/simulatedexecution.py b/flumine/execution/simulatedexecution.py
index c7c3b39..8c3f75d 100644
--- a/flumine/execution/simulatedexecution.py
+++ b/flumine/execution/simulatedexecution.py
@@ -117,7 +117,9 @@ class SimulatedExecution(BaseExecution):
                 # place new order
                 self._bet_id += 1
                 replacement_order = order.trade.create_order_replacement(
-                    order, instruction.get("newPrice")
+                    order,
+                    instruction.get("newPrice"),
+                    cancel_instruction_report.size_cancelled,
                 )
                 place_instruction_report = replacement_order.simulated.place(
                     order_package.client, market.market_book, instruction, self._bet_id
diff --git a/flumine/order/trade.py b/flumine/order/trade.py
index 90a583c..353b37a 100644
--- a/flumine/order/trade.py
+++ b/flumine/order/trade.py
@@ -103,13 +103,13 @@ class Trade:
         return order
 
     def create_order_replacement(
-        self, order: BetfairOrder, new_price: float
+        self, order: BetfairOrder, new_price: float, size: float
     ) -> BetfairOrder:
         """Create new order due to replace
         execution"""
         order_type = LimitOrder(
             price=new_price,
-            size=order.order_type.size,
+            size=size,
             persistence_type=order.order_type.persistence_type,
         )
         order = BetfairOrder(


Test patch:
diff --git a/tests/test_trade.py b/tests/test_trade.py
index 8130bf0..95eb0eb 100644
--- a/tests/test_trade.py
+++ b/tests/test_trade.py
@@ -111,7 +111,7 @@ class TradeTest(unittest.TestCase):
 
     def test_create_order_replacement(self):
         mock_order = mock.Mock()
-        replacement_order = self.trade.create_order_replacement(mock_order, 12)
+        replacement_order = self.trade.create_order_replacement(mock_order, 12, 2.00)
         self.assertEqual(self.trade.orders, [replacement_order])
 
     def test_create_order_from_current_limit(self):