思路:通过1m行情推导5m,15m,30m等行情数据
方法:用python 读取1M到 dataframe 里,然后resample
目的:减少聚宽本地化数据存储
df = get_price('000001.XSHE', start_date='2019-07-09', end_date='2019-07-10', frequency='1m')
df
open | close | high | low | volume | money | |
---|---|---|---|---|---|---|
2019-07-09 09:31:00 | 13.63 | 13.67 | 13.68 | 13.63 | 1143400.0 | 15596355.0 |
2019-07-09 09:32:00 | 13.67 | 13.69 | 13.70 | 13.67 | 783800.0 | 10727583.0 |
2019-07-09 09:33:00 | 13.69 | 13.68 | 13.71 | 13.68 | 540900.0 | 7405717.0 |
2019-07-09 09:34:00 | 13.68 | 13.69 | 13.70 | 13.68 | 411500.0 | 5632185.0 |
2019-07-09 09:35:00 | 13.70 | 13.68 | 13.70 | 13.68 | 486100.0 | 6654323.0 |
2019-07-09 09:36:00 | 13.68 | 13.67 | 13.69 | 13.67 | 272800.0 | 3731108.0 |
2019-07-09 09:37:00 | 13.66 | 13.67 | 13.69 | 13.66 | 171300.0 | 2342662.0 |
2019-07-09 09:38:00 | 13.67 | 13.68 | 13.68 | 13.66 | 282000.0 | 3853614.0 |
2019-07-09 09:39:00 | 13.68 | 13.66 | 13.68 | 13.66 | 168600.0 | 2304859.0 |
2019-07-09 09:40:00 | 13.66 | 13.65 | 13.67 | 13.65 | 203900.0 | 2785913.0 |
2019-07-09 09:41:00 | 13.65 | 13.63 | 13.65 | 13.62 | 261800.0 | 3569102.0 |
2019-07-09 09:42:00 | 13.63 | 13.63 | 13.64 | 13.61 | 273500.0 | 3727157.0 |
2019-07-09 09:43:00 | 13.64 | 13.64 | 13.65 | 13.64 | 170800.0 | 2331083.0 |
2019-07-09 09:44:00 | 13.65 | 13.64 | 13.65 | 13.62 | 315700.0 | 4306803.0 |
2019-07-09 09:45:00 | 13.63 | 13.60 | 13.64 | 13.60 | 313100.0 | 4260555.0 |
2019-07-09 09:46:00 | 13.60 | 13.63 | 13.63 | 13.60 | 134100.0 | 1825819.0 |
2019-07-09 09:47:00 | 13.62 | 13.59 | 13.63 | 13.59 | 385700.0 | 5247569.0 |
2019-07-09 09:48:00 | 13.59 | 13.58 | 13.59 | 13.58 | 245100.0 | 3329665.0 |
2019-07-09 09:49:00 | 13.57 | 13.59 | 13.60 | 13.57 | 226800.0 | 3081024.0 |
2019-07-09 09:50:00 | 13.59 | 13.60 | 13.60 | 13.56 | 169400.0 | 2300557.0 |
2019-07-09 09:51:00 | 13.59 | 13.61 | 13.61 | 13.59 | 453900.0 | 6171954.0 |
2019-07-09 09:52:00 | 13.60 | 13.60 | 13.60 | 13.59 | 364400.0 | 4955388.0 |
2019-07-09 09:53:00 | 13.60 | 13.60 | 13.62 | 13.60 | 356800.0 | 4853578.0 |
2019-07-09 09:54:00 | 13.60 | 13.60 | 13.61 | 13.59 | 100500.0 | 1366567.0 |
2019-07-09 09:55:00 | 13.61 | 13.61 | 13.62 | 13.60 | 121900.0 | 1659043.0 |
2019-07-09 09:56:00 | 13.61 | 13.62 | 13.62 | 13.60 | 116400.0 | 1584391.0 |
2019-07-09 09:57:00 | 13.62 | 13.64 | 13.65 | 13.62 | 145100.0 | 1977713.0 |
2019-07-09 09:58:00 | 13.65 | 13.65 | 13.65 | 13.64 | 133200.0 | 1817718.0 |
2019-07-09 09:59:00 | 13.65 | 13.64 | 13.65 | 13.63 | 135200.0 | 1844973.0 |
2019-07-09 10:00:00 | 13.65 | 13.64 | 13.65 | 13.63 | 99500.0 | 1357421.0 |
... | ... | ... | ... | ... | ... | ... |
2019-07-09 14:31:00 | 13.58 | 13.58 | 13.59 | 13.58 | 117200.0 | 1592258.0 |
2019-07-09 14:32:00 | 13.59 | 13.59 | 13.59 | 13.58 | 113800.0 | 1545852.0 |
2019-07-09 14:33:00 | 13.58 | 13.59 | 13.60 | 13.58 | 100400.0 | 1364174.0 |
2019-07-09 14:34:00 | 13.58 | 13.57 | 13.59 | 13.57 | 67700.0 | 919268.0 |
2019-07-09 14:35:00 | 13.58 | 13.57 | 13.59 | 13.57 | 177800.0 | 2414611.0 |
2019-07-09 14:36:00 | 13.57 | 13.57 | 13.58 | 13.57 | 99800.0 | 1354903.0 |
2019-07-09 14:37:00 | 13.57 | 13.57 | 13.58 | 13.57 | 94300.0 | 1280156.0 |
2019-07-09 14:38:00 | 13.57 | 13.57 | 13.58 | 13.57 | 109200.0 | 1482393.0 |
2019-07-09 14:39:00 | 13.57 | 13.57 | 13.58 | 13.57 | 64700.0 | 878053.0 |
2019-07-09 14:40:00 | 13.57 | 13.56 | 13.58 | 13.56 | 75700.0 | 1026956.0 |
2019-07-09 14:41:00 | 13.56 | 13.56 | 13.57 | 13.56 | 83300.0 | 1129664.0 |
2019-07-09 14:42:00 | 13.56 | 13.57 | 13.57 | 13.56 | 89300.0 | 1211393.0 |
2019-07-09 14:43:00 | 13.56 | 13.56 | 13.56 | 13.55 | 221100.0 | 2998109.0 |
2019-07-09 14:44:00 | 13.56 | 13.58 | 13.58 | 13.55 | 176600.0 | 2394734.0 |
2019-07-09 14:45:00 | 13.58 | 13.55 | 13.58 | 13.55 | 320100.0 | 4338364.0 |
2019-07-09 14:46:00 | 13.54 | 13.54 | 13.55 | 13.54 | 202800.0 | 2746928.0 |
2019-07-09 14:47:00 | 13.55 | 13.55 | 13.56 | 13.54 | 154000.0 | 2086493.0 |
2019-07-09 14:48:00 | 13.55 | 13.56 | 13.57 | 13.55 | 96500.0 | 1308327.0 |
2019-07-09 14:49:00 | 13.57 | 13.56 | 13.58 | 13.55 | 175400.0 | 2378805.0 |
2019-07-09 14:50:00 | 13.55 | 13.55 | 13.56 | 13.55 | 73100.0 | 991180.0 |
2019-07-09 14:51:00 | 13.56 | 13.57 | 13.58 | 13.56 | 229800.0 | 3117588.0 |
2019-07-09 14:52:00 | 13.56 | 13.58 | 13.58 | 13.56 | 208000.0 | 2822832.0 |
2019-07-09 14:53:00 | 13.57 | 13.58 | 13.58 | 13.55 | 83700.0 | 1135359.0 |
2019-07-09 14:54:00 | 13.57 | 13.56 | 13.59 | 13.56 | 422900.0 | 5741235.0 |
2019-07-09 14:55:00 | 13.56 | 13.57 | 13.58 | 13.55 | 198400.0 | 2690498.0 |
2019-07-09 14:56:00 | 13.56 | 13.56 | 13.57 | 13.56 | 158100.0 | 2143902.0 |
2019-07-09 14:57:00 | 13.56 | 13.56 | 13.57 | 13.55 | 112600.0 | 1527141.0 |
2019-07-09 14:58:00 | 13.56 | 13.56 | 13.56 | 13.56 | 5000.0 | 67842.0 |
2019-07-09 14:59:00 | 13.56 | 13.56 | 13.56 | 13.56 | 0.0 | 0.0 |
2019-07-09 15:00:00 | 13.59 | 13.59 | 13.59 | 13.59 | 1986400.0 | 26995176.0 |
240 rows × 6 columns
df.resample('5min',closed='right').sum()
open | close | high | low | volume | money | |
---|---|---|---|---|---|---|
2019-07-09 09:30:00 | 68.37 | 68.41 | 68.49 | 68.34 | 3365700.0 | 46016163.0 |
2019-07-09 09:35:00 | 68.35 | 68.33 | 68.41 | 68.30 | 1098600.0 | 15018156.0 |
2019-07-09 09:40:00 | 68.20 | 68.14 | 68.23 | 68.09 | 1334900.0 | 18194700.0 |
2019-07-09 09:45:00 | 67.97 | 67.99 | 68.05 | 67.90 | 1161100.0 | 15784634.0 |
2019-07-09 09:50:00 | 68.00 | 68.02 | 68.06 | 67.97 | 1397500.0 | 19006530.0 |
2019-07-09 09:55:00 | 68.18 | 68.19 | 68.22 | 68.12 | 629400.0 | 8582216.0 |
2019-07-09 10:00:00 | 68.08 | 68.11 | 68.17 | 68.05 | 586200.0 | 7982295.0 |
2019-07-09 10:05:00 | 68.05 | 68.01 | 68.09 | 67.95 | 788000.0 | 10721514.0 |
2019-07-09 10:10:00 | 67.99 | 67.98 | 68.05 | 67.93 | 933100.0 | 12682380.0 |
2019-07-09 10:15:00 | 67.98 | 67.96 | 68.01 | 67.94 | 624300.0 | 8486493.0 |
2019-07-09 10:20:00 | 68.01 | 68.01 | 68.05 | 67.99 | 710300.0 | 9661509.0 |
2019-07-09 10:25:00 | 67.92 | 67.91 | 67.98 | 67.85 | 1331100.0 | 18078771.0 |
2019-07-09 10:30:00 | 67.86 | 67.86 | 67.92 | 67.81 | 876900.0 | 11896633.0 |
2019-07-09 10:35:00 | 67.86 | 67.81 | 67.87 | 67.77 | 511200.0 | 6931454.0 |
2019-07-09 10:40:00 | 67.83 | 67.82 | 67.87 | 67.75 | 865000.0 | 11725203.0 |
2019-07-09 10:45:00 | 67.74 | 67.74 | 67.77 | 67.70 | 618500.0 | 8376086.0 |
2019-07-09 10:50:00 | 67.55 | 67.54 | 67.60 | 67.48 | 2608200.0 | 35182527.0 |
2019-07-09 10:55:00 | 67.43 | 67.45 | 67.49 | 67.39 | 1253000.0 | 16887068.0 |
2019-07-09 11:00:00 | 67.44 | 67.44 | 67.48 | 67.37 | 2468900.0 | 33246169.0 |
2019-07-09 11:05:00 | 67.50 | 67.53 | 67.57 | 67.48 | 773300.0 | 10438367.0 |
2019-07-09 11:10:00 | 67.54 | 67.52 | 67.64 | 67.46 | 769800.0 | 10401557.0 |
2019-07-09 11:15:00 | 67.43 | 67.41 | 67.47 | 67.38 | 545100.0 | 7349661.0 |
2019-07-09 11:20:00 | 67.37 | 67.37 | 67.42 | 67.32 | 735600.0 | 9911370.0 |
2019-07-09 11:25:00 | 67.41 | 67.40 | 67.47 | 67.37 | 604700.0 | 8156699.0 |
2019-07-09 11:30:00 | 0.00 | 0.00 | 0.00 | 0.00 | 0.0 | 0.0 |
2019-07-09 11:35:00 | 0.00 | 0.00 | 0.00 | 0.00 | 0.0 | 0.0 |
2019-07-09 11:40:00 | 0.00 | 0.00 | 0.00 | 0.00 | 0.0 | 0.0 |
2019-07-09 11:45:00 | 0.00 | 0.00 | 0.00 | 0.00 | 0.0 | 0.0 |
2019-07-09 11:50:00 | 0.00 | 0.00 | 0.00 | 0.00 | 0.0 | 0.0 |
2019-07-09 11:55:00 | 0.00 | 0.00 | 0.00 | 0.00 | 0.0 | 0.0 |
... | ... | ... | ... | ... | ... | ... |
2019-07-09 12:30:00 | 0.00 | 0.00 | 0.00 | 0.00 | 0.0 | 0.0 |
2019-07-09 12:35:00 | 0.00 | 0.00 | 0.00 | 0.00 | 0.0 | 0.0 |
2019-07-09 12:40:00 | 0.00 | 0.00 | 0.00 | 0.00 | 0.0 | 0.0 |
2019-07-09 12:45:00 | 0.00 | 0.00 | 0.00 | 0.00 | 0.0 | 0.0 |
2019-07-09 12:50:00 | 0.00 | 0.00 | 0.00 | 0.00 | 0.0 | 0.0 |
2019-07-09 12:55:00 | 0.00 | 0.00 | 0.00 | 0.00 | 0.0 | 0.0 |
2019-07-09 13:00:00 | 67.47 | 67.48 | 67.53 | 67.40 | 964000.0 | 13002987.0 |
2019-07-09 13:05:00 | 67.71 | 67.74 | 67.77 | 67.67 | 695700.0 | 9422106.0 |
2019-07-09 13:10:00 | 67.73 | 67.73 | 67.77 | 67.70 | 422500.0 | 5723518.0 |
2019-07-09 13:15:00 | 67.73 | 67.70 | 67.75 | 67.65 | 672500.0 | 9103390.0 |
2019-07-09 13:20:00 | 67.58 | 67.59 | 67.64 | 67.54 | 816100.0 | 11031583.0 |
2019-07-09 13:25:00 | 67.60 | 67.61 | 67.64 | 67.57 | 433100.0 | 5854292.0 |
2019-07-09 13:30:00 | 67.60 | 67.62 | 67.65 | 67.55 | 451200.0 | 6099373.0 |
2019-07-09 13:35:00 | 67.67 | 67.61 | 67.72 | 67.57 | 477500.0 | 6457281.0 |
2019-07-09 13:40:00 | 67.60 | 67.62 | 67.67 | 67.54 | 1855600.0 | 25107706.0 |
2019-07-09 13:45:00 | 67.59 | 67.62 | 67.68 | 67.50 | 617700.0 | 8348572.0 |
2019-07-09 13:50:00 | 67.55 | 67.53 | 67.60 | 67.46 | 751800.0 | 10149509.0 |
2019-07-09 13:55:00 | 67.66 | 67.69 | 67.72 | 67.62 | 435800.0 | 5898325.0 |
2019-07-09 14:00:00 | 67.78 | 67.82 | 67.88 | 67.76 | 1122900.0 | 15234098.0 |
2019-07-09 14:05:00 | 67.84 | 67.83 | 67.90 | 67.78 | 1992400.0 | 27018603.0 |
2019-07-09 14:10:00 | 67.91 | 67.92 | 67.97 | 67.86 | 1458000.0 | 19815209.0 |
2019-07-09 14:15:00 | 67.96 | 68.00 | 68.03 | 67.93 | 739000.0 | 10046584.0 |
2019-07-09 14:20:00 | 68.06 | 68.00 | 68.08 | 67.95 | 1596700.0 | 21740864.0 |
2019-07-09 14:25:00 | 67.95 | 67.96 | 67.99 | 67.90 | 1319400.0 | 17935345.0 |
2019-07-09 14:30:00 | 67.91 | 67.90 | 67.96 | 67.88 | 576900.0 | 7836163.0 |
2019-07-09 14:35:00 | 67.85 | 67.84 | 67.90 | 67.84 | 443700.0 | 6022461.0 |
2019-07-09 14:40:00 | 67.82 | 67.82 | 67.86 | 67.77 | 890400.0 | 12072264.0 |
2019-07-09 14:45:00 | 67.76 | 67.76 | 67.82 | 67.73 | 701800.0 | 9511733.0 |
2019-07-09 14:50:00 | 67.82 | 67.86 | 67.91 | 67.78 | 1142800.0 | 15507512.0 |
2019-07-09 14:55:00 | 67.83 | 67.83 | 67.85 | 67.82 | 2262100.0 | 30734061.0 |
66 rows × 6 columns
本社区仅针对特定人员开放
查看需注册登录并通过风险意识测评
5秒后跳转登录页面...
移动端课程