Hello,
>>> rdp.__version__ '1.0.0a12'
I am bit confused about the lack of updates on rdp.StreamingPrices when the function is.open() is not used every time in front of get_snapshot. In the end I want to make this data available to my application and not to read it from the console. Is this normal behavior. Normally with stream state open I would expect that a snapshot delivers the actual value every time and not a valid from 5 minutes ago.
What is the best way to deal with this issue?
case1: Is.open is only used 1x and data is apparently flowing in according to print statement. Here is valid that no update on get_snapshot can be observed:
>>> def display_fields(streaming_prices, instrument_name, fields): ... print("Fields received for", instrument_name, ":", fields) ... >>> streaming_prices = rdp.StreamingPrices( ... universe = ['EUR=','GBP=','JPY=', 'CAD='], ... fields = ['SALTIM', 'CF_BID','CF_ASK','OPEN_PRC', 'CF_HIGH','CF_LOW', 'CF_CLOSE'], ... on_refresh = lambda streaming_prices, instrument_name, fields : ... display_fields(streaming_prices, instrument_name, fields), ... on_update = lambda streaming_prices, instrument_name, fields : ... display_fields(streaming_prices, instrument_name, fields) ... ) >>> streaming_prices.open() Fields received for EUR= : {'CF_BID': 1.1131, 'CF_ASK': 1.1132, 'OPEN_PRC': 1.1144, 'CF_HIGH': 1.1155, 'CF_LOW': 1.1122, 'CF_CLOSE': 1.1143} Fields received for EUR= : {'CF_BID': 1.113, 'CF_ASK': 1.1134} Fields received for EUR= : {'CF_BID': 1.1129, 'CF_ASK': 1.1133} Fields received for EUR= : {'CF_BID': 1.1131, 'CF_ASK': 1.1132} Fields received for GBP= : {'CF_BID': 1.3387, 'CF_ASK': 1.3391, 'OPEN_PRC': 1.3378, 'CF_HIGH': 1.3415, 'CF_LOW': 1.3366, 'CF_CLOSE': 1.3385} Fields received for CAD= : {'CF_BID': 1.2788, 'CF_ASK': 1.2792, 'OPEN_PRC': 1.2741, 'CF_HIGH': 1.2796, 'CF_LOW': 1.2713, 'CF_CLOSE': 1.274} Fields received for JPY= : {'CF_BID': 115.6, 'CF_ASK': 115.61, 'OPEN_PRC': 115.35, 'CF_HIGH': 115.68, 'CF_LOW': 115.28, 'CF_CLOSE': 115.34} <StreamState.Open: 3> >>> streaming_prices.open() <StreamState.Open: 3> >>> streaming_prices.get_snapshot() Instrument CF_BID CF_ASK OPEN_PRC CF_HIGH CF_LOW CF_CLOSE 0 EUR= 1.1131 1.1132 1.1144 1.1155 1.1122 1.1143 1 GBP= 1.3387 1.3391 1.3378 1.3415 1.3366 1.3385 2 JPY= 115.6 115.61 115.35 115.68 115.28 115.34 3 CAD= 1.2788 1.2792 1.2741 1.2796 1.2713 1.274 >>> streaming_prices.get_snapshot() Instrument CF_BID CF_ASK OPEN_PRC CF_HIGH CF_LOW CF_CLOSE 0 EUR= 1.1131 1.1132 1.1144 1.1155 1.1122 1.1143 1 GBP= 1.3387 1.3391 1.3378 1.3415 1.3366 1.3385 2 JPY= 115.6 115.61 115.35 115.68 115.28 115.34 3 CAD= 1.2788 1.2792 1.2741 1.2796 1.2713 1.274 >>> streaming_prices.get_snapshot() Instrument CF_BID CF_ASK OPEN_PRC CF_HIGH CF_LOW CF_CLOSE 0 EUR= 1.1131 1.1132 1.1144 1.1155 1.1122 1.1143 1 GBP= 1.3387 1.3391 1.3378 1.3415 1.3366 1.3385 2 JPY= 115.6 115.61 115.35 115.68 115.28 115.34 3 CAD= 1.2788 1.2792 1.2741 1.2796 1.2713 1.274 >>> streaming_prices.get_snapshot() Instrument CF_BID CF_ASK OPEN_PRC CF_HIGH CF_LOW CF_CLOSE 0 EUR= 1.1131 1.1132 1.1144 1.1155 1.1122 1.1143 1 GBP= 1.3387 1.3391 1.3378 1.3415 1.3366 1.3385 2 JPY= 115.6 115.61 115.35 115.68 115.28 115.34 3 CAD= 1.2788 1.2792 1.2741 1.2796 1.2713 1.274 >>> streaming_prices.state() TypeError: 'StreamState' object is not callable >>> streaming_prices.state <StreamState.Open: 3>
Case2: is.open is used every time before get_snapshot and data is updated (now I get different prices):
>>> streaming_prices.state <StreamState.Open: 3> >>> streaming_prices.open() <StreamState.Open: 3> >>> streaming_prices.get_snapshot() Instrument CF_BID CF_ASK OPEN_PRC CF_HIGH CF_LOW CF_CLOSE 0 EUR= 1.1131 1.1132 1.1144 1.1155 1.1122 1.1143 1 GBP= 1.3387 1.3391 1.3378 1.3415 1.3366 1.3385 2 JPY= 115.6 115.61 115.35 115.68 115.28 115.34 3 CAD= 1.2788 1.2792 1.2741 1.2796 1.2713 1.274 >>> streaming_prices.open() Fields received for EUR= : {'CF_BID': 1.1131, 'CF_ASK': 1.1133} Fields received for CAD= : {'CF_BID': 1.2788, 'CF_ASK': 1.2793} Fields received for JPY= : {'CF_BID': 115.59, 'CF_ASK': 115.64} Fields received for GBP= : {'CF_BID': 1.3387, 'CF_ASK': 1.3392} Fields received for JPY= : {'CF_BID': 115.6, 'CF_ASK': 115.61} Fields received for CAD= : {'CF_BID': 1.2789, 'CF_ASK': 1.2791} Fields received for EUR= : {'CF_BID': 1.1131, 'CF_ASK': 1.1133} Fields received for GBP= : {'CF_BID': 1.3388, 'CF_ASK': 1.339} Fields received for JPY= : {'CF_BID': 115.6, 'CF_ASK': 115.61} Fields received for CAD= : {'CF_BID': 1.2788, 'CF_ASK': 1.2792} Fields received for EUR= : {'CF_BID': 1.1131, 'CF_ASK': 1.1132} Fields received for GBP= : {'CF_BID': 1.3387, 'CF_ASK': 1.3391} <StreamState.Open: 3> >>> streaming_prices.get_snapshot() Instrument CF_BID CF_ASK OPEN_PRC CF_HIGH CF_LOW CF_CLOSE 0 EUR= 1.1131 1.1132 1.1144 1.1155 1.1122 1.1143 1 GBP= 1.3388 1.339 1.3378 1.3415 1.3366 1.3385 2 JPY= 115.6 115.61 115.35 115.68 115.28 115.34 3 CAD= 1.2789 1.2791 1.2741 1.2796 1.2713 1.274 >>> streaming_prices.get_snapshot() Instrument CF_BID CF_ASK OPEN_PRC CF_HIGH CF_LOW CF_CLOSE 0 EUR= 1.1131 1.1132 1.1144 1.1155 1.1122 1.1143 1 GBP= 1.3388 1.339 1.3378 1.3415 1.3366 1.3385 2 JPY= 115.6 115.61 115.35 115.68 115.28 115.34 3 CAD= 1.2789 1.2791 1.2741 1.2796 1.2713 1.274 >>> streaming_prices.open() Fields received for JPY= : {'CF_BID': 115.59, 'CF_ASK': 115.62} Fields received for JPY= : {'CF_BID': 115.59, 'CF_ASK': 115.63} Fields received for CAD= : {'CF_BID': 1.2789, 'CF_ASK': 1.2791} Fields received for GBP= : {'CF_BID': 1.3388, 'CF_ASK': 1.339} Fields received for JPY= : {'CF_BID': 115.6, 'CF_ASK': 115.61} Fields received for JPY= : {'CF_BID': 115.6, 'CF_ASK': 115.61} Fields received for JPY= : {'CF_BID': 115.6, 'CF_ASK': 115.61} <StreamState.Open: 3> >>> streaming_prices.get_snapshot() Instrument CF_BID CF_ASK OPEN_PRC CF_HIGH CF_LOW CF_CLOSE 0 EUR= 1.113 1.1134 1.1144 1.1155 1.1122 1.1143 1 GBP= 1.3388 1.3389 1.3378 1.3415 1.3366 1.3385 2 JPY= 115.6 115.61 115.35 115.68 115.28 115.34 3 CAD= 1.2788 1.2792 1.2741 1.2796 1.2713 1.274 >>> streaming_prices.open() Fields received for EUR= : {'CF_BID': 1.1131, 'CF_ASK': 1.1132} Fields received for CAD= : {'CF_BID': 1.2789, 'CF_ASK': 1.279} Fields received for CAD= : {'CF_BID': 1.2787, 'CF_ASK': 1.2791} Fields received for JPY= : {'CF_BID': 115.6, 'CF_ASK': 115.61} Fields received for CAD= : {'CF_BID': 1.2788, 'CF_ASK': 1.2792} Fields received for CAD= : {'CF_BID': 1.2789, 'CF_ASK': 1.279} Fields received for CAD= : {'CF_BID': 1.2788, 'CF_ASK': 1.2792} Fields received for GBP= : {'CF_BID': 1.3388, 'CF_ASK': 1.3389} Fields received for EUR= : {'CF_BID': 1.113, 'CF_ASK': 1.1134} Fields received for CAD= : {'CF_BID': 1.2788, 'CF_ASK': 1.2792} <StreamState.Open: 3> >>> streaming_prices.get_snapshot() Instrument CF_BID CF_ASK OPEN_PRC CF_HIGH CF_LOW CF_CLOSE 0 EUR= 1.1131 1.1132 1.1144 1.1155 1.1122 1.1143 1 GBP= 1.3387 1.3391 1.3378 1.3415 1.3366 1.3385 2 JPY= 115.6 115.61 115.35 115.68 115.28 115.34 3 CAD= 1.2788 1.2792 1.2741 1.2796 1.2713 1.274