Skip to content

Commit

Permalink
trading plan api
Browse files Browse the repository at this point in the history
  • Loading branch information
foolcage committed Apr 22, 2024
1 parent dacad1f commit 3c17234
Show file tree
Hide file tree
Showing 67 changed files with 35,629 additions and 171 deletions.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
13 changes: 13 additions & 0 deletions api-tests/trading/build_trading_plan.http
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
POST http://127.0.0.1:8090/api/trading/build_trading_plan
accept: application/json
Content-Type: application/json

{
"stock_id": "stock_sz_300133",
"trading_date": "2024-04-23",
"expected_open_pct": 0.02,
"buy_price": 6.9,
"sell_price": null,
"trading_reason": "主线",
"trading_signal_type": "open_long"
}
5 changes: 5 additions & 0 deletions api-tests/trading/get_current_trading_plan.http
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
GET http://127.0.0.1:8090/api/trading/get_current_trading_plan
accept: application/json



5 changes: 5 additions & 0 deletions api-tests/trading/get_future_trading_plan.http
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
GET http://127.0.0.1:8090/api/trading/get_future_trading_plan
accept: application/json



12 changes: 12 additions & 0 deletions api-tests/trading/query_trading_plan.http
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
POST http://127.0.0.1:8090/api/trading/query_trading_plan
accept: application/json
Content-Type: application/json

{
"time_range": {
"relative_time_range": {
"interval": -30,
"time_unit": "day"
}
}
}
2 changes: 1 addition & 1 deletion examples/data_runner/actor_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
StockActorSummary,
)
from zvt.informer import EmailInformer
from zvt.utils import next_date, current_date
from zvt.utils import date_time_by_interval, current_date

logger = logging.getLogger(__name__)

Expand Down
2 changes: 1 addition & 1 deletion examples/data_runner/kdata_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ def report_hot_topics():


@sched.scheduled_job("cron", hour=15, minute=30, day_of_week="mon-fri")
def record_stock_data(data_provider="em", entity_provider="em", sleeping_time=0.2):
def record_stock_data(data_provider="em", entity_provider="em", sleeping_time=0):
email_action = EmailInformer()
# 涨停数据
run_data_recorder(domain=LimitUpInfo, data_provider=None, force_update=False)
Expand Down
6 changes: 3 additions & 3 deletions examples/data_runner/trading_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
Stock1dHfqKdata,
)
from zvt.informer import EmailInformer
from zvt.utils import next_date, current_date, to_pd_timestamp
from zvt.utils import date_time_by_interval, current_date, to_pd_timestamp

logger = logging.getLogger(__name__)

Expand All @@ -33,12 +33,12 @@ def record_dragon_tiger(data_provider="em", entity_provider="em", sleeping_time=

email_action = EmailInformer()
# recent year
start_timestamp = next_date(current_date(), -400)
start_timestamp = date_time_by_interval(current_date(), -400)
# 最近一年牛x的营业部
players = get_big_players(start_timestamp=start_timestamp)

# 最近30天有牛x的营业部上榜的个股
recent_date = next_date(current_date(), -30)
recent_date = date_time_by_interval(current_date(), -30)
selected = []
for player in players:
filters = [
Expand Down
3 changes: 1 addition & 2 deletions examples/main_line_hidden_tags.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
[
"央企",
"中字头"
"次新股"
]
5 changes: 3 additions & 2 deletions examples/main_line_tags.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
[
"金融",
"房地产"
"智能机器",
"半导体",
"AI"
]
4 changes: 2 additions & 2 deletions examples/report_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
from zvt.contract.factor import Factor, TargetType
from zvt.domain import StockNews
from zvt.informer import EmailInformer
from zvt.utils import next_date
from zvt.utils import date_time_by_interval

logger = logging.getLogger("__name__")

Expand Down Expand Up @@ -154,7 +154,7 @@ def report_targets(
# 成交量
vol_df = get_top_volume_entities(
entity_type=entity_type,
start_timestamp=next_date(target_date, -30),
start_timestamp=date_time_by_interval(target_date, -30),
end_timestamp=target_date,
adjust_type=adjust_type,
pct=0.4,
Expand Down
6 changes: 3 additions & 3 deletions examples/research/dragon_and_tiger.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
# -*- coding: utf-8 -*-
from zvt.api.selector import get_big_players, get_player_success_rate
from zvt.domain import DragonAndTiger
from zvt.utils import next_date, current_date
from zvt.utils import date_time_by_interval, current_date

if __name__ == "__main__":
provider = "em"
DragonAndTiger.record_data(provider=provider)
end_timestamp = next_date(current_date(), -60)
end_timestamp = date_time_by_interval(current_date(), -60)
# recent year
start_timestamp = next_date(end_timestamp, -400)
start_timestamp = date_time_by_interval(end_timestamp, -400)
print(f"{start_timestamp} to {end_timestamp}")
players = get_big_players(start_timestamp=start_timestamp, end_timestamp=end_timestamp)
print(players)
Expand Down
4 changes: 2 additions & 2 deletions examples/research/top_dragon_tiger.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from zvt.contract.factor import Transformer, Accumulator
from zvt.domain import Stock
from zvt.factors import TechnicalFactor
from zvt.utils import pd_is_not_null, pre_month_start_date, next_date
from zvt.utils import pd_is_not_null, pre_month_start_date, date_time_by_interval


def top_dragon_and_tiger(data_provider="em", start_timestamp="2021-01-01", end_timestamp="2022-01-01"):
Expand All @@ -21,7 +21,7 @@ def top_dragon_and_tiger(data_provider="em", start_timestamp="2021-01-01", end_t
for entity_id in df.index[:30]:
players = get_players(
entity_id=entity_id,
start_timestamp=next_date(start_date, 15),
start_timestamp=date_time_by_interval(start_date, 15),
end_timestamp=end_timestamp,
provider=data_provider,
direction="in",
Expand Down
4 changes: 2 additions & 2 deletions examples/research/top_tags.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-
from zvt.api import get_top_performance_by_month
from zvt.domain import Stock1dHfqKdata
from zvt.utils import next_date, month_end_date, is_same_date
from zvt.utils import date_time_by_interval, month_end_date, is_same_date


# 每月涨幅前30,市值90%分布在100亿以下
Expand All @@ -26,7 +26,7 @@ def top_tags(data_provider="em", start_timestamp="2020-01-01", end_timestamp="20
if not kdata or kdata[0].turnover_rate == 0:
if is_same_date(query_timestamp, month_end_date(query_timestamp)):
break
query_timestamp = next_date(query_timestamp)
query_timestamp = date_time_by_interval(query_timestamp)
continue
cap = kdata[0].turnover / kdata[0].turnover_rate
break
Expand Down
Loading

0 comments on commit 3c17234

Please sign in to comment.