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 / 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
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()
[[source]]
url = "https://pypi.org/simple"
verify_ssl = true
name = "pypi"
[packages]
requests = "*"
BeautifulSoup4 = "*"
IPython = "*"
pandas = "*"
@umitanuki
umitanuki / algo.py
Created September 19, 2018 21:15
An example of live algo migrate from Quantopian
from pylivetrader.api import (
attach_pipeline,
date_rules,
time_rules,
order,
get_open_orders,
cancel_order,
pipeline_output,
schedule_function,
)
@umitanuki
umitanuki / main.py
Created November 19, 2018 02:01
Alpaca Backtrader Integration Example
import backtrader as bt
import alpaca_backtrader_api
import pandas as pd
class SmaCross(bt.SignalStrategy):
def __init__(self):
sma1, sma2 = bt.ind.SMA(period=10), bt.ind.SMA(period=30)
crossover = bt.ind.CrossOver(sma1, sma2)
self.signal_add(bt.SIGNAL_LONG, crossover)
@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
var PositionRowStart = 17;
function _request(path, params) {
var headers = {
"APCA-API-KEY-ID": "*** API key ID ***",
"APCA-API-SECRET-KEY": "*** API secret key",
};
var endpoint = "https://api.alpaca.markets";
using System;
using System.Configuration;
using Alpaca.Markets;
namespace example
{
class Program
{
static void Main(string[] args)
{
[[source]]
url = "https://pypi.org/simple"
verify_ssl = true
name = "pypi"
[packages]
pipeline-live = ""
ipython = "*"
ta-lib = "*"
@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