v0.7.2: AGGRESSIVE — ±1.0% threshold, 15% max position, 2 trades/cycle
This commit is contained in:
parent
3ae96f34e6
commit
3bc728b291
|
|
@ -20,14 +20,14 @@ if not API_KEY or not API_SECRET:
|
||||||
SYMBOLS = ['BTCUSDT', 'ETHUSDT', 'BNBUSDT', 'XRPUSDT', 'SOLUSDT', 'ADAUSDT', 'DOGUSDT', 'DOTUSDT', 'AVAXUSDT']
|
SYMBOLS = ['BTCUSDT', 'ETHUSDT', 'BNBUSDT', 'XRPUSDT', 'SOLUSDT', 'ADAUSDT', 'DOGUSDT', 'DOTUSDT', 'AVAXUSDT']
|
||||||
TRACKED_COINS = ['BTC', 'ETH', 'BNB', 'XRP', 'SOL', 'ADA', 'DOGE', 'DOT', 'AVAX']
|
TRACKED_COINS = ['BTC', 'ETH', 'BNB', 'XRP', 'SOL', 'ADA', 'DOGE', 'DOT', 'AVAX']
|
||||||
MIN_TRADE_USDT = 12.00
|
MIN_TRADE_USDT = 12.00
|
||||||
MAX_POSITION_PCT = 0.07
|
MAX_POSITION_PCT = 0.15
|
||||||
TAKE_PROFIT_PCT = 0.015
|
TAKE_PROFIT_PCT = 0.015
|
||||||
STOP_LOSS_PCT = -0.008
|
STOP_LOSS_PCT = -0.008
|
||||||
CYCLE_SEC = 60
|
CYCLE_SEC = 60
|
||||||
|
|
||||||
# COIN-LEVEL CONTRARIAN THRESHOLDS
|
# COIN-LEVEL CONTRARIAN THRESHOLDS
|
||||||
COIN_BUY_THRESHOLD = -1.5 # Buy when coin DOWN 1.5% (24h)
|
COIN_BUY_THRESHOLD = -1.0 # Buy when coin DOWN 1.0% (24h) — AGGRESSIVE
|
||||||
COIN_SELL_THRESHOLD = +1.5 # Sell when coin UP 1.5% (24h)
|
COIN_SELL_THRESHOLD = +1.0 # Sell when coin UP 1.0% (24h) — AGGRESSIVE
|
||||||
LOOKBACK_HOURS = 24
|
LOOKBACK_HOURS = 24
|
||||||
|
|
||||||
class TradingBotV07:
|
class TradingBotV07:
|
||||||
|
|
@ -39,7 +39,7 @@ class TradingBotV07:
|
||||||
self.max_trade_usdt = 0
|
self.max_trade_usdt = 0
|
||||||
|
|
||||||
# LOAD 24H PRICE HISTORY ON STARTUP
|
# LOAD 24H PRICE HISTORY ON STARTUP
|
||||||
logger.info("[v0.7.1] Loading 24h price history from Binance...")
|
logger.info("[v0.7.2 AGGRESSIVE] Loading 24h price history from Binance...")
|
||||||
for symbol in SYMBOLS:
|
for symbol in SYMBOLS:
|
||||||
try:
|
try:
|
||||||
klines = self.client.get_historical_klines(symbol, '1m', '1 day ago UTC')
|
klines = self.client.get_historical_klines(symbol, '1m', '1 day ago UTC')
|
||||||
|
|
@ -51,7 +51,7 @@ class TradingBotV07:
|
||||||
|
|
||||||
|
|
||||||
# LOAD EXISTING HOLDINGS FROM BINANCE
|
# LOAD EXISTING HOLDINGS FROM BINANCE
|
||||||
logger.info("[v0.7.1] Recovering existing holdings from Binance...")
|
logger.info("[v0.7.2 AGGRESSIVE] Recovering existing holdings from Binance...")
|
||||||
try:
|
try:
|
||||||
account = self.client.get_account()
|
account = self.client.get_account()
|
||||||
for b in account['balances']:
|
for b in account['balances']:
|
||||||
|
|
@ -74,7 +74,7 @@ class TradingBotV07:
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.warning(f"Recovery failed: {e}")
|
logger.warning(f"Recovery failed: {e}")
|
||||||
|
|
||||||
logger.info(f"[v0.7.1] Startup complete. Active trades: {len(self.active_trades)}")
|
logger.info(f"[v0.7.2 AGGRESSIVE] Startup complete. Active trades: {len(self.active_trades)}")
|
||||||
|
|
||||||
logger.info(f"[v0.7.1 INIT] Price history loaded. Ready for ±1.5% signals.")
|
logger.info(f"[v0.7.1 INIT] Price history loaded. Ready for ±1.5% signals.")
|
||||||
|
|
||||||
|
|
@ -307,24 +307,31 @@ class TradingBotV07:
|
||||||
if len(self.price_history[symbol]) > 1440: # Keep 24h history
|
if len(self.price_history[symbol]) > 1440: # Keep 24h history
|
||||||
self.price_history[symbol].pop(0)
|
self.price_history[symbol].pop(0)
|
||||||
|
|
||||||
# Check for COIN-LEVEL SELL (each coin UP 2%+)
|
# Check for COIN-LEVEL SELL (each coin UP 1%+) — UP TO 2 SELLS PER CYCLE
|
||||||
|
sell_count = 0
|
||||||
for symbol in list(self.active_trades.keys()):
|
for symbol in list(self.active_trades.keys()):
|
||||||
|
if sell_count >= 2: # Max 2 sells per cycle
|
||||||
|
break
|
||||||
if self.is_coin_sell_signal(symbol):
|
if self.is_coin_sell_signal(symbol):
|
||||||
self.place_sell_order(symbol)
|
self.place_sell_order(symbol)
|
||||||
break # One sell per cycle
|
sell_count += 1
|
||||||
|
|
||||||
# Check TP/SL
|
# Check TP/SL
|
||||||
self.check_and_close_positions()
|
self.check_and_close_positions()
|
||||||
|
|
||||||
# Check for COIN-LEVEL BUY (each coin DOWN 2%+)
|
# Check for COIN-LEVEL BUY (each coin DOWN 1%+) — UP TO 2 BUYS PER CYCLE
|
||||||
|
buy_count = 0
|
||||||
for symbol in SYMBOLS:
|
for symbol in SYMBOLS:
|
||||||
|
if buy_count >= 2: # Max 2 buys per cycle
|
||||||
|
break
|
||||||
if symbol in self.active_trades:
|
if symbol in self.active_trades:
|
||||||
continue # Skip already held
|
continue # Skip already held
|
||||||
|
|
||||||
if self.is_coin_buy_signal(symbol) and usdt_free >= MIN_TRADE_USDT:
|
if self.is_coin_buy_signal(symbol) and usdt_free >= MIN_TRADE_USDT:
|
||||||
trade_amount = min(max(MIN_TRADE_USDT, self.max_trade_usdt), usdt_free * 0.5)
|
trade_amount = min(max(MIN_TRADE_USDT, self.max_trade_usdt), usdt_free * 0.5)
|
||||||
self.place_buy_order(symbol, trade_amount)
|
self.place_buy_order(symbol, trade_amount)
|
||||||
break # One buy per cycle
|
buy_count += 1
|
||||||
|
usdt_free -= trade_amount # Update available capital
|
||||||
|
|
||||||
# Save trades
|
# Save trades
|
||||||
try:
|
try:
|
||||||
|
|
@ -336,7 +343,7 @@ class TradingBotV07:
|
||||||
'portfolio_value': round(portfolio_val, 2),
|
'portfolio_value': round(portfolio_val, 2),
|
||||||
'max_trade_usdt': round(self.max_trade_usdt, 2),
|
'max_trade_usdt': round(self.max_trade_usdt, 2),
|
||||||
'timestamp': datetime.now().isoformat(),
|
'timestamp': datetime.now().isoformat(),
|
||||||
'version': 'v0.7.1-recovery-fix'
|
'version': 'v0.7.2-aggressive-triple-option'
|
||||||
}, f)
|
}, f)
|
||||||
os.replace(temp, '/home/marc/bot-deploy/active_trades.json')
|
os.replace(temp, '/home/marc/bot-deploy/active_trades.json')
|
||||||
except:
|
except:
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue