コード例 #1
0
        )

    driver.add_testcase(
        "continuous-time",
        hedge_models.FeatureHedge(),
        risk_measure=hedge_models.ExpectedShortfall(alpha),
        normaliser=None,
        feature_function="delta",
        price_type="arbitrage")

    driver.add_testcase(
        "deep network",
        hedge_models.NeuralHedge(
            timesteps=timesteps * hedge_multiplier,
            instrument_dim=book.instrument_dim,
            internal_dim=0,
            num_layers=layers,
            num_units=units,
            activation=activation),
        risk_measure=hedge_models.ExpectedShortfall(alpha),
        normaliser=preprocessing.MeanVarianceNormaliser(),
        feature_function="log_martingale",
        price_type="arbitrage")


    driver.add_testcase(
        "deep network w. PCA",
        hedge_models.NeuralHedge(
            timesteps=timesteps * hedge_multiplier,
            instrument_dim=book.instrument_dim,
            internal_dim=0,
コード例 #2
0
    frequency=0,  # no need for frequency for non-path dependent derivatives.
    init_instruments=init_instruments,
    init_numeraire=init_numeraire,
    book=book,
    cost=1 / 100 if cost else None,
    risk_neutral=True,
    learning_rate=1e-1)
driver.verbose = 2

risklevels = [0.05, 0.5, 0.95] if not cost else [0.95]
for alpha in risklevels:
    driver.add_testcase(f"deep network {alpha}",
                        hedge_models.NeuralHedge(
                            timesteps=timesteps,
                            instrument_dim=book.instrument_dim,
                            internal_dim=0,
                            num_layers=4,
                            num_units=5,
                            activation=tf.keras.activations.softplus),
                        risk_measure=hedge_models.ExpectedShortfall(alpha),
                        normaliser=preprocessing.MeanVarianceNormaliser(),
                        feature_function="log_martingale",
                        price_type="arbitrage")

if driver.cost is not None or not driver.risk_neutral:
    driver.add_liability_free(
        hedge_models.LinearFeatureHedge(
            timesteps=timesteps,
            instrument_dim=book.instrument_dim,
            mappings=[approximators.IdentityFeatureMap] \
                * (1 + (driver.cost is not None))),
コード例 #3
0
                        normaliser=None,
                        feature_function=lazy_feature_function,
                        price_type="arbitrage")

    driver.add_testcase("jump continuous-time",
                        hedge_models.FeatureHedge(),
                        risk_measure=risk_measure(),
                        normaliser=None,
                        feature_function=jump_feature_function,
                        price_type="arbitrage")

    driver.add_testcase("deep network",
                        hedge_models.NeuralHedge(
                            timesteps=timesteps,
                            instrument_dim=tradebook.instrument_dim,
                            internal_dim=0,
                            num_layers=layers,
                            num_units=units,
                            activation=activation),
                        risk_measure=risk_measure(),
                        normaliser=preprocessing.MeanVarianceNormaliser(),
                        feature_function="log_martingale",
                        price_type="arbitrage")

    driver.add_testcase(
        "identity feature map",
        hedge_models.LinearFeatureHedge(
            timesteps=timesteps,
            instrument_dim=tradebook.instrument_dim,
            mappings=[approximators.IdentityFeatureMap] \
                * (1 + (driver.cost is not None))),