Skip to content

Commit 987b530

Browse files
scratch demos to compare old vs new api
1 parent 50e6c41 commit 987b530

File tree

2 files changed

+41
-0
lines changed

2 files changed

+41
-0
lines changed
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import os.path
2+
import matplotlib.dates as mdates
3+
import matplotlib.pyplot as plt
4+
import pandas as pd
5+
6+
from mplfinance.original_flavor import candlestick_ohlc
7+
8+
date1 = "2004-2-1"
9+
date2 = "2004-4-12"
10+
infile = os.path.join('data','yahoofinance-INTC-19950101-20040412.csv')
11+
quotes = pd.read_csv(infile, index_col=0, parse_dates=True, infer_datetime_format=True)
12+
13+
# select desired range of dates
14+
quotes = quotes[(quotes.index >= date1) & (quotes.index <= date2)]
15+
16+
fig, ax = plt.subplots()
17+
candlestick_ohlc(ax, zip(mdates.date2num(quotes.index.to_pydatetime()),
18+
quotes['Open'], quotes['High'],
19+
quotes['Low'], quotes['Close']), width=0.6)
20+
21+
fig.subplots_adjust(bottom=0.2)
22+
ax.xaxis.set_major_formatter(mdates.DateFormatter('%b %d')) # e.g., Jan 12
23+
24+
ax.xaxis_date()
25+
ax.autoscale_view()
26+
plt.setp(plt.gca().get_xticklabels(), rotation=45, horizontalalignment='right')
27+
28+
plt.show()
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import os.path
2+
import pandas as pd
3+
import mplfinance as mpf
4+
5+
date1 = "2004-2-1"
6+
date2 = "2004-4-12"
7+
infile = os.path.join('data','yahoofinance-INTC-19950101-20040412.csv')
8+
quotes = pd.read_csv(infile, index_col=0, parse_dates=True, infer_datetime_format=True)
9+
10+
# select desired range of dates
11+
quotes = quotes[(quotes.index >= date1) & (quotes.index <= date2)]
12+
13+
mpf.plot(quotes,type='candle',style='checkers')

0 commit comments

Comments
 (0)