Skip to content

Instantly share code, notes, and snippets.

View Whamp's full-sized avatar

Will Hampson Whamp

View GitHub Profile
# build your encoder upto here. It can simply be a series of dense layers, a convolutional network
# or even an LSTM decoder. Once made, flatten out the final layer of the encoder, call it hidden.
# we use Keras to build the graph
latent_size = 5
mean = Dense(latent_size)(hidden)
# we usually don't directly compute the stddev σ
# but the log of the stddev instead, which is log(σ)
@StuartGordonReid
StuartGordonReid / RiskAdjustedReturnMetrics.py
Last active June 13, 2023 06:40
Measured of Risk-adjusted Return
import math
import numpy
import numpy.random as nrand
"""
Note - for some of the metrics the absolute value is returns. This is because if the risk (loss) is higher we want to
discount the expected excess return from the portfolio by a higher amount. Therefore risk should be positive.
"""