Skip to content

Commit f7e7d85

Browse files
DanielGoldfarbDaniel Goldfarb
authored andcommitted
Final README updates for new version
1 parent ff4de2e commit f7e7d85

21 files changed

+253
-4054
lines changed

README.md

Lines changed: 62 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -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/DanielGoldfarb/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/DanielGoldfarb/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/DanielGoldfarb/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/DanielGoldfarb/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/DanielGoldfarb/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/DanielGoldfarb/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/DanielGoldfarb/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/DanielGoldfarb/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/DanielGoldfarb/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/DanielGoldfarb/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/DanielGoldfarb/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/DanielGoldfarb/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,11 +538,13 @@ 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

531550
For more examples of using mplfinance, please see the jupyter notebooks in the **[`examples`](https://github.com/matplotlib/mplfinance/blob/master/examples/)** directory.
@@ -535,8 +554,8 @@ For more examples of using mplfinance, please see the jupyter notebooks in the *
535554
# <a name="release"></a>Release Notes
536555

537556
| Version | Description | Release Date |
538-
|----------|--------------|----------------|
539-
| 0.12.3a0 | - kwarg `block=False` for non-blocking call to `mpf.plot()`<br> - customize aspect ratio, title, y-labels<br> - customize colors and other `style` aspects of plot<br> - `no_xgaps` now default 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-11 |
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 |
540559
| 0.12.0a3 | Increase mav limit from 3 to 7 different mavs | 2020-01-16 |
541560
| 0.12.0a2 | Ability to save plot to a file (pdf, svg, png, jpg, ...) | 2020-01-14 |
542561
| 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 |
@@ -566,10 +585,18 @@ With this new ` mplfinance ` package installed, in addition to the new API, user
566585
from mplfinance.original_flavor import <method>
567586
```
568587

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

591+
592+
571593
```python
572594
from mplfinance.original_flavor import candlestick_ohlc
573595
```
596+
574597
---
575598

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

examples/addplot.ipynb

Lines changed: 36 additions & 30 deletions
Large diffs are not rendered by default.

examples/customization_and_styles.ipynb

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -92,15 +92,15 @@
9292
" </thead>\n",
9393
" <tbody>\n",
9494
" <tr>\n",
95-
" <td>2019-11-01</td>\n",
95+
" <th>2019-11-01</th>\n",
9696
" <td>3050.72</td>\n",
9797
" <td>3066.95</td>\n",
9898
" <td>3050.72</td>\n",
9999
" <td>3066.91</td>\n",
100100
" <td>510301237</td>\n",
101101
" </tr>\n",
102102
" <tr>\n",
103-
" <td>2019-11-04</td>\n",
103+
" <th>2019-11-04</th>\n",
104104
" <td>3078.96</td>\n",
105105
" <td>3085.20</td>\n",
106106
" <td>3074.87</td>\n",
@@ -160,15 +160,15 @@
160160
" </thead>\n",
161161
" <tbody>\n",
162162
" <tr>\n",
163-
" <td>2019-11-27</td>\n",
163+
" <th>2019-11-27</th>\n",
164164
" <td>3145.49</td>\n",
165165
" <td>3154.26</td>\n",
166166
" <td>3143.41</td>\n",
167167
" <td>3153.63</td>\n",
168168
" <td>421853938</td>\n",
169169
" </tr>\n",
170170
" <tr>\n",
171-
" <td>2019-11-29</td>\n",
171+
" <th>2019-11-29</th>\n",
172172
" <td>3147.18</td>\n",
173173
" <td>3150.30</td>\n",
174174
" <td>3139.34</td>\n",
@@ -362,6 +362,7 @@
362362
" 'default',\n",
363363
" 'mike',\n",
364364
" 'nightclouds',\n",
365+
" 'sas',\n",
365366
" 'starsandstripes',\n",
366367
" 'yahoo']"
367368
]
@@ -387,7 +388,7 @@
387388
},
388389
{
389390
"cell_type": "code",
390-
"execution_count": 12,
391+
"execution_count": 9,
391392
"metadata": {},
392393
"outputs": [],
393394
"source": [
@@ -397,7 +398,7 @@
397398
},
398399
{
399400
"cell_type": "code",
400-
"execution_count": 13,
401+
"execution_count": 10,
401402
"metadata": {
402403
"scrolled": false
403404
},
@@ -1027,7 +1028,7 @@
10271028
"name": "python",
10281029
"nbconvert_exporter": "python",
10291030
"pygments_lexer": "ipython3",
1030-
"version": "3.7.4"
1031+
"version": "3.7.6"
10311032
}
10321033
},
10331034
"nbformat": 4,

0 commit comments

Comments
 (0)