- nifty是印度國家證券交易所的股票指數。 *
我有一個名爲「livedata」的數據庫,其中表名爲nifty
這是印度國家證券交易所的股票指數。我有一排名爲20週期移動平均線計算nifty指數價格
ID爲主鍵,時間爲時間戳,cmp爲特定的「漂亮」股票指數。白天(09:15:01 AM至03:29:59 PM)分鐘
(1)我收到大約5個貿易條目。
例子: -
ID | time | cmp |
-----------------------------------
1 |2014-10-17 10:55:05 | 7743.85 |
2 |2014-10-17 10:55:15 | 7743.55 |
3 |2014-10-17 10:55:22 | 7743.35 |
4 |2014-10-17 10:55:34 | 7744.85 |
5 |2014-10-17 10:55:45 | 7743.35 |
6 |2014-10-17 10:55:56 | 7743.25 | this should be the last/closing trade Entry.
7 |2014-10-17 10:56:17 | 7743.15 |
8 |2014-10-17 10:56:25 | 7742.85 |
9 |2014-10-17 10:56:35 | 7742.25 |
10 |2014-10-17 10:56:45 | 7743.35 |
11 |2014-10-17 10:56:55 | 7742.65 | this should be the last/closing trade Entry.
12 |2014-10-17 10:57:23 | 7743.55 |
13 |2014-10-17 10:57:37 | 7744.85 |
14 |2014-10-17 10:57:46 | 7743.55 |
15 |2014-10-17 10:57:53 | 7741.85 |
16 |2014-10-17 10:57:56 | 7742.45 | this should be the last/closing trade Entry.
17 |2014-10-17 10:58:05 | 7743.85 |
18 |2014-10-17 10:58:17 | 7743.55 |
19 |2014-10-17 10:58:29 | 7743.35 |
20 |2014-10-17 10:58:37 | 7744.85 |
21 |2014-10-17 10:58:48 | 7743.35 |
22 |2014-10-17 10:58:56 | 7743.25 | this should be the last/closing trade Entry.
23 |2014-10-17 10:59:17 | 7743.15 |
24 |2014-10-17 10:59:21 | 7742.85 |
25 |2014-10-17 10:59:33 | 7742.25 |
26 |2014-10-17 10:59:43 | 7743.35 |
27 |2014-10-17 10:59:50 | 7742.65 |
28 |2014-10-17 10:59:57 | 7743.55 | this should be the last/closing trade Entry.
29 |2014-10-17 10:60:17 | 7744.85 |
30 |2014-10-17 10:60:25 | 7743.55 |
31 |2014-10-17 10:60:36 | 7741.85 |
32 |2014-10-17 10:60:47 | 7742.45 |this should be the last/closing trade Entry.
我想計算基於最後一個/收盤價爲每分鐘均線。對於單一(1)分鐘內的很多條目,我只需要最後一個交易條目。 實施例鹼所需的結果: -
ID | time | cmp |
-----------------------------------
6 |2014-10-17 10:55:56 | 7743.25 |
11 |2014-10-17 10:56:55 | 7742.65 |
16 |2014-10-17 10:57:56 | 7742.45 |
22 |2014-10-17 10:58:56 | 7743.25 |
28 |2014-10-17 10:59:57 | 7743.55 |
32 |2014-10-17 10:60:47 | 7742.45 |
例(移動平均= ADD 20期間,即最後20分鐘的每分鐘最後交易條目&除以20.值應該出現在
前端可能使用$ result = mysql_query($ query)或die( mysql_error());請建議..
如果我想要得到的每分鐘我怎麼寫PHP代碼的最後一個條目現在我使用
$query= "SELECT FROM nifty WHERE time BETWEEN '2014-10-17 10:55:05' AND '2014-10-17 10:60:47'";
實際結果取條目? -
ID Date Stamp CMP
1 2014-10-17 10:55:05 7743.85
2 2014-10-17 10:55:14 7743.75
3 2014-10-17 10:55:18 7745.30
4 2014-10-17 10:55:21 7745.35
5 2014-10-17 10:55:32 7745.10
6 2014-10-17 10:55:36 7744.85
7 2014-10-17 10:55:46 7744.40
8 2014-10-17 10:55:50 7744.70
9 2014-10-17 10:55:59 7745.60 this should be the last/closing trade Entry.
10 2014-10-17 10:56:06 7745.80
11 2014-10-17 10:56:11 7745.40
12 2014-10-17 10:56:23 7746.50
13 2014-10-17 10:56:32 7747.30
14 2014-10-17 10:56:34 7747.35
15 2014-10-17 10:56:41 7747.65
16 2014-10-17 10:56:52 7747.80
17 2014-10-17 10:56:56 7748.20 this should be the last/closing trade Entry.
18 2014-10-17 10:57:01 7747.80
19 2014-10-17 10:57:13 7747.75
20 2014-10-17 10:57:16 7747.55
21 2014-10-17 10:57:28 7747.50
22 2014-10-17 10:57:32 7746.95
23 2014-10-17 10:57:38 7746.55
24 2014-10-17 10:57:40 7746.70
25 2014-10-17 10:57:50 7747.25
26 2014-10-17 10:57:58 7746.55 this should be the last/closing trade Entry.
27 2014-10-17 10:58:09 7746.70
28 2014-10-17 10:58:11 7746.90
29 2014-10-17 10:58:17 7747.20
30 2014-10-17 10:58:26 7746.75
31 2014-10-17 10:58:33 7746.70
32 2014-10-17 10:58:37 7746.55 this should be the last/closing trade Entry.
33 2014-10-17 11:30:28 7748.35
34 2014-10-17 11:30:32 7748.95
35 2014-10-17 11:30:40 7749.95
36 2014-10-17 11:30:45 7749.05
37 2014-10-17 11:30:58 7748.95 this should be the last/closing trade Entry.
38 2014-10-17 11:31:03 7748.80
39 2014-10-17 11:31:08 7749.90
40 2014-10-17 11:31:12 7751.80
41 2014-10-17 11:31:26 7752.70
42 2014-10-17 11:31:33 7753.80
43 2014-10-17 11:31:33 7753.60
44 2014-10-17 11:31:39 7752.55
45 2014-10-17 11:31:50 7752.65
46 2014-10-17 11:31:56 7754.60 this should be the last/closing trade Entry.
47 2014-10-17 11:32:18 7755.15
48 2014-10-17 11:32:18 7755.35
49 2014-10-17 11:32:26 7755.25
50 2014-10-17 11:32:36 7754.45
51 2014-10-17 11:32:40 7754.90
52 2014-10-17 11:32:56 7754.40 this should be the last/closing trade Entry.
53 2014-10-17 11:33:10 7754.35
54 2014-10-17 11:33:12 7753.65
55 2014-10-17 11:33:15 7753.45
56 2014-10-17 11:33:22 7753.50
57 2014-10-17 11:33:25 7753.35
58 2014-10-17 11:33:34 7753.45
59 2014-10-17 11:33:39 7754.20
60 2014-10-17 11:33:49 7756.35
61 2014-10-17 11:33:50 7755.65
62 2014-10-17 11:33:54 7757.15 this should be the last/closing trade Entry.
63 2014-10-17 11:34:01 7759.05
我們可以使用循環,而這樣做嗎? 請幫忙解決這個很多提前感謝。
結果使用SELECT LOOP WHILE DO WHILE
等
歡迎來到Stack Overflow!這個問題在信息上有點短暫。你可以分享你的嘗試,並且遇到了什麼問題? 請閱讀[如何在StackOverflow上提問](http://stackoverflow.com/help/how-to-ask) – 2015-02-11 18:31:53
從什麼時候有'10:60'? – eggyal 2015-02-11 19:12:55