id: a1341a69e9d0430a8914503c5e660a2d
parent_id: 
item_type: 1
item_id: 7352af4d410b42d78884459b93d8b7ea
item_updated_time: 1764365031177
title_diff: "[{\"diffs\":[[1,\"量化入门QMT软件使用（05）-逐K运行\"]],\"start1\":0,\"start2\":0,\"length1\":0,\"length2\":20}]"
body_diff: "[{\"diffs\":[[1,\"<html>\\\r\\\n<head>\\\r\\\n  <title>量化入门|QMT软件使用（05）-逐K运行</title>\\\r\\\n  <basefont face=\\\"微软雅黑\\\" size=\\\"2\\\" />\\\r\\\n  <meta http-equiv=\\\"Content-Type\\\" content=\\\"text/html;charset=utf-8\\\" />\\\r\\\n  <meta name=\\\"exporter-version\\\" content=\\\"YXBJ Windows/608924 (zh-CN, DDL); Windows/10.0.0 (Win64); EDAMVersion=V2;\\\"/>\\\r\\\n  <meta name=\\\"content-class\\\" content=\\\"yinxiang.peso.superNote\\\"/>\\\r\\\n  <meta name=\\\"application-data:yinxiang.noteLayout\\\" content=\\\"{\\\"lineSpace\\\":\\\"recommend\\\",\\\"paragraphSpace\\\":\\\"recommend\\\"}\\\"/>\\\r\\\n  <style>\\\r\\\n\\tbody, td {\\\r\\\n\\t  font-family: 微软雅黑;\\\r\\\n\\t  font-size: 12pt;\\\r\\\n\\t}\\\r\\\n  </style>\\\r\\\n</head>\\\r\\\n<body>\\\r\\\n<a name=\\\"47190\\\"></a>\\\r\\\n<h1>量化入门|QMT软件使用（05）-逐K运行</h1>\\\r\\\n\\\r\\\n<div><span style=\\\"\\\"><div style=\\\"max-width: 700px;\\\"><p></p><div style=\\\"--en-blockquote: true; box-sizing: border-box; border-left: 3px solid #b4c0cc; background-position: initial initial; background-repeat: initial initial;\\\"><div>原文链接: <a href=\\\"https://mp.weixin.qq.com/s?__biz=MzkzOTg3NTM4OQ==&amp;mid=2247483777&amp;idx=1&amp;sn=0ba679597bf324e82d7ec70499fcede5&amp;chksm=c32e7998748f9bd0223afe6120d136c3e460dadadf2a759087d179b344ed202439f590ad6615&amp;mpshare=1&amp;scene=1&amp;srcid=0820SzKZauMJS1gCo4xJLa5U&amp;sharer_shareinfo=3c3f089eb69bc0f7c9b216694995bb4b&amp;sharer_shareinfo_first=3c3f089eb69bc0f7c9b216694995bb4b#rd\\\"><span>https://mp.weixin.qq.com/s?__biz=MzkzOTg3NTM4OQ==&amp;mid=224748...</span></a></div></div><p></p><div style=\\\"\\\"><div><div><div><span style=\\\"\\\">原创</span><span> 量化小九 </span><span><a style=\\\"\\\"> 量化小九 </a></span><span><em></em></span></div><div style=\\\"\\\"><p style=\\\"\\\"><strong><span>计算机盯盘系统通过实时扫描机制彻底替代人工监控！</span></strong><span><br/></span></p><p style=\\\"\\\"><span>传统股民依赖分时图与K线图进行决策，但受限于人类神经反应速度，难以捕捉3秒刷新周期内的细微波动，往往滞后于突变行情。</span></p><p style=\\\"\\\"><span>而量化系统以固定时间切片（如3秒/次）完成全市场扫描，同步执行策略计算与信号响应，实现毫秒级决策闭环。</span></p><p style=\\\"\\\"><span>这种从</span><strong><span>认知延迟</span></strong><span>到</span><strong><span>机器预判</span></strong><span>的跨越，使监控效率提升至少两个数量级。</span></p><p style=\\\"\\\"><span><br/></span></p><div style=\\\"text-align: center;\\\"><img src=\\\"量化入门QMT软件使用（05）-逐K运行_files/640.jpg\\\" type=\\\"image/jpeg\\\" data-filename=\\\"640.jpg\\\" style=\\\"--en-marks: %7B%22align%22%3A%22center%22%7D; width: auto; height: 528px;\\\" width=\\\"auto\\\"/></div><p style=\\\"\\\"><span><br/></span></p><p style=\\\"-webkit-tap-highlight-color: transparent; outline: 0; max-width: 100%; box-sizing: border-box; overflow-wrap: break-word; clear: both; min-height: 1em;\\\"><span style=\\\"-webkit-tap-highlight-color: transparent; outline: 0px; max-width: 100%; box-sizing: border-box; overflow-wrap: break-word; font-weight: bold;\\\"><span style=\\\"-webkit-tap-highlight-color: transparent; outline: 0px; max-width: 100%; box-sizing: border-box; overflow-wrap: break-word;\\\"><span style=\\\"-webkit-tap-highlight-color: transparent; outline: 0px; max-width: 100%; box-sizing: border-box; overflow-wrap: break-word;\\\">这种盯盘方式也称为逐K运行，QMT使用了handlebar方法：</span></span></span></p><p style=\\\"-webkit-tap-highlight-color: transparent; outline: 0; max-width: 100%; box-sizing: border-box; overflow-wrap: break-word; clear: both; min-height: 1em;\\\"><span style=\\\"-webkit-tap-highlight-color: transparent; outline: 0px; max-width: 100%; box-sizing: border-box; overflow-wrap: break-word;\\\"><span style=\\\"-webkit-tap-highlight-color: transparent; outline: 0px; max-width: 100%; box-sizing: border-box; overflow-wrap: break-word;\\\"><span style=\\\"-webkit-tap-highlight-color: transparent; outline: 0px; max-width: 100%; box-sizing: border-box; overflow-wrap: break-word;\\\">我们以挂单买入的示例，来理解逐K运行：</span></span></span></p><p style=\\\"-webkit-tap-highlight-color: transparent; outline: 0; max-width: 100%; box-sizing: border-box; overflow-wrap: break-word; clear: both; min-height: 1em;\\\"><span style=\\\"-webkit-tap-highlight-color: transparent; outline: 0px; max-width: 100%; box-sizing: border-box; overflow-wrap: break-word; font-weight: bold;\\\"><span style=\\\"-webkit-tap-highlight-color: transparent; outline: 0px; max-width: 100%; box-sizing: border-box; overflow-wrap: break-word;\\\"><span style=\\\"-webkit-tap-highlight-color: transparent; outline: 0px; max-width: 100%; box-sizing: border-box; overflow-wrap: break-word;\\\">挂单买入场景：</span></span></span></p><p style=\\\"-webkit-tap-highlight-color: transparent; outline: 0; max-width: 100%; box-sizing: border-box; overflow-wrap: break-word; clear: both; min-height: 1em;\\\"><span style=\\\"-webkit-tap-highlight-color: transparent; outline: 0px; max-width: 100%; box-sizing: border-box; overflow-wrap: break-word;\\\"><span style=\\\"-webkit-tap-highlight-color: transparent; outline: 0px; max-width: 100%; box-sizing: border-box; overflow-wrap: break-word;\\\"><span style=\\\"-webkit-tap-highlight-color: transparent; outline: 0px; max-width: 100%; box-sizing: border-box; overflow-wrap: break-word;\\\">1，获取每3s监控当前价格；</span></span></span></p><p style=\\\"-webkit-tap-highlight-color: transparent; outline: 0; max-width: 100%; box-sizing: border-box; overflow-wrap: break-word; clear: both; min-height: 1em;\\\"><span style=\\\"-webkit-tap-highlight-color: transparent; outline: 0px; max-width: 100%; box-sizing: border-box; overflow-wrap: break-word;\\\"><span style=\\\"-webkit-tap-highlight-color: transparent; outline: 0px; max-width: 100%; box-sizing: border-box; overflow-wrap: break-word;\\\"><span style=\\\"-webkit-tap-highlight-color: transparent; outline: 0px; max-width: 100%; box-sizing: border-box; overflow-wrap: break-word;\\\">2，与目标价比较；</span></span></span></p><p style=\\\"-webkit-tap-highlight-color: transparent; outline: 0; max-width: 100%; box-sizing: border-box; overflow-wrap: break-word; clear: both; min-height: 1em;\\\"><span style=\\\"-webkit-tap-highlight-color: transparent; outline: 0px; max-width: 100%; box-sizing: border-box; overflow-wrap: break-word;\\\"><span style=\\\"-webkit-tap-highlight-color: transparent; outline: 0px; max-width: 100%; box-sizing: border-box; overflow-wrap: break-word;\\\"><span style=\\\"-webkit-tap-highlight-color: transparent; outline: 0px; max-width: 100%; box-sizing: border-box; overflow-wrap: break-word;\\\">3，满足条件则进行交易。</span></span></span></p><p style=\\\"\\\"><span><br/></span></p><div style=\\\"-webkit-tap-highlight-color: transparent; outline: 0px; max-width: 100%; box-sizing: border-box; overflow-wrap: break-word; color: rgb(25, 27, 31); font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: pre-wrap; background-color: rgb(255, 255, 255); text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;\\\"><div style=\\\"-webkit-tap-highlight-color: transparent; outline: 0px; max-width: 100%; box-sizing: border-box; overflow-wrap: break-word;\\\"><img src=\\\"量化入门QMT软件使用（05）-逐K运行_files/640.png\\\" type=\\\"image/png\\\" data-filename=\\\"640.png\\\" style=\\\"--en-marks: %7B%22align%22%3A%22center%22%7D; -webkit-tap-highlight-color: transparent; outline: 0px; max-width: 100%; box-sizing: border-box; overflow-wrap: break-word; height: auto; width: auto; display: block;\\\" width=\\\"auto\\\"/></div><p style=\\\"-webkit-tap-highlight-color: transparent; outline: 0; max-width: 100%; box-sizing: border-box; overflow-wrap: break-word; clear: both; min-height: 1em;\\\"><span style=\\\"-webkit-tap-highlight-color: transparent; outline: 0px; max-width: 100%; box-sizing: border-box; overflow-wrap: break-word;\\\"><br/></span></p></div><p style=\\\"\\\"></p><div><span>由上图代码可以看到这里，首先是handlebar函数，然后获取tick数据，再在获取最新价，获取完最新价之后再与我们的目标价作对比，如果大于目标价，就调用下单函数，下单成功后就成功了，如果如果小于，他又会继续运行handlebar方法，每三秒自动运行一次，直到买入。</span></div><p style=\\\"\\\"></p><p style=\\\"\\\"><span>挂单买入的实现非常简单，通过handlebar方法，盘中每3s就会自动运行一次，运行的时候，会把handlebar里面的代码执行一遍。该策略比较简单，因此计算时间也就几ms。</span></p><p style=\\\"-webkit-tap-highlight-color: transparent; outline: 0; max-width: 100%; box-sizing: border-box; overflow-wrap: break-word; clear: both; min-height: 1em;\\\"><span style=\\\"-webkit-tap-highlight-color: transparent; outline: 0px; max-width: 100%; box-sizing: border-box; overflow-wrap: break-word; font-weight: bold;\\\"><span style=\\\"-webkit-tap-highlight-color: transparent; outline: 0px; max-width: 100%; box-sizing: border-box; overflow-wrap: break-word;\\\"><span style=\\\"-webkit-tap-highlight-color: transparent; outline: 0px; max-width: 100%; box-sizing: border-box; overflow-wrap: break-word;\\\">3秒运行一次，会不会觉得太慢了呢？</span></span></span></p><p style=\\\"-webkit-tap-highlight-color: transparent; outline: 0; max-width: 100%; box-sizing: border-box; overflow-wrap: break-word; clear: both; min-height: 1em;\\\"><span style=\\\"-webkit-tap-highlight-color: transparent; outline: 0px; max-width: 100%; box-sizing: border-box; overflow-wrap: break-word;\\\"><span style=\\\"-webkit-tap-highlight-color: transparent; outline: 0px; max-width: 100%; box-sizing: border-box; overflow-wrap: break-word;\\\"><span style=\\\"-webkit-tap-highlight-color: transparent; outline: 0px; max-width: 100%; box-sizing: border-box; overflow-wrap: break-word;\\\">如果你接触一段时间量化后，可能会觉得3s也挺慢，没关系，QMT还准备了两种盯盘方法，后面会一一讲到。</span></span></span></p><p style=\\\"\\\"><span><br/></span></p><div style=\\\"-webkit-tap-highlight-color: transparent; outline: 0px; max-width: 100%; box-sizing: border-box; overflow-wrap: break-word; color: rgb(25, 27, 31); font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: pre-wrap; background-color: rgb(255, 255, 255); text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;\\\"><div style=\\\"-webkit-tap-highlight-color: transparent; outline: 0px; max-width: 100%; box-sizing: border-box; overflow-wrap: break-word;\\\"><img src=\\\"量化入门QMT软件使用（05）-逐K运行_files/640 [1].png\\\" type=\\\"image/png\\\" data-filename=\\\"640.png\\\" style=\\\"--en-marks: %7B%22align%22%3A%22center%22%7D; -webkit-tap-highlight-color: transparent; outline: 0px; max-width: 100%; box-sizing: border-box; overflow-wrap: break-word; height: auto; width: auto; display: block;\\\" width=\\\"auto\\\"/></div><p style=\\\"-webkit-tap-highlight-color: transparent; outline: 0; max-width: 100%; box-sizing: border-box; overflow-wrap: break-word; clear: both; min-height: 1em;\\\"><span style=\\\"-webkit-tap-highlight-color: transparent; outline: 0px; max-width: 100%; box-sizing: border-box; overflow-wrap: break-word;\\\"><br/></span></p></div><p style=\\\"\\\"><span><br/></span></p><p style=\\\"-webkit-tap-highlight-color: transparent; outline: 0; max-width: 100%; box-sizing: border-box; overflow-wrap: break-word; clear: both; min-height: 1em;\\\"><span style=\\\"-webkit-tap-highlight-color: transparent; outline: 0px; max-width: 100%; box-sizing: border-box; overflow-wrap: break-word;\\\"><span style=\\\"-webkit-tap-highlight-color: transparent; outline: 0px; max-width: 100%; box-sizing: border-box; overflow-wrap: break-word;\\\"><span style=\\\"-webkit-tap-highlight-color: transparent; outline: 0px; max-width: 100%; box-sizing: border-box; overflow-wrap: break-word;\\\">这里大家可能也发现了，该策略并不完整：</span></span></span></p><p style=\\\"-webkit-tap-highlight-color: transparent; outline: 0; max-width: 100%; box-sizing: border-box; overflow-wrap: break-word; clear: both; min-height: 1em;\\\"><span style=\\\"-webkit-tap-highlight-color: transparent; outline: 0px; max-width: 100%; box-sizing: border-box; overflow-wrap: break-word;\\\"><span style=\\\"-webkit-tap-highlight-color: transparent; outline: 0px; max-width: 100%; box-sizing: border-box; overflow-wrap: break-word;\\\"><span style=\\\"-webkit-tap-highlight-color: transparent; outline: 0px; max-width: 100%; box-sizing: border-box; overflow-wrap: break-word;\\\">1，股票池和目标价是人工设置；</span></span></span></p><p style=\\\"-webkit-tap-highlight-color: transparent; outline: 0; max-width: 100%; box-sizing: border-box; overflow-wrap: break-word; clear: both; min-height: 1em;\\\"><span style=\\\"-webkit-tap-highlight-color: transparent; outline: 0px; max-width: 100%; box-sizing: border-box; overflow-wrap: break-word;\\\"><span style=\\\"-webkit-tap-highlight-color: transparent; outline: 0px; max-width: 100%; box-sizing: border-box; overflow-wrap: break-word;\\\"><span style=\\\"-webkit-tap-highlight-color: transparent; outline: 0px; max-width: 100%; box-sizing: border-box; overflow-wrap: break-word;\\\">2，没有仓位判断、没有卖出条件。</span></span></span></p><p style=\\\"-webkit-tap-highlight-color: transparent; outline: 0; max-width: 100%; box-sizing: border-box; overflow-wrap: break-word; clear: both; min-height: 1em;\\\"><span style=\\\"-webkit-tap-highlight-color: transparent; outline: 0px; max-width: 100%; box-sizing: border-box; overflow-wrap: break-word; font-weight: bold;\\\"><span style=\\\"-webkit-tap-highlight-color: transparent; outline: 0px; max-width: 100%; box-sizing: border-box; overflow-wrap: break-word;\\\"><span style=\\\"-webkit-tap-highlight-color: transparent; outline: 0px; max-width: 100%; box-sizing: border-box; overflow-wrap: break-word;\\\">如果可以让计算自动得到：股票池、仓位、买卖价格，那么整个策略岂不是完全自动化了？</span></span></span></p><p style=\\\"-webkit-tap-highlight-color: transparent; outline: 0; max-width: 100%; box-sizing: border-box; overflow-wrap: break-word; clear: both; min-height: 1em;\\\"><span style=\\\"-webkit-tap-highlight-color: transparent; outline: 0px; max-width: 100%; box-sizing: border-box; overflow-wrap: break-word;\\\"><span style=\\\"-webkit-tap-highlight-color: transparent; outline: 0px; max-width: 100%; box-sizing: border-box; overflow-wrap: break-word;\\\"><span style=\\\"-webkit-tap-highlight-color: transparent; outline: 0px; max-width: 100%; box-sizing: border-box; overflow-wrap: break-word;\\\">没错，这是量化交易开始的第一步，从实现一个简单策略开始。</span></span></span></p><div><span><br/></span></div></div></div></div></div></div></span>\\\n</div></body></html>\\u0000\"]],\"start1\":0,\"start2\":0,\"length1\":0,\"length2\":13607}]"
metadata_diff: {"new":{"id":"7352af4d410b42d78884459b93d8b7ea","parent_id":"f67288c3a0be4374b5d532b5dcc3aabc","latitude":"0.00000000","longitude":"0.00000000","altitude":"0.0000","author":"","source_url":"","is_todo":0,"todo_due":0,"todo_completed":0,"source":"joplin-desktop","source_application":"net.cozic.joplin-desktop","application_data":"","order":1764348878958,"user_updated_time":1764345642025,"markup_language":2,"is_shared":0,"share_id":"","conflict_original_id":"","master_key_id":"","user_data":"","deleted_time":1764365031177},"deleted":[]}
encryption_cipher_text: 
encryption_applied: 0
updated_time: 2025-11-28T21:24:59.058Z
created_time: 2025-11-28T21:24:59.058Z
type_: 13