Skip to content

Instantly share code, notes, and snippets.

Lionel Young lionelyoung

Block or report user

Report or block lionelyoung

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View install_talib_linux.sh
#!/usr/bin/env bash
# Download ta-lib-0.4.0-src.tar.gz and:
if [[ ! -f "ta-lib-0.4.0-src.tar.gz" ]]; then
wget http://prdownloads.sourceforge.net/ta-lib/ta-lib-0.4.0-src.tar.gz
fi
# untar and cd
if [[ ! -d "ta-lib" ]]; then
tar xvf ta-lib-0.4.0-src.tar.gz
fi
@lionelyoung
lionelyoung / rss_blogspot_to_org.py
Created Mar 28, 2020
Download xml and parse it into org mode for reading. Requires the full content to be in the RSS feed
View rss_blogspot_to_org.py
#!/usr/bin/env python
# Download xml and parse it into org mode for reading
# Requires the full content to be in the RSS feed
import argparse
from lxml import etree
import logging
import os
import requests
import subprocess
import sys
@lionelyoung
lionelyoung / http_server_auth.py
Last active Feb 9, 2020 — forked from mauler/http_server_auth.py
Python3 http.server supporting basic HTTP Auth (username/password)
View http_server_auth.py
# Extended python -m http.serve with --username and --password parameters for
# basic auth, based on https://gist.github.com/fxsjy/5465353
# Usage: python -m http_server_auth -u USERNAME -p PASSWORD -d .
from functools import partial
from http.server import SimpleHTTPRequestHandler, test
import base64
import os
class AuthHTTPRequestHandler(SimpleHTTPRequestHandler):
@lionelyoung
lionelyoung / labeling_plus.py
Last active Jan 21, 2020
update mlfinlab.labeling to use indexes profit taking and stop loss horizontal barriers
View labeling_plus.py
def apply_pt_sl_on_t1(close, events, pt_sl, molecule): # pragma: no cover
"""
Snippet 3.2, page 45, Triple Barrier Labeling Method
This function applies the triple-barrier labeling method. It works on a set of
datetime index values (molecule). This allows the program to parallelize the processing.
Mainly it returns a DataFrame of timestamps regarding the time when the first barriers were reached.
:param close: (series) close prices
View install_lightgbm_mac.sh
#!/usr/bin/env bash
# https://lightgbm.readthedocs.io/en/latest/Installation-Guide.html#macos
# Mac Mojave, using Apple Clang
set -e
info () {
printf " [ \033[00;34m..\033[0m ] $1\n"
}
View strategy_position_debug.py
from qtpylib.algo import Algo
from qtpylib import futures
class DebugPosition(Algo):
def on_start(self):
self.counter = 0
self.counter_at_entry = 0
def on_fill(self, instrument, order):
View easylanguage-mode.obj
;; easylanguage mode
;; https://www.emacswiki.org/emacs/GenericMode
;; too many members for the default specpdlsize
;; still missing some options, processed via
;; #!/bin/sh
;; cat $1 | awk '{ print $1 }' | tr -d ";" | grep = | cut -f1 -d= | sort -u | while read x; do echo -n "\"$x\" "; done
(setq max-specpdl-size 6000)
(define-generic-mode 'easylanguage-mode
;; comments
@lionelyoung
lionelyoung / finddir.sh
Created Jul 9, 2017
Find a subdirectory name with maxdepth
View finddir.sh
# Find dir
# https://stackoverflow.com/questions/2824504/how-do-i-prevent-find-from-printing-git-folders
function finddir () {
# Defaults
DEPTH=4
# Arg check
if [ "$#" -gt 2 ] || [ "$#" -lt 1 ] ; then
echo "Illegal number of parameters"
fi
@lionelyoung
lionelyoung / emacs.el
Created Jun 16, 2017
Random Emacs Functions from Pastebin
View emacs.el
(defun user--save-macro (name)
"Save a macro. Take a name as an argument and save the last defined macro under this name."
(interactive "SName of the macro :")
(kmacro-name-last-macro name)
(find-file "~/.emacs.d/macros.el")
(goto-char (point-max))
(newline)
(insert-kbd-macro name)
(newline)
(save-buffer)
@lionelyoung
lionelyoung / crude_futures_lasttradingday.py
Created May 6, 2017
Calculate the last trading day given a contract_month
View crude_futures_lasttradingday.py
import datetime
from dateutil.relativedelta import relativedelta
import pandas as pd
from pandas.tseries.offsets import BDay
def crude_futures_lasttradingday(contract_month):
"""Trading in the current delivery month shall cease on the third business
day prior to the twenty-fifth calendar day of the month preceding the
delivery month. If the twenty-fifth calendar day of the month is a
non-business day, trading shall cease on the third business day prior to the
You can’t perform that action at this time.