### Run Python Example Source: https://github.com/itsxactly/btquant/blob/1.5.0-RC2/dependencies/ccapi/README.md How to execute a simple Python example after building and installing the Python binding. This is suitable for market data subscription examples. ```python python3 main.py ``` -------------------------------- ### BTQuant Installation and Setup Source: https://context7.com/itsxactly/btquant/llms.txt Provides commands for cloning the BTQuant repository, performing an automated installation that sets up a virtual environment, and activating it. Includes verification steps using the `btq` CLI. ```bash # Clone with all submodules git clone --recurse-submodules https://github.com/ItsXactlY/BTQuant.git cd BTQuant # Automated setup (creates ~/.btq virtual environment) bash Installers/install_all.sh # Activate source ~/.btq/bin/activate # Verify btq --help btq list strategies ``` -------------------------------- ### Install BTQuant using Quick Setup Command Source: https://github.com/itsxactly/btquant/wiki/2.-Getting-Started Run this command in your terminal to install BTQuant on Linux systems. Ensure you have curl installed. ```bash curl -fsSL https://raw.githubusercontent.com/itsXactlY/BTQuant/refs/heads/testing-unstable/Install/install.sh | bash ``` -------------------------------- ### Build and Run C++ Example Source: https://github.com/itsxactly/btquant/blob/1.5.0-RC2/dependencies/ccapi/README.md Instructions for building and running a C++ example using CMake. Ensure CMake is installed and follow the specified commands for building and execution. ```bash mkdir example/build cd example/build rm -rf * (if rebuild from scratch) cmake .. cmake --build . --target ``` -------------------------------- ### Run Javascript Example Source: https://github.com/itsxactly/btquant/blob/1.5.0-RC2/dependencies/ccapi/README.md Commands to install dependencies and run a Javascript example using npm. Includes steps for cleaning node modules if a rebuild is necessary. ```bash rm -rf node_modules (if rebuild from scratch) npm install node index.js ``` -------------------------------- ### Start a Specific BTQuant Bot Example Source: https://github.com/itsxactly/btquant/wiki/5. Pm2 Starts a specific BTQuant bot example script (Example_Trading_Websocket_Tickdata_Mexc.py) using Python 3 and names the process 'mexc-ws'. ```bash pm2 start Example_Trading_Websocket_Tickdata_Mexc.py --interpreter=python3 --name="mexc-ws" ``` -------------------------------- ### Install BTQuant Framework Source: https://github.com/itsxactly/btquant/blob/1.5.0-RC2/README.md Automated script to install BTQuant, CCAPI C++ components, shared memory setup, and M$SQL adapter. Ensure prerequisites like Python 3.12+ and C++17 are met. This script handles multiple setup steps for a complete BTQuant environment. ```bash git clone --recurse-submodules https://github.com/ItsXactlY/BTQuant.git cd BTQuant bash Installers/install_all.sh ``` -------------------------------- ### HotSpine SQL Integration Usage Example Source: https://github.com/itsxactly/btquant/blob/1.5.0-RC2/docs/technical/hotspine.md Example of initializing HotSpineSQLIntegration, starting asynchronous storage, storing a trade, querying historical data, and stopping storage. ```python from backtrader.hotspine.sql_integration import HotSpineSQLIntegration from backtrader.bigbraincentral.storage_mssql import MSSQLConfig config = MSSQLConfig(server="localhost", database="BTQ_MarketData") integration = HotSpineSQLIntegration(sql_config=config) integration.start_async_storage() # Store trade asynchronously integration.store_trade_async(trade) # Query historical data trades = integration.get_historical_trades( exchange="binance", symbol="BTC-USDT", start=datetime(2024, 1, 1) ) integration.stop_async_storage() ``` -------------------------------- ### Install and Configure SQL Server Source: https://github.com/itsxactly/btquant/wiki/6.1-[OBSOLETE]Installing-Microsoft-SQL Installs the SQL Server for Linux package and runs the initial setup script to configure the server, including edition selection, SA password, and license acceptance. ```bash yay -S mssql-server sudo /opt/mssql/bin/mssql-conf setup ``` -------------------------------- ### Live Trading Binance Setup (Python) Source: https://github.com/itsxactly/btquant/blob/1.5.0-RC2/docs/technical/architecture.md Configures live trading with Binance, specifying coin, collateral, exchange, account, and asset. Supports strategy selection, historical data start time, and alert configurations. ```python def livetrade_binance( coin: str, collateral: str, exchange: str, account: str, asset: str, strategy: str = "", start_hours_ago: int = 1, enable_alerts: bool = False, alert_channel: str = "", ) -> None: ... ``` -------------------------------- ### Build and Run Java Example Source: https://github.com/itsxactly/btquant/blob/1.5.0-RC2/dependencies/ccapi/README.md Steps to compile and run a Java example, including setting the classpath and library path. Troubleshoot common errors related to missing packages or libraries. ```bash mkdir build cd build rm -rf * (if rebuild from scratch) javac -cp ../../../../build/java/packaging/1.0.0/ccapi-1.0.0.jar -d . ../Main.java java -cp .:../../../../build/java/packaging/1.0.0/ccapi-1.0.0.jar -Djava.library.path=../../../../build/java/packaging/1.0.0 Main ``` -------------------------------- ### Build and Run Go Example Source: https://github.com/itsxactly/btquant/blob/1.5.0-RC2/dependencies/ccapi/README.md Steps to build and run a Go example, emphasizing the importance of sourcing the export script for cgo tool environment variables. Includes cleaning and building commands. ```bash go clean (if rebuild from scratch) source ../../../build/go/packaging/1.0.0/export_compiler_options.sh (this step is important) go build . ./main ``` -------------------------------- ### Run Linux Shell Script Installer Source: https://github.com/itsxactly/btquant/blob/1.5.0-RC2/installers/INSTALL.md Navigate to the installer directory, make the script executable, and run it to install PubBTQuant on Linux. The installer handles dependency checks, building, and system integration. ```bash cd /path/to/PubBTQuant/installers/linux chmod +x installer.sh ./installer.sh ``` -------------------------------- ### Install BTQuant Project Source: https://github.com/itsxactly/btquant/blob/1.5.0-RC2/autonomous_agency/README.md Navigate to the BTQuant project directory to begin. ```bash cd /path/to/PubBTQuant ``` -------------------------------- ### Set Up Development Environment Source: https://github.com/itsxactly/btquant/blob/1.5.0-RC2/README.md Installs the necessary dependencies for development. Ensure you have forked and cloned the repository first. ```bash git clone https://github.com/itsXactlY/BTQuant.git cd BTQuant bash Installers/install.sh --dev ``` -------------------------------- ### Live Trading HotSpine Setup (Python) Source: https://github.com/itsxactly/btquant/blob/1.5.0-RC2/docs/technical/architecture.md Starts live trading using the HotSpine shared memory feed. Requires a symbol ID and strategy class. Customizable with shared memory name, batch mode, poll interval, and strategy parameters. ```python def livetrade_hotspine( symbol_id: int, strategy_class, shm_name: str = "/btquant_hotspine", batch_mode: bool = False, poll_interval: float = 0.0001, **strategy_params ) -> None: ... ``` -------------------------------- ### Automated BTQuant Installation Source: https://github.com/itsxactly/btquant/blob/1.5.0-RC2/docs/installation.md Use this script to automatically clone the repository, install dependencies, configure SQL Server, set up the Python environment, and build BTQuant components. ```bash git clone --recurse-submodules -b prototyping https://github.com/ItsXactlY/BTQuant BTQuant cd BTQuant bash Installers/install_all.sh ``` -------------------------------- ### Manual Installation: Create Virtual Environment Source: https://github.com/itsxactly/btquant/blob/1.5.0-RC2/docs/installation.md Create and activate a Python virtual environment for BTQuant. ```bash python3 -m venv ~/.btq source ~/.btq/bin/activate ``` -------------------------------- ### Run C# Example Source: https://github.com/itsxactly/btquant/blob/1.5.0-RC2/dependencies/ccapi/README.md Instructions for running a C# example, including setting the LD_LIBRARY_PATH environment variable and specifying the CCAPI library path. Addresses common build and runtime errors. ```bash dotnet clean (if rebuild from scratch) env LD_LIBRARY_PATH="$LD_LIBRARY_PATH:../../../build/csharp/packaging/1.0.0" dotnet run --property:CcapiLibraryPath=../../../build/csharp/packaging/1.0.0/ccapi.dll -c Release ``` -------------------------------- ### Run macOS Shell Script Installer Source: https://github.com/itsxactly/btquant/blob/1.5.0-RC2/installers/INSTALL.md Navigate to the macOS installer directory, make the script executable, and run it to install PubBTQuant. This process includes dependency installation via Homebrew, application building, and DMG creation. ```bash cd /path/to/PubBTQuant/installers/macos chmod +x installer.sh ./installer.sh ``` -------------------------------- ### Install Dependencies from Source Source: https://github.com/itsxactly/btquant/blob/1.5.0-RC2/docs/installation.md Ensure you are in the virtual environment and have navigated to the dependencies directory before installing from source. This is crucial for resolving import errors. ```bash source ~/.btq/bin/activate cd dependencies pip install . ``` -------------------------------- ### BTQuant Built-in Indicators Example Source: https://context7.com/itsxactly/btquant/llms.txt Demonstrates the initialization of various standard, Ehlers, and BTQuant custom indicators within a Backtrader strategy. Ensure Backtrader is installed and indicators are imported correctly. ```python import backtrader as bt from backtrader.indicators.ehlers import ( MesaAdaptiveMovingAverage, LaguerreFilter, RSX, SuperSmootherFilter, CyberCycle, DecyclerOscillator, ) from backtrader.indicators.supertrend import SuperTrend from backtrader.indicators.qqe import QQE from backtrader.indicators.vumanchu import VumanchuMarketCipher_A class DemoStrategy(bt.Strategy): def __init__(self): # Standard self.sma = bt.ind.SMA(period=20) self.ema = bt.ind.EMA(period=20) self.rsi = bt.ind.RSI(period=14) self.macd = bt.ind.MACD(period_me1=12, period_me2=26, period_signal=9) self.bb = bt.ind.BollingerBands(period=20, devfactor=2.0) self.atr = bt.ind.ATR(period=14) # Ehlers self.mama = MesaAdaptiveMovingAverage(self.data.close, fast=0.5, slow=0.05) self.lag = LaguerreFilter(self.data.close, gamma=0.8) self.rsx = RSX(self.data.close, period=14) self.ss = SuperSmootherFilter(self.data.close, period=20) self.cc = CyberCycle(self.data.close, alpha=0.07) self.dec = DecyclerOscillator(self.data.close) # BTQuant custom self.st = SuperTrend(self.data, period=10, multiplier=3.0) self.qqe = QQE(self.data.close, rsi_period=14, sf=5) self.vmc = VumanchuMarketCipher_A(self.data) def next(self): if self.mama.mama[0] > self.mama.fama[0] and self.qqe.trend[0] > 0: self.buy() ``` -------------------------------- ### Manual Installation: Install Python Dependencies Source: https://github.com/itsxactly/btquant/blob/1.5.0-RC2/docs/installation.md Install Python dependencies, including core libraries and optional packages, within the activated virtual environment. ```bash pip install --upgrade pip setuptools wheel pip install pybind11 cd dependencies pip install . ``` -------------------------------- ### Install Development Dependencies Source: https://github.com/itsxactly/btquant/blob/1.5.0-RC2/TEST_REPORT.md Installs all development dependencies listed in the requirements-dev.txt file. This command should be run after setting up the virtual environment. ```bash pip install -r requirements-dev.txt ``` -------------------------------- ### Manual Installation: Clone Repository Source: https://github.com/itsxactly/btquant/blob/1.5.0-RC2/docs/installation.md Manually clone the BTQuant repository and navigate into the project directory. ```bash git clone --recurse-submodules -b prototyping https://github.com/ItsXactlY/BTQuant BTQuant cd BTQuant ``` -------------------------------- ### Run Installer Test Script Source: https://github.com/itsxactly/btquant/blob/1.5.0-RC2/installers/README.md Execute the test suite to verify the functionality of the installer system. ```bash ./installers/test_installer.sh ``` -------------------------------- ### Install System Dependencies Source: https://github.com/itsxactly/btquant/blob/1.5.0-RC2/docs/troubleshooting.md Installs necessary system packages for BTQuant on Ubuntu/Debian. It also shows how to clear the pip cache and reinstall dependencies. ```bash # Install system dependencies (Ubuntu/Debian) sudo apt-get update sudo apt-get install -y build-essential python3-dev unixodbc-dev git # Clear pip cache and reinstall pip cache purge cd dependencies pip install . ``` -------------------------------- ### Install pyker for Process Management Source: https://github.com/itsxactly/btquant/blob/1.5.0-RC2/dependencies/dashboard/README.md Clones the pyker repository and installs it for process management. This is an optional step. ```bash git clone https://github.com/mrvi0/pyker.git cd pyker python3 install.py ``` -------------------------------- ### CLI Backtesting Commands Source: https://github.com/itsxactly/btquant/blob/1.5.0-RC2/docs/user-guide/backtesting.md Examples of how to use the btq CLI for backtesting, bulk analysis, optimization, and listing resources. ```APIDOC ## CLI Commands ### Single Backtest ```bash btq backtest --coin BTC --strategy SMA_Cross_Simple --interval 1h \ --start 2024-01-01 --end 2025-01-01 --cash 10000 --plot ``` ### Multiple Coins ```bash btq backtest --coins BTC,ETH,BNB --strategy MACD_ADX --interval 15m ``` ### Bulk Analysis ```bash btq bulk --interval 1h --workers 8 --strategy Aligator_supertrend ``` ### Optimization ```bash btq optimize --coin BTC --strategy QQE_Hullband_VolumeOsc \ --trials 200 --aggressive --workers 6 ``` ### List Resources ```bash btq list strategies btq list coins --collateral USDT ``` ### CLI Arguments **Mode** (required, first arg): `backtest`, `bulk`, `optimize`, `list`, `live` | Group | Flag | Default | Description | |---|---|---|---| | Common | `--coin` / `--symbol` | - | Single coin (e.g. BTC) | | Common | `--coins` / `--symbols` | - | Comma-separated coins | | Common | `--strategy` / `--strat` | - | Strategy class name | | Common | `--collateral` / `--pair` | USDT | Trading pair | | Common | `--interval` / `--timeframe` / `--tf` | 15m | Timeframe | | Common | `--start` / `--start-date` | - | Start date YYYY-MM-DD | | Common | `--end` / `--end-date` | 2025-01-01 | End date YYYY-MM-DD | | Capital | `--cash` / `--capital` | 1000 | Initial capital | | Capital | `--commission` | 0.00075 | Commission rate | | Capital | `--leverage` | 1 | Leverage multiplier | | Capital | `--slippage` | 5.0 | Slippage in bps | | Output | `--plot` / `-p` | false | Show plot | | Output | `--quantstats` / `-q` | false | Generate QuantStats HTML report | | Output | `--debug` / `-d` | false | Debug output | | Output | `--verbose` / `-v` | false | Verbose output | | Output | `--save` | false | Save results to file | | Output | `--output` / `-o` | auto | Output filename | | Bulk | `--workers` / `-j` | 8 | Parallel workers | | Optimize | `--trials` / `-n` | 200 | Optuna trials | | Optimize | `--opt-workers` | same as --workers | Parallel opt workers | | Optimize | `--study-name` | auto | Optuna study name | | Optimize | `--aggressive` | false | Aggressive param space | | Optimize | `--conservative` | false | Conservative param space | | Optimize | `--multi-period` | false | Multi-period validation | | Optimize | `--min-trades` | 30 | Min trades for valid trial | | Optimize | `--pruner` | hyperband | Pruner: hyperband, median, none | | Optimize | `--seed` | 42 | Random seed | | Strategy | `--params` | - | JSON or key=value params | | Strategy | `--take-profit` / `--tp` | - | Take profit % | | Strategy | `--stop-loss` / `--sl` | - | Stop loss % | | Strategy | `--position-size` / `--size` | - | Position size % of capital | | Misc | `--exchange` | - | Exchange name | | Misc | `--no-cache` | false | Disable caching | | Misc | `--clear-cache` | false | Clear cache before run | ``` -------------------------------- ### Post-Installation Commands Source: https://github.com/itsxactly/btquant/blob/1.5.0-RC2/docs/installation.md After the automated installation, activate the virtual environment and reload the PATH to ensure all tools are accessible. ```bash # Activate the virtual environment source ~/.btq/bin/activate # Reload PATH for sqlcmd and ~/bin source ~/.bashrc ``` -------------------------------- ### Monitor All Detectors Example Output Source: https://github.com/itsxactly/btquant/blob/1.5.0-RC2/tests/new/QUICKSTART.md Example output from the full manipulation monitor, showing detected stop hunts, arbitrage opportunities, and whale activity. ```text 🚨 StopHunt(symbol=BTC-USDT, exchange=binance, deviation=-1.2%, signal=LONG) 💰 Arbitrage(buy=kraken@42150, sell=binance@42250, profit=65bps) 🐋 WhaleDetected(symbol=ETH-USDT, size=$250000, lagging=3 exchanges) ``` -------------------------------- ### Install Azure Data Studio Source: https://github.com/itsxactly/btquant/wiki/6.1-[OBSOLETE]Installing-Microsoft-SQL Installs Azure Data Studio, a cross-platform graphical tool for managing SQL Server, from the Arch User Repository (AUR). ```bash yay -S azuredatastudio-bin ``` -------------------------------- ### Multi-Symbol Live Trading with HotSpine Source: https://github.com/itsxactly/btquant/blob/1.5.0-RC2/docs/technical/hotspine.md Example of setting up live trading for multiple symbols simultaneously using livetrade_hotspine_multi_symbol. ```python from backtrader.livetrading import livetrade_hotspine_multi_symbol livetrade_hotspine_multi_symbol( symbol_ids=[1, 2, 3], # BTC, ETH, SOL strategy=MyStrategy, shm_name="/btquant_hotspine" ) ``` -------------------------------- ### Install Backtrader in Development Mode Source: https://github.com/itsxactly/btquant/blob/1.5.0-RC2/TEST_REPORT.md Installs the backtrader package in development mode from a local path. Ensure the path to the dependencies directory is correct. ```bash pip install -e ../dependencies ``` -------------------------------- ### btq CLI Modes Source: https://github.com/itsxactly/btquant/blob/1.5.0-RC2/docs/technical/architecture.md Examples of common btq CLI commands for different operational modes. ```bash btq backtest --coin BTC --strategy MyStrat --interval 15m ``` ```bash btq bulk --strategy MyStrat --interval 1h --workers 8 ``` ```bash btq optimize --coin BTC --strategy MyStrat --trials 200 ``` ```bash btq list strategies ``` ```bash btq list coins --collateral USDT ``` -------------------------------- ### SQL Server Connection String Example Source: https://github.com/itsxactly/btquant/blob/1.5.0-RC2/docs/technical/bigbraincentral.md An example of a formatted ODBC connection string for SQL Server. Ensure 'YourPassword' is replaced with the actual password. ```sql DRIVER={ODBC Driver 18 for SQL Server};SERVER=localhost;DATABASE=BTQ_MarketData;UID=SA;PWD=YourPassword;TrustServerCertificate=yes; ``` -------------------------------- ### Install SQL Server ODBC Driver and Tools Source: https://github.com/itsxactly/btquant/wiki/6.1-[OBSOLETE]Installing-Microsoft-SQL Installs the necessary ODBC drivers and command-line tools for interacting with SQL Server on Arch Linux using yay. ```bash yay -S msodbcsql yay -S mssql-tools ``` -------------------------------- ### Start a BTQuant Bot with PM2 Source: https://github.com/itsxactly/btquant/wiki/5. Pm2 Starts a Python script as a managed process using PM2. Specify the script, interpreter, and a descriptive name for easy identification. ```bash pm2 start script.py --interpreter=python3 --name="descriptive-name" ``` -------------------------------- ### Live Trading Setup with CCXT Source: https://github.com/itsxactly/btquant/blob/1.5.0-RC2/docs/quickstart.md Sets up live trading using CCXT for specified exchanges. Requires API keys and configuration details. ```python from backtrader.strategies.NearestNeighbors_RationalQuadraticKernel import NRK from backtrader import livetrading ccxt_config = { 'apiKey': '', 'secret': '', 'enableRateLimit': True, 'rateLimit': 20, 'options': {'defaultType': 'spot'} } livetrading.livetrade( coin='XRP', collateral='USDT', strategy=NRK, asset='XRP/USDT', exchange='mexc', account='', config=ccxt_config ) ``` -------------------------------- ### Clone BTQuant Project Source: https://github.com/itsxactly/btquant/blob/1.5.0-RC2/tests/new/QUICKSTART.md Clone the BTQuant project and navigate to the manipulation detector example directory. ```bash cd ~/projects/BTQuant/dependencies/ccapi/example/ mkdir manipulation_detector cd manipulation_detector # Copy all files here ``` -------------------------------- ### Run Agency Modes Source: https://github.com/itsxactly/btquant/blob/1.5.0-RC2/autonomous_agency/README.md Initialize the agency, check its status, or start the perpetual optimization loop. ```bash python run_agency.py --mode init python run_agency.py --mode status python run_agency.py --mode full ``` -------------------------------- ### CLI Backtest Command Source: https://github.com/itsxactly/btquant/blob/1.5.0-RC2/docs/user-guide/strategies.md Example of how to run a backtest using the command-line interface. Specifies the coin, strategy, interval, and enables plotting. ```bash # Single backtest btq backtest --coin BTC --strategy SMA_Cross_Simple --interval 15m --plot ``` -------------------------------- ### CCXT JSON Configuration Example Source: https://github.com/itsxactly/btquant/blob/1.5.0-RC2/docs/technical/configuration.md Example of a CCXT exchange configuration file in JSON format. This file should be placed in the virtual environment's `ccxt/` directory, named `{exchange}_{account}.json`. It includes API keys, secrets, and specific exchange options. ```json { "apiKey": "your-api-key-here", "secret": "your-secret-here", "enableRateLimit": true, "options": { "adjustForTimeDifference": true, "defaultType": "spot" } } ``` -------------------------------- ### C++ Build Configuration with CMake Source: https://github.com/itsxactly/btquant/blob/1.5.0-RC2/dependencies/ccapi/README.md Example CMakeLists.txt for building the C++ library. Ensure C++17 and OpenSSL are available. Define service and exchange enablement macros. ```cmake cmake -DOPENSSL_ROOT_DIR=... On macOS, you might be missing headers for OpenSSL, `brew install openssl` and `cmake -DOPENSSL_ROOT_DIR=/usr/local/opt/openssl`. On Ubuntu, `sudo apt-get install libssl-dev`. On Windows, `vcpkg install openssl:x64-windows` and `cmake -DOPENSSL_ROOT_DIR=C:/vcpkg/installed/x64-windows-static`. ``` -------------------------------- ### New Detector Header File Example Source: https://github.com/itsxactly/btquant/blob/1.5.0-RC2/tests/new/ARCHITECTURE.md Create a new header file in `include/detectors/` inheriting from `DetectorPlugin`. Implement `getName`, `configure`, `analyze`, and `onOrderBookUpdate` methods. ```cpp // include/detectors/new_detector.hpp #pragma once #include "detector_plugin.hpp" class NewDetector : public DetectorPlugin { public: std::string getName() const override { return "new_detector"; } void configure(const YAML::Node& config) override; std::vector analyze(const MarketSnapshot& snapshot) override; void onOrderBookUpdate(const OrderBook& book) override; }; ``` -------------------------------- ### Live Trading with HotSpine Source: https://github.com/itsxactly/btquant/blob/1.5.0-RC2/docs/technical/hotspine.md Example of initiating live trading using the livetrade_hotspine function with specific symbol ID and trading parameters. ```python from backtrader.livetrading import livetrade_hotspine livetrade_hotspine( symbol_id=1, # BTC-USDT on Binance strategy_class=MyStrategy, shm_name="/btquant_hotspine", batch_mode=False, poll_interval=0.0001, take_profit=2.0, stop_loss=1.0 ) ``` -------------------------------- ### Manual Installation: Build CCAPI Source: https://github.com/itsxactly/btquant/blob/1.5.0-RC2/docs/installation.md Build the CCAPI component for real-time market data collection. This involves updating submodules, configuring with CMake, and building the project. ```bash cd dependencies/ccapi git submodule update --init --recursive cd example mkdir -p build && cd build cmake .. cmake --build . ``` -------------------------------- ### ReadOnlyTradesAgg Get Ticks by ID Method Source: https://github.com/itsxactly/btquant/blob/1.5.0-RC2/docs/technical/bigbraincentral.md Retrieves tick-level trade data starting from a specific ID. Useful for incremental updates. ```python class ReadOnlyTradesAgg(ReadOnlyOHLCV): def get_ticks_by_id(self, exchange: str, symbol: str, last_id: int, limit: int = 1000) -> list[dict]: ``` -------------------------------- ### Live Trading MEXC Setup (Python) Source: https://github.com/itsxactly/btquant/blob/1.5.0-RC2/docs/technical/architecture.md Sets up live trading for MEXC, similar to Binance, requiring coin, collateral, exchange, account, and asset. Includes options for strategy, historical data, and alerts. ```python def livetrade_mexc( coin: str, collateral: str, exchange: str, account: str, asset: str, strategy: str = "", start_hours_ago: int = 1, enable_alerts: bool = False, alert_channel: str = "", ) -> None: ... ``` -------------------------------- ### Live Trading Bitget Setup (Python) Source: https://github.com/itsxactly/btquant/blob/1.5.0-RC2/docs/technical/architecture.md Initializes live trading for Bitget, specifying coin, collateral, exchange, account, and asset. Supports strategy, historical data loading, and alert settings. ```python def livetrade_bitget( coin: str, collateral: str, exchange: str, account: str, asset: str, strategy: str = "", start_hours_ago: int = 1, enable_alerts: bool = False, alert_channel: str = "", ) -> None: ... ``` -------------------------------- ### Get Crypto Data with CCXT Source: https://github.com/itsxactly/btquant/blob/1.5.0-RC2/docs/faq.md Fetch historical cryptocurrency data for a specified symbol, date range, timeframe, and exchange using the CCXT library. Ensure CCXT is installed and configured. ```python from backtrader import get_crypto_data data = get_crypto_data('BTC/USDT', '2024-01-01', '2024-01-31', '1h', 'binance') ``` -------------------------------- ### List Available Resources with btq CLI Source: https://context7.com/itsxactly/btquant/llms.txt Use the `btq` CLI to list available strategies or coins. You can filter coins by collateral. ```bash # List available resources btq list strategies btq list coins --collateral USDT ``` -------------------------------- ### Compile Windows NSIS Installer Source: https://github.com/itsxactly/btquant/blob/1.5.0-RC2/installers/INSTALL.md Compile the NSIS installer script for Windows using the `makensis` command. Ensure NSIS is installed and the script path is correct. ```bash makensis installers\windows\installer.nsi ``` -------------------------------- ### Install ImPlot using vcpkg Source: https://github.com/itsxactly/btquant/blob/1.5.0-RC2/dependencies/BTQ_Render_Engine/src/imgui/README.md Instructions for installing ImPlot via the vcpkg dependency manager. This involves cloning vcpkg, bootstrapping, integrating, and then installing the implot package. ```bash git clone https://github.com/Microsoft/vcpkg.git cd vcpkg ./bootstrap-vcpkg.sh ./vcpkg integrate install ./vcpkg install implot ``` -------------------------------- ### List Resources via CLI Source: https://github.com/itsxactly/btquant/blob/1.5.0-RC2/docs/user-guide/backtesting.md List available strategies or coins. Use `--collateral` to filter coins by their collateral asset. ```bash btq list strategies ``` ```bash btq list coins --collateral USDT ``` -------------------------------- ### Install PM2 Globally Source: https://github.com/itsxactly/btquant/wiki/5. Pm2 Installs PM2 globally on your system using npm, making it accessible from any directory. ```bash npm install pm2 -g ``` -------------------------------- ### Install Python Dependencies Source: https://github.com/itsxactly/btquant/blob/1.5.0-RC2/dependencies/dashboard/README.md Installs the necessary Python packages for the dashboard. Ensure you have a `requirements.txt` file in your project directory. ```bash pip install -r requirements.txt ``` -------------------------------- ### Live Trading Web3 Setup (Python) Source: https://github.com/itsxactly/btquant/blob/1.5.0-RC2/docs/technical/architecture.md Initiates live trading via Web3, requiring coin, collateral, Web3 WebSocket endpoint, exchange, account, and asset details. Supports strategy selection, timezone, and alert configuration. ```python def livetrade_web3( coin: str, collateral: str, web3ws: str, exchange: str, account: str, asset: str, strategy: str = "", timezone: str = 'Europe/Berlin', start_hours_ago: int = 2, enable_alerts: bool = False, ) -> None: ... ``` -------------------------------- ### Start Dashboard with pyker Source: https://github.com/itsxactly/btquant/blob/1.5.0-RC2/dependencies/dashboard/README.md Starts the dashboard process using pyker, a process management tool. This is an alternative to running Streamlit directly. ```bash pyker start dashboard start.py ``` -------------------------------- ### Configure API Keys via File Source: https://github.com/itsxactly/btquant/blob/1.5.0-RC2/docs/troubleshooting.md Creates a configuration file to store API keys and secrets for exchanges like Binance. Ensure the file path and content are correct. ```bash mkdir -p .btq/ccxt cat > .btq/ccxt/binance_main.json << 'EOF' { "apiKey": "your-api-key", "secret": "your-secret" } EOF ``` -------------------------------- ### Remove Linux PubBTQuant Installation Source: https://github.com/itsxactly/btquant/blob/1.5.0-RC2/installers/INSTALL.md Clean up a PubBTQuant installation on Linux by removing the application directory and its desktop entry. This is a manual uninstallation process. ```bash rm -rf ~/.pubbtquant rm ~/.local/share/applications/pubbtquant.desktop ``` -------------------------------- ### btq CLI Backtest Command Source: https://github.com/itsxactly/btquant/blob/1.5.0-RC2/docs/technical/configuration.md Example of using the `btq` command-line interface to run a backtest with various parameters such as coin, strategy, date range, and trading settings. ```bash btq backtest \ --coin BTC \ --strategy SuperTrend_Scalp \ --interval 15m \ --start 2024-01-01 \ --end 2025-01-01 \ --cash 10000 \ --commission 0.001 \ --leverage 5 \ --take-profit 2.0 \ --stop-loss 1.0 \ --plot \ --quantstats ``` -------------------------------- ### Load and Save HotSpine Configuration Source: https://github.com/itsxactly/btquant/blob/1.5.0-RC2/docs/technical/configuration.md Demonstrates how to load configuration from a JSON file and save the current configuration to a file using the HotSpine library. Also shows how to get default configurations and set up logging. ```python from backtrader.hotspine.config import ( HotSpineConfig, load_config_from_file, save_config_to_file, get_default_config, configure_logging ) # Get default config config = get_default_config() # Load from JSON file config = load_config_from_file("/path/to/hotspine_config.json") # Save to JSON file save_config_to_file(config, "/path/to/hotspine_config.json") # Configure logging configure_logging(level=logging.DEBUG, log_file="/var/log/hotspine.log") ``` -------------------------------- ### Start a BTQuant Bot with Memory Restart Limit Source: https://github.com/itsxactly/btquant/wiki/5. Pm2 Starts a Python script with PM2, setting a maximum memory limit (550MB) after which the process will automatically restart. ```bash pm2 start testing_ccxt.py --interpreter=python3 --name="mexc-ws" --max-memory-restart=550M ``` -------------------------------- ### Live Trading CCXT Setup (Python) Source: https://github.com/itsxactly/btquant/blob/1.5.0-RC2/docs/technical/architecture.md Function to initiate live trading using CCXT for a specified coin, collateral, exchange, account, asset, and strategy. Configuration can be optionally provided. ```python def livetrade_ccxt( coin: str, collateral: str, exchange: str, account: str, asset: str, strategy_class: str, config: Optional[Dict[str, Any]] = None, ) -> None: ... ``` -------------------------------- ### List Available BTQuant Strategies (CLI) Source: https://github.com/itsxactly/btquant/blob/1.5.0-RC2/docs/faq.md List all available trading strategies that can be used with BTQuant via the command-line interface. This helps in selecting a strategy for backtesting. ```bash btq list strategies ``` -------------------------------- ### Run a Simple BTQuant Backtest Source: https://github.com/itsxactly/btquant/blob/1.5.0-RC2/docs/installation.md Execute a basic backtest for a specified coin and strategy. Ensure your data source is configured before running. ```bash btq backtest --coin BTC --strategy VuManchCipher_A --interval 15m --start 2024-01-01 --end 2024-01-08 ``` -------------------------------- ### Market Depth Output Example Source: https://github.com/itsxactly/btquant/blob/1.5.0-RC2/dependencies/ccapi/README.md This console output shows an example of the market depth data received, including best bid and ask prices and sizes. This format is typical for 'MARKET_DEPTH' subscriptions. ```console Best bid and ask at 2020-07-27T23:56:51.884855000Z are: {BID_PRICE=10995, BID_SIZE=0.22187803} {ASK_PRICE=10995.44, ASK_SIZE=2} Best bid and ask at 2020-07-27T23:56:51.935993000Z are: ... ``` -------------------------------- ### HotSpineReader Dynamic Configuration (C++) Source: https://github.com/itsxactly/btquant/blob/1.5.0-RC2/tests/new/ARCHITECTURE.md Demonstrates setting up and attaching the HotSpineReader with dynamic configuration parameters. This allows for runtime adjustment of shared memory paths, buffer sizes, and polling intervals. ```cpp HotSpineReader::Config config; config.sharedMemoryPath = "/btquant_hotspine"; config.bufferSize = 65536; config.pollIntervalMs = 1000; config.batchSize = 100; HotSpineReader reader(config); reader.attach(); // Dynamic attachment to shared memory ``` -------------------------------- ### Prepare Build Directory Source: https://github.com/itsxactly/btquant/blob/1.5.0-RC2/dependencies/datacollector/Howto_CCAPI.md Navigate into the cloned ccapi directory and create a build directory. If you are rebuilding from scratch, remove all existing contents of the build directory first. ```bash cd ccapi mkdir example/build cd example/build rm -rf * (if rebuild from scratch) ``` -------------------------------- ### CCXT Environment Variable Configuration Example Source: https://github.com/itsxactly/btquant/blob/1.5.0-RC2/docs/technical/configuration.md Example of setting CCXT exchange configuration using environment variables. These variables follow the pattern `BTQ_{EXCHANGE}_{ACCOUNT}_...` and override file-based configurations. Ensure variables are exported before running the application. ```bash export BTQ_BINANCE_MAIN_API_KEY="your-api-key" export BTQ_BINANCE_MAIN_API_SECRET="your-secret" ``` -------------------------------- ### ReadOnlyTradesAgg.get_ticks_by_id Source: https://github.com/itsxactly/btquant/blob/1.5.0-RC2/docs/technical/bigbraincentral.md Retrieves tick-level trade data starting from a specific trade ID. ```APIDOC ## ReadOnlyTradesAgg.get_ticks_by_id ### Description Retrieves tick-level trade data, formatted as OHLCV, starting from a specified trade ID. ### Method `ReadOnlyTradesAgg.get_ticks_by_id(exchange: str, symbol: str, last_id: int, limit: int = 1000)` ### Parameters #### Path Parameters - **exchange** (str) - The exchange name. - **symbol** (str) - The trading symbol (e.g., BTCUSDT). - **last_id** (int) - The ID of the last trade received. Data will be fetched starting from the next ID. - **limit** (int, optional) - The maximum number of trade ticks to return. Defaults to 1000. ``` -------------------------------- ### Run a Backtest with Python and CLI Source: https://github.com/itsxactly/btquant/blob/1.5.0-RC2/docs/faq.md Initiate a backtest for a specified strategy and coin. Ensure your strategy class is correctly defined and accessible. ```python from backtrader.utils.backtest import backtest result = backtest(MyStrategy, coin='BTC', start_date='2024-01-01', end_date='2024-01-31', interval='1h', init_cash=1000) ``` ```bash btq backtest --coin BTC --strategy MyStrategy --interval 1h --start 2024-01-01 --end 2024-01-31 ``` -------------------------------- ### Troubleshoot SQL Server Service Startup Source: https://github.com/itsxactly/btquant/wiki/6.1-[OBSOLETE]Installing-Microsoft-SQL Use these commands to check SQL Server logs and validate its configuration when the service fails to start. This helps diagnose issues preventing the SQL Server from running. ```bash sudo journalctl -u mssql-server -f ``` ```bash sudo /opt/mssql/bin/mssql-conf validate ``` -------------------------------- ### Run BTQuant Monitors Source: https://github.com/itsxactly/btquant/blob/1.5.0-RC2/tests/new/QUICKSTART.md Execute the compiled BTQuant monitor binaries from the build directory. Options include a full monitor, a simple stop hunt monitor, and a multi-exchange price comparison tool. ```bash cd build # Full monitor with all detectors ./manipulation_monitor # Simple stop hunt monitor ./simple_monitor # Multi-exchange price comparison ./multi_exchange_monitor ``` -------------------------------- ### JRR Close Request Payload Source: https://github.com/itsxactly/btquant/blob/1.5.0-RC2/docs/technical/api-reference.md Example JSON payload for a JRR close order request. ```json { "Exchange": "mimic", "Market": "spot", "Account": "default", "Action": "Close", "Asset": "BTC/USDT", "Identity": "your-identity" } ``` -------------------------------- ### Run Unit Tests Source: https://github.com/itsxactly/btquant/blob/1.5.0-RC2/tests/new/ARCHITECTURE.md Navigate to the `tests/new` directory and build and run the unit tests using CMake. ```bash cd tests/new cmake --build build --target unit_tests ./build/unit_tests ``` -------------------------------- ### JRR Buy Request Payload Source: https://github.com/itsxactly/btquant/blob/1.5.0-RC2/docs/technical/api-reference.md Example JSON payload for a JRR buy order request. ```json { "Exchange": "mimic", "Market": "spot", "Account": "default", "Action": "Buy", "Asset": "BTC/USDT", "USD": "100.0", "Identity": "your-identity" } ``` -------------------------------- ### Launch Azure Data Studio Source: https://github.com/itsxactly/btquant/wiki/6.1-[OBSOLETE]Installing-Microsoft-SQL Launches the Azure Data Studio application from the command line. ```bash azuredatastudio ``` -------------------------------- ### Live Feed from MSSQL Database Source: https://github.com/itsxactly/btquant/blob/1.5.0-RC2/docs/technical/bigbraincentral.md Set up a live data feed using BinanceDBData from an MSSQL database for real-time backtesting. Requires correct database configuration and strategy definition. ```python import backtrader as bt from backtrader.feeds.db_ohlcv_mssql import BinanceDBData, MSSQLFeedConfig from datetime import datetime config = MSSQLFeedConfig( server="localhost", database="BTQ_MarketData", username="SA", password="YourPassword" ) cerebro = bt.Cerebro() data = BinanceDBData( db_config=config, symbol="BTC-USDT", timeframe=bt.TimeFrame.Minutes, compression=1, fromdate=datetime(2024, 1, 1), live=True, ticks=True ) cerebro.adddata(data) cerebro.addstrategy(MyStrategy) cerebro.run() ```