Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/tasks improvement #14

Merged
merged 88 commits into from
Nov 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
88 commits
Select commit Hold shift + click to select a range
7c50edd
(feat) add summarized metrics table and computing
tomasgaudino Oct 28, 2024
d339010
(feat) add optuna postgres db to docker-compose file
tomasgaudino Oct 28, 2024
6f3a7c1
(feat) add executors to optuna db as user attr
tomasgaudino Oct 28, 2024
2631d85
(feat) add get_metrics_df to timescale_client.py
tomasgaudino Oct 28, 2024
2320c5f
(feat) update xtreet bt tasks
cardosofede Nov 6, 2024
e8e013c
(feat) add optuna logger
tomasgaudino Oct 28, 2024
485fce4
(feat) update tasks
cardosofede Nov 6, 2024
f82969c
(feat) change logger
tomasgaudino Oct 28, 2024
14b1ff5
(feat) hardcode port and dbnames + fix dockerfile
tomasgaudino Oct 29, 2024
08b9478
(feat) more f***ing fixes
tomasgaudino Oct 29, 2024
7e417b9
(feat) more f***ing fixes
tomasgaudino Oct 29, 2024
2a72dad
(feat) more f***ing fixes
tomasgaudino Oct 29, 2024
4969209
(feat) more f***ing fixes
tomasgaudino Oct 29, 2024
b4f570a
(feat) more f***ing fixes
tomasgaudino Oct 29, 2024
a052d10
(feat) make sqlite or postgres optional to work with optimizer.py
tomasgaudino Oct 31, 2024
3b42901
(feat) implement environment variables for optimization notebook
tomasgaudino Oct 31, 2024
9eded2a
(feat) implement environment variables for optimization notebook and …
tomasgaudino Oct 31, 2024
7a11b93
(feat) update trades downloader task timescale client + update docker…
tomasgaudino Oct 31, 2024
333d0ea
(feat) add data reporting task
tomasgaudino Oct 31, 2024
a287a1b
(feat) add data reporting task
tomasgaudino Oct 31, 2024
4f24e1d
(fix) fix tsclient definition
tomasgaudino Oct 31, 2024
f44e88b
(fix) fix days data retention param
tomasgaudino Oct 31, 2024
3076094
(feat) add todo
tomasgaudino Oct 31, 2024
0f58e36
(feat) fix data reporting task
cardosofede Oct 31, 2024
30f9e83
(feat) remove reporter file
cardosofede Oct 31, 2024
0d52186
(feat) remove number restriction
cardosofede Oct 31, 2024
c2f7ea4
(feat) remove unused method
cardosofede Oct 31, 2024
22ca715
(feat) update backtesting task
cardosofede Nov 1, 2024
f3f65b1
(feat) update backtesting tasks
cardosofede Nov 1, 2024
2a7a7f3
(feat) update docker and env
cardosofede Nov 1, 2024
4d7d6c8
(feat) update env
cardosofede Nov 1, 2024
a1a0720
(feat) update report generator
cardosofede Nov 1, 2024
0feed49
(feat) update env
cardosofede Nov 1, 2024
35d2d47
(feat) update environment
cardosofede Nov 1, 2024
b29267e
(feat) update environment.yml
tomasgaudino Nov 5, 2024
6434171
(feat) rebase
tomasgaudino Nov 5, 2024
2546487
(feat) add backtesting runner service + script
tomasgaudino Nov 5, 2024
ddea502
(feat) add quants-view page
tomasgaudino Nov 5, 2024
d128998
(feat) add pgport to optunadb
tomasgaudino Nov 5, 2024
e7f5b11
(feat) setup for deployment
tomasgaudino Nov 5, 2024
72011ea
(feat) add config_id and version variables
tomasgaudino Nov 5, 2024
494abba
(feat) update environment
cardosofede Nov 6, 2024
b1c3931
(feat) update environment
cardosofede Nov 6, 2024
43d4927
(feat) update quants view
cardosofede Nov 6, 2024
dbcbd3d
(feat) update tasks
cardosofede Nov 6, 2024
515078d
(feat) update timescale config
cardosofede Nov 6, 2024
3416679
(feat) update db configs
cardosofede Nov 6, 2024
42bae33
(feat) keep custom info
cardosofede Nov 6, 2024
5504048
(feat) add start and end bt
cardosofede Nov 6, 2024
f83c488
(feat) add again executors to trials
tomasgaudino Nov 7, 2024
3cc284f
(feat) improve summary metrics generation in timescale_client.py
tomasgaudino Nov 8, 2024
f8134cb
(feat) remove append metrics from trades downloader task
tomasgaudino Nov 8, 2024
5cafa82
(feat) add metrics report runner + fix timescaledb refresh metrics me…
tomasgaudino Nov 8, 2024
14f3c23
(feat) rename metrics report to db status and add to compose-tasks.yml
tomasgaudino Nov 8, 2024
56568e6
(feat) add path rooting
tomasgaudino Nov 8, 2024
01681e4
(fix) fix error
tomasgaudino Nov 8, 2024
1b3c372
(feat) update bt task
tomasgaudino Nov 8, 2024
6cfd420
(feat) add env vars to quants-view.py
tomasgaudino Nov 8, 2024
b04a331
(fix) remove extra column from get db status df
tomasgaudino Nov 8, 2024
c5780c8
(feat) update top markets report from bt task
tomasgaudino Nov 8, 2024
3882b53
(fix) fix volume column name
tomasgaudino Nov 8, 2024
0367862
(feat) update bt task
tomasgaudino Nov 8, 2024
d2d7ca5
(feat) update config gen simple
tomasgaudino Nov 8, 2024
e0462ed
(feat) debug quants-view
tomasgaudino Nov 8, 2024
269f84c
(feat) split task and runner in db status
tomasgaudino Nov 8, 2024
813a7f1
(feat) make candles downloader multi interval + add runner
tomasgaudino Nov 8, 2024
4f93439
(feat) update compose-tasks.yml with candles downloader
tomasgaudino Nov 8, 2024
e2356f7
(feat) add sleep 1 sec to candles downloader
tomasgaudino Nov 8, 2024
d26d884
(feat) minor change
cardosofede Nov 8, 2024
0340294
(feat) update notebooks
cardosofede Nov 8, 2024
2f8fe09
(feat) add smugplug strategy design
cardosofede Nov 8, 2024
5bb5aaf
(feat) add backtesting notebook
cardosofede Nov 8, 2024
75876a9
(feat) add controller
cardosofede Nov 8, 2024
89b3a08
(feat) add smugplug bt task and config gen
tomasgaudino Nov 9, 2024
f01c081
(feat) simplify and rename append db status metric + update task
tomasgaudino Nov 9, 2024
224a22e
(feat) add now method cause it was freezed
tomasgaudino Nov 9, 2024
5f48343
(feat) add screener task + update timescaledb client to manage screen…
tomasgaudino Nov 9, 2024
559497e
(feat) add first time load feature
tomasgaudino Nov 9, 2024
e3193e2
(fix) fix timescale_client.py to accept none stuff when no data
tomasgaudino Nov 10, 2024
3e36c2e
(feat) make screener deployable
tomasgaudino Nov 10, 2024
4a6c33b
(feat) remove old screeners service
tomasgaudino Nov 10, 2024
06a83b8
(feat) update data reporting task
tomasgaudino Nov 13, 2024
2dade77
(feat) update data reporting task + fix timescaledb params
tomasgaudino Nov 13, 2024
09b04fb
(feat) add data folder for mail reporting
tomasgaudino Nov 13, 2024
31e262c
(fix) fix timedelta corrections
tomasgaudino Nov 13, 2024
7afc60e
(feat) add bot status report in report
tomasgaudino Nov 13, 2024
67db3fd
(feat) make report deployable
tomasgaudino Nov 13, 2024
cce8305
(feat) update grid strike
cardosofede Nov 13, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ COPY core/ core/
COPY environment.yml .
COPY research_notebooks/ research_notebooks/
COPY controllers/ controllers/
COPY tasks/ tasks/

