Skip to content

Commit 0b613fc

Browse files
Merge pull request #27 from DanielGoldfarb/master
New Version 0.12.3
2 parents 2bb9058 + 792647d commit 0b613fc

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+4759
-1447
lines changed

README.md

Lines changed: 66 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
---
77

88
# Installation
9-
##    `pip install mplfinance`
9+
##    `pip install --upgrade mplfinance`
1010
- mplfinance requires [matplotlib](https://pypi.org/project/matplotlib/) and [pandas](https://pypi.org/project/pandas/)
1111

1212
---
@@ -15,9 +15,9 @@
1515

1616
- **[The New API](https://github.com/matplotlib/mplfinance#newapi)**
1717
- **[Basic Usage](https://github.com/matplotlib/mplfinance#usage)**
18-
- **[Adding Custom Data to Ohlcv Plots](https://github.com/matplotlib/mplfinance/blob/master/examples/addplot.ipynb)**
18+
- **[Adding Your Own Technical Studies to Plots](https://github.com/matplotlib/mplfinance/blob/master/examples/addplot.ipynb)**
1919
- **[Saving the Plot to a File](https://github.com/matplotlib/mplfinance/blob/master/examples/savefig.ipynb)**
20-
- Customizing the Appearance of Plots (presently in development)
20+
- **[Customizing the Appearance of Plots](https://github.com/matplotlib/mplfinance/blob/master/examples/customization_and_styles.ipynb)**
2121
- Technical Studies (presently in development)
2222
- **[Latest Release Info](https://github.com/matplotlib/mplfinance#release)**
2323
- **[Some Background History About This Package](https://github.com/matplotlib/mplfinance#history)**
@@ -35,8 +35,8 @@ The conventional way to import the new API is as follows:
3535
```python
3636
import mplfinance as mpf
3737
```
38-
39-
The most common usage is then to call
38+
39+
The most common usage is then to call
4040

4141
```python
4242
mpf.plot(data)
@@ -53,6 +53,7 @@ I am very interested to hear from you regarding what you think of the new `mplfi
5353
# <a name="usage"></a>Basic Usage
5454
Start with a Pandas DataFrame containing OHLC data. For example,
5555

56+
5657
```python
5758
import pandas as pd
5859
daily = pd.read_csv('examples/data/SP500_NOV2019_Hist.csv',index_col=0,parse_dates=True)
@@ -61,6 +62,7 @@ daily.shape
6162
daily.head(3)
6263
daily.tail(3)
6364
```
65+
6466
(20, 5)
6567

6668
<table border="1" class="dataframe">
@@ -159,20 +161,21 @@ daily.tail(3)
159161
</tbody>
160162
</table>
161163

162-
<br>
163164

164165
---
165-
166166
<br>
167167

168168
After importing mplfinance, plotting OHLC data is as simple as calling `mpf.plot()` on the dataframe
169169

170+
170171
```python
171172
import mplfinance as mpf
172173
mpf.plot(daily)
173174
```
174175

175-
![png](https://raw.githubusercontent.com/matplotlib/mplfinance/master/readme_files/readme_4_0.png)
176+
177+
![png](https://raw.githubusercontent.com/matplotlib/mplfinance/master/readme_files/readme_4_1.png)
178+
176179

177180
---
178181
<br>
@@ -184,14 +187,18 @@ The default plot type, as you can see above, is `'ohlc'`. Other plot types can
184187
mpf.plot(daily,type='candle')
185188
```
186189

187-
![png](https://raw.githubusercontent.com/matplotlib/mplfinance/master/readme_files/readme_6_0.png)
190+
191+
![png](https://raw.githubusercontent.com/matplotlib/mplfinance/master/readme_files/readme_6_1.png)
192+
188193

189194

190195
```python
191196
mpf.plot(daily,type='line')
192197
```
193198

194-
![png](https://raw.githubusercontent.com/matplotlib/mplfinance/master/readme_files/readme_7_0.png)
199+
200+
![png](https://raw.githubusercontent.com/matplotlib/mplfinance/master/readme_files/readme_7_1.png)
201+
195202

196203
---
197204
<br>
@@ -205,14 +212,18 @@ We can also plot moving averages with the `mav` keyword
205212
mpf.plot(daily,type='ohlc',mav=4)
206213
```
207214

208-
![png](https://raw.githubusercontent.com/matplotlib/mplfinance/master/readme_files/readme_9_0.png)
215+
216+
![png](https://raw.githubusercontent.com/matplotlib/mplfinance/master/readme_files/readme_9_1.png)
217+
209218

210219

211220
```python
212221
mpf.plot(daily,type='candle',mav=(3,6,9))
213222
```
214223

215-
![png](https://raw.githubusercontent.com/matplotlib/mplfinance/master/readme_files/readme_10_0.png)
224+
225+
![png](https://raw.githubusercontent.com/matplotlib/mplfinance/master/readme_files/readme_10_1.png)
226+
216227

217228
---
218229
We can also display `Volume`
@@ -223,20 +234,23 @@ mpf.plot(daily,type='candle',mav=(3,6,9),volume=True)
223234
```
224235

225236

226-
![png](https://raw.githubusercontent.com/matplotlib/mplfinance/master/readme_files/readme_12_0.png)
237+
![png](https://raw.githubusercontent.com/matplotlib/mplfinance/master/readme_files/readme_12_1.png)
238+
227239

228-
Notice, in the above chart, there are gaps along the x-coordinate corresponding to days on which there was no trading.
229-
- Many people like to see these gaps so that they can tell, with a quick glance, where the weekends and holidays fall.
230-
- For example, in the above chart you can see a gap at Thursday, November 28th for the U.S. Thanksgiving holiday.
231-
- Gaps along the x-axis can be eliminated with the `no_xgaps` keyword
240+
Notice, in the above chart, there are no gaps along the x-coordinate, even though there are days on which there was no trading. ***Non-trading days are simply not shown*** (since there are no prices for those days).
241+
242+
- However, sometimes people like to see these gaps, so that they can tell, with a quick glance, where the weekends and holidays fall.
243+
244+
- Non-trading days can be displayed with the `show_nontrading` keyword.
245+
- For example, in the chart below, you can easily see weekends, as well as a gap at Thursday, November 28th for the U.S. Thanksgiving holiday.
232246

233247

234248
```python
235-
mpf.plot(daily,type='candle',mav=(3,6,9),volume=True,no_xgaps=True)
249+
mpf.plot(daily,type='candle',mav=(3,6,9),volume=True,show_nontrading=True)
236250
```
237251

238252

239-
![png](https://raw.githubusercontent.com/matplotlib/mplfinance/master/readme_files/readme_14_0.png)
253+
![png](https://raw.githubusercontent.com/matplotlib/mplfinance/master/readme_files/readme_14_1.png)
240254

241255

242256
---
@@ -255,6 +269,7 @@ intraday.tail(3)
255269

256270
(1563, 4)
257271

272+
258273
<table border="1" class="dataframe">
259274
<thead>
260275
<tr style="text-align: right;">
@@ -341,6 +356,8 @@ intraday.tail(3)
341356
</tbody>
342357
</table>
343358

359+
360+
344361
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.
345362

346363

@@ -349,12 +366,11 @@ iday = intraday.loc['2019-11-06 15:00':'2019-11-06 16:00',:]
349366
mpf.plot(iday,type='candle',mav=(7,12))
350367
```
351368

352-
![png](https://raw.githubusercontent.com/matplotlib/mplfinance/master/readme_files/readme_18_0.png)
353369

370+
![png](https://raw.githubusercontent.com/matplotlib/mplfinance/master/readme_files/readme_18_1.png)
354371

355-
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:
356-
- The x-axis displays *BOTH* TIME and DATE
357-
- `no-xgaps` defaults to `True` FOR INTRADAY DATA INVOLVING TWO OR MORE TRADING DAYS
372+
373+
The "time-interpretation" of the `mav` integers depends on the frequency of the data, because the mav integers are the *number of data points* used in the Moving Average (not the number of days or minutes, etc). Notice above that for intraday data the x-axis automatically displays TIME *instead of* date. Below we see that if the intraday data spans into two (or more) trading days the x-axis automatically displays *BOTH* TIME and DATE
358374

359375

360376
```python
@@ -363,47 +379,47 @@ mpf.plot(iday,type='candle')
363379
```
364380

365381

366-
![png](https://raw.githubusercontent.com/matplotlib/mplfinance/master/readme_files/readme_20_0.png)
382+
![png](https://raw.githubusercontent.com/matplotlib/mplfinance/master/readme_files/readme_20_1.png)
367383

368384

369385
---
370-
In the plot below, we see **what would happen if ` no_xgaps ` did NOT** default to `True` for intraday data involving two or more days.
386+
In the plot below, we see what an intraday plot looks like when we **display non-trading time periods** with **`show_nontrading=True`** for intraday data spanning into two or more days.
371387

372388

373389
```python
374-
mpf.plot(iday,type='candle',no_xgaps=False)
390+
mpf.plot(iday,type='candle',show_nontrading=True)
375391
```
376392

377393

378-
![png](https://raw.githubusercontent.com/matplotlib/mplfinance/master/readme_files/readme_22_0.png)
394+
![png](https://raw.githubusercontent.com/matplotlib/mplfinance/master/readme_files/readme_22_1.png)
379395

380396

381397
---
382-
Below: 4 days of intraday data with `no_xgaps=False`
398+
Below: 4 days of intraday data with `show_nontrading=True`
383399

384400

385401
```python
386-
mpf.plot(intraday,type='ohlc',no_xgaps=False) # 4 day of intraday with no_xgaps=False
402+
mpf.plot(intraday,type='ohlc',show_nontrading=True)
387403
```
388404

389405

390-
![png](https://raw.githubusercontent.com/matplotlib/mplfinance/master/readme_files/readme_24_0.png)
406+
![png](https://raw.githubusercontent.com/matplotlib/mplfinance/master/readme_files/readme_24_1.png)
391407

392408

393409
---
394-
Below: 4 days of intraday data with `no_xgaps` defaulted to `True` for intraday data spanning more than one day.
410+
Below: the same 4 days of intraday data with `show_nontrading` defaulted to `False`.
395411

396412

397413
```python
398-
mpf.plot(intraday,type='line') # intraday spanning more than one day defaults to no_xgaps=True
414+
mpf.plot(intraday,type='line')
399415
```
400416

401417

402-
![png](https://raw.githubusercontent.com/matplotlib/mplfinance/master/readme_files/readme_26_0.png)
418+
![png](https://raw.githubusercontent.com/matplotlib/mplfinance/master/readme_files/readme_26_1.png)
403419

404420

405421
---
406-
Below: Daily data spanning more than a year automatically adds the *YEAR* to the DATE format
422+
Below: Daily data spanning across a year boundary automatically adds the *YEAR* to the DATE format
407423

408424

409425
```python
@@ -415,6 +431,7 @@ df.tail(3)
415431

416432
(2519, 6)
417433

434+
418435
<table border="1" class="dataframe">
419436
<thead>
420437
<tr style="text-align: right;">
@@ -521,21 +538,24 @@ df.tail(3)
521538
</tbody>
522539
</table>
523540

541+
524542
```python
525-
mpf.plot(df[700:850],type='bars',volume=True,no_xgaps=True,mav=(20,40))
543+
mpf.plot(df[700:850],type='bars',volume=True,mav=(20,40))
526544
```
527545

528-
![png](https://raw.githubusercontent.com/matplotlib/mplfinance/master/readme_files/readme_29_0.png)
546+
547+
![png](readme_files/readme_29_1.png)
529548

530549

531-
For more examples of using mplfinance, please see the jupyter notebooks in the `examples` directory.
550+
For more examples of using mplfinance, please see the jupyter notebooks in the **[`examples`](https://github.com/matplotlib/mplfinance/blob/master/examples/)** directory.
532551

533552
---
534553

535554
# <a name="release"></a>Release Notes
536555

537556
| Version | Description | Release Date |
538-
|----------|--------------|----------------|
557+
|:---------|:-------------|:---------------|
558+
| 0.12.3a0 | - kwarg `block=False` for non-blocking call to `mpf.plot()`<br> - customize aspect ratio, figure title, y-labels<br> - customize colors and other `style` aspects of plot<br> - `no_xgaps` now defaults to True: use `show_nontrading=True` to set no_xgaps to false<br> - secondary y-axis available to `make_addplot()`<br> - bug fix for volume widths | 2020-02-12 |
539559
| 0.12.0a3 | Increase mav limit from 3 to 7 different mavs | 2020-01-16 |
540560
| 0.12.0a2 | Ability to save plot to a file (pdf, svg, png, jpg, ...) | 2020-01-14 |
541561
| 0.12.0a1 | Ability to plot arbitrary user data (in addition to basic OHLCV data).<br> - both line and scatter plots available.<br> - optionally plot on either the "main" or "lower" (aka "volume") axis. | 2020-01-09 |
@@ -565,10 +585,18 @@ With this new ` mplfinance ` package installed, in addition to the new API, user
565585
from mplfinance.original_flavor import <method>
566586
```
567587

588+
568589
where `<method>` indicates the method you want to import, for example:
569590

591+
592+
570593
```python
571594
from mplfinance.original_flavor import candlestick_ohlc
572595
```
596+
573597
---
574598

599+
600+
```python
601+
602+
```

examples/addplot.ipynb

Lines changed: 137 additions & 26 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)