Skip to content

Instantly share code, notes, and snippets.

View alexanu's full-sized avatar

Oleksandr Anufriyev alexanu

View GitHub Profile
@alexanu
alexanu / stock_market_api.py
Created February 2, 2020 15:58
Finnhub stock market api example
import requests
#OHLC data
r = requests.get('https://finnhub.io/api/v1/stock/candle?symbol=AAPL&resolution=1&from=1572651390&to=1572910590')
print(r.json())
#Tick data
r = requests.get('https://finnhub.io/api/v1/stock/tick?symbol=AAPL&from=1575968404&to=1575968424')
print(r.json())
@alexanu
alexanu / volumebar_generator.py
Created January 12, 2020 16:22 — forked from GerardBCN/volumebar_generator.py
Volume bar generator
import numpy as np
# expects a numpy array with trades
# each trade is composed of: [time, price, quantity]
def generate_volumebars(trades, frequency=10):
times = trades[:,0]
prices = trades[:,1]
volumes = trades[:,2]
ans = np.zeros(shape=(len(prices), 6))
candle_counter = 0