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
# julia language | |
using Plots | |
# n = degrees | |
n = 360 | |
sin_out = fill(NaN,n) | |
cos_out = fill(NaN,n) | |
for i = 1:size(sin_out,1) | |
# julia function - sind,cosd = sin/cos in degrees | |
sin_out[i] = sind(i) | |
cos_out[i] = cosd(i) |
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
""" | |
``` | |
Relative strength index | |
rsi(x::Array{T}; n::Int64=14)::Array{Float64} | |
Indicator weights the average gain and loss correctly not averaging over 0 values. Accounts for NaN in the calculation | |
using NaNMath; nm=NaNMath | |
``` | |
""" | |
function rsi(x::AbstractArray{T}; n::Int64=14)::Array{Float64} where {T<:Real} | |
dims = size(x,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
// Implements a dictionary's functionality | |
#include <ctype.h> | |
#include <stdbool.h> | |
#include <stdint.h> | |
#include <stdio.h> | |
#include <stdlib.h> | |
#include <string.h> | |
#include <strings.h> | |
#include <math.h> |
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
function collatz(n::Int64)::Int64 | |
while(n != 1) | |
# base case | |
if n == 1 | |
break | |
end | |
# if even | |
if (n % 2 == 0) | |
n = Int64(n /2) | |
elseif (n % 2 != 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 python modules | |
import os | |
import pandas as pd | |
# directory name from which | |
# we are going to extract our files with its size | |
path = "C:/Users/andre/Downloads/OneDrive_1_4-5-2022" | |
# Get list of all files only in the given directory | |
fun = lambda x: os.path.isfile(os.path.join(path, x)) |
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
using FredApi, DataFrames, Dates, Statistics, Plots, TimeSeries | |
# load FRED oil data | |
key = "your_key" | |
set_api_key(key) | |
# full sample | |
crude_oil = get_symbols("WTISPLC") | |
price = values(crude_oil) |
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
using DataFrames, Plots, CSV, Dates, Statistics | |
# Load CDC NHCS covid weekly data | |
nhcs = CSV.read("C:/Users/andrew.bannerman/Desktop/Julia/scripts/Provisional_COVID-19_Deaths_by_Week__Sex__and_Age.csv", DataFrame, header=true, delim=",") | |
#rename columns | |
colnames = ["Data_as_of", "State", "MMWR_Week", "End_Week", "Sex", "Age_Group", "Total_Deaths", "COVID19_Deaths"] | |
rename!(nhcs, colnames) | |
# Subset data only for all sexes |
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
# GHCN data | |
using CSV | |
using DataFrames | |
using Dates | |
using Statistics | |
using Plots | |
# Data | |
# USCHN | |
# https://cdiac.ess-dive.lbl.gov/epubs/ndp/ushcn/ushcn.html#:~:text=The%20United%20States%20Historical%20Climatology%20Network%20%28USHCN%29%20is,observing%20stations%20across%20the%2048%20contiguous%20United%20States. |
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
# Data: https://www.ncei.noaa.gov/access/metadata/landing-page/bin/iso?id=gov.noaa.ncdc%3AC00861 | |
###################################################################################################### | |
# load .dly data file | |
# load as 1x string per row | |
# split the string per the readme .txt element / column position (static) | |
# export as .csv | |
###################################################################################################### | |
# read all files in directory | |
all_dly_files = cd(readdir, "C:/Users/andrew.bannerman/Desktop/Julia/scripts/GHCN data/ghcnd_all/") |
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
using CSV, DataFrames, Plots | |
# load data | |
data = CSV.read("D:/Model Book/pattern recognition/data_store/MOXC.csv",header=true) | |
# Prepare data for OHLC plot | |
n = size(data,1) | |
high_p = Float64.(data.high) | |
low_p = Float64.(data.low) | |
open_p = Float64.(data.open) |
NewerOlder