Skip to content

Commit 469464e

Browse files
Merge pull request #98 from coffincw/master
Add Renko and Point and Figure Tests
2 parents d60e96d + a84047b commit 469464e

File tree

12 files changed

+255
-7
lines changed

12 files changed

+255
-7
lines changed

tests/reference_images/pnf01.png

55.3 KB
Loading

tests/reference_images/pnf02.png

46.2 KB
Loading

tests/reference_images/pnf03.png

51.2 KB
Loading

tests/reference_images/pnf04.png

63 KB
Loading

tests/reference_images/renko01.png

33.4 KB
Loading

tests/reference_images/renko02.png

33.9 KB
Loading

tests/reference_images/renko03.png

32.8 KB
Loading

tests/reference_images/renko04.png

46.9 KB
Loading

tests/test_addplot.py

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,9 @@ def test_addplot01(bolldata):
3232
tname = os.path.join(tdir,fname)
3333
rname = os.path.join(refd,fname)
3434

35-
mpf.plot(df,volume=True,savefig=tname)
36-
35+
fig_axis = mpf.plot(df,volume=True,savefig=tname,returnfig=True)
36+
plt.close(fig_axis[0])
37+
3738
tsize = os.path.getsize(tname)
3839
print(glob.glob(tname),'[',tsize,'bytes',']')
3940

@@ -53,7 +54,8 @@ def test_addplot02(bolldata):
5354
rname = os.path.join(refd,fname)
5455

5556
apdict = mpf.make_addplot(df['LowerB'])
56-
mpf.plot(df,volume=True,addplot=apdict,savefig=tname)
57+
fig_axis = mpf.plot(df,volume=True,addplot=apdict,savefig=tname,returnfig=True)
58+
plt.close(fig_axis[0])
5759

5860
tsize = os.path.getsize(tname)
5961
print(glob.glob(tname),'[',tsize,'bytes',']')
@@ -108,7 +110,8 @@ def test_addplot03(bolldata):
108110
mpf.make_addplot((df['PercentB']),panel='lower',color='g')
109111
]
110112

111-
mpf.plot(df,addplot=apds,figscale=1.3,volume=True,savefig=tname)
113+
fig_axis = mpf.plot(df,addplot=apds,figscale=1.3,volume=True,savefig=tname,returnfig=True)
114+
plt.close(fig_axis[0])
112115

113116
tsize = os.path.getsize(tname)
114117
print(glob.glob(tname),'[',tsize,'bytes',']')
@@ -139,8 +142,9 @@ def test_addplot04(bolldata):
139142
mpf.make_addplot((df['PercentB']),panel='lower',color='g',linestyle='dotted')
140143
]
141144

142-
mpf.plot(df,addplot=apds,figscale=1.5,volume=True,
143-
style='starsandstripes',savefig=tname)
145+
fig_axis = mpf.plot(df,addplot=apds,figscale=1.5,volume=True,
146+
style='starsandstripes',savefig=tname,returnfig=True)
147+
plt.close(fig_axis[0])
144148

145149
tsize = os.path.getsize(tname)
146150
print(glob.glob(tname),'[',tsize,'bytes',']')

tests/test_exceptions.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,12 +59,16 @@ def test_kwarg_validation_error(bolldata):
5959
mpf.make_marketcolors(base_mpf_style='classic',ohlc='chartreussse')
6060
assert 'NOT is_color_like' in str(ex.value)
6161

62-
def test_renko_addplot(bolldata):
62+
def test_pmove_addplot(bolldata):
6363
df = bolldata
6464
apdict = mpf.make_addplot(df['LowerB'])
6565
with pytest.raises(ValueError) as ex:
6666
mpf.plot(df,type='renko',volume=True,addplot=apdict)
6767
assert '`addplot` is not supported for `type=\'renko\'`' in str(ex.value)
68+
69+
with pytest.raises(ValueError) as ex:
70+
mpf.plot(df,type='pointnfigure',volume=True,addplot=apdict)
71+
assert '`addplot` is not supported for `type=\'pointnfigure\'`' in str(ex.value)
6872
#mpf.plot(df,type='renko',volume=True)
6973

7074
def test_figratio_bounds(bolldata):

0 commit comments

Comments
 (0)