Skip to content

Commit 01c5568

Browse files
archive a few more experiments and examples
1 parent 0027ce1 commit 01c5568

File tree

5 files changed

+527
-0
lines changed

5 files changed

+527
-0
lines changed

examples/mpf_demo_autoclose.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import pandas as pd
2+
import mplfinance as mpf
3+
4+
import time
5+
import matplotlib.pyplot as plt
6+
7+
infile = 'data/yahoofinance-SPY-20200901-20210113.csv'
8+
9+
df = pd.read_csv(infile, index_col=0, parse_dates=True)
10+
11+
# print('len(df)=',len(df))
12+
13+
14+
for jj in (0,1,2):
15+
start = jj*35
16+
stop = start + 35
17+
tdf = df.iloc[start:stop]
18+
fig,_ = mpf.plot(tdf,type='candle',volume=True,mav=(10,20),figscale=1.5,returnfig=True)
19+
plt.pause(4)
20+
plt.close(fig)
21+
del fig

examples/mpf_demo_axlabelsize.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import pandas as pd
2+
import mplfinance as mpf
3+
4+
infile = 'data/yahoofinance-SPY-20200901-20210113.csv'
5+
6+
df = pd.read_csv(infile, index_col=0, parse_dates=True).iloc[0:60]
7+
8+
# mpf.plot(df,figscale=1.5,type='candle',mav=(10,20))
9+
10+
11+
#mpf.plot(df,type='candle',figscale=1.5)
12+
13+
#df = pd.read_csv(infile, index_col=0, parse_dates=True).iloc[0:180]
14+
#mpf.plot(df,type='renko',figscale=1.5)
15+
#mpf.plot(df,type='pnf',figscale=1.5)
16+
17+
#mpf.plot(df,type='candle',figscale=1.5,mav=10)
18+
19+
mystyle=mpf.make_mpf_style(base_mpf_style='yahoo',rc={'axes.labelsize':'small'})
20+
mpf.plot(df,type='candle',volume=True,mav=(10,20),figscale=1.5,style=mystyle)
21+
22+
mystyle=mpf.make_mpf_style(base_mpf_style='yahoo',rc={'axes.labelsize':'medium'})
23+
mpf.plot(df,type='candle',volume=True,mav=(10,20),figscale=1.5,style=mystyle)
24+
25+
mystyle=mpf.make_mpf_style(base_mpf_style='yahoo',rc={'axes.labelsize':18})
26+
mpf.plot(df,type='candle',volume=True,mav=(10,20),figscale=1.5,style=mystyle)
27+
28+

examples/scratch_pad/mpl.zorderaxes.ipynb

Lines changed: 444 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import matplotlib.pyplot as plt
2+
import random
3+
4+
fig = plt.figure(figsize=(6,6))
5+
ax = fig.add_axes([0.1,0.1,0.8,0.8])
6+
x = [x for x in range(0,50)]
7+
y = [random.randint(10,30) for y in range(0,50)]
8+
ax.bar(x,y)
9+
10+
plt.show()
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import matplotlib.pyplot as plt
2+
import timeit
3+
import random
4+
5+
def pbar():
6+
fig = plt.figure(figsize=(5,2))
7+
ax = fig.add_axes([0.1,0.1,0.8,0.8])
8+
x = [x for x in range(0,150)]
9+
y = [random.randint(10,30) for y in range(0,150)]
10+
ax.bar(x,y)
11+
12+
def pline():
13+
fig = plt.figure(figsize=(5,2))
14+
ax = fig.add_axes([0.1,0.1,0.8,0.8])
15+
x = [x for x in range(0,150)]
16+
y = [random.randint(10,30) for y in range(0,150)]
17+
ax.plot(x,y)
18+
19+
timeline = timeit.timeit(pline,number=5)
20+
timebar = timeit.timeit(pbar,number=5)
21+
print('timeline=',timeline)
22+
print('timebar =',timebar)
23+
print('\ntimebar/timeline=',timebar/timeline)
24+

0 commit comments

Comments
 (0)