Lean  $LEAN_TAG$
QuantConnect.Securities.MarketHoursDatabase Class Reference

Provides access to exchange hours and raw data times zones in various markets More...

Classes

class  Entry
 Represents a single entry in the MarketHoursDatabase More...
 

Public Member Functions

 MarketHoursDatabase (Dictionary< SecurityDatabaseKey, Entry > exchangeHours)
 Initializes a new instance of the MarketHoursDatabase class More...
 
SecurityExchangeHours GetExchangeHours (SubscriptionDataConfig configuration)
 Convenience method for retrieving exchange hours from market hours database using a subscription config More...
 
SecurityExchangeHours GetExchangeHours (string market, Symbol symbol, SecurityType securityType)
 Convenience method for retrieving exchange hours from market hours database using a subscription config More...
 
DateTimeZone GetDataTimeZone (string market, Symbol symbol, SecurityType securityType)
 Performs a lookup using the specified information and returns the data's time zone if found, if an entry is not found, an exception is thrown More...
 
void ReloadEntries ()
 Reload entries dictionary from MHDB file and merge them with previous custom ones More...
 
virtual Entry SetEntry (string market, string symbol, SecurityType securityType, SecurityExchangeHours exchangeHours, DateTimeZone dataTimeZone=null)
 Sets the entry for the specified market/symbol/security-type. This is intended to be used by custom data and other data sources that don't have explicit entries in market-hours-database.csv. At run time, the algorithm can update the market hours database via calls to AddData. More...
 
virtual Entry SetEntryAlwaysOpen (string market, string symbol, SecurityType securityType, DateTimeZone timeZone)
 Convenience method for the common custom data case. Sets the entry for the specified symbol using SecurityExchangeHours.AlwaysOpen(timeZone) This sets the data time zone equal to the exchange time zone as well. More...
 
virtual Entry GetEntry (string market, string symbol, SecurityType securityType)
 Gets the entry for the specified market/symbol/security-type More...
 
bool TryGetEntry (string market, Symbol symbol, SecurityType securityType, out Entry entry)
 Tries to get the entry for the specified market/symbol/security-type More...
 
bool TryGetEntry (string market, string symbol, SecurityType securityType, out Entry entry)
 Tries to get the entry for the specified market/symbol/security-type More...
 
virtual Entry GetEntry (string market, Symbol symbol, SecurityType securityType)
 Gets the entry for the specified market/symbol/security-type More...
 

Static Public Member Functions

static void Reset ()
 Resets the market hours database, forcing a reload when reused. Called in tests where multiple algorithms are run sequentially, and we need to guarantee that every test starts with the same environment. More...
 
static MarketHoursDatabase FromDataFolder ()
 Gets the instance of the MarketHoursDatabase class produced by reading in the market hours data found in /Data/market-hours/ More...
 
static MarketHoursDatabase FromFile (string path)
 Reads the specified file as a market hours database instance More...
 
static string GetDatabaseSymbolKey (Symbol symbol)
 Gets the correct string symbol to use as a database key More...
 

Public Attributes

List< KeyValuePair< SecurityDatabaseKey, Entry > > ExchangeHoursListing => _entries.ToList()
 Gets all the exchange hours held by this provider More...
 

Protected Member Functions

bool ContainsKey (SecurityDatabaseKey key)
 Determines if the database contains the specified key More...
 

Properties

static MarketHoursDatabase AlwaysOpen [get]
 Gets a MarketHoursDatabase that always returns SecurityExchangeHours.AlwaysOpen More...
 

Detailed Description

Provides access to exchange hours and raw data times zones in various markets

Definition at line 33 of file MarketHoursDatabase.cs.

Constructor & Destructor Documentation

◆ MarketHoursDatabase()

QuantConnect.Securities.MarketHoursDatabase.MarketHoursDatabase ( Dictionary< SecurityDatabaseKey, Entry exchangeHours)

Initializes a new instance of the MarketHoursDatabase class

Parameters
exchangeHoursThe full listing of exchange hours by key

Definition at line 67 of file MarketHoursDatabase.cs.

Member Function Documentation

◆ GetExchangeHours() [1/2]

