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
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 |
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 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']) |
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 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() |
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
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. |
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
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; |
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
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; |
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
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); |
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
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; |
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
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, |
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
{"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> | |
} |
NewerOlder