Lux.Beams.Hyperliquid.TradeRiskManagementBeam (Lux v0.5.0)

View Source

A beam that evaluates trade suggestions against risk management criteria and portfolio state.

This beam:

  1. Fetches current portfolio state and positions
  2. Gets current market prices and conditions
  3. Evaluates the trade against risk management rules
  4. Either executes or rejects the trade based on risk assessment

Example

Lux.Beams.Hyperliquid.TradeRiskManagementBeam.run(%{
  address: "0x0403369c02199a0cb827f4d6492927e9fa5668d5",
  trade: %{
    coin: "ETH",
    is_buy: true,
    sz: 0.1,
    limit_px: 2800.0,
    order_type: %{limit: %{tif: "Gtc"}},
    reduce_only: false
  }
})
{:ok, %{
  status: "accepted", # or "rejected"
  risk_metrics: %{
    position_size_ratio: 0.15,
    leverage: 2.0,
    portfolio_concentration: 0.25,
    # ... other metrics
  },
  execution_result: %{} # if accepted
}}

Summary

Functions

Determines if the trade should be executed based on risk metrics

Functions

run(input, opts \\ [])

should_execute?(ctx)

Determines if the trade should be executed based on risk metrics

view()