Skip to content

MarketHoursDatabaseJsonConverter

QuantConnect.Util.MarketHoursDatabaseJsonConverter

Bases: TypeChangeJsonConverter[MarketHoursDatabase, QuantConnect_Util_MarketHoursDatabaseJsonConverter_MarketHoursDatabaseJson]

Provides json conversion for the MarketHoursDatabase class

populate_properties

populate_properties: bool

True will populate TResult object returned by convert(TResult) with json properties

This codeEntityType is protected.

MarketHoursDatabaseJson

MarketHoursDatabaseJson(database: MarketHoursDatabase)

Bases: Object

Defines the json structure of the market-hours-database.json file

Initializes a new instance of the MarketHoursDatabaseJson class

Parameters:

Name Type Description Default
database MarketHoursDatabase

The database instance to copy

required

entries

entries: Dictionary[str, MarketHoursDatabaseEntryJson]

The entries in the market hours database, keyed by SecurityDatabaseKey

convert

convert() -> MarketHoursDatabase

Converts this json representation to the MarketHoursDatabase type

Returns:

Type Description
MarketHoursDatabase

A new instance of the MarketHoursDatabase class.

MarketHoursDatabaseEntryJson

MarketHoursDatabaseEntryJson(entry: Entry)

Bases: Object

Defines the json structure of a single entry in the market-hours-database.json file

Initializes a new instance of the MarketHoursDatabaseEntryJson class

Parameters:

Name Type Description Default
entry Entry

The entry instance to copy

required

data_time_zone

data_time_zone: str

The data's raw time zone

exchange_time_zone

exchange_time_zone: str

The exchange's time zone id from the tzdb

sunday

sunday: List[MarketHoursSegment]

Sunday market hours segments

monday

monday: List[MarketHoursSegment]

Monday market hours segments

tuesday

tuesday: List[MarketHoursSegment]

Tuesday market hours segments

wednesday

wednesday: List[MarketHoursSegment]

Wednesday market hours segments

thursday

thursday: List[MarketHoursSegment]

Thursday market hours segments

friday

friday: List[MarketHoursSegment]

Friday market hours segments

saturday

saturday: List[MarketHoursSegment]

Saturday market hours segments

holidays

holidays: List[str]

Holiday date strings

early_closes

early_closes: Dictionary[str, timedelta]

Early closes by date

late_opens

late_opens: Dictionary[str, timedelta]

Late opens by date

bank_holidays

bank_holidays: List[str]

Bank holidays date strings

convert

convert(
    underlying_entry: Entry, market_entry: Entry
) -> Entry

Converts this json representation to the MarketHoursDatabase.Entry type

Returns:

Type Description
Entry

A new instance of the MarketHoursDatabase.Entry class.

convert

Signature descriptions:

  • Convert the input value to a value to be serialzied

  • Converts the input value to be deserialized

Parameters:

Name Type Description Default
value MarketHoursDatabase | MarketHoursDatabaseJson

The input value to be converted before serialziation

required

Returns:

Type Description
MarketHoursDatabaseJson | MarketHoursDatabase

Depends on the signature used. Case 1: [A new instance of TResult that is to be serialzied.]; Case 2: [The converted value.]

create

create(type: Type, token: Any) -> MarketHoursDatabase

Creates an instance of the un-projected type to be deserialized

This codeEntityType is protected.

Parameters:

Name Type Description Default
type Type

The input object type, this is the data held in the token

required
token Any

The input data to be converted into a T

required

Returns:

Type Description
MarketHoursDatabase

A new instance of T that is to be serialized using default rules.

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.

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