[ [中文](README.cn.md) ]
**Pyqie**是一个 python 的经典的量化策略引擎。
由于这只是一个简单的策略运行套件,所以并不推荐在实际的工作中使用。
## 说明
- 支持调用 pyqie 的指标计算库
- 支持在 python 环境下调用 pyqie 的数学库
- 支持使用简单的 python 环境下的 ECS 启发 pyqie 的指标计算
## 如何安装
### Windows
在安装[Python3](https://www.python.org/) (3.7 或更高版本) 之后,执行以下命令:
```sh
pip install -U pyqie
```
如果你使用官方安装程序安装 Python,请勾选`Add Python 3.x to PATH`复选框以启用`pyqie`命令。
### Mac
在安装[Python3](https://www.python.org/) (3.7 或更高版本) 之后,执行以下命令:
```sh
python3 -m pip install -U pyqie
```
如果你使用默认安装在 Mac 上的 Python3,请在上述命令的开头添加`sudo`以启用`pyqie`命令。
### Linux
[Python3](https://www.python.org/) (3.7 或更高版本),以及`python3-pip`这三个包之后,执行以下命令:
```sh
sudo pip3 install -U pyqie
```
如果上述方法不奏效,请根据[Makefile](../Makefile)中的说明尝试自我构建。
### 尝试 Pyqie 例程
以 Python 包版本为例,安装 Pyqie 后,用以下命令将 Pyxe 例程复制到当前文件夹:
```sh
pyqie copy_examples
```
例程包含:
<table>
<tr>
<td>01_hello_pyqie.py</td>
<td>最简单的应用</td>
<td><a href="https://github.com/xiatian0716/pyqie/blob/main/python/pyqie/examples/01_hello_pyqie.py">Code</a></td>
</tr>
<tr>
<td>02_hello_esper.py</td>
<td>自带 python 风格的 ECS</td>
<td><a href="https://github.com/xiatian0716/pyqie/blob/main/python/pyqie/examples/02_hello_esper.py">Code</a></td>
</tr>
</table>
运行例程,可以使用以下命令:
```sh
cd pyqie_examples
pyqie run 01_hello_pyqie.py
pyqie play 30SecondsOfDaylight.pyxapp
```
## 使用教程
### 创建 Pyqie 应用
在 python 文件中导入 Pyqie 包后,首先使用`init`函数指定窗口大小,然后使用`run`函数启动 Pyqie 应用。
```python
import pyqie
pyqie.init(160, 120)
def update():
sq4 = pyqie.sqrt(4)
print(sq4)
print("update")
def draw():
print("draw")
def close():
print("close")
pyqie.run(update, draw,close)
```
`run`函数的两个参数`update`函数和`draw`函数分别用来在需要时更新帧和绘制画面。
实际应用中,建议将 pyqie 代码封装成如下类:
```python
import pyqie
import asyncio
class App:
def __init__(self):
pyqie.init(1000)
pyqie.run(self.update, self.draw,self.close)
def update(self):
sq4 = pyqie.sqrt(4)
print(sq4)
print("update")
def draw(self):
print("draw")
loop = asyncio.get_event_loop()
loop.run_until_complete(self.consumer())
def close(self):
print("close")
async def consumer(self):
print("consumer")
App()
```
### 运行 Pyqie 应用
创建的 Python 脚本可以使用以下命令执行:
```sh
pyqie run PYTHON_SCRIPT_FILE
```
它也可以像普通的 Python 脚本一样被执行:
```sh
python3 PYTHON_SCRIPT_FILE
```
### 如何发布应用
Pyqie 支持跨平台的应用文件格式 (Pyqie 应用文件)。
使用以下命令创建 Pyqie 应用文件 (.pyxapp):
```sh
pyqie package APP_DIR STARTUP_SCRIPT_FILE
```
如果应用程序应包括资源或其他模块,请将它们放在应用程序目录中。
创建好的应用文件使用以下命令执行:
```sh
pyqie play PYQIE_APP_FILE
```
Pyqie 应用程序文件也可以通过`pyqie app2exe`或`pyqie app2html`命令转换为可执行文件或 HTML 文件。
## API 参考手册
### 系统
- `width`,`height`<br>
画面的宽和高
- `frame_count`<br>
目前为止,经过的总帧数
- `init(width, height, [title], [fps], [quit_key], [display_scale], [capture_scale], [capture_sec])`<br>
使用屏幕尺寸 (`width`,`height`) 初始化 Pyqie 应用。以下属性为可选配置项:窗口标题`title`,帧率`fps`,应用退出按键`quit_key`,用 "display_scale "来决定显示的比例,用 "capture_scale "来决定屏幕捕捉的比例,以及屏幕捕获的最长记录时间`capture_sec`。<br>
示例:`pyqie.init(160, 120, title="My Pyqie App", fps=60, quit_key=pyqie.KEY_NONE, capture_scale=3, capture_sec=0)`
- `run(update, draw)`<br>
启动 Pyqie 应用,并调用`update`函数刷新画面帧,并使用`draw`函数渲染画面。
- `show()`<br>
显示屏幕直到`Esc`键被按下。
- `flip()`<br>
将屏幕重新调整一帧。当按下`Esc`键时,应用程序退出。该功能在网络版中不起作用。
- `quit()`<br>
退出 Pyqie 应用。
### 数学
- `ceil(x)`<br>
返回大于或等于`x`的最小的整数。
- `floor(x)`<br>
返回小于或等于`x`的最大整数。
- `sgn(x)`<br>
当`x`是正数时返回 1,当它是零时返回 0,当它是负数时返回 1。
- `sqrt(x)`<br>
返回`x`的平方根。
- `sin(deg)`<br>
返回`deg`度的正弦。
- `cos(deg)`<br>
返回`deg`度的余弦。
- `atan2(y, x)`<br>
返回`y`/`x`的正切,单位是度。
- `rseed(seed)`<br>
设置随机数发生器的种子。
- `rndi(a, b)`<br>
返回一个大于或等于`a`且小于或等于`b`的随机整数。
- `rndf(a, b)`<br>
返回一个大于或等于`a`且小于或等于`b`的随机小数。
- `nseed(seed)`<br>
设置佩林噪声的种子。
- `noise(x, [y], [z])`<br>
返回指定坐标的佩林噪声值。
## 许可证
Pyqie 遵循[MIT License](../LICENSE)。您可以在专利软件中重复使用,前提是该软件的所有副本或重要部分均包含 MIT 许可条款的副本和版权声明。
Raw data
{
"_id": null,
"home_page": null,
"name": "pyqie",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.7",
"maintainer_email": null,
"keywords": "quantdev, python",
"author": "Takashi Kitao <takashi.xiatian0716@gmail.com>",
"author_email": "xiatian0716 <takashi.xiatian0716@gmail.com>",
"download_url": null,
"platform": null,
"description": "[ [\u4e2d\u6587](README.cn.md) ]\r\n\r\n**Pyqie**\u662f\u4e00\u4e2a python \u7684\u7ecf\u5178\u7684\u91cf\u5316\u7b56\u7565\u5f15\u64ce\u3002\r\n\r\n\u7531\u4e8e\u8fd9\u53ea\u662f\u4e00\u4e2a\u7b80\u5355\u7684\u7b56\u7565\u8fd0\u884c\u5957\u4ef6\uff0c\u6240\u4ee5\u5e76\u4e0d\u63a8\u8350\u5728\u5b9e\u9645\u7684\u5de5\u4f5c\u4e2d\u4f7f\u7528\u3002\r\n\r\n## \u8bf4\u660e\r\n\r\n- \u652f\u6301\u8c03\u7528 pyqie \u7684\u6307\u6807\u8ba1\u7b97\u5e93\r\n- \u652f\u6301\u5728 python \u73af\u5883\u4e0b\u8c03\u7528 pyqie \u7684\u6570\u5b66\u5e93\r\n- \u652f\u6301\u4f7f\u7528\u7b80\u5355\u7684 python \u73af\u5883\u4e0b\u7684 ECS \u542f\u53d1 pyqie \u7684\u6307\u6807\u8ba1\u7b97\r\n\r\n## \u5982\u4f55\u5b89\u88c5\r\n\r\n### Windows\r\n\r\n\u5728\u5b89\u88c5[Python3](https://www.python.org/) (3.7 \u6216\u66f4\u9ad8\u7248\u672c) \u4e4b\u540e\uff0c\u6267\u884c\u4ee5\u4e0b\u547d\u4ee4\uff1a\r\n\r\n```sh\r\npip install -U pyqie\r\n```\r\n\r\n\u5982\u679c\u4f60\u4f7f\u7528\u5b98\u65b9\u5b89\u88c5\u7a0b\u5e8f\u5b89\u88c5 Python\uff0c\u8bf7\u52fe\u9009`Add Python 3.x to PATH`\u590d\u9009\u6846\u4ee5\u542f\u7528`pyqie`\u547d\u4ee4\u3002\r\n\r\n### Mac\r\n\r\n\u5728\u5b89\u88c5[Python3](https://www.python.org/) (3.7 \u6216\u66f4\u9ad8\u7248\u672c) \u4e4b\u540e\uff0c\u6267\u884c\u4ee5\u4e0b\u547d\u4ee4\uff1a\r\n\r\n```sh\r\npython3 -m pip install -U pyqie\r\n```\r\n\r\n\u5982\u679c\u4f60\u4f7f\u7528\u9ed8\u8ba4\u5b89\u88c5\u5728 Mac \u4e0a\u7684 Python3\uff0c\u8bf7\u5728\u4e0a\u8ff0\u547d\u4ee4\u7684\u5f00\u5934\u6dfb\u52a0`sudo`\u4ee5\u542f\u7528`pyqie`\u547d\u4ee4\u3002\r\n\r\n### Linux\r\n\r\n[Python3](https://www.python.org/) (3.7 \u6216\u66f4\u9ad8\u7248\u672c)\uff0c\u4ee5\u53ca`python3-pip`\u8fd9\u4e09\u4e2a\u5305\u4e4b\u540e\uff0c\u6267\u884c\u4ee5\u4e0b\u547d\u4ee4\uff1a\r\n\r\n```sh\r\nsudo pip3 install -U pyqie\r\n```\r\n\r\n\u5982\u679c\u4e0a\u8ff0\u65b9\u6cd5\u4e0d\u594f\u6548\uff0c\u8bf7\u6839\u636e[Makefile](../Makefile)\u4e2d\u7684\u8bf4\u660e\u5c1d\u8bd5\u81ea\u6211\u6784\u5efa\u3002\r\n\r\n### \u5c1d\u8bd5 Pyqie \u4f8b\u7a0b\r\n\r\n\u4ee5 Python \u5305\u7248\u672c\u4e3a\u4f8b\uff0c\u5b89\u88c5 Pyqie \u540e\uff0c\u7528\u4ee5\u4e0b\u547d\u4ee4\u5c06 Pyxe \u4f8b\u7a0b\u590d\u5236\u5230\u5f53\u524d\u6587\u4ef6\u5939\uff1a\r\n\r\n```sh\r\npyqie copy_examples\r\n```\r\n\r\n\u4f8b\u7a0b\u5305\u542b\uff1a\r\n\r\n<table>\r\n<tr>\r\n<td>01_hello_pyqie.py</td>\r\n<td>\u6700\u7b80\u5355\u7684\u5e94\u7528</td>\r\n<td><a href=\"https://github.com/xiatian0716/pyqie/blob/main/python/pyqie/examples/01_hello_pyqie.py\">Code</a></td>\r\n</tr>\r\n<tr>\r\n<td>02_hello_esper.py</td>\r\n<td>\u81ea\u5e26 python \u98ce\u683c\u7684 ECS</td>\r\n<td><a href=\"https://github.com/xiatian0716/pyqie/blob/main/python/pyqie/examples/02_hello_esper.py\">Code</a></td>\r\n</tr>\r\n</table>\r\n\r\n\u8fd0\u884c\u4f8b\u7a0b\uff0c\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\uff1a\r\n\r\n```sh\r\ncd pyqie_examples\r\npyqie run 01_hello_pyqie.py\r\npyqie play 30SecondsOfDaylight.pyxapp\r\n```\r\n\r\n## \u4f7f\u7528\u6559\u7a0b\r\n\r\n### \u521b\u5efa Pyqie \u5e94\u7528\r\n\r\n\u5728 python \u6587\u4ef6\u4e2d\u5bfc\u5165 Pyqie \u5305\u540e\uff0c\u9996\u5148\u4f7f\u7528`init`\u51fd\u6570\u6307\u5b9a\u7a97\u53e3\u5927\u5c0f\uff0c\u7136\u540e\u4f7f\u7528`run`\u51fd\u6570\u542f\u52a8 Pyqie \u5e94\u7528\u3002\r\n\r\n```python\r\nimport pyqie\r\n\r\npyqie.init(160, 120)\r\n\r\ndef update():\r\n sq4 = pyqie.sqrt(4)\r\n print(sq4)\r\n print(\"update\")\r\n\r\ndef draw():\r\n print(\"draw\")\r\n\r\ndef close():\r\n print(\"close\")\r\n\r\npyqie.run(update, draw,close)\r\n```\r\n\r\n`run`\u51fd\u6570\u7684\u4e24\u4e2a\u53c2\u6570`update`\u51fd\u6570\u548c`draw`\u51fd\u6570\u5206\u522b\u7528\u6765\u5728\u9700\u8981\u65f6\u66f4\u65b0\u5e27\u548c\u7ed8\u5236\u753b\u9762\u3002\r\n\r\n\u5b9e\u9645\u5e94\u7528\u4e2d\uff0c\u5efa\u8bae\u5c06 pyqie \u4ee3\u7801\u5c01\u88c5\u6210\u5982\u4e0b\u7c7b\uff1a\r\n\r\n```python\r\nimport pyqie\r\nimport asyncio\r\n\r\nclass App:\r\n def __init__(self):\r\n pyqie.init(1000)\r\n pyqie.run(self.update, self.draw,self.close)\r\n\r\n def update(self):\r\n sq4 = pyqie.sqrt(4)\r\n print(sq4)\r\n print(\"update\")\r\n\r\n def draw(self):\r\n print(\"draw\")\r\n loop = asyncio.get_event_loop()\r\n loop.run_until_complete(self.consumer())\r\n\r\n def close(self):\r\n print(\"close\")\r\n\r\n async def consumer(self):\r\n print(\"consumer\")\r\n\r\nApp()\r\n```\r\n\r\n\r\n### \u8fd0\u884c Pyqie \u5e94\u7528\r\n\r\n\u521b\u5efa\u7684 Python \u811a\u672c\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u6267\u884c\uff1a\r\n\r\n```sh\r\npyqie run PYTHON_SCRIPT_FILE\r\n```\r\n\r\n\u5b83\u4e5f\u53ef\u4ee5\u50cf\u666e\u901a\u7684 Python \u811a\u672c\u4e00\u6837\u88ab\u6267\u884c\uff1a\r\n\r\n```sh\r\npython3 PYTHON_SCRIPT_FILE\r\n```\r\n\r\n\r\n### \u5982\u4f55\u53d1\u5e03\u5e94\u7528\r\n\r\nPyqie \u652f\u6301\u8de8\u5e73\u53f0\u7684\u5e94\u7528\u6587\u4ef6\u683c\u5f0f (Pyqie \u5e94\u7528\u6587\u4ef6)\u3002\r\n\r\n\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u521b\u5efa Pyqie \u5e94\u7528\u6587\u4ef6 (.pyxapp)\uff1a\r\n\r\n```sh\r\npyqie package APP_DIR STARTUP_SCRIPT_FILE\r\n```\r\n\r\n\u5982\u679c\u5e94\u7528\u7a0b\u5e8f\u5e94\u5305\u62ec\u8d44\u6e90\u6216\u5176\u4ed6\u6a21\u5757\uff0c\u8bf7\u5c06\u5b83\u4eec\u653e\u5728\u5e94\u7528\u7a0b\u5e8f\u76ee\u5f55\u4e2d\u3002\r\n\r\n\u521b\u5efa\u597d\u7684\u5e94\u7528\u6587\u4ef6\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u6267\u884c\uff1a\r\n\r\n```sh\r\npyqie play PYQIE_APP_FILE\r\n```\r\n\r\nPyqie \u5e94\u7528\u7a0b\u5e8f\u6587\u4ef6\u4e5f\u53ef\u4ee5\u901a\u8fc7`pyqie app2exe`\u6216`pyqie app2html`\u547d\u4ee4\u8f6c\u6362\u4e3a\u53ef\u6267\u884c\u6587\u4ef6\u6216 HTML \u6587\u4ef6\u3002\r\n\r\n## API \u53c2\u8003\u624b\u518c\r\n\r\n### \u7cfb\u7edf\r\n\r\n- `width`\uff0c`height`<br>\r\n \u753b\u9762\u7684\u5bbd\u548c\u9ad8\r\n\r\n- `frame_count`<br>\r\n \u76ee\u524d\u4e3a\u6b62\uff0c\u7ecf\u8fc7\u7684\u603b\u5e27\u6570\r\n\r\n- `init(width, height, [title], [fps], [quit_key], [display_scale], [capture_scale], [capture_sec])`<br>\r\n \u4f7f\u7528\u5c4f\u5e55\u5c3a\u5bf8 (`width`\uff0c`height`) \u521d\u59cb\u5316 Pyqie \u5e94\u7528\u3002\u4ee5\u4e0b\u5c5e\u6027\u4e3a\u53ef\u9009\u914d\u7f6e\u9879\uff1a\u7a97\u53e3\u6807\u9898`title`\uff0c\u5e27\u7387`fps`\uff0c\u5e94\u7528\u9000\u51fa\u6309\u952e`quit_key`\uff0c\u7528 \"display_scale \"\u6765\u51b3\u5b9a\u663e\u793a\u7684\u6bd4\u4f8b\uff0c\u7528 \"capture_scale \"\u6765\u51b3\u5b9a\u5c4f\u5e55\u6355\u6349\u7684\u6bd4\u4f8b\uff0c\u4ee5\u53ca\u5c4f\u5e55\u6355\u83b7\u7684\u6700\u957f\u8bb0\u5f55\u65f6\u95f4`capture_sec`\u3002<br>\r\n \u793a\u4f8b\uff1a`pyqie.init(160, 120, title=\"My Pyqie App\", fps=60, quit_key=pyqie.KEY_NONE, capture_scale=3, capture_sec=0)`\r\n\r\n- `run(update, draw)`<br>\r\n \u542f\u52a8 Pyqie \u5e94\u7528\uff0c\u5e76\u8c03\u7528`update`\u51fd\u6570\u5237\u65b0\u753b\u9762\u5e27\uff0c\u5e76\u4f7f\u7528`draw`\u51fd\u6570\u6e32\u67d3\u753b\u9762\u3002\r\n\r\n- `show()`<br>\r\n \u663e\u793a\u5c4f\u5e55\u76f4\u5230`Esc`\u952e\u88ab\u6309\u4e0b\u3002\r\n\r\n- `flip()`<br>\r\n \u5c06\u5c4f\u5e55\u91cd\u65b0\u8c03\u6574\u4e00\u5e27\u3002\u5f53\u6309\u4e0b`Esc`\u952e\u65f6\uff0c\u5e94\u7528\u7a0b\u5e8f\u9000\u51fa\u3002\u8be5\u529f\u80fd\u5728\u7f51\u7edc\u7248\u4e2d\u4e0d\u8d77\u4f5c\u7528\u3002\r\n\r\n- `quit()`<br>\r\n \u9000\u51fa Pyqie \u5e94\u7528\u3002\r\n\r\n### \u6570\u5b66\r\n\r\n- `ceil(x)`<br>\r\n \u8fd4\u56de\u5927\u4e8e\u6216\u7b49\u4e8e`x`\u7684\u6700\u5c0f\u7684\u6574\u6570\u3002\r\n\r\n- `floor(x)`<br>\r\n \u8fd4\u56de\u5c0f\u4e8e\u6216\u7b49\u4e8e`x`\u7684\u6700\u5927\u6574\u6570\u3002\r\n\r\n- `sgn(x)`<br>\r\n \u5f53`x`\u662f\u6b63\u6570\u65f6\u8fd4\u56de 1\uff0c\u5f53\u5b83\u662f\u96f6\u65f6\u8fd4\u56de 0\uff0c\u5f53\u5b83\u662f\u8d1f\u6570\u65f6\u8fd4\u56de 1\u3002\r\n\r\n- `sqrt(x)`<br>\r\n \u8fd4\u56de`x`\u7684\u5e73\u65b9\u6839\u3002\r\n\r\n- `sin(deg)`<br>\r\n \u8fd4\u56de`deg`\u5ea6\u7684\u6b63\u5f26\u3002\r\n\r\n- `cos(deg)`<br>\r\n \u8fd4\u56de`deg`\u5ea6\u7684\u4f59\u5f26\u3002\r\n\r\n- `atan2(y, x)`<br>\r\n \u8fd4\u56de`y`/`x`\u7684\u6b63\u5207\uff0c\u5355\u4f4d\u662f\u5ea6\u3002\r\n\r\n- `rseed(seed)`<br>\r\n \u8bbe\u7f6e\u968f\u673a\u6570\u53d1\u751f\u5668\u7684\u79cd\u5b50\u3002\r\n\r\n- `rndi(a, b)`<br>\r\n \u8fd4\u56de\u4e00\u4e2a\u5927\u4e8e\u6216\u7b49\u4e8e`a`\u4e14\u5c0f\u4e8e\u6216\u7b49\u4e8e`b`\u7684\u968f\u673a\u6574\u6570\u3002\r\n\r\n- `rndf(a, b)`<br>\r\n \u8fd4\u56de\u4e00\u4e2a\u5927\u4e8e\u6216\u7b49\u4e8e`a`\u4e14\u5c0f\u4e8e\u6216\u7b49\u4e8e`b`\u7684\u968f\u673a\u5c0f\u6570\u3002\r\n\r\n- `nseed(seed)`<br>\r\n \u8bbe\u7f6e\u4f69\u6797\u566a\u58f0\u7684\u79cd\u5b50\u3002\r\n\r\n- `noise(x, [y], [z])`<br>\r\n \u8fd4\u56de\u6307\u5b9a\u5750\u6807\u7684\u4f69\u6797\u566a\u58f0\u503c\u3002\r\n\r\n## \u8bb8\u53ef\u8bc1\r\n\r\nPyqie \u9075\u5faa[MIT License](../LICENSE)\u3002\u60a8\u53ef\u4ee5\u5728\u4e13\u5229\u8f6f\u4ef6\u4e2d\u91cd\u590d\u4f7f\u7528\uff0c\u524d\u63d0\u662f\u8be5\u8f6f\u4ef6\u7684\u6240\u6709\u526f\u672c\u6216\u91cd\u8981\u90e8\u5206\u5747\u5305\u542b MIT \u8bb8\u53ef\u6761\u6b3e\u7684\u526f\u672c\u548c\u7248\u6743\u58f0\u660e\u3002\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "A retro game engine for Python",
"version": "0.0.4",
"project_urls": {
"homepage": "https://github.com/xiatian0716/pyqie"
},
"split_keywords": [
"quantdev",
" python"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "e8fe5c736efbe6e44053e39a482443f648a596fba6d7ed3904b7cfc514b43e76",
"md5": "0afd224cffbdb66902c89173171d6ef4",
"sha256": "99c41418055564f92cf56da630e370babf30134253466dcdf0280e0f7f346622"
},
"downloads": -1,
"filename": "pyqie-0.0.4-cp37-abi3-win_amd64.whl",
"has_sig": false,
"md5_digest": "0afd224cffbdb66902c89173171d6ef4",
"packagetype": "bdist_wheel",
"python_version": "cp37",
"requires_python": ">=3.7",
"size": 210212,
"upload_time": "2024-04-13T11:21:33",
"upload_time_iso_8601": "2024-04-13T11:21:33.597351Z",
"url": "https://files.pythonhosted.org/packages/e8/fe/5c736efbe6e44053e39a482443f648a596fba6d7ed3904b7cfc514b43e76/pyqie-0.0.4-cp37-abi3-win_amd64.whl",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-04-13 11:21:33",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "xiatian0716",
"github_project": "pyqie",
"github_not_found": true,
"lcname": "pyqie"
}