返回列表 发布新帖

收盘前逆回购示例

1412 2
发表于 2023-12-25 16:44:23 | 显示全部楼层 阅读模式
  1. #coding:gbk
  2. import datetime

  3. '''
  4. 14点55 撤回未成交委托
  5. 14点56 卖出国债逆回购1天期 204001.SH
  6. '''

  7. ordered, canceled, pre_date = False, False, ''


  8. def init(C):
  9.         C.run_time('f', "5nSecond", "2020-01-01 00:00:00", "SH")


  10. def f(C):
  11.         global ordered, pre_date, canceled
  12.         now = datetime.datetime.now()
  13.         now_date = now.strftime("%Y%m%d")
  14.         now_time = now.strftime("%H%M")
  15.         #每天更新记录变量
  16.         if now_date != pre_date:
  17.                 ordered, canceled, pre_date = False, False, now_date
  18.         #撤单
  19.         if now_time >= '1455' and not canceled:
  20.                 orders = get_trade_detail_data(account, 'stock', 'order')
  21.                 for order in orders:
  22.                         if can_cancel_order(order.m_strOrderSysID, account,'stock'):
  23.                                 print('cancel', order.m_strOrderSysID, order.m_strInstrumentID + '.' + order.m_strExchangeID, order.m_strInstrumentName, order.m_strRemark)
  24.                                 cancel(order.m_strOrderSysID, account, 'stock', C)
  25.                 canceled = True
  26.         #卖出逆回购
  27.         if now_time >= '1456' and not ordered:
  28.                 acct = get_trade_detail_data(account,'stock','account')
  29.                 available_money = int(acct[0].m_dAvailable)
  30.                 vol = int(available_money / 1000) * 10
  31.                 msg = f"{now_date} {now_time} {account} {accountType} 可用资金 {available_money} 卖出 {vol} 单位逆回购"
  32.                 print(msg)
  33.                 if vol >= 10:
  34.                         passorder(24, 1101, account, '204001.SH', 14, -1, vol, '尾盘逆回购', 2, msg, C)
  35.                 ordered = True
复制代码


评论2

Liwu楼主
发表于 2023-12-25 16:45:02 | 显示全部楼层
account, accountType 变量为模型交易界面添加策略时, 选择的账号/账号类型.
朱勃宇
发表于 2023-12-25 17:40:54 | 显示全部楼层
666

回复

您需要登录后才可以回帖 登录 | 立即注册

客服专线

400-080-8112

用思考的速度交易,用真诚的态度合作,我们是认真的!
  • 关注公众号
  • 添加微信客服
Copyright © 2001-2025 迅投QMT社区 版权所有 All Rights Reserved. 京ICP备2025122616号-3
关灯 快速发帖
扫一扫添加微信客服
QQ客服返回顶部
快速回复 返回顶部 返回列表