Skip to content

Instantly share code, notes, and snippets.

View bnsheehy's full-sized avatar

Bryant Sheehy bnsheehy

  • Chicago area
View GitHub Profile
@bnsheehy
bnsheehy / rs_matrix_pseudocode
Last active January 17, 2022 04:56
RS Matrix Pseudocode
Set the parameter values:
boxSize = 0.035
reversalThreshold = 3
reversalAmount = boxSize x reversalThreshold = 0.105
historyDays = 180
lagTime = 0 days
endDate = today - lagTime
startDate = today - historyDays
@bnsheehy
bnsheehy / open_local_window_colab.py
Created January 7, 2022 19:24
Python Open Local Window - Colab
# Import the libraries.
from google.colab import files
import io
import json
# Use files.upload to produce the "Choose Files" button below, then select your file.
uploaded = files.upload()
# Use io.BytesIO to decode the file, then json.load to open it.
file = io.BytesIO(uploaded['sample_credentials.json'])
@bnsheehy
bnsheehy / open_local_window_tkinter.py
Last active January 13, 2022 18:54
Python Open Local Drive Window - Tkinter
# Import the Tkinter and JSON libraries
from tkinter import *
from tkinter import filedialog
from tkinter import Tk
import json
# Quickly get rid of the root window popup
root = Tk()
root.withdraw()
@bnsheehy
bnsheehy / pnf_pseudocode.txt
Created January 4, 2022 22:16
Point & Figure Pseudocode
If previous day’s plot_symbol = "X", then:
If current price >= previous price, then:
Today's plot_symbol = "X".
and copy yesterday's signal_name to today.
And if today's price is higher than the last high_point:
then make today's price the high_point,
and copy yesterday's signal_name to today.
@bnsheehy
bnsheehy / bpi_alculation.sql
Created December 28, 2021 21:02
BPI Calculation
SELECT p.date, SUM(p.signal_name = 'BUY') / COUNT(*)
FROM base_pnf_data_historical AS p
LEFT JOIN custom_lists AS c ON p.ticker = c.ticker
WHERE p.date > '2021-01-01'
AND c.list_names LIKE 'SP500%'
GROUP BY p.date;
@bnsheehy
bnsheehy / Duplicate_PnF_Backup_Table.sql
Created December 26, 2021 22:43
Create Backup Table for PnF Data
CREATE TABLE base_pnf_data_historical_bkup AS SELECT * FROM base_pnf_data_historical;
INSERT INTO base_pnf_data_historical_bkup AS SELECT * FROM base_pnf_data_historical;
@bnsheehy
bnsheehy / Index_PnF_Columns.sql
Created December 26, 2021 22:40
Index the PnF History Data Table Columns
CREATE INDEX idx_ticker ON base_pnf_data_historical (ticker(8));
CREATE INDEX idx_figi ON base_pnf_data_historical (figi(14));
CREATE INDEX idx_date ON base_pnf_data_historical (date);
CREATE INDEX idx_update_date ON base_pnf_data_historical (last_update_date);
CREATE INDEX idx_corp_action_date ON base_pnf_data_historical (last_corp_action_date);
@bnsheehy
bnsheehy / Load_PnF_Table.sql
Last active December 26, 2021 22:38
Load the PnF Data History Table
LOAD DATA LOCAL INFILE '/Users/....../data_files/df_pnf_data_history_complete_load.csv'
INTO TABLE price_data_historical
FIELDS TERMINATED BY ','
ENCLOSED BY '"'
IGNORE 1 LINES;
@bnsheehy
bnsheehy / Create_PnF_Historical_Table.sql
Created December 26, 2021 22:33
Create the PnF Historical Data Table
CREATE TABLE IF NOT EXISTS `base_pnf_data_historical` (
`key_id` varchar(40) NOT NULL,
`date` datetime NOT NULL,
`figi` varchar(14) NOT NULL,
`ticker` varchar(8) NOT NULL,
`open` float NULL,
`high` float NULL,
`low` float NULL,
`close` float NULL,
`change` float NULL,
{"file_path": <my file path>,
"intrinio_key": <my Intrinio API key>,
"aws_access_key": <my AWS access key>,
"aws_secret_key": <my AWS secret key>,
"rds_host": <my RDS host URL>,
"rds_user": <my RDS user name>,
"rds_password": <my RDS password>,
"rds_database": <my RDS database name>,
"rds_charset": <my RDS characterset code>
}