Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to increase the logarithmic rate of return queue for VNPY's K-line sequence management tool ArrayManager

2025-03-26 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

How to increase the logarithmic rate of return queue for VNPY's K-line sequence management tool ArrayManager, many novices are not very clear about this. In order to help you solve this problem, the following editor will explain it in detail. People with this need can come and learn. I hope you can get something.

When doing strategy modeling, it is often necessary to convert the K-line into data that can be normally distributed, so that we can use those powerful mathematical models for mining.

The implementation is very simple.

C = ln (t1/t0)

If we look at the performance of a single investment over a total T period, we should use a logarithmic rate of return, not an arithmetic rate of return. The arithmetic average does not correctly reflect the rate of return on an investment product. For example, an investment product that rose 50% this year and fell 50% next year has an average return of 0, but in fact, it lost 25% of its initial capital two years later. On the contrary, because the logarithmic rate of return is additive, its average value can correctly reflect the real rate of return of the investment product. For example, the logarithmic returns of these two years are 40.5% and-69.3% respectively, with an average of-28.77%. The conversion to a percentage loss is exp {- 28.77%}-1 =-25%.

The time series additivity of logarithmic returns allows us to use two other sharp tools: the central limit theorem and the law of large numbers. Assuming that the initial capital is ln 0 (assuming that it is equal to 1), the logarithmic rate of return for the entire T period is ln (XeroT) = ln (X_T/X_0). The biggest advantage of the logarithmic rate of return is its additivity. The logarithmic rate of return of a single period is added to get the overall logarithmic rate of return.

In VNPY's K-line sequence management tool ArrayManager, you can add the following code. Returns logarithmic rate of return series by attribute

@ propertydef percentLog (self): "get logarithmic return sequence" arrayold = self.closeArray [0:self.size-1] arraynew = self.closeArray [1:self.size] return np.log (arraynew/arrayold) * 100.0

Traditional close curve

After the logarithmic rate of return, after ignoring several sudden maximum and minimum values, it is a very similar normal distribution, and then it can be applied with a bunch of models.

Is it helpful for you to read the above content? If you want to know more about the relevant knowledge or read more related articles, please follow the industry information channel, thank you for your support.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report