repo stringclasses 85
values | path stringlengths 8 121 | func_name stringlengths 1 82 | original_string stringlengths 112 65.5k | language stringclasses 1
value | code stringlengths 112 65.5k | code_tokens listlengths 20 4.09k | docstring stringlengths 3 46.3k | docstring_tokens listlengths 1 564 | sha stringclasses 85
values | url stringlengths 93 218 | partition stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|
ricequant/rqalpha | rqalpha/mod/rqalpha_mod_sys_transaction_cost/deciders.py | StockTransactionCostDecider.get_trade_commission | def get_trade_commission(self, trade):
"""
计算手续费这个逻辑比较复杂,按照如下算法来计算:
1. 定义一个剩余手续费的概念,根据order_id存储在commission_map中,默认为min_commission
2. 当trade来时计算该trade产生的手续费cost_money
3. 如果cost_money > commission
3.1 如果commission 等于 min_commission,说明这是第一笔trade,此时,直接commission置0,返回c... | python | def get_trade_commission(self, trade):
"""
计算手续费这个逻辑比较复杂,按照如下算法来计算:
1. 定义一个剩余手续费的概念,根据order_id存储在commission_map中,默认为min_commission
2. 当trade来时计算该trade产生的手续费cost_money
3. 如果cost_money > commission
3.1 如果commission 等于 min_commission,说明这是第一笔trade,此时,直接commission置0,返回c... | [
"def",
"get_trade_commission",
"(",
"self",
",",
"trade",
")",
":",
"order_id",
"=",
"trade",
".",
"order_id",
"if",
"self",
".",
"env",
".",
"data_proxy",
".",
"instruments",
"(",
"trade",
".",
"order_book_id",
")",
".",
"type",
"==",
"'PublicFund'",
":",... | 计算手续费这个逻辑比较复杂,按照如下算法来计算:
1. 定义一个剩余手续费的概念,根据order_id存储在commission_map中,默认为min_commission
2. 当trade来时计算该trade产生的手续费cost_money
3. 如果cost_money > commission
3.1 如果commission 等于 min_commission,说明这是第一笔trade,此时,直接commission置0,返回cost_money即可
3.2 如果commission 不等于 min_commission... | [
"计算手续费这个逻辑比较复杂,按照如下算法来计算:",
"1",
".",
"定义一个剩余手续费的概念,根据order_id存储在commission_map中,默认为min_commission",
"2",
".",
"当trade来时计算该trade产生的手续费cost_money",
"3",
".",
"如果cost_money",
">",
"commission",
"3",
".",
"1",
"如果commission",
"等于",
"min_commission,说明这是第一笔trade,此时,直接commission置0,返回cost... | ac40a62d4e7eca9494b4d0a14f46facf5616820c | https://github.com/ricequant/rqalpha/blob/ac40a62d4e7eca9494b4d0a14f46facf5616820c/rqalpha/mod/rqalpha_mod_sys_transaction_cost/deciders.py#L50-L80 | train |
ricequant/rqalpha | rqalpha/mod/rqalpha_mod_sys_transaction_cost/deciders.py | HKStockTransactionCostDecider._get_tax | def _get_tax(self, order_book_id, _, cost_money):
"""
港交所收费项目繁多,按照如下逻辑计算税费:
1. 税费比例为 0.11%,不足 1 元按 1 元记,四舍五入保留两位小数(包括印花税、交易征费、交易系统使用费)。
2,五元固定费用(包括卖方收取的转手纸印花税、买方收取的过户费用)。
"""
instrument = Environment.get_instance().get_instrument(order_book_id)
if instrument.type ... | python | def _get_tax(self, order_book_id, _, cost_money):
"""
港交所收费项目繁多,按照如下逻辑计算税费:
1. 税费比例为 0.11%,不足 1 元按 1 元记,四舍五入保留两位小数(包括印花税、交易征费、交易系统使用费)。
2,五元固定费用(包括卖方收取的转手纸印花税、买方收取的过户费用)。
"""
instrument = Environment.get_instance().get_instrument(order_book_id)
if instrument.type ... | [
"def",
"_get_tax",
"(",
"self",
",",
"order_book_id",
",",
"_",
",",
"cost_money",
")",
":",
"instrument",
"=",
"Environment",
".",
"get_instance",
"(",
")",
".",
"get_instrument",
"(",
"order_book_id",
")",
"if",
"instrument",
".",
"type",
"!=",
"'CS'",
"... | 港交所收费项目繁多,按照如下逻辑计算税费:
1. 税费比例为 0.11%,不足 1 元按 1 元记,四舍五入保留两位小数(包括印花税、交易征费、交易系统使用费)。
2,五元固定费用(包括卖方收取的转手纸印花税、买方收取的过户费用)。 | [
"港交所收费项目繁多,按照如下逻辑计算税费:",
"1",
".",
"税费比例为",
"0",
".",
"11%,不足",
"1",
"元按",
"1",
"元记,四舍五入保留两位小数(包括印花税、交易征费、交易系统使用费)。",
"2,五元固定费用(包括卖方收取的转手纸印花税、买方收取的过户费用)。"
] | ac40a62d4e7eca9494b4d0a14f46facf5616820c | https://github.com/ricequant/rqalpha/blob/ac40a62d4e7eca9494b4d0a14f46facf5616820c/rqalpha/mod/rqalpha_mod_sys_transaction_cost/deciders.py#L108-L122 | train |
ricequant/rqalpha | rqalpha/model/bar.py | BarObject.prev_close | def prev_close(self):
"""
[float] 昨日收盘价
"""
try:
return self._data['prev_close']
except (ValueError, KeyError):
pass
if self._prev_close is None:
trading_dt = Environment.get_instance().trading_dt
data_proxy = Environment.g... | python | def prev_close(self):
"""
[float] 昨日收盘价
"""
try:
return self._data['prev_close']
except (ValueError, KeyError):
pass
if self._prev_close is None:
trading_dt = Environment.get_instance().trading_dt
data_proxy = Environment.g... | [
"def",
"prev_close",
"(",
"self",
")",
":",
"try",
":",
"return",
"self",
".",
"_data",
"[",
"'prev_close'",
"]",
"except",
"(",
"ValueError",
",",
"KeyError",
")",
":",
"pass",
"if",
"self",
".",
"_prev_close",
"is",
"None",
":",
"trading_dt",
"=",
"E... | [float] 昨日收盘价 | [
"[",
"float",
"]",
"昨日收盘价"
] | ac40a62d4e7eca9494b4d0a14f46facf5616820c | https://github.com/ricequant/rqalpha/blob/ac40a62d4e7eca9494b4d0a14f46facf5616820c/rqalpha/model/bar.py#L91-L104 | train |
ricequant/rqalpha | rqalpha/model/bar.py | BarObject._bar_status | def _bar_status(self):
"""
WARNING: 获取 bar_status 比较耗费性能,而且是lazy_compute,因此不要多次调用!!!!
"""
if self.isnan or np.isnan(self.limit_up):
return BAR_STATUS.ERROR
if self.close >= self.limit_up:
return BAR_STATUS.LIMIT_UP
if self.close <= self.limit_down:... | python | def _bar_status(self):
"""
WARNING: 获取 bar_status 比较耗费性能,而且是lazy_compute,因此不要多次调用!!!!
"""
if self.isnan or np.isnan(self.limit_up):
return BAR_STATUS.ERROR
if self.close >= self.limit_up:
return BAR_STATUS.LIMIT_UP
if self.close <= self.limit_down:... | [
"def",
"_bar_status",
"(",
"self",
")",
":",
"if",
"self",
".",
"isnan",
"or",
"np",
".",
"isnan",
"(",
"self",
".",
"limit_up",
")",
":",
"return",
"BAR_STATUS",
".",
"ERROR",
"if",
"self",
".",
"close",
">=",
"self",
".",
"limit_up",
":",
"return",... | WARNING: 获取 bar_status 比较耗费性能,而且是lazy_compute,因此不要多次调用!!!! | [
"WARNING",
":",
"获取",
"bar_status",
"比较耗费性能,而且是lazy_compute,因此不要多次调用!!!!"
] | ac40a62d4e7eca9494b4d0a14f46facf5616820c | https://github.com/ricequant/rqalpha/blob/ac40a62d4e7eca9494b4d0a14f46facf5616820c/rqalpha/model/bar.py#L107-L117 | train |
ricequant/rqalpha | rqalpha/model/bar.py | BarObject.prev_settlement | def prev_settlement(self):
"""
[float] 昨日结算价(期货专用)
"""
try:
return self._data['prev_settlement']
except (ValueError, KeyError):
pass
if self._prev_settlement is None:
trading_dt = Environment.get_instance().trading_dt
data_... | python | def prev_settlement(self):
"""
[float] 昨日结算价(期货专用)
"""
try:
return self._data['prev_settlement']
except (ValueError, KeyError):
pass
if self._prev_settlement is None:
trading_dt = Environment.get_instance().trading_dt
data_... | [
"def",
"prev_settlement",
"(",
"self",
")",
":",
"try",
":",
"return",
"self",
".",
"_data",
"[",
"'prev_settlement'",
"]",
"except",
"(",
"ValueError",
",",
"KeyError",
")",
":",
"pass",
"if",
"self",
".",
"_prev_settlement",
"is",
"None",
":",
"trading_d... | [float] 昨日结算价(期货专用) | [
"[",
"float",
"]",
"昨日结算价(期货专用)"
] | ac40a62d4e7eca9494b4d0a14f46facf5616820c | https://github.com/ricequant/rqalpha/blob/ac40a62d4e7eca9494b4d0a14f46facf5616820c/rqalpha/model/bar.py#L180-L193 | train |
ricequant/rqalpha | rqalpha/api/api_base.py | submit_order | def submit_order(id_or_ins, amount, side, price=None, position_effect=None):
"""
通用下单函数,策略可以通过该函数自由选择参数下单。
:param id_or_ins: 下单标的物
:type id_or_ins: :class:`~Instrument` object | `str`
:param float amount: 下单量,需为正数
:param side: 多空方向,多(SIDE.BUY)或空(SIDE.SELL)
:type side: :class:`~SIDE` enum
... | python | def submit_order(id_or_ins, amount, side, price=None, position_effect=None):
"""
通用下单函数,策略可以通过该函数自由选择参数下单。
:param id_or_ins: 下单标的物
:type id_or_ins: :class:`~Instrument` object | `str`
:param float amount: 下单量,需为正数
:param side: 多空方向,多(SIDE.BUY)或空(SIDE.SELL)
:type side: :class:`~SIDE` enum
... | [
"def",
"submit_order",
"(",
"id_or_ins",
",",
"amount",
",",
"side",
",",
"price",
"=",
"None",
",",
"position_effect",
"=",
"None",
")",
":",
"order_book_id",
"=",
"assure_order_book_id",
"(",
"id_or_ins",
")",
"env",
"=",
"Environment",
".",
"get_instance",
... | 通用下单函数,策略可以通过该函数自由选择参数下单。
:param id_or_ins: 下单标的物
:type id_or_ins: :class:`~Instrument` object | `str`
:param float amount: 下单量,需为正数
:param side: 多空方向,多(SIDE.BUY)或空(SIDE.SELL)
:type side: :class:`~SIDE` enum
:param float price: 下单价格,默认为None,表示市价单
:param position_effect: 开平方向,开仓(POSITION... | [
"通用下单函数,策略可以通过该函数自由选择参数下单。"
] | ac40a62d4e7eca9494b4d0a14f46facf5616820c | https://github.com/ricequant/rqalpha/blob/ac40a62d4e7eca9494b4d0a14f46facf5616820c/rqalpha/api/api_base.py#L224-L291 | train |
ricequant/rqalpha | rqalpha/api/api_base.py | cancel_order | def cancel_order(order):
"""
撤单
:param order: 需要撤销的order对象
:type order: :class:`~Order` object
"""
env = Environment.get_instance()
if env.can_cancel_order(order):
env.broker.cancel_order(order)
return order | python | def cancel_order(order):
"""
撤单
:param order: 需要撤销的order对象
:type order: :class:`~Order` object
"""
env = Environment.get_instance()
if env.can_cancel_order(order):
env.broker.cancel_order(order)
return order | [
"def",
"cancel_order",
"(",
"order",
")",
":",
"env",
"=",
"Environment",
".",
"get_instance",
"(",
")",
"if",
"env",
".",
"can_cancel_order",
"(",
"order",
")",
":",
"env",
".",
"broker",
".",
"cancel_order",
"(",
"order",
")",
"return",
"order"
] | 撤单
:param order: 需要撤销的order对象
:type order: :class:`~Order` object | [
"撤单"
] | ac40a62d4e7eca9494b4d0a14f46facf5616820c | https://github.com/ricequant/rqalpha/blob/ac40a62d4e7eca9494b4d0a14f46facf5616820c/rqalpha/api/api_base.py#L304-L314 | train |
ricequant/rqalpha | rqalpha/api/api_base.py | update_universe | def update_universe(id_or_symbols):
"""
该方法用于更新现在关注的证券的集合(e.g.:股票池)。PS:会在下一个bar事件触发时候产生(新的关注的股票池更新)效果。并且update_universe会是覆盖(overwrite)的操作而不是在已有的股票池的基础上进行增量添加。比如已有的股票池为['000001.XSHE', '000024.XSHE']然后调用了update_universe(['000030.XSHE'])之后,股票池就会变成000030.XSHE一个股票了,随后的数据更新也只会跟踪000030.XSHE这一个股票了。
:param id_or_sy... | python | def update_universe(id_or_symbols):
"""
该方法用于更新现在关注的证券的集合(e.g.:股票池)。PS:会在下一个bar事件触发时候产生(新的关注的股票池更新)效果。并且update_universe会是覆盖(overwrite)的操作而不是在已有的股票池的基础上进行增量添加。比如已有的股票池为['000001.XSHE', '000024.XSHE']然后调用了update_universe(['000030.XSHE'])之后,股票池就会变成000030.XSHE一个股票了,随后的数据更新也只会跟踪000030.XSHE这一个股票了。
:param id_or_sy... | [
"def",
"update_universe",
"(",
"id_or_symbols",
")",
":",
"if",
"isinstance",
"(",
"id_or_symbols",
",",
"(",
"six",
".",
"string_types",
",",
"Instrument",
")",
")",
":",
"id_or_symbols",
"=",
"[",
"id_or_symbols",
"]",
"order_book_ids",
"=",
"set",
"(",
"a... | 该方法用于更新现在关注的证券的集合(e.g.:股票池)。PS:会在下一个bar事件触发时候产生(新的关注的股票池更新)效果。并且update_universe会是覆盖(overwrite)的操作而不是在已有的股票池的基础上进行增量添加。比如已有的股票池为['000001.XSHE', '000024.XSHE']然后调用了update_universe(['000030.XSHE'])之后,股票池就会变成000030.XSHE一个股票了,随后的数据更新也只会跟踪000030.XSHE这一个股票了。
:param id_or_symbols: 标的物
:type id_or_symbols: :class:`~Ins... | [
"该方法用于更新现在关注的证券的集合(e",
".",
"g",
".",
":股票池)。PS:会在下一个bar事件触发时候产生(新的关注的股票池更新)效果。并且update_universe会是覆盖(overwrite)的操作而不是在已有的股票池的基础上进行增量添加。比如已有的股票池为",
"[",
"000001",
".",
"XSHE",
"000024",
".",
"XSHE",
"]",
"然后调用了update_universe",
"(",
"[",
"000030",
".",
"XSHE",
"]",
")",
"之后,... | ac40a62d4e7eca9494b4d0a14f46facf5616820c | https://github.com/ricequant/rqalpha/blob/ac40a62d4e7eca9494b4d0a14f46facf5616820c/rqalpha/api/api_base.py#L327-L340 | train |
ricequant/rqalpha | rqalpha/api/api_base.py | subscribe | def subscribe(id_or_symbols):
"""
订阅合约行情。该操作会导致合约池内合约的增加,从而影响handle_bar中处理bar数据的数量。
需要注意,用户在初次编写策略时候需要首先订阅合约行情,否则handle_bar不会被触发。
:param id_or_symbols: 标的物
:type id_or_symbols: :class:`~Instrument` object | `str` | List[:class:`~Instrument`] | List[`str`]
"""
current_universe = Environment... | python | def subscribe(id_or_symbols):
"""
订阅合约行情。该操作会导致合约池内合约的增加,从而影响handle_bar中处理bar数据的数量。
需要注意,用户在初次编写策略时候需要首先订阅合约行情,否则handle_bar不会被触发。
:param id_or_symbols: 标的物
:type id_or_symbols: :class:`~Instrument` object | `str` | List[:class:`~Instrument`] | List[`str`]
"""
current_universe = Environment... | [
"def",
"subscribe",
"(",
"id_or_symbols",
")",
":",
"current_universe",
"=",
"Environment",
".",
"get_instance",
"(",
")",
".",
"get_universe",
"(",
")",
"if",
"isinstance",
"(",
"id_or_symbols",
",",
"six",
".",
"string_types",
")",
":",
"order_book_id",
"=",... | 订阅合约行情。该操作会导致合约池内合约的增加,从而影响handle_bar中处理bar数据的数量。
需要注意,用户在初次编写策略时候需要首先订阅合约行情,否则handle_bar不会被触发。
:param id_or_symbols: 标的物
:type id_or_symbols: :class:`~Instrument` object | `str` | List[:class:`~Instrument`] | List[`str`] | [
"订阅合约行情。该操作会导致合约池内合约的增加,从而影响handle_bar中处理bar数据的数量。"
] | ac40a62d4e7eca9494b4d0a14f46facf5616820c | https://github.com/ricequant/rqalpha/blob/ac40a62d4e7eca9494b4d0a14f46facf5616820c/rqalpha/api/api_base.py#L353-L374 | train |
ricequant/rqalpha | rqalpha/api/api_base.py | unsubscribe | def unsubscribe(id_or_symbols):
"""
取消订阅合约行情。取消订阅会导致合约池内合约的减少,如果当前合约池中没有任何合约,则策略直接退出。
:param id_or_symbols: 标的物
:type id_or_symbols: :class:`~Instrument` object | `str` | List[:class:`~Instrument`] | List[`str`]
"""
current_universe = Environment.get_instance().get_universe()
if isinstance(... | python | def unsubscribe(id_or_symbols):
"""
取消订阅合约行情。取消订阅会导致合约池内合约的减少,如果当前合约池中没有任何合约,则策略直接退出。
:param id_or_symbols: 标的物
:type id_or_symbols: :class:`~Instrument` object | `str` | List[:class:`~Instrument`] | List[`str`]
"""
current_universe = Environment.get_instance().get_universe()
if isinstance(... | [
"def",
"unsubscribe",
"(",
"id_or_symbols",
")",
":",
"current_universe",
"=",
"Environment",
".",
"get_instance",
"(",
")",
".",
"get_universe",
"(",
")",
"if",
"isinstance",
"(",
"id_or_symbols",
",",
"six",
".",
"string_types",
")",
":",
"order_book_id",
"=... | 取消订阅合约行情。取消订阅会导致合约池内合约的减少,如果当前合约池中没有任何合约,则策略直接退出。
:param id_or_symbols: 标的物
:type id_or_symbols: :class:`~Instrument` object | `str` | List[:class:`~Instrument`] | List[`str`] | [
"取消订阅合约行情。取消订阅会导致合约池内合约的减少,如果当前合约池中没有任何合约,则策略直接退出。"
] | ac40a62d4e7eca9494b4d0a14f46facf5616820c | https://github.com/ricequant/rqalpha/blob/ac40a62d4e7eca9494b4d0a14f46facf5616820c/rqalpha/api/api_base.py#L387-L407 | train |
ricequant/rqalpha | rqalpha/api/api_base.py | get_yield_curve | def get_yield_curve(date=None, tenor=None):
"""
获取某个国家市场指定日期的收益率曲线水平。
数据为2002年至今的中债国债收益率曲线,来源于中央国债登记结算有限责任公司。
:param date: 查询日期,默认为策略当前日期前一天
:type date: `str` | `date` | `datetime` | `pandas.Timestamp`
:param str tenor: 标准期限,'0S' - 隔夜,'1M' - 1个月,'1Y' - 1年,默认为全部期限
:return: `pandas.DataFra... | python | def get_yield_curve(date=None, tenor=None):
"""
获取某个国家市场指定日期的收益率曲线水平。
数据为2002年至今的中债国债收益率曲线,来源于中央国债登记结算有限责任公司。
:param date: 查询日期,默认为策略当前日期前一天
:type date: `str` | `date` | `datetime` | `pandas.Timestamp`
:param str tenor: 标准期限,'0S' - 隔夜,'1M' - 1个月,'1Y' - 1年,默认为全部期限
:return: `pandas.DataFra... | [
"def",
"get_yield_curve",
"(",
"date",
"=",
"None",
",",
"tenor",
"=",
"None",
")",
":",
"env",
"=",
"Environment",
".",
"get_instance",
"(",
")",
"trading_date",
"=",
"env",
".",
"trading_dt",
".",
"date",
"(",
")",
"yesterday",
"=",
"env",
".",
"data... | 获取某个国家市场指定日期的收益率曲线水平。
数据为2002年至今的中债国债收益率曲线,来源于中央国债登记结算有限责任公司。
:param date: 查询日期,默认为策略当前日期前一天
:type date: `str` | `date` | `datetime` | `pandas.Timestamp`
:param str tenor: 标准期限,'0S' - 隔夜,'1M' - 1个月,'1Y' - 1年,默认为全部期限
:return: `pandas.DataFrame` - 查询时间段内无风险收益率曲线
:example:
.. code-block:... | [
"获取某个国家市场指定日期的收益率曲线水平。"
] | ac40a62d4e7eca9494b4d0a14f46facf5616820c | https://github.com/ricequant/rqalpha/blob/ac40a62d4e7eca9494b4d0a14f46facf5616820c/rqalpha/api/api_base.py#L423-L465 | train |
ricequant/rqalpha | rqalpha/api/api_base.py | history_bars | def history_bars(
order_book_id,
bar_count,
frequency,
fields=None,
skip_suspended=True,
include_now=False,
adjust_type="pre",
):
"""
获取指定合约的历史行情,同时支持日以及分钟历史数据。不能在init中调用。 注意,该API会自动跳过停牌数据。
日回测获取分钟历史数据:不支持
日回测获取日历史数据
========================= ========================... | python | def history_bars(
order_book_id,
bar_count,
frequency,
fields=None,
skip_suspended=True,
include_now=False,
adjust_type="pre",
):
"""
获取指定合约的历史行情,同时支持日以及分钟历史数据。不能在init中调用。 注意,该API会自动跳过停牌数据。
日回测获取分钟历史数据:不支持
日回测获取日历史数据
========================= ========================... | [
"def",
"history_bars",
"(",
"order_book_id",
",",
"bar_count",
",",
"frequency",
",",
"fields",
"=",
"None",
",",
"skip_suspended",
"=",
"True",
",",
"include_now",
"=",
"False",
",",
"adjust_type",
"=",
"\"pre\"",
",",
")",
":",
"order_book_id",
"=",
"assur... | 获取指定合约的历史行情,同时支持日以及分钟历史数据。不能在init中调用。 注意,该API会自动跳过停牌数据。
日回测获取分钟历史数据:不支持
日回测获取日历史数据
========================= ===================================================
调用时间 返回数据
========================= ===================================================
T日before_trading ... | [
"获取指定合约的历史行情,同时支持日以及分钟历史数据。不能在init中调用。",
"注意,该API会自动跳过停牌数据。"
] | ac40a62d4e7eca9494b4d0a14f46facf5616820c | https://github.com/ricequant/rqalpha/blob/ac40a62d4e7eca9494b4d0a14f46facf5616820c/rqalpha/api/api_base.py#L487-L612 | train |
ricequant/rqalpha | rqalpha/api/api_base.py | all_instruments | def all_instruments(type=None, date=None):
"""
获取某个国家市场的所有合约信息。使用者可以通过这一方法很快地对合约信息有一个快速了解,目前仅支持中国市场。
:param str type: 需要查询合约类型,例如:type='CS'代表股票。默认是所有类型
:param date: 查询时间点
:type date: `str` | `datetime` | `date`
:return: `pandas DataFrame` 所有合约的基本信息。
其中type参数传入的合约类型和对应的解释如下:
=======... | python | def all_instruments(type=None, date=None):
"""
获取某个国家市场的所有合约信息。使用者可以通过这一方法很快地对合约信息有一个快速了解,目前仅支持中国市场。
:param str type: 需要查询合约类型,例如:type='CS'代表股票。默认是所有类型
:param date: 查询时间点
:type date: `str` | `datetime` | `date`
:return: `pandas DataFrame` 所有合约的基本信息。
其中type参数传入的合约类型和对应的解释如下:
=======... | [
"def",
"all_instruments",
"(",
"type",
"=",
"None",
",",
"date",
"=",
"None",
")",
":",
"env",
"=",
"Environment",
".",
"get_instance",
"(",
")",
"if",
"date",
"is",
"None",
":",
"dt",
"=",
"env",
".",
"trading_dt",
"else",
":",
"dt",
"=",
"pd",
".... | 获取某个国家市场的所有合约信息。使用者可以通过这一方法很快地对合约信息有一个快速了解,目前仅支持中国市场。
:param str type: 需要查询合约类型,例如:type='CS'代表股票。默认是所有类型
:param date: 查询时间点
:type date: `str` | `datetime` | `date`
:return: `pandas DataFrame` 所有合约的基本信息。
其中type参数传入的合约类型和对应的解释如下:
========================= ==================================... | [
"获取某个国家市场的所有合约信息。使用者可以通过这一方法很快地对合约信息有一个快速了解,目前仅支持中国市场。"
] | ac40a62d4e7eca9494b4d0a14f46facf5616820c | https://github.com/ricequant/rqalpha/blob/ac40a62d4e7eca9494b4d0a14f46facf5616820c/rqalpha/api/api_base.py#L630-L707 | train |
ricequant/rqalpha | rqalpha/api/api_base.py | current_snapshot | def current_snapshot(id_or_symbol):
"""
获得当前市场快照数据。只能在日内交易阶段调用,获取当日调用时点的市场快照数据。
市场快照数据记录了每日从开盘到当前的数据信息,可以理解为一个动态的day bar数据。
在目前分钟回测中,快照数据为当日所有分钟线累积而成,一般情况下,最后一个分钟线获取到的快照数据应当与当日的日线行情保持一致。
需要注意,在实盘模拟中,该函数返回的是调用当时的市场快照情况,所以在同一个handle_bar中不同时点调用可能返回的数据不同。
如果当日截止到调用时候对应股票没有任何成交,那么snapshot中的close, hig... | python | def current_snapshot(id_or_symbol):
"""
获得当前市场快照数据。只能在日内交易阶段调用,获取当日调用时点的市场快照数据。
市场快照数据记录了每日从开盘到当前的数据信息,可以理解为一个动态的day bar数据。
在目前分钟回测中,快照数据为当日所有分钟线累积而成,一般情况下,最后一个分钟线获取到的快照数据应当与当日的日线行情保持一致。
需要注意,在实盘模拟中,该函数返回的是调用当时的市场快照情况,所以在同一个handle_bar中不同时点调用可能返回的数据不同。
如果当日截止到调用时候对应股票没有任何成交,那么snapshot中的close, hig... | [
"def",
"current_snapshot",
"(",
"id_or_symbol",
")",
":",
"env",
"=",
"Environment",
".",
"get_instance",
"(",
")",
"frequency",
"=",
"env",
".",
"config",
".",
"base",
".",
"frequency",
"order_book_id",
"=",
"assure_order_book_id",
"(",
"id_or_symbol",
")",
"... | 获得当前市场快照数据。只能在日内交易阶段调用,获取当日调用时点的市场快照数据。
市场快照数据记录了每日从开盘到当前的数据信息,可以理解为一个动态的day bar数据。
在目前分钟回测中,快照数据为当日所有分钟线累积而成,一般情况下,最后一个分钟线获取到的快照数据应当与当日的日线行情保持一致。
需要注意,在实盘模拟中,该函数返回的是调用当时的市场快照情况,所以在同一个handle_bar中不同时点调用可能返回的数据不同。
如果当日截止到调用时候对应股票没有任何成交,那么snapshot中的close, high, low, last几个价格水平都将以0表示。
:param str id_or_... | [
"获得当前市场快照数据。只能在日内交易阶段调用,获取当日调用时点的市场快照数据。",
"市场快照数据记录了每日从开盘到当前的数据信息,可以理解为一个动态的day",
"bar数据。",
"在目前分钟回测中,快照数据为当日所有分钟线累积而成,一般情况下,最后一个分钟线获取到的快照数据应当与当日的日线行情保持一致。",
"需要注意,在实盘模拟中,该函数返回的是调用当时的市场快照情况,所以在同一个handle_bar中不同时点调用可能返回的数据不同。",
"如果当日截止到调用时候对应股票没有任何成交,那么snapshot中的close",
"high",
"low",
"last几个价格水平都将以0... | ac40a62d4e7eca9494b4d0a14f46facf5616820c | https://github.com/ricequant/rqalpha/blob/ac40a62d4e7eca9494b4d0a14f46facf5616820c/rqalpha/api/api_base.py#L989-L1028 | train |
ricequant/rqalpha | rqalpha/mod/rqalpha_mod_sys_accounts/account_model/stock_account.py | StockAccount.dividend_receivable | def dividend_receivable(self):
"""
[float] 投资组合在分红现金收到账面之前的应收分红部分。具体细节在分红部分
"""
return sum(d['quantity'] * d['dividend_per_share'] for d in six.itervalues(self._dividend_receivable)) | python | def dividend_receivable(self):
"""
[float] 投资组合在分红现金收到账面之前的应收分红部分。具体细节在分红部分
"""
return sum(d['quantity'] * d['dividend_per_share'] for d in six.itervalues(self._dividend_receivable)) | [
"def",
"dividend_receivable",
"(",
"self",
")",
":",
"return",
"sum",
"(",
"d",
"[",
"'quantity'",
"]",
"*",
"d",
"[",
"'dividend_per_share'",
"]",
"for",
"d",
"in",
"six",
".",
"itervalues",
"(",
"self",
".",
"_dividend_receivable",
")",
")"
] | [float] 投资组合在分红现金收到账面之前的应收分红部分。具体细节在分红部分 | [
"[",
"float",
"]",
"投资组合在分红现金收到账面之前的应收分红部分。具体细节在分红部分"
] | ac40a62d4e7eca9494b4d0a14f46facf5616820c | https://github.com/ricequant/rqalpha/blob/ac40a62d4e7eca9494b4d0a14f46facf5616820c/rqalpha/mod/rqalpha_mod_sys_accounts/account_model/stock_account.py#L247-L251 | train |
ricequant/rqalpha | rqalpha/interface.py | AbstractDataSource.history_bars | def history_bars(self, instrument, bar_count, frequency, fields, dt, skip_suspended=True,
include_now=False, adjust_type='pre', adjust_orig=None):
"""
获取历史数据
:param instrument: 合约对象
:type instrument: :class:`~Instrument`
:param int bar_count: 获取的历史数据数量
... | python | def history_bars(self, instrument, bar_count, frequency, fields, dt, skip_suspended=True,
include_now=False, adjust_type='pre', adjust_orig=None):
"""
获取历史数据
:param instrument: 合约对象
:type instrument: :class:`~Instrument`
:param int bar_count: 获取的历史数据数量
... | [
"def",
"history_bars",
"(",
"self",
",",
"instrument",
",",
"bar_count",
",",
"frequency",
",",
"fields",
",",
"dt",
",",
"skip_suspended",
"=",
"True",
",",
"include_now",
"=",
"False",
",",
"adjust_type",
"=",
"'pre'",
",",
"adjust_orig",
"=",
"None",
")... | 获取历史数据
:param instrument: 合约对象
:type instrument: :class:`~Instrument`
:param int bar_count: 获取的历史数据数量
:param str frequency: 周期频率,`1d` 表示日周期, `1m` 表示分钟周期
:param str fields: 返回数据字段
========================= ===================================================
fi... | [
"获取历史数据"
] | ac40a62d4e7eca9494b4d0a14f46facf5616820c | https://github.com/ricequant/rqalpha/blob/ac40a62d4e7eca9494b4d0a14f46facf5616820c/rqalpha/interface.py#L360-L398 | train |
ricequant/rqalpha | rqalpha/mod/rqalpha_mod_sys_accounts/api/api_stock.py | order_shares | def order_shares(id_or_ins, amount, price=None, style=None):
"""
落指定股数的买/卖单,最常见的落单方式之一。如有需要落单类型当做一个参量传入,如果忽略掉落单类型,那么默认是市价单(market order)。
:param id_or_ins: 下单标的物
:type id_or_ins: :class:`~Instrument` object | `str`
:param int amount: 下单量, 正数代表买入,负数代表卖出。将会根据一手xx股来向下调整到一手的倍数,比如中国A股就是调整成100股的倍数。
... | python | def order_shares(id_or_ins, amount, price=None, style=None):
"""
落指定股数的买/卖单,最常见的落单方式之一。如有需要落单类型当做一个参量传入,如果忽略掉落单类型,那么默认是市价单(market order)。
:param id_or_ins: 下单标的物
:type id_or_ins: :class:`~Instrument` object | `str`
:param int amount: 下单量, 正数代表买入,负数代表卖出。将会根据一手xx股来向下调整到一手的倍数,比如中国A股就是调整成100股的倍数。
... | [
"def",
"order_shares",
"(",
"id_or_ins",
",",
"amount",
",",
"price",
"=",
"None",
",",
"style",
"=",
"None",
")",
":",
"if",
"amount",
"==",
"0",
":",
"# 如果下单量为0,则认为其并没有发单,则直接返回None",
"user_system_log",
".",
"warn",
"(",
"_",
"(",
"u\"Order Creation Failed: O... | 落指定股数的买/卖单,最常见的落单方式之一。如有需要落单类型当做一个参量传入,如果忽略掉落单类型,那么默认是市价单(market order)。
:param id_or_ins: 下单标的物
:type id_or_ins: :class:`~Instrument` object | `str`
:param int amount: 下单量, 正数代表买入,负数代表卖出。将会根据一手xx股来向下调整到一手的倍数,比如中国A股就是调整成100股的倍数。
:param float price: 下单价格,默认为None,表示 :class:`~MarketOrder`, 此参数主要用于简化 `st... | [
"落指定股数的买",
"/",
"卖单,最常见的落单方式之一。如有需要落单类型当做一个参量传入,如果忽略掉落单类型,那么默认是市价单(market",
"order)。"
] | ac40a62d4e7eca9494b4d0a14f46facf5616820c | https://github.com/ricequant/rqalpha/blob/ac40a62d4e7eca9494b4d0a14f46facf5616820c/rqalpha/mod/rqalpha_mod_sys_accounts/api/api_stock.py#L68-L139 | train |
ricequant/rqalpha | rqalpha/mod/rqalpha_mod_sys_accounts/api/api_stock.py | order_lots | def order_lots(id_or_ins, amount, price=None, style=None):
"""
指定手数发送买/卖单。如有需要落单类型当做一个参量传入,如果忽略掉落单类型,那么默认是市价单(market order)。
:param id_or_ins: 下单标的物
:type id_or_ins: :class:`~Instrument` object | `str`
:param int amount: 下单量, 正数代表买入,负数代表卖出。将会根据一手xx股来向下调整到一手的倍数,比如中国A股就是调整成100股的倍数。
:param float... | python | def order_lots(id_or_ins, amount, price=None, style=None):
"""
指定手数发送买/卖单。如有需要落单类型当做一个参量传入,如果忽略掉落单类型,那么默认是市价单(market order)。
:param id_or_ins: 下单标的物
:type id_or_ins: :class:`~Instrument` object | `str`
:param int amount: 下单量, 正数代表买入,负数代表卖出。将会根据一手xx股来向下调整到一手的倍数,比如中国A股就是调整成100股的倍数。
:param float... | [
"def",
"order_lots",
"(",
"id_or_ins",
",",
"amount",
",",
"price",
"=",
"None",
",",
"style",
"=",
"None",
")",
":",
"order_book_id",
"=",
"assure_stock_order_book_id",
"(",
"id_or_ins",
")",
"round_lot",
"=",
"int",
"(",
"Environment",
".",
"get_instance",
... | 指定手数发送买/卖单。如有需要落单类型当做一个参量传入,如果忽略掉落单类型,那么默认是市价单(market order)。
:param id_or_ins: 下单标的物
:type id_or_ins: :class:`~Instrument` object | `str`
:param int amount: 下单量, 正数代表买入,负数代表卖出。将会根据一手xx股来向下调整到一手的倍数,比如中国A股就是调整成100股的倍数。
:param float price: 下单价格,默认为None,表示 :class:`~MarketOrder`, 此参数主要用于简化 `style` 参数。
... | [
"指定手数发送买",
"/",
"卖单。如有需要落单类型当做一个参量传入,如果忽略掉落单类型,那么默认是市价单(market",
"order)。"
] | ac40a62d4e7eca9494b4d0a14f46facf5616820c | https://github.com/ricequant/rqalpha/blob/ac40a62d4e7eca9494b4d0a14f46facf5616820c/rqalpha/mod/rqalpha_mod_sys_accounts/api/api_stock.py#L162-L194 | train |
ricequant/rqalpha | rqalpha/mod/rqalpha_mod_sys_accounts/api/api_stock.py | order_value | def order_value(id_or_ins, cash_amount, price=None, style=None):
"""
使用想要花费的金钱买入/卖出股票,而不是买入/卖出想要的股数,正数代表买入,负数代表卖出。股票的股数总是会被调整成对应的100的倍数(在A中国A股市场1手是100股)。如果资金不足,该API将不会创建发送订单。
需要注意:
当您提交一个买单时,cash_amount 代表的含义是您希望买入股票消耗的金额(包含税费),最终买入的股数不仅和发单的价格有关,还和税费相关的参数设置有关。
当您提交一个卖单时,cash_amount 代表的意义是您希望卖出股票的总价... | python | def order_value(id_or_ins, cash_amount, price=None, style=None):
"""
使用想要花费的金钱买入/卖出股票,而不是买入/卖出想要的股数,正数代表买入,负数代表卖出。股票的股数总是会被调整成对应的100的倍数(在A中国A股市场1手是100股)。如果资金不足,该API将不会创建发送订单。
需要注意:
当您提交一个买单时,cash_amount 代表的含义是您希望买入股票消耗的金额(包含税费),最终买入的股数不仅和发单的价格有关,还和税费相关的参数设置有关。
当您提交一个卖单时,cash_amount 代表的意义是您希望卖出股票的总价... | [
"def",
"order_value",
"(",
"id_or_ins",
",",
"cash_amount",
",",
"price",
"=",
"None",
",",
"style",
"=",
"None",
")",
":",
"style",
"=",
"cal_style",
"(",
"price",
",",
"style",
")",
"if",
"isinstance",
"(",
"style",
",",
"LimitOrder",
")",
":",
"if",... | 使用想要花费的金钱买入/卖出股票,而不是买入/卖出想要的股数,正数代表买入,负数代表卖出。股票的股数总是会被调整成对应的100的倍数(在A中国A股市场1手是100股)。如果资金不足,该API将不会创建发送订单。
需要注意:
当您提交一个买单时,cash_amount 代表的含义是您希望买入股票消耗的金额(包含税费),最终买入的股数不仅和发单的价格有关,还和税费相关的参数设置有关。
当您提交一个卖单时,cash_amount 代表的意义是您希望卖出股票的总价值。如果金额超出了您所持有股票的价值,那么您将卖出所有股票。
:param id_or_ins: 下单标的物
:type id_or_i... | [
"使用想要花费的金钱买入",
"/",
"卖出股票,而不是买入",
"/",
"卖出想要的股数,正数代表买入,负数代表卖出。股票的股数总是会被调整成对应的100的倍数(在A中国A股市场1手是100股)。如果资金不足,该API将不会创建发送订单。"
] | ac40a62d4e7eca9494b4d0a14f46facf5616820c | https://github.com/ricequant/rqalpha/blob/ac40a62d4e7eca9494b4d0a14f46facf5616820c/rqalpha/mod/rqalpha_mod_sys_accounts/api/api_stock.py#L206-L282 | train |
ricequant/rqalpha | rqalpha/mod/rqalpha_mod_sys_accounts/api/api_stock.py | order_percent | def order_percent(id_or_ins, percent, price=None, style=None):
"""
发送一个花费价值等于目前投资组合(市场价值和目前现金的总和)一定百分比现金的买/卖单,正数代表买,负数代表卖。股票的股数总是会被调整成对应的一手的股票数的倍数(1手是100股)。百分比是一个小数,并且小于或等于1(<=100%),0.5表示的是50%.需要注意,如果资金不足,该API将不会创建发送订单。
需要注意:
发送买单时,percent 代表的是期望买入股票消耗的金额(包含税费)占投资组合总权益的比例。
发送卖单时,percent 代表的是期望卖出的股票... | python | def order_percent(id_or_ins, percent, price=None, style=None):
"""
发送一个花费价值等于目前投资组合(市场价值和目前现金的总和)一定百分比现金的买/卖单,正数代表买,负数代表卖。股票的股数总是会被调整成对应的一手的股票数的倍数(1手是100股)。百分比是一个小数,并且小于或等于1(<=100%),0.5表示的是50%.需要注意,如果资金不足,该API将不会创建发送订单。
需要注意:
发送买单时,percent 代表的是期望买入股票消耗的金额(包含税费)占投资组合总权益的比例。
发送卖单时,percent 代表的是期望卖出的股票... | [
"def",
"order_percent",
"(",
"id_or_ins",
",",
"percent",
",",
"price",
"=",
"None",
",",
"style",
"=",
"None",
")",
":",
"if",
"percent",
"<",
"-",
"1",
"or",
"percent",
">",
"1",
":",
"raise",
"RQInvalidArgument",
"(",
"_",
"(",
"u\"percent should betw... | 发送一个花费价值等于目前投资组合(市场价值和目前现金的总和)一定百分比现金的买/卖单,正数代表买,负数代表卖。股票的股数总是会被调整成对应的一手的股票数的倍数(1手是100股)。百分比是一个小数,并且小于或等于1(<=100%),0.5表示的是50%.需要注意,如果资金不足,该API将不会创建发送订单。
需要注意:
发送买单时,percent 代表的是期望买入股票消耗的金额(包含税费)占投资组合总权益的比例。
发送卖单时,percent 代表的是期望卖出的股票总价值占投资组合总权益的比例。
:param id_or_ins: 下单标的物
:type id_or_ins: :class:`~... | [
"发送一个花费价值等于目前投资组合(市场价值和目前现金的总和)一定百分比现金的买",
"/",
"卖单,正数代表买,负数代表卖。股票的股数总是会被调整成对应的一手的股票数的倍数(1手是100股)。百分比是一个小数,并且小于或等于1(<",
"=",
"100%),0",
".",
"5表示的是50%",
".",
"需要注意,如果资金不足,该API将不会创建发送订单。"
] | ac40a62d4e7eca9494b4d0a14f46facf5616820c | https://github.com/ricequant/rqalpha/blob/ac40a62d4e7eca9494b4d0a14f46facf5616820c/rqalpha/mod/rqalpha_mod_sys_accounts/api/api_stock.py#L294-L326 | train |
ricequant/rqalpha | rqalpha/mod/rqalpha_mod_sys_accounts/api/api_stock.py | order_target_value | def order_target_value(id_or_ins, cash_amount, price=None, style=None):
"""
买入/卖出并且自动调整该证券的仓位到一个目标价值。
加仓时,cash_amount 代表现有持仓的价值加上即将花费(包含税费)的现金的总价值。
减仓时,cash_amount 代表调整仓位的目标价至。
需要注意,如果资金不足,该API将不会创建发送订单。
:param id_or_ins: 下单标的物
:type id_or_ins: :class:`~Instrument` object | `str` | List[:c... | python | def order_target_value(id_or_ins, cash_amount, price=None, style=None):
"""
买入/卖出并且自动调整该证券的仓位到一个目标价值。
加仓时,cash_amount 代表现有持仓的价值加上即将花费(包含税费)的现金的总价值。
减仓时,cash_amount 代表调整仓位的目标价至。
需要注意,如果资金不足,该API将不会创建发送订单。
:param id_or_ins: 下单标的物
:type id_or_ins: :class:`~Instrument` object | `str` | List[:c... | [
"def",
"order_target_value",
"(",
"id_or_ins",
",",
"cash_amount",
",",
"price",
"=",
"None",
",",
"style",
"=",
"None",
")",
":",
"order_book_id",
"=",
"assure_stock_order_book_id",
"(",
"id_or_ins",
")",
"account",
"=",
"Environment",
".",
"get_instance",
"(",... | 买入/卖出并且自动调整该证券的仓位到一个目标价值。
加仓时,cash_amount 代表现有持仓的价值加上即将花费(包含税费)的现金的总价值。
减仓时,cash_amount 代表调整仓位的目标价至。
需要注意,如果资金不足,该API将不会创建发送订单。
:param id_or_ins: 下单标的物
:type id_or_ins: :class:`~Instrument` object | `str` | List[:class:`~Instrument`] | List[`str`]
:param float cash_amount: 最终的该证券的仓位目标价值。
... | [
"买入",
"/",
"卖出并且自动调整该证券的仓位到一个目标价值。",
"加仓时,cash_amount",
"代表现有持仓的价值加上即将花费(包含税费)的现金的总价值。",
"减仓时,cash_amount",
"代表调整仓位的目标价至。"
] | ac40a62d4e7eca9494b4d0a14f46facf5616820c | https://github.com/ricequant/rqalpha/blob/ac40a62d4e7eca9494b4d0a14f46facf5616820c/rqalpha/mod/rqalpha_mod_sys_accounts/api/api_stock.py#L338-L380 | train |
ricequant/rqalpha | rqalpha/mod/rqalpha_mod_sys_accounts/api/api_stock.py | order_target_percent | def order_target_percent(id_or_ins, percent, price=None, style=None):
"""
买入/卖出证券以自动调整该证券的仓位到占有一个目标价值。
加仓时,percent 代表证券已有持仓的价值加上即将花费的现金(包含税费)的总值占当前投资组合总价值的比例。
减仓时,percent 代表证券将被调整到的目标价至占当前投资组合总价值的比例。
其实我们需要计算一个position_to_adjust (即应该调整的仓位)
`position_to_adjust = target_position - current_posit... | python | def order_target_percent(id_or_ins, percent, price=None, style=None):
"""
买入/卖出证券以自动调整该证券的仓位到占有一个目标价值。
加仓时,percent 代表证券已有持仓的价值加上即将花费的现金(包含税费)的总值占当前投资组合总价值的比例。
减仓时,percent 代表证券将被调整到的目标价至占当前投资组合总价值的比例。
其实我们需要计算一个position_to_adjust (即应该调整的仓位)
`position_to_adjust = target_position - current_posit... | [
"def",
"order_target_percent",
"(",
"id_or_ins",
",",
"percent",
",",
"price",
"=",
"None",
",",
"style",
"=",
"None",
")",
":",
"if",
"percent",
"<",
"0",
"or",
"percent",
">",
"1",
":",
"raise",
"RQInvalidArgument",
"(",
"_",
"(",
"u\"percent should betw... | 买入/卖出证券以自动调整该证券的仓位到占有一个目标价值。
加仓时,percent 代表证券已有持仓的价值加上即将花费的现金(包含税费)的总值占当前投资组合总价值的比例。
减仓时,percent 代表证券将被调整到的目标价至占当前投资组合总价值的比例。
其实我们需要计算一个position_to_adjust (即应该调整的仓位)
`position_to_adjust = target_position - current_position`
投资组合价值等于所有已有仓位的价值和剩余现金的总和。买/卖单会被下舍入一手股数(A股是100的倍数)的倍数。目标百分比应该是一个小数,并且最大值... | [
"买入",
"/",
"卖出证券以自动调整该证券的仓位到占有一个目标价值。"
] | ac40a62d4e7eca9494b4d0a14f46facf5616820c | https://github.com/ricequant/rqalpha/blob/ac40a62d4e7eca9494b4d0a14f46facf5616820c/rqalpha/mod/rqalpha_mod_sys_accounts/api/api_stock.py#L392-L445 | train |
ricequant/rqalpha | rqalpha/mod/rqalpha_mod_sys_accounts/api/api_stock.py | is_suspended | def is_suspended(order_book_id, count=1):
"""
判断某只股票是否全天停牌。
:param str order_book_id: 某只股票的代码或股票代码,可传入单只股票的order_book_id, symbol
:param int count: 回溯获取的数据个数。默认为当前能够获取到的最近的数据
:return: count为1时 `bool`; count>1时 `pandas.DataFrame`
"""
dt = Environment.get_instance().calendar_dt.date()
or... | python | def is_suspended(order_book_id, count=1):
"""
判断某只股票是否全天停牌。
:param str order_book_id: 某只股票的代码或股票代码,可传入单只股票的order_book_id, symbol
:param int count: 回溯获取的数据个数。默认为当前能够获取到的最近的数据
:return: count为1时 `bool`; count>1时 `pandas.DataFrame`
"""
dt = Environment.get_instance().calendar_dt.date()
or... | [
"def",
"is_suspended",
"(",
"order_book_id",
",",
"count",
"=",
"1",
")",
":",
"dt",
"=",
"Environment",
".",
"get_instance",
"(",
")",
".",
"calendar_dt",
".",
"date",
"(",
")",
"order_book_id",
"=",
"assure_stock_order_book_id",
"(",
"order_book_id",
")",
... | 判断某只股票是否全天停牌。
:param str order_book_id: 某只股票的代码或股票代码,可传入单只股票的order_book_id, symbol
:param int count: 回溯获取的数据个数。默认为当前能够获取到的最近的数据
:return: count为1时 `bool`; count>1时 `pandas.DataFrame` | [
"判断某只股票是否全天停牌。"
] | ac40a62d4e7eca9494b4d0a14f46facf5616820c | https://github.com/ricequant/rqalpha/blob/ac40a62d4e7eca9494b4d0a14f46facf5616820c/rqalpha/mod/rqalpha_mod_sys_accounts/api/api_stock.py#L457-L469 | train |
ricequant/rqalpha | rqalpha/__main__.py | update_bundle | def update_bundle(data_bundle_path, locale):
"""
Sync Data Bundle
"""
import rqalpha.utils.bundle_helper
rqalpha.utils.bundle_helper.update_bundle(data_bundle_path, locale) | python | def update_bundle(data_bundle_path, locale):
"""
Sync Data Bundle
"""
import rqalpha.utils.bundle_helper
rqalpha.utils.bundle_helper.update_bundle(data_bundle_path, locale) | [
"def",
"update_bundle",
"(",
"data_bundle_path",
",",
"locale",
")",
":",
"import",
"rqalpha",
".",
"utils",
".",
"bundle_helper",
"rqalpha",
".",
"utils",
".",
"bundle_helper",
".",
"update_bundle",
"(",
"data_bundle_path",
",",
"locale",
")"
] | Sync Data Bundle | [
"Sync",
"Data",
"Bundle"
] | ac40a62d4e7eca9494b4d0a14f46facf5616820c | https://github.com/ricequant/rqalpha/blob/ac40a62d4e7eca9494b4d0a14f46facf5616820c/rqalpha/__main__.py#L77-L82 | train |
ricequant/rqalpha | rqalpha/__main__.py | run | def run(**kwargs):
"""
Start to run a strategy
"""
config_path = kwargs.get('config_path', None)
if config_path is not None:
config_path = os.path.abspath(config_path)
kwargs.pop('config_path')
if not kwargs.get('base__securities', None):
kwargs.pop('base__securities', No... | python | def run(**kwargs):
"""
Start to run a strategy
"""
config_path = kwargs.get('config_path', None)
if config_path is not None:
config_path = os.path.abspath(config_path)
kwargs.pop('config_path')
if not kwargs.get('base__securities', None):
kwargs.pop('base__securities', No... | [
"def",
"run",
"(",
"*",
"*",
"kwargs",
")",
":",
"config_path",
"=",
"kwargs",
".",
"get",
"(",
"'config_path'",
",",
"None",
")",
"if",
"config_path",
"is",
"not",
"None",
":",
"config_path",
"=",
"os",
".",
"path",
".",
"abspath",
"(",
"config_path",... | Start to run a strategy | [
"Start",
"to",
"run",
"a",
"strategy"
] | ac40a62d4e7eca9494b4d0a14f46facf5616820c | https://github.com/ricequant/rqalpha/blob/ac40a62d4e7eca9494b4d0a14f46facf5616820c/rqalpha/__main__.py#L112-L140 | train |
ricequant/rqalpha | rqalpha/__main__.py | examples | def examples(directory):
"""
Generate example strategies to target folder
"""
source_dir = os.path.join(os.path.dirname(os.path.realpath(__file__)), "examples")
try:
shutil.copytree(source_dir, os.path.join(directory, "examples"))
except OSError as e:
if e.errno == errno.EEXIST:... | python | def examples(directory):
"""
Generate example strategies to target folder
"""
source_dir = os.path.join(os.path.dirname(os.path.realpath(__file__)), "examples")
try:
shutil.copytree(source_dir, os.path.join(directory, "examples"))
except OSError as e:
if e.errno == errno.EEXIST:... | [
"def",
"examples",
"(",
"directory",
")",
":",
"source_dir",
"=",
"os",
".",
"path",
".",
"join",
"(",
"os",
".",
"path",
".",
"dirname",
"(",
"os",
".",
"path",
".",
"realpath",
"(",
"__file__",
")",
")",
",",
"\"examples\"",
")",
"try",
":",
"shu... | Generate example strategies to target folder | [
"Generate",
"example",
"strategies",
"to",
"target",
"folder"
] | ac40a62d4e7eca9494b4d0a14f46facf5616820c | https://github.com/ricequant/rqalpha/blob/ac40a62d4e7eca9494b4d0a14f46facf5616820c/rqalpha/__main__.py#L145-L155 | train |
ricequant/rqalpha | rqalpha/__main__.py | generate_config | def generate_config(directory):
"""
Generate default config file
"""
default_config = os.path.join(os.path.dirname(os.path.realpath(__file__)), "config.yml")
target_config_path = os.path.abspath(os.path.join(directory, 'config.yml'))
shutil.copy(default_config, target_config_path)
six.print_... | python | def generate_config(directory):
"""
Generate default config file
"""
default_config = os.path.join(os.path.dirname(os.path.realpath(__file__)), "config.yml")
target_config_path = os.path.abspath(os.path.join(directory, 'config.yml'))
shutil.copy(default_config, target_config_path)
six.print_... | [
"def",
"generate_config",
"(",
"directory",
")",
":",
"default_config",
"=",
"os",
".",
"path",
".",
"join",
"(",
"os",
".",
"path",
".",
"dirname",
"(",
"os",
".",
"path",
".",
"realpath",
"(",
"__file__",
")",
")",
",",
"\"config.yml\"",
")",
"target... | Generate default config file | [
"Generate",
"default",
"config",
"file"
] | ac40a62d4e7eca9494b4d0a14f46facf5616820c | https://github.com/ricequant/rqalpha/blob/ac40a62d4e7eca9494b4d0a14f46facf5616820c/rqalpha/__main__.py#L170-L177 | train |
ricequant/rqalpha | rqalpha/__main__.py | mod | def mod(cmd, params):
"""
Mod management command
rqalpha mod list \n
rqalpha mod install xxx \n
rqalpha mod uninstall xxx \n
rqalpha mod enable xxx \n
rqalpha mod disable xxx \n
"""
def list(params):
"""
List all mod configuration
"""
from tabulate i... | python | def mod(cmd, params):
"""
Mod management command
rqalpha mod list \n
rqalpha mod install xxx \n
rqalpha mod uninstall xxx \n
rqalpha mod enable xxx \n
rqalpha mod disable xxx \n
"""
def list(params):
"""
List all mod configuration
"""
from tabulate i... | [
"def",
"mod",
"(",
"cmd",
",",
"params",
")",
":",
"def",
"list",
"(",
"params",
")",
":",
"\"\"\"\n List all mod configuration\n \"\"\"",
"from",
"tabulate",
"import",
"tabulate",
"from",
"rqalpha",
".",
"utils",
".",
"config",
"import",
"get_mod_co... | Mod management command
rqalpha mod list \n
rqalpha mod install xxx \n
rqalpha mod uninstall xxx \n
rqalpha mod enable xxx \n
rqalpha mod disable xxx \n | [
"Mod",
"management",
"command"
] | ac40a62d4e7eca9494b4d0a14f46facf5616820c | https://github.com/ricequant/rqalpha/blob/ac40a62d4e7eca9494b4d0a14f46facf5616820c/rqalpha/__main__.py#L188-L379 | train |
ricequant/rqalpha | rqalpha/mod/rqalpha_mod_sys_analyser/__init__.py | plot | def plot(result_pickle_file_path, show, plot_save_file):
"""
[sys_analyser] draw result DataFrame
"""
import pandas as pd
from .plot import plot_result
result_dict = pd.read_pickle(result_pickle_file_path)
plot_result(result_dict, show, plot_save_file) | python | def plot(result_pickle_file_path, show, plot_save_file):
"""
[sys_analyser] draw result DataFrame
"""
import pandas as pd
from .plot import plot_result
result_dict = pd.read_pickle(result_pickle_file_path)
plot_result(result_dict, show, plot_save_file) | [
"def",
"plot",
"(",
"result_pickle_file_path",
",",
"show",
",",
"plot_save_file",
")",
":",
"import",
"pandas",
"as",
"pd",
"from",
".",
"plot",
"import",
"plot_result",
"result_dict",
"=",
"pd",
".",
"read_pickle",
"(",
"result_pickle_file_path",
")",
"plot_re... | [sys_analyser] draw result DataFrame | [
"[",
"sys_analyser",
"]",
"draw",
"result",
"DataFrame"
] | ac40a62d4e7eca9494b4d0a14f46facf5616820c | https://github.com/ricequant/rqalpha/blob/ac40a62d4e7eca9494b4d0a14f46facf5616820c/rqalpha/mod/rqalpha_mod_sys_analyser/__init__.py#L78-L86 | train |
ricequant/rqalpha | rqalpha/mod/rqalpha_mod_sys_analyser/__init__.py | report | def report(result_pickle_file_path, target_report_csv_path):
"""
[sys_analyser] Generate report from backtest output file
"""
import pandas as pd
result_dict = pd.read_pickle(result_pickle_file_path)
from .report import generate_report
generate_report(result_dict, target_report_csv_path) | python | def report(result_pickle_file_path, target_report_csv_path):
"""
[sys_analyser] Generate report from backtest output file
"""
import pandas as pd
result_dict = pd.read_pickle(result_pickle_file_path)
from .report import generate_report
generate_report(result_dict, target_report_csv_path) | [
"def",
"report",
"(",
"result_pickle_file_path",
",",
"target_report_csv_path",
")",
":",
"import",
"pandas",
"as",
"pd",
"result_dict",
"=",
"pd",
".",
"read_pickle",
"(",
"result_pickle_file_path",
")",
"from",
".",
"report",
"import",
"generate_report",
"generate... | [sys_analyser] Generate report from backtest output file | [
"[",
"sys_analyser",
"]",
"Generate",
"report",
"from",
"backtest",
"output",
"file"
] | ac40a62d4e7eca9494b4d0a14f46facf5616820c | https://github.com/ricequant/rqalpha/blob/ac40a62d4e7eca9494b4d0a14f46facf5616820c/rqalpha/mod/rqalpha_mod_sys_analyser/__init__.py#L92-L100 | train |
ricequant/rqalpha | rqalpha/mod/rqalpha_mod_sys_accounts/account_model/future_account.py | FutureAccount.margin | def margin(self):
"""
[float] 总保证金
"""
return sum(position.margin for position in six.itervalues(self._positions)) | python | def margin(self):
"""
[float] 总保证金
"""
return sum(position.margin for position in six.itervalues(self._positions)) | [
"def",
"margin",
"(",
"self",
")",
":",
"return",
"sum",
"(",
"position",
".",
"margin",
"for",
"position",
"in",
"six",
".",
"itervalues",
"(",
"self",
".",
"_positions",
")",
")"
] | [float] 总保证金 | [
"[",
"float",
"]",
"总保证金"
] | ac40a62d4e7eca9494b4d0a14f46facf5616820c | https://github.com/ricequant/rqalpha/blob/ac40a62d4e7eca9494b4d0a14f46facf5616820c/rqalpha/mod/rqalpha_mod_sys_accounts/account_model/future_account.py#L177-L181 | train |
ricequant/rqalpha | rqalpha/mod/rqalpha_mod_sys_accounts/account_model/future_account.py | FutureAccount.buy_margin | def buy_margin(self):
"""
[float] 买方向保证金
"""
return sum(position.buy_margin for position in six.itervalues(self._positions)) | python | def buy_margin(self):
"""
[float] 买方向保证金
"""
return sum(position.buy_margin for position in six.itervalues(self._positions)) | [
"def",
"buy_margin",
"(",
"self",
")",
":",
"return",
"sum",
"(",
"position",
".",
"buy_margin",
"for",
"position",
"in",
"six",
".",
"itervalues",
"(",
"self",
".",
"_positions",
")",
")"
] | [float] 买方向保证金 | [
"[",
"float",
"]",
"买方向保证金"
] | ac40a62d4e7eca9494b4d0a14f46facf5616820c | https://github.com/ricequant/rqalpha/blob/ac40a62d4e7eca9494b4d0a14f46facf5616820c/rqalpha/mod/rqalpha_mod_sys_accounts/account_model/future_account.py#L184-L188 | train |
ricequant/rqalpha | rqalpha/mod/rqalpha_mod_sys_accounts/account_model/future_account.py | FutureAccount.sell_margin | def sell_margin(self):
"""
[float] 卖方向保证金
"""
return sum(position.sell_margin for position in six.itervalues(self._positions)) | python | def sell_margin(self):
"""
[float] 卖方向保证金
"""
return sum(position.sell_margin for position in six.itervalues(self._positions)) | [
"def",
"sell_margin",
"(",
"self",
")",
":",
"return",
"sum",
"(",
"position",
".",
"sell_margin",
"for",
"position",
"in",
"six",
".",
"itervalues",
"(",
"self",
".",
"_positions",
")",
")"
] | [float] 卖方向保证金 | [
"[",
"float",
"]",
"卖方向保证金"
] | ac40a62d4e7eca9494b4d0a14f46facf5616820c | https://github.com/ricequant/rqalpha/blob/ac40a62d4e7eca9494b4d0a14f46facf5616820c/rqalpha/mod/rqalpha_mod_sys_accounts/account_model/future_account.py#L191-L195 | train |
ricequant/rqalpha | rqalpha/mod/rqalpha_mod_sys_accounts/account_model/future_account.py | FutureAccount.holding_pnl | def holding_pnl(self):
"""
[float] 浮动盈亏
"""
return sum(position.holding_pnl for position in six.itervalues(self._positions)) | python | def holding_pnl(self):
"""
[float] 浮动盈亏
"""
return sum(position.holding_pnl for position in six.itervalues(self._positions)) | [
"def",
"holding_pnl",
"(",
"self",
")",
":",
"return",
"sum",
"(",
"position",
".",
"holding_pnl",
"for",
"position",
"in",
"six",
".",
"itervalues",
"(",
"self",
".",
"_positions",
")",
")"
] | [float] 浮动盈亏 | [
"[",
"float",
"]",
"浮动盈亏"
] | ac40a62d4e7eca9494b4d0a14f46facf5616820c | https://github.com/ricequant/rqalpha/blob/ac40a62d4e7eca9494b4d0a14f46facf5616820c/rqalpha/mod/rqalpha_mod_sys_accounts/account_model/future_account.py#L206-L210 | train |
ricequant/rqalpha | rqalpha/mod/rqalpha_mod_sys_accounts/account_model/future_account.py | FutureAccount.realized_pnl | def realized_pnl(self):
"""
[float] 平仓盈亏
"""
return sum(position.realized_pnl for position in six.itervalues(self._positions)) | python | def realized_pnl(self):
"""
[float] 平仓盈亏
"""
return sum(position.realized_pnl for position in six.itervalues(self._positions)) | [
"def",
"realized_pnl",
"(",
"self",
")",
":",
"return",
"sum",
"(",
"position",
".",
"realized_pnl",
"for",
"position",
"in",
"six",
".",
"itervalues",
"(",
"self",
".",
"_positions",
")",
")"
] | [float] 平仓盈亏 | [
"[",
"float",
"]",
"平仓盈亏"
] | ac40a62d4e7eca9494b4d0a14f46facf5616820c | https://github.com/ricequant/rqalpha/blob/ac40a62d4e7eca9494b4d0a14f46facf5616820c/rqalpha/mod/rqalpha_mod_sys_accounts/account_model/future_account.py#L213-L217 | train |
ricequant/rqalpha | rqalpha/api/api_extension.py | order | def order(order_book_id, quantity, price=None, style=None):
"""
全品种通用智能调仓函数
如果不指定 price, 则相当于下 MarketOrder
如果 order_book_id 是股票,等同于调用 order_shares
如果 order_book_id 是期货,则进行智能下单:
* quantity 表示调仓量
* 如果 quantity 为正数,则先平 Sell 方向仓位,再开 Buy 方向仓位
* 如果 quantity 为负数,则先平 Buy 反向... | python | def order(order_book_id, quantity, price=None, style=None):
"""
全品种通用智能调仓函数
如果不指定 price, 则相当于下 MarketOrder
如果 order_book_id 是股票,等同于调用 order_shares
如果 order_book_id 是期货,则进行智能下单:
* quantity 表示调仓量
* 如果 quantity 为正数,则先平 Sell 方向仓位,再开 Buy 方向仓位
* 如果 quantity 为负数,则先平 Buy 反向... | [
"def",
"order",
"(",
"order_book_id",
",",
"quantity",
",",
"price",
"=",
"None",
",",
"style",
"=",
"None",
")",
":",
"style",
"=",
"cal_style",
"(",
"price",
",",
"style",
")",
"orders",
"=",
"Environment",
".",
"get_instance",
"(",
")",
".",
"portfo... | 全品种通用智能调仓函数
如果不指定 price, 则相当于下 MarketOrder
如果 order_book_id 是股票,等同于调用 order_shares
如果 order_book_id 是期货,则进行智能下单:
* quantity 表示调仓量
* 如果 quantity 为正数,则先平 Sell 方向仓位,再开 Buy 方向仓位
* 如果 quantity 为负数,则先平 Buy 反向仓位,再开 Sell 方向仓位
:param order_book_id: 下单标的物
:type order_book_id... | [
"全品种通用智能调仓函数"
] | ac40a62d4e7eca9494b4d0a14f46facf5616820c | https://github.com/ricequant/rqalpha/blob/ac40a62d4e7eca9494b4d0a14f46facf5616820c/rqalpha/api/api_extension.py#L52-L96 | train |
elastic/elasticsearch-py | elasticsearch/client/xpack/sql.py | SqlClient.clear_cursor | def clear_cursor(self, body, params=None):
"""
`<Clear SQL cursor>`_
:arg body: Specify the cursor value in the `cursor` element to clean the
cursor.
"""
if body in SKIP_IN_PATH:
raise ValueError("Empty value passed for a required argument 'body'.")
... | python | def clear_cursor(self, body, params=None):
"""
`<Clear SQL cursor>`_
:arg body: Specify the cursor value in the `cursor` element to clean the
cursor.
"""
if body in SKIP_IN_PATH:
raise ValueError("Empty value passed for a required argument 'body'.")
... | [
"def",
"clear_cursor",
"(",
"self",
",",
"body",
",",
"params",
"=",
"None",
")",
":",
"if",
"body",
"in",
"SKIP_IN_PATH",
":",
"raise",
"ValueError",
"(",
"\"Empty value passed for a required argument 'body'.\"",
")",
"return",
"self",
".",
"transport",
".",
"p... | `<Clear SQL cursor>`_
:arg body: Specify the cursor value in the `cursor` element to clean the
cursor. | [
"<Clear",
"SQL",
"cursor",
">",
"_"
] | 2aab285c8f506f3863cbdaba3c90a685c510ba00 | https://github.com/elastic/elasticsearch-py/blob/2aab285c8f506f3863cbdaba3c90a685c510ba00/elasticsearch/client/xpack/sql.py#L6-L17 | train |
elastic/elasticsearch-py | elasticsearch/client/xpack/sql.py | SqlClient.query | def query(self, body, params=None):
"""
`<Execute SQL>`_
:arg body: Use the `query` element to start a query. Use the `cursor`
element to continue a query.
:arg format: a short version of the Accept header, e.g. json, yaml
"""
if body in SKIP_IN_PATH:
... | python | def query(self, body, params=None):
"""
`<Execute SQL>`_
:arg body: Use the `query` element to start a query. Use the `cursor`
element to continue a query.
:arg format: a short version of the Accept header, e.g. json, yaml
"""
if body in SKIP_IN_PATH:
... | [
"def",
"query",
"(",
"self",
",",
"body",
",",
"params",
"=",
"None",
")",
":",
"if",
"body",
"in",
"SKIP_IN_PATH",
":",
"raise",
"ValueError",
"(",
"\"Empty value passed for a required argument 'body'.\"",
")",
"return",
"self",
".",
"transport",
".",
"perform_... | `<Execute SQL>`_
:arg body: Use the `query` element to start a query. Use the `cursor`
element to continue a query.
:arg format: a short version of the Accept header, e.g. json, yaml | [
"<Execute",
"SQL",
">",
"_"
] | 2aab285c8f506f3863cbdaba3c90a685c510ba00 | https://github.com/elastic/elasticsearch-py/blob/2aab285c8f506f3863cbdaba3c90a685c510ba00/elasticsearch/client/xpack/sql.py#L20-L30 | train |
elastic/elasticsearch-py | elasticsearch/client/xpack/sql.py | SqlClient.translate | def translate(self, body, params=None):
"""
`<Translate SQL into Elasticsearch queries>`_
:arg body: Specify the query in the `query` element.
"""
if body in SKIP_IN_PATH:
raise ValueError("Empty value passed for a required argument 'body'.")
return self.tran... | python | def translate(self, body, params=None):
"""
`<Translate SQL into Elasticsearch queries>`_
:arg body: Specify the query in the `query` element.
"""
if body in SKIP_IN_PATH:
raise ValueError("Empty value passed for a required argument 'body'.")
return self.tran... | [
"def",
"translate",
"(",
"self",
",",
"body",
",",
"params",
"=",
"None",
")",
":",
"if",
"body",
"in",
"SKIP_IN_PATH",
":",
"raise",
"ValueError",
"(",
"\"Empty value passed for a required argument 'body'.\"",
")",
"return",
"self",
".",
"transport",
".",
"perf... | `<Translate SQL into Elasticsearch queries>`_
:arg body: Specify the query in the `query` element. | [
"<Translate",
"SQL",
"into",
"Elasticsearch",
"queries",
">",
"_"
] | 2aab285c8f506f3863cbdaba3c90a685c510ba00 | https://github.com/elastic/elasticsearch-py/blob/2aab285c8f506f3863cbdaba3c90a685c510ba00/elasticsearch/client/xpack/sql.py#L33-L43 | train |
elastic/elasticsearch-py | elasticsearch/connection/base.py | Connection.log_request_success | def log_request_success(self, method, full_url, path, body, status_code, response, duration):
""" Log a successful API call. """
# TODO: optionally pass in params instead of full_url and do urlencode only when needed
# body has already been serialized to utf-8, deserialize it for logging
... | python | def log_request_success(self, method, full_url, path, body, status_code, response, duration):
""" Log a successful API call. """
# TODO: optionally pass in params instead of full_url and do urlencode only when needed
# body has already been serialized to utf-8, deserialize it for logging
... | [
"def",
"log_request_success",
"(",
"self",
",",
"method",
",",
"full_url",
",",
"path",
",",
"body",
",",
"status_code",
",",
"response",
",",
"duration",
")",
":",
"# TODO: optionally pass in params instead of full_url and do urlencode only when needed",
"# body has alrea... | Log a successful API call. | [
"Log",
"a",
"successful",
"API",
"call",
"."
] | 2aab285c8f506f3863cbdaba3c90a685c510ba00 | https://github.com/elastic/elasticsearch-py/blob/2aab285c8f506f3863cbdaba3c90a685c510ba00/elasticsearch/connection/base.py#L72-L91 | train |
elastic/elasticsearch-py | elasticsearch/connection/base.py | Connection.log_request_fail | def log_request_fail(self, method, full_url, path, body, duration, status_code=None, response=None, exception=None):
""" Log an unsuccessful API call. """
# do not log 404s on HEAD requests
if method == 'HEAD' and status_code == 404:
return
logger.warning(
'%s %s... | python | def log_request_fail(self, method, full_url, path, body, duration, status_code=None, response=None, exception=None):
""" Log an unsuccessful API call. """
# do not log 404s on HEAD requests
if method == 'HEAD' and status_code == 404:
return
logger.warning(
'%s %s... | [
"def",
"log_request_fail",
"(",
"self",
",",
"method",
",",
"full_url",
",",
"path",
",",
"body",
",",
"duration",
",",
"status_code",
"=",
"None",
",",
"response",
"=",
"None",
",",
"exception",
"=",
"None",
")",
":",
"# do not log 404s on HEAD requests",
"... | Log an unsuccessful API call. | [
"Log",
"an",
"unsuccessful",
"API",
"call",
"."
] | 2aab285c8f506f3863cbdaba3c90a685c510ba00 | https://github.com/elastic/elasticsearch-py/blob/2aab285c8f506f3863cbdaba3c90a685c510ba00/elasticsearch/connection/base.py#L93-L116 | train |
elastic/elasticsearch-py | elasticsearch/connection/base.py | Connection._raise_error | def _raise_error(self, status_code, raw_data):
""" Locate appropriate exception and raise it. """
error_message = raw_data
additional_info = None
try:
if raw_data:
additional_info = json.loads(raw_data)
error_message = additional_info.get('erro... | python | def _raise_error(self, status_code, raw_data):
""" Locate appropriate exception and raise it. """
error_message = raw_data
additional_info = None
try:
if raw_data:
additional_info = json.loads(raw_data)
error_message = additional_info.get('erro... | [
"def",
"_raise_error",
"(",
"self",
",",
"status_code",
",",
"raw_data",
")",
":",
"error_message",
"=",
"raw_data",
"additional_info",
"=",
"None",
"try",
":",
"if",
"raw_data",
":",
"additional_info",
"=",
"json",
".",
"loads",
"(",
"raw_data",
")",
"error... | Locate appropriate exception and raise it. | [
"Locate",
"appropriate",
"exception",
"and",
"raise",
"it",
"."
] | 2aab285c8f506f3863cbdaba3c90a685c510ba00 | https://github.com/elastic/elasticsearch-py/blob/2aab285c8f506f3863cbdaba3c90a685c510ba00/elasticsearch/connection/base.py#L118-L131 | train |
elastic/elasticsearch-py | elasticsearch/client/__init__.py | _normalize_hosts | def _normalize_hosts(hosts):
"""
Helper function to transform hosts argument to
:class:`~elasticsearch.Elasticsearch` to a list of dicts.
"""
# if hosts are empty, just defer to defaults down the line
if hosts is None:
return [{}]
# passed in just one string
if isinstance(hosts,... | python | def _normalize_hosts(hosts):
"""
Helper function to transform hosts argument to
:class:`~elasticsearch.Elasticsearch` to a list of dicts.
"""
# if hosts are empty, just defer to defaults down the line
if hosts is None:
return [{}]
# passed in just one string
if isinstance(hosts,... | [
"def",
"_normalize_hosts",
"(",
"hosts",
")",
":",
"# if hosts are empty, just defer to defaults down the line",
"if",
"hosts",
"is",
"None",
":",
"return",
"[",
"{",
"}",
"]",
"# passed in just one string",
"if",
"isinstance",
"(",
"hosts",
",",
"string_types",
")",
... | Helper function to transform hosts argument to
:class:`~elasticsearch.Elasticsearch` to a list of dicts. | [
"Helper",
"function",
"to",
"transform",
"hosts",
"argument",
"to",
":",
"class",
":",
"~elasticsearch",
".",
"Elasticsearch",
"to",
"a",
"list",
"of",
"dicts",
"."
] | 2aab285c8f506f3863cbdaba3c90a685c510ba00 | https://github.com/elastic/elasticsearch-py/blob/2aab285c8f506f3863cbdaba3c90a685c510ba00/elasticsearch/client/__init__.py#L21-L63 | train |
elastic/elasticsearch-py | elasticsearch/client/__init__.py | Elasticsearch.ping | def ping(self, params=None):
"""
Returns True if the cluster is up, False otherwise.
`<http://www.elastic.co/guide/>`_
"""
try:
return self.transport.perform_request("HEAD", "/", params=params)
except TransportError:
return False | python | def ping(self, params=None):
"""
Returns True if the cluster is up, False otherwise.
`<http://www.elastic.co/guide/>`_
"""
try:
return self.transport.perform_request("HEAD", "/", params=params)
except TransportError:
return False | [
"def",
"ping",
"(",
"self",
",",
"params",
"=",
"None",
")",
":",
"try",
":",
"return",
"self",
".",
"transport",
".",
"perform_request",
"(",
"\"HEAD\"",
",",
"\"/\"",
",",
"params",
"=",
"params",
")",
"except",
"TransportError",
":",
"return",
"False"... | Returns True if the cluster is up, False otherwise.
`<http://www.elastic.co/guide/>`_ | [
"Returns",
"True",
"if",
"the",
"cluster",
"is",
"up",
"False",
"otherwise",
".",
"<http",
":",
"//",
"www",
".",
"elastic",
".",
"co",
"/",
"guide",
"/",
">",
"_"
] | 2aab285c8f506f3863cbdaba3c90a685c510ba00 | https://github.com/elastic/elasticsearch-py/blob/2aab285c8f506f3863cbdaba3c90a685c510ba00/elasticsearch/client/__init__.py#L243-L251 | train |
elastic/elasticsearch-py | elasticsearch/client/__init__.py | Elasticsearch.mget | def mget(self, body, doc_type=None, index=None, params=None):
"""
Get multiple documents based on an index, type (optional) and ids.
`<http://www.elastic.co/guide/en/elasticsearch/reference/current/docs-multi-get.html>`_
:arg body: Document identifiers; can be either `docs` (containing ... | python | def mget(self, body, doc_type=None, index=None, params=None):
"""
Get multiple documents based on an index, type (optional) and ids.
`<http://www.elastic.co/guide/en/elasticsearch/reference/current/docs-multi-get.html>`_
:arg body: Document identifiers; can be either `docs` (containing ... | [
"def",
"mget",
"(",
"self",
",",
"body",
",",
"doc_type",
"=",
"None",
",",
"index",
"=",
"None",
",",
"params",
"=",
"None",
")",
":",
"if",
"body",
"in",
"SKIP_IN_PATH",
":",
"raise",
"ValueError",
"(",
"\"Empty value passed for a required argument 'body'.\"... | Get multiple documents based on an index, type (optional) and ids.
`<http://www.elastic.co/guide/en/elasticsearch/reference/current/docs-multi-get.html>`_
:arg body: Document identifiers; can be either `docs` (containing full
document information) or `ids` (when index and type is provided i... | [
"Get",
"multiple",
"documents",
"based",
"on",
"an",
"index",
"type",
"(",
"optional",
")",
"and",
"ids",
".",
"<http",
":",
"//",
"www",
".",
"elastic",
".",
"co",
"/",
"guide",
"/",
"en",
"/",
"elasticsearch",
"/",
"reference",
"/",
"current",
"/",
... | 2aab285c8f506f3863cbdaba3c90a685c510ba00 | https://github.com/elastic/elasticsearch-py/blob/2aab285c8f506f3863cbdaba3c90a685c510ba00/elasticsearch/client/__init__.py#L566-L595 | train |
elastic/elasticsearch-py | elasticsearch/client/__init__.py | Elasticsearch.update | def update(self, index, id, doc_type="_doc", body=None, params=None):
"""
Update a document based on a script or partial data provided.
`<http://www.elastic.co/guide/en/elasticsearch/reference/current/docs-update.html>`_
:arg index: The name of the index
:arg id: Document ID
... | python | def update(self, index, id, doc_type="_doc", body=None, params=None):
"""
Update a document based on a script or partial data provided.
`<http://www.elastic.co/guide/en/elasticsearch/reference/current/docs-update.html>`_
:arg index: The name of the index
:arg id: Document ID
... | [
"def",
"update",
"(",
"self",
",",
"index",
",",
"id",
",",
"doc_type",
"=",
"\"_doc\"",
",",
"body",
"=",
"None",
",",
"params",
"=",
"None",
")",
":",
"for",
"param",
"in",
"(",
"index",
",",
"id",
")",
":",
"if",
"param",
"in",
"SKIP_IN_PATH",
... | Update a document based on a script or partial data provided.
`<http://www.elastic.co/guide/en/elasticsearch/reference/current/docs-update.html>`_
:arg index: The name of the index
:arg id: Document ID
:arg body: The request definition using either `script` or partial `doc`
:arg... | [
"Update",
"a",
"document",
"based",
"on",
"a",
"script",
"or",
"partial",
"data",
"provided",
".",
"<http",
":",
"//",
"www",
".",
"elastic",
".",
"co",
"/",
"guide",
"/",
"en",
"/",
"elasticsearch",
"/",
"reference",
"/",
"current",
"/",
"docs",
"-",
... | 2aab285c8f506f3863cbdaba3c90a685c510ba00 | https://github.com/elastic/elasticsearch-py/blob/2aab285c8f506f3863cbdaba3c90a685c510ba00/elasticsearch/client/__init__.py#L618-L662 | train |
elastic/elasticsearch-py | elasticsearch/client/__init__.py | Elasticsearch.search | def search(self, index=None, body=None, params=None):
"""
Execute a search query and get back search hits that match the query.
`<http://www.elastic.co/guide/en/elasticsearch/reference/current/search-search.html>`_
:arg index: A list of index names to search, or a string containing a
... | python | def search(self, index=None, body=None, params=None):
"""
Execute a search query and get back search hits that match the query.
`<http://www.elastic.co/guide/en/elasticsearch/reference/current/search-search.html>`_
:arg index: A list of index names to search, or a string containing a
... | [
"def",
"search",
"(",
"self",
",",
"index",
"=",
"None",
",",
"body",
"=",
"None",
",",
"params",
"=",
"None",
")",
":",
"# from is a reserved word so it cannot be used, use from_ instead",
"if",
"\"from_\"",
"in",
"params",
":",
"params",
"[",
"\"from\"",
"]",
... | Execute a search query and get back search hits that match the query.
`<http://www.elastic.co/guide/en/elasticsearch/reference/current/search-search.html>`_
:arg index: A list of index names to search, or a string containing a
comma-separated list of index names to search; use `_all`
... | [
"Execute",
"a",
"search",
"query",
"and",
"get",
"back",
"search",
"hits",
"that",
"match",
"the",
"query",
".",
"<http",
":",
"//",
"www",
".",
"elastic",
".",
"co",
"/",
"guide",
"/",
"en",
"/",
"elasticsearch",
"/",
"reference",
"/",
"current",
"/",... | 2aab285c8f506f3863cbdaba3c90a685c510ba00 | https://github.com/elastic/elasticsearch-py/blob/2aab285c8f506f3863cbdaba3c90a685c510ba00/elasticsearch/client/__init__.py#L709-L813 | train |
elastic/elasticsearch-py | elasticsearch/client/__init__.py | Elasticsearch.reindex | def reindex(self, body, params=None):
"""
Reindex all documents from one index to another.
`<https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-reindex.html>`_
:arg body: The search definition using the Query DSL and the prototype
for the index request.
... | python | def reindex(self, body, params=None):
"""
Reindex all documents from one index to another.
`<https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-reindex.html>`_
:arg body: The search definition using the Query DSL and the prototype
for the index request.
... | [
"def",
"reindex",
"(",
"self",
",",
"body",
",",
"params",
"=",
"None",
")",
":",
"if",
"body",
"in",
"SKIP_IN_PATH",
":",
"raise",
"ValueError",
"(",
"\"Empty value passed for a required argument 'body'.\"",
")",
"return",
"self",
".",
"transport",
".",
"perfor... | Reindex all documents from one index to another.
`<https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-reindex.html>`_
:arg body: The search definition using the Query DSL and the prototype
for the index request.
:arg refresh: Should the effected indexes be refreshe... | [
"Reindex",
"all",
"documents",
"from",
"one",
"index",
"to",
"another",
".",
"<https",
":",
"//",
"www",
".",
"elastic",
".",
"co",
"/",
"guide",
"/",
"en",
"/",
"elasticsearch",
"/",
"reference",
"/",
"current",
"/",
"docs",
"-",
"reindex",
".",
"html... | 2aab285c8f506f3863cbdaba3c90a685c510ba00 | https://github.com/elastic/elasticsearch-py/blob/2aab285c8f506f3863cbdaba3c90a685c510ba00/elasticsearch/client/__init__.py#L946-L973 | train |
elastic/elasticsearch-py | elasticsearch/client/__init__.py | Elasticsearch.reindex_rethrottle | def reindex_rethrottle(self, task_id=None, params=None):
"""
Change the value of ``requests_per_second`` of a running ``reindex`` task.
`<https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-reindex.html>`_
:arg task_id: The task id to rethrottle
:arg requests_pe... | python | def reindex_rethrottle(self, task_id=None, params=None):
"""
Change the value of ``requests_per_second`` of a running ``reindex`` task.
`<https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-reindex.html>`_
:arg task_id: The task id to rethrottle
:arg requests_pe... | [
"def",
"reindex_rethrottle",
"(",
"self",
",",
"task_id",
"=",
"None",
",",
"params",
"=",
"None",
")",
":",
"return",
"self",
".",
"transport",
".",
"perform_request",
"(",
"\"POST\"",
",",
"_make_path",
"(",
"\"_reindex\"",
",",
"task_id",
",",
"\"_rethrot... | Change the value of ``requests_per_second`` of a running ``reindex`` task.
`<https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-reindex.html>`_
:arg task_id: The task id to rethrottle
:arg requests_per_second: The throttle to set on this request in
floating sub-req... | [
"Change",
"the",
"value",
"of",
"requests_per_second",
"of",
"a",
"running",
"reindex",
"task",
".",
"<https",
":",
"//",
"www",
".",
"elastic",
".",
"co",
"/",
"guide",
"/",
"en",
"/",
"elasticsearch",
"/",
"reference",
"/",
"current",
"/",
"docs",
"-",... | 2aab285c8f506f3863cbdaba3c90a685c510ba00 | https://github.com/elastic/elasticsearch-py/blob/2aab285c8f506f3863cbdaba3c90a685c510ba00/elasticsearch/client/__init__.py#L976-L987 | train |
elastic/elasticsearch-py | elasticsearch/client/__init__.py | Elasticsearch.search_shards | def search_shards(self, index=None, params=None):
"""
The search shards api returns the indices and shards that a search
request would be executed against. This can give useful feedback for working
out issues or planning optimizations with routing and shard preferences.
`<http://... | python | def search_shards(self, index=None, params=None):
"""
The search shards api returns the indices and shards that a search
request would be executed against. This can give useful feedback for working
out issues or planning optimizations with routing and shard preferences.
`<http://... | [
"def",
"search_shards",
"(",
"self",
",",
"index",
"=",
"None",
",",
"params",
"=",
"None",
")",
":",
"return",
"self",
".",
"transport",
".",
"perform_request",
"(",
"\"GET\"",
",",
"_make_path",
"(",
"index",
",",
"\"_search_shards\"",
")",
",",
"params"... | The search shards api returns the indices and shards that a search
request would be executed against. This can give useful feedback for working
out issues or planning optimizations with routing and shard preferences.
`<http://www.elastic.co/guide/en/elasticsearch/reference/current/search-shards.... | [
"The",
"search",
"shards",
"api",
"returns",
"the",
"indices",
"and",
"shards",
"that",
"a",
"search",
"request",
"would",
"be",
"executed",
"against",
".",
"This",
"can",
"give",
"useful",
"feedback",
"for",
"working",
"out",
"issues",
"or",
"planning",
"op... | 2aab285c8f506f3863cbdaba3c90a685c510ba00 | https://github.com/elastic/elasticsearch-py/blob/2aab285c8f506f3863cbdaba3c90a685c510ba00/elasticsearch/client/__init__.py#L1115-L1141 | train |
elastic/elasticsearch-py | elasticsearch/client/__init__.py | Elasticsearch.search_template | def search_template(self, index=None, body=None, params=None):
"""
A query that accepts a query template and a map of key/value pairs to
fill in template parameters.
`<http://www.elastic.co/guide/en/elasticsearch/reference/current/search-template.html>`_
:arg index: A list of in... | python | def search_template(self, index=None, body=None, params=None):
"""
A query that accepts a query template and a map of key/value pairs to
fill in template parameters.
`<http://www.elastic.co/guide/en/elasticsearch/reference/current/search-template.html>`_
:arg index: A list of in... | [
"def",
"search_template",
"(",
"self",
",",
"index",
"=",
"None",
",",
"body",
"=",
"None",
",",
"params",
"=",
"None",
")",
":",
"return",
"self",
".",
"transport",
".",
"perform_request",
"(",
"\"GET\"",
",",
"_make_path",
"(",
"index",
",",
"\"_search... | A query that accepts a query template and a map of key/value pairs to
fill in template parameters.
`<http://www.elastic.co/guide/en/elasticsearch/reference/current/search-template.html>`_
:arg index: A list of index names to search, or a string containing a
comma-separated list of i... | [
"A",
"query",
"that",
"accepts",
"a",
"query",
"template",
"and",
"a",
"map",
"of",
"key",
"/",
"value",
"pairs",
"to",
"fill",
"in",
"template",
"parameters",
".",
"<http",
":",
"//",
"www",
".",
"elastic",
".",
"co",
"/",
"guide",
"/",
"en",
"/",
... | 2aab285c8f506f3863cbdaba3c90a685c510ba00 | https://github.com/elastic/elasticsearch-py/blob/2aab285c8f506f3863cbdaba3c90a685c510ba00/elasticsearch/client/__init__.py#L1155-L1189 | train |
elastic/elasticsearch-py | elasticsearch/client/__init__.py | Elasticsearch.scroll | def scroll(self, scroll_id=None, body=None, params=None):
"""
Scroll a search request created by specifying the scroll parameter.
`<http://www.elastic.co/guide/en/elasticsearch/reference/current/search-request-scroll.html>`_
:arg scroll_id: The scroll ID
:arg body: The scroll ID... | python | def scroll(self, scroll_id=None, body=None, params=None):
"""
Scroll a search request created by specifying the scroll parameter.
`<http://www.elastic.co/guide/en/elasticsearch/reference/current/search-request-scroll.html>`_
:arg scroll_id: The scroll ID
:arg body: The scroll ID... | [
"def",
"scroll",
"(",
"self",
",",
"scroll_id",
"=",
"None",
",",
"body",
"=",
"None",
",",
"params",
"=",
"None",
")",
":",
"if",
"scroll_id",
"in",
"SKIP_IN_PATH",
"and",
"body",
"in",
"SKIP_IN_PATH",
":",
"raise",
"ValueError",
"(",
"\"You need to suppl... | Scroll a search request created by specifying the scroll parameter.
`<http://www.elastic.co/guide/en/elasticsearch/reference/current/search-request-scroll.html>`_
:arg scroll_id: The scroll ID
:arg body: The scroll ID if not passed by URL or query parameter.
:arg scroll: Specify how lon... | [
"Scroll",
"a",
"search",
"request",
"created",
"by",
"specifying",
"the",
"scroll",
"parameter",
".",
"<http",
":",
"//",
"www",
".",
"elastic",
".",
"co",
"/",
"guide",
"/",
"en",
"/",
"elasticsearch",
"/",
"reference",
"/",
"current",
"/",
"search",
"-... | 2aab285c8f506f3863cbdaba3c90a685c510ba00 | https://github.com/elastic/elasticsearch-py/blob/2aab285c8f506f3863cbdaba3c90a685c510ba00/elasticsearch/client/__init__.py#L1248-L1270 | train |
elastic/elasticsearch-py | elasticsearch/client/__init__.py | Elasticsearch.mtermvectors | def mtermvectors(self, doc_type=None, index=None, body=None, params=None):
"""
Multi termvectors API allows to get multiple termvectors based on an
index, type and id.
`<http://www.elastic.co/guide/en/elasticsearch/reference/current/docs-multi-termvectors.html>`_
:arg index: The... | python | def mtermvectors(self, doc_type=None, index=None, body=None, params=None):
"""
Multi termvectors API allows to get multiple termvectors based on an
index, type and id.
`<http://www.elastic.co/guide/en/elasticsearch/reference/current/docs-multi-termvectors.html>`_
:arg index: The... | [
"def",
"mtermvectors",
"(",
"self",
",",
"doc_type",
"=",
"None",
",",
"index",
"=",
"None",
",",
"body",
"=",
"None",
",",
"params",
"=",
"None",
")",
":",
"return",
"self",
".",
"transport",
".",
"perform_request",
"(",
"\"GET\"",
",",
"_make_path",
... | Multi termvectors API allows to get multiple termvectors based on an
index, type and id.
`<http://www.elastic.co/guide/en/elasticsearch/reference/current/docs-multi-termvectors.html>`_
:arg index: The index in which the document resides.
:arg body: Define ids, documents, parameters or a... | [
"Multi",
"termvectors",
"API",
"allows",
"to",
"get",
"multiple",
"termvectors",
"based",
"on",
"an",
"index",
"type",
"and",
"id",
".",
"<http",
":",
"//",
"www",
".",
"elastic",
".",
"co",
"/",
"guide",
"/",
"en",
"/",
"elasticsearch",
"/",
"reference"... | 2aab285c8f506f3863cbdaba3c90a685c510ba00 | https://github.com/elastic/elasticsearch-py/blob/2aab285c8f506f3863cbdaba3c90a685c510ba00/elasticsearch/client/__init__.py#L1565-L1615 | train |
elastic/elasticsearch-py | elasticsearch/client/__init__.py | Elasticsearch.put_script | def put_script(self, id, body, context=None, params=None):
"""
Create a script in given language with specified ID.
`<http://www.elastic.co/guide/en/elasticsearch/reference/current/modules-scripting.html>`_
:arg id: Script ID
:arg body: The document
"""
for param... | python | def put_script(self, id, body, context=None, params=None):
"""
Create a script in given language with specified ID.
`<http://www.elastic.co/guide/en/elasticsearch/reference/current/modules-scripting.html>`_
:arg id: Script ID
:arg body: The document
"""
for param... | [
"def",
"put_script",
"(",
"self",
",",
"id",
",",
"body",
",",
"context",
"=",
"None",
",",
"params",
"=",
"None",
")",
":",
"for",
"param",
"in",
"(",
"id",
",",
"body",
")",
":",
"if",
"param",
"in",
"SKIP_IN_PATH",
":",
"raise",
"ValueError",
"(... | Create a script in given language with specified ID.
`<http://www.elastic.co/guide/en/elasticsearch/reference/current/modules-scripting.html>`_
:arg id: Script ID
:arg body: The document | [
"Create",
"a",
"script",
"in",
"given",
"language",
"with",
"specified",
"ID",
".",
"<http",
":",
"//",
"www",
".",
"elastic",
".",
"co",
"/",
"guide",
"/",
"en",
"/",
"elasticsearch",
"/",
"reference",
"/",
"current",
"/",
"modules",
"-",
"scripting",
... | 2aab285c8f506f3863cbdaba3c90a685c510ba00 | https://github.com/elastic/elasticsearch-py/blob/2aab285c8f506f3863cbdaba3c90a685c510ba00/elasticsearch/client/__init__.py#L1618-L1631 | train |
elastic/elasticsearch-py | elasticsearch/client/__init__.py | Elasticsearch.render_search_template | def render_search_template(self, id=None, body=None, params=None):
"""
`<http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/search-template.html>`_
:arg id: The id of the stored search template
:arg body: The search definition template and its params
"""
... | python | def render_search_template(self, id=None, body=None, params=None):
"""
`<http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/search-template.html>`_
:arg id: The id of the stored search template
:arg body: The search definition template and its params
"""
... | [
"def",
"render_search_template",
"(",
"self",
",",
"id",
"=",
"None",
",",
"body",
"=",
"None",
",",
"params",
"=",
"None",
")",
":",
"return",
"self",
".",
"transport",
".",
"perform_request",
"(",
"\"GET\"",
",",
"_make_path",
"(",
"\"_render\"",
",",
... | `<http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/search-template.html>`_
:arg id: The id of the stored search template
:arg body: The search definition template and its params | [
"<http",
":",
"//",
"www",
".",
"elasticsearch",
".",
"org",
"/",
"guide",
"/",
"en",
"/",
"elasticsearch",
"/",
"reference",
"/",
"current",
"/",
"search",
"-",
"template",
".",
"html",
">",
"_"
] | 2aab285c8f506f3863cbdaba3c90a685c510ba00 | https://github.com/elastic/elasticsearch-py/blob/2aab285c8f506f3863cbdaba3c90a685c510ba00/elasticsearch/client/__init__.py#L1662-L1671 | train |
elastic/elasticsearch-py | elasticsearch/client/__init__.py | Elasticsearch.msearch_template | def msearch_template(self, body, index=None, params=None):
"""
The /_search/template endpoint allows to use the mustache language to
pre render search requests, before they are executed and fill existing
templates with template parameters.
`<http://www.elastic.co/guide/en/elastic... | python | def msearch_template(self, body, index=None, params=None):
"""
The /_search/template endpoint allows to use the mustache language to
pre render search requests, before they are executed and fill existing
templates with template parameters.
`<http://www.elastic.co/guide/en/elastic... | [
"def",
"msearch_template",
"(",
"self",
",",
"body",
",",
"index",
"=",
"None",
",",
"params",
"=",
"None",
")",
":",
"if",
"body",
"in",
"SKIP_IN_PATH",
":",
"raise",
"ValueError",
"(",
"\"Empty value passed for a required argument 'body'.\"",
")",
"return",
"s... | The /_search/template endpoint allows to use the mustache language to
pre render search requests, before they are executed and fill existing
templates with template parameters.
`<http://www.elastic.co/guide/en/elasticsearch/reference/current/search-template.html>`_
:arg body: The reques... | [
"The",
"/",
"_search",
"/",
"template",
"endpoint",
"allows",
"to",
"use",
"the",
"mustache",
"language",
"to",
"pre",
"render",
"search",
"requests",
"before",
"they",
"are",
"executed",
"and",
"fill",
"existing",
"templates",
"with",
"template",
"parameters",
... | 2aab285c8f506f3863cbdaba3c90a685c510ba00 | https://github.com/elastic/elasticsearch-py/blob/2aab285c8f506f3863cbdaba3c90a685c510ba00/elasticsearch/client/__init__.py#L1674-L1701 | train |
elastic/elasticsearch-py | elasticsearch/client/__init__.py | Elasticsearch.field_caps | def field_caps(self, index=None, body=None, params=None):
"""
The field capabilities API allows to retrieve the capabilities of fields among multiple indices.
`<http://www.elastic.co/guide/en/elasticsearch/reference/current/search-field-caps.html>`_
:arg index: A list of index names, or... | python | def field_caps(self, index=None, body=None, params=None):
"""
The field capabilities API allows to retrieve the capabilities of fields among multiple indices.
`<http://www.elastic.co/guide/en/elasticsearch/reference/current/search-field-caps.html>`_
:arg index: A list of index names, or... | [
"def",
"field_caps",
"(",
"self",
",",
"index",
"=",
"None",
",",
"body",
"=",
"None",
",",
"params",
"=",
"None",
")",
":",
"return",
"self",
".",
"transport",
".",
"perform_request",
"(",
"\"GET\"",
",",
"_make_path",
"(",
"index",
",",
"\"_field_caps\... | The field capabilities API allows to retrieve the capabilities of fields among multiple indices.
`<http://www.elastic.co/guide/en/elasticsearch/reference/current/search-field-caps.html>`_
:arg index: A list of index names, or a string containing a
comma-separated list of index names; use `_... | [
"The",
"field",
"capabilities",
"API",
"allows",
"to",
"retrieve",
"the",
"capabilities",
"of",
"fields",
"among",
"multiple",
"indices",
".",
"<http",
":",
"//",
"www",
".",
"elastic",
".",
"co",
"/",
"guide",
"/",
"en",
"/",
"elasticsearch",
"/",
"refere... | 2aab285c8f506f3863cbdaba3c90a685c510ba00 | https://github.com/elastic/elasticsearch-py/blob/2aab285c8f506f3863cbdaba3c90a685c510ba00/elasticsearch/client/__init__.py#L1706-L1727 | train |
elastic/elasticsearch-py | elasticsearch/client/xpack/monitoring.py | MonitoringClient.bulk | def bulk(self, body, doc_type=None, params=None):
"""
`<http://www.elastic.co/guide/en/monitoring/current/appendix-api-bulk.html>`_
:arg body: The operation definition and data (action-data pairs),
separated by newlines
:arg doc_type: Default document type for items which do... | python | def bulk(self, body, doc_type=None, params=None):
"""
`<http://www.elastic.co/guide/en/monitoring/current/appendix-api-bulk.html>`_
:arg body: The operation definition and data (action-data pairs),
separated by newlines
:arg doc_type: Default document type for items which do... | [
"def",
"bulk",
"(",
"self",
",",
"body",
",",
"doc_type",
"=",
"None",
",",
"params",
"=",
"None",
")",
":",
"if",
"body",
"in",
"SKIP_IN_PATH",
":",
"raise",
"ValueError",
"(",
"\"Empty value passed for a required argument 'body'.\"",
")",
"return",
"self",
"... | `<http://www.elastic.co/guide/en/monitoring/current/appendix-api-bulk.html>`_
:arg body: The operation definition and data (action-data pairs),
separated by newlines
:arg doc_type: Default document type for items which don't provide one
:arg interval: Collection interval (e.g., '10s... | [
"<http",
":",
"//",
"www",
".",
"elastic",
".",
"co",
"/",
"guide",
"/",
"en",
"/",
"monitoring",
"/",
"current",
"/",
"appendix",
"-",
"api",
"-",
"bulk",
".",
"html",
">",
"_"
] | 2aab285c8f506f3863cbdaba3c90a685c510ba00 | https://github.com/elastic/elasticsearch-py/blob/2aab285c8f506f3863cbdaba3c90a685c510ba00/elasticsearch/client/xpack/monitoring.py#L6-L25 | train |
elastic/elasticsearch-py | elasticsearch/transport.py | Transport.add_connection | def add_connection(self, host):
"""
Create a new :class:`~elasticsearch.Connection` instance and add it to the pool.
:arg host: kwargs that will be used to create the instance
"""
self.hosts.append(host)
self.set_connections(self.hosts) | python | def add_connection(self, host):
"""
Create a new :class:`~elasticsearch.Connection` instance and add it to the pool.
:arg host: kwargs that will be used to create the instance
"""
self.hosts.append(host)
self.set_connections(self.hosts) | [
"def",
"add_connection",
"(",
"self",
",",
"host",
")",
":",
"self",
".",
"hosts",
".",
"append",
"(",
"host",
")",
"self",
".",
"set_connections",
"(",
"self",
".",
"hosts",
")"
] | Create a new :class:`~elasticsearch.Connection` instance and add it to the pool.
:arg host: kwargs that will be used to create the instance | [
"Create",
"a",
"new",
":",
"class",
":",
"~elasticsearch",
".",
"Connection",
"instance",
"and",
"add",
"it",
"to",
"the",
"pool",
"."
] | 2aab285c8f506f3863cbdaba3c90a685c510ba00 | https://github.com/elastic/elasticsearch-py/blob/2aab285c8f506f3863cbdaba3c90a685c510ba00/elasticsearch/transport.py#L124-L131 | train |
elastic/elasticsearch-py | elasticsearch/transport.py | Transport.get_connection | def get_connection(self):
"""
Retreive a :class:`~elasticsearch.Connection` instance from the
:class:`~elasticsearch.ConnectionPool` instance.
"""
if self.sniffer_timeout:
if time.time() >= self.last_sniff + self.sniffer_timeout:
self.sniff_hosts()
... | python | def get_connection(self):
"""
Retreive a :class:`~elasticsearch.Connection` instance from the
:class:`~elasticsearch.ConnectionPool` instance.
"""
if self.sniffer_timeout:
if time.time() >= self.last_sniff + self.sniffer_timeout:
self.sniff_hosts()
... | [
"def",
"get_connection",
"(",
"self",
")",
":",
"if",
"self",
".",
"sniffer_timeout",
":",
"if",
"time",
".",
"time",
"(",
")",
">=",
"self",
".",
"last_sniff",
"+",
"self",
".",
"sniffer_timeout",
":",
"self",
".",
"sniff_hosts",
"(",
")",
"return",
"... | Retreive a :class:`~elasticsearch.Connection` instance from the
:class:`~elasticsearch.ConnectionPool` instance. | [
"Retreive",
"a",
":",
"class",
":",
"~elasticsearch",
".",
"Connection",
"instance",
"from",
"the",
":",
"class",
":",
"~elasticsearch",
".",
"ConnectionPool",
"instance",
"."
] | 2aab285c8f506f3863cbdaba3c90a685c510ba00 | https://github.com/elastic/elasticsearch-py/blob/2aab285c8f506f3863cbdaba3c90a685c510ba00/elasticsearch/transport.py#L164-L172 | train |
elastic/elasticsearch-py | elasticsearch/transport.py | Transport.sniff_hosts | def sniff_hosts(self, initial=False):
"""
Obtain a list of nodes from the cluster and create a new connection
pool using the information retrieved.
To extract the node connection parameters use the ``nodes_to_host_callback``.
:arg initial: flag indicating if this is during star... | python | def sniff_hosts(self, initial=False):
"""
Obtain a list of nodes from the cluster and create a new connection
pool using the information retrieved.
To extract the node connection parameters use the ``nodes_to_host_callback``.
:arg initial: flag indicating if this is during star... | [
"def",
"sniff_hosts",
"(",
"self",
",",
"initial",
"=",
"False",
")",
":",
"node_info",
"=",
"self",
".",
"_get_sniff_data",
"(",
"initial",
")",
"hosts",
"=",
"list",
"(",
"filter",
"(",
"None",
",",
"(",
"self",
".",
"_get_host_info",
"(",
"n",
")",
... | Obtain a list of nodes from the cluster and create a new connection
pool using the information retrieved.
To extract the node connection parameters use the ``nodes_to_host_callback``.
:arg initial: flag indicating if this is during startup
(``sniff_on_start``), ignore the ``sniff_t... | [
"Obtain",
"a",
"list",
"of",
"nodes",
"from",
"the",
"cluster",
"and",
"create",
"a",
"new",
"connection",
"pool",
"using",
"the",
"information",
"retrieved",
"."
] | 2aab285c8f506f3863cbdaba3c90a685c510ba00 | https://github.com/elastic/elasticsearch-py/blob/2aab285c8f506f3863cbdaba3c90a685c510ba00/elasticsearch/transport.py#L225-L244 | train |
elastic/elasticsearch-py | elasticsearch/transport.py | Transport.mark_dead | def mark_dead(self, connection):
"""
Mark a connection as dead (failed) in the connection pool. If sniffing
on failure is enabled this will initiate the sniffing process.
:arg connection: instance of :class:`~elasticsearch.Connection` that failed
"""
# mark as dead even ... | python | def mark_dead(self, connection):
"""
Mark a connection as dead (failed) in the connection pool. If sniffing
on failure is enabled this will initiate the sniffing process.
:arg connection: instance of :class:`~elasticsearch.Connection` that failed
"""
# mark as dead even ... | [
"def",
"mark_dead",
"(",
"self",
",",
"connection",
")",
":",
"# mark as dead even when sniffing to avoid hitting this host during the sniff process",
"self",
".",
"connection_pool",
".",
"mark_dead",
"(",
"connection",
")",
"if",
"self",
".",
"sniff_on_connection_fail",
":... | Mark a connection as dead (failed) in the connection pool. If sniffing
on failure is enabled this will initiate the sniffing process.
:arg connection: instance of :class:`~elasticsearch.Connection` that failed | [
"Mark",
"a",
"connection",
"as",
"dead",
"(",
"failed",
")",
"in",
"the",
"connection",
"pool",
".",
"If",
"sniffing",
"on",
"failure",
"is",
"enabled",
"this",
"will",
"initiate",
"the",
"sniffing",
"process",
"."
] | 2aab285c8f506f3863cbdaba3c90a685c510ba00 | https://github.com/elastic/elasticsearch-py/blob/2aab285c8f506f3863cbdaba3c90a685c510ba00/elasticsearch/transport.py#L246-L256 | train |
elastic/elasticsearch-py | elasticsearch/transport.py | Transport.perform_request | def perform_request(self, method, url, headers=None, params=None, body=None):
"""
Perform the actual request. Retrieve a connection from the connection
pool, pass all the information to it's perform_request method and
return the data.
If an exception was raised, mark the connect... | python | def perform_request(self, method, url, headers=None, params=None, body=None):
"""
Perform the actual request. Retrieve a connection from the connection
pool, pass all the information to it's perform_request method and
return the data.
If an exception was raised, mark the connect... | [
"def",
"perform_request",
"(",
"self",
",",
"method",
",",
"url",
",",
"headers",
"=",
"None",
",",
"params",
"=",
"None",
",",
"body",
"=",
"None",
")",
":",
"if",
"body",
"is",
"not",
"None",
":",
"body",
"=",
"self",
".",
"serializer",
".",
"dum... | Perform the actual request. Retrieve a connection from the connection
pool, pass all the information to it's perform_request method and
return the data.
If an exception was raised, mark the connection as failed and retry (up
to `max_retries` times).
If the operation was succesf... | [
"Perform",
"the",
"actual",
"request",
".",
"Retrieve",
"a",
"connection",
"from",
"the",
"connection",
"pool",
"pass",
"all",
"the",
"information",
"to",
"it",
"s",
"perform_request",
"method",
"and",
"return",
"the",
"data",
"."
] | 2aab285c8f506f3863cbdaba3c90a685c510ba00 | https://github.com/elastic/elasticsearch-py/blob/2aab285c8f506f3863cbdaba3c90a685c510ba00/elasticsearch/transport.py#L258-L350 | train |
elastic/elasticsearch-py | elasticsearch/client/xpack/security.py | SecurityClient.change_password | def change_password(self, body, username=None, params=None):
"""
`<https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-change-password.html>`_
:arg body: the new password for the user
:arg username: The username of the user to change the password for
:ar... | python | def change_password(self, body, username=None, params=None):
"""
`<https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-change-password.html>`_
:arg body: the new password for the user
:arg username: The username of the user to change the password for
:ar... | [
"def",
"change_password",
"(",
"self",
",",
"body",
",",
"username",
"=",
"None",
",",
"params",
"=",
"None",
")",
":",
"if",
"body",
"in",
"SKIP_IN_PATH",
":",
"raise",
"ValueError",
"(",
"\"Empty value passed for a required argument 'body'.\"",
")",
"return",
... | `<https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-change-password.html>`_
:arg body: the new password for the user
:arg username: The username of the user to change the password for
:arg refresh: If `true` (the default) then refresh the affected shards
t... | [
"<https",
":",
"//",
"www",
".",
"elastic",
".",
"co",
"/",
"guide",
"/",
"en",
"/",
"elasticsearch",
"/",
"reference",
"/",
"current",
"/",
"security",
"-",
"api",
"-",
"change",
"-",
"password",
".",
"html",
">",
"_"
] | 2aab285c8f506f3863cbdaba3c90a685c510ba00 | https://github.com/elastic/elasticsearch-py/blob/2aab285c8f506f3863cbdaba3c90a685c510ba00/elasticsearch/client/xpack/security.py#L15-L34 | train |
elastic/elasticsearch-py | elasticsearch/client/xpack/security.py | SecurityClient.clear_cached_realms | def clear_cached_realms(self, realms, params=None):
"""
`<https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-clear-cache.html>`_
:arg realms: Comma-separated list of realms to clear
:arg usernames: Comma-separated list of usernames to clear from the
... | python | def clear_cached_realms(self, realms, params=None):
"""
`<https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-clear-cache.html>`_
:arg realms: Comma-separated list of realms to clear
:arg usernames: Comma-separated list of usernames to clear from the
... | [
"def",
"clear_cached_realms",
"(",
"self",
",",
"realms",
",",
"params",
"=",
"None",
")",
":",
"if",
"realms",
"in",
"SKIP_IN_PATH",
":",
"raise",
"ValueError",
"(",
"\"Empty value passed for a required argument 'realms'.\"",
")",
"return",
"self",
".",
"transport"... | `<https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-clear-cache.html>`_
:arg realms: Comma-separated list of realms to clear
:arg usernames: Comma-separated list of usernames to clear from the
cache | [
"<https",
":",
"//",
"www",
".",
"elastic",
".",
"co",
"/",
"guide",
"/",
"en",
"/",
"elasticsearch",
"/",
"reference",
"/",
"current",
"/",
"security",
"-",
"api",
"-",
"clear",
"-",
"cache",
".",
"html",
">",
"_"
] | 2aab285c8f506f3863cbdaba3c90a685c510ba00 | https://github.com/elastic/elasticsearch-py/blob/2aab285c8f506f3863cbdaba3c90a685c510ba00/elasticsearch/client/xpack/security.py#L37-L51 | train |
elastic/elasticsearch-py | elasticsearch/client/xpack/security.py | SecurityClient.clear_cached_roles | def clear_cached_roles(self, name, params=None):
"""
`<https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-clear-role-cache.html>`_
:arg name: Role name
"""
if name in SKIP_IN_PATH:
raise ValueError("Empty value passed for a required argument... | python | def clear_cached_roles(self, name, params=None):
"""
`<https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-clear-role-cache.html>`_
:arg name: Role name
"""
if name in SKIP_IN_PATH:
raise ValueError("Empty value passed for a required argument... | [
"def",
"clear_cached_roles",
"(",
"self",
",",
"name",
",",
"params",
"=",
"None",
")",
":",
"if",
"name",
"in",
"SKIP_IN_PATH",
":",
"raise",
"ValueError",
"(",
"\"Empty value passed for a required argument 'name'.\"",
")",
"return",
"self",
".",
"transport",
"."... | `<https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-clear-role-cache.html>`_
:arg name: Role name | [
"<https",
":",
"//",
"www",
".",
"elastic",
".",
"co",
"/",
"guide",
"/",
"en",
"/",
"elasticsearch",
"/",
"reference",
"/",
"current",
"/",
"security",
"-",
"api",
"-",
"clear",
"-",
"role",
"-",
"cache",
".",
"html",
">",
"_"
] | 2aab285c8f506f3863cbdaba3c90a685c510ba00 | https://github.com/elastic/elasticsearch-py/blob/2aab285c8f506f3863cbdaba3c90a685c510ba00/elasticsearch/client/xpack/security.py#L54-L64 | train |
elastic/elasticsearch-py | elasticsearch/client/xpack/security.py | SecurityClient.create_api_key | def create_api_key(self, body, params=None):
"""
`<https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-create-api-key.html>`_
:arg body: The api key request to create an API key
:arg refresh: If `true` (the default) then refresh the affected shards
t... | python | def create_api_key(self, body, params=None):
"""
`<https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-create-api-key.html>`_
:arg body: The api key request to create an API key
:arg refresh: If `true` (the default) then refresh the affected shards
t... | [
"def",
"create_api_key",
"(",
"self",
",",
"body",
",",
"params",
"=",
"None",
")",
":",
"if",
"body",
"in",
"SKIP_IN_PATH",
":",
"raise",
"ValueError",
"(",
"\"Empty value passed for a required argument 'body'.\"",
")",
"return",
"self",
".",
"transport",
".",
... | `<https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-create-api-key.html>`_
:arg body: The api key request to create an API key
:arg refresh: If `true` (the default) then refresh the affected shards
to make this operation visible to search, if `wait_for` then wait
... | [
"<https",
":",
"//",
"www",
".",
"elastic",
".",
"co",
"/",
"guide",
"/",
"en",
"/",
"elasticsearch",
"/",
"reference",
"/",
"current",
"/",
"security",
"-",
"api",
"-",
"create",
"-",
"api",
"-",
"key",
".",
"html",
">",
"_"
] | 2aab285c8f506f3863cbdaba3c90a685c510ba00 | https://github.com/elastic/elasticsearch-py/blob/2aab285c8f506f3863cbdaba3c90a685c510ba00/elasticsearch/client/xpack/security.py#L67-L82 | train |
elastic/elasticsearch-py | elasticsearch/client/xpack/security.py | SecurityClient.delete_privileges | def delete_privileges(self, application, name, params=None):
"""
`<TODO>`_
:arg application: Application name
:arg name: Privilege name
:arg refresh: If `true` (the default) then refresh the affected shards
to make this operation visible to search, if `wait_for` then... | python | def delete_privileges(self, application, name, params=None):
"""
`<TODO>`_
:arg application: Application name
:arg name: Privilege name
:arg refresh: If `true` (the default) then refresh the affected shards
to make this operation visible to search, if `wait_for` then... | [
"def",
"delete_privileges",
"(",
"self",
",",
"application",
",",
"name",
",",
"params",
"=",
"None",
")",
":",
"for",
"param",
"in",
"(",
"application",
",",
"name",
")",
":",
"if",
"param",
"in",
"SKIP_IN_PATH",
":",
"raise",
"ValueError",
"(",
"\"Empt... | `<TODO>`_
:arg application: Application name
:arg name: Privilege name
:arg refresh: If `true` (the default) then refresh the affected shards
to make this operation visible to search, if `wait_for` then wait
for a refresh to make this operation visible to search, if `fal... | [
"<TODO",
">",
"_"
] | 2aab285c8f506f3863cbdaba3c90a685c510ba00 | https://github.com/elastic/elasticsearch-py/blob/2aab285c8f506f3863cbdaba3c90a685c510ba00/elasticsearch/client/xpack/security.py#L85-L104 | train |
elastic/elasticsearch-py | elasticsearch/client/xpack/security.py | SecurityClient.delete_user | def delete_user(self, username, params=None):
"""
`<https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-delete-user.html>`_
:arg username: username
:arg refresh: If `true` (the default) then refresh the affected shards
to make this operation visible ... | python | def delete_user(self, username, params=None):
"""
`<https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-delete-user.html>`_
:arg username: username
:arg refresh: If `true` (the default) then refresh the affected shards
to make this operation visible ... | [
"def",
"delete_user",
"(",
"self",
",",
"username",
",",
"params",
"=",
"None",
")",
":",
"if",
"username",
"in",
"SKIP_IN_PATH",
":",
"raise",
"ValueError",
"(",
"\"Empty value passed for a required argument 'username'.\"",
")",
"return",
"self",
".",
"transport",
... | `<https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-delete-user.html>`_
:arg username: username
:arg refresh: If `true` (the default) then refresh the affected shards
to make this operation visible to search, if `wait_for` then wait
for a refresh to ma... | [
"<https",
":",
"//",
"www",
".",
"elastic",
".",
"co",
"/",
"guide",
"/",
"en",
"/",
"elasticsearch",
"/",
"reference",
"/",
"current",
"/",
"security",
"-",
"api",
"-",
"delete",
"-",
"user",
".",
"html",
">",
"_"
] | 2aab285c8f506f3863cbdaba3c90a685c510ba00 | https://github.com/elastic/elasticsearch-py/blob/2aab285c8f506f3863cbdaba3c90a685c510ba00/elasticsearch/client/xpack/security.py#L143-L158 | train |
elastic/elasticsearch-py | elasticsearch/client/xpack/security.py | SecurityClient.get_privileges | def get_privileges(self, application=None, name=None, params=None):
"""
`<TODO>`_
:arg application: Application name
:arg name: Privilege name
"""
return self.transport.perform_request(
"GET",
_make_path("_security", "privilege", application, name... | python | def get_privileges(self, application=None, name=None, params=None):
"""
`<TODO>`_
:arg application: Application name
:arg name: Privilege name
"""
return self.transport.perform_request(
"GET",
_make_path("_security", "privilege", application, name... | [
"def",
"get_privileges",
"(",
"self",
",",
"application",
"=",
"None",
",",
"name",
"=",
"None",
",",
"params",
"=",
"None",
")",
":",
"return",
"self",
".",
"transport",
".",
"perform_request",
"(",
"\"GET\"",
",",
"_make_path",
"(",
"\"_security\"",
",",... | `<TODO>`_
:arg application: Application name
:arg name: Privilege name | [
"<TODO",
">",
"_"
] | 2aab285c8f506f3863cbdaba3c90a685c510ba00 | https://github.com/elastic/elasticsearch-py/blob/2aab285c8f506f3863cbdaba3c90a685c510ba00/elasticsearch/client/xpack/security.py#L213-L224 | train |
elastic/elasticsearch-py | elasticsearch/client/xpack/security.py | SecurityClient.get_role | def get_role(self, name=None, params=None):
"""
`<https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-get-role.html>`_
:arg name: Role name
"""
return self.transport.perform_request(
"GET", _make_path("_security", "role", name), params=params... | python | def get_role(self, name=None, params=None):
"""
`<https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-get-role.html>`_
:arg name: Role name
"""
return self.transport.perform_request(
"GET", _make_path("_security", "role", name), params=params... | [
"def",
"get_role",
"(",
"self",
",",
"name",
"=",
"None",
",",
"params",
"=",
"None",
")",
":",
"return",
"self",
".",
"transport",
".",
"perform_request",
"(",
"\"GET\"",
",",
"_make_path",
"(",
"\"_security\"",
",",
"\"role\"",
",",
"name",
")",
",",
... | `<https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-get-role.html>`_
:arg name: Role name | [
"<https",
":",
"//",
"www",
".",
"elastic",
".",
"co",
"/",
"guide",
"/",
"en",
"/",
"elasticsearch",
"/",
"reference",
"/",
"current",
"/",
"security",
"-",
"api",
"-",
"get",
"-",
"role",
".",
"html",
">",
"_"
] | 2aab285c8f506f3863cbdaba3c90a685c510ba00 | https://github.com/elastic/elasticsearch-py/blob/2aab285c8f506f3863cbdaba3c90a685c510ba00/elasticsearch/client/xpack/security.py#L227-L235 | train |
elastic/elasticsearch-py | elasticsearch/client/xpack/security.py | SecurityClient.get_role_mapping | def get_role_mapping(self, name=None, params=None):
"""
`<https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-get-role-mapping.html>`_
:arg name: Role-Mapping name
"""
return self.transport.perform_request(
"GET", _make_path("_security", "rol... | python | def get_role_mapping(self, name=None, params=None):
"""
`<https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-get-role-mapping.html>`_
:arg name: Role-Mapping name
"""
return self.transport.perform_request(
"GET", _make_path("_security", "rol... | [
"def",
"get_role_mapping",
"(",
"self",
",",
"name",
"=",
"None",
",",
"params",
"=",
"None",
")",
":",
"return",
"self",
".",
"transport",
".",
"perform_request",
"(",
"\"GET\"",
",",
"_make_path",
"(",
"\"_security\"",
",",
"\"role_mapping\"",
",",
"name",... | `<https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-get-role-mapping.html>`_
:arg name: Role-Mapping name | [
"<https",
":",
"//",
"www",
".",
"elastic",
".",
"co",
"/",
"guide",
"/",
"en",
"/",
"elasticsearch",
"/",
"reference",
"/",
"current",
"/",
"security",
"-",
"api",
"-",
"get",
"-",
"role",
"-",
"mapping",
".",
"html",
">",
"_"
] | 2aab285c8f506f3863cbdaba3c90a685c510ba00 | https://github.com/elastic/elasticsearch-py/blob/2aab285c8f506f3863cbdaba3c90a685c510ba00/elasticsearch/client/xpack/security.py#L238-L246 | train |
elastic/elasticsearch-py | elasticsearch/client/xpack/security.py | SecurityClient.get_token | def get_token(self, body, params=None):
"""
`<https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-get-token.html>`_
:arg body: The token request to get
"""
if body in SKIP_IN_PATH:
raise ValueError("Empty value passed for a required argument ... | python | def get_token(self, body, params=None):
"""
`<https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-get-token.html>`_
:arg body: The token request to get
"""
if body in SKIP_IN_PATH:
raise ValueError("Empty value passed for a required argument ... | [
"def",
"get_token",
"(",
"self",
",",
"body",
",",
"params",
"=",
"None",
")",
":",
"if",
"body",
"in",
"SKIP_IN_PATH",
":",
"raise",
"ValueError",
"(",
"\"Empty value passed for a required argument 'body'.\"",
")",
"return",
"self",
".",
"transport",
".",
"perf... | `<https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-get-token.html>`_
:arg body: The token request to get | [
"<https",
":",
"//",
"www",
".",
"elastic",
".",
"co",
"/",
"guide",
"/",
"en",
"/",
"elasticsearch",
"/",
"reference",
"/",
"current",
"/",
"security",
"-",
"api",
"-",
"get",
"-",
"token",
".",
"html",
">",
"_"
] | 2aab285c8f506f3863cbdaba3c90a685c510ba00 | https://github.com/elastic/elasticsearch-py/blob/2aab285c8f506f3863cbdaba3c90a685c510ba00/elasticsearch/client/xpack/security.py#L249-L259 | train |
elastic/elasticsearch-py | elasticsearch/client/xpack/security.py | SecurityClient.get_user | def get_user(self, username=None, params=None):
"""
`<https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-get-user.html>`_
:arg username: A comma-separated list of usernames
"""
return self.transport.perform_request(
"GET", _make_path("_secur... | python | def get_user(self, username=None, params=None):
"""
`<https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-get-user.html>`_
:arg username: A comma-separated list of usernames
"""
return self.transport.perform_request(
"GET", _make_path("_secur... | [
"def",
"get_user",
"(",
"self",
",",
"username",
"=",
"None",
",",
"params",
"=",
"None",
")",
":",
"return",
"self",
".",
"transport",
".",
"perform_request",
"(",
"\"GET\"",
",",
"_make_path",
"(",
"\"_security\"",
",",
"\"user\"",
",",
"username",
")",
... | `<https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-get-user.html>`_
:arg username: A comma-separated list of usernames | [
"<https",
":",
"//",
"www",
".",
"elastic",
".",
"co",
"/",
"guide",
"/",
"en",
"/",
"elasticsearch",
"/",
"reference",
"/",
"current",
"/",
"security",
"-",
"api",
"-",
"get",
"-",
"user",
".",
"html",
">",
"_"
] | 2aab285c8f506f3863cbdaba3c90a685c510ba00 | https://github.com/elastic/elasticsearch-py/blob/2aab285c8f506f3863cbdaba3c90a685c510ba00/elasticsearch/client/xpack/security.py#L262-L270 | train |
elastic/elasticsearch-py | elasticsearch/client/xpack/security.py | SecurityClient.has_privileges | def has_privileges(self, body, user=None, params=None):
"""
`<https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-has-privileges.html>`_
:arg body: The privileges to test
:arg user: Username
"""
if body in SKIP_IN_PATH:
raise ValueErr... | python | def has_privileges(self, body, user=None, params=None):
"""
`<https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-has-privileges.html>`_
:arg body: The privileges to test
:arg user: Username
"""
if body in SKIP_IN_PATH:
raise ValueErr... | [
"def",
"has_privileges",
"(",
"self",
",",
"body",
",",
"user",
"=",
"None",
",",
"params",
"=",
"None",
")",
":",
"if",
"body",
"in",
"SKIP_IN_PATH",
":",
"raise",
"ValueError",
"(",
"\"Empty value passed for a required argument 'body'.\"",
")",
"return",
"self... | `<https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-has-privileges.html>`_
:arg body: The privileges to test
:arg user: Username | [
"<https",
":",
"//",
"www",
".",
"elastic",
".",
"co",
"/",
"guide",
"/",
"en",
"/",
"elasticsearch",
"/",
"reference",
"/",
"current",
"/",
"security",
"-",
"api",
"-",
"has",
"-",
"privileges",
".",
"html",
">",
"_"
] | 2aab285c8f506f3863cbdaba3c90a685c510ba00 | https://github.com/elastic/elasticsearch-py/blob/2aab285c8f506f3863cbdaba3c90a685c510ba00/elasticsearch/client/xpack/security.py#L282-L296 | train |
elastic/elasticsearch-py | elasticsearch/client/xpack/security.py | SecurityClient.invalidate_api_key | def invalidate_api_key(self, body, params=None):
"""
`<https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-invalidate-api-key.html>`_
:arg body: The api key request to invalidate API key(s)
"""
if body in SKIP_IN_PATH:
raise ValueError("Empty... | python | def invalidate_api_key(self, body, params=None):
"""
`<https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-invalidate-api-key.html>`_
:arg body: The api key request to invalidate API key(s)
"""
if body in SKIP_IN_PATH:
raise ValueError("Empty... | [
"def",
"invalidate_api_key",
"(",
"self",
",",
"body",
",",
"params",
"=",
"None",
")",
":",
"if",
"body",
"in",
"SKIP_IN_PATH",
":",
"raise",
"ValueError",
"(",
"\"Empty value passed for a required argument 'body'.\"",
")",
"return",
"self",
".",
"transport",
"."... | `<https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-invalidate-api-key.html>`_
:arg body: The api key request to invalidate API key(s) | [
"<https",
":",
"//",
"www",
".",
"elastic",
".",
"co",
"/",
"guide",
"/",
"en",
"/",
"elasticsearch",
"/",
"reference",
"/",
"current",
"/",
"security",
"-",
"api",
"-",
"invalidate",
"-",
"api",
"-",
"key",
".",
"html",
">",
"_"
] | 2aab285c8f506f3863cbdaba3c90a685c510ba00 | https://github.com/elastic/elasticsearch-py/blob/2aab285c8f506f3863cbdaba3c90a685c510ba00/elasticsearch/client/xpack/security.py#L299-L309 | train |
elastic/elasticsearch-py | elasticsearch/client/xpack/security.py | SecurityClient.invalidate_token | def invalidate_token(self, body, params=None):
"""
`<https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-invalidate-token.html>`_
:arg body: The token to invalidate
"""
if body in SKIP_IN_PATH:
raise ValueError("Empty value passed for a requi... | python | def invalidate_token(self, body, params=None):
"""
`<https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-invalidate-token.html>`_
:arg body: The token to invalidate
"""
if body in SKIP_IN_PATH:
raise ValueError("Empty value passed for a requi... | [
"def",
"invalidate_token",
"(",
"self",
",",
"body",
",",
"params",
"=",
"None",
")",
":",
"if",
"body",
"in",
"SKIP_IN_PATH",
":",
"raise",
"ValueError",
"(",
"\"Empty value passed for a required argument 'body'.\"",
")",
"return",
"self",
".",
"transport",
".",
... | `<https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-invalidate-token.html>`_
:arg body: The token to invalidate | [
"<https",
":",
"//",
"www",
".",
"elastic",
".",
"co",
"/",
"guide",
"/",
"en",
"/",
"elasticsearch",
"/",
"reference",
"/",
"current",
"/",
"security",
"-",
"api",
"-",
"invalidate",
"-",
"token",
".",
"html",
">",
"_"
] | 2aab285c8f506f3863cbdaba3c90a685c510ba00 | https://github.com/elastic/elasticsearch-py/blob/2aab285c8f506f3863cbdaba3c90a685c510ba00/elasticsearch/client/xpack/security.py#L312-L322 | train |
elastic/elasticsearch-py | elasticsearch/client/xpack/security.py | SecurityClient.put_privileges | def put_privileges(self, body, params=None):
"""
`<TODO>`_
:arg body: The privilege(s) to add
:arg refresh: If `true` (the default) then refresh the affected shards
to make this operation visible to search, if `wait_for` then wait
for a refresh to make this opera... | python | def put_privileges(self, body, params=None):
"""
`<TODO>`_
:arg body: The privilege(s) to add
:arg refresh: If `true` (the default) then refresh the affected shards
to make this operation visible to search, if `wait_for` then wait
for a refresh to make this opera... | [
"def",
"put_privileges",
"(",
"self",
",",
"body",
",",
"params",
"=",
"None",
")",
":",
"if",
"body",
"in",
"SKIP_IN_PATH",
":",
"raise",
"ValueError",
"(",
"\"Empty value passed for a required argument 'body'.\"",
")",
"return",
"self",
".",
"transport",
".",
... | `<TODO>`_
:arg body: The privilege(s) to add
:arg refresh: If `true` (the default) then refresh the affected shards
to make this operation visible to search, if `wait_for` then wait
for a refresh to make this operation visible to search, if `false`
then do nothing wi... | [
"<TODO",
">",
"_"
] | 2aab285c8f506f3863cbdaba3c90a685c510ba00 | https://github.com/elastic/elasticsearch-py/blob/2aab285c8f506f3863cbdaba3c90a685c510ba00/elasticsearch/client/xpack/security.py#L325-L340 | train |
elastic/elasticsearch-py | elasticsearch/client/xpack/security.py | SecurityClient.put_user | def put_user(self, username, body, params=None):
"""
`<https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-put-user.html>`_
:arg username: The username of the User
:arg body: The user to add
:arg refresh: If `true` (the default) then refresh the affected... | python | def put_user(self, username, body, params=None):
"""
`<https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-put-user.html>`_
:arg username: The username of the User
:arg body: The user to add
:arg refresh: If `true` (the default) then refresh the affected... | [
"def",
"put_user",
"(",
"self",
",",
"username",
",",
"body",
",",
"params",
"=",
"None",
")",
":",
"for",
"param",
"in",
"(",
"username",
",",
"body",
")",
":",
"if",
"param",
"in",
"SKIP_IN_PATH",
":",
"raise",
"ValueError",
"(",
"\"Empty value passed ... | `<https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-put-user.html>`_
:arg username: The username of the User
:arg body: The user to add
:arg refresh: If `true` (the default) then refresh the affected shards
to make this operation visible to search, if `wai... | [
"<https",
":",
"//",
"www",
".",
"elastic",
".",
"co",
"/",
"guide",
"/",
"en",
"/",
"elasticsearch",
"/",
"reference",
"/",
"current",
"/",
"security",
"-",
"api",
"-",
"put",
"-",
"user",
".",
"html",
">",
"_"
] | 2aab285c8f506f3863cbdaba3c90a685c510ba00 | https://github.com/elastic/elasticsearch-py/blob/2aab285c8f506f3863cbdaba3c90a685c510ba00/elasticsearch/client/xpack/security.py#L386-L403 | train |
elastic/elasticsearch-py | elasticsearch/client/xpack/ilm.py | IlmClient.delete_lifecycle | def delete_lifecycle(self, policy=None, params=None):
"""
`<https://www.elastic.co/guide/en/elasticsearch/reference/current/ilm-delete-lifecycle.html>`_
:arg policy: The name of the index lifecycle policy
"""
return self.transport.perform_request(
"DELETE", _make_pat... | python | def delete_lifecycle(self, policy=None, params=None):
"""
`<https://www.elastic.co/guide/en/elasticsearch/reference/current/ilm-delete-lifecycle.html>`_
:arg policy: The name of the index lifecycle policy
"""
return self.transport.perform_request(
"DELETE", _make_pat... | [
"def",
"delete_lifecycle",
"(",
"self",
",",
"policy",
"=",
"None",
",",
"params",
"=",
"None",
")",
":",
"return",
"self",
".",
"transport",
".",
"perform_request",
"(",
"\"DELETE\"",
",",
"_make_path",
"(",
"\"_ilm\"",
",",
"\"policy\"",
",",
"policy",
"... | `<https://www.elastic.co/guide/en/elasticsearch/reference/current/ilm-delete-lifecycle.html>`_
:arg policy: The name of the index lifecycle policy | [
"<https",
":",
"//",
"www",
".",
"elastic",
".",
"co",
"/",
"guide",
"/",
"en",
"/",
"elasticsearch",
"/",
"reference",
"/",
"current",
"/",
"ilm",
"-",
"delete",
"-",
"lifecycle",
".",
"html",
">",
"_"
] | 2aab285c8f506f3863cbdaba3c90a685c510ba00 | https://github.com/elastic/elasticsearch-py/blob/2aab285c8f506f3863cbdaba3c90a685c510ba00/elasticsearch/client/xpack/ilm.py#L6-L14 | train |
elastic/elasticsearch-py | elasticsearch/client/xpack/ilm.py | IlmClient.explain_lifecycle | def explain_lifecycle(self, index=None, params=None):
"""
`<https://www.elastic.co/guide/en/elasticsearch/reference/current/ilm-explain-lifecycle.html>`_
:arg index: The name of the index to explain
"""
return self.transport.perform_request(
"GET", _make_path(index, ... | python | def explain_lifecycle(self, index=None, params=None):
"""
`<https://www.elastic.co/guide/en/elasticsearch/reference/current/ilm-explain-lifecycle.html>`_
:arg index: The name of the index to explain
"""
return self.transport.perform_request(
"GET", _make_path(index, ... | [
"def",
"explain_lifecycle",
"(",
"self",
",",
"index",
"=",
"None",
",",
"params",
"=",
"None",
")",
":",
"return",
"self",
".",
"transport",
".",
"perform_request",
"(",
"\"GET\"",
",",
"_make_path",
"(",
"index",
",",
"\"_ilm\"",
",",
"\"explain\"",
")",... | `<https://www.elastic.co/guide/en/elasticsearch/reference/current/ilm-explain-lifecycle.html>`_
:arg index: The name of the index to explain | [
"<https",
":",
"//",
"www",
".",
"elastic",
".",
"co",
"/",
"guide",
"/",
"en",
"/",
"elasticsearch",
"/",
"reference",
"/",
"current",
"/",
"ilm",
"-",
"explain",
"-",
"lifecycle",
".",
"html",
">",
"_"
] | 2aab285c8f506f3863cbdaba3c90a685c510ba00 | https://github.com/elastic/elasticsearch-py/blob/2aab285c8f506f3863cbdaba3c90a685c510ba00/elasticsearch/client/xpack/ilm.py#L17-L25 | train |
elastic/elasticsearch-py | elasticsearch/client/xpack/ilm.py | IlmClient.get_lifecycle | def get_lifecycle(self, policy=None, params=None):
"""
`<https://www.elastic.co/guide/en/elasticsearch/reference/current/ilm-get-lifecycle.html>`_
:arg policy: The name of the index lifecycle policy
"""
return self.transport.perform_request(
"GET", _make_path("_ilm",... | python | def get_lifecycle(self, policy=None, params=None):
"""
`<https://www.elastic.co/guide/en/elasticsearch/reference/current/ilm-get-lifecycle.html>`_
:arg policy: The name of the index lifecycle policy
"""
return self.transport.perform_request(
"GET", _make_path("_ilm",... | [
"def",
"get_lifecycle",
"(",
"self",
",",
"policy",
"=",
"None",
",",
"params",
"=",
"None",
")",
":",
"return",
"self",
".",
"transport",
".",
"perform_request",
"(",
"\"GET\"",
",",
"_make_path",
"(",
"\"_ilm\"",
",",
"\"policy\"",
",",
"policy",
")",
... | `<https://www.elastic.co/guide/en/elasticsearch/reference/current/ilm-get-lifecycle.html>`_
:arg policy: The name of the index lifecycle policy | [
"<https",
":",
"//",
"www",
".",
"elastic",
".",
"co",
"/",
"guide",
"/",
"en",
"/",
"elasticsearch",
"/",
"reference",
"/",
"current",
"/",
"ilm",
"-",
"get",
"-",
"lifecycle",
".",
"html",
">",
"_"
] | 2aab285c8f506f3863cbdaba3c90a685c510ba00 | https://github.com/elastic/elasticsearch-py/blob/2aab285c8f506f3863cbdaba3c90a685c510ba00/elasticsearch/client/xpack/ilm.py#L28-L36 | train |
elastic/elasticsearch-py | elasticsearch/client/xpack/ilm.py | IlmClient.move_to_step | def move_to_step(self, index=None, body=None, params=None):
"""
`<https://www.elastic.co/guide/en/elasticsearch/reference/current/ilm-move-to-step.html>`_
:arg index: The name of the index whose lifecycle step is to change
:arg body: The new lifecycle step to move to
"""
... | python | def move_to_step(self, index=None, body=None, params=None):
"""
`<https://www.elastic.co/guide/en/elasticsearch/reference/current/ilm-move-to-step.html>`_
:arg index: The name of the index whose lifecycle step is to change
:arg body: The new lifecycle step to move to
"""
... | [
"def",
"move_to_step",
"(",
"self",
",",
"index",
"=",
"None",
",",
"body",
"=",
"None",
",",
"params",
"=",
"None",
")",
":",
"return",
"self",
".",
"transport",
".",
"perform_request",
"(",
"\"POST\"",
",",
"_make_path",
"(",
"\"_ilm\"",
",",
"\"move\"... | `<https://www.elastic.co/guide/en/elasticsearch/reference/current/ilm-move-to-step.html>`_
:arg index: The name of the index whose lifecycle step is to change
:arg body: The new lifecycle step to move to | [
"<https",
":",
"//",
"www",
".",
"elastic",
".",
"co",
"/",
"guide",
"/",
"en",
"/",
"elasticsearch",
"/",
"reference",
"/",
"current",
"/",
"ilm",
"-",
"move",
"-",
"to",
"-",
"step",
".",
"html",
">",
"_"
] | 2aab285c8f506f3863cbdaba3c90a685c510ba00 | https://github.com/elastic/elasticsearch-py/blob/2aab285c8f506f3863cbdaba3c90a685c510ba00/elasticsearch/client/xpack/ilm.py#L46-L55 | train |
elastic/elasticsearch-py | elasticsearch/client/xpack/ilm.py | IlmClient.put_lifecycle | def put_lifecycle(self, policy=None, body=None, params=None):
"""
`<https://www.elastic.co/guide/en/elasticsearch/reference/current/ilm-put-lifecycle.html>`_
:arg policy: The name of the index lifecycle policy
:arg body: The lifecycle policy definition to register
"""
re... | python | def put_lifecycle(self, policy=None, body=None, params=None):
"""
`<https://www.elastic.co/guide/en/elasticsearch/reference/current/ilm-put-lifecycle.html>`_
:arg policy: The name of the index lifecycle policy
:arg body: The lifecycle policy definition to register
"""
re... | [
"def",
"put_lifecycle",
"(",
"self",
",",
"policy",
"=",
"None",
",",
"body",
"=",
"None",
",",
"params",
"=",
"None",
")",
":",
"return",
"self",
".",
"transport",
".",
"perform_request",
"(",
"\"PUT\"",
",",
"_make_path",
"(",
"\"_ilm\"",
",",
"\"polic... | `<https://www.elastic.co/guide/en/elasticsearch/reference/current/ilm-put-lifecycle.html>`_
:arg policy: The name of the index lifecycle policy
:arg body: The lifecycle policy definition to register | [
"<https",
":",
"//",
"www",
".",
"elastic",
".",
"co",
"/",
"guide",
"/",
"en",
"/",
"elasticsearch",
"/",
"reference",
"/",
"current",
"/",
"ilm",
"-",
"put",
"-",
"lifecycle",
".",
"html",
">",
"_"
] | 2aab285c8f506f3863cbdaba3c90a685c510ba00 | https://github.com/elastic/elasticsearch-py/blob/2aab285c8f506f3863cbdaba3c90a685c510ba00/elasticsearch/client/xpack/ilm.py#L58-L67 | train |
elastic/elasticsearch-py | elasticsearch/client/xpack/ilm.py | IlmClient.remove_policy | def remove_policy(self, index=None, params=None):
"""
`<https://www.elastic.co/guide/en/elasticsearch/reference/current/ilm-remove-policy.html>`_
:arg index: The name of the index to remove policy on
"""
return self.transport.perform_request(
"POST", _make_path(index... | python | def remove_policy(self, index=None, params=None):
"""
`<https://www.elastic.co/guide/en/elasticsearch/reference/current/ilm-remove-policy.html>`_
:arg index: The name of the index to remove policy on
"""
return self.transport.perform_request(
"POST", _make_path(index... | [
"def",
"remove_policy",
"(",
"self",
",",
"index",
"=",
"None",
",",
"params",
"=",
"None",
")",
":",
"return",
"self",
".",
"transport",
".",
"perform_request",
"(",
"\"POST\"",
",",
"_make_path",
"(",
"index",
",",
"\"_ilm\"",
",",
"\"remove\"",
")",
"... | `<https://www.elastic.co/guide/en/elasticsearch/reference/current/ilm-remove-policy.html>`_
:arg index: The name of the index to remove policy on | [
"<https",
":",
"//",
"www",
".",
"elastic",
".",
"co",
"/",
"guide",
"/",
"en",
"/",
"elasticsearch",
"/",
"reference",
"/",
"current",
"/",
"ilm",
"-",
"remove",
"-",
"policy",
".",
"html",
">",
"_"
] | 2aab285c8f506f3863cbdaba3c90a685c510ba00 | https://github.com/elastic/elasticsearch-py/blob/2aab285c8f506f3863cbdaba3c90a685c510ba00/elasticsearch/client/xpack/ilm.py#L70-L78 | train |
elastic/elasticsearch-py | elasticsearch/client/xpack/ilm.py | IlmClient.retry | def retry(self, index=None, params=None):
"""
`<https://www.elastic.co/guide/en/elasticsearch/reference/current/ilm-retry-policy.html>`_
:arg index: The name of the indices (comma-separated) whose failed
lifecycle step is to be retry
"""
return self.transport.perform... | python | def retry(self, index=None, params=None):
"""
`<https://www.elastic.co/guide/en/elasticsearch/reference/current/ilm-retry-policy.html>`_
:arg index: The name of the indices (comma-separated) whose failed
lifecycle step is to be retry
"""
return self.transport.perform... | [
"def",
"retry",
"(",
"self",
",",
"index",
"=",
"None",
",",
"params",
"=",
"None",
")",
":",
"return",
"self",
".",
"transport",
".",
"perform_request",
"(",
"\"POST\"",
",",
"_make_path",
"(",
"index",
",",
"\"_ilm\"",
",",
"\"retry\"",
")",
",",
"pa... | `<https://www.elastic.co/guide/en/elasticsearch/reference/current/ilm-retry-policy.html>`_
:arg index: The name of the indices (comma-separated) whose failed
lifecycle step is to be retry | [
"<https",
":",
"//",
"www",
".",
"elastic",
".",
"co",
"/",
"guide",
"/",
"en",
"/",
"elasticsearch",
"/",
"reference",
"/",
"current",
"/",
"ilm",
"-",
"retry",
"-",
"policy",
".",
"html",
">",
"_"
] | 2aab285c8f506f3863cbdaba3c90a685c510ba00 | https://github.com/elastic/elasticsearch-py/blob/2aab285c8f506f3863cbdaba3c90a685c510ba00/elasticsearch/client/xpack/ilm.py#L81-L90 | train |
elastic/elasticsearch-py | elasticsearch/client/xpack/license.py | LicenseClient.post | def post(self, body=None, params=None):
"""
`<https://www.elastic.co/guide/en/x-pack/current/license-management.html>`_
:arg body: licenses to be installed
:arg acknowledge: whether the user has acknowledged acknowledge messages
(default: false)
"""
return se... | python | def post(self, body=None, params=None):
"""
`<https://www.elastic.co/guide/en/x-pack/current/license-management.html>`_
:arg body: licenses to be installed
:arg acknowledge: whether the user has acknowledged acknowledge messages
(default: false)
"""
return se... | [
"def",
"post",
"(",
"self",
",",
"body",
"=",
"None",
",",
"params",
"=",
"None",
")",
":",
"return",
"self",
".",
"transport",
".",
"perform_request",
"(",
"\"PUT\"",
",",
"\"/_license\"",
",",
"params",
"=",
"params",
",",
"body",
"=",
"body",
")"
] | `<https://www.elastic.co/guide/en/x-pack/current/license-management.html>`_
:arg body: licenses to be installed
:arg acknowledge: whether the user has acknowledged acknowledge messages
(default: false) | [
"<https",
":",
"//",
"www",
".",
"elastic",
".",
"co",
"/",
"guide",
"/",
"en",
"/",
"x",
"-",
"pack",
"/",
"current",
"/",
"license",
"-",
"management",
".",
"html",
">",
"_"
] | 2aab285c8f506f3863cbdaba3c90a685c510ba00 | https://github.com/elastic/elasticsearch-py/blob/2aab285c8f506f3863cbdaba3c90a685c510ba00/elasticsearch/client/xpack/license.py#L41-L51 | train |
elastic/elasticsearch-py | example/load.py | parse_commits | def parse_commits(head, name):
"""
Go through the git repository log and generate a document per commit
containing all the metadata.
"""
for commit in head.traverse():
yield {
'_id': commit.hexsha,
'repository': name,
'committed_date': datetime.fromtimesta... | python | def parse_commits(head, name):
"""
Go through the git repository log and generate a document per commit
containing all the metadata.
"""
for commit in head.traverse():
yield {
'_id': commit.hexsha,
'repository': name,
'committed_date': datetime.fromtimesta... | [
"def",
"parse_commits",
"(",
"head",
",",
"name",
")",
":",
"for",
"commit",
"in",
"head",
".",
"traverse",
"(",
")",
":",
"yield",
"{",
"'_id'",
":",
"commit",
".",
"hexsha",
",",
"'repository'",
":",
"name",
",",
"'committed_date'",
":",
"datetime",
... | Go through the git repository log and generate a document per commit
containing all the metadata. | [
"Go",
"through",
"the",
"git",
"repository",
"log",
"and",
"generate",
"a",
"document",
"per",
"commit",
"containing",
"all",
"the",
"metadata",
"."
] | 2aab285c8f506f3863cbdaba3c90a685c510ba00 | https://github.com/elastic/elasticsearch-py/blob/2aab285c8f506f3863cbdaba3c90a685c510ba00/example/load.py#L76-L100 | train |
elastic/elasticsearch-py | example/load.py | load_repo | def load_repo(client, path=None, index='git'):
"""
Parse a git repository with all it's commits and load it into elasticsearch
using `client`. If the index doesn't exist it will be created.
"""
path = dirname(dirname(abspath(__file__))) if path is None else path
repo_name = basename(path)
re... | python | def load_repo(client, path=None, index='git'):
"""
Parse a git repository with all it's commits and load it into elasticsearch
using `client`. If the index doesn't exist it will be created.
"""
path = dirname(dirname(abspath(__file__))) if path is None else path
repo_name = basename(path)
re... | [
"def",
"load_repo",
"(",
"client",
",",
"path",
"=",
"None",
",",
"index",
"=",
"'git'",
")",
":",
"path",
"=",
"dirname",
"(",
"dirname",
"(",
"abspath",
"(",
"__file__",
")",
")",
")",
"if",
"path",
"is",
"None",
"else",
"path",
"repo_name",
"=",
... | Parse a git repository with all it's commits and load it into elasticsearch
using `client`. If the index doesn't exist it will be created. | [
"Parse",
"a",
"git",
"repository",
"with",
"all",
"it",
"s",
"commits",
"and",
"load",
"it",
"into",
"elasticsearch",
"using",
"client",
".",
"If",
"the",
"index",
"doesn",
"t",
"exist",
"it",
"will",
"be",
"created",
"."
] | 2aab285c8f506f3863cbdaba3c90a685c510ba00 | https://github.com/elastic/elasticsearch-py/blob/2aab285c8f506f3863cbdaba3c90a685c510ba00/example/load.py#L102-L130 | train |
elastic/elasticsearch-py | elasticsearch/client/xpack/rollup.py | RollupClient.get_jobs | def get_jobs(self, id=None, params=None):
"""
`<>`_
:arg id: The ID of the job(s) to fetch. Accepts glob patterns, or left
blank for all jobs
"""
return self.transport.perform_request(
"GET", _make_path("_rollup", "job", id), params=params
) | python | def get_jobs(self, id=None, params=None):
"""
`<>`_
:arg id: The ID of the job(s) to fetch. Accepts glob patterns, or left
blank for all jobs
"""
return self.transport.perform_request(
"GET", _make_path("_rollup", "job", id), params=params
) | [
"def",
"get_jobs",
"(",
"self",
",",
"id",
"=",
"None",
",",
"params",
"=",
"None",
")",
":",
"return",
"self",
".",
"transport",
".",
"perform_request",
"(",
"\"GET\"",
",",
"_make_path",
"(",
"\"_rollup\"",
",",
"\"job\"",
",",
"id",
")",
",",
"param... | `<>`_
:arg id: The ID of the job(s) to fetch. Accepts glob patterns, or left
blank for all jobs | [
"<",
">",
"_"
] | 2aab285c8f506f3863cbdaba3c90a685c510ba00 | https://github.com/elastic/elasticsearch-py/blob/2aab285c8f506f3863cbdaba3c90a685c510ba00/elasticsearch/client/xpack/rollup.py#L19-L28 | train |
elastic/elasticsearch-py | elasticsearch/client/xpack/rollup.py | RollupClient.get_rollup_caps | def get_rollup_caps(self, id=None, params=None):
"""
`<>`_
:arg id: The ID of the index to check rollup capabilities on, or left
blank for all jobs
"""
return self.transport.perform_request(
"GET", _make_path("_rollup", "data", id), params=params
... | python | def get_rollup_caps(self, id=None, params=None):
"""
`<>`_
:arg id: The ID of the index to check rollup capabilities on, or left
blank for all jobs
"""
return self.transport.perform_request(
"GET", _make_path("_rollup", "data", id), params=params
... | [
"def",
"get_rollup_caps",
"(",
"self",
",",
"id",
"=",
"None",
",",
"params",
"=",
"None",
")",
":",
"return",
"self",
".",
"transport",
".",
"perform_request",
"(",
"\"GET\"",
",",
"_make_path",
"(",
"\"_rollup\"",
",",
"\"data\"",
",",
"id",
")",
",",
... | `<>`_
:arg id: The ID of the index to check rollup capabilities on, or left
blank for all jobs | [
"<",
">",
"_"
] | 2aab285c8f506f3863cbdaba3c90a685c510ba00 | https://github.com/elastic/elasticsearch-py/blob/2aab285c8f506f3863cbdaba3c90a685c510ba00/elasticsearch/client/xpack/rollup.py#L31-L40 | train |
elastic/elasticsearch-py | elasticsearch/client/xpack/rollup.py | RollupClient.put_job | def put_job(self, id, body, params=None):
"""
`<>`_
:arg id: The ID of the job to create
:arg body: The job configuration
"""
for param in (id, body):
if param in SKIP_IN_PATH:
raise ValueError("Empty value passed for a required argument.")
... | python | def put_job(self, id, body, params=None):
"""
`<>`_
:arg id: The ID of the job to create
:arg body: The job configuration
"""
for param in (id, body):
if param in SKIP_IN_PATH:
raise ValueError("Empty value passed for a required argument.")
... | [
"def",
"put_job",
"(",
"self",
",",
"id",
",",
"body",
",",
"params",
"=",
"None",
")",
":",
"for",
"param",
"in",
"(",
"id",
",",
"body",
")",
":",
"if",
"param",
"in",
"SKIP_IN_PATH",
":",
"raise",
"ValueError",
"(",
"\"Empty value passed for a require... | `<>`_
:arg id: The ID of the job to create
:arg body: The job configuration | [
"<",
">",
"_"
] | 2aab285c8f506f3863cbdaba3c90a685c510ba00 | https://github.com/elastic/elasticsearch-py/blob/2aab285c8f506f3863cbdaba3c90a685c510ba00/elasticsearch/client/xpack/rollup.py#L57-L69 | train |
elastic/elasticsearch-py | elasticsearch/client/xpack/deprecation.py | DeprecationClient.info | def info(self, index=None, params=None):
"""
`<http://www.elastic.co/guide/en/migration/current/migration-api-deprecation.html>`_
:arg index: Index pattern
"""
return self.transport.perform_request(
"GET",
_make_path(index, "_xpack", "migration", "depreca... | python | def info(self, index=None, params=None):
"""
`<http://www.elastic.co/guide/en/migration/current/migration-api-deprecation.html>`_
:arg index: Index pattern
"""
return self.transport.perform_request(
"GET",
_make_path(index, "_xpack", "migration", "depreca... | [
"def",
"info",
"(",
"self",
",",
"index",
"=",
"None",
",",
"params",
"=",
"None",
")",
":",
"return",
"self",
".",
"transport",
".",
"perform_request",
"(",
"\"GET\"",
",",
"_make_path",
"(",
"index",
",",
"\"_xpack\"",
",",
"\"migration\"",
",",
"\"dep... | `<http://www.elastic.co/guide/en/migration/current/migration-api-deprecation.html>`_
:arg index: Index pattern | [
"<http",
":",
"//",
"www",
".",
"elastic",
".",
"co",
"/",
"guide",
"/",
"en",
"/",
"migration",
"/",
"current",
"/",
"migration",
"-",
"api",
"-",
"deprecation",
".",
"html",
">",
"_"
] | 2aab285c8f506f3863cbdaba3c90a685c510ba00 | https://github.com/elastic/elasticsearch-py/blob/2aab285c8f506f3863cbdaba3c90a685c510ba00/elasticsearch/client/xpack/deprecation.py#L6-L16 | train |
elastic/elasticsearch-py | elasticsearch/client/nodes.py | NodesClient.info | def info(self, node_id=None, metric=None, params=None):
"""
The cluster nodes info API allows to retrieve one or more (or all) of
the cluster nodes information.
`<https://www.elastic.co/guide/en/elasticsearch/reference/current/cluster-nodes-info.html>`_
:arg node_id: A comma-sep... | python | def info(self, node_id=None, metric=None, params=None):
"""
The cluster nodes info API allows to retrieve one or more (or all) of
the cluster nodes information.
`<https://www.elastic.co/guide/en/elasticsearch/reference/current/cluster-nodes-info.html>`_
:arg node_id: A comma-sep... | [
"def",
"info",
"(",
"self",
",",
"node_id",
"=",
"None",
",",
"metric",
"=",
"None",
",",
"params",
"=",
"None",
")",
":",
"return",
"self",
".",
"transport",
".",
"perform_request",
"(",
"\"GET\"",
",",
"_make_path",
"(",
"\"_nodes\"",
",",
"node_id",
... | The cluster nodes info API allows to retrieve one or more (or all) of
the cluster nodes information.
`<https://www.elastic.co/guide/en/elasticsearch/reference/current/cluster-nodes-info.html>`_
:arg node_id: A comma-separated list of node IDs or names to limit the
returned informati... | [
"The",
"cluster",
"nodes",
"info",
"API",
"allows",
"to",
"retrieve",
"one",
"or",
"more",
"(",
"or",
"all",
")",
"of",
"the",
"cluster",
"nodes",
"information",
".",
"<https",
":",
"//",
"www",
".",
"elastic",
".",
"co",
"/",
"guide",
"/",
"en",
"/"... | 2aab285c8f506f3863cbdaba3c90a685c510ba00 | https://github.com/elastic/elasticsearch-py/blob/2aab285c8f506f3863cbdaba3c90a685c510ba00/elasticsearch/client/nodes.py#L17-L34 | train |
elastic/elasticsearch-py | elasticsearch/client/nodes.py | NodesClient.stats | def stats(self, node_id=None, metric=None, index_metric=None, params=None):
"""
The cluster nodes stats API allows to retrieve one or more (or all) of
the cluster nodes statistics.
`<https://www.elastic.co/guide/en/elasticsearch/reference/current/cluster-nodes-stats.html>`_
:arg... | python | def stats(self, node_id=None, metric=None, index_metric=None, params=None):
"""
The cluster nodes stats API allows to retrieve one or more (or all) of
the cluster nodes statistics.
`<https://www.elastic.co/guide/en/elasticsearch/reference/current/cluster-nodes-stats.html>`_
:arg... | [
"def",
"stats",
"(",
"self",
",",
"node_id",
"=",
"None",
",",
"metric",
"=",
"None",
",",
"index_metric",
"=",
"None",
",",
"params",
"=",
"None",
")",
":",
"return",
"self",
".",
"transport",
".",
"perform_request",
"(",
"\"GET\"",
",",
"_make_path",
... | The cluster nodes stats API allows to retrieve one or more (or all) of
the cluster nodes statistics.
`<https://www.elastic.co/guide/en/elasticsearch/reference/current/cluster-nodes-stats.html>`_
:arg node_id: A comma-separated list of node IDs or names to limit the
returned informat... | [
"The",
"cluster",
"nodes",
"stats",
"API",
"allows",
"to",
"retrieve",
"one",
"or",
"more",
"(",
"or",
"all",
")",
"of",
"the",
"cluster",
"nodes",
"statistics",
".",
"<https",
":",
"//",
"www",
".",
"elastic",
".",
"co",
"/",
"guide",
"/",
"en",
"/"... | 2aab285c8f506f3863cbdaba3c90a685c510ba00 | https://github.com/elastic/elasticsearch-py/blob/2aab285c8f506f3863cbdaba3c90a685c510ba00/elasticsearch/client/nodes.py#L46-L82 | train |
elastic/elasticsearch-py | elasticsearch/client/nodes.py | NodesClient.hot_threads | def hot_threads(self, node_id=None, params=None):
"""
An API allowing to get the current hot threads on each node in the cluster.
`<https://www.elastic.co/guide/en/elasticsearch/reference/current/cluster-nodes-hot-threads.html>`_
:arg node_id: A comma-separated list of node IDs or names... | python | def hot_threads(self, node_id=None, params=None):
"""
An API allowing to get the current hot threads on each node in the cluster.
`<https://www.elastic.co/guide/en/elasticsearch/reference/current/cluster-nodes-hot-threads.html>`_
:arg node_id: A comma-separated list of node IDs or names... | [
"def",
"hot_threads",
"(",
"self",
",",
"node_id",
"=",
"None",
",",
"params",
"=",
"None",
")",
":",
"# avoid python reserved words",
"if",
"params",
"and",
"\"type_\"",
"in",
"params",
":",
"params",
"[",
"\"type\"",
"]",
"=",
"params",
".",
"pop",
"(",
... | An API allowing to get the current hot threads on each node in the cluster.
`<https://www.elastic.co/guide/en/elasticsearch/reference/current/cluster-nodes-hot-threads.html>`_
:arg node_id: A comma-separated list of node IDs or names to limit the
returned information; use `_local` to return... | [
"An",
"API",
"allowing",
"to",
"get",
"the",
"current",
"hot",
"threads",
"on",
"each",
"node",
"in",
"the",
"cluster",
".",
"<https",
":",
"//",
"www",
".",
"elastic",
".",
"co",
"/",
"guide",
"/",
"en",
"/",
"elasticsearch",
"/",
"reference",
"/",
... | 2aab285c8f506f3863cbdaba3c90a685c510ba00 | https://github.com/elastic/elasticsearch-py/blob/2aab285c8f506f3863cbdaba3c90a685c510ba00/elasticsearch/client/nodes.py#L87-L112 | train |
elastic/elasticsearch-py | elasticsearch/client/nodes.py | NodesClient.usage | def usage(self, node_id=None, metric=None, params=None):
"""
The cluster nodes usage API allows to retrieve information on the usage
of features for each node.
`<http://www.elastic.co/guide/en/elasticsearch/reference/master/cluster-nodes-usage.html>`_
:arg node_id: A comma-separ... | python | def usage(self, node_id=None, metric=None, params=None):
"""
The cluster nodes usage API allows to retrieve information on the usage
of features for each node.
`<http://www.elastic.co/guide/en/elasticsearch/reference/master/cluster-nodes-usage.html>`_
:arg node_id: A comma-separ... | [
"def",
"usage",
"(",
"self",
",",
"node_id",
"=",
"None",
",",
"metric",
"=",
"None",
",",
"params",
"=",
"None",
")",
":",
"return",
"self",
".",
"transport",
".",
"perform_request",
"(",
"\"GET\"",
",",
"_make_path",
"(",
"\"_nodes\"",
",",
"node_id",
... | The cluster nodes usage API allows to retrieve information on the usage
of features for each node.
`<http://www.elastic.co/guide/en/elasticsearch/reference/master/cluster-nodes-usage.html>`_
:arg node_id: A comma-separated list of node IDs or names to limit the
returned information;... | [
"The",
"cluster",
"nodes",
"usage",
"API",
"allows",
"to",
"retrieve",
"information",
"on",
"the",
"usage",
"of",
"features",
"for",
"each",
"node",
".",
"<http",
":",
"//",
"www",
".",
"elastic",
".",
"co",
"/",
"guide",
"/",
"en",
"/",
"elasticsearch",... | 2aab285c8f506f3863cbdaba3c90a685c510ba00 | https://github.com/elastic/elasticsearch-py/blob/2aab285c8f506f3863cbdaba3c90a685c510ba00/elasticsearch/client/nodes.py#L115-L132 | train |
elastic/elasticsearch-py | elasticsearch/helpers/actions.py | _chunk_actions | def _chunk_actions(actions, chunk_size, max_chunk_bytes, serializer):
"""
Split actions into chunks by number or size, serialize them into strings in
the process.
"""
bulk_actions, bulk_data = [], []
size, action_count = 0, 0
for action, data in actions:
raw_data, raw_action = data, ... | python | def _chunk_actions(actions, chunk_size, max_chunk_bytes, serializer):
"""
Split actions into chunks by number or size, serialize them into strings in
the process.
"""
bulk_actions, bulk_data = [], []
size, action_count = 0, 0
for action, data in actions:
raw_data, raw_action = data, ... | [
"def",
"_chunk_actions",
"(",
"actions",
",",
"chunk_size",
",",
"max_chunk_bytes",
",",
"serializer",
")",
":",
"bulk_actions",
",",
"bulk_data",
"=",
"[",
"]",
",",
"[",
"]",
"size",
",",
"action_count",
"=",
"0",
",",
"0",
"for",
"action",
",",
"data"... | Split actions into chunks by number or size, serialize them into strings in
the process. | [
"Split",
"actions",
"into",
"chunks",
"by",
"number",
"or",
"size",
"serialize",
"them",
"into",
"strings",
"in",
"the",
"process",
"."
] | 2aab285c8f506f3863cbdaba3c90a685c510ba00 | https://github.com/elastic/elasticsearch-py/blob/2aab285c8f506f3863cbdaba3c90a685c510ba00/elasticsearch/helpers/actions.py#L56-L92 | train |
elastic/elasticsearch-py | elasticsearch/helpers/actions.py | _process_bulk_chunk | def _process_bulk_chunk(
client,
bulk_actions,
bulk_data,
raise_on_exception=True,
raise_on_error=True,
*args,
**kwargs
):
"""
Send a bulk request to elasticsearch and process the output.
"""
# if raise on error is set, we need to collect errors per chunk before raising them
... | python | def _process_bulk_chunk(
client,
bulk_actions,
bulk_data,
raise_on_exception=True,
raise_on_error=True,
*args,
**kwargs
):
"""
Send a bulk request to elasticsearch and process the output.
"""
# if raise on error is set, we need to collect errors per chunk before raising them
... | [
"def",
"_process_bulk_chunk",
"(",
"client",
",",
"bulk_actions",
",",
"bulk_data",
",",
"raise_on_exception",
"=",
"True",
",",
"raise_on_error",
"=",
"True",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"# if raise on error is set, we need to collect error... | Send a bulk request to elasticsearch and process the output. | [
"Send",
"a",
"bulk",
"request",
"to",
"elasticsearch",
"and",
"process",
"the",
"output",
"."
] | 2aab285c8f506f3863cbdaba3c90a685c510ba00 | https://github.com/elastic/elasticsearch-py/blob/2aab285c8f506f3863cbdaba3c90a685c510ba00/elasticsearch/helpers/actions.py#L95-L158 | train |
elastic/elasticsearch-py | elasticsearch/helpers/actions.py | streaming_bulk | def streaming_bulk(
client,
actions,
chunk_size=500,
max_chunk_bytes=100 * 1024 * 1024,
raise_on_error=True,
expand_action_callback=expand_action,
raise_on_exception=True,
max_retries=0,
initial_backoff=2,
max_backoff=600,
yield_ok=True,
*args,
**kwargs
):
"""
... | python | def streaming_bulk(
client,
actions,
chunk_size=500,
max_chunk_bytes=100 * 1024 * 1024,
raise_on_error=True,
expand_action_callback=expand_action,
raise_on_exception=True,
max_retries=0,
initial_backoff=2,
max_backoff=600,
yield_ok=True,
*args,
**kwargs
):
"""
... | [
"def",
"streaming_bulk",
"(",
"client",
",",
"actions",
",",
"chunk_size",
"=",
"500",
",",
"max_chunk_bytes",
"=",
"100",
"*",
"1024",
"*",
"1024",
",",
"raise_on_error",
"=",
"True",
",",
"expand_action_callback",
"=",
"expand_action",
",",
"raise_on_exception... | Streaming bulk consumes actions from the iterable passed in and yields
results per action. For non-streaming usecases use
:func:`~elasticsearch.helpers.bulk` which is a wrapper around streaming
bulk that returns summary information about the bulk operation once the
entire input is consumed and sent.
... | [
"Streaming",
"bulk",
"consumes",
"actions",
"from",
"the",
"iterable",
"passed",
"in",
"and",
"yields",
"results",
"per",
"action",
".",
"For",
"non",
"-",
"streaming",
"usecases",
"use",
":",
"func",
":",
"~elasticsearch",
".",
"helpers",
".",
"bulk",
"whic... | 2aab285c8f506f3863cbdaba3c90a685c510ba00 | https://github.com/elastic/elasticsearch-py/blob/2aab285c8f506f3863cbdaba3c90a685c510ba00/elasticsearch/helpers/actions.py#L161-L262 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.