mirror of
https://github.com/d0zingcat/deploy.git
synced 2026-06-07 23:16:50 +00:00
(feat) deployment scenarios
This commit is contained in:
39
autostart_hummingbot_compose/README.md
Normal file
39
autostart_hummingbot_compose/README.md
Normal file
@@ -0,0 +1,39 @@
|
||||
# Deploy and autostart a single Hummingbot instance with docker Compose
|
||||
|
||||
## How to use it
|
||||
|
||||
- Make sure you have docker and docker-compose installed.
|
||||
- To autostart you will need the config_file of the strategy, and the password already generated.
|
||||
- **Important:**
|
||||
- In this example the password generated is `a` and it was done in a Mac, if you are using a different OS
|
||||
or you want to use a different password, make sure to delete the .password_verification file under the conf folder and follow the
|
||||
instructions on troubleshooting.
|
||||
- You can autostart a strategy or a script. In this case on line `13` we are autostarting a script that is inside the scripts folder.
|
||||
If you want to start a strategy, there is one config file under conf/strategies, you can just change format_status.py for conf_pure_mm_1.yml to test it!
|
||||
- Make sure that the compose file on lines `12` and `13` have the correct path to the config file and the password.
|
||||
- Run the following command:
|
||||
```
|
||||
docker-compose up -d
|
||||
```
|
||||
|
||||
- Attach the terminal:
|
||||
```
|
||||
docker attach simple_hummingbot_compose-bot-1
|
||||
```
|
||||
|
||||
- Now you have Hummingbot running and autostarted! Remember that you can detach the terminal without stopping the bot by pressing `Ctrl + P` and `Ctrl + Q`.
|
||||
|
||||
|
||||
## Troubleshooting
|
||||
If you don't have the password you can
|
||||
- Remove the line `12` and `13` from the compose file
|
||||
- Start the bot with the following command:
|
||||
```
|
||||
docker-compose up -d
|
||||
```
|
||||
- Attach the terminal:
|
||||
```
|
||||
docker attach autostart_hummingbot_compose-bot-1
|
||||
```
|
||||
- Create the password and exit the client
|
||||
- Add the line `12` and `13` to the compose file and start over!
|
||||
21
autostart_hummingbot_compose/docker-compose.yml
Normal file
21
autostart_hummingbot_compose/docker-compose.yml
Normal file
@@ -0,0 +1,21 @@
|
||||
version: "3.9"
|
||||
services:
|
||||
bot:
|
||||
image: hummingbot/hummingbot:latest
|
||||
volumes:
|
||||
- "./hummingbot_files/conf:/conf"
|
||||
- "./hummingbot_files/logs:/logs"
|
||||
- "./hummingbot_files/data:/data"
|
||||
- "./hummingbot_files/scripts:/scripts"
|
||||
- "./hummingbot_files/certs:/certs"
|
||||
environment:
|
||||
- CONFIG_PASSWORD=a
|
||||
- CONFIG_FILE_NAME=format_status.py
|
||||
logging:
|
||||
driver: "json-file"
|
||||
options:
|
||||
max-size: "10m"
|
||||
max-file: 5
|
||||
tty: true
|
||||
stdin_open: true
|
||||
network_mode: host
|
||||
@@ -0,0 +1,150 @@
|
||||
########################################################
|
||||
### Pure market making strategy config ###
|
||||
########################################################
|
||||
|
||||
template_version: 24
|
||||
strategy: pure_market_making
|
||||
|
||||
# Exchange and token parameters.
|
||||
exchange: binance_paper_trade
|
||||
|
||||
# Token trading pair for the exchange, e.g. BTC-USDT
|
||||
market: ETH-USDT
|
||||
|
||||
# How far away from mid price to place the bid order.
|
||||
# Spread of 1 = 1% away from mid price at that time.
|
||||
# Example if mid price is 100 and bid_spread is 1.
|
||||
# Your bid is placed at 99.
|
||||
bid_spread: 1.0
|
||||
|
||||
# How far away from mid price to place the ask order.
|
||||
# Spread of 1 = 1% away from mid price at that time.
|
||||
# Example if mid price is 100 and ask_spread is 1.
|
||||
# Your bid is placed at 101.
|
||||
ask_spread: 1.0
|
||||
|
||||
# Minimum Spread
|
||||
# How far away from the mid price to cancel active orders
|
||||
minimum_spread: -100.0
|
||||
|
||||
# Time in seconds before cancelling and placing new orders.
|
||||
# If the value is 60, the bot cancels active orders and placing new ones after a minute.
|
||||
order_refresh_time: 10.0
|
||||
|
||||
# Time in seconds before replacing existing order with new orders at the same price.
|
||||
max_order_age: 1800.0
|
||||
|
||||
# The spread (from mid price) to defer order refresh process to the next cycle.
|
||||
# (Enter 1 to indicate 1%), value below 0, e.g. -1, is to disable this feature - not recommended.
|
||||
order_refresh_tolerance_pct: 0.0
|
||||
|
||||
# Size of your bid and ask order.
|
||||
order_amount: 0.5
|
||||
|
||||
# Price band ceiling.
|
||||
price_ceiling: -1.0
|
||||
|
||||
# Price band floor.
|
||||
price_floor: -1.0
|
||||
|
||||
# enable moving price floor and ceiling.
|
||||
moving_price_band_enabled: false
|
||||
|
||||
# Price band ceiling pct.
|
||||
price_ceiling_pct: 1.0
|
||||
|
||||
# Price band floor pct.
|
||||
price_floor_pct: -1.0
|
||||
|
||||
# price_band_refresh_time.
|
||||
price_band_refresh_time: 86400.0
|
||||
|
||||
# Whether to alternate between buys and sells (true/false).
|
||||
ping_pong_enabled: false
|
||||
|
||||
# Whether to enable Inventory skew feature (true/false).
|
||||
inventory_skew_enabled: false
|
||||
|
||||
# Target base asset inventory percentage target to be maintained (for Inventory skew feature).
|
||||
inventory_target_base_pct: 50.0
|
||||
|
||||
# The range around the inventory target base percent to maintain, expressed in multiples of total order size (for
|
||||
# inventory skew feature).
|
||||
inventory_range_multiplier: 1.0
|
||||
|
||||
# Initial price of the base asset. Note: this setting is not affects anything, the price is kept in the database.
|
||||
inventory_price: 1.0
|
||||
|
||||
# Number of levels of orders to place on each side of the order book.
|
||||
order_levels: 1
|
||||
|
||||
# Increase or decrease size of consecutive orders after the first order (if order_levels > 1).
|
||||
order_level_amount: 0.0
|
||||
|
||||
# Order price space between orders (if order_levels > 1).
|
||||
order_level_spread: 1.0
|
||||
|
||||
# How long to wait before placing the next order in case your order gets filled.
|
||||
filled_order_delay: 60.0
|
||||
|
||||
# Whether to stop cancellations of orders on the other side (of the order book),
|
||||
# when one side is filled (hanging orders feature) (true/false).
|
||||
hanging_orders_enabled: false
|
||||
|
||||
# Spread (from mid price, in percentage) hanging orders will be canceled (Enter 1 to indicate 1%)
|
||||
hanging_orders_cancel_pct: 10.0
|
||||
|
||||
# Whether to enable order optimization mode (true/false).
|
||||
order_optimization_enabled: false
|
||||
|
||||
# The depth in base asset amount to be used for finding top ask (for order optimization mode).
|
||||
ask_order_optimization_depth: 0.0
|
||||
|
||||
# The depth in base asset amount to be used for finding top bid (for order optimization mode).
|
||||
bid_order_optimization_depth: 0.0
|
||||
|
||||
# Whether to enable adding transaction costs to order price calculation (true/false).
|
||||
add_transaction_costs: false
|
||||
|
||||
# The price source (current_market/external_market/custom_api).
|
||||
price_source: current_market
|
||||
|
||||
# The price type (mid_price/last_price/last_own_trade_price/best_bid/best_ask/inventory_cost).
|
||||
price_type: mid_price
|
||||
|
||||
# An external exchange name (for external exchange pricing source).
|
||||
price_source_exchange:
|
||||
|
||||
# A trading pair for the external exchange, e.g. BTC-USDT (for external exchange pricing source).
|
||||
price_source_market:
|
||||
|
||||
# An external api that returns price (for custom_api pricing source).
|
||||
price_source_custom_api:
|
||||
|
||||
# An interval time in second to update the price from custom api (for custom_api pricing source).
|
||||
custom_api_update_interval: 5.0
|
||||
|
||||
#Take order if they cross order book when external price source is enabled
|
||||
take_if_crossed:
|
||||
|
||||
# Use user provided orders to directly override the orders placed by order_amount and order_level_parameter
|
||||
# This is an advanced feature and user is expected to directly edit this field in config file
|
||||
# Below is an sample input, the format is a dictionary, the key is user-defined order name, the value is a list which includes buy/sell, order spread, and order amount
|
||||
# order_override:
|
||||
# order_1: [buy, 0.5, 100]
|
||||
# order_2: [buy, 0.75, 200]
|
||||
# order_3: [sell, 0.1, 500]
|
||||
# Please make sure there is a space between : and [
|
||||
order_override:
|
||||
|
||||
# Simpler override config for separate bid and order level spreads
|
||||
split_order_levels_enabled: false
|
||||
bid_order_level_spreads:
|
||||
ask_order_level_spreads:
|
||||
bid_order_level_amounts:
|
||||
ask_order_level_amounts:
|
||||
# If the strategy should wait to receive cancellations confirmation before creating new orders during refresh time
|
||||
should_wait_order_cancel_confirmation: true
|
||||
|
||||
# For more detailed information, see:
|
||||
# https://docs.hummingbot.io/strategies/pure-market-making/#configuration-parameters
|
||||
@@ -0,0 +1,47 @@
|
||||
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