TSLab
TSLab.proSupportTSLab LiveTSVerse
Eng
Eng
  • TSLab trading platform
  • For newbies
    • A beginner's guide
      • Purchasing a license key for a data provider
      • An example of connecting text quotes
      • Example of connecting a data provider to a broker / exchange
      • An example of creating a script in TSLab
      • An example of creating a trading algorithm in TSLab
  • Installing TSLab
    • TSLab Installation Guide
      • System requirements
      • TSLab Installation manual
    • Update TSLab
      • Preparing for update
      • Release build
      • Nightly build
    • Restarting the TSLab program
    • TSLab Changelog
      • TSLab 2.1 Changelog
      • TSLab 2.2 Changelog
        • 2.2.26.0 - 2024/01/31
        • 2.2.25.0 - 2024/01/17
        • 2.2.24.0 - 2024/12/04
        • 2.2.23.0 - 2024/09/19
        • 2.2.22.0 - 2024/08/30
        • 2.2.21.0 - 2024/05/17
        • 2.2.20.0 - 2024/05/15
        • 2.2.19.0 - 2024/02/21
        • 2.2.18.0 - 2024/02/09
        • 2.2.17.0 - 2023/11/16
        • 2.2.16.0 - 2023/10/20
        • 2.2.15.0 - 2023/10/13
        • 2.2.14.0 - 2023/08/11
        • 2.2.13.0 - 2023/05/12
        • 2.2.12.0 - 2023/02/28
        • 2.2.11.0 - 2022/12/15
        • 2.2.10.0 - 2022/10/27
        • 2.2.9.0 - 2022/09/16
        • 2.2.7.0 - 2022/06/23
        • 2.2.5.0 - 2022/04/29
        • 2.2.3.0 - 2022/04/01
        • 2.2.2.0 - 2021/12/29
  • Data providers
    • Cryptocurrency exchanges
      • Binance Cryptocurrency Exchange
        • Registration on Binance
          • Registration on Binance Exchange website
          • Configure Binance Wallet
          • Creating a Binance API Key for TSLab
          • Binance. Transferring USDT from wallet to wallet without commission
        • Registration on TSLab [Binance]
          • Account registration on the TSLab website [Binance]
          • Creating a free Binance Data Provider for TSLab
        • Setting up a Binance Data Provider in TSLab
        • TSLab Binance Edition
          • Starting the program
          • Configuring the Binance Data provider
      • Bitget Cryptocurrency Exchange
        • Registration on the Bitget official website
        • Creating a Free Bitget Data Provider
        • Configuring the Bitget Data Provider in TSLab
      • ByBit Cryptocurrency Exchange
        • Registration on the ByBit website
        • Creating a free ByBit data provider
        • Configuring the ByBit Data Provider in TSLab
      • Deribit Cryptocurrency Exchange
        • Deribit data provider settings
        • Deribit. Frequently asked questions and useful information
        • Deribit. Possible problems and solutions
        • Deribit Margin Requirements Calculation
        • An example of a ready-made script for Deribit
      • Kucoin Cryptocurrency Exchange
        • Registration on the KuCoin official website
        • Creating an API key on the KuCoin website
        • Issuing a free license for KuCoin Data Provider
        • Setting up the KuCoin data provider in TSLab
      • OKX Cryptocurrency Exchange
        • Setting up an OKX account
          • Registration on the OKX website
          • OKX API Key creation
          • Issuing a free license for OKX Data Provider
          • Setting up the OKX data provider in TSLab
          • OKX demo account
        • TSLab OKX Edition
          • First launch of TSLab OKEx Edition
          • Configuring the OKEx data provider
          • Trading in TSLab [OKEx]
          • OKEx Demo
    • Historical Data
      • YahooFinance
      • Offline data provider in CSV format
      • An example of connecting text quotes
      • Text files with historical data
    • Interactive Brokers
      • Getting Started with Interactive Brokers Data Provider
        • Installing and configuring the Trader Workstation (TWS) terminal
        • Installing and configuring the IB Gateway terminal
      • Features of working with Interactive Brokers data provider
      • Known issues for Interactive Brokers Data Provider
      • Loading instruments in a package
  • Working with the program
    • Main menu
      • File
        • Program Settings
      • View
        • Chart
          • Features of working with the Chart in TSLab
          • Chart Controls
        • Depth of Market
        • Quotes
        • All Trades
      • Data
        • Data Providers window
        • Add online data provider
        • Add offline data provider
      • Lab
        • Scripts window
          • Script Container
      • Trading
        • Accounts window
        • Positions window
        • My trades window
        • My orders window
          • Move orders and deals to an agent
        • Autotrading Control Center window
          • Agent window
          • Agent trading settings
            • Event recalculations
            • Slippage
          • "Forget errors" of the agent
        • Orders manager
          • Linking a manually completed order to an agent
        • Agent Control Center window
      • Tools
        • Data backup and recovery
        • Notifications manager
          • Notifications Manager Filters
          • Reference List of Service Message Numbers
          • Example of setting up notifications for Gmail
        • Export to Excel
    • Common interface
      • Status bar
      • Tab
      • Workspace
      • Spreadsheets
    • Visual editor
      • Toolbar
        • Compress and Decompress Blocks
      • List of visual blocks
        • Service Elements
        • Cycles
        • TSChannel
      • The syntax of the Formula, Boolean expression and String expression blocks.
    • Autotrading Control Center
      • Agent trade settings
        • Agent trade settings - Placing orders
        • Agent trading settings - Script execution
        • Agent trading settings - Events
    • TSLab API
      • API Introduction
        • Visual Studio Installation
        • First script (API)
        • First Indicator (API)
        • Script Debugging
        • Logging
      • Writing scripts on the API
        • Trading Instrument Data
        • Working with positions
        • List of deals
        • The order queue
        • Standard Indicators and Handlers
        • Script parameters
        • Caching
        • Local and global cache
        • Multiple Tools
      • Writing indicators on the API
        • Stream indicator
        • Bar indicator
        • Pre-processed indicator
        • Indicator with multiple calculations
      • Additional features
        • The ability to create your own optimizers *
        • C ++ / CLI script
        • API Control Panel
        • Result from script
        • * Оптимизация. Пул массивов.
      • Examples
        • Get script results
        • Get script parameters
        • Get script and agent settings
        • Get position balance (net worth)
        • An example of a strategy Breakout of the Donchian channel
        • Example of a Moving Average Crossover strategy
        • Indicator example
        • How to speed up the processing of a script on the API
        • Links to examples
      • Question - Answer
        • HandlerParameter Attribute
    • Optimization
      • Insufficient load on a multicore processor
  • Examples of scripts and indicators
    • Examples of algorithms and indicators
    • Examples of implementing strategies in TSLab
      • A trading system based on indicator CCI
      • A trading system based on Standard Deviation
      • A trading system based on Aroon
      • A trading system based on ADX and DI technical indicators
      • A trading system based on the RSI indicator
      • Example of a trading strategy without parameters
  • TSLab website
    • TSLab Support Service
      • Memory dump of TSLab application
      • TSLab program log files
