BenzingaNewsJsonConverter
QuantConnect.DataSource.BenzingaNewsJsonConverter
BenzingaNewsJsonConverter(
symbol: Union[Symbol, str, BaseContract] = None,
live_mode: bool = False,
)
Bases: JsonConverter
Helper json converter class used to convert Benzinga news data into BenzingaNews
An example schema of the data in a serialized format is provided to help you better understand this converter.
Creates a new instance of the json converter
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
symbol
|
Union[Symbol, str, BaseContract]
|
The Symbol instance associated with this news |
None
|
live_mode
|
bool
|
True if live mode, false for backtesting |
False
|
SHARE_CLASS_MAPPED_TICKERS
SHARE_CLASS_MAPPED_TICKERS: Dictionary[
str, HashSet[str]
] = ...
Sometimes "Berkshire Hathaway" is mentioned as "BRK" in the raw data, although it is separated into class A and B shares and should appear as BRK.A and BRK.B. Because our map file system does not perform the conversion from BRK -> { BRK.A, BRK.B }, we must provide them manually. Note that we don't dynamically try to locate class A and B shares because there can exist companies with the same base ticker that class A and B shares have. For example, CBS trades under "CBS" and "CBS.A", which means that if "CBS" appears, it will be automatically mapped to CBS. However, if we dynamically selected "CBS.A" - we might select a different company not associated with the ticker being referenced.
can_convert
can_convert(object_type: Type) -> bool
Determines whether this instance can convert the specified object type.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
object_type
|
Type
|
Type of the object. |
required |
Returns:
| Type | Description |
|---|---|
bool
|
true if this instance can convert the specified object type; otherwise, false. |
deserialize_news
deserialize_news(
item: Any, enable_logging: bool = False
) -> BenzingaNews
Helper method to deserialize a single json Benzinga news
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
item
|
Any
|
The json token containing the Benzinga news to deserialize |
required |
enable_logging
|
bool
|
true to enable logging (for debug purposes) |
False
|
Returns:
| Type | Description |
|---|---|
BenzingaNews
|
The deserialized BenzingaNews instance. |
read_json
read_json(
reader: Any,
object_type: Type,
existing_value: Any,
serializer: Any,
) -> Object
Reads the JSON representation of the object.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
reader
|
Any
|
The Newtonsoft.Json.JsonReader to read from. |
required |
object_type
|
Type
|
Type of the object. |
required |
existing_value
|
Any
|
The existing value of object being read. |
required |
serializer
|
Any
|
The calling serializer. |
required |
Returns:
| Type | Description |
|---|---|
Object
|
The object value. |
write_json
write_json(
writer: Any, value: Any, serializer: Any
) -> None
Writes the JSON representation of the object.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
writer
|
Any
|
The Newtonsoft.Json.JsonWriter to write to. |
required |
value
|
Any
|
The value. |
required |
serializer
|
Any
|
The calling serializer. |
required |