5
5
import pytest
6
6
import numpy as np
7
7
import pandas as pd
8
- from pandas .tslib import Timestamp
9
8
from jqdatasdk import *
10
9
11
10
logging .basicConfig ()
12
11
log = logging
13
12
14
13
15
14
with open ("/home/server/etc/jqdatasdk/import_debug_account.py" ) as f :
16
- exec (f .read ())
15
+ exec (f .read ())
17
16
18
17
def test_get_index_stocks ():
19
18
assert len (get_index_stocks ('000300.XSHG' )) == 300
@@ -575,7 +574,7 @@ def test_ticks():
575
574
assert len (get_ticks ("NI1804.XSGE" , end_dt = "2018-03-16" , count = 100 )) == 100
576
575
assert get_ticks ("NI1804.XSGE" , end_dt = "2018-03-16" , count = 10 , fields = ["current" , "volume" , "position" , "a1_v" , "a1_p" , "b1_v" , "b1_p" ]).shape == (10 , 7 )
577
576
assert len (get_ticks ("000001.XSHE" , end_dt = "2018-03-16" , count = 10 )) == 10
578
- assert get_ticks ("SM1809.XZCE" , '2018-07-06' , '2018-07-07' ).iloc [3 ][0 ] == Timestamp ( '2018-07-06 09:00:01.500000' )
577
+ assert str ( get_ticks ("SM1809.XZCE" , '2018-07-06' , '2018-07-07' ).iloc [3 ][0 ]) == '2018-07-06 09:00:01.500000'
579
578
assert get_ticks ("000001.XSHE" , end_dt = "2018-03-16" , count = 10 , fields = ["a1_v" , "a2_v" , "a3_v" , "a4_v" , "a5_v" , "b1_v" , "b2_v" , "b3_v" , "b4_v" , "b5_v" ]).shape == (10 , 10 )
580
579
581
580
@@ -640,6 +639,26 @@ def test_finance_tables():
640
639
assert finance .STK_MONEY_FLOW != None
641
640
with pytest .raises (Exception , message = 'finance 没有该表' ):
642
641
finance .STK
642
+ df = finance .run_query (query (finance .STK_STATUS_CHANGE ))
643
+ stk_status_change_columns = ["id" , "company_id" , "code" , "name" ,
644
+ "pub_date" , "change_date" , "change_reason" ,
645
+ "change_type_id" , "change_type" , "comments" ,
646
+ "public_status_id" , "public_status" ]
647
+ assert set (stk_status_change_columns ) - set (df .columns ) == set ()
648
+ df = finance .run_query (query (finance .STK_FIN_FORCAST ))
649
+ stk_fin_forcast_columns = ["id" , "company_id" , "code" , "name" ,
650
+ "end_date" , "report_type_id" , "report_type" ,
651
+ "pub_date" , "type_id" , "type" , "profit_min" ,
652
+ "profit_max" , "profit_last" , "profit_ratio_min" ,
653
+ "profit_ratio_max" , "content" ,]
654
+ assert set (stk_fin_forcast_columns ) - set (df .columns ) == set ()
655
+ df = finance .run_query (query (finance .STK_LIST ))
656
+ stk_list_columns = ["id" , "code" , "name" , "short_name" ,
657
+ "category" , "exchange" , "start_date" ,
658
+ "end_date" , "company_id" , "company_name" ,
659
+ "ipo_shares" , "book_price" , "par_value" ,
660
+ "state_id" , "state" , "status" ]
661
+ assert set (stk_list_columns ) - set (df .columns ) == set (["status" ])
643
662
644
663
645
664
def test_get_factor_values ():
@@ -835,4 +854,4 @@ def test_get_data():
835
854
def test_api_limit ():
836
855
alpha191 .alpha_001 ("000001.XSHE" , end_date = "2018-03-10" )
837
856
with pytest .raises (Exception ) as e :
838
- alpha191 .alpha_001 ("000001.XSHE" , end_date = "2018-03-10" )
857
+ alpha191 .alpha_001 ("000001.XSHE" , end_date = "2018-03-10" )
0 commit comments