1
1
[ ![ Build Status] ( https://travis-ci.org/matplotlib/mplfinance.svg?branch=master )] ( https://travis-ci.org/matplotlib/mplfinance )
2
2
3
3
# mplfinance
4
- (to replace mpl-finance sometime in 2020).
4
+ ## matplotlib utilities for the visualization, and visual analysis, of financial data
5
5
6
6
---
7
7
8
- ## The ` mplfinance ` package provides utilities for the visualization, and visual analysis, of financial data
9
-
10
- ## Installation
11
- ###   ;  ;  ; ` pip install mplfinance `
8
+ # Installation
9
+ ##   ;  ;  ; ` pip install mplfinance `
12
10
- mplfinance requires [ matplotlib] ( https://pypi.org/project/matplotlib/ ) and [ pandas] ( https://pypi.org/project/pandas/ )
13
11
12
+ ---
14
13
15
- ## Usage
14
+ # Usage
16
15
Start with a Pandas DataFrame containing OHLC data. For example,
17
16
18
17
``` python
@@ -121,51 +120,60 @@ daily.tail(3)
121
120
</tbody >
122
121
</table >
123
122
123
+ <br >
124
+
124
125
---
125
- After importing mplfinance, plotting open,high,low,close data is as simple as calling ` mpf.plot() ` on the dataframe
126
+
127
+ <br >
128
+
129
+ After importing mplfinance, plotting OHLC data is as simple as calling ` mpf.plot() ` on the dataframe
126
130
127
131
``` python
128
132
import mplfinance as mpf
129
133
mpf.plot(daily)
130
134
```
131
135
132
- ![ png] ( https://raw.githubusercontent.com/DanielGoldfarb /mplfinance/master/readme_files/readme_4_0.png )
136
+ ![ png] ( https://raw.githubusercontent.com/matplotlib /mplfinance/master/readme_files/readme_4_0.png )
133
137
134
138
---
139
+ <br >
140
+
135
141
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' ` or ` type='line' `
136
142
137
143
138
144
``` python
139
145
mpf.plot(daily,type = ' candle' )
140
146
```
141
147
142
- ![ png] ( readme_files/readme_6_0.png )
148
+ ![ png] ( https://raw.githubusercontent.com/matplotlib/mplfinance/master/ readme_files/readme_6_0.png)
143
149
144
150
145
151
``` python
146
152
mpf.plot(daily,type = ' line' )
147
153
```
148
154
149
- ![ png] ( readme_files/readme_7_0.png )
155
+ ![ png] ( https://raw.githubusercontent.com/matplotlib/mplfinance/master/ readme_files/readme_7_0.png)
150
156
151
157
---
158
+ <br >
159
+
152
160
We can also plot moving averages with the ` mav ` keyword
153
- - use an scaler for a single moving average
161
+ - use a scaler for a single moving average
154
162
- use a tuple or list of integers for multiple moving averages
155
163
156
164
157
165
``` python
158
166
mpf.plot(daily,type = ' ohlc' ,mav = 4 )
159
167
```
160
168
161
- ![ png] ( readme_files/readme_9_0.png )
169
+ ![ png] ( https://raw.githubusercontent.com/matplotlib/mplfinance/master/ readme_files/readme_9_0.png)
162
170
163
171
164
172
``` python
165
173
mpf.plot(daily,type = ' candle' ,mav = (3 ,6 ,9 ))
166
174
```
167
175
168
- ![ png] ( readme_files/readme_10_0.png )
176
+ ![ png] ( https://raw.githubusercontent.com/matplotlib/mplfinance/master/ readme_files/readme_10_0.png)
169
177
170
178
---
171
179
We can also display ` Volume `
@@ -176,7 +184,7 @@ mpf.plot(daily,type='candle',mav=(3,6,9),volume=True)
176
184
```
177
185
178
186
179
- ![ png] ( readme_files/readme_12_0.png )
187
+ ![ png] ( https://raw.githubusercontent.com/matplotlib/mplfinance/master/ readme_files/readme_12_0.png)
180
188
181
189
Notice, in the above chart, there are gaps along the x-coordinate corresponding to days on which there was no trading.
182
190
- Many people like to see these gaps so that they can tell, with a quick glance, where the weekends and holidays fall.
@@ -189,7 +197,7 @@ mpf.plot(daily,type='candle',mav=(3,6,9),volume=True,no_xgaps=True)
189
197
```
190
198
191
199
192
- ![ png] ( readme_files/readme_14_0.png )
200
+ ![ png] ( https://raw.githubusercontent.com/matplotlib/mplfinance/master/ readme_files/readme_14_0.png)
193
201
194
202
195
203
---
@@ -302,7 +310,7 @@ iday = intraday.loc['2019-11-06 15:00':'2019-11-06 16:00',:]
302
310
mpf.plot(iday,type = ' candle' ,mav = (7 ,12 ))
303
311
```
304
312
305
- ![ png] ( readme_files/readme_18_0.png )
313
+ ![ png] ( https://raw.githubusercontent.com/matplotlib/mplfinance/master/ readme_files/readme_18_0.png)
306
314
307
315
308
316
The "time-interpretation" of the ` mav ` integers depends on the frequency of the data, because the mav integers are number of data points used in the Moving Average. Notice above that for intraday data the x-axis automatically displays TIME * instead of* date. Below we see that if the intraday data spans two (or more) trading days then two things happen:
@@ -316,7 +324,7 @@ mpf.plot(iday,type='candle')
316
324
```
317
325
318
326
319
- ![ png] ( readme_files/readme_20_0.png )
327
+ ![ png] ( https://raw.githubusercontent.com/matplotlib/mplfinance/master/ readme_files/readme_20_0.png)
320
328
321
329
322
330
---
@@ -328,7 +336,7 @@ mpf.plot(iday,type='candle',no_xgaps=False)
328
336
```
329
337
330
338
331
- ![ png] ( readme_files/readme_22_0.png )
339
+ ![ png] ( https://raw.githubusercontent.com/matplotlib/mplfinance/master/ readme_files/readme_22_0.png)
332
340
333
341
334
342
---
@@ -340,7 +348,7 @@ mpf.plot(intraday,type='ohlc',no_xgaps=False) # 4 day of intraday with no_xgaps
340
348
```
341
349
342
350
343
- ![ png] ( readme_files/readme_24_0.png )
351
+ ![ png] ( https://raw.githubusercontent.com/matplotlib/mplfinance/master/ readme_files/readme_24_0.png)
344
352
345
353
346
354
---
@@ -352,7 +360,7 @@ mpf.plot(intraday,type='line') # intraday spanning more than one day defaults t
352
360
```
353
361
354
362
355
- ![ png] ( readme_files/readme_26_0.png )
363
+ ![ png] ( https://raw.githubusercontent.com/matplotlib/mplfinance/master/ readme_files/readme_26_0.png)
356
364
357
365
358
366
---
@@ -478,7 +486,7 @@ df.tail(3)
478
486
mpf.plot(df[700 :850 ],type = ' bars' ,volume = True ,no_xgaps = True ,mav = (20 ,40 ))
479
487
```
480
488
481
- ![ png] ( readme_files/readme_29_0.png )
489
+ ![ png] ( https://raw.githubusercontent.com/matplotlib/mplfinance/master/ readme_files/readme_29_0.png)
482
490
483
491
484
492
For more examples of using mplfinance, please see the jupyter notebooks in the ` examples ` directory.
0 commit comments