Skip to content

Commit

Permalink
Fix multiple levels kdata record_data issue
Browse files Browse the repository at this point in the history
  • Loading branch information
foolcage committed Dec 29, 2024
1 parent 4f14cda commit 3e12e39
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 7 deletions.
2 changes: 1 addition & 1 deletion .readthedocs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ version: 2
build:
os: "ubuntu-20.04"
tools:
python: "3.8"
python: "3.12"
python:
install:
- requirements: requirements/docs.txt
Expand Down
2 changes: 1 addition & 1 deletion requirements/docs.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
sphinx==4.4.0
sphinx_autodoc_typehints==1.15.3
rst2pdf==0.99
ipython==7.31.1
ipython==8.29.0
sphinx_rtd_theme==1.0.0
readthedocs-sphinx-search==0.1.1
5 changes: 3 additions & 2 deletions src/zvt/recorders/qmt/index/qmt_index_recorder.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,15 @@
from zvt.contract.api import df_to_db
from zvt.contract.recorder import FixedCycleDataRecorder
from zvt.contract.utils import evaluate_size_from_timestamp
from zvt.domain import Index, Index1mKdata
from zvt.domain import Index, IndexKdataCommon
from zvt.utils.pd_utils import pd_is_not_null
from zvt.utils.time_utils import TIME_FORMAT_DAY, TIME_FORMAT_MINUTE, current_date, to_time_str


class QmtIndexRecorder(FixedCycleDataRecorder):
provider = "qmt"
data_schema = Index1mKdata
# class level kdata schema should always use common
data_schema = IndexKdataCommon
entity_provider = "em"
entity_schema = Index
download_history_data = False
Expand Down
55 changes: 52 additions & 3 deletions src/zvt/recorders/sina/quotes/sina_index_kdata_recorder.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@
import pandas as pd
import requests

from zvt.api.kdata import generate_kdata_id
from zvt.api.kdata import generate_kdata_id, get_kdata_schema
from zvt.contract import IntervalLevel, AdjustType
from zvt.contract.recorder import FixedCycleDataRecorder
from zvt.domain import Index, Index1dKdata
from zvt.domain import Index, IndexKdataCommon
from zvt.utils.time_utils import get_year_quarters, is_same_date


Expand All @@ -16,9 +17,57 @@ class ChinaIndexDayKdataRecorder(FixedCycleDataRecorder):
entity_schema = Index

provider = "sina"
data_schema = Index1dKdata
data_schema = IndexKdataCommon
url = "http://vip.stock.finance.sina.com.cn/corp/go.php/vMS_MarketHistory/stockid/{}/type/S.phtml?year={}&jidu={}"

def __init__(
self,
force_update=True,
sleeping_time=10,
exchanges=None,
entity_id=None,
entity_ids=None,
code=None,
codes=None,
day_data=False,
entity_filters=None,
ignore_failed=True,
real_time=False,
fix_duplicate_way="ignore",
start_timestamp=None,
end_timestamp=None,
level=IntervalLevel.LEVEL_1DAY,
kdata_use_begin_time=False,
one_day_trading_minutes=24 * 60,
return_unfinished=False,
) -> None:
level = IntervalLevel(level)
self.adjust_type = AdjustType.qfq
self.entity_type = self.entity_schema.__name__.lower()

self.data_schema = get_kdata_schema(entity_type=self.entity_type, level=level, adjust_type=self.adjust_type)

super().__init__(
force_update,
sleeping_time,
exchanges,
entity_id,
entity_ids,
code,
codes,
day_data,
entity_filters,
ignore_failed,
real_time,
fix_duplicate_way,
start_timestamp,
end_timestamp,
level,
kdata_use_begin_time,
one_day_trading_minutes,
return_unfinished,
)

def get_data_map(self):
return {}

Expand Down

0 comments on commit 3e12e39

Please sign in to comment.