Search Framework:
MarketDetails
Namespace: WealthLab.Core
Parent: Object

The MarketDetails class contains information about a market, such as the US Stock Market, or the Cryptocurrency markets. Historical Data Providers in WealthLab can create MarketDetails instances and assign them to symbols, or you can make such assignments yourself using the Markets & Symbols tool.

Members
BaseTimeZone
public string BaseTimeZone

Contains the time zone that the market trades in. The string is compatible with Windows time zone ID values.


BenchmarkSymbol
public string BenchmarkSymbol

Contains a suggested symbol to use as a benchmark for backtest comparisons. For example, the US Stocks MarketDetails uses SPY, while the CryptoCurrencies MarketDetails uses BTC.USD.


DisplayDecimals
public int DisplayDecimals

Contains the number of decimal places to use when displaying price data for the market.


GetHoursLocalTime
public MarketHours GetHoursLocalTime(DateTime dt)

Returns the market hours in the market's time zone for the specified date (dt parameter) in the local time zone, as an instance of the MarketHours class.


GetHoursMarketTime
public MarketHours GetHoursMarketTime(DateTime dt)

Returns the market hours in the market's time zone for the specified date (dt parameter), as an instance of the MarketHours class.


GetSecurityName
public string GetSecurityName(string symbol)

Returns the security name of the specified symbol, if available.


HolidayDates
public List<DateTime> HolidayDates

A list of dates that represent market holidays where the market would normally be open but is closed.

Example Code
using WealthLab.Backtest;
using System;
using WealthLab.Core;
using System.Collections.Generic;

namespace WealthScript
{
	public class MyStrategy : UserStrategyBase
	{
		List<DateTime> _holidays;

		public override void Initialize(BarHistory bars)
		{
			_holidays = bars.Market.HolidayDates;

			//print the list of holidays for the bars' market
			foreach (DateTime holiday in _holidays)
			{
				WriteToDebugLog(holiday.ToShortDateString());
			}
		}


		public override void Execute(BarHistory bars, int idx)
		{

		}

	}
}

IsOpenNow
public bool IsOpenNow

Uses the current system time and time zone, the BaseTimeZone of the market, and the market's GetHours method to determine if the market is currently open or closed.


IsPostMarket
public bool IsPostMarket

Uses the current system time and time zone, the BaseTimeZone of the market, and the market's GetHours method to determine if the current time is considered "post-market close".


IsPreMarket
public bool IsPreMarket

Uses the current system time and time zone, the BaseTimeZone of the market, and the market's GetHours method to determine if the current time is considered "pre-market open".


IsTradingDay
public bool IsTradingDay(DateTime dt)

Returns true if the specified date (dt parameter) is an active trading day in this market.


Name
public string Name

Contains the name of the market.


QuantityDecimals
public int QuantityDecimals

Contains the number of decimal places to use when calculating the number of shares or contracts to use for a position in the market.


TradingDaysOfWeek
public List<DayOfWeek> TradingDaysOfWeek

A List that contains DayOfWeek enumerated values that represent the days of the week that this market is open for trading.



Members for Market Creators
Clone
public MarketDetails Clone()

Creates a new MarketDetails instance that copies all of the properties of this market.


SpecifyMarketHours
public void SpecifyMarketHours(int dayOfWeek, TimeSpan mktOpen, TimeSpan mktClose)

Custom data providers that are creating MarketDetail instances can use this method to specify market open and close times for a specific day of the week. To specify the default market hours, they should call this method passing -1 as the dayOfWeek parameter. Every MarketDetails should have a default market hours (-1 value) defined in this way.


SymbolMapping
public Dictionary<string, string> SymbolMapping

A Dictionary that data provider creators can use to map symbols to their corresponding security names. WealthLab will check this Dictionary at the time data is loaded to see if a security name is available, and if so will assign it to the SecurityName property of the resulting BarHistory instance.


TradeOnAllDays
public void TradeOnAllDays()

Data Provider creators can call this method to indicate that the market trades on all days of the week. It populates the TradingDaysOfWeek property list with all 7 days of the week.


TradeOnWeekdays
public void TradeOnWeekdays()

Data Provider creators can call this method to indicate that the market trades on weekdays. It populates the TradingDaysOfWeek property list with the values Monday through Friday.