mirror of
https://github.com/PR0M3TH3AN/python_charts.git
synced 2026-10-27 08:50:39 +00:00
Merge pull request #11 from PR0M3TH3AN/codex/unify---offset-parameter-name
Unify offset argument
This commit is contained in:
3 files changed
+5
-5
No files matched your search
@@ -183,7 +183,7 @@ After downloading the required series, generate the Bitcoin‐Global M2 overlay
|
|||||||
|
|
||||||
([Real Python][1], [Software Engineering Stack Exchange][2])
|
([Real Python][1], [Software Engineering Stack Exchange][2])
|
||||||
2. Renames each column to `"value"` for consistency.
|
2. Renames each column to `"value"` for consistency.
|
||||||
3. Finds the overlapping date range, shifts M2 by `--offset-days` (default = 94 days), and overlays the two series on dual axes.
|
3. Finds the overlapping date range, shifts M2 by `--offset` (default = 94 days), and overlays the two series on dual axes.
|
||||||
4. Saves the figure—e.g., `outputs/bitcoin_m2_chart_20250531_090608.png` ([martinheinz.dev][4], [Real Python][1])
|
4. Saves the figure—e.g., `outputs/bitcoin_m2_chart_20250531_090608.png` ([martinheinz.dev][4], [Real Python][1])
|
||||||
|
|
||||||
> **CLI Options for `bitcoin_m2_chart.py`:**
|
> **CLI Options for `bitcoin_m2_chart.py`:**
|
||||||
@@ -194,7 +194,7 @@ After downloading the required series, generate the Bitcoin‐Global M2 overlay
|
|||||||
> | `--m2-series` | `GLOBAL_M2` | FRED series code for global M2 money supply |
|
> | `--m2-series` | `GLOBAL_M2` | FRED series code for global M2 money supply |
|
||||||
> | `--start` | `2010-01-01` | Start date for fetching both series |
|
> | `--start` | `2010-01-01` | Start date for fetching both series |
|
||||||
> | `--end` | Today | End date for fetching both series |
|
> | `--end` | Today | End date for fetching both series |
|
||||||
> | `--offset-days` | `94` | Shift M2 by this many days (positive → M2 leads) |
|
> | `--offset` | `94` | Shift M2 by this many days (positive → M2 leads) |
|
||||||
> | `--extend-years` | `1` | Years beyond `end` to extend the x‐axis |
|
> | `--extend-years` | `1` | Years beyond `end` to extend the x‐axis |
|
||||||
> | `--output` | None | Optional path to save the figure (PNG/PDF) |
|
> | `--output` | None | Optional path to save the figure (PNG/PDF) |
|
||||||
|
|
||||||
|
|||||||
@@ -104,7 +104,7 @@ def main(argv: list[str] | None = None) -> plt.Figure:
|
|||||||
help="end date YYYY-MM-DD",
|
help="end date YYYY-MM-DD",
|
||||||
)
|
)
|
||||||
p.add_argument(
|
p.add_argument(
|
||||||
"--offset-days",
|
"--offset",
|
||||||
type=int,
|
type=int,
|
||||||
default=94,
|
default=94,
|
||||||
help="shift M2 by this many days (positive = M2 leads)",
|
help="shift M2 by this many days (positive = M2 leads)",
|
||||||
@@ -124,7 +124,7 @@ def main(argv: list[str] | None = None) -> plt.Figure:
|
|||||||
end_dt = datetime.fromisoformat(args.end)
|
end_dt = datetime.fromisoformat(args.end)
|
||||||
|
|
||||||
btc, m2 = fetch_series(start_dt, end_dt, args.btc_series, args.m2_series, args.db)
|
btc, m2 = fetch_series(start_dt, end_dt, args.btc_series, args.m2_series, args.db)
|
||||||
fig = plot_bitcoin_m2(btc, m2, args.offset_days, args.extend_years)
|
fig = plot_bitcoin_m2(btc, m2, args.offset, args.extend_years)
|
||||||
|
|
||||||
save_figure(fig, args.output, __file__)
|
save_figure(fig, args.output, __file__)
|
||||||
if argv is None:
|
if argv is None:
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ import matplotlib.pyplot as plt
|
|||||||
import pandas as pd
|
import pandas as pd
|
||||||
|
|
||||||
# IMPORTANT: import common directly (no "scripts." prefix)
|
# IMPORTANT: import common directly (no "scripts." prefix)
|
||||||
from common import fetch_series_db, save_figure
|
from scripts.common import fetch_series_db, save_figure
|
||||||
|
|
||||||
|
|
||||||
def fetch_series_multi(
|
def fetch_series_multi(
|
||||||
|
|||||||
Reference in new issue
Block a user