Demo entry 6684599

py

   

Submitted by anonymous on Dec 16, 2017 at 12:58
Language: Python 3. Code size: 832 Bytes.

# Last funds calculation as part of start funds value, and make sure to include a
# little bit of shakiness. Number 2 just picked from thin air.
sharpe_ratio_ish = lambda funds: funds.iloc[-1] / (funds[0] * (funds.std() + 2))
settings = dict(optimize=np.median, fund_value=sharpe_ratio_ish)
currencies = [c for cg in currency_groups for c in cg.split()]
best_result = [-100] * len(currencies)
for _ in range(100):
    result = []
    for currency in currencies:
        df = load_currency(currency, now-60*days, now)
        simulate(df, settings)
        result += [settings.fund_value(df['funds'])]
    if settings.optimize(result) > settings.optimize(best_result):
        best_result = res
        best_settings = dict(settings)
    settings[some_key] = some_random_value # create new settings by randomizing here

This snippet took 0.01 seconds to highlight.

Back to the Entry List or Home.

Delete this entry (admin only).