feat(deribit): ship production-ready Deribit toolkit for SpoonOS#37
Conversation
Overview: Production-ready Deribit integration for `spoon-toolkit`, enabling SpoonOS agents to access Deribit market data, account, and trading APIs in a safe, well-documented way. Features: Unified validated tools for spot/futures/options, spec-based handling of `contract_size`/`tick_size`, end-to-end example workflows for small real balances, and English-only docs including SpoonOS quick start, JSON-RPC → tool mapping, recommended workflows, and error-handling guidelines.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| if tick_size and tick_size > 0: | ||
| # Always normalize price to conform to tick_size to avoid float precision issues | ||
| price_decimal = Decimal(str(price)) | ||
| tick_decimal = Decimal(str(tick_size)) | ||
|
|
||
| # Calculate the normalized price (always round down for buy orders) | ||
| normalized_price = (price_decimal / tick_decimal).quantize(Decimal('1'), rounding=ROUND_DOWN) * tick_decimal | ||
|
|
There was a problem hiding this comment.
Sell price normalization rounds in wrong direction
The _validate_price helper inside the sell order tool normalizes prices using ROUND_DOWN and even carries a comment about buy orders. For sell limit or stop orders this truncates the user’s price to the previous tick (e.g., 3120.07 → 3120.06 for a 0.01 tick), so the order is submitted cheaper than requested and may fill at an unexpectedly low price. Sell-side normalization should round up to the next tick size, not down, to preserve the trader’s minimum acceptable price.
Useful? React with 👍 / 👎.
- Fix import paths in all test files to use correct module path
(spoon_toolkits.data_platforms.deribit instead of spoon_toolkits.deribit)
- Change test assertions from dict-style access (result.get("error")) to
attribute access (result.error) to match ToolResult class interface
- Fix sell order price normalization: use ROUND_UP instead of ROUND_DOWN
to preserve trader's minimum acceptable price for sell orders
All 39 unit tests now pass.
…n trading.py - Removed unnecessary whitespace throughout the file to enhance code clarity. - Ensured consistent formatting in the `ValidationResult` class and various methods for better maintainability. - No functional changes were made; this commit focuses solely on code style improvements.
Overview
Production-ready Deribit integration for
spoon-toolkit, enabling SpoonOS agents to safely access Deribit market data, account endpoints, and trading APIs with clear documentation and predictable behavior.Features
Unified and validated tools covering spot, futures, and options
Spec-driven handling of
contract_sizeandtick_sizeEnd-to-end workflow examples using small real balances
English-only documentation, including: