Blockchain Quantitative Investing series of courses ((4) - Dynamic balancing strategies

Author: 15565556421, Created: 2018-08-10 11:42:53, Updated: 2022-08-26 11:18:03

Read the original:Blockchain Quantitative Investing series of courses ((4) - Dynamic balancing strategies

The Foreword

Warren Buffett's mentor, Benjamin Graham, had been in theYou are a smart investor.In a book, a trading model of dynamic equity-bond equilibrium was mentioned.The transaction model is very simple:

  • Invest 50% of your money in a stock fund and the remaining 50% in a bond fund; that is, both stocks and bonds are half each.
  • A re-balancing of assets at fixed intervals or market changes, returning the ratio of equity assets to bond assets to the original 1:1. That's the whole logic of the whole strategy, including when to buy and how much to buy.

In this approach, the volatility of the bond fund is actually small, far below the volatility of the stock, so the bond is treated as a'reference parity', i.e. the bond is used to measure whether the stock is earning too much or too little. If the stock price rises, the market value of the stock is greater than the market value of the bond, and when the ratio of the two market values exceeds the set threshold, the stock is readjusted, the stock is sold, and the bond is bought, so that the stock market ratio returns to the original value of 1:1.

Instead, a fall in the stock price causes the market value of the stock to be less than the market value of the bond, and when the market value ratio of the two exceeds the set threshold, the total position is readjusted, stocks are bought and bonds are sold, bringing the stock-bond market value ratio back to the original 1:1 ratio.

In this way, a dynamically balanced ratio between stocks and bonds is enough to enjoy the fruits of stock growth and reduce asset volatility. As a pioneer of value investing, Graham provides us with a good idea.

If this is a complete strategy, why don't we use it on digital currencies?

The dynamic balancing strategy in BTC, a blockchain asset

Strategic logic

  • At the current value of BTC, the account balance retains ¥5000 in cash and 0.1 BTC, i.e. the initial ratio of cash to BTC market value is 1:1.
  • If the price of BTC rises to ¥6000, i.e. the market value of BTC is greater than the account balance, and the difference between them is greater than the set threshold, sell ((6000-5000) / 6000/2 coins.
  • If the price of BTC drops to ¥4,000, i.e. the market value of BTC is less than the account balance, and the difference between them is more than the set threshold, buy ¥5000-4000/4000/2 coins.

In this way, regardless of whether BTC is appreciated or depreciated, the account balance is always kept dynamically equal to the market value of BTC. If BTC is depreciated, buy some, wait for it to come back, sell some more, as if it were normal.

So how do you do that in code?

Let's take inventors as an example of a quantitative trading platform, and first let's look at a strategic framework:

The whole policy framework is actually quite simple, with a main main function, an onTick sub-function, a CancelPendingOrders function, and the necessary parameters.

Sub-modules

The following transaction logic is clear, all the annotations have been written in the code, you can click on the image to enlarge it.

The main processes are as follows:

  • Get your account information.
  • Get the Tick data.
  • Tick data is calculated as the difference between the bid and offer prices.
  • Calculate the account balance and BTC market price difference.
  • Calculate the purchase and sale conditions, order price, order quantity.
  • Subscribe and return true.

Withdrawal of modules

It's easier to remove modules, the steps are as follows:

  • I'm not going to be able to do it, but I'm going to have to wait a second before I can withdraw it, individual exchange, you know.
  • Continue to retrieve the array of outstanding orders, and continue to retrieve if an exception is returned.
  • If the pending order array is empty, immediately return the withdrawal status.
  • If there are outstanding orders, go through the entire array and cancel them in order of order number.

Policy all source code

With the help of inventors who quantify the trading platform, a complete blockchain BTC dynamic balancing strategy should be created with just 80 lines of code.

Next, let's test this simple dynamic balancing strategy to see if it works. Below is a review of BTC's historical data for reference only.

Reviewing the environment

Re-tested performance

The retest curve

Here's another chart of the price movement of BTC over the same period.

Have you ever had a seizure?

BTC has been declining for 8 months, even reaching a maximum decline of over 70%, which has caused many investors to lose confidence in blockchain assets. This strategy has a cumulative return of up to 160% and an annualized return risk ratio of more than 5%.

This dynamic balancing strategy, with only one core parameter (the threshold threshold), is a very simple investment method that seeks not excessive returns, but solid returns. In contrast to the trend strategy, the dynamic balancing strategy is counter-moving. It reduces the temperature of the stock when the market is hot, and increases the volatility when the market is cool, somewhat similar to macroeconomic regulation. In fact, the dynamic balancing strategy is adhering to the concept of price unpredictability, while also capturing price volatility.

Given the reasons for this article, it is impossible to do it face-to-face, so it is important to know the words. The most important thing about the dynamic balance strategy is investment ideas, you can even exchange a single BTC asset in this article for a basket of blockchain assets.

Finally, let us conclude with Benjamin Graham's famous quote from his book The Savvy Investor: "The stock market is not a 'weighing scale' for accurate measurement of value, but rather a 'voting machine' in which the decisions of countless people are a mixture of rational and emotional judgments, often far from each other".

Read more:Blockchain Quantitative Investing series of courses ((1) - briefing Blockchain Quantitative Investing Series Courses ((2) - Understanding the digital currency Blockchain Quantitative Investing Series Course ((3)) - cross-term leverage


Related

More

lcgs005It's better to have a Python version, because most people are learning Python now.

weifThe amount of money is too small, it is not suitable, the coin is slow

weifTrading with two currencies may be better, if with a stable currency, there may be a loss, suitable for the coin party