Skip to content

Instantly share code, notes, and snippets.

View whittlem's full-sized avatar

Michael Whittle whittlem

View GitHub Profile
@whittlem
whittlem / rhel8-apache24-using-mpm
Last active September 7, 2020 16:26
Amazon AWS EC2 'User Data' script to auto provision Apache 2.4 using MPM on RHEL8
#!/bin/bash
yum repolist all;
yum-config-manager --enable codeready-builder-for-rhel-8-rhui-rpms;
yum update -y;
dd if=/dev/zero of=/swapfile bs=128M count=32;
chmod 600 /swapfile;
mkswap /swapfile;
swapon /swapfile;
@whittlem
whittlem / aws-ec2-rhel8-apache24
Created September 7, 2020 16:59
Amazon AWS EC2 RHEL8 provisioning script for Apache 2.4
#!/bin/bash
yum repolist all;
yum-config-manager --enable codeready-builder-for-rhel-8-rhui-rpms;
yum update -y;
dd if=/dev/zero of=/swapfile bs=128M count=32;
chmod 600 /swapfile;
mkswap /swapfile;
swapon /swapfile;
@whittlem
whittlem / movingAverageConvergenceDivergence.py
Last active November 17, 2020 13:21
Trading using Python - Moving Average Convergence Divergence (MACD)
# data: dictionary { 'dd/mm/yyy': price, 'dd/mm/yyyy': price, ... }
def movingAverageConvergenceDivergence(data):
if not isinstance(data, dict):
raise Exception('Dictionary input expected')
if (26 > len(data)):
raise Exception('Insufficient data for calculation')
@whittlem
whittlem / macd.py
Last active November 17, 2020 14:31
Trading using Python — Moving Average Convergence Divergence (MACD)
# https://whittle.medium.com/trading-using-python-moving-average-convergence-divergence-macd-4dbfee1c1a37
import re
import requests
from datetime import datetime
def cbpGetHistoricRates(market='BTC-GBP', granularity=86400, iso8601start='', iso8601end=''):
if not isinstance(market, str):
raise Exception('Market string input expected')
# https://whittle.medium.com/trading-using-python-relative-strength-index-rsi-f0c63c1c0db
import re
import requests
from datetime import datetime
def cbpGetHistoricRates(market='BTC-GBP', granularity=86400, iso8601start='', iso8601end=''):
if not isinstance(market, str):
raise Exception('Market string input expected')
# data: dictionary { 'dd/mm/yyy': price, 'dd/mm/yyyy': price, ... }
# num: range in the average calculation, normally 9 to 26
def simpleMovingAverage(data, num):
if not isinstance(data, dict):
raise Exception('Dictionary input expected')
if not isinstance(num, int):
raise Exception('Integer input expected')
if num < 5 or num > 200:
@whittlem
whittlem / ema.py
Last active November 17, 2020 16:54
Trading using Python — Exponential Moving Average (EMA)
# https://levelup.gitconnected.com/trading-using-python-exponential-moving-average-ema-f38ed3211a44?source=your_stories_page-------------------------------------
import re
import requests
from datetime import datetime
def cbpGetHistoricRates(market='BTC-GBP', granularity=86400, iso8601start='', iso8601end=''):
if not isinstance(market, str):
raise Exception('Market string input expected')
@whittlem
whittlem / sma.py
Created November 17, 2020 16:55
Trading using Python — Simple Moving Average (SMA)
# https://levelup.gitconnected.com/trading-using-python-simple-moving-average-sma-8713caf0d4ee
import requests
from datetime import datetime
# granularity: 60, 300, 900, 3600, 21600, 86400
def cbpGetHistoricRates(market='BTC-GBP', granularity=86400, iso8601start='', iso8601end=''):
api = 'https://api.pro.coinbase.com/products/' + market + '/candles?granularity=' + \
@whittlem
whittlem / matplotlib.py
Last active February 13, 2021 15:17
Technical Analysis Graphs using Python Matplotlib
import requests
from datetime import datetime
import matplotlib.pyplot as plt
def cbpGetHistoricRates(market='BTC-GBP', granularity=86400, iso8601start='', iso8601end=''):
api = 'https://api.pro.coinbase.com/products/' + market + '/candles?granularity=' + \
str(granularity) + '&start=' + iso8601start + '&end=' + iso8601end
resp = requests.get(api)
if resp.status_code != 200:
#!/bin/sh
### BEGIN INIT INFO
# Provides: apache
# Required-Start: $all
# Required-Stop: $all
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: apache
# Description: Start apache
### END INIT INFO