Monday, March 4, 2024

miniQMT自动交易

 https://blog.csdn.net/u010214511/article/details/130275793

http://dict.thinktrader.net/nativeApi/code_examples.html

1. Install Python 3.11.8

Need install Windows installer (64-bit) instead of Windows installer (ARM64) on Parallel Desktop (ARM) M2 chip

2. Install xtquant: pip install quant1x-xtquant

3. 

https://download.gjzq.com.cn/gjty/organ/gjzqqmt.rar

登录QMT极简模式,连接QMT客户端:

import random

from xtquant.xttrader import XtQuantTrader

path = r'C:\国金证券QMT交易端\userdata_mini'

session_id = int(random.randint(100000,999999))

xt_trader = XtQuantTrader(path, session_id)

xt_trader.start()

connect_result=xt_trader.connect()

print(connect_result)

if connect_result == 0:

print('Connected successfully!')

订阅账户:

acc = StockAccount('888XXXXXXX')

subscribe_result=xt_trader.subscribe(acc)

print(subscribe_result)

下单:

stock_code='000429.SZ'

order_id=xt_trader.order_stock(acc,stock_code,xtconstant.STOCK_BUY,100,xtconstant.FIX_PRICE,9.3)

xt_trader.cancel_order_stock(acc,1082384002)


    asset = xt_trader.query_stock_asset(acc)

    if asset:

        print("asset:")

        print("cash {0}".format(asset.cash))


run API auspix_detail takes 127 ms to PD

while it takes more thn 600 ms to Tencent Cloud

腾讯轻量云服务器以下规格足够用了:

腾讯云服务器可以随时销毁退钱,退钱的比例很好,几乎是全款

通用型
  • CPU - 2核 内存 - 4GB
  • 系统盘 - SSD云硬盘 90GB
  • 流量包 - 800GB/月(带宽:6Mbps)

C:\git\QMT>pip config get global.index-url
https://pypi.tuna.tsinghua.edu.cn/simple

To set a China-based mirror for faster downloads, you can change it as follows:

pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple

No comments:

Post a Comment