Trading strategy params inspection and updating#162
Conversation
| 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 |
There was a problem hiding this comment.
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.
77ph
left a comment
There was a problem hiding this comment.
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.
…irectly after scheduling donation
…tive other than BRIDGE_STATUS
…in_progress and send user notification
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
…id_bridge_request
Features:
trading_strategyon thesimple_fsmskill'sArbitrageStrategyAgentState.arbitrage_strategy_params_update_requestin thetrading_stateskillHttpHandlertrading_stateparameters in theCoolDownRoundvia an atomic swap of instancesCurl request examples to be used for testing locally:
curl -X GET http://localhost:8889/metricscurl -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.