Skip to content

Instantly share code, notes, and snippets.

View umitanuki's full-sized avatar

Hitoshi Harada umitanuki

  • Alpaca
  • California
View GitHub Profile
[[source]]
url = "https://pypi.org/simple"
verify_ssl = true
name = "pypi"
[packages]
pipeline-live = ""
ipython = "*"
ta-lib = "*"
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";
@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 / 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,
)
[[source]]
url = "https://pypi.org/simple"
verify_ssl = true
name = "pypi"
[packages]
requests = "*"
BeautifulSoup4 = "*"
IPython = "*"
pandas = "*"
using System;
using System.Configuration;
using Alpaca.Markets;
namespace example
{
class Program
{
static void Main(string[] args)
{
shares price dollar
AAPL 2.0 190.9403 381.8806
MSFT 3.0 107.556 322.668
FB 1.0 210.91 210.91
JPM 1.0 113.35 113.35
JNJ 1.0 126.63 126.63
XOM 1.0 80.569 80.569
BAC 3.0 30.75 92.25
WFC 1.0 57.5786 57.5786
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
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}
@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