Initial commit: Version 1 of source code

This commit is contained in:
2025-09-21 08:34:54 -04:00
commit c8771c0683
3 changed files with 97 additions and 0 deletions

6
.env Normal file
View File

@@ -0,0 +1,6 @@
EMAIL_SENDER=your_email@gmail.com
EMAIL_RECIPIENT=recipient@example.com
EMAIL_PASSWORD=your_app_password
SMTP_SERVER=smtp.gmail.com
SMTP_PORT=587
SEC_API_KEY=your_sec_api_key

6
.env.example Normal file
View File

@@ -0,0 +1,6 @@
EMAIL_SENDER=your_email@gmail.com
EMAIL_RECIPIENT=recipient@example.com
EMAIL_PASSWORD=your_app_password
SMTP_SERVER=smtp.gmail.com
SMTP_PORT=587
SEC_API_KEY=your_sec_api_key

85
HedgeAnalyzer.py Normal file
View File

@@ -0,0 +1,85 @@
# pip install sec-api pandas python-dotenv
from sec_api import ThirteenFApi
import pandas as pd
from smtplib import SMTP
from email.mime.text import MIMEText
from email.mime.multipart import MIMEMultipart
from dotenv import load_dotenv
import os
import uuid
# Load environment variables from .env file
load_dotenv()
# Email configuration from .env
EMAIL_SENDER = os.getenv('EMAIL_SENDER')
EMAIL_RECIPIENT = os.getenv('EMAIL_RECIPIENT')
EMAIL_PASSWORD = os.getenv('EMAIL_PASSWORD')
SMTP_SERVER = os.getenv('SMTP_SERVER', 'smtp.gmail.com')
SMTP_PORT = int(os.getenv('SMTP_PORT', 587))
SEC_API_KEY = os.getenv('SEC_API_KEY') # Get free at sec-api.io
# Initialize SEC API
api = ThirteenFApi(SEC_API_KEY)
# Point72 CIK
CIK = '0001603466'
# Get latest two 13F filings
filings = api.get_filings(cik=CIK)
filings = sorted(filings, key=lambda x: x['periodOfReport'], reverse=True)[:2]
latest = filings[0]
prev = filings[1]
# Fetch holdings
latest_df = pd.DataFrame(api.get_holdings(accessionNo=latest['accessionNo']))
prev_df = pd.DataFrame(api.get_holdings(accessionNo=prev['accessionNo']))
# Set index for comparison
key_col = 'cusip'
latest_df = latest_df.set_index(key_col)
prev_df = prev_df.set_index(key_col)
# Additions
additions = latest_df[~latest_df.index.isin(prev_df.index)]
# Removals
removals = prev_df[~prev_df.index.isin(latest_df.index)]
# Changes >10%
both = latest_df.index.intersection(prev_df.index)
changes = latest_df.loc[both].join(prev_df.loc[both], lsuffix='_new', rsuffix='_old')
changes['share_change'] = changes['shrsOrPrnamt_new'] - changes['shrsOrPrnamt_old']
changes = changes[abs(changes['share_change']) / changes['shrsOrPrnamt_old'] > 0.1]
# Summary
summary = f"""
Point72 13F Changes {prev['periodOfReport']} to {latest['periodOfReport']}
Additions ({len(additions)}):
{additions[['nameOfIssuer', 'shrsOrPrnamt', 'value']].to_string()}
Removals ({len(removals)}):
{removals[['nameOfIssuer', 'shrsOrPrnamt', 'value']].to_string()}
Changes ({len(changes)}):
{changes[['nameOfIssuer_new', 'share_change']].to_string()}
"""
# Email
msg = MIMEMultipart()
msg['From'] = EMAIL_SENDER
msg['To'] = EMAIL_RECIPIENT
msg['Subject'] = f'Point72 13F Update {latest["periodOfReport"]}'
msg.attach(MIMEText(summary, 'plain'))
server = SMTP(SMTP_SERVER, SMTP_PORT)
server.starttls()
server.login(EMAIL_SENDER, EMAIL_PASSWORD)
server.send_message(msg)
server.quit()
print("Email sent!")