Skip to content

Commit 374eeef

Browse files
committed
Change .tag docstrings
1 parent 49b5897 commit 374eeef

File tree

1 file changed

+12
-15
lines changed

1 file changed

+12
-15
lines changed

backtesting/backtesting.py

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@ class Strategy(metaclass=ABCMeta):
4949
`backtesting.backtesting.Strategy.next` to define
5050
your own strategy.
5151
"""
52-
5352
def __init__(self, broker, data, params):
5453
self._indicators = []
5554
self._broker: _Broker = broker
@@ -292,7 +291,6 @@ class _Orders(tuple):
292291
"""
293292
TODO: remove this class. Only for deprecation.
294293
"""
295-
296294
def cancel(self):
297295
"""Cancel all non-contingent (i.e. SL/TP) orders."""
298296
for order in self:
@@ -320,7 +318,6 @@ class Position:
320318
if self.position:
321319
... # we have a position, either long or short
322320
"""
323-
324321
def __init__(self, broker: '_Broker'):
325322
self.__broker = broker
326323

@@ -385,7 +382,6 @@ class Order:
385382
[filled]: https://www.investopedia.com/terms/f/fill.asp
386383
[Good 'Til Canceled]: https://www.investopedia.com/terms/g/gtc.asp
387384
"""
388-
389385
def __init__(self, broker: '_Broker',
390386
size: float,
391387
limit_price: Optional[float] = None,
@@ -491,11 +487,10 @@ def parent_trade(self):
491487
return self.__parent_trade
492488

493489
@property
494-
def tag(self) -> Optional[object]:
490+
def tag(self):
495491
"""
496-
An attribute which, if set, persists to enable tracking of this order
497-
by an external identifier if it becomes a trade in `Strategy.trades`
498-
and when closed in `Strategy.closed_trades`.
492+
Arbitrary value (such as a string) which, if set, enables tracking
493+
of this order and the associated `Trade` (see `Trade.tag`).
499494
"""
500495
return self.__tag
501496

@@ -533,8 +528,7 @@ class Trade:
533528
When an `Order` is filled, it results in an active `Trade`.
534529
Find active trades in `Strategy.trades` and closed, settled trades in `Strategy.closed_trades`.
535530
"""
536-
537-
def __init__(self, broker: '_Broker', size: int, entry_price: float, entry_bar, tag: object):
531+
def __init__(self, broker: '_Broker', size: int, entry_price: float, entry_bar, tag):
538532
self.__broker = broker
539533
self.__size = size
540534
self.__entry_price = entry_price
@@ -596,11 +590,15 @@ def exit_bar(self) -> Optional[int]:
596590
return self.__exit_bar
597591

598592
@property
599-
def tag(self) -> Optional[object]:
593+
def tag(self):
600594
"""
601-
A tag attribute optionally set when placing an order with
602-
`Strategy.buy()` or `Strategy.sell()`.
603-
See `Order.tag`.
595+
A tag value inherited from the `Order` that opened
596+
this trade.
597+
598+
This can be used to track trades and apply conditional
599+
logic / subgroup analysis.
600+
601+
See also `Order.tag`.
604602
"""
605603
return self.__tag
606604

@@ -1023,7 +1021,6 @@ class Backtest:
10231021
instance, or `backtesting.backtesting.Backtest.optimize` to
10241022
optimize it.
10251023
"""
1026-
10271024
def __init__(self,
10281025
data: pd.DataFrame,
10291026
strategy: Type[Strategy],

0 commit comments

Comments
 (0)