#encoding:gbk
import pandas as pd
import numpy as np
import talib
def init(ContextInfo):
stock_code_list=[] #股票代码列表
stock_code_list=ContextInfo.get_stock_list_in_sector('沪深A股') #获取沪深所有A股
#遍历A股所有股票,打印输出
for i in stock_code_list:
lastPrice_dict=ContextInfo.get_market_data_ex(['lastPrice'],[i],period='tick',count=1)
#lastPrice_dict=ContextInfo.get_market_data(['quoter'],[i],period='tick',count=-1)
print(lastPrice_dict)
def handlebar(ContextInfo):
pass
当使用get_market_data函数时,可以看到内存占用直线飙升
猜测主要原因是get_market_data获取quoter时,quoter的数据量比较大

而用get_market_data_ex只是单独获取一个lastPrice,数据量相对小很多。

而使用get_market_data_ex这个第二版函数的时候,内存占用,其他方面都很正常。既然做了升级,不知道为什么QMT没有把get_market_data这个函数抛弃了,反而还在文档中,让使用者傻傻分不清楚,只有掉坑里折腾半天才爬上来。