Thanks to visit codestin.com
Credit goes to github.com

Skip to content

aresbit/exokx

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 

Repository files navigation

MINA-USDT OKX Futures Trading Bot

A comprehensive trading bot for OKX MINA-USDT perpetual futures using OpenBB-style strategy and CCXT for execution.

Features

  • Multi-indicator Strategy: Combines RSI, MACD, Moving Averages, and Bollinger Bands
  • Risk Management: Configurable position sizing, stop loss, and take profit
  • Paper Trading: Sandbox mode for testing strategies
  • Position Management: Automatic position opening/closing based on signals
  • Comprehensive Logging: Detailed logs for all trading activities

Installation

  1. Install dependencies:
pip install -r requirements.txt
  1. Configure your OKX API credentials in config.json:
{
    "api_key": "your_api_key_here",
    "secret": "your_secret_here",
    "password": "your_password_here",
    "sandbox": true,
    "leverage": 3,
    "position_size": 0.1,
    "stop_loss": 0.02,
    "take_profit": 0.04,
    "max_positions": 1,
    "interval": "15m",
    "strategy": {
        "rsi_period": 14,
        "rsi_overbought": 70,
        "rsi_oversold": 30,
        "macd_fast": 12,
        "macd_slow": 26,
        "macd_signal": 9,
        "sma_short": 20,
        "sma_long": 50
    }
}

Usage

Basic Usage

python mina_okx_trading.py

Configuration Options

  • sandbox: Set to true for paper trading, false for live trading
  • leverage: Trading leverage (default: 3x)
  • position_size: Position size as percentage of account balance (default: 10%)
  • stop_loss: Stop loss percentage (default: 2%)
  • take_profit: Take profit percentage (default: 4%)
  • interval: Candlestick interval (default: 15m)

Strategy Parameters

  • RSI: Overbought at 70, oversold at 30
  • MACD: Fast=12, Slow=26, Signal=9
  • Moving Averages: Short=20, Long=50
  • Bollinger Bands: 20-period with 2 standard deviations

Trading Logic

The bot uses a scoring system combining multiple indicators:

  1. RSI: +1 for oversold, -1 for overbought
  2. MACD: +1 for bullish crossover, -1 for bearish crossover
  3. Moving Averages: +1 for bullish alignment, -1 for bearish alignment
  4. Bollinger Bands: +1 for touching lower band, -1 for touching upper band

Signal Generation:

  • BUY: Score ≥ 3
  • SELL: Score ≤ -3
  • HOLD: -2 ≤ Score ≤ 2

Safety Features

  • Sandbox Mode: Test strategies without real money
  • Position Limits: Maximum 1 position at a time
  • Automatic Position Closure: Closes opposite positions before opening new ones
  • Error Handling: Comprehensive error handling and logging

Monitoring

The bot creates detailed logs in mina_trading.log including:

  • Trading signals and decisions
  • Order executions
  • Position updates
  • Error messages

API Setup

  1. Create OKX API credentials at https://www.okx.com/account/my-api
  2. Enable futures trading permissions
  3. Add your API key, secret, and password to config.json
  4. Start with sandbox mode enabled for testing

Risk Warning

⚠️ Trading cryptocurrency futures involves substantial risk. Never trade with money you cannot afford to lose.

  • Always test strategies in sandbox mode first
  • Start with small position sizes
  • Monitor the bot closely during initial runs
  • Use appropriate stop losses and position sizing

Customization

You can modify the strategy by adjusting parameters in config.json or by editing the generate_signal() method in the code.

Support

For issues and questions:

  • Check the logs in mina_trading.log
  • Ensure all dependencies are installed
  • Verify API credentials and permissions
  • Test in sandbox mode first

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages