Skip to content

Commit 5dd8d41

Browse files
authored
Merge pull request #24 from hummingbot/feat/clean_up_repo
Feat/clean up repo
2 parents 51b3ea3 + a719ae1 commit 5dd8d41

27 files changed

+180
-272
lines changed

.pre-commit-config.yaml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
repos:
2+
- repo: https://github.com/pre-commit/pre-commit-hooks
3+
rev: v2.3.0
4+
hooks:
5+
- id: detect-private-key
6+
7+
- repo: https://github.com/pre-commit/mirrors-eslint
8+
rev: v8.10.0
9+
hooks:
10+
- id: eslint
11+
files: \.[jt]sx?$ # *.js, *.jsx, *.ts and *.tsx
12+
types: [file]
13+
14+
- repo: https://github.com/CoinAlpha/git-hooks
15+
rev: 78f0683233a09c68a072fd52740d32c0376d4f0f
16+
hooks:
17+
- id: detect-wallet-private-key
18+
types: [file]
19+
exclude: .json
20+
21+
- repo: https://github.com/pycqa/isort
22+
rev: 5.12.0
23+
hooks:
24+
- id: isort
25+
files: "\\.(py)$"
26+
args: [--settings-path=pyproject.toml]
27+
28+
- repo: https://github.com/pycqa/flake8
29+
rev: 3.9.2
30+
hooks:
31+
- id: flake8
32+
additional_dependencies: ['flake8']
33+
args: [--max-line-length=130]

bots/controllers/directional_trading/bollinger_v1.py

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,20 @@
11
from typing import List
22

33
import pandas_ta as ta # noqa: F401
4-
from pydantic import Field, validator
5-
64
from hummingbot.client.config.config_data_types import ClientFieldData
75
from hummingbot.data_feed.candles_feed.data_types import CandlesConfig
86
from hummingbot.strategy_v2.controllers.directional_trading_controller_base import (
97
DirectionalTradingControllerBase,
108
DirectionalTradingControllerConfigBase,
119
)
10+
from pydantic import Field, validator
1211

1312

