Parent: Object
The MarketDetails class contains information about a financial market, such as the US stock market, futures markets, or cryptocurrency markets. It defines properties such as trading days, market hours, time zone, holidays, security type, currency, and display conventions. Historical Data Providers can create MarketDetails instances and associate them with symbols. Users can also create and modify markets using the Markets & Symbols tool.
Contains the time zone in which the market trades. The value should be a valid Windows time zone ID, such as "Eastern Standard Time". Assigning this property also establishes the TimeZoneInfo and time offsets used by the market's time conversion methods.
Contains a suggested symbol to use as a benchmark for backtest comparisons. For example, a US Stocks market might use SPY, while a cryptocurrency market might use BTC.USD.
Returns true if the MarketDetails instance can be edited by the user. Markets created locally in the WL9 Markets configuration are editable, while markets supplied by providers are generally read-only.
Creates a new MarketDetails instance containing a copy of this market's settings. The new market's Name is prefixed with "Copy of ".
Gets or sets the user-assigned Commission instance associated with this market.
Returns a string representation of the market's assigned Commission, or an empty string if no Commission is assigned.
Converts the specified DateTime from the computer's local time zone to the market's BaseTimeZone.
Converts the specified DateTime from the market's BaseTimeZone to the computer's local time zone.
Converts the specified DateTime from the market's BaseTimeZone to UTC.
Converts the specified UTC DateTime to the market's BaseTimeZone.
Contains the default currency for the market. The default value is "USD".
Contains the number of decimal places to use when displaying price data for the market. The default value is 2.
Returns today's market closing time expressed in the computer's local time zone.
Returns today's market closing time expressed in the market's BaseTimeZone.
Returns the MarketHours applicable to the specified DateTime. The dt parameter is interpreted in the computer's local time zone and converted to market time before the appropriate hours are determined.
Returns the MarketHours applicable to the specified DateTime, which is interpreted as being in the market's BaseTimeZone. Special market hours defined by the market's HolidaySet take precedence over its normal weekly hours.
Returns a List of dates known to be missing for the specified symbol. Returns an empty List if no missing dates are defined for the symbol.
Returns the applicable market opening time expressed in the computer's local time zone. If useBaseline is true, the baseline opening time defined by the MarketHours is used.
Returns the applicable market opening time expressed in the market's BaseTimeZone.
Returns the security name associated with the specified symbol in the market's SecurityNameMapping. Returns an empty string if no security name is available.
Returns the current time difference, in hours, between the two Windows time zone IDs specified in timeZoneId1 and timeZoneId2.
Returns a List of dates representing market holidays on which the market would normally trade but is closed. The list is obtained from the market's HolidaySet. If no HolidaySet is assigned, an empty List is returned.
using WealthLab.Backtest; using WealthLab.Core; using System; using System.Collections.Generic; namespace WealthScript { public class MyStrategy : UserStrategyBase { List<DateTime> _holidays; public override void Initialize(BarHistory bars) { _holidays = bars.Market.HolidayDates; foreach (DateTime holiday in _holidays) WriteToDebugLog(holiday.ToShortDateString()); } public override void Execute(BarHistory bars, int idx) { } } }
Contains the HolidaySet associated with the market. The HolidaySet defines market holidays and can also provide special market hours for particular dates.
Returns true if the MarketHours applicable to the current market time indicate that the market is always open.
Returns true if dt is the last trading date in the period specified by scale. This method accounts for the market's trading days and holidays when determining the next trading date. It supports weekly, monthly, quarterly, and yearly periods.
Returns true if the market is open at the specified DateTime, interpreted in the computer's local time zone.
Returns true if the market is open at the specified DateTime, interpreted in the market's BaseTimeZone. The method accounts for trading days, holidays, markets that are always open, and markets whose sessions trade through midnight.
Uses the current system time, the market's BaseTimeZone, trading days, holidays, and market hours to determine whether the market is currently open.
Returns true if the current time is after the market's regular trading session on an active trading day. Markets whose sessions trade through midnight are handled appropriately.
Returns true if the current time is before the market's regular trading session on an active trading day. For markets that trade through midnight, this represents the gap between the previous session close and the next session open.
Returns true if the specified DateTime falls outside the market's regular trading session for the specified HistoryScale.
Returns true if this MarketDetails instance cannot be edited by the user. This is the inverse of CanEdit.
Returns true if the specified date is an active trading day based on the market's TradingDaysOfWeek and HolidayDates.
Returns true if the specified local DateTime corresponds to an active trading day in the market. The DateTime is converted to the market's BaseTimeZone before the trading day is determined.
Returns true if the specified DateTime, interpreted in the market's BaseTimeZone, is an active trading day.
Returns a List containing the symbols currently defined in the market's SecurityNameMapping.
Contains the descriptive name of the market.
Returns the current time expressed in the market's BaseTimeZone.
Returns the current time offset between the computer's local time zone and the market's BaseTimeZone.
Returns the current time offset between UTC and the market's BaseTimeZone.
Contains the number of decimal places permitted when calculating share or contract quantities for positions in the market. The default value is zero.
A Dictionary that maps symbols to their corresponding security names. Data Provider creators can populate this Dictionary so that WL9 can assign security names when historical data is loaded.
Contains the default SecurityType for symbols in the market. The default value is SecurityType.Stock.
Contains information identifying the source of the MarketDetails instance.
Specifies the market opening and closing times for a particular day of the week. Pass -1 in dayOfWeek to specify the default hours used for days that do not have their own specific hours.
Returns the amount of time remaining until the market closes. If the market is not currently open, returns a zero TimeSpan.
Returns the amount of time remaining until the market opens when the market is currently in its pre-market period. Otherwise, returns a zero TimeSpan.
Returns the System.TimeZoneInfo instance corresponding to the market's BaseTimeZone.
Configures the market to trade every day of the week. If includeSaturday is false, Saturday is omitted, resulting in a Sunday-through-Friday trading week.
Configures the market to trade Monday through Friday.
Configures the market to trade Sunday through Friday, excluding Saturday.
Contains the DayOfWeek values representing the days of the week on which the market trades.
Returns a compact string representation of the market's trading days. Common values include "All", "Weekdays", and "Sun+Weekdays". Other combinations are represented using abbreviated day names.
Contains the MarketWeeklyHours instance that defines the market's normal trading hours for each day of the week.