Documentation
Contents
Getting Started
Ecnanib is an automated cryptocurrency trading platform for Binance. It lets you create and manage trading bots that execute strategies 24/7, with built-in risk management and real-time monitoring.
Quick Start
- Create an account — Register with your email and a strong password.
- Connect your Binance API keys — Go to Settings → API Keys and add your Binance API key and secret. Enable "Spot Trading" permissions on Binance but keep "Withdrawals" disabled for safety.
- Create a bot — Use the Bot Wizard to pick a trading pair, strategy, and risk limits.
- Monitor — Watch your bot's performance on the Dashboard with real-time updates.
Dashboard
The Dashboard is your central control panel. It displays:
- Total Balance — The combined investment amount across all your bots.
- 24h PnL — Profit and loss over the last 24 hours.
- Active Bots — Number of bots currently running.
- Recent Trades — The latest trade executions with price, quantity, and realized PnL.
- Portfolio Allocation — A breakdown of investment across bots.
- Equity Curve — A chart showing cumulative PnL over time based on your trades.
- Kill All Bots — An emergency button that immediately stops all running bots and cancels their open orders.
Data updates in real time via SignalR, so you don't need to refresh the page.
Creating a Bot
The Bot Wizard walks you through creating a new trading bot in five steps:
- Select Trading Pair — Choose a bot name, trading pair (e.g., BTCUSDT, ETHUSDT), market type (Spot or USDT Futures), and kline interval. For futures, you can also set leverage (1x–125x) and margin type (Isolated or Cross).
- Choose Strategy — Pick a trading strategy. See the Trading Strategies section for details on each.
- Strategy Parameters — Configure strategy-specific settings. Defaults are provided for each strategy.
- Risk Limits & Investment — Set your investment amount, stop-loss, take-profit, daily loss limit, trailing stop, and max exposure. Select which Binance API key to use.
- Review & Confirm — Review your configuration. Optionally check "Start bot immediately after creation" to launch it right away.
After creation, you can start, pause, or stop your bot from the Bots page.
Trading Strategies
Ecnanib supports nine trading strategies. Each strategy has its own parameters and is suited to different market conditions.
Grid Trading
Places buy and sell orders at preset grid levels within a defined price range. Profits from price oscillation in sideways markets by repeatedly buying low and selling high within the grid.
Parameters
| Parameter | Description |
|---|---|
| Upper Price | The top of the grid range. |
| Lower Price | The bottom of the grid range. |
| Grid Levels | Number of grid lines between upper and lower price. |
| Quantity per Grid | Order size at each grid level. |
| Mode | Arithmetic (equal spacing) or Geometric (percentage spacing). |
Dollar Cost Averaging (DCA)
Opens a base order, then places additional safety orders as the price drops. This averages down your entry price and takes profit when the price rebounds.
Parameters
| Parameter | Description |
|---|---|
| Base Order Size | The initial order amount. |
| Safety Order Size | The amount for each safety order. |
| Max Safety Orders | Maximum number of safety orders to place. |
| Price Deviation % | Price drop percentage to trigger each safety order. |
| Step Scale | Multiplier for the deviation between successive safety orders. |
| Volume Scale | Multiplier for the size of successive safety orders. |
| Take Profit % | Percentage gain from average entry to close the deal. |
| Trailing TP | Enable trailing take-profit to capture extended moves. |
RSI (Relative Strength Index)
Buys when the RSI indicator drops into oversold territory and sells when it rises into overbought territory. Works best in ranging or mean-reverting markets.
Parameters
| Parameter | Default | Description |
|---|---|---|
| Period | 14 | Number of candles used to calculate RSI. |
| Overbought Level | 70 | RSI value above which a sell signal is generated. |
| Oversold Level | 30 | RSI value below which a buy signal is generated. |
| Confirmation Candles | 1 | Number of consecutive candles the RSI must remain in the zone to confirm the signal. |
Moving Average Crossover
Buys on a golden cross (fast MA crosses above slow MA) and sells on a death cross (fast MA crosses below slow MA). Effective for capturing trends in trending markets.
Parameters
| Parameter | Default | Description |
|---|---|---|
| Fast Period | 9 | Number of candles for the fast moving average. |
| Slow Period | 21 | Number of candles for the slow moving average. |
| MA Type | EMA | Simple Moving Average (SMA) or Exponential Moving Average (EMA). |
| Signal Smooth | 1 | Number of consecutive confirming ticks after a crossover before emitting a signal. Higher values reduce whipsaws. |
Trailing Stop
Enters a position and then trails the price upward. If the price drops by the callback rate from its highest point, the position is sold. This locks in profits during uptrends while limiting downside.
Parameters
| Parameter | Description |
|---|---|
| Activation % | Minimum price increase from entry before the trailing stop activates. |
| Callback Rate | Percentage drop from the peak price that triggers a sell. |
| Entry Signal | Condition or indicator that triggers the initial entry. |
MACD (Moving Average Convergence Divergence)
Generates buy signals on bullish crossovers (MACD line crosses above the signal line) and sell signals on bearish crossovers (MACD line crosses below the signal line). The histogram strength is used to gauge signal confidence.
Parameters
| Parameter | Default | Description |
|---|---|---|
| Fast Period | 12 | EMA period for the fast MACD line. |
| Slow Period | 26 | EMA period for the slow MACD line. |
| Signal Period | 9 | EMA period for the signal line. |
Bollinger Bands
A mean-reversion strategy that buys when price touches or crosses the lower band (oversold) and sells when price touches or crosses the upper band (overbought). Uses the Bollinger %B indicator to measure signal strength.
Parameters
| Parameter | Default | Description |
|---|---|---|
| Period | 20 | SMA period for the middle band. |
| Multiplier | 2.0 | Standard deviation multiplier that controls band width. |
Gemini AI
Uses Google Gemini to analyze candlestick data and generate buy, sell, or hold signals with confidence scores. The AI considers multiple technical factors and market context to make trading decisions.
Requires a Gemini API key. You can add your own key via Settings → API Keys in the Gemini AI Keys section. Each key is encrypted at rest using AES-256-GCM, just like Binance API keys. You can also configure per-key settings:
| Setting | Default | Description |
|---|---|---|
| Model | gemini-2.0-flash | The Gemini model to use for analysis. |
| Temperature | 0.2 | Controls randomness (0.0 = deterministic, 2.0 = creative). |
| Min Confidence | 0.6 | Signals below this confidence score are rejected as Hold. |
When creating a Gemini AI bot in the Bot Wizard, you must select which Gemini key to use. A per-user key is required — bots cannot use the Gemini AI strategy without one.
Bot Wizard Options
In addition to the per-key settings above, the Bot Wizard offers these per-bot options for Gemini AI:
| Option | Description |
|---|---|
| Custom Prompt | Custom trading instructions for the AI. Available placeholders: {symbol}, {currentPrice}, {candleData}, {indicatorData}. |
| Replace Default Prompt | When checked, your custom prompt fully replaces the default analysis prompt. Otherwise it is appended. |
| Max Trade Size | Maximum trade size in USDT for this bot. |
| Refresh Interval | How often (in minutes) the AI re-analyzes the market. Default is 60 minutes. |
Custom Script
Write your own trading logic in C#. Your script receives a ScriptContext global object
containing the current candlestick, up to 100 historical candles, and pre-computed indicator values.
Return a Signal with a Buy, Sell, or Hold action.
Available Helpers
Hold(reason)— Create a hold signal.Buy(strength, reason, orderType, limitPrice, quantity)— Create a buy signal.Sell(strength, reason, orderType, limitPrice, quantity)— Create a sell signal.
Security
Scripts run in a sandbox with limited namespace access (System, System.Linq, System.Collections.Generic, and Ecnanib domain types). File I/O, networking, reflection, and process management are blocked. Each script execution has a 100ms timeout. Scripts are compiled at bot startup, so compilation errors surface immediately.
Risk Management
Every bot runs through a risk management pipeline before executing trades. The following protections are available:
| Feature | Description |
|---|---|
| Stop-Loss | Automatically closes the position if the price drops below a specified percentage from the entry price. |
| Take-Profit | Automatically closes the position once a target profit percentage is reached. |
| Daily Loss Limit | Pauses the bot if cumulative losses for the day exceed a threshold. |
| Trailing Stop | Follows the price upward and sells if it drops by a specified callback percentage from the peak. |
| Kill All Bots | Emergency button on the Dashboard that immediately stops all bots and cancels all open orders. |
Risk limits are configured per bot during creation and can be updated from the bot detail page.
Backtesting
Backtesting lets you test a strategy against historical data before risking real capital.
How to Run a Backtest
- Go to the Backtest page.
- Select a trading pair and date range.
- Choose a strategy and configure its parameters.
- Set risk limits (stop-loss, take-profit, etc.).
- Optionally set Leverage (1x for spot, higher values simulate futures leverage).
- Click Run Backtest.
Interpreting Results
- Total Return — Overall percentage gain or loss.
- Win Rate — Percentage of trades that were profitable.
- Max Drawdown — Largest peak-to-trough decline during the backtest period.
- Sharpe Ratio — Risk-adjusted return (higher is better, annualized).
- Sortino Ratio — Like Sharpe but only penalizes downside volatility (annualized).
- Profit Factor — Gross profit divided by gross loss. Values above 1.0 indicate profitability.
- Avg Trade Duration — Average holding period across all trades.
- Total Trades — Number of trades executed during the simulation.
- Equity Curve — Visual chart showing portfolio value over time.
Note: Past performance does not guarantee future results. Backtests use historical data and do not account for slippage, partial fills, or exchange downtime.
Backtest Comparison
The Backtest Comparison page lets you select 2–4 previous backtest results and view them side by side. A comparison table highlights the best performer in each metric (PnL, Win Rate, Sharpe Ratio, Sortino Ratio, Max Drawdown, Profit Factor, and more), making it easy to evaluate which strategy or configuration performed best.
API Keys
Creating Binance API Keys
- Log in to your Binance account.
- Go to API Management in your account settings.
- Create a new API key with a descriptive label.
- Enable Spot Trading permission.
- Restrict the key to your server's IP address for extra security.
- Do not enable Withdrawal permissions.
Adding Binance Keys to Ecnanib
- Go to Settings → API Keys.
- Click Add API Key.
- Enter your API key and secret.
- The key is saved and your secret is encrypted immediately.
Adding Gemini AI Keys
- Get an API key from Google AI Studio.
- Go to Settings → API Keys and scroll to the Gemini AI Keys section.
- Enter a label and your API key. Optionally configure the model, temperature, and minimum confidence threshold.
- Click Test to verify the key works before using it in a bot.
When creating a Gemini AI bot, you must select a Gemini key in the Bot Wizard. Each bot stores a reference to the key, so you can use different keys (or different model settings) for different bots. If you delete a Gemini key, bots using it will not be able to start until a new key is assigned.
Security
Both Binance and Gemini API keys are encrypted at rest using AES-256-GCM with HKDF key derivation. Plaintext keys are never stored in the database. Only the encrypted ciphertext is persisted, and decryption happens in memory only when needed (to sign Binance requests or call the Gemini API).
FAQ
Q: Is my API key safe?
Yes. API secrets are encrypted with AES-256-GCM before being stored. The encryption master key is kept separate from the database. We recommend disabling withdrawal permissions on your Binance API key and restricting it to your server's IP address.
Q: Can I run multiple bots at the same time?
Yes. You can run multiple bots with different strategies, trading pairs, and risk settings simultaneously. Each bot operates independently with its own allocated capital.
Q: What happens if the app restarts?
Bot configurations are persisted in the database. When the app starts, the Bot Orchestrator automatically resumes all bots that were in the Running state. Open orders on Binance remain active regardless of the app's state.
Q: Can I use this with Binance Testnet?
Yes. Configure the Binance base URL in the application settings to point to the testnet API endpoint. This lets you test strategies with simulated funds.
Q: How do I stop all bots in an emergency?
Use the Kill All Bots button on the Dashboard. It immediately stops all running bots and cancels their open orders on Binance.
Q: What trading pairs are supported?
Ecnanib supports all spot and USDT futures trading pairs available on Binance. The Bot Wizard fetches the current list of pairs from the Binance API when you create a bot.
Q: Do I need a Gemini API key?
Only if you want to use the Gemini AI strategy. All other strategies work without it. To use the AI strategy, you must add a Gemini API key in Settings → API Keys under the Gemini AI Keys section. Each key is encrypted and stored per-user, and you can configure model, temperature, and confidence settings per key. You can also test the key before using it in a bot.