Documentation

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
  1. Create an accountRegister with your email and a strong password.
  2. 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.
  3. Create a bot — Use the Bot Wizard to pick a trading pair, strategy, and risk limits.
  4. 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:

  1. 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).
  2. Choose Strategy — Pick a trading strategy. See the Trading Strategies section for details on each.
  3. Strategy Parameters — Configure strategy-specific settings. Defaults are provided for each strategy.
  4. 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.
  5. 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
ParameterDescription
Upper PriceThe top of the grid range.
Lower PriceThe bottom of the grid range.
Grid LevelsNumber of grid lines between upper and lower price.
Quantity per GridOrder size at each grid level.
ModeArithmetic (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
ParameterDescription
Base Order SizeThe initial order amount.
Safety Order SizeThe amount for each safety order.
Max Safety OrdersMaximum number of safety orders to place.
Price Deviation %Price drop percentage to trigger each safety order.
Step ScaleMultiplier for the deviation between successive safety orders.
Volume ScaleMultiplier for the size of successive safety orders.
Take Profit %Percentage gain from average entry to close the deal.
Trailing TPEnable 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
ParameterDefaultDescription
Period14Number of candles used to calculate RSI.
Overbought Level70RSI value above which a sell signal is generated.
Oversold Level30RSI value below which a buy signal is generated.
Confirmation Candles1Number 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
ParameterDefaultDescription
Fast Period9Number of candles for the fast moving average.
Slow Period21Number of candles for the slow moving average.
MA TypeEMASimple Moving Average (SMA) or Exponential Moving Average (EMA).
Signal Smooth1Number 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
ParameterDescription
Activation %Minimum price increase from entry before the trailing stop activates.
Callback RatePercentage drop from the peak price that triggers a sell.
Entry SignalCondition 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
ParameterDefaultDescription
Fast Period12EMA period for the fast MACD line.
Slow Period26EMA period for the slow MACD line.
Signal Period9EMA 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
ParameterDefaultDescription
Period20SMA period for the middle band.
Multiplier2.0Standard 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:

SettingDefaultDescription
Modelgemini-2.0-flashThe Gemini model to use for analysis.
Temperature0.2Controls randomness (0.0 = deterministic, 2.0 = creative).
Min Confidence0.6Signals 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:

OptionDescription
Custom PromptCustom trading instructions for the AI. Available placeholders: {symbol}, {currentPrice}, {candleData}, {indicatorData}.
Replace Default PromptWhen checked, your custom prompt fully replaces the default analysis prompt. Otherwise it is appended.
Max Trade SizeMaximum trade size in USDT for this bot.
Refresh IntervalHow 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:

FeatureDescription
Stop-LossAutomatically closes the position if the price drops below a specified percentage from the entry price.
Take-ProfitAutomatically closes the position once a target profit percentage is reached.
Daily Loss LimitPauses the bot if cumulative losses for the day exceed a threshold.
Trailing StopFollows the price upward and sells if it drops by a specified callback percentage from the peak.
Kill All BotsEmergency 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
  1. Go to the Backtest page.
  2. Select a trading pair and date range.
  3. Choose a strategy and configure its parameters.
  4. Set risk limits (stop-loss, take-profit, etc.).
  5. Optionally set Leverage (1x for spot, higher values simulate futures leverage).
  6. 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
  1. Log in to your Binance account.
  2. Go to API Management in your account settings.
  3. Create a new API key with a descriptive label.
  4. Enable Spot Trading permission.
  5. Restrict the key to your server's IP address for extra security.
  6. Do not enable Withdrawal permissions.
Adding Binance Keys to Ecnanib
  1. Go to Settings → API Keys.
  2. Click Add API Key.
  3. Enter your API key and secret.
  4. The key is saved and your secret is encrypted immediately.
Adding Gemini AI Keys
  1. Get an API key from Google AI Studio.
  2. Go to Settings → API Keys and scroll to the Gemini AI Keys section.
  3. Enter a label and your API key. Optionally configure the model, temperature, and minimum confidence threshold.
  4. 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.

An unhandled error has occurred. Reload X

Rejoining the server...

Rejoin failed... trying again in seconds.

Failed to rejoin.
Please retry or reload the page.

The session has been paused by the server.

Failed to resume the session.
Please retry or reload the page.