Skip to content

Instantly share code, notes, and snippets.

#!/bin/bash -x
echo "Script started";
echo "Downloading the Ranger policy patch script";
wget -O /tmp/patch_policy_esp.py https://hdiconfigactions.blob.core.windows.net/linuxhdiplclusterconfigactionv01/patch_policy_esp.py
sudo python /tmp/patch_policy_esp.py
echo "Scripts Finished"
@ivannp
ivannp / format_default
Created February 16, 2018 06:04
format/default to support lib.ivannp
#
# Copyright (C) 1996-2001, Thomas Andrews
#
# $Id: default 277 2008-10-27 17:36:14Z thomasoa $
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
@ivannp
ivannp / rallies.r
Last active November 28, 2017 20:14
POTUS Rallies since Election Day
require(quantmod)
require(ggplot2)
require(ggthemes)
# The starting index in the elections dates and president's arrays
# start.index = 7
start.index = 6
# sp = getSymbols("^GSPC", from="1900-01-01", auto.assign=F)
sp = as.xts(read.csv.zoo('dji.csv', format='%Y%m%d', header=F, sep=",")[,1:4])
import dshelper as dsh
import instrumentdb as idb
import logging
import numpy as np
import os
import pandas as pd
import psutil
import sys
import tensorflow as tf
import time
@ivannp
ivannp / m4b2mp3.py
Created February 12, 2017 02:28
Converting files (.m4b to .mp3) in python
import glob
import os
import subprocess
def main():
base_dir = os.path.abspath('d:/abooks')
ffmpeg_path = os.path.abspath('C:/tools/ffmpeg/bin/ffmpeg.exe')
pattern = os.path.join(base_dir, '**', '*.m4b')
import cntk
import cntk.ops as C
import numpy as np
from sklearn.preprocessing import OneHotEncoder
from cntk.blocks import default_options, Input # Building blocks
from cntk.initializer import glorot_uniform
from cntk.layers import Dense # Layers
from cntk.learner import sgd, learning_rate_schedule, UnitType
@ivannp
ivannp / mlloop.py
Last active November 5, 2018 20:30
Walk-Forward Machine Learning Loop
import dshelper as dsh
import numpy as np
import os
import pandas as pd
import sys
import time
from sklearn.discriminant_analysis import QuadraticDiscriminantAnalysis as QDA
from sqlalchemy import create_engine, MetaData
@ivannp
ivannp / opportunities.py
Last active August 16, 2017 21:27
Discovering trading opportunities in price series and generating possible predictors
import pandas as pd
import numpy as np
import instrumentdb as idb
import math
import pickle
def good_entries(ohlcv, min_days = 3, days_out = 15, vola_len = 35, days_pos = 0.6, stop_loss = 1.5):
if days_out <= min_days:
raise RuntimeError('days_out must be greater than min_days.')
'''
A module to load instruments and bars from a SQLite database.
'''
import pandas as pd
import toml
from sqlalchemy import create_engine
class CsiDb:
require(R6)
require(quantmod)
# Db interface
YahooDb = R6Class("YahooDb",
public = list(
initialize = function(path="yahoo.sqlite") {
private$path = path
},