@davoodmehraban89 / VELYQOR / commits / 523ba5d
Fork 0

Intelligence, Advanced Charting & Trading Platform

feat(research): guarded personal-use yfinance export outside commercial ingestion

davoodmehraban89 committed Oct 12, 2026 at 00:25 UTC 523ba5df5797001ebdeb0a005388f5654115dbe7
1 file changed +60
scripts/research-yfinance.py new
+60
@@ -0,0 +1,60 @@
1 +#!/usr/bin/env python3
2 +"""Explicitly research-only Yahoo Finance export. Not part of production ingestion.
3 +
4 +The yfinance project states that downloaded Yahoo data is intended for personal use.
5 +Do NOT use this command to seed the commercial ChartNova database or public APIs.
6 +"""
7 +import argparse
8 +import csv
9 +from datetime import date
10 +import re
11 +import sys
12 +
13 +def main():
14 + parser = argparse.ArgumentParser(description="Research-only yfinance OHLC export to stdout.")
15 + parser.add_argument("--symbol", required=True, help="Yahoo Finance symbol, e.g. ^GSPC")
16 + parser.add_argument("--start", required=True, help="YYYY-MM-DD")
17 + parser.add_argument("--end", required=True, help="YYYY-MM-DD (exclusive)")
18 + parser.add_argument("--interval", choices=["1d", "1h"], default="1d")
19 + parser.add_argument("--acknowledge-research-only", action="store_true", required=True)
20 + args = parser.parse_args()
21 + if not args.acknowledge_research_only:
22 + parser.error("Must acknowledge research-only, personal-use limitations")
23 + if not re.fullmatch(r"[A-Za-z0-9^._=\-]{1,40}", args.symbol):
24 + parser.error("Invalid Yahoo ticker")
25 + try:
26 + start = date.fromisoformat(args.start)
27 + end = date.fromisoformat(args.end)
28 + except ValueError:
29 + parser.error("Dates must be valid YYYY-MM-DD")
30 + if end <= start:
31 + parser.error("End must be after start")
32 + try:
33 + import yfinance as yf
34 + except ImportError:
35 + parser.error("Research dependency missing: install yfinance in an isolated Python environment")
36 +
37 + frame = yf.Ticker(args.symbol).history(
38 + start=args.start, end=args.end, interval=args.interval,
39 + auto_adjust=False, actions=False,
40 + )
41 + if frame.empty:
42 + print("No vendor rows returned; nothing exported.", file=sys.stderr)
43 + return 2
44 + print(
45 + "RESEARCH ONLY — Yahoo Finance rights are not verified for "
46 + "ChartNova commercial storage or redistribution.", file=sys.stderr
47 + )
48 + csvout = csv.writer(sys.stdout)
49 + csvout.writerow(["source","rights","symbol","interval","source_timestamp","open","high","low","close","volume"])
50 + for stamp, row in frame.iterrows():
51 + if stamp.tzinfo is None:
52 + raise ValueError("Provider returned timezone-naive timestamp; cannot safely export")
53 + csvout.writerow([
54 + "yfinance","research_only",args.symbol,args.interval,
55 + stamp.isoformat(),row["Open"],row["High"],row["Low"],row["Close"],row.get("Volume", ""),
56 + ])
57 + return 0
58 +
59 +if __name__ == "__main__":
60 + raise SystemExit(main())