예제 #1
0
def check_immediate_availability():
    # start indexing task - should take a few seconds
    # post_to_tranquility(MarketEvent('trade', 'gold', 'c1', 500, 'Russia', -10, 16.7))
    product_name = 'bronze'
    MeDruidHelper.post_to_tranquility(MarketEvent('trade', product_name, 'c1', 500, 'Russia', -10, 16.7))
    events = MeDruidHelper().select_one_market_event(product_name)
    return len(events) > 0
예제 #2
0
 def test_track_indexing_task(self):
     """
     example of tracking indexing task (either batch or streaming, although streaming will run until period closes)
     :return:
     """
     MeDruidHelper.track_indexing_task(
         'index_hadoop_marketevents_2016-07-11T09:38:07.348Z')
예제 #3
0
 def test_streaming(self):
     product_name = 'ore'
     MeDruidHelper.post_to_tranquility(
         MarketEvent('trade', product_name, 'South Land', 500, 'Russia',
                     -10, 16.7))
     time.sleep(1)
     event = MeDruidHelper().select_one_market_event(product_name)
     print event
예제 #4
0
 def test_simple_select(self):
     product_name = 'copper'
     event_time = (datetime.utcnow() - relativedelta(month=1)).strftime(
         model.DT_FORMAT)
     event = MarketEvent('trade',
                         product_name,
                         'Sumitomo',
                         50000,
                         'Japan',
                         qty=-10000,
                         price=200,
                         time=event_time)
     MeDruidHelper.index_market_events('marketevents2.json', [event])
     print MeDruidHelper().select_one_market_event(product_name)
예제 #5
0
def main():
    proto_event = MarketEvent('trade',
                              'copper',
                              'Sumitomo',
                              50000,
                              'Japan',
                              qty=-10000,
                              price=200)
    events = []
    for _ in range(1):
        me = copy(proto_event)
        random_int = random.randint(1, 100)
        me.time = (datetime.utcnow() - timedelta(days=random_int)).strftime(
            model.DT_FORMAT)
        me.qty = proto_event.qty + 1000 * random_int * (1 if random_int %
                                                        2 == 0 else -1)
        events.append(me)
    MeDruidHelper.index_market_events('marketevents2.json', events)
예제 #6
0
 def test_positions_query(self):
     delta = MeDruidHelper().positions_delta(product_name='copper',
                                             min_num_employees=1000,
                                             start_dt=datetime(year=2016,
                                                               month=02,
                                                               day=01),
                                             end_dt=datetime(year=2016,
                                                             month=07,
                                                             day=10))
예제 #7
0
 def test_shutdown_streaming_task(self):
     MeDruidHelper.shutdown_streaming_task(
         'index_realtime_marketevents_2016-07-11T10%3A00%3A00.000Z_0_0')