python event 事件类 events.py 类
Locust源码分析之events.py模块(5)
https://blog.youkuaiyun.com/biheyu828/article/details/84983780
eventpy —— Python 事件派发和回调代码库
https://zhuanlan.zhihu.com/p/107190607
eventpy —— Python 事件派发和回调代码库
https://zhuanlan.zhihu.com/p/107190607
国人wqking开发,支持Python 3和Cython。
eventpy是一个 Python 事件库,它提供的工具允许应用程序组件通过调度事件并监听它们来相互通信。使用eventpy,您可以非常轻松地实现信号/插槽机制或观察者模式。
GitHub:wqking/eventpy
特性
支持同步事件调度和异步事件队列。
可配置和可扩展的策略。
支持嵌套事件。在处理事件期间,侦听器可以安全地调度事件,追加/预置/插入/删除其他侦听器。
线程安全。支持多线程。
用大量单元测试来保证质量。
灵活易用。
侦听器和事件可以是任何类型,不需要从任何基类继承。
Version:0.0.1
License:Apache License Version 2.0
GitHub:wqking/eventpy
使用 CallbackList
# create a CallbackList
callbackList = CallbackList()
callbackList.append(lambda s, b : print("Got callback 1, s is %s b is %d" % (s, b)))
def anotherCallback(s, b) :
print("Got callback 2, s is %s b is %d" % (s, b))
callbackList.append(anotherCallback)
# Invoke the callback list
callbackList("Hello world", True)
使用 EventDispatcher
# create an EventDispatcher
dispatcher = EventDispatcher()
dispatcher.appendListener(3, lambda s, b : print("Got event 3, s is %s b is %d" % (s, b)))
dispatcher.appendListener(5, lambda s, b : print("Got event 5, s is %s b is %d" % (s, b)))
dispatcher.appendListener(5, lambda s, b : print("Got another event 5, s is %s b is %d" % (s, b)))
# Dispatch the events, the first argument is always the event type.
dispatcher.dispatch(3, "Hello", True)
dispatcher.dispatch(5, "World", False)
使用 EventQueue
# create an EventQueue
queue = eventqueue.EventQueue()
queue.appendListener(3, lambda s, n : print("Got event 3, s is %s n is %d" % (s, n)))
queue.appendListener(5, lambda s, n : print("Got event 5, s is %s n is %d" % (s, n)))
queue.appendListener(5, lambda s, n : print("Got another event 5, s is %s n is %d" % (s, n)))
# Enqueue the events, the first argument is always the event type.
# The listeners are not triggered during enqueue.
queue.enqueue(3, "Hello", 38)
queue.enqueue(5, "World", 58)
# Process the event queue, dispatch all queued events.
queue.process();
GitHub 上有什么「不能错过」,简单、易学的 Python 项目?
GitHub 上有什么「不能错过」,简单、易学的 Python 项目?
GitHub 上有什么「不能错过」,简单、易学的 Python 项目?
GitHub 上有什么「不能错过」,简单、易学的 Python 项目?
1. runscope/httpbin。使用flask,网站是httpbin(1): HTTP Client Testing Service。
1. runscope/httpbin。使用flask,网站是httpbin(1): HTTP Client Testing Service。
vnpy-ctp业务逻辑封装教程
小白EXCEL金融分析的博客
vnpy-ctp业务逻辑封装教程(1)前篇
新浪首页登录注册
小白EXCEL金融分析的博客
vnpy-ctp业务逻辑封装教程(1)前篇
转载2017-01-14 17:00:02
标签:pythonctp
以前总觉得CTP很高大上,最近一直研究海风的PYCTP和VNPY的架构,用PYTHON 可以把高大上的CTP拉下神坛,VNPY使用PYTHON 32位的2.7版本是为了在复杂的生产环境例如基于TICK的高频交易为了速度和可靠性而作出的选择,也并不是说PYTHON 64位的3.5版本会出问题,相反基于这个逻辑,我们相信VNPY 的架构经得起高频交易的测试,对于我等非高频交易的人来说,这个架构非常稳定,所以我采用64位的3.5,因为速度对于我来讲并不重要,而且速度决定于策略算法,并不是64位和32的差别。我不是程序员,只是个交易员,PYTHON才学习半年,所以只能用我能理解的方法讲解。PYTHON采用ANACOND的最新64位版本。
我不需要去编译CTP_API,直接用海风封装好的PYCTP,只需要搞业务逻辑,海风的开源项目地址:https://git.oschina.net/hubert28/at_py,下载后把PY_CTP目录复制到anacond的SITEPACKGES目录下,这样就有了QUOTE和TRADE2个轮子,接下去打开VNPY的开源项目地址:https://github.com/vnpy/vnpy,在vn.even目录下是最新的事件驱动框架,复制粘帖,生成eventEngine.py,修改第4行:from Queue import Queue, Empty,PY3.5的版本是:from queue import Queue, Empty,第10行和292行PYQT4改成PYQT5,第295行修改PRINT命令。接下去测试EVENTENGINE,出现如下内容说明EVENTENGINE正常。
事件驱动�1�3
接下去进入vnpy/vn.demo/ctpdemo/目录,把eventType.py复制过来。
把�6�7eventType.py 和eventEngine.py2个文件移动到anacond的SITEPACKGES里面的PY_CTP目录里,这样就齐活了。
21
据结构
算法可视化工具 https://github.com/algorithm-visualizer/algorithm-visualizer
Java Web
OJ开源项目 https://github.com/QingdaoU/OnlineJudge
Android
MVP开发模式官方示例 https://github.com/android10/Android-CleanArchitecture
MVP开发模式示例 https://github.com/sockeqwe/mosby
MVPSocket(Demo)https://github.com/GavinAndre/MVPSocket
okhttp https://github.com/square/okhttp
EventBus https://github.com/greenrobot/EventBus
一款android自动生成表格框架
https://github.com/huangyanbin/smartTable
Android 检索手机目录方式的文件选择器
https://github.com/leonHua/LFilePicker
AndroidDevTools(Android相关工具整合) https://github.com/inferjay/AndroidDevTools
HTML5 danmaku video player
https://github.com/MoePlayer/DPlayer
趣享GIF开源版 https://github.com/guolindev/giffun
Android指纹识别例子 https://github.com/googlesamples/android-FingerprintDialog
ffmpeg-android https://github.com/WritingMinds/ffmpeg-android
一个整合了大量主流开源项目高度可配置化的 Android MVP 快速集成框架
https://github.com/JessYanCoding/MVPArms
今日头条屏幕适配方案终极版,一个极低成本的 Android 屏幕适配方案
https://github.com/JessYanCoding/AndroidAutoSize
GitHub上最火的Android开源项目,所有开源项目都有详细资料和配套视频
https://github.com/open-android/Android
提高 Android UI 开发效率的 UI 库
https://github.com/Tencent/QMUI_Android
ImmersionBar
https://github.com/gyf-dev/ImmersionBar
图标库
https://github.com/JoanZapata/android-iconify
FragmentationX
https://github.com/YoKeyword/Fragmentation
动画框架AVLoadingIndicatorView
https://github.com/81813780/AVLoadingIndicatorView
Android图片轮播控件
https://github.com/youth5201314/banner
数据库
阿里Druid数据库连接池 https://github.com/alibaba/druid
其他
chrome插件,查看Android离线文档的时候屏蔽google资源请求
https://github.com/xesam/android_offline_doc_plugin
中国省市县数据
https://github.com/small-dream/China_Province_City
README文件语法
https://github.com/guodongxiaren/README
剑指offer源代码
https://github.com/zhedahht/ChineseCodingInterviewAppendix
《Android开发艺术探索》书中源代码
https://github.com/singwhatiwanna/android-art-res
《第一行代码 第2版》全书源代码
https://github.com/guolindev/booksource