17 using System.Collections.Generic;
20 using System.Reflection;
21 using System.Globalization;
56 private readonly List<SubscriptionDataConfig> _subscriptionsBag;
77 lock (_subscriptionsBag)
79 return _subscriptionsBag.ToList();
117 [Obsolete(
"This property is obsolete. Use the 'SubscriptionDataConfig' exposed by 'SubscriptionManager'")]
123 [Obsolete(
"This property is obsolete. Use the 'SubscriptionDataConfig' exposed by 'SubscriptionManager'")]
129 [Obsolete(
"This property is obsolete. Use the 'SubscriptionDataConfig' exposed by 'SubscriptionManager'")]
135 [Obsolete(
"This property is obsolete. Use the 'SubscriptionDataConfig' exposed by 'SubscriptionManager'")]
141 [Obsolete(
"This property returns only the first subscription. Use the 'Subscriptions' property for all of this security's subscriptions.")]
146 lock (_subscriptionsBag)
148 return _subscriptionsBag.FirstOrDefault();
344 registeredTypesProvider,
376 registeredTypesProvider,
404 if (symbolProperties ==
null)
406 throw new ArgumentNullException(nameof(symbolProperties),
Messages.
Security.ValidSymbolPropertiesInstanceRequired);
415 _subscriptionsBag =
new ();
435 UpdateSubscriptionProperties();
475 registeredTypesProvider,
476 marginInterestRateModel
479 _subscriptionsBag.Add(config);
480 UpdateSubscriptionProperties();
500 if (_localTimeKeeper ==
null)
502 throw new InvalidOperationException(
Messages.
Security.SetLocalTimeKeeperMustBeCalledBeforeUsingLocalTime);
593 _localTimeKeeper = localTimeKeeper;
594 Exchange.SetLocalDateTimeFrontierProvider(localTimeKeeper);
604 if (data ==
null)
return;
607 UpdateMarketPrice(data);
618 public void Update(IReadOnlyList<BaseData> data,
Type dataType,
bool? containsFillForwardData =
null)
622 UpdateMarketPrice(data[data.Count - 1]);
628 [Obsolete(
"This method is obsolete. Use the 'SubscriptionDataConfig' exposed by" +
629 " 'SubscriptionManager' and the 'IsCustomData()' extension method")]
657 [Obsolete(
"This method is obsolete. Use the 'SubscriptionDataConfig' exposed by" +
658 " 'SubscriptionManager' and the 'SetDataNormalizationMode()' extension method")]
661 lock (_subscriptionsBag)
663 foreach (var subscription
in _subscriptionsBag)
665 subscription.DataNormalizationMode = mode;
667 UpdateSubscriptionProperties();
678 lock (_subscriptionsBag)
681 .Select(x => x.DataNormalizationMode)
849 throw new Exception($
"SetShortableProvider: {pyObject.Repr()} is not a valid argument");
882 throw new ArgumentException($
"SetDataFilter: {pyObject.Repr()} is not a valid argument");
896 #region DynamicObject Overrides and Helper Methods
901 public override bool TryGetMember(GetMemberBinder binder, out
object result)
909 public override bool TrySetMember(SetMemberBinder binder,
object value)
918 public override bool TryInvokeMember(InvokeMemberBinder binder,
object[] args, out
object result)
923 CultureInfo.InvariantCulture);
939 public void Add(
string key,
object value)
955 value = CastDynamicPropertyValue<T>(obj);
995 value = CastDynamicPropertyValue<T>(objectValue);
1013 public object this[
string key]
1017 return Get<object>(key);
1045 lock (_subscriptionsBag)
1049 throw new ArgumentException(
Messages.
Security.UnmatchingSymbols, $
"{nameof(subscription)}.{nameof(subscription.Symbol)}");
1053 throw new ArgumentException(
Messages.
Security.UnmatchingExchangeTimeZones, $
"{nameof(subscription)}.{nameof(subscription.ExchangeTimeZone)}");
1055 _subscriptionsBag.Add(subscription);
1056 UpdateSubscriptionProperties();
1066 lock (_subscriptionsBag)
1068 foreach (var subscription
in subscriptions)
1070 if (subscription.Symbol !=
Symbol)
1072 throw new ArgumentException(Messages.Security.UnmatchingSymbols, $
"{nameof(subscription)}.{nameof(subscription.Symbol)}");
1076 throw new ArgumentException(Messages.Security.UnmatchingExchangeTimeZones, $
"{nameof(subscription)}.{nameof(subscription.ExchangeTimeZone)}");
1078 _subscriptionsBag.Add(subscription);
1080 UpdateSubscriptionProperties();
1098 private void UpdateSubscriptionProperties()
1100 Resolution = _subscriptionsBag.Select(x => x.Resolution).DefaultIfEmpty(
Resolution.Daily).Min();
1109 private void UpdateMarketPrice(
BaseData data)
1121 private static T CastDynamicPropertyValue<T>(
object obj)
1124 var pyObj = obj as PyObject;
1129 value = pyObj.As<T>();