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 / 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())
@PatrickAlphaC
PatrickAlphaC / tiingo_sample.py
Last active January 21, 2020 17:29
Simple Tiingo Startup
import requests
import json
token = 'XXX'
# Get a token from https://api.tiingo.com/
ticker = "TSLA"
url = "https://api.tiingo.com/tiingo/daily/{}/prices?token={}".format(ticker, token)
response = requests.get(url)
print(response.json())
@PatrickAlphaC
PatrickAlphaC / alpha_vantage_sample.py
Last active January 21, 2020 17:29
Simple Alpha Vantage Startup
import requests
import json
key = 'XXX'
# Get a key from https://www.alphavantage.co/support/#api-key
ticker = 'TSLA'
url = 'https://www.alphavantage.co/query?function=GLOBAL_QUOTE&symbol={}&apikey={}'.format(ticker, key)
response = requests.get(url)
print(response.json())
@PatrickAlphaC
PatrickAlphaC / alphavantagesimple.sol
Last active May 8, 2020 01:16
Start using Alpha Vantage data in your smart contracts
// For documentation, check out:
// https://alphavantage.co
// More Chainlink documentation on solidity
// https://github.com/alphavantage/alpha-vantage-chainlink
pragma solidity >= 0.4.20;
// MAKE SURE TO USE A 0.4.24 COMPILER IN REMIX
import "https://github.com/smartcontractkit/chainlink/evm-contracts/src/v0.4/ChainlinkClient.sol";
import "https://github.com/smartcontractkit/chainlink/evm-contracts/src/v0.4/vendor/Ownable.sol";

Keybase proof

I hereby claim:

  • I am patrickalphac on github.
  • I am patrickalphac (https://keybase.io/patrickalphac) on keybase.
  • I have a public key ASAyyIwPsnA5C2ncU6b55yI1RzCtZGJy6FW8plXCURsTzgo

To claim this, I am signing this object:

@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 / 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 / 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 / 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():