def grid_check_stop(self):
    '\n        网格逐一止损/止盈检查 (根据指数价格进行止损止盈）\n        :return:\n        '
    if (self.entrust != 0):
        return
    if (not self.trading):
        if (not self.backtesting):
            self.write_error(u'当前不允许交易')
        return
    long_grids = self.gt.get_opened_grids_without_types(direction=Direction.LONG, types=[LOCK_GRID])
    for g in long_grids:
        if ((g.stop_price > 0) and (g.stop_price > self.cur_99_price) and g.open_status and (not g.order_status)):
            dist_record = dict()
            dist_record['datetime'] = self.cur_datetime
            dist_record['symbol'] = self.idx_symbol
            dist_record['volume'] = g.volume
            dist_record['price'] = self.cur_99_price
            dist_record['operation'] = 'stop leave'
            dist_record['signals'] = '{}<{}'.format(self.cur_99_price, g.stop_price)
            self.write_log(u'{} 指数价:{} 触发多单止损线{},{}当前价:{}。指数开仓价:{},主力开仓价:{},v：{}'.format(self.cur_datetime, self.cur_99_price, g.stop_price, self.vt_symbol, self.cur_mi_price, g.open_price, g.snapshot.get('open_price'), g.volume))
            self.save_dist(dist_record)
            if self.tns_close_long_pos(g):
                self.write_log(u'多单止盈/止损委托成功')
            else:
                self.write_error(u'多单止损委托失败')
    short_grids = self.gt.get_opened_grids_without_types(direction=Direction.SHORT, types=[LOCK_GRID])
    for g in short_grids:
        if ((g.stop_price > 0) and (g.stop_price < self.cur_99_price) and g.open_status and (not g.order_status)):
            dist_record = dict()
            dist_record['datetime'] = self.cur_datetime
            dist_record['symbol'] = self.idx_symbol
            dist_record['volume'] = g.volume
            dist_record['price'] = self.cur_99_price
            dist_record['operation'] = 'stop leave'
            dist_record['signals'] = '{}<{}'.format(self.cur_99_price, g.stop_price)
            self.write_log(u'{} 指数价:{} 触发空单止损线:{},{}最新价:{}。指数开仓价:{},主力开仓价:{},v：{}'.format(self.cur_datetime, self.cur_99_price, g.stop_price, self.vt_symbol, self.cur_mi_price, g.open_price, g.snapshot.get('open_price'), g.volume))
            self.save_dist(dist_record)
            if self.tns_close_short_pos(g):
                self.write_log(u'空单止盈/止损委托成功')
            else:
                self.write_error(u'委托空单平仓失败')
网格逐一止损/止盈检查 (根据指数价格进行止损止盈）
:return:
def grid_check_stop(self):
    '\n        网格逐一止损/止盈检查 (根据指数价格进行止损止盈）\n        :return:\n        '
    if (self.entrust != 0):
        return
    if (not self.trading):
        if (not self.backtesting):
            self.write_error(u'当前不允许交易')
        return
    long_grids = self.gt.get_opened_grids_without_types(direction=Direction.LONG, types=[LOCK_GRID])
    for g in long_grids:
        if ((g.stop_price > 0) and (g.stop_price > self.cur_99_price) and g.open_status and (not g.order_status)):
            dist_record = dict()
            dist_record['datetime'] = self.cur_datetime
            dist_record['symbol'] = self.idx_symbol
            dist_record['volume'] = g.volume
            dist_record['price'] = self.cur_99_price
            dist_record['operation'] = 'stop leave'
            dist_record['signals'] = '{}<{}'.format(self.cur_99_price, g.stop_price)
            self.write_log(u'{} 指数价:{} 触发多单止损线{},{}当前价:{}。指数开仓价:{},主力开仓价:{},v：{}'.format(self.cur_datetime, self.cur_99_price, g.stop_price, self.vt_symbol, self.cur_mi_price, g.open_price, g.snapshot.get('open_price'), g.volume))
            self.save_dist(dist_record)
            if self.tns_close_long_pos(g):
                self.write_log(u'多单止盈/止损委托成功')
            else:
                self.write_error(u'多单止损委托失败')
    short_grids = self.gt.get_opened_grids_without_types(direction=Direction.SHORT, types=[LOCK_GRID])
    for g in short_grids:
        if ((g.stop_price > 0) and (g.stop_price < self.cur_99_price) and g.open_status and (not g.order_status)):
            dist_record = dict()
            dist_record['datetime'] = self.cur_datetime
            dist_record['symbol'] = self.idx_symbol
            dist_record['volume'] = g.volume
            dist_record['price'] = self.cur_99_price
            dist_record['operation'] = 'stop leave'
            dist_record['signals'] = '{}<{}'.format(self.cur_99_price, g.stop_price)
            self.write_log(u'{} 指数价:{} 触发空单止损线:{},{}最新价:{}。指数开仓价:{},主力开仓价:{},v：{}'.format(self.cur_datetime, self.cur_99_price, g.stop_price, self.vt_symbol, self.cur_mi_price, g.open_price, g.snapshot.get('open_price'), g.volume))
            self.save_dist(dist_record)
            if self.tns_close_short_pos(g):
                self.write_log(u'空单止盈/止损委托成功')
            else:
                self.write_error(u'委托空单平仓失败')