@@ -49,6 +49,7 @@ class Strategy(metaclass=ABCMeta):
4949 `backtesting.backtesting.Strategy.next` to define
5050 your own strategy.
5151 """
52+
5253 def __init__ (self , broker , data , params ):
5354 self ._indicators = []
5455 self ._broker : _Broker = broker
@@ -291,6 +292,7 @@ class _Orders(tuple):
291292 """
292293 TODO: remove this class. Only for deprecation.
293294 """
295+
294296 def cancel (self ):
295297 """Cancel all non-contingent (i.e. SL/TP) orders."""
296298 for order in self :
@@ -318,6 +320,7 @@ class Position:
318320 if self.position:
319321 ... # we have a position, either long or short
320322 """
323+
321324 def __init__ (self , broker : '_Broker' ):
322325 self .__broker = broker
323326
@@ -382,6 +385,7 @@ class Order:
382385 [filled]: https://www.investopedia.com/terms/f/fill.asp
383386 [Good 'Til Canceled]: https://www.investopedia.com/terms/g/gtc.asp
384387 """
388+
385389 def __init__ (self , broker : '_Broker' ,
386390 size : float ,
387391 limit_price : Optional [float ] = None ,
@@ -415,7 +419,7 @@ def __repr__(self):
415419 ('tp' , self .__tp_price ),
416420 ('contingent' , self .is_contingent ),
417421 ('tag' , self .__tag ),
418- ) if value is not None ))
422+ ) if value is not None and isinstance ( value , Number ) ))
419423
420424 def cancel (self ):
421425 """Cancel the order."""
@@ -528,6 +532,7 @@ class Trade:
528532 When an `Order` is filled, it results in an active `Trade`.
529533 Find active trades in `Strategy.trades` and closed, settled trades in `Strategy.closed_trades`.
530534 """
535+
531536 def __init__ (self , broker : '_Broker' , size : int , entry_price : float , entry_bar , tag ):
532537 self .__broker = broker
533538 self .__size = size
@@ -1021,6 +1026,7 @@ class Backtest:
10211026 instance, or `backtesting.backtesting.Backtest.optimize` to
10221027 optimize it.
10231028 """
1029+
10241030 def __init__ (self ,
10251031 data : pd .DataFrame ,
10261032 strategy : Type [Strategy ],
0 commit comments