Powered by GitBook
LogoLogo

Мы в соцсетях

  • Группа в Telegram
  • Новости TSLab
  • Vkontakte
  • YouTube канал TSLab Live

Наши веб-сайты

  • TSLab
  • Служба поддержки
On this page
  • General system and computer requirements
  • How much RAM is required for optimization?
  • What determines the speed of optimization and script recalculation?
  • The "Script Optimization" menu in the program
  • Optimization in the program
  • Optimization types
  • How to enable indicator parameters for optimization?
  • Number of optimization iterations
  • Optimization Results
  • Saving a set of parameters after optimization
  • Queue of multiple optimizations
  • Calculating GPU optimizations (CUDA computing)

Was this helpful?

Export as PDF
  1. Working with the program

Optimization

Last updated 3 years ago

Was this helpful?

General system and computer requirements

The higher the number of processor threads, the better for optimization speed.

Select the amount of RAM based on the tasks and the calculation algorithm described below.

How much RAM is required for optimization?

The final memory consumption during optimization can be calculated using the following formula:

Memory (bytes) = Number_of_Bars * 8 * Number_of_Unique_Parameter_Sets

  • Number of Bars – how many history bars have you passed to the script

  • 8 – the number of bytes that one double number occupies

  • Number of Unique Parameter Sets – the number of unique combinations of parameters in the script. This value is not always equal to the number of iterations in the script. For two moving averages with a period from 1 to 300, the number of unique sets will always be 299, while the number of recalculations will be much larger. And by caching these 299 unique results, the optimization speed gain will be obtained, which is achieved by using GetData.

One gigabyte is always 1024 megabytes, and one megabyte is 1024 kilobytes, and a kilobyte is always 1024 bytes.

Within the program, one double number can take up to 10 bytes. TSLab allocates memory not only for the cache, but also for other intermediate calculations, and the closing prices of the instrument are also cached (which may take up some amount of memory). Therefore, memory will be spent a little more than in the calculations according to the above formula.

What determines the speed of optimization and script recalculation?

The program fully supports multithreading. Therefore, the more threads the processor supports, the faster the optimization is, with a sufficient amount of RAM.

The faster (high frequency) the processor and the more cores (possible threads), the faster the optimization. Read the related article:

The "Script Optimization" menu in the program

You can open the Script Optimization menu by selecting File -> Program Settings -> Script Optimization

