forked from hummingbot/hummingbot
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'development' into refactor/add_bvnd
- Loading branch information
Showing
47 changed files
with
3,434 additions
and
92 deletions.
There are no files selected for viewing
This file contains 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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains 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 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 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 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 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 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 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,50 @@ | ||
from decimal import Decimal | ||
import threading | ||
from typing import ( | ||
TYPE_CHECKING, | ||
) | ||
from hummingbot.core.utils.async_utils import safe_ensure_future | ||
from hummingbot.core.rate_oracle.rate_oracle import RateOracle | ||
|
||
s_float_0 = float(0) | ||
s_decimal_0 = Decimal("0") | ||
|
||
if TYPE_CHECKING: | ||
from hummingbot.client.hummingbot_application import HummingbotApplication | ||
|
||
|
||
class RateCommand: | ||
def rate(self, # type: HummingbotApplication | ||
pair: str, | ||
token: str | ||
): | ||
if threading.current_thread() != threading.main_thread(): | ||
self.ev_loop.call_soon_threadsafe(self.trades) | ||
return | ||
if pair: | ||
safe_ensure_future(self.show_rate(pair)) | ||
elif token: | ||
safe_ensure_future(self.show_token_value(token)) | ||
|
||
async def show_rate(self, # type: HummingbotApplication | ||
pair: str, | ||
): | ||
pair = pair.upper() | ||
self._notify(f"Source: {RateOracle.source.name}") | ||
rate = await RateOracle.rate_async(pair) | ||
if rate is None: | ||
self._notify("Rate is not available.") | ||
return | ||
base, quote = pair.split("-") | ||
self._notify(f"1 {base} = {rate} {quote}") | ||
|
||
async def show_token_value(self, # type: HummingbotApplication | ||
token: str | ||
): | ||
token = token.upper() | ||
self._notify(f"Source: {RateOracle.source.name}") | ||
rate = await RateOracle.global_rate(token) | ||
if rate is None: | ||
self._notify("Rate is not available.") | ||
return | ||
self._notify(f"1 {token} = {RateOracle.global_token_symbol} {rate} {RateOracle.global_token}") |
This file contains 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 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
Oops, something went wrong.