dsxindexer


Namedsxindexer JSON
Version 1.1.0 PyPI version JSON
download
home_pagehttps://github.com/dsxkline/dsxindexer
Summarydsxindexer 是一个指标生成器,支持常用指标,自定义扩展指标算法,公式编辑功能
upload_time2023-05-08 08:44:18
maintainer
docs_urlNone
authorfangyunsm
requires_python>=3.6,<4
licenseMIT License
keywords 通达信指标 公式编辑器 量化指标
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # dsxindexer
 基于麦语言的量化指标公式编辑器框架,目前支持部分通达信公式,因为公式太多,所以慢慢完善中,有兴趣的朋友可以自己实现哦。

## 安装

```
pip install dsxindexer
```

## 使用

```python
# 导入包
import dsxindexer
# 导入数据工具箱
import dsxquant
# 首先获取K线历史数据
klines = dsxquant.get_klines("000001",dsxquant.market.SZ).datas()
klines:list = klines.data
klines.reverse()
# 创建指标处理器
sp = dsxindexer.sindexer(klines)
# 注册系统指标
sp.register(dsxindexer.INDEXER.MACD)
# 执行计算结果
result = sp.execute()
```

## 自定义指标公式


```python
import dsxindexer
import dsxquant

class ABCD(dsxindexer.BaseSindexer):
    """ABCD
    通过继承指标器基类自定义ABCD指标
    """
    # 定义指标名称
    __typename__ = "ABCD"

    def formula(self):
        return """
        long:MACD.LONG;
        金叉:CROSS(MACD.DIF,MACD.DEA);
        死叉:LONGCROSS(MACD.DIF,MACD.DEA,5) AND MACD.DIF<-0.1 ;
        Kjd:"KDJ.K";
        # 这里是注释
        A:CLOSE;#收盘价
        B:HIGH;#最高价
        C:A*B;
        {这里是注释符了}
        D:1000+(A+B*90/(60*C))/90*A-100000/C*100;
        E:IF(A>=B,
        IFF(B>C,D,A),C);
        买线:1000;
        卖线:456 * 买线;
        哈哈:!90;
        """

# 获取K线历史数据
klines = dsxquant.get_klines("000001",dsxquant.market.SZ).datas()
klines:list = klines.data
klines.reverse()
dsxindexer.logger.info("开始处理....")
# 指标处理器
sp = dsxindexer.sindexer(klines)
# 注册自定义指标
sp.register(ABCD)
# 执行计算结果
result = sp.execute()
# 取最后一个
model = result[-1]
dsxindexer.logger.info(model.DATE+" %s" % vars(model.ABCD))

```

## 指标编写方式

目前指标支持系统指标,自定义指标,自定义可分为两种方式:继承和工厂方式

### 继承方式

```python
class MAn(dsxindexer.BaseSindexer):
    """MAn
    """
    # 定义指标名称
    __typename__ = "MAn"

    def formula(self):
        return """
        MA5:MA(CLOSE,5);
        MA30:MA(CLOSE,30);
        MA60:MA(CLOSE,60);
        """
# 指标处理器
sp = dsxindexer.sindexer(klines)
sp.register(MAn)
# 执行计算结果
result = sp.execute()
```

### 工厂方式

```python
# 指标处理器
sp = dsxindexer.sindexer(klines)
# 通过指标工厂自定义指标
MA10 = dsxindexer.factory.create("MA10","MA10:MA(CLOSE,10);")
sp.register(MA10)
# 执行计算结果
result = sp.execute()
```

## 使用系统指标

目前支持大概几十个系统指标,后续不断完善中....


