Skip to content
Proyectos

TreborNamor/strategy-workbench-ml

Ver en GitHub

Acerca de

HyperView es un conjunto de herramientas de línea de comandos que funciona sin conexión para realizar backtesting de estrategias de Python y optimizar parámetros con archivos CSV locales de velas.

Herramientas de desarrollo

Cómo se miden estas cifras

Crecimiento de estrellas medido

in 24h
0
in 7 days
+1
in 15 days
+5
in 1 month
+13

Cambios netos en períodos que se solapan, no totales diarios. Los datos no disponibles se dejan en blanco. Las estrellas indican interés, no calidad.

README.md

Original

HyperView

HyperView is an offline command line toolkit for backtesting Python strategies and optimizing their parameters with local historical candle data. It does not connect to a market data service or use browser credentials.

Vietnamese documentation

Install from a local checkout

Use Python 3.11 or newer. From the project directory:

python -m pip install -e .
hyperview --help

The package is named hyperview-backtest and the command is hyperview. You can also run python -m hyperview. The bootstrap scripts in scripts/ support local, pip, pipx, and uvx installation from the checkout. Installation may need to download dependencies. Running the toolkit uses local inputs.

Load historical candles

Use data you have permission to use for backtesting. The CSV must have a header and the columns time,open,high,low,close. The optional volume column is useful for strategies that need it. Use UTC epoch seconds or ISO 8601 timestamps throughout the time column. Timestamps without an offset are interpreted as UTC. Prices and volume must be numeric.

time,open,high,low,close,volume
2026-01-02T14:30:00Z,100,102,99,101,2500
2026-01-02T14:35:00Z,101,103,100,102,2800
hyperview import-csv ./candles.csv --symbol DEMO:EXAMPLE --timeframe 5m --session regular
hyperview list-data
hyperview list-strategies

The import validates the CSV, sorts by time, and keeps the first row for each timestamp. It writes to the configured data_dir (by default data/). It leaves the source file intact and refuses to overwrite an existing destination.

You can also put compatible CSVs in that directory directly. The filename for the example is 5m-regular-DEMO-EXAMPLE.csv. The older spelling DEMO_EXAMPLE_5m_regular.csv also works. For an adjustment label of dividends or none, append it to the stem with the matching separator. The default label is splits. Session and adjustment labels select the file and do not modify its data. Files from previous versions should only be used if your license permits backtesting.

Backtest and optimize

hyperview backtest --symbol DEMO:EXAMPLE --timeframe 5m --session regular \
  --strategy macd_rsi --sl 3 --tp 6 --mode long

hyperview hyperopt --symbol DEMO:EXAMPLE --timeframe 5m --session regular \
  --strategy macd_rsi --n-trials 50

Use a representative dataset with enough bars for the strategy. Set --start and --end to restrict the data. The start is inclusive and the end is exclusive. Omit --symbol to use the configured pairlist. Import a separate CSV for each symbol and timeframe you plan to run. The specialized smc_swing optimizer can read multiple timeframes according to smc.maps in the configuration.

The optimizer saves stop loss and take profit settings under results/. Use backtest --preset-file PATH to reuse them. Local .pine files can also be used as parameter templates with pine-optimize or pine-batch-optimize. These commands read local scripts and candles and can write updated copies of the scripts and optimization reports.

Use hyperview --config PATH COMMAND to select a configuration. See config.json and its schema for timeframe, pair list, strategy, data directory, output directory, and optimization settings.

Backtest assumptions

The simulator uses OHLC bars. Signals normally enter at the next bar's open, and stop loss and take profit fills use an assumed intrabar path. Results are simulations and depend on the dataset, strategy, and fill assumptions.

New Python strategies can extend BaseStrategy in strategy/. The package is released under the MIT License.

Indicators

HyperView ships with 20 wrapped indicators backed by TA-Lib, plus 4 signal helpers. You also have direct access to all 150+ TA-Lib functions via the to_numpy / wrap conversion helpers.

Wrapped Indicators

Category Functions
Moving Averages ema, sma, wma
Momentum rsi, macd, stochastic, stochastic_rsi, cci, williams_r, momentum, roc
Trend adx (returns ADX, +DI, −DI), aroon (returns down, up), psar
Volatility atr, bollinger_bands (returns upper, middle, lower)
Volume obv, mfi, ad, vwap

Signal Helpers

Function Description
crossed_above(a, b) True on bars where a crosses above b
crossed_below(a, b) True on bars where a crosses below b
barssince(cond) Bars since condition was last True
to_unix_timestamp(dt) Convert ISO date string to UTC unix timestamp

Using TA-Lib Directly

For any of TA-Lib's 150+ functions not wrapped above, call talib directly and use the conversion helpers:

import talib
from strategy.indicators import to_numpy, wrap

df["cci"] = wrap(talib.CCI(to_numpy(df["high"]),
                            to_numpy(df["low"]),
                            to_numpy(df["close"]), timeperiod=20), df.index)

Adding Custom Strategies

  1. Create a new file in strategy/ (e.g. my_strategy.py)
  2. Subclass BaseStrategy and implement generate_signals(), default_settings(), required_columns()
  3. Decorate the class with @register_strategy

Strategies are auto-discovered at startup — no manual imports needed.

from strategy import register_strategy
from strategy.base import BaseStrategy
from strategy.indicators import ema, crossed_above

@register_strategy
class MyStrategy(BaseStrategy):
    strategy_name = "my_strategy"

    def default_settings(self):
        return {"fast_period": 10, "slow_period": 20}

    def required_columns(self):
        return ["time", "open", "high", "low", "close"]

    def generate_signals(self, candles, settings):
        df = self.prepare_candles(candles)

        fast = ema(df["close"], settings["fast_period"])
        slow = ema(df["close"], settings["slow_period"])

        df["buy_signal"] = crossed_above(fast, slow)
        df["sell_signal"] = crossed_above(slow, fast)
        df["in_date_range"] = True
        df["enable_long"] = True
        df["enable_short"] = False

        return df

Then use it: hyperview backtest --symbol DEMO:EXAMPLE --strategy my_strategy --sl 5 --tp 5

Explorar proyectos relacionados

Cargando…