diff --git a/funcat.egg-info/PKG-INFO b/funcat.egg-info/PKG-INFO index f58f9b3..a688be1 100644 --- a/funcat.egg-info/PKG-INFO +++ b/funcat.egg-info/PKG-INFO @@ -1,4 +1,4 @@ -Metadata-Version: 2.1 +Metadata-Version: 1.1 Name: funcat Version: 1.1.0 Summary: funcat @@ -6,6 +6,7 @@ Home-page: https://github.com/cedricporter/funcat Author: Hua Liang Author-email: et@everet.org License: Apache License v2 +Description: UNKNOWN Platform: UNKNOWN Classifier: Programming Language :: Python Classifier: Operating System :: Microsoft :: Windows @@ -14,7 +15,3 @@ Classifier: Programming Language :: Python :: 2.7 Classifier: Programming Language :: Python :: 3.4 Classifier: Programming Language :: Python :: 3.5 Classifier: Programming Language :: Python :: 3.6 -License-File: LICENSE - -UNKNOWN - diff --git a/funcat/data/tushare_backend.py b/funcat/data/tushare_backend.py index aafe991..f582cc8 100644 --- a/funcat/data/tushare_backend.py +++ b/funcat/data/tushare_backend.py @@ -98,7 +98,14 @@ def get_price(self, order_book_id, start, end, freq): str_start_date = get_str_date_from_int(start) str_end_date = get_str_date_from_int(end) - filename = (order_book_id + str_start_date + str_end_date).replace('.', '-') + '.csv' + + # should find up-to-date filename, in case of lossing data. + filename = "NAF" + for trade_date_suffix in reversed(self.trading_dates): + filename = (order_book_id + str_start_date + str(trade_date_suffix)).replace('.', '-') + '.csv' + if os.path.exists('data/' + filename): + break + if os.path.exists('data'): if os.path.exists('data/' + filename): # csv file may be empty, raise except EmptyDataError @@ -145,6 +152,7 @@ def get_price(self, order_book_id, start, end, freq): df.to_csv('data/' + filename, index=False) + # dataframe needs update if found persistent data from disk and end time is equal to today if not df.empty and str(df.at[0, 'trade_date']) == str(last_tradeday) and str(end) == now: rt = get_runtime_data(order_book_id) if rt is not None and str(rt.at[0, 'trade_date']) == now: diff --git a/tests/test_api.py b/tests/test_api.py index 663281c..22d10f5 100644 --- a/tests/test_api.py +++ b/tests/test_api.py @@ -11,8 +11,8 @@ def test_000001(): from funcat.data.tushare_backend import TushareDataBackend set_data_backend(TushareDataBackend()) - T("20200814") - S("000001.SH") + T("20220808") + S("002694.SZ") print(O, H, L, C, V) print(MA(C, 5), MA(C, 10), MA(C, 20))