playbook/docs/tsl/modules/pytsl_api.md

51 lines
1.1 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# 天软 pyTSL 接口使用说明
## 定位
- 官方 Python SDK面向取数/执行/批量/异步与数据转换。
## 结构索引
- 安装与配置
- pyTSL 接口说明Client / AsyncClient / async_util / Batch / Task / Const / TSResultValue
- pyTSLPy 兼容说明
- 示例与数据类型转换
- 附录与常见问题
## 安装方式(摘要)
- `pip install tspytsl`(在线安装)
- 离线安装与手动部署
## 核心类与模块
- `pyTSL.Client`:同步客户端
- `pyTSL.AsyncClient`:异步客户端
- `pyTSL.async_util`:异步工具函数
- `TSBatch` / `Task`:批量与任务
- `TSResultValue`:统一返回结果封装
- `pyTSL.Const`:常量与字段
## 关键方法(常用)
- `login` / `logout`
- `exec` / `call` / `query`
- `download_list` / `download` / `upload` / `remove`
- `DatetimeToDouble` / `DoubleToDatetime`
- `EncodeStream` / `DecodeStream`
- `DataFrameToTSArray`
## 示例Python
```python
import pyTSL
c = pyTSL.Client("user", "password")
c.login()
result = c.query("select close from market where stock = 'SZ000001' end")
print(result.dataframe())
c.logout()
```