{"id":17081857,"url":"https://github.com/yutiansut/qaschedule","last_synced_at":"2025-05-07T23:38:38.405Z","repository":{"id":57458786,"uuid":"228316918","full_name":"yutiansut/QASchedule","owner":"yutiansut","description":"Schedule for job","archived":false,"fork":false,"pushed_at":"2019-12-21T22:55:48.000Z","size":16,"stargazers_count":2,"open_issues_count":1,"forks_count":9,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-05-07T23:38:23.285Z","etag":null,"topics":["quantaxis"],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/yutiansut.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-12-16T06:21:34.000Z","updated_at":"2020-01-07T06:13:10.000Z","dependencies_parsed_at":"2022-09-10T05:50:46.871Z","dependency_job_id":null,"html_url":"https://github.com/yutiansut/QASchedule","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yutiansut%2FQASchedule","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yutiansut%2FQASchedule/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yutiansut%2FQASchedule/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yutiansut%2FQASchedule/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/yutiansut","download_url":"https://codeload.github.com/yutiansut/QASchedule/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252973607,"owners_count":21834104,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["quantaxis"],"created_at":"2024-10-14T12:57:09.883Z","updated_at":"2025-05-07T23:38:38.380Z","avatar_url":"https://github.com/yutiansut.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# QASchedule\nSchedule for job\n\n\nQASchedule 是为了做什么的?\n\n![image.png](http://pic.yutiansut.com/Frk8C_HjxTrYzlwT-J0UJMUSOx4h)\n\n很多时候, 我们的策略需要定时去执行一些任务, 比如 定时1小时来进行一次选股, 但是很多时候的策略执行的中间状态并不为人所知.\n\nQASchedule是为了实现一个可视化版本的job flow\n\n\n本QASchedule移植于 QAUnicorn, 一个内部的定时管理任务\n\n\n1. 内部定时任务指派\n2. long-running job的自动运维和状态汇报\n3. 支持QAEventMQ/ QAWebsocket/ QAREST 等多个接入模式\n\n\n\n常见场景：\n\n1. 你持有股票，设定一个止损价格， 如果当价格跌破某个价位， 就进行平仓【汇报状态】 【检查周期： tick】\n\n2. 你有一个日内策略， 需要对于一个股票池进行监控， 当A股票发生异常行为时， 产生一个事件【汇报状态】， 并对b股票进行操作【汇报状态】\n\n3. 你有一个选股策略，在每个小时都对全市场进行扫描，选择出股票后进行一系列操作\n\n4. 你有一些待执行的任务， 形成一个rpc服务， 当远程调用的时候自动执行这个流程\n\n\n希望做成什么:\n\n## 内部的定时任务\n这是一种模式, 基于@的\n\n\n```python\n@every(frequence='1hour')\ndef do_1hour():\n    sumbit_event(event_type='x')\n@every(frequence='1tick')\ndef do_every_tick()\n@every(frequence='event_driven', routing_key='x')\ndef do_while_calling()\n```\n这是另外一种模式, 基于on_xxx\n\n```python\nclass xxx(QAStrategy):\n    def on_bar():\n        pass\n```\n\n## 外部的定时任务\n\n基于celery beat, 实现心跳检查和一些定时的运维活动\n\n提供可视化界面和http接口\n\n\n\n\n## 状态汇报协议：\n\n\n```json\n{\n    \"source\": \"jobxxx\",\n    \"filepath\": \"xxxx\",\n    \"name\" : \"xxx\",\n    \"status\": \"xxxx\",\n    \"confirm\": false,\n    \"context\": \"xxxx\"\n}\n```\n\n## 动态进程创建/指派\n\n基于http的动态进程创建\npost: http://ip:port/job/new?content=xxx\n\n会自动在开启此服务的服务器的缓存位置: ~/.quantaxis/cache中创建一个随机uuid.py文件\n\n然后动态运行\n\n\n\n## 使用QASchedule以后\n\nQAEventMQ会产生一个新的exchange: QAEventTopic\n\n此Exchange为topic模式, 需要使用QAPUBSUB.consumer.subscriber_topic来订阅\n\nrouting_key \n\n- \"#\"  为监听所有事件\n- \"*.event \" 监听所有event事件\n- \"1min.#\" 监听所有1min事件\n- \"5min.#\" 监听所有5min事件\n- \"15min.#\" 监听所有15min事件\n\n直接调试: \n\n```\nqaps_sub --model topic --exchange QAEventTopic --routing_key \"#\"\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyutiansut%2Fqaschedule","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fyutiansut%2Fqaschedule","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyutiansut%2Fqaschedule/lists"}