/projects/OG-Engine/src/com/opengamma/engine/marketdata/MarketDataProvider.java

https://github.com/gsteri1/OG-Platform · Java · 127 lines · 24 code · 16 blank · 87 comment · 0 complexity · a69205825113e825a777bbd2b0563910 MD5 · raw file

  1. /**
  2. * Copyright (C) 2009 - present by OpenGamma Inc. and the OpenGamma group of companies
  3. *
  4. * Please see distribution for license.
  5. */
  6. package com.opengamma.engine.marketdata;
  7. import java.util.Set;
  8. import javax.time.Duration;
  9. import javax.time.Instant;
  10. import com.opengamma.engine.marketdata.availability.MarketDataAvailabilityProvider;
  11. import com.opengamma.engine.marketdata.permission.MarketDataPermissionProvider;
  12. import com.opengamma.engine.marketdata.spec.MarketDataSpecification;
  13. import com.opengamma.engine.value.ValueRequirement;
  14. import com.opengamma.livedata.UserPrincipal;
  15. import com.opengamma.util.PublicSPI;
  16. /**
  17. * Represents a source of market data from which the engine can obtain a consistent snapshot and receive notifications
  18. * of changes.
  19. */
  20. @PublicSPI
  21. public interface MarketDataProvider {
  22. /**
  23. * Adds a listener which will receive notifications of certain events. The events could be related to any
  24. * subscriptions made through this snapshot provider.
  25. *
  26. * @param listener the listener to add.
  27. */
  28. void addListener(MarketDataListener listener);
  29. /**
  30. * Removes a listener.
  31. *
  32. * @param listener the listener to remove
  33. */
  34. void removeListener(MarketDataListener listener);
  35. //-------------------------------------------------------------------------
  36. /**
  37. * Attempts to subscribe a user to a piece of market data. All listeners will be notified of the result
  38. * asynchronously. The existence of a subscription might notify the provider that the value should be included in
  39. * snapshots.
  40. *
  41. * @param user the user making the subscription, not null
  42. * @param valueRequirement the market data requirement, not null
  43. */
  44. void subscribe(UserPrincipal user, ValueRequirement valueRequirement);
  45. /**
  46. * Attempts to subscribe a user to a set of market data. All listeners will be notified of the result
  47. * asynchronously. The existence of a subscription might notify the provider that the value should be included in
  48. * snapshots.
  49. *
  50. * @param user the user making the subscription, not null
  51. * @param valueRequirements the market data requirements, not null
  52. */
  53. void subscribe(UserPrincipal user, Set<ValueRequirement> valueRequirements);
  54. /**
  55. * Unsubscribes a user from a piece of market data.
  56. *
  57. * @param user the user who made the subscription, not null
  58. * @param valueRequirement the market data requirement, not null
  59. */
  60. void unsubscribe(UserPrincipal user, ValueRequirement valueRequirement);
  61. /**
  62. * Unsubscribes a user from a set of market data.
  63. *
  64. * @param user the user who made the subscription, not null
  65. * @param valueRequirements the market data requirements, not null
  66. */
  67. void unsubscribe(UserPrincipal user, Set<ValueRequirement> valueRequirements);
  68. //-------------------------------------------------------------------------
  69. /**
  70. * Gets the availability provider for this market data provider. It is expected that obtaining an accurate
  71. * availability provider could be a heavy operation. This method is called every time a view definition is compiled,
  72. * in order to build the dependency graphs, and the result on each occasion is cached and reused throughout that
  73. * compilation.
  74. *
  75. * @return the availability provider, not null
  76. */
  77. MarketDataAvailabilityProvider getAvailabilityProvider();
  78. /**
  79. * Gets the permission provider, not null
  80. *
  81. * @return the permission provider, not null
  82. */
  83. MarketDataPermissionProvider getPermissionProvider();
  84. //-------------------------------------------------------------------------
  85. /**
  86. * Gets whether a market data specification is compatible with this market data provider. It does not necessarily
  87. * indicate that the specification can be satisfied, only whether the market data provider knows how to make the best
  88. * attempt to satisfy it.
  89. *
  90. * @param marketDataSpec describes the market data, not null
  91. * @return true if the specification is compatible with this provider
  92. */
  93. boolean isCompatible(MarketDataSpecification marketDataSpec);
  94. /**
  95. * Obtains access to a snapshot of market data.
  96. *
  97. * @param marketDataSpec describes the market data to obtain, not null
  98. * @return the snapshot, not null
  99. */
  100. MarketDataSnapshot snapshot(MarketDataSpecification marketDataSpec);
  101. /**
  102. * Gets the real-time duration between two instants on the market data time-line. If the market data provider is
  103. * replaying data at a different rate from normal then this will not correspond to the actual duration between the
  104. * two instants.
  105. *
  106. * @param fromInstant the instant from which the duration begins, not null
  107. * @param toInstant the instant at which the duration ends, not null
  108. * @return the real-time duration, null if the market data provider is not able to tell
  109. */
  110. Duration getRealTimeDuration(Instant fromInstant, Instant toInstant);
  111. }