Skip to content

Instantly share code, notes, and snippets.

View umitanuki's full-sized avatar

Hitoshi Harada umitanuki

  • Alpaca
  • California
View GitHub Profile
@umitanuki
umitanuki / create 1000 inherit table.sql
Created June 14, 2011 06:11
create 1000 inherit table
do $$ declare declare begin for i in 1 .. 1000 loop execute 'create table myt' || i || '(check (id between ' || (i * 99) || ' and ' || (i * 100) || ' )) inherits(size_m)'; end loop; end; $$;
@umitanuki
umitanuki / Makefile
Created April 29, 2013 16:47
Attempt to cause EINTER but read is not interrupted by signal...
PROG = run
OBJS = main.o
all: $(PROG)
$(PROG): $(OBJS)
$(CC) -o $(PROG) $(OBJS)
clean:
rm -f $(OBJS) $(PROG)
PROG = run
OBJS = main.o
all: $(PROG)
$(PROG): $(OBJS)
$(CC) -o $(PROG) $(OBJS)
clean:
rm -f $(PROG) $(OBJS)
@umitanuki
umitanuki / multicast.go
Last active December 21, 2015 15:29
Multicast replies in unicast
package main
import "log"
import "net"
import "os"
var gaddr *net.UDPAddr = &net.UDPAddr{IP: net.IPv4(224, 0, 0, 254), Port: 12345}
func listener(c chan int) {
logger := log.New(os.Stdout, "[L]", log.Ltime | log.Lshortfile)
conn, err := net.ListenMulticastUDP("udp", nil, gaddr)
@umitanuki
umitanuki / turtle.py
Created March 22, 2016 21:23
Turtle in quantopian
# For this example, we're going to write a simple momentum script.
# When the stock goes up quickly, we're going to buy;
# when it goes down we're going to sell.
# Hopefully we'll ride the waves.
from collections import deque
import math
import talib
atr = ta.ATR(timeperiod=20) # used to calculate 20-day ATR
import matplotlib.pyplot as plt
from datetime import datetime
import alpaca_trade_api as tradeapi
import numpy as np
from positionhandling import positionHandler
import loader
api = tradeapi.REST()
@umitanuki
umitanuki / MLP.py
Created August 2, 2018 22:30
blog-mlp-scripts
import argparse
import sys
import tempfile
from time import time
import random
from os import listdir
from os.path import isfile, join
import pandas
@umitanuki
umitanuki / selenium.py
Created August 22, 2018 20:46
Selenium script to get ETF consittuents
import pandas as pd
'''
brew install phantomjs
or
brew tap homebrew/cask
brew cask install chromedriver
'''
# from selenium import webdriver
from selenium.webdriver.chrome.webdriver import WebDriver
import iexfinance
import pandas as pd
def iex_charts(symbols):
partlen = 99
result = {}
for i in range(0, len(symbols), partlen):
charts = iexfinance.Stock(symbols[i:i+partlen]).get_chart(range='1m')
if type(charts) == list:
charts = {symbols[i]: charts}
epoch replicated original
2018-07-23 00:00:00-04:00 0.0 0.0
2018-07-24 00:00:00-04:00 0.004842152599199184 0.005032119914346984
2018-07-25 00:00:00-04:00 0.014004961318249324 0.013597430406852257
2018-07-26 00:00:00-04:00 0.010925193556577603 0.011206281227694456
2018-07-27 00:00:00-04:00 0.004277340381589269 0.004354032833690319
2018-07-30 00:00:00-04:00 -0.0014288588707714984 -0.0008922198429693077
2018-07-31 00:00:00-04:00 0.0034754019979314626 0.004032833690221255
2018-08-01 00:00:00-04:00 0.0024404618505173285 0.0023554603854390615
2018-08-02 00:00:00-04:00 0.007497095460409252 0.007815845824411126