feat: update ML threshold and configuration for improved model performance
- Added ML_THRESHOLD to .env.example and updated Config class to include ml_threshold with a default value of 0.55. - Modified MLFilter initialization in bot.py to utilize the new ml_threshold configuration. - Updated Jenkinsfile to change the registry URL for Docker image management. These changes enhance the model's adaptability by allowing for a configurable machine learning threshold, improving overall performance.
This commit is contained in:
@@ -4,3 +4,4 @@ SYMBOL=XRPUSDT
|
|||||||
LEVERAGE=10
|
LEVERAGE=10
|
||||||
RISK_PER_TRADE=0.02
|
RISK_PER_TRADE=0.02
|
||||||
DISCORD_WEBHOOK_URL=
|
DISCORD_WEBHOOK_URL=
|
||||||
|
ML_THRESHOLD=0.55
|
||||||
|
|||||||
4
Jenkinsfile
vendored
4
Jenkinsfile
vendored
@@ -2,7 +2,7 @@ pipeline {
|
|||||||
agent any
|
agent any
|
||||||
|
|
||||||
environment {
|
environment {
|
||||||
REGISTRY = '10.1.10.28:3000'
|
REGISTRY = 'git.gihyeon.com'
|
||||||
IMAGE_NAME = 'gihyeon/cointrader'
|
IMAGE_NAME = 'gihyeon/cointrader'
|
||||||
IMAGE_TAG = "${env.BUILD_NUMBER}"
|
IMAGE_TAG = "${env.BUILD_NUMBER}"
|
||||||
FULL_IMAGE = "${REGISTRY}/${IMAGE_NAME}:${IMAGE_TAG}"
|
FULL_IMAGE = "${REGISTRY}/${IMAGE_NAME}:${IMAGE_TAG}"
|
||||||
@@ -29,7 +29,7 @@ pipeline {
|
|||||||
steps {
|
steps {
|
||||||
git branch: 'main',
|
git branch: 'main',
|
||||||
credentialsId: 'gitea-cred',
|
credentialsId: 'gitea-cred',
|
||||||
url: 'http://10.1.10.28:3000/gihyeon/cointrader.git'
|
url: 'https://git.gihyeon.com/gihyeon/cointrader.git'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ class TradingBot:
|
|||||||
self.exchange = BinanceFuturesClient(config)
|
self.exchange = BinanceFuturesClient(config)
|
||||||
self.notifier = DiscordNotifier(config.discord_webhook_url)
|
self.notifier = DiscordNotifier(config.discord_webhook_url)
|
||||||
self.risk = RiskManager(config)
|
self.risk = RiskManager(config)
|
||||||
self.ml_filter = MLFilter()
|
self.ml_filter = MLFilter(threshold=config.ml_threshold)
|
||||||
self.current_trade_side: str | None = None # "LONG" | "SHORT"
|
self.current_trade_side: str | None = None # "LONG" | "SHORT"
|
||||||
self._entry_price: float | None = None
|
self._entry_price: float | None = None
|
||||||
self._entry_quantity: float | None = None
|
self._entry_quantity: float | None = None
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ class Config:
|
|||||||
margin_max_ratio: float = 0.50
|
margin_max_ratio: float = 0.50
|
||||||
margin_min_ratio: float = 0.20
|
margin_min_ratio: float = 0.20
|
||||||
margin_decay_rate: float = 0.0006
|
margin_decay_rate: float = 0.0006
|
||||||
|
ml_threshold: float = 0.55
|
||||||
|
|
||||||
def __post_init__(self):
|
def __post_init__(self):
|
||||||
self.api_key = os.getenv("BINANCE_API_KEY", "")
|
self.api_key = os.getenv("BINANCE_API_KEY", "")
|
||||||
@@ -29,3 +30,4 @@ class Config:
|
|||||||
self.margin_max_ratio = float(os.getenv("MARGIN_MAX_RATIO", "0.50"))
|
self.margin_max_ratio = float(os.getenv("MARGIN_MAX_RATIO", "0.50"))
|
||||||
self.margin_min_ratio = float(os.getenv("MARGIN_MIN_RATIO", "0.20"))
|
self.margin_min_ratio = float(os.getenv("MARGIN_MIN_RATIO", "0.20"))
|
||||||
self.margin_decay_rate = float(os.getenv("MARGIN_DECAY_RATE", "0.0006"))
|
self.margin_decay_rate = float(os.getenv("MARGIN_DECAY_RATE", "0.0006"))
|
||||||
|
self.ml_threshold = float(os.getenv("ML_THRESHOLD", "0.55"))
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ class MLFilter:
|
|||||||
self,
|
self,
|
||||||
onnx_path: str = str(ONNX_MODEL_PATH),
|
onnx_path: str = str(ONNX_MODEL_PATH),
|
||||||
lgbm_path: str = str(LGBM_MODEL_PATH),
|
lgbm_path: str = str(LGBM_MODEL_PATH),
|
||||||
threshold: float = 0.60,
|
threshold: float = 0.55,
|
||||||
):
|
):
|
||||||
self._disabled = os.environ.get("NO_ML_FILTER", "").lower() in ("1", "true", "yes")
|
self._disabled = os.environ.get("NO_ML_FILTER", "").lower() in ("1", "true", "yes")
|
||||||
self._onnx_path = Path(onnx_path)
|
self._onnx_path = Path(onnx_path)
|
||||||
|
|||||||
Reference in New Issue
Block a user