Skip to content

Commit

Permalink
Merge branch 'master' into feat/new-readme-master
Browse files Browse the repository at this point in the history
  • Loading branch information
fengtality authored Apr 14, 2024
2 parents 251b0ed + befa575 commit 1747a6a
Show file tree
Hide file tree
Showing 220 changed files with 19,880 additions and 9,598 deletions.
3 changes: 2 additions & 1 deletion .coveragerc
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ omit =
hummingbot/connector/derivative/position.py
hummingbot/connector/exchange/bitfinex*
hummingbot/connector/exchange/coinbase_pro*
hummingbot/connector/exchange/foxbit*
hummingbot/connector/exchange/hitbtc*
hummingbot/connector/exchange/injective_v2/account_delegation_script.py
hummingbot/connector/exchange/paper_trade*
hummingbot/connector/gateway/**
hummingbot/connector/test_support/*
Expand All @@ -27,7 +29,6 @@ omit =
hummingbot/strategy/*/start.py
hummingbot/strategy/dev*
hummingbot/user/user_balances.py
hummingbot/smart_components/controllers/*
dynamic_context = test_function
branch = true

Expand Down
37 changes: 0 additions & 37 deletions .github/workflows/docker_build_dev.yml

This file was deleted.

38 changes: 0 additions & 38 deletions .github/workflows/docker_build_latest.yml

This file was deleted.

37 changes: 0 additions & 37 deletions .github/workflows/docker_build_tags.yml

This file was deleted.

80 changes: 80 additions & 0 deletions .github/workflows/docker_buildx_workflow.yml
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 }}
3 changes: 2 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ RUN conda env create -f /tmp/environment.yml && \
COPY bin/ bin/
COPY hummingbot/ hummingbot/
COPY scripts/ scripts/
COPY controllers/ controllers/
COPY scripts/ scripts-copy/
COPY setup.py .
COPY LICENSE .
Expand Down Expand Up @@ -60,7 +61,7 @@ RUN apt-get update && \
rm -rf /var/lib/apt/lists/*

# Create mount points
RUN mkdir -p /home/hummingbot/conf /home/hummingbot/conf/connectors /home/hummingbot/conf/strategies /home/hummingbot/conf/scripts /home/hummingbot/logs /home/hummingbot/data /home/hummingbot/certs /home/hummingbot/scripts
RUN mkdir -p /home/hummingbot/conf /home/hummingbot/conf/connectors /home/hummingbot/conf/strategies /home/hummingbot/conf/controllers /home/hummingbot/conf/scripts /home/hummingbot/logs /home/hummingbot/data /home/hummingbot/certs /home/hummingbot/scripts /home/hummingbot/controllers

WORKDIR /home/hummingbot

Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ test:
--exclude-dir="test/mock" \
--exclude-dir="test/hummingbot/connector/gateway/amm" \
--exclude-dir="test/hummingbot/connector/exchange/coinbase_pro" \
--exclude-dir="test/hummingbot/connector/exchange/kraken" \
--exclude-dir="test/hummingbot/connector/exchange/hitbtc" \
--exclude-dir="test/hummingbot/connector/exchange/foxbit" \
--exclude-dir="test/hummingbot/connector/gateway/clob_spot/data_sources/dexalot" \
--exclude-dir="test/hummingbot/strategy/amm_arb" \
--exclude-dir="test/hummingbot/core/gateway" \
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
107 changes: 107 additions & 0 deletions controllers/directional_trading/bollinger_v1.py
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", )]
Loading

0 comments on commit 1747a6a

Please sign in to comment.