资源加载中... loading...

Many years later, you will find this article is the most valuable one in your investment career - find out where the returns and risks come from

Author: FMZ~Lydia, Created: 2022-12-19 15:03:57, Updated: 2023-09-20 10:58:10

img

Many years later, you will find this article is the most valuable one in your investment career - find out where the returns and risks come from

Many years later, Ah Jiu, who has grown up, recalled his childhood youthful years, he forgot the Golden Cross and the Bearish Crossover, he forgot about the liquidations and mentality, but he must still remember the fifth issue of Zinan teaching quantitative trading.

Because what Zinan taught in this issue made him realize the importance of “finding out where the returns and risks come from”.

In order to make it convenient for people without programming bases to benefit from “Zinan teaching quantitative trading”, I will try not to use code in the column, and also try to use pseudocode to realize functions if necessary.

Everyone who makes investments receives a sentence of soul torture from relatives and friends:

“How can you make profits?”

Or extend it:

“Why don’t you lose money?”

Most people should only laugh back when they meet someone who is teasing them. However, if you think carefully, this is a good question, and it is a very important question.

How can you make profits? In other words, what is the source of your income?

When most people encounter the problem, they will say honestly and simply, “Buy at a low point and sell at a high point”. If I buy low and sell high, I will make a profit. This leads to the next question. How do you decide whether a point is low or high?

What, you said you could just feel it? Bullshit. I’ll give you a section of K-line, and you will tell me whether it’s a high or low point.

img

Is this the high or the low point?

What? You said you need to look at the Bollinger Bands?

img

You said the pressure level has been broken and the low point is undoubtedly? Will it definitely increase next?

img

You didn’t expect that, did you? It broke through a bunch of Bollinger Bands mentioned by Great V, and then decreases continuously.

You say it doesn’t count and let me take another cut?

img

Come on, we broke through the pressure level twice. Do you think it’s increasing or decreasing?

Having learned the lesson just now, the author will definitely play a joke on me. So you say, “Decreasing, decreasing is definitely”:

img

Sorry, all the way is increasing.

So do you think it is a high point or a low point?

Don’t dare to say it? Next comes a waterfall.

img

This is the strangeness of waveform theory. If the current waveform does not conform, he will say that it is only temporary. The next waveform must conform. If the next waveform does not conform, he will say that the next waveform must conform again. It’s the same as giving birth to a boy or a girl. If you guess wrong, he will say that you must have a boy or a girl in the next birth.

Far from it, I mean to tell you that this kind of thing is invalid if you do not confirm that it is valid. Just like taking medicine, all drugs are listed on the market on the assumption that they are invalid, and they can only be listed on the market if they are proved to be effective (except for traditional Chinese medicine, which can only be said to be invalid unless it kills a large number of people and can not be hidden when it is reported, otherwise it can only be said that it is unfortunate to be killed, and it cannot be said that there is a problem with the toxic traditional Chinese medicine.)

Your source of income is the same. You must assume that your current idea is wrong and prove it to be effective through “logic” or “statistics”.

Then you can say it is effective.

The proven “profit source” is the credible profit source.

Then, the next question is very simple. How to prove validity through “logic”?

It’s very simple. For example, I know an exchange, its raw_Kline_ info is generated through the price and depth information of Binance, Huobi, etc. Then it must have a delay relative to the target exchange, right?

So as long as I can find its target exchange and fit out its formula for drawing the price of the K-line, I can get the information about its next drawing of K-line before it draws K-line. Through the price information. We will know the price trend information of an exchange within a few hundred milliseconds.

Seeing this, the impatient “leek” prepared to write something happily, while the patient leek is still taking notes.

Because you still can’t get any profit here…

Why? Because there is a commission for the transaction. The commission for the price change within a few hundred milliseconds is generally about 0.005%. And the commission of the exchange is about 0.01%. At this time, you have to consider whether you are a taker or a maker, because logically speaking, a taker, that is, taking someone else’s order, which is obviously faster and more stable to catch the trend. However, the fees for the takers of exchanges are often much higher than those for makers. Although the service charge of maker is relatively low, it can often get a zero service charge account (for example, if you forward this article and praised “Zinan teaching quantitative trading” is the most reliable program you have ever seen. Maybe I will share the method of a two-month 0 maker service charge for a top 20 digital currency exchange in the next issue… Shh.). However, the problem with the maker is that you have to wait for others to take it. According to my experience, 10 times of trend judgment, once you can be taken, you will be the luckiest dog.

