mirror of
https://github.com/d0zingcat/deploy.git
synced 2026-06-08 15:10:57 +00:00
edit autostart example
This commit is contained in:
@@ -1,47 +0,0 @@
|
||||
from hummingbot.strategy.script_strategy_base import ScriptStrategyBase
|
||||
|
||||
|
||||
class FormatStatusExample(ScriptStrategyBase):
|
||||
"""
|
||||
This example shows how to add a custom format_status to a strategy and query the order book.
|
||||
Run the command status --live, once the strategy starts.
|
||||
"""
|
||||
markets = {
|
||||
"binance_paper_trade": {"ETH-USDT"},
|
||||
"kucoin_paper_trade": {"ETH-USDT"},
|
||||
"gate_io_paper_trade": {"ETH-USDT"},
|
||||
}
|
||||
|
||||
def format_status(self) -> str:
|
||||
"""
|
||||
Returns status of the current strategy on user balances and current active orders. This function is called
|
||||
when status command is issued. Override this function to create custom status display output.
|
||||
"""
|
||||
if not self.ready_to_trade:
|
||||
return "Market connectors are not ready."
|
||||
lines = []
|
||||
warning_lines = []
|
||||
warning_lines.extend(self.network_warning(self.get_market_trading_pair_tuples()))
|
||||
|
||||
balance_df = self.get_balance_df()
|
||||
lines.extend(["", " Balances:"] + [" " + line for line in balance_df.to_string(index=False).split("\n")])
|
||||
market_status_df = self.get_market_status_df_with_depth()
|
||||
lines.extend(["", " Market Status Data Frame:"] + [" " + line for line in market_status_df.to_string(index=False).split("\n")])
|
||||
|
||||
warning_lines.extend(self.balance_warning(self.get_market_trading_pair_tuples()))
|
||||
if len(warning_lines) > 0:
|
||||
lines.extend(["", "*** WARNINGS ***"] + warning_lines)
|
||||
return "\n".join(lines)
|
||||
|
||||
def get_market_status_df_with_depth(self):
|
||||
market_status_df = self.market_status_data_frame(self.get_market_trading_pair_tuples())
|
||||
market_status_df["Exchange"] = market_status_df.apply(lambda x: x["Exchange"].strip("PaperTrade") + "paper_trade", axis=1)
|
||||
market_status_df["Volume (+1%)"] = market_status_df.apply(lambda x: self.get_volume_for_percentage_from_mid_price(x, 0.01), axis=1)
|
||||
market_status_df["Volume (-1%)"] = market_status_df.apply(lambda x: self.get_volume_for_percentage_from_mid_price(x, -0.01), axis=1)
|
||||
return market_status_df
|
||||
|
||||
def get_volume_for_percentage_from_mid_price(self, row, percentage):
|
||||
price = row["Mid Price"] * (1 + percentage)
|
||||
is_buy = percentage > 0
|
||||
result = self.connectors[row["Exchange"]].get_volume_for_price(row["Market"], is_buy, price)
|
||||
return result.result_volume
|
||||
Reference in New Issue
Block a user