repo stringlengths 7 55 | path stringlengths 4 223 | func_name stringlengths 1 134 | original_string stringlengths 75 104k | language stringclasses 1
value | code stringlengths 75 104k | code_tokens listlengths 19 28.4k | docstring stringlengths 1 46.9k | docstring_tokens listlengths 1 1.97k | sha stringlengths 40 40 | url stringlengths 87 315 | partition stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|
blue-yonder/tsfresh | tsfresh/examples/har_dataset.py | download_har_dataset | def download_har_dataset():
"""
Download human activity recognition dataset from UCI ML Repository and store it at /tsfresh/notebooks/data.
Examples
========
>>> from tsfresh.examples import har_dataset
>>> har_dataset.download_har_dataset()
"""
zipurl = 'https://github.com/MaxBen... | python | def download_har_dataset():
"""
Download human activity recognition dataset from UCI ML Repository and store it at /tsfresh/notebooks/data.
Examples
========
>>> from tsfresh.examples import har_dataset
>>> har_dataset.download_har_dataset()
"""
zipurl = 'https://github.com/MaxBen... | [
"def",
"download_har_dataset",
"(",
")",
":",
"zipurl",
"=",
"'https://github.com/MaxBenChrist/human-activity-dataset/blob/master/UCI%20HAR%20Dataset.zip?raw=true'",
"if",
"os",
".",
"path",
".",
"exists",
"(",
"data_file_name_dataset",
")",
"and",
"os",
".",
"path",
".",
... | Download human activity recognition dataset from UCI ML Repository and store it at /tsfresh/notebooks/data.
Examples
========
>>> from tsfresh.examples import har_dataset
>>> har_dataset.download_har_dataset() | [
"Download",
"human",
"activity",
"recognition",
"dataset",
"from",
"UCI",
"ML",
"Repository",
"and",
"store",
"it",
"at",
"/",
"tsfresh",
"/",
"notebooks",
"/",
"data",
".",
"Examples",
"========"
] | c72c9c574371cf7dd7d54e00a466792792e5d202 | https://github.com/blue-yonder/tsfresh/blob/c72c9c574371cf7dd7d54e00a466792792e5d202/tsfresh/examples/har_dataset.py#L38-L58 | train |
blue-yonder/tsfresh | tsfresh/transformers/feature_augmenter.py | FeatureAugmenter.transform | def transform(self, X):
"""
Add the features calculated using the timeseries_container and add them to the corresponding rows in the input
pandas.DataFrame X.
To save some computing time, you should only include those time serieses in the container, that you
need. You can set th... | python | def transform(self, X):
"""
Add the features calculated using the timeseries_container and add them to the corresponding rows in the input
pandas.DataFrame X.
To save some computing time, you should only include those time serieses in the container, that you
need. You can set th... | [
"def",
"transform",
"(",
"self",
",",
"X",
")",
":",
"if",
"self",
".",
"timeseries_container",
"is",
"None",
":",
"raise",
"RuntimeError",
"(",
"\"You have to provide a time series using the set_timeseries_container function before.\"",
")",
"# Extract only features for the ... | Add the features calculated using the timeseries_container and add them to the corresponding rows in the input
pandas.DataFrame X.
To save some computing time, you should only include those time serieses in the container, that you
need. You can set the timeseries container with the method :func... | [
"Add",
"the",
"features",
"calculated",
"using",
"the",
"timeseries_container",
"and",
"add",
"them",
"to",
"the",
"corresponding",
"rows",
"in",
"the",
"input",
"pandas",
".",
"DataFrame",
"X",
"."
] | c72c9c574371cf7dd7d54e00a466792792e5d202 | https://github.com/blue-yonder/tsfresh/blob/c72c9c574371cf7dd7d54e00a466792792e5d202/tsfresh/transformers/feature_augmenter.py#L166-L202 | train |
blue-yonder/tsfresh | tsfresh/transformers/relevant_feature_augmenter.py | RelevantFeatureAugmenter.fit | def fit(self, X, y):
"""
Use the given timeseries from :func:`~set_timeseries_container` and calculate features from it and add them
to the data sample X (which can contain other manually-designed features).
Then determine which of the features of X are relevant for the given target y.
... | python | def fit(self, X, y):
"""
Use the given timeseries from :func:`~set_timeseries_container` and calculate features from it and add them
to the data sample X (which can contain other manually-designed features).
Then determine which of the features of X are relevant for the given target y.
... | [
"def",
"fit",
"(",
"self",
",",
"X",
",",
"y",
")",
":",
"if",
"self",
".",
"timeseries_container",
"is",
"None",
":",
"raise",
"RuntimeError",
"(",
"\"You have to provide a time series using the set_timeseries_container function before.\"",
")",
"self",
".",
"feature... | Use the given timeseries from :func:`~set_timeseries_container` and calculate features from it and add them
to the data sample X (which can contain other manually-designed features).
Then determine which of the features of X are relevant for the given target y.
Store those relevant features int... | [
"Use",
"the",
"given",
"timeseries",
"from",
":",
"func",
":",
"~set_timeseries_container",
"and",
"calculate",
"features",
"from",
"it",
"and",
"add",
"them",
"to",
"the",
"data",
"sample",
"X",
"(",
"which",
"can",
"contain",
"other",
"manually",
"-",
"des... | c72c9c574371cf7dd7d54e00a466792792e5d202 | https://github.com/blue-yonder/tsfresh/blob/c72c9c574371cf7dd7d54e00a466792792e5d202/tsfresh/transformers/relevant_feature_augmenter.py#L228-L268 | train |
blue-yonder/tsfresh | tsfresh/transformers/relevant_feature_augmenter.py | RelevantFeatureAugmenter.transform | def transform(self, X):
"""
After the fit step, it is known which features are relevant, Only extract those from the time series handed in
with the function :func:`~set_timeseries_container`.
If filter_only_tsfresh_features is False, also delete the irrelevant, already present features ... | python | def transform(self, X):
"""
After the fit step, it is known which features are relevant, Only extract those from the time series handed in
with the function :func:`~set_timeseries_container`.
If filter_only_tsfresh_features is False, also delete the irrelevant, already present features ... | [
"def",
"transform",
"(",
"self",
",",
"X",
")",
":",
"if",
"self",
".",
"feature_selector",
".",
"relevant_features",
"is",
"None",
":",
"raise",
"RuntimeError",
"(",
"\"You have to call fit before.\"",
")",
"if",
"self",
".",
"timeseries_container",
"is",
"None... | After the fit step, it is known which features are relevant, Only extract those from the time series handed in
with the function :func:`~set_timeseries_container`.
If filter_only_tsfresh_features is False, also delete the irrelevant, already present features in the data frame.
:param X: the da... | [
"After",
"the",
"fit",
"step",
"it",
"is",
"known",
"which",
"features",
"are",
"relevant",
"Only",
"extract",
"those",
"from",
"the",
"time",
"series",
"handed",
"in",
"with",
"the",
"function",
":",
"func",
":",
"~set_timeseries_container",
"."
] | c72c9c574371cf7dd7d54e00a466792792e5d202 | https://github.com/blue-yonder/tsfresh/blob/c72c9c574371cf7dd7d54e00a466792792e5d202/tsfresh/transformers/relevant_feature_augmenter.py#L270-L321 | train |
blue-yonder/tsfresh | tsfresh/scripts/run_tsfresh.py | _preprocess | def _preprocess(df):
"""
given a DataFrame where records are stored row-wise, rearrange it
such that records are stored column-wise.
"""
df = df.stack()
df.index.rename(["id", "time"], inplace=True) # .reset_index()
df.name = "value"
df = df.reset_index()
return df | python | def _preprocess(df):
"""
given a DataFrame where records are stored row-wise, rearrange it
such that records are stored column-wise.
"""
df = df.stack()
df.index.rename(["id", "time"], inplace=True) # .reset_index()
df.name = "value"
df = df.reset_index()
return df | [
"def",
"_preprocess",
"(",
"df",
")",
":",
"df",
"=",
"df",
".",
"stack",
"(",
")",
"df",
".",
"index",
".",
"rename",
"(",
"[",
"\"id\"",
",",
"\"time\"",
"]",
",",
"inplace",
"=",
"True",
")",
"# .reset_index()",
"df",
".",
"name",
"=",
"\"value\... | given a DataFrame where records are stored row-wise, rearrange it
such that records are stored column-wise. | [
"given",
"a",
"DataFrame",
"where",
"records",
"are",
"stored",
"row",
"-",
"wise",
"rearrange",
"it",
"such",
"that",
"records",
"are",
"stored",
"column",
"-",
"wise",
"."
] | c72c9c574371cf7dd7d54e00a466792792e5d202 | https://github.com/blue-yonder/tsfresh/blob/c72c9c574371cf7dd7d54e00a466792792e5d202/tsfresh/scripts/run_tsfresh.py#L30-L42 | train |
blue-yonder/tsfresh | tsfresh/feature_selection/relevance.py | calculate_relevance_table | def calculate_relevance_table(X, y, ml_task='auto', n_jobs=defaults.N_PROCESSES, chunksize=defaults.CHUNKSIZE,
test_for_binary_target_binary_feature=defaults.TEST_FOR_BINARY_TARGET_BINARY_FEATURE,
test_for_binary_target_real_feature=defaults.TEST_FOR_BINARY_TARGET_REAL_FEATURE,
... | python | def calculate_relevance_table(X, y, ml_task='auto', n_jobs=defaults.N_PROCESSES, chunksize=defaults.CHUNKSIZE,
test_for_binary_target_binary_feature=defaults.TEST_FOR_BINARY_TARGET_BINARY_FEATURE,
test_for_binary_target_real_feature=defaults.TEST_FOR_BINARY_TARGET_REAL_FEATURE,
... | [
"def",
"calculate_relevance_table",
"(",
"X",
",",
"y",
",",
"ml_task",
"=",
"'auto'",
",",
"n_jobs",
"=",
"defaults",
".",
"N_PROCESSES",
",",
"chunksize",
"=",
"defaults",
".",
"CHUNKSIZE",
",",
"test_for_binary_target_binary_feature",
"=",
"defaults",
".",
"T... | Calculate the relevance table for the features contained in feature matrix `X` with respect to target vector `y`.
The relevance table is calculated for the intended machine learning task `ml_task`.
To accomplish this for each feature from the input pandas.DataFrame an univariate feature significance test
i... | [
"Calculate",
"the",
"relevance",
"table",
"for",
"the",
"features",
"contained",
"in",
"feature",
"matrix",
"X",
"with",
"respect",
"to",
"target",
"vector",
"y",
".",
"The",
"relevance",
"table",
"is",
"calculated",
"for",
"the",
"intended",
"machine",
"learn... | c72c9c574371cf7dd7d54e00a466792792e5d202 | https://github.com/blue-yonder/tsfresh/blob/c72c9c574371cf7dd7d54e00a466792792e5d202/tsfresh/feature_selection/relevance.py#L31-L191 | train |
blue-yonder/tsfresh | tsfresh/feature_selection/relevance.py | infer_ml_task | def infer_ml_task(y):
"""
Infer the machine learning task to select for.
The result will be either `'regression'` or `'classification'`.
If the target vector only consists of integer typed values or objects, we assume the task is `'classification'`.
Else `'regression'`.
:param y: The target vec... | python | def infer_ml_task(y):
"""
Infer the machine learning task to select for.
The result will be either `'regression'` or `'classification'`.
If the target vector only consists of integer typed values or objects, we assume the task is `'classification'`.
Else `'regression'`.
:param y: The target vec... | [
"def",
"infer_ml_task",
"(",
"y",
")",
":",
"if",
"y",
".",
"dtype",
".",
"kind",
"in",
"np",
".",
"typecodes",
"[",
"'AllInteger'",
"]",
"or",
"y",
".",
"dtype",
"==",
"np",
".",
"object",
":",
"ml_task",
"=",
"'classification'",
"else",
":",
"ml_ta... | Infer the machine learning task to select for.
The result will be either `'regression'` or `'classification'`.
If the target vector only consists of integer typed values or objects, we assume the task is `'classification'`.
Else `'regression'`.
:param y: The target vector y.
:type y: pandas.Series
... | [
"Infer",
"the",
"machine",
"learning",
"task",
"to",
"select",
"for",
".",
"The",
"result",
"will",
"be",
"either",
"regression",
"or",
"classification",
".",
"If",
"the",
"target",
"vector",
"only",
"consists",
"of",
"integer",
"typed",
"values",
"or",
"obj... | c72c9c574371cf7dd7d54e00a466792792e5d202 | https://github.com/blue-yonder/tsfresh/blob/c72c9c574371cf7dd7d54e00a466792792e5d202/tsfresh/feature_selection/relevance.py#L208-L226 | train |
blue-yonder/tsfresh | tsfresh/feature_selection/relevance.py | combine_relevance_tables | def combine_relevance_tables(relevance_tables):
"""
Create a combined relevance table out of a list of relevance tables,
aggregating the p-values and the relevances.
:param relevance_tables: A list of relevance tables
:type relevance_tables: List[pd.DataFrame]
:return: The combined relevance ta... | python | def combine_relevance_tables(relevance_tables):
"""
Create a combined relevance table out of a list of relevance tables,
aggregating the p-values and the relevances.
:param relevance_tables: A list of relevance tables
:type relevance_tables: List[pd.DataFrame]
:return: The combined relevance ta... | [
"def",
"combine_relevance_tables",
"(",
"relevance_tables",
")",
":",
"def",
"_combine",
"(",
"a",
",",
"b",
")",
":",
"a",
".",
"relevant",
"|=",
"b",
".",
"relevant",
"a",
".",
"p_value",
"=",
"a",
".",
"p_value",
".",
"combine",
"(",
"b",
".",
"p_... | Create a combined relevance table out of a list of relevance tables,
aggregating the p-values and the relevances.
:param relevance_tables: A list of relevance tables
:type relevance_tables: List[pd.DataFrame]
:return: The combined relevance table
:rtype: pandas.DataFrame | [
"Create",
"a",
"combined",
"relevance",
"table",
"out",
"of",
"a",
"list",
"of",
"relevance",
"tables",
"aggregating",
"the",
"p",
"-",
"values",
"and",
"the",
"relevances",
"."
] | c72c9c574371cf7dd7d54e00a466792792e5d202 | https://github.com/blue-yonder/tsfresh/blob/c72c9c574371cf7dd7d54e00a466792792e5d202/tsfresh/feature_selection/relevance.py#L229-L244 | train |
blue-yonder/tsfresh | tsfresh/feature_selection/relevance.py | get_feature_type | def get_feature_type(feature_column):
"""
For a given feature, determine if it is real, binary or constant.
Here binary means that only two unique values occur in the feature.
:param feature_column: The feature column
:type feature_column: pandas.Series
:return: 'constant', 'binary' or 'real'
... | python | def get_feature_type(feature_column):
"""
For a given feature, determine if it is real, binary or constant.
Here binary means that only two unique values occur in the feature.
:param feature_column: The feature column
:type feature_column: pandas.Series
:return: 'constant', 'binary' or 'real'
... | [
"def",
"get_feature_type",
"(",
"feature_column",
")",
":",
"n_unique_values",
"=",
"len",
"(",
"set",
"(",
"feature_column",
".",
"values",
")",
")",
"if",
"n_unique_values",
"==",
"1",
":",
"_logger",
".",
"warning",
"(",
"\"[test_feature_significance] Feature {... | For a given feature, determine if it is real, binary or constant.
Here binary means that only two unique values occur in the feature.
:param feature_column: The feature column
:type feature_column: pandas.Series
:return: 'constant', 'binary' or 'real' | [
"For",
"a",
"given",
"feature",
"determine",
"if",
"it",
"is",
"real",
"binary",
"or",
"constant",
".",
"Here",
"binary",
"means",
"that",
"only",
"two",
"unique",
"values",
"occur",
"in",
"the",
"feature",
"."
] | c72c9c574371cf7dd7d54e00a466792792e5d202 | https://github.com/blue-yonder/tsfresh/blob/c72c9c574371cf7dd7d54e00a466792792e5d202/tsfresh/feature_selection/relevance.py#L247-L263 | train |
blue-yonder/tsfresh | tsfresh/feature_extraction/extraction.py | extract_features | def extract_features(timeseries_container, default_fc_parameters=None,
kind_to_fc_parameters=None,
column_id=None, column_sort=None, column_kind=None, column_value=None,
chunksize=defaults.CHUNKSIZE,
n_jobs=defaults.N_PROCESSES, show_wa... | python | def extract_features(timeseries_container, default_fc_parameters=None,
kind_to_fc_parameters=None,
column_id=None, column_sort=None, column_kind=None, column_value=None,
chunksize=defaults.CHUNKSIZE,
n_jobs=defaults.N_PROCESSES, show_wa... | [
"def",
"extract_features",
"(",
"timeseries_container",
",",
"default_fc_parameters",
"=",
"None",
",",
"kind_to_fc_parameters",
"=",
"None",
",",
"column_id",
"=",
"None",
",",
"column_sort",
"=",
"None",
",",
"column_kind",
"=",
"None",
",",
"column_value",
"=",... | Extract features from
* a :class:`pandas.DataFrame` containing the different time series
or
* a dictionary of :class:`pandas.DataFrame` each containing one type of time series
In both cases a :class:`pandas.DataFrame` with the calculated features will be returned.
For a list of all the calculat... | [
"Extract",
"features",
"from"
] | c72c9c574371cf7dd7d54e00a466792792e5d202 | https://github.com/blue-yonder/tsfresh/blob/c72c9c574371cf7dd7d54e00a466792792e5d202/tsfresh/feature_extraction/extraction.py#L43-L189 | train |
blue-yonder/tsfresh | tsfresh/feature_extraction/extraction.py | generate_data_chunk_format | def generate_data_chunk_format(df, column_id, column_kind, column_value):
"""Converts the dataframe df in into a list of individual time seriess.
E.g. the DataFrame
==== ====== =========
id kind val
==== ====== =========
1 a -0.21761
1 a ... | python | def generate_data_chunk_format(df, column_id, column_kind, column_value):
"""Converts the dataframe df in into a list of individual time seriess.
E.g. the DataFrame
==== ====== =========
id kind val
==== ====== =========
1 a -0.21761
1 a ... | [
"def",
"generate_data_chunk_format",
"(",
"df",
",",
"column_id",
",",
"column_kind",
",",
"column_value",
")",
":",
"MAX_VALUES_GROUPBY",
"=",
"2147483647",
"if",
"df",
"[",
"[",
"column_id",
",",
"column_kind",
"]",
"]",
".",
"nunique",
"(",
")",
".",
"pro... | Converts the dataframe df in into a list of individual time seriess.
E.g. the DataFrame
==== ====== =========
id kind val
==== ====== =========
1 a -0.21761
1 a -0.613667
1 a -2.07339
2 b -0.576254
... | [
"Converts",
"the",
"dataframe",
"df",
"in",
"into",
"a",
"list",
"of",
"individual",
"time",
"seriess",
"."
] | c72c9c574371cf7dd7d54e00a466792792e5d202 | https://github.com/blue-yonder/tsfresh/blob/c72c9c574371cf7dd7d54e00a466792792e5d202/tsfresh/feature_extraction/extraction.py#L192-L249 | train |
blue-yonder/tsfresh | tsfresh/feature_extraction/extraction.py | _do_extraction | def _do_extraction(df, column_id, column_value, column_kind,
default_fc_parameters, kind_to_fc_parameters,
n_jobs, chunk_size, disable_progressbar, distributor):
"""
Wrapper around the _do_extraction_on_chunk, which calls it on all chunks in the data frame.
A chunk is a... | python | def _do_extraction(df, column_id, column_value, column_kind,
default_fc_parameters, kind_to_fc_parameters,
n_jobs, chunk_size, disable_progressbar, distributor):
"""
Wrapper around the _do_extraction_on_chunk, which calls it on all chunks in the data frame.
A chunk is a... | [
"def",
"_do_extraction",
"(",
"df",
",",
"column_id",
",",
"column_value",
",",
"column_kind",
",",
"default_fc_parameters",
",",
"kind_to_fc_parameters",
",",
"n_jobs",
",",
"chunk_size",
",",
"disable_progressbar",
",",
"distributor",
")",
":",
"data_in_chunks",
"... | Wrapper around the _do_extraction_on_chunk, which calls it on all chunks in the data frame.
A chunk is a subset of the data, with a given kind and id - so a single time series.
The data is separated out into those single time series and the _do_extraction_on_chunk is
called on each of them. The results are... | [
"Wrapper",
"around",
"the",
"_do_extraction_on_chunk",
"which",
"calls",
"it",
"on",
"all",
"chunks",
"in",
"the",
"data",
"frame",
".",
"A",
"chunk",
"is",
"a",
"subset",
"of",
"the",
"data",
"with",
"a",
"given",
"kind",
"and",
"id",
"-",
"so",
"a",
... | c72c9c574371cf7dd7d54e00a466792792e5d202 | https://github.com/blue-yonder/tsfresh/blob/c72c9c574371cf7dd7d54e00a466792792e5d202/tsfresh/feature_extraction/extraction.py#L252-L335 | train |
blue-yonder/tsfresh | tsfresh/feature_extraction/extraction.py | _do_extraction_on_chunk | def _do_extraction_on_chunk(chunk, default_fc_parameters, kind_to_fc_parameters):
"""
Main function of this module: use the feature calculators defined in the
default_fc_parameters or kind_to_fc_parameters parameters and extract all
features on the chunk.
The chunk consists of the chunk id, the chu... | python | def _do_extraction_on_chunk(chunk, default_fc_parameters, kind_to_fc_parameters):
"""
Main function of this module: use the feature calculators defined in the
default_fc_parameters or kind_to_fc_parameters parameters and extract all
features on the chunk.
The chunk consists of the chunk id, the chu... | [
"def",
"_do_extraction_on_chunk",
"(",
"chunk",
",",
"default_fc_parameters",
",",
"kind_to_fc_parameters",
")",
":",
"sample_id",
",",
"kind",
",",
"data",
"=",
"chunk",
"if",
"kind_to_fc_parameters",
"and",
"kind",
"in",
"kind_to_fc_parameters",
":",
"fc_parameters"... | Main function of this module: use the feature calculators defined in the
default_fc_parameters or kind_to_fc_parameters parameters and extract all
features on the chunk.
The chunk consists of the chunk id, the chunk kind and the data (as a Series),
which is then converted to a numpy array - so a single... | [
"Main",
"function",
"of",
"this",
"module",
":",
"use",
"the",
"feature",
"calculators",
"defined",
"in",
"the",
"default_fc_parameters",
"or",
"kind_to_fc_parameters",
"parameters",
"and",
"extract",
"all",
"features",
"on",
"the",
"chunk",
"."
] | c72c9c574371cf7dd7d54e00a466792792e5d202 | https://github.com/blue-yonder/tsfresh/blob/c72c9c574371cf7dd7d54e00a466792792e5d202/tsfresh/feature_extraction/extraction.py#L338-L402 | train |
blue-yonder/tsfresh | tsfresh/utilities/string_manipulation.py | get_config_from_string | def get_config_from_string(parts):
"""
Helper function to extract the configuration of a certain function from the column name.
The column name parts (split by "__") should be passed to this function. It will skip the
kind name and the function name and only use the parameter parts. These parts will be ... | python | def get_config_from_string(parts):
"""
Helper function to extract the configuration of a certain function from the column name.
The column name parts (split by "__") should be passed to this function. It will skip the
kind name and the function name and only use the parameter parts. These parts will be ... | [
"def",
"get_config_from_string",
"(",
"parts",
")",
":",
"relevant_parts",
"=",
"parts",
"[",
"2",
":",
"]",
"if",
"not",
"relevant_parts",
":",
"return",
"config_kwargs",
"=",
"[",
"s",
".",
"rsplit",
"(",
"\"_\"",
",",
"1",
")",
"[",
"0",
"]",
"for",... | Helper function to extract the configuration of a certain function from the column name.
The column name parts (split by "__") should be passed to this function. It will skip the
kind name and the function name and only use the parameter parts. These parts will be split up on "_"
into the parameter name and... | [
"Helper",
"function",
"to",
"extract",
"the",
"configuration",
"of",
"a",
"certain",
"function",
"from",
"the",
"column",
"name",
".",
"The",
"column",
"name",
"parts",
"(",
"split",
"by",
"__",
")",
"should",
"be",
"passed",
"to",
"this",
"function",
".",... | c72c9c574371cf7dd7d54e00a466792792e5d202 | https://github.com/blue-yonder/tsfresh/blob/c72c9c574371cf7dd7d54e00a466792792e5d202/tsfresh/utilities/string_manipulation.py#L10-L44 | train |
blue-yonder/tsfresh | tsfresh/utilities/string_manipulation.py | convert_to_output_format | def convert_to_output_format(param):
"""
Helper function to convert parameters to a valid string, that can be used in a column name.
Does the opposite which is used in the from_columns function.
The parameters are sorted by their name and written out in the form
<param name>_<param value>__<par... | python | def convert_to_output_format(param):
"""
Helper function to convert parameters to a valid string, that can be used in a column name.
Does the opposite which is used in the from_columns function.
The parameters are sorted by their name and written out in the form
<param name>_<param value>__<par... | [
"def",
"convert_to_output_format",
"(",
"param",
")",
":",
"def",
"add_parenthesis_if_string_value",
"(",
"x",
")",
":",
"if",
"isinstance",
"(",
"x",
",",
"string_types",
")",
":",
"return",
"'\"'",
"+",
"str",
"(",
"x",
")",
"+",
"'\"'",
"else",
":",
"... | Helper function to convert parameters to a valid string, that can be used in a column name.
Does the opposite which is used in the from_columns function.
The parameters are sorted by their name and written out in the form
<param name>_<param value>__<param name>_<param value>__ ...
If a <param_val... | [
"Helper",
"function",
"to",
"convert",
"parameters",
"to",
"a",
"valid",
"string",
"that",
"can",
"be",
"used",
"in",
"a",
"column",
"name",
".",
"Does",
"the",
"opposite",
"which",
"is",
"used",
"in",
"the",
"from_columns",
"function",
"."
] | c72c9c574371cf7dd7d54e00a466792792e5d202 | https://github.com/blue-yonder/tsfresh/blob/c72c9c574371cf7dd7d54e00a466792792e5d202/tsfresh/utilities/string_manipulation.py#L47-L71 | train |
blue-yonder/tsfresh | tsfresh/utilities/profiling.py | end_profiling | def end_profiling(profiler, filename, sorting=None):
"""
Helper function to stop the profiling process and write out the profiled
data into the given filename. Before this, sort the stats by the passed sorting.
:param profiler: An already started profiler (probably by start_profiling).
:type profil... | python | def end_profiling(profiler, filename, sorting=None):
"""
Helper function to stop the profiling process and write out the profiled
data into the given filename. Before this, sort the stats by the passed sorting.
:param profiler: An already started profiler (probably by start_profiling).
:type profil... | [
"def",
"end_profiling",
"(",
"profiler",
",",
"filename",
",",
"sorting",
"=",
"None",
")",
":",
"profiler",
".",
"disable",
"(",
")",
"s",
"=",
"six",
".",
"StringIO",
"(",
")",
"ps",
"=",
"pstats",
".",
"Stats",
"(",
"profiler",
",",
"stream",
"=",... | Helper function to stop the profiling process and write out the profiled
data into the given filename. Before this, sort the stats by the passed sorting.
:param profiler: An already started profiler (probably by start_profiling).
:type profiler: cProfile.Profile
:param filename: The name of the output ... | [
"Helper",
"function",
"to",
"stop",
"the",
"profiling",
"process",
"and",
"write",
"out",
"the",
"profiled",
"data",
"into",
"the",
"given",
"filename",
".",
"Before",
"this",
"sort",
"the",
"stats",
"by",
"the",
"passed",
"sorting",
"."
] | c72c9c574371cf7dd7d54e00a466792792e5d202 | https://github.com/blue-yonder/tsfresh/blob/c72c9c574371cf7dd7d54e00a466792792e5d202/tsfresh/utilities/profiling.py#L39-L67 | train |
blue-yonder/tsfresh | tsfresh/transformers/per_column_imputer.py | PerColumnImputer.fit | def fit(self, X, y=None):
"""
Compute the min, max and median for all columns in the DataFrame. For more information,
please see the :func:`~tsfresh.utilities.dataframe_functions.get_range_values_per_column` function.
:param X: DataFrame to calculate min, max and median ... | python | def fit(self, X, y=None):
"""
Compute the min, max and median for all columns in the DataFrame. For more information,
please see the :func:`~tsfresh.utilities.dataframe_functions.get_range_values_per_column` function.
:param X: DataFrame to calculate min, max and median ... | [
"def",
"fit",
"(",
"self",
",",
"X",
",",
"y",
"=",
"None",
")",
":",
"if",
"not",
"isinstance",
"(",
"X",
",",
"pd",
".",
"DataFrame",
")",
":",
"X",
"=",
"pd",
".",
"DataFrame",
"(",
"X",
")",
"col_to_max",
",",
"col_to_min",
",",
"col_to_media... | Compute the min, max and median for all columns in the DataFrame. For more information,
please see the :func:`~tsfresh.utilities.dataframe_functions.get_range_values_per_column` function.
:param X: DataFrame to calculate min, max and median values on
:type X: pandas.DataFrame
... | [
"Compute",
"the",
"min",
"max",
"and",
"median",
"for",
"all",
"columns",
"in",
"the",
"DataFrame",
".",
"For",
"more",
"information",
"please",
"see",
"the",
":",
"func",
":",
"~tsfresh",
".",
"utilities",
".",
"dataframe_functions",
".",
"get_range_values_pe... | c72c9c574371cf7dd7d54e00a466792792e5d202 | https://github.com/blue-yonder/tsfresh/blob/c72c9c574371cf7dd7d54e00a466792792e5d202/tsfresh/transformers/per_column_imputer.py#L46-L85 | train |
blue-yonder/tsfresh | tsfresh/transformers/per_column_imputer.py | PerColumnImputer.transform | def transform(self, X):
"""
Column-wise replace all ``NaNs``, ``-inf`` and ``+inf`` in the DataFrame `X` with average/extreme
values from the provided dictionaries.
:param X: DataFrame to impute
:type X: pandas.DataFrame
:return: imputed DataFram... | python | def transform(self, X):
"""
Column-wise replace all ``NaNs``, ``-inf`` and ``+inf`` in the DataFrame `X` with average/extreme
values from the provided dictionaries.
:param X: DataFrame to impute
:type X: pandas.DataFrame
:return: imputed DataFram... | [
"def",
"transform",
"(",
"self",
",",
"X",
")",
":",
"if",
"not",
"isinstance",
"(",
"X",
",",
"pd",
".",
"DataFrame",
")",
":",
"X",
"=",
"pd",
".",
"DataFrame",
"(",
"X",
")",
"if",
"self",
".",
"_col_to_NINF_repl",
"is",
"None",
"or",
"self",
... | Column-wise replace all ``NaNs``, ``-inf`` and ``+inf`` in the DataFrame `X` with average/extreme
values from the provided dictionaries.
:param X: DataFrame to impute
:type X: pandas.DataFrame
:return: imputed DataFrame
:rtype: pandas.DataFrame
:... | [
"Column",
"-",
"wise",
"replace",
"all",
"NaNs",
"-",
"inf",
"and",
"+",
"inf",
"in",
"the",
"DataFrame",
"X",
"with",
"average",
"/",
"extreme",
"values",
"from",
"the",
"provided",
"dictionaries",
"."
] | c72c9c574371cf7dd7d54e00a466792792e5d202 | https://github.com/blue-yonder/tsfresh/blob/c72c9c574371cf7dd7d54e00a466792792e5d202/tsfresh/transformers/per_column_imputer.py#L87-L109 | train |
blue-yonder/tsfresh | tsfresh/examples/robot_execution_failures.py | download_robot_execution_failures | def download_robot_execution_failures():
"""
Download the Robot Execution Failures LP1 Data Set[#1] from the UCI Machine Learning Repository [#2] and store it
locally.
:return:
Examples
========
>>> from tsfresh.examples import download_robot_execution_failures
>>> download_robot_exec... | python | def download_robot_execution_failures():
"""
Download the Robot Execution Failures LP1 Data Set[#1] from the UCI Machine Learning Repository [#2] and store it
locally.
:return:
Examples
========
>>> from tsfresh.examples import download_robot_execution_failures
>>> download_robot_exec... | [
"def",
"download_robot_execution_failures",
"(",
")",
":",
"if",
"os",
".",
"path",
".",
"exists",
"(",
"data_file_name",
")",
":",
"_logger",
".",
"warning",
"(",
"\"You have already downloaded the Robot Execution Failures LP1 Data Set.\"",
")",
"return",
"if",
"not",
... | Download the Robot Execution Failures LP1 Data Set[#1] from the UCI Machine Learning Repository [#2] and store it
locally.
:return:
Examples
========
>>> from tsfresh.examples import download_robot_execution_failures
>>> download_robot_execution_failures() | [
"Download",
"the",
"Robot",
"Execution",
"Failures",
"LP1",
"Data",
"Set",
"[",
"#1",
"]",
"from",
"the",
"UCI",
"Machine",
"Learning",
"Repository",
"[",
"#2",
"]",
"and",
"store",
"it",
"locally",
"."
] | c72c9c574371cf7dd7d54e00a466792792e5d202 | https://github.com/blue-yonder/tsfresh/blob/c72c9c574371cf7dd7d54e00a466792792e5d202/tsfresh/examples/robot_execution_failures.py#L43-L74 | train |
blue-yonder/tsfresh | tsfresh/examples/robot_execution_failures.py | load_robot_execution_failures | def load_robot_execution_failures(multiclass=False):
"""
Load the Robot Execution Failures LP1 Data Set[1].
The Time series are passed as a flat DataFrame.
Examples
========
>>> from tsfresh.examples import load_robot_execution_failures
>>> df, y = load_robot_execution_failures()
>>> p... | python | def load_robot_execution_failures(multiclass=False):
"""
Load the Robot Execution Failures LP1 Data Set[1].
The Time series are passed as a flat DataFrame.
Examples
========
>>> from tsfresh.examples import load_robot_execution_failures
>>> df, y = load_robot_execution_failures()
>>> p... | [
"def",
"load_robot_execution_failures",
"(",
"multiclass",
"=",
"False",
")",
":",
"if",
"not",
"os",
".",
"path",
".",
"exists",
"(",
"data_file_name",
")",
":",
"raise",
"RuntimeError",
"(",
"UCI_MLD_REF_MSG",
")",
"id_to_target",
"=",
"{",
"}",
"df_rows",
... | Load the Robot Execution Failures LP1 Data Set[1].
The Time series are passed as a flat DataFrame.
Examples
========
>>> from tsfresh.examples import load_robot_execution_failures
>>> df, y = load_robot_execution_failures()
>>> print(df.shape)
(1320, 8)
:param multiclass: If True, ret... | [
"Load",
"the",
"Robot",
"Execution",
"Failures",
"LP1",
"Data",
"Set",
"[",
"1",
"]",
".",
"The",
"Time",
"series",
"are",
"passed",
"as",
"a",
"flat",
"DataFrame",
"."
] | c72c9c574371cf7dd7d54e00a466792792e5d202 | https://github.com/blue-yonder/tsfresh/blob/c72c9c574371cf7dd7d54e00a466792792e5d202/tsfresh/examples/robot_execution_failures.py#L77-L123 | train |
blue-yonder/tsfresh | tsfresh/convenience/relevant_extraction.py | extract_relevant_features | def extract_relevant_features(timeseries_container, y, X=None,
default_fc_parameters=None,
kind_to_fc_parameters=None,
column_id=None, column_sort=None, column_kind=None, column_value=None,
show_warni... | python | def extract_relevant_features(timeseries_container, y, X=None,
default_fc_parameters=None,
kind_to_fc_parameters=None,
column_id=None, column_sort=None, column_kind=None, column_value=None,
show_warni... | [
"def",
"extract_relevant_features",
"(",
"timeseries_container",
",",
"y",
",",
"X",
"=",
"None",
",",
"default_fc_parameters",
"=",
"None",
",",
"kind_to_fc_parameters",
"=",
"None",
",",
"column_id",
"=",
"None",
",",
"column_sort",
"=",
"None",
",",
"column_k... | High level convenience function to extract time series features from `timeseries_container`. Then return feature
matrix `X` possibly augmented with relevant features with respect to target vector `y`.
For more details see the documentation of :func:`~tsfresh.feature_extraction.extraction.extract_features` and
... | [
"High",
"level",
"convenience",
"function",
"to",
"extract",
"time",
"series",
"features",
"from",
"timeseries_container",
".",
"Then",
"return",
"feature",
"matrix",
"X",
"possibly",
"augmented",
"with",
"relevant",
"features",
"with",
"respect",
"to",
"target",
... | c72c9c574371cf7dd7d54e00a466792792e5d202 | https://github.com/blue-yonder/tsfresh/blob/c72c9c574371cf7dd7d54e00a466792792e5d202/tsfresh/convenience/relevant_extraction.py#L13-L181 | train |
blue-yonder/tsfresh | tsfresh/examples/driftbif_simulation.py | sample_tau | def sample_tau(n=10, kappa_3=0.3, ratio=0.5, rel_increase=0.15):
"""
Return list of control parameters
:param n: number of samples
:type n: int
:param kappa_3: inverse bifurcation point
:type kappa_3: float
:param ratio: ratio (default 0.5) of samples before and beyond drift-bifurcatio... | python | def sample_tau(n=10, kappa_3=0.3, ratio=0.5, rel_increase=0.15):
"""
Return list of control parameters
:param n: number of samples
:type n: int
:param kappa_3: inverse bifurcation point
:type kappa_3: float
:param ratio: ratio (default 0.5) of samples before and beyond drift-bifurcatio... | [
"def",
"sample_tau",
"(",
"n",
"=",
"10",
",",
"kappa_3",
"=",
"0.3",
",",
"ratio",
"=",
"0.5",
",",
"rel_increase",
"=",
"0.15",
")",
":",
"assert",
"ratio",
">",
"0",
"and",
"ratio",
"<=",
"1",
"assert",
"kappa_3",
">",
"0",
"assert",
"rel_increase... | Return list of control parameters
:param n: number of samples
:type n: int
:param kappa_3: inverse bifurcation point
:type kappa_3: float
:param ratio: ratio (default 0.5) of samples before and beyond drift-bifurcation
:type ratio: float
:param rel_increase: relative increase from bifu... | [
"Return",
"list",
"of",
"control",
"parameters"
] | c72c9c574371cf7dd7d54e00a466792792e5d202 | https://github.com/blue-yonder/tsfresh/blob/c72c9c574371cf7dd7d54e00a466792792e5d202/tsfresh/examples/driftbif_simulation.py#L105-L127 | train |
blue-yonder/tsfresh | tsfresh/examples/driftbif_simulation.py | load_driftbif | def load_driftbif(n, l, m=2, classification=True, kappa_3=0.3, seed=False):
"""
Simulates n time-series with l time steps each for the m-dimensional velocity of a dissipative soliton
classification=True:
target 0 means tau<=1/0.3, Dissipative Soliton with Brownian motion (purely noise driven)
targe... | python | def load_driftbif(n, l, m=2, classification=True, kappa_3=0.3, seed=False):
"""
Simulates n time-series with l time steps each for the m-dimensional velocity of a dissipative soliton
classification=True:
target 0 means tau<=1/0.3, Dissipative Soliton with Brownian motion (purely noise driven)
targe... | [
"def",
"load_driftbif",
"(",
"n",
",",
"l",
",",
"m",
"=",
"2",
",",
"classification",
"=",
"True",
",",
"kappa_3",
"=",
"0.3",
",",
"seed",
"=",
"False",
")",
":",
"# todo: add ratio of classes",
"if",
"m",
">",
"2",
":",
"logging",
".",
"warning",
... | Simulates n time-series with l time steps each for the m-dimensional velocity of a dissipative soliton
classification=True:
target 0 means tau<=1/0.3, Dissipative Soliton with Brownian motion (purely noise driven)
target 1 means tau> 1/0.3, Dissipative Soliton with Active Brownian motion (intrinsiv velocit... | [
"Simulates",
"n",
"time",
"-",
"series",
"with",
"l",
"time",
"steps",
"each",
"for",
"the",
"m",
"-",
"dimensional",
"velocity",
"of",
"a",
"dissipative",
"soliton"
] | c72c9c574371cf7dd7d54e00a466792792e5d202 | https://github.com/blue-yonder/tsfresh/blob/c72c9c574371cf7dd7d54e00a466792792e5d202/tsfresh/examples/driftbif_simulation.py#L130-L185 | train |
blue-yonder/tsfresh | tsfresh/utilities/dataframe_functions.py | check_for_nans_in_columns | def check_for_nans_in_columns(df, columns=None):
"""
Helper function to check for ``NaN`` in the data frame and raise a ``ValueError`` if there is one.
:param df: the pandas DataFrame to test for NaNs
:type df: pandas.DataFrame
:param columns: a list of columns to test for NaNs. If left empty, all ... | python | def check_for_nans_in_columns(df, columns=None):
"""
Helper function to check for ``NaN`` in the data frame and raise a ``ValueError`` if there is one.
:param df: the pandas DataFrame to test for NaNs
:type df: pandas.DataFrame
:param columns: a list of columns to test for NaNs. If left empty, all ... | [
"def",
"check_for_nans_in_columns",
"(",
"df",
",",
"columns",
"=",
"None",
")",
":",
"if",
"columns",
"is",
"None",
":",
"columns",
"=",
"df",
".",
"columns",
"if",
"pd",
".",
"isnull",
"(",
"df",
".",
"loc",
"[",
":",
",",
"columns",
"]",
")",
".... | Helper function to check for ``NaN`` in the data frame and raise a ``ValueError`` if there is one.
:param df: the pandas DataFrame to test for NaNs
:type df: pandas.DataFrame
:param columns: a list of columns to test for NaNs. If left empty, all columns of the DataFrame will be tested.
:type columns: l... | [
"Helper",
"function",
"to",
"check",
"for",
"NaN",
"in",
"the",
"data",
"frame",
"and",
"raise",
"a",
"ValueError",
"if",
"there",
"is",
"one",
"."
] | c72c9c574371cf7dd7d54e00a466792792e5d202 | https://github.com/blue-yonder/tsfresh/blob/c72c9c574371cf7dd7d54e00a466792792e5d202/tsfresh/utilities/dataframe_functions.py#L18-L38 | train |
blue-yonder/tsfresh | tsfresh/utilities/dataframe_functions.py | impute | def impute(df_impute):
"""
Columnwise replaces all ``NaNs`` and ``infs`` from the DataFrame `df_impute` with average/extreme values from
the same columns. This is done as follows: Each occurring ``inf`` or ``NaN`` in `df_impute` is replaced by
* ``-inf`` -> ``min``
* ``+inf`` -> ``max``
... | python | def impute(df_impute):
"""
Columnwise replaces all ``NaNs`` and ``infs`` from the DataFrame `df_impute` with average/extreme values from
the same columns. This is done as follows: Each occurring ``inf`` or ``NaN`` in `df_impute` is replaced by
* ``-inf`` -> ``min``
* ``+inf`` -> ``max``
... | [
"def",
"impute",
"(",
"df_impute",
")",
":",
"col_to_max",
",",
"col_to_min",
",",
"col_to_median",
"=",
"get_range_values_per_column",
"(",
"df_impute",
")",
"df_impute",
"=",
"impute_dataframe_range",
"(",
"df_impute",
",",
"col_to_max",
",",
"col_to_min",
",",
... | Columnwise replaces all ``NaNs`` and ``infs`` from the DataFrame `df_impute` with average/extreme values from
the same columns. This is done as follows: Each occurring ``inf`` or ``NaN`` in `df_impute` is replaced by
* ``-inf`` -> ``min``
* ``+inf`` -> ``max``
* ``NaN`` -> ``median``
I... | [
"Columnwise",
"replaces",
"all",
"NaNs",
"and",
"infs",
"from",
"the",
"DataFrame",
"df_impute",
"with",
"average",
"/",
"extreme",
"values",
"from",
"the",
"same",
"columns",
".",
"This",
"is",
"done",
"as",
"follows",
":",
"Each",
"occurring",
"inf",
"or",... | c72c9c574371cf7dd7d54e00a466792792e5d202 | https://github.com/blue-yonder/tsfresh/blob/c72c9c574371cf7dd7d54e00a466792792e5d202/tsfresh/utilities/dataframe_functions.py#L41-L66 | train |
blue-yonder/tsfresh | tsfresh/utilities/dataframe_functions.py | impute_dataframe_zero | def impute_dataframe_zero(df_impute):
"""
Replaces all ``NaNs``, ``-infs`` and ``+infs`` from the DataFrame `df_impute` with 0s.
The `df_impute` will be modified in place. All its columns will be into converted into dtype ``np.float64``.
:param df_impute: DataFrame to impute
:type df_impute: pandas... | python | def impute_dataframe_zero(df_impute):
"""
Replaces all ``NaNs``, ``-infs`` and ``+infs`` from the DataFrame `df_impute` with 0s.
The `df_impute` will be modified in place. All its columns will be into converted into dtype ``np.float64``.
:param df_impute: DataFrame to impute
:type df_impute: pandas... | [
"def",
"impute_dataframe_zero",
"(",
"df_impute",
")",
":",
"df_impute",
".",
"replace",
"(",
"[",
"np",
".",
"PINF",
",",
"np",
".",
"NINF",
"]",
",",
"0",
",",
"inplace",
"=",
"True",
")",
"df_impute",
".",
"fillna",
"(",
"0",
",",
"inplace",
"=",
... | Replaces all ``NaNs``, ``-infs`` and ``+infs`` from the DataFrame `df_impute` with 0s.
The `df_impute` will be modified in place. All its columns will be into converted into dtype ``np.float64``.
:param df_impute: DataFrame to impute
:type df_impute: pandas.DataFrame
:return df_impute: imputed DataFra... | [
"Replaces",
"all",
"NaNs",
"-",
"infs",
"and",
"+",
"infs",
"from",
"the",
"DataFrame",
"df_impute",
"with",
"0s",
".",
"The",
"df_impute",
"will",
"be",
"modified",
"in",
"place",
".",
"All",
"its",
"columns",
"will",
"be",
"into",
"converted",
"into",
... | c72c9c574371cf7dd7d54e00a466792792e5d202 | https://github.com/blue-yonder/tsfresh/blob/c72c9c574371cf7dd7d54e00a466792792e5d202/tsfresh/utilities/dataframe_functions.py#L69-L86 | train |
blue-yonder/tsfresh | tsfresh/utilities/dataframe_functions.py | impute_dataframe_range | def impute_dataframe_range(df_impute, col_to_max, col_to_min, col_to_median):
"""
Columnwise replaces all ``NaNs``, ``-inf`` and ``+inf`` from the DataFrame `df_impute` with average/extreme values
from the provided dictionaries.
This is done as follows: Each occurring ``inf`` or ``NaN`` in `df_impute` ... | python | def impute_dataframe_range(df_impute, col_to_max, col_to_min, col_to_median):
"""
Columnwise replaces all ``NaNs``, ``-inf`` and ``+inf`` from the DataFrame `df_impute` with average/extreme values
from the provided dictionaries.
This is done as follows: Each occurring ``inf`` or ``NaN`` in `df_impute` ... | [
"def",
"impute_dataframe_range",
"(",
"df_impute",
",",
"col_to_max",
",",
"col_to_min",
",",
"col_to_median",
")",
":",
"columns",
"=",
"df_impute",
".",
"columns",
"# Making sure col_to_median, col_to_max and col_to_min have entries for every column",
"if",
"not",
"set",
... | Columnwise replaces all ``NaNs``, ``-inf`` and ``+inf`` from the DataFrame `df_impute` with average/extreme values
from the provided dictionaries.
This is done as follows: Each occurring ``inf`` or ``NaN`` in `df_impute` is replaced by
* ``-inf`` -> by value in col_to_min
* ``+inf`` -> by valu... | [
"Columnwise",
"replaces",
"all",
"NaNs",
"-",
"inf",
"and",
"+",
"inf",
"from",
"the",
"DataFrame",
"df_impute",
"with",
"average",
"/",
"extreme",
"values",
"from",
"the",
"provided",
"dictionaries",
"."
] | c72c9c574371cf7dd7d54e00a466792792e5d202 | https://github.com/blue-yonder/tsfresh/blob/c72c9c574371cf7dd7d54e00a466792792e5d202/tsfresh/utilities/dataframe_functions.py#L89-L147 | train |
blue-yonder/tsfresh | tsfresh/utilities/dataframe_functions.py | get_range_values_per_column | def get_range_values_per_column(df):
"""
Retrieves the finite max, min and mean values per column in the DataFrame `df` and stores them in three
dictionaries. Those dictionaries `col_to_max`, `col_to_min`, `col_to_median` map the columnname to the maximal,
minimal or median value of that column.
If... | python | def get_range_values_per_column(df):
"""
Retrieves the finite max, min and mean values per column in the DataFrame `df` and stores them in three
dictionaries. Those dictionaries `col_to_max`, `col_to_min`, `col_to_median` map the columnname to the maximal,
minimal or median value of that column.
If... | [
"def",
"get_range_values_per_column",
"(",
"df",
")",
":",
"data",
"=",
"df",
".",
"get_values",
"(",
")",
"masked",
"=",
"np",
".",
"ma",
".",
"masked_invalid",
"(",
"data",
")",
"columns",
"=",
"df",
".",
"columns",
"is_col_non_finite",
"=",
"masked",
... | Retrieves the finite max, min and mean values per column in the DataFrame `df` and stores them in three
dictionaries. Those dictionaries `col_to_max`, `col_to_min`, `col_to_median` map the columnname to the maximal,
minimal or median value of that column.
If a column does not contain any finite values at a... | [
"Retrieves",
"the",
"finite",
"max",
"min",
"and",
"mean",
"values",
"per",
"column",
"in",
"the",
"DataFrame",
"df",
"and",
"stores",
"them",
"in",
"three",
"dictionaries",
".",
"Those",
"dictionaries",
"col_to_max",
"col_to_min",
"col_to_median",
"map",
"the",... | c72c9c574371cf7dd7d54e00a466792792e5d202 | https://github.com/blue-yonder/tsfresh/blob/c72c9c574371cf7dd7d54e00a466792792e5d202/tsfresh/utilities/dataframe_functions.py#L150-L183 | train |
blue-yonder/tsfresh | tsfresh/utilities/dataframe_functions.py | restrict_input_to_index | def restrict_input_to_index(df_or_dict, column_id, index):
"""
Restrict df_or_dict to those ids contained in index.
:param df_or_dict: a pandas DataFrame or a dictionary.
:type df_or_dict: pandas.DataFrame or dict
:param column_id: it must be present in the pandas DataFrame or in all DataFrames in ... | python | def restrict_input_to_index(df_or_dict, column_id, index):
"""
Restrict df_or_dict to those ids contained in index.
:param df_or_dict: a pandas DataFrame or a dictionary.
:type df_or_dict: pandas.DataFrame or dict
:param column_id: it must be present in the pandas DataFrame or in all DataFrames in ... | [
"def",
"restrict_input_to_index",
"(",
"df_or_dict",
",",
"column_id",
",",
"index",
")",
":",
"if",
"isinstance",
"(",
"df_or_dict",
",",
"pd",
".",
"DataFrame",
")",
":",
"df_or_dict_restricted",
"=",
"df_or_dict",
"[",
"df_or_dict",
"[",
"column_id",
"]",
"... | Restrict df_or_dict to those ids contained in index.
:param df_or_dict: a pandas DataFrame or a dictionary.
:type df_or_dict: pandas.DataFrame or dict
:param column_id: it must be present in the pandas DataFrame or in all DataFrames in the dictionary.
It is not allowed to have NaN values in this co... | [
"Restrict",
"df_or_dict",
"to",
"those",
"ids",
"contained",
"in",
"index",
"."
] | c72c9c574371cf7dd7d54e00a466792792e5d202 | https://github.com/blue-yonder/tsfresh/blob/c72c9c574371cf7dd7d54e00a466792792e5d202/tsfresh/utilities/dataframe_functions.py#L186-L210 | train |
blue-yonder/tsfresh | tsfresh/utilities/dataframe_functions.py | get_ids | def get_ids(df_or_dict, column_id):
"""
Aggregates all ids in column_id from the time series container `
:param df_or_dict: a pandas DataFrame or a dictionary.
:type df_or_dict: pandas.DataFrame or dict
:param column_id: it must be present in the pandas DataFrame or in all DataFrames in the diction... | python | def get_ids(df_or_dict, column_id):
"""
Aggregates all ids in column_id from the time series container `
:param df_or_dict: a pandas DataFrame or a dictionary.
:type df_or_dict: pandas.DataFrame or dict
:param column_id: it must be present in the pandas DataFrame or in all DataFrames in the diction... | [
"def",
"get_ids",
"(",
"df_or_dict",
",",
"column_id",
")",
":",
"if",
"isinstance",
"(",
"df_or_dict",
",",
"pd",
".",
"DataFrame",
")",
":",
"return",
"set",
"(",
"df_or_dict",
"[",
"column_id",
"]",
")",
"elif",
"isinstance",
"(",
"df_or_dict",
",",
"... | Aggregates all ids in column_id from the time series container `
:param df_or_dict: a pandas DataFrame or a dictionary.
:type df_or_dict: pandas.DataFrame or dict
:param column_id: it must be present in the pandas DataFrame or in all DataFrames in the dictionary.
It is not allowed to have NaN value... | [
"Aggregates",
"all",
"ids",
"in",
"column_id",
"from",
"the",
"time",
"series",
"container"
] | c72c9c574371cf7dd7d54e00a466792792e5d202 | https://github.com/blue-yonder/tsfresh/blob/c72c9c574371cf7dd7d54e00a466792792e5d202/tsfresh/utilities/dataframe_functions.py#L213-L232 | train |
blue-yonder/tsfresh | tsfresh/utilities/dataframe_functions.py | _normalize_input_to_internal_representation | def _normalize_input_to_internal_representation(timeseries_container, column_id, column_sort, column_kind, column_value):
"""
Try to transform any given input to the internal representation of time series, which is a flat DataFrame
(the first format from see :ref:`data-formats-label`).
This function ca... | python | def _normalize_input_to_internal_representation(timeseries_container, column_id, column_sort, column_kind, column_value):
"""
Try to transform any given input to the internal representation of time series, which is a flat DataFrame
(the first format from see :ref:`data-formats-label`).
This function ca... | [
"def",
"_normalize_input_to_internal_representation",
"(",
"timeseries_container",
",",
"column_id",
",",
"column_sort",
",",
"column_kind",
",",
"column_value",
")",
":",
"# Also make it possible to have a dict as an input",
"if",
"isinstance",
"(",
"timeseries_container",
","... | Try to transform any given input to the internal representation of time series, which is a flat DataFrame
(the first format from see :ref:`data-formats-label`).
This function can transform pandas DataFrames in different formats or dictionaries into the internal format
that we use. It should not be called b... | [
"Try",
"to",
"transform",
"any",
"given",
"input",
"to",
"the",
"internal",
"representation",
"of",
"time",
"series",
"which",
"is",
"a",
"flat",
"DataFrame",
"(",
"the",
"first",
"format",
"from",
"see",
":",
"ref",
":",
"data",
"-",
"formats",
"-",
"la... | c72c9c574371cf7dd7d54e00a466792792e5d202 | https://github.com/blue-yonder/tsfresh/blob/c72c9c574371cf7dd7d54e00a466792792e5d202/tsfresh/utilities/dataframe_functions.py#L237-L351 | train |
blue-yonder/tsfresh | tsfresh/utilities/dataframe_functions.py | roll_time_series | def roll_time_series(df_or_dict, column_id, column_sort, column_kind, rolling_direction, max_timeshift=None):
"""
This method creates sub windows of the time series. It rolls the (sorted) data frames for each kind and each id
separately in the "time" domain (which is represented by the sort order of the sor... | python | def roll_time_series(df_or_dict, column_id, column_sort, column_kind, rolling_direction, max_timeshift=None):
"""
This method creates sub windows of the time series. It rolls the (sorted) data frames for each kind and each id
separately in the "time" domain (which is represented by the sort order of the sor... | [
"def",
"roll_time_series",
"(",
"df_or_dict",
",",
"column_id",
",",
"column_sort",
",",
"column_kind",
",",
"rolling_direction",
",",
"max_timeshift",
"=",
"None",
")",
":",
"if",
"rolling_direction",
"==",
"0",
":",
"raise",
"ValueError",
"(",
"\"Rolling directi... | This method creates sub windows of the time series. It rolls the (sorted) data frames for each kind and each id
separately in the "time" domain (which is represented by the sort order of the sort column given by `column_sort`).
For each rolling step, a new id is created by the scheme "id={id}, shift={shift}", ... | [
"This",
"method",
"creates",
"sub",
"windows",
"of",
"the",
"time",
"series",
".",
"It",
"rolls",
"the",
"(",
"sorted",
")",
"data",
"frames",
"for",
"each",
"kind",
"and",
"each",
"id",
"separately",
"in",
"the",
"time",
"domain",
"(",
"which",
"is",
... | c72c9c574371cf7dd7d54e00a466792792e5d202 | https://github.com/blue-yonder/tsfresh/blob/c72c9c574371cf7dd7d54e00a466792792e5d202/tsfresh/utilities/dataframe_functions.py#L354-L471 | train |
blue-yonder/tsfresh | tsfresh/utilities/dataframe_functions.py | make_forecasting_frame | def make_forecasting_frame(x, kind, max_timeshift, rolling_direction):
"""
Takes a singular time series x and constructs a DataFrame df and target vector y that can be used for a time series
forecasting task.
The returned df will contain, for every time stamp in x, the last max_timeshift data points as... | python | def make_forecasting_frame(x, kind, max_timeshift, rolling_direction):
"""
Takes a singular time series x and constructs a DataFrame df and target vector y that can be used for a time series
forecasting task.
The returned df will contain, for every time stamp in x, the last max_timeshift data points as... | [
"def",
"make_forecasting_frame",
"(",
"x",
",",
"kind",
",",
"max_timeshift",
",",
"rolling_direction",
")",
":",
"n",
"=",
"len",
"(",
"x",
")",
"if",
"isinstance",
"(",
"x",
",",
"pd",
".",
"Series",
")",
":",
"t",
"=",
"x",
".",
"index",
"else",
... | Takes a singular time series x and constructs a DataFrame df and target vector y that can be used for a time series
forecasting task.
The returned df will contain, for every time stamp in x, the last max_timeshift data points as a new
time series, such can be used to fit a time series forecasting model.
... | [
"Takes",
"a",
"singular",
"time",
"series",
"x",
"and",
"constructs",
"a",
"DataFrame",
"df",
"and",
"target",
"vector",
"y",
"that",
"can",
"be",
"used",
"for",
"a",
"time",
"series",
"forecasting",
"task",
"."
] | c72c9c574371cf7dd7d54e00a466792792e5d202 | https://github.com/blue-yonder/tsfresh/blob/c72c9c574371cf7dd7d54e00a466792792e5d202/tsfresh/utilities/dataframe_functions.py#L474-L533 | train |
blue-yonder/tsfresh | tsfresh/feature_selection/selection.py | select_features | def select_features(X, y, test_for_binary_target_binary_feature=defaults.TEST_FOR_BINARY_TARGET_BINARY_FEATURE,
test_for_binary_target_real_feature=defaults.TEST_FOR_BINARY_TARGET_REAL_FEATURE,
test_for_real_target_binary_feature=defaults.TEST_FOR_REAL_TARGET_BINARY_FEATURE,
... | python | def select_features(X, y, test_for_binary_target_binary_feature=defaults.TEST_FOR_BINARY_TARGET_BINARY_FEATURE,
test_for_binary_target_real_feature=defaults.TEST_FOR_BINARY_TARGET_REAL_FEATURE,
test_for_real_target_binary_feature=defaults.TEST_FOR_REAL_TARGET_BINARY_FEATURE,
... | [
"def",
"select_features",
"(",
"X",
",",
"y",
",",
"test_for_binary_target_binary_feature",
"=",
"defaults",
".",
"TEST_FOR_BINARY_TARGET_BINARY_FEATURE",
",",
"test_for_binary_target_real_feature",
"=",
"defaults",
".",
"TEST_FOR_BINARY_TARGET_REAL_FEATURE",
",",
"test_for_rea... | Check the significance of all features (columns) of feature matrix X and return a possibly reduced feature matrix
only containing relevant features.
The feature matrix must be a pandas.DataFrame in the format:
+-------+-----------+-----------+-----+-----------+
| index | feature_1 | feature_2 ... | [
"Check",
"the",
"significance",
"of",
"all",
"features",
"(",
"columns",
")",
"of",
"feature",
"matrix",
"X",
"and",
"return",
"a",
"possibly",
"reduced",
"feature",
"matrix",
"only",
"containing",
"relevant",
"features",
"."
] | c72c9c574371cf7dd7d54e00a466792792e5d202 | https://github.com/blue-yonder/tsfresh/blob/c72c9c574371cf7dd7d54e00a466792792e5d202/tsfresh/feature_selection/selection.py#L22-L153 | train |
erdewit/ib_insync | ib_insync/ib.py | IB.connect | def connect(
self, host: str = '127.0.0.1', port: int = 7497,
clientId: int = 1, timeout: float = 2):
"""
Connect to a running TWS or IB gateway application.
After the connection is made the client is fully synchronized
and ready to serve requests.
This m... | python | def connect(
self, host: str = '127.0.0.1', port: int = 7497,
clientId: int = 1, timeout: float = 2):
"""
Connect to a running TWS or IB gateway application.
After the connection is made the client is fully synchronized
and ready to serve requests.
This m... | [
"def",
"connect",
"(",
"self",
",",
"host",
":",
"str",
"=",
"'127.0.0.1'",
",",
"port",
":",
"int",
"=",
"7497",
",",
"clientId",
":",
"int",
"=",
"1",
",",
"timeout",
":",
"float",
"=",
"2",
")",
":",
"return",
"self",
".",
"_run",
"(",
"self",... | Connect to a running TWS or IB gateway application.
After the connection is made the client is fully synchronized
and ready to serve requests.
This method is blocking.
Args:
host: Host name or IP address.
port: Port number.
clientId: ID number to use... | [
"Connect",
"to",
"a",
"running",
"TWS",
"or",
"IB",
"gateway",
"application",
".",
"After",
"the",
"connection",
"is",
"made",
"the",
"client",
"is",
"fully",
"synchronized",
"and",
"ready",
"to",
"serve",
"requests",
"."
] | d0646a482590f5cb7bfddbd1f0870f8c4bc1df80 | https://github.com/erdewit/ib_insync/blob/d0646a482590f5cb7bfddbd1f0870f8c4bc1df80/ib_insync/ib.py#L208-L228 | train |
erdewit/ib_insync | ib_insync/ib.py | IB.disconnect | def disconnect(self):
"""
Disconnect from a TWS or IB gateway application.
This will clear all session state.
"""
if not self.client.isConnected():
return
stats = self.client.connectionStats()
self._logger.info(
f'Disconnecting from {self.c... | python | def disconnect(self):
"""
Disconnect from a TWS or IB gateway application.
This will clear all session state.
"""
if not self.client.isConnected():
return
stats = self.client.connectionStats()
self._logger.info(
f'Disconnecting from {self.c... | [
"def",
"disconnect",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"client",
".",
"isConnected",
"(",
")",
":",
"return",
"stats",
"=",
"self",
".",
"client",
".",
"connectionStats",
"(",
")",
"self",
".",
"_logger",
".",
"info",
"(",
"f'Disconnecti... | Disconnect from a TWS or IB gateway application.
This will clear all session state. | [
"Disconnect",
"from",
"a",
"TWS",
"or",
"IB",
"gateway",
"application",
".",
"This",
"will",
"clear",
"all",
"session",
"state",
"."
] | d0646a482590f5cb7bfddbd1f0870f8c4bc1df80 | https://github.com/erdewit/ib_insync/blob/d0646a482590f5cb7bfddbd1f0870f8c4bc1df80/ib_insync/ib.py#L230-L245 | train |
erdewit/ib_insync | ib_insync/ib.py | IB.waitOnUpdate | def waitOnUpdate(self, timeout: float = 0) -> bool:
"""
Wait on any new update to arrive from the network.
Args:
timeout: Maximum time in seconds to wait.
If 0 then no timeout is used.
.. note::
A loop with ``waitOnUpdate`` should not be used to ... | python | def waitOnUpdate(self, timeout: float = 0) -> bool:
"""
Wait on any new update to arrive from the network.
Args:
timeout: Maximum time in seconds to wait.
If 0 then no timeout is used.
.. note::
A loop with ``waitOnUpdate`` should not be used to ... | [
"def",
"waitOnUpdate",
"(",
"self",
",",
"timeout",
":",
"float",
"=",
"0",
")",
"->",
"bool",
":",
"if",
"timeout",
":",
"with",
"suppress",
"(",
"asyncio",
".",
"TimeoutError",
")",
":",
"util",
".",
"run",
"(",
"asyncio",
".",
"wait_for",
"(",
"se... | Wait on any new update to arrive from the network.
Args:
timeout: Maximum time in seconds to wait.
If 0 then no timeout is used.
.. note::
A loop with ``waitOnUpdate`` should not be used to harvest
tick data from tickers, since some ticks can go miss... | [
"Wait",
"on",
"any",
"new",
"update",
"to",
"arrive",
"from",
"the",
"network",
"."
] | d0646a482590f5cb7bfddbd1f0870f8c4bc1df80 | https://github.com/erdewit/ib_insync/blob/d0646a482590f5cb7bfddbd1f0870f8c4bc1df80/ib_insync/ib.py#L263-L283 | train |
erdewit/ib_insync | ib_insync/ib.py | IB.loopUntil | def loopUntil(
self, condition=None, timeout: float = 0) -> Iterator[object]:
"""
Iterate until condition is met, with optional timeout in seconds.
The yielded value is that of the condition or False when timed out.
Args:
condition: Predicate function that is tes... | python | def loopUntil(
self, condition=None, timeout: float = 0) -> Iterator[object]:
"""
Iterate until condition is met, with optional timeout in seconds.
The yielded value is that of the condition or False when timed out.
Args:
condition: Predicate function that is tes... | [
"def",
"loopUntil",
"(",
"self",
",",
"condition",
"=",
"None",
",",
"timeout",
":",
"float",
"=",
"0",
")",
"->",
"Iterator",
"[",
"object",
"]",
":",
"endTime",
"=",
"time",
".",
"time",
"(",
")",
"+",
"timeout",
"while",
"True",
":",
"test",
"="... | Iterate until condition is met, with optional timeout in seconds.
The yielded value is that of the condition or False when timed out.
Args:
condition: Predicate function that is tested after every network
update.
timeout: Maximum time in seconds to wait.
... | [
"Iterate",
"until",
"condition",
"is",
"met",
"with",
"optional",
"timeout",
"in",
"seconds",
".",
"The",
"yielded",
"value",
"is",
"that",
"of",
"the",
"condition",
"or",
"False",
"when",
"timed",
"out",
"."
] | d0646a482590f5cb7bfddbd1f0870f8c4bc1df80 | https://github.com/erdewit/ib_insync/blob/d0646a482590f5cb7bfddbd1f0870f8c4bc1df80/ib_insync/ib.py#L285-L308 | train |
erdewit/ib_insync | ib_insync/ib.py | IB.accountValues | def accountValues(self, account: str = '') -> List[AccountValue]:
"""
List of account values for the given account,
or of all accounts if account is left blank.
Args:
account: If specified, filter for this account name.
"""
if account:
return [v f... | python | def accountValues(self, account: str = '') -> List[AccountValue]:
"""
List of account values for the given account,
or of all accounts if account is left blank.
Args:
account: If specified, filter for this account name.
"""
if account:
return [v f... | [
"def",
"accountValues",
"(",
"self",
",",
"account",
":",
"str",
"=",
"''",
")",
"->",
"List",
"[",
"AccountValue",
"]",
":",
"if",
"account",
":",
"return",
"[",
"v",
"for",
"v",
"in",
"self",
".",
"wrapper",
".",
"accountValues",
".",
"values",
"("... | List of account values for the given account,
or of all accounts if account is left blank.
Args:
account: If specified, filter for this account name. | [
"List",
"of",
"account",
"values",
"for",
"the",
"given",
"account",
"or",
"of",
"all",
"accounts",
"if",
"account",
"is",
"left",
"blank",
"."
] | d0646a482590f5cb7bfddbd1f0870f8c4bc1df80 | https://github.com/erdewit/ib_insync/blob/d0646a482590f5cb7bfddbd1f0870f8c4bc1df80/ib_insync/ib.py#L329-L341 | train |
erdewit/ib_insync | ib_insync/ib.py | IB.accountSummary | def accountSummary(self, account: str = '') -> List[AccountValue]:
"""
List of account values for the given account,
or of all accounts if account is left blank.
This method is blocking on first run, non-blocking after that.
Args:
account: If specified, filter for t... | python | def accountSummary(self, account: str = '') -> List[AccountValue]:
"""
List of account values for the given account,
or of all accounts if account is left blank.
This method is blocking on first run, non-blocking after that.
Args:
account: If specified, filter for t... | [
"def",
"accountSummary",
"(",
"self",
",",
"account",
":",
"str",
"=",
"''",
")",
"->",
"List",
"[",
"AccountValue",
"]",
":",
"if",
"not",
"self",
".",
"wrapper",
".",
"acctSummary",
":",
"# loaded on demand since it takes ca. 250 ms",
"self",
".",
"reqAccoun... | List of account values for the given account,
or of all accounts if account is left blank.
This method is blocking on first run, non-blocking after that.
Args:
account: If specified, filter for this account name. | [
"List",
"of",
"account",
"values",
"for",
"the",
"given",
"account",
"or",
"of",
"all",
"accounts",
"if",
"account",
"is",
"left",
"blank",
"."
] | d0646a482590f5cb7bfddbd1f0870f8c4bc1df80 | https://github.com/erdewit/ib_insync/blob/d0646a482590f5cb7bfddbd1f0870f8c4bc1df80/ib_insync/ib.py#L343-L360 | train |
erdewit/ib_insync | ib_insync/ib.py | IB.portfolio | def portfolio(self) -> List[PortfolioItem]:
"""
List of portfolio items of the default account.
"""
account = self.wrapper.accounts[0]
return [v for v in self.wrapper.portfolio[account].values()] | python | def portfolio(self) -> List[PortfolioItem]:
"""
List of portfolio items of the default account.
"""
account = self.wrapper.accounts[0]
return [v for v in self.wrapper.portfolio[account].values()] | [
"def",
"portfolio",
"(",
"self",
")",
"->",
"List",
"[",
"PortfolioItem",
"]",
":",
"account",
"=",
"self",
".",
"wrapper",
".",
"accounts",
"[",
"0",
"]",
"return",
"[",
"v",
"for",
"v",
"in",
"self",
".",
"wrapper",
".",
"portfolio",
"[",
"account"... | List of portfolio items of the default account. | [
"List",
"of",
"portfolio",
"items",
"of",
"the",
"default",
"account",
"."
] | d0646a482590f5cb7bfddbd1f0870f8c4bc1df80 | https://github.com/erdewit/ib_insync/blob/d0646a482590f5cb7bfddbd1f0870f8c4bc1df80/ib_insync/ib.py#L362-L367 | train |
erdewit/ib_insync | ib_insync/ib.py | IB.positions | def positions(self, account: str = '') -> List[Position]:
"""
List of positions for the given account,
or of all accounts if account is left blank.
Args:
account: If specified, filter for this account name.
"""
if account:
return list(self.wrapper... | python | def positions(self, account: str = '') -> List[Position]:
"""
List of positions for the given account,
or of all accounts if account is left blank.
Args:
account: If specified, filter for this account name.
"""
if account:
return list(self.wrapper... | [
"def",
"positions",
"(",
"self",
",",
"account",
":",
"str",
"=",
"''",
")",
"->",
"List",
"[",
"Position",
"]",
":",
"if",
"account",
":",
"return",
"list",
"(",
"self",
".",
"wrapper",
".",
"positions",
"[",
"account",
"]",
".",
"values",
"(",
")... | List of positions for the given account,
or of all accounts if account is left blank.
Args:
account: If specified, filter for this account name. | [
"List",
"of",
"positions",
"for",
"the",
"given",
"account",
"or",
"of",
"all",
"accounts",
"if",
"account",
"is",
"left",
"blank",
"."
] | d0646a482590f5cb7bfddbd1f0870f8c4bc1df80 | https://github.com/erdewit/ib_insync/blob/d0646a482590f5cb7bfddbd1f0870f8c4bc1df80/ib_insync/ib.py#L369-L381 | train |
erdewit/ib_insync | ib_insync/ib.py | IB.pnl | def pnl(self, account='', modelCode='') -> List[PnL]:
"""
List of subscribed :class:`.PnL` objects (profit and loss),
optionally filtered by account and/or modelCode.
The :class:`.PnL` objects are kept live updated.
Args:
account: If specified, filter for this accou... | python | def pnl(self, account='', modelCode='') -> List[PnL]:
"""
List of subscribed :class:`.PnL` objects (profit and loss),
optionally filtered by account and/or modelCode.
The :class:`.PnL` objects are kept live updated.
Args:
account: If specified, filter for this accou... | [
"def",
"pnl",
"(",
"self",
",",
"account",
"=",
"''",
",",
"modelCode",
"=",
"''",
")",
"->",
"List",
"[",
"PnL",
"]",
":",
"return",
"[",
"v",
"for",
"v",
"in",
"self",
".",
"wrapper",
".",
"pnls",
".",
"values",
"(",
")",
"if",
"(",
"not",
... | List of subscribed :class:`.PnL` objects (profit and loss),
optionally filtered by account and/or modelCode.
The :class:`.PnL` objects are kept live updated.
Args:
account: If specified, filter for this account name.
modelCode: If specified, filter for this account mode... | [
"List",
"of",
"subscribed",
":",
"class",
":",
".",
"PnL",
"objects",
"(",
"profit",
"and",
"loss",
")",
"optionally",
"filtered",
"by",
"account",
"and",
"/",
"or",
"modelCode",
"."
] | d0646a482590f5cb7bfddbd1f0870f8c4bc1df80 | https://github.com/erdewit/ib_insync/blob/d0646a482590f5cb7bfddbd1f0870f8c4bc1df80/ib_insync/ib.py#L383-L396 | train |
erdewit/ib_insync | ib_insync/ib.py | IB.pnlSingle | def pnlSingle(
self, account: str = '', modelCode: str = '',
conId: int = 0) -> List[PnLSingle]:
"""
List of subscribed :class:`.PnLSingle` objects (profit and loss for
single positions).
The :class:`.PnLSingle` objects are kept live updated.
Args:
... | python | def pnlSingle(
self, account: str = '', modelCode: str = '',
conId: int = 0) -> List[PnLSingle]:
"""
List of subscribed :class:`.PnLSingle` objects (profit and loss for
single positions).
The :class:`.PnLSingle` objects are kept live updated.
Args:
... | [
"def",
"pnlSingle",
"(",
"self",
",",
"account",
":",
"str",
"=",
"''",
",",
"modelCode",
":",
"str",
"=",
"''",
",",
"conId",
":",
"int",
"=",
"0",
")",
"->",
"List",
"[",
"PnLSingle",
"]",
":",
"return",
"[",
"v",
"for",
"v",
"in",
"self",
".... | List of subscribed :class:`.PnLSingle` objects (profit and loss for
single positions).
The :class:`.PnLSingle` objects are kept live updated.
Args:
account: If specified, filter for this account name.
modelCode: If specified, filter for this account model.
c... | [
"List",
"of",
"subscribed",
":",
"class",
":",
".",
"PnLSingle",
"objects",
"(",
"profit",
"and",
"loss",
"for",
"single",
"positions",
")",
"."
] | d0646a482590f5cb7bfddbd1f0870f8c4bc1df80 | https://github.com/erdewit/ib_insync/blob/d0646a482590f5cb7bfddbd1f0870f8c4bc1df80/ib_insync/ib.py#L398-L415 | train |
erdewit/ib_insync | ib_insync/ib.py | IB.openTrades | def openTrades(self) -> List[Trade]:
"""
List of all open order trades.
"""
return [v for v in self.wrapper.trades.values()
if v.orderStatus.status not in OrderStatus.DoneStates] | python | def openTrades(self) -> List[Trade]:
"""
List of all open order trades.
"""
return [v for v in self.wrapper.trades.values()
if v.orderStatus.status not in OrderStatus.DoneStates] | [
"def",
"openTrades",
"(",
"self",
")",
"->",
"List",
"[",
"Trade",
"]",
":",
"return",
"[",
"v",
"for",
"v",
"in",
"self",
".",
"wrapper",
".",
"trades",
".",
"values",
"(",
")",
"if",
"v",
".",
"orderStatus",
".",
"status",
"not",
"in",
"OrderStat... | List of all open order trades. | [
"List",
"of",
"all",
"open",
"order",
"trades",
"."
] | d0646a482590f5cb7bfddbd1f0870f8c4bc1df80 | https://github.com/erdewit/ib_insync/blob/d0646a482590f5cb7bfddbd1f0870f8c4bc1df80/ib_insync/ib.py#L423-L428 | train |
erdewit/ib_insync | ib_insync/ib.py | IB.orders | def orders(self) -> List[Order]:
"""
List of all orders from this session.
"""
return list(
trade.order for trade in self.wrapper.trades.values()) | python | def orders(self) -> List[Order]:
"""
List of all orders from this session.
"""
return list(
trade.order for trade in self.wrapper.trades.values()) | [
"def",
"orders",
"(",
"self",
")",
"->",
"List",
"[",
"Order",
"]",
":",
"return",
"list",
"(",
"trade",
".",
"order",
"for",
"trade",
"in",
"self",
".",
"wrapper",
".",
"trades",
".",
"values",
"(",
")",
")"
] | List of all orders from this session. | [
"List",
"of",
"all",
"orders",
"from",
"this",
"session",
"."
] | d0646a482590f5cb7bfddbd1f0870f8c4bc1df80 | https://github.com/erdewit/ib_insync/blob/d0646a482590f5cb7bfddbd1f0870f8c4bc1df80/ib_insync/ib.py#L430-L435 | train |
erdewit/ib_insync | ib_insync/ib.py | IB.openOrders | def openOrders(self) -> List[Order]:
"""
List of all open orders.
"""
return [trade.order for trade in self.wrapper.trades.values()
if trade.orderStatus.status not in OrderStatus.DoneStates] | python | def openOrders(self) -> List[Order]:
"""
List of all open orders.
"""
return [trade.order for trade in self.wrapper.trades.values()
if trade.orderStatus.status not in OrderStatus.DoneStates] | [
"def",
"openOrders",
"(",
"self",
")",
"->",
"List",
"[",
"Order",
"]",
":",
"return",
"[",
"trade",
".",
"order",
"for",
"trade",
"in",
"self",
".",
"wrapper",
".",
"trades",
".",
"values",
"(",
")",
"if",
"trade",
".",
"orderStatus",
".",
"status",... | List of all open orders. | [
"List",
"of",
"all",
"open",
"orders",
"."
] | d0646a482590f5cb7bfddbd1f0870f8c4bc1df80 | https://github.com/erdewit/ib_insync/blob/d0646a482590f5cb7bfddbd1f0870f8c4bc1df80/ib_insync/ib.py#L437-L442 | train |
erdewit/ib_insync | ib_insync/ib.py | IB.executions | def executions(self) -> List[Execution]:
"""
List of all executions from this session.
"""
return list(fill.execution for fill in self.wrapper.fills.values()) | python | def executions(self) -> List[Execution]:
"""
List of all executions from this session.
"""
return list(fill.execution for fill in self.wrapper.fills.values()) | [
"def",
"executions",
"(",
"self",
")",
"->",
"List",
"[",
"Execution",
"]",
":",
"return",
"list",
"(",
"fill",
".",
"execution",
"for",
"fill",
"in",
"self",
".",
"wrapper",
".",
"fills",
".",
"values",
"(",
")",
")"
] | List of all executions from this session. | [
"List",
"of",
"all",
"executions",
"from",
"this",
"session",
"."
] | d0646a482590f5cb7bfddbd1f0870f8c4bc1df80 | https://github.com/erdewit/ib_insync/blob/d0646a482590f5cb7bfddbd1f0870f8c4bc1df80/ib_insync/ib.py#L450-L454 | train |
erdewit/ib_insync | ib_insync/ib.py | IB.ticker | def ticker(self, contract: Contract) -> Ticker:
"""
Get ticker of the given contract. It must have been requested before
with reqMktData with the same contract object. The ticker may not be
ready yet if called directly after :meth:`.reqMktData`.
Args:
contract: Contr... | python | def ticker(self, contract: Contract) -> Ticker:
"""
Get ticker of the given contract. It must have been requested before
with reqMktData with the same contract object. The ticker may not be
ready yet if called directly after :meth:`.reqMktData`.
Args:
contract: Contr... | [
"def",
"ticker",
"(",
"self",
",",
"contract",
":",
"Contract",
")",
"->",
"Ticker",
":",
"return",
"self",
".",
"wrapper",
".",
"tickers",
".",
"get",
"(",
"id",
"(",
"contract",
")",
")"
] | Get ticker of the given contract. It must have been requested before
with reqMktData with the same contract object. The ticker may not be
ready yet if called directly after :meth:`.reqMktData`.
Args:
contract: Contract to get ticker for. | [
"Get",
"ticker",
"of",
"the",
"given",
"contract",
".",
"It",
"must",
"have",
"been",
"requested",
"before",
"with",
"reqMktData",
"with",
"the",
"same",
"contract",
"object",
".",
"The",
"ticker",
"may",
"not",
"be",
"ready",
"yet",
"if",
"called",
"direc... | d0646a482590f5cb7bfddbd1f0870f8c4bc1df80 | https://github.com/erdewit/ib_insync/blob/d0646a482590f5cb7bfddbd1f0870f8c4bc1df80/ib_insync/ib.py#L456-L465 | train |
erdewit/ib_insync | ib_insync/ib.py | IB.reqTickers | def reqTickers(
self, *contracts: List[Contract],
regulatorySnapshot: bool = False) -> List[Ticker]:
"""
Request and return a list of snapshot tickers.
The list is returned when all tickers are ready.
This method is blocking.
Args:
contracts:... | python | def reqTickers(
self, *contracts: List[Contract],
regulatorySnapshot: bool = False) -> List[Ticker]:
"""
Request and return a list of snapshot tickers.
The list is returned when all tickers are ready.
This method is blocking.
Args:
contracts:... | [
"def",
"reqTickers",
"(",
"self",
",",
"*",
"contracts",
":",
"List",
"[",
"Contract",
"]",
",",
"regulatorySnapshot",
":",
"bool",
"=",
"False",
")",
"->",
"List",
"[",
"Ticker",
"]",
":",
"return",
"self",
".",
"_run",
"(",
"self",
".",
"reqTickersAs... | Request and return a list of snapshot tickers.
The list is returned when all tickers are ready.
This method is blocking.
Args:
contracts: Contracts to get tickers for.
regulatorySnapshot: Request NBBO snapshots (may incur a fee). | [
"Request",
"and",
"return",
"a",
"list",
"of",
"snapshot",
"tickers",
".",
"The",
"list",
"is",
"returned",
"when",
"all",
"tickers",
"are",
"ready",
"."
] | d0646a482590f5cb7bfddbd1f0870f8c4bc1df80 | https://github.com/erdewit/ib_insync/blob/d0646a482590f5cb7bfddbd1f0870f8c4bc1df80/ib_insync/ib.py#L499-L514 | train |
erdewit/ib_insync | ib_insync/ib.py | IB.qualifyContracts | def qualifyContracts(self, *contracts: List[Contract]) -> List[Contract]:
"""
Fully qualify the given contracts in-place. This will fill in
the missing fields in the contract, especially the conId.
Returns a list of contracts that have been successfully qualified.
This method i... | python | def qualifyContracts(self, *contracts: List[Contract]) -> List[Contract]:
"""
Fully qualify the given contracts in-place. This will fill in
the missing fields in the contract, especially the conId.
Returns a list of contracts that have been successfully qualified.
This method i... | [
"def",
"qualifyContracts",
"(",
"self",
",",
"*",
"contracts",
":",
"List",
"[",
"Contract",
"]",
")",
"->",
"List",
"[",
"Contract",
"]",
":",
"return",
"self",
".",
"_run",
"(",
"self",
".",
"qualifyContractsAsync",
"(",
"*",
"contracts",
")",
")"
] | Fully qualify the given contracts in-place. This will fill in
the missing fields in the contract, especially the conId.
Returns a list of contracts that have been successfully qualified.
This method is blocking.
Args:
contracts: Contracts to qualify. | [
"Fully",
"qualify",
"the",
"given",
"contracts",
"in",
"-",
"place",
".",
"This",
"will",
"fill",
"in",
"the",
"missing",
"fields",
"in",
"the",
"contract",
"especially",
"the",
"conId",
"."
] | d0646a482590f5cb7bfddbd1f0870f8c4bc1df80 | https://github.com/erdewit/ib_insync/blob/d0646a482590f5cb7bfddbd1f0870f8c4bc1df80/ib_insync/ib.py#L516-L528 | train |
erdewit/ib_insync | ib_insync/ib.py | IB.bracketOrder | def bracketOrder(
self, action: str, quantity: float,
limitPrice: float, takeProfitPrice: float,
stopLossPrice: float, **kwargs) -> BracketOrder:
"""
Create a limit order that is bracketed by a take-profit order and
a stop-loss order. Submit the bracket like:
... | python | def bracketOrder(
self, action: str, quantity: float,
limitPrice: float, takeProfitPrice: float,
stopLossPrice: float, **kwargs) -> BracketOrder:
"""
Create a limit order that is bracketed by a take-profit order and
a stop-loss order. Submit the bracket like:
... | [
"def",
"bracketOrder",
"(",
"self",
",",
"action",
":",
"str",
",",
"quantity",
":",
"float",
",",
"limitPrice",
":",
"float",
",",
"takeProfitPrice",
":",
"float",
",",
"stopLossPrice",
":",
"float",
",",
"*",
"*",
"kwargs",
")",
"->",
"BracketOrder",
"... | Create a limit order that is bracketed by a take-profit order and
a stop-loss order. Submit the bracket like:
.. code-block:: python
for o in bracket:
ib.placeOrder(contract, o)
https://interactivebrokers.github.io/tws-api/bracket_order.html
Args:
... | [
"Create",
"a",
"limit",
"order",
"that",
"is",
"bracketed",
"by",
"a",
"take",
"-",
"profit",
"order",
"and",
"a",
"stop",
"-",
"loss",
"order",
".",
"Submit",
"the",
"bracket",
"like",
":"
] | d0646a482590f5cb7bfddbd1f0870f8c4bc1df80 | https://github.com/erdewit/ib_insync/blob/d0646a482590f5cb7bfddbd1f0870f8c4bc1df80/ib_insync/ib.py#L530-L571 | train |
erdewit/ib_insync | ib_insync/ib.py | IB.oneCancelsAll | def oneCancelsAll(
orders: List[Order], ocaGroup: str, ocaType: int) -> List[Order]:
"""
Place the trades in the same One Cancels All (OCA) group.
https://interactivebrokers.github.io/tws-api/oca.html
Args:
orders: The orders that are to be placed together.
... | python | def oneCancelsAll(
orders: List[Order], ocaGroup: str, ocaType: int) -> List[Order]:
"""
Place the trades in the same One Cancels All (OCA) group.
https://interactivebrokers.github.io/tws-api/oca.html
Args:
orders: The orders that are to be placed together.
... | [
"def",
"oneCancelsAll",
"(",
"orders",
":",
"List",
"[",
"Order",
"]",
",",
"ocaGroup",
":",
"str",
",",
"ocaType",
":",
"int",
")",
"->",
"List",
"[",
"Order",
"]",
":",
"for",
"o",
"in",
"orders",
":",
"o",
".",
"ocaGroup",
"=",
"ocaGroup",
"o",
... | Place the trades in the same One Cancels All (OCA) group.
https://interactivebrokers.github.io/tws-api/oca.html
Args:
orders: The orders that are to be placed together. | [
"Place",
"the",
"trades",
"in",
"the",
"same",
"One",
"Cancels",
"All",
"(",
"OCA",
")",
"group",
"."
] | d0646a482590f5cb7bfddbd1f0870f8c4bc1df80 | https://github.com/erdewit/ib_insync/blob/d0646a482590f5cb7bfddbd1f0870f8c4bc1df80/ib_insync/ib.py#L574-L587 | train |
erdewit/ib_insync | ib_insync/ib.py | IB.whatIfOrder | def whatIfOrder(self, contract: Contract, order: Order) -> OrderState:
"""
Retrieve commission and margin impact without actually
placing the order. The given order will not be modified in any way.
This method is blocking.
Args:
contract: Contract to test.
... | python | def whatIfOrder(self, contract: Contract, order: Order) -> OrderState:
"""
Retrieve commission and margin impact without actually
placing the order. The given order will not be modified in any way.
This method is blocking.
Args:
contract: Contract to test.
... | [
"def",
"whatIfOrder",
"(",
"self",
",",
"contract",
":",
"Contract",
",",
"order",
":",
"Order",
")",
"->",
"OrderState",
":",
"return",
"self",
".",
"_run",
"(",
"self",
".",
"whatIfOrderAsync",
"(",
"contract",
",",
"order",
")",
")"
] | Retrieve commission and margin impact without actually
placing the order. The given order will not be modified in any way.
This method is blocking.
Args:
contract: Contract to test.
order: Order to test. | [
"Retrieve",
"commission",
"and",
"margin",
"impact",
"without",
"actually",
"placing",
"the",
"order",
".",
"The",
"given",
"order",
"will",
"not",
"be",
"modified",
"in",
"any",
"way",
"."
] | d0646a482590f5cb7bfddbd1f0870f8c4bc1df80 | https://github.com/erdewit/ib_insync/blob/d0646a482590f5cb7bfddbd1f0870f8c4bc1df80/ib_insync/ib.py#L589-L600 | train |
erdewit/ib_insync | ib_insync/ib.py | IB.placeOrder | def placeOrder(self, contract: Contract, order: Order) -> Trade:
"""
Place a new order or modify an existing order.
Returns a Trade that is kept live updated with
status changes, fills, etc.
Args:
contract: Contract to use for order.
order: The order to b... | python | def placeOrder(self, contract: Contract, order: Order) -> Trade:
"""
Place a new order or modify an existing order.
Returns a Trade that is kept live updated with
status changes, fills, etc.
Args:
contract: Contract to use for order.
order: The order to b... | [
"def",
"placeOrder",
"(",
"self",
",",
"contract",
":",
"Contract",
",",
"order",
":",
"Order",
")",
"->",
"Trade",
":",
"orderId",
"=",
"order",
".",
"orderId",
"or",
"self",
".",
"client",
".",
"getReqId",
"(",
")",
"self",
".",
"client",
".",
"pla... | Place a new order or modify an existing order.
Returns a Trade that is kept live updated with
status changes, fills, etc.
Args:
contract: Contract to use for order.
order: The order to be placed. | [
"Place",
"a",
"new",
"order",
"or",
"modify",
"an",
"existing",
"order",
".",
"Returns",
"a",
"Trade",
"that",
"is",
"kept",
"live",
"updated",
"with",
"status",
"changes",
"fills",
"etc",
"."
] | d0646a482590f5cb7bfddbd1f0870f8c4bc1df80 | https://github.com/erdewit/ib_insync/blob/d0646a482590f5cb7bfddbd1f0870f8c4bc1df80/ib_insync/ib.py#L602-L637 | train |
erdewit/ib_insync | ib_insync/ib.py | IB.cancelOrder | def cancelOrder(self, order: Order) -> Trade:
"""
Cancel the order and return the Trade it belongs to.
Args:
order: The order to be canceled.
"""
self.client.cancelOrder(order.orderId)
now = datetime.datetime.now(datetime.timezone.utc)
key = self.wrap... | python | def cancelOrder(self, order: Order) -> Trade:
"""
Cancel the order and return the Trade it belongs to.
Args:
order: The order to be canceled.
"""
self.client.cancelOrder(order.orderId)
now = datetime.datetime.now(datetime.timezone.utc)
key = self.wrap... | [
"def",
"cancelOrder",
"(",
"self",
",",
"order",
":",
"Order",
")",
"->",
"Trade",
":",
"self",
".",
"client",
".",
"cancelOrder",
"(",
"order",
".",
"orderId",
")",
"now",
"=",
"datetime",
".",
"datetime",
".",
"now",
"(",
"datetime",
".",
"timezone",... | Cancel the order and return the Trade it belongs to.
Args:
order: The order to be canceled. | [
"Cancel",
"the",
"order",
"and",
"return",
"the",
"Trade",
"it",
"belongs",
"to",
"."
] | d0646a482590f5cb7bfddbd1f0870f8c4bc1df80 | https://github.com/erdewit/ib_insync/blob/d0646a482590f5cb7bfddbd1f0870f8c4bc1df80/ib_insync/ib.py#L639-L671 | train |
erdewit/ib_insync | ib_insync/ib.py | IB.reqAccountUpdatesMulti | def reqAccountUpdatesMulti(
self, account: str = '', modelCode: str = ''):
"""
It is recommended to use :meth:`.accountValues` instead.
Request account values of multiple accounts and keep updated.
This method is blocking.
Args:
account: If specified, f... | python | def reqAccountUpdatesMulti(
self, account: str = '', modelCode: str = ''):
"""
It is recommended to use :meth:`.accountValues` instead.
Request account values of multiple accounts and keep updated.
This method is blocking.
Args:
account: If specified, f... | [
"def",
"reqAccountUpdatesMulti",
"(",
"self",
",",
"account",
":",
"str",
"=",
"''",
",",
"modelCode",
":",
"str",
"=",
"''",
")",
":",
"self",
".",
"_run",
"(",
"self",
".",
"reqAccountUpdatesMultiAsync",
"(",
"account",
",",
"modelCode",
")",
")"
] | It is recommended to use :meth:`.accountValues` instead.
Request account values of multiple accounts and keep updated.
This method is blocking.
Args:
account: If specified, filter for this account name.
modelCode: If specified, filter for this account model. | [
"It",
"is",
"recommended",
"to",
"use",
":",
"meth",
":",
".",
"accountValues",
"instead",
"."
] | d0646a482590f5cb7bfddbd1f0870f8c4bc1df80 | https://github.com/erdewit/ib_insync/blob/d0646a482590f5cb7bfddbd1f0870f8c4bc1df80/ib_insync/ib.py#L704-L717 | train |
erdewit/ib_insync | ib_insync/ib.py | IB.reqExecutions | def reqExecutions(
self, execFilter: ExecutionFilter = None) -> List[Fill]:
"""
It is recommended to use :meth:`.fills` or
:meth:`.executions` instead.
Request and return a list a list of fills.
This method is blocking.
Args:
execFilter: If spe... | python | def reqExecutions(
self, execFilter: ExecutionFilter = None) -> List[Fill]:
"""
It is recommended to use :meth:`.fills` or
:meth:`.executions` instead.
Request and return a list a list of fills.
This method is blocking.
Args:
execFilter: If spe... | [
"def",
"reqExecutions",
"(",
"self",
",",
"execFilter",
":",
"ExecutionFilter",
"=",
"None",
")",
"->",
"List",
"[",
"Fill",
"]",
":",
"return",
"self",
".",
"_run",
"(",
"self",
".",
"reqExecutionsAsync",
"(",
"execFilter",
")",
")"
] | It is recommended to use :meth:`.fills` or
:meth:`.executions` instead.
Request and return a list a list of fills.
This method is blocking.
Args:
execFilter: If specified, return executions that match the filter. | [
"It",
"is",
"recommended",
"to",
"use",
":",
"meth",
":",
".",
"fills",
"or",
":",
"meth",
":",
".",
"executions",
"instead",
"."
] | d0646a482590f5cb7bfddbd1f0870f8c4bc1df80 | https://github.com/erdewit/ib_insync/blob/d0646a482590f5cb7bfddbd1f0870f8c4bc1df80/ib_insync/ib.py#L768-L781 | train |
erdewit/ib_insync | ib_insync/ib.py | IB.reqPnL | def reqPnL(self, account: str, modelCode: str = '') -> PnL:
"""
Start a subscription for profit and loss events.
Returns a :class:`.PnL` object that is kept live updated.
The result can also be queried from :meth:`.pnl`.
https://interactivebrokers.github.io/tws-api/pnl.html
... | python | def reqPnL(self, account: str, modelCode: str = '') -> PnL:
"""
Start a subscription for profit and loss events.
Returns a :class:`.PnL` object that is kept live updated.
The result can also be queried from :meth:`.pnl`.
https://interactivebrokers.github.io/tws-api/pnl.html
... | [
"def",
"reqPnL",
"(",
"self",
",",
"account",
":",
"str",
",",
"modelCode",
":",
"str",
"=",
"''",
")",
"->",
"PnL",
":",
"key",
"=",
"(",
"account",
",",
"modelCode",
")",
"assert",
"key",
"not",
"in",
"self",
".",
"wrapper",
".",
"pnlKey2ReqId",
... | Start a subscription for profit and loss events.
Returns a :class:`.PnL` object that is kept live updated.
The result can also be queried from :meth:`.pnl`.
https://interactivebrokers.github.io/tws-api/pnl.html
Args:
account: Subscribe to this account.
modelCod... | [
"Start",
"a",
"subscription",
"for",
"profit",
"and",
"loss",
"events",
"."
] | d0646a482590f5cb7bfddbd1f0870f8c4bc1df80 | https://github.com/erdewit/ib_insync/blob/d0646a482590f5cb7bfddbd1f0870f8c4bc1df80/ib_insync/ib.py#L793-L813 | train |
erdewit/ib_insync | ib_insync/ib.py | IB.cancelPnL | def cancelPnL(self, account, modelCode: str = ''):
"""
Cancel PnL subscription.
Args:
account: Cancel for this account.
modelCode: If specified, cancel for this account model.
"""
key = (account, modelCode)
reqId = self.wrapper.pnlKey2ReqId.pop(ke... | python | def cancelPnL(self, account, modelCode: str = ''):
"""
Cancel PnL subscription.
Args:
account: Cancel for this account.
modelCode: If specified, cancel for this account model.
"""
key = (account, modelCode)
reqId = self.wrapper.pnlKey2ReqId.pop(ke... | [
"def",
"cancelPnL",
"(",
"self",
",",
"account",
",",
"modelCode",
":",
"str",
"=",
"''",
")",
":",
"key",
"=",
"(",
"account",
",",
"modelCode",
")",
"reqId",
"=",
"self",
".",
"wrapper",
".",
"pnlKey2ReqId",
".",
"pop",
"(",
"key",
",",
"None",
"... | Cancel PnL subscription.
Args:
account: Cancel for this account.
modelCode: If specified, cancel for this account model. | [
"Cancel",
"PnL",
"subscription",
"."
] | d0646a482590f5cb7bfddbd1f0870f8c4bc1df80 | https://github.com/erdewit/ib_insync/blob/d0646a482590f5cb7bfddbd1f0870f8c4bc1df80/ib_insync/ib.py#L815-L831 | train |
erdewit/ib_insync | ib_insync/ib.py | IB.reqPnLSingle | def reqPnLSingle(
self, account: str, modelCode: str, conId: int) -> PnLSingle:
"""
Start a subscription for profit and loss events for single positions.
Returns a :class:`.PnLSingle` object that is kept live updated.
The result can also be queried from :meth:`.pnlSingle`.
... | python | def reqPnLSingle(
self, account: str, modelCode: str, conId: int) -> PnLSingle:
"""
Start a subscription for profit and loss events for single positions.
Returns a :class:`.PnLSingle` object that is kept live updated.
The result can also be queried from :meth:`.pnlSingle`.
... | [
"def",
"reqPnLSingle",
"(",
"self",
",",
"account",
":",
"str",
",",
"modelCode",
":",
"str",
",",
"conId",
":",
"int",
")",
"->",
"PnLSingle",
":",
"key",
"=",
"(",
"account",
",",
"modelCode",
",",
"conId",
")",
"assert",
"key",
"not",
"in",
"self"... | Start a subscription for profit and loss events for single positions.
Returns a :class:`.PnLSingle` object that is kept live updated.
The result can also be queried from :meth:`.pnlSingle`.
https://interactivebrokers.github.io/tws-api/pnl.html
Args:
account: Subscribe to t... | [
"Start",
"a",
"subscription",
"for",
"profit",
"and",
"loss",
"events",
"for",
"single",
"positions",
"."
] | d0646a482590f5cb7bfddbd1f0870f8c4bc1df80 | https://github.com/erdewit/ib_insync/blob/d0646a482590f5cb7bfddbd1f0870f8c4bc1df80/ib_insync/ib.py#L833-L855 | train |
erdewit/ib_insync | ib_insync/ib.py | IB.cancelPnLSingle | def cancelPnLSingle(
self, account: str, modelCode: str, conId: int):
"""
Cancel PnLSingle subscription for the given account, modelCode
and conId.
Args:
account: Cancel for this account name.
modelCode: Cancel for this account model.
conI... | python | def cancelPnLSingle(
self, account: str, modelCode: str, conId: int):
"""
Cancel PnLSingle subscription for the given account, modelCode
and conId.
Args:
account: Cancel for this account name.
modelCode: Cancel for this account model.
conI... | [
"def",
"cancelPnLSingle",
"(",
"self",
",",
"account",
":",
"str",
",",
"modelCode",
":",
"str",
",",
"conId",
":",
"int",
")",
":",
"key",
"=",
"(",
"account",
",",
"modelCode",
",",
"conId",
")",
"reqId",
"=",
"self",
".",
"wrapper",
".",
"pnlSingl... | Cancel PnLSingle subscription for the given account, modelCode
and conId.
Args:
account: Cancel for this account name.
modelCode: Cancel for this account model.
conId: Cancel for this contract ID. | [
"Cancel",
"PnLSingle",
"subscription",
"for",
"the",
"given",
"account",
"modelCode",
"and",
"conId",
"."
] | d0646a482590f5cb7bfddbd1f0870f8c4bc1df80 | https://github.com/erdewit/ib_insync/blob/d0646a482590f5cb7bfddbd1f0870f8c4bc1df80/ib_insync/ib.py#L857-L876 | train |
erdewit/ib_insync | ib_insync/ib.py | IB.reqContractDetails | def reqContractDetails(self, contract: Contract) -> List[ContractDetails]:
"""
Get a list of contract details that match the given contract.
If the returned list is empty then the contract is not known;
If the list has multiple values then the contract is ambiguous.
The fully qu... | python | def reqContractDetails(self, contract: Contract) -> List[ContractDetails]:
"""
Get a list of contract details that match the given contract.
If the returned list is empty then the contract is not known;
If the list has multiple values then the contract is ambiguous.
The fully qu... | [
"def",
"reqContractDetails",
"(",
"self",
",",
"contract",
":",
"Contract",
")",
"->",
"List",
"[",
"ContractDetails",
"]",
":",
"return",
"self",
".",
"_run",
"(",
"self",
".",
"reqContractDetailsAsync",
"(",
"contract",
")",
")"
] | Get a list of contract details that match the given contract.
If the returned list is empty then the contract is not known;
If the list has multiple values then the contract is ambiguous.
The fully qualified contract is available in the the
ContractDetails.contract attribute.
T... | [
"Get",
"a",
"list",
"of",
"contract",
"details",
"that",
"match",
"the",
"given",
"contract",
".",
"If",
"the",
"returned",
"list",
"is",
"empty",
"then",
"the",
"contract",
"is",
"not",
"known",
";",
"If",
"the",
"list",
"has",
"multiple",
"values",
"th... | d0646a482590f5cb7bfddbd1f0870f8c4bc1df80 | https://github.com/erdewit/ib_insync/blob/d0646a482590f5cb7bfddbd1f0870f8c4bc1df80/ib_insync/ib.py#L878-L894 | train |
erdewit/ib_insync | ib_insync/ib.py | IB.reqMatchingSymbols | def reqMatchingSymbols(self, pattern: str) -> List[ContractDescription]:
"""
Request contract descriptions of contracts that match a pattern.
This method is blocking.
https://interactivebrokers.github.io/tws-api/matching_symbols.html
Args:
pattern: The first few le... | python | def reqMatchingSymbols(self, pattern: str) -> List[ContractDescription]:
"""
Request contract descriptions of contracts that match a pattern.
This method is blocking.
https://interactivebrokers.github.io/tws-api/matching_symbols.html
Args:
pattern: The first few le... | [
"def",
"reqMatchingSymbols",
"(",
"self",
",",
"pattern",
":",
"str",
")",
"->",
"List",
"[",
"ContractDescription",
"]",
":",
"return",
"self",
".",
"_run",
"(",
"self",
".",
"reqMatchingSymbolsAsync",
"(",
"pattern",
")",
")"
] | Request contract descriptions of contracts that match a pattern.
This method is blocking.
https://interactivebrokers.github.io/tws-api/matching_symbols.html
Args:
pattern: The first few letters of the ticker symbol, or for
longer strings a character sequence matchi... | [
"Request",
"contract",
"descriptions",
"of",
"contracts",
"that",
"match",
"a",
"pattern",
"."
] | d0646a482590f5cb7bfddbd1f0870f8c4bc1df80 | https://github.com/erdewit/ib_insync/blob/d0646a482590f5cb7bfddbd1f0870f8c4bc1df80/ib_insync/ib.py#L896-L909 | train |
erdewit/ib_insync | ib_insync/ib.py | IB.reqMarketRule | def reqMarketRule(self, marketRuleId: int) -> PriceIncrement:
"""
Request price increments rule.
https://interactivebrokers.github.io/tws-api/minimum_increment.html
Args:
marketRuleId: ID of market rule.
The market rule IDs for a contract can be obtained
... | python | def reqMarketRule(self, marketRuleId: int) -> PriceIncrement:
"""
Request price increments rule.
https://interactivebrokers.github.io/tws-api/minimum_increment.html
Args:
marketRuleId: ID of market rule.
The market rule IDs for a contract can be obtained
... | [
"def",
"reqMarketRule",
"(",
"self",
",",
"marketRuleId",
":",
"int",
")",
"->",
"PriceIncrement",
":",
"return",
"self",
".",
"_run",
"(",
"self",
".",
"reqMarketRuleAsync",
"(",
"marketRuleId",
")",
")"
] | Request price increments rule.
https://interactivebrokers.github.io/tws-api/minimum_increment.html
Args:
marketRuleId: ID of market rule.
The market rule IDs for a contract can be obtained
via :meth:`.reqContractDetails` from
:class:`.Contrac... | [
"Request",
"price",
"increments",
"rule",
"."
] | d0646a482590f5cb7bfddbd1f0870f8c4bc1df80 | https://github.com/erdewit/ib_insync/blob/d0646a482590f5cb7bfddbd1f0870f8c4bc1df80/ib_insync/ib.py#L911-L924 | train |
erdewit/ib_insync | ib_insync/ib.py | IB.reqRealTimeBars | def reqRealTimeBars(
self, contract: Contract, barSize: int,
whatToShow: str, useRTH: bool,
realTimeBarsOptions: List[TagValue] = None) -> RealTimeBarList:
"""
Request realtime 5 second bars.
https://interactivebrokers.github.io/tws-api/realtime_bars.html
... | python | def reqRealTimeBars(
self, contract: Contract, barSize: int,
whatToShow: str, useRTH: bool,
realTimeBarsOptions: List[TagValue] = None) -> RealTimeBarList:
"""
Request realtime 5 second bars.
https://interactivebrokers.github.io/tws-api/realtime_bars.html
... | [
"def",
"reqRealTimeBars",
"(",
"self",
",",
"contract",
":",
"Contract",
",",
"barSize",
":",
"int",
",",
"whatToShow",
":",
"str",
",",
"useRTH",
":",
"bool",
",",
"realTimeBarsOptions",
":",
"List",
"[",
"TagValue",
"]",
"=",
"None",
")",
"->",
"RealTi... | Request realtime 5 second bars.
https://interactivebrokers.github.io/tws-api/realtime_bars.html
Args:
contract: Contract of interest.
barSize: Must be 5.
whatToShow: Specifies the source for constructing bars.
Can be 'TRADES', 'MIDPOINT', 'BID' or 'A... | [
"Request",
"realtime",
"5",
"second",
"bars",
"."
] | d0646a482590f5cb7bfddbd1f0870f8c4bc1df80 | https://github.com/erdewit/ib_insync/blob/d0646a482590f5cb7bfddbd1f0870f8c4bc1df80/ib_insync/ib.py#L926-L955 | train |
erdewit/ib_insync | ib_insync/ib.py | IB.cancelRealTimeBars | def cancelRealTimeBars(self, bars: RealTimeBarList):
"""
Cancel the realtime bars subscription.
Args:
bars: The bar list that was obtained from ``reqRealTimeBars``.
"""
self.client.cancelRealTimeBars(bars.reqId)
self.wrapper.endSubscription(bars) | python | def cancelRealTimeBars(self, bars: RealTimeBarList):
"""
Cancel the realtime bars subscription.
Args:
bars: The bar list that was obtained from ``reqRealTimeBars``.
"""
self.client.cancelRealTimeBars(bars.reqId)
self.wrapper.endSubscription(bars) | [
"def",
"cancelRealTimeBars",
"(",
"self",
",",
"bars",
":",
"RealTimeBarList",
")",
":",
"self",
".",
"client",
".",
"cancelRealTimeBars",
"(",
"bars",
".",
"reqId",
")",
"self",
".",
"wrapper",
".",
"endSubscription",
"(",
"bars",
")"
] | Cancel the realtime bars subscription.
Args:
bars: The bar list that was obtained from ``reqRealTimeBars``. | [
"Cancel",
"the",
"realtime",
"bars",
"subscription",
"."
] | d0646a482590f5cb7bfddbd1f0870f8c4bc1df80 | https://github.com/erdewit/ib_insync/blob/d0646a482590f5cb7bfddbd1f0870f8c4bc1df80/ib_insync/ib.py#L957-L965 | train |
erdewit/ib_insync | ib_insync/ib.py | IB.reqHistoricalData | def reqHistoricalData(
self, contract: Contract, endDateTime: object,
durationStr: str, barSizeSetting: str,
whatToShow: str, useRTH: bool,
formatDate: int = 1, keepUpToDate: bool = False,
chartOptions: List[TagValue] = None) -> BarDataList:
"""
... | python | def reqHistoricalData(
self, contract: Contract, endDateTime: object,
durationStr: str, barSizeSetting: str,
whatToShow: str, useRTH: bool,
formatDate: int = 1, keepUpToDate: bool = False,
chartOptions: List[TagValue] = None) -> BarDataList:
"""
... | [
"def",
"reqHistoricalData",
"(",
"self",
",",
"contract",
":",
"Contract",
",",
"endDateTime",
":",
"object",
",",
"durationStr",
":",
"str",
",",
"barSizeSetting",
":",
"str",
",",
"whatToShow",
":",
"str",
",",
"useRTH",
":",
"bool",
",",
"formatDate",
"... | Request historical bar data.
This method is blocking.
https://interactivebrokers.github.io/tws-api/historical_bars.html
Args:
contract: Contract of interest.
endDateTime: Can be set to '' to indicate the current time,
or it can be given as a datetime.da... | [
"Request",
"historical",
"bar",
"data",
"."
] | d0646a482590f5cb7bfddbd1f0870f8c4bc1df80 | https://github.com/erdewit/ib_insync/blob/d0646a482590f5cb7bfddbd1f0870f8c4bc1df80/ib_insync/ib.py#L967-L1014 | train |
erdewit/ib_insync | ib_insync/ib.py | IB.cancelHistoricalData | def cancelHistoricalData(self, bars: BarDataList):
"""
Cancel the update subscription for the historical bars.
Args:
bars: The bar list that was obtained from ``reqHistoricalData``
with a keepUpToDate subscription.
"""
self.client.cancelHistoricalDat... | python | def cancelHistoricalData(self, bars: BarDataList):
"""
Cancel the update subscription for the historical bars.
Args:
bars: The bar list that was obtained from ``reqHistoricalData``
with a keepUpToDate subscription.
"""
self.client.cancelHistoricalDat... | [
"def",
"cancelHistoricalData",
"(",
"self",
",",
"bars",
":",
"BarDataList",
")",
":",
"self",
".",
"client",
".",
"cancelHistoricalData",
"(",
"bars",
".",
"reqId",
")",
"self",
".",
"wrapper",
".",
"endSubscription",
"(",
"bars",
")"
] | Cancel the update subscription for the historical bars.
Args:
bars: The bar list that was obtained from ``reqHistoricalData``
with a keepUpToDate subscription. | [
"Cancel",
"the",
"update",
"subscription",
"for",
"the",
"historical",
"bars",
"."
] | d0646a482590f5cb7bfddbd1f0870f8c4bc1df80 | https://github.com/erdewit/ib_insync/blob/d0646a482590f5cb7bfddbd1f0870f8c4bc1df80/ib_insync/ib.py#L1016-L1026 | train |
erdewit/ib_insync | ib_insync/ib.py | IB.reqHistoricalTicks | def reqHistoricalTicks(
self, contract: Contract,
startDateTime: Union[str, datetime.date],
endDateTime: Union[str, datetime.date],
numberOfTicks: int, whatToShow: str, useRth: bool,
ignoreSize: bool = False,
miscOptions: List[TagValue] = None) -> ... | python | def reqHistoricalTicks(
self, contract: Contract,
startDateTime: Union[str, datetime.date],
endDateTime: Union[str, datetime.date],
numberOfTicks: int, whatToShow: str, useRth: bool,
ignoreSize: bool = False,
miscOptions: List[TagValue] = None) -> ... | [
"def",
"reqHistoricalTicks",
"(",
"self",
",",
"contract",
":",
"Contract",
",",
"startDateTime",
":",
"Union",
"[",
"str",
",",
"datetime",
".",
"date",
"]",
",",
"endDateTime",
":",
"Union",
"[",
"str",
",",
"datetime",
".",
"date",
"]",
",",
"numberOf... | Request historical ticks. The time resolution of the ticks
is one second.
This method is blocking.
https://interactivebrokers.github.io/tws-api/historical_time_and_sales.html
Args:
contract: Contract to query.
startDateTime: Can be given as a datetime.date or
... | [
"Request",
"historical",
"ticks",
".",
"The",
"time",
"resolution",
"of",
"the",
"ticks",
"is",
"one",
"second",
"."
] | d0646a482590f5cb7bfddbd1f0870f8c4bc1df80 | https://github.com/erdewit/ib_insync/blob/d0646a482590f5cb7bfddbd1f0870f8c4bc1df80/ib_insync/ib.py#L1028-L1063 | train |
erdewit/ib_insync | ib_insync/ib.py | IB.reqHeadTimeStamp | def reqHeadTimeStamp(
self, contract: Contract, whatToShow: str,
useRTH: bool, formatDate: int = 1) -> datetime.datetime:
"""
Get the datetime of earliest available historical data
for the contract.
Args:
contract: Contract of interest.
us... | python | def reqHeadTimeStamp(
self, contract: Contract, whatToShow: str,
useRTH: bool, formatDate: int = 1) -> datetime.datetime:
"""
Get the datetime of earliest available historical data
for the contract.
Args:
contract: Contract of interest.
us... | [
"def",
"reqHeadTimeStamp",
"(",
"self",
",",
"contract",
":",
"Contract",
",",
"whatToShow",
":",
"str",
",",
"useRTH",
":",
"bool",
",",
"formatDate",
":",
"int",
"=",
"1",
")",
"->",
"datetime",
".",
"datetime",
":",
"return",
"self",
".",
"_run",
"(... | Get the datetime of earliest available historical data
for the contract.
Args:
contract: Contract of interest.
useRTH: If True then only show data from within Regular
Trading Hours, if False then show all data.
formatDate: If set to 2 then the result ... | [
"Get",
"the",
"datetime",
"of",
"earliest",
"available",
"historical",
"data",
"for",
"the",
"contract",
"."
] | d0646a482590f5cb7bfddbd1f0870f8c4bc1df80 | https://github.com/erdewit/ib_insync/blob/d0646a482590f5cb7bfddbd1f0870f8c4bc1df80/ib_insync/ib.py#L1081-L1097 | train |
erdewit/ib_insync | ib_insync/ib.py | IB.reqMktData | def reqMktData(
self, contract: Contract, genericTickList: str = '',
snapshot: bool = False, regulatorySnapshot: bool = False,
mktDataOptions: List[TagValue] = None) -> Ticker:
"""
Subscribe to tick data or request a snapshot.
Returns the Ticker that holds the... | python | def reqMktData(
self, contract: Contract, genericTickList: str = '',
snapshot: bool = False, regulatorySnapshot: bool = False,
mktDataOptions: List[TagValue] = None) -> Ticker:
"""
Subscribe to tick data or request a snapshot.
Returns the Ticker that holds the... | [
"def",
"reqMktData",
"(",
"self",
",",
"contract",
":",
"Contract",
",",
"genericTickList",
":",
"str",
"=",
"''",
",",
"snapshot",
":",
"bool",
"=",
"False",
",",
"regulatorySnapshot",
":",
"bool",
"=",
"False",
",",
"mktDataOptions",
":",
"List",
"[",
... | Subscribe to tick data or request a snapshot.
Returns the Ticker that holds the market data. The ticker will
initially be empty and gradually (after a couple of seconds)
be filled.
https://interactivebrokers.github.io/tws-api/md_request.html
Args:
contract: Contract... | [
"Subscribe",
"to",
"tick",
"data",
"or",
"request",
"a",
"snapshot",
".",
"Returns",
"the",
"Ticker",
"that",
"holds",
"the",
"market",
"data",
".",
"The",
"ticker",
"will",
"initially",
"be",
"empty",
"and",
"gradually",
"(",
"after",
"a",
"couple",
"of",... | d0646a482590f5cb7bfddbd1f0870f8c4bc1df80 | https://github.com/erdewit/ib_insync/blob/d0646a482590f5cb7bfddbd1f0870f8c4bc1df80/ib_insync/ib.py#L1099-L1154 | train |
erdewit/ib_insync | ib_insync/ib.py | IB.cancelMktData | def cancelMktData(self, contract: Contract):
"""
Unsubscribe from realtime streaming tick data.
Args:
contract: The exact contract object that was used to
subscribe with.
"""
ticker = self.ticker(contract)
reqId = self.wrapper.endTicker(ticker... | python | def cancelMktData(self, contract: Contract):
"""
Unsubscribe from realtime streaming tick data.
Args:
contract: The exact contract object that was used to
subscribe with.
"""
ticker = self.ticker(contract)
reqId = self.wrapper.endTicker(ticker... | [
"def",
"cancelMktData",
"(",
"self",
",",
"contract",
":",
"Contract",
")",
":",
"ticker",
"=",
"self",
".",
"ticker",
"(",
"contract",
")",
"reqId",
"=",
"self",
".",
"wrapper",
".",
"endTicker",
"(",
"ticker",
",",
"'mktData'",
")",
"if",
"reqId",
":... | Unsubscribe from realtime streaming tick data.
Args:
contract: The exact contract object that was used to
subscribe with. | [
"Unsubscribe",
"from",
"realtime",
"streaming",
"tick",
"data",
"."
] | d0646a482590f5cb7bfddbd1f0870f8c4bc1df80 | https://github.com/erdewit/ib_insync/blob/d0646a482590f5cb7bfddbd1f0870f8c4bc1df80/ib_insync/ib.py#L1156-L1170 | train |
erdewit/ib_insync | ib_insync/ib.py | IB.reqTickByTickData | def reqTickByTickData(
self, contract: Contract, tickType: str,
numberOfTicks: int = 0, ignoreSize: bool = False) -> Ticker:
"""
Subscribe to tick-by-tick data and return the Ticker that
holds the ticks in ticker.tickByTicks.
https://interactivebrokers.github.io/... | python | def reqTickByTickData(
self, contract: Contract, tickType: str,
numberOfTicks: int = 0, ignoreSize: bool = False) -> Ticker:
"""
Subscribe to tick-by-tick data and return the Ticker that
holds the ticks in ticker.tickByTicks.
https://interactivebrokers.github.io/... | [
"def",
"reqTickByTickData",
"(",
"self",
",",
"contract",
":",
"Contract",
",",
"tickType",
":",
"str",
",",
"numberOfTicks",
":",
"int",
"=",
"0",
",",
"ignoreSize",
":",
"bool",
"=",
"False",
")",
"->",
"Ticker",
":",
"reqId",
"=",
"self",
".",
"clie... | Subscribe to tick-by-tick data and return the Ticker that
holds the ticks in ticker.tickByTicks.
https://interactivebrokers.github.io/tws-api/tick_data.html
Args:
contract: Contract of interest.
tickType: One of 'Last', 'AllLast', 'BidAsk' or 'MidPoint'.
nu... | [
"Subscribe",
"to",
"tick",
"-",
"by",
"-",
"tick",
"data",
"and",
"return",
"the",
"Ticker",
"that",
"holds",
"the",
"ticks",
"in",
"ticker",
".",
"tickByTicks",
"."
] | d0646a482590f5cb7bfddbd1f0870f8c4bc1df80 | https://github.com/erdewit/ib_insync/blob/d0646a482590f5cb7bfddbd1f0870f8c4bc1df80/ib_insync/ib.py#L1172-L1191 | train |
erdewit/ib_insync | ib_insync/ib.py | IB.cancelTickByTickData | def cancelTickByTickData(self, contract: Contract, tickType: str):
"""
Unsubscribe from tick-by-tick data
Args:
contract: The exact contract object that was used to
subscribe with.
"""
ticker = self.ticker(contract)
reqId = self.wrapper.endTic... | python | def cancelTickByTickData(self, contract: Contract, tickType: str):
"""
Unsubscribe from tick-by-tick data
Args:
contract: The exact contract object that was used to
subscribe with.
"""
ticker = self.ticker(contract)
reqId = self.wrapper.endTic... | [
"def",
"cancelTickByTickData",
"(",
"self",
",",
"contract",
":",
"Contract",
",",
"tickType",
":",
"str",
")",
":",
"ticker",
"=",
"self",
".",
"ticker",
"(",
"contract",
")",
"reqId",
"=",
"self",
".",
"wrapper",
".",
"endTicker",
"(",
"ticker",
",",
... | Unsubscribe from tick-by-tick data
Args:
contract: The exact contract object that was used to
subscribe with. | [
"Unsubscribe",
"from",
"tick",
"-",
"by",
"-",
"tick",
"data"
] | d0646a482590f5cb7bfddbd1f0870f8c4bc1df80 | https://github.com/erdewit/ib_insync/blob/d0646a482590f5cb7bfddbd1f0870f8c4bc1df80/ib_insync/ib.py#L1193-L1207 | train |
erdewit/ib_insync | ib_insync/ib.py | IB.reqMktDepth | def reqMktDepth(
self, contract: Contract, numRows: int = 5,
isSmartDepth: bool = False, mktDepthOptions=None) -> Ticker:
"""
Subscribe to market depth data (a.k.a. DOM, L2 or order book).
https://interactivebrokers.github.io/tws-api/market_depth.html
Args:
... | python | def reqMktDepth(
self, contract: Contract, numRows: int = 5,
isSmartDepth: bool = False, mktDepthOptions=None) -> Ticker:
"""
Subscribe to market depth data (a.k.a. DOM, L2 or order book).
https://interactivebrokers.github.io/tws-api/market_depth.html
Args:
... | [
"def",
"reqMktDepth",
"(",
"self",
",",
"contract",
":",
"Contract",
",",
"numRows",
":",
"int",
"=",
"5",
",",
"isSmartDepth",
":",
"bool",
"=",
"False",
",",
"mktDepthOptions",
"=",
"None",
")",
"->",
"Ticker",
":",
"reqId",
"=",
"self",
".",
"client... | Subscribe to market depth data (a.k.a. DOM, L2 or order book).
https://interactivebrokers.github.io/tws-api/market_depth.html
Args:
contract: Contract of interest.
numRows: Number of depth level on each side of the order book
(5 max).
isSmartDepth: C... | [
"Subscribe",
"to",
"market",
"depth",
"data",
"(",
"a",
".",
"k",
".",
"a",
".",
"DOM",
"L2",
"or",
"order",
"book",
")",
"."
] | d0646a482590f5cb7bfddbd1f0870f8c4bc1df80 | https://github.com/erdewit/ib_insync/blob/d0646a482590f5cb7bfddbd1f0870f8c4bc1df80/ib_insync/ib.py#L1216-L1240 | train |
erdewit/ib_insync | ib_insync/ib.py | IB.cancelMktDepth | def cancelMktDepth(self, contract: Contract, isSmartDepth=False):
"""
Unsubscribe from market depth data.
Args:
contract: The exact contract object that was used to
subscribe with.
"""
ticker = self.ticker(contract)
reqId = self.wrapper.endTic... | python | def cancelMktDepth(self, contract: Contract, isSmartDepth=False):
"""
Unsubscribe from market depth data.
Args:
contract: The exact contract object that was used to
subscribe with.
"""
ticker = self.ticker(contract)
reqId = self.wrapper.endTic... | [
"def",
"cancelMktDepth",
"(",
"self",
",",
"contract",
":",
"Contract",
",",
"isSmartDepth",
"=",
"False",
")",
":",
"ticker",
"=",
"self",
".",
"ticker",
"(",
"contract",
")",
"reqId",
"=",
"self",
".",
"wrapper",
".",
"endTicker",
"(",
"ticker",
",",
... | Unsubscribe from market depth data.
Args:
contract: The exact contract object that was used to
subscribe with. | [
"Unsubscribe",
"from",
"market",
"depth",
"data",
"."
] | d0646a482590f5cb7bfddbd1f0870f8c4bc1df80 | https://github.com/erdewit/ib_insync/blob/d0646a482590f5cb7bfddbd1f0870f8c4bc1df80/ib_insync/ib.py#L1242-L1256 | train |
erdewit/ib_insync | ib_insync/ib.py | IB.reqHistogramData | def reqHistogramData(
self, contract: Contract,
useRTH: bool, period: str) -> List[HistogramData]:
"""
Request histogram data.
This method is blocking.
https://interactivebrokers.github.io/tws-api/histograms.html
Args:
contract: Contract to ... | python | def reqHistogramData(
self, contract: Contract,
useRTH: bool, period: str) -> List[HistogramData]:
"""
Request histogram data.
This method is blocking.
https://interactivebrokers.github.io/tws-api/histograms.html
Args:
contract: Contract to ... | [
"def",
"reqHistogramData",
"(",
"self",
",",
"contract",
":",
"Contract",
",",
"useRTH",
":",
"bool",
",",
"period",
":",
"str",
")",
"->",
"List",
"[",
"HistogramData",
"]",
":",
"return",
"self",
".",
"_run",
"(",
"self",
".",
"reqHistogramDataAsync",
... | Request histogram data.
This method is blocking.
https://interactivebrokers.github.io/tws-api/histograms.html
Args:
contract: Contract to query.
useRTH: If True then only show data from within Regular
Trading Hours, if False then show all data.
... | [
"Request",
"histogram",
"data",
"."
] | d0646a482590f5cb7bfddbd1f0870f8c4bc1df80 | https://github.com/erdewit/ib_insync/blob/d0646a482590f5cb7bfddbd1f0870f8c4bc1df80/ib_insync/ib.py#L1258-L1276 | train |
erdewit/ib_insync | ib_insync/ib.py | IB.reqFundamentalData | def reqFundamentalData(
self, contract: Contract, reportType: str,
fundamentalDataOptions: List[TagValue] = None) -> str:
"""
Get fundamental data of a contract in XML format.
This method is blocking.
https://interactivebrokers.github.io/tws-api/fundamentals.htm... | python | def reqFundamentalData(
self, contract: Contract, reportType: str,
fundamentalDataOptions: List[TagValue] = None) -> str:
"""
Get fundamental data of a contract in XML format.
This method is blocking.
https://interactivebrokers.github.io/tws-api/fundamentals.htm... | [
"def",
"reqFundamentalData",
"(",
"self",
",",
"contract",
":",
"Contract",
",",
"reportType",
":",
"str",
",",
"fundamentalDataOptions",
":",
"List",
"[",
"TagValue",
"]",
"=",
"None",
")",
"->",
"str",
":",
"return",
"self",
".",
"_run",
"(",
"self",
"... | Get fundamental data of a contract in XML format.
This method is blocking.
https://interactivebrokers.github.io/tws-api/fundamentals.html
Args:
contract: Contract to query.
reportType:
* 'ReportsFinSummary': Financial summary
* 'Reports... | [
"Get",
"fundamental",
"data",
"of",
"a",
"contract",
"in",
"XML",
"format",
"."
] | d0646a482590f5cb7bfddbd1f0870f8c4bc1df80 | https://github.com/erdewit/ib_insync/blob/d0646a482590f5cb7bfddbd1f0870f8c4bc1df80/ib_insync/ib.py#L1278-L1302 | train |
erdewit/ib_insync | ib_insync/ib.py | IB.reqScannerData | def reqScannerData(
self, subscription: ScannerSubscription,
scannerSubscriptionOptions: List[TagValue] = None,
scannerSubscriptionFilterOptions:
List[TagValue] = None) -> ScanDataList:
"""
Do a blocking market scan by starting a subscription and canceling... | python | def reqScannerData(
self, subscription: ScannerSubscription,
scannerSubscriptionOptions: List[TagValue] = None,
scannerSubscriptionFilterOptions:
List[TagValue] = None) -> ScanDataList:
"""
Do a blocking market scan by starting a subscription and canceling... | [
"def",
"reqScannerData",
"(",
"self",
",",
"subscription",
":",
"ScannerSubscription",
",",
"scannerSubscriptionOptions",
":",
"List",
"[",
"TagValue",
"]",
"=",
"None",
",",
"scannerSubscriptionFilterOptions",
":",
"List",
"[",
"TagValue",
"]",
"=",
"None",
")",
... | Do a blocking market scan by starting a subscription and canceling it
after the initial list of results are in.
This method is blocking.
https://interactivebrokers.github.io/tws-api/market_scanners.html
Args:
subscription: Basic filters.
scannerSubscriptionOpti... | [
"Do",
"a",
"blocking",
"market",
"scan",
"by",
"starting",
"a",
"subscription",
"and",
"canceling",
"it",
"after",
"the",
"initial",
"list",
"of",
"results",
"are",
"in",
"."
] | d0646a482590f5cb7bfddbd1f0870f8c4bc1df80 | https://github.com/erdewit/ib_insync/blob/d0646a482590f5cb7bfddbd1f0870f8c4bc1df80/ib_insync/ib.py#L1304-L1325 | train |
erdewit/ib_insync | ib_insync/ib.py | IB.reqScannerSubscription | def reqScannerSubscription(
self, subscription: ScannerSubscription,
scannerSubscriptionOptions: List[TagValue] = None,
scannerSubscriptionFilterOptions:
List[TagValue] = None) -> ScanDataList:
"""
Subscribe to market scan data.
https://interactiv... | python | def reqScannerSubscription(
self, subscription: ScannerSubscription,
scannerSubscriptionOptions: List[TagValue] = None,
scannerSubscriptionFilterOptions:
List[TagValue] = None) -> ScanDataList:
"""
Subscribe to market scan data.
https://interactiv... | [
"def",
"reqScannerSubscription",
"(",
"self",
",",
"subscription",
":",
"ScannerSubscription",
",",
"scannerSubscriptionOptions",
":",
"List",
"[",
"TagValue",
"]",
"=",
"None",
",",
"scannerSubscriptionFilterOptions",
":",
"List",
"[",
"TagValue",
"]",
"=",
"None",... | Subscribe to market scan data.
https://interactivebrokers.github.io/tws-api/market_scanners.html
Args:
subscription: What to scan for.
scannerSubscriptionOptions: Unknown.
scannerSubscriptionFilterOptions: Unknown. | [
"Subscribe",
"to",
"market",
"scan",
"data",
"."
] | d0646a482590f5cb7bfddbd1f0870f8c4bc1df80 | https://github.com/erdewit/ib_insync/blob/d0646a482590f5cb7bfddbd1f0870f8c4bc1df80/ib_insync/ib.py#L1327-L1353 | train |
erdewit/ib_insync | ib_insync/ib.py | IB.cancelScannerSubscription | def cancelScannerSubscription(self, dataList: ScanDataList):
"""
Cancel market data subscription.
https://interactivebrokers.github.io/tws-api/market_scanners.html
Args:
dataList: The scan data list that was obtained from
:meth:`.reqScannerSubscription`.
... | python | def cancelScannerSubscription(self, dataList: ScanDataList):
"""
Cancel market data subscription.
https://interactivebrokers.github.io/tws-api/market_scanners.html
Args:
dataList: The scan data list that was obtained from
:meth:`.reqScannerSubscription`.
... | [
"def",
"cancelScannerSubscription",
"(",
"self",
",",
"dataList",
":",
"ScanDataList",
")",
":",
"self",
".",
"client",
".",
"cancelScannerSubscription",
"(",
"dataList",
".",
"reqId",
")",
"self",
".",
"wrapper",
".",
"endSubscription",
"(",
"dataList",
")"
] | Cancel market data subscription.
https://interactivebrokers.github.io/tws-api/market_scanners.html
Args:
dataList: The scan data list that was obtained from
:meth:`.reqScannerSubscription`. | [
"Cancel",
"market",
"data",
"subscription",
"."
] | d0646a482590f5cb7bfddbd1f0870f8c4bc1df80 | https://github.com/erdewit/ib_insync/blob/d0646a482590f5cb7bfddbd1f0870f8c4bc1df80/ib_insync/ib.py#L1355-L1366 | train |
erdewit/ib_insync | ib_insync/ib.py | IB.calculateImpliedVolatility | def calculateImpliedVolatility(
self, contract: Contract,
optionPrice: float, underPrice: float,
implVolOptions: List[TagValue] = None) -> OptionComputation:
"""
Calculate the volatility given the option price.
This method is blocking.
https://intera... | python | def calculateImpliedVolatility(
self, contract: Contract,
optionPrice: float, underPrice: float,
implVolOptions: List[TagValue] = None) -> OptionComputation:
"""
Calculate the volatility given the option price.
This method is blocking.
https://intera... | [
"def",
"calculateImpliedVolatility",
"(",
"self",
",",
"contract",
":",
"Contract",
",",
"optionPrice",
":",
"float",
",",
"underPrice",
":",
"float",
",",
"implVolOptions",
":",
"List",
"[",
"TagValue",
"]",
"=",
"None",
")",
"->",
"OptionComputation",
":",
... | Calculate the volatility given the option price.
This method is blocking.
https://interactivebrokers.github.io/tws-api/option_computations.html
Args:
contract: Option contract.
optionPrice: Option price to use in calculation.
underPrice: Price of the underl... | [
"Calculate",
"the",
"volatility",
"given",
"the",
"option",
"price",
"."
] | d0646a482590f5cb7bfddbd1f0870f8c4bc1df80 | https://github.com/erdewit/ib_insync/blob/d0646a482590f5cb7bfddbd1f0870f8c4bc1df80/ib_insync/ib.py#L1376-L1395 | train |
erdewit/ib_insync | ib_insync/ib.py | IB.calculateOptionPrice | def calculateOptionPrice(
self, contract: Contract,
volatility: float, underPrice: float,
optPrcOptions=None) -> OptionComputation:
"""
Calculate the option price given the volatility.
This method is blocking.
https://interactivebrokers.github.io/tws... | python | def calculateOptionPrice(
self, contract: Contract,
volatility: float, underPrice: float,
optPrcOptions=None) -> OptionComputation:
"""
Calculate the option price given the volatility.
This method is blocking.
https://interactivebrokers.github.io/tws... | [
"def",
"calculateOptionPrice",
"(",
"self",
",",
"contract",
":",
"Contract",
",",
"volatility",
":",
"float",
",",
"underPrice",
":",
"float",
",",
"optPrcOptions",
"=",
"None",
")",
"->",
"OptionComputation",
":",
"return",
"self",
".",
"_run",
"(",
"self"... | Calculate the option price given the volatility.
This method is blocking.
https://interactivebrokers.github.io/tws-api/option_computations.html
Args:
contract: Option contract.
volatility: Option volatility to use in calculation.
underPrice: Price of the un... | [
"Calculate",
"the",
"option",
"price",
"given",
"the",
"volatility",
"."
] | d0646a482590f5cb7bfddbd1f0870f8c4bc1df80 | https://github.com/erdewit/ib_insync/blob/d0646a482590f5cb7bfddbd1f0870f8c4bc1df80/ib_insync/ib.py#L1397-L1416 | train |
erdewit/ib_insync | ib_insync/ib.py | IB.reqSecDefOptParams | def reqSecDefOptParams(
self, underlyingSymbol: str,
futFopExchange: str, underlyingSecType: str,
underlyingConId: int) -> List[OptionChain]:
"""
Get the option chain.
This method is blocking.
https://interactivebrokers.github.io/tws-api/options.html... | python | def reqSecDefOptParams(
self, underlyingSymbol: str,
futFopExchange: str, underlyingSecType: str,
underlyingConId: int) -> List[OptionChain]:
"""
Get the option chain.
This method is blocking.
https://interactivebrokers.github.io/tws-api/options.html... | [
"def",
"reqSecDefOptParams",
"(",
"self",
",",
"underlyingSymbol",
":",
"str",
",",
"futFopExchange",
":",
"str",
",",
"underlyingSecType",
":",
"str",
",",
"underlyingConId",
":",
"int",
")",
"->",
"List",
"[",
"OptionChain",
"]",
":",
"return",
"self",
"."... | Get the option chain.
This method is blocking.
https://interactivebrokers.github.io/tws-api/options.html
Args:
underlyingSymbol: Symbol of underlier contract.
futFopExchange: Exchange (only for ``FuturesOption``, otherwise
leave blank).
unde... | [
"Get",
"the",
"option",
"chain",
"."
] | d0646a482590f5cb7bfddbd1f0870f8c4bc1df80 | https://github.com/erdewit/ib_insync/blob/d0646a482590f5cb7bfddbd1f0870f8c4bc1df80/ib_insync/ib.py#L1418-L1440 | train |
erdewit/ib_insync | ib_insync/ib.py | IB.exerciseOptions | def exerciseOptions(
self, contract: Contract, exerciseAction: int,
exerciseQuantity: int, account: str, override: int):
"""
Exercise an options contract.
https://interactivebrokers.github.io/tws-api/options.html
Args:
contract: The option contract t... | python | def exerciseOptions(
self, contract: Contract, exerciseAction: int,
exerciseQuantity: int, account: str, override: int):
"""
Exercise an options contract.
https://interactivebrokers.github.io/tws-api/options.html
Args:
contract: The option contract t... | [
"def",
"exerciseOptions",
"(",
"self",
",",
"contract",
":",
"Contract",
",",
"exerciseAction",
":",
"int",
",",
"exerciseQuantity",
":",
"int",
",",
"account",
":",
"str",
",",
"override",
":",
"int",
")",
":",
"reqId",
"=",
"self",
".",
"client",
".",
... | Exercise an options contract.
https://interactivebrokers.github.io/tws-api/options.html
Args:
contract: The option contract to be exercised.
exerciseAction:
* 1 = exercise the option
* 2 = let the option lapse
exerciseQuantity: Number... | [
"Exercise",
"an",
"options",
"contract",
"."
] | d0646a482590f5cb7bfddbd1f0870f8c4bc1df80 | https://github.com/erdewit/ib_insync/blob/d0646a482590f5cb7bfddbd1f0870f8c4bc1df80/ib_insync/ib.py#L1442-L1464 | train |
erdewit/ib_insync | ib_insync/ib.py | IB.reqNewsArticle | def reqNewsArticle(
self, providerCode: str, articleId: str,
newsArticleOptions: List[TagValue] = None) -> NewsArticle:
"""
Get the body of a news article.
This method is blocking.
https://interactivebrokers.github.io/tws-api/news.html
Args:
... | python | def reqNewsArticle(
self, providerCode: str, articleId: str,
newsArticleOptions: List[TagValue] = None) -> NewsArticle:
"""
Get the body of a news article.
This method is blocking.
https://interactivebrokers.github.io/tws-api/news.html
Args:
... | [
"def",
"reqNewsArticle",
"(",
"self",
",",
"providerCode",
":",
"str",
",",
"articleId",
":",
"str",
",",
"newsArticleOptions",
":",
"List",
"[",
"TagValue",
"]",
"=",
"None",
")",
"->",
"NewsArticle",
":",
"return",
"self",
".",
"_run",
"(",
"self",
"."... | Get the body of a news article.
This method is blocking.
https://interactivebrokers.github.io/tws-api/news.html
Args:
providerCode: Code indicating news provider, like 'BZ' or 'FLY'.
articleId: ID of the specific article.
newsArticleOptions: Unknown. | [
"Get",
"the",
"body",
"of",
"a",
"news",
"article",
"."
] | d0646a482590f5cb7bfddbd1f0870f8c4bc1df80 | https://github.com/erdewit/ib_insync/blob/d0646a482590f5cb7bfddbd1f0870f8c4bc1df80/ib_insync/ib.py#L1474-L1491 | train |
erdewit/ib_insync | ib_insync/ib.py | IB.reqHistoricalNews | def reqHistoricalNews(
self, conId: int, providerCodes: str,
startDateTime: Union[str, datetime.date],
endDateTime: Union[str, datetime.date],
totalResults: int,
historicalNewsOptions: List[TagValue] = None) -> HistoricalNews:
"""
Get historica... | python | def reqHistoricalNews(
self, conId: int, providerCodes: str,
startDateTime: Union[str, datetime.date],
endDateTime: Union[str, datetime.date],
totalResults: int,
historicalNewsOptions: List[TagValue] = None) -> HistoricalNews:
"""
Get historica... | [
"def",
"reqHistoricalNews",
"(",
"self",
",",
"conId",
":",
"int",
",",
"providerCodes",
":",
"str",
",",
"startDateTime",
":",
"Union",
"[",
"str",
",",
"datetime",
".",
"date",
"]",
",",
"endDateTime",
":",
"Union",
"[",
"str",
",",
"datetime",
".",
... | Get historical news headline.
https://interactivebrokers.github.io/tws-api/news.html
This method is blocking.
Args:
conId: Search news articles for contract with this conId.
providerCodes: A '+'-separated list of provider codes, like
'BZ+FLY'.
... | [
"Get",
"historical",
"news",
"headline",
"."
] | d0646a482590f5cb7bfddbd1f0870f8c4bc1df80 | https://github.com/erdewit/ib_insync/blob/d0646a482590f5cb7bfddbd1f0870f8c4bc1df80/ib_insync/ib.py#L1493-L1524 | train |
erdewit/ib_insync | ib_insync/ib.py | IB.replaceFA | def replaceFA(self, faDataType: int, xml: str):
"""
Replaces Financial Advisor's settings.
Args:
faDataType: See :meth:`.requestFA`.
xml: The XML-formatted configuration string.
"""
self.client.replaceFA(faDataType, xml) | python | def replaceFA(self, faDataType: int, xml: str):
"""
Replaces Financial Advisor's settings.
Args:
faDataType: See :meth:`.requestFA`.
xml: The XML-formatted configuration string.
"""
self.client.replaceFA(faDataType, xml) | [
"def",
"replaceFA",
"(",
"self",
",",
"faDataType",
":",
"int",
",",
"xml",
":",
"str",
")",
":",
"self",
".",
"client",
".",
"replaceFA",
"(",
"faDataType",
",",
"xml",
")"
] | Replaces Financial Advisor's settings.
Args:
faDataType: See :meth:`.requestFA`.
xml: The XML-formatted configuration string. | [
"Replaces",
"Financial",
"Advisor",
"s",
"settings",
"."
] | d0646a482590f5cb7bfddbd1f0870f8c4bc1df80 | https://github.com/erdewit/ib_insync/blob/d0646a482590f5cb7bfddbd1f0870f8c4bc1df80/ib_insync/ib.py#L1563-L1571 | train |
erdewit/ib_insync | ib_insync/util.py | df | def df(objs, labels=None):
"""
Create pandas DataFrame from the sequence of same-type objects.
When a list of labels is given then only retain those labels and
drop the rest.
"""
import pandas as pd
from .objects import Object, DynamicObject
if objs:
objs = list(objs)
obj... | python | def df(objs, labels=None):
"""
Create pandas DataFrame from the sequence of same-type objects.
When a list of labels is given then only retain those labels and
drop the rest.
"""
import pandas as pd
from .objects import Object, DynamicObject
if objs:
objs = list(objs)
obj... | [
"def",
"df",
"(",
"objs",
",",
"labels",
"=",
"None",
")",
":",
"import",
"pandas",
"as",
"pd",
"from",
".",
"objects",
"import",
"Object",
",",
"DynamicObject",
"if",
"objs",
":",
"objs",
"=",
"list",
"(",
"objs",
")",
"obj",
"=",
"objs",
"[",
"0"... | Create pandas DataFrame from the sequence of same-type objects.
When a list of labels is given then only retain those labels and
drop the rest. | [
"Create",
"pandas",
"DataFrame",
"from",
"the",
"sequence",
"of",
"same",
"-",
"type",
"objects",
".",
"When",
"a",
"list",
"of",
"labels",
"is",
"given",
"then",
"only",
"retain",
"those",
"labels",
"and",
"drop",
"the",
"rest",
"."
] | d0646a482590f5cb7bfddbd1f0870f8c4bc1df80 | https://github.com/erdewit/ib_insync/blob/d0646a482590f5cb7bfddbd1f0870f8c4bc1df80/ib_insync/util.py#L23-L49 | train |
erdewit/ib_insync | ib_insync/util.py | tree | def tree(obj):
"""
Convert object to a tree of lists, dicts and simple values.
The result can be serialized to JSON.
"""
from .objects import Object
if isinstance(obj, (bool, int, float, str, bytes)):
return obj
elif isinstance(obj, (datetime.date, datetime.time)):
return obj... | python | def tree(obj):
"""
Convert object to a tree of lists, dicts and simple values.
The result can be serialized to JSON.
"""
from .objects import Object
if isinstance(obj, (bool, int, float, str, bytes)):
return obj
elif isinstance(obj, (datetime.date, datetime.time)):
return obj... | [
"def",
"tree",
"(",
"obj",
")",
":",
"from",
".",
"objects",
"import",
"Object",
"if",
"isinstance",
"(",
"obj",
",",
"(",
"bool",
",",
"int",
",",
"float",
",",
"str",
",",
"bytes",
")",
")",
":",
"return",
"obj",
"elif",
"isinstance",
"(",
"obj",... | Convert object to a tree of lists, dicts and simple values.
The result can be serialized to JSON. | [
"Convert",
"object",
"to",
"a",
"tree",
"of",
"lists",
"dicts",
"and",
"simple",
"values",
".",
"The",
"result",
"can",
"be",
"serialized",
"to",
"JSON",
"."
] | d0646a482590f5cb7bfddbd1f0870f8c4bc1df80 | https://github.com/erdewit/ib_insync/blob/d0646a482590f5cb7bfddbd1f0870f8c4bc1df80/ib_insync/util.py#L52-L69 | train |
erdewit/ib_insync | ib_insync/util.py | barplot | def barplot(bars, title='', upColor='blue', downColor='red'):
"""
Create candlestick plot for the given bars. The bars can be given as
a DataFrame or as a list of bar objects.
"""
import pandas as pd
import matplotlib.pyplot as plt
from matplotlib.lines import Line2D
from matplotlib.patc... | python | def barplot(bars, title='', upColor='blue', downColor='red'):
"""
Create candlestick plot for the given bars. The bars can be given as
a DataFrame or as a list of bar objects.
"""
import pandas as pd
import matplotlib.pyplot as plt
from matplotlib.lines import Line2D
from matplotlib.patc... | [
"def",
"barplot",
"(",
"bars",
",",
"title",
"=",
"''",
",",
"upColor",
"=",
"'blue'",
",",
"downColor",
"=",
"'red'",
")",
":",
"import",
"pandas",
"as",
"pd",
"import",
"matplotlib",
".",
"pyplot",
"as",
"plt",
"from",
"matplotlib",
".",
"lines",
"im... | Create candlestick plot for the given bars. The bars can be given as
a DataFrame or as a list of bar objects. | [
"Create",
"candlestick",
"plot",
"for",
"the",
"given",
"bars",
".",
"The",
"bars",
"can",
"be",
"given",
"as",
"a",
"DataFrame",
"or",
"as",
"a",
"list",
"of",
"bar",
"objects",
"."
] | d0646a482590f5cb7bfddbd1f0870f8c4bc1df80 | https://github.com/erdewit/ib_insync/blob/d0646a482590f5cb7bfddbd1f0870f8c4bc1df80/ib_insync/util.py#L72-L125 | train |
erdewit/ib_insync | ib_insync/util.py | logToFile | def logToFile(path, level=logging.INFO):
"""
Create a log handler that logs to the given file.
"""
logger = logging.getLogger()
logger.setLevel(level)
formatter = logging.Formatter(
'%(asctime)s %(name)s %(levelname)s %(message)s')
handler = logging.FileHandler(path)
handler.setF... | python | def logToFile(path, level=logging.INFO):
"""
Create a log handler that logs to the given file.
"""
logger = logging.getLogger()
logger.setLevel(level)
formatter = logging.Formatter(
'%(asctime)s %(name)s %(levelname)s %(message)s')
handler = logging.FileHandler(path)
handler.setF... | [
"def",
"logToFile",
"(",
"path",
",",
"level",
"=",
"logging",
".",
"INFO",
")",
":",
"logger",
"=",
"logging",
".",
"getLogger",
"(",
")",
"logger",
".",
"setLevel",
"(",
"level",
")",
"formatter",
"=",
"logging",
".",
"Formatter",
"(",
"'%(asctime)s %(... | Create a log handler that logs to the given file. | [
"Create",
"a",
"log",
"handler",
"that",
"logs",
"to",
"the",
"given",
"file",
"."
] | d0646a482590f5cb7bfddbd1f0870f8c4bc1df80 | https://github.com/erdewit/ib_insync/blob/d0646a482590f5cb7bfddbd1f0870f8c4bc1df80/ib_insync/util.py#L135-L145 | train |
erdewit/ib_insync | ib_insync/util.py | logToConsole | def logToConsole(level=logging.INFO):
"""
Create a log handler that logs to the console.
"""
logger = logging.getLogger()
logger.setLevel(level)
formatter = logging.Formatter(
'%(asctime)s %(name)s %(levelname)s %(message)s')
handler = logging.StreamHandler()
handler.setFormatter... | python | def logToConsole(level=logging.INFO):
"""
Create a log handler that logs to the console.
"""
logger = logging.getLogger()
logger.setLevel(level)
formatter = logging.Formatter(
'%(asctime)s %(name)s %(levelname)s %(message)s')
handler = logging.StreamHandler()
handler.setFormatter... | [
"def",
"logToConsole",
"(",
"level",
"=",
"logging",
".",
"INFO",
")",
":",
"logger",
"=",
"logging",
".",
"getLogger",
"(",
")",
"logger",
".",
"setLevel",
"(",
"level",
")",
"formatter",
"=",
"logging",
".",
"Formatter",
"(",
"'%(asctime)s %(name)s %(level... | Create a log handler that logs to the console. | [
"Create",
"a",
"log",
"handler",
"that",
"logs",
"to",
"the",
"console",
"."
] | d0646a482590f5cb7bfddbd1f0870f8c4bc1df80 | https://github.com/erdewit/ib_insync/blob/d0646a482590f5cb7bfddbd1f0870f8c4bc1df80/ib_insync/util.py#L148-L161 | train |
erdewit/ib_insync | ib_insync/util.py | formatSI | def formatSI(n) -> str:
"""
Format the integer or float n to 3 significant digits + SI prefix.
"""
s = ''
if n < 0:
n = -n
s += '-'
if type(n) is int and n < 1000:
s = str(n) + ' '
elif n < 1e-22:
s = '0.00 '
else:
assert n < 9.99e26
log = ... | python | def formatSI(n) -> str:
"""
Format the integer or float n to 3 significant digits + SI prefix.
"""
s = ''
if n < 0:
n = -n
s += '-'
if type(n) is int and n < 1000:
s = str(n) + ' '
elif n < 1e-22:
s = '0.00 '
else:
assert n < 9.99e26
log = ... | [
"def",
"formatSI",
"(",
"n",
")",
"->",
"str",
":",
"s",
"=",
"''",
"if",
"n",
"<",
"0",
":",
"n",
"=",
"-",
"n",
"s",
"+=",
"'-'",
"if",
"type",
"(",
"n",
")",
"is",
"int",
"and",
"n",
"<",
"1000",
":",
"s",
"=",
"str",
"(",
"n",
")",
... | Format the integer or float n to 3 significant digits + SI prefix. | [
"Format",
"the",
"integer",
"or",
"float",
"n",
"to",
"3",
"significant",
"digits",
"+",
"SI",
"prefix",
"."
] | d0646a482590f5cb7bfddbd1f0870f8c4bc1df80 | https://github.com/erdewit/ib_insync/blob/d0646a482590f5cb7bfddbd1f0870f8c4bc1df80/ib_insync/util.py#L171-L197 | train |
erdewit/ib_insync | ib_insync/util.py | run | def run(*awaitables, timeout: float = None):
"""
By default run the event loop forever.
When awaitables (like Tasks, Futures or coroutines) are given then
run the event loop until each has completed and return their results.
An optional timeout (in seconds) can be given that will raise
asyncio... | python | def run(*awaitables, timeout: float = None):
"""
By default run the event loop forever.
When awaitables (like Tasks, Futures or coroutines) are given then
run the event loop until each has completed and return their results.
An optional timeout (in seconds) can be given that will raise
asyncio... | [
"def",
"run",
"(",
"*",
"awaitables",
",",
"timeout",
":",
"float",
"=",
"None",
")",
":",
"loop",
"=",
"asyncio",
".",
"get_event_loop",
"(",
")",
"if",
"not",
"awaitables",
":",
"if",
"loop",
".",
"is_running",
"(",
")",
":",
"return",
"loop",
".",... | By default run the event loop forever.
When awaitables (like Tasks, Futures or coroutines) are given then
run the event loop until each has completed and return their results.
An optional timeout (in seconds) can be given that will raise
asyncio.TimeoutError if the awaitables are not ready within the
... | [
"By",
"default",
"run",
"the",
"event",
"loop",
"forever",
"."
] | d0646a482590f5cb7bfddbd1f0870f8c4bc1df80 | https://github.com/erdewit/ib_insync/blob/d0646a482590f5cb7bfddbd1f0870f8c4bc1df80/ib_insync/util.py#L214-L257 | train |
erdewit/ib_insync | ib_insync/util.py | schedule | def schedule(
time: Union[datetime.time, datetime.datetime],
callback: Callable, *args):
"""
Schedule the callback to be run at the given time with
the given arguments.
Args:
time: Time to run callback. If given as :py:class:`datetime.time`
then use today as date.
... | python | def schedule(
time: Union[datetime.time, datetime.datetime],
callback: Callable, *args):
"""
Schedule the callback to be run at the given time with
the given arguments.
Args:
time: Time to run callback. If given as :py:class:`datetime.time`
then use today as date.
... | [
"def",
"schedule",
"(",
"time",
":",
"Union",
"[",
"datetime",
".",
"time",
",",
"datetime",
".",
"datetime",
"]",
",",
"callback",
":",
"Callable",
",",
"*",
"args",
")",
":",
"dt",
"=",
"_fillDate",
"(",
"time",
")",
"now",
"=",
"datetime",
".",
... | Schedule the callback to be run at the given time with
the given arguments.
Args:
time: Time to run callback. If given as :py:class:`datetime.time`
then use today as date.
callback: Callable scheduled to run.
args: Arguments for to call callback with. | [
"Schedule",
"the",
"callback",
"to",
"be",
"run",
"at",
"the",
"given",
"time",
"with",
"the",
"given",
"arguments",
"."
] | d0646a482590f5cb7bfddbd1f0870f8c4bc1df80 | https://github.com/erdewit/ib_insync/blob/d0646a482590f5cb7bfddbd1f0870f8c4bc1df80/ib_insync/util.py#L269-L286 | train |
erdewit/ib_insync | ib_insync/util.py | timeRange | def timeRange(
start: datetime.time, end: datetime.time,
step: float) -> Iterator[datetime.datetime]:
"""
Iterator that waits periodically until certain time points are
reached while yielding those time points.
Args:
start: Start time, can be specified as datetime.datetime,
... | python | def timeRange(
start: datetime.time, end: datetime.time,
step: float) -> Iterator[datetime.datetime]:
"""
Iterator that waits periodically until certain time points are
reached while yielding those time points.
Args:
start: Start time, can be specified as datetime.datetime,
... | [
"def",
"timeRange",
"(",
"start",
":",
"datetime",
".",
"time",
",",
"end",
":",
"datetime",
".",
"time",
",",
"step",
":",
"float",
")",
"->",
"Iterator",
"[",
"datetime",
".",
"datetime",
"]",
":",
"assert",
"step",
">",
"0",
"start",
"=",
"_fillDa... | Iterator that waits periodically until certain time points are
reached while yielding those time points.
Args:
start: Start time, can be specified as datetime.datetime,
or as datetime.time in which case today is used as the date
end: End time, can be specified as datetime.datetime,
... | [
"Iterator",
"that",
"waits",
"periodically",
"until",
"certain",
"time",
"points",
"are",
"reached",
"while",
"yielding",
"those",
"time",
"points",
"."
] | d0646a482590f5cb7bfddbd1f0870f8c4bc1df80 | https://github.com/erdewit/ib_insync/blob/d0646a482590f5cb7bfddbd1f0870f8c4bc1df80/ib_insync/util.py#L301-L325 | train |
erdewit/ib_insync | ib_insync/util.py | timeRangeAsync | async def timeRangeAsync(
start: datetime.time, end: datetime.time,
step: float) -> AsyncIterator[datetime.datetime]:
"""
Async version of :meth:`timeRange`.
"""
assert step > 0
start = _fillDate(start)
end = _fillDate(end)
delta = datetime.timedelta(seconds=step)
t = sta... | python | async def timeRangeAsync(
start: datetime.time, end: datetime.time,
step: float) -> AsyncIterator[datetime.datetime]:
"""
Async version of :meth:`timeRange`.
"""
assert step > 0
start = _fillDate(start)
end = _fillDate(end)
delta = datetime.timedelta(seconds=step)
t = sta... | [
"async",
"def",
"timeRangeAsync",
"(",
"start",
":",
"datetime",
".",
"time",
",",
"end",
":",
"datetime",
".",
"time",
",",
"step",
":",
"float",
")",
"->",
"AsyncIterator",
"[",
"datetime",
".",
"datetime",
"]",
":",
"assert",
"step",
">",
"0",
"star... | Async version of :meth:`timeRange`. | [
"Async",
"version",
"of",
":",
"meth",
":",
"timeRange",
"."
] | d0646a482590f5cb7bfddbd1f0870f8c4bc1df80 | https://github.com/erdewit/ib_insync/blob/d0646a482590f5cb7bfddbd1f0870f8c4bc1df80/ib_insync/util.py#L343-L359 | train |
erdewit/ib_insync | ib_insync/util.py | waitUntilAsync | async def waitUntilAsync(t: datetime.time) -> bool:
"""
Async version of :meth:`waitUntil`.
"""
t = _fillDate(t)
now = datetime.datetime.now(t.tzinfo)
secs = (t - now).total_seconds()
await asyncio.sleep(secs)
return True | python | async def waitUntilAsync(t: datetime.time) -> bool:
"""
Async version of :meth:`waitUntil`.
"""
t = _fillDate(t)
now = datetime.datetime.now(t.tzinfo)
secs = (t - now).total_seconds()
await asyncio.sleep(secs)
return True | [
"async",
"def",
"waitUntilAsync",
"(",
"t",
":",
"datetime",
".",
"time",
")",
"->",
"bool",
":",
"t",
"=",
"_fillDate",
"(",
"t",
")",
"now",
"=",
"datetime",
".",
"datetime",
".",
"now",
"(",
"t",
".",
"tzinfo",
")",
"secs",
"=",
"(",
"t",
"-",... | Async version of :meth:`waitUntil`. | [
"Async",
"version",
"of",
":",
"meth",
":",
"waitUntil",
"."
] | d0646a482590f5cb7bfddbd1f0870f8c4bc1df80 | https://github.com/erdewit/ib_insync/blob/d0646a482590f5cb7bfddbd1f0870f8c4bc1df80/ib_insync/util.py#L362-L370 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.