forked from hummingbot/hummingbot
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into feat/new-readme-master
- Loading branch information
Showing
220 changed files
with
19,880 additions
and
9,598 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
name: Client Docker Buildx Workflow | ||
|
||
on: | ||
pull_request: | ||
types: [closed] | ||
branches: | ||
- master | ||
- development | ||
release: | ||
types: [published, edited] | ||
|
||
jobs: | ||
build_pr: | ||
if: github.event_name == 'pull_request' && github.event.pull_request.merged == true | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v4.1.1 | ||
|
||
- name: Set up QEMU | ||
uses: docker/setup-qemu-action@v3 | ||
|
||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v3.1.0 | ||
|
||
- name: Login to DockerHub | ||
uses: docker/login-action@v3 | ||
with: | ||
username: ${{ secrets.DOCKERHUB_USERNAME }} | ||
password: ${{ secrets.DOCKERHUB_TOKEN }} | ||
|
||
- name: Build and push Development Image | ||
if: github.base_ref == 'development' | ||
uses: docker/build-push-action@v5 | ||
with: | ||
context: . | ||
platforms: linux/amd64,linux/arm64 | ||
push: true | ||
tags: hummingbot/hummingbot:development | ||
|
||
- name: Build and push Latest Image | ||
if: github.base_ref == 'master' | ||
uses: docker/build-push-action@v5 | ||
with: | ||
context: . | ||
file: ./Dockerfile | ||
platforms: linux/amd64,linux/arm64 | ||
push: true | ||
tags: hummingbot/hummingbot:latest | ||
|
||
build_release: | ||
if: github.event_name == 'release' | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v4.1.1 | ||
|
||
- name: Set up QEMU | ||
uses: docker/setup-qemu-action@v3 | ||
|
||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v3.1.0 | ||
|
||
- name: Login to DockerHub | ||
uses: docker/login-action@v3 | ||
with: | ||
username: ${{ secrets.DOCKERHUB_USERNAME }} | ||
password: ${{ secrets.DOCKERHUB_TOKEN }} | ||
|
||
- name: Extract tag name | ||
id: get_tag | ||
run: echo ::set-output name=VERSION::version-${GITHUB_REF#refs/tags/v} | ||
|
||
- name: Build and push | ||
uses: docker/build-push-action@v5 | ||
with: | ||
context: . | ||
platforms: linux/amd64,linux/arm64 | ||
push: true | ||
tags: hummingbot/hummingbot:${{ steps.get_tag.outputs.VERSION }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
from typing import List | ||
|
||
import pandas as pd | ||
import pandas_ta as ta # noqa: F401 | ||
from pydantic import Field, validator | ||
|
||
from hummingbot.client.config.config_data_types import ClientFieldData | ||
from hummingbot.client.ui.interface_utils import format_df_for_printout | ||
from hummingbot.data_feed.candles_feed.candles_factory import CandlesConfig | ||
from hummingbot.smart_components.controllers.directional_trading_controller_base import ( | ||
DirectionalTradingControllerBase, | ||
DirectionalTradingControllerConfigBase, | ||
) | ||
|
||
|
||
class BollingerV1ControllerConfig(DirectionalTradingControllerConfigBase): | ||
controller_name = "bollinger_v1" | ||
candles_config: List[CandlesConfig] = [] | ||
candles_connector: 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: ", ) | ||
) | ||
candles_trading_pair: 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: ", ) | ||
) | ||
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)) | ||
bb_length: int = Field( | ||
default=100, | ||
client_data=ClientFieldData( | ||
prompt=lambda mi: "Enter the Bollinger Bands length: ", | ||
prompt_on_new=True)) | ||
bb_std: float = Field( | ||
default=2.0, | ||
client_data=ClientFieldData( | ||
prompt=lambda mi: "Enter the Bollinger Bands standard deviation: ", | ||
prompt_on_new=False)) | ||
bb_long_threshold: float = Field( | ||
default=0.0, | ||
client_data=ClientFieldData( | ||
prompt=lambda mi: "Enter the Bollinger Bands long threshold: ", | ||
prompt_on_new=True)) | ||
bb_short_threshold: float = Field( | ||
default=1.0, | ||
client_data=ClientFieldData( | ||
prompt=lambda mi: "Enter the Bollinger Bands short threshold: ", | ||
prompt_on_new=True)) | ||
|
||
@validator("candles_connector", pre=True, always=True) | ||
def set_candles_connector(cls, v, values): | ||
if v is None or v == "": | ||
return values.get("connector_name") | ||
return v | ||
|
||
@validator("candles_trading_pair", pre=True, always=True) | ||
def set_candles_trading_pair(cls, v, values): | ||
if v is None or v == "": | ||
return values.get("trading_pair") | ||
return v | ||
|
||
|
||
class BollingerV1Controller(DirectionalTradingControllerBase): | ||
|
||
def __init__(self, config: BollingerV1ControllerConfig, *args, **kwargs): | ||
self.config = config | ||
self.max_records = self.config.bb_length | ||
if len(self.config.candles_config) == 0: | ||
self.config.candles_config = [CandlesConfig( | ||
connector=config.candles_connector, | ||
trading_pair=config.candles_trading_pair, | ||
interval=config.interval, | ||
max_records=self.max_records | ||
)] | ||
super().__init__(config, *args, **kwargs) | ||
|
||
def get_signal(self) -> int: | ||
return self.get_processed_data()["signal"].iloc[-1] | ||
|
||
def get_processed_data(self) -> pd.DataFrame: | ||
df = self.market_data_provider.get_candles_df(connector_name=self.config.candles_connector, | ||
trading_pair=self.config.candles_trading_pair, | ||
interval=self.config.interval, | ||
max_records=self.max_records) | ||
# Add indicators | ||
df.ta.bbands(length=self.config.bb_length, std=self.config.bb_std, append=True) | ||
|
||
# Generate signal | ||
long_condition = df[f"BBP_{self.config.bb_length}_{self.config.bb_std}"] < self.config.bb_long_threshold | ||
short_condition = df[f"BBP_{self.config.bb_length}_{self.config.bb_std}"] > self.config.bb_short_threshold | ||
|
||
# Generate signal | ||
df["signal"] = 0 | ||
df.loc[long_condition, "signal"] = 1 | ||
df.loc[short_condition, "signal"] = -1 | ||
return df | ||
|
||
def to_format_status(self) -> List[str]: | ||
df = self.get_processed_data() | ||
return [format_df_for_printout(df.tail(5), table_format="psql", )] |
Oops, something went wrong.