Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
Former-commit-id: 82be58c
  • Loading branch information
foolcage committed Jan 14, 2020
1 parent 0b83f56 commit 0622e99
Show file tree
Hide file tree
Showing 51 changed files with 182 additions and 138 deletions.
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
zvdata == 1.1.3
zvdata == 1.1.4
requests == 2.20.1
SQLAlchemy == 1.2.14
pandas == 0.24.2
Expand Down
22 changes: 11 additions & 11 deletions tests/recorders/joinquant/test_quote_recorder.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,48 +6,48 @@
from zvdata import IntervalLevel

from zvt.settings import SAMPLE_STOCK_CODES
from zvt.recorders.joinquant.quotes.jq_stock_kdata_recorder import ChinaStockKdataRecorder
from zvt.recorders.joinquant.quotes.jq_stock_kdata_recorder import JqChinaStockKdataRecorder


def test_1wk_kdata_recorder():
recorder = ChinaStockKdataRecorder(codes=SAMPLE_STOCK_CODES, sleeping_time=0, level=IntervalLevel.LEVEL_1WEEK,
real_time=False)
recorder = JqChinaStockKdataRecorder(codes=SAMPLE_STOCK_CODES, sleeping_time=0, level=IntervalLevel.LEVEL_1WEEK,
real_time=False)
try:
recorder.run()
except:
assert False


def test_1mon_kdata_recorder():
recorder = ChinaStockKdataRecorder(codes=SAMPLE_STOCK_CODES, sleeping_time=0, level=IntervalLevel.LEVEL_1MON,
real_time=False)
recorder = JqChinaStockKdataRecorder(codes=SAMPLE_STOCK_CODES, sleeping_time=0, level=IntervalLevel.LEVEL_1MON,
real_time=False)
try:
recorder.run()
except:
assert False


def test_1d_kdata_recorder():
recorder = ChinaStockKdataRecorder(codes=SAMPLE_STOCK_CODES, sleeping_time=0, level=IntervalLevel.LEVEL_1DAY,
real_time=False)
recorder = JqChinaStockKdataRecorder(codes=SAMPLE_STOCK_CODES, sleeping_time=0, level=IntervalLevel.LEVEL_1DAY,
real_time=False)
try:
recorder.run()
except:
assert False


def test_1h_kdata_recorder():
recorder = ChinaStockKdataRecorder(codes=['000338'], sleeping_time=0, level=IntervalLevel.LEVEL_1HOUR,
real_time=False, start_timestamp='2019-01-01')
recorder = JqChinaStockKdataRecorder(codes=['000338'], sleeping_time=0, level=IntervalLevel.LEVEL_1HOUR,
real_time=False, start_timestamp='2019-01-01')
try:
recorder.run()
except:
assert False


def test_5m_kdata_recorder():
recorder = ChinaStockKdataRecorder(codes=['000338'], sleeping_time=0, level=IntervalLevel.LEVEL_5MIN,
real_time=False, start_timestamp='2019-01-01')
recorder = JqChinaStockKdataRecorder(codes=['000338'], sleeping_time=0, level=IntervalLevel.LEVEL_5MIN,
real_time=False, start_timestamp='2019-01-01')
try:
recorder.run()
except:
Expand Down
2 changes: 1 addition & 1 deletion zvt/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ def init_env(zvt_home: str) -> None:
pprint.pprint(zvt_env)


if os.getenv('TESTING_ZVT'):
if True:
init_env(zvt_home=ZVT_TEST_HOME)

# init the sample data if need
Expand Down
25 changes: 6 additions & 19 deletions zvt/recorders/eastmoney/__init__.py
Original file line number Diff line number Diff line change
@@ -1,20 +1,7 @@
# -*- coding: utf-8 -*-
from .dividend_financing.dividend_detail_recorder import DividendDetailRecorder
from .dividend_financing.dividend_financing_recorder import DividendFinancingRecorder
from .dividend_financing.rights_issue_detail_recorder import RightsIssueDetailRecorder
from .dividend_financing.spo_detail_recorder import SPODetailRecorder
from .finance.china_stock_balance_sheet_recorder import ChinaStockBalanceSheetRecorder
from .finance.china_stock_cash_flow_recorder import ChinaStockCashFlowRecorder
from .finance.china_stock_finance_factor_recorder import ChinaStockFinanceFactorRecorder
from .finance.china_stock_income_statement_recorder import ChinaStockIncomeStatementRecorder
from .holder.top_ten_holder_recorder import TopTenHolderRecorder
from .holder.top_ten_tradable_holder_recorder import TopTenTradableHolderRecorder
from .meta.china_stock_category_recorder import ChinaStockCategoryRecorder
from .meta.china_stock_meta_recorder import ChinaStockMetaRecorder
from .trading.holder_trading_recorder import HolderTradingRecorder
from .trading.manager_trading_recorder import ManagerTradingRecorder