1413
class BollingerV1ControllerConfig(DirectionalTradingControllerConfigBase):
1514
controller_name = "bollinger_v1"
1615
candles_config: List[CandlesConfig] = []
17-
candles_connector: str = Field(
18-
default=None,
19-
client_data=ClientFieldData(
20-
prompt_on_new=True,
21-
prompt=lambda mi: "Enter the connector for the candles data, leave empty to use the same exchange as the connector: ", )
22-
)
23-
candles_trading_pair: str = Field(
24-
default=None,
25-
client_data=ClientFieldData(
26-
prompt_on_new=True,
27-
prompt=lambda mi: "Enter the trading pair for the candles data, leave empty to use the same trading pair as the connector: ", )
28-
)
16+
candles_connector: str = Field(default=None)
17+
candles_trading_pair: str = Field(default=None)
2918
interval: str = Field(
3019
default="3m",
3120
client_data=ClientFieldData(

bots/controllers/directional_trading/dman_v3.py

Lines changed: 14 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33
from typing import List, Optional, Tuple
44

55
import pandas_ta as ta # noqa: F401
6-
from pydantic import Field, validator
7-
86
from hummingbot.client.config.config_data_types import ClientFieldData
97
from hummingbot.core.data_type.common import TradeType
108
from hummingbot.data_feed.candles_feed.data_types import CandlesConfig
@@ -14,23 +12,14 @@
1412
)
1513
from hummingbot.strategy_v2.executors.dca_executor.data_types import DCAExecutorConfig, DCAMode
1614
from hummingbot.strategy_v2.executors.position_executor.data_types import TrailingStop
15+
from pydantic import Field, validator
1716

1817

1918
class DManV3ControllerConfig(DirectionalTradingControllerConfigBase):
2019
controller_name: str = "dman_v3"
2120
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)
3423
interval: str = Field(
3524
default="30m",
3625
client_data=ClientFieldData(
@@ -61,9 +50,10 @@ class DManV3ControllerConfig(DirectionalTradingControllerConfigBase):
6150
dca_spreads: List[Decimal] = Field(
6251
default="0.001,0.018,0.15,0.25",
6352
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%) ",
6757
prompt_on_new=True))
6858
dca_amounts_pct: List[Decimal] = Field(
6959
default=None,
@@ -119,7 +109,9 @@ def validate_amounts(cls, v, values):
119109
return [Decimal('1.0') / len(spreads) for _ in spreads]
120110
return v
121111

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]]:
123115
amounts_pct = self.dca_amounts_pct
124116
if amounts_pct is None:
125117
# Equally distribute if amounts_pct is not set
@@ -151,6 +143,7 @@ class DManV3Controller(DirectionalTradingControllerBase):
151143
Mean reversion strategy with Grid execution making use of Bollinger Bands indicator to make spreads dynamic
152144
and shift the mid-price.
153145
"""
146+
154147
def __init__(self, config: DManV3ControllerConfig, *args, **kwargs):
155148
self.config = config
156149
self.max_records = config.bb_length
@@ -201,8 +194,9 @@ def get_executor_config(self, trade_type: TradeType, price: Decimal, amount: Dec
201194
prices = [price * (1 + spread * spread_multiplier) for spread in spread]
202195
if self.config.dynamic_target:
203196
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)
206200
else:
207201
stop_loss = self.config.stop_loss
208202
trailing_stop = self.config.trailing_stop

bots/controllers/directional_trading/macd_bb_v1.py

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,20 @@
11
from typing import List
22

33
import pandas_ta as ta # noqa: F401
4-
from pydantic import Field, validator
5-
64
from hummingbot.client.config.config_data_types import ClientFieldData
75
from hummingbot.data_feed.candles_feed.data_types import CandlesConfig
86
from hummingbot.strategy_v2.controllers.directional_trading_controller_base import (
97
DirectionalTradingControllerBase,
108
DirectionalTradingControllerConfigBase,
119
)
10+
from pydantic import Field, validator
1211

1312

1413
class MACDBBV1ControllerConfig(DirectionalTradingControllerConfigBase):
1514
controller_name = "macd_bb_v1"
1615
candles_config: List[CandlesConfig] = []
17-
candles_connector: str = Field(
18-
default=None,
19-
client_data=ClientFieldData(
20-
prompt_on_new=True,
21-
prompt=lambda mi: "Enter the connector for the candles data, leave empty to use the same exchange as the connector: ", )
22-
)
23-
candles_trading_pair: str = Field(
24-
default=None,
25-
client_data=ClientFieldData(
26-
prompt_on_new=True,
27-
prompt=lambda mi: "Enter the trading pair for the candles data, leave empty to use the same trading pair as the connector: ", )
28-
)
16+
candles_connector: str = Field(default=None)
17+
candles_trading_pair: str = Field(default=None)
2918
interval: str = Field(
3019
default="3m",
3120
client_data=ClientFieldData(

bots/controllers/directional_trading/supertrend_v1.py

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,28 @@
11
from typing import List, Optional
22

33
import pandas_ta as ta # noqa: F401
4-
from pydantic import Field, validator
5-
64
from hummingbot.client.config.config_data_types import ClientFieldData
75
from hummingbot.data_feed.candles_feed.data_types import CandlesConfig
86
from hummingbot.strategy_v2.controllers.directional_trading_controller_base import (
97
DirectionalTradingControllerBase,
108
DirectionalTradingControllerConfigBase,
119
)
10+
from pydantic import Field, validator
1211

1312

1413
class SuperTrendConfig(DirectionalTradingControllerConfigBase):
1514
controller_name: str = "supertrend_v1"
1615
candles_config: List[CandlesConfig] = []
17-
candles_connector: Optional[str] = Field(default=None, client_data=ClientFieldData(prompt_on_new=True, prompt=lambda mi: "Enter the connector for the candles data, leave empty to use the same exchange as the connector: ", ))
18-
candles_trading_pair: Optional[str] = Field(default=None, client_data=ClientFieldData(prompt_on_new=True, prompt=lambda mi: "Enter the trading pair for the candles data, leave empty to use the same trading pair as the connector: ", ))
19-
interval: str = Field(default="3m", client_data=ClientFieldData(prompt=lambda mi: "Enter the candle interval (e.g., 1m, 5m, 1h, 1d): ", prompt_on_new=False))
20-
length: int = Field(default=20, client_data=ClientFieldData(prompt=lambda mi: "Enter the supertrend length: ", prompt_on_new=True))
21-
multiplier: float = Field(default=4.0, client_data=ClientFieldData(prompt=lambda mi: "Enter the supertrend multiplier: ", prompt_on_new=True))
22-
percentage_threshold: float = Field(default=0.01, client_data=ClientFieldData(prompt=lambda mi: "Enter the percentage threshold: ", prompt_on_new=True))
16+
candles_connector: Optional[str] = Field(default=None)
17+
candles_trading_pair: Optional[str] = Field(default=None)
18+
interval: str = Field(default="3m")
19+
length: int = Field(default=20, client_data=ClientFieldData(prompt=lambda mi: "Enter the supertrend length: ",
20+
prompt_on_new=True))
21+
multiplier: float = Field(default=4.0,
22+
client_data=ClientFieldData(prompt=lambda mi: "Enter the supertrend multiplier: ",
23+
prompt_on_new=True))
24+
percentage_threshold: float = Field(default=0.01, client_data=ClientFieldData(
25+
prompt=lambda mi: "Enter the percentage threshold: ", prompt_on_new=True))
2326

2427
@validator("candles_connector", pre=True, always=True)
2528
def set_candles_connector(cls, v, values):
@@ -54,11 +57,14 @@ async def update_processed_data(self):
5457
max_records=self.max_records)
5558
# Add indicators
5659
df.ta.supertrend(length=self.config.length, multiplier=self.config.multiplier, append=True)
57-
df["percentage_distance"] = abs(df["close"] - df[f"SUPERT_{self.config.length}_{self.config.multiplier}"]) / df["close"]
60+
df["percentage_distance"] = abs(df["close"] - df[f"SUPERT_{self.config.length}_{self.config.multiplier}"]) / df[
61+
"close"]
5862

5963
# Generate long and short conditions
60-
long_condition = (df[f"SUPERTd_{self.config.length}_{self.config.multiplier}"] == 1) & (df["percentage_distance"] < self.config.percentage_threshold)
61-
short_condition = (df[f"SUPERTd_{self.config.length}_{self.config.multiplier}"] == -1) & (df["percentage_distance"] < self.config.percentage_threshold)
64+
long_condition = (df[f"SUPERTd_{self.config.length}_{self.config.multiplier}"] == 1) & (
65+
df["percentage_distance"] < self.config.percentage_threshold)
66+
short_condition = (df[f"SUPERTd_{self.config.length}_{self.config.multiplier}"] == -1) & (
67+
df["percentage_distance"] < self.config.percentage_threshold)
6268

6369
# Choose side
6470
df['signal'] = 0

bots/controllers/directional_trading/trend_simple_v1.py

Lines changed: 0 additions & 139 deletions
This file was deleted.

0 commit comments

Comments
 (0)