Skip to content

Instantly share code, notes, and snippets.

View PatrickAlphaC's full-sized avatar
💭
Enabling web3 developers at scale

Patrick Collins PatrickAlphaC

💭
Enabling web3 developers at scale
View GitHub Profile
@PatrickAlphaC
PatrickAlphaC / alpha_vantage_short_start.py
Created September 12, 2019 18:26
Alpha Vantage Get Started Short Version
from alpha_vantage.timeseries import TimeSeries
# Your key here
key = 'yourkeyhere'
ts = TimeSeries(key)
aapl, meta = ts.get_daily(symbol='AAPL')
print(aapl['2019-09-12'])
@PatrickAlphaC
PatrickAlphaC / alpha_vantage_get_started.py
Last active September 13, 2019 17:46
Alpha Vantage Python Start
'''
On your terminal run:
pip install alpha_vantage
This also uses the pandas dataframe, and matplotlib, commonly used python packages
pip install pandas
pip install matplotlib
For the develop version run:
pip install git+https://github.com/RomelTorres/alpha_vantage.git@develop
@PatrickAlphaC
PatrickAlphaC / threading_alpha_vantage.py
Last active October 7, 2019 18:07
A simple start to threading in python with alpha vantage
from alpha_vantage.timeseries import TimeSeries
import threading
import os
# I use an environment vairable to get my key,
# you can also just hardcode your key in the code to test this
KEY = os.path.expandvars("$ALPHA_VANTAGE_HIGHER_KEY")
ts = TimeSeries(key=KEY, output_format='pandas')
# 10 tickers from the NASDAQ-100
tickers = ['ATVI','ADBE','AMD','ALXN','ALGN', 'GOOG', 'AMZN', 'AAL', 'ADI', 'AMAT']
@PatrickAlphaC
PatrickAlphaC / threadpoolexecutor.py
Last active October 7, 2019 18:07
Using a threadpoolexecutor in python
# For python 3.2+
from alpha_vantage.timeseries import TimeSeries
from concurrent.futures import ThreadPoolExecutor
import os
KEY = os.path.expandvars("$ALPHA_VANTAGE_HIGHER_KEY")
ts = TimeSeries(key=KEY, output_format='pandas')
tickers = ['ATVI','ADBE','AMD','ALXN','ALGN', 'GOOG', 'AMZN', 'AAL', 'ADI', 'AMAT']
def thread_pool():
@PatrickAlphaC
PatrickAlphaC / threadpoolexecutor_full.py
Last active October 7, 2019 18:07
Using the threadpoolexecutor in all it's glory
from alpha_vantage.timeseries import TimeSeries
from concurrent.futures import ThreadPoolExecutor
import os
KEY = os.path.expandvars("$ALPHA_VANTAGE_HIGHER_KEY")
ts = TimeSeries(key=KEY, output_format='pandas')
tickers = ['ATVI','ADBE','AMD','ALXN','ALGN', 'GOOG', 'AMZN', 'AAL', 'ADI', 'AMAT']
def thread_pool():
with ThreadPoolExecutor(max_workers=10) as executor:
@PatrickAlphaC
PatrickAlphaC / https_redirect.js
Created October 17, 2019 23:27
A chunk of code to add to your app.js file in node to make it rediect http to https (not-secure to secure)
var app = express()
// Make sure you call this before you call any app.get functions.
app.use(requireHTTPS);
// code here, with gets and such
function requireHTTPS(req, res, next) {
// The 'x-forwarded-proto' check is for Heroku
if (!req.secure && req.get('x-forwarded-proto') !== 'https' && process.env.NODE_ENV !== "development") {
return res.redirect('https://' + req.get('host') + req.url);
@PatrickAlphaC
PatrickAlphaC / vendor_compare.py
Created November 15, 2019 19:12
Data vendor comparison
# You'll need 3 environment variables API keys to run this
# ALPHAVANTAGE_API_KEY
# INTRINIO_PROD_KEY
# IEX_TOKEN
# Sometimes the vendor will error out the API call and you'll have to call it again....
from __future__ import print_function
import pandas as pd
import threading
@PatrickAlphaC
PatrickAlphaC / tradier_sample.py
Created January 21, 2020 17:28
Simple Tradier Sandbox startup
import requests
import json
ticker = 'TSLA'
# Only US tickers in the developer account
token = 'XXXXX'
# Get a sandbox/developer token here: https://developer.tradier.com/
headers = {'Authorization': 'Bearer {}'.format(token),
'Accept': 'application/json'}
@PatrickAlphaC
PatrickAlphaC / sample_xignite.py
Last active January 21, 2020 17:28
Simple Xignite Startup
import requests
import json
token = 'XXXXX'
# Get an Xignite token from https://www.xignite.com/Register
url = "http://globalcurrencies.xignite.com/xGlobalCurrencies.json/ListCurrencies?_token={}".format(token)
response = requests.get(url)
print(response.json())
@PatrickAlphaC
PatrickAlphaC / intrinio_sample.py
Last active January 21, 2020 17:29
Simple Intrinio Startup
import requests
import json
key = 'XXXX'
# Get a key from https://intrinio.com/
ticker = 'MSFT'
url = 'https://api-v2.intrinio.com/companies/{}?api_key={}'.format(ticker, key)
response = requests.get(url)
print(response.json())