kissbt 0.1.3__tar.gz → 0.1.5__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: kissbt
3
- Version: 0.1.3
3
+ Version: 0.1.5
4
4
  Summary: The keep it simple backtesting framework for Python.
5
5
  Author-email: Adrian Hasse <adrian.hasse@finblobs.com>
6
6
  Maintainer-email: Adrian Hasse <adrian.hasse@finblobs.com>
@@ -376,7 +376,7 @@ class Broker:
376
376
  # sell assets out of universe, we use close price of previous bar, since this is
377
377
  # the last price we know
378
378
  ticker_out_of_universe = set()
379
- if self._previous_bar.empty:
379
+ if not self._previous_bar.empty:
380
380
  ticker_out_of_universe = set(self._open_positions.keys()) - set(
381
381
  self._current_bar.index
382
382
  )
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: kissbt
3
- Version: 0.1.3
3
+ Version: 0.1.5
4
4
  Summary: The keep it simple backtesting framework for Python.
5
5
  Author-email: Adrian Hasse <adrian.hasse@finblobs.com>
6
6
  Maintainer-email: Adrian Hasse <adrian.hasse@finblobs.com>
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "kissbt"
7
- version = "0.1.3"
7
+ version = "0.1.5"
8
8
  description = "The keep it simple backtesting framework for Python."
9
9
  readme = "README.md"
10
10
  authors = [
@@ -351,3 +351,23 @@ def test_update_open_positions_cases(
351
351
  else:
352
352
  assert broker._open_positions["AAPL"].size == expected_size
353
353
  assert broker._open_positions["AAPL"].price == pytest.approx(expected_price)
354
+
355
+
356
+ def test_update_ticker_out_of_universe(broker):
357
+ broker._open_positions["AAPL"] = OpenPosition("AAPL", 10, 100, datetime(2024, 1, 1))
358
+
359
+ broker.update(
360
+ pd.DataFrame({"close": [100, 500]}, index=["GOOG", "AAPL"]),
361
+ datetime(2024, 1, 2),
362
+ )
363
+
364
+ broker.update(pd.DataFrame({"close": [110]}, index=["GOOG"]), datetime(2024, 1, 3))
365
+
366
+ assert len(broker._closed_positions) == 1
367
+ closed_pos = broker._closed_positions[0]
368
+ assert closed_pos.ticker == "AAPL"
369
+ assert closed_pos.size == 10
370
+ assert closed_pos.purchase_price == 100
371
+ assert closed_pos.selling_price == 500
372
+ assert closed_pos.purchase_datetime == datetime(2024, 1, 1)
373
+ assert closed_pos.selling_datetime == datetime(2024, 1, 2)
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes