Skip to content

Commit 4c59e15

Browse files
Updated pypi package to qstrader 0.3.0 (#399)
1 parent f26d8c5 commit 4c59e15

File tree

7 files changed

+24
-16
lines changed

7 files changed

+24
-16
lines changed

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
# 0.3.0
2+
3+
* Updates dependencies to use numpy v2.0.0.
4+
* Updates simulated_broker.py to change np.NaN to np.nan
5+
* Updates backtest_data_handler.py to change np.NaN to np.nan
6+
* Updates daily_bar_csv.py to change np.NaN to np.nan
7+
* Updates tests
8+
19
# 0.2.9
210

311
* Updates requirements file to use numpy v1.26.4 or lower. This is the last version of QSTrader that supports numpy<2.0.0.

pyproject.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@ build-backend = "hatchling.build"
44

55
[project]
66
name = "qstrader"
7-
version = "0.2.9"
7+
version = "0.3.0"
88
dependencies = [
99
"click>=8.1",
1010
"matplotlib>=3.8",
11-
"numpy<=1.26.4",
11+
"numpy>=2.0.0",
1212
"pandas>=2.2",
1313
"seaborn>=0.13",
1414
]

qstrader/broker/simulated_broker.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -567,7 +567,7 @@ def _execute_order(self, dt, portfolio_id, order):
567567
bid_ask = self.data_handler.get_asset_latest_bid_ask_price(
568568
dt, order.asset
569569
)
570-
if bid_ask == (np.NaN, np.NaN):
570+
if bid_ask == (np.nan, np.nan):
571571
raise ValueError(price_err_msg)
572572

573573
# Calculate the consideration and total commission

qstrader/data/backtest_data_handler.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,28 +17,28 @@ def get_asset_latest_bid_price(self, dt, asset_symbol):
1717
"""
1818
"""
1919
# TODO: Check for asset in Universe
20-
bid = np.NaN
20+
bid = np.nan
2121
for ds in self.data_sources:
2222
try:
2323
bid = ds.get_bid(dt, asset_symbol)
2424
if not np.isnan(bid):
2525
return bid
2626
except Exception:
27-
bid = np.NaN
27+
bid = np.nan
2828
return bid
2929

3030
def get_asset_latest_ask_price(self, dt, asset_symbol):
3131
"""
3232
"""
3333
# TODO: Check for asset in Universe
34-
ask = np.NaN
34+
ask = np.nan
3535
for ds in self.data_sources:
3636
try:
3737
ask = ds.get_ask(dt, asset_symbol)
3838
if not np.isnan(ask):
3939
return ask
4040
except Exception:
41-
ask = np.NaN
41+
ask = np.nan
4242
return ask
4343

4444
def get_asset_latest_bid_ask_price(self, dt, asset_symbol):
@@ -61,7 +61,7 @@ def get_asset_latest_mid_price(self, dt, asset_symbol):
6161
mid = (bid_ask[0] + bid_ask[1]) / 2.0
6262
except Exception:
6363
# TODO: Log this
64-
mid = np.NaN
64+
mid = np.nan
6565
return mid
6666

6767
def get_assets_historical_range_close_price(

qstrader/data/daily_bar_csv.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ def get_bid(self, dt, asset):
219219
try:
220220
bid = bid_series.iloc[0]
221221
except KeyError: # Before start date
222-
return np.NaN
222+
return np.nan
223223
return bid
224224

225225
@functools.lru_cache(maxsize=1024 * 1024)
@@ -244,7 +244,7 @@ def get_ask(self, dt, asset):
244244
try:
245245
ask = ask_series.iloc[0]
246246
except KeyError: # Before start date
247-
return np.NaN
247+
return np.nan
248248
return ask
249249

250250
def get_assets_historical_closes(self, start_dt, end_dt, assets):

requirements/base.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
click>=8.0
22
matplotlib>=3.8
3-
numpy<=1.26.4
3+
numpy>=2.0.0
44
pandas>=2.2
55
seaborn>=0.13

tests/unit/broker/test_simulated_broker.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
class ExchangeMock(object):
1515
def get_latest_asset_bid_ask(self, asset):
16-
return (np.NaN, np.NaN)
16+
return (np.nan, np.nan)
1717

1818
def is_open_at_datetime(self, dt):
1919
return True
@@ -34,10 +34,10 @@ def is_open_at_datetime(self, dt):
3434

3535
class DataHandlerMock(object):
3636
def get_asset_latest_bid_ask_price(self, dt, asset):
37-
return (np.NaN, np.NaN)
37+
return (np.nan, np.nan)
3838

3939
def get_asset_latest_mid_price(self, dt, asset):
40-
return np.NaN
40+
return np.nan
4141

4242

4343
class DataHandlerMockPrice(object):
@@ -570,7 +570,7 @@ def test_submit_order():
570570
"""
571571
Tests the execute_order method for:
572572
* Raises ValueError if no portfolio_id
573-
* Raises ValueError if bid/ask is (np.NaN, np.NaN)
573+
* Raises ValueError if bid/ask is (np.nan, np.nan)
574574
* Checks that bid/ask are correctly set dependent
575575
upon order direction
576576
* Checks that portfolio values are correct after
@@ -589,7 +589,7 @@ def test_submit_order():
589589
with pytest.raises(KeyError):
590590
sb.submit_order("1234", order)
591591

592-
# Raises ValueError if bid/ask is (np.NaN, np.NaN)
592+
# Raises ValueError if bid/ask is (np.nan, np.nan)
593593
exchange_exception = ExchangeMockException()
594594
sbnp = SimulatedBroker(start_dt, exchange_exception, data_handler)
595595
sbnp.create_portfolio(portfolio_id=1234, name="My Portfolio #1")

0 commit comments

Comments
 (0)