Did you find any problems? Even if you can judge the trend, you may not be able to make profits. In addition to “being able to determine the trend”, your income source here has an additional piece of information that you previously ignored “and catch the trend.”

The ability to catch the trend is divided into two parts:

  1. It can get the order.
  2. The profit brought by the increasing and decreasing trend can cover the cost of order grabbing (commission).

Together with these are the sources of your profits and risks.

Come on, read it again:

  1. Find a D exchange that benchmarks the prices of A, B and C exchanges;
  2. Fitting out the algorithm for D exchange benchmarking other exchanges to draw K-line;
  3. According to the fitted algorithm, determine the short-term trend of a trading pair in Exchange D;
  4. Change the position by placing orders or taking orders according to the determined trend;
  5. Make sure that the cost of changing your position is lower than the profit of your trend.

Well, these five points constitute the source of return and risk of your strategy. Next, assign the first assignment to extract the source of return and risk from these five points~

What will you do after you extract it?

Answer yourself 2 questions:

  1. Is your source of return reliable? Can your assumption of profitability be proved by logic or statistics?
  2. Can your sources of risk be addressed?

Whenever you look at your trading system, you should question yourself these two questions first, and then you can answer “Why do you make profits” and “Why don’t you lose money” righteously.

Someone may want to ask: what about the logical proof and the statistical proof? Backtest… If it is digital currency, use FMZ platform to backtest: https://www.fmz.cn/sign-up/1974419, if you use my link to register, it will give a real bot of 5 yuan~. As for statistics, it is generally the data backtesting of multiple different periods. After the backtesting proves to be effective, run on the simulation bot, the real bot. That is, (real bot) practice is the only standard for (statistical method) testing (effective strategy) truth.

Strategy pseudo code (suppose you have seen Zinan teaching quantitative trading and writing about the middle layer, here, only the logic layer pseudo code is written, and no content is filled in. You have to do fault tolerance, optimization and improve the strategy by yourself.):

'''
class high_freq():
    def __init__(self,mid_class):
    '''
    This is used to initialize various data, do it yourself as needed
    '''
        pass
        
    def refreash_data(self):
    '''
    This is used to refresh markets, depth, and account information
    '''
        pass
        
    def refreash_target_data(self):
    '''
    This is used to refresh the exchange data for benchmarking
    '''
        pass
        
    def make_price_condition(self):
    '''
    This is used to process price information
    '''
        pass
        
    def make_amount_condition(self):
    '''
    This is used to process amount information
    '''
        pass
        
    def make_deal_condition(self):
    '''
    Give the judgment of the trading conditions, whether to make bids, ask or wait according to the price information and amount information
    '''
        pass
    
    def make_trade_dict(self):
    '''
    Generate the order book to be traded according to the trading conditions and depth
    '''
        pass
        
    def do_trade_and_cancel(self):
    '''
    According to the information in the order book, cancel the old order, fill in the new pending order price, and pend the order
    '''
        pass
        
    def check_deal(self):
    '''
    Check the pending order situation, whether pending orders successful, whether there are network problems omitted single, position risk
    '''
        pass

    def lower_risk(self):
    '''
    Reduce position risk according to your own settings. For example, if they tend to hold currencies, they usually pay more for small buy orders.
    If they tend to short positions, they sell small buy orders more.
    This is easy to understand. The upward period tends to hold currencies, while the downward period tends to hold short positions.
    '''
        pass
    
    def trade_controller(self):
    '''
    Process trading-related logic, integrated into a single function
    '''
        pass
        
    def clear_info_controller(self):
    '''
    Processing and cleaning up thread-related logic, integrated together
    '''
        pass
    
    def target_controller(self, target_class):
    '''
    Processing and benchmarking with exchange information related logic, integrated together
    '''
        pass
    
def main():
    raw_base_class = mid_class(exchanges[0])
    base_class = high_freq(base_class)
    
    raw_target_class =  mid_class(exchanges[1])
    target_class =  high_freq(target_class)
    
    While True:
        Sleep(100)
        
        base_class.refreash_data()
        target_class.refreash_target_data()
        
        base_class.target_controller(target_class)
        base_class.clear_info_controller()
        base_class.trade_controller()

So that’s the end of this article. Like more and forward more. In the next issue, I will share how to fool small and medium-sized exchanges into giving you a zero commission test period (so that you can manipulate the strategy illustrated in this article actually. I have not shared the code here, but I have run the market making strategy myself. According to different exchanges and trading pairs, profits are about 0.1-0.5% per day.)


Related

More