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
#!/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
# untar and cd
if [[ ! -d "ta-lib" ]]; then
tar xvf ta-lib-0.4.0-src.tar.gz
lionelyoung /
Created Mar 28, 2020
Download xml and parse it into org mode for reading. Requires the full content to be in the RSS feed
#!/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 /
Last active Feb 9, 2020 — forked from mauler/
Python3 http.server supporting basic HTTP Auth (username/password)
# Extended python -m http.serve with --username and --password parameters for
# basic auth, based on
# 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 /
Last active Jan 21, 2020
update mlfinlab.labeling to use indexes profit taking and stop loss horizontal barriers
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
#!/usr/bin/env bash
# Mac Mojave, using Apple Clang
set -e
info () {
printf " [ \033[00;34m..\033[0m ] $1\n"
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
;; 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 /
Created Jul 9, 2017
Find a subdirectory name with maxdepth
# Find dir
function finddir () {
# Defaults
# Arg check
if [ "$#" -gt 2 ] || [ "$#" -lt 1 ] ; then
echo "Illegal number of parameters"
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))
(insert-kbd-macro name)
lionelyoung /
Created May 6, 2017
Calculate the last trading day given a contract_month
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.