Liking cljdoc? Tell your friends :D

var-techml-neanderthal.core

Public API — re-exports all sub-namespaces for single-ns consumers.

Aliases here carry the defining var's :doc, :arglists, :file and :line, so (doc var-techml-neanderthal.core/foo) shows the real documentation and REPL-driven editor hover (Calva, CIDER) works. Static-only analysis (clj-kondo, Cursive's offline index) does not expand this macro and will show less — require the defining namespace directly if that is how your editor resolves symbols.

Public API — re-exports all sub-namespaces for single-ns consumers.

Aliases here carry the defining var's :doc, :arglists, :file and :line, so
(doc var-techml-neanderthal.core/foo) shows the real documentation and
REPL-driven editor hover (Calva, CIDER) works. Static-only analysis
(clj-kondo, Cursive's offline index) does not expand this macro and will
show less — require the defining namespace directly if that is how your
editor resolves symbols.
raw docstring

beta-tmdclj

(beta-tmd dx dy xtail)
source

beta-tmd-ex-tailsclj

(beta-tmd-ex-tails dx dy)
source

bond-total-returnclj

(bond-total-return entry-price exit-price coupon days)
source

conditional-betaclj

(conditional-beta dts pred)

Beta over just the rows where the benchmark return satisfies pred.

Beta over just the rows where the benchmark return satisfies pred.
sourceraw docstring

days->monthsclj

(days->months dates)

It's quite hard without actual interop with java.time etc. 25d will suffice

It's quite hard without actual interop with java.time etc. 25d will suffice
sourceraw docstring

days->weeksclj

(days->weeks dates)
source

ds-daily-changeclj

(ds-daily-change dataset cols f)

This will error out if there are several columns with the same name.

This will error out if there are several columns with the same name.
sourceraw docstring

ds-date-filterclj

(ds-date-filter dataset dates)
source

ds-differencesclj

(ds-differences dataset)
source

ds-differences-with-indexclj

(ds-differences-with-index dataset index-col-name)
source

ds-returnsclj

(ds-returns dataset)
source

ds-returns-with-indexclj

(ds-returns-with-index dataset index-col-name)
source

linear-regression-tmdclj

(linear-regression-tmd dx dy)

Same speed as matrix and you lose the alpha - but easier to read and easier inputs will return [beta r2]

Same speed as matrix and you lose the alpha - but easier to read and easier inputs
will return [beta r2]
sourceraw docstring

linear-regression-tmd-ex-tailsclj

(linear-regression-tmd-ex-tails dx dy)

5x slower with tails

5x slower with tails
sourceraw docstring

maxdrawdownclj

(maxdrawdown xs)

Single pass tracking running peak and running min-drawdown - ~10x faster than (apply min (map - xs (reductions max xs))), which walks xs three times through lazy seqs instead of once.

Single pass tracking running peak and running min-drawdown - ~10x faster
than (apply min (map - xs (reductions max xs))), which walks xs three times
through lazy seqs instead of once.
sourceraw docstring

nd-beta-breakdownclj

(nd-beta-breakdown bonds
                   nominals
                   adjusted-history-prices
                   portfolio-value
                   benchmark-return)

Marginal beta calculation - this is tricky. In particular we define a new series of returns such that all weights are constant at 1: S(i,t) = N(i) * r(i,t) * p(i, t-1) / sum(N(i) * p(i, t-1) this avoids gamma effects where weights change over time because of the bond price changes By linearity of covariance: sum(marginal_betas) = portfolio_beta

Marginal beta calculation - this is tricky.
In particular we define a new series of returns such that all weights are constant at 1:
S(i,t) = N(i) * r(i,t) * p(i, t-1) / sum(N(i) * p(i, t-1)
this avoids gamma effects where weights change over time because of the bond price changes
By linearity of covariance: sum(marginal_betas) = portfolio_beta
sourceraw docstring

nd-beta-vectorclj

(nd-beta-vector A b)

beta = covariance(asset, benchmark) / variance(benchmark) A is a matrix [[asset-1-returns-over-time] [] []], b is a vector [benchmark-returns-over-time] Equivalent Python where A is a DataFrame and b a series: pandas.np.dot(b.T - b.mean (), A - A.mean (axis=0)) / (b.shape [0] - 1) / pandas.np.var(b, axis=0, ddof=1)

beta = covariance(asset, benchmark) / variance(benchmark)
A is a matrix [[asset-1-returns-over-time] [] []], b is a vector [benchmark-returns-over-time]
Equivalent Python where A is a DataFrame and b a series:
pandas.np.dot(b.T - b.mean (), A - A.mean (axis=0)) / (b.shape [0] - 1) / pandas.np.var(b, axis=0, ddof=1)
sourceraw docstring

nd-pnlsclj

(nd-pnls m)
source

nd-portfolio-value->maxdrawdownclj

(nd-portfolio-value->maxdrawdown portfolio-value kdates)
source

nd-returnsclj

(nd-returns m)
source

nd-returns->varclj

(nd-returns->var rtn kdates)
source

panama-adjust-reducerclj

(panama-adjust-reducer ordered-contracts binding-lag bdh-records)
source

panama-adjust-reducer-b4clj

(panama-adjust-reducer-b4 ordered-contracts binding-lag bdh-records)
source

panama-adjust-reducer-OHLCVclj

(panama-adjust-reducer-OHLCV ordered-contracts binding-lag bdh-records)
source

panama-adjust-reducer-oldclj

(panama-adjust-reducer-old ordered-contracts binding-lag bdh-records)

This is kept for debugging - will return original data with overlap at the binding date

This is kept for debugging - will return original data with overlap at the binding date
sourceraw docstring

quantileclj

(quantile p vs)
(quantile p c svs mn mx)
source

quantile-simpleclj

(quantile-simple q sorted-xs)
source

returns->regressionclj

(returns->regression portfolio-return benchmark-return kdates)
source

simple-olsclj

(simple-ols xs ys)

Single-factor OLS of ys on xs -> {:beta :alpha :rsq}.

beta is the textbook slope cov(x,y)/var(x), NOT the algebraically equal r*sd(y)/sd(x): a flat portfolio (sd(y) = 0, e.g. a shell fund whose value never moves) makes r itself 0/0 = NaN, which then poisons beta and alpha. Dividing by var(x) gives beta 0.0 and alpha mean(y) there.

Single pass over xs/ys accumulating raw sums (no intermediate dtype-next arrays for centered deviations) - ~4x faster than the dfn/-, dfn/* chain this replaced, verified to agree with it to ~1e-10 relative error.

rsq stays r^2, hence still NaN when y has no variance to explain.

Single-factor OLS of ys on xs -> {:beta :alpha :rsq}.

beta is the textbook slope cov(x,y)/var(x), NOT the algebraically equal
r*sd(y)/sd(x): a flat portfolio (sd(y) = 0, e.g. a shell fund whose value
never moves) makes r itself 0/0 = NaN, which then poisons beta and alpha.
Dividing by var(x) gives beta 0.0 and alpha mean(y) there.

Single pass over xs/ys accumulating raw sums (no intermediate dtype-next
arrays for centered deviations) - ~4x faster than the dfn/-, dfn/* chain
this replaced, verified to agree with it to ~1e-10 relative error.

rsq stays r^2, hence still NaN when y has no variance to explain.
sourceraw docstring

cljdoc builds & hosts documentation for Clojure/Script libraries

Keyboard shortcuts
Ctrl+kJump to recent docs
←Move to previous article
→Move to next article
Ctrl+/Jump to the search field
× close