partition stringclasses 3
values | func_name stringlengths 1 134 | docstring stringlengths 1 46.9k | path stringlengths 4 223 | original_string stringlengths 75 104k | code stringlengths 75 104k | docstring_tokens listlengths 1 1.97k | repo stringlengths 7 55 | language stringclasses 1
value | url stringlengths 87 315 | code_tokens listlengths 19 28.4k | sha stringlengths 40 40 |
|---|---|---|---|---|---|---|---|---|---|---|---|
valid | OutstationCommandHandler.Select | The Master sent a Select command to the Outstation. Handle it.
:param command: ControlRelayOutputBlock,
AnalogOutputInt16, AnalogOutputInt32, AnalogOutputFloat32, or AnalogOutputDouble64.
:param index: int
:return: CommandStatus | examples/outstation.py | def Select(self, command, index):
"""
The Master sent a Select command to the Outstation. Handle it.
:param command: ControlRelayOutputBlock,
AnalogOutputInt16, AnalogOutputInt32, AnalogOutputFloat32, or AnalogOutputDouble64.
:param index: int
:return... | def Select(self, command, index):
"""
The Master sent a Select command to the Outstation. Handle it.
:param command: ControlRelayOutputBlock,
AnalogOutputInt16, AnalogOutputInt32, AnalogOutputFloat32, or AnalogOutputDouble64.
:param index: int
:return... | [
"The",
"Master",
"sent",
"a",
"Select",
"command",
"to",
"the",
"Outstation",
".",
"Handle",
"it",
"."
] | ChargePoint/pydnp3 | python | https://github.com/ChargePoint/pydnp3/blob/5bcd8240d1fc0aa1579e71f2efcab63b4c61c547/examples/outstation.py#L231-L241 | [
"def",
"Select",
"(",
"self",
",",
"command",
",",
"index",
")",
":",
"OutstationApplication",
".",
"process_point_value",
"(",
"'Select'",
",",
"command",
",",
"index",
",",
"None",
")",
"return",
"opendnp3",
".",
"CommandStatus",
".",
"SUCCESS"
] | 5bcd8240d1fc0aa1579e71f2efcab63b4c61c547 |
valid | OutstationCommandHandler.Operate | The Master sent an Operate command to the Outstation. Handle it.
:param command: ControlRelayOutputBlock,
AnalogOutputInt16, AnalogOutputInt32, AnalogOutputFloat32, or AnalogOutputDouble64.
:param index: int
:param op_type: OperateType
:return: CommandStatus | examples/outstation.py | def Operate(self, command, index, op_type):
"""
The Master sent an Operate command to the Outstation. Handle it.
:param command: ControlRelayOutputBlock,
AnalogOutputInt16, AnalogOutputInt32, AnalogOutputFloat32, or AnalogOutputDouble64.
:param index: int
... | def Operate(self, command, index, op_type):
"""
The Master sent an Operate command to the Outstation. Handle it.
:param command: ControlRelayOutputBlock,
AnalogOutputInt16, AnalogOutputInt32, AnalogOutputFloat32, or AnalogOutputDouble64.
:param index: int
... | [
"The",
"Master",
"sent",
"an",
"Operate",
"command",
"to",
"the",
"Outstation",
".",
"Handle",
"it",
"."
] | ChargePoint/pydnp3 | python | https://github.com/ChargePoint/pydnp3/blob/5bcd8240d1fc0aa1579e71f2efcab63b4c61c547/examples/outstation.py#L243-L254 | [
"def",
"Operate",
"(",
"self",
",",
"command",
",",
"index",
",",
"op_type",
")",
":",
"OutstationApplication",
".",
"process_point_value",
"(",
"'Operate'",
",",
"command",
",",
"index",
",",
"op_type",
")",
"return",
"opendnp3",
".",
"CommandStatus",
".",
... | 5bcd8240d1fc0aa1579e71f2efcab63b4c61c547 |
valid | OutstationCmd.do_a | Send the Master an AnalogInput (group 32) value. Command syntax is: a index value | examples/outstation_cmd.py | def do_a(self, line):
"""Send the Master an AnalogInput (group 32) value. Command syntax is: a index value"""
index, value_string = self.index_and_value_from_line(line)
if index and value_string:
try:
self.application.apply_update(opendnp3.Analog(float(value_string)),... | def do_a(self, line):
"""Send the Master an AnalogInput (group 32) value. Command syntax is: a index value"""
index, value_string = self.index_and_value_from_line(line)
if index and value_string:
try:
self.application.apply_update(opendnp3.Analog(float(value_string)),... | [
"Send",
"the",
"Master",
"an",
"AnalogInput",
"(",
"group",
"32",
")",
"value",
".",
"Command",
"syntax",
"is",
":",
"a",
"index",
"value"
] | ChargePoint/pydnp3 | python | https://github.com/ChargePoint/pydnp3/blob/5bcd8240d1fc0aa1579e71f2efcab63b4c61c547/examples/outstation_cmd.py#L37-L44 | [
"def",
"do_a",
"(",
"self",
",",
"line",
")",
":",
"index",
",",
"value_string",
"=",
"self",
".",
"index_and_value_from_line",
"(",
"line",
")",
"if",
"index",
"and",
"value_string",
":",
"try",
":",
"self",
".",
"application",
".",
"apply_update",
"(",
... | 5bcd8240d1fc0aa1579e71f2efcab63b4c61c547 |
valid | OutstationCmd.do_b | Send the Master a BinaryInput (group 2) value. Command syntax is: 'b index true' or 'b index false | examples/outstation_cmd.py | def do_b(self, line):
"""Send the Master a BinaryInput (group 2) value. Command syntax is: 'b index true' or 'b index false'"""
index, value_string = self.index_and_value_from_line(line)
if index and value_string:
if value_string.lower() == 'true' or value_string.lower() == 'false':
... | def do_b(self, line):
"""Send the Master a BinaryInput (group 2) value. Command syntax is: 'b index true' or 'b index false'"""
index, value_string = self.index_and_value_from_line(line)
if index and value_string:
if value_string.lower() == 'true' or value_string.lower() == 'false':
... | [
"Send",
"the",
"Master",
"a",
"BinaryInput",
"(",
"group",
"2",
")",
"value",
".",
"Command",
"syntax",
"is",
":",
"b",
"index",
"true",
"or",
"b",
"index",
"false"
] | ChargePoint/pydnp3 | python | https://github.com/ChargePoint/pydnp3/blob/5bcd8240d1fc0aa1579e71f2efcab63b4c61c547/examples/outstation_cmd.py#L50-L57 | [
"def",
"do_b",
"(",
"self",
",",
"line",
")",
":",
"index",
",",
"value_string",
"=",
"self",
".",
"index_and_value_from_line",
"(",
"line",
")",
"if",
"index",
"and",
"value_string",
":",
"if",
"value_string",
".",
"lower",
"(",
")",
"==",
"'true'",
"or... | 5bcd8240d1fc0aa1579e71f2efcab63b4c61c547 |
valid | OutstationCmd.do_b0 | Send the Master a BinaryInput (group 2) value of False at index 6. Command syntax is: b0 | examples/outstation_cmd.py | def do_b0(self, line):
"""Send the Master a BinaryInput (group 2) value of False at index 6. Command syntax is: b0"""
self.application.apply_update(opendnp3.Binary(False), index=6) | def do_b0(self, line):
"""Send the Master a BinaryInput (group 2) value of False at index 6. Command syntax is: b0"""
self.application.apply_update(opendnp3.Binary(False), index=6) | [
"Send",
"the",
"Master",
"a",
"BinaryInput",
"(",
"group",
"2",
")",
"value",
"of",
"False",
"at",
"index",
"6",
".",
"Command",
"syntax",
"is",
":",
"b0"
] | ChargePoint/pydnp3 | python | https://github.com/ChargePoint/pydnp3/blob/5bcd8240d1fc0aa1579e71f2efcab63b4c61c547/examples/outstation_cmd.py#L59-L61 | [
"def",
"do_b0",
"(",
"self",
",",
"line",
")",
":",
"self",
".",
"application",
".",
"apply_update",
"(",
"opendnp3",
".",
"Binary",
"(",
"False",
")",
",",
"index",
"=",
"6",
")"
] | 5bcd8240d1fc0aa1579e71f2efcab63b4c61c547 |
valid | OutstationCmd.do_c | Send the Master a Counter (group 22) value. Command syntax is: c index value | examples/outstation_cmd.py | def do_c(self, line):
"""Send the Master a Counter (group 22) value. Command syntax is: c index value"""
index, value_string = self.index_and_value_from_line(line)
if index and value_string:
try:
self.application.apply_update(opendnp3.Counter(int(value_string)), index... | def do_c(self, line):
"""Send the Master a Counter (group 22) value. Command syntax is: c index value"""
index, value_string = self.index_and_value_from_line(line)
if index and value_string:
try:
self.application.apply_update(opendnp3.Counter(int(value_string)), index... | [
"Send",
"the",
"Master",
"a",
"Counter",
"(",
"group",
"22",
")",
"value",
".",
"Command",
"syntax",
"is",
":",
"c",
"index",
"value"
] | ChargePoint/pydnp3 | python | https://github.com/ChargePoint/pydnp3/blob/5bcd8240d1fc0aa1579e71f2efcab63b4c61c547/examples/outstation_cmd.py#L63-L70 | [
"def",
"do_c",
"(",
"self",
",",
"line",
")",
":",
"index",
",",
"value_string",
"=",
"self",
".",
"index_and_value_from_line",
"(",
"line",
")",
"if",
"index",
"and",
"value_string",
":",
"try",
":",
"self",
".",
"application",
".",
"apply_update",
"(",
... | 5bcd8240d1fc0aa1579e71f2efcab63b4c61c547 |
valid | OutstationCmd.do_d | Send the Master a DoubleBitBinaryInput (group 4) value of DETERMINED_ON. Command syntax is: d index | examples/outstation_cmd.py | def do_d(self, line):
"""Send the Master a DoubleBitBinaryInput (group 4) value of DETERMINED_ON. Command syntax is: d index"""
index = self.index_from_line(line)
if index:
self.application.apply_update(opendnp3.DoubleBitBinary(opendnp3.DoubleBit.DETERMINED_ON), index) | def do_d(self, line):
"""Send the Master a DoubleBitBinaryInput (group 4) value of DETERMINED_ON. Command syntax is: d index"""
index = self.index_from_line(line)
if index:
self.application.apply_update(opendnp3.DoubleBitBinary(opendnp3.DoubleBit.DETERMINED_ON), index) | [
"Send",
"the",
"Master",
"a",
"DoubleBitBinaryInput",
"(",
"group",
"4",
")",
"value",
"of",
"DETERMINED_ON",
".",
"Command",
"syntax",
"is",
":",
"d",
"index"
] | ChargePoint/pydnp3 | python | https://github.com/ChargePoint/pydnp3/blob/5bcd8240d1fc0aa1579e71f2efcab63b4c61c547/examples/outstation_cmd.py#L72-L76 | [
"def",
"do_d",
"(",
"self",
",",
"line",
")",
":",
"index",
"=",
"self",
".",
"index_from_line",
"(",
"line",
")",
"if",
"index",
":",
"self",
".",
"application",
".",
"apply_update",
"(",
"opendnp3",
".",
"DoubleBitBinary",
"(",
"opendnp3",
".",
"Double... | 5bcd8240d1fc0aa1579e71f2efcab63b4c61c547 |
valid | OutstationCmd.do_menu | Display a menu of command-line options. Command syntax is: menu | examples/outstation_cmd.py | def do_menu(self, line):
"""Display a menu of command-line options. Command syntax is: menu"""
print('\ta\t\tAnalog measurement.\tEnter index and value as arguments.')
print('\ta2\t\tAnalog 2 for MMDC.Vol (index 4).')
print('\tb\t\tBinary measurement.\tEnter index and value as arguments.... | def do_menu(self, line):
"""Display a menu of command-line options. Command syntax is: menu"""
print('\ta\t\tAnalog measurement.\tEnter index and value as arguments.')
print('\ta2\t\tAnalog 2 for MMDC.Vol (index 4).')
print('\tb\t\tBinary measurement.\tEnter index and value as arguments.... | [
"Display",
"a",
"menu",
"of",
"command",
"-",
"line",
"options",
".",
"Command",
"syntax",
"is",
":",
"menu"
] | ChargePoint/pydnp3 | python | https://github.com/ChargePoint/pydnp3/blob/5bcd8240d1fc0aa1579e71f2efcab63b4c61c547/examples/outstation_cmd.py#L78-L88 | [
"def",
"do_menu",
"(",
"self",
",",
"line",
")",
":",
"print",
"(",
"'\\ta\\t\\tAnalog measurement.\\tEnter index and value as arguments.'",
")",
"print",
"(",
"'\\ta2\\t\\tAnalog 2 for MMDC.Vol (index 4).'",
")",
"print",
"(",
"'\\tb\\t\\tBinary measurement.\\tEnter index and va... | 5bcd8240d1fc0aa1579e71f2efcab63b4c61c547 |
valid | OutstationCmd.index_and_value_from_line | Parse an index (integer) and value (string) from command line args and return them. | examples/outstation_cmd.py | def index_and_value_from_line(line):
"""Parse an index (integer) and value (string) from command line args and return them."""
try:
index = int(line.split(' ')[0])
except (ValueError, IndexError):
print('Please enter an integer index as the first argument.')
i... | def index_and_value_from_line(line):
"""Parse an index (integer) and value (string) from command line args and return them."""
try:
index = int(line.split(' ')[0])
except (ValueError, IndexError):
print('Please enter an integer index as the first argument.')
i... | [
"Parse",
"an",
"index",
"(",
"integer",
")",
"and",
"value",
"(",
"string",
")",
"from",
"command",
"line",
"args",
"and",
"return",
"them",
"."
] | ChargePoint/pydnp3 | python | https://github.com/ChargePoint/pydnp3/blob/5bcd8240d1fc0aa1579e71f2efcab63b4c61c547/examples/outstation_cmd.py#L96-L108 | [
"def",
"index_and_value_from_line",
"(",
"line",
")",
":",
"try",
":",
"index",
"=",
"int",
"(",
"line",
".",
"split",
"(",
"' '",
")",
"[",
"0",
"]",
")",
"except",
"(",
"ValueError",
",",
"IndexError",
")",
":",
"print",
"(",
"'Please enter an integer ... | 5bcd8240d1fc0aa1579e71f2efcab63b4c61c547 |
valid | OutstationCmd.index_from_line | Parse an index (integer) from command line args and return it. | examples/outstation_cmd.py | def index_from_line(line):
"""Parse an index (integer) from command line args and return it."""
try:
index = int(line.split(' ')[0])
except (ValueError, IndexError):
print('Please enter an integer index as the first argument.')
index = None
return inde... | def index_from_line(line):
"""Parse an index (integer) from command line args and return it."""
try:
index = int(line.split(' ')[0])
except (ValueError, IndexError):
print('Please enter an integer index as the first argument.')
index = None
return inde... | [
"Parse",
"an",
"index",
"(",
"integer",
")",
"from",
"command",
"line",
"args",
"and",
"return",
"it",
"."
] | ChargePoint/pydnp3 | python | https://github.com/ChargePoint/pydnp3/blob/5bcd8240d1fc0aa1579e71f2efcab63b4c61c547/examples/outstation_cmd.py#L111-L118 | [
"def",
"index_from_line",
"(",
"line",
")",
":",
"try",
":",
"index",
"=",
"int",
"(",
"line",
".",
"split",
"(",
"' '",
")",
"[",
"0",
"]",
")",
"except",
"(",
"ValueError",
",",
"IndexError",
")",
":",
"print",
"(",
"'Please enter an integer index as t... | 5bcd8240d1fc0aa1579e71f2efcab63b4c61c547 |
valid | MasterCmd.do_menu | Display a menu of command-line options. Command syntax is: menu | examples/master_cmd.py | def do_menu(self, line):
"""Display a menu of command-line options. Command syntax is: menu"""
print('\tchan_log_all\tSet the channel log level to ALL_COMMS.')
print('\tchan_log_normal\tSet the channel log level to NORMAL.')
print('\tdisable_unsol\tPerform the function DISABLE_UNSOLICITE... | def do_menu(self, line):
"""Display a menu of command-line options. Command syntax is: menu"""
print('\tchan_log_all\tSet the channel log level to ALL_COMMS.')
print('\tchan_log_normal\tSet the channel log level to NORMAL.')
print('\tdisable_unsol\tPerform the function DISABLE_UNSOLICITE... | [
"Display",
"a",
"menu",
"of",
"command",
"-",
"line",
"options",
".",
"Command",
"syntax",
"is",
":",
"menu"
] | ChargePoint/pydnp3 | python | https://github.com/ChargePoint/pydnp3/blob/5bcd8240d1fc0aa1579e71f2efcab63b4c61c547/examples/master_cmd.py#L41-L61 | [
"def",
"do_menu",
"(",
"self",
",",
"line",
")",
":",
"print",
"(",
"'\\tchan_log_all\\tSet the channel log level to ALL_COMMS.'",
")",
"print",
"(",
"'\\tchan_log_normal\\tSet the channel log level to NORMAL.'",
")",
"print",
"(",
"'\\tdisable_unsol\\tPerform the function DISABL... | 5bcd8240d1fc0aa1579e71f2efcab63b4c61c547 |
valid | MasterCmd.do_chan_log_all | Set the channel log level to ALL_COMMS. Command syntax is: chan_log_all | examples/master_cmd.py | def do_chan_log_all(self, line):
"""Set the channel log level to ALL_COMMS. Command syntax is: chan_log_all"""
self.application.channel.SetLogFilters(openpal.LogFilters(opendnp3.levels.ALL_COMMS))
print('Channel log filtering level is now: {0}'.format(opendnp3.levels.ALL_COMMS)) | def do_chan_log_all(self, line):
"""Set the channel log level to ALL_COMMS. Command syntax is: chan_log_all"""
self.application.channel.SetLogFilters(openpal.LogFilters(opendnp3.levels.ALL_COMMS))
print('Channel log filtering level is now: {0}'.format(opendnp3.levels.ALL_COMMS)) | [
"Set",
"the",
"channel",
"log",
"level",
"to",
"ALL_COMMS",
".",
"Command",
"syntax",
"is",
":",
"chan_log_all"
] | ChargePoint/pydnp3 | python | https://github.com/ChargePoint/pydnp3/blob/5bcd8240d1fc0aa1579e71f2efcab63b4c61c547/examples/master_cmd.py#L63-L66 | [
"def",
"do_chan_log_all",
"(",
"self",
",",
"line",
")",
":",
"self",
".",
"application",
".",
"channel",
".",
"SetLogFilters",
"(",
"openpal",
".",
"LogFilters",
"(",
"opendnp3",
".",
"levels",
".",
"ALL_COMMS",
")",
")",
"print",
"(",
"'Channel log filteri... | 5bcd8240d1fc0aa1579e71f2efcab63b4c61c547 |
valid | MasterCmd.do_chan_log_normal | Set the channel log level to NORMAL. Command syntax is: chan_log_normal | examples/master_cmd.py | def do_chan_log_normal(self, line):
"""Set the channel log level to NORMAL. Command syntax is: chan_log_normal"""
self.application.channel.SetLogFilters(openpal.LogFilters(opendnp3.levels.NORMAL))
print('Channel log filtering level is now: {0}'.format(opendnp3.levels.NORMAL)) | def do_chan_log_normal(self, line):
"""Set the channel log level to NORMAL. Command syntax is: chan_log_normal"""
self.application.channel.SetLogFilters(openpal.LogFilters(opendnp3.levels.NORMAL))
print('Channel log filtering level is now: {0}'.format(opendnp3.levels.NORMAL)) | [
"Set",
"the",
"channel",
"log",
"level",
"to",
"NORMAL",
".",
"Command",
"syntax",
"is",
":",
"chan_log_normal"
] | ChargePoint/pydnp3 | python | https://github.com/ChargePoint/pydnp3/blob/5bcd8240d1fc0aa1579e71f2efcab63b4c61c547/examples/master_cmd.py#L68-L71 | [
"def",
"do_chan_log_normal",
"(",
"self",
",",
"line",
")",
":",
"self",
".",
"application",
".",
"channel",
".",
"SetLogFilters",
"(",
"openpal",
".",
"LogFilters",
"(",
"opendnp3",
".",
"levels",
".",
"NORMAL",
")",
")",
"print",
"(",
"'Channel log filteri... | 5bcd8240d1fc0aa1579e71f2efcab63b4c61c547 |
valid | MasterCmd.do_disable_unsol | Perform the function DISABLE_UNSOLICITED. Command syntax is: disable_unsol | examples/master_cmd.py | def do_disable_unsol(self, line):
"""Perform the function DISABLE_UNSOLICITED. Command syntax is: disable_unsol"""
headers = [opendnp3.Header().AllObjects(60, 2),
opendnp3.Header().AllObjects(60, 3),
opendnp3.Header().AllObjects(60, 4)]
self.application.mast... | def do_disable_unsol(self, line):
"""Perform the function DISABLE_UNSOLICITED. Command syntax is: disable_unsol"""
headers = [opendnp3.Header().AllObjects(60, 2),
opendnp3.Header().AllObjects(60, 3),
opendnp3.Header().AllObjects(60, 4)]
self.application.mast... | [
"Perform",
"the",
"function",
"DISABLE_UNSOLICITED",
".",
"Command",
"syntax",
"is",
":",
"disable_unsol"
] | ChargePoint/pydnp3 | python | https://github.com/ChargePoint/pydnp3/blob/5bcd8240d1fc0aa1579e71f2efcab63b4c61c547/examples/master_cmd.py#L73-L81 | [
"def",
"do_disable_unsol",
"(",
"self",
",",
"line",
")",
":",
"headers",
"=",
"[",
"opendnp3",
".",
"Header",
"(",
")",
".",
"AllObjects",
"(",
"60",
",",
"2",
")",
",",
"opendnp3",
".",
"Header",
"(",
")",
".",
"AllObjects",
"(",
"60",
",",
"3",
... | 5bcd8240d1fc0aa1579e71f2efcab63b4c61c547 |
valid | MasterCmd.do_mast_log_all | Set the master log level to ALL_COMMS. Command syntax is: mast_log_all | examples/master_cmd.py | def do_mast_log_all(self, line):
"""Set the master log level to ALL_COMMS. Command syntax is: mast_log_all"""
self.application.master.SetLogFilters(openpal.LogFilters(opendnp3.levels.ALL_COMMS))
_log.debug('Master log filtering level is now: {0}'.format(opendnp3.levels.ALL_COMMS)) | def do_mast_log_all(self, line):
"""Set the master log level to ALL_COMMS. Command syntax is: mast_log_all"""
self.application.master.SetLogFilters(openpal.LogFilters(opendnp3.levels.ALL_COMMS))
_log.debug('Master log filtering level is now: {0}'.format(opendnp3.levels.ALL_COMMS)) | [
"Set",
"the",
"master",
"log",
"level",
"to",
"ALL_COMMS",
".",
"Command",
"syntax",
"is",
":",
"mast_log_all"
] | ChargePoint/pydnp3 | python | https://github.com/ChargePoint/pydnp3/blob/5bcd8240d1fc0aa1579e71f2efcab63b4c61c547/examples/master_cmd.py#L83-L86 | [
"def",
"do_mast_log_all",
"(",
"self",
",",
"line",
")",
":",
"self",
".",
"application",
".",
"master",
".",
"SetLogFilters",
"(",
"openpal",
".",
"LogFilters",
"(",
"opendnp3",
".",
"levels",
".",
"ALL_COMMS",
")",
")",
"_log",
".",
"debug",
"(",
"'Mas... | 5bcd8240d1fc0aa1579e71f2efcab63b4c61c547 |
valid | MasterCmd.do_mast_log_normal | Set the master log level to NORMAL. Command syntax is: mast_log_normal | examples/master_cmd.py | def do_mast_log_normal(self, line):
"""Set the master log level to NORMAL. Command syntax is: mast_log_normal"""
self.application.master.SetLogFilters(openpal.LogFilters(opendnp3.levels.NORMAL))
_log.debug('Master log filtering level is now: {0}'.format(opendnp3.levels.NORMAL)) | def do_mast_log_normal(self, line):
"""Set the master log level to NORMAL. Command syntax is: mast_log_normal"""
self.application.master.SetLogFilters(openpal.LogFilters(opendnp3.levels.NORMAL))
_log.debug('Master log filtering level is now: {0}'.format(opendnp3.levels.NORMAL)) | [
"Set",
"the",
"master",
"log",
"level",
"to",
"NORMAL",
".",
"Command",
"syntax",
"is",
":",
"mast_log_normal"
] | ChargePoint/pydnp3 | python | https://github.com/ChargePoint/pydnp3/blob/5bcd8240d1fc0aa1579e71f2efcab63b4c61c547/examples/master_cmd.py#L88-L91 | [
"def",
"do_mast_log_normal",
"(",
"self",
",",
"line",
")",
":",
"self",
".",
"application",
".",
"master",
".",
"SetLogFilters",
"(",
"openpal",
".",
"LogFilters",
"(",
"opendnp3",
".",
"levels",
".",
"NORMAL",
")",
")",
"_log",
".",
"debug",
"(",
"'Mas... | 5bcd8240d1fc0aa1579e71f2efcab63b4c61c547 |
valid | MasterCmd.do_o1 | Send a DirectOperate BinaryOutput (group 12) index 5 LATCH_ON to the Outstation. Command syntax is: o1 | examples/master_cmd.py | def do_o1(self, line):
"""Send a DirectOperate BinaryOutput (group 12) index 5 LATCH_ON to the Outstation. Command syntax is: o1"""
self.application.send_direct_operate_command(opendnp3.ControlRelayOutputBlock(opendnp3.ControlCode.LATCH_ON),
5,
... | def do_o1(self, line):
"""Send a DirectOperate BinaryOutput (group 12) index 5 LATCH_ON to the Outstation. Command syntax is: o1"""
self.application.send_direct_operate_command(opendnp3.ControlRelayOutputBlock(opendnp3.ControlCode.LATCH_ON),
5,
... | [
"Send",
"a",
"DirectOperate",
"BinaryOutput",
"(",
"group",
"12",
")",
"index",
"5",
"LATCH_ON",
"to",
"the",
"Outstation",
".",
"Command",
"syntax",
"is",
":",
"o1"
] | ChargePoint/pydnp3 | python | https://github.com/ChargePoint/pydnp3/blob/5bcd8240d1fc0aa1579e71f2efcab63b4c61c547/examples/master_cmd.py#L93-L97 | [
"def",
"do_o1",
"(",
"self",
",",
"line",
")",
":",
"self",
".",
"application",
".",
"send_direct_operate_command",
"(",
"opendnp3",
".",
"ControlRelayOutputBlock",
"(",
"opendnp3",
".",
"ControlCode",
".",
"LATCH_ON",
")",
",",
"5",
",",
"command_callback",
"... | 5bcd8240d1fc0aa1579e71f2efcab63b4c61c547 |
valid | MasterCmd.do_o3 | Send a DirectOperate BinaryOutput (group 12) CommandSet to the Outstation. Command syntax is: o3 | examples/master_cmd.py | def do_o3(self, line):
"""Send a DirectOperate BinaryOutput (group 12) CommandSet to the Outstation. Command syntax is: o3"""
self.application.send_direct_operate_command_set(opendnp3.CommandSet(
[
opendnp3.WithIndex(opendnp3.ControlRelayOutputBlock(opendnp3.ControlCode.LATCH... | def do_o3(self, line):
"""Send a DirectOperate BinaryOutput (group 12) CommandSet to the Outstation. Command syntax is: o3"""
self.application.send_direct_operate_command_set(opendnp3.CommandSet(
[
opendnp3.WithIndex(opendnp3.ControlRelayOutputBlock(opendnp3.ControlCode.LATCH... | [
"Send",
"a",
"DirectOperate",
"BinaryOutput",
"(",
"group",
"12",
")",
"CommandSet",
"to",
"the",
"Outstation",
".",
"Command",
"syntax",
"is",
":",
"o3"
] | ChargePoint/pydnp3 | python | https://github.com/ChargePoint/pydnp3/blob/5bcd8240d1fc0aa1579e71f2efcab63b4c61c547/examples/master_cmd.py#L105-L113 | [
"def",
"do_o3",
"(",
"self",
",",
"line",
")",
":",
"self",
".",
"application",
".",
"send_direct_operate_command_set",
"(",
"opendnp3",
".",
"CommandSet",
"(",
"[",
"opendnp3",
".",
"WithIndex",
"(",
"opendnp3",
".",
"ControlRelayOutputBlock",
"(",
"opendnp3",
... | 5bcd8240d1fc0aa1579e71f2efcab63b4c61c547 |
valid | MasterCmd.do_restart | Request that the Outstation perform a cold restart. Command syntax is: restart | examples/master_cmd.py | def do_restart(self, line):
"""Request that the Outstation perform a cold restart. Command syntax is: restart"""
self.application.master.Restart(opendnp3.RestartType.COLD, restart_callback) | def do_restart(self, line):
"""Request that the Outstation perform a cold restart. Command syntax is: restart"""
self.application.master.Restart(opendnp3.RestartType.COLD, restart_callback) | [
"Request",
"that",
"the",
"Outstation",
"perform",
"a",
"cold",
"restart",
".",
"Command",
"syntax",
"is",
":",
"restart"
] | ChargePoint/pydnp3 | python | https://github.com/ChargePoint/pydnp3/blob/5bcd8240d1fc0aa1579e71f2efcab63b4c61c547/examples/master_cmd.py#L123-L125 | [
"def",
"do_restart",
"(",
"self",
",",
"line",
")",
":",
"self",
".",
"application",
".",
"master",
".",
"Restart",
"(",
"opendnp3",
".",
"RestartType",
".",
"COLD",
",",
"restart_callback",
")"
] | 5bcd8240d1fc0aa1579e71f2efcab63b4c61c547 |
valid | MasterCmd.do_s1 | Send a SelectAndOperate BinaryOutput (group 12) index 8 LATCH_ON to the Outstation. Command syntax is: s1 | examples/master_cmd.py | def do_s1(self, line):
"""Send a SelectAndOperate BinaryOutput (group 12) index 8 LATCH_ON to the Outstation. Command syntax is: s1"""
self.application.send_select_and_operate_command(opendnp3.ControlRelayOutputBlock(opendnp3.ControlCode.LATCH_ON),
... | def do_s1(self, line):
"""Send a SelectAndOperate BinaryOutput (group 12) index 8 LATCH_ON to the Outstation. Command syntax is: s1"""
self.application.send_select_and_operate_command(opendnp3.ControlRelayOutputBlock(opendnp3.ControlCode.LATCH_ON),
... | [
"Send",
"a",
"SelectAndOperate",
"BinaryOutput",
"(",
"group",
"12",
")",
"index",
"8",
"LATCH_ON",
"to",
"the",
"Outstation",
".",
"Command",
"syntax",
"is",
":",
"s1"
] | ChargePoint/pydnp3 | python | https://github.com/ChargePoint/pydnp3/blob/5bcd8240d1fc0aa1579e71f2efcab63b4c61c547/examples/master_cmd.py#L127-L131 | [
"def",
"do_s1",
"(",
"self",
",",
"line",
")",
":",
"self",
".",
"application",
".",
"send_select_and_operate_command",
"(",
"opendnp3",
".",
"ControlRelayOutputBlock",
"(",
"opendnp3",
".",
"ControlCode",
".",
"LATCH_ON",
")",
",",
"8",
",",
"command_callback",... | 5bcd8240d1fc0aa1579e71f2efcab63b4c61c547 |
valid | MasterCmd.do_s2 | Send a SelectAndOperate BinaryOutput (group 12) CommandSet to the Outstation. Command syntax is: s2 | examples/master_cmd.py | def do_s2(self, line):
"""Send a SelectAndOperate BinaryOutput (group 12) CommandSet to the Outstation. Command syntax is: s2"""
self.application.send_select_and_operate_command_set(opendnp3.CommandSet(
[
opendnp3.WithIndex(opendnp3.ControlRelayOutputBlock(opendnp3.ControlCod... | def do_s2(self, line):
"""Send a SelectAndOperate BinaryOutput (group 12) CommandSet to the Outstation. Command syntax is: s2"""
self.application.send_select_and_operate_command_set(opendnp3.CommandSet(
[
opendnp3.WithIndex(opendnp3.ControlRelayOutputBlock(opendnp3.ControlCod... | [
"Send",
"a",
"SelectAndOperate",
"BinaryOutput",
"(",
"group",
"12",
")",
"CommandSet",
"to",
"the",
"Outstation",
".",
"Command",
"syntax",
"is",
":",
"s2"
] | ChargePoint/pydnp3 | python | https://github.com/ChargePoint/pydnp3/blob/5bcd8240d1fc0aa1579e71f2efcab63b4c61c547/examples/master_cmd.py#L133-L140 | [
"def",
"do_s2",
"(",
"self",
",",
"line",
")",
":",
"self",
".",
"application",
".",
"send_select_and_operate_command_set",
"(",
"opendnp3",
".",
"CommandSet",
"(",
"[",
"opendnp3",
".",
"WithIndex",
"(",
"opendnp3",
".",
"ControlRelayOutputBlock",
"(",
"opendnp... | 5bcd8240d1fc0aa1579e71f2efcab63b4c61c547 |
valid | MasterCmd.do_scan_all | Call ScanAllObjects. Command syntax is: scan_all | examples/master_cmd.py | def do_scan_all(self, line):
"""Call ScanAllObjects. Command syntax is: scan_all"""
self.application.master.ScanAllObjects(opendnp3.GroupVariationID(2, 1), opendnp3.TaskConfig().Default()) | def do_scan_all(self, line):
"""Call ScanAllObjects. Command syntax is: scan_all"""
self.application.master.ScanAllObjects(opendnp3.GroupVariationID(2, 1), opendnp3.TaskConfig().Default()) | [
"Call",
"ScanAllObjects",
".",
"Command",
"syntax",
"is",
":",
"scan_all"
] | ChargePoint/pydnp3 | python | https://github.com/ChargePoint/pydnp3/blob/5bcd8240d1fc0aa1579e71f2efcab63b4c61c547/examples/master_cmd.py#L142-L144 | [
"def",
"do_scan_all",
"(",
"self",
",",
"line",
")",
":",
"self",
".",
"application",
".",
"master",
".",
"ScanAllObjects",
"(",
"opendnp3",
".",
"GroupVariationID",
"(",
"2",
",",
"1",
")",
",",
"opendnp3",
".",
"TaskConfig",
"(",
")",
".",
"Default",
... | 5bcd8240d1fc0aa1579e71f2efcab63b4c61c547 |
valid | MasterCmd.do_scan_range | Do an ad-hoc scan of a range of points (group 1, variation 2, indexes 0-3). Command syntax is: scan_range | examples/master_cmd.py | def do_scan_range(self, line):
"""Do an ad-hoc scan of a range of points (group 1, variation 2, indexes 0-3). Command syntax is: scan_range"""
self.application.master.ScanRange(opendnp3.GroupVariationID(1, 2), 0, 3, opendnp3.TaskConfig().Default()) | def do_scan_range(self, line):
"""Do an ad-hoc scan of a range of points (group 1, variation 2, indexes 0-3). Command syntax is: scan_range"""
self.application.master.ScanRange(opendnp3.GroupVariationID(1, 2), 0, 3, opendnp3.TaskConfig().Default()) | [
"Do",
"an",
"ad",
"-",
"hoc",
"scan",
"of",
"a",
"range",
"of",
"points",
"(",
"group",
"1",
"variation",
"2",
"indexes",
"0",
"-",
"3",
")",
".",
"Command",
"syntax",
"is",
":",
"scan_range"
] | ChargePoint/pydnp3 | python | https://github.com/ChargePoint/pydnp3/blob/5bcd8240d1fc0aa1579e71f2efcab63b4c61c547/examples/master_cmd.py#L150-L152 | [
"def",
"do_scan_range",
"(",
"self",
",",
"line",
")",
":",
"self",
".",
"application",
".",
"master",
".",
"ScanRange",
"(",
"opendnp3",
".",
"GroupVariationID",
"(",
"1",
",",
"2",
")",
",",
"0",
",",
"3",
",",
"opendnp3",
".",
"TaskConfig",
"(",
"... | 5bcd8240d1fc0aa1579e71f2efcab63b4c61c547 |
valid | MasterCmd.do_write_time | Write a TimeAndInterval to the Outstation. Command syntax is: write_time | examples/master_cmd.py | def do_write_time(self, line):
"""Write a TimeAndInterval to the Outstation. Command syntax is: write_time"""
millis_since_epoch = int((datetime.now() - datetime.utcfromtimestamp(0)).total_seconds() * 1000.0)
self.application.master.Write(opendnp3.TimeAndInterval(opendnp3.DNPTime(millis_since_ep... | def do_write_time(self, line):
"""Write a TimeAndInterval to the Outstation. Command syntax is: write_time"""
millis_since_epoch = int((datetime.now() - datetime.utcfromtimestamp(0)).total_seconds() * 1000.0)
self.application.master.Write(opendnp3.TimeAndInterval(opendnp3.DNPTime(millis_since_ep... | [
"Write",
"a",
"TimeAndInterval",
"to",
"the",
"Outstation",
".",
"Command",
"syntax",
"is",
":",
"write_time"
] | ChargePoint/pydnp3 | python | https://github.com/ChargePoint/pydnp3/blob/5bcd8240d1fc0aa1579e71f2efcab63b4c61c547/examples/master_cmd.py#L158-L165 | [
"def",
"do_write_time",
"(",
"self",
",",
"line",
")",
":",
"millis_since_epoch",
"=",
"int",
"(",
"(",
"datetime",
".",
"now",
"(",
")",
"-",
"datetime",
".",
"utcfromtimestamp",
"(",
"0",
")",
")",
".",
"total_seconds",
"(",
")",
"*",
"1000.0",
")",
... | 5bcd8240d1fc0aa1579e71f2efcab63b4c61c547 |
valid | with_bloomberg | Wrapper function for Bloomberg connection
Args:
func: function to wrap | xbbg/core/conn.py | def with_bloomberg(func):
"""
Wrapper function for Bloomberg connection
Args:
func: function to wrap
"""
@wraps(func)
def wrapper(*args, **kwargs):
scope = utils.func_scope(func=func)
param = inspect.signature(func).parameters
port = kwargs.pop('port', _PORT_)
... | def with_bloomberg(func):
"""
Wrapper function for Bloomberg connection
Args:
func: function to wrap
"""
@wraps(func)
def wrapper(*args, **kwargs):
scope = utils.func_scope(func=func)
param = inspect.signature(func).parameters
port = kwargs.pop('port', _PORT_)
... | [
"Wrapper",
"function",
"for",
"Bloomberg",
"connection"
] | alpha-xone/xbbg | python | https://github.com/alpha-xone/xbbg/blob/70226eb19a72a08144b5d8cea9db4913200f7bc5/xbbg/core/conn.py#L26-L102 | [
"def",
"with_bloomberg",
"(",
"func",
")",
":",
"@",
"wraps",
"(",
"func",
")",
"def",
"wrapper",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"scope",
"=",
"utils",
".",
"func_scope",
"(",
"func",
"=",
"func",
")",
"param",
"=",
"inspect",... | 70226eb19a72a08144b5d8cea9db4913200f7bc5 |
valid | create_connection | Create Bloomberg connection
Returns:
(Bloomberg connection, if connection is new) | xbbg/core/conn.py | def create_connection(port=_PORT_, timeout=_TIMEOUT_, restart=False):
"""
Create Bloomberg connection
Returns:
(Bloomberg connection, if connection is new)
"""
if _CON_SYM_ in globals():
if not isinstance(globals()[_CON_SYM_], pdblp.BCon):
del globals()[_CON_SYM_]
i... | def create_connection(port=_PORT_, timeout=_TIMEOUT_, restart=False):
"""
Create Bloomberg connection
Returns:
(Bloomberg connection, if connection is new)
"""
if _CON_SYM_ in globals():
if not isinstance(globals()[_CON_SYM_], pdblp.BCon):
del globals()[_CON_SYM_]
i... | [
"Create",
"Bloomberg",
"connection"
] | alpha-xone/xbbg | python | https://github.com/alpha-xone/xbbg/blob/70226eb19a72a08144b5d8cea9db4913200f7bc5/xbbg/core/conn.py#L105-L125 | [
"def",
"create_connection",
"(",
"port",
"=",
"_PORT_",
",",
"timeout",
"=",
"_TIMEOUT_",
",",
"restart",
"=",
"False",
")",
":",
"if",
"_CON_SYM_",
"in",
"globals",
"(",
")",
":",
"if",
"not",
"isinstance",
"(",
"globals",
"(",
")",
"[",
"_CON_SYM_",
... | 70226eb19a72a08144b5d8cea9db4913200f7bc5 |
valid | delete_connection | Stop and destroy Bloomberg connection | xbbg/core/conn.py | def delete_connection():
"""
Stop and destroy Bloomberg connection
"""
if _CON_SYM_ in globals():
con = globals().pop(_CON_SYM_)
if not getattr(con, '_session').start(): con.stop() | def delete_connection():
"""
Stop and destroy Bloomberg connection
"""
if _CON_SYM_ in globals():
con = globals().pop(_CON_SYM_)
if not getattr(con, '_session').start(): con.stop() | [
"Stop",
"and",
"destroy",
"Bloomberg",
"connection"
] | alpha-xone/xbbg | python | https://github.com/alpha-xone/xbbg/blob/70226eb19a72a08144b5d8cea9db4913200f7bc5/xbbg/core/conn.py#L128-L134 | [
"def",
"delete_connection",
"(",
")",
":",
"if",
"_CON_SYM_",
"in",
"globals",
"(",
")",
":",
"con",
"=",
"globals",
"(",
")",
".",
"pop",
"(",
"_CON_SYM_",
")",
"if",
"not",
"getattr",
"(",
"con",
",",
"'_session'",
")",
".",
"start",
"(",
")",
":... | 70226eb19a72a08144b5d8cea9db4913200f7bc5 |
valid | bdp_bds_cache | Find cached `BDP` / `BDS` queries
Args:
func: function name - bdp or bds
tickers: tickers
flds: fields
**kwargs: other kwargs
Returns:
ToQuery(ticker, flds, kwargs) | xbbg/io/cached.py | def bdp_bds_cache(func, tickers, flds, **kwargs) -> ToQuery:
"""
Find cached `BDP` / `BDS` queries
Args:
func: function name - bdp or bds
tickers: tickers
flds: fields
**kwargs: other kwargs
Returns:
ToQuery(ticker, flds, kwargs)
"""
cache_data = []
... | def bdp_bds_cache(func, tickers, flds, **kwargs) -> ToQuery:
"""
Find cached `BDP` / `BDS` queries
Args:
func: function name - bdp or bds
tickers: tickers
flds: fields
**kwargs: other kwargs
Returns:
ToQuery(ticker, flds, kwargs)
"""
cache_data = []
... | [
"Find",
"cached",
"BDP",
"/",
"BDS",
"queries"
] | alpha-xone/xbbg | python | https://github.com/alpha-xone/xbbg/blob/70226eb19a72a08144b5d8cea9db4913200f7bc5/xbbg/io/cached.py#L13-L53 | [
"def",
"bdp_bds_cache",
"(",
"func",
",",
"tickers",
",",
"flds",
",",
"*",
"*",
"kwargs",
")",
"->",
"ToQuery",
":",
"cache_data",
"=",
"[",
"]",
"log_level",
"=",
"kwargs",
".",
"get",
"(",
"'log'",
",",
"logs",
".",
"LOG_LEVEL",
")",
"logger",
"="... | 70226eb19a72a08144b5d8cea9db4913200f7bc5 |
valid | parse_version | Parse versions | setup.py | def parse_version(package):
"""
Parse versions
"""
init_file = f'{PACKAGE_ROOT}/{package}/__init__.py'
with open(init_file, 'r', encoding='utf-8') as f:
for line in f.readlines():
if '__version__' in line:
return line.split('=')[1].strip()[1:-1]
return '' | def parse_version(package):
"""
Parse versions
"""
init_file = f'{PACKAGE_ROOT}/{package}/__init__.py'
with open(init_file, 'r', encoding='utf-8') as f:
for line in f.readlines():
if '__version__' in line:
return line.split('=')[1].strip()[1:-1]
return '' | [
"Parse",
"versions"
] | alpha-xone/xbbg | python | https://github.com/alpha-xone/xbbg/blob/70226eb19a72a08144b5d8cea9db4913200f7bc5/setup.py#L15-L24 | [
"def",
"parse_version",
"(",
"package",
")",
":",
"init_file",
"=",
"f'{PACKAGE_ROOT}/{package}/__init__.py'",
"with",
"open",
"(",
"init_file",
",",
"'r'",
",",
"encoding",
"=",
"'utf-8'",
")",
"as",
"f",
":",
"for",
"line",
"in",
"f",
".",
"readlines",
"("... | 70226eb19a72a08144b5d8cea9db4913200f7bc5 |
valid | parse_markdown | Parse markdown as description | setup.py | def parse_markdown():
"""
Parse markdown as description
"""
readme_file = f'{PACKAGE_ROOT}/README.md'
if path.exists(readme_file):
with open(readme_file, 'r', encoding='utf-8') as f:
long_description = f.read()
return long_description | def parse_markdown():
"""
Parse markdown as description
"""
readme_file = f'{PACKAGE_ROOT}/README.md'
if path.exists(readme_file):
with open(readme_file, 'r', encoding='utf-8') as f:
long_description = f.read()
return long_description | [
"Parse",
"markdown",
"as",
"description"
] | alpha-xone/xbbg | python | https://github.com/alpha-xone/xbbg/blob/70226eb19a72a08144b5d8cea9db4913200f7bc5/setup.py#L27-L35 | [
"def",
"parse_markdown",
"(",
")",
":",
"readme_file",
"=",
"f'{PACKAGE_ROOT}/README.md'",
"if",
"path",
".",
"exists",
"(",
"readme_file",
")",
":",
"with",
"open",
"(",
"readme_file",
",",
"'r'",
",",
"encoding",
"=",
"'utf-8'",
")",
"as",
"f",
":",
"lon... | 70226eb19a72a08144b5d8cea9db4913200f7bc5 |
valid | parse_description | Parse the description in the README file | setup.py | def parse_description(markdown=True):
"""
Parse the description in the README file
"""
if markdown: return parse_markdown()
try:
from pypandoc import convert
readme_file = f'{PACKAGE_ROOT}/docs/index.rst'
if not path.exists(readme_file):
raise ImportError
... | def parse_description(markdown=True):
"""
Parse the description in the README file
"""
if markdown: return parse_markdown()
try:
from pypandoc import convert
readme_file = f'{PACKAGE_ROOT}/docs/index.rst'
if not path.exists(readme_file):
raise ImportError
... | [
"Parse",
"the",
"description",
"in",
"the",
"README",
"file"
] | alpha-xone/xbbg | python | https://github.com/alpha-xone/xbbg/blob/70226eb19a72a08144b5d8cea9db4913200f7bc5/setup.py#L38-L53 | [
"def",
"parse_description",
"(",
"markdown",
"=",
"True",
")",
":",
"if",
"markdown",
":",
"return",
"parse_markdown",
"(",
")",
"try",
":",
"from",
"pypandoc",
"import",
"convert",
"readme_file",
"=",
"f'{PACKAGE_ROOT}/docs/index.rst'",
"if",
"not",
"path",
"."... | 70226eb19a72a08144b5d8cea9db4913200f7bc5 |
valid | proc_ovrds | Bloomberg overrides
Args:
**kwargs: overrides
Returns:
list of tuples
Examples:
>>> proc_ovrds(DVD_Start_Dt='20180101')
[('DVD_Start_Dt', '20180101')]
>>> proc_ovrds(DVD_Start_Dt='20180101', cache=True, has_date=True)
[('DVD_Start_Dt', '20180101')] | xbbg/core/assist.py | def proc_ovrds(**kwargs):
"""
Bloomberg overrides
Args:
**kwargs: overrides
Returns:
list of tuples
Examples:
>>> proc_ovrds(DVD_Start_Dt='20180101')
[('DVD_Start_Dt', '20180101')]
>>> proc_ovrds(DVD_Start_Dt='20180101', cache=True, has_date=True)
[... | def proc_ovrds(**kwargs):
"""
Bloomberg overrides
Args:
**kwargs: overrides
Returns:
list of tuples
Examples:
>>> proc_ovrds(DVD_Start_Dt='20180101')
[('DVD_Start_Dt', '20180101')]
>>> proc_ovrds(DVD_Start_Dt='20180101', cache=True, has_date=True)
[... | [
"Bloomberg",
"overrides"
] | alpha-xone/xbbg | python | https://github.com/alpha-xone/xbbg/blob/70226eb19a72a08144b5d8cea9db4913200f7bc5/xbbg/core/assist.py#L59-L78 | [
"def",
"proc_ovrds",
"(",
"*",
"*",
"kwargs",
")",
":",
"return",
"[",
"(",
"k",
",",
"v",
")",
"for",
"k",
",",
"v",
"in",
"kwargs",
".",
"items",
"(",
")",
"if",
"k",
"not",
"in",
"list",
"(",
"ELEM_KEYS",
".",
"keys",
"(",
")",
")",
"+",
... | 70226eb19a72a08144b5d8cea9db4913200f7bc5 |
valid | proc_elms | Bloomberg overrides for elements
Args:
**kwargs: overrides
Returns:
list of tuples
Examples:
>>> proc_elms(PerAdj='A', Per='W')
[('periodicityAdjustment', 'ACTUAL'), ('periodicitySelection', 'WEEKLY')]
>>> proc_elms(Days='A', Fill='B')
[('nonTradingDayFillO... | xbbg/core/assist.py | def proc_elms(**kwargs) -> list:
"""
Bloomberg overrides for elements
Args:
**kwargs: overrides
Returns:
list of tuples
Examples:
>>> proc_elms(PerAdj='A', Per='W')
[('periodicityAdjustment', 'ACTUAL'), ('periodicitySelection', 'WEEKLY')]
>>> proc_elms(Days... | def proc_elms(**kwargs) -> list:
"""
Bloomberg overrides for elements
Args:
**kwargs: overrides
Returns:
list of tuples
Examples:
>>> proc_elms(PerAdj='A', Per='W')
[('periodicityAdjustment', 'ACTUAL'), ('periodicitySelection', 'WEEKLY')]
>>> proc_elms(Days... | [
"Bloomberg",
"overrides",
"for",
"elements"
] | alpha-xone/xbbg | python | https://github.com/alpha-xone/xbbg/blob/70226eb19a72a08144b5d8cea9db4913200f7bc5/xbbg/core/assist.py#L81-L110 | [
"def",
"proc_elms",
"(",
"*",
"*",
"kwargs",
")",
"->",
"list",
":",
"return",
"[",
"(",
"ELEM_KEYS",
".",
"get",
"(",
"k",
",",
"k",
")",
",",
"ELEM_VALS",
".",
"get",
"(",
"ELEM_KEYS",
".",
"get",
"(",
"k",
",",
"k",
")",
",",
"dict",
"(",
... | 70226eb19a72a08144b5d8cea9db4913200f7bc5 |
valid | format_earning | Standardized earning outputs and add percentage by each blocks
Args:
data: earning data block
header: earning headers
Returns:
pd.DataFrame
Examples:
>>> format_earning(
... data=pd.read_pickle('xbbg/tests/data/sample_earning.pkl'),
... header=pd.re... | xbbg/core/assist.py | def format_earning(data: pd.DataFrame, header: pd.DataFrame) -> pd.DataFrame:
"""
Standardized earning outputs and add percentage by each blocks
Args:
data: earning data block
header: earning headers
Returns:
pd.DataFrame
Examples:
>>> format_earning(
... ... | def format_earning(data: pd.DataFrame, header: pd.DataFrame) -> pd.DataFrame:
"""
Standardized earning outputs and add percentage by each blocks
Args:
data: earning data block
header: earning headers
Returns:
pd.DataFrame
Examples:
>>> format_earning(
... ... | [
"Standardized",
"earning",
"outputs",
"and",
"add",
"percentage",
"by",
"each",
"blocks"
] | alpha-xone/xbbg | python | https://github.com/alpha-xone/xbbg/blob/70226eb19a72a08144b5d8cea9db4913200f7bc5/xbbg/core/assist.py#L113-L175 | [
"def",
"format_earning",
"(",
"data",
":",
"pd",
".",
"DataFrame",
",",
"header",
":",
"pd",
".",
"DataFrame",
")",
"->",
"pd",
".",
"DataFrame",
":",
"if",
"data",
".",
"dropna",
"(",
"subset",
"=",
"[",
"'value'",
"]",
")",
".",
"empty",
":",
"re... | 70226eb19a72a08144b5d8cea9db4913200f7bc5 |
valid | format_output | Format `pdblp` outputs to column-based results
Args:
data: `pdblp` result
source: `bdp` or `bds`
col_maps: rename columns with these mappings
Returns:
pd.DataFrame
Examples:
>>> format_output(
... data=pd.read_pickle('xbbg/tests/data/sample_bdp.pkl'),
... | xbbg/core/assist.py | def format_output(data: pd.DataFrame, source, col_maps=None) -> pd.DataFrame:
"""
Format `pdblp` outputs to column-based results
Args:
data: `pdblp` result
source: `bdp` or `bds`
col_maps: rename columns with these mappings
Returns:
pd.DataFrame
Examples:
>... | def format_output(data: pd.DataFrame, source, col_maps=None) -> pd.DataFrame:
"""
Format `pdblp` outputs to column-based results
Args:
data: `pdblp` result
source: `bdp` or `bds`
col_maps: rename columns with these mappings
Returns:
pd.DataFrame
Examples:
>... | [
"Format",
"pdblp",
"outputs",
"to",
"column",
"-",
"based",
"results"
] | alpha-xone/xbbg | python | https://github.com/alpha-xone/xbbg/blob/70226eb19a72a08144b5d8cea9db4913200f7bc5/xbbg/core/assist.py#L178-L229 | [
"def",
"format_output",
"(",
"data",
":",
"pd",
".",
"DataFrame",
",",
"source",
",",
"col_maps",
"=",
"None",
")",
"->",
"pd",
".",
"DataFrame",
":",
"if",
"data",
".",
"empty",
":",
"return",
"pd",
".",
"DataFrame",
"(",
")",
"if",
"source",
"==",
... | 70226eb19a72a08144b5d8cea9db4913200f7bc5 |
valid | format_intraday | Format intraday data
Args:
data: pd.DataFrame from bdib
ticker: ticker
Returns:
pd.DataFrame
Examples:
>>> format_intraday(
... data=pd.read_parquet('xbbg/tests/data/sample_bdib.parq'),
... ticker='SPY US Equity',
... ).xs('close', axis=1, l... | xbbg/core/assist.py | def format_intraday(data: pd.DataFrame, ticker, **kwargs) -> pd.DataFrame:
"""
Format intraday data
Args:
data: pd.DataFrame from bdib
ticker: ticker
Returns:
pd.DataFrame
Examples:
>>> format_intraday(
... data=pd.read_parquet('xbbg/tests/data/sample_b... | def format_intraday(data: pd.DataFrame, ticker, **kwargs) -> pd.DataFrame:
"""
Format intraday data
Args:
data: pd.DataFrame from bdib
ticker: ticker
Returns:
pd.DataFrame
Examples:
>>> format_intraday(
... data=pd.read_parquet('xbbg/tests/data/sample_b... | [
"Format",
"intraday",
"data"
] | alpha-xone/xbbg | python | https://github.com/alpha-xone/xbbg/blob/70226eb19a72a08144b5d8cea9db4913200f7bc5/xbbg/core/assist.py#L232-L276 | [
"def",
"format_intraday",
"(",
"data",
":",
"pd",
".",
"DataFrame",
",",
"ticker",
",",
"*",
"*",
"kwargs",
")",
"->",
"pd",
".",
"DataFrame",
":",
"if",
"data",
".",
"empty",
":",
"return",
"pd",
".",
"DataFrame",
"(",
")",
"data",
".",
"columns",
... | 70226eb19a72a08144b5d8cea9db4913200f7bc5 |
valid | info_qry | Logging info for given tickers and fields
Args:
tickers: tickers
flds: fields
Returns:
str
Examples:
>>> print(info_qry(
... tickers=['NVDA US Equity'], flds=['Name', 'Security_Name']
... ))
tickers: ['NVDA US Equity']
fields: ['Name', ... | xbbg/core/assist.py | def info_qry(tickers, flds) -> str:
"""
Logging info for given tickers and fields
Args:
tickers: tickers
flds: fields
Returns:
str
Examples:
>>> print(info_qry(
... tickers=['NVDA US Equity'], flds=['Name', 'Security_Name']
... ))
ticker... | def info_qry(tickers, flds) -> str:
"""
Logging info for given tickers and fields
Args:
tickers: tickers
flds: fields
Returns:
str
Examples:
>>> print(info_qry(
... tickers=['NVDA US Equity'], flds=['Name', 'Security_Name']
... ))
ticker... | [
"Logging",
"info",
"for",
"given",
"tickers",
"and",
"fields"
] | alpha-xone/xbbg | python | https://github.com/alpha-xone/xbbg/blob/70226eb19a72a08144b5d8cea9db4913200f7bc5/xbbg/core/assist.py#L279-L300 | [
"def",
"info_qry",
"(",
"tickers",
",",
"flds",
")",
"->",
"str",
":",
"full_list",
"=",
"'\\n'",
".",
"join",
"(",
"[",
"f'tickers: {tickers[:8]}'",
"]",
"+",
"[",
"f' {tickers[n:(n + 8)]}'",
"for",
"n",
"in",
"range",
"(",
"8",
",",
"len",
"(",
... | 70226eb19a72a08144b5d8cea9db4913200f7bc5 |
valid | bdp | Bloomberg reference data
Args:
tickers: tickers
flds: fields to query
**kwargs: bbg overrides
Returns:
pd.DataFrame
Examples:
>>> bdp('IQ US Equity', 'Crncy', raw=True)
ticker field value
0 IQ US Equity Crncy USD
>>> bdp('IQ US... | xbbg/blp.py | def bdp(tickers, flds, **kwargs):
"""
Bloomberg reference data
Args:
tickers: tickers
flds: fields to query
**kwargs: bbg overrides
Returns:
pd.DataFrame
Examples:
>>> bdp('IQ US Equity', 'Crncy', raw=True)
ticker field value
0 IQ... | def bdp(tickers, flds, **kwargs):
"""
Bloomberg reference data
Args:
tickers: tickers
flds: fields to query
**kwargs: bbg overrides
Returns:
pd.DataFrame
Examples:
>>> bdp('IQ US Equity', 'Crncy', raw=True)
ticker field value
0 IQ... | [
"Bloomberg",
"reference",
"data"
] | alpha-xone/xbbg | python | https://github.com/alpha-xone/xbbg/blob/70226eb19a72a08144b5d8cea9db4913200f7bc5/xbbg/blp.py#L30-L72 | [
"def",
"bdp",
"(",
"tickers",
",",
"flds",
",",
"*",
"*",
"kwargs",
")",
":",
"logger",
"=",
"logs",
".",
"get_logger",
"(",
"bdp",
",",
"level",
"=",
"kwargs",
".",
"pop",
"(",
"'log'",
",",
"logs",
".",
"LOG_LEVEL",
")",
")",
"con",
",",
"_",
... | 70226eb19a72a08144b5d8cea9db4913200f7bc5 |
valid | bds | Bloomberg block data
Args:
tickers: ticker(s)
flds: field(s)
**kwargs: other overrides for query
-> raw: raw output from `pdbdp` library, default False
Returns:
pd.DataFrame: block data
Examples:
>>> import os
>>>
>>> pd.options.display.wi... | xbbg/blp.py | def bds(tickers, flds, **kwargs):
"""
Bloomberg block data
Args:
tickers: ticker(s)
flds: field(s)
**kwargs: other overrides for query
-> raw: raw output from `pdbdp` library, default False
Returns:
pd.DataFrame: block data
Examples:
>>> import os... | def bds(tickers, flds, **kwargs):
"""
Bloomberg block data
Args:
tickers: ticker(s)
flds: field(s)
**kwargs: other overrides for query
-> raw: raw output from `pdbdp` library, default False
Returns:
pd.DataFrame: block data
Examples:
>>> import os... | [
"Bloomberg",
"block",
"data"
] | alpha-xone/xbbg | python | https://github.com/alpha-xone/xbbg/blob/70226eb19a72a08144b5d8cea9db4913200f7bc5/xbbg/blp.py#L76-L158 | [
"def",
"bds",
"(",
"tickers",
",",
"flds",
",",
"*",
"*",
"kwargs",
")",
":",
"logger",
"=",
"logs",
".",
"get_logger",
"(",
"bds",
",",
"level",
"=",
"kwargs",
".",
"pop",
"(",
"'log'",
",",
"logs",
".",
"LOG_LEVEL",
")",
")",
"con",
",",
"_",
... | 70226eb19a72a08144b5d8cea9db4913200f7bc5 |
valid | bdh | Bloomberg historical data
Args:
tickers: ticker(s)
flds: field(s)
start_date: start date
end_date: end date - default today
adjust: `all`, `dvd`, `normal`, `abn` (=abnormal), `split`, `-` or None
exact match of above words will adjust for corresponding events... | xbbg/blp.py | def bdh(
tickers, flds=None, start_date=None, end_date='today', adjust=None, **kwargs
) -> pd.DataFrame:
"""
Bloomberg historical data
Args:
tickers: ticker(s)
flds: field(s)
start_date: start date
end_date: end date - default today
adjust: `all`, `dvd`, `nor... | def bdh(
tickers, flds=None, start_date=None, end_date='today', adjust=None, **kwargs
) -> pd.DataFrame:
"""
Bloomberg historical data
Args:
tickers: ticker(s)
flds: field(s)
start_date: start date
end_date: end date - default today
adjust: `all`, `dvd`, `nor... | [
"Bloomberg",
"historical",
"data"
] | alpha-xone/xbbg | python | https://github.com/alpha-xone/xbbg/blob/70226eb19a72a08144b5d8cea9db4913200f7bc5/xbbg/blp.py#L162-L256 | [
"def",
"bdh",
"(",
"tickers",
",",
"flds",
"=",
"None",
",",
"start_date",
"=",
"None",
",",
"end_date",
"=",
"'today'",
",",
"adjust",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
"->",
"pd",
".",
"DataFrame",
":",
"logger",
"=",
"logs",
".",
"get_l... | 70226eb19a72a08144b5d8cea9db4913200f7bc5 |
valid | bdib | Bloomberg intraday bar data
Args:
ticker: ticker name
dt: date to download
typ: [TRADE, BID, ASK, BID_BEST, ASK_BEST, BEST_BID, BEST_ASK]
**kwargs:
batch: whether is batch process to download data
log: level of logs
Returns:
pd.DataFrame | xbbg/blp.py | def bdib(ticker, dt, typ='TRADE', **kwargs) -> pd.DataFrame:
"""
Bloomberg intraday bar data
Args:
ticker: ticker name
dt: date to download
typ: [TRADE, BID, ASK, BID_BEST, ASK_BEST, BEST_BID, BEST_ASK]
**kwargs:
batch: whether is batch process to download data
... | def bdib(ticker, dt, typ='TRADE', **kwargs) -> pd.DataFrame:
"""
Bloomberg intraday bar data
Args:
ticker: ticker name
dt: date to download
typ: [TRADE, BID, ASK, BID_BEST, ASK_BEST, BEST_BID, BEST_ASK]
**kwargs:
batch: whether is batch process to download data
... | [
"Bloomberg",
"intraday",
"bar",
"data"
] | alpha-xone/xbbg | python | https://github.com/alpha-xone/xbbg/blob/70226eb19a72a08144b5d8cea9db4913200f7bc5/xbbg/blp.py#L260-L347 | [
"def",
"bdib",
"(",
"ticker",
",",
"dt",
",",
"typ",
"=",
"'TRADE'",
",",
"*",
"*",
"kwargs",
")",
"->",
"pd",
".",
"DataFrame",
":",
"from",
"xbbg",
".",
"core",
"import",
"missing",
"logger",
"=",
"logs",
".",
"get_logger",
"(",
"bdib",
",",
"lev... | 70226eb19a72a08144b5d8cea9db4913200f7bc5 |
valid | intraday | Bloomberg intraday bar data within market session
Args:
ticker: ticker
dt: date
session: examples include
day_open_30, am_normal_30_30, day_close_30, allday_exact_0930_1000
**kwargs:
ref: reference ticker or exchange for timezone
keep_tz: if ... | xbbg/blp.py | def intraday(ticker, dt, session='', **kwargs) -> pd.DataFrame:
"""
Bloomberg intraday bar data within market session
Args:
ticker: ticker
dt: date
session: examples include
day_open_30, am_normal_30_30, day_close_30, allday_exact_0930_1000
**kwargs:
... | def intraday(ticker, dt, session='', **kwargs) -> pd.DataFrame:
"""
Bloomberg intraday bar data within market session
Args:
ticker: ticker
dt: date
session: examples include
day_open_30, am_normal_30_30, day_close_30, allday_exact_0930_1000
**kwargs:
... | [
"Bloomberg",
"intraday",
"bar",
"data",
"within",
"market",
"session"
] | alpha-xone/xbbg | python | https://github.com/alpha-xone/xbbg/blob/70226eb19a72a08144b5d8cea9db4913200f7bc5/xbbg/blp.py#L350-L398 | [
"def",
"intraday",
"(",
"ticker",
",",
"dt",
",",
"session",
"=",
"''",
",",
"*",
"*",
"kwargs",
")",
"->",
"pd",
".",
"DataFrame",
":",
"from",
"xbbg",
".",
"core",
"import",
"intervals",
"cur_data",
"=",
"bdib",
"(",
"ticker",
"=",
"ticker",
",",
... | 70226eb19a72a08144b5d8cea9db4913200f7bc5 |
valid | earning | Earning exposures by Geo or Products
Args:
ticker: ticker name
by: [G(eo), P(roduct)]
typ: type of earning, start with `PG_` in Bloomberg FLDS - default `Revenue`
ccy: currency of earnings
level: hierarchy level of earnings
Returns:
pd.DataFrame
Examples:
... | xbbg/blp.py | def earning(
ticker, by='Geo', typ='Revenue', ccy=None, level=None, **kwargs
) -> pd.DataFrame:
"""
Earning exposures by Geo or Products
Args:
ticker: ticker name
by: [G(eo), P(roduct)]
typ: type of earning, start with `PG_` in Bloomberg FLDS - default `Revenue`
ccy:... | def earning(
ticker, by='Geo', typ='Revenue', ccy=None, level=None, **kwargs
) -> pd.DataFrame:
"""
Earning exposures by Geo or Products
Args:
ticker: ticker name
by: [G(eo), P(roduct)]
typ: type of earning, start with `PG_` in Bloomberg FLDS - default `Revenue`
ccy:... | [
"Earning",
"exposures",
"by",
"Geo",
"or",
"Products"
] | alpha-xone/xbbg | python | https://github.com/alpha-xone/xbbg/blob/70226eb19a72a08144b5d8cea9db4913200f7bc5/xbbg/blp.py#L402-L436 | [
"def",
"earning",
"(",
"ticker",
",",
"by",
"=",
"'Geo'",
",",
"typ",
"=",
"'Revenue'",
",",
"ccy",
"=",
"None",
",",
"level",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
"->",
"pd",
".",
"DataFrame",
":",
"ovrd",
"=",
"'G'",
"if",
"by",
"[",
"0... | 70226eb19a72a08144b5d8cea9db4913200f7bc5 |
valid | dividend | Bloomberg dividend / split history
Args:
tickers: list of tickers
typ: dividend adjustment type
`all`: `DVD_Hist_All`
`dvd`: `DVD_Hist`
`split`: `Eqy_DVD_Hist_Splits`
`gross`: `Eqy_DVD_Hist_Gross`
`adjust`: `Eqy_DVD_... | xbbg/blp.py | def dividend(
tickers, typ='all', start_date=None, end_date=None, **kwargs
) -> pd.DataFrame:
"""
Bloomberg dividend / split history
Args:
tickers: list of tickers
typ: dividend adjustment type
`all`: `DVD_Hist_All`
`dvd`: `DVD_Hist`
`... | def dividend(
tickers, typ='all', start_date=None, end_date=None, **kwargs
) -> pd.DataFrame:
"""
Bloomberg dividend / split history
Args:
tickers: list of tickers
typ: dividend adjustment type
`all`: `DVD_Hist_All`
`dvd`: `DVD_Hist`
`... | [
"Bloomberg",
"dividend",
"/",
"split",
"history"
] | alpha-xone/xbbg | python | https://github.com/alpha-xone/xbbg/blob/70226eb19a72a08144b5d8cea9db4913200f7bc5/xbbg/blp.py#L439-L512 | [
"def",
"dividend",
"(",
"tickers",
",",
"typ",
"=",
"'all'",
",",
"start_date",
"=",
"None",
",",
"end_date",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
"->",
"pd",
".",
"DataFrame",
":",
"if",
"isinstance",
"(",
"tickers",
",",
"str",
")",
":",
"t... | 70226eb19a72a08144b5d8cea9db4913200f7bc5 |
valid | active_futures | Active futures contract
Args:
ticker: futures ticker, i.e., ESA Index, Z A Index, CLA Comdty, etc.
dt: date
Returns:
str: ticker name | xbbg/blp.py | def active_futures(ticker: str, dt) -> str:
"""
Active futures contract
Args:
ticker: futures ticker, i.e., ESA Index, Z A Index, CLA Comdty, etc.
dt: date
Returns:
str: ticker name
"""
t_info = ticker.split()
prefix, asset = ' '.join(t_info[:-1]), t_info[-1]
in... | def active_futures(ticker: str, dt) -> str:
"""
Active futures contract
Args:
ticker: futures ticker, i.e., ESA Index, Z A Index, CLA Comdty, etc.
dt: date
Returns:
str: ticker name
"""
t_info = ticker.split()
prefix, asset = ' '.join(t_info[:-1]), t_info[-1]
in... | [
"Active",
"futures",
"contract"
] | alpha-xone/xbbg | python | https://github.com/alpha-xone/xbbg/blob/70226eb19a72a08144b5d8cea9db4913200f7bc5/xbbg/blp.py#L516-L542 | [
"def",
"active_futures",
"(",
"ticker",
":",
"str",
",",
"dt",
")",
"->",
"str",
":",
"t_info",
"=",
"ticker",
".",
"split",
"(",
")",
"prefix",
",",
"asset",
"=",
"' '",
".",
"join",
"(",
"t_info",
"[",
":",
"-",
"1",
"]",
")",
",",
"t_info",
... | 70226eb19a72a08144b5d8cea9db4913200f7bc5 |
valid | fut_ticker | Get proper ticker from generic ticker
Args:
gen_ticker: generic ticker
dt: date
freq: futures contract frequency
log: level of logs
Returns:
str: exact futures ticker | xbbg/blp.py | def fut_ticker(gen_ticker: str, dt, freq: str, log=logs.LOG_LEVEL) -> str:
"""
Get proper ticker from generic ticker
Args:
gen_ticker: generic ticker
dt: date
freq: futures contract frequency
log: level of logs
Returns:
str: exact futures ticker
"""
logg... | def fut_ticker(gen_ticker: str, dt, freq: str, log=logs.LOG_LEVEL) -> str:
"""
Get proper ticker from generic ticker
Args:
gen_ticker: generic ticker
dt: date
freq: futures contract frequency
log: level of logs
Returns:
str: exact futures ticker
"""
logg... | [
"Get",
"proper",
"ticker",
"from",
"generic",
"ticker"
] | alpha-xone/xbbg | python | https://github.com/alpha-xone/xbbg/blob/70226eb19a72a08144b5d8cea9db4913200f7bc5/xbbg/blp.py#L546-L603 | [
"def",
"fut_ticker",
"(",
"gen_ticker",
":",
"str",
",",
"dt",
",",
"freq",
":",
"str",
",",
"log",
"=",
"logs",
".",
"LOG_LEVEL",
")",
"->",
"str",
":",
"logger",
"=",
"logs",
".",
"get_logger",
"(",
"fut_ticker",
",",
"level",
"=",
"log",
")",
"d... | 70226eb19a72a08144b5d8cea9db4913200f7bc5 |
valid | check_hours | Check exchange hours vs local hours
Args:
tickers: list of tickers
tz_exch: exchange timezone
tz_loc: local timezone
Returns:
Local and exchange hours | xbbg/blp.py | def check_hours(tickers, tz_exch, tz_loc=DEFAULT_TZ) -> pd.DataFrame:
"""
Check exchange hours vs local hours
Args:
tickers: list of tickers
tz_exch: exchange timezone
tz_loc: local timezone
Returns:
Local and exchange hours
"""
cols = ['Trading_Day_Start_Time_E... | def check_hours(tickers, tz_exch, tz_loc=DEFAULT_TZ) -> pd.DataFrame:
"""
Check exchange hours vs local hours
Args:
tickers: list of tickers
tz_exch: exchange timezone
tz_loc: local timezone
Returns:
Local and exchange hours
"""
cols = ['Trading_Day_Start_Time_E... | [
"Check",
"exchange",
"hours",
"vs",
"local",
"hours"
] | alpha-xone/xbbg | python | https://github.com/alpha-xone/xbbg/blob/70226eb19a72a08144b5d8cea9db4913200f7bc5/xbbg/blp.py#L607-L634 | [
"def",
"check_hours",
"(",
"tickers",
",",
"tz_exch",
",",
"tz_loc",
"=",
"DEFAULT_TZ",
")",
"->",
"pd",
".",
"DataFrame",
":",
"cols",
"=",
"[",
"'Trading_Day_Start_Time_EOD'",
",",
"'Trading_Day_End_Time_EOD'",
"]",
"con",
",",
"_",
"=",
"create_connection",
... | 70226eb19a72a08144b5d8cea9db4913200f7bc5 |
valid | hist_file | Data file location for Bloomberg historical data
Args:
ticker: ticker name
dt: date
typ: [TRADE, BID, ASK, BID_BEST, ASK_BEST, BEST_BID, BEST_ASK]
Returns:
file location
Examples:
>>> os.environ['BBG_ROOT'] = ''
>>> hist_file(ticker='ES1 Index', dt='2018-08... | xbbg/io/storage.py | def hist_file(ticker: str, dt, typ='TRADE') -> str:
"""
Data file location for Bloomberg historical data
Args:
ticker: ticker name
dt: date
typ: [TRADE, BID, ASK, BID_BEST, ASK_BEST, BEST_BID, BEST_ASK]
Returns:
file location
Examples:
>>> os.environ['BBG_R... | def hist_file(ticker: str, dt, typ='TRADE') -> str:
"""
Data file location for Bloomberg historical data
Args:
ticker: ticker name
dt: date
typ: [TRADE, BID, ASK, BID_BEST, ASK_BEST, BEST_BID, BEST_ASK]
Returns:
file location
Examples:
>>> os.environ['BBG_R... | [
"Data",
"file",
"location",
"for",
"Bloomberg",
"historical",
"data"
] | alpha-xone/xbbg | python | https://github.com/alpha-xone/xbbg/blob/70226eb19a72a08144b5d8cea9db4913200f7bc5/xbbg/io/storage.py#L11-L36 | [
"def",
"hist_file",
"(",
"ticker",
":",
"str",
",",
"dt",
",",
"typ",
"=",
"'TRADE'",
")",
"->",
"str",
":",
"data_path",
"=",
"os",
".",
"environ",
".",
"get",
"(",
"assist",
".",
"BBG_ROOT",
",",
"''",
")",
".",
"replace",
"(",
"'\\\\'",
",",
"... | 70226eb19a72a08144b5d8cea9db4913200f7bc5 |
valid | ref_file | Data file location for Bloomberg reference data
Args:
ticker: ticker name
fld: field
has_date: whether add current date to data file
cache: if has_date is True, whether to load file from latest cached
ext: file extension
**kwargs: other overrides passed to ref functi... | xbbg/io/storage.py | def ref_file(
ticker: str, fld: str, has_date=False, cache=False, ext='parq', **kwargs
) -> str:
"""
Data file location for Bloomberg reference data
Args:
ticker: ticker name
fld: field
has_date: whether add current date to data file
cache: if has_date is True, wheth... | def ref_file(
ticker: str, fld: str, has_date=False, cache=False, ext='parq', **kwargs
) -> str:
"""
Data file location for Bloomberg reference data
Args:
ticker: ticker name
fld: field
has_date: whether add current date to data file
cache: if has_date is True, wheth... | [
"Data",
"file",
"location",
"for",
"Bloomberg",
"reference",
"data"
] | alpha-xone/xbbg | python | https://github.com/alpha-xone/xbbg/blob/70226eb19a72a08144b5d8cea9db4913200f7bc5/xbbg/io/storage.py#L39-L134 | [
"def",
"ref_file",
"(",
"ticker",
":",
"str",
",",
"fld",
":",
"str",
",",
"has_date",
"=",
"False",
",",
"cache",
"=",
"False",
",",
"ext",
"=",
"'parq'",
",",
"*",
"*",
"kwargs",
")",
"->",
"str",
":",
"data_path",
"=",
"os",
".",
"environ",
".... | 70226eb19a72a08144b5d8cea9db4913200f7bc5 |
valid | save_intraday | Check whether data is done for the day and save
Args:
data: data
ticker: ticker
dt: date
typ: [TRADE, BID, ASK, BID_BEST, ASK_BEST, BEST_BID, BEST_ASK]
Examples:
>>> os.environ['BBG_ROOT'] = 'xbbg/tests/data'
>>> sample = pd.read_parquet('xbbg/tests/data/aapl.pa... | xbbg/io/storage.py | def save_intraday(data: pd.DataFrame, ticker: str, dt, typ='TRADE'):
"""
Check whether data is done for the day and save
Args:
data: data
ticker: ticker
dt: date
typ: [TRADE, BID, ASK, BID_BEST, ASK_BEST, BEST_BID, BEST_ASK]
Examples:
>>> os.environ['BBG_ROOT'] ... | def save_intraday(data: pd.DataFrame, ticker: str, dt, typ='TRADE'):
"""
Check whether data is done for the day and save
Args:
data: data
ticker: ticker
dt: date
typ: [TRADE, BID, ASK, BID_BEST, ASK_BEST, BEST_BID, BEST_ASK]
Examples:
>>> os.environ['BBG_ROOT'] ... | [
"Check",
"whether",
"data",
"is",
"done",
"for",
"the",
"day",
"and",
"save"
] | alpha-xone/xbbg | python | https://github.com/alpha-xone/xbbg/blob/70226eb19a72a08144b5d8cea9db4913200f7bc5/xbbg/io/storage.py#L137-L183 | [
"def",
"save_intraday",
"(",
"data",
":",
"pd",
".",
"DataFrame",
",",
"ticker",
":",
"str",
",",
"dt",
",",
"typ",
"=",
"'TRADE'",
")",
":",
"cur_dt",
"=",
"pd",
".",
"Timestamp",
"(",
"dt",
")",
".",
"strftime",
"(",
"'%Y-%m-%d'",
")",
"logger",
... | 70226eb19a72a08144b5d8cea9db4913200f7bc5 |
valid | exch_info | Exchange info for given ticker
Args:
ticker: ticker or exchange
Returns:
pd.Series
Examples:
>>> exch_info('SPY US Equity')
tz America/New_York
allday [04:00, 20:00]
day [09:30, 16:00]
pre [04:00, 09:30]
post ... | xbbg/const.py | def exch_info(ticker: str) -> pd.Series:
"""
Exchange info for given ticker
Args:
ticker: ticker or exchange
Returns:
pd.Series
Examples:
>>> exch_info('SPY US Equity')
tz America/New_York
allday [04:00, 20:00]
day [09:30, 16:00]... | def exch_info(ticker: str) -> pd.Series:
"""
Exchange info for given ticker
Args:
ticker: ticker or exchange
Returns:
pd.Series
Examples:
>>> exch_info('SPY US Equity')
tz America/New_York
allday [04:00, 20:00]
day [09:30, 16:00]... | [
"Exchange",
"info",
"for",
"given",
"ticker"
] | alpha-xone/xbbg | python | https://github.com/alpha-xone/xbbg/blob/70226eb19a72a08144b5d8cea9db4913200f7bc5/xbbg/const.py#L16-L71 | [
"def",
"exch_info",
"(",
"ticker",
":",
"str",
")",
"->",
"pd",
".",
"Series",
":",
"logger",
"=",
"logs",
".",
"get_logger",
"(",
"exch_info",
",",
"level",
"=",
"'debug'",
")",
"if",
"' '",
"not",
"in",
"ticker",
".",
"strip",
"(",
")",
":",
"tic... | 70226eb19a72a08144b5d8cea9db4913200f7bc5 |
valid | market_info | Get info for given market
Args:
ticker: Bloomberg full ticker
Returns:
dict
Examples:
>>> info = market_info('SHCOMP Index')
>>> info['exch']
'EquityChina'
>>> info = market_info('ICICIC=1 IS Equity')
>>> info['freq'], info['is_fut']
('M', T... | xbbg/const.py | def market_info(ticker: str) -> dict:
"""
Get info for given market
Args:
ticker: Bloomberg full ticker
Returns:
dict
Examples:
>>> info = market_info('SHCOMP Index')
>>> info['exch']
'EquityChina'
>>> info = market_info('ICICIC=1 IS Equity')
... | def market_info(ticker: str) -> dict:
"""
Get info for given market
Args:
ticker: Bloomberg full ticker
Returns:
dict
Examples:
>>> info = market_info('SHCOMP Index')
>>> info['exch']
'EquityChina'
>>> info = market_info('ICICIC=1 IS Equity')
... | [
"Get",
"info",
"for",
"given",
"market"
] | alpha-xone/xbbg | python | https://github.com/alpha-xone/xbbg/blob/70226eb19a72a08144b5d8cea9db4913200f7bc5/xbbg/const.py#L74-L166 | [
"def",
"market_info",
"(",
"ticker",
":",
"str",
")",
"->",
"dict",
":",
"t_info",
"=",
"ticker",
".",
"split",
"(",
")",
"assets",
"=",
"param",
".",
"load_info",
"(",
"'assets'",
")",
"# ========================== #",
"# Equity #",
"# =====... | 70226eb19a72a08144b5d8cea9db4913200f7bc5 |
valid | ccy_pair | Currency pair info
Args:
local: local currency
base: base currency
Returns:
CurrencyPair
Examples:
>>> ccy_pair(local='HKD', base='USD')
CurrencyPair(ticker='HKD Curncy', factor=1.0, power=1)
>>> ccy_pair(local='GBp')
CurrencyPair(ticker='GBP Curncy... | xbbg/const.py | def ccy_pair(local, base='USD') -> CurrencyPair:
"""
Currency pair info
Args:
local: local currency
base: base currency
Returns:
CurrencyPair
Examples:
>>> ccy_pair(local='HKD', base='USD')
CurrencyPair(ticker='HKD Curncy', factor=1.0, power=1)
>>> ... | def ccy_pair(local, base='USD') -> CurrencyPair:
"""
Currency pair info
Args:
local: local currency
base: base currency
Returns:
CurrencyPair
Examples:
>>> ccy_pair(local='HKD', base='USD')
CurrencyPair(ticker='HKD Curncy', factor=1.0, power=1)
>>> ... | [
"Currency",
"pair",
"info"
] | alpha-xone/xbbg | python | https://github.com/alpha-xone/xbbg/blob/70226eb19a72a08144b5d8cea9db4913200f7bc5/xbbg/const.py#L169-L218 | [
"def",
"ccy_pair",
"(",
"local",
",",
"base",
"=",
"'USD'",
")",
"->",
"CurrencyPair",
":",
"ccy_param",
"=",
"param",
".",
"load_info",
"(",
"cat",
"=",
"'ccy'",
")",
"if",
"f'{local}{base}'",
"in",
"ccy_param",
":",
"info",
"=",
"ccy_param",
"[",
"f'{l... | 70226eb19a72a08144b5d8cea9db4913200f7bc5 |
valid | market_timing | Market close time for ticker
Args:
ticker: ticker name
dt: date
timing: [EOD (default), BOD]
tz: conversion to timezone
Returns:
str: date & time
Examples:
>>> market_timing('7267 JT Equity', dt='2018-09-10')
'2018-09-10 14:58'
>>> market_ti... | xbbg/const.py | def market_timing(ticker, dt, timing='EOD', tz='local') -> str:
"""
Market close time for ticker
Args:
ticker: ticker name
dt: date
timing: [EOD (default), BOD]
tz: conversion to timezone
Returns:
str: date & time
Examples:
>>> market_timing('7267 J... | def market_timing(ticker, dt, timing='EOD', tz='local') -> str:
"""
Market close time for ticker
Args:
ticker: ticker name
dt: date
timing: [EOD (default), BOD]
tz: conversion to timezone
Returns:
str: date & time
Examples:
>>> market_timing('7267 J... | [
"Market",
"close",
"time",
"for",
"ticker"
] | alpha-xone/xbbg | python | https://github.com/alpha-xone/xbbg/blob/70226eb19a72a08144b5d8cea9db4913200f7bc5/xbbg/const.py#L221-L264 | [
"def",
"market_timing",
"(",
"ticker",
",",
"dt",
",",
"timing",
"=",
"'EOD'",
",",
"tz",
"=",
"'local'",
")",
"->",
"str",
":",
"logger",
"=",
"logs",
".",
"get_logger",
"(",
"market_timing",
")",
"exch",
"=",
"pd",
".",
"Series",
"(",
"exch_info",
... | 70226eb19a72a08144b5d8cea9db4913200f7bc5 |
valid | flatten | Flatten any array of items to list
Args:
iterable: any array or value
maps: map items to values
unique: drop duplicates
Returns:
list: flattened list
References:
https://stackoverflow.com/a/40857703/1332656
Examples:
>>> flatten('abc')
['abc']
... | xbbg/core/utils.py | def flatten(iterable, maps=None, unique=False) -> list:
"""
Flatten any array of items to list
Args:
iterable: any array or value
maps: map items to values
unique: drop duplicates
Returns:
list: flattened list
References:
https://stackoverflow.com/a/4085770... | def flatten(iterable, maps=None, unique=False) -> list:
"""
Flatten any array of items to list
Args:
iterable: any array or value
maps: map items to values
unique: drop duplicates
Returns:
list: flattened list
References:
https://stackoverflow.com/a/4085770... | [
"Flatten",
"any",
"array",
"of",
"items",
"to",
"list"
] | alpha-xone/xbbg | python | https://github.com/alpha-xone/xbbg/blob/70226eb19a72a08144b5d8cea9db4913200f7bc5/xbbg/core/utils.py#L12-L47 | [
"def",
"flatten",
"(",
"iterable",
",",
"maps",
"=",
"None",
",",
"unique",
"=",
"False",
")",
"->",
"list",
":",
"if",
"iterable",
"is",
"None",
":",
"return",
"[",
"]",
"if",
"maps",
"is",
"None",
":",
"maps",
"=",
"dict",
"(",
")",
"if",
"isin... | 70226eb19a72a08144b5d8cea9db4913200f7bc5 |
valid | _to_gen_ | Recursively iterate lists and tuples | xbbg/core/utils.py | def _to_gen_(iterable):
"""
Recursively iterate lists and tuples
"""
from collections import Iterable
for elm in iterable:
if isinstance(elm, Iterable) and not isinstance(elm, (str, bytes)):
yield from flatten(elm)
else: yield elm | def _to_gen_(iterable):
"""
Recursively iterate lists and tuples
"""
from collections import Iterable
for elm in iterable:
if isinstance(elm, Iterable) and not isinstance(elm, (str, bytes)):
yield from flatten(elm)
else: yield elm | [
"Recursively",
"iterate",
"lists",
"and",
"tuples"
] | alpha-xone/xbbg | python | https://github.com/alpha-xone/xbbg/blob/70226eb19a72a08144b5d8cea9db4913200f7bc5/xbbg/core/utils.py#L50-L59 | [
"def",
"_to_gen_",
"(",
"iterable",
")",
":",
"from",
"collections",
"import",
"Iterable",
"for",
"elm",
"in",
"iterable",
":",
"if",
"isinstance",
"(",
"elm",
",",
"Iterable",
")",
"and",
"not",
"isinstance",
"(",
"elm",
",",
"(",
"str",
",",
"bytes",
... | 70226eb19a72a08144b5d8cea9db4913200f7bc5 |
valid | cur_time | Current time
Args:
typ: one of ['date', 'time', 'time_path', 'raw', '']
tz: timezone
Returns:
relevant current time or date
Examples:
>>> cur_dt = pd.Timestamp('now')
>>> cur_time(typ='date') == cur_dt.strftime('%Y-%m-%d')
True
>>> cur_time(typ='tim... | xbbg/core/utils.py | def cur_time(typ='date', tz=DEFAULT_TZ) -> (datetime.date, str):
"""
Current time
Args:
typ: one of ['date', 'time', 'time_path', 'raw', '']
tz: timezone
Returns:
relevant current time or date
Examples:
>>> cur_dt = pd.Timestamp('now')
>>> cur_time(typ='dat... | def cur_time(typ='date', tz=DEFAULT_TZ) -> (datetime.date, str):
"""
Current time
Args:
typ: one of ['date', 'time', 'time_path', 'raw', '']
tz: timezone
Returns:
relevant current time or date
Examples:
>>> cur_dt = pd.Timestamp('now')
>>> cur_time(typ='dat... | [
"Current",
"time"
] | alpha-xone/xbbg | python | https://github.com/alpha-xone/xbbg/blob/70226eb19a72a08144b5d8cea9db4913200f7bc5/xbbg/core/utils.py#L82-L113 | [
"def",
"cur_time",
"(",
"typ",
"=",
"'date'",
",",
"tz",
"=",
"DEFAULT_TZ",
")",
"->",
"(",
"datetime",
".",
"date",
",",
"str",
")",
":",
"dt",
"=",
"pd",
".",
"Timestamp",
"(",
"'now'",
",",
"tz",
"=",
"tz",
")",
"if",
"typ",
"==",
"'date'",
... | 70226eb19a72a08144b5d8cea9db4913200f7bc5 |
valid | to_str | Convert dict to string
Args:
data: dict
fmt: how key and value being represented
sep: how pairs of key and value are seperated
public_only: if display public members only
Returns:
str: string representation of dict
Examples:
>>> test_dict = dict(b=1, a=0, c... | xbbg/core/utils.py | def to_str(
data: dict, fmt='{key}={value}', sep=', ', public_only=True
) -> str:
"""
Convert dict to string
Args:
data: dict
fmt: how key and value being represented
sep: how pairs of key and value are seperated
public_only: if display public members only
Retur... | def to_str(
data: dict, fmt='{key}={value}', sep=', ', public_only=True
) -> str:
"""
Convert dict to string
Args:
data: dict
fmt: how key and value being represented
sep: how pairs of key and value are seperated
public_only: if display public members only
Retur... | [
"Convert",
"dict",
"to",
"string"
] | alpha-xone/xbbg | python | https://github.com/alpha-xone/xbbg/blob/70226eb19a72a08144b5d8cea9db4913200f7bc5/xbbg/core/utils.py#L151-L181 | [
"def",
"to_str",
"(",
"data",
":",
"dict",
",",
"fmt",
"=",
"'{key}={value}'",
",",
"sep",
"=",
"', '",
",",
"public_only",
"=",
"True",
")",
"->",
"str",
":",
"if",
"public_only",
":",
"keys",
"=",
"list",
"(",
"filter",
"(",
"lambda",
"vv",
":",
... | 70226eb19a72a08144b5d8cea9db4913200f7bc5 |
valid | load_module | Load module from full path
Args:
full_path: module full path name
Returns:
python module
References:
https://stackoverflow.com/a/67692/1332656
Examples:
>>> import os
>>>
>>> cur_file = os.path.abspath(__file__).replace('\\\\', '/')
>>> cur_path = ... | xbbg/core/utils.py | def load_module(full_path):
"""
Load module from full path
Args:
full_path: module full path name
Returns:
python module
References:
https://stackoverflow.com/a/67692/1332656
Examples:
>>> import os
>>>
>>> cur_file = os.path.abspath(__file__).repl... | def load_module(full_path):
"""
Load module from full path
Args:
full_path: module full path name
Returns:
python module
References:
https://stackoverflow.com/a/67692/1332656
Examples:
>>> import os
>>>
>>> cur_file = os.path.abspath(__file__).repl... | [
"Load",
"module",
"from",
"full",
"path",
"Args",
":",
"full_path",
":",
"module",
"full",
"path",
"name",
"Returns",
":",
"python",
"module",
"References",
":",
"https",
":",
"//",
"stackoverflow",
".",
"com",
"/",
"a",
"/",
"67692",
"/",
"1332656",
"Ex... | alpha-xone/xbbg | python | https://github.com/alpha-xone/xbbg/blob/70226eb19a72a08144b5d8cea9db4913200f7bc5/xbbg/core/utils.py#L204-L235 | [
"def",
"load_module",
"(",
"full_path",
")",
":",
"from",
"importlib",
"import",
"util",
"file_name",
"=",
"full_path",
".",
"replace",
"(",
"'\\\\'",
",",
"'/'",
")",
".",
"split",
"(",
"'/'",
")",
"[",
"-",
"1",
"]",
"if",
"file_name",
"[",
"-",
"3... | 70226eb19a72a08144b5d8cea9db4913200f7bc5 |
valid | load_info | Load parameters for assets
Args:
cat: category
Returns:
dict
Examples:
>>> import pandas as pd
>>>
>>> assets = load_info(cat='assets')
>>> all(cat in assets for cat in ['Equity', 'Index', 'Curncy', 'Corp'])
True
>>> os.environ['BBG_PATH'] =... | xbbg/io/param.py | def load_info(cat):
"""
Load parameters for assets
Args:
cat: category
Returns:
dict
Examples:
>>> import pandas as pd
>>>
>>> assets = load_info(cat='assets')
>>> all(cat in assets for cat in ['Equity', 'Index', 'Curncy', 'Corp'])
True
... | def load_info(cat):
"""
Load parameters for assets
Args:
cat: category
Returns:
dict
Examples:
>>> import pandas as pd
>>>
>>> assets = load_info(cat='assets')
>>> all(cat in assets for cat in ['Equity', 'Index', 'Curncy', 'Corp'])
True
... | [
"Load",
"parameters",
"for",
"assets"
] | alpha-xone/xbbg | python | https://github.com/alpha-xone/xbbg/blob/70226eb19a72a08144b5d8cea9db4913200f7bc5/xbbg/io/param.py#L12-L48 | [
"def",
"load_info",
"(",
"cat",
")",
":",
"res",
"=",
"_load_yaml_",
"(",
"f'{PKG_PATH}/markets/{cat}.yml'",
")",
"root",
"=",
"os",
".",
"environ",
".",
"get",
"(",
"'BBG_ROOT'",
",",
"''",
")",
".",
"replace",
"(",
"'\\\\'",
",",
"'/'",
")",
"if",
"n... | 70226eb19a72a08144b5d8cea9db4913200f7bc5 |
valid | _load_yaml_ | Load assets infomation from file
Args:
file_name: file name
Returns:
dict | xbbg/io/param.py | def _load_yaml_(file_name):
"""
Load assets infomation from file
Args:
file_name: file name
Returns:
dict
"""
if not os.path.exists(file_name): return dict()
with open(file_name, 'r', encoding='utf-8') as fp:
return YAML().load(stream=fp) | def _load_yaml_(file_name):
"""
Load assets infomation from file
Args:
file_name: file name
Returns:
dict
"""
if not os.path.exists(file_name): return dict()
with open(file_name, 'r', encoding='utf-8') as fp:
return YAML().load(stream=fp) | [
"Load",
"assets",
"infomation",
"from",
"file"
] | alpha-xone/xbbg | python | https://github.com/alpha-xone/xbbg/blob/70226eb19a72a08144b5d8cea9db4913200f7bc5/xbbg/io/param.py#L51-L64 | [
"def",
"_load_yaml_",
"(",
"file_name",
")",
":",
"if",
"not",
"os",
".",
"path",
".",
"exists",
"(",
"file_name",
")",
":",
"return",
"dict",
"(",
")",
"with",
"open",
"(",
"file_name",
",",
"'r'",
",",
"encoding",
"=",
"'utf-8'",
")",
"as",
"fp",
... | 70226eb19a72a08144b5d8cea9db4913200f7bc5 |
valid | to_hour | Convert YAML input to hours
Args:
num: number in YMAL file, e.g., 900, 1700, etc.
Returns:
str
Examples:
>>> to_hour(900)
'09:00'
>>> to_hour(1700)
'17:00' | xbbg/io/param.py | def to_hour(num) -> str:
"""
Convert YAML input to hours
Args:
num: number in YMAL file, e.g., 900, 1700, etc.
Returns:
str
Examples:
>>> to_hour(900)
'09:00'
>>> to_hour(1700)
'17:00'
"""
to_str = str(int(num))
return pd.Timestamp(f'{to... | def to_hour(num) -> str:
"""
Convert YAML input to hours
Args:
num: number in YMAL file, e.g., 900, 1700, etc.
Returns:
str
Examples:
>>> to_hour(900)
'09:00'
>>> to_hour(1700)
'17:00'
"""
to_str = str(int(num))
return pd.Timestamp(f'{to... | [
"Convert",
"YAML",
"input",
"to",
"hours"
] | alpha-xone/xbbg | python | https://github.com/alpha-xone/xbbg/blob/70226eb19a72a08144b5d8cea9db4913200f7bc5/xbbg/io/param.py#L67-L84 | [
"def",
"to_hour",
"(",
"num",
")",
"->",
"str",
":",
"to_str",
"=",
"str",
"(",
"int",
"(",
"num",
")",
")",
"return",
"pd",
".",
"Timestamp",
"(",
"f'{to_str[:-2]}:{to_str[-2:]}'",
")",
".",
"strftime",
"(",
"'%H:%M'",
")"
] | 70226eb19a72a08144b5d8cea9db4913200f7bc5 |
valid | abspath | Absolute path
Args:
cur_file: __file__ or file or path str
parent: level of parent to look for
Returns:
str | xbbg/io/files.py | def abspath(cur_file, parent=0) -> str:
"""
Absolute path
Args:
cur_file: __file__ or file or path str
parent: level of parent to look for
Returns:
str
"""
file_path = os.path.abspath(cur_file).replace('\\', '/')
if os.path.isdir(file_path) and parent == 0: return f... | def abspath(cur_file, parent=0) -> str:
"""
Absolute path
Args:
cur_file: __file__ or file or path str
parent: level of parent to look for
Returns:
str
"""
file_path = os.path.abspath(cur_file).replace('\\', '/')
if os.path.isdir(file_path) and parent == 0: return f... | [
"Absolute",
"path"
] | alpha-xone/xbbg | python | https://github.com/alpha-xone/xbbg/blob/70226eb19a72a08144b5d8cea9db4913200f7bc5/xbbg/io/files.py#L21-L35 | [
"def",
"abspath",
"(",
"cur_file",
",",
"parent",
"=",
"0",
")",
"->",
"str",
":",
"file_path",
"=",
"os",
".",
"path",
".",
"abspath",
"(",
"cur_file",
")",
".",
"replace",
"(",
"'\\\\'",
",",
"'/'",
")",
"if",
"os",
".",
"path",
".",
"isdir",
"... | 70226eb19a72a08144b5d8cea9db4913200f7bc5 |
valid | create_folder | Make folder as well as all parent folders if not exists
Args:
path_name: full path name
is_file: whether input is name of file | xbbg/io/files.py | def create_folder(path_name: str, is_file=False):
"""
Make folder as well as all parent folders if not exists
Args:
path_name: full path name
is_file: whether input is name of file
"""
path_sep = path_name.replace('\\', '/').split('/')
for i in range(1, len(path_sep) + (0 if is_... | def create_folder(path_name: str, is_file=False):
"""
Make folder as well as all parent folders if not exists
Args:
path_name: full path name
is_file: whether input is name of file
"""
path_sep = path_name.replace('\\', '/').split('/')
for i in range(1, len(path_sep) + (0 if is_... | [
"Make",
"folder",
"as",
"well",
"as",
"all",
"parent",
"folders",
"if",
"not",
"exists"
] | alpha-xone/xbbg | python | https://github.com/alpha-xone/xbbg/blob/70226eb19a72a08144b5d8cea9db4913200f7bc5/xbbg/io/files.py#L38-L49 | [
"def",
"create_folder",
"(",
"path_name",
":",
"str",
",",
"is_file",
"=",
"False",
")",
":",
"path_sep",
"=",
"path_name",
".",
"replace",
"(",
"'\\\\'",
",",
"'/'",
")",
".",
"split",
"(",
"'/'",
")",
"for",
"i",
"in",
"range",
"(",
"1",
",",
"le... | 70226eb19a72a08144b5d8cea9db4913200f7bc5 |
valid | all_files | Search all files with criteria
Returned list will be sorted by last modified
Args:
path_name: full path name
keyword: keyword to search
ext: file extensions, split by ','
full_path: whether return full path (default True)
has_date: whether has date in file name (default ... | xbbg/io/files.py | def all_files(
path_name, keyword='', ext='', full_path=True,
has_date=False, date_fmt=DATE_FMT
) -> list:
"""
Search all files with criteria
Returned list will be sorted by last modified
Args:
path_name: full path name
keyword: keyword to search
ext: file extens... | def all_files(
path_name, keyword='', ext='', full_path=True,
has_date=False, date_fmt=DATE_FMT
) -> list:
"""
Search all files with criteria
Returned list will be sorted by last modified
Args:
path_name: full path name
keyword: keyword to search
ext: file extens... | [
"Search",
"all",
"files",
"with",
"criteria",
"Returned",
"list",
"will",
"be",
"sorted",
"by",
"last",
"modified"
] | alpha-xone/xbbg | python | https://github.com/alpha-xone/xbbg/blob/70226eb19a72a08144b5d8cea9db4913200f7bc5/xbbg/io/files.py#L52-L91 | [
"def",
"all_files",
"(",
"path_name",
",",
"keyword",
"=",
"''",
",",
"ext",
"=",
"''",
",",
"full_path",
"=",
"True",
",",
"has_date",
"=",
"False",
",",
"date_fmt",
"=",
"DATE_FMT",
")",
"->",
"list",
":",
"if",
"not",
"os",
".",
"path",
".",
"ex... | 70226eb19a72a08144b5d8cea9db4913200f7bc5 |
valid | all_folders | Search all folders with criteria
Returned list will be sorted by last modified
Args:
path_name: full path name
keyword: keyword to search
has_date: whether has date in file name (default False)
date_fmt: date format to check for has_date parameter
Returns:
list: all... | xbbg/io/files.py | def all_folders(
path_name, keyword='', has_date=False, date_fmt=DATE_FMT
) -> list:
"""
Search all folders with criteria
Returned list will be sorted by last modified
Args:
path_name: full path name
keyword: keyword to search
has_date: whether has date in file name (def... | def all_folders(
path_name, keyword='', has_date=False, date_fmt=DATE_FMT
) -> list:
"""
Search all folders with criteria
Returned list will be sorted by last modified
Args:
path_name: full path name
keyword: keyword to search
has_date: whether has date in file name (def... | [
"Search",
"all",
"folders",
"with",
"criteria",
"Returned",
"list",
"will",
"be",
"sorted",
"by",
"last",
"modified"
] | alpha-xone/xbbg | python | https://github.com/alpha-xone/xbbg/blob/70226eb19a72a08144b5d8cea9db4913200f7bc5/xbbg/io/files.py#L94-L128 | [
"def",
"all_folders",
"(",
"path_name",
",",
"keyword",
"=",
"''",
",",
"has_date",
"=",
"False",
",",
"date_fmt",
"=",
"DATE_FMT",
")",
"->",
"list",
":",
"if",
"not",
"os",
".",
"path",
".",
"exists",
"(",
"path",
"=",
"path_name",
")",
":",
"retur... | 70226eb19a72a08144b5d8cea9db4913200f7bc5 |
valid | sort_by_modified | Sort files or folders by modified time
Args:
files_or_folders: list of files or folders
Returns:
list | xbbg/io/files.py | def sort_by_modified(files_or_folders: list) -> list:
"""
Sort files or folders by modified time
Args:
files_or_folders: list of files or folders
Returns:
list
"""
return sorted(files_or_folders, key=os.path.getmtime, reverse=True) | def sort_by_modified(files_or_folders: list) -> list:
"""
Sort files or folders by modified time
Args:
files_or_folders: list of files or folders
Returns:
list
"""
return sorted(files_or_folders, key=os.path.getmtime, reverse=True) | [
"Sort",
"files",
"or",
"folders",
"by",
"modified",
"time"
] | alpha-xone/xbbg | python | https://github.com/alpha-xone/xbbg/blob/70226eb19a72a08144b5d8cea9db4913200f7bc5/xbbg/io/files.py#L131-L141 | [
"def",
"sort_by_modified",
"(",
"files_or_folders",
":",
"list",
")",
"->",
"list",
":",
"return",
"sorted",
"(",
"files_or_folders",
",",
"key",
"=",
"os",
".",
"path",
".",
"getmtime",
",",
"reverse",
"=",
"True",
")"
] | 70226eb19a72a08144b5d8cea9db4913200f7bc5 |
valid | filter_by_dates | Filter files or dates by date patterns
Args:
files_or_folders: list of files or folders
date_fmt: date format
Returns:
list | xbbg/io/files.py | def filter_by_dates(files_or_folders: list, date_fmt=DATE_FMT) -> list:
"""
Filter files or dates by date patterns
Args:
files_or_folders: list of files or folders
date_fmt: date format
Returns:
list
"""
r = re.compile(f'.*{date_fmt}.*')
return list(filter(
... | def filter_by_dates(files_or_folders: list, date_fmt=DATE_FMT) -> list:
"""
Filter files or dates by date patterns
Args:
files_or_folders: list of files or folders
date_fmt: date format
Returns:
list
"""
r = re.compile(f'.*{date_fmt}.*')
return list(filter(
... | [
"Filter",
"files",
"or",
"dates",
"by",
"date",
"patterns"
] | alpha-xone/xbbg | python | https://github.com/alpha-xone/xbbg/blob/70226eb19a72a08144b5d8cea9db4913200f7bc5/xbbg/io/files.py#L144-L159 | [
"def",
"filter_by_dates",
"(",
"files_or_folders",
":",
"list",
",",
"date_fmt",
"=",
"DATE_FMT",
")",
"->",
"list",
":",
"r",
"=",
"re",
".",
"compile",
"(",
"f'.*{date_fmt}.*'",
")",
"return",
"list",
"(",
"filter",
"(",
"lambda",
"vv",
":",
"r",
".",
... | 70226eb19a72a08144b5d8cea9db4913200f7bc5 |
valid | file_modified_time | File modified time in python
Args:
file_name: file name
Returns:
pd.Timestamp | xbbg/io/files.py | def file_modified_time(file_name) -> pd.Timestamp:
"""
File modified time in python
Args:
file_name: file name
Returns:
pd.Timestamp
"""
return pd.to_datetime(time.ctime(os.path.getmtime(filename=file_name))) | def file_modified_time(file_name) -> pd.Timestamp:
"""
File modified time in python
Args:
file_name: file name
Returns:
pd.Timestamp
"""
return pd.to_datetime(time.ctime(os.path.getmtime(filename=file_name))) | [
"File",
"modified",
"time",
"in",
"python"
] | alpha-xone/xbbg | python | https://github.com/alpha-xone/xbbg/blob/70226eb19a72a08144b5d8cea9db4913200f7bc5/xbbg/io/files.py#L191-L201 | [
"def",
"file_modified_time",
"(",
"file_name",
")",
"->",
"pd",
".",
"Timestamp",
":",
"return",
"pd",
".",
"to_datetime",
"(",
"time",
".",
"ctime",
"(",
"os",
".",
"path",
".",
"getmtime",
"(",
"filename",
"=",
"file_name",
")",
")",
")"
] | 70226eb19a72a08144b5d8cea9db4913200f7bc5 |
valid | get_interval | Get interval from defined session
Args:
ticker: ticker
session: session
Returns:
Session of start_time and end_time
Examples:
>>> get_interval('005490 KS Equity', 'day_open_30')
Session(start_time='09:00', end_time='09:30')
>>> get_interval('005490 KS Equit... | xbbg/core/intervals.py | def get_interval(ticker, session) -> Session:
"""
Get interval from defined session
Args:
ticker: ticker
session: session
Returns:
Session of start_time and end_time
Examples:
>>> get_interval('005490 KS Equity', 'day_open_30')
Session(start_time='09:00', e... | def get_interval(ticker, session) -> Session:
"""
Get interval from defined session
Args:
ticker: ticker
session: session
Returns:
Session of start_time and end_time
Examples:
>>> get_interval('005490 KS Equity', 'day_open_30')
Session(start_time='09:00', e... | [
"Get",
"interval",
"from",
"defined",
"session"
] | alpha-xone/xbbg | python | https://github.com/alpha-xone/xbbg/blob/70226eb19a72a08144b5d8cea9db4913200f7bc5/xbbg/core/intervals.py#L13-L56 | [
"def",
"get_interval",
"(",
"ticker",
",",
"session",
")",
"->",
"Session",
":",
"if",
"'_'",
"not",
"in",
"session",
":",
"session",
"=",
"f'{session}_normal_0_0'",
"interval",
"=",
"Intervals",
"(",
"ticker",
"=",
"ticker",
")",
"ss_info",
"=",
"session",
... | 70226eb19a72a08144b5d8cea9db4913200f7bc5 |
valid | shift_time | Shift start time by mins
Args:
start_time: start time in terms of HH:MM string
mins: number of minutes (+ / -)
Returns:
end time in terms of HH:MM string | xbbg/core/intervals.py | def shift_time(start_time, mins) -> str:
"""
Shift start time by mins
Args:
start_time: start time in terms of HH:MM string
mins: number of minutes (+ / -)
Returns:
end time in terms of HH:MM string
"""
s_time = pd.Timestamp(start_time)
e_time = s_time + np.sign(min... | def shift_time(start_time, mins) -> str:
"""
Shift start time by mins
Args:
start_time: start time in terms of HH:MM string
mins: number of minutes (+ / -)
Returns:
end time in terms of HH:MM string
"""
s_time = pd.Timestamp(start_time)
e_time = s_time + np.sign(min... | [
"Shift",
"start",
"time",
"by",
"mins"
] | alpha-xone/xbbg | python | https://github.com/alpha-xone/xbbg/blob/70226eb19a72a08144b5d8cea9db4913200f7bc5/xbbg/core/intervals.py#L59-L72 | [
"def",
"shift_time",
"(",
"start_time",
",",
"mins",
")",
"->",
"str",
":",
"s_time",
"=",
"pd",
".",
"Timestamp",
"(",
"start_time",
")",
"e_time",
"=",
"s_time",
"+",
"np",
".",
"sign",
"(",
"mins",
")",
"*",
"pd",
".",
"Timedelta",
"(",
"f'00:{abs... | 70226eb19a72a08144b5d8cea9db4913200f7bc5 |
valid | Intervals.market_open | Time intervals for market open
Args:
session: [allday, day, am, pm, night]
mins: mintues after open
Returns:
Session of start_time and end_time | xbbg/core/intervals.py | def market_open(self, session, mins) -> Session:
"""
Time intervals for market open
Args:
session: [allday, day, am, pm, night]
mins: mintues after open
Returns:
Session of start_time and end_time
"""
if session not in self.exch: retu... | def market_open(self, session, mins) -> Session:
"""
Time intervals for market open
Args:
session: [allday, day, am, pm, night]
mins: mintues after open
Returns:
Session of start_time and end_time
"""
if session not in self.exch: retu... | [
"Time",
"intervals",
"for",
"market",
"open"
] | alpha-xone/xbbg | python | https://github.com/alpha-xone/xbbg/blob/70226eb19a72a08144b5d8cea9db4913200f7bc5/xbbg/core/intervals.py#L85-L98 | [
"def",
"market_open",
"(",
"self",
",",
"session",
",",
"mins",
")",
"->",
"Session",
":",
"if",
"session",
"not",
"in",
"self",
".",
"exch",
":",
"return",
"SessNA",
"start_time",
"=",
"self",
".",
"exch",
"[",
"session",
"]",
"[",
"0",
"]",
"return... | 70226eb19a72a08144b5d8cea9db4913200f7bc5 |
valid | Intervals.market_close | Time intervals for market close
Args:
session: [allday, day, am, pm, night]
mins: mintues before close
Returns:
Session of start_time and end_time | xbbg/core/intervals.py | def market_close(self, session, mins) -> Session:
"""
Time intervals for market close
Args:
session: [allday, day, am, pm, night]
mins: mintues before close
Returns:
Session of start_time and end_time
"""
if session not in self.exch: ... | def market_close(self, session, mins) -> Session:
"""
Time intervals for market close
Args:
session: [allday, day, am, pm, night]
mins: mintues before close
Returns:
Session of start_time and end_time
"""
if session not in self.exch: ... | [
"Time",
"intervals",
"for",
"market",
"close"
] | alpha-xone/xbbg | python | https://github.com/alpha-xone/xbbg/blob/70226eb19a72a08144b5d8cea9db4913200f7bc5/xbbg/core/intervals.py#L100-L113 | [
"def",
"market_close",
"(",
"self",
",",
"session",
",",
"mins",
")",
"->",
"Session",
":",
"if",
"session",
"not",
"in",
"self",
".",
"exch",
":",
"return",
"SessNA",
"end_time",
"=",
"self",
".",
"exch",
"[",
"session",
"]",
"[",
"-",
"1",
"]",
"... | 70226eb19a72a08144b5d8cea9db4913200f7bc5 |
valid | Intervals.market_normal | Time intervals between market
Args:
session: [allday, day, am, pm, night]
after_open: mins after open
before_close: mins before close
Returns:
Session of start_time and end_time | xbbg/core/intervals.py | def market_normal(self, session, after_open, before_close) -> Session:
"""
Time intervals between market
Args:
session: [allday, day, am, pm, night]
after_open: mins after open
before_close: mins before close
Returns:
Session of start_tim... | def market_normal(self, session, after_open, before_close) -> Session:
"""
Time intervals between market
Args:
session: [allday, day, am, pm, night]
after_open: mins after open
before_close: mins before close
Returns:
Session of start_tim... | [
"Time",
"intervals",
"between",
"market"
] | alpha-xone/xbbg | python | https://github.com/alpha-xone/xbbg/blob/70226eb19a72a08144b5d8cea9db4913200f7bc5/xbbg/core/intervals.py#L115-L141 | [
"def",
"market_normal",
"(",
"self",
",",
"session",
",",
"after_open",
",",
"before_close",
")",
"->",
"Session",
":",
"logger",
"=",
"logs",
".",
"get_logger",
"(",
"self",
".",
"market_normal",
")",
"if",
"session",
"not",
"in",
"self",
".",
"exch",
"... | 70226eb19a72a08144b5d8cea9db4913200f7bc5 |
valid | Intervals.market_exact | Explicitly specify start time and end time
Args:
session: predefined session
start_time: start time in terms of HHMM string
end_time: end time in terms of HHMM string
Returns:
Session of start_time and end_time | xbbg/core/intervals.py | def market_exact(self, session, start_time: str, end_time: str) -> Session:
"""
Explicitly specify start time and end time
Args:
session: predefined session
start_time: start time in terms of HHMM string
end_time: end time in terms of HHMM string
Ret... | def market_exact(self, session, start_time: str, end_time: str) -> Session:
"""
Explicitly specify start time and end time
Args:
session: predefined session
start_time: start time in terms of HHMM string
end_time: end time in terms of HHMM string
Ret... | [
"Explicitly",
"specify",
"start",
"time",
"and",
"end",
"time"
] | alpha-xone/xbbg | python | https://github.com/alpha-xone/xbbg/blob/70226eb19a72a08144b5d8cea9db4913200f7bc5/xbbg/core/intervals.py#L143-L171 | [
"def",
"market_exact",
"(",
"self",
",",
"session",
",",
"start_time",
":",
"str",
",",
"end_time",
":",
"str",
")",
"->",
"Session",
":",
"if",
"session",
"not",
"in",
"self",
".",
"exch",
":",
"return",
"SessNA",
"ss",
"=",
"self",
".",
"exch",
"["... | 70226eb19a72a08144b5d8cea9db4913200f7bc5 |
valid | get_tz | Convert tz from ticker / shorthands to timezone
Args:
tz: ticker or timezone shorthands
Returns:
str: Python timzone
Examples:
>>> get_tz('NY')
'America/New_York'
>>> get_tz(TimeZone.NY)
'America/New_York'
>>> get_tz('BHP AU Equity')
'Austra... | xbbg/core/timezone.py | def get_tz(tz) -> str:
"""
Convert tz from ticker / shorthands to timezone
Args:
tz: ticker or timezone shorthands
Returns:
str: Python timzone
Examples:
>>> get_tz('NY')
'America/New_York'
>>> get_tz(TimeZone.NY)
'America/New_York'
>>> get_... | def get_tz(tz) -> str:
"""
Convert tz from ticker / shorthands to timezone
Args:
tz: ticker or timezone shorthands
Returns:
str: Python timzone
Examples:
>>> get_tz('NY')
'America/New_York'
>>> get_tz(TimeZone.NY)
'America/New_York'
>>> get_... | [
"Convert",
"tz",
"from",
"ticker",
"/",
"shorthands",
"to",
"timezone"
] | alpha-xone/xbbg | python | https://github.com/alpha-xone/xbbg/blob/70226eb19a72a08144b5d8cea9db4913200f7bc5/xbbg/core/timezone.py#L11-L42 | [
"def",
"get_tz",
"(",
"tz",
")",
"->",
"str",
":",
"from",
"xbbg",
".",
"const",
"import",
"exch_info",
"if",
"tz",
"is",
"None",
":",
"return",
"DEFAULT_TZ",
"to_tz",
"=",
"tz",
"if",
"isinstance",
"(",
"tz",
",",
"str",
")",
":",
"if",
"hasattr",
... | 70226eb19a72a08144b5d8cea9db4913200f7bc5 |
valid | tz_convert | Convert to tz
Args:
dt: date time
to_tz: to tz
from_tz: from tz - will be ignored if tz from dt is given
Returns:
str: date & time
Examples:
>>> dt_1 = pd.Timestamp('2018-09-10 16:00', tz='Asia/Hong_Kong')
>>> tz_convert(dt_1, to_tz='NY')
'2018-09-1... | xbbg/core/timezone.py | def tz_convert(dt, to_tz, from_tz=None) -> str:
"""
Convert to tz
Args:
dt: date time
to_tz: to tz
from_tz: from tz - will be ignored if tz from dt is given
Returns:
str: date & time
Examples:
>>> dt_1 = pd.Timestamp('2018-09-10 16:00', tz='Asia/Hong_Kong')... | def tz_convert(dt, to_tz, from_tz=None) -> str:
"""
Convert to tz
Args:
dt: date time
to_tz: to tz
from_tz: from tz - will be ignored if tz from dt is given
Returns:
str: date & time
Examples:
>>> dt_1 = pd.Timestamp('2018-09-10 16:00', tz='Asia/Hong_Kong')... | [
"Convert",
"to",
"tz"
] | alpha-xone/xbbg | python | https://github.com/alpha-xone/xbbg/blob/70226eb19a72a08144b5d8cea9db4913200f7bc5/xbbg/core/timezone.py#L45-L73 | [
"def",
"tz_convert",
"(",
"dt",
",",
"to_tz",
",",
"from_tz",
"=",
"None",
")",
"->",
"str",
":",
"logger",
"=",
"logs",
".",
"get_logger",
"(",
"tz_convert",
",",
"level",
"=",
"'info'",
")",
"f_tz",
",",
"t_tz",
"=",
"get_tz",
"(",
"from_tz",
")",
... | 70226eb19a72a08144b5d8cea9db4913200f7bc5 |
valid | missing_info | Full infomation for missing query | xbbg/core/missing.py | def missing_info(**kwargs) -> str:
"""
Full infomation for missing query
"""
func = kwargs.pop('func', 'unknown')
if 'ticker' in kwargs: kwargs['ticker'] = kwargs['ticker'].replace('/', '_')
info = utils.to_str(kwargs, fmt='{value}', sep='/')[1:-1]
return f'{func}/{info}' | def missing_info(**kwargs) -> str:
"""
Full infomation for missing query
"""
func = kwargs.pop('func', 'unknown')
if 'ticker' in kwargs: kwargs['ticker'] = kwargs['ticker'].replace('/', '_')
info = utils.to_str(kwargs, fmt='{value}', sep='/')[1:-1]
return f'{func}/{info}' | [
"Full",
"infomation",
"for",
"missing",
"query"
] | alpha-xone/xbbg | python | https://github.com/alpha-xone/xbbg/blob/70226eb19a72a08144b5d8cea9db4913200f7bc5/xbbg/core/missing.py#L8-L15 | [
"def",
"missing_info",
"(",
"*",
"*",
"kwargs",
")",
"->",
"str",
":",
"func",
"=",
"kwargs",
".",
"pop",
"(",
"'func'",
",",
"'unknown'",
")",
"if",
"'ticker'",
"in",
"kwargs",
":",
"kwargs",
"[",
"'ticker'",
"]",
"=",
"kwargs",
"[",
"'ticker'",
"]"... | 70226eb19a72a08144b5d8cea9db4913200f7bc5 |
valid | current_missing | Check number of trials for missing values
Returns:
int: number of trials already tried | xbbg/core/missing.py | def current_missing(**kwargs) -> int:
"""
Check number of trials for missing values
Returns:
int: number of trials already tried
"""
data_path = os.environ.get(BBG_ROOT, '').replace('\\', '/')
if not data_path: return 0
return len(files.all_files(f'{data_path}/Logs/{missing_info(**k... | def current_missing(**kwargs) -> int:
"""
Check number of trials for missing values
Returns:
int: number of trials already tried
"""
data_path = os.environ.get(BBG_ROOT, '').replace('\\', '/')
if not data_path: return 0
return len(files.all_files(f'{data_path}/Logs/{missing_info(**k... | [
"Check",
"number",
"of",
"trials",
"for",
"missing",
"values"
] | alpha-xone/xbbg | python | https://github.com/alpha-xone/xbbg/blob/70226eb19a72a08144b5d8cea9db4913200f7bc5/xbbg/core/missing.py#L18-L27 | [
"def",
"current_missing",
"(",
"*",
"*",
"kwargs",
")",
"->",
"int",
":",
"data_path",
"=",
"os",
".",
"environ",
".",
"get",
"(",
"BBG_ROOT",
",",
"''",
")",
".",
"replace",
"(",
"'\\\\'",
",",
"'/'",
")",
"if",
"not",
"data_path",
":",
"return",
... | 70226eb19a72a08144b5d8cea9db4913200f7bc5 |
valid | update_missing | Update number of trials for missing values | xbbg/core/missing.py | def update_missing(**kwargs):
"""
Update number of trials for missing values
"""
data_path = os.environ.get(BBG_ROOT, '').replace('\\', '/')
if not data_path: return
if len(kwargs) == 0: return
log_path = f'{data_path}/Logs/{missing_info(**kwargs)}'
cnt = len(files.all_files(log_path))... | def update_missing(**kwargs):
"""
Update number of trials for missing values
"""
data_path = os.environ.get(BBG_ROOT, '').replace('\\', '/')
if not data_path: return
if len(kwargs) == 0: return
log_path = f'{data_path}/Logs/{missing_info(**kwargs)}'
cnt = len(files.all_files(log_path))... | [
"Update",
"number",
"of",
"trials",
"for",
"missing",
"values"
] | alpha-xone/xbbg | python | https://github.com/alpha-xone/xbbg/blob/70226eb19a72a08144b5d8cea9db4913200f7bc5/xbbg/core/missing.py#L30-L42 | [
"def",
"update_missing",
"(",
"*",
"*",
"kwargs",
")",
":",
"data_path",
"=",
"os",
".",
"environ",
".",
"get",
"(",
"BBG_ROOT",
",",
"''",
")",
".",
"replace",
"(",
"'\\\\'",
",",
"'/'",
")",
"if",
"not",
"data_path",
":",
"return",
"if",
"len",
"... | 70226eb19a72a08144b5d8cea9db4913200f7bc5 |
valid | public | Decorator for public views that do not require authentication
Sets an attribute in the fuction STRONGHOLD_IS_PUBLIC to True | stronghold/decorators.py | def public(function):
"""
Decorator for public views that do not require authentication
Sets an attribute in the fuction STRONGHOLD_IS_PUBLIC to True
"""
orig_func = function
while isinstance(orig_func, partial):
orig_func = orig_func.func
set_view_func_public(orig_func)
return ... | def public(function):
"""
Decorator for public views that do not require authentication
Sets an attribute in the fuction STRONGHOLD_IS_PUBLIC to True
"""
orig_func = function
while isinstance(orig_func, partial):
orig_func = orig_func.func
set_view_func_public(orig_func)
return ... | [
"Decorator",
"for",
"public",
"views",
"that",
"do",
"not",
"require",
"authentication",
"Sets",
"an",
"attribute",
"in",
"the",
"fuction",
"STRONGHOLD_IS_PUBLIC",
"to",
"True"
] | mgrouchy/django-stronghold | python | https://github.com/mgrouchy/django-stronghold/blob/4b1e0dd7118fb3c2398f7d3bc93467f907b2bf67/stronghold/decorators.py#L5-L15 | [
"def",
"public",
"(",
"function",
")",
":",
"orig_func",
"=",
"function",
"while",
"isinstance",
"(",
"orig_func",
",",
"partial",
")",
":",
"orig_func",
"=",
"orig_func",
".",
"func",
"set_view_func_public",
"(",
"orig_func",
")",
"return",
"function"
] | 4b1e0dd7118fb3c2398f7d3bc93467f907b2bf67 |
valid | custom_req | Utility for sending a predefined request and printing response as well
as storing messages in a list, useful for testing
Parameters
----------
session: blpapi.session.Session
request: blpapi.request.Request
Request to be sent
Returns
-------
List of all messages received | pdblp/utils.py | def custom_req(session, request):
"""
Utility for sending a predefined request and printing response as well
as storing messages in a list, useful for testing
Parameters
----------
session: blpapi.session.Session
request: blpapi.request.Request
Request to be sent
Returns
--... | def custom_req(session, request):
"""
Utility for sending a predefined request and printing response as well
as storing messages in a list, useful for testing
Parameters
----------
session: blpapi.session.Session
request: blpapi.request.Request
Request to be sent
Returns
--... | [
"Utility",
"for",
"sending",
"a",
"predefined",
"request",
"and",
"printing",
"response",
"as",
"well",
"as",
"storing",
"messages",
"in",
"a",
"list",
"useful",
"for",
"testing"
] | matthewgilbert/pdblp | python | https://github.com/matthewgilbert/pdblp/blob/aaef49ad6fca9af6ee44739d6e7e1cc3e7b0f8e2/pdblp/utils.py#L4-L36 | [
"def",
"custom_req",
"(",
"session",
",",
"request",
")",
":",
"# flush event queue in case previous call errored out",
"while",
"(",
"session",
".",
"tryNextEvent",
"(",
")",
")",
":",
"pass",
"print",
"(",
"\"Sending Request:\\n %s\"",
"%",
"request",
")",
"sessio... | aaef49ad6fca9af6ee44739d6e7e1cc3e7b0f8e2 |
valid | to_dict_list | Translate a string representation of a Bloomberg Open API Request/Response
into a list of dictionaries.return
Parameters
----------
mystr: str
A string representation of one or more blpapi.request.Request or
blp.message.Message, these should be '\\n' seperated | pdblp/parser.py | def to_dict_list(mystr):
"""
Translate a string representation of a Bloomberg Open API Request/Response
into a list of dictionaries.return
Parameters
----------
mystr: str
A string representation of one or more blpapi.request.Request or
blp.message.Message, these should be '\\n'... | def to_dict_list(mystr):
"""
Translate a string representation of a Bloomberg Open API Request/Response
into a list of dictionaries.return
Parameters
----------
mystr: str
A string representation of one or more blpapi.request.Request or
blp.message.Message, these should be '\\n'... | [
"Translate",
"a",
"string",
"representation",
"of",
"a",
"Bloomberg",
"Open",
"API",
"Request",
"/",
"Response",
"into",
"a",
"list",
"of",
"dictionaries",
".",
"return"
] | matthewgilbert/pdblp | python | https://github.com/matthewgilbert/pdblp/blob/aaef49ad6fca9af6ee44739d6e7e1cc3e7b0f8e2/pdblp/parser.py#L51-L66 | [
"def",
"to_dict_list",
"(",
"mystr",
")",
":",
"res",
"=",
"_parse",
"(",
"mystr",
")",
"dicts",
"=",
"[",
"]",
"for",
"res_dict",
"in",
"res",
":",
"dicts",
".",
"append",
"(",
"res_dict",
".",
"asDict",
"(",
")",
")",
"return",
"dicts"
] | aaef49ad6fca9af6ee44739d6e7e1cc3e7b0f8e2 |
valid | bopen | Open and manage a BCon wrapper to a Bloomberg API session
Parameters
----------
**kwargs:
Keyword arguments passed into pdblp.BCon initialization | pdblp/pdblp.py | def bopen(**kwargs):
"""
Open and manage a BCon wrapper to a Bloomberg API session
Parameters
----------
**kwargs:
Keyword arguments passed into pdblp.BCon initialization
"""
con = BCon(**kwargs)
con.start()
try:
yield con
finally:
con.stop() | def bopen(**kwargs):
"""
Open and manage a BCon wrapper to a Bloomberg API session
Parameters
----------
**kwargs:
Keyword arguments passed into pdblp.BCon initialization
"""
con = BCon(**kwargs)
con.start()
try:
yield con
finally:
con.stop() | [
"Open",
"and",
"manage",
"a",
"BCon",
"wrapper",
"to",
"a",
"Bloomberg",
"API",
"session"
] | matthewgilbert/pdblp | python | https://github.com/matthewgilbert/pdblp/blob/aaef49ad6fca9af6ee44739d6e7e1cc3e7b0f8e2/pdblp/pdblp.py#L40-L54 | [
"def",
"bopen",
"(",
"*",
"*",
"kwargs",
")",
":",
"con",
"=",
"BCon",
"(",
"*",
"*",
"kwargs",
")",
"con",
".",
"start",
"(",
")",
"try",
":",
"yield",
"con",
"finally",
":",
"con",
".",
"stop",
"(",
")"
] | aaef49ad6fca9af6ee44739d6e7e1cc3e7b0f8e2 |
valid | BCon.start | Start connection and initialize session services | pdblp/pdblp.py | def start(self):
"""
Start connection and initialize session services
"""
# flush event queue in defensive way
logger = _get_logger(self.debug)
started = self._session.start()
if started:
ev = self._session.nextEvent()
ev_name = _EVENT_DIC... | def start(self):
"""
Start connection and initialize session services
"""
# flush event queue in defensive way
logger = _get_logger(self.debug)
started = self._session.start()
if started:
ev = self._session.nextEvent()
ev_name = _EVENT_DIC... | [
"Start",
"connection",
"and",
"initialize",
"session",
"services"
] | matthewgilbert/pdblp | python | https://github.com/matthewgilbert/pdblp/blob/aaef49ad6fca9af6ee44739d6e7e1cc3e7b0f8e2/pdblp/pdblp.py#L117-L149 | [
"def",
"start",
"(",
"self",
")",
":",
"# flush event queue in defensive way",
"logger",
"=",
"_get_logger",
"(",
"self",
".",
"debug",
")",
"started",
"=",
"self",
".",
"_session",
".",
"start",
"(",
")",
"if",
"started",
":",
"ev",
"=",
"self",
".",
"_... | aaef49ad6fca9af6ee44739d6e7e1cc3e7b0f8e2 |
valid | BCon._init_services | Initialize blpapi.Session services | pdblp/pdblp.py | def _init_services(self):
"""
Initialize blpapi.Session services
"""
logger = _get_logger(self.debug)
# flush event queue in defensive way
opened = self._session.openService('//blp/refdata')
ev = self._session.nextEvent()
ev_name = _EVENT_DICT[ev.eventTyp... | def _init_services(self):
"""
Initialize blpapi.Session services
"""
logger = _get_logger(self.debug)
# flush event queue in defensive way
opened = self._session.openService('//blp/refdata')
ev = self._session.nextEvent()
ev_name = _EVENT_DICT[ev.eventTyp... | [
"Initialize",
"blpapi",
".",
"Session",
"services"
] | matthewgilbert/pdblp | python | https://github.com/matthewgilbert/pdblp/blob/aaef49ad6fca9af6ee44739d6e7e1cc3e7b0f8e2/pdblp/pdblp.py#L151-L186 | [
"def",
"_init_services",
"(",
"self",
")",
":",
"logger",
"=",
"_get_logger",
"(",
"self",
".",
"debug",
")",
"# flush event queue in defensive way",
"opened",
"=",
"self",
".",
"_session",
".",
"openService",
"(",
"'//blp/refdata'",
")",
"ev",
"=",
"self",
".... | aaef49ad6fca9af6ee44739d6e7e1cc3e7b0f8e2 |
valid | BCon.bdh | Get tickers and fields, return pandas DataFrame with columns as
MultiIndex with levels "ticker" and "field" and indexed by "date".
If long data is requested return DataFrame with columns
["date", "ticker", "field", "value"].
Parameters
----------
tickers: {list, string}
... | pdblp/pdblp.py | def bdh(self, tickers, flds, start_date, end_date, elms=None,
ovrds=None, longdata=False):
"""
Get tickers and fields, return pandas DataFrame with columns as
MultiIndex with levels "ticker" and "field" and indexed by "date".
If long data is requested return DataFrame with co... | def bdh(self, tickers, flds, start_date, end_date, elms=None,
ovrds=None, longdata=False):
"""
Get tickers and fields, return pandas DataFrame with columns as
MultiIndex with levels "ticker" and "field" and indexed by "date".
If long data is requested return DataFrame with co... | [
"Get",
"tickers",
"and",
"fields",
"return",
"pandas",
"DataFrame",
"with",
"columns",
"as",
"MultiIndex",
"with",
"levels",
"ticker",
"and",
"field",
"and",
"indexed",
"by",
"date",
".",
"If",
"long",
"data",
"is",
"requested",
"return",
"DataFrame",
"with",
... | matthewgilbert/pdblp | python | https://github.com/matthewgilbert/pdblp/blob/aaef49ad6fca9af6ee44739d6e7e1cc3e7b0f8e2/pdblp/pdblp.py#L240-L284 | [
"def",
"bdh",
"(",
"self",
",",
"tickers",
",",
"flds",
",",
"start_date",
",",
"end_date",
",",
"elms",
"=",
"None",
",",
"ovrds",
"=",
"None",
",",
"longdata",
"=",
"False",
")",
":",
"ovrds",
"=",
"[",
"]",
"if",
"not",
"ovrds",
"else",
"ovrds",... | aaef49ad6fca9af6ee44739d6e7e1cc3e7b0f8e2 |
valid | BCon.ref | Make a reference data request, get tickers and fields, return long
pandas DataFrame with columns [ticker, field, value]
Parameters
----------
tickers: {list, string}
String or list of strings corresponding to tickers
flds: {list, string}
String or list of... | pdblp/pdblp.py | def ref(self, tickers, flds, ovrds=None):
"""
Make a reference data request, get tickers and fields, return long
pandas DataFrame with columns [ticker, field, value]
Parameters
----------
tickers: {list, string}
String or list of strings corresponding to tick... | def ref(self, tickers, flds, ovrds=None):
"""
Make a reference data request, get tickers and fields, return long
pandas DataFrame with columns [ticker, field, value]
Parameters
----------
tickers: {list, string}
String or list of strings corresponding to tick... | [
"Make",
"a",
"reference",
"data",
"request",
"get",
"tickers",
"and",
"fields",
"return",
"long",
"pandas",
"DataFrame",
"with",
"columns",
"[",
"ticker",
"field",
"value",
"]"
] | matthewgilbert/pdblp | python | https://github.com/matthewgilbert/pdblp/blob/aaef49ad6fca9af6ee44739d6e7e1cc3e7b0f8e2/pdblp/pdblp.py#L322-L367 | [
"def",
"ref",
"(",
"self",
",",
"tickers",
",",
"flds",
",",
"ovrds",
"=",
"None",
")",
":",
"ovrds",
"=",
"[",
"]",
"if",
"not",
"ovrds",
"else",
"ovrds",
"logger",
"=",
"_get_logger",
"(",
"self",
".",
"debug",
")",
"if",
"type",
"(",
"tickers",
... | aaef49ad6fca9af6ee44739d6e7e1cc3e7b0f8e2 |
valid | BCon.bulkref_hist | Make iterative calls to bulkref() and create a long DataFrame with
columns [date, ticker, field, name, value, position] where each date
corresponds to overriding a historical data override field.
Parameters
----------
tickers: {list, string}
String or list of strings... | pdblp/pdblp.py | def bulkref_hist(self, tickers, flds, dates, ovrds=None,
date_field='REFERENCE_DATE'):
"""
Make iterative calls to bulkref() and create a long DataFrame with
columns [date, ticker, field, name, value, position] where each date
corresponds to overriding a historical d... | def bulkref_hist(self, tickers, flds, dates, ovrds=None,
date_field='REFERENCE_DATE'):
"""
Make iterative calls to bulkref() and create a long DataFrame with
columns [date, ticker, field, name, value, position] where each date
corresponds to overriding a historical d... | [
"Make",
"iterative",
"calls",
"to",
"bulkref",
"()",
"and",
"create",
"a",
"long",
"DataFrame",
"with",
"columns",
"[",
"date",
"ticker",
"field",
"name",
"value",
"position",
"]",
"where",
"each",
"date",
"corresponds",
"to",
"overriding",
"a",
"historical",
... | matthewgilbert/pdblp | python | https://github.com/matthewgilbert/pdblp/blob/aaef49ad6fca9af6ee44739d6e7e1cc3e7b0f8e2/pdblp/pdblp.py#L561-L608 | [
"def",
"bulkref_hist",
"(",
"self",
",",
"tickers",
",",
"flds",
",",
"dates",
",",
"ovrds",
"=",
"None",
",",
"date_field",
"=",
"'REFERENCE_DATE'",
")",
":",
"ovrds",
"=",
"[",
"]",
"if",
"not",
"ovrds",
"else",
"ovrds",
"if",
"type",
"(",
"tickers",... | aaef49ad6fca9af6ee44739d6e7e1cc3e7b0f8e2 |
valid | BCon.bdib | Get Open, High, Low, Close, Volume, and numEvents for a ticker.
Return pandas DataFrame
Parameters
----------
ticker: string
String corresponding to ticker
start_datetime: string
UTC datetime in format YYYY-mm-ddTHH:MM:SS
end_datetime: string
... | pdblp/pdblp.py | def bdib(self, ticker, start_datetime, end_datetime, event_type, interval,
elms=None):
"""
Get Open, High, Low, Close, Volume, and numEvents for a ticker.
Return pandas DataFrame
Parameters
----------
ticker: string
String corresponding to ticker... | def bdib(self, ticker, start_datetime, end_datetime, event_type, interval,
elms=None):
"""
Get Open, High, Low, Close, Volume, and numEvents for a ticker.
Return pandas DataFrame
Parameters
----------
ticker: string
String corresponding to ticker... | [
"Get",
"Open",
"High",
"Low",
"Close",
"Volume",
"and",
"numEvents",
"for",
"a",
"ticker",
".",
"Return",
"pandas",
"DataFrame"
] | matthewgilbert/pdblp | python | https://github.com/matthewgilbert/pdblp/blob/aaef49ad6fca9af6ee44739d6e7e1cc3e7b0f8e2/pdblp/pdblp.py#L630-L682 | [
"def",
"bdib",
"(",
"self",
",",
"ticker",
",",
"start_datetime",
",",
"end_datetime",
",",
"event_type",
",",
"interval",
",",
"elms",
"=",
"None",
")",
":",
"elms",
"=",
"[",
"]",
"if",
"not",
"elms",
"else",
"elms",
"# flush event queue in case previous c... | aaef49ad6fca9af6ee44739d6e7e1cc3e7b0f8e2 |
valid | BCon.bsrch | This function uses the Bloomberg API to retrieve 'bsrch' (Bloomberg
SRCH Data) queries. Returns list of tickers.
Parameters
----------
domain: string
A character string with the name of the domain to execute.
It can be a user defined SRCH screen, commodity screen... | pdblp/pdblp.py | def bsrch(self, domain):
"""
This function uses the Bloomberg API to retrieve 'bsrch' (Bloomberg
SRCH Data) queries. Returns list of tickers.
Parameters
----------
domain: string
A character string with the name of the domain to execute.
It can be... | def bsrch(self, domain):
"""
This function uses the Bloomberg API to retrieve 'bsrch' (Bloomberg
SRCH Data) queries. Returns list of tickers.
Parameters
----------
domain: string
A character string with the name of the domain to execute.
It can be... | [
"This",
"function",
"uses",
"the",
"Bloomberg",
"API",
"to",
"retrieve",
"bsrch",
"(",
"Bloomberg",
"SRCH",
"Data",
")",
"queries",
".",
"Returns",
"list",
"of",
"tickers",
"."
] | matthewgilbert/pdblp | python | https://github.com/matthewgilbert/pdblp/blob/aaef49ad6fca9af6ee44739d6e7e1cc3e7b0f8e2/pdblp/pdblp.py#L684-L712 | [
"def",
"bsrch",
"(",
"self",
",",
"domain",
")",
":",
"logger",
"=",
"_get_logger",
"(",
"self",
".",
"debug",
")",
"request",
"=",
"self",
".",
"exrService",
".",
"createRequest",
"(",
"'ExcelGetGridRequest'",
")",
"request",
".",
"set",
"(",
"'Domain'",
... | aaef49ad6fca9af6ee44739d6e7e1cc3e7b0f8e2 |
valid | assemble_one | Assemble one EVM instruction from its textual representation.
:param asmcode: assembly code for one instruction
:type asmcode: str
:param pc: program counter of the instruction(optional)
:type pc: int
:param fork: fork name (optional)
:type fork: str
:return: An ... | pyevmasm/evmasm.py | def assemble_one(asmcode, pc=0, fork=DEFAULT_FORK):
""" Assemble one EVM instruction from its textual representation.
:param asmcode: assembly code for one instruction
:type asmcode: str
:param pc: program counter of the instruction(optional)
:type pc: int
:param fork: fork ... | def assemble_one(asmcode, pc=0, fork=DEFAULT_FORK):
""" Assemble one EVM instruction from its textual representation.
:param asmcode: assembly code for one instruction
:type asmcode: str
:param pc: program counter of the instruction(optional)
:type pc: int
:param fork: fork ... | [
"Assemble",
"one",
"EVM",
"instruction",
"from",
"its",
"textual",
"representation",
"."
] | crytic/pyevmasm | python | https://github.com/crytic/pyevmasm/blob/d27daf19a36d630a31499e783b716cf1165798d8/pyevmasm/evmasm.py#L332-L361 | [
"def",
"assemble_one",
"(",
"asmcode",
",",
"pc",
"=",
"0",
",",
"fork",
"=",
"DEFAULT_FORK",
")",
":",
"try",
":",
"instruction_table",
"=",
"instruction_tables",
"[",
"fork",
"]",
"asmcode",
"=",
"asmcode",
".",
"strip",
"(",
")",
".",
"split",
"(",
... | d27daf19a36d630a31499e783b716cf1165798d8 |
valid | assemble_all | Assemble a sequence of textual representation of EVM instructions
:param asmcode: assembly code for any number of instructions
:type asmcode: str
:param pc: program counter of the first instruction(optional)
:type pc: int
:param fork: fork name (optional)
:type fork: str... | pyevmasm/evmasm.py | def assemble_all(asmcode, pc=0, fork=DEFAULT_FORK):
""" Assemble a sequence of textual representation of EVM instructions
:param asmcode: assembly code for any number of instructions
:type asmcode: str
:param pc: program counter of the first instruction(optional)
:type pc: int
... | def assemble_all(asmcode, pc=0, fork=DEFAULT_FORK):
""" Assemble a sequence of textual representation of EVM instructions
:param asmcode: assembly code for any number of instructions
:type asmcode: str
:param pc: program counter of the first instruction(optional)
:type pc: int
... | [
"Assemble",
"a",
"sequence",
"of",
"textual",
"representation",
"of",
"EVM",
"instructions"
] | crytic/pyevmasm | python | https://github.com/crytic/pyevmasm/blob/d27daf19a36d630a31499e783b716cf1165798d8/pyevmasm/evmasm.py#L364-L398 | [
"def",
"assemble_all",
"(",
"asmcode",
",",
"pc",
"=",
"0",
",",
"fork",
"=",
"DEFAULT_FORK",
")",
":",
"asmcode",
"=",
"asmcode",
".",
"split",
"(",
"'\\n'",
")",
"asmcode",
"=",
"iter",
"(",
"asmcode",
")",
"for",
"line",
"in",
"asmcode",
":",
"if"... | d27daf19a36d630a31499e783b716cf1165798d8 |
valid | disassemble_one | Disassemble a single instruction from a bytecode
:param bytecode: the bytecode stream
:type bytecode: str | bytes | bytearray | iterator
:param pc: program counter of the instruction(optional)
:type pc: int
:param fork: fork name (optional)
:type fork: str
:retur... | pyevmasm/evmasm.py | def disassemble_one(bytecode, pc=0, fork=DEFAULT_FORK):
""" Disassemble a single instruction from a bytecode
:param bytecode: the bytecode stream
:type bytecode: str | bytes | bytearray | iterator
:param pc: program counter of the instruction(optional)
:type pc: int
:param f... | def disassemble_one(bytecode, pc=0, fork=DEFAULT_FORK):
""" Disassemble a single instruction from a bytecode
:param bytecode: the bytecode stream
:type bytecode: str | bytes | bytearray | iterator
:param pc: program counter of the instruction(optional)
:type pc: int
:param f... | [
"Disassemble",
"a",
"single",
"instruction",
"from",
"a",
"bytecode"
] | crytic/pyevmasm | python | https://github.com/crytic/pyevmasm/blob/d27daf19a36d630a31499e783b716cf1165798d8/pyevmasm/evmasm.py#L401-L443 | [
"def",
"disassemble_one",
"(",
"bytecode",
",",
"pc",
"=",
"0",
",",
"fork",
"=",
"DEFAULT_FORK",
")",
":",
"instruction_table",
"=",
"instruction_tables",
"[",
"fork",
"]",
"if",
"isinstance",
"(",
"bytecode",
",",
"bytes",
")",
":",
"bytecode",
"=",
"byt... | d27daf19a36d630a31499e783b716cf1165798d8 |
valid | disassemble_all | Disassemble all instructions in bytecode
:param bytecode: an evm bytecode (binary)
:type bytecode: str | bytes | bytearray | iterator
:param pc: program counter of the first instruction(optional)
:type pc: int
:param fork: fork name (optional)
:type fork: str
:re... | pyevmasm/evmasm.py | def disassemble_all(bytecode, pc=0, fork=DEFAULT_FORK):
""" Disassemble all instructions in bytecode
:param bytecode: an evm bytecode (binary)
:type bytecode: str | bytes | bytearray | iterator
:param pc: program counter of the first instruction(optional)
:type pc: int
:para... | def disassemble_all(bytecode, pc=0, fork=DEFAULT_FORK):
""" Disassemble all instructions in bytecode
:param bytecode: an evm bytecode (binary)
:type bytecode: str | bytes | bytearray | iterator
:param pc: program counter of the first instruction(optional)
:type pc: int
:para... | [
"Disassemble",
"all",
"instructions",
"in",
"bytecode"
] | crytic/pyevmasm | python | https://github.com/crytic/pyevmasm/blob/d27daf19a36d630a31499e783b716cf1165798d8/pyevmasm/evmasm.py#L446-L488 | [
"def",
"disassemble_all",
"(",
"bytecode",
",",
"pc",
"=",
"0",
",",
"fork",
"=",
"DEFAULT_FORK",
")",
":",
"if",
"isinstance",
"(",
"bytecode",
",",
"bytes",
")",
":",
"bytecode",
"=",
"bytearray",
"(",
"bytecode",
")",
"if",
"isinstance",
"(",
"bytecod... | d27daf19a36d630a31499e783b716cf1165798d8 |
valid | disassemble | Disassemble an EVM bytecode
:param bytecode: binary representation of an evm bytecode
:type bytecode: str | bytes | bytearray
:param pc: program counter of the first instruction(optional)
:type pc: int
:param fork: fork name (optional)
:type fork: str
:return: th... | pyevmasm/evmasm.py | def disassemble(bytecode, pc=0, fork=DEFAULT_FORK):
""" Disassemble an EVM bytecode
:param bytecode: binary representation of an evm bytecode
:type bytecode: str | bytes | bytearray
:param pc: program counter of the first instruction(optional)
:type pc: int
:param fork: fork... | def disassemble(bytecode, pc=0, fork=DEFAULT_FORK):
""" Disassemble an EVM bytecode
:param bytecode: binary representation of an evm bytecode
:type bytecode: str | bytes | bytearray
:param pc: program counter of the first instruction(optional)
:type pc: int
:param fork: fork... | [
"Disassemble",
"an",
"EVM",
"bytecode"
] | crytic/pyevmasm | python | https://github.com/crytic/pyevmasm/blob/d27daf19a36d630a31499e783b716cf1165798d8/pyevmasm/evmasm.py#L491-L513 | [
"def",
"disassemble",
"(",
"bytecode",
",",
"pc",
"=",
"0",
",",
"fork",
"=",
"DEFAULT_FORK",
")",
":",
"return",
"'\\n'",
".",
"join",
"(",
"map",
"(",
"str",
",",
"disassemble_all",
"(",
"bytecode",
",",
"pc",
"=",
"pc",
",",
"fork",
"=",
"fork",
... | d27daf19a36d630a31499e783b716cf1165798d8 |
valid | assemble | Assemble an EVM program
:param asmcode: an evm assembler program
:type asmcode: str
:param pc: program counter of the first instruction(optional)
:type pc: int
:param fork: fork name (optional)
:type fork: str
:return: the hex representation of the bytecode
... | pyevmasm/evmasm.py | def assemble(asmcode, pc=0, fork=DEFAULT_FORK):
""" Assemble an EVM program
:param asmcode: an evm assembler program
:type asmcode: str
:param pc: program counter of the first instruction(optional)
:type pc: int
:param fork: fork name (optional)
:type fork: str
... | def assemble(asmcode, pc=0, fork=DEFAULT_FORK):
""" Assemble an EVM program
:param asmcode: an evm assembler program
:type asmcode: str
:param pc: program counter of the first instruction(optional)
:type pc: int
:param fork: fork name (optional)
:type fork: str
... | [
"Assemble",
"an",
"EVM",
"program"
] | crytic/pyevmasm | python | https://github.com/crytic/pyevmasm/blob/d27daf19a36d630a31499e783b716cf1165798d8/pyevmasm/evmasm.py#L516-L539 | [
"def",
"assemble",
"(",
"asmcode",
",",
"pc",
"=",
"0",
",",
"fork",
"=",
"DEFAULT_FORK",
")",
":",
"return",
"b''",
".",
"join",
"(",
"x",
".",
"bytes",
"for",
"x",
"in",
"assemble_all",
"(",
"asmcode",
",",
"pc",
"=",
"pc",
",",
"fork",
"=",
"f... | d27daf19a36d630a31499e783b716cf1165798d8 |
valid | disassemble_hex | Disassemble an EVM bytecode
:param bytecode: canonical representation of an evm bytecode (hexadecimal)
:type bytecode: str
:param pc: program counter of the first instruction(optional)
:type pc: int
:param fork: fork name (optional)
:type fork: str
:return: the t... | pyevmasm/evmasm.py | def disassemble_hex(bytecode, pc=0, fork=DEFAULT_FORK):
""" Disassemble an EVM bytecode
:param bytecode: canonical representation of an evm bytecode (hexadecimal)
:type bytecode: str
:param pc: program counter of the first instruction(optional)
:type pc: int
:param fork: for... | def disassemble_hex(bytecode, pc=0, fork=DEFAULT_FORK):
""" Disassemble an EVM bytecode
:param bytecode: canonical representation of an evm bytecode (hexadecimal)
:type bytecode: str
:param pc: program counter of the first instruction(optional)
:type pc: int
:param fork: for... | [
"Disassemble",
"an",
"EVM",
"bytecode"
] | crytic/pyevmasm | python | https://github.com/crytic/pyevmasm/blob/d27daf19a36d630a31499e783b716cf1165798d8/pyevmasm/evmasm.py#L542-L568 | [
"def",
"disassemble_hex",
"(",
"bytecode",
",",
"pc",
"=",
"0",
",",
"fork",
"=",
"DEFAULT_FORK",
")",
":",
"if",
"bytecode",
".",
"startswith",
"(",
"'0x'",
")",
":",
"bytecode",
"=",
"bytecode",
"[",
"2",
":",
"]",
"bytecode",
"=",
"unhexlify",
"(",
... | d27daf19a36d630a31499e783b716cf1165798d8 |
valid | assemble_hex | Assemble an EVM program
:param asmcode: an evm assembler program
:type asmcode: str | iterator[Instruction]
:param pc: program counter of the first instruction(optional)
:type pc: int
:param fork: fork name (optional)
:type fork: str
:return: the hex representati... | pyevmasm/evmasm.py | def assemble_hex(asmcode, pc=0, fork=DEFAULT_FORK):
""" Assemble an EVM program
:param asmcode: an evm assembler program
:type asmcode: str | iterator[Instruction]
:param pc: program counter of the first instruction(optional)
:type pc: int
:param fork: fork name (optional)
... | def assemble_hex(asmcode, pc=0, fork=DEFAULT_FORK):
""" Assemble an EVM program
:param asmcode: an evm assembler program
:type asmcode: str | iterator[Instruction]
:param pc: program counter of the first instruction(optional)
:type pc: int
:param fork: fork name (optional)
... | [
"Assemble",
"an",
"EVM",
"program"
] | crytic/pyevmasm | python | https://github.com/crytic/pyevmasm/blob/d27daf19a36d630a31499e783b716cf1165798d8/pyevmasm/evmasm.py#L571-L596 | [
"def",
"assemble_hex",
"(",
"asmcode",
",",
"pc",
"=",
"0",
",",
"fork",
"=",
"DEFAULT_FORK",
")",
":",
"if",
"isinstance",
"(",
"asmcode",
",",
"list",
")",
":",
"return",
"'0x'",
"+",
"hexlify",
"(",
"b''",
".",
"join",
"(",
"[",
"x",
".",
"bytes... | d27daf19a36d630a31499e783b716cf1165798d8 |
valid | block_to_fork | Convert block number to fork name.
:param block_number: block number
:type block_number: int
:return: fork name
:rtype: str
Example use::
>>> block_to_fork(0)
...
"frontier"
>>> block_to_fork(4370000)
...
... | pyevmasm/evmasm.py | def block_to_fork(block_number):
""" Convert block number to fork name.
:param block_number: block number
:type block_number: int
:return: fork name
:rtype: str
Example use::
>>> block_to_fork(0)
...
"frontier"
>>> block_to_f... | def block_to_fork(block_number):
""" Convert block number to fork name.
:param block_number: block number
:type block_number: int
:return: fork name
:rtype: str
Example use::
>>> block_to_fork(0)
...
"frontier"
>>> block_to_f... | [
"Convert",
"block",
"number",
"to",
"fork",
"name",
"."
] | crytic/pyevmasm | python | https://github.com/crytic/pyevmasm/blob/d27daf19a36d630a31499e783b716cf1165798d8/pyevmasm/evmasm.py#L881-L914 | [
"def",
"block_to_fork",
"(",
"block_number",
")",
":",
"forks_by_block",
"=",
"{",
"0",
":",
"\"frontier\"",
",",
"1150000",
":",
"\"homestead\"",
",",
"# 1920000 Dao ",
"2463000",
":",
"\"tangerine_whistle\"",
",",
"2675000",
":",
"\"spurious_dragon\"",
",",
"437... | d27daf19a36d630a31499e783b716cf1165798d8 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.