@@ -381,8 +381,6 @@ cdef class ExecAlgorithm(Actor):
381
381
382
382
Raises
383
383
------
384
- ValueError
385
- If `primary.status` is not ``INITIALIZED``.
386
384
ValueError
387
385
If `primary.exec_algorithm_id` is not equal to `self.id`.
388
386
ValueError
@@ -393,7 +391,6 @@ cdef class ExecAlgorithm(Actor):
393
391
"""
394
392
Condition.not_none(primary, " primary" )
395
393
Condition.not_none(quantity, " quantity" )
396
- Condition.equal(primary.status, OrderStatus.INITIALIZED, " primary.status" , " order_status" )
397
394
Condition.equal(primary.exec_algorithm_id, self .id, " primary.exec_algorithm_id" , " id" )
398
395
399
396
if reduce_primary:
@@ -468,8 +465,6 @@ cdef class ExecAlgorithm(Actor):
468
465
469
466
Raises
470
467
------
471
- ValueError
472
- If `primary.status` is not ``INITIALIZED``.
473
468
ValueError
474
469
If `primary.exec_algorithm_id` is not equal to `self.id`.
475
470
ValueError
@@ -482,7 +477,6 @@ cdef class ExecAlgorithm(Actor):
482
477
"""
483
478
Condition.not_none(primary, " primary" )
484
479
Condition.not_none(quantity, " quantity" )
485
- Condition.equal(primary.status, OrderStatus.INITIALIZED, " primary.status" , " order_status" )
486
480
Condition.equal(primary.exec_algorithm_id, self .id, " primary.exec_algorithm_id" , " id" )
487
481
488
482
if reduce_primary:
@@ -556,8 +550,6 @@ cdef class ExecAlgorithm(Actor):
556
550
557
551
Raises
558
552
------
559
- ValueError
560
- If `primary.status` is not ``INITIALIZED``.
561
553
ValueError
562
554
If `primary.exec_algorithm_id` is not equal to `self.id`.
563
555
ValueError
@@ -570,7 +562,6 @@ cdef class ExecAlgorithm(Actor):
570
562
"""
571
563
Condition.not_none(primary, " primary" )
572
564
Condition.not_none(quantity, " quantity" )
573
- Condition.equal(primary.status, OrderStatus.INITIALIZED, " primary.status" , " order_status" )
574
565
Condition.equal(primary.exec_algorithm_id, self .id, " primary.exec_algorithm_id" , " id" )
575
566
576
567
if reduce_primary:
@@ -679,6 +670,13 @@ cdef class ExecAlgorithm(Actor):
679
670
680
671
# Handle primary (original) order
681
672
primary_command = self .cache.load_submit_order_command(order.client_order_id)
673
+ cdef Order cached_order = self .cache.order(order.client_order_id)
674
+ if cached_order.order_type != order.order_type:
675
+ self .cache.add_order(order, primary_command.position_id, override = True )
676
+
677
+ # Replace commands order with transformed order
678
+ primary_command.order = order
679
+
682
680
Condition.equal(order.strategy_id, primary_command.strategy_id, " order.strategy_id" , " primary_command.strategy_id" )
683
681
if primary_command is None :
684
682
self ._log.error(
@@ -779,7 +777,7 @@ cdef class ExecAlgorithm(Actor):
779
777
return # Cannot send command
780
778
781
779
cdef OrderPendingUpdate event
782
- if not order.is_emulated_c():
780
+ if order.status ! = OrderStatus.INITIALIZED and not order.is_emulated_c():
783
781
# Generate and apply event
784
782
event = self ._generate_order_pending_update(order)
785
783
try :
@@ -942,7 +940,7 @@ cdef class ExecAlgorithm(Actor):
942
940
return # Cannot send command
943
941
944
942
cdef OrderPendingCancel event
945
- if not order.is_emulated_c():
943
+ if order.status ! = OrderStatus.INITIALIZED and not order.is_emulated_c():
946
944
# Generate and apply event
947
945
event = self ._generate_order_pending_cancel(order)
948
946
try :
0 commit comments