Skip to content

Trading strategy params inspection and updating#162

Merged
8ball030 merged 54 commits intomainfrom
feat/trading_strategy_params_inspection_and_updating
Feb 5, 2026
Merged

Trading strategy params inspection and updating#162
8ball030 merged 54 commits intomainfrom
feat/trading_strategy_params_inspection_and_updating

Conversation

@Karrenbelt
Copy link
Collaborator

Features:

  1. GET request to return currently configured arbitrage strategy parameters
  2. expose trading_strategy on the simple_fsm skill's ArbitrageStrategy
  3. POST request to update the configured arbitrage strategy parameters
    • Validate the incoming request and set the AgentState.arbitrage_strategy_params_update_request in the trading_state skill HttpHandler
    • Update the trading_state parameters in the CoolDownRound via an atomic swap of instances

Curl request examples to be used for testing locally:

  • GET: curl -X GET http://localhost:8889/metrics
  • POST: curl -X POST http://localhost:8889/metrics -d '{"base_asset": "DRV", "quote_asset": "USDC", "order_size": 250.0, "min_profit": 10.0, "max_open_orders": 10}'

Then, on can of course use the GET request to confirm that the parameter update has in fact occurred, and persists.

Comment on lines +129 to +143
received_params = json.loads(http_msg.body)
agent_state = self.context.shared_state.get("state")
type_hints = get_type_hints(ArbitrageStrategyParams)
typed_params = {}
for key, value in received_params.items():
if (expected_type := type_hints.get(key)) is None:
self.context.logger.warning(f"Unexpected arbitrage strategy parameter: {key}: ignoring")
continue
try:
typed_value = expected_type(value)
except Exception: # noqa: BLE001
msg = f"Failed to cast arbitrage strategy parameter {key} value {value} to {expected_type}: ignoring"
self.context.logger.warning(msg)
continue
typed_params[key] = typed_value
Copy link
Collaborator Author

@Karrenbelt Karrenbelt Jan 22, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

while this is defensive, we might want to consider faulty inputs beyond the mere expected type, which I have not done. For example, the base_asset must be available among some set of assets, and the quote_asset should, in fact, always be USDC. Now instead of creating some sort of Enum or set to check whether the base_asset is available, which is chain specific and varies over time, we may instead consider simply testing what happens when this is not the case (i.e. random string), and whether the effect this has on the behavior of the agent is what we desire it to be.

Copy link
Collaborator

@77ph 77ph left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The routing bug in /metrics was fixed correctly.
However, several merge-blocking issues from the audit remain unresolved:
get_timeseries(days=7) API mismatch,
unsafe assumption that trading_strategy is always initialized,
lack of basic robustness in /metrics (test all possible occurrences, including the semantics:
endswith("/metrics"):
OK - /metrics
? /metrics?x=1
? /api/v1/metrics
)
The current PR partially addresses the audit.

Karrenbelt and others added 27 commits January 28, 2026 13:50
Add LightAccount sweeping and insufficient balance user notifications
Resolve bridge transaction failures and nonce collisions
…rpc-with-drpc

Replace Base RPC endpoint (llamarpc -> drpc)
…rticipation

Minimum Donation Fallback for Daily Activity Tracking
Address audit findings for PR-158 and PR-162
@8ball030 8ball030 merged commit df3fe63 into main Feb 5, 2026
1 check passed
@8ball030 8ball030 deleted the feat/trading_strategy_params_inspection_and_updating branch February 5, 2026 19:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants