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 ();
441 UpdateSubscriptionProperties();
481 registeredTypesProvider,
482 marginInterestRateModel
485 _subscriptionsBag.Add(config);
486 UpdateSubscriptionProperties();
506 if (_localTimeKeeper ==
null)
599 _localTimeKeeper = localTimeKeeper;
600 Exchange.SetLocalDateTimeFrontierProvider(localTimeKeeper);
610 if (data ==
null)
return;
613 UpdateMarketPrice(data);
624 public void Update(IReadOnlyList<BaseData> data,
Type dataType,
bool? containsFillForwardData =
null)
628 UpdateMarketPrice(data[data.Count - 1]);
634 [Obsolete(
"This method is obsolete. Use the 'SubscriptionDataConfig' exposed by" +
635 " 'SubscriptionManager' and the 'IsCustomData()' extension method")]
663 [Obsolete(
"This method is obsolete. Use the 'SubscriptionDataConfig' exposed by" +
664 " 'SubscriptionManager' and the 'SetDataNormalizationMode()' extension method")]
667 lock (_subscriptionsBag)
669 foreach (var subscription
in _subscriptionsBag)
671 subscription.DataNormalizationMode = mode;
673 UpdateSubscriptionProperties();
684 lock (_subscriptionsBag)
687 .Select(x => x.DataNormalizationMode)
855 throw new Exception($
"SetShortableProvider: {pyObject.Repr()} is not a valid argument");
888 throw new ArgumentException($
"SetDataFilter: {pyObject.Repr()} is not a valid argument");
902 #region DynamicObject Overrides and Helper Methods
907 public override bool TryGetMember(GetMemberBinder binder, out
object result)
915 public override bool TrySetMember(SetMemberBinder binder,
object value)
924 public override bool TryInvokeMember(InvokeMemberBinder binder,
object[] args, out
object result)
929 CultureInfo.InvariantCulture);
945 public void Add(
string key,
object value)
956 public void Set(
string key,
object value)
972 value = CastDynamicPropertyValue<T>(obj);
1012 value = CastDynamicPropertyValue<T>(objectValue);
1030 public object this[
string key]
1034 return Get<object>(key);
1062 lock (_subscriptionsBag)
1072 _subscriptionsBag.Add(subscription);
1073 UpdateSubscriptionProperties();
1083 lock (_subscriptionsBag)
1085 foreach (var subscription
in subscriptions)
1087 if (subscription.Symbol !=
Symbol)
1089 throw new ArgumentException(Messages.Security.UnmatchingSymbols, $
"{nameof(subscription)}.{nameof(subscription.Symbol)}");
1093 throw new ArgumentException(Messages.Security.UnmatchingExchangeTimeZones, $
"{nameof(subscription)}.{nameof(subscription.ExchangeTimeZone)}");
1095 _subscriptionsBag.Add(subscription);
1097 UpdateSubscriptionProperties();
1115 private void UpdateSubscriptionProperties()
1117 Resolution = _subscriptionsBag.Select(x => x.Resolution).DefaultIfEmpty(
Resolution.Daily).Min();
1126 private void UpdateMarketPrice(
BaseData data)
1138 private static T CastDynamicPropertyValue<T>(
object obj)
1141 var pyObj = obj as PyObject;
1146 value = pyObj.As<T>();
1160 internal void ApplySplit(
Split split)
1162 Cache.ApplySplit(split);
1169 internal virtual void UpdateSymbolProperties(
SymbolProperties symbolProperties)
1171 if (symbolProperties !=
null)