Skip to content

Instantly share code, notes, and snippets.

Hitoshi Harada umitanuki

  • Alpaca
  • California
Block or report user

Report or block umitanuki

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
View Pipefile
[[source]]
url = "https://pypi.org/simple"
verify_ssl = true
name = "pypi"
[packages]
pipeline-live = ""
ipython = "*"
ta-lib = "*"
View Code.gs
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 Nov 19, 2018
Alpaca Backtrader Integration Example
View main.py
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 Sep 19, 2018
An example of live algo migrate from Quantopian
View algo.py
from pylivetrader.api import (
attach_pipeline,
date_rules,
time_rules,
order,
get_open_orders,
cancel_order,
pipeline_output,
schedule_function,
)
View Pipfile
[[source]]
url = "https://pypi.org/simple"
verify_ssl = true
name = "pypi"
[packages]
requests = "*"
BeautifulSoup4 = "*"
IPython = "*"
pandas = "*"
View Program.cs
using System;
using System.Configuration;
using Alpaca.Markets;
namespace example
{
class Program
{
static void Main(string[] args)
{
View new_portfolio.csv
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
View compare.csv
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
View iex_prices.py
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 Aug 22, 2018
Selenium script to get ETF consittuents
View selenium.py
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
You can’t perform that action at this time.