Skip to content

Instantly share code, notes, and snippets.

@boyboi86
boyboi86 / create_synthetic_data.py
Last active February 28, 2024 08:36
Generate Synthetic High-Frequency Data for Quantitative research
import numpy as np
import pandas as pd
import datetime as dt
from sklearn.datasets import make_classification
def create_price_data(start_price: float = 1000.00, mu: float = .0, var: float = 1.0, n_samples: int = 1000000):
i = np.random.normal(mu, var, n_samples)
df0 = pd.date_range(periods=n_samples, freq=pd.tseries.offsets.Minute(), end=dt.datetime.today())
@endolith
endolith / frequency_estimator.py
Last active October 26, 2024 20:10
Frequency estimation methods in Python
from __future__ import division
from numpy.fft import rfft
from numpy import argmax, mean, diff, log, nonzero
from scipy.signal import blackmanharris, correlate
from time import time
import sys
try:
import soundfile as sf
except ImportError:
from scikits.audiolab import flacread