def price_vol_factor(code):#排序用价量因子
    cutime = GetCurrentTime()
    if cutime.hour==9 and cutime.minute==0 and cutime.second==0:
        g.open_price_day=GetQuote(code).now
    if cutime.hour==21 and cutime.minute==0 and cutime.second==0:
        g.open_price_night=GetQuote(code).now
    print('test:open_price_night: '+str(g.open_price_night))

    if cutime.hour>=8 and cutime.hour<=15: #日盘时
        rate_of_price=(GetQuote(code).now-g.open_price_day)/g.open_price_day*100
    else: #夜盘时
        rate_of_price=(GetQuote(code).now-g.open_price_night)/g.open_price_night*100

    return rate_of_price #返回品种的价格涨跌幅因子

单个品种使用该函数没有问题,正确返回,但是多品种比如(m,y,rb)循环时,全局变量g.open_price_day和g.open_price_day会出问题,开盘第一根k线返回正常,但是第二根k线时,比如m品种,g.open_price_night依然是上根k线rb的开盘价,而不是m的开盘价,怎么解决这个问题?