In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)06/01 Report--
Kdb+ (db based on K language, enhanced version, also referred to as kdb) is a very minority database. It has very high performance and rich and efficient time series functions. In the field of access and real-time analysis of massive stocks, × × and other high-frequency data, only kdb is exclusive.
Kdb+ is a column-based in-memory database developed and sold by KxSystems. It is usually used for high-frequency trading and is very suitable for high-speed storage, analysis, processing and retrieval of large data sets. Kdb+ can process billions of records and analyze the data in the database. The database is available in 32-bit (free) and 64-bit versions through a variety of operating systems. Financial institutions use kdb+ to analyze time series data, such as stock or commodity trading data. The database is also used for other time-sensitive data applications, including stock and commodity trading, telecommunications, sensor data, log data, and machine and network usage monitoring.
Q language is a proprietary array processing language developed by Arthur Whitney and commercialized by Kx. This language is used as the query language for kdb+, and kdb+ is based on K (a variant of the APL language). The Q language is K concise packaging, which provides some readability.
Kdb+ 's rich time series functions can help us to calculate stocks easily. I have an A-share database based on Kdb. The daily table stores the daily line data of Shanghai A-shares and Shenzhen A-shares. Let's take a look at the data processing of Kdb+, and subsequent articles will explain how to use kdb and how to create this database.
1. Query the opening price (o), the highest price (o), the lowest price (l) and the closing price (c) of the stock (sym) on a certain day. The following results show only five pieces of data, and the rest are ignored.
Q) select from daily where date = 2016.11.10date sym o h l Cmurmuri November 10, 2016 000001 9.1 9.16 9.1 9.142016.11.10 000002 26 28.28 25.58 26.562016.11.10 000004 45 46.87 44.85 45. 32016.11.10 000005 7.45 7.68 7.44 7.532016.11.10 000006 10.09 10.17 10.06 10.12..
two。 Inquire about the price of 002695 of the stock in the last 10 trading days.
Q)-10#select from daily where sym= `002695date sym o h l Murray Murray, October 25, 2016 002695 26.03 27.5 24.55 26.732016.10.26 002695 25.9 27.89 25.82 26.856.10.27 002695 26.7 29.54 26.33 29.54 2016.11 . 02 002695 32.49 32.49 30.86 32.492016.11.03 002695 34 35.74 32.21 32.772016.11.04 002695 32.31 33.69 30.15 30.512016.11.07 002695 30.18 31 29.6 30.592016.11.08 002695 30.48 32.56 29.78 31.42016.11.09 002695 30.53 31.99 30.05 31.52016.11.10 002695 31.8 31.99 30.8 31.19
3. Calculate the simple moving average price of 002695 (Huang Shang Huang) for 5, 10 and 20 days
Q)-10#select date,sym,o,h,l,c, MA5:mavg [5 TAC], MA10:mavg [10 TAC], MA20:mavg [20] C] from daily where sym= `002695date sym o h l c MA5 MA10 MA20---2016.10.25 002695 26.03 27.5 24.55 26.73 23.044 20.108 18.7045 2016.10 . 26 002695 25.9 27.89 25.82 26.85 24.588 21.082 19.11552016.10.27 002695 26.7 29.54 26.33 29.54 26.288 22.351 19.632016.11.02 002695 32.49 32.49 30.86 32.49 28.184 23.86 20.3422016.11.03 002695 34 35.74 32.21 32.77 29.676 25.426 21.15352016.11.04 002695 32.31 33.69 30.15 30.51 30. 432 26.738 21.8342016.11.07 002695 30.18 31 29.6 30.59 31.18 27.884 22.52952016.11.08 002695 30.48 32.56 29.78 31.4 31.552 28.92 23.2892016.11.09 002695 30.53 31.99 30.05 31.5 31.354 29.769 24.052016.11.10 002695 31.8 31.99 30.8 31.19 31.038 30.357 24.757
4. Calculate the 10-day exponential moving average of 002695 (Huang Shanghuang)
Q)-10#select date,sym,o,h,l,c, MA5:ema [2% 1x 10 C] from daily where sym= `002695date sym o h l c MA5---2016.10.25 002695 26.03 27.5 24.55 26.73 21.396752016.10.26 002695 25.9 27.89 25.82 26.85 22.388252016.27 002695 26.7 29.54 26.33 29.54 23.688572016.11.02 002695 32.49 32.49 30.86 32.49 25.288832016.11.03 002695 34 35.74 32.21 32.77 26.649042016.11.04 002695 32.31 33.69 30.15 30.51 27.351032016.11.07 002695 30.18 31 29.6 30.59 27.939942016.11.08 002695 30.48 32.56 29.78 31.4 28.569042016.11.09 002695 30. 53 31.99 30.05 31.5 29.101942016.11.10 002695 31.8 31.99 30.8 31.19 29.48159
5. Find out the stock symbol that has reached an annual high in the last 20 trading days.
Q) 10 cut exec distinct sym from daily where 1b = ({(max-250roomx) = max-20roomx}; c) fby sym,2016.11.10= (last;date) fby sym000019 000034 000338 000404 000510 000513 000518 000550 567000568 000581 000615 000635 000639 000661 000678 000723 000731 000818 000820 000823 000881 000889 000895 910 00092000913 000915 935 000937 000953 959 000960 000993 2010050 200051 2000885 200088 2094 210013 2122 2400 2132 2141 210050 2400200132 2141 210050 2167 20012 220012 220064 17000033 230052 23006230074 230086 240056 240056 240056
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.