Skip to content

Instantly share code, notes, and snippets.

View 0xJchen's full-sized avatar
🀄
Focusing

Jiachen W 0xJchen

🀄
Focusing
View GitHub Profile
@0xJchen
0xJchen / gist:9693396ef7b8139014825478b3e8ba6e
Created September 17, 2023 05:04
AVL-Tree Testcase Generator
#!/bin/bash
# Function to generate a single test file
generate_test_file() {
local filename=$1
local num_commands=$2
> "$filename"
# Generate random 'i' and 'd' commands with random numbers
for (( j=0; j<$num_commands; j++ )); do
package test;
import java.awt.*;
import java.awt.geom.Rectangle2D;
import java.awt.image.BufferedImage;
import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;
#!/bin/bash
# Initialize an associative array to store png filenames and their corresponding grepped numbers
declare -A png_map
# Clear the loggers.txt file if it exists
> loggers.txt
# Iterate over each png file in ./selected directory
for png_file in ./selected/*.png; do
{
"cells": [
{
"cell_type": "code",
"execution_count": 35,
"metadata": {},
"outputs": [],
"source": [
"from SABR import SABR_swaption, SABR\n",
"import pandas as pd\n",
@0xJchen
0xJchen / test.ipynb
Created September 27, 2023 06:33
simple SABR
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@0xJchen
0xJchen / test_SABR.ipynb
Created September 27, 2023 06:34
simple SABR
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@0xJchen
0xJchen / SABR.ipynb
Created September 27, 2023 06:35
SIMPLE SABR
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@0xJchen
0xJchen / test.ipynb
Created September 27, 2023 06:36
sample sabr
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@0xJchen
0xJchen / test.ipynb
Created September 27, 2023 06:37
sample sabr
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@0xJchen
0xJchen / chatgpt-sabr.py
Last active September 27, 2023 10:11
chatgpt-sabr
import numpy as np
from scipy.optimize import minimize
from math import log, sqrt
import matplotlib.pyplot as plt
def sabr_iv(alpha, beta, rho, nu, F, K, T):
"""
Returns the implied volatility using the SABR model formula.
"""
X = K
if F == K: