@johback
Hello
More examples are here https://github.com/quantiacs/toolbox/blob/main/qnt/tests/test_fundamental_data.py
This is a simple example.
import qnt.data as qndata
import datetime as dt
import qnt.data.secgov_indicators
import qnt.data as qndata
import qnt.stats as qns
assets = qndata.stocks.load_ndx_list(tail=dt.timedelta(days=5 * 365))
assets_names = [i["id"] for i in assets]
data = qndata.stocks.load_ndx_data(tail=dt.timedelta(days=5 * 365),
dims=("time", "field", "asset"),
assets=assets_names,
forward_order=True)
facts_names = ['operating_expense'] # 'assets', 'liabilities', 'ivestment_short_term' and other
fundamental_data = qnt.data.secgov_load_indicators(assets,
time_coord=data.time,
standard_indicators=facts_names)
# Operating expenses include marketing, noncapitalized R&D,
# travel and entertainment, office supply, rent, salary, cogs...
weights = fundamental_data.sel(field='operating_expense')
is_liquid = data.sel(field="is_liquid")
weights = weights * is_liquid
# calc stats
stats = qns.calc_stat(data, weights.sel(time=slice("2006-01-01", None)))
display(stats.to_pandas().tail())
# graph
performance = stats.to_pandas()["equity"]
import qnt.graph as qngraph
qngraph.make_plot_filled(performance.index, performance, name="PnL (Equity)", type="log")