Skip to content

Instantly share code, notes, and snippets.

View scubamut's full-sized avatar

scubamut

  • Individual
  • Johannesburg and London
View GitHub Profile
@scubamut
scubamut / app.py
Last active August 29, 2015 14:19 — forked from vgoklani/app.py
from flask import Flask, render_template
app = Flask(__name__)
@app.route('/')
@app.route('/index')
def index(chartID = 'chart_ID', chart_type = 'bar', chart_height = 350):
chart = {"renderTo": chartID, "type": chart_type, "height": chart_height,}
series = [{"name": 'Label1', "data": [1,2,3]}, {"name": 'Label2', "data": [4, 5, 6]}]
title = {"text": 'My Title'}
@scubamut
scubamut / install pkg from jupyter
Last active February 4, 2019 06:16
Install a conda package in the current Jupyter kernel
#
import sys
!conda install --yes --prefix {sys.prefix} -c anaconda beautifulsoup4
@scubamut
scubamut / dash_app_template.py
Last active February 23, 2018 09:08 — forked from alysivji/dash_app_template.py
Dash app template
# standard library
import os
# dash libs
import dash
from dash.dependencies import Input, Output
import dash_core_components as dcc
import dash_html_components as html
import plotly.figure_factory as ff
import plotly.graph_objs as go
@scubamut
scubamut / 1. install
Last active March 25, 2019 09:35
COLAB: setup for strategy backtests
from __future__ import print_function
!pip install git+https://github.com/scubamut/fintools.git
!pip install cvxopt
!pip install pyfolio
!pip install ffn
!pip install itable
!pip install git+https://github.com/pydata/pandas-datareader.git
@scubamut
scubamut / plotly-in-colab.ipynb
Last active August 30, 2018 10:35
Plotly in Colab.ipynb
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@scubamut
scubamut / print_bundle_symbols.py
Last active March 18, 2023 09:11
How to print symbols in the zipline bundle
# HOW TO PRINT BUNDLE SYMBOLS
import os
from pandas import Timestamp
from zipline.data.bundles import load
now = Timestamp.utcnow()
bundle = load('US_stock_bundle', os.environ, now)
symbols = set(str(asset.symbol)
for asset in bundle.asset_finder.retrieve_all(
@scubamut
scubamut / RS0001
Last active June 26, 2023 13:20
For use with quantopian algorithms
"""
This is a template algorithm on Quantopian for you to adapt and fill in.
"""
import pandas as pd
import numpy as np
def initialize(context):
"""
Called once at the start of the algorithm.
"""
# https://www.quantopian.com/posts/introducing-the-pipeline-api
"""
This example comes from a request in the forums.
The post can be found here: https://www.quantopian.com/posts/ranking-system-based-on-trading-volume-slash-shares-outstanding
The request was:
I am stuck trying to build a stock ranking system with two signals:
1. Trading Volume/Shares Outstanding.
# import research
from quantopian.research import run_pipeline
# import pipeline methods
# from quantopian.algorithm import attach_pipeline, pipeline_output
from quantopian.pipeline import Pipeline, CustomFilter
# Fundamantals
from quantopian.pipeline.data import Fundamentals
from quantopian.pipeline.data import morningstar
# import research
from quantopian.research import run_pipeline
# import pipeline methods
# from quantopian.algorithm import attach_pipeline, pipeline_output
from quantopian.pipeline import Pipeline, CustomFilter
# Fundamantals
from quantopian.pipeline.data import Fundamentals
from quantopian.pipeline.data import morningstar