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();
118 [Obsolete(
"This property is obsolete. Use the 'SubscriptionDataConfig' exposed by 'SubscriptionManager'")]
124 [Obsolete(
"This property is obsolete. Use the 'SubscriptionDataConfig' exposed by 'SubscriptionManager'")]
130 [Obsolete(
"This property is obsolete. Use the 'SubscriptionDataConfig' exposed by 'SubscriptionManager'")]
136 [Obsolete(
"This property is obsolete. Use the 'SubscriptionDataConfig' exposed by 'SubscriptionManager'")]
142 [Obsolete(
"This property returns only the first subscription. Use the 'Subscriptions' property for all of this security's subscriptions.")]
147 lock (_subscriptionsBag)
149 return _subscriptionsBag.FirstOrDefault();
345 registeredTypesProvider,
377 registeredTypesProvider,
405 if (symbolProperties ==
null)
416 _subscriptionsBag =
new ();
436 UpdateSubscriptionProperties();
476 registeredTypesProvider,
477 marginInterestRateModel
480 _subscriptionsBag.Add(config);
481 UpdateSubscriptionProperties();
501 if (_localTimeKeeper ==
null)
594 _localTimeKeeper = localTimeKeeper;
595 Exchange.SetLocalDateTimeFrontierProvider(localTimeKeeper);
605 if (data ==
null)
return;
608 UpdateMarketPrice(data);
619 public void Update(IReadOnlyList<BaseData> data,
Type dataType,
bool? containsFillForwardData =
null)
623 UpdateMarketPrice(data[data.Count - 1]);
629 [Obsolete(
"This method is obsolete. Use the 'SubscriptionDataConfig' exposed by" +
630 " 'SubscriptionManager' and the 'IsCustomData()' extension method")]
658 [Obsolete(
"This method is obsolete. Use the 'SubscriptionDataConfig' exposed by" +
659 " 'SubscriptionManager' and the 'SetDataNormalizationMode()' extension method")]
662 lock (_subscriptionsBag)
664 foreach (var subscription
in _subscriptionsBag)
666 subscription.DataNormalizationMode = mode;
668 UpdateSubscriptionProperties();
679 lock (_subscriptionsBag)
682 .Select(x => x.DataNormalizationMode)
850 throw new Exception($
"SetShortableProvider: {pyObject.Repr()} is not a valid argument");
883 throw new ArgumentException($
"SetDataFilter: {pyObject.Repr()} is not a valid argument");
897 #region DynamicObject Overrides and Helper Methods
902 public override bool TryGetMember(GetMemberBinder binder, out
object result)
910 public override bool TrySetMember(SetMemberBinder binder,
object value)
919 public override bool TryInvokeMember(InvokeMemberBinder binder,
object[] args, out
object result)
924 CultureInfo.InvariantCulture);
940 public void Add(
string key,
object value)
956 value = CastDynamicPropertyValue<T>(obj);
996 value = CastDynamicPropertyValue<T>(objectValue);
1014 public object this[
string key]
1018 return Get<object>(key);
1046 lock (_subscriptionsBag)
1056 _subscriptionsBag.Add(subscription);
1057 UpdateSubscriptionProperties();
1067 lock (_subscriptionsBag)
1069 foreach (var subscription
in subscriptions)
1071 if (subscription.Symbol !=
Symbol)
1073 throw new ArgumentException(Messages.Security.UnmatchingSymbols, $
"{nameof(subscription)}.{nameof(subscription.Symbol)}");
1077 throw new ArgumentException(Messages.Security.UnmatchingExchangeTimeZones, $
"{nameof(subscription)}.{nameof(subscription.ExchangeTimeZone)}");
1079 _subscriptionsBag.Add(subscription);
1081 UpdateSubscriptionProperties();
1099 private void UpdateSubscriptionProperties()
1101 Resolution = _subscriptionsBag.Select(x => x.Resolution).DefaultIfEmpty(
Resolution.Daily).Min();
1110 private void UpdateMarketPrice(
BaseData data)
1122 private static T CastDynamicPropertyValue<T>(
object obj)
1125 var pyObj = obj as PyObject;
1130 value = pyObj.As<T>();
1144 internal void ApplySplit(
Split split)
1146 Cache.ApplySplit(split);
1153 internal virtual void UpdateSymbolProperties(
SymbolProperties symbolProperties)
1155 if (symbolProperties !=
null)