Here are the examples of the python api async_blp.requests.ReferenceDataRequest taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
13 Examples
3
Source : conftest.py
with MIT License
from rockscie
with MIT License
from rockscie
def data_request():
"""
Simple request
"""
field_name = 'PX_LAST'
security_id = 'F Equity'
return ReferenceDataRequest([security_id], [field_name])
@pytest.fixture()
3
Source : test_base_handler.py
with MIT License
from rockscie
with MIT License
from rockscie
async def test__current_load(self, session_options):
handler = HandlerBase(session_options)
request = ReferenceDataRequest(['security'],
['field1', 'field2'])
handler._current_requests['id'] = request
assert handler.current_load == 2
async def test___raise_exception__message(self, msg_daily_reached,
3
Source : test_requests.py
with MIT License
from rockscie
with MIT License
from rockscie
def test__init__not_inside_loop(self,
simple_field_data):
field_name, _, security_id = simple_field_data
request = ReferenceDataRequest([security_id], [field_name])
assert request._loop is None
assert request._msg_queue is None
@pytest.mark.asyncio
3
Source : test_requests.py
with MIT License
from rockscie
with MIT License
from rockscie
async def test__set_running_loop_as_default__queue_is_empty(
self,
simple_field_data):
field_name, _, security_id = simple_field_data
request = ReferenceDataRequest([security_id], [field_name])
request.set_running_loop_as_default()
assert request._loop == asyncio.get_running_loop()
@pytest.mark.asyncio
3
Source : test_requests.py
with MIT License
from rockscie
with MIT License
from rockscie
async def test__set_running_loop_as_default__queue_is_not_empty(
self,
simple_field_data):
field_name, _, security_id = simple_field_data
request = ReferenceDataRequest([security_id], [field_name])
request._msg_queue.put_nowait(1)
with pytest.raises(RuntimeError):
request.set_running_loop_as_default()
def test__set_running_loop_as_default__not_inside_loop(
3
Source : test_requests.py
with MIT License
from rockscie
with MIT License
from rockscie
def test__set_running_loop_as_default__not_inside_loop(
self,
simple_field_data):
field_name, _, security_id = simple_field_data
request = ReferenceDataRequest([security_id], [field_name])
with pytest.raises(RuntimeError):
request.set_running_loop_as_default()
@pytest.mark.asyncio
3
Source : test_requests.py
with MIT License
from rockscie
with MIT License
from rockscie
async def test__send_queue_message__inside_loop(self, simple_field_data):
field_name, _, security_id = simple_field_data
request = ReferenceDataRequest([security_id], [field_name])
request.send_queue_message(1)
await asyncio.sleep(0.001)
assert request._msg_queue.get_nowait() == 1
def test__send_queue_message__not_inside_loop(self, simple_field_data):
3
Source : test_requests.py
with MIT License
from rockscie
with MIT License
from rockscie
def test__send_queue_message__not_inside_loop(self, simple_field_data):
field_name, _, security_id = simple_field_data
request = ReferenceDataRequest([security_id], [field_name])
with pytest.raises(RuntimeError):
request.send_queue_message(1)
@pytest.mark.asyncio
3
Source : test_requests.py
with MIT License
from rockscie
with MIT License
from rockscie
async def test__process__one_security(self,
response_msg_one_security,
one_value_array_field_data):
field_name, field_value, security_id = one_value_array_field_data
request = ReferenceDataRequest([security_id], [field_name])
request.send_queue_message(response_msg_one_security)
request.send_queue_message(None)
expected_df = pd.DataFrame(columns=[field_name], index=[security_id])
expected_df.at[security_id, field_name] = field_value
actual_df, _ = await request.process()
pd.testing.assert_frame_equal(actual_df, expected_df)
@pytest.mark.asyncio
3
Source : test_requests.py
with MIT License
from rockscie
with MIT License
from rockscie
async def test__process__empty(self, one_value_array_field_data):
field_name, _, security_id = one_value_array_field_data
request = ReferenceDataRequest([security_id], [field_name])
request.send_queue_message(None)
expected_df = pd.DataFrame(columns=[field_name], index=[security_id])
actual_df, _ = await request.process()
pd.testing.assert_frame_equal(actual_df, expected_df)
class TestHistoricalDataRequest:
0
Source : test_async_blp.py
with MIT License
from rockscie
with MIT License
from rockscie
async def test___chose_handler__free_slot_available(self,
session_options):
"""
When there are no free handlers and `max_sessions` is not reached,
new handler should be created
"""
bloomberg = AsyncBloomberg()
handler = RequestHandler(session_options)
request = ReferenceDataRequest(['security_id'], ['field'])
corr_id = CorrelationId(uuid.uuid4())
handler._current_requests[corr_id] = request
bloomberg._request_handlers.append(handler)
chosen_handler = bloomberg._choose_handler()
assert chosen_handler != handler
async def test___chose_handler__max_sessions_reached(self,
0
Source : test_async_blp.py
with MIT License
from rockscie
with MIT License
from rockscie
async def test___chose_handler__max_sessions_reached(self,
session_options):
"""
When there are no free handlers and `max_sessions` is reached,
the least busy handler should be chosen
"""
bloomberg = AsyncBloomberg(max_sessions=2)
handler_1 = RequestHandler(session_options)
handler_2 = RequestHandler(session_options)
request_1 = ReferenceDataRequest(['security_id'], ['field'])
request_2 = ReferenceDataRequest(['security_id', 'security_id_2'],
['field', 'field_2'])
corr_id_1 = CorrelationId(uuid.uuid4())
corr_id_2 = CorrelationId(uuid.uuid4())
handler_1._current_requests[corr_id_1] = request_1
handler_2._current_requests[corr_id_2] = request_2
bloomberg._request_handlers.append(handler_1)
bloomberg._request_handlers.append(handler_2)
chosen_handler = bloomberg._choose_handler()
assert chosen_handler == handler_1
def test__init__not_inside_loop(self):
0
Source : test_requests.py
with MIT License
from rockscie
with MIT License
from rockscie
async def test__process__several_securities(self,
response_msg_several_securities,
one_value_array_field_data,
simple_field_data):
field_name_1, field_value_1, security_id_1 = one_value_array_field_data
field_name_2, field_value_2, security_id_2 = simple_field_data
request = ReferenceDataRequest([security_id_1, security_id_2],
[field_name_1, field_name_2])
request.send_queue_message(response_msg_several_securities)
request.send_queue_message(None)
expected_df = pd.DataFrame(columns=[field_name_1, field_name_2],
index=[security_id_1, security_id_2])
expected_df.at[security_id_1, field_name_1] = field_value_1
expected_df.at[security_id_2, field_name_2] = field_value_2
actual_df, _ = await request.process()
pd.testing.assert_frame_equal(actual_df, expected_df)
@pytest.mark.asyncio