Skip to content

Finalytics 1.0.0-rc.6

Pre-release
Pre-release

Choose a tag to compare

@Nnamdi-sys Nnamdi-sys released this 09 Nov 15:53
· 24 commits to main since this release

Added

  • keep_cash in optimise, as in rebalance: keep_cash=True (.keep_all_cash() in Rust)
    holds every currency's cash in current_weights at its current weight, and
    keep_cash=["USD"] (.keep_cash(["USD"])) that of the currencies named, and optimises the
    rest, with every limit measured on the whole portfolio. The weights hold the kept cash, so
    portfolio.rebalance(result, keep_cash=True) trades what the limits allow, and its turnover is
    the optimisation's. It needs current_weights, takes no cash limits on the cash it keeps,
    and applies to the frontier and to each refit of a walk-forward backtest (keep_cash in
    compare and backtest). methods() lists it with the limits of every method that takes
    limits, as a new kind of option, currencies; finalytics::KeepCash is its type in Rust.

  • include_benchmark in screen (.include_benchmark() in Rust) screens the universe's
    benchmark as a candidate too; see Changed.

  • A Python test runs every example in the package's docstrings, and JavaScript and Python tests
    hold the contract sweep's cases: every problem reported together, at the option given.

Fixed

  • Every problem with a call's inputs is reported together. A value that could not be read hid
    every other problem: an unknown method hid a limit out of range, a number that is not finite
    hid an unknown asset, fixed weights given limits hid an unknown asset, and a rebalancing's
    targets, a report's account and an asset setting hid the checks after them. Options are read
    field by field and checked on the fields that read; with an unknown method, only the checks
    that do not depend on it run, so no option is said to be unused by a method not chosen.

  • Five of the Python package's docstring examples used names they did not define; they run as
    written now. The cash and optimise docstrings said optimisation never holds cash, which
    cash limits and keep_cash change, and JavaScript's Result left out evaluate and
    rebalance. The methods page said one rule for unused options applies "in every verb"; it
    says which verbs now, and what the shared options risk_free_rate, expected_returns,
    current_weights and benchmark_weights change in a backtest: the fits of the methods that
    use them, not the report's ratios.

  • Minimum CVaR with limits on cash, such as cash=(0, 0.2), failed in its report ("weights: 6
    weights for 5 assets") on every kind of assets, though methods() lists the limit for it. The
    report now splits the expected shortfall over every weight, the cash's included, on the
    returns the method minimised.

  • An optimisation's weights could fall a little below zero, of the order of 1e-13, and the engine
    then refused its own output: portfolio.rebalance(optimisation), the weights given back as
    current_weights, and walk-forward backtests with trade limits, whose refits checked the
    weights the run held as if they had been given. The weights of optimise and the frontier are
    now within their bounds, at zero or the current weight where the solver was within 1e-7 of
    it, and add up to one; their expected return and volatility are those of the weights given.
    A refit starts from the weights the run holds without checking them as user input.

  • A walk-forward refit with trade limits after fits that found no weights, holding only cash,
    sent NaN weights without a risk-free asset (and could not invest with one). With nothing
    invested, a refit now enters from cash, as the first fit does.

  • Rebalancing to an optimisation traded every instrument: the assets the optimisation did not
    trade were within about 1e-10 of their current weights, and each difference became a separate
    trade of a fraction of a unit, paying the minimum fee, so the optimisation's max_trades and
    min_trade did not hold in the trades. An optimisation's weights for the assets it does not
    trade are now their current weights exactly, and rebalance treats a change worth less than
    one minor unit of the instrument's currency, or a billionth of the account's value, as no
    trade.

  • Every input that takes weights by asset now follows one rule, and portfolio.weights() is
    valid in each. current_weights, benchmark_weights (in optimise and the frontier), fixed
    weights and benchmark weights in backtests and comparisons refused cash in another currency,
    such as EUR cash, which Portfolio.assets() lists and evaluate takes; current_weights,
    benchmark_weights and plans refused Cash at the risk-free rate unless cash limits were
    given. Each now takes every label the assets list, cash included, and Cash where it stands
    for cash at the risk-free rate. An optimisation invests the cash in another currency it is
    given, counting it in the turnover and listing it among the trades; a benchmark's cash in
    another currency counts in the tracking error, with its risk; and a backtest holds such cash
    as the asset it is, moving with its exchange rate.

  • A report's benchmark_weights (for the tracking error) that named a holding not held, or did
    not add up to one, and expected_returns for a holding not held, were accepted: the first was
    caught inside the risk estimate and turned into a warning that dropped the holdings' risk from
    the overview and the risk report, and the others changed nothing. They are now refused when the
    report is built, with the other options, at options.benchmark_weights and
    options.expected_returns.

  • The optimisation report's chart labelled equal weight's point beside the weights' dot when
    the two nearly coincided, as for equal weight itself or given weights close to it, so the label
    read as the weights'. The label is left out then; the legend names the point.

  • The backtest and comparison reports echoed fixed weights, and a benchmark's weights, without
    their cash and with every asset they left out at zero: {"US Equity": 0.55, "Bonds": 0.35, "T-Bills": 0.1} came back as five assets adding up to 0.9. The reports' weights are now those
    given, the risk-free asset, Cash and cash in other currencies included.

  • A backtest given a name (name="Mine") used it for the strategy and the report's title but
    left report.name empty, where optimise, compare and evaluate put it. It is now there.

  • The Python and JavaScript documentation of Portfolio.assets() said it holds the instruments
    alone; it holds the portfolio's cash too, as the Rust documentation says: base-currency cash as
    the risk-free asset and cash in other currencies, so that the portfolio's own weights can be
    valued and optimised from.

Changed

  • One message for a label that is not one of the assets, unknown asset Nope, in every input
    that takes weights or values by asset; rebalancing targets said "is not an instrument of the
    portfolio". Current and benchmark weights and evaluate, like fixed weights, report weights
    that do not add up to one beside an unknown label, and fixed weights say where the cash goes
    as the others do ("give T-Bills, the risk-free asset, any cash"). Limits and risk budgets that
    name cash in another currency say that optimisation does not choose it, and expected returns
    for the risk-free asset or Cash point to risk_free_rate.

  • The digests of the optimisation, backtest and comparison reports (context.digest, printed as
    the inputs at the foot of each page) now cover every input: the strategies, their weights and
    options, the benchmark, the validation and the money for backtests and comparisons, and the
    method's parameters, the current and benchmark weights and the given weights for optimise
    and evaluate. Different inputs gave the same digest, such as minimum variance and risk
    parity, or a target return of 6% and of 7%. Every such digest changes.

  • Assets.frontier refuses what it does not use, in the words of the rule every verb follows
    (options.target: the frontier does not use target): a method (in JavaScript), a method's
    parameters, resampling, and the risk-free rate unless it is the return of Cash on a frontier
    that holds cash. It accepted them and did nothing. Python's frontier takes risk_free_rate
    for that case. In TypeScript, frontier takes FrontierOptions, the limits and the options
    they use, rather than Partial<OptimiseOptions>, and the options of compare and backtest
    (OptimiseLimits) no longer include current_weights, which backtests refuse.

  • A comparison refuses an option none of its methods takes in the words one optimisation uses,
    grouping the methods by their reason, and its notes name the options that do not apply to a
    method (The limits on cash do not apply.). It said that maximum Sharpe or minimum CVaR "is
    fully invested and long only, and takes no limits on weights", and noted that the limits on
    weights did not apply to a method when others had. A method that takes no limits, given
    cash, is said to take none rather than to keep its ratio.

  • Fields that options and documents do not have are refused at every depth, as the options'
    top level already was in Python and JavaScript: a group's misspelt maxx, which left the group
    without a limit, a goal's nmae, a walk-forward's yeers, and in Rust a misspelt top-level
    field of ReportOptions, OptimiseOptions or BacktestOptions read from JSON. JSON with
    extra members, which was read as if they were not there, is now refused, naming the member.

  • rebalance with keep_cash takes targets that give the kept cash its weight now, as an
    optimisation that kept the same cash gives them, as shares of the whole value; targets that
    leave the kept cash out are shares of the rest, as before. A target for kept cash at another
    weight is still refused, now saying the weight it has.

  • A rebalancing's turnover, for each account and for the accounts together, is half the sum
    of the changes in weight with the cash included, as an optimisation's is and its
    max_turnover limits; it was half the value traded in instruments. For the same trades the
    two figures now agree; a rebalancing that invests or raises cash shows a larger turnover.

  • The overview report's efficient frontier is the instruments', the one optimise and
    evaluate draw: it chose cash in other currencies as an asset, which optimisation never does,
    so its least risky point leaned on the cash. The overview's frontier figures change.

  • Attribution periods that reach past the report's start or date are attributed over the part
    within the report, with the benchmark's figures as given and a warning that says so, rather
    than refused; a period wholly outside the report is left out with a warning, and a report with
    no period inside it is refused.

  • A screen's benchmark serves beta and the other measures against it and is not a candidate:
    it is no longer listed, matched or counted among the securities, unless include_benchmark
    asks for it.

  • In Rust, Portfolio::assets() returns a builder ended by .build(), as every other verb with
    options does, so that options can be added to it later: portfolio.assets().build()?.
    Python and JavaScript keep assets().

  • Problems are reported at the option given, under options in every verb and language:
    options.trading_cost_bps and options.validation.start in backtests, options.chance in
    plans, options.limit and options.rules[0].measure in screens, options.covariance for
    Python's Assets as for JavaScript's, and options.fee_bps, options.tax[0] and
    options.accounts[0] in a rebalancing, rather than the fee rate and tax fields they become
    inside the engine. A comparison's strategy is at the method or weights it was given as
    (options.methods[1], options.weights.Mine) rather than strategies[k], a benchmark's
    weights at options.benchmark, a plan's fixed weights at options.weights rather than
    weights.weights, and a report's date before the books at options.as_of rather than a
    start not given. Problems are worded alike in JavaScript and Python: an unknown name or
    method as minimum_varience is not one of minimum_variance, …, a misspelt option with a
    suggestion (is not an option; did you mean max_weight?), a negative count as must be a whole number of zero or more, and a number that is not finite as NaN or Infinity.