Skip to main content

Package for QMT

Project description

QMT自动交易及监控脚本

快速开始

账户分析(需配置Summary.py导出策略运行文件)

根据持仓/交割单备注,分析策略持仓,各策略盈亏,分标的盈亏情况。

初始化配置

import EzQmt as qmt

''' 策略运行文件目录, 外部转入转出资金情况(格式:[('20250124', -10000), ]),开始/结束时间,业绩比较基准 转债转股条款(格式:{转债代码:(股票代码,转股价)}),是否隐藏具体金额 策略合并, 资金账号 '''

acct0 = qmt.smy.account(summary_loc, outcash_list=outcash_list, start_date='20240101', end_date='20250101', benchmark=benchmark,
conv_stk={'113600.SH':('603978.SH', 10), '123096.SZ':('300078.SZ', 2.38)}, if_hide=True,
renamestrat={'junk':'策略1', 'basic':'策略1', 'special':'策略1', 'Sell':'策略0', '再平衡':'策略0'}, accnum=accnum)

acct0.get_acct()

acct0.get_pos()

acct0.get_deal()

acct0.cal_stratpos()

acct0.cal_contri()

acct0.strats

总账户

''' 总组合净值,月度收益,收益的标的贡献 '''

acct0.pnl()

image

image

acct0.pnl_monthly()

image

acct0.contri['all']

image

分策略

''' 策略仓位,各策略表现 '''

acct0.displaystrats_pos()

acct0.displaystrats_pnl()

image image ''' 查看具体某一策略 '''

strat = '策略0'

acct0.pnl(strat, benchmark=None)

acct0.contri[strat]

image

image

image

交易滑点分析(单边)

''' 需提供分钟线数据(开盘集合竞价时间戳为9:30,9:30~9:31时间戳为9:31) '''

deal_comm = acct0.cal_deal_comm(min_data, acct0.deal[acct0.deal['strat']=='策略1'].copy())

deal_comm[['comm_close', 'comm_open', 'comm_mco', 'comm_avg']].mean()

image

策略

Rebalance.py 仓位再平衡策略

自动拆单、挂撤单,将持仓市值占比调整至目标值。

输入为lude(禄得)格式的策略篮子文件,支持阈值调仓。

安装/配置

python库安装

pip install EzQmt

QMT 客户端 配置方法

1731993271869

在模型研究界面,使用策略文件中内容替换图示代码框中全部代码,调整代码中自定义参数,新建策略。 1731993357372 1731993389345

在模型交易界面,找到刚刚新建的策略,新建策略交易,选择自己的账号和账号类型,运行。

备注

-------------------- 联系作者 ---------------------

对于个性化程序交易策略代码需求,可以联系作者。 cde0c826807b3836377d0e13cf4bbf4

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

EzQmt-2.1.0.tar.gz (11.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

EzQmt-2.1.0-py3-none-any.whl (11.0 kB view details)

Uploaded Python 3

File details

Details for the file EzQmt-2.1.0.tar.gz.

File metadata

  • Download URL: EzQmt-2.1.0.tar.gz
  • Upload date:
  • Size: 11.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.10.9

File hashes

Hashes for EzQmt-2.1.0.tar.gz
Algorithm Hash digest
SHA256 a1e6c37774b44000d585c2ef36a9a08cdc4971e718adc67dda3a8ad0c7155b52
MD5 aa137dab6983b942eda4bf712846a510
BLAKE2b-256 7fae94aa03e0d9414bdb7910dfb9f92cc9601f74e679f5a97811cf464ee4f441

See more details on using hashes here.

File details

Details for the file EzQmt-2.1.0-py3-none-any.whl.

File metadata

  • Download URL: EzQmt-2.1.0-py3-none-any.whl
  • Upload date:
  • Size: 11.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.10.9

File hashes

Hashes for EzQmt-2.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 4a2b89abba04e0274186dbfa47bb67bd9088da8111032894c7af05c0c69e639e
MD5 63fe4cbc8af70244b02d685ff0f95275
BLAKE2b-256 d3429cb69bbfc59664a16d6d93d658b6351cbed2fa24c0025a03bd08ee69d091

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page