@@ -882,9 +882,7 @@ def next(self):
882882
883883 def _process_orders (self ):
884884 data = self ._data
885- open_price = data ._current_value ("Open" )
886- high_price = data ._current_value ("High" )
887- low_price = data ._current_value ("Low" )
885+ open , high , low = data ._current_value ("Open" ), data ._current_value ("High" ), data ._current_value ("Low" )
888886 reprocess_orders = False
889887
890888 # Process orders
@@ -898,7 +896,7 @@ def _process_orders(self):
898896 stop_price = order .stop
899897 if stop_price :
900898 is_stop_hit = (
901- high_price >= stop_price if order .is_long else low_price <= stop_price
899+ high >= stop_price if order .is_long else low <= stop_price
902900 )
903901 if not is_stop_hit :
904902 continue
@@ -911,7 +909,7 @@ def _process_orders(self):
911909 # Check if limit order can be filled.
912910 if order .limit :
913911 is_limit_hit = (
914- low_price <= order .limit if order .is_long else high_price >= order .limit
912+ low <= order .limit if order .is_long else high >= order .limit
915913 )
916914 # When stop and limit are hit within the same bar, we pessimistically
917915 # assume limit was hit before the stop (i.e. "before it counts")
@@ -924,9 +922,9 @@ def _process_orders(self):
924922
925923 # stop_price, if set, was hit within this bar
926924 price = (
927- min (stop_price or open_price , order .limit )
925+ min (stop_price or open , order .limit )
928926 if order .is_long
929- else max (stop_price or open_price , order .limit )
927+ else max (stop_price or open , order .limit )
930928 )
931929 else :
932930 # Market-if-touched / market order
@@ -935,7 +933,7 @@ def _process_orders(self):
935933 price = (
936934 prev_close
937935 if self ._trade_on_close and not order .is_contingent
938- else open_price
936+ else open
939937 )
940938 if stop_price :
941939 price = max (price , stop_price ) if order .is_long else min (price , stop_price )
@@ -1054,20 +1052,20 @@ def _process_orders(self):
10541052 and (
10551053 (
10561054 order .is_long
1057- and order .tp <= high_price
1058- and (order .sl or - np .inf ) < low_price
1055+ and order .tp <= high
1056+ and (order .sl or - np .inf ) < low
10591057 )
10601058 or (
10611059 order .is_short
1062- and order .tp >= low_price
1063- and (order .sl or np .inf ) > high_price
1060+ and order .tp >= low
1061+ and (order .sl or np .inf ) > high
10641062 )
10651063 )
10661064 ):
10671065 reprocess_orders = True
10681066 elif (
1069- low_price <= (order .sl or - np .inf ) <= high_price
1070- or low_price <= (order .tp or - np .inf ) <= high_price
1067+ low <= (order .sl or - np .inf ) <= high
1068+ or low <= (order .tp or - np .inf ) <= high
10711069 ):
10721070 warnings .warn (
10731071 f"({ data .index [- 1 ]} ) A contingent SL/TP order would execute in the "
0 commit comments