For multi-core processors, enable the "Should be used on multiprocessor (or many cores) systems" option

  • Script debugging - this is a debugger for working with Visual Studio or SharpDevelop

  • Script execution timeout - the default is 40 seconds. This is the time to recalculate the script. If the computer was unable to calculate the script within the specified time, the program will stop recalculation and remove the task. The setting affects not only the optimization, but this parameter is the maximum time for calculating the agent.

  • Script cache size - is selected by the brute-force search method. All computers are different, even with the same hardware. Depending on the drivers, installed programs, OS version and running services, they may behave differently. With an excess of RAM and working in 64bit on the latest versions of Windows, this parameter can be left alone or set close to the available free physical RAM.

About the brute-force search method from the user:

RAM is engaged in storing data, from where it is consumed and recalculated by the processor. A larger amount of RAM will allow you to place a larger amount of calculated data there without the need to extract this data from the HDD. The processor is responsible for the recalculation itself, respectively, the optimization speed will be determined by the balance between the amount of RAM and the processor speed. Increasing the RAM without increasing the processor speed will not have an effect after passing the point of maximum RAM load, just as increasing the processor frequency will have a lesser effect with low RAM, because data will have to be taken from low-speed data storage devices such as HDD and SDD.

The "brute-force search method" in this case implies the need to find a balance between the amount of data that needs to be optimized, processor frequency, RAM size, HDD / SSD speed and the number of processes already running in your system.

This is the "brute-force search method". You can play Need For Speed ​​on your computer while optimization is running. It is clear that, all other things being equal, optimization in this mode will be slower than on the machine on which the game is not running. It seems that this is exactly what was meant in the documentation for TSLab

Alexandr Ganov

  • Optimization threads number - 0 means that the program will use the number of threads based on the number of cores.In the example, the picture shows a regular dual-core 2ghz xeon. It has 2 threads by default, since there are two cores. However, if you use hyper-threading processors, for example i7, then the number of threads can be taken by the number of cores, multiplied by two. The optimization speed will increase significantly.

  • Stop opt. if RAM is not enough - the program will stop optimization if the RAM resources are exhausted. If you uncheck the flag, Windows can take processes to SWAP (when using 64 bits) or throw a memory exception error (when using 32 bits)

  • Should be used on multiprocessor (or many cores) systems - the setting is available since version 2.1. This is a NET garbage collector setting. For example, for multi-core xeon (more than 8 cores), configuration is required, even regardless of the Windows version (server or not). With fewer cores, the setting may not affect the processor load.

Optimization in the program

Optimization types

  • Brute force - Direct enumeration of parameters with a given step from smaller to larger, in turn.

  • Random - Enumeration of parameters with a given step, in random order

  • Genetic - Read more in the article API. Plugins. Implementing IOptimizationMethod

How to enable indicator parameters for optimization?

Optimization parameters are enabled in the block properties.

Number of optimization iterations

Let's set the boundaries of the parameter optimization, for example, 1 - 100, step = 1. In total, a maximum of 100 iterations.

But if you set 30 iterations, not the maximum (100), then the optimizer will go through not exactly 30 iterations, but 34-35.

Explanation:

"Number of iterations" specifies the minimum number of iterations. In general, the number should be a multiple of the number of parameters involved.

Optimization Results

The block outputs the value from the Result for optimization script into a column by block name.

There can be several results for optimization (limited by common sense)

Nothing is counted in the column, i.e. the block simply outputs the value from the Result for optimization to the Optimization Results table. For example, some characteristics evaluating a strategy.

If the Optimization Results table does not load, check the filter settings:

Saving a set of parameters after optimization

Click the Save parameters button in the "Optimization" tab. Give a name to the parameter set. This set of parameters will be available in the "Parameters" tab

Queue of multiple optimizations

Q:

There are several quotes. It is necessary to run the script for these quotes with certain sets of optimizing parameters and save the results to a file. Is it possible to solve this problem by creating an additional script that will perform the above task? It would be very convenient to put the script at night so that all planned optimizations are performed at night. Since optimizations can take 2-3 hours, it would be convenient to schedule several calculations to run overnight. Which will significantly speed up the optimization process.

A:

It is not possible to queue several optimization tasks with built-in tools in TSLab. We have plans to implement these opportunities in the future.

Calculating GPU optimizations (CUDA computing)

Will there be GPU optimization in the program? The GPU is not capable of doing all the calculations, and in this case it is technically impossible to do, so the answer is no.

The Optimization Results table appears at the beginning of the optimization process unless the Save to Excel option is selected on the Optimization page. The table has a column Result from script. In the toolbox, the editor has a Result for optimization block. The block code is here: ​

Insufficient load on a multicore processor
https://github.com/tslab-hub/handlers