Repository navigation
(feat) restore rate oracle config endpoints, scoped to bots #235
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
76ce1c4
(feat) restore rate oracle config endpoints, scoped to bots
cardosofede 17e62b2
fix(bot-rate-oracle): reject blank quote tokens, switch live token on…
cardosofede 31e671d
feat(system): report API/hummingbot versions and image provenance at …
cardosofede d8e3f1f
fix(docker): copy version.py into the image
cardosofede 836f1a4
feat(system): report the market-data tunables at GET /system/info
cardosofede 549f4f5
feat(bot-rate-oracle): rate_limits_share_pct with the rest of the bot…
cardosofede ea7f5a0
feat(system): let the API replace its own container with the publishe…
cardosofede 7e27fae
fix(api): render validation errors from ValueError validators as 422,…
cardosofede 238ecb7
fix(system): never report another container or a local build as the p…
cardosofede ab29ce9
fix(system): collect a failed upgrade helper without waiting for a re…
cardosofede d5bbe50
fix(bot-rate-oracle): reject a blank global_token_symbol like its sib…
cardosofede 9292dec
fix(system): never adopt or remove a foreign stack's self-upgrade helper
cardosofede 96dabd6
fix(bot-rate-oracle): tolerate a hand-edited or malformed conf_client…
cardosofede File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,88 @@ | ||
| """ | ||
| Pydantic models for the bot client defaults endpoints. | ||
|
|
||
| The API itself prices through the in-house ticker pool, but deployed bots still run | ||
| hummingbot's RateOracle, configured from the conf_client.yml copied out of their | ||
| credentials profile. These models describe that persisted configuration, plus the one | ||
| other conf_client.yml knob operators tune per profile -- rate_limits_share_pct, the share | ||
| of each exchange's API rate limit a bot instance is allowed to spend. | ||
| """ | ||
|
|
||
| from typing import List, Optional | ||
|
|
||
| from pydantic import BaseModel, Field, field_validator | ||
|
|
||
|
|
||
| class GlobalTokenConfig(BaseModel): | ||
| """Global token configuration for displaying values.""" | ||
| global_token_name: Optional[str] = Field( | ||
| default=None, | ||
| description="The token to use as global quote (e.g., USDT, USD, BTC)" | ||
| ) | ||
| global_token_symbol: Optional[str] = Field( | ||
| default=None, | ||
| description="Symbol to display for the global token" | ||
| ) | ||
|
|
||
| @field_validator("global_token_name", "global_token_symbol") | ||
| @classmethod | ||
| def _reject_blank(cls, v: Optional[str], info) -> Optional[str]: | ||
| # A blank quote token would make every cross-rate lookup resolve to nothing, and a | ||
| # blank symbol renders every value in the bot's status without a unit. Omit the | ||
| # field to leave it unchanged. | ||
| if v is not None: | ||
| v = v.strip() | ||
| if not v: | ||
| raise ValueError(f"{info.field_name} must not be blank") | ||
| return v | ||
|
|
||
|
|
||
| class RateOracleSourceConfig(BaseModel): | ||
| """Rate oracle source configuration.""" | ||
| name: str = Field(description="The rate oracle source deployed bots use for price data") | ||
|
|
||
|
|
||
| class RateOracleConfig(BaseModel): | ||
| """Bot client defaults persisted in an account's conf_client.yml.""" | ||
| account_name: str = Field(description="Credentials profile the configuration belongs to") | ||
| rate_oracle_source: RateOracleSourceConfig | ||
| global_token: GlobalTokenConfig | ||
| # Bounds mirror hummingbot's own ClientConfigMap.rate_limits_share_pct (gt=0, le=100): | ||
| # the file is read back by hummingbot inside the bot container, so a value it would | ||
| # reject must not be writable here. | ||
| rate_limits_share_pct: float = Field( | ||
| default=100.0, | ||
| gt=0, | ||
| le=100, | ||
| description="Percentage of each exchange's API rate limit allocated to a bot instance" | ||
| ) | ||
|
|
||
|
|
||
| class RateOracleConfigResponse(RateOracleConfig): | ||
| """Response for the rate oracle configuration GET endpoint.""" | ||
| available_sources: List[str] = Field(description="Rate oracle sources that can be configured") | ||
|
|
||
|
|
||
| class RateOracleConfigUpdateRequest(BaseModel): | ||
| """Request model for updating the rate oracle configuration.""" | ||
| rate_oracle_source: Optional[RateOracleSourceConfig] = Field( | ||
| default=None, | ||
| description="New rate oracle source configuration (optional)" | ||
| ) | ||
| global_token: Optional[GlobalTokenConfig] = Field( | ||
| default=None, | ||
| description="New global token configuration (optional)" | ||
| ) | ||
| rate_limits_share_pct: Optional[float] = Field( | ||
| default=None, | ||
| gt=0, | ||
| le=100, | ||
| description="New share of each exchange's API rate limit for a bot instance, 1-100 (optional)" | ||
| ) | ||
|
|
||
|
|
||
| class RateOracleConfigUpdateResponse(BaseModel): | ||
| """Response for a bot client defaults update.""" | ||
| success: bool = Field(description="Whether the update was successful") | ||
| message: str = Field(description="Status message") | ||
| config: RateOracleConfig = Field(description="Updated configuration") | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| """System router models (FEAT-122).""" | ||
|
|
||
| from pydantic import BaseModel, Field | ||
|
|
||
|
|
||
| class SelfUpgradeRequest(BaseModel): | ||
| """Consent to what a self-upgrade destroys. | ||
|
|
||
| Restarting the API closes every RUNNING executor as SYSTEM_CLEANUP and they are not | ||
| restored, so the one field here is the acknowledgement of that -- and it defaults to | ||
| False, which means a caller that sends an empty body is refused rather than served. | ||
| Bot containers are separate and keep running. | ||
| """ | ||
|
|
||
| acknowledge_executor_loss: bool = Field( | ||
| default=False, | ||
| description=( | ||
| "Confirms that every running executor will be closed as SYSTEM_CLEANUP and not " | ||
| "restored. Required when the server has any running executor." | ||
| ), | ||
| ) |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Extending this validator to
global_token_symbolmakes the read endpoint fail validation when an existing or manually editedconf_client.ymlcontains an empty symbol._to_configpasses that persisted value directly into this model, and the GET route does not handle the resulting validation error. This makes the account’s configuration endpoint return a server error instead of exposing or normalizing the configuration.