semvec/pypi-packages huggingface dataset:
tdxtrader 0.1.2
通达信预警信号程序化交易

[![PyPI version](https://badge.fury.io/py/tdxtrader.svg)](https://badge.fury.io/py/tdxtrader)
[![Downloads](https://static.pepy.tech/badge/tdxtrader/month)](https://pepy.tech/project/tdxtrader)

# tdxtrader

通达信预警信号程序化交易

> 声明：本项目仅用于学习和研究，不保证交易收益，不作为投资建议，风险自负，请充分使用QMT模拟盘测试。

## 欢迎加入知识星球

![知识星球](./qrcode.png)

## 安装

```shell
pip install tdxtrader
```

## 预警指标设置

设置两个指标，一个作为买入信号，一个作为卖出信号

![预警指标](./cut2.png)

## 预警文件设置

![预警文件](./cut1.png)

## demo

```python
import tdxtrader
# 参数
account_id = 'xxxx' # 账号ID
mini_qmt_path = r'D:\国金证券QMT交易端\userdata_mini' # mini_qmt 路径
file_path = r'D:\new_tdx\sign.txt' # 预警文件路径
interval = 1 # 轮询时间(秒)
buy_sign = 'KDJ买入条件选股' # 买入信号
sell_sign = 'KDJ卖出条件选股' # 卖出信号

def buy_event(stock, xt_trader):
    '''买入数量'''
    return { 
      'size': 100, 
      'price': -1, # 如果是限价，则设置价格
      'type': '市价', # 市价，限价
    }

def sell_event(stock, position, xt_trader):
    '''卖出数量'''
    return { 
      'size': position.can_use_volume, # 卖全仓
      'price': -1,  # 如果是限价，则设置价格
      'type': '市价' # 市价，限价
    }


tdxtrader.start(
    account_id=account_id,
    mini_qmt_path=mini_qmt_path,
    file_path=file_path,
    interval=interval,
    buy_sign=buy_sign,
    sell_sign=sell_sign,
    buy_event=buy_event,
    sell_event=sell_event
)
```

### 限价委托（获取预警价格）

stock对象中包含了当前股票的详细信息，可以通过price属性获取预警时的价格

```python
def buy_event(stock, xt_trader):
    '''买入数量'''
    return { 
      'size': 100, 
      'price': stock.get('price'), # 如果是限价，则设置价格
      'type': '限价', # 市价，限价
    }

def sell_event(stock, position, xt_trader):
    '''卖出数量'''
    return { 
      'size': position.can_use_volume, # 卖全仓
      'price': stock.get('price'),  # 如果是限价，则设置价格
      'type': '限价' # 市价，限价
    }
```
excellentman 1.5.0
A tool for running Newman with parameters from an Excel file
Requires Python: >=3.8

# excellentman
An experimental repo for probably writing tools to execute parameterized newman runs from data in spreadsheets

## Install Newman

1. Download and install [Node.js](https://nodejs.org/en/download/current/).
2. Then run `npm install` in your checkout  

## Installing

`pip install excellentman`

## Usage

`excellentman <EXCEL_FILE> <JSON_COLLECTION> <ENVIRONMENT_FILE>`

Where:
 - *EXCEL_FILE*: is a an excel file where each worksheet contains parameters to be passed into the postman requests
 - *JSON_COLLECTION*: collection of requests, either a URL, or downloaded from postman
 - *ENVIRONMENT_FILE*: an exported Postman environments file

## Example

We've included example data for querying https://www.thecocktaildb.com, in the `examples` directory.

 - `examples/Cocktails.postman_collection.json` - A postman collection for querying the cocktail database
 - `examples/Cocktails.xlsx` - An excel file with multiple worksheets for different types of cocktails
 - `examples/Production Cocktails.postman_environment.json` - An environment file for parameterizing the requests

You can run this:

`excellentman examples/Cocktails.xlsx examples/Cocktails.postman_collection.json "examples/Production Cocktails.postman_environment.json"`

### Custom Field Handling

If you have data in your spreadsheet that needs to be transformed before it gets sent to the API you're working with, you can provide a python file of transformation functions, as in `examples/custom_formats.py`.

We include a trivial example that lowercases the drink names, which you can demonstrate by running:

`excellentman examples/Cocktails.xlsx examples/Cocktails.postman_collection.json "examples/Production Cocktails.postman_environment.json" --custom_formats=examples/custom_formats.py`

### Custom Report Formatting

This tool uses `newman-reporter-htmlextra` to provide an HTML report of the results and can also support `newman-reporter-xunit` to provide an XML report file. You can customize the template used for this report, and pass it in as follows:

`excellentman examples/Cocktails.xlsx examples/Cocktails.postman_collection.json "examples/Production Cocktails.postman_environment.json" --custom_template=examples/example_reporter_template.hbs --xunit_file=xunit_reporter_example.xml`


## Publishing a new version

Update the version in setup.py.

Build the version to publish

`python3 setup.py sdist bdist_wheel`

Publish to testpypi (for now)

`python3 -m twine upload --repository pypi dist/*`