__all__ = ['ChinaStockBalanceSheetRecorder', 'ChinaStockIncomeStatementRecorder', 'ChinaStockCashFlowRecorder',
'ChinaStockFinanceFactorRecorder', 'ChinaStockCategoryRecorder', 'ChinaStockMetaRecorder',
'DividendFinancingRecorder', 'RightsIssueDetailRecorder', 'DividendDetailRecorder', 'SPODetailRecorder',
'TopTenHolderRecorder', 'TopTenTradableHolderRecorder', 'HolderTradingRecorder', 'ManagerTradingRecorder']
from zvt.recorders.eastmoney.dividend_financing import *
from zvt.recorders.eastmoney.finance import *
from zvt.recorders.eastmoney.holder import *
from zvt.recorders.eastmoney.meta import *
from zvt.recorders.eastmoney.quotes import *
from zvt.recorders.eastmoney.trading import *
6 changes: 3 additions & 3 deletions zvt/recorders/eastmoney/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ def record(self, entity_item, start, end, size, timestamps):


class EastmoneyTimestampsDataRecorder(BaseEastmoneyRecorder, TimestampsDataRecorder):
entity_provider = 'eastmoney'
entity_provider = 'joinquant'
entity_schema = Stock

provider = 'eastmoney'
Expand All @@ -163,7 +163,7 @@ def init_timestamps(self, entity):


class EastmoneyPageabeDataRecorder(BaseEastmoneyRecorder, TimeSeriesDataRecorder):
entity_provider = 'eastmoney'
entity_provider = 'joinquant'
entity_schema = Stock

provider = 'eastmoney'
Expand Down Expand Up @@ -205,7 +205,7 @@ def generate_request_param(self, security_item, start, end, size, timestamp):


class EastmoneyMoreDataRecorder(BaseEastmoneyRecorder, TimeSeriesDataRecorder):
entity_provider = 'eastmoney'
entity_provider = 'joinquant'
entity_schema = Stock

provider = 'eastmoney'
Expand Down
6 changes: 5 additions & 1 deletion zvt/recorders/eastmoney/dividend_financing/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@
# -*- coding: utf-8 -*-
# -*- coding: utf-8 -*-
from zvt.recorders.eastmoney.dividend_financing.dividend_detail_recorder import *
from zvt.recorders.eastmoney.dividend_financing.dividend_financing_recorder import *
from zvt.recorders.eastmoney.dividend_financing.rights_issue_detail_recorder import *
from zvt.recorders.eastmoney.dividend_financing.spo_detail_recorder import *
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
# -*- coding: utf-8 -*-
from zvdata.utils.time_utils import to_pd_timestamp
from zvt.domain import DividendDetail

from zvt.recorders.eastmoney.common import EastmoneyPageabeDataRecorder
from zvdata.utils.time_utils import to_pd_timestamp


class DividendDetailRecorder(EastmoneyPageabeDataRecorder):
Expand All @@ -28,6 +27,8 @@ def get_data_map(self):
}


__all__ = ['DividendDetailRecorder']

if __name__ == '__main__':
# init_log('dividend_detail.log')

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# -*- coding: utf-8 -*-
from zvdata.utils.utils import second_item_to_float
from zvt.api.api import get_dividend_financing
from zvt.domain.fundamental.dividend_financing import DividendFinancing
from zvt.recorders.eastmoney.common import EastmoneyPageabeDataRecorder
from zvdata.utils.utils import second_item_to_float


