|
17 | 17 | from multiprocessing import Pool |
18 | 18 | from typing import Iterable, Union |
19 | 19 | from typing import List, Union |
20 | | -from arctic import Arctic |
21 | 20 |
|
22 | 21 | # For supporting multiprocessing in outer code, joblib is used |
23 | 22 | from joblib import delayed |
24 | | -import pymongo |
25 | 23 |
|
26 | 24 | from .cache import H |
27 | 25 | from ..config import C |
@@ -582,7 +580,7 @@ def inst_calculator(inst, start_time, end_time, freq, column_names, spans=None, |
582 | 580 | data.index = _calendar[data.index.values.astype(int)] |
583 | 581 | data.index.names = ["datetime"] |
584 | 582 |
|
585 | | - if spans is not None: |
| 583 | + if not data.empty and spans is not None: |
586 | 584 | mask = np.zeros(len(data), dtype=bool) |
587 | 585 | for begin, end in spans: |
588 | 586 | mask |= (data.index >= begin) & (data.index <= end) |
@@ -702,45 +700,6 @@ def feature(self, instrument, field, start_index, end_index, freq): |
702 | 700 | return self.backend_obj(instrument=instrument, field=field, freq=freq)[start_index : end_index + 1] |
703 | 701 |
|
704 | 702 |
|
705 | | -class ArcticFeatureProvider(FeatureProvider): |
706 | | - def __init__( |
707 | | - self, uri="127.0.0.1", retry_time=0, market_transaction_time_list=[("09:15", "11:30"), ("13:00", "15:00")] |
708 | | - ): |
709 | | - super().__init__() |
710 | | - self.uri = uri |
711 | | - # TODO: |
712 | | - # retry connecting if error occurs |
713 | | - # does it real matters? |
714 | | - self.retry_time = retry_time |
715 | | - # NOTE: this is especially important for TResample operator |
716 | | - self.market_transaction_time_list = market_transaction_time_list |
717 | | - |
718 | | - def feature(self, instrument, field, start_index, end_index, freq): |
719 | | - field = str(field)[1:] |
720 | | - with pymongo.MongoClient(self.uri) as client: |
721 | | - # TODO: this will result in frequently connecting the server and performance issue |
722 | | - arctic = Arctic(client) |
723 | | - |
724 | | - if freq not in arctic.list_libraries(): |
725 | | - raise ValueError("lib {} not in arctic".format(freq)) |
726 | | - |
727 | | - if instrument not in arctic[freq].list_symbols(): |
728 | | - # instruments does not exist |
729 | | - return pd.Series() |
730 | | - else: |
731 | | - df = arctic[freq].read(instrument, columns=[field], chunk_range=(start_index, end_index)) |
732 | | - s = df[field] |
733 | | - |
734 | | - if not s.empty: |
735 | | - s = pd.concat( |
736 | | - [ |
737 | | - s.between_time(time_tuple[0], time_tuple[1]) |
738 | | - for time_tuple in self.market_transaction_time_list |
739 | | - ] |
740 | | - ) |
741 | | - return s |
742 | | - |
743 | | - |
744 | 703 | class LocalExpressionProvider(ExpressionProvider): |
745 | 704 | """Local expression data provider class |
746 | 705 |
|
|
0 commit comments