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
class fileclass: | |
def __init__(self, input): | |
self.Filename = input | |
self.Size = os.path.getsize(input) | |
def summary(self): | |
print(f'File is named {self.Filename} and has size {self.Size}') | |
def __lt__(obj1, obj2): | |
if obj1.Size<obj2.Size: | |
print(f'{obj1.Filename} is smaller than {obj2.Filename}\n') | |
if obj2.Size<obj1.Size: |
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
classdef fileclass | |
properties | |
Filename | |
Size | |
end | |
methods | |
function obj = fileclass(inputfile) | |
obj.Filename = inputfile; |
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
% Example x,y,z | |
x = [-15:1:1]; | |
y = sin(x/2); | |
z = (x/10).^3; | |
figure('color','w'); plot3(x,y,z,'o-','markersize',8,'color',[1,.5,.5],'linewidth',2,'markerfacecolor','k'); grid on | |
coords_tbl = array2table([x',y',z']); | |
zlims = get(gca,'ZLim') | |
set(gca,'nextplot','add','linewidth',1); |
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
figure('color','w'); ax = axes('nextplot','add'); | |
yd = 2; % Alter this variable to space your Tseries further apart on the y-axis | |
rowfun( @(cellnumber,tseries) plot(ax,1+tseries{1}+yd*cellnumber,'color','k'),... | |
mytable(:,{'CellNumber','Tseries'}) ) | |
set(ax,'YTick',[],'YColor','w','TickDir','out') |
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
dictionary_of_texts = dict() | |
for filename,pdf_text in zip(files,pdf_as_text): | |
if len( pdf_text )!=0: | |
dictionary_of_texts[filename] = pdf_text | |
try: | |
for filename,pdf_text in zip(problem_pdfs,image_pdf_text): | |
dictionary_of_texts[filename] = pdf_text | |
except: |
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
# Variables: | |
# (1) pdf_as_text | |
# where some list elements are empty because an attempt was made to | |
# read in a PDF that is a scanned image (not typed text) | |
# (2) files | |
# a list of file names and paths to the PDFs | |
!apt-get install poppler-utils | |
!pip install pdf2image |
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
import pickle, yfinance as yf | |
stock_tseries_df = pd.DataFrame() | |
for x in ssr_database.iterrows(): | |
try: | |
thisstock = yf.download( x[1].Ticker, start=x[1].Datetime.date(), end=x[1].NextDay.date(), interval = '30m' ) | |
tmp = pd.DataFrame( [ x[1].Ticker, x[1].Datetime, x[1].NextDay, \ | |
thisstock['Close'].values[0:13],thisstock['Close'].values[14:],\ |
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
import pickle | |
stock_tseries_df = pd.DataFrame() | |
for x in ssr_database.iterrows(): | |
try: | |
thisstock = yf.download( x[1].Ticker, start=x[1].Datetime.date(), end=x[1].NextDay.date(), interval = '30m' ) | |
tmp = pd.DataFrame( [ x[1].Ticker, x[1].Datetime, x[1].NextDay, thisstock['Close'].values[0:13],thisstock['Close'].values[14:],thisstock['Volume'].values[0:13],thisstock['Volume'].values[14:]] ).transpose() | |
stock_tseries_df = pd.concat( [stock_tseries_df,tmp] ) |
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
import re, pandas as pd | |
from dateutil import parser | |
lines = []; | |
with open('ssr.csv','r') as f: | |
while 1: | |
myline = f.readline() | |
if re.search('[A-Z]+,',myline) is not None: # A line containing stock information | |
lines.append( [re.search('[A-Z]+',myline).group(0),\ |
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
import requests | |
import urllib3 | |
from datetime import datetime | |
urllib3.disable_warnings() | |
headers = {'User-Agent': 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/42.0.2311.90 Safari/537.36'} | |
date_field = f'{datetime.now().year}{datetime.now().month:02}{datetime.now().day:02}' | |
url = f'https://www.nasdaqtrader.com/dynamic/symdir/shorthalts/shorthalts{date_field}.txt' | |
response = requests.get(url, headers=headers, verify=False).text; |
NewerOlder