Skip to content

Instantly share code, notes, and snippets.

View carloocchiena's full-sized avatar

Carlo Occhiena carloocchiena

View GitHub Profile
"""
I'm starting to like the Variance-Gamma model quite a bit.
Here is a quick and dirty Octave (Matlab) code for generating the IV skew given VG parameters
I took the parameters from the Madan, Carr and Chang paper.
Instead of evaluating a double integral I use the mixing formula, which results in a single integral.
From Linkedin profile of Frido Rolloos
""
import numpy as np
@carloocchiena
carloocchiena / aziona_SQL_tutorial.sql
Created December 28, 2023 17:37
SQL code for tutorial for Aziona blog
-- create our table
CREATE TABLE Videogiochi (
ID INT PRIMARY KEY AUTO_INCREMENT,
Nome VARCHAR(100) NOT NULL,
AnnoUscita INT NOT NULL,
Rating INT CHECK (Rating >= 1 AND Rating <= 5)
);
-- insert the data
INSERT INTO Videogiochi (Nome, AnnoUscita, Rating) VALUES
@carloocchiena
carloocchiena / zencastr backup script
Last active February 16, 2023 18:10
Put this script in console to download a corrupted track from the browser (Google Chrome)
app.location.recordings.each(function (recording) {
recording.tracks.each(function (track) {
track.downloadFromLocal(window.location.href);
})
})
# copy and paste the script on a Jupyter Notebook to have the
# table printed on screen
import numpy as np
import pandas as pd
from scipy.integrate import quad
def normal_probability_density(x):
constant = 1.0 / np.sqrt(2 * np.pi)
return(constant * np.exp((-x**2) / 2))
# TSP with heuristic dynamic programming
# Solution is based on "always picking the shortest route available" on the matrix
from itertools import permutations
def travel_salesman_problem(graph: list, path_sum: int = 0) -> int:
vertex = []
min_path = []
[MASTER]
# A comma-separated list of package or module names from where C extensions may
# be loaded. Extensions are loading into the active Python interpreter and may
# run arbitrary code.
extension-pkg-allow-list=
# A comma-separated list of package or module names from where C extensions may
# be loaded. Extensions are loading into the active Python interpreter and may
# run arbitrary code. (This is an alternative name to extension-pkg-allow-list
from fastapi import FastAPI, HTTPException
from pydantic import BaseModel
from typing import Optional
import uvicorn
# instantiate our FastApi application
app = FastAPI()
# initiate our test dataset
videogames = [
# Play it live on https://replit.com/@carlo_/wordletest#main.py
import random
from collections import Counter
from english_words import english_words_lower_alpha_set as words
words = list(words)
SECRET = words[random.choice(range(len(words)))]
@carloocchiena
carloocchiena / django_cheatsheet.py
Last active October 30, 2022 01:34
A simple list of django CLI commands you may need whenever starting up a new project
# Django Cheatsheet
# start a new Python env (with Anaconda)
`conda create -n my_env pip python=3.8.8` # insert your fav python version here
# activate Python Env
`conda activate my_env`
# install Django
`pip install django`