Class Exchange
- Namespace
- ATAS.DataFeedsCore
- Assembly
- ATAS.DataFeedsCore.dll
Exchange with its time zone and weekly trading sessions; used to convert data feed times and to find session, week and month boundaries.
[DataContract]
public class Exchange : IEntity, IKnowSession
- Inheritance
-
objectExchange
- Implements
- Extension Methods
Constructors
Exchange()
Creates an exchange with one default session (Monday 00:00 to Saturday 00:00).
public Exchange()
Properties
Code
Unique code of the exchange record; the key other entities refer to.
[DataMember]
[LocalizedCategory(typeof(Strings), "Common")]
[LocalizedDisplayName(typeof(Strings), "Code")]
public string Code { get; set; }
Property Value
- string
ConvertTradeTimeToLocal
true when the times passed to the session methods are already in exchange local time; false when they are in UTC and are converted with TimeZoneInfo first.
[DataMember]
[LocalizedCategory(typeof(Strings), "Common")]
[LocalizedDisplayName(typeof(Strings), "ConvertTradeTimeToLocal")]
public bool ConvertTradeTimeToLocal { get; set; }
Property Value
- bool
Country
Country of the exchange.
[DataMember]
[LocalizedCategory(typeof(Strings), "Common")]
[LocalizedDisplayName(typeof(Strings), "Country")]
public string Country { get; set; }
Property Value
- string
EntityType
Always Exchange.
[Browsable(false)]
public EntityType EntityType { get; }
Property Value
ExchangeCode
Code of the exchange as it is known to the data feed (stored in the Exchange column); may differ from Code.
[DataMember]
[LocalizedCategory(typeof(Strings), "Common")]
[LocalizedDisplayName(typeof(Strings), "ExchangeCode")]
public string ExchangeCode { get; set; }
Property Value
- string
FirstDayOfWeek
First day of the week used by IsNewWeek(DateTime, DateTime).
[DataMember]
[LocalizedCategory(typeof(Strings), "Common")]
[LocalizedDisplayName(typeof(Strings), "FirstDayOfWeek")]
public DayOfWeek FirstDayOfWeek { get; set; }
Property Value
- DayOfWeek
IsSystemExchange
true for an exchange that comes from the instruments registry; such an exchange cannot be edited by the user.
[Browsable(false)]
public bool IsSystemExchange { get; set; }
Property Value
- bool
Name
Display name of the exchange; also returned by ToString().
[DataMember]
[LocalizedCategory(typeof(Strings), "Common")]
[LocalizedDisplayName(typeof(Strings), "Name")]
public string Name { get; set; }
Property Value
- string
TimeZone
System identifier of the exchange time zone; kept in sync with TimeZoneInfo. Setting an identifier the system does not know throws System.TimeZoneNotFoundException.
[DataMember]
[Browsable(false)]
public string? TimeZone { get; set; }
Property Value
- string
TimeZoneInfo
Time zone in which WorkingTimes are defined; kept in sync with TimeZone.
[LocalizedCategory(typeof(Strings), "Common")]
[LocalizedDisplayName(typeof(Strings), "TimeZone")]
public TimeZoneInfo? TimeZoneInfo { get; set; }
Property Value
- TimeZoneInfo
WorkingTimes
Weekly trading sessions of the exchange, in exchange local time. A new instance contains one default session.
[DataMember]
[LocalizedCategory(typeof(Strings), "Common")]
[LocalizedDisplayName(typeof(Strings), "WorkingTimes")]
public List<WorkingTime> WorkingTimes { get; set; }
Property Value
- List<WorkingTime>
Methods
Clone()
Creates a copy of the exchange with copies of its sessions; IsSystemExchange is not copied.
public Exchange Clone()
Returns
- Exchange
The new exchange.
GetNextSessionOpen(DateTime)
Finds the start of the next session that opens at or after a time.
public DateTime? GetNextSessionOpen(DateTime time)
Parameters
timeDateTimeTime in UTC, or in exchange local time when ConvertTradeTimeToLocal is set.
Returns
- DateTime?
The session start in the same time base as
time, or null when there are no sessions ortimeis within 7 days of System.DateTime.MaxValue.
GetPreviousSessionClose(DateTime)
Finds the end of the last session that closed at or before a time.
public DateTime? GetPreviousSessionClose(DateTime time)
Parameters
timeDateTimeTime in UTC, or in exchange local time when ConvertTradeTimeToLocal is set.
Returns
- DateTime?
The session end in the same time base as
time, or null when there are no sessions ortimeis within 7 days of System.DateTime.MinValue.
GetWorkingDateTime(DateTime)
Gets the start and end of the session that contains a time.
<p>Added in ATAS 8.0.15.</p>
public Tuple<DateTime, DateTime>? GetWorkingDateTime(DateTime time)
Parameters
timeDateTimeTime in UTC, or in exchange local time when ConvertTradeTimeToLocal is set.
Returns
- Tuple<DateTime, DateTime>
Session start and end in the same time base as
time, or null when the time is outside any session.
GetWorkingTime(DateTime)
Finds the session that contains a time.
<p>Added in ATAS 8.0.15.</p>
public WorkingTime? GetWorkingTime(DateTime time)
Parameters
timeDateTimeTime in UTC, or in exchange local time when ConvertTradeTimeToLocal is set.
Returns
- WorkingTime
The first matching entry of WorkingTimes, or null when the time is outside any session.
IsNewMonth(DateTime, DateTime)
Checks whether two times belong to different months.
public bool IsNewMonth(DateTime prevTime, DateTime newTime)
Parameters
prevTimeDateTimePrevious time, in the same time base as for IsWorkingTime(DateTime).
newTimeDateTimeNew time, in the same time base as for IsWorkingTime(DateTime).
Returns
- bool
true when the month differs; the session end times are compared when both times are inside sessions, otherwise (and always for MOEX exchanges) the times themselves.
IsNewSession(DateTime, DateTime)
Checks whether newTime starts a new trading session relative to prevTime.
public bool IsNewSession(DateTime prevTime, DateTime newTime)
Parameters
prevTimeDateTimePrevious time, in the same time base as for IsWorkingTime(DateTime).
newTimeDateTimeNew time, in the same time base as for IsWorkingTime(DateTime).
Returns
- bool
false when
newTimeis outside any session; true whenprevTimeis outside any session, or the two times belong to different WorkingTimes entries or to the same weekday of different dates.
IsNewWeek(DateTime, DateTime)
Checks whether two times belong to different weeks, counted from FirstDayOfWeek.
public bool IsNewWeek(DateTime prevTime, DateTime newTime)
Parameters
prevTimeDateTimePrevious time, in the same time base as for IsWorkingTime(DateTime).
newTimeDateTimeNew time, in the same time base as for IsWorkingTime(DateTime).
Returns
- bool
true when the week of year differs; the session start times are compared when both times are inside sessions, otherwise the times themselves.
IsWorkingTime(DateTime)
Checks whether a time falls into one of the WorkingTimes.
public bool IsWorkingTime(DateTime time)
Parameters
timeDateTimeTime in UTC, or in exchange local time when ConvertTradeTimeToLocal is set.
Returns
- bool
true when the time is inside a session.
OnPropertyChanged(string)
Raises PropertyChanged.
protected virtual void OnPropertyChanged(string propertyName)
Parameters
propertyNamestringName of the changed property.
ToLocalTime(DateTime)
Converts a UTC time to exchange local time.
public DateTime ToLocalTime(DateTime time)
Parameters
timeDateTimeUTC time; its System.DateTime.Kind is ignored.
Returns
- DateTime
Exchange local time with System.DateTimeKind.Unspecified kind.
ToString()
Returns a string that represents the current object.
public override string ToString()
Returns
- string
A string that represents the current object.
ToUtcTime(DateTime)
Converts an exchange local time to UTC.
public DateTime ToUtcTime(DateTime time)
Parameters
timeDateTimeExchange local time; its System.DateTime.Kind is ignored.
Returns
- DateTime
UTC time with System.DateTimeKind.Unspecified kind.
TrimToMinTradedRange(DateTime, DateTime)
Trims a time range so that both ends lie inside trading sessions.
public (DateTime? MinTradedTime, DateTime? MaxTradedTime) TrimToMinTradedRange(DateTime from, DateTime to)
Parameters
fromDateTimeRange start; moved forward to the next session open when it is outside a session.
toDateTimeRange end; moved back to the previous session close when it is outside a session.
Returns
- (DateTime? MinTradedTime, DateTime? MaxTradedTime)
The trimmed range, or both values null when no traded time remains.
Events
PropertyChanged
Occurs when a property shown in the exchange editor changes.
<p>Added in ATAS 8.0.15.</p>
public event PropertyChangedEventHandler? PropertyChanged
Event Type
- PropertyChangedEventHandler