def tns_switch_short_pos(self, open_new=True):
    '\n        切换合约，从持仓的非主力合约，切换至主力合约\n        :param open_new: 是否开仓新得主力合约\n        :return:\n        '
    if (self.entrust != 0):
        return
    if (self.position.short_pos == 0):
        return
    if (self.cur_mi_price == 0):
        return
    none_mi_grid = None
    none_mi_symbol = None
    for g in self.gt.get_opened_grids(direction=Direction.SHORT):
        none_mi_symbol = g.snapshot.get('mi_symbol')
        if ((none_mi_symbol is None) or (none_mi_symbol == self.vt_symbol)):
            continue
        if ((not g.open_status) or g.order_status or ((g.volume - g.traded_volume) <= 0)):
            continue
        none_mi_grid = g
        if ((g.traded_volume > 0) and ((g.volume - g.traded_volume) > 0)):
            g.volume -= g.traded_volume
            g.traded_volume = 0
        break
    if (none_mi_grid is None):
        return
    none_mi_tick = self.tick_dict.get(none_mi_symbol)
    mi_tick = self.tick_dict.get(self.vt_symbol, None)
    if ((none_mi_tick is None) or (mi_tick is None)):
        return
    if (self.is_lower_limit(none_mi_symbol) or self.is_lower_limit(self.vt_symbol)):
        return
    none_mi_price = max(none_mi_tick.last_price, none_mi_tick.bid_price_1)
    grid = deepcopy(none_mi_grid)
    grid.id = str(uuid.uuid1())
    vt_orderids = self.cover(price=none_mi_price, volume=none_mi_grid.volume, vt_symbol=none_mi_symbol, order_type=self.order_type, grid=none_mi_grid)
    if (len(vt_orderids) > 0):
        self.write_log(f'委托平空非主力合约{none_mi_symbol}持仓:{none_mi_grid.volume}')
        if none_mi_grid.snapshot.get('switched', False):
            self.write_log(f'已经执行过换月，不再创建新的空操作')
            return
        none_mi_grid.snapshot.update({'switched': True})
        if (not open_new):
            self.write_log(f'不开空新的主力合约:{self.vt_symbol},数量:{grid.volume}')
            self.gt.save()
            return
        grid.id = str(uuid.uuid1())
        grid.snapshot.update({'mi_symbol': self.vt_symbol, 'open_price': self.cur_mi_price})
        self.gt.up_grids.append(grid)
        vt_orderids = self.short(price=self.cur_mi_price, volume=grid.volume, vt_symbol=self.vt_symbol, order_type=self.order_type, grid=grid)
        if (len(vt_orderids) > 0):
            self.write_log(f'委托做空主力合约:{self.vt_symbol},价格:{self.cur_mi_price},数量:{grid.volume}')
        else:
            self.write_error(f'委托做空主力合约:{self.vt_symbol}失败')
        self.gt.save()
    else:
        self.write_error(f'委托平空非主力合约:{none_mi_symbol}失败')
切换合约，从持仓的非主力合约，切换至主力合约
:param open_new: 是否开仓新得主力合约
:return:
def tns_switch_short_pos(self, open_new=True):
    '\n        切换合约，从持仓的非主力合约，切换至主力合约\n        :param open_new: 是否开仓新得主力合约\n        :return:\n        '
    if (self.entrust != 0):
        return
    if (self.position.short_pos == 0):
        return
    if (self.cur_mi_price == 0):
        return
    none_mi_grid = None
    none_mi_symbol = None
    for g in self.gt.get_opened_grids(direction=Direction.SHORT):
        none_mi_symbol = g.snapshot.get('mi_symbol')
        if ((none_mi_symbol is None) or (none_mi_symbol == self.vt_symbol)):
            continue
        if ((not g.open_status) or g.order_status or ((g.volume - g.traded_volume) <= 0)):
            continue
        none_mi_grid = g
        if ((g.traded_volume > 0) and ((g.volume - g.traded_volume) > 0)):
            g.volume -= g.traded_volume
            g.traded_volume = 0
        break
    if (none_mi_grid is None):
        return
    none_mi_tick = self.tick_dict.get(none_mi_symbol)
    mi_tick = self.tick_dict.get(self.vt_symbol, None)
    if ((none_mi_tick is None) or (mi_tick is None)):
        return
    if (self.is_lower_limit(none_mi_symbol) or self.is_lower_limit(self.vt_symbol)):
        return
    none_mi_price = max(none_mi_tick.last_price, none_mi_tick.bid_price_1)
    grid = deepcopy(none_mi_grid)
    grid.id = str(uuid.uuid1())
    vt_orderids = self.cover(price=none_mi_price, volume=none_mi_grid.volume, vt_symbol=none_mi_symbol, order_type=self.order_type, grid=none_mi_grid)
    if (len(vt_orderids) > 0):
        self.write_log(f'委托平空非主力合约{none_mi_symbol}持仓:{none_mi_grid.volume}')
        if none_mi_grid.snapshot.get('switched', False):
            self.write_log(f'已经执行过换月，不再创建新的空操作')
            return
        none_mi_grid.snapshot.update({'switched': True})
        if (not open_new):
            self.write_log(f'不开空新的主力合约:{self.vt_symbol},数量:{grid.volume}')
            self.gt.save()
            return
        grid.id = str(uuid.uuid1())
        grid.snapshot.update({'mi_symbol': self.vt_symbol, 'open_price': self.cur_mi_price})
        self.gt.up_grids.append(grid)
        vt_orderids = self.short(price=self.cur_mi_price, volume=grid.volume, vt_symbol=self.vt_symbol, order_type=self.order_type, grid=grid)
        if (len(vt_orderids) > 0):
            self.write_log(f'委托做空主力合约:{self.vt_symbol},价格:{self.cur_mi_price},数量:{grid.volume}')
        else:
            self.write_error(f'委托做空主力合约:{self.vt_symbol}失败')
        self.gt.save()
    else:
        self.write_error(f'委托平空非主力合约:{none_mi_symbol}失败')