I previously wrote an article titled "Introduction to CTA Strategy Based on VN.PY", which mainly focused on an introduction to VN.PY. This article, based on the previous one, focuses on the process of accessing the Futures Penetration CTP API. Since my own futures account is with ShenYinWanGuo, this article uses ShenYinWanGuo futures as an example. The general process is similar to the diagram below, but there are some minor differences.
Image source: https://www.vnpy.com/forum/topic/603-kan-wan-zhe-pian-che-di-gao-ding-qi-huo-chuan-tou-shi-ctp-apijie-ru?page=1#pid2167
1. Apply for Penetration Access#
Contact your account manager for this step. The account manager will provide you with some materials to fill out. Pay attention to not apply for the wrong type, such as applying for options account by mistake. Generally, ShenYinWanGuo's simulated accounts start with "800", while individual stock options simulated accounts start with "0000", making them easily distinguishable. Additionally, some old customers may encounter issues with simulated trading in the Energy Center or Shanghai Futures Exchange (error message: "Investor is not registered with the exchange") after their simulated accounts have been opened. This is usually because their accounts were opened earlier, before the Energy Center was established, resulting in a lack of permissions (this is unrelated to whether your live trading account has the same permissions or not). In this case, keep in touch with your account manager and ask them to help you open the necessary permissions.
Before obtaining your own simulated account, you can use a public test account for testing purposes (corresponding to VNTrader: CTP Test). The main purpose of this test account is to check if your VNPY is working properly (not for testing trading strategies). The test account and IP information can be found in the "CTP System Penetration Supervision Test Guide" (provided by ShenYinWanGuo, I won't randomly disclose their information here). A successful test page should look like the following, without displaying too much log information. It is best to confirm the success with your account manager at ShenYinWanGuo. If you can place orders, it means the test was successful.
2. Apply for AppID#
After obtaining the simulated live trading account and password, you also need to obtain the product name and authorization code. In ShenYinWanGuo's corresponding terminology, the product name corresponds to the AppID, and the authorization code corresponds to the AuthCode or Terminal Authentication Code, which are the same concept. AppID is a trading program code provided by the user. When applying as an individual, most people would write it as: client_xxxx_yyyy, where xxxx is your software name and yyyy is the version number. These two fields are filled in by the customer themselves and there are no fixed rules. Note: AppID represents the access system. The same AppID represents the same access system and is not tied to an account. In other words, your AppID can be used by someone else's account. Determine your AppID and provide it to your account manager to help you apply for the AuthCode.
3. Obtain AuthCode#
In theory, the application for the simulated live trading AuthCode should be quick (I received mine in about an hour after applying). Now you can connect to CTP for strategy testing (in ShenYinWanGuo, VNTrader should be selected instead of CTP Test). After the first CTP connection, it will display: CTP: First login requires password modification. Download a FastQuant Trading Terminal (Simulated) from the ShenYinWanGuo official website, enter your account and initial password, and you will be prompted to modify the password. After completing the modification, connect in VN.PY. After successful connection, view a contract information. The information after successful connection can be seen below, where various login information and contract queries are confirmed in the log section.
4. Simulated Testing#
In the simulated live trading environment, you can execute CTA strategies for simulated testing. However, the real-time nature of ShenYin's simulated live trading market data is lacking, and prices take a while to change. According to ShenYin's customer service, simulated live trading also involves matching trades, but because there are fewer participants, the price changes are not significant. This lack of real-time data is not very useful for strategy validation, especially for high-frequency strategies, and it is even less useful than SimNow. However, this step is necessary.
After completing the above steps, you can proceed to complete the verification with the futures company and perform the final live trading testing in a similar manner.