dev 6
This commit is contained in:
@@ -18,7 +18,7 @@ if PROJECT_ROOT not in sys.path:
|
||||
|
||||
from sdk import APIError, Client
|
||||
from strategy.trend.boot import StartTrend
|
||||
|
||||
from strategy.ipo import AutoBuyIpo
|
||||
|
||||
@dataclass(frozen=True, slots=True)
|
||||
class StrategyDefinition:
|
||||
@@ -124,6 +124,9 @@ def main() -> int:
|
||||
configure_logging(config.global_config.qmt_data_dir)
|
||||
wait_for_qmt_api()
|
||||
|
||||
# 自动打新
|
||||
AutoBuyIpo()
|
||||
|
||||
STRATEGIES[config.account_config.strategy].start_strategy()
|
||||
return 0
|
||||
except (OSError, yaml.YAMLError, ValueError, RuntimeError, KeyError) as exc:
|
||||
|
||||
@@ -7,7 +7,7 @@ ORDER_TYPE_VOLUME, PR_TYPE_LATEST, QUICK_TRADE_NOW = 1101, 5, 2
|
||||
class TradeMixin:
|
||||
account_type: str
|
||||
|
||||
def passorder(self, op_type, stock, volume, order_type=0, pr_type=0, price=0, quick_trade=0, strategy_name=""):
|
||||
def passorder(self, op_type, stock, volume, order_type=0, pr_type=0, price=0.0, quick_trade=0, strategy_name=""):
|
||||
body = {"opType": op_type, "stock": stock, "price": price, "volume": volume}
|
||||
for key, value in (("orderType", order_type), ("prType", pr_type), ("quickTrade", quick_trade), ("strategyName", strategy_name)):
|
||||
if value: body[key] = value
|
||||
|
||||
22
py-client/strategy/ipo/boot.py
Normal file
22
py-client/strategy/ipo/boot.py
Normal file
@@ -0,0 +1,22 @@
|
||||
from sdk import Client
|
||||
import config
|
||||
|
||||
def AutoBuyIpo() -> None:
|
||||
client = Client(
|
||||
config.global_config.qmt_base_url,
|
||||
config.global_config.qmt_token,
|
||||
config.HTTP_TIMEOUT,
|
||||
)
|
||||
|
||||
result = client.ipo_data("STOCK")
|
||||
for stock in result:
|
||||
ipo_price = result[stock]['issuePrice'] # 发行价
|
||||
maxPurchaseNum = result[stock]['maxPurchaseNum'] # 可申购额度
|
||||
client.passorder(
|
||||
op_type=23,
|
||||
stock=stock,
|
||||
volume=maxPurchaseNum,
|
||||
pr_type=11,
|
||||
price=ipo_price,
|
||||
strategy_name="新股申购",
|
||||
)
|
||||
Binary file not shown.
Binary file not shown.
@@ -84,7 +84,10 @@ def StartTrend() -> None:
|
||||
storeState.reconcile(positions, orders, deals)
|
||||
|
||||
# 获取本策略的信号开仓数据
|
||||
signals = init_signals(config.global_config,["morning","tail","arbitrage"])
|
||||
signals = init_signals(
|
||||
config.global_config,
|
||||
config.account_config.signal_allow,
|
||||
)
|
||||
run = Runtime(
|
||||
client=client,
|
||||
global_cfg=config.global_config,
|
||||
@@ -182,11 +185,3 @@ def RunOnce(run: Runtime, signals) -> None:
|
||||
|
||||
# 8. 持仓计算。当前 Go 版本的 managePositions 为空,保留扩展入口。
|
||||
manage_positions(run, ticks, positions, market_ok,assets.available)
|
||||
|
||||
|
||||
def SignalFilter(signals, allowed_names):
|
||||
"""只保留账户配置明确允许使用的信号。"""
|
||||
if not allowed_names:
|
||||
return []
|
||||
allowed = set(allowed_names)
|
||||
return [signal for signal in signals if signal.signal_key in allowed]
|
||||
|
||||
Binary file not shown.
Reference in New Issue
Block a user