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);
590 Value = coarse.
Value,
591 EndTime = coarse.EndTime,
592 DollarVolume = coarse.DollarVolume,
593 DataType = coarse.DataType,
613 _localTimeKeeper = localTimeKeeper;
619 Exchange.SetLocalDateTimeFrontier(args.Time);
630 if (data ==
null)
return;
633 UpdateMarketPrice(data);
644 public void Update(IReadOnlyList<BaseData> data,
Type dataType,
bool? containsFillForwardData =
null)
648 UpdateMarketPrice(data[data.Count - 1]);
654 [Obsolete(
"This method is obsolete. Use the 'SubscriptionDataConfig' exposed by" +
655 " 'SubscriptionManager' and the 'IsCustomData()' extension method")]
683 [Obsolete(
"This method is obsolete. Use the 'SubscriptionDataConfig' exposed by" +
684 " 'SubscriptionManager' and the 'SetDataNormalizationMode()' extension method")]
687 lock (_subscriptionsBag)
689 foreach (var subscription
in _subscriptionsBag)
691 subscription.DataNormalizationMode = mode;
693 UpdateSubscriptionProperties();
704 lock (_subscriptionsBag)
707 .Select(x => x.DataNormalizationMode)
857 throw new Exception($
"SetShortableProvider: {pyObject.Repr()} is not a valid argument");
890 throw new ArgumentException($
"SetDataFilter: {pyObject.Repr()} is not a valid argument");
904 #region DynamicObject Overrides and Helper Methods
909 public override bool TryGetMember(GetMemberBinder binder, out
object result)
917 public override bool TrySetMember(SetMemberBinder binder,
object value)
926 public override bool TryInvokeMember(InvokeMemberBinder binder,
object[] args, out
object result)
931 CultureInfo.InvariantCulture);
947 public void Add(
string key,
object value)
963 value = CastDynamicPropertyValue<T>(obj);
1003 value = CastDynamicPropertyValue<T>(objectValue);
1021 public object this[
string key]
1025 return Get<object>(key);
1053 lock (_subscriptionsBag)
1057 throw new ArgumentException(
Messages.
Security.UnmatchingSymbols, $
"{nameof(subscription)}.{nameof(subscription.Symbol)}");
1061 throw new ArgumentException(
Messages.
Security.UnmatchingExchangeTimeZones, $
"{nameof(subscription)}.{nameof(subscription.ExchangeTimeZone)}");
1063 _subscriptionsBag.Add(subscription);
1064 UpdateSubscriptionProperties();
1074 lock (_subscriptionsBag)
1076 foreach (var subscription
in subscriptions)
1078 if (subscription.Symbol !=
Symbol)
1080 throw new ArgumentException(Messages.Security.UnmatchingSymbols, $
"{nameof(subscription)}.{nameof(subscription.Symbol)}");
1084 throw new ArgumentException(Messages.Security.UnmatchingExchangeTimeZones, $
"{nameof(subscription)}.{nameof(subscription.ExchangeTimeZone)}");
1086 _subscriptionsBag.Add(subscription);
1088 UpdateSubscriptionProperties();
1106 private void UpdateSubscriptionProperties()
1108 Resolution = _subscriptionsBag.Select(x => x.Resolution).DefaultIfEmpty(
Resolution.Daily).Min();
1117 private void UpdateMarketPrice(
BaseData data)
1129 private static T CastDynamicPropertyValue<T>(
object obj)
1132 var pyObj = obj as PyObject;
1137 value = pyObj.As<T>();