This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- 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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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': |