- Get key ratio, return csv format file
http://financials.morningstar.com/ajax/exportKR2CSV.html?t=<market>:<stock>
Market
- XHKG: Hong Kong Stock Exchange
- XASE: American Stock Exchange
- XNAS: Nasdaq Stock Exchange >* XNYS: New York Stock Exchange
| def dc(ohlcv, thresh=0.005): | |
| upturn_event = True | |
| p_h = p_l = ohlcv['close'][0] | |
| dc_ranges = defaultdict(list) | |
| tuples = tuple(ohlcv.itertuples()) | |
| # here we find the timedelta between the timeseries index, 1 and 0, so 1 day for daily data | |
| step = tuples[1].Index - tuples[0].Index | |
| # loop over tuples of ohlcv and time as Index, |
| """ | |
| Python code for fractional differencing of pandas time series | |
| illustrating the concepts of the article "Preserving Memory in Stationary Time Series" | |
| by Simon Kuttruf | |
| While this code is dedicated to the public domain for use without permission, the author disclaims any liability in connection with the use of this code. | |
| """ | |
| import numpy as np | |
| import pandas as pd |
| import numpy as np | |
| import pandas as pd | |
| from datetime import datetime | |
| from fastparquet import write | |
| def compute_vwap(df): | |
| q = df['foreignNotional'] | |
| p = df['price'] |
| { | |
| "metadata": { | |
| "name": "" | |
| }, | |
| "nbformat": 3, | |
| "nbformat_minor": 0, | |
| "worksheets": [ | |
| { | |
| "cells": [ | |
| { |
| # lazy data frame | |
| # | |
| # like idata.frame, but exploits lazy evaluation + macro code generation | |
| # instead of active bindings | |
| library(vadr) | |
| lazy.frame <- function(df, enclos=parent.frame(), ...) UseMethod("lazy.frame") | |
| lazy.frame.lazy.frame <- function(df, ...) df |
| """ | |
| A script to automatically export bookmarks from Firefox's SQLite database. | |
| There does not seem to be a programmatic way to get Firefox to export its bookmarks in | |
| the conventional HTML format. However, you can access the bookmark information directly | |
| in Firefox's internal database, which is what this script does. | |
| Always be careful when working with the internal database! If you delete data, you will | |
| likely not be able to recover it. |
| """ | |
| This function takes observable macro factors (surprises) as inputs and creates macro factor mimicking portfolios (MFMPs) as outputs. It uses | |
| a novel machine-learning approach, the Principal Components Instrumental Variables FMP Estimator, | |
| described by Jurczenko and Teiletche (2020) in Macro Factor-Micking Portfolios: | |
| https://papers.ssrn.com/sol3/papers.cfm?abstract_id=3363598 | |
| The methodology addresses many of the common problems associated with macro factors and multifactor risk modeling and, as they show, | |
| is superior to other common FMP approaches. | |
| We describe the steps of the PCIV algorithm below, as well as in our Medium post: | |
| For a more detailed explanation, see the link to the paper above. | |
| Note that access to macroeconomic and base assets is required to estimate macro factor-mimicking portfolios. See the macro factors |
| # high-low spread estimator (hlse) | |
| def hlse(ohlc_df, frequency='daily'): | |
| """ | |
| Computes the high-low spread estimator, an estimate of bid-offer spreads, a measure of liquidity risk. | |
| See Corwin & Schultz (2011) for details: https://papers.ssrn.com/sol3/papers.cfm?abstract_id=1106193 | |
| Parameters | |
| ---------- | |
| ohlc_df: DataFrame | |
| DataFrame with DatetimeIndex and Open, High, Low and Close (OHLC) prices from which to compute the high-low spread estimates. |