Skip to content

Comments

feat(deribit): ship production-ready Deribit toolkit for SpoonOS#37

Merged
veithly merged 3 commits intoXSpoonAi:mainfrom
hacknexus:feature/deribit-integration
Dec 18, 2025
Merged

feat(deribit): ship production-ready Deribit toolkit for SpoonOS#37
veithly merged 3 commits intoXSpoonAi:mainfrom
hacknexus:feature/deribit-integration

Conversation

@hacknexus
Copy link

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_size and tick_size

  • End-to-end workflow examples using small real balances

  • English-only documentation, including:

    • SpoonOS quick start
    • JSON-RPC → tool mapping
    • Recommended agent workflows
    • Error-handling guidelines

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.
Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 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".

Comment on lines 726 to 733
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

Choose a reason for hiding this comment

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

P1 Badge 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.
@veithly veithly merged commit ec7fe4a into XSpoonAi:main Dec 18, 2025
1 check passed
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.

2 participants