Repository navigation
Expand file tree
/
Copy pathforms.py
More file actions
79 lines (67 loc) · 2.61 KB
/
Copy pathforms.py
File metadata and controls
79 lines (67 loc) · 2.61 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
"""Prixe /api/forms — SEC filings with optional AI summaries.
Covers the last 6 years. Supports 10-K, 10-Q, 8-K, 13F-HR, Form 3/4/5,
144, 424B2-8, CORRESP, D, EFFECT, FWP, SC TO-*, SD, and their amendments.
Requires Pro+ subscription.
"""
import requests
API_KEY = "YOUR_API_KEY"
BASE = "https://api.prixe.io"
HEADERS = {
"Authorization": f"Bearer {API_KEY}",
"Content-Type": "application/json",
}
def available_forms(ticker: str, year: int | None = None):
"""GET /api/forms — list the form types available for a ticker."""
params = {"ticker": ticker}
if year is not None:
params["year"] = year
r = requests.get(f"{BASE}/api/forms",
headers={"Authorization": HEADERS["Authorization"]},
params=params)
r.raise_for_status()
data = r.json()
scope = f" in {year}" if year else " (all years)"
print(f"{data['company_name']} ({ticker}) — {data['total_filings']} filings{scope}:")
for row in data["forms"]:
print(f" {row['form']:12s} {row['count']} filings")
def annual_report(ticker: str, year: int = 2024, ai_summary: bool = True):
"""POST /api/forms — fetch the 10-K for a given ticker/year, with AI summary."""
r = requests.post(
f"{BASE}/api/forms",
headers=HEADERS,
json={"ticker": ticker, "form": "10-K", "year": year, "ai_summary": ai_summary},
)
r.raise_for_status()
data = r.json()
for filing in data["filings"]["data"]:
print(f"[{filing['filing_date']}] {filing.get('ai_title') or filing['form']}")
if filing.get("ai_summary"):
print(f" {filing['ai_summary']}")
if filing.get("period_of_report"):
print(f" Covers period ending: {filing['period_of_report']}")
def insider_trades(ticker: str, start: str, end: str):
"""POST /api/forms — Form 4 insider transactions in a date range."""
r = requests.post(
f"{BASE}/api/forms",
headers=HEADERS,
json={
"ticker": ticker,
"form": "4",
"year": int(start[:4]),
"start_date": start,
"end_date": end,
"limit": 50,
},
)
r.raise_for_status()
data = r.json()
print(f"{data['pagination']['total']} Form 4 filings for {ticker} {start}..{end}")
for filing in data["filings"]["data"]:
txns = filing.get("transactions") or []
print(f" {filing['filing_date']} {len(txns)} transactions")
if __name__ == "__main__":
available_forms("TSLA", year=2024)
print()
annual_report("MSFT", year=2024)
print()
insider_trades("AAPL", "2024-07-01", "2024-09-30")