class DividendFinancingRecorder(EastmoneyPageabeDataRecorder):
Expand Down Expand Up @@ -47,6 +47,8 @@ def on_finish(self):
super().on_finish()


__all__ = ['DividendFinancingRecorder']

if __name__ == '__main__':
# init_log('dividend_financing.log')

Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
# -*- coding: utf-8 -*-
from zvdata.utils.pd_utils import pd_is_not_null
from zvdata.utils.time_utils import now_pd_timestamp
from zvdata.utils.utils import to_float
from zvt.api.api import get_dividend_financing, get_rights_issue_detail
from zvt.domain import RightsIssueDetail, DividendFinancing

from zvt.recorders.eastmoney.common import EastmoneyPageabeDataRecorder
from zvt.settings import SAMPLE_STOCK_CODES
from zvdata.utils.pd_utils import pd_is_not_null
from zvdata.utils.time_utils import now_pd_timestamp


class RightsIssueDetailRecorder(EastmoneyPageabeDataRecorder):
Expand Down Expand Up @@ -48,6 +47,8 @@ def on_finish(self):
super().on_finish()


__all__ = ['RightsIssueDetailRecorder']

if __name__ == '__main__':
# init_log('rights_issue.log')

Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
# -*- coding: utf-8 -*-
from zvdata.utils.pd_utils import pd_is_not_null
from zvdata.utils.time_utils import now_pd_timestamp
from zvdata.utils.utils import to_float
from zvt.api.api import get_dividend_financing, get_spo_detail
from zvt.domain import SpoDetail, DividendFinancing

from zvt.recorders.eastmoney.common import EastmoneyPageabeDataRecorder
from zvdata.utils.pd_utils import pd_is_not_null
from zvdata.utils.time_utils import now_pd_timestamp


class SPODetailRecorder(EastmoneyPageabeDataRecorder):
Expand Down Expand Up @@ -45,6 +44,8 @@ def on_finish(self):
super().on_finish()


__all__ = ['SPODetailRecorder']

if __name__ == '__main__':
# init_log('spo_detail.log')

Expand Down
6 changes: 5 additions & 1 deletion zvt/recorders/eastmoney/finance/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@
# -*- coding: utf-8 -*-
# -*- coding: utf-8 -*-
from zvt.recorders.eastmoney.finance.china_stock_balance_sheet_recorder import *
from zvt.recorders.eastmoney.finance.china_stock_cash_flow_recorder import *
from zvt.recorders.eastmoney.finance.china_stock_finance_factor_recorder import *
from zvt.recorders.eastmoney.finance.china_stock_income_statement_recorder import *
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from zvt.domain import FinanceFactor
from zvt.recorders.eastmoney.common import company_type_flag, get_fc, EastmoneyTimestampsDataRecorder, \
call_eastmoney_api, get_from_path_fields
from zvt.recorders.joinquant import to_jq_entity_id
from zvt.recorders.joinquant.common import to_jq_entity_id


class BaseChinaStockFinanceRecorder(EastmoneyTimestampsDataRecorder):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -445,6 +445,8 @@ def get_data_map(self):
return balance_sheet_map


__all__ = ['ChinaStockBalanceSheetRecorder']

if __name__ == '__main__':
# init_log('blance_sheet.log')
recorder = ChinaStockBalanceSheetRecorder(codes=['002572'])
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# -*- coding: utf-8 -*-
from zvdata.utils.time_utils import to_pd_timestamp
from zvdata.utils.utils import add_func_to_value, first_item_to_float
from zvt.api.common import to_report_period_type
from zvt.domain import CashFlowStatement
from zvt.recorders.eastmoney.finance.base_china_stock_finance_recorder import BaseChinaStockFinanceRecorder
from zvdata.utils.time_utils import to_pd_timestamp
from zvdata.utils.utils import add_func_to_value, first_item_to_float

