### Start Trading Bot Process Source: https://github.com/banbox/bandoc/blob/master/en-US/guide/live_trading.md Execute this command to start the real-time trading bot in the background. A configuration file is specified, and logs are redirected. ```shell nohup /ban/bot trade -config @demo.yml > /tmp/trade.log 2>&1 & ``` -------------------------------- ### Start WebUI Source: https://github.com/banbox/bandoc/blob/master/en-US/guide/quick_local.md Execute `bot.exe` in the strategy project to start the WebUI and automatically open the browser. The WebUI can also be accessed at `http://127.0.0.1:8000/en-US`. ```bash bot.exe ``` -------------------------------- ### Trading Configuration Example Source: https://github.com/banbox/bandoc/blob/master/en-US/guide/bot_usage.md Example of enabling the API server for the trading robot in the yml configuration file. ```yaml api_server: enable: true # enable here bind_ip: 0.0.0.0 port: 8001 jwt_secret_key: '123456789' # This should be complicated enough users: - user: ban pwd: '123' acc_roles: {user1: admin} # allow bot accounts and role ``` -------------------------------- ### Setup Source: https://github.com/banbox/bandoc/blob/master/en-US/api/goods.md Initializes the goods package configuration, primarily for setting up trading pair filters. ```APIDOC ## Setup ### Description Initializes the goods package configuration. Mainly used for setting up trading pair filters. ### Returns - `*errs.Error` - Error information during initialization, returns nil if successful ``` -------------------------------- ### Setup Source: https://github.com/banbox/bandoc/blob/master/en-US/api/core.md Initializes the system's core components. It returns an error if any issues occur during initialization. ```APIDOC ## Setup ### Description Initialize system core components. ### Returns - `*errs.Error` - Error information during initialization, returns nil if successful ``` -------------------------------- ### Complete YAML Configuration Example Source: https://github.com/banbox/bandoc/blob/master/en-US/guide/configuration.md This snippet shows a comprehensive example of a YAML configuration file for a trading bot. It includes settings for bot name, environment, leverage, order book parameters, market and contract types, order details, risk management, backtesting, and strategy execution. ```yaml name: local # Bot name, used to distinguish different bots in message notifications env: prod # Running environment, prod represents production network, test represents test network (Binance testnet), dry_run represents simulation leverage: 2 # Leverage ratio, only valid in the futures market limit_vol_secs: 5 # The expiration time for the order book price based on trading volume, in seconds, default is 10 put_limit_secs: 120 # Limit order submission time to the exchange within which it is expected to be filled, in seconds, default is 120 account_pull_secs: 60 # The interval in seconds for regularly updating account balance and positions, default is 60 seconds. market_type: spot # Market type: spot for spot trading, linear for USDT-margined contracts, inverse for coin-margined contracts, option for options contracts contract_type: swap # swap for perpetual contracts, future for expiring contracts odbook_ttl: 1000 # Order book expiration time, in milliseconds, default is 500 concur_num: 2 # Concurrent number of symbol candle downloads, default is 2 symbols order_type: market # Order type: market for market orders, limit for limit orders stop_enter_bars: 20 # Cancel the limit entry order if it is not filled within this many candles, default is 0 (disabled) prefire: 0 # Whether to trigger 10% ahead of the bar’s completion time margin_add_rate: 0.66 # For futures contracts, add margin when the loss reaches this ratio of the initial margin to avoid liquidation, default is 0.66 stake_amount: 15 # Default amount per order, lower priority than stake_pct stake_pct: 50 # Percentage of account to use for each order, based on the nominal value max_stake_amt: 5000 # Max order amount of 5k, valid only if stake_pct is specified draw_balance_over: 0 # When the balance exceeds this value, the excess amount will be automatically withdrawn and will not be used for subsequent transactions. It is only used for backtesting. charge_on_bomb: false # Automatically recharge to continue backtesting when backtesting liquidation occurs take_over_strat: ma:demo # The strategy for taking over user orders during real trading, empty by default close_on_stuck: 20 # If no K-line is received within 20 minutes, all positions will be closed. The default value is 20. (Only valid for live trading) open_vol_rate: 1 # Maximum allowed open order quantity / average candle volume ratio when not specifying order quantity, default is 1 min_open_rate: 0.5 # Minimum open order ratio, allows order if balance / per order amount exceeds this ratio when balance is insufficient, default is 0.5 (50%) low_cost_action: ignore # Action when stake amount < the minimum amount: ignore/keepBig/keepAll max_simul_open: 0 # Maximum number of simultaneously open orders on one candlestick bt_net_cost: 15 # Order delay in backtest, can be used to simulate slippage, in seconds, default is 15 relay_sim_unfinish: false # When trading a new symbol (backtesting/live trading), whether to trading from the open order relay at the beginning time order_bar_max: 500 # Find the maximum number of bars for forward simulation from the open orders at the start time. ntp_lang_code: none # NTP (Network Time Protocol) real-time synchronization. The default is `none`(disabled). Supported codes: zh-CN, zh-HK, zh-TW, ja-JP, ko-KR, zh-SG, and global (indicating global NTP servers such as Google, Apple, Facebook, etc.). wallet_amounts: # Wallet balance, used for backtesting USDT: 10000 stake_currency: [USDT, TUSD] # Limit trading pairs to those priced in these currencies fatal_stop: # Global stop loss, forbids order placement when total loss reaches these limits '1440': 0.1 # 10% loss in a day '180': 0.2 # 20% loss in 3 hours '30': 0.3 # 30% loss in half an hour fatal_stop_hours: 8 # Prohibits order placement for this many hours when global stop loss is triggered; default is 8 time_start: "20230701" # K-line start time, supports timestamp, date, date-time, etc., used for backtesting, data export, etc. time_end: "20230808" run_timeframes: [5m] # All allowed timeframes for the bot. The strategy will choose the most suitable minimum timeframe; this setting is lower priority than run_policy run_policy: # The strategy to run, multiple strategies can run simultaneously or a strategy can be run with different parameters - name: Demo # Strategy name run_timeframes: [5m] # Timeframes supported by this strategy, overrides the root run_timeframes when provided refine_tf: 1m # Matching period, a string or a number, where a number represents a reduction factor relative to timeframes: '1m', '5m', '3-6', 5 filters: # All filters from pairlists can be used - name: OffsetFilter # Offset limit filter, typically used last offset: 10 # Start from the 10th item ``` -------------------------------- ### Example Strategy Configuration Source: https://github.com/banbox/bandoc/blob/master/en-US/guide/roll_btopt.md This snippet shows a Freqtrade strategy configuration with specific parameters and run timeframes. It's an example of a strategy that might be used in conjunction with optimization. ```yaml - name: freqtrade:Strategy001 run_timeframes: [ 5m ] params: {bigRate: 2.61, lenSml: 27.93, midRate: 3.90} ``` -------------------------------- ### Start Data Server Source: https://github.com/banbox/bandoc/blob/master/en-US/guide/bot_usage.md Starts a gRPC server to provide data and metric results to clients in other languages, useful for AI and machine learning. ```text banbot tool: data_server: serve a grpc server as data feeder ``` -------------------------------- ### Start WebUI Source: https://github.com/banbox/bandoc/blob/master/en-US/guide/bot_usage.md Directly execute the bot to start the WebUI interface for managing strategies, backtesting, and analyzing transactions. The UI is accessible at http://localhost:8000. ```shell bot ``` -------------------------------- ### API Server Configuration Example Source: https://github.com/banbox/bandoc/blob/master/en-US/guide/strat_custom.md Example YAML configuration for enabling and securing the API server, which allows external control of trading strategies via HTTP POST requests. ```yaml api_server: # For controlling the robot through the api from an external source enable: true bind_ip: 0.0.0.0 port: 8001 users: - user: api pwd: very_strong_password allow_ips: [] acc_roles: user1: admin ``` -------------------------------- ### Example Optimization Log Header Source: https://github.com/banbox/bandoc/blob/master/en-US/guide/roll_btopt.md This is an example of a log header from a hyperparameter optimization run, indicating the optimization method and the number of rounds. ```text # run hyper optimize: bayes, rounds: 20 ``` -------------------------------- ### Start Spider Process Source: https://github.com/banbox/bandoc/blob/master/en-US/guide/live_trading.md Execute this command to start the spider process in the background. Logs are redirected to a file for monitoring. ```shell nohup /ban/bot spider > /tmp/spider.log 2>&1 & ``` -------------------------------- ### Example Banbot Configuration Source: https://github.com/banbox/bandoc/blob/master/en-US/guide/quick_local.md This YAML snippet shows an example configuration for 'config.local.yml', detailing parameters like stake amount, wallet balances, timeframes, trading pairs, and exchange API keys. ```yaml stake_amount: 100 wallet_amounts: USDT: 1000 time_start: "20240701" time_end: "20250701" pairs: ['ETH'] run_policy: - name: ma:demo run_timeframes: [15m] accounts: user1: binance: # or okx/bybit prod: api_key: vvv api_secret: vvv ``` -------------------------------- ### Start Real-Time Trading Source: https://github.com/banbox/bandoc/blob/master/en-US/guide/bot_usage.md Initiates real-time trading. Use with `-spider` to start the crawler or configure `api_server` in yml for Dashboard UI management. ```shell bot trade [-spider] [-pairs PAIRS] ... ``` -------------------------------- ### Compile and Run WebUI Source: https://github.com/banbox/bandoc/blob/master/en-US/guide/backtest.md Compile your Go project into an executable and start the WebUI to perform backtesting research. ```bash go build -o bot ./bot web ``` -------------------------------- ### Export Candlesticks Configuration Example (protobuf) Source: https://github.com/banbox/bandoc/blob/master/en-US/advanced/kline_tools.md Example YAML configuration for exporting candlestick data. Specifies exchange, market, timeframes, time range, and symbols. 'time_range' is mandatory. ```yaml klines: - exchange: 'binance' market: 'linear' timeframes: ['15m', '1h', '1d'] time_range: '20210101-20250101' symbols: [] # - exchange: 'binance' # market: 'spot' # timeframes: ['1h', '1d'] # time_range: '20240101-20250101' # symbols: [] ``` -------------------------------- ### SetupComs Source: https://github.com/banbox/bandoc/blob/master/en-US/api/biz.md Initializes basic components required for the system, including configuration, logging, and core modules. This is a fundamental setup function typically called during system startup. ```APIDOC ## SetupComs ### Description Initialize basic components. ### Method Not specified (assumed to be a function call within the Go SDK) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Parameters - **args** (*config.CmdArgs) - Command line arguments ### Returns - **`*errs.Error`** - Error information ### Implementation Details - Set error printing function - Create context and cancellation function - Initialize data directory - Load configuration file - Set up logging system - Initialize core components, exchanges, ORM, and goods modules - Mainly used for basic infrastructure initialization during system startup ``` -------------------------------- ### Setup Source: https://github.com/banbox/bandoc/blob/master/en-US/api/exg.md Initializes exchange settings. This function is crucial for preparing the exchange interface for subsequent operations. ```APIDOC ## Setup ### Description Initialize exchange settings. ### Returns - `*errs.Error` - Returns error information if initialization fails, nil otherwise ``` -------------------------------- ### StartApi Source: https://github.com/banbox/bandoc/blob/master/en-US/api/live.md Start API server. This method initiates the API server and returns an error if the startup process fails. ```APIDOC ## StartApi ### Description Start API server. This method initiates the API server and returns an error if the startup process fails. ### Returns - `*errs.Error` - Returns error information if startup fails ``` -------------------------------- ### Start Backtesting Source: https://github.com/banbox/bandoc/blob/master/en-US/guide/bot_usage.md Initiates backtesting. Use `-nodb` to avoid saving orders to the database and `-separate` to run strategy groups individually. ```shell bot backtest [-nodb] [-separate] ... ``` -------------------------------- ### HTTP POST Request Example Source: https://github.com/banbox/bandoc/blob/master/en-US/guide/strat_custom.md Example JSON payload for making an HTTP POST request to the strategy API server to trigger specific actions within a strategy. ```json { "token": "very_strong_password", // This is the password in the api_server "strategy": "ma:postApi", // This is the name of the requested strategy // The first two are fixed and required. The following fields are optional, and you can parse them in the strategy by yourself. "action": "openLong", "data1": 123, // Other arbitrary data to be sent to the strategy "data2": "hello" } ``` -------------------------------- ### SetupComsExg Source: https://github.com/banbox/bandoc/blob/master/en-US/api/biz.md Initializes exchange-related components, building upon the basic setup provided by `SetupComs`. This is used when exchange-specific functionality is required. ```APIDOC ## SetupComsExg ### Description Initialize exchange-related basic components. ### Method Not specified (assumed to be a function call within the Go SDK) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Parameters - **args** (*config.CmdArgs) - Command line arguments ### Returns - **`*errs.Error`** - Error information ### Implementation Details - Call `SetupComs` to complete basic initialization - Initialize exchange ORM module - Mainly used for initialization when exchange functionality is needed ``` -------------------------------- ### StartApi Source: https://github.com/banbox/bandoc/blob/master/en-US/api/web.md Starts the Web monitoring panel for real-time trading, providing monitoring and management functionality. ```APIDOC ## StartApi ### Description Start the Web monitoring panel for real-time trading. This method is used to start a Web server that provides monitoring and management functionality for real-time trading data. ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Method Not specified (likely a function call within the SDK) ### Endpoint Not applicable (SDK function) ### Request Example ```go // Example of calling StartApi function err := web.StartApi() if err != nil { // Handle error } ``` ### Response #### Success Response Returns nil if startup is successful. #### Error Response - `*errs.Error` - Returns a custom error type if an error occurs during startup. ``` -------------------------------- ### Open Order with Stop and Limit Prices Source: https://github.com/banbox/bandoc/blob/master/en-US/guide/strat_custom.md Configures an entry order with both a stop trigger price and a limit entry price. This example demonstrates entering a long position. ```go err := strat.OpenOrder(&strat.EnterReq{ Tag: "My second entry signal", Stop: 120, Limit: 122, }) ``` -------------------------------- ### StartLiveOdMgr Source: https://github.com/banbox/bandoc/blob/master/en-US/api/biz.md Starts the live order manager. This function initiates the operation of the live order management system. ```APIDOC ## StartLiveOdMgr ### Description Starts the live order manager. This function initiates the operation of the live order management system. ``` -------------------------------- ### Running Hyperparameter Optimization Source: https://github.com/banbox/bandoc/blob/master/en-US/guide/hyperopt.md Use the 'optimize' command to start hyperparameter tuning. Specify an output file, the number of optimization rounds, and the sampling method. The '-nodb' parameter is fixed during tuning. ```shell bot optimize -out PATH [-opt-rounds 30] [-sampler bayes] ``` -------------------------------- ### Defining Strategy Function with Parameters Source: https://github.com/banbox/bandoc/blob/master/en-US/guide/strat_custom.md Implement a strategy function that accepts a RunPolicyConfig and returns a TradeStrat. This example demonstrates how to retrieve parameters using Param and define hyperparameters using Def with different distribution types (PNorm, PNormF, PUniform). ```go func Demo(pol *config.RunPolicyConfig) *strat.TradeStrat { atrLen := pol.Param("atrLen", 9) atrLen1 := pol.Def("atrLen1", 9, core.PNorm(3, 20)) atrLen2 := pol.Def("atrLen2", 9, core.PNormF(3, 20, 12, 1)) atrLen3 := pol.Def("atrLen3", 9, core.PUniform(3, 20)) other1 := pol.More["other1"].(string) other2 := pol.More["other2"].(int) other3 := pol.More["other3"].(float64) return &strat.TradeStrat{ // more } } ``` -------------------------------- ### Start Crawler Process Source: https://github.com/banbox/bandoc/blob/master/en-US/guide/bot_usage.md Initiate the crawler process, which is necessary for real-time trading. It listens on port 6789 by default and accepts local requests. ```shell bot spider [-datadir PATH] [-c PATH] [-c PATH] ``` -------------------------------- ### RunSpider Source: https://github.com/banbox/bandoc/blob/master/en-US/api/data.md Starts the data spider service, listening on a specified network address. ```APIDOC ## RunSpider ### Description Run data spider service. ### Parameters - `addr string` - Service listening address ### Returns - `*errs.Error` - Error information ``` -------------------------------- ### StartApi Source: https://github.com/banbox/bandoc/blob/master/zh-CN/api/live.md Starts the API server. This function is crucial for enabling external access to the trading system's functionalities via a web interface. ```APIDOC ## StartApi ### Description Starts the API server. This function is crucial for enabling external access to the trading system's functionalities via a web interface. ### Method POST ### Endpoint /api/live/start ### Response #### Success Response (200) - **message** (string) - Indicates successful API server startup. #### Response Example ```json { "message": "API server started successfully" } ``` ``` -------------------------------- ### Strategy Job Configuration Example Source: https://github.com/banbox/bandoc/blob/master/en-US/guide/basic.md This YAML configuration defines multiple groups of strategy jobs using the 'ma:demo' strategy. Each group specifies run timeframes, direction (dirt), parameters, and trading pairs. Note that overlapping pairs might be ignored based on priority. ```yaml run_policy: - name: ma:demo run_timeframes: [5m] dirt: long params: {smlLen: 5, bigLen: 20} pairs: [BTC/USDT, ETH/USDT] - name: ma:demo run_timeframes: [5m, 15m] dirt: short params: {smlLen: 7, bigLen: 30} pairs: [BTC/USDT, ETH/USDT] - name: ma:demo run_timeframes: [15m] dirt: long params: {smlLen: 4, bigLen: 15} pairs: [BCH/USDT, ETC/USDT, BTC/USDT] - name: ma:demo run_timeframes: [5m] dirt: long params: {smlLen: 5, bigLen: 20} pairs: [BCH/USDT, ETC/USDT] ``` -------------------------------- ### RunDev Source: https://github.com/banbox/bandoc/blob/master/en-US/api/web.md Starts the Web UI robot control panel in the development environment for robot management and monitoring. ```APIDOC ## RunDev ### Description Run the Web UI robot control panel. This method is used to start the Web interface in the development environment for robot management and monitoring. ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Method Not specified (likely a function call within the SDK) ### Endpoint Not applicable (SDK function) ### Request Example ```go // Example of calling RunDev function // Assuming 'args' is a slice of strings representing command-line arguments err := web.RunDev(args) if err != nil { // Handle error } ``` ### Response #### Success Response Returns nil if startup is successful. #### Error Response - `error` - Returns corresponding error information if an error occurs during startup. ``` -------------------------------- ### Interpreting Hyperparameter Optimization Results Source: https://github.com/banbox/bandoc/blob/master/en-US/guide/hyperopt.md Example log output from hyperparameter optimization, showing strategy performance metrics like loss, profit, drawdown, and Sharpe ratio for different parameter sets. ```text # run hyper optimize: bayes, rounds: 20 # date range: 2021-01-01 00:00:00 - 2021-12-27 00:00:00 ============== freqtrade:Strategy001/5m/ ============= loss: -81.15 bigRate: 2.02, lenSml: 19.49, midRate: 2.38 odNum: 195, profit: 109.7%, drawDown: 18.2%, sharpe: 6.89 loss: -86.14 bigRate: 2.00, lenSml: 20.71, midRate: 3.72 odNum: 292, profit: 107.8%, drawDown: 13.9%, sharpe: 7.69 loss: -118.02 bigRate: 2.15, lenSml: 20.92, midRate: 2.71 odNum: 210, profit: 167.9%, drawDown: 20.9%, sharpe: 7.49 loss: -72.20 bigRate: 1.90, lenSml: 20.89, midRate: 2.52 odNum: 220, profit: 100.6%, drawDown: 19.8%, sharpe: 6.73 loss: -80.40 bigRate: 2.17, lenSml: 22.64, midRate: 1.96 odNum: 148, profit: 115.2%, drawDown: 21.3%, sharpe: 6.66 loss: -90.39 bigRate: 1.88, lenSml: 23.61, midRate: 2.79 odNum: 183, profit: 164.5%, drawDown: 32.9%, sharpe: 5.15 loss: -93.75 bigRate: 1.84, lenSml: 16.12, midRate: 2.43 odNum: 247, profit: 126.3%, drawDown: 18.0%, sharpe: 7.04 loss: -72.83 bigRate: 1.98, lenSml: 19.76, midRate: 3.77 odNum: 293, profit: 91.1%, drawDown: 13.9%, sharpe: 6.80 loss: -71.02 bigRate: 1.93, lenSml: 19.75, midRate: 3.89 odNum: 304, profit: 97.6%, drawDown: 19.1%, sharpe: 6.64 loss: -140.38 bigRate: 2.61, lenSml: 27.93, midRate: 3.90 odNum: 192, profit: 191.3%, drawDown: 18.6%, sharpe: 8.48 loss: -95.02 bigRate: 2.88, lenSml: 23.35, midRate: 2.77 odNum: 192, profit: 165.0%, drawDown: 30.8%, sharpe: 8.92 loss: -78.63 bigRate: 2.02, lenSml: 29.28, midRate: 3.28 odNum: 212, profit: 109.3%, drawDown: 19.7%, sharpe: 6.81 loss: -81.46 bigRate: 2.69, lenSml: 21.28, midRate: 3.71 odNum: 258, profit: 109.1%, drawDown: 17.7%, sharpe: 7.20 ``` -------------------------------- ### Initialize New Project and Add Banbot Dependency Source: https://github.com/banbox/bandoc/blob/master/en-US/guide/init_project.md Create a new project directory, navigate into it, initialize Go modules, and add the Banbot dependency. ```shell # mystrats is the project name and can be changed freely mkdir mystrats cd mystrats go mod init mystrats go get github.com/banbox/banbot ``` -------------------------------- ### Install mailx on CentOS 8 Source: https://github.com/banbox/bandoc/blob/master/en-US/guide/live_trading.md Install the mailx package on CentOS 8 systems to enable email sending capabilities for monitoring. ```shell dnf install mailx ``` -------------------------------- ### Build Bot Documentation Source: https://github.com/banbox/bandoc/blob/master/README.md Run this command to compile the bot documentation. ```shell npm run build ``` -------------------------------- ### Configure Main Entry File for Banbot Application Source: https://github.com/banbox/bandoc/blob/master/en-US/guide/init_project.md Sets up the main entry point for the Banbot application, importing the strategy package to make it available for execution. ```go package main import ( "github.com/banbox/banbot/entry" _ "mystrats/ma" ) func main() { entry.RunCmd() } ``` -------------------------------- ### Upgrade Banbot with Local Installation Source: https://github.com/banbox/bandoc/blob/master/en-US/guide/faq.md Update the version in your go.mod file and run go mod tidy to apply changes for local installations. ```go go mod tidy ``` -------------------------------- ### GetNetLock Source: https://github.com/banbox/bandoc/blob/master/en-US/api/utils.md Get a distributed lock with a specified timeout. ```APIDOC ## GetNetLock ### Description Get distributed lock. ### Parameters #### Path Parameters - `key string` (string) - Required - Lock key name - `timeout int` (integer) - Required - Lock acquisition timeout (seconds) ### Returns #### Success Response - `int32` (integer) - Lock value (used for unlocking) - `*errs.Error` (object) - Error information ``` -------------------------------- ### Initialize Configuration Files Source: https://github.com/banbox/bandoc/blob/master/en-US/guide/quick_local.md Execute this command in your strategy project to automatically generate the 'config.yml' and 'config.local.yml' files within the directory specified by BanDataDir. ```shell bot.exe init ``` -------------------------------- ### GetSystemLanguage Source: https://github.com/banbox/bandoc/blob/master/en-US/api/utils.md Get the system's current language setting. ```APIDOC ## GetSystemLanguage ### Description Get system language setting. ### Returns #### Success Response - `string` (string) - System language code ``` -------------------------------- ### GetServerData Source: https://github.com/banbox/bandoc/blob/master/en-US/api/utils.md Get data from BanServer or BanClient using a key. ```APIDOC ## GetServerData ### Description Get data from BanServer or BanClient. ### Parameters #### Path Parameters - `key string` (string) - Required - Data key name ### Returns #### Success Response - `string` (string) - Retrieved data value - `*errs.Error` (object) - Error information ``` -------------------------------- ### ParseTimeRange Source: https://github.com/banbox/bandoc/blob/master/en-US/api/config.md Parses a time range string into start and end timestamps. ```APIDOC ## ParseTimeRange ### Description Parse time range string. ### Parameters - `timeRange`: string - Time range string in format "YYYYMMDD-YYYYMMDD" ### Returns - `int64` - Start timestamp (milliseconds) - `int64` - End timestamp (milliseconds) - `error` - Error information ``` -------------------------------- ### UniqueItems Source: https://github.com/banbox/bandoc/blob/master/en-US/api/utils.md Get unique elements and duplicate elements from an array. Supports generics. ```APIDOC ## UniqueItems ### Description Get unique elements and duplicate elements from an array. Supports generics. ### Parameters #### Path Parameters - `arr []T` (array) - Required - Input array, supports generics ### Returns #### Success Response - `[]T` (array) - Array of unique elements - `[]T` (array) - Array of duplicate elements ``` -------------------------------- ### NewClientIO Source: https://github.com/banbox/bandoc/blob/master/en-US/api/utils.md Create a new BanClient instance to connect to BanServer. ```APIDOC ## NewClientIO ### Description Create a new BanClient instance to connect to BanServer. ### Parameters #### Path Parameters - `addr string` (string) - Required - Server address (e.g., "127.0.0.1:6789") ### Returns #### Success Response - `*ClientIO` (object) - Client instance - `*errs.Error` (object) - Error information ``` -------------------------------- ### GetTakeOverTF Source: https://github.com/banbox/bandoc/blob/master/en-US/api/config.md Gets the takeover time frame for a specified trading pair, with a default fallback. ```APIDOC ## GetTakeOverTF ### Description Get takeover time frame for specified trading pair. ### Parameters - `pair`: string - Trading pair name - `defTF`: string - Default time frame ### Returns - `string` - Time frame ``` -------------------------------- ### Compile and Run Command Line Backtest Source: https://github.com/banbox/bandoc/blob/master/en-US/guide/backtest.md Compile your Go project and run the backtest command from the terminal. ```bash go build -o bot ./bot backtest ``` -------------------------------- ### Get Strategy Performance Configuration Source: https://github.com/banbox/bandoc/blob/master/en-US/api/strat.md Retrieves the performance configuration for a given strategy and trading pair. ```APIDOC ## GetStratPerf Get strategy performance configuration. ### Method [Method Signature] ### Parameters #### Path Parameters - **pair** (string) - Trading pair name - **strat** (string) - Strategy name ### Returns - **StratPerfConfig** (*config.StratPerfConfig) - Strategy performance configuration ``` -------------------------------- ### Compile Banbot Strategy Project (Windows) Source: https://github.com/banbox/bandoc/blob/master/en-US/guide/quick_local.md Use these commands to initialize project dependencies and compile the strategy and Banbot into a single executable file on Windows. ```shell # Initialize dependencies go mod tidy # Compile the strategy and banbot into a single executable file go build -o bot.exe ``` -------------------------------- ### Get Strategy Instance Source: https://github.com/banbox/bandoc/blob/master/en-US/api/strat.md Retrieves a strategy instance based on the trading pair and strategy ID. ```APIDOC ## Get Get strategy instance based on trading pair and strategy ID. ### Method [Method Signature] ### Parameters #### Path Parameters - **pair** (string) - Trading pair name - **stratID** (string) - Strategy ID ### Returns - **TradeStrat** (*TradeStrat) - Trading strategy instance, returns nil if not exists ``` -------------------------------- ### Compile Banbot Strategy Project (Linux/MacOS) Source: https://github.com/banbox/bandoc/blob/master/en-US/guide/quick_local.md Use these commands to initialize project dependencies and compile the strategy and Banbot into a single executable file on Linux or MacOS. ```shell # Initialize dependencies go mod tidy # Compile the strategy and banbot into a single executable file go build -o bot ``` -------------------------------- ### InitDataDir Source: https://github.com/banbox/bandoc/blob/master/en-US/api/biz.md Initializes the data directory for the system. ```APIDOC ## InitDataDir ### Description Initialize data directory. ### Method Not specified (assumed to be a function call within the Go SDK) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Returns - **`*errs.Error`** - Error information ``` -------------------------------- ### Display Bot Help Information Source: https://github.com/banbox/bandoc/blob/master/en-US/guide/bot_usage.md View a list of available subcommands and their descriptions by running the bot with the -help flag. ```text banbot 0.1.5 please run with a subcommand: trade: live trade backtest: backtest with strategies and data spider: start the spider optimize: run hyper parameters optimization bt_opt: backtest over optimize kline: run kline commands tick: run tick commands tool: run tools web: run web dashboard ``` -------------------------------- ### Get All Strategy Jobs Source: https://github.com/banbox/bandoc/blob/master/en-US/api/strat.md Retrieves all strategy jobs for a specified account, grouped by trading pair and strategy. ```APIDOC ## GetJobs Get all strategy jobs for the specified account. ### Method [Method Signature] ### Parameters #### Path Parameters - **account** (string) - Account name ### Returns - **map[string]map[string]*StratJob** - Job mapping grouped by trading pair and strategy ``` -------------------------------- ### Now Source: https://github.com/banbox/bandoc/blob/master/en-US/api/btime.md Gets the current UTC time. Returns real-time in live mode, backtest time in backtest mode. ```APIDOC ## Now ### Description Get current UTC time. Returns real-time in live mode, backtest time in backtest mode. ### Returns - `*time.Time` - Time object pointer ``` -------------------------------- ### Initializing StratJob.More in OnStartUp Source: https://github.com/banbox/bandoc/blob/master/en-US/guide/strat_custom.md Initialize `StratJob.More` in `OnStartUp` to save temporary variables or synchronize information between callback functions. This is crucial for relaying data from `OnInfoBar` to `OnBar`. ```go m, _ := s.More.(*Demo2Sta) ``` -------------------------------- ### Open Order with Default Parameters Source: https://github.com/banbox/bandoc/blob/master/en-US/guide/strat_custom.md Opens a long position using default order amount and leverage. No stop profit or stop loss is configured. ```go err := strat.OpenOrder(&strat.EnterReq{ Tag: "My first entry signal", }) ``` -------------------------------- ### RunDataServer Source: https://github.com/banbox/bandoc/blob/master/en-US/api/biz.md Runs the data server. This function initializes and starts the data server process, which is essential for data handling operations. ```APIDOC ## RunDataServer ### Description Runs the data server. This function initializes and starts the data server process, which is essential for data handling operations. ### Parameters - `args`: *config.CmdArgs - Command line arguments ### Returns - `*errs.Error` - Error information ``` -------------------------------- ### Get Information Strategy Jobs Source: https://github.com/banbox/bandoc/blob/master/en-US/api/strat.md Retrieves information about strategy jobs for a specified account, grouped by trading pair and strategy. ```APIDOC ## GetInfoJobs Get information strategy jobs for the specified account. ### Method [Method Signature] ### Parameters #### Path Parameters - **account** (string) - Account name ### Returns - **map[string]map[string]*StratJob** - Information job mapping grouped by trading pair and strategy ``` -------------------------------- ### Compile for Linux Source: https://github.com/banbox/bandoc/blob/master/en-US/guide/live_trading.md Set the GOARCH and GOOS environment variables for Linux and build the bot executable. ```shell export GOARCH="amd64" export GOOS="linux" go build -o bot ``` -------------------------------- ### Perpetual Contract Naming Source: https://github.com/banbox/bandoc/blob/master/en-US/guide/basic.md Examples of perpetual contract naming conventions, showing base currency, quote currency, and settlement currency. ```text // Base currency // // // Quote currency // // // Settlement currency // // // 'BTC/USDT:BTC' // BTC/USDT perpetual contract settled in BTC 'BTC/USDT:USDT' // BTC/USDT perpetual contract settled in USDT 'ETH/USDT:ETH' // ETH/USDT perpetual contract settled in ETH 'ETH/USDT:USDT' // ETH/USDT perpetual contract settled in USDT ``` -------------------------------- ### Running Rolling Optimization with 'goodAvg' Picker Source: https://github.com/banbox/bandoc/blob/master/en-US/guide/roll_btopt.md This command initiates a rolling optimization process using Freqtrade's 'bot bt_opt' command. It specifies a review period of 12 months, a run period of 2 months, 20 optimization rounds, and selects parameters using the 'goodAvg' method. ```shell bot bt_opt -review-period 12M -run-period 2M -opt-rounds 20 -picker goodAvg ``` -------------------------------- ### Delivery Contract Naming Source: https://github.com/banbox/bandoc/blob/master/en-US/guide/basic.md Examples of delivery contract naming conventions, including base currency, quote currency, settlement currency, and delivery date. ```text // Base currency // // // Quote currency // // // Settlement currency // // // // Identifier (delivery date) // // // // 'BTC/USDT:BTC-211225' // BTC/USDT inverse contract settled in BTC with delivery date 2021-12-25 'BTC/USDT:USDT-210625' // BTC/USDT linear contract settled in USDT with delivery date 2021-06-25 ``` -------------------------------- ### Compile for Windows (CMD) Source: https://github.com/banbox/bandoc/blob/master/en-US/guide/live_trading.md Use Windows Command Prompt to set environment variables for building Windows or Linux executables. ```shell # build for windows set GOARCH=amd64 set GOOS=windows go build -o bot.exe # build for linux set GOARCH=amd64 set GOOS=linux go build -o bot ``` -------------------------------- ### Telegram Custom Bot Setup Source: https://github.com/banbox/bandoc/blob/master/en-US/guide/live_trading.md Configure a custom Telegram bot with your own Bot Token and Chat ID. Supports proxy configuration for network-restricted environments. ```yaml rpc_channels: telegram_bot: type: telegram disable: false token: "123456789:ABCdefGHIjklMNOpqrsTUVwxyz" # Required: Bot Token chat_id: "987654321" # Required: Chat ID proxy: "http://127.0.0.1:7897" # Optional: Proxy address msg_types: [entry, exit, status, exception] min_intv_secs: 5 ``` -------------------------------- ### ExportAdjFactors Source: https://github.com/banbox/bandoc/blob/master/en-US/api/biz.md Exports price adjustment factor data, including start time and factor values, with support for timezone settings. This is used for financial data analysis. ```APIDOC ## ExportAdjFactors ### Description Exports price adjustment factor data, including start time and factor values, with support for timezone settings. This is used for financial data analysis. ### Parameters - `args`: *config.CmdArgs - Command line arguments ### Returns - `*errs.Error` - Error information ### Implementation Details - Export price adjustment factor data - Include start time, factor values, etc. - Support timezone settings ``` -------------------------------- ### Configure Environment Variables (Windows) Source: https://github.com/banbox/bandoc/blob/master/en-US/guide/quick_local.md Set the BanDataDir and BanStratDir environment variables for local Banbot operation on Windows. These paths specify directories for data and strategy files. ```text BanDataDir=E:\quant\bandata BanStratDir=E:\quant\banstrats ``` -------------------------------- ### Registering a Command Function with Raw Arguments Source: https://github.com/banbox/bandoc/blob/master/en-US/advanced/custom_cmd.md Use `RunRaw` instead of `Run` to manually parse command-line arguments as a slice of strings. This provides more flexibility for argument handling. ```go entry.AddCmdJob(&entry.CmdJob{ Name: "hello", Parent: "", RunRaw: func(args []string) error { fmt.Println(strings.Join(args, " ")) return nil }, Help: "show hello", }) ``` -------------------------------- ### Run Rolling Optimization Backtest Source: https://github.com/banbox/bandoc/blob/master/en-US/guide/roll_btopt.md Use this command to initiate a rolling optimization backtest. Specify the review period for optimization, the run period for backtesting, the number of optimization rounds, and the parameter picker strategy. ```shell bot bt_opt -review-period 12M -run-period 2M -opt-rounds 20 -picker score ``` -------------------------------- ### Options Contract Naming Source: https://github.com/banbox/bandoc/blob/master/en-US/guide/basic.md Examples of options contract naming conventions, including base currency, quote currency, settlement currency, delivery date, strike price, and type (put/call). ```text // Base currency // // // Quote currency // // // Settlement currency // // // // Identifier (delivery date) // // // // // Strike price // // // // // Type, put (P) or call (C) // // // // // 'BTC/USDT:BTC-211225-60000-P' // BTC/USDT inverse contract settled in BTC, with the right to sell at 60000 on 2021-12-25 'ETH/USDT:USDT-211225-40000-C' // BTC/USDT linear contract settled in USDT, with the right to buy at 40000 on 2021-12-25 'ETH/USDT:ETH-210625-5000-P' // ETH/USDT inverse contract settled in ETH, with the right to sell at 5000 on 2021-06-25 'ETH/USDT:USDT-210625-5000-C' // ETH/USDT linear contract settled in USDT, with the right to buy at 5000 on 2021-06-25 ``` -------------------------------- ### Configure Backtesting Parameters Source: https://github.com/banbox/bandoc/blob/master/en-US/guide/backtest.md Configure essential backtesting parameters in the config.local.yml file for command-line backtesting. ```yaml market_type: linear leverage: 10 time_start: "20251101" time_end: "20251112" stake_amount: 30 pairs: [BTC, ETH] stake_currency: [USDT] wallet_amounts: USDT: 1000 run_policy: - name: ma:demo run_timeframes: [1h] ``` -------------------------------- ### Optimize Command-Line Options Source: https://github.com/banbox/bandoc/blob/master/en-US/guide/hyperopt.md This lists the available command-line flags for the 'optimize' command, including concurrency, logging levels, data directories, and output/sampling configurations. ```text Usage of optimize: -concur int Concurrent Number (default 1) -config value config path to use, Multiple -config options may be used -datadir string Path to data dir. -each-pairs run for each pairs -level string set logging level to debug (default "info") -logfile string Log to the file specified -max-pool-size int max pool size for db -no-compress disable compress for hyper table -no-default ignore default: config.yml, config.local.yml -nodb dont save orders to database -opt-rounds int rounds num for single optimize job (default 30) -out string output file or directory -picker string Method for selecting targets from multiple hyperparameter optimization results (default "good3") -sampler string hyper optimize method, tpe/bayes/random/cmaes/ipop-cmaes/bipop-cmaes (default "bayes") ``` -------------------------------- ### Telegram Official Bot Setup Source: https://github.com/banbox/bandoc/blob/master/en-US/guide/live_trading.md Use banbot's official Telegram bot for simple configuration without needing a Bot Token. The bot automatically generates a secret for binding. ```yaml rpc_channels: telegram_bot: type: telegram disable: false secret: "" # Optional: custom UUID v4 format secret, auto-generated if empty msg_types: [entry, exit, status, exception] min_intv_secs: 5 ``` -------------------------------- ### WebUI Command Parameters Source: https://github.com/banbox/bandoc/blob/master/en-US/guide/bot_usage.md Usage details for the 'web' subcommand, including host binding, port, configuration paths, data directory, database file, log level, log file, and timezone. ```text Usage of web: -host string bind host ip (default "127.0.0.1") -port int port to listen (default 8000) -config value config path to use, Multiple -config options may be used -datadir string Path to data dir. -db string db file path (default "dev.db") -level string log level (default "info") -logfile string log file path, default: system temp dir -tz string timezone (default "utc") ``` -------------------------------- ### NewBanServer Source: https://github.com/banbox/bandoc/blob/master/en-US/api/utils.md Create a new BanServer instance for TCP network communication. ```APIDOC ## NewBanServer ### Description Create a new BanServer instance for TCP network communication. ### Parameters #### Path Parameters - `addr string` (string) - Required - Server listening address (e.g., "127.0.0.1:6789") - `name string` (string) - Required - Server name ### Returns #### Success Response - `*ServerIO` (object) - Server instance ``` -------------------------------- ### Custom Exit Logic Source: https://github.com/banbox/bandoc/blob/master/en-US/guide/strat_custom.md Implement custom exit logic for each open order on every candlestick. This example opens a long order if none exist and closes it with a 10% probability, or exits based on profit rate. ```go func CustomExitDemo(pol *config.RunPolicyConfig) *strat.TradeStrat { return &strat.TradeStrat{ OnBar: func(s *strat.StratJob) { if len(s.LongOrders) == 0 { s.OpenOrder(&strat.EnterReq{Tag: "long"}) } else if rand.Float64() < 0.1 { s.CloseOrders(&strat.ExitReq{Tag: "close"}) } }, OnCheckExit: func(s *strat.StratJob, od *ormo.InOutOrder) *strat.ExitReq { if od.ProfitRate > 0.1 { // Exit if profit exceeds 10% return &strat.ExitReq{Tag: "profit"} } return nil }, } } ```