Blog

 

Entertainment

 

First

Prev

Next

Last

 

切换成中文

   

PHP Application to Estimate SZ162411 Net Value

Aug 18, 2015
As my CSR Stock is turning into cash soon, I am considering to use the USD to trade XOP while using my other CNY to trade SZ162411 together. I was watching stock quotations on Yahoo and Sina everyday, and always need to click on the calculator application to convert the price between XOP and SZ162411, soon I got bored.
Later I thought of my first PHP application 5 years ago, and decided to write my second PHP application. It was planned to put all the usual stock quotations together, and to estimate SZ162411 net value based on XOP, ^SPSIOP and USDCNY exchange rate. Today the first version is released, and I am writing this record of programming details for future reference.
Thanks abkoooo for Sina realtime US stock data format.
Using Sina realtime source for US and Chinese stocks, oil futures and forex: gb_xop,sz162411,hf_CL,USDCNY
At first I found that fopen will always fail to open those urls, maybe my Yahoo Web Hosting does not support allow_url_fopen. I searched and found curl to solve this problem, copied some curl code to my url_get_contents function with name similar as file_get_contents.
To optimize web response time, I used 2 files gb_xop.txt and sz162411.txt to save last updated stock data. The following are checked:

  1. New request in the same minute using data in original files directly.
  2. Using gb_xop.txt for US stock data after US market closed.
  3. Using sz162411.txt for Chinese stock data after Chinese market closed.

Similarly, oil future data is stored in file hf_cl.txt, and USDCNY forex data in usdcny.txt.
Part of the complete Lenna story
Part of the complete Lenna story

SMA

Aug 20, 2015
To set up my own trading rules, and to avoid following the market all night, I plan to trade XOP simply on Simple Moving Average (SMA) values. This version added the premium of current trading price comparing with XOP estimation of SZ162411 net value, and the days in past 100 trading days did the estimated SMA value fitted in the trading range.
The historic data of XOP only need to update once a day, using Yahoo stock historic data: https://finance.yahoo.com/quote/XOP/history
The official fund net value only need to update once a day too. Using file f_162411.txt for official SZ162411 net value from f_162411, as I do not konw when the data will be updated, I update it once an hour stupidly.
Using debug file debug.txt for temp data checking.

Stock Transaction

Sep 13, 2015
After login, user can now input related stock transaction record. And we make SZ162411 and XOP arbitrage analysis based on those record.
The input and handling of stock transaction record is in file /woody/res/php/_edittransactionform.php and /woody/res/php/_submittransaction.php. Visual C++ coded Woody's Web Tool is modified to generate _submitXXX.php file automatically when insert copy of a _editXXXform.php file.

Period Three Implies Chaos

Feb 26, 2016
SZ162411 is trading more than 10% higher than its net value recently, the max premium as high as 17%, so the XOP and SZ162411 arbitrage is not possible now.
Continuing to organzie the similar code, added MysqlReference and MyStockReference class. FutureReference and ForexReference are now extended from MysqlReference, same as the new MyStockReference. We called MySQL related function in MysqlReference class, put history and calibration database operation in the same place.

The Most Stupid Bug in Recent Years

May 15, 2016
Last week USDCNY was rising significantly again, and a new bug of SZ162411 net value estimation floated on water. On Friday, May 13, my estimation was about 1% higher than the official data. I began to check the problem yesterday, found that the last automatic calibration was done on the evening of May 12, after the official net value of May 11 data released. And the automatic calibration on May 13 was not done yet. In other words, the calibration was one day late for quite some time now, but when USDCNY had little change, the problem was ignored.
It was easy to find the bug, I used the simplest way to fix the estimation bug caused by continue Chinese and USA market close after Chinese New Year. Because only Hongkong QDII would have the chance of official QDII net value newer than ETF, I rewrote part of the code by checking if it was HK QDII, and modified an actually unrelated code, what should be $iHours = STOCK_HOUR_END + ($this->usdhkd_ref ? 0 : 24); was written as $iHours = STOCK_HOUR_END + ($this->usdhkd_ref) ? 0 : 24;
But this bug made me feel very bad, this time I can not say I am still a 6 years new PHP programmer. As a proud 25 years C programmer, this is also a very stupid bug in C language!

Automatic and manual calibration history

Oct 6, 2016
SZ162411 calibration history.

AR1688 Entertainment PA1688 PA3288 PA6488 Palmmicro

Resource Image Blog

No comments for this page yet.

More options? Please login or register account.