Skip to content

Instantly share code, notes, and snippets.

import datetime
import pandas as pd
from ib_insync import *
pd.set_option('display.max_rows', None)
ib = IB()
ib.connect('127.0.0.1', 7496, clientId=15)
contract = Stock('SPY', 'SMART', 'USD')
@fdoperezi
fdoperezi / nes.py
Created March 12, 2021 22:15 — forked from karpathy/nes.py
Natural Evolution Strategies (NES) toy example that optimizes a quadratic function
"""
A bare bones examples of optimizing a black-box function (f) using
Natural Evolution Strategies (NES), where the parameter distribution is a
gaussian of fixed standard deviation.
"""
import numpy as np
np.random.seed(0)
# the function we want to optimize
@fdoperezi
fdoperezi / 1_Storage.sol
Created January 8, 2021 19:24 — forked from rori4/1_Storage.sol
Created using remix-ide: Realtime Ethereum Contract Compiler and Runtime. Load this file by pasting this gists URL or ID at https://remix.ethereum.org/#version=soljson-v0.5.17+commit.d19bba13.js&optimize=false&gist=
pragma solidity >=0.4.22 <0.7.0;
/**
* @title Storage
* @dev Store & retreive value in a variable
*/
contract Storage {
uint256 number;
@fdoperezi
fdoperezi / ml_factor_investing.ipynb
Created July 22, 2020 00:12
ml_factor_investing.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@fdoperezi
fdoperezi / book_recs.md
Created June 11, 2020 01:17
Books I've used in class or found through other channels; spans Python, R, Java, C, C++, Finance, Data Science:

Machine Learning and AI for Finance

Advances in Financial Machine Learning, de Prado: http://www.quantresearch.org/
Machine Learning for Asset Managers, de Prado
Machine Learning for Factor Investing, Guida: http://www.mlfactor.com/
Big Data and Machine Learning in Quantitative Investment, Guida
Artificial Intelligence in Finance, Hilpisch: https://home.tpq.io/

Trading Analytics and Algorithms

Python for Finance 2d ed, Hilpisch
Derivatives Analytics with Python, Hilpisch

@fdoperezi
fdoperezi / Google Colab SSH
Created July 9, 2019 02:40 — forked from yashkumaratri/Google Colab SSH
SSH into google colab
#CODE
#Generate root password
import random, string
password = ''.join(random.choice(string.ascii_letters + string.digits) for i in range(20))
#Download ngrok
! wget -q -c -nc https://bin.equinox.io/c/4VmDzA7iaHb/ngrok-stable-linux-amd64.zip
! unzip -qq -n ngrok-stable-linux-amd64.zip
#Setup sshd
@fdoperezi
fdoperezi / kaggledays-sf_h2o_automl_6000.R
Created April 26, 2019 03:34 — forked from ledell/kaggledays-sf_h2o_automl_6000.R
KaggleDays SF: H2O AutoML solution
### Kaggle Days SF: Hackathon submission (8th place)
# I used the latest version of H2O (3.24.0.1)
# Latest stable always here: http://h2o-release.s3.amazonaws.com/h2o/latest_stable.html
# H2O 3.24.0.1: http://h2o-release.s3.amazonaws.com/h2o/rel-yates/1/index.html
# If you are a Python user, you can use the demo Python code available on the H2O AutoML User Guide
# instead: http://docs.h2o.ai/h2o/latest-stable/h2o-docs/automl.html
# Unfortunately it was a private competition, so the data is not publicly available!

#Background

For each type of analysis think about:

  • What problem does it solve, and for whom?
  • How is it being solved today?
  • How can it beneficially affect business?
  • What are the data inputs and where do they come from?
  • What are the outputs and how are they consumed- (online algorithm, a static report, etc)
  • Is this a revenue leakage ("saves us money") or a revenue growth ("makes us money") problem?
@fdoperezi
fdoperezi / keras.py
Created January 22, 2016 20:09 — forked from hnykda/keras.py
Tada's usage (see discussion)
""" From: http://danielhnyk.cz/predicting-sequences-vectors-keras-using-rnn-lstm/ """
from keras.models import Sequential
from keras.layers.core import TimeDistributedDense, Activation, Dropout
from keras.layers.recurrent import GRU
import numpy as np
def _load_data(data, steps = 40):
docX, docY = [], []
for i in range(0, data.shape[0]/steps-1):
docX.append(data[i*steps:(i+1)*steps,:])
@fdoperezi
fdoperezi / keras_prediction.py
Created January 22, 2016 20:08 — forked from Nemitek/keras_prediction.py
Predicting sequences of vectors (regression) in Keras using RNN - LSTM (original by danielhnyk.cz) - fixed for Keras 0.2.0
import pandas as pd
from random import random
flow = (list(range(1,10,1)) + list(range(10,1,-1)))*1000
pdata = pd.DataFrame({"a":flow, "b":flow})
pdata.b = pdata.b.shift(9)
data = pdata.iloc[10:] * random() # some noise
import numpy as np