获取一分钟K线,返回的数据有问题,时间转换是用官方的,不知道是啥情况?
time_to_datetime(time)
async def Getsk(self, symbol, di_list): try: ''' di_list['klines'] = { 'xlsx_name':f'{symbols}_day', 'duration_seconds' : 60 * 60 * 24, 'data_length':120, } di_list['klines2'] = { 'xlsx_name':f'{symbols}_min', 'duration_seconds' : 60, 'data_length':120, } ''' k_duration_seconds = di_list.get('klines').get('duration_seconds') k_data_length = di_list.get('klines').get('data_length') k_xlsx_name = di_list.get('klines').get('xlsx_name') # k2_duration_seconds = di_list.get('klines2').get('duration_seconds') k2_data_length = di_list.get('klines2').get('data_length') k2_xlsx_name = di_list.get('klines2').get('xlsx_name') # 取K线 klines = SI.api.get_kline_serial(symbol, k_duration_seconds, k_data_length) klines2 = SI.api.get_kline_serial(symbol, k2_duration_seconds, k2_data_length) # # 设置净持仓 target_pos = TargetPosTask(SI.api, symbol) # 持仓信息 position = SI.api.get_position(symbol) async with SI.api.register_update_notify([klines, klines2]) as update_chan: # 确保收到了所有订阅的数据 while not SI.api.is_serial_ready(klines): await update_chan.recv() # 确保收到了所有订阅的数据 while not SI.api.is_serial_ready(klines2): await update_chan.recv() # 开始循环处理数据 async for _ in update_chan: # 大周期k线 if SI.api.is_changing(klines.iloc[-1], "datetime"): print(klines) # 小周期k线 if SI.api.is_changing(klines2.iloc[-1], "datetime"): # print(klines2) except TqTimeoutError as e: print('Getsk---Error', e) <img src="https://www.shinnytech.com/wp-content/uploads/anspress-temp/898d1351ac13f8ec267332c93377be82b77e54bd_4598.png" />
yao1234 未选择答案 2022年2月18日
datetime id open high low close volume open_oi close_oi symbol duration
2022-01-12 01:27:00 55210 4638 4640 4637 4639 210 738799 738848 SHFE.hc2205 60
2022-01-12 01:28:00 55211 4639 4642 4639 4642 557 738848 738952 SHFE.hc2205 60
2022-01-12 01:29:00 55212 4642 4644 4642 4643 646 738952 738898 SHFE.hc2205 60
2022-01-12 01:30:00 55213 4643 4644 4640 4641 476 738898 738930 SHFE.hc2205 60
2022-01-12 01:31:00 55214 4641 4646 4640 4643 814 738930 738978 SHFE.hc2205 60
2022-01-12 01:32:00 55215 4643 4654 4643 4651 1976 738978 738804 SHFE.hc2205 60
2022-01-12 01:33:00 55216 4651 4656 4651 4656 2040 738804 738926 SHFE.hc2205 60
2022-01-12 01:34:00 55217 4656 4659 4654 4659 2282 738926 739656 SHFE.hc2205 60
2022-01-12 01:35:00 55218 4659 4660 4656 4656 1397 739656 739381 SHFE.hc2205 60
2022-01-12 01:36:00 55219 4656 4660 4656 4659 998 739381 739618 SHFE.hc2205 60
2022-01-12 01:37:00 55220 4659 4664 4659 4664 3303 739618 739492 SHFE.hc2205 60
2022-01-12 01:38:00 55221 4664 4665 4661 4664 1916 739492 739707 SHFE.hc2205 60
2022-01-12 01:39:00 55222 4664 4665 4663 4665 846 739707 739830 SHFE.hc2205 60
2022-01-12 01:40:00 55223 4665 4667 4661 4661 3782 739830 740615 SHFE.hc2205 60
2022-01-12 01:41:00 55224 4661 4666 4661 4665 1154 740615 740690 SHFE.hc2205 60
2022-01-12 01:42:00 55225 4665 4667 4663 4664 1023 740690 740809 SHFE.hc2205 60
2022-01-12 01:43:00 55226 4664 4667 4661 4661 822 740809 740873 SHFE.hc2205 60
2022-01-12 01:44:00 55227 4661 4664 4661 4664 770 740873 740823 SHFE.hc2205 60
2022-01-12 01:45:00 55228 4664 4666 4659 4659 944 740823 741010 SHFE.hc2205 60
2022-01-12 01:46:00 55229 4659 4660 4654 4655 1322 741010 740847 SHFE.hc2205 60
2022-01-12 01:47:00 55230 4655 4659 4655 4658 343 740847 740886 SHFE.hc2205 60
2022-01-12 01:48:00 55231 4658 4660 4655 4655 516 740886 740919 SHFE.hc2205 60
2022-01-12 01:49:00 55232 4655 4660 4655 4660 354 740919 740892 SHFE.hc2205 60
2022-01-12 01:50:00 55233 4660 4660 4657 4657 282 740892 740964 SHFE.hc2205 60
2022-01-12 01:51:00 55234 4657 4658 4655 4657 291 740964 740957 SHFE.hc2205 60
2022-01-12 01:52:00 55235 4657 4657 4654 4654 182 740957 740944 SHFE.hc2205 60
2022-01-12 01:53:00 55236 4654 4654 4650 4652 789 740944 740720 SHFE.hc2205 60
2022-01-12 01:54:00 55237 4652 4657 4652 4655 433 740720 740802 SHFE.hc2205 60
2022-01-12 01:55:00 55238 4655 4657 4654 4656 236 740802 740721 SHFE.hc2205 60
2022-01-12 01:56:00 55239 4656 4660 4655 4660 578 740721 740758 SHFE.hc2205 60
2022-01-12 01:57:00 55240 4660 4664 4660 4663 1150 740758 740735 SHFE.hc2205 60
2022-01-12 01:58:00 55241 4663 4665 4662 4664 495 740735 740611 SHFE.hc2205 60
2022-01-12 01:59:00 55242 4664 4665 4662 4664 508 740611 740648 SHFE.hc2205 60
2022-01-12 02:00:00 55243 4664 4665 4658 4660 946 740648 740675 SHFE.hc2205 60
2022-01-12 02:01:00 55244 4660 4663 4659 4662 228 740675 740699 SHFE.hc2205 60
2022-01-12 02:02:00 55245 4662 4664 4661 4663 216 740699 740769 SHFE.hc2205 60
2022-01-12 02:03:00 55246 4663 4665 4660 4662 202 740769 740818 SHFE.hc2205 60
2022-01-12 02:04:00 55247 4662 4663 4659 4659 429 740818 741014 SHFE.hc2205 60
2022-01-12 02:05:00 55248 4659 4663 4658 4661 209 741014 741024 SHFE.hc2205 60
2022-01-12 02:06:00 55249 4661 4663 4658 4659 213 741024 741058 SHFE.hc2205 60
2022-01-12 02:07:00 55250 4659 4659 4654 4656 506 741058 741041 SHFE.hc2205 60
2022-01-12 02:08:00 55251 4656 4660 4655 4659 546 741041 741106 SHFE.hc2205 60
2022-01-12 02:09:00 55252 4659 4661 4659 4659 255 741106 741069 SHFE.hc2205 60
2022-01-12 02:10:00 55253 4659 4661 4658 4660 247 741069 741091 SHFE.hc2205 60
2022-01-12 02:11:00 55254 4660 4661 4656 4657 342 741091 741066 SHFE.hc2205 60
2022-01-12 02:12:00 55255 4657 4660 4655 4656 174 741066 741069 SHFE.hc2205 60
2022-01-12 02:13:00 55256 4656 4657 4647 4653 1600 741069 740604 SHFE.hc2205 60
2022-01-12 02:14:00 55257 4653 4656 4648 4648 799 740604 740463 SHFE.hc2205 60
2022-01-12 02:30:00 55258 4651 4656 4648 4648 2525 740463 740375 SHFE.hc2205 60
2022-01-12 02:31:00 55259 4648 4650 4641 4644 2707 740375 740449 SHFE.hc2205 60
2022-01-12 02:32:00 55260 4644 4648 4641 4645 2932 740449 740535 SHFE.hc2205 60
2022-01-12 02:33:00 55261 4645 4645 4640 4640 2558 740535 739778 SHFE.hc2205 60
2022-01-12 02:34:00 55262 4640 4645 4636 4637 3001 739778 739085 SHFE.hc2205 60
2022-01-12 02:35:00 55263 4637 4637 4632 4635 2539 739085 739320 SHFE.hc2205 60
2022-01-12 02:36:00 55264 4635 4637 4633 4636 1438 739320 739280 SHFE.hc2205 60
2022-01-12 02:37:00 55265 4636 4637 4632 4632 1101 739280 739409 SHFE.hc2205 60
2022-01-12 02:38:00 55266 4632 4637 4630 4636 2923 739409 738897 SHFE.hc2205 60
2022-01-12 02:39:00 55267 4636 4637 4633 4636 924 738897 738852 SHFE.hc2205 60
2022-01-12 02:40:00 55268 4636 4642 4634 4640 2290 738852 738330 SHFE.hc2205 60
2022-01-12 02:41:00 55269 4640 4640 4635 4637 616 738330 738443 SHFE.hc2205 60
2022-01-12 02:42:00 55270 4637 4637 4634 4636 451 738443 738488 SHFE.hc2205 60
2022-01-12 02:43:00 55271 4636 4637 4633 4636 637 738488 738555 SHFE.hc2205 60
2022-01-12 02:44:00 55272 4636 4643 4635 4638 933 738555 738613 SHFE.hc2205 60