Skip to content

Commit 8910c66

Browse files
Merge branch 'master' of github.com:matplotlib/mplfinance
2 parents cebe712 + f81a205 commit 8910c66

17 files changed

+3919
-38
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,4 @@ __pycache__
66
*.egg-info
77
.tox/
88
.cache/
9+
*.code-workspace

README.md

Lines changed: 13 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,22 @@
11
[![Build Status](https://travis-ci.org/matplotlib/mplfinance.svg?branch=master)](https://travis-ci.org/matplotlib/mplfinance)
22

33
# mplfinance
4-
## matplotlib utilities for the visualization, and visual analysis, of financial data
4+
matplotlib utilities for the visualization, and visual analysis, of financial data
55

6-
---
7-
8-
# Installation
9-
##    `pip install --upgrade mplfinance`
10-
- mplfinance requires [matplotlib](https://pypi.org/project/matplotlib/) and [pandas](https://pypi.org/project/pandas/)
6+
## Installation
7+
```bash
8+
pip install --upgrade mplfinance
9+
```
10+
- mplfinance requires [matplotlib](https://pypi.org/project/matplotlib/) and [pandas](https://pypi.org/project/pandas/)
1111

1212
---
1313

14-
# <a name="announcements"></a>Announcing Version 0.12.7
15-
### [External Axes Mode and Animation Support.](https://github.com/matplotlib/mplfinance/blob/master/RELEASE_NOTES.md)
14+
## <a name="announcements"></a>Announcing Version 0.12.7
15+
[External Axes Mode and Animation Support.](https://github.com/matplotlib/mplfinance/blob/master/RELEASE_NOTES.md)
1616

1717
---
1818

19-
# <a name="tutorials"></a>Contents and Tutorials
19+
## <a name="tutorials"></a>Contents and Tutorials
2020

2121
- **[The New API](https://github.com/matplotlib/mplfinance#newapi)**
2222
- **[Tutorials](https://github.com/matplotlib/mplfinance#tutorials)**
@@ -59,7 +59,7 @@ I am very interested to hear from you regarding what you think of the new `mplfi
5959

6060
---
6161

62-
# <a name="usage"></a>Basic Usage
62+
## <a name="usage"></a>Basic Usage
6363
Start with a Pandas DataFrame containing OHLC data. For example,
6464

6565

@@ -171,7 +171,6 @@ daily.tail(3)
171171
</table>
172172

173173

174-
---
175174
<br>
176175

177176
After importing mplfinance, plotting OHLC data is as simple as calling `mpf.plot()` on the dataframe
@@ -186,7 +185,6 @@ mpf.plot(daily)
186185
![png](https://raw.githubusercontent.com/matplotlib/mplfinance/master/readme_files/readme_4_1.png)
187186

188187

189-
---
190188
<br>
191189

192190
The default plot type, as you can see above, is `'ohlc'`. Other plot types can be specified with the keyword argument `type`, for example, `type='candle'`, `type='line'`, `type='renko'`, or `type='pnf'`
@@ -385,7 +383,7 @@ intraday.tail(3)
385383

386384

387385

388-
The above dataframe contains Open,High,Low,Close data at 1 minute intervervals for the S&P 500 stock index for November 5, 6, 7 and 8, 2019. Let's look at the last hour of trading on November 6th, with a 7 minute and 12 minute moving average.
386+
The above dataframe contains Open,High,Low,Close data at 1 minute intervals for the S&P 500 stock index for November 5, 6, 7 and 8, 2019. Let's look at the last hour of trading on November 6th, with a 7 minute and 12 minute moving average.
389387

390388

391389
```python
@@ -584,11 +582,9 @@ My name is Daniel Goldfarb. In November 2019, I became the maintainer of `matpl
584582
It is my intention to archive the `matplotlib/mpl-finance` repository soon, and direct everyone to `matplotlib/mplfinance`. The main reason for the rename is to avoid confusion with the hyphen and the underscore: As it was, `mpl-finance` was *installed with the hyphen, but imported with an underscore `mpl_finance`.* Going forward it will be a simple matter of both installing and importing `mplfinance`.
585583

586584
---
587-
### <a name="oldapi"></a>old API availability
588-
589-
**With this new ` mplfinance ` package installed, in addition to the new API, users can still access the old API**.<br> The old API may be removed some day, but for the foreseeable future we will keep it ... at least until we are very confident that users of the old API can accomplish the same things with the new API.
585+
## <a name="oldapi"></a>Old API availability
590586

591-
---
587+
**With this new ` mplfinance ` package installed, in addition to the new API, users can still access the old API**.<br> The old API may be removed someday, but for the foreseeable future we will keep it ... at least until we are very confident that users of the old API can accomplish the same things with the new API.
592588

593589
To access the old API with the new ` mplfinance ` package installed, change the old import statments
594590

@@ -612,10 +608,3 @@ where `<method>` indicates the method you want to import, for example:
612608
```python
613609
from mplfinance.original_flavor import candlestick_ohlc
614610
```
615-
616-
---
617-
618-
619-
```python
620-
621-
```
Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
Date,Open,High,Low,Close,Adj Close,Volume
2+
2020-09-01,350.209991,352.709991,349.239990,352.600006,349.703522,54999300
3+
2020-09-02,354.670013,358.750000,353.429993,357.700012,354.761627,69540000
4+
2020-09-03,355.869995,356.380005,342.589996,345.390015,342.552765,148011100
5+
2020-09-04,346.130005,347.829987,334.869995,342.570007,339.755890,139156300
6+
2020-09-08,336.709991,342.640015,332.880005,333.209991,330.472778,114465300
7+
2020-09-09,337.549988,342.459991,336.609985,339.790009,336.998749,91462300
8+
2020-09-10,341.820007,342.529999,332.850006,333.890015,331.147217,90569500
9+
2020-09-11,335.820007,336.970001,331.000000,334.059998,331.315796,84680200
10+
2020-09-14,337.489990,340.380005,334.220001,338.459991,335.679657,65605700
11+
2020-09-15,341.119995,342.019989,338.470001,340.170013,337.375641,52920900
12+
2020-09-16,341.510010,343.059998,338.519989,338.820007,336.036713,82096000
13+
2020-09-17,333.559998,337.700012,332.989990,335.839996,333.081207,91523300
14+
2020-09-18,335.369995,335.489990,327.970001,330.649994,329.246521,105877900
15+
2020-09-21,325.700012,327.130005,321.730011,326.970001,325.582153,99450800
16+
2020-09-22,328.570007,330.899994,325.859985,330.299988,328.898010,63612100
17+
2020-09-23,330.899994,331.200012,322.100006,322.640015,321.270538,93112200
18+
2020-09-24,321.220001,326.799988,319.799988,323.500000,322.126892,76681300
19+
2020-09-25,322.579987,329.579987,321.640015,328.730011,327.334686,71069400
20+
2020-09-28,333.220001,334.959991,332.149994,334.190002,332.771515,64584600
21+
2020-09-29,333.970001,334.769989,331.619995,332.369995,330.959229,51304000
22+
2020-09-30,333.089996,338.290009,332.880005,334.890015,333.468567,103653800
23+
2020-10-01,337.690002,338.739990,335.010010,337.040009,335.609406,88698700
24+
2020-10-02,331.700012,337.010010,331.190002,333.839996,332.423004,89431100
25+
2020-10-05,336.059998,339.959991,336.010010,339.760010,338.317871,45713100
26+
2020-10-06,339.910004,342.170013,334.380005,334.929993,333.508362,90128900
27+
2020-10-07,338.119995,341.630005,338.089996,340.760010,339.313629,56999600
28+
2020-10-08,342.850006,343.850006,341.859985,343.779999,342.320801,45242500
29+
2020-10-09,345.559998,347.350006,344.890015,346.850006,345.377777,59528600
30+
2020-10-12,349.589996,354.019989,349.059998,352.429993,350.934082,80388500
31+
2020-10-13,352.279999,352.470001,349.089996,350.130005,348.643860,73255500
32+
2020-10-14,350.750000,351.929993,347.140015,347.929993,346.453186,57958700
33+
2020-10-15,343.709991,348.019989,343.130005,347.500000,346.025024,60357700
34+
2020-10-16,348.959991,350.750000,347.100006,347.290009,345.815918,89501900
35+
2020-10-19,348.649994,349.329987,341.040009,342.010010,340.558319,68425600
36+
2020-10-20,343.459991,346.880005,342.640015,343.380005,341.922516,60051900
37+
2020-10-21,343.329987,345.670013,342.399994,342.730011,341.275269,63575000
38+
2020-10-22,342.959991,345.239990,340.649994,344.609985,343.147278,55399300
39+
2020-10-23,345.929993,345.989990,343.130005,345.779999,344.312317,49143900
40+
2020-10-26,342.130005,342.980011,335.619995,339.390015,337.949463,91473000
41+
2020-10-27,339.760010,340.119995,337.989990,338.220001,336.784393,65994100
42+
2020-10-28,332.100006,338.250000,326.130005,326.660004,325.273468,127094300
43+
2020-10-29,326.910004,333.399994,325.089996,329.980011,328.579376,90597700
44+
2020-10-30,328.279999,329.690002,322.600006,326.540009,325.153992,120287300
45+
2020-11-02,330.200012,332.359985,327.239990,330.200012,328.798462,86068300
46+
2020-11-03,333.690002,338.250000,330.290009,336.029999,334.603699,93294200
47+
2020-11-04,340.859985,347.940002,339.589996,343.540009,342.081818,126959700
48+
2020-11-05,349.239990,352.190002,348.859985,350.239990,348.753387,82039700
49+
2020-11-06,349.929993,351.510010,347.649994,350.160004,348.673737,74973000
50+
2020-11-09,363.970001,364.380005,354.059998,354.559998,353.055054,172304200
51+
2020-11-10,353.489990,355.179993,350.510010,354.040009,352.537262,85552000
52+
2020-11-11,356.399994,357.559998,355.059998,356.670013,355.156097,58649000
53+
2020-11-12,355.579987,356.720001,351.260010,353.209991,351.710754,67546200
54+
2020-11-13,355.269989,358.899994,354.709991,358.100006,356.580017,62892200
55+
2020-11-16,360.980011,362.779999,359.589996,362.570007,361.031067,74541100
56+
2020-11-17,359.970001,361.920013,358.339996,360.619995,359.089325,66111000
57+
2020-11-18,360.910004,361.500000,356.239990,356.279999,354.767731,70591300
58+
2020-11-19,355.600006,358.179993,354.149994,357.779999,356.261383,59940900
59+
2020-11-20,357.500000,357.720001,355.250000,355.329987,353.821777,70417300
60+
2020-11-23,357.279999,358.820007,354.869995,357.459991,355.942719,63230600
61+
2020-11-24,360.209991,363.809998,359.290009,363.220001,361.678284,62415900
62+
2020-11-25,363.130005,363.160004,361.480011,362.660004,361.120667,45330900
63+
2020-11-27,363.839996,364.179993,362.579987,363.670013,362.126404,28514100
64+
2020-11-30,362.829987,363.119995,359.170013,362.059998,360.523224,83872700
65+
2020-12-01,365.570007,367.679993,364.929993,366.019989,364.466400,74505000
66+
2020-12-02,364.820007,366.959991,364.200012,366.790009,365.233154,45927000
67+
2020-12-03,366.679993,368.190002,365.500000,366.690002,365.133575,62882000
68+
2020-12-04,367.320007,369.850006,367.220001,369.850006,368.280151,50749900
69+
2020-12-07,369.019989,369.619995,367.720001,369.089996,367.523376,48944300
70+
2020-12-08,367.720001,370.779999,367.670013,370.170013,368.598816,42458900
71+
2020-12-09,370.880005,371.049988,365.950012,366.850006,365.292877,74098300
72+
2020-12-10,365.369995,367.859985,364.429993,366.730011,365.173401,57735400
73+
2020-12-11,364.899994,366.739990,363.260010,366.299988,364.745209,57698600
74+
2020-12-14,368.640015,369.799988,364.470001,364.660004,363.112183,69216200
75+
2020-12-15,367.399994,369.589996,365.920013,369.589996,368.021240,64071100
76+
2020-12-16,369.820007,371.160004,368.869995,370.170013,368.598816,58420500
77+
2020-12-17,371.940002,372.459991,371.049988,372.239990,370.660004,64119500
78+
2020-12-18,370.970001,371.149994,367.019989,369.179993,369.179993,136542300
79+
2020-12-21,364.970001,378.459991,362.029999,367.859985,367.859985,96386700
80+
2020-12-22,368.209991,368.329987,366.029999,367.239990,367.239990,47949000
81+
2020-12-23,368.279999,369.619995,367.220001,367.570007,367.570007,46201400
82+
2020-12-24,368.079987,369.029999,367.450012,369.000000,369.000000,26457900
83+
2020-12-28,371.739990,372.589996,371.070007,372.170013,372.170013,39000400
84+
2020-12-29,373.809998,374.000000,370.829987,371.459991,371.459991,53680500
85+
2020-12-30,372.339996,373.100006,371.570007,371.989990,371.989990,49455300
86+
2020-12-31,371.779999,374.660004,371.230011,373.880005,373.880005,78469000
87+
2021-01-04,375.309998,375.450012,364.820007,368.790009,368.790009,110210800
88+
2021-01-05,368.100006,372.500000,368.049988,371.329987,371.329987,66426200
89+
2021-01-06,369.709991,376.980011,369.119995,373.549988,373.549988,107997700
90+
2021-01-07,376.100006,379.899994,375.910004,379.100006,379.100006,68766800
91+
2021-01-08,380.589996,381.489990,377.100006,381.260010,381.260010,71677200
92+
2021-01-11,377.850006,380.579987,377.720001,378.690002,378.690002,51176700
93+
2021-01-12,378.890015,379.859985,376.359985,378.769989,378.769989,52445000

examples/hollow_and_filled_candles.ipynb

Lines changed: 558 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
#!/bin/env python
2+
3+
import pandas as pd
4+
import mplfinance as mpf
5+
6+
Dates = ['2019-11-06', '2019-11-07', '2019-11-08', '2019-11-11', '2019-11-12']
7+
Open = [3075.1, 3092.0, 3092.0, 3080.33, 3089.28]
8+
High = [3078.34, 3096.0, 3096.0, 3088.33, 3102.61]
9+
Low = [3065.89, 3081.0, 3081.0, 3075.82, 3084.73]
10+
Close = [3076.78, 3085.0, 3085.0, 3087.01, 3091.84]
11+
Volume = [544288522, 566117910, 460757054, 366044400, 434953689]
12+
13+
data = dict(Open=Open,High=High,Low=Low,Close=Close,Volume=Volume)
14+
df = pd.DataFrame(data,index=pd.DatetimeIndex(Dates))
15+
16+
df.loc['2019-11-07','Open' ] = 3085
17+
df.loc['2019-11-07','Close'] = 3092
18+
df.loc['2019-11-07','Low' ] = 3081
19+
df.loc['2019-11-07','High' ] = 3096
20+
21+
df.loc['2019-11-08','Open' ] = 3085
22+
df.loc['2019-11-08','Close'] = 3092
23+
df.loc['2019-11-08','Low' ] = 3081
24+
df.loc['2019-11-08','High' ] = 3096
25+
26+
27+
dfs = df.copy()
28+
dfs.loc['2019-11-07','Open' ] = 3092
29+
dfs.loc['2019-11-07','Close'] = 3085
30+
31+
dfs.loc['2019-11-08','Open' ] = 3092
32+
dfs.loc['2019-11-08','Close'] = 3085
33+
34+
df = df.iloc[0:3]
35+
dfs = dfs.iloc[0:3]
36+
37+
kwargs=dict(type='hollow_candle',figratio=(8,10),figscale=2.0,update_width_config=dict(candle_linewidth=4.25))
38+
39+
40+
# s = mpf.make_mpf_style(base_mpf_style='charles',gridstyle='',facecolor='#79c0c3')
41+
# s = mpf.make_mpf_style(base_mpf_style='charles',gridstyle='',facecolor='gainsboro')
42+
# s = mpf.make_mpf_style(base_mpf_style='charles',gridstyle='',facecolor='pink')
43+
# s = mpf.make_mpf_style(base_mpf_style='charles',gridstyle='',facecolor='#ffd6dd')
44+
s = mpf.make_mpf_style(base_mpf_style='charles',gridstyle='')
45+
46+
mpf.plot(df ,style=s,**kwargs,savefig='hollow_red_green.jpg')
47+
mpf.plot(dfs,style=s,**kwargs,savefig='solid_red_green.jpg')
48+
49+
# st1 = mpf.make_mpf_style(base_mpf_style='checkers',gridstyle='',facecolor='#56b0b3')
50+
mc = mpf.make_marketcolors(base_mpf_style='checkers',down='#a02128')
51+
st1 = mpf.make_mpf_style(base_mpf_style='checkers',gridstyle='',facecolor='#79c0c3',marketcolors=mc)
52+
53+
mpf.plot(df ,style=st1,**kwargs,savefig='hollow_red_blackt.jpg')
54+
mpf.plot(dfs,style=st1,**kwargs,savefig='solid_red_blackt.jpg')
55+
56+
st2 = mpf.make_mpf_style(base_mpf_style='checkers',gridstyle='',marketcolors=mc)
57+
58+
mpf.plot(df ,style=st2,**kwargs,savefig='hollow_red_black.jpg')
59+
mpf.plot(dfs,style=st2,**kwargs,savefig='solid_red_black.jpg')
60+
61+
st3 = mpf.make_mpf_style(base_mpf_style='classic',gridstyle='',facecolor='#79c0c3')
62+
mpf.plot(df ,style=st3,**kwargs,savefig='hollow_black_white.jpg')
63+
mpf.plot(dfs,style=st3,**kwargs,savefig='solid_black_white.jpg')
64+
65+
##
66+
## df = pd.read_csv('data/SP500_NOV2019_Hist.csv',index_col=0,parse_dates=True)
67+
##
68+
## df.loc['2019-11-07','Open' ] = 3085
69+
## df.loc['2019-11-07','Close'] = 3092
70+
## df.loc['2019-11-07','Low' ] = 3081
71+
## df.loc['2019-11-07','High' ] = 3096
72+
##
73+
## df.loc['2019-11-08','Open' ] = 3085
74+
## df.loc['2019-11-08','Close'] = 3092
75+
## df.loc['2019-11-08','Low' ] = 3081
76+
## df.loc['2019-11-08','High' ] = 3096
77+
##
78+
##
79+
## dfs = df.copy()
80+
## dfs.loc['2019-11-07','Open' ] = 3092
81+
## dfs.loc['2019-11-07','Close'] = 3085
82+
##
83+
## dfs.loc['2019-11-08','Open' ] = 3092
84+
## dfs.loc['2019-11-08','Close'] = 3085
85+
##
86+
## neoclassic = mpf.make_mpf_style(base_mpf_style='classic',facecolor='cyan')
87+
## st = neoclassic
88+
## st = mpf.make_mpf_style(base_mpf_style='nightclouds',gridstyle='')
89+
## #st = mpf.make_mpf_style(base_mpf_style='sas',gridstyle='') #figcolor='#3C8284'
90+
## st1 = mpf.make_mpf_style(base_mpf_style='classic',gridstyle='',facecolor='#56b0b3')
91+
## #st1 = mpf.make_mpf_style(base_mpf_style='classic',gridstyle='',facecolor='#ffd6dd')
92+
## mpf.plot(df.iloc[3:8],type='hollow_candle',volume=False,style=st1,figscale=1,update_width_config=dict(candle_linewidth=2.25))
93+
## mpf.plot(dfs.iloc[3:8],type='hollow_candle',volume=False,style=st1,figscale=1,update_width_config=dict(candle_linewidth=2.25))
94+
##

0 commit comments

Comments
 (0)