Ejemplo n.º 1
0
def test_000001():
    from funcat.data.tencent_backend import TencentDataBackend
    set_data_backend(TencentDataBackend(freq='5m'))

    data_backend = funcat_execution_context.get_data_backend()
    order_book_id_list = data_backend.get_order_book_id_list()
    funcat_execution_context.set_current_freq("5m")

    now = datetime.date.today().strftime("%Y%m%d")
    print(now)
    T(now)
    S("601360.SH")

    print(C, CCI(C, H, L))
Ejemplo n.º 2
0
def test_000001():
    """本测试为测试分钟数据,非交易时间会报错!
    """
    from funcat.data.tencent_backend import TencentDataBackend
    set_data_backend(TencentDataBackend(freq='5m'))

    data_backend = funcat_execution_context.get_data_backend()
    order_book_id_list = data_backend.get_order_book_id_list()
    funcat_execution_context.set_current_freq("5m")

    now = datetime.date.today().strftime("%Y%m%d")
    print(now)
    T(now)
    # S("601360.SH")
    S("600000.SH")
    print(f"Close:\n{C}, type:{type(C)}")
    print(f"High:\n{H}, type:{type(H)}")
    print(f"Low:\n{L}, type:{type(L)}")
    print(CCI(C, H, L))
Ejemplo n.º 3
0
 def test_CLOSE_asyn(self):
     data_backend = ExecutionContext.get_data_backend()
     order_book_id_list = data_backend.get_order_book_id_list()[150:300]
     # 选出涨停股
     data = selectAsync(lambda: C > 50,
                        start_date=20181228,
                        end_date=20190104,
                        order_book_id_list=order_book_id_list)
     self.assertTrue(len(data) > 0, f"交易数据:{data}")
     print(data)
Ejemplo n.º 4
0
 def test_CLOSE_select2_2(self):
     data_backend = ExecutionContext.get_data_backend()
     order_book_id_list = data_backend.get_order_book_id_list()[150:300]
     # 选出涨停股
     data = select2(lambda: 30 > C > 20,
                    start_date=20181228,
                    end_date=20190104,
                    order_book_id_list=order_book_id_list)
     self.assertTrue(len(data) > 0, f"交易数据:{data}")
     print(data)
     for item in range(len(data)):
         for k, v in data[item].items():
             print(k, v, end=";")
         print("")
Ejemplo n.º 5
0
 def tearDown(self):
     super().tearDown(self)
     try:
         # 打印当前统计信息
         from funcat import get_start_date, get_current_date, get_current_security
         from funcat.context import ExecutionContext
         start_date = get_start_date()
         current_date = get_current_date()
         trading_dates = ExecutionContext.get_data_backend(
         ).get_trading_dates(start=start_date, end=current_date)
         print(
             f"|| --> {get_current_security()},trading dates:{trading_dates[0]}~{trading_dates[-1]}"
         )
     except Exception:
         pass
Ejemplo n.º 6
0
def get_data(code):
    S(code)
    freq = ExecutionContext.get_current_freq()
    bars = get_bars(freq)
    data = pd.DataFrame(bars)
    if len(bars) > 0:
        # data = data[['datetime', 'open', 'high', 'low', 'close', 'volume']]
        data = data[['date', 'open', 'high', 'low', 'close', 'volume']]
        # data['datetime'] = pd.to_datetime(
        #     data['datetime'] // 1000000,
        #     format='%Y%m%d').astype('str')[
        #     :6]
        # data.set_index('datetime', inplace=True)
        data['date'] = pd.to_datetime(data['date'], format="%Y-%m-%d")
        data.set_index('date', inplace=True)
    return data
Ejemplo n.º 7
0
 def stock_info(cls):
     data_backend = ExecutionContext.get_data_backend()
     stock_basics = data_backend.stock_basics
     print(stock_basics.columns)
     # print(stock_basics.head(10))
     return stock_basics