Skip to content

Instantly share code, notes, and snippets.

View Birappa87's full-sized avatar
🎯
Focusing

Birappa Goudanavar Birappa87

🎯
Focusing
View GitHub Profile
def dump_data(df, choice):
connection_string = f'postgresql://{user_name}:{password}@{host}:{port}/{db_name}'
# Create a database engine
engine = create_engine(connection_string)
# Create a sessionmaker
Session = sessionmaker(bind=engine)
if choice == 'CreditSpreadFile':
@Birappa87
Birappa87 / scraper.py
Created November 2, 2023 19:46
Main Logic
def main_covered_calls():
try:
urls = {
'coveredCalls' : 'https://www.optionsplay.com/hub/covered-calls'
}
html = extract_data(url=urls['coveredCalls'], choice='coveredCalls')
data = parse_data(html, choice='coveredCalls')
data.to_csv('data/covered_calls.csv')
dump_data(df=data, choice='coveredCalls', index=False)
@Birappa87
Birappa87 / scraper.py
Created November 2, 2023 19:40
Importing modules
from playwright.sync_api import sync_playwright
from bs4 import BeautifulSoup
from sqlalchemy import create_engine
from sqlalchemy.orm import sessionmaker
import subprocess
import pandas as pd
import datetime
import psycopg2
-- Retrieve next plan's start date located in the next row based on current row
WITH next_plan_cte AS (
SELECT
customer_id,
plan_id,
start_date,
LEAD(plan_id, 1) OVER(
PARTITION BY customer_id
ORDER BY plan_id) as next_plan
FROM subscriptions)