Esempio n. 1
0
 async def confirm_oracle_conversion_rate(self,  # type: HummingbotApplication
                                          ) -> bool:
     try:
         result = False
         self.app.clear_input()
         self.placeholder_mode = True
         self.app.hide_input = True
         for pair in settings.rate_oracle_pairs:
             msg = await RateCommand.oracle_rate_msg(pair)
             self.notify("\nRate Oracle:\n" + msg)
         config = ConfigVar(key="confirm_oracle_use",
                            type_str="bool",
                            prompt="Please confirm to proceed if the above oracle source and rates are correct for "
                                   "this strategy (Yes/No)  >>> ",
                            required_if=lambda: True,
                            validator=lambda v: validate_bool(v))
         await self.prompt_a_config(config)
         if config.value:
             result = True
     except OracleRateUnavailable:
         self.notify("Oracle rate is not available.")
     finally:
         self.placeholder_mode = False
         self.app.hide_input = False
         self.app.change_prompt(prompt=">>> ")
     return result
Esempio n. 2
0
 def validate_bool(cls, v: str):
     """Used for client-friendly error output."""
     if isinstance(v, str):
         ret = validate_bool(v)
         if ret is not None:
             raise ValueError(ret)
     return v
def validate_take_if_crossed(value: str) -> Optional[str]:
    err_msg = validate_bool(value)
    if err_msg is not None:
        return err_msg
    price_source_enabled = perpetual_market_making_config_map["price_source_enabled"].value
    take_if_crossed = parse_cvar_value(perpetual_market_making_config_map["take_if_crossed"], value)
    if take_if_crossed and not price_source_enabled:
        return "You can enable this feature only when external pricing source for mid-market price is used."
Esempio n. 4
0
     prompt=
     "What is the minimum profitability for you to make a trade? (Enter 1 to indicate 1%) >>> ",
     prompt_on_new=True,
     default=Decimal("0.3"),
     validator=lambda v: validate_decimal(
         v, Decimal(-100), Decimal("100"), inclusive=True),
     type_str="decimal",
 ),
 "use_oracle_conversion_rate":
 ConfigVar(
     key="use_oracle_conversion_rate",
     type_str="bool",
     prompt=
     "Do you want to use rate oracle on unmatched trading pairs? (Yes/No) >>> ",
     prompt_on_new=True,
     validator=lambda v: validate_bool(v),
     on_validated=update_oracle_settings,
 ),
 "secondary_to_primary_base_conversion_rate":
 ConfigVar(
     key="secondary_to_primary_base_conversion_rate",
     prompt=
     "Enter conversion rate for secondary base asset value to primary base asset value, e.g. "
     "if primary base asset is USD and the secondary is DAI, 1 DAI is valued at 1.25 USD, "
     "the conversion rate is 1.25 >>> ",
     default=Decimal("1"),
     validator=lambda v: validate_decimal(v, Decimal(0), inclusive=False),
     type_str="decimal",
 ),
 "secondary_to_primary_quote_conversion_rate":
 ConfigVar(