Adding stoploss can control the risks. So, what’s the price, Gul’dan? (The article is initially published on FMZ Quant.) In quantitative trading, every programmer is facing a difficult decision: Add stop-loss logic, or not?
Without stop-loss and stop-profit logic, it is often possible to continue to take profits, thereby increasing the rate of return. But there is often a risk of ruining the return accumulated for years overnight by volatility. Adding the stop-loss logic can improve the funding rate and reduce the risk of each trade, but it often leads to a lower return rate.
To be or not to be? It is a question.
After many times of liquidation, people who always have losses, finally added a stop-loss logic in each strategy.
But, Gul’dan, what’s the price? Take my own account as an example: The profit caused by canceling orders is theoretically the profit in the account, and the loss caused by canceling orders is theoretically the profit missed (because the canceled trade information will not be reflected in the account, but if the order is not canceled, the trade will be reflected in the account. That is easy to understand, right?) So we recorded the price and amount of the canceled orders, and maintain the part that appears within the range of the subsequent K-line. The price difference between this part and the current price can simply be regarded as the profit/missed profit caused by the cancellation of orders. That is, the formula for calculating the profit (missed) is:
'‘’ hand_price: the handed price. now_price: the current price.
hand_amount: the executed amount; whether it is positive or negative is determined by the directions of bid and ask. '‘’ (hand_price - now_price)*hand_amount
My stop-loss logic here is the way to cancel the corresponding trades after discovering the rises and falls. For example, after a crash is found, the probability of executing a buy order is reduced in the trading logic, and the probability of executing a sell order is increased.
And cancel the corresponding buy orders or sell orders that have been placed in the direction of decreasing probability, and record them in the statistical information.
Due to frequent trades, canceling orders in one direction can directly affect the position.
Compared with trading to stop loss, this method of predicting market to stop loss has a huge advantage because it can save handling fees, for there is no trading due to cancellation.
So knowing this, let’s take a look at the transaction information in the picture.
The current profit in the account is 67.4 caused by market making, and -17.4 caused by equalization, that is, the current theoretical profit is 50.
Check out and see the actual return converted from the current position value is 48, which is almost equal.
The theoretical and actual values are very similar, indicating that our formula is correct, at least within the error range.
Then we use the same method to calculate and see how much return the canceled order brings:
-162
That is, stop-loss/stop-profit, let us miss the return about 162.
This is nearly three times the actual profit to the date.
So, can it be said that as long as we do not stop loss, our profit can be 4 times what it is now?
of course not…
As for why, the first point is because of “the funding rate”.
When trading on a platform, the spot requires you to have a “commodity” in order to “place an order”, so the canceled order stops loss, in fact, if it is executed, it will inevitably lead to the subsequent new pending orders cannot be executed because the funds have been occupied.
That is to say, if it is “profitable”, it will lead to the “disappearance” of a later order that can be profitable.
Just imagine, if the current price is 1000, we stop loss for 10 sell orders at 1001, and later find out the volatility stops at 1010 and then execute 10 sell orders. After a while, the price drops back to 1000.
It seems that the cancellation of the order has caused us to miss 10% of the profit, but if the order is not canceled, it will be unable to trade at 1010 due to the occupation of funds and lose 100% of the profit.
Suppose we currently have only 10 items. So in fact, it seems that it has caused a missed profit of 10, but in fact it has brought 90% of excess return.
That is the first point, and the importance of the funding rate is also the most overlooked point for most of the half-way “masters” (or super rich people, who are just rich and have unlimited funds).
I guess you have already figured it out as well. If your market judgment is accurate, then you can use the method of adding leverage to the funds to obtain this part of the return.
Yes, this is also an important reason why if the strategy is stable and certain stop-loss restrictions are relaxed, and when the same trend judgment parameters are used, the return increase of doing futures is much greater than the that in spot. Futures have greatly improved the funding rate (in exchange for the risk of liquidation).
Therefore, the profit brought by the stop-loss is a real profit, and the missed profit caused by the stop-loss is not necessarily a real missed profit.
Secondly, if the stop-loss logic is not carried out, and you are like me to stop loss by reducing the probability of submitting orders (sub-high frequency, a common method for high-frequency strategies), a cost will definitely be paid, for you seriously execut the trade and do not stop loss.
However, with a stop-loss logic, this cost will be saved due to the cancellation of the order.
In other words, the similar stop-loss methods of sub-high-frequency and high-frequency strategies reduce the loss per order, which is equivalent to the cost of pending the order. That is, in this case, as long as you have a 50% accuracy rate of grasping the trend reversal, you shall stop the loss. (Of course, you can also use my invitation link to trade on Binance, and the handling fee is 20% off: https://www.binance.com/cn/register?ref=ILBGUIDR
Recommended ID: ILBGUIDR. As long as you use my link to trade, you can consult me once for free about your specific technical problems in cryptocurrency quantitative trading.)
Finally, stop-loss is a type of trend judgment, which is inaccurate and brings little loss. Once the judgment is accurate, the benefits it brings are extremely exaggerated.
Take the sub-high-frequency strategy like the market maker strategy as an example. Because the trading frequency is very high, that is, at least a few orders per second. So, if the judgment is not accurate, the frequency will be pretty high.
And in the case of high frequency, the miss profit, caused by thousands of times of misjudgment, is actually only 1%.
And once the judgment is accurate once, the return brought is not just a few percent.
A correct stop-loss logic, the lowered drawback is at least a few tenths.
If there is one thing for a trader, by which the returns are real profits, and the losses are not necessarily real losses. And once the return is brought, compared with the loss, it is at least dozens of times more than your loss.
Without stop-loss, a high return can be maintained.
In the short term, the return curve has indeed maintained, and it seems that there is a 1 to 2 times of return.
With a stop-loss, you are trading at the price of missing several cents every second in to guarantee your positions in the event of a big fluctuation.
Positions are not dead.
But is it all worth it?