Skip to content

Commit f886b97

Browse files
committed
attempt to fix tests, tweak requirements
more adjustments bump python versions copypasta restrict matplotlib version for ffn compat use date_range for newer pandas compat
1 parent 3085ff9 commit f886b97

File tree

6 files changed

+36
-18
lines changed

6 files changed

+36
-18
lines changed

.travis.yml

+7-3
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
language: python
22
python:
33
- "2.7"
4-
- "3.4"
5-
- "3.5"
64
- "3.6"
5+
- "3.7"
6+
- "3.8"
7+
78
# command to install dependencies
89
install:
9-
- pip install -r requirements.txt
10+
- pip install -e .[dev]
11+
1012
# deploys to pypi
1113
deploy:
1214
provider: pypi
@@ -18,9 +20,11 @@ deploy:
1820
distributions: sdist
1921
repo: pmorissette/bt
2022
branch: master
23+
2124
# command to run tests
2225
script:
2326
- nosetests --with-coverage --cover-package bt
27+
2428
# command to run codecov coverage
2529
after_success:
2630
- codecov

bt/algos.py

+4-3
Original file line numberDiff line numberDiff line change
@@ -1254,7 +1254,7 @@ def __call__(self, target):
12541254
index=covar.columns
12551255
)
12561256

1257-
vol = np.sqrt(np.matmul(weights.values.T,np.matmul(covar,weights.values))*self.annualization_factor)
1257+
vol = np.sqrt(np.matmul(weights.values.T,np.matmul(covar.values, weights.values))*self.annualization_factor)
12581258

12591259
#vol is too high
12601260
if vol > self.target_volatility:
@@ -1350,11 +1350,12 @@ def __call__(self, target):
13501350
covar = returns.cov()
13511351
else:
13521352
raise NotImplementedError('covar_method not implemented')
1353-
1354-
PTE_vol = np.sqrt(np.matmul(weights.values.T, np.matmul(covar, weights.values)) * self.annualization_factor)
1353+
1354+
PTE_vol = np.sqrt(np.matmul(weights.values.T, np.matmul(covar.values, weights.values)) * self.annualization_factor)
13551355

13561356
if pd.isnull(PTE_vol):
13571357
return False
1358+
13581359
# vol is too high
13591360
if PTE_vol > self.PTE_volatility_cap:
13601361
return True

pyproject.toml

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[build-system]
2+
# Minimum requirements for the build system to execute.
3+
requires = ["setuptools", "wheel", "cython>0.25"]

requirements.txt

+6-9
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
1-
cython
1+
cython>=0.25
22
future
3-
numpy
4-
pandas
5-
matplotlib
6-
ffn
7-
pyprind
8-
ipython
9-
coverage
10-
codecov
3+
numpy>=1
4+
pandas>=0.19
5+
matplotlib>=2
6+
ffn>=0.3.4
7+
pyprind>=2.11

setup.py

+15-2
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,22 @@ def local_file(filename):
4141
keywords='python finance quant backtesting strategies',
4242
url='https://github.com/pmorissette/bt',
4343
install_requires=[
44-
'ffn',
44+
'ffn>=0.3.4',
4545
'pyprind>=2.10'
4646
],
47+
extras_require={
48+
'dev': [
49+
'codecov',
50+
'coverage',
51+
'cython>=0.25',
52+
'future',
53+
'numpy>=1',
54+
'pandas>=0.19',
55+
'matplotlib>=2,<3',
56+
'ffn>=0.3.4',
57+
'pyprind>=2.11',
58+
],
59+
},
4760
packages=['bt'],
4861
long_description=local_file('README.rst').read(),
4962
classifiers=[
@@ -52,5 +65,5 @@ def local_file(filename):
5265
'Programming Language :: Python'
5366
],
5467
ext_modules=ext_modules,
55-
python_requires='>=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*'
68+
python_requires='>=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*, !=3.5.*'
5669
)

tests/test_core.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -2085,7 +2085,7 @@ def test_securitybase_allocate():
20852085

20862086
def test_securitybase_allocate_commisions():
20872087

2088-
date_span = pd.DatetimeIndex(start='10/1/2017', end='10/11/2017', freq='B')
2088+
date_span = pd.date_range(start='10/1/2017', end='10/11/2017', freq='B')
20892089
numper = len(date_span.values)
20902090
comms = 0.01
20912091

0 commit comments

Comments
 (0)