### 常用系统指标
```python
# 系统默认指标
class INDEXER:
    BOLL="BOLL"
    BRAR="BRAR"
    CCI="CCI"
    CDP="CDP"
    CR="CR"
    DMA="DMA"
    EMV="EMV"
    EXPMA="EXPMA"
    KDJ="KDJ"
    MACD="MACD"
    MIKE="MIKE"
    OBV="OBV"
    PSY="PSY"
    ROC="ROC"
    RSI="RSI"
    TRIX="TRIX"
    VR="VR"
    WR="WR"
    WVAD="WVAD"
```


            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/dsxkline/dsxindexer",
    "name": "dsxindexer",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.6,<4",
    "maintainer_email": "",
    "keywords": "\u901a\u8fbe\u4fe1\u6307\u6807,\u516c\u5f0f\u7f16\u8f91\u5668,\u91cf\u5316\u6307\u6807",
    "author": "fangyunsm",
    "author_email": "fangyunsm <934476300@qq.com>",
    "download_url": "https://files.pythonhosted.org/packages/fd/d2/f3b0bf2cb0151fac035a6ef92721aed77cfaf5ef7a89b48a0a9662b07b4d/dsxindexer-1.1.0.tar.gz",
    "platform": null,
    "description": "# dsxindexer\n \u57fa\u4e8e\u9ea6\u8bed\u8a00\u7684\u91cf\u5316\u6307\u6807\u516c\u5f0f\u7f16\u8f91\u5668\u6846\u67b6,\u76ee\u524d\u652f\u6301\u90e8\u5206\u901a\u8fbe\u4fe1\u516c\u5f0f\uff0c\u56e0\u4e3a\u516c\u5f0f\u592a\u591a\uff0c\u6240\u4ee5\u6162\u6162\u5b8c\u5584\u4e2d\uff0c\u6709\u5174\u8da3\u7684\u670b\u53cb\u53ef\u4ee5\u81ea\u5df1\u5b9e\u73b0\u54e6\u3002\n\n## \u5b89\u88c5\n\n```\npip install dsxindexer\n```\n\n## \u4f7f\u7528\n\n```python\n# \u5bfc\u5165\u5305\nimport dsxindexer\n# \u5bfc\u5165\u6570\u636e\u5de5\u5177\u7bb1\nimport dsxquant\n# \u9996\u5148\u83b7\u53d6K\u7ebf\u5386\u53f2\u6570\u636e\nklines = dsxquant.get_klines(\"000001\",dsxquant.market.SZ).datas()\nklines:list = klines.data\nklines.reverse()\n# \u521b\u5efa\u6307\u6807\u5904\u7406\u5668\nsp = dsxindexer.sindexer(klines)\n# \u6ce8\u518c\u7cfb\u7edf\u6307\u6807\nsp.register(dsxindexer.INDEXER.MACD)\n# \u6267\u884c\u8ba1\u7b97\u7ed3\u679c\nresult = sp.execute()\n```\n\n## \u81ea\u5b9a\u4e49\u6307\u6807\u516c\u5f0f\n\n\n```python\nimport dsxindexer\nimport dsxquant\n\nclass ABCD(dsxindexer.BaseSindexer):\n    \"\"\"ABCD\n    \u901a\u8fc7\u7ee7\u627f\u6307\u6807\u5668\u57fa\u7c7b\u81ea\u5b9a\u4e49ABCD\u6307\u6807\n    \"\"\"\n    # \u5b9a\u4e49\u6307\u6807\u540d\u79f0\n    __typename__ = \"ABCD\"\n\n    def formula(self):\n        return \"\"\"\n        long:MACD.LONG;\n        \u91d1\u53c9:CROSS(MACD.DIF,MACD.DEA);\n        \u6b7b\u53c9:LONGCROSS(MACD.DIF,MACD.DEA,5) AND MACD.DIF<-0.1 ;\n        Kjd:\"KDJ.K\";\n        # \u8fd9\u91cc\u662f\u6ce8\u91ca\n        A:CLOSE;#\u6536\u76d8\u4ef7\n        B:HIGH;#\u6700\u9ad8\u4ef7\n        C:A*B;\n        {\u8fd9\u91cc\u662f\u6ce8\u91ca\u7b26\u4e86}\n        D:1000+(A+B*90/(60*C))/90*A-100000/C*100;\n        E:IF(A>=B,\n        IFF(B>C,D,A),C);\n        \u4e70\u7ebf:1000;\n        \u5356\u7ebf:456 * \u4e70\u7ebf;\n        \u54c8\u54c8:!90;\n        \"\"\"\n\n# \u83b7\u53d6K\u7ebf\u5386\u53f2\u6570\u636e\nklines = dsxquant.get_klines(\"000001\",dsxquant.market.SZ).datas()\nklines:list = klines.data\nklines.reverse()\ndsxindexer.logger.info(\"\u5f00\u59cb\u5904\u7406....\")\n# \u6307\u6807\u5904\u7406\u5668\nsp = dsxindexer.sindexer(klines)\n# \u6ce8\u518c\u81ea\u5b9a\u4e49\u6307\u6807\nsp.register(ABCD)\n# \u6267\u884c\u8ba1\u7b97\u7ed3\u679c\nresult = sp.execute()\n# \u53d6\u6700\u540e\u4e00\u4e2a\nmodel = result[-1]\ndsxindexer.logger.info(model.DATE+\" %s\" % vars(model.ABCD))\n\n```\n\n## \u6307\u6807\u7f16\u5199\u65b9\u5f0f\n\n\u76ee\u524d\u6307\u6807\u652f\u6301\u7cfb\u7edf\u6307\u6807\uff0c\u81ea\u5b9a\u4e49\u6307\u6807\uff0c\u81ea\u5b9a\u4e49\u53ef\u5206\u4e3a\u4e24\u79cd\u65b9\u5f0f\uff1a\u7ee7\u627f\u548c\u5de5\u5382\u65b9\u5f0f\n\n### \u7ee7\u627f\u65b9\u5f0f\n\n```python\nclass MAn(dsxindexer.BaseSindexer):\n    \"\"\"MAn\n    \"\"\"\n    # \u5b9a\u4e49\u6307\u6807\u540d\u79f0\n    __typename__ = \"MAn\"\n\n    def formula(self):\n        return \"\"\"\n        MA5:MA(CLOSE,5);\n        MA30:MA(CLOSE,30);\n        MA60:MA(CLOSE,60);\n        \"\"\"\n# \u6307\u6807\u5904\u7406\u5668\nsp = dsxindexer.sindexer(klines)\nsp.register(MAn)\n# \u6267\u884c\u8ba1\u7b97\u7ed3\u679c\nresult = sp.execute()\n```\n\n### \u5de5\u5382\u65b9\u5f0f\n\n```python\n# \u6307\u6807\u5904\u7406\u5668\nsp = dsxindexer.sindexer(klines)\n# \u901a\u8fc7\u6307\u6807\u5de5\u5382\u81ea\u5b9a\u4e49\u6307\u6807\nMA10 = dsxindexer.factory.create(\"MA10\",\"MA10:MA(CLOSE,10);\")\nsp.register(MA10)\n# \u6267\u884c\u8ba1\u7b97\u7ed3\u679c\nresult = sp.execute()\n```\n\n## \u4f7f\u7528\u7cfb\u7edf\u6307\u6807\n\n\u76ee\u524d\u652f\u6301\u5927\u6982\u51e0\u5341\u4e2a\u7cfb\u7edf\u6307\u6807\uff0c\u540e\u7eed\u4e0d\u65ad\u5b8c\u5584\u4e2d....\n\n\n### \u5e38\u7528\u7cfb\u7edf\u6307\u6807\n```python\n# \u7cfb\u7edf\u9ed8\u8ba4\u6307\u6807\nclass INDEXER:\n    BOLL=\"BOLL\"\n    BRAR=\"BRAR\"\n    CCI=\"CCI\"\n    CDP=\"CDP\"\n    CR=\"CR\"\n    DMA=\"DMA\"\n    EMV=\"EMV\"\n    EXPMA=\"EXPMA\"\n    KDJ=\"KDJ\"\n    MACD=\"MACD\"\n    MIKE=\"MIKE\"\n    OBV=\"OBV\"\n    PSY=\"PSY\"\n    ROC=\"ROC\"\n    RSI=\"RSI\"\n    TRIX=\"TRIX\"\n    VR=\"VR\"\n    WR=\"WR\"\n    WVAD=\"WVAD\"\n```\n\n",
    "bugtrack_url": null,
    "license": "MIT License",
    "summary": "dsxindexer \u662f\u4e00\u4e2a\u6307\u6807\u751f\u6210\u5668\uff0c\u652f\u6301\u5e38\u7528\u6307\u6807\uff0c\u81ea\u5b9a\u4e49\u6269\u5c55\u6307\u6807\u7b97\u6cd5\uff0c\u516c\u5f0f\u7f16\u8f91\u529f\u80fd",
    "version": "1.1.0",
    "project_urls": {
        "Bug Tracker": "https://github.com/dsxkline/dsxindexer/issues",
        "Homepage": "https://github.com/dsxkline/dsxindexer"
    },
    "split_keywords": [
        "\u901a\u8fbe\u4fe1\u6307\u6807",
        "\u516c\u5f0f\u7f16\u8f91\u5668",
        "\u91cf\u5316\u6307\u6807"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "c9aa9855a428126c2ace88bc49cadaf4a64953a2b751fe05cc8c49317e3841bd",
                "md5": "5aeab265aae0d007a81c0134f039bba0",
                "sha256": "84b8b927a66551d70d30b941f2b3996a89dc31256e67600236bb4537a9d6f945"
            },
            "downloads": -1,
            "filename": "dsxindexer-1.1.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "5aeab265aae0d007a81c0134f039bba0",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.6,<4",
            "size": 62643,
            "upload_time": "2023-05-08T08:44:16",
            "upload_time_iso_8601": "2023-05-08T08:44:16.811487Z",
            "url": "https://files.pythonhosted.org/packages/c9/aa/9855a428126c2ace88bc49cadaf4a64953a2b751fe05cc8c49317e3841bd/dsxindexer-1.1.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "fdd2f3b0bf2cb0151fac035a6ef92721aed77cfaf5ef7a89b48a0a9662b07b4d",
                "md5": "e5ff71b150cf681a01bd30d03f1090c4",
                "sha256": "dd7e6600746554f4a305668186dc48dccdfcd7a0e3a7ba29e31cf328ca55641b"
            },
            "downloads": -1,
            "filename": "dsxindexer-1.1.0.tar.gz",
            "has_sig": false,
            "md5_digest": "e5ff71b150cf681a01bd30d03f1090c4",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.6,<4",
            "size": 40157,
            "upload_time": "2023-05-08T08:44:18",
            "upload_time_iso_8601": "2023-05-08T08:44:18.881004Z",
            "url": "https://files.pythonhosted.org/packages/fd/d2/f3b0bf2cb0151fac035a6ef92721aed77cfaf5ef7a89b48a0a9662b07b4d/dsxindexer-1.1.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-05-08 08:44:18",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "dsxkline",
    "github_project": "dsxindexer",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "requirements": [],
    "lcname": "dsxindexer"
}
        
Elapsed time: 0.15834s