Skip to content

Instantly share code, notes, and snippets.

@jwsmithers
jwsmithers / normalise.py
Last active April 26, 2020 04:02
Normalise
def normalise_df(df,asset,norm_window_size=100,use_preloaded_scalers=False):
"""
Normalise the dataframe.
This normalises by column (i.e. feature). Some people call this scaling
Args:
df(pd.df): The dataframe to normalise
asset (str): Stock name we're trying to predict (or first stock name)
norm_window_size (int): The window size for each feature to normalise.
use_preloaded_scalers (bool): False for training, True for inference
@jwsmithers
jwsmithers / HyperparameterTable.md
Last active August 15, 2019 15:45
HyperparameterTable
Parameters Description Value
LSTM layers - 2
LSTM Nodes - 33
Dense Nodes - 95
Dense Activation - selu
Normalisation window - 1000
Batch size Number of sequence in a batch 150
Sequence length Number of previous points to take into account 22
News lag Number of days prior to current day to take news into account 1
@jwsmithers
jwsmithers / DownloadFromIB.py
Last active December 2, 2022 17:42
Function to download from IB
from ib_insync import *
import asyncio
import nest_asyncio
async def update_from_IB(stock):
"""
Asynchronous call example to update stocks from Interactive broker.
Args:
stock(str): Stock, I.e. AAPL