# Create the environment from the environment.yml file
# If cchardet fails, we'll install it separately
Expand Down
28 changes: 28 additions & 0 deletions compose-db.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
services:
timescaledb:
container_name: timescaledb
image: timescale/timescaledb:latest-pg14
environment:
- POSTGRES_USER=admin
- POSTGRES_PASSWORD=admin
- POSTGRES_DB=timescaledb
volumes:
- timescale-data:/var/lib/postgresql/data
ports:
- "5432:5432"
optunadb:
container_name: optunadb
image: postgres:latest
environment:
- POSTGRES_USER=admin
- POSTGRES_PASSWORD=admin
- POSTGRES_DB=optimization_database
volumes:
- optuna-data:/var/lib/postgresql/data
ports:
- "5433:5432"
volumes:
timescale-data:
driver: local
optuna-data:
driver: local
54 changes: 54 additions & 0 deletions compose-tasks.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
services:
data-generation-runner:
image: hummingbot/quants-lab:latest
volumes:
- .:/quants-lab
env_file:
- .env
command: conda run --no-capture-output -n quants-lab python3 tasks/data_generation_runner.py
network_mode: host

backtesting-runner:
image: hummingbot/quants-lab:latest
volumes:
- .:/quants-lab
env_file:
- .env
command: conda run --no-capture-output -n quants-lab python3 tasks/backtesting_runner.py
network_mode: host

