Skip to content

Commit 13675fb

Browse files
initial new test work; and play with subplot
1 parent 16252ab commit 13675fb

File tree

8 files changed

+932
-167
lines changed

8 files changed

+932
-167
lines changed
83.4 KB
Loading

examples/mpftests/test_addplot.py

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import os as os
2+
import pandas as pd
3+
import mplfinance as mpf
4+
import matplotlib.pyplot as plt
5+
6+
print('pd.__version__ =',pd.__version__ ) # for the record
7+
print('mpf.__version__ =',mpf.__version__) # for the record
8+
print("plt.rcParams['backend'] =",plt.rcParams['backend']) # for the record
9+
10+
import subprocess
11+
result = subprocess.run(['pwd'], stdout=subprocess.PIPE)
12+
print('result.stdout=',result.stdout)
13+
14+
15+
df = pd.read_csv('../data/SPY_20110701_20120630_Bollinger.csv',index_col=0,parse_dates=True)
16+
print('df.shape=' , df.shape )
17+
print('df.head(3)=', df.head(3))
18+
print('df.tail(3)=', df.tail(3))
19+
20+
21+
mpf.plot(df,volume=True,savefig='test01.jpg')
22+
23+
os.system('ls -l test01.jpg')
24+
25+
rc = os.system('diff test01.jpg reference_images/test01.jpg')
26+
assert rc == 0
27+
28+
apdict = mpf.make_addplot(df['LowerB'])
29+
mpf.plot(df,volume=True,addplot=apdict,savefig='test02.jpg')
30+
31+
os.system('ls -l test02.jpg')
32+
rc = os.system('diff test02.jpg reference_images/test02.jpg')
33+
assert rc == 0

examples/mpftests/tmp.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import os as os
2+
import pandas as pd
3+
import mplfinance as mpf
4+
import matplotlib.pyplot as plt
5+
6+
print('pd.__version__ =',pd.__version__ ) # for the record
7+
print('mpf.__version__ =',mpf.__version__) # for the record
8+
print("plt.rcParams['backend'] =",plt.rcParams['backend']) # for the record
9+
10+
import subprocess
11+
result = subprocess.run(['pwd'], stdout=subprocess.PIPE)
12+
print('result.stdout=',result.stdout)
13+
14+
15+
df = pd.read_csv('../data/SPY_20110701_20120630_Bollinger.csv',index_col=0,parse_dates=True)
16+
print('df.shape=' , df.shape )
17+
print('df.head(3)=', df.head(3))
18+
print('df.tail(3)=', df.tail(3))
19+
20+
s = mpf.make_mpf_style(base_mpf_style='default',rc={'font.size':30})
21+
22+
mpf.plot(df,volume=True,figratio=(3,2),figscale=5.25,style=s)

examples/savefig.ipynb

Lines changed: 69 additions & 161 deletions
Large diffs are not rendered by default.

examples/scratch_pad/figsubplot_tests.ipynb

Lines changed: 294 additions & 0 deletions
Large diffs are not rendered by default.

examples/scratch_pad/test_plot_image_comparison.ipynb

Lines changed: 489 additions & 0 deletions
Large diffs are not rendered by default.

tests.py

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,29 @@
22
import os
33
import subprocess
44

5+
def test_mplfinance():
6+
'''Run new mplfinance api tests.'''
7+
8+
os.environ['MPLBACKEND'] = 'agg'
9+
10+
os.chdir("examples/mpftests")
11+
12+
exs = glob.glob('test*.py')
13+
try:
14+
for ex in exs:
15+
subprocess.check_call(["python", ex])
16+
finally:
17+
os.chdir("../..")
18+
19+
20+
def test_original_flavor_e2e_examples():
21+
"""Run e2e tests for folder"""
522

6-
def test_e2e_examples():
7-
"""Run e2e tests over examples folder"""
8-
print('>>> tests.py')
923
os.chdir("examples/original_flavor")
24+
1025
exs = glob.glob('*.py')
11-
for ex in exs:
12-
subprocess.check_call(["python", ex])
26+
try:
27+
for ex in exs:
28+
subprocess.check_call(["python", ex])
29+
finally:
30+
os.chdir("../..")

tox.ini

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,9 @@
55

66
[tox]
77
envlist = py36, py37, py38
8+
89
[pytest]
9-
python_files = 'tests.py'
10+
python_files = tests.py
1011

1112
[testenv]
1213
deps =

0 commit comments

Comments
 (0)