This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import sys | |
| import json | |
| def etherscan_link(addy : str): | |
| return f"https://etherscan.io/address/{addy}" | |
| def formatted_addy(addy : str): | |
| l = etherscan_link(addy) | |
| return f"[{addy}]({l})" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "fmt" | |
| "os" | |
| "strings" | |
| "github.com/ethereum/go-ethereum/common" | |
| "github.com/ethereum/go-ethereum/common/hexutil" | |
| "github.com/ethereum/go-ethereum/crypto" |
We can't make this file beautiful and searchable because it's too large.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ,index,from,to,rate,size | |
| 3,2020-06-27 04:09:50.067495,USDC,SUSD,1.001588762375985,25000 | |
| 28,2020-06-27 04:11:11.292177,USDC,SUSD,1.001588762375985,25000 | |
| 53,2020-06-27 04:12:34.177547,USDC,SUSD,1.0027119623148046,25000 | |
| 78,2020-06-27 04:13:56.708093,USDC,SUSD,1.003010811424284,25000 | |
| 103,2020-06-27 04:15:20.536155,USDC,SUSD,1.0028803226935665,25000 | |
| 128,2020-06-27 04:16:43.109911,USDC,SUSD,1.002789565214155,25000 | |
| 153,2020-06-27 04:18:06.122941,USDC,SUSD,1.002789565214155,25000 | |
| 178,2020-06-27 04:19:29.468458,USDC,SUSD,1.0027931408604205,25000 | |
| 203,2020-06-27 04:20:52.114432,USDC,SUSD,1.0027931408604205,25000 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def simple_evaluate(data, states, hi=1.1, lo=0.9): | |
| skip = len(data) - len(states) | |
| chg = data['close'].pct_change()[skip:] | |
| n = max(states) + 1 | |
| buys, sells = np.zeros(len(states)), np.zeros(len(states)) | |
| for i in range(n): | |
| state = (states == i) | |
| dex = np.append(0, state[:-1]) | |
| V = (chg.multiply(dex, axis=0)+1).cumprod() | |
| if V[-1] > hi: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import requests | |
| def nomics_query(q): | |
| API_ROOT = "https://api.nomics.com/" | |
| API_VERSION = "v1" | |
| url = API_ROOT + API_VERSION + '/' + q | |
| return requests.get(url) | |
| def nomics_candles(api_key, interval, currency, start=None, end=None): | |
| q = "candles?key={}&interval={}¤cy={}".format(api_key, interval, currency) | |
| if start: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def kelly_four_moments(mu, sigma, c3, c4): | |
| return (c3/(3*c4) - (c3**2/c4**2 - 3*(mu**2 + sigma**2)/c4)/(3*(-c3**3/c4**3 + 9*c3*(mu**2 + sigma**2)/(2*c4**2) + np.sqrt(-4*(c3**2/c4**2 - 3*(mu**2 + sigma**2)/c4)**3 | |
| + (-2*c3**3/c4**3 + 9*c3*(mu**2 + sigma**2)/c4**2 - 27*mu/c4)**2)/2 - 27*mu/(2*c4))**(1/3)) | |
| - (-c3**3/c4**3 + 9*c3*(mu**2 + sigma**2)/(2*c4**2) + np.sqrt(-4*(c3**2/c4**2 - 3*(mu**2 + sigma**2)/c4)**3 | |
| + (-2*c3**3/c4**3 + 9*c3*(mu**2 + sigma**2)/c4**2 - 27*mu/c4)**2)/2 - 27*mu/(2*c4))**(1/3)/3) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import statsmodels.sandbox.distributions.extras as extras | |
| import scipy.interpolate as interpolate | |
| import numpy as np | |
| def generate_normal_four_moments(mu, sigma, skew, kurt, size=1000, sd_wide = 10): | |
| f = extras.pdf_mvsk([mu, sigma, skew, kurt]) | |
| x = np.linspace(mu - sd_wide * sigma, mu + sd_wide * sigma, num=500) | |
| y = [f(i) for i in x] | |
| yy = np.cumsum(y) / np.sum(y) | |
| inv_cdf = interpolate.interp1d(yy, x, fill_value="extrapolate") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @jit | |
| def game(): | |
| flip = np.random.binomial(1, .5) | |
| if flip == 1: | |
| return 1./3 | |
| return -3./10 | |
| @jit | |
| def repeated_game(S0, f, plays=1000): | |
| games = [game() for i in range(plays)] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import os | |
| import subprocess | |
| import argparse | |
| import shlex | |
| FIXED = r"""\documentclass{standalone} | |
| \usepackage{xcolor} | |
| \usepackage{amsmath} | |
| \usepackage[utf8]{inputenc} | |
| \usepackage[charter]{mathdesign} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| """ Simple websocket client wrapper """ | |
| import asyncio | |
| import ujson | |
| import websockets | |
| from logging import getLogger | |
| l = getLogger('websocket_client') | |
| class WebsocketClient: |