API documentation, members, signatures, and C# examples.
Search the framework
Find classes, members, and documentation.
NamespaceWealthLab.Core
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.
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.
public MarketHours GetHoursMarketTime(DateTime dt)
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.
public DateTime GetOpenTimeLocalTime(bool useBaseline)
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 security name associated with the specified symbol in the market's SecurityNameMapping. Returns an empty string if no security name is available.
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.
C# example
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.
public bool IsLastTradingDateInPeriod(DateTime dt, Frequency scale)
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 market's BaseTimeZone.
The method accounts for trading days, holidays, markets that are always open, and markets whose sessions trade through midnight.
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 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.
public Dictionary<string, string> SecurityNameMapping
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.
public void SpecifyMarketHours(int dayOfWeek, TimeSpan mktOpen, TimeSpan mktClose)
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.
public void TradeOnAllDays(bool includeSaturday = true)
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.
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.