The kraken-infinity-grid is an advanced, open-source Python-based trading algorithm engineered to automate cryptocurrency trading on the Kraken Spot exchange using grid trading strategies. By placing systematic buy and sell orders across predefined price intervals, it enables traders to capitalize on market volatility—buying low and selling high in a structured, repeatable manner.
Built with flexibility in mind, this tool supports multiple trading strategies such as GridHODL, GridSell, SWING, and cDCA, making it suitable for various market conditions and investment goals. It leverages the python-kraken-sdk library to securely interact with the Kraken API and can be deployed locally or via Docker, with support for both SQLite and PostgreSQL databases.
⚠️ Disclaimer: This software was designed for personal use and is not affiliated with, endorsed by, or associated with Kraken or Payward Ltd. Use at your own risk. The authors assume no liability for financial losses, technical errors, or trading outcomes resulting from its use.
Core Concepts of Grid Trading
Grid trading is a proven strategy that thrives in volatile markets by exploiting price oscillations. Instead of predicting market direction, it profits from movement—regardless of whether prices rise or fall—by placing layered orders above and below the current market price.
How Grid Trading Works
At its core, the kraken-infinity-grid creates a series of buy and sell orders spaced at fixed percentage intervals (e.g., 4%). As the price fluctuates within this grid:
- Buy orders are triggered when prices drop.
- Sell orders activate when prices rebound.
Each completed cycle—buy followed by sell—generates a small profit in the quote currency (e.g., USD), while potentially accumulating more of the base currency (e.g., BTC) depending on the strategy used.
👉 Discover how automated grid trading can enhance your crypto strategy today.
Key Advantages
- Passive Income Potential: Profits are captured continuously without requiring constant monitoring.
- Volatility Utilization: High market swings increase trading frequency and profit opportunities.
- Disciplined Execution: Removes emotional decision-making through fully automated order placement.
Available Trading Strategies
The kraken-infinity-grid supports four distinct strategies tailored to different risk profiles and market outlooks.
GridHODL
This strategy combines grid trading with long-term accumulation. It places buy orders at set intervals below the current price and automatically sets corresponding sell orders 4% above each purchase point.
- Ideal for: Sideways or moderately volatile markets.
- Outcome: Gradual accumulation of base currency with incremental profits.
- Example: With BTC at $50,000 and a 4% interval, buy orders might be placed at $48,000, $46,080, etc. Each time a buy executes, a sell is placed 4% higher.
GridSell
A profit-first approach where every bought amount is fully sold off at a markup.
- Ideal for: Traders seeking consistent short-term gains.
- Mechanism: After purchasing $100 worth of BTC at $48,000, the entire BTC amount is sold at $49,920 (4% higher).
- Benefit: Reduces exposure during downturns by not holding assets long-term.
SWING
An evolution of GridHODL that activates aggressive selling when prices break out above historical buy levels.
- Trigger Condition: When market price exceeds the highest recorded buy level.
- Action: Begins placing sell orders above that level while continuing to accumulate during dips.
- Use Case: Bull markets where rapid upward movement occurs after consolidation.
⚠️ Note: This strategy may start selling existing holdings above current prices—plan accordingly.
cDCA (Custom Dollar-Cost Averaging)
Focuses purely on accumulation by placing buy orders at fixed price intervals rather than fixed time intervals.
- No Sell Orders: All buys are held indefinitely.
- Dynamic Adjustment: As price rises, new buy zones shift upward to stay relevant.
- Best For: Long-term investors who believe in future price appreciation.
Setup & Deployment
Before running the algorithm with real funds, ensure you fully understand its behavior. Consider testing in dry-run mode first.
Prerequisites
Kraken API Keys
- Generate API keys from your Kraken account.
Ensure permissions include:
- Order placement
- Order querying
- Account information access
Telegram Notifications (Optional)
- Create two bots via @BotFather.
- Send a message to each bot to activate the chat.
- Retrieve bot tokens and chat IDs via
https://api.telegram.org/bot<TOKEN>/getUpdates.
Database
Choose between:
- Local SQLite file (simple setup)
- PostgreSQL (recommended for production)
Running the Algorithm
Option 1: Pure Python Environment
python3 -m venv venv
source venv/bin/activate
pip install kraken-infinity-grid
kraken-infinity-grid run \
--api-key YOUR_API_KEY \
--secret-key YOUR_SECRET_KEY \
--strategy GridHODL \
--base-currency BTC \
--quote-currency USD \
--amount-per-grid 100 \
--interval 0.04 \
--sqlite-file /path/to/grid.dbOption 2: Docker Compose (Recommended)
Clone the repository:
git clone https://github.com/btschwertfeger/kraken-infinity-grid.gitBuild and run:
docker system prune -a docker compose build --no-cache docker compose up
Ensure environment variables are configured in docker-compose.yaml or .env file.
Configuration Parameters
| Environment Variable | Description |
|---|---|
KRAKEN_API_KEY | Your Kraken API key |
KRAKEN_SECRET_KEY | Your Kraken secret key |
KRAKEN_RUN_STRATEGY | Strategy: GridHODL, GridSell, SWING, cDCA |
KRAKEN_RUN_BASE_CURRENCY | e.g., BTC |
KRAKEN_RUN_QUOTE_CURRENCY | e.g., USD |
KRAKEN_RUN_AMOUNT_PER_GRID | Amount per trade (e.g., 100 USD) |
KRAKEN_RUN_INTERVAL | Price interval (e.g., 0.04 = 4%) |
KRAKEN_DRY_RUN | Set to true to simulate trades |
KRAKEN_RUN_SQLITE_FILE | Path to SQLite database |
👉 Learn how to automate your crypto trades with precision tools like this one.
Monitoring & Troubleshooting
Real-Time Monitoring
- Track active orders via the Kraken Web Interface.
- Enable Telegram notifications for trade updates and exception alerts.
Common Issues & Fixes
- Invalid Nonce Errors: Use unique API keys per instance to avoid timestamp conflicts.
- Rate Limiting: Check your Kraken tier; upgrade if needed.
- API Delays: The system retries failed requests up to three times. Restart if unresolved.
- Maintenance Downtime: Monitor Kraken Status Page.
Risk Management & Best Practices
While grid trading offers consistent micro-gains, it carries risks—especially during strong trending markets or black swan events.
Risk Mitigation Tips
- Start with small capital allocations.
- Use dry-run mode extensively before live deployment.
- Monitor logs and Telegram alerts regularly.
- Avoid using shared API keys across multiple bots.
Always remember: past performance does not guarantee future results. Automated trading involves substantial risk.
Frequently Asked Questions (FAQ)
Q: Is kraken-infinity-grid safe to use with real funds?
A: While technically robust, it’s third-party software with no official Kraken support. Always test in dry-run mode first and never risk more than you can afford to lose.
Q: Can I run multiple strategies simultaneously?
A: Yes, but use separate API keys and unique userref values for each instance to prevent nonce conflicts.
Q: Does it work during market crashes or surges?
A: GridHODL and cDCA perform better in ranging markets. In strong trends, you may end up over-bought or miss upside—SWING helps mitigate this.
Q: How are profits calculated?
A: Each sell order above a buy generates a profit in quote currency minus fees. Use the配套 PnL calculator for tax reporting.
Q: Can I backtest the strategy?
A: Limited backtesting tools exist in the /tools directory, but full backtesting support is still under development.
Q: What happens if the bot goes offline?
A: Open orders remain on Kraken’s exchange. Upon restart, the bot syncs with existing orders and resumes operation.
Final Thoughts
The kraken-infinity-grid offers a powerful way to automate crypto trading on Kraken using intelligent grid-based logic. Whether you're looking to accumulate assets over time or capture frequent micro-profits, its flexible strategies adapt to your goals.
However, automation doesn’t eliminate risk—it shifts the responsibility to proper configuration, monitoring, and risk management.
👉 Take control of your trading journey with smart automation tools today.