-
Notifications
You must be signed in to change notification settings - Fork 864
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
1)add dragon and tiger data 2)add currency entity and kdata 3)improve…
… compare intent
- Loading branch information
Showing
25 changed files
with
660 additions
and
105 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
# -*- coding: utf-8 -*- | ||
import logging | ||
|
||
from apscheduler.schedulers.background import BackgroundScheduler | ||
|
||
from examples.recorder_utils import run_data_recorder | ||
from zvt import init_log | ||
from zvt.domain import ( | ||
DragonAndTiger, | ||
) | ||
|
||
logger = logging.getLogger(__name__) | ||
|
||
sched = BackgroundScheduler() | ||
|
||
|
||
@sched.scheduled_job("cron", hour=18, minute=00, day_of_week="mon-fri") | ||
def record_dragon_tiger(data_provider="em", entity_provider="em", sleeping_time=2): | ||
# 龙虎榜数据 | ||
run_data_recorder( | ||
domain=DragonAndTiger, | ||
data_provider=data_provider, | ||
entity_provider=entity_provider, | ||
day_data=True, | ||
sleeping_time=sleeping_time, | ||
) | ||
|
||
|
||
if __name__ == "__main__": | ||
init_log("trading_runner.log") | ||
|
||
record_dragon_tiger() | ||
|
||
sched.start() | ||
|
||
sched._thread.join() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,65 @@ | ||
# -*- coding: utf-8 -*- | ||
def compare_kline(): | ||
from zvt.api.intent import compare | ||
from zvt.domain import Index, Indexus, Index1dKdata, Indexus1dKdata | ||
from zvt.api.intent import compare | ||
from zvt.domain import Indexus1dKdata, Index, Indexus, Index1dKdata | ||
from zvt.domain import TreasuryYield | ||
|
||
|
||
def china_vs_us_stock(): | ||
# 上证,道琼斯指数 | ||
Index.record_data() | ||
Indexus.record_data() | ||
Index1dKdata.record_data(entity_id="index_sh_000001") | ||
Indexus1dKdata.record_data(entity_id="indexus_us_SPX") | ||
compare(entity_ids=["index_sh_000001", "indexus_us_SPX"], start_timestamp="2000-01-01", scale_value=100) | ||
|
||
|
||
def us_yield_and_stock(): | ||
# 美债收益率,道琼斯指数 | ||
entity_ids = ["country_galaxy_US", "indexus_us_SPX"] | ||
compare( | ||
entity_ids=entity_ids, | ||
start_timestamp="1990-01-01", | ||
scale_value=None, | ||
schema_map_columns={TreasuryYield: ["yield_2", "yield_5"], Indexus1dKdata: ["close"]}, | ||
) | ||
|
||
|
||
def commodity_and_stock(): | ||
# 江西铜业,沪铜 | ||
entity_ids = ["stock_sh_600362", "future_shfe_CU"] | ||
compare( | ||
entity_ids=entity_ids, | ||
start_timestamp="2005-01-01", | ||
scale_value=100, | ||
) | ||
|
||
|
||
def compare_metal(): | ||
# 沪铜,沪铝,螺纹钢 | ||
entity_ids = ["future_shfe_CU", "future_shfe_AL", "future_shfe_RB"] | ||
compare( | ||
entity_ids=entity_ids, | ||
start_timestamp="2009-04-01", | ||
scale_value=100, | ||
) | ||
|
||
|
||
compare(entity_ids=["index_sh_000001", "indexus_us_SPX"]) | ||
def compare_udi_and_stock(): | ||
# 美股指数 | ||
# Indexus.record_data() | ||
entity_ids = ["indexus_us_NDX", "indexus_us_SPX", "indexus_us_UDI"] | ||
# Indexus1dKdata.record_data(entity_ids=entity_ids, sleeping_time=0) | ||
compare( | ||
entity_ids=entity_ids, | ||
start_timestamp="2015-01-01", | ||
scale_value=100, | ||
schema_map_columns={Indexus1dKdata: ["close"]}, | ||
) | ||
|
||
|
||
if __name__ == "__main__": | ||
compare_kline() | ||
# compare_kline() | ||
# us_yield_and_stock() | ||
# commodity_and_stock() | ||
# compare_metal() | ||
compare_udi_and_stock() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.