cash_flow_map = {
# 经营活动产生的现金流量
Expand Down Expand Up @@ -209,6 +209,8 @@ def get_data_map(self):
return cash_flow_map


__all__ = ['ChinaStockCashFlowRecorder']

if __name__ == '__main__':
# init_log('cash_flow.log')
recorder = ChinaStockCashFlowRecorder(codes=['002572'])
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# -*- coding: utf-8 -*-
from zvdata.utils.time_utils import to_pd_timestamp
from zvdata.utils.utils import add_func_to_value, to_float
from zvt.api.common import to_report_period_type
from zvt.domain import FinanceFactor
from zvt.recorders.eastmoney.finance.base_china_stock_finance_recorder import BaseChinaStockFinanceRecorder
from zvdata.utils.time_utils import to_pd_timestamp

finance_factor_map = {
# 基本每股收益(元)
Expand Down Expand Up @@ -153,6 +153,8 @@ def get_data_map(self):
return finance_factor_map


__all__ = ['ChinaStockFinanceFactorRecorder']

if __name__ == '__main__':
# init_log('finance_factor.log')
recorder = ChinaStockFinanceFactorRecorder(codes=['000001'])
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# -*- coding: utf-8 -*-
from zvdata.utils.time_utils import to_pd_timestamp
from zvdata.utils.utils import add_func_to_value, first_item_to_float
from zvt.api.common import to_report_period_type
from zvt.domain import IncomeStatement
from zvt.recorders.eastmoney.finance.base_china_stock_finance_recorder import BaseChinaStockFinanceRecorder
from zvdata.utils.time_utils import to_pd_timestamp
from zvdata.utils.utils import add_func_to_value, first_item_to_float

income_statement_map = {
# 营业总收入
Expand Down Expand Up @@ -171,6 +171,8 @@ def get_data_map(self):
return income_statement_map


__all__ = ['ChinaStockIncomeStatementRecorder']

if __name__ == '__main__':
# init_log('income_statement.log')
recorder = ChinaStockIncomeStatementRecorder(codes=['002572'])
Expand Down
4 changes: 3 additions & 1 deletion zvt/recorders/eastmoney/holder/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
# -*- coding: utf-8 -*-
# -*- coding: utf-8 -*-
from zvt.recorders.eastmoney.holder.top_ten_holder_recorder import *
from zvt.recorders.eastmoney.holder.top_ten_tradable_holder_recorder import *
4 changes: 3 additions & 1 deletion zvt/recorders/eastmoney/holder/top_ten_holder_recorder.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# -*- coding: utf-8 -*-
from zvdata.utils.time_utils import to_time_str, to_pd_timestamp
from zvdata.utils.utils import to_float
from zvt.api.common import to_report_period_type
from zvt.domain.misc.holder import TopTenHolder
from zvt.recorders.eastmoney.common import EastmoneyTimestampsDataRecorder, get_fc
from zvdata.utils.time_utils import to_time_str, to_pd_timestamp


class TopTenHolderRecorder(EastmoneyTimestampsDataRecorder):
Expand Down Expand Up @@ -48,6 +48,8 @@ def generate_domain_id(self, entity, original_data):
return the_id


__all__ = ['TopTenHolder']

if __name__ == '__main__':
# init_log('top_ten_holder.log')

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ class TopTenTradableHolderRecorder(TopTenHolderRecorder):
timestamp_path_fields = ['BaoGaoQi']


__all__ = ['TopTenTradableHolderRecorder']

if __name__ == '__main__':
# init_log('top_ten_tradable_holder.log')

Expand Down
4 changes: 3 additions & 1 deletion zvt/recorders/eastmoney/meta/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
# -*- coding: utf-8 -*-
# -*- coding: utf-8 -*-
from zvt.recorders.eastmoney.meta.china_stock_category_recorder import *
from zvt.recorders.eastmoney.meta.china_stock_meta_recorder import *
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@

from zvdata.api import df_to_db
from zvdata.recorder import Recorder
from zvdata.utils.utils import json_callback_param
from zvt.api.common import china_stock_code_to_id
from zvt.api.quote import get_entities
from zvt.domain import BlockStock, BlockCategory
from zvt.domain.meta.stock_meta import Index
from zvdata.utils.utils import json_callback_param


class ChinaStockCategoryRecorder(Recorder):
Expand Down Expand Up @@ -80,6 +80,8 @@ def run(self):
self.sleep()


__all__ = ['ChinaStockCategoryRecorder']

if __name__ == '__main__':
# init_log('china_stock_category.log')

Expand Down
Loading

0 comments on commit 0622e99

Please sign in to comment.