SecurityExchangeHours QuantConnect.Securities.MarketHoursDatabase.GetExchangeHours ( SubscriptionDataConfig  configuration)

Convenience method for retrieving exchange hours from market hours database using a subscription config

Parameters
configurationThe subscription data config to get exchange hours for
Returns
The configure exchange hours for the specified configuration

Definition at line 77 of file MarketHoursDatabase.cs.

Here is the caller graph for this function:

◆ GetExchangeHours() [2/2]

SecurityExchangeHours QuantConnect.Securities.MarketHoursDatabase.GetExchangeHours ( string  market,
Symbol  symbol,
SecurityType  securityType 
)

Convenience method for retrieving exchange hours from market hours database using a subscription config

Parameters
marketThe market the exchange resides in, i.e, 'usa', 'fxcm', ect...
symbolThe particular symbol being traded
securityTypeThe security type of the symbol
Returns
The exchange hours for the specified security

Definition at line 89 of file MarketHoursDatabase.cs.

Here is the call graph for this function:

◆ GetDataTimeZone()

DateTimeZone QuantConnect.Securities.MarketHoursDatabase.GetDataTimeZone ( string  market,
Symbol  symbol,
SecurityType  securityType 
)

Performs a lookup using the specified information and returns the data's time zone if found, if an entry is not found, an exception is thrown

Parameters
marketThe market the exchange resides in, i.e, 'usa', 'fxcm', ect...
symbolThe particular symbol being traded
securityTypeThe security type of the symbol
Returns
The raw data time zone for the specified security

Definition at line 102 of file MarketHoursDatabase.cs.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ Reset()

static void QuantConnect.Securities.MarketHoursDatabase.Reset ( )
static

Resets the market hours database, forcing a reload when reused. Called in tests where multiple algorithms are run sequentially, and we need to guarantee that every test starts with the same environment.

Definition at line 112 of file MarketHoursDatabase.cs.

Here is the caller graph for this function:

◆ ReloadEntries()

void QuantConnect.Securities.MarketHoursDatabase.ReloadEntries ( )

Reload entries dictionary from MHDB file and merge them with previous custom ones

Definition at line 123 of file MarketHoursDatabase.cs.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ FromDataFolder()

static MarketHoursDatabase QuantConnect.Securities.MarketHoursDatabase.FromDataFolder ( )
static

Gets the instance of the MarketHoursDatabase class produced by reading in the market hours data found in /Data/market-hours/

Returns
A MarketHoursDatabase class that represents the data in the market-hours folder

Definition at line 139 of file MarketHoursDatabase.cs.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ FromFile()

static MarketHoursDatabase QuantConnect.Securities.MarketHoursDatabase.FromFile ( string  path)
static

Reads the specified file as a market hours database instance

Parameters
pathThe market hours database file path
Returns
A new instance of the MarketHoursDatabase class

Definition at line 162 of file MarketHoursDatabase.cs.

Here is the caller graph for this function:

◆ SetEntry()

virtual Entry QuantConnect.Securities.MarketHoursDatabase.SetEntry ( string  market,
string  symbol,
SecurityType  securityType,
SecurityExchangeHours  exchangeHours,
DateTimeZone  dataTimeZone = null 
)
virtual

Sets the entry for the specified market/symbol/security-type. This is intended to be used by custom data and other data sources that don't have explicit entries in market-hours-database.csv. At run time, the algorithm can update the market hours database via calls to AddData.

Parameters
marketThe market the exchange resides in, i.e, 'usa', 'fxcm', ect...
symbolThe particular symbol being traded
securityTypeThe security type of the symbol
exchangeHoursThe exchange hours for the specified symbol
dataTimeZoneThe time zone of the symbol's raw data. Optional, defaults to the exchange time zone
Returns
The entry matching the specified market/symbol/security-type

Definition at line 179 of file MarketHoursDatabase.cs.

Here is the caller graph for this function:

◆ SetEntryAlwaysOpen()

virtual Entry QuantConnect.Securities.MarketHoursDatabase.SetEntryAlwaysOpen ( string  market,
string  symbol,
SecurityType  securityType,
DateTimeZone  timeZone 
)
virtual

