API Reference#
Configuration#
- class orion_finance_sdk_py.contracts.OrionConfig[source]#
Bases:
OrionSmartContractOrionConfig contract.
Initialize the OrionConfig contract.
- property all_token_decimals: list[int]#
Fetch decimals for all whitelisted assets (parallel to
whitelisted_assets).
- property decommissioned_vaults: list[str]#
Fetch all decommissioned vault addresses.
- property encrypted_vault_factory: str#
Fetch the EncryptedVaultFactory address.
- property fee_change_cooldown_duration: int#
Fetch the fee change cooldown duration in seconds.
- property get_investment_universe: list[str]#
Alias for whitelisted_assets (Investment Universe).
- property hpke_public_key: bytes#
Fetch the Orion HPKE recipient public key (X25519, 32 raw bytes).
- is_decommissioned_vault(vault_address)[source]#
Check if a vault is fully decommissioned.
- Return type:
bool- Parameters:
vault_address (str)
- is_decommissioning_vault(vault_address)[source]#
Check if a vault is currently decommissioning.
- Return type:
bool- Parameters:
vault_address (str)
- is_encrypted_vault(vault_address)[source]#
Check if an address is a registered Orion encrypted vault.
- Return type:
bool- Parameters:
vault_address (str)
- is_orion_vault(vault_address)[source]#
Check if an address is a registered Orion vault.
- Return type:
bool- Parameters:
vault_address (str)
- is_system_idle()[source]#
Check if the system is in idle state, required for vault deployment.
- Return type:
bool
- is_whitelisted(token_address)[source]#
Check if a token address is whitelisted.
- Return type:
bool- Parameters:
token_address (str)
- is_whitelisted_manager(manager_address)[source]#
Check if a manager address is whitelisted.
- Return type:
bool- Parameters:
manager_address (str)
- property liquidity_orchestrator: str#
Fetch the LiquidityOrchestrator contract address.
- property manager_intent_decimals: int#
Alias for strategist_intent_decimals.
- property max_fulfill_batch_size: int#
Fetch the maximum fulfill batch size.
- property min_deposit_amount: int#
Fetch the minimum deposit amount from the OrionConfig contract.
- property min_redeem_amount: int#
Fetch the minimum redeem amount from the OrionConfig contract.
- property netting_fee_coefficient: int#
Fetch the netting fee coefficient from the OrionConfig contract.
- property orion_encrypted_vaults: list[str]#
Fetch all Orion encrypted vault addresses from the OrionConfig contract.
- property orion_managers: list[str]#
Fetch all whitelisted Orion manager addresses.
- property orion_transparent_vaults: list[str]#
Fetch all Orion transparent vault addresses from the OrionConfig contract.
- property price_adapter_decimals: int#
Fetch the price adapter decimals from OrionConfig.
- property price_adapter_registry: str#
Fetch the PriceAdapterRegistry contract address.
- remove_orion_vault(vault_address)[source]#
Start vault decommissioning (manager or owner only).
Signs with
MANAGER_PRIVATE_KEYand verifies the signer is the vault manager.- Return type:
TransactionResult- Parameters:
vault_address (str)
- property risk_free_rate: int#
Fetch the risk free rate from the OrionConfig contract.
- property rs_fee_coefficient: int#
Fetch the revenue share fee coefficient from the OrionConfig contract.
- property strategist_intent_decimals: int#
Fetch the strategist intent decimals from the OrionConfig contract.
- token_decimals(token_address)[source]#
Fetch the decimals of a token address.
- Return type:
int- Parameters:
token_address (str)
- property transparent_vault_factory: str#
Fetch the TransparentVaultFactory address.
- property underlying_asset: str#
Fetch the underlying asset address.
- property whitelisted_asset_names: list[str]#
Fetch all whitelisted asset names from the OrionConfig contract.
- property whitelisted_assets: list[str]#
Fetch all whitelisted asset addresses from the OrionConfig contract.
- property whitelisted_assets_length: int#
Fetch the number of whitelisted assets.
Vaults#
- class orion_finance_sdk_py.contracts.OrionVault(contract_name, contract_address=None)[source]#
Bases:
OrionSmartContractOrionVault contract.
Initialize the OrionVault contract.
- Parameters:
contract_name (
str) – onchain contract name (ABI key).contract_address (
str|None) – Vault address. If omitted, usesORION_VAULT_ADDRESS.
- property active_fee_model: dict#
Fetch the currently active fee model (struct FeeModel).
- allowance(owner, spender)[source]#
Fetch vault share allowance.
- Return type:
int- Parameters:
owner (str)
spender (str)
Approve
spenderto transfer vault shares.- Return type:
TransactionResult- Parameters:
spender (str)
amount (int)
key_env (str)
- property asset: str#
Fetch the vault underlying asset address.
- balance_of(account)[source]#
Fetch vault share balance for an account.
- Return type:
int- Parameters:
account (str)
Check if
accountmay hold vault shares.If no holder access control is set (zero address), returns True.
- Return type:
bool- Parameters:
account (str)
- can_request_deposit(user, data=b'')[source]#
Check if a user is allowed to request a deposit.
Queries the vault’s depositAccessControl contract. If no access control is set (zero address), returns True. On-chain signature is
canRequestDeposit(address sender, bytes data).- Return type:
bool- Parameters:
user (str)
data (bytes)
Check if
sendermay transfer vault shares.If no transfer access control is set (zero address), returns True. On-chain signature is
canTransferShares(address sender, bytes data).- Return type:
bool- Parameters:
sender (str)
data (bytes)
- cancel_deposit_request(amount, *, key_env='LP_PRIVATE_KEY')[source]#
Cancel a previously submitted deposit request.
- Return type:
TransactionResult- Parameters:
amount (int)
key_env (str)
- cancel_redeem_request(shares, *, key_env='LP_PRIVATE_KEY')[source]#
Cancel a previously submitted redemption request.
- Return type:
TransactionResult- Parameters:
shares (int)
key_env (str)
- claim_underlying(*, key_env='LP_PRIVATE_KEY')[source]#
Claim escrowed underlying after a failed deposit or redemption fulfill.
- Return type:
TransactionResult- Parameters:
key_env (str)
- convert_to_assets(shares, block=None)[source]#
Convert shares to assets.
- Parameters:
shares (
int) – Share amount in vault share units.block (
int|None) – Optional block number for a historicaleth_call.
- Return type:
int
Convert assets to shares.
- Return type:
int- Parameters:
assets (int)
block (int | None)
- property decimals: int#
Fetch the vault share token decimals.
- property deposit_access_control: str#
Fetch the deposit access control contract address (
address(0)if none).
- get_portfolio(block=None)[source]#
Get the vault portfolio.
- Parameters:
block (
int|None) – Optional block number for a historicaleth_call.- Returns:
mapping of token address to shares. Encrypted vaults: opaque OrionCiphertext
bytes(subclass override).- Return type:
dict|bytes
- get_portfolio_pct_tvl()[source]#
Portfolio weights as fractions of PIT TVL (sum to ~1.0).
Combines
get_portfolio()withPriceAdapterRegistry.get_prices().- Return type:
dict[str,float]- Returns:
Mapping of checksummed token address to weight in [0, 1]. Empty if the portfolio is empty or PIT total is zero.
- property holder_access_control: str#
Fetch the holder access control contract address (
address(0)if none).
- property is_decommissioning: bool#
Check if the vault is in decommissioning mode.
- property manager_address: str#
Fetch the manager address.
- max_deposit(receiver)[source]#
Fetch the maximum deposit amount for a receiver.
- Return type:
int- Parameters:
receiver (str)
- property max_management_fee: int#
Fetch the maximum management fee allowed from the vault contract.
- max_mint(receiver)[source]#
Fetch max mint for
receiver.- Return type:
int- Parameters:
receiver (str)
- property max_performance_fee: int#
Fetch the maximum performance fee allowed from the vault contract.
- property name: str#
Fetch the vault ERC-20 name.
- pending_deposit(fulfill_batch_size=None)[source]#
Get total pending deposit amount across all users.
- Return type:
int- Parameters:
fulfill_batch_size (int | None)
- pending_redeem(fulfill_batch_size=None)[source]#
Get total pending redemption shares across all users.
- Return type:
int- Parameters:
fulfill_batch_size (int | None)
- pending_redeem_batch(fulfill_batch_size=None)[source]#
Fetch a batch of pending redeem owners and share amounts.
- Return type:
tuple[list[str],list[int]]- Parameters:
fulfill_batch_size (int | None)
- pending_underlying_claim(account)[source]#
Fetch escrowed underlying claimable by
account(failed fulfill).- Return type:
int- Parameters:
account (str)
- property pending_vault_fees: float#
Fetch the pending vault fees in the underlying asset.
- point_in_time_total_assets()[source]#
Estimate vault TVL from portfolio shares and PIT oracle prices.
- Return type:
int- Returns:
Sum of position values in underlying units (same scaling as registry prices after dividing by
price_adapter_decimals).
- preview_redeem(shares)[source]#
Preview assets received for redeeming
shares.- Return type:
int- Parameters:
shares (int)
- redeem(shares, receiver, owner, *, key_env='LP_PRIVATE_KEY')[source]#
Sync ERC-4626 redeem — only allowed when the vault is decommissioned.
- Return type:
TransactionResult- Parameters:
shares (int)
receiver (str)
owner (str)
key_env (str)
- request_deposit(assets, *, key_env='LP_PRIVATE_KEY')[source]#
Submit an asynchronous deposit request (signed with LP key by default).
- Return type:
TransactionResult- Parameters:
assets (int)
key_env (str)
- request_deposit_for(beneficiary, assets, *, key_env='LP_PRIVATE_KEY')[source]#
Submit a deposit request credited to
beneficiary.- Return type:
TransactionResult- Parameters:
beneficiary (str)
assets (int)
key_env (str)
- request_redeem(shares, *, key_env='LP_PRIVATE_KEY')[source]#
Submit a redemption request.
- Return type:
TransactionResult- Parameters:
shares (int)
key_env (str)
- set_deposit_access_control(access_control_address)[source]#
Set the deposit access control contract address.
- Return type:
TransactionResult- Parameters:
access_control_address (str)
- set_holder_access_control(access_control_address)[source]#
Set the holder access control contract address.
- Return type:
TransactionResult- Parameters:
access_control_address (str)
- set_transfer_access_control(access_control_address)[source]#
Set the transfer access control contract address.
- Return type:
TransactionResult- Parameters:
access_control_address (str)
Fetch the current share price (value of 1 share unit).
Fetch the share price (value of 1 full share) at a historical block.
- Return type:
int- Parameters:
block (int)
Sample vault share price over a time range (onchain
eth_callat each point).The SDK returns plain dicts; wrap in pandas in your notebook for correlation analysis. Public RPCs are rate-limited - use a dedicated
RPC_URLfor long series.- Parameters:
start (
datetime|int) – Start asdatetime, unix timestamp, or block number (ints>= 1_000_000_000are treated as timestamps).end (
datetime|int|None) – End bound (same types asstart). Defaults to latest block.interval (
str) – Sampling interval. Only"1d"(daily) is supported for now.
- Return type:
list[dict]- Returns:
List of
{"timestamp", "block", "share_price"}dicts (unix timestamp, block number, share price in underlying units). Points before the vault was deployed are omitted.
- property strategist_address: str#
Fetch the strategist address.
- property symbol: str#
Fetch the vault ERC-20 symbol.
- property total_assets: int#
Fetch the total assets of the vault.
- total_assets_at(block)[source]#
Fetch
totalAssetsat a historical block.- Return type:
int- Parameters:
block (int)
- property total_supply: int#
Fetch vault share total supply.
- property transfer_access_control: str#
Fetch the transfer access control contract address (
address(0)if none).
Transfer vault shares via allowance.
- Return type:
TransactionResult- Parameters:
from_address (str)
to (str)
amount (int)
key_env (str)
- transfer_manager_fees(amount)[source]#
Transfer manager fees (claimVaultFees).
- Return type:
TransactionResult- Parameters:
amount (int)
Transfer vault shares.
- Return type:
TransactionResult- Parameters:
to (str)
amount (int)
key_env (str)
- class orion_finance_sdk_py.contracts.OrionTransparentVault(contract_address=None)[source]#
Bases:
OrionVaultOrionTransparentVault contract.
Initialize the OrionTransparentVault contract.
- Parameters:
contract_address (
str|None) – Vault address. If omitted, usesORION_VAULT_ADDRESS.
- get_intent()[source]#
Fetch the current strategist intent as fractional weights (sum ≈ 1).
onchain weights are scaled by
OrionConfig.strategist_intent_decimals. Returns an empty dict when no intent is set. Compare withget_portfolio_pct_tvl()to see expected rebalancing.- Return type:
dict[str,float]
Factory#
- class orion_finance_sdk_py.contracts.VaultFactory(vault_type, contract_address=None)[source]#
Bases:
OrionSmartContractVaultFactory contract.
Initialize the VaultFactory contract.
- Parameters:
vault_type (str)
contract_address (str | None)
- create_orion_vault(strategist_address, name, symbol, fee_type, performance_fee, management_fee, deposit_access_control='0x0000000000000000000000000000000000000000', holder_access_control='0x0000000000000000000000000000000000000000', transfer_access_control='0x0000000000000000000000000000000000000000')[source]#
Create an Orion vault for a given strategist address.
Omitted ACL addresses default to
address(0)(permissionless).- Return type:
TransactionResult- Parameters:
strategist_address (str)
name (str)
symbol (str)
fee_type (int)
performance_fee (int)
management_fee (int)
deposit_access_control (str)
holder_access_control (str)
transfer_access_control (str)
Liquidity Orchestrator#
- class orion_finance_sdk_py.contracts.LiquidityOrchestrator[source]#
Bases:
OrionSmartContractLiquidityOrchestrator contract.
Initialize the LiquidityOrchestrator contract.
- property buffer_amount: int#
Fetch the current LO underlying buffer amount.
- property current_phase: int#
Fetch the current epoch phase enum value.
- property epoch_counter: int#
Fetch the epoch counter.
- property epoch_duration: int#
Fetch the epoch duration in seconds.
- get_asset_prices(assets)[source]#
Fetch LO-reported prices for the given assets.
- Return type:
list[int]- Parameters:
assets (Iterable[str])
- property pending_protocol_fees: int#
Fetch pending protocol fees (underlying units).
- property slippage_tolerance: int#
Fetch the slippage tolerance.
- property target_buffer_ratio: int#
Fetch the target buffer ratio.
Price Adapter Registry#
- class orion_finance_sdk_py.contracts.PriceAdapterRegistry(contract_address=None)[source]#
Bases:
OrionSmartContractPriceAdapterRegistry contract for point-in-time asset prices.
Initialize the PriceAdapterRegistry contract.
- Parameters:
contract_address (
str|None) – Optional registry address. If omitted, resolved fromOrionConfig.price_adapter_registry.
- get_price(asset, block=None)[source]#
Fetch the point-in-time price for a single asset.
- Parameters:
asset (
str) – Token contract address.block (
int|None) – Optional block number for a historicaleth_call.
- Return type:
int- Returns:
Price scaled by
price_adapter_decimals.
- get_prices(block=None, assets=None)[source]#
Fetch point-in-time prices for the investment universe (or a subset).
- Parameters:
block (
int|None) – Optional block number for historical prices.assets (
Optional[Iterable[str]]) – Optional token addresses to price. Defaults to the full whitelisted investment universe fromOrionConfig.
- Return type:
dict[str,int]- Returns:
Mapping of checksummed asset address to price (scaled by
price_adapter_decimals).
- property price_adapter_decimals: int#
Fetch the price adapter decimals from the registry.
- price_history(start, end=None, interval='1d', assets=None)[source]#
Sample PIT prices for whitelisted assets over a time range.
No vault is required - prices come from the price adapter registry for the investment universe (or an optional subset). The SDK returns plain dicts; wrap in pandas in your notebook for return / distribution analysis. Public RPCs are rate-limited - use a dedicated
RPC_URLfor long series.- Parameters:
start (
datetime|int) – Start asdatetime, unix timestamp, or block number (ints>= 1_000_000_000are treated as timestamps).end (
datetime|int|None) – End bound (same types asstart). Defaults to latest block.interval (
str) – Sampling interval. Only"1d"(daily) is supported for now.assets (
Optional[Iterable[str]]) – Optional token addresses to price. Defaults to the full whitelisted investment universe fromOrionConfig.
- Return type:
list[dict]- Returns:
List of
{"timestamp", "block", "prices"}dicts wherepricesmaps checksummed asset address to price (scaled byprice_adapter_decimals).
Execution cost#
- class orion_finance_sdk_py.costs.types.ExecutionCost(symbol, timestamp, signed_size, netting_eta, swap_size, fee_pct, slippage_pct, cost_pct, amount_in, amount_out)[source]#
Estimated execution cost of a signed asset trade.
Fields apply to any venue and any vault.
- Parameters:
symbol (str)
timestamp (str)
signed_size (float)
netting_eta (float)
swap_size (float)
fee_pct (float)
slippage_pct (float)
cost_pct (float)
amount_in (float)
amount_out (float)
- amount_in: float#
- amount_out: float#
- cost_pct: float#
- fee_pct: float#
- netting_eta: float#
- signed_size: float#
- slippage_pct: float#
- swap_size: float#
- symbol: str#
- timestamp: str#
- class orion_finance_sdk_py.costs.estimator.ExecutionCostEstimator(*, rpc_url=None, block_number=None)[source]#
Manager-facing execution cost estimator.
v1 wraps Uniswap v3 on Ethereum mainnet (the venue Orion will use). If
rpc_urlandMAINNET_RPC_URLare unset, public mainnet RPCs are probed in order. SetMAINNET_RPC_URLto an archival endpoint for historicaltimestampqueries and higher rate limits. Optionalblock_numberpins snapshots for research reproducibility and is not part ofget_cost.Initialize with an optional RPC URL and pinned block.
- Parameters:
rpc_url (str | None)
block_number (int | None)
- get_cost(symbol, signed_size, timestamp=None, *, netting_eta=0.0, venue='uniswap_v3')[source]#
Estimate execution cost of a signed trade in human asset units.
- Parameters:
symbol (
str) – Ticker (e.g.WETH,WBTC) or mainnet token address.signed_size (
float) – Human units of the risk asset. Positive buys (exact output), negative sells (exact input).timestamp (
str|None) – UTC calendar dateYYYY-MM-DD.Nonemeans now.netting_eta (
float) – Fraction of the nominal size that is internally netted. The venue swap is(1 - eta) * signed_size; cost percentages are those of that swap, not scaled by(1-eta).venue (
str) – Backend selector. Onlyuniswap_v3is implemented.
- Return type:
- orion_finance_sdk_py.costs.estimator.get_cost(symbol, signed_size, timestamp=None, *, netting_eta=0.0, venue='uniswap_v3')[source]#
Module-level wrapper around a process-default
ExecutionCostEstimator.- Return type:
- Parameters:
symbol (str)
signed_size (float)
timestamp (str | None)
netting_eta (float)
venue (str)
Return statistics#
- class orion_finance_sdk_py.stats.series.ReturnSeries(returns, *, prices=None, periods_per_year=365)[source]#
Simple-return panel with contiguous-daily ranking hygiene.
returnsis the contiguous one-calendar-day panel used for SASR, sample Sharpe, covariance, PCA, and MeanRisk. Path statistics usepriceswhen the object was built from a price panel (gaps included).Store already-hygiened contiguous daily returns and optional prices.
- Parameters:
returns (pd.DataFrame)
prices (pd.DataFrame | None)
periods_per_year (int)
- property columns: Index#
Asset labels.
- excess_returns(rfr)[source]#
Contiguous daily simple returns minus the compounded per-period RFR.
- Return type:
DataFrame- Parameters:
rfr (float)
- classmethod from_price_history(series, *, decimals, names=None, min_obs=None, periods_per_year=365)[source]#
Build from
PriceAdapterRegistry.price_historyrecords.- Return type:
- Parameters:
series (Sequence[Mapping[str, Any]])
decimals (int)
names (Mapping[str, str] | None)
min_obs (int | None)
periods_per_year (int)
- classmethod from_prices(prices, *, periods_per_year=365)[source]#
Build from a DatetimeIndex panel of strictly positive prices.
- Return type:
- Parameters:
prices (Series | DataFrame)
periods_per_year (int)
- classmethod from_returns(returns, *, periods_per_year=365)[source]#
Build from a DatetimeIndex panel of simple returns.
- Return type:
- Parameters:
returns (Series | DataFrame)
periods_per_year (int)
Build from vault
share_price_historyrecords keyed by symbol.- Return type:
- Parameters:
histories (Mapping[str, Iterable[Mapping[str, Any]]])
min_obs (int | None)
periods_per_year (int)
- property prices: DataFrame | None#
Source prices when built from a price panel; otherwise
None.
- property returns: DataFrame#
Daily simple-return panel with gap-boundary rows set to NaN.
- class orion_finance_sdk_py.stats.ranking.RankingMetrics(n, sample_sharpe, dasr, sasr, t_eff, t_weeks, w, vsr, rho, sr_daily, vol)[source]#
Univariate ranking intermediates for one return series.
- Parameters:
n (int)
sample_sharpe (float | None)
dasr (float | None)
sasr (float | None)
t_eff (float | None)
t_weeks (float | None)
w (float | None)
vsr (float | None)
rho (float | None)
sr_daily (float | None)
vol (float | None)
- dasr: float | None#
- n: int#
- rho: float | None#
- sample_sharpe: float | None#
- sasr: float | None#
- sr_daily: float | None#
- t_eff: float | None#
- t_weeks: float | None#
- vol: float | None#
- vsr: float | None#
- w: float | None#
- orion_finance_sdk_py.stats.ranking.rank_products(rs, rfr, *, periods_per_year=None)[source]#
SASR by asset, sorted descending. This is the only product ranking score.
- Return type:
Series- Parameters:
rs (ReturnSeries)
rfr (float)
periods_per_year (int | None)
- orion_finance_sdk_py.stats.ranking.expanding_sasr(rs, rfr, *, periods_per_year=None)[source]#
SASR at each date using all contiguous daily returns up to that date.
Expanding window (not rolling): column
jat rowiisrank_columnon the positional prefixrs.returns[j].iloc[: i + 1]. Matches SASR’s track-record weight growing with history.- Return type:
DataFrame- Parameters:
rs (ReturnSeries)
rfr (float)
periods_per_year (int | None)
- orion_finance_sdk_py.stats.ranking.ranking_metrics(rs, rfr, *, periods_per_year=None)[source]#
Univariate SASR intermediates for each column of
rs.- Return type:
dict[str,RankingMetrics]- Parameters:
rs (ReturnSeries)
rfr (float)
periods_per_year (int | None)
- orion_finance_sdk_py.stats.measures.summary(rs, rfr=0.0, *, periods_per_year=None, cvar_beta=0.95, var_beta=0.95)[source]#
One row per asset: skfolio period stats, path stats, and SASR fields.
sharpeis 365-day sample Sharpe from skfolio mean / sample std.sasris the Orion ranking score. They are not aliases.- Return type:
DataFrame- Parameters:
rs (ReturnSeries)
rfr (float)
periods_per_year (int | None)
cvar_beta (float)
var_beta (float)
- orion_finance_sdk_py.stats.measures.product_scoreboard(rs, rfr=0.0, *, periods_per_year=None)[source]#
summarysorted by SASR descending (the product ranking table).- Return type:
DataFrame- Parameters:
rs (ReturnSeries)
rfr (float)
periods_per_year (int | None)
- orion_finance_sdk_py.stats.rfr.rfr_decimal(bps)[source]#
Convert an annualized protocol rate in basis points to a decimal.
OrionConfig.risk_free_rateis annualized basis points (410→0.041).- Return type:
float- Parameters:
bps (float | int)
skfolio-backed covariance and correlation estimators.
- orion_finance_sdk_py.stats.covariance.correlation(rs)[source]#
Correlation of overlapping contiguous daily returns (skfolio).
- Return type:
DataFrame- Parameters:
rs (ReturnSeries | DataFrame)
- orion_finance_sdk_py.stats.covariance.ledoit_wolf(rs)[source]#
Ledoit–Wolf shrunk covariance via skfolio
LedoitWolf.- Return type:
DataFrame- Parameters:
rs (ReturnSeries | DataFrame)
- orion_finance_sdk_py.stats.covariance.sample(rs)[source]#
Sample covariance via skfolio
EmpiricalCovariance(ddof=1).- Return type:
DataFrame- Parameters:
rs (ReturnSeries | DataFrame)
Build labeled price panels from on-chain history dicts.
- orion_finance_sdk_py.stats.panels.from_price_history(series, *, decimals, names=None, min_obs=None)[source]#
Turn
PriceAdapterRegistry.price_historydicts into a price panel.- Parameters:
series (
Sequence[Mapping[str,Any]]) – List of{"timestamp", "block", "prices"}records.decimals (
int) –price_adapter_decimalsused to scale integer prices.names (
Mapping[str,str] |None) – Optional address → display name map.min_obs (
int|None) – Drop columns with fewer than this many non-null observations.
- Return type:
DataFrame
Turn vault
share_price_historydicts into a labeled price panel.- Parameters:
histories (
Mapping[str,Iterable[Mapping[str,Any]]]) – Map of column name → list of{"timestamp", "block", "share_price"}records.min_obs (
int|None) – Drop columns with fewer than this many non-null observations.
- Return type:
DataFrame
- orion_finance_sdk_py.stats.panels.normalized_prices(prices)[source]#
Rebase each column to 1.0 at its first valid observation.
- Return type:
DataFrame- Parameters:
prices (DataFrame)
Principal-component analysis of overlapping daily returns.
- class orion_finance_sdk_py.stats.factors.PCAResult(explained_variance_ratio, loadings, scores)[source]#
Standardized PCA of an overlapping return panel.
- Parameters:
explained_variance_ratio (ndarray)
loadings (DataFrame)
scores (DataFrame)
- orion_finance_sdk_py.stats.factors.pca(returns, *, n_components=None, standardize=True)[source]#
Fit PCA on overlapping contiguous daily returns.
Requires at least three overlapping rows and two columns. Default
standardize=Truematches the universe-research notebook (StandardScalerthenPCA).- Return type:
- Parameters:
returns (ReturnSeries | DataFrame)
n_components (int | None)
standardize (bool)
Thin skfolio MeanRisk helpers for research notebooks.
Not a sklearn Pipeline. Weights are labeled Series. Annualization defaults to 365. Zero-variance assets are dropped before fitting, as in the universe notebook.
- class orion_finance_sdk_py.stats.portfolio.FittedPortfolio(weights, model, dropped)[source]#
Labeled MeanRisk weights plus the fitted skfolio estimator.
- Parameters:
weights (Series)
model (MeanRisk)
dropped (tuple[str, ...])
- orion_finance_sdk_py.stats.portfolio.chronological_split(returns, test_size=0.33)[source]#
Time-ordered train/test split (no shuffle) on overlapping rows.
- Return type:
tuple[DataFrame,DataFrame]- Parameters:
returns (ReturnSeries | DataFrame)
test_size (float)
- orion_finance_sdk_py.stats.portfolio.drop_zero_variance(returns, *, threshold=1e-10)[source]#
Drop columns whose population std is at or below
threshold.- Return type:
tuple[DataFrame,tuple[str,...]]- Parameters:
returns (DataFrame)
threshold (float)
- orion_finance_sdk_py.stats.portfolio.max_sharpe(returns, *, rfr=0.0, periods_per_year=365)[source]#
Maximize Sharpe ratio (mean excess return / standard deviation).
- Return type:
- Parameters:
returns (ReturnSeries | DataFrame)
rfr (float)
periods_per_year (int)
- orion_finance_sdk_py.stats.portfolio.max_sortino(returns, *, rfr=0.0, periods_per_year=365)[source]#
Maximize Sortino ratio (mean / semi-deviation).
- Return type:
- Parameters:
returns (ReturnSeries | DataFrame)
rfr (float)
periods_per_year (int)
- orion_finance_sdk_py.stats.portfolio.min_variance(returns, *, rfr=0.0, periods_per_year=365)[source]#
Minimum-variance long-only portfolio (skfolio
MeanRiskdefault).- Return type:
- Parameters:
returns (ReturnSeries | DataFrame)
rfr (float)
periods_per_year (int)
RPC defaults#
Public RPC defaults, health probing, and chain-agnostic block lookup.
- orion_finance_sdk_py.rpc.block_at_timestamp(w3, timestamp, *, lo=None, hi=None)[source]#
Return the latest block number whose timestamp is <=
timestamp.Optional
lo/hibound the binary search (inclusive). When omitted, the search uses genesis and the chain tip.- Return type:
int- Parameters:
w3 (Web3)
timestamp (int)
lo (int | None)
hi (int | None)
- orion_finance_sdk_py.rpc.call_with_rpc_retry(fn, *, retries=5, backoff_factor=0.25)[source]#
Call
fn, retrying on transient transport failures.Does not retry application-level RPC / contract errors.
- Return type:
TypeVar(T)- Parameters:
fn (Callable[[], T])
retries (int)
backoff_factor (float)
- orion_finance_sdk_py.rpc.clear_default_rpc_cache()[source]#
Clear process-level cached default RPC URLs (for tests).
- Return type:
None
- orion_finance_sdk_py.rpc.get_block(w3, block_identifier)[source]#
eth_getBlockByNumberwith transient transport retries.- Parameters:
w3 (Web3)
- orion_finance_sdk_py.rpc.make_http_provider(rpc_url, *, timeout=60.0)[source]#
Build a
Web3.HTTPProviderwith timeout and connection-error retries.- Parameters:
rpc_url (str)
timeout (float)
- orion_finance_sdk_py.rpc.pick_default_mainnet_rpc(timeout=5.0)[source]#
Probe default public mainnet RPCs in order; return the first that works (cached).
- Return type:
str|None- Returns:
A working RPC URL, or
Noneif every default endpoint failed.- Parameters:
timeout (float)