The resource loading... loading...

Visualizing modules to build trading strategies - out

Author: Inventors quantify - small dreams, Created: 2019-07-29 09:04:35, Updated: 2023-10-20 20:09:03

img

Visualization modules to build trading strategies

By studying the content of the previous chapters of this series, you will have a basic understanding of the use of various types of visualization modules. In this chapter, we use a simple but interesting strategy to build a visualization module.

  • A simple, violent but fun chase-and-fall strategy

    • Strategic thought

      The core of the strategy is to chase down, choose the market for the digital currency spot market, such as BTC_USDT, according to the price at the time of the strategy's operation, the price rises by a certain percentage, then buy a certain percentage of the current asset, and sell a certain percentage of the current asset.

    • Select Visualize class libraries and add multiple modules

      Before we started building, we added some reusable modules.

      img

      As shown above:

      The class libraries contain reusable packages that can be used after selection. The selected "digital currency spot market library" is a trading library for the digital currency spot market, which internally handles complex detection, retesting, etc. logics (e.g. how to handle transactions without a transaction after placing an order, etc.). This is a very convenient way to build strategies without a lot of complicated processing logic.

    • Spelling of policy modules

      img

      Since the strategic idea is simple, the strategic modules are put together, not very big. We are reassured that in less than a year from October 18th, there will be a large number of shocks and trends, which can be used as a preliminary testing strategy. The parameters of the retest:

      img

      Here's how this strategy performed in retesting:img

      An equivalent JavaScript language strategy, also released at the same time, can be studied by interested students. By learning how to build strategies through visualization modules, it is easy to get started with the conception of strategies, the use of various interfaces and programmatic transactions.

      The strategy has no other interface parameters, and interested students can optimize the extension.

      function main() {
          var basePrice = -1
          var addRatio = 0.02
            
          while (true) {
              var ticker = exchange.GetTicker()
              if (basePrice == -1) {
                  basePrice = ticker.Last
              }
              
              if ((ticker.Last - basePrice) > 0 && ((ticker.Last - basePrice) / basePrice > addRatio)) {
                  var acc = exchange.GetAccount()
                  var amount = acc.Balance * addRatio / ticker.Last
                  
                  $.Buy(amount)
                  basePrice = ticker.Last
              } 
              
              if ((ticker.Last - basePrice) < 0 && ((basePrice - ticker.Last) / basePrice > addRatio)) {
                  var acc = exchange.GetAccount()
                  var amount = acc.Stocks * addRatio
                  
                  $.Sell(amount)
                  basePrice = ticker.Last
              }
          } 
      }
      

      A very interesting part of this strategy is that when the account asset is initially set to a coin and a cash value equivalent, for example, BTC_USDT trading pair, where the current price of BTC is 10,000, the account coin is divided into five, then the USDT is divided into 50,000.

      The strategy is to take a neutral approach to market conditions, where prices are falling. I'm going to try to allocate a little bit less USDT, a little bit more currency. For example:

      img

      There is a marked change in the measurement.

      You can also set up more USDT and less currency.

      img

      In the meantime, let's put together modules and try out our own programmatic trading ideas.

Visualizing the paradigm strategy:

More tips can be found at:https://www.fmz.com/square

Other articles in this series

It's boring programming, it's easy to do with blocks, try it out, it's fun!


Related

More