db-status-runner:
image: hummingbot/quants-lab:latest
volumes:
- .:/quants-lab
env_file:
- .env
command: conda run --no-capture-output -n quants-lab python3 tasks/db_status_runner.py
network_mode: host

candles-downloader-runner:
image: hummingbot/quants-lab:latest
volumes:
- .:/quants-lab
env_file:
- .env
command: conda run --no-capture-output -n quants-lab python3 tasks/candles_downloader_runner.py
network_mode: host

screener-runner:
image: hummingbot/quants-lab:latest
volumes:
- .:/quants-lab
env_file:
- .env
command: conda run --no-capture-output -n quants-lab python3 tasks/screener_runner.py
network_mode: host

report-runner:
image: hummingbot/quants-lab:latest
volumes:
- .:/quants-lab
env_file:
- .env
command: conda run --no-capture-output -n quants-lab python3 tasks/report_runner.py
network_mode: host
109 changes: 109 additions & 0 deletions controllers/directional_trading/smugplug.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
from typing import List

import pandas_ta as ta # noqa: F401
from hummingbot.client.config.config_data_types import ClientFieldData
from hummingbot.data_feed.candles_feed.data_types import CandlesConfig
from hummingbot.strategy_v2.controllers.directional_trading_controller_base import (
DirectionalTradingControllerBase,
DirectionalTradingControllerConfigBase,
)
from pydantic import Field, validator


class SmugPlugControllerConfig(DirectionalTradingControllerConfigBase):
controller_name = "smugplug"
candles_config: List[CandlesConfig] = []
candles_connector: str = Field(
default=None)
candles_trading_pair: str = Field(
default=None)
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))
macd_fast: int = Field(
default=21,
client_data=ClientFieldData(
prompt=lambda mi: "Enter the MACD fast period: ",
prompt_on_new=True))
macd_slow: int = Field(
default=42,
client_data=ClientFieldData(
prompt=lambda mi: "Enter the MACD slow period: ",
prompt_on_new=True))
macd_signal: int = Field(
default=9,
client_data=ClientFieldData(
prompt=lambda mi: "Enter the MACD signal period: ",
prompt_on_new=True))
# EMAs
ema_short: int = 8
ema_medium: int = 29
ema_long: int = 31

# ATR
atr_length: int = 11
atr_multiplier: float = 1.5

@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 SmugPlugController(DirectionalTradingControllerBase):

def __init__(self, config: SmugPlugControllerConfig, *args, **kwargs):
self.config = config
self.max_records = max(config.macd_slow, config.macd_fast, config.macd_signal,
config.atr_length, config.ema_short, config.ema_medium, config.ema_long) + 20
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)

async def update_processed_data(self):
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.macd(fast=self.config.macd_fast, slow=self.config.macd_slow, signal=self.config.macd_signal, append=True)
df.ta.atr(length=self.config.atr_length, append=True)
df.ta.ema(length=self.config.ema_short, append=True)
df.ta.ema(length=self.config.ema_medium, append=True)
df.ta.ema(length=self.config.ema_long, append=True)
df["long_atr_support"] = df["close"].shift(1) - df[
f"ATRr_{self.config.atr_length}"] * self.config.atr_multiplier
df["short_atr_resistance"] = df["close"].shift(1) + df[
f"ATRr_{self.config.atr_length}"] * self.config.atr_multiplier

macdh = df[f"MACDh_{self.config.macd_fast}_{self.config.macd_slow}_{self.config.macd_signal}"]
short_ema = df[f"EMA_{self.config.ema_short}"]
medium_ema = df[f"EMA_{self.config.ema_medium}"]
long_ema = df[f"EMA_{self.config.ema_long}"]
close = df["close"]
long_condition = (short_ema > medium_ema) & (medium_ema > long_ema) & (close > short_ema) & \
(close > df["long_atr_support"]) & (macdh > 0)
short_condition = (short_ema < medium_ema) & (medium_ema < long_ema) & (close < short_ema) & \
(close < df["short_atr_resistance"]) & (macdh < 0)

df["signal"] = 0
df.loc[long_condition, "signal"] = 1
df.loc[short_condition, "signal"] = -1

# Update processed data
self.processed_data["signal"] = df["signal"].iloc[-1]
self.processed_data["features"] = df
Loading