Skip to content

Instantly share code, notes, and snippets.

View mdominguez2010's full-sized avatar
🎯
Focusing

Marcos Dominguez mdominguez2010

🎯
Focusing
View GitHub Profile
# Plot ROC area under the curve
from sklearn.preprocessing import label_binarize
from sklearn.multiclass import OneVsRestClassifier
from sklearn.metrics import roc_curve, auc
from itertools import cycle
from sklearn import svm
from scipy import interp
# Binarize the output
def get_daily_adjusted_price_data(api_key, stock):
url = f"https://www.alphavantage.co/query?function=TIME_SERIES_DAILY_ADJUSTED&symbol={stock}&outputsize=full&apikey={api_key}"
raw_data = requests.get(url).json()
return raw_data
def create_dataframe(raw_data):
dataframe = pd.DataFrame(columns=['Date', 'Open', 'High', 'Low', 'Close', 'Adj Close', 'Volume'])
for key in raw_data["Time Series (Daily)"].keys():
@mdominguez2010
mdominguez2010 / wsb-non-unique.py
Last active November 5, 2021 19:17
wsb-non-unique
raw_data.drop(['exchange'], axis=1, inplace=True)
raw_data.drop(['delayed', 'realtimeEntitled'], axis=1, inplace=True)
# Similar operation as above on a list of columns that only have 1 unique value
for column in list(raw_data.columns):
if raw_data[column].nunique() <= 1:
raw_data.drop(column, axis=1, inplace=True)
raw_data.drop(
['cusip',
'assetType',
'description',
'assetMainType',
'symbol',
'securityStatus',
'symbol.1',
'bidTick',
'exchangeName',
CREATE DATABASE wallstreetbets;
\connect wallstreetbets;
CREATE TABLE sentiment_analysis(
stock text,
Bearish text,
Neutral text,
Bullish text,
Total_Compound text,
from os import set_blocking
import requests
import pandas as pd
import numpy as np
from datetime import date
import matplotlib.pyplot as plt
# Load in df
df = pd.read_csv('df.csv', index_col=0)
# Import Libraries
import pandas as pd
import praw
from data import *
import time
import matplotlib.pyplot as plt
import squarify
from nltk.sentiment.vader import SentimentIntensityAnalyzer
from datetime import date
import numpy as np
import pandas as pd
'''includes US stock symbols with market cap > 100 Million, and price above $3.
Download the csv file:
https://www.nasdaq.com/market-activity/stocks/screener?exchange=nasdaq&letter=0&render=download
for all of the NYSE, NASDAQ and NYSEAMERICAN public traded companies.
'''
stocks = pd.read_csv('tickers.csv')
@mdominguez2010
mdominguez2010 / test.py
Last active February 26, 2021 20:41
cc
# features and target
X = df.loc[:,'limit_bal':'Apr_Pmt']
y = df['Default']
# encode categorical
categoricals = list(X.select_dtypes('object').columns)
numericals = list(X.select_dtypes('int64').columns)
def encode_cats(categoricals, numericals):
"""