View ASME_B31G.jl
# Provided for informational purposes - user required to verify the output
# ASME B31G-2012 - Manual for Determining the Remaining Strength of Corroded Pipelines
# B31G Level 0 Evaluation
D = 20
Tnom = 1.0
pitMAX = .200
Lm = 1.5
Ltable = 4.35
View first_profitable_exit.jl
###############################################################
# exit first profitable price over entry
# exit after fixed bars (max_hold) if no profitable trade
###############################################################
signal = [0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0]
close = [10,10,8,3,14,5,6,2,4,22,2,1,1,1,10,3,3,3,3,3,3,30]
first_prof = zero(signal)
max_hold = 6
for i = 1:length(signal) # 1:length(signal)-1 if buying next bar at open
View n_bar_hold.jl
###################################
# n bar Hold - Stay in trade when repeat signals
###################################
# Dummy Data
Signal = [0 1 1 0 0 0 0 0 1 0 0 0 0 0 0 0 1 0 0 0 0 0 ]
# Initialize output
n_bar = zeros(signal)
i = 1
j = 1
View Noise_Test.jl
# Packages
using Indicators
# Build H L C matrix
h = data1_h
l = data1_l
c = data1_c
m = Array{Float64}(zeros(length(data1_c),0))
m = hcat(m,h)
m = hcat(m,l)
View 1min_data.jl
using DataFrames
using CSV
using Missings
# Load 1 minute data - close data sampled every 1 minute
main_data1_1min = CSV.read("C:/Users/Andrew.Bannerman/Desktop/Julia/GE/ES Data/1.min.reg.sess.es_0830_to_1500.txt",types=[String; String; fill(Float64, 4); Int;Int],header=true)
main_data2_1min = CSV.read("C:/Users/Andrew.Bannerman/Desktop/Julia/GE/ES Data/1.min.reg.sess.es_0830_to_1500.txt", header=true)
main_data3_1min = CSV.read("C:/Users/Andrew.Bannerman/Desktop/Julia/GE/ES Data/1.min.reg.sess.es_0830_to_1500.txt", header=true)
test_one = CSV.read("C:/Users/Andrew.Bannerman/Desktop/Julia/GE/ES Data/10.min.reg.sess.es.txt", header=true)
test = convert(Array{Float64},test_one[:Close])
View train_test_set_split.jl
# Split data to train and test sets
# dummy data
data = collect(1:1:100)
# Train and test sets
# Set specific % for train and test sets
len = length(data)
mult = .30
split_no = Int64.(round(mult * len))
train_set = data[1:split_no]
test_set = data[split_no+1:len]
View rolling_RS_hurst.jl
####################################################################################
# Rolling Hurst
####################################################################################
# initialize outputs
m = Array{Float64}(length(d_es_close),0)
log_n_out = m
out_RS = m
# Set lags (range or specific)
View rolling_autocorrelation.jl
# Rolling Autocorrelation
# Sliding window (k width)
mean_out = zeros(size(d_es_close,1))
var_out = zeros(size(d_es_close,1))
cov_out = zeros(size(d_es_close,1))
autocor_out = zeros(size(d_es_close,1))
devmean_out = zeros(size(d_es_close,1))
n=1000
k = 1 # set lag
n_lag = 100 # return series lag
View na.locf.jl
# NA LOCF
# First convert missing to 0 (just easier to work with)
# Pull data to array
example_array = df[:col]
example_array = Float64.(collect(Missings.replace(example_array, 0.0)))
# NA LOCF Function
function locf(x::Array{Float64})
dx = zeros(x)
View rleid.jl
function rleid(x::AbstractVector)
isempty(x) && return Int[]
rle = similar(x, Int)
idx = 1
rle[1] = idx
prev = x[1]
for i in 2:length(x)
this = x[i]
if ismissing(this)
if !ismissing(prev)