Gander
Technical indicators and plotting for stock market analysis
Authors:
Ole Olaussen: ole.olaussen@ekkobit.com
Xuan Ling: xuan.ling@ekkobit.com
For more complete documentation, go to Gander at ReadTheDocs
Installation
pip install gander
Examples
import gander.indicators as gi
import gander.plotting as gp
import matplotlib.pyplot as plt
Using Matplotlib and Gander to create daily stock charts
Let’s say we have a Pandas DataFrame of a stocks data and we want to make a chart of a subset of the data. Our DataFrame might look something like this:
Adding indicators to the data set
df = gi.calc_ema(df, df["close"], "ema12", window=13)
df = gi.calc_ema(df, df["close"], "ema26", window=27)
df = gi.calc_macd(df, df["ema12"], df["ema26"])
This will give us something like this:
To get a subset of the data and positions on the x-axis, we can do:
df_plot = df[-300:-200]
xpos = range(100)
Building figure and subplots
fig = plt.figure(figsize=(12, 6))
ax1 = plt.subplot2grid((3, 1), (0, 0), rowspan=2)
ax2 = plt.subplot2grid((3, 1), (2, 0), rowspan=1)
ticks, labels = gp.daily_labels(df_plot, df_plot.index, step=5)
Customizing x-axis ticks, labels and grid
for ax in [ax1, ax2]:
ax.set_xlim(xmin=-1, xmax=104)
ax.set_xticks(ticks)
ax.grid(alpha=0.3)
ax1.xaxis.set_ticklabels([])
ax1.tick_params(axis='x', length=0)
ax2.set_xticklabels(labels)
for label in ax2.get_xticklabels():
if len(label.get_text()) == 4:
label.set_fontsize(14)
label.set_fontweight("bold")
elif len(label.get_text()) == 3:
label.set_fontsize(12)
label.set_fontweight("bold")
else:
label.set_fontsize(10)
Adding plots
gp.candles(df_plot, ax1)
ax1.plot(xpos, df_plot["ema12"], "b-")
ax1.plot(xpos, df_plot["ema26"], "k-")
gp.macds(df_plot, ax2, "fast", "signal", "macd-h")
Using Matplotlib and Gander to create weekly stock charts
Let’s again say we have a Pandas DataFrame of a stocks data and we want to make a chart of a subset of the data data. Only this time we have weekly data. Our DataFrame might look something like this:
Adding indicators to the data set
df = gi.calc_ema(df, df["close"], "ema12", window=13)
df = gi.calc_ema(df, df["close"], "ema26", window=27)
df = gi.calc_macd(df, df["ema12"], df["ema26"])
This will give us something like this:
To get a subset of the data and positions on the x-axis, we can again do:
df_plot = df[-230:-130]
xpos = range(100)
The process of building the chart is the same as for daily data, except we might do different customizations to the lables on the x-axis:
Building figure and subplots
fig = plt.figure(figsize=(12, 6))
ax1 = plt.subplot2grid((3, 1), (0, 0), rowspan=2)
ax2 = plt.subplot2grid((3, 1), (2, 0), rowspan=1)
ticks, labels = gp.weekly_labels(df_plot, df_plot.index, step=10)
Customizing x-axis ticks, labels and grid
for ax in [ax1, ax2]:
ax.set_xlim(xmin=-1, xmax=104)
ax.set_xticks(ticks)
ax.grid(alpha=0.3)
ax1.xaxis.set_ticklabels([])
ax1.tick_params(axis='x', length=0)
ax2.set_xticklabels(labels)
for label in ax2.get_xticklabels():
if len(label.get_text()) == 4:
label.set_fontsize(14)
label.set_fontweight("bold")
Adding plots
gp.candles(df_plot, ax1)
ax1.plot(xpos, df_plot["ema12"], "b-")
ax1.plot(xpos, df_plot["ema26"], "k-")
gp.macds(df_plot, ax2, "fast", "signal", "macd-h")
Contribute
Tips on contributing: https://github.com/ekkobit/gander/blob/master/CONTRIBUTING.md
Issue Tracker: https://github.com/ekkobit/gander/issues
Source Code: https://github.com/ekkobit/gander
Documentation: https://gander.readthedocs.io
Metadata
Release files for gander 0.0.4
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| gander-0.0.4.tar.gz | 10.8 kB | Without provenance | Details for gander-0.0.4.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| gander-0.0.4-py3-none-any.whl | Python 3 | none | any | Details for gander-0.0.4-py3-none-any.whl |
Total release size: 35.8 kB
Release files / gander-0.0.4.tar.gz
| Download URL | gander-0.0.4.tar.gz |
|---|---|
| Size | 10.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
2ecdfdd10bafbbeb467635a435d3c68038074baac69845ad59433c5e18b9c6d0
|
|
BLAKE2b-256 checksum How to use checksums |
7e81557a8ba6883381d322e3fbd65454e6a7f6e6bc3e3722d0060b0259640229
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.4.0 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.7.4
|
Release files / gander-0.0.4-py3-none-any.whl
| Download URL | gander-0.0.4-py3-none-any.whl |
|---|---|
| Size | 25.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
da2309b4a4187ff6c97bfa90f19ea9094c13a12eed3e392c1741a984b56002a3
|
|
BLAKE2b-256 checksum How to use checksums |
7173fb0e0295caf2f67e99dd0c5cbfa822753ea8c6779d3d024f5811e29e5f80
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.4.0 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.7.4
|
Security for gander 0.0.4
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.