Skip to content

Instantly share code, notes, and snippets.

def exponentialMovingAverage(period, data):
#--- Exponential Moving Average
# data: array, time series data e.g. daily close prices
# period: integer, number of periods form time series array to include in calculation
#--- import libraries
import numpy as np
#--- get first non nan index
dos2unix -n /tmp/target_file.txt /tmp/tmp.txt
mv -f /tmp/tmp.txt /tmp/target_file.txt
SELECT
CASE
WHEN length(
translate('testing123£$%^4521 with ch*(ars HELP TEST THIS',
' 1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz',
''
)
) > 0
THEN TRUE
ELSE FALSE
def simpleMovingAverage(period, data):
# --- Simple Moving Average
# data: array, time series data e.g. daily close prices
# period: integer, number of periods form time series array to include in calculation
# --- import libraries
import numpy as np
# --- get first non nan index
def t3MovingAverage(period,data,vfactor=0.7,tcount=3):
#--- T3 Moving Average
# data: array, time series data e.g. daily close prices.
# period: integer, number of periods form time series array to include in calculation.
# vfactor: float, number between 1 and 0. 1 = DEMA, 0 = EMA. default 0.7.
# tcount: integer, number 1 or greater. times the data is smoothed with the generalisedDEMA. default 3 (T3).
#
# requires numpy and techind libraries
#
def mesaAdaptiveMovingAverage(high, low, fastLimit, slowLimit, warmUpPeriod):
# --- MESA Adaptive Moving Average
# high: array, time series data e.g. daily close prices
# low: array, time series data e.g. daily close prices
# period: integer, number of periods from time series array to include in calculation
#
# converted from sources:
# https://www.mesasoftware.com/papers/MAMA.pdf
# https://www.quantconnect.com/forum/discussion/942/john-ehlers-mama-and-frama-indicators/p1
select
'testing1234521 with chars x2' as original_string,
trim(
translate(
original_string,
translate(
original_string,
'1234567890',
''
),
Private Function createDIR(dir As String) As Boolean
'--- Create Directory (recursivley)
' excel vba code to take string input as path and recursivley create
' folders if not exists. windows only.
'
' dir: full path to directory you want created (string)
'--- setup
createDIR = False