Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 2a1f33c

Browse filesBrowse files
committed
DEPR: Remove old deprecation
1 parent 054d453 commit 2a1f33c
Copy full SHA for 2a1f33c

2 files changed

+4-23Lines changed: 4 additions & 23 deletions

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎backtesting/backtesting.py‎

Copy file name to clipboardExpand all lines: backtesting/backtesting.py
+1-22Lines changed: 1 addition & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,7 @@ def position(self) -> 'Position':
312312
@property
313313
def orders(self) -> 'Tuple[Order, ...]':
314314
"""List of orders (see `Order`) waiting for execution."""
315-
return _Orders(self._broker.orders)
315+
return tuple(self._broker.orders)
316316

317317
@property
318318
def trades(self) -> 'Tuple[Trade, ...]':
@@ -325,27 +325,6 @@ def closed_trades(self) -> 'Tuple[Trade, ...]':
325325
return tuple(self._broker.closed_trades)
326326

327327

328-
class _Orders(tuple):
329-
"""
330-
TODO: remove this class. Only for deprecation.
331-
"""
332-
def cancel(self):
333-
"""Cancel all non-contingent (i.e. SL/TP) orders."""
334-
for order in self:
335-
if not order.is_contingent:
336-
order.cancel()
337-
338-
def __getattr__(self, item):
339-
# TODO: Warn on deprecations from the previous version. Remove in the next.
340-
removed_attrs = ('entry', 'set_entry', 'is_long', 'is_short',
341-
'sl', 'tp', 'set_sl', 'set_tp')
342-
if item in removed_attrs:
343-
raise AttributeError(f'Strategy.orders.{"/.".join(removed_attrs)} were removed in'
344-
'Backtesting 0.2.0. '
345-
'Use `Order` API instead. See docs.')
346-
raise AttributeError(f"'tuple' object has no attribute {item!r}")
347-
348-
349328
class Position:
350329
"""
351330
Currently held asset position, available as
Collapse file

‎backtesting/test/_test.py‎

Copy file name to clipboardExpand all lines: backtesting/test/_test.py
+3-1Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,9 @@ def next(self, _FEW_DAYS=pd.Timedelta('3 days')): # noqa: N803
173173
self.position.is_long
174174

175175
if crossover(self.sma, self.data.Close):
176-
self.orders.cancel() # cancels only non-contingent
176+
for order in self.orders:
177+
if not order.is_contingent:
178+
order.cancel()
177179
price = self.data.Close[-1]
178180
sl, tp = 1.05 * price, .9 * price
179181

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.