def get_positions(self):
    "\n        获取策略当前持仓(重构，使用主力合约）\n        :return: [{'vt_symbol':symbol,'direction':direction,'volume':volume]\n        "
    if (not self.position):
        return []
    pos_list = []
    if (self.position.long_pos > 0):
        for g in self.gt.get_opened_grids(direction=Direction.LONG):
            vt_symbol = g.snapshot.get('mi_symbol', (g.vt_symbol if (g.vt_symbol and ('99' not in g.vt_symbol)) else self.vt_symbol))
            open_price = g.snapshot.get('open_price', g.open_price)
            pos_list.append({'vt_symbol': vt_symbol, 'direction': 'long', 'volume': (g.volume - g.traded_volume), 'price': open_price})
    if (abs(self.position.short_pos) > 0):
        for g in self.gt.get_opened_grids(direction=Direction.SHORT):
            vt_symbol = g.snapshot.get('mi_symbol', (g.vt_symbol if (g.vt_symbol and ('99' not in g.vt_symbol)) else self.vt_symbol))
            open_price = g.snapshot.get('open_price', g.open_price)
            pos_list.append({'vt_symbol': vt_symbol, 'direction': 'short', 'volume': abs((g.volume - g.traded_volume)), 'price': open_price})
    if (self.cur_datetime and ((datetime.now() - self.cur_datetime).total_seconds() < 10)):
        self.write_log(u'当前持仓:{}'.format(pos_list))
    return pos_list
获取策略当前持仓(重构，使用主力合约）
:return: [{'vt_symbol':symbol,'direction':direction,'volume':volume]
def get_positions(self):
    "\n        获取策略当前持仓(重构，使用主力合约）\n        :return: [{'vt_symbol':symbol,'direction':direction,'volume':volume]\n        "
    if (not self.position):
        return []
    pos_list = []
    if (self.position.long_pos > 0):
        for g in self.gt.get_opened_grids(direction=Direction.LONG):
            vt_symbol = g.snapshot.get('mi_symbol', (g.vt_symbol if (g.vt_symbol and ('99' not in g.vt_symbol)) else self.vt_symbol))
            open_price = g.snapshot.get('open_price', g.open_price)
            pos_list.append({'vt_symbol': vt_symbol, 'direction': 'long', 'volume': (g.volume - g.traded_volume), 'price': open_price})
    if (abs(self.position.short_pos) > 0):
        for g in self.gt.get_opened_grids(direction=Direction.SHORT):
            vt_symbol = g.snapshot.get('mi_symbol', (g.vt_symbol if (g.vt_symbol and ('99' not in g.vt_symbol)) else self.vt_symbol))
            open_price = g.snapshot.get('open_price', g.open_price)
            pos_list.append({'vt_symbol': vt_symbol, 'direction': 'short', 'volume': abs((g.volume - g.traded_volume)), 'price': open_price})
    if (self.cur_datetime and ((datetime.now() - self.cur_datetime).total_seconds() < 10)):
        self.write_log(u'当前持仓:{}'.format(pos_list))
    return pos_list