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 implement a single platform Equalization Strategy in Python

2025-01-15 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

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

This article is about how to achieve a single-platform equilibrium strategy in Python. I think it is very practical, so I share it with you. I hope you can get something after reading this article. Let's take a look at it.

Policy description

Quote from the JavaScript version: this needs to build a position, for example, the account has 5000 yuan, with one coin, if the value of the coin is greater than the balance of the account by 5000 and the price difference exceeds the threshold, for example, if the coin is now worth 6000 yuan, sell (6000-5000) / 6000 pesque 2 coins, state that the currency has appreciated and change the money back. If the currency depreciates, for example, 4000 yuan. Just buy (5000-4000) / 4000 pesque 2 coins, buy some when the currency falls, and if it goes up again, sell it again, just like the balance, the two sides are hedged differently, so I named it the equilibrium strategy.

The principle of the strategy is very simple, and the JavaScript version of the code is not long, only more than 70 lines. Transplanted into a more concise syntax of the Python language strategy, the code is shorter, very suitable for beginners to learn, in the inventor quantitative trading platform, there are a large number of developers to share the code, language support JavaScript/C++/Python, etc., so to master a development language, not only for learning, research, development strategies are very helpful, but also more familiar with the API interface of the platform.

Policy code

At the beginning of the code

Is the backtest configuration, which means that the retest configuration (setting) is saved in the form of code, and the backtest configuration is automatically configured according to this setting. This part can be deleted, deleted, and you need to manually set the retest configuration information on the backtest page. Reference: https://www.fmz.com/bbs-topic/859 the parameters of this strategy are exactly the same as those of the JavaScript version, the policy code is also transplanted sentence by sentence, and the program structure has not changed. You can compare it sentence by sentence to see the differences between strategies written in different languages.

Back test

Parameter configuration

Statistical data

The above is how to achieve a single-platform equilibrium strategy in Python. The editor believes that there are some knowledge points that we may see or use in our daily work. I hope you can learn more from this article. For more details, please follow the industry information channel.

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

Internet Technology

Wechat

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

12
Report