Skip to content

Instantly share code, notes, and snippets.

@joelonsql
joelonsql / PostgreSQL-EXTENSIONs.md
Last active May 5, 2024 22:09
1000+ PostgreSQL EXTENSIONs

🗺🐘 1000+ PostgreSQL EXTENSIONs

This is a list of URLs to PostgreSQL EXTENSION repos, listed in alphabetical order of parent repo, with active forks listed under each parent.

⭐️ >= 10 stars
⭐️⭐️ >= 100 stars
⭐️⭐️⭐️ >= 1000 stars
Numbers of stars might not be up-to-date.

@nicklatin
nicklatin / macro_factor_mimicking_portfolios.py
Last active September 17, 2023 03:32
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?ab…
"""
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
@nicklatin
nicklatin / orthogonalization.py
Last active November 12, 2022 15:45
Klein and Chow (2013) propose an optimal simultaneous orthogonal transformation of factors, following the so-called symmetric procedure of Schweinler and Wigner (1970) and Löwdin (1970): https://www.sciencedirect.com/science/article/abs/pii/S1062976913000185. The data transformation allows the identification of the underlying uncorrelated compon…
# orthogonalization of correlated factors in a multifactor model
def orthogonalize_factors(factors_df, output_format='df'):
"""
As described by Klein and Chow (2013) in Orthogonalized Factors and Systematic Risk Decompositions:
https://www.sciencedirect.com/science/article/abs/pii/S1062976913000185
They propose an optimal simultaneous orthogonal transformation of factors, following the so-called symmetric procedure
of Schweinler and Wigner (1970) and Löwdin (1970). The data transformation allows the identification of the underlying uncorrelated
components of common factors without changing their correlation with the original factors. It also facilitates the systematic risk
decomposition by disentangling the coefficient of determination (R²) based on factors' volatilities, which makes it easier to distinguish
@nicklatin
nicklatin / high_low_spread_estimator.py
Last active August 17, 2023 16:23
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
# 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.
@fritschy
fritschy / cryptsetup-with-luks2-and-integrity-demo.sh
Created April 20, 2020 13:08 — forked from MawKKe/cryptsetup-with-luks2-and-integrity-demo.sh
dm-crypt + dm-integrity + dm-raid = awesome!
#!/usr/bin/env bash
#
# Author: Markus (MawKKe) ekkwam@gmail.com
# Date: 2018-03-19
#
#
# What?
#
# Linux dm-crypt + dm-integrity + dm-raid (RAID1)
#

Problem

In Arch Linux mkinitcpio -p linux

shows

Possibly missing firmware for module: aic94xx
Possibly missing firmware for module: wd719x
Possibly missing firmware for module: xhci_pci
@huntrar
huntrar / full-disk-encryption-arch-uefi.md
Last active May 2, 2024 11:04
Arch Linux Full-Disk Encryption Installation Guide [Encrypted Boot, UEFI, NVMe, Evil Maid]

Arch Linux Full-Disk Encryption Installation Guide

This guide provides instructions for an Arch Linux installation featuring full-disk encryption via LVM on LUKS and an encrypted boot partition (GRUB) for UEFI systems.

Following the main installation are further instructions to harden against Evil Maid attacks via UEFI Secure Boot custom key enrollment and self-signed kernel and bootloader.

Preface

You will find most of this information pulled from the Arch Wiki and other resources linked thereof.

Note: The system was installed on an NVMe SSD, substitute /dev/nvme0nX with /dev/sdX or your device as needed.

@flipdazed
flipdazed / almgren_chriss.py
Created April 30, 2019 22:41
Linear Almgren-Chriss python model
import numba as nb
import numpy as np
def impact_perm(nu, gamma, beta):
"""Returns the permenant dollar price impact per unit time
In paper as :math:`g(\nu)`
Args:
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']
@iafisher
iafisher / bookmarks_from_sql.py
Created March 9, 2019 22:54
Programmatically access your Firefox bookmarks
"""
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.