|
3 | 3 | from typing import List, Optional, Tuple
|
4 | 4 |
|
5 | 5 | import pandas_ta as ta # noqa: F401
|
6 |
| -from pydantic import Field, validator |
7 |
| - |
8 | 6 | from hummingbot.client.config.config_data_types import ClientFieldData
|
9 | 7 | from hummingbot.core.data_type.common import TradeType
|
10 | 8 | from hummingbot.data_feed.candles_feed.data_types import CandlesConfig
|
|
14 | 12 | )
|
15 | 13 | from hummingbot.strategy_v2.executors.dca_executor.data_types import DCAExecutorConfig, DCAMode
|
16 | 14 | from hummingbot.strategy_v2.executors.position_executor.data_types import TrailingStop
|
| 15 | +from pydantic import Field, validator |
17 | 16 |
|
18 | 17 |
|
19 | 18 | class DManV3ControllerConfig(DirectionalTradingControllerConfigBase):
|
20 | 19 | controller_name: str = "dman_v3"
|
21 | 20 | candles_config: List[CandlesConfig] = []
|
22 |
| - candles_connector: str = Field( |
23 |
| - default=None, |
24 |
| - client_data=ClientFieldData( |
25 |
| - prompt_on_new=True, |
26 |
| - prompt=lambda mi: "Enter the connector for the candles data, leave empty to use the same exchange as the connector: ",) |
27 |
| - ) |
28 |
| - candles_trading_pair: str = Field( |
29 |
| - default=None, |
30 |
| - client_data=ClientFieldData( |
31 |
| - prompt_on_new=True, |
32 |
| - prompt=lambda mi: "Enter the trading pair for the candles data, leave empty to use the same trading pair as the connector: ",) |
33 |
| - ) |
| 21 | + candles_connector: str = Field(default=None) |
| 22 | + candles_trading_pair: str = Field(default=None) |
34 | 23 | interval: str = Field(
|
35 | 24 | default="30m",
|
36 | 25 | client_data=ClientFieldData(
|
@@ -61,9 +50,10 @@ class DManV3ControllerConfig(DirectionalTradingControllerConfigBase):
|
61 | 50 | dca_spreads: List[Decimal] = Field(
|
62 | 51 | default="0.001,0.018,0.15,0.25",
|
63 | 52 | client_data=ClientFieldData(
|
64 |
| - prompt=lambda mi: "Enter the spreads for each DCA level (comma-separated) if dynamic_spread=True this value " |
65 |
| - "will multiply the Bollinger Bands width, e.g. if the Bollinger Bands width is 0.1 (10%)" |
66 |
| - "and the spread is 0.2, the distance of the order to the current price will be 0.02 (2%) ", |
| 53 | + prompt=lambda |
| 54 | + mi: "Enter the spreads for each DCA level (comma-separated) if dynamic_spread=True this value " |
| 55 | + "will multiply the Bollinger Bands width, e.g. if the Bollinger Bands width is 0.1 (10%)" |
| 56 | + "and the spread is 0.2, the distance of the order to the current price will be 0.02 (2%) ", |
67 | 57 | prompt_on_new=True))
|
68 | 58 | dca_amounts_pct: List[Decimal] = Field(
|
69 | 59 | default=None,
|
@@ -119,7 +109,9 @@ def validate_amounts(cls, v, values):
|
119 | 109 | return [Decimal('1.0') / len(spreads) for _ in spreads]
|
120 | 110 | return v
|
121 | 111 |
|
122 |
| - def get_spreads_and_amounts_in_quote(self, trade_type: TradeType, total_amount_quote: Decimal) -> Tuple[List[Decimal], List[Decimal]]: |
| 112 | + def get_spreads_and_amounts_in_quote(self, |
| 113 | + trade_type: TradeType, |
| 114 | + total_amount_quote: Decimal) -> Tuple[List[Decimal], List[Decimal]]: |
123 | 115 | amounts_pct = self.dca_amounts_pct
|
124 | 116 | if amounts_pct is None:
|
125 | 117 | # Equally distribute if amounts_pct is not set
|
@@ -151,6 +143,7 @@ class DManV3Controller(DirectionalTradingControllerBase):
|
151 | 143 | Mean reversion strategy with Grid execution making use of Bollinger Bands indicator to make spreads dynamic
|
152 | 144 | and shift the mid-price.
|
153 | 145 | """
|
| 146 | + |
154 | 147 | def __init__(self, config: DManV3ControllerConfig, *args, **kwargs):
|
155 | 148 | self.config = config
|
156 | 149 | self.max_records = config.bb_length
|
@@ -201,8 +194,9 @@ def get_executor_config(self, trade_type: TradeType, price: Decimal, amount: Dec
|
201 | 194 | prices = [price * (1 + spread * spread_multiplier) for spread in spread]
|
202 | 195 | if self.config.dynamic_target:
|
203 | 196 | stop_loss = self.config.stop_loss * spread_multiplier
|
204 |
| - trailing_stop = TrailingStop(activation_price=self.config.trailing_stop.activation_price * spread_multiplier, |
205 |
| - trailing_delta=self.config.trailing_stop.trailing_delta * spread_multiplier) |
| 197 | + trailing_stop = TrailingStop( |
| 198 | + activation_price=self.config.trailing_stop.activation_price * spread_multiplier, |
| 199 | + trailing_delta=self.config.trailing_stop.trailing_delta * spread_multiplier) |
206 | 200 | else:
|
207 | 201 | stop_loss = self.config.stop_loss
|
208 | 202 | trailing_stop = self.config.trailing_stop
|
|
0 commit comments