Convenience method for the common custom data case. Sets the entry for the specified symbol using SecurityExchangeHours.AlwaysOpen(timeZone) This sets the data time zone equal to the exchange time zone as well.

Parameters
marketThe market the exchange resides in, i.e, 'usa', 'fxcm', ect...
symbolThe particular symbol being traded
securityTypeThe security type of the symbol
timeZoneThe time zone of the symbol's exchange and raw data
Returns
The entry matching the specified market/symbol/security-type

Definition at line 199 of file MarketHoursDatabase.cs.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetEntry() [1/2]

virtual Entry QuantConnect.Securities.MarketHoursDatabase.GetEntry ( string  market,
string  symbol,
SecurityType  securityType 
)
virtual

Gets the entry for the specified market/symbol/security-type

Parameters
marketThe market the exchange resides in, i.e, 'usa', 'fxcm', ect...
symbolThe particular symbol being traded
securityTypeThe security type of the symbol
Returns
The entry matching the specified market/symbol/security-type

Definition at line 211 of file MarketHoursDatabase.cs.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ TryGetEntry() [1/2]

bool QuantConnect.Securities.MarketHoursDatabase.TryGetEntry ( string  market,
Symbol  symbol,
SecurityType  securityType,
out Entry  entry 
)

Tries to get the entry for the specified market/symbol/security-type

Parameters
marketThe market the exchange resides in, i.e, 'usa', 'fxcm', ect...
symbolThe particular symbol being traded
securityTypeThe security type of the symbol
entryThe entry found if any
Returns
True if the entry was present, else false

Definition at line 249 of file MarketHoursDatabase.cs.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ TryGetEntry() [2/2]

bool QuantConnect.Securities.MarketHoursDatabase.TryGetEntry ( string  market,
string  symbol,
SecurityType  securityType,
out Entry  entry 
)

Tries to get the entry for the specified market/symbol/security-type

Parameters
marketThe market the exchange resides in, i.e, 'usa', 'fxcm', ect...
symbolThe particular symbol being traded
securityTypeThe security type of the symbol
entryThe entry found if any
Returns
True if the entry was present, else false

Definition at line 262 of file MarketHoursDatabase.cs.

Here is the call graph for this function:

◆ GetEntry() [2/2]

virtual Entry QuantConnect.Securities.MarketHoursDatabase.GetEntry ( string  market,
Symbol  symbol,
SecurityType  securityType 
)
virtual

Gets the entry for the specified market/symbol/security-type

Parameters
marketThe market the exchange resides in, i.e, 'usa', 'fxcm', ect...
symbolThe particular symbol being traded (Symbol class)
securityTypeThe security type of the symbol
Returns
The entry matching the specified market/symbol/security-type

Definition at line 283 of file MarketHoursDatabase.cs.

Here is the call graph for this function:

◆ GetDatabaseSymbolKey()

static string QuantConnect.Securities.MarketHoursDatabase.GetDatabaseSymbolKey ( Symbol  symbol)
static

Gets the correct string symbol to use as a database key

Parameters
symbolThe symbol
Returns
The symbol string used in the database ke

Definition at line 293 of file MarketHoursDatabase.cs.

Here is the caller graph for this function:

◆ ContainsKey()

bool QuantConnect.Securities.MarketHoursDatabase.ContainsKey ( SecurityDatabaseKey  key)
protected

Determines if the database contains the specified key

Parameters
keyThe key to search for
Returns
True if an entry is found, otherwise false

Definition at line 329 of file MarketHoursDatabase.cs.

Member Data Documentation

◆ ExchangeHoursListing

List<KeyValuePair<SecurityDatabaseKey,Entry> > QuantConnect.Securities.MarketHoursDatabase.ExchangeHoursListing => _entries.ToList()

Gets all the exchange hours held by this provider

Definition at line 45 of file MarketHoursDatabase.cs.

Property Documentation

◆ AlwaysOpen

MarketHoursDatabase QuantConnect.Securities.MarketHoursDatabase.AlwaysOpen
staticget

Gets a MarketHoursDatabase that always returns SecurityExchangeHours.AlwaysOpen

Definition at line 51 of file MarketHoursDatabase.cs.


The documentation for this class was generated from the following file: