Skip to content

Commit

Permalink
DOC: Add example and update documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
Benjamin Abel committed Jan 22, 2018
1 parent 812419f commit 36210b2
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 21 deletions.
2 changes: 1 addition & 1 deletion doc/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@

# General information about the project.
project = u'mpl_finance'
copyright = u'2017, Matplotlib Developers'
copyright = u'2018, Matplotlib Developers'
author = u'Matplotlib Developers'

# The version info for the project you're documenting, acts as replacement for
Expand Down
3 changes: 3 additions & 0 deletions doc/source/examples.rst
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,6 @@ Examples

.. plot:: ../../examples/longshort.py
:include-source:

.. plot:: ../../examples/plot_day_summary_oclh_demo.py
:include-source:
4 changes: 2 additions & 2 deletions doc/source/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
mpl_finance: financial helpers for matplotlib
=============================================

A collection of functions for collecting, analyzing and plotting financial data
A collection of functions for analyzing and plotting financial data
in combination with matplotlib.

.. toctree::
Expand All @@ -21,7 +21,7 @@ unchanged. Now that this code is separate from the core it can pick
up dependencies, like :mod:`pandas` or :mod:`scipy` and expose a more
powerful API to the user.

We are looking for a finance domain-export to lead this effort!
We are looking for a finance domain-expert to lead this effort!


* :ref:`genindex`
Expand Down
18 changes: 0 additions & 18 deletions doc/source/mpl_finance.rst
Original file line number Diff line number Diff line change
Expand Up @@ -53,21 +53,3 @@ Other
:nosignatures:

index_bar


Historical Data
---------------

.. warning::

These are all broken due to changes in the (undocumented) Yahoo! finance API.

.. autosummary::
:toctree: _as_gen
:nosignatures:

fetch_historical_yahoo
quotes_historical_yahoo_ochl
quotes_historical_yahoo_ohlc
parse_yahoo_historical_ochl
parse_yahoo_historical_ohlc
41 changes: 41 additions & 0 deletions examples/plot_day_summary_oclh_demo.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
"""
Show how to use plot_day_summary_oclh function
"""
import matplotlib.pyplot as plt
import pandas as pd
from matplotlib.dates import (MONDAY, DateFormatter, MonthLocator,
WeekdayLocator, date2num)

from mpl_finance import plot_day_summary_oclh

date1 = "2003-11-1"
date2 = "2003-12-1"

# every monday
mondays = WeekdayLocator(MONDAY)
daysFmt = DateFormatter("%d %b %y")


quotes = pd.read_csv('data/yahoofinance-INTC-19950101-20040412.csv',
index_col=0,
parse_dates=True,
infer_datetime_format=True)

# select desired range of dates
quotes = quotes[(quotes.index >= date1) & (quotes.index <= date2)]


fig, ax = plt.subplots()
plot_day_summary_oclh(ax, zip(date2num(quotes.index.to_pydatetime()),
quotes['Open'], quotes['Close'],
quotes['Low'], quotes['High']),
ticksize=3)
ax.xaxis.set_major_locator(mondays)
ax.xaxis.set_major_formatter(daysFmt)
ax.autoscale_view()
ax.xaxis.grid(True, 'major')
ax.grid(True)

fig.autofmt_xdate()

plt.show()

0 comments on commit 36210b2

Please sign in to comment.